bpmn-elements 17.3.0 → 18.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 +3 -1
- package/dist/Api.js +83 -0
- package/dist/Context.js +228 -22
- package/dist/Environment.js +111 -31
- package/dist/EventBroker.js +57 -1
- package/dist/Expressions.js +3 -4
- package/dist/MessageFormatter.js +29 -16
- package/dist/Timers.js +13 -9
- package/dist/Tracker.js +1 -0
- package/dist/activity/Activity.js +434 -233
- package/dist/activity/ActivityExecution.js +113 -40
- package/dist/activity/Dummy.js +6 -1
- package/dist/activity/Escalation.js +36 -24
- package/dist/activity/ExecutionScope.js +1 -1
- package/dist/activity/Message.js +36 -24
- package/dist/activity/Signal.js +36 -24
- package/dist/activity/outbound-evaluator.js +1 -1
- package/dist/condition.js +12 -6
- package/dist/constants.js +21 -0
- package/dist/definition/Definition.js +182 -64
- package/dist/definition/DefinitionExecution.js +195 -82
- package/dist/error/BpmnError.js +12 -1
- package/dist/error/Errors.js +50 -9
- package/dist/eventDefinitions/CancelEventDefinition.js +29 -11
- package/dist/eventDefinitions/CompensateEventDefinition.js +51 -31
- package/dist/eventDefinitions/ConditionalEventDefinition.js +21 -9
- package/dist/eventDefinitions/ErrorEventDefinition.js +46 -30
- package/dist/eventDefinitions/EscalationEventDefinition.js +44 -27
- package/dist/eventDefinitions/EventDefinitionExecution.js +30 -23
- package/dist/eventDefinitions/LinkEventDefinition.js +45 -120
- package/dist/eventDefinitions/MessageEventDefinition.js +44 -29
- package/dist/eventDefinitions/SignalEventDefinition.js +46 -31
- package/dist/eventDefinitions/TerminateEventDefinition.js +10 -1
- package/dist/eventDefinitions/TimerEventDefinition.js +57 -37
- package/dist/eventDefinitions/index.js +20 -21
- package/dist/events/BoundaryEvent.js +52 -40
- package/dist/events/EndEvent.js +22 -8
- package/dist/events/IntermediateCatchEvent.js +26 -8
- package/dist/events/IntermediateThrowEvent.js +24 -9
- package/dist/events/StartEvent.js +30 -14
- package/dist/events/index.js +10 -11
- package/dist/flows/Association.js +50 -7
- package/dist/flows/MessageFlow.js +49 -10
- package/dist/flows/SequenceFlow.js +93 -22
- package/dist/flows/index.js +6 -7
- package/dist/gateways/EventBasedGateway.js +29 -15
- package/dist/gateways/ExclusiveGateway.js +20 -5
- package/dist/gateways/InclusiveGateway.js +21 -5
- package/dist/gateways/ParallelGateway.js +253 -15
- package/dist/gateways/index.js +8 -9
- package/dist/getPropertyValue.js +1 -1
- package/dist/index.js +42 -43
- package/dist/io/BpmnIO.js +15 -1
- package/dist/io/EnvironmentDataObject.js +29 -1
- package/dist/io/EnvironmentDataStore.js +24 -1
- package/dist/io/EnvironmentDataStoreReference.js +24 -1
- package/dist/io/InputOutputSpecification.js +21 -11
- package/dist/io/Properties.js +28 -17
- package/dist/messageHelper.js +41 -4
- package/dist/process/Lane.js +15 -4
- package/dist/process/Process.js +174 -76
- package/dist/process/ProcessExecution.js +362 -177
- package/dist/shared.js +2 -0
- package/dist/tasks/CallActivity.js +19 -4
- package/dist/tasks/LoopCharacteristics.js +94 -9
- package/dist/tasks/ReceiveTask.js +36 -21
- package/dist/tasks/ScriptTask.js +22 -6
- package/dist/tasks/ServiceImplementation.js +7 -4
- package/dist/tasks/ServiceTask.js +19 -4
- package/dist/tasks/SignalTask.js +19 -4
- package/dist/tasks/StandardLoopCharacteristics.js +8 -4
- package/dist/tasks/SubProcess.js +44 -29
- package/dist/tasks/Task.js +19 -4
- package/dist/tasks/Transaction.js +8 -4
- package/dist/tasks/index.js +16 -18
- package/package.json +31 -13
- package/src/Api.js +70 -0
- package/src/Context.js +200 -19
- package/src/Environment.js +99 -30
- package/src/EventBroker.js +46 -1
- package/src/Expressions.js +2 -3
- package/src/MessageFormatter.js +24 -16
- package/src/Timers.js +12 -9
- package/src/Tracker.js +1 -0
- package/src/activity/Activity.js +372 -218
- package/src/activity/ActivityExecution.js +93 -42
- package/src/activity/Dummy.js +6 -1
- package/src/activity/Escalation.js +25 -18
- package/src/activity/ExecutionScope.js +1 -1
- package/src/activity/Message.js +25 -18
- package/src/activity/Signal.js +25 -18
- package/src/activity/outbound-evaluator.js +1 -1
- package/src/condition.js +11 -5
- package/src/constants.js +15 -0
- package/src/definition/Definition.js +157 -62
- package/src/definition/DefinitionExecution.js +161 -83
- package/src/error/BpmnError.js +11 -1
- package/src/error/Errors.js +44 -5
- package/src/eventDefinitions/CancelEventDefinition.js +27 -13
- package/src/eventDefinitions/CompensateEventDefinition.js +48 -32
- package/src/eventDefinitions/ConditionalEventDefinition.js +20 -10
- package/src/eventDefinitions/ErrorEventDefinition.js +44 -33
- package/src/eventDefinitions/EscalationEventDefinition.js +39 -26
- package/src/eventDefinitions/EventDefinitionExecution.js +30 -24
- package/src/eventDefinitions/LinkEventDefinition.js +34 -120
- package/src/eventDefinitions/MessageEventDefinition.js +42 -31
- package/src/eventDefinitions/SignalEventDefinition.js +43 -32
- package/src/eventDefinitions/TerminateEventDefinition.js +9 -1
- package/src/eventDefinitions/TimerEventDefinition.js +53 -35
- package/src/eventDefinitions/index.js +10 -23
- package/src/events/BoundaryEvent.js +50 -39
- package/src/events/EndEvent.js +19 -7
- package/src/events/IntermediateCatchEvent.js +24 -8
- package/src/events/IntermediateThrowEvent.js +24 -8
- package/src/events/StartEvent.js +25 -14
- package/src/events/index.js +5 -18
- package/src/flows/Association.js +43 -9
- package/src/flows/MessageFlow.js +41 -10
- package/src/flows/SequenceFlow.js +82 -19
- package/src/flows/index.js +3 -4
- package/src/gateways/EventBasedGateway.js +27 -15
- package/src/gateways/ExclusiveGateway.js +16 -3
- package/src/gateways/InclusiveGateway.js +16 -3
- package/src/gateways/ParallelGateway.js +301 -10
- package/src/gateways/index.js +4 -4
- package/src/getPropertyValue.js +1 -1
- package/src/index.js +19 -19
- package/src/io/BpmnIO.js +13 -1
- package/src/io/EnvironmentDataObject.js +26 -1
- package/src/io/EnvironmentDataStore.js +22 -1
- package/src/io/EnvironmentDataStoreReference.js +22 -1
- package/src/io/InputOutputSpecification.js +17 -8
- package/src/io/Properties.js +23 -13
- package/src/messageHelper.js +36 -4
- package/src/process/Lane.js +14 -4
- package/src/process/Process.js +154 -72
- package/src/process/ProcessExecution.js +326 -175
- package/src/shared.js +1 -0
- package/src/tasks/CallActivity.js +16 -2
- package/src/tasks/LoopCharacteristics.js +77 -11
- package/src/tasks/ReceiveTask.js +33 -22
- package/src/tasks/ScriptTask.js +17 -3
- package/src/tasks/ServiceImplementation.js +6 -3
- package/src/tasks/ServiceTask.js +16 -2
- package/src/tasks/SignalTask.js +16 -2
- package/src/tasks/StandardLoopCharacteristics.js +7 -3
- package/src/tasks/SubProcess.js +37 -23
- package/src/tasks/Task.js +16 -2
- package/src/tasks/Transaction.js +7 -3
- package/src/tasks/index.js +8 -9
- package/types/bundle-errors.d.ts +1 -0
- package/types/bundle.d.ts +97 -0
- package/types/index.d.ts +2614 -84
- package/types/interfaces.d.ts +636 -0
- package/types/types.d.ts +0 -765
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _getPropertyValue =
|
|
6
|
+
exports.EscalationEventDefinition = EscalationEventDefinition;
|
|
7
|
+
var _getPropertyValue = require("../getPropertyValue.js");
|
|
8
8
|
var _shared = require("../shared.js");
|
|
9
9
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
var _constants = require("../constants.js");
|
|
11
|
+
const K_REFERENCE = Symbol.for('reference');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Escalation event definition
|
|
15
|
+
* @param {import('#types').Activity} activity
|
|
16
|
+
* @param {import('moddle-context-serializer').EventDefinition} eventDefinition
|
|
17
|
+
*/
|
|
16
18
|
function EscalationEventDefinition(activity, eventDefinition) {
|
|
17
19
|
const {
|
|
18
20
|
id,
|
|
@@ -26,7 +28,9 @@ function EscalationEventDefinition(activity, eventDefinition) {
|
|
|
26
28
|
} = eventDefinition;
|
|
27
29
|
this.id = id;
|
|
28
30
|
this.type = type;
|
|
29
|
-
|
|
31
|
+
|
|
32
|
+
/** @type {import('#types').EventReference} */
|
|
33
|
+
this.reference = {
|
|
30
34
|
name: 'anonymous',
|
|
31
35
|
...behaviour.escalationRef,
|
|
32
36
|
referenceType: 'escalate'
|
|
@@ -35,44 +39,53 @@ function EscalationEventDefinition(activity, eventDefinition) {
|
|
|
35
39
|
this.activity = activity;
|
|
36
40
|
this.broker = broker;
|
|
37
41
|
this.logger = environment.Logger(type.toLowerCase());
|
|
38
|
-
const referenceElement = this[
|
|
42
|
+
const referenceElement = this[_constants.K_REFERENCE_ELEMENT] = this.reference.id && activity.getActivityById(this.reference.id);
|
|
39
43
|
if (!isThrowing) {
|
|
40
|
-
this[
|
|
44
|
+
this[_constants.K_COMPLETED] = false;
|
|
41
45
|
const referenceId = referenceElement ? referenceElement.id : 'anonymous';
|
|
42
|
-
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
|
|
43
|
-
this[
|
|
46
|
+
const messageQueueName = `${this.reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
|
|
47
|
+
this[_constants.K_MESSAGE_Q] = broker.assertQueue(messageQueueName, {
|
|
44
48
|
autoDelete: false,
|
|
45
49
|
durable: true
|
|
46
50
|
});
|
|
47
|
-
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
|
|
51
|
+
broker.bindQueue(messageQueueName, 'api', `*.${this.reference.referenceType}.#`, {
|
|
48
52
|
durable: true,
|
|
49
53
|
priority: 400
|
|
50
54
|
});
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
Object.defineProperty(EscalationEventDefinition.prototype, 'executionId', {
|
|
58
|
+
/** @returns {string} */
|
|
54
59
|
get() {
|
|
55
|
-
return this[
|
|
60
|
+
return this[_constants.K_EXECUTE_MESSAGE]?.content.executionId;
|
|
56
61
|
}
|
|
57
62
|
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
66
|
+
*/
|
|
58
67
|
EscalationEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
59
68
|
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
60
69
|
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
73
|
+
*/
|
|
61
74
|
EscalationEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
|
|
62
|
-
this[
|
|
63
|
-
this[
|
|
75
|
+
this[_constants.K_EXECUTE_MESSAGE] = executeMessage;
|
|
76
|
+
this[_constants.K_COMPLETED] = false;
|
|
64
77
|
const executeContent = executeMessage.content;
|
|
65
78
|
const {
|
|
66
79
|
executionId,
|
|
67
80
|
parent
|
|
68
81
|
} = executeContent;
|
|
69
|
-
const info = this[
|
|
82
|
+
const info = this[K_REFERENCE] = this._getReferenceInfo(executeMessage);
|
|
70
83
|
const broker = this.broker;
|
|
71
|
-
this[
|
|
84
|
+
this[_constants.K_MESSAGE_Q].consume(this._onCatchMessage.bind(this), {
|
|
72
85
|
noAck: true,
|
|
73
86
|
consumerTag: `_onescalate-${executionId}`
|
|
74
87
|
});
|
|
75
|
-
if (this[
|
|
88
|
+
if (this[_constants.K_COMPLETED]) return;
|
|
76
89
|
broker.subscribeTmp('api', `activity.#.${executionId}`, this._onApiMessage.bind(this), {
|
|
77
90
|
noAck: true,
|
|
78
91
|
consumerTag: `_api-${executionId}`
|
|
@@ -88,6 +101,10 @@ EscalationEventDefinition.prototype.executeCatch = function executeCatch(execute
|
|
|
88
101
|
waitContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
89
102
|
broker.publish('event', 'activity.wait', waitContent);
|
|
90
103
|
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
107
|
+
*/
|
|
91
108
|
EscalationEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
92
109
|
const executeContent = executeMessage.content;
|
|
93
110
|
const {
|
|
@@ -110,13 +127,13 @@ EscalationEventDefinition.prototype.executeThrow = function executeThrow(execute
|
|
|
110
127
|
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
|
|
111
128
|
};
|
|
112
129
|
EscalationEventDefinition.prototype._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
113
|
-
const info = this[
|
|
114
|
-
if ((0, _getPropertyValue.
|
|
130
|
+
const info = this[K_REFERENCE];
|
|
131
|
+
if ((0, _getPropertyValue.getPropertyValue)(message, 'content.message.id') !== info.message.id) return;
|
|
115
132
|
const output = message.content.message;
|
|
116
|
-
this[
|
|
133
|
+
this[_constants.K_COMPLETED] = true;
|
|
117
134
|
this._stop();
|
|
118
135
|
this._debug(`caught ${info.description}`);
|
|
119
|
-
const executeContent = this[
|
|
136
|
+
const executeContent = this[_constants.K_EXECUTE_MESSAGE].content;
|
|
120
137
|
const {
|
|
121
138
|
parent,
|
|
122
139
|
...content
|
|
@@ -145,9 +162,9 @@ EscalationEventDefinition.prototype._onApiMessage = function onApiMessage(routin
|
|
|
145
162
|
}
|
|
146
163
|
case 'discard':
|
|
147
164
|
{
|
|
148
|
-
this[
|
|
165
|
+
this[_constants.K_COMPLETED] = true;
|
|
149
166
|
this._stop();
|
|
150
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
167
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[_constants.K_EXECUTE_MESSAGE].content));
|
|
151
168
|
}
|
|
152
169
|
case 'stop':
|
|
153
170
|
{
|
|
@@ -163,7 +180,7 @@ EscalationEventDefinition.prototype._stop = function stop() {
|
|
|
163
180
|
broker.cancel(`_onescalate-${executionId}`);
|
|
164
181
|
};
|
|
165
182
|
EscalationEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(message) {
|
|
166
|
-
const referenceElement = this[
|
|
183
|
+
const referenceElement = this[_constants.K_REFERENCE_ELEMENT];
|
|
167
184
|
if (!referenceElement) {
|
|
168
185
|
return {
|
|
169
186
|
message: {
|
|
@@ -3,39 +3,46 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.EventDefinitionExecution = EventDefinitionExecution;
|
|
7
7
|
var _messageHelper = require("../messageHelper.js");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var _constants = require("../constants.js");
|
|
9
|
+
/**
|
|
10
|
+
* Event definition execution orchestrator. Drives a sequence of event definitions for the
|
|
11
|
+
* activity and publishes the completed routing key when the last definition completes.
|
|
12
|
+
* @param {import('#types').Activity} activity
|
|
13
|
+
* @param {import('#types').EventDefinition[]} eventDefinitions
|
|
14
|
+
* @param {string} [completedRoutingKey] Routing key to publish on completion, defaults to `execute.completed`
|
|
15
|
+
*/
|
|
11
16
|
function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKey = 'execute.completed') {
|
|
12
17
|
this.id = activity.id;
|
|
13
18
|
this.activity = activity;
|
|
14
19
|
this.broker = activity.broker;
|
|
15
20
|
this.eventDefinitions = eventDefinitions;
|
|
16
21
|
this.completedRoutingKey = completedRoutingKey;
|
|
17
|
-
this[
|
|
18
|
-
this[
|
|
19
|
-
this[
|
|
22
|
+
this[_constants.K_COMPLETED] = false;
|
|
23
|
+
this[_constants.K_STOPPED] = false;
|
|
24
|
+
this[_constants.K_EXECUTE_MESSAGE] = null;
|
|
20
25
|
}
|
|
21
|
-
Object.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return this[kCompleted];
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
stopped: {
|
|
28
|
-
get() {
|
|
29
|
-
return this[kStopped];
|
|
30
|
-
}
|
|
26
|
+
Object.defineProperty(EventDefinitionExecution.prototype, 'completed', {
|
|
27
|
+
get() {
|
|
28
|
+
return this[_constants.K_COMPLETED];
|
|
31
29
|
}
|
|
32
30
|
});
|
|
31
|
+
Object.defineProperty(EventDefinitionExecution.prototype, 'stopped', {
|
|
32
|
+
get() {
|
|
33
|
+
return this[_constants.K_STOPPED];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
39
|
+
*/
|
|
33
40
|
EventDefinitionExecution.prototype.execute = function execute(executeMessage) {
|
|
34
41
|
const content = executeMessage.content;
|
|
35
42
|
if (content.isDefinitionScope) return this._executeDefinition(executeMessage);
|
|
36
43
|
if (!content.isRootScope) return;
|
|
37
44
|
const broker = this.broker;
|
|
38
|
-
this[
|
|
45
|
+
this[_constants.K_EXECUTE_MESSAGE] = executeMessage;
|
|
39
46
|
const executionId = content.executionId;
|
|
40
47
|
broker.subscribeTmp('execution', 'execute.#', this._onExecuteMessage.bind(this), {
|
|
41
48
|
noAck: true,
|
|
@@ -54,8 +61,8 @@ EventDefinitionExecution.prototype.execute = function execute(executeMessage) {
|
|
|
54
61
|
const parent = (0, _messageHelper.unshiftParent)(content.parent, content);
|
|
55
62
|
const eventDefinitions = this.eventDefinitions;
|
|
56
63
|
for (let index = 0; index < eventDefinitions.length; ++index) {
|
|
57
|
-
if (this[
|
|
58
|
-
if (this[
|
|
64
|
+
if (this[_constants.K_COMPLETED]) break;
|
|
65
|
+
if (this[_constants.K_STOPPED]) break;
|
|
59
66
|
const ed = eventDefinitions[index];
|
|
60
67
|
const edExecutionId = `${executionId}_${index}`;
|
|
61
68
|
this._debug(executionId, `start event definition ${ed.type}, index ${index}`);
|
|
@@ -109,10 +116,10 @@ EventDefinitionExecution.prototype._complete = function complete(message) {
|
|
|
109
116
|
index,
|
|
110
117
|
parent
|
|
111
118
|
} = message.content;
|
|
112
|
-
this[
|
|
119
|
+
this[_constants.K_COMPLETED] = true;
|
|
113
120
|
this._debug(executionId, `event definition ${type} completed, index ${index}`);
|
|
114
121
|
const completeContent = (0, _messageHelper.cloneContent)(message.content, {
|
|
115
|
-
executionId: this[
|
|
122
|
+
executionId: this[_constants.K_EXECUTE_MESSAGE].content.executionId,
|
|
116
123
|
isRootScope: true,
|
|
117
124
|
isDefinitionScope: undefined
|
|
118
125
|
});
|
|
@@ -132,7 +139,7 @@ EventDefinitionExecution.prototype._executeDefinition = function executeDefiniti
|
|
|
132
139
|
ed.execute(message);
|
|
133
140
|
};
|
|
134
141
|
EventDefinitionExecution.prototype._stop = function stop() {
|
|
135
|
-
this[
|
|
142
|
+
this[_constants.K_STOPPED] = true;
|
|
136
143
|
this.broker.cancel('_eventdefinition-execution-execute-tag');
|
|
137
144
|
this.broker.cancel('_eventdefinition-execution-api-tag');
|
|
138
145
|
};
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue.js"));
|
|
8
|
-
var _shared = require("../shared.js");
|
|
6
|
+
exports.LinkEventDefinition = LinkEventDefinition;
|
|
9
7
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
var _constants = require("../constants.js");
|
|
9
|
+
/**
|
|
10
|
+
* Link event definition
|
|
11
|
+
* @param {import('#types').Activity} activity
|
|
12
|
+
* @param {import('moddle-context-serializer').EventDefinition} eventDefinition
|
|
13
|
+
*/
|
|
14
14
|
function LinkEventDefinition(activity, eventDefinition) {
|
|
15
15
|
const {
|
|
16
16
|
id,
|
|
@@ -24,7 +24,10 @@ function LinkEventDefinition(activity, eventDefinition) {
|
|
|
24
24
|
} = eventDefinition;
|
|
25
25
|
this.id = id;
|
|
26
26
|
this.type = type;
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
/** @type {import('#types').EventReference} */
|
|
29
|
+
this.reference = {
|
|
30
|
+
id: behaviour.name,
|
|
28
31
|
linkName: behaviour.name,
|
|
29
32
|
referenceType: 'link'
|
|
30
33
|
};
|
|
@@ -32,65 +35,59 @@ function LinkEventDefinition(activity, eventDefinition) {
|
|
|
32
35
|
this.activity = activity;
|
|
33
36
|
this.broker = broker;
|
|
34
37
|
this.logger = environment.Logger(type.toLowerCase());
|
|
35
|
-
this[kCompleted] = false;
|
|
36
|
-
if (!isThrowing) {
|
|
37
|
-
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(reference.linkName)}-q`;
|
|
38
|
-
this[kMessageQ] = broker.assertQueue(messageQueueName, {
|
|
39
|
-
autoDelete: false,
|
|
40
|
-
durable: true
|
|
41
|
-
});
|
|
42
|
-
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
|
|
43
|
-
durable: true
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
broker.subscribeTmp('event', 'activity.discard', this._onDiscard.bind(this), {
|
|
47
|
-
noAck: true,
|
|
48
|
-
consumerTag: '_link-parent-discard'
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
38
|
}
|
|
52
39
|
Object.defineProperty(LinkEventDefinition.prototype, 'executionId', {
|
|
40
|
+
/** @returns {string} */
|
|
53
41
|
get() {
|
|
54
|
-
return this[
|
|
42
|
+
return this[_constants.K_EXECUTE_MESSAGE]?.content.executionId;
|
|
55
43
|
}
|
|
56
44
|
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
48
|
+
*/
|
|
57
49
|
LinkEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
58
50
|
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
59
51
|
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
55
|
+
*/
|
|
60
56
|
LinkEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
|
|
61
|
-
this[
|
|
62
|
-
this[kCompleted] = false;
|
|
57
|
+
this[_constants.K_EXECUTE_MESSAGE] = executeMessage;
|
|
63
58
|
const executeContent = executeMessage.content;
|
|
64
59
|
const {
|
|
65
60
|
executionId,
|
|
66
61
|
parent
|
|
67
62
|
} = executeContent;
|
|
68
63
|
const parentExecutionId = parent.executionId;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
if (this[kCompleted]) return;
|
|
64
|
+
const linkMessage = executeContent.message ?? executeContent.input ?? {
|
|
65
|
+
...this.reference
|
|
66
|
+
};
|
|
67
|
+
this.logger.debug(`<${executionId} (${this.activity.id})> caught link ${this.reference.linkName}`);
|
|
74
68
|
const broker = this.broker;
|
|
75
|
-
const
|
|
76
|
-
broker.subscribeTmp('api', `activity.stop.${parentExecutionId}`, onApiMessage, {
|
|
77
|
-
noAck: true,
|
|
78
|
-
consumerTag: `_api-parent-${executionId}`
|
|
79
|
-
});
|
|
80
|
-
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
81
|
-
noAck: true,
|
|
82
|
-
consumerTag: `_api-${executionId}`
|
|
83
|
-
});
|
|
84
|
-
this._debug(`expect link ${this.reference.linkName}`);
|
|
85
|
-
const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
86
|
-
executionId: parentExecutionId,
|
|
69
|
+
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
87
70
|
link: {
|
|
88
71
|
...this.reference
|
|
89
|
-
}
|
|
72
|
+
},
|
|
73
|
+
message: {
|
|
74
|
+
...linkMessage
|
|
75
|
+
},
|
|
76
|
+
executionId: parentExecutionId
|
|
77
|
+
});
|
|
78
|
+
catchContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
79
|
+
broker.publish('event', 'activity.catch', catchContent, {
|
|
80
|
+
type: 'catch'
|
|
90
81
|
});
|
|
91
|
-
|
|
92
|
-
|
|
82
|
+
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
83
|
+
output: linkMessage,
|
|
84
|
+
state: 'catch'
|
|
85
|
+
}));
|
|
93
86
|
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
90
|
+
*/
|
|
94
91
|
LinkEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
95
92
|
const executeContent = executeMessage.content;
|
|
96
93
|
const {
|
|
@@ -109,79 +106,7 @@ LinkEventDefinition.prototype.executeThrow = function executeThrow(executeMessag
|
|
|
109
106
|
});
|
|
110
107
|
linkContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
111
108
|
broker.publish('event', 'activity.link', linkContent, {
|
|
112
|
-
type: 'link'
|
|
113
|
-
delegate: true
|
|
109
|
+
type: 'link'
|
|
114
110
|
});
|
|
115
111
|
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
|
|
116
|
-
};
|
|
117
|
-
LinkEventDefinition.prototype._onCatchLink = function onCatchLink(routingKey, message) {
|
|
118
|
-
if ((0, _getPropertyValue.default)(message, 'content.message.linkName') !== this.reference.linkName) return;
|
|
119
|
-
if (message.content.state === 'discard') return this._discard();
|
|
120
|
-
return this._complete('caught', message.content.message);
|
|
121
|
-
};
|
|
122
|
-
LinkEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
123
|
-
const messageType = message.properties.type;
|
|
124
|
-
switch (messageType) {
|
|
125
|
-
case 'discard':
|
|
126
|
-
{
|
|
127
|
-
return this._discard();
|
|
128
|
-
}
|
|
129
|
-
case 'stop':
|
|
130
|
-
{
|
|
131
|
-
this._stop();
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
LinkEventDefinition.prototype._complete = function complete(verb, output) {
|
|
137
|
-
this[kCompleted] = true;
|
|
138
|
-
this._stop();
|
|
139
|
-
this._debug(`${verb} link ${this.reference.linkName}`);
|
|
140
|
-
const executeContent = this[kExecuteMessage].content;
|
|
141
|
-
const parent = executeContent.parent;
|
|
142
|
-
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
143
|
-
link: {
|
|
144
|
-
...this.reference
|
|
145
|
-
},
|
|
146
|
-
message: {
|
|
147
|
-
...output
|
|
148
|
-
},
|
|
149
|
-
executionId: parent.executionId
|
|
150
|
-
});
|
|
151
|
-
catchContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
152
|
-
const broker = this.broker;
|
|
153
|
-
broker.publish('event', 'activity.catch', catchContent, {
|
|
154
|
-
type: 'catch'
|
|
155
|
-
});
|
|
156
|
-
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
157
|
-
output,
|
|
158
|
-
state: 'catch'
|
|
159
|
-
}));
|
|
160
|
-
};
|
|
161
|
-
LinkEventDefinition.prototype._discard = function discard() {
|
|
162
|
-
this[kCompleted] = true;
|
|
163
|
-
this._stop();
|
|
164
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
165
|
-
};
|
|
166
|
-
LinkEventDefinition.prototype._stop = function stop() {
|
|
167
|
-
const broker = this.broker,
|
|
168
|
-
executionId = this.executionId;
|
|
169
|
-
broker.cancel(`_api-link-${executionId}`);
|
|
170
|
-
broker.cancel(`_api-parent-${executionId}`);
|
|
171
|
-
broker.cancel(`_api-${executionId}`);
|
|
172
|
-
this[kMessageQ].purge();
|
|
173
|
-
};
|
|
174
|
-
LinkEventDefinition.prototype._onDiscard = function onDiscard(_, message) {
|
|
175
|
-
this.broker.publish('event', 'activity.link.discard', (0, _messageHelper.cloneContent)(message.content, {
|
|
176
|
-
message: {
|
|
177
|
-
...this.reference
|
|
178
|
-
},
|
|
179
|
-
state: 'discard'
|
|
180
|
-
}), {
|
|
181
|
-
type: 'link',
|
|
182
|
-
delegate: true
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
LinkEventDefinition.prototype._debug = function debug(msg) {
|
|
186
|
-
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
187
112
|
};
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _getPropertyValue =
|
|
6
|
+
exports.MessageEventDefinition = MessageEventDefinition;
|
|
7
|
+
var _getPropertyValue = require("../getPropertyValue.js");
|
|
8
8
|
var _shared = require("../shared.js");
|
|
9
9
|
var _messageHelper = require("../messageHelper.js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
var _constants = require("../constants.js");
|
|
11
|
+
/**
|
|
12
|
+
* Message event definition
|
|
13
|
+
* @param {import('#types').Activity} activity
|
|
14
|
+
* @param {import('moddle-context-serializer').EventDefinition} eventDefinition
|
|
15
|
+
*/
|
|
16
16
|
function MessageEventDefinition(activity, eventDefinition) {
|
|
17
17
|
const {
|
|
18
18
|
id,
|
|
@@ -26,7 +26,9 @@ function MessageEventDefinition(activity, eventDefinition) {
|
|
|
26
26
|
} = eventDefinition;
|
|
27
27
|
this.id = id;
|
|
28
28
|
this.type = type;
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
/** @type {import('#types').EventReference} */
|
|
31
|
+
this.reference = {
|
|
30
32
|
name: 'anonymous',
|
|
31
33
|
...behaviour.messageRef,
|
|
32
34
|
referenceType: 'message'
|
|
@@ -35,46 +37,55 @@ function MessageEventDefinition(activity, eventDefinition) {
|
|
|
35
37
|
this.activity = activity;
|
|
36
38
|
this.broker = broker;
|
|
37
39
|
this.logger = environment.Logger(type.toLowerCase());
|
|
38
|
-
const referenceElement = this[
|
|
40
|
+
const referenceElement = this[_constants.K_REFERENCE_ELEMENT] = this.reference.id && activity.getActivityById(this.reference.id);
|
|
39
41
|
if (!isThrowing) {
|
|
40
|
-
this[
|
|
42
|
+
this[_constants.K_COMPLETED] = false;
|
|
41
43
|
const referenceId = referenceElement ? referenceElement.id : 'anonymous';
|
|
42
|
-
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
|
|
43
|
-
this[
|
|
44
|
+
const messageQueueName = `${this.reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
|
|
45
|
+
this[_constants.K_MESSAGE_Q] = broker.assertQueue(messageQueueName, {
|
|
44
46
|
autoDelete: false,
|
|
45
47
|
durable: true
|
|
46
48
|
});
|
|
47
|
-
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
|
|
49
|
+
broker.bindQueue(messageQueueName, 'api', `*.${this.reference.referenceType}.#`, {
|
|
48
50
|
durable: true
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
Object.defineProperty(MessageEventDefinition.prototype, 'executionId', {
|
|
55
|
+
/** @returns {string} */
|
|
53
56
|
get() {
|
|
54
|
-
return this[
|
|
57
|
+
return this[_constants.K_EXECUTE_MESSAGE]?.content.executionId;
|
|
55
58
|
}
|
|
56
59
|
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
63
|
+
*/
|
|
57
64
|
MessageEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
58
65
|
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
59
66
|
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
70
|
+
*/
|
|
60
71
|
MessageEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
|
|
61
|
-
this[
|
|
62
|
-
this[
|
|
72
|
+
this[_constants.K_EXECUTE_MESSAGE] = executeMessage;
|
|
73
|
+
this[_constants.K_COMPLETED] = false;
|
|
63
74
|
const executeContent = executeMessage.content;
|
|
64
75
|
const {
|
|
65
76
|
executionId,
|
|
66
77
|
parent
|
|
67
78
|
} = executeContent;
|
|
68
79
|
const parentExecutionId = parent?.executionId;
|
|
69
|
-
const info = this[
|
|
80
|
+
const info = this[_constants.K_REFERENCE_INFO] = this._getReferenceInfo(executeMessage);
|
|
70
81
|
this._debug(`expect ${info.description}`);
|
|
71
82
|
const broker = this.broker;
|
|
72
83
|
const onCatchMessage = this._onCatchMessage.bind(this);
|
|
73
|
-
this[
|
|
84
|
+
this[_constants.K_MESSAGE_Q].consume(onCatchMessage, {
|
|
74
85
|
noAck: true,
|
|
75
86
|
consumerTag: `_api-message-${executionId}`
|
|
76
87
|
});
|
|
77
|
-
if (this[
|
|
88
|
+
if (this[_constants.K_COMPLETED]) return;
|
|
78
89
|
const onApiMessage = this._onApiMessage.bind(this);
|
|
79
90
|
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
80
91
|
noAck: true,
|
|
@@ -99,6 +110,10 @@ MessageEventDefinition.prototype.executeCatch = function executeCatch(executeMes
|
|
|
99
110
|
waitContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
100
111
|
broker.publish('event', 'activity.wait', waitContent);
|
|
101
112
|
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {import('#types').ElementBrokerMessage} executeMessage
|
|
116
|
+
*/
|
|
102
117
|
MessageEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
|
|
103
118
|
const executeContent = executeMessage.content;
|
|
104
119
|
const {
|
|
@@ -124,12 +139,12 @@ MessageEventDefinition.prototype.executeThrow = function executeThrow(executeMes
|
|
|
124
139
|
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
|
|
125
140
|
};
|
|
126
141
|
MessageEventDefinition.prototype._onCatchMessage = function onCatchMessage(routingKey, message) {
|
|
127
|
-
if ((0, _getPropertyValue.
|
|
142
|
+
if ((0, _getPropertyValue.getPropertyValue)(message, 'content.message.id') !== this[_constants.K_REFERENCE_INFO].message.id) return;
|
|
128
143
|
const {
|
|
129
144
|
type,
|
|
130
145
|
correlationId
|
|
131
146
|
} = message.properties;
|
|
132
|
-
this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[
|
|
147
|
+
this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[_constants.K_EXECUTE_MESSAGE].content, {
|
|
133
148
|
message: {
|
|
134
149
|
...message.content.message
|
|
135
150
|
}
|
|
@@ -156,9 +171,9 @@ MessageEventDefinition.prototype._onApiMessage = function onApiMessage(routingKe
|
|
|
156
171
|
}
|
|
157
172
|
case 'discard':
|
|
158
173
|
{
|
|
159
|
-
this[
|
|
174
|
+
this[_constants.K_COMPLETED] = true;
|
|
160
175
|
this._stop();
|
|
161
|
-
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[
|
|
176
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[_constants.K_EXECUTE_MESSAGE].content), {
|
|
162
177
|
correlationId
|
|
163
178
|
});
|
|
164
179
|
}
|
|
@@ -169,11 +184,11 @@ MessageEventDefinition.prototype._onApiMessage = function onApiMessage(routingKe
|
|
|
169
184
|
}
|
|
170
185
|
};
|
|
171
186
|
MessageEventDefinition.prototype._complete = function complete(verb, output, options) {
|
|
172
|
-
this[
|
|
187
|
+
this[_constants.K_COMPLETED] = true;
|
|
173
188
|
this._stop();
|
|
174
|
-
this._debug(`${verb} ${this[
|
|
189
|
+
this._debug(`${verb} ${this[_constants.K_REFERENCE_INFO].description}`);
|
|
175
190
|
const broker = this.broker;
|
|
176
|
-
const executeContent = this[
|
|
191
|
+
const executeContent = this[_constants.K_EXECUTE_MESSAGE].content;
|
|
177
192
|
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
178
193
|
message: {
|
|
179
194
|
...output
|
|
@@ -196,10 +211,10 @@ MessageEventDefinition.prototype._stop = function stop() {
|
|
|
196
211
|
broker.cancel(`_api-${executionId}`);
|
|
197
212
|
broker.cancel(`_api-parent-${executionId}`);
|
|
198
213
|
broker.cancel(`_api-delegated-${executionId}`);
|
|
199
|
-
this[
|
|
214
|
+
this[_constants.K_MESSAGE_Q].purge();
|
|
200
215
|
};
|
|
201
216
|
MessageEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(message) {
|
|
202
|
-
const referenceElement = this[
|
|
217
|
+
const referenceElement = this[_constants.K_REFERENCE_ELEMENT];
|
|
203
218
|
if (!referenceElement) {
|
|
204
219
|
return {
|
|
205
220
|
message: {
|