@emaarco/bpmn-js-data-simulation 0.3.0 → 0.4.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/model.d.ts +20 -0
- package/dist/domain/model.d.ts.map +1 -1
- package/dist/index.cjs +169 -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 +168 -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 +20 -0
- package/dist/integration/PathSimulation.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 +4 -0
- 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"}
|
package/dist/domain/model.d.ts
CHANGED
|
@@ -61,4 +61,24 @@ 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
|
+
}
|
|
64
84
|
//# 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,WAAW,CAAA;AAEnD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAA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,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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1049,6 +1049,18 @@ function gatewayOf(element) {
|
|
|
1049
1049
|
if (element.type === "bpmn:SequenceFlow" && element.source && isGateway(element.source)) return element.source.id;
|
|
1050
1050
|
return void 0;
|
|
1051
1051
|
}
|
|
1052
|
+
function outgoingSequenceFlows(element) {
|
|
1053
|
+
return (element.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
1054
|
+
}
|
|
1055
|
+
function readOutgoingFlow(sequenceFlow, engine) {
|
|
1056
|
+
const name = sequenceFlow.businessObject.name;
|
|
1057
|
+
return {
|
|
1058
|
+
id: sequenceFlow.id,
|
|
1059
|
+
...typeof name === "string" && name ? { name } : {},
|
|
1060
|
+
expression: engine.readCondition(sequenceFlow.businessObject),
|
|
1061
|
+
isDefault: sequenceFlow.source?.businessObject.default === sequenceFlow.businessObject
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1052
1064
|
|
|
1053
1065
|
class DataGateways {
|
|
1054
1066
|
constructor(dataSimulation, store, simulator) {
|
|
@@ -1070,7 +1082,7 @@ class DataGateways {
|
|
|
1070
1082
|
return;
|
|
1071
1083
|
}
|
|
1072
1084
|
for (const flowId of decision.takenFlowIds) {
|
|
1073
|
-
const flow =
|
|
1085
|
+
const flow = outgoingSequenceFlows(gateway).find((candidate) => candidate.id === flowId);
|
|
1074
1086
|
this.simulator.enter({ element: flow, scope: scope.parent });
|
|
1075
1087
|
}
|
|
1076
1088
|
}
|
|
@@ -1128,19 +1140,7 @@ class DataGateways {
|
|
|
1128
1140
|
}
|
|
1129
1141
|
outgoingFlows(gateway) {
|
|
1130
1142
|
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"));
|
|
1143
|
+
return outgoingSequenceFlows(gateway).map((flow) => readOutgoingFlow(flow, engine));
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
1146
1146
|
DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
|
|
@@ -1196,10 +1196,15 @@ const TRACE_EVENT = "tokenSimulation.simulator.trace";
|
|
|
1196
1196
|
const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
|
|
1197
1197
|
|
|
1198
1198
|
class DataSimulation {
|
|
1199
|
-
constructor(config, eventBus, store) {
|
|
1199
|
+
constructor(config, eventBus, store, injector) {
|
|
1200
1200
|
this.eventBus = eventBus;
|
|
1201
1201
|
this.store = store;
|
|
1202
1202
|
this.scenarioParser = new ScenarioParser();
|
|
1203
|
+
if (!injector.get("simulator", false)) {
|
|
1204
|
+
throw new Error(
|
|
1205
|
+
"DataSimulationModule needs bpmn-js-token-simulation; for the path alone use PathSimulationModule"
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1203
1208
|
this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
|
|
1204
1209
|
this.ioMappings = new IoMappings(this.engine, store);
|
|
1205
1210
|
this.enabled = config?.enabled ?? true;
|
|
@@ -1262,7 +1267,7 @@ class DataSimulation {
|
|
|
1262
1267
|
if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
|
|
1263
1268
|
}
|
|
1264
1269
|
}
|
|
1265
|
-
DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore"];
|
|
1270
|
+
DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore", "injector"];
|
|
1266
1271
|
|
|
1267
1272
|
class GatewayDecisionView {
|
|
1268
1273
|
constructor(snapshot) {
|
|
@@ -1432,7 +1437,7 @@ function createSheet() {
|
|
|
1432
1437
|
|
|
1433
1438
|
const OUTCOME_OVERLAY = "bds-flow-outcome";
|
|
1434
1439
|
const DECIDED_MARKER = "bds-gateway--decided";
|
|
1435
|
-
const STUCK_MARKER = "bds-gateway--stuck";
|
|
1440
|
+
const STUCK_MARKER$1 = "bds-gateway--stuck";
|
|
1436
1441
|
const BADGE_DISTANCE = 38;
|
|
1437
1442
|
const BADGE_MIN_SCALE = 1;
|
|
1438
1443
|
class DataSimulationOverlays {
|
|
@@ -1487,13 +1492,13 @@ class DataSimulationOverlays {
|
|
|
1487
1492
|
markGateway({ elementId, decision }) {
|
|
1488
1493
|
const gateway = this.elementRegistry.get(elementId);
|
|
1489
1494
|
if (!gateway) return;
|
|
1490
|
-
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
|
|
1495
|
+
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1491
1496
|
this.markedGateways.push(gateway);
|
|
1492
1497
|
}
|
|
1493
1498
|
unmarkGateways() {
|
|
1494
1499
|
for (const gateway of this.markedGateways) {
|
|
1495
1500
|
this.canvas.removeMarker(gateway, DECIDED_MARKER);
|
|
1496
|
-
this.canvas.removeMarker(gateway, STUCK_MARKER);
|
|
1501
|
+
this.canvas.removeMarker(gateway, STUCK_MARKER$1);
|
|
1497
1502
|
}
|
|
1498
1503
|
this.markedGateways = [];
|
|
1499
1504
|
}
|
|
@@ -2060,7 +2065,150 @@ class DataStartForm {
|
|
|
2060
2065
|
}
|
|
2061
2066
|
DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
|
|
2062
2067
|
|
|
2068
|
+
class PathResolver {
|
|
2069
|
+
constructor() {
|
|
2070
|
+
this.router = new GatewayRouter();
|
|
2071
|
+
}
|
|
2072
|
+
resolve(graph, evaluateCondition) {
|
|
2073
|
+
const nodes = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
2074
|
+
const takenIds = /* @__PURE__ */ new Set();
|
|
2075
|
+
const decisions = {};
|
|
2076
|
+
const pendingIds = [...graph.startIds];
|
|
2077
|
+
while (pendingIds.length) {
|
|
2078
|
+
const node = nodes.get(pendingIds.shift());
|
|
2079
|
+
if (!node || takenIds.has(node.id)) continue;
|
|
2080
|
+
takenIds.add(node.id);
|
|
2081
|
+
pendingIds.push(...node.nestedStartIds);
|
|
2082
|
+
for (const flow of this.leave(node, evaluateCondition, decisions)) {
|
|
2083
|
+
takenIds.add(flow.id);
|
|
2084
|
+
pendingIds.push(flow.targetId);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
const elementIds = graph.nodes.flatMap((node) => [node.id, ...node.outgoing.map((flow) => flow.id)]);
|
|
2088
|
+
return {
|
|
2089
|
+
taken: elementIds.filter((id) => takenIds.has(id)),
|
|
2090
|
+
skipped: elementIds.filter((id) => !takenIds.has(id)),
|
|
2091
|
+
decisions,
|
|
2092
|
+
measures: this.sumMeasures(graph.nodes.filter((node) => takenIds.has(node.id)))
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
leave(node, evaluateCondition, decisions) {
|
|
2096
|
+
if (!node.gatewayKind || node.outgoing.length < 2) return node.outgoing;
|
|
2097
|
+
const decision = this.router.route(node.gatewayKind, node.outgoing, evaluateCondition);
|
|
2098
|
+
decisions[node.id] = decision;
|
|
2099
|
+
return node.outgoing.filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
2100
|
+
}
|
|
2101
|
+
sumMeasures(nodes) {
|
|
2102
|
+
const totals = {};
|
|
2103
|
+
for (const node of nodes) {
|
|
2104
|
+
for (const [name, value] of Object.entries(node.measures)) totals[name] = (totals[name] ?? 0) + value;
|
|
2105
|
+
}
|
|
2106
|
+
return totals;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
const GATEWAY_KINDS = {
|
|
2111
|
+
"bpmn:ExclusiveGateway": "exclusive",
|
|
2112
|
+
"bpmn:InclusiveGateway": "inclusive"
|
|
2113
|
+
};
|
|
2114
|
+
class PathGraphReader {
|
|
2115
|
+
constructor(elementRegistry, engine) {
|
|
2116
|
+
this.elementRegistry = elementRegistry;
|
|
2117
|
+
this.engine = engine;
|
|
2118
|
+
}
|
|
2119
|
+
read(measureNames) {
|
|
2120
|
+
const flowNodes = this.elementRegistry.filter(
|
|
2121
|
+
(element) => element.id === element.businessObject.id && is(element, "bpmn:FlowNode")
|
|
2122
|
+
);
|
|
2123
|
+
const startEventsIn = (container) => flowNodes.filter((node) => is(node, "bpmn:StartEvent") && node.businessObject.$parent === container);
|
|
2124
|
+
const processStartIds = flowNodes.filter((node) => is(node, "bpmn:StartEvent") && this.isProcess(node.businessObject.$parent)).map((node) => node.id);
|
|
2125
|
+
return {
|
|
2126
|
+
startIds: processStartIds,
|
|
2127
|
+
nodes: flowNodes.map((node) => this.toPathNode(node, startEventsIn, measureNames))
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
toPathNode(node, startEventsIn, measureNames) {
|
|
2131
|
+
const entersSubProcess = is(node, "bpmn:SubProcess") && !node.businessObject.triggeredByEvent;
|
|
2132
|
+
return {
|
|
2133
|
+
id: node.id,
|
|
2134
|
+
...GATEWAY_KINDS[node.type] ? { gatewayKind: GATEWAY_KINDS[node.type] } : {},
|
|
2135
|
+
outgoing: outgoingSequenceFlows(node).map((flow) => ({
|
|
2136
|
+
...readOutgoingFlow(flow, this.engine),
|
|
2137
|
+
targetId: flow.target.id
|
|
2138
|
+
})),
|
|
2139
|
+
nestedStartIds: entersSubProcess ? startEventsIn(node.businessObject).map((start) => start.id) : [],
|
|
2140
|
+
measures: Object.fromEntries(measureNames.map((name) => [name, this.readMeasure(node.businessObject, name)]))
|
|
2141
|
+
};
|
|
2142
|
+
}
|
|
2143
|
+
isProcess(element) {
|
|
2144
|
+
return element?.$type === "bpmn:Process";
|
|
2145
|
+
}
|
|
2146
|
+
readMeasure(businessObject, name) {
|
|
2147
|
+
const attribute = businessObject.$attrs?.[name];
|
|
2148
|
+
const value = typeof attribute === "string" && attribute.trim() ? Number(attribute) : Number.NaN;
|
|
2149
|
+
return Number.isFinite(value) ? value : 0;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
const TAKEN_MARKER = "bds-path--taken";
|
|
2154
|
+
const SKIPPED_MARKER = "bds-path--skipped";
|
|
2155
|
+
const STUCK_MARKER = "bds-path--stuck";
|
|
2156
|
+
class PathMarkers {
|
|
2157
|
+
constructor(canvas, elementRegistry) {
|
|
2158
|
+
this.canvas = canvas;
|
|
2159
|
+
this.elementRegistry = elementRegistry;
|
|
2160
|
+
this.marked = [];
|
|
2161
|
+
}
|
|
2162
|
+
show(path) {
|
|
2163
|
+
this.clear();
|
|
2164
|
+
for (const id of path.taken) this.mark(id, TAKEN_MARKER);
|
|
2165
|
+
for (const id of path.skipped) this.mark(id, SKIPPED_MARKER);
|
|
2166
|
+
for (const [gatewayId, decision] of Object.entries(path.decisions)) {
|
|
2167
|
+
if (decision.stuckReason) this.mark(gatewayId, STUCK_MARKER);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
clear() {
|
|
2171
|
+
for (const { element, marker } of this.marked) this.canvas.removeMarker(element, marker);
|
|
2172
|
+
this.marked = [];
|
|
2173
|
+
}
|
|
2174
|
+
mark(id, marker) {
|
|
2175
|
+
const element = this.elementRegistry.get(id);
|
|
2176
|
+
if (!element) return;
|
|
2177
|
+
for (const markedElement of [element, ...element.labels ?? []]) {
|
|
2178
|
+
this.canvas.addMarker(markedElement, marker);
|
|
2179
|
+
this.marked.push({ element: markedElement, marker });
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
class PathSimulation {
|
|
2185
|
+
constructor(config, elementRegistry, canvas) {
|
|
2186
|
+
this.pathResolver = new PathResolver();
|
|
2187
|
+
this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
|
|
2188
|
+
this.pathGraphReader = new PathGraphReader(elementRegistry, this.engine);
|
|
2189
|
+
this.pathMarkers = new PathMarkers(canvas, elementRegistry);
|
|
2190
|
+
}
|
|
2191
|
+
getEngine() {
|
|
2192
|
+
return this.engine;
|
|
2193
|
+
}
|
|
2194
|
+
simulate(variables, options = {}) {
|
|
2195
|
+
const graph = this.pathGraphReader.read(options.measures ?? []);
|
|
2196
|
+
const path = this.pathResolver.resolve(graph, (expression) => this.engine.evaluate(expression, variables));
|
|
2197
|
+
this.pathMarkers.show(path);
|
|
2198
|
+
return path;
|
|
2199
|
+
}
|
|
2200
|
+
clear() {
|
|
2201
|
+
this.pathMarkers.clear();
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
PathSimulation.$inject = ["config.dataSimulation", "elementRegistry", "canvas"];
|
|
2205
|
+
|
|
2206
|
+
const PathSimulationModule = {
|
|
2207
|
+
__init__: [],
|
|
2208
|
+
pathSimulation: ["type", PathSimulation]
|
|
2209
|
+
};
|
|
2063
2210
|
const DataSimulationModule = {
|
|
2211
|
+
__depends__: [PathSimulationModule],
|
|
2064
2212
|
__init__: [
|
|
2065
2213
|
"dataSimulation",
|
|
2066
2214
|
"dataSimulationOverlays",
|
|
@@ -2083,9 +2231,11 @@ const DataSimulationModule = {
|
|
|
2083
2231
|
};
|
|
2084
2232
|
|
|
2085
2233
|
exports.Camunda7Engine = Camunda7Engine;
|
|
2234
|
+
exports.DataSimulationModule = DataSimulationModule;
|
|
2086
2235
|
exports.DataSimulationStore = DataSimulationStore;
|
|
2087
2236
|
exports.EngineRegistry = EngineRegistry;
|
|
2088
2237
|
exports.GatewayRouter = GatewayRouter;
|
|
2238
|
+
exports.PathSimulationModule = PathSimulationModule;
|
|
2089
2239
|
exports.ScenarioError = ScenarioError;
|
|
2090
2240
|
exports.ScenarioParser = ScenarioParser;
|
|
2091
2241
|
exports.SimpleStartFormRenderer = SimpleStartFormRenderer;
|