bpmn-elements 6.0.1 → 8.0.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 +341 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +176 -172
- package/dist/src/Environment.js +110 -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/activity/Activity.js +1105 -916
- 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 +710 -408
- 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 -100
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +173 -182
- 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 +17 -14
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +33 -29
- package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +117 -124
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +439 -362
- package/dist/src/process/ProcessExecution.js +748 -646
- package/dist/src/shared.js +2 -2
- 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 +193 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +16 -16
- package/src/Api.js +65 -59
- package/src/Context.js +145 -140
- package/src/Environment.js +116 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +914 -776
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +437 -401
- package/src/definition/DefinitionExecution.js +598 -340
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +159 -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 -112
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +146 -160
- 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 -15
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +29 -18
- package/src/io/EnvironmentDataStoreReference.js +31 -20
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +95 -97
- package/src/process/Process.js +378 -333
- package/src/process/ProcessExecution.js +603 -553
- 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
|
@@ -13,114 +13,183 @@ var _Errors = require("./error/Errors");
|
|
|
13
13
|
|
|
14
14
|
var _smqp = require("smqp");
|
|
15
15
|
|
|
16
|
+
const kOnMessage = Symbol.for('onMessage');
|
|
17
|
+
const kExecution = Symbol.for('execution');
|
|
18
|
+
|
|
16
19
|
function Formatter(element, formatQ) {
|
|
17
20
|
const {
|
|
18
21
|
id,
|
|
19
22
|
broker,
|
|
20
23
|
logger
|
|
21
24
|
} = element;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
25
|
+
this.id = id;
|
|
26
|
+
this.broker = broker;
|
|
27
|
+
this.logger = logger;
|
|
28
|
+
this.formatQ = formatQ;
|
|
29
|
+
this.pendingFormats = [];
|
|
30
|
+
this[kOnMessage] = this._onMessage.bind(this);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Formatter.prototype.format = function format(message, callback) {
|
|
34
|
+
const correlationId = this._runId = (0, _shared.getUniqueId)(message.fields.routingKey);
|
|
35
|
+
const consumerTag = '_formatter-' + correlationId;
|
|
36
|
+
const formatQ = this.formatQ;
|
|
37
|
+
formatQ.queueMessage({
|
|
38
|
+
routingKey: '_formatting.exec'
|
|
39
|
+
}, {}, {
|
|
40
|
+
correlationId,
|
|
41
|
+
persistent: false
|
|
42
|
+
});
|
|
43
|
+
this[kExecution] = {
|
|
44
|
+
correlationId,
|
|
45
|
+
formatKey: message.fields.routingKey,
|
|
46
|
+
runMessage: (0, _messageHelper.cloneMessage)(message),
|
|
47
|
+
callback,
|
|
48
|
+
pending: [],
|
|
49
|
+
formatted: false,
|
|
50
|
+
executeMessage: null
|
|
51
|
+
};
|
|
52
|
+
formatQ.consume(this[kOnMessage], {
|
|
53
|
+
consumerTag,
|
|
54
|
+
prefetch: 100
|
|
55
|
+
});
|
|
56
|
+
};
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function onFormatMessage(routingKey, message) {
|
|
65
|
-
const {
|
|
66
|
-
endRoutingKey,
|
|
67
|
-
error
|
|
68
|
-
} = message.content || {};
|
|
69
|
-
|
|
70
|
-
if (endRoutingKey) {
|
|
71
|
-
pendingFormats.push(message);
|
|
72
|
-
return logger.debug(`<${id}> start formatting ${fields.routingKey} message content with formatter ${routingKey}`);
|
|
58
|
+
Formatter.prototype._onMessage = function onMessage(routingKey, message) {
|
|
59
|
+
const {
|
|
60
|
+
formatKey,
|
|
61
|
+
correlationId,
|
|
62
|
+
pending,
|
|
63
|
+
executeMessage
|
|
64
|
+
} = this[kExecution];
|
|
65
|
+
const asyncFormatting = pending.length;
|
|
66
|
+
|
|
67
|
+
switch (routingKey) {
|
|
68
|
+
case '_formatting.exec':
|
|
69
|
+
if (message.properties.correlationId !== correlationId) return message.ack();
|
|
70
|
+
|
|
71
|
+
if (!asyncFormatting) {
|
|
72
|
+
message.ack();
|
|
73
|
+
return this._complete(message);
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const errMessage = error && error.message || 'formatting failed';
|
|
89
|
-
logger.debug(`<${id}> formatting of ${fields.routingKey} failed with ${routingKey}: ${errMessage}`);
|
|
90
|
-
formattingError = new _Errors.ActivityError(errMessage, (0, _messageHelper.cloneMessage)(runMessage, formattedContent), error);
|
|
91
|
-
pendingFormats.splice(0).forEach(({
|
|
92
|
-
nack
|
|
93
|
-
}) => nack(false, false));
|
|
76
|
+
this[kExecution].executeMessage = message;
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
default:
|
|
80
|
+
{
|
|
81
|
+
message.ack();
|
|
82
|
+
const endRoutingKey = message.content && message.content.endRoutingKey;
|
|
83
|
+
|
|
84
|
+
if (endRoutingKey) {
|
|
85
|
+
this._decorate(message.content);
|
|
86
|
+
|
|
87
|
+
pending.push(message);
|
|
88
|
+
return this._debug(`start formatting ${formatKey} message content with formatter ${routingKey}`);
|
|
94
89
|
}
|
|
95
90
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
if (asyncFormatting) {
|
|
92
|
+
const {
|
|
93
|
+
isError,
|
|
94
|
+
message: startMessage
|
|
95
|
+
} = this._popFormatStart(pending, routingKey);
|
|
96
|
+
|
|
97
|
+
if (startMessage) startMessage.ack();
|
|
98
|
+
|
|
99
|
+
if (isError) {
|
|
100
|
+
return this._complete(message, true);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this._decorate(message.content);
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
endRoutingKey,
|
|
105
|
-
errorRoutingKey = '#.error'
|
|
106
|
-
} = pendingFormat.content;
|
|
107
|
-
|
|
108
|
-
if ((0, _smqp.getRoutingKeyPattern)(endRoutingKey).test(routingKey)) {
|
|
109
|
-
logger.debug(`<${id}> completed formatting ${fields.routingKey} message content with formatter ${routingKey}`);
|
|
110
|
-
pendingFormats.splice(i, 1);
|
|
111
|
-
return {
|
|
112
|
-
message: pendingFormat
|
|
113
|
-
};
|
|
114
|
-
} else if ((0, _smqp.getRoutingKeyPattern)(errorRoutingKey).test(routingKey)) {
|
|
115
|
-
pendingFormats.splice(i, 1);
|
|
116
|
-
return {
|
|
117
|
-
isError: true,
|
|
118
|
-
message: pendingFormat
|
|
119
|
-
};
|
|
106
|
+
this._debug(`format ${message.fields.routingKey} message content with formatter ${routingKey}`);
|
|
107
|
+
|
|
108
|
+
if (executeMessage && asyncFormatting && !pending.length) {
|
|
109
|
+
this._complete(message);
|
|
120
110
|
}
|
|
121
111
|
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
122
114
|
|
|
123
|
-
|
|
115
|
+
Formatter.prototype._complete = function complete(message, isError) {
|
|
116
|
+
const {
|
|
117
|
+
runMessage,
|
|
118
|
+
formatKey,
|
|
119
|
+
callback,
|
|
120
|
+
formatted,
|
|
121
|
+
executeMessage
|
|
122
|
+
} = this[kExecution];
|
|
123
|
+
this[kExecution] = null;
|
|
124
|
+
if (executeMessage) executeMessage.ack();
|
|
125
|
+
this.broker.cancel(message.fields.consumerTag);
|
|
126
|
+
|
|
127
|
+
if (isError) {
|
|
128
|
+
const error = message.content && message.content.error || new Error('formatting failed');
|
|
129
|
+
const errMessage = error.message || 'formatting failed';
|
|
130
|
+
|
|
131
|
+
this._debug(`formatting of ${formatKey} failed with ${message.fields.routingKey}: ${errMessage}`);
|
|
132
|
+
|
|
133
|
+
return callback(new _Errors.ActivityError(errMessage, (0, _messageHelper.cloneMessage)(runMessage), error));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return callback(null, runMessage.content, formatted);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
Formatter.prototype._decorate = function decorate(withContent) {
|
|
140
|
+
const content = this[kExecution].runMessage.content;
|
|
141
|
+
|
|
142
|
+
for (const key in withContent) {
|
|
143
|
+
switch (key) {
|
|
144
|
+
case 'id':
|
|
145
|
+
case 'type':
|
|
146
|
+
case 'parent':
|
|
147
|
+
case 'attachedTo':
|
|
148
|
+
case 'executionId':
|
|
149
|
+
case 'isSubProcess':
|
|
150
|
+
case 'isMultiInstance':
|
|
151
|
+
case 'inbound':
|
|
152
|
+
case 'outbound':
|
|
153
|
+
case 'endRoutingKey':
|
|
154
|
+
case 'errorRoutingKey':
|
|
155
|
+
break;
|
|
156
|
+
|
|
157
|
+
default:
|
|
158
|
+
{
|
|
159
|
+
content[key] = withContent[key];
|
|
160
|
+
this[kExecution].formatted = true;
|
|
161
|
+
}
|
|
124
162
|
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
Formatter.prototype._popFormatStart = function popFormattingStart(pending, routingKey) {
|
|
167
|
+
for (let idx = 0; idx < pending.length; idx++) {
|
|
168
|
+
const msg = pending[idx];
|
|
169
|
+
const {
|
|
170
|
+
endRoutingKey,
|
|
171
|
+
errorRoutingKey = '#.error'
|
|
172
|
+
} = msg.content;
|
|
173
|
+
|
|
174
|
+
if (endRoutingKey && (0, _smqp.getRoutingKeyPattern)(endRoutingKey).test(routingKey)) {
|
|
175
|
+
this._debug(`completed formatting ${msg.fields.routingKey} message content with formatter ${routingKey}`);
|
|
176
|
+
|
|
177
|
+
pending.splice(idx, 1);
|
|
178
|
+
return {
|
|
179
|
+
message: msg
|
|
180
|
+
};
|
|
181
|
+
} else if ((0, _smqp.getRoutingKeyPattern)(errorRoutingKey).test(routingKey)) {
|
|
182
|
+
pending.splice(idx, 1);
|
|
183
|
+
return {
|
|
184
|
+
isError: true,
|
|
185
|
+
message: msg
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {};
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
Formatter.prototype._debug = function debug(msg) {
|
|
194
|
+
this.logger.debug(`<${this.id}> ${msg}`);
|
|
195
|
+
};
|