bpmn-elements 8.2.4 → 9.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 (123) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{src/Api.js → Api.js} +11 -12
  3. package/dist/{src/Context.js → Context.js} +26 -27
  4. package/dist/{src/Environment.js → Environment.js} +15 -16
  5. package/dist/{src/EventBroker.js → EventBroker.js} +1 -1
  6. package/dist/{src/Expressions.js → Expressions.js} +1 -1
  7. package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
  8. package/dist/{src/activity → activity}/Activity.js +62 -63
  9. package/dist/{src/activity → activity}/ActivityExecution.js +23 -24
  10. package/dist/{src/activity → activity}/Dummy.js +1 -1
  11. package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
  12. package/dist/{src/definition → definition}/Definition.js +41 -42
  13. package/dist/{src/definition → definition}/DefinitionExecution.js +45 -46
  14. package/dist/{src/error → error}/Errors.js +1 -1
  15. package/dist/{src/eventDefinitions → eventDefinitions}/CancelEventDefinition.js +12 -13
  16. package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +12 -13
  17. package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +13 -14
  18. package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +13 -14
  19. package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
  20. package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
  21. package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
  22. package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
  23. package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
  24. package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
  25. package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
  26. package/dist/{src/events → events}/BoundaryEvent.js +15 -16
  27. package/dist/{src/events → events}/EndEvent.js +3 -3
  28. package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
  29. package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
  30. package/dist/{src/events → events}/StartEvent.js +8 -9
  31. package/dist/{src/flows → flows}/Association.js +15 -16
  32. package/dist/{src/flows → flows}/MessageFlow.js +16 -14
  33. package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
  34. package/dist/{src/gateways → gateways}/EventBasedGateway.js +2 -2
  35. package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
  36. package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
  37. package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
  38. package/dist/index.js +48 -48
  39. package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
  40. package/dist/{src/io → io}/Properties.js +7 -8
  41. package/dist/package.json +3 -0
  42. package/dist/{src/process → process}/Process.js +39 -40
  43. package/dist/{src/process → process}/ProcessExecution.js +42 -43
  44. package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
  45. package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
  46. package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
  47. package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
  48. package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
  49. package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
  50. package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
  51. package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
  52. package/dist/{src/tasks → tasks}/SubProcess.js +17 -18
  53. package/dist/{src/tasks → tasks}/Task.js +2 -2
  54. package/dist/{src/tasks → tasks}/Transaction.js +1 -1
  55. package/package.json +30 -30
  56. package/src/Api.js +11 -13
  57. package/src/Context.js +26 -28
  58. package/src/Environment.js +15 -17
  59. package/src/EventBroker.js +1 -1
  60. package/src/Expressions.js +1 -1
  61. package/src/MessageFormatter.js +3 -3
  62. package/src/activity/Activity.js +62 -64
  63. package/src/activity/ActivityExecution.js +23 -25
  64. package/src/activity/Dummy.js +1 -1
  65. package/src/activity/ExecutionScope.js +2 -2
  66. package/src/definition/Definition.js +41 -43
  67. package/src/definition/DefinitionExecution.js +45 -47
  68. package/src/error/Errors.js +1 -1
  69. package/src/eventDefinitions/CancelEventDefinition.js +12 -14
  70. package/src/eventDefinitions/CompensateEventDefinition.js +12 -14
  71. package/src/eventDefinitions/ConditionalEventDefinition.js +13 -15
  72. package/src/eventDefinitions/ErrorEventDefinition.js +13 -15
  73. package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
  74. package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
  75. package/src/eventDefinitions/LinkEventDefinition.js +14 -16
  76. package/src/eventDefinitions/MessageEventDefinition.js +13 -15
  77. package/src/eventDefinitions/SignalEventDefinition.js +13 -15
  78. package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
  79. package/src/eventDefinitions/TimerEventDefinition.js +15 -17
  80. package/src/events/BoundaryEvent.js +15 -17
  81. package/src/events/EndEvent.js +3 -3
  82. package/src/events/IntermediateCatchEvent.js +3 -3
  83. package/src/events/IntermediateThrowEvent.js +3 -3
  84. package/src/events/StartEvent.js +8 -10
  85. package/src/flows/Association.js +15 -17
  86. package/src/flows/MessageFlow.js +14 -15
  87. package/src/flows/SequenceFlow.js +16 -20
  88. package/src/gateways/EventBasedGateway.js +2 -2
  89. package/src/gateways/ExclusiveGateway.js +2 -2
  90. package/src/gateways/InclusiveGateway.js +2 -2
  91. package/src/gateways/ParallelGateway.js +2 -2
  92. package/src/index.js +106 -0
  93. package/src/io/InputOutputSpecification.js +8 -10
  94. package/src/io/Properties.js +7 -9
  95. package/src/process/Process.js +39 -41
  96. package/src/process/ProcessExecution.js +42 -44
  97. package/src/tasks/CallActivity.js +7 -9
  98. package/src/tasks/LoopCharacteristics.js +2 -2
  99. package/src/tasks/ReceiveTask.js +215 -217
  100. package/src/tasks/ScriptTask.js +4 -4
  101. package/src/tasks/ServiceImplementation.js +1 -1
  102. package/src/tasks/ServiceTask.js +6 -8
  103. package/src/tasks/SignalTask.js +7 -9
  104. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  105. package/src/tasks/SubProcess.js +17 -19
  106. package/src/tasks/Task.js +2 -2
  107. package/src/tasks/Transaction.js +1 -1
  108. package/types/index.d.ts +491 -0
  109. package/index.js +0 -106
  110. /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
  111. /package/dist/{src/Scripts.js → Scripts.js} +0 -0
  112. /package/dist/{src/Timers.js → Timers.js} +0 -0
  113. /package/dist/{src/activity → activity}/Escalation.js +0 -0
  114. /package/dist/{src/activity → activity}/Message.js +0 -0
  115. /package/dist/{src/activity → activity}/Signal.js +0 -0
  116. /package/dist/{src/error → error}/BpmnError.js +0 -0
  117. /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
  118. /package/dist/{src/io → io}/BpmnIO.js +0 -0
  119. /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
  120. /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
  121. /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
  122. /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
  123. /package/dist/{src/shared.js → shared.js} +0 -0
@@ -1,9 +1,9 @@
1
- import DefinitionExecution from './DefinitionExecution';
2
- import {DefinitionApi} from '../Api';
3
- import {DefinitionBroker} from '../EventBroker';
4
- import {getUniqueId, getOptionsAndCallback} from '../shared';
5
- import {makeErrorFromMessage} from '../error/Errors';
6
- import {cloneMessage, cloneContent} from '../messageHelper';
1
+ import DefinitionExecution from './DefinitionExecution.js';
2
+ import {DefinitionApi} from '../Api.js';
3
+ import {DefinitionBroker} from '../EventBroker.js';
4
+ import {getUniqueId, getOptionsAndCallback} from '../shared.js';
5
+ import {makeErrorFromMessage} from '../error/Errors.js';
6
+ import {cloneMessage, cloneContent} from '../messageHelper.js';
7
7
 
8
8
  const kConsuming = Symbol.for('consuming');
9
9
  const kCounters = Symbol.for('counters');
@@ -63,30 +63,28 @@ export function Definition(context, options) {
63
63
  this.logger = environment.Logger(type.toLowerCase());
64
64
  }
65
65
 
66
- const proto = Definition.prototype;
67
-
68
- Object.defineProperty(proto, 'counters', {
66
+ Object.defineProperty(Definition.prototype, 'counters', {
69
67
  enumerable: true,
70
68
  get() {
71
69
  return {...this[kCounters]};
72
70
  },
73
71
  });
74
72
 
75
- Object.defineProperty(proto, 'execution', {
73
+ Object.defineProperty(Definition.prototype, 'execution', {
76
74
  enumerable: true,
77
75
  get() {
78
76
  return this[kExec].execution;
79
77
  },
80
78
  });
81
79
 
82
- Object.defineProperty(proto, 'executionId', {
80
+ Object.defineProperty(Definition.prototype, 'executionId', {
83
81
  enumerable: true,
84
82
  get() {
85
83
  return this[kExec].executionId;
86
84
  },
87
85
  });
88
86
 
89
- Object.defineProperty(proto, 'isRunning', {
87
+ Object.defineProperty(Definition.prototype, 'isRunning', {
90
88
  enumerable: true,
91
89
  get() {
92
90
  if (!this[kConsuming]) return false;
@@ -94,21 +92,21 @@ Object.defineProperty(proto, 'isRunning', {
94
92
  },
95
93
  });
96
94
 
97
- Object.defineProperty(proto, 'status', {
95
+ Object.defineProperty(Definition.prototype, 'status', {
98
96
  enumerable: true,
99
97
  get() {
100
98
  return this[kStatus];
101
99
  },
102
100
  });
103
101
 
104
- Object.defineProperty(proto, 'stopped', {
102
+ Object.defineProperty(Definition.prototype, 'stopped', {
105
103
  enumerable: true,
106
104
  get() {
107
105
  return this[kStopped];
108
106
  },
109
107
  });
110
108
 
111
- proto.run = function run(optionsOrCallback, optionalCallback) {
109
+ Definition.prototype.run = function run(optionsOrCallback, optionalCallback) {
112
110
  const [runOptions, callback] = getOptionsAndCallback(optionsOrCallback, optionalCallback);
113
111
  if (this.isRunning) {
114
112
  const err = new Error('definition is already running');
@@ -136,7 +134,7 @@ proto.run = function run(optionsOrCallback, optionalCallback) {
136
134
  return this;
137
135
  };
138
136
 
139
- proto.resume = function resume(callback) {
137
+ Definition.prototype.resume = function resume(callback) {
140
138
  if (this.isRunning) {
141
139
  const err = new Error('cannot resume running definition');
142
140
  if (callback) return callback(err);
@@ -158,7 +156,7 @@ proto.resume = function resume(callback) {
158
156
  return this;
159
157
  };
160
158
 
161
- proto.recover = function recover(state) {
159
+ Definition.prototype.recover = function recover(state) {
162
160
  if (this.isRunning) throw new Error('cannot recover running definition');
163
161
  if (!state) return this;
164
162
 
@@ -182,7 +180,7 @@ proto.recover = function recover(state) {
182
180
  return this;
183
181
  };
184
182
 
185
- proto.shake = function shake(startId) {
183
+ Definition.prototype.shake = function shake(startId) {
186
184
  let result = {};
187
185
  const broker = this.broker;
188
186
 
@@ -221,7 +219,7 @@ proto.shake = function shake(startId) {
221
219
  }
222
220
  };
223
221
 
224
- proto.getState = function getState() {
222
+ Definition.prototype.getState = function getState() {
225
223
  return this._createMessage({
226
224
  status: this.status,
227
225
  stopped: this.stopped,
@@ -232,29 +230,29 @@ proto.getState = function getState() {
232
230
  });
233
231
  };
234
232
 
235
- proto.getProcesses = function getProcesses() {
233
+ Definition.prototype.getProcesses = function getProcesses() {
236
234
  const execution = this.execution;
237
235
  if (execution) return execution.getProcesses();
238
236
  return this.context.getProcesses();
239
237
  };
240
238
 
241
- proto.getExecutableProcesses = function getExecutableProcesses() {
239
+ Definition.prototype.getExecutableProcesses = function getExecutableProcesses() {
242
240
  const execution = this.execution;
243
241
  if (execution) return execution.getExecutableProcesses();
244
242
  return this.context.getExecutableProcesses();
245
243
  };
246
244
 
247
- proto.getRunningProcesses = function getRunningProcesses() {
245
+ Definition.prototype.getRunningProcesses = function getRunningProcesses() {
248
246
  const execution = this.execution;
249
247
  if (!execution) return [];
250
248
  return execution.getRunningProcesses();
251
249
  };
252
250
 
253
- proto.getProcessById = function getProcessById(processId) {
251
+ Definition.prototype.getProcessById = function getProcessById(processId) {
254
252
  return this.getProcesses().find((p) => p.id === processId);
255
253
  };
256
254
 
257
- proto.getActivityById = function getActivityById(childId) {
255
+ Definition.prototype.getActivityById = function getActivityById(childId) {
258
256
  const bps = this.getProcesses();
259
257
  for (const bp of bps) {
260
258
  const child = bp.getActivityById(childId);
@@ -263,17 +261,17 @@ proto.getActivityById = function getActivityById(childId) {
263
261
  return null;
264
262
  };
265
263
 
266
- proto.getElementById = function getElementById(elementId) {
264
+ Definition.prototype.getElementById = function getElementById(elementId) {
267
265
  return this.context.getActivityById(elementId);
268
266
  };
269
267
 
270
- proto.getPostponed = function getPostponed(...args) {
268
+ Definition.prototype.getPostponed = function getPostponed(...args) {
271
269
  const execution = this.execution;
272
270
  if (!execution) return [];
273
271
  return execution.getPostponed(...args);
274
272
  };
275
273
 
276
- proto.getApi = function getApi(message) {
274
+ Definition.prototype.getApi = function getApi(message) {
277
275
  const execution = this.execution;
278
276
  if (execution) return execution.getApi(message);
279
277
  message = message || this[kStateMessage];
@@ -281,15 +279,15 @@ proto.getApi = function getApi(message) {
281
279
  return DefinitionApi(this.broker, message);
282
280
  };
283
281
 
284
- proto.signal = function signal(message) {
282
+ Definition.prototype.signal = function signal(message) {
285
283
  return this.getApi().signal(message, {delegate: true});
286
284
  };
287
285
 
288
- proto.cancelActivity = function cancelActivity(message) {
286
+ Definition.prototype.cancelActivity = function cancelActivity(message) {
289
287
  return this.getApi().cancel(message, {delegate: true});
290
288
  };
291
289
 
292
- proto.sendMessage = function sendMessage(message) {
290
+ Definition.prototype.sendMessage = function sendMessage(message) {
293
291
  const messageContent = {message};
294
292
  let messageType = 'message';
295
293
  const reference = message && message.id && this.getElementById(message.id);
@@ -302,12 +300,12 @@ proto.sendMessage = function sendMessage(message) {
302
300
  return this.getApi().sendApiMessage(messageType, messageContent, {delegate: true});
303
301
  };
304
302
 
305
- proto.stop = function stop() {
303
+ Definition.prototype.stop = function stop() {
306
304
  if (!this.isRunning) return;
307
305
  this.getApi().stop();
308
306
  };
309
307
 
310
- proto._activateRunConsumers = function activateRunConsumers() {
308
+ Definition.prototype._activateRunConsumers = function activateRunConsumers() {
311
309
  this[kConsuming] = true;
312
310
  const broker = this.broker;
313
311
  const {onApiMessage, onRunMessage} = this[kMessageHandlers];
@@ -321,7 +319,7 @@ proto._activateRunConsumers = function activateRunConsumers() {
321
319
  });
322
320
  };
323
321
 
324
- proto._deactivateRunConsumers = function deactivateRunConsumers() {
322
+ Definition.prototype._deactivateRunConsumers = function deactivateRunConsumers() {
325
323
  const broker = this.broker;
326
324
  broker.cancel('_definition-api');
327
325
  broker.cancel('_definition-run');
@@ -329,7 +327,7 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
329
327
  this[kConsuming] = false;
330
328
  };
331
329
 
332
- proto._createMessage = function createMessage(override) {
330
+ Definition.prototype._createMessage = function createMessage(override) {
333
331
  return {
334
332
  id: this.id,
335
333
  type: this.type,
@@ -339,7 +337,7 @@ proto._createMessage = function createMessage(override) {
339
337
  };
340
338
  };
341
339
 
342
- proto._onRunMessage = function onRunMessage(routingKey, message) {
340
+ Definition.prototype._onRunMessage = function onRunMessage(routingKey, message) {
343
341
  const {content, fields} = message;
344
342
  if (routingKey === 'run.resume') {
345
343
  return this._onResumeMessage(message);
@@ -425,7 +423,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
425
423
  message.ack();
426
424
  };
427
425
 
428
- proto._onResumeMessage = function onResumeMessage(message) {
426
+ Definition.prototype._onResumeMessage = function onResumeMessage(message) {
429
427
  message.ack();
430
428
 
431
429
  const stateMessage = this[kStateMessage];
@@ -446,7 +444,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
446
444
  return this.broker.publish('run', stateMessage.fields.routingKey, cloneContent(stateMessage.content), stateMessage.properties);
447
445
  };
448
446
 
449
- proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
447
+ Definition.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
450
448
  const {content, properties} = message;
451
449
  const messageType = properties.type;
452
450
 
@@ -471,7 +469,7 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
471
469
  executeMessage.ack();
472
470
  };
473
471
 
474
- proto._onApiMessage = function onApiMessage(routingKey, message) {
472
+ Definition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
475
473
  if (message.properties.type === 'stop') {
476
474
  const execution = this.execution;
477
475
  if (!execution || execution.completed) {
@@ -480,7 +478,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
480
478
  }
481
479
  };
482
480
 
483
- proto._publishEvent = function publishEvent(action, content, msgOpts) {
481
+ Definition.prototype._publishEvent = function publishEvent(action, content, msgOpts) {
484
482
  const execution = this.execution;
485
483
  this.broker.publish('event', `definition.${action}`, execution ? execution._createMessage(content) : cloneContent(content), {
486
484
  type: action,
@@ -488,13 +486,13 @@ proto._publishEvent = function publishEvent(action, content, msgOpts) {
488
486
  });
489
487
  };
490
488
 
491
- proto._onStop = function onStop() {
489
+ Definition.prototype._onStop = function onStop() {
492
490
  this[kStopped] = true;
493
491
  this._deactivateRunConsumers();
494
492
  return this._publishEvent('stop', this._createMessage());
495
493
  };
496
494
 
497
- proto._onBrokerReturnFn = function onBrokerReturn(message) {
495
+ Definition.prototype._onBrokerReturnFn = function onBrokerReturn(message) {
498
496
  if (message.properties.type === 'error') {
499
497
  this._deactivateRunConsumers();
500
498
  const err = makeErrorFromMessage(message);
@@ -502,14 +500,14 @@ proto._onBrokerReturnFn = function onBrokerReturn(message) {
502
500
  }
503
501
  };
504
502
 
505
- proto._reset = function reset() {
503
+ Definition.prototype._reset = function reset() {
506
504
  this[kExec].executionId = undefined;
507
505
  this._deactivateRunConsumers();
508
506
  this.broker.purgeQueue('run-q');
509
507
  this.broker.purgeQueue('execution-q');
510
508
  };
511
509
 
512
- proto._debug = function debug(msg) {
510
+ Definition.prototype._debug = function debug(msg) {
513
511
  this.logger.debug(`<${this.id}> ${msg}`);
514
512
  };
515
513
 
@@ -1,7 +1,7 @@
1
- import getPropertyValue from '../getPropertyValue';
2
- import {DefinitionApi} from '../Api';
3
- import {brokerSafeId} from '../shared';
4
- import {cloneContent, cloneMessage, pushParent, cloneParent} from '../messageHelper';
1
+ import getPropertyValue from '../getPropertyValue.js';
2
+ import {DefinitionApi} from '../Api.js';
3
+ import {brokerSafeId} from '../shared.js';
4
+ import {cloneContent, cloneMessage, pushParent, cloneParent} from '../messageHelper.js';
5
5
 
6
6
  const kActivated = Symbol.for('activated');
7
7
  const kProcessesQ = Symbol.for('processesQ');
@@ -61,49 +61,47 @@ export default function DefinitionExecution(definition, context) {
61
61
  };
62
62
  }
63
63
 
64
- const proto = DefinitionExecution.prototype;
65
-
66
- Object.defineProperty(proto, 'stopped', {
64
+ Object.defineProperty(DefinitionExecution.prototype, 'stopped', {
67
65
  enumerable: true,
68
66
  get() {
69
67
  return this[kStopped];
70
68
  },
71
69
  });
72
70
 
73
- Object.defineProperty(proto, 'completed', {
71
+ Object.defineProperty(DefinitionExecution.prototype, 'completed', {
74
72
  enumerable: true,
75
73
  get() {
76
74
  return this[kCompleted];
77
75
  },
78
76
  });
79
77
 
80
- Object.defineProperty(proto, 'status', {
78
+ Object.defineProperty(DefinitionExecution.prototype, 'status', {
81
79
  enumerable: true,
82
80
  get() {
83
81
  return this[kStatus];
84
82
  },
85
83
  });
86
84
 
87
- Object.defineProperty(proto, 'processes', {
85
+ Object.defineProperty(DefinitionExecution.prototype, 'processes', {
88
86
  enumerable: true,
89
87
  get() {
90
88
  return this[kProcesses].running;
91
89
  },
92
90
  });
93
91
 
94
- Object.defineProperty(proto, 'postponedCount', {
92
+ Object.defineProperty(DefinitionExecution.prototype, 'postponedCount', {
95
93
  get() {
96
94
  return this[kProcesses].postponed.length;
97
95
  },
98
96
  });
99
97
 
100
- Object.defineProperty(proto, 'isRunning', {
98
+ Object.defineProperty(DefinitionExecution.prototype, 'isRunning', {
101
99
  get() {
102
100
  return this[kActivated];
103
101
  },
104
102
  });
105
103
 
106
- proto.execute = function execute(executeMessage) {
104
+ DefinitionExecution.prototype.execute = function execute(executeMessage) {
107
105
  if (!executeMessage) throw new Error('Definition execution requires message');
108
106
  const content = executeMessage.content;
109
107
  const executionId = this.executionId = content.executionId;
@@ -139,7 +137,7 @@ proto.execute = function execute(executeMessage) {
139
137
  return true;
140
138
  };
141
139
 
142
- proto.resume = function resume() {
140
+ DefinitionExecution.prototype.resume = function resume() {
143
141
  this._debug(`resume ${this[kStatus]} definition execution`);
144
142
 
145
143
  if (this[kCompleted]) return this._complete('completed');
@@ -157,7 +155,7 @@ proto.resume = function resume() {
157
155
  for (const bp of running) bp.resume();
158
156
  };
159
157
 
160
- proto.recover = function recover(state) {
158
+ DefinitionExecution.prototype.recover = function recover(state) {
161
159
  if (!state) return this;
162
160
  this.executionId = state.executionId;
163
161
 
@@ -189,11 +187,11 @@ proto.recover = function recover(state) {
189
187
  return this;
190
188
  };
191
189
 
192
- proto.stop = function stop() {
190
+ DefinitionExecution.prototype.stop = function stop() {
193
191
  this.getApi().stop();
194
192
  };
195
193
 
196
- proto.getProcesses = function getProcesses() {
194
+ DefinitionExecution.prototype.getProcesses = function getProcesses() {
197
195
  const {running, processes} = this[kProcesses];
198
196
  const result = running.slice();
199
197
  for (const bp of processes) {
@@ -202,29 +200,29 @@ proto.getProcesses = function getProcesses() {
202
200
  return result;
203
201
  };
204
202
 
205
- proto.getProcessById = function getProcessById(processId) {
203
+ DefinitionExecution.prototype.getProcessById = function getProcessById(processId) {
206
204
  return this.getProcesses().find((bp) => bp.id === processId);
207
205
  };
208
206
 
209
- proto.getProcessesById = function getProcessesById(processId) {
207
+ DefinitionExecution.prototype.getProcessesById = function getProcessesById(processId) {
210
208
  return this.getProcesses().filter((bp) => bp.id === processId);
211
209
  };
212
210
 
213
- proto.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
211
+ DefinitionExecution.prototype.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
214
212
  const running = this[kProcesses].running;
215
213
  return running.find((bp) => bp.executionId === processExecutionId);
216
214
  };
217
215
 
218
- proto.getRunningProcesses = function getRunningProcesses() {
216
+ DefinitionExecution.prototype.getRunningProcesses = function getRunningProcesses() {
219
217
  const running = this[kProcesses].running;
220
218
  return running.filter((bp) => bp.executionId);
221
219
  };
222
220
 
223
- proto.getExecutableProcesses = function getExecutableProcesses() {
221
+ DefinitionExecution.prototype.getExecutableProcesses = function getExecutableProcesses() {
224
222
  return this[kProcesses].executable.slice();
225
223
  };
226
224
 
227
- proto.getState = function getState() {
225
+ DefinitionExecution.prototype.getState = function getState() {
228
226
  return {
229
227
  executionId: this.executionId,
230
228
  stopped: this[kStopped],
@@ -234,7 +232,7 @@ proto.getState = function getState() {
234
232
  };
235
233
  };
236
234
 
237
- proto.getApi = function getApi(apiMessage) {
235
+ DefinitionExecution.prototype.getApi = function getApi(apiMessage) {
238
236
  if (!apiMessage) apiMessage = this[kExecuteMessage] || {content: this._createMessage()};
239
237
 
240
238
  const content = apiMessage.content;
@@ -257,7 +255,7 @@ proto.getApi = function getApi(apiMessage) {
257
255
  return api;
258
256
  };
259
257
 
260
- proto.getPostponed = function getPostponed(...args) {
258
+ DefinitionExecution.prototype.getPostponed = function getPostponed(...args) {
261
259
  const running = this[kProcesses].running;
262
260
  return running.reduce((result, p) => {
263
261
  result = result.concat(p.getPostponed(...args));
@@ -265,7 +263,7 @@ proto.getPostponed = function getPostponed(...args) {
265
263
  }, []);
266
264
  };
267
265
 
268
- proto._start = function start() {
266
+ DefinitionExecution.prototype._start = function start() {
269
267
  const {ids, executable, postponed} = this[kProcesses];
270
268
  if (!ids.length) {
271
269
  return this._complete('completed');
@@ -287,7 +285,7 @@ proto._start = function start() {
287
285
  });
288
286
  };
289
287
 
290
- proto._activate = function activate(processList) {
288
+ DefinitionExecution.prototype._activate = function activate(processList) {
291
289
  this.broker.subscribeTmp('api', '#', this[kMessageHandlers].onApiMessage, {
292
290
  noAck: true,
293
291
  consumerTag: '_definition-api-consumer',
@@ -296,7 +294,7 @@ proto._activate = function activate(processList) {
296
294
  this[kActivated] = true;
297
295
  };
298
296
 
299
- proto._activateProcess = function activateProcess(bp) {
297
+ DefinitionExecution.prototype._activateProcess = function activateProcess(bp) {
300
298
  const handlers = this[kMessageHandlers];
301
299
 
302
300
  bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
@@ -330,7 +328,7 @@ proto._activateProcess = function activateProcess(bp) {
330
328
  });
331
329
  };
332
330
 
333
- proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
331
+ DefinitionExecution.prototype._onChildEvent = function onChildEvent(routingKey, originalMessage) {
334
332
  const message = cloneMessage(originalMessage);
335
333
  const content = message.content;
336
334
  const parent = content.parent = content.parent || {};
@@ -348,14 +346,14 @@ proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
348
346
  this[kProcessesQ].queueMessage(message.fields, cloneContent(content), message.properties);
349
347
  };
350
348
 
351
- proto._deactivate = function deactivate() {
349
+ DefinitionExecution.prototype._deactivate = function deactivate() {
352
350
  this.broker.cancel('_definition-api-consumer');
353
351
  this.broker.cancel(`_definition-activity-${this.executionId}`);
354
352
  for (const bp of this[kProcesses].running) this._deactivateProcess(bp);
355
353
  this[kActivated] = false;
356
354
  };
357
355
 
358
- proto._deactivateProcess = function deactivateProcess(bp) {
356
+ DefinitionExecution.prototype._deactivateProcess = function deactivateProcess(bp) {
359
357
  bp.broker.cancel('_definition-outbound-message-consumer');
360
358
  bp.broker.cancel('_definition-activity-consumer');
361
359
  bp.broker.cancel('_definition-signal-consumer');
@@ -364,7 +362,7 @@ proto._deactivateProcess = function deactivateProcess(bp) {
364
362
  bp.broker.cancel('_definition-call-cancel-consumer');
365
363
  };
366
364
 
367
- proto._onProcessMessage = function onProcessMessage(routingKey, message) {
365
+ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(routingKey, message) {
368
366
  const content = message.content;
369
367
  const isRedelivered = message.fields.redelivered;
370
368
  const {id: childId, inbound} = content;
@@ -429,7 +427,7 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
429
427
  }
430
428
  };
431
429
 
432
- proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
430
+ DefinitionExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
433
431
  let previousMsg;
434
432
  const postponed = this[kProcesses].postponed;
435
433
  const idx = postponed.findIndex((msg) => msg.content.executionId === message.content.executionId);
@@ -441,7 +439,7 @@ proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage
441
439
  if (postponeMessage) postponed.push(message);
442
440
  };
443
441
 
444
- proto._onProcessCompleted = function onProcessCompleted(message) {
442
+ DefinitionExecution.prototype._onProcessCompleted = function onProcessCompleted(message) {
445
443
  this._stateChangeMessage(message, false);
446
444
  if (message.fields.redelivered) return message.ack();
447
445
 
@@ -459,7 +457,7 @@ proto._onProcessCompleted = function onProcessCompleted(message) {
459
457
  }
460
458
  };
461
459
 
462
- proto._onStopped = function onStopped(message) {
460
+ DefinitionExecution.prototype._onStopped = function onStopped(message) {
463
461
  const running = this[kProcesses].running;
464
462
  this._debug(`stop definition execution (stop process executions ${running.length})`);
465
463
  this[kProcessesQ].close();
@@ -472,7 +470,7 @@ proto._onStopped = function onStopped(message) {
472
470
  }), {type: 'stopped', persistent: false});
473
471
  };
474
472
 
475
- proto._onApiMessage = function onApiMessage(routingKey, message) {
473
+ DefinitionExecution.prototype._onApiMessage = function onApiMessage(routingKey, message) {
476
474
  const messageType = message.properties.type;
477
475
  const delegate = message.properties.delegate;
478
476
 
@@ -494,7 +492,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
494
492
  }
495
493
  };
496
494
 
497
- proto._startProcessesByMessage = function startProcessesByMessage(reference) {
495
+ DefinitionExecution.prototype._startProcessesByMessage = function startProcessesByMessage(reference) {
498
496
  const {processes: bps, running} = this[kProcesses];
499
497
  if (bps.length < 2) return;
500
498
 
@@ -523,7 +521,7 @@ proto._startProcessesByMessage = function startProcessesByMessage(reference) {
523
521
  }
524
522
  };
525
523
 
526
- proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
524
+ DefinitionExecution.prototype._onMessageOutbound = function onMessageOutbound(routingKey, message) {
527
525
  const content = message.content;
528
526
  const {target, source} = content;
529
527
 
@@ -553,7 +551,7 @@ proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
553
551
  targetProcess.sendMessage(message);
554
552
  };
555
553
 
556
- proto._onCallActivity = function onCallActivity(routingKey, message) {
554
+ DefinitionExecution.prototype._onCallActivity = function onCallActivity(routingKey, message) {
557
555
  const content = message.content;
558
556
  const {calledElement, id: fromId, executionId: fromExecutionId, name: fromName, parent: fromParent} = content;
559
557
  if (!calledElement) return;
@@ -584,7 +582,7 @@ proto._onCallActivity = function onCallActivity(routingKey, message) {
584
582
  targetProcess.run({inbound: [cloneContent(content)]});
585
583
  };
586
584
 
587
- proto._onCancelCallActivity = function onCancelCallActivity(routingKey, message) {
585
+ DefinitionExecution.prototype._onCancelCallActivity = function onCancelCallActivity(routingKey, message) {
588
586
  const {calledElement, id: fromId, executionId: fromExecutionId, parent: fromParent} = message.content;
589
587
  if (!calledElement) return;
590
588
 
@@ -597,7 +595,7 @@ proto._onCancelCallActivity = function onCancelCallActivity(routingKey, message)
597
595
  targetProcess.getApi().discard();
598
596
  };
599
597
 
600
- proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage) {
598
+ DefinitionExecution.prototype._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage) {
601
599
  const content = executeMessage.content;
602
600
  const messageType = executeMessage.properties.type;
603
601
  const delegateMessage = executeMessage.content.message;
@@ -623,14 +621,14 @@ proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage
623
621
  }), {type: messageType});
624
622
  };
625
623
 
626
- proto._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
624
+ DefinitionExecution.prototype._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
627
625
  const running = this[kProcesses].running;
628
626
  const idx = running.findIndex((p) => p.executionId === processExecutionId);
629
627
  if (idx === -1) return;
630
628
  return running.splice(idx, 1)[0];
631
629
  };
632
630
 
633
- proto._complete = function complete(completionType, content, options) {
631
+ DefinitionExecution.prototype._complete = function complete(completionType, content, options) {
634
632
  this._deactivate();
635
633
  const stateMessage = this[kExecuteMessage];
636
634
  this._debug(`definition execution ${completionType} in ${Date.now() - stateMessage.properties.timestamp}ms`);
@@ -647,7 +645,7 @@ proto._complete = function complete(completionType, content, options) {
647
645
  }, {type: completionType, mandatory: completionType === 'error', ...options});
648
646
  };
649
647
 
650
- proto._createMessage = function createMessage(content = {}) {
648
+ DefinitionExecution.prototype._createMessage = function createMessage(content = {}) {
651
649
  return {
652
650
  id: this.id,
653
651
  type: this.type,
@@ -657,7 +655,7 @@ proto._createMessage = function createMessage(content = {}) {
657
655
  };
658
656
  };
659
657
 
660
- proto._getProcessApi = function getProcessApi(message) {
658
+ DefinitionExecution.prototype._getProcessApi = function getProcessApi(message) {
661
659
  const content = message.content;
662
660
  let api = this._getProcessApiByExecutionId(content.executionId, message);
663
661
  if (api) return api;
@@ -675,12 +673,12 @@ proto._getProcessApi = function getProcessApi(message) {
675
673
  }
676
674
  };
677
675
 
678
- proto._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentExecutionId, message) {
676
+ DefinitionExecution.prototype._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentExecutionId, message) {
679
677
  const processInstance = this.getProcessByExecutionId(parentExecutionId);
680
678
  if (!processInstance) return;
681
679
  return processInstance.getApi(message);
682
680
  };
683
681
 
684
- proto._debug = function debug(logMessage) {
682
+ DefinitionExecution.prototype._debug = function debug(logMessage) {
685
683
  this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
686
684
  };
@@ -1,4 +1,4 @@
1
- import {cloneMessage} from '../messageHelper';
1
+ import {cloneMessage} from '../messageHelper.js';
2
2
 
3
3
  class ActivityError extends Error {
4
4
  constructor(description, sourceMessage, inner) {