bpmn-elements 8.2.4 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/{src/Api.js → Api.js} +11 -12
- package/dist/{src/Context.js → Context.js} +26 -27
- package/dist/{src/Environment.js → Environment.js} +15 -16
- package/dist/{src/EventBroker.js → EventBroker.js} +5 -1
- package/dist/{src/Expressions.js → Expressions.js} +1 -1
- package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
- package/dist/Tracker.js +89 -0
- package/dist/{src/activity → activity}/Activity.js +109 -120
- package/dist/{src/activity → activity}/ActivityExecution.js +28 -32
- package/dist/{src/activity → activity}/Dummy.js +1 -1
- package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
- package/dist/{src/definition → definition}/Definition.js +64 -59
- package/dist/{src/definition → definition}/DefinitionExecution.js +68 -46
- package/dist/{src/error → error}/Errors.js +1 -1
- package/dist/eventDefinitions/CancelEventDefinition.js +127 -0
- package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +64 -52
- package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +24 -16
- package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +15 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
- package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
- package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
- package/dist/{src/events → events}/BoundaryEvent.js +39 -25
- package/dist/{src/events → events}/EndEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
- package/dist/{src/events → events}/StartEvent.js +8 -9
- package/dist/{src/flows → flows}/Association.js +14 -22
- package/dist/{src/flows → flows}/MessageFlow.js +16 -14
- package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
- package/dist/{src/gateways → gateways}/EventBasedGateway.js +3 -4
- package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
- package/dist/index.js +48 -48
- package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
- package/dist/{src/io → io}/Properties.js +7 -8
- package/dist/package.json +3 -0
- package/dist/{src/process → process}/Process.js +44 -40
- package/dist/{src/process → process}/ProcessExecution.js +169 -78
- package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
- package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
- package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
- package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
- package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
- package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
- package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
- package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
- package/dist/{src/tasks → tasks}/SubProcess.js +19 -19
- package/dist/{src/tasks → tasks}/Task.js +2 -2
- package/dist/{src/tasks → tasks}/Transaction.js +1 -1
- package/package.json +31 -31
- package/src/Api.js +11 -13
- package/src/Context.js +26 -28
- package/src/Environment.js +15 -17
- package/src/EventBroker.js +2 -1
- package/src/Expressions.js +1 -1
- package/src/MessageFormatter.js +3 -3
- package/src/Tracker.js +73 -0
- package/src/activity/Activity.js +106 -114
- package/src/activity/ActivityExecution.js +28 -32
- package/src/activity/Dummy.js +1 -1
- package/src/activity/ExecutionScope.js +2 -2
- package/src/definition/Definition.js +65 -64
- package/src/definition/DefinitionExecution.js +71 -47
- package/src/error/Errors.js +1 -1
- package/src/eventDefinitions/CancelEventDefinition.js +32 -78
- package/src/eventDefinitions/CompensateEventDefinition.js +58 -52
- package/src/eventDefinitions/ConditionalEventDefinition.js +25 -17
- package/src/eventDefinitions/ErrorEventDefinition.js +15 -15
- package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
- package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
- package/src/eventDefinitions/LinkEventDefinition.js +14 -16
- package/src/eventDefinitions/MessageEventDefinition.js +13 -15
- package/src/eventDefinitions/SignalEventDefinition.js +13 -15
- package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +15 -17
- package/src/events/BoundaryEvent.js +34 -24
- package/src/events/EndEvent.js +3 -3
- package/src/events/IntermediateCatchEvent.js +3 -3
- package/src/events/IntermediateThrowEvent.js +3 -3
- package/src/events/StartEvent.js +8 -10
- package/src/flows/Association.js +14 -26
- package/src/flows/MessageFlow.js +14 -15
- package/src/flows/SequenceFlow.js +16 -20
- package/src/gateways/EventBasedGateway.js +3 -4
- package/src/gateways/ExclusiveGateway.js +2 -2
- package/src/gateways/InclusiveGateway.js +2 -2
- package/src/gateways/ParallelGateway.js +2 -2
- package/src/index.js +106 -0
- package/src/io/InputOutputSpecification.js +8 -10
- package/src/io/Properties.js +7 -9
- package/src/process/Process.js +45 -41
- package/src/process/ProcessExecution.js +167 -79
- package/src/tasks/CallActivity.js +7 -9
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/ReceiveTask.js +215 -217
- package/src/tasks/ScriptTask.js +4 -4
- package/src/tasks/ServiceImplementation.js +1 -1
- package/src/tasks/ServiceTask.js +6 -8
- package/src/tasks/SignalTask.js +7 -9
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +19 -20
- package/src/tasks/Task.js +2 -2
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +520 -0
- package/dist/src/eventDefinitions/CancelEventDefinition.js +0 -184
- package/index.js +0 -106
- /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
- /package/dist/{src/Scripts.js → Scripts.js} +0 -0
- /package/dist/{src/Timers.js → Timers.js} +0 -0
- /package/dist/{src/activity → activity}/Escalation.js +0 -0
- /package/dist/{src/activity → activity}/Message.js +0 -0
- /package/dist/{src/activity → activity}/Signal.js +0 -0
- /package/dist/{src/error → error}/BpmnError.js +0 -0
- /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
- /package/dist/{src/io → io}/BpmnIO.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
- /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
- /package/dist/{src/shared.js → shared.js} +0 -0
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _ActivityExecution = _interopRequireDefault(require("./ActivityExecution"));
|
|
8
|
-
var _shared = require("../shared");
|
|
9
|
-
var _Api = require("../Api");
|
|
10
|
-
var _EventBroker = require("../EventBroker");
|
|
11
|
-
var _MessageFormatter = require("../MessageFormatter");
|
|
12
|
-
var _messageHelper = require("../messageHelper");
|
|
13
|
-
var _Errors = require("../error/Errors");
|
|
7
|
+
var _ActivityExecution = _interopRequireDefault(require("./ActivityExecution.js"));
|
|
8
|
+
var _shared = require("../shared.js");
|
|
9
|
+
var _Api = require("../Api.js");
|
|
10
|
+
var _EventBroker = require("../EventBroker.js");
|
|
11
|
+
var _MessageFormatter = require("../MessageFormatter.js");
|
|
12
|
+
var _messageHelper = require("../messageHelper.js");
|
|
13
|
+
var _Errors = require("../error/Errors.js");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
const kActivityDef = Symbol.for('activityDefinition');
|
|
16
16
|
const kConsuming = Symbol.for('consuming');
|
|
@@ -24,6 +24,7 @@ const kFlows = Symbol.for('flows');
|
|
|
24
24
|
const kFormatter = Symbol.for('formatter');
|
|
25
25
|
const kMessageHandlers = Symbol.for('messageHandlers');
|
|
26
26
|
const kStateMessage = Symbol.for('stateMessage');
|
|
27
|
+
const kActivated = Symbol.for('activated');
|
|
27
28
|
var _default = Activity;
|
|
28
29
|
exports.default = _default;
|
|
29
30
|
function Activity(Behaviour, activityDef, context) {
|
|
@@ -54,6 +55,7 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
54
55
|
taken: 0,
|
|
55
56
|
discarded: 0
|
|
56
57
|
};
|
|
58
|
+
const isForCompensation = !!behaviour.isForCompensation;
|
|
57
59
|
let attachedToActivity, attachedTo;
|
|
58
60
|
if (attachedToRef) {
|
|
59
61
|
attachedTo = attachedToRef.id;
|
|
@@ -73,7 +75,14 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
73
75
|
this.emitFatal = emitFatal;
|
|
74
76
|
const inboundSequenceFlows = context.getInboundSequenceFlows(id);
|
|
75
77
|
const inboundAssociations = context.getInboundAssociations(id);
|
|
76
|
-
|
|
78
|
+
let inboundTriggers;
|
|
79
|
+
if (attachedToActivity) {
|
|
80
|
+
inboundTriggers = [attachedToActivity];
|
|
81
|
+
} else if (isForCompensation) {
|
|
82
|
+
inboundTriggers = inboundAssociations.slice();
|
|
83
|
+
} else {
|
|
84
|
+
inboundTriggers = inboundSequenceFlows.slice();
|
|
85
|
+
}
|
|
77
86
|
const outboundSequenceFlows = context.getOutboundSequenceFlows(id);
|
|
78
87
|
const flows = this[kFlows] = {
|
|
79
88
|
inboundSequenceFlows,
|
|
@@ -83,7 +92,6 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
83
92
|
outboundSequenceFlows,
|
|
84
93
|
outboundEvaluator: new OutboundEvaluator(this, outboundSequenceFlows)
|
|
85
94
|
};
|
|
86
|
-
const isForCompensation = !!behaviour.isForCompensation;
|
|
87
95
|
const isParallelJoin = activityDef.isParallelGateway && flows.inboundSequenceFlows.length > 1;
|
|
88
96
|
this[kFlags] = {
|
|
89
97
|
isEnd: flows.outboundSequenceFlows.length === 0,
|
|
@@ -103,34 +111,10 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
103
111
|
onApiMessage: this._onApiMessage.bind(this),
|
|
104
112
|
onExecutionMessage: this._onExecutionMessage.bind(this)
|
|
105
113
|
};
|
|
106
|
-
const onInboundEvent = this._onInboundEvent.bind(this);
|
|
107
|
-
broker.assertQueue('inbound-q', {
|
|
108
|
-
durable: true,
|
|
109
|
-
autoDelete: false
|
|
110
|
-
});
|
|
111
|
-
if (isForCompensation) {
|
|
112
|
-
for (const trigger of inboundAssociations) {
|
|
113
|
-
trigger.broker.subscribeTmp('event', '#', onInboundEvent, {
|
|
114
|
-
noAck: true,
|
|
115
|
-
consumerTag: `_inbound-${id}`
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
for (const trigger of inboundTriggers) {
|
|
120
|
-
if (trigger.isSequenceFlow) trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {
|
|
121
|
-
noAck: true,
|
|
122
|
-
consumerTag: `_inbound-${id}`
|
|
123
|
-
});else trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {
|
|
124
|
-
noAck: true,
|
|
125
|
-
consumerTag: `_inbound-${id}`
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
114
|
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed, this.context));
|
|
130
115
|
this[kExtensions] = context.loadExtensions(this);
|
|
131
116
|
}
|
|
132
|
-
|
|
133
|
-
Object.defineProperty(proto, 'counters', {
|
|
117
|
+
Object.defineProperty(Activity.prototype, 'counters', {
|
|
134
118
|
enumerable: true,
|
|
135
119
|
get() {
|
|
136
120
|
return {
|
|
@@ -138,32 +122,32 @@ Object.defineProperty(proto, 'counters', {
|
|
|
138
122
|
};
|
|
139
123
|
}
|
|
140
124
|
});
|
|
141
|
-
Object.defineProperty(
|
|
125
|
+
Object.defineProperty(Activity.prototype, 'execution', {
|
|
142
126
|
enumerable: true,
|
|
143
127
|
get() {
|
|
144
128
|
return this[kExec].execution;
|
|
145
129
|
}
|
|
146
130
|
});
|
|
147
|
-
Object.defineProperty(
|
|
131
|
+
Object.defineProperty(Activity.prototype, 'executionId', {
|
|
148
132
|
enumerable: true,
|
|
149
133
|
get() {
|
|
150
134
|
return this[kExec].executionId;
|
|
151
135
|
}
|
|
152
136
|
});
|
|
153
|
-
Object.defineProperty(
|
|
137
|
+
Object.defineProperty(Activity.prototype, 'extensions', {
|
|
154
138
|
enumerable: true,
|
|
155
139
|
get() {
|
|
156
140
|
return this[kExtensions];
|
|
157
141
|
}
|
|
158
142
|
});
|
|
159
|
-
Object.defineProperty(
|
|
143
|
+
Object.defineProperty(Activity.prototype, 'bpmnIo', {
|
|
160
144
|
enumerable: true,
|
|
161
145
|
get() {
|
|
162
146
|
const extensions = this[kExtensions];
|
|
163
147
|
return extensions && extensions.extensions.find(e => e.type === 'bpmnio');
|
|
164
148
|
}
|
|
165
149
|
});
|
|
166
|
-
Object.defineProperty(
|
|
150
|
+
Object.defineProperty(Activity.prototype, 'formatter', {
|
|
167
151
|
enumerable: true,
|
|
168
152
|
get() {
|
|
169
153
|
let formatter = this[kFormatter];
|
|
@@ -177,68 +161,74 @@ Object.defineProperty(proto, 'formatter', {
|
|
|
177
161
|
return formatter;
|
|
178
162
|
}
|
|
179
163
|
});
|
|
180
|
-
Object.defineProperty(
|
|
164
|
+
Object.defineProperty(Activity.prototype, 'isRunning', {
|
|
181
165
|
enumerable: true,
|
|
182
166
|
get() {
|
|
183
167
|
if (!this[kConsuming]) return false;
|
|
184
168
|
return !!this.status;
|
|
185
169
|
}
|
|
186
170
|
});
|
|
187
|
-
Object.defineProperty(
|
|
171
|
+
Object.defineProperty(Activity.prototype, 'outbound', {
|
|
188
172
|
enumerable: true,
|
|
189
173
|
get() {
|
|
190
174
|
return this[kFlows].outboundSequenceFlows;
|
|
191
175
|
}
|
|
192
176
|
});
|
|
193
|
-
Object.defineProperty(
|
|
177
|
+
Object.defineProperty(Activity.prototype, 'inbound', {
|
|
194
178
|
enumerable: true,
|
|
195
179
|
get() {
|
|
196
180
|
return this[kFlows].inboundSequenceFlows;
|
|
197
181
|
}
|
|
198
182
|
});
|
|
199
|
-
Object.defineProperty(
|
|
183
|
+
Object.defineProperty(Activity.prototype, 'isEnd', {
|
|
200
184
|
enumerable: true,
|
|
201
185
|
get() {
|
|
202
186
|
return this[kFlags].isEnd;
|
|
203
187
|
}
|
|
204
188
|
});
|
|
205
|
-
Object.defineProperty(
|
|
189
|
+
Object.defineProperty(Activity.prototype, 'isStart', {
|
|
206
190
|
enumerable: true,
|
|
207
191
|
get() {
|
|
208
192
|
return this[kFlags].isStart;
|
|
209
193
|
}
|
|
210
194
|
});
|
|
211
|
-
Object.defineProperty(
|
|
195
|
+
Object.defineProperty(Activity.prototype, 'isSubProcess', {
|
|
212
196
|
enumerable: true,
|
|
213
197
|
get() {
|
|
214
198
|
return this[kFlags].isSubProcess;
|
|
215
199
|
}
|
|
216
200
|
});
|
|
217
|
-
Object.defineProperty(
|
|
201
|
+
Object.defineProperty(Activity.prototype, 'isTransaction', {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
get() {
|
|
204
|
+
return this[kFlags].isTransaction;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
Object.defineProperty(Activity.prototype, 'isMultiInstance', {
|
|
218
208
|
enumerable: true,
|
|
219
209
|
get() {
|
|
220
210
|
return this[kFlags].isMultiInstance;
|
|
221
211
|
}
|
|
222
212
|
});
|
|
223
|
-
Object.defineProperty(
|
|
213
|
+
Object.defineProperty(Activity.prototype, 'isThrowing', {
|
|
224
214
|
enumerable: true,
|
|
225
215
|
get() {
|
|
226
216
|
return this[kFlags].isThrowing;
|
|
227
217
|
}
|
|
228
218
|
});
|
|
229
|
-
Object.defineProperty(
|
|
219
|
+
Object.defineProperty(Activity.prototype, 'isForCompensation', {
|
|
230
220
|
enumerable: true,
|
|
231
221
|
get() {
|
|
232
222
|
return this[kFlags].isForCompensation;
|
|
233
223
|
}
|
|
234
224
|
});
|
|
235
|
-
Object.defineProperty(
|
|
225
|
+
Object.defineProperty(Activity.prototype, 'triggeredByEvent', {
|
|
236
226
|
enumerable: true,
|
|
237
227
|
get() {
|
|
238
228
|
return this[kActivityDef].triggeredByEvent;
|
|
239
229
|
}
|
|
240
230
|
});
|
|
241
|
-
Object.defineProperty(
|
|
231
|
+
Object.defineProperty(Activity.prototype, 'attachedTo', {
|
|
242
232
|
enumerable: true,
|
|
243
233
|
get() {
|
|
244
234
|
const attachedToId = this[kFlags].attachedTo;
|
|
@@ -246,22 +236,25 @@ Object.defineProperty(proto, 'attachedTo', {
|
|
|
246
236
|
return this.getActivityById(attachedToId);
|
|
247
237
|
}
|
|
248
238
|
});
|
|
249
|
-
Object.defineProperty(
|
|
239
|
+
Object.defineProperty(Activity.prototype, 'eventDefinitions', {
|
|
250
240
|
enumerable: true,
|
|
251
241
|
get() {
|
|
252
242
|
return this[kEventDefinitions];
|
|
253
243
|
}
|
|
254
244
|
});
|
|
255
|
-
|
|
256
|
-
|
|
245
|
+
Activity.prototype.activate = function activate() {
|
|
246
|
+
this[kActivated] = true;
|
|
247
|
+
this.addInboundListeners();
|
|
257
248
|
return this._consumeInbound();
|
|
258
249
|
};
|
|
259
|
-
|
|
250
|
+
Activity.prototype.deactivate = function deactivate() {
|
|
251
|
+
this[kActivated] = false;
|
|
260
252
|
const broker = this.broker;
|
|
253
|
+
this.removeInboundListeners();
|
|
261
254
|
broker.cancel('_run-on-inbound');
|
|
262
255
|
broker.cancel('_format-consumer');
|
|
263
256
|
};
|
|
264
|
-
|
|
257
|
+
Activity.prototype.init = function init(initContent) {
|
|
265
258
|
const id = this.id;
|
|
266
259
|
const exec = this[kExec];
|
|
267
260
|
const executionId = exec.initExecutionId = exec.initExecutionId || (0, _shared.getUniqueId)(id);
|
|
@@ -271,7 +264,7 @@ proto.init = function init(initContent) {
|
|
|
271
264
|
executionId
|
|
272
265
|
}));
|
|
273
266
|
};
|
|
274
|
-
|
|
267
|
+
Activity.prototype.run = function run(runContent) {
|
|
275
268
|
const id = this.id;
|
|
276
269
|
if (this.isRunning) throw new Error(`activity <${id}> is already running`);
|
|
277
270
|
const exec = this[kExec];
|
|
@@ -287,7 +280,7 @@ proto.run = function run(runContent) {
|
|
|
287
280
|
broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
|
|
288
281
|
this._consumeRunQ();
|
|
289
282
|
};
|
|
290
|
-
|
|
283
|
+
Activity.prototype.recover = function recover(state) {
|
|
291
284
|
if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
|
|
292
285
|
if (!state) return;
|
|
293
286
|
this.stopped = state.stopped;
|
|
@@ -304,7 +297,7 @@ proto.recover = function recover(state) {
|
|
|
304
297
|
this.broker.recover(state.broker);
|
|
305
298
|
return this;
|
|
306
299
|
};
|
|
307
|
-
|
|
300
|
+
Activity.prototype.resume = function resume() {
|
|
308
301
|
if (this[kConsuming]) {
|
|
309
302
|
throw new Error(`cannot resume running activity <${this.id}>`);
|
|
310
303
|
}
|
|
@@ -317,7 +310,7 @@ proto.resume = function resume() {
|
|
|
317
310
|
});
|
|
318
311
|
this._consumeRunQ();
|
|
319
312
|
};
|
|
320
|
-
|
|
313
|
+
Activity.prototype.discard = function discard(discardContent) {
|
|
321
314
|
if (!this.status) return this._runDiscard(discardContent);
|
|
322
315
|
const execution = this[kExec].execution;
|
|
323
316
|
if (execution && !execution.completed) return execution.discard();
|
|
@@ -327,11 +320,33 @@ proto.discard = function discard(discardContent) {
|
|
|
327
320
|
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[kStateMessage].content));
|
|
328
321
|
this._consumeRunQ();
|
|
329
322
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
323
|
+
Activity.prototype.addInboundListeners = function addInboundListeners() {
|
|
324
|
+
const onInboundEvent = this._onInboundEvent.bind(this);
|
|
325
|
+
const triggerConsumerTag = `_inbound-${this.id}`;
|
|
326
|
+
for (const trigger of this[kFlows].inboundTriggers) {
|
|
327
|
+
if (trigger.isSequenceFlow) trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {
|
|
328
|
+
noAck: true,
|
|
329
|
+
consumerTag: triggerConsumerTag
|
|
330
|
+
});else if (this.isForCompensation) trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, {
|
|
331
|
+
noAck: true,
|
|
332
|
+
consumerTag: triggerConsumerTag
|
|
333
|
+
});else trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {
|
|
334
|
+
noAck: true,
|
|
335
|
+
consumerTag: triggerConsumerTag
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
Activity.prototype.removeInboundListeners = function removeInboundListeners() {
|
|
340
|
+
const triggerConsumerTag = `_inbound-${this.id}`;
|
|
341
|
+
for (const trigger of this[kFlows].inboundTriggers) {
|
|
342
|
+
trigger.broker.cancel(triggerConsumerTag);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
Activity.prototype.stop = function stop() {
|
|
346
|
+
if (!this[kConsuming]) return this.broker.cancel('_run-on-inbound');
|
|
347
|
+
return this.getApi(this[kStateMessage]).stop();
|
|
333
348
|
};
|
|
334
|
-
|
|
349
|
+
Activity.prototype.next = function next() {
|
|
335
350
|
if (!this.environment.settings.step) return;
|
|
336
351
|
const stateMessage = this[kStateMessage];
|
|
337
352
|
if (!stateMessage) return;
|
|
@@ -341,15 +356,15 @@ proto.next = function next() {
|
|
|
341
356
|
stateMessage.ack();
|
|
342
357
|
return current;
|
|
343
358
|
};
|
|
344
|
-
|
|
359
|
+
Activity.prototype.shake = function shake() {
|
|
345
360
|
this._shakeOutbound({
|
|
346
361
|
content: this._createMessage()
|
|
347
362
|
});
|
|
348
363
|
};
|
|
349
|
-
|
|
364
|
+
Activity.prototype.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
|
|
350
365
|
return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
|
|
351
366
|
};
|
|
352
|
-
|
|
367
|
+
Activity.prototype.getState = function getState() {
|
|
353
368
|
const msg = this._createMessage();
|
|
354
369
|
const exec = this[kExec];
|
|
355
370
|
return {
|
|
@@ -364,15 +379,15 @@ proto.getState = function getState() {
|
|
|
364
379
|
execution: exec.execution && exec.execution.getState()
|
|
365
380
|
};
|
|
366
381
|
};
|
|
367
|
-
|
|
382
|
+
Activity.prototype.getApi = function getApi(message) {
|
|
368
383
|
const execution = this[kExec].execution;
|
|
369
384
|
if (execution && !execution.completed) return execution.getApi(message);
|
|
370
385
|
return (0, _Api.ActivityApi)(this.broker, message || this[kStateMessage]);
|
|
371
386
|
};
|
|
372
|
-
|
|
387
|
+
Activity.prototype.getActivityById = function getActivityById(elementId) {
|
|
373
388
|
return this.context.getActivityById(elementId);
|
|
374
389
|
};
|
|
375
|
-
|
|
390
|
+
Activity.prototype._runDiscard = function runDiscard(discardContent) {
|
|
376
391
|
const exec = this[kExec];
|
|
377
392
|
const executionId = exec.executionId = exec.initExecutionId || (0, _shared.getUniqueId)(this.id);
|
|
378
393
|
exec.initExecutionId = null;
|
|
@@ -384,7 +399,7 @@ proto._runDiscard = function runDiscard(discardContent) {
|
|
|
384
399
|
this.broker.publish('run', 'run.discard', content);
|
|
385
400
|
this._consumeRunQ();
|
|
386
401
|
};
|
|
387
|
-
|
|
402
|
+
Activity.prototype._discardRun = function discardRun() {
|
|
388
403
|
const status = this.status;
|
|
389
404
|
if (!status) return;
|
|
390
405
|
const execution = this[kExec].execution;
|
|
@@ -403,7 +418,7 @@ proto._discardRun = function discardRun() {
|
|
|
403
418
|
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(message.content));
|
|
404
419
|
this._consumeRunQ();
|
|
405
420
|
};
|
|
406
|
-
|
|
421
|
+
Activity.prototype._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
407
422
|
const message = (0, _messageHelper.cloneMessage)(sourceMessage);
|
|
408
423
|
message.content.sequence = message.content.sequence || [];
|
|
409
424
|
message.content.sequence.push({
|
|
@@ -423,7 +438,8 @@ proto._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
|
423
438
|
}
|
|
424
439
|
for (const flow of this[kFlows].outboundSequenceFlows) flow.shake(message);
|
|
425
440
|
};
|
|
426
|
-
|
|
441
|
+
Activity.prototype._consumeInbound = function consumeInbound() {
|
|
442
|
+
if (!this[kActivated]) return;
|
|
427
443
|
if (this.status) return;
|
|
428
444
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
429
445
|
if (this[kFlags].isParallelJoin) {
|
|
@@ -436,9 +452,8 @@ proto._consumeInbound = function consumeInbound() {
|
|
|
436
452
|
consumerTag: '_run-on-inbound'
|
|
437
453
|
});
|
|
438
454
|
};
|
|
439
|
-
|
|
455
|
+
Activity.prototype._onInbound = function onInbound(routingKey, message) {
|
|
440
456
|
message.ack();
|
|
441
|
-
const id = this.id;
|
|
442
457
|
const broker = this.broker;
|
|
443
458
|
broker.cancel('_run-on-inbound');
|
|
444
459
|
const content = message.content;
|
|
@@ -462,18 +477,9 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
462
477
|
discardSequence
|
|
463
478
|
});
|
|
464
479
|
}
|
|
465
|
-
case 'association.complete':
|
|
466
|
-
{
|
|
467
|
-
broker.cancel('_run-on-inbound');
|
|
468
|
-
const compensationId = `${(0, _shared.brokerSafeId)(id)}_${(0, _shared.brokerSafeId)(content.sequenceId)}`;
|
|
469
|
-
this.logger.debug(`<${id}> completed compensation with id <${compensationId}>`);
|
|
470
|
-
return this._publishEvent('compensation.end', this._createMessage({
|
|
471
|
-
executionId: compensationId
|
|
472
|
-
}));
|
|
473
|
-
}
|
|
474
480
|
}
|
|
475
481
|
};
|
|
476
|
-
|
|
482
|
+
Activity.prototype._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
477
483
|
const {
|
|
478
484
|
content
|
|
479
485
|
} = message;
|
|
@@ -516,13 +522,12 @@ proto._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
|
516
522
|
inbound
|
|
517
523
|
});
|
|
518
524
|
};
|
|
519
|
-
|
|
525
|
+
Activity.prototype._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
520
526
|
const {
|
|
521
527
|
fields,
|
|
522
528
|
content,
|
|
523
529
|
properties
|
|
524
530
|
} = message;
|
|
525
|
-
const id = this.id;
|
|
526
531
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
527
532
|
switch (routingKey) {
|
|
528
533
|
case 'activity.enter':
|
|
@@ -541,26 +546,9 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
541
546
|
case 'flow.take':
|
|
542
547
|
case 'flow.discard':
|
|
543
548
|
return inboundQ.queueMessage(fields, (0, _messageHelper.cloneContent)(content), properties);
|
|
544
|
-
case 'association.discard':
|
|
545
|
-
{
|
|
546
|
-
this.logger.debug(`<${id}> compensation discarded`);
|
|
547
|
-
return inboundQ.purge();
|
|
548
|
-
}
|
|
549
|
-
case 'association.complete':
|
|
550
|
-
{
|
|
551
|
-
if (!this[kFlags].isForCompensation) break;
|
|
552
|
-
inboundQ.queueMessage(fields, (0, _messageHelper.cloneContent)(content), properties);
|
|
553
|
-
const compensationId = `${(0, _shared.brokerSafeId)(id)}_${(0, _shared.brokerSafeId)(content.sequenceId)}`;
|
|
554
|
-
this._publishEvent('compensation.start', this._createMessage({
|
|
555
|
-
executionId: compensationId,
|
|
556
|
-
placeholder: true
|
|
557
|
-
}));
|
|
558
|
-
this.logger.debug(`<${id}> start compensation with id <${compensationId}>`);
|
|
559
|
-
return this._consumeInbound();
|
|
560
|
-
}
|
|
561
549
|
}
|
|
562
550
|
};
|
|
563
|
-
|
|
551
|
+
Activity.prototype._consumeRunQ = function consumeRunQ() {
|
|
564
552
|
if (this[kConsuming]) return;
|
|
565
553
|
this[kConsuming] = true;
|
|
566
554
|
this.broker.getQueue('run-q').assertConsumer(this[kMessageHandlers].onRunMessage, {
|
|
@@ -568,7 +556,7 @@ proto._consumeRunQ = function consumeRunQ() {
|
|
|
568
556
|
consumerTag: '_activity-run'
|
|
569
557
|
});
|
|
570
558
|
};
|
|
571
|
-
|
|
559
|
+
Activity.prototype._onRunMessage = function onRunMessage(routingKey, message, messageProperties) {
|
|
572
560
|
switch (routingKey) {
|
|
573
561
|
case 'run.outbound.discard':
|
|
574
562
|
case 'run.outbound.take':
|
|
@@ -588,7 +576,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message, messageProperti
|
|
|
588
576
|
this._continueRunMessage(routingKey, message, messageProperties);
|
|
589
577
|
});
|
|
590
578
|
};
|
|
591
|
-
|
|
579
|
+
Activity.prototype._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
592
580
|
const isRedelivered = message.fields.redelivered;
|
|
593
581
|
const content = (0, _messageHelper.cloneContent)(message.content);
|
|
594
582
|
const correlationId = message.properties.correlationId;
|
|
@@ -641,6 +629,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
641
629
|
{
|
|
642
630
|
const execution = this.execution;
|
|
643
631
|
if (!isRedelivered && execution) {
|
|
632
|
+
if (execution.completed) return message.ack();
|
|
644
633
|
this[kExecuteMessage] = message;
|
|
645
634
|
return execution.passthrough(message);
|
|
646
635
|
}
|
|
@@ -726,7 +715,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
726
715
|
}
|
|
727
716
|
if (!step) message.ack();
|
|
728
717
|
};
|
|
729
|
-
|
|
718
|
+
Activity.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
730
719
|
const executeMessage = this[kExecuteMessage];
|
|
731
720
|
const content = (0, _messageHelper.cloneContent)({
|
|
732
721
|
...executeMessage.content,
|
|
@@ -764,6 +753,7 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
764
753
|
});
|
|
765
754
|
break;
|
|
766
755
|
}
|
|
756
|
+
case 'execution.cancel':
|
|
767
757
|
case 'execution.discard':
|
|
768
758
|
this.status = 'discarded';
|
|
769
759
|
broker.publish('run', 'run.discarded', content, {
|
|
@@ -781,13 +771,12 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
781
771
|
message.ack();
|
|
782
772
|
this._ackRunExecuteMessage();
|
|
783
773
|
};
|
|
784
|
-
|
|
774
|
+
Activity.prototype._ackRunExecuteMessage = function ackRunExecuteMessage() {
|
|
785
775
|
if (this.environment.settings.step) return;
|
|
786
776
|
const executeMessage = this[kExecuteMessage];
|
|
787
|
-
this[kExecuteMessage] = null;
|
|
788
777
|
executeMessage.ack();
|
|
789
778
|
};
|
|
790
|
-
|
|
779
|
+
Activity.prototype._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
791
780
|
const {
|
|
792
781
|
content,
|
|
793
782
|
properties
|
|
@@ -818,7 +807,7 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
818
807
|
onOutbound();
|
|
819
808
|
});
|
|
820
809
|
};
|
|
821
|
-
|
|
810
|
+
Activity.prototype._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
822
811
|
const outboundSequenceFlows = this[kFlows].outboundSequenceFlows;
|
|
823
812
|
if (!outboundSequenceFlows.length) return callback(null, []);
|
|
824
813
|
const fromContent = fromMessage.content;
|
|
@@ -844,7 +833,7 @@ proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
|
844
833
|
return callback(null, outbound);
|
|
845
834
|
});
|
|
846
835
|
};
|
|
847
|
-
|
|
836
|
+
Activity.prototype._doRunOutbound = function doRunOutbound(outboundList, content, discardSequence) {
|
|
848
837
|
for (const outboundFlow of outboundList) {
|
|
849
838
|
const {
|
|
850
839
|
id: flowId,
|
|
@@ -862,7 +851,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
862
851
|
}
|
|
863
852
|
return outboundList;
|
|
864
853
|
};
|
|
865
|
-
|
|
854
|
+
Activity.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
866
855
|
message.ack();
|
|
867
856
|
const stateMessage = this[kStateMessage];
|
|
868
857
|
const fields = stateMessage.fields;
|
|
@@ -881,7 +870,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
881
870
|
this.logger.debug(`<${this.id}> resume from ${message.content.status}`);
|
|
882
871
|
return this.broker.publish('run', fields.routingKey, (0, _messageHelper.cloneContent)(stateMessage.content), stateMessage.properties);
|
|
883
872
|
};
|
|
884
|
-
|
|
873
|
+
Activity.prototype._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
885
874
|
this.broker.publish('event', `activity.${state}`, (0, _messageHelper.cloneContent)(content, {
|
|
886
875
|
state
|
|
887
876
|
}), {
|
|
@@ -891,7 +880,7 @@ proto._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
|
891
880
|
persistent: 'persistent' in properties ? properties.persistent : state !== 'stop'
|
|
892
881
|
});
|
|
893
882
|
};
|
|
894
|
-
|
|
883
|
+
Activity.prototype._onStop = function onStop(message) {
|
|
895
884
|
const running = this[kConsuming];
|
|
896
885
|
this.stopped = true;
|
|
897
886
|
this[kConsuming] = false;
|
|
@@ -906,7 +895,7 @@ proto._onStop = function onStop(message) {
|
|
|
906
895
|
this._publishEvent('stop', this._createMessage());
|
|
907
896
|
}
|
|
908
897
|
};
|
|
909
|
-
|
|
898
|
+
Activity.prototype._consumeApi = function consumeApi() {
|
|
910
899
|
const executionId = this[kExec].executionId;
|
|
911
900
|
if (!executionId) return;
|
|
912
901
|
const broker = this.broker;
|
|
@@ -917,7 +906,7 @@ proto._consumeApi = function consumeApi() {
|
|
|
917
906
|
priority: 100
|
|
918
907
|
});
|
|
919
908
|
};
|
|
920
|
-
|
|
909
|
+
Activity.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
921
910
|
switch (message.properties.type) {
|
|
922
911
|
case 'discard':
|
|
923
912
|
{
|
|
@@ -933,7 +922,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
933
922
|
}
|
|
934
923
|
}
|
|
935
924
|
};
|
|
936
|
-
|
|
925
|
+
Activity.prototype._createMessage = function createMessage(override) {
|
|
937
926
|
const name = this.name,
|
|
938
927
|
status = this.status,
|
|
939
928
|
parent = this.parent;
|
|
@@ -956,10 +945,10 @@ proto._createMessage = function createMessage(override) {
|
|
|
956
945
|
}
|
|
957
946
|
return result;
|
|
958
947
|
};
|
|
959
|
-
|
|
948
|
+
Activity.prototype._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId) {
|
|
960
949
|
return this[kFlows].outboundSequenceFlows.find(flow => flow.id === flowId);
|
|
961
950
|
};
|
|
962
|
-
|
|
951
|
+
Activity.prototype._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
963
952
|
const broker = this.broker;
|
|
964
953
|
broker.cancel('_activity-api');
|
|
965
954
|
broker.cancel('_activity-run');
|