@emaarco/bpmn-js-data-simulation 0.5.0 → 0.6.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 +1 -0
- 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 +2 -2
- package/dist/domain/PathVariableDeriver.d.ts.map +1 -1
- package/dist/domain/model.d.ts +17 -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 +450 -75
- 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 +450 -75
- 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 +5 -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,7 +7,7 @@ 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) {
|
|
@@ -31,9 +31,17 @@ class GatewayRouter {
|
|
|
31
31
|
}
|
|
32
32
|
return this.stuck(evaluations, defaultFlow, "No condition is true and there is no default flow");
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
refuse(outgoing, reason) {
|
|
35
|
+
return {
|
|
36
|
+
flows: outgoing.map((flow) => ({ flow, outcome: "skipped" })),
|
|
37
|
+
takenFlowIds: [],
|
|
38
|
+
stuckReason: reason,
|
|
39
|
+
refusedByEngine: true
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
evaluateFlow(kind, flow, evaluateCondition) {
|
|
35
43
|
if (flow.expression === void 0) {
|
|
36
|
-
return { flow, outcome: "error", reason: "Missing condition" };
|
|
44
|
+
return kind === "activity" ? { flow, outcome: "taken", reason: "No condition" } : { flow, outcome: "error", reason: "Missing condition" };
|
|
37
45
|
}
|
|
38
46
|
const evaluation = evaluateCondition(flow.expression);
|
|
39
47
|
if (!evaluation.ok) {
|
|
@@ -196,6 +204,16 @@ function readConditionExpression(sequenceFlow) {
|
|
|
196
204
|
language: typeof condition.language === "string" ? condition.language : void 0
|
|
197
205
|
};
|
|
198
206
|
}
|
|
207
|
+
function readMultiInstanceLoop(element) {
|
|
208
|
+
const characteristics = element.loopCharacteristics;
|
|
209
|
+
if (characteristics?.$type !== "bpmn:MultiInstanceLoopCharacteristics") return void 0;
|
|
210
|
+
const cardinality = characteristics.loopCardinality?.body;
|
|
211
|
+
return {
|
|
212
|
+
characteristics,
|
|
213
|
+
mode: characteristics.isSequential ? "sequential" : "parallel",
|
|
214
|
+
cardinality: typeof cardinality === "string" ? cardinality.trim() || void 0 : void 0
|
|
215
|
+
};
|
|
216
|
+
}
|
|
199
217
|
|
|
200
218
|
class JuelError extends Error {
|
|
201
219
|
constructor() {
|
|
@@ -612,6 +630,15 @@ class Camunda7Engine {
|
|
|
612
630
|
const isJuel = !condition?.language || condition.language.toLowerCase() === "juel";
|
|
613
631
|
return isJuel ? condition?.body?.trim() || void 0 : void 0;
|
|
614
632
|
}
|
|
633
|
+
readLoop(activity) {
|
|
634
|
+
const loop = readMultiInstanceLoop(activity);
|
|
635
|
+
if (!loop) return void 0;
|
|
636
|
+
return {
|
|
637
|
+
mode: loop.mode,
|
|
638
|
+
cardinality: loop.cardinality,
|
|
639
|
+
collection: this.collectionExpression(loop.characteristics)
|
|
640
|
+
};
|
|
641
|
+
}
|
|
615
642
|
canEvaluate(expression) {
|
|
616
643
|
try {
|
|
617
644
|
JuelTemplate.parse(expression);
|
|
@@ -637,6 +664,12 @@ class Camunda7Engine {
|
|
|
637
664
|
return [];
|
|
638
665
|
}
|
|
639
666
|
}
|
|
667
|
+
collectionExpression(characteristics) {
|
|
668
|
+
const collection = typeof characteristics.collection === "string" ? characteristics.collection.trim() : "";
|
|
669
|
+
if (!collection) return void 0;
|
|
670
|
+
const isVariableName = !/[$#]\{/.test(collection);
|
|
671
|
+
return isVariableName ? `\${${collection}}` : collection;
|
|
672
|
+
}
|
|
640
673
|
readMappings(element, property) {
|
|
641
674
|
const inputOutput = findExtension(element, "camunda:InputOutput");
|
|
642
675
|
return listProperty(inputOutput, property).filter((parameter) => typeof parameter.name === "string" && parameter.name && !parameter.definition).map((parameter) => ({
|
|
@@ -653,6 +686,7 @@ class ZeebeEngine {
|
|
|
653
686
|
this.label = "Zeebe";
|
|
654
687
|
this.expressionLanguage = "FEEL";
|
|
655
688
|
this.taskResultPropagation = "without-output-mappings";
|
|
689
|
+
this.activityConditionRefusal = "Zeebe rejects this model on deploy: conditional sequence flows are only supported at exclusive or inclusive gateways";
|
|
656
690
|
}
|
|
657
691
|
writeVariable(variables, target, value) {
|
|
658
692
|
return setVariable(variables, target, value);
|
|
@@ -666,6 +700,13 @@ class ZeebeEngine {
|
|
|
666
700
|
readCondition(sequenceFlow) {
|
|
667
701
|
return readConditionExpression(sequenceFlow)?.body?.trim() || void 0;
|
|
668
702
|
}
|
|
703
|
+
readLoop(activity) {
|
|
704
|
+
const loop = readMultiInstanceLoop(activity);
|
|
705
|
+
if (!loop) return void 0;
|
|
706
|
+
const inputCollection = findExtension(loop.characteristics, "zeebe:LoopCharacteristics")?.inputCollection;
|
|
707
|
+
const collection = typeof inputCollection === "string" ? inputCollection.trim() || void 0 : void 0;
|
|
708
|
+
return { mode: loop.mode, cardinality: loop.cardinality, collection };
|
|
709
|
+
}
|
|
669
710
|
canEvaluate(expression) {
|
|
670
711
|
return this.isFeel(expression) && this.parsesAsFeel(expression);
|
|
671
712
|
}
|
|
@@ -813,6 +854,9 @@ class DataSimulationStore {
|
|
|
813
854
|
addWaiting(instanceId, waiting) {
|
|
814
855
|
this.updateInstance(instanceId, (instance) => ({ ...instance, waiting: [...instance.waiting, waiting] }));
|
|
815
856
|
}
|
|
857
|
+
isWaitingScope(scopeId) {
|
|
858
|
+
return [...this.instances.values()].some((instance) => instance.waiting.some((waiting) => waiting.scopeId === scopeId));
|
|
859
|
+
}
|
|
816
860
|
removeWaiting(scopeId) {
|
|
817
861
|
const instance = [...this.instances.values()].find(
|
|
818
862
|
(candidate) => candidate.waiting.some((waiting) => waiting.scopeId === scopeId)
|
|
@@ -960,6 +1004,26 @@ class SimpleStartFormRenderer {
|
|
|
960
1004
|
}
|
|
961
1005
|
}
|
|
962
1006
|
|
|
1007
|
+
class DataActivityBehavior {
|
|
1008
|
+
constructor(behavior, dataGateways) {
|
|
1009
|
+
this.dataGateways = dataGateways;
|
|
1010
|
+
const exitThroughAllFlows = behavior.exit.bind(behavior);
|
|
1011
|
+
behavior.exit = (context) => {
|
|
1012
|
+
const { element, scope } = context;
|
|
1013
|
+
const completing = scope.active && !scope.failed;
|
|
1014
|
+
if (!completing || !this.dataGateways.routesActivityByData(element)) {
|
|
1015
|
+
exitThroughAllFlows(context);
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
this.dataGateways.exitActivity(
|
|
1019
|
+
context,
|
|
1020
|
+
(takenFlows) => exitThroughAllFlows({ ...context, element: { ...element, outgoing: takenFlows } })
|
|
1021
|
+
);
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
DataActivityBehavior.$inject = ["activityBehavior", "dataGateways"];
|
|
1026
|
+
|
|
963
1027
|
const FLOW_CHOICE_TYPES = ["bpmn:ExclusiveGateway", "bpmn:InclusiveGateway"];
|
|
964
1028
|
const TRIGGER_TYPE = "bpmn:Event";
|
|
965
1029
|
class DataContextPads {
|
|
@@ -1029,6 +1093,9 @@ function findProcessInstance(scope) {
|
|
|
1029
1093
|
while (current.parent) current = current.parent;
|
|
1030
1094
|
return current;
|
|
1031
1095
|
}
|
|
1096
|
+
function isLoopInstance(scope) {
|
|
1097
|
+
return scope.parent?.element === scope.element;
|
|
1098
|
+
}
|
|
1032
1099
|
function elementName(element) {
|
|
1033
1100
|
const name = element.businessObject.name;
|
|
1034
1101
|
return typeof name === "string" && name.trim() ? name.trim() : element.id;
|
|
@@ -1043,10 +1110,19 @@ function flowNodesOf(elementRegistry) {
|
|
|
1043
1110
|
function isGateway(element) {
|
|
1044
1111
|
return element.type === "bpmn:ExclusiveGateway" || element.type === "bpmn:InclusiveGateway";
|
|
1045
1112
|
}
|
|
1046
|
-
function
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1113
|
+
function decidingElementOf(element) {
|
|
1114
|
+
return element.type === "bpmn:SequenceFlow" ? element.source?.id : element.id;
|
|
1115
|
+
}
|
|
1116
|
+
function activityRouting(activity, engine) {
|
|
1117
|
+
if (!is(activity, "bpmn:Activity")) return "none";
|
|
1118
|
+
const conditional = outgoingSequenceFlows(activity).filter((flow) => readConditionExpression(flow.businessObject));
|
|
1119
|
+
if (engine.activityConditionRefusal) return conditional.length ? "refused" : "none";
|
|
1120
|
+
if (!conditional.length && !activity.businessObject.default) return "none";
|
|
1121
|
+
const evaluable = conditional.every((flow) => {
|
|
1122
|
+
const expression = engine.readCondition(flow.businessObject);
|
|
1123
|
+
return expression !== void 0 && engine.canEvaluate(expression);
|
|
1124
|
+
});
|
|
1125
|
+
return evaluable ? "by-conditions" : "none";
|
|
1050
1126
|
}
|
|
1051
1127
|
function outgoingSequenceFlows(element) {
|
|
1052
1128
|
return (element.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
@@ -1061,6 +1137,33 @@ function readOutgoingFlow(sequenceFlow, engine) {
|
|
|
1061
1137
|
};
|
|
1062
1138
|
}
|
|
1063
1139
|
|
|
1140
|
+
class MultiInstanceBehaviors {
|
|
1141
|
+
constructor(activity, subProcess, multiInstance) {
|
|
1142
|
+
this.multiInstance = multiInstance;
|
|
1143
|
+
this.runInstances(activity);
|
|
1144
|
+
this.runInstances(subProcess);
|
|
1145
|
+
}
|
|
1146
|
+
runInstances(behavior) {
|
|
1147
|
+
const enterOnce = behavior.enter.bind(behavior);
|
|
1148
|
+
const exitOnce = behavior.exit.bind(behavior);
|
|
1149
|
+
behavior.enter = (context) => {
|
|
1150
|
+
const loop = this.multiInstance.loopOf(context.element);
|
|
1151
|
+
if (!loop) enterOnce(context);
|
|
1152
|
+
else if (isLoopInstance(context.scope))
|
|
1153
|
+
this.multiInstance.enterInstance(context, enterOnce);
|
|
1154
|
+
else this.multiInstance.enterBody(context, loop);
|
|
1155
|
+
};
|
|
1156
|
+
behavior.exit = (context) => {
|
|
1157
|
+
if (this.multiInstance.loopOf(context.element) && isLoopInstance(context.scope)) {
|
|
1158
|
+
this.multiInstance.exitInstance(context);
|
|
1159
|
+
} else {
|
|
1160
|
+
exitOnce(context);
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
MultiInstanceBehaviors.$inject = ["activityBehavior", "subProcessBehavior", "multiInstanceActivities"];
|
|
1166
|
+
|
|
1064
1167
|
class DataGateways {
|
|
1065
1168
|
constructor(dataSimulation, store, simulator) {
|
|
1066
1169
|
this.dataSimulation = dataSimulation;
|
|
@@ -1073,6 +1176,9 @@ class DataGateways {
|
|
|
1073
1176
|
const outgoing = this.outgoingFlows(gateway);
|
|
1074
1177
|
return this.dataSimulation.isEnabled() && outgoing.length > 1 && outgoing.filter((flow) => !flow.isDefault).every((flow) => flow.expression !== void 0 && engine.canEvaluate(flow.expression));
|
|
1075
1178
|
}
|
|
1179
|
+
routesActivityByData(activity) {
|
|
1180
|
+
return this.dataSimulation.isEnabled() && activityRouting(activity, this.dataSimulation.getEngine()) !== "none";
|
|
1181
|
+
}
|
|
1076
1182
|
exit(context, kind) {
|
|
1077
1183
|
const { element: gateway, scope } = context;
|
|
1078
1184
|
const decision = this.decide(gateway, scope, kind);
|
|
@@ -1080,11 +1186,19 @@ class DataGateways {
|
|
|
1080
1186
|
this.waitForRetry(gateway, scope);
|
|
1081
1187
|
return;
|
|
1082
1188
|
}
|
|
1083
|
-
for (const
|
|
1084
|
-
const flow = outgoingSequenceFlows(gateway).find((candidate) => candidate.id === flowId);
|
|
1189
|
+
for (const flow of this.takenFlows(gateway, decision)) {
|
|
1085
1190
|
this.simulator.enter({ element: flow, scope: scope.parent });
|
|
1086
1191
|
}
|
|
1087
1192
|
}
|
|
1193
|
+
exitActivity(context, leaveThrough) {
|
|
1194
|
+
const { element: activity, scope } = context;
|
|
1195
|
+
const decision = this.decide(activity, scope, "activity");
|
|
1196
|
+
if (decision.stuckReason) {
|
|
1197
|
+
this.waitForRetry(activity, scope);
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
leaveThrough(this.takenFlows(activity, decision));
|
|
1201
|
+
}
|
|
1088
1202
|
recordClickDecision(context, kind) {
|
|
1089
1203
|
if (!this.dataSimulation.isEnabled()) return;
|
|
1090
1204
|
const { element: gateway, scope } = context;
|
|
@@ -1101,45 +1215,48 @@ class DataGateways {
|
|
|
1101
1215
|
};
|
|
1102
1216
|
this.record(gateway, scope, kind, "click", decision, []);
|
|
1103
1217
|
}
|
|
1104
|
-
decide(
|
|
1218
|
+
decide(element, scope, kind) {
|
|
1105
1219
|
const engine = this.dataSimulation.getEngine();
|
|
1106
1220
|
const variables = this.dataSimulation.getVariables(scope);
|
|
1107
|
-
const outgoing = this.outgoingFlows(
|
|
1108
|
-
const
|
|
1221
|
+
const outgoing = this.outgoingFlows(element);
|
|
1222
|
+
const refusal = kind === "activity" ? engine.activityConditionRefusal : void 0;
|
|
1223
|
+
const decision = refusal ? this.router.refuse(outgoing, refusal) : this.router.route(kind, outgoing, (expression) => engine.evaluate(expression, variables));
|
|
1109
1224
|
const names = outgoing.flatMap((flow) => flow.expression ? engine.readVariableNames(flow.expression) : []);
|
|
1110
1225
|
const inputs = [...new Set(names)].map((name) => ({ name, value: structuredClone(variables[name]) }));
|
|
1111
|
-
this.record(
|
|
1226
|
+
this.record(element, scope, kind, "data", decision, inputs);
|
|
1112
1227
|
return decision;
|
|
1113
1228
|
}
|
|
1114
|
-
|
|
1229
|
+
takenFlows(element, decision) {
|
|
1230
|
+
return outgoingSequenceFlows(element).filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
1231
|
+
}
|
|
1232
|
+
record(element, scope, gatewayKind, chosenBy, decision, inputs) {
|
|
1115
1233
|
this.store.record({
|
|
1116
1234
|
kind: "decision",
|
|
1117
1235
|
instanceId: findProcessInstance(scope).id,
|
|
1118
|
-
elementId:
|
|
1119
|
-
elementName: elementName(
|
|
1236
|
+
elementId: element.id,
|
|
1237
|
+
elementName: elementName(element),
|
|
1120
1238
|
gatewayKind,
|
|
1121
1239
|
chosenBy,
|
|
1122
1240
|
decision,
|
|
1123
1241
|
inputs
|
|
1124
1242
|
});
|
|
1125
1243
|
}
|
|
1126
|
-
waitForRetry(
|
|
1127
|
-
const waitingScope = this.simulator.createScope({ element
|
|
1244
|
+
waitForRetry(element, scope) {
|
|
1245
|
+
const waitingScope = this.simulator.createScope({ element, parent: scope.parent, initiator: scope }).start();
|
|
1128
1246
|
this.store.addWaiting(findProcessInstance(scope).id, {
|
|
1129
1247
|
scopeId: waitingScope.id,
|
|
1130
|
-
gatewayId:
|
|
1131
|
-
gatewayName: elementName(
|
|
1248
|
+
gatewayId: element.id,
|
|
1249
|
+
gatewayName: elementName(element)
|
|
1132
1250
|
});
|
|
1133
|
-
const retry = { element
|
|
1251
|
+
const retry = { element, type: "continue", interrupting: false, boundary: false };
|
|
1134
1252
|
const subscription = this.simulator.subscribe(waitingScope, retry, (initiator) => {
|
|
1135
1253
|
subscription.remove();
|
|
1136
|
-
this.
|
|
1137
|
-
this.simulator.exit({ element: gateway, scope: waitingScope, initiator });
|
|
1254
|
+
this.simulator.exit({ element, scope: waitingScope, initiator });
|
|
1138
1255
|
});
|
|
1139
1256
|
}
|
|
1140
|
-
outgoingFlows(
|
|
1257
|
+
outgoingFlows(element) {
|
|
1141
1258
|
const engine = this.dataSimulation.getEngine();
|
|
1142
|
-
return outgoingSequenceFlows(
|
|
1259
|
+
return outgoingSequenceFlows(element).map((flow) => readOutgoingFlow(flow, engine));
|
|
1143
1260
|
}
|
|
1144
1261
|
}
|
|
1145
1262
|
DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
|
|
@@ -1192,6 +1309,8 @@ const RESET_SIMULATION_EVENT = "tokenSimulation.resetSimulation";
|
|
|
1192
1309
|
const SCOPE_CREATE_EVENT = "tokenSimulation.simulator.createScope";
|
|
1193
1310
|
const SCOPE_DESTROYED_EVENT = "tokenSimulation.simulator.destroyScope";
|
|
1194
1311
|
const TRACE_EVENT = "tokenSimulation.simulator.trace";
|
|
1312
|
+
const ELEMENT_CHANGED_EVENT = "tokenSimulation.simulator.elementChanged";
|
|
1313
|
+
const TOKEN_COUNT_OVERLAY = "bts-token-count";
|
|
1195
1314
|
const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
|
|
1196
1315
|
|
|
1197
1316
|
class DataSimulation {
|
|
@@ -1261,7 +1380,8 @@ class DataSimulation {
|
|
|
1261
1380
|
this.store.startInstance(scope.id, elementName(scope.element));
|
|
1262
1381
|
}
|
|
1263
1382
|
applyMappings(element, scope) {
|
|
1264
|
-
|
|
1383
|
+
const isRetry = this.store.isWaitingScope(scope.id);
|
|
1384
|
+
if (!is(element, "bpmn:FlowNode") || isLoopInstance(scope) || scope.failed || scope.canceled || isRetry) return;
|
|
1265
1385
|
const instanceId = findProcessInstance(scope).id;
|
|
1266
1386
|
if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
|
|
1267
1387
|
}
|
|
@@ -1319,6 +1439,11 @@ class OutcomeBadge {
|
|
|
1319
1439
|
}
|
|
1320
1440
|
}
|
|
1321
1441
|
|
|
1442
|
+
const KIND_LABELS = {
|
|
1443
|
+
exclusive: "exclusive",
|
|
1444
|
+
inclusive: "inclusive",
|
|
1445
|
+
activity: "conditional flows"
|
|
1446
|
+
};
|
|
1322
1447
|
class DecisionCard {
|
|
1323
1448
|
constructor({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
|
|
1324
1449
|
this.element = h(
|
|
@@ -1328,14 +1453,14 @@ class DecisionCard {
|
|
|
1328
1453
|
"div",
|
|
1329
1454
|
{ className: "bds-decision-title" },
|
|
1330
1455
|
h("span", {}, elementName),
|
|
1331
|
-
h(
|
|
1456
|
+
h(
|
|
1457
|
+
"span",
|
|
1458
|
+
{ className: "bds-tag" },
|
|
1459
|
+
chosenBy === "click" ? `${KIND_LABELS[gatewayKind]} \xB7 by click` : KIND_LABELS[gatewayKind]
|
|
1460
|
+
),
|
|
1332
1461
|
onClose ? this.closeButton(onClose) : null
|
|
1333
1462
|
),
|
|
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,
|
|
1463
|
+
decision.stuckReason ? h("p", { className: "bds-error" }, this.stuckMessage(decision, gatewayKind)) : null,
|
|
1339
1464
|
h(
|
|
1340
1465
|
"ul",
|
|
1341
1466
|
{ className: "bds-flows" },
|
|
@@ -1352,6 +1477,11 @@ class DecisionCard {
|
|
|
1352
1477
|
inputs.length ? this.inputList(inputs) : null
|
|
1353
1478
|
);
|
|
1354
1479
|
}
|
|
1480
|
+
stuckMessage({ stuckReason, refusedByEngine }, kind) {
|
|
1481
|
+
if (refusedByEngine) return `${stuckReason}.`;
|
|
1482
|
+
const element = kind === "activity" ? "activity" : "gateway";
|
|
1483
|
+
return `${stuckReason}. Change the variables in Process Data, then press \u25B6 on the ${element}.`;
|
|
1484
|
+
}
|
|
1355
1485
|
closeButton(onClose) {
|
|
1356
1486
|
const button = h(
|
|
1357
1487
|
"button",
|
|
@@ -1410,7 +1540,7 @@ function isInView(anchor, bounds) {
|
|
|
1410
1540
|
return anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height;
|
|
1411
1541
|
}
|
|
1412
1542
|
|
|
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";
|
|
1543
|
+
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
1544
|
|
|
1415
1545
|
let sharedSheet;
|
|
1416
1546
|
function inShadow(...children) {
|
|
@@ -1444,8 +1574,8 @@ class DataSimulationOverlays {
|
|
|
1444
1574
|
this.overlays = overlays;
|
|
1445
1575
|
this.elementRegistry = elementRegistry;
|
|
1446
1576
|
this.canvas = canvas;
|
|
1447
|
-
this.
|
|
1448
|
-
this.
|
|
1577
|
+
this.pinnedElementIds = /* @__PURE__ */ new Set();
|
|
1578
|
+
this.markedElements = [];
|
|
1449
1579
|
this.popovers = [];
|
|
1450
1580
|
this.popoverLayer = inShadow();
|
|
1451
1581
|
this.renderedState = "";
|
|
@@ -1455,12 +1585,12 @@ class DataSimulationOverlays {
|
|
|
1455
1585
|
this.render();
|
|
1456
1586
|
});
|
|
1457
1587
|
eventBus.on("element.hover", ({ element }) => {
|
|
1458
|
-
this.
|
|
1588
|
+
this.hoveredElementId = decidingElementOf(element);
|
|
1459
1589
|
this.render();
|
|
1460
1590
|
});
|
|
1461
1591
|
eventBus.on("element.click", ({ element }) => {
|
|
1462
|
-
if (!isGateway(element)) return;
|
|
1463
|
-
if (!this.
|
|
1592
|
+
if (!isGateway(element) && !this.hasDecision(element)) return;
|
|
1593
|
+
if (!this.pinnedElementIds.delete(element.id)) this.pinnedElementIds.add(element.id);
|
|
1464
1594
|
this.render();
|
|
1465
1595
|
});
|
|
1466
1596
|
eventBus.on(["canvas.viewbox.changed", "canvas.resized"], () => this.placePopovers());
|
|
@@ -1473,33 +1603,36 @@ class DataSimulationOverlays {
|
|
|
1473
1603
|
render() {
|
|
1474
1604
|
const { decisions, shown } = new GatewayDecisionView(this.snapshot);
|
|
1475
1605
|
const cards = shown.filter(
|
|
1476
|
-
({ elementId }) => elementId === this.
|
|
1606
|
+
({ elementId }) => elementId === this.hoveredElementId || this.pinnedElementIds.has(elementId)
|
|
1477
1607
|
);
|
|
1478
1608
|
const state = JSON.stringify([
|
|
1479
1609
|
decisions.map((entry) => entry.id),
|
|
1480
1610
|
shown.map((entry) => entry.id),
|
|
1481
|
-
cards.map((entry) => [entry.id, this.
|
|
1611
|
+
cards.map((entry) => [entry.id, this.pinnedElementIds.has(entry.elementId)])
|
|
1482
1612
|
]);
|
|
1483
1613
|
if (state === this.renderedState) return;
|
|
1484
1614
|
this.renderedState = state;
|
|
1485
1615
|
this.overlays.remove({ type: OUTCOME_OVERLAY });
|
|
1486
|
-
this.
|
|
1616
|
+
this.unmarkElements();
|
|
1487
1617
|
for (const entry of decisions) this.showOutcomes(entry.decision);
|
|
1488
|
-
for (const entry of shown) this.
|
|
1618
|
+
for (const entry of shown) this.markElement(entry);
|
|
1489
1619
|
this.showCards(cards);
|
|
1490
1620
|
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
this.
|
|
1621
|
+
hasDecision(element) {
|
|
1622
|
+
return new GatewayDecisionView(this.snapshot).shown.some(({ elementId }) => elementId === element.id);
|
|
1623
|
+
}
|
|
1624
|
+
markElement({ elementId, decision }) {
|
|
1625
|
+
const element = this.elementRegistry.get(elementId);
|
|
1626
|
+
if (!element) return;
|
|
1627
|
+
this.canvas.addMarker(element, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1628
|
+
this.markedElements.push(element);
|
|
1496
1629
|
}
|
|
1497
|
-
|
|
1498
|
-
for (const
|
|
1499
|
-
this.canvas.removeMarker(
|
|
1500
|
-
this.canvas.removeMarker(
|
|
1630
|
+
unmarkElements() {
|
|
1631
|
+
for (const element of this.markedElements) {
|
|
1632
|
+
this.canvas.removeMarker(element, DECIDED_MARKER);
|
|
1633
|
+
this.canvas.removeMarker(element, STUCK_MARKER$1);
|
|
1501
1634
|
}
|
|
1502
|
-
this.
|
|
1635
|
+
this.markedElements = [];
|
|
1503
1636
|
}
|
|
1504
1637
|
showOutcomes(decision) {
|
|
1505
1638
|
for (const { flow, outcome, reason } of decision.flows) {
|
|
@@ -1516,16 +1649,16 @@ class DataSimulationOverlays {
|
|
|
1516
1649
|
}
|
|
1517
1650
|
showCards(entries) {
|
|
1518
1651
|
this.popovers = entries.flatMap((entry) => {
|
|
1519
|
-
const
|
|
1520
|
-
if (!
|
|
1652
|
+
const element = this.elementRegistry.get(entry.elementId);
|
|
1653
|
+
if (!element) return [];
|
|
1521
1654
|
const close = () => {
|
|
1522
|
-
this.
|
|
1655
|
+
this.pinnedElementIds.delete(entry.elementId);
|
|
1523
1656
|
this.render();
|
|
1524
1657
|
};
|
|
1525
|
-
const card = new DecisionCard(entry, this.
|
|
1658
|
+
const card = new DecisionCard(entry, this.pinnedElementIds.has(entry.elementId) ? close : void 0).element;
|
|
1526
1659
|
card.classList.add("bds-popover");
|
|
1527
1660
|
card.dataset.elementId = entry.elementId;
|
|
1528
|
-
return [{
|
|
1661
|
+
return [{ element, card }];
|
|
1529
1662
|
});
|
|
1530
1663
|
this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
|
|
1531
1664
|
this.placePopovers();
|
|
@@ -1533,10 +1666,10 @@ class DataSimulationOverlays {
|
|
|
1533
1666
|
placePopovers() {
|
|
1534
1667
|
const container = this.canvas.getContainer();
|
|
1535
1668
|
const bounds = { width: container.clientWidth, height: container.clientHeight };
|
|
1536
|
-
for (const {
|
|
1669
|
+
for (const { element, card } of this.popovers) {
|
|
1537
1670
|
card.style.maxHeight = "";
|
|
1538
1671
|
const { left, top, maxHeight, hidden } = placePopover(
|
|
1539
|
-
this.canvas.getAbsoluteBBox(
|
|
1672
|
+
this.canvas.getAbsoluteBBox(element),
|
|
1540
1673
|
{ width: card.offsetWidth, height: card.offsetHeight },
|
|
1541
1674
|
bounds
|
|
1542
1675
|
);
|
|
@@ -1698,11 +1831,13 @@ class VariablesPanel {
|
|
|
1698
1831
|
}
|
|
1699
1832
|
renderIssues({ log, selectedInstanceId }) {
|
|
1700
1833
|
const issues = log.filter(
|
|
1701
|
-
(entry) => entry.
|
|
1834
|
+
(entry) => entry.instanceId === selectedInstanceId && this.isIssue(entry)
|
|
1702
1835
|
);
|
|
1703
1836
|
this.issueSection.hidden = !issues.length;
|
|
1704
1837
|
this.issueList.replaceChildren(
|
|
1705
|
-
...issues.slice().reverse().map(
|
|
1838
|
+
...issues.slice().reverse().map(
|
|
1839
|
+
(issue) => issue.kind === "mapping-issue" ? this.renderMappingIssue(issue) : this.renderInstanceCountIssue(issue)
|
|
1840
|
+
)
|
|
1706
1841
|
);
|
|
1707
1842
|
}
|
|
1708
1843
|
describeStatus({ processName, status, waiting }) {
|
|
@@ -1722,6 +1857,17 @@ class VariablesPanel {
|
|
|
1722
1857
|
h("p", { className: "bds-error" }, `${target}: ${reason}`)
|
|
1723
1858
|
);
|
|
1724
1859
|
}
|
|
1860
|
+
isIssue(entry) {
|
|
1861
|
+
return entry.kind === "mapping-issue" || entry.kind === "multi-instance" && Boolean(entry.count.reason);
|
|
1862
|
+
}
|
|
1863
|
+
renderInstanceCountIssue({ elementName, count }) {
|
|
1864
|
+
return h(
|
|
1865
|
+
"li",
|
|
1866
|
+
{ className: "bds-log-entry bds-log-entry--issue" },
|
|
1867
|
+
h("div", { className: "bds-log-title" }, elementName, h("span", { className: "bds-tag" }, "instances")),
|
|
1868
|
+
h("p", { className: "bds-error" }, `Ran ${count.count} instances by default: ${count.reason}`)
|
|
1869
|
+
);
|
|
1870
|
+
}
|
|
1725
1871
|
parseVariables(text) {
|
|
1726
1872
|
try {
|
|
1727
1873
|
const value = JSON.parse(text || "{}");
|
|
@@ -1994,8 +2140,10 @@ class VariableUsageCollector {
|
|
|
1994
2140
|
}
|
|
1995
2141
|
if (!is(element, "bpmn:FlowNode")) return void 0;
|
|
1996
2142
|
const { inputs, outputs } = this.engine.readIoMappings(businessObject);
|
|
2143
|
+
const loop = this.engine.readLoop?.(businessObject);
|
|
2144
|
+
const readOnEnter = [loop?.cardinality, loop?.collection, ...inputs.map((mapping) => mapping.source)];
|
|
1997
2145
|
return this.usage(element, {
|
|
1998
|
-
inputReads:
|
|
2146
|
+
inputReads: readOnEnter.flatMap((expression) => expression ? this.engine.readVariableNames(expression) : []),
|
|
1999
2147
|
inputTargets: inputs.map((mapping) => mapping.target),
|
|
2000
2148
|
outputReads: outputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
|
|
2001
2149
|
outputTargets: outputs.map((mapping) => mapping.target)
|
|
@@ -2064,6 +2212,210 @@ class DataStartForm {
|
|
|
2064
2212
|
}
|
|
2065
2213
|
DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
|
|
2066
2214
|
|
|
2215
|
+
const DEFAULT_INSTANCE_COUNT = 3;
|
|
2216
|
+
class InstanceCounter {
|
|
2217
|
+
count({ cardinality, collection }, evaluate) {
|
|
2218
|
+
if (!evaluate) return { count: DEFAULT_INSTANCE_COUNT, source: "default" };
|
|
2219
|
+
if (cardinality) return this.fromCardinality(cardinality, evaluate(cardinality));
|
|
2220
|
+
if (collection) return this.fromCollection(collection, evaluate(collection));
|
|
2221
|
+
return { count: DEFAULT_INSTANCE_COUNT, source: "default" };
|
|
2222
|
+
}
|
|
2223
|
+
fromCardinality(expression, evaluation) {
|
|
2224
|
+
if (!evaluation.ok) return this.fallback(expression, evaluation.reason);
|
|
2225
|
+
const count = typeof evaluation.value === "string" ? Number(evaluation.value) : evaluation.value;
|
|
2226
|
+
if (typeof count !== "number" || !Number.isInteger(count) || count < 0) {
|
|
2227
|
+
return this.fallback(expression, `Loop cardinality ${JSON.stringify(evaluation.value)} is not a whole number`);
|
|
2228
|
+
}
|
|
2229
|
+
return { count, source: "cardinality", expression };
|
|
2230
|
+
}
|
|
2231
|
+
fromCollection(expression, evaluation) {
|
|
2232
|
+
if (!evaluation.ok) return this.fallback(expression, evaluation.reason);
|
|
2233
|
+
if (!Array.isArray(evaluation.value)) {
|
|
2234
|
+
return this.fallback(expression, `Collection ${JSON.stringify(evaluation.value)} is not a list`);
|
|
2235
|
+
}
|
|
2236
|
+
return { count: evaluation.value.length, source: "collection", expression };
|
|
2237
|
+
}
|
|
2238
|
+
fallback(expression, reason) {
|
|
2239
|
+
return { count: DEFAULT_INSTANCE_COUNT, source: "default", expression, reason };
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
class InstanceLoop {
|
|
2244
|
+
constructor(mode, count) {
|
|
2245
|
+
this.mode = mode;
|
|
2246
|
+
this.statuses = Array.from({ length: count }, () => "waiting");
|
|
2247
|
+
}
|
|
2248
|
+
get progress() {
|
|
2249
|
+
return this.statuses;
|
|
2250
|
+
}
|
|
2251
|
+
get finished() {
|
|
2252
|
+
return this.statuses.every((status) => status === "done");
|
|
2253
|
+
}
|
|
2254
|
+
start() {
|
|
2255
|
+
const first = this.mode === "parallel" ? this.statuses.map((_, index) => index) : [0];
|
|
2256
|
+
return first.filter((index) => index < this.statuses.length).map((index) => this.run(index));
|
|
2257
|
+
}
|
|
2258
|
+
complete(index) {
|
|
2259
|
+
this.statuses[index] = "done";
|
|
2260
|
+
const next = this.statuses.indexOf("waiting");
|
|
2261
|
+
return this.mode === "sequential" && next >= 0 ? this.run(next) : void 0;
|
|
2262
|
+
}
|
|
2263
|
+
run(index) {
|
|
2264
|
+
this.statuses[index] = "running";
|
|
2265
|
+
return index;
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
const MAX_DOTS = 12;
|
|
2270
|
+
class InstanceProgress {
|
|
2271
|
+
constructor(mode, count) {
|
|
2272
|
+
this.element = h("span", { className: "bds-loop" });
|
|
2273
|
+
this.description = this.describe(mode, count);
|
|
2274
|
+
}
|
|
2275
|
+
show(progress) {
|
|
2276
|
+
const done = progress.filter((status) => status === "done").length;
|
|
2277
|
+
const dots = progress.length <= MAX_DOTS ? progress.map(
|
|
2278
|
+
(status) => h("span", { className: `bds-loop-dot bds-loop-dot--${status}`, "data-status": status })
|
|
2279
|
+
) : [];
|
|
2280
|
+
this.element.title = this.description;
|
|
2281
|
+
this.element.replaceChildren(...dots, h("span", { className: "bds-loop-count" }, `${done}/${progress.length}`));
|
|
2282
|
+
}
|
|
2283
|
+
describe(mode, { count, source, expression, reason }) {
|
|
2284
|
+
if (!count) return `No instance: ${expression} is empty`;
|
|
2285
|
+
const instances = `${count} ${mode} instance${count === 1 ? "" : "s"}`;
|
|
2286
|
+
if (source === "collection") return `${instances}, one per item of ${expression}`;
|
|
2287
|
+
if (source === "cardinality") return `${instances}, loop cardinality ${expression}`;
|
|
2288
|
+
return reason ? `${instances} (default): ${reason}` : `${instances} (default without data)`;
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
const PROGRESS_OVERLAY = "bds-loop-progress";
|
|
2293
|
+
const PROGRESS_OFFSET_TOP = -26;
|
|
2294
|
+
const BELOW_TOKEN_COUNT = 250;
|
|
2295
|
+
const STAGGER_STEP_LENGTH = 6;
|
|
2296
|
+
class MultiInstanceActivities {
|
|
2297
|
+
constructor(dataSimulation, store, simulator, scopeBehavior, overlays, eventBus, injector) {
|
|
2298
|
+
this.dataSimulation = dataSimulation;
|
|
2299
|
+
this.store = store;
|
|
2300
|
+
this.simulator = simulator;
|
|
2301
|
+
this.scopeBehavior = scopeBehavior;
|
|
2302
|
+
this.overlays = overlays;
|
|
2303
|
+
this.counter = new InstanceCounter();
|
|
2304
|
+
this.loops = /* @__PURE__ */ new Map();
|
|
2305
|
+
this.instanceIndexes = /* @__PURE__ */ new WeakMap();
|
|
2306
|
+
this.animation = injector.get("animation", false);
|
|
2307
|
+
eventBus.on(ELEMENT_CHANGED_EVENT, BELOW_TOKEN_COUNT, ({ element }) => {
|
|
2308
|
+
if (this.loopOf(element)) this.overlays.remove({ element, type: TOKEN_COUNT_OVERLAY });
|
|
2309
|
+
});
|
|
2310
|
+
eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => this.loops.delete(scope.id));
|
|
2311
|
+
eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => {
|
|
2312
|
+
this.loops.clear();
|
|
2313
|
+
this.overlays.remove({ type: PROGRESS_OVERLAY });
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
loopOf(activity) {
|
|
2317
|
+
return this.dataSimulation.getEngine().readLoop?.(activity.businessObject);
|
|
2318
|
+
}
|
|
2319
|
+
enterBody(context, loop) {
|
|
2320
|
+
const { element, scope: body } = context;
|
|
2321
|
+
const count = this.count(body, loop);
|
|
2322
|
+
this.record(element, body, loop, count);
|
|
2323
|
+
const instanceLoop = new InstanceLoop(loop.mode, count.count);
|
|
2324
|
+
const progress = this.showProgress(element, new InstanceProgress(loop.mode, count));
|
|
2325
|
+
if (!count.count) {
|
|
2326
|
+
progress.show(instanceLoop.progress);
|
|
2327
|
+
this.simulator.exit(context);
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2330
|
+
this.loops.set(body.id, { loop: instanceLoop, progress });
|
|
2331
|
+
for (const index of instanceLoop.start()) this.startInstance(element, body, index);
|
|
2332
|
+
progress.show(instanceLoop.progress);
|
|
2333
|
+
}
|
|
2334
|
+
enterInstance(context, enterActivity) {
|
|
2335
|
+
const { element, scope, loopIndex } = context;
|
|
2336
|
+
const loop = this.loops.get(scope.parent.id)?.loop;
|
|
2337
|
+
this.instanceIndexes.set(scope, loopIndex);
|
|
2338
|
+
const runInstance = is(element, "bpmn:SubProcess") ? () => enterActivity(context) : () => this.passThrough(element, scope, () => enterActivity(context));
|
|
2339
|
+
const staggerSteps = loop?.mode === "parallel" ? loopIndex : 0;
|
|
2340
|
+
this.stagger(element, scope, staggerSteps, runInstance);
|
|
2341
|
+
}
|
|
2342
|
+
exitInstance({ element, scope }) {
|
|
2343
|
+
const body = scope.parent;
|
|
2344
|
+
const run = this.loops.get(body.id);
|
|
2345
|
+
if (!run) return;
|
|
2346
|
+
const { loop, progress } = run;
|
|
2347
|
+
const next = loop.complete(this.instanceIndexes.get(scope));
|
|
2348
|
+
if (next !== void 0) this.startInstance(element, body, next);
|
|
2349
|
+
progress.show(loop.progress);
|
|
2350
|
+
if (loop.finished) {
|
|
2351
|
+
this.loops.delete(body.id);
|
|
2352
|
+
this.scopeBehavior.tryExit(body, scope);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
count(body, loop) {
|
|
2356
|
+
if (!this.dataSimulation.isEnabled()) return this.counter.count(loop);
|
|
2357
|
+
const engine = this.dataSimulation.getEngine();
|
|
2358
|
+
const variables = this.dataSimulation.getVariables(body);
|
|
2359
|
+
return this.counter.count(loop, (expression) => engine.evaluate(expression, variables));
|
|
2360
|
+
}
|
|
2361
|
+
record(activity, body, { mode }, count) {
|
|
2362
|
+
const instanceId = findProcessInstance(body).id;
|
|
2363
|
+
if (!this.dataSimulation.isEnabled() || !this.store.hasInstance(instanceId)) return;
|
|
2364
|
+
this.store.record({
|
|
2365
|
+
kind: "multi-instance",
|
|
2366
|
+
instanceId,
|
|
2367
|
+
elementId: activity.id,
|
|
2368
|
+
elementName: elementName(activity),
|
|
2369
|
+
mode,
|
|
2370
|
+
count
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
showProgress(activity, progress) {
|
|
2374
|
+
this.overlays.remove({ element: activity, type: PROGRESS_OVERLAY });
|
|
2375
|
+
this.overlays.add(activity, PROGRESS_OVERLAY, {
|
|
2376
|
+
position: { top: PROGRESS_OFFSET_TOP, left: 0 },
|
|
2377
|
+
scale: { min: 1 },
|
|
2378
|
+
html: inShadow(progress.element)
|
|
2379
|
+
});
|
|
2380
|
+
return progress;
|
|
2381
|
+
}
|
|
2382
|
+
startInstance(activity, body, index) {
|
|
2383
|
+
this.simulator.enter({ element: activity, scope: body, initiator: body, loopIndex: index });
|
|
2384
|
+
}
|
|
2385
|
+
passThrough(activity, scope, done) {
|
|
2386
|
+
if (!this.animation) {
|
|
2387
|
+
done();
|
|
2388
|
+
return;
|
|
2389
|
+
}
|
|
2390
|
+
const entry = this.entryPoint(activity);
|
|
2391
|
+
const exit = { x: entry.x + (activity.width ?? 0), y: entry.y };
|
|
2392
|
+
this.animation.animate({ waypoints: [entry, exit] }, scope, done);
|
|
2393
|
+
}
|
|
2394
|
+
stagger(activity, scope, steps, done) {
|
|
2395
|
+
if (!this.animation || !steps) {
|
|
2396
|
+
done();
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
const entry = this.entryPoint(activity);
|
|
2400
|
+
const pause = { waypoints: [entry, { x: entry.x + STAGGER_STEP_LENGTH, y: entry.y }] };
|
|
2401
|
+
const waiting = this.animation.createAnimation(pause, scope, () => this.stagger(activity, scope, steps - 1, done));
|
|
2402
|
+
if (waiting) waiting.hide();
|
|
2403
|
+
else done();
|
|
2404
|
+
}
|
|
2405
|
+
entryPoint({ x = 0, y = 0, height = 0 }) {
|
|
2406
|
+
return { x, y: y + height / 2 };
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
MultiInstanceActivities.$inject = [
|
|
2410
|
+
"dataSimulation",
|
|
2411
|
+
"dataSimulationStore",
|
|
2412
|
+
"simulator",
|
|
2413
|
+
"scopeBehavior",
|
|
2414
|
+
"overlays",
|
|
2415
|
+
"eventBus",
|
|
2416
|
+
"injector"
|
|
2417
|
+
];
|
|
2418
|
+
|
|
2067
2419
|
class PathResolver {
|
|
2068
2420
|
constructor() {
|
|
2069
2421
|
this.router = new GatewayRouter();
|
|
@@ -2092,11 +2444,15 @@ class PathResolver {
|
|
|
2092
2444
|
};
|
|
2093
2445
|
}
|
|
2094
2446
|
leave(node, evaluateCondition, decisions) {
|
|
2095
|
-
if (!
|
|
2096
|
-
const decision = this.router.route(node.
|
|
2447
|
+
if (!this.routesByData(node)) return node.outgoing;
|
|
2448
|
+
const decision = node.refusalReason ? this.router.refuse(node.outgoing, node.refusalReason) : this.router.route(node.routingKind, node.outgoing, evaluateCondition);
|
|
2097
2449
|
decisions[node.id] = decision;
|
|
2098
2450
|
return node.outgoing.filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
2099
2451
|
}
|
|
2452
|
+
routesByData(node) {
|
|
2453
|
+
if (node.routingKind === "activity") return node.outgoing.length > 0;
|
|
2454
|
+
return node.routingKind !== void 0 && node.outgoing.length > 1;
|
|
2455
|
+
}
|
|
2100
2456
|
sumMeasures(nodes) {
|
|
2101
2457
|
const totals = {};
|
|
2102
2458
|
for (const node of nodes) {
|
|
@@ -2110,25 +2466,27 @@ const NICE_STEPS = [1, 2, 5, 10];
|
|
|
2110
2466
|
const RANGE_STEPS = 100;
|
|
2111
2467
|
const NUMBER_LITERAL = /(?<![\w.])\d+(?:\.\d+)?/g;
|
|
2112
2468
|
class PathVariableDeriver {
|
|
2113
|
-
derive(conditions, values) {
|
|
2469
|
+
derive(conditions, values, rangeOverrides = {}) {
|
|
2114
2470
|
const names = [...new Set(conditions.flatMap((condition) => condition.variableNames))];
|
|
2115
2471
|
return names.map((name) => {
|
|
2116
2472
|
const conditionsReadingName = conditions.filter((condition) => condition.variableNames.includes(name));
|
|
2117
|
-
return this.variableFor(name, values[name], conditionsReadingName);
|
|
2473
|
+
return this.variableFor(name, values[name], conditionsReadingName, rangeOverrides[name] ?? {});
|
|
2118
2474
|
});
|
|
2119
2475
|
}
|
|
2120
|
-
variableFor(name, value, conditionsReadingName) {
|
|
2476
|
+
variableFor(name, value, conditionsReadingName, rangeOverride) {
|
|
2121
2477
|
if (typeof value === "boolean") return { name, type: "boolean" };
|
|
2122
2478
|
if (typeof value === "number") {
|
|
2123
2479
|
const comparedNumbers = conditionsReadingName.flatMap((condition) => this.numberLiterals(condition.expression));
|
|
2124
|
-
return { name, type: "number", range: this.rangeAround(value, comparedNumbers) };
|
|
2480
|
+
return { name, type: "number", range: this.rangeAround(value, comparedNumbers, rangeOverride) };
|
|
2125
2481
|
}
|
|
2126
2482
|
if (value === void 0 || typeof value === "string") return { name, type: "text" };
|
|
2127
2483
|
return { name, type: "json" };
|
|
2128
2484
|
}
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2485
|
+
// The value itself is not doubled: a slider dragged to the end then keeps its range when derived again.
|
|
2486
|
+
rangeAround(value, comparedNumbers, override) {
|
|
2487
|
+
const min = override.min ?? 0;
|
|
2488
|
+
const max = override.max ?? this.niceCeiling(Math.max(Math.abs(value), 2 * Math.max(0, ...comparedNumbers)));
|
|
2489
|
+
return { min, max, step: override.step ?? (max - min) / RANGE_STEPS };
|
|
2132
2490
|
}
|
|
2133
2491
|
niceCeiling(value) {
|
|
2134
2492
|
if (value <= 0) return 1;
|
|
@@ -2162,7 +2520,7 @@ class PathGraphReader {
|
|
|
2162
2520
|
const entersSubProcess = is(node, "bpmn:SubProcess") && !node.businessObject.triggeredByEvent;
|
|
2163
2521
|
return {
|
|
2164
2522
|
id: node.id,
|
|
2165
|
-
...
|
|
2523
|
+
...this.routingOf(node),
|
|
2166
2524
|
outgoing: outgoingSequenceFlows(node).map((flow) => ({
|
|
2167
2525
|
...readOutgoingFlow(flow, this.engine),
|
|
2168
2526
|
targetId: flow.target.id
|
|
@@ -2171,6 +2529,18 @@ class PathGraphReader {
|
|
|
2171
2529
|
measures: Object.fromEntries(measureNames.map((name) => [name, this.readMeasure(node.businessObject, name)]))
|
|
2172
2530
|
};
|
|
2173
2531
|
}
|
|
2532
|
+
routingOf(node) {
|
|
2533
|
+
const gatewayKind = GATEWAY_KINDS[node.type];
|
|
2534
|
+
if (gatewayKind) return { routingKind: gatewayKind };
|
|
2535
|
+
switch (activityRouting(node, this.engine)) {
|
|
2536
|
+
case "by-conditions":
|
|
2537
|
+
return { routingKind: "activity" };
|
|
2538
|
+
case "refused":
|
|
2539
|
+
return { routingKind: "activity", refusalReason: this.engine.activityConditionRefusal };
|
|
2540
|
+
case "none":
|
|
2541
|
+
return {};
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2174
2544
|
isProcess(element) {
|
|
2175
2545
|
return element?.$type === "bpmn:Process";
|
|
2176
2546
|
}
|
|
@@ -2251,8 +2621,8 @@ class PathSimulation {
|
|
|
2251
2621
|
this.pathMarkers.show(path);
|
|
2252
2622
|
return path;
|
|
2253
2623
|
}
|
|
2254
|
-
deriveVariables(values) {
|
|
2255
|
-
return this.pathVariableDeriver.derive(this.evaluableConditions(), values);
|
|
2624
|
+
deriveVariables(values, options = {}) {
|
|
2625
|
+
return this.pathVariableDeriver.derive(this.evaluableConditions(), values, options.ranges);
|
|
2256
2626
|
}
|
|
2257
2627
|
variablesOf(scenario, fallbacks = []) {
|
|
2258
2628
|
return this.scenarioVariables.of(scenario, fallbacks);
|
|
@@ -2278,6 +2648,8 @@ const DataSimulationModule = {
|
|
|
2278
2648
|
"dataSimulationPanel",
|
|
2279
2649
|
"dataSimulationToggle",
|
|
2280
2650
|
"dataGatewayBehaviors",
|
|
2651
|
+
"dataActivityBehavior",
|
|
2652
|
+
"multiInstanceBehaviors",
|
|
2281
2653
|
"dataGatewaySettings",
|
|
2282
2654
|
"dataContextPads"
|
|
2283
2655
|
],
|
|
@@ -2289,8 +2661,11 @@ const DataSimulationModule = {
|
|
|
2289
2661
|
dataGateways: ["type", DataGateways],
|
|
2290
2662
|
dataStartForm: ["type", DataStartForm],
|
|
2291
2663
|
dataGatewayBehaviors: ["type", DataGatewayBehaviors],
|
|
2664
|
+
dataActivityBehavior: ["type", DataActivityBehavior],
|
|
2292
2665
|
dataGatewaySettings: ["type", DataGatewaySettings],
|
|
2293
|
-
dataContextPads: ["type", DataContextPads]
|
|
2666
|
+
dataContextPads: ["type", DataContextPads],
|
|
2667
|
+
multiInstanceActivities: ["type", MultiInstanceActivities],
|
|
2668
|
+
multiInstanceBehaviors: ["type", MultiInstanceBehaviors]
|
|
2294
2669
|
};
|
|
2295
2670
|
|
|
2296
2671
|
export { Camunda7Engine, DataSimulationModule, DataSimulationStore, EngineRegistry, GatewayRouter, PathSimulationModule, ScenarioError, ScenarioParser, SimpleStartFormRenderer, StartFieldCodec, ZeebeEngine, camunda7Engine, DataSimulationModule as default, zeebeEngine };
|