bpmn-elements 17.2.2 → 18.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 (155) hide show
  1. package/README.md +3 -1
  2. package/dist/Api.js +83 -0
  3. package/dist/Context.js +228 -22
  4. package/dist/Environment.js +111 -31
  5. package/dist/EventBroker.js +57 -1
  6. package/dist/Expressions.js +3 -4
  7. package/dist/MessageFormatter.js +29 -16
  8. package/dist/Timers.js +13 -9
  9. package/dist/Tracker.js +1 -0
  10. package/dist/activity/Activity.js +458 -254
  11. package/dist/activity/ActivityExecution.js +113 -40
  12. package/dist/activity/Dummy.js +6 -1
  13. package/dist/activity/Escalation.js +36 -24
  14. package/dist/activity/ExecutionScope.js +1 -1
  15. package/dist/activity/Message.js +36 -24
  16. package/dist/activity/Signal.js +36 -24
  17. package/dist/activity/outbound-evaluator.js +1 -1
  18. package/dist/condition.js +12 -6
  19. package/dist/constants.js +21 -0
  20. package/dist/definition/Definition.js +182 -64
  21. package/dist/definition/DefinitionExecution.js +195 -82
  22. package/dist/error/BpmnError.js +12 -1
  23. package/dist/error/Errors.js +50 -9
  24. package/dist/eventDefinitions/CancelEventDefinition.js +29 -11
  25. package/dist/eventDefinitions/CompensateEventDefinition.js +51 -31
  26. package/dist/eventDefinitions/ConditionalEventDefinition.js +21 -9
  27. package/dist/eventDefinitions/ErrorEventDefinition.js +46 -30
  28. package/dist/eventDefinitions/EscalationEventDefinition.js +44 -27
  29. package/dist/eventDefinitions/EventDefinitionExecution.js +30 -23
  30. package/dist/eventDefinitions/LinkEventDefinition.js +45 -120
  31. package/dist/eventDefinitions/MessageEventDefinition.js +44 -29
  32. package/dist/eventDefinitions/SignalEventDefinition.js +46 -31
  33. package/dist/eventDefinitions/TerminateEventDefinition.js +10 -1
  34. package/dist/eventDefinitions/TimerEventDefinition.js +57 -37
  35. package/dist/eventDefinitions/index.js +20 -21
  36. package/dist/events/BoundaryEvent.js +52 -40
  37. package/dist/events/EndEvent.js +22 -8
  38. package/dist/events/IntermediateCatchEvent.js +26 -8
  39. package/dist/events/IntermediateThrowEvent.js +24 -9
  40. package/dist/events/StartEvent.js +30 -14
  41. package/dist/events/index.js +10 -11
  42. package/dist/flows/Association.js +50 -7
  43. package/dist/flows/MessageFlow.js +49 -10
  44. package/dist/flows/SequenceFlow.js +93 -22
  45. package/dist/flows/index.js +6 -7
  46. package/dist/gateways/EventBasedGateway.js +29 -15
  47. package/dist/gateways/ExclusiveGateway.js +20 -5
  48. package/dist/gateways/InclusiveGateway.js +21 -5
  49. package/dist/gateways/ParallelGateway.js +253 -15
  50. package/dist/gateways/index.js +8 -9
  51. package/dist/getPropertyValue.js +2 -2
  52. package/dist/index.js +42 -43
  53. package/dist/io/BpmnIO.js +15 -1
  54. package/dist/io/EnvironmentDataObject.js +29 -1
  55. package/dist/io/EnvironmentDataStore.js +24 -1
  56. package/dist/io/EnvironmentDataStoreReference.js +24 -1
  57. package/dist/io/InputOutputSpecification.js +21 -11
  58. package/dist/io/Properties.js +28 -17
  59. package/dist/messageHelper.js +41 -4
  60. package/dist/process/Lane.js +15 -4
  61. package/dist/process/Process.js +174 -76
  62. package/dist/process/ProcessExecution.js +362 -177
  63. package/dist/shared.js +2 -0
  64. package/dist/tasks/CallActivity.js +19 -4
  65. package/dist/tasks/LoopCharacteristics.js +94 -9
  66. package/dist/tasks/ReceiveTask.js +36 -21
  67. package/dist/tasks/ScriptTask.js +22 -6
  68. package/dist/tasks/ServiceImplementation.js +7 -4
  69. package/dist/tasks/ServiceTask.js +19 -4
  70. package/dist/tasks/SignalTask.js +19 -4
  71. package/dist/tasks/StandardLoopCharacteristics.js +8 -4
  72. package/dist/tasks/SubProcess.js +44 -29
  73. package/dist/tasks/Task.js +19 -4
  74. package/dist/tasks/Transaction.js +8 -4
  75. package/dist/tasks/index.js +16 -18
  76. package/package.json +31 -13
  77. package/src/Api.js +70 -0
  78. package/src/Context.js +200 -19
  79. package/src/Environment.js +99 -30
  80. package/src/EventBroker.js +46 -1
  81. package/src/Expressions.js +2 -3
  82. package/src/MessageFormatter.js +24 -16
  83. package/src/Timers.js +12 -9
  84. package/src/Tracker.js +1 -0
  85. package/src/activity/Activity.js +388 -231
  86. package/src/activity/ActivityExecution.js +93 -42
  87. package/src/activity/Dummy.js +6 -1
  88. package/src/activity/Escalation.js +25 -18
  89. package/src/activity/ExecutionScope.js +1 -1
  90. package/src/activity/Message.js +25 -18
  91. package/src/activity/Signal.js +25 -18
  92. package/src/activity/outbound-evaluator.js +1 -1
  93. package/src/condition.js +11 -5
  94. package/src/constants.js +15 -0
  95. package/src/definition/Definition.js +157 -62
  96. package/src/definition/DefinitionExecution.js +161 -83
  97. package/src/error/BpmnError.js +11 -1
  98. package/src/error/Errors.js +44 -5
  99. package/src/eventDefinitions/CancelEventDefinition.js +27 -13
  100. package/src/eventDefinitions/CompensateEventDefinition.js +48 -32
  101. package/src/eventDefinitions/ConditionalEventDefinition.js +20 -10
  102. package/src/eventDefinitions/ErrorEventDefinition.js +44 -33
  103. package/src/eventDefinitions/EscalationEventDefinition.js +39 -26
  104. package/src/eventDefinitions/EventDefinitionExecution.js +30 -24
  105. package/src/eventDefinitions/LinkEventDefinition.js +34 -120
  106. package/src/eventDefinitions/MessageEventDefinition.js +42 -31
  107. package/src/eventDefinitions/SignalEventDefinition.js +43 -32
  108. package/src/eventDefinitions/TerminateEventDefinition.js +9 -1
  109. package/src/eventDefinitions/TimerEventDefinition.js +53 -35
  110. package/src/eventDefinitions/index.js +10 -23
  111. package/src/events/BoundaryEvent.js +50 -39
  112. package/src/events/EndEvent.js +19 -7
  113. package/src/events/IntermediateCatchEvent.js +24 -8
  114. package/src/events/IntermediateThrowEvent.js +24 -8
  115. package/src/events/StartEvent.js +25 -14
  116. package/src/events/index.js +5 -18
  117. package/src/flows/Association.js +43 -9
  118. package/src/flows/MessageFlow.js +41 -10
  119. package/src/flows/SequenceFlow.js +82 -19
  120. package/src/flows/index.js +3 -4
  121. package/src/gateways/EventBasedGateway.js +27 -15
  122. package/src/gateways/ExclusiveGateway.js +16 -3
  123. package/src/gateways/InclusiveGateway.js +16 -3
  124. package/src/gateways/ParallelGateway.js +301 -10
  125. package/src/gateways/index.js +4 -4
  126. package/src/getPropertyValue.js +2 -2
  127. package/src/index.js +19 -19
  128. package/src/io/BpmnIO.js +13 -1
  129. package/src/io/EnvironmentDataObject.js +26 -1
  130. package/src/io/EnvironmentDataStore.js +22 -1
  131. package/src/io/EnvironmentDataStoreReference.js +22 -1
  132. package/src/io/InputOutputSpecification.js +17 -8
  133. package/src/io/Properties.js +23 -13
  134. package/src/messageHelper.js +36 -4
  135. package/src/process/Lane.js +14 -4
  136. package/src/process/Process.js +154 -72
  137. package/src/process/ProcessExecution.js +326 -175
  138. package/src/shared.js +1 -0
  139. package/src/tasks/CallActivity.js +16 -2
  140. package/src/tasks/LoopCharacteristics.js +77 -11
  141. package/src/tasks/ReceiveTask.js +33 -22
  142. package/src/tasks/ScriptTask.js +17 -3
  143. package/src/tasks/ServiceImplementation.js +6 -3
  144. package/src/tasks/ServiceTask.js +16 -2
  145. package/src/tasks/SignalTask.js +16 -2
  146. package/src/tasks/StandardLoopCharacteristics.js +7 -3
  147. package/src/tasks/SubProcess.js +37 -23
  148. package/src/tasks/Task.js +16 -2
  149. package/src/tasks/Transaction.js +7 -3
  150. package/src/tasks/index.js +8 -9
  151. package/types/bundle-errors.d.ts +1 -0
  152. package/types/bundle.d.ts +97 -0
  153. package/types/index.d.ts +2614 -84
  154. package/types/interfaces.d.ts +636 -0
  155. package/types/types.d.ts +0 -765
@@ -3,7 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = EnvironmentDataStore;
6
+ exports.EnvironmentDataStore = EnvironmentDataStore;
7
+ /**
8
+ * Builtin data store. Reads from / writes to `environment.variables._data`.
9
+ * @param {import('moddle-context-serializer').DataStore} dataStoreDef
10
+ * @param {import('#types').ContextInstance} context
11
+ * @satisfies {import('#types').IIOData}
12
+ */
7
13
  function EnvironmentDataStore(dataStoreDef, {
8
14
  environment
9
15
  }) {
@@ -17,16 +23,33 @@ function EnvironmentDataStore(dataStoreDef, {
17
23
  this.id = id;
18
24
  this.type = type;
19
25
  this.name = name;
26
+ /** @type {Record<string, any>} */
20
27
  this.behaviour = behaviour;
28
+ /** @type {import('moddle-context-serializer').Parent | undefined} */
21
29
  this.parent = parent;
22
30
  this.environment = environment;
23
31
  }
32
+
33
+ /**
34
+ * @param {import('smqp').Broker} broker
35
+ * @param {string} exchange
36
+ * @param {string} routingKeyPrefix
37
+ * @param {Record<string, any>} [messageProperties]
38
+ */
24
39
  EnvironmentDataStore.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
25
40
  const environment = this.environment;
26
41
  const value = environment.variables._data?.[this.id];
27
42
  const content = this._createContent(value);
28
43
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
29
44
  };
45
+
46
+ /**
47
+ * @param {import('smqp').Broker} broker
48
+ * @param {string} exchange
49
+ * @param {string} routingKeyPrefix
50
+ * @param {any} value
51
+ * @param {Record<string, any>} [messageProperties]
52
+ */
30
53
  EnvironmentDataStore.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
31
54
  const environment = this.environment;
32
55
  environment.variables._data = environment.variables._data || {};
@@ -3,7 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = EnvironmentDataStoreReference;
6
+ exports.EnvironmentDataStoreReference = EnvironmentDataStoreReference;
7
+ /**
8
+ * Builtin data store reference. Reads from / writes to `environment.variables._data`.
9
+ * @param {import('moddle-context-serializer').DataStore} dataObjectDef
10
+ * @param {import('#types').ContextInstance} context
11
+ * @satisfies {import('#types').IIOData}
12
+ */
7
13
  function EnvironmentDataStoreReference(dataObjectDef, {
8
14
  environment
9
15
  }) {
@@ -17,16 +23,33 @@ function EnvironmentDataStoreReference(dataObjectDef, {
17
23
  this.id = id;
18
24
  this.type = type;
19
25
  this.name = name;
26
+ /** @type {Record<string, any>} */
20
27
  this.behaviour = behaviour;
28
+ /** @type {import('moddle-context-serializer').Parent | undefined} */
21
29
  this.parent = parent;
22
30
  this.environment = environment;
23
31
  }
32
+
33
+ /**
34
+ * @param {import('smqp').Broker} broker
35
+ * @param {string} exchange
36
+ * @param {string} routingKeyPrefix
37
+ * @param {Record<string, any>} [messageProperties]
38
+ */
24
39
  EnvironmentDataStoreReference.prototype.read = function read(broker, exchange, routingKeyPrefix, messageProperties) {
25
40
  const environment = this.environment;
26
41
  const value = environment.variables._data?.[this.id];
27
42
  const content = this._createContent(value);
28
43
  return broker.publish(exchange, `${routingKeyPrefix}response`, content, messageProperties);
29
44
  };
45
+
46
+ /**
47
+ * @param {import('smqp').Broker} broker
48
+ * @param {string} exchange
49
+ * @param {string} routingKeyPrefix
50
+ * @param {any} value
51
+ * @param {Record<string, any>} [messageProperties]
52
+ */
30
53
  EnvironmentDataStoreReference.prototype.write = function write(broker, exchange, routingKeyPrefix, value, messageProperties) {
31
54
  const environment = this.environment;
32
55
  environment.variables._data = environment.variables._data || {};
@@ -3,11 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = IoSpecification;
7
- var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue.js"));
6
+ exports.IoSpecification = IoSpecification;
7
+ var _getPropertyValue = require("../getPropertyValue.js");
8
8
  var _shared = require("../shared.js");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- const kConsuming = Symbol.for('consuming');
9
+ var _constants = require("../constants.js");
10
+ /**
11
+ * Activity ioSpecification behaviour. Reads bound data objects on enter and writes them on completion.
12
+ * @param {import('#types').Activity} activity
13
+ * @param {import('moddle-context-serializer').IoSpecification} ioSpecificationDef
14
+ * @param {import('#types').ContextInstance} context
15
+ * @satisfies {import('#types').IExtension}
16
+ */
11
17
  function IoSpecification(activity, ioSpecificationDef, context) {
12
18
  const {
13
19
  id,
@@ -21,20 +27,24 @@ function IoSpecification(activity, ioSpecificationDef, context) {
21
27
  this.broker = activity.broker;
22
28
  this.context = context;
23
29
  }
30
+
31
+ /**
32
+ * @param {import('#types').ElementBrokerMessage} [message]
33
+ */
24
34
  IoSpecification.prototype.activate = function activate(message) {
25
- if (this[kConsuming]) return;
35
+ if (this[_constants.K_CONSUMING]) return;
26
36
  if (message?.fields.redelivered && message.fields.routingKey === 'run.start') {
27
37
  this._onFormatEnter();
28
38
  }
29
39
  if (message?.fields.redelivered && message.fields.routingKey === 'run.end') {
30
40
  this._onFormatComplete(message);
31
41
  }
32
- this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
42
+ this[_constants.K_CONSUMING] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
33
43
  noAck: true
34
44
  });
35
45
  };
36
46
  IoSpecification.prototype.deactivate = function deactivate() {
37
- if (this[kConsuming]) this[kConsuming] = this[kConsuming].cancel();
47
+ if (this[_constants.K_CONSUMING]) this[_constants.K_CONSUMING] = this[_constants.K_CONSUMING].cancel();
38
48
  };
39
49
  IoSpecification.prototype._onActivityEvent = function onActivityEvent(routingKey, message) {
40
50
  const {
@@ -73,7 +83,7 @@ IoSpecification.prototype._onFormatEnter = function onFormatOnEnter() {
73
83
  name: ioSource.name
74
84
  };
75
85
  result.sources.push(source);
76
- const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.source.dataObject.id');
86
+ const dataObjectId = (0, _getPropertyValue.getPropertyValue)(ioSource, 'behaviour.association.source.dataObject.id');
77
87
  if (!dataObjectId) return result;
78
88
  const dataObject = this.context.getDataObjectById(dataObjectId);
79
89
  if (!dataObject) return result;
@@ -118,8 +128,8 @@ IoSpecification.prototype._onFormatEnter = function onFormatOnEnter() {
118
128
  };
119
129
  IoSpecification.prototype._onFormatComplete = function formatOnComplete(message) {
120
130
  const safeType = (0, _shared.brokerSafeId)(this.type).toLowerCase();
121
- const messageInputs = (0, _getPropertyValue.default)(message, 'content.ioSpecification.dataInputs');
122
- const messageOutputs = (0, _getPropertyValue.default)(message, 'content.output.ioSpecification.dataOutputs') || [];
131
+ const messageInputs = (0, _getPropertyValue.getPropertyValue)(message, 'content.ioSpecification.dataInputs');
132
+ const messageOutputs = (0, _getPropertyValue.getPropertyValue)(message, 'content.output.ioSpecification.dataOutputs') || [];
123
133
  const dataOutputs = this.behaviour.dataOutputs;
124
134
  const broker = this.broker;
125
135
  const context = this.context;
@@ -137,7 +147,7 @@ IoSpecification.prototype._onFormatComplete = function formatOnComplete(message)
137
147
  value
138
148
  };
139
149
  result.sources.push(source);
140
- const dataObjectId = (0, _getPropertyValue.default)(ioSource, 'behaviour.association.target.dataObject.id');
150
+ const dataObjectId = (0, _getPropertyValue.getPropertyValue)(ioSource, 'behaviour.association.target.dataObject.id');
141
151
  if (!dataObjectId) return result;
142
152
  const dataObject = context.getDataObjectById(dataObjectId);
143
153
  if (!dataObject) return result;
@@ -3,15 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Properties;
7
- var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue.js"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- const kProperties = Symbol.for('properties');
10
- const kConsuming = Symbol.for('consuming');
6
+ exports.Properties = Properties;
7
+ var _getPropertyValue = require("../getPropertyValue.js");
8
+ var _constants = require("../constants.js");
9
+ const K_PROPERTIES = Symbol.for('properties');
10
+
11
+ /**
12
+ * Activity properties behaviour. Resolves bound data input/output references during the run.
13
+ * @param {import('#types').Activity} activity
14
+ * @param {{ type: 'properties', values: import('moddle-context-serializer').IElement[] }} propertiesDef
15
+ * @param {import('#types').ContextInstance} context
16
+ * @satisfies {import('#types').IExtension}
17
+ */
11
18
  function Properties(activity, propertiesDef, context) {
12
19
  this.activity = activity;
13
20
  this.broker = activity.broker;
14
- const props = this[kProperties] = {
21
+ const props = this[K_PROPERTIES] = {
15
22
  properties: new Set(),
16
23
  dataInputObjects: new Set(),
17
24
  dataOutputObjects: new Set()
@@ -26,10 +33,10 @@ function Properties(activity, propertiesDef, context) {
26
33
  name: def.behaviour?.name
27
34
  };
28
35
  props.properties.add(source);
29
- const inputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataObject.id');
30
- const outputDataObjectId = (0, _getPropertyValue.default)(def, 'behaviour.dataOutput.association.target.dataObject.id');
31
- const inputDataStoreId = (0, _getPropertyValue.default)(def, 'behaviour.dataInput.association.source.dataStore.id');
32
- const outputDataStoreId = (0, _getPropertyValue.default)(def, 'behaviour.dataOutput.association.target.dataStore.id');
36
+ const inputDataObjectId = (0, _getPropertyValue.getPropertyValue)(def, 'behaviour.dataInput.association.source.dataObject.id');
37
+ const outputDataObjectId = (0, _getPropertyValue.getPropertyValue)(def, 'behaviour.dataOutput.association.target.dataObject.id');
38
+ const inputDataStoreId = (0, _getPropertyValue.getPropertyValue)(def, 'behaviour.dataInput.association.source.dataStore.id');
39
+ const outputDataStoreId = (0, _getPropertyValue.getPropertyValue)(def, 'behaviour.dataOutput.association.target.dataStore.id');
33
40
  if (inputDataObjectId) {
34
41
  const reference = context.getDataObjectById(inputDataObjectId);
35
42
  props.dataInputObjects.add({
@@ -72,20 +79,24 @@ function Properties(activity, propertiesDef, context) {
72
79
  }
73
80
  }
74
81
  }
82
+
83
+ /**
84
+ * @param {import('#types').ElementBrokerMessage} message
85
+ */
75
86
  Properties.prototype.activate = function activate(message) {
76
- if (this[kConsuming]) return;
87
+ if (this[_constants.K_CONSUMING]) return;
77
88
  if (message.fields.redelivered && message.fields.routingKey === 'run.start') {
78
89
  this._onActivityEvent('activity.enter', message);
79
90
  }
80
91
  if (message.fields.redelivered && message.content.properties) {
81
92
  this._onActivityEvent('activity.extension.resume', message);
82
93
  }
83
- this[kConsuming] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
94
+ this[_constants.K_CONSUMING] = this.broker.subscribeTmp('event', 'activity.#', this._onActivityEvent.bind(this), {
84
95
  noAck: true
85
96
  });
86
97
  };
87
98
  Properties.prototype.deactivate = function deactivate() {
88
- if (this[kConsuming]) this[kConsuming] = this[kConsuming].cancel();
99
+ if (this[_constants.K_CONSUMING]) this[_constants.K_CONSUMING] = this[_constants.K_CONSUMING].cancel();
89
100
  };
90
101
  Properties.prototype._onActivityEvent = function onActivityEvent(routingKey, message) {
91
102
  switch (routingKey) {
@@ -98,7 +109,7 @@ Properties.prototype._onActivityEvent = function onActivityEvent(routingKey, mes
98
109
  };
99
110
  Properties.prototype._formatOnEnter = function formatOnEnter(message) {
100
111
  const startRoutingKey = 'run.enter.bpmn-properties';
101
- const dataInputObjects = this[kProperties].dataInputObjects;
112
+ const dataInputObjects = this[K_PROPERTIES].dataInputObjects;
102
113
  const broker = this.broker;
103
114
  if (!dataInputObjects.size) {
104
115
  return broker.getQueue('format-run-q').queueMessage({
@@ -122,9 +133,9 @@ Properties.prototype._formatOnEnter = function formatOnEnter(message) {
122
133
  };
123
134
  Properties.prototype._formatOnComplete = function formatOnComplete(message) {
124
135
  const startRoutingKey = 'run.end.bpmn-properties';
125
- const messageOutput = (0, _getPropertyValue.default)(message, 'content.output.properties') || {};
136
+ const messageOutput = (0, _getPropertyValue.getPropertyValue)(message, 'content.output.properties') || {};
126
137
  const outputProperties = this._getProperties(message, messageOutput);
127
- const dataOutputObjects = this[kProperties].dataOutputObjects;
138
+ const dataOutputObjects = this[K_PROPERTIES].dataOutputObjects;
128
139
  const broker = this.broker;
129
140
  if (!dataOutputObjects.size) {
130
141
  return broker.getQueue('format-run-q').queueMessage({
@@ -157,7 +168,7 @@ Properties.prototype._getProperties = function getProperties(message, values) {
157
168
  id,
158
169
  type,
159
170
  name
160
- } of this[kProperties].properties) {
171
+ } of this[K_PROPERTIES].properties) {
161
172
  if (!(id in response)) {
162
173
  response[id] = {
163
174
  id,
@@ -9,14 +9,21 @@ exports.cloneParent = cloneParent;
9
9
  exports.pushParent = pushParent;
10
10
  exports.shiftParent = shiftParent;
11
11
  exports.unshiftParent = unshiftParent;
12
+ /**
13
+ * Clone message content
14
+ * @param {import('#types').ElementMessageContent} content
15
+ * @param {Record<string, any>} [extend]
16
+ * @returns cloned content
17
+ */
12
18
  function cloneContent(content, extend) {
13
19
  const {
14
- discardSequence,
15
20
  inbound,
16
21
  outbound,
17
22
  parent,
18
23
  sequence
19
24
  } = content;
25
+
26
+ /** @type {import('#types').ElementMessageContent} */
20
27
  const clone = {
21
28
  ...content,
22
29
  ...extend
@@ -24,9 +31,6 @@ function cloneContent(content, extend) {
24
31
  if (parent) {
25
32
  clone.parent = cloneParent(parent);
26
33
  }
27
- if (discardSequence) {
28
- clone.discardSequence = discardSequence.slice();
29
- }
30
34
  if (inbound) {
31
35
  clone.inbound = inbound.map(c => cloneContent(c));
32
36
  }
@@ -38,6 +42,13 @@ function cloneContent(content, extend) {
38
42
  }
39
43
  return clone;
40
44
  }
45
+
46
+ /**
47
+ * Clone message
48
+ * @param {import('#types').ElementBrokerMessage} message
49
+ * @param {Record<string, any>} [overrideContent]
50
+ * @returns {Pick<ElementBrokerMessage, 'fields' | 'content', 'properties'>}
51
+ */
41
52
  function cloneMessage(message, overrideContent) {
42
53
  return {
43
54
  fields: {
@@ -49,6 +60,12 @@ function cloneMessage(message, overrideContent) {
49
60
  }
50
61
  };
51
62
  }
63
+
64
+ /**
65
+ * Clone parent
66
+ * @param {import('#types').ElementParent} parent
67
+ * @returns {import('#types').ElementParent} cloned parent
68
+ */
52
69
  function cloneParent(parent) {
53
70
  const {
54
71
  path
@@ -64,6 +81,13 @@ function cloneParent(parent) {
64
81
  });
65
82
  return clone;
66
83
  }
84
+
85
+ /**
86
+ * Add parent to top of path
87
+ * @param {import('#types').ElementParent} parent
88
+ * @param {import('#types').ElementMessageContent} adoptingParent
89
+ * @returns {import('#types').ElementParent}
90
+ */
67
91
  function unshiftParent(parent, adoptingParent) {
68
92
  const {
69
93
  id,
@@ -94,6 +118,12 @@ function unshiftParent(parent, adoptingParent) {
94
118
  });
95
119
  return clone;
96
120
  }
121
+
122
+ /**
123
+ * Remove top parent from path
124
+ * @param {import('#types').ElementParent} parent
125
+ * @returns {import('#types').ElementParent}
126
+ */
97
127
  function shiftParent(parent) {
98
128
  if (!parent) return;
99
129
  if (!parent.path || !parent.path.length) return;
@@ -109,6 +139,13 @@ function shiftParent(parent) {
109
139
  clone.path = clone.path.length ? clone.path : undefined;
110
140
  return clone;
111
141
  }
142
+
143
+ /**
144
+ * Add ancestor parent at end
145
+ * @param {import('#types').ElementParent} parent
146
+ * @param {import('#types').ElementMessageContent} ancestor
147
+ * @returns {import('#types').ElementParent}
148
+ */
112
149
  function pushParent(parent, ancestor) {
113
150
  const {
114
151
  id,
@@ -3,8 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Lane;
7
- const kProcess = Symbol.for('process');
6
+ exports.Lane = Lane;
7
+ const K_PROCESS = Symbol.for('process');
8
+
9
+ /**
10
+ * Process lane. Wraps a `<bpmn:lane>` definition and points back to its owning process;
11
+ * activities reference their lane through `Activity.lane`.
12
+ * @param {import('#types').Process} process
13
+ * @param {import('moddle-context-serializer').SerializableElement} laneDefinition
14
+ */
8
15
  function Lane(process, laneDefinition) {
9
16
  const {
10
17
  broker,
@@ -15,14 +22,17 @@ function Lane(process, laneDefinition) {
15
22
  type,
16
23
  behaviour
17
24
  } = laneDefinition;
18
- this[kProcess] = process;
25
+ this[K_PROCESS] = process;
19
26
  this.id = id;
20
27
  this.type = type;
28
+ /** @type {string} */
21
29
  this.name = behaviour.name;
30
+ /** @type {import('moddle-context-serializer').Parent} */
22
31
  this.parent = {
23
32
  id: process.id,
24
33
  type: process.type
25
34
  };
35
+ /** @type {Record<string, any>} */
26
36
  this.behaviour = {
27
37
  ...behaviour
28
38
  };
@@ -32,7 +42,8 @@ function Lane(process, laneDefinition) {
32
42
  this.logger = environment.Logger(type.toLowerCase());
33
43
  }
34
44
  Object.defineProperty(Lane.prototype, 'process', {
45
+ /** @returns {import('#types').Process} */
35
46
  get() {
36
- return this[kProcess];
47
+ return this[K_PROCESS];
37
48
  }
38
49
  });