bpmn-elements 8.1.0 → 8.2.1

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