bpmn-elements 13.1.2 → 14.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 +1 -2
- package/dist/Context.js +36 -2
- package/dist/activity/Activity.js +32 -15
- package/dist/definition/DefinitionExecution.js +1 -1
- package/dist/error/Errors.js +6 -1
- package/dist/eventDefinitions/TimerEventDefinition.js +18 -31
- package/dist/getPropertyValue.js +1 -2
- package/dist/index.js +13 -5
- package/package.json +16 -14
- package/src/Api.js +18 -20
- package/src/Context.js +49 -7
- package/src/Environment.js +10 -20
- package/src/EventBroker.js +21 -27
- package/src/MessageFormatter.js +23 -19
- package/src/Tracker.js +4 -4
- package/src/activity/Activity.js +174 -121
- package/src/activity/ActivityExecution.js +38 -29
- package/src/activity/Dummy.js +3 -3
- package/src/activity/Escalation.js +4 -4
- package/src/activity/ExecutionScope.js +4 -4
- package/src/activity/Message.js +5 -5
- package/src/activity/Signal.js +5 -5
- package/src/definition/Definition.js +44 -36
- package/src/definition/DefinitionExecution.js +97 -66
- package/src/error/BpmnError.js +3 -3
- package/src/error/Errors.js +27 -15
- package/src/eventDefinitions/CancelEventDefinition.js +16 -11
- package/src/eventDefinitions/CompensateEventDefinition.js +28 -23
- package/src/eventDefinitions/ConditionalEventDefinition.js +42 -23
- package/src/eventDefinitions/ErrorEventDefinition.js +47 -34
- package/src/eventDefinitions/EscalationEventDefinition.js +21 -20
- package/src/eventDefinitions/EventDefinitionExecution.js +6 -6
- package/src/eventDefinitions/LinkEventDefinition.js +28 -22
- package/src/eventDefinitions/MessageEventDefinition.js +47 -36
- package/src/eventDefinitions/SignalEventDefinition.js +42 -31
- package/src/eventDefinitions/TerminateEventDefinition.js +4 -4
- package/src/eventDefinitions/TimerEventDefinition.js +56 -57
- package/src/events/BoundaryEvent.js +81 -46
- package/src/events/EndEvent.js +2 -2
- package/src/events/IntermediateCatchEvent.js +8 -4
- package/src/events/IntermediateThrowEvent.js +2 -2
- package/src/events/StartEvent.js +29 -18
- package/src/flows/Association.js +11 -11
- package/src/flows/MessageFlow.js +16 -14
- package/src/flows/SequenceFlow.js +22 -20
- package/src/gateways/EventBasedGateway.js +7 -6
- package/src/gateways/ExclusiveGateway.js +4 -4
- package/src/gateways/InclusiveGateway.js +3 -3
- package/src/gateways/ParallelGateway.js +4 -4
- package/src/getPropertyValue.js +3 -6
- package/src/index.js +3 -3
- package/src/io/BpmnIO.js +5 -6
- package/src/io/EnvironmentDataObject.js +2 -3
- package/src/io/EnvironmentDataStore.js +2 -2
- package/src/io/EnvironmentDataStoreReference.js +2 -2
- package/src/io/InputOutputSpecification.js +60 -54
- package/src/io/Properties.js +45 -33
- package/src/messageHelper.js +16 -23
- package/src/process/Lane.js +3 -3
- package/src/process/Process.js +40 -34
- package/src/process/ProcessExecution.js +122 -78
- package/src/tasks/CallActivity.js +109 -57
- package/src/tasks/LoopCharacteristics.js +30 -18
- package/src/tasks/ReceiveTask.js +59 -38
- package/src/tasks/ScriptTask.js +17 -8
- package/src/tasks/ServiceTask.js +16 -9
- package/src/tasks/SignalTask.js +47 -28
- package/src/tasks/StandardLoopCharacteristics.js +3 -3
- package/src/tasks/SubProcess.js +9 -8
- package/src/tasks/Task.js +4 -3
- package/src/tasks/Transaction.js +1 -1
- package/types/index.d.ts +6 -6
- package/types/types.d.ts +39 -35
- package/CHANGELOG.md +0 -459
- package/src/ExtensionsMapper.js +0 -42
- package/src/iso-duration.js +0 -91
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
bpmn-elements
|
|
2
|
-
=============
|
|
1
|
+
# bpmn-elements
|
|
3
2
|
|
|
4
3
|
[](https://github.com/paed01/bpmn-elements/actions/workflows/build.yaml)[](https://coveralls.io/github/paed01/bpmn-elements?branch=master)
|
|
5
4
|
|
package/dist/Context.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = Context;
|
|
7
7
|
var _BpmnIO = _interopRequireDefault(require("./io/BpmnIO.js"));
|
|
8
8
|
var _Environment = _interopRequireDefault(require("./Environment.js"));
|
|
9
|
-
var _ExtensionsMapper = _interopRequireDefault(require("./ExtensionsMapper.js"));
|
|
10
9
|
var _shared = require("./shared.js");
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
11
|
const kOwner = Symbol.for('owner');
|
|
12
|
+
const kActivated = Symbol.for('activated');
|
|
13
13
|
function Context(definitionContext, environment) {
|
|
14
14
|
environment = environment ? environment.clone() : new _Environment.default();
|
|
15
15
|
return new ContextInstance(definitionContext, environment);
|
|
@@ -27,7 +27,7 @@ function ContextInstance(definitionContext, environment, owner) {
|
|
|
27
27
|
this.sid = sid;
|
|
28
28
|
this.definitionContext = definitionContext;
|
|
29
29
|
this.environment = environment;
|
|
30
|
-
this.extensionsMapper = new
|
|
30
|
+
this.extensionsMapper = new ExtensionsMapper(this);
|
|
31
31
|
this.refs = {
|
|
32
32
|
activityRefs: {},
|
|
33
33
|
associationRefs: [],
|
|
@@ -192,4 +192,38 @@ ContextInstance.prototype.getActivityParentById = function getActivityParentById
|
|
|
192
192
|
const activity = this.getActivityById(activityId);
|
|
193
193
|
const parentId = activity.parent.id;
|
|
194
194
|
return this.getProcessById(parentId) || this.getActivityById(parentId);
|
|
195
|
+
};
|
|
196
|
+
function ExtensionsMapper(context) {
|
|
197
|
+
this.context = context;
|
|
198
|
+
}
|
|
199
|
+
ExtensionsMapper.prototype.get = function get(activity) {
|
|
200
|
+
return new Extensions(activity, this.context, this._getExtensions());
|
|
201
|
+
};
|
|
202
|
+
ExtensionsMapper.prototype._getExtensions = function getExtensions() {
|
|
203
|
+
let extensions;
|
|
204
|
+
if (!(extensions = this.context.environment.extensions)) return [];
|
|
205
|
+
return Object.values(extensions);
|
|
206
|
+
};
|
|
207
|
+
function Extensions(activity, context, extensions) {
|
|
208
|
+
const result = this.extensions = [];
|
|
209
|
+
for (const Extension of extensions) {
|
|
210
|
+
const extension = Extension(activity, context);
|
|
211
|
+
if (extension) result.push(extension);
|
|
212
|
+
}
|
|
213
|
+
this[kActivated] = false;
|
|
214
|
+
}
|
|
215
|
+
Object.defineProperty(Extensions.prototype, 'count', {
|
|
216
|
+
get() {
|
|
217
|
+
return this.extensions.length;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
Extensions.prototype.activate = function activate(message) {
|
|
221
|
+
if (this[kActivated]) return;
|
|
222
|
+
this[kActivated] = true;
|
|
223
|
+
for (const extension of this.extensions) extension.activate(message);
|
|
224
|
+
};
|
|
225
|
+
Extensions.prototype.deactivate = function deactivate(message) {
|
|
226
|
+
if (!this[kActivated]) return;
|
|
227
|
+
this[kActivated] = false;
|
|
228
|
+
for (const extension of this.extensions) extension.deactivate(message);
|
|
195
229
|
};
|
|
@@ -14,6 +14,7 @@ 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');
|
|
17
|
+
const kConsumingRunQ = Symbol.for('run queue consumer');
|
|
17
18
|
const kCounters = Symbol.for('counters');
|
|
18
19
|
const kEventDefinitions = Symbol.for('eventDefinitions');
|
|
19
20
|
const kExec = Symbol.for('exec');
|
|
@@ -113,6 +114,8 @@ function Activity(Behaviour, activityDef, context) {
|
|
|
113
114
|
};
|
|
114
115
|
this[kEventDefinitions] = eventDefinitions && eventDefinitions.map(ed => new ed.Behaviour(this, ed, this.context));
|
|
115
116
|
this[kExtensions] = context.loadExtensions(this);
|
|
117
|
+
this[kConsuming] = false;
|
|
118
|
+
this[kConsumingRunQ] = undefined;
|
|
116
119
|
}
|
|
117
120
|
Object.defineProperties(Activity.prototype, {
|
|
118
121
|
counters: {
|
|
@@ -239,6 +242,7 @@ Object.defineProperties(Activity.prototype, {
|
|
|
239
242
|
}
|
|
240
243
|
});
|
|
241
244
|
Activity.prototype.activate = function activate() {
|
|
245
|
+
if (this[kActivated]) return;
|
|
242
246
|
this[kActivated] = true;
|
|
243
247
|
this.addInboundListeners();
|
|
244
248
|
return this._consumeInbound();
|
|
@@ -274,6 +278,7 @@ Activity.prototype.run = function run(runContent) {
|
|
|
274
278
|
const broker = this.broker;
|
|
275
279
|
broker.publish('run', 'run.enter', content);
|
|
276
280
|
broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
|
|
281
|
+
this[kConsuming] = true;
|
|
277
282
|
this._consumeRunQ();
|
|
278
283
|
};
|
|
279
284
|
Activity.prototype.getState = function getState() {
|
|
@@ -322,6 +327,7 @@ Activity.prototype.resume = function resume() {
|
|
|
322
327
|
this.broker.publish('run', 'run.resume', content, {
|
|
323
328
|
persistent: false
|
|
324
329
|
});
|
|
330
|
+
this[kConsuming] = true;
|
|
325
331
|
this._consumeRunQ();
|
|
326
332
|
};
|
|
327
333
|
Activity.prototype.discard = function discard(discardContent) {
|
|
@@ -332,6 +338,7 @@ Activity.prototype.discard = function discard(discardContent) {
|
|
|
332
338
|
const broker = this.broker;
|
|
333
339
|
broker.getQueue('run-q').purge();
|
|
334
340
|
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(this[kStateMessage].content));
|
|
341
|
+
this[kConsuming] = true;
|
|
335
342
|
this._consumeRunQ();
|
|
336
343
|
};
|
|
337
344
|
Activity.prototype.addInboundListeners = function addInboundListeners() {
|
|
@@ -396,6 +403,7 @@ Activity.prototype._runDiscard = function runDiscard(discardContent) {
|
|
|
396
403
|
executionId
|
|
397
404
|
});
|
|
398
405
|
this.broker.publish('run', 'run.discard', content);
|
|
406
|
+
this[kConsuming] = true;
|
|
399
407
|
this._consumeRunQ();
|
|
400
408
|
};
|
|
401
409
|
Activity.prototype._discardRun = function discardRun() {
|
|
@@ -404,17 +412,19 @@ Activity.prototype._discardRun = function discardRun() {
|
|
|
404
412
|
const execution = this[kExec].execution;
|
|
405
413
|
if (execution && !execution.completed) return;
|
|
406
414
|
switch (status) {
|
|
415
|
+
case 'end':
|
|
407
416
|
case 'executing':
|
|
408
417
|
case 'error':
|
|
409
418
|
case 'discarded':
|
|
410
419
|
return;
|
|
411
420
|
}
|
|
412
421
|
this._deactivateRunConsumers();
|
|
413
|
-
const
|
|
414
|
-
if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(
|
|
422
|
+
const stateMessage = this[kStateMessage];
|
|
423
|
+
if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(stateMessage));
|
|
415
424
|
const broker = this.broker;
|
|
416
425
|
broker.getQueue('run-q').purge();
|
|
417
|
-
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(
|
|
426
|
+
broker.publish('run', 'run.discard', (0, _messageHelper.cloneContent)(stateMessage.content));
|
|
427
|
+
this[kConsuming] = true;
|
|
418
428
|
this._consumeRunQ();
|
|
419
429
|
};
|
|
420
430
|
Activity.prototype._shakeOutbound = function shakeOutbound(sourceMessage) {
|
|
@@ -441,13 +451,14 @@ Activity.prototype._consumeInbound = function consumeInbound() {
|
|
|
441
451
|
if (!this[kActivated]) return;
|
|
442
452
|
if (this.status) return;
|
|
443
453
|
const inboundQ = this.broker.getQueue('inbound-q');
|
|
454
|
+
const onInbound = this[kMessageHandlers].onInbound;
|
|
444
455
|
if (this[kFlags].isParallelJoin) {
|
|
445
|
-
return inboundQ.consume(
|
|
456
|
+
return inboundQ.consume(onInbound, {
|
|
446
457
|
consumerTag: '_run-on-inbound',
|
|
447
458
|
prefetch: 1000
|
|
448
459
|
});
|
|
449
460
|
}
|
|
450
|
-
return inboundQ.consume(
|
|
461
|
+
return inboundQ.consume(onInbound, {
|
|
451
462
|
consumerTag: '_run-on-inbound'
|
|
452
463
|
});
|
|
453
464
|
};
|
|
@@ -548,13 +559,17 @@ Activity.prototype._onInboundEvent = function onInboundEvent(routingKey, message
|
|
|
548
559
|
}
|
|
549
560
|
};
|
|
550
561
|
Activity.prototype._consumeRunQ = function consumeRunQ() {
|
|
551
|
-
|
|
552
|
-
this[kConsuming] = true;
|
|
562
|
+
this[kConsumingRunQ] = true;
|
|
553
563
|
this.broker.getQueue('run-q').assertConsumer(this[kMessageHandlers].onRunMessage, {
|
|
554
564
|
exclusive: true,
|
|
555
565
|
consumerTag: '_activity-run'
|
|
556
566
|
});
|
|
557
567
|
};
|
|
568
|
+
Activity.prototype._pauseRunQ = function pauseRunQ() {
|
|
569
|
+
if (!this[kConsumingRunQ]) return;
|
|
570
|
+
this[kConsumingRunQ] = false;
|
|
571
|
+
this.broker.cancel('_activity-run');
|
|
572
|
+
};
|
|
558
573
|
Activity.prototype._onRunMessage = function onRunMessage(routingKey, message, messageProperties) {
|
|
559
574
|
switch (routingKey) {
|
|
560
575
|
case 'run.outbound.discard':
|
|
@@ -709,8 +724,9 @@ Activity.prototype._continueRunMessage = function continueRunMessage(routingKey,
|
|
|
709
724
|
break;
|
|
710
725
|
}
|
|
711
726
|
case 'run.next':
|
|
712
|
-
|
|
713
|
-
|
|
727
|
+
message.ack();
|
|
728
|
+
this._pauseRunQ();
|
|
729
|
+
return this._consumeInbound();
|
|
714
730
|
}
|
|
715
731
|
if (!step) message.ack();
|
|
716
732
|
};
|
|
@@ -877,8 +893,7 @@ Activity.prototype._publishEvent = function publishEvent(state, content, propert
|
|
|
877
893
|
}), {
|
|
878
894
|
...properties,
|
|
879
895
|
type: state,
|
|
880
|
-
mandatory: state === 'error'
|
|
881
|
-
persistent: 'persistent' in properties ? properties.persistent : state !== 'stop'
|
|
896
|
+
mandatory: state === 'error'
|
|
882
897
|
});
|
|
883
898
|
};
|
|
884
899
|
Activity.prototype._onStop = function onStop(message) {
|
|
@@ -886,14 +901,16 @@ Activity.prototype._onStop = function onStop(message) {
|
|
|
886
901
|
this.stopped = true;
|
|
887
902
|
this[kConsuming] = false;
|
|
888
903
|
const broker = this.broker;
|
|
889
|
-
|
|
904
|
+
this._pauseRunQ();
|
|
890
905
|
broker.cancel('_activity-api');
|
|
891
906
|
broker.cancel('_activity-execution');
|
|
892
907
|
broker.cancel('_run-on-inbound');
|
|
893
908
|
broker.cancel('_format-consumer');
|
|
909
|
+
if (this.extensions) this.extensions.deactivate((0, _messageHelper.cloneMessage)(message));
|
|
894
910
|
if (running) {
|
|
895
|
-
|
|
896
|
-
|
|
911
|
+
this._publishEvent('stop', this._createMessage(), {
|
|
912
|
+
persistent: false
|
|
913
|
+
});
|
|
897
914
|
}
|
|
898
915
|
};
|
|
899
916
|
Activity.prototype._consumeApi = function consumeApi() {
|
|
@@ -952,7 +969,7 @@ Activity.prototype._getOutboundSequenceFlowById = function getOutboundSequenceFl
|
|
|
952
969
|
Activity.prototype._deactivateRunConsumers = function _deactivateRunConsumers() {
|
|
953
970
|
const broker = this.broker;
|
|
954
971
|
broker.cancel('_activity-api');
|
|
955
|
-
|
|
972
|
+
this._pauseRunQ();
|
|
956
973
|
broker.cancel('_activity-execution');
|
|
957
974
|
this[kConsuming] = false;
|
|
958
975
|
};
|
|
@@ -412,7 +412,6 @@ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(rout
|
|
|
412
412
|
}
|
|
413
413
|
case 'process.error':
|
|
414
414
|
{
|
|
415
|
-
// message.ack();
|
|
416
415
|
if (inbound && inbound.length) {
|
|
417
416
|
const calledFrom = inbound[0];
|
|
418
417
|
this._getProcessApi({
|
|
@@ -428,6 +427,7 @@ DefinitionExecution.prototype._onProcessMessage = function onProcessMessage(rout
|
|
|
428
427
|
for (const bp of this[kProcesses].running.slice()) {
|
|
429
428
|
if (bp.id !== childId) bp.stop();
|
|
430
429
|
}
|
|
430
|
+
Object.assign(this.environment.output, content.output);
|
|
431
431
|
this._complete('error', {
|
|
432
432
|
error: content.error
|
|
433
433
|
});
|
package/dist/error/Errors.js
CHANGED
|
@@ -23,7 +23,12 @@ class ActivityError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.ActivityError = ActivityError;
|
|
26
|
-
class RunError extends ActivityError {
|
|
26
|
+
class RunError extends ActivityError {
|
|
27
|
+
constructor(...args) {
|
|
28
|
+
super(...args);
|
|
29
|
+
this.type = 'RunError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
27
32
|
exports.RunError = RunError;
|
|
28
33
|
class BpmnError extends Error {
|
|
29
34
|
constructor(description, behaviour = {}, sourceMessage, inner) {
|
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = TimerEventDefinition;
|
|
7
7
|
var _messageHelper = require("../messageHelper.js");
|
|
8
|
-
var
|
|
8
|
+
var _piso = require("@0dep/piso");
|
|
9
9
|
const kStopped = Symbol.for('stopped');
|
|
10
10
|
const kTimerContent = Symbol.for('timerContent');
|
|
11
11
|
const kTimer = Symbol.for('timer');
|
|
12
|
+
const timerTypes = ['timeDuration', 'timeDate', 'timeCycle'];
|
|
12
13
|
function TimerEventDefinition(activity, eventDefinition) {
|
|
13
14
|
const type = this.type = eventDefinition.type || 'TimerEventDefinition';
|
|
14
15
|
this.activity = activity;
|
|
@@ -81,7 +82,6 @@ TimerEventDefinition.prototype.execute = function execute(executeMessage) {
|
|
|
81
82
|
broker.publish('execution', 'execute.timer', (0, _messageHelper.cloneContent)(timerContent));
|
|
82
83
|
broker.publish('event', 'activity.timer', (0, _messageHelper.cloneContent)(timerContent));
|
|
83
84
|
if (this.stopped) return;
|
|
84
|
-
if (timerContent.timeout === undefined) return this._debug(`waiting for ${timerContent.timerType || 'signal'}`);
|
|
85
85
|
if (timerContent.timeout <= 0) return this._completed();
|
|
86
86
|
const timers = this.environment.timers.register(timerContent);
|
|
87
87
|
const delay = timerContent.timeout;
|
|
@@ -191,25 +191,21 @@ TimerEventDefinition.prototype._stop = function stop() {
|
|
|
191
191
|
};
|
|
192
192
|
TimerEventDefinition.prototype.parse = function parse(timerType, value) {
|
|
193
193
|
let repeat, delay, expireAt;
|
|
194
|
+
const now = new Date();
|
|
194
195
|
switch (timerType) {
|
|
195
196
|
case 'timeCycle':
|
|
196
197
|
case 'timeDuration':
|
|
197
198
|
{
|
|
198
|
-
const parsed =
|
|
199
|
+
const parsed = new _piso.ISOInterval(value).parse();
|
|
199
200
|
if (parsed.repeat) repeat = parsed.repeat;
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
expireAt = parsed.getExpireAt(now, now);
|
|
202
|
+
delay = expireAt.getTime() - now.getTime();
|
|
202
203
|
break;
|
|
203
204
|
}
|
|
204
205
|
case 'timeDate':
|
|
205
206
|
{
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
expireAt = new Date(ms);
|
|
209
|
-
delay = Date.now() - expireAt;
|
|
210
|
-
} else {
|
|
211
|
-
throw new TypeError(`invalid timeDate >${value}<`);
|
|
212
|
-
}
|
|
207
|
+
expireAt = (0, _piso.getDate)(value);
|
|
208
|
+
delay = now.getTime() - expireAt;
|
|
213
209
|
break;
|
|
214
210
|
}
|
|
215
211
|
}
|
|
@@ -226,28 +222,22 @@ TimerEventDefinition.prototype._getTimers = function getTimers(executeMessage) {
|
|
|
226
222
|
expireAt: new Date(content.expireAt)
|
|
227
223
|
})
|
|
228
224
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (t in content) result[t] = content[t];else if (t in this) result[t] = this.environment.resolveExpression(this[t], executeMessage);else continue;
|
|
225
|
+
for (const timerType of timerTypes) {
|
|
226
|
+
if (timerType in content) result[timerType] = content[timerType];else if (timerType in this) result[timerType] = this.environment.resolveExpression(this[timerType], executeMessage);else continue;
|
|
232
227
|
let expireAtDate, repeat;
|
|
233
|
-
const timerStr = result[
|
|
228
|
+
const timerStr = result[timerType];
|
|
234
229
|
if (timerStr) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
expireAtDate = parsedExpireAt;
|
|
242
|
-
} catch (err) {
|
|
243
|
-
parseErr = err;
|
|
244
|
-
}
|
|
230
|
+
const {
|
|
231
|
+
repeat: parsedRepeat,
|
|
232
|
+
expireAt: parsedExpireAt
|
|
233
|
+
} = this.parse(timerType, timerStr);
|
|
234
|
+
repeat = parsedRepeat;
|
|
235
|
+
expireAtDate = parsedExpireAt;
|
|
245
236
|
} else {
|
|
246
237
|
expireAtDate = new Date();
|
|
247
238
|
}
|
|
248
|
-
if (!expireAtDate) continue;
|
|
249
239
|
if (!('expireAt' in result) || result.expireAt > expireAtDate) {
|
|
250
|
-
result.timerType =
|
|
240
|
+
result.timerType = timerType;
|
|
251
241
|
result.expireAt = expireAtDate;
|
|
252
242
|
result.repeat = repeat;
|
|
253
243
|
}
|
|
@@ -259,9 +249,6 @@ TimerEventDefinition.prototype._getTimers = function getTimers(executeMessage) {
|
|
|
259
249
|
} else if (!Object.keys(result).length) {
|
|
260
250
|
result.timeout = 0;
|
|
261
251
|
}
|
|
262
|
-
if (!('timeout' in result) && parseErr) {
|
|
263
|
-
this.logger.warn(`<${this.activity.id}> failed to parse timer: ${parseErr.message}`);
|
|
264
|
-
}
|
|
265
252
|
if (content.inbound && 'repeat' in content.inbound[0]) {
|
|
266
253
|
result.repeat = content.inbound[0].repeat;
|
|
267
254
|
}
|
package/dist/getPropertyValue.js
CHANGED
|
@@ -48,7 +48,6 @@ function executeFn(fn, args, base, fnScope) {
|
|
|
48
48
|
}
|
|
49
49
|
if (!fnScope) return fn.apply(null, callArguments);
|
|
50
50
|
return function ScopedIIFE() {
|
|
51
|
-
// eslint-disable-line no-extra-parens
|
|
52
51
|
return fn.apply(this, callArguments);
|
|
53
52
|
}.call(fnScope);
|
|
54
53
|
}
|
|
@@ -65,7 +64,7 @@ function splitArguments(args, base, fnScope) {
|
|
|
65
64
|
argCompleted = true;
|
|
66
65
|
} else if (charPos !== ' ') {
|
|
67
66
|
arg += charPos;
|
|
68
|
-
if (charPos === '
|
|
67
|
+
if (charPos === "'" || charPos === '"') {
|
|
69
68
|
insideString = true;
|
|
70
69
|
delimiter = charPos;
|
|
71
70
|
}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "Activity", {
|
|
|
9
9
|
return _Activity.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "ActivityError", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Errors.ActivityError;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "Association", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function () {
|
|
@@ -147,7 +153,6 @@ Object.defineProperty(exports, "Group", {
|
|
|
147
153
|
return _Dummy.default;
|
|
148
154
|
}
|
|
149
155
|
});
|
|
150
|
-
exports.ISODuration = void 0;
|
|
151
156
|
Object.defineProperty(exports, "InclusiveGateway", {
|
|
152
157
|
enumerable: true,
|
|
153
158
|
get: function () {
|
|
@@ -238,6 +243,12 @@ Object.defineProperty(exports, "ReceiveTask", {
|
|
|
238
243
|
return _ReceiveTask.default;
|
|
239
244
|
}
|
|
240
245
|
});
|
|
246
|
+
Object.defineProperty(exports, "RunError", {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: function () {
|
|
249
|
+
return _Errors.RunError;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
241
252
|
Object.defineProperty(exports, "ScriptTask", {
|
|
242
253
|
enumerable: true,
|
|
243
254
|
get: function () {
|
|
@@ -396,8 +407,5 @@ var _TerminateEventDefinition = _interopRequireDefault(require("./eventDefinitio
|
|
|
396
407
|
var _TimerEventDefinition = _interopRequireDefault(require("./eventDefinitions/TimerEventDefinition.js"));
|
|
397
408
|
var _Transaction = _interopRequireDefault(require("./tasks/Transaction.js"));
|
|
398
409
|
var _Timers = require("./Timers.js");
|
|
399
|
-
var
|
|
400
|
-
exports.ISODuration = ISODuration;
|
|
401
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
402
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
410
|
+
var _Errors = require("./error/Errors.js");
|
|
403
411
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-elements",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "Executable workflow elements based on BPMN 2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "mocha -R @bonniernews/hot-bev -p -t 3000",
|
|
35
35
|
"posttest": "npm run lint && npm run dist",
|
|
36
|
-
"lint": "eslint . --cache",
|
|
36
|
+
"lint": "eslint . --cache && prettier . --check --cache",
|
|
37
37
|
"prepack": "npm run dist",
|
|
38
38
|
"cov:html": "c8 -r html -r text mocha -R @bonniernews/hot-bev -p -t 3000",
|
|
39
39
|
"test:lcov": "c8 -r lcov mocha && npm run lint",
|
|
@@ -64,27 +64,29 @@
|
|
|
64
64
|
],
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@aircall/expression-parser": "^1.0.4",
|
|
67
|
-
"@babel/cli": "^7.
|
|
68
|
-
"@babel/core": "^7.
|
|
69
|
-
"@babel/preset-env": "^7.
|
|
67
|
+
"@babel/cli": "^7.24.1",
|
|
68
|
+
"@babel/core": "^7.24.4",
|
|
69
|
+
"@babel/preset-env": "^7.24.4",
|
|
70
70
|
"@babel/register": "^7.23.7",
|
|
71
71
|
"@bonniernews/hot-bev": "^0.4.0",
|
|
72
|
-
"@types/node": "^16.18.
|
|
73
|
-
"bpmn-moddle": "^
|
|
72
|
+
"@types/node": "^16.18.95",
|
|
73
|
+
"bpmn-moddle": "^9.0.1",
|
|
74
74
|
"c8": "^9.1.0",
|
|
75
75
|
"camunda-bpmn-moddle": "^7.0.1",
|
|
76
|
-
"chai": "^5.0
|
|
76
|
+
"chai": "^5.1.0",
|
|
77
77
|
"chronokinesis": "^6.0.0",
|
|
78
78
|
"debug": "^4.3.4",
|
|
79
|
-
"eslint": "^
|
|
80
|
-
"
|
|
81
|
-
"got": "^14.2.
|
|
82
|
-
"mocha": "^10.
|
|
79
|
+
"eslint": "^9.0.0",
|
|
80
|
+
"globals": "^15.0.0",
|
|
81
|
+
"got": "^14.2.1",
|
|
82
|
+
"mocha": "^10.4.0",
|
|
83
83
|
"mocha-cakes-2": "^3.3.0",
|
|
84
84
|
"moddle-context-serializer": "^4.1.2",
|
|
85
|
-
"nock": "^13.5.
|
|
85
|
+
"nock": "^13.5.3",
|
|
86
|
+
"prettier": "^3.2.5"
|
|
86
87
|
},
|
|
87
88
|
"dependencies": {
|
|
88
|
-
"
|
|
89
|
+
"@0dep/piso": "^0.1.3",
|
|
90
|
+
"smqp": "^8.2.4"
|
|
89
91
|
}
|
|
90
92
|
}
|
package/src/Api.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {cloneMessage} from './messageHelper.js';
|
|
2
|
-
import {getUniqueId} from './shared.js';
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
ActivityApi,
|
|
6
|
-
DefinitionApi,
|
|
7
|
-
ProcessApi,
|
|
8
|
-
FlowApi,
|
|
9
|
-
Api,
|
|
10
|
-
};
|
|
1
|
+
import { cloneMessage } from './messageHelper.js';
|
|
2
|
+
import { getUniqueId } from './shared.js';
|
|
3
|
+
|
|
4
|
+
export { ActivityApi, DefinitionApi, ProcessApi, FlowApi, Api };
|
|
11
5
|
|
|
12
6
|
function ActivityApi(broker, apiMessage, environment) {
|
|
13
7
|
return new Api('activity', broker, apiMessage, environment);
|
|
@@ -30,7 +24,7 @@ function Api(pfx, broker, sourceMessage, environment) {
|
|
|
30
24
|
|
|
31
25
|
const apiMessage = cloneMessage(sourceMessage);
|
|
32
26
|
|
|
33
|
-
const {id, type, name, executionId} = apiMessage.content;
|
|
27
|
+
const { id, type, name, executionId } = apiMessage.content;
|
|
34
28
|
this.id = id;
|
|
35
29
|
this.type = type;
|
|
36
30
|
this.name = name;
|
|
@@ -45,7 +39,7 @@ function Api(pfx, broker, sourceMessage, environment) {
|
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
Api.prototype.cancel = function cancel(message, options) {
|
|
48
|
-
this.sendApiMessage('cancel', {message}, options);
|
|
42
|
+
this.sendApiMessage('cancel', { message }, options);
|
|
49
43
|
};
|
|
50
44
|
|
|
51
45
|
Api.prototype.discard = function discard() {
|
|
@@ -53,11 +47,11 @@ Api.prototype.discard = function discard() {
|
|
|
53
47
|
};
|
|
54
48
|
|
|
55
49
|
Api.prototype.fail = function fail(error) {
|
|
56
|
-
this.sendApiMessage('error', {error});
|
|
50
|
+
this.sendApiMessage('error', { error });
|
|
57
51
|
};
|
|
58
52
|
|
|
59
53
|
Api.prototype.signal = function signal(message, options) {
|
|
60
|
-
this.sendApiMessage('signal', {message}, options);
|
|
54
|
+
this.sendApiMessage('signal', { message }, options);
|
|
61
55
|
};
|
|
62
56
|
|
|
63
57
|
Api.prototype.stop = function stop() {
|
|
@@ -65,18 +59,22 @@ Api.prototype.stop = function stop() {
|
|
|
65
59
|
};
|
|
66
60
|
|
|
67
61
|
Api.prototype.resolveExpression = function resolveExpression(expression) {
|
|
68
|
-
return this.environment.resolveExpression(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
return this.environment.resolveExpression(
|
|
63
|
+
expression,
|
|
64
|
+
{
|
|
65
|
+
fields: this.fields,
|
|
66
|
+
content: this.content,
|
|
67
|
+
properties: this.messageProperties,
|
|
68
|
+
},
|
|
69
|
+
this.owner,
|
|
70
|
+
);
|
|
73
71
|
};
|
|
74
72
|
|
|
75
73
|
Api.prototype.sendApiMessage = function sendApiMessage(action, content, options) {
|
|
76
74
|
const correlationId = (options && options.correlationId) || getUniqueId(`${this.id || this.messagePrefix}_signal`);
|
|
77
75
|
let key = `${this.messagePrefix}.${action}`;
|
|
78
76
|
if (this.executionId) key += `.${this.executionId}`;
|
|
79
|
-
this.broker.publish('api', key, this.createMessage(content), {...options, correlationId, type: action});
|
|
77
|
+
this.broker.publish('api', key, this.createMessage(content), { ...options, correlationId, type: action });
|
|
80
78
|
};
|
|
81
79
|
|
|
82
80
|
Api.prototype.getPostponed = function getPostponed(...args) {
|
package/src/Context.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import BpmnIO from './io/BpmnIO.js';
|
|
2
2
|
import Environment from './Environment.js';
|
|
3
|
-
import
|
|
4
|
-
import {getUniqueId} from './shared.js';
|
|
3
|
+
import { getUniqueId } from './shared.js';
|
|
5
4
|
|
|
6
5
|
const kOwner = Symbol.for('owner');
|
|
6
|
+
const kActivated = Symbol.for('activated');
|
|
7
7
|
|
|
8
8
|
export default function Context(definitionContext, environment) {
|
|
9
9
|
environment = environment ? environment.clone() : new Environment();
|
|
@@ -11,7 +11,7 @@ export default function Context(definitionContext, environment) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function ContextInstance(definitionContext, environment, owner) {
|
|
14
|
-
const {id = 'Def', name, type = 'context'} = definitionContext;
|
|
14
|
+
const { id = 'Def', name, type = 'context' } = definitionContext;
|
|
15
15
|
const sid = getUniqueId(id);
|
|
16
16
|
this.id = id;
|
|
17
17
|
this.name = name;
|
|
@@ -148,11 +148,11 @@ ContextInstance.prototype.getNewProcessById = function getNewProcessById(process
|
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
ContextInstance.prototype.getProcesses = function getProcesses() {
|
|
151
|
-
return this.definitionContext.getProcesses().map(({id: processId}) => this.getProcessById(processId));
|
|
151
|
+
return this.definitionContext.getProcesses().map(({ id: processId }) => this.getProcessById(processId));
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
ContextInstance.prototype.getExecutableProcesses = function getExecutableProcesses() {
|
|
155
|
-
return this.definitionContext.getExecutableProcesses().map(({id: processId}) => this.getProcessById(processId));
|
|
155
|
+
return this.definitionContext.getExecutableProcesses().map(({ id: processId }) => this.getProcessById(processId));
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
ContextInstance.prototype.getMessageFlows = function getMessageFlows(sourceId) {
|
|
@@ -180,7 +180,8 @@ ContextInstance.prototype.getDataStoreById = function getDataStoreById(reference
|
|
|
180
180
|
let dataStore;
|
|
181
181
|
if ((dataStore = this.refs.dataStoreRefs[referenceId])) return dataStore;
|
|
182
182
|
|
|
183
|
-
const dataStoreDef =
|
|
183
|
+
const dataStoreDef =
|
|
184
|
+
this.definitionContext.getDataStoreById(referenceId) || this.definitionContext.getDataStoreReferenceById(referenceId);
|
|
184
185
|
if (!dataStoreDef) return;
|
|
185
186
|
|
|
186
187
|
dataStore = this.refs.dataStoreRefs[dataStoreDef.id] = new dataStoreDef.Behaviour(dataStoreDef, this);
|
|
@@ -189,7 +190,7 @@ ContextInstance.prototype.getDataStoreById = function getDataStoreById(reference
|
|
|
189
190
|
};
|
|
190
191
|
|
|
191
192
|
ContextInstance.prototype.getStartActivities = function getStartActivities(filterOptions, scopeId) {
|
|
192
|
-
const {referenceId, referenceType = 'unknown'} = filterOptions || {};
|
|
193
|
+
const { referenceId, referenceType = 'unknown' } = filterOptions || {};
|
|
193
194
|
const result = [];
|
|
194
195
|
for (const activity of this.getActivities()) {
|
|
195
196
|
if (!activity.isStart) continue;
|
|
@@ -224,3 +225,44 @@ ContextInstance.prototype.getActivityParentById = function getActivityParentById
|
|
|
224
225
|
const parentId = activity.parent.id;
|
|
225
226
|
return this.getProcessById(parentId) || this.getActivityById(parentId);
|
|
226
227
|
};
|
|
228
|
+
|
|
229
|
+
function ExtensionsMapper(context) {
|
|
230
|
+
this.context = context;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
ExtensionsMapper.prototype.get = function get(activity) {
|
|
234
|
+
return new Extensions(activity, this.context, this._getExtensions());
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
ExtensionsMapper.prototype._getExtensions = function getExtensions() {
|
|
238
|
+
let extensions;
|
|
239
|
+
if (!(extensions = this.context.environment.extensions)) return [];
|
|
240
|
+
return Object.values(extensions);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
function Extensions(activity, context, extensions) {
|
|
244
|
+
const result = (this.extensions = []);
|
|
245
|
+
for (const Extension of extensions) {
|
|
246
|
+
const extension = Extension(activity, context);
|
|
247
|
+
if (extension) result.push(extension);
|
|
248
|
+
}
|
|
249
|
+
this[kActivated] = false;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
Object.defineProperty(Extensions.prototype, 'count', {
|
|
253
|
+
get() {
|
|
254
|
+
return this.extensions.length;
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
Extensions.prototype.activate = function activate(message) {
|
|
259
|
+
if (this[kActivated]) return;
|
|
260
|
+
this[kActivated] = true;
|
|
261
|
+
for (const extension of this.extensions) extension.activate(message);
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
Extensions.prototype.deactivate = function deactivate(message) {
|
|
265
|
+
if (!this[kActivated]) return;
|
|
266
|
+
this[kActivated] = false;
|
|
267
|
+
for (const extension of this.extensions) extension.deactivate(message);
|
|
268
|
+
};
|