Relates to #129
backend/src/features/ocr/domain/ocr.types.ts
backend/src/features/ocr/external/ocr-client.ts
backend/src/features/ocr/domain/ocr.service.ts
backend/src/features/ocr/api/ocr.controller.ts
backend/src/features/ocr/api/ocr.routes.ts
ManualExtractionResponse
ManualJobResponse
OcrClient.submitManualJob()
/extract/manual
ocrService.submitManualJob()
OcrController.extractManual()
application/pdf
.pdf
%PDF
POST /api/ocr/extract/manual
preHandler: [requireAuth, requireTier('document.scanMaintenanceSchedule')]
GET /api/ocr/jobs/:jobId
OcrService.getJobStatus()
backend/src/features/ocr/tests/unit/ocr-manual.test.ts
Phase: Execution | Agent: Developer | Status: PASS
1. ocr.controller.ts - extractManual (PDF validation)
ocr.controller.ts
2. ocr.service.ts - getJobStatus (410 Gone)
ocr.service.ts
3. ocr.controller.ts - getJobStatus (410 handling)
4. ocr-manual.test.ts - 16 unit tests
ocr-manual.test.ts
document.scanMaintenanceSchedule
Test Suites: 2 passed, 2 total (ocr-receipt + ocr-manual) Tests: 27 passed, 27 total Type-check: PASS (0 errors) Lint: No new warnings
Verdict: PASS | Next: QR post-implementation review
No dependencies set.
The note is not visible to the blocked user.
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