bpmn-elements 7.0.0 → 8.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 (68) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/src/Context.js +50 -40
  3. package/dist/src/Environment.js +39 -19
  4. package/dist/src/MessageFormatter.js +11 -11
  5. package/dist/src/activity/Activity.js +91 -91
  6. package/dist/src/activity/ActivityExecution.js +35 -35
  7. package/dist/src/definition/Definition.js +50 -50
  8. package/dist/src/definition/DefinitionExecution.js +114 -125
  9. package/dist/src/eventDefinitions/CancelEventDefinition.js +16 -16
  10. package/dist/src/eventDefinitions/CompensateEventDefinition.js +24 -24
  11. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  12. package/dist/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  13. package/dist/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  14. package/dist/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  15. package/dist/src/eventDefinitions/LinkEventDefinition.js +15 -15
  16. package/dist/src/eventDefinitions/MessageEventDefinition.js +23 -23
  17. package/dist/src/eventDefinitions/SignalEventDefinition.js +24 -24
  18. package/dist/src/eventDefinitions/TimerEventDefinition.js +21 -21
  19. package/dist/src/events/BoundaryEvent.js +20 -20
  20. package/dist/src/events/EndEvent.js +3 -3
  21. package/dist/src/events/IntermediateCatchEvent.js +3 -3
  22. package/dist/src/events/IntermediateThrowEvent.js +3 -3
  23. package/dist/src/events/StartEvent.js +9 -9
  24. package/dist/src/flows/Association.js +7 -7
  25. package/dist/src/flows/MessageFlow.js +9 -9
  26. package/dist/src/flows/SequenceFlow.js +7 -7
  27. package/dist/src/gateways/EventBasedGateway.js +11 -11
  28. package/dist/src/io/InputOutputSpecification.js +4 -4
  29. package/dist/src/io/Properties.js +9 -9
  30. package/dist/src/process/Process.js +64 -61
  31. package/dist/src/process/ProcessExecution.js +93 -90
  32. package/dist/src/tasks/ReceiveTask.js +16 -16
  33. package/dist/src/tasks/SubProcess.js +16 -18
  34. package/package.json +9 -9
  35. package/src/Context.js +48 -40
  36. package/src/Environment.js +48 -20
  37. package/src/EventBroker.js +1 -1
  38. package/src/MessageFormatter.js +11 -11
  39. package/src/activity/Activity.js +91 -91
  40. package/src/activity/ActivityExecution.js +34 -34
  41. package/src/definition/Definition.js +51 -50
  42. package/src/definition/DefinitionExecution.js +111 -113
  43. package/src/eventDefinitions/CancelEventDefinition.js +16 -16
  44. package/src/eventDefinitions/CompensateEventDefinition.js +25 -24
  45. package/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  46. package/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  47. package/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  48. package/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  49. package/src/eventDefinitions/LinkEventDefinition.js +15 -15
  50. package/src/eventDefinitions/MessageEventDefinition.js +23 -23
  51. package/src/eventDefinitions/SignalEventDefinition.js +24 -24
  52. package/src/eventDefinitions/TimerEventDefinition.js +21 -21
  53. package/src/events/BoundaryEvent.js +20 -20
  54. package/src/events/EndEvent.js +3 -3
  55. package/src/events/IntermediateCatchEvent.js +3 -3
  56. package/src/events/IntermediateThrowEvent.js +3 -3
  57. package/src/events/StartEvent.js +9 -9
  58. package/src/flows/Association.js +7 -7
  59. package/src/flows/MessageFlow.js +9 -9
  60. package/src/flows/SequenceFlow.js +7 -7
  61. package/src/gateways/EventBasedGateway.js +11 -11
  62. package/src/io/BpmnIO.js +5 -1
  63. package/src/io/InputOutputSpecification.js +4 -4
  64. package/src/io/Properties.js +9 -9
  65. package/src/process/Process.js +62 -58
  66. package/src/process/ProcessExecution.js +86 -88
  67. package/src/tasks/ReceiveTask.js +16 -16
  68. package/src/tasks/SubProcess.js +16 -16
@@ -15,48 +15,53 @@ var _messageHelper = require("../messageHelper");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
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');
18
+ const kActivated = Symbol.for('activated');
19
+ const kProcessesQ = Symbol.for('processesQ');
20
+ const kCompleted = Symbol.for('completed');
21
+ const kExecuteMessage = Symbol.for('executeMessage');
22
+ const kMessageHandlers = Symbol.for('messageHandlers');
23
+ const kParent = Symbol.for('definition');
24
+ const kProcesses = Symbol.for('processes');
25
+ const kStatus = Symbol.for('status');
26
+ const kStopped = Symbol.for('stopped');
27
27
 
28
28
  function DefinitionExecution(definition, context) {
29
29
  const broker = definition.broker;
30
- this[parentSymbol] = definition;
30
+ this[kParent] = definition;
31
31
  this.id = definition.id;
32
32
  this.type = definition.type;
33
33
  this.broker = broker;
34
- this.environment = definition.environment;
34
+ const environment = this.environment = definition.environment;
35
35
  this.context = context;
36
- const processes = this[processesSymbol] = context.getProcesses();
37
- this[processesSymbol] = {
36
+ const processes = context.getProcesses();
37
+ const ids = [];
38
+ const executable = [];
39
+
40
+ for (const bp of processes) {
41
+ bp.environment.assignVariables(environment.variables);
42
+ bp.environment.assignSettings(environment.settings);
43
+ ids.push(bp.id);
44
+ if (bp.isExecutable) executable.push(bp);
45
+ }
46
+
47
+ this[kProcesses] = {
38
48
  processes,
39
49
  running: [],
40
- ids: processes.map(({
41
- id: childId
42
- }) => childId),
43
- executable: context.getExecutableProcesses(),
50
+ ids,
51
+ executable,
44
52
  postponed: []
45
53
  };
46
54
  broker.assertExchange('execution', 'topic', {
47
55
  autoDelete: false,
48
56
  durable: true
49
57
  });
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
58
  this.executionId = undefined;
59
- this[messageHandlersSymbol] = {
59
+ this[kCompleted] = false;
60
+ this[kStopped] = false;
61
+ this[kActivated] = false;
62
+ this[kStatus] = 'init';
63
+ this[kProcessesQ] = undefined;
64
+ this[kMessageHandlers] = {
60
65
  onApiMessage: this._onApiMessage.bind(this),
61
66
  onCallActivity: this._onCallActivity.bind(this),
62
67
  onCancelCallActivity: this._onCancelCallActivity.bind(this),
@@ -72,7 +77,7 @@ Object.defineProperty(proto, 'stopped', {
72
77
  enumerable: true,
73
78
 
74
79
  get() {
75
- return this[stoppedSymbol];
80
+ return this[kStopped];
76
81
  }
77
82
 
78
83
  });
@@ -80,7 +85,7 @@ Object.defineProperty(proto, 'completed', {
80
85
  enumerable: true,
81
86
 
82
87
  get() {
83
- return this[completedSymbol];
88
+ return this[kCompleted];
84
89
  }
85
90
 
86
91
  });
@@ -88,7 +93,7 @@ Object.defineProperty(proto, 'status', {
88
93
  enumerable: true,
89
94
 
90
95
  get() {
91
- return this[statusSymbol];
96
+ return this[kStatus];
92
97
  }
93
98
 
94
99
  });
@@ -96,19 +101,19 @@ Object.defineProperty(proto, 'processes', {
96
101
  enumerable: true,
97
102
 
98
103
  get() {
99
- return this[processesSymbol].running;
104
+ return this[kProcesses].running;
100
105
  }
101
106
 
102
107
  });
103
108
  Object.defineProperty(proto, 'postponedCount', {
104
109
  get() {
105
- return this[processesSymbol].postponed.length;
110
+ return this[kProcesses].postponed.length;
106
111
  }
107
112
 
108
113
  });
109
114
  Object.defineProperty(proto, 'isRunning', {
110
115
  get() {
111
- return this[activatedSymbol];
116
+ return this[kActivated];
112
117
  }
113
118
 
114
119
  });
@@ -118,12 +123,12 @@ proto.execute = function execute(executeMessage) {
118
123
  const content = executeMessage.content;
119
124
  const executionId = this.executionId = content.executionId;
120
125
  if (!executionId) throw new Error('Definition execution requires execution id');
121
- this[executeMessageSymbol] = (0, _messageHelper.cloneMessage)(executeMessage, {
126
+ this[kExecuteMessage] = (0, _messageHelper.cloneMessage)(executeMessage, {
122
127
  executionId,
123
128
  state: 'start'
124
129
  });
125
- this[stoppedSymbol] = false;
126
- this[processesQSymbol] = this.broker.assertQueue(`execute-${executionId}-q`, {
130
+ this[kStopped] = false;
131
+ this[kProcessesQ] = this.broker.assertQueue(`execute-${executionId}-q`, {
127
132
  durable: true,
128
133
  autoDelete: false
129
134
  });
@@ -135,7 +140,7 @@ proto.execute = function execute(executeMessage) {
135
140
  const {
136
141
  running,
137
142
  executable
138
- } = this[processesSymbol];
143
+ } = this[kProcesses];
139
144
 
140
145
  if (content.processId) {
141
146
  const startWithProcess = this.getProcessById(content.processId);
@@ -158,33 +163,22 @@ proto.execute = function execute(executeMessage) {
158
163
  };
159
164
 
160
165
  proto.resume = function resume() {
161
- this._debug(`resume ${this.status} definition execution`);
166
+ this._debug(`resume ${this[kStatus]} definition execution`);
162
167
 
163
- if (this.completed) return this._complete('completed');
168
+ if (this[kCompleted]) return this._complete('completed');
164
169
  const {
165
170
  running,
166
171
  postponed
167
- } = this[processesSymbol];
172
+ } = this[kProcesses];
168
173
 
169
174
  this._activate(running);
170
175
 
171
176
  postponed.splice(0);
172
- this[processesQSymbol].consume(this[messageHandlersSymbol].onProcessMessage, {
177
+ this[kProcessesQ].consume(this[kMessageHandlers].onProcessMessage, {
173
178
  prefetch: 1000,
174
179
  consumerTag: `_definition-activity-${this.executionId}`
175
180
  });
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
- }
187
- }
181
+ if (this[kCompleted]) return;
188
182
 
189
183
  for (const bp of running) bp.resume();
190
184
  };
@@ -192,20 +186,32 @@ proto.resume = function resume() {
192
186
  proto.recover = function recover(state) {
193
187
  if (!state) return this;
194
188
  this.executionId = state.executionId;
195
- this[stoppedSymbol] = state.stopped;
196
- this[completedSymbol] = state.completed;
197
- this[statusSymbol] = state.status;
189
+ this[kStopped] = state.stopped;
190
+ this[kCompleted] = state.completed;
191
+ this[kStatus] = state.status;
198
192
 
199
- this._debug(`recover ${this.status} definition execution`);
193
+ this._debug(`recover ${this[kStatus]} definition execution`);
200
194
 
201
- const running = this[processesSymbol].running;
195
+ const running = this[kProcesses].running;
202
196
  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
- });
197
+ const ids = [];
198
+
199
+ for (const bpState of state.processes) {
200
+ const bpid = bpState.id;
201
+ let bp;
202
+
203
+ if (ids.indexOf(bpid) > -1) {
204
+ bp = this.context.getNewProcessById(bpid);
205
+ } else {
206
+ bp = this.getProcessById(bpid);
207
+ }
208
+
209
+ if (!bp) return;
210
+ ids.push(bpid);
211
+ bp.recover(bpState);
212
+ running.push(bp);
213
+ }
214
+
209
215
  return this;
210
216
  };
211
217
 
@@ -217,7 +223,7 @@ proto.getProcesses = function getProcesses() {
217
223
  const {
218
224
  running,
219
225
  processes
220
- } = this[processesSymbol];
226
+ } = this[kProcesses];
221
227
  const result = running.slice();
222
228
 
223
229
  for (const bp of processes) {
@@ -236,31 +242,31 @@ proto.getProcessesById = function getProcessesById(processId) {
236
242
  };
237
243
 
238
244
  proto.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
239
- const running = this[processesSymbol].running;
245
+ const running = this[kProcesses].running;
240
246
  return running.find(bp => bp.executionId === processExecutionId);
241
247
  };
242
248
 
243
249
  proto.getRunningProcesses = function getRunningProcesses() {
244
- const running = this[processesSymbol].running;
250
+ const running = this[kProcesses].running;
245
251
  return running.filter(bp => bp.executionId);
246
252
  };
247
253
 
248
254
  proto.getExecutableProcesses = function getExecutableProcesses() {
249
- return this[processesSymbol].executable.slice();
255
+ return this[kProcesses].executable.slice();
250
256
  };
251
257
 
252
258
  proto.getState = function getState() {
253
259
  return {
254
260
  executionId: this.executionId,
255
- stopped: this.stopped,
256
- completed: this.completed,
257
- status: this.status,
258
- processes: this[processesSymbol].running.map(bp => bp.getState())
261
+ stopped: this[kStopped],
262
+ completed: this[kCompleted],
263
+ status: this[kStatus],
264
+ processes: this[kProcesses].running.map(bp => bp.getState())
259
265
  };
260
266
  };
261
267
 
262
268
  proto.getApi = function getApi(apiMessage) {
263
- if (!apiMessage) apiMessage = this[executeMessageSymbol] || {
269
+ if (!apiMessage) apiMessage = this[kExecuteMessage] || {
264
270
  content: this._createMessage()
265
271
  };
266
272
  const content = apiMessage.content;
@@ -270,7 +276,7 @@ proto.getApi = function getApi(apiMessage) {
270
276
  }
271
277
 
272
278
  const api = (0, _Api.DefinitionApi)(this.broker, apiMessage);
273
- const postponed = this[processesSymbol].postponed;
279
+ const postponed = this[kProcesses].postponed;
274
280
  const self = this;
275
281
 
276
282
  api.getExecuting = function getExecuting() {
@@ -286,7 +292,7 @@ proto.getApi = function getApi(apiMessage) {
286
292
  };
287
293
 
288
294
  proto.getPostponed = function getPostponed(...args) {
289
- const running = this[processesSymbol].running;
295
+ const running = this[kProcesses].running;
290
296
  return running.reduce((result, p) => {
291
297
  result = result.concat(p.getPostponed(...args));
292
298
  return result;
@@ -298,10 +304,10 @@ proto._start = function start() {
298
304
  ids,
299
305
  executable,
300
306
  postponed
301
- } = this[processesSymbol];
307
+ } = this[kProcesses];
302
308
 
303
309
  if (!ids.length) {
304
- return this.publishCompletionMessage('completed');
310
+ return this._complete('completed');
305
311
  }
306
312
 
307
313
  if (!executable.length) {
@@ -310,32 +316,32 @@ proto._start = function start() {
310
316
  });
311
317
  }
312
318
 
313
- this[statusSymbol] = 'start';
319
+ this[kStatus] = 'start';
314
320
 
315
321
  for (const bp of executable) bp.init();
316
322
 
317
323
  for (const bp of executable) bp.run();
318
324
 
319
325
  postponed.splice(0);
320
- this[processesQSymbol].assertConsumer(this[messageHandlersSymbol].onProcessMessage, {
326
+ this[kProcessesQ].assertConsumer(this[kMessageHandlers].onProcessMessage, {
321
327
  prefetch: 1000,
322
328
  consumerTag: `_definition-activity-${this.executionId}`
323
329
  });
324
330
  };
325
331
 
326
332
  proto._activate = function activate(processList) {
327
- this.broker.subscribeTmp('api', '#', this[messageHandlersSymbol].onApiMessage, {
333
+ this.broker.subscribeTmp('api', '#', this[kMessageHandlers].onApiMessage, {
328
334
  noAck: true,
329
335
  consumerTag: '_definition-api-consumer'
330
336
  });
331
337
 
332
338
  for (const bp of processList) this._activateProcess(bp);
333
339
 
334
- this[activatedSymbol] = true;
340
+ this[kActivated] = true;
335
341
  };
336
342
 
337
343
  proto._activateProcess = function activateProcess(bp) {
338
- const handlers = this[messageHandlersSymbol];
344
+ const handlers = this[kMessageHandlers];
339
345
  bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
340
346
  noAck: true,
341
347
  consumerTag: '_definition-outbound-message-consumer'
@@ -371,7 +377,7 @@ proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
371
377
  const message = (0, _messageHelper.cloneMessage)(originalMessage);
372
378
  const content = message.content;
373
379
  const parent = content.parent = content.parent || {};
374
- const isDirectChild = this[processesSymbol].ids.indexOf(content.id) > -1;
380
+ const isDirectChild = this[kProcesses].ids.indexOf(content.id) > -1;
375
381
 
376
382
  if (isDirectChild) {
377
383
  parent.executionId = this.executionId;
@@ -383,16 +389,16 @@ proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
383
389
  mandatory: false
384
390
  });
385
391
  if (!isDirectChild) return;
386
- this[processesQSymbol].queueMessage(message.fields, (0, _messageHelper.cloneContent)(content), message.properties);
392
+ this[kProcessesQ].queueMessage(message.fields, (0, _messageHelper.cloneContent)(content), message.properties);
387
393
  };
388
394
 
389
395
  proto._deactivate = function deactivate() {
390
396
  this.broker.cancel('_definition-api-consumer');
391
397
  this.broker.cancel(`_definition-activity-${this.executionId}`);
392
398
 
393
- for (const bp of this[processesSymbol].running) this._deactivateProcess(bp);
399
+ for (const bp of this[kProcesses].running) this._deactivateProcess(bp);
394
400
 
395
- this[activatedSymbol] = false;
401
+ this[kActivated] = false;
396
402
  };
397
403
 
398
404
  proto._deactivateProcess = function deactivateProcess(bp) {
@@ -409,7 +415,6 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
409
415
  const isRedelivered = message.fields.redelivered;
410
416
  const {
411
417
  id: childId,
412
- executionId: childExecutionId,
413
418
  inbound
414
419
  } = content;
415
420
  if (isRedelivered && message.properties.persistent === false) return;
@@ -417,12 +422,8 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
417
422
  switch (routingKey) {
418
423
  case 'execution.stop':
419
424
  {
420
- if (childExecutionId === this.executionId) {
421
- message.ack();
422
- return this._onStopped(message);
423
- }
424
-
425
- break;
425
+ message.ack();
426
+ return this._onStopped(message);
426
427
  }
427
428
 
428
429
  case 'process.leave':
@@ -434,9 +435,8 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
434
435
  this._stateChangeMessage(message, true);
435
436
 
436
437
  switch (routingKey) {
437
- case 'process.discard':
438
438
  case 'process.enter':
439
- this[statusSymbol] = 'executing';
439
+ this[kStatus] = 'executing';
440
440
  break;
441
441
 
442
442
  case 'process.discarded':
@@ -488,7 +488,7 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
488
488
  type: 'error'
489
489
  });
490
490
  } else {
491
- for (const bp of this[processesSymbol].running.slice()) {
491
+ for (const bp of this[kProcesses].running.slice()) {
492
492
  if (bp.id !== childId) bp.stop();
493
493
  }
494
494
 
@@ -504,7 +504,7 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
504
504
 
505
505
  proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
506
506
  let previousMsg;
507
- const postponed = this[processesSymbol].postponed;
507
+ const postponed = this[kProcesses].postponed;
508
508
  const idx = postponed.findIndex(msg => msg.content.executionId === message.content.executionId);
509
509
 
510
510
  if (idx > -1) {
@@ -542,18 +542,18 @@ proto._onProcessCompleted = function onProcessCompleted(message) {
542
542
  };
543
543
 
544
544
  proto._onStopped = function onStopped(message) {
545
- const running = this[processesSymbol].running;
545
+ const running = this[kProcesses].running;
546
546
 
547
547
  this._debug(`stop definition execution (stop process executions ${running.length})`);
548
548
 
549
- this[processesQSymbol].close();
550
-
551
- this._deactivate();
549
+ this[kProcessesQ].close();
552
550
 
553
551
  for (const bp of running.slice()) bp.stop();
554
552
 
555
- this[stoppedSymbol] = true;
556
- return this.broker.publish('execution', `execution.stopped.${this.executionId}`, (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, { ...message.content
553
+ this._deactivate();
554
+
555
+ this[kStopped] = true;
556
+ return this.broker.publish('execution', `execution.stopped.${this.executionId}`, (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, { ...message.content
557
557
  }), {
558
558
  type: 'stopped',
559
559
  persistent: false
@@ -574,7 +574,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
574
574
  }
575
575
 
576
576
  if (delegate) {
577
- for (const bp of this[processesSymbol].running.slice()) {
577
+ for (const bp of this[kProcesses].running.slice()) {
578
578
  bp.broker.publish('api', routingKey, (0, _messageHelper.cloneContent)(message.content), message.properties);
579
579
  }
580
580
  }
@@ -582,7 +582,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
582
582
  if (this.executionId !== message.content.executionId) return;
583
583
 
584
584
  if (messageType === 'stop') {
585
- this[processesQSymbol].queueMessage({
585
+ this[kProcessesQ].queueMessage({
586
586
  routingKey: 'execution.stop'
587
587
  }, (0, _messageHelper.cloneContent)(message.content), {
588
588
  persistent: false
@@ -594,7 +594,7 @@ proto._startProcessesByMessage = function startProcessesByMessage(reference) {
594
594
  const {
595
595
  processes: bps,
596
596
  running
597
- } = this[processesSymbol];
597
+ } = this[kProcesses];
598
598
  if (bps.length < 2) return;
599
599
 
600
600
  for (const bp of bps) {
@@ -654,7 +654,7 @@ proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
654
654
 
655
655
  this._activateProcess(targetProcess);
656
656
 
657
- this[processesSymbol].running.push(targetProcess);
657
+ this[kProcesses].running.push(targetProcess);
658
658
  targetProcess.init();
659
659
  targetProcess.run();
660
660
  targetProcess.sendMessage(message);
@@ -692,7 +692,7 @@ proto._onCallActivity = function onCallActivity(routingKey, message) {
692
692
 
693
693
  this._activateProcess(targetProcess);
694
694
 
695
- this[processesSymbol].running.push(targetProcess);
695
+ this[kProcesses].running.push(targetProcess);
696
696
  targetProcess.init(bpExecutionId);
697
697
  targetProcess.run({
698
698
  inbound: [(0, _messageHelper.cloneContent)(content)]
@@ -746,7 +746,7 @@ proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage
746
746
  };
747
747
 
748
748
  proto._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
749
- const running = this[processesSymbol].running;
749
+ const running = this[kProcesses].running;
750
750
  const idx = running.findIndex(p => p.executionId === processExecutionId);
751
751
  if (idx === -1) return;
752
752
  return running.splice(idx, 1)[0];
@@ -755,14 +755,14 @@ proto._removeProcessByExecutionId = function removeProcessByExecutionId(processE
755
755
  proto._complete = function complete(completionType, content, options) {
756
756
  this._deactivate();
757
757
 
758
- const stateMessage = this[executeMessageSymbol];
758
+ const stateMessage = this[kExecuteMessage];
759
759
 
760
760
  this._debug(`definition execution ${completionType} in ${Date.now() - stateMessage.properties.timestamp}ms`);
761
761
 
762
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);
763
+ this[kCompleted] = true;
764
+ this[kStatus] = completionType;
765
+ this.broker.deleteQueue(this[kProcessesQ].name);
766
766
  return this.broker.publish('execution', `execution.${completionType}.${this.executionId}`, { ...stateMessage.content,
767
767
  output: { ...this.environment.output
768
768
  },
@@ -775,23 +775,12 @@ proto._complete = function complete(completionType, content, options) {
775
775
  });
776
776
  };
777
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
778
  proto._createMessage = function createMessage(content = {}) {
790
779
  return {
791
780
  id: this.id,
792
781
  type: this.type,
793
782
  executionId: this.executionId,
794
- status: this.status,
783
+ status: this[kStatus],
795
784
  ...content
796
785
  };
797
786
  };
@@ -820,5 +809,5 @@ proto._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentEx
820
809
  };
821
810
 
822
811
  proto._debug = function debug(logMessage) {
823
- this[parentSymbol].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
812
+ this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
824
813
  };
@@ -9,9 +9,9 @@ var _shared = require("../shared");
9
9
 
10
10
  var _messageHelper = require("../messageHelper");
11
11
 
12
- const messageQSymbol = Symbol.for('cancelQ');
13
- const completedSymbol = Symbol.for('completed');
14
- const executeMessageSymbol = Symbol.for('executeMessage');
12
+ const kMessageQ = Symbol.for('cancelQ');
13
+ const kCompleted = Symbol.for('completed');
14
+ const kExecuteMessage = Symbol.for('executeMessage');
15
15
 
16
16
  function CancelEventDefinition(activity, eventDefinition) {
17
17
  const {
@@ -33,9 +33,9 @@ function CancelEventDefinition(activity, eventDefinition) {
33
33
  this.logger = environment.Logger(type.toLowerCase());
34
34
 
35
35
  if (!isThrowing) {
36
- this[completedSymbol] = false;
36
+ this[kCompleted] = false;
37
37
  const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-q`;
38
- this[messageQSymbol] = broker.assertQueue(messageQueueName, {
38
+ this[kMessageQ] = broker.assertQueue(messageQueueName, {
39
39
  autoDelete: false,
40
40
  durable: true
41
41
  });
@@ -49,7 +49,7 @@ function CancelEventDefinition(activity, eventDefinition) {
49
49
  const proto = CancelEventDefinition.prototype;
50
50
  Object.defineProperty(proto, 'executionId', {
51
51
  get() {
52
- const message = this[executeMessageSymbol];
52
+ const message = this[kExecuteMessage];
53
53
  return message && message.content.executionId;
54
54
  }
55
55
 
@@ -60,8 +60,8 @@ proto.execute = function execute(executeMessage) {
60
60
  };
61
61
 
62
62
  proto.executeCatch = function executeCatch(executeMessage) {
63
- this[executeMessageSymbol] = executeMessage;
64
- this[completedSymbol] = false;
63
+ this[kExecuteMessage] = executeMessage;
64
+ this[kCompleted] = false;
65
65
  const executeContent = executeMessage.content;
66
66
  const {
67
67
  executionId,
@@ -72,11 +72,11 @@ proto.executeCatch = function executeCatch(executeMessage) {
72
72
 
73
73
  const onCatchMessage = this._onCatchMessage.bind(this);
74
74
 
75
- this[messageQSymbol].consume(onCatchMessage, {
75
+ this[kMessageQ].consume(onCatchMessage, {
76
76
  noAck: true,
77
77
  consumerTag: `_oncancel-${executionId}`
78
78
  });
79
- if (this[completedSymbol]) return;
79
+ if (this[kCompleted]) return;
80
80
 
81
81
  const onApiMessage = this._onApiMessage.bind(this);
82
82
 
@@ -137,7 +137,7 @@ proto._onCatchMessage = function onCatchMessage(_, message) {
137
137
  proto._onCancelTransaction = function onCancelTransaction(_, message) {
138
138
  const broker = this.broker,
139
139
  executionId = this.executionId;
140
- const executeContent = this[executeMessageSymbol].content;
140
+ const executeContent = this[kExecuteMessage].content;
141
141
  broker.cancel(`_oncancel-${executionId}`);
142
142
 
143
143
  this._debug(`cancel transaction thrown by <${message.content.id}>`);
@@ -167,13 +167,13 @@ proto._onCancelTransaction = function onCancelTransaction(_, message) {
167
167
  };
168
168
 
169
169
  proto._complete = function complete(output) {
170
- this[completedSymbol] = true;
170
+ this[kCompleted] = true;
171
171
 
172
172
  this._stop();
173
173
 
174
174
  this._debug('completed');
175
175
 
176
- const content = (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, {
176
+ const content = (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
177
177
  output,
178
178
  state: 'cancel'
179
179
  });
@@ -184,11 +184,11 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
184
184
  switch (message.properties.type) {
185
185
  case 'discard':
186
186
  {
187
- this[completedSymbol] = true;
187
+ this[kCompleted] = true;
188
188
 
189
189
  this._stop();
190
190
 
191
- const content = (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content);
191
+ const content = (0, _messageHelper.cloneContent)(this[kExecuteMessage].content);
192
192
  return this.broker.publish('execution', 'execute.discard', content);
193
193
  }
194
194
 
@@ -209,7 +209,7 @@ proto._stop = function stop() {
209
209
  broker.cancel(`_oncancel-${executionId}`);
210
210
  broker.cancel(`_oncancelend-${executionId}`);
211
211
  broker.cancel(`_onattached-cancel-${executionId}`);
212
- this[messageQSymbol].purge();
212
+ this[kMessageQ].purge();
213
213
  };
214
214
 
215
215
  proto._debug = function debug(msg) {