Files
documenso/packages/lib/server-only/ai/envelope/detect-recipients/schema.ts
T
Lucas Smith 7a94ee3b83 feat: add ai detection for recipients and fields (#2271)
Use Gemini to handle detection of recipients and fields within
documents.

Opt in using organisation or team settings.

Replaces #2128 since the branch was cursed and would include
dependencies that weren't even in the lock file.



https://github.com/user-attachments/assets/e6cbb58f-62b9-4079-a9ae-7af5c4f2e4ec
2025-12-03 23:39:41 +11:00

25 lines
932 B
TypeScript

import { RecipientRole } from '@prisma/client';
import { z } from 'zod';
export const ZDetectedRecipientSchema = z.object({
name: z.string().describe('The detected recipient name, leave blank if unknown'),
email: z.string().describe('The detected recipient email, leave blank if unknown'),
role: z
.nativeEnum(RecipientRole)
.optional()
.default(RecipientRole.SIGNER)
.describe(
'The detected recipient role. Use SIGNER for people who need to sign, APPROVER for approvers, CC for people who should receive a copy, VIEWER for view-only recipients',
),
});
export type TDetectedRecipientSchema = z.infer<typeof ZDetectedRecipientSchema>;
export const ZDetectedRecipientsSchema = z.object({
recipients: z
.array(ZDetectedRecipientSchema)
.describe('The list of detected recipients from the document'),
});
export type TDetectedRecipientsSchema = z.infer<typeof ZDetectedRecipientsSchema>;