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:
@@ -42,12 +42,26 @@ import {
|
||||
interestBerths,
|
||||
documentTemplates,
|
||||
} from './schema';
|
||||
import {
|
||||
getStandardEoiTemplateHtml,
|
||||
STANDARD_EOI_MERGE_FIELDS,
|
||||
} from '@/lib/pdf/templates/eoi-standard-inapp';
|
||||
import berthSnapshot from './seed-data/berths.json';
|
||||
|
||||
// Seed body for the default "Standard EOI" document_templates row.
|
||||
// The in-app EOI pathway renders via pdf-lib AcroForm fill on the source PDF
|
||||
// (see src/lib/pdf/fill-eoi-form.ts), not from this HTML. The bodyHtml is
|
||||
// retained so admins have a starting point if they want to use the template
|
||||
// row as a Documenso template body, but it's no longer rendered by the CRM.
|
||||
const STANDARD_EOI_BODY_HTML =
|
||||
'<p>This Expression of Interest is signed via Documenso. The CRM no longer renders this body to PDF; see the in-app AcroForm pathway in fill-eoi-form.ts.</p>';
|
||||
const STANDARD_EOI_MERGE_FIELDS = [
|
||||
'date.today',
|
||||
'date.year',
|
||||
'port.name',
|
||||
'client.fullName',
|
||||
'client.primaryEmail',
|
||||
'yacht.name',
|
||||
'berth.mooringNumber',
|
||||
'interest.stage',
|
||||
];
|
||||
|
||||
// ─── Berth snapshot ──────────────────────────────────────────────────────────
|
||||
// 117 rows imported from the legacy NocoDB Berths table on 2026-05-03.
|
||||
// Refresh via `pnpm tsx scripts/import-berths-from-nocodb.ts --update-snapshot`.
|
||||
@@ -798,7 +812,7 @@ export async function seedPortData(portId: string, portSlug: string): Promise<Se
|
||||
description:
|
||||
'Default Expression of Interest / Letter of Intent template, rendered in-app via pdfme. Use for ports that prefer in-app PDF generation over the Documenso template path.',
|
||||
templateType: 'eoi',
|
||||
bodyHtml: getStandardEoiTemplateHtml(),
|
||||
bodyHtml: STANDARD_EOI_BODY_HTML,
|
||||
mergeFields: STANDARD_EOI_MERGE_FIELDS,
|
||||
isActive: true,
|
||||
createdBy: SEED_USER_ID,
|
||||
|
||||
Reference in New Issue
Block a user