Files
esign/packages/trpc/server/organisation-router/get-organisation-email-domain.ts
zooqueen fb4e3df0e3 rename: @hanzo/sign-* → @hanzo/esign-* (full eSign brand consistency)
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign).
Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files)
and align docker/Dockerfile turbo --scope/--filter to the actual remix
package name @hanzo/esign (was a pre-existing mismatch with -remix that
broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
2026-06-21 19:56:09 -07:00

45 lines
1.2 KiB
TypeScript

import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@hanzo/esign-lib/constants/organisations';
import { AppError, AppErrorCode } from '@hanzo/esign-lib/errors/app-error';
import { buildOrganisationWhereQuery } from '@hanzo/esign-lib/utils/organisations';
import { prisma } from '@hanzo/esign-prisma';
import {
ZGetOrganisationEmailDomainRequestSchema,
ZGetOrganisationEmailDomainResponseSchema,
} from './get-organisation-email-domain.types';
type GetOrganisationEmailDomainOptions = {
userId: number;
emailDomainId: string;
};
export const getOrganisationEmailDomain = async ({
userId,
emailDomainId,
}: GetOrganisationEmailDomainOptions) => {
const emailDomain = await prisma.emailDomain.findFirst({
where: {
id: emailDomainId,
organisation: buildOrganisationWhereQuery({
organisationId: undefined,
userId,
roles: ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_ORGANISATION'],
}),
},
omit: {
privateKey: true,
},
include: {
emails: true,
},
});
if (!emailDomain) {
throw new AppError(AppErrorCode.NOT_FOUND, {
message: 'Email domain not found',
});
}
return emailDomain;
};