Runtime for dataflow artifacts in ProcessEngine Flow 5.
@processengine/dataflows validates, prepares and executes linear dataflow artifacts composed of MAPPINGS, RULES and DECISIONS pipeline items. It is the runtime for PROCESS/DATA steps in Flow 5.
PROCESS/DATA (flow graph step)
→ processor runtime calls executeDataflow(...)
→ @processengine/dataflows executes dataflow artifact
→ returns DataflowOutput.writes[]
→ @processengine/semantics.reduce applies writes to process state
npm install @processengine/dataflowsimport { validateDataflow, prepareDataflow, executeDataflow } from '@processengine/dataflows';
// 1. Validate
const source = {
id: 'dataflow.example',
version: '1.0.0',
schema: {
'$.context.data.facts.result': {
title: 'Result facts',
description: 'Facts produced from the input application for the quick start example.',
fields: {
ok: {
type: 'boolean',
title: 'Input is acceptable',
description: 'true when the application payload can continue through the example dataflow.'
}
}
}
},
pipeline: [{
id: 'map_input',
type: 'MAPPINGS',
kind: 'facts',
artefactId: 'mappings.example',
contract: {
input: { ref: '$.context.input.application' },
output: { ref: '$.context.data.facts.result' }
}
}]
};
const validation = validateDataflow(source);
if (!validation.ok) throw new Error('Invalid');
// 2. Prepare (once, cache the result)
const artifact = prepareDataflow(source);
// 3. Execute
const state = { context: { input: { application: { ok: true } }, data: {} } };
const registries = {
mappings: {
get: (id) => ({ id }),
executeMappings: (_artifact, input) => ({ output: { ok: input.ok } })
}
};
const result = executeDataflow(artifact, { state, registries });
// result.writes[] — transport-safe, pass directly to semantics.reduceThe package is designed from the public contract inward:
- one normative source shape, not several accepted aliases;
- one runtime result contract from neighbour libraries:
{ output, trace? }; - child runtime
trace, if returned, is accepted but not merged into dataflow trace in v1; - no compatibility branches before the first release;
- no hidden fallback behavior for malformed artifacts;
- validation rejects unsupported fields instead of interpreting them leniently;
- runtime failure trace is observable in
DataflowRuntimeError.details.tracewhen trace is enabled.
For v1 every pipeline item has exactly one input contract:
contract: {
input: { ref: '$.context.data.payloads.clientComparison' },
output: { ref: '$.context.data.facts.clientComparison' }
}If a later version needs composite input assembly, it must be introduced as a new explicit contract, not as an implicit extension of this one.
Schema nodes and fields are part of the human-readable contract. Each schema node and each declared field must have both title and description. This keeps dataflow artifacts usable as code-as-docs and makes the data contract readable in Flow UI, reviews, and business-requirement traceability.
validateDataflow(source, options?) → ValidationResult
prepareDataflow(source, options?) → DataflowArtifact
executeDataflow(artifact, input, options?) → DataflowOutput
@processengine/dataflows does not know the flow graph, does not move currentStepId, does not persist state, and does not own retry/fail policy.
The examples/ directory contains normative examples:
happy-path.json— minimal valid dataflow artifact;failing-path-missing-input.json— valid artifact that demonstrates runtime missing-input behavior;interop-read-after-write.json— MAPPINGS → DECISIONS read-after-write interop.
See SPEC_RU.md for full normative specification.
See COMPATIBILITY.md for compatibility guarantees.
See MIGRATION.md for migration from Flow 3.