bpmn-elements 8.2.4 → 9.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 +10 -0
- 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} +1 -1
- package/dist/{src/Expressions.js → Expressions.js} +1 -1
- package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
- package/dist/{src/activity → activity}/Activity.js +62 -63
- package/dist/{src/activity → activity}/ActivityExecution.js +23 -24
- 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 +41 -42
- package/dist/{src/definition → definition}/DefinitionExecution.js +45 -46
- package/dist/{src/error → error}/Errors.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/CancelEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +13 -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 +15 -16
- 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 +15 -16
- 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 +2 -2
- 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 +39 -40
- package/dist/{src/process → process}/ProcessExecution.js +42 -43
- 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 +17 -18
- package/dist/{src/tasks → tasks}/Task.js +2 -2
- package/dist/{src/tasks → tasks}/Transaction.js +1 -1
- package/package.json +30 -30
- package/src/Api.js +11 -13
- package/src/Context.js +26 -28
- package/src/Environment.js +15 -17
- package/src/EventBroker.js +1 -1
- package/src/Expressions.js +1 -1
- package/src/MessageFormatter.js +3 -3
- package/src/activity/Activity.js +62 -64
- package/src/activity/ActivityExecution.js +23 -25
- package/src/activity/Dummy.js +1 -1
- package/src/activity/ExecutionScope.js +2 -2
- package/src/definition/Definition.js +41 -43
- package/src/definition/DefinitionExecution.js +45 -47
- package/src/error/Errors.js +1 -1
- package/src/eventDefinitions/CancelEventDefinition.js +12 -14
- package/src/eventDefinitions/CompensateEventDefinition.js +12 -14
- package/src/eventDefinitions/ConditionalEventDefinition.js +13 -15
- package/src/eventDefinitions/ErrorEventDefinition.js +13 -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 +15 -17
- 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 +15 -17
- package/src/flows/MessageFlow.js +14 -15
- package/src/flows/SequenceFlow.js +16 -20
- package/src/gateways/EventBasedGateway.js +2 -2
- 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 +39 -41
- package/src/process/ProcessExecution.js +42 -44
- 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 +17 -19
- package/src/tasks/Task.js +2 -2
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +491 -0
- 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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import DefinitionExecution from './DefinitionExecution';
|
|
2
|
-
import {DefinitionApi} from '../Api';
|
|
3
|
-
import {DefinitionBroker} from '../EventBroker';
|
|
4
|
-
import {getUniqueId, getOptionsAndCallback} from '../shared';
|
|
5
|
-
import {makeErrorFromMessage} from '../error/Errors';
|
|
6
|
-
import {cloneMessage, cloneContent} from '../messageHelper';
|
|
1
|
+
import DefinitionExecution from './DefinitionExecution.js';
|
|
2
|
+
import {DefinitionApi} from '../Api.js';
|
|
3
|
+
import {DefinitionBroker} from '../EventBroker.js';
|
|
4
|
+
import {getUniqueId, getOptionsAndCallback} from '../shared.js';
|
|
5
|
+
import {makeErrorFromMessage} from '../error/Errors.js';
|
|
6
|
+
import {cloneMessage, cloneContent} from '../messageHelper.js';
|
|
7
7
|
|
|
8
8
|
const kConsuming = Symbol.for('consuming');
|
|
9
9
|
const kCounters = Symbol.for('counters');
|
|
@@ -63,30 +63,28 @@ export function Definition(context, options) {
|
|
|
63
63
|
this.logger = environment.Logger(type.toLowerCase());
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Object.defineProperty(proto, 'counters', {
|
|
66
|
+
Object.defineProperty(Definition.prototype, 'counters', {
|
|
69
67
|
enumerable: true,
|
|
70
68
|
get() {
|
|
71
69
|
return {...this[kCounters]};
|
|
72
70
|
},
|
|
73
71
|
});
|
|
74
72
|
|
|
75
|
-
Object.defineProperty(
|
|
73
|
+
Object.defineProperty(Definition.prototype, 'execution', {
|
|
76
74
|
enumerable: true,
|
|
77
75
|
get() {
|
|
78
76
|
return this[kExec].execution;
|
|
79
77
|
},
|
|
80
78
|
});
|
|
81
79
|
|
|
82
|
-
Object.defineProperty(
|
|
80
|
+
Object.defineProperty(Definition.prototype, 'executionId', {
|
|
83
81
|
enumerable: true,
|
|
84
82
|
get() {
|
|
85
83
|
return this[kExec].executionId;
|
|
86
84
|
},
|
|
87
85
|
});
|
|
88
86
|
|
|
89
|
-
Object.defineProperty(
|
|
87
|
+
Object.defineProperty(Definition.prototype, 'isRunning', {
|
|
90
88
|
enumerable: true,
|
|
91
89
|
get() {
|
|
92
90
|
if (!this[kConsuming]) return false;
|
|
@@ -94,21 +92,21 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
94
92
|
},
|
|
95
93
|
});
|
|
96
94
|
|
|
97
|
-
Object.defineProperty(
|
|
95
|
+
Object.defineProperty(Definition.prototype, 'status', {
|
|
98
96
|
enumerable: true,
|
|
99
97
|
get() {
|
|
100
98
|
return this[kStatus];
|
|
101
99
|
},
|
|
102
100
|
});
|
|
103
101
|
|
|
104
|
-
Object.defineProperty(
|
|
102
|
+
Object.defineProperty(Definition.prototype, 'stopped', {
|
|
105
103
|
enumerable: true,
|
|
106
104
|
get() {
|
|
107
105
|
return this[kStopped];
|
|
108
106
|
},
|
|
109
107
|
});
|
|
110
108
|
|
|
111
|
-
|
|
109
|
+
Definition.prototype.run = function run(optionsOrCallback, optionalCallback) {
|
|
112
110
|
const [runOptions, callback] = getOptionsAndCallback(optionsOrCallback, optionalCallback);
|
|
113
111
|
if (this.isRunning) {
|
|
114
112
|
const err = new Error('definition is already running');
|
|
@@ -136,7 +134,7 @@ proto.run = function run(optionsOrCallback, optionalCallback) {
|
|
|
136
134
|
return this;
|
|
137
135
|
};
|
|
138
136
|
|
|
139
|
-
|
|
137
|
+
Definition.prototype.resume = function resume(callback) {
|
|
140
138
|
if (this.isRunning) {
|
|
141
139
|
const err = new Error('cannot resume running definition');
|
|
142
140
|
if (callback) return callback(err);
|
|
@@ -158,7 +156,7 @@ proto.resume = function resume(callback) {
|
|
|
158
156
|
return this;
|
|
159
157
|
};
|
|
160
158
|
|
|
161
|
-
|
|
159
|
+
Definition.prototype.recover = function recover(state) {
|
|
162
160
|
if (this.isRunning) throw new Error('cannot recover running definition');
|
|
163
161
|
if (!state) return this;
|
|
164
162
|
|
|
@@ -182,7 +180,7 @@ proto.recover = function recover(state) {
|
|
|
182
180
|
return this;
|
|
183
181
|
};
|
|
184
182
|
|
|
185
|
-
|
|
183
|
+
Definition.prototype.shake = function shake(startId) {
|
|
186
184
|
let result = {};
|
|
187
185
|
const broker = this.broker;
|
|
188
186
|
|
|
@@ -221,7 +219,7 @@ proto.shake = function shake(startId) {
|
|
|
221
219
|
}
|
|
222
220
|
};
|
|
223
221
|
|
|
224
|
-
|
|
222
|
+
Definition.prototype.getState = function getState() {
|
|
225
223
|
return this._createMessage({
|
|
226
224
|
status: this.status,
|
|
227
225
|
stopped: this.stopped,
|
|
@@ -232,29 +230,29 @@ proto.getState = function getState() {
|
|
|
232
230
|
});
|
|
233
231
|
};
|
|
234
232
|
|
|
235
|
-
|
|
233
|
+
Definition.prototype.getProcesses = function getProcesses() {
|
|
236
234
|
const execution = this.execution;
|
|
237
235
|
if (execution) return execution.getProcesses();
|
|
238
236
|
return this.context.getProcesses();
|
|
239
237
|
};
|
|
240
238
|
|
|
241
|
-
|
|
239
|
+
Definition.prototype.getExecutableProcesses = function getExecutableProcesses() {
|
|
242
240
|
const execution = this.execution;
|
|
243
241
|
if (execution) return execution.getExecutableProcesses();
|
|
244
242
|
return this.context.getExecutableProcesses();
|
|
245
243
|
};
|
|
246
244
|
|
|
247
|
-
|
|
245
|
+
Definition.prototype.getRunningProcesses = function getRunningProcesses() {
|
|
248
246
|
const execution = this.execution;
|
|
249
247
|
if (!execution) return [];
|
|
250
248
|
return execution.getRunningProcesses();
|
|
251
249
|
};
|
|
252
250
|
|
|
253
|
-
|
|
251
|
+
Definition.prototype.getProcessById = function getProcessById(processId) {
|
|
254
252
|
return this.getProcesses().find((p) => p.id === processId);
|
|
255
253
|
};
|
|
256
254
|
|
|
257
|
-
|
|
255
|
+
Definition.prototype.getActivityById = function getActivityById(childId) {
|
|
258
256
|
const bps = this.getProcesses();
|
|
259
257
|
for (const bp of bps) {
|
|
260
258
|
const child = bp.getActivityById(childId);
|
|
@@ -263,17 +261,17 @@ proto.getActivityById = function getActivityById(childId) {
|
|
|
263
261
|
return null;
|
|
264
262
|
};
|
|
265
263
|
|
|
266
|
-
|
|
264
|
+
Definition.prototype.getElementById = function getElementById(elementId) {
|
|
267
265
|
return this.context.getActivityById(elementId);
|
|
268
266
|
};
|
|
269
267
|
|
|
270
|
-
|
|
268
|
+
Definition.prototype.getPostponed = function getPostponed(...args) {
|
|
271
269
|
const execution = this.execution;
|
|
272
270
|
if (!execution) return [];
|
|
273
271
|
return execution.getPostponed(...args);
|
|
274
272
|
};
|
|
275
273
|
|
|
276
|
-
|
|
274
|
+
Definition.prototype.getApi = function getApi(message) {
|
|
277
275
|
const execution = this.execution;
|
|
278
276
|
if (execution) return execution.getApi(message);
|
|
279
277
|
message = message || this[kStateMessage];
|
|
@@ -281,15 +279,15 @@ proto.getApi = function getApi(message) {
|
|
|
281
279
|
return DefinitionApi(this.broker, message);
|
|
282
280
|
};
|
|
283
281
|
|
|
284
|
-
|
|
282
|
+
Definition.prototype.signal = function signal(message) {
|
|
285
283
|
return this.getApi().signal(message, {delegate: true});
|
|
286
284
|
};
|
|
287
285
|
|
|
288
|
-
|
|
286
|
+
Definition.prototype.cancelActivity = function cancelActivity(message) {
|
|
289
287
|
return this.getApi().cancel(message, {delegate: true});
|
|
290
288
|
};
|
|
291
289
|
|
|
292
|
-
|
|
290
|
+
Definition.prototype.sendMessage = function sendMessage(message) {
|
|
293
291
|
const messageContent = {message};
|
|
294
292
|
let messageType = 'message';
|
|
295
293
|
const reference = message && message.id && this.getElementById(message.id);
|
|
@@ -302,12 +300,12 @@ proto.sendMessage = function sendMessage(message) {
|
|
|
302
300
|
return this.getApi().sendApiMessage(messageType, messageContent, {delegate: true});
|
|
303
301
|
};
|
|
304
302
|
|
|
305
|
-
|
|
303
|
+
Definition.prototype.stop = function stop() {
|
|
306
304
|
if (!this.isRunning) return;
|
|
307
305
|
this.getApi().stop();
|
|
308
306
|
};
|
|
309
307
|
|
|
310
|
-
|
|
308
|
+
Definition.prototype._activateRunConsumers = function activateRunConsumers() {
|
|
311
309
|
this[kConsuming] = true;
|
|
312
310
|
const broker = this.broker;
|
|
313
311
|
const {onApiMessage, onRunMessage} = this[kMessageHandlers];
|
|
@@ -321,7 +319,7 @@ proto._activateRunConsumers = function activateRunConsumers() {
|
|
|
321
319
|
});
|
|
322
320
|
};
|
|
323
321
|
|
|
324
|
-
|
|
322
|
+
Definition.prototype._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
325
323
|
const broker = this.broker;
|
|
326
324
|
broker.cancel('_definition-api');
|
|
327
325
|
broker.cancel('_definition-run');
|
|
@@ -329,7 +327,7 @@ proto._deactivateRunConsumers = function deactivateRunConsumers() {
|
|
|
329
327
|
this[kConsuming] = false;
|
|
330
328
|
};
|
|
331
329
|
|
|
332
|
-
|
|
330
|
+
Definition.prototype._createMessage = function createMessage(override) {
|
|
333
331
|
return {
|
|
334
332
|
id: this.id,
|
|
335
333
|
type: this.type,
|
|
@@ -339,7 +337,7 @@ proto._createMessage = function createMessage(override) {
|
|
|
339
337
|
};
|
|
340
338
|
};
|
|
341
339
|
|
|
342
|
-
|
|
340
|
+
Definition.prototype._onRunMessage = function onRunMessage(routingKey, message) {
|
|
343
341
|
const {content, fields} = message;
|
|
344
342
|
if (routingKey === 'run.resume') {
|
|
345
343
|
return this._onResumeMessage(message);
|
|
@@ -425,7 +423,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message) {
|
|
|
425
423
|
message.ack();
|
|
426
424
|
};
|
|
427
425
|
|
|
428
|
-
|
|
426
|
+
Definition.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
429
427
|
message.ack();
|
|
430
428
|
|
|
431
429
|
const stateMessage = this[kStateMessage];
|
|
@@ -446,7 +444,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
446
444
|
return this.broker.publish('run', stateMessage.fields.routingKey, cloneContent(stateMessage.content), stateMessage.properties);
|
|
447
445
|
};
|
|
448
446
|
|
|
449
|
-
|
|
447
|
+
Definition.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
450
448
|
const {content, properties} = message;
|
|
451
449
|
const messageType = properties.type;
|
|
452
450
|
|
|
@@ -471,7 +469,7 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
471
469
|
executeMessage.ack();
|
|
472
470
|
};
|
|
473
471
|
|
|
474
|
-
|
|
472
|
+
Definition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
475
473
|
if (message.properties.type === 'stop') {
|
|
476
474
|
const execution = this.execution;
|
|
477
475
|
if (!execution || execution.completed) {
|
|
@@ -480,7 +478,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
480
478
|
}
|
|
481
479
|
};
|
|
482
480
|
|
|
483
|
-
|
|
481
|
+
Definition.prototype._publishEvent = function publishEvent(action, content, msgOpts) {
|
|
484
482
|
const execution = this.execution;
|
|
485
483
|
this.broker.publish('event', `definition.${action}`, execution ? execution._createMessage(content) : cloneContent(content), {
|
|
486
484
|
type: action,
|
|
@@ -488,13 +486,13 @@ proto._publishEvent = function publishEvent(action, content, msgOpts) {
|
|
|
488
486
|
});
|
|
489
487
|
};
|
|
490
488
|
|
|
491
|
-
|
|
489
|
+
Definition.prototype._onStop = function onStop() {
|
|
492
490
|
this[kStopped] = true;
|
|
493
491
|
this._deactivateRunConsumers();
|
|
494
492
|
return this._publishEvent('stop', this._createMessage());
|
|
495
493
|
};
|
|
496
494
|
|
|
497
|
-
|
|
495
|
+
Definition.prototype._onBrokerReturnFn = function onBrokerReturn(message) {
|
|
498
496
|
if (message.properties.type === 'error') {
|
|
499
497
|
this._deactivateRunConsumers();
|
|
500
498
|
const err = makeErrorFromMessage(message);
|
|
@@ -502,14 +500,14 @@ proto._onBrokerReturnFn = function onBrokerReturn(message) {
|
|
|
502
500
|
}
|
|
503
501
|
};
|
|
504
502
|
|
|
505
|
-
|
|
503
|
+
Definition.prototype._reset = function reset() {
|
|
506
504
|
this[kExec].executionId = undefined;
|
|
507
505
|
this._deactivateRunConsumers();
|
|
508
506
|
this.broker.purgeQueue('run-q');
|
|
509
507
|
this.broker.purgeQueue('execution-q');
|
|
510
508
|
};
|
|
511
509
|
|
|
512
|
-
|
|
510
|
+
Definition.prototype._debug = function debug(msg) {
|
|
513
511
|
this.logger.debug(`<${this.id}> ${msg}`);
|
|
514
512
|
};
|
|
515
513
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import getPropertyValue from '../getPropertyValue';
|
|
2
|
-
import {DefinitionApi} from '../Api';
|
|
3
|
-
import {brokerSafeId} from '../shared';
|
|
4
|
-
import {cloneContent, cloneMessage, pushParent, cloneParent} from '../messageHelper';
|
|
1
|
+
import getPropertyValue from '../getPropertyValue.js';
|
|
2
|
+
import {DefinitionApi} from '../Api.js';
|
|
3
|
+
import {brokerSafeId} from '../shared.js';
|
|
4
|
+
import {cloneContent, cloneMessage, pushParent, cloneParent} from '../messageHelper.js';
|
|
5
5
|
|
|
6
6
|
const kActivated = Symbol.for('activated');
|
|
7
7
|
const kProcessesQ = Symbol.for('processesQ');
|
|
@@ -61,49 +61,47 @@ export default function DefinitionExecution(definition, context) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(proto, 'stopped', {
|
|
64
|
+
Object.defineProperty(DefinitionExecution.prototype, 'stopped', {
|
|
67
65
|
enumerable: true,
|
|
68
66
|
get() {
|
|
69
67
|
return this[kStopped];
|
|
70
68
|
},
|
|
71
69
|
});
|
|
72
70
|
|
|
73
|
-
Object.defineProperty(
|
|
71
|
+
Object.defineProperty(DefinitionExecution.prototype, 'completed', {
|
|
74
72
|
enumerable: true,
|
|
75
73
|
get() {
|
|
76
74
|
return this[kCompleted];
|
|
77
75
|
},
|
|
78
76
|
});
|
|
79
77
|
|
|
80
|
-
Object.defineProperty(
|
|
78
|
+
Object.defineProperty(DefinitionExecution.prototype, 'status', {
|
|
81
79
|
enumerable: true,
|
|
82
80
|
get() {
|
|
83
81
|
return this[kStatus];
|
|
84
82
|
},
|
|
85
83
|
});
|
|
86
84
|
|
|
87
|
-
Object.defineProperty(
|
|
85
|
+
Object.defineProperty(DefinitionExecution.prototype, 'processes', {
|
|
88
86
|
enumerable: true,
|
|
89
87
|
get() {
|
|
90
88
|
return this[kProcesses].running;
|
|
91
89
|
},
|
|
92
90
|
});
|
|
93
91
|
|
|
94
|
-
Object.defineProperty(
|
|
92
|
+
Object.defineProperty(DefinitionExecution.prototype, 'postponedCount', {
|
|
95
93
|
get() {
|
|
96
94
|
return this[kProcesses].postponed.length;
|
|
97
95
|
},
|
|
98
96
|
});
|
|
99
97
|
|
|
100
|
-
Object.defineProperty(
|
|
98
|
+
Object.defineProperty(DefinitionExecution.prototype, 'isRunning', {
|
|
101
99
|
get() {
|
|
102
100
|
return this[kActivated];
|
|
103
101
|
},
|
|
104
102
|
});
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
DefinitionExecution.prototype.execute = function execute(executeMessage) {
|
|
107
105
|
if (!executeMessage) throw new Error('Definition execution requires message');
|
|
108
106
|
const content = executeMessage.content;
|
|
109
107
|
const executionId = this.executionId = content.executionId;
|
|
@@ -139,7 +137,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
139
137
|
return true;
|
|
140
138
|
};
|
|
141
139
|
|
|
142
|
-
|
|
140
|
+
DefinitionExecution.prototype.resume = function resume() {
|
|
143
141
|
this._debug(`resume ${this[kStatus]} definition execution`);
|
|
144
142
|
|
|
145
143
|
if (this[kCompleted]) return this._complete('completed');
|
|
@@ -157,7 +155,7 @@ proto.resume = function resume() {
|
|
|
157
155
|
for (const bp of running) bp.resume();
|
|
158
156
|
};
|
|
159
157
|
|
|
160
|
-
|
|
158
|
+
DefinitionExecution.prototype.recover = function recover(state) {
|
|
161
159
|
if (!state) return this;
|
|
162
160
|
this.executionId = state.executionId;
|
|
163
161
|
|
|
@@ -189,11 +187,11 @@ proto.recover = function recover(state) {
|
|
|
189
187
|
return this;
|
|
190
188
|
};
|
|
191
189
|
|
|
192
|
-
|
|
190
|
+
DefinitionExecution.prototype.stop = function stop() {
|
|
193
191
|
this.getApi().stop();
|
|
194
192
|
};
|
|
195
193
|
|
|
196
|
-
|
|
194
|
+
DefinitionExecution.prototype.getProcesses = function getProcesses() {
|
|
197
195
|
const {running, processes} = this[kProcesses];
|
|
198
196
|
const result = running.slice();
|
|
199
197
|
for (const bp of processes) {
|
|
@@ -202,29 +200,29 @@ proto.getProcesses = function getProcesses() {
|
|
|
202
200
|
return result;
|
|
203
201
|
};
|
|
204
202
|
|
|
205
|
-
|
|
203
|
+
DefinitionExecution.prototype.getProcessById = function getProcessById(processId) {
|
|
206
204
|
return this.getProcesses().find((bp) => bp.id === processId);
|
|
207
205
|
};
|
|
208
206
|
|
|
209
|
-
|
|
207
|
+
DefinitionExecution.prototype.getProcessesById = function getProcessesById(processId) {
|
|
210
208
|
return this.getProcesses().filter((bp) => bp.id === processId);
|
|
211
209
|
};
|
|
212
210
|
|
|
213
|
-
|
|
211
|
+
DefinitionExecution.prototype.getProcessByExecutionId = function getProcessByExecutionId(processExecutionId) {
|
|
214
212
|
const running = this[kProcesses].running;
|
|
215
213
|
return running.find((bp) => bp.executionId === processExecutionId);
|
|
216
214
|
};
|
|
217
215
|
|
|
218
|
-
|
|
216
|
+
DefinitionExecution.prototype.getRunningProcesses = function getRunningProcesses() {
|
|
219
217
|
const running = this[kProcesses].running;
|
|
220
218
|
return running.filter((bp) => bp.executionId);
|
|
221
219
|
};
|
|
222
220
|
|
|
223
|
-
|
|
221
|
+
DefinitionExecution.prototype.getExecutableProcesses = function getExecutableProcesses() {
|
|
224
222
|
return this[kProcesses].executable.slice();
|
|
225
223
|
};
|
|
226
224
|
|
|
227
|
-
|
|
225
|
+
DefinitionExecution.prototype.getState = function getState() {
|
|
228
226
|
return {
|
|
229
227
|
executionId: this.executionId,
|
|
230
228
|
stopped: this[kStopped],
|
|
@@ -234,7 +232,7 @@ proto.getState = function getState() {
|
|
|
234
232
|
};
|
|
235
233
|
};
|
|
236
234
|
|
|
237
|
-
|
|
235
|
+
DefinitionExecution.prototype.getApi = function getApi(apiMessage) {
|
|
238
236
|
if (!apiMessage) apiMessage = this[kExecuteMessage] || {content: this._createMessage()};
|
|
239
237
|
|
|
240
238
|
const content = apiMessage.content;
|
|
@@ -257,7 +255,7 @@ proto.getApi = function getApi(apiMessage) {
|
|
|
257
255
|
return api;
|
|
258
256
|
};
|
|
259
257
|
|
|
260
|
-
|
|
258
|
+
DefinitionExecution.prototype.getPostponed = function getPostponed(...args) {
|
|
261
259
|
const running = this[kProcesses].running;
|
|
262
260
|
return running.reduce((result, p) => {
|
|
263
261
|
result = result.concat(p.getPostponed(...args));
|
|
@@ -265,7 +263,7 @@ proto.getPostponed = function getPostponed(...args) {
|
|
|
265
263
|
}, []);
|
|
266
264
|
};
|
|
267
265
|
|
|
268
|
-
|
|
266
|
+
DefinitionExecution.prototype._start = function start() {
|
|
269
267
|
const {ids, executable, postponed} = this[kProcesses];
|
|
270
268
|
if (!ids.length) {
|
|
271
269
|
return this._complete('completed');
|
|
@@ -287,7 +285,7 @@ proto._start = function start() {
|
|
|
287
285
|
});
|
|
288
286
|
};
|
|
289
287
|
|
|
290
|
-
|
|
288
|
+
DefinitionExecution.prototype._activate = function activate(processList) {
|
|
291
289
|
this.broker.subscribeTmp('api', '#', this[kMessageHandlers].onApiMessage, {
|
|
292
290
|
noAck: true,
|
|
293
291
|
consumerTag: '_definition-api-consumer',
|
|
@@ -296,7 +294,7 @@ proto._activate = function activate(processList) {
|
|
|
296
294
|
this[kActivated] = true;
|
|
297
295
|
};
|
|
298
296
|
|
|
299
|
-
|
|
297
|
+
DefinitionExecution.prototype._activateProcess = function activateProcess(bp) {
|
|
300
298
|
const handlers = this[kMessageHandlers];
|
|
301
299
|
|
|
302
300
|
bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
|
|
@@ -330,7 +328,7 @@ proto._activateProcess = function activateProcess(bp) {
|
|
|
330
328
|
});
|
|
331
329
|
};
|
|
332
330
|
|
|
333
|
-
|
|
331
|
+
DefinitionExecution.prototype._onChildEvent = function onChildEvent(routingKey, originalMessage) {
|
|
334
332
|
const message = cloneMessage(originalMessage);
|
|
335
333
|
const content = message.content;
|
|
336
334
|
const parent = content.parent = content.parent || {};
|
|
@@ -348,14 +346,14 @@ proto._onChildEvent = function onChildEvent(routingKey, originalMessage) {
|
|
|
348
346
|
this[kProcessesQ].queueMessage(message.fields, cloneContent(content), message.properties);
|
|
349
347
|
};
|
|
350
348
|
|
|
351
|
-
|
|
349
|
+
DefinitionExecution.prototype._deactivate = function deactivate() {
|
|
352
350
|
this.broker.cancel('_definition-api-consumer');
|
|
353
351
|
this.broker.cancel(`_definition-activity-${this.executionId}`);
|
|
354
352
|
for (const bp of this[kProcesses].running) this._deactivateProcess(bp);
|
|
355
353
|
this[kActivated] = false;
|
|
356
354
|
};
|
|
357
355
|
|
|
358
|
-
|
|
356
|
+
DefinitionExecution.prototype._deactivateProcess = function deactivateProcess(bp) {
|
|
359
357
|
bp.broker.cancel('_definition-outbound-message-consumer');
|
|
360
358
|
bp.broker.cancel('_definition-activity-consumer');
|
|
361
359
|
bp.broker.cancel('_definition-signal-consumer');
|
|
@@ -364,7 +362,7 @@ proto._deactivateProcess = function deactivateProcess(bp) {
|
|
|
364
362
|
bp.broker.cancel('_definition-call-cancel-consumer');
|
|
365
363
|
};
|
|
366
364
|
|
|
367
|
-
|
|
365
|
+
DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(routingKey, message) {
|
|
368
366
|
const content = message.content;
|
|
369
367
|
const isRedelivered = message.fields.redelivered;
|
|
370
368
|
const {id: childId, inbound} = content;
|
|
@@ -429,7 +427,7 @@ proto._onProcessMessage = function onProcessMessage(routingKey, message) {
|
|
|
429
427
|
}
|
|
430
428
|
};
|
|
431
429
|
|
|
432
|
-
|
|
430
|
+
DefinitionExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
|
|
433
431
|
let previousMsg;
|
|
434
432
|
const postponed = this[kProcesses].postponed;
|
|
435
433
|
const idx = postponed.findIndex((msg) => msg.content.executionId === message.content.executionId);
|
|
@@ -441,7 +439,7 @@ proto._stateChangeMessage = function stateChangeMessage(message, postponeMessage
|
|
|
441
439
|
if (postponeMessage) postponed.push(message);
|
|
442
440
|
};
|
|
443
441
|
|
|
444
|
-
|
|
442
|
+
DefinitionExecution.prototype._onProcessCompleted = function onProcessCompleted(message) {
|
|
445
443
|
this._stateChangeMessage(message, false);
|
|
446
444
|
if (message.fields.redelivered) return message.ack();
|
|
447
445
|
|
|
@@ -459,7 +457,7 @@ proto._onProcessCompleted = function onProcessCompleted(message) {
|
|
|
459
457
|
}
|
|
460
458
|
};
|
|
461
459
|
|
|
462
|
-
|
|
460
|
+
DefinitionExecution.prototype._onStopped = function onStopped(message) {
|
|
463
461
|
const running = this[kProcesses].running;
|
|
464
462
|
this._debug(`stop definition execution (stop process executions ${running.length})`);
|
|
465
463
|
this[kProcessesQ].close();
|
|
@@ -472,7 +470,7 @@ proto._onStopped = function onStopped(message) {
|
|
|
472
470
|
}), {type: 'stopped', persistent: false});
|
|
473
471
|
};
|
|
474
472
|
|
|
475
|
-
|
|
473
|
+
DefinitionExecution.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
476
474
|
const messageType = message.properties.type;
|
|
477
475
|
const delegate = message.properties.delegate;
|
|
478
476
|
|
|
@@ -494,7 +492,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
494
492
|
}
|
|
495
493
|
};
|
|
496
494
|
|
|
497
|
-
|
|
495
|
+
DefinitionExecution.prototype._startProcessesByMessage = function startProcessesByMessage(reference) {
|
|
498
496
|
const {processes: bps, running} = this[kProcesses];
|
|
499
497
|
if (bps.length < 2) return;
|
|
500
498
|
|
|
@@ -523,7 +521,7 @@ proto._startProcessesByMessage = function startProcessesByMessage(reference) {
|
|
|
523
521
|
}
|
|
524
522
|
};
|
|
525
523
|
|
|
526
|
-
|
|
524
|
+
DefinitionExecution.prototype._onMessageOutbound = function onMessageOutbound(routingKey, message) {
|
|
527
525
|
const content = message.content;
|
|
528
526
|
const {target, source} = content;
|
|
529
527
|
|
|
@@ -553,7 +551,7 @@ proto._onMessageOutbound = function onMessageOutbound(routingKey, message) {
|
|
|
553
551
|
targetProcess.sendMessage(message);
|
|
554
552
|
};
|
|
555
553
|
|
|
556
|
-
|
|
554
|
+
DefinitionExecution.prototype._onCallActivity = function onCallActivity(routingKey, message) {
|
|
557
555
|
const content = message.content;
|
|
558
556
|
const {calledElement, id: fromId, executionId: fromExecutionId, name: fromName, parent: fromParent} = content;
|
|
559
557
|
if (!calledElement) return;
|
|
@@ -584,7 +582,7 @@ proto._onCallActivity = function onCallActivity(routingKey, message) {
|
|
|
584
582
|
targetProcess.run({inbound: [cloneContent(content)]});
|
|
585
583
|
};
|
|
586
584
|
|
|
587
|
-
|
|
585
|
+
DefinitionExecution.prototype._onCancelCallActivity = function onCancelCallActivity(routingKey, message) {
|
|
588
586
|
const {calledElement, id: fromId, executionId: fromExecutionId, parent: fromParent} = message.content;
|
|
589
587
|
if (!calledElement) return;
|
|
590
588
|
|
|
@@ -597,7 +595,7 @@ proto._onCancelCallActivity = function onCancelCallActivity(routingKey, message)
|
|
|
597
595
|
targetProcess.getApi().discard();
|
|
598
596
|
};
|
|
599
597
|
|
|
600
|
-
|
|
598
|
+
DefinitionExecution.prototype._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage) {
|
|
601
599
|
const content = executeMessage.content;
|
|
602
600
|
const messageType = executeMessage.properties.type;
|
|
603
601
|
const delegateMessage = executeMessage.content.message;
|
|
@@ -623,14 +621,14 @@ proto._onDelegateMessage = function onDelegateMessage(routingKey, executeMessage
|
|
|
623
621
|
}), {type: messageType});
|
|
624
622
|
};
|
|
625
623
|
|
|
626
|
-
|
|
624
|
+
DefinitionExecution.prototype._removeProcessByExecutionId = function removeProcessByExecutionId(processExecutionId) {
|
|
627
625
|
const running = this[kProcesses].running;
|
|
628
626
|
const idx = running.findIndex((p) => p.executionId === processExecutionId);
|
|
629
627
|
if (idx === -1) return;
|
|
630
628
|
return running.splice(idx, 1)[0];
|
|
631
629
|
};
|
|
632
630
|
|
|
633
|
-
|
|
631
|
+
DefinitionExecution.prototype._complete = function complete(completionType, content, options) {
|
|
634
632
|
this._deactivate();
|
|
635
633
|
const stateMessage = this[kExecuteMessage];
|
|
636
634
|
this._debug(`definition execution ${completionType} in ${Date.now() - stateMessage.properties.timestamp}ms`);
|
|
@@ -647,7 +645,7 @@ proto._complete = function complete(completionType, content, options) {
|
|
|
647
645
|
}, {type: completionType, mandatory: completionType === 'error', ...options});
|
|
648
646
|
};
|
|
649
647
|
|
|
650
|
-
|
|
648
|
+
DefinitionExecution.prototype._createMessage = function createMessage(content = {}) {
|
|
651
649
|
return {
|
|
652
650
|
id: this.id,
|
|
653
651
|
type: this.type,
|
|
@@ -657,7 +655,7 @@ proto._createMessage = function createMessage(content = {}) {
|
|
|
657
655
|
};
|
|
658
656
|
};
|
|
659
657
|
|
|
660
|
-
|
|
658
|
+
DefinitionExecution.prototype._getProcessApi = function getProcessApi(message) {
|
|
661
659
|
const content = message.content;
|
|
662
660
|
let api = this._getProcessApiByExecutionId(content.executionId, message);
|
|
663
661
|
if (api) return api;
|
|
@@ -675,12 +673,12 @@ proto._getProcessApi = function getProcessApi(message) {
|
|
|
675
673
|
}
|
|
676
674
|
};
|
|
677
675
|
|
|
678
|
-
|
|
676
|
+
DefinitionExecution.prototype._getProcessApiByExecutionId = function getProcessApiByExecutionId(parentExecutionId, message) {
|
|
679
677
|
const processInstance = this.getProcessByExecutionId(parentExecutionId);
|
|
680
678
|
if (!processInstance) return;
|
|
681
679
|
return processInstance.getApi(message);
|
|
682
680
|
};
|
|
683
681
|
|
|
684
|
-
|
|
682
|
+
DefinitionExecution.prototype._debug = function debug(logMessage) {
|
|
685
683
|
this[kParent].logger.debug(`<${this.executionId} (${this.id})> ${logMessage}`);
|
|
686
684
|
};
|
package/src/error/Errors.js
CHANGED