Evaluates and transforms data-mapping rules against live job state.

MapperService is the bridge between a workflow's declarative mapping rules (including @pipe expressions) and the runtime job data. It recursively walks a rule tree, delegating leaf-level resolution to the Pipe engine. Static helpers such as evaluate also power transition-condition checks during workflow execution.

const mapper = new MapperService(
{ greeting: '{data.name}', score: { '@pipe': [['{data.x}', '{data.y}'], ['{@math.add}']] } },
jobState,
);
const result = mapper.mapRules();
// => { greeting: 'Alice', score: 7 }

Constructors

Methods

Constructors

Methods

  • Recursively resolves every rule in the tree against the current job state and returns a fully-evaluated copy.

    Returns Record<string, unknown>

    A plain object mirroring the rule structure with all expressions replaced by their resolved values.

  • Evaluates a transition rule against the current job state and an incoming Stream message code to decide whether the transition fires.

    Parameters

    • transitionRule: boolean | TransitionRule

      A boolean shorthand or a TransitionRule containing code, optional gate, and optional match conditions.

    • context: JobState

      The current JobState used to resolve actual expressions inside match entries.

    • code: number

      The StreamCode returned by the preceding activity (e.g. 200).

    Returns boolean

    true if the transition should be taken, false otherwise.

    Supports both simple boolean rules (true / false) and compound match rules with optional AND / OR gating. When the rule includes a match array, each entry's actual expression is resolved via Pipe.resolve and compared to the expected value.

    const shouldTransition = MapperService.evaluate(
    { code: 200, match: [{ expected: true, actual: '{data.isReady}' }] },
    jobState,
    200,
    );