mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
7a94ee3b83
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
25 lines
932 B
TypeScript
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>;
|