π Description
Settlement.status ("pending" | "executed" | "cancelled") is central to the settlement lifecycle, but SettlementService.list only accepts anchor/asset filters β there's no way to ask GET /api/v1/settlements for, say, only pending settlements, even though routes/metrics.ts already computes pendingSettlements internally via the same kind of filter.
π§© Requirements and context
- Extend
SettlementService.list's filters parameter to accept an optional status, validated against the SettlementStatus union (reject anything else with 400).
- Wire
?status= through routes/settlements.ts's GET / handler.
- Combine correctly with existing
?anchor=/?asset= filters, sorting, and pagination.
π οΈ Suggested execution
- Modify
src/services/settlementService.ts's list to accept and validate status.
- Modify
src/routes/settlements.ts's GET / handler to parse req.query.status.
- Update
src/openapi.ts's /api/v1/settlements GET parameters.
- Add tests in
src/services/settlementService.test.ts and src/routes/settlements.test.ts covering each status value and an invalid value.
β
Acceptance criteria
π Security notes
N/A β read-path filter over already-exposed settlement lifecycle data.
π Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
π Description
Settlement.status("pending" | "executed" | "cancelled") is central to the settlement lifecycle, butSettlementService.listonly acceptsanchor/assetfilters β there's no way to askGET /api/v1/settlementsfor, say, onlypendingsettlements, even thoughroutes/metrics.tsalready computespendingSettlementsinternally via the same kind of filter.π§© Requirements and context
SettlementService.list'sfiltersparameter to accept an optionalstatus, validated against theSettlementStatusunion (reject anything else with 400).?status=throughroutes/settlements.ts'sGET /handler.?anchor=/?asset=filters, sorting, and pagination.π οΈ Suggested execution
src/services/settlementService.ts'slistto accept and validatestatus.src/routes/settlements.ts'sGET /handler to parsereq.query.status.src/openapi.ts's/api/v1/settlementsGETparameters.src/services/settlementService.test.tsandsrc/routes/settlements.test.tscovering each status value and an invalid value.β Acceptance criteria
GET /api/v1/settlements?status=pendingreturns only pending settlements.?status=value (not one of the three valid statuses) returns 400.π Security notes
N/A β read-path filter over already-exposed settlement lifecycle data.
π Guidelines