bpmn-elements 11.1.1 → 13.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 (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/Environment.js +15 -15
  3. package/dist/activity/Activity.js +123 -143
  4. package/dist/activity/ActivityExecution.js +1 -3
  5. package/dist/definition/Definition.js +39 -44
  6. package/dist/definition/DefinitionExecution.js +51 -53
  7. package/dist/eventDefinitions/EventDefinitionExecution.js +10 -10
  8. package/dist/eventDefinitions/TimerEventDefinition.js +16 -16
  9. package/dist/events/BoundaryEvent.js +12 -11
  10. package/dist/events/index.js +60 -0
  11. package/dist/flows/Association.js +0 -1
  12. package/dist/flows/MessageFlow.js +0 -1
  13. package/dist/flows/SequenceFlow.js +1 -3
  14. package/dist/gateways/index.js +49 -0
  15. package/dist/getPropertyValue.js +1 -2
  16. package/dist/index.js +2 -2
  17. package/dist/process/Process.js +54 -61
  18. package/dist/process/ProcessExecution.js +31 -33
  19. package/dist/tasks/LoopCharacteristics.js +20 -7
  20. package/dist/tasks/SubProcess.js +33 -61
  21. package/dist/tasks/index.js +93 -0
  22. package/events.d.ts +1 -0
  23. package/gateways.d.ts +1 -0
  24. package/index.d.ts +1 -0
  25. package/package.json +39 -19
  26. package/src/Environment.js +16 -17
  27. package/src/activity/Activity.js +96 -131
  28. package/src/activity/ActivityExecution.js +0 -1
  29. package/src/definition/Definition.js +30 -40
  30. package/src/definition/DefinitionExecution.js +47 -55
  31. package/src/eventDefinitions/EventDefinitionExecution.js +9 -10
  32. package/src/eventDefinitions/TimerEventDefinition.js +14 -16
  33. package/src/events/BoundaryEvent.js +11 -11
  34. package/src/events/index.js +5 -0
  35. package/src/flows/Association.js +0 -1
  36. package/src/flows/MessageFlow.js +0 -1
  37. package/src/flows/SequenceFlow.js +0 -1
  38. package/src/gateways/index.js +4 -0
  39. package/src/process/Process.js +40 -54
  40. package/src/process/ProcessExecution.js +25 -31
  41. package/src/tasks/LoopCharacteristics.js +18 -7
  42. package/src/tasks/SubProcess.js +32 -66
  43. package/src/tasks/index.js +8 -0
  44. package/tasks.d.ts +1 -0
  45. package/types/index.d.ts +69 -767
  46. package/types/types.d.ts +706 -0
@@ -39,39 +39,32 @@ export function SubProcessBehaviour(activity, context) {
39
39
 
40
40
  this[kExecutions] = [];
41
41
  this[kMessageHandlers] = {
42
- onApiRootMessage: this._onApiRootMessage.bind(this),
43
42
  onExecutionCompleted: this._onExecutionCompleted.bind(this),
44
43
  };
45
44
  }
46
45
 
47
- Object.defineProperty(SubProcessBehaviour.prototype, 'execution', {
48
- get() {
49
- return this[kExecutions][0];
46
+ Object.defineProperties(SubProcessBehaviour.prototype, {
47
+ execution: {
48
+ get() {
49
+ return this[kExecutions][0];
50
+ },
50
51
  },
51
- });
52
-
53
- Object.defineProperty(SubProcessBehaviour.prototype, 'executions', {
54
- get() {
55
- return this[kExecutions].slice();
52
+ executions: {
53
+ get() {
54
+ return this[kExecutions].slice();
55
+ },
56
56
  },
57
57
  });
58
58
 
59
59
  SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
60
- const content = executeMessage.content;
60
+ const { isRootScope, executionId } = executeMessage.content;
61
61
 
62
- let executionId = this.executionId;
63
- if (content.isRootScope) {
64
- executionId = this.executionId = content.executionId;
62
+ if (isRootScope) {
63
+ this.executionId = executionId;
65
64
  }
66
65
 
67
66
  const loopCharacteristics = this.loopCharacteristics;
68
- if (loopCharacteristics && content.isRootScope) {
69
- this.broker.subscribeTmp('api', `activity.#.${executionId}`, this[kMessageHandlers].onApiRootMessage, {
70
- noAck: true,
71
- consumerTag: `_api-${executionId}`,
72
- priority: 200,
73
- });
74
-
67
+ if (loopCharacteristics && isRootScope) {
75
68
  return loopCharacteristics.execute(executeMessage);
76
69
  }
77
70
 
@@ -79,22 +72,6 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
79
72
  return processExecution.execute(executeMessage);
80
73
  };
81
74
 
82
- SubProcessBehaviour.prototype.stop = function stop() {
83
- for (const execution of this[kExecutions]) {
84
- this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
85
- this.broker.cancel(`_sub-process-api-${execution.executionId}`);
86
- execution.stop();
87
- }
88
- };
89
-
90
- SubProcessBehaviour.prototype.discard = function discard() {
91
- for (const execution of this[kExecutions]) {
92
- this.broker.cancel(`_sub-process-execution-${execution.executionId}`);
93
- this.broker.cancel(`_sub-process-api-${execution.executionId}`);
94
- execution.discard();
95
- }
96
- };
97
-
98
75
  SubProcessBehaviour.prototype.getState = function getState() {
99
76
  if (this.loopCharacteristics) {
100
77
  return {
@@ -148,28 +125,13 @@ SubProcessBehaviour.prototype.getPostponed = function getPostponed() {
148
125
  }, []);
149
126
  };
150
127
 
151
- SubProcessBehaviour.prototype._onApiRootMessage = function onApiRootMessage(_, message) {
152
- const messageType = message.properties.type;
153
-
154
- switch (messageType) {
155
- case 'stop':
156
- this.broker.cancel(message.fields.consumerTag);
157
- this.stop();
158
- break;
159
- case 'discard':
160
- this.broker.cancel(message.fields.consumerTag);
161
- this.discard();
162
- break;
163
- }
164
- };
165
-
166
128
  SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(executeMessage) {
167
129
  const content = executeMessage.content;
168
130
  const executionId = content.executionId;
169
131
 
170
132
  let execution = this._getExecutionById(executionId);
171
133
  if (execution) {
172
- if (executeMessage.fields.redelivered) this._addListeners(execution, executionId);
134
+ if (executeMessage.fields.redelivered) this._addListeners(executionId);
173
135
  return execution;
174
136
  }
175
137
 
@@ -179,12 +141,12 @@ SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(execut
179
141
  execution = new ProcessExecution(this.activity, subContext);
180
142
  this[kExecutions].push(execution);
181
143
 
182
- this._addListeners(execution, executionId);
144
+ this._addListeners(executionId);
183
145
 
184
146
  return execution;
185
147
  };
186
148
 
187
- SubProcessBehaviour.prototype._addListeners = function addListeners(processExecution, executionId) {
149
+ SubProcessBehaviour.prototype._addListeners = function addListeners(executionId) {
188
150
  this.broker.subscribeTmp('subprocess-execution', `execution.#.${executionId}`, this[kMessageHandlers].onExecutionCompleted, {
189
151
  noAck: true,
190
152
  consumerTag: `_sub-process-execution-${executionId}`,
@@ -200,38 +162,42 @@ SubProcessBehaviour.prototype._onExecutionCompleted = function onExecutionComple
200
162
 
201
163
  switch (messageType) {
202
164
  case 'stopped': {
203
- broker.cancel(message.fields.consumerTag);
204
- break;
165
+ return broker.cancel(message.fields.consumerTag);
205
166
  }
167
+ case 'completed':
206
168
  case 'cancel':
207
169
  case 'discard': {
208
170
  broker.cancel(message.fields.consumerTag);
209
- broker.publish('execution', 'execute.' + messageType, cloneContent(content));
210
- break;
211
- }
212
- case 'completed': {
213
- broker.cancel(message.fields.consumerTag);
214
- broker.publish('execution', 'execute.completed', cloneContent(content));
215
- break;
171
+ return this._completeExecution('execute.' + messageType, content);
216
172
  }
217
173
  case 'error': {
218
174
  broker.cancel(message.fields.consumerTag);
219
175
 
220
176
  const {error} = content;
221
177
  this.activity.logger.error(`<${this.id}>`, error);
222
- broker.publish('execution', 'execute.error', cloneContent(content));
223
- break;
178
+
179
+ return this._completeExecution('execute.error', content);
224
180
  }
225
181
  }
226
182
  };
227
183
 
184
+ SubProcessBehaviour.prototype._completeExecution = function completeExecution(completeRoutingKey, content) {
185
+ if (this.loopCharacteristics) {
186
+ const executions = this[kExecutions];
187
+ const executionIdx = executions.findIndex((pe) => pe.executionId === content.executionId);
188
+ if (executionIdx < 0) return;
189
+ executions.splice(executionIdx, 1);
190
+ }
191
+
192
+ this.broker.publish('execution', completeRoutingKey, cloneContent(content));
193
+ };
194
+
228
195
  SubProcessBehaviour.prototype.getApi = function getApi(apiMessage) {
229
196
  const content = apiMessage.content;
230
197
 
231
198
  if (content.id === this.id) return;
232
199
 
233
200
  let execution;
234
-
235
201
  if ((execution = this._getExecutionById(content.parent.executionId))) {
236
202
  return execution.getApi(apiMessage);
237
203
  }
@@ -0,0 +1,8 @@
1
+ export * from './CallActivity.js';
2
+ export * from './ReceiveTask.js';
3
+ export * from './ScriptTask.js';
4
+ export * from './ServiceTask.js';
5
+ export * from './SignalTask.js';
6
+ export * from './SubProcess.js';
7
+ export * from './Task.js';
8
+ export * from './Transaction.js';
package/tasks.d.ts ADDED
@@ -0,0 +1 @@
1
+ import './types/index.js';