output-sdk
    Preparing search index...

    Type Alias WorkflowContext<InputSchema, OutputSchema>

    The second argument passed to the workflow's fn function.

    type WorkflowContext<
        InputSchema extends AnyZodSchema
        | undefined = undefined,
        OutputSchema extends AnyZodSchema | undefined = undefined,
    > = {
        control: {
            continueAsNew: InputSchema extends AnyZodSchema
                ? (
                    input: z.infer<InputSchema>,
                ) => OutputSchema extends AnyZodSchema ? z.infer<OutputSchema> : void
                : () => OutputSchema extends AnyZodSchema ? z.infer<OutputSchema> : void;
            isContinueAsNewSuggested: () => boolean;
        };
        info: { workflowId: string };
    }

    Type Parameters

    • InputSchema extends AnyZodSchema | undefined = undefined
    • OutputSchema extends AnyZodSchema | undefined = undefined
    Index

    Properties

    Properties

    control: {
        continueAsNew: InputSchema extends AnyZodSchema
            ? (
                input: z.infer<InputSchema>,
            ) => OutputSchema extends AnyZodSchema ? z.infer<OutputSchema> : void
            : () => OutputSchema extends AnyZodSchema ? z.infer<OutputSchema> : void;
        isContinueAsNewSuggested: () => boolean;
    }

    Functions that allow fine control over the underlying Temporal workflows

    Type Declaration

    • continueAsNew: InputSchema extends AnyZodSchema
          ? (
              input: z.infer<InputSchema>,
          ) => OutputSchema extends AnyZodSchema ? z.infer<OutputSchema> : void
          : () => OutputSchema extends AnyZodSchema ? z.infer<OutputSchema> : void

      Closes the current workflow execution successfully and creates a new workflow execution.

      The new workflow execution is in the same chain as the previous workflow, but it generates another trace file.

      It acts as a checkpoint when the workflow gets too long or approaches certain scaling limits.

      It accepts input with the same schema as the parent workflow function (inputSchema).

      Calling this function must be the last statement in the workflow, accompanied by a return:

        return control.continueAsNew();
      

      Upon returning, the parent workflow execution closes without any output, and the new execution takes its place.

      The function's return type matches outputSchema; although no value is returned, the execution is replaced.

      The input for the new run. Omit when the workflow has no input schema.

      The workflow output type for type-checking; never returns at runtime.

    • isContinueAsNewSuggested: () => boolean

      Indicates whether the Temporal runtime suggests continuing this workflow as new.

      Use this to decide whether to continueAsNew before long waits or at loop boundaries. Prefer returning the continueAsNew(...) call immediately when this becomes true.

    info: { workflowId: string }

    Information about the workflow execution

    Type Declaration