bpmn-elements 9.1.3 → 9.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 +5 -0
- package/dist/activity/Activity.js +4 -17
- package/dist/flows/SequenceFlow.js +11 -1
- package/package.json +2 -2
- package/src/activity/Activity.js +3 -11
- package/src/flows/SequenceFlow.js +14 -1
- package/types/index.d.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
# 9.2.0
|
|
5
|
+
|
|
6
|
+
- move outbound sequence flow evaluation logic from activity to sequence flow, where it belongs
|
|
7
|
+
- spread sequence flow evaluation result, if object, to sequence flow take message
|
|
8
|
+
|
|
4
9
|
# 9.1.3
|
|
5
10
|
|
|
6
11
|
- type declare execution scope
|
|
@@ -837,10 +837,12 @@ Activity.prototype._doRunOutbound = function doRunOutbound(outboundList, content
|
|
|
837
837
|
for (const outboundFlow of outboundList) {
|
|
838
838
|
const {
|
|
839
839
|
id: flowId,
|
|
840
|
-
action
|
|
840
|
+
action,
|
|
841
|
+
result
|
|
841
842
|
} = outboundFlow;
|
|
842
843
|
this.broker.publish('run', 'run.outbound.' + action, (0, _messageHelper.cloneContent)(content, {
|
|
843
844
|
flow: {
|
|
845
|
+
...(result && typeof result === 'object' && result),
|
|
844
846
|
...outboundFlow,
|
|
845
847
|
sequenceId: (0, _shared.getUniqueId)(`${flowId}_${action}`),
|
|
846
848
|
...(discardSequence && {
|
|
@@ -1027,26 +1029,11 @@ OutboundEvaluator.prototype.onEvaluated = function onEvaluated(routingKey, messa
|
|
|
1027
1029
|
};
|
|
1028
1030
|
OutboundEvaluator.prototype.evaluateFlow = function evaluateFlow(flow) {
|
|
1029
1031
|
const broker = this.broker;
|
|
1030
|
-
if (flow.isDefault) {
|
|
1031
|
-
return broker.publish('execution', 'evaluate.flow.take', formatFlowAction(flow, {
|
|
1032
|
-
action: 'take'
|
|
1033
|
-
}), {
|
|
1034
|
-
persistent: false
|
|
1035
|
-
});
|
|
1036
|
-
}
|
|
1037
|
-
const flowCondition = flow.getCondition();
|
|
1038
|
-
if (!flowCondition) {
|
|
1039
|
-
return broker.publish('execution', 'evaluate.flow.take', formatFlowAction(flow, {
|
|
1040
|
-
action: 'take'
|
|
1041
|
-
}), {
|
|
1042
|
-
persistent: false
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
1032
|
const {
|
|
1046
1033
|
fromMessage,
|
|
1047
1034
|
evaluationId
|
|
1048
1035
|
} = this.evaluateArgs;
|
|
1049
|
-
|
|
1036
|
+
flow.evaluate((0, _messageHelper.cloneMessage)(fromMessage), (err, result) => {
|
|
1050
1037
|
if (err) return this.completed(err);
|
|
1051
1038
|
const action = result ? 'take' : 'discard';
|
|
1052
1039
|
return broker.publish('execution', 'evaluate.flow.' + action, formatFlowAction(flow, {
|
|
@@ -124,7 +124,7 @@ SequenceFlow.prototype.shake = function shake(message) {
|
|
|
124
124
|
persistent: false,
|
|
125
125
|
type: 'shake'
|
|
126
126
|
});
|
|
127
|
-
for (const s of message.content.sequence) {
|
|
127
|
+
for (const s of message.content.sequence || []) {
|
|
128
128
|
if (s.id === this.id) return this.broker.publish('event', 'flow.shake.loop', content, {
|
|
129
129
|
persistent: false,
|
|
130
130
|
type: 'shake'
|
|
@@ -164,6 +164,16 @@ SequenceFlow.prototype.createMessage = function createMessage(override) {
|
|
|
164
164
|
parent: (0, _messageHelper.cloneParent)(this.parent)
|
|
165
165
|
};
|
|
166
166
|
};
|
|
167
|
+
SequenceFlow.prototype.evaluate = function evaluate(fromMessage, callback) {
|
|
168
|
+
if (this.isDefault) {
|
|
169
|
+
return callback(null, true);
|
|
170
|
+
}
|
|
171
|
+
const flowCondition = this.getCondition();
|
|
172
|
+
if (!flowCondition) {
|
|
173
|
+
return callback(null, true);
|
|
174
|
+
}
|
|
175
|
+
flowCondition.execute(fromMessage, callback);
|
|
176
|
+
};
|
|
167
177
|
SequenceFlow.prototype._publishEvent = function publishEvent(action, content) {
|
|
168
178
|
const eventContent = this.createMessage({
|
|
169
179
|
action,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-elements",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Executable workflow elements based on BPMN 2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"chai": "^4.3.7",
|
|
56
56
|
"chronokinesis": "^5.0.2",
|
|
57
57
|
"debug": "^4.3.4",
|
|
58
|
-
"eslint": "^8.
|
|
58
|
+
"eslint": "^8.39.0",
|
|
59
59
|
"eslint-plugin-import": "^2.27.5",
|
|
60
60
|
"got": "^12.6.0",
|
|
61
61
|
"mocha": "^10.1.0",
|
package/src/activity/Activity.js
CHANGED
|
@@ -807,9 +807,10 @@ Activity.prototype._doOutbound = function doOutbound(fromMessage, isDiscarded, c
|
|
|
807
807
|
|
|
808
808
|
Activity.prototype._doRunOutbound = function doRunOutbound(outboundList, content, discardSequence) {
|
|
809
809
|
for (const outboundFlow of outboundList) {
|
|
810
|
-
const {id: flowId, action} = outboundFlow;
|
|
810
|
+
const {id: flowId, action, result} = outboundFlow;
|
|
811
811
|
this.broker.publish('run', 'run.outbound.' + action, cloneContent(content, {
|
|
812
812
|
flow: {
|
|
813
|
+
...(result && typeof result === 'object' && result),
|
|
813
814
|
...outboundFlow,
|
|
814
815
|
sequenceId: getUniqueId(`${flowId}_${action}`),
|
|
815
816
|
...(discardSequence && {discardSequence: discardSequence.slice()}),
|
|
@@ -1000,17 +1001,8 @@ OutboundEvaluator.prototype.onEvaluated = function onEvaluated(routingKey, messa
|
|
|
1000
1001
|
|
|
1001
1002
|
OutboundEvaluator.prototype.evaluateFlow = function evaluateFlow(flow) {
|
|
1002
1003
|
const broker = this.broker;
|
|
1003
|
-
if (flow.isDefault) {
|
|
1004
|
-
return broker.publish('execution', 'evaluate.flow.take', formatFlowAction(flow, {action: 'take'}), {persistent: false});
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
const flowCondition = flow.getCondition();
|
|
1008
|
-
if (!flowCondition) {
|
|
1009
|
-
return broker.publish('execution', 'evaluate.flow.take', formatFlowAction(flow, {action: 'take'}), {persistent: false});
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
1004
|
const {fromMessage, evaluationId} = this.evaluateArgs;
|
|
1013
|
-
|
|
1005
|
+
flow.evaluate(cloneMessage(fromMessage), (err, result) => {
|
|
1014
1006
|
if (err) return this.completed(err);
|
|
1015
1007
|
const action = result ? 'take' : 'discard';
|
|
1016
1008
|
return broker.publish('execution', 'evaluate.flow.' + action, formatFlowAction(flow, {
|
|
@@ -101,7 +101,7 @@ SequenceFlow.prototype.shake = function shake(message) {
|
|
|
101
101
|
|
|
102
102
|
if (content.id === this.targetId) return this.broker.publish('event', 'flow.shake.loop', content, {persistent: false, type: 'shake'});
|
|
103
103
|
|
|
104
|
-
for (const s of message.content.sequence) {
|
|
104
|
+
for (const s of message.content.sequence || []) {
|
|
105
105
|
if (s.id === this.id) return this.broker.publish('event', 'flow.shake.loop', content, {persistent: false, type: 'shake'});
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -140,6 +140,19 @@ SequenceFlow.prototype.createMessage = function createMessage(override) {
|
|
|
140
140
|
};
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
+
SequenceFlow.prototype.evaluate = function evaluate(fromMessage, callback) {
|
|
144
|
+
if (this.isDefault) {
|
|
145
|
+
return callback(null, true);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const flowCondition = this.getCondition();
|
|
149
|
+
if (!flowCondition) {
|
|
150
|
+
return callback(null, true);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
flowCondition.execute(fromMessage, callback);
|
|
154
|
+
};
|
|
155
|
+
|
|
143
156
|
SequenceFlow.prototype._publishEvent = function publishEvent(action, content) {
|
|
144
157
|
const eventContent = this.createMessage({
|
|
145
158
|
action,
|
package/types/index.d.ts
CHANGED
|
@@ -481,6 +481,13 @@ declare module 'bpmn-elements' {
|
|
|
481
481
|
shake(message: any): number;
|
|
482
482
|
getCondition(): any;
|
|
483
483
|
createMessage(override?: any): object;
|
|
484
|
+
/**
|
|
485
|
+
* Evaluate flow
|
|
486
|
+
* Executes condition if any, default flow is
|
|
487
|
+
* @param fromMessage Activity message
|
|
488
|
+
* @param {evaluateCallback} callback Callback with evaluation result, if truthy flow should be taken
|
|
489
|
+
*/
|
|
490
|
+
evaluate(fromMessage: ElementBrokerMessage, callback: (err: Error, result: any) => void): void;
|
|
484
491
|
}
|
|
485
492
|
|
|
486
493
|
interface MessageFlowReference {
|
|
@@ -635,3 +642,10 @@ declare module 'bpmn-elements' {
|
|
|
635
642
|
constructor(description: string, sourceMessage: MessageMessage, inner?: Error);
|
|
636
643
|
}
|
|
637
644
|
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Evaluate flow callback
|
|
648
|
+
* @callback evaluateCallback
|
|
649
|
+
* @param {Error} err Evaluation error
|
|
650
|
+
* @param {boolean|object} evaluationResult If thruthy flow should be taken
|
|
651
|
+
*/
|