bpmn-elements 5.1.3 → 7.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 +322 -0
- package/README.md +9 -3
- package/dist/index.js +71 -39
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +169 -164
- package/dist/src/Environment.js +90 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/Timers.js +4 -6
- package/dist/src/activity/Activity.js +1108 -901
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +722 -409
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -101
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +172 -184
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +31 -0
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +52 -0
- package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +252 -0
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +433 -359
- package/dist/src/process/ProcessExecution.js +744 -645
- package/dist/src/shared.js +3 -6
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +195 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +8 -0
- package/package.json +16 -15
- package/src/Api.js +65 -59
- package/src/Context.js +142 -132
- package/src/Environment.js +88 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/Timers.js +4 -4
- package/src/activity/Activity.js +916 -757
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +436 -401
- package/src/definition/DefinitionExecution.js +603 -343
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -113
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +145 -163
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -0
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +33 -0
- package/src/io/EnvironmentDataStoreReference.js +33 -0
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +199 -0
- package/src/process/Process.js +374 -333
- package/src/process/ProcessExecution.js +606 -554
- package/src/shared.js +1 -5
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
|
@@ -11,196 +11,202 @@ var _shared = require("../shared");
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
+
const consumingSymbol = Symbol.for('consuming');
|
|
15
|
+
|
|
14
16
|
function IoSpecification(activity, ioSpecificationDef, context) {
|
|
15
17
|
const {
|
|
16
18
|
id,
|
|
17
19
|
type = 'iospecification',
|
|
18
20
|
behaviour = {}
|
|
19
21
|
} = ioSpecificationDef;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
this.id = id;
|
|
23
|
+
this.type = type;
|
|
24
|
+
this.behaviour = behaviour;
|
|
25
|
+
this.activity = activity;
|
|
26
|
+
this.broker = activity.broker;
|
|
27
|
+
this.context = context;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const proto = IoSpecification.prototype;
|
|
31
|
+
|
|
32
|
+
proto.activate = function activate() {
|
|
33
|
+
if (this[consumingSymbol]) return;
|
|
34
|
+
this[consumingSymbol] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
|
|
35
|
+
noAck: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
proto.deactivate = function deactivate() {
|
|
40
|
+
if (this[consumingSymbol]) this[consumingSymbol] = this[consumingSymbol].cancel();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
25
44
|
const {
|
|
26
45
|
dataInputs,
|
|
27
46
|
dataOutputs
|
|
28
|
-
} = behaviour;
|
|
29
|
-
const ioApi = {
|
|
30
|
-
id,
|
|
31
|
-
type,
|
|
32
|
-
behaviour,
|
|
33
|
-
activate,
|
|
34
|
-
deactivate
|
|
35
|
-
};
|
|
36
|
-
return ioApi;
|
|
47
|
+
} = this.behaviour;
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
activityConsumer = broker.subscribeTmp('event', 'activity.#', onActivityEvent, {
|
|
41
|
-
noAck: true
|
|
42
|
-
});
|
|
49
|
+
if ((dataInputs || dataOutputs) && routingKey === 'activity.enter') {
|
|
50
|
+
return this._onFormatEnter();
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
if (dataOutputs && routingKey === 'activity.execution.completed') {
|
|
54
|
+
this._onFormatComplete(message);
|
|
47
55
|
}
|
|
56
|
+
};
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
proto._onFormatEnter = function onFormatOnEnter() {
|
|
59
|
+
const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
|
|
60
|
+
const startRoutingKey = `run.onstart.${safeType}`;
|
|
61
|
+
const {
|
|
62
|
+
dataInputs,
|
|
63
|
+
dataOutputs
|
|
64
|
+
} = this.behaviour;
|
|
65
|
+
const broker = this.broker;
|
|
53
66
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
if (!dataInputs) {
|
|
68
|
+
return broker.publish('format', startRoutingKey, {
|
|
69
|
+
ioSpecification: {
|
|
70
|
+
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
71
|
+
}
|
|
72
|
+
});
|
|
57
73
|
}
|
|
58
74
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
75
|
+
const {
|
|
76
|
+
dataObjects,
|
|
77
|
+
sources
|
|
78
|
+
} = dataInputs.reduce((result, ioSource, index) => {
|
|
79
|
+
const source = {
|
|
80
|
+
id: ioSource.id,
|
|
81
|
+
type: ioSource.type,
|
|
82
|
+
name: ioSource.name
|
|
83
|
+
};
|
|
84
|
+
result.sources.push(source);
|
|
85
|
+
const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.source.dataObject.id');
|
|
86
|
+
if (!dataObjectId) return result;
|
|
87
|
+
const dataObject = this.context.getDataObjectById(dataObjectId);
|
|
88
|
+
if (!dataObject) return result;
|
|
89
|
+
result.dataObjects.push({
|
|
90
|
+
index,
|
|
91
|
+
dataObject
|
|
92
|
+
});
|
|
93
|
+
return result;
|
|
94
|
+
}, {
|
|
95
|
+
dataObjects: [],
|
|
96
|
+
sources: []
|
|
97
|
+
});
|
|
69
98
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
type: ioSource.type,
|
|
77
|
-
name: ioSource.name
|
|
78
|
-
};
|
|
79
|
-
result.sources.push(source);
|
|
80
|
-
const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.source.dataObject.id');
|
|
81
|
-
if (!dataObjectId) return result;
|
|
82
|
-
const dataObject = context.getDataObjectById(dataObjectId);
|
|
83
|
-
if (!dataObject) return result;
|
|
84
|
-
result.dataObjects.push({
|
|
85
|
-
index,
|
|
86
|
-
dataObject
|
|
87
|
-
});
|
|
88
|
-
return result;
|
|
89
|
-
}, {
|
|
90
|
-
dataObjects: [],
|
|
91
|
-
sources: []
|
|
99
|
+
if (!dataObjects.length) {
|
|
100
|
+
return broker.publish('format', startRoutingKey, {
|
|
101
|
+
ioSpecification: {
|
|
102
|
+
dataInputs: sources,
|
|
103
|
+
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
104
|
+
}
|
|
92
105
|
});
|
|
106
|
+
}
|
|
93
107
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
const endRoutingKey = `run.onstart.${safeType}.end`;
|
|
109
|
+
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
110
|
+
endRoutingKey,
|
|
111
|
+
ioSpecification: {
|
|
112
|
+
dataInputs: sources.map(source => {
|
|
113
|
+
return { ...source
|
|
114
|
+
};
|
|
115
|
+
}),
|
|
116
|
+
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
101
117
|
}
|
|
118
|
+
});
|
|
119
|
+
return read(broker, dataObjects, (_, responses) => {
|
|
120
|
+
for (const response of responses) sources[response.index].value = response.value;
|
|
102
121
|
|
|
103
|
-
|
|
104
|
-
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
105
|
-
endRoutingKey,
|
|
122
|
+
broker.publish('format', endRoutingKey, {
|
|
106
123
|
ioSpecification: {
|
|
107
|
-
dataInputs: sources
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
}),
|
|
111
|
-
dataOutputs: getDataOutputs()
|
|
124
|
+
dataInputs: sources,
|
|
125
|
+
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
112
126
|
}
|
|
113
127
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
sources[response.index].value = response.value;
|
|
117
|
-
});
|
|
118
|
-
broker.publish('format', endRoutingKey, {
|
|
119
|
-
ioSpecification: {
|
|
120
|
-
dataInputs: sources,
|
|
121
|
-
dataOutputs: getDataOutputs()
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
}
|
|
128
|
+
});
|
|
129
|
+
};
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
proto._onFormatComplete = function formatOnComplete(message) {
|
|
132
|
+
const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
|
|
133
|
+
const messageInputs = (0, _getPropertyValue.default)(message, 'content.ioSpecification.dataInputs');
|
|
134
|
+
const messageOutputs = (0, _getPropertyValue.default)(message, 'content.output.ioSpecification.dataOutputs') || [];
|
|
135
|
+
const dataOutputs = this.behaviour.dataOutputs;
|
|
136
|
+
const broker = this.broker;
|
|
137
|
+
const context = this.context;
|
|
138
|
+
const {
|
|
139
|
+
dataObjects,
|
|
140
|
+
sources
|
|
141
|
+
} = dataOutputs.reduce((result, ioSource, index) => {
|
|
130
142
|
const {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
result.dataObjects.push({
|
|
149
|
-
index,
|
|
150
|
-
dataObject,
|
|
151
|
-
value
|
|
152
|
-
});
|
|
153
|
-
return result;
|
|
154
|
-
}, {
|
|
155
|
-
dataObjects: [],
|
|
156
|
-
sources: []
|
|
143
|
+
value
|
|
144
|
+
} = messageOutputs.find(output => output.id === ioSource.id) || {};
|
|
145
|
+
const source = {
|
|
146
|
+
id: ioSource.id,
|
|
147
|
+
type: ioSource.type,
|
|
148
|
+
name: ioSource.name,
|
|
149
|
+
value
|
|
150
|
+
};
|
|
151
|
+
result.sources.push(source);
|
|
152
|
+
const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.target.dataObject.id');
|
|
153
|
+
if (!dataObjectId) return result;
|
|
154
|
+
const dataObject = context.getDataObjectById(dataObjectId);
|
|
155
|
+
if (!dataObject) return result;
|
|
156
|
+
result.dataObjects.push({
|
|
157
|
+
index,
|
|
158
|
+
dataObject,
|
|
159
|
+
value
|
|
157
160
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
dataOutputs: sources
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
161
|
+
return result;
|
|
162
|
+
}, {
|
|
163
|
+
dataObjects: [],
|
|
164
|
+
sources: []
|
|
165
|
+
});
|
|
166
|
+
const startRoutingKey = `run.onend.${safeType}`;
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
broker.publish('format',
|
|
171
|
-
endRoutingKey,
|
|
168
|
+
if (!dataObjects.length) {
|
|
169
|
+
return broker.publish('format', startRoutingKey, {
|
|
172
170
|
ioSpecification: {
|
|
173
|
-
dataInputs:
|
|
174
|
-
|
|
175
|
-
};
|
|
176
|
-
}),
|
|
177
|
-
dataOutputs: getDataOutputs()
|
|
171
|
+
dataInputs: messageInputs,
|
|
172
|
+
dataOutputs: sources
|
|
178
173
|
}
|
|
179
174
|
});
|
|
180
|
-
return write(broker, dataObjects, (_, responses) => {
|
|
181
|
-
responses.forEach(response => {
|
|
182
|
-
sources[response.index].value = response.value;
|
|
183
|
-
});
|
|
184
|
-
broker.publish('format', endRoutingKey, {
|
|
185
|
-
ioSpecification: {
|
|
186
|
-
dataInputs: sources,
|
|
187
|
-
dataOutputs: getDataOutputs()
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
175
|
}
|
|
192
176
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
177
|
+
const endRoutingKey = `run.onend.${safeType}.end`;
|
|
178
|
+
broker.publish('format', `${startRoutingKey}.begin`, {
|
|
179
|
+
endRoutingKey,
|
|
180
|
+
ioSpecification: {
|
|
181
|
+
dataInputs: sources.map(input => {
|
|
182
|
+
return { ...input
|
|
183
|
+
};
|
|
184
|
+
}),
|
|
185
|
+
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
return write(broker, dataObjects, (_, responses) => {
|
|
189
|
+
for (const response of responses) sources[response.index].value = response.value;
|
|
190
|
+
|
|
191
|
+
broker.publish('format', endRoutingKey, {
|
|
192
|
+
ioSpecification: {
|
|
193
|
+
dataInputs: sources,
|
|
194
|
+
dataOutputs: this._getDataOutputs(dataOutputs)
|
|
195
|
+
}
|
|
201
196
|
});
|
|
202
|
-
}
|
|
203
|
-
}
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
proto._getDataOutputs = function getDataOutputs(dataOutputs) {
|
|
201
|
+
if (!dataOutputs) return;
|
|
202
|
+
return dataOutputs.map(dataOutput => {
|
|
203
|
+
return {
|
|
204
|
+
id: dataOutput.id,
|
|
205
|
+
type: dataOutput.type,
|
|
206
|
+
name: dataOutput.name
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
};
|
|
204
210
|
|
|
205
211
|
function read(broker, dataObjectRefs, callback) {
|
|
206
212
|
const responses = [];
|
|
@@ -209,10 +215,9 @@ function read(broker, dataObjectRefs, callback) {
|
|
|
209
215
|
noAck: true
|
|
210
216
|
});
|
|
211
217
|
|
|
212
|
-
for (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
} = dataObjectRefs[i];
|
|
218
|
+
for (const {
|
|
219
|
+
dataObject
|
|
220
|
+
} of dataObjectRefs) {
|
|
216
221
|
dataObject.read(broker, 'data', 'data.read.');
|
|
217
222
|
}
|
|
218
223
|
|
|
@@ -235,24 +240,28 @@ function read(broker, dataObjectRefs, callback) {
|
|
|
235
240
|
function write(broker, dataObjectRefs, callback) {
|
|
236
241
|
const responses = [];
|
|
237
242
|
let count = 0;
|
|
238
|
-
|
|
243
|
+
broker.subscribeTmp('data', 'data.write.#', onDataObjectResponse, {
|
|
239
244
|
noAck: true
|
|
240
245
|
});
|
|
241
246
|
|
|
242
|
-
for (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
} = dataObjectRefs[i];
|
|
247
|
+
for (const {
|
|
248
|
+
dataObject,
|
|
249
|
+
value
|
|
250
|
+
} of dataObjectRefs) {
|
|
247
251
|
dataObject.write(broker, 'data', 'data.write.', value);
|
|
248
252
|
}
|
|
249
253
|
|
|
250
254
|
function onDataObjectResponse(routingKey, message) {
|
|
251
|
-
const idx = dataObjectRefs.findIndex(
|
|
252
|
-
|
|
255
|
+
const idx = dataObjectRefs.findIndex(({
|
|
256
|
+
dataObject
|
|
257
|
+
}) => dataObject.id === message.content.id);
|
|
258
|
+
responses[idx] = {
|
|
259
|
+
index: idx,
|
|
260
|
+
...message.content
|
|
261
|
+
};
|
|
253
262
|
++count;
|
|
254
263
|
if (count < dataObjectRefs.length) return;
|
|
255
|
-
|
|
264
|
+
broker.cancel(message.fields.consumerTag);
|
|
256
265
|
return callback(null, responses);
|
|
257
266
|
}
|
|
258
267
|
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Properties;
|
|
7
|
+
|
|
8
|
+
var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const propertiesSymbol = Symbol.for('properties');
|
|
13
|
+
const consumingSymbol = Symbol.for('consuming');
|
|
14
|
+
|
|
15
|
+
function Properties(activity, propertiesDef, context) {
|
|
16
|
+
this.activity = activity;
|
|
17
|
+
this.broker = activity.broker;
|
|
18
|
+
const props = this[propertiesSymbol] = {
|
|
19
|
+
properties: [],
|
|
20
|
+
dataInputObjects: [],
|
|
21
|
+
dataOutputObjects: []
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
for (const {
|
|
25
|
+
id,
|
|
26
|
+
...def
|
|
27
|
+
} of propertiesDef.values) {
|
|
28
|
+
const source = {
|
|
29
|
+
id,
|
|
30
|
+
type: def.type,
|
|
31
|
+
name: def.behaviour && def.behaviour.name
|
|
32
|
+
};
|
|
33
|
+
props.properties.push(source);
|
|
34
|
+
const inputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataObject.id');
|
|
35
|
+
const outputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataOutput.association.target.dataObject.id');
|
|
36
|
+
const inputDataStoreId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataStore.id');
|
|
37
|
+
const outputDataStoreId = (0, _getPropertyValue.default)(def, 'behaviour.dataOutput.association.target.dataStore.id');
|
|
38
|
+
|
|
39
|
+
if (inputDataObjectId) {
|
|
40
|
+
const reference = context.getDataObjectById(inputDataObjectId);
|
|
41
|
+
props.dataInputObjects.push({
|
|
42
|
+
id,
|
|
43
|
+
reference
|
|
44
|
+
});
|
|
45
|
+
source.input = {
|
|
46
|
+
reference
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (outputDataObjectId) {
|
|
51
|
+
const reference = context.getDataObjectById(outputDataObjectId);
|
|
52
|
+
props.dataOutputObjects.push({
|
|
53
|
+
id,
|
|
54
|
+
reference: reference
|
|
55
|
+
});
|
|
56
|
+
source.output = {
|
|
57
|
+
reference
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (inputDataStoreId) {
|
|
62
|
+
const reference = context.getDataStoreById(inputDataStoreId);
|
|
63
|
+
props.dataInputObjects.push({
|
|
64
|
+
id,
|
|
65
|
+
reference
|
|
66
|
+
});
|
|
67
|
+
source.input = {
|
|
68
|
+
reference
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (outputDataStoreId) {
|
|
73
|
+
const reference = context.getDataStoreById(outputDataStoreId);
|
|
74
|
+
props.dataOutputObjects.push({
|
|
75
|
+
id,
|
|
76
|
+
reference
|
|
77
|
+
});
|
|
78
|
+
source.output = {
|
|
79
|
+
reference
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const proto = Properties.prototype;
|
|
86
|
+
|
|
87
|
+
proto.activate = function activate(message) {
|
|
88
|
+
if (this[consumingSymbol]) return;
|
|
89
|
+
|
|
90
|
+
if (message.fields.redelivered && message.content.properties) {
|
|
91
|
+
this._onActivityEvent('activity.extension.resume', message);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this[consumingSymbol] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
|
|
95
|
+
noAck: true
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
proto.deactivate = function deactivate() {
|
|
100
|
+
if (this[consumingSymbol]) this[consumingSymbol] = this[consumingSymbol].cancel();
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
proto._onActivityEvent = function onActivityEvent(routingKey, message) {
|
|
104
|
+
if (routingKey === 'activity.enter') {
|
|
105
|
+
return this._formatOnEnter(message);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (routingKey === 'activity.extension.resume') {
|
|
109
|
+
return this._formatOnEnter(message);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (routingKey === 'activity.execution.completed') {
|
|
113
|
+
return this._formatOnComplete(message);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
proto._formatOnEnter = function formatOnEnter(message) {
|
|
118
|
+
const startRoutingKey = 'run.enter.bpmn-properties';
|
|
119
|
+
const dataInputObjects = this[propertiesSymbol].dataInputObjects;
|
|
120
|
+
const broker = this.broker;
|
|
121
|
+
|
|
122
|
+
if (!dataInputObjects.length) {
|
|
123
|
+
return broker.getQueue('format-run-q').queueMessage({
|
|
124
|
+
routingKey: startRoutingKey
|
|
125
|
+
}, {
|
|
126
|
+
properties: this._getProperties(message)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const endRoutingKey = 'run.enter.bpmn-properties.end';
|
|
131
|
+
broker.getQueue('format-run-q').queueMessage({
|
|
132
|
+
routingKey: startRoutingKey
|
|
133
|
+
}, {
|
|
134
|
+
endRoutingKey,
|
|
135
|
+
properties: this._getProperties(message)
|
|
136
|
+
});
|
|
137
|
+
return read(broker, dataInputObjects, (_, responses) => {
|
|
138
|
+
broker.publish('format', endRoutingKey, {
|
|
139
|
+
properties: this._getProperties(message, responses)
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
proto._formatOnComplete = function formatOnComplete(message) {
|
|
145
|
+
const startRoutingKey = 'run.end.bpmn-properties';
|
|
146
|
+
const messageOutput = (0, _getPropertyValue.default)(message, 'content.output.properties') || {};
|
|
147
|
+
|
|
148
|
+
const outputProperties = this._getProperties(message, messageOutput);
|
|
149
|
+
|
|
150
|
+
const dataOutputObjects = this[propertiesSymbol].dataOutputObjects;
|
|
151
|
+
const broker = this.broker;
|
|
152
|
+
|
|
153
|
+
if (!dataOutputObjects.length) {
|
|
154
|
+
return broker.getQueue('format-run-q').queueMessage({
|
|
155
|
+
routingKey: startRoutingKey
|
|
156
|
+
}, {
|
|
157
|
+
properties: outputProperties
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const endRoutingKey = 'run.end.bpmn-properties.end';
|
|
162
|
+
broker.getQueue('format-run-q').queueMessage({
|
|
163
|
+
routingKey: startRoutingKey
|
|
164
|
+
}, {
|
|
165
|
+
endRoutingKey,
|
|
166
|
+
properties: outputProperties
|
|
167
|
+
});
|
|
168
|
+
return write(broker, dataOutputObjects, outputProperties, (_, responses) => {
|
|
169
|
+
broker.publish('format', endRoutingKey, {
|
|
170
|
+
properties: this._getProperties(message, responses)
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
proto._getProperties = function getProperties(message, values) {
|
|
176
|
+
let response = {};
|
|
177
|
+
|
|
178
|
+
if (message.content.properties) {
|
|
179
|
+
response = { ...message.content.properties
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
for (const {
|
|
184
|
+
id,
|
|
185
|
+
type,
|
|
186
|
+
name
|
|
187
|
+
} of this[propertiesSymbol].properties) {
|
|
188
|
+
if (!(id in response)) {
|
|
189
|
+
response[id] = {
|
|
190
|
+
id,
|
|
191
|
+
type,
|
|
192
|
+
name
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (!values || !(id in values)) continue;
|
|
197
|
+
response[id].value = values[id].value;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return response;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
function read(broker, dataReferences, callback) {
|
|
204
|
+
const responses = {};
|
|
205
|
+
let count = 0;
|
|
206
|
+
const dataReadConsumer = broker.subscribeTmp('data', 'data.read.#', onDataReadResponse, {
|
|
207
|
+
noAck: true
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
for (const {
|
|
211
|
+
id: propertyId,
|
|
212
|
+
reference
|
|
213
|
+
} of dataReferences) {
|
|
214
|
+
reference.read(broker, 'data', 'data.read.', {
|
|
215
|
+
correlationId: propertyId
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function onDataReadResponse(routingKey, message) {
|
|
220
|
+
responses[message.properties.correlationId] = { ...message.content
|
|
221
|
+
};
|
|
222
|
+
if (++count < dataReferences.length) return;
|
|
223
|
+
dataReadConsumer.cancel();
|
|
224
|
+
return callback(null, responses);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function write(broker, dataReferences, properties, callback) {
|
|
229
|
+
const responses = [];
|
|
230
|
+
let count = 0;
|
|
231
|
+
const dataWriteConsumer = broker.subscribeTmp('data', 'data.write.#', onDataWriteResponse, {
|
|
232
|
+
noAck: true
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
for (const {
|
|
236
|
+
id: propertyId,
|
|
237
|
+
reference
|
|
238
|
+
} of dataReferences) {
|
|
239
|
+
const value = propertyId in properties ? properties[propertyId].value : undefined;
|
|
240
|
+
reference.write(broker, 'data', 'data.write.', value, {
|
|
241
|
+
correlationId: propertyId
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function onDataWriteResponse(routingKey, message) {
|
|
246
|
+
responses[message.properties.correlationId] = { ...message.content
|
|
247
|
+
};
|
|
248
|
+
if (++count < dataReferences.length) return;
|
|
249
|
+
dataWriteConsumer.cancel();
|
|
250
|
+
return callback(null, responses);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.cloneContent = cloneContent;
|
|
7
7
|
exports.cloneMessage = cloneMessage;
|
|
8
8
|
exports.cloneParent = cloneParent;
|
|
9
|
+
exports.pushParent = pushParent;
|
|
9
10
|
exports.shiftParent = shiftParent;
|
|
10
11
|
exports.unshiftParent = unshiftParent;
|
|
11
|
-
exports.pushParent = pushParent;
|
|
12
12
|
|
|
13
13
|
function cloneContent(content, extend) {
|
|
14
14
|
const {
|