bpmn-elements 5.1.3 → 7.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 (119) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/README.md +9 -3
  3. package/dist/index.js +71 -39
  4. package/dist/src/Api.js +77 -76
  5. package/dist/src/Context.js +169 -164
  6. package/dist/src/Environment.js +90 -102
  7. package/dist/src/EventBroker.js +89 -88
  8. package/dist/src/ExtensionsMapper.js +2 -2
  9. package/dist/src/MessageFormatter.js +164 -95
  10. package/dist/src/Scripts.js +6 -2
  11. package/dist/src/Timers.js +4 -6
  12. package/dist/src/activity/Activity.js +1108 -901
  13. package/dist/src/activity/ActivityExecution.js +342 -297
  14. package/dist/src/activity/Dummy.js +3 -3
  15. package/dist/src/definition/Definition.js +498 -444
  16. package/dist/src/definition/DefinitionExecution.js +722 -409
  17. package/dist/src/error/Errors.js +17 -7
  18. package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
  19. package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
  20. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
  21. package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
  22. package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
  23. package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
  24. package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
  25. package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
  26. package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
  27. package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
  28. package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
  29. package/dist/src/events/BoundaryEvent.js +180 -144
  30. package/dist/src/events/EndEvent.js +18 -23
  31. package/dist/src/events/IntermediateCatchEvent.js +44 -58
  32. package/dist/src/events/IntermediateThrowEvent.js +18 -23
  33. package/dist/src/events/StartEvent.js +109 -94
  34. package/dist/src/flows/Association.js +94 -101
  35. package/dist/src/flows/MessageFlow.js +86 -103
  36. package/dist/src/flows/SequenceFlow.js +172 -184
  37. package/dist/src/gateways/EventBasedGateway.js +88 -84
  38. package/dist/src/gateways/ExclusiveGateway.js +13 -16
  39. package/dist/src/gateways/InclusiveGateway.js +11 -14
  40. package/dist/src/gateways/ParallelGateway.js +11 -14
  41. package/dist/src/getPropertyValue.js +34 -34
  42. package/dist/src/io/BpmnIO.js +31 -0
  43. package/dist/src/io/EnvironmentDataObject.js +33 -29
  44. package/dist/src/io/EnvironmentDataStore.js +52 -0
  45. package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
  46. package/dist/src/io/InputOutputSpecification.js +177 -168
  47. package/dist/src/io/Properties.js +252 -0
  48. package/dist/src/messageHelper.js +1 -1
  49. package/dist/src/process/Process.js +433 -359
  50. package/dist/src/process/ProcessExecution.js +744 -645
  51. package/dist/src/shared.js +3 -6
  52. package/dist/src/tasks/CallActivity.js +160 -0
  53. package/dist/src/tasks/LoopCharacteristics.js +309 -330
  54. package/dist/src/tasks/ReceiveTask.js +233 -182
  55. package/dist/src/tasks/ScriptTask.js +35 -41
  56. package/dist/src/tasks/ServiceImplementation.js +13 -20
  57. package/dist/src/tasks/ServiceTask.js +82 -75
  58. package/dist/src/tasks/SignalTask.js +97 -93
  59. package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
  60. package/dist/src/tasks/SubProcess.js +195 -175
  61. package/dist/src/tasks/Task.js +17 -19
  62. package/index.js +8 -0
  63. package/package.json +16 -15
  64. package/src/Api.js +65 -59
  65. package/src/Context.js +142 -132
  66. package/src/Environment.js +88 -100
  67. package/src/EventBroker.js +67 -68
  68. package/src/ExtensionsMapper.js +2 -2
  69. package/src/MessageFormatter.js +132 -74
  70. package/src/Timers.js +4 -4
  71. package/src/activity/Activity.js +916 -757
  72. package/src/activity/ActivityExecution.js +293 -247
  73. package/src/activity/Dummy.js +2 -2
  74. package/src/definition/Definition.js +436 -401
  75. package/src/definition/DefinitionExecution.js +603 -343
  76. package/src/error/Errors.js +11 -6
  77. package/src/eventDefinitions/CancelEventDefinition.js +164 -121
  78. package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
  79. package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
  80. package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
  81. package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
  82. package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
  83. package/src/eventDefinitions/LinkEventDefinition.js +160 -129
  84. package/src/eventDefinitions/MessageEventDefinition.js +178 -121
  85. package/src/eventDefinitions/SignalEventDefinition.js +162 -106
  86. package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
  87. package/src/eventDefinitions/TimerEventDefinition.js +202 -167
  88. package/src/events/BoundaryEvent.js +156 -115
  89. package/src/events/EndEvent.js +15 -18
  90. package/src/events/IntermediateCatchEvent.js +40 -44
  91. package/src/events/IntermediateThrowEvent.js +15 -18
  92. package/src/events/StartEvent.js +84 -50
  93. package/src/flows/Association.js +98 -113
  94. package/src/flows/MessageFlow.js +81 -97
  95. package/src/flows/SequenceFlow.js +145 -163
  96. package/src/gateways/EventBasedGateway.js +75 -68
  97. package/src/gateways/ExclusiveGateway.js +8 -13
  98. package/src/gateways/InclusiveGateway.js +8 -13
  99. package/src/gateways/ParallelGateway.js +8 -13
  100. package/src/getPropertyValue.js +34 -33
  101. package/src/io/BpmnIO.js +20 -0
  102. package/src/io/EnvironmentDataObject.js +29 -18
  103. package/src/io/EnvironmentDataStore.js +33 -0
  104. package/src/io/EnvironmentDataStoreReference.js +33 -0
  105. package/src/io/InputOutputSpecification.js +154 -157
  106. package/src/io/Properties.js +199 -0
  107. package/src/process/Process.js +374 -333
  108. package/src/process/ProcessExecution.js +606 -554
  109. package/src/shared.js +1 -5
  110. package/src/tasks/CallActivity.js +130 -0
  111. package/src/tasks/LoopCharacteristics.js +290 -289
  112. package/src/tasks/ReceiveTask.js +174 -107
  113. package/src/tasks/ScriptTask.js +27 -30
  114. package/src/tasks/ServiceImplementation.js +13 -18
  115. package/src/tasks/ServiceTask.js +67 -60
  116. package/src/tasks/SignalTask.js +77 -52
  117. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  118. package/src/tasks/SubProcess.js +184 -157
  119. package/src/tasks/Task.js +15 -19
@@ -13,193 +13,235 @@ var _messageHelper = require("../messageHelper");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
+ const completedSymbol = Symbol.for('completed');
17
+ const messageQSymbol = Symbol.for('messageQ');
18
+ const executeMessageSymbol = Symbol.for('executeMessage');
19
+ const referenceElementSymbol = Symbol.for('referenceElement');
20
+ const referenceInfoSymbol = Symbol.for('referenceInfo');
21
+
16
22
  function SignalEventDefinition(activity, eventDefinition) {
17
23
  const {
18
24
  id,
19
25
  broker,
20
26
  environment,
21
27
  isStart,
22
- isThrowing,
23
- getActivityById
28
+ isThrowing
24
29
  } = activity;
25
30
  const {
26
31
  type,
27
32
  behaviour = {}
28
33
  } = eventDefinition;
29
- const {
30
- debug
31
- } = environment.Logger(type.toLowerCase());
32
- const reference = behaviour.signalRef || {
33
- name: 'anonymous'
34
+ this.id = id;
35
+ this.type = type;
36
+ const reference = this.reference = {
37
+ name: 'anonymous',
38
+ ...behaviour.signalRef,
39
+ referenceType: 'signal'
34
40
  };
35
- const referenceElement = reference.id && getActivityById(reference.id);
36
- const signalId = referenceElement ? referenceElement.id : 'anonymous';
37
- const signalQueueName = `signal-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(signalId)}-q`;
38
- if (!isThrowing && isStart) setupCatch();
39
- const source = {
40
- id,
41
- type,
42
- reference: { ...reference,
43
- referenceType: 'signal'
44
- },
45
- execute: isThrowing ? executeThrow : executeCatch
46
- };
47
- return source;
48
-
49
- function executeCatch(executeMessage) {
50
- let completed;
51
- const messageContent = (0, _messageHelper.cloneContent)(executeMessage.content);
52
- const {
53
- executionId,
54
- parent
55
- } = messageContent;
56
- const parentExecutionId = parent && parent.executionId;
57
- const {
58
- message: referenceMessage,
59
- description
60
- } = resolveMessage(executeMessage);
61
- if (isStart) broker.consume(signalQueueName, onCatchSignal, {
62
- noAck: true,
63
- consumerTag: `_api-signal-${executionId}`
64
- });
65
- if (completed) return;
66
- broker.subscribeTmp('api', `activity.#.${parentExecutionId}`, onApiMessage, {
67
- noAck: true,
68
- consumerTag: `_api-parent-${parentExecutionId}`
41
+ this.isThrowing = isThrowing;
42
+ this.activity = activity;
43
+ this.broker = broker;
44
+ this.logger = environment.Logger(type.toLowerCase());
45
+ const referenceElement = this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
46
+
47
+ if (!isThrowing && isStart) {
48
+ this[completedSymbol] = false;
49
+ const referenceId = referenceElement ? referenceElement.id : 'anonymous';
50
+ const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
51
+ this[messageQSymbol] = broker.assertQueue(messageQueueName, {
52
+ autoDelete: false,
53
+ durable: true
69
54
  });
70
- broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
71
- noAck: true,
72
- consumerTag: `_api-${executionId}`
55
+ broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
56
+ durable: true
73
57
  });
74
- broker.subscribeTmp('api', '#.signal.*', onCatchSignal, {
58
+ }
59
+ }
60
+
61
+ const proto = SignalEventDefinition.prototype;
62
+ Object.defineProperty(proto, 'executionId', {
63
+ get() {
64
+ const message = this[executeMessageSymbol];
65
+ return message && message.content.executionId;
66
+ }
67
+
68
+ });
69
+
70
+ proto.execute = function execute(executeMessage) {
71
+ return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
72
+ };
73
+
74
+ proto.executeCatch = function executeCatch(executeMessage) {
75
+ this[executeMessageSymbol] = executeMessage;
76
+ this[completedSymbol] = false;
77
+ const executeContent = executeMessage.content;
78
+ const {
79
+ executionId,
80
+ parent
81
+ } = executeContent;
82
+ const parentExecutionId = parent && parent.executionId;
83
+
84
+ const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
85
+
86
+ const broker = this.broker;
87
+
88
+ const onCatchMessage = this._onCatchMessage.bind(this);
89
+
90
+ if (this.activity.isStart) {
91
+ this[messageQSymbol].consume(onCatchMessage, {
75
92
  noAck: true,
76
- consumerTag: `_api-delegated-${executionId}`
77
- });
78
- debug(`<${executionId} (${id})> expect ${description}`);
79
- broker.publish('event', 'activity.wait', { ...messageContent,
80
- executionId: parentExecutionId,
81
- parent: (0, _messageHelper.shiftParent)(parent),
82
- signal: { ...referenceMessage
83
- }
93
+ consumerTag: `_api-signal-${executionId}`
84
94
  });
95
+ if (this[completedSymbol]) return;
96
+ }
85
97
 
86
- function onCatchSignal(routingKey, message) {
87
- if ((0, _getPropertyValue.default)(message, 'content.message.id') !== referenceMessage.id) return;
88
- completed = true;
89
- stop();
90
- const {
91
- type: messageType,
92
- correlationId
93
- } = message.properties;
94
- broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(messageContent, {
95
- message: { ...message.content.message
96
- }
97
- }), {
98
- correlationId,
99
- type: messageType
100
- });
101
- return complete(message.content.message, message.properties);
98
+ const onApiMessage = this._onApiMessage.bind(this);
99
+
100
+ broker.subscribeTmp('api', `activity.#.${parentExecutionId}`, onApiMessage, {
101
+ noAck: true,
102
+ consumerTag: `_api-parent-${executionId}`
103
+ });
104
+ broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
105
+ noAck: true,
106
+ consumerTag: `_api-${executionId}`
107
+ });
108
+ broker.subscribeTmp('api', '#.signal.*', onCatchMessage, {
109
+ noAck: true,
110
+ consumerTag: `_api-delegated-${executionId}`
111
+ });
112
+
113
+ this._debug(`expect ${info.description}`);
114
+
115
+ const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
116
+ executionId: parent.executionId,
117
+ signal: { ...info.message
102
118
  }
119
+ });
120
+ waitContent.parent = (0, _messageHelper.shiftParent)(parent);
121
+ broker.publish('event', 'activity.wait', waitContent);
122
+ };
103
123
 
104
- function onApiMessage(routingKey, message) {
105
- const {
106
- type: messageType,
107
- correlationId
108
- } = message.properties;
109
-
110
- switch (messageType) {
111
- case 'signal':
112
- {
113
- return complete(message.content.message, {
114
- correlationId
115
- });
116
- }
117
-
118
- case 'discard':
119
- {
120
- completed = true;
121
- stop();
122
- return broker.publish('execution', 'execute.discard', { ...messageContent
123
- }, {
124
- correlationId
125
- });
126
- }
127
-
128
- case 'stop':
129
- {
130
- stop();
131
- break;
132
- }
133
- }
134
- }
124
+ proto.executeThrow = function executeThrow(executeMessage) {
125
+ const executeContent = executeMessage.content;
126
+ const {
127
+ executionId,
128
+ parent
129
+ } = executeContent;
135
130
 
136
- function complete(output, options) {
137
- completed = true;
138
- stop();
139
- debug(`<${executionId} (${id})> signaled with`, description);
140
- return broker.publish('execution', 'execute.completed', { ...messageContent,
141
- output,
142
- state: 'signal'
143
- }, options);
144
- }
131
+ const info = this._getReferenceInfo(executeMessage);
132
+
133
+ this.logger.debug(`<${executionId} (${this.activity.id})> throw ${info.description}`);
134
+ const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
135
+ executionId: parent.executionId,
136
+ message: { ...executeContent.input,
137
+ ...info.message
138
+ },
139
+ state: 'throw'
140
+ });
141
+ throwContent.parent = (0, _messageHelper.shiftParent)(parent);
142
+ const broker = this.broker;
143
+ broker.publish('event', 'activity.signal', throwContent, {
144
+ type: 'signal'
145
+ });
146
+ return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
147
+ };
148
+
149
+ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
150
+ const info = this[referenceInfoSymbol];
151
+ if ((0, _getPropertyValue.default)(message, 'content.message.id') !== info.message.id) return;
152
+ this[completedSymbol] = true;
153
+
154
+ this._stop();
145
155
 
146
- function stop() {
147
- broker.cancel(`_api-signal-${executionId}`);
148
- broker.cancel(`_api-parent-${parentExecutionId}`);
149
- broker.cancel(`_api-${executionId}`);
150
- broker.cancel(`_api-delegated-${executionId}`);
151
- if (isStart) broker.purgeQueue(signalQueueName);
156
+ const {
157
+ type,
158
+ correlationId
159
+ } = message.properties;
160
+ this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, {
161
+ message: { ...message.content.message
152
162
  }
153
- }
163
+ }), {
164
+ correlationId,
165
+ type
166
+ });
167
+ return this._complete(message.content.message, message.properties);
168
+ };
169
+
170
+ proto._onApiMessage = function onApiMessage(routingKey, message) {
171
+ const {
172
+ type,
173
+ correlationId
174
+ } = message.properties;
175
+
176
+ switch (type) {
177
+ case 'signal':
178
+ {
179
+ return this._complete(message.content.message, {
180
+ correlationId
181
+ });
182
+ }
154
183
 
155
- function executeThrow(executeMessage) {
156
- const messageContent = (0, _messageHelper.cloneContent)(executeMessage.content);
157
- const {
158
- executionId,
159
- parent
160
- } = messageContent;
161
- const parentExecutionId = parent && parent.executionId;
162
- const {
163
- message: referenceMessage,
164
- description
165
- } = resolveMessage(executeMessage);
166
- debug(`<${executionId} (${id})> throw ${description}`);
167
- broker.publish('event', 'activity.signal', { ...(0, _messageHelper.cloneContent)(messageContent),
168
- executionId: parentExecutionId,
169
- parent: (0, _messageHelper.shiftParent)(parent),
170
- message: { ...messageContent.input,
171
- ...referenceMessage
172
- },
173
- state: 'throw'
174
- }, {
175
- type: 'signal'
176
- });
177
- return broker.publish('execution', 'execute.completed', messageContent);
184
+ case 'discard':
185
+ {
186
+ this[completedSymbol] = true;
187
+
188
+ this._stop();
189
+
190
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content), {
191
+ correlationId
192
+ });
193
+ }
194
+
195
+ case 'stop':
196
+ {
197
+ this._stop();
198
+
199
+ break;
200
+ }
178
201
  }
202
+ };
179
203
 
180
- function resolveMessage(message) {
181
- if (!referenceElement) {
182
- return {
183
- message: { ...reference
184
- },
185
- description: 'anonymous signal'
186
- };
187
- }
204
+ proto._complete = function complete(output, options) {
205
+ this[completedSymbol] = true;
206
+
207
+ this._stop();
208
+
209
+ this._debug(`signaled with ${this[referenceInfoSymbol].description}`);
188
210
 
189
- const result = {
190
- message: referenceElement.resolve(message)
211
+ return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, {
212
+ output,
213
+ state: 'signal'
214
+ }), options);
215
+ };
216
+
217
+ proto._stop = function stop() {
218
+ const broker = this.broker,
219
+ executionId = this.executionId;
220
+ broker.cancel(`_api-signal-${executionId}`);
221
+ broker.cancel(`_api-parent-${executionId}`);
222
+ broker.cancel(`_api-${executionId}`);
223
+ broker.cancel(`_api-delegated-${executionId}`);
224
+ if (this.activity.isStart) this[messageQSymbol].purge();
225
+ };
226
+
227
+ proto._getReferenceInfo = function getReferenceInfo(message) {
228
+ const referenceElement = this[referenceElementSymbol];
229
+
230
+ if (!referenceElement) {
231
+ return {
232
+ message: { ...this.reference
233
+ },
234
+ description: 'anonymous signal'
191
235
  };
192
- result.description = `${result.message.name} <${result.message.id}>`;
193
- return result;
194
236
  }
195
237
 
196
- function setupCatch() {
197
- broker.assertQueue(signalQueueName, {
198
- autoDelete: false,
199
- durable: true
200
- });
201
- broker.bindQueue(signalQueueName, 'api', '*.signal.#', {
202
- durable: true
203
- });
204
- }
205
- }
238
+ const result = {
239
+ message: referenceElement.resolve(message)
240
+ };
241
+ result.description = `${result.message.name} <${result.message.id}>`;
242
+ return result;
243
+ };
244
+
245
+ proto._debug = function debug(msg) {
246
+ this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
247
+ };
@@ -7,34 +7,32 @@ exports.default = TerminateEventDefinition;
7
7
 
8
8
  var _messageHelper = require("../messageHelper");
9
9
 
10
- function TerminateEventDefinition(activity, eventDefinition = {}) {
10
+ function TerminateEventDefinition(activity, eventDefinition) {
11
11
  const {
12
12
  id,
13
13
  broker,
14
14
  environment
15
15
  } = activity;
16
16
  const {
17
- type = 'terminateeventdefinition'
17
+ type = 'TerminateEventDefinition'
18
18
  } = eventDefinition;
19
- const {
20
- debug
21
- } = environment.Logger(type.toLowerCase());
22
- const source = {
23
- id,
24
- type,
25
- execute
26
- };
27
- return source;
19
+ this.id = id;
20
+ this.type = type;
21
+ this.activity = activity;
22
+ this.broker = broker;
23
+ this.logger = environment.Logger(type.toLowerCase());
24
+ }
28
25
 
29
- function execute(executeMessage) {
30
- const content = (0, _messageHelper.cloneContent)(executeMessage.content);
31
- const terminateContent = (0, _messageHelper.cloneContent)(content);
32
- terminateContent.parent = (0, _messageHelper.shiftParent)(terminateContent.parent);
33
- terminateContent.state = 'terminate';
34
- debug(`<${content.executionId} (${content.id})> terminate`);
35
- broker.publish('event', 'process.terminate', terminateContent, {
36
- type: 'terminate'
37
- });
38
- broker.publish('execution', 'execute.completed', content);
39
- }
40
- }
26
+ TerminateEventDefinition.prototype.execute = function execute(executeMessage) {
27
+ const executeContent = executeMessage.content;
28
+ const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
29
+ state: 'terminate'
30
+ });
31
+ throwContent.parent = (0, _messageHelper.shiftParent)(executeContent.parent);
32
+ this.logger.debug(`<${executeContent.executionId} (${executeContent.id})> terminate`);
33
+ const broker = this.broker;
34
+ broker.publish('event', 'process.terminate', throwContent, {
35
+ type: 'terminate'
36
+ });
37
+ broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
38
+ };