bpmn-elements 17.2.2 → 18.0.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 +3 -1
- package/dist/Api.js +83 -0
- package/dist/Context.js +228 -22
- package/dist/Environment.js +111 -31
- package/dist/EventBroker.js +57 -1
- package/dist/Expressions.js +3 -4
- package/dist/MessageFormatter.js +29 -16
- package/dist/Timers.js +13 -9
- package/dist/Tracker.js +1 -0
- package/dist/activity/Activity.js +458 -254
- package/dist/activity/ActivityExecution.js +113 -40
- package/dist/activity/Dummy.js +6 -1
- package/dist/activity/Escalation.js +36 -24
- package/dist/activity/ExecutionScope.js +1 -1
- package/dist/activity/Message.js +36 -24
- package/dist/activity/Signal.js +36 -24
- package/dist/activity/outbound-evaluator.js +1 -1
- package/dist/condition.js +12 -6
- package/dist/constants.js +21 -0
- package/dist/definition/Definition.js +182 -64
- package/dist/definition/DefinitionExecution.js +195 -82
- package/dist/error/BpmnError.js +12 -1
- package/dist/error/Errors.js +50 -9
- package/dist/eventDefinitions/CancelEventDefinition.js +29 -11
- package/dist/eventDefinitions/CompensateEventDefinition.js +51 -31
- package/dist/eventDefinitions/ConditionalEventDefinition.js +21 -9
- package/dist/eventDefinitions/ErrorEventDefinition.js +46 -30
- package/dist/eventDefinitions/EscalationEventDefinition.js +44 -27
- package/dist/eventDefinitions/EventDefinitionExecution.js +30 -23
- package/dist/eventDefinitions/LinkEventDefinition.js +45 -120
- package/dist/eventDefinitions/MessageEventDefinition.js +44 -29
- package/dist/eventDefinitions/SignalEventDefinition.js +46 -31
- package/dist/eventDefinitions/TerminateEventDefinition.js +10 -1
- package/dist/eventDefinitions/TimerEventDefinition.js +57 -37
- package/dist/eventDefinitions/index.js +20 -21
- package/dist/events/BoundaryEvent.js +52 -40
- package/dist/events/EndEvent.js +22 -8
- package/dist/events/IntermediateCatchEvent.js +26 -8
- package/dist/events/IntermediateThrowEvent.js +24 -9
- package/dist/events/StartEvent.js +30 -14
- package/dist/events/index.js +10 -11
- package/dist/flows/Association.js +50 -7
- package/dist/flows/MessageFlow.js +49 -10
- package/dist/flows/SequenceFlow.js +93 -22
- package/dist/flows/index.js +6 -7
- package/dist/gateways/EventBasedGateway.js +29 -15
- package/dist/gateways/ExclusiveGateway.js +20 -5
- package/dist/gateways/InclusiveGateway.js +21 -5
- package/dist/gateways/ParallelGateway.js +253 -15
- package/dist/gateways/index.js +8 -9
- package/dist/getPropertyValue.js +2 -2
- package/dist/index.js +42 -43
- package/dist/io/BpmnIO.js +15 -1
- package/dist/io/EnvironmentDataObject.js +29 -1
- package/dist/io/EnvironmentDataStore.js +24 -1
- package/dist/io/EnvironmentDataStoreReference.js +24 -1
- package/dist/io/InputOutputSpecification.js +21 -11
- package/dist/io/Properties.js +28 -17
- package/dist/messageHelper.js +41 -4
- package/dist/process/Lane.js +15 -4
- package/dist/process/Process.js +174 -76
- package/dist/process/ProcessExecution.js +362 -177
- package/dist/shared.js +2 -0
- package/dist/tasks/CallActivity.js +19 -4
- package/dist/tasks/LoopCharacteristics.js +94 -9
- package/dist/tasks/ReceiveTask.js +36 -21
- package/dist/tasks/ScriptTask.js +22 -6
- package/dist/tasks/ServiceImplementation.js +7 -4
- package/dist/tasks/ServiceTask.js +19 -4
- package/dist/tasks/SignalTask.js +19 -4
- package/dist/tasks/StandardLoopCharacteristics.js +8 -4
- package/dist/tasks/SubProcess.js +44 -29
- package/dist/tasks/Task.js +19 -4
- package/dist/tasks/Transaction.js +8 -4
- package/dist/tasks/index.js +16 -18
- package/package.json +31 -13
- package/src/Api.js +70 -0
- package/src/Context.js +200 -19
- package/src/Environment.js +99 -30
- package/src/EventBroker.js +46 -1
- package/src/Expressions.js +2 -3
- package/src/MessageFormatter.js +24 -16
- package/src/Timers.js +12 -9
- package/src/Tracker.js +1 -0
- package/src/activity/Activity.js +388 -231
- package/src/activity/ActivityExecution.js +93 -42
- package/src/activity/Dummy.js +6 -1
- package/src/activity/Escalation.js +25 -18
- package/src/activity/ExecutionScope.js +1 -1
- package/src/activity/Message.js +25 -18
- package/src/activity/Signal.js +25 -18
- package/src/activity/outbound-evaluator.js +1 -1
- package/src/condition.js +11 -5
- package/src/constants.js +15 -0
- package/src/definition/Definition.js +157 -62
- package/src/definition/DefinitionExecution.js +161 -83
- package/src/error/BpmnError.js +11 -1
- package/src/error/Errors.js +44 -5
- package/src/eventDefinitions/CancelEventDefinition.js +27 -13
- package/src/eventDefinitions/CompensateEventDefinition.js +48 -32
- package/src/eventDefinitions/ConditionalEventDefinition.js +20 -10
- package/src/eventDefinitions/ErrorEventDefinition.js +44 -33
- package/src/eventDefinitions/EscalationEventDefinition.js +39 -26
- package/src/eventDefinitions/EventDefinitionExecution.js +30 -24
- package/src/eventDefinitions/LinkEventDefinition.js +34 -120
- package/src/eventDefinitions/MessageEventDefinition.js +42 -31
- package/src/eventDefinitions/SignalEventDefinition.js +43 -32
- package/src/eventDefinitions/TerminateEventDefinition.js +9 -1
- package/src/eventDefinitions/TimerEventDefinition.js +53 -35
- package/src/eventDefinitions/index.js +10 -23
- package/src/events/BoundaryEvent.js +50 -39
- package/src/events/EndEvent.js +19 -7
- package/src/events/IntermediateCatchEvent.js +24 -8
- package/src/events/IntermediateThrowEvent.js +24 -8
- package/src/events/StartEvent.js +25 -14
- package/src/events/index.js +5 -18
- package/src/flows/Association.js +43 -9
- package/src/flows/MessageFlow.js +41 -10
- package/src/flows/SequenceFlow.js +82 -19
- package/src/flows/index.js +3 -4
- package/src/gateways/EventBasedGateway.js +27 -15
- package/src/gateways/ExclusiveGateway.js +16 -3
- package/src/gateways/InclusiveGateway.js +16 -3
- package/src/gateways/ParallelGateway.js +301 -10
- package/src/gateways/index.js +4 -4
- package/src/getPropertyValue.js +2 -2
- package/src/index.js +19 -19
- package/src/io/BpmnIO.js +13 -1
- package/src/io/EnvironmentDataObject.js +26 -1
- package/src/io/EnvironmentDataStore.js +22 -1
- package/src/io/EnvironmentDataStoreReference.js +22 -1
- package/src/io/InputOutputSpecification.js +17 -8
- package/src/io/Properties.js +23 -13
- package/src/messageHelper.js +36 -4
- package/src/process/Lane.js +14 -4
- package/src/process/Process.js +154 -72
- package/src/process/ProcessExecution.js +326 -175
- package/src/shared.js +1 -0
- package/src/tasks/CallActivity.js +16 -2
- package/src/tasks/LoopCharacteristics.js +77 -11
- package/src/tasks/ReceiveTask.js +33 -22
- package/src/tasks/ScriptTask.js +17 -3
- package/src/tasks/ServiceImplementation.js +6 -3
- package/src/tasks/ServiceTask.js +16 -2
- package/src/tasks/SignalTask.js +16 -2
- package/src/tasks/StandardLoopCharacteristics.js +7 -3
- package/src/tasks/SubProcess.js +37 -23
- package/src/tasks/Task.js +16 -2
- package/src/tasks/Transaction.js +7 -3
- package/src/tasks/index.js +8 -9
- package/types/bundle-errors.d.ts +1 -0
- package/types/bundle.d.ts +97 -0
- package/types/index.d.ts +2614 -84
- package/types/interfaces.d.ts +636 -0
- package/types/types.d.ts +0 -765
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.SequenceFlow = SequenceFlow;
|
|
7
7
|
var _messageHelper = require("../messageHelper.js");
|
|
8
8
|
var _shared = require("../shared.js");
|
|
9
9
|
var _EventBroker = require("../EventBroker.js");
|
|
10
10
|
var _Api = require("../Api.js");
|
|
11
11
|
var _condition = require("../condition.js");
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
var _constants = require("../constants.js");
|
|
13
|
+
/**
|
|
14
|
+
* Sequence flow connecting two activities. Owns its broker and publishes take/discard/looped
|
|
15
|
+
* events; activities subscribe to drive their inbound queue.
|
|
16
|
+
* @param {import('moddle-context-serializer').SequenceFlow} flowDef
|
|
17
|
+
* @param {import('#types').ContextInstance} context
|
|
18
|
+
*/
|
|
14
19
|
function SequenceFlow(flowDef, {
|
|
15
20
|
environment
|
|
16
21
|
}) {
|
|
@@ -28,6 +33,7 @@ function SequenceFlow(flowDef, {
|
|
|
28
33
|
this.type = type;
|
|
29
34
|
this.name = name;
|
|
30
35
|
this.parent = (0, _messageHelper.cloneParent)(parent);
|
|
36
|
+
/** @type {Record<string, any>} */
|
|
31
37
|
this.behaviour = behaviour;
|
|
32
38
|
this.sourceId = sourceId;
|
|
33
39
|
this.targetId = targetId;
|
|
@@ -35,7 +41,7 @@ function SequenceFlow(flowDef, {
|
|
|
35
41
|
this.isSequenceFlow = true;
|
|
36
42
|
this.environment = environment;
|
|
37
43
|
const logger = this.logger = environment.Logger(type.toLowerCase());
|
|
38
|
-
this[
|
|
44
|
+
this[_constants.K_COUNTERS] = {
|
|
39
45
|
looped: 0,
|
|
40
46
|
take: 0,
|
|
41
47
|
discard: 0
|
|
@@ -60,32 +66,51 @@ function SequenceFlow(flowDef, {
|
|
|
60
66
|
logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
|
|
61
67
|
}
|
|
62
68
|
Object.defineProperty(SequenceFlow.prototype, 'counters', {
|
|
69
|
+
/** @returns {{ take: number, discard: number, looped: number }} */
|
|
63
70
|
get() {
|
|
64
71
|
return {
|
|
65
|
-
...this[
|
|
72
|
+
...this[_constants.K_COUNTERS]
|
|
66
73
|
};
|
|
67
74
|
}
|
|
68
75
|
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Take the flow and publish flow.take.
|
|
79
|
+
* @param {Record<string, any>} [content]
|
|
80
|
+
*/
|
|
69
81
|
SequenceFlow.prototype.take = function take(content) {
|
|
70
82
|
const sequenceId = content?.sequenceId;
|
|
71
83
|
this.logger.debug(`<${sequenceId} (${this.id})> take, target <${this.targetId}>`);
|
|
72
|
-
++this[
|
|
84
|
+
++this[_constants.K_COUNTERS].take;
|
|
73
85
|
this._publishEvent('take', content);
|
|
74
86
|
return true;
|
|
75
87
|
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Discard the flow and publish flow.discard.
|
|
91
|
+
*
|
|
92
|
+
* @deprecated The execution runtime no longer discards sequence flows, so this is a no-op during a run. It will be removed in a future version.
|
|
93
|
+
* @param {Record<string, any>} [content]
|
|
94
|
+
*/
|
|
76
95
|
SequenceFlow.prototype.discard = function discard(content = {}) {
|
|
77
96
|
const sequenceId = content?.sequenceId ?? (0, _shared.getUniqueId)(this.id);
|
|
78
|
-
const discardSequence = content.discardSequence =
|
|
97
|
+
const discardSequence = content.discardSequence = content.discardSequence?.slice() || [];
|
|
79
98
|
if (discardSequence.indexOf(this.targetId) > -1) {
|
|
80
|
-
++this[
|
|
99
|
+
++this[_constants.K_COUNTERS].looped;
|
|
81
100
|
this.logger.debug(`<${this.id}> discard loop detected <${this.sourceId}> -> <${this.targetId}>. Stop.`);
|
|
82
101
|
return this._publishEvent('looped', content);
|
|
83
102
|
}
|
|
84
103
|
discardSequence.push(this.sourceId);
|
|
85
104
|
this.logger.debug(`<${sequenceId} (${this.id})> discard, target <${this.targetId}>`);
|
|
86
|
-
++this[
|
|
105
|
+
++this[_constants.K_COUNTERS].discard;
|
|
87
106
|
this._publishEvent('discard', content);
|
|
88
107
|
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Snapshot flow state. Returns undefined when the broker has no state and `disableTrackState`
|
|
111
|
+
* is set.
|
|
112
|
+
* @returns {import('#types').SequenceFlowState | undefined}
|
|
113
|
+
*/
|
|
89
114
|
SequenceFlow.prototype.getState = function getState() {
|
|
90
115
|
const brokerState = this.broker.getState(true);
|
|
91
116
|
if (!brokerState && this.environment.settings.disableTrackState) return;
|
|
@@ -96,42 +121,74 @@ SequenceFlow.prototype.getState = function getState() {
|
|
|
96
121
|
broker: brokerState
|
|
97
122
|
};
|
|
98
123
|
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Restore flow state captured by getState.
|
|
127
|
+
* @param {import('#types').SequenceFlowState} state
|
|
128
|
+
*/
|
|
99
129
|
SequenceFlow.prototype.recover = function recover(state) {
|
|
100
|
-
Object.assign(this[
|
|
130
|
+
Object.assign(this[_constants.K_COUNTERS], state.counters);
|
|
101
131
|
this.broker.recover(state.broker);
|
|
102
132
|
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Resolve a Flow Api wrapper.
|
|
136
|
+
* @param {import('#types').ElementBrokerMessage} [message]
|
|
137
|
+
* @returns {import('#types').IApi<this>}
|
|
138
|
+
*/
|
|
103
139
|
SequenceFlow.prototype.getApi = function getApi(message) {
|
|
104
140
|
return (0, _Api.FlowApi)(this.broker, message || {
|
|
105
141
|
content: this.createMessage()
|
|
106
142
|
});
|
|
107
143
|
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Stop the flow's broker.
|
|
147
|
+
*/
|
|
108
148
|
SequenceFlow.prototype.stop = function stop() {
|
|
109
149
|
this.broker.stop();
|
|
110
150
|
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Walk the flow as part of a process shake. Detects loops and publishes flow.shake.loop
|
|
154
|
+
* when the target was already visited, otherwise flow.shake.
|
|
155
|
+
* @param {import('#types').ElementBrokerMessage} message
|
|
156
|
+
*/
|
|
111
157
|
SequenceFlow.prototype.shake = function shake(message) {
|
|
112
158
|
const content = (0, _messageHelper.cloneContent)(message.content);
|
|
113
159
|
content.sequence = content.sequence || [];
|
|
114
|
-
|
|
160
|
+
const info = {
|
|
115
161
|
id: this.id,
|
|
116
162
|
type: this.type,
|
|
117
163
|
isSequenceFlow: true,
|
|
164
|
+
sourceId: this.sourceId,
|
|
118
165
|
targetId: this.targetId
|
|
119
|
-
}
|
|
120
|
-
if (content.id === this.targetId)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
166
|
+
};
|
|
167
|
+
if (content.id === this.targetId) {
|
|
168
|
+
content.sequence.push(info);
|
|
169
|
+
return this.broker.publish('event', 'flow.shake.loop', content, {
|
|
170
|
+
persistent: false,
|
|
171
|
+
type: 'shake'
|
|
172
|
+
});
|
|
173
|
+
} else if (content.sequence?.find(f => f.id === this.id)) {
|
|
174
|
+
return this.broker.publish('event', 'flow.shake.loop', content, {
|
|
175
|
+
persistent: false,
|
|
176
|
+
type: 'shake'
|
|
177
|
+
});
|
|
178
|
+
} else {
|
|
179
|
+
content.sequence.push(info);
|
|
180
|
+
this.broker.publish('event', 'flow.shake', content, {
|
|
126
181
|
persistent: false,
|
|
127
182
|
type: 'shake'
|
|
128
183
|
});
|
|
129
184
|
}
|
|
130
|
-
this.broker.publish('event', 'flow.shake', content, {
|
|
131
|
-
persistent: false,
|
|
132
|
-
type: 'shake'
|
|
133
|
-
});
|
|
134
185
|
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Resolve the flow's condition (script or expression). Returns null when no condition is set.
|
|
189
|
+
* Emits a fatal error when the script language is missing or unsupported.
|
|
190
|
+
* @returns {import('#types').ICondition | null}
|
|
191
|
+
*/
|
|
135
192
|
SequenceFlow.prototype.getCondition = function getCondition() {
|
|
136
193
|
const conditionExpression = this.behaviour.conditionExpression;
|
|
137
194
|
if (!conditionExpression) return null;
|
|
@@ -148,6 +205,12 @@ SequenceFlow.prototype.getCondition = function getCondition() {
|
|
|
148
205
|
}
|
|
149
206
|
return new _condition.ExpressionCondition(this, conditionExpression.body);
|
|
150
207
|
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Build a flow event message body, optionally merging override content.
|
|
211
|
+
* @param {Record<string, any>} [override]
|
|
212
|
+
* @returns {import('#types').ElementMessageContent}
|
|
213
|
+
*/
|
|
151
214
|
SequenceFlow.prototype.createMessage = function createMessage(override) {
|
|
152
215
|
return {
|
|
153
216
|
...override,
|
|
@@ -161,6 +224,12 @@ SequenceFlow.prototype.createMessage = function createMessage(override) {
|
|
|
161
224
|
parent: (0, _messageHelper.cloneParent)(this.parent)
|
|
162
225
|
};
|
|
163
226
|
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Evaluate the flow's condition for the source activity message. Default flows are always taken.
|
|
230
|
+
* @param {import('#types').ElementBrokerMessage} fromMessage Source activity message
|
|
231
|
+
* @param {(err: Error | null, result?: boolean | unknown) => void} callback Callback with truthy result if flow should be taken
|
|
232
|
+
*/
|
|
164
233
|
SequenceFlow.prototype.evaluate = function evaluate(fromMessage, callback) {
|
|
165
234
|
if (this.isDefault) {
|
|
166
235
|
return callback(null, true);
|
|
@@ -171,6 +240,8 @@ SequenceFlow.prototype.evaluate = function evaluate(fromMessage, callback) {
|
|
|
171
240
|
}
|
|
172
241
|
flowCondition.execute(fromMessage, callback);
|
|
173
242
|
};
|
|
243
|
+
|
|
244
|
+
/** @internal */
|
|
174
245
|
SequenceFlow.prototype._publishEvent = function publishEvent(action, content) {
|
|
175
246
|
const eventContent = this.createMessage({
|
|
176
247
|
action,
|
package/dist/flows/index.js
CHANGED
|
@@ -6,22 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "Association", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return _Association.
|
|
9
|
+
return _Association.Association;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "MessageFlow", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return _MessageFlow.
|
|
15
|
+
return _MessageFlow.MessageFlow;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "SequenceFlow", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return _SequenceFlow.
|
|
21
|
+
return _SequenceFlow.SequenceFlow;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
var _Association =
|
|
25
|
-
var _MessageFlow =
|
|
26
|
-
var _SequenceFlow =
|
|
27
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
+
var _Association = require("./Association.js");
|
|
25
|
+
var _MessageFlow = require("./MessageFlow.js");
|
|
26
|
+
var _SequenceFlow = require("./SequenceFlow.js");
|
|
@@ -3,24 +3,38 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.EventBasedGateway = EventBasedGateway;
|
|
6
7
|
exports.EventBasedGatewayBehaviour = EventBasedGatewayBehaviour;
|
|
7
|
-
|
|
8
|
-
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
8
|
+
var _Activity = require("../activity/Activity.js");
|
|
9
9
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var _constants = require("../constants.js");
|
|
11
|
+
/**
|
|
12
|
+
* Event based gateway
|
|
13
|
+
* @param {import('moddle-context-serializer').Activity} activityDef
|
|
14
|
+
* @param {import('#types').ContextInstance} context
|
|
15
|
+
*/
|
|
13
16
|
function EventBasedGateway(activityDef, context) {
|
|
14
|
-
return new _Activity.
|
|
17
|
+
return new _Activity.Activity(EventBasedGatewayBehaviour, activityDef, context);
|
|
15
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Event based gateway behaviour
|
|
22
|
+
* @param {import('#types').Activity} activity
|
|
23
|
+
* @param {import('#types').ContextInstance} context
|
|
24
|
+
*/
|
|
16
25
|
function EventBasedGatewayBehaviour(activity, context) {
|
|
17
26
|
this.id = activity.id;
|
|
18
27
|
this.type = activity.type;
|
|
19
28
|
this.activity = activity;
|
|
20
29
|
this.broker = activity.broker;
|
|
21
30
|
this.context = context;
|
|
22
|
-
this[
|
|
31
|
+
this[_constants.K_TARGETS] = new Set(activity.outbound.map(flow => context.getActivityById(flow.targetId)));
|
|
23
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
24
38
|
EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage) {
|
|
25
39
|
const executeContent = executeMessage.content;
|
|
26
40
|
const {
|
|
@@ -28,8 +42,8 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
28
42
|
outbound = [],
|
|
29
43
|
outboundTaken
|
|
30
44
|
} = executeContent;
|
|
31
|
-
const targets = this[
|
|
32
|
-
this[
|
|
45
|
+
const targets = this[_constants.K_TARGETS];
|
|
46
|
+
this[_constants.K_COMPLETED] = false;
|
|
33
47
|
if (!targets.size) return this._complete(executeContent);
|
|
34
48
|
for (const flow of this.activity.outbound) {
|
|
35
49
|
outbound.push({
|
|
@@ -37,10 +51,10 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
37
51
|
action: 'take'
|
|
38
52
|
});
|
|
39
53
|
}
|
|
40
|
-
if (!this[
|
|
54
|
+
if (!this[_constants.K_COMPLETED] && outboundTaken) return;
|
|
41
55
|
const targetConsumerTag = `_gateway-listener-${this.id}`;
|
|
42
56
|
const onTargetCompleted = this._onTargetCompleted.bind(this, executeMessage);
|
|
43
|
-
for (const target of this[
|
|
57
|
+
for (const target of this[_constants.K_TARGETS]) {
|
|
44
58
|
target.broker.subscribeOnce('event', 'activity.end', onTargetCompleted, {
|
|
45
59
|
consumerTag: targetConsumerTag
|
|
46
60
|
});
|
|
@@ -49,7 +63,7 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
49
63
|
broker.subscribeOnce('api', `activity.stop.${executionId}`, () => this._stop(), {
|
|
50
64
|
consumerTag: '_api-stop-execution'
|
|
51
65
|
});
|
|
52
|
-
this[
|
|
66
|
+
this[_constants.K_COMPLETED] = false;
|
|
53
67
|
if (!executeMessage.fields.redelivered) {
|
|
54
68
|
return broker.publish('execution', 'execute.outbound.take', (0, _messageHelper.cloneContent)(executeContent, {
|
|
55
69
|
outboundTaken: true
|
|
@@ -65,7 +79,7 @@ EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompl
|
|
|
65
79
|
const executionId = executeContent.executionId;
|
|
66
80
|
this.activity.logger.debug(`<${executionId} (${this.id})> <${targetExecutionId}> completed run, discarding the rest`);
|
|
67
81
|
this._stop();
|
|
68
|
-
for (const target of this[
|
|
82
|
+
for (const target of this[_constants.K_TARGETS]) {
|
|
69
83
|
if (target === owner) continue;
|
|
70
84
|
target.discard();
|
|
71
85
|
}
|
|
@@ -79,11 +93,11 @@ EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompl
|
|
|
79
93
|
this._complete(completedContent);
|
|
80
94
|
};
|
|
81
95
|
EventBasedGatewayBehaviour.prototype._complete = function complete(completedContent) {
|
|
82
|
-
this[
|
|
96
|
+
this[_constants.K_COMPLETED] = true;
|
|
83
97
|
this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(completedContent));
|
|
84
98
|
};
|
|
85
99
|
EventBasedGatewayBehaviour.prototype._stop = function stop() {
|
|
86
100
|
const targetConsumerTag = `_gateway-listener-${this.id}`;
|
|
87
|
-
for (const target of this[
|
|
101
|
+
for (const target of this[_constants.K_TARGETS]) target.broker.cancel(targetConsumerTag);
|
|
88
102
|
this.broker.cancel('_api-stop-execution');
|
|
89
103
|
};
|
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.ExclusiveGateway = ExclusiveGateway;
|
|
6
7
|
exports.ExclusiveGatewayBehaviour = ExclusiveGatewayBehaviour;
|
|
7
|
-
|
|
8
|
-
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
8
|
+
var _Activity = require("../activity/Activity.js");
|
|
9
9
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Exclusive gateway
|
|
12
|
+
* @param {import('moddle-context-serializer').Activity} activityDef
|
|
13
|
+
* @param {import('#types').ContextInstance} context
|
|
14
|
+
*/
|
|
11
15
|
function ExclusiveGateway(activityDef, context) {
|
|
12
|
-
return new _Activity.
|
|
16
|
+
return new _Activity.Activity(ExclusiveGatewayBehaviour, activityDef, context);
|
|
13
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Exclusive gateway behaviour
|
|
21
|
+
* @param {import('#types').Activity} activity
|
|
22
|
+
*/
|
|
14
23
|
function ExclusiveGatewayBehaviour(activity) {
|
|
15
24
|
const {
|
|
16
25
|
id,
|
|
@@ -21,10 +30,16 @@ function ExclusiveGatewayBehaviour(activity) {
|
|
|
21
30
|
this.type = type;
|
|
22
31
|
this.broker = broker;
|
|
23
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
24
38
|
ExclusiveGatewayBehaviour.prototype.execute = function execute({
|
|
25
39
|
content
|
|
26
40
|
}) {
|
|
27
41
|
this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
|
|
28
|
-
outboundTakeOne: true
|
|
42
|
+
outboundTakeOne: true,
|
|
43
|
+
requireOutbound: true
|
|
29
44
|
}));
|
|
30
45
|
};
|
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.InclusiveGateway = InclusiveGateway;
|
|
6
7
|
exports.InclusiveGatewayBehaviour = InclusiveGatewayBehaviour;
|
|
7
|
-
|
|
8
|
-
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
8
|
+
var _Activity = require("../activity/Activity.js");
|
|
9
9
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Inclusive gateway
|
|
12
|
+
* @param {import('moddle-context-serializer').Activity} activityDef
|
|
13
|
+
* @param {import('#types').ContextInstance} context
|
|
14
|
+
*/
|
|
11
15
|
function InclusiveGateway(activityDef, context) {
|
|
12
|
-
return new _Activity.
|
|
16
|
+
return new _Activity.Activity(InclusiveGatewayBehaviour, activityDef, context);
|
|
13
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Inclusive gateway behaviour
|
|
21
|
+
* @param {import('#types').Activity} activity
|
|
22
|
+
*/
|
|
14
23
|
function InclusiveGatewayBehaviour(activity) {
|
|
15
24
|
const {
|
|
16
25
|
id,
|
|
@@ -21,8 +30,15 @@ function InclusiveGatewayBehaviour(activity) {
|
|
|
21
30
|
this.type = type;
|
|
22
31
|
this.broker = broker;
|
|
23
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
24
38
|
InclusiveGatewayBehaviour.prototype.execute = function execute({
|
|
25
39
|
content
|
|
26
40
|
}) {
|
|
27
|
-
this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content
|
|
41
|
+
this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
|
|
42
|
+
requireOutbound: true
|
|
43
|
+
}));
|
|
28
44
|
};
|