@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.
Files changed (33) hide show
  1. package/README.md +59 -64
  2. package/dist/assets/bpmn-js-data-simulation.css +26 -1
  3. package/dist/domain/PathResolver.d.ts +9 -0
  4. package/dist/domain/PathResolver.d.ts.map +1 -0
  5. package/dist/domain/PathVariableDeriver.d.ts +9 -0
  6. package/dist/domain/PathVariableDeriver.d.ts.map +1 -0
  7. package/dist/domain/model.d.ts +43 -0
  8. package/dist/domain/model.d.ts.map +1 -1
  9. package/dist/index.cjs +236 -19
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +3 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +235 -20
  14. package/dist/index.js.map +1 -1
  15. package/dist/integration/DataGateways.d.ts +0 -1
  16. package/dist/integration/DataGateways.d.ts.map +1 -1
  17. package/dist/integration/DataSimulation.d.ts +2 -2
  18. package/dist/integration/DataSimulation.d.ts.map +1 -1
  19. package/dist/integration/PathGraphReader.d.ts +13 -0
  20. package/dist/integration/PathGraphReader.d.ts.map +1 -0
  21. package/dist/integration/PathMarkers.d.ts +12 -0
  22. package/dist/integration/PathMarkers.d.ts.map +1 -0
  23. package/dist/integration/PathSimulation.d.ts +25 -0
  24. package/dist/integration/PathSimulation.d.ts.map +1 -0
  25. package/dist/integration/ScenarioVariables.d.ts +11 -0
  26. package/dist/integration/ScenarioVariables.d.ts.map +1 -0
  27. package/dist/integration/index.d.ts +2 -2
  28. package/dist/integration/index.d.ts.map +1 -1
  29. package/dist/integration/tokenSimulation.d.ts +6 -0
  30. package/dist/integration/tokenSimulation.d.ts.map +1 -1
  31. package/dist/utils/diagramElements.d.ts +6 -1
  32. package/dist/utils/diagramElements.d.ts.map +1 -1
  33. package/package.json +9 -6
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, NumberRange, OutgoingFlow, PathVariable, 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
@@ -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,EAAE,OAAO,EAAE,KAAK,+BAA+B,EAAE,MAAM,wBAAwB,CAAA"}
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,WAAW,EACX,YAAY,EACZ,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
@@ -1037,6 +1037,9 @@ function is(element, type) {
1037
1037
  const businessObject = element.businessObject;
1038
1038
  return typeof businessObject?.$instanceOf === "function" && businessObject.$instanceOf(type);
1039
1039
  }
1040
+ function flowNodesOf(elementRegistry) {
1041
+ return elementRegistry.filter((element) => element.id === element.businessObject.id && is(element, "bpmn:FlowNode"));
1042
+ }
1040
1043
  function isGateway(element) {
1041
1044
  return element.type === "bpmn:ExclusiveGateway" || element.type === "bpmn:InclusiveGateway";
1042
1045
  }
@@ -1045,6 +1048,18 @@ function gatewayOf(element) {
1045
1048
  if (element.type === "bpmn:SequenceFlow" && element.source && isGateway(element.source)) return element.source.id;
1046
1049
  return void 0;
1047
1050
  }
1051
+ function outgoingSequenceFlows(element) {
1052
+ return (element.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
1053
+ }
1054
+ function readOutgoingFlow(sequenceFlow, engine) {
1055
+ const name = sequenceFlow.businessObject.name;
1056
+ return {
1057
+ id: sequenceFlow.id,
1058
+ ...typeof name === "string" && name ? { name } : {},
1059
+ expression: engine.readCondition(sequenceFlow.businessObject),
1060
+ isDefault: sequenceFlow.source?.businessObject.default === sequenceFlow.businessObject
1061
+ };
1062
+ }
1048
1063
 
1049
1064
  class DataGateways {
1050
1065
  constructor(dataSimulation, store, simulator) {
@@ -1066,7 +1081,7 @@ class DataGateways {
1066
1081
  return;
1067
1082
  }
1068
1083
  for (const flowId of decision.takenFlowIds) {
1069
- const flow = this.sequenceFlows(gateway).find((candidate) => candidate.id === flowId);
1084
+ const flow = outgoingSequenceFlows(gateway).find((candidate) => candidate.id === flowId);
1070
1085
  this.simulator.enter({ element: flow, scope: scope.parent });
1071
1086
  }
1072
1087
  }
@@ -1124,19 +1139,7 @@ class DataGateways {
1124
1139
  }
1125
1140
  outgoingFlows(gateway) {
1126
1141
  const engine = this.dataSimulation.getEngine();
1127
- const defaultFlow = gateway.businessObject.default;
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"));
1142
+ return outgoingSequenceFlows(gateway).map((flow) => readOutgoingFlow(flow, engine));
1140
1143
  }
1141
1144
  }
1142
1145
  DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
@@ -1192,10 +1195,15 @@ const TRACE_EVENT = "tokenSimulation.simulator.trace";
1192
1195
  const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
1193
1196
 
1194
1197
  class DataSimulation {
1195
- constructor(config, eventBus, store) {
1198
+ constructor(config, eventBus, store, injector) {
1196
1199
  this.eventBus = eventBus;
1197
1200
  this.store = store;
1198
1201
  this.scenarioParser = new ScenarioParser();
1202
+ if (!injector.get("simulator", false)) {
1203
+ throw new Error(
1204
+ "DataSimulationModule needs bpmn-js-token-simulation; for the path alone use PathSimulationModule"
1205
+ );
1206
+ }
1199
1207
  this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
1200
1208
  this.ioMappings = new IoMappings(this.engine, store);
1201
1209
  this.enabled = config?.enabled ?? true;
@@ -1258,7 +1266,7 @@ class DataSimulation {
1258
1266
  if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
1259
1267
  }
1260
1268
  }
1261
- DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore"];
1269
+ DataSimulation.$inject = ["config.dataSimulation", "eventBus", "dataSimulationStore", "injector"];
1262
1270
 
1263
1271
  class GatewayDecisionView {
1264
1272
  constructor(snapshot) {
@@ -1428,7 +1436,7 @@ function createSheet() {
1428
1436
 
1429
1437
  const OUTCOME_OVERLAY = "bds-flow-outcome";
1430
1438
  const DECIDED_MARKER = "bds-gateway--decided";
1431
- const STUCK_MARKER = "bds-gateway--stuck";
1439
+ const STUCK_MARKER$1 = "bds-gateway--stuck";
1432
1440
  const BADGE_DISTANCE = 38;
1433
1441
  const BADGE_MIN_SCALE = 1;
1434
1442
  class DataSimulationOverlays {
@@ -1483,13 +1491,13 @@ class DataSimulationOverlays {
1483
1491
  markGateway({ elementId, decision }) {
1484
1492
  const gateway = this.elementRegistry.get(elementId);
1485
1493
  if (!gateway) return;
1486
- this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER : DECIDED_MARKER);
1494
+ this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
1487
1495
  this.markedGateways.push(gateway);
1488
1496
  }
1489
1497
  unmarkGateways() {
1490
1498
  for (const gateway of this.markedGateways) {
1491
1499
  this.canvas.removeMarker(gateway, DECIDED_MARKER);
1492
- this.canvas.removeMarker(gateway, STUCK_MARKER);
1500
+ this.canvas.removeMarker(gateway, STUCK_MARKER$1);
1493
1501
  }
1494
1502
  this.markedGateways = [];
1495
1503
  }
@@ -2056,7 +2064,214 @@ class DataStartForm {
2056
2064
  }
2057
2065
  DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
2058
2066
 
2067
+ class PathResolver {
2068
+ constructor() {
2069
+ this.router = new GatewayRouter();
2070
+ }
2071
+ resolve(graph, evaluateCondition) {
2072
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node]));
2073
+ const takenIds = /* @__PURE__ */ new Set();
2074
+ const decisions = {};
2075
+ const pendingIds = [...graph.startIds];
2076
+ while (pendingIds.length) {
2077
+ const node = nodes.get(pendingIds.shift());
2078
+ if (!node || takenIds.has(node.id)) continue;
2079
+ takenIds.add(node.id);
2080
+ pendingIds.push(...node.nestedStartIds);
2081
+ for (const flow of this.leave(node, evaluateCondition, decisions)) {
2082
+ takenIds.add(flow.id);
2083
+ pendingIds.push(flow.targetId);
2084
+ }
2085
+ }
2086
+ const elementIds = graph.nodes.flatMap((node) => [node.id, ...node.outgoing.map((flow) => flow.id)]);
2087
+ return {
2088
+ taken: elementIds.filter((id) => takenIds.has(id)),
2089
+ skipped: elementIds.filter((id) => !takenIds.has(id)),
2090
+ decisions,
2091
+ measures: this.sumMeasures(graph.nodes.filter((node) => takenIds.has(node.id)))
2092
+ };
2093
+ }
2094
+ leave(node, evaluateCondition, decisions) {
2095
+ if (!node.gatewayKind || node.outgoing.length < 2) return node.outgoing;
2096
+ const decision = this.router.route(node.gatewayKind, node.outgoing, evaluateCondition);
2097
+ decisions[node.id] = decision;
2098
+ return node.outgoing.filter((flow) => decision.takenFlowIds.includes(flow.id));
2099
+ }
2100
+ sumMeasures(nodes) {
2101
+ const totals = {};
2102
+ for (const node of nodes) {
2103
+ for (const [name, value] of Object.entries(node.measures)) totals[name] = (totals[name] ?? 0) + value;
2104
+ }
2105
+ return totals;
2106
+ }
2107
+ }
2108
+
2109
+ const NICE_STEPS = [1, 2, 5, 10];
2110
+ const RANGE_STEPS = 100;
2111
+ const NUMBER_LITERAL = /(?<![\w.])\d+(?:\.\d+)?/g;
2112
+ class PathVariableDeriver {
2113
+ derive(conditions, values) {
2114
+ const names = [...new Set(conditions.flatMap((condition) => condition.variableNames))];
2115
+ return names.map((name) => {
2116
+ const conditionsReadingName = conditions.filter((condition) => condition.variableNames.includes(name));
2117
+ return this.variableFor(name, values[name], conditionsReadingName);
2118
+ });
2119
+ }
2120
+ variableFor(name, value, conditionsReadingName) {
2121
+ if (typeof value === "boolean") return { name, type: "boolean" };
2122
+ if (typeof value === "number") {
2123
+ const comparedNumbers = conditionsReadingName.flatMap((condition) => this.numberLiterals(condition.expression));
2124
+ return { name, type: "number", range: this.rangeAround(value, comparedNumbers) };
2125
+ }
2126
+ if (value === void 0 || typeof value === "string") return { name, type: "text" };
2127
+ return { name, type: "json" };
2128
+ }
2129
+ rangeAround(value, comparedNumbers) {
2130
+ const max = this.niceCeiling(2 * Math.max(Math.abs(value), ...comparedNumbers));
2131
+ return { min: 0, max, step: max / RANGE_STEPS };
2132
+ }
2133
+ niceCeiling(value) {
2134
+ if (value <= 0) return 1;
2135
+ const magnitude = 10 ** Math.floor(Math.log10(value));
2136
+ return NICE_STEPS.find((step) => step * magnitude >= value) * magnitude;
2137
+ }
2138
+ numberLiterals(expression) {
2139
+ return (expression.match(NUMBER_LITERAL) ?? []).map(Number);
2140
+ }
2141
+ }
2142
+
2143
+ const GATEWAY_KINDS = {
2144
+ "bpmn:ExclusiveGateway": "exclusive",
2145
+ "bpmn:InclusiveGateway": "inclusive"
2146
+ };
2147
+ class PathGraphReader {
2148
+ constructor(elementRegistry, engine) {
2149
+ this.elementRegistry = elementRegistry;
2150
+ this.engine = engine;
2151
+ }
2152
+ read(measureNames) {
2153
+ const flowNodes = flowNodesOf(this.elementRegistry);
2154
+ const startEventsIn = (container) => flowNodes.filter((node) => is(node, "bpmn:StartEvent") && node.businessObject.$parent === container);
2155
+ const processStartIds = flowNodes.filter((node) => is(node, "bpmn:StartEvent") && this.isProcess(node.businessObject.$parent)).map((node) => node.id);
2156
+ return {
2157
+ startIds: processStartIds,
2158
+ nodes: flowNodes.map((node) => this.toPathNode(node, startEventsIn, measureNames))
2159
+ };
2160
+ }
2161
+ toPathNode(node, startEventsIn, measureNames) {
2162
+ const entersSubProcess = is(node, "bpmn:SubProcess") && !node.businessObject.triggeredByEvent;
2163
+ return {
2164
+ id: node.id,
2165
+ ...GATEWAY_KINDS[node.type] ? { gatewayKind: GATEWAY_KINDS[node.type] } : {},
2166
+ outgoing: outgoingSequenceFlows(node).map((flow) => ({
2167
+ ...readOutgoingFlow(flow, this.engine),
2168
+ targetId: flow.target.id
2169
+ })),
2170
+ nestedStartIds: entersSubProcess ? startEventsIn(node.businessObject).map((start) => start.id) : [],
2171
+ measures: Object.fromEntries(measureNames.map((name) => [name, this.readMeasure(node.businessObject, name)]))
2172
+ };
2173
+ }
2174
+ isProcess(element) {
2175
+ return element?.$type === "bpmn:Process";
2176
+ }
2177
+ readMeasure(businessObject, name) {
2178
+ const attribute = businessObject.$attrs?.[name];
2179
+ const value = typeof attribute === "string" && attribute.trim() ? Number(attribute) : Number.NaN;
2180
+ return Number.isFinite(value) ? value : 0;
2181
+ }
2182
+ }
2183
+
2184
+ const TAKEN_MARKER = "bds-path--taken";
2185
+ const SKIPPED_MARKER = "bds-path--skipped";
2186
+ const STUCK_MARKER = "bds-path--stuck";
2187
+ class PathMarkers {
2188
+ constructor(canvas, elementRegistry) {
2189
+ this.canvas = canvas;
2190
+ this.elementRegistry = elementRegistry;
2191
+ this.marked = [];
2192
+ }
2193
+ show(path) {
2194
+ this.clear();
2195
+ for (const id of path.taken) this.mark(id, TAKEN_MARKER);
2196
+ for (const id of path.skipped) this.mark(id, SKIPPED_MARKER);
2197
+ for (const [gatewayId, decision] of Object.entries(path.decisions)) {
2198
+ if (decision.stuckReason) this.mark(gatewayId, STUCK_MARKER);
2199
+ }
2200
+ }
2201
+ clear() {
2202
+ for (const { element, marker } of this.marked) this.canvas.removeMarker(element, marker);
2203
+ this.marked = [];
2204
+ }
2205
+ mark(id, marker) {
2206
+ const element = this.elementRegistry.get(id);
2207
+ if (!element) return;
2208
+ for (const markedElement of [element, ...element.labels ?? []]) {
2209
+ this.canvas.addMarker(markedElement, marker);
2210
+ this.marked.push({ element: markedElement, marker });
2211
+ }
2212
+ }
2213
+ }
2214
+
2215
+ class ScenarioVariables {
2216
+ constructor(elementRegistry, engine) {
2217
+ this.elementRegistry = elementRegistry;
2218
+ this.engine = engine;
2219
+ }
2220
+ of(scenario, fallbacks) {
2221
+ const fallbackVariables = fallbacks.map((fallback) => this.afterOutputMappings(fallback));
2222
+ return Object.assign({}, ...fallbackVariables, this.afterOutputMappings(scenario));
2223
+ }
2224
+ afterOutputMappings(scenario) {
2225
+ let variables = Object.assign({}, scenario?.variables, ...Object.values(scenario?.taskResults ?? {}));
2226
+ for (const flowNode of flowNodesOf(this.elementRegistry)) {
2227
+ for (const { source, target } of this.engine.readIoMappings(flowNode.businessObject).outputs) {
2228
+ const evaluation = this.engine.evaluate(source, variables);
2229
+ if (evaluation.ok) variables = this.engine.writeVariable(variables, target, evaluation.value);
2230
+ }
2231
+ }
2232
+ return variables;
2233
+ }
2234
+ }
2235
+
2236
+ class PathSimulation {
2237
+ constructor(config, elementRegistry, canvas) {
2238
+ this.pathResolver = new PathResolver();
2239
+ this.pathVariableDeriver = new PathVariableDeriver();
2240
+ this.engine = new EngineRegistry().resolve(config?.engine ?? "zeebe");
2241
+ this.pathGraphReader = new PathGraphReader(elementRegistry, this.engine);
2242
+ this.pathMarkers = new PathMarkers(canvas, elementRegistry);
2243
+ this.scenarioVariables = new ScenarioVariables(elementRegistry, this.engine);
2244
+ }
2245
+ getEngine() {
2246
+ return this.engine;
2247
+ }
2248
+ simulate(variables, options = {}) {
2249
+ const graph = this.pathGraphReader.read(options.measures ?? []);
2250
+ const path = this.pathResolver.resolve(graph, (expression) => this.engine.evaluate(expression, variables));
2251
+ this.pathMarkers.show(path);
2252
+ return path;
2253
+ }
2254
+ deriveVariables(values) {
2255
+ return this.pathVariableDeriver.derive(this.evaluableConditions(), values);
2256
+ }
2257
+ variablesOf(scenario, fallbacks = []) {
2258
+ return this.scenarioVariables.of(scenario, fallbacks);
2259
+ }
2260
+ clear() {
2261
+ this.pathMarkers.clear();
2262
+ }
2263
+ evaluableConditions() {
2264
+ 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) }));
2265
+ }
2266
+ }
2267
+ PathSimulation.$inject = ["config.dataSimulation", "elementRegistry", "canvas"];
2268
+
2269
+ const PathSimulationModule = {
2270
+ __init__: [],
2271
+ pathSimulation: ["type", PathSimulation]
2272
+ };
2059
2273
  const DataSimulationModule = {
2274
+ __depends__: [PathSimulationModule],
2060
2275
  __init__: [
2061
2276
  "dataSimulation",
2062
2277
  "dataSimulationOverlays",
@@ -2078,5 +2293,5 @@ const DataSimulationModule = {
2078
2293
  dataContextPads: ["type", DataContextPads]
2079
2294
  };
2080
2295
 
2081
- export { Camunda7Engine, DataSimulationStore, EngineRegistry, GatewayRouter, ScenarioError, ScenarioParser, SimpleStartFormRenderer, StartFieldCodec, ZeebeEngine, camunda7Engine, DataSimulationModule as default, zeebeEngine };
2296
+ export { Camunda7Engine, DataSimulationModule, DataSimulationStore, EngineRegistry, GatewayRouter, PathSimulationModule, ScenarioError, ScenarioParser, SimpleStartFormRenderer, StartFieldCodec, ZeebeEngine, camunda7Engine, DataSimulationModule as default, zeebeEngine };
2082
2297
  //# sourceMappingURL=index.js.map