bpmn-elements 8.2.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 (74) hide show
  1. package/CHANGELOG.md +4 -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 +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 +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 +2 -1
  74. package/src/tasks/StandardLoopCharacteristics.js +0 -1
@@ -8,24 +8,18 @@ exports.DefinitionBroker = DefinitionBroker;
8
8
  exports.EventBroker = EventBroker;
9
9
  exports.MessageFlowBroker = MessageFlowBroker;
10
10
  exports.ProcessBroker = ProcessBroker;
11
-
12
11
  var _smqp = require("smqp");
13
-
14
12
  var _Errors = require("./error/Errors");
15
-
16
13
  function ActivityBroker(activity) {
17
14
  const executionBroker = ExecutionBroker(activity, 'activity');
18
15
  return executionBroker;
19
16
  }
20
-
21
17
  function ProcessBroker(owner) {
22
18
  return ExecutionBroker(owner, 'process');
23
19
  }
24
-
25
20
  function DefinitionBroker(owner, onBrokerReturn) {
26
21
  return ExecutionBroker(owner, 'definition', onBrokerReturn);
27
22
  }
28
-
29
23
  function MessageFlowBroker(owner) {
30
24
  const eventBroker = new EventBroker(owner, {
31
25
  prefix: 'messageflow',
@@ -44,7 +38,6 @@ function MessageFlowBroker(owner) {
44
38
  broker.bindQueue('message-q', 'message', 'message.#');
45
39
  return eventBroker;
46
40
  }
47
-
48
41
  function ExecutionBroker(brokerOwner, prefix, onBrokerReturn) {
49
42
  const eventBroker = new EventBroker(brokerOwner, {
50
43
  prefix,
@@ -82,7 +75,6 @@ function ExecutionBroker(brokerOwner, prefix, onBrokerReturn) {
82
75
  broker.bindQueue(executionQ.name, 'execution', 'execution.#');
83
76
  return eventBroker;
84
77
  }
85
-
86
78
  function EventBroker(brokerOwner, options, onBrokerReturn) {
87
79
  this.options = options;
88
80
  this.eventPrefix = options.prefix;
@@ -95,51 +87,44 @@ function EventBroker(brokerOwner, options, onBrokerReturn) {
95
87
  this.emit = this.emit.bind(this);
96
88
  this.emitFatal = this.emitFatal.bind(this);
97
89
  }
98
-
99
90
  EventBroker.prototype.on = function on(eventName, callback, eventOptions = {
100
91
  once: false
101
92
  }) {
102
93
  const key = this._getEventRoutingKey(eventName);
103
-
104
94
  if (eventOptions.once) return this.broker.subscribeOnce('event', key, eventCallback, eventOptions);
105
- return this.broker.subscribeTmp('event', key, eventCallback, { ...eventOptions,
95
+ return this.broker.subscribeTmp('event', key, eventCallback, {
96
+ ...eventOptions,
106
97
  noAck: true
107
98
  });
108
-
109
99
  function eventCallback(routingKey, message, owner) {
110
100
  if (eventName === 'error') return callback((0, _Errors.makeErrorFromMessage)(message));
111
101
  callback(owner.getApi(message));
112
102
  }
113
103
  };
114
-
115
104
  EventBroker.prototype.once = function once(eventName, callback, eventOptions = {}) {
116
- return this.on(eventName, callback, { ...eventOptions,
105
+ return this.on(eventName, callback, {
106
+ ...eventOptions,
117
107
  once: true
118
108
  });
119
109
  };
120
-
121
110
  EventBroker.prototype.waitFor = function waitFor(eventName, onMessage) {
122
111
  const key = this._getEventRoutingKey(eventName);
123
-
124
112
  return new Promise((resolve, reject) => {
125
113
  const consumers = [this.broker.subscribeTmp('event', key, eventCallback, {
126
114
  noAck: true
127
115
  }), this.broker.subscribeTmp('event', '*.error', errorCallback, {
128
116
  noAck: true
129
117
  })];
130
-
131
118
  function eventCallback(routingKey, message, owner) {
132
119
  if (onMessage && !onMessage(routingKey, message, owner)) return;
133
120
  unsubscribe();
134
121
  return resolve(owner.getApi(message));
135
122
  }
136
-
137
123
  function errorCallback(routingKey, message, owner) {
138
124
  if (!message.properties.mandatory) return;
139
125
  unsubscribe();
140
126
  return reject((0, _Errors.makeErrorFromMessage)(message, owner));
141
127
  }
142
-
143
128
  function unsubscribe() {
144
129
  for (const consumer of consumers) {
145
130
  consumer.cancel();
@@ -147,39 +132,35 @@ EventBroker.prototype.waitFor = function waitFor(eventName, onMessage) {
147
132
  }
148
133
  });
149
134
  };
150
-
151
135
  EventBroker.prototype.emit = function emit(eventName, content, props) {
152
- this.broker.publish('event', `${this.eventPrefix}.${eventName}`, { ...content
136
+ this.broker.publish('event', `${this.eventPrefix}.${eventName}`, {
137
+ ...content
153
138
  }, {
154
139
  type: eventName,
155
140
  ...props
156
141
  });
157
142
  };
158
-
159
143
  EventBroker.prototype.emitFatal = function emitFatal(error, content) {
160
- this.emit('error', { ...content,
144
+ this.emit('error', {
145
+ ...content,
161
146
  error
162
147
  }, {
163
148
  mandatory: true
164
149
  });
165
150
  };
166
-
167
151
  EventBroker.prototype._onBrokerReturnFn = function onBrokerReturnFn(message) {
168
152
  if (message.properties.type === 'error') {
169
153
  const err = (0, _Errors.makeErrorFromMessage)(message);
170
154
  throw err;
171
155
  }
172
156
  };
173
-
174
157
  EventBroker.prototype._getEventRoutingKey = function getEventRoutingKey(eventName) {
175
158
  if (eventName.indexOf('.') > -1) return eventName;
176
-
177
159
  switch (eventName) {
178
160
  case 'wait':
179
161
  {
180
162
  return `activity.${eventName}`;
181
163
  }
182
-
183
164
  default:
184
165
  {
185
166
  return `${this.eventPrefix}.${eventName}`;
@@ -4,14 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Expressions;
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 isExpressionPattern = /^\${(.+?)}$/;
13
10
  const expressionPattern = /\${(.+?)}/;
14
-
15
11
  function Expressions() {
16
12
  return {
17
13
  resolveExpression,
@@ -19,14 +15,11 @@ function Expressions() {
19
15
  hasExpression
20
16
  };
21
17
  }
22
-
23
18
  function resolveExpression(templatedString, context, expressionFnContext) {
24
19
  let result = templatedString;
25
-
26
20
  while (expressionPattern.test(result)) {
27
21
  const expressionMatch = result.match(expressionPattern);
28
22
  const innerProperty = expressionMatch[1];
29
-
30
23
  if (innerProperty === 'true') {
31
24
  return true;
32
25
  } else if (innerProperty === 'false') {
@@ -37,24 +30,18 @@ function resolveExpression(templatedString, context, expressionFnContext) {
37
30
  const n = Number(innerProperty);
38
31
  if (!isNaN(n)) return n;
39
32
  }
40
-
41
33
  const contextValue = (0, _getPropertyValue.default)(context, innerProperty, expressionFnContext);
42
-
43
34
  if (expressionMatch.input === expressionMatch[0]) {
44
35
  return contextValue;
45
36
  }
46
-
47
37
  result = result.replace(expressionMatch[0], contextValue === undefined ? '' : contextValue);
48
38
  }
49
-
50
39
  return result;
51
40
  }
52
-
53
41
  function isExpression(text) {
54
42
  if (!text) return false;
55
43
  return isExpressionPattern.test(text);
56
44
  }
57
-
58
45
  function hasExpression(text) {
59
46
  if (!text) return false;
60
47
  return expressionPattern.test(text);
@@ -5,49 +5,37 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = ExtensionsMapper;
7
7
  const kActivated = Symbol.for('activated');
8
-
9
8
  function ExtensionsMapper(context) {
10
9
  this.context = context;
11
10
  }
12
-
13
11
  ExtensionsMapper.prototype.get = function get(activity) {
14
12
  return new Extensions(activity, this.context, this._getExtensions());
15
13
  };
16
-
17
14
  ExtensionsMapper.prototype._getExtensions = function getExtensions() {
18
15
  let extensions;
19
16
  if (!(extensions = this.context.environment.extensions)) return [];
20
17
  return Object.values(extensions);
21
18
  };
22
-
23
19
  function Extensions(activity, context, extensions) {
24
20
  const result = this.extensions = [];
25
-
26
21
  for (const Extension of extensions) {
27
22
  const extension = Extension(activity, context);
28
23
  if (extension) result.push(extension);
29
24
  }
30
-
31
25
  this[kActivated] = false;
32
26
  }
33
-
34
27
  Object.defineProperty(Extensions.prototype, 'count', {
35
28
  get() {
36
29
  return this.extensions.length;
37
30
  }
38
-
39
31
  });
40
-
41
32
  Extensions.prototype.activate = function activate(message) {
42
33
  if (this[kActivated]) return;
43
34
  this[kActivated] = true;
44
-
45
35
  for (const extension of this.extensions) extension.activate(message);
46
36
  };
47
-
48
37
  Extensions.prototype.deactivate = function deactivate(message) {
49
38
  if (!this[kActivated]) return;
50
39
  this[kActivated] = false;
51
-
52
40
  for (const extension of this.extensions) extension.deactivate(message);
53
41
  };
@@ -4,18 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Formatter = Formatter;
7
-
8
7
  var _messageHelper = require("./messageHelper");
9
-
10
8
  var _shared = require("./shared");
11
-
12
9
  var _Errors = require("./error/Errors");
13
-
14
10
  var _smqp = require("smqp");
15
-
16
11
  const kOnMessage = Symbol.for('onMessage');
17
12
  const kExecution = Symbol.for('execution');
18
-
19
13
  function Formatter(element, formatQ) {
20
14
  const {
21
15
  id,
@@ -29,7 +23,6 @@ function Formatter(element, formatQ) {
29
23
  this.pendingFormats = [];
30
24
  this[kOnMessage] = this._onMessage.bind(this);
31
25
  }
32
-
33
26
  Formatter.prototype.format = function format(message, callback) {
34
27
  const correlationId = this._runId = (0, _shared.getUniqueId)(message.fields.routingKey);
35
28
  const consumerTag = '_formatter-' + correlationId;
@@ -54,7 +47,6 @@ Formatter.prototype.format = function format(message, callback) {
54
47
  prefetch: 100
55
48
  });
56
49
  };
57
-
58
50
  Formatter.prototype._onMessage = function onMessage(routingKey, message) {
59
51
  const {
60
52
  formatKey,
@@ -63,55 +55,42 @@ Formatter.prototype._onMessage = function onMessage(routingKey, message) {
63
55
  executeMessage
64
56
  } = this[kExecution];
65
57
  const asyncFormatting = pending.length;
66
-
67
58
  switch (routingKey) {
68
59
  case '_formatting.exec':
69
60
  if (message.properties.correlationId !== correlationId) return message.ack();
70
-
71
61
  if (!asyncFormatting) {
72
62
  message.ack();
73
63
  return this._complete(message);
74
64
  }
75
-
76
65
  this[kExecution].executeMessage = message;
77
66
  break;
78
-
79
67
  default:
80
68
  {
81
69
  message.ack();
82
70
  const endRoutingKey = message.content && message.content.endRoutingKey;
83
-
84
71
  if (endRoutingKey) {
85
72
  this._decorate(message.content);
86
-
87
73
  pending.push(message);
88
74
  return this._debug(`start formatting ${formatKey} message content with formatter ${routingKey}`);
89
75
  }
90
-
91
76
  if (asyncFormatting) {
92
77
  const {
93
78
  isError,
94
79
  message: startMessage
95
80
  } = this._popFormatStart(pending, routingKey);
96
-
97
81
  if (startMessage) startMessage.ack();
98
-
99
82
  if (isError) {
100
83
  return this._complete(message, true);
101
84
  }
102
85
  }
103
-
104
86
  this._decorate(message.content);
105
-
106
87
  this._debug(`format ${message.fields.routingKey} message content with formatter ${routingKey}`);
107
-
108
88
  if (executeMessage && asyncFormatting && !pending.length) {
109
89
  this._complete(message);
110
90
  }
111
91
  }
112
92
  }
113
93
  };
114
-
115
94
  Formatter.prototype._complete = function complete(message, isError) {
116
95
  const {
117
96
  runMessage,
@@ -123,22 +102,16 @@ Formatter.prototype._complete = function complete(message, isError) {
123
102
  this[kExecution] = null;
124
103
  if (executeMessage) executeMessage.ack();
125
104
  this.broker.cancel(message.fields.consumerTag);
126
-
127
105
  if (isError) {
128
106
  const error = message.content && message.content.error || new Error('formatting failed');
129
107
  const errMessage = error.message || 'formatting failed';
130
-
131
108
  this._debug(`formatting of ${formatKey} failed with ${message.fields.routingKey}: ${errMessage}`);
132
-
133
109
  return callback(new _Errors.ActivityError(errMessage, (0, _messageHelper.cloneMessage)(runMessage), error));
134
110
  }
135
-
136
111
  return callback(null, runMessage.content, formatted);
137
112
  };
138
-
139
113
  Formatter.prototype._decorate = function decorate(withContent) {
140
114
  const content = this[kExecution].runMessage.content;
141
-
142
115
  for (const key in withContent) {
143
116
  switch (key) {
144
117
  case 'id':
@@ -153,7 +126,6 @@ Formatter.prototype._decorate = function decorate(withContent) {
153
126
  case 'endRoutingKey':
154
127
  case 'errorRoutingKey':
155
128
  break;
156
-
157
129
  default:
158
130
  {
159
131
  content[key] = withContent[key];
@@ -162,7 +134,6 @@ Formatter.prototype._decorate = function decorate(withContent) {
162
134
  }
163
135
  }
164
136
  };
165
-
166
137
  Formatter.prototype._popFormatStart = function popFormattingStart(pending, routingKey) {
167
138
  for (let idx = 0; idx < pending.length; idx++) {
168
139
  const msg = pending[idx];
@@ -170,10 +141,8 @@ Formatter.prototype._popFormatStart = function popFormattingStart(pending, routi
170
141
  endRoutingKey,
171
142
  errorRoutingKey = '#.error'
172
143
  } = msg.content;
173
-
174
144
  if (endRoutingKey && (0, _smqp.getRoutingKeyPattern)(endRoutingKey).test(routingKey)) {
175
145
  this._debug(`completed formatting ${msg.fields.routingKey} message content with formatter ${routingKey}`);
176
-
177
146
  pending.splice(idx, 1);
178
147
  return {
179
148
  message: msg
@@ -186,10 +155,8 @@ Formatter.prototype._popFormatStart = function popFormattingStart(pending, routi
186
155
  };
187
156
  }
188
157
  }
189
-
190
158
  return {};
191
159
  };
192
-
193
160
  Formatter.prototype._debug = function debug(msg) {
194
161
  this.logger.debug(`<${this.id}> ${msg}`);
195
162
  };
@@ -4,18 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Scripts = Scripts;
7
-
8
7
  function Scripts() {
9
8
  return {
10
9
  getScript,
11
10
  register
12
11
  };
13
-
14
- function
15
- /*scriptType, activity*/
16
- getScript() {}
17
-
18
- function
19
- /*activity*/
20
- register() {}
12
+ function getScript( /*scriptType, activity*/) {}
13
+ function register( /*activity*/) {}
21
14
  }
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Timers = Timers;
7
-
8
7
  function Timers(options) {
9
8
  let count = 0;
10
9
  const executing = [];
@@ -17,26 +16,22 @@ function Timers(options) {
17
16
  get executing() {
18
17
  return executing.slice();
19
18
  },
20
-
21
19
  register,
22
20
  setTimeout: wrappedSetTimeout,
23
21
  clearTimeout: wrappedClearTimeout
24
22
  };
25
23
  return timersApi;
26
-
27
24
  function register(owner) {
28
25
  return {
29
26
  setTimeout: registerTimeout(owner),
30
27
  clearTimeout: timersApi.clearTimeout
31
28
  };
32
29
  }
33
-
34
30
  function registerTimeout(owner) {
35
31
  return function registeredSetTimeout(...args) {
36
32
  return timersApi.setTimeout.call(owner, ...args);
37
33
  };
38
34
  }
39
-
40
35
  function wrappedSetTimeout(callback, delay, ...args) {
41
36
  const ref = {
42
37
  timerId: `timer_${count++}`,
@@ -48,22 +43,18 @@ function Timers(options) {
48
43
  executing.push(ref);
49
44
  ref.timerRef = options.setTimeout.call(null, onTimeout, delay, ...args);
50
45
  return ref;
51
-
52
46
  function onTimeout(...rargs) {
53
47
  const idx = executing.indexOf(ref);
54
48
  if (idx > -1) executing.splice(idx, 1);
55
49
  return callback(...rargs);
56
50
  }
57
51
  }
58
-
59
52
  function wrappedClearTimeout(ref) {
60
53
  const idx = executing.indexOf(ref);
61
-
62
54
  if (idx > -1) {
63
55
  executing.splice(idx, 1);
64
56
  return options.clearTimeout.call(null, ref.timerRef);
65
57
  }
66
-
67
58
  return options.clearTimeout.call(null, ref);
68
59
  }
69
60
  }