bpmn-elements 16.2.0 → 16.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/dist/Api.js +1 -1
- package/dist/Context.js +2 -4
- package/dist/Environment.js +3 -3
- package/dist/EventBroker.js +1 -1
- package/dist/MessageFormatter.js +2 -2
- package/dist/Tracker.js +1 -0
- package/dist/activity/Activity.js +19 -13
- package/dist/activity/ActivityExecution.js +2 -2
- package/dist/activity/outbound-evaluator.js +0 -3
- package/dist/definition/Definition.js +4 -4
- package/dist/definition/DefinitionExecution.js +6 -6
- package/dist/error/Errors.js +7 -10
- package/dist/eventDefinitions/CancelEventDefinition.js +1 -2
- package/dist/eventDefinitions/CompensateEventDefinition.js +2 -3
- package/dist/eventDefinitions/ConditionalEventDefinition.js +2 -3
- package/dist/eventDefinitions/ErrorEventDefinition.js +3 -4
- package/dist/eventDefinitions/EscalationEventDefinition.js +1 -2
- package/dist/eventDefinitions/LinkEventDefinition.js +1 -2
- package/dist/eventDefinitions/MessageEventDefinition.js +2 -3
- package/dist/eventDefinitions/SignalEventDefinition.js +2 -3
- package/dist/eventDefinitions/TimerEventDefinition.js +2 -3
- package/dist/events/BoundaryEvent.js +2 -3
- package/dist/events/StartEvent.js +1 -2
- package/dist/flows/Association.js +2 -2
- package/dist/flows/SequenceFlow.js +3 -7
- package/dist/io/EnvironmentDataObject.js +1 -1
- package/dist/io/EnvironmentDataStore.js +1 -1
- package/dist/io/EnvironmentDataStoreReference.js +1 -1
- package/dist/io/InputOutputSpecification.js +2 -2
- package/dist/io/Properties.js +14 -14
- package/dist/process/Process.js +5 -7
- package/dist/process/ProcessExecution.js +13 -13
- package/dist/tasks/ServiceTask.js +1 -1
- package/package.json +2 -2
- package/src/Api.js +1 -1
- package/src/Context.js +2 -1
- package/src/Environment.js +3 -3
- package/src/EventBroker.js +1 -1
- package/src/MessageFormatter.js +2 -2
- package/src/Tracker.js +1 -0
- package/src/activity/Activity.js +18 -13
- package/src/activity/ActivityExecution.js +2 -2
- package/src/activity/outbound-evaluator.js +0 -1
- package/src/definition/Definition.js +4 -4
- package/src/definition/DefinitionExecution.js +6 -6
- package/src/error/Errors.js +7 -11
- package/src/eventDefinitions/CancelEventDefinition.js +1 -2
- package/src/eventDefinitions/CompensateEventDefinition.js +2 -3
- package/src/eventDefinitions/ConditionalEventDefinition.js +2 -3
- package/src/eventDefinitions/ErrorEventDefinition.js +3 -4
- package/src/eventDefinitions/EscalationEventDefinition.js +1 -2
- package/src/eventDefinitions/LinkEventDefinition.js +1 -2
- package/src/eventDefinitions/MessageEventDefinition.js +2 -3
- package/src/eventDefinitions/SignalEventDefinition.js +2 -3
- package/src/eventDefinitions/TimerEventDefinition.js +2 -3
- package/src/events/BoundaryEvent.js +2 -3
- package/src/events/StartEvent.js +1 -2
- package/src/flows/Association.js +2 -2
- package/src/flows/SequenceFlow.js +3 -3
- package/src/io/EnvironmentDataObject.js +1 -1
- package/src/io/EnvironmentDataStore.js +1 -1
- package/src/io/EnvironmentDataStoreReference.js +1 -1
- package/src/io/InputOutputSpecification.js +2 -2
- package/src/io/Properties.js +14 -14
- package/src/process/Process.js +5 -7
- package/src/process/ProcessExecution.js +13 -13
- package/src/tasks/ServiceTask.js +1 -1
package/dist/io/Properties.js
CHANGED
|
@@ -12,9 +12,9 @@ function Properties(activity, propertiesDef, context) {
|
|
|
12
12
|
this.activity = activity;
|
|
13
13
|
this.broker = activity.broker;
|
|
14
14
|
const props = this[kProperties] = {
|
|
15
|
-
properties:
|
|
16
|
-
dataInputObjects:
|
|
17
|
-
dataOutputObjects:
|
|
15
|
+
properties: new Set(),
|
|
16
|
+
dataInputObjects: new Set(),
|
|
17
|
+
dataOutputObjects: new Set()
|
|
18
18
|
};
|
|
19
19
|
for (const {
|
|
20
20
|
id,
|
|
@@ -23,16 +23,16 @@ function Properties(activity, propertiesDef, context) {
|
|
|
23
23
|
const source = {
|
|
24
24
|
id,
|
|
25
25
|
type: def.type,
|
|
26
|
-
name: def.behaviour
|
|
26
|
+
name: def.behaviour?.name
|
|
27
27
|
};
|
|
28
|
-
props.properties.
|
|
28
|
+
props.properties.add(source);
|
|
29
29
|
const inputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataObject.id');
|
|
30
30
|
const outputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataOutput.association.target.dataObject.id');
|
|
31
31
|
const inputDataStoreId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataStore.id');
|
|
32
32
|
const outputDataStoreId = (0, _getPropertyValue.default)(def, 'behaviour.dataOutput.association.target.dataStore.id');
|
|
33
33
|
if (inputDataObjectId) {
|
|
34
34
|
const reference = context.getDataObjectById(inputDataObjectId);
|
|
35
|
-
props.dataInputObjects.
|
|
35
|
+
props.dataInputObjects.add({
|
|
36
36
|
id,
|
|
37
37
|
reference
|
|
38
38
|
});
|
|
@@ -42,7 +42,7 @@ function Properties(activity, propertiesDef, context) {
|
|
|
42
42
|
}
|
|
43
43
|
if (outputDataObjectId) {
|
|
44
44
|
const reference = context.getDataObjectById(outputDataObjectId);
|
|
45
|
-
props.dataOutputObjects.
|
|
45
|
+
props.dataOutputObjects.add({
|
|
46
46
|
id,
|
|
47
47
|
reference: reference
|
|
48
48
|
});
|
|
@@ -52,7 +52,7 @@ function Properties(activity, propertiesDef, context) {
|
|
|
52
52
|
}
|
|
53
53
|
if (inputDataStoreId) {
|
|
54
54
|
const reference = context.getDataStoreById(inputDataStoreId);
|
|
55
|
-
props.dataInputObjects.
|
|
55
|
+
props.dataInputObjects.add({
|
|
56
56
|
id,
|
|
57
57
|
reference
|
|
58
58
|
});
|
|
@@ -62,7 +62,7 @@ function Properties(activity, propertiesDef, context) {
|
|
|
62
62
|
}
|
|
63
63
|
if (outputDataStoreId) {
|
|
64
64
|
const reference = context.getDataStoreById(outputDataStoreId);
|
|
65
|
-
props.dataOutputObjects.
|
|
65
|
+
props.dataOutputObjects.add({
|
|
66
66
|
id,
|
|
67
67
|
reference
|
|
68
68
|
});
|
|
@@ -100,7 +100,7 @@ Properties.prototype._formatOnEnter = function formatOnEnter(message) {
|
|
|
100
100
|
const startRoutingKey = 'run.enter.bpmn-properties';
|
|
101
101
|
const dataInputObjects = this[kProperties].dataInputObjects;
|
|
102
102
|
const broker = this.broker;
|
|
103
|
-
if (!dataInputObjects.
|
|
103
|
+
if (!dataInputObjects.size) {
|
|
104
104
|
return broker.getQueue('format-run-q').queueMessage({
|
|
105
105
|
routingKey: startRoutingKey
|
|
106
106
|
}, {
|
|
@@ -114,7 +114,7 @@ Properties.prototype._formatOnEnter = function formatOnEnter(message) {
|
|
|
114
114
|
endRoutingKey,
|
|
115
115
|
properties: this._getProperties(message)
|
|
116
116
|
});
|
|
117
|
-
return read(broker, dataInputObjects, (_, responses) => {
|
|
117
|
+
return read(broker, [...dataInputObjects], (_, responses) => {
|
|
118
118
|
broker.publish('format', endRoutingKey, {
|
|
119
119
|
properties: this._getProperties(message, responses)
|
|
120
120
|
});
|
|
@@ -126,7 +126,7 @@ Properties.prototype._formatOnComplete = function formatOnComplete(message) {
|
|
|
126
126
|
const outputProperties = this._getProperties(message, messageOutput);
|
|
127
127
|
const dataOutputObjects = this[kProperties].dataOutputObjects;
|
|
128
128
|
const broker = this.broker;
|
|
129
|
-
if (!dataOutputObjects.
|
|
129
|
+
if (!dataOutputObjects.size) {
|
|
130
130
|
return broker.getQueue('format-run-q').queueMessage({
|
|
131
131
|
routingKey: startRoutingKey
|
|
132
132
|
}, {
|
|
@@ -140,7 +140,7 @@ Properties.prototype._formatOnComplete = function formatOnComplete(message) {
|
|
|
140
140
|
endRoutingKey,
|
|
141
141
|
properties: outputProperties
|
|
142
142
|
});
|
|
143
|
-
return write(broker, dataOutputObjects, outputProperties, (_, responses) => {
|
|
143
|
+
return write(broker, [...dataOutputObjects], outputProperties, (_, responses) => {
|
|
144
144
|
broker.publish('format', endRoutingKey, {
|
|
145
145
|
properties: this._getProperties(message, responses)
|
|
146
146
|
});
|
|
@@ -194,7 +194,7 @@ function read(broker, dataReferences, callback) {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
function write(broker, dataReferences, properties, callback) {
|
|
197
|
-
const responses =
|
|
197
|
+
const responses = {};
|
|
198
198
|
let count = 0;
|
|
199
199
|
const dataWriteConsumer = broker.subscribeTmp('data', 'data.write.#', onDataWriteResponse, {
|
|
200
200
|
noAck: true
|
package/dist/process/Process.js
CHANGED
|
@@ -81,8 +81,7 @@ Object.defineProperties(Process.prototype, {
|
|
|
81
81
|
},
|
|
82
82
|
lanes: {
|
|
83
83
|
get() {
|
|
84
|
-
|
|
85
|
-
return lanes && lanes.slice();
|
|
84
|
+
return this[kLanes]?.slice();
|
|
86
85
|
}
|
|
87
86
|
},
|
|
88
87
|
extensions: {
|
|
@@ -119,8 +118,7 @@ Object.defineProperties(Process.prototype, {
|
|
|
119
118
|
},
|
|
120
119
|
activityStatus: {
|
|
121
120
|
get() {
|
|
122
|
-
|
|
123
|
-
return execution && execution.activityStatus || 'idle';
|
|
121
|
+
return this[kExec].get('execution')?.activityStatus || 'idle';
|
|
124
122
|
}
|
|
125
123
|
}
|
|
126
124
|
});
|
|
@@ -169,7 +167,7 @@ Process.prototype.getState = function getState() {
|
|
|
169
167
|
stopped: this.stopped,
|
|
170
168
|
counters: this.counters,
|
|
171
169
|
broker: this.broker.getState(true),
|
|
172
|
-
execution: this.execution
|
|
170
|
+
execution: this.execution?.getState()
|
|
173
171
|
};
|
|
174
172
|
};
|
|
175
173
|
Process.prototype.recover = function recover(state) {
|
|
@@ -378,10 +376,10 @@ Process.prototype._publishEvent = function publishEvent(state, content) {
|
|
|
378
376
|
});
|
|
379
377
|
};
|
|
380
378
|
Process.prototype.sendMessage = function sendMessage(message) {
|
|
381
|
-
const messageContent = message
|
|
379
|
+
const messageContent = message?.content;
|
|
382
380
|
if (!messageContent) return;
|
|
383
381
|
let targetsFound = false;
|
|
384
|
-
if (messageContent.target
|
|
382
|
+
if (messageContent.target?.id && this.getActivityById(messageContent.target.id)) {
|
|
385
383
|
targetsFound = true;
|
|
386
384
|
} else if (messageContent.message && this.getStartActivities({
|
|
387
385
|
referenceId: messageContent.message.id,
|
|
@@ -41,8 +41,8 @@ function ProcessExecution(parentActivity, context) {
|
|
|
41
41
|
associations: context.getAssociations(id),
|
|
42
42
|
flows: context.getSequenceFlows(id),
|
|
43
43
|
outboundMessageFlows: context.getMessageFlows(id),
|
|
44
|
-
startActivities:
|
|
45
|
-
triggeredByEvent:
|
|
44
|
+
startActivities: new Set(),
|
|
45
|
+
triggeredByEvent: new Set(),
|
|
46
46
|
detachedActivities: new Set(),
|
|
47
47
|
startSequences: {}
|
|
48
48
|
};
|
|
@@ -127,7 +127,7 @@ ProcessExecution.prototype.resume = function resume() {
|
|
|
127
127
|
detachedActivities,
|
|
128
128
|
postponed
|
|
129
129
|
} = this[kElements];
|
|
130
|
-
if (startActivities.
|
|
130
|
+
if (startActivities.size > 1) {
|
|
131
131
|
for (const a of startActivities) a.shake();
|
|
132
132
|
}
|
|
133
133
|
postponed.clear();
|
|
@@ -182,7 +182,7 @@ ProcessExecution.prototype.getState = function getState() {
|
|
|
182
182
|
flows: flowStates
|
|
183
183
|
}),
|
|
184
184
|
...(outboundMessageFlows.length && {
|
|
185
|
-
messageFlows: outboundMessageFlows.
|
|
185
|
+
messageFlows: outboundMessageFlows.map(f => f.getState()).filter(Boolean)
|
|
186
186
|
}),
|
|
187
187
|
...(associations.length && {
|
|
188
188
|
associations: associations.map(f => f.getState()).filter(Boolean)
|
|
@@ -349,7 +349,7 @@ ProcessExecution.prototype._start = function start() {
|
|
|
349
349
|
postponed,
|
|
350
350
|
detachedActivities
|
|
351
351
|
} = this[kElements];
|
|
352
|
-
if (startActivities.
|
|
352
|
+
if (startActivities.size > 1) {
|
|
353
353
|
for (const a of startActivities) a.shake();
|
|
354
354
|
}
|
|
355
355
|
for (const a of startActivities) a.init();
|
|
@@ -411,8 +411,8 @@ ProcessExecution.prototype._activate = function activate() {
|
|
|
411
411
|
priority: 200
|
|
412
412
|
});
|
|
413
413
|
}
|
|
414
|
-
startActivities.
|
|
415
|
-
triggeredByEvent.
|
|
414
|
+
startActivities.clear();
|
|
415
|
+
triggeredByEvent.clear();
|
|
416
416
|
for (const activity of children) {
|
|
417
417
|
if (activity.placeholder) continue;
|
|
418
418
|
activity.activate(this);
|
|
@@ -421,8 +421,8 @@ ProcessExecution.prototype._activate = function activate() {
|
|
|
421
421
|
consumerTag: '_process-activity-consumer',
|
|
422
422
|
priority: 200
|
|
423
423
|
});
|
|
424
|
-
if (activity.isStart) startActivities.
|
|
425
|
-
if (activity.triggeredByEvent) triggeredByEvent.
|
|
424
|
+
if (activity.isStart) startActivities.add(activity);
|
|
425
|
+
if (activity.triggeredByEvent) triggeredByEvent.add(activity);
|
|
426
426
|
}
|
|
427
427
|
this[kActivated] = true;
|
|
428
428
|
};
|
|
@@ -458,14 +458,14 @@ ProcessExecution.prototype._onDelegateEvent = function onDelegateEvent(message)
|
|
|
458
458
|
const eventType = message.properties.type;
|
|
459
459
|
let delegate = true;
|
|
460
460
|
const content = message.content;
|
|
461
|
-
if (content.message
|
|
461
|
+
if (content.message?.id) {
|
|
462
462
|
this._debug(`delegate ${eventType} event with id <${content.message.id}>`);
|
|
463
463
|
} else {
|
|
464
464
|
this._debug(`delegate ${eventType} anonymous event`);
|
|
465
465
|
}
|
|
466
466
|
for (const activity of this[kElements].triggeredByEvent) {
|
|
467
467
|
if (activity.getStartActivities({
|
|
468
|
-
referenceId: content.message
|
|
468
|
+
referenceId: content.message?.id,
|
|
469
469
|
referenceType: eventType
|
|
470
470
|
}).length) {
|
|
471
471
|
delegate = false;
|
|
@@ -588,7 +588,7 @@ ProcessExecution.prototype._onChildMessage = function onChildMessage(routingKey,
|
|
|
588
588
|
{
|
|
589
589
|
let eventCaughtBy;
|
|
590
590
|
for (const msg of this[kElements].postponed) {
|
|
591
|
-
if (msg.fields.routingKey === 'activity.catch' && msg.content.source
|
|
591
|
+
if (msg.fields.routingKey === 'activity.catch' && msg.content.source?.executionId === content.executionId) {
|
|
592
592
|
eventCaughtBy = msg;
|
|
593
593
|
break;
|
|
594
594
|
}
|
|
@@ -676,7 +676,7 @@ ProcessExecution.prototype._onChildCompleted = function onChildCompleted(message
|
|
|
676
676
|
type: 'cancel'
|
|
677
677
|
});
|
|
678
678
|
}
|
|
679
|
-
if (isEnd && startActivities.
|
|
679
|
+
if (isEnd && startActivities.size) {
|
|
680
680
|
const startSequences = this[kElements].startSequences;
|
|
681
681
|
for (const msg of postponed) {
|
|
682
682
|
const postponedId = msg.content.id;
|
|
@@ -80,7 +80,7 @@ ServiceTaskBehaviour.prototype._onApiMessage = function onApiMessage(executeMess
|
|
|
80
80
|
const executionId = executeMessage.content.executionId;
|
|
81
81
|
broker.cancel(`_api-${executionId}`);
|
|
82
82
|
const service = this.service;
|
|
83
|
-
if (service
|
|
83
|
+
if (service?.stop) service.stop(message);
|
|
84
84
|
return this.activity.logger.debug(`<${executionId} (${this.id})> stopped`);
|
|
85
85
|
}
|
|
86
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-elements",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.1",
|
|
4
4
|
"description": "Executable workflow elements based on BPMN 2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"texample": "^0.0.6"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@0dep/piso": "^2.0
|
|
106
|
+
"@0dep/piso": "^2.2.0",
|
|
107
107
|
"smqp": "^9.0.2"
|
|
108
108
|
}
|
|
109
109
|
}
|
package/src/Api.js
CHANGED
|
@@ -71,7 +71,7 @@ Api.prototype.resolveExpression = function resolveExpression(expression) {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
Api.prototype.sendApiMessage = function sendApiMessage(action, content, options) {
|
|
74
|
-
const correlationId =
|
|
74
|
+
const correlationId = options?.correlationId || getUniqueId(`${this.id || this.messagePrefix}_signal`);
|
|
75
75
|
let key = `${this.messagePrefix}.${action}`;
|
|
76
76
|
if (this.executionId) key += `.${this.executionId}`;
|
|
77
77
|
this.broker.publish('api', key, this.createMessage(content), { ...options, correlationId, type: action });
|
package/src/Context.js
CHANGED
|
@@ -206,7 +206,8 @@ ContextInstance.prototype.getDataStoreById = function getDataStoreById(reference
|
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
ContextInstance.prototype.getStartActivities = function getStartActivities(filterOptions, scopeId) {
|
|
209
|
-
const
|
|
209
|
+
const referenceId = filterOptions?.referenceId;
|
|
210
|
+
const referenceType = filterOptions?.referenceType || 'unknown';
|
|
210
211
|
const result = [];
|
|
211
212
|
for (const activity of this.getActivities()) {
|
|
212
213
|
if (!activity.isStart) continue;
|
package/src/Environment.js
CHANGED
|
@@ -59,7 +59,7 @@ Environment.prototype.recover = function recover(state) {
|
|
|
59
59
|
return this;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
Environment.prototype.clone = function clone(overrideOptions
|
|
62
|
+
Environment.prototype.clone = function clone(overrideOptions) {
|
|
63
63
|
const services = this[kServices];
|
|
64
64
|
const newOptions = {
|
|
65
65
|
settings: { ...this.settings },
|
|
@@ -74,7 +74,7 @@ Environment.prototype.clone = function clone(overrideOptions = {}) {
|
|
|
74
74
|
services,
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
if (overrideOptions
|
|
77
|
+
if (overrideOptions?.services) newOptions.services = { ...services, ...overrideOptions.services };
|
|
78
78
|
|
|
79
79
|
return new this.constructor(newOptions);
|
|
80
80
|
};
|
|
@@ -109,7 +109,7 @@ Environment.prototype.getServiceByName = function getServiceByName(serviceName)
|
|
|
109
109
|
return this[kServices][serviceName];
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
Environment.prototype.resolveExpression = function resolveExpression(expression, message
|
|
112
|
+
Environment.prototype.resolveExpression = function resolveExpression(expression, message, expressionFnContext) {
|
|
113
113
|
const from = {
|
|
114
114
|
environment: this,
|
|
115
115
|
...message,
|
package/src/EventBroker.js
CHANGED
|
@@ -78,7 +78,7 @@ EventBroker.prototype.on = function on(eventName, callback, eventOptions = { onc
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
EventBroker.prototype.once = function once(eventName, callback, eventOptions
|
|
81
|
+
EventBroker.prototype.once = function once(eventName, callback, eventOptions) {
|
|
82
82
|
return this.on(eventName, callback, { ...eventOptions, once: true });
|
|
83
83
|
};
|
|
84
84
|
|
package/src/MessageFormatter.js
CHANGED
|
@@ -65,7 +65,7 @@ Formatter.prototype._onMessage = function onMessage(routingKey, message) {
|
|
|
65
65
|
default: {
|
|
66
66
|
message.ack();
|
|
67
67
|
|
|
68
|
-
const endRoutingKey = message.content
|
|
68
|
+
const endRoutingKey = message.content?.endRoutingKey;
|
|
69
69
|
if (endRoutingKey) {
|
|
70
70
|
this._decorate(message.content);
|
|
71
71
|
pending.push(message);
|
|
@@ -99,7 +99,7 @@ Formatter.prototype._complete = function complete(message, isError) {
|
|
|
99
99
|
this.broker.cancel(message.fields.consumerTag);
|
|
100
100
|
|
|
101
101
|
if (isError) {
|
|
102
|
-
const error =
|
|
102
|
+
const error = message.content?.error || new Error('formatting failed');
|
|
103
103
|
const errMessage = error.message || 'formatting failed';
|
|
104
104
|
this._debug(`formatting of ${formatKey} failed with ${message.fields.routingKey}: ${errMessage}`);
|
|
105
105
|
return callback(new ActivityError(errMessage, cloneMessage(runMessage), error));
|
package/src/Tracker.js
CHANGED
|
@@ -30,6 +30,7 @@ ActivityTracker.prototype.track = function track(routingKey, message) {
|
|
|
30
30
|
break;
|
|
31
31
|
case 'activity.execution.outbound.take':
|
|
32
32
|
case 'activity.detach':
|
|
33
|
+
case 'activity.call':
|
|
33
34
|
case 'activity.wait': {
|
|
34
35
|
if (content.isMultiInstance) this._waiting(content.parent.executionId);
|
|
35
36
|
else this._waiting(executionId);
|
package/src/activity/Activity.js
CHANGED
|
@@ -94,7 +94,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
94
94
|
isTransaction: activityDef.isTransaction,
|
|
95
95
|
isParallelJoin,
|
|
96
96
|
isThrowing: activityDef.isThrowing,
|
|
97
|
-
lane: activityDef.lane
|
|
97
|
+
lane: activityDef.lane?.id,
|
|
98
98
|
};
|
|
99
99
|
this[kExec] = new Map();
|
|
100
100
|
|
|
@@ -105,7 +105,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
105
105
|
onExecutionMessage: this._onExecutionMessage.bind(this),
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
this[kEventDefinitions] = eventDefinitions
|
|
108
|
+
this[kEventDefinitions] = eventDefinitions?.map((ed, idx) => new ed.Behaviour(this, ed, context, idx));
|
|
109
109
|
this[kExtensions] = context.loadExtensions(this);
|
|
110
110
|
this[kConsuming] = false;
|
|
111
111
|
this[kConsumingRunQ] = undefined;
|
|
@@ -135,7 +135,7 @@ Object.defineProperties(Activity.prototype, {
|
|
|
135
135
|
bpmnIo: {
|
|
136
136
|
get() {
|
|
137
137
|
const extensions = this[kExtensions];
|
|
138
|
-
return extensions
|
|
138
|
+
return extensions?.extensions.find((e) => e.type === 'bpmnio');
|
|
139
139
|
},
|
|
140
140
|
},
|
|
141
141
|
formatter: {
|
|
@@ -655,7 +655,7 @@ Activity.prototype._continueRunMessage = function continueRunMessage(routingKey,
|
|
|
655
655
|
break;
|
|
656
656
|
}
|
|
657
657
|
case 'run.execute.passthrough': {
|
|
658
|
-
const execution = this.execution;
|
|
658
|
+
const execution = this[kExec].get('execution');
|
|
659
659
|
if (!isRedelivered && execution) {
|
|
660
660
|
if (execution.completed) return message.ack();
|
|
661
661
|
this[kExecuteMessage] = message;
|
|
@@ -666,13 +666,19 @@ Activity.prototype._continueRunMessage = function continueRunMessage(routingKey,
|
|
|
666
666
|
this.status = 'executing';
|
|
667
667
|
this[kExecuteMessage] = message;
|
|
668
668
|
|
|
669
|
-
const exec = this[kExec];
|
|
670
669
|
if (isRedelivered && this.extensions) this.extensions.activate(cloneMessage(message));
|
|
671
|
-
|
|
670
|
+
|
|
671
|
+
const exec = this[kExec];
|
|
672
|
+
let execution = exec.get('execution');
|
|
673
|
+
if (!execution) {
|
|
674
|
+
execution = new ActivityExecution(this, this.context);
|
|
675
|
+
exec.set('execution', execution);
|
|
676
|
+
}
|
|
677
|
+
|
|
672
678
|
this.broker
|
|
673
679
|
.getQueue('execution-q')
|
|
674
680
|
.assertConsumer(this[kMessageHandlers].onExecutionMessage, { exclusive: true, consumerTag: '_activity-execution' });
|
|
675
|
-
return
|
|
681
|
+
return execution.execute(message);
|
|
676
682
|
}
|
|
677
683
|
case 'run.end': {
|
|
678
684
|
this.logger.debug(`<${id}> end`, isRedelivered ? 'redelivered' : '');
|
|
@@ -827,14 +833,14 @@ Activity.prototype._doOutbound = function doOutbound(fromMessage, isDiscarded, c
|
|
|
827
833
|
const fromContent = fromMessage.content;
|
|
828
834
|
|
|
829
835
|
let discardSequence = fromContent.discardSequence;
|
|
830
|
-
if (isDiscarded && !discardSequence && this[kFlags].attachedTo && fromContent.inbound
|
|
836
|
+
if (isDiscarded && !discardSequence && this[kFlags].attachedTo && fromContent.inbound?.[0]) {
|
|
831
837
|
discardSequence = [fromContent.inbound[0].id];
|
|
832
838
|
}
|
|
833
839
|
|
|
834
840
|
let outboundFlows;
|
|
835
841
|
if (isDiscarded) {
|
|
836
842
|
outboundFlows = outboundSequenceFlows.map((flow) => formatFlowAction(flow, { action: 'discard' }));
|
|
837
|
-
} else if (fromContent.outbound
|
|
843
|
+
} else if (fromContent.outbound?.length) {
|
|
838
844
|
outboundFlows = outboundSequenceFlows.map((flow) => formatFlowAction(flow, fromContent.outbound.filter((f) => f.id === flow.id).pop()));
|
|
839
845
|
}
|
|
840
846
|
|
|
@@ -914,7 +920,7 @@ Activity.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
|
914
920
|
return this.broker.publish('run', fields.routingKey, cloneContent(stateMessage.content), stateMessage.properties);
|
|
915
921
|
};
|
|
916
922
|
|
|
917
|
-
Activity.prototype._publishEvent = function publishEvent(state, content, properties
|
|
923
|
+
Activity.prototype._publishEvent = function publishEvent(state, content, properties) {
|
|
918
924
|
this.broker.publish('event', `activity.${state}`, cloneContent(content, { state }), {
|
|
919
925
|
...properties,
|
|
920
926
|
type: state,
|
|
@@ -969,9 +975,8 @@ Activity.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
969
975
|
};
|
|
970
976
|
|
|
971
977
|
Activity.prototype._createMessage = function createMessage(override) {
|
|
972
|
-
const name = this
|
|
973
|
-
|
|
974
|
-
parent = this.parent;
|
|
978
|
+
const { name, status, parent } = this;
|
|
979
|
+
|
|
975
980
|
const result = {
|
|
976
981
|
...override,
|
|
977
982
|
id: this.id,
|
|
@@ -32,7 +32,7 @@ Object.defineProperty(ActivityExecution.prototype, 'completed', {
|
|
|
32
32
|
|
|
33
33
|
ActivityExecution.prototype.execute = function execute(executeMessage) {
|
|
34
34
|
if (!executeMessage) throw new Error('Execution requires message');
|
|
35
|
-
const executionId = executeMessage.content
|
|
35
|
+
const executionId = executeMessage.content?.executionId;
|
|
36
36
|
if (!executionId) throw new Error('Execution requires execution id');
|
|
37
37
|
|
|
38
38
|
this.executionId = executionId;
|
|
@@ -347,7 +347,7 @@ ActivityExecution.prototype._onParentApiMessage = function onParentApiMessage(ro
|
|
|
347
347
|
};
|
|
348
348
|
|
|
349
349
|
ActivityExecution.prototype._onStop = function onStop(message) {
|
|
350
|
-
const stoppedId = message
|
|
350
|
+
const stoppedId = message?.content?.executionId;
|
|
351
351
|
const running = this.getPostponed();
|
|
352
352
|
for (const api of running) {
|
|
353
353
|
if (stoppedId !== api.content.executionId) {
|
|
@@ -98,7 +98,7 @@ Object.defineProperties(Definition.prototype, {
|
|
|
98
98
|
activityStatus: {
|
|
99
99
|
get() {
|
|
100
100
|
const execution = this[kExec].get('execution');
|
|
101
|
-
return
|
|
101
|
+
return execution?.activityStatus || 'idle';
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
104
|
});
|
|
@@ -160,7 +160,7 @@ Definition.prototype.getState = function getState() {
|
|
|
160
160
|
stopped: this.stopped,
|
|
161
161
|
counters: this.counters,
|
|
162
162
|
environment: this.environment.getState(),
|
|
163
|
-
execution: this.execution
|
|
163
|
+
execution: this.execution?.getState(),
|
|
164
164
|
broker: this.broker.getState(true),
|
|
165
165
|
});
|
|
166
166
|
};
|
|
@@ -289,8 +289,8 @@ Definition.prototype.cancelActivity = function cancelActivity(message) {
|
|
|
289
289
|
Definition.prototype.sendMessage = function sendMessage(message) {
|
|
290
290
|
const messageContent = { message };
|
|
291
291
|
let messageType = 'message';
|
|
292
|
-
const reference = message
|
|
293
|
-
if (reference
|
|
292
|
+
const reference = message?.id && this.getElementById(message.id);
|
|
293
|
+
if (reference?.resolve) {
|
|
294
294
|
const resolvedReference = reference.resolve(this._createMessage({ message }));
|
|
295
295
|
messageType = resolvedReference.messageType || messageType;
|
|
296
296
|
messageContent.message = { ...message, ...resolvedReference };
|
|
@@ -408,7 +408,7 @@ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(rout
|
|
|
408
408
|
this[kStatus] = 'executing';
|
|
409
409
|
break;
|
|
410
410
|
case 'process.discarded': {
|
|
411
|
-
if (inbound
|
|
411
|
+
if (inbound?.length) {
|
|
412
412
|
const calledFrom = inbound[0];
|
|
413
413
|
this._getProcessApi({ content: calledFrom }).cancel({
|
|
414
414
|
executionId: calledFrom.executionId,
|
|
@@ -417,7 +417,7 @@ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(rout
|
|
|
417
417
|
break;
|
|
418
418
|
}
|
|
419
419
|
case 'process.end': {
|
|
420
|
-
if (inbound
|
|
420
|
+
if (inbound?.length) {
|
|
421
421
|
const calledFrom = inbound[0];
|
|
422
422
|
|
|
423
423
|
this._getProcessApi({ content: calledFrom }).signal({
|
|
@@ -430,7 +430,7 @@ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(rout
|
|
|
430
430
|
break;
|
|
431
431
|
}
|
|
432
432
|
case 'process.error': {
|
|
433
|
-
if (inbound
|
|
433
|
+
if (inbound?.length) {
|
|
434
434
|
const calledFrom = inbound[0];
|
|
435
435
|
|
|
436
436
|
this._getProcessApi({ content: calledFrom }).sendApiMessage(
|
|
@@ -478,7 +478,7 @@ DefinitionExecution.prototype._onProcessCompleted = function onProcessCompleted(
|
|
|
478
478
|
message.ack();
|
|
479
479
|
this._debug(`left <${executionId} (${id})> (${type}), pending runs ${this.postponedCount}`);
|
|
480
480
|
|
|
481
|
-
if (inbound
|
|
481
|
+
if (inbound?.length) {
|
|
482
482
|
const bp = this._removeProcessByExecutionId(executionId);
|
|
483
483
|
this._deactivateProcess(bp);
|
|
484
484
|
}
|
|
@@ -651,7 +651,7 @@ DefinitionExecution.prototype._onDelegateMessage = function onDelegateMessage(ro
|
|
|
651
651
|
const delegateMessage = executeMessage.content.message;
|
|
652
652
|
|
|
653
653
|
const reference = this.context.getActivityById(delegateMessage.id);
|
|
654
|
-
const message = reference
|
|
654
|
+
const message = reference?.resolve(executeMessage);
|
|
655
655
|
|
|
656
656
|
this._debug(
|
|
657
657
|
`<${reference ? `${messageType} ${delegateMessage.id}>` : `anonymous ${messageType}`} event received from <${content.parent.id}.${content.id}>. Delegating.`,
|
|
@@ -710,7 +710,7 @@ DefinitionExecution.prototype._complete = function complete(completionType, cont
|
|
|
710
710
|
);
|
|
711
711
|
};
|
|
712
712
|
|
|
713
|
-
DefinitionExecution.prototype._createMessage = function createMessage(content
|
|
713
|
+
DefinitionExecution.prototype._createMessage = function createMessage(content) {
|
|
714
714
|
return {
|
|
715
715
|
id: this.id,
|
|
716
716
|
type: this.type,
|
package/src/error/Errors.js
CHANGED
|
@@ -6,8 +6,7 @@ class ActivityError extends Error {
|
|
|
6
6
|
this.type = 'ActivityError';
|
|
7
7
|
this.name = this.constructor.name;
|
|
8
8
|
this.description = description;
|
|
9
|
-
if (sourceMessage)
|
|
10
|
-
this.source = cloneMessage(sourceMessage, sourceMessage.content && sourceMessage.content.error && { error: undefined });
|
|
9
|
+
if (sourceMessage) this.source = cloneMessage(sourceMessage, sourceMessage.content?.error && { error: undefined });
|
|
11
10
|
if (inner) {
|
|
12
11
|
this.inner = inner;
|
|
13
12
|
if (inner.name) this.name = inner.name;
|
|
@@ -24,17 +23,14 @@ class RunError extends ActivityError {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
class BpmnError extends Error {
|
|
27
|
-
constructor(description, behaviour
|
|
28
|
-
const { errorCode } = behaviour;
|
|
29
|
-
|
|
26
|
+
constructor(description, behaviour, sourceMessage, inner) {
|
|
30
27
|
super(description);
|
|
31
28
|
this.type = 'BpmnError';
|
|
32
|
-
this.name = behaviour
|
|
29
|
+
this.name = behaviour?.name ?? this.constructor.name;
|
|
33
30
|
this.description = description;
|
|
34
|
-
this.code =
|
|
35
|
-
this.id = behaviour
|
|
36
|
-
if (sourceMessage)
|
|
37
|
-
this.source = cloneMessage(sourceMessage, sourceMessage.content && sourceMessage.content.error && { error: undefined });
|
|
31
|
+
this.code = behaviour?.errorCode?.toString() ?? behaviour?.code;
|
|
32
|
+
this.id = behaviour?.id;
|
|
33
|
+
if (sourceMessage) this.source = cloneMessage(sourceMessage, sourceMessage.content?.error && { error: undefined });
|
|
38
34
|
if (inner) this.inner = inner;
|
|
39
35
|
}
|
|
40
36
|
}
|
|
@@ -47,7 +43,7 @@ function makeErrorFromMessage(errorMessage) {
|
|
|
47
43
|
if (isKnownError(content)) return content;
|
|
48
44
|
|
|
49
45
|
const { error } = content;
|
|
50
|
-
if (!error) return new Error(`Malformatted error message with routing key ${errorMessage.fields
|
|
46
|
+
if (!error) return new Error(`Malformatted error message with routing key ${errorMessage.fields?.routingKey}`);
|
|
51
47
|
|
|
52
48
|
if (isKnownError(error)) return error;
|
|
53
49
|
|
|
@@ -19,8 +19,7 @@ export default function CancelEventDefinition(activity, eventDefinition) {
|
|
|
19
19
|
|
|
20
20
|
Object.defineProperty(CancelEventDefinition.prototype, 'executionId', {
|
|
21
21
|
get() {
|
|
22
|
-
|
|
23
|
-
return message && message.content.executionId;
|
|
22
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
24
23
|
},
|
|
25
24
|
});
|
|
26
25
|
|
|
@@ -30,8 +30,7 @@ export default function CompensateEventDefinition(activity, eventDefinition, con
|
|
|
30
30
|
|
|
31
31
|
Object.defineProperty(CompensateEventDefinition.prototype, 'executionId', {
|
|
32
32
|
get() {
|
|
33
|
-
|
|
34
|
-
return message && message.content.executionId;
|
|
33
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
35
34
|
},
|
|
36
35
|
});
|
|
37
36
|
|
|
@@ -87,7 +86,7 @@ CompensateEventDefinition.prototype.executeCatch = function executeCatch(execute
|
|
|
87
86
|
CompensateEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
88
87
|
const executeContent = executeMessage.content;
|
|
89
88
|
const { parent } = executeContent;
|
|
90
|
-
const parentExecutionId = parent
|
|
89
|
+
const parentExecutionId = parent?.executionId;
|
|
91
90
|
|
|
92
91
|
this.logger.debug(`<${parentExecutionId} (${this.id})> throw compensate`);
|
|
93
92
|
|
|
@@ -20,8 +20,7 @@ export default function ConditionalEventDefinition(activity, eventDefinition, _c
|
|
|
20
20
|
|
|
21
21
|
Object.defineProperty(ConditionalEventDefinition.prototype, 'executionId', {
|
|
22
22
|
get() {
|
|
23
|
-
|
|
24
|
-
return message && message.content.executionId;
|
|
23
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
25
24
|
},
|
|
26
25
|
});
|
|
27
26
|
|
|
@@ -149,7 +148,7 @@ ConditionalEventDefinition.prototype.getCondition = function getCondition(index)
|
|
|
149
148
|
};
|
|
150
149
|
|
|
151
150
|
ConditionalEventDefinition.prototype._onDelegateApiMessage = function onDelegateApiMessage(routingKey, message) {
|
|
152
|
-
if (message.content.message
|
|
151
|
+
if (message.content.message?.id === this.id) {
|
|
153
152
|
this._onApiMessage(routingKey, message);
|
|
154
153
|
}
|
|
155
154
|
};
|