feat(05-01): add preparePdf utility and fields/prepare API routes

- Installed @cantoo/pdf-lib for server-side PDF mutation
- Created src/lib/pdf/prepare-document.ts with preparePdf function using atomic tmp->rename write pattern
- form.flatten() called before drawing signature rectangles
- Created GET/PUT /api/documents/[id]/fields routes for signature field storage
- Created POST /api/documents/[id]/prepare route that calls preparePdf and transitions status to Sent
- Fixed pre-existing null check error in scripts/debug-inspect2.ts (Rule 3: blocking build)
- Build compiles successfully with 2 new API routes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chandler Copeland
2026-03-19 23:54:41 -06:00
parent d67130da20
commit c81e8ea838
6 changed files with 353 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ config({ path: path.resolve(process.cwd(), '.env.local') });
for (const el of loginLinks) {
const text = await el.textContent().catch(() => '');
const href = await el.getAttribute('href').catch(() => '');
if (/login|sign.?in|log.?in|get started|access/i.test(text + href)) {
if (/login|sign.?in|log.?in|get started|access/i.test((text ?? '') + (href ?? ''))) {
console.log('Found login element:', text?.trim().slice(0,60), href?.slice(0,80));
}
}