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,217 +1,215 @@
1
- import Activity from '../activity/Activity';
2
- import {cloneContent} from '../messageHelper';
3
-
4
- const kCompleted = Symbol.for('completed');
5
- const kExecuteMessage = Symbol.for('executeMessage');
6
- const kReferenceElement = Symbol.for('referenceElement');
7
- const kReferenceInfo = Symbol.for('referenceInfo');
8
-
9
- export default function ReceiveTask(activityDef, context) {
10
- const task = new Activity(ReceiveTaskBehaviour, activityDef, context);
11
-
12
- task.broker.assertQueue('message', {autoDelete: false, durable: true});
13
- task.broker.bindQueue('message', 'api', '*.message.#', {durable: true});
14
-
15
- return task;
16
- }
17
-
18
- export function ReceiveTaskBehaviour(activity) {
19
- const {id, type, behaviour} = activity;
20
-
21
- this.id = id;
22
- this.type = type;
23
-
24
- const reference = this.reference = {
25
- name: 'anonymous',
26
- ...behaviour.messageRef,
27
- referenceType: 'message',
28
- };
29
-
30
- this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
31
- this.activity = activity;
32
- this.broker = activity.broker;
33
-
34
- this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
35
- }
36
-
37
- ReceiveTaskBehaviour.prototype.execute = function execute(executeMessage) {
38
- return new ReceiveTaskExecution(this).execute(executeMessage);
39
- };
40
-
41
- function ReceiveTaskExecution(parent) {
42
- const {activity, broker, loopCharacteristics, reference} = parent;
43
-
44
- this.id = activity.id;
45
- this.logger = activity.logger;
46
- this.reference = reference;
47
- this.broker = broker;
48
- this.loopCharacteristics = loopCharacteristics;
49
- this.referenceElement = parent[kReferenceElement];
50
-
51
- this[kCompleted] = false;
52
- }
53
-
54
- const proto = ReceiveTaskExecution.prototype;
55
-
56
- proto.execute = function execute(executeMessage) {
57
- this[kExecuteMessage] = executeMessage;
58
-
59
- const executeContent = executeMessage.content;
60
- const {executionId, isRootScope} = executeContent;
61
- this.executionId = executionId;
62
-
63
- const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
64
-
65
- if (isRootScope) {
66
- this._setupMessageHandling(executionId);
67
- }
68
-
69
- const loopCharacteristics = this.loopCharacteristics;
70
- if (loopCharacteristics && executeMessage.content.isRootScope) {
71
- return loopCharacteristics.execute(executeMessage);
72
- }
73
-
74
- const broker = this.broker;
75
- broker.consume('message', this._onCatchMessage.bind(this), {
76
- noAck: true,
77
- consumerTag: `_onmessage-${executionId}`,
78
- });
79
-
80
- if (this[kCompleted]) return;
81
-
82
- broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
83
- noAck: true,
84
- consumerTag: `_api-${executionId}`,
85
- priority: 400,
86
- });
87
-
88
- this._debug(`expect ${info.description}`);
89
-
90
- broker.publish('event', 'activity.wait', cloneContent(executeContent, {message: {...info.message}}));
91
- };
92
-
93
- proto._onCatchMessage = function onCatchMessage(routingKey, message) {
94
- const content = message.content;
95
-
96
- const {id: signalId, executionId: signalExecutionId} = content.message || {};
97
- const {message: referenceMessage, description} = this[kReferenceInfo];
98
-
99
- if (!referenceMessage.id && signalId || signalExecutionId) {
100
- if (this.loopCharacteristics && signalExecutionId !== this.executionId) return;
101
- if (signalId !== this.id && signalExecutionId !== this.executionId) return;
102
- this._debug('caught direct message');
103
- } else if (referenceMessage.id !== signalId) return;
104
- else {
105
- this._debug(`caught ${description}`);
106
- }
107
-
108
- const {type: messageType, correlationId} = message.properties;
109
- const broker = this.broker;
110
- const executeContent = this[kExecuteMessage].content;
111
-
112
- broker.publish('event', 'activity.consumed', cloneContent(executeContent, {message: {...message.content.message}}), {correlationId, type: messageType});
113
- broker.publish('event', 'activity.catch', cloneContent(executeContent, {message: message.content.message}), {type: 'catch', correlationId});
114
-
115
- this._complete(message.content.message, {correlationId});
116
- };
117
-
118
- proto._onApiMessage = function onApiMessage(routingKey, message) {
119
- const {type: messageType, correlationId} = message.properties;
120
- switch (messageType) {
121
- case 'message':
122
- case 'signal': {
123
- return this._complete(message.content.message, {correlationId});
124
- }
125
- case 'discard': {
126
- this[kCompleted] = true;
127
- this._stop();
128
- return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
129
- }
130
- case 'stop': {
131
- return this._stop();
132
- }
133
- }
134
- };
135
-
136
- proto._complete = function complete(output, options) {
137
- this[kCompleted] = true;
138
- this._stop();
139
- return this.broker.publish('execution', 'execute.completed', cloneContent(this[kExecuteMessage].content, {output}), options);
140
- };
141
-
142
- proto._stop = function stop() {
143
- const broker = this.broker, executionId = this.executionId;
144
- broker.cancel(`_onmessage-${executionId}`);
145
- broker.cancel(`_api-${executionId}`);
146
- };
147
-
148
- proto._setupMessageHandling = function setupMessageHandling(executionId) {
149
- const broker = this.broker;
150
- broker.subscribeTmp('api', '#.signal.*', this._onDelegateMessage.bind(this), {
151
- noAck: true,
152
- consumerTag: `_api-delegated-${executionId}`,
153
- }, {
154
- noAck: true,
155
- });
156
- broker.subscribeTmp('api', `activity.stop.${executionId}`, this._onStopApiMessage.bind(this), {
157
- noAck: true,
158
- consumerTag: `_api-stop-${executionId}`,
159
- priority: 400,
160
- });
161
- broker.subscribeTmp('execution', 'execute.#', this._onExecutionComplete.bind(this), {
162
- noAck: true,
163
- consumerTag: `_execution-complete-${executionId}`,
164
- }, {
165
- noAck: true,
166
- });
167
- };
168
-
169
- proto._onDelegateMessage = function onDelegateMessage(_, message) {
170
- if (!message.properties.delegate) return;
171
- this.broker.sendToQueue('message', message.content, message.properties);
172
- };
173
-
174
- proto._onStopApiMessage = function onStopApiMessage() {
175
- this._stopMessageHandling(true);
176
- };
177
-
178
- proto._onExecutionComplete = function onExecutionComplete(routingKey, {content}) {
179
- if (!content.isRootScope) return;
180
- switch (routingKey) {
181
- case 'execute.completed':
182
- case 'execute.error':
183
- case 'execute.discard':
184
- this._stopMessageHandling();
185
- break;
186
- }
187
- };
188
-
189
- proto._stopMessageHandling = function stop(keepMessageQ) {
190
- const broker = this.broker, executionId = this.executionId;
191
- broker.cancel(`_api-delegated-${executionId}`);
192
- broker.cancel(`_api-stop-${executionId}`);
193
- broker.cancel(`_execution-complete-${executionId}`);
194
- if (!keepMessageQ) broker.purgeQueue('message');
195
- };
196
-
197
- proto._getReferenceInfo = function getReferenceInfo(message) {
198
- const referenceElement = this.referenceElement;
199
- if (!referenceElement) {
200
- return {
201
- message: {...this.reference},
202
- description: 'anonymous message',
203
- };
204
- }
205
-
206
- const result = {
207
- message: referenceElement.resolve(message),
208
- };
209
-
210
- result.description = `${result.message.name} <${result.message.id}>`;
211
-
212
- return result;
213
- };
214
-
215
- proto._debug = function debug(msg) {
216
- this.logger.debug(`<${this.executionId} (${this.id})> ${msg}`);
217
- };
1
+ import Activity from '../activity/Activity.js';
2
+ import {cloneContent} from '../messageHelper.js';
3
+
4
+ const kCompleted = Symbol.for('completed');
5
+ const kExecuteMessage = Symbol.for('executeMessage');
6
+ const kReferenceElement = Symbol.for('referenceElement');
7
+ const kReferenceInfo = Symbol.for('referenceInfo');
8
+
9
+ export default function ReceiveTask(activityDef, context) {
10
+ const task = new Activity(ReceiveTaskBehaviour, activityDef, context);
11
+
12
+ task.broker.assertQueue('message', {autoDelete: false, durable: true});
13
+ task.broker.bindQueue('message', 'api', '*.message.#', {durable: true});
14
+
15
+ return task;
16
+ }
17
+
18
+ export function ReceiveTaskBehaviour(activity) {
19
+ const {id, type, behaviour} = activity;
20
+
21
+ this.id = id;
22
+ this.type = type;
23
+
24
+ const reference = this.reference = {
25
+ name: 'anonymous',
26
+ ...behaviour.messageRef,
27
+ referenceType: 'message',
28
+ };
29
+
30
+ this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
31
+ this.activity = activity;
32
+ this.broker = activity.broker;
33
+
34
+ this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
35
+ }
36
+
37
+ ReceiveTaskBehaviour.prototype.execute = function execute(executeMessage) {
38
+ return new ReceiveTaskExecution(this).execute(executeMessage);
39
+ };
40
+
41
+ function ReceiveTaskExecution(parent) {
42
+ const {activity, broker, loopCharacteristics, reference} = parent;
43
+
44
+ this.id = activity.id;
45
+ this.logger = activity.logger;
46
+ this.reference = reference;
47
+ this.broker = broker;
48
+ this.loopCharacteristics = loopCharacteristics;
49
+ this.referenceElement = parent[kReferenceElement];
50
+
51
+ this[kCompleted] = false;
52
+ }
53
+
54
+ ReceiveTaskExecution.prototype.execute = function execute(executeMessage) {
55
+ this[kExecuteMessage] = executeMessage;
56
+
57
+ const executeContent = executeMessage.content;
58
+ const {executionId, isRootScope} = executeContent;
59
+ this.executionId = executionId;
60
+
61
+ const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
62
+
63
+ if (isRootScope) {
64
+ this._setupMessageHandling(executionId);
65
+ }
66
+
67
+ const loopCharacteristics = this.loopCharacteristics;
68
+ if (loopCharacteristics && executeMessage.content.isRootScope) {
69
+ return loopCharacteristics.execute(executeMessage);
70
+ }
71
+
72
+ const broker = this.broker;
73
+ broker.consume('message', this._onCatchMessage.bind(this), {
74
+ noAck: true,
75
+ consumerTag: `_onmessage-${executionId}`,
76
+ });
77
+
78
+ if (this[kCompleted]) return;
79
+
80
+ broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
81
+ noAck: true,
82
+ consumerTag: `_api-${executionId}`,
83
+ priority: 400,
84
+ });
85
+
86
+ this._debug(`expect ${info.description}`);
87
+
88
+ broker.publish('event', 'activity.wait', cloneContent(executeContent, {message: {...info.message}}));
89
+ };
90
+
91
+ ReceiveTaskExecution.prototype._onCatchMessage = function onCatchMessage(routingKey, message) {
92
+ const content = message.content;
93
+
94
+ const {id: signalId, executionId: signalExecutionId} = content.message || {};
95
+ const {message: referenceMessage, description} = this[kReferenceInfo];
96
+
97
+ if (!referenceMessage.id && signalId || signalExecutionId) {
98
+ if (this.loopCharacteristics && signalExecutionId !== this.executionId) return;
99
+ if (signalId !== this.id && signalExecutionId !== this.executionId) return;
100
+ this._debug('caught direct message');
101
+ } else if (referenceMessage.id !== signalId) return;
102
+ else {
103
+ this._debug(`caught ${description}`);
104
+ }
105
+
106
+ const {type: messageType, correlationId} = message.properties;
107
+ const broker = this.broker;
108
+ const executeContent = this[kExecuteMessage].content;
109
+
110
+ broker.publish('event', 'activity.consumed', cloneContent(executeContent, {message: {...message.content.message}}), {correlationId, type: messageType});
111
+ broker.publish('event', 'activity.catch', cloneContent(executeContent, {message: message.content.message}), {type: 'catch', correlationId});
112
+
113
+ this._complete(message.content.message, {correlationId});
114
+ };
115
+
116
+ ReceiveTaskExecution.prototype._onApiMessage = function onApiMessage(routingKey, message) {
117
+ const {type: messageType, correlationId} = message.properties;
118
+ switch (messageType) {
119
+ case 'message':
120
+ case 'signal': {
121
+ return this._complete(message.content.message, {correlationId});
122
+ }
123
+ case 'discard': {
124
+ this[kCompleted] = true;
125
+ this._stop();
126
+ return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content), {correlationId});
127
+ }
128
+ case 'stop': {
129
+ return this._stop();
130
+ }
131
+ }
132
+ };
133
+
134
+ ReceiveTaskExecution.prototype._complete = function complete(output, options) {
135
+ this[kCompleted] = true;
136
+ this._stop();
137
+ return this.broker.publish('execution', 'execute.completed', cloneContent(this[kExecuteMessage].content, {output}), options);
138
+ };
139
+
140
+ ReceiveTaskExecution.prototype._stop = function stop() {
141
+ const broker = this.broker, executionId = this.executionId;
142
+ broker.cancel(`_onmessage-${executionId}`);
143
+ broker.cancel(`_api-${executionId}`);
144
+ };
145
+
146
+ ReceiveTaskExecution.prototype._setupMessageHandling = function setupMessageHandling(executionId) {
147
+ const broker = this.broker;
148
+ broker.subscribeTmp('api', '#.signal.*', this._onDelegateMessage.bind(this), {
149
+ noAck: true,
150
+ consumerTag: `_api-delegated-${executionId}`,
151
+ }, {
152
+ noAck: true,
153
+ });
154
+ broker.subscribeTmp('api', `activity.stop.${executionId}`, this._onStopApiMessage.bind(this), {
155
+ noAck: true,
156
+ consumerTag: `_api-stop-${executionId}`,
157
+ priority: 400,
158
+ });
159
+ broker.subscribeTmp('execution', 'execute.#', this._onExecutionComplete.bind(this), {
160
+ noAck: true,
161
+ consumerTag: `_execution-complete-${executionId}`,
162
+ }, {
163
+ noAck: true,
164
+ });
165
+ };
166
+
167
+ ReceiveTaskExecution.prototype._onDelegateMessage = function onDelegateMessage(_, message) {
168
+ if (!message.properties.delegate) return;
169
+ this.broker.sendToQueue('message', message.content, message.properties);
170
+ };
171
+
172
+ ReceiveTaskExecution.prototype._onStopApiMessage = function onStopApiMessage() {
173
+ this._stopMessageHandling(true);
174
+ };
175
+
176
+ ReceiveTaskExecution.prototype._onExecutionComplete = function onExecutionComplete(routingKey, {content}) {
177
+ if (!content.isRootScope) return;
178
+ switch (routingKey) {
179
+ case 'execute.completed':
180
+ case 'execute.error':
181
+ case 'execute.discard':
182
+ this._stopMessageHandling();
183
+ break;
184
+ }
185
+ };
186
+
187
+ ReceiveTaskExecution.prototype._stopMessageHandling = function stop(keepMessageQ) {
188
+ const broker = this.broker, executionId = this.executionId;
189
+ broker.cancel(`_api-delegated-${executionId}`);
190
+ broker.cancel(`_api-stop-${executionId}`);
191
+ broker.cancel(`_execution-complete-${executionId}`);
192
+ if (!keepMessageQ) broker.purgeQueue('message');
193
+ };
194
+
195
+ ReceiveTaskExecution.prototype._getReferenceInfo = function getReferenceInfo(message) {
196
+ const referenceElement = this.referenceElement;
197
+ if (!referenceElement) {
198
+ return {
199
+ message: {...this.reference},
200
+ description: 'anonymous message',
201
+ };
202
+ }
203
+
204
+ const result = {
205
+ message: referenceElement.resolve(message),
206
+ };
207
+
208
+ result.description = `${result.message.name} <${result.message.id}>`;
209
+
210
+ return result;
211
+ };
212
+
213
+ ReceiveTaskExecution.prototype._debug = function debug(msg) {
214
+ this.logger.debug(`<${this.executionId} (${this.id})> ${msg}`);
215
+ };
@@ -1,7 +1,7 @@
1
- import Activity from '../activity/Activity';
2
- import ExecutionScope from '../activity/ExecutionScope';
3
- import { ActivityError } from '../error/Errors';
4
- import {cloneContent, cloneMessage} from '../messageHelper';
1
+ import Activity from '../activity/Activity.js';
2
+ import ExecutionScope from '../activity/ExecutionScope.js';
3
+ import { ActivityError } from '../error/Errors.js';
4
+ import {cloneContent, cloneMessage} from '../messageHelper.js';
5
5
 
6
6
  export default function ScriptTask(activityDef, context) {
7
7
  return new Activity(ScriptTaskBehaviour, activityDef, context);
@@ -1,4 +1,4 @@
1
- import ExecutionScope from '../activity/ExecutionScope';
1
+ import ExecutionScope from '../activity/ExecutionScope.js';
2
2
 
3
3
  export default function ServiceImplementation(activity) {
4
4
  this.type = `${activity.type}:implementation`;
@@ -1,6 +1,6 @@
1
- import Activity from '../activity/Activity';
2
- import {ActivityError} from '../error/Errors';
3
- import {cloneMessage, cloneContent} from '../messageHelper';
1
+ import Activity from '../activity/Activity.js';
2
+ import {ActivityError} from '../error/Errors.js';
3
+ import {cloneMessage, cloneContent} from '../messageHelper.js';
4
4
 
5
5
  export default function ServiceTask(activityDef, context) {
6
6
  return new Activity(ServiceTaskBehaviour, activityDef, context);
@@ -17,9 +17,7 @@ export function ServiceTaskBehaviour(activity) {
17
17
  this.broker = activity.broker;
18
18
  }
19
19
 
20
- const proto = ServiceTaskBehaviour.prototype;
21
-
22
- proto.execute = function execute(executeMessage) {
20
+ ServiceTaskBehaviour.prototype.execute = function execute(executeMessage) {
23
21
  const executeContent = executeMessage.content;
24
22
  const loopCharacteristics = this.loopCharacteristics;
25
23
  if (loopCharacteristics && executeContent.isRootScope) {
@@ -44,13 +42,13 @@ proto.execute = function execute(executeMessage) {
44
42
  });
45
43
  };
46
44
 
47
- proto.getService = function getService(message) {
45
+ ServiceTaskBehaviour.prototype.getService = function getService(message) {
48
46
  let Service = this.activity.behaviour.Service;
49
47
  if (!Service && this.environment.settings.enableDummyService) Service = DummyService;
50
48
  return Service && new Service(this.activity, cloneMessage(message));
51
49
  };
52
50
 
53
- proto._onApiMessage = function onApiMessage(executeMessage, _, message) {
51
+ ServiceTaskBehaviour.prototype._onApiMessage = function onApiMessage(executeMessage, _, message) {
54
52
  const broker = this.broker;
55
53
  switch (message.properties.type) {
56
54
  case 'discard': {
@@ -1,6 +1,6 @@
1
- import Activity from '../activity/Activity';
2
- import {ActivityError} from '../error/Errors';
3
- import {cloneContent} from '../messageHelper';
1
+ import Activity from '../activity/Activity.js';
2
+ import {ActivityError} from '../error/Errors.js';
3
+ import {cloneContent} from '../messageHelper.js';
4
4
 
5
5
  export default function SignalTask(activityDef, context) {
6
6
  return new Activity(SignalTaskBehaviour, activityDef, context);
@@ -16,9 +16,7 @@ export function SignalTaskBehaviour(activity) {
16
16
  this.broker = activity.broker;
17
17
  }
18
18
 
19
- const proto = SignalTaskBehaviour.prototype;
20
-
21
- proto.execute = function execute(executeMessage) {
19
+ SignalTaskBehaviour.prototype.execute = function execute(executeMessage) {
22
20
  const executeContent = executeMessage.content;
23
21
  const loopCharacteristics = this.loopCharacteristics;
24
22
  if (loopCharacteristics && executeContent.isRootScope) {
@@ -39,7 +37,7 @@ proto.execute = function execute(executeMessage) {
39
37
  broker.publish('event', 'activity.wait', cloneContent(executeContent, {state: 'wait'}));
40
38
  };
41
39
 
42
- proto._onDelegatedApiMessage = function onDelegatedApiMessage(executeMessage, routingKey, message) {
40
+ SignalTaskBehaviour.prototype._onDelegatedApiMessage = function onDelegatedApiMessage(executeMessage, routingKey, message) {
43
41
  if (!message.properties.delegate) return;
44
42
 
45
43
  const {content: delegateContent} = message;
@@ -61,7 +59,7 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(executeMessage, ro
61
59
  return this._onApiMessage(executeMessage, routingKey, message);
62
60
  };
63
61
 
64
- proto._onApiMessage = function onApiMessage(executeMessage, routingKey, message) {
62
+ SignalTaskBehaviour.prototype._onApiMessage = function onApiMessage(executeMessage, routingKey, message) {
65
63
  const {type: messageType, correlationId} = message.properties;
66
64
  const executeContent = executeMessage.content;
67
65
  switch (messageType) {
@@ -89,7 +87,7 @@ proto._onApiMessage = function onApiMessage(executeMessage, routingKey, message)
89
87
  }
90
88
  };
91
89
 
92
- proto._stop = function stop(executionId) {
90
+ SignalTaskBehaviour.prototype._stop = function stop(executionId) {
93
91
  const broker = this.broker;
94
92
  broker.cancel(`_api-${executionId}`);
95
93
  broker.cancel(`_api-delegated-${executionId}`);
@@ -1,4 +1,4 @@
1
- import LoopCharacteristics from './LoopCharacteristics';
1
+ import LoopCharacteristics from './LoopCharacteristics.js';
2
2
 
3
3
  export default function StandardLoopCharacteristics(activity, loopCharacteristics) {
4
4
  let {behaviour} = loopCharacteristics;