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
@@ -2,11 +2,11 @@ import getPropertyValue from '../getPropertyValue';
2
2
  import {brokerSafeId} from '../shared';
3
3
  import {cloneContent, shiftParent} from '../messageHelper';
4
4
 
5
- const completedSymbol = Symbol.for('completed');
6
- const messageQSymbol = Symbol.for('messageQ');
7
- const executeMessageSymbol = Symbol.for('executeMessage');
8
- const referenceElementSymbol = Symbol.for('referenceElement');
9
- const referenceInfoSymbol = Symbol.for('referenceInfo');
5
+ const kCompleted = Symbol.for('completed');
6
+ const kMessageQ = Symbol.for('messageQ');
7
+ const kExecuteMessage = Symbol.for('executeMessage');
8
+ const kReferenceElement = Symbol.for('referenceElement');
9
+ const kReferenceInfo = Symbol.for('referenceInfo');
10
10
 
11
11
  export default function MessageEventDefinition(activity, eventDefinition) {
12
12
  const {id, broker, environment, isThrowing} = activity;
@@ -26,12 +26,12 @@ export default function MessageEventDefinition(activity, eventDefinition) {
26
26
  this.broker = broker;
27
27
  this.logger = environment.Logger(type.toLowerCase());
28
28
 
29
- const referenceElement = this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
29
+ const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
30
30
  if (!isThrowing) {
31
- this[completedSymbol] = false;
31
+ this[kCompleted] = false;
32
32
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
33
33
  const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(referenceId)}-q`;
34
- this[messageQSymbol] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
34
+ this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
35
35
  broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true});
36
36
  }
37
37
  }
@@ -40,7 +40,7 @@ const proto = MessageEventDefinition.prototype;
40
40
 
41
41
  Object.defineProperty(proto, 'executionId', {
42
42
  get() {
43
- const message = this[executeMessageSymbol];
43
+ const message = this[kExecuteMessage];
44
44
  return message && message.content.executionId;
45
45
  },
46
46
  });
@@ -50,24 +50,24 @@ proto.execute = function execute(executeMessage) {
50
50
  };
51
51
 
52
52
  proto.executeCatch = function executeCatch(executeMessage) {
53
- this[executeMessageSymbol] = executeMessage;
54
- this[completedSymbol] = false;
53
+ this[kExecuteMessage] = executeMessage;
54
+ this[kCompleted] = false;
55
55
 
56
56
  const executeContent = executeMessage.content;
57
57
  const {executionId, parent} = executeContent;
58
58
  const parentExecutionId = parent && parent.executionId;
59
59
 
60
- const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
60
+ const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
61
61
  this._debug(`expect ${info.description}`);
62
62
 
63
63
  const broker = this.broker;
64
64
  const onCatchMessage = this._onCatchMessage.bind(this);
65
- this[messageQSymbol].consume(onCatchMessage, {
65
+ this[kMessageQ].consume(onCatchMessage, {
66
66
  noAck: true,
67
67
  consumerTag: `_api-message-${executionId}`,
68
68
  });
69
69
 
70
- if (this[completedSymbol]) return;
70
+ if (this[kCompleted]) return;
71
71
 
72
72
  const onApiMessage = this._onApiMessage.bind(this);
73
73
  broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
@@ -115,10 +115,10 @@ proto.executeThrow = function executeThrow(executeMessage) {
115
115
  };
116
116
 
117
117
  proto._onCatchMessage = function onCatchMessage(routingKey, message) {
118
- if (getPropertyValue(message, 'content.message.id') !== this[referenceInfoSymbol].message.id) return;
118
+ if (getPropertyValue(message, 'content.message.id') !== this[kReferenceInfo].message.id) return;
119
119
 
120
120
  const {type, correlationId} = message.properties;
121
- this.broker.publish('event', 'activity.consumed', cloneContent(this[executeMessageSymbol].content, {
121
+ this.broker.publish('event', 'activity.consumed', cloneContent(this[kExecuteMessage].content, {
122
122
  message: {...message.content.message},
123
123
  }), {
124
124
  correlationId,
@@ -136,9 +136,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
136
136
  return this._complete('got signal with', message.content.message, {correlationId});
137
137
  }
138
138
  case 'discard': {
139
- this[completedSymbol] = true;
139
+ this[kCompleted] = true;
140
140
  this._stop();
141
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content), {correlationId});
141
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
142
142
  }
143
143
  case 'stop': {
144
144
  return this._stop();
@@ -147,13 +147,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
147
147
  };
148
148
 
149
149
  proto._complete = function complete(verb, output, options) {
150
- this[completedSymbol] = true;
150
+ this[kCompleted] = true;
151
151
 
152
152
  this._stop();
153
- this._debug(`${verb} ${this[referenceInfoSymbol].description}`);
153
+ this._debug(`${verb} ${this[kReferenceInfo].description}`);
154
154
 
155
155
  const broker = this.broker;
156
- const executeContent = this[executeMessageSymbol].content;
156
+ const executeContent = this[kExecuteMessage].content;
157
157
  const catchContent = cloneContent(executeContent, {
158
158
  message: {...output},
159
159
  executionId: executeContent.parent.executionId,
@@ -174,11 +174,11 @@ proto._stop = function stop() {
174
174
  broker.cancel(`_api-${executionId}`);
175
175
  broker.cancel(`_api-parent-${executionId}`);
176
176
  broker.cancel(`_api-delegated-${executionId}`);
177
- this[messageQSymbol].purge();
177
+ this[kMessageQ].purge();
178
178
  };
179
179
 
180
180
  proto._getReferenceInfo = function getReferenceInfo(message) {
181
- const referenceElement = this[referenceElementSymbol];
181
+ const referenceElement = this[kReferenceElement];
182
182
  if (!referenceElement) {
183
183
  return {
184
184
  message: {...this.reference},
@@ -2,11 +2,11 @@ import getPropertyValue from '../getPropertyValue';
2
2
  import {brokerSafeId} from '../shared';
3
3
  import {cloneContent, shiftParent} from '../messageHelper';
4
4
 
5
- const completedSymbol = Symbol.for('completed');
6
- const messageQSymbol = Symbol.for('messageQ');
7
- const executeMessageSymbol = Symbol.for('executeMessage');
8
- const referenceElementSymbol = Symbol.for('referenceElement');
9
- const referenceInfoSymbol = Symbol.for('referenceInfo');
5
+ const kCompleted = Symbol.for('completed');
6
+ const kMessageQ = Symbol.for('messageQ');
7
+ const kExecuteMessage = Symbol.for('executeMessage');
8
+ const kReferenceElement = Symbol.for('referenceElement');
9
+ const kReferenceInfo = Symbol.for('referenceInfo');
10
10
 
11
11
  export default function SignalEventDefinition(activity, eventDefinition) {
12
12
  const {id, broker, environment, isStart, isThrowing} = activity;
@@ -26,12 +26,12 @@ export default function SignalEventDefinition(activity, eventDefinition) {
26
26
  this.broker = broker;
27
27
  this.logger = environment.Logger(type.toLowerCase());
28
28
 
29
- const referenceElement = this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
29
+ const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
30
30
  if (!isThrowing && isStart) {
31
- this[completedSymbol] = false;
31
+ this[kCompleted] = false;
32
32
  const referenceId = referenceElement ? referenceElement.id : 'anonymous';
33
33
  const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(referenceId)}-q`;
34
- this[messageQSymbol] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
34
+ this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
35
35
  broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true});
36
36
  }
37
37
  }
@@ -40,7 +40,7 @@ const proto = SignalEventDefinition.prototype;
40
40
 
41
41
  Object.defineProperty(proto, 'executionId', {
42
42
  get() {
43
- const message = this[executeMessageSymbol];
43
+ const message = this[kExecuteMessage];
44
44
  return message && message.content.executionId;
45
45
  },
46
46
  });
@@ -50,23 +50,23 @@ proto.execute = function execute(executeMessage) {
50
50
  };
51
51
 
52
52
  proto.executeCatch = function executeCatch(executeMessage) {
53
- this[executeMessageSymbol] = executeMessage;
54
- this[completedSymbol] = false;
53
+ this[kExecuteMessage] = executeMessage;
54
+ this[kCompleted] = false;
55
55
 
56
56
  const executeContent = executeMessage.content;
57
57
  const {executionId, parent} = executeContent;
58
58
  const parentExecutionId = parent && parent.executionId;
59
59
 
60
- const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
60
+ const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
61
61
  const broker = this.broker;
62
62
 
63
63
  const onCatchMessage = this._onCatchMessage.bind(this);
64
64
  if (this.activity.isStart) {
65
- this[messageQSymbol].consume(onCatchMessage, {
65
+ this[kMessageQ].consume(onCatchMessage, {
66
66
  noAck: true,
67
67
  consumerTag: `_api-signal-${executionId}`,
68
68
  });
69
- if (this[completedSymbol]) return;
69
+ if (this[kCompleted]) return;
70
70
  }
71
71
 
72
72
  const onApiMessage = this._onApiMessage.bind(this);
@@ -116,13 +116,13 @@ proto.executeThrow = function executeThrow(executeMessage) {
116
116
  };
117
117
 
118
118
  proto._onCatchMessage = function onCatchMessage(routingKey, message) {
119
- const info = this[referenceInfoSymbol];
119
+ const info = this[kReferenceInfo];
120
120
  if (getPropertyValue(message, 'content.message.id') !== info.message.id) return;
121
- this[completedSymbol] = true;
121
+ this[kCompleted] = true;
122
122
  this._stop();
123
123
 
124
124
  const {type, correlationId} = message.properties;
125
- this.broker.publish('event', 'activity.consumed', cloneContent(this[executeMessageSymbol].content, {
125
+ this.broker.publish('event', 'activity.consumed', cloneContent(this[kExecuteMessage].content, {
126
126
  message: { ...message.content.message},
127
127
  }), {
128
128
  correlationId,
@@ -140,9 +140,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
140
140
  return this._complete(message.content.message, {correlationId});
141
141
  }
142
142
  case 'discard': {
143
- this[completedSymbol] = true;
143
+ this[kCompleted] = true;
144
144
  this._stop();
145
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content), {correlationId});
145
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
146
146
  }
147
147
  case 'stop': {
148
148
  this._stop();
@@ -152,10 +152,10 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
152
152
  };
153
153
 
154
154
  proto._complete = function complete(output, options) {
155
- this[completedSymbol] = true;
155
+ this[kCompleted] = true;
156
156
  this._stop();
157
- this._debug(`signaled with ${this[referenceInfoSymbol].description}`);
158
- return this.broker.publish('execution', 'execute.completed', cloneContent(this[executeMessageSymbol].content, {
157
+ this._debug(`signaled with ${this[kReferenceInfo].description}`);
158
+ return this.broker.publish('execution', 'execute.completed', cloneContent(this[kExecuteMessage].content, {
159
159
  output,
160
160
  state: 'signal',
161
161
  }), options);
@@ -167,11 +167,11 @@ proto._stop = function stop() {
167
167
  broker.cancel(`_api-parent-${executionId}`);
168
168
  broker.cancel(`_api-${executionId}`);
169
169
  broker.cancel(`_api-delegated-${executionId}`);
170
- if (this.activity.isStart) this[messageQSymbol].purge();
170
+ if (this.activity.isStart) this[kMessageQ].purge();
171
171
  };
172
172
 
173
173
  proto._getReferenceInfo = function getReferenceInfo(message) {
174
- const referenceElement = this[referenceElementSymbol];
174
+ const referenceElement = this[kReferenceElement];
175
175
  if (!referenceElement) {
176
176
  return {
177
177
  message: {...this.reference},
@@ -1,9 +1,9 @@
1
1
  import {cloneContent} from '../messageHelper';
2
2
  import {toSeconds, parse} from 'iso8601-duration';
3
3
 
4
- const stoppedSymbol = Symbol.for('stopped');
5
- const timerContentSymbol = Symbol.for('timerContent');
6
- const timerSymbol = Symbol.for('timer');
4
+ const kStopped = Symbol.for('stopped');
5
+ const kTimerContent = Symbol.for('timerContent');
6
+ const kTimer = Symbol.for('timer');
7
7
 
8
8
  export default function TimerEventDefinition(activity, eventDefinition) {
9
9
  const type = this.type = eventDefinition.type || 'TimerEventDefinition';
@@ -19,15 +19,15 @@ export default function TimerEventDefinition(activity, eventDefinition) {
19
19
  this.broker = activity.broker;
20
20
  this.logger = environment.Logger(type.toLowerCase());
21
21
 
22
- this[stoppedSymbol] = false;
23
- this[timerSymbol] = null;
22
+ this[kStopped] = false;
23
+ this[kTimer] = null;
24
24
  }
25
25
 
26
26
  const proto = TimerEventDefinition.prototype;
27
27
 
28
28
  Object.defineProperty(proto, 'executionId', {
29
29
  get() {
30
- const content = this[timerContentSymbol];
30
+ const content = this[kTimerContent];
31
31
  return content && content.executionId;
32
32
  },
33
33
  });
@@ -35,33 +35,33 @@ Object.defineProperty(proto, 'executionId', {
35
35
  Object.defineProperty(proto, 'stopped', {
36
36
  enumerable: true,
37
37
  get() {
38
- return this[stoppedSymbol];
38
+ return this[kStopped];
39
39
  },
40
40
  });
41
41
 
42
42
  Object.defineProperty(proto, 'timer', {
43
43
  enumerable: true,
44
44
  get() {
45
- return this[timerSymbol];
45
+ return this[kTimer];
46
46
  },
47
47
  });
48
48
 
49
49
  proto.execute = function execute(executeMessage) {
50
50
  const {routingKey: executeKey, redelivered: isResumed} = executeMessage.fields;
51
- const timer = this[timerSymbol];
51
+ const timer = this[kTimer];
52
52
  if (timer && executeKey === 'execute.timer') {
53
53
  return;
54
54
  }
55
55
 
56
- if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
57
- this[stoppedSymbol] = false;
56
+ if (timer) this[kTimer] = this.environment.timers.clearTimeout(timer);
57
+ this[kStopped] = false;
58
58
 
59
59
  const content = executeMessage.content;
60
60
  const executionId = content.executionId;
61
61
  const startedAt = this.startedAt = 'startedAt' in content ? new Date(content.startedAt) : new Date();
62
62
 
63
63
  const resolvedTimer = this._getTimers(executeMessage);
64
- const timerContent = this[timerContentSymbol] = cloneContent(content, {
64
+ const timerContent = this[kTimerContent] = cloneContent(content, {
65
65
  ...resolvedTimer,
66
66
  ...(isResumed ? {isResumed} : undefined),
67
67
  startedAt,
@@ -86,7 +86,7 @@ proto.execute = function execute(executeMessage) {
86
86
  if (timerContent.timeout <= 0) return this._completed();
87
87
 
88
88
  const timers = this.environment.timers.register(timerContent);
89
- this[timerSymbol] = timers.setTimeout(this._completed.bind(this), timerContent.timeout, {
89
+ this[kTimer] = timers.setTimeout(this._completed.bind(this), timerContent.timeout, {
90
90
  id: content.id,
91
91
  type: this.type,
92
92
  executionId,
@@ -95,8 +95,8 @@ proto.execute = function execute(executeMessage) {
95
95
  };
96
96
 
97
97
  proto.stop = function stopTimer() {
98
- const timer = this[timerSymbol];
99
- if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
98
+ const timer = this[kTimer];
99
+ if (timer) this[kTimer] = this.environment.timers.clearTimeout(timer);
100
100
  };
101
101
 
102
102
  proto._completed = function completed(completeContent, options) {
@@ -107,7 +107,7 @@ proto._completed = function completed(completeContent, options) {
107
107
  const runningTime = stoppedAt.getTime() - this.startedAt.getTime();
108
108
  this._debug(`completed in ${runningTime}ms`);
109
109
 
110
- const timerContent = this[timerContentSymbol];
110
+ const timerContent = this[kTimerContent];
111
111
  const content = {stoppedAt, runningTime, state: 'timeout', ...completeContent};
112
112
 
113
113
  const broker = this.broker;
@@ -129,7 +129,7 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, messag
129
129
  if (signalExecutionId && signalId === id && signalExecutionId !== executionId) return;
130
130
 
131
131
  const {type, correlationId} = message.properties;
132
- this.broker.publish('event', 'activity.consumed', cloneContent(this[timerContentSymbol], {
132
+ this.broker.publish('event', 'activity.consumed', cloneContent(this[kTimerContent], {
133
133
  message: {
134
134
  ...content.message,
135
135
  },
@@ -156,15 +156,15 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
156
156
  case 'discard': {
157
157
  this._stop();
158
158
  this._debug('discarded');
159
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[timerContentSymbol], {state: 'discard'}), {correlationId});
159
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kTimerContent], {state: 'discard'}), {correlationId});
160
160
  }
161
161
  }
162
162
  };
163
163
 
164
164
  proto._stop = function stop() {
165
- this[stoppedSymbol] = true;
166
- const timer = this[timerSymbol];
167
- if (timer) this[timerSymbol] = this.environment.timers.clearTimeout(timer);
165
+ this[kStopped] = true;
166
+ const timer = this[kTimer];
167
+ if (timer) this[kTimer] = this.environment.timers.clearTimeout(timer);
168
168
  const broker = this.broker;
169
169
  broker.cancel(`_api-${this.executionId}`);
170
170
  broker.cancel(`_api-delegated-${this.executionId}`);
@@ -3,11 +3,11 @@ import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecuti
3
3
  import {cloneContent, cloneMessage} from '../messageHelper';
4
4
  import {brokerSafeId} from '../shared';
5
5
 
6
- const attachedTagsSymbol = Symbol.for('attachedConsumers');
7
- const completeContentSymbol = Symbol.for('completeContent');
8
- const executeMessageSymbol = Symbol.for('executeMessage');
9
- const executionSymbol = Symbol.for('execution');
10
- const shovelsSymbol = Symbol.for('shovels');
6
+ const kAttachedTags = Symbol.for('attachedConsumers');
7
+ const kCompleteContent = Symbol.for('completeContent');
8
+ const kExecuteMessage = Symbol.for('executeMessage');
9
+ const kExecution = Symbol.for('execution');
10
+ const kShovels = Symbol.for('shovels');
11
11
 
12
12
  export default function BoundaryEvent(activityDef, context) {
13
13
  return new Activity(BoundaryEventBehaviour, activityDef, context);
@@ -20,16 +20,16 @@ export function BoundaryEventBehaviour(activity) {
20
20
  this.activity = activity;
21
21
  this.environment = activity.environment;
22
22
  this.broker = activity.broker;
23
- this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions, 'execute.bound.completed');
24
- this[shovelsSymbol] = [];
25
- this[attachedTagsSymbol] = [];
23
+ this[kExecution] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions, 'execute.bound.completed');
24
+ this[kShovels] = [];
25
+ this[kAttachedTags] = [];
26
26
  }
27
27
 
28
28
  const proto = BoundaryEventBehaviour.prototype;
29
29
 
30
30
  Object.defineProperty(proto, 'executionId', {
31
31
  get() {
32
- const message = this[executeMessageSymbol];
32
+ const message = this[kExecuteMessage];
33
33
  return message && message.content.executionId;
34
34
  },
35
35
  });
@@ -45,9 +45,9 @@ Object.defineProperty(proto, 'cancelActivity', {
45
45
  proto.execute = function execute(executeMessage) {
46
46
  const {isRootScope, executionId} = executeMessage.content;
47
47
 
48
- const eventDefinitionExecution = this[executionSymbol];
48
+ const eventDefinitionExecution = this[kExecution];
49
49
  if (isRootScope) {
50
- this[executeMessageSymbol] = executeMessage;
50
+ this[kExecuteMessage] = executeMessage;
51
51
 
52
52
  const broker = this.broker;
53
53
  if (eventDefinitionExecution && !this.environment.settings.strict) {
@@ -63,7 +63,7 @@ proto.execute = function execute(executeMessage) {
63
63
  consumerTag,
64
64
  priority: 300,
65
65
  });
66
- this[attachedTagsSymbol].push(consumerTag);
66
+ this[kAttachedTags].push(consumerTag);
67
67
 
68
68
  broker.subscribeOnce('execution', 'execute.detach', this._onDetachMessage.bind(this), {
69
69
  consumerTag: '_detach-tag',
@@ -87,9 +87,9 @@ proto._onCompleted = function onCompleted(_, {content}) {
87
87
  return this.broker.publish('execution', 'execute.completed', cloneContent(content));
88
88
  }
89
89
 
90
- this[completeContentSymbol] = content;
90
+ this[kCompleteContent] = content;
91
91
 
92
- const {inbound} = this[executeMessageSymbol].content;
92
+ const {inbound} = this[kExecuteMessage].content;
93
93
  const attachedToContent = inbound && inbound[0];
94
94
  const attachedTo = this.attachedTo;
95
95
  this.activity.logger.debug(`<${this.executionId} (${this.id})> cancel ${attachedTo.status} activity <${attachedToContent.executionId} (${attachedToContent.id})>`);
@@ -100,8 +100,8 @@ proto._onCompleted = function onCompleted(_, {content}) {
100
100
  proto._onAttachedLeave = function onAttachedLeave(_, {content}) {
101
101
  if (content.id !== this.attachedTo.id) return;
102
102
  this._stop();
103
- const completeContent = this[completeContentSymbol];
104
- if (!completeContent) return this.broker.publish('execution', 'execute.discard', this[executeMessageSymbol].content);
103
+ const completeContent = this[kCompleteContent];
104
+ if (!completeContent) return this.broker.publish('execution', 'execute.discard', this[kExecuteMessage].content);
105
105
  return this.broker.publish('execution', 'execute.completed', cloneContent(completeContent));
106
106
  };
107
107
 
@@ -110,7 +110,7 @@ proto._onExpectMessage = function onExpectMessage(_, {content}) {
110
110
  const attachedTo = this.attachedTo;
111
111
 
112
112
  const errorConsumerTag = `_bound-error-listener-${executionId}`;
113
- this[attachedTagsSymbol].push(errorConsumerTag);
113
+ this[kAttachedTags].push(errorConsumerTag);
114
114
 
115
115
  attachedTo.broker.subscribeTmp('event', 'activity.error', (__, errorMessage) => {
116
116
  if (errorMessage.content.id !== attachedTo.id) return;
@@ -130,7 +130,7 @@ proto._onDetachMessage = function onDetachMessage(_, {content}) {
130
130
  const {executionId: detachId, bindExchange, sourceExchange, sourcePattern} = content;
131
131
 
132
132
  const shovelName = `_detached-${brokerSafeId(id)}_${detachId}`;
133
- this[shovelsSymbol].push(shovelName);
133
+ this[kShovels].push(shovelName);
134
134
 
135
135
  const broker = this.broker;
136
136
  attachedTo.broker.createShovel(shovelName, {
@@ -162,8 +162,8 @@ proto._onApiMessage = function onApiMessage(_, message) {
162
162
 
163
163
  proto._stop = function stop(detach) {
164
164
  const attachedTo = this.attachedTo, broker = this.broker, executionId = this.executionId;
165
- for (const tag of this[attachedTagsSymbol].splice(0)) attachedTo.broker.cancel(tag);
166
- for (const shovelName of this[shovelsSymbol].splice(0)) attachedTo.broker.closeShovel(shovelName);
165
+ for (const tag of this[kAttachedTags].splice(0)) attachedTo.broker.cancel(tag);
166
+ for (const shovelName of this[kShovels].splice(0)) attachedTo.broker.closeShovel(shovelName);
167
167
 
168
168
  broker.cancel('_expect-tag');
169
169
  broker.cancel('_detach-tag');
@@ -2,7 +2,7 @@ import Activity from '../activity/Activity';
2
2
  import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
3
3
  import {cloneContent} from '../messageHelper';
4
4
 
5
- const executionSymbol = Symbol.for('execution');
5
+ const kExecution = Symbol.for('execution');
6
6
 
7
7
  export default function EndEvent(activityDef, context) {
8
8
  return new Activity(EndEventBehaviour, {...activityDef, isThrowing: true}, context);
@@ -12,11 +12,11 @@ export function EndEventBehaviour(activity) {
12
12
  this.id = activity.id;
13
13
  this.type = activity.type;
14
14
  this.broker = activity.broker;
15
- this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
15
+ this[kExecution] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
16
16
  }
17
17
 
18
18
  EndEventBehaviour.prototype.execute = function execute(executeMessage) {
19
- const execution = this[executionSymbol];
19
+ const execution = this[kExecution];
20
20
  if (execution) {
21
21
  return execution.execute(executeMessage);
22
22
  }
@@ -2,7 +2,7 @@ import Activity from '../activity/Activity';
2
2
  import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
3
3
  import {cloneContent} from '../messageHelper';
4
4
 
5
- const executionSymbol = Symbol.for('execution');
5
+ const kExecution = Symbol.for('execution');
6
6
 
7
7
  export default function IntermediateCatchEvent(activityDef, context) {
8
8
  return new Activity(IntermediateCatchEventBehaviour, activityDef, context);
@@ -12,11 +12,11 @@ export function IntermediateCatchEventBehaviour(activity) {
12
12
  this.id = activity.id;
13
13
  this.type = activity.type;
14
14
  this.broker = activity.broker;
15
- this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
15
+ this[kExecution] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
16
16
  }
17
17
 
18
18
  IntermediateCatchEventBehaviour.prototype.execute = function execute(executeMessage) {
19
- const execution = this[executionSymbol];
19
+ const execution = this[kExecution];
20
20
  if (execution) {
21
21
  return execution.execute(executeMessage);
22
22
  }
@@ -2,7 +2,7 @@ import Activity from '../activity/Activity';
2
2
  import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
3
3
  import {cloneContent} from '../messageHelper';
4
4
 
5
- const executionSymbol = Symbol.for('execution');
5
+ const kExecution = Symbol.for('execution');
6
6
 
7
7
  export default function IntermediateThrowEvent(activityDef, context) {
8
8
  return new Activity(IntermediateThrowEventBehaviour, {...activityDef, isThrowing: true}, context);
@@ -12,11 +12,11 @@ export function IntermediateThrowEventBehaviour(activity) {
12
12
  this.id = activity.id;
13
13
  this.type = activity.type;
14
14
  this.broker = activity.broker;
15
- this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
15
+ this[kExecution] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
16
16
  }
17
17
 
18
18
  IntermediateThrowEventBehaviour.prototype.execute = function execute(executeMessage) {
19
- const execution = this[executionSymbol];
19
+ const execution = this[kExecution];
20
20
  if (execution) {
21
21
  return execution.execute(executeMessage);
22
22
  }
@@ -2,8 +2,8 @@ import Activity from '../activity/Activity';
2
2
  import EventDefinitionExecution from '../eventDefinitions/EventDefinitionExecution';
3
3
  import {cloneContent} from '../messageHelper';
4
4
 
5
- const executeMessageSymbol = Symbol.for('executeMessage');
6
- const executionSymbol = Symbol.for('execution');
5
+ const kExecuteMessage = Symbol.for('executeMessage');
6
+ const kExecution = Symbol.for('execution');
7
7
 
8
8
  export default function StartEvent(activityDef, context) {
9
9
  return new Activity(StartEventBehaviour, activityDef, context);
@@ -14,20 +14,20 @@ export function StartEventBehaviour(activity) {
14
14
  this.type = activity.type;
15
15
  this.activity = activity;
16
16
  this.broker = activity.broker;
17
- this[executionSymbol] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
17
+ this[kExecution] = activity.eventDefinitions && new EventDefinitionExecution(activity, activity.eventDefinitions);
18
18
  }
19
19
 
20
20
  const proto = StartEventBehaviour.prototype;
21
21
 
22
22
  Object.defineProperty(proto, 'executionId', {
23
23
  get() {
24
- const message = this[executeMessageSymbol];
24
+ const message = this[kExecuteMessage];
25
25
  return message && message.content.executionId;
26
26
  },
27
27
  });
28
28
 
29
29
  proto.execute = function execute(executeMessage) {
30
- const execution = this[executionSymbol];
30
+ const execution = this[kExecution];
31
31
  if (execution) {
32
32
  return execution.execute(executeMessage);
33
33
  }
@@ -39,7 +39,7 @@ proto.execute = function execute(executeMessage) {
39
39
  }
40
40
 
41
41
  const executionId = content.executionId;
42
- this[executeMessageSymbol] = executeMessage;
42
+ this[kExecuteMessage] = executeMessage;
43
43
  broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => this._onApiMessage(...args), {
44
44
  noAck: true,
45
45
  consumerTag: `_api-${executionId}`,
@@ -59,7 +59,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
59
59
  return this._stop();
60
60
  case 'signal': {
61
61
  this._stop();
62
- const content = this[executeMessageSymbol].content;
62
+ const content = this[kExecuteMessage].content;
63
63
  return this.broker.publish('execution', 'execute.completed', cloneContent(content, {
64
64
  output: message.content.message,
65
65
  state: 'signal',
@@ -67,7 +67,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
67
67
  }
68
68
  case 'discard': {
69
69
  this._stop();
70
- const content = this[executeMessageSymbol].content;
70
+ const content = this[kExecuteMessage].content;
71
71
  return this.broker.publish('execution', 'execute.discard', cloneContent(content), {correlationId});
72
72
  }
73
73
  }
@@ -83,7 +83,7 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(routingKey, messag
83
83
  if (signalId !== this.id && signalExecutionId !== this.executionId) return;
84
84
 
85
85
  const {type, correlationId} = message.properties;
86
- const executeContent = this[executeMessageSymbol].content;
86
+ const executeContent = this[kExecuteMessage].content;
87
87
  this.broker.publish('event', 'activity.consumed', cloneContent(executeContent, {
88
88
  message: {
89
89
  ...content.message,