Commit 16ea765
committed
feat(api): add import job REST API and service layer
Add REST API endpoints and business logic for GEDCOM import job management:
API Endpoints (6):
- POST /api/import-jobs - Create job with file upload
- GET /api/import-jobs - List user's jobs (paginated, filterable)
- GET /api/import-jobs/{job_id} - Get job detail with stages
- POST /api/import-jobs/{job_id}/pause - Pause running job
- POST /api/import-jobs/{job_id}/resume - Resume paused job
- DELETE /api/import-jobs/{job_id} - Cancel job and delete files
Service Layer:
- create_import_job() - Upload GEDCOM, transition UPLOADED → QUEUED
- get_job_with_stages() - Fetch job with pipeline stages
- list_user_jobs() - Paginated job list with filtering
- pause_job() / resume_job() - Job lifecycle management
- cancel_job() - Delete job and cleanup storage
- claim_next_job() - Worker job claiming (lease-based)
- complete_stage() / fail_job() - Stage execution updates
Database Changes:
- Add order field to ImportJobStage for pipeline ordering
- Change ImportJob.user_id from UUID to string (for Google JWT subject IDs)
Tests:
- 17 comprehensive endpoint tests (100% passing)
- Coverage: routes 72%, service layer 26% (worker functions untested)
File Storage:
- Pattern: /data/gedcom/{user_id}/{job_id}/original.ged
- user_id is string (Google subject), job_id is UUID
State Machine:
- Jobs: UPLOADED → QUEUED → IN_PROGRESS → PAUSED/COMPLETED/FAILED/CANCELLED
- Stages: PENDING → IN_PROGRESS → COMPLETED/FAILED/RETRYING1 parent 1ee23c4 commit 16ea765
7 files changed
Lines changed: 1473 additions & 3 deletions
File tree
- apps/api
- src/api
- routes
- services
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
151 | 152 | | |
152 | 153 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | | - | |
| 98 | + | |
| 99 | + | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| |||
0 commit comments