updates on the api endpoints on the customer page and more
This commit is contained in:
64
CLAUDE.md
64
CLAUDE.md
@@ -45,7 +45,7 @@ customers.
|
||||
prior sessions]**
|
||||
|
||||
- **Backend**: Go + Fiber, deployed on **Kubernetes**, at `api.doormile.com`.
|
||||
200 registered routes **[verified this session, exact count]** — see §7.
|
||||
220 registered routes **[verified 2026-09-02, exact count]** — see §7.
|
||||
This is the primary booking/assignment API and the primary trigger for
|
||||
miler assignment, calling the AI decision layer with a 5-second timeout
|
||||
fallback so a slow AI response never blocks a booking.
|
||||
@@ -196,7 +196,8 @@ websocket routes. **[verified this session]**
|
||||
`MilerSkipDelivery`, added this session). `ConsignmentHistory` (event
|
||||
log), `ConsignmentException` (Lost/Damaged/Misrouted/Receiver_Refused/
|
||||
Missing_Contents/Undeliverable).
|
||||
- `Hub`, `Vehicle`, `Tripsheet`, `TripsheetItem`, `DeliveryProof`.
|
||||
- `Hub`, `Vehicle`, `Tripsheet`, `TripsheetItem`, `DeliveryProof`. `Hub` is what
|
||||
the rider app calls a **Base** — same row, different word (see §12).
|
||||
- `AppUser` (`appusers`) — shared login table for staff/miler/admin roles
|
||||
(`Roleid`: 1 admin, 3 manager, 4 rep/exec, 5 miler, 6 hub staff via a
|
||||
separate `HubStaffAccount` table). `MilerProfile` — actual rider profile
|
||||
@@ -402,6 +403,65 @@ code compiled correctly the first time it hit a real toolchain.
|
||||
|
||||
---
|
||||
|
||||
## 8.4 Logistics pickup-source & base-handover flow (2026-09-02)
|
||||
|
||||
**[verified this session]** — closes requests 25–31 on the Miler logistics line.
|
||||
Full contract, state-transition tables and wire values:
|
||||
[`docs/logistics-base-handover.md`](docs/logistics-base-handover.md).
|
||||
|
||||
**Vocabulary.** The wire says *hub*; the rider app renders it as *Base*. Never
|
||||
change a wire value to match the app's wording: `inward_at_hub`,
|
||||
`Inwarded_at_Hub`, `next_hub`, `pickup_source_type: "hub"` stay exactly as spelt.
|
||||
|
||||
**Feature flag `MILER_HUB_HANDOVER_ENABLED`** (default **off**, read per request,
|
||||
same pattern as `MILER_COLLECTED_STATE_ENABLED`). On, a hub-routed parcel stops
|
||||
at `Created` at pickup-complete and only reaches `Inwarded_at_Hub` when the
|
||||
handover is recorded. Off (today), pickup-complete marks it `Inwarded_at_Hub`
|
||||
immediately — which is what the deployed rider app expects. **Do not turn it on
|
||||
until a rider build that calls `inward-at-hub` is live**, or every intercity
|
||||
parcel strands on `Created` with no way to advance it. Everything else in this
|
||||
work is ungated.
|
||||
|
||||
**New endpoints (4):**
|
||||
|
||||
| Method | Path | Handler |
|
||||
|---|---|---|
|
||||
| POST | `/miler/consignments/:id/inward-at-hub` | `MilerInwardConsignmentAtHub` |
|
||||
| GET | `/miler/bases` | `MilerGetBases` |
|
||||
| GET | `/hub/inbound/expected` | `GetHubInboundExpected` |
|
||||
| POST | `/hub/inbound/:id/reconcile` | `ReconcileHubInbound` |
|
||||
|
||||
**New columns** (additive, nullable, `AutoMigrate`; no CHECK constraint needed
|
||||
widening — `Created` was already permitted on `consignments`):
|
||||
`pickupbookings.pickupsourcetype`, `pickupbookings.pickuphubid`,
|
||||
`consignments.inwardedat`.
|
||||
|
||||
**Conventions added — reuse these, don't reimplement:**
|
||||
- `renderBase(hub)` (`controllers/logisticsHandoverController.go`) is the ONE
|
||||
shape a base is returned in — all six fields, everywhere. A test enforces the
|
||||
count, because five of six leaves a rider unable to navigate.
|
||||
- `nextActionForConsignment(status)` is the ONE definition of what a rider does
|
||||
next. pickup-complete, the queue read and the consignment read all call it, so
|
||||
a poll can never disagree with the pivot.
|
||||
- `resolveHandoverHub(booking, riderHubID)` decides which base a parcel goes to.
|
||||
Backend decides; the app never picks a base.
|
||||
- `pickupSource(booking, customerName)` resolves type/id/name/address for any
|
||||
booking row, in the miler queue, the hub dispatch board and the admin detail.
|
||||
- `scopeConsignmentsToOwnTenant(c, query)` (`hubInboundController.go`) is the
|
||||
consignment counterpart of `scopeBookingsToOwnTenant` — use it on any new
|
||||
hub-console consignment query.
|
||||
|
||||
**Two pre-existing bugs fixed in passing:** a hub-routed pickup left its
|
||||
`BookingAssignment` open forever, so the rider could never go off duty
|
||||
(`MilerEndDuty` refuses while any assignment is Assigned/Accepted); and the
|
||||
no-rider-hub fallback took whichever hub row an unordered query returned first,
|
||||
now nearest-active-base by haversine.
|
||||
|
||||
**Not verified:** no integration test has hit the 4 new endpoints; the migration
|
||||
has not run against a real DB. `go build`, `go vet` and `go test ./...` all pass.
|
||||
|
||||
---
|
||||
|
||||
## 9. Current blockers & open work (whole-project level)
|
||||
|
||||
**[carried forward]**
|
||||
|
||||
Reference in New Issue
Block a user