footprintjs - v11.2.0
    Preparing search index...

    Function flowChart

    • Start a flowchart with its first stage; returns a fluent builder.

      Chain .addFunction() / .addDeciderFunction() / .addSelectorFunction() / .addSubFlowChart() etc. to add more stages, then finish with .build().

      Type Parameters

      • TState extends object

      Parameters

      • name: string

        Human-readable display label for the stage (shown in the narrative/trace).

      • fn:
            | TypedStageFunction<TState>
            | PausableHandler<TypedScope<TState>, unknown, unknown>

        The stage's work — a (scope) => … function, or a PausableHandler for human-in-the-loop pauses.

      • id: string

        Stable stage id used in traces, the commit log, and runtimeStageId. Keep it unique within the chart.

      • Optionaloptions: FlowChartOptions

        Optional { description?, structureRecorders?, retry?, touches?, tags?, failFast? } (FlowChartOptions). retry, touches and tags apply to this first stage; failFast is read only by flowChartSelector and is ignored here.

      Returns FlowChartBuilder<any, TypedScope<TState>>

      const chart = flowChart<State>('FetchUser', async (scope) => {
      scope.user = await getUser();
      }, 'fetch-user')
      .addFunction('Process', processFn, 'process')
      .build();

      const trace = narrative();
      const result = await chart.recorder(trace).run();
      console.log(trace.getEntries().map((e) => e.text).join('\n'));
    • Start a flowchart with its first stage; returns a fluent builder.

      Chain .addFunction() / .addDeciderFunction() / .addSelectorFunction() / .addSubFlowChart() etc. to add more stages, then finish with .build().

      Type Parameters

      • TOut = any
      • TScope = any

      Parameters

      • name: string

        Human-readable display label for the stage (shown in the narrative/trace).

      • fn: StageHandler<TOut, TScope> | PausableHandler<TScope, unknown, unknown>

        The stage's work — a (scope) => … function, or a PausableHandler for human-in-the-loop pauses.

      • id: string

        Stable stage id used in traces, the commit log, and runtimeStageId. Keep it unique within the chart.

      • Optionaloptions: FlowChartOptions

        Optional { description?, structureRecorders?, retry?, touches?, tags?, failFast? } (FlowChartOptions). retry, touches and tags apply to this first stage; failFast is read only by flowChartSelector and is ignored here.

      Returns FlowChartBuilder<TOut, TScope>

      const chart = flowChart<State>('FetchUser', async (scope) => {
      scope.user = await getUser();
      }, 'fetch-user')
      .addFunction('Process', processFn, 'process')
      .build();

      const trace = narrative();
      const result = await chart.recorder(trace).run();
      console.log(trace.getEntries().map((e) => e.text).join('\n'));