@emaarco/bpmn-js-data-simulation 0.2.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/engines/camunda7/Camunda7Engine.d.ts +4 -2
- package/dist/engines/camunda7/Camunda7Engine.d.ts.map +1 -1
- package/dist/engines/types.d.ts +4 -2
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/engines/zeebe/ZeebeEngine.d.ts +4 -2
- package/dist/engines/zeebe/ZeebeEngine.d.ts.map +1 -1
- package/dist/index.cjs +181 -33
- 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 +180 -34
- 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/IoMappings.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/VariableUsageCollector.d.ts.map +1 -1
- 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 +13 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Evaluation, FlowEvaluation, FlowOutcome, GatewayKind, Mapping, OutgoingFlow, RoutingDecision, Scenario, StartField, StartFieldType, Variables, } from './domain/model.js';
|
|
1
|
+
export type { Evaluation, FlowEvaluation, FlowOutcome, GatewayKind, Mapping, OutgoingFlow, RoutingDecision, Scenario, SimulatedPath, StartField, StartFieldType, Variables, } from './domain/model.js';
|
|
2
2
|
export { GatewayRouter } from './domain/GatewayRouter.js';
|
|
3
3
|
export { ScenarioError } from './domain/ScenarioError.js';
|
|
4
4
|
export { ScenarioParser } from './domain/ScenarioParser.js';
|
|
@@ -13,5 +13,6 @@ export type { ConditionInput, DecisionLogEntry, InstanceState, InstanceStatus, L
|
|
|
13
13
|
export type { FormValues, RenderedStartForm, StartFormRenderer } from './ui/startForm.js';
|
|
14
14
|
export { SimpleStartFormRenderer } from './ui/SimpleStartFormRenderer.js';
|
|
15
15
|
export type { DataSimulation, DataSimulationConfig } from './integration/DataSimulation.js';
|
|
16
|
-
export { default, type DataSimulationModuleDeclaration } from './integration/index.js';
|
|
16
|
+
export { DataSimulationModule, DataSimulationModule as default, type DataSimulationModuleDeclaration, PathSimulationModule, } from './integration/index.js';
|
|
17
|
+
export type { PathSimulation, PathSimulationConfig, PathSimulationOptions } from './integration/PathSimulation.js';
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,qCAAqC,CAAA;AAE5C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AAEzE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAC3F,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,aAAa,EACb,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,qCAAqC,CAAA;AAE5C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AAEzE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAC3F,OAAO,EACL,oBAAoB,EACpB,oBAAoB,IAAI,OAAO,EAC/B,KAAK,+BAA+B,EACpC,oBAAoB,GACrB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -601,11 +601,11 @@ class Camunda7Engine {
|
|
|
601
601
|
writeVariable(variables, target, value) {
|
|
602
602
|
return { ...variables, [target]: value };
|
|
603
603
|
}
|
|
604
|
-
|
|
605
|
-
return
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
604
|
+
readIoMappings(element) {
|
|
605
|
+
return {
|
|
606
|
+
inputs: this.readMappings(element, "inputParameters"),
|
|
607
|
+
outputs: this.readMappings(element, "outputParameters")
|
|
608
|
+
};
|
|
609
609
|
}
|
|
610
610
|
readCondition(sequenceFlow) {
|
|
611
611
|
const condition = readConditionExpression(sequenceFlow);
|
|
@@ -657,11 +657,11 @@ class ZeebeEngine {
|
|
|
657
657
|
writeVariable(variables, target, value) {
|
|
658
658
|
return setVariable(variables, target, value);
|
|
659
659
|
}
|
|
660
|
-
|
|
661
|
-
return
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
660
|
+
readIoMappings(element) {
|
|
661
|
+
return {
|
|
662
|
+
inputs: this.readMappings(element, "inputParameters"),
|
|
663
|
+
outputs: this.readMappings(element, "outputParameters")
|
|
664
|
+
};
|
|
665
665
|
}
|
|
666
666
|
readCondition(sequenceFlow) {
|
|
667
667
|
return readConditionExpression(sequenceFlow)?.body?.trim() || void 0;
|
|
@@ -1045,6 +1045,18 @@ function gatewayOf(element) {
|
|
|
1045
1045
|
if (element.type === "bpmn:SequenceFlow" && element.source && isGateway(element.source)) return element.source.id;
|
|
1046
1046
|
return void 0;
|
|
1047
1047
|
}
|
|
1048
|
+
function outgoingSequenceFlows(element) {
|
|
1049
|
+
return (element.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
1050
|
+
}
|
|
1051
|
+
function readOutgoingFlow(sequenceFlow, engine) {
|
|
1052
|
+
const name = sequenceFlow.businessObject.name;
|
|
1053
|
+
return {
|
|
1054
|
+
id: sequenceFlow.id,
|
|
1055
|
+
...typeof name === "string" && name ? { name } : {},
|
|
1056
|
+
expression: engine.readCondition(sequenceFlow.businessObject),
|
|
1057
|
+
isDefault: sequenceFlow.source?.businessObject.default === sequenceFlow.businessObject
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1048
1060
|
|
|
1049
1061
|
class DataGateways {
|
|
1050
1062
|
constructor(dataSimulation, store, simulator) {
|
|
@@ -1066,7 +1078,7 @@ class DataGateways {
|
|
|
1066
1078
|
return;
|
|
1067
1079
|
}
|
|
1068
1080
|
for (const flowId of decision.takenFlowIds) {
|
|
1069
|
-
const flow =
|
|
1081
|
+
const flow = outgoingSequenceFlows(gateway).find((candidate) => candidate.id === flowId);
|
|
1070
1082
|
this.simulator.enter({ element: flow, scope: scope.parent });
|
|
1071
1083
|
}
|
|
1072
1084
|
}
|
|
@@ -1124,19 +1136,7 @@ class DataGateways {
|
|
|
1124
1136
|
}
|
|
1125
1137
|
outgoingFlows(gateway) {
|
|
1126
1138
|
const engine = this.dataSimulation.getEngine();
|
|
1127
|
-
|
|
1128
|
-
return this.sequenceFlows(gateway).map((flow) => {
|
|
1129
|
-
const name = flow.businessObject.name;
|
|
1130
|
-
return {
|
|
1131
|
-
id: flow.id,
|
|
1132
|
-
...typeof name === "string" && name ? { name } : {},
|
|
1133
|
-
expression: engine.readCondition(flow.businessObject),
|
|
1134
|
-
isDefault: flow.businessObject === defaultFlow
|
|
1135
|
-
};
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
sequenceFlows(gateway) {
|
|
1139
|
-
return (gateway.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
1139
|
+
return outgoingSequenceFlows(gateway).map((flow) => readOutgoingFlow(flow, engine));
|
|
1140
1140
|
}
|
|
1141
1141
|
}
|
|
1142
1142
|
DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
|
|
@@ -1147,8 +1147,7 @@ class IoMappings {
|
|
|
1147
1147
|
this.store = store;
|
|
1148
1148
|
}
|
|
1149
1149
|
apply(element, instanceId) {
|
|
1150
|
-
const inputs = this.engine.
|
|
1151
|
-
const outputs = this.engine.readOutputMappings(element.businessObject);
|
|
1150
|
+
const { inputs, outputs } = this.engine.readIoMappings(element.businessObject);
|
|
1152
1151
|
const taskResult = this.store.getTaskResult(instanceId, element.id);
|
|
1153
1152
|
if (!inputs.length && !outputs.length && !taskResult) return;
|
|
1154
1153
|
const processVariables = this.store.getVariables(instanceId);
|
|
@@ -1193,10 +1192,15 @@ const TRACE_EVENT = "tokenSimulation.simulator.trace";
|
|
|
1193
1192
|
const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
|
|
1194
1193
|
|
|
1195
1194
|
class DataSimulation {
|
|
1196
|
-
constructor(config, eventBus, store) {
|
|
1195
|
+
constructor(config, eventBus, store, injector) {
|
|
1197
1196
|
this.eventBus = eventBus;
|
|
1198
1197
|
this.store = store;
|
|
1199
1198
|
this.scenarioParser = new ScenarioParser();
|
|
1199
|
+
if (!injector.get("simulator", false)) {
|
|
1200
|
+
throw new Error(
|
|
1201
|
+
"DataSimulationModule needs bpmn-js-token-simulation; for the path alone use PathSimulationModule"
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
1200
1204
|
this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
|
|
1201
1205
|
this.ioMappings = new IoMappings(this.engine, store);
|
|
1202
1206
|
this.enabled = config?.enabled ?? true;
|
|
@@ -1259,7 +1263,7 @@ class DataSimulation {
|
|
|
1259
1263
|
if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
|
|
1260
1264
|
}
|
|
1261
1265
|
}
|
|
1262
|
-
DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore"];
|
|
1266
|
+
DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore", "injector"];
|
|
1263
1267
|
|
|
1264
1268
|
class GatewayDecisionView {
|
|
1265
1269
|
constructor(snapshot) {
|
|
@@ -1429,7 +1433,7 @@ function createSheet() {
|
|
|
1429
1433
|
|
|
1430
1434
|
const OUTCOME_OVERLAY = "bds-flow-outcome";
|
|
1431
1435
|
const DECIDED_MARKER = "bds-gateway--decided";
|
|
1432
|
-
const STUCK_MARKER = "bds-gateway--stuck";
|
|
1436
|
+
const STUCK_MARKER$1 = "bds-gateway--stuck";
|
|
1433
1437
|
const BADGE_DISTANCE = 38;
|
|
1434
1438
|
const BADGE_MIN_SCALE = 1;
|
|
1435
1439
|
class DataSimulationOverlays {
|
|
@@ -1484,13 +1488,13 @@ class DataSimulationOverlays {
|
|
|
1484
1488
|
markGateway({ elementId, decision }) {
|
|
1485
1489
|
const gateway = this.elementRegistry.get(elementId);
|
|
1486
1490
|
if (!gateway) return;
|
|
1487
|
-
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
|
|
1491
|
+
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1488
1492
|
this.markedGateways.push(gateway);
|
|
1489
1493
|
}
|
|
1490
1494
|
unmarkGateways() {
|
|
1491
1495
|
for (const gateway of this.markedGateways) {
|
|
1492
1496
|
this.canvas.removeMarker(gateway, DECIDED_MARKER);
|
|
1493
|
-
this.canvas.removeMarker(gateway, STUCK_MARKER);
|
|
1497
|
+
this.canvas.removeMarker(gateway, STUCK_MARKER$1);
|
|
1494
1498
|
}
|
|
1495
1499
|
this.markedGateways = [];
|
|
1496
1500
|
}
|
|
@@ -1986,8 +1990,7 @@ class VariableUsageCollector {
|
|
|
1986
1990
|
return this.usage(element.source ?? element, { conditionReads: this.engine.readVariableNames(condition) });
|
|
1987
1991
|
}
|
|
1988
1992
|
if (!is(element, "bpmn:FlowNode")) return void 0;
|
|
1989
|
-
const inputs = this.engine.
|
|
1990
|
-
const outputs = this.engine.readOutputMappings(businessObject);
|
|
1993
|
+
const { inputs, outputs } = this.engine.readIoMappings(businessObject);
|
|
1991
1994
|
return this.usage(element, {
|
|
1992
1995
|
inputReads: inputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
|
|
1993
1996
|
inputTargets: inputs.map((mapping) => mapping.target),
|
|
@@ -2058,7 +2061,150 @@ class DataStartForm {
|
|
|
2058
2061
|
}
|
|
2059
2062
|
DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
|
|
2060
2063
|
|
|
2064
|
+
class PathResolver {
|
|
2065
|
+
constructor() {
|
|
2066
|
+
this.router = new GatewayRouter();
|
|
2067
|
+
}
|
|
2068
|
+
resolve(graph, evaluateCondition) {
|
|
2069
|
+
const nodes = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
2070
|
+
const takenIds = /* @__PURE__ */ new Set();
|
|
2071
|
+
const decisions = {};
|
|
2072
|
+
const pendingIds = [...graph.startIds];
|
|
2073
|
+
while (pendingIds.length) {
|
|
2074
|
+
const node = nodes.get(pendingIds.shift());
|
|
2075
|
+
if (!node || takenIds.has(node.id)) continue;
|
|
2076
|
+
takenIds.add(node.id);
|
|
2077
|
+
pendingIds.push(...node.nestedStartIds);
|
|
2078
|
+
for (const flow of this.leave(node, evaluateCondition, decisions)) {
|
|
2079
|
+
takenIds.add(flow.id);
|
|
2080
|
+
pendingIds.push(flow.targetId);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
const elementIds = graph.nodes.flatMap((node) => [node.id, ...node.outgoing.map((flow) => flow.id)]);
|
|
2084
|
+
return {
|
|
2085
|
+
taken: elementIds.filter((id) => takenIds.has(id)),
|
|
2086
|
+
skipped: elementIds.filter((id) => !takenIds.has(id)),
|
|
2087
|
+
decisions,
|
|
2088
|
+
measures: this.sumMeasures(graph.nodes.filter((node) => takenIds.has(node.id)))
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
leave(node, evaluateCondition, decisions) {
|
|
2092
|
+
if (!node.gatewayKind || node.outgoing.length < 2) return node.outgoing;
|
|
2093
|
+
const decision = this.router.route(node.gatewayKind, node.outgoing, evaluateCondition);
|
|
2094
|
+
decisions[node.id] = decision;
|
|
2095
|
+
return node.outgoing.filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
2096
|
+
}
|
|
2097
|
+
sumMeasures(nodes) {
|
|
2098
|
+
const totals = {};
|
|
2099
|
+
for (const node of nodes) {
|
|
2100
|
+
for (const [name, value] of Object.entries(node.measures)) totals[name] = (totals[name] ?? 0) + value;
|
|
2101
|
+
}
|
|
2102
|
+
return totals;
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
const GATEWAY_KINDS = {
|
|
2107
|
+
"bpmn:ExclusiveGateway": "exclusive",
|
|
2108
|
+
"bpmn:InclusiveGateway": "inclusive"
|
|
2109
|
+
};
|
|
2110
|
+
class PathGraphReader {
|
|
2111
|
+
constructor(elementRegistry, engine) {
|
|
2112
|
+
this.elementRegistry = elementRegistry;
|
|
2113
|
+
this.engine = engine;
|
|
2114
|
+
}
|
|
2115
|
+
read(measureNames) {
|
|
2116
|
+
const flowNodes = this.elementRegistry.filter(
|
|
2117
|
+
(element) => element.id === element.businessObject.id && is(element, "bpmn:FlowNode")
|
|
2118
|
+
);
|
|
2119
|
+
const startEventsIn = (container) => flowNodes.filter((node) => is(node, "bpmn:StartEvent") && node.businessObject.$parent === container);
|
|
2120
|
+
const processStartIds = flowNodes.filter((node) => is(node, "bpmn:StartEvent") && this.isProcess(node.businessObject.$parent)).map((node) => node.id);
|
|
2121
|
+
return {
|
|
2122
|
+
startIds: processStartIds,
|
|
2123
|
+
nodes: flowNodes.map((node) => this.toPathNode(node, startEventsIn, measureNames))
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
toPathNode(node, startEventsIn, measureNames) {
|
|
2127
|
+
const entersSubProcess = is(node, "bpmn:SubProcess") && !node.businessObject.triggeredByEvent;
|
|
2128
|
+
return {
|
|
2129
|
+
id: node.id,
|
|
2130
|
+
...GATEWAY_KINDS[node.type] ? { gatewayKind: GATEWAY_KINDS[node.type] } : {},
|
|
2131
|
+
outgoing: outgoingSequenceFlows(node).map((flow) => ({
|
|
2132
|
+
...readOutgoingFlow(flow, this.engine),
|
|
2133
|
+
targetId: flow.target.id
|
|
2134
|
+
})),
|
|
2135
|
+
nestedStartIds: entersSubProcess ? startEventsIn(node.businessObject).map((start) => start.id) : [],
|
|
2136
|
+
measures: Object.fromEntries(measureNames.map((name) => [name, this.readMeasure(node.businessObject, name)]))
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
isProcess(element) {
|
|
2140
|
+
return element?.$type === "bpmn:Process";
|
|
2141
|
+
}
|
|
2142
|
+
readMeasure(businessObject, name) {
|
|
2143
|
+
const attribute = businessObject.$attrs?.[name];
|
|
2144
|
+
const value = typeof attribute === "string" && attribute.trim() ? Number(attribute) : Number.NaN;
|
|
2145
|
+
return Number.isFinite(value) ? value : 0;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
const TAKEN_MARKER = "bds-path--taken";
|
|
2150
|
+
const SKIPPED_MARKER = "bds-path--skipped";
|
|
2151
|
+
const STUCK_MARKER = "bds-path--stuck";
|
|
2152
|
+
class PathMarkers {
|
|
2153
|
+
constructor(canvas, elementRegistry) {
|
|
2154
|
+
this.canvas = canvas;
|
|
2155
|
+
this.elementRegistry = elementRegistry;
|
|
2156
|
+
this.marked = [];
|
|
2157
|
+
}
|
|
2158
|
+
show(path) {
|
|
2159
|
+
this.clear();
|
|
2160
|
+
for (const id of path.taken) this.mark(id, TAKEN_MARKER);
|
|
2161
|
+
for (const id of path.skipped) this.mark(id, SKIPPED_MARKER);
|
|
2162
|
+
for (const [gatewayId, decision] of Object.entries(path.decisions)) {
|
|
2163
|
+
if (decision.stuckReason) this.mark(gatewayId, STUCK_MARKER);
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
clear() {
|
|
2167
|
+
for (const { element, marker } of this.marked) this.canvas.removeMarker(element, marker);
|
|
2168
|
+
this.marked = [];
|
|
2169
|
+
}
|
|
2170
|
+
mark(id, marker) {
|
|
2171
|
+
const element = this.elementRegistry.get(id);
|
|
2172
|
+
if (!element) return;
|
|
2173
|
+
for (const markedElement of [element, ...element.labels ?? []]) {
|
|
2174
|
+
this.canvas.addMarker(markedElement, marker);
|
|
2175
|
+
this.marked.push({ element: markedElement, marker });
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
class PathSimulation {
|
|
2181
|
+
constructor(config, elementRegistry, canvas) {
|
|
2182
|
+
this.pathResolver = new PathResolver();
|
|
2183
|
+
this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
|
|
2184
|
+
this.pathGraphReader = new PathGraphReader(elementRegistry, this.engine);
|
|
2185
|
+
this.pathMarkers = new PathMarkers(canvas, elementRegistry);
|
|
2186
|
+
}
|
|
2187
|
+
getEngine() {
|
|
2188
|
+
return this.engine;
|
|
2189
|
+
}
|
|
2190
|
+
simulate(variables, options = {}) {
|
|
2191
|
+
const graph = this.pathGraphReader.read(options.measures ?? []);
|
|
2192
|
+
const path = this.pathResolver.resolve(graph, (expression) => this.engine.evaluate(expression, variables));
|
|
2193
|
+
this.pathMarkers.show(path);
|
|
2194
|
+
return path;
|
|
2195
|
+
}
|
|
2196
|
+
clear() {
|
|
2197
|
+
this.pathMarkers.clear();
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
PathSimulation.$inject = ["config.dataSimulation", "elementRegistry", "canvas"];
|
|
2201
|
+
|
|
2202
|
+
const PathSimulationModule = {
|
|
2203
|
+
__init__: [],
|
|
2204
|
+
pathSimulation: ["type", PathSimulation]
|
|
2205
|
+
};
|
|
2061
2206
|
const DataSimulationModule = {
|
|
2207
|
+
__depends__: [PathSimulationModule],
|
|
2062
2208
|
__init__: [
|
|
2063
2209
|
"dataSimulation",
|
|
2064
2210
|
"dataSimulationOverlays",
|
|
@@ -2080,5 +2226,5 @@ const DataSimulationModule = {
|
|
|
2080
2226
|
dataContextPads: ["type", DataContextPads]
|
|
2081
2227
|
};
|
|
2082
2228
|
|
|
2083
|
-
export { Camunda7Engine, DataSimulationStore, EngineRegistry, GatewayRouter, ScenarioError, ScenarioParser, SimpleStartFormRenderer, StartFieldCodec, ZeebeEngine, camunda7Engine, DataSimulationModule as default, zeebeEngine };
|
|
2229
|
+
export { Camunda7Engine, DataSimulationModule, DataSimulationStore, EngineRegistry, GatewayRouter, PathSimulationModule, ScenarioError, ScenarioParser, SimpleStartFormRenderer, StartFieldCodec, ZeebeEngine, camunda7Engine, DataSimulationModule as default, zeebeEngine };
|
|
2084
2230
|
//# sourceMappingURL=index.js.map
|