bpmn-elements 8.2.0 → 8.2.2
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 +8 -0
- package/dist/index.js +0 -49
- package/dist/src/Api.js +4 -19
- package/dist/src/Context.js +0 -35
- package/dist/src/Environment.js +18 -44
- package/dist/src/EventBroker.js +8 -27
- package/dist/src/Expressions.js +0 -13
- package/dist/src/ExtensionsMapper.js +0 -12
- package/dist/src/MessageFormatter.js +0 -33
- package/dist/src/Scripts.js +2 -9
- package/dist/src/Timers.js +0 -9
- package/dist/src/activity/Activity.js +39 -243
- package/dist/src/activity/ActivityExecution.js +8 -76
- package/dist/src/activity/Dummy.js +2 -3
- package/dist/src/activity/Escalation.js +4 -4
- package/dist/src/activity/ExecutionScope.js +0 -4
- package/dist/src/activity/Message.js +4 -4
- package/dist/src/activity/Signal.js +4 -4
- package/dist/src/definition/Definition.js +12 -133
- package/dist/src/definition/DefinitionExecution.js +10 -160
- package/dist/src/error/BpmnError.js +2 -3
- package/dist/src/error/Errors.js +0 -16
- package/dist/src/eventDefinitions/CancelEventDefinition.js +2 -35
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +3 -34
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +3 -42
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +11 -41
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +7 -37
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +0 -30
- package/dist/src/eventDefinitions/LinkEventDefinition.js +11 -37
- package/dist/src/eventDefinitions/MessageEventDefinition.js +11 -44
- package/dist/src/eventDefinitions/SignalEventDefinition.js +9 -46
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +0 -3
- package/dist/src/eventDefinitions/TimerEventDefinition.js +8 -52
- package/dist/src/events/BoundaryEvent.js +4 -44
- package/dist/src/events/EndEvent.js +2 -11
- package/dist/src/events/IntermediateCatchEvent.js +0 -13
- package/dist/src/events/IntermediateThrowEvent.js +2 -11
- package/dist/src/events/StartEvent.js +5 -25
- package/dist/src/flows/Association.js +4 -27
- package/dist/src/flows/MessageFlow.js +6 -18
- package/dist/src/flows/SequenceFlow.js +4 -39
- package/dist/src/gateways/EventBasedGateway.js +0 -21
- package/dist/src/gateways/ExclusiveGateway.js +0 -6
- package/dist/src/gateways/InclusiveGateway.js +0 -6
- package/dist/src/gateways/ParallelGateway.js +2 -7
- package/dist/src/getPropertyValue.js +0 -30
- package/dist/src/io/BpmnIO.js +2 -7
- package/dist/src/io/EnvironmentDataObject.js +0 -8
- package/dist/src/io/EnvironmentDataStore.js +0 -8
- package/dist/src/io/EnvironmentDataStoreReference.js +0 -8
- package/dist/src/io/InputOutputSpecification.js +12 -37
- package/dist/src/io/Properties.js +6 -39
- package/dist/src/messageHelper.js +10 -23
- package/dist/src/process/Process.js +10 -112
- package/dist/src/process/ProcessExecution.js +24 -170
- package/dist/src/shared.js +0 -7
- package/dist/src/tasks/CallActivity.js +2 -23
- package/dist/src/tasks/LoopCharacteristics.js +16 -67
- package/dist/src/tasks/ReceiveTask.js +8 -48
- package/dist/src/tasks/ScriptTask.js +1 -15
- package/dist/src/tasks/ServiceImplementation.js +0 -4
- package/dist/src/tasks/ServiceTask.js +0 -20
- package/dist/src/tasks/SignalTask.js +2 -21
- package/dist/src/tasks/StandardLoopCharacteristics.js +4 -5
- package/dist/src/tasks/SubProcess.js +4 -52
- package/dist/src/tasks/Task.js +0 -8
- package/dist/src/tasks/Transaction.js +0 -3
- package/package.json +7 -7
- package/src/Context.js +0 -1
- package/src/activity/Activity.js +1 -1
- package/src/gateways/EventBasedGateway.js +0 -1
- package/src/io/InputOutputSpecification.js +0 -1
- package/src/process/ProcessExecution.js +8 -1
- package/src/tasks/StandardLoopCharacteristics.js +0 -1
package/dist/src/shared.js
CHANGED
|
@@ -9,19 +9,15 @@ exports.generateId = generateId;
|
|
|
9
9
|
exports.getOptionsAndCallback = getOptionsAndCallback;
|
|
10
10
|
exports.getUniqueId = getUniqueId;
|
|
11
11
|
const safePattern = /[./\\#*:\s]/g;
|
|
12
|
-
|
|
13
12
|
function generateId() {
|
|
14
13
|
return Math.random().toString(16).substring(2, 12);
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
function brokerSafeId(id) {
|
|
18
16
|
return id.replace(safePattern, '_');
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
function getUniqueId(prefix) {
|
|
22
19
|
return `${brokerSafeId(prefix)}_${generateId()}`;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
function filterUndefined(obj) {
|
|
26
22
|
return Object.keys(obj).reduce((filtered, key) => {
|
|
27
23
|
const objValue = obj[key];
|
|
@@ -29,15 +25,12 @@ function filterUndefined(obj) {
|
|
|
29
25
|
return filtered;
|
|
30
26
|
}, {});
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
function getOptionsAndCallback(optionsOrCallback, callback) {
|
|
34
29
|
let options;
|
|
35
|
-
|
|
36
30
|
if (typeof optionsOrCallback === 'function') {
|
|
37
31
|
callback = optionsOrCallback;
|
|
38
32
|
} else {
|
|
39
33
|
options = optionsOrCallback;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return [options, callback];
|
|
43
36
|
}
|
|
@@ -5,19 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.CallActivityBehaviour = CallActivityBehaviour;
|
|
7
7
|
exports.default = CallActivity;
|
|
8
|
-
|
|
9
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity"));
|
|
10
|
-
|
|
11
9
|
var _Errors = require("../error/Errors");
|
|
12
|
-
|
|
13
10
|
var _messageHelper = require("../messageHelper");
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
12
|
function CallActivity(activityDef, context) {
|
|
18
13
|
return new _Activity.default(CallActivityBehaviour, activityDef, context);
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
function CallActivityBehaviour(activity) {
|
|
22
16
|
const {
|
|
23
17
|
id,
|
|
@@ -32,19 +26,14 @@ function CallActivityBehaviour(activity) {
|
|
|
32
26
|
this.broker = activity.broker;
|
|
33
27
|
this.environment = activity.environment;
|
|
34
28
|
}
|
|
35
|
-
|
|
36
29
|
const proto = CallActivityBehaviour.prototype;
|
|
37
|
-
|
|
38
30
|
proto.execute = function execute(executeMessage) {
|
|
39
31
|
const executeContent = executeMessage.content;
|
|
40
32
|
const loopCharacteristics = this.loopCharacteristics;
|
|
41
|
-
|
|
42
33
|
if (loopCharacteristics && executeContent.isRootScope) {
|
|
43
34
|
return loopCharacteristics.execute(executeMessage);
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
const broker = this.broker;
|
|
47
|
-
|
|
48
37
|
try {
|
|
49
38
|
var calledElement = this.environment.resolveExpression(this.calledElement); // eslint-disable-line no-var
|
|
50
39
|
} catch (err) {
|
|
@@ -54,7 +43,6 @@ proto.execute = function execute(executeMessage) {
|
|
|
54
43
|
mandatory: true
|
|
55
44
|
}));
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
const executionId = executeContent.executionId;
|
|
59
47
|
broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => {
|
|
60
48
|
this._onApiMessage(calledElement, executeMessage, ...args);
|
|
@@ -74,7 +62,6 @@ proto.execute = function execute(executeMessage) {
|
|
|
74
62
|
type: 'call'
|
|
75
63
|
});
|
|
76
64
|
};
|
|
77
|
-
|
|
78
65
|
proto._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, executeMessage, routingKey, message) {
|
|
79
66
|
if (!message.properties.delegate) return;
|
|
80
67
|
const {
|
|
@@ -93,7 +80,8 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, exe
|
|
|
93
80
|
correlationId
|
|
94
81
|
} = message.properties;
|
|
95
82
|
this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
96
|
-
message: {
|
|
83
|
+
message: {
|
|
84
|
+
...delegateContent.message
|
|
97
85
|
}
|
|
98
86
|
}), {
|
|
99
87
|
correlationId,
|
|
@@ -101,18 +89,15 @@ proto._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, exe
|
|
|
101
89
|
});
|
|
102
90
|
return this._onApiMessage(calledElement, executeMessage, routingKey, message);
|
|
103
91
|
};
|
|
104
|
-
|
|
105
92
|
proto._onApiMessage = function onApiMessage(calledElement, executeMessage, routingKey, message) {
|
|
106
93
|
const {
|
|
107
94
|
type: messageType,
|
|
108
95
|
correlationId
|
|
109
96
|
} = message.properties;
|
|
110
97
|
const executeContent = executeMessage.content;
|
|
111
|
-
|
|
112
98
|
switch (messageType) {
|
|
113
99
|
case 'stop':
|
|
114
100
|
return this._stop(executeContent.executionId);
|
|
115
|
-
|
|
116
101
|
case 'cancel':
|
|
117
102
|
{
|
|
118
103
|
this.broker.publish('event', 'activity.call.cancel', (0, _messageHelper.cloneContent)(executeContent, {
|
|
@@ -122,27 +107,22 @@ proto._onApiMessage = function onApiMessage(calledElement, executeMessage, routi
|
|
|
122
107
|
type: 'cancel'
|
|
123
108
|
});
|
|
124
109
|
}
|
|
125
|
-
|
|
126
110
|
case 'signal':
|
|
127
111
|
this._stop(executeContent.executionId);
|
|
128
|
-
|
|
129
112
|
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
130
113
|
output: message.content.message,
|
|
131
114
|
state: messageType
|
|
132
115
|
}), {
|
|
133
116
|
correlationId
|
|
134
117
|
});
|
|
135
|
-
|
|
136
118
|
case 'error':
|
|
137
119
|
this._stop(executeContent.executionId);
|
|
138
|
-
|
|
139
120
|
return this.broker.publish('execution', 'execute.error', (0, _messageHelper.cloneContent)(executeContent, {
|
|
140
121
|
error: new _Errors.ActivityError(message.content.message, executeMessage, message.content)
|
|
141
122
|
}, {
|
|
142
123
|
mandatory: true,
|
|
143
124
|
correlationId
|
|
144
125
|
}));
|
|
145
|
-
|
|
146
126
|
case 'discard':
|
|
147
127
|
return this.broker.publish('event', 'activity.call.cancel', (0, _messageHelper.cloneContent)(executeContent, {
|
|
148
128
|
state: 'discard',
|
|
@@ -152,7 +132,6 @@ proto._onApiMessage = function onApiMessage(calledElement, executeMessage, routi
|
|
|
152
132
|
});
|
|
153
133
|
}
|
|
154
134
|
};
|
|
155
|
-
|
|
156
135
|
proto._stop = function stop(executionId) {
|
|
157
136
|
const broker = this.broker;
|
|
158
137
|
broker.cancel(`_api-${executionId}`);
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = LoopCharacteristics;
|
|
7
|
-
|
|
8
7
|
var _Errors = require("../error/Errors");
|
|
9
|
-
|
|
10
8
|
var _messageHelper = require("../messageHelper");
|
|
11
|
-
|
|
12
9
|
function LoopCharacteristics(activity, loopCharacteristics) {
|
|
13
10
|
this.activity = activity;
|
|
14
11
|
this.loopCharacteristics = loopCharacteristics;
|
|
@@ -26,24 +23,19 @@ function LoopCharacteristics(activity, loopCharacteristics) {
|
|
|
26
23
|
let completionCondition, startCondition, loopCardinality;
|
|
27
24
|
if ('loopCardinality' in behaviour) loopCardinality = behaviour.loopCardinality;else if ('loopMaximum' in behaviour) loopCardinality = behaviour.loopMaximum;
|
|
28
25
|
this.loopCardinality = loopCardinality;
|
|
29
|
-
|
|
30
26
|
if (behaviour.loopCondition) {
|
|
31
27
|
if (behaviour.testBefore) startCondition = behaviour.loopCondition;else completionCondition = behaviour.loopCondition;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
if (behaviour.completionCondition) {
|
|
35
30
|
completionCondition = behaviour.completionCondition;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
if (collection) {
|
|
39
33
|
this.loopType = 'collection';
|
|
40
34
|
this.elementVariable = behaviour.elementVariable || 'item';
|
|
41
35
|
} else if (completionCondition) this.loopType = 'complete condition';else if (startCondition) this.loopType = 'start condition';else if (loopCardinality) this.loopType = 'cardinality';
|
|
42
|
-
|
|
43
36
|
this.characteristics = null;
|
|
44
37
|
this.execution = null;
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
LoopCharacteristics.prototype.execute = function execute(executeMessage) {
|
|
48
40
|
if (!executeMessage) throw new TypeError('LoopCharacteristics execution requires message');
|
|
49
41
|
const chr = this.characteristics = this.characteristics || new Characteristics(this.activity, this.loopCharacteristics, executeMessage);
|
|
@@ -51,61 +43,53 @@ LoopCharacteristics.prototype.execute = function execute(executeMessage) {
|
|
|
51
43
|
const execution = this.isSequential ? new SequentialLoopCharacteristics(this.activity, chr) : new ParallelLoopCharacteristics(this.activity, chr);
|
|
52
44
|
return execution.execute(executeMessage);
|
|
53
45
|
};
|
|
54
|
-
|
|
55
46
|
function SequentialLoopCharacteristics(activity, characteristics) {
|
|
56
47
|
this.activity = activity;
|
|
57
48
|
this.id = activity.id;
|
|
58
49
|
this.characteristics = characteristics;
|
|
59
50
|
}
|
|
60
|
-
|
|
61
51
|
SequentialLoopCharacteristics.prototype.execute = function execute(executeMessage) {
|
|
62
52
|
const {
|
|
63
53
|
routingKey: executeRoutingKey,
|
|
64
54
|
redelivered: isRedelivered
|
|
65
55
|
} = executeMessage.fields || {};
|
|
66
56
|
const chr = this.characteristics;
|
|
67
|
-
|
|
68
57
|
if (!chr.cardinality && !chr.startCondition && !chr.completionCondition) {
|
|
69
58
|
throw new _Errors.RunError(`<${this.id}> cardinality, collection, or condition is required in sequential loops`, executeMessage);
|
|
70
59
|
}
|
|
71
|
-
|
|
72
60
|
let startIndex = 0;
|
|
73
|
-
|
|
74
61
|
if (isRedelivered && executeRoutingKey === 'execute.iteration.next') {
|
|
75
62
|
startIndex = executeMessage.content.index;
|
|
76
63
|
}
|
|
77
|
-
|
|
78
64
|
chr.subscribe(this._onCompleteMessage.bind(this));
|
|
79
65
|
return this._startNext(startIndex, isRedelivered);
|
|
80
66
|
};
|
|
81
|
-
|
|
82
67
|
SequentialLoopCharacteristics.prototype._startNext = function startNext(index, ignoreIfExecuting) {
|
|
83
68
|
const chr = this.characteristics;
|
|
84
69
|
const content = chr.next(index);
|
|
85
70
|
if (!content) return;
|
|
86
|
-
|
|
87
71
|
if (chr.isStartConditionMet({
|
|
88
72
|
content
|
|
89
73
|
})) {
|
|
90
74
|
chr.debug('start condition met');
|
|
91
75
|
return;
|
|
92
76
|
}
|
|
93
|
-
|
|
94
77
|
chr.debug(`${ignoreIfExecuting ? 'resume' : 'start'} sequential iteration index ${content.index}`);
|
|
95
78
|
const broker = this.activity.broker;
|
|
96
|
-
broker.publish('execution', 'execute.iteration.next', {
|
|
79
|
+
broker.publish('execution', 'execute.iteration.next', {
|
|
80
|
+
...content,
|
|
97
81
|
...chr.getContent(),
|
|
98
82
|
index,
|
|
99
83
|
preventComplete: true,
|
|
100
84
|
output: chr.output.slice(),
|
|
101
85
|
state: 'iteration.next'
|
|
102
86
|
});
|
|
103
|
-
broker.publish('execution', 'execute.start', {
|
|
87
|
+
broker.publish('execution', 'execute.start', {
|
|
88
|
+
...content,
|
|
104
89
|
ignoreIfExecuting
|
|
105
90
|
});
|
|
106
91
|
return content;
|
|
107
92
|
};
|
|
108
|
-
|
|
109
93
|
SequentialLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMessage(_, message) {
|
|
110
94
|
const {
|
|
111
95
|
content
|
|
@@ -113,21 +97,19 @@ SequentialLoopCharacteristics.prototype._onCompleteMessage = function onComplete
|
|
|
113
97
|
const chr = this.characteristics;
|
|
114
98
|
const loopOutput = chr.output;
|
|
115
99
|
if (content.output !== undefined) loopOutput[content.index] = content.output;
|
|
116
|
-
this.activity.broker.publish('execution', 'execute.iteration.completed', {
|
|
100
|
+
this.activity.broker.publish('execution', 'execute.iteration.completed', {
|
|
101
|
+
...message.content,
|
|
117
102
|
...chr.getContent(),
|
|
118
103
|
preventComplete: true,
|
|
119
104
|
output: loopOutput.slice(),
|
|
120
105
|
state: 'iteration.completed'
|
|
121
106
|
});
|
|
122
|
-
|
|
123
107
|
if (chr.isCompletionConditionMet(message, loopOutput)) {
|
|
124
108
|
chr.debug('complete condition met');
|
|
125
109
|
} else if (this._startNext(content.index + 1)) return;
|
|
126
|
-
|
|
127
110
|
chr.debug('sequential loop completed');
|
|
128
111
|
return chr.complete(content);
|
|
129
112
|
};
|
|
130
|
-
|
|
131
113
|
function ParallelLoopCharacteristics(activity, characteristics) {
|
|
132
114
|
this.activity = activity;
|
|
133
115
|
this.id = activity.id;
|
|
@@ -135,52 +117,44 @@ function ParallelLoopCharacteristics(activity, characteristics) {
|
|
|
135
117
|
this.running = 0;
|
|
136
118
|
this.index = 0;
|
|
137
119
|
}
|
|
138
|
-
|
|
139
120
|
ParallelLoopCharacteristics.prototype.execute = function execute(executeMessage) {
|
|
140
121
|
const chr = this.characteristics;
|
|
141
122
|
if (!chr.cardinality) throw new _Errors.RunError(`<${this.id}> cardinality or collection is required in parallel loops`, executeMessage);
|
|
142
123
|
const isRedelivered = executeMessage.fields.redelivered;
|
|
143
|
-
|
|
144
124
|
if (isRedelivered) {
|
|
145
125
|
if (!isNaN(executeMessage.content.index)) this.index = executeMessage.content.index;
|
|
146
126
|
if (!isNaN(executeMessage.content.running)) this.running = executeMessage.content.running;
|
|
147
127
|
}
|
|
148
|
-
|
|
149
128
|
chr.subscribe(this._onCompleteMessage.bind(this));
|
|
150
129
|
if (isRedelivered) return;
|
|
151
130
|
return this._startBatch();
|
|
152
131
|
};
|
|
153
|
-
|
|
154
132
|
ParallelLoopCharacteristics.prototype._startBatch = function startBatch() {
|
|
155
133
|
const chr = this.characteristics;
|
|
156
134
|
const cardinality = chr.cardinality;
|
|
157
135
|
const batch = [];
|
|
158
136
|
let startContent = chr.next(this.index);
|
|
159
|
-
|
|
160
137
|
do {
|
|
161
138
|
chr.debug(`start parallel iteration index ${this.index}`);
|
|
162
139
|
batch.push(startContent);
|
|
163
140
|
this.running++;
|
|
164
141
|
this.index++;
|
|
165
|
-
|
|
166
142
|
if (this.index >= cardinality || this.running >= chr.batchSize) {
|
|
167
143
|
break;
|
|
168
144
|
}
|
|
169
145
|
} while (startContent = chr.next(this.index));
|
|
170
|
-
|
|
171
146
|
const broker = this.activity.broker;
|
|
172
|
-
broker.publish('execution', 'execute.iteration.batch', {
|
|
147
|
+
broker.publish('execution', 'execute.iteration.batch', {
|
|
148
|
+
...chr.getContent(),
|
|
173
149
|
index: this.index,
|
|
174
150
|
running: this.running,
|
|
175
151
|
output: chr.output,
|
|
176
152
|
preventComplete: true
|
|
177
153
|
});
|
|
178
|
-
|
|
179
154
|
for (const content of batch) {
|
|
180
155
|
broker.publish('execution', 'execute.start', content);
|
|
181
156
|
}
|
|
182
157
|
};
|
|
183
|
-
|
|
184
158
|
ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMessage(_, message) {
|
|
185
159
|
const chr = this.characteristics;
|
|
186
160
|
const {
|
|
@@ -188,7 +162,8 @@ ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMe
|
|
|
188
162
|
} = message;
|
|
189
163
|
if (content.output !== undefined) chr.output[content.index] = content.output;
|
|
190
164
|
this.running--;
|
|
191
|
-
this.activity.broker.publish('execution', 'execute.iteration.completed', {
|
|
165
|
+
this.activity.broker.publish('execution', 'execute.iteration.completed', {
|
|
166
|
+
...content,
|
|
192
167
|
...chr.getContent(),
|
|
193
168
|
index: this.index,
|
|
194
169
|
running: this.running,
|
|
@@ -196,22 +171,17 @@ ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMe
|
|
|
196
171
|
state: 'iteration.completed',
|
|
197
172
|
preventComplete: true
|
|
198
173
|
});
|
|
199
|
-
|
|
200
174
|
if (this.running <= 0 && !chr.next(this.index)) {
|
|
201
175
|
return chr.complete(content);
|
|
202
176
|
}
|
|
203
|
-
|
|
204
177
|
if (chr.isCompletionConditionMet(message)) {
|
|
205
178
|
return chr.complete(content);
|
|
206
179
|
}
|
|
207
|
-
|
|
208
180
|
if (this.running <= 0) {
|
|
209
181
|
this.running = 0;
|
|
210
|
-
|
|
211
182
|
this._startBatch();
|
|
212
183
|
}
|
|
213
184
|
};
|
|
214
|
-
|
|
215
185
|
function Characteristics(activity, loopCharacteristics, executeMessage) {
|
|
216
186
|
this.activity = activity;
|
|
217
187
|
const behaviour = this.behaviour = loopCharacteristics.behaviour || {};
|
|
@@ -224,99 +194,83 @@ function Characteristics(activity, loopCharacteristics, executeMessage) {
|
|
|
224
194
|
this.output = executeMessage.content.output || [];
|
|
225
195
|
this.parent = (0, _messageHelper.unshiftParent)(executeMessage.content.parent, executeMessage.content);
|
|
226
196
|
if ('loopCardinality' in behaviour) this.loopCardinality = behaviour.loopCardinality;else if ('loopMaximum' in behaviour) this.loopCardinality = behaviour.loopMaximum;
|
|
227
|
-
|
|
228
197
|
if (behaviour.loopCondition) {
|
|
229
198
|
if (behaviour.testBefore) this.startCondition = behaviour.loopCondition;else this.completionCondition = behaviour.loopCondition;
|
|
230
199
|
}
|
|
231
|
-
|
|
232
200
|
if (behaviour.completionCondition) {
|
|
233
201
|
this.completionCondition = behaviour.completionCondition;
|
|
234
202
|
}
|
|
235
|
-
|
|
236
203
|
const collection = this.collection = this.getCollection();
|
|
237
|
-
|
|
238
204
|
if (collection) {
|
|
239
205
|
this.elementVariable = behaviour.elementVariable || 'item';
|
|
240
206
|
}
|
|
241
|
-
|
|
242
207
|
this.cardinality = this.getCardinality(collection);
|
|
243
208
|
this.onApiMessage = this.onApiMessage.bind(this);
|
|
244
209
|
const environment = activity.environment;
|
|
245
210
|
this.logger = environment.Logger(type.toLowerCase());
|
|
246
211
|
this.batchSize = environment.settings.batchSize || 50;
|
|
247
212
|
}
|
|
248
|
-
|
|
249
213
|
Characteristics.prototype.getContent = function getContent() {
|
|
250
|
-
return {
|
|
214
|
+
return {
|
|
215
|
+
...(0, _messageHelper.cloneContent)(this.message.content),
|
|
251
216
|
loopCardinality: this.cardinality,
|
|
252
217
|
isSequential: this.isSequential,
|
|
253
218
|
output: undefined
|
|
254
219
|
};
|
|
255
220
|
};
|
|
256
|
-
|
|
257
221
|
Characteristics.prototype.next = function next(index) {
|
|
258
222
|
const cardinality = this.cardinality;
|
|
259
223
|
if (cardinality > 0 && index >= cardinality) return;
|
|
260
224
|
const collection = this.collection;
|
|
261
225
|
if (collection && index >= collection.length) return;
|
|
262
|
-
const content = {
|
|
226
|
+
const content = {
|
|
227
|
+
...this.getContent(),
|
|
263
228
|
isRootScope: undefined,
|
|
264
229
|
executionId: `${this.parentExecutionId}_${index}`,
|
|
265
230
|
isMultiInstance: true,
|
|
266
231
|
parent: (0, _messageHelper.cloneParent)(this.parent),
|
|
267
232
|
index
|
|
268
233
|
};
|
|
269
|
-
|
|
270
234
|
if (collection) {
|
|
271
235
|
content[this.elementVariable] = collection[index];
|
|
272
236
|
}
|
|
273
|
-
|
|
274
237
|
return content;
|
|
275
238
|
};
|
|
276
|
-
|
|
277
239
|
Characteristics.prototype.getCardinality = function getCardinality(collection) {
|
|
278
240
|
const collectionLen = this.collection && Array.isArray(collection) ? collection.length : undefined;
|
|
279
|
-
|
|
280
241
|
if (!this.loopCardinality) {
|
|
281
242
|
return collectionLen;
|
|
282
243
|
}
|
|
283
|
-
|
|
284
244
|
const value = this.activity.environment.resolveExpression(this.loopCardinality, this.message);
|
|
285
|
-
|
|
286
245
|
if (value !== undefined && isNaN(value) || value < 0) {
|
|
287
246
|
throw new _Errors.RunError(`<${this.id}> invalid loop cardinality >${value}<`, this.message);
|
|
288
247
|
}
|
|
289
|
-
|
|
290
248
|
if (value === undefined) return collectionLen;
|
|
291
249
|
return Number(value);
|
|
292
250
|
};
|
|
293
|
-
|
|
294
251
|
Characteristics.prototype.getCollection = function getCollection() {
|
|
295
252
|
const collectionExpression = this.behaviour.collection;
|
|
296
253
|
if (!collectionExpression) return;
|
|
297
254
|
return this.activity.environment.resolveExpression(collectionExpression, this.message);
|
|
298
255
|
};
|
|
299
|
-
|
|
300
256
|
Characteristics.prototype.isStartConditionMet = function isStartConditionMet(message) {
|
|
301
257
|
if (!this.startCondition) return false;
|
|
302
258
|
return this.activity.environment.resolveExpression(this.startCondition, (0, _messageHelper.cloneMessage)(message));
|
|
303
259
|
};
|
|
304
|
-
|
|
305
260
|
Characteristics.prototype.isCompletionConditionMet = function isCompletionConditionMet(message) {
|
|
306
261
|
if (!this.completionCondition) return false;
|
|
307
262
|
return this.activity.environment.resolveExpression(this.completionCondition, (0, _messageHelper.cloneMessage)(message, {
|
|
308
263
|
loopOutput: this.output
|
|
309
264
|
}));
|
|
310
265
|
};
|
|
311
|
-
|
|
312
266
|
Characteristics.prototype.complete = function complete(content) {
|
|
313
267
|
this.stop();
|
|
314
|
-
return this.broker.publish('execution', 'execute.completed', {
|
|
268
|
+
return this.broker.publish('execution', 'execute.completed', {
|
|
269
|
+
...content,
|
|
315
270
|
...this.getContent(),
|
|
316
271
|
output: this.output
|
|
317
272
|
});
|
|
318
273
|
};
|
|
319
|
-
|
|
320
274
|
Characteristics.prototype.subscribe = function subscribe(onIterationCompleteMessage) {
|
|
321
275
|
this.broker.subscribeTmp('api', `activity.*.${this.parentExecutionId}`, this.onApiMessage, {
|
|
322
276
|
noAck: true,
|
|
@@ -329,10 +283,8 @@ Characteristics.prototype.subscribe = function subscribe(onIterationCompleteMess
|
|
|
329
283
|
consumerTag: '_execute-q-multi-instance-tag',
|
|
330
284
|
priority: 300
|
|
331
285
|
});
|
|
332
|
-
|
|
333
286
|
function onComplete(routingKey, message, ...args) {
|
|
334
287
|
if (!message.content.isMultiInstance) return;
|
|
335
|
-
|
|
336
288
|
switch (routingKey) {
|
|
337
289
|
case 'execute.cancel':
|
|
338
290
|
case 'execute.completed':
|
|
@@ -340,7 +292,6 @@ Characteristics.prototype.subscribe = function subscribe(onIterationCompleteMess
|
|
|
340
292
|
}
|
|
341
293
|
}
|
|
342
294
|
};
|
|
343
|
-
|
|
344
295
|
Characteristics.prototype.onApiMessage = function onApiMessage(_, message) {
|
|
345
296
|
switch (message.properties.type) {
|
|
346
297
|
case 'stop':
|
|
@@ -349,12 +300,10 @@ Characteristics.prototype.onApiMessage = function onApiMessage(_, message) {
|
|
|
349
300
|
break;
|
|
350
301
|
}
|
|
351
302
|
};
|
|
352
|
-
|
|
353
303
|
Characteristics.prototype.stop = function stop() {
|
|
354
304
|
this.broker.cancel('_execute-q-multi-instance-tag');
|
|
355
305
|
this.broker.cancel('_api-multi-instance-tag');
|
|
356
306
|
};
|
|
357
|
-
|
|
358
307
|
Characteristics.prototype.debug = function debug(msg) {
|
|
359
308
|
this.logger.debug(`<${this.parentExecutionId} (${this.id})> ${msg}`);
|
|
360
309
|
};
|