bpmn-elements 14.0.1 → 15.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/README.md +0 -4
- package/dist/Context.js +41 -35
- package/dist/Environment.js +1 -1
- package/dist/Expressions.js +1 -1
- package/dist/MessageFormatter.js +0 -1
- package/dist/Timers.js +5 -9
- package/dist/Tracker.js +15 -19
- package/dist/activity/Activity.js +17 -11
- package/dist/activity/ActivityExecution.js +43 -29
- package/dist/definition/Definition.js +1 -1
- package/dist/definition/DefinitionExecution.js +64 -55
- package/dist/eventDefinitions/EscalationEventDefinition.js +1 -1
- package/dist/eventDefinitions/LinkEventDefinition.js +1 -1
- package/dist/eventDefinitions/MessageEventDefinition.js +1 -1
- package/dist/eventDefinitions/SignalEventDefinition.js +3 -2
- package/dist/events/BoundaryEvent.js +11 -9
- package/dist/events/EndEvent.js +1 -1
- package/dist/events/IntermediateCatchEvent.js +1 -1
- package/dist/events/IntermediateThrowEvent.js +1 -1
- package/dist/events/StartEvent.js +1 -1
- package/dist/flows/SequenceFlow.js +1 -1
- package/dist/gateways/EventBasedGateway.js +1 -1
- package/dist/gateways/ExclusiveGateway.js +1 -1
- package/dist/gateways/InclusiveGateway.js +1 -1
- package/dist/gateways/ParallelGateway.js +1 -1
- package/dist/index.js +1 -1
- package/dist/io/InputOutputSpecification.js +1 -1
- package/dist/io/Properties.js +1 -1
- package/dist/process/Process.js +1 -1
- package/dist/process/ProcessExecution.js +67 -40
- package/dist/tasks/CallActivity.js +1 -1
- package/dist/tasks/LoopCharacteristics.js +2 -2
- package/dist/tasks/ReceiveTask.js +1 -1
- package/dist/tasks/ScriptTask.js +1 -1
- package/dist/tasks/ServiceImplementation.js +1 -1
- package/dist/tasks/ServiceTask.js +1 -1
- package/dist/tasks/SignalTask.js +1 -1
- package/dist/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/tasks/SubProcess.js +27 -28
- package/dist/tasks/Task.js +1 -1
- package/dist/tasks/Transaction.js +1 -1
- package/package.json +5 -3
- package/src/Context.js +51 -35
- package/src/MessageFormatter.js +0 -3
- package/src/Timers.js +5 -9
- package/src/Tracker.js +13 -17
- package/src/activity/Activity.js +5 -3
- package/src/activity/ActivityExecution.js +43 -26
- package/src/definition/DefinitionExecution.js +64 -54
- package/src/eventDefinitions/SignalEventDefinition.js +1 -1
- package/src/events/BoundaryEvent.js +10 -8
- package/src/process/ProcessExecution.js +70 -40
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/SubProcess.js +27 -27
- package/types/types.d.ts +1 -1
|
@@ -36,15 +36,15 @@ function ProcessExecution(parentActivity, context) {
|
|
|
36
36
|
this.environment = context.environment;
|
|
37
37
|
this.context = context;
|
|
38
38
|
this[kElements] = {
|
|
39
|
+
postponed: new Set(),
|
|
39
40
|
children: context.getActivities(id),
|
|
40
41
|
associations: context.getAssociations(id),
|
|
41
42
|
flows: context.getSequenceFlows(id),
|
|
42
43
|
outboundMessageFlows: context.getMessageFlows(id),
|
|
43
44
|
startActivities: [],
|
|
44
45
|
triggeredByEvent: [],
|
|
45
|
-
detachedActivities:
|
|
46
|
-
startSequences: {}
|
|
47
|
-
postponed: []
|
|
46
|
+
detachedActivities: new Set(),
|
|
47
|
+
startSequences: {}
|
|
48
48
|
};
|
|
49
49
|
const exchangeName = this._exchangeName = isSubProcess ? 'subprocess-execution' : 'execution';
|
|
50
50
|
broker.assertExchange(exchangeName, 'topic', {
|
|
@@ -82,7 +82,7 @@ Object.defineProperties(ProcessExecution.prototype, {
|
|
|
82
82
|
},
|
|
83
83
|
postponedCount: {
|
|
84
84
|
get() {
|
|
85
|
-
return this[kElements].postponed.
|
|
85
|
+
return this[kElements].postponed.size;
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
isRunning: {
|
|
@@ -130,8 +130,8 @@ ProcessExecution.prototype.resume = function resume() {
|
|
|
130
130
|
if (startActivities.length > 1) {
|
|
131
131
|
for (const a of startActivities) a.shake();
|
|
132
132
|
}
|
|
133
|
-
postponed.
|
|
134
|
-
detachedActivities.
|
|
133
|
+
postponed.clear();
|
|
134
|
+
detachedActivities.clear();
|
|
135
135
|
this[kActivityQ].consume(this[kMessageHandlers].onChildMessage, {
|
|
136
136
|
prefetch: 1000,
|
|
137
137
|
consumerTag: `_process-activity-${this.executionId}`
|
|
@@ -140,7 +140,7 @@ ProcessExecution.prototype.resume = function resume() {
|
|
|
140
140
|
const status = this.status;
|
|
141
141
|
if (status === 'init') return this._start();
|
|
142
142
|
const tracker = this[kTracker];
|
|
143
|
-
for (const msg of postponed
|
|
143
|
+
for (const msg of new Set(postponed)) {
|
|
144
144
|
const activity = this.getActivityById(msg.content.id);
|
|
145
145
|
if (!activity) continue;
|
|
146
146
|
if (msg.content.placeholder) continue;
|
|
@@ -153,7 +153,7 @@ ProcessExecution.prototype.resume = function resume() {
|
|
|
153
153
|
activity.resume();
|
|
154
154
|
}
|
|
155
155
|
if (this[kCompleted]) return;
|
|
156
|
-
if (!postponed.
|
|
156
|
+
if (!postponed.size && status === 'executing') return this._complete('completed');
|
|
157
157
|
};
|
|
158
158
|
ProcessExecution.prototype.getState = function getState() {
|
|
159
159
|
const {
|
|
@@ -272,7 +272,7 @@ ProcessExecution.prototype.stop = function stop() {
|
|
|
272
272
|
};
|
|
273
273
|
ProcessExecution.prototype.getPostponed = function getPostponed(filterFn) {
|
|
274
274
|
const result = [];
|
|
275
|
-
for (const msg of this[kElements].postponed
|
|
275
|
+
for (const msg of this[kElements].postponed) {
|
|
276
276
|
const api = this._getChildApi(msg);
|
|
277
277
|
if (!api) continue;
|
|
278
278
|
if (filterFn && !filterFn(api)) continue;
|
|
@@ -325,11 +325,12 @@ ProcessExecution.prototype.getApi = function getApi(message) {
|
|
|
325
325
|
const postponed = this[kElements].postponed;
|
|
326
326
|
const self = this;
|
|
327
327
|
api.getExecuting = function getExecuting() {
|
|
328
|
-
|
|
328
|
+
const result = [];
|
|
329
|
+
for (const msg of postponed) {
|
|
329
330
|
const childApi = self._getChildApi(msg);
|
|
330
331
|
if (childApi) result.push(childApi);
|
|
331
|
-
|
|
332
|
-
|
|
332
|
+
}
|
|
333
|
+
return result;
|
|
333
334
|
};
|
|
334
335
|
return api;
|
|
335
336
|
};
|
|
@@ -354,8 +355,8 @@ ProcessExecution.prototype._start = function start() {
|
|
|
354
355
|
for (const a of startActivities) a.init();
|
|
355
356
|
this[kStatus] = 'executing';
|
|
356
357
|
for (const a of startActivities) a.run();
|
|
357
|
-
postponed.
|
|
358
|
-
detachedActivities.
|
|
358
|
+
postponed.clear();
|
|
359
|
+
detachedActivities.clear();
|
|
359
360
|
this[kActivityQ].assertConsumer(this[kMessageHandlers].onChildMessage, {
|
|
360
361
|
prefetch: 1000,
|
|
361
362
|
consumerTag: `_process-activity-${this.executionId}`
|
|
@@ -546,9 +547,13 @@ ProcessExecution.prototype._onChildMessage = function onChildMessage(routingKey,
|
|
|
546
547
|
return this._onCancel(message);
|
|
547
548
|
case 'activity.error.caught':
|
|
548
549
|
{
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
550
|
+
let prevMsg;
|
|
551
|
+
for (const msg of this[kElements].postponed) {
|
|
552
|
+
if (msg.content.executionId === content.executionId) {
|
|
553
|
+
prevMsg = msg;
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
552
557
|
if (!prevMsg) return message.ack();
|
|
553
558
|
break;
|
|
554
559
|
}
|
|
@@ -560,7 +565,7 @@ ProcessExecution.prototype._onChildMessage = function onChildMessage(routingKey,
|
|
|
560
565
|
switch (routingKey) {
|
|
561
566
|
case 'activity.detach':
|
|
562
567
|
{
|
|
563
|
-
this[kElements].detachedActivities.
|
|
568
|
+
this[kElements].detachedActivities.add((0, _messageHelper.cloneMessage)(message));
|
|
564
569
|
break;
|
|
565
570
|
}
|
|
566
571
|
case 'activity.cancel':
|
|
@@ -581,10 +586,13 @@ ProcessExecution.prototype._onChildMessage = function onChildMessage(routingKey,
|
|
|
581
586
|
}
|
|
582
587
|
case 'activity.error':
|
|
583
588
|
{
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
589
|
+
let eventCaughtBy;
|
|
590
|
+
for (const msg of this[kElements].postponed) {
|
|
591
|
+
if (msg.fields.routingKey === 'activity.catch' && msg.content.source && msg.content.source.executionId === content.executionId) {
|
|
592
|
+
eventCaughtBy = msg;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
588
596
|
if (eventCaughtBy) {
|
|
589
597
|
this[kActivityQ].queueMessage({
|
|
590
598
|
routingKey: 'activity.error.caught'
|
|
@@ -603,23 +611,37 @@ ProcessExecution.prototype._onChildMessage = function onChildMessage(routingKey,
|
|
|
603
611
|
ProcessExecution.prototype._stateChangeMessage = function stateChangeMessage(message, postponeMessage) {
|
|
604
612
|
const previousMsg = this._popPostponed(message.content);
|
|
605
613
|
if (previousMsg) previousMsg.ack();
|
|
606
|
-
if (postponeMessage) this[kElements].postponed.
|
|
614
|
+
if (postponeMessage) this[kElements].postponed.add(message);
|
|
607
615
|
};
|
|
608
616
|
ProcessExecution.prototype._popPostponed = function popPostponed(byContent) {
|
|
609
617
|
const {
|
|
610
618
|
postponed,
|
|
611
619
|
detachedActivities
|
|
612
620
|
} = this[kElements];
|
|
613
|
-
const postponedIdx = postponed.findIndex(msg => {
|
|
614
|
-
if (msg.content.isSequenceFlow || msg.content.isAssociation) return msg.content.sequenceId === byContent.sequenceId;
|
|
615
|
-
return msg.content.executionId === byContent.executionId;
|
|
616
|
-
});
|
|
617
621
|
let postponedMsg;
|
|
618
|
-
if (
|
|
619
|
-
|
|
622
|
+
if (byContent.sequenceId) {
|
|
623
|
+
for (const msg of postponed) {
|
|
624
|
+
if (!msg.content.isSequenceFlow && !msg.content.isAssociation) continue;
|
|
625
|
+
if (msg.content.sequenceId === byContent.sequenceId) {
|
|
626
|
+
postponedMsg = msg;
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
} else {
|
|
631
|
+
for (const msg of postponed) {
|
|
632
|
+
if (msg.content.executionId === byContent.executionId) {
|
|
633
|
+
postponedMsg = msg;
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (postponedMsg) postponed.delete(postponedMsg);
|
|
639
|
+
for (const msg of detachedActivities) {
|
|
640
|
+
if (msg.content.executionId === byContent.executionId) {
|
|
641
|
+
detachedActivities.delete(msg);
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
620
644
|
}
|
|
621
|
-
const detachedIdx = detachedActivities.findIndex(msg => msg.content.executionId === byContent.executionId);
|
|
622
|
-
if (detachedIdx > -1) detachedActivities.splice(detachedIdx, 1);
|
|
623
645
|
return postponedMsg;
|
|
624
646
|
};
|
|
625
647
|
ProcessExecution.prototype._onChildCompleted = function onChildCompleted(message) {
|
|
@@ -635,15 +657,15 @@ ProcessExecution.prototype._onChildCompleted = function onChildCompleted(message
|
|
|
635
657
|
detachedActivities,
|
|
636
658
|
startActivities
|
|
637
659
|
} = this[kElements];
|
|
638
|
-
const postponedCount = postponed.
|
|
660
|
+
const postponedCount = postponed.size;
|
|
639
661
|
if (!postponedCount) {
|
|
640
662
|
this._debug(`left <${id}> (${type}), pending runs ${postponedCount}`);
|
|
641
663
|
message.ack();
|
|
642
664
|
return this._complete('completed');
|
|
643
665
|
}
|
|
644
666
|
message.ack();
|
|
645
|
-
this._debug(`left <${id}> (${type}), pending
|
|
646
|
-
if (postponedCount && postponedCount === detachedActivities.
|
|
667
|
+
this._debug(`left <${id}> (${type}), pending activities ${postponedCount}`);
|
|
668
|
+
if (postponedCount && postponedCount === detachedActivities.size) {
|
|
647
669
|
return this[kActivityQ].queueMessage({
|
|
648
670
|
routingKey: 'execution.discard.detached'
|
|
649
671
|
}, {
|
|
@@ -687,8 +709,10 @@ ProcessExecution.prototype._stopExecution = function stopExecution(message) {
|
|
|
687
709
|
};
|
|
688
710
|
ProcessExecution.prototype._onDiscard = function onDiscard() {
|
|
689
711
|
this._deactivate();
|
|
690
|
-
const
|
|
691
|
-
|
|
712
|
+
const postponed = this[kElements].postponed;
|
|
713
|
+
const running = new Set(postponed);
|
|
714
|
+
postponed.clear();
|
|
715
|
+
this._debug(`discard process execution (discard child executions ${running.size})`);
|
|
692
716
|
if (this.isSubProcess) {
|
|
693
717
|
this.stop();
|
|
694
718
|
} else {
|
|
@@ -700,10 +724,11 @@ ProcessExecution.prototype._onDiscard = function onDiscard() {
|
|
|
700
724
|
return this._complete('discard');
|
|
701
725
|
};
|
|
702
726
|
ProcessExecution.prototype._onCancel = function onCancel() {
|
|
703
|
-
const
|
|
727
|
+
const postponed = this[kElements].postponed;
|
|
728
|
+
const running = new Set(postponed);
|
|
704
729
|
const isTransaction = this.isTransaction;
|
|
705
730
|
if (isTransaction) {
|
|
706
|
-
this._debug(`cancel transaction execution (cancel child executions ${running.
|
|
731
|
+
this._debug(`cancel transaction execution (cancel child executions ${running.size})`);
|
|
707
732
|
this[kStatus] = 'cancel';
|
|
708
733
|
this.broker.publish('event', 'transaction.cancel', (0, _messageHelper.cloneMessage)(this[kExecuteMessage], {
|
|
709
734
|
state: 'cancel'
|
|
@@ -716,7 +741,7 @@ ProcessExecution.prototype._onCancel = function onCancel() {
|
|
|
716
741
|
}
|
|
717
742
|
}
|
|
718
743
|
} else {
|
|
719
|
-
this._debug(`cancel process execution (cancel child executions ${running.
|
|
744
|
+
this._debug(`cancel process execution (cancel child executions ${running.size})`);
|
|
720
745
|
for (const msg of running) {
|
|
721
746
|
this._getChildApi(msg).discard();
|
|
722
747
|
}
|
|
@@ -799,7 +824,9 @@ ProcessExecution.prototype._complete = function complete(completionType, content
|
|
|
799
824
|
ProcessExecution.prototype._terminate = function terminate(message) {
|
|
800
825
|
this[kStatus] = 'terminated';
|
|
801
826
|
this._debug('terminating process execution');
|
|
802
|
-
const
|
|
827
|
+
const postponed = this[kElements].postponed;
|
|
828
|
+
const running = new Set(postponed);
|
|
829
|
+
postponed.clear();
|
|
803
830
|
for (const flow of this.getSequenceFlows()) flow.stop();
|
|
804
831
|
for (const flow of this.getAssociations()) flow.stop();
|
|
805
832
|
for (const msg of running) {
|
|
@@ -8,7 +8,7 @@ exports.default = CallActivity;
|
|
|
8
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
9
9
|
var _Errors = require("../error/Errors.js");
|
|
10
10
|
var _messageHelper = require("../messageHelper.js");
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function CallActivity(activityDef, context) {
|
|
13
13
|
return new _Activity.default(CallActivityBehaviour, activityDef, context);
|
|
14
14
|
}
|
|
@@ -139,11 +139,11 @@ ParallelLoopCharacteristics.prototype.execute = function execute(executeMessage)
|
|
|
139
139
|
ParallelLoopCharacteristics.prototype._startBatch = function startBatch() {
|
|
140
140
|
const chr = this.characteristics;
|
|
141
141
|
const cardinality = chr.cardinality;
|
|
142
|
-
const batch =
|
|
142
|
+
const batch = new Set();
|
|
143
143
|
let startContent = chr.next(this.index);
|
|
144
144
|
do {
|
|
145
145
|
chr.debug(`start parallel iteration index ${this.index}`);
|
|
146
|
-
batch.
|
|
146
|
+
batch.add(startContent);
|
|
147
147
|
this.running++;
|
|
148
148
|
this.index++;
|
|
149
149
|
if (this.index >= cardinality || this.running >= chr.batchSize) {
|
|
@@ -7,7 +7,7 @@ exports.ReceiveTaskBehaviour = ReceiveTaskBehaviour;
|
|
|
7
7
|
exports.default = ReceiveTask;
|
|
8
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
9
9
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
function _interopRequireDefault(
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
const kCompleted = Symbol.for('completed');
|
|
12
12
|
const kExecuteMessage = Symbol.for('executeMessage');
|
|
13
13
|
const kReferenceElement = Symbol.for('referenceElement');
|
package/dist/tasks/ScriptTask.js
CHANGED
|
@@ -9,7 +9,7 @@ var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
|
9
9
|
var _ExecutionScope = _interopRequireDefault(require("../activity/ExecutionScope.js"));
|
|
10
10
|
var _Errors = require("../error/Errors.js");
|
|
11
11
|
var _messageHelper = require("../messageHelper.js");
|
|
12
|
-
function _interopRequireDefault(
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
function ScriptTask(activityDef, context) {
|
|
14
14
|
return new _Activity.default(ScriptTaskBehaviour, activityDef, context);
|
|
15
15
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = ServiceImplementation;
|
|
7
7
|
var _ExecutionScope = _interopRequireDefault(require("../activity/ExecutionScope.js"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
function ServiceImplementation(activity) {
|
|
10
10
|
this.type = `${activity.type}:implementation`;
|
|
11
11
|
this.implementation = activity.behaviour.implementation;
|
|
@@ -8,7 +8,7 @@ exports.default = ServiceTask;
|
|
|
8
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
9
9
|
var _Errors = require("../error/Errors.js");
|
|
10
10
|
var _messageHelper = require("../messageHelper.js");
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function ServiceTask(activityDef, context) {
|
|
13
13
|
return new _Activity.default(ServiceTaskBehaviour, activityDef, context);
|
|
14
14
|
}
|
package/dist/tasks/SignalTask.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = SignalTask;
|
|
|
8
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
9
9
|
var _Errors = require("../error/Errors.js");
|
|
10
10
|
var _messageHelper = require("../messageHelper.js");
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function SignalTask(activityDef, context) {
|
|
13
13
|
return new _Activity.default(SignalTaskBehaviour, activityDef, context);
|
|
14
14
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = StandardLoopCharacteristics;
|
|
7
7
|
var _LoopCharacteristics = _interopRequireDefault(require("./LoopCharacteristics.js"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
function StandardLoopCharacteristics(activity, loopCharacteristics) {
|
|
10
10
|
let {
|
|
11
11
|
behaviour
|
package/dist/tasks/SubProcess.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.default = SubProcess;
|
|
|
8
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
9
9
|
var _ProcessExecution = _interopRequireDefault(require("../process/ProcessExecution.js"));
|
|
10
10
|
var _messageHelper = require("../messageHelper.js");
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
const kExecutions = Symbol.for('executions');
|
|
13
13
|
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
14
14
|
function SubProcess(activityDef, context) {
|
|
@@ -54,7 +54,7 @@ function SubProcessBehaviour(activity, context) {
|
|
|
54
54
|
this.environment = activity.environment;
|
|
55
55
|
this.broker = activity.broker;
|
|
56
56
|
this.executionId = undefined;
|
|
57
|
-
this[kExecutions] =
|
|
57
|
+
this[kExecutions] = new Set();
|
|
58
58
|
this[kMessageHandlers] = {
|
|
59
59
|
onExecutionCompleted: this._onExecutionCompleted.bind(this)
|
|
60
60
|
};
|
|
@@ -62,12 +62,12 @@ function SubProcessBehaviour(activity, context) {
|
|
|
62
62
|
Object.defineProperties(SubProcessBehaviour.prototype, {
|
|
63
63
|
execution: {
|
|
64
64
|
get() {
|
|
65
|
-
return this[kExecutions][0];
|
|
65
|
+
return [...this[kExecutions]][0];
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
executions: {
|
|
69
69
|
get() {
|
|
70
|
-
return this[kExecutions]
|
|
70
|
+
return [...this[kExecutions]];
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
});
|
|
@@ -87,47 +87,45 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
|
|
|
87
87
|
return processExecution.execute(executeMessage);
|
|
88
88
|
};
|
|
89
89
|
SubProcessBehaviour.prototype.getState = function getState() {
|
|
90
|
+
const states = [];
|
|
91
|
+
for (const pe of this[kExecutions]) {
|
|
92
|
+
const state = pe.getState();
|
|
93
|
+
state.environment = pe.environment.getState();
|
|
94
|
+
states.push(state);
|
|
95
|
+
}
|
|
90
96
|
if (this.loopCharacteristics) {
|
|
91
97
|
return {
|
|
92
|
-
executions:
|
|
93
|
-
const state = pe.getState();
|
|
94
|
-
state.environment = pe.environment.getState();
|
|
95
|
-
return state;
|
|
96
|
-
})
|
|
98
|
+
executions: states
|
|
97
99
|
};
|
|
98
100
|
}
|
|
99
|
-
|
|
100
|
-
if (execution) {
|
|
101
|
-
const state = execution.getState();
|
|
102
|
-
state.environment = execution.environment.getState();
|
|
103
|
-
return state;
|
|
104
|
-
}
|
|
101
|
+
return states[0];
|
|
105
102
|
};
|
|
106
103
|
SubProcessBehaviour.prototype.recover = function recover(state) {
|
|
107
104
|
if (!state) return;
|
|
108
105
|
const executions = this[kExecutions];
|
|
109
106
|
const loopCharacteristics = this.loopCharacteristics;
|
|
110
107
|
if (loopCharacteristics && state.executions) {
|
|
111
|
-
executions.
|
|
108
|
+
executions.clear();
|
|
112
109
|
for (const se of state.executions) {
|
|
113
110
|
this.recover(se);
|
|
114
111
|
}
|
|
115
112
|
return;
|
|
116
113
|
}
|
|
117
114
|
if (!loopCharacteristics) {
|
|
118
|
-
executions.
|
|
115
|
+
executions.clear();
|
|
119
116
|
}
|
|
120
117
|
const subEnvironment = this.environment.clone().recover(state.environment);
|
|
121
118
|
const subContext = this.context.clone(subEnvironment, this.activity);
|
|
122
119
|
const execution = new _ProcessExecution.default(this.activity, subContext).recover(state);
|
|
123
|
-
executions.
|
|
120
|
+
executions.add(execution);
|
|
124
121
|
return execution;
|
|
125
122
|
};
|
|
126
123
|
SubProcessBehaviour.prototype.getPostponed = function getPostponed() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
124
|
+
let postponed = [];
|
|
125
|
+
for (const pe of this[kExecutions]) {
|
|
126
|
+
postponed = postponed.concat(pe.getPostponed());
|
|
127
|
+
}
|
|
128
|
+
return postponed;
|
|
131
129
|
};
|
|
132
130
|
SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(executeMessage) {
|
|
133
131
|
const content = executeMessage.content;
|
|
@@ -140,7 +138,7 @@ SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(execut
|
|
|
140
138
|
const subEnvironment = this.environment.clone();
|
|
141
139
|
const subContext = this.context.clone(subEnvironment, this.activity);
|
|
142
140
|
execution = new _ProcessExecution.default(this.activity, subContext);
|
|
143
|
-
this[kExecutions].
|
|
141
|
+
this[kExecutions].add(execution);
|
|
144
142
|
this._addListeners(executionId);
|
|
145
143
|
return execution;
|
|
146
144
|
};
|
|
@@ -180,10 +178,9 @@ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionComple
|
|
|
180
178
|
};
|
|
181
179
|
SubProcessBehaviour.prototype._completeExecution = function completeExecution(completeRoutingKey, content) {
|
|
182
180
|
if (this.loopCharacteristics) {
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
executions.splice(executionIdx, 1);
|
|
181
|
+
const execution = this._getExecutionById(content.executionId);
|
|
182
|
+
if (!execution) return;
|
|
183
|
+
this[kExecutions].delete(execution);
|
|
187
184
|
}
|
|
188
185
|
this.broker.publish('execution', completeRoutingKey, (0, _messageHelper.cloneContent)(content));
|
|
189
186
|
};
|
|
@@ -199,5 +196,7 @@ SubProcessBehaviour.prototype.getApi = function getApi(apiMessage) {
|
|
|
199
196
|
}
|
|
200
197
|
};
|
|
201
198
|
SubProcessBehaviour.prototype._getExecutionById = function getExecutionById(executionId) {
|
|
202
|
-
|
|
199
|
+
for (const pe of this[kExecutions]) {
|
|
200
|
+
if (pe.executionId === executionId) return pe;
|
|
201
|
+
}
|
|
203
202
|
};
|
package/dist/tasks/Task.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.TaskBehaviour = TaskBehaviour;
|
|
|
7
7
|
exports.default = Task;
|
|
8
8
|
var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
|
|
9
9
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
function _interopRequireDefault(
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
function Task(activityDef, context) {
|
|
12
12
|
return new _Activity.default(TaskBehaviour, activityDef, context);
|
|
13
13
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = Transaction;
|
|
7
7
|
var _SubProcess = _interopRequireDefault(require("./SubProcess.js"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
function Transaction(activityDef, context) {
|
|
10
10
|
const transaction = {
|
|
11
11
|
type: 'transaction',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-elements",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Executable workflow elements based on BPMN 2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"posttest": "npm run lint && npm run dist",
|
|
36
36
|
"lint": "eslint . --cache && prettier . --check --cache",
|
|
37
37
|
"prepack": "npm run dist",
|
|
38
|
+
"test:md": "texample ./docs/Examples.md,./docs/StartEvent.md,./docs/Extension.md",
|
|
38
39
|
"cov:html": "c8 -r html -r text mocha -R @bonniernews/hot-bev -p -t 3000",
|
|
39
40
|
"test:lcov": "c8 -r lcov mocha && npm run lint",
|
|
40
41
|
"dist": "babel src -d dist/"
|
|
@@ -83,10 +84,11 @@
|
|
|
83
84
|
"mocha-cakes-2": "^3.3.0",
|
|
84
85
|
"moddle-context-serializer": "^4.1.2",
|
|
85
86
|
"nock": "^13.5.3",
|
|
86
|
-
"prettier": "^3.2.5"
|
|
87
|
+
"prettier": "^3.2.5",
|
|
88
|
+
"texample": "^0.0.5"
|
|
87
89
|
},
|
|
88
90
|
"dependencies": {
|
|
89
91
|
"@0dep/piso": "^0.1.3",
|
|
90
|
-
"smqp": "^
|
|
92
|
+
"smqp": "^9.0.1"
|
|
91
93
|
}
|
|
92
94
|
}
|