feat(server): migrate orders + webhooks to @hono/zod-openapi (batch 5) - #50
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
Shared typing hardened (cod-shared):
orders.statusandorder_status_history.statuscolumns now enum-typed (text({ enum })), matching sibling columnsOrderStatustype;updateOrderStatus(Webhook)params typed;OrderFilters.statusaccepts union or dashboard "all" sentinelCorrectness fixes surfaced by the migration:
dispatched— generated spec documents all 11 statusesisOrderStatus) before touching order state — invalid admin mappings now logunmappedinstead of poisoning statusPATCH /{id}/statusinvalid-transition response gained the missingcategoryfield (envelope consistency)Webhooks (#20) — 3 public receiver endpoints
INVALID_WEBHOOK_PAYLOADcodesVerification
npm run typecheck— passnpm test— 970/970 pass (+32 new route/spec tests)