Files
documenso/packages/lib/server-only/field/get-completed-fields-for-token.ts
David Nguyen 7f09ba72f4 feat: add envelopes (#2025)
This PR is handles the changes required to support envelopes. The new
envelope editor/signing page will be hidden during release.

The core changes here is to migrate the documents and templates model to
a centralized envelopes model.

Even though Documents and Templates are removed, from the user
perspective they will still exist as we remap envelopes to documents and
templates.
2025-10-14 21:56:36 +11:00

38 lines
838 B
TypeScript

import { EnvelopeType, SigningStatus } from '@prisma/client';
import { prisma } from '@documenso/prisma';
export type GetCompletedFieldsForTokenOptions = {
token: string;
};
// Note: You many need to filter this on a per envelope item ID basis.
export const getCompletedFieldsForToken = async ({ token }: GetCompletedFieldsForTokenOptions) => {
return await prisma.field.findMany({
where: {
envelope: {
type: EnvelopeType.DOCUMENT,
recipients: {
some: {
token,
},
},
},
recipient: {
signingStatus: SigningStatus.SIGNED,
},
inserted: true,
},
include: {
signature: true,
recipient: {
select: {
name: true,
email: true,
signingStatus: true,
},
},
},
});
};