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
@@ -1,11 +1,11 @@
1
1
  import {brokerSafeId} from '../shared';
2
2
  import {cloneContent, cloneMessage, shiftParent} from '../messageHelper';
3
3
 
4
- const completedSymbol = Symbol.for('completed');
5
- const executeMessageSymbol = Symbol.for('executeMessage');
6
- const messageQSymbol = Symbol.for('messageQ');
7
- const compensateQSymbol = Symbol.for('compensateQ');
8
- const associationsSymbol = Symbol.for('associations');
4
+ const kCompleted = Symbol.for('completed');
5
+ const kExecuteMessage = Symbol.for('executeMessage');
6
+ const kMessageQ = Symbol.for('messageQ');
7
+ const kCompensateQ = Symbol.for('compensateQ');
8
+ const kAssociations = Symbol.for('associations');
9
9
 
10
10
  export default function CompensateEventDefinition(activity, eventDefinition, context) {
11
11
  const {id, broker, environment, isThrowing} = activity;
@@ -19,10 +19,10 @@ export default function CompensateEventDefinition(activity, eventDefinition, con
19
19
  this.logger = environment.Logger(type.toLowerCase());
20
20
 
21
21
  if (!isThrowing) {
22
- this[completedSymbol] = false;
23
- this[associationsSymbol] = context.getOutboundAssociations(id) || [];
22
+ this[kCompleted] = false;
23
+ this[kAssociations] = context.getOutboundAssociations(id) || [];
24
24
  const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-q`;
25
- this[messageQSymbol] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
25
+ this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
26
26
  broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true, priority: 400});
27
27
  }
28
28
  }
@@ -31,7 +31,7 @@ const proto = CompensateEventDefinition.prototype;
31
31
 
32
32
  Object.defineProperty(proto, 'executionId', {
33
33
  get() {
34
- const message = this[executeMessageSymbol];
34
+ const message = this[kExecuteMessage];
35
35
  return message && message.content.executionId;
36
36
  },
37
37
  });
@@ -41,8 +41,8 @@ proto.execute = function execute(executeMessage) {
41
41
  };
42
42
 
43
43
  proto.executeCatch = function executeCatch(executeMessage) {
44
- this[executeMessageSymbol] = executeMessage;
45
- this[completedSymbol] = false;
44
+ this[kExecuteMessage] = executeMessage;
45
+ this[kCompleted] = false;
46
46
 
47
47
  const executeContent = executeMessage.content;
48
48
  const {executionId, parent} = executeContent;
@@ -51,7 +51,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
51
51
 
52
52
  const broker = this.broker;
53
53
  broker.assertExchange('compensate', 'topic');
54
- this[compensateQSymbol] = broker.assertQueue('compensate-q', {durable: true, autoDelete: false});
54
+ this[kCompensateQ] = broker.assertQueue('compensate-q', {durable: true, autoDelete: false});
55
55
  broker.subscribeTmp('compensate', 'execute.#', this._onCollect.bind(this), {
56
56
  noAck: true,
57
57
  consumerTag: '_oncollect-messages',
@@ -62,12 +62,12 @@ proto.executeCatch = function executeCatch(executeMessage) {
62
62
  bindExchange: 'compensate',
63
63
  }));
64
64
 
65
- this[messageQSymbol].consume(this._onCompensateApiMessage.bind(this), {
65
+ this[kMessageQ].consume(this._onCompensateApiMessage.bind(this), {
66
66
  noAck: true,
67
67
  consumerTag: `_oncompensate-${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, {
@@ -103,23 +103,24 @@ proto.executeThrow = function executeThrow(executeMessage) {
103
103
  };
104
104
 
105
105
  proto._onCollect = function onCollect(routingKey, message) {
106
+
106
107
  switch (routingKey) {
107
108
  case 'execute.error':
108
109
  case 'execute.completed': {
109
- return this[compensateQSymbol].queueMessage(message.fields, cloneContent(message.content), message.properties);
110
+ return this[kCompensateQ].queueMessage(message.fields, cloneContent(message.content), message.properties);
110
111
  }
111
112
  }
112
113
  };
113
114
 
114
115
  proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
115
116
  const output = message.content.message;
116
- this[completedSymbol] = true;
117
+ this[kCompleted] = true;
117
118
 
118
119
  this._stop();
119
120
 
120
121
  this._debug('caught compensate event');
121
122
  const broker = this.broker;
122
- const executeContent = this[executeMessageSymbol].content;
123
+ const executeContent = this[kExecuteMessage].content;
123
124
  const catchContent = cloneContent(executeContent, {
124
125
  message: {...output},
125
126
  executionId: executeContent.parent.executionId,
@@ -128,11 +129,11 @@ proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, mess
128
129
 
129
130
  broker.publish('event', 'activity.catch', catchContent, {type: 'catch'});
130
131
 
131
- const compensateQ = this[compensateQSymbol];
132
+ const compensateQ = this[kCompensateQ];
132
133
  compensateQ.on('depleted', onDepleted);
133
134
  compensateQ.consume(this._onCollected.bind(this), {noAck: true, consumerTag: '_convey-messages'});
134
135
 
135
- for (const association of this[associationsSymbol]) association.complete(cloneMessage(message));
136
+ for (const association of this[kAssociations]) association.complete(cloneMessage(message));
136
137
 
137
138
  function onDepleted() {
138
139
  compensateQ.off('depleted', onDepleted);
@@ -141,7 +142,7 @@ proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, mess
141
142
  };
142
143
 
143
144
  proto._onCollected = function onCollected(routingKey, message) {
144
- for (const association of this[associationsSymbol]) association.take(cloneMessage(message));
145
+ for (const association of this[kAssociations]) association.take(cloneMessage(message));
145
146
  };
146
147
 
147
148
  proto._onApiMessage = function onApiMessage(routingKey, message) {
@@ -152,10 +153,10 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
152
153
  return this._onCompensateApiMessage(routingKey, message);
153
154
  }
154
155
  case 'discard': {
155
- this[completedSymbol] = true;
156
+ this[kCompleted] = true;
156
157
  this._stop();
157
- for (const association of this[associationsSymbol]) association.discard(cloneMessage(message));
158
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content));
158
+ for (const association of this[kAssociations]) association.discard(cloneMessage(message));
159
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content));
159
160
  }
160
161
  case 'stop': {
161
162
  this._stop();
@@ -170,7 +171,7 @@ proto._stop = function stop() {
170
171
  broker.cancel(`_oncompensate-${executionId}`);
171
172
  broker.cancel('_oncollect-messages');
172
173
  broker.cancel('_convey-messages');
173
- this[messageQSymbol].purge();
174
+ this[kMessageQ].purge();
174
175
  };
175
176
 
176
177
  proto._debug = function debug(msg) {
@@ -1,7 +1,7 @@
1
1
  import {cloneContent, shiftParent} from '../messageHelper';
2
2
  import {ActivityError} from '../error/Errors';
3
3
 
4
- const executeMessageSymbol = Symbol.for('executeMessage');
4
+ const kExecuteMessage = Symbol.for('executeMessage');
5
5
 
6
6
  export default function ConditionalEventDefinition(activity, eventDefinition) {
7
7
  const {id, broker, environment, attachedTo} = activity;
@@ -22,13 +22,13 @@ const proto = ConditionalEventDefinition.prototype;
22
22
 
23
23
  Object.defineProperty(proto, 'executionId', {
24
24
  get() {
25
- const message = this[executeMessageSymbol];
25
+ const message = this[kExecuteMessage];
26
26
  return message && message.content.executionId;
27
27
  },
28
28
  });
29
29
 
30
30
  proto.execute = function execute(executeMessage) {
31
- this[executeMessageSymbol] = executeMessage;
31
+ this[kExecuteMessage] = executeMessage;
32
32
  return this.isWaiting ? this.executeWait(executeMessage) : this.executeCatch(executeMessage);
33
33
  };
34
34
 
@@ -87,7 +87,7 @@ proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
87
87
  }
88
88
  case 'discard': {
89
89
  this._stopWait();
90
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content, {state: 'discard'}));
90
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content, {state: 'discard'}));
91
91
  }
92
92
  case 'stop': {
93
93
  return this._stopWait();
@@ -96,7 +96,7 @@ proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
96
96
  };
97
97
 
98
98
  proto._evaluateWait = function evaluate(message) {
99
- const executeMessage = this[executeMessageSymbol];
99
+ const executeMessage = this[kExecuteMessage];
100
100
  const broker = this.broker, executeContent = executeMessage.content;
101
101
 
102
102
  try {
@@ -125,7 +125,7 @@ proto._stopWait = function stopWait() {
125
125
  proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
126
126
  this._stopCatch();
127
127
 
128
- const executeMessage = this[executeMessageSymbol];
128
+ const executeMessage = this[kExecuteMessage];
129
129
  const broker = this.broker, executeContent = executeMessage.content;
130
130
  try {
131
131
  var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
@@ -150,7 +150,7 @@ proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
150
150
  case 'discard': {
151
151
  this._stopCatch();
152
152
  this._debug('discarded');
153
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content, {state: 'discard'}));
153
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content, {state: 'discard'}));
154
154
  }
155
155
  case 'stop': {
156
156
  this._stopCatch();
@@ -160,7 +160,7 @@ proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
160
160
  };
161
161
 
162
162
  proto._stopCatch = function stopCatch() {
163
- const {executionId, index} = this[executeMessageSymbol].content;
163
+ const {executionId, index} = this[kExecuteMessage].content;
164
164
  this.activity.attachedTo.broker.cancel(`_onend-${executionId}_${index}`);
165
165
  this.broker.cancel(`_api-${executionId}_${index}`);
166
166
  };
@@ -1,11 +1,11 @@
1
1
  import {brokerSafeId} from '../shared';
2
2
  import {cloneContent, shiftParent} from '../messageHelper';
3
3
 
4
- const completedSymbol = Symbol.for('completed');
5
- const messageQSymbol = Symbol.for('messageQ');
6
- const executeMessageSymbol = Symbol.for('executeMessage');
7
- const referenceElementSymbol = Symbol.for('referenceElement');
8
- const referenceInfoSymbol = Symbol.for('referenceInfo');
4
+ const kCompleted = Symbol.for('completed');
5
+ const kMessageQ = Symbol.for('messageQ');
6
+ const kExecuteMessage = Symbol.for('executeMessage');
7
+ const kReferenceElement = Symbol.for('referenceElement');
8
+ const kReferenceInfo = Symbol.for('referenceInfo');
9
9
 
10
10
  export default function ErrorEventDefinition(activity, eventDefinition) {
11
11
  const {id, broker, environment, isThrowing} = activity;
@@ -26,12 +26,12 @@ export default function ErrorEventDefinition(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, priority: 300});
36
36
  }
37
37
  }
@@ -40,7 +40,7 @@ const proto = ErrorEventDefinition.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,21 +50,21 @@ 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
 
62
- this[messageQSymbol].consume(this._onThrowApiMessage.bind(this), {
62
+ this[kMessageQ].consume(this._onThrowApiMessage.bind(this), {
63
63
  noAck: true,
64
64
  consumerTag: `_onthrow-${executionId}`,
65
65
  });
66
66
 
67
- if (this[completedSymbol]) return;
67
+ if (this[kCompleted]) return;
68
68
 
69
69
  this._debug(`expect ${info.description}`);
70
70
 
@@ -85,7 +85,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
85
85
  expect: {...info.message},
86
86
  }));
87
87
 
88
- if (this[completedSymbol]) return this._stop();
88
+ if (this[kCompleted]) return this._stop();
89
89
  }
90
90
 
91
91
  const waitContent = cloneContent(executeContent, {
@@ -122,11 +122,11 @@ proto.executeThrow = function executeThrow(executeMessage) {
122
122
 
123
123
  proto._onErrorMessage = function onErrorMessage(routingKey, message) {
124
124
  const error = message.content.error;
125
- if (!this[referenceElementSymbol]) return this._catchError(routingKey, message, error);
125
+ if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
126
126
 
127
127
  if (!error) return;
128
128
 
129
- const info = this[referenceInfoSymbol];
129
+ const info = this[kReferenceInfo];
130
130
  if (('' + error.code) !== ('' + info.message.code)) return;
131
131
 
132
132
  return this._catchError(routingKey, message, error);
@@ -134,21 +134,21 @@ proto._onErrorMessage = function onErrorMessage(routingKey, message) {
134
134
 
135
135
  proto._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
136
136
  const error = message.content.message;
137
- if (!this[referenceElementSymbol]) return this._catchError(routingKey, message, error);
137
+ if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
138
138
 
139
- const info = this[referenceInfoSymbol];
139
+ const info = this[kReferenceInfo];
140
140
  if (info.message.id !== (error && error.id)) return;
141
141
  return this._catchError(routingKey, message, error);
142
142
  };
143
143
 
144
144
  proto._catchError = function catchError(routingKey, message, error) {
145
- this[completedSymbol] = true;
145
+ this[kCompleted] = true;
146
146
 
147
147
  this._stop();
148
148
 
149
- this._debug(`caught ${this[referenceInfoSymbol].description}`);
149
+ this._debug(`caught ${this[kReferenceInfo].description}`);
150
150
 
151
- const executeContent = this[executeMessageSymbol].content;
151
+ const executeContent = this[kExecuteMessage].content;
152
152
  const parent = executeContent.parent;
153
153
  const catchContent = cloneContent(executeContent, {
154
154
  source: {
@@ -176,9 +176,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
176
176
 
177
177
  switch (messageType) {
178
178
  case 'discard': {
179
- this[completedSymbol] = true;
179
+ this[kCompleted] = true;
180
180
  this._stop();
181
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content));
181
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content));
182
182
  }
183
183
  case 'stop': {
184
184
  this._stop();
@@ -192,11 +192,11 @@ proto._stop = function stop() {
192
192
  broker.cancel(`_onthrow-${executionId}`);
193
193
  broker.cancel(`_onerror-${executionId}`);
194
194
  broker.cancel(`_api-${executionId}`);
195
- this[messageQSymbol].purge();
195
+ this[kMessageQ].purge();
196
196
  };
197
197
 
198
198
  proto._getReferenceInfo = function getReferenceInfo(message) {
199
- const referenceElement = this[referenceElementSymbol];
199
+ const referenceElement = this[kReferenceElement];
200
200
  if (!referenceElement) {
201
201
  return {
202
202
  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('reference');
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 kReference = Symbol.for('reference');
10
10
 
11
11
  export default function EscalationEventDefinition(activity, eventDefinition) {
12
12
  const {id, broker, environment, isThrowing} = activity;
@@ -26,12 +26,12 @@ export default function EscalationEventDefinition(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, priority: 400});
36
36
  }
37
37
  }
@@ -40,7 +40,7 @@ const proto = EscalationEventDefinition.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,20 +50,20 @@ 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
 
59
- const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
59
+ const info = this[kReference] = this._getReferenceInfo(executeMessage);
60
60
  const broker = this.broker;
61
- this[messageQSymbol].consume(this._onCatchMessage.bind(this), {
61
+ this[kMessageQ].consume(this._onCatchMessage.bind(this), {
62
62
  noAck: true,
63
63
  consumerTag: `_onescalate-${executionId}`,
64
64
  });
65
65
 
66
- if (this[completedSymbol]) return;
66
+ if (this[kCompleted]) return;
67
67
 
68
68
  broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
69
69
  noAck: true,
@@ -103,17 +103,17 @@ proto.executeThrow = function executeThrow(executeMessage) {
103
103
  };
104
104
 
105
105
  proto._onCatchMessage = function onCatchMessage(routingKey, message) {
106
- const info = this[referenceInfoSymbol];
106
+ const info = this[kReference];
107
107
  if (getPropertyValue(message, 'content.message.id') !== info.message.id) return;
108
108
 
109
109
  const output = message.content.message;
110
- this[completedSymbol] = true;
110
+ this[kCompleted] = true;
111
111
 
112
112
  this._stop();
113
113
 
114
114
  this._debug(`caught ${info.description}`);
115
115
 
116
- const executeContent = this[executeMessageSymbol].content;
116
+ const executeContent = this[kExecuteMessage].content;
117
117
  const {parent, ...content} = executeContent;
118
118
  const catchContent = cloneContent(content, {
119
119
  message: {...output},
@@ -133,9 +133,9 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
133
133
  return this._onCatchMessage(routingKey, message);
134
134
  }
135
135
  case 'discard': {
136
- this[completedSymbol] = true;
136
+ this[kCompleted] = true;
137
137
  this._stop();
138
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content));
138
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content));
139
139
  }
140
140
  case 'stop': {
141
141
  this._stop();
@@ -151,7 +151,7 @@ proto._stop = function stop() {
151
151
  };
152
152
 
153
153
  proto._getReferenceInfo = function getReferenceInfo(message) {
154
- const referenceElement = this[referenceElementSymbol];
154
+ const referenceElement = this[kReferenceElement];
155
155
  if (!referenceElement) {
156
156
  return {
157
157
  message: {...this.reference},
@@ -1,8 +1,8 @@
1
1
  import {cloneContent, unshiftParent, shiftParent, cloneParent} from '../messageHelper';
2
2
 
3
- const completedSymbol = Symbol.for('completed');
4
- const executeMessageSymbol = Symbol.for('executeMessage');
5
- const stoppedSymbol = Symbol.for('stopped');
3
+ const kCompleted = Symbol.for('completed');
4
+ const kExecuteMessage = Symbol.for('executeMessage');
5
+ const kStopped = Symbol.for('stopped');
6
6
 
7
7
  export default function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKey = 'execute.completed') {
8
8
  this.id = activity.id;
@@ -10,9 +10,9 @@ export default function EventDefinitionExecution(activity, eventDefinitions, com
10
10
  this.broker = activity.broker;
11
11
  this.eventDefinitions = eventDefinitions;
12
12
  this.completedRoutingKey = completedRoutingKey;
13
- this[completedSymbol] = false;
14
- this[stoppedSymbol] = false;
15
- this[executeMessageSymbol] = null;
13
+ this[kCompleted] = false;
14
+ this[kStopped] = false;
15
+ this[kExecuteMessage] = null;
16
16
  }
17
17
 
18
18
  const proto = EventDefinitionExecution.prototype;
@@ -20,14 +20,14 @@ const proto = EventDefinitionExecution.prototype;
20
20
  Object.defineProperty(proto, 'completed', {
21
21
  enumerable: true,
22
22
  get() {
23
- return this[completedSymbol];
23
+ return this[kCompleted];
24
24
  },
25
25
  });
26
26
 
27
27
  Object.defineProperty(proto, 'stopped', {
28
28
  enumerable: true,
29
29
  get() {
30
- return this[stoppedSymbol];
30
+ return this[kStopped];
31
31
  },
32
32
  });
33
33
 
@@ -39,7 +39,7 @@ proto.execute = function execute(executeMessage) {
39
39
 
40
40
  const broker = this.broker;
41
41
 
42
- this[executeMessageSymbol] = executeMessage;
42
+ this[kExecuteMessage] = executeMessage;
43
43
  const executionId = content.executionId;
44
44
 
45
45
  broker.subscribeTmp('execution', 'execute.#', this._onExecuteMessage.bind(this), {
@@ -61,8 +61,8 @@ proto.execute = function execute(executeMessage) {
61
61
  const eventDefinitions = this.eventDefinitions;
62
62
 
63
63
  for (let index = 0; index < eventDefinitions.length; ++index) {
64
- if (this[completedSymbol]) break;
65
- if (this[stoppedSymbol]) break;
64
+ if (this[kCompleted]) break;
65
+ if (this[kStopped]) break;
66
66
 
67
67
  const ed = eventDefinitions[index];
68
68
  const edExecutionId = `${executionId}_${index}`;
@@ -113,12 +113,12 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
113
113
 
114
114
  proto._complete = function complete(message) {
115
115
  const {executionId, type, index, parent} = message.content;
116
- this[completedSymbol] = true;
116
+ this[kCompleted] = true;
117
117
 
118
118
  this._debug(executionId, `event definition ${type} completed, index ${index}`);
119
119
 
120
120
  const completeContent = cloneContent(message.content, {
121
- executionId: this[executeMessageSymbol].content.executionId,
121
+ executionId: this[kExecuteMessage].content.executionId,
122
122
  isRootScope: true,
123
123
  });
124
124
  completeContent.parent = shiftParent(parent);
@@ -135,7 +135,7 @@ proto._executeDefinition = function executeDefinition(message) {
135
135
  };
136
136
 
137
137
  proto._stop = function stop() {
138
- this[stoppedSymbol] = true;
138
+ this[kStopped] = true;
139
139
  this.broker.cancel('_eventdefinition-execution-execute-tag');
140
140
  this.broker.cancel('_eventdefinition-execution-api-tag');
141
141
  };
@@ -2,9 +2,9 @@ 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');
5
+ const kCompleted = Symbol.for('completed');
6
+ const kMessageQ = Symbol.for('messageQ');
7
+ const kExecuteMessage = Symbol.for('executeMessage');
8
8
 
9
9
  export default function LinkEventDefinition(activity, eventDefinition) {
10
10
  const {id, broker, environment, isThrowing} = activity;
@@ -22,11 +22,11 @@ export default function LinkEventDefinition(activity, eventDefinition) {
22
22
  this.activity = activity;
23
23
  this.broker = broker;
24
24
  this.logger = environment.Logger(type.toLowerCase());
25
- this[completedSymbol] = false;
25
+ this[kCompleted] = false;
26
26
 
27
27
  if (!isThrowing) {
28
28
  const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(reference.linkName)}-q`;
29
- this[messageQSymbol] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
29
+ this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
30
30
  broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true});
31
31
  } else {
32
32
  broker.subscribeTmp('event', 'activity.discard', this._onDiscard.bind(this), {
@@ -40,7 +40,7 @@ const proto = LinkEventDefinition.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,19 +50,19 @@ 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.executionId;
59
59
 
60
- this[messageQSymbol].consume(this._onCatchLink.bind(this), {
60
+ this[kMessageQ].consume(this._onCatchLink.bind(this), {
61
61
  noAck: true,
62
62
  consumerTag: `_api-link-${executionId}`,
63
63
  });
64
64
 
65
- if (this[completedSymbol]) return;
65
+ if (this[kCompleted]) return;
66
66
 
67
67
  const broker = this.broker;
68
68
  const onApiMessage = this._onApiMessage.bind(this);
@@ -127,13 +127,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
127
127
  };
128
128
 
129
129
  proto._complete = function complete(verb, output) {
130
- this[completedSymbol] = true;
130
+ this[kCompleted] = true;
131
131
 
132
132
  this._stop();
133
133
 
134
134
  this._debug(`${verb} link ${this.reference.linkName}`);
135
135
 
136
- const executeContent = this[executeMessageSymbol].content;
136
+ const executeContent = this[kExecuteMessage].content;
137
137
  const parent = executeContent.parent;
138
138
  const catchContent = cloneContent(executeContent, {
139
139
  link: {...this.reference},
@@ -149,9 +149,9 @@ proto._complete = function complete(verb, output) {
149
149
  };
150
150
 
151
151
  proto._discard = function discard() {
152
- this[completedSymbol] = true;
152
+ this[kCompleted] = true;
153
153
  this._stop();
154
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[executeMessageSymbol].content));
154
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content));
155
155
  };
156
156
 
157
157
  proto._stop = function stop() {
@@ -159,7 +159,7 @@ proto._stop = function stop() {
159
159
  broker.cancel(`_api-link-${executionId}`);
160
160
  broker.cancel(`_api-parent-${executionId}`);
161
161
  broker.cancel(`_api-${executionId}`);
162
- this[messageQSymbol].purge();
162
+ this[kMessageQ].purge();
163
163
  };
164
164
 
165
165
  proto._onDiscard = function onDiscard(_, message) {