bpmn-elements 11.1.1 → 13.0.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 +14 -0
- package/dist/Environment.js +15 -15
- package/dist/activity/Activity.js +123 -143
- package/dist/activity/ActivityExecution.js +1 -3
- package/dist/definition/Definition.js +39 -44
- package/dist/definition/DefinitionExecution.js +51 -53
- package/dist/eventDefinitions/EventDefinitionExecution.js +10 -10
- package/dist/eventDefinitions/TimerEventDefinition.js +16 -16
- package/dist/events/BoundaryEvent.js +12 -11
- package/dist/events/index.js +60 -0
- package/dist/flows/Association.js +0 -1
- package/dist/flows/MessageFlow.js +0 -1
- package/dist/flows/SequenceFlow.js +1 -3
- package/dist/gateways/index.js +49 -0
- package/dist/getPropertyValue.js +1 -2
- package/dist/index.js +2 -2
- package/dist/process/Process.js +54 -61
- package/dist/process/ProcessExecution.js +31 -33
- package/dist/tasks/LoopCharacteristics.js +20 -7
- package/dist/tasks/SubProcess.js +33 -61
- package/dist/tasks/index.js +93 -0
- package/events.d.ts +1 -0
- package/gateways.d.ts +1 -0
- package/index.d.ts +1 -0
- package/package.json +39 -19
- package/src/Environment.js +16 -17
- package/src/activity/Activity.js +96 -131
- package/src/activity/ActivityExecution.js +0 -1
- package/src/definition/Definition.js +30 -40
- package/src/definition/DefinitionExecution.js +47 -55
- package/src/eventDefinitions/EventDefinitionExecution.js +9 -10
- package/src/eventDefinitions/TimerEventDefinition.js +14 -16
- package/src/events/BoundaryEvent.js +11 -11
- package/src/events/index.js +5 -0
- package/src/flows/Association.js +0 -1
- package/src/flows/MessageFlow.js +0 -1
- package/src/flows/SequenceFlow.js +0 -1
- package/src/gateways/index.js +4 -0
- package/src/process/Process.js +40 -54
- package/src/process/ProcessExecution.js +25 -31
- package/src/tasks/LoopCharacteristics.js +18 -7
- package/src/tasks/SubProcess.js +32 -66
- package/src/tasks/index.js +8 -0
- package/tasks.d.ts +1 -0
- package/types/index.d.ts +69 -767
- package/types/types.d.ts +706 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _BoundaryEvent = require("./BoundaryEvent.js");
|
|
7
|
+
Object.keys(_BoundaryEvent).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _BoundaryEvent[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _BoundaryEvent[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _EndEvent = require("./EndEvent.js");
|
|
18
|
+
Object.keys(_EndEvent).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _EndEvent[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _EndEvent[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _IntermediateCatchEvent = require("./IntermediateCatchEvent.js");
|
|
29
|
+
Object.keys(_IntermediateCatchEvent).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _IntermediateCatchEvent[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _IntermediateCatchEvent[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _IntermediateThrowEvent = require("./IntermediateThrowEvent.js");
|
|
40
|
+
Object.keys(_IntermediateThrowEvent).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _IntermediateThrowEvent[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _IntermediateThrowEvent[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _StartEvent = require("./StartEvent.js");
|
|
51
|
+
Object.keys(_StartEvent).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _StartEvent[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _StartEvent[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -11,8 +11,7 @@ var _EventBroker = require("../EventBroker.js");
|
|
|
11
11
|
var _Api = require("../Api.js");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
const kCounters = Symbol.for('counters');
|
|
14
|
-
var _default = SequenceFlow;
|
|
15
|
-
exports.default = _default;
|
|
14
|
+
var _default = exports.default = SequenceFlow;
|
|
16
15
|
function SequenceFlow(flowDef, {
|
|
17
16
|
environment
|
|
18
17
|
}) {
|
|
@@ -62,7 +61,6 @@ function SequenceFlow(flowDef, {
|
|
|
62
61
|
logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
|
|
63
62
|
}
|
|
64
63
|
Object.defineProperty(SequenceFlow.prototype, 'counters', {
|
|
65
|
-
enumerable: true,
|
|
66
64
|
get() {
|
|
67
65
|
return {
|
|
68
66
|
...this[kCounters]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _EventBasedGateway = require("./EventBasedGateway.js");
|
|
7
|
+
Object.keys(_EventBasedGateway).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _EventBasedGateway[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _EventBasedGateway[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _ExclusiveGateway = require("./ExclusiveGateway.js");
|
|
18
|
+
Object.keys(_ExclusiveGateway).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _ExclusiveGateway[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _ExclusiveGateway[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _InclusiveGateway = require("./InclusiveGateway.js");
|
|
29
|
+
Object.keys(_InclusiveGateway).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _InclusiveGateway[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _InclusiveGateway[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _ParallelGateway = require("./ParallelGateway.js");
|
|
40
|
+
Object.keys(_ParallelGateway).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _ParallelGateway[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _ParallelGateway[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
package/dist/getPropertyValue.js
CHANGED
|
@@ -8,8 +8,7 @@ const propertyPattern = /(\w+)\((.*?)(?:\))|(\.|\[|^)(.+?)(?:\]|\[|\.|$)/;
|
|
|
8
8
|
const stringConstantPattern = /^(['"])(.*)\1$/;
|
|
9
9
|
const numberConstantPattern = /^\W*-?\d+(.\d+)?\W*$/;
|
|
10
10
|
const negativeIndexPattern = /^-\d+$/;
|
|
11
|
-
var _default = getPropertyValue;
|
|
12
|
-
exports.default = _default;
|
|
11
|
+
var _default = exports.default = getPropertyValue;
|
|
13
12
|
function getPropertyValue(inputContext, propertyPath, fnScope) {
|
|
14
13
|
if (!inputContext) return;
|
|
15
14
|
let resultValue;
|
package/dist/index.js
CHANGED
|
@@ -398,6 +398,6 @@ var _Transaction = _interopRequireDefault(require("./tasks/Transaction.js"));
|
|
|
398
398
|
var _Timers = require("./Timers.js");
|
|
399
399
|
var ISODuration = _interopRequireWildcard(require("./iso-duration.js"));
|
|
400
400
|
exports.ISODuration = ISODuration;
|
|
401
|
-
function _getRequireWildcardCache(
|
|
402
|
-
function _interopRequireWildcard(
|
|
401
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
402
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
403
403
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/process/Process.js
CHANGED
|
@@ -22,8 +22,7 @@ const kMessageHandlers = Symbol.for('messageHandlers');
|
|
|
22
22
|
const kStateMessage = Symbol.for('stateMessage');
|
|
23
23
|
const kStatus = Symbol.for('status');
|
|
24
24
|
const kStopped = Symbol.for('stopped');
|
|
25
|
-
var _default = Process;
|
|
26
|
-
exports.default = _default;
|
|
25
|
+
var _default = exports.default = Process;
|
|
27
26
|
function Process(processDef, context) {
|
|
28
27
|
const {
|
|
29
28
|
id,
|
|
@@ -72,65 +71,59 @@ function Process(processDef, context) {
|
|
|
72
71
|
}
|
|
73
72
|
this[kExtensions] = context.loadExtensions(this);
|
|
74
73
|
}
|
|
75
|
-
Object.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return this[kStatus];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
Object.defineProperty(Process.prototype, 'activityStatus', {
|
|
132
|
-
get() {
|
|
133
|
-
return this[kExec].execution && this[kExec].execution.activityStatus || 'idle';
|
|
74
|
+
Object.defineProperties(Process.prototype, {
|
|
75
|
+
counters: {
|
|
76
|
+
get() {
|
|
77
|
+
return {
|
|
78
|
+
...this[kCounters]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
lanes: {
|
|
83
|
+
get() {
|
|
84
|
+
const lanes = this[kLanes];
|
|
85
|
+
return lanes && lanes.slice();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
extensions: {
|
|
89
|
+
get() {
|
|
90
|
+
return this[kExtensions];
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
stopped: {
|
|
94
|
+
get() {
|
|
95
|
+
return this[kStopped];
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
isRunning: {
|
|
99
|
+
get() {
|
|
100
|
+
if (!this[kConsuming]) return false;
|
|
101
|
+
return !!this.status;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
executionId: {
|
|
105
|
+
get() {
|
|
106
|
+
const {
|
|
107
|
+
executionId,
|
|
108
|
+
initExecutionId
|
|
109
|
+
} = this[kExec];
|
|
110
|
+
return executionId || initExecutionId;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
execution: {
|
|
114
|
+
get() {
|
|
115
|
+
return this[kExec].execution;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
status: {
|
|
119
|
+
get() {
|
|
120
|
+
return this[kStatus];
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
activityStatus: {
|
|
124
|
+
get() {
|
|
125
|
+
return this[kExec].execution && this[kExec].execution.activityStatus || 'idle';
|
|
126
|
+
}
|
|
134
127
|
}
|
|
135
128
|
});
|
|
136
129
|
Process.prototype.init = function init(useAsExecutionId) {
|
|
@@ -8,8 +8,7 @@ var _Api = require("../Api.js");
|
|
|
8
8
|
var _messageHelper = require("../messageHelper.js");
|
|
9
9
|
var _shared = require("../shared.js");
|
|
10
10
|
var _Tracker = require("../Tracker.js");
|
|
11
|
-
var _default = ProcessExecution;
|
|
12
|
-
exports.default = _default;
|
|
11
|
+
var _default = exports.default = ProcessExecution;
|
|
13
12
|
const kActivated = Symbol.for('activated');
|
|
14
13
|
const kActivityQ = Symbol.for('activityQ');
|
|
15
14
|
const kCompleted = Symbol.for('completed');
|
|
@@ -65,37 +64,36 @@ function ProcessExecution(parentActivity, context) {
|
|
|
65
64
|
onMessageFlowEvent: this._onMessageFlowEvent.bind(this)
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
|
-
Object.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return this[kTracker].activityStatus;
|
|
67
|
+
Object.defineProperties(ProcessExecution.prototype, {
|
|
68
|
+
stopped: {
|
|
69
|
+
get() {
|
|
70
|
+
return this[kStopped];
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
completed: {
|
|
74
|
+
get() {
|
|
75
|
+
return this[kCompleted];
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
status: {
|
|
79
|
+
get() {
|
|
80
|
+
return this[kStatus];
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
postponedCount: {
|
|
84
|
+
get() {
|
|
85
|
+
return this[kElements].postponed.length;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
isRunning: {
|
|
89
|
+
get() {
|
|
90
|
+
return this[kActivated];
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
activityStatus: {
|
|
94
|
+
get() {
|
|
95
|
+
return this[kTracker].activityStatus;
|
|
96
|
+
}
|
|
99
97
|
}
|
|
100
98
|
});
|
|
101
99
|
ProcessExecution.prototype.execute = function execute(executeMessage) {
|
|
@@ -116,14 +116,21 @@ function ParallelLoopCharacteristics(activity, characteristics) {
|
|
|
116
116
|
this.characteristics = characteristics;
|
|
117
117
|
this.running = 0;
|
|
118
118
|
this.index = 0;
|
|
119
|
+
this.discarded = 0;
|
|
119
120
|
}
|
|
120
121
|
ParallelLoopCharacteristics.prototype.execute = function execute(executeMessage) {
|
|
121
122
|
const chr = this.characteristics;
|
|
122
123
|
if (!chr.cardinality) throw new _Errors.RunError(`<${this.id}> cardinality or collection is required in parallel loops`, executeMessage);
|
|
123
124
|
const isRedelivered = executeMessage.fields.redelivered;
|
|
124
125
|
if (isRedelivered) {
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
const {
|
|
127
|
+
index,
|
|
128
|
+
running,
|
|
129
|
+
discarded
|
|
130
|
+
} = executeMessage.content;
|
|
131
|
+
if (!isNaN(index)) this.index = index;
|
|
132
|
+
if (!isNaN(running)) this.running = running;
|
|
133
|
+
if (!isNaN(discarded)) this.discarded = discarded;
|
|
127
134
|
}
|
|
128
135
|
chr.subscribe(this._onCompleteMessage.bind(this));
|
|
129
136
|
if (isRedelivered) return;
|
|
@@ -148,6 +155,7 @@ ParallelLoopCharacteristics.prototype._startBatch = function startBatch() {
|
|
|
148
155
|
...chr.getContent(),
|
|
149
156
|
index: this.index,
|
|
150
157
|
running: this.running,
|
|
158
|
+
discarded: this.discarded,
|
|
151
159
|
output: chr.output,
|
|
152
160
|
preventComplete: true
|
|
153
161
|
});
|
|
@@ -155,27 +163,31 @@ ParallelLoopCharacteristics.prototype._startBatch = function startBatch() {
|
|
|
155
163
|
broker.publish('execution', 'execute.start', content);
|
|
156
164
|
}
|
|
157
165
|
};
|
|
158
|
-
ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMessage(
|
|
166
|
+
ParallelLoopCharacteristics.prototype._onCompleteMessage = function onCompleteMessage(routingKey, message) {
|
|
159
167
|
const chr = this.characteristics;
|
|
160
168
|
const {
|
|
161
169
|
content
|
|
162
170
|
} = message;
|
|
163
171
|
if (content.output !== undefined) chr.output[content.index] = content.output;
|
|
172
|
+
if (routingKey === 'execute.discard') {
|
|
173
|
+
this.discarded++;
|
|
174
|
+
}
|
|
164
175
|
this.running--;
|
|
165
176
|
this.activity.broker.publish('execution', 'execute.iteration.completed', {
|
|
166
177
|
...content,
|
|
167
178
|
...chr.getContent(),
|
|
168
179
|
index: this.index,
|
|
169
180
|
running: this.running,
|
|
181
|
+
discarded: this.discarded,
|
|
170
182
|
output: chr.output,
|
|
171
183
|
state: 'iteration.completed',
|
|
172
184
|
preventComplete: true
|
|
173
185
|
});
|
|
174
186
|
if (this.running <= 0 && !chr.next(this.index)) {
|
|
175
|
-
return chr.complete(content);
|
|
187
|
+
return chr.complete(content, this.discarded === this.index);
|
|
176
188
|
}
|
|
177
189
|
if (chr.isCompletionConditionMet(message)) {
|
|
178
|
-
return chr.complete(content);
|
|
190
|
+
return chr.complete(content, this.discarded === this.index);
|
|
179
191
|
}
|
|
180
192
|
if (this.running <= 0) {
|
|
181
193
|
this.running = 0;
|
|
@@ -263,9 +275,9 @@ Characteristics.prototype.isCompletionConditionMet = function isCompletionCondit
|
|
|
263
275
|
loopOutput: this.output
|
|
264
276
|
}));
|
|
265
277
|
};
|
|
266
|
-
Characteristics.prototype.complete = function complete(content) {
|
|
278
|
+
Characteristics.prototype.complete = function complete(content, allDiscarded) {
|
|
267
279
|
this.stop();
|
|
268
|
-
return this.broker.publish('execution', 'execute.completed', {
|
|
280
|
+
return this.broker.publish('execution', 'execute.' + (allDiscarded ? 'discard' : 'completed'), {
|
|
269
281
|
...content,
|
|
270
282
|
...this.getContent(),
|
|
271
283
|
output: this.output
|
|
@@ -286,6 +298,7 @@ Characteristics.prototype.subscribe = function subscribe(onIterationCompleteMess
|
|
|
286
298
|
function onComplete(routingKey, message, ...args) {
|
|
287
299
|
if (!message.content.isMultiInstance) return;
|
|
288
300
|
switch (routingKey) {
|
|
301
|
+
case 'execute.discard':
|
|
289
302
|
case 'execute.cancel':
|
|
290
303
|
case 'execute.completed':
|
|
291
304
|
return onIterationCompleteMessage(routingKey, message, ...args);
|
package/dist/tasks/SubProcess.js
CHANGED
|
@@ -56,52 +56,36 @@ function SubProcessBehaviour(activity, context) {
|
|
|
56
56
|
this.executionId = undefined;
|
|
57
57
|
this[kExecutions] = [];
|
|
58
58
|
this[kMessageHandlers] = {
|
|
59
|
-
onApiRootMessage: this._onApiRootMessage.bind(this),
|
|
60
59
|
onExecutionCompleted: this._onExecutionCompleted.bind(this)
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
|
-
Object.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
Object.defineProperties(SubProcessBehaviour.prototype, {
|
|
63
|
+
execution: {
|
|
64
|
+
get() {
|
|
65
|
+
return this[kExecutions][0];
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
executions: {
|
|
69
|
+
get() {
|
|
70
|
+
return this[kExecutions].slice();
|
|
71
|
+
}
|
|
71
72
|
}
|
|
72
73
|
});
|
|
73
74
|
SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
const {
|
|
76
|
+
isRootScope,
|
|
77
|
+
executionId
|
|
78
|
+
} = executeMessage.content;
|
|
79
|
+
if (isRootScope) {
|
|
80
|
+
this.executionId = executionId;
|
|
78
81
|
}
|
|
79
82
|
const loopCharacteristics = this.loopCharacteristics;
|
|
80
|
-
if (loopCharacteristics &&
|
|
81
|
-
this.broker.subscribeTmp('api', `activity.#.${executionId}`, this[kMessageHandlers].onApiRootMessage, {
|
|
82
|
-
noAck: true,
|
|
83
|
-
consumerTag: `_api-${executionId}`,
|
|
84
|
-
priority: 200
|
|
85
|
-
});
|
|
83
|
+
if (loopCharacteristics && isRootScope) {
|
|
86
84
|
return loopCharacteristics.execute(executeMessage);
|
|
87
85
|
}
|
|
88
86
|
const processExecution = this._upsertExecution(executeMessage);
|
|
89
87
|
return processExecution.execute(executeMessage);
|
|
90
88
|
};
|
|
91
|
-
SubProcessBehaviour.prototype.stop = function stop() {
|
|
92
|
-
for (const execution of this[kExecutions]) {
|
|
93
|
-
this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
|
|
94
|
-
this.broker.cancel(`_sub-process-api-${execution.executionId}`);
|
|
95
|
-
execution.stop();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
SubProcessBehaviour.prototype.discard = function discard() {
|
|
99
|
-
for (const execution of this[kExecutions]) {
|
|
100
|
-
this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
|
|
101
|
-
this.broker.cancel(`_sub-process-api-${execution.executionId}`);
|
|
102
|
-
execution.discard();
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
89
|
SubProcessBehaviour.prototype.getState = function getState() {
|
|
106
90
|
if (this.loopCharacteristics) {
|
|
107
91
|
return {
|
|
@@ -145,35 +129,22 @@ SubProcessBehaviour.prototype.getPostponed = function getPostponed() {
|
|
|
145
129
|
return result;
|
|
146
130
|
}, []);
|
|
147
131
|
};
|
|
148
|
-
SubProcessBehaviour.prototype._onApiRootMessage = function onApiRootMessage(_, message) {
|
|
149
|
-
const messageType = message.properties.type;
|
|
150
|
-
switch (messageType) {
|
|
151
|
-
case 'stop':
|
|
152
|
-
this.broker.cancel(message.fields.consumerTag);
|
|
153
|
-
this.stop();
|
|
154
|
-
break;
|
|
155
|
-
case 'discard':
|
|
156
|
-
this.broker.cancel(message.fields.consumerTag);
|
|
157
|
-
this.discard();
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
132
|
SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(executeMessage) {
|
|
162
133
|
const content = executeMessage.content;
|
|
163
134
|
const executionId = content.executionId;
|
|
164
135
|
let execution = this._getExecutionById(executionId);
|
|
165
136
|
if (execution) {
|
|
166
|
-
if (executeMessage.fields.redelivered) this._addListeners(
|
|
137
|
+
if (executeMessage.fields.redelivered) this._addListeners(executionId);
|
|
167
138
|
return execution;
|
|
168
139
|
}
|
|
169
140
|
const subEnvironment = this.environment.clone();
|
|
170
141
|
const subContext = this.context.clone(subEnvironment, this.activity);
|
|
171
142
|
execution = new _ProcessExecution.default(this.activity, subContext);
|
|
172
143
|
this[kExecutions].push(execution);
|
|
173
|
-
this._addListeners(
|
|
144
|
+
this._addListeners(executionId);
|
|
174
145
|
return execution;
|
|
175
146
|
};
|
|
176
|
-
SubProcessBehaviour.prototype._addListeners = function addListeners(
|
|
147
|
+
SubProcessBehaviour.prototype._addListeners = function addListeners(executionId) {
|
|
177
148
|
this.broker.subscribeTmp('subprocess-execution', `execution.#.${executionId}`, this[kMessageHandlers].onExecutionCompleted, {
|
|
178
149
|
noAck: true,
|
|
179
150
|
consumerTag: `_sub-process-execution-${executionId}`
|
|
@@ -187,21 +158,14 @@ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionComple
|
|
|
187
158
|
switch (messageType) {
|
|
188
159
|
case 'stopped':
|
|
189
160
|
{
|
|
190
|
-
broker.cancel(message.fields.consumerTag);
|
|
191
|
-
break;
|
|
161
|
+
return broker.cancel(message.fields.consumerTag);
|
|
192
162
|
}
|
|
163
|
+
case 'completed':
|
|
193
164
|
case 'cancel':
|
|
194
165
|
case 'discard':
|
|
195
166
|
{
|
|
196
167
|
broker.cancel(message.fields.consumerTag);
|
|
197
|
-
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
case 'completed':
|
|
201
|
-
{
|
|
202
|
-
broker.cancel(message.fields.consumerTag);
|
|
203
|
-
broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content));
|
|
204
|
-
break;
|
|
168
|
+
return this._completeExecution('execute.' + messageType, content);
|
|
205
169
|
}
|
|
206
170
|
case 'error':
|
|
207
171
|
{
|
|
@@ -210,11 +174,19 @@ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionComple
|
|
|
210
174
|
error
|
|
211
175
|
} = content;
|
|
212
176
|
this.activity.logger.error(`<${this.id}>`, error);
|
|
213
|
-
|
|
214
|
-
break;
|
|
177
|
+
return this._completeExecution('execute.error', content);
|
|
215
178
|
}
|
|
216
179
|
}
|
|
217
180
|
};
|
|
181
|
+
SubProcessBehaviour.prototype._completeExecution = function completeExecution(completeRoutingKey, content) {
|
|
182
|
+
if (this.loopCharacteristics) {
|
|
183
|
+
const executions = this[kExecutions];
|
|
184
|
+
const executionIdx = executions.findIndex(pe => pe.executionId === content.executionId);
|
|
185
|
+
if (executionIdx < 0) return;
|
|
186
|
+
executions.splice(executionIdx, 1);
|
|
187
|
+
}
|
|
188
|
+
this.broker.publish('execution', completeRoutingKey, (0, _messageHelper.cloneContent)(content));
|
|
189
|
+
};
|
|
218
190
|
SubProcessBehaviour.prototype.getApi = function getApi(apiMessage) {
|
|
219
191
|
const content = apiMessage.content;
|
|
220
192
|
if (content.id === this.id) return;
|