bpmn-elements 16.2.1 → 16.2.2

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.
@@ -3,12 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = getPropertyValue;
7
7
  const propertyPattern = /(\w+)\((.*?)(?:\))|(\.|\[|^)(.+?)(?:\]|\[|\.|$)/;
8
8
  const stringConstantPattern = /^(['"])(.*)\1$/;
9
9
  const numberConstantPattern = /^\W*-?\d+(.\d+)?\W*$/;
10
10
  const negativeIndexPattern = /^-\d+$/;
11
- var _default = exports.default = getPropertyValue;
12
11
  function getPropertyValue(inputContext, propertyPath, fnScope) {
13
12
  if (!inputContext) return;
14
13
  let resultValue;
@@ -52,7 +52,11 @@ CallActivityBehaviour.prototype.execute = function execute(executeMessage) {
52
52
  });
53
53
  broker.subscribeTmp('api', '#.signal.*', (...args) => this._onDelegatedApiMessage(calledElement, executeMessage, ...args), {
54
54
  noAck: true,
55
- consumerTag: `_api-delegated-${executionId}`
55
+ consumerTag: `_api-delegated-signal-${executionId}`
56
+ });
57
+ broker.subscribeTmp('api', '#.cancel.*', (...args) => this._onDelegatedApiMessage(calledElement, executeMessage, ...args), {
58
+ noAck: true,
59
+ consumerTag: `_api-delegated-cancel-${executionId}`
56
60
  });
57
61
  broker.publish('event', 'activity.call', (0, _messageHelper.cloneContent)(executeContent, {
58
62
  state: 'wait',
@@ -134,5 +138,6 @@ CallActivityBehaviour.prototype._onApiMessage = function onApiMessage(calledElem
134
138
  CallActivityBehaviour.prototype._stop = function stop(executionId) {
135
139
  const broker = this.broker;
136
140
  broker.cancel(`_api-${executionId}`);
137
- broker.cancel(`_api-delegated-${executionId}`);
141
+ broker.cancel(`_api-delegated-signal-${executionId}`);
142
+ broker.cancel(`_api-delegated-cancel-${executionId}`);
138
143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "16.2.1",
3
+ "version": "16.2.2",
4
4
  "description": "Executable workflow elements based on BPMN 2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -85,7 +85,7 @@
85
85
  "@babel/preset-env": "^7.24.4",
86
86
  "@babel/register": "^7.23.7",
87
87
  "@bonniernews/hot-bev": "^0.4.0",
88
- "@types/node": "^16.18.95",
88
+ "@types/node": "^18.19.63",
89
89
  "bpmn-moddle": "^9.0.1",
90
90
  "c8": "^10.1.1",
91
91
  "camunda-bpmn-moddle": "^7.0.1",
@@ -95,7 +95,7 @@
95
95
  "eslint": "^9.0.0",
96
96
  "globals": "^15.0.0",
97
97
  "got": "^14.2.1",
98
- "mocha": "^10.4.0",
98
+ "mocha": "^11.0.1",
99
99
  "mocha-cakes-2": "^3.3.0",
100
100
  "moddle-context-serializer": "^4.2.1",
101
101
  "nock": "^13.5.3",
@@ -103,7 +103,7 @@
103
103
  "texample": "^0.0.6"
104
104
  },
105
105
  "dependencies": {
106
- "@0dep/piso": "^2.2.0",
107
- "smqp": "^9.0.2"
106
+ "@0dep/piso": "^2.4.0",
107
+ "smqp": "^9.0.4"
108
108
  }
109
109
  }
package/src/Api.js CHANGED
@@ -1,25 +1,23 @@
1
1
  import { cloneMessage } from './messageHelper.js';
2
2
  import { getUniqueId } from './shared.js';
3
3
 
4
- export { ActivityApi, DefinitionApi, ProcessApi, FlowApi, Api };
5
-
6
- function ActivityApi(broker, apiMessage, environment) {
4
+ export function ActivityApi(broker, apiMessage, environment) {
7
5
  return new Api('activity', broker, apiMessage, environment);
8
6
  }
9
7
 
10
- function DefinitionApi(broker, apiMessage, environment) {
8
+ export function DefinitionApi(broker, apiMessage, environment) {
11
9
  return new Api('definition', broker, apiMessage, environment);
12
10
  }
13
11
 
14
- function ProcessApi(broker, apiMessage, environment) {
12
+ export function ProcessApi(broker, apiMessage, environment) {
15
13
  return new Api('process', broker, apiMessage, environment);
16
14
  }
17
15
 
18
- function FlowApi(broker, apiMessage, environment) {
16
+ export function FlowApi(broker, apiMessage, environment) {
19
17
  return new Api('flow', broker, apiMessage, environment);
20
18
  }
21
19
 
22
- function Api(pfx, broker, sourceMessage, environment) {
20
+ export function Api(pfx, broker, sourceMessage, environment) {
23
21
  if (!sourceMessage) throw new Error('Api requires message');
24
22
 
25
23
  const apiMessage = cloneMessage(sourceMessage);
@@ -1,25 +1,23 @@
1
1
  import { Broker } from 'smqp';
2
2
  import { makeErrorFromMessage } from './error/Errors.js';
3
3
 
4
- export { ActivityBroker, DefinitionBroker, MessageFlowBroker, ProcessBroker, EventBroker };
5
-
6
- function ActivityBroker(activity) {
4
+ export function ActivityBroker(activity) {
7
5
  const executionBroker = ExecutionBroker(activity, 'activity');
8
6
  return executionBroker;
9
7
  }
10
8
 
11
- function ProcessBroker(owner) {
9
+ export function ProcessBroker(owner) {
12
10
  const executionBroker = ExecutionBroker(owner, 'process');
13
11
  executionBroker.broker.assertQueue('api-q', { durable: false, autoDelete: false });
14
12
  executionBroker.broker.bindQueue('api-q', 'api', '#');
15
13
  return executionBroker;
16
14
  }
17
15
 
18
- function DefinitionBroker(owner, onBrokerReturn) {
16
+ export function DefinitionBroker(owner, onBrokerReturn) {
19
17
  return ExecutionBroker(owner, 'definition', onBrokerReturn);
20
18
  }
21
19
 
22
- function MessageFlowBroker(owner) {
20
+ export function MessageFlowBroker(owner) {
23
21
  const eventBroker = new EventBroker(owner, { prefix: 'messageflow', autoDelete: false, durable: false });
24
22
  const broker = eventBroker.broker;
25
23
 
@@ -51,7 +49,7 @@ function ExecutionBroker(brokerOwner, prefix, onBrokerReturn) {
51
49
  return eventBroker;
52
50
  }
53
51
 
54
- function EventBroker(brokerOwner, options, onBrokerReturn) {
52
+ export function EventBroker(brokerOwner, options, onBrokerReturn) {
55
53
  this.options = options;
56
54
  this.eventPrefix = options.prefix;
57
55
 
@@ -6,9 +6,7 @@ import { getRoutingKeyPattern } from 'smqp';
6
6
  const kOnMessage = Symbol.for('onMessage');
7
7
  const kExecution = Symbol.for('execution');
8
8
 
9
- export { Formatter };
10
-
11
- function Formatter(element, formatQ) {
9
+ export function Formatter(element, formatQ) {
12
10
  const { id, broker, logger } = element;
13
11
  this.id = id;
14
12
  this.broker = broker;
@@ -1,6 +1,6 @@
1
1
  import { cloneMessage } from '../messageHelper.js';
2
2
 
3
- class ActivityError extends Error {
3
+ export class ActivityError extends Error {
4
4
  constructor(description, sourceMessage, inner) {
5
5
  super(description);
6
6
  this.type = 'ActivityError';
@@ -15,14 +15,14 @@ class ActivityError extends Error {
15
15
  }
16
16
  }
17
17
 
18
- class RunError extends ActivityError {
18
+ export class RunError extends ActivityError {
19
19
  constructor(...args) {
20
20
  super(...args);
21
21
  this.type = 'RunError';
22
22
  }
23
23
  }
24
24
 
25
- class BpmnError extends Error {
25
+ export class BpmnError extends Error {
26
26
  constructor(description, behaviour, sourceMessage, inner) {
27
27
  super(description);
28
28
  this.type = 'BpmnError';
@@ -35,9 +35,7 @@ class BpmnError extends Error {
35
35
  }
36
36
  }
37
37
 
38
- export { ActivityError, BpmnError, RunError, makeErrorFromMessage };
39
-
40
- function makeErrorFromMessage(errorMessage) {
38
+ export function makeErrorFromMessage(errorMessage) {
41
39
  const { content } = errorMessage;
42
40
 
43
41
  if (isKnownError(content)) return content;
@@ -3,9 +3,7 @@ const stringConstantPattern = /^(['"])(.*)\1$/;
3
3
  const numberConstantPattern = /^\W*-?\d+(.\d+)?\W*$/;
4
4
  const negativeIndexPattern = /^-\d+$/;
5
5
 
6
- export default getPropertyValue;
7
-
8
- function getPropertyValue(inputContext, propertyPath, fnScope) {
6
+ export default function getPropertyValue(inputContext, propertyPath, fnScope) {
9
7
  if (!inputContext) return;
10
8
 
11
9
  let resultValue;
@@ -1,6 +1,4 @@
1
- export { cloneContent, cloneMessage, cloneParent, shiftParent, unshiftParent, pushParent };
2
-
3
- function cloneContent(content, extend) {
1
+ export function cloneContent(content, extend) {
4
2
  const { discardSequence, inbound, outbound, parent, sequence } = content;
5
3
 
6
4
  const clone = {
@@ -27,7 +25,7 @@ function cloneContent(content, extend) {
27
25
  return clone;
28
26
  }
29
27
 
30
- function cloneMessage(message, overrideContent) {
28
+ export function cloneMessage(message, overrideContent) {
31
29
  return {
32
30
  fields: { ...message.fields },
33
31
  content: cloneContent(message.content, overrideContent),
@@ -35,7 +33,7 @@ function cloneMessage(message, overrideContent) {
35
33
  };
36
34
  }
37
35
 
38
- function cloneParent(parent) {
36
+ export function cloneParent(parent) {
39
37
  const { path } = parent;
40
38
  const clone = { ...parent };
41
39
  if (!path) return clone;
@@ -47,7 +45,7 @@ function cloneParent(parent) {
47
45
  return clone;
48
46
  }
49
47
 
50
- function unshiftParent(parent, adoptingParent) {
48
+ export function unshiftParent(parent, adoptingParent) {
51
49
  const { id, type, executionId } = adoptingParent;
52
50
  if (!parent) {
53
51
  return {
@@ -69,7 +67,7 @@ function unshiftParent(parent, adoptingParent) {
69
67
  return clone;
70
68
  }
71
69
 
72
- function shiftParent(parent) {
70
+ export function shiftParent(parent) {
73
71
  if (!parent) return;
74
72
  if (!parent.path || !parent.path.length) return;
75
73
 
@@ -82,7 +80,7 @@ function shiftParent(parent) {
82
80
  return clone;
83
81
  }
84
82
 
85
- function pushParent(parent, ancestor) {
83
+ export function pushParent(parent, ancestor) {
86
84
  const { id, type, executionId } = ancestor;
87
85
  if (!parent) return { id, type, executionId };
88
86
 
@@ -8,7 +8,6 @@ export default function CallActivity(activityDef, context) {
8
8
 
9
9
  export function CallActivityBehaviour(activity) {
10
10
  const { id, type, behaviour = {} } = activity;
11
-
12
11
  this.id = id;
13
12
  this.type = type;
14
13
  this.calledElement = behaviour.calledElement;
@@ -60,7 +59,11 @@ CallActivityBehaviour.prototype.execute = function execute(executeMessage) {
60
59
  );
61
60
  broker.subscribeTmp('api', '#.signal.*', (...args) => this._onDelegatedApiMessage(calledElement, executeMessage, ...args), {
62
61
  noAck: true,
63
- consumerTag: `_api-delegated-${executionId}`,
62
+ consumerTag: `_api-delegated-signal-${executionId}`,
63
+ });
64
+ broker.subscribeTmp('api', '#.cancel.*', (...args) => this._onDelegatedApiMessage(calledElement, executeMessage, ...args), {
65
+ noAck: true,
66
+ consumerTag: `_api-delegated-cancel-${executionId}`,
64
67
  });
65
68
 
66
69
  broker.publish(
@@ -176,5 +179,6 @@ CallActivityBehaviour.prototype._onApiMessage = function onApiMessage(calledElem
176
179
  CallActivityBehaviour.prototype._stop = function stop(executionId) {
177
180
  const broker = this.broker;
178
181
  broker.cancel(`_api-${executionId}`);
179
- broker.cancel(`_api-delegated-${executionId}`);
182
+ broker.cancel(`_api-delegated-signal-${executionId}`);
183
+ broker.cancel(`_api-delegated-cancel-${executionId}`);
180
184
  };