Function step

  • Declares a step: a class extending Step directly, whose run makes its outcome. A workflow lists it with @withStep, which accepts only a class declared with @step.

    Every parameter of the step's constructor and of its run is a request, marked with the decorator of what it requests: @input on the constructor's, @service, @contributor and @stepReporter on those of run.

    import assert from "node:assert/strict";
    import { type Outcome, Step, step } from "itinera/step";

    @step()
    class Ship extends Step {
    override run(): Outcome {
    return this.succeed();
    }
    }

    assert.deepEqual(new Ship().run(), { kind: "success" });

    A step keeps no static data, which every attempt of every journey would share: a public static property holding anything but a function does not compile, and a protected or private one, or an accessor, is refused when the class is defined, as WithoutStaticData says.

    Returns <C extends StepClass>(target: WithoutStaticData<C, typeof Step>) => void

    Error, when the class is defined, if it does not extend Step itself, if it keeps static data, if it is declared twice, or if a parameter has no request.