Skip to content

Interface: FlowBranchBuilder<TFlowIn, TBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs> ​

Defined in: builders/flow-branch-builder.ts:20

Fluent builder for a conditional multi-way branch inside a FlowNode (.branch(id, $b => ...)).

Configures the unified branch output schema, ordered when(predicate, ...) cases, and the required otherwise(...) fallback case.

Extends ​

Type Parameters ​

Type ParameterDefault typeDescription
TFlowInunknownEnclosing flow input payload type.
TBranchOutunknownUnified output payload type produced by the selected branch.
THandleunknownIsolation scope handle type.
TBranchId extends stringstringLiteral branch step identifier string.
TReceiptunknownInspected scope receipt type.
TCustomMetrics extends Record<string, unknown>Record<string, unknown>Custom step telemetry metrics type.
TStepOutputs extends Record<string, unknown>Record<string, never>Accumulated step outputs map type.

Methods ​

otherwise() ​

ts
otherwise<TNextOutputs>(configure): FlowBranchBuilder<TFlowIn, TBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs>;

Defined in: builders/flow-branch-builder.ts:97

Configures the fallback otherwise($sub => ...) branch executed when no when predicate matches.

Throws at builder call time if the fallback sub-branch returned by configure contains zero steps.

Type Parameters ​

Type ParameterDefault typeDescription
TNextOutputs extends Record<string, unknown>TStepOutputsAccumulated step outputs map inside the fallback sub-branch.

Parameters ​

ParameterTypeDescription
configure($sub) => FlowSubBranchBuilder<TFlowIn, TBranchOut, THandle, TReceipt, TCustomMetrics, TNextOutputs>Fallback sub-branch configurator callback.

Returns ​

FlowBranchBuilder<TFlowIn, TBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs>

New immutable branch builder.


output() ​

ts
output<TNewBranchOut>(schema): FlowBranchBuilder<TFlowIn, TNewBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs>;

Defined in: builders/flow-branch-builder.ts:40

Binds the unified Zod output validation schema for all cases of this branch.

Every branch case (when and otherwise) must produce an output conforming to schema.

Type Parameters ​

Type ParameterDescription
TNewBranchOutUnified branch output payload type.

Parameters ​

ParameterTypeDescription
schemaZodType<TNewBranchOut>Zod schema validating the branch output.

Returns ​

FlowBranchBuilder<TFlowIn, TNewBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs>

New immutable branch builder.


toAST() ​

ts
toAST(): FlowBranchNode;

Defined in: ast/ast-builder.ts:20

Compiles the current builder configuration into a deeply frozen passive AST node.

Validates required builder invariants at compilation time and returns an immutable plain-object AST representation containing zero execution methods.

Returns ​

FlowBranchNode

Deeply frozen passive AST node.

Inherited from ​

AstBuilder.toAST


when() ​

ts
when<TNextOutputs>(predicate, configure): FlowBranchBuilder<TFlowIn, TBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs>;

Defined in: builders/flow-branch-builder.ts:64

Appends a conditional when(predicate, $sub => ...) branch case evaluated in declaration order.

Throws at builder call time if the sub-branch returned by configure contains zero steps.

Type Parameters ​

Type ParameterDefault typeDescription
TNextOutputs extends Record<string, unknown>TStepOutputsAccumulated step outputs map inside the sub-branch.

Parameters ​

ParameterTypeDescription
predicate(input) => booleanSynchronous predicate over flowInput.
configure($sub) => FlowSubBranchBuilder<TFlowIn, TBranchOut, THandle, TReceipt, TCustomMetrics, TNextOutputs>Sub-branch configurator callback.

Returns ​

FlowBranchBuilder<TFlowIn, TBranchOut, THandle, TBranchId, TReceipt, TCustomMetrics, TStepOutputs>

New immutable branch builder.

Released under the MIT License.