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,27 +3,41 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.EndEvent = EndEvent;
6
7
  exports.EndEventBehaviour = EndEventBehaviour;
7
- exports.default = EndEvent;
8
- var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
9
- var _EventDefinitionExecution = _interopRequireDefault(require("../eventDefinitions/EventDefinitionExecution.js"));
8
+ var _Activity = require("../activity/Activity.js");
9
+ var _EventDefinitionExecution = require("../eventDefinitions/EventDefinitionExecution.js");
10
10
  var _messageHelper = require("../messageHelper.js");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const kExecution = Symbol.for('execution');
11
+ var _constants = require("../constants.js");
12
+ /**
13
+ * End event
14
+ * @param {import('moddle-context-serializer').Activity} activityDef
15
+ * @param {import('#types').ContextInstance} context
16
+ */
13
17
  function EndEvent(activityDef, context) {
14
- return new _Activity.default(EndEventBehaviour, {
18
+ return new _Activity.Activity(EndEventBehaviour, {
15
19
  ...activityDef,
16
20
  isThrowing: true
17
21
  }, context);
18
22
  }
23
+
24
+ /**
25
+ * End event behaviour
26
+ * @param {import('#types').Activity} activity
27
+ */
19
28
  function EndEventBehaviour(activity) {
20
29
  this.id = activity.id;
21
30
  this.type = activity.type;
22
31
  this.broker = activity.broker;
23
- this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
32
+ this[_constants.K_EXECUTION] = activity.eventDefinitions && new _EventDefinitionExecution.EventDefinitionExecution(activity, activity.eventDefinitions);
24
33
  }
34
+
35
+ /**
36
+ * @param {import('#types').ElementBrokerMessage} executeMessage
37
+ * @returns {void}
38
+ */
25
39
  EndEventBehaviour.prototype.execute = function execute(executeMessage) {
26
- const execution = this[kExecution];
40
+ const execution = this[_constants.K_EXECUTION];
27
41
  if (execution) {
28
42
  return execution.execute(executeMessage);
29
43
  }
@@ -3,24 +3,42 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.IntermediateCatchEvent = IntermediateCatchEvent;
6
7
  exports.IntermediateCatchEventBehaviour = IntermediateCatchEventBehaviour;
7
- exports.default = IntermediateCatchEvent;
8
- var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
9
- var _EventDefinitionExecution = _interopRequireDefault(require("../eventDefinitions/EventDefinitionExecution.js"));
8
+ var _Activity = require("../activity/Activity.js");
9
+ var _EventDefinitionExecution = require("../eventDefinitions/EventDefinitionExecution.js");
10
10
  var _messageHelper = require("../messageHelper.js");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const kExecution = Symbol.for('execution');
11
+ var _constants = require("../constants.js");
12
+ /**
13
+ * Intermediate catch event
14
+ * @param {import('moddle-context-serializer').Activity} activityDef
15
+ * @param {import('#types').ContextInstance} context
16
+ */
13
17
  function IntermediateCatchEvent(activityDef, context) {
14
- return new _Activity.default(IntermediateCatchEventBehaviour, activityDef, context);
18
+ return new _Activity.Activity(IntermediateCatchEventBehaviour, {
19
+ ...activityDef,
20
+ isCatching: true,
21
+ ...context.getLinkEventDefinitionInfo(activityDef)
22
+ }, context);
15
23
  }
24
+
25
+ /**
26
+ * Intermediate catch event behaviour
27
+ * @param {import('#types').Activity} activity
28
+ */
16
29
  function IntermediateCatchEventBehaviour(activity) {
17
30
  this.id = activity.id;
18
31
  this.type = activity.type;
19
32
  this.broker = activity.broker;
20
- this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
33
+ this[_constants.K_EXECUTION] = activity.eventDefinitions && new _EventDefinitionExecution.EventDefinitionExecution(activity, activity.eventDefinitions);
21
34
  }
35
+
36
+ /**
37
+ * @param {import('#types').ElementBrokerMessage} executeMessage
38
+ * @returns {void}
39
+ */
22
40
  IntermediateCatchEventBehaviour.prototype.execute = function execute(executeMessage) {
23
- const execution = this[kExecution];
41
+ const execution = this[_constants.K_EXECUTION];
24
42
  if (execution) {
25
43
  return execution.execute(executeMessage);
26
44
  }
@@ -3,27 +3,42 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.IntermediateThrowEvent = IntermediateThrowEvent;
6
7
  exports.IntermediateThrowEventBehaviour = IntermediateThrowEventBehaviour;
7
- exports.default = IntermediateThrowEvent;
8
- var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
9
- var _EventDefinitionExecution = _interopRequireDefault(require("../eventDefinitions/EventDefinitionExecution.js"));
8
+ var _Activity = require("../activity/Activity.js");
9
+ var _EventDefinitionExecution = require("../eventDefinitions/EventDefinitionExecution.js");
10
10
  var _messageHelper = require("../messageHelper.js");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const kExecution = Symbol.for('execution');
11
+ var _constants = require("../constants.js");
12
+ /**
13
+ * Intermediate throw event
14
+ * @param {import('moddle-context-serializer').Activity} activityDef
15
+ * @param {import('#types').ContextInstance} context
16
+ */
13
17
  function IntermediateThrowEvent(activityDef, context) {
14
- return new _Activity.default(IntermediateThrowEventBehaviour, {
18
+ return new _Activity.Activity(IntermediateThrowEventBehaviour, {
15
19
  ...activityDef,
16
- isThrowing: true
20
+ isThrowing: true,
21
+ ...context.getLinkEventDefinitionInfo(activityDef)
17
22
  }, context);
18
23
  }
24
+
25
+ /**
26
+ * Intermediate throw event behaviour
27
+ * @param {import('#types').Activity} activity
28
+ */
19
29
  function IntermediateThrowEventBehaviour(activity) {
20
30
  this.id = activity.id;
21
31
  this.type = activity.type;
22
32
  this.broker = activity.broker;
23
- this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
33
+ this[_constants.K_EXECUTION] = activity.eventDefinitions && new _EventDefinitionExecution.EventDefinitionExecution(activity, activity.eventDefinitions);
24
34
  }
35
+
36
+ /**
37
+ * @param {import('#types').ElementBrokerMessage} executeMessage
38
+ * @returns {void}
39
+ */
25
40
  IntermediateThrowEventBehaviour.prototype.execute = function execute(executeMessage) {
26
- const execution = this[kExecution];
41
+ const execution = this[_constants.K_EXECUTION];
27
42
  if (execution) {
28
43
  return execution.execute(executeMessage);
29
44
  }
@@ -3,31 +3,47 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.StartEvent = StartEvent;
6
7
  exports.StartEventBehaviour = StartEventBehaviour;
7
- exports.default = StartEvent;
8
- var _Activity = _interopRequireDefault(require("../activity/Activity.js"));
9
- var _EventDefinitionExecution = _interopRequireDefault(require("../eventDefinitions/EventDefinitionExecution.js"));
8
+ var _Activity = require("../activity/Activity.js");
9
+ var _EventDefinitionExecution = require("../eventDefinitions/EventDefinitionExecution.js");
10
10
  var _messageHelper = require("../messageHelper.js");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- const kExecuteMessage = Symbol.for('executeMessage');
13
- const kExecution = Symbol.for('execution');
11
+ var _constants = require("../constants.js");
12
+ /**
13
+ * Start event
14
+ * @param {import('moddle-context-serializer').Activity} activityDef
15
+ * @param {import('#types').ContextInstance} context
16
+ */
14
17
  function StartEvent(activityDef, context) {
15
- return new _Activity.default(StartEventBehaviour, activityDef, context);
18
+ return new _Activity.Activity(StartEventBehaviour, {
19
+ ...activityDef,
20
+ isStartEvent: true
21
+ }, context);
16
22
  }
23
+
24
+ /**
25
+ * Start event behaviour
26
+ * @param {import('#types').Activity} activity
27
+ */
17
28
  function StartEventBehaviour(activity) {
18
29
  this.id = activity.id;
19
30
  this.type = activity.type;
20
31
  this.activity = activity;
21
32
  this.broker = activity.broker;
22
- this[kExecution] = activity.eventDefinitions && new _EventDefinitionExecution.default(activity, activity.eventDefinitions);
33
+ this[_constants.K_EXECUTION] = activity.eventDefinitions && new _EventDefinitionExecution.EventDefinitionExecution(activity, activity.eventDefinitions);
23
34
  }
24
35
  Object.defineProperty(StartEventBehaviour.prototype, 'executionId', {
25
36
  get() {
26
- return this[kExecuteMessage]?.content.executionId;
37
+ return this[_constants.K_EXECUTE_MESSAGE]?.content.executionId;
27
38
  }
28
39
  });
40
+
41
+ /**
42
+ * @param {import('#types').ElementBrokerMessage} executeMessage
43
+ * @returns {void}
44
+ */
29
45
  StartEventBehaviour.prototype.execute = function execute(executeMessage) {
30
- const execution = this[kExecution];
46
+ const execution = this[_constants.K_EXECUTION];
31
47
  if (execution) {
32
48
  return execution.execute(executeMessage);
33
49
  }
@@ -37,7 +53,7 @@ StartEventBehaviour.prototype.execute = function execute(executeMessage) {
37
53
  return broker.publish('execution', 'execute.completed', content);
38
54
  }
39
55
  const executionId = content.executionId;
40
- this[kExecuteMessage] = executeMessage;
56
+ this[_constants.K_EXECUTE_MESSAGE] = executeMessage;
41
57
  broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => this._onApiMessage(...args), {
42
58
  noAck: true,
43
59
  consumerTag: `_api-${executionId}`,
@@ -64,7 +80,7 @@ StartEventBehaviour.prototype._onApiMessage = function onApiMessage(routingKey,
64
80
  case 'signal':
65
81
  {
66
82
  this._stop();
67
- const content = this[kExecuteMessage].content;
83
+ const content = this[_constants.K_EXECUTE_MESSAGE].content;
68
84
  return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(content, {
69
85
  output: message.content.message,
70
86
  state: 'signal'
@@ -75,7 +91,7 @@ StartEventBehaviour.prototype._onApiMessage = function onApiMessage(routingKey,
75
91
  case 'discard':
76
92
  {
77
93
  this._stop();
78
- const content = this[kExecuteMessage].content;
94
+ const content = this[_constants.K_EXECUTE_MESSAGE].content;
79
95
  return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(content), {
80
96
  correlationId
81
97
  });
@@ -95,7 +111,7 @@ StartEventBehaviour.prototype._onDelegatedApiMessage = function onDelegatedApiMe
95
111
  type,
96
112
  correlationId
97
113
  } = message.properties;
98
- const executeContent = this[kExecuteMessage].content;
114
+ const executeContent = this[_constants.K_EXECUTE_MESSAGE].content;
99
115
  this.broker.publish('event', 'activity.consumed', (0, _messageHelper.cloneContent)(executeContent, {
100
116
  message: {
101
117
  ...content.message
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "BoundaryEvent", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _BoundaryEvent.default;
9
+ return _BoundaryEvent.BoundaryEvent;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "BoundaryEventBehaviour", {
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "BoundaryEventBehaviour", {
18
18
  Object.defineProperty(exports, "EndEvent", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _EndEvent.default;
21
+ return _EndEvent.EndEvent;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "EndEventBehaviour", {
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "EndEventBehaviour", {
30
30
  Object.defineProperty(exports, "IntermediateCatchEvent", {
31
31
  enumerable: true,
32
32
  get: function () {
33
- return _IntermediateCatchEvent.default;
33
+ return _IntermediateCatchEvent.IntermediateCatchEvent;
34
34
  }
35
35
  });
36
36
  Object.defineProperty(exports, "IntermediateCatchEventBehaviour", {
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "IntermediateCatchEventBehaviour", {
42
42
  Object.defineProperty(exports, "IntermediateThrowEvent", {
43
43
  enumerable: true,
44
44
  get: function () {
45
- return _IntermediateThrowEvent.default;
45
+ return _IntermediateThrowEvent.IntermediateThrowEvent;
46
46
  }
47
47
  });
48
48
  Object.defineProperty(exports, "IntermediateThrowEventBehaviour", {
@@ -54,7 +54,7 @@ Object.defineProperty(exports, "IntermediateThrowEventBehaviour", {
54
54
  Object.defineProperty(exports, "StartEvent", {
55
55
  enumerable: true,
56
56
  get: function () {
57
- return _StartEvent.default;
57
+ return _StartEvent.StartEvent;
58
58
  }
59
59
  });
60
60
  Object.defineProperty(exports, "StartEventBehaviour", {
@@ -63,9 +63,8 @@ Object.defineProperty(exports, "StartEventBehaviour", {
63
63
  return _StartEvent.StartEventBehaviour;
64
64
  }
65
65
  });
66
- var _BoundaryEvent = _interopRequireWildcard(require("./BoundaryEvent.js"));
67
- var _EndEvent = _interopRequireWildcard(require("./EndEvent.js"));
68
- var _IntermediateCatchEvent = _interopRequireWildcard(require("./IntermediateCatchEvent.js"));
69
- var _IntermediateThrowEvent = _interopRequireWildcard(require("./IntermediateThrowEvent.js"));
70
- var _StartEvent = _interopRequireWildcard(require("./StartEvent.js"));
71
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
66
+ var _BoundaryEvent = require("./BoundaryEvent.js");
67
+ var _EndEvent = require("./EndEvent.js");
68
+ var _IntermediateCatchEvent = require("./IntermediateCatchEvent.js");
69
+ var _IntermediateThrowEvent = require("./IntermediateThrowEvent.js");
70
+ var _StartEvent = require("./StartEvent.js");
@@ -3,12 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Association;
6
+ exports.Association = Association;
7
7
  var _messageHelper = require("../messageHelper.js");
8
8
  var _EventBroker = require("../EventBroker.js");
9
9
  var _Api = require("../Api.js");
10
10
  var _shared = require("../shared.js");
11
- const kCounters = Symbol.for('counters');
11
+ var _constants = require("../constants.js");
12
+ /**
13
+ * Association connecting a source and target activity. Used to drive compensation —
14
+ * activities marked `isForCompensation` subscribe to inbound association events.
15
+ * @param {import('moddle-context-serializer').Association} associationDef
16
+ * @param {import('#types').ContextInstance} context
17
+ */
12
18
  function Association(associationDef, {
13
19
  environment
14
20
  }) {
@@ -25,13 +31,14 @@ function Association(associationDef, {
25
31
  this.type = type;
26
32
  this.name = name;
27
33
  this.parent = (0, _messageHelper.cloneParent)(parent);
34
+ /** @type {Record<string, any>} */
28
35
  this.behaviour = behaviour;
29
36
  this.sourceId = sourceId;
30
37
  this.targetId = targetId;
31
38
  this.isAssociation = true;
32
39
  this.environment = environment;
33
40
  const logger = this.logger = environment.Logger(type.toLowerCase());
34
- this[kCounters] = {
41
+ this[_constants.K_COUNTERS] = {
35
42
  take: 0,
36
43
  discard: 0
37
44
  };
@@ -52,24 +59,41 @@ function Association(associationDef, {
52
59
  logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
53
60
  }
54
61
  Object.defineProperty(Association.prototype, 'counters', {
62
+ /** @returns {{ take: number, discard: number }} */
55
63
  get() {
56
64
  return {
57
- ...this[kCounters]
65
+ ...this[_constants.K_COUNTERS]
58
66
  };
59
67
  }
60
68
  });
69
+
70
+ /**
71
+ * Take the association and publish association.take.
72
+ * @param {Record<string, any>} [content]
73
+ */
61
74
  Association.prototype.take = function take(content) {
62
75
  this.logger.debug(`<${this.id}> take target <${this.targetId}>`);
63
- ++this[kCounters].take;
76
+ ++this[_constants.K_COUNTERS].take;
64
77
  this._publishEvent('take', content);
65
78
  return true;
66
79
  };
80
+
81
+ /**
82
+ * Discard the association and publish association.discard.
83
+ * @param {Record<string, any>} [content]
84
+ */
67
85
  Association.prototype.discard = function discard(content) {
68
86
  this.logger.debug(`<${this.id}> discard target <${this.targetId}>`);
69
- ++this[kCounters].discard;
87
+ ++this[_constants.K_COUNTERS].discard;
70
88
  this._publishEvent('discard', content);
71
89
  return true;
72
90
  };
91
+
92
+ /**
93
+ * Snapshot association state. Returns undefined when broker has no state and
94
+ * `disableTrackState` is set.
95
+ * @returns {import('#types').AssociationState | undefined}
96
+ */
73
97
  Association.prototype.getState = function getState() {
74
98
  const brokerState = this.broker.getState(true);
75
99
  if (!brokerState && this.environment.settings.disableTrackState) return;
@@ -80,18 +104,35 @@ Association.prototype.getState = function getState() {
80
104
  broker: brokerState
81
105
  };
82
106
  };
107
+
108
+ /**
109
+ * Restore association state captured by getState.
110
+ * @param {import('#types').AssociationState} state
111
+ */
83
112
  Association.prototype.recover = function recover(state) {
84
- Object.assign(this[kCounters], state.counters);
113
+ Object.assign(this[_constants.K_COUNTERS], state.counters);
85
114
  this.broker.recover(state.broker);
86
115
  };
116
+
117
+ /**
118
+ * Resolve an association-scoped Api wrapper.
119
+ * @param {import('#types').ElementBrokerMessage} [message]
120
+ * @returns {import('#types').IApi<this>}
121
+ */
87
122
  Association.prototype.getApi = function getApi(message) {
88
123
  return new _Api.Api('association', this.broker, message || {
89
124
  content: this._createMessageContent()
90
125
  });
91
126
  };
127
+
128
+ /**
129
+ * Stop the association's broker.
130
+ */
92
131
  Association.prototype.stop = function stop() {
93
132
  this.broker.stop();
94
133
  };
134
+
135
+ /** @internal */
95
136
  Association.prototype._publishEvent = function publishEvent(action, content) {
96
137
  const eventContent = this._createMessageContent({
97
138
  action,
@@ -102,6 +143,8 @@ Association.prototype._publishEvent = function publishEvent(action, content) {
102
143
  type: action
103
144
  });
104
145
  };
146
+
147
+ /** @internal */
105
148
  Association.prototype._createMessageContent = function createMessageContent(override) {
106
149
  return {
107
150
  ...override,
@@ -3,13 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = MessageFlow;
6
+ exports.MessageFlow = MessageFlow;
7
7
  var _shared = require("../shared.js");
8
8
  var _messageHelper = require("../messageHelper.js");
9
9
  var _EventBroker = require("../EventBroker.js");
10
10
  var _Api = require("../Api.js");
11
- const kCounters = Symbol.for('counters');
12
- const kSourceElement = Symbol.for('sourceElement');
11
+ var _constants = require("../constants.js");
12
+ const K_SOURCE_ELEMENT = Symbol.for('sourceElement');
13
+
14
+ /**
15
+ * Message flow connecting a source activity (or process) to a target. Subscribes to the
16
+ * source's `end` event and publishes `message.outbound` whenever the source completes,
17
+ * carrying any message payload through to the target.
18
+ * @param {import('moddle-context-serializer').MessageFlow} flowDef
19
+ * @param {import('#types').ContextInstance} context
20
+ */
13
21
  function MessageFlow(flowDef, context) {
14
22
  const {
15
23
  id,
@@ -26,10 +34,11 @@ function MessageFlow(flowDef, context) {
26
34
  this.parent = (0, _messageHelper.cloneParent)(parent);
27
35
  this.source = source;
28
36
  this.target = target;
37
+ /** @type {Record<string, any>} */
29
38
  this.behaviour = behaviour;
30
39
  this.environment = context.environment;
31
40
  this.context = context;
32
- this[kCounters] = {
41
+ this[_constants.K_COUNTERS] = {
33
42
  messages: 0
34
43
  };
35
44
  const {
@@ -44,16 +53,23 @@ function MessageFlow(flowDef, context) {
44
53
  this.once = once;
45
54
  this.emit = emit;
46
55
  this.waitFor = waitFor;
47
- this[kSourceElement] = context.getActivityById(source.id) || context.getProcessById(source.processId);
56
+ this[K_SOURCE_ELEMENT] = context.getActivityById(source.id) || context.getProcessById(source.processId);
48
57
  this.logger = context.environment.Logger(type.toLowerCase());
49
58
  }
50
59
  Object.defineProperty(MessageFlow.prototype, 'counters', {
60
+ /** @returns {{ messages: number }} */
51
61
  get() {
52
62
  return {
53
- ...this[kCounters]
63
+ ...this[_constants.K_COUNTERS]
54
64
  };
55
65
  }
56
66
  });
67
+
68
+ /**
69
+ * Snapshot message-flow state. Returns undefined when broker has no state and
70
+ * `disableTrackState` is set.
71
+ * @returns {import('#types').MessageFlowState | undefined}
72
+ */
57
73
  MessageFlow.prototype.getState = function getState() {
58
74
  const brokerState = this.broker.getState(true);
59
75
  if (!brokerState && this.environment.settings.disableTrackState) return;
@@ -64,17 +80,32 @@ MessageFlow.prototype.getState = function getState() {
64
80
  broker: brokerState
65
81
  };
66
82
  };
83
+
84
+ /**
85
+ * Restore message-flow state captured by getState.
86
+ * @param {import('#types').MessageFlowState} state
87
+ */
67
88
  MessageFlow.prototype.recover = function recover(state) {
68
- Object.assign(this[kCounters], state.counters);
89
+ Object.assign(this[_constants.K_COUNTERS], state.counters);
69
90
  this.broker.recover(state.broker);
70
91
  };
92
+
93
+ /**
94
+ * Resolve a message-scoped Api wrapper.
95
+ * @param {import('#types').ElementBrokerMessage} [message]
96
+ * @returns {import('#types').IApi<this>}
97
+ */
71
98
  MessageFlow.prototype.getApi = function getApi(message) {
72
99
  return new _Api.Api('message', this.broker, message || {
73
100
  content: this._createMessageContent()
74
101
  });
75
102
  };
103
+
104
+ /**
105
+ * Subscribe to the source element's message and end events to bridge the message across.
106
+ */
76
107
  MessageFlow.prototype.activate = function activate() {
77
- const sourceElement = this[kSourceElement];
108
+ const sourceElement = this[K_SOURCE_ELEMENT];
78
109
  const safeId = (0, _shared.brokerSafeId)(this.id);
79
110
  sourceElement.on('message', this.deactivate.bind(this), {
80
111
  consumerTag: `_message-on-message-${safeId}`
@@ -83,21 +114,29 @@ MessageFlow.prototype.activate = function activate() {
83
114
  consumerTag: `_message-on-end-${safeId}`
84
115
  });
85
116
  };
117
+
118
+ /**
119
+ * Cancel the source element subscriptions added by activate.
120
+ */
86
121
  MessageFlow.prototype.deactivate = function deactivate() {
87
- const sourceElement = this[kSourceElement];
122
+ const sourceElement = this[K_SOURCE_ELEMENT];
88
123
  const safeId = (0, _shared.brokerSafeId)(this.id);
89
124
  sourceElement.broker.cancel(`_message-on-end-${safeId}`);
90
125
  sourceElement.broker.cancel(`_message-on-message-${safeId}`);
91
126
  };
127
+
128
+ /** @internal */
92
129
  MessageFlow.prototype._onSourceEnd = function onSourceEnd({
93
130
  content
94
131
  }) {
95
- ++this[kCounters].messages;
132
+ ++this[_constants.K_COUNTERS].messages;
96
133
  const source = this.source;
97
134
  const target = this.target;
98
135
  this.logger.debug(`<${this.id}> sending message from <${source.processId}.${source.id}> to <${target.id ? `${target.processId}.${target.id}` : target.processId}>`);
99
136
  this.broker.publish('event', 'message.outbound', this._createMessageContent(content.message));
100
137
  };
138
+
139
+ /** @internal */
101
140
  MessageFlow.prototype._createMessageContent = function createMessage(message) {
102
141
  return {
103
142
  id: this.id,