Skip to Content

Workflow.map()

The .map() method maps output data from a previous step to the input of a subsequent step, allowing you to transform data between steps.

Usage

const step1 = createStep({ id: "step1", inputSchema: z.object({ inputValue: z.string(), }), outputSchema: z.object({ outputValue: z.string(), }), execute: async ({ inputData }) => { return { outputValue: inputData.inputValue }; }, }); const step2 = createStep({ id: "step2", inputSchema: z.object({ unexpectedName: z.string(), }), outputSchema: z.object({ result: z.string(), }), execute: async ({ inputData }) => { return { result: inputData.unexpectedName }; }, }); const workflow = createWorkflow({ id: "my-workflow", steps: [step1, step2], inputSchema: z.object({ inputValue: z.string(), }), outputSchema: z.object({ result: z.string(), }), }); workflow .then(step1) .map({ unexpectedName: { step: step1, path: "outputValue", }, }) .then(step2) .commit();

Parameters

mappingConfig:

object
Configuration object that defines how data should be mapped between workflow steps, either as a mapping object or a mapping function
Step | Step[]
string
any
ZodType
Step
string

Returns

workflow:

NewWorkflow
The workflow instance for method chaining