bpmn-elements 17.2.1 → 17.3.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.
@@ -86,7 +86,7 @@ function Activity(Behaviour, activityDef, context) {
86
86
  }
87
87
  const outboundSequenceFlows = context.getOutboundSequenceFlows(id);
88
88
  const isParallelJoin = activityDef.isParallelGateway && inboundSequenceFlows.length > 1;
89
- const flows = this[kFlows] = {
89
+ this[kFlows] = {
90
90
  inboundSequenceFlows,
91
91
  inboundAssociations,
92
92
  inboundTriggers,
@@ -100,8 +100,8 @@ function Activity(Behaviour, activityDef, context) {
100
100
  })
101
101
  };
102
102
  this[kFlags] = {
103
- isEnd: flows.outboundSequenceFlows.length === 0,
104
- isStart: flows.inboundSequenceFlows.length === 0 && !attachedTo && !behaviour.triggeredByEvent && !isForCompensation,
103
+ isEnd: !outboundSequenceFlows.length,
104
+ isStart: !inboundTriggers.length && !behaviour.triggeredByEvent,
105
105
  isSubProcess: activityDef.isSubProcess,
106
106
  isMultiInstance: !!behaviour.loopCharacteristics,
107
107
  isForCompensation,
@@ -245,8 +245,7 @@ Object.defineProperties(Activity.prototype, {
245
245
  Activity.prototype.activate = function activate() {
246
246
  if (this[kActivated]) return;
247
247
  this[kActivated] = true;
248
- this.addInboundListeners();
249
- return this._consumeInbound();
248
+ return this.addInboundListeners() && this._consumeInbound();
250
249
  };
251
250
  Activity.prototype.deactivate = function deactivate() {
252
251
  this[kActivated] = false;
@@ -349,26 +348,30 @@ Activity.prototype.discard = function discard(discardContent) {
349
348
  this._consumeRunQ();
350
349
  };
351
350
  Activity.prototype.addInboundListeners = function addInboundListeners() {
352
- const onInboundEvent = this._onInboundEvent.bind(this);
353
- const triggerConsumerTag = `_inbound-${this.id}`;
354
- for (const trigger of this[kFlows].inboundTriggers) {
355
- if (trigger.isSequenceFlow) {
356
- trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {
357
- noAck: true,
358
- consumerTag: triggerConsumerTag
359
- });
360
- } else if (this.isForCompensation) {
361
- trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, {
362
- noAck: true,
363
- consumerTag: triggerConsumerTag
364
- });
365
- } else {
366
- trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {
367
- noAck: true,
368
- consumerTag: triggerConsumerTag
369
- });
351
+ const triggers = this[kFlows].inboundTriggers;
352
+ if (triggers.length) {
353
+ const onInboundEvent = this._onInboundEvent.bind(this);
354
+ const triggerConsumerTag = `_inbound-${this.id}`;
355
+ for (const trigger of triggers) {
356
+ if (trigger.isSequenceFlow) {
357
+ trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, {
358
+ noAck: true,
359
+ consumerTag: triggerConsumerTag
360
+ });
361
+ } else if (this.isForCompensation) {
362
+ trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, {
363
+ noAck: true,
364
+ consumerTag: triggerConsumerTag
365
+ });
366
+ } else {
367
+ trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, {
368
+ noAck: true,
369
+ consumerTag: triggerConsumerTag
370
+ });
371
+ }
370
372
  }
371
373
  }
374
+ return triggers.length;
372
375
  };
373
376
  Activity.prototype.removeInboundListeners = function removeInboundListeners() {
374
377
  const triggerConsumerTag = `_inbound-${this.id}`;
@@ -471,16 +474,16 @@ Activity.prototype._shakeOutbound = function shakeOutbound(sourceMessage) {
471
474
  };
472
475
  Activity.prototype._consumeInbound = function consumeInbound() {
473
476
  if (!this[kActivated]) return;
474
- if (this.status) return;
477
+ if (this.status || !this[kFlows].inboundTriggers.length) return;
475
478
  const inboundQ = this.broker.getQueue('inbound-q');
476
479
  const onInbound = this[kMessageHandlers].onInbound;
477
480
  if (this[kFlags].isParallelJoin) {
478
- return inboundQ.consume(onInbound, {
481
+ return inboundQ.assertConsumer(onInbound, {
479
482
  consumerTag: '_run-on-inbound',
480
483
  prefetch: 1000
481
484
  });
482
485
  }
483
- return inboundQ.consume(onInbound, {
486
+ return inboundQ.assertConsumer(onInbound, {
484
487
  consumerTag: '_run-on-inbound'
485
488
  });
486
489
  };
@@ -76,7 +76,7 @@ function splitArguments(args, base, fnScope) {
76
76
  }
77
77
  }
78
78
  if (argCompleted) {
79
- if (arg.length > 0) {
79
+ if (arg.length) {
80
80
  callArguments.push(getFunctionArgument(base, arg.trim(), fnScope));
81
81
  }
82
82
  arg = '';
@@ -335,7 +335,7 @@ ProcessExecution.prototype.getApi = function getApi(message) {
335
335
  return api;
336
336
  };
337
337
  ProcessExecution.prototype._start = function start() {
338
- if (this[kElements].children.length === 0) {
338
+ if (!this[kElements].children.length) {
339
339
  return this._complete('completed');
340
340
  }
341
341
  this[kStatus] = 'start';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "17.2.1",
3
+ "version": "17.3.0",
4
4
  "description": "Executable workflow elements based on BPMN 2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -89,7 +89,7 @@
89
89
  "bpmn-moddle": "^9.0.1",
90
90
  "c8": "^10.1.1",
91
91
  "camunda-bpmn-moddle": "^7.0.1",
92
- "chai": "^5.1.0",
92
+ "chai": "^6.2.1",
93
93
  "chronokinesis": "^7.0.0",
94
94
  "debug": "^4.3.4",
95
95
  "eslint": "^9.0.0",
@@ -99,10 +99,10 @@
99
99
  "moddle-context-serializer": "^4.2.1",
100
100
  "nock": "^14.0.0",
101
101
  "prettier": "^3.2.5",
102
- "texample": "^0.0.8"
102
+ "texample": "^0.1.0"
103
103
  },
104
104
  "dependencies": {
105
105
  "@0dep/piso": "^3.0.1",
106
- "smqp": "^10.0.0"
106
+ "smqp": "^11.0.1"
107
107
  }
108
108
  }
@@ -72,7 +72,7 @@ function Activity(Behaviour, activityDef, context) {
72
72
 
73
73
  const isParallelJoin = activityDef.isParallelGateway && inboundSequenceFlows.length > 1;
74
74
 
75
- const flows = (this[kFlows] = {
75
+ this[kFlows] = {
76
76
  inboundSequenceFlows,
77
77
  inboundAssociations,
78
78
  inboundTriggers,
@@ -82,11 +82,11 @@ function Activity(Behaviour, activityDef, context) {
82
82
  inboundJoinFlows: new Set(),
83
83
  inboundSourceIds: new Set(inboundSequenceFlows.map(({ sourceId }) => sourceId)),
84
84
  }),
85
- });
85
+ };
86
86
 
87
87
  this[kFlags] = {
88
- isEnd: flows.outboundSequenceFlows.length === 0,
89
- isStart: flows.inboundSequenceFlows.length === 0 && !attachedTo && !behaviour.triggeredByEvent && !isForCompensation,
88
+ isEnd: !outboundSequenceFlows.length,
89
+ isStart: !inboundTriggers.length && !behaviour.triggeredByEvent,
90
90
  isSubProcess: activityDef.isSubProcess,
91
91
  isMultiInstance: !!behaviour.loopCharacteristics,
92
92
  isForCompensation,
@@ -233,8 +233,7 @@ Object.defineProperties(Activity.prototype, {
233
233
  Activity.prototype.activate = function activate() {
234
234
  if (this[kActivated]) return;
235
235
  this[kActivated] = true;
236
- this.addInboundListeners();
237
- return this._consumeInbound();
236
+ return this.addInboundListeners() && this._consumeInbound();
238
237
  };
239
238
 
240
239
  Activity.prototype.deactivate = function deactivate() {
@@ -346,17 +345,21 @@ Activity.prototype.discard = function discard(discardContent) {
346
345
  };
347
346
 
348
347
  Activity.prototype.addInboundListeners = function addInboundListeners() {
349
- const onInboundEvent = this._onInboundEvent.bind(this);
350
- const triggerConsumerTag = `_inbound-${this.id}`;
351
- for (const trigger of this[kFlows].inboundTriggers) {
352
- if (trigger.isSequenceFlow) {
353
- trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
354
- } else if (this.isForCompensation) {
355
- trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
356
- } else {
357
- trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
348
+ const triggers = this[kFlows].inboundTriggers;
349
+ if (triggers.length) {
350
+ const onInboundEvent = this._onInboundEvent.bind(this);
351
+ const triggerConsumerTag = `_inbound-${this.id}`;
352
+ for (const trigger of triggers) {
353
+ if (trigger.isSequenceFlow) {
354
+ trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
355
+ } else if (this.isForCompensation) {
356
+ trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
357
+ } else {
358
+ trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
359
+ }
358
360
  }
359
361
  }
362
+ return triggers.length;
360
363
  };
361
364
 
362
365
  Activity.prototype.removeInboundListeners = function removeInboundListeners() {
@@ -466,16 +469,16 @@ Activity.prototype._shakeOutbound = function shakeOutbound(sourceMessage) {
466
469
  Activity.prototype._consumeInbound = function consumeInbound() {
467
470
  if (!this[kActivated]) return;
468
471
 
469
- if (this.status) return;
472
+ if (this.status || !this[kFlows].inboundTriggers.length) return;
470
473
 
471
474
  const inboundQ = this.broker.getQueue('inbound-q');
472
475
  const onInbound = this[kMessageHandlers].onInbound;
473
476
 
474
477
  if (this[kFlags].isParallelJoin) {
475
- return inboundQ.consume(onInbound, { consumerTag: '_run-on-inbound', prefetch: 1000 });
478
+ return inboundQ.assertConsumer(onInbound, { consumerTag: '_run-on-inbound', prefetch: 1000 });
476
479
  }
477
480
 
478
- return inboundQ.consume(onInbound, { consumerTag: '_run-on-inbound' });
481
+ return inboundQ.assertConsumer(onInbound, { consumerTag: '_run-on-inbound' });
479
482
  };
480
483
 
481
484
  Activity.prototype._onInbound = function onInbound(routingKey, message) {
@@ -86,7 +86,7 @@ function splitArguments(args, base, fnScope) {
86
86
  }
87
87
 
88
88
  if (argCompleted) {
89
- if (arg.length > 0) {
89
+ if (arg.length) {
90
90
  callArguments.push(getFunctionArgument(base, arg.trim(), fnScope));
91
91
  }
92
92
  arg = '';
@@ -359,7 +359,7 @@ ProcessExecution.prototype.getApi = function getApi(message) {
359
359
  };
360
360
 
361
361
  ProcessExecution.prototype._start = function start() {
362
- if (this[kElements].children.length === 0) {
362
+ if (!this[kElements].children.length) {
363
363
  return this._complete('completed');
364
364
  }
365
365