Skip to main content

Function: defineWorkflow()

Call Signature​

defineWorkflow<TInput>(id, options?): WorkflowBuilder<TInput, TInput>

Defined in: packages/workflow-engine/src/core/workflow.ts:984

Create a WorkflowBuilder.

The workflow's output schema is always the last stage's outputSchema (or the merged object of the last parallel group); there is no separate output option.

Type Parameters​

TInput​

TInput extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> = ZodUnknown

Parameters​

id​

string

options?​

WorkflowOptions<TInput>

Returns​

WorkflowBuilder<TInput, TInput>

Example​

// id + options
const workflow = defineWorkflow("my-workflow", { input: InputSchema })
.stage("first", { schemas: { ... }, execute })
.build();

// options object
const workflow = defineWorkflow({
id: "my-workflow",
name: "My Workflow",
input: InputSchema,
})
.pipe(stage1)
.pipe(stage2)
.build();

Call Signature​

defineWorkflow<TInput>(options): WorkflowBuilder<TInput, TInput>

Defined in: packages/workflow-engine/src/core/workflow.ts:988

Create a WorkflowBuilder.

The workflow's output schema is always the last stage's outputSchema (or the merged object of the last parallel group); there is no separate output option.

Type Parameters​

TInput​

TInput extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Parameters​

options​

DefineWorkflowOptions<TInput>

Returns​

WorkflowBuilder<TInput, TInput>

Example​

// id + options
const workflow = defineWorkflow("my-workflow", { input: InputSchema })
.stage("first", { schemas: { ... }, execute })
.build();

// options object
const workflow = defineWorkflow({
id: "my-workflow",
name: "My Workflow",
input: InputSchema,
})
.pipe(stage1)
.pipe(stage2)
.build();