bpmn-elements 13.1.2 → 13.2.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.
- package/README.md +1 -2
- package/dist/Context.js +36 -2
- package/dist/definition/DefinitionExecution.js +1 -1
- package/dist/getPropertyValue.js +1 -2
- package/dist/index.js +1 -1
- package/package.json +14 -13
- package/src/Api.js +18 -20
- package/src/Context.js +49 -7
- package/src/Environment.js +10 -20
- package/src/EventBroker.js +21 -27
- package/src/MessageFormatter.js +23 -19
- package/src/Tracker.js +4 -4
- package/src/activity/Activity.js +141 -109
- package/src/activity/ActivityExecution.js +38 -29
- package/src/activity/Dummy.js +3 -3
- package/src/activity/Escalation.js +4 -4
- package/src/activity/ExecutionScope.js +4 -4
- package/src/activity/Message.js +5 -5
- package/src/activity/Signal.js +5 -5
- package/src/definition/Definition.js +44 -36
- package/src/definition/DefinitionExecution.js +97 -66
- package/src/error/BpmnError.js +3 -3
- package/src/error/Errors.js +19 -14
- package/src/eventDefinitions/CancelEventDefinition.js +16 -11
- package/src/eventDefinitions/CompensateEventDefinition.js +28 -23
- package/src/eventDefinitions/ConditionalEventDefinition.js +42 -23
- package/src/eventDefinitions/ErrorEventDefinition.js +47 -34
- package/src/eventDefinitions/EscalationEventDefinition.js +21 -20
- package/src/eventDefinitions/EventDefinitionExecution.js +6 -6
- package/src/eventDefinitions/LinkEventDefinition.js +28 -22
- package/src/eventDefinitions/MessageEventDefinition.js +47 -36
- package/src/eventDefinitions/SignalEventDefinition.js +42 -31
- package/src/eventDefinitions/TerminateEventDefinition.js +4 -4
- package/src/eventDefinitions/TimerEventDefinition.js +41 -29
- package/src/events/BoundaryEvent.js +81 -46
- package/src/events/EndEvent.js +2 -2
- package/src/events/IntermediateCatchEvent.js +8 -4
- package/src/events/IntermediateThrowEvent.js +2 -2
- package/src/events/StartEvent.js +29 -18
- package/src/flows/Association.js +11 -11
- package/src/flows/MessageFlow.js +16 -14
- package/src/flows/SequenceFlow.js +22 -20
- package/src/gateways/EventBasedGateway.js +7 -6
- package/src/gateways/ExclusiveGateway.js +4 -4
- package/src/gateways/InclusiveGateway.js +3 -3
- package/src/gateways/ParallelGateway.js +4 -4
- package/src/getPropertyValue.js +3 -6
- package/src/index.js +1 -1
- package/src/io/BpmnIO.js +5 -6
- package/src/io/EnvironmentDataObject.js +2 -3
- package/src/io/EnvironmentDataStore.js +2 -2
- package/src/io/EnvironmentDataStoreReference.js +2 -2
- package/src/io/InputOutputSpecification.js +60 -54
- package/src/io/Properties.js +45 -33
- package/src/iso-duration.js +9 -13
- package/src/messageHelper.js +16 -23
- package/src/process/Lane.js +3 -3
- package/src/process/Process.js +40 -34
- package/src/process/ProcessExecution.js +122 -78
- package/src/tasks/CallActivity.js +109 -57
- package/src/tasks/LoopCharacteristics.js +30 -18
- package/src/tasks/ReceiveTask.js +59 -38
- package/src/tasks/ScriptTask.js +17 -8
- package/src/tasks/ServiceTask.js +16 -9
- package/src/tasks/SignalTask.js +47 -28
- package/src/tasks/StandardLoopCharacteristics.js +3 -3
- package/src/tasks/SubProcess.js +9 -8
- package/src/tasks/Task.js +4 -3
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +6 -6
- package/types/types.d.ts +39 -35
- package/CHANGELOG.md +0 -459
- package/src/ExtensionsMapper.js +0 -42
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {cloneContent, shiftParent} from '../messageHelper.js';
|
|
2
|
-
import {ActivityError} from '../error/Errors.js';
|
|
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
|
|
|
6
6
|
export default function ConditionalEventDefinition(activity, eventDefinition) {
|
|
7
|
-
const {id, broker, environment, attachedTo} = activity;
|
|
7
|
+
const { id, broker, environment, attachedTo } = activity;
|
|
8
8
|
|
|
9
|
-
const {type = 'ConditionalEventDefinition', behaviour = {}} = eventDefinition;
|
|
9
|
+
const { type = 'ConditionalEventDefinition', behaviour = {} } = eventDefinition;
|
|
10
10
|
|
|
11
11
|
this.id = id;
|
|
12
12
|
this.type = type;
|
|
@@ -32,7 +32,7 @@ ConditionalEventDefinition.prototype.execute = function execute(executeMessage)
|
|
|
32
32
|
|
|
33
33
|
ConditionalEventDefinition.prototype.executeWait = function executeWait(executeMessage) {
|
|
34
34
|
const executeContent = executeMessage.content;
|
|
35
|
-
const {executionId, parent} = executeContent;
|
|
35
|
+
const { executionId, parent } = executeContent;
|
|
36
36
|
const parentExecutionId = parent.executionId;
|
|
37
37
|
|
|
38
38
|
if (this._evaluateWait(executeMessage)) return;
|
|
@@ -59,7 +59,7 @@ ConditionalEventDefinition.prototype.executeWait = function executeWait(executeM
|
|
|
59
59
|
|
|
60
60
|
ConditionalEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
|
|
61
61
|
const executeContent = executeMessage.content;
|
|
62
|
-
const {executionId, index, parent} = executeContent;
|
|
62
|
+
const { executionId, index, parent } = executeContent;
|
|
63
63
|
const parentExecutionId = parent.executionId;
|
|
64
64
|
|
|
65
65
|
const broker = this.broker;
|
|
@@ -68,7 +68,7 @@ ConditionalEventDefinition.prototype.executeCatch = function executeCatch(execut
|
|
|
68
68
|
consumerTag: `_api-${executionId}_${index}`,
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
const {id: attachedToId, broker: attachedToBroker} = this.activity.attachedTo;
|
|
71
|
+
const { id: attachedToId, broker: attachedToBroker } = this.activity.attachedTo;
|
|
72
72
|
|
|
73
73
|
this._debug(`listen for execute completed from <${attachedToId}>`);
|
|
74
74
|
|
|
@@ -95,7 +95,7 @@ ConditionalEventDefinition.prototype._onWaitApiMessage = function onWaitApiMessa
|
|
|
95
95
|
}
|
|
96
96
|
case 'discard': {
|
|
97
97
|
this._stopWait();
|
|
98
|
-
return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content, {state: 'discard'}));
|
|
98
|
+
return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content, { state: 'discard' }));
|
|
99
99
|
}
|
|
100
100
|
case 'stop': {
|
|
101
101
|
return this._stopWait();
|
|
@@ -105,27 +105,37 @@ ConditionalEventDefinition.prototype._onWaitApiMessage = function onWaitApiMessa
|
|
|
105
105
|
|
|
106
106
|
ConditionalEventDefinition.prototype._evaluateWait = function evaluate(message) {
|
|
107
107
|
const executeMessage = this[kExecuteMessage];
|
|
108
|
-
const broker = this.broker,
|
|
108
|
+
const broker = this.broker,
|
|
109
|
+
executeContent = executeMessage.content;
|
|
109
110
|
|
|
110
111
|
try {
|
|
111
112
|
var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
|
|
112
113
|
} catch (err) {
|
|
113
|
-
return broker.publish(
|
|
114
|
+
return broker.publish(
|
|
115
|
+
'execution',
|
|
116
|
+
'execute.error',
|
|
117
|
+
cloneContent(executeContent, { error: new ActivityError(err.message, executeMessage, err) }, { mandatory: true }),
|
|
118
|
+
);
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
this._debug(`condition evaluated to ${!!output}`);
|
|
117
122
|
|
|
118
|
-
broker.publish(
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
broker.publish(
|
|
124
|
+
'event',
|
|
125
|
+
'activity.condition',
|
|
126
|
+
cloneContent(executeContent, {
|
|
127
|
+
conditionResult: output,
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
121
130
|
|
|
122
131
|
if (!output) return;
|
|
123
132
|
this._stopWait();
|
|
124
|
-
return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output}));
|
|
133
|
+
return broker.publish('execution', 'execute.completed', cloneContent(executeContent, { output }));
|
|
125
134
|
};
|
|
126
135
|
|
|
127
136
|
ConditionalEventDefinition.prototype._stopWait = function stopWait() {
|
|
128
|
-
const broker = this.broker,
|
|
137
|
+
const broker = this.broker,
|
|
138
|
+
executionId = this.executionId;
|
|
129
139
|
broker.cancel(`_api-${executionId}`);
|
|
130
140
|
broker.cancel(`_parent-signal-${executionId}`);
|
|
131
141
|
};
|
|
@@ -134,21 +144,30 @@ ConditionalEventDefinition.prototype._onAttachedCompleted = function onAttachedC
|
|
|
134
144
|
this._stopCatch();
|
|
135
145
|
|
|
136
146
|
const executeMessage = this[kExecuteMessage];
|
|
137
|
-
const broker = this.broker,
|
|
147
|
+
const broker = this.broker,
|
|
148
|
+
executeContent = executeMessage.content;
|
|
138
149
|
try {
|
|
139
150
|
var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
|
|
140
151
|
} catch (err) {
|
|
141
|
-
return broker.publish(
|
|
152
|
+
return broker.publish(
|
|
153
|
+
'execution',
|
|
154
|
+
'execute.error',
|
|
155
|
+
cloneContent(executeContent, { error: new ActivityError(err.message, executeMessage, err) }, { mandatory: true }),
|
|
156
|
+
);
|
|
142
157
|
}
|
|
143
158
|
|
|
144
159
|
this._debug(`condition from <${message.content.executionId}> evaluated to ${!!output}`);
|
|
145
160
|
|
|
146
|
-
broker.publish(
|
|
147
|
-
|
|
148
|
-
|
|
161
|
+
broker.publish(
|
|
162
|
+
'event',
|
|
163
|
+
'activity.condition',
|
|
164
|
+
cloneContent(executeContent, {
|
|
165
|
+
conditionResult: output,
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
149
168
|
|
|
150
169
|
if (output) {
|
|
151
|
-
broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output}));
|
|
170
|
+
broker.publish('execution', 'execute.completed', cloneContent(executeContent, { output }));
|
|
152
171
|
}
|
|
153
172
|
};
|
|
154
173
|
|
|
@@ -158,7 +177,7 @@ ConditionalEventDefinition.prototype._onCatchApiMessage = function onCatchApiMes
|
|
|
158
177
|
case 'discard': {
|
|
159
178
|
this._stopCatch();
|
|
160
179
|
this._debug('discarded');
|
|
161
|
-
return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content, {state: 'discard'}));
|
|
180
|
+
return this.broker.publish('execution', 'execute.discard', cloneContent(this[kExecuteMessage].content, { state: 'discard' }));
|
|
162
181
|
}
|
|
163
182
|
case 'stop': {
|
|
164
183
|
this._stopCatch();
|
|
@@ -168,7 +187,7 @@ ConditionalEventDefinition.prototype._onCatchApiMessage = function onCatchApiMes
|
|
|
168
187
|
};
|
|
169
188
|
|
|
170
189
|
ConditionalEventDefinition.prototype._stopCatch = function stopCatch() {
|
|
171
|
-
const {executionId, index} = this[kExecuteMessage].content;
|
|
190
|
+
const { executionId, index } = this[kExecuteMessage].content;
|
|
172
191
|
this.activity.attachedTo.broker.cancel(`_onend-${executionId}_${index}`);
|
|
173
192
|
this.broker.cancel(`_api-${executionId}_${index}`);
|
|
174
193
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {brokerSafeId} from '../shared.js';
|
|
2
|
-
import {cloneContent, shiftParent} from '../messageHelper.js';
|
|
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');
|
|
@@ -8,17 +8,17 @@ const kReferenceElement = Symbol.for('referenceElement');
|
|
|
8
8
|
const kReferenceInfo = Symbol.for('referenceInfo');
|
|
9
9
|
|
|
10
10
|
export default function ErrorEventDefinition(activity, eventDefinition) {
|
|
11
|
-
const {id, broker, environment, isThrowing} = activity;
|
|
12
|
-
const {type = 'ErrorEventDefinition', behaviour = {}} = eventDefinition;
|
|
11
|
+
const { id, broker, environment, isThrowing } = activity;
|
|
12
|
+
const { type = 'ErrorEventDefinition', behaviour = {} } = eventDefinition;
|
|
13
13
|
|
|
14
14
|
this.id = id;
|
|
15
15
|
this.type = type;
|
|
16
16
|
|
|
17
|
-
const reference = this.reference = {
|
|
17
|
+
const reference = (this.reference = {
|
|
18
18
|
name: 'anonymous',
|
|
19
19
|
...behaviour.errorRef,
|
|
20
20
|
referenceType: 'throw',
|
|
21
|
-
};
|
|
21
|
+
});
|
|
22
22
|
|
|
23
23
|
this.isThrowing = isThrowing;
|
|
24
24
|
this.activity = activity;
|
|
@@ -26,13 +26,13 @@ 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[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
|
|
29
|
+
const referenceElement = (this[kReferenceElement] = reference.id && activity.getActivityById(reference.id));
|
|
30
30
|
if (!isThrowing) {
|
|
31
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[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
|
|
35
|
-
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true, priority: 300});
|
|
34
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, { autoDelete: false, durable: true });
|
|
35
|
+
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, { durable: true, priority: 300 });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -52,10 +52,10 @@ ErrorEventDefinition.prototype.executeCatch = function executeCatch(executeMessa
|
|
|
52
52
|
this[kCompleted] = false;
|
|
53
53
|
|
|
54
54
|
const executeContent = executeMessage.content;
|
|
55
|
-
const {executionId, parent} = executeContent;
|
|
55
|
+
const { executionId, parent } = executeContent;
|
|
56
56
|
const parentExecutionId = parent && parent.executionId;
|
|
57
57
|
|
|
58
|
-
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
58
|
+
const info = (this[kReferenceInfo] = this._getReferenceInfo(executeMessage));
|
|
59
59
|
|
|
60
60
|
this[kMessageQ].consume(this._onThrowApiMessage.bind(this), {
|
|
61
61
|
noAck: true,
|
|
@@ -78,19 +78,23 @@ ErrorEventDefinition.prototype.executeCatch = function executeCatch(executeMessa
|
|
|
78
78
|
noAck: true,
|
|
79
79
|
consumerTag: `_onerror-${executionId}`,
|
|
80
80
|
});
|
|
81
|
-
broker.publish(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
broker.publish(
|
|
82
|
+
'execution',
|
|
83
|
+
'execute.expect',
|
|
84
|
+
cloneContent(executeContent, {
|
|
85
|
+
pattern: 'activity.error',
|
|
86
|
+
exchange: 'execution',
|
|
87
|
+
expectRoutingKey,
|
|
88
|
+
expect: { ...info.message },
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
87
91
|
|
|
88
92
|
if (this[kCompleted]) return this._stop();
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
const waitContent = cloneContent(executeContent, {
|
|
92
96
|
executionId: parentExecutionId,
|
|
93
|
-
expect: {...info.message},
|
|
97
|
+
expect: { ...info.message },
|
|
94
98
|
});
|
|
95
99
|
waitContent.parent = shiftParent(parent);
|
|
96
100
|
|
|
@@ -99,7 +103,7 @@ ErrorEventDefinition.prototype.executeCatch = function executeCatch(executeMessa
|
|
|
99
103
|
|
|
100
104
|
ErrorEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
101
105
|
const executeContent = executeMessage.content;
|
|
102
|
-
const {executionId, parent} = executeContent;
|
|
106
|
+
const { executionId, parent } = executeContent;
|
|
103
107
|
|
|
104
108
|
const info = this._getReferenceInfo(executeMessage);
|
|
105
109
|
|
|
@@ -108,16 +112,20 @@ ErrorEventDefinition.prototype.executeThrow = function executeThrow(executeMessa
|
|
|
108
112
|
const broker = this.broker;
|
|
109
113
|
const throwContent = cloneContent(executeContent, {
|
|
110
114
|
executionId: parent.executionId,
|
|
111
|
-
message: {...info.message},
|
|
115
|
+
message: { ...info.message },
|
|
112
116
|
state: 'throw',
|
|
113
117
|
});
|
|
114
118
|
throwContent.parent = shiftParent(parent);
|
|
115
119
|
|
|
116
|
-
this.broker.publish('event', 'activity.throw', throwContent, {type: 'throw', delegate: true});
|
|
120
|
+
this.broker.publish('event', 'activity.throw', throwContent, { type: 'throw', delegate: true });
|
|
117
121
|
|
|
118
|
-
return broker.publish(
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
return broker.publish(
|
|
123
|
+
'execution',
|
|
124
|
+
'execute.completed',
|
|
125
|
+
cloneContent(executeContent, {
|
|
126
|
+
message: { ...info.message },
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
121
129
|
};
|
|
122
130
|
|
|
123
131
|
ErrorEventDefinition.prototype._onErrorMessage = function onErrorMessage(routingKey, message) {
|
|
@@ -127,7 +135,7 @@ ErrorEventDefinition.prototype._onErrorMessage = function onErrorMessage(routing
|
|
|
127
135
|
if (!error) return;
|
|
128
136
|
|
|
129
137
|
const info = this[kReferenceInfo];
|
|
130
|
-
if (
|
|
138
|
+
if ('' + error.code !== '' + info.message.code) return;
|
|
131
139
|
|
|
132
140
|
return this._catchError(routingKey, message, error);
|
|
133
141
|
};
|
|
@@ -162,13 +170,17 @@ ErrorEventDefinition.prototype._catchError = function catchError(routingKey, mes
|
|
|
162
170
|
catchContent.parent = shiftParent(parent);
|
|
163
171
|
|
|
164
172
|
const broker = this.broker;
|
|
165
|
-
broker.publish('event', 'activity.catch', catchContent, {type: 'catch'});
|
|
166
|
-
|
|
167
|
-
return broker.publish(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
broker.publish('event', 'activity.catch', catchContent, { type: 'catch' });
|
|
174
|
+
|
|
175
|
+
return broker.publish(
|
|
176
|
+
'execution',
|
|
177
|
+
'execute.completed',
|
|
178
|
+
cloneContent(executeContent, {
|
|
179
|
+
output: error,
|
|
180
|
+
cancelActivity: true,
|
|
181
|
+
state: 'catch',
|
|
182
|
+
}),
|
|
183
|
+
);
|
|
172
184
|
};
|
|
173
185
|
|
|
174
186
|
ErrorEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
@@ -188,7 +200,8 @@ ErrorEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey,
|
|
|
188
200
|
};
|
|
189
201
|
|
|
190
202
|
ErrorEventDefinition.prototype._stop = function stop() {
|
|
191
|
-
const broker = this.broker,
|
|
203
|
+
const broker = this.broker,
|
|
204
|
+
executionId = this.executionId;
|
|
192
205
|
broker.cancel(`_onthrow-${executionId}`);
|
|
193
206
|
broker.cancel(`_onerror-${executionId}`);
|
|
194
207
|
broker.cancel(`_api-${executionId}`);
|
|
@@ -199,7 +212,7 @@ ErrorEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(mes
|
|
|
199
212
|
const referenceElement = this[kReferenceElement];
|
|
200
213
|
if (!referenceElement) {
|
|
201
214
|
return {
|
|
202
|
-
message: {...this.reference},
|
|
215
|
+
message: { ...this.reference },
|
|
203
216
|
description: 'anonymous error',
|
|
204
217
|
};
|
|
205
218
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import getPropertyValue from '../getPropertyValue.js';
|
|
2
|
-
import {brokerSafeId} from '../shared.js';
|
|
3
|
-
import {cloneContent, shiftParent} from '../messageHelper.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');
|
|
@@ -9,30 +9,30 @@ const kReferenceElement = Symbol.for('referenceElement');
|
|
|
9
9
|
const kReference = Symbol.for('reference');
|
|
10
10
|
|
|
11
11
|
export default function EscalationEventDefinition(activity, eventDefinition) {
|
|
12
|
-
const {id, broker, environment, isThrowing} = activity;
|
|
13
|
-
const {type, behaviour = {}} = eventDefinition;
|
|
12
|
+
const { id, broker, environment, isThrowing } = activity;
|
|
13
|
+
const { type, behaviour = {} } = eventDefinition;
|
|
14
14
|
|
|
15
15
|
this.id = id;
|
|
16
16
|
this.type = type;
|
|
17
17
|
|
|
18
|
-
const reference = this.reference = {
|
|
18
|
+
const reference = (this.reference = {
|
|
19
19
|
name: 'anonymous',
|
|
20
20
|
...behaviour.escalationRef,
|
|
21
21
|
referenceType: 'escalate',
|
|
22
|
-
};
|
|
22
|
+
});
|
|
23
23
|
|
|
24
24
|
this.isThrowing = isThrowing;
|
|
25
25
|
this.activity = activity;
|
|
26
26
|
this.broker = broker;
|
|
27
27
|
this.logger = environment.Logger(type.toLowerCase());
|
|
28
28
|
|
|
29
|
-
const referenceElement = this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
|
|
29
|
+
const referenceElement = (this[kReferenceElement] = reference.id && activity.getActivityById(reference.id));
|
|
30
30
|
if (!isThrowing) {
|
|
31
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[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
|
|
35
|
-
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true, priority: 400});
|
|
34
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, { autoDelete: false, durable: true });
|
|
35
|
+
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, { durable: true, priority: 400 });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -52,9 +52,9 @@ EscalationEventDefinition.prototype.executeCatch = function executeCatch(execute
|
|
|
52
52
|
this[kCompleted] = false;
|
|
53
53
|
|
|
54
54
|
const executeContent = executeMessage.content;
|
|
55
|
-
const {executionId, parent} = executeContent;
|
|
55
|
+
const { executionId, parent } = executeContent;
|
|
56
56
|
|
|
57
|
-
const info = this[kReference] = this._getReferenceInfo(executeMessage);
|
|
57
|
+
const info = (this[kReference] = this._getReferenceInfo(executeMessage));
|
|
58
58
|
const broker = this.broker;
|
|
59
59
|
this[kMessageQ].consume(this._onCatchMessage.bind(this), {
|
|
60
60
|
noAck: true,
|
|
@@ -73,7 +73,7 @@ EscalationEventDefinition.prototype.executeCatch = function executeCatch(execute
|
|
|
73
73
|
const waitContent = cloneContent(executeContent, {
|
|
74
74
|
executionId: parent.executionId,
|
|
75
75
|
parent: shiftParent(parent),
|
|
76
|
-
escalation: {...info.message},
|
|
76
|
+
escalation: { ...info.message },
|
|
77
77
|
});
|
|
78
78
|
waitContent.parent = shiftParent(parent);
|
|
79
79
|
|
|
@@ -82,7 +82,7 @@ EscalationEventDefinition.prototype.executeCatch = function executeCatch(execute
|
|
|
82
82
|
|
|
83
83
|
EscalationEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
84
84
|
const executeContent = executeMessage.content;
|
|
85
|
-
const {executionId, parent} = executeContent;
|
|
85
|
+
const { executionId, parent } = executeContent;
|
|
86
86
|
|
|
87
87
|
const info = this._getReferenceInfo(executeMessage);
|
|
88
88
|
this.logger.debug(`<${executionId} (${this.activity.id})> escalate ${info.description}`);
|
|
@@ -95,7 +95,7 @@ EscalationEventDefinition.prototype.executeThrow = function executeThrow(execute
|
|
|
95
95
|
});
|
|
96
96
|
throwContent.parent = shiftParent(parent);
|
|
97
97
|
|
|
98
|
-
broker.publish('event', 'activity.escalate', throwContent, {type: 'escalate', delegate: true});
|
|
98
|
+
broker.publish('event', 'activity.escalate', throwContent, { type: 'escalate', delegate: true });
|
|
99
99
|
|
|
100
100
|
return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
|
|
101
101
|
};
|
|
@@ -112,17 +112,17 @@ EscalationEventDefinition.prototype._onCatchMessage = function onCatchMessage(ro
|
|
|
112
112
|
this._debug(`caught ${info.description}`);
|
|
113
113
|
|
|
114
114
|
const executeContent = this[kExecuteMessage].content;
|
|
115
|
-
const {parent, ...content} = executeContent;
|
|
115
|
+
const { parent, ...content } = executeContent;
|
|
116
116
|
const catchContent = cloneContent(content, {
|
|
117
|
-
message: {...output},
|
|
117
|
+
message: { ...output },
|
|
118
118
|
executionId: parent.executionId,
|
|
119
119
|
});
|
|
120
120
|
catchContent.parent = shiftParent(parent);
|
|
121
121
|
|
|
122
122
|
const broker = this.broker;
|
|
123
|
-
broker.publish('event', 'activity.catch', catchContent, {type: 'catch'});
|
|
123
|
+
broker.publish('event', 'activity.catch', catchContent, { type: 'catch' });
|
|
124
124
|
|
|
125
|
-
return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output, state: 'catch'}));
|
|
125
|
+
return broker.publish('execution', 'execute.completed', cloneContent(executeContent, { output, state: 'catch' }));
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
EscalationEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
@@ -143,7 +143,8 @@ EscalationEventDefinition.prototype._onApiMessage = function onApiMessage(routin
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
EscalationEventDefinition.prototype._stop = function stop() {
|
|
146
|
-
const broker = this.broker,
|
|
146
|
+
const broker = this.broker,
|
|
147
|
+
executionId = this.executionId;
|
|
147
148
|
broker.cancel(`_api-${executionId}`);
|
|
148
149
|
broker.cancel(`_onescalate-${executionId}`);
|
|
149
150
|
};
|
|
@@ -152,7 +153,7 @@ EscalationEventDefinition.prototype._getReferenceInfo = function getReferenceInf
|
|
|
152
153
|
const referenceElement = this[kReferenceElement];
|
|
153
154
|
if (!referenceElement) {
|
|
154
155
|
return {
|
|
155
|
-
message: {...this.reference},
|
|
156
|
+
message: { ...this.reference },
|
|
156
157
|
description: 'anonymous escalation',
|
|
157
158
|
};
|
|
158
159
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {cloneContent, unshiftParent, shiftParent, cloneParent} from '../messageHelper.js';
|
|
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');
|
|
@@ -50,7 +50,7 @@ EventDefinitionExecution.prototype.execute = function execute(executeMessage) {
|
|
|
50
50
|
priority: 300,
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
broker.publish('execution', 'execute.update', cloneContent(content, {preventComplete: true}));
|
|
53
|
+
broker.publish('execution', 'execute.update', cloneContent(content, { preventComplete: true }));
|
|
54
54
|
|
|
55
55
|
if (executeMessage.fields.redelivered) return;
|
|
56
56
|
|
|
@@ -96,7 +96,7 @@ EventDefinitionExecution.prototype._onExecuteMessage = function onExecuteMessage
|
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
case 'execute.discard': {
|
|
99
|
-
const {executionId, isDefinitionScope} = message.content;
|
|
99
|
+
const { executionId, isDefinitionScope } = message.content;
|
|
100
100
|
if (isDefinitionScope) {
|
|
101
101
|
this._debug(executionId, `event definition ${message.content.type} discarded, index ${message.content.index}`);
|
|
102
102
|
break;
|
|
@@ -109,7 +109,7 @@ EventDefinitionExecution.prototype._onExecuteMessage = function onExecuteMessage
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
EventDefinitionExecution.prototype._complete = function complete(message) {
|
|
112
|
-
const {executionId, type, index, parent} = message.content;
|
|
112
|
+
const { executionId, type, index, parent } = message.content;
|
|
113
113
|
this[kCompleted] = true;
|
|
114
114
|
|
|
115
115
|
this._debug(executionId, `event definition ${type} completed, index ${index}`);
|
|
@@ -121,11 +121,11 @@ EventDefinitionExecution.prototype._complete = function complete(message) {
|
|
|
121
121
|
});
|
|
122
122
|
completeContent.parent = shiftParent(parent);
|
|
123
123
|
|
|
124
|
-
this.broker.publish('execution', this.completedRoutingKey, completeContent, {correlationId: message.properties.correlationId});
|
|
124
|
+
this.broker.publish('execution', this.completedRoutingKey, completeContent, { correlationId: message.properties.correlationId });
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
EventDefinitionExecution.prototype._executeDefinition = function executeDefinition(message) {
|
|
128
|
-
const {executionId, index} = message.content;
|
|
128
|
+
const { executionId, index } = message.content;
|
|
129
129
|
const ed = this.eventDefinitions[index];
|
|
130
130
|
if (!ed) return this.activity.logger.warn(`<${executionId} (${this.id})> found no event definition on index ${index}`);
|
|
131
131
|
this._debug(executionId, `execute event definition ${ed.type}, index ${index}`);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import getPropertyValue from '../getPropertyValue.js';
|
|
2
|
-
import {brokerSafeId} from '../shared.js';
|
|
3
|
-
import {cloneContent, shiftParent} from '../messageHelper.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');
|
|
7
7
|
const kExecuteMessage = Symbol.for('executeMessage');
|
|
8
8
|
|
|
9
9
|
export default function LinkEventDefinition(activity, eventDefinition) {
|
|
10
|
-
const {id, broker, environment, isThrowing} = activity;
|
|
11
|
-
const {type = 'LinkEventDefinition', behaviour} = eventDefinition;
|
|
10
|
+
const { id, broker, environment, isThrowing } = activity;
|
|
11
|
+
const { type = 'LinkEventDefinition', behaviour } = eventDefinition;
|
|
12
12
|
|
|
13
13
|
this.id = id;
|
|
14
14
|
this.type = type;
|
|
15
15
|
|
|
16
|
-
const reference = this.reference = {
|
|
16
|
+
const reference = (this.reference = {
|
|
17
17
|
linkName: behaviour.name,
|
|
18
18
|
referenceType: 'link',
|
|
19
|
-
};
|
|
19
|
+
});
|
|
20
20
|
|
|
21
21
|
this.isThrowing = isThrowing;
|
|
22
22
|
this.activity = activity;
|
|
@@ -26,8 +26,8 @@ export default function LinkEventDefinition(activity, eventDefinition) {
|
|
|
26
26
|
|
|
27
27
|
if (!isThrowing) {
|
|
28
28
|
const messageQueueName = `${reference.referenceType}-${brokerSafeId(id)}-${brokerSafeId(reference.linkName)}-q`;
|
|
29
|
-
this[kMessageQ] = broker.assertQueue(messageQueueName, {autoDelete: false, durable: true});
|
|
30
|
-
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {durable: true});
|
|
29
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, { autoDelete: false, durable: true });
|
|
30
|
+
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, { durable: true });
|
|
31
31
|
} else {
|
|
32
32
|
broker.subscribeTmp('event', 'activity.discard', this._onDiscard.bind(this), {
|
|
33
33
|
noAck: true,
|
|
@@ -52,7 +52,7 @@ LinkEventDefinition.prototype.executeCatch = function executeCatch(executeMessag
|
|
|
52
52
|
this[kCompleted] = false;
|
|
53
53
|
|
|
54
54
|
const executeContent = executeMessage.content;
|
|
55
|
-
const {executionId, parent} = executeContent;
|
|
55
|
+
const { executionId, parent } = executeContent;
|
|
56
56
|
const parentExecutionId = parent.executionId;
|
|
57
57
|
|
|
58
58
|
this[kMessageQ].consume(this._onCatchLink.bind(this), {
|
|
@@ -77,7 +77,7 @@ LinkEventDefinition.prototype.executeCatch = function executeCatch(executeMessag
|
|
|
77
77
|
|
|
78
78
|
const waitContent = cloneContent(executeContent, {
|
|
79
79
|
executionId: parentExecutionId,
|
|
80
|
-
link: {...this.reference},
|
|
80
|
+
link: { ...this.reference },
|
|
81
81
|
});
|
|
82
82
|
waitContent.parent = shiftParent(parent);
|
|
83
83
|
|
|
@@ -86,7 +86,7 @@ LinkEventDefinition.prototype.executeCatch = function executeCatch(executeMessag
|
|
|
86
86
|
|
|
87
87
|
LinkEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
88
88
|
const executeContent = executeMessage.content;
|
|
89
|
-
const {executionId, parent} = executeContent;
|
|
89
|
+
const { executionId, parent } = executeContent;
|
|
90
90
|
const parentExecutionId = parent && parent.executionId;
|
|
91
91
|
|
|
92
92
|
this.logger.debug(`<${executionId} (${this.activity.id})> throw link ${this.reference.linkName}`);
|
|
@@ -94,12 +94,12 @@ LinkEventDefinition.prototype.executeThrow = function executeThrow(executeMessag
|
|
|
94
94
|
const broker = this.broker;
|
|
95
95
|
const linkContent = cloneContent(executeContent, {
|
|
96
96
|
executionId: parentExecutionId,
|
|
97
|
-
message: {...this.reference},
|
|
97
|
+
message: { ...this.reference },
|
|
98
98
|
state: 'throw',
|
|
99
99
|
});
|
|
100
100
|
linkContent.parent = shiftParent(parent);
|
|
101
101
|
|
|
102
|
-
broker.publish('event', 'activity.link', linkContent, {type: 'link', delegate: true});
|
|
102
|
+
broker.publish('event', 'activity.link', linkContent, { type: 'link', delegate: true });
|
|
103
103
|
|
|
104
104
|
return broker.publish('execution', 'execute.completed', cloneContent(executeContent));
|
|
105
105
|
};
|
|
@@ -134,16 +134,16 @@ LinkEventDefinition.prototype._complete = function complete(verb, output) {
|
|
|
134
134
|
const executeContent = this[kExecuteMessage].content;
|
|
135
135
|
const parent = executeContent.parent;
|
|
136
136
|
const catchContent = cloneContent(executeContent, {
|
|
137
|
-
link: {...this.reference},
|
|
138
|
-
message: {...output},
|
|
137
|
+
link: { ...this.reference },
|
|
138
|
+
message: { ...output },
|
|
139
139
|
executionId: parent.executionId,
|
|
140
140
|
});
|
|
141
141
|
catchContent.parent = shiftParent(parent);
|
|
142
142
|
|
|
143
143
|
const broker = this.broker;
|
|
144
|
-
broker.publish('event', 'activity.catch', catchContent, {type: 'catch'});
|
|
144
|
+
broker.publish('event', 'activity.catch', catchContent, { type: 'catch' });
|
|
145
145
|
|
|
146
|
-
return broker.publish('execution', 'execute.completed', cloneContent(executeContent, {output, state: 'catch'}));
|
|
146
|
+
return broker.publish('execution', 'execute.completed', cloneContent(executeContent, { output, state: 'catch' }));
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
LinkEventDefinition.prototype._discard = function discard() {
|
|
@@ -153,7 +153,8 @@ LinkEventDefinition.prototype._discard = function discard() {
|
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
LinkEventDefinition.prototype._stop = function stop() {
|
|
156
|
-
const broker = this.broker,
|
|
156
|
+
const broker = this.broker,
|
|
157
|
+
executionId = this.executionId;
|
|
157
158
|
broker.cancel(`_api-link-${executionId}`);
|
|
158
159
|
broker.cancel(`_api-parent-${executionId}`);
|
|
159
160
|
broker.cancel(`_api-${executionId}`);
|
|
@@ -161,10 +162,15 @@ LinkEventDefinition.prototype._stop = function stop() {
|
|
|
161
162
|
};
|
|
162
163
|
|
|
163
164
|
LinkEventDefinition.prototype._onDiscard = function onDiscard(_, message) {
|
|
164
|
-
this.broker.publish(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
this.broker.publish(
|
|
166
|
+
'event',
|
|
167
|
+
'activity.link.discard',
|
|
168
|
+
cloneContent(message.content, {
|
|
169
|
+
message: { ...this.reference },
|
|
170
|
+
state: 'discard',
|
|
171
|
+
}),
|
|
172
|
+
{ type: 'link', delegate: true },
|
|
173
|
+
);
|
|
168
174
|
};
|
|
169
175
|
|
|
170
176
|
LinkEventDefinition.prototype._debug = function debug(msg) {
|