refactor(backend): extract reusable ingestDocument() core
Moves the document ingestion pipeline (R2 upload, structure tree, DOCX→PDF conversion, document_versions V1 row, status update) from handleDocumentUpload into ingestDocument() in lib/ingest.ts so that the upcoming mail-attachment-filing task can reuse it without touching the HTTP layer. The countPdfPages and extractStructureTree helpers are also moved (not duplicated). The upload routes remain behaviourally identical: same HTTP status codes, same response shape, same audit event. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Repository | IZGD/legal-platform |
|---|---|
| Author | SW3xyz <alain@studioweb3.xyz> |
| Authored | |
| Parents | b606eb3f |
| Stats | 3 files changed , +295 , -193 |
| Part of | Google Workspace backend: OAuth, encrypted tokens, Gmail/Calendar, mail triage |
Capture this commit into my fork
Download a Markdown prompt that tells Claude how to port this
exact commit into your working tree. Run it via
claude -p < capture-commit-634ad9cb.md
from inside the repo you want the change in.