bpmn-elements 17.3.0 → 18.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.
Files changed (155) hide show
  1. package/README.md +3 -1
  2. package/dist/Api.js +83 -0
  3. package/dist/Context.js +228 -22
  4. package/dist/Environment.js +111 -31
  5. package/dist/EventBroker.js +57 -1
  6. package/dist/Expressions.js +3 -4
  7. package/dist/MessageFormatter.js +29 -16
  8. package/dist/Timers.js +13 -9
  9. package/dist/Tracker.js +1 -0
  10. package/dist/activity/Activity.js +434 -233
  11. package/dist/activity/ActivityExecution.js +113 -40
  12. package/dist/activity/Dummy.js +6 -1
  13. package/dist/activity/Escalation.js +36 -24
  14. package/dist/activity/ExecutionScope.js +1 -1
  15. package/dist/activity/Message.js +36 -24
  16. package/dist/activity/Signal.js +36 -24
  17. package/dist/activity/outbound-evaluator.js +1 -1
  18. package/dist/condition.js +12 -6
  19. package/dist/constants.js +21 -0
  20. package/dist/definition/Definition.js +182 -64
  21. package/dist/definition/DefinitionExecution.js +195 -82
  22. package/dist/error/BpmnError.js +12 -1
  23. package/dist/error/Errors.js +50 -9
  24. package/dist/eventDefinitions/CancelEventDefinition.js +29 -11
  25. package/dist/eventDefinitions/CompensateEventDefinition.js +51 -31
  26. package/dist/eventDefinitions/ConditionalEventDefinition.js +21 -9
  27. package/dist/eventDefinitions/ErrorEventDefinition.js +46 -30
  28. package/dist/eventDefinitions/EscalationEventDefinition.js +44 -27
  29. package/dist/eventDefinitions/EventDefinitionExecution.js +30 -23
  30. package/dist/eventDefinitions/LinkEventDefinition.js +45 -120
  31. package/dist/eventDefinitions/MessageEventDefinition.js +44 -29
  32. package/dist/eventDefinitions/SignalEventDefinition.js +46 -31
  33. package/dist/eventDefinitions/TerminateEventDefinition.js +10 -1
  34. package/dist/eventDefinitions/TimerEventDefinition.js +57 -37
  35. package/dist/eventDefinitions/index.js +20 -21
  36. package/dist/events/BoundaryEvent.js +52 -40
  37. package/dist/events/EndEvent.js +22 -8
  38. package/dist/events/IntermediateCatchEvent.js +26 -8
  39. package/dist/events/IntermediateThrowEvent.js +24 -9
  40. package/dist/events/StartEvent.js +30 -14
  41. package/dist/events/index.js +10 -11
  42. package/dist/flows/Association.js +50 -7
  43. package/dist/flows/MessageFlow.js +49 -10
  44. package/dist/flows/SequenceFlow.js +93 -22
  45. package/dist/flows/index.js +6 -7
  46. package/dist/gateways/EventBasedGateway.js +29 -15
  47. package/dist/gateways/ExclusiveGateway.js +20 -5
  48. package/dist/gateways/InclusiveGateway.js +21 -5
  49. package/dist/gateways/ParallelGateway.js +253 -15
  50. package/dist/gateways/index.js +8 -9
  51. package/dist/getPropertyValue.js +1 -1
  52. package/dist/index.js +42 -43
  53. package/dist/io/BpmnIO.js +15 -1
  54. package/dist/io/EnvironmentDataObject.js +29 -1
  55. package/dist/io/EnvironmentDataStore.js +24 -1
  56. package/dist/io/EnvironmentDataStoreReference.js +24 -1
  57. package/dist/io/InputOutputSpecification.js +21 -11
  58. package/dist/io/Properties.js +28 -17
  59. package/dist/messageHelper.js +41 -4
  60. package/dist/process/Lane.js +15 -4
  61. package/dist/process/Process.js +174 -76
  62. package/dist/process/ProcessExecution.js +362 -177
  63. package/dist/shared.js +2 -0
  64. package/dist/tasks/CallActivity.js +19 -4
  65. package/dist/tasks/LoopCharacteristics.js +94 -9
  66. package/dist/tasks/ReceiveTask.js +36 -21
  67. package/dist/tasks/ScriptTask.js +22 -6
  68. package/dist/tasks/ServiceImplementation.js +7 -4
  69. package/dist/tasks/ServiceTask.js +19 -4
  70. package/dist/tasks/SignalTask.js +19 -4
  71. package/dist/tasks/StandardLoopCharacteristics.js +8 -4
  72. package/dist/tasks/SubProcess.js +44 -29
  73. package/dist/tasks/Task.js +19 -4
  74. package/dist/tasks/Transaction.js +8 -4
  75. package/dist/tasks/index.js +16 -18
  76. package/package.json +31 -13
  77. package/src/Api.js +70 -0
  78. package/src/Context.js +200 -19
  79. package/src/Environment.js +99 -30
  80. package/src/EventBroker.js +46 -1
  81. package/src/Expressions.js +2 -3
  82. package/src/MessageFormatter.js +24 -16
  83. package/src/Timers.js +12 -9
  84. package/src/Tracker.js +1 -0
  85. package/src/activity/Activity.js +372 -218
  86. package/src/activity/ActivityExecution.js +93 -42
  87. package/src/activity/Dummy.js +6 -1
  88. package/src/activity/Escalation.js +25 -18
  89. package/src/activity/ExecutionScope.js +1 -1
  90. package/src/activity/Message.js +25 -18
  91. package/src/activity/Signal.js +25 -18
  92. package/src/activity/outbound-evaluator.js +1 -1
  93. package/src/condition.js +11 -5
  94. package/src/constants.js +15 -0
  95. package/src/definition/Definition.js +157 -62
  96. package/src/definition/DefinitionExecution.js +161 -83
  97. package/src/error/BpmnError.js +11 -1
  98. package/src/error/Errors.js +44 -5
  99. package/src/eventDefinitions/CancelEventDefinition.js +27 -13
  100. package/src/eventDefinitions/CompensateEventDefinition.js +48 -32
  101. package/src/eventDefinitions/ConditionalEventDefinition.js +20 -10
  102. package/src/eventDefinitions/ErrorEventDefinition.js +44 -33
  103. package/src/eventDefinitions/EscalationEventDefinition.js +39 -26
  104. package/src/eventDefinitions/EventDefinitionExecution.js +30 -24
  105. package/src/eventDefinitions/LinkEventDefinition.js +34 -120
  106. package/src/eventDefinitions/MessageEventDefinition.js +42 -31
  107. package/src/eventDefinitions/SignalEventDefinition.js +43 -32
  108. package/src/eventDefinitions/TerminateEventDefinition.js +9 -1
  109. package/src/eventDefinitions/TimerEventDefinition.js +53 -35
  110. package/src/eventDefinitions/index.js +10 -23
  111. package/src/events/BoundaryEvent.js +50 -39
  112. package/src/events/EndEvent.js +19 -7
  113. package/src/events/IntermediateCatchEvent.js +24 -8
  114. package/src/events/IntermediateThrowEvent.js +24 -8
  115. package/src/events/StartEvent.js +25 -14
  116. package/src/events/index.js +5 -18
  117. package/src/flows/Association.js +43 -9
  118. package/src/flows/MessageFlow.js +41 -10
  119. package/src/flows/SequenceFlow.js +82 -19
  120. package/src/flows/index.js +3 -4
  121. package/src/gateways/EventBasedGateway.js +27 -15
  122. package/src/gateways/ExclusiveGateway.js +16 -3
  123. package/src/gateways/InclusiveGateway.js +16 -3
  124. package/src/gateways/ParallelGateway.js +301 -10
  125. package/src/gateways/index.js +4 -4
  126. package/src/getPropertyValue.js +1 -1
  127. package/src/index.js +19 -19
  128. package/src/io/BpmnIO.js +13 -1
  129. package/src/io/EnvironmentDataObject.js +26 -1
  130. package/src/io/EnvironmentDataStore.js +22 -1
  131. package/src/io/EnvironmentDataStoreReference.js +22 -1
  132. package/src/io/InputOutputSpecification.js +17 -8
  133. package/src/io/Properties.js +23 -13
  134. package/src/messageHelper.js +36 -4
  135. package/src/process/Lane.js +14 -4
  136. package/src/process/Process.js +154 -72
  137. package/src/process/ProcessExecution.js +326 -175
  138. package/src/shared.js +1 -0
  139. package/src/tasks/CallActivity.js +16 -2
  140. package/src/tasks/LoopCharacteristics.js +77 -11
  141. package/src/tasks/ReceiveTask.js +33 -22
  142. package/src/tasks/ScriptTask.js +17 -3
  143. package/src/tasks/ServiceImplementation.js +6 -3
  144. package/src/tasks/ServiceTask.js +16 -2
  145. package/src/tasks/SignalTask.js +16 -2
  146. package/src/tasks/StandardLoopCharacteristics.js +7 -3
  147. package/src/tasks/SubProcess.js +37 -23
  148. package/src/tasks/Task.js +16 -2
  149. package/src/tasks/Transaction.js +7 -3
  150. package/src/tasks/index.js +8 -9
  151. package/types/bundle-errors.d.ts +1 -0
  152. package/types/bundle.d.ts +97 -0
  153. package/types/index.d.ts +2614 -84
  154. package/types/interfaces.d.ts +636 -0
  155. package/types/types.d.ts +0 -765
@@ -3,48 +3,59 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.ActivityExecution = ActivityExecution;
7
7
  var _Api = require("../Api.js");
8
8
  var _messageHelper = require("../messageHelper.js");
9
- const kCompleted = Symbol.for('completed');
10
- const kExecuteQ = Symbol.for('executeQ');
11
- const kExecuteMessage = Symbol.for('executeMessage');
12
- const kMessageHandlers = Symbol.for('messageHandlers');
13
- const kPostponed = Symbol.for('postponed');
14
- var _default = exports.default = ActivityExecution;
9
+ var _constants = require("../constants.js");
10
+ const K_EXECUTE_Q = Symbol.for('executeQ');
11
+ const K_POSTPONED = Symbol.for('postponed');
12
+
13
+ /**
14
+ * Per-run execution orchestrator for an Activity. Instantiates the element-specific behaviour
15
+ * and drives the execute message flow over the activity broker.
16
+ * @param {import('./Activity.js').Activity} activity
17
+ * @param {import('../Context.js').ContextInstance} context
18
+ */
15
19
  function ActivityExecution(activity, context) {
16
20
  this.activity = activity;
17
21
  this.context = context;
18
22
  this.id = activity.id;
19
23
  this.broker = activity.broker;
20
- this[kPostponed] = new Set();
21
- this[kCompleted] = false;
22
- this[kExecuteQ] = this.broker.assertQueue('execute-q', {
24
+ this[K_POSTPONED] = new Set();
25
+ this[_constants.K_COMPLETED] = false;
26
+ this[K_EXECUTE_Q] = this.broker.assertQueue('execute-q', {
23
27
  durable: true,
24
28
  autoDelete: false
25
29
  });
26
- this[kMessageHandlers] = {
30
+ this[_constants.K_MESSAGE_HANDLERS] = {
27
31
  onParentApiMessage: this._onParentApiMessage.bind(this),
28
32
  onExecuteMessage: this._onExecuteMessage.bind(this)
29
33
  };
30
34
  }
31
35
  Object.defineProperty(ActivityExecution.prototype, 'completed', {
36
+ /** @returns {boolean} */
32
37
  get() {
33
- return this[kCompleted];
38
+ return this[_constants.K_COMPLETED];
34
39
  }
35
40
  });
41
+
42
+ /**
43
+ * Begin executing the activity behaviour. Resumes if the message is redelivered.
44
+ * @param {import('#types').ElementBrokerMessage} executeMessage
45
+ * @throws {Error} when message or executionId is missing
46
+ */
36
47
  ActivityExecution.prototype.execute = function execute(executeMessage) {
37
48
  if (!executeMessage) throw new Error('Execution requires message');
38
49
  const executionId = executeMessage.content?.executionId;
39
50
  if (!executionId) throw new Error('Execution requires execution id');
40
51
  this.executionId = executionId;
41
- const initMessage = this[kExecuteMessage] = (0, _messageHelper.cloneMessage)(executeMessage, {
52
+ const initMessage = this[_constants.K_EXECUTE_MESSAGE] = (0, _messageHelper.cloneMessage)(executeMessage, {
42
53
  executionId,
43
54
  state: 'start',
44
55
  isRootScope: true
45
56
  });
46
57
  if (executeMessage.fields.redelivered) {
47
- this[kPostponed].clear();
58
+ this[K_POSTPONED].clear();
48
59
  this._debug('resume execution');
49
60
  if (!this.source) this.source = new this.activity.Behaviour(this.activity, this.context);
50
61
  this.activate();
@@ -57,8 +68,12 @@ ActivityExecution.prototype.execute = function execute(executeMessage) {
57
68
  this.source = new this.activity.Behaviour(this.activity, this.context);
58
69
  this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(initMessage.content));
59
70
  };
71
+
72
+ /**
73
+ * Bind the execute queue and start consuming execute and api messages.
74
+ */
60
75
  ActivityExecution.prototype.activate = function activate() {
61
- if (this[kCompleted]) return;
76
+ if (this[_constants.K_COMPLETED]) return;
62
77
  const broker = this.broker;
63
78
  const batchSize = this.activity.environment.settings.batchSize || 50;
64
79
  broker.bindQueue('execute-q', 'execution', 'execute.#', {
@@ -67,35 +82,49 @@ ActivityExecution.prototype.activate = function activate() {
67
82
  const {
68
83
  onExecuteMessage,
69
84
  onParentApiMessage
70
- } = this[kMessageHandlers];
71
- this[kExecuteQ].assertConsumer(onExecuteMessage, {
85
+ } = this[_constants.K_MESSAGE_HANDLERS];
86
+ this[K_EXECUTE_Q].assertConsumer(onExecuteMessage, {
72
87
  exclusive: true,
73
88
  prefetch: batchSize * 2,
74
89
  priority: 100,
75
90
  consumerTag: '_activity-execute'
76
91
  });
77
- if (this[kCompleted]) return this.deactivate();
92
+ if (this[_constants.K_COMPLETED]) return this.deactivate();
78
93
  broker.subscribeTmp('api', `activity.*.${this.executionId}`, onParentApiMessage, {
79
94
  noAck: true,
80
95
  consumerTag: '_activity-api-execution',
81
96
  priority: 200
82
97
  });
83
98
  };
99
+
100
+ /**
101
+ * Cancel execute and api consumers and unbind the execute queue.
102
+ */
84
103
  ActivityExecution.prototype.deactivate = function deactivate() {
85
104
  const broker = this.broker;
86
105
  broker.cancel('_activity-api-execution');
87
106
  broker.cancel('_activity-execute');
88
107
  broker.unbindQueue('execute-q', 'execution', 'execute.#');
89
108
  };
109
+
110
+ /**
111
+ * Discard the running execution.
112
+ */
90
113
  ActivityExecution.prototype.discard = function discard() {
91
- if (this[kCompleted]) return;
92
- const initMessage = this[kExecuteMessage];
114
+ if (this[_constants.K_COMPLETED]) return;
115
+ const initMessage = this[_constants.K_EXECUTE_MESSAGE];
93
116
  if (!initMessage) return this.activity.logger.warn(`<${this.id}> is not executing`);
94
117
  this.getApi(initMessage).discard();
95
118
  };
119
+
120
+ /**
121
+ * Resolve an Api wrapper, preferring a behaviour-specific Api when the source exposes one.
122
+ * @param {import('#types').ElementBrokerMessage} [apiMessage]
123
+ * @returns {import('#types').IApi<import('./Activity.js').Activity>}
124
+ */
96
125
  ActivityExecution.prototype.getApi = function getApi(apiMessage) {
97
126
  const self = this;
98
- if (!apiMessage) apiMessage = this[kExecuteMessage];
127
+ if (!apiMessage) apiMessage = this[_constants.K_EXECUTE_MESSAGE];
99
128
  if (self.source.getApi) {
100
129
  const sourceApi = self.source.getApi(apiMessage);
101
130
  if (sourceApi) return sourceApi;
@@ -103,7 +132,7 @@ ActivityExecution.prototype.getApi = function getApi(apiMessage) {
103
132
  const api = (0, _Api.ActivityApi)(self.broker, apiMessage);
104
133
  api.getExecuting = function getExecuting() {
105
134
  const result = [];
106
- for (const msg of self[kPostponed]) {
135
+ for (const msg of self[K_POSTPONED]) {
107
136
  if (msg.content.executionId === apiMessage.content.executionId) continue;
108
137
  result.push(self.getApi(msg));
109
138
  }
@@ -111,22 +140,37 @@ ActivityExecution.prototype.getApi = function getApi(apiMessage) {
111
140
  };
112
141
  return api;
113
142
  };
143
+
144
+ /**
145
+ * Pass an execute message straight to the behaviour, executing first if no source is set up yet.
146
+ * @param {import('#types').ElementBrokerMessage} executeMessage
147
+ * @returns {void}
148
+ */
114
149
  ActivityExecution.prototype.passthrough = function passthrough(executeMessage) {
115
150
  if (!this.source) return this.execute(executeMessage);
116
151
  return this._sourceExecute(executeMessage);
117
152
  };
153
+
154
+ /**
155
+ * List currently postponed executions as Api wrappers, including those from sub-process behaviours.
156
+ */
118
157
  ActivityExecution.prototype.getPostponed = function getPostponed() {
119
158
  let apis = [];
120
- for (const msg of this[kPostponed]) {
159
+ for (const msg of this[K_POSTPONED]) {
121
160
  apis.push(this.getApi(msg));
122
161
  }
123
162
  if (!this.activity.isSubProcess || !this.source) return apis;
124
163
  apis = apis.concat(this.source.getPostponed());
125
164
  return apis;
126
165
  };
166
+
167
+ /**
168
+ * Snapshot execution state, merging behaviour-specific state when the source provides it.
169
+ * @returns {import('#types').ActivityExecutionState}
170
+ */
127
171
  ActivityExecution.prototype.getState = function getState() {
128
172
  const result = {
129
- completed: this[kCompleted]
173
+ completed: this[_constants.K_COMPLETED]
130
174
  };
131
175
  const source = this.source;
132
176
  if (!source || !source.getState) return result;
@@ -135,21 +179,33 @@ ActivityExecution.prototype.getState = function getState() {
135
179
  ...source.getState()
136
180
  };
137
181
  };
182
+
183
+ /**
184
+ * Restore execution state captured by getState.
185
+ * @param {import('#types').ActivityExecutionState} [state]
186
+ * @returns {this}
187
+ */
138
188
  ActivityExecution.prototype.recover = function recover(state) {
139
- this[kPostponed].clear();
189
+ this[K_POSTPONED].clear();
140
190
  if (!state) return this;
141
- if ('completed' in state) this[kCompleted] = state.completed;
191
+ if ('completed' in state) this[_constants.K_COMPLETED] = state.completed;
142
192
  const source = this.source = new this.activity.Behaviour(this.activity, this.context);
143
193
  if (source.recover) {
144
194
  source.recover(state);
145
195
  }
146
196
  return this;
147
197
  };
198
+
199
+ /**
200
+ * Stop the execution via the activity api.
201
+ */
148
202
  ActivityExecution.prototype.stop = function stop() {
149
- const executeMessage = this[kExecuteMessage];
203
+ const executeMessage = this[_constants.K_EXECUTE_MESSAGE];
150
204
  if (!executeMessage) return;
151
205
  this.getApi(executeMessage).stop();
152
206
  };
207
+
208
+ /** @internal */
153
209
  ActivityExecution.prototype._sourceExecute = function sourceExecute(executeMessage) {
154
210
  try {
155
211
  return this.source.execute(executeMessage);
@@ -159,6 +215,8 @@ ActivityExecution.prototype._sourceExecute = function sourceExecute(executeMessa
159
215
  }));
160
216
  }
161
217
  };
218
+
219
+ /** @internal */
162
220
  ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routingKey, message) {
163
221
  const {
164
222
  fields,
@@ -170,7 +228,7 @@ ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routin
170
228
  switch (routingKey) {
171
229
  case 'execute.resume.execution':
172
230
  {
173
- if (!this[kPostponed].size) return this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
231
+ if (!this[K_POSTPONED].size) return this.broker.publish('execution', 'execute.start', (0, _messageHelper.cloneContent)(this[_constants.K_EXECUTE_MESSAGE].content));
174
232
  break;
175
233
  }
176
234
  case 'execute.cancel':
@@ -212,12 +270,14 @@ ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routin
212
270
  }
213
271
  }
214
272
  };
273
+
274
+ /** @internal */
215
275
  ActivityExecution.prototype._onStateChangeMessage = function onStateChangeMessage(message) {
216
276
  const {
217
277
  ignoreIfExecuting,
218
278
  executionId
219
279
  } = message.content;
220
- const postponed = this[kPostponed];
280
+ const postponed = this[K_POSTPONED];
221
281
  let previousMsg;
222
282
  for (const msg of postponed) {
223
283
  if (msg.content.executionId === executionId) previousMsg = msg;
@@ -236,17 +296,19 @@ ActivityExecution.prototype._onStateChangeMessage = function onStateChangeMessag
236
296
  return true;
237
297
  }
238
298
  };
299
+
300
+ /** @internal */
239
301
  ActivityExecution.prototype._onExecutionCompleted = function onExecutionCompleted(message) {
240
302
  const postponedMsg = this._ackPostponed(message);
241
303
  if (!postponedMsg) return;
242
- const postponed = this[kPostponed];
304
+ const postponed = this[K_POSTPONED];
243
305
  const {
244
306
  executionId,
245
307
  keep,
246
308
  isRootScope
247
309
  } = message.content;
248
310
  if (!isRootScope) {
249
- this._debug('completed sub execution');
311
+ this._debug('completed sub execution', executionId);
250
312
  if (!keep) message.ack();
251
313
  if (postponed.size === 1) {
252
314
  const onlyMessage = postponed.values().next().value;
@@ -257,7 +319,7 @@ ActivityExecution.prototype._onExecutionCompleted = function onExecutionComplete
257
319
  return;
258
320
  }
259
321
  this._debug('completed execution', executionId);
260
- this[kCompleted] = true;
322
+ this[_constants.K_COMPLETED] = true;
261
323
  message.ack(true);
262
324
  this.deactivate();
263
325
  const subApis = this.getPostponed();
@@ -268,6 +330,8 @@ ActivityExecution.prototype._onExecutionCompleted = function onExecutionComplete
268
330
  ...message.content
269
331
  }, message.properties.correlationId);
270
332
  };
333
+
334
+ /** @internal */
271
335
  ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarded(discardType, message) {
272
336
  const postponedMsg = this._ackPostponed(message);
273
337
  const {
@@ -275,7 +339,7 @@ ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarde
275
339
  error
276
340
  } = message.content;
277
341
  if (!isRootScope && !postponedMsg) return;
278
- const postponed = this[kPostponed];
342
+ const postponed = this[K_POSTPONED];
279
343
  const correlationId = message.properties.correlationId;
280
344
  if (!error && !isRootScope) {
281
345
  message.ack();
@@ -296,8 +360,10 @@ ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarde
296
360
  for (const api of subApis) api.discard();
297
361
  this._publishExecutionCompleted(discardType, (0, _messageHelper.cloneContent)(message.content), correlationId);
298
362
  };
363
+
364
+ /** @internal */
299
365
  ActivityExecution.prototype._publishExecutionCompleted = function publishExecutionCompleted(completionType, completeContent, correlationId) {
300
- this[kCompleted] = true;
366
+ this[_constants.K_COMPLETED] = true;
301
367
  this.broker.publish('execution', `execution.${completionType}`, {
302
368
  ...completeContent,
303
369
  state: completionType
@@ -306,11 +372,13 @@ ActivityExecution.prototype._publishExecutionCompleted = function publishExecuti
306
372
  correlationId
307
373
  });
308
374
  };
375
+
376
+ /** @internal */
309
377
  ActivityExecution.prototype._ackPostponed = function ackPostponed(completeMessage) {
310
378
  const {
311
379
  executionId: eid
312
380
  } = completeMessage.content;
313
- const postponed = this[kPostponed];
381
+ const postponed = this[K_POSTPONED];
314
382
  for (const msg of postponed) {
315
383
  if (msg.content.executionId === eid) {
316
384
  postponed.delete(msg);
@@ -319,24 +387,28 @@ ActivityExecution.prototype._ackPostponed = function ackPostponed(completeMessag
319
387
  }
320
388
  }
321
389
  };
390
+
391
+ /** @internal */
322
392
  ActivityExecution.prototype._onParentApiMessage = function onParentApiMessage(routingKey, message) {
323
393
  switch (message.properties.type) {
324
394
  case 'error':
325
- return this[kExecuteQ].queueMessage({
395
+ return this[K_EXECUTE_Q].queueMessage({
326
396
  routingKey: 'execute.error'
327
397
  }, {
328
398
  error: message.content.error
329
399
  });
330
400
  case 'discard':
331
- return this[kExecuteQ].queueMessage({
401
+ return this[K_EXECUTE_Q].queueMessage({
332
402
  routingKey: 'execute.discard'
333
- }, (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
403
+ }, (0, _messageHelper.cloneContent)(this[_constants.K_EXECUTE_MESSAGE].content));
334
404
  case 'stop':
335
405
  {
336
406
  return this._onStop(message);
337
407
  }
338
408
  }
339
409
  };
410
+
411
+ /** @internal */
340
412
  ActivityExecution.prototype._onStop = function onStop(message) {
341
413
  const stoppedId = message?.content?.executionId;
342
414
  const running = this.getPostponed();
@@ -348,16 +420,17 @@ ActivityExecution.prototype._onStop = function onStop(message) {
348
420
  this.broker.cancel('_activity-execute');
349
421
  this.broker.cancel('_activity-api-execution');
350
422
  };
423
+
424
+ /** @internal */
351
425
  ActivityExecution.prototype._debug = function debug(logMessage, executionId) {
352
426
  executionId = executionId || this.executionId;
353
427
  this.activity.logger.debug(`<${executionId} (${this.id})> ${logMessage}`);
354
428
  };
355
429
  function getExecuteMessage(message) {
356
- const result = (0, _messageHelper.cloneMessage)(message, {
430
+ return (0, _messageHelper.cloneMessage)(message, {
357
431
  ...(message.fields.redelivered && {
358
432
  isRecovered: true
359
433
  }),
360
434
  ignoreIfExecuting: undefined
361
435
  });
362
- return result;
363
436
  }
@@ -3,8 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = DummyActivity;
6
+ exports.DummyActivity = DummyActivity;
7
7
  var _messageHelper = require("../messageHelper.js");
8
+ /**
9
+ * Placeholder activity for non-executable elements (text annotations, groups, categories).
10
+ * @param {import('moddle-context-serializer').Activity} activityDef
11
+ * @returns {{ id: string, type: string, name: string | undefined, behaviour: Record<string, any>, parent: import('#types').ElementParent, placeholder: true }}
12
+ */
8
13
  function DummyActivity(activityDef) {
9
14
  const {
10
15
  id,
@@ -3,36 +3,48 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Escalation;
7
- function Escalation(signalDef, context) {
6
+ exports.Escalation = Escalation;
7
+ /**
8
+ * Escalation reference element. Resolves the escalation name expression against the execution message.
9
+ * @param {import('moddle-context-serializer').SerializableElement} escalationDef
10
+ * @param {import('#types').ContextInstance} context
11
+ */
12
+ function Escalation(escalationDef, context) {
13
+ if (!(this instanceof Escalation)) return new Escalation(escalationDef, context);
8
14
  const {
9
15
  id,
10
16
  type,
11
17
  name,
12
- parent: originalParent
13
- } = signalDef;
14
- const {
15
- environment
16
- } = context;
17
- const parent = {
18
- ...originalParent
18
+ parent
19
+ } = escalationDef;
20
+ this.id = id;
21
+ this.type = type;
22
+ this.name = name;
23
+ /** @type {import('#types').ElementParent} */
24
+ this.parent = {
25
+ ...parent
19
26
  };
20
- return {
27
+ this.environment = context.environment;
28
+ }
29
+
30
+ /**
31
+ * Resolve escalation reference for the given execution message.
32
+ * @param {import('#types').ElementBrokerMessage} executionMessage
33
+ */
34
+ Escalation.prototype.resolve = function resolve(executionMessage) {
35
+ const {
21
36
  id,
22
37
  type,
23
38
  name,
24
- parent,
25
- resolve
39
+ parent
40
+ } = this;
41
+ return {
42
+ id,
43
+ type,
44
+ messageType: 'escalation',
45
+ name: name && this.environment.resolveExpression(name, executionMessage),
46
+ parent: {
47
+ ...parent
48
+ }
26
49
  };
27
- function resolve(executionMessage) {
28
- return {
29
- id,
30
- type,
31
- messageType: 'escalation',
32
- name: name && environment.resolveExpression(name, executionMessage),
33
- parent: {
34
- ...parent
35
- }
36
- };
37
- }
38
- }
50
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = ExecutionScope;
6
+ exports.ExecutionScope = ExecutionScope;
7
7
  var _messageHelper = require("../messageHelper.js");
8
8
  var _Errors = require("../error/Errors.js");
9
9
  function ExecutionScope(activity, initMessage) {
@@ -3,38 +3,50 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Message;
6
+ exports.Message = Message;
7
+ /**
8
+ * Message reference element. Resolves the message name expression against the execution message.
9
+ * @param {import('moddle-context-serializer').SerializableElement} messageDef
10
+ * @param {import('#types').ContextInstance} context
11
+ */
7
12
  function Message(messageDef, context) {
13
+ if (!(this instanceof Message)) return new Message(messageDef, context);
8
14
  const {
9
15
  id,
10
16
  type,
11
17
  name,
12
- parent: originalParent
18
+ parent
13
19
  } = messageDef;
14
- const {
15
- environment
16
- } = context;
17
- const parent = {
18
- ...originalParent
20
+ this.id = id;
21
+ this.type = type;
22
+ this.name = name;
23
+ /** @type {import('#types').ElementParent} */
24
+ this.parent = {
25
+ ...parent
19
26
  };
20
- return {
27
+ this.environment = context.environment;
28
+ }
29
+
30
+ /**
31
+ * Resolve message reference for the given execution message.
32
+ * @param {import('#types').ElementBrokerMessage} executionMessage
33
+ */
34
+ Message.prototype.resolve = function resolve(executionMessage) {
35
+ const {
21
36
  id,
22
37
  type,
23
38
  name,
24
- parent,
25
- resolve
39
+ parent
40
+ } = this;
41
+ return {
42
+ id,
43
+ type,
44
+ messageType: 'message',
45
+ ...(name && {
46
+ name: this.environment.resolveExpression(name, executionMessage)
47
+ }),
48
+ parent: {
49
+ ...parent
50
+ }
26
51
  };
27
- function resolve(executionMessage) {
28
- return {
29
- id,
30
- type,
31
- messageType: 'message',
32
- ...(name && {
33
- name: environment.resolveExpression(name, executionMessage)
34
- }),
35
- parent: {
36
- ...parent
37
- }
38
- };
39
- }
40
- }
52
+ };
@@ -3,38 +3,50 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Signal;
6
+ exports.Signal = Signal;
7
+ /**
8
+ * Signal reference element. Resolves the signal name expression against the execution message.
9
+ * @param {import('moddle-context-serializer').SerializableElement} signalDef
10
+ * @param {import('#types').ContextInstance} context
11
+ */
7
12
  function Signal(signalDef, context) {
13
+ if (!(this instanceof Signal)) return new Signal(signalDef, context);
8
14
  const {
9
15
  id,
10
16
  type = 'Signal',
11
17
  name,
12
- parent: originalParent
18
+ parent
13
19
  } = signalDef;
14
- const {
15
- environment
16
- } = context;
17
- const parent = {
18
- ...originalParent
20
+ this.id = id;
21
+ this.type = type;
22
+ this.name = name;
23
+ /** @type {import('#types').ElementParent} */
24
+ this.parent = {
25
+ ...parent
19
26
  };
20
- return {
27
+ this.environment = context.environment;
28
+ }
29
+
30
+ /**
31
+ * Resolve signal reference for the given execution message.
32
+ * @param {import('#types').ElementBrokerMessage} executionMessage
33
+ */
34
+ Signal.prototype.resolve = function resolve(executionMessage) {
35
+ const {
21
36
  id,
22
37
  type,
23
38
  name,
24
- parent,
25
- resolve
39
+ parent
40
+ } = this;
41
+ return {
42
+ id,
43
+ type,
44
+ messageType: 'signal',
45
+ ...(name && {
46
+ name: this.environment.resolveExpression(name, executionMessage)
47
+ }),
48
+ parent: {
49
+ ...parent
50
+ }
26
51
  };
27
- function resolve(executionMessage) {
28
- return {
29
- id,
30
- type,
31
- messageType: 'signal',
32
- ...(name && {
33
- name: environment.resolveExpression(name, executionMessage)
34
- }),
35
- parent: {
36
- ...parent
37
- }
38
- };
39
- }
40
- }
52
+ };
@@ -102,7 +102,7 @@ OutboundEvaluator.prototype.completed = function completed(err) {
102
102
  } = this.evaluateArgs;
103
103
  this.broker.cancel(`_flow-evaluation-${evaluationId}`);
104
104
  if (err) return callback(err);
105
- if (!takenCount && this.outboundFlows.length) {
105
+ if (!takenCount && this.outboundFlows.length && fromMessage.content.requireOutbound) {
106
106
  const nonTakenError = new _Errors.ActivityError(`<${this.activity.id}> no conditional flow taken`, fromMessage);
107
107
  return callback(nonTakenError);
108
108
  }