bpmn-elements 8.2.3 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/{src/Api.js → Api.js} +11 -12
- package/dist/{src/Context.js → Context.js} +26 -27
- package/dist/{src/Environment.js → Environment.js} +15 -16
- package/dist/{src/EventBroker.js → EventBroker.js} +8 -2
- package/dist/{src/Expressions.js → Expressions.js} +1 -1
- package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
- package/dist/{src/activity → activity}/Activity.js +62 -63
- package/dist/{src/activity → activity}/ActivityExecution.js +23 -24
- package/dist/{src/activity → activity}/Dummy.js +1 -1
- package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
- package/dist/{src/definition → definition}/Definition.js +41 -42
- package/dist/{src/definition → definition}/DefinitionExecution.js +45 -46
- package/dist/{src/error → error}/Errors.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/CancelEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
- package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
- package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
- package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
- package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
- package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
- package/dist/{src/events → events}/BoundaryEvent.js +15 -16
- package/dist/{src/events → events}/EndEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
- package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
- package/dist/{src/events → events}/StartEvent.js +8 -9
- package/dist/{src/flows → flows}/Association.js +15 -16
- package/dist/{src/flows → flows}/MessageFlow.js +16 -14
- package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
- package/dist/{src/gateways → gateways}/EventBasedGateway.js +2 -2
- package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
- package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
- package/dist/index.js +48 -48
- package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
- package/dist/{src/io → io}/Properties.js +7 -8
- package/dist/package.json +3 -0
- package/dist/{src/process → process}/Process.js +39 -40
- package/dist/{src/process → process}/ProcessExecution.js +55 -48
- package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
- package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
- package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
- package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
- package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
- package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
- package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
- package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
- package/dist/{src/tasks → tasks}/SubProcess.js +17 -18
- package/dist/{src/tasks → tasks}/Task.js +2 -2
- package/dist/{src/tasks → tasks}/Transaction.js +1 -1
- package/package.json +31 -31
- package/src/Api.js +11 -13
- package/src/Context.js +26 -28
- package/src/Environment.js +15 -17
- package/src/EventBroker.js +5 -2
- package/src/Expressions.js +1 -1
- package/src/MessageFormatter.js +3 -3
- package/src/activity/Activity.js +62 -64
- package/src/activity/ActivityExecution.js +23 -25
- package/src/activity/Dummy.js +1 -1
- package/src/activity/ExecutionScope.js +2 -2
- package/src/definition/Definition.js +41 -43
- package/src/definition/DefinitionExecution.js +45 -47
- package/src/error/Errors.js +1 -1
- package/src/eventDefinitions/CancelEventDefinition.js +12 -14
- package/src/eventDefinitions/CompensateEventDefinition.js +12 -14
- package/src/eventDefinitions/ConditionalEventDefinition.js +13 -15
- package/src/eventDefinitions/ErrorEventDefinition.js +13 -15
- package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
- package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
- package/src/eventDefinitions/LinkEventDefinition.js +14 -16
- package/src/eventDefinitions/MessageEventDefinition.js +13 -15
- package/src/eventDefinitions/SignalEventDefinition.js +13 -15
- package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
- package/src/eventDefinitions/TimerEventDefinition.js +15 -17
- package/src/events/BoundaryEvent.js +15 -17
- package/src/events/EndEvent.js +3 -3
- package/src/events/IntermediateCatchEvent.js +3 -3
- package/src/events/IntermediateThrowEvent.js +3 -3
- package/src/events/StartEvent.js +8 -10
- package/src/flows/Association.js +15 -17
- package/src/flows/MessageFlow.js +14 -15
- package/src/flows/SequenceFlow.js +16 -20
- package/src/gateways/EventBasedGateway.js +2 -2
- package/src/gateways/ExclusiveGateway.js +2 -2
- package/src/gateways/InclusiveGateway.js +2 -2
- package/src/gateways/ParallelGateway.js +2 -2
- package/src/index.js +106 -0
- package/src/io/InputOutputSpecification.js +8 -10
- package/src/io/Properties.js +7 -9
- package/src/process/Process.js +39 -41
- package/src/process/ProcessExecution.js +55 -49
- package/src/tasks/CallActivity.js +7 -9
- package/src/tasks/LoopCharacteristics.js +2 -2
- package/src/tasks/ReceiveTask.js +215 -217
- package/src/tasks/ScriptTask.js +4 -4
- package/src/tasks/ServiceImplementation.js +1 -1
- package/src/tasks/ServiceTask.js +6 -8
- package/src/tasks/SignalTask.js +7 -9
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +17 -19
- package/src/tasks/Task.js +2 -2
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +491 -0
- package/index.js +0 -106
- /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
- /package/dist/{src/Scripts.js → Scripts.js} +0 -0
- /package/dist/{src/Timers.js → Timers.js} +0 -0
- /package/dist/{src/activity → activity}/Escalation.js +0 -0
- /package/dist/{src/activity → activity}/Message.js +0 -0
- /package/dist/{src/activity → activity}/Signal.js +0 -0
- /package/dist/{src/error → error}/BpmnError.js +0 -0
- /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
- /package/dist/{src/io → io}/BpmnIO.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
- /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
- /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
- /package/dist/{src/shared.js → shared.js} +0 -0
package/src/activity/Activity.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import ActivityExecution from './ActivityExecution';
|
|
2
|
-
import {brokerSafeId, getUniqueId} from '../shared';
|
|
3
|
-
import {ActivityApi} from '../Api';
|
|
4
|
-
import {ActivityBroker} from '../EventBroker';
|
|
5
|
-
import {Formatter} from '../MessageFormatter';
|
|
6
|
-
import {cloneContent, cloneParent, cloneMessage} from '../messageHelper';
|
|
7
|
-
import {makeErrorFromMessage, ActivityError} from '../error/Errors';
|
|
1
|
+
import ActivityExecution from './ActivityExecution.js';
|
|
2
|
+
import {brokerSafeId, getUniqueId} from '../shared.js';
|
|
3
|
+
import {ActivityApi} from '../Api.js';
|
|
4
|
+
import {ActivityBroker} from '../EventBroker.js';
|
|
5
|
+
import {Formatter} from '../MessageFormatter.js';
|
|
6
|
+
import {cloneContent, cloneParent, cloneMessage} from '../messageHelper.js';
|
|
7
|
+
import {makeErrorFromMessage, ActivityError} from '../error/Errors.js';
|
|
8
8
|
|
|
9
9
|
const kActivityDef = Symbol.for('activityDefinition');
|
|
10
10
|
const kConsuming = Symbol.for('consuming');
|
|
@@ -106,37 +106,35 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
106
106
|
this[kExtensions] = context.loadExtensions(this);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Object.defineProperty(proto, 'counters', {
|
|
109
|
+
Object.defineProperty(Activity.prototype, 'counters', {
|
|
112
110
|
enumerable: true,
|
|
113
111
|
get() {
|
|
114
112
|
return {...this[kCounters]};
|
|
115
113
|
},
|
|
116
114
|
});
|
|
117
115
|
|
|
118
|
-
Object.defineProperty(
|
|
116
|
+
Object.defineProperty(Activity.prototype, 'execution', {
|
|
119
117
|
enumerable: true,
|
|
120
118
|
get() {
|
|
121
119
|
return this[kExec].execution;
|
|
122
120
|
},
|
|
123
121
|
});
|
|
124
122
|
|
|
125
|
-
Object.defineProperty(
|
|
123
|
+
Object.defineProperty(Activity.prototype, 'executionId', {
|
|
126
124
|
enumerable: true,
|
|
127
125
|
get() {
|
|
128
126
|
return this[kExec].executionId;
|
|
129
127
|
},
|
|
130
128
|
});
|
|
131
129
|
|
|
132
|
-
Object.defineProperty(
|
|
130
|
+
Object.defineProperty(Activity.prototype, 'extensions', {
|
|
133
131
|
enumerable: true,
|
|
134
132
|
get() {
|
|
135
133
|
return this[kExtensions];
|
|
136
134
|
},
|
|
137
135
|
});
|
|
138
136
|
|
|
139
|
-
Object.defineProperty(
|
|
137
|
+
Object.defineProperty(Activity.prototype, 'bpmnIo', {
|
|
140
138
|
enumerable: true,
|
|
141
139
|
get() {
|
|
142
140
|
const extensions = this[kExtensions];
|
|
@@ -144,7 +142,7 @@ Object.defineProperty(proto, 'bpmnIo', {
|
|
|
144
142
|
},
|
|
145
143
|
});
|
|
146
144
|
|
|
147
|
-
Object.defineProperty(
|
|
145
|
+
Object.defineProperty(Activity.prototype, 'formatter', {
|
|
148
146
|
enumerable: true,
|
|
149
147
|
get() {
|
|
150
148
|
let formatter = this[kFormatter];
|
|
@@ -160,7 +158,7 @@ Object.defineProperty(proto, 'formatter', {
|
|
|
160
158
|
},
|
|
161
159
|
});
|
|
162
160
|
|
|
163
|
-
Object.defineProperty(
|
|
161
|
+
Object.defineProperty(Activity.prototype, 'isRunning', {
|
|
164
162
|
enumerable: true,
|
|
165
163
|
get() {
|
|
166
164
|
if (!this[kConsuming]) return false;
|
|
@@ -168,66 +166,66 @@ Object.defineProperty(proto, 'isRunning', {
|
|
|
168
166
|
},
|
|
169
167
|
});
|
|
170
168
|
|
|
171
|
-
Object.defineProperty(
|
|
169
|
+
Object.defineProperty(Activity.prototype, 'outbound', {
|
|
172
170
|
enumerable: true,
|
|
173
171
|
get() {
|
|
174
172
|
return this[kFlows].outboundSequenceFlows;
|
|
175
173
|
},
|
|
176
174
|
});
|
|
177
175
|
|
|
178
|
-
Object.defineProperty(
|
|
176
|
+
Object.defineProperty(Activity.prototype, 'inbound', {
|
|
179
177
|
enumerable: true,
|
|
180
178
|
get() {
|
|
181
179
|
return this[kFlows].inboundSequenceFlows;
|
|
182
180
|
},
|
|
183
181
|
});
|
|
184
182
|
|
|
185
|
-
Object.defineProperty(
|
|
183
|
+
Object.defineProperty(Activity.prototype, 'isEnd', {
|
|
186
184
|
enumerable: true,
|
|
187
185
|
get() {
|
|
188
186
|
return this[kFlags].isEnd;
|
|
189
187
|
},
|
|
190
188
|
});
|
|
191
|
-
Object.defineProperty(
|
|
189
|
+
Object.defineProperty(Activity.prototype, 'isStart', {
|
|
192
190
|
enumerable: true,
|
|
193
191
|
get() {
|
|
194
192
|
return this[kFlags].isStart;
|
|
195
193
|
},
|
|
196
194
|
});
|
|
197
|
-
Object.defineProperty(
|
|
195
|
+
Object.defineProperty(Activity.prototype, 'isSubProcess', {
|
|
198
196
|
enumerable: true,
|
|
199
197
|
get() {
|
|
200
198
|
return this[kFlags].isSubProcess;
|
|
201
199
|
},
|
|
202
200
|
});
|
|
203
201
|
|
|
204
|
-
Object.defineProperty(
|
|
202
|
+
Object.defineProperty(Activity.prototype, 'isMultiInstance', {
|
|
205
203
|
enumerable: true,
|
|
206
204
|
get() {
|
|
207
205
|
return this[kFlags].isMultiInstance;
|
|
208
206
|
},
|
|
209
207
|
});
|
|
210
208
|
|
|
211
|
-
Object.defineProperty(
|
|
209
|
+
Object.defineProperty(Activity.prototype, 'isThrowing', {
|
|
212
210
|
enumerable: true,
|
|
213
211
|
get() {
|
|
214
212
|
return this[kFlags].isThrowing;
|
|
215
213
|
},
|
|
216
214
|
});
|
|
217
|
-
Object.defineProperty(
|
|
215
|
+
Object.defineProperty(Activity.prototype, 'isForCompensation', {
|
|
218
216
|
enumerable: true,
|
|
219
217
|
get() {
|
|
220
218
|
return this[kFlags].isForCompensation;
|
|
221
219
|
},
|
|
222
220
|
});
|
|
223
|
-
Object.defineProperty(
|
|
221
|
+
Object.defineProperty(Activity.prototype, 'triggeredByEvent', {
|
|
224
222
|
enumerable: true,
|
|
225
223
|
get() {
|
|
226
224
|
return this[kActivityDef].triggeredByEvent;
|
|
227
225
|
},
|
|
228
226
|
});
|
|
229
227
|
|
|
230
|
-
Object.defineProperty(
|
|
228
|
+
Object.defineProperty(Activity.prototype, 'attachedTo', {
|
|
231
229
|
enumerable: true,
|
|
232
230
|
get() {
|
|
233
231
|
const attachedToId = this[kFlags].attachedTo;
|
|
@@ -236,25 +234,25 @@ Object.defineProperty(proto, 'attachedTo', {
|
|
|
236
234
|
},
|
|
237
235
|
});
|
|
238
236
|
|
|
239
|
-
Object.defineProperty(
|
|
237
|
+
Object.defineProperty(Activity.prototype, 'eventDefinitions', {
|
|
240
238
|
enumerable: true,
|
|
241
239
|
get() {
|
|
242
240
|
return this[kEventDefinitions];
|
|
243
241
|
},
|
|
244
242
|
});
|
|
245
243
|
|
|
246
|
-
|
|
244
|
+
Activity.prototype.activate = function activate() {
|
|
247
245
|
if (this[kFlags].isForCompensation) return;
|
|
248
246
|
return this._consumeInbound();
|
|
249
247
|
};
|
|
250
248
|
|
|
251
|
-
|
|
249
|
+
Activity.prototype.deactivate = function deactivate() {
|
|
252
250
|
const broker = this.broker;
|
|
253
251
|
broker.cancel('_run-on-inbound');
|
|
254
252
|
broker.cancel('_format-consumer');
|
|
255
253
|
};
|
|
256
254
|
|
|
257
|
-
|
|
255
|
+
Activity.prototype.init = function init(initContent) {
|
|
258
256
|
const id = this.id;
|
|
259
257
|
const exec = this[kExec];
|
|
260
258
|
const executionId = exec.initExecutionId = exec.initExecutionId || getUniqueId(id);
|
|
@@ -262,7 +260,7 @@ proto.init = function init(initContent) {
|
|
|
262
260
|
this._publishEvent('init', this._createMessage({...initContent, executionId}));
|
|
263
261
|
};
|
|
264
262
|
|
|
265
|
-
|
|
263
|
+
Activity.prototype.run = function run(runContent) {
|
|
266
264
|
const id = this.id;
|
|
267
265
|
if (this.isRunning) throw new Error(`activity <${id}> is already running`);
|
|
268
266
|
|
|
@@ -281,7 +279,7 @@ proto.run = function run(runContent) {
|
|
|
281
279
|
this._consumeRunQ();
|
|
282
280
|
};
|
|
283
281
|
|
|
284
|
-
|
|
282
|
+
Activity.prototype.recover = function recover(state) {
|
|
285
283
|
if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
|
|
286
284
|
if (!state) return;
|
|
287
285
|
|
|
@@ -301,7 +299,7 @@ proto.recover = function recover(state) {
|
|
|
301
299
|
return this;
|
|
302
300
|
};
|
|
303
301
|
|
|
304
|
-
|
|
302
|
+
Activity.prototype.resume = function resume() {
|
|
305
303
|
if (this[kConsuming]) {
|
|
306
304
|
throw new Error(`cannot resume running activity <${this.id}>`);
|
|
307
305
|
}
|
|
@@ -316,7 +314,7 @@ proto.resume = function resume() {
|
|
|
316
314
|
this._consumeRunQ();
|
|
317
315
|
};
|
|
318
316
|
|
|
319
|
-
|
|
317
|
+
Activity.prototype.discard = function discard(discardContent) {
|
|
320
318
|
if (!this.status) return this._runDiscard(discardContent);
|
|
321
319
|
const execution = this[kExec].execution;
|
|
322
320
|
if (execution && !execution.completed) return execution.discard();
|
|
@@ -328,12 +326,12 @@ proto.discard = function discard(discardContent) {
|
|
|
328
326
|
this._consumeRunQ();
|
|
329
327
|
};
|
|
330
328
|
|
|
331
|
-
|
|
329
|
+
Activity.prototype.stop = function stop() {
|
|
332
330
|
if (!this[kConsuming]) return;
|
|
333
331
|
return this.getApi().stop();
|
|
334
332
|
};
|
|
335
333
|
|
|
336
|
-
|
|
334
|
+
Activity.prototype.next = function next() {
|
|
337
335
|
if (!this.environment.settings.step) return;
|
|
338
336
|
const stateMessage = this[kStateMessage];
|
|
339
337
|
if (!stateMessage) return;
|
|
@@ -344,15 +342,15 @@ proto.next = function next() {
|
|
|
344
342
|
return current;
|
|
345
343
|
};
|
|
346
344
|
|
|
347
|
-
|
|
345
|
+
Activity.prototype.shake = function shake() {
|
|
348
346
|
this._shakeOutbound({content: this._createMessage()});
|
|
349
347
|
};
|
|
350
348
|
|
|
351
|
-
|
|
349
|
+
Activity.prototype.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
|
|
352
350
|
return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
|
|
353
351
|
};
|
|
354
352
|
|
|
355
|
-
|
|
353
|
+
Activity.prototype.getState = function getState() {
|
|
356
354
|
const msg = this._createMessage();
|
|
357
355
|
|
|
358
356
|
const exec = this[kExec];
|
|
@@ -367,17 +365,17 @@ proto.getState = function getState() {
|
|
|
367
365
|
};
|
|
368
366
|
};
|
|
369
367
|
|
|
370
|
-
|
|
368
|
+
Activity.prototype.getApi = function getApi(message) {
|
|
371
369
|
const execution = this[kExec].execution;
|
|
372
370
|
if (execution && !execution.completed) return execution.getApi(message);
|
|
373
371
|
return ActivityApi(this.broker, message || this[kStateMessage]);
|
|
374
372
|
};
|
|
375
373
|
|
|
376
|
-
|
|
374
|
+
Activity.prototype.getActivityById = function getActivityById(elementId) {
|
|
377
375
|
return this.context.getActivityById(elementId);
|
|
378
376
|
};
|
|
379
377
|
|
|
380
|
-
|
|
378
|
+
Activity.prototype._runDiscard = function runDiscard(discardContent) {
|
|
381
379
|
const exec = this[kExec];
|
|
382
380
|
const executionId = exec.executionId = exec.initExecutionId || getUniqueId(this.id);
|
|
383
381
|
exec.initExecutionId = null;
|
|
@@ -390,7 +388,7 @@ proto._runDiscard = function runDiscard(discardContent) {
|
|
|
390
388
|
this._consumeRunQ();
|
|
391
389
|
};
|
|
392
390
|
|
|
393
|
-
|
|
391
|
+
Activity.prototype._discardRun = function discardRun() {
|
|
394
392
|
const status = this.status;
|
|
395
393
|
if (!status) return;
|
|
396
394
|
|
|
@@ -413,7 +411,7 @@ proto._discardRun = function discardRun() {
|
|
|
413
411
|
this._consumeRunQ();
|
|
414
412
|
};
|
|
415
413
|
|
|
416
|
-
|
|
414
|
+
Activity.prototype._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
417
415
|
const message = cloneMessage(sourceMessage);
|
|
418
416
|
message.content.sequence = message.content.sequence || [];
|
|
419
417
|
message.content.sequence.push({id: this.id, type: this.type});
|
|
@@ -428,7 +426,7 @@ proto._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
|
428
426
|
for (const flow of this[kFlows].outboundSequenceFlows) flow.shake(message);
|
|
429
427
|
};
|
|
430
428
|
|
|
431
|
-
|
|
429
|
+
Activity.prototype._consumeInbound = function consumeInbound() {
|
|
432
430
|
if (this.status) return;
|
|
433
431
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
434
432
|
if (this[kFlags].isParallelJoin) {
|
|
@@ -438,7 +436,7 @@ proto._consumeInbound = function consumeInbound() {
|
|
|
438
436
|
return inboundQ.consume(this[kMessageHandlers].onInbound, {consumerTag: '_run-on-inbound'});
|
|
439
437
|
};
|
|
440
438
|
|
|
441
|
-
|
|
439
|
+
Activity.prototype._onInbound = function onInbound(routingKey, message) {
|
|
442
440
|
message.ack();
|
|
443
441
|
const id = this.id;
|
|
444
442
|
const broker = this.broker;
|
|
@@ -475,7 +473,7 @@ proto._onInbound = function onInbound(routingKey, message) {
|
|
|
475
473
|
}
|
|
476
474
|
};
|
|
477
475
|
|
|
478
|
-
|
|
476
|
+
Activity.prototype._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
479
477
|
const {content} = message;
|
|
480
478
|
const {inboundSequenceFlows, inboundJoinFlows, inboundTriggers} = this[kFlows];
|
|
481
479
|
const idx = inboundJoinFlows.findIndex((msg) => msg.content.id === content.id);
|
|
@@ -516,7 +514,7 @@ proto._onJoinInbound = function onJoinInbound(routingKey, message) {
|
|
|
516
514
|
return this.run({inbound});
|
|
517
515
|
};
|
|
518
516
|
|
|
519
|
-
|
|
517
|
+
Activity.prototype._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
520
518
|
const {fields, content, properties} = message;
|
|
521
519
|
const id = this.id;
|
|
522
520
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
@@ -558,14 +556,14 @@ proto._onInboundEvent = function onInboundEvent(routingKey, message) {
|
|
|
558
556
|
}
|
|
559
557
|
};
|
|
560
558
|
|
|
561
|
-
|
|
559
|
+
Activity.prototype._consumeRunQ = function consumeRunQ() {
|
|
562
560
|
if (this[kConsuming]) return;
|
|
563
561
|
|
|
564
562
|
this[kConsuming] = true;
|
|
565
563
|
this.broker.getQueue('run-q').assertConsumer(this[kMessageHandlers].onRunMessage, {exclusive: true, consumerTag: '_activity-run'});
|
|
566
564
|
};
|
|
567
565
|
|
|
568
|
-
|
|
566
|
+
Activity.prototype._onRunMessage = function onRunMessage(routingKey, message, messageProperties) {
|
|
569
567
|
switch (routingKey) {
|
|
570
568
|
case 'run.outbound.discard':
|
|
571
569
|
case 'run.outbound.take':
|
|
@@ -586,7 +584,7 @@ proto._onRunMessage = function onRunMessage(routingKey, message, messageProperti
|
|
|
586
584
|
});
|
|
587
585
|
};
|
|
588
586
|
|
|
589
|
-
|
|
587
|
+
Activity.prototype._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
590
588
|
const isRedelivered = message.fields.redelivered;
|
|
591
589
|
const content = cloneContent(message.content);
|
|
592
590
|
const correlationId = message.properties.correlationId;
|
|
@@ -712,7 +710,7 @@ proto._continueRunMessage = function continueRunMessage(routingKey, message) {
|
|
|
712
710
|
if (!step) message.ack();
|
|
713
711
|
};
|
|
714
712
|
|
|
715
|
-
|
|
713
|
+
Activity.prototype._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
716
714
|
const executeMessage = this[kExecuteMessage];
|
|
717
715
|
const content = cloneContent({
|
|
718
716
|
...executeMessage.content,
|
|
@@ -755,14 +753,14 @@ proto._onExecutionMessage = function onExecutionMessage(routingKey, message) {
|
|
|
755
753
|
this._ackRunExecuteMessage();
|
|
756
754
|
};
|
|
757
755
|
|
|
758
|
-
|
|
756
|
+
Activity.prototype._ackRunExecuteMessage = function ackRunExecuteMessage() {
|
|
759
757
|
if (this.environment.settings.step) return;
|
|
760
758
|
const executeMessage = this[kExecuteMessage];
|
|
761
759
|
this[kExecuteMessage] = null;
|
|
762
760
|
executeMessage.ack();
|
|
763
761
|
};
|
|
764
762
|
|
|
765
|
-
|
|
763
|
+
Activity.prototype._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
766
764
|
const {content, properties} = message;
|
|
767
765
|
const correlationId = properties.correlationId;
|
|
768
766
|
if (content.ignoreOutbound) {
|
|
@@ -783,7 +781,7 @@ proto._doRunLeave = function doRunLeave(message, isDiscarded, onOutbound) {
|
|
|
783
781
|
});
|
|
784
782
|
};
|
|
785
783
|
|
|
786
|
-
|
|
784
|
+
Activity.prototype._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
787
785
|
const outboundSequenceFlows = this[kFlows].outboundSequenceFlows;
|
|
788
786
|
if (!outboundSequenceFlows.length) return callback(null, []);
|
|
789
787
|
|
|
@@ -813,7 +811,7 @@ proto._doOutbound = function doOutbound(fromMessage, isDiscarded, callback) {
|
|
|
813
811
|
});
|
|
814
812
|
};
|
|
815
813
|
|
|
816
|
-
|
|
814
|
+
Activity.prototype._doRunOutbound = function doRunOutbound(outboundList, content, discardSequence) {
|
|
817
815
|
for (const outboundFlow of outboundList) {
|
|
818
816
|
const {id: flowId, action} = outboundFlow;
|
|
819
817
|
this.broker.publish('run', 'run.outbound.' + action, cloneContent(content, {
|
|
@@ -827,7 +825,7 @@ proto._doRunOutbound = function doRunOutbound(outboundList, content, discardSequ
|
|
|
827
825
|
return outboundList;
|
|
828
826
|
};
|
|
829
827
|
|
|
830
|
-
|
|
828
|
+
Activity.prototype._onResumeMessage = function onResumeMessage(message) {
|
|
831
829
|
message.ack();
|
|
832
830
|
|
|
833
831
|
const stateMessage = this[kStateMessage];
|
|
@@ -852,7 +850,7 @@ proto._onResumeMessage = function onResumeMessage(message) {
|
|
|
852
850
|
return this.broker.publish('run', fields.routingKey, cloneContent(stateMessage.content), stateMessage.properties);
|
|
853
851
|
};
|
|
854
852
|
|
|
855
|
-
|
|
853
|
+
Activity.prototype._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
856
854
|
this.broker.publish('event', `activity.${state}`, cloneContent(content, {state}), {
|
|
857
855
|
...properties,
|
|
858
856
|
type: state,
|
|
@@ -861,7 +859,7 @@ proto._publishEvent = function publishEvent(state, content, properties = {}) {
|
|
|
861
859
|
});
|
|
862
860
|
};
|
|
863
861
|
|
|
864
|
-
|
|
862
|
+
Activity.prototype._onStop = function onStop(message) {
|
|
865
863
|
const running = this[kConsuming];
|
|
866
864
|
|
|
867
865
|
this.stopped = true;
|
|
@@ -880,7 +878,7 @@ proto._onStop = function onStop(message) {
|
|
|
880
878
|
}
|
|
881
879
|
};
|
|
882
880
|
|
|
883
|
-
|
|
881
|
+
Activity.prototype._consumeApi = function consumeApi() {
|
|
884
882
|
const executionId = this[kExec].executionId;
|
|
885
883
|
if (!executionId) return;
|
|
886
884
|
const broker = this.broker;
|
|
@@ -888,7 +886,7 @@ proto._consumeApi = function consumeApi() {
|
|
|
888
886
|
broker.subscribeTmp('api', `activity.*.${executionId}`, this[kMessageHandlers].onApiMessage, {noAck: true, consumerTag: '_activity-api', priority: 100});
|
|
889
887
|
};
|
|
890
888
|
|
|
891
|
-
|
|
889
|
+
Activity.prototype._onApiMessage = function onApiMessage(routingKey, message) {
|
|
892
890
|
switch (message.properties.type) {
|
|
893
891
|
case 'discard': {
|
|
894
892
|
return this._discardRun(message);
|
|
@@ -902,7 +900,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
|
902
900
|
}
|
|
903
901
|
};
|
|
904
902
|
|
|
905
|
-
|
|
903
|
+
Activity.prototype._createMessage = function createMessage(override) {
|
|
906
904
|
const name = this.name, status = this.status, parent = this.parent;
|
|
907
905
|
const result = {
|
|
908
906
|
...override,
|
|
@@ -920,11 +918,11 @@ proto._createMessage = function createMessage(override) {
|
|
|
920
918
|
return result;
|
|
921
919
|
};
|
|
922
920
|
|
|
923
|
-
|
|
921
|
+
Activity.prototype._getOutboundSequenceFlowById = function getOutboundSequenceFlowById(flowId) {
|
|
924
922
|
return this[kFlows].outboundSequenceFlows.find((flow) => flow.id === flowId);
|
|
925
923
|
};
|
|
926
924
|
|
|
927
|
-
|
|
925
|
+
Activity.prototype._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
928
926
|
const broker = this.broker;
|
|
929
927
|
broker.cancel('_activity-api');
|
|
930
928
|
broker.cancel('_activity-run');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ActivityApi} from '../Api';
|
|
2
|
-
import {cloneContent, cloneMessage} from '../messageHelper';
|
|
1
|
+
import {ActivityApi} from '../Api.js';
|
|
2
|
+
import {cloneContent, cloneMessage} from '../messageHelper.js';
|
|
3
3
|
|
|
4
4
|
const kCompleted = Symbol.for('completed');
|
|
5
5
|
const kExecuteQ = Symbol.for('executeQ');
|
|
@@ -24,16 +24,14 @@ function ActivityExecution(activity, context) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Object.defineProperty(proto, 'completed', {
|
|
27
|
+
Object.defineProperty(ActivityExecution.prototype, 'completed', {
|
|
30
28
|
enumerable: true,
|
|
31
29
|
get() {
|
|
32
30
|
return this[kCompleted];
|
|
33
31
|
},
|
|
34
32
|
});
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
ActivityExecution.prototype.execute = function execute(executeMessage) {
|
|
37
35
|
if (!executeMessage) throw new Error('Execution requires message');
|
|
38
36
|
const executionId = executeMessage.content && executeMessage.content.executionId;
|
|
39
37
|
if (!executionId) throw new Error('Execution requires execution id');
|
|
@@ -61,7 +59,7 @@ proto.execute = function execute(executeMessage) {
|
|
|
61
59
|
this.broker.publish('execution', 'execute.start', cloneContent(initMessage.content));
|
|
62
60
|
};
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
ActivityExecution.prototype.activate = function activate() {
|
|
65
63
|
if (this[kCompleted]) return;
|
|
66
64
|
|
|
67
65
|
const broker = this.broker;
|
|
@@ -85,21 +83,21 @@ proto.activate = function activate() {
|
|
|
85
83
|
});
|
|
86
84
|
};
|
|
87
85
|
|
|
88
|
-
|
|
86
|
+
ActivityExecution.prototype.deactivate = function deactivate() {
|
|
89
87
|
const broker = this.broker;
|
|
90
88
|
broker.cancel('_activity-api-execution');
|
|
91
89
|
broker.cancel('_activity-execute');
|
|
92
90
|
broker.unbindQueue('execute-q', 'execution', 'execute.#');
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
ActivityExecution.prototype.discard = function discard() {
|
|
96
94
|
if (this[kCompleted]) return;
|
|
97
95
|
const initMessage = this[kExecuteMessage];
|
|
98
96
|
if (!initMessage) return this.activity.logger.warn(`<${this.id}> is not executing`);
|
|
99
97
|
this.getApi(initMessage).discard();
|
|
100
98
|
};
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
ActivityExecution.prototype.getApi = function getApi(apiMessage) {
|
|
103
101
|
const self = this;
|
|
104
102
|
if (!apiMessage) apiMessage = this[kExecuteMessage];
|
|
105
103
|
|
|
@@ -121,19 +119,19 @@ proto.getApi = function getApi(apiMessage) {
|
|
|
121
119
|
return api;
|
|
122
120
|
};
|
|
123
121
|
|
|
124
|
-
|
|
122
|
+
ActivityExecution.prototype.passthrough = function passthrough(executeMessage) {
|
|
125
123
|
if (!this.source) return this.execute(executeMessage);
|
|
126
124
|
return this._sourceExecute(executeMessage);
|
|
127
125
|
};
|
|
128
126
|
|
|
129
|
-
|
|
127
|
+
ActivityExecution.prototype.getPostponed = function getPostponed() {
|
|
130
128
|
let apis = this[kPostponed].map((msg) => this.getApi(msg));
|
|
131
129
|
if (!this.activity.isSubProcess || !this.source) return apis;
|
|
132
130
|
apis = apis.concat(this.source.getPostponed());
|
|
133
131
|
return apis;
|
|
134
132
|
};
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
ActivityExecution.prototype.getState = function getState() {
|
|
137
135
|
const result = {completed: this[kCompleted]};
|
|
138
136
|
const source = this.source;
|
|
139
137
|
|
|
@@ -141,7 +139,7 @@ proto.getState = function getState() {
|
|
|
141
139
|
return {...result, ...source.getState()};
|
|
142
140
|
};
|
|
143
141
|
|
|
144
|
-
|
|
142
|
+
ActivityExecution.prototype.recover = function recover(state) {
|
|
145
143
|
this[kPostponed].splice(0);
|
|
146
144
|
|
|
147
145
|
if (!state) return this;
|
|
@@ -155,13 +153,13 @@ proto.recover = function recover(state) {
|
|
|
155
153
|
return this;
|
|
156
154
|
};
|
|
157
155
|
|
|
158
|
-
|
|
156
|
+
ActivityExecution.prototype.stop = function stop() {
|
|
159
157
|
const executeMessage = this[kExecuteMessage];
|
|
160
158
|
if (!executeMessage) return;
|
|
161
159
|
this.getApi(executeMessage).stop();
|
|
162
160
|
};
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
ActivityExecution.prototype._sourceExecute = function sourceExecute(executeMessage) {
|
|
165
163
|
try {
|
|
166
164
|
return this.source.execute(executeMessage);
|
|
167
165
|
} catch (error) {
|
|
@@ -169,7 +167,7 @@ proto._sourceExecute = function sourceExecute(executeMessage) {
|
|
|
169
167
|
}
|
|
170
168
|
};
|
|
171
169
|
|
|
172
|
-
|
|
170
|
+
ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routingKey, message) {
|
|
173
171
|
const {fields, content, properties} = message;
|
|
174
172
|
const isRedelivered = fields.redelivered;
|
|
175
173
|
|
|
@@ -213,7 +211,7 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
|
|
|
213
211
|
}
|
|
214
212
|
};
|
|
215
213
|
|
|
216
|
-
|
|
214
|
+
ActivityExecution.prototype._onStateChangeMessage = function onStateChangeMessage(message) {
|
|
217
215
|
const {ignoreIfExecuting, executionId} = message.content;
|
|
218
216
|
const postponed = this[kPostponed];
|
|
219
217
|
const idx = postponed.findIndex((msg) => msg.content.executionId === executionId);
|
|
@@ -234,7 +232,7 @@ proto._onStateChangeMessage = function onStateChangeMessage(message) {
|
|
|
234
232
|
return true;
|
|
235
233
|
};
|
|
236
234
|
|
|
237
|
-
|
|
235
|
+
ActivityExecution.prototype._onExecutionCompleted = function onExecutionCompleted(message) {
|
|
238
236
|
const postponedMsg = this._ackPostponed(message);
|
|
239
237
|
if (!postponedMsg) return;
|
|
240
238
|
const postponed = this[kPostponed];
|
|
@@ -263,7 +261,7 @@ proto._onExecutionCompleted = function onExecutionCompleted(message) {
|
|
|
263
261
|
this._publishExecutionCompleted('completed', {...postponedMsg.content, ...message.content}, message.properties.correlationId);
|
|
264
262
|
};
|
|
265
263
|
|
|
266
|
-
|
|
264
|
+
ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarded(message) {
|
|
267
265
|
const postponedMsg = this._ackPostponed(message);
|
|
268
266
|
const {isRootScope, error} = message.content;
|
|
269
267
|
if (!isRootScope && !postponedMsg) return;
|
|
@@ -293,7 +291,7 @@ proto._onExecutionDiscarded = function onExecutionDiscarded(message) {
|
|
|
293
291
|
this._publishExecutionCompleted('discard', message.content, correlationId);
|
|
294
292
|
};
|
|
295
293
|
|
|
296
|
-
|
|
294
|
+
ActivityExecution.prototype._publishExecutionCompleted = function publishExecutionCompleted(completionType, completeContent, correlationId) {
|
|
297
295
|
this[kCompleted] = true;
|
|
298
296
|
|
|
299
297
|
this.broker.publish('execution', `execution.${completionType}`, {
|
|
@@ -302,7 +300,7 @@ proto._publishExecutionCompleted = function publishExecutionCompleted(completion
|
|
|
302
300
|
}, {type: completionType, correlationId});
|
|
303
301
|
};
|
|
304
302
|
|
|
305
|
-
|
|
303
|
+
ActivityExecution.prototype._ackPostponed = function ackPostponed(completeMessage) {
|
|
306
304
|
const {executionId: eid} = completeMessage.content;
|
|
307
305
|
|
|
308
306
|
const postponed = this[kPostponed];
|
|
@@ -313,7 +311,7 @@ proto._ackPostponed = function ackPostponed(completeMessage) {
|
|
|
313
311
|
return msg;
|
|
314
312
|
};
|
|
315
313
|
|
|
316
|
-
|
|
314
|
+
ActivityExecution.prototype._onParentApiMessage = function onParentApiMessage(routingKey, message) {
|
|
317
315
|
switch (message.properties.type) {
|
|
318
316
|
case 'error':
|
|
319
317
|
return this[kExecuteQ].queueMessage({routingKey: 'execute.error'}, {error: message.content.error});
|
|
@@ -325,7 +323,7 @@ proto._onParentApiMessage = function onParentApiMessage(routingKey, message) {
|
|
|
325
323
|
}
|
|
326
324
|
};
|
|
327
325
|
|
|
328
|
-
|
|
326
|
+
ActivityExecution.prototype._onStop = function onStop(message) {
|
|
329
327
|
const stoppedId = message && message.content && message.content.executionId;
|
|
330
328
|
const running = this.getPostponed();
|
|
331
329
|
for (const api of running) {
|
|
@@ -338,7 +336,7 @@ proto._onStop = function onStop(message) {
|
|
|
338
336
|
this.broker.cancel('_activity-api-execution');
|
|
339
337
|
};
|
|
340
338
|
|
|
341
|
-
|
|
339
|
+
ActivityExecution.prototype._debug = function debug(logMessage, executionId) {
|
|
342
340
|
executionId = executionId || this.executionId;
|
|
343
341
|
this.activity.logger.debug(`<${executionId} (${this.id})> ${logMessage}`);
|
|
344
342
|
};
|
package/src/activity/Dummy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {cloneMessage} from '../messageHelper';
|
|
2
|
-
import {ActivityError, BpmnError} from '../error/Errors';
|
|
1
|
+
import {cloneMessage} from '../messageHelper.js';
|
|
2
|
+
import {ActivityError, BpmnError} from '../error/Errors.js';
|
|
3
3
|
|
|
4
4
|
export default function ExecutionScope(activity, initMessage) {
|
|
5
5
|
const {id, type, environment, logger} = activity;
|