bpmn-elements 8.2.4 → 9.1.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 +16 -0
- package/README.md +1 -1
- package/dist/{src/Api.js → Api.js} +11 -12
- package/dist/{src/Context.js → Context.js} +26 -27
- package/dist/{src/Environment.js → Environment.js} +15 -16
- package/dist/{src/EventBroker.js → EventBroker.js} +5 -1
- package/dist/{src/Expressions.js → Expressions.js} +1 -1
- package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
- package/dist/Tracker.js +89 -0
- package/dist/{src/activity → activity}/Activity.js +109 -120
- package/dist/{src/activity → activity}/ActivityExecution.js +28 -32
- package/dist/{src/activity → activity}/Dummy.js +1 -1
- package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
- package/dist/{src/definition → definition}/Definition.js +64 -59
- package/dist/{src/definition → definition}/DefinitionExecution.js +68 -46
- package/dist/{src/error → error}/Errors.js +1 -1
- package/dist/eventDefinitions/CancelEventDefinition.js +127 -0
- package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +64 -52
- package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +24 -16
- package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +15 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
- package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
- package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
- package/dist/{src/events → events}/BoundaryEvent.js +39 -25
- package/dist/{src/events → events}/EndEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
- package/dist/{src/events → events}/StartEvent.js +8 -9
- package/dist/{src/flows → flows}/Association.js +14 -22
- package/dist/{src/flows → flows}/MessageFlow.js +16 -14
- package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
- package/dist/{src/gateways → gateways}/EventBasedGateway.js +3 -4
- package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
- package/dist/index.js +48 -48
- package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
- package/dist/{src/io → io}/Properties.js +7 -8
- package/dist/package.json +3 -0
- package/dist/{src/process → process}/Process.js +44 -40
- package/dist/{src/process → process}/ProcessExecution.js +169 -78
- package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
- package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
- package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
- package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
- package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
- package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
- package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
- package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
- package/dist/{src/tasks → tasks}/SubProcess.js +19 -19
- package/dist/{src/tasks → tasks}/Task.js +2 -2
- package/dist/{src/tasks → tasks}/Transaction.js +1 -1
- package/package.json +31 -31
- package/src/Api.js +11 -13
- package/src/Context.js +26 -28
- package/src/Environment.js +15 -17
- package/src/EventBroker.js +2 -1
- package/src/Expressions.js +1 -1
- package/src/MessageFormatter.js +3 -3
- package/src/Tracker.js +73 -0
- package/src/activity/Activity.js +106 -114
- package/src/activity/ActivityExecution.js +28 -32
- package/src/activity/Dummy.js +1 -1
- package/src/activity/ExecutionScope.js +2 -2
- package/src/definition/Definition.js +65 -64
- package/src/definition/DefinitionExecution.js +71 -47
- package/src/error/Errors.js +1 -1
- package/src/eventDefinitions/CancelEventDefinition.js +32 -78
- package/src/eventDefinitions/CompensateEventDefinition.js +58 -52
- package/src/eventDefinitions/ConditionalEventDefinition.js +25 -17
- package/src/eventDefinitions/ErrorEventDefinition.js +15 -15
- package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
- package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
- package/src/eventDefinitions/LinkEventDefinition.js +14 -16
- package/src/eventDefinitions/MessageEventDefinition.js +13 -15
- package/src/eventDefinitions/SignalEventDefinition.js +13 -15
- package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +15 -17
- package/src/events/BoundaryEvent.js +34 -24
- package/src/events/EndEvent.js +3 -3
- package/src/events/IntermediateCatchEvent.js +3 -3
- package/src/events/IntermediateThrowEvent.js +3 -3
- package/src/events/StartEvent.js +8 -10
- package/src/flows/Association.js +14 -26
- package/src/flows/MessageFlow.js +14 -15
- package/src/flows/SequenceFlow.js +16 -20
- package/src/gateways/EventBasedGateway.js +3 -4
- package/src/gateways/ExclusiveGateway.js +2 -2
- package/src/gateways/InclusiveGateway.js +2 -2
- package/src/gateways/ParallelGateway.js +2 -2
- package/src/index.js +106 -0
- package/src/io/InputOutputSpecification.js +8 -10
- package/src/io/Properties.js +7 -9
- package/src/process/Process.js +45 -41
- package/src/process/ProcessExecution.js +167 -79
- package/src/tasks/CallActivity.js +7 -9
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/ReceiveTask.js +215 -217
- package/src/tasks/ScriptTask.js +4 -4
- package/src/tasks/ServiceImplementation.js +1 -1
- package/src/tasks/ServiceTask.js +6 -8
- package/src/tasks/SignalTask.js +7 -9
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +19 -20
- package/src/tasks/Task.js +2 -2
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +520 -0
- package/dist/src/eventDefinitions/CancelEventDefinition.js +0 -184
- package/index.js +0 -106
- /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
- /package/dist/{src/Scripts.js → Scripts.js} +0 -0
- /package/dist/{src/Timers.js → Timers.js} +0 -0
- /package/dist/{src/activity → activity}/Escalation.js +0 -0
- /package/dist/{src/activity → activity}/Message.js +0 -0
- /package/dist/{src/activity → activity}/Signal.js +0 -0
- /package/dist/{src/error → error}/BpmnError.js +0 -0
- /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
- /package/dist/{src/io → io}/BpmnIO.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
- /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
- /package/dist/{src/shared.js → shared.js} +0 -0
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = DefinitionExecution;
|
|
7
|
-
var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
|
|
8
|
-
var _Api = require("../Api");
|
|
9
|
-
var _shared = require("../shared");
|
|
10
|
-
var _messageHelper = require("../messageHelper");
|
|
7
|
+
var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue.js"));
|
|
8
|
+
var _Api = require("../Api.js");
|
|
9
|
+
var _shared = require("../shared.js");
|
|
10
|
+
var _messageHelper = require("../messageHelper.js");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
const kActivated = Symbol.for('activated');
|
|
13
13
|
const kProcessesQ = Symbol.for('processesQ');
|
|
@@ -62,42 +62,64 @@ function DefinitionExecution(definition, context) {
|
|
|
62
62
|
onProcessMessage: this._onProcessMessage.bind(this)
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(proto, 'stopped', {
|
|
65
|
+
Object.defineProperty(DefinitionExecution.prototype, 'stopped', {
|
|
67
66
|
enumerable: true,
|
|
68
67
|
get() {
|
|
69
68
|
return this[kStopped];
|
|
70
69
|
}
|
|
71
70
|
});
|
|
72
|
-
Object.defineProperty(
|
|
71
|
+
Object.defineProperty(DefinitionExecution.prototype, 'completed', {
|
|
73
72
|
enumerable: true,
|
|
74
73
|
get() {
|
|
75
74
|
return this[kCompleted];
|
|
76
75
|
}
|
|
77
76
|
});
|
|
78
|
-
Object.defineProperty(
|
|
77
|
+
Object.defineProperty(DefinitionExecution.prototype, 'status', {
|
|
79
78
|
enumerable: true,
|
|
80
79
|
get() {
|
|
81
80
|
return this[kStatus];
|
|
82
81
|
}
|
|
83
82
|
});
|
|
84
|
-
Object.defineProperty(
|
|
83
|
+
Object.defineProperty(DefinitionExecution.prototype, 'processes', {
|
|
85
84
|
enumerable: true,
|
|
86
85
|
get() {
|
|
87
86
|
return this[kProcesses].running;
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
|
-
Object.defineProperty(
|
|
89
|
+
Object.defineProperty(DefinitionExecution.prototype, 'postponedCount', {
|
|
91
90
|
get() {
|
|
92
91
|
return this[kProcesses].postponed.length;
|
|
93
92
|
}
|
|
94
93
|
});
|
|
95
|
-
Object.defineProperty(
|
|
94
|
+
Object.defineProperty(DefinitionExecution.prototype, 'isRunning', {
|
|
96
95
|
get() {
|
|
97
96
|
return this[kActivated];
|
|
98
97
|
}
|
|
99
98
|
});
|
|
100
|
-
|
|
99
|
+
Object.defineProperty(DefinitionExecution.prototype, 'activityStatus', {
|
|
100
|
+
get() {
|
|
101
|
+
let status = 'idle';
|
|
102
|
+
const running = this[kProcesses].running;
|
|
103
|
+
if (!running || !running.length) return status;
|
|
104
|
+
for (const bp of running) {
|
|
105
|
+
const bpStatus = bp.activityStatus;
|
|
106
|
+
switch (bp.activityStatus) {
|
|
107
|
+
case 'idle':
|
|
108
|
+
break;
|
|
109
|
+
case 'executing':
|
|
110
|
+
return bpStatus;
|
|
111
|
+
case 'timer':
|
|
112
|
+
status = bpStatus;
|
|
113
|
+
break;
|
|
114
|
+
case 'wait':
|
|
115
|
+
if (status === 'idle') status = bpStatus;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return status;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
DefinitionExecution.prototype.execute = function execute(executeMessage) {
|
|
101
123
|
if (!executeMessage) throw new Error('Definition execution requires message');
|
|
102
124
|
const content = executeMessage.content;
|
|
103
125
|
const executionId = this.executionId = content.executionId;
|
|
@@ -131,7 +153,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
131
153
|
this._start();
|
|
132
154
|
return true;
|
|
133
155
|
};
|
|
134
|
-
|
|
156
|
+
DefinitionExecution.prototype.resume = function resume() {
|
|
135
157
|
this._debug(`resume ${this[kStatus]} definition execution`);
|
|
136
158
|
if (this[kCompleted]) return this._complete('completed');
|
|
137
159
|
const {
|
|
@@ -147,7 +169,7 @@ proto.resume = function resume() {
|
|
|
147
169
|
if (this[kCompleted]) return;
|
|
148
170
|
for (const bp of running) bp.resume();
|
|
149
171
|
};
|
|
150
|
-
|
|
172
|
+
DefinitionExecution.prototype.recover = function recover(state) {
|
|
151
173
|
if (!state) return this;
|
|
152
174
|
this.executionId = state.executionId;
|
|
153
175
|
this[kStopped] = state.stopped;
|
|
@@ -172,10 +194,10 @@ proto.recover = function recover(state) {
|
|
|
172
194
|
}
|
|
173
195
|
return this;
|
|
174
196
|
};
|
|
175
|
-
|
|
197
|
+
DefinitionExecution.prototype.stop = function stop() {
|
|
176
198
|
this.getApi().stop();
|
|
177
199
|
};
|
|
178
|
-
|
|
200
|
+
DefinitionExecution.prototype.getProcesses = function getProcesses() {
|
|
179
201
|
const {
|
|
180
202
|
running,
|
|
181
203
|
processes
|
|
@@ -186,24 +208,24 @@ proto.getProcesses = function getProcesses() {
|
|
|
186
208
|
}
|
|
187
209
|
return result;
|
|
188
210
|
};
|
|
189
|
-
|
|
211
|
+
DefinitionExecution.prototype.getProcessById = function getProcessById(processId) {
|
|
190
212
|
return this.getProcesses().find(bp => bp.id === processId);
|
|
191
213
|
};
|
|
192
|
-
|
|
214
|
+
DefinitionExecution.prototype.getProcessesById = function getProcessesById(processId) {
|
|
193
215
|
return this.getProcesses().filter(bp => bp.id === processId);
|
|
194
216
|
};
|
|
195
|
-
|
|
217
|
+
DefinitionExecution.prototype.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
|
|
196
218
|
const running = this[kProcesses].running;
|
|
197
219
|
return running.find(bp => bp.executionId === processExecutionId);
|
|
198
220
|
};
|
|
199
|
-
|
|
221
|
+
DefinitionExecution.prototype.getRunningProcesses = function getRunningProcesses() {
|
|
200
222
|
const running = this[kProcesses].running;
|
|
201
223
|
return running.filter(bp => bp.executionId);
|
|
202
224
|
};
|
|
203
|
-
|
|
225
|
+
DefinitionExecution.prototype.getExecutableProcesses = function getExecutableProcesses() {
|
|
204
226
|
return this[kProcesses].executable.slice();
|
|
205
227
|
};
|
|
206
|
-
|
|
228
|
+
DefinitionExecution.prototype.getState = function getState() {
|
|
207
229
|
return {
|
|
208
230
|
executionId: this.executionId,
|
|
209
231
|
stopped: this[kStopped],
|
|
@@ -212,7 +234,7 @@ proto.getState = function getState() {
|
|
|
212
234
|
processes: this[kProcesses].running.map(bp => bp.getState())
|
|
213
235
|
};
|
|
214
236
|
};
|
|
215
|
-
|
|
237
|
+
DefinitionExecution.prototype.getApi = function getApi(apiMessage) {
|
|
216
238
|
if (!apiMessage) apiMessage = this[kExecuteMessage] || {
|
|
217
239
|
content: this._createMessage()
|
|
218
240
|
};
|
|
@@ -232,14 +254,14 @@ proto.getApi = function getApi(apiMessage) {
|
|
|
232
254
|
};
|
|
233
255
|
return api;
|
|
234
256
|
};
|
|
235
|
-
|
|
257
|
+
DefinitionExecution.prototype.getPostponed = function getPostponed(...args) {
|
|
236
258
|
const running = this[kProcesses].running;
|
|
237
259
|
return running.reduce((result, p) => {
|
|
238
260
|
result = result.concat(p.getPostponed(...args));
|
|
239
261
|
return result;
|
|
240
262
|
}, []);
|
|
241
263
|
};
|
|
242
|
-
|
|
264
|
+
DefinitionExecution.prototype._start = function start() {
|
|
243
265
|
const {
|
|
244
266
|
ids,
|
|
245
267
|
executable,
|
|
@@ -262,7 +284,7 @@ proto._start = function start() {
|
|
|
262
284
|
consumerTag: `_definition-activity-${this.executionId}`
|
|
263
285
|
});
|
|
264
286
|
};
|
|
265
|
-
|
|
287
|
+
DefinitionExecution.prototype._activate = function activate(processList) {
|
|
266
288
|
this.broker.subscribeTmp('api', '#', this[kMessageHandlers].onApiMessage, {
|
|
267
289
|
noAck: true,
|
|
268
290
|
consumerTag: '_definition-api-consumer'
|
|
@@ -270,7 +292,7 @@ proto._activate = function activate(processList) {
|
|
|
270
292
|
for (const bp of processList) this._activateProcess(bp);
|
|
271
293
|
this[kActivated] = true;
|
|
272
294
|
};
|
|
273
|
-
|
|
295
|
+
DefinitionExecution.prototype._activateProcess = function activateProcess(bp) {
|
|
274
296
|
const handlers = this[kMessageHandlers];
|
|
275
297
|
bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
|
|
276
298
|
noAck: true,
|
|
@@ -302,7 +324,7 @@ proto._activateProcess = function activateProcess(bp) {
|
|
|
302
324
|
priority: 100
|
|
303
325
|
});
|
|
304
326
|
};
|
|
305
|
-
|
|
327
|
+
DefinitionExecution.prototype._onChildEvent = function onChildEvent(routingKey, originalMessage) {
|
|
306
328
|
const message = (0, _messageHelper.cloneMessage)(originalMessage);
|
|
307
329
|
const content = message.content;
|
|
308
330
|
const parent = content.parent = content.parent || {};
|
|
@@ -319,13 +341,13 @@ proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
|
|
|
319
341
|
if (!isDirectChild) return;
|
|
320
342
|
this[kProcessesQ].queueMessage(message.fields, (0, _messageHelper.cloneContent)(content), message.properties);
|
|
321
343
|
};
|
|
322
|
-
|
|
344
|
+
DefinitionExecution.prototype._deactivate = function deactivate() {
|
|
323
345
|
this.broker.cancel('_definition-api-consumer');
|
|
324
346
|
this.broker.cancel(`_definition-activity-${this.executionId}`);
|
|
325
347
|
for (const bp of this[kProcesses].running) this._deactivateProcess(bp);
|
|
326
348
|
this[kActivated] = false;
|
|
327
349
|
};
|
|
328
|
-
|
|
350
|
+
DefinitionExecution.prototype._deactivateProcess = function deactivateProcess(bp) {
|
|
329
351
|
bp.broker.cancel('_definition-outbound-message-consumer');
|
|
330
352
|
bp.broker.cancel('_definition-activity-consumer');
|
|
331
353
|
bp.broker.cancel('_definition-signal-consumer');
|
|
@@ -333,7 +355,7 @@ proto._deactivateProcess = function deactivateProcess(bp) {
|
|
|
333
355
|
bp.broker.cancel('_definition-call-consumer');
|
|
334
356
|
bp.broker.cancel('_definition-call-cancel-consumer');
|
|
335
357
|
};
|
|
336
|
-
|
|
358
|
+
DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(routingKey, message) {
|
|
337
359
|
const content = message.content;
|
|
338
360
|
const isRedelivered = message.fields.redelivered;
|
|
339
361
|
const {
|
|
@@ -411,7 +433,7 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
|
|
|
411
433
|
}
|
|
412
434
|
}
|
|
413
435
|
};
|
|
414
|
-
|
|
436
|
+
DefinitionExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
|
|
415
437
|
let previousMsg;
|
|
416
438
|
const postponed = this[kProcesses].postponed;
|
|
417
439
|
const idx = postponed.findIndex(msg => msg.content.executionId === message.content.executionId);
|
|
@@ -421,7 +443,7 @@ proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage
|
|
|
421
443
|
if (previousMsg) previousMsg.ack();
|
|
422
444
|
if (postponeMessage) postponed.push(message);
|
|
423
445
|
};
|
|
424
|
-
|
|
446
|
+
DefinitionExecution.prototype._onProcessCompleted = function onProcessCompleted(message) {
|
|
425
447
|
this._stateChangeMessage(message, false);
|
|
426
448
|
if (message.fields.redelivered) return message.ack();
|
|
427
449
|
const {
|
|
@@ -440,7 +462,7 @@ proto._onProcessCompleted = function onProcessCompleted(message) {
|
|
|
440
462
|
this._complete('completed');
|
|
441
463
|
}
|
|
442
464
|
};
|
|
443
|
-
|
|
465
|
+
DefinitionExecution.prototype._onStopped = function onStopped(message) {
|
|
444
466
|
const running = this[kProcesses].running;
|
|
445
467
|
this._debug(`stop definition execution (stop process executions ${running.length})`);
|
|
446
468
|
this[kProcessesQ].close();
|
|
@@ -454,7 +476,7 @@ proto._onStopped = function onStopped(message) {
|
|
|
454
476
|
persistent: false
|
|
455
477
|
});
|
|
456
478
|
};
|
|
457
|
-
|
|
479
|
+
DefinitionExecution.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
458
480
|
const messageType = message.properties.type;
|
|
459
481
|
const delegate = message.properties.delegate;
|
|
460
482
|
if (delegate && this.id === message.content.id) {
|
|
@@ -478,7 +500,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
478
500
|
});
|
|
479
501
|
}
|
|
480
502
|
};
|
|
481
|
-
|
|
503
|
+
DefinitionExecution.prototype._startProcessesByMessage = function startProcessesByMessage(reference) {
|
|
482
504
|
const {
|
|
483
505
|
processes: bps,
|
|
484
506
|
running
|
|
@@ -505,7 +527,7 @@ proto._startProcessesByMessage = function startProcessesByMessage(reference) {
|
|
|
505
527
|
if (reference.referenceType === 'message') return;
|
|
506
528
|
}
|
|
507
529
|
};
|
|
508
|
-
|
|
530
|
+
DefinitionExecution.prototype._onMessageOutbound = function onMessageOutbound(routingKey, message) {
|
|
509
531
|
const content = message.content;
|
|
510
532
|
const {
|
|
511
533
|
target,
|
|
@@ -531,7 +553,7 @@ proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
|
|
|
531
553
|
targetProcess.run();
|
|
532
554
|
targetProcess.sendMessage(message);
|
|
533
555
|
};
|
|
534
|
-
|
|
556
|
+
DefinitionExecution.prototype._onCallActivity = function onCallActivity(routingKey, message) {
|
|
535
557
|
const content = message.content;
|
|
536
558
|
const {
|
|
537
559
|
calledElement,
|
|
@@ -564,7 +586,7 @@ proto._onCallActivity = function onCallActivity(routingKey, message) {
|
|
|
564
586
|
inbound: [(0, _messageHelper.cloneContent)(content)]
|
|
565
587
|
});
|
|
566
588
|
};
|
|
567
|
-
|
|
589
|
+
DefinitionExecution.prototype._onCancelCallActivity = function onCancelCallActivity(routingKey, message) {
|
|
568
590
|
const {
|
|
569
591
|
calledElement,
|
|
570
592
|
id: fromId,
|
|
@@ -578,7 +600,7 @@ proto._onCancelCallActivity = function onCancelCallActivity(routingKey, message)
|
|
|
578
600
|
this._debug(`cancel call from <${fromParent.id}.${fromId}> to <${calledElement}>`);
|
|
579
601
|
targetProcess.getApi().discard();
|
|
580
602
|
};
|
|
581
|
-
|
|
603
|
+
DefinitionExecution.prototype._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage) {
|
|
582
604
|
const content = executeMessage.content;
|
|
583
605
|
const messageType = executeMessage.properties.type;
|
|
584
606
|
const delegateMessage = executeMessage.content.message;
|
|
@@ -604,13 +626,13 @@ proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage
|
|
|
604
626
|
type: messageType
|
|
605
627
|
});
|
|
606
628
|
};
|
|
607
|
-
|
|
629
|
+
DefinitionExecution.prototype._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
|
|
608
630
|
const running = this[kProcesses].running;
|
|
609
631
|
const idx = running.findIndex(p => p.executionId === processExecutionId);
|
|
610
632
|
if (idx === -1) return;
|
|
611
633
|
return running.splice(idx, 1)[0];
|
|
612
634
|
};
|
|
613
|
-
|
|
635
|
+
DefinitionExecution.prototype._complete = function complete(completionType, content, options) {
|
|
614
636
|
this._deactivate();
|
|
615
637
|
const stateMessage = this[kExecuteMessage];
|
|
616
638
|
this._debug(`definition execution ${completionType} in ${Date.now() - stateMessage.properties.timestamp}ms`);
|
|
@@ -631,7 +653,7 @@ proto._complete = function complete(completionType, content, options) {
|
|
|
631
653
|
...options
|
|
632
654
|
});
|
|
633
655
|
};
|
|
634
|
-
|
|
656
|
+
DefinitionExecution.prototype._createMessage = function createMessage(content = {}) {
|
|
635
657
|
return {
|
|
636
658
|
id: this.id,
|
|
637
659
|
type: this.type,
|
|
@@ -640,7 +662,7 @@ proto._createMessage = function createMessage(content = {}) {
|
|
|
640
662
|
...content
|
|
641
663
|
};
|
|
642
664
|
};
|
|
643
|
-
|
|
665
|
+
DefinitionExecution.prototype._getProcessApi = function getProcessApi(message) {
|
|
644
666
|
const content = message.content;
|
|
645
667
|
let api = this._getProcessApiByExecutionId(content.executionId, message);
|
|
646
668
|
if (api) return api;
|
|
@@ -653,11 +675,11 @@ proto._getProcessApi = function getProcessApi(message) {
|
|
|
653
675
|
if (api) return api;
|
|
654
676
|
}
|
|
655
677
|
};
|
|
656
|
-
|
|
678
|
+
DefinitionExecution.prototype._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentExecutionId, message) {
|
|
657
679
|
const processInstance = this.getProcessByExecutionId(parentExecutionId);
|
|
658
680
|
if (!processInstance) return;
|
|
659
681
|
return processInstance.getApi(message);
|
|
660
682
|
};
|
|
661
|
-
|
|
683
|
+
DefinitionExecution.prototype._debug = function debug(logMessage) {
|
|
662
684
|
this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
|
|
663
685
|
};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.RunError = exports.BpmnError = exports.ActivityError = void 0;
|
|
7
7
|
exports.makeErrorFromMessage = makeErrorFromMessage;
|
|
8
|
-
var _messageHelper = require("../messageHelper");
|
|
8
|
+
var _messageHelper = require("../messageHelper.js");
|
|
9
9
|
class ActivityError extends Error {
|
|
10
10
|
constructor(description, sourceMessage, inner) {
|
|
11
11
|
super(description);
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = CancelEventDefinition;
|
|
7
|
+
var _messageHelper = require("../messageHelper.js");
|
|
8
|
+
const kCompleted = Symbol.for('completed');
|
|
9
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
10
|
+
function CancelEventDefinition(activity, eventDefinition) {
|
|
11
|
+
const {
|
|
12
|
+
id,
|
|
13
|
+
broker,
|
|
14
|
+
environment,
|
|
15
|
+
isThrowing
|
|
16
|
+
} = activity;
|
|
17
|
+
const type = eventDefinition.type;
|
|
18
|
+
this.id = id;
|
|
19
|
+
this.type = type;
|
|
20
|
+
this.reference = {
|
|
21
|
+
referenceType: 'cancel'
|
|
22
|
+
};
|
|
23
|
+
this.isThrowing = isThrowing;
|
|
24
|
+
this.activity = activity;
|
|
25
|
+
this.environment = environment;
|
|
26
|
+
this.broker = broker;
|
|
27
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(CancelEventDefinition.prototype, 'executionId', {
|
|
30
|
+
get() {
|
|
31
|
+
const message = this[kExecuteMessage];
|
|
32
|
+
return message && message.content.executionId;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
CancelEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
36
|
+
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
37
|
+
};
|
|
38
|
+
CancelEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
|
|
39
|
+
this[kExecuteMessage] = executeMessage;
|
|
40
|
+
this[kCompleted] = false;
|
|
41
|
+
const executeContent = executeMessage.content;
|
|
42
|
+
const {
|
|
43
|
+
executionId,
|
|
44
|
+
parent
|
|
45
|
+
} = executeContent;
|
|
46
|
+
const parentExecutionId = parent.executionId;
|
|
47
|
+
const broker = this.broker;
|
|
48
|
+
this._debug('expect cancel');
|
|
49
|
+
broker.subscribeTmp('api', `activity.#.${parent.executionId}#`, this._onApiMessage.bind(this), {
|
|
50
|
+
noAck: true,
|
|
51
|
+
consumerTag: `_api-${executionId}`
|
|
52
|
+
});
|
|
53
|
+
const expectRoutingKey = `execute.cancelled.${executionId}`;
|
|
54
|
+
broker.subscribeOnce('execution', expectRoutingKey, this._onCatchMessage.bind(this), {
|
|
55
|
+
consumerTag: `_onattached-cancel-${executionId}`
|
|
56
|
+
});
|
|
57
|
+
broker.publish('execution', 'execute.expect', (0, _messageHelper.cloneContent)(executeContent, {
|
|
58
|
+
pattern: 'activity.execution.cancel',
|
|
59
|
+
exchange: 'execution',
|
|
60
|
+
expectRoutingKey
|
|
61
|
+
}));
|
|
62
|
+
const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
63
|
+
executionId: parentExecutionId,
|
|
64
|
+
condition: this.condition,
|
|
65
|
+
expect: 'cancel'
|
|
66
|
+
});
|
|
67
|
+
waitContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
68
|
+
broker.publish('event', 'activity.wait', waitContent);
|
|
69
|
+
};
|
|
70
|
+
CancelEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
71
|
+
const executeContent = executeMessage.content;
|
|
72
|
+
const {
|
|
73
|
+
executionId,
|
|
74
|
+
parent
|
|
75
|
+
} = executeContent;
|
|
76
|
+
this.logger.debug(`<${executionId} (${this.activity.id})> throw cancel`);
|
|
77
|
+
const broker = this.broker;
|
|
78
|
+
const cancelContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
79
|
+
executionId: parent.executionId,
|
|
80
|
+
state: 'throw'
|
|
81
|
+
});
|
|
82
|
+
cancelContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
83
|
+
broker.publish('event', 'activity.cancel', cancelContent, {
|
|
84
|
+
type: 'cancel'
|
|
85
|
+
});
|
|
86
|
+
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
|
|
87
|
+
};
|
|
88
|
+
CancelEventDefinition.prototype._onCatchMessage = function onCatchMessage(_, message) {
|
|
89
|
+
const content = message.content;
|
|
90
|
+
this._debug(`cancel caught from <${content.id}>`);
|
|
91
|
+
return this._complete(content.message);
|
|
92
|
+
};
|
|
93
|
+
CancelEventDefinition.prototype._complete = function complete(output) {
|
|
94
|
+
this[kCompleted] = true;
|
|
95
|
+
this._stop();
|
|
96
|
+
this._debug('completed');
|
|
97
|
+
const content = (0, _messageHelper.cloneContent)(this[kExecuteMessage].content, {
|
|
98
|
+
output,
|
|
99
|
+
state: 'cancel'
|
|
100
|
+
});
|
|
101
|
+
return this.broker.publish('execution', 'execute.completed', content);
|
|
102
|
+
};
|
|
103
|
+
CancelEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
104
|
+
switch (message.properties.type) {
|
|
105
|
+
case 'discard':
|
|
106
|
+
{
|
|
107
|
+
this[kCompleted] = true;
|
|
108
|
+
this._stop();
|
|
109
|
+
const content = (0, _messageHelper.cloneContent)(this[kExecuteMessage].content);
|
|
110
|
+
return this.broker.publish('execution', 'execute.discard', content);
|
|
111
|
+
}
|
|
112
|
+
case 'stop':
|
|
113
|
+
{
|
|
114
|
+
this._stop();
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
CancelEventDefinition.prototype._stop = function stop() {
|
|
120
|
+
const broker = this.broker,
|
|
121
|
+
executionId = this.executionId;
|
|
122
|
+
broker.cancel(`_onattached-cancel-${executionId}`);
|
|
123
|
+
broker.cancel(`_api-${executionId}`);
|
|
124
|
+
};
|
|
125
|
+
CancelEventDefinition.prototype._debug = function debug(msg) {
|
|
126
|
+
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
127
|
+
};
|