Skip to content

feat: order status history and an order 360 timeline API - #338

Open
Boy-Offi9 wants to merge 4 commits into
Delivery-Plus0:devfrom
Boy-Offi9:feat/order-status-history
Open

Boy-Offi9 wants to merge 4 commits into
Delivery-Plus0:devfrom
Boy-Offi9:feat/order-status-history

Conversation

@Boy-Offi9

@Boy-Offi9 Boy-Offi9 commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements #217: the order's status history and the staff Order 360 timeline API.

Related issue

Closes #217

Changes made

order-service

  • order_status_history (migration 009, entity): one append-only row per transition — orderId, from, to, actorType (CUSTOMER/RESTAURANT/DRIVER/SYSTEM/STAFF), actorId, reason, at — written in the same transaction as every status compare-and-set in orders.repository.ts (and the creation row in create), so every applied transition leaves exactly one row. Only the CAS winner writes. Backfill is not possible; documented in the migration and in docs/services/order-service.md.
  • GET /admin/orders/:id (support.read): the full staff view — items and prices, the fee split, the drop-off snapshot, the payment line, without the internal fee-split columns.
  • GET /admin/orders/:id/timeline (support.read): one merged, time-sorted list of {at, source, type, actor, details} from the order history plus three new internal slices. A source that doesn't answer is reported in unavailable, never made up. Internal notes (STAFF_NOTE) arrive with feat: support actions (cancel, refund, re-dispatch, internal notes) #219.
  • Actor mapping (historyActorFor): JWT role → actor type; SYSTEM callers carry no person (sub is a service identity); STAFF keeps the admin's id.

payment-service — GET /internal/payments/orders/:orderId/timeline (SYSTEM, caller-checked): every payment attempt with its outcome, and the refund with who asked.

delivery-service — GET /internal/deliveries/orders/:orderId/timeline (SYSTEM): created / assigned (with driver) / picked up / completed / cancelled from the compare-and-set timestamps.

notification-service — GET /internal/notifications/orders/:orderId/timeline (SYSTEM): the stage notifications as types and times only (matched on params.orderId); no message bodies in staff views.

Contract & docs — admin OpenAPI routes added and regenerated (docs/openapi/admin.json); docs/services/{order,payment,delivery,notification}-service.md, env vars (PAYMENT_SERVICE_URL, DELIVERY_SERVICE_URL, NOTIFICATION_SERVICE_URL) and .project-context/16-current-state.md updated in the same PR.

Testing performed

  • npm run verify (lint + all workspace tests + build) passes; 743 tests green.
  • New tests: actor mapping, history entity, the two admin routes (permission metadata + service delegation), the timeline merge (ordering, unavailable sources, reason passthrough), staff-view fee-split stripping.

Breaking changes

None. Additive migration (009), additive admin routes, additive internal routes.

Documentation changes

Listed above; all in this PR.

Checklist

  • Tests and build pass locally
  • No secrets or generated artifacts are included
  • API and event contract changes are documented
  • Security and authorization impact was considered
  • Docker or configuration changes were validated

…API (Delivery-Plus0#217)

- order_status_history: one append-only row per transition, written in the same
  transaction as every status compare-and-set (and the creation row with the order);
  actorType CUSTOMER/RESTAURANT/DRIVER/SYSTEM/STAFF with the person behind it, and
  the reason when one was given. No backfill for orders before this ships.
- GET /admin/orders/:id: the full staff view (items, fee split, drop-off snapshot,
  payment line), support.read
- GET /admin/orders/:id/timeline: one merged, time-sorted list of the order history
  plus payment-, delivery- and notification-service slices over new internal SYSTEM
  routes (ADR 001); a source that doesn't answer is listed as unavailable, never made
  up. Internal notes arrive with Delivery-Plus0#219.

Closes Delivery-Plus0#217
…tion on Windows)

The Trivy image scan blocks every service image on the critical cross-spawn
advisory; an override in the root package.json moves the lockfile to the fixed
release. Build-only transitive dependency; no runtime behaviour change.
…relation mapped a second orderId column and broke inserts in the e2e seed

The entity had both a @manytoone(() => Order) relation and an explicit
orderId column; TypeORM mapped orderId twice, so every INSERT listed the
column twice and failed with 'column "orderId" of relation
"order_status_history" specified more than once'. The history is never
loaded through an Order, so the FK lives in the migration only.
…urce

The e2e stack boots the app through AppModule's forRoot, which still
listed only [Order, OrderItem] — every history insert failed with
EntityMetadataNotFoundError in the Integration workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: order status history and an order 360 timeline API

1 participant