bpmn-elements 5.1.3 → 7.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 (119) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/README.md +9 -3
  3. package/dist/index.js +71 -39
  4. package/dist/src/Api.js +77 -76
  5. package/dist/src/Context.js +169 -164
  6. package/dist/src/Environment.js +90 -102
  7. package/dist/src/EventBroker.js +89 -88
  8. package/dist/src/ExtensionsMapper.js +2 -2
  9. package/dist/src/MessageFormatter.js +164 -95
  10. package/dist/src/Scripts.js +6 -2
  11. package/dist/src/Timers.js +4 -6
  12. package/dist/src/activity/Activity.js +1108 -901
  13. package/dist/src/activity/ActivityExecution.js +342 -297
  14. package/dist/src/activity/Dummy.js +3 -3
  15. package/dist/src/definition/Definition.js +498 -444
  16. package/dist/src/definition/DefinitionExecution.js +722 -409
  17. package/dist/src/error/Errors.js +17 -7
  18. package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
  19. package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
  20. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
  21. package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
  22. package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
  23. package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
  24. package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
  25. package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
  26. package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
  27. package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
  28. package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
  29. package/dist/src/events/BoundaryEvent.js +180 -144
  30. package/dist/src/events/EndEvent.js +18 -23
  31. package/dist/src/events/IntermediateCatchEvent.js +44 -58
  32. package/dist/src/events/IntermediateThrowEvent.js +18 -23
  33. package/dist/src/events/StartEvent.js +109 -94
  34. package/dist/src/flows/Association.js +94 -101
  35. package/dist/src/flows/MessageFlow.js +86 -103
  36. package/dist/src/flows/SequenceFlow.js +172 -184
  37. package/dist/src/gateways/EventBasedGateway.js +88 -84
  38. package/dist/src/gateways/ExclusiveGateway.js +13 -16
  39. package/dist/src/gateways/InclusiveGateway.js +11 -14
  40. package/dist/src/gateways/ParallelGateway.js +11 -14
  41. package/dist/src/getPropertyValue.js +34 -34
  42. package/dist/src/io/BpmnIO.js +31 -0
  43. package/dist/src/io/EnvironmentDataObject.js +33 -29
  44. package/dist/src/io/EnvironmentDataStore.js +52 -0
  45. package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
  46. package/dist/src/io/InputOutputSpecification.js +177 -168
  47. package/dist/src/io/Properties.js +252 -0
  48. package/dist/src/messageHelper.js +1 -1
  49. package/dist/src/process/Process.js +433 -359
  50. package/dist/src/process/ProcessExecution.js +744 -645
  51. package/dist/src/shared.js +3 -6
  52. package/dist/src/tasks/CallActivity.js +160 -0
  53. package/dist/src/tasks/LoopCharacteristics.js +309 -330
  54. package/dist/src/tasks/ReceiveTask.js +233 -182
  55. package/dist/src/tasks/ScriptTask.js +35 -41
  56. package/dist/src/tasks/ServiceImplementation.js +13 -20
  57. package/dist/src/tasks/ServiceTask.js +82 -75
  58. package/dist/src/tasks/SignalTask.js +97 -93
  59. package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
  60. package/dist/src/tasks/SubProcess.js +195 -175
  61. package/dist/src/tasks/Task.js +17 -19
  62. package/index.js +8 -0
  63. package/package.json +16 -15
  64. package/src/Api.js +65 -59
  65. package/src/Context.js +142 -132
  66. package/src/Environment.js +88 -100
  67. package/src/EventBroker.js +67 -68
  68. package/src/ExtensionsMapper.js +2 -2
  69. package/src/MessageFormatter.js +132 -74
  70. package/src/Timers.js +4 -4
  71. package/src/activity/Activity.js +916 -757
  72. package/src/activity/ActivityExecution.js +293 -247
  73. package/src/activity/Dummy.js +2 -2
  74. package/src/definition/Definition.js +436 -401
  75. package/src/definition/DefinitionExecution.js +603 -343
  76. package/src/error/Errors.js +11 -6
  77. package/src/eventDefinitions/CancelEventDefinition.js +164 -121
  78. package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
  79. package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
  80. package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
  81. package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
  82. package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
  83. package/src/eventDefinitions/LinkEventDefinition.js +160 -129
  84. package/src/eventDefinitions/MessageEventDefinition.js +178 -121
  85. package/src/eventDefinitions/SignalEventDefinition.js +162 -106
  86. package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
  87. package/src/eventDefinitions/TimerEventDefinition.js +202 -167
  88. package/src/events/BoundaryEvent.js +156 -115
  89. package/src/events/EndEvent.js +15 -18
  90. package/src/events/IntermediateCatchEvent.js +40 -44
  91. package/src/events/IntermediateThrowEvent.js +15 -18
  92. package/src/events/StartEvent.js +84 -50
  93. package/src/flows/Association.js +98 -113
  94. package/src/flows/MessageFlow.js +81 -97
  95. package/src/flows/SequenceFlow.js +145 -163
  96. package/src/gateways/EventBasedGateway.js +75 -68
  97. package/src/gateways/ExclusiveGateway.js +8 -13
  98. package/src/gateways/InclusiveGateway.js +8 -13
  99. package/src/gateways/ParallelGateway.js +8 -13
  100. package/src/getPropertyValue.js +34 -33
  101. package/src/io/BpmnIO.js +20 -0
  102. package/src/io/EnvironmentDataObject.js +29 -18
  103. package/src/io/EnvironmentDataStore.js +33 -0
  104. package/src/io/EnvironmentDataStoreReference.js +33 -0
  105. package/src/io/InputOutputSpecification.js +154 -157
  106. package/src/io/Properties.js +199 -0
  107. package/src/process/Process.js +374 -333
  108. package/src/process/ProcessExecution.js +606 -554
  109. package/src/shared.js +1 -5
  110. package/src/tasks/CallActivity.js +130 -0
  111. package/src/tasks/LoopCharacteristics.js +290 -289
  112. package/src/tasks/ReceiveTask.js +174 -107
  113. package/src/tasks/ScriptTask.js +27 -30
  114. package/src/tasks/ServiceImplementation.js +13 -18
  115. package/src/tasks/ServiceTask.js +67 -60
  116. package/src/tasks/SignalTask.js +77 -52
  117. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  118. package/src/tasks/SubProcess.js +184 -157
  119. package/src/tasks/Task.js +15 -19
@@ -5,507 +5,820 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = DefinitionExecution;
7
7
 
8
+ var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
9
+
8
10
  var _Api = require("../Api");
9
11
 
10
- var _messageHelper = require("../messageHelper");
12
+ var _shared = require("../shared");
11
13
 
12
- var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
14
+ var _messageHelper = require("../messageHelper");
13
15
 
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
- function DefinitionExecution(definition) {
17
- const {
18
- id,
19
- type,
20
- broker,
21
- logger,
22
- environment
23
- } = definition;
24
- const processes = definition.getProcesses();
25
- const processIds = processes.map(({
26
- id: childId
27
- }) => childId);
28
- let executableProcesses = definition.getExecutableProcesses();
29
- const postponed = [];
18
+ const activatedSymbol = Symbol.for('activated');
19
+ const processesQSymbol = Symbol.for('processesQ');
20
+ const completedSymbol = Symbol.for('completed');
21
+ const executeMessageSymbol = Symbol.for('executeMessage');
22
+ const messageHandlersSymbol = Symbol.for('messageHandlers');
23
+ const parentSymbol = Symbol.for('definition');
24
+ const processesSymbol = Symbol.for('processes');
25
+ const statusSymbol = Symbol.for('status');
26
+ const stoppedSymbol = Symbol.for('stopped');
27
+
28
+ function DefinitionExecution(definition, context) {
29
+ const broker = definition.broker;
30
+ this[parentSymbol] = definition;
31
+ this.id = definition.id;
32
+ this.type = definition.type;
33
+ this.broker = broker;
34
+ this.environment = definition.environment;
35
+ this.context = context;
36
+ const processes = this[processesSymbol] = context.getProcesses();
37
+ this[processesSymbol] = {
38
+ processes,
39
+ running: [],
40
+ ids: processes.map(({
41
+ id: childId
42
+ }) => childId),
43
+ executable: context.getExecutableProcesses(),
44
+ postponed: []
45
+ };
30
46
  broker.assertExchange('execution', 'topic', {
31
47
  autoDelete: false,
32
48
  durable: true
33
49
  });
34
- let activityQ,
35
- status = 'init',
36
- executionId,
37
- stopped,
38
- activated,
39
- initMessage,
40
- completed = false;
41
- const definitionExecution = {
42
- id,
43
- type,
44
- broker,
50
+ broker.assertQueue('activity-q', {
51
+ autoDelete: false,
52
+ durable: false
53
+ });
54
+ this[completedSymbol] = false;
55
+ this[stoppedSymbol] = false;
56
+ this[activatedSymbol] = false;
57
+ this[statusSymbol] = 'init';
58
+ this.executionId = undefined;
59
+ this[messageHandlersSymbol] = {
60
+ onApiMessage: this._onApiMessage.bind(this),
61
+ onCallActivity: this._onCallActivity.bind(this),
62
+ onCancelCallActivity: this._onCancelCallActivity.bind(this),
63
+ onChildEvent: this._onChildEvent.bind(this),
64
+ onDelegateMessage: this._onDelegateMessage.bind(this),
65
+ onMessageOutbound: this._onMessageOutbound.bind(this),
66
+ onProcessMessage: this._onProcessMessage.bind(this)
67
+ };
68
+ }
45
69
 
46
- get environment() {
47
- return environment;
48
- },
70
+ const proto = DefinitionExecution.prototype;
71
+ Object.defineProperty(proto, 'stopped', {
72
+ enumerable: true,
49
73
 
50
- get executionId() {
51
- return executionId;
52
- },
74
+ get() {
75
+ return this[stoppedSymbol];
76
+ }
53
77
 
54
- get completed() {
55
- return completed;
56
- },
78
+ });
79
+ Object.defineProperty(proto, 'completed', {
80
+ enumerable: true,
57
81
 
58
- get status() {
59
- return status;
60
- },
82
+ get() {
83
+ return this[completedSymbol];
84
+ }
61
85
 
62
- get stopped() {
63
- return stopped;
64
- },
86
+ });
87
+ Object.defineProperty(proto, 'status', {
88
+ enumerable: true,
65
89
 
66
- get postponedCount() {
67
- return postponed.length;
68
- },
90
+ get() {
91
+ return this[statusSymbol];
92
+ }
69
93
 
70
- get isRunning() {
71
- if (activated) return true;
72
- return false;
73
- },
94
+ });
95
+ Object.defineProperty(proto, 'processes', {
96
+ enumerable: true,
74
97
 
75
- processes,
76
- createMessage,
77
- getApi,
78
- getState,
79
- getPostponed,
80
- execute,
81
- resume,
82
- recover,
83
- stop
84
- };
85
- return definitionExecution;
86
-
87
- function execute(executeMessage) {
88
- if (!executeMessage) throw new Error('Definition execution requires message');
89
- const {
90
- content,
91
- fields
92
- } = executeMessage;
93
- if (!content || !content.executionId) throw new Error('Definition execution requires execution id');
94
- const isRedelivered = fields.redelivered;
95
- executionId = content.executionId;
96
- initMessage = (0, _messageHelper.cloneMessage)(executeMessage, {
97
- executionId,
98
- state: 'start'
99
- });
100
- stopped = false;
101
- activityQ = broker.assertQueue(`execute-${executionId}-q`, {
102
- durable: true,
103
- autoDelete: false
104
- });
98
+ get() {
99
+ return this[processesSymbol].running;
100
+ }
105
101
 
106
- if (isRedelivered) {
107
- return resume();
108
- }
102
+ });
103
+ Object.defineProperty(proto, 'postponedCount', {
104
+ get() {
105
+ return this[processesSymbol].postponed.length;
106
+ }
109
107
 
110
- if (content.processId) {
111
- const startWithProcess = definition.getProcessById(content.processId);
112
- if (startWithProcess) executableProcesses = [startWithProcess];
113
- }
108
+ });
109
+ Object.defineProperty(proto, 'isRunning', {
110
+ get() {
111
+ return this[activatedSymbol];
112
+ }
114
113
 
115
- logger.debug(`<${executionId} (${id})> execute definition`);
116
- activate();
117
- start();
118
- return true;
114
+ });
115
+
116
+ proto.execute = function execute(executeMessage) {
117
+ if (!executeMessage) throw new Error('Definition execution requires message');
118
+ const content = executeMessage.content;
119
+ const executionId = this.executionId = content.executionId;
120
+ if (!executionId) throw new Error('Definition execution requires execution id');
121
+ this[executeMessageSymbol] = (0, _messageHelper.cloneMessage)(executeMessage, {
122
+ executionId,
123
+ state: 'start'
124
+ });
125
+ this[stoppedSymbol] = false;
126
+ this[processesQSymbol] = this.broker.assertQueue(`execute-${executionId}-q`, {
127
+ durable: true,
128
+ autoDelete: false
129
+ });
130
+
131
+ if (executeMessage.fields.redelivered) {
132
+ return this.resume();
119
133
  }
120
134
 
121
- function resume() {
122
- logger.debug(`<${executionId} (${id})> resume`, status, 'definition execution');
123
- if (completed) return complete('completed');
124
- activate();
125
- postponed.splice(0);
126
- activityQ.consume(onProcessMessage, {
127
- prefetch: 1000,
128
- consumerTag: `_definition-activity-${executionId}`
129
- });
130
- if (completed) return complete('completed');
135
+ const {
136
+ running,
137
+ executable
138
+ } = this[processesSymbol];
131
139
 
132
- switch (status) {
133
- case 'init':
134
- return start();
140
+ if (content.processId) {
141
+ const startWithProcess = this.getProcessById(content.processId);
135
142
 
136
- case 'executing':
137
- {
138
- if (!postponed.length) return complete('completed');
139
- break;
140
- }
143
+ if (startWithProcess) {
144
+ executable.splice(0);
145
+ executable.push(startWithProcess);
141
146
  }
142
-
143
- processes.forEach(p => p.resume());
144
147
  }
145
148
 
146
- function start() {
147
- if (!processes.length) {
148
- return publishCompletionMessage('completed');
149
- }
149
+ this._debug('execute definition');
150
150
 
151
- if (!executableProcesses.length) {
152
- return complete('error', {
153
- error: new Error('No executable process')
154
- });
155
- }
151
+ running.push(...executable);
156
152
 
157
- status = 'start';
158
- executableProcesses.forEach(p => p.init());
159
- executableProcesses.forEach(p => p.run());
160
- postponed.splice(0);
161
- activityQ.assertConsumer(onProcessMessage, {
162
- prefetch: 1000,
163
- consumerTag: `_definition-activity-${executionId}`
164
- });
153
+ this._activate(executable);
154
+
155
+ this._start();
156
+
157
+ return true;
158
+ };
159
+
160
+ proto.resume = function resume() {
161
+ this._debug(`resume ${this.status} definition execution`);
162
+
163
+ if (this.completed) return this._complete('completed');
164
+ const {
165
+ running,
166
+ postponed
167
+ } = this[processesSymbol];
168
+
169
+ this._activate(running);
170
+
171
+ postponed.splice(0);
172
+ this[processesQSymbol].consume(this[messageHandlersSymbol].onProcessMessage, {
173
+ prefetch: 1000,
174
+ consumerTag: `_definition-activity-${this.executionId}`
175
+ });
176
+ if (this.completed) return this._complete('completed');
177
+
178
+ switch (this.status) {
179
+ case 'init':
180
+ return this._start();
181
+
182
+ case 'executing':
183
+ {
184
+ if (!this.postponedCount) return this._complete('completed');
185
+ break;
186
+ }
165
187
  }
166
188
 
167
- function recover(state) {
168
- if (!state) return definitionExecution;
169
- executionId = state.executionId;
170
- stopped = state.stopped;
171
- completed = state.completed;
172
- status = state.status;
173
- logger.debug(`<${executionId} (${id})> recover`, status, 'definition execution');
174
- state.processes.forEach(processState => {
175
- const instance = definition.getProcessById(processState.id);
176
- if (!instance) return;
177
- instance.recover(processState);
178
- });
179
- return definitionExecution;
189
+ for (const bp of running) bp.resume();
190
+ };
191
+
192
+ proto.recover = function recover(state) {
193
+ if (!state) return this;
194
+ this.executionId = state.executionId;
195
+ this[stoppedSymbol] = state.stopped;
196
+ this[completedSymbol] = state.completed;
197
+ this[statusSymbol] = state.status;
198
+
199
+ this._debug(`recover ${this.status} definition execution`);
200
+
201
+ const running = this[processesSymbol].running;
202
+ running.splice(0);
203
+ state.processes.map(processState => {
204
+ const instance = this.context.getNewProcessById(processState.id);
205
+ if (!instance) return;
206
+ instance.recover(processState);
207
+ running.push(instance);
208
+ });
209
+ return this;
210
+ };
211
+
212
+ proto.stop = function stop() {
213
+ this.getApi().stop();
214
+ };
215
+
216
+ proto.getProcesses = function getProcesses() {
217
+ const {
218
+ running,
219
+ processes
220
+ } = this[processesSymbol];
221
+ const result = running.slice();
222
+
223
+ for (const bp of processes) {
224
+ if (!result.find(runningBp => bp.id === runningBp.id)) result.push(bp);
180
225
  }
181
226
 
182
- function stop() {
183
- getApi().stop();
227
+ return result;
228
+ };
229
+
230
+ proto.getProcessById = function getProcessById(processId) {
231
+ return this.getProcesses().find(bp => bp.id === processId);
232
+ };
233
+
234
+ proto.getProcessesById = function getProcessesById(processId) {
235
+ return this.getProcesses().filter(bp => bp.id === processId);
236
+ };
237
+
238
+ proto.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
239
+ const running = this[processesSymbol].running;
240
+ return running.find(bp => bp.executionId === processExecutionId);
241
+ };
242
+
243
+ proto.getRunningProcesses = function getRunningProcesses() {
244
+ const running = this[processesSymbol].running;
245
+ return running.filter(bp => bp.executionId);
246
+ };
247
+
248
+ proto.getExecutableProcesses = function getExecutableProcesses() {
249
+ return this[processesSymbol].executable.slice();
250
+ };
251
+
252
+ proto.getState = function getState() {
253
+ return {
254
+ executionId: this.executionId,
255
+ stopped: this.stopped,
256
+ completed: this.completed,
257
+ status: this.status,
258
+ processes: this[processesSymbol].running.map(bp => bp.getState())
259
+ };
260
+ };
261
+
262
+ proto.getApi = function getApi(apiMessage) {
263
+ if (!apiMessage) apiMessage = this[executeMessageSymbol] || {
264
+ content: this._createMessage()
265
+ };
266
+ const content = apiMessage.content;
267
+
268
+ if (content.executionId !== this.executionId) {
269
+ return this._getProcessApi(apiMessage);
184
270
  }
185
271
 
186
- function activate() {
187
- broker.subscribeTmp('api', '#', onApiMessage, {
188
- noAck: true,
189
- consumerTag: '_definition-api-consumer'
190
- });
191
- processes.forEach(p => {
192
- p.broker.subscribeTmp('message', 'message.outbound', onMessageOutbound, {
193
- noAck: true,
194
- consumerTag: '_definition-outbound-message-consumer'
195
- });
196
- p.broker.subscribeTmp('event', 'activity.signal', onDelegateMessage, {
197
- noAck: true,
198
- consumerTag: '_definition-signal-consumer',
199
- priority: 200
200
- });
201
- p.broker.subscribeTmp('event', 'activity.message', onDelegateMessage, {
202
- noAck: true,
203
- consumerTag: '_definition-message-consumer',
204
- priority: 200
205
- });
206
- p.broker.subscribeTmp('event', '#', onEvent, {
207
- noAck: true,
208
- consumerTag: '_definition-activity-consumer',
209
- priority: 100
210
- });
211
- });
212
- activated = true;
213
-
214
- function onEvent(routingKey, originalMessage) {
215
- const message = (0, _messageHelper.cloneMessage)(originalMessage);
216
- const content = message.content;
217
- const parent = content.parent = content.parent || {};
218
- const isDirectChild = processIds.indexOf(content.id) > -1;
219
-
220
- if (isDirectChild) {
221
- parent.executionId = executionId;
222
- } else {
223
- content.parent = (0, _messageHelper.pushParent)(parent, {
224
- id,
225
- type,
226
- executionId
227
- });
228
- }
272
+ const api = (0, _Api.DefinitionApi)(this.broker, apiMessage);
273
+ const postponed = this[processesSymbol].postponed;
274
+ const self = this;
229
275
 
230
- broker.publish('event', routingKey, content, { ...message.properties,
231
- mandatory: false
232
- });
233
- if (!isDirectChild) return;
234
- activityQ.queueMessage(message.fields, (0, _messageHelper.cloneContent)(content), message.properties);
235
- }
276
+ api.getExecuting = function getExecuting() {
277
+ return postponed.reduce((result, msg) => {
278
+ const bpApi = self._getProcessApi(msg);
279
+
280
+ if (bpApi) result.push(bpApi);
281
+ return result;
282
+ }, []);
283
+ };
284
+
285
+ return api;
286
+ };
287
+
288
+ proto.getPostponed = function getPostponed(...args) {
289
+ const running = this[processesSymbol].running;
290
+ return running.reduce((result, p) => {
291
+ result = result.concat(p.getPostponed(...args));
292
+ return result;
293
+ }, []);
294
+ };
295
+
296
+ proto._start = function start() {
297
+ const {
298
+ ids,
299
+ executable,
300
+ postponed
301
+ } = this[processesSymbol];
302
+
303
+ if (!ids.length) {
304
+ return this.publishCompletionMessage('completed');
236
305
  }
237
306
 
238
- function deactivate() {
239
- broker.cancel('_definition-api-consumer');
240
- broker.cancel(`_definition-activity-${executionId}`);
241
- processes.forEach(p => {
242
- p.broker.cancel('_definition-outbound-message-consumer');
243
- p.broker.cancel('_definition-activity-consumer');
244
- p.broker.cancel('_definition-signal-consumer');
245
- p.broker.cancel('_definition-message-consumer');
307
+ if (!executable.length) {
308
+ return this._complete('error', {
309
+ error: new Error('No executable process')
246
310
  });
247
- activated = false;
248
311
  }
249
312
 
250
- function onProcessMessage(routingKey, message) {
251
- const content = message.content;
252
- const isRedelivered = message.fields.redelivered;
253
- const {
254
- id: childId,
255
- type: activityType,
256
- executionId: childExecutionId
257
- } = content;
258
- if (isRedelivered && message.properties.persistent === false) return;
259
-
260
- switch (routingKey) {
261
- case 'execution.stop':
262
- {
263
- if (childExecutionId === executionId) {
264
- message.ack();
265
- return onStopped();
266
- }
267
-
268
- break;
269
- }
313
+ this[statusSymbol] = 'start';
270
314
 
271
- case 'process.leave':
272
- {
273
- return onChildCompleted();
274
- }
275
- }
315
+ for (const bp of executable) bp.init();
276
316
 
277
- stateChangeMessage(true);
317
+ for (const bp of executable) bp.run();
278
318
 
279
- switch (routingKey) {
280
- case 'process.discard':
281
- case 'process.enter':
282
- status = 'executing';
283
- break;
319
+ postponed.splice(0);
320
+ this[processesQSymbol].assertConsumer(this[messageHandlersSymbol].onProcessMessage, {
321
+ prefetch: 1000,
322
+ consumerTag: `_definition-activity-${this.executionId}`
323
+ });
324
+ };
284
325
 
285
- case 'process.error':
286
- {
287
- processes.slice().forEach(p => {
288
- if (p.id !== childId) p.stop();
289
- });
290
- complete('error', {
291
- error: content.error
292
- });
293
- break;
294
- }
295
- }
326
+ proto._activate = function activate(processList) {
327
+ this.broker.subscribeTmp('api', '#', this[messageHandlersSymbol].onApiMessage, {
328
+ noAck: true,
329
+ consumerTag: '_definition-api-consumer'
330
+ });
296
331
 
297
- function stateChangeMessage(postponeMessage = true) {
298
- const previousMsg = popPostponed(childId);
299
- if (previousMsg) previousMsg.ack();
300
- if (postponeMessage) postponed.push(message);
301
- }
332
+ for (const bp of processList) this._activateProcess(bp);
302
333
 
303
- function popPostponed(postponedId) {
304
- const idx = postponed.findIndex(msg => msg.content.id === postponedId);
334
+ this[activatedSymbol] = true;
335
+ };
305
336
 
306
- if (idx > -1) {
307
- return postponed.splice(idx, 1)[0];
308
- }
309
- }
337
+ proto._activateProcess = function activateProcess(bp) {
338
+ const handlers = this[messageHandlersSymbol];
339
+ bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
340
+ noAck: true,
341
+ consumerTag: '_definition-outbound-message-consumer'
342
+ });
343
+ bp.broker.subscribeTmp('event', 'activity.signal', handlers.onDelegateMessage, {
344
+ noAck: true,
345
+ consumerTag: '_definition-signal-consumer',
346
+ priority: 200
347
+ });
348
+ bp.broker.subscribeTmp('event', 'activity.message', handlers.onDelegateMessage, {
349
+ noAck: true,
350
+ consumerTag: '_definition-message-consumer',
351
+ priority: 200
352
+ });
353
+ bp.broker.subscribeTmp('event', 'activity.call', handlers.onCallActivity, {
354
+ noAck: true,
355
+ consumerTag: '_definition-call-consumer',
356
+ priority: 200
357
+ });
358
+ bp.broker.subscribeTmp('event', 'activity.call.cancel', handlers.onCancelCallActivity, {
359
+ noAck: true,
360
+ consumerTag: '_definition-call-cancel-consumer',
361
+ priority: 200
362
+ });
363
+ bp.broker.subscribeTmp('event', '#', handlers.onChildEvent, {
364
+ noAck: true,
365
+ consumerTag: '_definition-activity-consumer',
366
+ priority: 100
367
+ });
368
+ };
369
+
370
+ proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
371
+ const message = (0, _messageHelper.cloneMessage)(originalMessage);
372
+ const content = message.content;
373
+ const parent = content.parent = content.parent || {};
374
+ const isDirectChild = this[processesSymbol].ids.indexOf(content.id) > -1;
375
+
376
+ if (isDirectChild) {
377
+ parent.executionId = this.executionId;
378
+ } else {
379
+ content.parent = (0, _messageHelper.pushParent)(parent, this);
380
+ }
310
381
 
311
- function onChildCompleted() {
312
- stateChangeMessage(false);
313
- if (isRedelivered) return message.ack();
314
- logger.debug(`<${executionId} (${id})> left <${childId}> (${activityType}), pending runs ${postponed.length}`);
382
+ this.broker.publish('event', routingKey, content, { ...message.properties,
383
+ mandatory: false
384
+ });
385
+ if (!isDirectChild) return;
386
+ this[processesQSymbol].queueMessage(message.fields, (0, _messageHelper.cloneContent)(content), message.properties);
387
+ };
388
+
389
+ proto._deactivate = function deactivate() {
390
+ this.broker.cancel('_definition-api-consumer');
391
+ this.broker.cancel(`_definition-activity-${this.executionId}`);
392
+
393
+ for (const bp of this[processesSymbol].running) this._deactivateProcess(bp);
394
+
395
+ this[activatedSymbol] = false;
396
+ };
397
+
398
+ proto._deactivateProcess = function deactivateProcess(bp) {
399
+ bp.broker.cancel('_definition-outbound-message-consumer');
400
+ bp.broker.cancel('_definition-activity-consumer');
401
+ bp.broker.cancel('_definition-signal-consumer');
402
+ bp.broker.cancel('_definition-message-consumer');
403
+ bp.broker.cancel('_definition-call-consumer');
404
+ bp.broker.cancel('_definition-call-cancel-consumer');
405
+ };
406
+
407
+ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
408
+ const content = message.content;
409
+ const isRedelivered = message.fields.redelivered;
410
+ const {
411
+ id: childId,
412
+ executionId: childExecutionId,
413
+ inbound
414
+ } = content;
415
+ if (isRedelivered && message.properties.persistent === false) return;
416
+
417
+ switch (routingKey) {
418
+ case 'execution.stop':
419
+ {
420
+ if (childExecutionId === this.executionId) {
421
+ message.ack();
422
+ return this._onStopped(message);
423
+ }
315
424
 
316
- if (!postponed.length) {
317
- message.ack();
318
- complete('completed');
425
+ break;
319
426
  }
320
- }
321
427
 
322
- function onStopped() {
323
- logger.debug(`<${executionId} (${id})> stop definition execution (stop process executions ${postponed.length})`);
324
- activityQ.close();
325
- deactivate();
326
- processes.slice().forEach(p => {
327
- p.stop();
328
- });
329
- stopped = true;
330
- return broker.publish('execution', `execution.stopped.${executionId}`, { ...initMessage.content,
331
- ...content
332
- }, {
333
- type: 'stopped',
334
- persistent: false
335
- });
336
- }
428
+ case 'process.leave':
429
+ {
430
+ return this._onProcessCompleted(message);
431
+ }
337
432
  }
338
433
 
339
- function onApiMessage(routingKey, message) {
340
- const messageType = message.properties.type;
341
- const delegate = message.properties.delegate;
434
+ this._stateChangeMessage(message, true);
342
435
 
343
- if (delegate && id === message.content.id) {
344
- const referenceId = (0, _getPropertyValue.default)(message, 'content.message.id');
436
+ switch (routingKey) {
437
+ case 'process.discard':
438
+ case 'process.enter':
439
+ this[statusSymbol] = 'executing';
440
+ break;
345
441
 
346
- for (const bp of processes) {
347
- if (bp.isRunning) continue;
442
+ case 'process.discarded':
443
+ {
444
+ if (inbound && inbound.length) {
445
+ const calledFrom = inbound[0];
348
446
 
349
- if (bp.getStartActivities({
350
- referenceId,
351
- referenceType: messageType
352
- }).length) {
353
- logger.debug(`<${executionId} (${id})> start <${bp.id}>`);
354
- bp.run();
447
+ this._getProcessApi({
448
+ content: calledFrom
449
+ }).cancel({
450
+ executionId: calledFrom.executionId
451
+ });
355
452
  }
453
+
454
+ break;
356
455
  }
357
- }
358
456
 
359
- if (delegate) {
360
- for (const bp of processes) {
361
- bp.broker.publish('api', routingKey, (0, _messageHelper.cloneContent)(message.content), message.properties);
457
+ case 'process.end':
458
+ {
459
+ if (inbound && inbound.length) {
460
+ const calledFrom = inbound[0];
461
+
462
+ this._getProcessApi({
463
+ content: calledFrom
464
+ }).signal({
465
+ executionId: calledFrom.executionId,
466
+ output: { ...content.output
467
+ }
468
+ });
469
+ } else {
470
+ Object.assign(this.environment.output, content.output);
471
+ }
472
+
473
+ break;
362
474
  }
363
- }
364
475
 
365
- if (executionId !== message.content.executionId) return;
476
+ case 'process.error':
477
+ {
478
+ if (inbound && inbound.length) {
479
+ const calledFrom = inbound[0];
480
+
481
+ this._getProcessApi({
482
+ content: calledFrom
483
+ }).sendApiMessage('error', {
484
+ executionId: calledFrom.executionId,
485
+ error: content.error
486
+ }, {
487
+ mandatory: true,
488
+ type: 'error'
489
+ });
490
+ } else {
491
+ for (const bp of this[processesSymbol].running.slice()) {
492
+ if (bp.id !== childId) bp.stop();
493
+ }
494
+
495
+ this._complete('error', {
496
+ error: content.error
497
+ });
498
+ }
366
499
 
367
- switch (messageType) {
368
- case 'stop':
369
- activityQ.queueMessage({
370
- routingKey: 'execution.stop'
371
- }, (0, _messageHelper.cloneContent)(message.content), {
372
- persistent: false
373
- });
374
500
  break;
375
- }
501
+ }
376
502
  }
503
+ };
377
504
 
378
- function getState() {
379
- return {
380
- executionId,
381
- stopped,
382
- completed,
383
- status,
384
- processes: processes.map(p => p.getState())
385
- };
386
- }
505
+ proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
506
+ let previousMsg;
507
+ const postponed = this[processesSymbol].postponed;
508
+ const idx = postponed.findIndex(msg => msg.content.executionId === message.content.executionId);
387
509
 
388
- function getPostponed(...args) {
389
- return processes.reduce((result, p) => {
390
- result = result.concat(p.getPostponed(...args));
391
- return result;
392
- }, []);
510
+ if (idx > -1) {
511
+ previousMsg = postponed.splice(idx, 1)[0];
393
512
  }
394
513
 
395
- function complete(completionType, content, options) {
396
- deactivate();
397
- logger.debug(`<${executionId} (${id})> definition execution ${completionType} in ${Date.now() - initMessage.properties.timestamp}ms`);
398
- if (!content) content = createMessage();
399
- completed = true;
400
- if (status !== 'terminated') status = completionType;
401
- broker.deleteQueue(activityQ.name);
402
- return broker.publish('execution', `execution.${completionType}.${executionId}`, { ...initMessage.content,
403
- output: environment.output,
404
- ...content,
405
- state: completionType
406
- }, {
407
- type: completionType,
408
- mandatory: completionType === 'error',
409
- ...options
410
- });
514
+ if (previousMsg) previousMsg.ack();
515
+ if (postponeMessage) postponed.push(message);
516
+ };
517
+
518
+ proto._onProcessCompleted = function onProcessCompleted(message) {
519
+ this._stateChangeMessage(message, false);
520
+
521
+ if (message.fields.redelivered) return message.ack();
522
+ const {
523
+ id,
524
+ executionId,
525
+ type,
526
+ inbound
527
+ } = message.content;
528
+
529
+ this._debug(`left <${executionId} (${id})> (${type}), pending runs ${this.postponedCount}`);
530
+
531
+ if (inbound && inbound.length) {
532
+ const bp = this._removeProcessByExecutionId(executionId);
533
+
534
+ this._deactivateProcess(bp);
411
535
  }
412
536
 
413
- function onMessageOutbound(routingKey, message) {
414
- const content = message.content;
415
- const {
416
- target,
417
- source
418
- } = content;
419
- logger.debug(`<${executionId} (${id})> conveying message from <${source.processId}.${source.id}> to`, target.id ? `<${target.processId}.${target.id}>` : `<${target.processId}>`);
420
- const targetProcess = getProcessById(target.processId);
421
- targetProcess.sendMessage(message);
537
+ if (!this.postponedCount) {
538
+ message.ack();
539
+
540
+ this._complete('completed');
422
541
  }
542
+ };
423
543
 
424
- function onDelegateMessage(routingKey, executeMessage) {
425
- const content = executeMessage.content;
426
- const messageType = executeMessage.properties.type;
427
- const delegateMessage = executeMessage.content.message;
428
- const reference = definition.getElementById(delegateMessage.id);
429
- const message = reference && reference.resolve(executeMessage);
430
- logger.debug(`<${executionId} (${id})>`, reference ? `${messageType} <${delegateMessage.id}>` : `anonymous ${messageType}`, `event received from <${content.parent.id}.${content.id}>. Delegating.`);
431
- getApi().sendApiMessage(messageType, {
432
- message: message,
433
- originalMessage: content.message
434
- }, {
435
- delegate: true,
436
- type: messageType
437
- });
438
- broker.publish('event', `definition.${messageType}`, createMessage({
439
- message: message && (0, _messageHelper.cloneContent)(message)
440
- }), {
441
- type: messageType
544
+ proto._onStopped = function onStopped(message) {
545
+ const running = this[processesSymbol].running;
546
+
547
+ this._debug(`stop definition execution (stop process executions ${running.length})`);
548
+
549
+ this[processesQSymbol].close();
550
+
551
+ this._deactivate();
552
+
553
+ for (const bp of running.slice()) bp.stop();
554
+
555
+ this[stoppedSymbol] = true;
556
+ return this.broker.publish('execution', `execution.stopped.${this.executionId}`, (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, { ...message.content
557
+ }), {
558
+ type: 'stopped',
559
+ persistent: false
560
+ });
561
+ };
562
+
563
+ proto._onApiMessage = function onApiMessage(routingKey, message) {
564
+ const messageType = message.properties.type;
565
+ const delegate = message.properties.delegate;
566
+
567
+ if (delegate && this.id === message.content.id) {
568
+ const referenceId = (0, _getPropertyValue.default)(message, 'content.message.id');
569
+
570
+ this._startProcessesByMessage({
571
+ referenceId,
572
+ referenceType: messageType
442
573
  });
443
574
  }
444
575
 
445
- function getProcessById(processId) {
446
- return processes.find(p => p.id === processId);
576
+ if (delegate) {
577
+ for (const bp of this[processesSymbol].running.slice()) {
578
+ bp.broker.publish('api', routingKey, (0, _messageHelper.cloneContent)(message.content), message.properties);
579
+ }
447
580
  }
448
581
 
449
- function publishCompletionMessage(completionType, content) {
450
- deactivate();
451
- logger.debug(`<${executionId} (${id})> ${completionType}`);
452
- if (!content) content = createMessage();
453
- return broker.publish('execution', `execution.${completionType}.${executionId}`, content, {
454
- type: completionType
582
+ if (this.executionId !== message.content.executionId) return;
583
+
584
+ if (messageType === 'stop') {
585
+ this[processesQSymbol].queueMessage({
586
+ routingKey: 'execution.stop'
587
+ }, (0, _messageHelper.cloneContent)(message.content), {
588
+ persistent: false
455
589
  });
456
590
  }
591
+ };
457
592
 
458
- function createMessage(content = {}) {
459
- return {
460
- id,
461
- type,
462
- executionId,
463
- status,
464
- ...content
465
- };
466
- }
593
+ proto._startProcessesByMessage = function startProcessesByMessage(reference) {
594
+ const {
595
+ processes: bps,
596
+ running
597
+ } = this[processesSymbol];
598
+ if (bps.length < 2) return;
599
+
600
+ for (const bp of bps) {
601
+ if (bp.isExecutable) continue;
602
+ if (!bp.getStartActivities(reference).length) continue;
467
603
 
468
- function getApi(apiMessage) {
469
- if (!apiMessage) apiMessage = initMessage || {
470
- content: createMessage()
471
- };
472
- const content = apiMessage.content;
604
+ if (!bp.executionId) {
605
+ this._debug(`start <${bp.id}> by <${reference.referenceId}> (${reference.referenceType})`);
473
606
 
474
- if (content.executionId !== executionId) {
475
- return getProcessApi(apiMessage);
607
+ this._activateProcess(bp);
608
+
609
+ running.push(bp);
610
+ bp.init();
611
+ bp.run();
612
+ if (reference.referenceType === 'message') return;
613
+ continue;
476
614
  }
477
615
 
478
- const api = (0, _Api.DefinitionApi)(broker, apiMessage);
616
+ this._debug(`start new <${bp.id}> by <${reference.referenceId}> (${reference.referenceType})`);
617
+
618
+ const targetProcess = this.context.getNewProcessById(bp.id);
479
619
 
480
- api.getExecuting = function getExecuting() {
481
- return postponed.reduce((result, msg) => {
482
- if (msg.content.executionId === content.executionId) return result;
483
- result.push(getApi(msg));
484
- return result;
485
- }, []);
486
- };
620
+ this._activateProcess(targetProcess);
487
621
 
488
- return api;
622
+ running.push(targetProcess);
623
+ targetProcess.init();
624
+ targetProcess.run();
625
+ if (reference.referenceType === 'message') return;
489
626
  }
627
+ };
490
628
 
491
- function getProcessApi(message) {
492
- const content = message.content;
493
- let api = getApiByProcessId(content.id);
494
- if (api) return api;
495
- if (!content.parent) return;
496
- api = getApiByProcessId(content.parent.id);
497
- if (api) return api;
498
- if (!content.parent.path) return;
629
+ proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
630
+ const content = message.content;
631
+ const {
632
+ target,
633
+ source
634
+ } = content;
635
+
636
+ this._debug(`conveying message from <${source.processId}.${source.id}> to`, target.id ? `<${target.processId}.${target.id}>` : `<${target.processId}>`);
499
637
 
500
- for (let i = 0; i < content.parent.path.length; i++) {
501
- api = getApiByProcessId(content.parent.path[i].id);
502
- if (api) return api;
638
+ const targetProcesses = this.getProcessesById(target.processId);
639
+ if (!targetProcesses.length) return;
640
+ let targetProcess, found;
641
+
642
+ for (const bp of targetProcesses) {
643
+ if (!bp.executionId) {
644
+ targetProcess = bp;
645
+ continue;
503
646
  }
504
647
 
505
- function getApiByProcessId(parentId) {
506
- const processInstance = getProcessById(parentId);
507
- if (!processInstance) return;
508
- return processInstance.getApi(message);
648
+ bp.sendMessage(message);
649
+ found = true;
650
+ }
651
+
652
+ if (found) return;
653
+ targetProcess = targetProcess || this.context.getNewProcessById(target.processId);
654
+
655
+ this._activateProcess(targetProcess);
656
+
657
+ this[processesSymbol].running.push(targetProcess);
658
+ targetProcess.init();
659
+ targetProcess.run();
660
+ targetProcess.sendMessage(message);
661
+ };
662
+
663
+ proto._onCallActivity = function onCallActivity(routingKey, message) {
664
+ const content = message.content;
665
+ const {
666
+ calledElement,
667
+ id: fromId,
668
+ executionId: fromExecutionId,
669
+ name: fromName,
670
+ parent: fromParent
671
+ } = content;
672
+ if (!calledElement) return;
673
+ const bpExecutionId = `${(0, _shared.brokerSafeId)(calledElement)}_${fromExecutionId}`;
674
+
675
+ if (content.isRecovered) {
676
+ if (this.getProcessByExecutionId(bpExecutionId)) return;
677
+ }
678
+
679
+ const targetProcess = this.context.getNewProcessById(calledElement, {
680
+ settings: {
681
+ calledFrom: (0, _messageHelper.cloneContent)({
682
+ id: fromId,
683
+ name: fromName,
684
+ executionId: content.executionId,
685
+ parent: content.parent
686
+ })
509
687
  }
688
+ });
689
+ if (!targetProcess) return;
690
+
691
+ this._debug(`call from <${fromParent.id}.${fromId}> to <${calledElement}>`);
692
+
693
+ this._activateProcess(targetProcess);
694
+
695
+ this[processesSymbol].running.push(targetProcess);
696
+ targetProcess.init(bpExecutionId);
697
+ targetProcess.run({
698
+ inbound: [(0, _messageHelper.cloneContent)(content)]
699
+ });
700
+ };
701
+
702
+ proto._onCancelCallActivity = function onCancelCallActivity(routingKey, message) {
703
+ const {
704
+ calledElement,
705
+ id: fromId,
706
+ executionId: fromExecutionId,
707
+ parent: fromParent
708
+ } = message.content;
709
+ if (!calledElement) return;
710
+ const bpExecutionId = `${(0, _shared.brokerSafeId)(calledElement)}_${fromExecutionId}`;
711
+ const targetProcess = this.getProcessByExecutionId(bpExecutionId);
712
+ if (!targetProcess) return;
713
+
714
+ this._debug(`cancel call from <${fromParent.id}.${fromId}> to <${calledElement}>`);
715
+
716
+ targetProcess.getApi().discard();
717
+ };
718
+
719
+ proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage) {
720
+ const content = executeMessage.content;
721
+ const messageType = executeMessage.properties.type;
722
+ const delegateMessage = executeMessage.content.message;
723
+ const reference = this.context.getActivityById(delegateMessage.id);
724
+ const message = reference && reference.resolve(executeMessage);
725
+
726
+ this._debug(`<${reference ? `${messageType} ${delegateMessage.id}>` : `anonymous ${messageType}`} event received from <${content.parent.id}.${content.id}>. Delegating.`);
727
+
728
+ this.getApi().sendApiMessage(messageType, {
729
+ source: {
730
+ id: content.id,
731
+ executionId: content.executionId,
732
+ type: content.type,
733
+ parent: (0, _messageHelper.cloneParent)(content.parent)
734
+ },
735
+ message,
736
+ originalMessage: content.message
737
+ }, {
738
+ delegate: true,
739
+ type: messageType
740
+ });
741
+ this.broker.publish('event', `definition.${messageType}`, this._createMessage({
742
+ message: message && (0, _messageHelper.cloneContent)(message)
743
+ }), {
744
+ type: messageType
745
+ });
746
+ };
747
+
748
+ proto._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
749
+ const running = this[processesSymbol].running;
750
+ const idx = running.findIndex(p => p.executionId === processExecutionId);
751
+ if (idx === -1) return;
752
+ return running.splice(idx, 1)[0];
753
+ };
754
+
755
+ proto._complete = function complete(completionType, content, options) {
756
+ this._deactivate();
757
+
758
+ const stateMessage = this[executeMessageSymbol];
759
+
760
+ this._debug(`definition execution ${completionType} in ${Date.now() - stateMessage.properties.timestamp}ms`);
761
+
762
+ if (!content) content = this._createMessage();
763
+ this[completedSymbol] = true;
764
+ if (this.status !== 'terminated') this[statusSymbol] = completionType;
765
+ this.broker.deleteQueue(this[processesQSymbol].name);
766
+ return this.broker.publish('execution', `execution.${completionType}.${this.executionId}`, { ...stateMessage.content,
767
+ output: { ...this.environment.output
768
+ },
769
+ ...content,
770
+ state: completionType
771
+ }, {
772
+ type: completionType,
773
+ mandatory: completionType === 'error',
774
+ ...options
775
+ });
776
+ };
777
+
778
+ proto.publishCompletionMessage = function publishCompletionMessage(completionType, content) {
779
+ this._deactivate();
780
+
781
+ this._debug(completionType);
782
+
783
+ if (!content) content = this._createMessage();
784
+ return this.broker.publish('execution', `execution.${completionType}.${this.executionId}`, content, {
785
+ type: completionType
786
+ });
787
+ };
788
+
789
+ proto._createMessage = function createMessage(content = {}) {
790
+ return {
791
+ id: this.id,
792
+ type: this.type,
793
+ executionId: this.executionId,
794
+ status: this.status,
795
+ ...content
796
+ };
797
+ };
798
+
799
+ proto._getProcessApi = function getProcessApi(message) {
800
+ const content = message.content;
801
+
802
+ let api = this._getProcessApiByExecutionId(content.executionId, message);
803
+
804
+ if (api) return api;
805
+ if (!content.parent) return;
806
+ api = this._getProcessApiByExecutionId(content.parent.executionId, message);
807
+ if (api) return api;
808
+ if (!content.parent.path) return;
809
+
810
+ for (const pp of content.parent.path) {
811
+ api = this._getProcessApiByExecutionId(pp.executionId, message);
812
+ if (api) return api;
510
813
  }
511
- }
814
+ };
815
+
816
+ proto._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentExecutionId, message) {
817
+ const processInstance = this.getProcessByExecutionId(parentExecutionId);
818
+ if (!processInstance) return;
819
+ return processInstance.getApi(message);
820
+ };
821
+
822
+ proto._debug = function debug(logMessage) {
823
+ this[parentSymbol].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
824
+ };