bpmn-elements 8.2.0 → 8.2.1

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 (74) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/index.js +0 -49
  3. package/dist/src/Api.js +4 -19
  4. package/dist/src/Context.js +0 -35
  5. package/dist/src/Environment.js +18 -44
  6. package/dist/src/EventBroker.js +8 -27
  7. package/dist/src/Expressions.js +0 -13
  8. package/dist/src/ExtensionsMapper.js +0 -12
  9. package/dist/src/MessageFormatter.js +0 -33
  10. package/dist/src/Scripts.js +2 -9
  11. package/dist/src/Timers.js +0 -9
  12. package/dist/src/activity/Activity.js +39 -243
  13. package/dist/src/activity/ActivityExecution.js +8 -76
  14. package/dist/src/activity/Dummy.js +2 -3
  15. package/dist/src/activity/Escalation.js +4 -4
  16. package/dist/src/activity/ExecutionScope.js +0 -4
  17. package/dist/src/activity/Message.js +4 -4
  18. package/dist/src/activity/Signal.js +4 -4
  19. package/dist/src/definition/Definition.js +12 -133
  20. package/dist/src/definition/DefinitionExecution.js +10 -160
  21. package/dist/src/error/BpmnError.js +2 -3
  22. package/dist/src/error/Errors.js +0 -16
  23. package/dist/src/eventDefinitions/CancelEventDefinition.js +2 -35
  24. package/dist/src/eventDefinitions/CompensateEventDefinition.js +3 -34
  25. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +3 -42
  26. package/dist/src/eventDefinitions/ErrorEventDefinition.js +11 -41
  27. package/dist/src/eventDefinitions/EscalationEventDefinition.js +7 -37
  28. package/dist/src/eventDefinitions/EventDefinitionExecution.js +0 -30
  29. package/dist/src/eventDefinitions/LinkEventDefinition.js +11 -37
  30. package/dist/src/eventDefinitions/MessageEventDefinition.js +11 -44
  31. package/dist/src/eventDefinitions/SignalEventDefinition.js +9 -46
  32. package/dist/src/eventDefinitions/TerminateEventDefinition.js +0 -3
  33. package/dist/src/eventDefinitions/TimerEventDefinition.js +8 -52
  34. package/dist/src/events/BoundaryEvent.js +4 -44
  35. package/dist/src/events/EndEvent.js +2 -11
  36. package/dist/src/events/IntermediateCatchEvent.js +0 -13
  37. package/dist/src/events/IntermediateThrowEvent.js +2 -11
  38. package/dist/src/events/StartEvent.js +5 -25
  39. package/dist/src/flows/Association.js +4 -27
  40. package/dist/src/flows/MessageFlow.js +6 -18
  41. package/dist/src/flows/SequenceFlow.js +4 -39
  42. package/dist/src/gateways/EventBasedGateway.js +0 -21
  43. package/dist/src/gateways/ExclusiveGateway.js +0 -6
  44. package/dist/src/gateways/InclusiveGateway.js +0 -6
  45. package/dist/src/gateways/ParallelGateway.js +2 -7
  46. package/dist/src/getPropertyValue.js +0 -30
  47. package/dist/src/io/BpmnIO.js +2 -7
  48. package/dist/src/io/EnvironmentDataObject.js +0 -8
  49. package/dist/src/io/EnvironmentDataStore.js +0 -8
  50. package/dist/src/io/EnvironmentDataStoreReference.js +0 -8
  51. package/dist/src/io/InputOutputSpecification.js +12 -37
  52. package/dist/src/io/Properties.js +6 -39
  53. package/dist/src/messageHelper.js +10 -23
  54. package/dist/src/process/Process.js +10 -112
  55. package/dist/src/process/ProcessExecution.js +14 -170
  56. package/dist/src/shared.js +0 -7
  57. package/dist/src/tasks/CallActivity.js +2 -23
  58. package/dist/src/tasks/LoopCharacteristics.js +16 -67
  59. package/dist/src/tasks/ReceiveTask.js +8 -48
  60. package/dist/src/tasks/ScriptTask.js +1 -15
  61. package/dist/src/tasks/ServiceImplementation.js +0 -4
  62. package/dist/src/tasks/ServiceTask.js +0 -20
  63. package/dist/src/tasks/SignalTask.js +2 -21
  64. package/dist/src/tasks/StandardLoopCharacteristics.js +4 -5
  65. package/dist/src/tasks/SubProcess.js +4 -52
  66. package/dist/src/tasks/Task.js +0 -8
  67. package/dist/src/tasks/Transaction.js +0 -3
  68. package/package.json +7 -7
  69. package/src/Context.js +0 -1
  70. package/src/activity/Activity.js +1 -1
  71. package/src/gateways/EventBasedGateway.js +0 -1
  72. package/src/io/InputOutputSpecification.js +0 -1
  73. package/src/process/ProcessExecution.js +2 -1
  74. package/src/tasks/StandardLoopCharacteristics.js +0 -1
@@ -5,21 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Process = Process;
7
7
  exports.default = void 0;
8
-
9
8
  var _ProcessExecution = _interopRequireDefault(require("./ProcessExecution"));
10
-
11
9
  var _shared = require("../shared");
12
-
13
10
  var _Api = require("../Api");
14
-
15
11
  var _EventBroker = require("../EventBroker");
16
-
17
12
  var _messageHelper = require("../messageHelper");
18
-
19
13
  var _Errors = require("../error/Errors");
20
-
21
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
-
23
15
  const kConsuming = Symbol.for('consuming');
24
16
  const kCounters = Symbol.for('counters');
25
17
  const kExec = Symbol.for('execution');
@@ -31,7 +23,6 @@ const kStatus = Symbol.for('status');
31
23
  const kStopped = Symbol.for('stopped');
32
24
  var _default = Process;
33
25
  exports.default = _default;
34
-
35
26
  function Process(processDef, context) {
36
27
  const {
37
28
  id,
@@ -77,45 +68,36 @@ function Process(processDef, context) {
77
68
  this.logger = environment.Logger(type.toLowerCase());
78
69
  this[kExtensions] = context.loadExtensions(this);
79
70
  }
80
-
81
71
  const proto = Process.prototype;
82
72
  Object.defineProperty(proto, 'counters', {
83
73
  enumerable: true,
84
-
85
74
  get() {
86
- return { ...this[kCounters]
75
+ return {
76
+ ...this[kCounters]
87
77
  };
88
78
  }
89
-
90
79
  });
91
80
  Object.defineProperty(proto, 'extensions', {
92
81
  enumerable: true,
93
-
94
82
  get() {
95
83
  return this[kExtensions];
96
84
  }
97
-
98
85
  });
99
86
  Object.defineProperty(proto, 'stopped', {
100
87
  enumerable: true,
101
-
102
88
  get() {
103
89
  return this[kStopped];
104
90
  }
105
-
106
91
  });
107
92
  Object.defineProperty(proto, 'isRunning', {
108
93
  enumerable: true,
109
-
110
94
  get() {
111
95
  if (!this[kConsuming]) return false;
112
96
  return !!this.status;
113
97
  }
114
-
115
98
  });
116
99
  Object.defineProperty(proto, 'executionId', {
117
100
  enumerable: true,
118
-
119
101
  get() {
120
102
  const {
121
103
  executionId,
@@ -123,70 +105,53 @@ Object.defineProperty(proto, 'executionId', {
123
105
  } = this[kExec];
124
106
  return executionId || initExecutionId;
125
107
  }
126
-
127
108
  });
128
109
  Object.defineProperty(proto, 'execution', {
129
110
  enumerable: true,
130
-
131
111
  get() {
132
112
  return this[kExec].execution;
133
113
  }
134
-
135
114
  });
136
115
  Object.defineProperty(proto, 'status', {
137
116
  enumerable: true,
138
-
139
117
  get() {
140
118
  return this[kStatus];
141
119
  }
142
-
143
120
  });
144
-
145
121
  proto.init = function init(useAsExecutionId) {
146
122
  const exec = this[kExec];
147
123
  const initExecutionId = exec.initExecutionId = useAsExecutionId || (0, _shared.getUniqueId)(this.id);
148
-
149
124
  this._debug(`initialized with executionId <${initExecutionId}>`);
150
-
151
125
  this._publishEvent('init', this._createMessage({
152
126
  executionId: initExecutionId
153
127
  }));
154
128
  };
155
-
156
129
  proto.run = function run(runContent) {
157
130
  if (this.isRunning) throw new Error(`process <${this.id}> is already running`);
158
131
  const exec = this[kExec];
159
132
  const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(this.id);
160
133
  exec.initExecutionId = undefined;
161
-
162
- const content = this._createMessage({ ...runContent,
134
+ const content = this._createMessage({
135
+ ...runContent,
163
136
  executionId
164
137
  });
165
-
166
138
  const broker = this.broker;
167
139
  broker.publish('run', 'run.enter', content);
168
140
  broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
169
141
  broker.publish('run', 'run.execute', (0, _messageHelper.cloneContent)(content));
170
-
171
142
  this._activateRunConsumers();
172
143
  };
173
-
174
144
  proto.resume = function resume() {
175
145
  if (this.isRunning) throw new Error(`cannot resume running process <${this.id}>`);
176
146
  if (!this.status) return this;
177
147
  this[kStopped] = false;
178
-
179
148
  const content = this._createMessage();
180
-
181
149
  this.broker.publish('run', 'run.resume', content, {
182
150
  persistent: false
183
151
  });
184
-
185
152
  this._activateRunConsumers();
186
-
187
153
  return this;
188
154
  };
189
-
190
155
  proto.recover = function recover(state) {
191
156
  if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
192
157
  if (!state) return this;
@@ -194,41 +159,35 @@ proto.recover = function recover(state) {
194
159
  this[kStatus] = state.status;
195
160
  const exec = this[kExec];
196
161
  exec.executionId = state.executionId;
197
- this[kCounters] = { ...this[kCounters],
162
+ this[kCounters] = {
163
+ ...this[kCounters],
198
164
  ...state.counters
199
165
  };
200
166
  this.environment.recover(state.environment);
201
-
202
167
  if (state.execution) {
203
168
  exec.execution = new _ProcessExecution.default(this, this.context).recover(state.execution);
204
169
  }
205
-
206
170
  this.broker.recover(state.broker);
207
171
  return this;
208
172
  };
209
-
210
173
  proto.shake = function shake(startId) {
211
174
  if (this.isRunning) return this.execution.shake(startId);
212
175
  return new _ProcessExecution.default(this, this.context).shake(startId);
213
176
  };
214
-
215
177
  proto.stop = function stop() {
216
178
  if (!this.isRunning) return;
217
179
  this.getApi().stop();
218
180
  };
219
-
220
181
  proto.getApi = function getApi(message) {
221
182
  const execution = this.execution;
222
183
  if (execution) return execution.getApi(message);
223
184
  return (0, _Api.ProcessApi)(this.broker, message || this[kStateMessage]);
224
185
  };
225
-
226
186
  proto.signal = function signal(message) {
227
187
  return this.getApi().signal(message, {
228
188
  delegate: true
229
189
  });
230
190
  };
231
-
232
191
  proto.getState = function getState() {
233
192
  return this._createMessage({
234
193
  environment: this.environment.getState(),
@@ -239,13 +198,11 @@ proto.getState = function getState() {
239
198
  execution: this.execution && this.execution.getState()
240
199
  });
241
200
  };
242
-
243
201
  proto.cancelActivity = function cancelActivity(message) {
244
202
  return this.getApi().cancel(message, {
245
203
  delegate: true
246
204
  });
247
205
  };
248
-
249
206
  proto._activateRunConsumers = function activateRunConsumers() {
250
207
  this[kConsuming] = true;
251
208
  const broker = this.broker;
@@ -263,7 +220,6 @@ proto._activateRunConsumers = function activateRunConsumers() {
263
220
  consumerTag: '_process-run'
264
221
  });
265
222
  };
266
-
267
223
  proto._deactivateRunConsumers = function deactivateRunConsumers() {
268
224
  const broker = this.broker;
269
225
  broker.cancel('_process-api');
@@ -271,54 +227,40 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
271
227
  broker.cancel('_process-execution');
272
228
  this[kConsuming] = false;
273
229
  };
274
-
275
230
  proto._onRunMessage = function onRunMessage(routingKey, message) {
276
231
  const {
277
232
  content,
278
233
  fields
279
234
  } = message;
280
-
281
235
  if (routingKey === 'run.resume') {
282
236
  return this._onResumeMessage(message);
283
237
  }
284
-
285
238
  const exec = this[kExec];
286
239
  this[kStateMessage] = message;
287
-
288
240
  switch (routingKey) {
289
241
  case 'run.enter':
290
242
  {
291
243
  this._debug('enter');
292
-
293
244
  this[kStatus] = 'entered';
294
245
  if (fields.redelivered) break;
295
246
  exec.execution = undefined;
296
-
297
247
  this._publishEvent('enter', content);
298
-
299
248
  break;
300
249
  }
301
-
302
250
  case 'run.start':
303
251
  {
304
252
  this._debug('start');
305
-
306
253
  this[kStatus] = 'start';
307
-
308
254
  this._publishEvent('start', content);
309
-
310
255
  break;
311
256
  }
312
-
313
257
  case 'run.execute':
314
258
  {
315
259
  this[kStatus] = 'executing';
316
260
  const executeMessage = (0, _messageHelper.cloneMessage)(message);
317
-
318
261
  if (fields.redelivered && !exec.execution) {
319
262
  executeMessage.fields.redelivered = undefined;
320
263
  }
321
-
322
264
  this[kExecuteMessage] = message;
323
265
  this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {
324
266
  exclusive: true,
@@ -327,45 +269,33 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
327
269
  const execution = exec.execution = exec.execution || new _ProcessExecution.default(this, this.context);
328
270
  return execution.execute(executeMessage);
329
271
  }
330
-
331
272
  case 'run.error':
332
273
  {
333
274
  this[kStatus] = 'errored';
334
-
335
275
  this._publishEvent('error', (0, _messageHelper.cloneContent)(content, {
336
276
  error: fields.redelivered ? (0, _Errors.makeErrorFromMessage)(message) : content.error
337
277
  }));
338
-
339
278
  break;
340
279
  }
341
-
342
280
  case 'run.end':
343
281
  {
344
282
  this[kStatus] = 'end';
345
283
  if (fields.redelivered) break;
346
-
347
284
  this._debug('completed');
348
-
349
285
  this[kCounters].completed++;
350
286
  this.broker.publish('run', 'run.leave', content);
351
-
352
287
  this._publishEvent('end', content);
353
-
354
288
  break;
355
289
  }
356
-
357
290
  case 'run.discarded':
358
291
  {
359
292
  this[kStatus] = 'discarded';
360
293
  if (fields.redelivered) break;
361
294
  this[kCounters].discarded++;
362
295
  this.broker.publish('run', 'run.leave', content);
363
-
364
296
  this._publishEvent('discarded', content);
365
-
366
297
  break;
367
298
  }
368
-
369
299
  case 'run.leave':
370
300
  {
371
301
  this[kStatus] = undefined;
@@ -374,20 +304,15 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
374
304
  output,
375
305
  ...rest
376
306
  } = content; // eslint-disable-line no-unused-vars
377
-
378
307
  this._publishEvent('leave', rest);
379
-
380
308
  break;
381
309
  }
382
310
  }
383
-
384
311
  message.ack();
385
312
  };
386
-
387
313
  proto._onResumeMessage = function onResumeMessage(message) {
388
314
  message.ack();
389
315
  const stateMessage = this[kStateMessage];
390
-
391
316
  switch (stateMessage.fields.routingKey) {
392
317
  case 'run.enter':
393
318
  case 'run.start':
@@ -395,67 +320,54 @@ proto._onResumeMessage = function onResumeMessage(message) {
395
320
  case 'run.end':
396
321
  case 'run.leave':
397
322
  break;
398
-
399
323
  default:
400
324
  return;
401
325
  }
402
-
403
326
  if (!stateMessage.fields.redelivered) return;
404
-
405
327
  this._debug(`resume from ${this.status}`);
406
-
407
328
  return this.broker.publish('run', stateMessage.fields.routingKey, (0, _messageHelper.cloneContent)(stateMessage.content), stateMessage.properties);
408
329
  };
409
-
410
330
  proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
411
331
  const content = message.content;
412
332
  const messageType = message.properties.type;
413
333
  message.ack();
414
-
415
334
  switch (messageType) {
416
335
  case 'stopped':
417
336
  {
418
337
  return this._onStop();
419
338
  }
420
-
421
339
  case 'error':
422
340
  {
423
341
  this.broker.publish('run', 'run.error', content);
424
342
  this.broker.publish('run', 'run.discarded', content);
425
343
  break;
426
344
  }
427
-
428
345
  case 'discard':
429
346
  this.broker.publish('run', 'run.discarded', content);
430
347
  break;
431
-
432
348
  default:
433
349
  {
434
350
  this.broker.publish('run', 'run.end', content);
435
351
  }
436
352
  }
437
-
438
353
  const executeMessage = this[kExecuteMessage];
439
354
  this[kExecuteMessage] = null;
440
355
  executeMessage.ack();
441
356
  };
442
-
443
357
  proto._publishEvent = function publishEvent(state, content) {
444
- const eventContent = this._createMessage({ ...content,
358
+ const eventContent = this._createMessage({
359
+ ...content,
445
360
  state
446
361
  });
447
-
448
362
  this.broker.publish('event', `process.${state}`, eventContent, {
449
363
  type: state,
450
364
  mandatory: state === 'error'
451
365
  });
452
366
  };
453
-
454
367
  proto.sendMessage = function sendMessage(message) {
455
368
  const messageContent = message && message.content;
456
369
  if (!messageContent) return;
457
370
  let targetsFound = false;
458
-
459
371
  if (messageContent.target && messageContent.target.id && this.getActivityById(messageContent.target.id)) {
460
372
  targetsFound = true;
461
373
  } else if (messageContent.message && this.getStartActivities({
@@ -464,77 +376,63 @@ proto.sendMessage = function sendMessage(message) {
464
376
  }).length) {
465
377
  targetsFound = true;
466
378
  }
467
-
468
379
  if (!targetsFound) return;
469
380
  if (!this.status) this.run();
470
381
  this.getApi().sendApiMessage(message.properties.type || 'message', (0, _messageHelper.cloneContent)(messageContent), {
471
382
  delegate: true
472
383
  });
473
384
  };
474
-
475
385
  proto.getActivityById = function getActivityById(childId) {
476
386
  const execution = this.execution;
477
387
  if (execution) return execution.getActivityById(childId);
478
388
  return this.context.getActivityById(childId);
479
389
  };
480
-
481
390
  proto.getActivities = function getActivities() {
482
391
  const execution = this.execution;
483
392
  if (execution) return execution.getActivities();
484
393
  return this.context.getActivities(this.id);
485
394
  };
486
-
487
395
  proto.getStartActivities = function getStartActivities(filterOptions) {
488
396
  return this.context.getStartActivities(filterOptions, this.id);
489
397
  };
490
-
491
398
  proto.getSequenceFlows = function getSequenceFlows() {
492
399
  const execution = this.execution;
493
400
  if (execution) return execution.getSequenceFlows();
494
401
  return this.context.getSequenceFlows();
495
402
  };
496
-
497
403
  proto.getPostponed = function getPostponed(...args) {
498
404
  const execution = this.execution;
499
405
  if (!execution) return [];
500
406
  return execution.getPostponed(...args);
501
407
  };
502
-
503
408
  proto._onApiMessage = function onApiMessage(routingKey, message) {
504
409
  const messageType = message.properties.type;
505
-
506
410
  switch (messageType) {
507
411
  case 'stop':
508
412
  {
509
413
  if (this.execution && !this.execution.completed) return;
510
-
511
414
  this._onStop();
512
-
513
415
  break;
514
416
  }
515
417
  }
516
418
  };
517
-
518
419
  proto._onStop = function onStop() {
519
420
  this[kStopped] = true;
520
-
521
421
  this._deactivateRunConsumers();
522
-
523
422
  return this._publishEvent('stop');
524
423
  };
525
-
526
424
  proto._createMessage = function createMessage(override) {
527
425
  return {
528
426
  id: this.id,
529
427
  type: this.type,
530
428
  name: this.name,
531
429
  executionId: this.executionId,
532
- parent: { ...this.parent
430
+ parent: {
431
+ ...this.parent
533
432
  },
534
433
  ...override
535
434
  };
536
435
  };
537
-
538
436
  proto._debug = function debug(msg) {
539
437
  this.logger.debug(`<${this.id}> ${msg}`);
540
438
  };