Flow API Reference
The Flow class is the primary interface for defining and executing workflows.
create<TInput>(name, config?)
Helper function to create a new Flow instance.
- Parameters:
name:string- Unique name for the flow.config:FlowConfig<TInput>(optional) - Global flow configuration.
- Returns:
Flow<TInput>
Methods
.step(name, fn, options?)
Adds a sequential step to the flow.
- Parameters:
name:string- Unique name for the step.fn:(ctx: FlowContext<TInput>) => Promise<void> | void- The function to execute.options:StepOptions<TInput>(optional) - Step-specific configuration.
- Returns:
this(for chaining)
.parallel(name, steps, options?)
Adds a block of steps to be executed in parallel.
- Parameters:
name:string- Unique name for the parallel block.steps:Step<TInput>[]- Array of step objects.options:ParallelOptions(optional) - Parallel execution configuration.
- Returns:
this(for chaining)
.run(input, options?)
Executes the flow with the given input.
- Parameters:
input:TInput- The input data for the flow.options:IdempotentRunOptions(optional) - Options for idempotency.
- Returns:
Promise<FlowResult>
Interfaces
FlowConfig<TInput>
ts
type FlowConfig<TInput> = {
idempotency?: IdempotencyStore;
hooks?: FlowHooks<TInput>;
schema?: StandardSchemaV1<TInput>;
logging?: boolean | FlowLoggerOptions;
plugins?: FlowPlugin<TInput>[];
};FlowResult
ts
type FlowResult = {
name: string;
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
durationMs: number;
steps: StepResult[];
error?: unknown;
};