Skip to content

feat(server): migrate orders + webhooks to @hono/zod-openapi (batch 5) - #50

Merged
bighadj22 merged 2 commits into
mainfrom
feat/orders-openapi-migration
Aug 21, 2026
Merged

bighadj22 merged 2 commits into
mainfrom
feat/orders-openapi-migration

Conversation

@bighadj22

Copy link
Copy Markdown
Owner

Summary

Batch 5 of the OpenAPI migration: 20/23 endpoints (~87%), ~9,845 legacy lines removed total. The two biggest remaining domains land here.

Orders (#19) — 17 routes (largest domain)

  • Full COD lifecycle: CRUD, status transitions with forward-flow guard, driver assign/unassign, per-line returns (Algerian box-opening workflow), single + bulk carrier dispatch, and post-dispatch shipment operations (update/cancel/remarks/tracking/label proxy)
  • Deletes the largest legacy file (~2,350 lines)
  • Route count corrected 13 → 17 (verified from routes.ts)

Shared typing hardened (cod-shared):

  • orders.status and order_status_history.status columns now enum-typed (text({ enum })), matching sibling columns
  • New exported OrderStatus type; updateOrderStatus(Webhook) params typed; OrderFilters.status accepts union or dashboard "all" sentinel

Correctness fixes surfaced by the migration:

  • Legacy spec's Order component omitted dispatched — generated spec documents all 11 statuses
  • Webhook carrier-status mappers (ZR/Yalidine) validated at the boundary (isOrderStatus) before touching order state — invalid admin mappings now log unmapped instead of poisoning status
  • PATCH /{id}/status invalid-transition response gained the missing category field (envelope consistency)

Webhooks (#20) — 3 public receiver endpoints

  • Yalidine CRC challenge (text/plain echo) + event batches; ZR Express Svix receiver
  • Receivers keep no request-body validation on purpose — ZR signature verification reads raw bytes before parsing; framework validation would break that contract. Payload shapes documented in descriptions; handlers preserve INVALID_WEBHOOK_PAYLOAD codes
  • Dual-protocol CRC endpoint registered with widened handler type (behavior unchanged)
  • Note: the legacy spec's other 4 webhook management operations already ship via delivery-companies (chore(deps): bump @modelcontextprotocol/sdk from 1.29.0 to 1.30.0 in /cod-server #3)

Verification

19/23 endpoints (~83%). All 17 routes converted — CRUD, lifecycle
transitions, driver assignment/unassignment, per-line returns, single +
bulk carrier dispatch, and post-dispatch shipment operations. Largest
legacy file deleted (~2,350 lines).

Shared typing hardened in cod-shared: orders.status and
order_status_history.status columns are now enum-typed; exported
OrderStatus type; updateOrderStatus(Webhook) params typed;
OrderFilters.status accepts the union or the dashboard "all" sentinel.

Correctness fixes surfaced by the migration:
- Legacy spec's Order component omitted the dispatched status — the
  generated spec documents all 11 lifecycle statuses.
- Webhook carrier-status mappers (ZR Express / Yalidine) are now
  validated at the boundary (isOrderStatus) before touching order state.
- PATCH /{id}/status invalid-transition response gained the missing
  category field for error-envelope consistency.

Adds orders/routes.test.ts (26 tests) and a serve.test.ts spec block.
20/23 endpoints (~87%). Yalidine CRC challenge + event delivery and ZR
Express Svix receiver converted. Receivers keep NO request-body
validation on purpose — ZR signature verification reads the raw body
before parsing, and framework validation there would break that
contract; payload shapes are documented in descriptions while handlers
preserve INVALID_WEBHOOK_PAYLOAD codes. The dual-protocol CRC endpoint
(text/plain echo vs JSON ack) is registered with a widened handler type.
The legacy spec's 4 management operations already ship via
delivery-companies (#3). Adds routes.test.ts and a serve.test.ts block.
@bighadj22
bighadj22 merged commit 2d441de into main Aug 21, 2026
3 checks passed
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.

1 participant