refactor:centralize order status rules in shared package #24

Open
aziz_28002 wants to merge 1 commits from refactor/dg-4-order-status-rules into master
Collaborator

Summary

This refactor puts the order status rules in one place and doesn't change behavior.

Ticket / Assignment

What changed

  • packages/shared/src/order-status.ts: each action now has its own list of allowed statuses.
  • apps/api/src/orders/order-status.ts: removed. rule now imported from @orderops/shared/order-status.
  • apps/api/src/orders/order-repository.ts: findOrderItemRecord now returns the order status as OrderStatus, the same way findOrderDetail does, so update-order-item.ts no longer needs the as never cast.
  • apps/web/src/orders/order-page.tsx: uses the shared rules

How to test

bun run test
bun run build:web
bun run check

Manual checks:

  • Not run. Changing the quantity on ORD-1002 (processing) should show "Order items cannot be changed for this order status." and send no request.
  • Not run. Changing the address on, or cancelling, ORD-1003 (shipped) should show the same API error messages as before.

Screenshots or recordings

N/A. No visible UI change.

Risks / follow-ups

  • Low risk: the allowed-status lists and messages match the old checks exactly, and the owner's tests cover each action on processing and shipped orders.
  • packages/shared now contains runtime code (the rule functions and messages) as well as types. Both the API and web builds pick it up.
  • Follow-up: the 3 existing TS2322 errors in the assignment test files will fail bun run check once it becomes a required CI gate.

PR checklist

  • change is scoped to one ticket or one small reviewable concern
  • acceptance criteria were checked
  • code follows CONTRIBUTING.md
  • no unrelated refactor is mixed in
  • debug code and temporary logs are removed
  • relevant automated checks were run locally
  • changed behavior was manually tested when needed
  • known risks or follow-ups are called out
## Summary This refactor puts the order status rules in one place and doesn't change behavior. ## Ticket / Assignment - Ticket: #22 ## What changed - `packages/shared/src/order-status.ts`: each action now has its own list of allowed statuses. - `apps/api/src/orders/order-status.ts`: removed. rule now imported from `@orderops/shared/order-status`. - `apps/api/src/orders/order-repository.ts`: `findOrderItemRecord` now returns the order status as `OrderStatus`, the same way `findOrderDetail` does, so `update-order-item.ts` no longer needs the `as never` cast. - `apps/web/src/orders/order-page.tsx`: uses the shared rules ## How to test ```bash bun run test bun run build:web bun run check ``` Manual checks: - Not run. Changing the quantity on ORD-1002 (processing) should show "Order items cannot be changed for this order status." and send no request. - Not run. Changing the address on, or cancelling, ORD-1003 (shipped) should show the same API error messages as before. ## Screenshots or recordings N/A. No visible UI change. ## Risks / follow-ups - Low risk: the allowed-status lists and messages match the old checks exactly, and the owner's tests cover each action on processing and shipped orders. - packages/shared now contains runtime code (the rule functions and messages) as well as types. Both the API and web builds pick it up. - Follow-up: the 3 existing TS2322 errors in the assignment test files will fail bun run check once it becomes a required CI gate. ## PR checklist - [x] change is scoped to one ticket or one small reviewable concern - [x] acceptance criteria were checked - [x] code follows CONTRIBUTING.md - [x] no unrelated refactor is mixed in - [x] debug code and temporary logs are removed - [x] relevant automated checks were run locally - [x] changed behavior was manually tested when needed - [x] known risks or follow-ups are called out
aziz_28002 added 1 commit 2026-10-08 12:45:13 +00:00
refactor:centralize order status rules in shared package
Runner Test / test (push) Successful in 17s
Runner Test / test (pull_request) Successful in 18s
12c4bc62c1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All checks were successful
Runner Test / test (push) Successful in 17s
Runner Test / test (pull_request) Successful in 18s
This pull request doesn't have enough required approvals yet. 0 of 1 approvals granted from users or teams on the allowlist.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin refactor/dg-4-order-status-rules:refactor/dg-4-order-status-rules
git checkout refactor/dg-4-order-status-rules
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: derrick/ai-wave-02#24