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
@@ -1,19 +1,26 @@
1
1
  import getPropertyValue from '../getPropertyValue';
2
2
 
3
+ const propertiesSymbol = Symbol.for('properties');
4
+ const consumingSymbol = Symbol.for('consuming');
5
+
3
6
  export default function Properties(activity, propertiesDef, context) {
4
- if (!propertiesDef || !propertiesDef.values || !propertiesDef.values.length) return;
7
+ this.activity = activity;
8
+ this.broker = activity.broker;
9
+
10
+ const props = this[propertiesSymbol] = {
11
+ properties: [],
12
+ dataInputObjects: [],
13
+ dataOutputObjects: [],
14
+ };
5
15
 
6
- const {broker, environment} = activity;
7
- const formatQ = broker.getQueue('format-run-q');
8
- let activityConsumer;
9
16
 
10
- const {properties, dataInputObjects, dataOutputObjects} = propertiesDef.values.reduce((result, {id, ...def}) => {
17
+ for (const {id, ...def} of propertiesDef.values) {
11
18
  const source = {
12
19
  id,
13
20
  type: def.type,
14
- name: def.name,
21
+ name: def.behaviour && def.behaviour.name,
15
22
  };
16
- result.properties.push(source);
23
+ props.properties.push(source);
17
24
 
18
25
  const inputDataObjectId = getPropertyValue(def, 'behaviour.dataInput.association.source.dataObject.id');
19
26
  const outputDataObjectId = getPropertyValue(def, 'behaviour.dataOutput.association.target.dataObject.id');
@@ -22,141 +29,134 @@ export default function Properties(activity, propertiesDef, context) {
22
29
 
23
30
  if (inputDataObjectId) {
24
31
  const reference = context.getDataObjectById(inputDataObjectId);
25
- result.dataInputObjects.push({id, reference});
32
+ props.dataInputObjects.push({id, reference});
26
33
  source.input = {
27
34
  reference,
28
35
  };
29
36
  }
30
37
  if (outputDataObjectId) {
31
38
  const reference = context.getDataObjectById(outputDataObjectId);
32
- result.dataOutputObjects.push({id, reference: reference});
39
+ props.dataOutputObjects.push({id, reference: reference});
33
40
  source.output = {
34
41
  reference,
35
42
  };
36
43
  }
37
44
  if (inputDataStoreId) {
38
45
  const reference = context.getDataStoreById(inputDataStoreId);
39
- result.dataInputObjects.push({id, reference});
46
+ props.dataInputObjects.push({id, reference});
40
47
  source.input = {
41
48
  reference,
42
49
  };
43
50
  }
44
51
  if (outputDataStoreId) {
45
52
  const reference = context.getDataStoreById(outputDataStoreId);
46
- result.dataOutputObjects.push({id, reference});
53
+ props.dataOutputObjects.push({id, reference});
47
54
  source.output = {
48
55
  reference,
49
56
  };
50
57
  }
51
- return result;
52
- }, {
53
- properties: [],
54
- dataInputObjects: [],
55
- dataOutputObjects: [],
56
- });
57
-
58
- const propertiesApi = {
59
- type: 'properties',
60
- activate,
61
- deactivate,
62
- };
63
-
64
- return propertiesApi;
65
-
66
- function activate(message) {
67
- if (activityConsumer) return;
58
+ }
59
+ }
68
60
 
69
- if (message.fields.redelivered && message.content.properties) {
70
- onActivityEvent('activity.extension.resume', message);
71
- }
61
+ const proto = Properties.prototype;
72
62
 
73
- activityConsumer = broker.subscribeTmp('event', 'activity.#', onActivityEvent, {noAck: true});
74
- }
63
+ proto.activate = function activate(message) {
64
+ if (this[consumingSymbol]) return;
75
65
 
76
- function deactivate() {
77
- if (activityConsumer) activityConsumer = activityConsumer.cancel();
66
+ if (message.fields.redelivered && message.content.properties) {
67
+ this._onActivityEvent('activity.extension.resume', message);
78
68
  }
79
69
 
80
- function onActivityEvent(routingKey, message) {
81
- if (routingKey === 'activity.enter') {
82
- return formatOnEnter(message);
83
- }
70
+ this[consumingSymbol] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {noAck: true});
71
+ };
84
72
 
85
- if (routingKey === 'activity.extension.resume') {
86
- return formatOnEnter(message);
87
- }
73
+ proto.deactivate = function deactivate() {
74
+ if (this[consumingSymbol]) this[consumingSymbol] = this[consumingSymbol].cancel();
75
+ };
88
76
 
89
- if (routingKey === 'activity.execution.completed') {
90
- return formatOnComplete(message);
91
- }
77
+ proto._onActivityEvent = function onActivityEvent(routingKey, message) {
78
+ if (routingKey === 'activity.enter') {
79
+ return this._formatOnEnter(message);
92
80
  }
93
81
 
94
- function formatOnEnter(message) {
95
- const startRoutingKey = 'run.enter.bpmn-properties';
82
+ if (routingKey === 'activity.extension.resume') {
83
+ return this._formatOnEnter(message);
84
+ }
96
85
 
97
- if (!dataInputObjects.length) {
98
- return formatQ.queueMessage({routingKey: startRoutingKey}, {
99
- properties: getProperties(message),
100
- });
101
- }
86
+ if (routingKey === 'activity.execution.completed') {
87
+ return this._formatOnComplete(message);
88
+ }
89
+ };
102
90
 
103
- const endRoutingKey = 'run.enter.bpmn-properties.end';
104
- formatQ.queueMessage({routingKey: startRoutingKey}, {
105
- endRoutingKey,
106
- properties: getProperties(message),
107
- });
91
+ proto._formatOnEnter = function formatOnEnter(message) {
92
+ const startRoutingKey = 'run.enter.bpmn-properties';
108
93
 
109
- return read(broker, dataInputObjects, (_, responses) => {
110
- broker.publish('format', endRoutingKey, {
111
- properties: getProperties(message, responses),
112
- });
94
+ const dataInputObjects = this[propertiesSymbol].dataInputObjects;
95
+ const broker = this.broker;
96
+ if (!dataInputObjects.length) {
97
+ return broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
98
+ properties: this._getProperties(message),
113
99
  });
114
100
  }
115
101
 
116
- function formatOnComplete(message) {
117
- const startRoutingKey = 'run.end.bpmn-properties';
102
+ const endRoutingKey = 'run.enter.bpmn-properties.end';
103
+ broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
104
+ endRoutingKey,
105
+ properties: this._getProperties(message),
106
+ });
118
107
 
119
- const messageOutput = getPropertyValue(message, 'content.output.properties') || {};
120
- const outputProperties = getProperties(message, messageOutput);
108
+ return read(broker, dataInputObjects, (_, responses) => {
109
+ broker.publish('format', endRoutingKey, {
110
+ properties: this._getProperties(message, responses),
111
+ });
112
+ });
113
+ };
121
114
 
122
- if (!dataOutputObjects.length) {
123
- return formatQ.queueMessage({routingKey: startRoutingKey}, {
124
- properties: outputProperties,
125
- });
126
- }
115
+ proto._formatOnComplete = function formatOnComplete(message) {
116
+ const startRoutingKey = 'run.end.bpmn-properties';
117
+
118
+ const messageOutput = getPropertyValue(message, 'content.output.properties') || {};
119
+ const outputProperties = this._getProperties(message, messageOutput);
127
120
 
128
- const endRoutingKey = 'run.end.bpmn-properties.end';
129
- formatQ.queueMessage({routingKey: startRoutingKey}, {
130
- endRoutingKey,
121
+ const dataOutputObjects = this[propertiesSymbol].dataOutputObjects;
122
+ const broker = this.broker;
123
+ if (!dataOutputObjects.length) {
124
+ return broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
131
125
  properties: outputProperties,
132
126
  });
127
+ }
128
+
129
+ const endRoutingKey = 'run.end.bpmn-properties.end';
130
+ broker.getQueue('format-run-q').queueMessage({routingKey: startRoutingKey}, {
131
+ endRoutingKey,
132
+ properties: outputProperties,
133
+ });
133
134
 
134
- return write(broker, dataOutputObjects, outputProperties, (_, responses) => {
135
- broker.publish('format', endRoutingKey, {
136
- properties: getProperties(message, responses),
137
- });
135
+ return write(broker, dataOutputObjects, outputProperties, (_, responses) => {
136
+ broker.publish('format', endRoutingKey, {
137
+ properties: this._getProperties(message, responses),
138
138
  });
139
- }
139
+ });
140
+ };
140
141
 
141
- function getProperties(message, values) {
142
- let response = {};
142
+ proto._getProperties = function getProperties(message, values) {
143
+ let response = {};
143
144
 
144
- if (message.content.properties) {
145
- response = {...message.content.properties};
146
- }
145
+ if (message.content.properties) {
146
+ response = {...message.content.properties};
147
+ }
147
148
 
148
- return properties.reduce((result, {id, type, name, value}) => {
149
- if (!(id in result)) {
150
- result[id] = {id, type, name};
151
- }
149
+ for (const {id, type, name} of this[propertiesSymbol].properties) {
150
+ if (!(id in response)) {
151
+ response[id] = {id, type, name};
152
+ }
152
153
 
153
- if (value !== undefined) result[id].value = environment.resolveExpression(value, message);
154
- if (!values || !(id in values)) return result;
155
- result[id].value = values[id].value;
156
- return result;
157
- }, response);
154
+ if (!values || !(id in values)) continue;
155
+ response[id].value = values[id].value;
158
156
  }
159
- }
157
+
158
+ return response;
159
+ };
160
160
 
161
161
  function read(broker, dataReferences, callback) {
162
162
  const responses = {};
@@ -164,8 +164,7 @@ function read(broker, dataReferences, callback) {
164
164
 
165
165
  const dataReadConsumer = broker.subscribeTmp('data', 'data.read.#', onDataReadResponse, {noAck: true});
166
166
 
167
- for (let i = 0; i < dataReferences.length; i++) {
168
- const {id: propertyId, reference} = dataReferences[i];
167
+ for (const {id: propertyId, reference} of dataReferences) {
169
168
  reference.read(broker, 'data', 'data.read.', {correlationId: propertyId});
170
169
  }
171
170
 
@@ -184,8 +183,7 @@ function write(broker, dataReferences, properties, callback) {
184
183
  let count = 0;
185
184
  const dataWriteConsumer = broker.subscribeTmp('data', 'data.write.#', onDataWriteResponse, {noAck: true});
186
185
 
187
- for (let i = 0; i < dataReferences.length; i++) {
188
- const {id: propertyId, reference} = dataReferences[i];
186
+ for (const {id: propertyId, reference} of dataReferences) {
189
187
  const value = propertyId in properties ? properties[propertyId].value : undefined;
190
188
  reference.write(broker, 'data', 'data.write.', value, {correlationId: propertyId});
191
189
  }