bpmn-elements 8.1.0 → 8.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/CHANGELOG.md +10 -0
- package/dist/index.js +0 -49
- package/dist/src/Api.js +4 -19
- package/dist/src/Context.js +7 -36
- package/dist/src/Environment.js +18 -44
- package/dist/src/EventBroker.js +8 -27
- package/dist/src/Expressions.js +0 -13
- package/dist/src/ExtensionsMapper.js +32 -44
- package/dist/src/MessageFormatter.js +0 -33
- package/dist/src/Scripts.js +2 -9
- package/dist/src/Timers.js +0 -9
- package/dist/src/activity/Activity.js +62 -294
- package/dist/src/activity/ActivityExecution.js +8 -76
- package/dist/src/activity/Dummy.js +2 -3
- package/dist/src/activity/Escalation.js +4 -4
- package/dist/src/activity/ExecutionScope.js +0 -4
- package/dist/src/activity/Message.js +4 -4
- package/dist/src/activity/Signal.js +4 -4
- package/dist/src/definition/Definition.js +12 -133
- package/dist/src/definition/DefinitionExecution.js +10 -160
- package/dist/src/error/BpmnError.js +2 -3
- package/dist/src/error/Errors.js +0 -16
- package/dist/src/eventDefinitions/CancelEventDefinition.js +2 -35
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +3 -34
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +3 -42
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +11 -41
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +7 -37
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +0 -30
- package/dist/src/eventDefinitions/LinkEventDefinition.js +11 -37
- package/dist/src/eventDefinitions/MessageEventDefinition.js +11 -44
- package/dist/src/eventDefinitions/SignalEventDefinition.js +9 -46
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +0 -3
- package/dist/src/eventDefinitions/TimerEventDefinition.js +8 -52
- package/dist/src/events/BoundaryEvent.js +4 -44
- package/dist/src/events/EndEvent.js +2 -11
- package/dist/src/events/IntermediateCatchEvent.js +0 -13
- package/dist/src/events/IntermediateThrowEvent.js +2 -11
- package/dist/src/events/StartEvent.js +5 -25
- package/dist/src/flows/Association.js +4 -27
- package/dist/src/flows/MessageFlow.js +6 -18
- package/dist/src/flows/SequenceFlow.js +4 -39
- package/dist/src/gateways/EventBasedGateway.js +0 -21
- package/dist/src/gateways/ExclusiveGateway.js +0 -6
- package/dist/src/gateways/InclusiveGateway.js +0 -6
- package/dist/src/gateways/ParallelGateway.js +2 -7
- package/dist/src/getPropertyValue.js +0 -30
- package/dist/src/io/BpmnIO.js +8 -5
- package/dist/src/io/EnvironmentDataObject.js +0 -8
- package/dist/src/io/EnvironmentDataStore.js +0 -8
- package/dist/src/io/EnvironmentDataStoreReference.js +0 -8
- package/dist/src/io/InputOutputSpecification.js +25 -36
- package/dist/src/io/Properties.js +15 -47
- package/dist/src/messageHelper.js +10 -23
- package/dist/src/process/Process.js +10 -112
- package/dist/src/process/ProcessExecution.js +14 -170
- package/dist/src/shared.js +0 -7
- package/dist/src/tasks/CallActivity.js +2 -23
- package/dist/src/tasks/LoopCharacteristics.js +16 -67
- package/dist/src/tasks/ReceiveTask.js +8 -48
- package/dist/src/tasks/ScriptTask.js +1 -15
- package/dist/src/tasks/ServiceImplementation.js +0 -4
- package/dist/src/tasks/ServiceTask.js +1 -25
- package/dist/src/tasks/SignalTask.js +2 -21
- package/dist/src/tasks/StandardLoopCharacteristics.js +4 -5
- package/dist/src/tasks/SubProcess.js +4 -52
- package/dist/src/tasks/Task.js +0 -8
- package/dist/src/tasks/Transaction.js +0 -3
- package/package.json +8 -8
- package/src/Context.js +7 -3
- package/src/ExtensionsMapper.js +35 -35
- package/src/activity/Activity.js +22 -51
- package/src/gateways/EventBasedGateway.js +0 -1
- package/src/io/BpmnIO.js +7 -0
- package/src/io/EnvironmentDataObject.js +1 -0
- package/src/io/InputOutputSpecification.js +17 -6
- package/src/io/Properties.js +9 -11
- package/src/process/ProcessExecution.js +2 -1
- package/src/tasks/ServiceTask.js +1 -3
- package/src/tasks/StandardLoopCharacteristics.js +0 -1
|
@@ -10,20 +10,16 @@ const numberConstantPattern = /^\W*-?\d+(.\d+)?\W*$/;
|
|
|
10
10
|
const negativeIndexPattern = /^-\d+$/;
|
|
11
11
|
var _default = getPropertyValue;
|
|
12
12
|
exports.default = _default;
|
|
13
|
-
|
|
14
13
|
function getPropertyValue(inputContext, propertyPath, fnScope) {
|
|
15
14
|
if (!inputContext) return;
|
|
16
15
|
let resultValue;
|
|
17
16
|
let next = iterateProps(inputContext, inputContext, propertyPath.trim(), fnScope);
|
|
18
|
-
|
|
19
17
|
while (next) {
|
|
20
18
|
resultValue = next.getResult();
|
|
21
19
|
next = next();
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
return resultValue;
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
function iterateProps(base, iterateContext, iteratePropertyPath, fnScope) {
|
|
28
24
|
let result;
|
|
29
25
|
const rest = iteratePropertyPath.replace(propertyPattern, (match, fnName, args, p, prop) => {
|
|
@@ -32,55 +28,44 @@ function iterateProps(base, iterateContext, iteratePropertyPath, fnScope) {
|
|
|
32
28
|
} else {
|
|
33
29
|
result = getNamedValue(iterateContext, prop);
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
return '';
|
|
37
32
|
});
|
|
38
33
|
if (rest === iteratePropertyPath) return;
|
|
39
34
|
if (result === undefined || result === null) return;
|
|
40
|
-
|
|
41
35
|
const iterateNext = () => iterateProps(base, result, rest, fnScope);
|
|
42
|
-
|
|
43
36
|
iterateNext.getResult = () => {
|
|
44
37
|
if (rest !== '') return;
|
|
45
38
|
return result;
|
|
46
39
|
};
|
|
47
|
-
|
|
48
40
|
return iterateNext;
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
function executeFn(fn, args, base, fnScope) {
|
|
52
43
|
if (!fn) return;
|
|
53
44
|
let callArguments = [];
|
|
54
|
-
|
|
55
45
|
if (args) {
|
|
56
46
|
callArguments = splitArguments(args, base, fnScope);
|
|
57
47
|
} else {
|
|
58
48
|
callArguments.push(base);
|
|
59
49
|
}
|
|
60
|
-
|
|
61
50
|
if (!fnScope) return fn.apply(null, callArguments);
|
|
62
51
|
return function ScopedIIFE() {
|
|
63
52
|
// eslint-disable-line no-extra-parens
|
|
64
53
|
return fn.apply(this, callArguments);
|
|
65
54
|
}.call(fnScope);
|
|
66
55
|
}
|
|
67
|
-
|
|
68
56
|
function splitArguments(args, base, fnScope) {
|
|
69
57
|
let insideString = false;
|
|
70
58
|
let delimiter = '';
|
|
71
59
|
let argCompleted = false;
|
|
72
60
|
let arg = '';
|
|
73
61
|
const callArguments = [];
|
|
74
|
-
|
|
75
62
|
for (let i = 0; i < args.length; i++) {
|
|
76
63
|
const charPos = args.charAt(i);
|
|
77
|
-
|
|
78
64
|
if (!insideString) {
|
|
79
65
|
if (charPos === ',') {
|
|
80
66
|
argCompleted = true;
|
|
81
67
|
} else if (charPos !== ' ') {
|
|
82
68
|
arg += charPos;
|
|
83
|
-
|
|
84
69
|
if (charPos === '\'' || charPos === '"') {
|
|
85
70
|
insideString = true;
|
|
86
71
|
delimiter = charPos;
|
|
@@ -88,69 +73,54 @@ function splitArguments(args, base, fnScope) {
|
|
|
88
73
|
}
|
|
89
74
|
} else {
|
|
90
75
|
arg += charPos;
|
|
91
|
-
|
|
92
76
|
if (charPos === delimiter) {
|
|
93
77
|
argCompleted = true;
|
|
94
78
|
delimiter = '';
|
|
95
79
|
}
|
|
96
80
|
}
|
|
97
|
-
|
|
98
81
|
if (argCompleted) {
|
|
99
82
|
if (arg.length > 0) {
|
|
100
83
|
callArguments.push(getFunctionArgument(base, arg.trim(), fnScope));
|
|
101
84
|
}
|
|
102
|
-
|
|
103
85
|
arg = '';
|
|
104
86
|
insideString = false;
|
|
105
87
|
argCompleted = false;
|
|
106
88
|
}
|
|
107
89
|
}
|
|
108
|
-
|
|
109
90
|
if (arg.trim() !== '') {
|
|
110
91
|
callArguments.push(getFunctionArgument(base, arg.trim(), fnScope));
|
|
111
92
|
}
|
|
112
|
-
|
|
113
93
|
return callArguments;
|
|
114
94
|
}
|
|
115
|
-
|
|
116
95
|
function getFunctionArgument(obj, argument, fnScope) {
|
|
117
96
|
const stringMatch = argument.match(stringConstantPattern);
|
|
118
|
-
|
|
119
97
|
if (stringMatch) {
|
|
120
98
|
return stringMatch[2];
|
|
121
99
|
} else if (numberConstantPattern.test(argument)) {
|
|
122
100
|
return Number(argument);
|
|
123
101
|
}
|
|
124
|
-
|
|
125
102
|
switch (argument) {
|
|
126
103
|
case 'true':
|
|
127
104
|
return true;
|
|
128
|
-
|
|
129
105
|
case 'false':
|
|
130
106
|
return false;
|
|
131
|
-
|
|
132
107
|
case 'null':
|
|
133
108
|
return null;
|
|
134
|
-
|
|
135
109
|
default:
|
|
136
110
|
return getPropertyValue(obj, argument, fnScope);
|
|
137
111
|
}
|
|
138
112
|
}
|
|
139
|
-
|
|
140
113
|
function getNamedValue(obj, property) {
|
|
141
114
|
if (Array.isArray(obj)) {
|
|
142
115
|
return getArrayItem(obj, property);
|
|
143
116
|
}
|
|
144
|
-
|
|
145
117
|
return obj[property];
|
|
146
118
|
}
|
|
147
|
-
|
|
148
119
|
function getArrayItem(list, idx) {
|
|
149
120
|
if (negativeIndexPattern.test(idx)) {
|
|
150
121
|
const nidx = Number(idx);
|
|
151
122
|
const aidx = nidx === 0 ? 0 : list.length + nidx;
|
|
152
123
|
return list[aidx];
|
|
153
124
|
}
|
|
154
|
-
|
|
155
125
|
return list[idx];
|
|
156
126
|
}
|
package/dist/src/io/BpmnIO.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = BpmnIO;
|
|
7
|
-
|
|
8
7
|
function BpmnIO(activity, context) {
|
|
9
8
|
this.activity = activity;
|
|
10
9
|
this.context = context;
|
|
10
|
+
this.type = 'bpmnio';
|
|
11
11
|
const {
|
|
12
12
|
ioSpecification: ioSpecificationDef,
|
|
13
13
|
properties: propertiesDef
|
|
@@ -15,17 +15,20 @@ function BpmnIO(activity, context) {
|
|
|
15
15
|
this.specification = ioSpecificationDef && new ioSpecificationDef.Behaviour(activity, ioSpecificationDef, context);
|
|
16
16
|
this.properties = propertiesDef && new propertiesDef.Behaviour(activity, propertiesDef, context);
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
Object.defineProperty(BpmnIO.prototype, 'hasIo', {
|
|
19
|
+
get() {
|
|
20
|
+
return this.specification || this.properties;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
19
23
|
BpmnIO.prototype.activate = function activate(message) {
|
|
20
24
|
const properties = this.properties,
|
|
21
|
-
|
|
25
|
+
specification = this.specification;
|
|
22
26
|
if (properties) properties.activate(message);
|
|
23
27
|
if (specification) specification.activate(message);
|
|
24
28
|
};
|
|
25
|
-
|
|
26
29
|
BpmnIO.prototype.deactivate = function deactivate(message) {
|
|
27
30
|
const properties = this.properties,
|
|
28
|
-
|
|
31
|
+
specification = this.specification;
|
|
29
32
|
if (properties) properties.deactivate(message);
|
|
30
33
|
if (specification) specification.deactivate(message);
|
|
31
34
|
};
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = EnvironmentDataObject;
|
|
7
|
-
|
|
8
7
|
function EnvironmentDataObject(dataObjectDef, {
|
|
9
8
|
environment
|
|
10
9
|
}) {
|
|
@@ -22,26 +21,19 @@ function EnvironmentDataObject(dataObjectDef, {
|
|
|
22
21
|
this.parent = parent;
|
|
23
22
|
this.environment = environment;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
EnvironmentDataObject.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
27
25
|
const environment = this.environment;
|
|
28
26
|
const value = environment.variables._data && environment.variables._data[this.id];
|
|
29
|
-
|
|
30
27
|
const content = this._createContent(value);
|
|
31
|
-
|
|
32
28
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
33
29
|
};
|
|
34
|
-
|
|
35
30
|
EnvironmentDataObject.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
36
31
|
const environment = this.environment;
|
|
37
32
|
environment.variables._data = environment.variables._data || {};
|
|
38
33
|
environment.variables._data[this.id] = value;
|
|
39
|
-
|
|
40
34
|
const content = this._createContent(value);
|
|
41
|
-
|
|
42
35
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
43
36
|
};
|
|
44
|
-
|
|
45
37
|
EnvironmentDataObject.prototype._createContent = function createContent(value) {
|
|
46
38
|
return {
|
|
47
39
|
id: this.id,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = EnvironmentDataStore;
|
|
7
|
-
|
|
8
7
|
function EnvironmentDataStore(dataStoreDef, {
|
|
9
8
|
environment
|
|
10
9
|
}) {
|
|
@@ -22,26 +21,19 @@ function EnvironmentDataStore(dataStoreDef, {
|
|
|
22
21
|
this.parent = parent;
|
|
23
22
|
this.environment = environment;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
EnvironmentDataStore.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
27
25
|
const environment = this.environment;
|
|
28
26
|
const value = environment.variables._data && environment.variables._data[this.id];
|
|
29
|
-
|
|
30
27
|
const content = this._createContent(value);
|
|
31
|
-
|
|
32
28
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
33
29
|
};
|
|
34
|
-
|
|
35
30
|
EnvironmentDataStore.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
36
31
|
const environment = this.environment;
|
|
37
32
|
environment.variables._data = environment.variables._data || {};
|
|
38
33
|
environment.variables._data[this.id] = value;
|
|
39
|
-
|
|
40
34
|
const content = this._createContent(value);
|
|
41
|
-
|
|
42
35
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
43
36
|
};
|
|
44
|
-
|
|
45
37
|
EnvironmentDataStore.prototype._createContent = function createContent(value) {
|
|
46
38
|
return {
|
|
47
39
|
id: this.id,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = EnvironmentDataStoreReference;
|
|
7
|
-
|
|
8
7
|
function EnvironmentDataStoreReference(dataObjectDef, {
|
|
9
8
|
environment
|
|
10
9
|
}) {
|
|
@@ -22,26 +21,19 @@ function EnvironmentDataStoreReference(dataObjectDef, {
|
|
|
22
21
|
this.parent = parent;
|
|
23
22
|
this.environment = environment;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
EnvironmentDataStoreReference.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
|
|
27
25
|
const environment = this.environment;
|
|
28
26
|
const value = environment.variables._data && environment.variables._data[this.id];
|
|
29
|
-
|
|
30
27
|
const content = this._createContent(value);
|
|
31
|
-
|
|
32
28
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
33
29
|
};
|
|
34
|
-
|
|
35
30
|
EnvironmentDataStoreReference.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
|
|
36
31
|
const environment = this.environment;
|
|
37
32
|
environment.variables._data = environment.variables._data || {};
|
|
38
33
|
environment.variables._data[this.id] = value;
|
|
39
|
-
|
|
40
34
|
const content = this._createContent(value);
|
|
41
|
-
|
|
42
35
|
return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
|
|
43
36
|
};
|
|
44
|
-
|
|
45
37
|
EnvironmentDataStoreReference.prototype._createContent = function createContent(value) {
|
|
46
38
|
return {
|
|
47
39
|
id: this.id,
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = IoSpecification;
|
|
7
|
-
|
|
8
7
|
var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
|
|
9
|
-
|
|
10
8
|
var _shared = require("../shared");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
const kConsuming = Symbol.for('consuming');
|
|
15
|
-
|
|
16
11
|
function IoSpecification(activity, ioSpecificationDef, context) {
|
|
17
12
|
const {
|
|
18
13
|
id,
|
|
@@ -26,35 +21,34 @@ function IoSpecification(activity, ioSpecificationDef, context) {
|
|
|
26
21
|
this.broker = activity.broker;
|
|
27
22
|
this.context = context;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
const proto = IoSpecification.prototype;
|
|
31
|
-
|
|
32
|
-
proto.activate = function activate() {
|
|
25
|
+
proto.activate = function activate(message) {
|
|
33
26
|
if (this[kConsuming]) return;
|
|
27
|
+
if (message && message.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
28
|
+
this._onFormatEnter();
|
|
29
|
+
}
|
|
30
|
+
if (message && message.fields.redelivered && message.fields.routingKey === 'run.end') {
|
|
31
|
+
this._onFormatComplete(message);
|
|
32
|
+
}
|
|
34
33
|
this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
|
|
35
34
|
noAck: true
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
|
-
|
|
39
37
|
proto.deactivate = function deactivate() {
|
|
40
38
|
if (this[kConsuming]) this[kConsuming] = this[kConsuming].cancel();
|
|
41
39
|
};
|
|
42
|
-
|
|
43
40
|
proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
44
41
|
const {
|
|
45
42
|
dataInputs,
|
|
46
43
|
dataOutputs
|
|
47
44
|
} = this.behaviour;
|
|
48
|
-
|
|
49
45
|
if ((dataInputs || dataOutputs) && routingKey === 'activity.enter') {
|
|
50
46
|
return this._onFormatEnter();
|
|
51
47
|
}
|
|
52
|
-
|
|
53
48
|
if (dataOutputs && routingKey === 'activity.execution.completed') {
|
|
54
49
|
this._onFormatComplete(message);
|
|
55
50
|
}
|
|
56
51
|
};
|
|
57
|
-
|
|
58
52
|
proto._onFormatEnter = function onFormatOnEnter() {
|
|
59
53
|
const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
|
|
60
54
|
const startRoutingKey = `run.onstart.${safeType}`;
|
|
@@ -63,7 +57,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
|
|
|
63
57
|
dataOutputs
|
|
64
58
|
} = this.behaviour;
|
|
65
59
|
const broker = this.broker;
|
|
66
|
-
|
|
67
60
|
if (!dataInputs) {
|
|
68
61
|
return broker.publish('format', startRoutingKey, {
|
|
69
62
|
ioSpecification: {
|
|
@@ -71,7 +64,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
|
|
|
71
64
|
}
|
|
72
65
|
});
|
|
73
66
|
}
|
|
74
|
-
|
|
75
67
|
const {
|
|
76
68
|
dataObjects,
|
|
77
69
|
sources
|
|
@@ -95,7 +87,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
|
|
|
95
87
|
dataObjects: [],
|
|
96
88
|
sources: []
|
|
97
89
|
});
|
|
98
|
-
|
|
99
90
|
if (!dataObjects.length) {
|
|
100
91
|
return broker.publish('format', startRoutingKey, {
|
|
101
92
|
ioSpecification: {
|
|
@@ -104,13 +95,13 @@ proto._onFormatEnter = function onFormatOnEnter() {
|
|
|
104
95
|
}
|
|
105
96
|
});
|
|
106
97
|
}
|
|
107
|
-
|
|
108
98
|
const endRoutingKey = `run.onstart.${safeType}.end`;
|
|
109
99
|
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
110
100
|
endRoutingKey,
|
|
111
101
|
ioSpecification: {
|
|
112
102
|
dataInputs: sources.map(source => {
|
|
113
|
-
return {
|
|
103
|
+
return {
|
|
104
|
+
...source
|
|
114
105
|
};
|
|
115
106
|
}),
|
|
116
107
|
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
@@ -118,7 +109,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
|
|
|
118
109
|
});
|
|
119
110
|
return read(broker, dataObjects, (_, responses) => {
|
|
120
111
|
for (const response of responses) sources[response.index].value = response.value;
|
|
121
|
-
|
|
122
112
|
broker.publish('format', endRoutingKey, {
|
|
123
113
|
ioSpecification: {
|
|
124
114
|
dataInputs: sources,
|
|
@@ -127,7 +117,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
|
|
|
127
117
|
});
|
|
128
118
|
});
|
|
129
119
|
};
|
|
130
|
-
|
|
131
120
|
proto._onFormatComplete = function formatOnComplete(message) {
|
|
132
121
|
const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
|
|
133
122
|
const messageInputs = (0, _getPropertyValue.default)(message, 'content.ioSpecification.dataInputs');
|
|
@@ -164,7 +153,6 @@ proto._onFormatComplete = function formatOnComplete(message) {
|
|
|
164
153
|
sources: []
|
|
165
154
|
});
|
|
166
155
|
const startRoutingKey = `run.onend.${safeType}`;
|
|
167
|
-
|
|
168
156
|
if (!dataObjects.length) {
|
|
169
157
|
return broker.publish('format', startRoutingKey, {
|
|
170
158
|
ioSpecification: {
|
|
@@ -173,30 +161,36 @@ proto._onFormatComplete = function formatOnComplete(message) {
|
|
|
173
161
|
}
|
|
174
162
|
});
|
|
175
163
|
}
|
|
176
|
-
|
|
177
164
|
const endRoutingKey = `run.onend.${safeType}.end`;
|
|
178
165
|
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
179
166
|
endRoutingKey,
|
|
180
167
|
ioSpecification: {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
168
|
+
...(messageInputs && {
|
|
169
|
+
dataInputs: messageInputs.map(input => {
|
|
170
|
+
return {
|
|
171
|
+
...input
|
|
172
|
+
};
|
|
173
|
+
})
|
|
184
174
|
}),
|
|
185
175
|
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
186
176
|
}
|
|
187
177
|
});
|
|
188
178
|
return write(broker, dataObjects, (_, responses) => {
|
|
189
179
|
for (const response of responses) sources[response.index].value = response.value;
|
|
190
|
-
|
|
191
180
|
broker.publish('format', endRoutingKey, {
|
|
192
181
|
ioSpecification: {
|
|
193
|
-
|
|
194
|
-
|
|
182
|
+
...(messageInputs && {
|
|
183
|
+
dataInputs: messageInputs.map(input => {
|
|
184
|
+
return {
|
|
185
|
+
...input
|
|
186
|
+
};
|
|
187
|
+
})
|
|
188
|
+
}),
|
|
189
|
+
dataOutputs: sources
|
|
195
190
|
}
|
|
196
191
|
});
|
|
197
192
|
});
|
|
198
193
|
};
|
|
199
|
-
|
|
200
194
|
proto._getDataOutputs = function getDataOutputs(dataOutputs) {
|
|
201
195
|
if (!dataOutputs) return;
|
|
202
196
|
return dataOutputs.map(dataOutput => {
|
|
@@ -207,27 +201,25 @@ proto._getDataOutputs = function getDataOutputs(dataOutputs) {
|
|
|
207
201
|
};
|
|
208
202
|
});
|
|
209
203
|
};
|
|
210
|
-
|
|
211
204
|
function read(broker, dataObjectRefs, callback) {
|
|
212
205
|
const responses = [];
|
|
213
206
|
let count = 0;
|
|
214
207
|
const dataReadConsumer = broker.subscribeTmp('data', 'data.read.#', onDataObjectResponse, {
|
|
215
208
|
noAck: true
|
|
216
209
|
});
|
|
217
|
-
|
|
218
210
|
for (const {
|
|
219
211
|
dataObject
|
|
220
212
|
} of dataObjectRefs) {
|
|
221
213
|
dataObject.read(broker, 'data', 'data.read.');
|
|
222
214
|
}
|
|
223
|
-
|
|
224
215
|
function onDataObjectResponse(routingKey, message) {
|
|
225
216
|
const {
|
|
226
217
|
index
|
|
227
218
|
} = dataObjectRefs.find(({
|
|
228
219
|
dataObject
|
|
229
220
|
}) => dataObject.id === message.content.id);
|
|
230
|
-
responses.push({
|
|
221
|
+
responses.push({
|
|
222
|
+
...message.content,
|
|
231
223
|
index
|
|
232
224
|
});
|
|
233
225
|
++count;
|
|
@@ -236,21 +228,18 @@ function read(broker, dataObjectRefs, callback) {
|
|
|
236
228
|
return callback(null, responses);
|
|
237
229
|
}
|
|
238
230
|
}
|
|
239
|
-
|
|
240
231
|
function write(broker, dataObjectRefs, callback) {
|
|
241
232
|
const responses = [];
|
|
242
233
|
let count = 0;
|
|
243
234
|
broker.subscribeTmp('data', 'data.write.#', onDataObjectResponse, {
|
|
244
235
|
noAck: true
|
|
245
236
|
});
|
|
246
|
-
|
|
247
237
|
for (const {
|
|
248
238
|
dataObject,
|
|
249
239
|
value
|
|
250
240
|
} of dataObjectRefs) {
|
|
251
241
|
dataObject.write(broker, 'data', 'data.write.', value);
|
|
252
242
|
}
|
|
253
|
-
|
|
254
243
|
function onDataObjectResponse(routingKey, message) {
|
|
255
244
|
const idx = dataObjectRefs.findIndex(({
|
|
256
245
|
dataObject
|