bpmn-elements 6.0.0 → 8.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 +335 -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 +176 -172
  6. package/dist/src/Environment.js +110 -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 +710 -408
  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 +439 -362
  49. package/dist/src/process/ProcessExecution.js +748 -646
  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 +193 -175
  60. package/dist/src/tasks/Task.js +17 -19
  61. package/index.js +2 -0
  62. package/package.json +15 -15
  63. package/src/Api.js +65 -59
  64. package/src/Context.js +145 -140
  65. package/src/Environment.js +116 -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 +437 -401
  73. package/src/definition/DefinitionExecution.js +598 -340
  74. package/src/error/Errors.js +11 -6
  75. package/src/eventDefinitions/CancelEventDefinition.js +164 -121
  76. package/src/eventDefinitions/CompensateEventDefinition.js +159 -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 +20 -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 +378 -333
  106. package/src/process/ProcessExecution.js +603 -553
  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
@@ -11,196 +11,202 @@ var _shared = require("../shared");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
+ const kConsuming = Symbol.for('consuming');
15
+
14
16
  function IoSpecification(activity, ioSpecificationDef, context) {
15
17
  const {
16
18
  id,
17
19
  type = 'iospecification',
18
20
  behaviour = {}
19
21
  } = ioSpecificationDef;
20
- const {
21
- broker
22
- } = activity;
23
- const safeType = (0, _shared.brokerSafeId)(type).toLowerCase();
24
- let activityConsumer;
22
+ this.id = id;
23
+ this.type = type;
24
+ this.behaviour = behaviour;
25
+ this.activity = activity;
26
+ this.broker = activity.broker;
27
+ this.context = context;
28
+ }
29
+
30
+ const proto = IoSpecification.prototype;
31
+
32
+ proto.activate = function activate() {
33
+ if (this[kConsuming]) return;
34
+ this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
35
+ noAck: true
36
+ });
37
+ };
38
+
39
+ proto.deactivate = function deactivate() {
40
+ if (this[kConsuming]) this[kConsuming] = this[kConsuming].cancel();
41
+ };
42
+
43
+ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
25
44
  const {
26
45
  dataInputs,
27
46
  dataOutputs
28
- } = behaviour;
29
- const ioApi = {
30
- id,
31
- type,
32
- behaviour,
33
- activate,
34
- deactivate
35
- };
36
- return ioApi;
47
+ } = this.behaviour;
37
48
 
38
- function activate() {
39
- if (activityConsumer) return;
40
- activityConsumer = broker.subscribeTmp('event', 'activity.#', onActivityEvent, {
41
- noAck: true
42
- });
49
+ if ((dataInputs || dataOutputs) && routingKey === 'activity.enter') {
50
+ return this._onFormatEnter();
43
51
  }
44
52
 
45
- function deactivate() {
46
- if (activityConsumer) activityConsumer = activityConsumer.cancel();
53
+ if (dataOutputs && routingKey === 'activity.execution.completed') {
54
+ this._onFormatComplete(message);
47
55
  }
56
+ };
48
57
 
49
- function onActivityEvent(routingKey, message) {
50
- if ((dataInputs || dataOutputs) && routingKey === 'activity.enter') {
51
- return formatOnEnter();
52
- }
58
+ proto._onFormatEnter = function onFormatOnEnter() {
59
+ const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
60
+ const startRoutingKey = `run.onstart.${safeType}`;
61
+ const {
62
+ dataInputs,
63
+ dataOutputs
64
+ } = this.behaviour;
65
+ const broker = this.broker;
53
66
 
54
- if (dataOutputs && routingKey === 'activity.execution.completed') {
55
- formatOnComplete(message);
56
- }
67
+ if (!dataInputs) {
68
+ return broker.publish('format', startRoutingKey, {
69
+ ioSpecification: {
70
+ dataOutputs: this._getDataOutputs(dataOutputs)
71
+ }
72
+ });
57
73
  }
58
74
 
59
- function formatOnEnter() {
60
- const startRoutingKey = `run.onstart.${safeType}`;
61
-
62
- if (!dataInputs) {
63
- return broker.publish('format', startRoutingKey, {
64
- ioSpecification: {
65
- dataOutputs: getDataOutputs()
66
- }
67
- });
68
- }
75
+ const {
76
+ dataObjects,
77
+ sources
78
+ } = dataInputs.reduce((result, ioSource, index) => {
79
+ const source = {
80
+ id: ioSource.id,
81
+ type: ioSource.type,
82
+ name: ioSource.name
83
+ };
84
+ result.sources.push(source);
85
+ const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.source.dataObject.id');
86
+ if (!dataObjectId) return result;
87
+ const dataObject = this.context.getDataObjectById(dataObjectId);
88
+ if (!dataObject) return result;
89
+ result.dataObjects.push({
90
+ index,
91
+ dataObject
92
+ });
93
+ return result;
94
+ }, {
95
+ dataObjects: [],
96
+ sources: []
97
+ });
69
98
 
70
- const {
71
- dataObjects,
72
- sources
73
- } = dataInputs.reduce((result, ioSource, index) => {
74
- const source = {
75
- id: ioSource.id,
76
- type: ioSource.type,
77
- name: ioSource.name
78
- };
79
- result.sources.push(source);
80
- const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.source.dataObject.id');
81
- if (!dataObjectId) return result;
82
- const dataObject = context.getDataObjectById(dataObjectId);
83
- if (!dataObject) return result;
84
- result.dataObjects.push({
85
- index,
86
- dataObject
87
- });
88
- return result;
89
- }, {
90
- dataObjects: [],
91
- sources: []
99
+ if (!dataObjects.length) {
100
+ return broker.publish('format', startRoutingKey, {
101
+ ioSpecification: {
102
+ dataInputs: sources,
103
+ dataOutputs: this._getDataOutputs(dataOutputs)
104
+ }
92
105
  });
106
+ }
93
107
 
94
- if (!dataObjects.length) {
95
- return broker.publish('format', startRoutingKey, {
96
- ioSpecification: {
97
- dataInputs: sources,
98
- dataOutputs: getDataOutputs()
99
- }
100
- });
108
+ const endRoutingKey = `run.onstart.${safeType}.end`;
109
+ broker.publish('format', `${startRoutingKey}.begin`, {
110
+ endRoutingKey,
111
+ ioSpecification: {
112
+ dataInputs: sources.map(source => {
113
+ return { ...source
114
+ };
115
+ }),
116
+ dataOutputs: this._getDataOutputs(dataOutputs)
101
117
  }
118
+ });
119
+ return read(broker, dataObjects, (_, responses) => {
120
+ for (const response of responses) sources[response.index].value = response.value;
102
121
 
103
- const endRoutingKey = `run.onstart.${safeType}.end`;
104
- broker.publish('format', `${startRoutingKey}.begin`, {
105
- endRoutingKey,
122
+ broker.publish('format', endRoutingKey, {
106
123
  ioSpecification: {
107
- dataInputs: sources.map(source => {
108
- return { ...source
109
- };
110
- }),
111
- dataOutputs: getDataOutputs()
124
+ dataInputs: sources,
125
+ dataOutputs: this._getDataOutputs(dataOutputs)
112
126
  }
113
127
  });
114
- return read(broker, dataObjects, (_, responses) => {
115
- responses.forEach(response => {
116
- sources[response.index].value = response.value;
117
- });
118
- broker.publish('format', endRoutingKey, {
119
- ioSpecification: {
120
- dataInputs: sources,
121
- dataOutputs: getDataOutputs()
122
- }
123
- });
124
- });
125
- }
128
+ });
129
+ };
126
130
 
127
- function formatOnComplete(message) {
128
- const messageInputs = (0, _getPropertyValue.default)(message, 'content.ioSpecification.dataInputs');
129
- const messageOutputs = (0, _getPropertyValue.default)(message, 'content.output.ioSpecification.dataOutputs') || [];
131
+ proto._onFormatComplete = function formatOnComplete(message) {
132
+ const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
133
+ const messageInputs = (0, _getPropertyValue.default)(message, 'content.ioSpecification.dataInputs');
134
+ const messageOutputs = (0, _getPropertyValue.default)(message, 'content.output.ioSpecification.dataOutputs') || [];
135
+ const dataOutputs = this.behaviour.dataOutputs;
136
+ const broker = this.broker;
137
+ const context = this.context;
138
+ const {
139
+ dataObjects,
140
+ sources
141
+ } = dataOutputs.reduce((result, ioSource, index) => {
130
142
  const {
131
- dataObjects,
132
- sources
133
- } = dataOutputs.reduce((result, ioSource, index) => {
134
- const {
135
- value
136
- } = messageOutputs.find(output => output.id === ioSource.id) || {};
137
- const source = {
138
- id: ioSource.id,
139
- type: ioSource.type,
140
- name: ioSource.name,
141
- value
142
- };
143
- result.sources.push(source);
144
- const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.target.dataObject.id');
145
- if (!dataObjectId) return result;
146
- const dataObject = context.getDataObjectById(dataObjectId);
147
- if (!dataObject) return result;
148
- result.dataObjects.push({
149
- index,
150
- dataObject,
151
- value
152
- });
153
- return result;
154
- }, {
155
- dataObjects: [],
156
- sources: []
143
+ value
144
+ } = messageOutputs.find(output => output.id === ioSource.id) || {};
145
+ const source = {
146
+ id: ioSource.id,
147
+ type: ioSource.type,
148
+ name: ioSource.name,
149
+ value
150
+ };
151
+ result.sources.push(source);
152
+ const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.target.dataObject.id');
153
+ if (!dataObjectId) return result;
154
+ const dataObject = context.getDataObjectById(dataObjectId);
155
+ if (!dataObject) return result;
156
+ result.dataObjects.push({
157
+ index,
158
+ dataObject,
159
+ value
157
160
  });
158
- const startRoutingKey = `run.onend.${safeType}`;
159
-
160
- if (!dataObjects.length) {
161
- return broker.publish('format', startRoutingKey, {
162
- ioSpecification: {
163
- dataInputs: messageInputs,
164
- dataOutputs: sources
165
- }
166
- });
167
- }
161
+ return result;
162
+ }, {
163
+ dataObjects: [],
164
+ sources: []
165
+ });
166
+ const startRoutingKey = `run.onend.${safeType}`;
168
167
 
169
- const endRoutingKey = `run.onend.${safeType}.end`;
170
- broker.publish('format', `${startRoutingKey}.begin`, {
171
- endRoutingKey,
168
+ if (!dataObjects.length) {
169
+ return broker.publish('format', startRoutingKey, {
172
170
  ioSpecification: {
173
- dataInputs: sources.map(input => {
174
- return { ...input
175
- };
176
- }),
177
- dataOutputs: getDataOutputs()
171
+ dataInputs: messageInputs,
172
+ dataOutputs: sources
178
173
  }
179
174
  });
180
- return write(broker, dataObjects, (_, responses) => {
181
- responses.forEach(response => {
182
- sources[response.index].value = response.value;
183
- });
184
- broker.publish('format', endRoutingKey, {
185
- ioSpecification: {
186
- dataInputs: sources,
187
- dataOutputs: getDataOutputs()
188
- }
189
- });
190
- });
191
175
  }
192
176
 
193
- function getDataOutputs() {
194
- if (!dataOutputs) return;
195
- return dataOutputs.map(dataOutput => {
196
- return {
197
- id: dataOutput.id,
198
- type: dataOutput.type,
199
- name: dataOutput.name
200
- };
177
+ const endRoutingKey = `run.onend.${safeType}.end`;
178
+ broker.publish('format', `${startRoutingKey}.begin`, {
179
+ endRoutingKey,
180
+ ioSpecification: {
181
+ dataInputs: sources.map(input => {
182
+ return { ...input
183
+ };
184
+ }),
185
+ dataOutputs: this._getDataOutputs(dataOutputs)
186
+ }
187
+ });
188
+ return write(broker, dataObjects, (_, responses) => {
189
+ for (const response of responses) sources[response.index].value = response.value;
190
+
191
+ broker.publish('format', endRoutingKey, {
192
+ ioSpecification: {
193
+ dataInputs: sources,
194
+ dataOutputs: this._getDataOutputs(dataOutputs)
195
+ }
201
196
  });
202
- }
203
- }
197
+ });
198
+ };
199
+
200
+ proto._getDataOutputs = function getDataOutputs(dataOutputs) {
201
+ if (!dataOutputs) return;
202
+ return dataOutputs.map(dataOutput => {
203
+ return {
204
+ id: dataOutput.id,
205
+ type: dataOutput.type,
206
+ name: dataOutput.name
207
+ };
208
+ });
209
+ };
204
210
 
205
211
  function read(broker, dataObjectRefs, callback) {
206
212
  const responses = [];
@@ -209,10 +215,9 @@ function read(broker, dataObjectRefs, callback) {
209
215
  noAck: true
210
216
  });
211
217
 
212
- for (let i = 0; i < dataObjectRefs.length; i++) {
213
- const {
214
- dataObject
215
- } = dataObjectRefs[i];
218
+ for (const {
219
+ dataObject
220
+ } of dataObjectRefs) {
216
221
  dataObject.read(broker, 'data', 'data.read.');
217
222
  }
218
223
 
@@ -235,24 +240,28 @@ function read(broker, dataObjectRefs, callback) {
235
240
  function write(broker, dataObjectRefs, callback) {
236
241
  const responses = [];
237
242
  let count = 0;
238
- const dataWriteConsumer = broker.subscribeTmp('data', 'data.write.#', onDataObjectResponse, {
243
+ broker.subscribeTmp('data', 'data.write.#', onDataObjectResponse, {
239
244
  noAck: true
240
245
  });
241
246
 
242
- for (let i = 0; i < dataObjectRefs.length; i++) {
243
- const {
244
- dataObject,
245
- value
246
- } = dataObjectRefs[i];
247
+ for (const {
248
+ dataObject,
249
+ value
250
+ } of dataObjectRefs) {
247
251
  dataObject.write(broker, 'data', 'data.write.', value);
248
252
  }
249
253
 
250
254
  function onDataObjectResponse(routingKey, message) {
251
- const idx = dataObjectRefs.findIndex(dobj => dobj.id === message.content.id);
252
- responses[idx] = message.content;
255
+ const idx = dataObjectRefs.findIndex(({
256
+ dataObject
257
+ }) => dataObject.id === message.content.id);
258
+ responses[idx] = {
259
+ index: idx,
260
+ ...message.content
261
+ };
253
262
  ++count;
254
263
  if (count < dataObjectRefs.length) return;
255
- dataWriteConsumer.cancel();
264
+ broker.cancel(message.fields.consumerTag);
256
265
  return callback(null, responses);
257
266
  }
258
267
  }