bpmn-elements 8.0.1 → 8.2.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/CHANGELOG.md +10 -0
- package/dist/src/Context.js +8 -2
- package/dist/src/ExtensionsMapper.js +40 -40
- package/dist/src/activity/Activity.js +40 -67
- package/dist/src/activity/ActivityExecution.js +2 -2
- package/dist/src/activity/Message.js +2 -2
- package/dist/src/activity/Signal.js +2 -2
- package/dist/src/eventDefinitions/TimerEventDefinition.js +55 -32
- package/dist/src/events/BoundaryEvent.js +48 -19
- package/dist/src/io/BpmnIO.js +8 -0
- package/dist/src/io/InputOutputSpecification.js +22 -8
- package/dist/src/io/Properties.js +10 -9
- package/dist/src/tasks/ServiceTask.js +1 -5
- package/package.json +8 -9
- package/src/Context.js +7 -2
- package/src/ExtensionsMapper.js +35 -35
- package/src/activity/Activity.js +30 -58
- package/src/activity/ActivityExecution.js +1 -1
- package/src/activity/Message.js +1 -1
- package/src/activity/Signal.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +40 -23
- package/src/events/BoundaryEvent.js +34 -17
- package/src/io/BpmnIO.js +7 -0
- package/src/io/EnvironmentDataObject.js +1 -0
- package/src/io/InputOutputSpecification.js +18 -6
- package/src/io/Properties.js +9 -11
- package/src/tasks/ServiceTask.js +1 -3
|
@@ -66,14 +66,6 @@ proto.execute = function execute(executeMessage) {
|
|
|
66
66
|
if (isRootScope) {
|
|
67
67
|
this[kExecuteMessage] = executeMessage;
|
|
68
68
|
const broker = this.broker;
|
|
69
|
-
|
|
70
|
-
if (eventDefinitionExecution && !this.environment.settings.strict) {
|
|
71
|
-
broker.subscribeTmp('execution', 'execute.expect', this._onExpectMessage.bind(this), {
|
|
72
|
-
noAck: true,
|
|
73
|
-
consumerTag: '_expect-tag'
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
69
|
const consumerTag = `_bound-listener-${executionId}`;
|
|
78
70
|
this.attachedTo.broker.subscribeTmp('event', 'activity.leave', this._onAttachedLeave.bind(this), {
|
|
79
71
|
noAck: true,
|
|
@@ -81,14 +73,23 @@ proto.execute = function execute(executeMessage) {
|
|
|
81
73
|
priority: 300
|
|
82
74
|
});
|
|
83
75
|
this[kAttachedTags].push(consumerTag);
|
|
84
|
-
broker.subscribeOnce('execution', 'execute.detach', this._onDetachMessage.bind(this), {
|
|
85
|
-
consumerTag: '_detach-tag'
|
|
86
|
-
});
|
|
87
76
|
broker.subscribeOnce('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
88
77
|
consumerTag: `_api-${executionId}`
|
|
89
78
|
});
|
|
90
|
-
broker.
|
|
91
|
-
|
|
79
|
+
const execQ = broker.assertQueue(`_bound-execution-${executionId}`, {
|
|
80
|
+
durable: false,
|
|
81
|
+
autoDelete: true
|
|
82
|
+
});
|
|
83
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.detach');
|
|
84
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.bound.completed');
|
|
85
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.repeat');
|
|
86
|
+
|
|
87
|
+
if (eventDefinitionExecution && !this.environment.settings.strict) {
|
|
88
|
+
broker.bindQueue(execQ.name, 'execution', 'execute.expect');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
execQ.consume(this._onExecutionMessage.bind(this), {
|
|
92
|
+
consumerTag: '_execution-tag'
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -97,19 +98,37 @@ proto.execute = function execute(executeMessage) {
|
|
|
97
98
|
}
|
|
98
99
|
};
|
|
99
100
|
|
|
101
|
+
proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
102
|
+
message.ack();
|
|
103
|
+
|
|
104
|
+
switch (routingKey) {
|
|
105
|
+
case 'execute.detach':
|
|
106
|
+
return this._onDetachMessage(routingKey, message);
|
|
107
|
+
|
|
108
|
+
case 'execute.bound.completed':
|
|
109
|
+
return this._onCompleted(routingKey, message);
|
|
110
|
+
|
|
111
|
+
case 'execute.repeat':
|
|
112
|
+
return this._onRepeatMessage(routingKey, message);
|
|
113
|
+
|
|
114
|
+
case 'execute.expect':
|
|
115
|
+
return this._onExpectMessage(routingKey, message);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
100
119
|
proto._onCompleted = function onCompleted(_, {
|
|
101
120
|
content
|
|
102
121
|
}) {
|
|
103
122
|
if (!this.cancelActivity && !content.cancelActivity) {
|
|
104
123
|
this._stop();
|
|
105
124
|
|
|
106
|
-
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content
|
|
125
|
+
return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
|
|
126
|
+
cancelActivity: false
|
|
127
|
+
}));
|
|
107
128
|
}
|
|
108
129
|
|
|
109
130
|
this[kCompleteContent] = content;
|
|
110
|
-
const
|
|
111
|
-
inbound
|
|
112
|
-
} = this[kExecuteMessage].content;
|
|
131
|
+
const inbound = this[kExecuteMessage].content.inbound;
|
|
113
132
|
const attachedToContent = inbound && inbound[0];
|
|
114
133
|
const attachedTo = this.attachedTo;
|
|
115
134
|
this.activity.logger.debug(`<${this.executionId} (${this.id})> cancel ${attachedTo.status} activity <${attachedToContent.executionId} (${attachedToContent.id})>`);
|
|
@@ -199,6 +218,17 @@ proto._onApiMessage = function onApiMessage(_, message) {
|
|
|
199
218
|
}
|
|
200
219
|
};
|
|
201
220
|
|
|
221
|
+
proto._onRepeatMessage = function onRepeatMessage(_, message) {
|
|
222
|
+
if (this.cancelActivity) return;
|
|
223
|
+
const executeMessage = this[kExecuteMessage];
|
|
224
|
+
const repeat = message.content.repeat;
|
|
225
|
+
this.broker.getQueue('inbound-q').queueMessage({
|
|
226
|
+
routingKey: 'activity.restart'
|
|
227
|
+
}, (0, _messageHelper.cloneContent)(executeMessage.content.inbound[0], {
|
|
228
|
+
repeat
|
|
229
|
+
}));
|
|
230
|
+
};
|
|
231
|
+
|
|
202
232
|
proto._stop = function stop(detach) {
|
|
203
233
|
const attachedTo = this.attachedTo,
|
|
204
234
|
broker = this.broker,
|
|
@@ -208,8 +238,7 @@ proto._stop = function stop(detach) {
|
|
|
208
238
|
|
|
209
239
|
for (const shovelName of this[kShovels].splice(0)) attachedTo.broker.closeShovel(shovelName);
|
|
210
240
|
|
|
211
|
-
broker.cancel('
|
|
212
|
-
broker.cancel('_detach-tag');
|
|
241
|
+
broker.cancel('_execution-tag');
|
|
213
242
|
broker.cancel(`_execution-completed-${executionId}`);
|
|
214
243
|
if (detach) return;
|
|
215
244
|
broker.cancel(`_api-${executionId}`);
|
package/dist/src/io/BpmnIO.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.default = BpmnIO;
|
|
|
8
8
|
function BpmnIO(activity, context) {
|
|
9
9
|
this.activity = activity;
|
|
10
10
|
this.context = context;
|
|
11
|
+
this.type = 'bpmnio';
|
|
11
12
|
const {
|
|
12
13
|
ioSpecification: ioSpecificationDef,
|
|
13
14
|
properties: propertiesDef
|
|
@@ -16,6 +17,13 @@ function BpmnIO(activity, context) {
|
|
|
16
17
|
this.properties = propertiesDef && new propertiesDef.Behaviour(activity, propertiesDef, context);
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
Object.defineProperty(BpmnIO.prototype, 'hasIo', {
|
|
21
|
+
get() {
|
|
22
|
+
return this.specification || this.properties;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
});
|
|
26
|
+
|
|
19
27
|
BpmnIO.prototype.activate = function activate(message) {
|
|
20
28
|
const properties = this.properties,
|
|
21
29
|
specification = this.specification;
|
|
@@ -29,8 +29,17 @@ function IoSpecification(activity, ioSpecificationDef, context) {
|
|
|
29
29
|
|
|
30
30
|
const proto = IoSpecification.prototype;
|
|
31
31
|
|
|
32
|
-
proto.activate = function activate() {
|
|
32
|
+
proto.activate = function activate(message) {
|
|
33
33
|
if (this[kConsuming]) return;
|
|
34
|
+
|
|
35
|
+
if (message && message.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
36
|
+
this._onFormatEnter();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (message && message.fields.redelivered && message.fields.routingKey === 'run.end') {
|
|
40
|
+
this._onFormatComplete(message);
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
|
|
35
44
|
noAck: true
|
|
36
45
|
});
|
|
@@ -177,10 +186,11 @@ proto._onFormatComplete = function formatOnComplete(message) {
|
|
|
177
186
|
const endRoutingKey = `run.onend.${safeType}.end`;
|
|
178
187
|
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
179
188
|
endRoutingKey,
|
|
180
|
-
ioSpecification: {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
ioSpecification: { ...(messageInputs && {
|
|
190
|
+
dataInputs: messageInputs.map(input => {
|
|
191
|
+
return { ...input
|
|
192
|
+
};
|
|
193
|
+
})
|
|
184
194
|
}),
|
|
185
195
|
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
186
196
|
}
|
|
@@ -189,9 +199,13 @@ proto._onFormatComplete = function formatOnComplete(message) {
|
|
|
189
199
|
for (const response of responses) sources[response.index].value = response.value;
|
|
190
200
|
|
|
191
201
|
broker.publish('format', endRoutingKey, {
|
|
192
|
-
ioSpecification: {
|
|
193
|
-
|
|
194
|
-
|
|
202
|
+
ioSpecification: { ...(messageInputs && {
|
|
203
|
+
dataInputs: messageInputs.map(input => {
|
|
204
|
+
return { ...input
|
|
205
|
+
};
|
|
206
|
+
})
|
|
207
|
+
}),
|
|
208
|
+
dataOutputs: sources
|
|
195
209
|
}
|
|
196
210
|
});
|
|
197
211
|
});
|
|
@@ -87,6 +87,10 @@ const proto = Properties.prototype;
|
|
|
87
87
|
proto.activate = function activate(message) {
|
|
88
88
|
if (this[kConsuming]) return;
|
|
89
89
|
|
|
90
|
+
if (message.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
91
|
+
this._onActivityEvent('activity.enter', message);
|
|
92
|
+
}
|
|
93
|
+
|
|
90
94
|
if (message.fields.redelivered && message.content.properties) {
|
|
91
95
|
this._onActivityEvent('activity.extension.resume', message);
|
|
92
96
|
}
|
|
@@ -101,16 +105,13 @@ proto.deactivate = function deactivate() {
|
|
|
101
105
|
};
|
|
102
106
|
|
|
103
107
|
proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (routingKey === 'activity.extension.resume') {
|
|
109
|
-
return this._formatOnEnter(message);
|
|
110
|
-
}
|
|
108
|
+
switch (routingKey) {
|
|
109
|
+
case 'activity.enter':
|
|
110
|
+
case 'activity.extension.resume':
|
|
111
|
+
return this._formatOnEnter(message);
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
case 'activity.execution.completed':
|
|
114
|
+
return this._formatOnComplete(message);
|
|
114
115
|
}
|
|
115
116
|
};
|
|
116
117
|
|
|
@@ -70,11 +70,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
70
70
|
|
|
71
71
|
proto.getService = function getService(message) {
|
|
72
72
|
let Service = this.activity.behaviour.Service;
|
|
73
|
-
|
|
74
|
-
if (!Service) {
|
|
75
|
-
Service = this.environment.settings.enableDummyService ? DummyService : null;
|
|
76
|
-
}
|
|
77
|
-
|
|
73
|
+
if (!Service && this.environment.settings.enableDummyService) Service = DummyService;
|
|
78
74
|
return Service && new Service(this.activity, (0, _messageHelper.cloneMessage)(message));
|
|
79
75
|
};
|
|
80
76
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-elements",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Executable workflow elements based on BPMN 2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"scripts": {
|
|
8
9
|
"test": "mocha -R dot",
|
|
9
10
|
"posttest": "npm run dist && eslint . --cache",
|
|
@@ -11,9 +12,7 @@
|
|
|
11
12
|
"cov:html": "nyc mocha -R dot && nyc report --reporter=html",
|
|
12
13
|
"test:lcov": "nyc mocha -R dot && nyc report --reporter lcov && npm run posttest",
|
|
13
14
|
"dist": "babel index.js -d dist && babel src -d dist/src",
|
|
14
|
-
"predist": "node -e \"fs.rmdirSync('./dist/src', {recursive: true});\""
|
|
15
|
-
"test-md": "node scripts/test-markdown ./API.md && node scripts/test-markdown ./docs/Examples.md",
|
|
16
|
-
"toc": "node scripts/generate-api-toc ./API.md,./docs/Examples.md,./docs/Form.md"
|
|
15
|
+
"predist": "node -e \"fs.rmdirSync('./dist/src', {recursive: true});\""
|
|
17
16
|
},
|
|
18
17
|
"repository": {
|
|
19
18
|
"type": "git",
|
|
@@ -47,10 +46,10 @@
|
|
|
47
46
|
],
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@aircall/expression-parser": "^1.0.4",
|
|
50
|
-
"@babel/cli": "^7.
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/preset-env": "^7.
|
|
53
|
-
"@babel/register": "^7.
|
|
49
|
+
"@babel/cli": "^7.19.3",
|
|
50
|
+
"@babel/core": "^7.19.3",
|
|
51
|
+
"@babel/preset-env": "^7.19.3",
|
|
52
|
+
"@babel/register": "^7.18.6",
|
|
54
53
|
"bpmn-moddle": "^7.1.2",
|
|
55
54
|
"camunda-bpmn-moddle": "^6.1.2",
|
|
56
55
|
"chai": "^4.3.6",
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
"mocha": "^9.2.2",
|
|
62
61
|
"mocha-cakes-2": "^3.3.0",
|
|
63
62
|
"moddle-context-serializer": "^2.1.0",
|
|
64
|
-
"nock": "^13.2.
|
|
63
|
+
"nock": "^13.2.8",
|
|
65
64
|
"nyc": "^15.1.0"
|
|
66
65
|
},
|
|
67
66
|
"dependencies": {
|
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,10 @@ 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
206
|
|
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
|
|
|
@@ -452,6 +450,7 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
452
450
|
switch (routingKey) {
|
|
453
451
|
case 'association.take':
|
|
454
452
|
case 'flow.take':
|
|
453
|
+
case 'activity.restart':
|
|
455
454
|
case 'activity.enter':
|
|
456
455
|
return this.run({
|
|
457
456
|
message: content.message,
|
|
@@ -600,12 +599,9 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
600
599
|
this.status = 'entered';
|
|
601
600
|
if (!isRedelivered) {
|
|
602
601
|
this[kExec].execution = null;
|
|
602
|
+
if (this.extensions) this.extensions.activate(cloneMessage(message));
|
|
603
|
+
this._publishEvent('enter', content, {correlationId});
|
|
603
604
|
}
|
|
604
|
-
|
|
605
|
-
if (this.extensions) this.extensions.activate(cloneMessage(message), this);
|
|
606
|
-
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
607
|
-
|
|
608
|
-
if (!isRedelivered) this._publishEvent('enter', content, {correlationId});
|
|
609
605
|
break;
|
|
610
606
|
}
|
|
611
607
|
case 'run.discard': {
|
|
@@ -614,8 +610,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
614
610
|
this.status = 'discard';
|
|
615
611
|
this[kExec].execution = null;
|
|
616
612
|
|
|
617
|
-
if (this.extensions) this.extensions.activate(cloneMessage(message)
|
|
618
|
-
if (this.bpmnIo) this.bpmnIo.activate(message);
|
|
613
|
+
if (this.extensions) this.extensions.activate(cloneMessage(message));
|
|
619
614
|
|
|
620
615
|
if (!isRedelivered) {
|
|
621
616
|
this.broker.publish('run', 'run.discarded', content, {correlationId});
|
|
@@ -630,7 +625,6 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
630
625
|
this.broker.publish('run', 'run.execute', content, {correlationId});
|
|
631
626
|
this._publishEvent('start', content, {correlationId});
|
|
632
627
|
}
|
|
633
|
-
|
|
634
628
|
break;
|
|
635
629
|
}
|
|
636
630
|
case 'run.execute.passthrough': {
|
|
@@ -644,23 +638,15 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
644
638
|
this.status = 'executing';
|
|
645
639
|
this[kExecuteMessage] = message;
|
|
646
640
|
|
|
647
|
-
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {exclusive: true, consumerTag: '_activity-execution'});
|
|
648
641
|
const exec = this[kExec];
|
|
642
|
+
if (isRedelivered && this.extensions) this.extensions.activate(cloneMessage(message));
|
|
649
643
|
if (!exec.execution) exec.execution = new ActivityExecution(this, this.context);
|
|
650
|
-
|
|
651
|
-
if (isRedelivered) {
|
|
652
|
-
return this._resumeExtensions(message, (err, formattedContent) => {
|
|
653
|
-
if (err) return this.emitFatal(err, message.content);
|
|
654
|
-
if (formattedContent) message.content = formattedContent;
|
|
655
|
-
this.status = 'executing';
|
|
656
|
-
return exec.execution.execute(message);
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
|
|
644
|
+
this.broker.getQueue('execution-q').assertConsumer(this[kMessageHandlers].onExecutionMessage, {exclusive: true, consumerTag: '_activity-execution'});
|
|
660
645
|
return exec.execution.execute(message);
|
|
661
646
|
}
|
|
662
647
|
case 'run.end': {
|
|
663
|
-
|
|
648
|
+
this.logger.debug(`<${id}> end`, isRedelivered ? 'redelivered' : '');
|
|
649
|
+
if (isRedelivered) break;
|
|
664
650
|
|
|
665
651
|
this[kCounters].taken++;
|
|
666
652
|
|
|
@@ -706,8 +692,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
706
692
|
case 'run.leave': {
|
|
707
693
|
this.status = undefined;
|
|
708
694
|
|
|
709
|
-
if (this.
|
|
710
|
-
if (this.extensions) this.extensions.deactivate(message);
|
|
695
|
+
if (this.extensions) this.extensions.deactivate(cloneMessage(message));
|
|
711
696
|
|
|
712
697
|
if (!isRedelivered) {
|
|
713
698
|
this.broker.publish('run', 'run.next', content, {persistent: false});
|
|
@@ -788,7 +773,7 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
788
773
|
}
|
|
789
774
|
|
|
790
775
|
this.broker.publish('run', 'run.leave', cloneContent(content, {
|
|
791
|
-
...(outbound.length
|
|
776
|
+
...(outbound.length && {outbound}),
|
|
792
777
|
}), {correlationId});
|
|
793
778
|
|
|
794
779
|
onOutbound();
|
|
@@ -832,7 +817,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
832
817
|
flow: {
|
|
833
818
|
...outboundFlow,
|
|
834
819
|
sequenceId: getUniqueId(`${flowId}_${action}`),
|
|
835
|
-
...(discardSequence
|
|
820
|
+
...(discardSequence && {discardSequence: discardSequence.slice()}),
|
|
836
821
|
},
|
|
837
822
|
}));
|
|
838
823
|
}
|
|
@@ -843,7 +828,8 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
843
828
|
message.ack();
|
|
844
829
|
|
|
845
830
|
const stateMessage = this[kStateMessage];
|
|
846
|
-
const
|
|
831
|
+
const fields = stateMessage.fields;
|
|
832
|
+
if (!fields.redelivered) return;
|
|
847
833
|
|
|
848
834
|
switch (fields.routingKey) {
|
|
849
835
|
case 'run.enter':
|
|
@@ -856,7 +842,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
856
842
|
return;
|
|
857
843
|
}
|
|
858
844
|
|
|
859
|
-
if (
|
|
845
|
+
if (this.extensions) this.extensions.activate(cloneMessage(stateMessage));
|
|
860
846
|
|
|
861
847
|
this.logger.debug(`<${this.id}> resume from ${message.content.status}`);
|
|
862
848
|
|
|
@@ -886,7 +872,7 @@ proto._onStop = function onStop(message) {
|
|
|
886
872
|
broker.cancel('_format-consumer');
|
|
887
873
|
|
|
888
874
|
if (running) {
|
|
889
|
-
if (this.extensions) this.extensions.deactivate(message
|
|
875
|
+
if (this.extensions) this.extensions.deactivate(message ? cloneMessage(message) : this._createMessage());
|
|
890
876
|
this._publishEvent('stop', this._createMessage());
|
|
891
877
|
}
|
|
892
878
|
};
|
|
@@ -919,9 +905,9 @@ proto._createMessage = function createMessage(override) {
|
|
|
919
905
|
...override,
|
|
920
906
|
id: this.id,
|
|
921
907
|
type: this.type,
|
|
922
|
-
...(name
|
|
923
|
-
...(status
|
|
924
|
-
...(parent
|
|
908
|
+
...(name && {name}),
|
|
909
|
+
...(status && {status}),
|
|
910
|
+
...(parent && {parent: cloneParent(parent)}),
|
|
925
911
|
};
|
|
926
912
|
|
|
927
913
|
for (const [flag, value] of Object.entries(this[kFlags])) {
|
|
@@ -935,20 +921,6 @@ proto._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId
|
|
|
935
921
|
return this[kFlows].outboundSequenceFlows.find((flow) => flow.id === flowId);
|
|
936
922
|
};
|
|
937
923
|
|
|
938
|
-
proto._resumeExtensions = function resumeExtensions(message, callback) {
|
|
939
|
-
const extensions = this.extensions, bpmnIo = this.bpmnIo;
|
|
940
|
-
if (!extensions && !bpmnIo) return callback();
|
|
941
|
-
|
|
942
|
-
if (extensions) extensions.activate(cloneMessage(message), this);
|
|
943
|
-
if (bpmnIo) bpmnIo.activate(cloneMessage(message), this);
|
|
944
|
-
|
|
945
|
-
this.status = 'formatting';
|
|
946
|
-
return this.formatter.format(message, (err, formattedContent, formatted) => {
|
|
947
|
-
if (err) return callback(err);
|
|
948
|
-
return callback(null, formatted && formattedContent);
|
|
949
|
-
});
|
|
950
|
-
};
|
|
951
|
-
|
|
952
924
|
proto._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
953
925
|
const broker = this.broker;
|
|
954
926
|
broker.cancel('_activity-api');
|
|
@@ -1070,7 +1042,7 @@ OutboundEvaluator.prototype.completed = function completed(err) {
|
|
|
1070
1042
|
for (const flow of Object.values(result)) {
|
|
1071
1043
|
evaluationResult.push({
|
|
1072
1044
|
...flow,
|
|
1073
|
-
...(message !== undefined
|
|
1045
|
+
...(message !== undefined && {message}),
|
|
1074
1046
|
});
|
|
1075
1047
|
}
|
|
1076
1048
|
|
|
@@ -1082,6 +1054,6 @@ function formatFlowAction(flow, options) {
|
|
|
1082
1054
|
...options,
|
|
1083
1055
|
id: flow.id,
|
|
1084
1056
|
action: options.action,
|
|
1085
|
-
...(flow.isDefault
|
|
1057
|
+
...(flow.isDefault && {isDefault: true}),
|
|
1086
1058
|
};
|
|
1087
1059
|
}
|
|
@@ -345,7 +345,7 @@ proto._debug = function debug(logMessage, executionId) {
|
|
|
345
345
|
|
|
346
346
|
function getExecuteMessage(message) {
|
|
347
347
|
const result = cloneMessage(message, {
|
|
348
|
-
...(message.fields.redelivered
|
|
348
|
+
...(message.fields.redelivered && {isRecovered: true}),
|
|
349
349
|
ignoreIfExecuting: undefined,
|
|
350
350
|
});
|
|
351
351
|
return result;
|
package/src/activity/Message.js
CHANGED
|
@@ -16,7 +16,7 @@ export default function Message(messageDef, context) {
|
|
|
16
16
|
id,
|
|
17
17
|
type,
|
|
18
18
|
messageType: 'message',
|
|
19
|
-
...(name
|
|
19
|
+
...(name && {name: environment.resolveExpression(name, executionMessage)}),
|
|
20
20
|
parent: {...parent},
|
|
21
21
|
};
|
|
22
22
|
}
|
package/src/activity/Signal.js
CHANGED
|
@@ -16,7 +16,7 @@ export default function Signal(signalDef, context) {
|
|
|
16
16
|
id,
|
|
17
17
|
type,
|
|
18
18
|
messageType: 'signal',
|
|
19
|
-
...(name
|
|
19
|
+
...(name && {name: environment.resolveExpression(name, executionMessage)}),
|
|
20
20
|
parent: {...parent},
|
|
21
21
|
};
|
|
22
22
|
}
|