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,205 +13,242 @@ 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 MessageEventDefinition(activity, eventDefinition) {
17
23
  const {
18
24
  id,
19
25
  broker,
20
26
  environment,
21
- isStart,
22
- isThrowing,
23
- getActivityById
27
+ isThrowing
24
28
  } = activity;
25
29
  const {
26
30
  type = 'MessageEventDefinition',
27
31
  behaviour = {}
28
32
  } = eventDefinition;
29
- const {
30
- debug
31
- } = environment.Logger(type.toLowerCase());
32
- const reference = behaviour.messageRef || {
33
- name: 'anonymous'
33
+ this.id = id;
34
+ this.type = type;
35
+ const reference = this.reference = {
36
+ name: 'anonymous',
37
+ ...behaviour.messageRef,
38
+ referenceType: 'message'
34
39
  };
35
- const referenceElement = reference.id && getActivityById(reference.id);
36
- const messageId = referenceElement ? referenceElement.id : 'anonymous';
37
- const messageQueueName = `message-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(messageId)}-q`;
38
- if (!isThrowing || isStart) setupCatch();
39
- const source = {
40
- id,
41
- type,
42
- reference: { ...reference,
43
- referenceType: 'message'
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
- } = resolveReference(executeMessage);
61
- broker.consume(messageQueueName, onCatchMessage, {
62
- noAck: true,
63
- consumerTag: `_onmessage-${executionId}`
64
- });
65
- if (completed) return;
66
- broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
67
- noAck: true,
68
- consumerTag: `_api-${executionId}`,
69
- priority: 400
70
- });
71
- if (parentExecutionId) broker.subscribeTmp('api', `activity.#.${parentExecutionId}`, onApiMessage, {
72
- noAck: true,
73
- consumerTag: `_api-parent-${executionId}`,
74
- priority: 400
75
- });
76
- broker.subscribeTmp('api', '#.signal.*', onCatchMessage, {
77
- noAck: true,
78
- consumerTag: `_api-delegated-${executionId}`
40
+ this.isThrowing = isThrowing;
41
+ this.activity = activity;
42
+ this.broker = broker;
43
+ this.logger = environment.Logger(type.toLowerCase());
44
+ const referenceElement = this[referenceElementSymbol] = reference.id && activity.getActivityById(reference.id);
45
+
46
+ if (!isThrowing) {
47
+ this[completedSymbol] = false;
48
+ const referenceId = referenceElement ? referenceElement.id : 'anonymous';
49
+ const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(referenceId)}-q`;
50
+ this[messageQSymbol] = broker.assertQueue(messageQueueName, {
51
+ autoDelete: false,
52
+ durable: true
79
53
  });
80
- debug(`<${executionId} (${id})> expect ${description}`);
81
- broker.publish('event', 'activity.wait', { ...messageContent,
82
- executionId: parentExecutionId || executionId,
83
- parent: (0, _messageHelper.shiftParent)(parent),
84
- message: { ...referenceMessage
85
- }
54
+ broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
55
+ durable: true
86
56
  });
57
+ }
58
+ }
87
59
 
88
- function onCatchMessage(routingKey, message) {
89
- if ((0, _getPropertyValue.default)(message, 'content.message.id') !== referenceMessage.id) return;
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
- complete('caught', message.content.message, {
102
- correlationId
103
- });
104
- }
60
+ const proto = MessageEventDefinition.prototype;
61
+ Object.defineProperty(proto, 'executionId', {
62
+ get() {
63
+ const message = this[executeMessageSymbol];
64
+ return message && message.content.executionId;
65
+ }
105
66
 
106
- function onApiMessage(routingKey, message) {
107
- const {
108
- type: messageType,
109
- correlationId
110
- } = message.properties;
111
-
112
- switch (messageType) {
113
- case 'message':
114
- case 'signal':
115
- {
116
- return complete('got signal with', message.content.message, {
117
- correlationId
118
- });
119
- }
120
-
121
- case 'discard':
122
- {
123
- completed = true;
124
- stop();
125
- return broker.publish('execution', 'execute.discard', { ...messageContent
126
- }, {
127
- correlationId
128
- });
129
- }
130
-
131
- case 'stop':
132
- {
133
- return stop();
134
- }
135
- }
136
- }
67
+ });
68
+
69
+ proto.execute = function execute(executeMessage) {
70
+ return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
71
+ };
137
72
 
138
- function complete(verb, output, options) {
139
- completed = true;
140
- stop();
141
- debug(`<${executionId} (${id})> ${verb} ${description}`);
142
- broker.publish('event', 'activity.catch', { ...messageContent,
143
- message: { ...output
144
- },
145
- executionId: parentExecutionId || executionId,
146
- parent: (0, _messageHelper.shiftParent)(executeMessage.content.parent)
147
- }, {
148
- type: 'catch'
149
- });
150
- return broker.publish('execution', 'execute.completed', { ...messageContent,
151
- output,
152
- state: 'catch'
153
- }, options);
73
+ proto.executeCatch = function executeCatch(executeMessage) {
74
+ this[executeMessageSymbol] = executeMessage;
75
+ this[completedSymbol] = false;
76
+ const executeContent = executeMessage.content;
77
+ const {
78
+ executionId,
79
+ parent
80
+ } = executeContent;
81
+ const parentExecutionId = parent && parent.executionId;
82
+
83
+ const info = this[referenceInfoSymbol] = this._getReferenceInfo(executeMessage);
84
+
85
+ this._debug(`expect ${info.description}`);
86
+
87
+ const broker = this.broker;
88
+
89
+ const onCatchMessage = this._onCatchMessage.bind(this);
90
+
91
+ this[messageQSymbol].consume(onCatchMessage, {
92
+ noAck: true,
93
+ consumerTag: `_api-message-${executionId}`
94
+ });
95
+ if (this[completedSymbol]) return;
96
+
97
+ const onApiMessage = this._onApiMessage.bind(this);
98
+
99
+ broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
100
+ noAck: true,
101
+ consumerTag: `_api-${executionId}`,
102
+ priority: 400
103
+ });
104
+ broker.subscribeTmp('api', `activity.#.${parentExecutionId}`, onApiMessage, {
105
+ noAck: true,
106
+ consumerTag: `_api-parent-${executionId}`,
107
+ priority: 400
108
+ });
109
+ broker.subscribeTmp('api', '#.signal.*', onCatchMessage, {
110
+ noAck: true,
111
+ consumerTag: `_api-delegated-${executionId}`
112
+ });
113
+ const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
114
+ executionId: parentExecutionId,
115
+ message: { ...info.message
154
116
  }
117
+ });
118
+ waitContent.parent = (0, _messageHelper.shiftParent)(parent);
119
+ broker.publish('event', 'activity.wait', waitContent);
120
+ };
155
121
 
156
- function stop() {
157
- broker.cancel(`_onmessage-${executionId}`);
158
- broker.cancel(`_api-${executionId}`);
159
- broker.cancel(`_api-parent-${executionId}`);
160
- broker.cancel(`_api-delegated-${executionId}`);
161
- broker.purgeQueue(messageQueueName);
122
+ proto.executeThrow = function executeThrow(executeMessage) {
123
+ const executeContent = executeMessage.content;
124
+ const {
125
+ executionId,
126
+ parent
127
+ } = executeContent;
128
+
129
+ const info = this._getReferenceInfo(executeMessage);
130
+
131
+ this.logger.debug(`<${executionId} (${this.activity.id})> message ${info.description}`);
132
+ const broker = this.broker;
133
+ const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
134
+ executionId: parent.executionId,
135
+ message: { ...executeContent.input,
136
+ ...info.message
137
+ },
138
+ state: 'throw'
139
+ });
140
+ throwContent.parent = (0, _messageHelper.shiftParent)(parent);
141
+ broker.publish('event', 'activity.message', throwContent, {
142
+ type: 'message',
143
+ delegate: true
144
+ });
145
+ return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
146
+ };
147
+
148
+ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
149
+ if ((0, _getPropertyValue.default)(message, 'content.message.id') !== this[referenceInfoSymbol].message.id) return;
150
+ const {
151
+ type,
152
+ correlationId
153
+ } = message.properties;
154
+ this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content, {
155
+ message: { ...message.content.message
162
156
  }
163
- }
157
+ }), {
158
+ correlationId,
159
+ type
160
+ });
164
161
 
165
- function executeThrow(executeMessage) {
166
- const messageContent = (0, _messageHelper.cloneContent)(executeMessage.content);
167
- const {
168
- executionId,
169
- parent
170
- } = messageContent;
171
- const parentExecutionId = parent && parent.executionId;
172
- const {
173
- message: referenceMessage,
174
- description
175
- } = resolveReference(executeMessage);
176
- debug(`<${executionId} (${id})> message ${description}`);
177
- broker.publish('event', 'activity.message', { ...(0, _messageHelper.cloneContent)(messageContent),
178
- executionId: parentExecutionId || executionId,
179
- parent: (0, _messageHelper.shiftParent)(parent),
180
- message: { ...messageContent.input,
181
- ...referenceMessage
182
- },
183
- state: 'throw'
184
- }, {
185
- type: 'message',
186
- delegate: true
187
- });
188
- return broker.publish('execution', 'execute.completed', { ...messageContent
189
- });
162
+ this._complete('caught', message.content.message, {
163
+ correlationId
164
+ });
165
+ };
166
+
167
+ proto._onApiMessage = function onApiMessage(routingKey, message) {
168
+ const {
169
+ type,
170
+ correlationId
171
+ } = message.properties;
172
+
173
+ switch (type) {
174
+ case 'message':
175
+ case 'signal':
176
+ {
177
+ return this._complete('got signal with', message.content.message, {
178
+ correlationId
179
+ });
180
+ }
181
+
182
+ case 'discard':
183
+ {
184
+ this[completedSymbol] = true;
185
+
186
+ this._stop();
187
+
188
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content), {
189
+ correlationId
190
+ });
191
+ }
192
+
193
+ case 'stop':
194
+ {
195
+ return this._stop();
196
+ }
190
197
  }
198
+ };
191
199
 
192
- function resolveReference(message) {
193
- if (!referenceElement) {
194
- return {
195
- message: { ...reference
196
- },
197
- description: 'anonymous message'
198
- };
199
- }
200
+ proto._complete = function complete(verb, output, options) {
201
+ this[completedSymbol] = true;
202
+
203
+ this._stop();
200
204
 
201
- const result = {
202
- message: referenceElement.resolve(message)
205
+ this._debug(`${verb} ${this[referenceInfoSymbol].description}`);
206
+
207
+ const broker = this.broker;
208
+ const executeContent = this[executeMessageSymbol].content;
209
+ const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
210
+ message: { ...output
211
+ },
212
+ executionId: executeContent.parent.executionId
213
+ });
214
+ catchContent.parent = (0, _messageHelper.shiftParent)(executeContent.parent);
215
+ broker.publish('event', 'activity.catch', catchContent, {
216
+ type: 'catch'
217
+ });
218
+ return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
219
+ output,
220
+ state: 'catch'
221
+ }), options);
222
+ };
223
+
224
+ proto._stop = function stop() {
225
+ const broker = this.broker,
226
+ executionId = this.executionId;
227
+ broker.cancel(`_api-message-${executionId}`);
228
+ broker.cancel(`_api-${executionId}`);
229
+ broker.cancel(`_api-parent-${executionId}`);
230
+ broker.cancel(`_api-delegated-${executionId}`);
231
+ this[messageQSymbol].purge();
232
+ };
233
+
234
+ proto._getReferenceInfo = function getReferenceInfo(message) {
235
+ const referenceElement = this[referenceElementSymbol];
236
+
237
+ if (!referenceElement) {
238
+ return {
239
+ message: { ...this.reference
240
+ },
241
+ description: 'anonymous message'
203
242
  };
204
- result.description = `${result.message.name} <${result.message.id}>`;
205
- return result;
206
243
  }
207
244
 
208
- function setupCatch() {
209
- broker.assertQueue(messageQueueName, {
210
- autoDelete: false,
211
- durable: true
212
- });
213
- broker.bindQueue(messageQueueName, 'api', '*.message.#', {
214
- durable: true
215
- });
216
- }
217
- }
245
+ const result = {
246
+ message: referenceElement.resolve(message)
247
+ };
248
+ result.description = `${result.message.name} <${result.message.id}>`;
249
+ return result;
250
+ };
251
+
252
+ proto._debug = function debug(msg) {
253
+ this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
254
+ };