bpmn-elements 6.0.0 → 8.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 +335 -0
- package/README.md +3 -0
- package/dist/index.js +52 -44
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +176 -172
- package/dist/src/Environment.js +110 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/activity/Activity.js +1106 -916
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +710 -408
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -100
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +173 -182
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +17 -14
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +33 -29
- package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +117 -124
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +439 -362
- package/dist/src/process/ProcessExecution.js +748 -646
- package/dist/src/shared.js +2 -2
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +193 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +2 -0
- package/package.json +15 -15
- package/src/Api.js +65 -59
- package/src/Context.js +145 -140
- package/src/Environment.js +116 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/activity/Activity.js +915 -775
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +437 -401
- package/src/definition/DefinitionExecution.js +598 -340
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +159 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -112
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +146 -160
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -15
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +29 -18
- package/src/io/EnvironmentDataStoreReference.js +31 -20
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +95 -97
- package/src/process/Process.js +378 -333
- package/src/process/ProcessExecution.js +603 -553
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
|
@@ -3,186 +3,219 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = CompensateEventDefinition;
|
|
7
7
|
|
|
8
8
|
var _shared = require("../shared");
|
|
9
9
|
|
|
10
10
|
var _messageHelper = require("../messageHelper");
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const kCompleted = Symbol.for('completed');
|
|
13
|
+
const kExecuteMessage = Symbol.for('executeMessage');
|
|
14
|
+
const kMessageQ = Symbol.for('messageQ');
|
|
15
|
+
const kCompensateQ = Symbol.for('compensateQ');
|
|
16
|
+
const kAssociations = Symbol.for('associations');
|
|
17
|
+
|
|
18
|
+
function CompensateEventDefinition(activity, eventDefinition, context) {
|
|
13
19
|
const {
|
|
14
20
|
id,
|
|
15
21
|
broker,
|
|
16
22
|
environment,
|
|
17
23
|
isThrowing
|
|
18
24
|
} = activity;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
debug
|
|
24
|
-
} = environment.Logger(type.toLowerCase());
|
|
25
|
-
const compensationQueueName = `compensate-${(0, _shared.brokerSafeId)(id)}-q`;
|
|
26
|
-
const associations = context.getOutboundAssociations(id) || [];
|
|
27
|
-
if (!isThrowing) setupCatch();
|
|
28
|
-
const source = {
|
|
29
|
-
id,
|
|
30
|
-
type,
|
|
31
|
-
reference: {
|
|
32
|
-
referenceType: 'compensate'
|
|
33
|
-
},
|
|
34
|
-
execute: isThrowing ? executeThrow : executeCatch
|
|
25
|
+
this.id = id;
|
|
26
|
+
const type = this.type = eventDefinition.type;
|
|
27
|
+
const reference = this.reference = {
|
|
28
|
+
referenceType: 'compensate'
|
|
35
29
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
consumerTag: `_oncompensate-${executionId}`
|
|
49
|
-
});
|
|
50
|
-
if (completed) return;
|
|
51
|
-
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
52
|
-
noAck: true,
|
|
53
|
-
consumerTag: `_api-${executionId}`
|
|
30
|
+
this.isThrowing = isThrowing;
|
|
31
|
+
this.activity = activity;
|
|
32
|
+
this.broker = broker;
|
|
33
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
34
|
+
|
|
35
|
+
if (!isThrowing) {
|
|
36
|
+
this[kCompleted] = false;
|
|
37
|
+
this[kAssociations] = context.getOutboundAssociations(id) || [];
|
|
38
|
+
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-q`;
|
|
39
|
+
this[kMessageQ] = broker.assertQueue(messageQueueName, {
|
|
40
|
+
autoDelete: false,
|
|
41
|
+
durable: true
|
|
54
42
|
});
|
|
55
|
-
|
|
56
|
-
debug(`<${executionId} (${id})> expect compensate`);
|
|
57
|
-
broker.assertExchange('compensate', 'topic');
|
|
58
|
-
const compensateQ = broker.assertQueue('compensate-q', {
|
|
43
|
+
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
|
|
59
44
|
durable: true,
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
broker.subscribeTmp('compensate', 'execute.#', onCollect, {
|
|
63
|
-
noAck: true,
|
|
64
|
-
consumerTag: '_oncollect-messages'
|
|
65
|
-
});
|
|
66
|
-
broker.publish('execution', 'execute.detach', (0, _messageHelper.cloneContent)(messageContent, {
|
|
67
|
-
bindExchange: 'compensate'
|
|
68
|
-
}));
|
|
69
|
-
broker.publish('event', 'activity.detach', { ...messageContent,
|
|
70
|
-
executionId: parentExecutionId,
|
|
71
|
-
parent: (0, _messageHelper.shiftParent)(parent),
|
|
72
|
-
bindExchange: 'compensate'
|
|
45
|
+
priority: 400
|
|
73
46
|
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
74
49
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
50
|
+
const proto = CompensateEventDefinition.prototype;
|
|
51
|
+
Object.defineProperty(proto, 'executionId', {
|
|
52
|
+
get() {
|
|
53
|
+
const message = this[kExecuteMessage];
|
|
54
|
+
return message && message.content.executionId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
proto.execute = function execute(executeMessage) {
|
|
60
|
+
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
proto.executeCatch = function executeCatch(executeMessage) {
|
|
64
|
+
this[kExecuteMessage] = executeMessage;
|
|
65
|
+
this[kCompleted] = false;
|
|
66
|
+
const executeContent = executeMessage.content;
|
|
67
|
+
const {
|
|
68
|
+
executionId,
|
|
69
|
+
parent
|
|
70
|
+
} = executeContent;
|
|
71
|
+
|
|
72
|
+
this._debug('expect compensate');
|
|
73
|
+
|
|
74
|
+
const broker = this.broker;
|
|
75
|
+
broker.assertExchange('compensate', 'topic');
|
|
76
|
+
this[kCompensateQ] = broker.assertQueue('compensate-q', {
|
|
77
|
+
durable: true,
|
|
78
|
+
autoDelete: false
|
|
79
|
+
});
|
|
80
|
+
broker.subscribeTmp('compensate', 'execute.#', this._onCollect.bind(this), {
|
|
81
|
+
noAck: true,
|
|
82
|
+
consumerTag: '_oncollect-messages'
|
|
83
|
+
});
|
|
84
|
+
broker.publish('execution', 'execute.detach', (0, _messageHelper.cloneContent)(executeContent, {
|
|
85
|
+
sourceExchange: 'execution',
|
|
86
|
+
bindExchange: 'compensate'
|
|
87
|
+
}));
|
|
88
|
+
this[kMessageQ].consume(this._onCompensateApiMessage.bind(this), {
|
|
89
|
+
noAck: true,
|
|
90
|
+
consumerTag: `_oncompensate-${executionId}`
|
|
91
|
+
});
|
|
92
|
+
if (this[kCompleted]) return;
|
|
93
|
+
|
|
94
|
+
const onApiMessage = this._onApiMessage.bind(this);
|
|
95
|
+
|
|
96
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
97
|
+
noAck: true,
|
|
98
|
+
consumerTag: `_api-${executionId}`
|
|
99
|
+
});
|
|
100
|
+
const detachContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
101
|
+
executionId: parent.executionId,
|
|
102
|
+
bindExchange: 'compensate'
|
|
103
|
+
});
|
|
104
|
+
detachContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
105
|
+
broker.publish('event', 'activity.detach', detachContent);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
proto.executeThrow = function executeThrow(executeMessage) {
|
|
109
|
+
const executeContent = executeMessage.content;
|
|
110
|
+
const {
|
|
111
|
+
executionId,
|
|
112
|
+
parent
|
|
113
|
+
} = executeContent;
|
|
114
|
+
const parentExecutionId = parent && parent.executionId;
|
|
115
|
+
this.logger.debug(`<${executionId} (${this.activity.id})> throw compensate`);
|
|
116
|
+
const broker = this.broker;
|
|
117
|
+
const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
118
|
+
executionId: parentExecutionId,
|
|
119
|
+
state: 'throw'
|
|
120
|
+
});
|
|
121
|
+
throwContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
122
|
+
broker.publish('event', 'activity.compensate', throwContent, {
|
|
123
|
+
type: 'compensate',
|
|
124
|
+
delegate: true
|
|
125
|
+
});
|
|
126
|
+
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
proto._onCollect = function onCollect(routingKey, message) {
|
|
130
|
+
switch (routingKey) {
|
|
131
|
+
case 'execute.error':
|
|
132
|
+
case 'execute.completed':
|
|
133
|
+
{
|
|
134
|
+
return this[kCompensateQ].queueMessage(message.fields, (0, _messageHelper.cloneContent)(message.content), message.properties);
|
|
147
135
|
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function stop() {
|
|
151
|
-
broker.cancel(`_api-${executionId}`);
|
|
152
|
-
broker.cancel(`_oncompensate-${executionId}`);
|
|
153
|
-
broker.cancel('_oncollect-messages');
|
|
154
|
-
broker.cancel('_convey-messages');
|
|
155
|
-
}
|
|
156
136
|
}
|
|
137
|
+
};
|
|
157
138
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
139
|
+
proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
|
|
140
|
+
const output = message.content.message;
|
|
141
|
+
this[kCompleted] = true;
|
|
142
|
+
|
|
143
|
+
this._stop();
|
|
144
|
+
|
|
145
|
+
this._debug('caught compensate event');
|
|
146
|
+
|
|
147
|
+
const broker = this.broker;
|
|
148
|
+
const executeContent = this[kExecuteMessage].content;
|
|
149
|
+
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
150
|
+
message: { ...output
|
|
151
|
+
},
|
|
152
|
+
executionId: executeContent.parent.executionId
|
|
153
|
+
});
|
|
154
|
+
catchContent.parent = (0, _messageHelper.shiftParent)(catchContent.parent);
|
|
155
|
+
broker.publish('event', 'activity.catch', catchContent, {
|
|
156
|
+
type: 'catch'
|
|
157
|
+
});
|
|
158
|
+
const compensateQ = this[kCompensateQ];
|
|
159
|
+
compensateQ.on('depleted', onDepleted);
|
|
160
|
+
compensateQ.consume(this._onCollected.bind(this), {
|
|
161
|
+
noAck: true,
|
|
162
|
+
consumerTag: '_convey-messages'
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
for (const association of this[kAssociations]) association.complete((0, _messageHelper.cloneMessage)(message));
|
|
166
|
+
|
|
167
|
+
function onDepleted() {
|
|
168
|
+
compensateQ.off('depleted', onDepleted);
|
|
169
|
+
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
170
|
+
output,
|
|
171
|
+
state: 'catch'
|
|
172
|
+
}));
|
|
176
173
|
}
|
|
174
|
+
};
|
|
177
175
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
proto._onCollected = function onCollected(routingKey, message) {
|
|
177
|
+
for (const association of this[kAssociations]) association.take((0, _messageHelper.cloneMessage)(message));
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
181
|
+
const messageType = message.properties.type;
|
|
182
|
+
|
|
183
|
+
switch (messageType) {
|
|
184
|
+
case 'compensate':
|
|
185
|
+
{
|
|
186
|
+
return this._onCompensateApiMessage(routingKey, message);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
case 'discard':
|
|
190
|
+
{
|
|
191
|
+
this[kCompleted] = true;
|
|
192
|
+
|
|
193
|
+
this._stop();
|
|
194
|
+
|
|
195
|
+
for (const association of this[kAssociations]) association.discard((0, _messageHelper.cloneMessage)(message));
|
|
196
|
+
|
|
197
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
case 'stop':
|
|
201
|
+
{
|
|
202
|
+
this._stop();
|
|
203
|
+
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
187
206
|
}
|
|
188
|
-
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
proto._stop = function stop() {
|
|
210
|
+
const broker = this.broker,
|
|
211
|
+
executionId = this.executionId;
|
|
212
|
+
broker.cancel(`_api-${executionId}`);
|
|
213
|
+
broker.cancel(`_oncompensate-${executionId}`);
|
|
214
|
+
broker.cancel('_oncollect-messages');
|
|
215
|
+
broker.cancel('_convey-messages');
|
|
216
|
+
this[kMessageQ].purge();
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
proto._debug = function debug(msg) {
|
|
220
|
+
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
221
|
+
};
|