Interface: AsyncBatchStageDefinition<TInput, TOutput, TConfig, TContext, TId>
Defined in: packages/workflow-engine/src/core/stage-factory.ts:229
Async-batch stage definition (for long-running batch jobs)
Extends
Omit<SyncStageDefinition<TInput,TOutput,TConfig,TContext,TId>,"execute">
Type Parameters
TInput
TInput extends z.ZodTypeAny | "none"
TOutput
TOutput extends z.ZodTypeAny
TConfig
TConfig extends z.ZodTypeAny
TContext
TContext extends Record<string, unknown> = Record<string, unknown>
TId
TId extends string = string
Properties
checkCompletion
checkCompletion: (
suspendedState,context) =>Promise<CompletionCheckResult<output<TOutput>>>
Defined in: packages/workflow-engine/src/core/stage-factory.ts:261
Check if the batch job is complete Called by the orchestrator when polling suspended stages
Context includes workflowRunId, stageId, config, log, and storage so you don't need to store these in metadata.
Parameters
suspendedState
batchId
string = ...
maxWaitTime?
number = ...
Milliseconds.
Deprecated
Prefer pollConfig.maxWaitTime. Back-filled by
defineStage() for async-batch checkCompletion; goes away with that
mode, not before.
metadata?
Record<string, unknown> = ...
pollInterval?
number = ...
Milliseconds.
Deprecated
Prefer pollConfig.pollInterval. Back-filled by
defineStage() for async-batch checkCompletion; goes away with that
mode, not before.
statusUrl?
string = ...
submittedAt?
string = ...
ISO date string.
Deprecated
Read timing from pollConfig instead. defineStage() still
back-fills this for checkCompletion implementations of the async-batch
mode; it goes away with that mode, not before.
context
CheckCompletionContext<output<TConfig>>
Returns
Promise<CompletionCheckResult<output<TOutput>>>
dependencies?
optionaldependencies?:string[]
Defined in: packages/workflow-engine/src/core/stage-factory.ts:197
Stage IDs this stage depends on (validated at workflow build time)
Inherited from
SyncStageDefinition.dependencies
description?
optionaldescription?:string
Defined in: packages/workflow-engine/src/core/stage-factory.ts:195
Optional description
Inherited from
SyncStageDefinition.description
estimateCost?
optionalestimateCost?: (input,config) =>number
Defined in: packages/workflow-engine/src/core/stage-factory.ts:220
Optional: Estimate cost before execution
Parameters
input
InferInput<TInput>
config
output<TConfig>
Returns
number
Inherited from
Omit.estimateCost
execute
execute: (
ctx) =>Promise<SimpleSuspendedResult|SimpleStageResult<output<TOutput>>>
Defined in: packages/workflow-engine/src/core/stage-factory.ts:250
Execute the stage - either return result or suspend for batch processing
When resuming from suspension, ctx.resumeState contains the suspended state. Check this to determine whether to submit a new batch or fetch results.
Return SimpleSuspendedResult when suspending - metrics will be auto-filled.
Parameters
ctx
EnhancedStageContext<InferInput<TInput>, output<TConfig>, TContext>
Returns
Promise<SimpleSuspendedResult | SimpleStageResult<output<TOutput>>>
id
id:
TId
Defined in: packages/workflow-engine/src/core/stage-factory.ts:191
Unique stage identifier
Inherited from
Omit.id
mode
mode:
"async-batch"
Defined in: packages/workflow-engine/src/core/stage-factory.ts:240
Mark as async-batch mode
name
name:
string
Defined in: packages/workflow-engine/src/core/stage-factory.ts:193
Human-readable name
Inherited from
schemas
schemas:
object
Defined in: packages/workflow-engine/src/core/stage-factory.ts:200
Zod schemas for validation
config
config:
TConfig
Configuration schema
input
input:
TInput
Input schema, or "none" for stages that use workflowContext
output
output:
TOutput
Output schema
Inherited from
Omit.schemas