@emaarco/bpmn-js-data-simulation 0.3.0 → 0.5.0
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/README.md +59 -64
- package/dist/assets/bpmn-js-data-simulation.css +26 -1
- package/dist/domain/PathResolver.d.ts +9 -0
- package/dist/domain/PathResolver.d.ts.map +1 -0
- package/dist/domain/PathVariableDeriver.d.ts +9 -0
- package/dist/domain/PathVariableDeriver.d.ts.map +1 -0
- package/dist/domain/model.d.ts +43 -0
- package/dist/domain/model.d.ts.map +1 -1
- package/dist/index.cjs +236 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +235 -20
- package/dist/index.js.map +1 -1
- package/dist/integration/DataGateways.d.ts +0 -1
- package/dist/integration/DataGateways.d.ts.map +1 -1
- package/dist/integration/DataSimulation.d.ts +2 -2
- package/dist/integration/DataSimulation.d.ts.map +1 -1
- package/dist/integration/PathGraphReader.d.ts +13 -0
- package/dist/integration/PathGraphReader.d.ts.map +1 -0
- package/dist/integration/PathMarkers.d.ts +12 -0
- package/dist/integration/PathMarkers.d.ts.map +1 -0
- package/dist/integration/PathSimulation.d.ts +25 -0
- package/dist/integration/PathSimulation.d.ts.map +1 -0
- package/dist/integration/ScenarioVariables.d.ts +11 -0
- package/dist/integration/ScenarioVariables.d.ts.map +1 -0
- package/dist/integration/index.d.ts +2 -2
- package/dist/integration/index.d.ts.map +1 -1
- package/dist/integration/tokenSimulation.d.ts +6 -0
- package/dist/integration/tokenSimulation.d.ts.map +1 -1
- package/dist/utils/diagramElements.d.ts +6 -1
- package/dist/utils/diagramElements.d.ts.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -1,98 +1,93 @@
|
|
|
1
1
|
# @emaarco/bpmn-js-data-simulation
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@emaarco/bpmn-js-data-simulation)
|
|
4
4
|
[](https://github.com/emaarco/bpmn-js-data-simulation/actions/workflows/ci.yml)
|
|
5
|
-
[](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
processes **with data**: start variables, io mappings and gateway conditions, evaluated the way the
|
|
9
|
-
engine would. No running engine, no clicking the path by hand.
|
|
7
|
+
[](https://emaarco.github.io/bpmn-js-data-simulation/)
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
**Show which path a process takes for real data, right in bpmn-js.**
|
|
10
|
+
|
|
11
|
+
An add-on for the bpmn-js token simulation whose gateways decide by their conditions, the way Zeebe or Camunda 7 would. Pre-1.0: a minor release may still change the API.
|
|
12
12
|
|
|
13
13
|
## Why
|
|
14
14
|
|
|
15
|
-
The token simulation
|
|
16
|
-
conditions, default flows and io mappings are ignored. That explains BPMN, but not _why_ a process
|
|
17
|
-
takes a path, and checking a condition still needs a deployed process and a running engine.
|
|
15
|
+
Seeing the path a process takes for given data usually means deploying it. The token simulation needs no engine, but you click every gateway and it ignores conditions and mappings. This add-on evaluates them in the modeler, viewer or slide your readers see, within [known limits](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/how-it-works.md#limits).
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## What you get
|
|
20
18
|
|
|
21
|
-
- **
|
|
22
|
-
|
|
23
|
-
- **
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
each engine's rules for task results and variables.
|
|
27
|
-
- **Fails visibly.** When no flow matches or a condition fails, the token stops at the gateway and
|
|
28
|
-
it turns red, as an incident would; its card tells why. Fix the data and continue.
|
|
29
|
-
- **Drop-in.** One more module next to the token simulation, in any bpmn-js modeler or viewer. A
|
|
30
|
-
**Data Simulation** switch next to the token simulation's own turns it off for the plain click-through.
|
|
19
|
+
- **See why a path is taken:** gateways that decided turn green, and a card lists each condition, its result and the values it read.
|
|
20
|
+
- **Show the path without running it:** `pathSimulation.simulate(variables)` marks the path the exclusive and inclusive gateways take, for example behind a slider, even in a plain viewer without the token simulation ([path simulation](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/usage.md#path-simulation-what-if)).
|
|
21
|
+
- **Start from a scenario:** the token simulation's ▶ opens a dialog prefilled from a [scenario file](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/scenarios.md) that also mocks task results.
|
|
22
|
+
- **Fail visibly:** if no flow matches or a condition fails, the token stops at a red gateway, like an incident.
|
|
23
|
+
- **Works in modelers and viewers:** one more module next to the token simulation.
|
|
31
24
|
|
|
32
|
-
##
|
|
25
|
+
## Supported engines
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
npm install @emaarco/bpmn-js-data-simulation
|
|
36
|
-
```
|
|
27
|
+
The `engine` option, `'zeebe'` by default, picks how conditions and mappings are read:
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
| Engine | `engine` | Conditions | Mappings |
|
|
30
|
+
| ------------------------------ | ------------ | ------------------------------------------------------------------------------------------------------- | --------------------- |
|
|
31
|
+
| Zeebe (Camunda 8) | `'zeebe'` | FEEL | `zeebe:ioMapping` |
|
|
32
|
+
| Camunda 7, Operaton, CIB seven | `'camunda7'` | [JUEL subset](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/engines.md#juel-subset) | `camunda:inputOutput` |
|
|
39
33
|
|
|
40
|
-
|
|
34
|
+
Conditions it cannot evaluate, such as JUEL method calls or scripts, fall back to a click and end the what-if path ([Engines](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/engines.md)).
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
import BpmnModeler from 'bpmn-js/lib/Modeler'
|
|
44
|
-
import TokenSimulationModule from 'bpmn-js-token-simulation'
|
|
45
|
-
import DataSimulationModule from '@emaarco/bpmn-js-data-simulation'
|
|
46
|
-
import zeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe.json'
|
|
47
|
-
import 'bpmn-js-token-simulation/assets/css/bpmn-js-token-simulation.css'
|
|
48
|
-
import '@emaarco/bpmn-js-data-simulation/assets/bpmn-js-data-simulation.css'
|
|
36
|
+
## Install
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
additionalModules: [TokenSimulationModule, DataSimulationModule],
|
|
53
|
-
moddleExtensions: { zeebe: zeebeModdle },
|
|
54
|
-
dataSimulation: { engine: 'zeebe', scenarios },
|
|
55
|
-
})
|
|
38
|
+
```bash
|
|
39
|
+
npm install @emaarco/bpmn-js-data-simulation bpmn-js-token-simulation zeebe-bpmn-moddle
|
|
56
40
|
```
|
|
57
41
|
|
|
58
|
-
|
|
59
|
-
the process reads, prefilled from a scenario. The [demo](https://emaarco.github.io/bpmn-js-data-simulation/)
|
|
60
|
-
runs Zeebe and Camunda 7 examples. Details: [usage](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/usage.md).
|
|
42
|
+
It needs `bpmn-js` 18 or newer; for Camunda 7, install `camunda-bpmn-moddle` instead of `zeebe-bpmn-moddle`. The full simulation needs `bpmn-js-token-simulation` in your own dependencies, as above; it is an optional peer, so npm does not add it for you.
|
|
61
43
|
|
|
62
|
-
|
|
44
|
+
For the path alone (`PathSimulationModule`), leave the token simulation out:
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
| No match or failed condition | The token waits at the gateway, marked red, until you fix the data |
|
|
70
|
-
| Unsupported condition | The gateway keeps the token simulation's click |
|
|
71
|
-
| Inspect | Gateway cards explain each decision; Process Data in the palette shows the variables |
|
|
46
|
+
```bash
|
|
47
|
+
npm install @emaarco/bpmn-js-data-simulation zeebe-bpmn-moddle
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Get started
|
|
72
51
|
|
|
73
|
-
|
|
52
|
+
1. Register the module next to the token simulation:
|
|
74
53
|
|
|
75
|
-
|
|
54
|
+
```ts
|
|
55
|
+
import BpmnModeler from 'bpmn-js/lib/Modeler'
|
|
56
|
+
import TokenSimulationModule from 'bpmn-js-token-simulation'
|
|
57
|
+
import DataSimulationModule from '@emaarco/bpmn-js-data-simulation'
|
|
58
|
+
import zeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe.json'
|
|
59
|
+
import 'bpmn-js-token-simulation/assets/css/bpmn-js-token-simulation.css'
|
|
60
|
+
import '@emaarco/bpmn-js-data-simulation/assets/bpmn-js-data-simulation.css'
|
|
76
61
|
|
|
77
|
-
|
|
62
|
+
const modeler = new BpmnModeler({
|
|
63
|
+
container: '#canvas',
|
|
64
|
+
additionalModules: [TokenSimulationModule, DataSimulationModule],
|
|
65
|
+
moddleExtensions: { zeebe: zeebeModdle },
|
|
66
|
+
dataSimulation: { engine: 'zeebe' },
|
|
67
|
+
})
|
|
68
|
+
```
|
|
78
69
|
|
|
79
|
-
|
|
70
|
+
For a viewer or Camunda 7, swap the imports as in [Usage](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/usage.md#set-up-the-modeler).
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
2. Turn on the **Token Simulation** switch at the top left and press ▶ on a start event.
|
|
73
|
+
3. Fill in the variables, start, and hover a gateway to see why it decided.
|
|
83
74
|
|
|
84
|
-
|
|
75
|
+
From code, `modeler.get('pathSimulation').simulate({ orderTotal: 6800 })` marks the path instead; a viewer with only `PathSimulationModule` does the same without the token simulation. Full walk-through: [Usage](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/usage.md).
|
|
85
76
|
|
|
86
|
-
##
|
|
77
|
+
## Help and feedback
|
|
87
78
|
|
|
88
|
-
- [Usage](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/usage.md)
|
|
89
|
-
- [
|
|
90
|
-
- [
|
|
91
|
-
- [How it works](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/how-it-works.md): how it plugs into the token simulation, decisions and limits
|
|
79
|
+
- **Documentation:** [Usage](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/usage.md), [Scenarios](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/scenarios.md), [Engines](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/engines.md) and [How it works](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/docs/how-it-works.md).
|
|
80
|
+
- **Demo:** [emaarco.github.io/bpmn-js-data-simulation](https://emaarco.github.io/bpmn-js-data-simulation/).
|
|
81
|
+
- **Bugs and ideas:** [open an issue](https://github.com/emaarco/bpmn-js-data-simulation/issues).
|
|
92
82
|
|
|
93
83
|
## Contributing
|
|
94
84
|
|
|
95
|
-
|
|
85
|
+
Contributions are welcome; see [CONTRIBUTING.md](https://github.com/emaarco/bpmn-js-data-simulation/blob/main/CONTRIBUTING.md).
|
|
86
|
+
|
|
87
|
+
## Credits
|
|
88
|
+
|
|
89
|
+
- [bpmn-js-token-simulation](https://github.com/bpmn-io/bpmn-js-token-simulation) by bpmn.io moves the tokens.
|
|
90
|
+
- [feelin](https://github.com/nikku/feelin) evaluates FEEL.
|
|
96
91
|
|
|
97
92
|
## License
|
|
98
93
|
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
--bds-danger-soft: rgba(201, 42, 42, 0.12);
|
|
22
22
|
--bds-gateway-decided-fill: #e7f3ee;
|
|
23
23
|
--bds-gateway-stuck-fill: #fbe9e9;
|
|
24
|
+
--bds-path-taken: var(--bds-accent);
|
|
25
|
+
--bds-path-skipped-opacity: 0.25;
|
|
24
26
|
|
|
25
27
|
--bds-space-1: 4px;
|
|
26
28
|
--bds-space-2: 8px;
|
|
@@ -67,6 +69,29 @@
|
|
|
67
69
|
stroke-width: 3px !important;
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
.djs-element.bds-path--taken,
|
|
73
|
+
.djs-element.bds-path--skipped {
|
|
74
|
+
transition: opacity var(--bds-motion-fast) var(--bds-ease);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.djs-element.bds-path--skipped {
|
|
78
|
+
opacity: var(--bds-path-skipped-opacity);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.djs-shape.bds-path--taken .djs-visual > :is(rect, circle, polygon) {
|
|
82
|
+
stroke: var(--bds-path-taken) !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.djs-connection.bds-path--taken .djs-visual > path {
|
|
86
|
+
stroke: var(--bds-path-taken) !important;
|
|
87
|
+
stroke-width: 2px !important;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.djs-element.bds-path--stuck .djs-visual > polygon {
|
|
91
|
+
fill: var(--bds-gateway-stuck-fill) !important;
|
|
92
|
+
stroke: var(--bds-danger) !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
70
95
|
.bds-palette-entry svg {
|
|
71
96
|
width: 1em;
|
|
72
97
|
height: 1em;
|
|
@@ -77,7 +102,7 @@
|
|
|
77
102
|
stroke-linejoin: round;
|
|
78
103
|
}
|
|
79
104
|
|
|
80
|
-
.bds-palette-entry[hidden] {
|
|
105
|
+
.bts-palette .bds-palette-entry[hidden] {
|
|
81
106
|
display: none;
|
|
82
107
|
}
|
|
83
108
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type EvaluateCondition } from './GatewayRouter.js';
|
|
2
|
+
import type { PathGraph, SimulatedPath } from './model.js';
|
|
3
|
+
export declare class PathResolver {
|
|
4
|
+
private readonly router;
|
|
5
|
+
resolve(graph: PathGraph, evaluateCondition: EvaluateCondition): SimulatedPath;
|
|
6
|
+
private leave;
|
|
7
|
+
private sumMeasures;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=PathResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathResolver.d.ts","sourceRoot":"","sources":["../../src/domain/PathResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,oBAAoB,CAAA;AAC1E,OAAO,KAAK,EAAY,SAAS,EAA6B,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/F,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAE7C,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,aAAa;IA0B9E,OAAO,CAAC,KAAK;IAWb,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConditionReads, PathVariable, Variables } from './model.js';
|
|
2
|
+
export declare class PathVariableDeriver {
|
|
3
|
+
derive(conditions: readonly ConditionReads[], values: Variables): PathVariable[];
|
|
4
|
+
private variableFor;
|
|
5
|
+
private rangeAround;
|
|
6
|
+
private niceCeiling;
|
|
7
|
+
private numberLiterals;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=PathVariableDeriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathVariableDeriver.d.ts","sourceRoot":"","sources":["../../src/domain/PathVariableDeriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAMtF,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE;IAQhF,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;CAGvB"}
|
package/dist/domain/model.d.ts
CHANGED
|
@@ -61,4 +61,47 @@ export interface StartFieldHints {
|
|
|
61
61
|
examples?: Variables[];
|
|
62
62
|
taskResultNames?: string[];
|
|
63
63
|
}
|
|
64
|
+
export interface PathFlow extends OutgoingFlow {
|
|
65
|
+
targetId: string;
|
|
66
|
+
}
|
|
67
|
+
export interface PathNode {
|
|
68
|
+
id: string;
|
|
69
|
+
gatewayKind?: GatewayKind;
|
|
70
|
+
outgoing: PathFlow[];
|
|
71
|
+
nestedStartIds: string[];
|
|
72
|
+
measures: Record<string, number>;
|
|
73
|
+
}
|
|
74
|
+
export interface PathGraph {
|
|
75
|
+
startIds: string[];
|
|
76
|
+
nodes: PathNode[];
|
|
77
|
+
}
|
|
78
|
+
export interface SimulatedPath {
|
|
79
|
+
taken: string[];
|
|
80
|
+
skipped: string[];
|
|
81
|
+
decisions: Record<string, RoutingDecision>;
|
|
82
|
+
measures: Record<string, number>;
|
|
83
|
+
}
|
|
84
|
+
export interface ConditionReads {
|
|
85
|
+
expression: string;
|
|
86
|
+
variableNames: string[];
|
|
87
|
+
}
|
|
88
|
+
export interface NumberRange {
|
|
89
|
+
min: number;
|
|
90
|
+
max: number;
|
|
91
|
+
step: number;
|
|
92
|
+
}
|
|
93
|
+
export type PathVariable = {
|
|
94
|
+
name: string;
|
|
95
|
+
type: 'boolean';
|
|
96
|
+
} | {
|
|
97
|
+
name: string;
|
|
98
|
+
type: 'number';
|
|
99
|
+
range: NumberRange;
|
|
100
|
+
} | {
|
|
101
|
+
name: string;
|
|
102
|
+
type: 'text';
|
|
103
|
+
} | {
|
|
104
|
+
name: string;
|
|
105
|
+
type: 'json';
|
|
106
|
+
};
|
|
64
107
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/domain/model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAE/C,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAErF,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,W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pB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1041,6 +1041,9 @@ function is(element, type) {
|
|
|
1041
1041
|
const businessObject = element.businessObject;
|
|
1042
1042
|
return typeof businessObject?.$instanceOf === "function" && businessObject.$instanceOf(type);
|
|
1043
1043
|
}
|
|
1044
|
+
function flowNodesOf(elementRegistry) {
|
|
1045
|
+
return elementRegistry.filter((element) => element.id === element.businessObject.id && is(element, "bpmn:FlowNode"));
|
|
1046
|
+
}
|
|
1044
1047
|
function isGateway(element) {
|
|
1045
1048
|
return element.type === "bpmn:ExclusiveGateway" || element.type === "bpmn:InclusiveGateway";
|
|
1046
1049
|
}
|
|
@@ -1049,6 +1052,18 @@ function gatewayOf(element) {
|
|
|
1049
1052
|
if (element.type === "bpmn:SequenceFlow" && element.source && isGateway(element.source)) return element.source.id;
|
|
1050
1053
|
return void 0;
|
|
1051
1054
|
}
|
|
1055
|
+
function outgoingSequenceFlows(element) {
|
|
1056
|
+
return (element.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
1057
|
+
}
|
|
1058
|
+
function readOutgoingFlow(sequenceFlow, engine) {
|
|
1059
|
+
const name = sequenceFlow.businessObject.name;
|
|
1060
|
+
return {
|
|
1061
|
+
id: sequenceFlow.id,
|
|
1062
|
+
...typeof name === "string" && name ? { name } : {},
|
|
1063
|
+
expression: engine.readCondition(sequenceFlow.businessObject),
|
|
1064
|
+
isDefault: sequenceFlow.source?.businessObject.default === sequenceFlow.businessObject
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1052
1067
|
|
|
1053
1068
|
class DataGateways {
|
|
1054
1069
|
constructor(dataSimulation, store, simulator) {
|
|
@@ -1070,7 +1085,7 @@ class DataGateways {
|
|
|
1070
1085
|
return;
|
|
1071
1086
|
}
|
|
1072
1087
|
for (const flowId of decision.takenFlowIds) {
|
|
1073
|
-
const flow =
|
|
1088
|
+
const flow = outgoingSequenceFlows(gateway).find((candidate) => candidate.id === flowId);
|
|
1074
1089
|
this.simulator.enter({ element: flow, scope: scope.parent });
|
|
1075
1090
|
}
|
|
1076
1091
|
}
|
|
@@ -1128,19 +1143,7 @@ class DataGateways {
|
|
|
1128
1143
|
}
|
|
1129
1144
|
outgoingFlows(gateway) {
|
|
1130
1145
|
const engine = this.dataSimulation.getEngine();
|
|
1131
|
-
|
|
1132
|
-
return this.sequenceFlows(gateway).map((flow) => {
|
|
1133
|
-
const name = flow.businessObject.name;
|
|
1134
|
-
return {
|
|
1135
|
-
id: flow.id,
|
|
1136
|
-
...typeof name === "string" && name ? { name } : {},
|
|
1137
|
-
expression: engine.readCondition(flow.businessObject),
|
|
1138
|
-
isDefault: flow.businessObject === defaultFlow
|
|
1139
|
-
};
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
sequenceFlows(gateway) {
|
|
1143
|
-
return (gateway.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
1146
|
+
return outgoingSequenceFlows(gateway).map((flow) => readOutgoingFlow(flow, engine));
|
|
1144
1147
|
}
|
|
1145
1148
|
}
|
|
1146
1149
|
DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
|
|
@@ -1196,10 +1199,15 @@ const TRACE_EVENT = "tokenSimulation.simulator.trace";
|
|
|
1196
1199
|
const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
|
|
1197
1200
|
|
|
1198
1201
|
class DataSimulation {
|
|
1199
|
-
constructor(config, eventBus, store) {
|
|
1202
|
+
constructor(config, eventBus, store, injector) {
|
|
1200
1203
|
this.eventBus = eventBus;
|
|
1201
1204
|
this.store = store;
|
|
1202
1205
|
this.scenarioParser = new ScenarioParser();
|
|
1206
|
+
if (!injector.get("simulator", false)) {
|
|
1207
|
+
throw new Error(
|
|
1208
|
+
"DataSimulationModule needs bpmn-js-token-simulation; for the path alone use PathSimulationModule"
|
|
1209
|
+
);
|
|
1210
|
+
}
|
|
1203
1211
|
this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
|
|
1204
1212
|
this.ioMappings = new IoMappings(this.engine, store);
|
|
1205
1213
|
this.enabled = config?.enabled ?? true;
|
|
@@ -1262,7 +1270,7 @@ class DataSimulation {
|
|
|
1262
1270
|
if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
|
|
1263
1271
|
}
|
|
1264
1272
|
}
|
|
1265
|
-
DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore"];
|
|
1273
|
+
DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore", "injector"];
|
|
1266
1274
|
|
|
1267
1275
|
class GatewayDecisionView {
|
|
1268
1276
|
constructor(snapshot) {
|
|
@@ -1432,7 +1440,7 @@ function createSheet() {
|
|
|
1432
1440
|
|
|
1433
1441
|
const OUTCOME_OVERLAY = "bds-flow-outcome";
|
|
1434
1442
|
const DECIDED_MARKER = "bds-gateway--decided";
|
|
1435
|
-
const STUCK_MARKER = "bds-gateway--stuck";
|
|
1443
|
+
const STUCK_MARKER$1 = "bds-gateway--stuck";
|
|
1436
1444
|
const BADGE_DISTANCE = 38;
|
|
1437
1445
|
const BADGE_MIN_SCALE = 1;
|
|
1438
1446
|
class DataSimulationOverlays {
|
|
@@ -1487,13 +1495,13 @@ class DataSimulationOverlays {
|
|
|
1487
1495
|
markGateway({ elementId, decision }) {
|
|
1488
1496
|
const gateway = this.elementRegistry.get(elementId);
|
|
1489
1497
|
if (!gateway) return;
|
|
1490
|
-
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
|
|
1498
|
+
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1491
1499
|
this.markedGateways.push(gateway);
|
|
1492
1500
|
}
|
|
1493
1501
|
unmarkGateways() {
|
|
1494
1502
|
for (const gateway of this.markedGateways) {
|
|
1495
1503
|
this.canvas.removeMarker(gateway, DECIDED_MARKER);
|
|
1496
|
-
this.canvas.removeMarker(gateway, STUCK_MARKER);
|
|
1504
|
+
this.canvas.removeMarker(gateway, STUCK_MARKER$1);
|
|
1497
1505
|
}
|
|
1498
1506
|
this.markedGateways = [];
|
|
1499
1507
|
}
|
|
@@ -2060,7 +2068,214 @@ class DataStartForm {
|
|
|
2060
2068
|
}
|
|
2061
2069
|
DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
|
|
2062
2070
|
|
|
2071
|
+
class PathResolver {
|
|
2072
|
+
constructor() {
|
|
2073
|
+
this.router = new GatewayRouter();
|
|
2074
|
+
}
|
|
2075
|
+
resolve(graph, evaluateCondition) {
|
|
2076
|
+
const nodes = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
2077
|
+
const takenIds = /* @__PURE__ */ new Set();
|
|
2078
|
+
const decisions = {};
|
|
2079
|
+
const pendingIds = [...graph.startIds];
|
|
2080
|
+
while (pendingIds.length) {
|
|
2081
|
+
const node = nodes.get(pendingIds.shift());
|
|
2082
|
+
if (!node || takenIds.has(node.id)) continue;
|
|
2083
|
+
takenIds.add(node.id);
|
|
2084
|
+
pendingIds.push(...node.nestedStartIds);
|
|
2085
|
+
for (const flow of this.leave(node, evaluateCondition, decisions)) {
|
|
2086
|
+
takenIds.add(flow.id);
|
|
2087
|
+
pendingIds.push(flow.targetId);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
const elementIds = graph.nodes.flatMap((node) => [node.id, ...node.outgoing.map((flow) => flow.id)]);
|
|
2091
|
+
return {
|
|
2092
|
+
taken: elementIds.filter((id) => takenIds.has(id)),
|
|
2093
|
+
skipped: elementIds.filter((id) => !takenIds.has(id)),
|
|
2094
|
+
decisions,
|
|
2095
|
+
measures: this.sumMeasures(graph.nodes.filter((node) => takenIds.has(node.id)))
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
leave(node, evaluateCondition, decisions) {
|
|
2099
|
+
if (!node.gatewayKind || node.outgoing.length < 2) return node.outgoing;
|
|
2100
|
+
const decision = this.router.route(node.gatewayKind, node.outgoing, evaluateCondition);
|
|
2101
|
+
decisions[node.id] = decision;
|
|
2102
|
+
return node.outgoing.filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
2103
|
+
}
|
|
2104
|
+
sumMeasures(nodes) {
|
|
2105
|
+
const totals = {};
|
|
2106
|
+
for (const node of nodes) {
|
|
2107
|
+
for (const [name, value] of Object.entries(node.measures)) totals[name] = (totals[name] ?? 0) + value;
|
|
2108
|
+
}
|
|
2109
|
+
return totals;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
const NICE_STEPS = [1, 2, 5, 10];
|
|
2114
|
+
const RANGE_STEPS = 100;
|
|
2115
|
+
const NUMBER_LITERAL = /(?<![\w.])\d+(?:\.\d+)?/g;
|
|
2116
|
+
class PathVariableDeriver {
|
|
2117
|
+
derive(conditions, values) {
|
|
2118
|
+
const names = [...new Set(conditions.flatMap((condition) => condition.variableNames))];
|
|
2119
|
+
return names.map((name) => {
|
|
2120
|
+
const conditionsReadingName = conditions.filter((condition) => condition.variableNames.includes(name));
|
|
2121
|
+
return this.variableFor(name, values[name], conditionsReadingName);
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
variableFor(name, value, conditionsReadingName) {
|
|
2125
|
+
if (typeof value === "boolean") return { name, type: "boolean" };
|
|
2126
|
+
if (typeof value === "number") {
|
|
2127
|
+
const comparedNumbers = conditionsReadingName.flatMap((condition) => this.numberLiterals(condition.expression));
|
|
2128
|
+
return { name, type: "number", range: this.rangeAround(value, comparedNumbers) };
|
|
2129
|
+
}
|
|
2130
|
+
if (value === void 0 || typeof value === "string") return { name, type: "text" };
|
|
2131
|
+
return { name, type: "json" };
|
|
2132
|
+
}
|
|
2133
|
+
rangeAround(value, comparedNumbers) {
|
|
2134
|
+
const max = this.niceCeiling(2 * Math.max(Math.abs(value), ...comparedNumbers));
|
|
2135
|
+
return { min: 0, max, step: max / RANGE_STEPS };
|
|
2136
|
+
}
|
|
2137
|
+
niceCeiling(value) {
|
|
2138
|
+
if (value <= 0) return 1;
|
|
2139
|
+
const magnitude = 10 ** Math.floor(Math.log10(value));
|
|
2140
|
+
return NICE_STEPS.find((step) => step * magnitude >= value) * magnitude;
|
|
2141
|
+
}
|
|
2142
|
+
numberLiterals(expression) {
|
|
2143
|
+
return (expression.match(NUMBER_LITERAL) ?? []).map(Number);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
const GATEWAY_KINDS = {
|
|
2148
|
+
"bpmn:ExclusiveGateway": "exclusive",
|
|
2149
|
+
"bpmn:InclusiveGateway": "inclusive"
|
|
2150
|
+
};
|
|
2151
|
+
class PathGraphReader {
|
|
2152
|
+
constructor(elementRegistry, engine) {
|
|
2153
|
+
this.elementRegistry = elementRegistry;
|
|
2154
|
+
this.engine = engine;
|
|
2155
|
+
}
|
|
2156
|
+
read(measureNames) {
|
|
2157
|
+
const flowNodes = flowNodesOf(this.elementRegistry);
|
|
2158
|
+
const startEventsIn = (container) => flowNodes.filter((node) => is(node, "bpmn:StartEvent") && node.businessObject.$parent === container);
|
|
2159
|
+
const processStartIds = flowNodes.filter((node) => is(node, "bpmn:StartEvent") && this.isProcess(node.businessObject.$parent)).map((node) => node.id);
|
|
2160
|
+
return {
|
|
2161
|
+
startIds: processStartIds,
|
|
2162
|
+
nodes: flowNodes.map((node) => this.toPathNode(node, startEventsIn, measureNames))
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
toPathNode(node, startEventsIn, measureNames) {
|
|
2166
|
+
const entersSubProcess = is(node, "bpmn:SubProcess") && !node.businessObject.triggeredByEvent;
|
|
2167
|
+
return {
|
|
2168
|
+
id: node.id,
|
|
2169
|
+
...GATEWAY_KINDS[node.type] ? { gatewayKind: GATEWAY_KINDS[node.type] } : {},
|
|
2170
|
+
outgoing: outgoingSequenceFlows(node).map((flow) => ({
|
|
2171
|
+
...readOutgoingFlow(flow, this.engine),
|
|
2172
|
+
targetId: flow.target.id
|
|
2173
|
+
})),
|
|
2174
|
+
nestedStartIds: entersSubProcess ? startEventsIn(node.businessObject).map((start) => start.id) : [],
|
|
2175
|
+
measures: Object.fromEntries(measureNames.map((name) => [name, this.readMeasure(node.businessObject, name)]))
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
isProcess(element) {
|
|
2179
|
+
return element?.$type === "bpmn:Process";
|
|
2180
|
+
}
|
|
2181
|
+
readMeasure(businessObject, name) {
|
|
2182
|
+
const attribute = businessObject.$attrs?.[name];
|
|
2183
|
+
const value = typeof attribute === "string" && attribute.trim() ? Number(attribute) : Number.NaN;
|
|
2184
|
+
return Number.isFinite(value) ? value : 0;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
const TAKEN_MARKER = "bds-path--taken";
|
|
2189
|
+
const SKIPPED_MARKER = "bds-path--skipped";
|
|
2190
|
+
const STUCK_MARKER = "bds-path--stuck";
|
|
2191
|
+
class PathMarkers {
|
|
2192
|
+
constructor(canvas, elementRegistry) {
|
|
2193
|
+
this.canvas = canvas;
|
|
2194
|
+
this.elementRegistry = elementRegistry;
|
|
2195
|
+
this.marked = [];
|
|
2196
|
+
}
|
|
2197
|
+
show(path) {
|
|
2198
|
+
this.clear();
|
|
2199
|
+
for (const id of path.taken) this.mark(id, TAKEN_MARKER);
|
|
2200
|
+
for (const id of path.skipped) this.mark(id, SKIPPED_MARKER);
|
|
2201
|
+
for (const [gatewayId, decision] of Object.entries(path.decisions)) {
|
|
2202
|
+
if (decision.stuckReason) this.mark(gatewayId, STUCK_MARKER);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
clear() {
|
|
2206
|
+
for (const { element, marker } of this.marked) this.canvas.removeMarker(element, marker);
|
|
2207
|
+
this.marked = [];
|
|
2208
|
+
}
|
|
2209
|
+
mark(id, marker) {
|
|
2210
|
+
const element = this.elementRegistry.get(id);
|
|
2211
|
+
if (!element) return;
|
|
2212
|
+
for (const markedElement of [element, ...element.labels ?? []]) {
|
|
2213
|
+
this.canvas.addMarker(markedElement, marker);
|
|
2214
|
+
this.marked.push({ element: markedElement, marker });
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
class ScenarioVariables {
|
|
2220
|
+
constructor(elementRegistry, engine) {
|
|
2221
|
+
this.elementRegistry = elementRegistry;
|
|
2222
|
+
this.engine = engine;
|
|
2223
|
+
}
|
|
2224
|
+
of(scenario, fallbacks) {
|
|
2225
|
+
const fallbackVariables = fallbacks.map((fallback) => this.afterOutputMappings(fallback));
|
|
2226
|
+
return Object.assign({}, ...fallbackVariables, this.afterOutputMappings(scenario));
|
|
2227
|
+
}
|
|
2228
|
+
afterOutputMappings(scenario) {
|
|
2229
|
+
let variables = Object.assign({}, scenario?.variables, ...Object.values(scenario?.taskResults ?? {}));
|
|
2230
|
+
for (const flowNode of flowNodesOf(this.elementRegistry)) {
|
|
2231
|
+
for (const { source, target } of this.engine.readIoMappings(flowNode.businessObject).outputs) {
|
|
2232
|
+
const evaluation = this.engine.evaluate(source, variables);
|
|
2233
|
+
if (evaluation.ok) variables = this.engine.writeVariable(variables, target, evaluation.value);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
return variables;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
class PathSimulation {
|
|
2241
|
+
constructor(config, elementRegistry, canvas) {
|
|
2242
|
+
this.pathResolver = new PathResolver();
|
|
2243
|
+
this.pathVariableDeriver = new PathVariableDeriver();
|
|
2244
|
+
this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
|
|
2245
|
+
this.pathGraphReader = new PathGraphReader(elementRegistry, this.engine);
|
|
2246
|
+
this.pathMarkers = new PathMarkers(canvas, elementRegistry);
|
|
2247
|
+
this.scenarioVariables = new ScenarioVariables(elementRegistry, this.engine);
|
|
2248
|
+
}
|
|
2249
|
+
getEngine() {
|
|
2250
|
+
return this.engine;
|
|
2251
|
+
}
|
|
2252
|
+
simulate(variables, options = {}) {
|
|
2253
|
+
const graph = this.pathGraphReader.read(options.measures ?? []);
|
|
2254
|
+
const path = this.pathResolver.resolve(graph, (expression) => this.engine.evaluate(expression, variables));
|
|
2255
|
+
this.pathMarkers.show(path);
|
|
2256
|
+
return path;
|
|
2257
|
+
}
|
|
2258
|
+
deriveVariables(values) {
|
|
2259
|
+
return this.pathVariableDeriver.derive(this.evaluableConditions(), values);
|
|
2260
|
+
}
|
|
2261
|
+
variablesOf(scenario, fallbacks = []) {
|
|
2262
|
+
return this.scenarioVariables.of(scenario, fallbacks);
|
|
2263
|
+
}
|
|
2264
|
+
clear() {
|
|
2265
|
+
this.pathMarkers.clear();
|
|
2266
|
+
}
|
|
2267
|
+
evaluableConditions() {
|
|
2268
|
+
return this.pathGraphReader.read([]).nodes.flatMap((node) => node.outgoing.map((flow) => flow.expression)).filter((expression) => expression !== void 0 && this.engine.canEvaluate(expression)).map((expression) => ({ expression, variableNames: this.engine.readVariableNames(expression) }));
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
PathSimulation.$inject = ["config.dataSimulation", "elementRegistry", "canvas"];
|
|
2272
|
+
|
|
2273
|
+
const PathSimulationModule = {
|
|
2274
|
+
__init__: [],
|
|
2275
|
+
pathSimulation: ["type", PathSimulation]
|
|
2276
|
+
};
|
|
2063
2277
|
const DataSimulationModule = {
|
|
2278
|
+
__depends__: [PathSimulationModule],
|
|
2064
2279
|
__init__: [
|
|
2065
2280
|
"dataSimulation",
|
|
2066
2281
|
"dataSimulationOverlays",
|
|
@@ -2083,9 +2298,11 @@ const DataSimulationModule = {
|
|
|
2083
2298
|
};
|
|
2084
2299
|
|
|
2085
2300
|
exports.Camunda7Engine = Camunda7Engine;
|
|
2301
|
+
exports.DataSimulationModule = DataSimulationModule;
|
|
2086
2302
|
exports.DataSimulationStore = DataSimulationStore;
|
|
2087
2303
|
exports.EngineRegistry = EngineRegistry;
|
|
2088
2304
|
exports.GatewayRouter = GatewayRouter;
|
|
2305
|
+
exports.PathSimulationModule = PathSimulationModule;
|
|
2089
2306
|
exports.ScenarioError = ScenarioError;
|
|
2090
2307
|
exports.ScenarioParser = ScenarioParser;
|
|
2091
2308
|
exports.SimpleStartFormRenderer = SimpleStartFormRenderer;
|