bpmn-elements 8.1.0 → 8.2.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 +10 -0
- package/dist/index.js +0 -49
- package/dist/src/Api.js +4 -19
- package/dist/src/Context.js +7 -36
- 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 +32 -44
- 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 +62 -294
- 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 +8 -5
- 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 +25 -36
- package/dist/src/io/Properties.js +15 -47
- package/dist/src/messageHelper.js +10 -23
- package/dist/src/process/Process.js +10 -112
- package/dist/src/process/ProcessExecution.js +14 -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 +1 -25
- 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 +8 -8
- package/src/Context.js +7 -3
- package/src/ExtensionsMapper.js +35 -35
- package/src/activity/Activity.js +22 -51
- package/src/gateways/EventBasedGateway.js +0 -1
- package/src/io/BpmnIO.js +7 -0
- package/src/io/EnvironmentDataObject.js +1 -0
- package/src/io/InputOutputSpecification.js +17 -6
- package/src/io/Properties.js +9 -11
- package/src/process/ProcessExecution.js +2 -1
- package/src/tasks/ServiceTask.js +1 -3
- package/src/tasks/StandardLoopCharacteristics.js +0 -1
|
@@ -5,49 +5,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SubProcessBehaviour = SubProcessBehaviour;
|
|
7
7
|
exports.default = SubProcess;
|
|
8
|
-
|
|
9
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity"));
|
|
10
|
-
|
|
11
9
|
var _ProcessExecution = _interopRequireDefault(require("../process/ProcessExecution"));
|
|
12
|
-
|
|
13
10
|
var _messageHelper = require("../messageHelper");
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
12
|
const kExecutions = Symbol.for('executions');
|
|
18
13
|
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
19
|
-
|
|
20
14
|
function SubProcess(activityDef, context) {
|
|
21
15
|
const triggeredByEvent = activityDef.behaviour && activityDef.behaviour.triggeredByEvent;
|
|
22
|
-
const subProcess = new _Activity.default(SubProcessBehaviour, {
|
|
16
|
+
const subProcess = new _Activity.default(SubProcessBehaviour, {
|
|
17
|
+
...activityDef,
|
|
23
18
|
isSubProcess: true,
|
|
24
19
|
triggeredByEvent
|
|
25
20
|
}, context);
|
|
26
|
-
|
|
27
21
|
subProcess.getStartActivities = function getStartActivities(filterOptions) {
|
|
28
22
|
return context.getStartActivities(filterOptions, activityDef.id);
|
|
29
23
|
};
|
|
30
|
-
|
|
31
24
|
subProcess.broker.cancel('_api-shake');
|
|
32
25
|
subProcess.broker.subscribeTmp('api', 'activity.shake.*', onShake, {
|
|
33
26
|
noAck: true,
|
|
34
27
|
consumerTag: '_api-shake'
|
|
35
28
|
});
|
|
36
29
|
return subProcess;
|
|
37
|
-
|
|
38
30
|
function onShake(_, message) {
|
|
39
31
|
const {
|
|
40
32
|
startId
|
|
41
33
|
} = message.content;
|
|
42
34
|
const last = message.content.sequence.pop();
|
|
43
35
|
const sequence = new _ProcessExecution.default(subProcess, context).shake(startId);
|
|
44
|
-
message.content.sequence.push({
|
|
36
|
+
message.content.sequence.push({
|
|
37
|
+
...last,
|
|
45
38
|
isSubProcess: true,
|
|
46
39
|
sequence
|
|
47
40
|
});
|
|
48
41
|
}
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
function SubProcessBehaviour(activity, context) {
|
|
52
44
|
const {
|
|
53
45
|
id,
|
|
@@ -68,31 +60,24 @@ function SubProcessBehaviour(activity, context) {
|
|
|
68
60
|
onExecutionCompleted: this._onExecutionCompleted.bind(this)
|
|
69
61
|
};
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
const proto = SubProcessBehaviour.prototype;
|
|
73
64
|
Object.defineProperty(proto, 'execution', {
|
|
74
65
|
get() {
|
|
75
66
|
return this[kExecutions][0];
|
|
76
67
|
}
|
|
77
|
-
|
|
78
68
|
});
|
|
79
69
|
Object.defineProperty(proto, 'executions', {
|
|
80
70
|
get() {
|
|
81
71
|
return this[kExecutions].slice();
|
|
82
72
|
}
|
|
83
|
-
|
|
84
73
|
});
|
|
85
|
-
|
|
86
74
|
proto.execute = function execute(executeMessage) {
|
|
87
75
|
const content = executeMessage.content;
|
|
88
76
|
let executionId = this.executionId;
|
|
89
|
-
|
|
90
77
|
if (content.isRootScope) {
|
|
91
78
|
executionId = this.executionId = content.executionId;
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
const loopCharacteristics = this.loopCharacteristics;
|
|
95
|
-
|
|
96
81
|
if (loopCharacteristics && content.isRootScope) {
|
|
97
82
|
this.broker.subscribeTmp('api', `activity.#.${executionId}`, this[kMessageHandlers].onApiRootMessage, {
|
|
98
83
|
noAck: true,
|
|
@@ -101,13 +86,10 @@ proto.execute = function execute(executeMessage) {
|
|
|
101
86
|
});
|
|
102
87
|
return loopCharacteristics.execute(executeMessage);
|
|
103
88
|
}
|
|
104
|
-
|
|
105
89
|
const processExecution = this._upsertExecution(executeMessage);
|
|
106
|
-
|
|
107
90
|
if (!processExecution) return;
|
|
108
91
|
return processExecution.execute(executeMessage);
|
|
109
92
|
};
|
|
110
|
-
|
|
111
93
|
proto.stop = function stop() {
|
|
112
94
|
for (const execution of this[kExecutions]) {
|
|
113
95
|
this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
|
|
@@ -115,7 +97,6 @@ proto.stop = function stop() {
|
|
|
115
97
|
execution.stop();
|
|
116
98
|
}
|
|
117
99
|
};
|
|
118
|
-
|
|
119
100
|
proto.discard = function discard() {
|
|
120
101
|
for (const execution of this[kExecutions]) {
|
|
121
102
|
this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
|
|
@@ -123,7 +104,6 @@ proto.discard = function discard() {
|
|
|
123
104
|
execution.discard();
|
|
124
105
|
}
|
|
125
106
|
};
|
|
126
|
-
|
|
127
107
|
proto.getState = function getState() {
|
|
128
108
|
if (this.loopCharacteristics) {
|
|
129
109
|
return {
|
|
@@ -134,120 +114,96 @@ proto.getState = function getState() {
|
|
|
134
114
|
})
|
|
135
115
|
};
|
|
136
116
|
}
|
|
137
|
-
|
|
138
117
|
const execution = this.execution;
|
|
139
|
-
|
|
140
118
|
if (execution) {
|
|
141
119
|
const state = execution.getState();
|
|
142
120
|
state.environment = execution.environment.getState();
|
|
143
121
|
return state;
|
|
144
122
|
}
|
|
145
123
|
};
|
|
146
|
-
|
|
147
124
|
proto.recover = function recover(state) {
|
|
148
125
|
if (!state) return;
|
|
149
126
|
const executions = this[kExecutions];
|
|
150
127
|
const loopCharacteristics = this.loopCharacteristics;
|
|
151
|
-
|
|
152
128
|
if (loopCharacteristics && state.executions) {
|
|
153
129
|
executions.splice(0);
|
|
154
|
-
|
|
155
130
|
for (const se of state.executions) {
|
|
156
131
|
this.recover(se);
|
|
157
132
|
}
|
|
158
|
-
|
|
159
133
|
return;
|
|
160
134
|
}
|
|
161
|
-
|
|
162
135
|
if (!loopCharacteristics) {
|
|
163
136
|
executions.splice(0);
|
|
164
137
|
}
|
|
165
|
-
|
|
166
138
|
const subEnvironment = this.environment.clone().recover(state.environment);
|
|
167
139
|
const subContext = this.context.clone(subEnvironment);
|
|
168
140
|
const execution = new _ProcessExecution.default(this.activity, subContext).recover(state);
|
|
169
141
|
executions.push(execution);
|
|
170
142
|
return execution;
|
|
171
143
|
};
|
|
172
|
-
|
|
173
144
|
proto.getPostponed = function getPostponed() {
|
|
174
145
|
return this[kExecutions].reduce((result, pe) => {
|
|
175
146
|
result = result.concat(pe.getPostponed());
|
|
176
147
|
return result;
|
|
177
148
|
}, []);
|
|
178
149
|
};
|
|
179
|
-
|
|
180
150
|
proto._onApiRootMessage = function onApiRootMessage(_, message) {
|
|
181
151
|
const messageType = message.properties.type;
|
|
182
|
-
|
|
183
152
|
switch (messageType) {
|
|
184
153
|
case 'stop':
|
|
185
154
|
this.broker.cancel(message.fields.consumerTag);
|
|
186
155
|
this.stop();
|
|
187
156
|
break;
|
|
188
|
-
|
|
189
157
|
case 'discard':
|
|
190
158
|
this.broker.cancel(message.fields.consumerTag);
|
|
191
159
|
this.discard();
|
|
192
160
|
break;
|
|
193
161
|
}
|
|
194
162
|
};
|
|
195
|
-
|
|
196
163
|
proto._upsertExecution = function upsertExecution(executeMessage) {
|
|
197
164
|
const content = executeMessage.content;
|
|
198
165
|
const executionId = content.executionId;
|
|
199
|
-
|
|
200
166
|
let execution = this._getExecutionById(executionId);
|
|
201
|
-
|
|
202
167
|
if (execution) {
|
|
203
168
|
if (executeMessage.fields.redelivered) this._addListeners(execution, executionId);
|
|
204
169
|
return execution;
|
|
205
170
|
}
|
|
206
|
-
|
|
207
171
|
const subEnvironment = this.environment.clone();
|
|
208
172
|
const subContext = this.context.clone(subEnvironment);
|
|
209
173
|
execution = new _ProcessExecution.default(this.activity, subContext);
|
|
210
174
|
this[kExecutions].push(execution);
|
|
211
|
-
|
|
212
175
|
this._addListeners(execution, executionId);
|
|
213
|
-
|
|
214
176
|
return execution;
|
|
215
177
|
};
|
|
216
|
-
|
|
217
178
|
proto._addListeners = function addListeners(processExecution, executionId) {
|
|
218
179
|
this.broker.subscribeTmp('subprocess-execution', `execution.#.${executionId}`, this[kMessageHandlers].onExecutionCompleted, {
|
|
219
180
|
noAck: true,
|
|
220
181
|
consumerTag: `_sub-process-execution-${executionId}`
|
|
221
182
|
});
|
|
222
183
|
};
|
|
223
|
-
|
|
224
184
|
proto._onExecutionCompleted = function onExecutionCompleted(_, message) {
|
|
225
185
|
if (message.fields.redelivered && message.properties.persistent === false) return;
|
|
226
186
|
const content = message.content;
|
|
227
187
|
const messageType = message.properties.type;
|
|
228
188
|
const broker = this.broker;
|
|
229
|
-
|
|
230
189
|
switch (messageType) {
|
|
231
190
|
case 'stopped':
|
|
232
191
|
{
|
|
233
192
|
broker.cancel(message.fields.consumerTag);
|
|
234
193
|
break;
|
|
235
194
|
}
|
|
236
|
-
|
|
237
195
|
case 'discard':
|
|
238
196
|
{
|
|
239
197
|
broker.cancel(message.fields.consumerTag);
|
|
240
198
|
broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(content));
|
|
241
199
|
break;
|
|
242
200
|
}
|
|
243
|
-
|
|
244
201
|
case 'completed':
|
|
245
202
|
{
|
|
246
203
|
broker.cancel(message.fields.consumerTag);
|
|
247
204
|
broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content));
|
|
248
205
|
break;
|
|
249
206
|
}
|
|
250
|
-
|
|
251
207
|
case 'error':
|
|
252
208
|
{
|
|
253
209
|
broker.cancel(message.fields.consumerTag);
|
|
@@ -260,21 +216,17 @@ proto._onExecutionCompleted = function onExecutionCompleted(_, message) {
|
|
|
260
216
|
}
|
|
261
217
|
}
|
|
262
218
|
};
|
|
263
|
-
|
|
264
219
|
proto.getApi = function getApi(apiMessage) {
|
|
265
220
|
const content = apiMessage.content;
|
|
266
221
|
if (content.id === this.id) return;
|
|
267
222
|
let execution;
|
|
268
|
-
|
|
269
223
|
if (execution = this._getExecutionById(content.parent.executionId)) {
|
|
270
224
|
return execution.getApi(apiMessage);
|
|
271
225
|
}
|
|
272
|
-
|
|
273
226
|
for (const pp of content.parent.path) {
|
|
274
227
|
if (execution = this._getExecutionById(pp.executionId)) return execution.getApi(apiMessage);
|
|
275
228
|
}
|
|
276
229
|
};
|
|
277
|
-
|
|
278
230
|
proto._getExecutionById = function getExecutionById(executionId) {
|
|
279
231
|
return this[kExecutions].find(pe => pe.executionId === executionId);
|
|
280
232
|
};
|
package/dist/src/tasks/Task.js
CHANGED
|
@@ -5,17 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TaskBehaviour = TaskBehaviour;
|
|
7
7
|
exports.default = Task;
|
|
8
|
-
|
|
9
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity"));
|
|
10
|
-
|
|
11
9
|
var _messageHelper = require("../messageHelper");
|
|
12
|
-
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
11
|
function Task(activityDef, context) {
|
|
16
12
|
return new _Activity.default(TaskBehaviour, activityDef, context);
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
function TaskBehaviour(activity) {
|
|
20
15
|
const {
|
|
21
16
|
id,
|
|
@@ -28,14 +23,11 @@ function TaskBehaviour(activity) {
|
|
|
28
23
|
this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
|
|
29
24
|
this.broker = broker;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
TaskBehaviour.prototype.execute = function execute(executeMessage) {
|
|
33
27
|
const executeContent = executeMessage.content;
|
|
34
28
|
const loopCharacteristics = this.loopCharacteristics;
|
|
35
|
-
|
|
36
29
|
if (loopCharacteristics && executeContent.isRootScope) {
|
|
37
30
|
return loopCharacteristics.execute(executeMessage);
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
|
|
41
33
|
};
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = Transaction;
|
|
7
|
-
|
|
8
7
|
var _SubProcess = _interopRequireDefault(require("./SubProcess"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
function Transaction(activityDef, context) {
|
|
13
10
|
const transaction = {
|
|
14
11
|
type: 'transaction',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-elements",
|
|
3
|
-
"version": "8.1
|
|
3
|
+
"version": "8.2.1",
|
|
4
4
|
"description": "Executable workflow elements based on BPMN 2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
],
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@aircall/expression-parser": "^1.0.4",
|
|
49
|
-
"@babel/cli": "^7.
|
|
50
|
-
"@babel/core": "^7.
|
|
51
|
-
"@babel/preset-env": "^7.
|
|
52
|
-
"@babel/register": "^7.18.
|
|
49
|
+
"@babel/cli": "^7.19.3",
|
|
50
|
+
"@babel/core": "^7.20.2",
|
|
51
|
+
"@babel/preset-env": "^7.20.2",
|
|
52
|
+
"@babel/register": "^7.18.9",
|
|
53
53
|
"bpmn-moddle": "^7.1.2",
|
|
54
54
|
"camunda-bpmn-moddle": "^6.1.2",
|
|
55
|
-
"chai": "^4.3.
|
|
55
|
+
"chai": "^4.3.7",
|
|
56
56
|
"chronokinesis": "^3.0.0",
|
|
57
57
|
"debug": "^4.3.4",
|
|
58
|
-
"eslint": "^
|
|
58
|
+
"eslint": "^8.27.0",
|
|
59
59
|
"got": "^11.8.5",
|
|
60
|
-
"mocha": "^
|
|
60
|
+
"mocha": "^10.1.0",
|
|
61
61
|
"mocha-cakes-2": "^3.3.0",
|
|
62
62
|
"moddle-context-serializer": "^2.1.0",
|
|
63
63
|
"nock": "^13.2.8",
|
package/src/Context.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import BpmnIO from './io/BpmnIO';
|
|
1
2
|
import Environment from './Environment';
|
|
2
3
|
import ExtensionsMapper from './ExtensionsMapper';
|
|
3
4
|
import {getUniqueId} from './shared';
|
|
@@ -16,7 +17,7 @@ function ContextInstance(definitionContext, environment) {
|
|
|
16
17
|
this.sid = sid;
|
|
17
18
|
this.definitionContext = definitionContext;
|
|
18
19
|
this.environment = environment;
|
|
19
|
-
this.extensionsMapper = ExtensionsMapper(this);
|
|
20
|
+
this.extensionsMapper = new ExtensionsMapper(this);
|
|
20
21
|
this.refs = {
|
|
21
22
|
activityRefs: {},
|
|
22
23
|
associationRefs: [],
|
|
@@ -196,6 +197,9 @@ proto.getStartActivities = function getStartActivities(filterOptions, scopeId) {
|
|
|
196
197
|
};
|
|
197
198
|
|
|
198
199
|
proto.loadExtensions = function loadExtensions(activity) {
|
|
199
|
-
|
|
200
|
+
const io = new BpmnIO(activity, this);
|
|
201
|
+
const extensions = this.extensionsMapper.get(activity);
|
|
202
|
+
if (io.hasIo) extensions.extensions.push(io);
|
|
203
|
+
if (!extensions.extensions.length) return;
|
|
204
|
+
return extensions;
|
|
200
205
|
};
|
|
201
|
-
|
package/src/ExtensionsMapper.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
const {extensions: envExtensions} = context.environment;
|
|
3
|
-
const extensions = getExtensions();
|
|
1
|
+
const kActivated = Symbol.for('activated');
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export default function ExtensionsMapper(context) {
|
|
4
|
+
this.context = context;
|
|
5
|
+
}
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
activate,
|
|
13
|
-
deactivate,
|
|
14
|
-
};
|
|
7
|
+
ExtensionsMapper.prototype.get = function get(activity) {
|
|
8
|
+
return new Extensions(activity, this.context, this._getExtensions());
|
|
9
|
+
};
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
ExtensionsMapper.prototype._getExtensions = function getExtensions() {
|
|
12
|
+
let extensions;
|
|
13
|
+
if (!(extensions = this.context.environment.extensions)) return [];
|
|
14
|
+
return Object.values(extensions);
|
|
15
|
+
};
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
17
|
+
function Extensions(activity, context, extensions) {
|
|
18
|
+
const result = this.extensions = [];
|
|
19
|
+
for (const Extension of extensions) {
|
|
20
|
+
const extension = Extension(activity, context);
|
|
21
|
+
if (extension) result.push(extension);
|
|
28
22
|
}
|
|
23
|
+
this[kActivated] = false;
|
|
24
|
+
}
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
Object.defineProperty(Extensions.prototype, 'count', {
|
|
27
|
+
get() {
|
|
28
|
+
return this.extensions.length;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
Extensions.prototype.activate = function activate(message) {
|
|
33
|
+
if (this[kActivated]) return;
|
|
34
|
+
this[kActivated] = true;
|
|
35
|
+
for (const extension of this.extensions) extension.activate(message);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Extensions.prototype.deactivate = function deactivate(message) {
|
|
39
|
+
if (!this[kActivated]) return;
|
|
40
|
+
this[kActivated] = false;
|
|
41
|
+
for (const extension of this.extensions) extension.deactivate(message);
|
|
42
|
+
};
|
package/src/activity/Activity.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import ActivityExecution from './ActivityExecution';
|
|
2
|
-
import BpmnIO from '../io/BpmnIO';
|
|
3
2
|
import {brokerSafeId, getUniqueId} from '../shared';
|
|
4
3
|
import {ActivityApi} from '../Api';
|
|
5
4
|
import {ActivityBroker} from '../EventBroker';
|
|
@@ -8,7 +7,6 @@ import {cloneContent, cloneParent, cloneMessage} from '../messageHelper';
|
|
|
8
7
|
import {makeErrorFromMessage, ActivityError} from '../error/Errors';
|
|
9
8
|
|
|
10
9
|
const kActivityDef = Symbol.for('activityDefinition');
|
|
11
|
-
const kBpmnIo = Symbol.for('bpmnIo');
|
|
12
10
|
const kConsuming = Symbol.for('consuming');
|
|
13
11
|
const kCounters = Symbol.for('counters');
|
|
14
12
|
const kEventDefinitions = Symbol.for('eventDefinitions');
|
|
@@ -105,6 +103,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map((ed) => new ed.Behaviour(this, ed, this.context));
|
|
106
|
+
this[kExtensions] = context.loadExtensions(this);
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
const proto = Activity.prototype;
|
|
@@ -130,21 +129,18 @@ Object.defineProperty(proto, 'executionId', {
|
|
|
130
129
|
},
|
|
131
130
|
});
|
|
132
131
|
|
|
133
|
-
Object.defineProperty(proto, '
|
|
132
|
+
Object.defineProperty(proto, 'extensions', {
|
|
134
133
|
enumerable: true,
|
|
135
134
|
get() {
|
|
136
|
-
|
|
137
|
-
const bpmnIo = this[kBpmnIo] = new BpmnIO(this, this.context);
|
|
138
|
-
return bpmnIo;
|
|
135
|
+
return this[kExtensions];
|
|
139
136
|
},
|
|
140
137
|
});
|
|
141
138
|
|
|
142
|
-
Object.defineProperty(proto, '
|
|
139
|
+
Object.defineProperty(proto, 'bpmnIo', {
|
|
143
140
|
enumerable: true,
|
|
144
141
|
get() {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return extensions;
|
|
142
|
+
const extensions = this[kExtensions];
|
|
143
|
+
return extensions && extensions.extensions.find(e => e.type === 'bpmnio');
|
|
148
144
|
},
|
|
149
145
|
});
|
|
150
146
|
|
|
@@ -408,10 +404,12 @@ proto._discardRun = function discardRun() {
|
|
|
408
404
|
}
|
|
409
405
|
|
|
410
406
|
this._deactivateRunConsumers();
|
|
411
|
-
|
|
407
|
+
|
|
408
|
+
const message = this[kStateMessage];
|
|
409
|
+
if (this.extensions) this.extensions.deactivate(cloneMessage(message));
|
|
412
410
|
const broker = this.broker;
|
|
413
411
|
broker.getQueue('run-q').purge();
|
|
414
|
-
broker.publish('run', 'run.discard', cloneContent(
|
|
412
|
+
broker.publish('run', 'run.discard', cloneContent(message.content));
|
|
415
413
|
this._consumeRunQ();
|
|
416
414
|
};
|
|
417
415
|
|
|
@@ -601,12 +599,9 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
601
599
|
this.status = 'entered';
|
|
602
600
|
if (!isRedelivered) {
|
|
603
601
|
this[kExec].execution = null;
|
|
602
|
+
if (this.extensions) this.extensions.activate(cloneMessage(message));
|
|
603
|
+
this._publishEvent('enter', content, {correlationId});
|
|
604
604
|
}
|
|
605
|
-
|
|
606
|
-
if (this.extensions) this.extensions.activate(cloneMessage(message), this);
|
|
607
|
-
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
608
|
-
|
|
609
|
-
if (!isRedelivered) this._publishEvent('enter', content, {correlationId});
|
|
610
605
|
break;
|
|
611
606
|
}
|
|
612
607
|
case 'run.discard': {
|
|
@@ -615,8 +610,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
615
610
|
this.status = 'discard';
|
|
616
611
|
this[kExec].execution = null;
|
|
617
612
|
|
|
618
|
-
if (this.extensions) this.extensions.activate(cloneMessage(message)
|
|
619
|
-
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
613
|
+
if (this.extensions) this.extensions.activate(cloneMessage(message));
|
|
620
614
|
|
|
621
615
|
if (!isRedelivered) {
|
|
622
616
|
this.broker.publish('run', 'run.discarded', content, {correlationId});
|
|
@@ -631,7 +625,6 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
631
625
|
this.broker.publish('run', 'run.execute', content, {correlationId});
|
|
632
626
|
this._publishEvent('start', content, {correlationId});
|
|
633
627
|
}
|
|
634
|
-
|
|
635
628
|
break;
|
|
636
629
|
}
|
|
637
630
|
case 'run.execute.passthrough': {
|
|
@@ -645,23 +638,15 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
645
638
|
this.status = 'executing';
|
|
646
639
|
this[kExecuteMessage] = message;
|
|
647
640
|
|
|
648
|
-
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {exclusive: true, consumerTag: '_activity-execution'});
|
|
649
641
|
const exec = this[kExec];
|
|
642
|
+
if (isRedelivered && this.extensions) this.extensions.activate(cloneMessage(message));
|
|
650
643
|
if (!exec.execution) exec.execution = new ActivityExecution(this, this.context);
|
|
651
|
-
|
|
652
|
-
if (isRedelivered) {
|
|
653
|
-
return this._resumeExtensions(message, (err, formattedContent) => {
|
|
654
|
-
if (err) return this.emitFatal(err, message.content);
|
|
655
|
-
if (formattedContent) message.content = formattedContent;
|
|
656
|
-
this.status = 'executing';
|
|
657
|
-
return exec.execution.execute(message);
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
|
|
644
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {exclusive: true, consumerTag: '_activity-execution'});
|
|
661
645
|
return exec.execution.execute(message);
|
|
662
646
|
}
|
|
663
647
|
case 'run.end': {
|
|
664
|
-
|
|
648
|
+
this.logger.debug(`<${id}> end`, isRedelivered ? 'redelivered' : '');
|
|
649
|
+
if (isRedelivered) break;
|
|
665
650
|
|
|
666
651
|
this[kCounters].taken++;
|
|
667
652
|
|
|
@@ -707,8 +692,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
707
692
|
case 'run.leave': {
|
|
708
693
|
this.status = undefined;
|
|
709
694
|
|
|
710
|
-
if (this.
|
|
711
|
-
if (this.extensions) this.extensions.deactivate(message);
|
|
695
|
+
if (this.extensions) this.extensions.deactivate(cloneMessage(message));
|
|
712
696
|
|
|
713
697
|
if (!isRedelivered) {
|
|
714
698
|
this.broker.publish('run', 'run.next', content, {persistent: false});
|
|
@@ -844,7 +828,8 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
844
828
|
message.ack();
|
|
845
829
|
|
|
846
830
|
const stateMessage = this[kStateMessage];
|
|
847
|
-
const
|
|
831
|
+
const fields = stateMessage.fields;
|
|
832
|
+
if (!fields.redelivered) return;
|
|
848
833
|
|
|
849
834
|
switch (fields.routingKey) {
|
|
850
835
|
case 'run.enter':
|
|
@@ -857,7 +842,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
857
842
|
return;
|
|
858
843
|
}
|
|
859
844
|
|
|
860
|
-
if (
|
|
845
|
+
if (this.extensions) this.extensions.activate(cloneMessage(stateMessage));
|
|
861
846
|
|
|
862
847
|
this.logger.debug(`<${this.id}> resume from ${message.content.status}`);
|
|
863
848
|
|
|
@@ -887,7 +872,7 @@ proto._onStop = function onStop(message) {
|
|
|
887
872
|
broker.cancel('_format-consumer');
|
|
888
873
|
|
|
889
874
|
if (running) {
|
|
890
|
-
if (this.extensions) this.extensions.deactivate(message
|
|
875
|
+
if (this.extensions) this.extensions.deactivate(cloneMessage(message));
|
|
891
876
|
this._publishEvent('stop', this._createMessage());
|
|
892
877
|
}
|
|
893
878
|
};
|
|
@@ -936,20 +921,6 @@ proto._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId
|
|
|
936
921
|
return this[kFlows].outboundSequenceFlows.find((flow) => flow.id === flowId);
|
|
937
922
|
};
|
|
938
923
|
|
|
939
|
-
proto._resumeExtensions = function resumeExtensions(message, callback) {
|
|
940
|
-
const extensions = this.extensions, bpmnIo = this.bpmnIo;
|
|
941
|
-
if (!extensions && !bpmnIo) return callback();
|
|
942
|
-
|
|
943
|
-
if (extensions) extensions.activate(cloneMessage(message), this);
|
|
944
|
-
if (bpmnIo) bpmnIo.activate(cloneMessage(message), this);
|
|
945
|
-
|
|
946
|
-
this.status = 'formatting';
|
|
947
|
-
return this.formatter.format(message, (err, formattedContent, formatted) => {
|
|
948
|
-
if (err) return callback(err);
|
|
949
|
-
return callback(null, formatted && formattedContent);
|
|
950
|
-
});
|
|
951
|
-
};
|
|
952
|
-
|
|
953
924
|
proto._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
954
925
|
const broker = this.broker;
|
|
955
926
|
broker.cancel('_activity-api');
|
package/src/io/BpmnIO.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default function BpmnIO(activity, context) {
|
|
2
2
|
this.activity = activity;
|
|
3
3
|
this.context = context;
|
|
4
|
+
this.type = 'bpmnio';
|
|
4
5
|
|
|
5
6
|
const {
|
|
6
7
|
ioSpecification: ioSpecificationDef,
|
|
@@ -11,6 +12,12 @@ export default function BpmnIO(activity, context) {
|
|
|
11
12
|
this.properties = propertiesDef && new propertiesDef.Behaviour(activity, propertiesDef, context);
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
Object.defineProperty(BpmnIO.prototype, 'hasIo', {
|
|
16
|
+
get() {
|
|
17
|
+
return this.specification || this.properties;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
14
21
|
BpmnIO.prototype.activate = function activate(message) {
|
|
15
22
|
const properties = this.properties, specification = this.specification;
|
|
16
23
|
if (properties) properties.activate(message);
|
|
@@ -9,6 +9,7 @@ export default function EnvironmentDataObject(dataObjectDef, {environment}) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
EnvironmentDataObject.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
12
|
+
|
|
12
13
|
const environment = this.environment;
|
|
13
14
|
const value = environment.variables._data && environment.variables._data[this.id];
|
|
14
15
|
const content = this._createContent(value);
|