bpmn-elements 8.2.4 → 9.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 (127) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/dist/{src/Api.js → Api.js} +11 -12
  4. package/dist/{src/Context.js → Context.js} +26 -27
  5. package/dist/{src/Environment.js → Environment.js} +15 -16
  6. package/dist/{src/EventBroker.js → EventBroker.js} +5 -1
  7. package/dist/{src/Expressions.js → Expressions.js} +1 -1
  8. package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
  9. package/dist/Tracker.js +89 -0
  10. package/dist/{src/activity → activity}/Activity.js +109 -120
  11. package/dist/{src/activity → activity}/ActivityExecution.js +28 -32
  12. package/dist/{src/activity → activity}/Dummy.js +1 -1
  13. package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
  14. package/dist/{src/definition → definition}/Definition.js +64 -59
  15. package/dist/{src/definition → definition}/DefinitionExecution.js +68 -46
  16. package/dist/{src/error → error}/Errors.js +1 -1
  17. package/dist/eventDefinitions/CancelEventDefinition.js +127 -0
  18. package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +64 -52
  19. package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +24 -16
  20. package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +15 -14
  21. package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
  22. package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
  23. package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
  24. package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
  25. package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
  26. package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
  27. package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
  28. package/dist/{src/events → events}/BoundaryEvent.js +39 -25
  29. package/dist/{src/events → events}/EndEvent.js +3 -3
  30. package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
  31. package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
  32. package/dist/{src/events → events}/StartEvent.js +8 -9
  33. package/dist/{src/flows → flows}/Association.js +14 -22
  34. package/dist/{src/flows → flows}/MessageFlow.js +16 -14
  35. package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
  36. package/dist/{src/gateways → gateways}/EventBasedGateway.js +3 -4
  37. package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
  38. package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
  39. package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
  40. package/dist/index.js +48 -48
  41. package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
  42. package/dist/{src/io → io}/Properties.js +7 -8
  43. package/dist/package.json +3 -0
  44. package/dist/{src/process → process}/Process.js +44 -40
  45. package/dist/{src/process → process}/ProcessExecution.js +169 -78
  46. package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
  47. package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
  48. package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
  49. package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
  50. package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
  51. package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
  52. package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
  53. package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
  54. package/dist/{src/tasks → tasks}/SubProcess.js +19 -19
  55. package/dist/{src/tasks → tasks}/Task.js +2 -2
  56. package/dist/{src/tasks → tasks}/Transaction.js +1 -1
  57. package/package.json +31 -31
  58. package/src/Api.js +11 -13
  59. package/src/Context.js +26 -28
  60. package/src/Environment.js +15 -17
  61. package/src/EventBroker.js +2 -1
  62. package/src/Expressions.js +1 -1
  63. package/src/MessageFormatter.js +3 -3
  64. package/src/Tracker.js +73 -0
  65. package/src/activity/Activity.js +106 -114
  66. package/src/activity/ActivityExecution.js +28 -32
  67. package/src/activity/Dummy.js +1 -1
  68. package/src/activity/ExecutionScope.js +2 -2
  69. package/src/definition/Definition.js +65 -64
  70. package/src/definition/DefinitionExecution.js +71 -47
  71. package/src/error/Errors.js +1 -1
  72. package/src/eventDefinitions/CancelEventDefinition.js +32 -78
  73. package/src/eventDefinitions/CompensateEventDefinition.js +58 -52
  74. package/src/eventDefinitions/ConditionalEventDefinition.js +25 -17
  75. package/src/eventDefinitions/ErrorEventDefinition.js +15 -15
  76. package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
  77. package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
  78. package/src/eventDefinitions/LinkEventDefinition.js +14 -16
  79. package/src/eventDefinitions/MessageEventDefinition.js +13 -15
  80. package/src/eventDefinitions/SignalEventDefinition.js +13 -15
  81. package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
  82. package/src/eventDefinitions/TimerEventDefinition.js +15 -17
  83. package/src/events/BoundaryEvent.js +34 -24
  84. package/src/events/EndEvent.js +3 -3
  85. package/src/events/IntermediateCatchEvent.js +3 -3
  86. package/src/events/IntermediateThrowEvent.js +3 -3
  87. package/src/events/StartEvent.js +8 -10
  88. package/src/flows/Association.js +14 -26
  89. package/src/flows/MessageFlow.js +14 -15
  90. package/src/flows/SequenceFlow.js +16 -20
  91. package/src/gateways/EventBasedGateway.js +3 -4
  92. package/src/gateways/ExclusiveGateway.js +2 -2
  93. package/src/gateways/InclusiveGateway.js +2 -2
  94. package/src/gateways/ParallelGateway.js +2 -2
  95. package/src/index.js +106 -0
  96. package/src/io/InputOutputSpecification.js +8 -10
  97. package/src/io/Properties.js +7 -9
  98. package/src/process/Process.js +45 -41
  99. package/src/process/ProcessExecution.js +167 -79
  100. package/src/tasks/CallActivity.js +7 -9
  101. package/src/tasks/LoopCharacteristics.js +2 -2
  102. package/src/tasks/ReceiveTask.js +215 -217
  103. package/src/tasks/ScriptTask.js +4 -4
  104. package/src/tasks/ServiceImplementation.js +1 -1
  105. package/src/tasks/ServiceTask.js +6 -8
  106. package/src/tasks/SignalTask.js +7 -9
  107. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  108. package/src/tasks/SubProcess.js +19 -20
  109. package/src/tasks/Task.js +2 -2
  110. package/src/tasks/Transaction.js +1 -1
  111. package/types/index.d.ts +520 -0
  112. package/dist/src/eventDefinitions/CancelEventDefinition.js +0 -184
  113. package/index.js +0 -106
  114. /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
  115. /package/dist/{src/Scripts.js → Scripts.js} +0 -0
  116. /package/dist/{src/Timers.js → Timers.js} +0 -0
  117. /package/dist/{src/activity → activity}/Escalation.js +0 -0
  118. /package/dist/{src/activity → activity}/Message.js +0 -0
  119. /package/dist/{src/activity → activity}/Signal.js +0 -0
  120. /package/dist/{src/error → error}/BpmnError.js +0 -0
  121. /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
  122. /package/dist/{src/io → io}/BpmnIO.js +0 -0
  123. /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
  124. /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
  125. /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
  126. /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
  127. /package/dist/{src/shared.js → shared.js} +0 -0
@@ -1,5 +1,5 @@
1
- import {brokerSafeId} from '../shared';
2
- import {cloneContent, cloneMessage, shiftParent} from '../messageHelper';
1
+ import {brokerSafeId} from '../shared.js';
2
+ import {cloneContent, cloneMessage, shiftParent} from '../messageHelper.js';
3
3
 
4
4
  const kCompleted = Symbol.for('completed');
5
5
  const kExecuteMessage = Symbol.for('executeMessage');
@@ -20,29 +20,33 @@ export default function CompensateEventDefinition(activity, eventDefinition, con
20
20
 
21
21
  if (!isThrowing) {
22
22
  this[kCompleted] = false;
23
- this[kAssociations] = context.getOutboundAssociations(id) || [];
23
+ this[kAssociations] = context.getOutboundAssociations(id);
24
24
  const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-q`;
25
25
  this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
26
+ this[kCompensateQ] = broker.assertQueue('compensate-q', {autoDelete: false, durable: true});
26
27
  broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true, priority: 400});
27
28
  }
28
29
  }
29
30
 
30
- const proto = CompensateEventDefinition.prototype;
31
-
32
- Object.defineProperty(proto, 'executionId', {
31
+ Object.defineProperty(CompensateEventDefinition.prototype, 'executionId', {
33
32
  get() {
34
33
  const message = this[kExecuteMessage];
35
34
  return message && message.content.executionId;
36
35
  },
37
36
  });
38
37
 
39
- proto.execute = function execute(executeMessage) {
38
+ CompensateEventDefinition.prototype.execute = function execute(executeMessage) {
40
39
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
41
40
  };
42
41
 
43
- proto.executeCatch = function executeCatch(executeMessage) {
42
+ CompensateEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
44
43
  this[kExecuteMessage] = executeMessage;
45
44
  this[kCompleted] = false;
45
+ if (executeMessage.fields.routingKey === 'execute.compensating') {
46
+ this._debug('resumed at compensating');
47
+ this[kCompleted] = true;
48
+ return this._compensate();
49
+ }
46
50
 
47
51
  const executeContent = executeMessage.content;
48
52
  const {executionId, parent} = executeContent;
@@ -50,18 +54,13 @@ proto.executeCatch = function executeCatch(executeMessage) {
50
54
  this._debug('expect compensate');
51
55
 
52
56
  const broker = this.broker;
57
+ broker.cancel('_convey-messages');
53
58
  broker.assertExchange('compensate', 'topic');
54
- this[kCompensateQ] = broker.assertQueue('compensate-q', {durable: true, autoDelete: false});
55
59
  broker.subscribeTmp('compensate', 'execute.#', this._onCollect.bind(this), {
56
60
  noAck: true,
57
61
  consumerTag: '_oncollect-messages',
58
62
  });
59
63
 
60
- broker.publish('execution', 'execute.detach', cloneContent(executeContent, {
61
- sourceExchange: 'execution',
62
- bindExchange: 'compensate',
63
- }));
64
-
65
64
  this[kMessageQ].consume(this._onCompensateApiMessage.bind(this), {
66
65
  noAck: true,
67
66
  consumerTag: `_oncompensate-${executionId}`,
@@ -69,27 +68,24 @@ proto.executeCatch = function executeCatch(executeMessage) {
69
68
 
70
69
  if (this[kCompleted]) return;
71
70
 
72
- const onApiMessage = this._onApiMessage.bind(this);
73
- broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
71
+ broker.subscribeTmp('api', `activity.#.${parent.executionId}#`, this._onApiMessage.bind(this), {
74
72
  noAck: true,
75
73
  consumerTag: `_api-${executionId}`,
76
74
  });
77
75
 
78
- const detachContent = cloneContent(executeContent, {
79
- executionId: parent.executionId,
76
+ broker.publish('execution', 'execute.detach', cloneContent(executeContent, {
77
+ sourceExchange: 'execution',
80
78
  bindExchange: 'compensate',
81
- });
82
- detachContent.parent = shiftParent(parent);
83
-
84
- broker.publish('event', 'activity.detach', detachContent);
79
+ expect: 'compensate',
80
+ }));
85
81
  };
86
82
 
87
- proto.executeThrow = function executeThrow(executeMessage) {
83
+ CompensateEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
88
84
  const executeContent = executeMessage.content;
89
- const {executionId, parent} = executeContent;
85
+ const {parent} = executeContent;
90
86
  const parentExecutionId = parent && parent.executionId;
91
87
 
92
- this.logger.debug(`<${executionId} (${this.activity.id})> throw compensate`);
88
+ this.logger.debug(`<${parentExecutionId} (${this.id})> throw compensate`);
93
89
 
94
90
  const broker = this.broker;
95
91
  const throwContent = cloneContent(executeContent, {
@@ -102,8 +98,7 @@ proto.executeThrow = function executeThrow(executeMessage) {
102
98
  return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
103
99
  };
104
100
 
105
- proto._onCollect = function onCollect(routingKey, message) {
106
-
101
+ CompensateEventDefinition.prototype._onCollect = function onCollect(routingKey, message) {
107
102
  switch (routingKey) {
108
103
  case 'execute.error':
109
104
  case 'execute.completed': {
@@ -112,68 +107,79 @@ proto._onCollect = function onCollect(routingKey, message) {
112
107
  }
113
108
  };
114
109
 
115
- proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
116
- const output = message.content.message;
110
+ CompensateEventDefinition.prototype._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
117
111
  this[kCompleted] = true;
112
+ const output = message.content.message;
113
+ const broker = this.broker;
114
+ const executeContent = this[kExecuteMessage].content;
118
115
 
119
- this._stop();
116
+ this._stopCollect();
120
117
 
121
118
  this._debug('caught compensate event');
122
- const broker = this.broker;
123
- const executeContent = this[kExecuteMessage].content;
119
+
124
120
  const catchContent = cloneContent(executeContent, {
125
121
  message: {...output},
126
122
  executionId: executeContent.parent.executionId,
127
123
  });
128
124
  catchContent.parent = shiftParent(catchContent.parent);
129
125
 
126
+ this[kCompensateQ].queueMessage({routingKey: 'execute.compensated'}, cloneContent(executeContent));
127
+
128
+ broker.publish('execution', 'execute.compensating', cloneContent(executeContent, {message: {...output}}));
130
129
  broker.publish('event', 'activity.catch', catchContent, {type: 'catch'});
131
130
 
132
- const compensateQ = this[kCompensateQ];
133
- compensateQ.on('depleted', onDepleted);
134
- compensateQ.consume(this._onCollected.bind(this), {noAck: true, consumerTag: '_convey-messages'});
131
+ return this._compensate();
132
+ };
135
133
 
136
- for (const association of this[kAssociations]) association.complete(cloneMessage(message));
134
+ CompensateEventDefinition.prototype._compensate = function compensate() {
135
+ return this[kCompensateQ].consume(this._onCollected.bind(this), {noAck: true, consumerTag: '_convey-messages'});
136
+ };
137
137
 
138
- function onDepleted() {
139
- compensateQ.off('depleted', onDepleted);
140
- return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output, state: 'catch'}));
138
+ CompensateEventDefinition.prototype._onCollected = function onCollected(routingKey, message) {
139
+ if (routingKey === 'execute.compensated') {
140
+ const broker = this.broker;
141
+ broker.cancel('_convey-messages');
142
+ return this.broker.publish('execution', 'execute.completed', cloneContent(message.content, {cancelActivity: false}));
141
143
  }
144
+ for (const association of this[kAssociations]) association.take(cloneMessage(message));
142
145
  };
143
146
 
144
- proto._onCollected = function onCollected(routingKey, message) {
145
- for (const association of this[kAssociations]) association.take(cloneMessage(message));
147
+ CompensateEventDefinition.prototype._onDiscardApiMessage = function onDiscardApiMessage(routingKey, message) {
148
+ this[kCompleted] = true;
149
+ this._stop();
150
+ this[kCompensateQ].purge();
151
+ for (const association of this[kAssociations]) association.discard(cloneMessage(message));
152
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content));
146
153
  };
147
154
 
148
- proto._onApiMessage = function onApiMessage(routingKey, message) {
155
+ CompensateEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
149
156
  const messageType = message.properties.type;
150
-
151
157
  switch (messageType) {
152
158
  case 'compensate': {
153
159
  return this._onCompensateApiMessage(routingKey, message);
154
160
  }
155
161
  case 'discard': {
156
- this[kCompleted] = true;
157
- this._stop();
158
- for (const association of this[kAssociations]) association.discard(cloneMessage(message));
159
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content));
162
+ return this._onDiscardApiMessage(routingKey, message);
160
163
  }
161
164
  case 'stop': {
162
- this._stop();
163
- break;
165
+ return this._stop();
164
166
  }
165
167
  }
166
168
  };
167
169
 
168
- proto._stop = function stop() {
170
+ CompensateEventDefinition.prototype._stopCollect = function stopCollect() {
169
171
  const broker = this.broker, executionId = this.executionId;
170
172
  broker.cancel(`_api-${executionId}`);
171
173
  broker.cancel(`_oncompensate-${executionId}`);
172
174
  broker.cancel('_oncollect-messages');
173
- broker.cancel('_convey-messages');
174
175
  this[kMessageQ].purge();
175
176
  };
176
177
 
177
- proto._debug = function debug(msg) {
178
+ CompensateEventDefinition.prototype._stop = function stop() {
179
+ this._stopCollect();
180
+ this.broker.cancel('_convey-messages');
181
+ };
182
+
183
+ CompensateEventDefinition.prototype._debug = function debug(msg) {
178
184
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
179
185
  };
@@ -1,5 +1,5 @@
1
- import {cloneContent, shiftParent} from '../messageHelper';
2
- import {ActivityError} from '../error/Errors';
1
+ import {cloneContent, shiftParent} from '../messageHelper.js';
2
+ import {ActivityError} from '../error/Errors.js';
3
3
 
4
4
  const kExecuteMessage = Symbol.for('executeMessage');
5
5
 
@@ -18,21 +18,19 @@ export default function ConditionalEventDefinition(activity, eventDefinition) {
18
18
  this.logger = environment.Logger(type.toLowerCase());
19
19
  }
20
20
 
21
- const proto = ConditionalEventDefinition.prototype;
22
-
23
- Object.defineProperty(proto, 'executionId', {
21
+ Object.defineProperty(ConditionalEventDefinition.prototype, 'executionId', {
24
22
  get() {
25
23
  const message = this[kExecuteMessage];
26
24
  return message && message.content.executionId;
27
25
  },
28
26
  });
29
27
 
30
- proto.execute = function execute(executeMessage) {
28
+ ConditionalEventDefinition.prototype.execute = function execute(executeMessage) {
31
29
  this[kExecuteMessage] = executeMessage;
32
30
  return this.isWaiting ? this.executeWait(executeMessage) : this.executeCatch(executeMessage);
33
31
  };
34
32
 
35
- proto.executeWait = function executeWait(executeMessage) {
33
+ ConditionalEventDefinition.prototype.executeWait = function executeWait(executeMessage) {
36
34
  const executeContent = executeMessage.content;
37
35
  const {executionId, parent} = executeContent;
38
36
  const parentExecutionId = parent.executionId;
@@ -59,11 +57,13 @@ proto.executeWait = function executeWait(executeMessage) {
59
57
  broker.publish('event', 'activity.wait', waitContent);
60
58
  };
61
59
 
62
- proto.executeCatch = function executeCatch(executeMessage) {
60
+ ConditionalEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
63
61
  const executeContent = executeMessage.content;
64
- const {executionId, index} = executeContent;
62
+ const {executionId, index, parent} = executeContent;
63
+ const parentExecutionId = parent.executionId;
65
64
 
66
- this.broker.subscribeTmp('api', `activity.#.${executionId}`, this._onCatchApiMessage.bind(this), {
65
+ const broker = this.broker;
66
+ broker.subscribeTmp('api', `activity.#.${executionId}`, this._onCatchApiMessage.bind(this), {
67
67
  noAck: true,
68
68
  consumerTag: `_api-${executionId}_${index}`,
69
69
  });
@@ -76,9 +76,17 @@ proto.executeCatch = function executeCatch(executeMessage) {
76
76
  priority: 300,
77
77
  consumerTag: `_onend-${executionId}_${index}`,
78
78
  });
79
+
80
+ const waitContent = cloneContent(executeContent, {
81
+ executionId: parentExecutionId,
82
+ condition: this.condition,
83
+ });
84
+ waitContent.parent = shiftParent(parent);
85
+
86
+ broker.publish('event', 'activity.wait', waitContent);
79
87
  };
80
88
 
81
- proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
89
+ ConditionalEventDefinition.prototype._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
82
90
  const messageType = message.properties.type;
83
91
 
84
92
  switch (messageType) {
@@ -95,7 +103,7 @@ proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
95
103
  }
96
104
  };
97
105
 
98
- proto._evaluateWait = function evaluate(message) {
106
+ ConditionalEventDefinition.prototype._evaluateWait = function evaluate(message) {
99
107
  const executeMessage = this[kExecuteMessage];
100
108
  const broker = this.broker, executeContent = executeMessage.content;
101
109
 
@@ -116,13 +124,13 @@ proto._evaluateWait = function evaluate(message) {
116
124
  return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output}));
117
125
  };
118
126
 
119
- proto._stopWait = function stopWait() {
127
+ ConditionalEventDefinition.prototype._stopWait = function stopWait() {
120
128
  const broker = this.broker, executionId = this.executionId;
121
129
  broker.cancel(`_api-${executionId}`);
122
130
  broker.cancel(`_parent-signal-${executionId}`);
123
131
  };
124
132
 
125
- proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
133
+ ConditionalEventDefinition.prototype._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
126
134
  this._stopCatch();
127
135
 
128
136
  const executeMessage = this[kExecuteMessage];
@@ -144,7 +152,7 @@ proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
144
152
  }
145
153
  };
146
154
 
147
- proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
155
+ ConditionalEventDefinition.prototype._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
148
156
  const messageType = message.properties.type;
149
157
  switch (messageType) {
150
158
  case 'discard': {
@@ -159,12 +167,12 @@ proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
159
167
  }
160
168
  };
161
169
 
162
- proto._stopCatch = function stopCatch() {
170
+ ConditionalEventDefinition.prototype._stopCatch = function stopCatch() {
163
171
  const {executionId, index} = this[kExecuteMessage].content;
164
172
  this.activity.attachedTo.broker.cancel(`_onend-${executionId}_${index}`);
165
173
  this.broker.cancel(`_api-${executionId}_${index}`);
166
174
  };
167
175
 
168
- proto._debug = function debug(msg) {
176
+ ConditionalEventDefinition.prototype._debug = function debug(msg) {
169
177
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
170
178
  };
@@ -1,5 +1,5 @@
1
- import {brokerSafeId} from '../shared';
2
- import {cloneContent, shiftParent} from '../messageHelper';
1
+ import {brokerSafeId} from '../shared.js';
2
+ import {cloneContent, shiftParent} from '../messageHelper.js';
3
3
 
4
4
  const kCompleted = Symbol.for('completed');
5
5
  const kMessageQ = Symbol.for('messageQ');
@@ -36,20 +36,18 @@ export default function ErrorEventDefinition(activity, eventDefinition) {
36
36
  }
37
37
  }
38
38
 
39
- const proto = ErrorEventDefinition.prototype;
40
-
41
- Object.defineProperty(proto, 'executionId', {
39
+ Object.defineProperty(ErrorEventDefinition.prototype, 'executionId', {
42
40
  get() {
43
41
  const message = this[kExecuteMessage];
44
42
  return message && message.content.executionId;
45
43
  },
46
44
  });
47
45
 
48
- proto.execute = function execute(executeMessage) {
46
+ ErrorEventDefinition.prototype.execute = function execute(executeMessage) {
49
47
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
50
48
  };
51
49
 
52
- proto.executeCatch = function executeCatch(executeMessage) {
50
+ ErrorEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
53
51
  this[kExecuteMessage] = executeMessage;
54
52
  this[kCompleted] = false;
55
53
 
@@ -81,6 +79,8 @@ proto.executeCatch = function executeCatch(executeMessage) {
81
79
  consumerTag: `_onerror-${executionId}`,
82
80
  });
83
81
  broker.publish('execution', 'execute.expect', cloneContent(executeContent, {
82
+ pattern: 'activity.error',
83
+ exchange: 'execution',
84
84
  expectRoutingKey,
85
85
  expect: {...info.message},
86
86
  }));
@@ -97,7 +97,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
97
97
  broker.publish('event', 'activity.wait', waitContent);
98
98
  };
99
99
 
100
- proto.executeThrow = function executeThrow(executeMessage) {
100
+ ErrorEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
101
101
  const executeContent = executeMessage.content;
102
102
  const {executionId, parent} = executeContent;
103
103
 
@@ -120,7 +120,7 @@ proto.executeThrow = function executeThrow(executeMessage) {
120
120
  }));
121
121
  };
122
122
 
123
- proto._onErrorMessage = function onErrorMessage(routingKey, message) {
123
+ ErrorEventDefinition.prototype._onErrorMessage = function onErrorMessage(routingKey, message) {
124
124
  const error = message.content.error;
125
125
  if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
126
126
 
@@ -132,7 +132,7 @@ proto._onErrorMessage = function onErrorMessage(routingKey, message) {
132
132
  return this._catchError(routingKey, message, error);
133
133
  };
134
134
 
135
- proto._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
135
+ ErrorEventDefinition.prototype._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
136
136
  const error = message.content.message;
137
137
  if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
138
138
 
@@ -141,7 +141,7 @@ proto._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
141
141
  return this._catchError(routingKey, message, error);
142
142
  };
143
143
 
144
- proto._catchError = function catchError(routingKey, message, error) {
144
+ ErrorEventDefinition.prototype._catchError = function catchError(routingKey, message, error) {
145
145
  this[kCompleted] = true;
146
146
 
147
147
  this._stop();
@@ -171,7 +171,7 @@ proto._catchError = function catchError(routingKey, message, error) {
171
171
  }));
172
172
  };
173
173
 
174
- proto._onApiMessage = function onApiMessage(routingKey, message) {
174
+ ErrorEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
175
175
  const messageType = message.properties.type;
176
176
 
177
177
  switch (messageType) {
@@ -187,7 +187,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
187
187
  }
188
188
  };
189
189
 
190
- proto._stop = function stop() {
190
+ ErrorEventDefinition.prototype._stop = function stop() {
191
191
  const broker = this.broker, executionId = this.executionId;
192
192
  broker.cancel(`_onthrow-${executionId}`);
193
193
  broker.cancel(`_onerror-${executionId}`);
@@ -195,7 +195,7 @@ proto._stop = function stop() {
195
195
  this[kMessageQ].purge();
196
196
  };
197
197
 
198
- proto._getReferenceInfo = function getReferenceInfo(message) {
198
+ ErrorEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(message) {
199
199
  const referenceElement = this[kReferenceElement];
200
200
  if (!referenceElement) {
201
201
  return {
@@ -214,6 +214,6 @@ proto._getReferenceInfo = function getReferenceInfo(message) {
214
214
  return result;
215
215
  };
216
216
 
217
- proto._debug = function debug(msg) {
217
+ ErrorEventDefinition.prototype._debug = function debug(msg) {
218
218
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
219
219
  };
@@ -1,6 +1,6 @@
1
- import getPropertyValue from '../getPropertyValue';
2
- import {brokerSafeId} from '../shared';
3
- import {cloneContent, shiftParent} from '../messageHelper';
1
+ import getPropertyValue from '../getPropertyValue.js';
2
+ import {brokerSafeId} from '../shared.js';
3
+ import {cloneContent, shiftParent} from '../messageHelper.js';
4
4
 
5
5
  const kCompleted = Symbol.for('completed');
6
6
  const kMessageQ = Symbol.for('messageQ');
@@ -36,20 +36,18 @@ export default function EscalationEventDefinition(activity, eventDefinition) {
36
36
  }
37
37
  }
38
38
 
39
- const proto = EscalationEventDefinition.prototype;
40
-
41
- Object.defineProperty(proto, 'executionId', {
39
+ Object.defineProperty(EscalationEventDefinition.prototype, 'executionId', {
42
40
  get() {
43
41
  const message = this[kExecuteMessage];
44
42
  return message && message.content.executionId;
45
43
  },
46
44
  });
47
45
 
48
- proto.execute = function execute(executeMessage) {
46
+ EscalationEventDefinition.prototype.execute = function execute(executeMessage) {
49
47
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
50
48
  };
51
49
 
52
- proto.executeCatch = function executeCatch(executeMessage) {
50
+ EscalationEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
53
51
  this[kExecuteMessage] = executeMessage;
54
52
  this[kCompleted] = false;
55
53
 
@@ -82,7 +80,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
82
80
  broker.publish('event', 'activity.wait', waitContent);
83
81
  };
84
82
 
85
- proto.executeThrow = function executeThrow(executeMessage) {
83
+ EscalationEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
86
84
  const executeContent = executeMessage.content;
87
85
  const {executionId, parent} = executeContent;
88
86
 
@@ -102,7 +100,7 @@ proto.executeThrow = function executeThrow(executeMessage) {
102
100
  return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
103
101
  };
104
102
 
105
- proto._onCatchMessage = function onCatchMessage(routingKey, message) {
103
+ EscalationEventDefinition.prototype._onCatchMessage = function onCatchMessage(routingKey, message) {
106
104
  const info = this[kReference];
107
105
  if (getPropertyValue(message, 'content.message.id') !== info.message.id) return;
108
106
 
@@ -127,7 +125,7 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
127
125
  return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output, state: 'catch'}));
128
126
  };
129
127
 
130
- proto._onApiMessage = function onApiMessage(routingKey, message) {
128
+ EscalationEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
131
129
  switch (message.properties.type) {
132
130
  case 'escalate': {
133
131
  return this._onCatchMessage(routingKey, message);
@@ -144,13 +142,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
144
142
  }
145
143
  };
146
144
 
147
- proto._stop = function stop() {
145
+ EscalationEventDefinition.prototype._stop = function stop() {
148
146
  const broker = this.broker, executionId = this.executionId;
149
147
  broker.cancel(`_api-${executionId}`);
150
148
  broker.cancel(`_onescalate-${executionId}`);
151
149
  };
152
150
 
153
- proto._getReferenceInfo = function getReferenceInfo(message) {
151
+ EscalationEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(message) {
154
152
  const referenceElement = this[kReferenceElement];
155
153
  if (!referenceElement) {
156
154
  return {
@@ -168,6 +166,6 @@ proto._getReferenceInfo = function getReferenceInfo(message) {
168
166
  return result;
169
167
  };
170
168
 
171
- proto._debug = function debug(msg) {
169
+ EscalationEventDefinition.prototype._debug = function debug(msg) {
172
170
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
173
171
  };
@@ -1,4 +1,4 @@
1
- import {cloneContent, unshiftParent, shiftParent, cloneParent} from '../messageHelper';
1
+ import {cloneContent, unshiftParent, shiftParent, cloneParent} from '../messageHelper.js';
2
2
 
3
3
  const kCompleted = Symbol.for('completed');
4
4
  const kExecuteMessage = Symbol.for('executeMessage');
@@ -15,23 +15,21 @@ export default function EventDefinitionExecution(activity, eventDefinitions, com
15
15
  this[kExecuteMessage] = null;
16
16
  }
17
17
 
18
- const proto = EventDefinitionExecution.prototype;
19
-
20
- Object.defineProperty(proto, 'completed', {
18
+ Object.defineProperty(EventDefinitionExecution.prototype, 'completed', {
21
19
  enumerable: true,
22
20
  get() {
23
21
  return this[kCompleted];
24
22
  },
25
23
  });
26
24
 
27
- Object.defineProperty(proto, 'stopped', {
25
+ Object.defineProperty(EventDefinitionExecution.prototype, 'stopped', {
28
26
  enumerable: true,
29
27
  get() {
30
28
  return this[kStopped];
31
29
  },
32
30
  });
33
31
 
34
- proto.execute = function execute(executeMessage) {
32
+ EventDefinitionExecution.prototype.execute = function execute(executeMessage) {
35
33
  const content = executeMessage.content;
36
34
 
37
35
  if (content.isDefinitionScope) return this._executeDefinition(executeMessage);
@@ -82,7 +80,7 @@ proto.execute = function execute(executeMessage) {
82
80
  }
83
81
  };
84
82
 
85
- proto._onApiMessage = function onApiMessage(_, message) {
83
+ EventDefinitionExecution.prototype._onApiMessage = function onApiMessage(_, message) {
86
84
  const messageType = message.properties.type;
87
85
  switch (messageType) {
88
86
  case 'stop':
@@ -91,7 +89,7 @@ proto._onApiMessage = function onApiMessage(_, message) {
91
89
  }
92
90
  };
93
91
 
94
- proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
92
+ EventDefinitionExecution.prototype._onExecuteMessage = function onExecuteMessage(routingKey, message) {
95
93
  switch (routingKey) {
96
94
  case 'execute.completed': {
97
95
  this._stop();
@@ -111,7 +109,7 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
111
109
  }
112
110
  };
113
111
 
114
- proto._complete = function complete(message) {
112
+ EventDefinitionExecution.prototype._complete = function complete(message) {
115
113
  const {executionId, type, index, parent} = message.content;
116
114
  this[kCompleted] = true;
117
115
 
@@ -127,7 +125,7 @@ proto._complete = function complete(message) {
127
125
  this.broker.publish('execution', this.completedRoutingKey, completeContent, {correlationId: message.properties.correlationId});
128
126
  };
129
127
 
130
- proto._executeDefinition = function executeDefinition(message) {
128
+ EventDefinitionExecution.prototype._executeDefinition = function executeDefinition(message) {
131
129
  const {executionId, index} = message.content;
132
130
  const ed = this.eventDefinitions[index];
133
131
  if (!ed) return this.activity.logger.warn(`<${executionId} (${this.id})> found no event definition on index ${index}`);
@@ -135,12 +133,12 @@ proto._executeDefinition = function executeDefinition(message) {
135
133
  ed.execute(message);
136
134
  };
137
135
 
138
- proto._stop = function stop() {
136
+ EventDefinitionExecution.prototype._stop = function stop() {
139
137
  this[kStopped] = true;
140
138
  this.broker.cancel('_eventdefinition-execution-execute-tag');
141
139
  this.broker.cancel('_eventdefinition-execution-api-tag');
142
140
  };
143
141
 
144
- proto._debug = function debug(executionId, msg) {
142
+ EventDefinitionExecution.prototype._debug = function debug(executionId, msg) {
145
143
  this.activity.logger.debug(`<${executionId} (${this.id})> ${msg}`);
146
144
  };