bpmn-elements 7.0.0 → 8.1.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 (72) hide show
  1. package/CHANGELOG.md +23 -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 +106 -106
  6. package/dist/src/activity/ActivityExecution.js +37 -37
  7. package/dist/src/activity/Message.js +2 -2
  8. package/dist/src/activity/Signal.js +2 -2
  9. package/dist/src/definition/Definition.js +50 -50
  10. package/dist/src/definition/DefinitionExecution.js +114 -125
  11. package/dist/src/eventDefinitions/CancelEventDefinition.js +16 -16
  12. package/dist/src/eventDefinitions/CompensateEventDefinition.js +24 -24
  13. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  14. package/dist/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  15. package/dist/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  16. package/dist/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  17. package/dist/src/eventDefinitions/LinkEventDefinition.js +15 -15
  18. package/dist/src/eventDefinitions/MessageEventDefinition.js +23 -23
  19. package/dist/src/eventDefinitions/SignalEventDefinition.js +24 -24
  20. package/dist/src/eventDefinitions/TimerEventDefinition.js +76 -53
  21. package/dist/src/events/BoundaryEvent.js +67 -38
  22. package/dist/src/events/EndEvent.js +3 -3
  23. package/dist/src/events/IntermediateCatchEvent.js +3 -3
  24. package/dist/src/events/IntermediateThrowEvent.js +3 -3
  25. package/dist/src/events/StartEvent.js +9 -9
  26. package/dist/src/flows/Association.js +7 -7
  27. package/dist/src/flows/MessageFlow.js +9 -9
  28. package/dist/src/flows/SequenceFlow.js +7 -7
  29. package/dist/src/gateways/EventBasedGateway.js +11 -11
  30. package/dist/src/io/InputOutputSpecification.js +4 -4
  31. package/dist/src/io/Properties.js +9 -9
  32. package/dist/src/process/Process.js +64 -61
  33. package/dist/src/process/ProcessExecution.js +93 -90
  34. package/dist/src/tasks/ReceiveTask.js +16 -16
  35. package/dist/src/tasks/SubProcess.js +16 -18
  36. package/package.json +15 -16
  37. package/src/Context.js +48 -40
  38. package/src/Environment.js +48 -20
  39. package/src/EventBroker.js +1 -1
  40. package/src/MessageFormatter.js +11 -11
  41. package/src/activity/Activity.js +99 -100
  42. package/src/activity/ActivityExecution.js +35 -35
  43. package/src/activity/Message.js +1 -1
  44. package/src/activity/Signal.js +1 -1
  45. package/src/definition/Definition.js +51 -50
  46. package/src/definition/DefinitionExecution.js +111 -113
  47. package/src/eventDefinitions/CancelEventDefinition.js +16 -16
  48. package/src/eventDefinitions/CompensateEventDefinition.js +25 -24
  49. package/src/eventDefinitions/ConditionalEventDefinition.js +8 -8
  50. package/src/eventDefinitions/ErrorEventDefinition.js +26 -26
  51. package/src/eventDefinitions/EscalationEventDefinition.js +20 -20
  52. package/src/eventDefinitions/EventDefinitionExecution.js +14 -14
  53. package/src/eventDefinitions/LinkEventDefinition.js +15 -15
  54. package/src/eventDefinitions/MessageEventDefinition.js +23 -23
  55. package/src/eventDefinitions/SignalEventDefinition.js +24 -24
  56. package/src/eventDefinitions/TimerEventDefinition.js +61 -44
  57. package/src/events/BoundaryEvent.js +53 -36
  58. package/src/events/EndEvent.js +3 -3
  59. package/src/events/IntermediateCatchEvent.js +3 -3
  60. package/src/events/IntermediateThrowEvent.js +3 -3
  61. package/src/events/StartEvent.js +9 -9
  62. package/src/flows/Association.js +7 -7
  63. package/src/flows/MessageFlow.js +9 -9
  64. package/src/flows/SequenceFlow.js +7 -7
  65. package/src/gateways/EventBasedGateway.js +11 -11
  66. package/src/io/BpmnIO.js +5 -1
  67. package/src/io/InputOutputSpecification.js +4 -4
  68. package/src/io/Properties.js +9 -9
  69. package/src/process/Process.js +62 -58
  70. package/src/process/ProcessExecution.js +86 -88
  71. package/src/tasks/ReceiveTask.js +16 -16
  72. package/src/tasks/SubProcess.js +16 -16
@@ -4,20 +4,20 @@ import {getUniqueId} from '../shared';
4
4
 
5
5
  export default ProcessExecution;
6
6
 
7
- const activatedSymbol = Symbol.for('activated');
8
- const activityQSymbol = Symbol.for('activityQ');
9
- const completedSymbol = Symbol.for('completed');
10
- const elementsSymbol = Symbol.for('elements');
11
- const executeMessageSymbol = Symbol.for('executeMessage');
12
- const messageHandlersSymbol = Symbol.for('messageHandlers');
13
- const parentSymbol = Symbol.for('parent');
14
- const statusSymbol = Symbol.for('status');
15
- const stoppedSymbol = Symbol.for('stopped');
7
+ const kActivated = Symbol.for('activated');
8
+ const kActivityQ = Symbol.for('activityQ');
9
+ const kCompleted = Symbol.for('completed');
10
+ const kElements = Symbol.for('elements');
11
+ const kExecuteMessage = Symbol.for('executeMessage');
12
+ const kMessageHandlers = Symbol.for('messageHandlers');
13
+ const kParent = Symbol.for('parent');
14
+ const kStatus = Symbol.for('status');
15
+ const kStopped = Symbol.for('stopped');
16
16
 
17
17
  function ProcessExecution(parentActivity, context) {
18
18
  const {id, type, broker, isSubProcess} = parentActivity;
19
19
 
20
- this[parentSymbol] = parentActivity;
20
+ this[kParent] = parentActivity;
21
21
  this.id = id;
22
22
  this.type = type;
23
23
  this.isSubProcess = isSubProcess;
@@ -25,7 +25,7 @@ function ProcessExecution(parentActivity, context) {
25
25
  this.environment = context.environment;
26
26
  this.context = context;
27
27
 
28
- this[elementsSymbol] = {
28
+ this[kElements] = {
29
29
  children: context.getActivities(id),
30
30
  associations: context.getAssociations(id),
31
31
  flows: context.getSequenceFlows(id),
@@ -40,13 +40,13 @@ function ProcessExecution(parentActivity, context) {
40
40
  const exchangeName = this._exchangeName = isSubProcess ? 'subprocess-execution' : 'execution';
41
41
  broker.assertExchange(exchangeName, 'topic', {autoDelete: false, durable: true});
42
42
 
43
- this[completedSymbol] = false;
44
- this[stoppedSymbol] = false;
45
- this[activatedSymbol] = false;
46
- this[statusSymbol] = 'init';
43
+ this[kCompleted] = false;
44
+ this[kStopped] = false;
45
+ this[kActivated] = false;
46
+ this[kStatus] = 'init';
47
47
  this.executionId = undefined;
48
48
 
49
- this[messageHandlersSymbol] = {
49
+ this[kMessageHandlers] = {
50
50
  onActivityEvent: this._onActivityEvent.bind(this),
51
51
  onApiMessage: this._onApiMessage.bind(this),
52
52
  onChildMessage: this._onChildMessage.bind(this),
@@ -59,33 +59,33 @@ const proto = ProcessExecution.prototype;
59
59
  Object.defineProperty(proto, 'stopped', {
60
60
  enumerable: true,
61
61
  get() {
62
- return this[stoppedSymbol];
62
+ return this[kStopped];
63
63
  },
64
64
  });
65
65
 
66
66
  Object.defineProperty(proto, 'completed', {
67
67
  enumerable: true,
68
68
  get() {
69
- return this[completedSymbol];
69
+ return this[kCompleted];
70
70
  },
71
71
  });
72
72
 
73
73
  Object.defineProperty(proto, 'status', {
74
74
  enumerable: true,
75
75
  get() {
76
- return this[statusSymbol];
76
+ return this[kStatus];
77
77
  },
78
78
  });
79
79
 
80
80
  Object.defineProperty(proto, 'postponedCount', {
81
81
  get() {
82
- return this[elementsSymbol].postponed.length;
82
+ return this[kElements].postponed.length;
83
83
  },
84
84
  });
85
85
 
86
86
  Object.defineProperty(proto, 'isRunning', {
87
87
  get() {
88
- return this[activatedSymbol];
88
+ return this[kActivated];
89
89
  },
90
90
  });
91
91
 
@@ -95,15 +95,15 @@ proto.execute = function execute(executeMessage) {
95
95
 
96
96
  const executionId = this.executionId = executeMessage.content.executionId;
97
97
 
98
- this[executeMessageSymbol] = cloneMessage(executeMessage, {
98
+ this[kExecuteMessage] = cloneMessage(executeMessage, {
99
99
  executionId,
100
100
  state: 'start',
101
101
  });
102
102
 
103
- this[stoppedSymbol] = false;
103
+ this[kStopped] = false;
104
104
 
105
105
  this.environment.assignVariables(executeMessage);
106
- this[activityQSymbol] = this.broker.assertQueue(`execute-${executionId}-q`, {durable: true, autoDelete: false});
106
+ this[kActivityQ] = this.broker.assertQueue(`execute-${executionId}-q`, {durable: true, autoDelete: false});
107
107
 
108
108
  if (executeMessage.fields.redelivered) {
109
109
  return this.resume();
@@ -118,11 +118,11 @@ proto.execute = function execute(executeMessage) {
118
118
  proto.resume = function resume() {
119
119
  this._debug(`resume process execution at ${this.status}`);
120
120
 
121
- if (this[completedSymbol]) return this._complete('completed');
121
+ if (this[kCompleted]) return this._complete('completed');
122
122
 
123
123
  this._activate();
124
124
 
125
- const {startActivities, detachedActivities, postponed} = this[elementsSymbol];
125
+ const {startActivities, detachedActivities, postponed} = this[kElements];
126
126
 
127
127
  if (startActivities.length > 1) {
128
128
  for (const a of startActivities) a.shake();
@@ -131,12 +131,12 @@ proto.resume = function resume() {
131
131
  postponed.splice(0);
132
132
  detachedActivities.splice(0);
133
133
 
134
- this[activityQSymbol].consume(this[messageHandlersSymbol].onChildMessage, {
134
+ this[kActivityQ].consume(this[kMessageHandlers].onChildMessage, {
135
135
  prefetch: 1000,
136
136
  consumerTag: `_process-activity-${this.executionId}`,
137
137
  });
138
138
 
139
- if (this[completedSymbol]) return this._complete('completed');
139
+ if (this[kCompleted]) return;
140
140
 
141
141
  switch (this.status) {
142
142
  case 'init':
@@ -159,9 +159,9 @@ proto.recover = function recover(state) {
159
159
  if (!state) return this;
160
160
  this.executionId = state.executionId;
161
161
 
162
- this[stoppedSymbol] = state.stopped;
163
- this[completedSymbol] = state.completed;
164
- this[statusSymbol] = state.status;
162
+ this[kStopped] = state.stopped;
163
+ this[kCompleted] = state.completed;
164
+ this[kStatus] = state.status;
165
165
 
166
166
  this._debug(`recover process execution at ${this.status}`);
167
167
 
@@ -209,7 +209,7 @@ proto.shake = function shake(fromId) {
209
209
  this.executionId = getUniqueId(id);
210
210
  this._activate();
211
211
  }
212
- const toShake = fromId ? [this.getActivityById(fromId)].filter(Boolean) : this[elementsSymbol].startActivities;
212
+ const toShake = fromId ? [this.getActivityById(fromId)].filter(Boolean) : this[kElements].startActivities;
213
213
 
214
214
  const result = {};
215
215
  this.broker.subscribeTmp('event', '*.shake.*', (routingKey, {content}) => {
@@ -241,7 +241,7 @@ proto.stop = function stop() {
241
241
  };
242
242
 
243
243
  proto.getPostponed = function getPostponed(filterFn) {
244
- return this[elementsSymbol].postponed.slice().reduce((result, msg) => {
244
+ return this[kElements].postponed.slice().reduce((result, msg) => {
245
245
  const api = this._getChildApi(msg);
246
246
  if (api) {
247
247
  if (filterFn && !filterFn(api)) return result;
@@ -252,8 +252,8 @@ proto.getPostponed = function getPostponed(filterFn) {
252
252
  };
253
253
 
254
254
  proto.discard = function discard() {
255
- this[statusSymbol] = 'discard';
256
- return this[activityQSymbol].queueMessage({routingKey: 'execution.discard'}, {
255
+ this[kStatus] = 'discard';
256
+ return this[kActivityQ].queueMessage({routingKey: 'execution.discard'}, {
257
257
  id: this.id,
258
258
  type: this.type,
259
259
  executionId: this.executionId,
@@ -262,37 +262,37 @@ proto.discard = function discard() {
262
262
 
263
263
 
264
264
  proto.getState = function getState() {
265
- const {flows, outboundMessageFlows, associations} = this[elementsSymbol];
265
+ const {children, flows, outboundMessageFlows, associations} = this[kElements];
266
266
  return {
267
267
  executionId: this.executionId,
268
- stopped: this[stoppedSymbol],
269
- completed: this[completedSymbol],
268
+ stopped: this[kStopped],
269
+ completed: this[kCompleted],
270
270
  status: this.status,
271
- children: this[elementsSymbol].children.reduce((result, activity) => {
271
+ children: children.reduce((result, activity) => {
272
272
  if (activity.placeholder) return result;
273
273
  result.push(activity.getState());
274
274
  return result;
275
275
  }, []),
276
- flows: flows.map((f) => f.getState()),
277
- messageFlows: outboundMessageFlows.map((f) => f.getState()),
278
- associations: associations.map((f) => f.getState()),
276
+ ...(flows.length && {flows: flows.map((f) => f.getState())}),
277
+ ...(outboundMessageFlows.length && {messageFlows: outboundMessageFlows.length && outboundMessageFlows.map((f) => f.getState())}),
278
+ ...(associations.length && {associations: associations.map((f) => f.getState())}),
279
279
  };
280
280
  };
281
281
 
282
282
  proto.getActivities = function getActivities() {
283
- return this[elementsSymbol].children.slice();
283
+ return this[kElements].children.slice();
284
284
  };
285
285
 
286
286
  proto.getActivityById = function getActivityById(activityId) {
287
- return this[elementsSymbol].children.find((child) => child.id === activityId);
287
+ return this[kElements].children.find((child) => child.id === activityId);
288
288
  };
289
289
 
290
290
  proto.getSequenceFlows = function getSequenceFlows() {
291
- return this[elementsSymbol].flows.slice();
291
+ return this[kElements].flows.slice();
292
292
  };
293
293
 
294
294
  proto.getApi = function getApi(message) {
295
- if (!message) return ProcessApi(this.broker, this[executeMessageSymbol]);
295
+ if (!message) return ProcessApi(this.broker, this[kExecuteMessage]);
296
296
 
297
297
  const content = message.content;
298
298
 
@@ -301,7 +301,7 @@ proto.getApi = function getApi(message) {
301
301
  }
302
302
 
303
303
  const api = ProcessApi(this.broker, message);
304
- const postponed = this[elementsSymbol].postponed;
304
+ const postponed = this[kElements].postponed;
305
305
  const self = this;
306
306
 
307
307
  api.getExecuting = function getExecuting() {
@@ -316,17 +316,17 @@ proto.getApi = function getApi(message) {
316
316
  };
317
317
 
318
318
  proto._start = function start() {
319
- if (this[elementsSymbol].children.length === 0) {
319
+ if (this[kElements].children.length === 0) {
320
320
  return this._complete('completed');
321
321
  }
322
322
 
323
- this[statusSymbol] = 'start';
323
+ this[kStatus] = 'start';
324
324
 
325
- const executeContent = {...this[executeMessageSymbol].content, state: this.status};
325
+ const executeContent = {...this[kExecuteMessage].content, state: this.status};
326
326
 
327
327
  this.broker.publish(this._exchangeName, 'execute.start', cloneContent(executeContent));
328
328
 
329
- const {startActivities, postponed, detachedActivities} = this[elementsSymbol];
329
+ const {startActivities, postponed, detachedActivities} = this[kElements];
330
330
  if (startActivities.length > 1) {
331
331
  for (const a of startActivities) a.shake();
332
332
  }
@@ -336,14 +336,14 @@ proto._start = function start() {
336
336
 
337
337
  postponed.splice(0);
338
338
  detachedActivities.splice(0);
339
- this[activityQSymbol].assertConsumer(this[messageHandlersSymbol].onChildMessage, {
339
+ this[kActivityQ].assertConsumer(this[kMessageHandlers].onChildMessage, {
340
340
  prefetch: 1000,
341
341
  consumerTag: `_process-activity-${this.executionId}`,
342
342
  });
343
343
  };
344
344
 
345
345
  proto._activate = function activate() {
346
- const {onApiMessage, onMessageFlowEvent, onActivityEvent} = this[messageHandlersSymbol];
346
+ const {onApiMessage, onMessageFlowEvent, onActivityEvent} = this[kMessageHandlers];
347
347
 
348
348
  this.broker.subscribeTmp('api', '#', onApiMessage, {
349
349
  noAck: true,
@@ -351,7 +351,7 @@ proto._activate = function activate() {
351
351
  priority: 200,
352
352
  });
353
353
 
354
- const {outboundMessageFlows, flows, associations, startActivities, triggeredByEvent, children} = this[elementsSymbol];
354
+ const {outboundMessageFlows, flows, associations, startActivities, triggeredByEvent, children} = this[kElements];
355
355
 
356
356
  for (const flow of outboundMessageFlows) {
357
357
  flow.activate();
@@ -393,7 +393,7 @@ proto._activate = function activate() {
393
393
  if (activity.triggeredByEvent) triggeredByEvent.push(activity);
394
394
  }
395
395
 
396
- this[activatedSymbol] = true;
396
+ this[kActivated] = true;
397
397
  };
398
398
 
399
399
  proto._deactivate = function deactivate() {
@@ -402,7 +402,7 @@ proto._deactivate = function deactivate() {
402
402
  broker.cancel(`_process-api-consumer-${executionId}`);
403
403
  broker.cancel(`_process-activity-${executionId}`);
404
404
 
405
- const {children, flows, associations, outboundMessageFlows} = this[elementsSymbol];
405
+ const {children, flows, associations, outboundMessageFlows} = this[kElements];
406
406
 
407
407
  for (const activity of children) {
408
408
  if (activity.placeholder) continue;
@@ -423,7 +423,7 @@ proto._deactivate = function deactivate() {
423
423
  flow.broker.cancel('_process-message-consumer');
424
424
  }
425
425
 
426
- this[activatedSymbol] = false;
426
+ this[kActivated] = false;
427
427
  };
428
428
 
429
429
  proto._onDelegateEvent = function onDelegateEvent(message) {
@@ -437,7 +437,7 @@ proto._onDelegateEvent = function onDelegateEvent(message) {
437
437
  this._debug(`delegate ${eventType} anonymous event`);
438
438
  }
439
439
 
440
- for (const activity of this[elementsSymbol].triggeredByEvent) {
440
+ for (const activity of this[kElements].triggeredByEvent) {
441
441
  if (activity.getStartActivities({referenceId: content.message && content.message.id, referenceType: eventType}).length) {
442
442
  delegate = false;
443
443
  activity.run(content.message);
@@ -477,12 +477,12 @@ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
477
477
 
478
478
  switch (routingKey) {
479
479
  case 'process.terminate':
480
- return this[activityQSymbol].queueMessage({routingKey: 'execution.terminate'}, cloneContent(content), {type: 'terminate', persistent: true});
480
+ return this[kActivityQ].queueMessage({routingKey: 'execution.terminate'}, cloneContent(content), {type: 'terminate', persistent: true});
481
481
  case 'activity.stop':
482
482
  return;
483
483
  }
484
484
 
485
- this[activityQSymbol].queueMessage(message.fields, cloneContent(content), {persistent: true, ...message.properties});
485
+ this[kActivityQ].queueMessage(message.fields, cloneContent(content), {persistent: true, ...message.properties});
486
486
  };
487
487
 
488
488
  proto._onChildMessage = function onChildMessage(routingKey, message) {
@@ -510,13 +510,13 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
510
510
 
511
511
  switch (routingKey) {
512
512
  case 'activity.detach': {
513
- this[elementsSymbol].detachedActivities.push(cloneMessage(message));
513
+ this[kElements].detachedActivities.push(cloneMessage(message));
514
514
  break;
515
515
  }
516
516
  case 'activity.discard':
517
517
  case 'activity.compensation.start':
518
518
  case 'activity.enter': {
519
- this[statusSymbol] = 'executing';
519
+ this[kStatus] = 'executing';
520
520
  if (!content.inbound) break;
521
521
 
522
522
  for (const inbound of content.inbound) {
@@ -527,9 +527,8 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
527
527
 
528
528
  break;
529
529
  }
530
- case 'flow.error':
531
530
  case 'activity.error': {
532
- const eventCaughtBy = this[elementsSymbol].postponed.find((msg) => {
531
+ const eventCaughtBy = this[kElements].postponed.find((msg) => {
533
532
  if (msg.fields.routingKey !== 'activity.catch') return;
534
533
  return msg.content.source && msg.content.source.executionId === content.executionId;
535
534
  });
@@ -544,11 +543,11 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
544
543
  proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
545
544
  const previousMsg = this._popPostponed(message.content);
546
545
  if (previousMsg) previousMsg.ack();
547
- if (postponeMessage) this[elementsSymbol].postponed.push(message);
546
+ if (postponeMessage) this[kElements].postponed.push(message);
548
547
  };
549
548
 
550
549
  proto._popPostponed = function popPostponed(byContent) {
551
- const {postponed, detachedActivities} = this[elementsSymbol];
550
+ const {postponed, detachedActivities} = this[kElements];
552
551
 
553
552
  const postponedIdx = postponed.findIndex((msg) => {
554
553
  if (msg.content.isSequenceFlow) return msg.content.sequenceId === byContent.sequenceId;
@@ -572,7 +571,7 @@ proto._onChildCompleted = function onChildCompleted(message) {
572
571
 
573
572
  const {id, type, isEnd} = message.content;
574
573
 
575
- const {postponed, detachedActivities, startActivities} = this[elementsSymbol];
574
+ const {postponed, detachedActivities, startActivities} = this[kElements];
576
575
  const postponedCount = postponed.length;
577
576
 
578
577
  if (!postponedCount) {
@@ -589,7 +588,7 @@ proto._onChildCompleted = function onChildCompleted(message) {
589
588
  }
590
589
 
591
590
  if (isEnd && startActivities.length) {
592
- const startSequences = this[elementsSymbol].startSequences;
591
+ const startSequences = this[kElements].startSequences;
593
592
  for (const msg of postponed) {
594
593
  const postponedId = msg.content.id;
595
594
  const startSequence = startSequences[postponedId];
@@ -603,29 +602,28 @@ proto._onChildCompleted = function onChildCompleted(message) {
603
602
  };
604
603
 
605
604
  proto._stopExecution = function stopExecution(message) {
606
- if (this[stoppedSymbol]) return;
607
605
  const postponedCount = this.postponedCount;
608
606
  this._debug(`stop process execution (stop child executions ${postponedCount})`);
609
607
  if (postponedCount) {
610
608
  for (const api of this.getPostponed()) api.stop();
611
609
  }
612
610
  this._deactivate();
613
- this[stoppedSymbol] = true;
611
+ this[kStopped] = true;
614
612
  return this.broker.publish(this._exchangeName, `execution.stopped.${this.executionId}`, {
615
- ...this[executeMessageSymbol].content,
613
+ ...this[kExecuteMessage].content,
616
614
  ...(message && message.content),
617
615
  }, {type: 'stopped', persistent: false});
618
616
  };
619
617
 
620
618
  proto._onDiscard = function onDiscard() {
621
619
  this._deactivate();
622
- const running = this[elementsSymbol].postponed.splice(0);
620
+ const running = this[kElements].postponed.splice(0);
623
621
  this._debug(`discard process execution (discard child executions ${running.length})`);
624
622
 
625
623
  for (const flow of this.getSequenceFlows()) flow.stop();
626
624
  for (const msg of running) this._getChildApi(msg).discard();
627
625
 
628
- this[activityQSymbol].purge();
626
+ this[kActivityQ].purge();
629
627
  return this._complete('discard');
630
628
  };
631
629
 
@@ -633,7 +631,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
633
631
  const executionId = this.executionId;
634
632
  const broker = this.broker;
635
633
  if (message.properties.delegate) {
636
- const {correlationId} = message.properties || getUniqueId(executionId);
634
+ const correlationId = message.properties.correlationId || getUniqueId(executionId);
637
635
  this._debug(`delegate api ${routingKey} message to children, with correlationId <${correlationId}>`);
638
636
 
639
637
  let consumed = false;
@@ -644,7 +642,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
644
642
  }
645
643
  }, {consumerTag: `_ct-delegate-${correlationId}`, noAck: true});
646
644
 
647
- for (const child of this[elementsSymbol].children) {
645
+ for (const child of this[kElements].children) {
648
646
  if (child.placeholder) continue;
649
647
  child.broker.publish('api', routingKey, cloneContent(message.content), message.properties);
650
648
  if (consumed) break;
@@ -665,7 +663,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
665
663
  case 'discard':
666
664
  return this.discard(message);
667
665
  case 'stop':
668
- this[activityQSymbol].queueMessage({routingKey: 'execution.stop'}, cloneContent(message.content), {persistent: false});
666
+ this[kActivityQ].queueMessage({routingKey: 'execution.stop'}, cloneContent(message.content), {persistent: false});
669
667
  break;
670
668
  }
671
669
  };
@@ -673,12 +671,12 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
673
671
  proto._complete = function complete(completionType, content) {
674
672
  this._deactivate();
675
673
  this._debug(`process execution ${completionType}`);
676
- this[completedSymbol] = true;
677
- if (this.status !== 'terminated') this[statusSymbol] = completionType;
674
+ this[kCompleted] = true;
675
+ if (this.status !== 'terminated') this[kStatus] = completionType;
678
676
  const broker = this.broker;
679
- this[activityQSymbol].delete();
677
+ this[kActivityQ].delete();
680
678
 
681
- return broker.publish(this._exchangeName, `execution.${completionType}.${this.executionId}`, cloneContent(this[executeMessageSymbol].content, {
679
+ return broker.publish(this._exchangeName, `execution.${completionType}.${this.executionId}`, cloneContent(this[kExecuteMessage].content, {
682
680
  output: {...this.environment.output},
683
681
  ...content,
684
682
  state: completionType,
@@ -686,10 +684,10 @@ proto._complete = function complete(completionType, content) {
686
684
  };
687
685
 
688
686
  proto._terminate = function terminate(message) {
689
- this[statusSymbol] = 'terminated';
687
+ this[kStatus] = 'terminated';
690
688
  this._debug('terminating process execution');
691
689
 
692
- const running = this[elementsSymbol].postponed.splice(0);
690
+ const running = this[kElements].postponed.splice(0);
693
691
  for (const flow of this.getSequenceFlows()) flow.stop();
694
692
 
695
693
  for (const msg of running) {
@@ -700,19 +698,19 @@ proto._terminate = function terminate(message) {
700
698
  msg.ack();
701
699
  }
702
700
 
703
- this[activityQSymbol].purge();
701
+ this[kActivityQ].purge();
704
702
  };
705
703
 
706
704
  proto._getFlowById = function getFlowById(flowId) {
707
- return this[elementsSymbol].flows.find((f) => f.id === flowId);
705
+ return this[kElements].flows.find((f) => f.id === flowId);
708
706
  };
709
707
 
710
708
  proto._getAssociationById = function getAssociationById(associationId) {
711
- return this[elementsSymbol].associations.find((a) => a.id === associationId);
709
+ return this[kElements].associations.find((a) => a.id === associationId);
712
710
  };
713
711
 
714
712
  proto._getMessageFlowById = function getMessageFlowById(flowId) {
715
- return this[elementsSymbol].outboundMessageFlows.find((f) => f.id === flowId);
713
+ return this[kElements].outboundMessageFlows.find((f) => f.id === flowId);
716
714
  };
717
715
 
718
716
  proto._getChildById = function getChildById(childId) {
@@ -741,9 +739,9 @@ proto._getChildApi = function getChildApi(message) {
741
739
  proto._onShookEnd = function onShookEnd(message) {
742
740
  const routingKey = message.fields.routingKey;
743
741
  if (routingKey !== 'activity.shake.end') return;
744
- this[elementsSymbol].startSequences[message.content.id] = cloneMessage(message);
742
+ this[kElements].startSequences[message.content.id] = cloneMessage(message);
745
743
  };
746
744
 
747
745
  proto._debug = function debugMessage(logMessage) {
748
- this[parentSymbol].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
746
+ this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
749
747
  };
@@ -1,10 +1,10 @@
1
1
  import Activity from '../activity/Activity';
2
2
  import {cloneContent} from '../messageHelper';
3
3
 
4
- const completedSymbol = Symbol.for('completed');
5
- const executeMessageSymbol = Symbol.for('executeMessage');
6
- const referenceElementSymbol = Symbol.for('referenceElement');
7
- const referenceInfoSymbol = Symbol.for('referenceInfo');
4
+ const kCompleted = Symbol.for('completed');
5
+ const kExecuteMessage = Symbol.for('executeMessage');
6
+ const kReferenceElement = Symbol.for('referenceElement');
7
+ const kReferenceInfo = Symbol.for('referenceInfo');
8
8
 
9
9
  export default function ReceiveTask(activityDef, context) {
10
10
  const task = new Activity(ReceiveTaskBehaviour, activityDef, context);
@@ -31,7 +31,7 @@ export function ReceiveTaskBehaviour(activity) {
31
31
  this.activity = activity;
32
32
  this.broker = activity.broker;
33
33
 
34
- this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
34
+ this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
35
35
  }
36
36
 
37
37
  ReceiveTaskBehaviour.prototype.execute = function execute(executeMessage) {
@@ -46,21 +46,21 @@ function ReceiveTaskExecution(parent) {
46
46
  this.reference = reference;
47
47
  this.broker = broker;
48
48
  this.loopCharacteristics = loopCharacteristics;
49
- this.referenceElement = parent[referenceElementSymbol];
49
+ this.referenceElement = parent[kReferenceElement];
50
50
 
51
- this[completedSymbol] = false;
51
+ this[kCompleted] = false;
52
52
  }
53
53
 
54
54
  const proto = ReceiveTaskExecution.prototype;
55
55
 
56
56
  proto.execute = function execute(executeMessage) {
57
- this[executeMessageSymbol] = executeMessage;
57
+ this[kExecuteMessage] = executeMessage;
58
58
 
59
59
  const executeContent = executeMessage.content;
60
60
  const {executionId, isRootScope} = executeContent;
61
61
  this.executionId = executionId;
62
62
 
63
- const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
63
+ const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
64
64
 
65
65
  if (isRootScope) {
66
66
  this._setupMessageHandling(executionId);
@@ -77,7 +77,7 @@ proto.execute = function execute(executeMessage) {
77
77
  consumerTag: `_onmessage-${executionId}`,
78
78
  });
79
79
 
80
- if (this[completedSymbol]) return;
80
+ if (this[kCompleted]) return;
81
81
 
82
82
  broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
83
83
  noAck: true,
@@ -94,7 +94,7 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
94
94
  const content = message.content;
95
95
 
96
96
  const {id: signalId, executionId: signalExecutionId} = content.message || {};
97
- const {message: referenceMessage, description} = this[referenceInfoSymbol];
97
+ const {message: referenceMessage, description} = this[kReferenceInfo];
98
98
 
99
99
  if (!referenceMessage.id && signalId || signalExecutionId) {
100
100
  if (this.loopCharacteristics && signalExecutionId !== this.executionId) return;
@@ -107,7 +107,7 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
107
107
 
108
108
  const {type: messageType, correlationId} = message.properties;
109
109
  const broker = this.broker;
110
- const executeContent = this[executeMessageSymbol].content;
110
+ const executeContent = this[kExecuteMessage].content;
111
111
 
112
112
  broker.publish('event', 'activity.consumed', cloneContent(executeContent, {message: {...message.content.message}}), {correlationId, type: messageType});
113
113
  broker.publish('event', 'activity.catch', cloneContent(executeContent, {message: message.content.message}), {type: 'catch', correlationId});
@@ -123,9 +123,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
123
123
  return this._complete(message.content.message, {correlationId});
124
124
  }
125
125
  case 'discard': {
126
- this[completedSymbol] = true;
126
+ this[kCompleted] = true;
127
127
  this._stop();
128
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content), {correlationId});
128
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
129
129
  }
130
130
  case 'stop': {
131
131
  return this._stop();
@@ -134,9 +134,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
134
134
  };
135
135
 
136
136
  proto._complete = function complete(output, options) {
137
- this[completedSymbol] = true;
137
+ this[kCompleted] = true;
138
138
  this._stop();
139
- return this.broker.publish('execution', 'execute.completed', cloneContent(this[executeMessageSymbol].content, {output}), options);
139
+ return this.broker.publish('execution', 'execute.completed', cloneContent(this[kExecuteMessage].content, {output}), options);
140
140
  };
141
141
 
142
142
  proto._stop = function stop() {