@emaarco/bpmn-js-data-simulation 0.5.0 → 0.7.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 +2 -1
- package/dist/assets/bpmn-js-data-simulation.css +9 -4
- package/dist/domain/GatewayRouter.d.ts +3 -2
- package/dist/domain/GatewayRouter.d.ts.map +1 -1
- package/dist/domain/InstanceCounter.d.ts +9 -0
- package/dist/domain/InstanceCounter.d.ts.map +1 -0
- package/dist/domain/InstanceLoop.d.ts +12 -0
- package/dist/domain/InstanceLoop.d.ts.map +1 -0
- package/dist/domain/PathResolver.d.ts +1 -0
- package/dist/domain/PathResolver.d.ts.map +1 -1
- package/dist/domain/PathVariableDeriver.d.ts +4 -2
- package/dist/domain/PathVariableDeriver.d.ts.map +1 -1
- package/dist/domain/model.d.ts +20 -1
- package/dist/domain/model.d.ts.map +1 -1
- package/dist/engines/camunda7/Camunda7Engine.d.ts +3 -1
- package/dist/engines/camunda7/Camunda7Engine.d.ts.map +1 -1
- package/dist/engines/types.d.ts +4 -1
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/engines/zeebe/ZeebeEngine.d.ts +3 -1
- package/dist/engines/zeebe/ZeebeEngine.d.ts.map +1 -1
- package/dist/index.cjs +492 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +492 -81
- package/dist/index.js.map +1 -1
- package/dist/integration/DataGateways.d.ts +3 -0
- package/dist/integration/DataGateways.d.ts.map +1 -1
- package/dist/integration/DataSimulation.d.ts.map +1 -1
- package/dist/integration/DataSimulationOverlays.d.ts +6 -5
- package/dist/integration/DataSimulationOverlays.d.ts.map +1 -1
- package/dist/integration/MultiInstanceActivities.d.ts +32 -0
- package/dist/integration/MultiInstanceActivities.d.ts.map +1 -0
- package/dist/integration/PathGraphReader.d.ts +1 -0
- package/dist/integration/PathGraphReader.d.ts.map +1 -1
- package/dist/integration/PathSimulation.d.ts +6 -2
- package/dist/integration/PathSimulation.d.ts.map +1 -1
- package/dist/integration/VariableUsageCollector.d.ts.map +1 -1
- package/dist/integration/behaviors/DataActivityBehavior.d.ts +12 -0
- package/dist/integration/behaviors/DataActivityBehavior.d.ts.map +1 -0
- package/dist/integration/behaviors/MultiInstanceBehaviors.d.ts +9 -0
- package/dist/integration/behaviors/MultiInstanceBehaviors.d.ts.map +1 -0
- package/dist/integration/index.d.ts.map +1 -1
- package/dist/integration/tokenSimulation.d.ts +26 -0
- package/dist/integration/tokenSimulation.d.ts.map +1 -1
- package/dist/simulation/DataSimulationStore.d.ts +10 -4
- package/dist/simulation/DataSimulationStore.d.ts.map +1 -1
- package/dist/ui/DecisionCard.d.ts +1 -0
- package/dist/ui/DecisionCard.d.ts.map +1 -1
- package/dist/ui/InstanceProgress.d.ts +9 -0
- package/dist/ui/InstanceProgress.d.ts.map +1 -0
- package/dist/ui/VariablesPanel.d.ts +2 -0
- package/dist/ui/VariablesPanel.d.ts.map +1 -1
- package/dist/utils/diagramElements.d.ts +4 -1
- package/dist/utils/diagramElements.d.ts.map +1 -1
- package/dist/utils/moddle.d.ts +6 -0
- package/dist/utils/moddle.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -7,15 +7,17 @@ class GatewayRouter {
|
|
|
7
7
|
const evaluations = [];
|
|
8
8
|
for (const flow of conditional) {
|
|
9
9
|
const alreadyDecided = kind === "exclusive" && evaluations.some((evaluation) => this.isDecisive(evaluation));
|
|
10
|
-
evaluations.push(alreadyDecided ? { flow, outcome: "skipped" } : this.evaluateFlow(flow, evaluateCondition));
|
|
10
|
+
evaluations.push(alreadyDecided ? { flow, outcome: "skipped" } : this.evaluateFlow(kind, flow, evaluateCondition));
|
|
11
11
|
}
|
|
12
12
|
const failed = evaluations.find((evaluation) => evaluation.outcome === "error");
|
|
13
13
|
if (failed) {
|
|
14
|
-
|
|
14
|
+
const decision = this.stuck(
|
|
15
15
|
evaluations,
|
|
16
16
|
defaultFlow,
|
|
17
17
|
`Condition of "${failed.flow.name ?? failed.flow.id}" failed: ${failed.reason}`
|
|
18
18
|
);
|
|
19
|
+
const missingVariables = [...new Set(evaluations.flatMap((evaluation) => evaluation.missingVariables ?? []))];
|
|
20
|
+
return missingVariables.length ? { ...decision, missingVariables } : decision;
|
|
19
21
|
}
|
|
20
22
|
const taken = evaluations.filter((evaluation) => evaluation.outcome === "taken");
|
|
21
23
|
if (taken.length) {
|
|
@@ -31,13 +33,22 @@ class GatewayRouter {
|
|
|
31
33
|
}
|
|
32
34
|
return this.stuck(evaluations, defaultFlow, "No condition is true and there is no default flow");
|
|
33
35
|
}
|
|
34
|
-
|
|
36
|
+
refuse(outgoing, reason) {
|
|
37
|
+
return {
|
|
38
|
+
flows: outgoing.map((flow) => ({ flow, outcome: "skipped" })),
|
|
39
|
+
takenFlowIds: [],
|
|
40
|
+
stuckReason: reason,
|
|
41
|
+
refusedByEngine: true
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
evaluateFlow(kind, flow, evaluateCondition) {
|
|
35
45
|
if (flow.expression === void 0) {
|
|
36
|
-
return { flow, outcome: "error", reason: "Missing condition" };
|
|
46
|
+
return kind === "activity" ? { flow, outcome: "taken", reason: "No condition" } : { flow, outcome: "error", reason: "Missing condition" };
|
|
37
47
|
}
|
|
38
48
|
const evaluation = evaluateCondition(flow.expression);
|
|
39
49
|
if (!evaluation.ok) {
|
|
40
|
-
|
|
50
|
+
const { reason, missingVariables } = evaluation;
|
|
51
|
+
return missingVariables ? { flow, outcome: "error", reason, missingVariables } : { flow, outcome: "error", reason };
|
|
41
52
|
}
|
|
42
53
|
if (typeof evaluation.value !== "boolean") {
|
|
43
54
|
return {
|
|
@@ -196,6 +207,16 @@ function readConditionExpression(sequenceFlow) {
|
|
|
196
207
|
language: typeof condition.language === "string" ? condition.language : void 0
|
|
197
208
|
};
|
|
198
209
|
}
|
|
210
|
+
function readMultiInstanceLoop(element) {
|
|
211
|
+
const characteristics = element.loopCharacteristics;
|
|
212
|
+
if (characteristics?.$type !== "bpmn:MultiInstanceLoopCharacteristics") return void 0;
|
|
213
|
+
const cardinality = characteristics.loopCardinality?.body;
|
|
214
|
+
return {
|
|
215
|
+
characteristics,
|
|
216
|
+
mode: characteristics.isSequential ? "sequential" : "parallel",
|
|
217
|
+
cardinality: typeof cardinality === "string" ? cardinality.trim() || void 0 : void 0
|
|
218
|
+
};
|
|
219
|
+
}
|
|
199
220
|
|
|
200
221
|
class JuelError extends Error {
|
|
201
222
|
constructor() {
|
|
@@ -612,6 +633,15 @@ class Camunda7Engine {
|
|
|
612
633
|
const isJuel = !condition?.language || condition.language.toLowerCase() === "juel";
|
|
613
634
|
return isJuel ? condition?.body?.trim() || void 0 : void 0;
|
|
614
635
|
}
|
|
636
|
+
readLoop(activity) {
|
|
637
|
+
const loop = readMultiInstanceLoop(activity);
|
|
638
|
+
if (!loop) return void 0;
|
|
639
|
+
return {
|
|
640
|
+
mode: loop.mode,
|
|
641
|
+
cardinality: loop.cardinality,
|
|
642
|
+
collection: this.collectionExpression(loop.characteristics)
|
|
643
|
+
};
|
|
644
|
+
}
|
|
615
645
|
canEvaluate(expression) {
|
|
616
646
|
try {
|
|
617
647
|
JuelTemplate.parse(expression);
|
|
@@ -637,6 +667,12 @@ class Camunda7Engine {
|
|
|
637
667
|
return [];
|
|
638
668
|
}
|
|
639
669
|
}
|
|
670
|
+
collectionExpression(characteristics) {
|
|
671
|
+
const collection = typeof characteristics.collection === "string" ? characteristics.collection.trim() : "";
|
|
672
|
+
if (!collection) return void 0;
|
|
673
|
+
const isVariableName = !/[$#]\{/.test(collection);
|
|
674
|
+
return isVariableName ? `\${${collection}}` : collection;
|
|
675
|
+
}
|
|
640
676
|
readMappings(element, property) {
|
|
641
677
|
const inputOutput = findExtension(element, "camunda:InputOutput");
|
|
642
678
|
return listProperty(inputOutput, property).filter((parameter) => typeof parameter.name === "string" && parameter.name && !parameter.definition).map((parameter) => ({
|
|
@@ -653,6 +689,7 @@ class ZeebeEngine {
|
|
|
653
689
|
this.label = "Zeebe";
|
|
654
690
|
this.expressionLanguage = "FEEL";
|
|
655
691
|
this.taskResultPropagation = "without-output-mappings";
|
|
692
|
+
this.activityConditionRefusal = "Zeebe rejects this model on deploy: conditional sequence flows are only supported at exclusive or inclusive gateways";
|
|
656
693
|
}
|
|
657
694
|
writeVariable(variables, target, value) {
|
|
658
695
|
return setVariable(variables, target, value);
|
|
@@ -666,6 +703,13 @@ class ZeebeEngine {
|
|
|
666
703
|
readCondition(sequenceFlow) {
|
|
667
704
|
return readConditionExpression(sequenceFlow)?.body?.trim() || void 0;
|
|
668
705
|
}
|
|
706
|
+
readLoop(activity) {
|
|
707
|
+
const loop = readMultiInstanceLoop(activity);
|
|
708
|
+
if (!loop) return void 0;
|
|
709
|
+
const inputCollection = findExtension(loop.characteristics, "zeebe:LoopCharacteristics")?.inputCollection;
|
|
710
|
+
const collection = typeof inputCollection === "string" ? inputCollection.trim() || void 0 : void 0;
|
|
711
|
+
return { mode: loop.mode, cardinality: loop.cardinality, collection };
|
|
712
|
+
}
|
|
669
713
|
canEvaluate(expression) {
|
|
670
714
|
return this.isFeel(expression) && this.parsesAsFeel(expression);
|
|
671
715
|
}
|
|
@@ -813,6 +857,9 @@ class DataSimulationStore {
|
|
|
813
857
|
addWaiting(instanceId, waiting) {
|
|
814
858
|
this.updateInstance(instanceId, (instance) => ({ ...instance, waiting: [...instance.waiting, waiting] }));
|
|
815
859
|
}
|
|
860
|
+
isWaitingScope(scopeId) {
|
|
861
|
+
return [...this.instances.values()].some((instance) => instance.waiting.some((waiting) => waiting.scopeId === scopeId));
|
|
862
|
+
}
|
|
816
863
|
removeWaiting(scopeId) {
|
|
817
864
|
const instance = [...this.instances.values()].find(
|
|
818
865
|
(candidate) => candidate.waiting.some((waiting) => waiting.scopeId === scopeId)
|
|
@@ -960,6 +1007,26 @@ class SimpleStartFormRenderer {
|
|
|
960
1007
|
}
|
|
961
1008
|
}
|
|
962
1009
|
|
|
1010
|
+
class DataActivityBehavior {
|
|
1011
|
+
constructor(behavior, dataGateways) {
|
|
1012
|
+
this.dataGateways = dataGateways;
|
|
1013
|
+
const exitThroughAllFlows = behavior.exit.bind(behavior);
|
|
1014
|
+
behavior.exit = (context) => {
|
|
1015
|
+
const { element, scope } = context;
|
|
1016
|
+
const completing = scope.active && !scope.failed;
|
|
1017
|
+
if (!completing || !this.dataGateways.routesActivityByData(element)) {
|
|
1018
|
+
exitThroughAllFlows(context);
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
this.dataGateways.exitActivity(
|
|
1022
|
+
context,
|
|
1023
|
+
(takenFlows) => exitThroughAllFlows({ ...context, element: { ...element, outgoing: takenFlows } })
|
|
1024
|
+
);
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
DataActivityBehavior.$inject = ["activityBehavior", "dataGateways"];
|
|
1029
|
+
|
|
963
1030
|
const FLOW_CHOICE_TYPES = ["bpmn:ExclusiveGateway", "bpmn:InclusiveGateway"];
|
|
964
1031
|
const TRIGGER_TYPE = "bpmn:Event";
|
|
965
1032
|
class DataContextPads {
|
|
@@ -1029,6 +1096,9 @@ function findProcessInstance(scope) {
|
|
|
1029
1096
|
while (current.parent) current = current.parent;
|
|
1030
1097
|
return current;
|
|
1031
1098
|
}
|
|
1099
|
+
function isLoopInstance(scope) {
|
|
1100
|
+
return scope.parent?.element === scope.element;
|
|
1101
|
+
}
|
|
1032
1102
|
function elementName(element) {
|
|
1033
1103
|
const name = element.businessObject.name;
|
|
1034
1104
|
return typeof name === "string" && name.trim() ? name.trim() : element.id;
|
|
@@ -1043,10 +1113,19 @@ function flowNodesOf(elementRegistry) {
|
|
|
1043
1113
|
function isGateway(element) {
|
|
1044
1114
|
return element.type === "bpmn:ExclusiveGateway" || element.type === "bpmn:InclusiveGateway";
|
|
1045
1115
|
}
|
|
1046
|
-
function
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1116
|
+
function decidingElementOf(element) {
|
|
1117
|
+
return element.type === "bpmn:SequenceFlow" ? element.source?.id : element.id;
|
|
1118
|
+
}
|
|
1119
|
+
function activityRouting(activity, engine) {
|
|
1120
|
+
if (!is(activity, "bpmn:Activity")) return "none";
|
|
1121
|
+
const conditional = outgoingSequenceFlows(activity).filter((flow) => readConditionExpression(flow.businessObject));
|
|
1122
|
+
if (engine.activityConditionRefusal) return conditional.length ? "refused" : "none";
|
|
1123
|
+
if (!conditional.length && !activity.businessObject.default) return "none";
|
|
1124
|
+
const evaluable = conditional.every((flow) => {
|
|
1125
|
+
const expression = engine.readCondition(flow.businessObject);
|
|
1126
|
+
return expression !== void 0 && engine.canEvaluate(expression);
|
|
1127
|
+
});
|
|
1128
|
+
return evaluable ? "by-conditions" : "none";
|
|
1050
1129
|
}
|
|
1051
1130
|
function outgoingSequenceFlows(element) {
|
|
1052
1131
|
return (element.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
@@ -1061,6 +1140,33 @@ function readOutgoingFlow(sequenceFlow, engine) {
|
|
|
1061
1140
|
};
|
|
1062
1141
|
}
|
|
1063
1142
|
|
|
1143
|
+
class MultiInstanceBehaviors {
|
|
1144
|
+
constructor(activity, subProcess, multiInstance) {
|
|
1145
|
+
this.multiInstance = multiInstance;
|
|
1146
|
+
this.runInstances(activity);
|
|
1147
|
+
this.runInstances(subProcess);
|
|
1148
|
+
}
|
|
1149
|
+
runInstances(behavior) {
|
|
1150
|
+
const enterOnce = behavior.enter.bind(behavior);
|
|
1151
|
+
const exitOnce = behavior.exit.bind(behavior);
|
|
1152
|
+
behavior.enter = (context) => {
|
|
1153
|
+
const loop = this.multiInstance.loopOf(context.element);
|
|
1154
|
+
if (!loop) enterOnce(context);
|
|
1155
|
+
else if (isLoopInstance(context.scope))
|
|
1156
|
+
this.multiInstance.enterInstance(context, enterOnce);
|
|
1157
|
+
else this.multiInstance.enterBody(context, loop);
|
|
1158
|
+
};
|
|
1159
|
+
behavior.exit = (context) => {
|
|
1160
|
+
if (this.multiInstance.loopOf(context.element) && isLoopInstance(context.scope)) {
|
|
1161
|
+
this.multiInstance.exitInstance(context);
|
|
1162
|
+
} else {
|
|
1163
|
+
exitOnce(context);
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
MultiInstanceBehaviors.$inject = ["activityBehavior", "subProcessBehavior", "multiInstanceActivities"];
|
|
1169
|
+
|
|
1064
1170
|
class DataGateways {
|
|
1065
1171
|
constructor(dataSimulation, store, simulator) {
|
|
1066
1172
|
this.dataSimulation = dataSimulation;
|
|
@@ -1073,6 +1179,9 @@ class DataGateways {
|
|
|
1073
1179
|
const outgoing = this.outgoingFlows(gateway);
|
|
1074
1180
|
return this.dataSimulation.isEnabled() && outgoing.length > 1 && outgoing.filter((flow) => !flow.isDefault).every((flow) => flow.expression !== void 0 && engine.canEvaluate(flow.expression));
|
|
1075
1181
|
}
|
|
1182
|
+
routesActivityByData(activity) {
|
|
1183
|
+
return this.dataSimulation.isEnabled() && activityRouting(activity, this.dataSimulation.getEngine()) !== "none";
|
|
1184
|
+
}
|
|
1076
1185
|
exit(context, kind) {
|
|
1077
1186
|
const { element: gateway, scope } = context;
|
|
1078
1187
|
const decision = this.decide(gateway, scope, kind);
|
|
@@ -1080,11 +1189,19 @@ class DataGateways {
|
|
|
1080
1189
|
this.waitForRetry(gateway, scope);
|
|
1081
1190
|
return;
|
|
1082
1191
|
}
|
|
1083
|
-
for (const
|
|
1084
|
-
const flow = outgoingSequenceFlows(gateway).find((candidate) => candidate.id === flowId);
|
|
1192
|
+
for (const flow of this.takenFlows(gateway, decision)) {
|
|
1085
1193
|
this.simulator.enter({ element: flow, scope: scope.parent });
|
|
1086
1194
|
}
|
|
1087
1195
|
}
|
|
1196
|
+
exitActivity(context, leaveThrough) {
|
|
1197
|
+
const { element: activity, scope } = context;
|
|
1198
|
+
const decision = this.decide(activity, scope, "activity");
|
|
1199
|
+
if (decision.stuckReason) {
|
|
1200
|
+
this.waitForRetry(activity, scope);
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
leaveThrough(this.takenFlows(activity, decision));
|
|
1204
|
+
}
|
|
1088
1205
|
recordClickDecision(context, kind) {
|
|
1089
1206
|
if (!this.dataSimulation.isEnabled()) return;
|
|
1090
1207
|
const { element: gateway, scope } = context;
|
|
@@ -1101,45 +1218,48 @@ class DataGateways {
|
|
|
1101
1218
|
};
|
|
1102
1219
|
this.record(gateway, scope, kind, "click", decision, []);
|
|
1103
1220
|
}
|
|
1104
|
-
decide(
|
|
1221
|
+
decide(element, scope, kind) {
|
|
1105
1222
|
const engine = this.dataSimulation.getEngine();
|
|
1106
1223
|
const variables = this.dataSimulation.getVariables(scope);
|
|
1107
|
-
const outgoing = this.outgoingFlows(
|
|
1108
|
-
const
|
|
1224
|
+
const outgoing = this.outgoingFlows(element);
|
|
1225
|
+
const refusal = kind === "activity" ? engine.activityConditionRefusal : void 0;
|
|
1226
|
+
const decision = refusal ? this.router.refuse(outgoing, refusal) : this.router.route(kind, outgoing, (expression) => engine.evaluate(expression, variables));
|
|
1109
1227
|
const names = outgoing.flatMap((flow) => flow.expression ? engine.readVariableNames(flow.expression) : []);
|
|
1110
1228
|
const inputs = [...new Set(names)].map((name) => ({ name, value: structuredClone(variables[name]) }));
|
|
1111
|
-
this.record(
|
|
1229
|
+
this.record(element, scope, kind, "data", decision, inputs);
|
|
1112
1230
|
return decision;
|
|
1113
1231
|
}
|
|
1114
|
-
|
|
1232
|
+
takenFlows(element, decision) {
|
|
1233
|
+
return outgoingSequenceFlows(element).filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
1234
|
+
}
|
|
1235
|
+
record(element, scope, gatewayKind, chosenBy, decision, inputs) {
|
|
1115
1236
|
this.store.record({
|
|
1116
1237
|
kind: "decision",
|
|
1117
1238
|
instanceId: findProcessInstance(scope).id,
|
|
1118
|
-
elementId:
|
|
1119
|
-
elementName: elementName(
|
|
1239
|
+
elementId: element.id,
|
|
1240
|
+
elementName: elementName(element),
|
|
1120
1241
|
gatewayKind,
|
|
1121
1242
|
chosenBy,
|
|
1122
1243
|
decision,
|
|
1123
1244
|
inputs
|
|
1124
1245
|
});
|
|
1125
1246
|
}
|
|
1126
|
-
waitForRetry(
|
|
1127
|
-
const waitingScope = this.simulator.createScope({ element
|
|
1247
|
+
waitForRetry(element, scope) {
|
|
1248
|
+
const waitingScope = this.simulator.createScope({ element, parent: scope.parent, initiator: scope }).start();
|
|
1128
1249
|
this.store.addWaiting(findProcessInstance(scope).id, {
|
|
1129
1250
|
scopeId: waitingScope.id,
|
|
1130
|
-
gatewayId:
|
|
1131
|
-
gatewayName: elementName(
|
|
1251
|
+
gatewayId: element.id,
|
|
1252
|
+
gatewayName: elementName(element)
|
|
1132
1253
|
});
|
|
1133
|
-
const retry = { element
|
|
1254
|
+
const retry = { element, type: "continue", interrupting: false, boundary: false };
|
|
1134
1255
|
const subscription = this.simulator.subscribe(waitingScope, retry, (initiator) => {
|
|
1135
1256
|
subscription.remove();
|
|
1136
|
-
this.
|
|
1137
|
-
this.simulator.exit({ element: gateway, scope: waitingScope, initiator });
|
|
1257
|
+
this.simulator.exit({ element, scope: waitingScope, initiator });
|
|
1138
1258
|
});
|
|
1139
1259
|
}
|
|
1140
|
-
outgoingFlows(
|
|
1260
|
+
outgoingFlows(element) {
|
|
1141
1261
|
const engine = this.dataSimulation.getEngine();
|
|
1142
|
-
return outgoingSequenceFlows(
|
|
1262
|
+
return outgoingSequenceFlows(element).map((flow) => readOutgoingFlow(flow, engine));
|
|
1143
1263
|
}
|
|
1144
1264
|
}
|
|
1145
1265
|
DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
|
|
@@ -1192,6 +1312,8 @@ const RESET_SIMULATION_EVENT = "tokenSimulation.resetSimulation";
|
|
|
1192
1312
|
const SCOPE_CREATE_EVENT = "tokenSimulation.simulator.createScope";
|
|
1193
1313
|
const SCOPE_DESTROYED_EVENT = "tokenSimulation.simulator.destroyScope";
|
|
1194
1314
|
const TRACE_EVENT = "tokenSimulation.simulator.trace";
|
|
1315
|
+
const ELEMENT_CHANGED_EVENT = "tokenSimulation.simulator.elementChanged";
|
|
1316
|
+
const TOKEN_COUNT_OVERLAY = "bts-token-count";
|
|
1195
1317
|
const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
|
|
1196
1318
|
|
|
1197
1319
|
class DataSimulation {
|
|
@@ -1261,7 +1383,8 @@ class DataSimulation {
|
|
|
1261
1383
|
this.store.startInstance(scope.id, elementName(scope.element));
|
|
1262
1384
|
}
|
|
1263
1385
|
applyMappings(element, scope) {
|
|
1264
|
-
|
|
1386
|
+
const isRetry = this.store.isWaitingScope(scope.id);
|
|
1387
|
+
if (!is(element, "bpmn:FlowNode") || isLoopInstance(scope) || scope.failed || scope.canceled || isRetry) return;
|
|
1265
1388
|
const instanceId = findProcessInstance(scope).id;
|
|
1266
1389
|
if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
|
|
1267
1390
|
}
|
|
@@ -1319,6 +1442,11 @@ class OutcomeBadge {
|
|
|
1319
1442
|
}
|
|
1320
1443
|
}
|
|
1321
1444
|
|
|
1445
|
+
const KIND_LABELS = {
|
|
1446
|
+
exclusive: "exclusive",
|
|
1447
|
+
inclusive: "inclusive",
|
|
1448
|
+
activity: "conditional flows"
|
|
1449
|
+
};
|
|
1322
1450
|
class DecisionCard {
|
|
1323
1451
|
constructor({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
|
|
1324
1452
|
this.element = h(
|
|
@@ -1328,14 +1456,14 @@ class DecisionCard {
|
|
|
1328
1456
|
"div",
|
|
1329
1457
|
{ className: "bds-decision-title" },
|
|
1330
1458
|
h("span", {}, elementName),
|
|
1331
|
-
h(
|
|
1459
|
+
h(
|
|
1460
|
+
"span",
|
|
1461
|
+
{ className: "bds-tag" },
|
|
1462
|
+
chosenBy === "click" ? `${KIND_LABELS[gatewayKind]} \xB7 by click` : KIND_LABELS[gatewayKind]
|
|
1463
|
+
),
|
|
1332
1464
|
onClose ? this.closeButton(onClose) : null
|
|
1333
1465
|
),
|
|
1334
|
-
decision.stuckReason ? h(
|
|
1335
|
-
"p",
|
|
1336
|
-
{ className: "bds-error" },
|
|
1337
|
-
`${decision.stuckReason}. Change the variables in Process Data, then press \u25B6 on the gateway.`
|
|
1338
|
-
) : null,
|
|
1466
|
+
decision.stuckReason ? h("p", { className: "bds-error" }, this.stuckMessage(decision, gatewayKind)) : null,
|
|
1339
1467
|
h(
|
|
1340
1468
|
"ul",
|
|
1341
1469
|
{ className: "bds-flows" },
|
|
@@ -1352,6 +1480,11 @@ class DecisionCard {
|
|
|
1352
1480
|
inputs.length ? this.inputList(inputs) : null
|
|
1353
1481
|
);
|
|
1354
1482
|
}
|
|
1483
|
+
stuckMessage({ stuckReason, refusedByEngine }, kind) {
|
|
1484
|
+
if (refusedByEngine) return `${stuckReason}.`;
|
|
1485
|
+
const element = kind === "activity" ? "activity" : "gateway";
|
|
1486
|
+
return `${stuckReason}. Change the variables in Process Data, then press \u25B6 on the ${element}.`;
|
|
1487
|
+
}
|
|
1355
1488
|
closeButton(onClose) {
|
|
1356
1489
|
const button = h(
|
|
1357
1490
|
"button",
|
|
@@ -1410,7 +1543,7 @@ function isInView(anchor, bounds) {
|
|
|
1410
1543
|
return anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height;
|
|
1411
1544
|
}
|
|
1412
1545
|
|
|
1413
|
-
var componentStyles = ":host {\n all: initial;\n display: contents;\n}\n\n.bds-panel {\n position: absolute;\n top: 30%;\n right: 20px;\n bottom: 50px;\n z-index: 10000;\n display: flex;\n flex-direction: column;\n width: 300px;\n overflow: hidden;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--token-simulation-control-background, #f1f2f4);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel[hidden] {\n display: none;\n}\n\n.bds-panel-header {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n height: 30px;\n padding: 6px 8px;\n font-size: 16px;\n color: var(--token-simulation-control-surface, #fff);\n background: var(--token-simulation-primary, #0067cc);\n}\n\n.bds-panel-heading {\n flex: 1;\n margin: 0;\n font: inherit;\n text-align: center;\n}\n\n.bds-panel-close {\n display: inline-flex;\n align-items: center;\n padding: 0;\n color: inherit;\n background: none;\n border: none;\n cursor: pointer;\n}\n\n.bds-variables-icon svg,\n.bds-panel-close svg {\n width: 1em;\n height: 1em;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.bds-variables-icon {\n display: inline-flex;\n align-items: center;\n}\n\n.bds-panel-body {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 7px 3px 7px 12px;\n padding: 5px 9px 5px 0;\n overflow-y: auto;\n}\n\n.bds-panel-engine {\n margin: 0;\n}\n\n.bds-panel .bds-section {\n padding: var(--bds-space-2);\n background: var(--token-simulation-control-surface, #fff);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n}\n\n.bds-engine {\n padding: 2px 8px;\n font-size: 11px;\n font-weight: 600;\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-icon-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n width: 26px;\n height: 26px;\n padding: 0;\n color: var(--bds-muted);\n background: transparent;\n border: 1px solid transparent;\n border-radius: var(--bds-radius-sm);\n cursor: pointer;\n}\n\n.bds-icon-button svg {\n width: 16px;\n height: 16px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.5;\n stroke-linecap: round;\n stroke-linejoin: round;\n transition: transform var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-icon-button:hover {\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n}\n\n.bds-section {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-section[hidden] {\n display: none;\n}\n\n.bds-section-title,\n.bds-label {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n color: var(--bds-muted);\n}\n\n.bds-section-title {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n}\n\n.bds-hint {\n margin: 0;\n font-size: 12px;\n color: var(--bds-muted);\n}\n\n.bds-hint[hidden],\n.bds-error[hidden] {\n display: none;\n}\n\n.bds-error {\n margin: 0;\n font-size: 12px;\n color: var(--bds-danger);\n}\n\n.bds-input {\n box-sizing: border-box;\n width: 100%;\n padding: 6px 10px;\n font-family: inherit;\n font-size: 13px;\n font-weight: 400;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n transition:\n border-color var(--bds-motion-fast) var(--bds-ease),\n box-shadow var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-input:focus,\n.bds-input:focus-visible {\n outline: none;\n border-color: var(--bds-accent);\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-input--invalid,\n.bds-input--invalid:focus {\n border-color: var(--bds-danger);\n box-shadow: 0 0 0 3px var(--bds-danger-soft);\n}\n\n.bds-json {\n min-height: 72px;\n font-family: var(--bds-font-mono);\n font-size: 12px;\n line-height: 1.5;\n resize: vertical;\n}\n\n.bds-instance-select[hidden] {\n display: none;\n}\n\n.bds-instance-select {\n padding: 4px 8px;\n font-size: 12px;\n}\n\n.bds-actions {\n display: flex;\n justify-content: flex-end;\n gap: var(--bds-space-2);\n margin-top: var(--bds-space-2);\n}\n\n.bds-button {\n padding: 5px 12px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 600;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n box-shadow: var(--bds-shadow-1);\n cursor: pointer;\n transition:\n background var(--bds-motion-fast) var(--bds-ease),\n border-color var(--bds-motion-fast) var(--bds-ease),\n color var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-button:hover {\n color: var(--bds-accent-ink);\n border-color: var(--bds-accent);\n background: var(--bds-accent-soft);\n}\n\n.bds-button--primary {\n color: var(--bds-on-accent);\n background: var(--bds-accent);\n border-color: var(--bds-accent);\n}\n\n.bds-button--primary:hover {\n color: var(--bds-on-accent);\n background: var(--bds-accent-ink);\n}\n\n.bds-button:focus-visible,\n.bds-icon-button:focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-status {\n margin: 0 0 var(--bds-space-1);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-status--running {\n color: var(--bds-accent-ink);\n}\n\n.bds-status--completed {\n color: var(--bds-success);\n}\n\n.bds-status--waiting {\n color: var(--bds-danger);\n}\n\n.bds-variables {\n width: 100%;\n border-collapse: collapse;\n}\n\n.bds-variables th,\n.bds-variables td {\n padding: 4px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--bds-line);\n}\n\n.bds-variables tr:last-child th,\n.bds-variables tr:last-child td {\n border-bottom: none;\n}\n\n.bds-variables th {\n width: 1%;\n padding-right: var(--bds-space-3);\n font-weight: 500;\n white-space: nowrap;\n}\n\n.bds-variables code,\n.bds-flow code {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n overflow-wrap: anywhere;\n}\n\n.bds-log {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-log-entry {\n padding: var(--bds-space-2);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n}\n\n.bds-log-entry--issue {\n border-color: var(--bds-danger-soft);\n background: linear-gradient(var(--bds-danger-soft), var(--bds-danger-soft)), var(--bds-surface);\n}\n\n.bds-log-title {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n margin-bottom: var(--bds-space-1);\n font-weight: 600;\n}\n\n.bds-tag {\n padding: 1px 6px;\n font-size: 11px;\n font-weight: 500;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-flows {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-flow {\n display: grid;\n grid-template-columns: 18px 1fr;\n align-items: center;\n column-gap: var(--bds-space-2);\n row-gap: 2px;\n}\n\n.bds-flow code,\n.bds-flow .bds-tag {\n grid-column: 2;\n justify-self: start;\n}\n\n.bds-flow code {\n padding: 1px 4px;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: 4px;\n}\n\n.bds-flow--skipped,\n.bds-flow--not-taken {\n color: var(--bds-muted);\n}\n\n.bds-outcome {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 700;\n line-height: 1;\n border-radius: var(--bds-radius-pill);\n border: 1px solid transparent;\n cursor: default;\n}\n\n.bds-outcome--taken {\n color: var(--bds-on-accent);\n background: var(--bds-success);\n}\n\n.bds-outcome--not-taken {\n color: var(--bds-muted);\n background: var(--bds-surface);\n border-color: var(--bds-line);\n}\n\n.bds-outcome--error {\n color: var(--bds-on-accent);\n background: var(--bds-danger);\n}\n\n.bds-outcome--skipped {\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n}\n\n.bds-outcome--on-flow {\n display: flex;\n box-shadow: var(--bds-shadow-1);\n transform: translate(-50%, -50%);\n}\n\n.bds-popover {\n position: absolute;\n z-index: 100;\n overflow-y: auto;\n}\n\n.bds-popover[hidden] {\n display: none;\n}\n\n.bds-decision {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n width: 300px;\n padding: 12px;\n font-family: var(--bds-font);\n font-size: 12px;\n line-height: 1.4;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-md);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-decision--stuck {\n border-color: var(--bds-danger);\n}\n\n.bds-decision-title {\n display: flex;\n align-items: center;\n gap: var(--bds-space-2);\n font-size: 13px;\n font-weight: 600;\n}\n\n.bds-decision-title .bds-tag {\n margin-left: auto;\n}\n\n.bds-decision-close {\n margin-left: 0;\n width: 22px;\n height: 22px;\n font-size: 16px;\n line-height: 1;\n}\n\n.bds-decision-inputs {\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 2px var(--bds-space-3);\n margin: 0;\n padding-top: var(--bds-space-2);\n border-top: 1px solid var(--bds-line);\n}\n\n.bds-decision-inputs dt {\n font-family: var(--bds-font-mono);\n color: var(--bds-muted);\n}\n\n.bds-decision-inputs dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.bds-decision-inputs code {\n font-family: var(--bds-font-mono);\n}\n\n.bds-dialog-backdrop {\n position: fixed;\n inset: 0;\n z-index: 10010;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--bds-space-3);\n background: rgba(29, 29, 29, 0.24);\n}\n\n.bds-dialog {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n box-sizing: border-box;\n width: 420px;\n max-width: 100%;\n max-height: 100%;\n margin: 0;\n padding: 20px;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-lg);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-dialog-content {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n min-height: 0;\n overflow-y: auto;\n}\n\n.bds-dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n}\n\n.bds-dialog .bds-actions {\n margin-top: 0;\n}\n\n.bds-form {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.bds-field {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-field-name {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-field-hint {\n font-size: 11px;\n color: var(--bds-muted);\n}\n\n.bds-checkbox {\n display: inline-flex;\n align-items: center;\n gap: var(--bds-space-2);\n cursor: pointer;\n}\n\n.bds-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: var(--bds-accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 0.001ms !important;\n }\n}\n\n.bds-form .bds-json {\n min-height: 0;\n}\n";
|
|
1546
|
+
var componentStyles = ":host {\n all: initial;\n display: contents;\n}\n\n.bds-panel {\n position: absolute;\n top: 30%;\n right: 20px;\n bottom: 50px;\n z-index: 10000;\n display: flex;\n flex-direction: column;\n width: 300px;\n overflow: hidden;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--token-simulation-control-background, #f1f2f4);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel[hidden] {\n display: none;\n}\n\n.bds-panel-header {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n height: 30px;\n padding: 6px 8px;\n font-size: 16px;\n color: var(--token-simulation-control-surface, #fff);\n background: var(--token-simulation-primary, #0067cc);\n}\n\n.bds-panel-heading {\n flex: 1;\n margin: 0;\n font: inherit;\n text-align: center;\n}\n\n.bds-panel-close {\n display: inline-flex;\n align-items: center;\n padding: 0;\n color: inherit;\n background: none;\n border: none;\n cursor: pointer;\n}\n\n.bds-variables-icon svg,\n.bds-panel-close svg {\n width: 1em;\n height: 1em;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.bds-variables-icon {\n display: inline-flex;\n align-items: center;\n}\n\n.bds-panel-body {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 7px 3px 7px 12px;\n padding: 5px 9px 5px 0;\n overflow-y: auto;\n}\n\n.bds-panel-engine {\n margin: 0;\n}\n\n.bds-panel .bds-section {\n padding: var(--bds-space-2);\n background: var(--token-simulation-control-surface, #fff);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n}\n\n.bds-engine {\n padding: 2px 8px;\n font-size: 11px;\n font-weight: 600;\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-icon-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n width: 26px;\n height: 26px;\n padding: 0;\n color: var(--bds-muted);\n background: transparent;\n border: 1px solid transparent;\n border-radius: var(--bds-radius-sm);\n cursor: pointer;\n}\n\n.bds-icon-button svg {\n width: 16px;\n height: 16px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.5;\n stroke-linecap: round;\n stroke-linejoin: round;\n transition: transform var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-icon-button:hover {\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n}\n\n.bds-section {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-section[hidden] {\n display: none;\n}\n\n.bds-section-title,\n.bds-label {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n color: var(--bds-muted);\n}\n\n.bds-section-title {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n}\n\n.bds-hint {\n margin: 0;\n font-size: 12px;\n color: var(--bds-muted);\n}\n\n.bds-hint[hidden],\n.bds-error[hidden] {\n display: none;\n}\n\n.bds-error {\n margin: 0;\n font-size: 12px;\n color: var(--bds-danger);\n}\n\n.bds-input {\n box-sizing: border-box;\n width: 100%;\n padding: 6px 10px;\n font-family: inherit;\n font-size: 13px;\n font-weight: 400;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n transition:\n border-color var(--bds-motion-fast) var(--bds-ease),\n box-shadow var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-input:focus,\n.bds-input:focus-visible {\n outline: none;\n border-color: var(--bds-accent);\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-input--invalid,\n.bds-input--invalid:focus {\n border-color: var(--bds-danger);\n box-shadow: 0 0 0 3px var(--bds-danger-soft);\n}\n\n.bds-json {\n min-height: 72px;\n font-family: var(--bds-font-mono);\n font-size: 12px;\n line-height: 1.5;\n resize: vertical;\n}\n\n.bds-instance-select[hidden] {\n display: none;\n}\n\n.bds-instance-select {\n padding: 4px 8px;\n font-size: 12px;\n}\n\n.bds-actions {\n display: flex;\n justify-content: flex-end;\n gap: var(--bds-space-2);\n margin-top: var(--bds-space-2);\n}\n\n.bds-button {\n padding: 5px 12px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 600;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n box-shadow: var(--bds-shadow-1);\n cursor: pointer;\n transition:\n background var(--bds-motion-fast) var(--bds-ease),\n border-color var(--bds-motion-fast) var(--bds-ease),\n color var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-button:hover {\n color: var(--bds-accent-ink);\n border-color: var(--bds-accent);\n background: var(--bds-accent-soft);\n}\n\n.bds-button--primary {\n color: var(--bds-on-accent);\n background: var(--bds-accent);\n border-color: var(--bds-accent);\n}\n\n.bds-button--primary:hover {\n color: var(--bds-on-accent);\n background: var(--bds-accent-ink);\n}\n\n.bds-button:focus-visible,\n.bds-icon-button:focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-status {\n margin: 0 0 var(--bds-space-1);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-status--running {\n color: var(--bds-accent-ink);\n}\n\n.bds-status--completed {\n color: var(--bds-success);\n}\n\n.bds-status--waiting {\n color: var(--bds-danger);\n}\n\n.bds-variables {\n width: 100%;\n border-collapse: collapse;\n}\n\n.bds-variables th,\n.bds-variables td {\n padding: 4px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--bds-line);\n}\n\n.bds-variables tr:last-child th,\n.bds-variables tr:last-child td {\n border-bottom: none;\n}\n\n.bds-variables th {\n width: 1%;\n padding-right: var(--bds-space-3);\n font-weight: 500;\n white-space: nowrap;\n}\n\n.bds-variables code,\n.bds-flow code {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n overflow-wrap: anywhere;\n}\n\n.bds-log {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-log-entry {\n padding: var(--bds-space-2);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n}\n\n.bds-log-entry--issue {\n border-color: var(--bds-danger-soft);\n background: linear-gradient(var(--bds-danger-soft), var(--bds-danger-soft)), var(--bds-surface);\n}\n\n.bds-log-title {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n margin-bottom: var(--bds-space-1);\n font-weight: 600;\n}\n\n.bds-tag {\n padding: 1px 6px;\n font-size: 11px;\n font-weight: 500;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-flows {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-flow {\n display: grid;\n grid-template-columns: 18px 1fr;\n align-items: center;\n column-gap: var(--bds-space-2);\n row-gap: 2px;\n}\n\n.bds-flow code,\n.bds-flow .bds-tag {\n grid-column: 2;\n justify-self: start;\n}\n\n.bds-flow code {\n padding: 1px 4px;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: 4px;\n}\n\n.bds-flow--skipped,\n.bds-flow--not-taken {\n color: var(--bds-muted);\n}\n\n.bds-outcome {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 700;\n line-height: 1;\n border-radius: var(--bds-radius-pill);\n border: 1px solid transparent;\n cursor: default;\n}\n\n.bds-outcome--taken {\n color: var(--bds-on-accent);\n background: var(--bds-success);\n}\n\n.bds-outcome--not-taken {\n color: var(--bds-muted);\n background: var(--bds-surface);\n border-color: var(--bds-line);\n}\n\n.bds-outcome--error {\n color: var(--bds-on-accent);\n background: var(--bds-danger);\n}\n\n.bds-outcome--skipped {\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n}\n\n.bds-outcome--on-flow {\n display: flex;\n box-shadow: var(--bds-shadow-1);\n transform: translate(-50%, -50%);\n}\n\n.bds-popover {\n position: absolute;\n z-index: 100;\n overflow-y: auto;\n}\n\n.bds-popover[hidden] {\n display: none;\n}\n\n.bds-decision {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n width: 300px;\n padding: 12px;\n font-family: var(--bds-font);\n font-size: 12px;\n line-height: 1.4;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-md);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-decision--stuck {\n border-color: var(--bds-danger);\n}\n\n.bds-decision-title {\n display: flex;\n align-items: center;\n gap: var(--bds-space-2);\n font-size: 13px;\n font-weight: 600;\n}\n\n.bds-decision-title .bds-tag {\n margin-left: auto;\n}\n\n.bds-decision-close {\n margin-left: 0;\n width: 22px;\n height: 22px;\n font-size: 16px;\n line-height: 1;\n}\n\n.bds-decision-inputs {\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 2px var(--bds-space-3);\n margin: 0;\n padding-top: var(--bds-space-2);\n border-top: 1px solid var(--bds-line);\n}\n\n.bds-decision-inputs dt {\n font-family: var(--bds-font-mono);\n color: var(--bds-muted);\n}\n\n.bds-decision-inputs dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.bds-decision-inputs code {\n font-family: var(--bds-font-mono);\n}\n\n.bds-dialog-backdrop {\n position: fixed;\n inset: 0;\n z-index: 10010;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--bds-space-3);\n background: rgba(29, 29, 29, 0.24);\n}\n\n.bds-dialog {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n box-sizing: border-box;\n width: 420px;\n max-width: 100%;\n max-height: 100%;\n margin: 0;\n padding: 20px;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-lg);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-dialog-content {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n min-height: 0;\n overflow-y: auto;\n}\n\n.bds-dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n}\n\n.bds-dialog .bds-actions {\n margin-top: 0;\n}\n\n.bds-form {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.bds-field {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-field-name {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-field-hint {\n font-size: 11px;\n color: var(--bds-muted);\n}\n\n.bds-checkbox {\n display: inline-flex;\n align-items: center;\n gap: var(--bds-space-2);\n cursor: pointer;\n}\n\n.bds-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: var(--bds-accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 0.001ms !important;\n }\n}\n\n.bds-form .bds-json {\n min-height: 0;\n}\n\n.bds-loop {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n padding: 2px 6px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 600;\n line-height: 1;\n white-space: nowrap;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-loop-dot {\n box-sizing: border-box;\n width: 8px;\n height: 8px;\n border-radius: var(--bds-radius-pill);\n border: 1.5px solid var(--bds-muted);\n}\n\n.bds-loop-dot--running {\n border-color: var(--bds-accent);\n background: var(--bds-accent);\n}\n\n.bds-loop-dot--done {\n border-color: var(--bds-success);\n background: var(--bds-success);\n}\n\n.bds-loop-count {\n margin-left: 2px;\n color: var(--bds-muted);\n}\n";
|
|
1414
1547
|
|
|
1415
1548
|
let sharedSheet;
|
|
1416
1549
|
function inShadow(...children) {
|
|
@@ -1444,8 +1577,8 @@ class DataSimulationOverlays {
|
|
|
1444
1577
|
this.overlays = overlays;
|
|
1445
1578
|
this.elementRegistry = elementRegistry;
|
|
1446
1579
|
this.canvas = canvas;
|
|
1447
|
-
this.
|
|
1448
|
-
this.
|
|
1580
|
+
this.pinnedElementIds = /* @__PURE__ */ new Set();
|
|
1581
|
+
this.markedElements = [];
|
|
1449
1582
|
this.popovers = [];
|
|
1450
1583
|
this.popoverLayer = inShadow();
|
|
1451
1584
|
this.renderedState = "";
|
|
@@ -1455,12 +1588,12 @@ class DataSimulationOverlays {
|
|
|
1455
1588
|
this.render();
|
|
1456
1589
|
});
|
|
1457
1590
|
eventBus.on("element.hover", ({ element }) => {
|
|
1458
|
-
this.
|
|
1591
|
+
this.hoveredElementId = decidingElementOf(element);
|
|
1459
1592
|
this.render();
|
|
1460
1593
|
});
|
|
1461
1594
|
eventBus.on("element.click", ({ element }) => {
|
|
1462
|
-
if (!isGateway(element)) return;
|
|
1463
|
-
if (!this.
|
|
1595
|
+
if (!isGateway(element) && !this.hasDecision(element)) return;
|
|
1596
|
+
if (!this.pinnedElementIds.delete(element.id)) this.pinnedElementIds.add(element.id);
|
|
1464
1597
|
this.render();
|
|
1465
1598
|
});
|
|
1466
1599
|
eventBus.on(["canvas.viewbox.changed", "canvas.resized"], () => this.placePopovers());
|
|
@@ -1473,33 +1606,36 @@ class DataSimulationOverlays {
|
|
|
1473
1606
|
render() {
|
|
1474
1607
|
const { decisions, shown } = new GatewayDecisionView(this.snapshot);
|
|
1475
1608
|
const cards = shown.filter(
|
|
1476
|
-
({ elementId }) => elementId === this.
|
|
1609
|
+
({ elementId }) => elementId === this.hoveredElementId || this.pinnedElementIds.has(elementId)
|
|
1477
1610
|
);
|
|
1478
1611
|
const state = JSON.stringify([
|
|
1479
1612
|
decisions.map((entry) => entry.id),
|
|
1480
1613
|
shown.map((entry) => entry.id),
|
|
1481
|
-
cards.map((entry) => [entry.id, this.
|
|
1614
|
+
cards.map((entry) => [entry.id, this.pinnedElementIds.has(entry.elementId)])
|
|
1482
1615
|
]);
|
|
1483
1616
|
if (state === this.renderedState) return;
|
|
1484
1617
|
this.renderedState = state;
|
|
1485
1618
|
this.overlays.remove({ type: OUTCOME_OVERLAY });
|
|
1486
|
-
this.
|
|
1619
|
+
this.unmarkElements();
|
|
1487
1620
|
for (const entry of decisions) this.showOutcomes(entry.decision);
|
|
1488
|
-
for (const entry of shown) this.
|
|
1621
|
+
for (const entry of shown) this.markElement(entry);
|
|
1489
1622
|
this.showCards(cards);
|
|
1490
1623
|
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
if (!gateway) return;
|
|
1494
|
-
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1495
|
-
this.markedGateways.push(gateway);
|
|
1624
|
+
hasDecision(element) {
|
|
1625
|
+
return new GatewayDecisionView(this.snapshot).shown.some(({ elementId }) => elementId === element.id);
|
|
1496
1626
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1627
|
+
markElement({ elementId, decision }) {
|
|
1628
|
+
const element = this.elementRegistry.get(elementId);
|
|
1629
|
+
if (!element) return;
|
|
1630
|
+
this.canvas.addMarker(element, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1631
|
+
this.markedElements.push(element);
|
|
1632
|
+
}
|
|
1633
|
+
unmarkElements() {
|
|
1634
|
+
for (const element of this.markedElements) {
|
|
1635
|
+
this.canvas.removeMarker(element, DECIDED_MARKER);
|
|
1636
|
+
this.canvas.removeMarker(element, STUCK_MARKER$1);
|
|
1501
1637
|
}
|
|
1502
|
-
this.
|
|
1638
|
+
this.markedElements = [];
|
|
1503
1639
|
}
|
|
1504
1640
|
showOutcomes(decision) {
|
|
1505
1641
|
for (const { flow, outcome, reason } of decision.flows) {
|
|
@@ -1516,16 +1652,16 @@ class DataSimulationOverlays {
|
|
|
1516
1652
|
}
|
|
1517
1653
|
showCards(entries) {
|
|
1518
1654
|
this.popovers = entries.flatMap((entry) => {
|
|
1519
|
-
const
|
|
1520
|
-
if (!
|
|
1655
|
+
const element = this.elementRegistry.get(entry.elementId);
|
|
1656
|
+
if (!element) return [];
|
|
1521
1657
|
const close = () => {
|
|
1522
|
-
this.
|
|
1658
|
+
this.pinnedElementIds.delete(entry.elementId);
|
|
1523
1659
|
this.render();
|
|
1524
1660
|
};
|
|
1525
|
-
const card = new DecisionCard(entry, this.
|
|
1661
|
+
const card = new DecisionCard(entry, this.pinnedElementIds.has(entry.elementId) ? close : void 0).element;
|
|
1526
1662
|
card.classList.add("bds-popover");
|
|
1527
1663
|
card.dataset.elementId = entry.elementId;
|
|
1528
|
-
return [{
|
|
1664
|
+
return [{ element, card }];
|
|
1529
1665
|
});
|
|
1530
1666
|
this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
|
|
1531
1667
|
this.placePopovers();
|
|
@@ -1533,10 +1669,10 @@ class DataSimulationOverlays {
|
|
|
1533
1669
|
placePopovers() {
|
|
1534
1670
|
const container = this.canvas.getContainer();
|
|
1535
1671
|
const bounds = { width: container.clientWidth, height: container.clientHeight };
|
|
1536
|
-
for (const {
|
|
1672
|
+
for (const { element, card } of this.popovers) {
|
|
1537
1673
|
card.style.maxHeight = "";
|
|
1538
1674
|
const { left, top, maxHeight, hidden } = placePopover(
|
|
1539
|
-
this.canvas.getAbsoluteBBox(
|
|
1675
|
+
this.canvas.getAbsoluteBBox(element),
|
|
1540
1676
|
{ width: card.offsetWidth, height: card.offsetHeight },
|
|
1541
1677
|
bounds
|
|
1542
1678
|
);
|
|
@@ -1698,11 +1834,13 @@ class VariablesPanel {
|
|
|
1698
1834
|
}
|
|
1699
1835
|
renderIssues({ log, selectedInstanceId }) {
|
|
1700
1836
|
const issues = log.filter(
|
|
1701
|
-
(entry) => entry.
|
|
1837
|
+
(entry) => entry.instanceId === selectedInstanceId && this.isIssue(entry)
|
|
1702
1838
|
);
|
|
1703
1839
|
this.issueSection.hidden = !issues.length;
|
|
1704
1840
|
this.issueList.replaceChildren(
|
|
1705
|
-
...issues.slice().reverse().map(
|
|
1841
|
+
...issues.slice().reverse().map(
|
|
1842
|
+
(issue) => issue.kind === "mapping-issue" ? this.renderMappingIssue(issue) : this.renderInstanceCountIssue(issue)
|
|
1843
|
+
)
|
|
1706
1844
|
);
|
|
1707
1845
|
}
|
|
1708
1846
|
describeStatus({ processName, status, waiting }) {
|
|
@@ -1722,6 +1860,17 @@ class VariablesPanel {
|
|
|
1722
1860
|
h("p", { className: "bds-error" }, `${target}: ${reason}`)
|
|
1723
1861
|
);
|
|
1724
1862
|
}
|
|
1863
|
+
isIssue(entry) {
|
|
1864
|
+
return entry.kind === "mapping-issue" || entry.kind === "multi-instance" && Boolean(entry.count.reason);
|
|
1865
|
+
}
|
|
1866
|
+
renderInstanceCountIssue({ elementName, count }) {
|
|
1867
|
+
return h(
|
|
1868
|
+
"li",
|
|
1869
|
+
{ className: "bds-log-entry bds-log-entry--issue" },
|
|
1870
|
+
h("div", { className: "bds-log-title" }, elementName, h("span", { className: "bds-tag" }, "instances")),
|
|
1871
|
+
h("p", { className: "bds-error" }, `Ran ${count.count} instances by default: ${count.reason}`)
|
|
1872
|
+
);
|
|
1873
|
+
}
|
|
1725
1874
|
parseVariables(text) {
|
|
1726
1875
|
try {
|
|
1727
1876
|
const value = JSON.parse(text || "{}");
|
|
@@ -1994,8 +2143,10 @@ class VariableUsageCollector {
|
|
|
1994
2143
|
}
|
|
1995
2144
|
if (!is(element, "bpmn:FlowNode")) return void 0;
|
|
1996
2145
|
const { inputs, outputs } = this.engine.readIoMappings(businessObject);
|
|
2146
|
+
const loop = this.engine.readLoop?.(businessObject);
|
|
2147
|
+
const readOnEnter = [loop?.cardinality, loop?.collection, ...inputs.map((mapping) => mapping.source)];
|
|
1997
2148
|
return this.usage(element, {
|
|
1998
|
-
inputReads:
|
|
2149
|
+
inputReads: readOnEnter.flatMap((expression) => expression ? this.engine.readVariableNames(expression) : []),
|
|
1999
2150
|
inputTargets: inputs.map((mapping) => mapping.target),
|
|
2000
2151
|
outputReads: outputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
|
|
2001
2152
|
outputTargets: outputs.map((mapping) => mapping.target)
|
|
@@ -2064,6 +2215,210 @@ class DataStartForm {
|
|
|
2064
2215
|
}
|
|
2065
2216
|
DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
|
|
2066
2217
|
|
|
2218
|
+
const DEFAULT_INSTANCE_COUNT = 3;
|
|
2219
|
+
class InstanceCounter {
|
|
2220
|
+
count({ cardinality, collection }, evaluate) {
|
|
2221
|
+
if (!evaluate) return { count: DEFAULT_INSTANCE_COUNT, source: "default" };
|
|
2222
|
+
if (cardinality) return this.fromCardinality(cardinality, evaluate(cardinality));
|
|
2223
|
+
if (collection) return this.fromCollection(collection, evaluate(collection));
|
|
2224
|
+
return { count: DEFAULT_INSTANCE_COUNT, source: "default" };
|
|
2225
|
+
}
|
|
2226
|
+
fromCardinality(expression, evaluation) {
|
|
2227
|
+
if (!evaluation.ok) return this.fallback(expression, evaluation.reason);
|
|
2228
|
+
const count = typeof evaluation.value === "string" ? Number(evaluation.value) : evaluation.value;
|
|
2229
|
+
if (typeof count !== "number" || !Number.isInteger(count) || count < 0) {
|
|
2230
|
+
return this.fallback(expression, `Loop cardinality ${JSON.stringify(evaluation.value)} is not a whole number`);
|
|
2231
|
+
}
|
|
2232
|
+
return { count, source: "cardinality", expression };
|
|
2233
|
+
}
|
|
2234
|
+
fromCollection(expression, evaluation) {
|
|
2235
|
+
if (!evaluation.ok) return this.fallback(expression, evaluation.reason);
|
|
2236
|
+
if (!Array.isArray(evaluation.value)) {
|
|
2237
|
+
return this.fallback(expression, `Collection ${JSON.stringify(evaluation.value)} is not a list`);
|
|
2238
|
+
}
|
|
2239
|
+
return { count: evaluation.value.length, source: "collection", expression };
|
|
2240
|
+
}
|
|
2241
|
+
fallback(expression, reason) {
|
|
2242
|
+
return { count: DEFAULT_INSTANCE_COUNT, source: "default", expression, reason };
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
class InstanceLoop {
|
|
2247
|
+
constructor(mode, count) {
|
|
2248
|
+
this.mode = mode;
|
|
2249
|
+
this.statuses = Array.from({ length: count }, () => "waiting");
|
|
2250
|
+
}
|
|
2251
|
+
get progress() {
|
|
2252
|
+
return this.statuses;
|
|
2253
|
+
}
|
|
2254
|
+
get finished() {
|
|
2255
|
+
return this.statuses.every((status) => status === "done");
|
|
2256
|
+
}
|
|
2257
|
+
start() {
|
|
2258
|
+
const first = this.mode === "parallel" ? this.statuses.map((_, index) => index) : [0];
|
|
2259
|
+
return first.filter((index) => index < this.statuses.length).map((index) => this.run(index));
|
|
2260
|
+
}
|
|
2261
|
+
complete(index) {
|
|
2262
|
+
this.statuses[index] = "done";
|
|
2263
|
+
const next = this.statuses.indexOf("waiting");
|
|
2264
|
+
return this.mode === "sequential" && next >= 0 ? this.run(next) : void 0;
|
|
2265
|
+
}
|
|
2266
|
+
run(index) {
|
|
2267
|
+
this.statuses[index] = "running";
|
|
2268
|
+
return index;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
const MAX_DOTS = 12;
|
|
2273
|
+
class InstanceProgress {
|
|
2274
|
+
constructor(mode, count) {
|
|
2275
|
+
this.element = h("span", { className: "bds-loop" });
|
|
2276
|
+
this.description = this.describe(mode, count);
|
|
2277
|
+
}
|
|
2278
|
+
show(progress) {
|
|
2279
|
+
const done = progress.filter((status) => status === "done").length;
|
|
2280
|
+
const dots = progress.length <= MAX_DOTS ? progress.map(
|
|
2281
|
+
(status) => h("span", { className: `bds-loop-dot bds-loop-dot--${status}`, "data-status": status })
|
|
2282
|
+
) : [];
|
|
2283
|
+
this.element.title = this.description;
|
|
2284
|
+
this.element.replaceChildren(...dots, h("span", { className: "bds-loop-count" }, `${done}/${progress.length}`));
|
|
2285
|
+
}
|
|
2286
|
+
describe(mode, { count, source, expression, reason }) {
|
|
2287
|
+
if (!count) return `No instance: ${expression} is empty`;
|
|
2288
|
+
const instances = `${count} ${mode} instance${count === 1 ? "" : "s"}`;
|
|
2289
|
+
if (source === "collection") return `${instances}, one per item of ${expression}`;
|
|
2290
|
+
if (source === "cardinality") return `${instances}, loop cardinality ${expression}`;
|
|
2291
|
+
return reason ? `${instances} (default): ${reason}` : `${instances} (default without data)`;
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
const PROGRESS_OVERLAY = "bds-loop-progress";
|
|
2296
|
+
const PROGRESS_OFFSET_TOP = -26;
|
|
2297
|
+
const BELOW_TOKEN_COUNT = 250;
|
|
2298
|
+
const STAGGER_STEP_LENGTH = 6;
|
|
2299
|
+
class MultiInstanceActivities {
|
|
2300
|
+
constructor(dataSimulation, store, simulator, scopeBehavior, overlays, eventBus, injector) {
|
|
2301
|
+
this.dataSimulation = dataSimulation;
|
|
2302
|
+
this.store = store;
|
|
2303
|
+
this.simulator = simulator;
|
|
2304
|
+
this.scopeBehavior = scopeBehavior;
|
|
2305
|
+
this.overlays = overlays;
|
|
2306
|
+
this.counter = new InstanceCounter();
|
|
2307
|
+
this.loops = /* @__PURE__ */ new Map();
|
|
2308
|
+
this.instanceIndexes = /* @__PURE__ */ new WeakMap();
|
|
2309
|
+
this.animation = injector.get("animation", false);
|
|
2310
|
+
eventBus.on(ELEMENT_CHANGED_EVENT, BELOW_TOKEN_COUNT, ({ element }) => {
|
|
2311
|
+
if (this.loopOf(element)) this.overlays.remove({ element, type: TOKEN_COUNT_OVERLAY });
|
|
2312
|
+
});
|
|
2313
|
+
eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => this.loops.delete(scope.id));
|
|
2314
|
+
eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => {
|
|
2315
|
+
this.loops.clear();
|
|
2316
|
+
this.overlays.remove({ type: PROGRESS_OVERLAY });
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
loopOf(activity) {
|
|
2320
|
+
return this.dataSimulation.getEngine().readLoop?.(activity.businessObject);
|
|
2321
|
+
}
|
|
2322
|
+
enterBody(context, loop) {
|
|
2323
|
+
const { element, scope: body } = context;
|
|
2324
|
+
const count = this.count(body, loop);
|
|
2325
|
+
this.record(element, body, loop, count);
|
|
2326
|
+
const instanceLoop = new InstanceLoop(loop.mode, count.count);
|
|
2327
|
+
const progress = this.showProgress(element, new InstanceProgress(loop.mode, count));
|
|
2328
|
+
if (!count.count) {
|
|
2329
|
+
progress.show(instanceLoop.progress);
|
|
2330
|
+
this.simulator.exit(context);
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2333
|
+
this.loops.set(body.id, { loop: instanceLoop, progress });
|
|
2334
|
+
for (const index of instanceLoop.start()) this.startInstance(element, body, index);
|
|
2335
|
+
progress.show(instanceLoop.progress);
|
|
2336
|
+
}
|
|
2337
|
+
enterInstance(context, enterActivity) {
|
|
2338
|
+
const { element, scope, loopIndex } = context;
|
|
2339
|
+
const loop = this.loops.get(scope.parent.id)?.loop;
|
|
2340
|
+
this.instanceIndexes.set(scope, loopIndex);
|
|
2341
|
+
const runInstance = is(element, "bpmn:SubProcess") ? () => enterActivity(context) : () => this.passThrough(element, scope, () => enterActivity(context));
|
|
2342
|
+
const staggerSteps = loop?.mode === "parallel" ? loopIndex : 0;
|
|
2343
|
+
this.stagger(element, scope, staggerSteps, runInstance);
|
|
2344
|
+
}
|
|
2345
|
+
exitInstance({ element, scope }) {
|
|
2346
|
+
const body = scope.parent;
|
|
2347
|
+
const run = this.loops.get(body.id);
|
|
2348
|
+
if (!run) return;
|
|
2349
|
+
const { loop, progress } = run;
|
|
2350
|
+
const next = loop.complete(this.instanceIndexes.get(scope));
|
|
2351
|
+
if (next !== void 0) this.startInstance(element, body, next);
|
|
2352
|
+
progress.show(loop.progress);
|
|
2353
|
+
if (loop.finished) {
|
|
2354
|
+
this.loops.delete(body.id);
|
|
2355
|
+
this.scopeBehavior.tryExit(body, scope);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
count(body, loop) {
|
|
2359
|
+
if (!this.dataSimulation.isEnabled()) return this.counter.count(loop);
|
|
2360
|
+
const engine = this.dataSimulation.getEngine();
|
|
2361
|
+
const variables = this.dataSimulation.getVariables(body);
|
|
2362
|
+
return this.counter.count(loop, (expression) => engine.evaluate(expression, variables));
|
|
2363
|
+
}
|
|
2364
|
+
record(activity, body, { mode }, count) {
|
|
2365
|
+
const instanceId = findProcessInstance(body).id;
|
|
2366
|
+
if (!this.dataSimulation.isEnabled() || !this.store.hasInstance(instanceId)) return;
|
|
2367
|
+
this.store.record({
|
|
2368
|
+
kind: "multi-instance",
|
|
2369
|
+
instanceId,
|
|
2370
|
+
elementId: activity.id,
|
|
2371
|
+
elementName: elementName(activity),
|
|
2372
|
+
mode,
|
|
2373
|
+
count
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
showProgress(activity, progress) {
|
|
2377
|
+
this.overlays.remove({ element: activity, type: PROGRESS_OVERLAY });
|
|
2378
|
+
this.overlays.add(activity, PROGRESS_OVERLAY, {
|
|
2379
|
+
position: { top: PROGRESS_OFFSET_TOP, left: 0 },
|
|
2380
|
+
scale: { min: 1 },
|
|
2381
|
+
html: inShadow(progress.element)
|
|
2382
|
+
});
|
|
2383
|
+
return progress;
|
|
2384
|
+
}
|
|
2385
|
+
startInstance(activity, body, index) {
|
|
2386
|
+
this.simulator.enter({ element: activity, scope: body, initiator: body, loopIndex: index });
|
|
2387
|
+
}
|
|
2388
|
+
passThrough(activity, scope, done) {
|
|
2389
|
+
if (!this.animation) {
|
|
2390
|
+
done();
|
|
2391
|
+
return;
|
|
2392
|
+
}
|
|
2393
|
+
const entry = this.entryPoint(activity);
|
|
2394
|
+
const exit = { x: entry.x + (activity.width ?? 0), y: entry.y };
|
|
2395
|
+
this.animation.animate({ waypoints: [entry, exit] }, scope, done);
|
|
2396
|
+
}
|
|
2397
|
+
stagger(activity, scope, steps, done) {
|
|
2398
|
+
if (!this.animation || !steps) {
|
|
2399
|
+
done();
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
const entry = this.entryPoint(activity);
|
|
2403
|
+
const pause = { waypoints: [entry, { x: entry.x + STAGGER_STEP_LENGTH, y: entry.y }] };
|
|
2404
|
+
const waiting = this.animation.createAnimation(pause, scope, () => this.stagger(activity, scope, steps - 1, done));
|
|
2405
|
+
if (waiting) waiting.hide();
|
|
2406
|
+
else done();
|
|
2407
|
+
}
|
|
2408
|
+
entryPoint({ x = 0, y = 0, height = 0 }) {
|
|
2409
|
+
return { x, y: y + height / 2 };
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
MultiInstanceActivities.$inject = [
|
|
2413
|
+
"dataSimulation",
|
|
2414
|
+
"dataSimulationStore",
|
|
2415
|
+
"simulator",
|
|
2416
|
+
"scopeBehavior",
|
|
2417
|
+
"overlays",
|
|
2418
|
+
"eventBus",
|
|
2419
|
+
"injector"
|
|
2420
|
+
];
|
|
2421
|
+
|
|
2067
2422
|
class PathResolver {
|
|
2068
2423
|
constructor() {
|
|
2069
2424
|
this.router = new GatewayRouter();
|
|
@@ -2092,11 +2447,15 @@ class PathResolver {
|
|
|
2092
2447
|
};
|
|
2093
2448
|
}
|
|
2094
2449
|
leave(node, evaluateCondition, decisions) {
|
|
2095
|
-
if (!
|
|
2096
|
-
const decision = this.router.route(node.
|
|
2450
|
+
if (!this.routesByData(node)) return node.outgoing;
|
|
2451
|
+
const decision = node.refusalReason ? this.router.refuse(node.outgoing, node.refusalReason) : this.router.route(node.routingKind, node.outgoing, evaluateCondition);
|
|
2097
2452
|
decisions[node.id] = decision;
|
|
2098
2453
|
return node.outgoing.filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
2099
2454
|
}
|
|
2455
|
+
routesByData(node) {
|
|
2456
|
+
if (node.routingKind === "activity") return node.outgoing.length > 0;
|
|
2457
|
+
return node.routingKind !== void 0 && node.outgoing.length > 1;
|
|
2458
|
+
}
|
|
2100
2459
|
sumMeasures(nodes) {
|
|
2101
2460
|
const totals = {};
|
|
2102
2461
|
for (const node of nodes) {
|
|
@@ -2109,26 +2468,54 @@ class PathResolver {
|
|
|
2109
2468
|
const NICE_STEPS = [1, 2, 5, 10];
|
|
2110
2469
|
const RANGE_STEPS = 100;
|
|
2111
2470
|
const NUMBER_LITERAL = /(?<![\w.])\d+(?:\.\d+)?/g;
|
|
2471
|
+
const COMPARISON = String.raw`(?:<=|>=|==|!=|<|>|=|\b(?:lt|gt|le|ge|eq|ne)\b)`;
|
|
2472
|
+
const EQUALITY = String.raw`(?:==|!=|=|\b(?:eq|ne)\b)`;
|
|
2473
|
+
const BOOLEAN_LEFT = String.raw`(?:^|(?<![\w$.])\(|\bnot\s*\(|!|&&|\|\||\b(?:and|or|not)\b)`;
|
|
2474
|
+
const BOOLEAN_RIGHT = String.raw`(?=$|\)|&&|\|\||\b(?:and|or)\b)`;
|
|
2112
2475
|
class PathVariableDeriver {
|
|
2113
|
-
derive(conditions, values) {
|
|
2476
|
+
derive(conditions, values, rangeOverrides = {}) {
|
|
2114
2477
|
const names = [...new Set(conditions.flatMap((condition) => condition.variableNames))];
|
|
2115
2478
|
return names.map((name) => {
|
|
2116
2479
|
const conditionsReadingName = conditions.filter((condition) => condition.variableNames.includes(name));
|
|
2117
|
-
return this.variableFor(name, values[name], conditionsReadingName);
|
|
2480
|
+
return this.variableFor(name, values[name], conditionsReadingName, rangeOverrides[name] ?? {});
|
|
2118
2481
|
});
|
|
2119
2482
|
}
|
|
2120
|
-
variableFor(name, value, conditionsReadingName) {
|
|
2121
|
-
|
|
2122
|
-
if (
|
|
2483
|
+
variableFor(name, value, conditionsReadingName, rangeOverride) {
|
|
2484
|
+
const type = value === void 0 ? this.typeFromConditions(name, conditionsReadingName) : typeof value;
|
|
2485
|
+
if (type === "boolean") return { name, type: "boolean" };
|
|
2486
|
+
if (type === "number") {
|
|
2123
2487
|
const comparedNumbers = conditionsReadingName.flatMap((condition) => this.numberLiterals(condition.expression));
|
|
2124
|
-
return { name, type: "number", range: this.rangeAround(value, comparedNumbers) };
|
|
2488
|
+
return { name, type: "number", range: this.rangeAround(Number(value ?? 0), comparedNumbers, rangeOverride) };
|
|
2125
2489
|
}
|
|
2126
2490
|
if (value === void 0 || typeof value === "string") return { name, type: "text" };
|
|
2127
2491
|
return { name, type: "json" };
|
|
2128
2492
|
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2493
|
+
// Without a value the conditions tell the type: compared with a number, or used as a condition of its own.
|
|
2494
|
+
typeFromConditions(name, conditions) {
|
|
2495
|
+
const variable = String.raw`(?<![\w.$])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\w.(])`;
|
|
2496
|
+
const comparedWithNumber = new RegExp(
|
|
2497
|
+
String.raw`${variable}\s*${COMPARISON}\s*-?\d|\d\s*${COMPARISON}\s*${variable}`
|
|
2498
|
+
);
|
|
2499
|
+
const usedAsBoolean = new RegExp(
|
|
2500
|
+
String.raw`${BOOLEAN_LEFT}\s*${variable}\s*${BOOLEAN_RIGHT}|${variable}\s*${EQUALITY}\s*(?:true|false)\b|\b(?:true|false)\s*${EQUALITY}\s*${variable}`
|
|
2501
|
+
);
|
|
2502
|
+
const bodies = conditions.map((condition) => this.body(condition.expression));
|
|
2503
|
+
if (bodies.some((body) => comparedWithNumber.test(body))) return "number";
|
|
2504
|
+
if (bodies.some((body) => usedAsBoolean.test(body))) return "boolean";
|
|
2505
|
+
return void 0;
|
|
2506
|
+
}
|
|
2507
|
+
// The expression without its FEEL `=` or its JUEL `${…}`.
|
|
2508
|
+
body(expression) {
|
|
2509
|
+
const trimmed = expression.trim();
|
|
2510
|
+
const juel = /^\$\{([\s\S]*)\}$/.exec(trimmed);
|
|
2511
|
+
if (juel) return juel[1].trim();
|
|
2512
|
+
return trimmed.replace(/^=/, "").trim();
|
|
2513
|
+
}
|
|
2514
|
+
// The value itself is not doubled: a slider dragged to the end then keeps its range when derived again.
|
|
2515
|
+
rangeAround(value, comparedNumbers, override) {
|
|
2516
|
+
const min = override.min ?? 0;
|
|
2517
|
+
const max = override.max ?? this.niceCeiling(Math.max(Math.abs(value), 2 * Math.max(0, ...comparedNumbers)));
|
|
2518
|
+
return { min, max, step: override.step ?? (max - min) / RANGE_STEPS };
|
|
2132
2519
|
}
|
|
2133
2520
|
niceCeiling(value) {
|
|
2134
2521
|
if (value <= 0) return 1;
|
|
@@ -2162,7 +2549,7 @@ class PathGraphReader {
|
|
|
2162
2549
|
const entersSubProcess = is(node, "bpmn:SubProcess") && !node.businessObject.triggeredByEvent;
|
|
2163
2550
|
return {
|
|
2164
2551
|
id: node.id,
|
|
2165
|
-
...
|
|
2552
|
+
...this.routingOf(node),
|
|
2166
2553
|
outgoing: outgoingSequenceFlows(node).map((flow) => ({
|
|
2167
2554
|
...readOutgoingFlow(flow, this.engine),
|
|
2168
2555
|
targetId: flow.target.id
|
|
@@ -2171,6 +2558,18 @@ class PathGraphReader {
|
|
|
2171
2558
|
measures: Object.fromEntries(measureNames.map((name) => [name, this.readMeasure(node.businessObject, name)]))
|
|
2172
2559
|
};
|
|
2173
2560
|
}
|
|
2561
|
+
routingOf(node) {
|
|
2562
|
+
const gatewayKind = GATEWAY_KINDS[node.type];
|
|
2563
|
+
if (gatewayKind) return { routingKind: gatewayKind };
|
|
2564
|
+
switch (activityRouting(node, this.engine)) {
|
|
2565
|
+
case "by-conditions":
|
|
2566
|
+
return { routingKind: "activity" };
|
|
2567
|
+
case "refused":
|
|
2568
|
+
return { routingKind: "activity", refusalReason: this.engine.activityConditionRefusal };
|
|
2569
|
+
case "none":
|
|
2570
|
+
return {};
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2174
2573
|
isProcess(element) {
|
|
2175
2574
|
return element?.$type === "bpmn:Process";
|
|
2176
2575
|
}
|
|
@@ -2195,7 +2594,7 @@ class PathMarkers {
|
|
|
2195
2594
|
for (const id of path.taken) this.mark(id, TAKEN_MARKER);
|
|
2196
2595
|
for (const id of path.skipped) this.mark(id, SKIPPED_MARKER);
|
|
2197
2596
|
for (const [gatewayId, decision] of Object.entries(path.decisions)) {
|
|
2198
|
-
if (decision.stuckReason) this.mark(gatewayId, STUCK_MARKER);
|
|
2597
|
+
if (decision.stuckReason && !decision.missingVariables) this.mark(gatewayId, STUCK_MARKER);
|
|
2199
2598
|
}
|
|
2200
2599
|
}
|
|
2201
2600
|
clear() {
|
|
@@ -2247,12 +2646,12 @@ class PathSimulation {
|
|
|
2247
2646
|
}
|
|
2248
2647
|
simulate(variables, options = {}) {
|
|
2249
2648
|
const graph = this.pathGraphReader.read(options.measures ?? []);
|
|
2250
|
-
const path = this.pathResolver.resolve(graph, (expression) => this.
|
|
2649
|
+
const path = this.pathResolver.resolve(graph, (expression) => this.evaluate(expression, variables));
|
|
2251
2650
|
this.pathMarkers.show(path);
|
|
2252
2651
|
return path;
|
|
2253
2652
|
}
|
|
2254
|
-
deriveVariables(values) {
|
|
2255
|
-
return this.pathVariableDeriver.derive(this.evaluableConditions(), values);
|
|
2653
|
+
deriveVariables(values, options = {}) {
|
|
2654
|
+
return this.pathVariableDeriver.derive(this.evaluableConditions(), values, options.ranges);
|
|
2256
2655
|
}
|
|
2257
2656
|
variablesOf(scenario, fallbacks = []) {
|
|
2258
2657
|
return this.scenarioVariables.of(scenario, fallbacks);
|
|
@@ -2260,6 +2659,13 @@ class PathSimulation {
|
|
|
2260
2659
|
clear() {
|
|
2261
2660
|
this.pathMarkers.clear();
|
|
2262
2661
|
}
|
|
2662
|
+
// A failed condition names the variables it reads that are not set: the gateway then waits for data.
|
|
2663
|
+
evaluate(expression, variables) {
|
|
2664
|
+
const evaluation = this.engine.evaluate(expression, variables);
|
|
2665
|
+
if (evaluation.ok) return evaluation;
|
|
2666
|
+
const missingVariables = this.engine.readVariableNames(expression).filter((name) => variables[name] === void 0);
|
|
2667
|
+
return missingVariables.length ? { ...evaluation, missingVariables } : evaluation;
|
|
2668
|
+
}
|
|
2263
2669
|
evaluableConditions() {
|
|
2264
2670
|
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
2671
|
}
|
|
@@ -2278,6 +2684,8 @@ const DataSimulationModule = {
|
|
|
2278
2684
|
"dataSimulationPanel",
|
|
2279
2685
|
"dataSimulationToggle",
|
|
2280
2686
|
"dataGatewayBehaviors",
|
|
2687
|
+
"dataActivityBehavior",
|
|
2688
|
+
"multiInstanceBehaviors",
|
|
2281
2689
|
"dataGatewaySettings",
|
|
2282
2690
|
"dataContextPads"
|
|
2283
2691
|
],
|
|
@@ -2289,8 +2697,11 @@ const DataSimulationModule = {
|
|
|
2289
2697
|
dataGateways: ["type", DataGateways],
|
|
2290
2698
|
dataStartForm: ["type", DataStartForm],
|
|
2291
2699
|
dataGatewayBehaviors: ["type", DataGatewayBehaviors],
|
|
2700
|
+
dataActivityBehavior: ["type", DataActivityBehavior],
|
|
2292
2701
|
dataGatewaySettings: ["type", DataGatewaySettings],
|
|
2293
|
-
dataContextPads: ["type", DataContextPads]
|
|
2702
|
+
dataContextPads: ["type", DataContextPads],
|
|
2703
|
+
multiInstanceActivities: ["type", MultiInstanceActivities],
|
|
2704
|
+
multiInstanceBehaviors: ["type", MultiInstanceBehaviors]
|
|
2294
2705
|
};
|
|
2295
2706
|
|
|
2296
2707
|
export { Camunda7Engine, DataSimulationModule, DataSimulationStore, EngineRegistry, GatewayRouter, PathSimulationModule, ScenarioError, ScenarioParser, SimpleStartFormRenderer, StartFieldCodec, ZeebeEngine, camunda7Engine, DataSimulationModule as default, zeebeEngine };
|