output-sdk
    Preparing search index...

    Function step

    • Creates a step.

      A step is a logical unit of work that can perform I/O. It is translated to a Temporal Activity.

      The step logic is defined in the fn handler function.

      The schema of the input that the function receives as the first argument is defined by the inputSchema option.

      The output of the fn handler must match the schema defined by outputSchema; otherwise, a validation error is raised.

      Type Parameters

      • InputSchema extends AnyZodSchema = undefined

        Zod schema of the fn's input.

      • OutputSchema extends AnyZodSchema = undefined

        Zod schema of the fn's return.

      Parameters

      Returns StepFunctionWrapper<StepFunction<InputSchema, OutputSchema>>

      The same handler function set at fn

      step( {
      name: 'process',
      description: 'A generic process',
      inputSchema: z.object( {
      value: z.number()
      } ),
      outputSchema: z.string(),
      fn: async input => {
      const result = await ai.call( input.value );
      return result as string;
      }
      } )
      step( {
      name: 'process',
      description: 'A generic process',
      inputSchema: z.object( {
      value: z.number()
      } ),
      fn: async input => {
      await ai.call( input.value );
      }
      } )
      step( {
      name: 'process',
      description: 'A generic process',
      outputSchema: z.string(),
      fn: async () => {
      const result = await ai.call();
      return result as string;
      }
      } )
      step( {
      name: 'process',
      description: 'A generic process',
      fn: async () => {
      await ai.call();
      }
      } )
      • Never call another step from within a step.
      • Never call a workflow from within a step.

      FatalError