WriteTransitionInstance
Executes one transition out of an Item’s current state.
Type Parameters
Section titled “Type Parameters”TWriteItem
Section titled “TWriteItem”TWriteItem extends WriteItem = WriteItem
The Item type returned by execute.
Methods
Section titled “Methods”execute()
Section titled “execute()”execute(
payload):Promise<TWriteItem>
Moves the Item to the transition’s target state, provided it is still in the source state.
Parameters
Section titled “Parameters”payload
Section titled “payload”Record<string, unknown>
Data accompanying the transition, matching the payload the transition declares.
Returns
Section titled “Returns”Promise<TWriteItem>
The Item in its new state; the instance the transition was taken from is unchanged.
Remarks
Section titled “Remarks”The source-state check and the state change are one atomic operation. A conflict is treated as transient, so the enclosing execution is retried within its retry budget with fresh Item lookups. The transition changes the state; publish the Event that announces the change from the same execution.
Throws
Section titled “Throws”StateTransitionConflictError when the Item is no longer in the transition’s source state, for example because another execution moved it first.
Example
Section titled “Example”Transition when in the expected state
const state = item.state;if (state?.value === 'active') return await state.transitions.deactivate.execute({});return item;
