feat(document-templates): delete TipTap-to-pdfme bridge

Phase 1 / commit 12 of 14 — strips out the 571-line tiptap-to-pdfme
serializer and every code path that depended on it. TipTap document
templates remain as Documenso-template seed bodies; the CRM no longer
renders them to PDF in-app.

Deleted:
  src/lib/pdf/tiptap-to-pdfme.ts                                (571 LOC)
  src/lib/pdf/templates/eoi-standard-inapp.ts                   (337 LOC)
  src/app/api/v1/admin/templates/preview/route.ts
  src/app/api/v1/document-templates/[id]/generate/route.ts
  src/app/api/v1/document-templates/[id]/generate-and-send/route.ts
  src/lib/services/document-templates.ts:generateFromTemplate (~140 LOC)
  src/lib/services/document-templates.ts:generateAndSend       (~40 LOC)
  src/lib/validators/document-templates.ts:generateAndSendSchema
  src/lib/validators/document-templates.ts:previewAdminTemplateSchema
  tests/unit/tiptap-serializer.test.ts (old bridge tests)

Preserved as src/lib/pdf/tiptap-validation.ts (~70 LOC):
  - validateTipTapDocument()  — still used to reject unsupported nodes
    on save in the admin template editor
  - TEMPLATE_VARIABLES        — drives the merge-token picker in the
    admin template form + preview UI

generateAndSign() now throws a clear ValidationError when a non-EOI
template tries the in-app pathway. Use a Documenso template, or wait
for the deferred AcroForm-fill admin-upload feature.

seed-data.ts: "Standard EOI (in-app)" template row now seeds with stub
bodyHtml + small MERGE_FIELDS array; the deleted HTML helper was never
actually rendered (in-app EOI is pdf-lib AcroForm fill on the source
PDF — generateEoiPdfFromTemplate, unchanged).

After this commit, pdfme has zero callers left. Commit 14 drops the
deps and the generate.ts shim.

1298/1298 vitest green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 21:11:23 +02:00
parent ed2424cc68
commit 411d0764e8
14 changed files with 137 additions and 1497 deletions

View File

@@ -306,8 +306,10 @@ describe('generateAndSign — inapp pathway', () => {
expect(pdfModule.generatePdf).not.toHaveBeenCalled();
});
it('falls back to HTML→pdfme for non-EOI template types', async () => {
// Create a non-EOI template inline.
it('rejects non-EOI template types on the inapp pathway', async () => {
// Non-EOI in-app PDF rendering was removed in the PDF stack overhaul
// (see docs/superpowers/specs/2026-05-12-pdf-stack-overhaul-design.md).
// The only surviving in-app pathway is EOI via pdf-lib AcroForm fill.
const [other] = await db
.insert(documentTemplates)
.values({
@@ -319,31 +321,16 @@ describe('generateAndSign — inapp pathway', () => {
})
.returning();
const fillModule = await import('@/lib/pdf/fill-eoi-form');
const pdfModule = await import('@/lib/pdf/generate');
const client = await import('@/lib/services/documenso-client');
vi.mocked(client.createDocument).mockResolvedValue({
id: 'doc-welcome',
status: 'PENDING',
recipients: [],
});
vi.mocked(client.sendDocument).mockResolvedValue({
id: 'doc-welcome',
status: 'PENDING',
recipients: [],
});
await generateAndSign(
other!.id,
setup.portId,
{ clientId: setup.clientId },
[{ name: 'C', email: 'c@x.com', role: 'signer', signingOrder: 1 }],
'inapp',
{ ...meta, portId: setup.portId },
);
expect(pdfModule.generatePdf).toHaveBeenCalled();
expect(fillModule.generateEoiPdfFromTemplate).not.toHaveBeenCalled();
await expect(
generateAndSign(
other!.id,
setup.portId,
{ clientId: setup.clientId },
[{ name: 'C', email: 'c@x.com', role: 'signer', signingOrder: 1 }],
'inapp',
{ ...meta, portId: setup.portId },
),
).rejects.toThrow(/welcome_letter/);
});
});