Transaction
Transaction:
object
Defined in: Core/Transaction.ts:52
Type Declaration
Section titled “Type Declaration”make: <
S>(…steps) =>Transaction<CombinedInput<S>,StepOutputs<S>,ErrorOf<S[number]>,UndoErrorOf<S[number]>> =makeTransaction
Assembles step definitions in execution order and validates their dependencies.
Assembles steps in execution order and validates their dependencies.
Type Parameters
Section titled “Type Parameters”S extends readonly AnyStepInternal[]
Parameters
Section titled “Parameters”…S & (ValidSequence<S, never> extends true ? unknown : never)
Returns
Section titled “Returns”Transaction<CombinedInput<S>, StepOutputs<S>, ErrorOf<S[number]>, UndoErrorOf<S[number]>>
Transaction.step for defining reusable steps.
Example
Section titled “Example”run: {(): <
Acc,E,EUndo>(transaction) =>Deferred<Result<Failure<Aborted|E,EUndo>,Acc>>; <In>(input,options?): <Acc,E,EUndo>(transaction) =>Deferred<Result<Failure<Aborted|E,EUndo>,Acc>>; } =runTransaction
Starts a Transaction and returns a deferred result.
Steps run sequentially. If all steps succeed, returns Ok(Acc) containing all step outputs.
If a step returns an error or cancellation is observed before a step starts, completed steps
with undo actions are undone in reverse order and the result is Err(Transaction.Failure).
Active tasks receive the signal and must handle cancellation themselves.
Call Signature
Section titled “Call Signature”(): <
Acc,E,EUndo>(transaction) =>Deferred<Result<Failure<Aborted|E,EUndo>,Acc>>
Starts a Transaction and returns a deferred result.
Steps run sequentially. If all steps succeed, returns Ok(Acc) containing all step outputs.
If a step returns an error or cancellation is observed before a step starts, completed steps
with undo actions are undone in reverse order and the result is Err(Transaction.Failure).
Active tasks receive the signal and must handle cancellation themselves.
Returns
Section titled “Returns”<Acc, E, EUndo>(transaction) => Deferred<Result<Failure<Aborted | E, EUndo>, Acc>>
Transaction.step for configuring transactional steps with compensating undo actions.
A transaction with no input is run as Transaction.run()(transaction). Pass undefined as the
input when such a transaction also needs run options:
Transaction.run(undefined, { signal })(transaction).
Example
Section titled “Example”Call Signature
Section titled “Call Signature”<
In>(input,options?): <Acc,E,EUndo>(transaction) =>Deferred<Result<Failure<Aborted|E,EUndo>,Acc>>
Starts a Transaction and returns a deferred result.
Steps run sequentially. If all steps succeed, returns Ok(Acc) containing all step outputs.
If a step returns an error or cancellation is observed before a step starts, completed steps
with undo actions are undone in reverse order and the result is Err(Transaction.Failure).
Active tasks receive the signal and must handle cancellation themselves.
Type Parameters
Section titled “Type Parameters”In
Parameters
Section titled “Parameters”In
options?
Section titled “options?”RunOptions<unknown, unknown>
Returns
Section titled “Returns”<Acc, E, EUndo>(transaction) => Deferred<Result<Failure<Aborted | E, EUndo>, Acc>>
Transaction.step for configuring transactional steps with compensating undo actions.
A transaction with no input is run as Transaction.run()(transaction). Pass undefined as the
input when such a transaction also needs run options:
Transaction.run(undefined, { signal })(transaction).
Example
Section titled “Example”Transaction.step for configuring transactional steps with compensating undo actions.
Example
Section titled “Example”step: {<
Id,Input,E,Out,EUndo>(id,run,undo?):Step<Id,Input,E,Out,EUndo,Record<never,never>>; <Id,D,Input,E,Out,EUndo>(id,deps,run,undo?):Step<Id,Input,E,Out,EUndo,D>; }
Defines a reusable step with optional named dependencies and compensation.
The step receives its run input in ctx and declared dependency outputs in deps.
An optional undo action can reverse external mutations if a later step fails.
Call Signature
Section titled “Call Signature”<
Id,Input,E,Out,EUndo>(id,run,undo?):Step<Id,Input,E,Out,EUndo,Record<never,never>>
Creates a reusable step with optional dependencies and optional compensation.
Type Parameters
Section titled “Type Parameters”Id extends string
Input = void
E = never
Out = never
EUndo = never
Parameters
Section titled “Parameters”Id extends "initial" ? never : Id
StepRun<Record<never, never>, Input, E, Out>
StepUndo<Record<never, never>, Input, Out, EUndo>
Returns
Section titled “Returns”Step<Id, Input, E, Out, EUndo, Record<never, never>>
Call Signature
Section titled “Call Signature”<
Id,D,Input,E,Out,EUndo>(id,deps,run,undo?):Step<Id,Input,E,Out,EUndo,D>
Creates a reusable step with optional dependencies and optional compensation.
Type Parameters
Section titled “Type Parameters”Id extends string
D extends Record<string, AnyStepInternal | undefined> = Record<never, never>
Input = void
E = never
Out = never
EUndo = never
Parameters
Section titled “Parameters”Id extends "initial" ? never : Id
D
StepRun<D, Input, E, Out>
StepUndo<D, Input, Out, EUndo>
Returns
Section titled “Returns”Step<Id, Input, E, Out, EUndo, D>
Transaction.run for executing the compiled transaction.
Example
Section titled “Example”stepFactory
Section titled “stepFactory”stepFactory: <
Input>() =>StepFactory<Input>
Creates a step constructor with a shared input type.
Type Parameters
Section titled “Type Parameters”Input
Returns
Section titled “Returns”StepFactory<Input>