bpmn-elements 8.2.3 → 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} +8 -2
  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 +55 -48
  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 +31 -31
  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 +5 -2
  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 +55 -49
  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 ProcessExecution from './ProcessExecution';
2
- import {getUniqueId} from '../shared';
3
- import {ProcessApi} from '../Api';
4
- import {ProcessBroker} from '../EventBroker';
5
- import {cloneMessage, cloneContent, cloneParent} from '../messageHelper';
6
- import {makeErrorFromMessage} from '../error/Errors';
1
+ import ProcessExecution from './ProcessExecution.js';
2
+ import {getUniqueId} from '../shared.js';
3
+ import {ProcessApi} from '../Api.js';
4
+ import {ProcessBroker} from '../EventBroker.js';
5
+ import {cloneMessage, cloneContent, cloneParent} from '../messageHelper.js';
6
+ import {makeErrorFromMessage} from '../error/Errors.js';
7
7
 
8
8
  const kConsuming = Symbol.for('consuming');
9
9
  const kCounters = Symbol.for('counters');
@@ -56,30 +56,28 @@ export function Process(processDef, context) {
56
56
  this[kExtensions] = context.loadExtensions(this);
57
57
  }
58
58
 
59
- const proto = Process.prototype;
60
-
61
- Object.defineProperty(proto, 'counters', {
59
+ Object.defineProperty(Process.prototype, 'counters', {
62
60
  enumerable: true,
63
61
  get() {
64
62
  return {...this[kCounters]};
65
63
  },
66
64
  });
67
65
 
68
- Object.defineProperty(proto, 'extensions', {
66
+ Object.defineProperty(Process.prototype, 'extensions', {
69
67
  enumerable: true,
70
68
  get() {
71
69
  return this[kExtensions];
72
70
  },
73
71
  });
74
72
 
75
- Object.defineProperty(proto, 'stopped', {
73
+ Object.defineProperty(Process.prototype, 'stopped', {
76
74
  enumerable: true,
77
75
  get() {
78
76
  return this[kStopped];
79
77
  },
80
78
  });
81
79
 
82
- Object.defineProperty(proto, 'isRunning', {
80
+ Object.defineProperty(Process.prototype, 'isRunning', {
83
81
  enumerable: true,
84
82
  get() {
85
83
  if (!this[kConsuming]) return false;
@@ -87,7 +85,7 @@ Object.defineProperty(proto, 'isRunning', {
87
85
  },
88
86
  });
89
87
 
90
- Object.defineProperty(proto, 'executionId', {
88
+ Object.defineProperty(Process.prototype, 'executionId', {
91
89
  enumerable: true,
92
90
  get() {
93
91
  const {executionId, initExecutionId} = this[kExec];
@@ -95,28 +93,28 @@ Object.defineProperty(proto, 'executionId', {
95
93
  },
96
94
  });
97
95
 
98
- Object.defineProperty(proto, 'execution', {
96
+ Object.defineProperty(Process.prototype, 'execution', {
99
97
  enumerable: true,
100
98
  get() {
101
99
  return this[kExec].execution;
102
100
  },
103
101
  });
104
102
 
105
- Object.defineProperty(proto, 'status', {
103
+ Object.defineProperty(Process.prototype, 'status', {
106
104
  enumerable: true,
107
105
  get() {
108
106
  return this[kStatus];
109
107
  },
110
108
  });
111
109
 
112
- proto.init = function init(useAsExecutionId) {
110
+ Process.prototype.init = function init(useAsExecutionId) {
113
111
  const exec = this[kExec];
114
112
  const initExecutionId = exec.initExecutionId = useAsExecutionId || getUniqueId(this.id);
115
113
  this._debug(`initialized with executionId <${initExecutionId}>`);
116
114
  this._publishEvent('init', this._createMessage({executionId: initExecutionId}));
117
115
  };
118
116
 
119
- proto.run = function run(runContent) {
117
+ Process.prototype.run = function run(runContent) {
120
118
  if (this.isRunning) throw new Error(`process <${this.id}> is already running`);
121
119
 
122
120
  const exec = this[kExec];
@@ -133,7 +131,7 @@ proto.run = function run(runContent) {
133
131
  this._activateRunConsumers();
134
132
  };
135
133
 
136
- proto.resume = function resume() {
134
+ Process.prototype.resume = function resume() {
137
135
  if (this.isRunning) throw new Error(`cannot resume running process <${this.id}>`);
138
136
  if (!this.status) return this;
139
137
 
@@ -145,7 +143,7 @@ proto.resume = function resume() {
145
143
  return this;
146
144
  };
147
145
 
148
- proto.recover = function recover(state) {
146
+ Process.prototype.recover = function recover(state) {
149
147
  if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
150
148
  if (!state) return this;
151
149
 
@@ -165,27 +163,27 @@ proto.recover = function recover(state) {
165
163
  return this;
166
164
  };
167
165
 
168
- proto.shake = function shake(startId) {
166
+ Process.prototype.shake = function shake(startId) {
169
167
  if (this.isRunning) return this.execution.shake(startId);
170
168
  return new ProcessExecution(this, this.context).shake(startId);
171
169
  };
172
170
 
173
- proto.stop = function stop() {
171
+ Process.prototype.stop = function stop() {
174
172
  if (!this.isRunning) return;
175
173
  this.getApi().stop();
176
174
  };
177
175
 
178
- proto.getApi = function getApi(message) {
176
+ Process.prototype.getApi = function getApi(message) {
179
177
  const execution = this.execution;
180
178
  if (execution) return execution.getApi(message);
181
179
  return ProcessApi(this.broker, message || this[kStateMessage]);
182
180
  };
183
181
 
184
- proto.signal = function signal(message) {
182
+ Process.prototype.signal = function signal(message) {
185
183
  return this.getApi().signal(message, {delegate: true});
186
184
  };
187
185
 
188
- proto.getState = function getState() {
186
+ Process.prototype.getState = function getState() {
189
187
  return this._createMessage({
190
188
  environment: this.environment.getState(),
191
189
  status: this.status,
@@ -196,11 +194,11 @@ proto.getState = function getState() {
196
194
  });
197
195
  };
198
196
 
199
- proto.cancelActivity = function cancelActivity(message) {
197
+ Process.prototype.cancelActivity = function cancelActivity(message) {
200
198
  return this.getApi().cancel(message, {delegate: true});
201
199
  };
202
200
 
203
- proto._activateRunConsumers = function activateRunConsumers() {
201
+ Process.prototype._activateRunConsumers = function activateRunConsumers() {
204
202
  this[kConsuming] = true;
205
203
  const broker = this.broker;
206
204
  const {onApiMessage, onRunMessage} = this[kMessageHandlers];
@@ -208,7 +206,7 @@ proto._activateRunConsumers = function activateRunConsumers() {
208
206
  broker.getQueue('run-q').assertConsumer(onRunMessage, {exclusive: true, consumerTag: '_process-run'});
209
207
  };
210
208
 
211
- proto._deactivateRunConsumers = function deactivateRunConsumers() {
209
+ Process.prototype._deactivateRunConsumers = function deactivateRunConsumers() {
212
210
  const broker = this.broker;
213
211
  broker.cancel('_process-api');
214
212
  broker.cancel('_process-run');
@@ -216,7 +214,7 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
216
214
  this[kConsuming] = false;
217
215
  };
218
216
 
219
- proto._onRunMessage = function onRunMessage(routingKey, message) {
217
+ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
220
218
  const {content, fields} = message;
221
219
 
222
220
  if (routingKey === 'run.resume') {
@@ -303,7 +301,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
303
301
  message.ack();
304
302
  };
305
303
 
306
- proto._onResumeMessage = function onResumeMessage(message) {
304
+ Process.prototype._onResumeMessage = function onResumeMessage(message) {
307
305
  message.ack();
308
306
 
309
307
  const stateMessage = this[kStateMessage];
@@ -325,7 +323,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
325
323
  return this.broker.publish('run', stateMessage.fields.routingKey, cloneContent(stateMessage.content), stateMessage.properties);
326
324
  };
327
325
 
328
- proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
326
+ Process.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
329
327
  const content = message.content;
330
328
  const messageType = message.properties.type;
331
329
  message.ack();
@@ -352,12 +350,12 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
352
350
  executeMessage.ack();
353
351
  };
354
352
 
355
- proto._publishEvent = function publishEvent(state, content) {
353
+ Process.prototype._publishEvent = function publishEvent(state, content) {
356
354
  const eventContent = this._createMessage({...content, state});
357
355
  this.broker.publish('event', `process.${state}`, eventContent, {type: state, mandatory: state === 'error'});
358
356
  };
359
357
 
360
- proto.sendMessage = function sendMessage(message) {
358
+ Process.prototype.sendMessage = function sendMessage(message) {
361
359
  const messageContent = message && message.content;
362
360
  if (!messageContent) return;
363
361
 
@@ -373,35 +371,35 @@ proto.sendMessage = function sendMessage(message) {
373
371
  this.getApi().sendApiMessage(message.properties.type || 'message', cloneContent(messageContent), {delegate: true});
374
372
  };
375
373
 
376
- proto.getActivityById = function getActivityById(childId) {
374
+ Process.prototype.getActivityById = function getActivityById(childId) {
377
375
  const execution = this.execution;
378
376
  if (execution) return execution.getActivityById(childId);
379
377
  return this.context.getActivityById(childId);
380
378
  };
381
379
 
382
- proto.getActivities = function getActivities() {
380
+ Process.prototype.getActivities = function getActivities() {
383
381
  const execution = this.execution;
384
382
  if (execution) return execution.getActivities();
385
383
  return this.context.getActivities(this.id);
386
384
  };
387
385
 
388
- proto.getStartActivities = function getStartActivities(filterOptions) {
386
+ Process.prototype.getStartActivities = function getStartActivities(filterOptions) {
389
387
  return this.context.getStartActivities(filterOptions, this.id);
390
388
  };
391
389
 
392
- proto.getSequenceFlows = function getSequenceFlows() {
390
+ Process.prototype.getSequenceFlows = function getSequenceFlows() {
393
391
  const execution = this.execution;
394
392
  if (execution) return execution.getSequenceFlows();
395
393
  return this.context.getSequenceFlows();
396
394
  };
397
395
 
398
- proto.getPostponed = function getPostponed(...args) {
396
+ Process.prototype.getPostponed = function getPostponed(...args) {
399
397
  const execution = this.execution;
400
398
  if (!execution) return [];
401
399
  return execution.getPostponed(...args);
402
400
  };
403
401
 
404
- proto._onApiMessage = function onApiMessage(routingKey, message) {
402
+ Process.prototype._onApiMessage = function onApiMessage(routingKey, message) {
405
403
  const messageType = message.properties.type;
406
404
 
407
405
  switch (messageType) {
@@ -413,13 +411,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
413
411
  }
414
412
  };
415
413
 
416
- proto._onStop = function onStop() {
414
+ Process.prototype._onStop = function onStop() {
417
415
  this[kStopped] = true;
418
416
  this._deactivateRunConsumers();
419
417
  return this._publishEvent('stop');
420
418
  };
421
419
 
422
- proto._createMessage = function createMessage(override) {
420
+ Process.prototype._createMessage = function createMessage(override) {
423
421
  return {
424
422
  id: this.id,
425
423
  type: this.type,
@@ -430,6 +428,6 @@ proto._createMessage = function createMessage(override) {
430
428
  };
431
429
  };
432
430
 
433
- proto._debug = function debug(msg) {
431
+ Process.prototype._debug = function debug(msg) {
434
432
  this.logger.debug(`<${this.id}> ${msg}`);
435
433
  };
@@ -1,6 +1,6 @@
1
- import {ProcessApi} from '../Api';
2
- import {cloneContent, cloneMessage, pushParent} from '../messageHelper';
3
- import {getUniqueId} from '../shared';
1
+ import {ProcessApi} from '../Api.js';
2
+ import {cloneContent, cloneMessage, pushParent} from '../messageHelper.js';
3
+ import {getUniqueId} from '../shared.js';
4
4
 
5
5
  export default ProcessExecution;
6
6
 
@@ -54,42 +54,40 @@ function ProcessExecution(parentActivity, context) {
54
54
  };
55
55
  }
56
56
 
57
- const proto = ProcessExecution.prototype;
58
-
59
- Object.defineProperty(proto, 'stopped', {
57
+ Object.defineProperty(ProcessExecution.prototype, 'stopped', {
60
58
  enumerable: true,
61
59
  get() {
62
60
  return this[kStopped];
63
61
  },
64
62
  });
65
63
 
66
- Object.defineProperty(proto, 'completed', {
64
+ Object.defineProperty(ProcessExecution.prototype, 'completed', {
67
65
  enumerable: true,
68
66
  get() {
69
67
  return this[kCompleted];
70
68
  },
71
69
  });
72
70
 
73
- Object.defineProperty(proto, 'status', {
71
+ Object.defineProperty(ProcessExecution.prototype, 'status', {
74
72
  enumerable: true,
75
73
  get() {
76
74
  return this[kStatus];
77
75
  },
78
76
  });
79
77
 
80
- Object.defineProperty(proto, 'postponedCount', {
78
+ Object.defineProperty(ProcessExecution.prototype, 'postponedCount', {
81
79
  get() {
82
80
  return this[kElements].postponed.length;
83
81
  },
84
82
  });
85
83
 
86
- Object.defineProperty(proto, 'isRunning', {
84
+ Object.defineProperty(ProcessExecution.prototype, 'isRunning', {
87
85
  get() {
88
86
  return this[kActivated];
89
87
  },
90
88
  });
91
89
 
92
- proto.execute = function execute(executeMessage) {
90
+ ProcessExecution.prototype.execute = function execute(executeMessage) {
93
91
  if (!executeMessage) throw new Error('Process execution requires message');
94
92
  if (!executeMessage.content || !executeMessage.content.executionId) throw new Error('Process execution requires execution id');
95
93
 
@@ -115,7 +113,7 @@ proto.execute = function execute(executeMessage) {
115
113
  return true;
116
114
  };
117
115
 
118
- proto.resume = function resume() {
116
+ ProcessExecution.prototype.resume = function resume() {
119
117
  this._debug(`resume process execution at ${this.status}`);
120
118
 
121
119
  if (this[kCompleted]) return this._complete('completed');
@@ -158,7 +156,7 @@ proto.resume = function resume() {
158
156
  if (!postponed.length && status === 'executing') return this._complete('completed');
159
157
  };
160
158
 
161
- proto.recover = function recover(state) {
159
+ ProcessExecution.prototype.recover = function recover(state) {
162
160
  if (!state) return this;
163
161
  this.executionId = state.executionId;
164
162
 
@@ -204,7 +202,7 @@ proto.recover = function recover(state) {
204
202
  return this;
205
203
  };
206
204
 
207
- proto.shake = function shake(fromId) {
205
+ ProcessExecution.prototype.shake = function shake(fromId) {
208
206
  let executing = true;
209
207
  const id = this.id;
210
208
  if (!this.isRunning) {
@@ -239,11 +237,11 @@ proto.shake = function shake(fromId) {
239
237
  return result;
240
238
  };
241
239
 
242
- proto.stop = function stop() {
240
+ ProcessExecution.prototype.stop = function stop() {
243
241
  this.getApi().stop();
244
242
  };
245
243
 
246
- proto.getPostponed = function getPostponed(filterFn) {
244
+ ProcessExecution.prototype.getPostponed = function getPostponed(filterFn) {
247
245
  const result = [];
248
246
  for (const msg of this[kElements].postponed.slice()) {
249
247
  const api = this._getChildApi(msg);
@@ -254,7 +252,7 @@ proto.getPostponed = function getPostponed(filterFn) {
254
252
  return result;
255
253
  };
256
254
 
257
- proto.discard = function discard() {
255
+ ProcessExecution.prototype.discard = function discard() {
258
256
  this[kStatus] = 'discard';
259
257
  return this[kActivityQ].queueMessage({routingKey: 'execution.discard'}, {
260
258
  id: this.id,
@@ -263,7 +261,7 @@ proto.discard = function discard() {
263
261
  }, {type: 'discard'});
264
262
  };
265
263
 
266
- proto.getState = function getState() {
264
+ ProcessExecution.prototype.getState = function getState() {
267
265
  const {children, flows, outboundMessageFlows, associations} = this[kElements];
268
266
  return {
269
267
  executionId: this.executionId,
@@ -281,19 +279,19 @@ proto.getState = function getState() {
281
279
  };
282
280
  };
283
281
 
284
- proto.getActivities = function getActivities() {
282
+ ProcessExecution.prototype.getActivities = function getActivities() {
285
283
  return this[kElements].children.slice();
286
284
  };
287
285
 
288
- proto.getActivityById = function getActivityById(activityId) {
286
+ ProcessExecution.prototype.getActivityById = function getActivityById(activityId) {
289
287
  return this[kElements].children.find((child) => child.id === activityId);
290
288
  };
291
289
 
292
- proto.getSequenceFlows = function getSequenceFlows() {
290
+ ProcessExecution.prototype.getSequenceFlows = function getSequenceFlows() {
293
291
  return this[kElements].flows.slice();
294
292
  };
295
293
 
296
- proto.getApi = function getApi(message) {
294
+ ProcessExecution.prototype.getApi = function getApi(message) {
297
295
  if (!message) return ProcessApi(this.broker, this[kExecuteMessage]);
298
296
 
299
297
  const content = message.content;
@@ -317,7 +315,7 @@ proto.getApi = function getApi(message) {
317
315
  return api;
318
316
  };
319
317
 
320
- proto._start = function start() {
318
+ ProcessExecution.prototype._start = function start() {
321
319
  if (this[kElements].children.length === 0) {
322
320
  return this._complete('completed');
323
321
  }
@@ -344,14 +342,22 @@ proto._start = function start() {
344
342
  });
345
343
  };
346
344
 
347
- proto._activate = function activate() {
345
+ ProcessExecution.prototype._activate = function activate() {
348
346
  const {onApiMessage, onMessageFlowEvent, onActivityEvent} = this[kMessageHandlers];
349
347
 
350
- this.broker.subscribeTmp('api', '#', onApiMessage, {
351
- noAck: true,
352
- consumerTag: `_process-api-consumer-${this.executionId}`,
353
- priority: 200,
354
- });
348
+ if (!this.isSubProcess) {
349
+ this.broker.consume('api-q', onApiMessage, {
350
+ noAck: true,
351
+ consumerTag: `_process-api-consumer-${this.executionId}`,
352
+ priority: 200,
353
+ });
354
+ } else {
355
+ this.broker.subscribeTmp('api', '#', onApiMessage, {
356
+ noAck: true,
357
+ consumerTag: `_process-api-consumer-${this.executionId}`,
358
+ priority: 200,
359
+ });
360
+ }
355
361
 
356
362
  const {outboundMessageFlows, flows, associations, startActivities, triggeredByEvent, children} = this[kElements];
357
363
 
@@ -398,7 +404,7 @@ proto._activate = function activate() {
398
404
  this[kActivated] = true;
399
405
  };
400
406
 
401
- proto._deactivate = function deactivate() {
407
+ ProcessExecution.prototype._deactivate = function deactivate() {
402
408
  const broker = this.broker;
403
409
  const executionId = this.executionId;
404
410
  broker.cancel(`_process-api-consumer-${executionId}`);
@@ -428,7 +434,7 @@ proto._deactivate = function deactivate() {
428
434
  this[kActivated] = false;
429
435
  };
430
436
 
431
- proto._onDelegateEvent = function onDelegateEvent(message) {
437
+ ProcessExecution.prototype._onDelegateEvent = function onDelegateEvent(message) {
432
438
  const eventType = message.properties.type;
433
439
  let delegate = true;
434
440
 
@@ -451,11 +457,11 @@ proto._onDelegateEvent = function onDelegateEvent(message) {
451
457
  return delegate;
452
458
  };
453
459
 
454
- proto._onMessageFlowEvent = function onMessageFlowEvent(routingKey, message) {
460
+ ProcessExecution.prototype._onMessageFlowEvent = function onMessageFlowEvent(routingKey, message) {
455
461
  this.broker.publish('message', routingKey, cloneContent(message.content), message.properties);
456
462
  };
457
463
 
458
- proto._onActivityEvent = function onActivityEvent(routingKey, message) {
464
+ ProcessExecution.prototype._onActivityEvent = function onActivityEvent(routingKey, message) {
459
465
  if (message.fields.redelivered && message.properties.persistent === false) return;
460
466
 
461
467
  const content = message.content;
@@ -487,7 +493,7 @@ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
487
493
  this[kActivityQ].queueMessage(message.fields, cloneContent(content), {persistent: true, ...message.properties});
488
494
  };
489
495
 
490
- proto._onChildMessage = function onChildMessage(routingKey, message) {
496
+ ProcessExecution.prototype._onChildMessage = function onChildMessage(routingKey, message) {
491
497
  if (message.fields.redelivered && message.properties.persistent === false) return message.ack();
492
498
 
493
499
  const content = message.content;
@@ -550,13 +556,13 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
550
556
  }
551
557
  };
552
558
 
553
- proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
559
+ ProcessExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
554
560
  const previousMsg = this._popPostponed(message.content);
555
561
  if (previousMsg) previousMsg.ack();
556
562
  if (postponeMessage) this[kElements].postponed.push(message);
557
563
  };
558
564
 
559
- proto._popPostponed = function popPostponed(byContent) {
565
+ ProcessExecution.prototype._popPostponed = function popPostponed(byContent) {
560
566
  const {postponed, detachedActivities} = this[kElements];
561
567
 
562
568
  const postponedIdx = postponed.findIndex((msg) => {
@@ -575,7 +581,7 @@ proto._popPostponed = function popPostponed(byContent) {
575
581
  return postponedMsg;
576
582
  };
577
583
 
578
- proto._onChildCompleted = function onChildCompleted(message) {
584
+ ProcessExecution.prototype._onChildCompleted = function onChildCompleted(message) {
579
585
  this._stateChangeMessage(message, false);
580
586
  if (message.fields.redelivered) return message.ack();
581
587
 
@@ -611,7 +617,7 @@ proto._onChildCompleted = function onChildCompleted(message) {
611
617
  }
612
618
  };
613
619
 
614
- proto._stopExecution = function stopExecution(message) {
620
+ ProcessExecution.prototype._stopExecution = function stopExecution(message) {
615
621
  const postponedCount = this.postponedCount;
616
622
  this._debug(`stop process execution (stop child executions ${postponedCount})`);
617
623
  if (postponedCount) {
@@ -625,7 +631,7 @@ proto._stopExecution = function stopExecution(message) {
625
631
  }, {type: 'stopped', persistent: false});
626
632
  };
627
633
 
628
- proto._onDiscard = function onDiscard() {
634
+ ProcessExecution.prototype._onDiscard = function onDiscard() {
629
635
  this._deactivate();
630
636
  const running = this[kElements].postponed.splice(0);
631
637
  this._debug(`discard process execution (discard child executions ${running.length})`);
@@ -637,7 +643,7 @@ proto._onDiscard = function onDiscard() {
637
643
  return this._complete('discard');
638
644
  };
639
645
 
640
- proto._onApiMessage = function onApiMessage(routingKey, message) {
646
+ ProcessExecution.prototype._onApiMessage = function onApiMessage(routingKey, message) {
641
647
  const executionId = this.executionId;
642
648
  const broker = this.broker;
643
649
  if (message.properties.delegate) {
@@ -678,7 +684,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
678
684
  }
679
685
  };
680
686
 
681
- proto._complete = function complete(completionType, content) {
687
+ ProcessExecution.prototype._complete = function complete(completionType, content) {
682
688
  this._deactivate();
683
689
  this._debug(`process execution ${completionType}`);
684
690
  this[kCompleted] = true;
@@ -693,7 +699,7 @@ proto._complete = function complete(completionType, content) {
693
699
  }), {type: completionType, mandatory: completionType === 'error'});
694
700
  };
695
701
 
696
- proto._terminate = function terminate(message) {
702
+ ProcessExecution.prototype._terminate = function terminate(message) {
697
703
  this[kStatus] = 'terminated';
698
704
  this._debug('terminating process execution');
699
705
 
@@ -711,23 +717,23 @@ proto._terminate = function terminate(message) {
711
717
  this[kActivityQ].purge();
712
718
  };
713
719
 
714
- proto._getFlowById = function getFlowById(flowId) {
720
+ ProcessExecution.prototype._getFlowById = function getFlowById(flowId) {
715
721
  return this[kElements].flows.find((f) => f.id === flowId);
716
722
  };
717
723
 
718
- proto._getAssociationById = function getAssociationById(associationId) {
724
+ ProcessExecution.prototype._getAssociationById = function getAssociationById(associationId) {
719
725
  return this[kElements].associations.find((a) => a.id === associationId);
720
726
  };
721
727
 
722
- proto._getMessageFlowById = function getMessageFlowById(flowId) {
728
+ ProcessExecution.prototype._getMessageFlowById = function getMessageFlowById(flowId) {
723
729
  return this[kElements].outboundMessageFlows.find((f) => f.id === flowId);
724
730
  };
725
731
 
726
- proto._getChildById = function getChildById(childId) {
732
+ ProcessExecution.prototype._getChildById = function getChildById(childId) {
727
733
  return this.getActivityById(childId) || this._getFlowById(childId);
728
734
  };
729
735
 
730
- proto._getChildApi = function getChildApi(message) {
736
+ ProcessExecution.prototype._getChildApi = function getChildApi(message) {
731
737
  const content = message.content;
732
738
 
733
739
  let child = this._getChildById(content.id);
@@ -746,12 +752,12 @@ proto._getChildApi = function getChildApi(message) {
746
752
  }
747
753
  };
748
754
 
749
- proto._onShookEnd = function onShookEnd(message) {
755
+ ProcessExecution.prototype._onShookEnd = function onShookEnd(message) {
750
756
  const routingKey = message.fields.routingKey;
751
757
  if (routingKey !== 'activity.shake.end') return;
752
758
  this[kElements].startSequences[message.content.id] = cloneMessage(message);
753
759
  };
754
760
 
755
- proto._debug = function debugMessage(logMessage) {
761
+ ProcessExecution.prototype._debug = function debugMessage(logMessage) {
756
762
  this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
757
763
  };
@@ -1,6 +1,6 @@
1
- import Activity from '../activity/Activity';
2
- import {ActivityError} from '../error/Errors';
3
- import {cloneContent} from '../messageHelper';
1
+ import Activity from '../activity/Activity.js';
2
+ import {ActivityError} from '../error/Errors.js';
3
+ import {cloneContent} from '../messageHelper.js';
4
4
 
5
5
  export default function CallActivity(activityDef, context) {
6
6
  return new Activity(CallActivityBehaviour, activityDef, context);
@@ -18,9 +18,7 @@ export function CallActivityBehaviour(activity) {
18
18
  this.environment = activity.environment;
19
19
  }
20
20
 
21
- const proto = CallActivityBehaviour.prototype;
22
-
23
- proto.execute = function execute(executeMessage) {
21
+ CallActivityBehaviour.prototype.execute = function execute(executeMessage) {
24
22
  const executeContent = executeMessage.content;
25
23
  const loopCharacteristics = this.loopCharacteristics;
26
24
  if (loopCharacteristics && executeContent.isRootScope) {
@@ -59,7 +57,7 @@ proto.execute = function execute(executeMessage) {
59
57
  });
60
58
  };
61
59
 
62
- proto._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, executeMessage, routingKey, message) {
60
+ CallActivityBehaviour.prototype._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, executeMessage, routingKey, message) {
63
61
  if (!message.properties.delegate) return;
64
62
  const {content: delegateContent} = message;
65
63
  if (!delegateContent || !delegateContent.message) return;
@@ -82,7 +80,7 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, exe
82
80
  return this._onApiMessage(calledElement, executeMessage, routingKey, message);
83
81
  };
84
82
 
85
- proto._onApiMessage = function onApiMessage(calledElement, executeMessage, routingKey, message) {
83
+ CallActivityBehaviour.prototype._onApiMessage = function onApiMessage(calledElement, executeMessage, routingKey, message) {
86
84
  const {type: messageType, correlationId} = message.properties;
87
85
  const executeContent = executeMessage.content;
88
86
 
@@ -123,7 +121,7 @@ proto._onApiMessage = function onApiMessage(calledElement, executeMessage, routi
123
121
  }
124
122
  };
125
123
 
126
- proto._stop = function stop(executionId) {
124
+ CallActivityBehaviour.prototype._stop = function stop(executionId) {
127
125
  const broker = this.broker;
128
126
  broker.cancel(`_api-${executionId}`);
129
127
  broker.cancel(`_api-delegated-${executionId}`);
@@ -1,5 +1,5 @@
1
- import {RunError} from '../error/Errors';
2
- import {cloneContent, cloneMessage, unshiftParent, cloneParent} from '../messageHelper';
1
+ import {RunError} from '../error/Errors.js';
2
+ import {cloneContent, cloneMessage, unshiftParent, cloneParent} from '../messageHelper.js';
3
3
 
4
4
  export default function LoopCharacteristics(activity, loopCharacteristics) {
5
5
  this.activity = activity;