bpmn-elements 7.0.0 → 8.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 (68) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/src/Context.js +50 -40
  3. package/dist/src/Environment.js +39 -19
  4. package/dist/src/MessageFormatter.js +11 -11
  5. package/dist/src/activity/Activity.js +91 -91
  6. package/dist/src/activity/ActivityExecution.js +35 -35
  7. package/dist/src/definition/Definition.js +50 -50
  8. package/dist/src/definition/DefinitionExecution.js +114 -125
  9. package/dist/src/eventDefinitions/CancelEventDefinition.js +16 -16
  10. package/dist/src/eventDefinitions/CompensateEventDefinition.js +24 -24
  11. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  12. package/dist/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  13. package/dist/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  14. package/dist/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  15. package/dist/src/eventDefinitions/LinkEventDefinition.js +15 -15
  16. package/dist/src/eventDefinitions/MessageEventDefinition.js +23 -23
  17. package/dist/src/eventDefinitions/SignalEventDefinition.js +24 -24
  18. package/dist/src/eventDefinitions/TimerEventDefinition.js +21 -21
  19. package/dist/src/events/BoundaryEvent.js +20 -20
  20. package/dist/src/events/EndEvent.js +3 -3
  21. package/dist/src/events/IntermediateCatchEvent.js +3 -3
  22. package/dist/src/events/IntermediateThrowEvent.js +3 -3
  23. package/dist/src/events/StartEvent.js +9 -9
  24. package/dist/src/flows/Association.js +7 -7
  25. package/dist/src/flows/MessageFlow.js +9 -9
  26. package/dist/src/flows/SequenceFlow.js +7 -7
  27. package/dist/src/gateways/EventBasedGateway.js +11 -11
  28. package/dist/src/io/InputOutputSpecification.js +4 -4
  29. package/dist/src/io/Properties.js +9 -9
  30. package/dist/src/process/Process.js +64 -61
  31. package/dist/src/process/ProcessExecution.js +93 -90
  32. package/dist/src/tasks/ReceiveTask.js +16 -16
  33. package/dist/src/tasks/SubProcess.js +16 -18
  34. package/package.json +9 -9
  35. package/src/Context.js +48 -40
  36. package/src/Environment.js +48 -20
  37. package/src/EventBroker.js +1 -1
  38. package/src/MessageFormatter.js +11 -11
  39. package/src/activity/Activity.js +91 -91
  40. package/src/activity/ActivityExecution.js +34 -34
  41. package/src/definition/Definition.js +51 -50
  42. package/src/definition/DefinitionExecution.js +111 -113
  43. package/src/eventDefinitions/CancelEventDefinition.js +16 -16
  44. package/src/eventDefinitions/CompensateEventDefinition.js +25 -24
  45. package/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  46. package/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  47. package/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  48. package/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  49. package/src/eventDefinitions/LinkEventDefinition.js +15 -15
  50. package/src/eventDefinitions/MessageEventDefinition.js +23 -23
  51. package/src/eventDefinitions/SignalEventDefinition.js +24 -24
  52. package/src/eventDefinitions/TimerEventDefinition.js +21 -21
  53. package/src/events/BoundaryEvent.js +20 -20
  54. package/src/events/EndEvent.js +3 -3
  55. package/src/events/IntermediateCatchEvent.js +3 -3
  56. package/src/events/IntermediateThrowEvent.js +3 -3
  57. package/src/events/StartEvent.js +9 -9
  58. package/src/flows/Association.js +7 -7
  59. package/src/flows/MessageFlow.js +9 -9
  60. package/src/flows/SequenceFlow.js +7 -7
  61. package/src/gateways/EventBasedGateway.js +11 -11
  62. package/src/io/BpmnIO.js +5 -1
  63. package/src/io/InputOutputSpecification.js +4 -4
  64. package/src/io/Properties.js +9 -9
  65. package/src/process/Process.js +62 -58
  66. package/src/process/ProcessExecution.js +86 -88
  67. package/src/tasks/ReceiveTask.js +16 -16
  68. package/src/tasks/SubProcess.js +16 -16
@@ -20,15 +20,15 @@ var _Errors = require("../error/Errors");
20
20
 
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
22
 
23
- const consumingSymbol = Symbol.for('consuming');
24
- const countersSymbol = Symbol.for('counters');
25
- const execSymbol = Symbol.for('exec');
26
- const executeMessageSymbol = Symbol.for('executeMessage');
27
- const extensionsSymbol = Symbol.for('extensions');
28
- const messageHandlersSymbol = Symbol.for('messageHandlers');
29
- const stateMessageSymbol = Symbol.for('stateMessage');
30
- const statusSymbol = Symbol.for('status');
31
- const stoppedSymbol = Symbol.for('stopped');
23
+ const kConsuming = Symbol.for('consuming');
24
+ const kCounters = Symbol.for('counters');
25
+ const kExec = Symbol.for('execution');
26
+ const kExecuteMessage = Symbol.for('executeMessage');
27
+ const kExtensions = Symbol.for('extensions');
28
+ const kMessageHandlers = Symbol.for('messageHandlers');
29
+ const kStateMessage = Symbol.for('stateMessage');
30
+ const kStatus = Symbol.for('status');
31
+ const kStopped = Symbol.for('stopped');
32
32
  var _default = Process;
33
33
  exports.default = _default;
34
34
 
@@ -51,12 +51,14 @@ function Process(processDef, context) {
51
51
  this.isExecutable = isExecutable;
52
52
  const environment = this.environment = context.environment;
53
53
  this.context = context;
54
- this[countersSymbol] = {
54
+ this[kCounters] = {
55
55
  completed: 0,
56
56
  discarded: 0
57
57
  };
58
- this[stoppedSymbol] = false;
59
- this[execSymbol] = {};
58
+ this[kConsuming] = false;
59
+ this[kExec] = {};
60
+ this[kStatus] = undefined;
61
+ this[kStopped] = false;
60
62
  const {
61
63
  broker,
62
64
  on,
@@ -67,13 +69,13 @@ function Process(processDef, context) {
67
69
  this.on = on;
68
70
  this.once = once;
69
71
  this.waitFor = waitFor;
70
- this[messageHandlersSymbol] = {
72
+ this[kMessageHandlers] = {
71
73
  onApiMessage: this._onApiMessage.bind(this),
72
74
  onRunMessage: this._onRunMessage.bind(this),
73
75
  onExecutionMessage: this._onExecutionMessage.bind(this)
74
76
  };
75
77
  this.logger = environment.Logger(type.toLowerCase());
76
- this[extensionsSymbol] = context.loadExtensions(this);
78
+ this[kExtensions] = context.loadExtensions(this);
77
79
  }
78
80
 
79
81
  const proto = Process.prototype;
@@ -81,7 +83,7 @@ Object.defineProperty(proto, 'counters', {
81
83
  enumerable: true,
82
84
 
83
85
  get() {
84
- return { ...this[countersSymbol]
86
+ return { ...this[kCounters]
85
87
  };
86
88
  }
87
89
 
@@ -90,7 +92,7 @@ Object.defineProperty(proto, 'extensions', {
90
92
  enumerable: true,
91
93
 
92
94
  get() {
93
- return this[extensionsSymbol];
95
+ return this[kExtensions];
94
96
  }
95
97
 
96
98
  });
@@ -98,7 +100,7 @@ Object.defineProperty(proto, 'stopped', {
98
100
  enumerable: true,
99
101
 
100
102
  get() {
101
- return this[stoppedSymbol];
103
+ return this[kStopped];
102
104
  }
103
105
 
104
106
  });
@@ -106,7 +108,7 @@ Object.defineProperty(proto, 'isRunning', {
106
108
  enumerable: true,
107
109
 
108
110
  get() {
109
- if (!this[consumingSymbol]) return false;
111
+ if (!this[kConsuming]) return false;
110
112
  return !!this.status;
111
113
  }
112
114
 
@@ -118,7 +120,7 @@ Object.defineProperty(proto, 'executionId', {
118
120
  const {
119
121
  executionId,
120
122
  initExecutionId
121
- } = this[execSymbol];
123
+ } = this[kExec];
122
124
  return executionId || initExecutionId;
123
125
  }
124
126
 
@@ -127,7 +129,7 @@ Object.defineProperty(proto, 'execution', {
127
129
  enumerable: true,
128
130
 
129
131
  get() {
130
- return this[execSymbol].execution;
132
+ return this[kExec].execution;
131
133
  }
132
134
 
133
135
  });
@@ -135,13 +137,13 @@ Object.defineProperty(proto, 'status', {
135
137
  enumerable: true,
136
138
 
137
139
  get() {
138
- return this[statusSymbol];
140
+ return this[kStatus];
139
141
  }
140
142
 
141
143
  });
142
144
 
143
145
  proto.init = function init(useAsExecutionId) {
144
- const exec = this[execSymbol];
146
+ const exec = this[kExec];
145
147
  const initExecutionId = exec.initExecutionId = useAsExecutionId || (0, _shared.getUniqueId)(this.id);
146
148
 
147
149
  this._debug(`initialized with executionId <${initExecutionId}>`);
@@ -153,7 +155,7 @@ proto.init = function init(useAsExecutionId) {
153
155
 
154
156
  proto.run = function run(runContent) {
155
157
  if (this.isRunning) throw new Error(`process <${this.id}> is already running`);
156
- const exec = this[execSymbol];
158
+ const exec = this[kExec];
157
159
  const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(this.id);
158
160
  exec.initExecutionId = undefined;
159
161
 
@@ -172,7 +174,7 @@ proto.run = function run(runContent) {
172
174
  proto.resume = function resume() {
173
175
  if (this.isRunning) throw new Error(`cannot resume running process <${this.id}>`);
174
176
  if (!this.status) return this;
175
- this[stoppedSymbol] = false;
177
+ this[kStopped] = false;
176
178
 
177
179
  const content = this._createMessage();
178
180
 
@@ -188,11 +190,11 @@ proto.resume = function resume() {
188
190
  proto.recover = function recover(state) {
189
191
  if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
190
192
  if (!state) return this;
191
- this[stoppedSymbol] = !!state.stopped;
192
- this[statusSymbol] = state.status;
193
- const exec = this[execSymbol];
193
+ this[kStopped] = !!state.stopped;
194
+ this[kStatus] = state.status;
195
+ const exec = this[kExec];
194
196
  exec.executionId = state.executionId;
195
- this[countersSymbol] = { ...this[countersSymbol],
197
+ this[kCounters] = { ...this[kCounters],
196
198
  ...state.counters
197
199
  };
198
200
  this.environment.recover(state.environment);
@@ -218,7 +220,7 @@ proto.stop = function stop() {
218
220
  proto.getApi = function getApi(message) {
219
221
  const execution = this.execution;
220
222
  if (execution) return execution.getApi(message);
221
- return (0, _Api.ProcessApi)(this.broker, message || this[stateMessageSymbol]);
223
+ return (0, _Api.ProcessApi)(this.broker, message || this[kStateMessage]);
222
224
  };
223
225
 
224
226
  proto.signal = function signal(message) {
@@ -234,9 +236,7 @@ proto.getState = function getState() {
234
236
  stopped: this.stopped,
235
237
  counters: this.counters,
236
238
  broker: this.broker.getState(true),
237
- execution: this.execution && this.execution.getState(),
238
- output: { ...this.environment.output
239
- }
239
+ execution: this.execution && this.execution.getState()
240
240
  });
241
241
  };
242
242
 
@@ -247,12 +247,12 @@ proto.cancelActivity = function cancelActivity(message) {
247
247
  };
248
248
 
249
249
  proto._activateRunConsumers = function activateRunConsumers() {
250
- this[consumingSymbol] = true;
250
+ this[kConsuming] = true;
251
251
  const broker = this.broker;
252
252
  const {
253
253
  onApiMessage,
254
254
  onRunMessage
255
- } = this[messageHandlersSymbol];
255
+ } = this[kMessageHandlers];
256
256
  broker.subscribeTmp('api', `process.*.${this.executionId}`, onApiMessage, {
257
257
  noAck: true,
258
258
  consumerTag: '_process-api',
@@ -269,7 +269,7 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
269
269
  broker.cancel('_process-api');
270
270
  broker.cancel('_process-run');
271
271
  broker.cancel('_process-execution');
272
- this[consumingSymbol] = false;
272
+ this[kConsuming] = false;
273
273
  };
274
274
 
275
275
  proto._onRunMessage = function onRunMessage(routingKey, message) {
@@ -282,15 +282,15 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
282
282
  return this._onResumeMessage(message);
283
283
  }
284
284
 
285
- const exec = this[execSymbol];
286
- this[stateMessageSymbol] = message;
285
+ const exec = this[kExec];
286
+ this[kStateMessage] = message;
287
287
 
288
288
  switch (routingKey) {
289
289
  case 'run.enter':
290
290
  {
291
291
  this._debug('enter');
292
292
 
293
- this[statusSymbol] = 'entered';
293
+ this[kStatus] = 'entered';
294
294
  if (fields.redelivered) break;
295
295
  exec.execution = undefined;
296
296
 
@@ -303,7 +303,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
303
303
  {
304
304
  this._debug('start');
305
305
 
306
- this[statusSymbol] = 'start';
306
+ this[kStatus] = 'start';
307
307
 
308
308
  this._publishEvent('start', content);
309
309
 
@@ -312,15 +312,15 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
312
312
 
313
313
  case 'run.execute':
314
314
  {
315
- this[statusSymbol] = 'executing';
315
+ this[kStatus] = 'executing';
316
316
  const executeMessage = (0, _messageHelper.cloneMessage)(message);
317
317
 
318
318
  if (fields.redelivered && !exec.execution) {
319
319
  executeMessage.fields.redelivered = undefined;
320
320
  }
321
321
 
322
- this[executeMessageSymbol] = message;
323
- this.broker.getQueue('execution-q').assertConsumer(this[messageHandlersSymbol].onExecutionMessage, {
322
+ this[kExecuteMessage] = message;
323
+ this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
324
324
  exclusive: true,
325
325
  consumerTag: '_process-execution'
326
326
  });
@@ -330,6 +330,8 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
330
330
 
331
331
  case 'run.error':
332
332
  {
333
+ this[kStatus] = 'errored';
334
+
333
335
  this._publishEvent('error', (0, _messageHelper.cloneContent)(content, {
334
336
  error: fields.redelivered ? (0, _Errors.makeErrorFromMessage)(message) : content.error
335
337
  }));
@@ -339,12 +341,12 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
339
341
 
340
342
  case 'run.end':
341
343
  {
342
- this[statusSymbol] = 'end';
344
+ this[kStatus] = 'end';
343
345
  if (fields.redelivered) break;
344
346
 
345
347
  this._debug('completed');
346
348
 
347
- this[countersSymbol].completed++;
349
+ this[kCounters].completed++;
348
350
  this.broker.publish('run', 'run.leave', content);
349
351
 
350
352
  this._publishEvent('end', content);
@@ -354,9 +356,9 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
354
356
 
355
357
  case 'run.discarded':
356
358
  {
357
- this[statusSymbol] = 'discarded';
359
+ this[kStatus] = 'discarded';
358
360
  if (fields.redelivered) break;
359
- this[countersSymbol].discarded++;
361
+ this[kCounters].discarded++;
360
362
  this.broker.publish('run', 'run.leave', content);
361
363
 
362
364
  this._publishEvent('discarded', content);
@@ -366,7 +368,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
366
368
 
367
369
  case 'run.leave':
368
370
  {
369
- this[statusSymbol] = undefined;
371
+ this[kStatus] = undefined;
370
372
  this.broker.cancel('_process-api');
371
373
  const {
372
374
  output,
@@ -384,7 +386,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
384
386
 
385
387
  proto._onResumeMessage = function onResumeMessage(message) {
386
388
  message.ack();
387
- const stateMessage = this[stateMessageSymbol];
389
+ const stateMessage = this[kStateMessage];
388
390
 
389
391
  switch (stateMessage.fields.routingKey) {
390
392
  case 'run.enter':
@@ -433,12 +435,9 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
433
435
  }
434
436
  }
435
437
 
436
- const executeMessage = this[executeMessageSymbol];
437
-
438
- if (executeMessage) {
439
- this[executeMessageSymbol] = null;
440
- executeMessage.ack();
441
- }
438
+ const executeMessage = this[kExecuteMessage];
439
+ this[kExecuteMessage] = null;
440
+ executeMessage.ack();
442
441
  };
443
442
 
444
443
  proto._publishEvent = function publishEvent(state, content) {
@@ -453,7 +452,7 @@ proto._publishEvent = function publishEvent(state, content) {
453
452
  };
454
453
 
455
454
  proto.sendMessage = function sendMessage(message) {
456
- const messageContent = message.content;
455
+ const messageContent = message && message.content;
457
456
  if (!messageContent) return;
458
457
  let targetsFound = false;
459
458
 
@@ -474,12 +473,14 @@ proto.sendMessage = function sendMessage(message) {
474
473
  };
475
474
 
476
475
  proto.getActivityById = function getActivityById(childId) {
477
- if (this.execution) return this.execution.getActivityById(childId);
476
+ const execution = this.execution;
477
+ if (execution) return execution.getActivityById(childId);
478
478
  return this.context.getActivityById(childId);
479
479
  };
480
480
 
481
481
  proto.getActivities = function getActivities() {
482
- if (this.execution) return this.execution.getActivities();
482
+ const execution = this.execution;
483
+ if (execution) return execution.getActivities();
483
484
  return this.context.getActivities(this.id);
484
485
  };
485
486
 
@@ -488,13 +489,15 @@ proto.getStartActivities = function getStartActivities(filterOptions) {
488
489
  };
489
490
 
490
491
  proto.getSequenceFlows = function getSequenceFlows() {
491
- if (this.execution) return this.execution.getSequenceFlows();
492
+ const execution = this.execution;
493
+ if (execution) return execution.getSequenceFlows();
492
494
  return this.context.getSequenceFlows();
493
495
  };
494
496
 
495
497
  proto.getPostponed = function getPostponed(...args) {
496
- if (!this.execution) return [];
497
- return this.execution.getPostponed(...args);
498
+ const execution = this.execution;
499
+ if (!execution) return [];
500
+ return execution.getPostponed(...args);
498
501
  };
499
502
 
500
503
  proto._onApiMessage = function onApiMessage(routingKey, message) {
@@ -513,7 +516,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
513
516
  };
514
517
 
515
518
  proto._onStop = function onStop() {
516
- this[stoppedSymbol] = true;
519
+ this[kStopped] = true;
517
520
 
518
521
  this._deactivateRunConsumers();
519
522