Skip to content

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

Closed
Boy-Offi9 wants to merge 1 commit into
devfrom
feat/order-status-history
Closed

Boy-Offi9 wants to merge 1 commit into
devfrom
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

Paused: P4 starts later. Migration, repository writes, actor mapping and tests are done; docs and the PR are not.

Co-authored-by: Yousef Ahmed Maher <ya1770620@gmail.com>
@Boy-Offi9 Boy-Offi9 closed this Dec 5, 2026
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

2 participants