bpmn-elements 8.2.0 → 8.2.2

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 (74) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +0 -49
  3. package/dist/src/Api.js +4 -19
  4. package/dist/src/Context.js +0 -35
  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 +0 -12
  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 +39 -243
  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 +2 -7
  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 +12 -37
  52. package/dist/src/io/Properties.js +6 -39
  53. package/dist/src/messageHelper.js +10 -23
  54. package/dist/src/process/Process.js +10 -112
  55. package/dist/src/process/ProcessExecution.js +24 -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 +0 -20
  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 +7 -7
  69. package/src/Context.js +0 -1
  70. package/src/activity/Activity.js +1 -1
  71. package/src/gateways/EventBasedGateway.js +0 -1
  72. package/src/io/InputOutputSpecification.js +0 -1
  73. package/src/process/ProcessExecution.js +8 -1
  74. package/src/tasks/StandardLoopCharacteristics.js +0 -1
@@ -10,20 +10,16 @@ const numberConstantPattern = /^\W*-?\d+(.\d+)?\W*$/;
10
10
  const negativeIndexPattern = /^-\d+$/;
11
11
  var _default = getPropertyValue;
12
12
  exports.default = _default;
13
-
14
13
  function getPropertyValue(inputContext, propertyPath, fnScope) {
15
14
  if (!inputContext) return;
16
15
  let resultValue;
17
16
  let next = iterateProps(inputContext, inputContext, propertyPath.trim(), fnScope);
18
-
19
17
  while (next) {
20
18
  resultValue = next.getResult();
21
19
  next = next();
22
20
  }
23
-
24
21
  return resultValue;
25
22
  }
26
-
27
23
  function iterateProps(base, iterateContext, iteratePropertyPath, fnScope) {
28
24
  let result;
29
25
  const rest = iteratePropertyPath.replace(propertyPattern, (match, fnName, args, p, prop) => {
@@ -32,55 +28,44 @@ function iterateProps(base, iterateContext, iteratePropertyPath, fnScope) {
32
28
  } else {
33
29
  result = getNamedValue(iterateContext, prop);
34
30
  }
35
-
36
31
  return '';
37
32
  });
38
33
  if (rest === iteratePropertyPath) return;
39
34
  if (result === undefined || result === null) return;
40
-
41
35
  const iterateNext = () => iterateProps(base, result, rest, fnScope);
42
-
43
36
  iterateNext.getResult = () => {
44
37
  if (rest !== '') return;
45
38
  return result;
46
39
  };
47
-
48
40
  return iterateNext;
49
41
  }
50
-
51
42
  function executeFn(fn, args, base, fnScope) {
52
43
  if (!fn) return;
53
44
  let callArguments = [];
54
-
55
45
  if (args) {
56
46
  callArguments = splitArguments(args, base, fnScope);
57
47
  } else {
58
48
  callArguments.push(base);
59
49
  }
60
-
61
50
  if (!fnScope) return fn.apply(null, callArguments);
62
51
  return function ScopedIIFE() {
63
52
  // eslint-disable-line no-extra-parens
64
53
  return fn.apply(this, callArguments);
65
54
  }.call(fnScope);
66
55
  }
67
-
68
56
  function splitArguments(args, base, fnScope) {
69
57
  let insideString = false;
70
58
  let delimiter = '';
71
59
  let argCompleted = false;
72
60
  let arg = '';
73
61
  const callArguments = [];
74
-
75
62
  for (let i = 0; i < args.length; i++) {
76
63
  const charPos = args.charAt(i);
77
-
78
64
  if (!insideString) {
79
65
  if (charPos === ',') {
80
66
  argCompleted = true;
81
67
  } else if (charPos !== ' ') {
82
68
  arg += charPos;
83
-
84
69
  if (charPos === '\'' || charPos === '"') {
85
70
  insideString = true;
86
71
  delimiter = charPos;
@@ -88,69 +73,54 @@ function splitArguments(args, base, fnScope) {
88
73
  }
89
74
  } else {
90
75
  arg += charPos;
91
-
92
76
  if (charPos === delimiter) {
93
77
  argCompleted = true;
94
78
  delimiter = '';
95
79
  }
96
80
  }
97
-
98
81
  if (argCompleted) {
99
82
  if (arg.length > 0) {
100
83
  callArguments.push(getFunctionArgument(base, arg.trim(), fnScope));
101
84
  }
102
-
103
85
  arg = '';
104
86
  insideString = false;
105
87
  argCompleted = false;
106
88
  }
107
89
  }
108
-
109
90
  if (arg.trim() !== '') {
110
91
  callArguments.push(getFunctionArgument(base, arg.trim(), fnScope));
111
92
  }
112
-
113
93
  return callArguments;
114
94
  }
115
-
116
95
  function getFunctionArgument(obj, argument, fnScope) {
117
96
  const stringMatch = argument.match(stringConstantPattern);
118
-
119
97
  if (stringMatch) {
120
98
  return stringMatch[2];
121
99
  } else if (numberConstantPattern.test(argument)) {
122
100
  return Number(argument);
123
101
  }
124
-
125
102
  switch (argument) {
126
103
  case 'true':
127
104
  return true;
128
-
129
105
  case 'false':
130
106
  return false;
131
-
132
107
  case 'null':
133
108
  return null;
134
-
135
109
  default:
136
110
  return getPropertyValue(obj, argument, fnScope);
137
111
  }
138
112
  }
139
-
140
113
  function getNamedValue(obj, property) {
141
114
  if (Array.isArray(obj)) {
142
115
  return getArrayItem(obj, property);
143
116
  }
144
-
145
117
  return obj[property];
146
118
  }
147
-
148
119
  function getArrayItem(list, idx) {
149
120
  if (negativeIndexPattern.test(idx)) {
150
121
  const nidx = Number(idx);
151
122
  const aidx = nidx === 0 ? 0 : list.length + nidx;
152
123
  return list[aidx];
153
124
  }
154
-
155
125
  return list[idx];
156
126
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = BpmnIO;
7
-
8
7
  function BpmnIO(activity, context) {
9
8
  this.activity = activity;
10
9
  this.context = context;
@@ -16,24 +15,20 @@ function BpmnIO(activity, context) {
16
15
  this.specification = ioSpecificationDef && new ioSpecificationDef.Behaviour(activity, ioSpecificationDef, context);
17
16
  this.properties = propertiesDef && new propertiesDef.Behaviour(activity, propertiesDef, context);
18
17
  }
19
-
20
18
  Object.defineProperty(BpmnIO.prototype, 'hasIo', {
21
19
  get() {
22
20
  return this.specification || this.properties;
23
21
  }
24
-
25
22
  });
26
-
27
23
  BpmnIO.prototype.activate = function activate(message) {
28
24
  const properties = this.properties,
29
- specification = this.specification;
25
+ specification = this.specification;
30
26
  if (properties) properties.activate(message);
31
27
  if (specification) specification.activate(message);
32
28
  };
33
-
34
29
  BpmnIO.prototype.deactivate = function deactivate(message) {
35
30
  const properties = this.properties,
36
- specification = this.specification;
31
+ specification = this.specification;
37
32
  if (properties) properties.deactivate(message);
38
33
  if (specification) specification.deactivate(message);
39
34
  };
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = EnvironmentDataObject;
7
-
8
7
  function EnvironmentDataObject(dataObjectDef, {
9
8
  environment
10
9
  }) {
@@ -22,26 +21,19 @@ function EnvironmentDataObject(dataObjectDef, {
22
21
  this.parent = parent;
23
22
  this.environment = environment;
24
23
  }
25
-
26
24
  EnvironmentDataObject.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
27
25
  const environment = this.environment;
28
26
  const value = environment.variables._data && environment.variables._data[this.id];
29
-
30
27
  const content = this._createContent(value);
31
-
32
28
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
33
29
  };
34
-
35
30
  EnvironmentDataObject.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
36
31
  const environment = this.environment;
37
32
  environment.variables._data = environment.variables._data || {};
38
33
  environment.variables._data[this.id] = value;
39
-
40
34
  const content = this._createContent(value);
41
-
42
35
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
43
36
  };
44
-
45
37
  EnvironmentDataObject.prototype._createContent = function createContent(value) {
46
38
  return {
47
39
  id: this.id,
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = EnvironmentDataStore;
7
-
8
7
  function EnvironmentDataStore(dataStoreDef, {
9
8
  environment
10
9
  }) {
@@ -22,26 +21,19 @@ function EnvironmentDataStore(dataStoreDef, {
22
21
  this.parent = parent;
23
22
  this.environment = environment;
24
23
  }
25
-
26
24
  EnvironmentDataStore.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
27
25
  const environment = this.environment;
28
26
  const value = environment.variables._data && environment.variables._data[this.id];
29
-
30
27
  const content = this._createContent(value);
31
-
32
28
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
33
29
  };
34
-
35
30
  EnvironmentDataStore.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
36
31
  const environment = this.environment;
37
32
  environment.variables._data = environment.variables._data || {};
38
33
  environment.variables._data[this.id] = value;
39
-
40
34
  const content = this._createContent(value);
41
-
42
35
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
43
36
  };
44
-
45
37
  EnvironmentDataStore.prototype._createContent = function createContent(value) {
46
38
  return {
47
39
  id: this.id,
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = EnvironmentDataStoreReference;
7
-
8
7
  function EnvironmentDataStoreReference(dataObjectDef, {
9
8
  environment
10
9
  }) {
@@ -22,26 +21,19 @@ function EnvironmentDataStoreReference(dataObjectDef, {
22
21
  this.parent = parent;
23
22
  this.environment = environment;
24
23
  }
25
-
26
24
  EnvironmentDataStoreReference.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
27
25
  const environment = this.environment;
28
26
  const value = environment.variables._data && environment.variables._data[this.id];
29
-
30
27
  const content = this._createContent(value);
31
-
32
28
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
33
29
  };
34
-
35
30
  EnvironmentDataStoreReference.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
36
31
  const environment = this.environment;
37
32
  environment.variables._data = environment.variables._data || {};
38
33
  environment.variables._data[this.id] = value;
39
-
40
34
  const content = this._createContent(value);
41
-
42
35
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
43
36
  };
44
-
45
37
  EnvironmentDataStoreReference.prototype._createContent = function createContent(value) {
46
38
  return {
47
39
  id: this.id,
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = IoSpecification;
7
-
8
7
  var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
9
-
10
8
  var _shared = require("../shared");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  const kConsuming = Symbol.for('consuming');
15
-
16
11
  function IoSpecification(activity, ioSpecificationDef, context) {
17
12
  const {
18
13
  id,
@@ -26,44 +21,34 @@ function IoSpecification(activity, ioSpecificationDef, context) {
26
21
  this.broker = activity.broker;
27
22
  this.context = context;
28
23
  }
29
-
30
24
  const proto = IoSpecification.prototype;
31
-
32
25
  proto.activate = function activate(message) {
33
26
  if (this[kConsuming]) return;
34
-
35
27
  if (message && message.fields.redelivered && message.fields.routingKey === 'run.start') {
36
28
  this._onFormatEnter();
37
29
  }
38
-
39
30
  if (message && message.fields.redelivered && message.fields.routingKey === 'run.end') {
40
31
  this._onFormatComplete(message);
41
32
  }
42
-
43
33
  this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
44
34
  noAck: true
45
35
  });
46
36
  };
47
-
48
37
  proto.deactivate = function deactivate() {
49
38
  if (this[kConsuming]) this[kConsuming] = this[kConsuming].cancel();
50
39
  };
51
-
52
40
  proto._onActivityEvent = function onActivityEvent(routingKey, message) {
53
41
  const {
54
42
  dataInputs,
55
43
  dataOutputs
56
44
  } = this.behaviour;
57
-
58
45
  if ((dataInputs || dataOutputs) && routingKey === 'activity.enter') {
59
46
  return this._onFormatEnter();
60
47
  }
61
-
62
48
  if (dataOutputs && routingKey === 'activity.execution.completed') {
63
49
  this._onFormatComplete(message);
64
50
  }
65
51
  };
66
-
67
52
  proto._onFormatEnter = function onFormatOnEnter() {
68
53
  const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
69
54
  const startRoutingKey = `run.onstart.${safeType}`;
@@ -72,7 +57,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
72
57
  dataOutputs
73
58
  } = this.behaviour;
74
59
  const broker = this.broker;
75
-
76
60
  if (!dataInputs) {
77
61
  return broker.publish('format', startRoutingKey, {
78
62
  ioSpecification: {
@@ -80,7 +64,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
80
64
  }
81
65
  });
82
66
  }
83
-
84
67
  const {
85
68
  dataObjects,
86
69
  sources
@@ -104,7 +87,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
104
87
  dataObjects: [],
105
88
  sources: []
106
89
  });
107
-
108
90
  if (!dataObjects.length) {
109
91
  return broker.publish('format', startRoutingKey, {
110
92
  ioSpecification: {
@@ -113,13 +95,13 @@ proto._onFormatEnter = function onFormatOnEnter() {
113
95
  }
114
96
  });
115
97
  }
116
-
117
98
  const endRoutingKey = `run.onstart.${safeType}.end`;
118
99
  broker.publish('format', `${startRoutingKey}.begin`, {
119
100
  endRoutingKey,
120
101
  ioSpecification: {
121
102
  dataInputs: sources.map(source => {
122
- return { ...source
103
+ return {
104
+ ...source
123
105
  };
124
106
  }),
125
107
  dataOutputs: this._getDataOutputs(dataOutputs)
@@ -127,7 +109,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
127
109
  });
128
110
  return read(broker, dataObjects, (_, responses) => {
129
111
  for (const response of responses) sources[response.index].value = response.value;
130
-
131
112
  broker.publish('format', endRoutingKey, {
132
113
  ioSpecification: {
133
114
  dataInputs: sources,
@@ -136,7 +117,6 @@ proto._onFormatEnter = function onFormatOnEnter() {
136
117
  });
137
118
  });
138
119
  };
139
-
140
120
  proto._onFormatComplete = function formatOnComplete(message) {
141
121
  const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
142
122
  const messageInputs = (0, _getPropertyValue.default)(message, 'content.ioSpecification.dataInputs');
@@ -173,7 +153,6 @@ proto._onFormatComplete = function formatOnComplete(message) {
173
153
  sources: []
174
154
  });
175
155
  const startRoutingKey = `run.onend.${safeType}`;
176
-
177
156
  if (!dataObjects.length) {
178
157
  return broker.publish('format', startRoutingKey, {
179
158
  ioSpecification: {
@@ -182,13 +161,14 @@ proto._onFormatComplete = function formatOnComplete(message) {
182
161
  }
183
162
  });
184
163
  }
185
-
186
164
  const endRoutingKey = `run.onend.${safeType}.end`;
187
165
  broker.publish('format', `${startRoutingKey}.begin`, {
188
166
  endRoutingKey,
189
- ioSpecification: { ...(messageInputs && {
167
+ ioSpecification: {
168
+ ...(messageInputs && {
190
169
  dataInputs: messageInputs.map(input => {
191
- return { ...input
170
+ return {
171
+ ...input
192
172
  };
193
173
  })
194
174
  }),
@@ -197,11 +177,12 @@ proto._onFormatComplete = function formatOnComplete(message) {
197
177
  });
198
178
  return write(broker, dataObjects, (_, responses) => {
199
179
  for (const response of responses) sources[response.index].value = response.value;
200
-
201
180
  broker.publish('format', endRoutingKey, {
202
- ioSpecification: { ...(messageInputs && {
181
+ ioSpecification: {
182
+ ...(messageInputs && {
203
183
  dataInputs: messageInputs.map(input => {
204
- return { ...input
184
+ return {
185
+ ...input
205
186
  };
206
187
  })
207
188
  }),
@@ -210,7 +191,6 @@ proto._onFormatComplete = function formatOnComplete(message) {
210
191
  });
211
192
  });
212
193
  };
213
-
214
194
  proto._getDataOutputs = function getDataOutputs(dataOutputs) {
215
195
  if (!dataOutputs) return;
216
196
  return dataOutputs.map(dataOutput => {
@@ -221,27 +201,25 @@ proto._getDataOutputs = function getDataOutputs(dataOutputs) {
221
201
  };
222
202
  });
223
203
  };
224
-
225
204
  function read(broker, dataObjectRefs, callback) {
226
205
  const responses = [];
227
206
  let count = 0;
228
207
  const dataReadConsumer = broker.subscribeTmp('data', 'data.read.#', onDataObjectResponse, {
229
208
  noAck: true
230
209
  });
231
-
232
210
  for (const {
233
211
  dataObject
234
212
  } of dataObjectRefs) {
235
213
  dataObject.read(broker, 'data', 'data.read.');
236
214
  }
237
-
238
215
  function onDataObjectResponse(routingKey, message) {
239
216
  const {
240
217
  index
241
218
  } = dataObjectRefs.find(({
242
219
  dataObject
243
220
  }) => dataObject.id === message.content.id);
244
- responses.push({ ...message.content,
221
+ responses.push({
222
+ ...message.content,
245
223
  index
246
224
  });
247
225
  ++count;
@@ -250,21 +228,18 @@ function read(broker, dataObjectRefs, callback) {
250
228
  return callback(null, responses);
251
229
  }
252
230
  }
253
-
254
231
  function write(broker, dataObjectRefs, callback) {
255
232
  const responses = [];
256
233
  let count = 0;
257
234
  broker.subscribeTmp('data', 'data.write.#', onDataObjectResponse, {
258
235
  noAck: true
259
236
  });
260
-
261
237
  for (const {
262
238
  dataObject,
263
239
  value
264
240
  } of dataObjectRefs) {
265
241
  dataObject.write(broker, 'data', 'data.write.', value);
266
242
  }
267
-
268
243
  function onDataObjectResponse(routingKey, message) {
269
244
  const idx = dataObjectRefs.findIndex(({
270
245
  dataObject