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,11 +1,11 @@
import { Prisma } from '@prisma/client';
import { EnvelopeType, Prisma } from '@prisma/client';
import { buildTeamWhereQuery } from '@documenso/lib/utils/teams';
import { prisma } from '@documenso/prisma';
export type GetRecipientSuggestionsOptions = {
userId: number;
teamId?: number;
teamId: number;
query: string;
};
@ -37,7 +37,8 @@ export const getRecipientSuggestions = async ({
const recipients = await prisma.recipient.findMany({
where: {
document: {
envelope: {
type: EnvelopeType.DOCUMENT,
team: buildTeamWhereQuery({ teamId, userId }),
},
...nameEmailFilter,
@ -45,7 +46,7 @@ export const getRecipientSuggestions = async ({
select: {
name: true,
email: true,
document: {
envelope: {
select: {
createdAt: true,
},
@ -53,7 +54,7 @@ export const getRecipientSuggestions = async ({
},
distinct: ['email'],
orderBy: {
document: {
envelope: {
createdAt: 'desc',
},
},