bpmn-elements 10.1.0 → 11.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ # 11.0.0
5
+
6
+ - slim activity state by removing properties not needed for recover, might be breaking if state is inspected
7
+ - slim process state by removing properties not needed for recover, might be breaking if state is inspected
8
+
4
9
  # 10.1.0
5
10
 
6
11
  - introduce Lane behaviour
@@ -296,6 +296,22 @@ Activity.prototype.run = function run(runContent) {
296
296
  broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
297
297
  this._consumeRunQ();
298
298
  };
299
+ Activity.prototype.getState = function getState() {
300
+ const status = this.status;
301
+ const exec = this[kExec];
302
+ return {
303
+ id: this.id,
304
+ type: this.type,
305
+ ...(status && {
306
+ status
307
+ }),
308
+ executionId: exec.executionId,
309
+ stopped: this.stopped,
310
+ counters: this.counters,
311
+ broker: this.broker.getState(true),
312
+ execution: exec.execution && exec.execution.getState()
313
+ };
314
+ };
299
315
  Activity.prototype.recover = function recover(state) {
300
316
  if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
301
317
  if (!state) return;
@@ -380,21 +396,6 @@ Activity.prototype.shake = function shake() {
380
396
  Activity.prototype.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
381
397
  return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
382
398
  };
383
- Activity.prototype.getState = function getState() {
384
- const msg = this._createMessage();
385
- const exec = this[kExec];
386
- return {
387
- ...msg,
388
- executionId: exec.executionId,
389
- stopped: this.stopped,
390
- behaviour: {
391
- ...this.behaviour
392
- },
393
- counters: this.counters,
394
- broker: this.broker.getState(true),
395
- execution: exec.execution && exec.execution.getState()
396
- };
397
- };
398
399
  Activity.prototype.getApi = function getApi(message) {
399
400
  const execution = this[kExec].execution;
400
401
  if (execution && !execution.completed) return execution.getApi(message);
@@ -156,6 +156,16 @@ Definition.prototype.resume = function resume(callback) {
156
156
  this._activateRunConsumers();
157
157
  return this;
158
158
  };
159
+ Definition.prototype.getState = function getState() {
160
+ return this._createMessage({
161
+ status: this.status,
162
+ stopped: this.stopped,
163
+ counters: this.counters,
164
+ environment: this.environment.getState(),
165
+ execution: this.execution && this.execution.getState(),
166
+ broker: this.broker.getState(true)
167
+ });
168
+ };
159
169
  Definition.prototype.recover = function recover(state) {
160
170
  if (this.isRunning) throw new Error('cannot recover running definition');
161
171
  if (!state) return this;
@@ -209,16 +219,6 @@ Definition.prototype._shakeProcess = function shakeProcess(shakeBp, startId) {
209
219
  if (shovel) shakeBp.broker.closeShovel('shaker');
210
220
  return shakeResult;
211
221
  };
212
- Definition.prototype.getState = function getState() {
213
- return this._createMessage({
214
- status: this.status,
215
- stopped: this.stopped,
216
- counters: this.counters,
217
- environment: this.environment.getState(),
218
- execution: this.execution && this.execution.getState(),
219
- broker: this.broker.getState(true)
220
- });
221
- };
222
222
  Definition.prototype.getProcesses = function getProcesses() {
223
223
  const execution = this.execution;
224
224
  if (execution) return execution.getProcesses();
@@ -72,10 +72,12 @@ Association.prototype.discard = function discard(content = {}) {
72
72
  return true;
73
73
  };
74
74
  Association.prototype.getState = function getState() {
75
- return this._createMessageContent({
75
+ return {
76
+ id: this.id,
77
+ type: this.type,
76
78
  counters: this.counters,
77
79
  broker: this.broker.getState(true)
78
- });
80
+ };
79
81
  };
80
82
  Association.prototype.recover = function recover(state) {
81
83
  Object.assign(this[kCounters], state.counters);
@@ -59,11 +59,13 @@ MessageFlow.prototype.getState = function getState() {
59
59
  return {
60
60
  id: this.id,
61
61
  type: this.type,
62
- counters: this.counters
62
+ counters: this.counters,
63
+ broker: this.broker.getState(true)
63
64
  };
64
65
  };
65
66
  MessageFlow.prototype.recover = function recover(state) {
66
67
  Object.assign(this[kCounters], state.counters);
68
+ this.broker.recover(state.broker);
67
69
  };
68
70
  MessageFlow.prototype.getApi = function getApi(message) {
69
71
  return new _Api.Api('message', this.broker, message || {
@@ -94,10 +94,12 @@ SequenceFlow.prototype.discard = function discard(content = {}) {
94
94
  this._publishEvent('discard', content);
95
95
  };
96
96
  SequenceFlow.prototype.getState = function getState() {
97
- return this.createMessage({
97
+ return {
98
+ id: this.id,
99
+ type: this.type,
98
100
  counters: this.counters,
99
101
  broker: this.broker.getState(true)
100
- });
102
+ };
101
103
  };
102
104
  SequenceFlow.prototype.recover = function recover(state) {
103
105
  Object.assign(this[kCounters], state.counters);
@@ -167,6 +167,19 @@ Process.prototype.resume = function resume() {
167
167
  this._activateRunConsumers();
168
168
  return this;
169
169
  };
170
+ Process.prototype.getState = function getState() {
171
+ return {
172
+ id: this.id,
173
+ type: this.type,
174
+ executionId: this.executionId,
175
+ environment: this.environment.getState(),
176
+ status: this.status,
177
+ stopped: this.stopped,
178
+ counters: this.counters,
179
+ broker: this.broker.getState(true),
180
+ execution: this.execution && this.execution.getState()
181
+ };
182
+ };
170
183
  Process.prototype.recover = function recover(state) {
171
184
  if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
172
185
  if (!state) return this;
@@ -203,16 +216,6 @@ Process.prototype.signal = function signal(message) {
203
216
  delegate: true
204
217
  });
205
218
  };
206
- Process.prototype.getState = function getState() {
207
- return this._createMessage({
208
- environment: this.environment.getState(),
209
- status: this.status,
210
- stopped: this.stopped,
211
- counters: this.counters,
212
- broker: this.broker.getState(true),
213
- execution: this.execution && this.execution.getState()
214
- });
215
- };
216
219
  Process.prototype.cancelActivity = function cancelActivity(message) {
217
220
  return this.getApi().cancel(message, {
218
221
  delegate: true
@@ -157,6 +157,34 @@ ProcessExecution.prototype.resume = function resume() {
157
157
  if (this[kCompleted]) return;
158
158
  if (!postponed.length && status === 'executing') return this._complete('completed');
159
159
  };
160
+ ProcessExecution.prototype.getState = function getState() {
161
+ const {
162
+ children,
163
+ flows,
164
+ outboundMessageFlows,
165
+ associations
166
+ } = this[kElements];
167
+ return {
168
+ executionId: this.executionId,
169
+ stopped: this[kStopped],
170
+ completed: this[kCompleted],
171
+ status: this.status,
172
+ children: children.reduce((result, activity) => {
173
+ if (activity.placeholder) return result;
174
+ result.push(activity.getState());
175
+ return result;
176
+ }, []),
177
+ ...(flows.length && {
178
+ flows: flows.map(f => f.getState())
179
+ }),
180
+ ...(outboundMessageFlows.length && {
181
+ messageFlows: outboundMessageFlows.length && outboundMessageFlows.map(f => f.getState())
182
+ }),
183
+ ...(associations.length && {
184
+ associations: associations.map(f => f.getState())
185
+ })
186
+ };
187
+ };
160
188
  ProcessExecution.prototype.recover = function recover(state) {
161
189
  if (!state) return this;
162
190
  this.executionId = state.executionId;
@@ -271,34 +299,6 @@ ProcessExecution.prototype.cancel = function discard() {
271
299
  type: 'cancel'
272
300
  });
273
301
  };
274
- ProcessExecution.prototype.getState = function getState() {
275
- const {
276
- children,
277
- flows,
278
- outboundMessageFlows,
279
- associations
280
- } = this[kElements];
281
- return {
282
- executionId: this.executionId,
283
- stopped: this[kStopped],
284
- completed: this[kCompleted],
285
- status: this.status,
286
- children: children.reduce((result, activity) => {
287
- if (activity.placeholder) return result;
288
- result.push(activity.getState());
289
- return result;
290
- }, []),
291
- ...(flows.length && {
292
- flows: flows.map(f => f.getState())
293
- }),
294
- ...(outboundMessageFlows.length && {
295
- messageFlows: outboundMessageFlows.length && outboundMessageFlows.map(f => f.getState())
296
- }),
297
- ...(associations.length && {
298
- associations: associations.map(f => f.getState())
299
- })
300
- };
301
- };
302
302
  ProcessExecution.prototype.getActivities = function getActivities() {
303
303
  return this[kElements].children.slice();
304
304
  };
@@ -86,7 +86,6 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
86
86
  return loopCharacteristics.execute(executeMessage);
87
87
  }
88
88
  const processExecution = this._upsertExecution(executeMessage);
89
- if (!processExecution) return;
90
89
  return processExecution.execute(executeMessage);
91
90
  };
92
91
  SubProcessBehaviour.prototype.stop = function stop() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "10.1.0",
3
+ "version": "11.0.0",
4
4
  "description": "Executable workflow elements based on BPMN 2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,11 +13,11 @@
13
13
  },
14
14
  "sideEffects": false,
15
15
  "scripts": {
16
- "test": "mocha -R @bonniernews/hot-bev -p -t 2000",
16
+ "test": "mocha -R @bonniernews/hot-bev -p -t 3000",
17
17
  "posttest": "npm run lint && npm run dist",
18
18
  "lint": "eslint . --cache",
19
19
  "prepack": "npm run dist",
20
- "cov:html": "c8 -r html -r text mocha -R @bonniernews/hot-bev -p -t 2000",
20
+ "cov:html": "c8 -r html -r text mocha -R @bonniernews/hot-bev -p -t 3000",
21
21
  "test:lcov": "c8 -r lcov mocha && npm run lint",
22
22
  "dist": "babel src -d dist/"
23
23
  },
@@ -51,12 +51,12 @@
51
51
  "@babel/register": "^7.22.5",
52
52
  "@bonniernews/hot-bev": "^0.4.0",
53
53
  "bpmn-moddle": "^8.0.1",
54
- "c8": "^7.14.0",
54
+ "c8": "^8.0.0",
55
55
  "camunda-bpmn-moddle": "^7.0.1",
56
56
  "chai": "^4.3.7",
57
57
  "chronokinesis": "^5.0.2",
58
58
  "debug": "^4.3.4",
59
- "eslint": "^8.42.0",
59
+ "eslint": "^8.43.0",
60
60
  "eslint-plugin-import": "^2.27.5",
61
61
  "got": "^12.6.1",
62
62
  "mocha": "^10.1.0",
@@ -301,6 +301,21 @@ Activity.prototype.run = function run(runContent) {
301
301
  this._consumeRunQ();
302
302
  };
303
303
 
304
+ Activity.prototype.getState = function getState() {
305
+ const status = this.status;
306
+ const exec = this[kExec];
307
+ return {
308
+ id: this.id,
309
+ type: this.type,
310
+ ...(status && {status}),
311
+ executionId: exec.executionId,
312
+ stopped: this.stopped,
313
+ counters: this.counters,
314
+ broker: this.broker.getState(true),
315
+ execution: exec.execution && exec.execution.getState(),
316
+ };
317
+ };
318
+
304
319
  Activity.prototype.recover = function recover(state) {
305
320
  if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
306
321
  if (!state) return;
@@ -389,21 +404,6 @@ Activity.prototype.evaluateOutbound = function evaluateOutbound(fromMessage, dis
389
404
  return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
390
405
  };
391
406
 
392
- Activity.prototype.getState = function getState() {
393
- const msg = this._createMessage();
394
-
395
- const exec = this[kExec];
396
- return {
397
- ...msg,
398
- executionId: exec.executionId,
399
- stopped: this.stopped,
400
- behaviour: {...this.behaviour},
401
- counters: this.counters,
402
- broker: this.broker.getState(true),
403
- execution: exec.execution && exec.execution.getState(),
404
- };
405
- };
406
-
407
407
  Activity.prototype.getApi = function getApi(message) {
408
408
  const execution = this[kExec].execution;
409
409
  if (execution && !execution.completed) return execution.getApi(message);
@@ -162,6 +162,17 @@ Definition.prototype.resume = function resume(callback) {
162
162
  return this;
163
163
  };
164
164
 
165
+ Definition.prototype.getState = function getState() {
166
+ return this._createMessage({
167
+ status: this.status,
168
+ stopped: this.stopped,
169
+ counters: this.counters,
170
+ environment: this.environment.getState(),
171
+ execution: this.execution && this.execution.getState(),
172
+ broker: this.broker.getState(true),
173
+ });
174
+ };
175
+
165
176
  Definition.prototype.recover = function recover(state) {
166
177
  if (this.isRunning) throw new Error('cannot recover running definition');
167
178
  if (!state) return this;
@@ -222,17 +233,6 @@ Definition.prototype._shakeProcess = function shakeProcess(shakeBp, startId) {
222
233
  return shakeResult;
223
234
  };
224
235
 
225
- Definition.prototype.getState = function getState() {
226
- return this._createMessage({
227
- status: this.status,
228
- stopped: this.stopped,
229
- counters: this.counters,
230
- environment: this.environment.getState(),
231
- execution: this.execution && this.execution.getState(),
232
- broker: this.broker.getState(true),
233
- });
234
- };
235
-
236
236
  Definition.prototype.getProcesses = function getProcesses() {
237
237
  const execution = this.execution;
238
238
  if (execution) return execution.getProcesses();
@@ -59,10 +59,12 @@ Association.prototype.discard = function discard(content = {}) {
59
59
  };
60
60
 
61
61
  Association.prototype.getState = function getState() {
62
- return this._createMessageContent({
62
+ return {
63
+ id: this.id,
64
+ type: this.type,
63
65
  counters: this.counters,
64
66
  broker: this.broker.getState(true),
65
- });
67
+ };
66
68
  };
67
69
 
68
70
  Association.prototype.recover = function recover(state) {
@@ -46,11 +46,13 @@ MessageFlow.prototype.getState = function getState() {
46
46
  id: this.id,
47
47
  type: this.type,
48
48
  counters: this.counters,
49
+ broker: this.broker.getState(true),
49
50
  };
50
51
  };
51
52
 
52
53
  MessageFlow.prototype.recover = function recover(state) {
53
54
  Object.assign(this[kCounters], state.counters);
55
+ this.broker.recover(state.broker);
54
56
  };
55
57
 
56
58
  MessageFlow.prototype.getApi = function getApi(message) {
@@ -75,10 +75,12 @@ SequenceFlow.prototype.discard = function discard(content = {}) {
75
75
  };
76
76
 
77
77
  SequenceFlow.prototype.getState = function getState() {
78
- return this.createMessage({
78
+ return {
79
+ id: this.id,
80
+ type: this.type,
79
81
  counters: this.counters,
80
82
  broker: this.broker.getState(true),
81
- });
83
+ };
82
84
  };
83
85
 
84
86
  SequenceFlow.prototype.recover = function recover(state) {
@@ -161,6 +161,20 @@ Process.prototype.resume = function resume() {
161
161
  return this;
162
162
  };
163
163
 
164
+ Process.prototype.getState = function getState() {
165
+ return {
166
+ id: this.id,
167
+ type: this.type,
168
+ executionId: this.executionId,
169
+ environment: this.environment.getState(),
170
+ status: this.status,
171
+ stopped: this.stopped,
172
+ counters: this.counters,
173
+ broker: this.broker.getState(true),
174
+ execution: this.execution && this.execution.getState(),
175
+ };
176
+ };
177
+
164
178
  Process.prototype.recover = function recover(state) {
165
179
  if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
166
180
  if (!state) return this;
@@ -201,17 +215,6 @@ Process.prototype.signal = function signal(message) {
201
215
  return this.getApi().signal(message, {delegate: true});
202
216
  };
203
217
 
204
- Process.prototype.getState = function getState() {
205
- return this._createMessage({
206
- environment: this.environment.getState(),
207
- status: this.status,
208
- stopped: this.stopped,
209
- counters: this.counters,
210
- broker: this.broker.getState(true),
211
- execution: this.execution && this.execution.getState(),
212
- });
213
- };
214
-
215
218
  Process.prototype.cancelActivity = function cancelActivity(message) {
216
219
  return this.getApi().cancel(message, {delegate: true});
217
220
  };
@@ -169,6 +169,24 @@ ProcessExecution.prototype.resume = function resume() {
169
169
  if (!postponed.length && status === 'executing') return this._complete('completed');
170
170
  };
171
171
 
172
+ ProcessExecution.prototype.getState = function getState() {
173
+ const {children, flows, outboundMessageFlows, associations} = this[kElements];
174
+ return {
175
+ executionId: this.executionId,
176
+ stopped: this[kStopped],
177
+ completed: this[kCompleted],
178
+ status: this.status,
179
+ children: children.reduce((result, activity) => {
180
+ if (activity.placeholder) return result;
181
+ result.push(activity.getState());
182
+ return result;
183
+ }, []),
184
+ ...(flows.length && {flows: flows.map((f) => f.getState())}),
185
+ ...(outboundMessageFlows.length && {messageFlows: outboundMessageFlows.length && outboundMessageFlows.map((f) => f.getState())}),
186
+ ...(associations.length && {associations: associations.map((f) => f.getState())}),
187
+ };
188
+ };
189
+
172
190
  ProcessExecution.prototype.recover = function recover(state) {
173
191
  if (!state) return this;
174
192
  this.executionId = state.executionId;
@@ -282,24 +300,6 @@ ProcessExecution.prototype.cancel = function discard() {
282
300
  }, { type: 'cancel' });
283
301
  };
284
302
 
285
- ProcessExecution.prototype.getState = function getState() {
286
- const {children, flows, outboundMessageFlows, associations} = this[kElements];
287
- return {
288
- executionId: this.executionId,
289
- stopped: this[kStopped],
290
- completed: this[kCompleted],
291
- status: this.status,
292
- children: children.reduce((result, activity) => {
293
- if (activity.placeholder) return result;
294
- result.push(activity.getState());
295
- return result;
296
- }, []),
297
- ...(flows.length && {flows: flows.map((f) => f.getState())}),
298
- ...(outboundMessageFlows.length && {messageFlows: outboundMessageFlows.length && outboundMessageFlows.map((f) => f.getState())}),
299
- ...(associations.length && {associations: associations.map((f) => f.getState())}),
300
- };
301
- };
302
-
303
303
  ProcessExecution.prototype.getActivities = function getActivities() {
304
304
  return this[kElements].children.slice();
305
305
  };
@@ -76,8 +76,6 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
76
76
  }
77
77
 
78
78
  const processExecution = this._upsertExecution(executeMessage);
79
- if (!processExecution) return;
80
-
81
79
  return processExecution.execute(executeMessage);
82
80
  };
83
81