npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@processengine/decisions

v2.0.0

Published

Flow 5 decision runtime for selecting outcomes from JSON-safe facts.

Readme

@processengine/decisions

Flow 5 decision runtime for selecting an outcome from already prepared JSON-safe facts.

Role

facts object -> decision output

@processengine/decisions does one job: it evaluates ordered business decision cases against a facts object and returns a transport-safe runtime result.

It does not read ProcessState, traverse raw payload arrays, execute mappings/rules, build patch plans, route a flow, perform side effects, or call infrastructure.

Install

npm install @processengine/decisions

Node.js >=20.19.0 is required.

Public API

const {
  validateDecisions,
  prepareDecisions,
  executeDecisions,
  formatDecisionsDiagnostics,
  formatDecisionsRuntimeError,
  DecisionsCompileError,
  DecisionsRuntimeError
} = require('@processengine/decisions');

Canonical lifecycle:

validateDecisions -> prepareDecisions -> executeDecisions

The old compile/evaluate/run API is not canonical in v2.

Quick start

const { validateDecisions, prepareDecisions, executeDecisions } = require('@processengine/decisions');

const source = {
  decisionSetId: 'decisions.validation.route',
  version: '2.0.0',
  title: 'Choose validation route',
  description: 'Selects whether processing can continue after validation.',
  cases: [
    {
      id: 'validation.has_errors',
      title: 'Has blocking errors',
      description: 'Rejects the request when validation produced at least one error.',
      when: { errorCount: { gt: 0 } },
      then: { outcome: 'REJECT_VALIDATION', reason: 'VALIDATION_ERROR' }
    }
  ],
  default: { outcome: 'CONTINUE', reason: 'VALIDATION_OK' }
};

const validation = validateDecisions(source);
if (!validation.ok) throw new Error(JSON.stringify(validation.diagnostics, null, 2));

const artifact = prepareDecisions(source);
const result = executeDecisions(artifact, { errorCount: 2 });

console.log(result.output.outcome); // REJECT_VALIDATION

Source artifact

interface DecisionsDefinitionV2 {
  decisionSetId: string;
  version: string;
  title: string;
  description: string;
  cases: DecisionCaseV2[];
  default: DecisionThen;
  metadata?: JsonObject;
}

cases must be a non-empty array. The first matching case wins. If no case matches, default is selected.

Conditions

Short equality form:

{ "resultStatus": "SUCCESS" }

Operator form:

{
  "errorCount": { "gt": 0 },
  "warningCount": { "eqFact": "softContactWarningCount" },
  "clientOriginKind": { "in": ["OWN_SERVICE", "SYSTEM"] },
  "optionalSignal": { "missing": true }
}

Supported operators:

eq / neq
gt / gte / lt / lte
in / notIn
exists / missing
eqFact / neqFact
gtFact / gteFact / ltFact / lteFact

exists and missing check path presence, not truthiness:

value null -> exists = true
value false -> exists = true
value 0 -> exists = true
absent fact -> missing = true

Runtime result

interface ExecuteDecisionsResult {
  output: {
    outcome: string;
    reason?: string;
    matchedCaseId?: string;
    decisionSetId: string;
    metadata?: JsonObject;
    tags?: string[];
  };
  trace?: DecisionTraceEvent[];
}

The result and trace are JSON-safe / transport-safe. metadata fields must be JSON-safe plain objects, case ids must be unique, and scalar condition operators reject object/array facts instead of guessing. This means the result can be written by @processengine/dataflows into $.context.data.decisions.* and then read by Flow 5 CONTROL/ROUTE at .outcome without host-side cleanup.

Trace

Trace is disabled by default. The only supported values are 'off', 'basic', and 'verbose'. Other values are rejected with DECISIONS_TRACE_MODE_INVALID.

executeDecisions(artifact, facts);                 // trace off by default
executeDecisions(artifact, facts, { trace: 'off' });
executeDecisions(artifact, facts, { trace: 'basic' });
executeDecisions(artifact, facts, { trace: 'verbose' });

verbose trace includes JSON-safe input/output snapshots. Invalid execution options are rejected with typed DecisionsRuntimeError; no raw JavaScript error is allowed to escape the public runtime boundary.

Flow 5 interop

Typical dataflow chain:

MAPPINGS kind=facts -> DECISIONS -> write $.context.data.decisions.<name>
CONTROL/ROUTE reads $.context.data.decisions.<name>.outcome

Documentation