feat: Backend OCR manual proxy endpoint (#129) #144
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Relates to #129
Milestone 6: Backend OCR Manual Proxy Endpoint
Files
backend/src/features/ocr/domain/ocr.types.tsbackend/src/features/ocr/external/ocr-client.tsbackend/src/features/ocr/domain/ocr.service.tsbackend/src/features/ocr/api/ocr.controller.tsbackend/src/features/ocr/api/ocr.routes.tsRequirements
ManualExtractionResponseandManualJobResponsetypes matching Python API responseOcrClient.submitManualJob()method that POSTs to Python/extract/manualwith PDF file and optional vehicleIdocrService.submitManualJob()with file validation (200MB max, PDF only)OcrController.extractManual()validates uploaded file:application/pdfOR filename ends.pdf%PDFPOST /api/ocr/extract/manualroute withpreHandler: [requireAuth, requireTier('document.scanMaintenanceSchedule')]GET /api/ocr/jobs/:jobIdhandles manual job polling and returns ManualJobResponseOcrService.getJobStatus()returns 410 Gone if job not found (Redis TTL expired). Message: "Job expired (max 2 hours). Please resubmit."Acceptance Criteria
Tests
backend/src/features/ocr/tests/unit/ocr-manual.test.ts(NEW)Milestone: Execution Complete
Phase: Execution | Agent: Developer | Status: PASS
Changes Made
1.
ocr.controller.ts- extractManual (PDF validation)application/pdfOR filename ending.pdf(browser fallback)%PDFmagic bytes validation on first 4 bytes after reading file buffer2.
ocr.service.ts- getJobStatus (410 Gone)3.
ocr.controller.ts- getJobStatus (410 handling)4.
ocr-manual.test.ts- 16 unit testsdocument.scanMaintenanceScheduleTest Results
Acceptance Criteria Verification
Verdict: PASS | Next: QR post-implementation review