bpmn-elements 16.1.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 +67 -163
- package/dist/activity/ActivityExecution.js +2 -2
- package/dist/activity/outbound-evaluator.js +131 -0
- 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/gateways/EventBasedGateway.js +7 -5
- 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 +65 -159
- package/src/activity/ActivityExecution.js +2 -2
- package/src/activity/outbound-evaluator.js +127 -0
- 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/gateways/EventBasedGateway.js +5 -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/error/Errors.js
CHANGED
|
@@ -12,7 +12,7 @@ class ActivityError extends Error {
|
|
|
12
12
|
this.type = 'ActivityError';
|
|
13
13
|
this.name = this.constructor.name;
|
|
14
14
|
this.description = description;
|
|
15
|
-
if (sourceMessage) this.source = (0, _messageHelper.cloneMessage)(sourceMessage, sourceMessage.content
|
|
15
|
+
if (sourceMessage) this.source = (0, _messageHelper.cloneMessage)(sourceMessage, sourceMessage.content?.error && {
|
|
16
16
|
error: undefined
|
|
17
17
|
});
|
|
18
18
|
if (inner) {
|
|
@@ -31,17 +31,14 @@ class RunError extends ActivityError {
|
|
|
31
31
|
}
|
|
32
32
|
exports.RunError = RunError;
|
|
33
33
|
class BpmnError extends Error {
|
|
34
|
-
constructor(description, behaviour
|
|
35
|
-
const {
|
|
36
|
-
errorCode
|
|
37
|
-
} = behaviour;
|
|
34
|
+
constructor(description, behaviour, sourceMessage, inner) {
|
|
38
35
|
super(description);
|
|
39
36
|
this.type = 'BpmnError';
|
|
40
|
-
this.name = behaviour
|
|
37
|
+
this.name = behaviour?.name ?? this.constructor.name;
|
|
41
38
|
this.description = description;
|
|
42
|
-
this.code =
|
|
43
|
-
this.id = behaviour
|
|
44
|
-
if (sourceMessage) this.source = (0, _messageHelper.cloneMessage)(sourceMessage, sourceMessage.content
|
|
39
|
+
this.code = behaviour?.errorCode?.toString() ?? behaviour?.code;
|
|
40
|
+
this.id = behaviour?.id;
|
|
41
|
+
if (sourceMessage) this.source = (0, _messageHelper.cloneMessage)(sourceMessage, sourceMessage.content?.error && {
|
|
45
42
|
error: undefined
|
|
46
43
|
});
|
|
47
44
|
if (inner) this.inner = inner;
|
|
@@ -56,7 +53,7 @@ function makeErrorFromMessage(errorMessage) {
|
|
|
56
53
|
const {
|
|
57
54
|
error
|
|
58
55
|
} = content;
|
|
59
|
-
if (!error) return new Error(`Malformatted error message with routing key ${errorMessage.fields
|
|
56
|
+
if (!error) return new Error(`Malformatted error message with routing key ${errorMessage.fields?.routingKey}`);
|
|
60
57
|
if (isKnownError(error)) return error;
|
|
61
58
|
switch (error.type) {
|
|
62
59
|
case 'ActivityError':
|
|
@@ -28,8 +28,7 @@ function CancelEventDefinition(activity, eventDefinition) {
|
|
|
28
28
|
}
|
|
29
29
|
Object.defineProperty(CancelEventDefinition.prototype, 'executionId', {
|
|
30
30
|
get() {
|
|
31
|
-
|
|
32
|
-
return message && message.content.executionId;
|
|
31
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
33
32
|
}
|
|
34
33
|
});
|
|
35
34
|
CancelEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -47,8 +47,7 @@ function CompensateEventDefinition(activity, eventDefinition, context) {
|
|
|
47
47
|
}
|
|
48
48
|
Object.defineProperty(CompensateEventDefinition.prototype, 'executionId', {
|
|
49
49
|
get() {
|
|
50
|
-
|
|
51
|
-
return message && message.content.executionId;
|
|
50
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
52
51
|
}
|
|
53
52
|
});
|
|
54
53
|
CompensateEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -95,7 +94,7 @@ CompensateEventDefinition.prototype.executeThrow = function executeThrow(execute
|
|
|
95
94
|
const {
|
|
96
95
|
parent
|
|
97
96
|
} = executeContent;
|
|
98
|
-
const parentExecutionId = parent
|
|
97
|
+
const parentExecutionId = parent?.executionId;
|
|
99
98
|
this.logger.debug(`<${parentExecutionId} (${this.id})> throw compensate`);
|
|
100
99
|
const broker = this.broker;
|
|
101
100
|
const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
@@ -29,8 +29,7 @@ function ConditionalEventDefinition(activity, eventDefinition, _context, index)
|
|
|
29
29
|
}
|
|
30
30
|
Object.defineProperty(ConditionalEventDefinition.prototype, 'executionId', {
|
|
31
31
|
get() {
|
|
32
|
-
|
|
33
|
-
return message && message.content.executionId;
|
|
32
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
34
33
|
}
|
|
35
34
|
});
|
|
36
35
|
ConditionalEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -151,7 +150,7 @@ ConditionalEventDefinition.prototype.getCondition = function getCondition(index)
|
|
|
151
150
|
}
|
|
152
151
|
};
|
|
153
152
|
ConditionalEventDefinition.prototype._onDelegateApiMessage = function onDelegateApiMessage(routingKey, message) {
|
|
154
|
-
if (message.content.message
|
|
153
|
+
if (message.content.message?.id === this.id) {
|
|
155
154
|
this._onApiMessage(routingKey, message);
|
|
156
155
|
}
|
|
157
156
|
};
|
|
@@ -51,8 +51,7 @@ function ErrorEventDefinition(activity, eventDefinition) {
|
|
|
51
51
|
}
|
|
52
52
|
Object.defineProperty(ErrorEventDefinition.prototype, 'executionId', {
|
|
53
53
|
get() {
|
|
54
|
-
|
|
55
|
-
return message && message.content.executionId;
|
|
54
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
ErrorEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -66,7 +65,7 @@ ErrorEventDefinition.prototype.executeCatch = function executeCatch(executeMessa
|
|
|
66
65
|
executionId,
|
|
67
66
|
parent
|
|
68
67
|
} = executeContent;
|
|
69
|
-
const parentExecutionId = parent
|
|
68
|
+
const parentExecutionId = parent?.executionId;
|
|
70
69
|
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
71
70
|
this[kMessageQ].consume(this._onThrowApiMessage.bind(this), {
|
|
72
71
|
noAck: true,
|
|
@@ -143,7 +142,7 @@ ErrorEventDefinition.prototype._onThrowApiMessage = function onThrowApiMessage(r
|
|
|
143
142
|
const error = message.content.message;
|
|
144
143
|
if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
|
|
145
144
|
const info = this[kReferenceInfo];
|
|
146
|
-
if (info.message.id !==
|
|
145
|
+
if (info.message.id !== error?.id) return;
|
|
147
146
|
return this._catchError(routingKey, message, error);
|
|
148
147
|
};
|
|
149
148
|
ErrorEventDefinition.prototype._catchError = function catchError(routingKey, message, error) {
|
|
@@ -52,8 +52,7 @@ function EscalationEventDefinition(activity, eventDefinition) {
|
|
|
52
52
|
}
|
|
53
53
|
Object.defineProperty(EscalationEventDefinition.prototype, 'executionId', {
|
|
54
54
|
get() {
|
|
55
|
-
|
|
56
|
-
return message && message.content.executionId;
|
|
55
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
58
|
EscalationEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -51,8 +51,7 @@ function LinkEventDefinition(activity, eventDefinition) {
|
|
|
51
51
|
}
|
|
52
52
|
Object.defineProperty(LinkEventDefinition.prototype, 'executionId', {
|
|
53
53
|
get() {
|
|
54
|
-
|
|
55
|
-
return message && message.content.executionId;
|
|
54
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
LinkEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -51,8 +51,7 @@ function MessageEventDefinition(activity, eventDefinition) {
|
|
|
51
51
|
}
|
|
52
52
|
Object.defineProperty(MessageEventDefinition.prototype, 'executionId', {
|
|
53
53
|
get() {
|
|
54
|
-
|
|
55
|
-
return message && message.content.executionId;
|
|
54
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
MessageEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -66,7 +65,7 @@ MessageEventDefinition.prototype.executeCatch = function executeCatch(executeMes
|
|
|
66
65
|
executionId,
|
|
67
66
|
parent
|
|
68
67
|
} = executeContent;
|
|
69
|
-
const parentExecutionId = parent
|
|
68
|
+
const parentExecutionId = parent?.executionId;
|
|
70
69
|
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
71
70
|
this._debug(`expect ${info.description}`);
|
|
72
71
|
const broker = this.broker;
|
|
@@ -52,8 +52,7 @@ function SignalEventDefinition(activity, eventDefinition) {
|
|
|
52
52
|
}
|
|
53
53
|
Object.defineProperty(SignalEventDefinition.prototype, 'executionId', {
|
|
54
54
|
get() {
|
|
55
|
-
|
|
56
|
-
return message && message.content.executionId;
|
|
55
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
58
|
SignalEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
@@ -67,7 +66,7 @@ SignalEventDefinition.prototype.executeCatch = function executeCatch(executeMess
|
|
|
67
66
|
executionId,
|
|
68
67
|
parent
|
|
69
68
|
} = executeContent;
|
|
70
|
-
const parentExecutionId = parent
|
|
69
|
+
const parentExecutionId = parent?.executionId;
|
|
71
70
|
const info = this[kReferenceInfo] = this._getReferenceInfo(executeMessage);
|
|
72
71
|
const broker = this.broker;
|
|
73
72
|
const onCatchMessage = this._onCatchMessage.bind(this);
|
|
@@ -32,8 +32,7 @@ function TimerEventDefinition(activity, eventDefinition) {
|
|
|
32
32
|
Object.defineProperties(TimerEventDefinition.prototype, {
|
|
33
33
|
executionId: {
|
|
34
34
|
get() {
|
|
35
|
-
|
|
36
|
-
return content && content.executionId;
|
|
35
|
+
return this[kTimerContent]?.executionId;
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
38
|
stopped: {
|
|
@@ -262,7 +261,7 @@ TimerEventDefinition.prototype._getTimers = function getTimers(executeMessage) {
|
|
|
262
261
|
} else if (!Object.keys(result).length) {
|
|
263
262
|
result.timeout = 0;
|
|
264
263
|
}
|
|
265
|
-
if (content.inbound && 'repeat' in content.inbound[0]) {
|
|
264
|
+
if (content.inbound?.[0] && 'repeat' in content.inbound[0]) {
|
|
266
265
|
result.repeat = content.inbound[0].repeat;
|
|
267
266
|
}
|
|
268
267
|
return result;
|
|
@@ -32,8 +32,7 @@ function BoundaryEventBehaviour(activity) {
|
|
|
32
32
|
Object.defineProperties(BoundaryEventBehaviour.prototype, {
|
|
33
33
|
executionId: {
|
|
34
34
|
get() {
|
|
35
|
-
|
|
36
|
-
return message && message.content.executionId;
|
|
35
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
38
|
cancelActivity: {
|
|
@@ -114,7 +113,7 @@ BoundaryEventBehaviour.prototype._onCompleted = function onCompleted(_, {
|
|
|
114
113
|
inbound,
|
|
115
114
|
executionId
|
|
116
115
|
} = this[kExecuteMessage].content;
|
|
117
|
-
const attachedToContent = inbound
|
|
116
|
+
const attachedToContent = inbound?.[0];
|
|
118
117
|
const attachedTo = this.attachedTo;
|
|
119
118
|
this.activity.logger.debug(`<${executionId} (${this.id})> cancel ${attachedTo.status} activity <${attachedToContent.executionId} (${attachedToContent.id})>`);
|
|
120
119
|
if (content.isRecovered && !attachedTo.isRunning) {
|
|
@@ -23,8 +23,7 @@ function StartEventBehaviour(activity) {
|
|
|
23
23
|
}
|
|
24
24
|
Object.defineProperty(StartEventBehaviour.prototype, 'executionId', {
|
|
25
25
|
get() {
|
|
26
|
-
|
|
27
|
-
return message && message.content.executionId;
|
|
26
|
+
return this[kExecuteMessage]?.content.executionId;
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
29
|
StartEventBehaviour.prototype.execute = function execute(executeMessage) {
|
|
@@ -58,13 +58,13 @@ Object.defineProperty(Association.prototype, 'counters', {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
Association.prototype.take = function take(content
|
|
61
|
+
Association.prototype.take = function take(content) {
|
|
62
62
|
this.logger.debug(`<${this.id}> take target <${this.targetId}>`);
|
|
63
63
|
++this[kCounters].take;
|
|
64
64
|
this._publishEvent('take', content);
|
|
65
65
|
return true;
|
|
66
66
|
};
|
|
67
|
-
Association.prototype.discard = function discard(content
|
|
67
|
+
Association.prototype.discard = function discard(content) {
|
|
68
68
|
this.logger.debug(`<${this.id}> discard target <${this.targetId}>`);
|
|
69
69
|
++this[kCounters].discard;
|
|
70
70
|
this._publishEvent('discard', content);
|
|
@@ -66,19 +66,15 @@ Object.defineProperty(SequenceFlow.prototype, 'counters', {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
SequenceFlow.prototype.take = function take(content
|
|
70
|
-
const
|
|
71
|
-
sequenceId
|
|
72
|
-
} = content;
|
|
69
|
+
SequenceFlow.prototype.take = function take(content) {
|
|
70
|
+
const sequenceId = content?.sequenceId;
|
|
73
71
|
this.logger.debug(`<${sequenceId} (${this.id})> take, target <${this.targetId}>`);
|
|
74
72
|
++this[kCounters].take;
|
|
75
73
|
this._publishEvent('take', content);
|
|
76
74
|
return true;
|
|
77
75
|
};
|
|
78
76
|
SequenceFlow.prototype.discard = function discard(content = {}) {
|
|
79
|
-
const
|
|
80
|
-
sequenceId = (0, _shared.getUniqueId)(this.id)
|
|
81
|
-
} = content;
|
|
77
|
+
const sequenceId = content?.sequenceId ?? (0, _shared.getUniqueId)(this.id);
|
|
82
78
|
const discardSequence = content.discardSequence = (content.discardSequence || []).slice();
|
|
83
79
|
if (discardSequence.indexOf(this.targetId) > -1) {
|
|
84
80
|
++this[kCounters].looped;
|
|
@@ -19,7 +19,7 @@ function EventBasedGatewayBehaviour(activity, context) {
|
|
|
19
19
|
this.activity = activity;
|
|
20
20
|
this.broker = activity.broker;
|
|
21
21
|
this.context = context;
|
|
22
|
-
this[kTargets] = activity.outbound.map(flow => context.getActivityById(flow.targetId));
|
|
22
|
+
this[kTargets] = new Set(activity.outbound.map(flow => context.getActivityById(flow.targetId)));
|
|
23
23
|
}
|
|
24
24
|
EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage) {
|
|
25
25
|
const executeContent = executeMessage.content;
|
|
@@ -30,7 +30,7 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
30
30
|
} = executeContent;
|
|
31
31
|
const targets = this[kTargets];
|
|
32
32
|
this[kCompleted] = false;
|
|
33
|
-
if (!targets.
|
|
33
|
+
if (!targets.size) return this._complete(executeContent);
|
|
34
34
|
for (const flow of this.activity.outbound) {
|
|
35
35
|
outbound.push({
|
|
36
36
|
id: flow.id,
|
|
@@ -50,9 +50,11 @@ EventBasedGatewayBehaviour.prototype.execute = function execute(executeMessage)
|
|
|
50
50
|
consumerTag: '_api-stop-execution'
|
|
51
51
|
});
|
|
52
52
|
this[kCompleted] = false;
|
|
53
|
-
if (!executeMessage.fields.redelivered)
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
if (!executeMessage.fields.redelivered) {
|
|
54
|
+
return broker.publish('execution', 'execute.outbound.take', (0, _messageHelper.cloneContent)(executeContent, {
|
|
55
|
+
outboundTaken: true
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
56
58
|
};
|
|
57
59
|
EventBasedGatewayBehaviour.prototype._onTargetCompleted = function onTargetCompleted(executeMessage, _, message, owner) {
|
|
58
60
|
const {
|
|
@@ -23,7 +23,7 @@ function EnvironmentDataObject(dataObjectDef, {
|
|
|
23
23
|
}
|
|
24
24
|
EnvironmentDataObject.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
25
25
|
const environment = this.environment;
|
|
26
|
-
const value = environment.variables._data
|
|
26
|
+
const value = environment.variables._data?.[this.id];
|
|
27
27
|
const content = this._createContent(value);
|
|
28
28
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
29
29
|
};
|
|
@@ -23,7 +23,7 @@ function EnvironmentDataStore(dataStoreDef, {
|
|
|
23
23
|
}
|
|
24
24
|
EnvironmentDataStore.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
25
25
|
const environment = this.environment;
|
|
26
|
-
const value = environment.variables._data
|
|
26
|
+
const value = environment.variables._data?.[this.id];
|
|
27
27
|
const content = this._createContent(value);
|
|
28
28
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
29
29
|
};
|
|
@@ -23,7 +23,7 @@ function EnvironmentDataStoreReference(dataObjectDef, {
|
|
|
23
23
|
}
|
|
24
24
|
EnvironmentDataStoreReference.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
25
25
|
const environment = this.environment;
|
|
26
|
-
const value = environment.variables._data
|
|
26
|
+
const value = environment.variables._data?.[this.id];
|
|
27
27
|
const content = this._createContent(value);
|
|
28
28
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
29
29
|
};
|
|
@@ -23,10 +23,10 @@ function IoSpecification(activity, ioSpecificationDef, context) {
|
|
|
23
23
|
}
|
|
24
24
|
IoSpecification.prototype.activate = function activate(message) {
|
|
25
25
|
if (this[kConsuming]) return;
|
|
26
|
-
if (message
|
|
26
|
+
if (message?.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
27
27
|
this._onFormatEnter();
|
|
28
28
|
}
|
|
29
|
-
if (message
|
|
29
|
+
if (message?.fields.redelivered && message.fields.routingKey === 'run.end') {
|
|
30
30
|
this._onFormatComplete(message);
|
|
31
31
|
}
|
|
32
32
|
this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
|
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.1
|
|
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;
|