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
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Definition = Definition;
7
7
  exports.default = void 0;
8
- var _DefinitionExecution = _interopRequireDefault(require("./DefinitionExecution"));
9
- var _Api = require("../Api");
10
- var _EventBroker = require("../EventBroker");
11
- var _shared = require("../shared");
12
- var _Errors = require("../error/Errors");
13
- var _messageHelper = require("../messageHelper");
8
+ var _DefinitionExecution = _interopRequireDefault(require("./DefinitionExecution.js"));
9
+ var _Api = require("../Api.js");
10
+ var _EventBroker = require("../EventBroker.js");
11
+ var _shared = require("../shared.js");
12
+ var _Errors = require("../error/Errors.js");
13
+ var _messageHelper = require("../messageHelper.js");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  const kConsuming = Symbol.for('consuming');
16
16
  const kCounters = Symbol.for('counters');
@@ -70,8 +70,7 @@ function Definition(context, options) {
70
70
  this.emitFatal = emitFatal;
71
71
  this.logger = environment.Logger(type.toLowerCase());
72
72
  }
73
- const proto = Definition.prototype;
74
- Object.defineProperty(proto, 'counters', {
73
+ Object.defineProperty(Definition.prototype, 'counters', {
75
74
  enumerable: true,
76
75
  get() {
77
76
  return {
@@ -79,38 +78,38 @@ Object.defineProperty(proto, 'counters', {
79
78
  };
80
79
  }
81
80
  });
82
- Object.defineProperty(proto, 'execution', {
81
+ Object.defineProperty(Definition.prototype, 'execution', {
83
82
  enumerable: true,
84
83
  get() {
85
84
  return this[kExec].execution;
86
85
  }
87
86
  });
88
- Object.defineProperty(proto, 'executionId', {
87
+ Object.defineProperty(Definition.prototype, 'executionId', {
89
88
  enumerable: true,
90
89
  get() {
91
90
  return this[kExec].executionId;
92
91
  }
93
92
  });
94
- Object.defineProperty(proto, 'isRunning', {
93
+ Object.defineProperty(Definition.prototype, 'isRunning', {
95
94
  enumerable: true,
96
95
  get() {
97
96
  if (!this[kConsuming]) return false;
98
97
  return !!this.status;
99
98
  }
100
99
  });
101
- Object.defineProperty(proto, 'status', {
100
+ Object.defineProperty(Definition.prototype, 'status', {
102
101
  enumerable: true,
103
102
  get() {
104
103
  return this[kStatus];
105
104
  }
106
105
  });
107
- Object.defineProperty(proto, 'stopped', {
106
+ Object.defineProperty(Definition.prototype, 'stopped', {
108
107
  enumerable: true,
109
108
  get() {
110
109
  return this[kStopped];
111
110
  }
112
111
  });
113
- proto.run = function run(optionsOrCallback, optionalCallback) {
112
+ Definition.prototype.run = function run(optionsOrCallback, optionalCallback) {
114
113
  const [runOptions, callback] = (0, _shared.getOptionsAndCallback)(optionsOrCallback, optionalCallback);
115
114
  if (this.isRunning) {
116
115
  const err = new Error('definition is already running');
@@ -133,7 +132,7 @@ proto.run = function run(optionsOrCallback, optionalCallback) {
133
132
  this._activateRunConsumers();
134
133
  return this;
135
134
  };
136
- proto.resume = function resume(callback) {
135
+ Definition.prototype.resume = function resume(callback) {
137
136
  if (this.isRunning) {
138
137
  const err = new Error('cannot resume running definition');
139
138
  if (callback) return callback(err);
@@ -152,7 +151,7 @@ proto.resume = function resume(callback) {
152
151
  this._activateRunConsumers();
153
152
  return this;
154
153
  };
155
- proto.recover = function recover(state) {
154
+ Definition.prototype.recover = function recover(state) {
156
155
  if (this.isRunning) throw new Error('cannot recover running definition');
157
156
  if (!state) return this;
158
157
  this[kStopped] = !!state.stopped;
@@ -172,7 +171,7 @@ proto.recover = function recover(state) {
172
171
  this.broker.recover(state.broker);
173
172
  return this;
174
173
  };
175
- proto.shake = function shake(startId) {
174
+ Definition.prototype.shake = function shake(startId) {
176
175
  let result = {};
177
176
  const broker = this.broker;
178
177
  let bps;
@@ -204,7 +203,7 @@ proto.shake = function shake(startId) {
204
203
  };
205
204
  }
206
205
  };
207
- proto.getState = function getState() {
206
+ Definition.prototype.getState = function getState() {
208
207
  return this._createMessage({
209
208
  status: this.status,
210
209
  stopped: this.stopped,
@@ -214,25 +213,25 @@ proto.getState = function getState() {
214
213
  broker: this.broker.getState(true)
215
214
  });
216
215
  };
217
- proto.getProcesses = function getProcesses() {
216
+ Definition.prototype.getProcesses = function getProcesses() {
218
217
  const execution = this.execution;
219
218
  if (execution) return execution.getProcesses();
220
219
  return this.context.getProcesses();
221
220
  };
222
- proto.getExecutableProcesses = function getExecutableProcesses() {
221
+ Definition.prototype.getExecutableProcesses = function getExecutableProcesses() {
223
222
  const execution = this.execution;
224
223
  if (execution) return execution.getExecutableProcesses();
225
224
  return this.context.getExecutableProcesses();
226
225
  };
227
- proto.getRunningProcesses = function getRunningProcesses() {
226
+ Definition.prototype.getRunningProcesses = function getRunningProcesses() {
228
227
  const execution = this.execution;
229
228
  if (!execution) return [];
230
229
  return execution.getRunningProcesses();
231
230
  };
232
- proto.getProcessById = function getProcessById(processId) {
231
+ Definition.prototype.getProcessById = function getProcessById(processId) {
233
232
  return this.getProcesses().find(p => p.id === processId);
234
233
  };
235
- proto.getActivityById = function getActivityById(childId) {
234
+ Definition.prototype.getActivityById = function getActivityById(childId) {
236
235
  const bps = this.getProcesses();
237
236
  for (const bp of bps) {
238
237
  const child = bp.getActivityById(childId);
@@ -240,32 +239,32 @@ proto.getActivityById = function getActivityById(childId) {
240
239
  }
241
240
  return null;
242
241
  };
243
- proto.getElementById = function getElementById(elementId) {
242
+ Definition.prototype.getElementById = function getElementById(elementId) {
244
243
  return this.context.getActivityById(elementId);
245
244
  };
246
- proto.getPostponed = function getPostponed(...args) {
245
+ Definition.prototype.getPostponed = function getPostponed(...args) {
247
246
  const execution = this.execution;
248
247
  if (!execution) return [];
249
248
  return execution.getPostponed(...args);
250
249
  };
251
- proto.getApi = function getApi(message) {
250
+ Definition.prototype.getApi = function getApi(message) {
252
251
  const execution = this.execution;
253
252
  if (execution) return execution.getApi(message);
254
253
  message = message || this[kStateMessage];
255
254
  if (!message) throw new Error('Definition is not running');
256
255
  return (0, _Api.DefinitionApi)(this.broker, message);
257
256
  };
258
- proto.signal = function signal(message) {
257
+ Definition.prototype.signal = function signal(message) {
259
258
  return this.getApi().signal(message, {
260
259
  delegate: true
261
260
  });
262
261
  };
263
- proto.cancelActivity = function cancelActivity(message) {
262
+ Definition.prototype.cancelActivity = function cancelActivity(message) {
264
263
  return this.getApi().cancel(message, {
265
264
  delegate: true
266
265
  });
267
266
  };
268
- proto.sendMessage = function sendMessage(message) {
267
+ Definition.prototype.sendMessage = function sendMessage(message) {
269
268
  const messageContent = {
270
269
  message
271
270
  };
@@ -285,11 +284,11 @@ proto.sendMessage = function sendMessage(message) {
285
284
  delegate: true
286
285
  });
287
286
  };
288
- proto.stop = function stop() {
287
+ Definition.prototype.stop = function stop() {
289
288
  if (!this.isRunning) return;
290
289
  this.getApi().stop();
291
290
  };
292
- proto._activateRunConsumers = function activateRunConsumers() {
291
+ Definition.prototype._activateRunConsumers = function activateRunConsumers() {
293
292
  this[kConsuming] = true;
294
293
  const broker = this.broker;
295
294
  const {
@@ -305,14 +304,14 @@ proto._activateRunConsumers = function activateRunConsumers() {
305
304
  consumerTag: '_definition-run'
306
305
  });
307
306
  };
308
- proto._deactivateRunConsumers = function deactivateRunConsumers() {
307
+ Definition.prototype._deactivateRunConsumers = function deactivateRunConsumers() {
309
308
  const broker = this.broker;
310
309
  broker.cancel('_definition-api');
311
310
  broker.cancel('_definition-run');
312
311
  broker.cancel('_definition-execution');
313
312
  this[kConsuming] = false;
314
313
  };
315
- proto._createMessage = function createMessage(override) {
314
+ Definition.prototype._createMessage = function createMessage(override) {
316
315
  return {
317
316
  id: this.id,
318
317
  type: this.type,
@@ -321,7 +320,7 @@ proto._createMessage = function createMessage(override) {
321
320
  ...override
322
321
  };
323
322
  };
324
- proto._onRunMessage = function onRunMessage(routingKey, message) {
323
+ Definition.prototype._onRunMessage = function onRunMessage(routingKey, message) {
325
324
  const {
326
325
  content,
327
326
  fields
@@ -405,7 +404,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
405
404
  }
406
405
  message.ack();
407
406
  };
408
- proto._onResumeMessage = function onResumeMessage(message) {
407
+ Definition.prototype._onResumeMessage = function onResumeMessage(message) {
409
408
  message.ack();
410
409
  const stateMessage = this[kStateMessage];
411
410
  switch (stateMessage.fields.routingKey) {
@@ -420,7 +419,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
420
419
  this._debug(`resume from ${this.status}`);
421
420
  return this.broker.publish('run', stateMessage.fields.routingKey, (0, _messageHelper.cloneContent)(stateMessage.content), stateMessage.properties);
422
421
  };
423
- proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
422
+ Definition.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
424
423
  const {
425
424
  content,
426
425
  properties
@@ -447,7 +446,7 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
447
446
  this[kExecuteMessage] = null;
448
447
  executeMessage.ack();
449
448
  };
450
- proto._onApiMessage = function onApiMessage(routingKey, message) {
449
+ Definition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
451
450
  if (message.properties.type === 'stop') {
452
451
  const execution = this.execution;
453
452
  if (!execution || execution.completed) {
@@ -455,32 +454,32 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
455
454
  }
456
455
  }
457
456
  };
458
- proto._publishEvent = function publishEvent(action, content, msgOpts) {
457
+ Definition.prototype._publishEvent = function publishEvent(action, content, msgOpts) {
459
458
  const execution = this.execution;
460
459
  this.broker.publish('event', `definition.${action}`, execution ? execution._createMessage(content) : (0, _messageHelper.cloneContent)(content), {
461
460
  type: action,
462
461
  ...msgOpts
463
462
  });
464
463
  };
465
- proto._onStop = function onStop() {
464
+ Definition.prototype._onStop = function onStop() {
466
465
  this[kStopped] = true;
467
466
  this._deactivateRunConsumers();
468
467
  return this._publishEvent('stop', this._createMessage());
469
468
  };
470
- proto._onBrokerReturnFn = function onBrokerReturn(message) {
469
+ Definition.prototype._onBrokerReturnFn = function onBrokerReturn(message) {
471
470
  if (message.properties.type === 'error') {
472
471
  this._deactivateRunConsumers();
473
472
  const err = (0, _Errors.makeErrorFromMessage)(message);
474
473
  throw err;
475
474
  }
476
475
  };
477
- proto._reset = function reset() {
476
+ Definition.prototype._reset = function reset() {
478
477
  this[kExec].executionId = undefined;
479
478
  this._deactivateRunConsumers();
480
479
  this.broker.purgeQueue('run-q');
481
480
  this.broker.purgeQueue('execution-q');
482
481
  };
483
- proto._debug = function debug(msg) {
482
+ Definition.prototype._debug = function debug(msg) {
484
483
  this.logger.debug(`<${this.id}> ${msg}`);
485
484
  };
486
485
  function addConsumerCallbacks(definition, callback) {
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = DefinitionExecution;
7
- var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
8
- var _Api = require("../Api");
9
- var _shared = require("../shared");
10
- var _messageHelper = require("../messageHelper");
7
+ var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue.js"));
8
+ var _Api = require("../Api.js");
9
+ var _shared = require("../shared.js");
10
+ var _messageHelper = require("../messageHelper.js");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  const kActivated = Symbol.for('activated');
13
13
  const kProcessesQ = Symbol.for('processesQ');
@@ -62,42 +62,41 @@ function DefinitionExecution(definition, context) {
62
62
  onProcessMessage: this._onProcessMessage.bind(this)
63
63
  };
64
64
  }
65
- const proto = DefinitionExecution.prototype;
66
- Object.defineProperty(proto, 'stopped', {
65
+ Object.defineProperty(DefinitionExecution.prototype, 'stopped', {
67
66
  enumerable: true,
68
67
  get() {
69
68
  return this[kStopped];
70
69
  }
71
70
  });
72
- Object.defineProperty(proto, 'completed', {
71
+ Object.defineProperty(DefinitionExecution.prototype, 'completed', {
73
72
  enumerable: true,
74
73
  get() {
75
74
  return this[kCompleted];
76
75
  }
77
76
  });
78
- Object.defineProperty(proto, 'status', {
77
+ Object.defineProperty(DefinitionExecution.prototype, 'status', {
79
78
  enumerable: true,
80
79
  get() {
81
80
  return this[kStatus];
82
81
  }
83
82
  });
84
- Object.defineProperty(proto, 'processes', {
83
+ Object.defineProperty(DefinitionExecution.prototype, 'processes', {
85
84
  enumerable: true,
86
85
  get() {
87
86
  return this[kProcesses].running;
88
87
  }
89
88
  });
90
- Object.defineProperty(proto, 'postponedCount', {
89
+ Object.defineProperty(DefinitionExecution.prototype, 'postponedCount', {
91
90
  get() {
92
91
  return this[kProcesses].postponed.length;
93
92
  }
94
93
  });
95
- Object.defineProperty(proto, 'isRunning', {
94
+ Object.defineProperty(DefinitionExecution.prototype, 'isRunning', {
96
95
  get() {
97
96
  return this[kActivated];
98
97
  }
99
98
  });
100
- proto.execute = function execute(executeMessage) {
99
+ DefinitionExecution.prototype.execute = function execute(executeMessage) {
101
100
  if (!executeMessage) throw new Error('Definition execution requires message');
102
101
  const content = executeMessage.content;
103
102
  const executionId = this.executionId = content.executionId;
@@ -131,7 +130,7 @@ proto.execute = function execute(executeMessage) {
131
130
  this._start();
132
131
  return true;
133
132
  };
134
- proto.resume = function resume() {
133
+ DefinitionExecution.prototype.resume = function resume() {
135
134
  this._debug(`resume ${this[kStatus]} definition execution`);
136
135
  if (this[kCompleted]) return this._complete('completed');
137
136
  const {
@@ -147,7 +146,7 @@ proto.resume = function resume() {
147
146
  if (this[kCompleted]) return;
148
147
  for (const bp of running) bp.resume();
149
148
  };
150
- proto.recover = function recover(state) {
149
+ DefinitionExecution.prototype.recover = function recover(state) {
151
150
  if (!state) return this;
152
151
  this.executionId = state.executionId;
153
152
  this[kStopped] = state.stopped;
@@ -172,10 +171,10 @@ proto.recover = function recover(state) {
172
171
  }
173
172
  return this;
174
173
  };
175
- proto.stop = function stop() {
174
+ DefinitionExecution.prototype.stop = function stop() {
176
175
  this.getApi().stop();
177
176
  };
178
- proto.getProcesses = function getProcesses() {
177
+ DefinitionExecution.prototype.getProcesses = function getProcesses() {
179
178
  const {
180
179
  running,
181
180
  processes
@@ -186,24 +185,24 @@ proto.getProcesses = function getProcesses() {
186
185
  }
187
186
  return result;
188
187
  };
189
- proto.getProcessById = function getProcessById(processId) {
188
+ DefinitionExecution.prototype.getProcessById = function getProcessById(processId) {
190
189
  return this.getProcesses().find(bp => bp.id === processId);
191
190
  };
192
- proto.getProcessesById = function getProcessesById(processId) {
191
+ DefinitionExecution.prototype.getProcessesById = function getProcessesById(processId) {
193
192
  return this.getProcesses().filter(bp => bp.id === processId);
194
193
  };
195
- proto.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
194
+ DefinitionExecution.prototype.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
196
195
  const running = this[kProcesses].running;
197
196
  return running.find(bp => bp.executionId === processExecutionId);
198
197
  };
199
- proto.getRunningProcesses = function getRunningProcesses() {
198
+ DefinitionExecution.prototype.getRunningProcesses = function getRunningProcesses() {
200
199
  const running = this[kProcesses].running;
201
200
  return running.filter(bp => bp.executionId);
202
201
  };
203
- proto.getExecutableProcesses = function getExecutableProcesses() {
202
+ DefinitionExecution.prototype.getExecutableProcesses = function getExecutableProcesses() {
204
203
  return this[kProcesses].executable.slice();
205
204
  };
206
- proto.getState = function getState() {
205
+ DefinitionExecution.prototype.getState = function getState() {
207
206
  return {
208
207
  executionId: this.executionId,
209
208
  stopped: this[kStopped],
@@ -212,7 +211,7 @@ proto.getState = function getState() {
212
211
  processes: this[kProcesses].running.map(bp => bp.getState())
213
212
  };
214
213
  };
215
- proto.getApi = function getApi(apiMessage) {
214
+ DefinitionExecution.prototype.getApi = function getApi(apiMessage) {
216
215
  if (!apiMessage) apiMessage = this[kExecuteMessage] || {
217
216
  content: this._createMessage()
218
217
  };
@@ -232,14 +231,14 @@ proto.getApi = function getApi(apiMessage) {
232
231
  };
233
232
  return api;
234
233
  };
235
- proto.getPostponed = function getPostponed(...args) {
234
+ DefinitionExecution.prototype.getPostponed = function getPostponed(...args) {
236
235
  const running = this[kProcesses].running;
237
236
  return running.reduce((result, p) => {
238
237
  result = result.concat(p.getPostponed(...args));
239
238
  return result;
240
239
  }, []);
241
240
  };
242
- proto._start = function start() {
241
+ DefinitionExecution.prototype._start = function start() {
243
242
  const {
244
243
  ids,
245
244
  executable,
@@ -262,7 +261,7 @@ proto._start = function start() {
262
261
  consumerTag: `_definition-activity-${this.executionId}`
263
262
  });
264
263
  };
265
- proto._activate = function activate(processList) {
264
+ DefinitionExecution.prototype._activate = function activate(processList) {
266
265
  this.broker.subscribeTmp('api', '#', this[kMessageHandlers].onApiMessage, {
267
266
  noAck: true,
268
267
  consumerTag: '_definition-api-consumer'
@@ -270,7 +269,7 @@ proto._activate = function activate(processList) {
270
269
  for (const bp of processList) this._activateProcess(bp);
271
270
  this[kActivated] = true;
272
271
  };
273
- proto._activateProcess = function activateProcess(bp) {
272
+ DefinitionExecution.prototype._activateProcess = function activateProcess(bp) {
274
273
  const handlers = this[kMessageHandlers];
275
274
  bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
276
275
  noAck: true,
@@ -302,7 +301,7 @@ proto._activateProcess = function activateProcess(bp) {
302
301
  priority: 100
303
302
  });
304
303
  };
305
- proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
304
+ DefinitionExecution.prototype._onChildEvent = function onChildEvent(routingKey, originalMessage) {
306
305
  const message = (0, _messageHelper.cloneMessage)(originalMessage);
307
306
  const content = message.content;
308
307
  const parent = content.parent = content.parent || {};
@@ -319,13 +318,13 @@ proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
319
318
  if (!isDirectChild) return;
320
319
  this[kProcessesQ].queueMessage(message.fields, (0, _messageHelper.cloneContent)(content), message.properties);
321
320
  };
322
- proto._deactivate = function deactivate() {
321
+ DefinitionExecution.prototype._deactivate = function deactivate() {
323
322
  this.broker.cancel('_definition-api-consumer');
324
323
  this.broker.cancel(`_definition-activity-${this.executionId}`);
325
324
  for (const bp of this[kProcesses].running) this._deactivateProcess(bp);
326
325
  this[kActivated] = false;
327
326
  };
328
- proto._deactivateProcess = function deactivateProcess(bp) {
327
+ DefinitionExecution.prototype._deactivateProcess = function deactivateProcess(bp) {
329
328
  bp.broker.cancel('_definition-outbound-message-consumer');
330
329
  bp.broker.cancel('_definition-activity-consumer');
331
330
  bp.broker.cancel('_definition-signal-consumer');
@@ -333,7 +332,7 @@ proto._deactivateProcess = function deactivateProcess(bp) {
333
332
  bp.broker.cancel('_definition-call-consumer');
334
333
  bp.broker.cancel('_definition-call-cancel-consumer');
335
334
  };
336
- proto._onProcessMessage = function onProcessMessage(routingKey, message) {
335
+ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(routingKey, message) {
337
336
  const content = message.content;
338
337
  const isRedelivered = message.fields.redelivered;
339
338
  const {
@@ -411,7 +410,7 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
411
410
  }
412
411
  }
413
412
  };
414
- proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
413
+ DefinitionExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
415
414
  let previousMsg;
416
415
  const postponed = this[kProcesses].postponed;
417
416
  const idx = postponed.findIndex(msg => msg.content.executionId === message.content.executionId);
@@ -421,7 +420,7 @@ proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage
421
420
  if (previousMsg) previousMsg.ack();
422
421
  if (postponeMessage) postponed.push(message);
423
422
  };
424
- proto._onProcessCompleted = function onProcessCompleted(message) {
423
+ DefinitionExecution.prototype._onProcessCompleted = function onProcessCompleted(message) {
425
424
  this._stateChangeMessage(message, false);
426
425
  if (message.fields.redelivered) return message.ack();
427
426
  const {
@@ -440,7 +439,7 @@ proto._onProcessCompleted = function onProcessCompleted(message) {
440
439
  this._complete('completed');
441
440
  }
442
441
  };
443
- proto._onStopped = function onStopped(message) {
442
+ DefinitionExecution.prototype._onStopped = function onStopped(message) {
444
443
  const running = this[kProcesses].running;
445
444
  this._debug(`stop definition execution (stop process executions ${running.length})`);
446
445
  this[kProcessesQ].close();
@@ -454,7 +453,7 @@ proto._onStopped = function onStopped(message) {
454
453
  persistent: false
455
454
  });
456
455
  };
457
- proto._onApiMessage = function onApiMessage(routingKey, message) {
456
+ DefinitionExecution.prototype._onApiMessage = function onApiMessage(routingKey, message) {
458
457
  const messageType = message.properties.type;
459
458
  const delegate = message.properties.delegate;
460
459
  if (delegate && this.id === message.content.id) {
@@ -478,7 +477,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
478
477
  });
479
478
  }
480
479
  };
481
- proto._startProcessesByMessage = function startProcessesByMessage(reference) {
480
+ DefinitionExecution.prototype._startProcessesByMessage = function startProcessesByMessage(reference) {
482
481
  const {
483
482
  processes: bps,
484
483
  running
@@ -505,7 +504,7 @@ proto._startProcessesByMessage = function startProcessesByMessage(reference) {
505
504
  if (reference.referenceType === 'message') return;
506
505
  }
507
506
  };
508
- proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
507
+ DefinitionExecution.prototype._onMessageOutbound = function onMessageOutbound(routingKey, message) {
509
508
  const content = message.content;
510
509
  const {
511
510
  target,
@@ -531,7 +530,7 @@ proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
531
530
  targetProcess.run();
532
531
  targetProcess.sendMessage(message);
533
532
  };
534
- proto._onCallActivity = function onCallActivity(routingKey, message) {
533
+ DefinitionExecution.prototype._onCallActivity = function onCallActivity(routingKey, message) {
535
534
  const content = message.content;
536
535
  const {
537
536
  calledElement,
@@ -564,7 +563,7 @@ proto._onCallActivity = function onCallActivity(routingKey, message) {
564
563
  inbound: [(0, _messageHelper.cloneContent)(content)]
565
564
  });
566
565
  };
567
- proto._onCancelCallActivity = function onCancelCallActivity(routingKey, message) {
566
+ DefinitionExecution.prototype._onCancelCallActivity = function onCancelCallActivity(routingKey, message) {
568
567
  const {
569
568
  calledElement,
570
569
  id: fromId,
@@ -578,7 +577,7 @@ proto._onCancelCallActivity = function onCancelCallActivity(routingKey, message)
578
577
  this._debug(`cancel call from <${fromParent.id}.${fromId}> to <${calledElement}>`);
579
578
  targetProcess.getApi().discard();
580
579
  };
581
- proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage) {
580
+ DefinitionExecution.prototype._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage) {
582
581
  const content = executeMessage.content;
583
582
  const messageType = executeMessage.properties.type;
584
583
  const delegateMessage = executeMessage.content.message;
@@ -604,13 +603,13 @@ proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage
604
603
  type: messageType
605
604
  });
606
605
  };
607
- proto._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
606
+ DefinitionExecution.prototype._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
608
607
  const running = this[kProcesses].running;
609
608
  const idx = running.findIndex(p => p.executionId === processExecutionId);
610
609
  if (idx === -1) return;
611
610
  return running.splice(idx, 1)[0];
612
611
  };
613
- proto._complete = function complete(completionType, content, options) {
612
+ DefinitionExecution.prototype._complete = function complete(completionType, content, options) {
614
613
  this._deactivate();
615
614
  const stateMessage = this[kExecuteMessage];
616
615
  this._debug(`definition execution ${completionType} in ${Date.now() - stateMessage.properties.timestamp}ms`);
@@ -631,7 +630,7 @@ proto._complete = function complete(completionType, content, options) {
631
630
  ...options
632
631
  });
633
632
  };
634
- proto._createMessage = function createMessage(content = {}) {
633
+ DefinitionExecution.prototype._createMessage = function createMessage(content = {}) {
635
634
  return {
636
635
  id: this.id,
637
636
  type: this.type,
@@ -640,7 +639,7 @@ proto._createMessage = function createMessage(content = {}) {
640
639
  ...content
641
640
  };
642
641
  };
643
- proto._getProcessApi = function getProcessApi(message) {
642
+ DefinitionExecution.prototype._getProcessApi = function getProcessApi(message) {
644
643
  const content = message.content;
645
644
  let api = this._getProcessApiByExecutionId(content.executionId, message);
646
645
  if (api) return api;
@@ -653,11 +652,11 @@ proto._getProcessApi = function getProcessApi(message) {
653
652
  if (api) return api;
654
653
  }
655
654
  };
656
- proto._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentExecutionId, message) {
655
+ DefinitionExecution.prototype._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentExecutionId, message) {
657
656
  const processInstance = this.getProcessByExecutionId(parentExecutionId);
658
657
  if (!processInstance) return;
659
658
  return processInstance.getApi(message);
660
659
  };
661
- proto._debug = function debug(logMessage) {
660
+ DefinitionExecution.prototype._debug = function debug(logMessage) {
662
661
  this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
663
662
  };
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.RunError = exports.BpmnError = exports.ActivityError = void 0;
7
7
  exports.makeErrorFromMessage = makeErrorFromMessage;
8
- var _messageHelper = require("../messageHelper");
8
+ var _messageHelper = require("../messageHelper.js");
9
9
  class ActivityError extends Error {
10
10
  constructor(description, sourceMessage, inner) {
11
11
  super(description);