feat(documents): Phase A schema + service skeletons

Adds Phase A data model deltas to documents/templates and the new
document_watchers table. Introduces createFromWizard/createFromUpload
stubs, getDocumentDetail aggregator, cancelDocument flow, signed-doc
email composer, reservation agreement context, and notifyDocumentEvent
fan-out. Validator update accepts new template formats with html-only
bodyHtml requirement. EOI cadence backfilled to 1 day to preserve
current effective behaviour.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-04-28 02:12:05 +02:00
parent d8ac62f6f4
commit 0eff6050ae
11 changed files with 9961 additions and 72 deletions

View File

@@ -15,7 +15,9 @@ const mergeFieldsSchema = z
},
);
export const createTemplateSchema = z.object({
export const templateFormats = ['html', 'pdf_form', 'pdf_overlay', 'documenso_render'] as const;
const createTemplateBaseSchema = z.object({
name: z.string().min(1).max(200),
description: z.string().max(500).optional(),
templateType: z.enum([
@@ -26,12 +28,18 @@ export const createTemplateSchema = z.object({
'correspondence',
'custom',
]),
bodyHtml: z.string().min(1),
templateFormat: z.enum(templateFormats).default('html'),
bodyHtml: z.string().min(1).optional(),
mergeFields: mergeFieldsSchema,
isActive: z.boolean().default(true),
});
export const updateTemplateSchema = createTemplateSchema.partial();
export const createTemplateSchema = createTemplateBaseSchema.refine(
(data) => data.templateFormat !== 'html' || (data.bodyHtml && data.bodyHtml.length > 0),
{ path: ['bodyHtml'], message: 'bodyHtml is required when templateFormat is html' },
);
export const updateTemplateSchema = createTemplateBaseSchema.partial();
export const listTemplatesSchema = baseListQuerySchema.extend({
templateType: z.string().optional(),