feat(eoi): dual-path generateAndSign (inapp + documenso-template)

generateAndSign now accepts a `pathway` parameter:

- `inapp` (existing): resolve in-app template -> pdfme -> MinIO -> Documenso
  createDocument + sendDocument.
- `documenso-template` (new): build EOI context from interestId, assemble
  the Documenso template payload, and call Documenso's
  /api/v1/templates/{id}/generate-document. Documenso owns the PDF; we
  still record a documents row for tracking.

Adds generateDocumentFromTemplate helper to the Documenso client and new
env vars (DOCUMENSO_TEMPLATE_ID_EOI + client/developer/approval recipient
IDs) with defaults matching the legacy flow. Covered by 6 new integration
tests (637/637 green).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-04-24 18:43:41 +02:00
parent 13d07e3906
commit f8255cedb8
6 changed files with 414 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ export const generateAndSendSchema = generateSchema.extend({
});
export const generateAndSignSchema = generateSchema.extend({
pathway: z.enum(['inapp', 'documenso-template']).default('inapp'),
signers: z
.array(
z.object({
@@ -47,7 +48,8 @@ export const generateAndSignSchema = generateSchema.extend({
signingOrder: z.number().int().min(1),
}),
)
.min(1),
.optional()
.default([]),
});
export type CreateTemplateInput = z.infer<typeof createTemplateSchema>;