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
|
@@ -7,6 +7,10 @@ exports.default = ConditionalEventDefinition;
|
|
|
7
7
|
|
|
8
8
|
var _messageHelper = require("../messageHelper");
|
|
9
9
|
|
|
10
|
+
var _Errors = require("../error/Errors");
|
|
11
|
+
|
|
12
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
13
|
+
|
|
10
14
|
function ConditionalEventDefinition(activity, eventDefinition) {
|
|
11
15
|
const {
|
|
12
16
|
id,
|
|
@@ -18,147 +22,205 @@ function ConditionalEventDefinition(activity, eventDefinition) {
|
|
|
18
22
|
type = 'ConditionalEventDefinition',
|
|
19
23
|
behaviour = {}
|
|
20
24
|
} = eventDefinition;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
this.id = id;
|
|
26
|
+
this.type = type;
|
|
27
|
+
this.isWaiting = !attachedTo;
|
|
28
|
+
this.condition = behaviour.expression;
|
|
29
|
+
this.activity = activity;
|
|
30
|
+
this.environment = environment;
|
|
31
|
+
this.broker = broker;
|
|
32
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const proto = ConditionalEventDefinition.prototype;
|
|
36
|
+
Object.defineProperty(proto, 'executionId', {
|
|
37
|
+
get() {
|
|
38
|
+
const message = this[kExecuteMessage];
|
|
39
|
+
return message && message.content.executionId;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
proto.execute = function execute(executeMessage) {
|
|
45
|
+
this[kExecuteMessage] = executeMessage;
|
|
46
|
+
return this.isWaiting ? this.executeWait(executeMessage) : this.executeCatch(executeMessage);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
proto.executeWait = function executeWait(executeMessage) {
|
|
50
|
+
const executeContent = executeMessage.content;
|
|
51
|
+
const {
|
|
52
|
+
executionId,
|
|
53
|
+
parent
|
|
54
|
+
} = executeContent;
|
|
55
|
+
const parentExecutionId = parent.executionId;
|
|
56
|
+
if (this._evaluateWait(executeMessage)) return;
|
|
57
|
+
const broker = this.broker;
|
|
58
|
+
|
|
59
|
+
const onApiMessage = this._onWaitApiMessage.bind(this);
|
|
60
|
+
|
|
61
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
62
|
+
noAck: true,
|
|
63
|
+
consumerTag: `_api-${executionId}`
|
|
64
|
+
});
|
|
65
|
+
broker.subscribeTmp('api', `activity.signal.${parentExecutionId}`, onApiMessage, {
|
|
66
|
+
noAck: true,
|
|
67
|
+
consumerTag: `_parent-signal-${executionId}`
|
|
68
|
+
});
|
|
69
|
+
const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
70
|
+
executionId: parentExecutionId,
|
|
71
|
+
condition: this.condition
|
|
72
|
+
});
|
|
73
|
+
waitContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
74
|
+
broker.publish('event', 'activity.wait', waitContent);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
proto.executeCatch = function executeCatch(executeMessage) {
|
|
78
|
+
const executeContent = executeMessage.content;
|
|
79
|
+
const {
|
|
80
|
+
executionId,
|
|
81
|
+
index
|
|
82
|
+
} = executeContent;
|
|
83
|
+
this.broker.subscribeTmp('api', `activity.#.${executionId}`, this._onCatchApiMessage.bind(this), {
|
|
84
|
+
noAck: true,
|
|
85
|
+
consumerTag: `_api-${executionId}_${index}`
|
|
86
|
+
});
|
|
87
|
+
const {
|
|
88
|
+
id: attachedToId,
|
|
89
|
+
broker: attachedToBroker
|
|
90
|
+
} = this.activity.attachedTo;
|
|
91
|
+
|
|
92
|
+
this._debug(`listen for execute completed from <${attachedToId}>`);
|
|
93
|
+
|
|
94
|
+
attachedToBroker.subscribeOnce('execution', 'execute.completed', this._onAttachedCompleted.bind(this), {
|
|
95
|
+
priority: 300,
|
|
96
|
+
consumerTag: `_onend-${executionId}_${index}`
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
|
|
101
|
+
const messageType = message.properties.type;
|
|
102
|
+
|
|
103
|
+
switch (messageType) {
|
|
104
|
+
case 'signal':
|
|
105
|
+
{
|
|
106
|
+
return this._evaluateWait(message);
|
|
69
107
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
stop();
|
|
79
|
-
debug(`<${executionId} (${id})> discarded`);
|
|
80
|
-
return broker.publish('execution', 'execute.discard', { ...messageContent,
|
|
81
|
-
state: 'discard'
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
case 'stop':
|
|
86
|
-
{
|
|
87
|
-
stop();
|
|
88
|
-
return debug(`<${executionId} (${id})> stopped`);
|
|
89
|
-
}
|
|
108
|
+
|
|
109
|
+
case 'discard':
|
|
110
|
+
{
|
|
111
|
+
this._stopWait();
|
|
112
|
+
|
|
113
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
114
|
+
state: 'discard'
|
|
115
|
+
}));
|
|
90
116
|
}
|
|
91
|
-
}
|
|
92
117
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
118
|
+
case 'stop':
|
|
119
|
+
{
|
|
120
|
+
return this._stopWait();
|
|
121
|
+
}
|
|
97
122
|
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
proto._evaluateWait = function evaluate(message) {
|
|
126
|
+
const executeMessage = this[kExecuteMessage];
|
|
127
|
+
const broker = this.broker,
|
|
128
|
+
executeContent = executeMessage.content;
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
|
|
132
|
+
} catch (err) {
|
|
133
|
+
return broker.publish('execution', 'execute.error', (0, _messageHelper.cloneContent)(executeContent, {
|
|
134
|
+
error: new _Errors.ActivityError(err.message, executeMessage, err)
|
|
135
|
+
}, {
|
|
136
|
+
mandatory: true
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this._debug(`condition evaluated to ${!!output}`);
|
|
141
|
+
|
|
142
|
+
broker.publish('event', 'activity.condition', (0, _messageHelper.cloneContent)(executeContent, {
|
|
143
|
+
conditionResult: output
|
|
144
|
+
}));
|
|
145
|
+
if (!output) return;
|
|
146
|
+
|
|
147
|
+
this._stopWait();
|
|
148
|
+
|
|
149
|
+
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
150
|
+
output
|
|
151
|
+
}));
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
proto._stopWait = function stopWait() {
|
|
155
|
+
const broker = this.broker,
|
|
156
|
+
executionId = this.executionId;
|
|
157
|
+
broker.cancel(`_api-${executionId}`);
|
|
158
|
+
broker.cancel(`_parent-signal-${executionId}`);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
|
|
162
|
+
this._stopCatch();
|
|
163
|
+
|
|
164
|
+
const executeMessage = this[kExecuteMessage];
|
|
165
|
+
const broker = this.broker,
|
|
166
|
+
executeContent = executeMessage.content;
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
var output = this.environment.resolveExpression(this.condition, message); // eslint-disable-line no-var
|
|
170
|
+
} catch (err) {
|
|
171
|
+
return broker.publish('execution', 'execute.error', (0, _messageHelper.cloneContent)(executeContent, {
|
|
172
|
+
error: new _Errors.ActivityError(err.message, executeMessage, err)
|
|
173
|
+
}, {
|
|
174
|
+
mandatory: true
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this._debug(`condition from <${message.content.executionId}> evaluated to ${!!output}`);
|
|
179
|
+
|
|
180
|
+
broker.publish('event', 'activity.condition', (0, _messageHelper.cloneContent)(executeContent, {
|
|
181
|
+
conditionResult: output
|
|
182
|
+
}));
|
|
183
|
+
|
|
184
|
+
if (output) {
|
|
185
|
+
broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
186
|
+
output
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
|
|
192
|
+
const messageType = message.properties.type;
|
|
98
193
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
broker.publish('event', 'activity.wait', { ...(0, _messageHelper.cloneContent)(messageContent),
|
|
117
|
-
executionId: parentExecutionId,
|
|
118
|
-
parent: (0, _messageHelper.shiftParent)(parent)
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
function onApiMessage(routingKey, message) {
|
|
122
|
-
const messageType = message.properties.type;
|
|
123
|
-
|
|
124
|
-
switch (messageType) {
|
|
125
|
-
case 'signal':
|
|
126
|
-
{
|
|
127
|
-
return evaluate(message);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
case 'discard':
|
|
131
|
-
{
|
|
132
|
-
stop();
|
|
133
|
-
return broker.publish('execution', 'execute.discard', { ...messageContent,
|
|
134
|
-
state: 'discard'
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
case 'stop':
|
|
139
|
-
{
|
|
140
|
-
stop();
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
194
|
+
switch (messageType) {
|
|
195
|
+
case 'discard':
|
|
196
|
+
{
|
|
197
|
+
this._stopCatch();
|
|
198
|
+
|
|
199
|
+
this._debug('discarded');
|
|
200
|
+
|
|
201
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
202
|
+
state: 'discard'
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
case 'stop':
|
|
207
|
+
{
|
|
208
|
+
this._stopCatch();
|
|
209
|
+
|
|
210
|
+
return this._debug('stopped');
|
|
143
211
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function evaluate(message) {
|
|
147
|
-
const output = environment.resolveExpression(condition, message);
|
|
148
|
-
debug(`<${executionId} (${id})> condition evaluated to`, !!output);
|
|
149
|
-
broker.publish('event', 'activity.condition', { ...(0, _messageHelper.cloneContent)(messageContent),
|
|
150
|
-
conditionResult: output
|
|
151
|
-
});
|
|
152
|
-
if (!output) return;
|
|
153
|
-
stop();
|
|
154
|
-
return broker.publish('execution', 'execute.completed', { ...messageContent,
|
|
155
|
-
output
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function stop() {
|
|
160
|
-
broker.cancel(`_api-${executionId}`);
|
|
161
|
-
broker.cancel(`_parent-signal-${executionId}`);
|
|
162
|
-
}
|
|
163
212
|
}
|
|
164
|
-
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
proto._stopCatch = function stopCatch() {
|
|
216
|
+
const {
|
|
217
|
+
executionId,
|
|
218
|
+
index
|
|
219
|
+
} = this[kExecuteMessage].content;
|
|
220
|
+
this.activity.attachedTo.broker.cancel(`_onend-${executionId}_${index}`);
|
|
221
|
+
this.broker.cancel(`_api-${executionId}_${index}`);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
proto._debug = function debug(msg) {
|
|
225
|
+
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
226
|
+
};
|