MachineWorkflow API
Generated reference for the public MachineWorkflow module.
effect-state-machine API / MachineWorkflow
MachineWorkflow
configuration
InvokeConfig
Defined in: packages/core/src/MachineWorkflow.ts:72
Configuration for one Workflow-backed machine invocation.
Details
payload receives the narrowed machine state and required stable work execution. The Workflow's
declared success and failure Schemas determine the corresponding machine transition reducers.
Since
0.2.0
Type Parameters
State
State extends Tagged
Current
Current extends TagOf<State>
Definition
Definition extends AnyWorkflow
Properties
workflow
readonlyworkflow:Definition
Defined in: packages/core/src/MachineWorkflow.ts:77
name?
readonlyoptionalname?:string
Defined in: packages/core/src/MachineWorkflow.ts:78
description?
readonlyoptionaldescription?:string
Defined in: packages/core/src/MachineWorkflow.ts:79
payload
readonlypayload: (args) =>Type<PayloadSchema<NoInfer<...>>>
Defined in: packages/core/src/MachineWorkflow.ts:80
Parameters
args
Readonly<{ state: ByTag<..., ...>; execution: WorkExecution; }>
Returns
Type<PayloadSchema<NoInfer<...>>>
onSuccess
readonlyonSuccess:SuccessTransition<State,Current,Type<SuccessSchema<NoInfer<...>>>>
Defined in: packages/core/src/MachineWorkflow.ts:86
onFailure
readonlyonFailure:FailureTransition<State,Current,Type<FailureSchema<NoInfer<...>>>>
Defined in: packages/core/src/MachineWorkflow.ts:87
constructors
executionId()
executionId(
workflowName,machineExecutionId):string
Defined in: packages/core/src/MachineWorkflow.ts:56
Derives the Workflow execution identity owned by one machine work execution.
Details
The versioned, length-prefixed encoding separates Workflow names and machine execution IDs without relying on a delimiter that user input could collide with. Redelivery of the same machine work produces the same Workflow execution ID.
Parameters
workflowName
string
machineExecutionId
Returns
string
Since
0.2.0
invoke()
invoke<
InputSchema,StateSource,EventSource,Definition,Current>(builder,config):Readonly<{description?: ... | ...;source:Reference;invoke:InvokeSpecBase;on?: ... | ...;after?: ... | ...;regions?:undefined;child?:undefined;onComplete?:undefined;final?:undefined; }> &Readonly<{invoke:EffectInvokeSpec<..., ..., ..., ..., ..., ..., ..., ...>; }>
Defined in: packages/core/src/MachineWorkflow.ts:112
Declares Workflow-backed work using the same activity-outcome seam as an ordinary invocation.
Redelivery reuses a versioned execution ID derived from the Workflow name and stable machine execution ID. The Workflow engine therefore resumes or observes the same execution while the machine still persists the decoded outcome through its own aggregate protocol.
When to use
Use when invoked machine work should be executed and resumed by Effect Workflow while machine
state remains owned by MachineEngine and MachineStore.
Gotchas
Workflow persistence does not replace the machine store. The resulting definition requires both the Workflow engine and any client services required by the Workflow, in addition to the machine engine required when the definition runs.
Type Parameters
InputSchema
InputSchema extends Top
StateSource
StateSource extends TaggedSchemaSource
EventSource
EventSource extends TaggedSchemaSource
Definition
Definition extends Any
Current
Current extends string = TagOf<Type<NormalizedTaggedSchema<StateSource>>>
Parameters
builder
child
<Current, Child>(config, on?) => ChildNodeConfig<State, Event, Current, Child>
define
<States>(config, states) => MachineDefinition<InputSchema, NormalizedTaggedSchema<...>, NormalizedTaggedSchema<...>, States>
final
(options?) => FinalNodeConfig
guard
<Args>(config) => NamedGuard<Args> = namedGuard
invoke
<Current, Success, AllowedFailure, Failure, Requirements, RetryError, RetryEnv>(config, on?, options?) => ... & ... & object
region
{ invoke: <Current, Slot, RegionTag, Success, AllowedFailure, Failure, Requirements, RetryError, RetryEnv>(config, on?, options?) => Readonly<...>; } = ...
region.invoke
<Current, Slot, RegionTag, Success, AllowedFailure, Failure, Requirements, RetryError, RetryEnv>(config, on?, options?) => Readonly<...> = invokeRegion
regions
<Current, RegionTrees>(regionTrees, on?, options?) => Readonly<...> & Readonly<...>
state
<Current>(on, options?) => AtomicNodeConfig<State, Event, Current>
schemas
Readonly<{ input: InputSchema; state: NormalizedTaggedSchema; event: NormalizedTaggedSchema; }>
config
InvokeConfig<Type<NormalizedTaggedSchema<StateSource>>, Current, Definition>
Returns
Readonly<{ description?: ... | ...; source: Reference; invoke: InvokeSpecBase; on?: ... | ...; after?: ... | ...; regions?: undefined; child?: undefined; onComplete?: undefined; final?: undefined; }> & Readonly<{ invoke: EffectInvokeSpec<..., ..., ..., ..., ..., ..., ..., ...>; }>
See
executionId for the stable identity used on redelivery.
Since
0.2.0
utility types
Payload
Payload<
Definition> =Schema.Schema.Type<PayloadSchema<Definition>>
Defined in: packages/core/src/MachineWorkflow.ts:24
Decoded payload accepted by a Workflow definition.
Type Parameters
Definition
Definition extends AnyWorkflow
Since
0.2.0
Success
Success<
Definition> =Schema.Schema.Type<SuccessSchema<Definition>>
Defined in: packages/core/src/MachineWorkflow.ts:32
Decoded success produced by a Workflow definition.
Type Parameters
Definition
Definition extends AnyWorkflow
Since
0.2.0
Failure
Failure<
Definition> =Schema.Schema.Type<FailureSchema<Definition>>
Defined in: packages/core/src/MachineWorkflow.ts:40
Declared error produced by a Workflow definition.
Type Parameters
Definition
Definition extends AnyWorkflow
Since
0.2.0