bpmn-elements 14.0.1 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +0 -4
  2. package/dist/Context.js +41 -35
  3. package/dist/Environment.js +1 -1
  4. package/dist/Expressions.js +1 -1
  5. package/dist/MessageFormatter.js +0 -1
  6. package/dist/Timers.js +5 -9
  7. package/dist/Tracker.js +15 -19
  8. package/dist/activity/Activity.js +17 -11
  9. package/dist/activity/ActivityExecution.js +43 -29
  10. package/dist/definition/Definition.js +1 -1
  11. package/dist/definition/DefinitionExecution.js +64 -55
  12. package/dist/eventDefinitions/EscalationEventDefinition.js +1 -1
  13. package/dist/eventDefinitions/LinkEventDefinition.js +1 -1
  14. package/dist/eventDefinitions/MessageEventDefinition.js +1 -1
  15. package/dist/eventDefinitions/SignalEventDefinition.js +3 -2
  16. package/dist/events/BoundaryEvent.js +11 -9
  17. package/dist/events/EndEvent.js +1 -1
  18. package/dist/events/IntermediateCatchEvent.js +1 -1
  19. package/dist/events/IntermediateThrowEvent.js +1 -1
  20. package/dist/events/StartEvent.js +1 -1
  21. package/dist/flows/SequenceFlow.js +1 -1
  22. package/dist/gateways/EventBasedGateway.js +1 -1
  23. package/dist/gateways/ExclusiveGateway.js +1 -1
  24. package/dist/gateways/InclusiveGateway.js +1 -1
  25. package/dist/gateways/ParallelGateway.js +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/io/InputOutputSpecification.js +1 -1
  28. package/dist/io/Properties.js +1 -1
  29. package/dist/process/Process.js +1 -1
  30. package/dist/process/ProcessExecution.js +67 -40
  31. package/dist/tasks/CallActivity.js +1 -1
  32. package/dist/tasks/LoopCharacteristics.js +2 -2
  33. package/dist/tasks/ReceiveTask.js +1 -1
  34. package/dist/tasks/ScriptTask.js +1 -1
  35. package/dist/tasks/ServiceImplementation.js +1 -1
  36. package/dist/tasks/ServiceTask.js +1 -1
  37. package/dist/tasks/SignalTask.js +1 -1
  38. package/dist/tasks/StandardLoopCharacteristics.js +1 -1
  39. package/dist/tasks/SubProcess.js +27 -28
  40. package/dist/tasks/Task.js +1 -1
  41. package/dist/tasks/Transaction.js +1 -1
  42. package/package.json +5 -3
  43. package/src/Context.js +51 -35
  44. package/src/MessageFormatter.js +0 -3
  45. package/src/Timers.js +5 -9
  46. package/src/Tracker.js +13 -17
  47. package/src/activity/Activity.js +5 -3
  48. package/src/activity/ActivityExecution.js +43 -26
  49. package/src/definition/DefinitionExecution.js +64 -54
  50. package/src/eventDefinitions/SignalEventDefinition.js +1 -1
  51. package/src/events/BoundaryEvent.js +10 -8
  52. package/src/process/ProcessExecution.js +70 -40
  53. package/src/tasks/LoopCharacteristics.js +2 -2
  54. package/src/tasks/SubProcess.js +27 -27
  55. package/types/types.d.ts +1 -1
@@ -38,7 +38,7 @@ export function SubProcessBehaviour(activity, context) {
38
38
  this.broker = activity.broker;
39
39
  this.executionId = undefined;
40
40
 
41
- this[kExecutions] = [];
41
+ this[kExecutions] = new Set();
42
42
  this[kMessageHandlers] = {
43
43
  onExecutionCompleted: this._onExecutionCompleted.bind(this),
44
44
  };
@@ -47,12 +47,12 @@ export function SubProcessBehaviour(activity, context) {
47
47
  Object.defineProperties(SubProcessBehaviour.prototype, {
48
48
  execution: {
49
49
  get() {
50
- return this[kExecutions][0];
50
+ return [...this[kExecutions]][0];
51
51
  },
52
52
  },
53
53
  executions: {
54
54
  get() {
55
- return this[kExecutions].slice();
55
+ return [...this[kExecutions]];
56
56
  },
57
57
  },
58
58
  });
@@ -74,22 +74,20 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
74
74
  };
75
75
 
76
76
  SubProcessBehaviour.prototype.getState = function getState() {
77
+ const states = [];
78
+ for (const pe of this[kExecutions]) {
79
+ const state = pe.getState();
80
+ state.environment = pe.environment.getState();
81
+ states.push(state);
82
+ }
83
+
77
84
  if (this.loopCharacteristics) {
78
85
  return {
79
- executions: this[kExecutions].map((pe) => {
80
- const state = pe.getState();
81
- state.environment = pe.environment.getState();
82
- return state;
83
- }),
86
+ executions: states,
84
87
  };
85
88
  }
86
89
 
87
- const execution = this.execution;
88
- if (execution) {
89
- const state = execution.getState();
90
- state.environment = execution.environment.getState();
91
- return state;
92
- }
90
+ return states[0];
93
91
  };
94
92
 
95
93
  SubProcessBehaviour.prototype.recover = function recover(state) {
@@ -99,7 +97,7 @@ SubProcessBehaviour.prototype.recover = function recover(state) {
99
97
 
100
98
  const loopCharacteristics = this.loopCharacteristics;
101
99
  if (loopCharacteristics && state.executions) {
102
- executions.splice(0);
100
+ executions.clear();
103
101
  for (const se of state.executions) {
104
102
  this.recover(se);
105
103
  }
@@ -107,7 +105,7 @@ SubProcessBehaviour.prototype.recover = function recover(state) {
107
105
  }
108
106
 
109
107
  if (!loopCharacteristics) {
110
- executions.splice(0);
108
+ executions.clear();
111
109
  }
112
110
 
113
111
  const subEnvironment = this.environment.clone().recover(state.environment);
@@ -115,15 +113,16 @@ SubProcessBehaviour.prototype.recover = function recover(state) {
115
113
 
116
114
  const execution = new ProcessExecution(this.activity, subContext).recover(state);
117
115
 
118
- executions.push(execution);
116
+ executions.add(execution);
119
117
  return execution;
120
118
  };
121
119
 
122
120
  SubProcessBehaviour.prototype.getPostponed = function getPostponed() {
123
- return this[kExecutions].reduce((result, pe) => {
124
- result = result.concat(pe.getPostponed());
125
- return result;
126
- }, []);
121
+ let postponed = [];
122
+ for (const pe of this[kExecutions]) {
123
+ postponed = postponed.concat(pe.getPostponed());
124
+ }
125
+ return postponed;
127
126
  };
128
127
 
129
128
  SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(executeMessage) {
@@ -140,7 +139,7 @@ SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(execut
140
139
  const subContext = this.context.clone(subEnvironment, this.activity);
141
140
 
142
141
  execution = new ProcessExecution(this.activity, subContext);
143
- this[kExecutions].push(execution);
142
+ this[kExecutions].add(execution);
144
143
 
145
144
  this._addListeners(executionId);
146
145
 
@@ -184,10 +183,9 @@ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionComple
184
183
 
185
184
  SubProcessBehaviour.prototype._completeExecution = function completeExecution(completeRoutingKey, content) {
186
185
  if (this.loopCharacteristics) {
187
- const executions = this[kExecutions];
188
- const executionIdx = executions.findIndex((pe) => pe.executionId === content.executionId);
189
- if (executionIdx < 0) return;
190
- executions.splice(executionIdx, 1);
186
+ const execution = this._getExecutionById(content.executionId);
187
+ if (!execution) return;
188
+ this[kExecutions].delete(execution);
191
189
  }
192
190
 
193
191
  this.broker.publish('execution', completeRoutingKey, cloneContent(content));
@@ -209,5 +207,7 @@ SubProcessBehaviour.prototype.getApi = function getApi(apiMessage) {
209
207
  };
210
208
 
211
209
  SubProcessBehaviour.prototype._getExecutionById = function getExecutionById(executionId) {
212
- return this[kExecutions].find((pe) => pe.executionId === executionId);
210
+ for (const pe of this[kExecutions]) {
211
+ if (pe.executionId === executionId) return pe;
212
+ }
213
213
  };
package/types/types.d.ts CHANGED
@@ -220,7 +220,7 @@ declare interface DefinitionExecution {
220
220
  getProcessByExecutionId(processExecutionId: string): Process;
221
221
  getRunningProcesses(): Process[];
222
222
  getExecutableProcesses(): Process[];
223
- getPostponed(filterFn: filterPostponed): Api<ElementBase>[];
223
+ getPostponed(filterFn?: filterPostponed): Api<ElementBase>[];
224
224
  }
225
225
 
226
226
  declare interface ActivityExecution {