export type DeliveryState = "PENDING" | "CONFIRMED" | "PREPARING" | "READY_FOR_PICKUP" | "PICKED_UP" | "IN_TRANSIT" | "DELIVERED" | "CANCELLED" | "FAILED" | "REFUNDED"; export type DeliveryEvent = "CONFIRM" | "START_PREPARING" | "MARK_READY" | "ASSIGN_RIDER" | "PICKUP" | "START_TRANSIT" | "DELIVER" | "CANCEL" | "FAIL" | "REFUND"; /** * Maps each state to the events it accepts and the resulting next state. * * S = your state union (e.g. "PENDING" | "PAID" | "SHIPPED") * E = your event union (e.g. "PAY" | "SHIP" | "CANCEL") */ export type TransitionMap = { [State in S]?: Partial>; }; export interface TransitionContext { orderId: string; from: S; to: S; event: E; timestamp: Date; metadata?: Record; } export type TransitionHook = (ctx: TransitionContext) => void | Promise; export interface StateMachineHooks { onTransition?: TransitionHook; onEnter?: Partial>>; onExit?: Partial>>; } export interface HistoryEntry { from: S; to: S; event: E; timestamp: Date; metadata?: Record; } export interface StateMachineConfig { orderId: string; initialState: S; transitions: TransitionMap; hooks?: StateMachineHooks; /** States where no further transitions are expected */ terminalStates?: S[]; /** States that represent an active, in-progress lifecycle */ activeStates?: S[]; } export type DeliveryStateMachineConfig = Omit, "initialState" | "transitions"> & { initialState?: DeliveryState; transitions?: TransitionMap; }; export declare class InvalidTransitionError extends Error { readonly from: S; readonly event: E; constructor(from: S, event: E); } //# sourceMappingURL=types.d.ts.map