bpmn-elements 10.0.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,18 @@
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
+
9
+ # 10.1.0
10
+
11
+ - introduce Lane behaviour
12
+ - add process `lanes` property with Lane instances
13
+ - add activity `lane` property containing a reference to the process lane instance
14
+ - add activity `parentElement` property referencing parent process or sub process
15
+
4
16
  # 10.0.0
5
17
 
6
18
  - drop iso8601-duration dependency and copy source (with licence). Export as `ISODuration`. Extend with repeat pattern parsing, e.g. `R3/PT1H` that corresponds to three repetitions every one hour
package/dist/Context.js CHANGED
@@ -9,11 +9,12 @@ var _Environment = _interopRequireDefault(require("./Environment.js"));
9
9
  var _ExtensionsMapper = _interopRequireDefault(require("./ExtensionsMapper.js"));
10
10
  var _shared = require("./shared.js");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const kOwner = Symbol.for('owner');
12
13
  function Context(definitionContext, environment) {
13
14
  environment = environment ? environment.clone() : new _Environment.default();
14
15
  return new ContextInstance(definitionContext, environment);
15
16
  }
16
- function ContextInstance(definitionContext, environment) {
17
+ function ContextInstance(definitionContext, environment, owner) {
17
18
  const {
18
19
  id = 'Def',
19
20
  name,
@@ -38,7 +39,13 @@ function ContextInstance(definitionContext, environment) {
38
39
  sequenceFlowRefs: {},
39
40
  sequenceFlows: []
40
41
  };
42
+ this[kOwner] = owner;
41
43
  }
44
+ Object.defineProperty(ContextInstance.prototype, 'owner', {
45
+ get() {
46
+ return this[kOwner];
47
+ }
48
+ });
42
49
  ContextInstance.prototype.getActivityById = function getActivityById(activityId) {
43
50
  const activityInstance = this.refs.activityRefs[activityId];
44
51
  if (activityInstance) return activityInstance;
@@ -95,8 +102,8 @@ ContextInstance.prototype.upsertAssociation = function upsertAssociation(associa
95
102
  instance = refs[associationDefinition.id] = new associationDefinition.Behaviour(associationDefinition, this);
96
103
  return instance;
97
104
  };
98
- ContextInstance.prototype.clone = function clone(newEnvironment) {
99
- return new ContextInstance(this.definitionContext, newEnvironment || this.environment);
105
+ ContextInstance.prototype.clone = function clone(newEnvironment, newOwner) {
106
+ return new ContextInstance(this.definitionContext, newEnvironment || this.environment, newOwner);
100
107
  };
101
108
  ContextInstance.prototype.getProcessById = function getProcessById(processId) {
102
109
  const refs = this.refs.processRefs;
@@ -106,13 +113,16 @@ ContextInstance.prototype.getProcessById = function getProcessById(processId) {
106
113
  if (!processDefinition) return null;
107
114
  const bpContext = this.clone(this.environment.clone());
108
115
  bp = refs[processId] = new processDefinition.Behaviour(processDefinition, bpContext);
116
+ bpContext[kOwner] = bp;
109
117
  this.refs.processes.push(bp);
110
118
  return bp;
111
119
  };
112
120
  ContextInstance.prototype.getNewProcessById = function getNewProcessById(processId) {
113
121
  if (!this.getProcessById(processId)) return null;
114
122
  const bpDef = this.definitionContext.getProcessById(processId);
115
- const bp = new bpDef.Behaviour(bpDef, this.clone(this.environment.clone()));
123
+ const bpContext = this.clone(this.environment.clone());
124
+ const bp = new bpDef.Behaviour(bpDef, bpContext);
125
+ bpContext[kOwner] = bp;
116
126
  return bp;
117
127
  };
118
128
  ContextInstance.prototype.getProcesses = function getProcesses() {
@@ -175,4 +185,11 @@ ContextInstance.prototype.loadExtensions = function loadExtensions(activity) {
175
185
  if (io.hasIo) extensions.extensions.push(io);
176
186
  if (!extensions.extensions.length) return;
177
187
  return extensions;
188
+ };
189
+ ContextInstance.prototype.getActivityParentById = function getActivityParentById(activityId) {
190
+ const owner = this[kOwner];
191
+ if (owner) return owner;
192
+ const activity = this.getActivityById(activityId);
193
+ const parentId = activity.parent.id;
194
+ return this.getProcessById(parentId) || this.getActivityById(parentId);
178
195
  };
@@ -102,7 +102,8 @@ function Activity(Behaviour, activityDef, context) {
102
102
  attachedTo,
103
103
  isTransaction: activityDef.isTransaction,
104
104
  isParallelJoin,
105
- isThrowing: activityDef.isThrowing
105
+ isThrowing: activityDef.isThrowing,
106
+ lane: activityDef.lane && activityDef.lane.id
106
107
  };
107
108
  this[kExec] = {};
108
109
  this[kMessageHandlers] = {
@@ -236,12 +237,27 @@ Object.defineProperty(Activity.prototype, 'attachedTo', {
236
237
  return this.getActivityById(attachedToId);
237
238
  }
238
239
  });
240
+ Object.defineProperty(Activity.prototype, 'lane', {
241
+ enumerable: true,
242
+ get() {
243
+ const laneId = this[kFlags].lane;
244
+ if (!laneId) return undefined;
245
+ const parent = this.parentElement;
246
+ return parent.getLaneById && parent.getLaneById(laneId);
247
+ }
248
+ });
239
249
  Object.defineProperty(Activity.prototype, 'eventDefinitions', {
240
250
  enumerable: true,
241
251
  get() {
242
252
  return this[kEventDefinitions];
243
253
  }
244
254
  });
255
+ Object.defineProperty(Activity.prototype, 'parentElement', {
256
+ enumerable: true,
257
+ get() {
258
+ return this.context.getActivityParentById(this.id);
259
+ }
260
+ });
245
261
  Activity.prototype.activate = function activate() {
246
262
  this[kActivated] = true;
247
263
  this.addInboundListeners();
@@ -280,6 +296,22 @@ Activity.prototype.run = function run(runContent) {
280
296
  broker.publish('run', 'run.start', (0, _messageHelper.cloneContent)(content));
281
297
  this._consumeRunQ();
282
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
+ };
283
315
  Activity.prototype.recover = function recover(state) {
284
316
  if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
285
317
  if (!state) return;
@@ -364,21 +396,6 @@ Activity.prototype.shake = function shake() {
364
396
  Activity.prototype.evaluateOutbound = function evaluateOutbound(fromMessage, discardRestAtTake, callback) {
365
397
  return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
366
398
  };
367
- Activity.prototype.getState = function getState() {
368
- const msg = this._createMessage();
369
- const exec = this[kExec];
370
- return {
371
- ...msg,
372
- executionId: exec.executionId,
373
- stopped: this.stopped,
374
- behaviour: {
375
- ...this.behaviour
376
- },
377
- counters: this.counters,
378
- broker: this.broker.getState(true),
379
- execution: exec.execution && exec.execution.getState()
380
- };
381
- };
382
399
  Activity.prototype.getApi = function getApi(message) {
383
400
  const execution = this[kExec].execution;
384
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();
@@ -294,31 +294,36 @@ DefinitionExecution.prototype._activate = function activate(processList) {
294
294
  };
295
295
  DefinitionExecution.prototype._activateProcess = function activateProcess(bp) {
296
296
  const handlers = this[kMessageHandlers];
297
- bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
297
+ const broker = bp.broker;
298
+ broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
298
299
  noAck: true,
299
300
  consumerTag: '_definition-outbound-message-consumer'
300
301
  });
301
- bp.broker.subscribeTmp('event', 'activity.signal', handlers.onDelegateMessage, {
302
+ const delegateEventQ = broker.assertQueue('_delegate-event-q', {
303
+ autoDelete: false,
304
+ durable: false
305
+ });
306
+ delegateEventQ.consume(handlers.onDelegateMessage, {
302
307
  noAck: true,
303
- consumerTag: '_definition-signal-consumer',
308
+ consumerTag: '_definition-signal-consumer'
309
+ });
310
+ broker.bindQueue('_delegate-event-q', 'event', 'activity.signal', {
304
311
  priority: 200
305
312
  });
306
- bp.broker.subscribeTmp('event', 'activity.message', handlers.onDelegateMessage, {
307
- noAck: true,
308
- consumerTag: '_definition-message-consumer',
313
+ broker.bindQueue('_delegate-event-q', 'event', 'activity.message', {
309
314
  priority: 200
310
315
  });
311
- bp.broker.subscribeTmp('event', 'activity.call', handlers.onCallActivity, {
316
+ broker.subscribeTmp('event', 'activity.call', handlers.onCallActivity, {
312
317
  noAck: true,
313
318
  consumerTag: '_definition-call-consumer',
314
319
  priority: 200
315
320
  });
316
- bp.broker.subscribeTmp('event', 'activity.call.cancel', handlers.onCancelCallActivity, {
321
+ broker.subscribeTmp('event', 'activity.call.cancel', handlers.onCancelCallActivity, {
317
322
  noAck: true,
318
323
  consumerTag: '_definition-call-cancel-consumer',
319
324
  priority: 200
320
325
  });
321
- bp.broker.subscribeTmp('event', '#', handlers.onChildEvent, {
326
+ broker.subscribeTmp('event', '#', handlers.onChildEvent, {
322
327
  noAck: true,
323
328
  consumerTag: '_definition-activity-consumer',
324
329
  priority: 100
@@ -351,7 +356,6 @@ DefinitionExecution.prototype._deactivateProcess = function deactivateProcess(bp
351
356
  bp.broker.cancel('_definition-outbound-message-consumer');
352
357
  bp.broker.cancel('_definition-activity-consumer');
353
358
  bp.broker.cancel('_definition-signal-consumer');
354
- bp.broker.cancel('_definition-message-consumer');
355
359
  bp.broker.cancel('_definition-call-consumer');
356
360
  bp.broker.cancel('_definition-call-cancel-consumer');
357
361
  };
@@ -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);
package/dist/index.js CHANGED
@@ -172,6 +172,12 @@ Object.defineProperty(exports, "IntermediateThrowEvent", {
172
172
  return _IntermediateThrowEvent.default;
173
173
  }
174
174
  });
175
+ Object.defineProperty(exports, "Lane", {
176
+ enumerable: true,
177
+ get: function () {
178
+ return _Lane.default;
179
+ }
180
+ });
175
181
  Object.defineProperty(exports, "LinkEventDefinition", {
176
182
  enumerable: true,
177
183
  get: function () {
@@ -365,6 +371,7 @@ var _InclusiveGateway = _interopRequireDefault(require("./gateways/InclusiveGate
365
371
  var _InputOutputSpecification = _interopRequireDefault(require("./io/InputOutputSpecification.js"));
366
372
  var _IntermediateCatchEvent = _interopRequireDefault(require("./events/IntermediateCatchEvent.js"));
367
373
  var _IntermediateThrowEvent = _interopRequireDefault(require("./events/IntermediateThrowEvent.js"));
374
+ var _Lane = _interopRequireDefault(require("./process/Lane.js"));
368
375
  var _LinkEventDefinition = _interopRequireDefault(require("./eventDefinitions/LinkEventDefinition.js"));
369
376
  var _LoopCharacteristics = _interopRequireDefault(require("./tasks/LoopCharacteristics.js"));
370
377
  var _Message = _interopRequireDefault(require("./activity/Message.js"));
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = Lane;
7
+ const kProcess = Symbol.for('process');
8
+ function Lane(process, laneDefinition) {
9
+ const {
10
+ broker,
11
+ environment
12
+ } = process;
13
+ const {
14
+ id,
15
+ type,
16
+ behaviour
17
+ } = laneDefinition;
18
+ this[kProcess] = process;
19
+ this.id = id;
20
+ this.type = type;
21
+ this.name = behaviour.name;
22
+ this.parent = {
23
+ id: process.id,
24
+ type: process.type
25
+ };
26
+ this.behaviour = {
27
+ ...behaviour
28
+ };
29
+ this.environment = environment;
30
+ this.broker = broker;
31
+ this.context = process.context;
32
+ this.logger = environment.Logger(type.toLowerCase());
33
+ }
34
+ Object.defineProperty(Lane.prototype, 'process', {
35
+ get() {
36
+ return this[kProcess];
37
+ }
38
+ });
@@ -17,6 +17,7 @@ const kCounters = Symbol.for('counters');
17
17
  const kExec = Symbol.for('execution');
18
18
  const kExecuteMessage = Symbol.for('executeMessage');
19
19
  const kExtensions = Symbol.for('extensions');
20
+ const kLanes = Symbol.for('lanes');
20
21
  const kMessageHandlers = Symbol.for('messageHandlers');
21
22
  const kStateMessage = Symbol.for('stateMessage');
22
23
  const kStatus = Symbol.for('status');
@@ -66,6 +67,9 @@ function Process(processDef, context) {
66
67
  onExecutionMessage: this._onExecutionMessage.bind(this)
67
68
  };
68
69
  this.logger = environment.Logger(type.toLowerCase());
70
+ if (behaviour.lanes) {
71
+ this[kLanes] = behaviour.lanes.map(lane => new lane.Behaviour(this, lane));
72
+ }
69
73
  this[kExtensions] = context.loadExtensions(this);
70
74
  }
71
75
  Object.defineProperty(Process.prototype, 'counters', {
@@ -76,6 +80,13 @@ Object.defineProperty(Process.prototype, 'counters', {
76
80
  };
77
81
  }
78
82
  });
83
+ Object.defineProperty(Process.prototype, 'lanes', {
84
+ enumerable: true,
85
+ get() {
86
+ const lanes = this[kLanes];
87
+ return lanes && lanes.slice();
88
+ }
89
+ });
79
90
  Object.defineProperty(Process.prototype, 'extensions', {
80
91
  enumerable: true,
81
92
  get() {
@@ -156,6 +167,19 @@ Process.prototype.resume = function resume() {
156
167
  this._activateRunConsumers();
157
168
  return this;
158
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
+ };
159
183
  Process.prototype.recover = function recover(state) {
160
184
  if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
161
185
  if (!state) return this;
@@ -192,16 +216,6 @@ Process.prototype.signal = function signal(message) {
192
216
  delegate: true
193
217
  });
194
218
  };
195
- Process.prototype.getState = function getState() {
196
- return this._createMessage({
197
- environment: this.environment.getState(),
198
- status: this.status,
199
- stopped: this.stopped,
200
- counters: this.counters,
201
- broker: this.broker.getState(true),
202
- execution: this.execution && this.execution.getState()
203
- });
204
- };
205
219
  Process.prototype.cancelActivity = function cancelActivity(message) {
206
220
  return this.getApi().cancel(message, {
207
221
  delegate: true
@@ -404,6 +418,11 @@ Process.prototype.getSequenceFlows = function getSequenceFlows() {
404
418
  if (execution) return execution.getSequenceFlows();
405
419
  return this.context.getSequenceFlows();
406
420
  };
421
+ Process.prototype.getLaneById = function getLaneById(laneId) {
422
+ const lanes = this[kLanes];
423
+ if (!lanes) return;
424
+ return lanes.find(lane => lane.id === laneId);
425
+ };
407
426
  Process.prototype.getPostponed = function getPostponed(...args) {
408
427
  const execution = this.execution;
409
428
  if (!execution) return [];
@@ -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() {
@@ -135,7 +134,7 @@ SubProcessBehaviour.prototype.recover = function recover(state) {
135
134
  executions.splice(0);
136
135
  }
137
136
  const subEnvironment = this.environment.clone().recover(state.environment);
138
- const subContext = this.context.clone(subEnvironment);
137
+ const subContext = this.context.clone(subEnvironment, this.activity);
139
138
  const execution = new _ProcessExecution.default(this.activity, subContext).recover(state);
140
139
  executions.push(execution);
141
140
  return execution;
@@ -168,7 +167,7 @@ SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(execut
168
167
  return execution;
169
168
  }
170
169
  const subEnvironment = this.environment.clone();
171
- const subContext = this.context.clone(subEnvironment);
170
+ const subContext = this.context.clone(subEnvironment, this.activity);
172
171
  execution = new _ProcessExecution.default(this.activity, subContext);
173
172
  this[kExecutions].push(execution);
174
173
  this._addListeners(execution, executionId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "10.0.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 dot",
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 dot",
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
  },
@@ -45,22 +45,23 @@
45
45
  ],
46
46
  "devDependencies": {
47
47
  "@aircall/expression-parser": "^1.0.4",
48
- "@babel/cli": "^7.21.5",
49
- "@babel/core": "^7.21.8",
50
- "@babel/preset-env": "^7.21.5",
51
- "@babel/register": "^7.21.0",
48
+ "@babel/cli": "^7.22.5",
49
+ "@babel/core": "^7.22.5",
50
+ "@babel/preset-env": "^7.22.5",
51
+ "@babel/register": "^7.22.5",
52
+ "@bonniernews/hot-bev": "^0.4.0",
52
53
  "bpmn-moddle": "^8.0.1",
53
- "c8": "^7.13.0",
54
+ "c8": "^8.0.0",
54
55
  "camunda-bpmn-moddle": "^7.0.1",
55
56
  "chai": "^4.3.7",
56
57
  "chronokinesis": "^5.0.2",
57
58
  "debug": "^4.3.4",
58
- "eslint": "^8.41.0",
59
+ "eslint": "^8.43.0",
59
60
  "eslint-plugin-import": "^2.27.5",
60
- "got": "^12.6.0",
61
+ "got": "^12.6.1",
61
62
  "mocha": "^10.1.0",
62
63
  "mocha-cakes-2": "^3.3.0",
63
- "moddle-context-serializer": "^3.2.2",
64
+ "moddle-context-serializer": "^4.0.0",
64
65
  "nock": "^13.3.1"
65
66
  },
66
67
  "dependencies": {
package/src/Context.js CHANGED
@@ -3,12 +3,14 @@ import Environment from './Environment.js';
3
3
  import ExtensionsMapper from './ExtensionsMapper.js';
4
4
  import {getUniqueId} from './shared.js';
5
5
 
6
+ const kOwner = Symbol.for('owner');
7
+
6
8
  export default function Context(definitionContext, environment) {
7
9
  environment = environment ? environment.clone() : new Environment();
8
10
  return new ContextInstance(definitionContext, environment);
9
11
  }
10
12
 
11
- function ContextInstance(definitionContext, environment) {
13
+ function ContextInstance(definitionContext, environment, owner) {
12
14
  const {id = 'Def', name, type = 'context'} = definitionContext;
13
15
  const sid = getUniqueId(id);
14
16
  this.id = id;
@@ -29,8 +31,15 @@ function ContextInstance(definitionContext, environment) {
29
31
  sequenceFlowRefs: {},
30
32
  sequenceFlows: [],
31
33
  };
34
+ this[kOwner] = owner;
32
35
  }
33
36
 
37
+ Object.defineProperty(ContextInstance.prototype, 'owner', {
38
+ get() {
39
+ return this[kOwner];
40
+ },
41
+ });
42
+
34
43
  ContextInstance.prototype.getActivityById = function getActivityById(activityId) {
35
44
  const activityInstance = this.refs.activityRefs[activityId];
36
45
  if (activityInstance) return activityInstance;
@@ -106,8 +115,8 @@ ContextInstance.prototype.upsertAssociation = function upsertAssociation(associa
106
115
  return instance;
107
116
  };
108
117
 
109
- ContextInstance.prototype.clone = function clone(newEnvironment) {
110
- return new ContextInstance(this.definitionContext, newEnvironment || this.environment);
118
+ ContextInstance.prototype.clone = function clone(newEnvironment, newOwner) {
119
+ return new ContextInstance(this.definitionContext, newEnvironment || this.environment, newOwner);
111
120
  };
112
121
 
113
122
  ContextInstance.prototype.getProcessById = function getProcessById(processId) {
@@ -120,6 +129,8 @@ ContextInstance.prototype.getProcessById = function getProcessById(processId) {
120
129
 
121
130
  const bpContext = this.clone(this.environment.clone());
122
131
  bp = refs[processId] = new processDefinition.Behaviour(processDefinition, bpContext);
132
+ bpContext[kOwner] = bp;
133
+
123
134
  this.refs.processes.push(bp);
124
135
 
125
136
  return bp;
@@ -128,7 +139,11 @@ ContextInstance.prototype.getProcessById = function getProcessById(processId) {
128
139
  ContextInstance.prototype.getNewProcessById = function getNewProcessById(processId) {
129
140
  if (!this.getProcessById(processId)) return null;
130
141
  const bpDef = this.definitionContext.getProcessById(processId);
131
- const bp = new bpDef.Behaviour(bpDef, this.clone(this.environment.clone()));
142
+
143
+ const bpContext = this.clone(this.environment.clone());
144
+ const bp = new bpDef.Behaviour(bpDef, bpContext);
145
+ bpContext[kOwner] = bp;
146
+
132
147
  return bp;
133
148
  };
134
149
 
@@ -201,3 +216,11 @@ ContextInstance.prototype.loadExtensions = function loadExtensions(activity) {
201
216
  if (!extensions.extensions.length) return;
202
217
  return extensions;
203
218
  };
219
+
220
+ ContextInstance.prototype.getActivityParentById = function getActivityParentById(activityId) {
221
+ const owner = this[kOwner];
222
+ if (owner) return owner;
223
+ const activity = this.getActivityById(activityId);
224
+ const parentId = activity.parent.id;
225
+ return this.getProcessById(parentId) || this.getActivityById(parentId);
226
+ };
@@ -87,6 +87,7 @@ function Activity(Behaviour, activityDef, context) {
87
87
  isTransaction: activityDef.isTransaction,
88
88
  isParallelJoin,
89
89
  isThrowing: activityDef.isThrowing,
90
+ lane: activityDef.lane && activityDef.lane.id,
90
91
  };
91
92
  this[kExec] = {};
92
93
 
@@ -235,6 +236,16 @@ Object.defineProperty(Activity.prototype, 'attachedTo', {
235
236
  },
236
237
  });
237
238
 
239
+ Object.defineProperty(Activity.prototype, 'lane', {
240
+ enumerable: true,
241
+ get() {
242
+ const laneId = this[kFlags].lane;
243
+ if (!laneId) return undefined;
244
+ const parent = this.parentElement;
245
+ return parent.getLaneById && parent.getLaneById(laneId);
246
+ },
247
+ });
248
+
238
249
  Object.defineProperty(Activity.prototype, 'eventDefinitions', {
239
250
  enumerable: true,
240
251
  get() {
@@ -242,6 +253,13 @@ Object.defineProperty(Activity.prototype, 'eventDefinitions', {
242
253
  },
243
254
  });
244
255
 
256
+ Object.defineProperty(Activity.prototype, 'parentElement', {
257
+ enumerable: true,
258
+ get() {
259
+ return this.context.getActivityParentById(this.id);
260
+ },
261
+ });
262
+
245
263
  Activity.prototype.activate = function activate() {
246
264
  this[kActivated] = true;
247
265
  this.addInboundListeners();
@@ -283,6 +301,21 @@ Activity.prototype.run = function run(runContent) {
283
301
  this._consumeRunQ();
284
302
  };
285
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
+
286
319
  Activity.prototype.recover = function recover(state) {
287
320
  if (this.isRunning) throw new Error(`cannot recover running activity <${this.id}>`);
288
321
  if (!state) return;
@@ -371,21 +404,6 @@ Activity.prototype.evaluateOutbound = function evaluateOutbound(fromMessage, dis
371
404
  return this[kFlows].outboundEvaluator.evaluate(fromMessage, discardRestAtTake, callback);
372
405
  };
373
406
 
374
- Activity.prototype.getState = function getState() {
375
- const msg = this._createMessage();
376
-
377
- const exec = this[kExec];
378
- return {
379
- ...msg,
380
- executionId: exec.executionId,
381
- stopped: this.stopped,
382
- behaviour: {...this.behaviour},
383
- counters: this.counters,
384
- broker: this.broker.getState(true),
385
- execution: exec.execution && exec.execution.getState(),
386
- };
387
- };
388
-
389
407
  Activity.prototype.getApi = function getApi(message) {
390
408
  const execution = this[kExec].execution;
391
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();
@@ -322,32 +322,29 @@ DefinitionExecution.prototype._activate = function activate(processList) {
322
322
 
323
323
  DefinitionExecution.prototype._activateProcess = function activateProcess(bp) {
324
324
  const handlers = this[kMessageHandlers];
325
+ const broker = bp.broker;
325
326
 
326
- bp.broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
327
+ broker.subscribeTmp('message', 'message.outbound', handlers.onMessageOutbound, {
327
328
  noAck: true,
328
329
  consumerTag: '_definition-outbound-message-consumer',
329
330
  });
330
- bp.broker.subscribeTmp('event', 'activity.signal', handlers.onDelegateMessage, {
331
- noAck: true,
332
- consumerTag: '_definition-signal-consumer',
333
- priority: 200,
334
- });
335
- bp.broker.subscribeTmp('event', 'activity.message', handlers.onDelegateMessage, {
336
- noAck: true,
337
- consumerTag: '_definition-message-consumer',
338
- priority: 200,
339
- });
340
- bp.broker.subscribeTmp('event', 'activity.call', handlers.onCallActivity, {
331
+
332
+ const delegateEventQ = broker.assertQueue('_delegate-event-q', {autoDelete: false, durable: false});
333
+ delegateEventQ.consume(handlers.onDelegateMessage, {noAck: true, consumerTag: '_definition-signal-consumer'});
334
+ broker.bindQueue('_delegate-event-q', 'event', 'activity.signal', {priority: 200});
335
+ broker.bindQueue('_delegate-event-q', 'event', 'activity.message', {priority: 200});
336
+
337
+ broker.subscribeTmp('event', 'activity.call', handlers.onCallActivity, {
341
338
  noAck: true,
342
339
  consumerTag: '_definition-call-consumer',
343
340
  priority: 200,
344
341
  });
345
- bp.broker.subscribeTmp('event', 'activity.call.cancel', handlers.onCancelCallActivity, {
342
+ broker.subscribeTmp('event', 'activity.call.cancel', handlers.onCancelCallActivity, {
346
343
  noAck: true,
347
344
  consumerTag: '_definition-call-cancel-consumer',
348
345
  priority: 200,
349
346
  });
350
- bp.broker.subscribeTmp('event', '#', handlers.onChildEvent, {
347
+ broker.subscribeTmp('event', '#', handlers.onChildEvent, {
351
348
  noAck: true,
352
349
  consumerTag: '_definition-activity-consumer',
353
350
  priority: 100,
@@ -383,7 +380,6 @@ DefinitionExecution.prototype._deactivateProcess = function deactivateProcess(bp
383
380
  bp.broker.cancel('_definition-outbound-message-consumer');
384
381
  bp.broker.cancel('_definition-activity-consumer');
385
382
  bp.broker.cancel('_definition-signal-consumer');
386
- bp.broker.cancel('_definition-message-consumer');
387
383
  bp.broker.cancel('_definition-call-consumer');
388
384
  bp.broker.cancel('_definition-call-cancel-consumer');
389
385
  };
@@ -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) {
package/src/index.js CHANGED
@@ -23,6 +23,7 @@ import InclusiveGateway from './gateways/InclusiveGateway.js';
23
23
  import InputOutputSpecification from './io/InputOutputSpecification.js';
24
24
  import IntermediateCatchEvent from './events/IntermediateCatchEvent.js';
25
25
  import IntermediateThrowEvent from './events/IntermediateThrowEvent.js';
26
+ import Lane from './process/Lane.js';
26
27
  import LinkEventDefinition from './eventDefinitions/LinkEventDefinition.js';
27
28
  import LoopCharacteristics from './tasks/LoopCharacteristics.js';
28
29
  import Message from './activity/Message.js';
@@ -82,6 +83,7 @@ export {
82
83
  Message,
83
84
  MessageEventDefinition,
84
85
  MessageFlow,
86
+ Lane,
85
87
  LoopCharacteristics as MultiInstanceLoopCharacteristics,
86
88
  ParallelGateway,
87
89
  Process,
@@ -0,0 +1,27 @@
1
+ const kProcess = Symbol.for('process');
2
+
3
+ export default function Lane(process, laneDefinition) {
4
+ const {broker, environment} = process;
5
+ const {id, type, behaviour} = laneDefinition;
6
+
7
+ this[kProcess] = process;
8
+
9
+ this.id = id;
10
+ this.type = type;
11
+ this.name = behaviour.name;
12
+ this.parent = {
13
+ id: process.id,
14
+ type: process.type,
15
+ };
16
+ this.behaviour = {...behaviour};
17
+ this.environment = environment;
18
+ this.broker = broker;
19
+ this.context = process.context;
20
+ this.logger = environment.Logger(type.toLowerCase());
21
+ }
22
+
23
+ Object.defineProperty(Lane.prototype, 'process', {
24
+ get() {
25
+ return this[kProcess];
26
+ },
27
+ });
@@ -10,6 +10,7 @@ const kCounters = Symbol.for('counters');
10
10
  const kExec = Symbol.for('execution');
11
11
  const kExecuteMessage = Symbol.for('executeMessage');
12
12
  const kExtensions = Symbol.for('extensions');
13
+ const kLanes = Symbol.for('lanes');
13
14
  const kMessageHandlers = Symbol.for('messageHandlers');
14
15
  const kStateMessage = Symbol.for('stateMessage');
15
16
  const kStatus = Symbol.for('status');
@@ -53,6 +54,9 @@ export function Process(processDef, context) {
53
54
 
54
55
  this.logger = environment.Logger(type.toLowerCase());
55
56
 
57
+ if (behaviour.lanes) {
58
+ this[kLanes] = behaviour.lanes.map((lane) => new lane.Behaviour(this, lane));
59
+ }
56
60
  this[kExtensions] = context.loadExtensions(this);
57
61
  }
58
62
 
@@ -63,6 +67,14 @@ Object.defineProperty(Process.prototype, 'counters', {
63
67
  },
64
68
  });
65
69
 
70
+ Object.defineProperty(Process.prototype, 'lanes', {
71
+ enumerable: true,
72
+ get() {
73
+ const lanes = this[kLanes];
74
+ return lanes && lanes.slice();
75
+ },
76
+ });
77
+
66
78
  Object.defineProperty(Process.prototype, 'extensions', {
67
79
  enumerable: true,
68
80
  get() {
@@ -149,6 +161,20 @@ Process.prototype.resume = function resume() {
149
161
  return this;
150
162
  };
151
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
+
152
178
  Process.prototype.recover = function recover(state) {
153
179
  if (this.isRunning) throw new Error(`cannot recover running process <${this.id}>`);
154
180
  if (!state) return this;
@@ -189,17 +215,6 @@ Process.prototype.signal = function signal(message) {
189
215
  return this.getApi().signal(message, {delegate: true});
190
216
  };
191
217
 
192
- Process.prototype.getState = function getState() {
193
- return this._createMessage({
194
- environment: this.environment.getState(),
195
- status: this.status,
196
- stopped: this.stopped,
197
- counters: this.counters,
198
- broker: this.broker.getState(true),
199
- execution: this.execution && this.execution.getState(),
200
- });
201
- };
202
-
203
218
  Process.prototype.cancelActivity = function cancelActivity(message) {
204
219
  return this.getApi().cancel(message, {delegate: true});
205
220
  };
@@ -399,6 +414,12 @@ Process.prototype.getSequenceFlows = function getSequenceFlows() {
399
414
  return this.context.getSequenceFlows();
400
415
  };
401
416
 
417
+ Process.prototype.getLaneById = function getLaneById(laneId) {
418
+ const lanes = this[kLanes];
419
+ if (!lanes) return;
420
+ return lanes.find((lane) => lane.id === laneId);
421
+ };
422
+
402
423
  Process.prototype.getPostponed = function getPostponed(...args) {
403
424
  const execution = this.execution;
404
425
  if (!execution) return [];
@@ -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
 
@@ -135,7 +133,7 @@ SubProcessBehaviour.prototype.recover = function recover(state) {
135
133
  }
136
134
 
137
135
  const subEnvironment = this.environment.clone().recover(state.environment);
138
- const subContext = this.context.clone(subEnvironment);
136
+ const subContext = this.context.clone(subEnvironment, this.activity);
139
137
 
140
138
  const execution = new ProcessExecution(this.activity, subContext).recover(state);
141
139
 
@@ -176,7 +174,7 @@ SubProcessBehaviour.prototype._upsertExecution = function upsertExecution(execut
176
174
  }
177
175
 
178
176
  const subEnvironment = this.environment.clone();
179
- const subContext = this.context.clone(subEnvironment);
177
+ const subContext = this.context.clone(subEnvironment, this.activity);
180
178
 
181
179
  execution = new ProcessExecution(this.activity, subContext);
182
180
  this[kExecutions].push(execution);
package/types/index.d.ts CHANGED
@@ -288,6 +288,8 @@ declare module 'bpmn-elements' {
288
288
  get sid(): string;
289
289
  get definitionContext(): SerializableContext;
290
290
  get environment(): Environment;
291
+ /** Context owner, Process or SubProcess activity */
292
+ get owner(): Process | Activity | undefined;
291
293
  getActivityById<T>(activityId: string): T;
292
294
  getSequenceFlowById(sequenceFlowId: string): SequenceFlow;
293
295
  getInboundSequenceFlows(activityId: string): SequenceFlow[];
@@ -429,6 +431,7 @@ declare module 'bpmn-elements' {
429
431
  constructor(processDef: SerializableElement, context: Context);
430
432
  get isExecutable(): boolean;
431
433
  get counters(): completedCounters;
434
+ get lanes(): Lane[] | undefined;
432
435
  get extensions(): IExtension;
433
436
  get stopped(): boolean;
434
437
  get isRunning(): boolean;
@@ -448,6 +451,7 @@ declare module 'bpmn-elements' {
448
451
  getActivities(): Activity[];
449
452
  getStartActivities(filterOptions?: startActivityFilterOptions): Activity[];
450
453
  getSequenceFlows(): SequenceFlow[];
454
+ getLaneById(laneId: string): Lane | undefined;
451
455
  getPostponed(filterFn: filterPostponed): Api<ElementBase>[];
452
456
  }
453
457
 
@@ -471,6 +475,24 @@ declare module 'bpmn-elements' {
471
475
  getApi(message?: ElementBrokerMessage): Api<ElementBase>;
472
476
  }
473
477
 
478
+ class Lane extends ElementBase {
479
+ constructor(process: Process, laneDefinition: SerializableElement);
480
+ /** Process broker */
481
+ get broker(): Broker;
482
+ get process(): Process;
483
+ }
484
+
485
+ interface ISequenceFlowCondition {
486
+ /** Condition type, e.g. script or expression */
487
+ get type(): string;
488
+ /**
489
+ * Execute sequence flow condition
490
+ * @param message Source element execution message
491
+ * @param callback Callback with truthy result if flow should be taken
492
+ */
493
+ execute(message: ElementBrokerMessage, callback: (err: Error, result: any) => void): void;
494
+ }
495
+
474
496
  class SequenceFlow extends Element<SequenceFlow> {
475
497
  get sourceId(): string;
476
498
  get targetId(): string;
@@ -480,7 +502,7 @@ declare module 'bpmn-elements' {
480
502
  take(content?: any): boolean;
481
503
  discard(content?: any): void;
482
504
  shake(message: any): number;
483
- getCondition(): any;
505
+ getCondition(): ISequenceFlowCondition | null;
484
506
  createMessage(override?: any): object;
485
507
  /**
486
508
  * Evaluate flow
@@ -496,6 +518,7 @@ declare module 'bpmn-elements' {
496
518
  get id(): string;
497
519
  get processId(): string;
498
520
  }
521
+
499
522
  class MessageFlow extends Element<MessageFlow> {
500
523
  get source(): MessageFlowReference;
501
524
  get target(): MessageFlowReference;
@@ -596,6 +619,8 @@ declare module 'bpmn-elements' {
596
619
  get triggeredByEvent(): boolean;
597
620
  get attachedTo(): Activity;
598
621
  get eventDefinitions(): EventDefinition[];
622
+ /** Parent element process or sub process reference */
623
+ get parentElement(): Process | Activity;
599
624
  activate(): void;
600
625
  deactivate(): void;
601
626
  init(initContent?: any): void;