@0dep/bpmn-extensions 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/index.js +17030 -0
- package/dist/package.json +3 -0
- package/package.json +91 -0
- package/src/ElementExtensions.js +142 -0
- package/src/Errors.js +15 -0
- package/src/Expressions.js +49 -0
- package/src/ProcessExtensions.js +49 -0
- package/src/SubProcessExtensions.js +39 -0
- package/src/extensions/ExecutionListeners.js +58 -0
- package/src/extensions/FeelScripts.js +49 -0
- package/src/extensions/Form.js +26 -0
- package/src/extensions/IoMapping.js +68 -0
- package/src/extensions/LoopCharacteristics.js +44 -0
- package/src/extensions/Properties.js +22 -0
- package/src/extensions/TaskDefinition.js +40 -0
- package/src/extensions/TaskHeaders.js +19 -0
- package/src/extensions/formatters.js +67 -0
- package/src/feel.js +60 -0
- package/src/getExtensions.js +70 -0
- package/src/index.js +64 -0
- package/types/index.d.ts +326 -0
- package/types/index.d.ts.map +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zerodep
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# @0dep/bpmn-extensions
|
|
2
|
+
|
|
3
|
+
[](https://github.com/zerodep/bpmn-extensions/actions/workflows/build-latest.yaml)[](https://coveralls.io/github/zerodep/bpmn-extensions?branch=main)[](https://www.npmjs.com/package/@0dep/bpmn-extensions)
|
|
4
|
+
|
|
5
|
+
Flow extensions for [bpmn-elements](https://github.com/paed01/bpmn-elements) with
|
|
6
|
+
[FEEL](https://www.omg.org/dmn/) expression support.
|
|
7
|
+
|
|
8
|
+
It teaches a bpmn-elements engine to run BPMN that uses the `zeebe:*` extension elements and FEEL
|
|
9
|
+
expressions (`= ...`) — the counterpart to [`@onify/flow-extensions`](https://github.com/onify/flow-extensions),
|
|
10
|
+
which covers the older `camunda:*` extension elements.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @0dep/bpmn-extensions bpmn-elements
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`bpmn-elements` (>= 18) is a peer dependency. Requires Node.js >= 22.
|
|
19
|
+
|
|
20
|
+
## What it does
|
|
21
|
+
|
|
22
|
+
- **FEEL expressions** — a `FeelExpressions()` adapter resolves FEEL (`= order.total > 100`)
|
|
23
|
+
everywhere bpmn-elements resolves an expression, including sequence flow conditions.
|
|
24
|
+
- **`zeebe:script`** — a `FeelScripts()` adapter runs a script task's FEEL `expression` and assigns
|
|
25
|
+
the result to its `resultVariable`.
|
|
26
|
+
- **`zeebe:taskDefinition`** — maps a service task's job `type` to an environment service (job worker).
|
|
27
|
+
- **`zeebe:ioMapping`** — input mapping on entry (parent scope) and output mapping on completion
|
|
28
|
+
(job-result scope), with dotted `target` paths. Propagates across boundaries: a call activity's
|
|
29
|
+
input reaches the called process and its output maps the called process result back; a sub
|
|
30
|
+
process's input becomes variables local to its children.
|
|
31
|
+
- **`zeebe:taskHeaders`** / **`zeebe:properties`** — exposed on the element content.
|
|
32
|
+
- **`zeebe:assignmentDefinition`** — assignee / candidate users / groups for user tasks.
|
|
33
|
+
- **`zeebe:formDefinition`** — resolves a user task's form (`formId` / `formKey` / `externalReference`,
|
|
34
|
+
`bindingType`) onto the element content for a task list to render.
|
|
35
|
+
- **`zeebe:executionListeners`** — blocking start/end job workers around an element, called as
|
|
36
|
+
`(elementApi, { retries, headers }, callback)` (`retries` and `headers` present only when the
|
|
37
|
+
listener declares them).
|
|
38
|
+
- **`zeebe:calledElement`** — call activity target process id.
|
|
39
|
+
- **`zeebe:loopCharacteristics`** — collection-based multi-instance (`inputCollection` / `inputElement`),
|
|
40
|
+
sequential or parallel, with `outputElement` aggregated into the `outputCollection` array in input order.
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
- `extensions(element, context)` — the flow extensions factory; pass it as an environment extension.
|
|
45
|
+
- `extendFn(behaviour)` — moddle-context-serializer behaviour extender (lifts the extension data
|
|
46
|
+
bpmn-elements expects on the behaviour: call activity process id and multi-instance collection).
|
|
47
|
+
- `FeelExpressions()` — a bpmn-elements `IExpressions` implementation backed by FEEL.
|
|
48
|
+
- `FeelScripts()` — a bpmn-elements `scripts` implementation that runs `zeebe:script` FEEL expressions.
|
|
49
|
+
- FEEL helpers: `isFeelExpression`, `stripFeel`, `evaluateFeel`, `evaluateFeelUnaryTest`, `resolveValue`.
|
|
50
|
+
- `JobService`, `ServiceError`, `FormatError`.
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
Wire it into a bpmn-elements definition (see `test/helpers/testHelpers.js` for the full helper):
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { createRequire } from 'node:module';
|
|
58
|
+
import { strict as assert } from 'node:assert';
|
|
59
|
+
import BpmnModdle from 'bpmn-moddle';
|
|
60
|
+
import * as elements from 'bpmn-elements';
|
|
61
|
+
import { Serializer, TypeResolver } from 'moddle-context-serializer';
|
|
62
|
+
import { extensions, extendFn, FeelExpressions, FeelScripts } from '@0dep/bpmn-extensions';
|
|
63
|
+
|
|
64
|
+
const require = createRequire(import.meta.url);
|
|
65
|
+
const moddle = new BpmnModdle({ zeebe: require('zeebe-bpmn-moddle/resources/zeebe.json') });
|
|
66
|
+
|
|
67
|
+
const source = `<?xml version="1.0" encoding="UTF-8"?>
|
|
68
|
+
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" id="def">
|
|
69
|
+
<process id="orders" isExecutable="true">
|
|
70
|
+
<startEvent id="start" />
|
|
71
|
+
<sequenceFlow id="to-charge" sourceRef="start" targetRef="charge" />
|
|
72
|
+
<serviceTask id="charge">
|
|
73
|
+
<extensionElements>
|
|
74
|
+
<zeebe:taskDefinition type="charge-card" />
|
|
75
|
+
<zeebe:ioMapping>
|
|
76
|
+
<zeebe:input source="= order.total" target="amount" />
|
|
77
|
+
<zeebe:output source="= transactionId" target="receipt.id" />
|
|
78
|
+
</zeebe:ioMapping>
|
|
79
|
+
</extensionElements>
|
|
80
|
+
</serviceTask>
|
|
81
|
+
<sequenceFlow id="to-end" sourceRef="charge" targetRef="end" />
|
|
82
|
+
<endEvent id="end" />
|
|
83
|
+
</process>
|
|
84
|
+
</definitions>`;
|
|
85
|
+
|
|
86
|
+
const moddleContext = await moddle.fromXML(source);
|
|
87
|
+
const serializer = Serializer(moddleContext, TypeResolver(elements), extendFn);
|
|
88
|
+
|
|
89
|
+
const definition = new elements.Definition(elements.Context(serializer), {
|
|
90
|
+
expressions: FeelExpressions(),
|
|
91
|
+
scripts: FeelScripts(),
|
|
92
|
+
extensions: { flowExtensions: extensions },
|
|
93
|
+
variables: { order: { total: 199 } },
|
|
94
|
+
services: {
|
|
95
|
+
'charge-card'(elementApi, callback) {
|
|
96
|
+
// elementApi.content.input — resolved zeebe:ioMapping input (here `{ amount: 199 }`)
|
|
97
|
+
// elementApi.content.headers — resolved zeebe:taskHeaders
|
|
98
|
+
callback(null, { transactionId: 'tx-1' }); // becomes the job variables for output mapping
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
definition.once('leave', () => {
|
|
104
|
+
console.log(definition.environment.output); // { receipt: { id: 'tx-1' } }
|
|
105
|
+
assert.deepEqual(definition.environment.output, { receipt: { id: 'tx-1' } });
|
|
106
|
+
});
|
|
107
|
+
definition.run();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
A service task's `zeebe:taskDefinition type="charge-card"` is dispatched to the environment
|
|
111
|
+
service named `charge-card`. Its callback result is the job's variables, which `zeebe:ioMapping`
|
|
112
|
+
output parameters map back into the process.
|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
npm test # mocha (BDD, mocha-cakes-2) + lint + run README examples (texample)
|
|
118
|
+
npm run test:md # run the README javascript examples with texample
|
|
119
|
+
npm run dist # bundle the CommonJS build with rollup
|
|
120
|
+
npm run types # generate types/index.d.ts from JSDoc with dts-buddy
|
|
121
|
+
npm run format # eslint --fix && prettier --write
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Flows under test are authored programmatically with `bpmn-moddle` via the `ProcessBuilder` helper
|
|
125
|
+
in `test/helpers/factory.js`, then run on a real bpmn-elements `Definition`. The test harness wires
|
|
126
|
+
the engine's `Logger` to the [`debug`](https://www.npmjs.com/package/debug) package, so
|
|
127
|
+
`DEBUG=bpmn-extensions:* npm test` traces the engine and extensions (`:error:*` for errors only).
|
|
128
|
+
|
|
129
|
+
See the `camunda8-bpmn-schemas` skill (`.claude/skills/`) for a reference of the `zeebe:*`
|
|
130
|
+
extension elements and FEEL.
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|