Model legal return transitions
Apply only legal return-workflow transitions and preserve discriminated state data across the transition path.Description
Requirements
Export transitionReturnState from src/App.tsx.
Allow requested to authorized or rejected, authorized to in_transit or rejected, in_transit to received, and received to refunded.
Throw a descriptive error without changing state for every other state-event pair.
Carry authorizationId from authorized into in_transit.
Treat refunded and rejected as terminal for every event.
Return an observably equivalent result for equivalent inputs without reading time, randomness, network, storage, or DOM globals.
Do not mutate input objects, arrays, nested records, or values retained in the returned result.
Ship return
authorized A1 receives ship T9
Returns in_transit with A1 and T9
Allow requested to authorized or rejected, authorized to in_transit or rejected, in_transit to received, and received to refunded.
Illegal refund
requested receives refund
Throws and leaves requested state unchanged
Throw a descriptive error without changing state for every other state-event pair.
Constraints
Implement a pure synchronous function with no external side effectsTreat every input collection and nested record as read-onlyReturn JSON-compatible data except where the declared TypeScript API explicitly uses bigint
Hints
Hint 1
Start with the legal-transition-table behavior and make its observable result deterministic.
Hint 2
Model rejects-illegal-transition independently before combining it with the remaining states.
Hint 3
Verify the boundary described by terminal-states without changing caller-owned input.