feat: migrate templates and documents to envelope model

This commit is contained in:
David Nguyen
2025-09-11 18:23:38 +10:00
parent eec2307634
commit bf89bc781b
234 changed files with 8677 additions and 6054 deletions

View File

@ -1,6 +1,8 @@
import { EnvelopeType } from '@prisma/client';
import { prisma } from '@documenso/prisma';
import { buildTeamWhereQuery } from '../../utils/teams';
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
export type DeleteTemplateOptions = {
id: number;
@ -9,10 +11,17 @@ export type DeleteTemplateOptions = {
};
export const deleteTemplate = async ({ id, userId, teamId }: DeleteTemplateOptions) => {
return await prisma.template.delete({
where: {
const { envelopeWhereInput } = await getEnvelopeWhereInput({
id: {
type: 'templateId',
id,
team: buildTeamWhereQuery({ teamId, userId }),
},
type: EnvelopeType.TEMPLATE,
userId,
teamId,
});
return await prisma.envelope.delete({
where: envelopeWhereInput,
});
};