bpmn-elements 11.1.1 → 13.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 (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/Environment.js +15 -15
  3. package/dist/activity/Activity.js +123 -143
  4. package/dist/activity/ActivityExecution.js +1 -3
  5. package/dist/definition/Definition.js +39 -44
  6. package/dist/definition/DefinitionExecution.js +51 -53
  7. package/dist/eventDefinitions/EventDefinitionExecution.js +10 -10
  8. package/dist/eventDefinitions/TimerEventDefinition.js +16 -16
  9. package/dist/events/BoundaryEvent.js +12 -11
  10. package/dist/events/index.js +60 -0
  11. package/dist/flows/Association.js +0 -1
  12. package/dist/flows/MessageFlow.js +0 -1
  13. package/dist/flows/SequenceFlow.js +1 -3
  14. package/dist/gateways/index.js +49 -0
  15. package/dist/getPropertyValue.js +1 -2
  16. package/dist/index.js +2 -2
  17. package/dist/process/Process.js +54 -61
  18. package/dist/process/ProcessExecution.js +31 -33
  19. package/dist/tasks/LoopCharacteristics.js +20 -7
  20. package/dist/tasks/SubProcess.js +33 -61
  21. package/dist/tasks/index.js +93 -0
  22. package/events.d.ts +1 -0
  23. package/gateways.d.ts +1 -0
  24. package/index.d.ts +1 -0
  25. package/package.json +39 -19
  26. package/src/Environment.js +16 -17
  27. package/src/activity/Activity.js +96 -131
  28. package/src/activity/ActivityExecution.js +0 -1
  29. package/src/definition/Definition.js +30 -40
  30. package/src/definition/DefinitionExecution.js +47 -55
  31. package/src/eventDefinitions/EventDefinitionExecution.js +9 -10
  32. package/src/eventDefinitions/TimerEventDefinition.js +14 -16
  33. package/src/events/BoundaryEvent.js +11 -11
  34. package/src/events/index.js +5 -0
  35. package/src/flows/Association.js +0 -1
  36. package/src/flows/MessageFlow.js +0 -1
  37. package/src/flows/SequenceFlow.js +0 -1
  38. package/src/gateways/index.js +4 -0
  39. package/src/process/Process.js +40 -54
  40. package/src/process/ProcessExecution.js +25 -31
  41. package/src/tasks/LoopCharacteristics.js +18 -7
  42. package/src/tasks/SubProcess.js +32 -66
  43. package/src/tasks/index.js +8 -0
  44. package/tasks.d.ts +1 -0
  45. package/types/index.d.ts +69 -767
  46. package/types/types.d.ts +706 -0
@@ -61,69 +61,61 @@ export default function DefinitionExecution(definition, context) {
61
61
  };
62
62
  }
63
63
 
64
- Object.defineProperty(DefinitionExecution.prototype, 'stopped', {
65
- enumerable: true,
66
- get() {
67
- return this[kStopped];
64
+ Object.defineProperties(DefinitionExecution.prototype, {
65
+ stopped: {
66
+ get() {
67
+ return this[kStopped];
68
+ },
68
69
  },
69
- });
70
-
71
- Object.defineProperty(DefinitionExecution.prototype, 'completed', {
72
- enumerable: true,
73
- get() {
74
- return this[kCompleted];
70
+ completed: {
71
+ get() {
72
+ return this[kCompleted];
73
+ },
75
74
  },
76
- });
77
-
78
- Object.defineProperty(DefinitionExecution.prototype, 'status', {
79
- enumerable: true,
80
- get() {
81
- return this[kStatus];
75
+ status: {
76
+ get() {
77
+ return this[kStatus];
78
+ },
82
79
  },
83
- });
84
-
85
- Object.defineProperty(DefinitionExecution.prototype, 'processes', {
86
- enumerable: true,
87
- get() {
88
- return this[kProcesses].running;
80
+ processes: {
81
+ get() {
82
+ return this[kProcesses].running;
83
+ },
89
84
  },
90
- });
91
-
92
- Object.defineProperty(DefinitionExecution.prototype, 'postponedCount', {
93
- get() {
94
- return this[kProcesses].postponed.length;
85
+ postponedCount: {
86
+ get() {
87
+ return this[kProcesses].postponed.length;
88
+ },
95
89
  },
96
- });
97
-
98
- Object.defineProperty(DefinitionExecution.prototype, 'isRunning', {
99
- get() {
100
- return this[kActivated];
90
+ isRunning: {
91
+ get() {
92
+ return this[kActivated];
93
+ },
101
94
  },
102
- });
103
-
104
- Object.defineProperty(DefinitionExecution.prototype, 'activityStatus', {
105
- get() {
106
- let status = 'idle';
107
- const running = this[kProcesses].running;
108
- if (!running || !running.length) return status;
109
-
110
- for (const bp of running) {
111
- const bpStatus = bp.activityStatus;
112
- switch (bp.activityStatus) {
113
- case 'idle':
114
- break;
115
- case 'executing':
116
- return bpStatus;
117
- case 'timer':
118
- status = bpStatus;
119
- break;
120
- case 'wait':
121
- if (status === 'idle') status = bpStatus;
122
- break;
95
+ activityStatus: {
96
+ get() {
97
+ let status = 'idle';
98
+ const running = this[kProcesses].running;
99
+ if (!running || !running.length) return status;
100
+
101
+ for (const bp of running) {
102
+ const bpStatus = bp.activityStatus;
103
+ switch (bp.activityStatus) {
104
+ case 'idle':
105
+ break;
106
+ case 'executing':
107
+ return bpStatus;
108
+ case 'timer':
109
+ status = bpStatus;
110
+ break;
111
+ case 'wait':
112
+ if (status === 'idle') status = bpStatus;
113
+ break;
114
+ }
123
115
  }
124
- }
125
116
 
126
- return status;
117
+ return status;
118
+ },
127
119
  },
128
120
  });
129
121
 
@@ -15,17 +15,16 @@ export default function EventDefinitionExecution(activity, eventDefinitions, com
15
15
  this[kExecuteMessage] = null;
16
16
  }
17
17
 
18
- Object.defineProperty(EventDefinitionExecution.prototype, 'completed', {
19
- enumerable: true,
20
- get() {
21
- return this[kCompleted];
18
+ Object.defineProperties(EventDefinitionExecution.prototype, {
19
+ completed: {
20
+ get() {
21
+ return this[kCompleted];
22
+ },
22
23
  },
23
- });
24
-
25
- Object.defineProperty(EventDefinitionExecution.prototype, 'stopped', {
26
- enumerable: true,
27
- get() {
28
- return this[kStopped];
24
+ stopped: {
25
+ get() {
26
+ return this[kStopped];
27
+ },
29
28
  },
30
29
  });
31
30
 
@@ -23,24 +23,22 @@ export default function TimerEventDefinition(activity, eventDefinition) {
23
23
  this[kTimer] = null;
24
24
  }
25
25
 
26
- Object.defineProperty(TimerEventDefinition.prototype, 'executionId', {
27
- get() {
28
- const content = this[kTimerContent];
29
- return content && content.executionId;
26
+ Object.defineProperties(TimerEventDefinition.prototype, {
27
+ executionId: {
28
+ get() {
29
+ const content = this[kTimerContent];
30
+ return content && content.executionId;
31
+ },
30
32
  },
31
- });
32
-
33
- Object.defineProperty(TimerEventDefinition.prototype, 'stopped', {
34
- enumerable: true,
35
- get() {
36
- return this[kStopped];
33
+ stopped: {
34
+ get() {
35
+ return this[kStopped];
36
+ },
37
37
  },
38
- });
39
-
40
- Object.defineProperty(TimerEventDefinition.prototype, 'timer', {
41
- enumerable: true,
42
- get() {
43
- return this[kTimer];
38
+ timer: {
39
+ get() {
40
+ return this[kTimer];
41
+ },
44
42
  },
45
43
  });
46
44
 
@@ -25,18 +25,18 @@ export function BoundaryEventBehaviour(activity) {
25
25
  this[kAttachedTags] = [];
26
26
  }
27
27
 
28
- Object.defineProperty(BoundaryEventBehaviour.prototype, 'executionId', {
29
- get() {
30
- const message = this[kExecuteMessage];
31
- return message && message.content.executionId;
28
+ Object.defineProperties(BoundaryEventBehaviour.prototype, {
29
+ executionId: {
30
+ get() {
31
+ const message = this[kExecuteMessage];
32
+ return message && message.content.executionId;
33
+ },
32
34
  },
33
- });
34
-
35
- Object.defineProperty(BoundaryEventBehaviour.prototype, 'cancelActivity', {
36
- enumerable: true,
37
- get() {
38
- const behaviour = this.activity.behaviour || {};
39
- return 'cancelActivity' in behaviour ? behaviour.cancelActivity : true;
35
+ cancelActivity: {
36
+ get() {
37
+ const behaviour = this.activity.behaviour || {};
38
+ return 'cancelActivity' in behaviour ? behaviour.cancelActivity : true;
39
+ },
40
40
  },
41
41
  });
42
42
 
@@ -0,0 +1,5 @@
1
+ export * from './BoundaryEvent.js';
2
+ export * from './EndEvent.js';
3
+ export * from './IntermediateCatchEvent.js';
4
+ export * from './IntermediateThrowEvent.js';
5
+ export * from './StartEvent.js';
@@ -34,7 +34,6 @@ export default function Association(associationDef, {environment}) {
34
34
  }
35
35
 
36
36
  Object.defineProperty(Association.prototype, 'counters', {
37
- enumerable: true,
38
37
  get() {
39
38
  return {...this[kCounters]};
40
39
  },
@@ -35,7 +35,6 @@ export default function MessageFlow(flowDef, context) {
35
35
  }
36
36
 
37
37
  Object.defineProperty(MessageFlow.prototype, 'counters', {
38
- enumerable: true,
39
38
  get() {
40
39
  return {...this[kCounters]};
41
40
  },
@@ -41,7 +41,6 @@ function SequenceFlow(flowDef, {environment}) {
41
41
  }
42
42
 
43
43
  Object.defineProperty(SequenceFlow.prototype, 'counters', {
44
- enumerable: true,
45
44
  get() {
46
45
  return {...this[kCounters]};
47
46
  },
@@ -0,0 +1,4 @@
1
+ export * from './EventBasedGateway.js';
2
+ export * from './ExclusiveGateway.js';
3
+ export * from './InclusiveGateway.js';
4
+ export * from './ParallelGateway.js';
@@ -60,68 +60,54 @@ export function Process(processDef, context) {
60
60
  this[kExtensions] = context.loadExtensions(this);
61
61
  }
62
62
 
63
- Object.defineProperty(Process.prototype, 'counters', {
64
- enumerable: true,
65
- get() {
66
- return {...this[kCounters]};
63
+ Object.defineProperties(Process.prototype, {
64
+ counters: {
65
+ get() {
66
+ return {...this[kCounters]};
67
+ },
67
68
  },
68
- });
69
-
70
- Object.defineProperty(Process.prototype, 'lanes', {
71
- enumerable: true,
72
- get() {
73
- const lanes = this[kLanes];
74
- return lanes && lanes.slice();
69
+ lanes: {
70
+ get() {
71
+ const lanes = this[kLanes];
72
+ return lanes && lanes.slice();
73
+ },
75
74
  },
76
- });
77
-
78
- Object.defineProperty(Process.prototype, 'extensions', {
79
- enumerable: true,
80
- get() {
81
- return this[kExtensions];
75
+ extensions: {
76
+ get() {
77
+ return this[kExtensions];
78
+ },
82
79
  },
83
- });
84
-
85
- Object.defineProperty(Process.prototype, 'stopped', {
86
- enumerable: true,
87
- get() {
88
- return this[kStopped];
80
+ stopped: {
81
+ get() {
82
+ return this[kStopped];
83
+ },
89
84
  },
90
- });
91
-
92
- Object.defineProperty(Process.prototype, 'isRunning', {
93
- enumerable: true,
94
- get() {
95
- if (!this[kConsuming]) return false;
96
- return !!this.status;
85
+ isRunning: {
86
+ get() {
87
+ if (!this[kConsuming]) return false;
88
+ return !!this.status;
89
+ },
97
90
  },
98
- });
99
-
100
- Object.defineProperty(Process.prototype, 'executionId', {
101
- enumerable: true,
102
- get() {
103
- const {executionId, initExecutionId} = this[kExec];
104
- return executionId || initExecutionId;
91
+ executionId: {
92
+ get() {
93
+ const {executionId, initExecutionId} = this[kExec];
94
+ return executionId || initExecutionId;
95
+ },
105
96
  },
106
- });
107
-
108
- Object.defineProperty(Process.prototype, 'execution', {
109
- enumerable: true,
110
- get() {
111
- return this[kExec].execution;
97
+ execution: {
98
+ get() {
99
+ return this[kExec].execution;
100
+ },
112
101
  },
113
- });
114
-
115
- Object.defineProperty(Process.prototype, 'status', {
116
- enumerable: true,
117
- get() {
118
- return this[kStatus];
102
+ status: {
103
+ get() {
104
+ return this[kStatus];
105
+ },
119
106
  },
120
- });
121
-
122
- Object.defineProperty(Process.prototype, 'activityStatus', {
123
- get() {
124
- return this[kExec].execution && this[kExec].execution.activityStatus || 'idle';
107
+ activityStatus: {
108
+ get() {
109
+ return this[kExec].execution && this[kExec].execution.activityStatus || 'idle';
110
+ },
125
111
  },
126
112
  });
127
113
 
@@ -58,42 +58,36 @@ function ProcessExecution(parentActivity, context) {
58
58
  };
59
59
  }
60
60
 
61
- Object.defineProperty(ProcessExecution.prototype, 'stopped', {
62
- enumerable: true,
63
- get() {
64
- return this[kStopped];
61
+ Object.defineProperties(ProcessExecution.prototype, {
62
+ stopped: {
63
+ get() {
64
+ return this[kStopped];
65
+ },
65
66
  },
66
- });
67
-
68
- Object.defineProperty(ProcessExecution.prototype, 'completed', {
69
- enumerable: true,
70
- get() {
71
- return this[kCompleted];
67
+ completed: {
68
+ get() {
69
+ return this[kCompleted];
70
+ },
72
71
  },
73
- });
74
-
75
- Object.defineProperty(ProcessExecution.prototype, 'status', {
76
- enumerable: true,
77
- get() {
78
- return this[kStatus];
72
+ status: {
73
+ get() {
74
+ return this[kStatus];
75
+ },
79
76
  },
80
- });
81
-
82
- Object.defineProperty(ProcessExecution.prototype, 'postponedCount', {
83
- get() {
84
- return this[kElements].postponed.length;
77
+ postponedCount: {
78
+ get() {
79
+ return this[kElements].postponed.length;
80
+ },
85
81
  },
86
- });
87
-
88
- Object.defineProperty(ProcessExecution.prototype, 'isRunning', {
89
- get() {
90
- return this[kActivated];
82
+ isRunning: {
83
+ get() {
84
+ return this[kActivated];
85
+ },
91
86
  },
92
- });
93
-
94
- Object.defineProperty(ProcessExecution.prototype, 'activityStatus', {
95
- get() {
96
- return this[kTracker].activityStatus;
87
+ activityStatus: {
88
+ get() {
89
+ return this[kTracker].activityStatus;
90
+ },
97
91
  },
98
92
  });
99
93
 
@@ -120,6 +120,7 @@ function ParallelLoopCharacteristics(activity, characteristics) {
120
120
  this.characteristics = characteristics;
121
121
  this.running = 0;
122
122
  this.index = 0;
123
+ this.discarded = 0;
123
124
  }
124
125
 
125
126
  ParallelLoopCharacteristics.prototype.execute = function execute(executeMessage) {
@@ -128,8 +129,10 @@ ParallelLoopCharacteristics.prototype.execute = function execute(executeMessage)
128
129
 
129
130
  const isRedelivered = executeMessage.fields.redelivered;
130
131
  if (isRedelivered) {
131
- if (!isNaN(executeMessage.content.index)) this.index = executeMessage.content.index;
132
- if (!isNaN(executeMessage.content.running)) this.running = executeMessage.content.running;
132
+ const { index, running, discarded } = executeMessage.content;
133
+ if (!isNaN(index)) this.index = index;
134
+ if (!isNaN(running)) this.running = running;
135
+ if (!isNaN(discarded)) this.discarded = discarded;
133
136
  }
134
137
  chr.subscribe(this._onCompleteMessage.bind(this));
135
138
 
@@ -160,6 +163,7 @@ ParallelLoopCharacteristics.prototype._startBatch = function startBatch() {
160
163
  ...chr.getContent(),
161
164
  index: this.index,
162
165
  running: this.running,
166
+ discarded: this.discarded,
163
167
  output: chr.output,
164
168
  preventComplete: true,
165
169
  });
@@ -169,11 +173,15 @@ ParallelLoopCharacteristics.prototype._startBatch = function startBatch() {
169
173
  }
170
174
  };
171
175
 
172
- ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMessage(_, message) {
176
+ ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMessage(routingKey, message) {
173
177
  const chr = this.characteristics;
174
178
  const {content} = message;
175
179
  if (content.output !== undefined) chr.output[content.index] = content.output;
176
180
 
181
+ if (routingKey === 'execute.discard') {
182
+ this.discarded++;
183
+ }
184
+
177
185
  this.running--;
178
186
 
179
187
  this.activity.broker.publish('execution', 'execute.iteration.completed', {
@@ -181,17 +189,18 @@ ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMe
181
189
  ...chr.getContent(),
182
190
  index: this.index,
183
191
  running: this.running,
192
+ discarded: this.discarded,
184
193
  output: chr.output,
185
194
  state: 'iteration.completed',
186
195
  preventComplete: true,
187
196
  });
188
197
 
189
198
  if (this.running <= 0 && !chr.next(this.index)) {
190
- return chr.complete(content);
199
+ return chr.complete(content, this.discarded === this.index);
191
200
  }
192
201
 
193
202
  if (chr.isCompletionConditionMet(message)) {
194
- return chr.complete(content);
203
+ return chr.complete(content, this.discarded === this.index);
195
204
  }
196
205
 
197
206
  if (this.running <= 0) {
@@ -299,10 +308,10 @@ Characteristics.prototype.isCompletionConditionMet = function isCompletionCondit
299
308
  return this.activity.environment.resolveExpression(this.completionCondition, cloneMessage(message, {loopOutput: this.output}));
300
309
  };
301
310
 
302
- Characteristics.prototype.complete = function complete(content) {
311
+ Characteristics.prototype.complete = function complete(content, allDiscarded) {
303
312
  this.stop();
304
313
 
305
- return this.broker.publish('execution', 'execute.completed', {
314
+ return this.broker.publish('execution', 'execute.' + (allDiscarded ? 'discard' : 'completed'), {
306
315
  ...content,
307
316
  ...this.getContent(),
308
317
  output: this.output,
@@ -315,7 +324,9 @@ Characteristics.prototype.subscribe = function subscribe(onIterationCompleteMess
315
324
 
316
325
  function onComplete(routingKey, message, ...args) {
317
326
  if (!message.content.isMultiInstance) return;
327
+
318
328
  switch (routingKey) {
329
+ case 'execute.discard':
319
330
  case 'execute.cancel':
320
331
  case 'execute.completed':
321
332
  return onIterationCompleteMessage(routingKey, message, ...args);