bpmn-elements 6.0.1 → 8.0.1
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/CHANGELOG.md +341 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +176 -172
- package/dist/src/Environment.js +110 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/activity/Activity.js +1105 -916
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +710 -408
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -100
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +173 -182
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +17 -14
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +33 -29
- package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +117 -124
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +439 -362
- package/dist/src/process/ProcessExecution.js +748 -646
- package/dist/src/shared.js +2 -2
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +193 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +16 -16
- package/src/Api.js +65 -59
- package/src/Context.js +145 -140
- package/src/Environment.js +116 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +914 -776
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +437 -401
- package/src/definition/DefinitionExecution.js +598 -340
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +159 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -112
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +146 -160
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -15
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +29 -18
- package/src/io/EnvironmentDataStoreReference.js +31 -20
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +95 -97
- package/src/process/Process.js +378 -333
- package/src/process/ProcessExecution.js +603 -553
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = ReceiveTask;
|
|
7
6
|
exports.ReceiveTaskBehaviour = ReceiveTaskBehaviour;
|
|
7
|
+
exports.default = ReceiveTask;
|
|
8
8
|
|
|
9
9
|
var _Activity = _interopRequireDefault(require("../activity/Activity"));
|
|
10
10
|
|
|
@@ -12,8 +12,13 @@ var _messageHelper = require("../messageHelper");
|
|
|
12
12
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
|
|
15
|
+
const kCompleted = Symbol.for('completed');
|
|
16
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
17
|
+
const kReferenceElement = Symbol.for('referenceElement');
|
|
18
|
+
const kReferenceInfo = Symbol.for('referenceInfo');
|
|
19
|
+
|
|
15
20
|
function ReceiveTask(activityDef, context) {
|
|
16
|
-
const task =
|
|
21
|
+
const task = new _Activity.default(ReceiveTaskBehaviour, activityDef, context);
|
|
17
22
|
task.broker.assertQueue('message', {
|
|
18
23
|
autoDelete: false,
|
|
19
24
|
durable: true
|
|
@@ -28,205 +33,251 @@ function ReceiveTaskBehaviour(activity) {
|
|
|
28
33
|
const {
|
|
29
34
|
id,
|
|
30
35
|
type,
|
|
31
|
-
|
|
32
|
-
logger,
|
|
33
|
-
behaviour = {},
|
|
34
|
-
getActivityById
|
|
36
|
+
behaviour
|
|
35
37
|
} = activity;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
this.id = id;
|
|
39
|
+
this.type = type;
|
|
40
|
+
const reference = this.reference = {
|
|
41
|
+
name: 'anonymous',
|
|
42
|
+
...behaviour.messageRef,
|
|
43
|
+
referenceType: 'message'
|
|
38
44
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
reference: { ...reference,
|
|
45
|
-
referenceType: 'message'
|
|
46
|
-
},
|
|
47
|
-
execute
|
|
48
|
-
};
|
|
49
|
-
return source;
|
|
45
|
+
this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
|
|
46
|
+
this.activity = activity;
|
|
47
|
+
this.broker = activity.broker;
|
|
48
|
+
this[kReferenceElement] = reference.id && activity.getActivityById(reference.id);
|
|
49
|
+
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
executionId
|
|
55
|
-
} = content;
|
|
56
|
-
if (content.isRootScope) setupMessageHandling(executionId);
|
|
51
|
+
ReceiveTaskBehaviour.prototype.execute = function execute(executeMessage) {
|
|
52
|
+
return new ReceiveTaskExecution(this).execute(executeMessage);
|
|
53
|
+
};
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
function ReceiveTaskExecution(parent) {
|
|
56
|
+
const {
|
|
57
|
+
activity,
|
|
58
|
+
broker,
|
|
59
|
+
loopCharacteristics,
|
|
60
|
+
reference
|
|
61
|
+
} = parent;
|
|
62
|
+
this.id = activity.id;
|
|
63
|
+
this.logger = activity.logger;
|
|
64
|
+
this.reference = reference;
|
|
65
|
+
this.broker = broker;
|
|
66
|
+
this.loopCharacteristics = loopCharacteristics;
|
|
67
|
+
this.referenceElement = parent[kReferenceElement];
|
|
68
|
+
this[kCompleted] = false;
|
|
69
|
+
}
|
|
61
70
|
|
|
62
|
-
|
|
63
|
-
const {
|
|
64
|
-
message: referenceMessage,
|
|
65
|
-
description
|
|
66
|
-
} = resolveReference(executeMessage);
|
|
67
|
-
broker.consume('message', onCatchMessage, {
|
|
68
|
-
noAck: true,
|
|
69
|
-
consumerTag: `_onmessage-${executionId}`
|
|
70
|
-
});
|
|
71
|
-
if (completed) return;
|
|
72
|
-
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
73
|
-
noAck: true,
|
|
74
|
-
consumerTag: `_api-${executionId}`,
|
|
75
|
-
priority: 400
|
|
76
|
-
});
|
|
77
|
-
logger.debug(`<${executionId} (${id})> expect ${description}`);
|
|
78
|
-
broker.publish('event', 'activity.wait', (0, _messageHelper.cloneContent)(content, {
|
|
79
|
-
message: { ...referenceMessage
|
|
80
|
-
}
|
|
81
|
-
}));
|
|
82
|
-
|
|
83
|
-
function onCatchMessage(routingKey, message) {
|
|
84
|
-
const {
|
|
85
|
-
content: delegateContent
|
|
86
|
-
} = message;
|
|
87
|
-
const {
|
|
88
|
-
id: signalId,
|
|
89
|
-
executionId: signalExecutionId
|
|
90
|
-
} = delegateContent.message || {};
|
|
91
|
-
|
|
92
|
-
if (!referenceMessage.id && signalId || signalExecutionId) {
|
|
93
|
-
if (loopCharacteristics && signalExecutionId !== executionId) return;
|
|
94
|
-
if (signalId !== id && signalExecutionId !== executionId) return;
|
|
95
|
-
logger.debug(`<${executionId} (${id})> caught direct message`);
|
|
96
|
-
} else if (referenceMessage.id !== signalId) return;else {
|
|
97
|
-
logger.debug(`<${executionId} (${id})> caught ${description}`);
|
|
98
|
-
}
|
|
71
|
+
const proto = ReceiveTaskExecution.prototype;
|
|
99
72
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
correlationId,
|
|
109
|
-
type: messageType
|
|
110
|
-
});
|
|
111
|
-
broker.publish('event', 'activity.catch', (0, _messageHelper.cloneContent)(content, {
|
|
112
|
-
message: message.content.message
|
|
113
|
-
}), {
|
|
114
|
-
type: 'catch',
|
|
115
|
-
correlationId
|
|
116
|
-
});
|
|
117
|
-
complete(message.content.message, {
|
|
118
|
-
correlationId
|
|
119
|
-
});
|
|
120
|
-
}
|
|
73
|
+
proto.execute = function execute(executeMessage) {
|
|
74
|
+
this[kExecuteMessage] = executeMessage;
|
|
75
|
+
const executeContent = executeMessage.content;
|
|
76
|
+
const {
|
|
77
|
+
executionId,
|
|
78
|
+
isRootScope
|
|
79
|
+
} = executeContent;
|
|
80
|
+
this.executionId = executionId;
|
|
121
81
|
|
|
122
|
-
|
|
123
|
-
const {
|
|
124
|
-
type: messageType,
|
|
125
|
-
correlationId
|
|
126
|
-
} = message.properties;
|
|
127
|
-
|
|
128
|
-
switch (messageType) {
|
|
129
|
-
case 'message':
|
|
130
|
-
case 'signal':
|
|
131
|
-
{
|
|
132
|
-
return complete(message.content.message, {
|
|
133
|
-
correlationId
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
case 'discard':
|
|
138
|
-
{
|
|
139
|
-
completed = true;
|
|
140
|
-
stop();
|
|
141
|
-
return broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(content), {
|
|
142
|
-
correlationId
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
case 'stop':
|
|
147
|
-
{
|
|
148
|
-
return stop();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
82
|
+
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
152
83
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
|
|
157
|
-
output
|
|
158
|
-
}), options);
|
|
159
|
-
}
|
|
84
|
+
if (isRootScope) {
|
|
85
|
+
this._setupMessageHandling(executionId);
|
|
86
|
+
}
|
|
160
87
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
88
|
+
const loopCharacteristics = this.loopCharacteristics;
|
|
89
|
+
|
|
90
|
+
if (loopCharacteristics && executeMessage.content.isRootScope) {
|
|
91
|
+
return loopCharacteristics.execute(executeMessage);
|
|
165
92
|
}
|
|
166
93
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
noAck: true
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
function onDelegateMessage(_, message) {
|
|
187
|
-
if (!message.properties.delegate) return;
|
|
188
|
-
broker.sendToQueue('message', message.content, message.properties);
|
|
94
|
+
const broker = this.broker;
|
|
95
|
+
broker.consume('message', this._onCatchMessage.bind(this), {
|
|
96
|
+
noAck: true,
|
|
97
|
+
consumerTag: `_onmessage-${executionId}`
|
|
98
|
+
});
|
|
99
|
+
if (this[kCompleted]) return;
|
|
100
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
101
|
+
noAck: true,
|
|
102
|
+
consumerTag: `_api-${executionId}`,
|
|
103
|
+
priority: 400
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
this._debug(`expect ${info.description}`);
|
|
107
|
+
|
|
108
|
+
broker.publish('event', 'activity.wait', (0, _messageHelper.cloneContent)(executeContent, {
|
|
109
|
+
message: { ...info.message
|
|
189
110
|
}
|
|
111
|
+
}));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
proto._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
115
|
+
const content = message.content;
|
|
116
|
+
const {
|
|
117
|
+
id: signalId,
|
|
118
|
+
executionId: signalExecutionId
|
|
119
|
+
} = content.message || {};
|
|
120
|
+
const {
|
|
121
|
+
message: referenceMessage,
|
|
122
|
+
description
|
|
123
|
+
} = this[kReferenceInfo];
|
|
190
124
|
|
|
191
|
-
|
|
192
|
-
|
|
125
|
+
if (!referenceMessage.id && signalId || signalExecutionId) {
|
|
126
|
+
if (this.loopCharacteristics && signalExecutionId !== this.executionId) return;
|
|
127
|
+
if (signalId !== this.id && signalExecutionId !== this.executionId) return;
|
|
128
|
+
|
|
129
|
+
this._debug('caught direct message');
|
|
130
|
+
} else if (referenceMessage.id !== signalId) return;else {
|
|
131
|
+
this._debug(`caught ${description}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const {
|
|
135
|
+
type: messageType,
|
|
136
|
+
correlationId
|
|
137
|
+
} = message.properties;
|
|
138
|
+
const broker = this.broker;
|
|
139
|
+
const executeContent = this[kExecuteMessage].content;
|
|
140
|
+
broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
141
|
+
message: { ...message.content.message
|
|
193
142
|
}
|
|
143
|
+
}), {
|
|
144
|
+
correlationId,
|
|
145
|
+
type: messageType
|
|
146
|
+
});
|
|
147
|
+
broker.publish('event', 'activity.catch', (0, _messageHelper.cloneContent)(executeContent, {
|
|
148
|
+
message: message.content.message
|
|
149
|
+
}), {
|
|
150
|
+
type: 'catch',
|
|
151
|
+
correlationId
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
this._complete(message.content.message, {
|
|
155
|
+
correlationId
|
|
156
|
+
});
|
|
157
|
+
};
|
|
194
158
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
159
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
160
|
+
const {
|
|
161
|
+
type: messageType,
|
|
162
|
+
correlationId
|
|
163
|
+
} = message.properties;
|
|
164
|
+
|
|
165
|
+
switch (messageType) {
|
|
166
|
+
case 'message':
|
|
167
|
+
case 'signal':
|
|
168
|
+
{
|
|
169
|
+
return this._complete(message.content.message, {
|
|
170
|
+
correlationId
|
|
171
|
+
});
|
|
206
172
|
}
|
|
207
|
-
}
|
|
208
173
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
174
|
+
case 'discard':
|
|
175
|
+
{
|
|
176
|
+
this[kCompleted] = true;
|
|
177
|
+
|
|
178
|
+
this._stop();
|
|
179
|
+
|
|
180
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content), {
|
|
181
|
+
correlationId
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
case 'stop':
|
|
186
|
+
{
|
|
187
|
+
return this._stop();
|
|
188
|
+
}
|
|
215
189
|
}
|
|
190
|
+
};
|
|
216
191
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
192
|
+
proto._complete = function complete(output, options) {
|
|
193
|
+
this[kCompleted] = true;
|
|
194
|
+
|
|
195
|
+
this._stop();
|
|
196
|
+
|
|
197
|
+
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
198
|
+
output
|
|
199
|
+
}), options);
|
|
200
|
+
};
|
|
225
201
|
|
|
226
|
-
|
|
227
|
-
|
|
202
|
+
proto._stop = function stop() {
|
|
203
|
+
const broker = this.broker,
|
|
204
|
+
executionId = this.executionId;
|
|
205
|
+
broker.cancel(`_onmessage-${executionId}`);
|
|
206
|
+
broker.cancel(`_api-${executionId}`);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
proto._setupMessageHandling = function setupMessageHandling(executionId) {
|
|
210
|
+
const broker = this.broker;
|
|
211
|
+
broker.subscribeTmp('api', '#.signal.*', this._onDelegateMessage.bind(this), {
|
|
212
|
+
noAck: true,
|
|
213
|
+
consumerTag: `_api-delegated-${executionId}`
|
|
214
|
+
}, {
|
|
215
|
+
noAck: true
|
|
216
|
+
});
|
|
217
|
+
broker.subscribeTmp('api', `activity.stop.${executionId}`, this._onStopApiMessage.bind(this), {
|
|
218
|
+
noAck: true,
|
|
219
|
+
consumerTag: `_api-stop-${executionId}`,
|
|
220
|
+
priority: 400
|
|
221
|
+
});
|
|
222
|
+
broker.subscribeTmp('execution', 'execute.#', this._onExecutionComplete.bind(this), {
|
|
223
|
+
noAck: true,
|
|
224
|
+
consumerTag: `_execution-complete-${executionId}`
|
|
225
|
+
}, {
|
|
226
|
+
noAck: true
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
proto._onDelegateMessage = function onDelegateMessage(_, message) {
|
|
231
|
+
if (!message.properties.delegate) return;
|
|
232
|
+
this.broker.sendToQueue('message', message.content, message.properties);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
proto._onStopApiMessage = function onStopApiMessage() {
|
|
236
|
+
this._stopMessageHandling(true);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
proto._onExecutionComplete = function onExecutionComplete(routingKey, {
|
|
240
|
+
content
|
|
241
|
+
}) {
|
|
242
|
+
if (!content.isRootScope) return;
|
|
243
|
+
|
|
244
|
+
switch (routingKey) {
|
|
245
|
+
case 'execute.completed':
|
|
246
|
+
case 'execute.error':
|
|
247
|
+
case 'execute.discard':
|
|
248
|
+
this._stopMessageHandling();
|
|
249
|
+
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
proto._stopMessageHandling = function stop(keepMessageQ) {
|
|
255
|
+
const broker = this.broker,
|
|
256
|
+
executionId = this.executionId;
|
|
257
|
+
broker.cancel(`_api-delegated-${executionId}`);
|
|
258
|
+
broker.cancel(`_api-stop-${executionId}`);
|
|
259
|
+
broker.cancel(`_execution-complete-${executionId}`);
|
|
260
|
+
if (!keepMessageQ) broker.purgeQueue('message');
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
proto._getReferenceInfo = function getReferenceInfo(message) {
|
|
264
|
+
const referenceElement = this.referenceElement;
|
|
265
|
+
|
|
266
|
+
if (!referenceElement) {
|
|
267
|
+
return {
|
|
268
|
+
message: { ...this.reference
|
|
269
|
+
},
|
|
270
|
+
description: 'anonymous message'
|
|
228
271
|
};
|
|
229
|
-
result.description = `${result.message.name} <${result.message.id}>`;
|
|
230
|
-
return result;
|
|
231
272
|
}
|
|
232
|
-
|
|
273
|
+
|
|
274
|
+
const result = {
|
|
275
|
+
message: referenceElement.resolve(message)
|
|
276
|
+
};
|
|
277
|
+
result.description = `${result.message.name} <${result.message.id}>`;
|
|
278
|
+
return result;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
proto._debug = function debug(msg) {
|
|
282
|
+
this.logger.debug(`<${this.executionId} (${this.id})> ${msg}`);
|
|
283
|
+
};
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = ScriptTask;
|
|
7
6
|
exports.ScriptTaskBehaviour = ScriptTaskBehaviour;
|
|
7
|
+
exports.default = ScriptTask;
|
|
8
8
|
|
|
9
9
|
var _Activity = _interopRequireDefault(require("../activity/Activity"));
|
|
10
10
|
|
|
@@ -17,60 +17,54 @@ var _messageHelper = require("../messageHelper");
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
|
|
19
19
|
function ScriptTask(activityDef, context) {
|
|
20
|
-
return
|
|
20
|
+
return new _Activity.default(ScriptTaskBehaviour, activityDef, context);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function ScriptTaskBehaviour(activity) {
|
|
24
24
|
const {
|
|
25
25
|
id,
|
|
26
26
|
type,
|
|
27
|
-
behaviour
|
|
28
|
-
broker,
|
|
29
|
-
logger,
|
|
30
|
-
environment,
|
|
31
|
-
emitFatal
|
|
27
|
+
behaviour
|
|
32
28
|
} = activity;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
this.id = id;
|
|
30
|
+
this.type = type;
|
|
31
|
+
this.scriptFormat = behaviour.scriptFormat;
|
|
32
|
+
this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
|
|
33
|
+
this.activity = activity;
|
|
34
|
+
const environment = this.environment = activity.environment;
|
|
37
35
|
environment.registerScript(activity);
|
|
38
|
-
|
|
39
|
-
id,
|
|
40
|
-
type,
|
|
41
|
-
loopCharacteristics,
|
|
42
|
-
execute
|
|
43
|
-
};
|
|
44
|
-
return source;
|
|
45
|
-
|
|
46
|
-
function execute(executeMessage) {
|
|
47
|
-
const content = executeMessage.content;
|
|
36
|
+
}
|
|
48
37
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
ScriptTaskBehaviour.prototype.execute = function execute(executeMessage) {
|
|
39
|
+
const executeContent = executeMessage.content;
|
|
40
|
+
const loopCharacteristics = this.loopCharacteristics;
|
|
52
41
|
|
|
53
|
-
|
|
42
|
+
if (loopCharacteristics && executeContent.isRootScope) {
|
|
43
|
+
return loopCharacteristics.execute(executeMessage);
|
|
44
|
+
}
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
const activity = this.activity,
|
|
47
|
+
scriptFormat = this.scriptFormat;
|
|
48
|
+
const script = this.environment.getScript(scriptFormat, activity, (0, _messageHelper.cloneMessage)(executeMessage));
|
|
58
49
|
|
|
59
|
-
|
|
50
|
+
if (!script) {
|
|
51
|
+
return activity.emitFatal(new _Errors.ActivityError(`Script format ${scriptFormat} is unsupported or was not registered for <${activity.id}>`, executeMessage), executeContent);
|
|
52
|
+
}
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
if (err) {
|
|
63
|
-
logger.error(`<${content.executionId} (${id})>`, err);
|
|
64
|
-
return broker.publish('execution', 'execute.error', (0, _messageHelper.cloneContent)(content, {
|
|
65
|
-
error: new _Errors.ActivityError(err.message, executeMessage, err)
|
|
66
|
-
}, {
|
|
67
|
-
mandatory: true
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
54
|
+
return script.execute((0, _ExecutionScope.default)(activity, executeMessage), scriptCallback);
|
|
70
55
|
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
function scriptCallback(err, output) {
|
|
57
|
+
if (err) {
|
|
58
|
+
activity.logger.error(`<${executeContent.executionId} (${activity.id})>`, err);
|
|
59
|
+
return activity.broker.publish('execution', 'execute.error', (0, _messageHelper.cloneContent)(executeContent, {
|
|
60
|
+
error: new _Errors.ActivityError(err.message, executeMessage, err)
|
|
61
|
+
}, {
|
|
62
|
+
mandatory: true
|
|
73
63
|
}));
|
|
74
64
|
}
|
|
65
|
+
|
|
66
|
+
return activity.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
67
|
+
output
|
|
68
|
+
}));
|
|
75
69
|
}
|
|
76
|
-
}
|
|
70
|
+
};
|
|
@@ -10,24 +10,17 @@ var _ExecutionScope = _interopRequireDefault(require("../activity/ExecutionScope
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
12
|
function ServiceImplementation(activity) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} = activity;
|
|
18
|
-
const implementation = behaviour.implementation;
|
|
19
|
-
const type = `${atype}:implementation`;
|
|
20
|
-
return {
|
|
21
|
-
type,
|
|
22
|
-
implementation,
|
|
23
|
-
execute
|
|
24
|
-
};
|
|
13
|
+
this.type = `${activity.type}:implementation`;
|
|
14
|
+
this.implementation = activity.behaviour.implementation;
|
|
15
|
+
this.activity = activity;
|
|
16
|
+
}
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
18
|
+
ServiceImplementation.prototype.execute = function execute(executionMessage, callback) {
|
|
19
|
+
const activity = this.activity;
|
|
20
|
+
const implementation = this.implementation;
|
|
21
|
+
const serviceFn = activity.environment.resolveExpression(implementation, executionMessage);
|
|
22
|
+
if (typeof serviceFn !== 'function') return callback(new Error(`Implementation ${implementation} did not resolve to a function`));
|
|
23
|
+
serviceFn.call(activity, (0, _ExecutionScope.default)(activity, executionMessage), (err, ...args) => {
|
|
24
|
+
callback(err, args);
|
|
25
|
+
});
|
|
26
|
+
};
|