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
package/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ # 13.0.0
5
+
6
+ - export task-, events-, and gateway activity behaviors through `bpmn-elements/tasks`, `bpmn-elements/events`, and `bpmn-elements/gateways` respectively
7
+ - refactor type definitions for three days to make the above type safe and VS-code happy. Why is it so freaking complicated? Ambient bla bla bla ts(4-digit-number)??? Looped through all 10.000 ts-typescript errors. Patches are inevitable and imminent
8
+ - use `Object.defineProperties` when feasible and skip pointless enumerable option on property
9
+
10
+ # 12.0.0
11
+
12
+ Memory issues running sequential multi-instance sub-process (MISP). All MISP executions are put in a list to be able to save state.
13
+
14
+ ## Breaking
15
+
16
+ - remove MISP execution from execution reference list when iteration is completed, discarded, or errored
17
+
4
18
  # 11.1.1
5
19
 
6
20
  - fix boundary event not cancelling task if resumed before task was resumed
@@ -25,23 +25,23 @@ function Environment(options = {}) {
25
25
  this[kServices] = options.services || {};
26
26
  this[kVariables] = options.variables || {};
27
27
  }
28
- Object.defineProperty(Environment.prototype, 'variables', {
29
- enumerable: true,
30
- get() {
31
- return this[kVariables];
32
- }
33
- });
34
- Object.defineProperty(Environment.prototype, 'services', {
35
- enumerable: true,
36
- get() {
37
- return this[kServices];
28
+ Object.defineProperties(Environment.prototype, {
29
+ variables: {
30
+ get() {
31
+ return this[kVariables];
32
+ }
38
33
  },
39
- set(value) {
40
- const services = this[kServices];
41
- for (const name in services) {
42
- if (!(name in value)) delete services[name];
34
+ services: {
35
+ get() {
36
+ return this[kServices];
37
+ },
38
+ set(value) {
39
+ const services = this[kServices];
40
+ for (const name in services) {
41
+ if (!(name in value)) delete services[name];
42
+ }
43
+ Object.assign(services, value);
43
44
  }
44
- Object.assign(services, value);
45
45
  }
46
46
  });
47
47
  Environment.prototype.getState = function getState() {
@@ -25,8 +25,7 @@ const kFormatter = Symbol.for('formatter');
25
25
  const kMessageHandlers = Symbol.for('messageHandlers');
26
26
  const kStateMessage = Symbol.for('stateMessage');
27
27
  const kActivated = Symbol.for('activated');
28
- var _default = Activity;
29
- exports.default = _default;
28
+ var _default = exports.default = Activity;
30
29
  function Activity(Behaviour, activityDef, context) {
31
30
  const {
32
31
  id,
@@ -115,147 +114,128 @@ function Activity(Behaviour, activityDef, context) {
115
114
  this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed, this.context));
116
115
  this[kExtensions] = context.loadExtensions(this);
117
116
  }
118
- Object.defineProperty(Activity.prototype, 'counters', {
119
- enumerable: true,
120
- get() {
121
- return {
122
- ...this[kCounters]
123
- };
124
- }
125
- });
126
- Object.defineProperty(Activity.prototype, 'execution', {
127
- enumerable: true,
128
- get() {
129
- return this[kExec].execution;
130
- }
131
- });
132
- Object.defineProperty(Activity.prototype, 'executionId', {
133
- enumerable: true,
134
- get() {
135
- return this[kExec].executionId;
136
- }
137
- });
138
- Object.defineProperty(Activity.prototype, 'extensions', {
139
- enumerable: true,
140
- get() {
141
- return this[kExtensions];
142
- }
143
- });
144
- Object.defineProperty(Activity.prototype, 'bpmnIo', {
145
- enumerable: true,
146
- get() {
147
- const extensions = this[kExtensions];
148
- return extensions && extensions.extensions.find(e => e.type === 'bpmnio');
149
- }
150
- });
151
- Object.defineProperty(Activity.prototype, 'formatter', {
152
- enumerable: true,
153
- get() {
154
- let formatter = this[kFormatter];
155
- if (formatter) return formatter;
156
- const broker = this.broker;
157
- formatter = this[kFormatter] = new _MessageFormatter.Formatter({
158
- id: this.id,
159
- broker,
160
- logger: this.logger
161
- }, broker.getQueue('format-run-q'));
162
- return formatter;
163
- }
164
- });
165
- Object.defineProperty(Activity.prototype, 'isRunning', {
166
- enumerable: true,
167
- get() {
168
- if (!this[kConsuming]) return false;
169
- return !!this.status;
170
- }
171
- });
172
- Object.defineProperty(Activity.prototype, 'outbound', {
173
- enumerable: true,
174
- get() {
175
- return this[kFlows].outboundSequenceFlows;
176
- }
177
- });
178
- Object.defineProperty(Activity.prototype, 'inbound', {
179
- enumerable: true,
180
- get() {
181
- return this[kFlows].inboundSequenceFlows;
182
- }
183
- });
184
- Object.defineProperty(Activity.prototype, 'isEnd', {
185
- enumerable: true,
186
- get() {
187
- return this[kFlags].isEnd;
188
- }
189
- });
190
- Object.defineProperty(Activity.prototype, 'isStart', {
191
- enumerable: true,
192
- get() {
193
- return this[kFlags].isStart;
194
- }
195
- });
196
- Object.defineProperty(Activity.prototype, 'isSubProcess', {
197
- enumerable: true,
198
- get() {
199
- return this[kFlags].isSubProcess;
200
- }
201
- });
202
- Object.defineProperty(Activity.prototype, 'isTransaction', {
203
- enumerable: true,
204
- get() {
205
- return this[kFlags].isTransaction;
206
- }
207
- });
208
- Object.defineProperty(Activity.prototype, 'isMultiInstance', {
209
- enumerable: true,
210
- get() {
211
- return this[kFlags].isMultiInstance;
212
- }
213
- });
214
- Object.defineProperty(Activity.prototype, 'isThrowing', {
215
- enumerable: true,
216
- get() {
217
- return this[kFlags].isThrowing;
218
- }
219
- });
220
- Object.defineProperty(Activity.prototype, 'isForCompensation', {
221
- enumerable: true,
222
- get() {
223
- return this[kFlags].isForCompensation;
224
- }
225
- });
226
- Object.defineProperty(Activity.prototype, 'triggeredByEvent', {
227
- enumerable: true,
228
- get() {
229
- return this[kActivityDef].triggeredByEvent;
230
- }
231
- });
232
- Object.defineProperty(Activity.prototype, 'attachedTo', {
233
- enumerable: true,
234
- get() {
235
- const attachedToId = this[kFlags].attachedTo;
236
- if (!attachedToId) return null;
237
- return this.getActivityById(attachedToId);
238
- }
239
- });
240
- Object.defineProperty(Activity.prototype, 'lane', {
241
- enumerable: true,
242
- get() {
243
- const laneId = this[kFlags].lane;
244
- if (!laneId) return undefined;
245
- const parent = this.parentElement;
246
- return parent.getLaneById && parent.getLaneById(laneId);
247
- }
248
- });
249
- Object.defineProperty(Activity.prototype, 'eventDefinitions', {
250
- enumerable: true,
251
- get() {
252
- return this[kEventDefinitions];
253
- }
254
- });
255
- Object.defineProperty(Activity.prototype, 'parentElement', {
256
- enumerable: true,
257
- get() {
258
- return this.context.getActivityParentById(this.id);
117
+ Object.defineProperties(Activity.prototype, {
118
+ counters: {
119
+ get() {
120
+ return {
121
+ ...this[kCounters]
122
+ };
123
+ }
124
+ },
125
+ execution: {
126
+ get() {
127
+ return this[kExec].execution;
128
+ }
129
+ },
130
+ executionId: {
131
+ get() {
132
+ return this[kExec].executionId;
133
+ }
134
+ },
135
+ extensions: {
136
+ get() {
137
+ return this[kExtensions];
138
+ }
139
+ },
140
+ bpmnIo: {
141
+ get() {
142
+ const extensions = this[kExtensions];
143
+ return extensions && extensions.extensions.find(e => e.type === 'bpmnio');
144
+ }
145
+ },
146
+ formatter: {
147
+ get() {
148
+ let formatter = this[kFormatter];
149
+ if (formatter) return formatter;
150
+ const broker = this.broker;
151
+ formatter = this[kFormatter] = new _MessageFormatter.Formatter({
152
+ id: this.id,
153
+ broker,
154
+ logger: this.logger
155
+ }, broker.getQueue('format-run-q'));
156
+ return formatter;
157
+ }
158
+ },
159
+ isRunning: {
160
+ get() {
161
+ if (!this[kConsuming]) return false;
162
+ return !!this.status;
163
+ }
164
+ },
165
+ outbound: {
166
+ get() {
167
+ return this[kFlows].outboundSequenceFlows;
168
+ }
169
+ },
170
+ inbound: {
171
+ get() {
172
+ return this[kFlows].inboundSequenceFlows;
173
+ }
174
+ },
175
+ isEnd: {
176
+ get() {
177
+ return this[kFlags].isEnd;
178
+ }
179
+ },
180
+ isStart: {
181
+ get() {
182
+ return this[kFlags].isStart;
183
+ }
184
+ },
185
+ isSubProcess: {
186
+ get() {
187
+ return this[kFlags].isSubProcess;
188
+ }
189
+ },
190
+ isTransaction: {
191
+ get() {
192
+ return this[kFlags].isTransaction;
193
+ }
194
+ },
195
+ isMultiInstance: {
196
+ get() {
197
+ return this[kFlags].isMultiInstance;
198
+ }
199
+ },
200
+ isThrowing: {
201
+ get() {
202
+ return this[kFlags].isThrowing;
203
+ }
204
+ },
205
+ isForCompensation: {
206
+ get() {
207
+ return this[kFlags].isForCompensation;
208
+ }
209
+ },
210
+ triggeredByEvent: {
211
+ get() {
212
+ return this[kActivityDef].triggeredByEvent;
213
+ }
214
+ },
215
+ attachedTo: {
216
+ get() {
217
+ const attachedToId = this[kFlags].attachedTo;
218
+ if (!attachedToId) return null;
219
+ return this.getActivityById(attachedToId);
220
+ }
221
+ },
222
+ lane: {
223
+ get() {
224
+ const laneId = this[kFlags].lane;
225
+ if (!laneId) return undefined;
226
+ const parent = this.parentElement;
227
+ return parent.getLaneById && parent.getLaneById(laneId);
228
+ }
229
+ },
230
+ eventDefinitions: {
231
+ get() {
232
+ return this[kEventDefinitions];
233
+ }
234
+ },
235
+ parentElement: {
236
+ get() {
237
+ return this.context.getActivityParentById(this.id);
238
+ }
259
239
  }
260
240
  });
261
241
  Activity.prototype.activate = function activate() {
@@ -11,8 +11,7 @@ const kExecuteQ = Symbol.for('executeQ');
11
11
  const kExecuteMessage = Symbol.for('executeMessage');
12
12
  const kMessageHandlers = Symbol.for('messageHandlers');
13
13
  const kPostponed = Symbol.for('postponed');
14
- var _default = ActivityExecution;
15
- exports.default = _default;
14
+ var _default = exports.default = ActivityExecution;
16
15
  function ActivityExecution(activity, context) {
17
16
  this.activity = activity;
18
17
  this.context = context;
@@ -30,7 +29,6 @@ function ActivityExecution(activity, context) {
30
29
  };
31
30
  }
32
31
  Object.defineProperty(ActivityExecution.prototype, 'completed', {
33
- enumerable: true,
34
32
  get() {
35
33
  return this[kCompleted];
36
34
  }
@@ -20,8 +20,7 @@ const kMessageHandlers = Symbol.for('messageHandlers');
20
20
  const kStateMessage = Symbol.for('stateMessage');
21
21
  const kStatus = Symbol.for('status');
22
22
  const kStopped = Symbol.for('stopped');
23
- var _default = Definition;
24
- exports.default = _default;
23
+ var _default = exports.default = Definition;
25
24
  function Definition(context, options) {
26
25
  if (!(this instanceof Definition)) return new Definition(context, options);
27
26
  if (!context) throw new Error('No context');
@@ -70,48 +69,44 @@ function Definition(context, options) {
70
69
  this.emitFatal = emitFatal;
71
70
  this.logger = environment.Logger(type.toLowerCase());
72
71
  }
73
- Object.defineProperty(Definition.prototype, 'counters', {
74
- enumerable: true,
75
- get() {
76
- return {
77
- ...this[kCounters]
78
- };
79
- }
80
- });
81
- Object.defineProperty(Definition.prototype, 'execution', {
82
- enumerable: true,
83
- get() {
84
- return this[kExec].execution;
85
- }
86
- });
87
- Object.defineProperty(Definition.prototype, 'executionId', {
88
- enumerable: true,
89
- get() {
90
- return this[kExec].executionId;
91
- }
92
- });
93
- Object.defineProperty(Definition.prototype, 'isRunning', {
94
- enumerable: true,
95
- get() {
96
- if (!this[kConsuming]) return false;
97
- return !!this.status;
98
- }
99
- });
100
- Object.defineProperty(Definition.prototype, 'status', {
101
- enumerable: true,
102
- get() {
103
- return this[kStatus];
104
- }
105
- });
106
- Object.defineProperty(Definition.prototype, 'stopped', {
107
- enumerable: true,
108
- get() {
109
- return this[kStopped];
110
- }
111
- });
112
- Object.defineProperty(Definition.prototype, 'activityStatus', {
113
- get() {
114
- return this[kExec].execution && this[kExec].execution.activityStatus || 'idle';
72
+ Object.defineProperties(Definition.prototype, {
73
+ counters: {
74
+ get() {
75
+ return {
76
+ ...this[kCounters]
77
+ };
78
+ }
79
+ },
80
+ execution: {
81
+ get() {
82
+ return this[kExec].execution;
83
+ }
84
+ },
85
+ executionId: {
86
+ get() {
87
+ return this[kExec].executionId;
88
+ }
89
+ },
90
+ isRunning: {
91
+ get() {
92
+ if (!this[kConsuming]) return false;
93
+ return !!this.status;
94
+ }
95
+ },
96
+ status: {
97
+ get() {
98
+ return this[kStatus];
99
+ }
100
+ },
101
+ stopped: {
102
+ get() {
103
+ return this[kStopped];
104
+ }
105
+ },
106
+ activityStatus: {
107
+ get() {
108
+ return this[kExec].execution && this[kExec].execution.activityStatus || 'idle';
109
+ }
115
110
  }
116
111
  });
117
112
  Definition.prototype.run = function run(optionsOrCallback, optionalCallback) {
@@ -62,61 +62,59 @@ function DefinitionExecution(definition, context) {
62
62
  onProcessMessage: this._onProcessMessage.bind(this)
63
63
  };
64
64
  }
65
- Object.defineProperty(DefinitionExecution.prototype, 'stopped', {
66
- enumerable: true,
67
- get() {
68
- return this[kStopped];
69
- }
70
- });
71
- Object.defineProperty(DefinitionExecution.prototype, 'completed', {
72
- enumerable: true,
73
- get() {
74
- return this[kCompleted];
75
- }
76
- });
77
- Object.defineProperty(DefinitionExecution.prototype, 'status', {
78
- enumerable: true,
79
- get() {
80
- return this[kStatus];
81
- }
82
- });
83
- Object.defineProperty(DefinitionExecution.prototype, 'processes', {
84
- enumerable: true,
85
- get() {
86
- return this[kProcesses].running;
87
- }
88
- });
89
- Object.defineProperty(DefinitionExecution.prototype, 'postponedCount', {
90
- get() {
91
- return this[kProcesses].postponed.length;
92
- }
93
- });
94
- Object.defineProperty(DefinitionExecution.prototype, 'isRunning', {
95
- get() {
96
- return this[kActivated];
97
- }
98
- });
99
- Object.defineProperty(DefinitionExecution.prototype, 'activityStatus', {
100
- get() {
101
- let status = 'idle';
102
- const running = this[kProcesses].running;
103
- if (!running || !running.length) return status;
104
- for (const bp of running) {
105
- const bpStatus = bp.activityStatus;
106
- switch (bp.activityStatus) {
107
- case 'idle':
108
- break;
109
- case 'executing':
110
- return bpStatus;
111
- case 'timer':
112
- status = bpStatus;
113
- break;
114
- case 'wait':
115
- if (status === 'idle') status = bpStatus;
116
- break;
65
+ Object.defineProperties(DefinitionExecution.prototype, {
66
+ stopped: {
67
+ get() {
68
+ return this[kStopped];
69
+ }
70
+ },
71
+ completed: {
72
+ get() {
73
+ return this[kCompleted];
74
+ }
75
+ },
76
+ status: {
77
+ get() {
78
+ return this[kStatus];
79
+ }
80
+ },
81
+ processes: {
82
+ get() {
83
+ return this[kProcesses].running;
84
+ }
85
+ },
86
+ postponedCount: {
87
+ get() {
88
+ return this[kProcesses].postponed.length;
89
+ }
90
+ },
91
+ isRunning: {
92
+ get() {
93
+ return this[kActivated];
94
+ }
95
+ },
96
+ activityStatus: {
97
+ get() {
98
+ let status = 'idle';
99
+ const running = this[kProcesses].running;
100
+ if (!running || !running.length) return status;
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
+ }
117
115
  }
116
+ return status;
118
117
  }
119
- return status;
120
118
  }
121
119
  });
122
120
  DefinitionExecution.prototype.execute = function execute(executeMessage) {
@@ -18,16 +18,16 @@ function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKe
18
18
  this[kStopped] = false;
19
19
  this[kExecuteMessage] = null;
20
20
  }
21
- Object.defineProperty(EventDefinitionExecution.prototype, 'completed', {
22
- enumerable: true,
23
- get() {
24
- return this[kCompleted];
25
- }
26
- });
27
- Object.defineProperty(EventDefinitionExecution.prototype, 'stopped', {
28
- enumerable: true,
29
- get() {
30
- return this[kStopped];
21
+ Object.defineProperties(EventDefinitionExecution.prototype, {
22
+ completed: {
23
+ get() {
24
+ return this[kCompleted];
25
+ }
26
+ },
27
+ stopped: {
28
+ get() {
29
+ return this[kStopped];
30
+ }
31
31
  }
32
32
  });
33
33
  EventDefinitionExecution.prototype.execute = function execute(executeMessage) {
@@ -27,22 +27,22 @@ function TimerEventDefinition(activity, eventDefinition) {
27
27
  this[kStopped] = false;
28
28
  this[kTimer] = null;
29
29
  }
30
- Object.defineProperty(TimerEventDefinition.prototype, 'executionId', {
31
- get() {
32
- const content = this[kTimerContent];
33
- return content && content.executionId;
34
- }
35
- });
36
- Object.defineProperty(TimerEventDefinition.prototype, 'stopped', {
37
- enumerable: true,
38
- get() {
39
- return this[kStopped];
40
- }
41
- });
42
- Object.defineProperty(TimerEventDefinition.prototype, 'timer', {
43
- enumerable: true,
44
- get() {
45
- return this[kTimer];
30
+ Object.defineProperties(TimerEventDefinition.prototype, {
31
+ executionId: {
32
+ get() {
33
+ const content = this[kTimerContent];
34
+ return content && content.executionId;
35
+ }
36
+ },
37
+ stopped: {
38
+ get() {
39
+ return this[kStopped];
40
+ }
41
+ },
42
+ timer: {
43
+ get() {
44
+ return this[kTimer];
45
+ }
46
46
  }
47
47
  });
48
48
  TimerEventDefinition.prototype.execute = function execute(executeMessage) {
@@ -29,17 +29,18 @@ function BoundaryEventBehaviour(activity) {
29
29
  this[kShovels] = [];
30
30
  this[kAttachedTags] = [];
31
31
  }
32
- Object.defineProperty(BoundaryEventBehaviour.prototype, 'executionId', {
33
- get() {
34
- const message = this[kExecuteMessage];
35
- return message && message.content.executionId;
36
- }
37
- });
38
- Object.defineProperty(BoundaryEventBehaviour.prototype, 'cancelActivity', {
39
- enumerable: true,
40
- get() {
41
- const behaviour = this.activity.behaviour || {};
42
- return 'cancelActivity' in behaviour ? behaviour.cancelActivity : true;
32
+ Object.defineProperties(BoundaryEventBehaviour.prototype, {
33
+ executionId: {
34
+ get() {
35
+ const message = this[kExecuteMessage];
36
+ return message && message.content.executionId;
37
+ }
38
+ },
39
+ cancelActivity: {
40
+ get() {
41
+ const behaviour = this.activity.behaviour || {};
42
+ return 'cancelActivity' in behaviour ? behaviour.cancelActivity : true;
43
+ }
43
44
  }
44
45
  });
45
46
  BoundaryEventBehaviour.prototype.execute = function execute(executeMessage) {