bpmn-elements 6.0.1 → 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 (116) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/README.md +3 -0
  3. package/dist/index.js +52 -44
  4. package/dist/src/Api.js +77 -76
  5. package/dist/src/Context.js +169 -175
  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/activity/Activity.js +1106 -916
  12. package/dist/src/activity/ActivityExecution.js +342 -297
  13. package/dist/src/activity/Dummy.js +3 -3
  14. package/dist/src/definition/Definition.js +498 -444
  15. package/dist/src/definition/DefinitionExecution.js +722 -409
  16. package/dist/src/error/Errors.js +17 -7
  17. package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
  18. package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
  19. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
  20. package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
  21. package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
  22. package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
  23. package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
  24. package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
  25. package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
  26. package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
  27. package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
  28. package/dist/src/events/BoundaryEvent.js +180 -144
  29. package/dist/src/events/EndEvent.js +18 -23
  30. package/dist/src/events/IntermediateCatchEvent.js +44 -58
  31. package/dist/src/events/IntermediateThrowEvent.js +18 -23
  32. package/dist/src/events/StartEvent.js +109 -94
  33. package/dist/src/flows/Association.js +94 -100
  34. package/dist/src/flows/MessageFlow.js +86 -103
  35. package/dist/src/flows/SequenceFlow.js +173 -182
  36. package/dist/src/gateways/EventBasedGateway.js +88 -84
  37. package/dist/src/gateways/ExclusiveGateway.js +13 -16
  38. package/dist/src/gateways/InclusiveGateway.js +11 -14
  39. package/dist/src/gateways/ParallelGateway.js +11 -14
  40. package/dist/src/getPropertyValue.js +34 -34
  41. package/dist/src/io/BpmnIO.js +17 -14
  42. package/dist/src/io/EnvironmentDataObject.js +33 -29
  43. package/dist/src/io/EnvironmentDataStore.js +33 -29
  44. package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
  45. package/dist/src/io/InputOutputSpecification.js +177 -168
  46. package/dist/src/io/Properties.js +117 -124
  47. package/dist/src/messageHelper.js +1 -1
  48. package/dist/src/process/Process.js +433 -359
  49. package/dist/src/process/ProcessExecution.js +744 -645
  50. package/dist/src/shared.js +2 -2
  51. package/dist/src/tasks/CallActivity.js +160 -0
  52. package/dist/src/tasks/LoopCharacteristics.js +309 -330
  53. package/dist/src/tasks/ReceiveTask.js +233 -182
  54. package/dist/src/tasks/ScriptTask.js +35 -41
  55. package/dist/src/tasks/ServiceImplementation.js +13 -20
  56. package/dist/src/tasks/ServiceTask.js +82 -75
  57. package/dist/src/tasks/SignalTask.js +97 -93
  58. package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
  59. package/dist/src/tasks/SubProcess.js +195 -175
  60. package/dist/src/tasks/Task.js +17 -19
  61. package/index.js +2 -0
  62. package/package.json +13 -13
  63. package/src/Api.js +65 -59
  64. package/src/Context.js +138 -141
  65. package/src/Environment.js +88 -100
  66. package/src/EventBroker.js +67 -68
  67. package/src/ExtensionsMapper.js +2 -2
  68. package/src/MessageFormatter.js +132 -74
  69. package/src/activity/Activity.js +915 -775
  70. package/src/activity/ActivityExecution.js +293 -247
  71. package/src/activity/Dummy.js +2 -2
  72. package/src/definition/Definition.js +436 -401
  73. package/src/definition/DefinitionExecution.js +603 -343
  74. package/src/error/Errors.js +11 -6
  75. package/src/eventDefinitions/CancelEventDefinition.js +164 -121
  76. package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
  77. package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
  78. package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
  79. package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
  80. package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
  81. package/src/eventDefinitions/LinkEventDefinition.js +160 -129
  82. package/src/eventDefinitions/MessageEventDefinition.js +178 -121
  83. package/src/eventDefinitions/SignalEventDefinition.js +162 -106
  84. package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
  85. package/src/eventDefinitions/TimerEventDefinition.js +202 -167
  86. package/src/events/BoundaryEvent.js +156 -115
  87. package/src/events/EndEvent.js +15 -18
  88. package/src/events/IntermediateCatchEvent.js +40 -44
  89. package/src/events/IntermediateThrowEvent.js +15 -18
  90. package/src/events/StartEvent.js +84 -50
  91. package/src/flows/Association.js +98 -112
  92. package/src/flows/MessageFlow.js +81 -97
  93. package/src/flows/SequenceFlow.js +146 -160
  94. package/src/gateways/EventBasedGateway.js +75 -68
  95. package/src/gateways/ExclusiveGateway.js +8 -13
  96. package/src/gateways/InclusiveGateway.js +8 -13
  97. package/src/gateways/ParallelGateway.js +8 -13
  98. package/src/getPropertyValue.js +34 -33
  99. package/src/io/BpmnIO.js +16 -15
  100. package/src/io/EnvironmentDataObject.js +29 -18
  101. package/src/io/EnvironmentDataStore.js +29 -18
  102. package/src/io/EnvironmentDataStoreReference.js +31 -20
  103. package/src/io/InputOutputSpecification.js +154 -157
  104. package/src/io/Properties.js +95 -97
  105. package/src/process/Process.js +374 -333
  106. package/src/process/ProcessExecution.js +606 -554
  107. package/src/tasks/CallActivity.js +130 -0
  108. package/src/tasks/LoopCharacteristics.js +290 -289
  109. package/src/tasks/ReceiveTask.js +174 -107
  110. package/src/tasks/ScriptTask.js +27 -30
  111. package/src/tasks/ServiceImplementation.js +13 -18
  112. package/src/tasks/ServiceTask.js +67 -60
  113. package/src/tasks/SignalTask.js +77 -52
  114. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  115. package/src/tasks/SubProcess.js +184 -157
  116. package/src/tasks/Task.js +15 -19
@@ -9,28 +9,28 @@ var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ const propertiesSymbol = Symbol.for('properties');
13
+ const consumingSymbol = Symbol.for('consuming');
14
+
12
15
  function Properties(activity, propertiesDef, context) {
13
- if (!propertiesDef || !propertiesDef.values || !propertiesDef.values.length) return;
14
- const {
15
- broker,
16
- environment
17
- } = activity;
18
- const formatQ = broker.getQueue('format-run-q');
19
- let activityConsumer;
20
- const {
21
- properties,
22
- dataInputObjects,
23
- dataOutputObjects
24
- } = propertiesDef.values.reduce((result, {
16
+ this.activity = activity;
17
+ this.broker = activity.broker;
18
+ const props = this[propertiesSymbol] = {
19
+ properties: [],
20
+ dataInputObjects: [],
21
+ dataOutputObjects: []
22
+ };
23
+
24
+ for (const {
25
25
  id,
26
26
  ...def
27
- }) => {
27
+ } of propertiesDef.values) {
28
28
  const source = {
29
29
  id,
30
30
  type: def.type,
31
- name: def.name
31
+ name: def.behaviour && def.behaviour.name
32
32
  };
33
- result.properties.push(source);
33
+ props.properties.push(source);
34
34
  const inputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataObject.id');
35
35
  const outputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataOutput.association.target.dataObject.id');
36
36
  const inputDataStoreId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataStore.id');
@@ -38,7 +38,7 @@ function Properties(activity, propertiesDef, context) {
38
38
 
39
39
  if (inputDataObjectId) {
40
40
  const reference = context.getDataObjectById(inputDataObjectId);
41
- result.dataInputObjects.push({
41
+ props.dataInputObjects.push({
42
42
  id,
43
43
  reference
44
44
  });
@@ -49,7 +49,7 @@ function Properties(activity, propertiesDef, context) {
49
49
 
50
50
  if (outputDataObjectId) {
51
51
  const reference = context.getDataObjectById(outputDataObjectId);
52
- result.dataOutputObjects.push({
52
+ props.dataOutputObjects.push({
53
53
  id,
54
54
  reference: reference
55
55
  });
@@ -60,7 +60,7 @@ function Properties(activity, propertiesDef, context) {
60
60
 
61
61
  if (inputDataStoreId) {
62
62
  const reference = context.getDataStoreById(inputDataStoreId);
63
- result.dataInputObjects.push({
63
+ props.dataInputObjects.push({
64
64
  id,
65
65
  reference
66
66
  });
@@ -71,7 +71,7 @@ function Properties(activity, propertiesDef, context) {
71
71
 
72
72
  if (outputDataStoreId) {
73
73
  const reference = context.getDataStoreById(outputDataStoreId);
74
- result.dataOutputObjects.push({
74
+ props.dataOutputObjects.push({
75
75
  id,
76
76
  reference
77
77
  });
@@ -79,131 +79,126 @@ function Properties(activity, propertiesDef, context) {
79
79
  reference
80
80
  };
81
81
  }
82
+ }
83
+ }
82
84
 
83
- return result;
84
- }, {
85
- properties: [],
86
- dataInputObjects: [],
87
- dataOutputObjects: []
88
- });
89
- const propertiesApi = {
90
- type: 'properties',
91
- activate,
92
- deactivate
93
- };
94
- return propertiesApi;
95
-
96
- function activate(message) {
97
- if (activityConsumer) return;
85
+ const proto = Properties.prototype;
98
86
 
99
- if (message.fields.redelivered && message.content.properties) {
100
- onActivityEvent('activity.extension.resume', message);
101
- }
87
+ proto.activate = function activate(message) {
88
+ if (this[consumingSymbol]) return;
102
89
 
103
- activityConsumer = broker.subscribeTmp('event', 'activity.#', onActivityEvent, {
104
- noAck: true
105
- });
90
+ if (message.fields.redelivered && message.content.properties) {
91
+ this._onActivityEvent('activity.extension.resume', message);
106
92
  }
107
93
 
108
- function deactivate() {
109
- if (activityConsumer) activityConsumer = activityConsumer.cancel();
110
- }
94
+ this[consumingSymbol] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
95
+ noAck: true
96
+ });
97
+ };
111
98
 
112
- function onActivityEvent(routingKey, message) {
113
- if (routingKey === 'activity.enter') {
114
- return formatOnEnter(message);
115
- }
99
+ proto.deactivate = function deactivate() {
100
+ if (this[consumingSymbol]) this[consumingSymbol] = this[consumingSymbol].cancel();
101
+ };
116
102
 
117
- if (routingKey === 'activity.extension.resume') {
118
- return formatOnEnter(message);
119
- }
103
+ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
104
+ if (routingKey === 'activity.enter') {
105
+ return this._formatOnEnter(message);
106
+ }
120
107
 
121
- if (routingKey === 'activity.execution.completed') {
122
- return formatOnComplete(message);
123
- }
108
+ if (routingKey === 'activity.extension.resume') {
109
+ return this._formatOnEnter(message);
124
110
  }
125
111
 
126
- function formatOnEnter(message) {
127
- const startRoutingKey = 'run.enter.bpmn-properties';
112
+ if (routingKey === 'activity.execution.completed') {
113
+ return this._formatOnComplete(message);
114
+ }
115
+ };
128
116
 
129
- if (!dataInputObjects.length) {
130
- return formatQ.queueMessage({
131
- routingKey: startRoutingKey
132
- }, {
133
- properties: getProperties(message)
134
- });
135
- }
117
+ proto._formatOnEnter = function formatOnEnter(message) {
118
+ const startRoutingKey = 'run.enter.bpmn-properties';
119
+ const dataInputObjects = this[propertiesSymbol].dataInputObjects;
120
+ const broker = this.broker;
136
121
 
137
- const endRoutingKey = 'run.enter.bpmn-properties.end';
138
- formatQ.queueMessage({
122
+ if (!dataInputObjects.length) {
123
+ return broker.getQueue('format-run-q').queueMessage({
139
124
  routingKey: startRoutingKey
140
125
  }, {
141
- endRoutingKey,
142
- properties: getProperties(message)
143
- });
144
- return read(broker, dataInputObjects, (_, responses) => {
145
- broker.publish('format', endRoutingKey, {
146
- properties: getProperties(message, responses)
147
- });
126
+ properties: this._getProperties(message)
148
127
  });
149
128
  }
150
129
 
151
- function formatOnComplete(message) {
152
- const startRoutingKey = 'run.end.bpmn-properties';
153
- const messageOutput = (0, _getPropertyValue.default)(message, 'content.output.properties') || {};
154
- const outputProperties = getProperties(message, messageOutput);
130
+ const endRoutingKey = 'run.enter.bpmn-properties.end';
131
+ broker.getQueue('format-run-q').queueMessage({
132
+ routingKey: startRoutingKey
133
+ }, {
134
+ endRoutingKey,
135
+ properties: this._getProperties(message)
136
+ });
137
+ return read(broker, dataInputObjects, (_, responses) => {
138
+ broker.publish('format', endRoutingKey, {
139
+ properties: this._getProperties(message, responses)
140
+ });
141
+ });
142
+ };
155
143
 
156
- if (!dataOutputObjects.length) {
157
- return formatQ.queueMessage({
158
- routingKey: startRoutingKey
159
- }, {
160
- properties: outputProperties
161
- });
162
- }
144
+ proto._formatOnComplete = function formatOnComplete(message) {
145
+ const startRoutingKey = 'run.end.bpmn-properties';
146
+ const messageOutput = (0, _getPropertyValue.default)(message, 'content.output.properties') || {};
147
+
148
+ const outputProperties = this._getProperties(message, messageOutput);
163
149
 
164
- const endRoutingKey = 'run.end.bpmn-properties.end';
165
- formatQ.queueMessage({
150
+ const dataOutputObjects = this[propertiesSymbol].dataOutputObjects;
151
+ const broker = this.broker;
152
+
153
+ if (!dataOutputObjects.length) {
154
+ return broker.getQueue('format-run-q').queueMessage({
166
155
  routingKey: startRoutingKey
167
156
  }, {
168
- endRoutingKey,
169
157
  properties: outputProperties
170
158
  });
171
- return write(broker, dataOutputObjects, outputProperties, (_, responses) => {
172
- broker.publish('format', endRoutingKey, {
173
- properties: getProperties(message, responses)
174
- });
175
- });
176
159
  }
177
160
 
178
- function getProperties(message, values) {
179
- let response = {};
161
+ const endRoutingKey = 'run.end.bpmn-properties.end';
162
+ broker.getQueue('format-run-q').queueMessage({
163
+ routingKey: startRoutingKey
164
+ }, {
165
+ endRoutingKey,
166
+ properties: outputProperties
167
+ });
168
+ return write(broker, dataOutputObjects, outputProperties, (_, responses) => {
169
+ broker.publish('format', endRoutingKey, {
170
+ properties: this._getProperties(message, responses)
171
+ });
172
+ });
173
+ };
180
174
 
181
- if (message.content.properties) {
182
- response = { ...message.content.properties
175
+ proto._getProperties = function getProperties(message, values) {
176
+ let response = {};
177
+
178
+ if (message.content.properties) {
179
+ response = { ...message.content.properties
180
+ };
181
+ }
182
+
183
+ for (const {
184
+ id,
185
+ type,
186
+ name
187
+ } of this[propertiesSymbol].properties) {
188
+ if (!(id in response)) {
189
+ response[id] = {
190
+ id,
191
+ type,
192
+ name
183
193
  };
184
194
  }
185
195
 
186
- return properties.reduce((result, {
187
- id,
188
- type,
189
- name,
190
- value
191
- }) => {
192
- if (!(id in result)) {
193
- result[id] = {
194
- id,
195
- type,
196
- name
197
- };
198
- }
199
-
200
- if (value !== undefined) result[id].value = environment.resolveExpression(value, message);
201
- if (!values || !(id in values)) return result;
202
- result[id].value = values[id].value;
203
- return result;
204
- }, response);
196
+ if (!values || !(id in values)) continue;
197
+ response[id].value = values[id].value;
205
198
  }
206
- }
199
+
200
+ return response;
201
+ };
207
202
 
208
203
  function read(broker, dataReferences, callback) {
209
204
  const responses = {};
@@ -212,11 +207,10 @@ function read(broker, dataReferences, callback) {
212
207
  noAck: true
213
208
  });
214
209
 
215
- for (let i = 0; i < dataReferences.length; i++) {
216
- const {
217
- id: propertyId,
218
- reference
219
- } = dataReferences[i];
210
+ for (const {
211
+ id: propertyId,
212
+ reference
213
+ } of dataReferences) {
220
214
  reference.read(broker, 'data', 'data.read.', {
221
215
  correlationId: propertyId
222
216
  });
@@ -238,11 +232,10 @@ function write(broker, dataReferences, properties, callback) {
238
232
  noAck: true
239
233
  });
240
234
 
241
- for (let i = 0; i < dataReferences.length; i++) {
242
- const {
243
- id: propertyId,
244
- reference
245
- } = dataReferences[i];
235
+ for (const {
236
+ id: propertyId,
237
+ reference
238
+ } of dataReferences) {
246
239
  const value = propertyId in properties ? properties[propertyId].value : undefined;
247
240
  reference.write(broker, 'data', 'data.write.', value, {
248
241
  correlationId: propertyId
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.cloneContent = cloneContent;
7
7
  exports.cloneMessage = cloneMessage;
8
8
  exports.cloneParent = cloneParent;
9
+ exports.pushParent = pushParent;
9
10
  exports.shiftParent = shiftParent;
10
11
  exports.unshiftParent = unshiftParent;
11
- exports.pushParent = pushParent;
12
12
 
13
13
  function cloneContent(content, extend) {
14
14
  const {