implemented the domain logic + processor endpoints
This commit is contained in:
44
README.md
44
README.md
@@ -59,35 +59,35 @@ Decisions captured:
|
||||
|
||||
Target: `packages/db/schema/*` + new migration files.
|
||||
|
||||
- [ ] Add `mobile_device` table:
|
||||
- [x] Add `mobile_device` table:
|
||||
- Fields: `id`, `externalDeviceId`, `name`, `manufacturer`, `model`, `androidVersion`, `ownerUserId`, `lastPingAt`, `createdAt`, `updatedAt`.
|
||||
- [ ] Add `mobile_sms` table:
|
||||
- [x] Add `mobile_sms` table:
|
||||
- Fields: `id`, `deviceId`, `externalMessageId?`, `sender`, `recipient?`, `body`, `sentAt`, `receivedAt?`, `rawPayload?`, `createdAt`.
|
||||
- [ ] Add `mobile_media_asset` table:
|
||||
- [x] Add `mobile_media_asset` table:
|
||||
- Fields: `id`, `deviceId`, `externalMediaId?`, `mimeType`, `filename?`, `capturedAt?`, `sizeBytes?`, `hash?`, `metadata`, `createdAt`.
|
||||
- [ ] Add indexes for common reads:
|
||||
- [x] Add indexes for common reads:
|
||||
- `mobile_device.lastPingAt`
|
||||
- `mobile_sms.deviceId + sentAt desc`
|
||||
- `mobile_media_asset.deviceId + createdAt desc`
|
||||
- [ ] Export schema from `packages/db/schema/index.ts`.
|
||||
- [x] Export schema from `packages/db/schema/index.ts`.
|
||||
|
||||
Definition of done:
|
||||
|
||||
- [ ] Tables and indexes exist in schema + migration files.
|
||||
- [ ] Naming matches existing conventions.
|
||||
- [x] Tables and indexes exist in schema + migration files.
|
||||
- [x] Naming matches existing conventions.
|
||||
|
||||
### Phase 2: Logic Domain (`@pkg/logic`)
|
||||
|
||||
Target: `packages/logic/domains/mobile/*` (new domain).
|
||||
|
||||
- [ ] Create `data.ts` with Valibot schemas and inferred types for:
|
||||
- [x] Create `data.ts` with Valibot schemas and inferred types for:
|
||||
- register device payload
|
||||
- ping payload
|
||||
- sms sync payload
|
||||
- media sync payload
|
||||
- admin query filters/pagination
|
||||
- [ ] Create `errors.ts` with domain error constructors using `getError`.
|
||||
- [ ] Create `repository.ts` with ResultAsync operations for:
|
||||
- [x] Create `errors.ts` with domain error constructors using `getError`.
|
||||
- [x] Create `repository.ts` with ResultAsync operations for:
|
||||
- upsert device
|
||||
- update last ping
|
||||
- bulk insert sms (idempotent)
|
||||
@@ -98,33 +98,33 @@ Target: `packages/logic/domains/mobile/*` (new domain).
|
||||
- list media by device (paginated, latest first)
|
||||
- delete single media asset
|
||||
- delete device (removed all child sms, and media assets, and by extensionn the associated files in r2+db as well)
|
||||
- [ ] Create `controller.ts` as use-case layer.
|
||||
- [ ] Wrap repository/controller operations with `traceResultAsync` and include `fctx`.
|
||||
- [x] Create `controller.ts` as use-case layer.
|
||||
- [x] Wrap repository/controller operations with `traceResultAsync` and include `fctx`.
|
||||
|
||||
Definition of done:
|
||||
|
||||
- [ ] Processor and main app can consume this domain without direct DB usage.
|
||||
- [ ] No ad-hoc thrown errors in domain flow; Result pattern is preserved.
|
||||
- [x] Processor and main app can consume this domain without direct DB usage.
|
||||
- [x] No ad-hoc thrown errors in domain flow; Result pattern is preserved.
|
||||
|
||||
### Phase 3: Processor Ingestion API (`apps/processor`)
|
||||
|
||||
Target: `apps/processor/src/domains/mobile/router.ts`.
|
||||
|
||||
- [ ] Replace stub endpoints with full handlers:
|
||||
- [x] Replace stub endpoints with full handlers:
|
||||
- `POST /register`
|
||||
- `PUT /ping`
|
||||
- `PUT /sms/sync`
|
||||
- `PUT /media/sync`
|
||||
- [ ] Validate request body using schemas from `@pkg/logic/domains/mobile/data`.
|
||||
- [ ] Build `FlowExecCtx` per request (flow id always; user/session when available).
|
||||
- [ ] Call mobile controller methods; return `{ data, error }` response shape.
|
||||
- [ ] Add basic endpoint protection agreed in Phase 0.
|
||||
- [ ] Add request-level structured logging for success/failure.
|
||||
- [x] Validate request body using schemas from `@pkg/logic/domains/mobile/data`.
|
||||
- [x] Build `FlowExecCtx` per request (flow id always; user/session when available).
|
||||
- [x] Call mobile controller methods; return `{ data, error }` response shape.
|
||||
- [x] Add basic endpoint protection agreed in Phase 0.
|
||||
- [x] Add request-level structured logging for success/failure.
|
||||
|
||||
Definition of done:
|
||||
|
||||
- [ ] Endpoints persist data into new tables.
|
||||
- [ ] Endpoint failures return normalized domain errors.
|
||||
- [x] Endpoints persist data into new tables.
|
||||
- [x] Endpoint failures return normalized domain errors.
|
||||
|
||||
### Phase 4: Admin UI in `apps/main`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user