bpmn-elements 12.0.0 → 13.1.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 (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/Environment.js +15 -15
  3. package/dist/activity/Activity.js +125 -142
  4. package/dist/activity/ActivityExecution.js +0 -1
  5. package/dist/definition/Definition.js +38 -42
  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 +3 -2
  12. package/dist/flows/MessageFlow.js +3 -2
  13. package/dist/flows/SequenceFlow.js +3 -2
  14. package/dist/gateways/index.js +49 -0
  15. package/dist/process/Process.js +53 -59
  16. package/dist/process/ProcessExecution.js +40 -35
  17. package/dist/tasks/SubProcess.js +2 -2
  18. package/dist/tasks/index.js +93 -0
  19. package/events.d.ts +1 -0
  20. package/gateways.d.ts +1 -0
  21. package/index.d.ts +1 -0
  22. package/package.json +39 -19
  23. package/src/Environment.js +16 -17
  24. package/src/activity/Activity.js +100 -132
  25. package/src/activity/ActivityExecution.js +0 -1
  26. package/src/definition/Definition.js +30 -40
  27. package/src/definition/DefinitionExecution.js +47 -55
  28. package/src/eventDefinitions/EventDefinitionExecution.js +9 -10
  29. package/src/eventDefinitions/TimerEventDefinition.js +14 -16
  30. package/src/events/BoundaryEvent.js +11 -11
  31. package/src/events/index.js +5 -0
  32. package/src/flows/Association.js +4 -2
  33. package/src/flows/MessageFlow.js +4 -2
  34. package/src/flows/SequenceFlow.js +4 -2
  35. package/src/gateways/index.js +4 -0
  36. package/src/process/Process.js +40 -54
  37. package/src/process/ProcessExecution.js +37 -35
  38. package/src/tasks/SubProcess.js +2 -2
  39. package/src/tasks/index.js +8 -0
  40. package/tasks.d.ts +1 -0
  41. package/types/index.d.ts +69 -767
  42. package/types/types.d.ts +721 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ # 13.1.0
5
+
6
+ - introduce `disableTrackState` setting. Tracking of elements is done by counters, e.g. activity taken or discarded, sequence flow taken and discarded. Counters are saved when getting state. If you run really big flows the state will keep all elements just to be able to recover the number of times an element has been touched. Needless to say it the state will grow out of it's comfort zone. Setting `disableTrackState` to true will only return state for elements that are actually running
7
+
8
+ ## Breaking
9
+
10
+ - `getState()` can return undefined
11
+
12
+ # 13.0.0
13
+
14
+ - export task-, events-, and gateway activity behaviors through `bpmn-elements/tasks`, `bpmn-elements/events`, and `bpmn-elements/gateways` respectively
15
+ - 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
16
+ - use `Object.defineProperties` when feasible and skip pointless enumerable option on property
17
+
4
18
  # 12.0.0
5
19
 
6
20
  Memory issues running sequential multi-instance sub-process (MISP). All MISP executions are put in a list to be able to save state.
@@ -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() {
@@ -114,147 +114,128 @@ function Activity(Behaviour, activityDef, context) {
114
114
  this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed, this.context));
115
115
  this[kExtensions] = context.loadExtensions(this);
116
116
  }
117
- Object.defineProperty(Activity.prototype, 'counters', {
118
- enumerable: true,
119
- get() {
120
- return {
121
- ...this[kCounters]
122
- };
123
- }
124
- });
125
- Object.defineProperty(Activity.prototype, 'execution', {
126
- enumerable: true,
127
- get() {
128
- return this[kExec].execution;
129
- }
130
- });
131
- Object.defineProperty(Activity.prototype, 'executionId', {
132
- enumerable: true,
133
- get() {
134
- return this[kExec].executionId;
135
- }
136
- });
137
- Object.defineProperty(Activity.prototype, 'extensions', {
138
- enumerable: true,
139
- get() {
140
- return this[kExtensions];
141
- }
142
- });
143
- Object.defineProperty(Activity.prototype, 'bpmnIo', {
144
- enumerable: true,
145
- get() {
146
- const extensions = this[kExtensions];
147
- return extensions && extensions.extensions.find(e => e.type === 'bpmnio');
148
- }
149
- });
150
- Object.defineProperty(Activity.prototype, 'formatter', {
151
- enumerable: true,
152
- get() {
153
- let formatter = this[kFormatter];
154
- if (formatter) return formatter;
155
- const broker = this.broker;
156
- formatter = this[kFormatter] = new _MessageFormatter.Formatter({
157
- id: this.id,
158
- broker,
159
- logger: this.logger
160
- }, broker.getQueue('format-run-q'));
161
- return formatter;
162
- }
163
- });
164
- Object.defineProperty(Activity.prototype, 'isRunning', {
165
- enumerable: true,
166
- get() {
167
- if (!this[kConsuming]) return false;
168
- return !!this.status;
169
- }
170
- });
171
- Object.defineProperty(Activity.prototype, 'outbound', {
172
- enumerable: true,
173
- get() {
174
- return this[kFlows].outboundSequenceFlows;
175
- }
176
- });
177
- Object.defineProperty(Activity.prototype, 'inbound', {
178
- enumerable: true,
179
- get() {
180
- return this[kFlows].inboundSequenceFlows;
181
- }
182
- });
183
- Object.defineProperty(Activity.prototype, 'isEnd', {
184
- enumerable: true,
185
- get() {
186
- return this[kFlags].isEnd;
187
- }
188
- });
189
- Object.defineProperty(Activity.prototype, 'isStart', {
190
- enumerable: true,
191
- get() {
192
- return this[kFlags].isStart;
193
- }
194
- });
195
- Object.defineProperty(Activity.prototype, 'isSubProcess', {
196
- enumerable: true,
197
- get() {
198
- return this[kFlags].isSubProcess;
199
- }
200
- });
201
- Object.defineProperty(Activity.prototype, 'isTransaction', {
202
- enumerable: true,
203
- get() {
204
- return this[kFlags].isTransaction;
205
- }
206
- });
207
- Object.defineProperty(Activity.prototype, 'isMultiInstance', {
208
- enumerable: true,
209
- get() {
210
- return this[kFlags].isMultiInstance;
211
- }
212
- });
213
- Object.defineProperty(Activity.prototype, 'isThrowing', {
214
- enumerable: true,
215
- get() {
216
- return this[kFlags].isThrowing;
217
- }
218
- });
219
- Object.defineProperty(Activity.prototype, 'isForCompensation', {
220
- enumerable: true,
221
- get() {
222
- return this[kFlags].isForCompensation;
223
- }
224
- });
225
- Object.defineProperty(Activity.prototype, 'triggeredByEvent', {
226
- enumerable: true,
227
- get() {
228
- return this[kActivityDef].triggeredByEvent;
229
- }
230
- });
231
- Object.defineProperty(Activity.prototype, 'attachedTo', {
232
- enumerable: true,
233
- get() {
234
- const attachedToId = this[kFlags].attachedTo;
235
- if (!attachedToId) return null;
236
- return this.getActivityById(attachedToId);
237
- }
238
- });
239
- Object.defineProperty(Activity.prototype, 'lane', {
240
- enumerable: true,
241
- get() {
242
- const laneId = this[kFlags].lane;
243
- if (!laneId) return undefined;
244
- const parent = this.parentElement;
245
- return parent.getLaneById && parent.getLaneById(laneId);
246
- }
247
- });
248
- Object.defineProperty(Activity.prototype, 'eventDefinitions', {
249
- enumerable: true,
250
- get() {
251
- return this[kEventDefinitions];
252
- }
253
- });
254
- Object.defineProperty(Activity.prototype, 'parentElement', {
255
- enumerable: true,
256
- get() {
257
- 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
+ }
258
239
  }
259
240
  });
260
241
  Activity.prototype.activate = function activate() {
@@ -298,6 +279,8 @@ Activity.prototype.run = function run(runContent) {
298
279
  Activity.prototype.getState = function getState() {
299
280
  const status = this.status;
300
281
  const exec = this[kExec];
282
+ const brokerState = this.broker.getState(true);
283
+ if (!brokerState && this.environment.settings.disableTrackState) return;
301
284
  return {
302
285
  id: this.id,
303
286
  type: this.type,
@@ -307,7 +290,7 @@ Activity.prototype.getState = function getState() {
307
290
  executionId: exec.executionId,
308
291
  stopped: this.stopped,
309
292
  counters: this.counters,
310
- broker: this.broker.getState(true),
293
+ broker: brokerState,
311
294
  execution: exec.execution && exec.execution.getState()
312
295
  };
313
296
  };
@@ -29,7 +29,6 @@ function ActivityExecution(activity, context) {
29
29
  };
30
30
  }
31
31
  Object.defineProperty(ActivityExecution.prototype, 'completed', {
32
- enumerable: true,
33
32
  get() {
34
33
  return this[kCompleted];
35
34
  }
@@ -69,48 +69,44 @@ function Definition(context, options) {
69
69
  this.emitFatal = emitFatal;
70
70
  this.logger = environment.Logger(type.toLowerCase());
71
71
  }
72
- Object.defineProperty(Definition.prototype, 'counters', {
73
- enumerable: true,
74
- get() {
75
- return {
76
- ...this[kCounters]
77
- };
78
- }
79
- });
80
- Object.defineProperty(Definition.prototype, 'execution', {
81
- enumerable: true,
82
- get() {
83
- return this[kExec].execution;
84
- }
85
- });
86
- Object.defineProperty(Definition.prototype, 'executionId', {
87
- enumerable: true,
88
- get() {
89
- return this[kExec].executionId;
90
- }
91
- });
92
- Object.defineProperty(Definition.prototype, 'isRunning', {
93
- enumerable: true,
94
- get() {
95
- if (!this[kConsuming]) return false;
96
- return !!this.status;
97
- }
98
- });
99
- Object.defineProperty(Definition.prototype, 'status', {
100
- enumerable: true,
101
- get() {
102
- return this[kStatus];
103
- }
104
- });
105
- Object.defineProperty(Definition.prototype, 'stopped', {
106
- enumerable: true,
107
- get() {
108
- return this[kStopped];
109
- }
110
- });
111
- Object.defineProperty(Definition.prototype, 'activityStatus', {
112
- get() {
113
- 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
+ }
114
110
  }
115
111
  });
116
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) {