bpmn-elements 8.2.0 → 8.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +0 -49
  3. package/dist/src/Api.js +4 -19
  4. package/dist/src/Context.js +0 -35
  5. package/dist/src/Environment.js +18 -44
  6. package/dist/src/EventBroker.js +8 -27
  7. package/dist/src/Expressions.js +0 -13
  8. package/dist/src/ExtensionsMapper.js +0 -12
  9. package/dist/src/MessageFormatter.js +0 -33
  10. package/dist/src/Scripts.js +2 -9
  11. package/dist/src/Timers.js +0 -9
  12. package/dist/src/activity/Activity.js +39 -243
  13. package/dist/src/activity/ActivityExecution.js +8 -76
  14. package/dist/src/activity/Dummy.js +2 -3
  15. package/dist/src/activity/Escalation.js +4 -4
  16. package/dist/src/activity/ExecutionScope.js +0 -4
  17. package/dist/src/activity/Message.js +4 -4
  18. package/dist/src/activity/Signal.js +4 -4
  19. package/dist/src/definition/Definition.js +12 -133
  20. package/dist/src/definition/DefinitionExecution.js +10 -160
  21. package/dist/src/error/BpmnError.js +2 -3
  22. package/dist/src/error/Errors.js +0 -16
  23. package/dist/src/eventDefinitions/CancelEventDefinition.js +2 -35
  24. package/dist/src/eventDefinitions/CompensateEventDefinition.js +3 -34
  25. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +3 -42
  26. package/dist/src/eventDefinitions/ErrorEventDefinition.js +11 -41
  27. package/dist/src/eventDefinitions/EscalationEventDefinition.js +7 -37
  28. package/dist/src/eventDefinitions/EventDefinitionExecution.js +0 -30
  29. package/dist/src/eventDefinitions/LinkEventDefinition.js +11 -37
  30. package/dist/src/eventDefinitions/MessageEventDefinition.js +11 -44
  31. package/dist/src/eventDefinitions/SignalEventDefinition.js +9 -46
  32. package/dist/src/eventDefinitions/TerminateEventDefinition.js +0 -3
  33. package/dist/src/eventDefinitions/TimerEventDefinition.js +8 -52
  34. package/dist/src/events/BoundaryEvent.js +4 -44
  35. package/dist/src/events/EndEvent.js +2 -11
  36. package/dist/src/events/IntermediateCatchEvent.js +0 -13
  37. package/dist/src/events/IntermediateThrowEvent.js +2 -11
  38. package/dist/src/events/StartEvent.js +5 -25
  39. package/dist/src/flows/Association.js +4 -27
  40. package/dist/src/flows/MessageFlow.js +6 -18
  41. package/dist/src/flows/SequenceFlow.js +4 -39
  42. package/dist/src/gateways/EventBasedGateway.js +0 -21
  43. package/dist/src/gateways/ExclusiveGateway.js +0 -6
  44. package/dist/src/gateways/InclusiveGateway.js +0 -6
  45. package/dist/src/gateways/ParallelGateway.js +2 -7
  46. package/dist/src/getPropertyValue.js +0 -30
  47. package/dist/src/io/BpmnIO.js +2 -7
  48. package/dist/src/io/EnvironmentDataObject.js +0 -8
  49. package/dist/src/io/EnvironmentDataStore.js +0 -8
  50. package/dist/src/io/EnvironmentDataStoreReference.js +0 -8
  51. package/dist/src/io/InputOutputSpecification.js +12 -37
  52. package/dist/src/io/Properties.js +6 -39
  53. package/dist/src/messageHelper.js +10 -23
  54. package/dist/src/process/Process.js +10 -112
  55. package/dist/src/process/ProcessExecution.js +24 -170
  56. package/dist/src/shared.js +0 -7
  57. package/dist/src/tasks/CallActivity.js +2 -23
  58. package/dist/src/tasks/LoopCharacteristics.js +16 -67
  59. package/dist/src/tasks/ReceiveTask.js +8 -48
  60. package/dist/src/tasks/ScriptTask.js +1 -15
  61. package/dist/src/tasks/ServiceImplementation.js +0 -4
  62. package/dist/src/tasks/ServiceTask.js +0 -20
  63. package/dist/src/tasks/SignalTask.js +2 -21
  64. package/dist/src/tasks/StandardLoopCharacteristics.js +4 -5
  65. package/dist/src/tasks/SubProcess.js +4 -52
  66. package/dist/src/tasks/Task.js +0 -8
  67. package/dist/src/tasks/Transaction.js +0 -3
  68. package/package.json +7 -7
  69. package/src/Context.js +0 -1
  70. package/src/activity/Activity.js +1 -1
  71. package/src/gateways/EventBasedGateway.js +0 -1
  72. package/src/io/InputOutputSpecification.js +0 -1
  73. package/src/process/ProcessExecution.js +8 -1
  74. package/src/tasks/StandardLoopCharacteristics.js +0 -1
@@ -5,49 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SubProcessBehaviour = SubProcessBehaviour;
7
7
  exports.default = SubProcess;
8
-
9
8
  var _Activity = _interopRequireDefault(require("../activity/Activity"));
10
-
11
9
  var _ProcessExecution = _interopRequireDefault(require("../process/ProcessExecution"));
12
-
13
10
  var _messageHelper = require("../messageHelper");
14
-
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
12
  const kExecutions = Symbol.for('executions');
18
13
  const kMessageHandlers = Symbol.for('messageHandlers');
19
-
20
14
  function SubProcess(activityDef, context) {
21
15
  const triggeredByEvent = activityDef.behaviour && activityDef.behaviour.triggeredByEvent;
22
- const subProcess = new _Activity.default(SubProcessBehaviour, { ...activityDef,
16
+ const subProcess = new _Activity.default(SubProcessBehaviour, {
17
+ ...activityDef,
23
18
  isSubProcess: true,
24
19
  triggeredByEvent
25
20
  }, context);
26
-
27
21
  subProcess.getStartActivities = function getStartActivities(filterOptions) {
28
22
  return context.getStartActivities(filterOptions, activityDef.id);
29
23
  };
30
-
31
24
  subProcess.broker.cancel('_api-shake');
32
25
  subProcess.broker.subscribeTmp('api', 'activity.shake.*', onShake, {
33
26
  noAck: true,
34
27
  consumerTag: '_api-shake'
35
28
  });
36
29
  return subProcess;
37
-
38
30
  function onShake(_, message) {
39
31
  const {
40
32
  startId
41
33
  } = message.content;
42
34
  const last = message.content.sequence.pop();
43
35
  const sequence = new _ProcessExecution.default(subProcess, context).shake(startId);
44
- message.content.sequence.push({ ...last,
36
+ message.content.sequence.push({
37
+ ...last,
45
38
  isSubProcess: true,
46
39
  sequence
47
40
  });
48
41
  }
49
42
  }
50
-
51
43
  function SubProcessBehaviour(activity, context) {
52
44
  const {
53
45
  id,
@@ -68,31 +60,24 @@ function SubProcessBehaviour(activity, context) {
68
60
  onExecutionCompleted: this._onExecutionCompleted.bind(this)
69
61
  };
70
62
  }
71
-
72
63
  const proto = SubProcessBehaviour.prototype;
73
64
  Object.defineProperty(proto, 'execution', {
74
65
  get() {
75
66
  return this[kExecutions][0];
76
67
  }
77
-
78
68
  });
79
69
  Object.defineProperty(proto, 'executions', {
80
70
  get() {
81
71
  return this[kExecutions].slice();
82
72
  }
83
-
84
73
  });
85
-
86
74
  proto.execute = function execute(executeMessage) {
87
75
  const content = executeMessage.content;
88
76
  let executionId = this.executionId;
89
-
90
77
  if (content.isRootScope) {
91
78
  executionId = this.executionId = content.executionId;
92
79
  }
93
-
94
80
  const loopCharacteristics = this.loopCharacteristics;
95
-
96
81
  if (loopCharacteristics && content.isRootScope) {
97
82
  this.broker.subscribeTmp('api', `activity.#.${executionId}`, this[kMessageHandlers].onApiRootMessage, {
98
83
  noAck: true,
@@ -101,13 +86,10 @@ proto.execute = function execute(executeMessage) {
101
86
  });
102
87
  return loopCharacteristics.execute(executeMessage);
103
88
  }
104
-
105
89
  const processExecution = this._upsertExecution(executeMessage);
106
-
107
90
  if (!processExecution) return;
108
91
  return processExecution.execute(executeMessage);
109
92
  };
110
-
111
93
  proto.stop = function stop() {
112
94
  for (const execution of this[kExecutions]) {
113
95
  this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
@@ -115,7 +97,6 @@ proto.stop = function stop() {
115
97
  execution.stop();
116
98
  }
117
99
  };
118
-
119
100
  proto.discard = function discard() {
120
101
  for (const execution of this[kExecutions]) {
121
102
  this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
@@ -123,7 +104,6 @@ proto.discard = function discard() {
123
104
  execution.discard();
124
105
  }
125
106
  };
126
-
127
107
  proto.getState = function getState() {
128
108
  if (this.loopCharacteristics) {
129
109
  return {
@@ -134,120 +114,96 @@ proto.getState = function getState() {
134
114
  })
135
115
  };
136
116
  }
137
-
138
117
  const execution = this.execution;
139
-
140
118
  if (execution) {
141
119
  const state = execution.getState();
142
120
  state.environment = execution.environment.getState();
143
121
  return state;
144
122
  }
145
123
  };
146
-
147
124
  proto.recover = function recover(state) {
148
125
  if (!state) return;
149
126
  const executions = this[kExecutions];
150
127
  const loopCharacteristics = this.loopCharacteristics;
151
-
152
128
  if (loopCharacteristics && state.executions) {
153
129
  executions.splice(0);
154
-
155
130
  for (const se of state.executions) {
156
131
  this.recover(se);
157
132
  }
158
-
159
133
  return;
160
134
  }
161
-
162
135
  if (!loopCharacteristics) {
163
136
  executions.splice(0);
164
137
  }
165
-
166
138
  const subEnvironment = this.environment.clone().recover(state.environment);
167
139
  const subContext = this.context.clone(subEnvironment);
168
140
  const execution = new _ProcessExecution.default(this.activity, subContext).recover(state);
169
141
  executions.push(execution);
170
142
  return execution;
171
143
  };
172
-
173
144
  proto.getPostponed = function getPostponed() {
174
145
  return this[kExecutions].reduce((result, pe) => {
175
146
  result = result.concat(pe.getPostponed());
176
147
  return result;
177
148
  }, []);
178
149
  };
179
-
180
150
  proto._onApiRootMessage = function onApiRootMessage(_, message) {
181
151
  const messageType = message.properties.type;
182
-
183
152
  switch (messageType) {
184
153
  case 'stop':
185
154
  this.broker.cancel(message.fields.consumerTag);
186
155
  this.stop();
187
156
  break;
188
-
189
157
  case 'discard':
190
158
  this.broker.cancel(message.fields.consumerTag);
191
159
  this.discard();
192
160
  break;
193
161
  }
194
162
  };
195
-
196
163
  proto._upsertExecution = function upsertExecution(executeMessage) {
197
164
  const content = executeMessage.content;
198
165
  const executionId = content.executionId;
199
-
200
166
  let execution = this._getExecutionById(executionId);
201
-
202
167
  if (execution) {
203
168
  if (executeMessage.fields.redelivered) this._addListeners(execution, executionId);
204
169
  return execution;
205
170
  }
206
-
207
171
  const subEnvironment = this.environment.clone();
208
172
  const subContext = this.context.clone(subEnvironment);
209
173
  execution = new _ProcessExecution.default(this.activity, subContext);
210
174
  this[kExecutions].push(execution);
211
-
212
175
  this._addListeners(execution, executionId);
213
-
214
176
  return execution;
215
177
  };
216
-
217
178
  proto._addListeners = function addListeners(processExecution, executionId) {
218
179
  this.broker.subscribeTmp('subprocess-execution', `execution.#.${executionId}`, this[kMessageHandlers].onExecutionCompleted, {
219
180
  noAck: true,
220
181
  consumerTag: `_sub-process-execution-${executionId}`
221
182
  });
222
183
  };
223
-
224
184
  proto._onExecutionCompleted = function onExecutionCompleted(_, message) {
225
185
  if (message.fields.redelivered && message.properties.persistent === false) return;
226
186
  const content = message.content;
227
187
  const messageType = message.properties.type;
228
188
  const broker = this.broker;
229
-
230
189
  switch (messageType) {
231
190
  case 'stopped':
232
191
  {
233
192
  broker.cancel(message.fields.consumerTag);
234
193
  break;
235
194
  }
236
-
237
195
  case 'discard':
238
196
  {
239
197
  broker.cancel(message.fields.consumerTag);
240
198
  broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(content));
241
199
  break;
242
200
  }
243
-
244
201
  case 'completed':
245
202
  {
246
203
  broker.cancel(message.fields.consumerTag);
247
204
  broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content));
248
205
  break;
249
206
  }
250
-
251
207
  case 'error':
252
208
  {
253
209
  broker.cancel(message.fields.consumerTag);
@@ -260,21 +216,17 @@ proto._onExecutionCompleted = function onExecutionCompleted(_, message) {
260
216
  }
261
217
  }
262
218
  };
263
-
264
219
  proto.getApi = function getApi(apiMessage) {
265
220
  const content = apiMessage.content;
266
221
  if (content.id === this.id) return;
267
222
  let execution;
268
-
269
223
  if (execution = this._getExecutionById(content.parent.executionId)) {
270
224
  return execution.getApi(apiMessage);
271
225
  }
272
-
273
226
  for (const pp of content.parent.path) {
274
227
  if (execution = this._getExecutionById(pp.executionId)) return execution.getApi(apiMessage);
275
228
  }
276
229
  };
277
-
278
230
  proto._getExecutionById = function getExecutionById(executionId) {
279
231
  return this[kExecutions].find(pe => pe.executionId === executionId);
280
232
  };
@@ -5,17 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TaskBehaviour = TaskBehaviour;
7
7
  exports.default = Task;
8
-
9
8
  var _Activity = _interopRequireDefault(require("../activity/Activity"));
10
-
11
9
  var _messageHelper = require("../messageHelper");
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
11
  function Task(activityDef, context) {
16
12
  return new _Activity.default(TaskBehaviour, activityDef, context);
17
13
  }
18
-
19
14
  function TaskBehaviour(activity) {
20
15
  const {
21
16
  id,
@@ -28,14 +23,11 @@ function TaskBehaviour(activity) {
28
23
  this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
29
24
  this.broker = broker;
30
25
  }
31
-
32
26
  TaskBehaviour.prototype.execute = function execute(executeMessage) {
33
27
  const executeContent = executeMessage.content;
34
28
  const loopCharacteristics = this.loopCharacteristics;
35
-
36
29
  if (loopCharacteristics && executeContent.isRootScope) {
37
30
  return loopCharacteristics.execute(executeMessage);
38
31
  }
39
-
40
32
  return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
41
33
  };
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Transaction;
7
-
8
7
  var _SubProcess = _interopRequireDefault(require("./SubProcess"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  function Transaction(activityDef, context) {
13
10
  const transaction = {
14
11
  type: 'transaction',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "description": "Executable workflow elements based on BPMN 2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "index.js",
@@ -47,17 +47,17 @@
47
47
  "devDependencies": {
48
48
  "@aircall/expression-parser": "^1.0.4",
49
49
  "@babel/cli": "^7.19.3",
50
- "@babel/core": "^7.19.3",
51
- "@babel/preset-env": "^7.19.3",
52
- "@babel/register": "^7.18.6",
50
+ "@babel/core": "^7.20.2",
51
+ "@babel/preset-env": "^7.20.2",
52
+ "@babel/register": "^7.18.9",
53
53
  "bpmn-moddle": "^7.1.2",
54
54
  "camunda-bpmn-moddle": "^6.1.2",
55
- "chai": "^4.3.6",
55
+ "chai": "^4.3.7",
56
56
  "chronokinesis": "^3.0.0",
57
57
  "debug": "^4.3.4",
58
- "eslint": "^7.32.0",
58
+ "eslint": "^8.27.0",
59
59
  "got": "^11.8.5",
60
- "mocha": "^9.2.2",
60
+ "mocha": "^10.1.0",
61
61
  "mocha-cakes-2": "^3.3.0",
62
62
  "moddle-context-serializer": "^2.1.0",
63
63
  "nock": "^13.2.8",
package/src/Context.js CHANGED
@@ -203,4 +203,3 @@ proto.loadExtensions = function loadExtensions(activity) {
203
203
  if (!extensions.extensions.length) return;
204
204
  return extensions;
205
205
  };
206
-
@@ -872,7 +872,7 @@ proto._onStop = function onStop(message) {
872
872
  broker.cancel('_format-consumer');
873
873
 
874
874
  if (running) {
875
- if (this.extensions) this.extensions.deactivate(message ? cloneMessage(message) : this._createMessage());
875
+ if (this.extensions) this.extensions.deactivate(cloneMessage(message));
876
876
  this._publishEvent('stop', this._createMessage());
877
877
  }
878
878
  };
@@ -81,4 +81,3 @@ EventBasedGatewayBehaviour.prototype._stop = function stop() {
81
81
  for (const target of this[kTargets]) target.broker.cancel(targetConsumerTag);
82
82
  this.broker.cancel('_api-stop-execution');
83
83
  };
84
-
@@ -113,7 +113,6 @@ proto._onFormatComplete = function formatOnComplete(message) {
113
113
  const broker = this.broker;
114
114
  const context = this.context;
115
115
 
116
-
117
116
  const {dataObjects, sources} = dataOutputs.reduce((result, ioSource, index) => {
118
117
  const {value} = messageOutputs.find((output) => output.id === ioSource.id) || {};
119
118
  const source = {
@@ -260,7 +260,6 @@ proto.discard = function discard() {
260
260
  }, {type: 'discard'});
261
261
  };
262
262
 
263
-
264
263
  proto.getState = function getState() {
265
264
  const {children, flows, outboundMessageFlows, associations} = this[kElements];
266
265
  return {
@@ -500,6 +499,13 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
500
499
  case 'execution.discard':
501
500
  message.ack();
502
501
  return this._onDiscard(message);
502
+ case 'activity.error.caught': {
503
+ const prevMsg = this[kElements].postponed.find((msg) => {
504
+ return msg.content.executionId === content.executionId;
505
+ });
506
+ if (!prevMsg) return message.ack();
507
+ break;
508
+ }
503
509
  case 'activity.compensation.end':
504
510
  case 'flow.looped':
505
511
  case 'activity.leave':
@@ -533,6 +539,7 @@ proto._onChildMessage = function onChildMessage(routingKey, message) {
533
539
  return msg.content.source && msg.content.source.executionId === content.executionId;
534
540
  });
535
541
  if (eventCaughtBy) {
542
+ this[kActivityQ].queueMessage({routingKey: 'activity.error.caught'}, cloneContent(content), {persistent: true, ...message.properties});
536
543
  return this._debug('error was caught');
537
544
  }
538
545
  return this._complete('error', {error: content.error});
@@ -5,4 +5,3 @@ export default function StandardLoopCharacteristics(activity, loopCharacteristic
5
5
  behaviour = {...behaviour, isSequential: true};
6
6
  return new LoopCharacteristics(activity, {...loopCharacteristics, behaviour});
7
7
  }
8
-