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
@@ -13,6 +13,10 @@ var _messageHelper = require("../messageHelper");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
+ const completedSymbol = Symbol.for('completed');
17
+ const messageQSymbol = Symbol.for('messageQ');
18
+ const executeMessageSymbol = Symbol.for('executeMessage');
19
+
16
20
  function LinkEventDefinition(activity, eventDefinition) {
17
21
  const {
18
22
  id,
@@ -21,170 +25,191 @@ function LinkEventDefinition(activity, eventDefinition) {
21
25
  isThrowing
22
26
  } = activity;
23
27
  const {
24
- type
28
+ type = 'LinkEventDefinition',
29
+ behaviour
25
30
  } = eventDefinition;
26
- const {
27
- debug
28
- } = environment.Logger(type.toLowerCase());
29
- const reference = {
30
- linkName: eventDefinition.behaviour.name
31
- };
32
- const linkQueueName = `link-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(reference.linkName)}-q`;
33
- if (!isThrowing) setupCatch();else setupThrow();
34
- const source = {
35
- id,
36
- type,
37
- reference: { ...reference,
38
- referenceType: 'link'
39
- },
40
- execute: isThrowing ? executeThrow : executeCatch
31
+ this.id = id;
32
+ this.type = type;
33
+ const reference = this.reference = {
34
+ linkName: behaviour.name,
35
+ referenceType: 'link'
41
36
  };
42
- return source;
43
-
44
- function executeCatch(executeMessage) {
45
- let completed;
46
- const messageContent = (0, _messageHelper.cloneContent)(executeMessage.content);
47
- const {
48
- executionId,
49
- parent
50
- } = messageContent;
51
- const parentExecutionId = parent && parent.executionId;
52
- const description = messageDescription();
53
- broker.consume(linkQueueName, onCatchLink, {
54
- noAck: true,
55
- consumerTag: `_api-link-${executionId}`
37
+ this.isThrowing = isThrowing;
38
+ this.activity = activity;
39
+ this.broker = broker;
40
+ this.logger = environment.Logger(type.toLowerCase());
41
+ this[completedSymbol] = false;
42
+
43
+ if (!isThrowing) {
44
+ const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(reference.linkName)}-q`;
45
+ this[messageQSymbol] = broker.assertQueue(messageQueueName, {
46
+ autoDelete: false,
47
+ durable: true
56
48
  });
57
- if (completed) return;
58
- broker.subscribeTmp('api', `activity.stop.${parentExecutionId}`, onApiMessage, {
59
- noAck: true,
60
- consumerTag: `_api-parent-${parentExecutionId}`
49
+ broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
50
+ durable: true
61
51
  });
62
- broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
52
+ } else {
53
+ broker.subscribeTmp('event', 'activity.discard', this._onDiscard.bind(this), {
63
54
  noAck: true,
64
- consumerTag: `_api-${executionId}`
65
- });
66
- debug(`<${executionId} (${id})> expect ${description}`);
67
- broker.publish('event', 'activity.wait', { ...messageContent,
68
- executionId: parentExecutionId,
69
- parent: (0, _messageHelper.shiftParent)(parent),
70
- link: { ...reference
71
- }
55
+ consumerTag: '_link-parent-discard'
72
56
  });
57
+ }
58
+ }
73
59
 
74
- function onCatchLink(routingKey, message) {
75
- if ((0, _getPropertyValue.default)(message, 'content.message.linkName') !== reference.linkName) return;
76
- if (message.content.state === 'discard') return discard();
77
- return complete('caught', message.content.message);
78
- }
60
+ const proto = LinkEventDefinition.prototype;
61
+ Object.defineProperty(proto, 'executionId', {
62
+ get() {
63
+ const message = this[executeMessageSymbol];
64
+ return message && message.content.executionId;
65
+ }
79
66
 
80
- function onApiMessage(routingKey, message) {
81
- const messageType = message.properties.type;
82
-
83
- switch (messageType) {
84
- case 'link':
85
- {
86
- return complete('got link with', message.content.message);
87
- }
88
-
89
- case 'discard':
90
- {
91
- return discard();
92
- }
93
-
94
- case 'stop':
95
- {
96
- stop();
97
- break;
98
- }
99
- }
100
- }
67
+ });
101
68
 
102
- function complete(verb, output) {
103
- completed = true;
104
- stop();
105
- debug(`<${executionId} (${id})> ${verb} ${description}`);
106
- broker.publish('event', 'activity.catch', { ...messageContent,
107
- link: { ...reference
108
- },
109
- message: { ...output
110
- },
111
- executionId: parentExecutionId || executionId,
112
- parent: (0, _messageHelper.shiftParent)(executeMessage.content.parent)
113
- }, {
114
- type: 'catch'
115
- });
116
- return broker.publish('execution', 'execute.completed', { ...messageContent,
117
- output,
118
- state: 'catch'
119
- });
120
- }
69
+ proto.execute = function execute(executeMessage) {
70
+ return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
71
+ };
121
72
 
122
- function discard() {
123
- completed = true;
124
- stop();
125
- return broker.publish('execution', 'execute.discard', { ...messageContent
126
- });
73
+ proto.executeCatch = function executeCatch(executeMessage) {
74
+ this[executeMessageSymbol] = executeMessage;
75
+ this[completedSymbol] = false;
76
+ const executeContent = executeMessage.content;
77
+ const {
78
+ executionId,
79
+ parent
80
+ } = executeContent;
81
+ const parentExecutionId = parent.executionId;
82
+ this[messageQSymbol].consume(this._onCatchLink.bind(this), {
83
+ noAck: true,
84
+ consumerTag: `_api-link-${executionId}`
85
+ });
86
+ if (this[completedSymbol]) return;
87
+ const broker = this.broker;
88
+
89
+ const onApiMessage = this._onApiMessage.bind(this);
90
+
91
+ broker.subscribeTmp('api', `activity.stop.${parentExecutionId}`, onApiMessage, {
92
+ noAck: true,
93
+ consumerTag: `_api-parent-${executionId}`
94
+ });
95
+ broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
96
+ noAck: true,
97
+ consumerTag: `_api-${executionId}`
98
+ });
99
+
100
+ this._debug(`expect link ${this.reference.linkName}`);
101
+
102
+ const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
103
+ executionId: parentExecutionId,
104
+ link: { ...this.reference
127
105
  }
106
+ });
107
+ waitContent.parent = (0, _messageHelper.shiftParent)(parent);
108
+ broker.publish('event', 'activity.wait', waitContent);
109
+ };
128
110
 
129
- function stop() {
130
- broker.cancel(`_api-link-${executionId}`);
131
- broker.cancel(`_api-parent-${parentExecutionId}`);
132
- broker.cancel(`_api-${executionId}`);
133
- broker.purgeQueue(linkQueueName);
134
- }
135
- }
111
+ proto.executeThrow = function executeThrow(executeMessage) {
112
+ const executeContent = executeMessage.content;
113
+ const {
114
+ executionId,
115
+ parent
116
+ } = executeContent;
117
+ const parentExecutionId = parent && parent.executionId;
118
+ this.logger.debug(`<${executionId} (${this.activity.id})> throw link ${this.reference.linkName}`);
119
+ const broker = this.broker;
120
+ const linkContent = (0, _messageHelper.cloneContent)(executeContent, {
121
+ executionId: parentExecutionId,
122
+ message: { ...this.reference
123
+ },
124
+ state: 'throw'
125
+ });
126
+ linkContent.parent = (0, _messageHelper.shiftParent)(parent);
127
+ broker.publish('event', 'activity.link', linkContent, {
128
+ type: 'link',
129
+ delegate: true
130
+ });
131
+ return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
132
+ };
133
+
134
+ proto._onCatchLink = function onCatchLink(routingKey, message) {
135
+ if ((0, _getPropertyValue.default)(message, 'content.message.linkName') !== this.reference.linkName) return;
136
+ if (message.content.state === 'discard') return this._discard();
137
+ return this._complete('caught', message.content.message);
138
+ };
139
+
140
+ proto._onApiMessage = function onApiMessage(routingKey, message) {
141
+ const messageType = message.properties.type;
142
+
143
+ switch (messageType) {
144
+ case 'discard':
145
+ {
146
+ return this._discard();
147
+ }
136
148
 
137
- function executeThrow(executeMessage) {
138
- const messageContent = (0, _messageHelper.cloneContent)(executeMessage.content);
139
- const {
140
- executionId,
141
- parent
142
- } = messageContent;
143
- const parentExecutionId = parent && parent.executionId;
144
- const description = messageDescription();
145
- debug(`<${executionId} (${id})> throw ${description}`);
146
- broker.publish('event', 'activity.link', { ...(0, _messageHelper.cloneContent)(messageContent),
147
- executionId: parentExecutionId,
148
- parent: (0, _messageHelper.shiftParent)(parent),
149
- message: { ...reference
150
- },
151
- state: 'throw'
152
- }, {
153
- type: 'link',
154
- delegate: true
155
- });
156
- return broker.publish('execution', 'execute.completed', messageContent);
157
- }
149
+ case 'stop':
150
+ {
151
+ this._stop();
158
152
 
159
- function messageDescription() {
160
- return `link ${reference.linkName}`;
153
+ break;
154
+ }
161
155
  }
156
+ };
162
157
 
163
- function setupCatch() {
164
- broker.assertQueue(linkQueueName, {
165
- autoDelete: false,
166
- durable: true
167
- });
168
- broker.bindQueue(linkQueueName, 'api', '*.link.#', {
169
- durable: true
170
- });
171
- }
158
+ proto._complete = function complete(verb, output) {
159
+ this[completedSymbol] = true;
172
160
 
173
- function setupThrow() {
174
- broker.subscribeTmp('event', 'activity.discard', onDiscard, {
175
- noAck: true,
176
- consumerTag: '_link-parent-discard'
177
- });
161
+ this._stop();
178
162
 
179
- function onDiscard(_, message) {
180
- broker.publish('event', 'activity.link.discard', { ...(0, _messageHelper.cloneContent)(message.content),
181
- message: { ...reference
182
- },
183
- state: 'discard'
184
- }, {
185
- type: 'link',
186
- delegate: true
187
- });
188
- }
189
- }
190
- }
163
+ this._debug(`${verb} link ${this.reference.linkName}`);
164
+
165
+ const executeContent = this[executeMessageSymbol].content;
166
+ const parent = executeContent.parent;
167
+ const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
168
+ link: { ...this.reference
169
+ },
170
+ message: { ...output
171
+ },
172
+ executionId: parent.executionId
173
+ });
174
+ catchContent.parent = (0, _messageHelper.shiftParent)(parent);
175
+ const broker = this.broker;
176
+ broker.publish('event', 'activity.catch', catchContent, {
177
+ type: 'catch'
178
+ });
179
+ return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
180
+ output,
181
+ state: 'catch'
182
+ }));
183
+ };
184
+
185
+ proto._discard = function discard() {
186
+ this[completedSymbol] = true;
187
+
188
+ this._stop();
189
+
190
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content));
191
+ };
192
+
193
+ proto._stop = function stop() {
194
+ const broker = this.broker,
195
+ executionId = this.executionId;
196
+ broker.cancel(`_api-link-${executionId}`);
197
+ broker.cancel(`_api-parent-${executionId}`);
198
+ broker.cancel(`_api-${executionId}`);
199
+ this[messageQSymbol].purge();
200
+ };
201
+
202
+ proto._onDiscard = function onDiscard(_, message) {
203
+ this.broker.publish('event', 'activity.link.discard', (0, _messageHelper.cloneContent)(message.content, {
204
+ message: { ...this.reference
205
+ },
206
+ state: 'discard'
207
+ }), {
208
+ type: 'link',
209
+ delegate: true
210
+ });
211
+ };
212
+
213
+ proto._debug = function debug(msg) {
214
+ this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
215
+ };