Skip to main content

FSM

A simple type-safe finite state machine. This is used internally to control the Order process, ensuring that the state of Orders, Payments, Fulfillments and Refunds follows a well-defined behaviour.

Signature
class FSM<T extends string, Data = any> {    constructor(config: StateMachineConfig<T, Data>, initialState: T)    initialState: T    currentState: T    transitionTo(state: T, data: Data) => Promise<{ finalize: () => Promise<any> }>;    jumpTo(state: T) => ;    getNextStates() => readonly T[];    canTransitionTo(state: T) => boolean;}

constructor

method(config: StateMachineConfig<T, Data>, initialState: T) => FSM

initialState

propertyT

currentState

propertyT

transitionTo

method(state: T, data: Data) => Promise<{ finalize: () => Promise<any> }>

jumpTo

method(state: T) =>

getNextStates

method() => readonly T[]

canTransitionTo

method(state: T) => boolean
Was this chapter helpful?
Report Issue
Edited Feb 2, 2026·Edit this page