bpmn-elements 8.1.0 → 8.2.1

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 (79) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/index.js +0 -49
  3. package/dist/src/Api.js +4 -19
  4. package/dist/src/Context.js +7 -36
  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 +32 -44
  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 +62 -294
  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 +8 -5
  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 +25 -36
  52. package/dist/src/io/Properties.js +15 -47
  53. package/dist/src/messageHelper.js +10 -23
  54. package/dist/src/process/Process.js +10 -112
  55. package/dist/src/process/ProcessExecution.js +14 -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 +1 -25
  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 +8 -8
  69. package/src/Context.js +7 -3
  70. package/src/ExtensionsMapper.js +35 -35
  71. package/src/activity/Activity.js +22 -51
  72. package/src/gateways/EventBasedGateway.js +0 -1
  73. package/src/io/BpmnIO.js +7 -0
  74. package/src/io/EnvironmentDataObject.js +1 -0
  75. package/src/io/InputOutputSpecification.js +17 -6
  76. package/src/io/Properties.js +9 -11
  77. package/src/process/ProcessExecution.js +2 -1
  78. package/src/tasks/ServiceTask.js +1 -3
  79. package/src/tasks/StandardLoopCharacteristics.js +0 -1
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _Api = require("../Api");
9
-
10
8
  var _messageHelper = require("../messageHelper");
11
-
12
9
  const kCompleted = Symbol.for('completed');
13
10
  const kExecuteQ = Symbol.for('executeQ');
14
11
  const kExecuteMessage = Symbol.for('executeMessage');
@@ -16,7 +13,6 @@ const kMessageHandlers = Symbol.for('messageHandlers');
16
13
  const kPostponed = Symbol.for('postponed');
17
14
  var _default = ActivityExecution;
18
15
  exports.default = _default;
19
-
20
16
  function ActivityExecution(activity, context) {
21
17
  this.activity = activity;
22
18
  this.context = context;
@@ -33,17 +29,13 @@ function ActivityExecution(activity, context) {
33
29
  onExecuteMessage: this._onExecuteMessage.bind(this)
34
30
  };
35
31
  }
36
-
37
32
  const proto = ActivityExecution.prototype;
38
33
  Object.defineProperty(proto, 'completed', {
39
34
  enumerable: true,
40
-
41
35
  get() {
42
36
  return this[kCompleted];
43
37
  }
44
-
45
38
  });
46
-
47
39
  proto.execute = function execute(executeMessage) {
48
40
  if (!executeMessage) throw new Error('Execution requires message');
49
41
  const executionId = executeMessage.content && executeMessage.content.executionId;
@@ -54,26 +46,20 @@ proto.execute = function execute(executeMessage) {
54
46
  state: 'start',
55
47
  isRootScope: true
56
48
  });
57
-
58
49
  if (executeMessage.fields.redelivered) {
59
50
  this[kPostponed].splice(0);
60
-
61
51
  this._debug('resume execution');
62
-
63
52
  if (!this.source) this.source = new this.activity.Behaviour(this.activity, this.context);
64
53
  this.activate();
65
54
  return this.broker.publish('execution', 'execute.resume.execution', (0, _messageHelper.cloneContent)(initMessage.content), {
66
55
  persistent: false
67
56
  });
68
57
  }
69
-
70
58
  this._debug('execute');
71
-
72
59
  this.activate();
73
60
  this.source = new this.activity.Behaviour(this.activity, this.context);
74
61
  this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(initMessage.content));
75
62
  };
76
-
77
63
  proto.activate = function activate() {
78
64
  if (this[kCompleted]) return;
79
65
  const broker = this.broker;
@@ -98,32 +84,26 @@ proto.activate = function activate() {
98
84
  priority: 200
99
85
  });
100
86
  };
101
-
102
87
  proto.deactivate = function deactivate() {
103
88
  const broker = this.broker;
104
89
  broker.cancel('_activity-api-execution');
105
90
  broker.cancel('_activity-execute');
106
91
  broker.unbindQueue('execute-q', 'execution', 'execute.#');
107
92
  };
108
-
109
93
  proto.discard = function discard() {
110
94
  if (this[kCompleted]) return;
111
95
  const initMessage = this[kExecuteMessage];
112
96
  if (!initMessage) return this.activity.logger.warn(`<${this.id}> is not executing`);
113
97
  this.getApi(initMessage).discard();
114
98
  };
115
-
116
99
  proto.getApi = function getApi(apiMessage) {
117
100
  const self = this;
118
101
  if (!apiMessage) apiMessage = this[kExecuteMessage];
119
-
120
102
  if (self.source.getApi) {
121
103
  const sourceApi = self.source.getApi(apiMessage);
122
104
  if (sourceApi) return sourceApi;
123
105
  }
124
-
125
106
  const api = (0, _Api.ActivityApi)(self.broker, apiMessage);
126
-
127
107
  api.getExecuting = function getExecuting() {
128
108
  return self[kPostponed].reduce((result, msg) => {
129
109
  if (msg.content.executionId === apiMessage.content.executionId) return result;
@@ -131,52 +111,44 @@ proto.getApi = function getApi(apiMessage) {
131
111
  return result;
132
112
  }, []);
133
113
  };
134
-
135
114
  return api;
136
115
  };
137
-
138
116
  proto.passthrough = function passthrough(executeMessage) {
139
117
  if (!this.source) return this.execute(executeMessage);
140
118
  return this._sourceExecute(executeMessage);
141
119
  };
142
-
143
120
  proto.getPostponed = function getPostponed() {
144
121
  let apis = this[kPostponed].map(msg => this.getApi(msg));
145
122
  if (!this.activity.isSubProcess || !this.source) return apis;
146
123
  apis = apis.concat(this.source.getPostponed());
147
124
  return apis;
148
125
  };
149
-
150
126
  proto.getState = function getState() {
151
127
  const result = {
152
128
  completed: this[kCompleted]
153
129
  };
154
130
  const source = this.source;
155
131
  if (!source || !source.getState) return result;
156
- return { ...result,
132
+ return {
133
+ ...result,
157
134
  ...source.getState()
158
135
  };
159
136
  };
160
-
161
137
  proto.recover = function recover(state) {
162
138
  this[kPostponed].splice(0);
163
139
  if (!state) return this;
164
140
  if ('completed' in state) this[kCompleted] = state.completed;
165
141
  const source = this.source = new this.activity.Behaviour(this.activity, this.context);
166
-
167
142
  if (source.recover) {
168
143
  source.recover(state);
169
144
  }
170
-
171
145
  return this;
172
146
  };
173
-
174
147
  proto.stop = function stop() {
175
148
  const executeMessage = this[kExecuteMessage];
176
149
  if (!executeMessage) return;
177
150
  this.getApi(executeMessage).stop();
178
151
  };
179
-
180
152
  proto._sourceExecute = function sourceExecute(executeMessage) {
181
153
  try {
182
154
  return this.source.execute(executeMessage);
@@ -186,7 +158,6 @@ proto._sourceExecute = function sourceExecute(executeMessage) {
186
158
  }));
187
159
  }
188
160
  };
189
-
190
161
  proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
191
162
  const {
192
163
  fields,
@@ -195,18 +166,15 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
195
166
  } = message;
196
167
  const isRedelivered = fields.redelivered;
197
168
  if (isRedelivered && properties.persistent === false) return message.ack();
198
-
199
169
  switch (routingKey) {
200
170
  case 'execute.resume.execution':
201
171
  {
202
172
  if (!this[kPostponed].length) return this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
203
173
  break;
204
174
  }
205
-
206
175
  case 'execute.error':
207
176
  case 'execute.discard':
208
177
  return this._onExecutionDiscarded(message);
209
-
210
178
  case 'execute.cancel':
211
179
  case 'execute.completed':
212
180
  {
@@ -214,40 +182,33 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
214
182
  message.ack();
215
183
  return this.broker.publish('execution', routingKey, getExecuteMessage(message).content);
216
184
  }
217
-
218
185
  return this._onExecutionCompleted(message);
219
186
  }
220
-
221
187
  case 'execute.start':
222
188
  {
223
189
  if (!this._onStateChangeMessage(message)) return;
224
190
  return this._sourceExecute(getExecuteMessage(message));
225
191
  }
226
-
227
192
  case 'execute.outbound.take':
228
193
  {
229
194
  if (isRedelivered) {
230
195
  message.ack();
231
196
  break;
232
197
  }
233
-
234
198
  this.broker.publish('execution', 'execution.outbound.take', (0, _messageHelper.cloneContent)(content), {
235
199
  type: 'outbound'
236
200
  });
237
201
  break;
238
202
  }
239
-
240
203
  default:
241
204
  {
242
205
  if (!this._onStateChangeMessage(message)) return;
243
-
244
206
  if (isRedelivered) {
245
207
  return this._sourceExecute(getExecuteMessage(message));
246
208
  }
247
209
  }
248
210
  }
249
211
  };
250
-
251
212
  proto._onStateChangeMessage = function onStateChangeMessage(message) {
252
213
  const {
253
214
  ignoreIfExecuting,
@@ -256,25 +217,20 @@ proto._onStateChangeMessage = function onStateChangeMessage(message) {
256
217
  const postponed = this[kPostponed];
257
218
  const idx = postponed.findIndex(msg => msg.content.executionId === executionId);
258
219
  let previousMsg;
259
-
260
220
  if (idx > -1) {
261
221
  if (ignoreIfExecuting) {
262
222
  message.ack();
263
223
  return false;
264
224
  }
265
-
266
225
  previousMsg = postponed.splice(idx, 1, message)[0];
267
226
  previousMsg.ack();
268
227
  return true;
269
228
  }
270
-
271
229
  postponed.push(message);
272
230
  return true;
273
231
  };
274
-
275
232
  proto._onExecutionCompleted = function onExecutionCompleted(message) {
276
233
  const postponedMsg = this._ackPostponed(message);
277
-
278
234
  if (!postponedMsg) return;
279
235
  const postponed = this[kPostponed];
280
236
  const {
@@ -282,37 +238,28 @@ proto._onExecutionCompleted = function onExecutionCompleted(message) {
282
238
  keep,
283
239
  isRootScope
284
240
  } = message.content;
285
-
286
241
  if (!isRootScope) {
287
242
  this._debug('completed sub execution');
288
-
289
243
  if (!keep) message.ack();
290
-
291
244
  if (postponed.length === 1 && postponed[0].content.isRootScope && !postponed[0].content.preventComplete) {
292
245
  return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(postponed[0].content));
293
246
  }
294
-
295
247
  return;
296
248
  }
297
-
298
249
  this._debug('completed execution', executionId);
299
-
300
250
  this[kCompleted] = true;
301
251
  message.ack(true);
302
252
  this.deactivate();
303
253
  const subApis = this.getPostponed();
304
254
  postponed.splice(0);
305
-
306
255
  for (const api of subApis) api.discard();
307
-
308
- this._publishExecutionCompleted('completed', { ...postponedMsg.content,
256
+ this._publishExecutionCompleted('completed', {
257
+ ...postponedMsg.content,
309
258
  ...message.content
310
259
  }, message.properties.correlationId);
311
260
  };
312
-
313
261
  proto._onExecutionDiscarded = function onExecutionDiscarded(message) {
314
262
  const postponedMsg = this._ackPostponed(message);
315
-
316
263
  const {
317
264
  isRootScope,
318
265
  error
@@ -320,45 +267,37 @@ proto._onExecutionDiscarded = function onExecutionDiscarded(message) {
320
267
  if (!isRootScope && !postponedMsg) return;
321
268
  const postponed = this[kPostponed];
322
269
  const correlationId = message.properties.correlationId;
323
-
324
270
  if (!error && !isRootScope) {
325
271
  message.ack();
326
-
327
272
  if (postponed.length === 1 && postponed[0].content.isRootScope) {
328
273
  return this.broker.publish('execution', 'execute.discard', postponed[0].content, {
329
274
  correlationId
330
275
  });
331
276
  }
332
-
333
277
  return;
334
278
  }
335
-
336
279
  message.ack(true);
337
280
  this.deactivate();
338
281
  const subApis = this.getPostponed();
339
282
  postponed.splice(0);
340
-
341
283
  for (const api of subApis) api.discard();
342
-
343
284
  if (error) {
344
285
  return this._publishExecutionCompleted('error', (0, _messageHelper.cloneContent)(message.content, {
345
286
  error
346
287
  }), correlationId);
347
288
  }
348
-
349
289
  this._publishExecutionCompleted('discard', message.content, correlationId);
350
290
  };
351
-
352
291
  proto._publishExecutionCompleted = function publishExecutionCompleted(completionType, completeContent, correlationId) {
353
292
  this[kCompleted] = true;
354
- this.broker.publish('execution', `execution.${completionType}`, { ...completeContent,
293
+ this.broker.publish('execution', `execution.${completionType}`, {
294
+ ...completeContent,
355
295
  state: completionType
356
296
  }, {
357
297
  type: completionType,
358
298
  correlationId
359
299
  });
360
300
  };
361
-
362
301
  proto._ackPostponed = function ackPostponed(completeMessage) {
363
302
  const {
364
303
  executionId: eid
@@ -372,7 +311,6 @@ proto._ackPostponed = function ackPostponed(completeMessage) {
372
311
  msg.ack();
373
312
  return msg;
374
313
  };
375
-
376
314
  proto._onParentApiMessage = function onParentApiMessage(routingKey, message) {
377
315
  switch (message.properties.type) {
378
316
  case 'error':
@@ -381,40 +319,34 @@ proto._onParentApiMessage = function onParentApiMessage(routingKey, message) {
381
319
  }, {
382
320
  error: message.content.error
383
321
  });
384
-
385
322
  case 'discard':
386
323
  return this[kExecuteQ].queueMessage({
387
324
  routingKey: 'execute.discard'
388
325
  }, (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
389
-
390
326
  case 'stop':
391
327
  {
392
328
  return this._onStop(message);
393
329
  }
394
330
  }
395
331
  };
396
-
397
332
  proto._onStop = function onStop(message) {
398
333
  const stoppedId = message && message.content && message.content.executionId;
399
334
  const running = this.getPostponed();
400
-
401
335
  for (const api of running) {
402
336
  if (stoppedId !== api.content.executionId) {
403
337
  api.stop();
404
338
  }
405
339
  }
406
-
407
340
  this.broker.cancel('_activity-execute');
408
341
  this.broker.cancel('_activity-api-execution');
409
342
  };
410
-
411
343
  proto._debug = function debug(logMessage, executionId) {
412
344
  executionId = executionId || this.executionId;
413
345
  this.activity.logger.debug(`<${executionId} (${this.id})> ${logMessage}`);
414
346
  };
415
-
416
347
  function getExecuteMessage(message) {
417
- const result = (0, _messageHelper.cloneMessage)(message, { ...(message.fields.redelivered && {
348
+ const result = (0, _messageHelper.cloneMessage)(message, {
349
+ ...(message.fields.redelivered && {
418
350
  isRecovered: true
419
351
  }),
420
352
  ignoreIfExecuting: undefined
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = DummyActivity;
7
-
8
7
  var _messageHelper = require("../messageHelper");
9
-
10
8
  function DummyActivity(activityDef) {
11
9
  const {
12
10
  id,
@@ -19,7 +17,8 @@ function DummyActivity(activityDef) {
19
17
  id,
20
18
  type,
21
19
  name,
22
- behaviour: { ...behaviour
20
+ behaviour: {
21
+ ...behaviour
23
22
  },
24
23
  parent: (0, _messageHelper.cloneParent)(parent),
25
24
  placeholder: true
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Escalation;
7
-
8
7
  function Escalation(signalDef, context) {
9
8
  const {
10
9
  id,
@@ -15,7 +14,8 @@ function Escalation(signalDef, context) {
15
14
  const {
16
15
  environment
17
16
  } = context;
18
- const parent = { ...originalParent
17
+ const parent = {
18
+ ...originalParent
19
19
  };
20
20
  return {
21
21
  id,
@@ -24,14 +24,14 @@ function Escalation(signalDef, context) {
24
24
  parent,
25
25
  resolve
26
26
  };
27
-
28
27
  function resolve(executionMessage) {
29
28
  return {
30
29
  id,
31
30
  type,
32
31
  messageType: 'escalation',
33
32
  name: name && environment.resolveExpression(name, executionMessage),
34
- parent: { ...parent
33
+ parent: {
34
+ ...parent
35
35
  }
36
36
  };
37
37
  }
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ExecutionScope;
7
-
8
7
  var _messageHelper = require("../messageHelper");
9
-
10
8
  var _Errors = require("../error/Errors");
11
-
12
9
  function ExecutionScope(activity, initMessage) {
13
10
  const {
14
11
  id,
@@ -34,7 +31,6 @@ function ExecutionScope(activity, initMessage) {
34
31
  BpmnError: _Errors.BpmnError
35
32
  };
36
33
  return scope;
37
-
38
34
  function resolveExpression(expression) {
39
35
  return environment.resolveExpression(expression, scope);
40
36
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Message;
7
-
8
7
  function Message(messageDef, context) {
9
8
  const {
10
9
  id,
@@ -15,7 +14,8 @@ function Message(messageDef, context) {
15
14
  const {
16
15
  environment
17
16
  } = context;
18
- const parent = { ...originalParent
17
+ const parent = {
18
+ ...originalParent
19
19
  };
20
20
  return {
21
21
  id,
@@ -24,7 +24,6 @@ function Message(messageDef, context) {
24
24
  parent,
25
25
  resolve
26
26
  };
27
-
28
27
  function resolve(executionMessage) {
29
28
  return {
30
29
  id,
@@ -33,7 +32,8 @@ function Message(messageDef, context) {
33
32
  ...(name && {
34
33
  name: environment.resolveExpression(name, executionMessage)
35
34
  }),
36
- parent: { ...parent
35
+ parent: {
36
+ ...parent
37
37
  }
38
38
  };
39
39
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Signal;
7
-
8
7
  function Signal(signalDef, context) {
9
8
  const {
10
9
  id,
@@ -15,7 +14,8 @@ function Signal(signalDef, context) {
15
14
  const {
16
15
  environment
17
16
  } = context;
18
- const parent = { ...originalParent
17
+ const parent = {
18
+ ...originalParent
19
19
  };
20
20
  return {
21
21
  id,
@@ -24,7 +24,6 @@ function Signal(signalDef, context) {
24
24
  parent,
25
25
  resolve
26
26
  };
27
-
28
27
  function resolve(executionMessage) {
29
28
  return {
30
29
  id,
@@ -33,7 +32,8 @@ function Signal(signalDef, context) {
33
32
  ...(name && {
34
33
  name: environment.resolveExpression(name, executionMessage)
35
34
  }),
36
- parent: { ...parent
35
+ parent: {
36
+ ...parent
37
37
  }
38
38
  };
39
39
  }