bpmn-elements 8.2.4 → 9.1.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 (127) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/dist/{src/Api.js → Api.js} +11 -12
  4. package/dist/{src/Context.js → Context.js} +26 -27
  5. package/dist/{src/Environment.js → Environment.js} +15 -16
  6. package/dist/{src/EventBroker.js → EventBroker.js} +5 -1
  7. package/dist/{src/Expressions.js → Expressions.js} +1 -1
  8. package/dist/{src/MessageFormatter.js → MessageFormatter.js} +3 -3
  9. package/dist/Tracker.js +89 -0
  10. package/dist/{src/activity → activity}/Activity.js +109 -120
  11. package/dist/{src/activity → activity}/ActivityExecution.js +28 -32
  12. package/dist/{src/activity → activity}/Dummy.js +1 -1
  13. package/dist/{src/activity → activity}/ExecutionScope.js +2 -2
  14. package/dist/{src/definition → definition}/Definition.js +64 -59
  15. package/dist/{src/definition → definition}/DefinitionExecution.js +68 -46
  16. package/dist/{src/error → error}/Errors.js +1 -1
  17. package/dist/eventDefinitions/CancelEventDefinition.js +127 -0
  18. package/dist/{src/eventDefinitions → eventDefinitions}/CompensateEventDefinition.js +64 -52
  19. package/dist/{src/eventDefinitions → eventDefinitions}/ConditionalEventDefinition.js +24 -16
  20. package/dist/{src/eventDefinitions → eventDefinitions}/ErrorEventDefinition.js +15 -14
  21. package/dist/{src/eventDefinitions → eventDefinitions}/EscalationEventDefinition.js +12 -13
  22. package/dist/{src/eventDefinitions → eventDefinitions}/EventDefinitionExecution.js +10 -11
  23. package/dist/{src/eventDefinitions → eventDefinitions}/LinkEventDefinition.js +14 -15
  24. package/dist/{src/eventDefinitions → eventDefinitions}/MessageEventDefinition.js +13 -14
  25. package/dist/{src/eventDefinitions → eventDefinitions}/SignalEventDefinition.js +13 -14
  26. package/dist/{src/eventDefinitions → eventDefinitions}/TerminateEventDefinition.js +1 -1
  27. package/dist/{src/eventDefinitions → eventDefinitions}/TimerEventDefinition.js +15 -16
  28. package/dist/{src/events → events}/BoundaryEvent.js +39 -25
  29. package/dist/{src/events → events}/EndEvent.js +3 -3
  30. package/dist/{src/events → events}/IntermediateCatchEvent.js +3 -3
  31. package/dist/{src/events → events}/IntermediateThrowEvent.js +3 -3
  32. package/dist/{src/events → events}/StartEvent.js +8 -9
  33. package/dist/{src/flows → flows}/Association.js +14 -22
  34. package/dist/{src/flows → flows}/MessageFlow.js +16 -14
  35. package/dist/{src/flows → flows}/SequenceFlow.js +16 -18
  36. package/dist/{src/gateways → gateways}/EventBasedGateway.js +3 -4
  37. package/dist/{src/gateways → gateways}/ExclusiveGateway.js +2 -2
  38. package/dist/{src/gateways → gateways}/InclusiveGateway.js +2 -2
  39. package/dist/{src/gateways → gateways}/ParallelGateway.js +2 -2
  40. package/dist/index.js +48 -48
  41. package/dist/{src/io → io}/InputOutputSpecification.js +8 -9
  42. package/dist/{src/io → io}/Properties.js +7 -8
  43. package/dist/package.json +3 -0
  44. package/dist/{src/process → process}/Process.js +44 -40
  45. package/dist/{src/process → process}/ProcessExecution.js +169 -78
  46. package/dist/{src/tasks → tasks}/CallActivity.js +7 -8
  47. package/dist/{src/tasks → tasks}/LoopCharacteristics.js +2 -2
  48. package/dist/{src/tasks → tasks}/ReceiveTask.js +14 -15
  49. package/dist/{src/tasks → tasks}/ScriptTask.js +4 -4
  50. package/dist/{src/tasks → tasks}/ServiceImplementation.js +1 -1
  51. package/dist/{src/tasks → tasks}/ServiceTask.js +6 -7
  52. package/dist/{src/tasks → tasks}/SignalTask.js +7 -8
  53. package/dist/{src/tasks → tasks}/StandardLoopCharacteristics.js +1 -1
  54. package/dist/{src/tasks → tasks}/SubProcess.js +19 -19
  55. package/dist/{src/tasks → tasks}/Task.js +2 -2
  56. package/dist/{src/tasks → tasks}/Transaction.js +1 -1
  57. package/package.json +31 -31
  58. package/src/Api.js +11 -13
  59. package/src/Context.js +26 -28
  60. package/src/Environment.js +15 -17
  61. package/src/EventBroker.js +2 -1
  62. package/src/Expressions.js +1 -1
  63. package/src/MessageFormatter.js +3 -3
  64. package/src/Tracker.js +73 -0
  65. package/src/activity/Activity.js +106 -114
  66. package/src/activity/ActivityExecution.js +28 -32
  67. package/src/activity/Dummy.js +1 -1
  68. package/src/activity/ExecutionScope.js +2 -2
  69. package/src/definition/Definition.js +65 -64
  70. package/src/definition/DefinitionExecution.js +71 -47
  71. package/src/error/Errors.js +1 -1
  72. package/src/eventDefinitions/CancelEventDefinition.js +32 -78
  73. package/src/eventDefinitions/CompensateEventDefinition.js +58 -52
  74. package/src/eventDefinitions/ConditionalEventDefinition.js +25 -17
  75. package/src/eventDefinitions/ErrorEventDefinition.js +15 -15
  76. package/src/eventDefinitions/EscalationEventDefinition.js +12 -14
  77. package/src/eventDefinitions/EventDefinitionExecution.js +10 -12
  78. package/src/eventDefinitions/LinkEventDefinition.js +14 -16
  79. package/src/eventDefinitions/MessageEventDefinition.js +13 -15
  80. package/src/eventDefinitions/SignalEventDefinition.js +13 -15
  81. package/src/eventDefinitions/TerminateEventDefinition.js +1 -1
  82. package/src/eventDefinitions/TimerEventDefinition.js +15 -17
  83. package/src/events/BoundaryEvent.js +34 -24
  84. package/src/events/EndEvent.js +3 -3
  85. package/src/events/IntermediateCatchEvent.js +3 -3
  86. package/src/events/IntermediateThrowEvent.js +3 -3
  87. package/src/events/StartEvent.js +8 -10
  88. package/src/flows/Association.js +14 -26
  89. package/src/flows/MessageFlow.js +14 -15
  90. package/src/flows/SequenceFlow.js +16 -20
  91. package/src/gateways/EventBasedGateway.js +3 -4
  92. package/src/gateways/ExclusiveGateway.js +2 -2
  93. package/src/gateways/InclusiveGateway.js +2 -2
  94. package/src/gateways/ParallelGateway.js +2 -2
  95. package/src/index.js +106 -0
  96. package/src/io/InputOutputSpecification.js +8 -10
  97. package/src/io/Properties.js +7 -9
  98. package/src/process/Process.js +45 -41
  99. package/src/process/ProcessExecution.js +167 -79
  100. package/src/tasks/CallActivity.js +7 -9
  101. package/src/tasks/LoopCharacteristics.js +2 -2
  102. package/src/tasks/ReceiveTask.js +215 -217
  103. package/src/tasks/ScriptTask.js +4 -4
  104. package/src/tasks/ServiceImplementation.js +1 -1
  105. package/src/tasks/ServiceTask.js +6 -8
  106. package/src/tasks/SignalTask.js +7 -9
  107. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  108. package/src/tasks/SubProcess.js +19 -20
  109. package/src/tasks/Task.js +2 -2
  110. package/src/tasks/Transaction.js +1 -1
  111. package/types/index.d.ts +520 -0
  112. package/dist/src/eventDefinitions/CancelEventDefinition.js +0 -184
  113. package/index.js +0 -106
  114. /package/dist/{src/ExtensionsMapper.js → ExtensionsMapper.js} +0 -0
  115. /package/dist/{src/Scripts.js → Scripts.js} +0 -0
  116. /package/dist/{src/Timers.js → Timers.js} +0 -0
  117. /package/dist/{src/activity → activity}/Escalation.js +0 -0
  118. /package/dist/{src/activity → activity}/Message.js +0 -0
  119. /package/dist/{src/activity → activity}/Signal.js +0 -0
  120. /package/dist/{src/error → error}/BpmnError.js +0 -0
  121. /package/dist/{src/getPropertyValue.js → getPropertyValue.js} +0 -0
  122. /package/dist/{src/io → io}/BpmnIO.js +0 -0
  123. /package/dist/{src/io → io}/EnvironmentDataObject.js +0 -0
  124. /package/dist/{src/io → io}/EnvironmentDataStore.js +0 -0
  125. /package/dist/{src/io → io}/EnvironmentDataStoreReference.js +0 -0
  126. /package/dist/{src/messageHelper.js → messageHelper.js} +0 -0
  127. /package/dist/{src/shared.js → shared.js} +0 -0
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = CompensateEventDefinition;
7
- var _shared = require("../shared");
8
- var _messageHelper = require("../messageHelper");
7
+ var _shared = require("../shared.js");
8
+ var _messageHelper = require("../messageHelper.js");
9
9
  const kCompleted = Symbol.for('completed');
10
10
  const kExecuteMessage = Symbol.for('executeMessage');
11
11
  const kMessageQ = Symbol.for('messageQ');
@@ -29,31 +29,39 @@ function CompensateEventDefinition(activity, eventDefinition, context) {
29
29
  this.logger = environment.Logger(type.toLowerCase());
30
30
  if (!isThrowing) {
31
31
  this[kCompleted] = false;
32
- this[kAssociations] = context.getOutboundAssociations(id) || [];
32
+ this[kAssociations] = context.getOutboundAssociations(id);
33
33
  const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-q`;
34
34
  this[kMessageQ] = broker.assertQueue(messageQueueName, {
35
35
  autoDelete: false,
36
36
  durable: true
37
37
  });
38
+ this[kCompensateQ] = broker.assertQueue('compensate-q', {
39
+ autoDelete: false,
40
+ durable: true
41
+ });
38
42
  broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
39
43
  durable: true,
40
44
  priority: 400
41
45
  });
42
46
  }
43
47
  }
44
- const proto = CompensateEventDefinition.prototype;
45
- Object.defineProperty(proto, 'executionId', {
48
+ Object.defineProperty(CompensateEventDefinition.prototype, 'executionId', {
46
49
  get() {
47
50
  const message = this[kExecuteMessage];
48
51
  return message && message.content.executionId;
49
52
  }
50
53
  });
51
- proto.execute = function execute(executeMessage) {
54
+ CompensateEventDefinition.prototype.execute = function execute(executeMessage) {
52
55
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
53
56
  };
54
- proto.executeCatch = function executeCatch(executeMessage) {
57
+ CompensateEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
55
58
  this[kExecuteMessage] = executeMessage;
56
59
  this[kCompleted] = false;
60
+ if (executeMessage.fields.routingKey === 'execute.compensating') {
61
+ this._debug('resumed at compensating');
62
+ this[kCompleted] = true;
63
+ return this._compensate();
64
+ }
57
65
  const executeContent = executeMessage.content;
58
66
  const {
59
67
  executionId,
@@ -61,44 +69,34 @@ proto.executeCatch = function executeCatch(executeMessage) {
61
69
  } = executeContent;
62
70
  this._debug('expect compensate');
63
71
  const broker = this.broker;
72
+ broker.cancel('_convey-messages');
64
73
  broker.assertExchange('compensate', 'topic');
65
- this[kCompensateQ] = broker.assertQueue('compensate-q', {
66
- durable: true,
67
- autoDelete: false
68
- });
69
74
  broker.subscribeTmp('compensate', 'execute.#', this._onCollect.bind(this), {
70
75
  noAck: true,
71
76
  consumerTag: '_oncollect-messages'
72
77
  });
73
- broker.publish('execution', 'execute.detach', (0, _messageHelper.cloneContent)(executeContent, {
74
- sourceExchange: 'execution',
75
- bindExchange: 'compensate'
76
- }));
77
78
  this[kMessageQ].consume(this._onCompensateApiMessage.bind(this), {
78
79
  noAck: true,
79
80
  consumerTag: `_oncompensate-${executionId}`
80
81
  });
81
82
  if (this[kCompleted]) return;
82
- const onApiMessage = this._onApiMessage.bind(this);
83
- broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
83
+ broker.subscribeTmp('api', `activity.#.${parent.executionId}#`, this._onApiMessage.bind(this), {
84
84
  noAck: true,
85
85
  consumerTag: `_api-${executionId}`
86
86
  });
87
- const detachContent = (0, _messageHelper.cloneContent)(executeContent, {
88
- executionId: parent.executionId,
89
- bindExchange: 'compensate'
90
- });
91
- detachContent.parent = (0, _messageHelper.shiftParent)(parent);
92
- broker.publish('event', 'activity.detach', detachContent);
87
+ broker.publish('execution', 'execute.detach', (0, _messageHelper.cloneContent)(executeContent, {
88
+ sourceExchange: 'execution',
89
+ bindExchange: 'compensate',
90
+ expect: 'compensate'
91
+ }));
93
92
  };
94
- proto.executeThrow = function executeThrow(executeMessage) {
93
+ CompensateEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
95
94
  const executeContent = executeMessage.content;
96
95
  const {
97
- executionId,
98
96
  parent
99
97
  } = executeContent;
100
98
  const parentExecutionId = parent && parent.executionId;
101
- this.logger.debug(`<${executionId} (${this.activity.id})> throw compensate`);
99
+ this.logger.debug(`<${parentExecutionId} (${this.id})> throw compensate`);
102
100
  const broker = this.broker;
103
101
  const throwContent = (0, _messageHelper.cloneContent)(executeContent, {
104
102
  executionId: parentExecutionId,
@@ -111,7 +109,7 @@ proto.executeThrow = function executeThrow(executeMessage) {
111
109
  });
112
110
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
113
111
  };
114
- proto._onCollect = function onCollect(routingKey, message) {
112
+ CompensateEventDefinition.prototype._onCollect = function onCollect(routingKey, message) {
115
113
  switch (routingKey) {
116
114
  case 'execute.error':
117
115
  case 'execute.completed':
@@ -120,13 +118,13 @@ proto._onCollect = function onCollect(routingKey, message) {
120
118
  }
121
119
  }
122
120
  };
123
- proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
124
- const output = message.content.message;
121
+ CompensateEventDefinition.prototype._onCompensateApiMessage = function onCompensateApiMessage(routingKey, message) {
125
122
  this[kCompleted] = true;
126
- this._stop();
127
- this._debug('caught compensate event');
123
+ const output = message.content.message;
128
124
  const broker = this.broker;
129
125
  const executeContent = this[kExecuteMessage].content;
126
+ this._stopCollect();
127
+ this._debug('caught compensate event');
130
128
  const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
131
129
  message: {
132
130
  ...output
@@ -134,28 +132,43 @@ proto._onCompensateApiMessage = function onCompensateApiMessage(routingKey, mess
134
132
  executionId: executeContent.parent.executionId
135
133
  });
136
134
  catchContent.parent = (0, _messageHelper.shiftParent)(catchContent.parent);
135
+ this[kCompensateQ].queueMessage({
136
+ routingKey: 'execute.compensated'
137
+ }, (0, _messageHelper.cloneContent)(executeContent));
138
+ broker.publish('execution', 'execute.compensating', (0, _messageHelper.cloneContent)(executeContent, {
139
+ message: {
140
+ ...output
141
+ }
142
+ }));
137
143
  broker.publish('event', 'activity.catch', catchContent, {
138
144
  type: 'catch'
139
145
  });
140
- const compensateQ = this[kCompensateQ];
141
- compensateQ.on('depleted', onDepleted);
142
- compensateQ.consume(this._onCollected.bind(this), {
146
+ return this._compensate();
147
+ };
148
+ CompensateEventDefinition.prototype._compensate = function compensate() {
149
+ return this[kCompensateQ].consume(this._onCollected.bind(this), {
143
150
  noAck: true,
144
151
  consumerTag: '_convey-messages'
145
152
  });
146
- for (const association of this[kAssociations]) association.complete((0, _messageHelper.cloneMessage)(message));
147
- function onDepleted() {
148
- compensateQ.off('depleted', onDepleted);
149
- return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
150
- output,
151
- state: 'catch'
153
+ };
154
+ CompensateEventDefinition.prototype._onCollected = function onCollected(routingKey, message) {
155
+ if (routingKey === 'execute.compensated') {
156
+ const broker = this.broker;
157
+ broker.cancel('_convey-messages');
158
+ return this.broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(message.content, {
159
+ cancelActivity: false
152
160
  }));
153
161
  }
154
- };
155
- proto._onCollected = function onCollected(routingKey, message) {
156
162
  for (const association of this[kAssociations]) association.take((0, _messageHelper.cloneMessage)(message));
157
163
  };
158
- proto._onApiMessage = function onApiMessage(routingKey, message) {
164
+ CompensateEventDefinition.prototype._onDiscardApiMessage = function onDiscardApiMessage(routingKey, message) {
165
+ this[kCompleted] = true;
166
+ this._stop();
167
+ this[kCompensateQ].purge();
168
+ for (const association of this[kAssociations]) association.discard((0, _messageHelper.cloneMessage)(message));
169
+ return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
170
+ };
171
+ CompensateEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
159
172
  const messageType = message.properties.type;
160
173
  switch (messageType) {
161
174
  case 'compensate':
@@ -164,27 +177,26 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
164
177
  }
165
178
  case 'discard':
166
179
  {
167
- this[kCompleted] = true;
168
- this._stop();
169
- for (const association of this[kAssociations]) association.discard((0, _messageHelper.cloneMessage)(message));
170
- return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[kExecuteMessage].content));
180
+ return this._onDiscardApiMessage(routingKey, message);
171
181
  }
172
182
  case 'stop':
173
183
  {
174
- this._stop();
175
- break;
184
+ return this._stop();
176
185
  }
177
186
  }
178
187
  };
179
- proto._stop = function stop() {
188
+ CompensateEventDefinition.prototype._stopCollect = function stopCollect() {
180
189
  const broker = this.broker,
181
190
  executionId = this.executionId;
182
191
  broker.cancel(`_api-${executionId}`);
183
192
  broker.cancel(`_oncompensate-${executionId}`);
184
193
  broker.cancel('_oncollect-messages');
185
- broker.cancel('_convey-messages');
186
194
  this[kMessageQ].purge();
187
195
  };
188
- proto._debug = function debug(msg) {
196
+ CompensateEventDefinition.prototype._stop = function stop() {
197
+ this._stopCollect();
198
+ this.broker.cancel('_convey-messages');
199
+ };
200
+ CompensateEventDefinition.prototype._debug = function debug(msg) {
189
201
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
190
202
  };
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ConditionalEventDefinition;
7
- var _messageHelper = require("../messageHelper");
8
- var _Errors = require("../error/Errors");
7
+ var _messageHelper = require("../messageHelper.js");
8
+ var _Errors = require("../error/Errors.js");
9
9
  const kExecuteMessage = Symbol.for('executeMessage');
10
10
  function ConditionalEventDefinition(activity, eventDefinition) {
11
11
  const {
@@ -27,18 +27,17 @@ function ConditionalEventDefinition(activity, eventDefinition) {
27
27
  this.broker = broker;
28
28
  this.logger = environment.Logger(type.toLowerCase());
29
29
  }
30
- const proto = ConditionalEventDefinition.prototype;
31
- Object.defineProperty(proto, 'executionId', {
30
+ Object.defineProperty(ConditionalEventDefinition.prototype, 'executionId', {
32
31
  get() {
33
32
  const message = this[kExecuteMessage];
34
33
  return message && message.content.executionId;
35
34
  }
36
35
  });
37
- proto.execute = function execute(executeMessage) {
36
+ ConditionalEventDefinition.prototype.execute = function execute(executeMessage) {
38
37
  this[kExecuteMessage] = executeMessage;
39
38
  return this.isWaiting ? this.executeWait(executeMessage) : this.executeCatch(executeMessage);
40
39
  };
41
- proto.executeWait = function executeWait(executeMessage) {
40
+ ConditionalEventDefinition.prototype.executeWait = function executeWait(executeMessage) {
42
41
  const executeContent = executeMessage.content;
43
42
  const {
44
43
  executionId,
@@ -63,13 +62,16 @@ proto.executeWait = function executeWait(executeMessage) {
63
62
  waitContent.parent = (0, _messageHelper.shiftParent)(parent);
64
63
  broker.publish('event', 'activity.wait', waitContent);
65
64
  };
66
- proto.executeCatch = function executeCatch(executeMessage) {
65
+ ConditionalEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
67
66
  const executeContent = executeMessage.content;
68
67
  const {
69
68
  executionId,
70
- index
69
+ index,
70
+ parent
71
71
  } = executeContent;
72
- this.broker.subscribeTmp('api', `activity.#.${executionId}`, this._onCatchApiMessage.bind(this), {
72
+ const parentExecutionId = parent.executionId;
73
+ const broker = this.broker;
74
+ broker.subscribeTmp('api', `activity.#.${executionId}`, this._onCatchApiMessage.bind(this), {
73
75
  noAck: true,
74
76
  consumerTag: `_api-${executionId}_${index}`
75
77
  });
@@ -82,8 +84,14 @@ proto.executeCatch = function executeCatch(executeMessage) {
82
84
  priority: 300,
83
85
  consumerTag: `_onend-${executionId}_${index}`
84
86
  });
87
+ const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
88
+ executionId: parentExecutionId,
89
+ condition: this.condition
90
+ });
91
+ waitContent.parent = (0, _messageHelper.shiftParent)(parent);
92
+ broker.publish('event', 'activity.wait', waitContent);
85
93
  };
86
- proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
94
+ ConditionalEventDefinition.prototype._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
87
95
  const messageType = message.properties.type;
88
96
  switch (messageType) {
89
97
  case 'signal':
@@ -103,7 +111,7 @@ proto._onWaitApiMessage = function onWaitApiMessage(routingKey, message) {
103
111
  }
104
112
  }
105
113
  };
106
- proto._evaluateWait = function evaluate(message) {
114
+ ConditionalEventDefinition.prototype._evaluateWait = function evaluate(message) {
107
115
  const executeMessage = this[kExecuteMessage];
108
116
  const broker = this.broker,
109
117
  executeContent = executeMessage.content;
@@ -126,13 +134,13 @@ proto._evaluateWait = function evaluate(message) {
126
134
  output
127
135
  }));
128
136
  };
129
- proto._stopWait = function stopWait() {
137
+ ConditionalEventDefinition.prototype._stopWait = function stopWait() {
130
138
  const broker = this.broker,
131
139
  executionId = this.executionId;
132
140
  broker.cancel(`_api-${executionId}`);
133
141
  broker.cancel(`_parent-signal-${executionId}`);
134
142
  };
135
- proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
143
+ ConditionalEventDefinition.prototype._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
136
144
  this._stopCatch();
137
145
  const executeMessage = this[kExecuteMessage];
138
146
  const broker = this.broker,
@@ -156,7 +164,7 @@ proto._onAttachedCompleted = function onAttachedCompleted(routingKey, message) {
156
164
  }));
157
165
  }
158
166
  };
159
- proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
167
+ ConditionalEventDefinition.prototype._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
160
168
  const messageType = message.properties.type;
161
169
  switch (messageType) {
162
170
  case 'discard':
@@ -174,7 +182,7 @@ proto._onCatchApiMessage = function onCatchApiMessage(routingKey, message) {
174
182
  }
175
183
  }
176
184
  };
177
- proto._stopCatch = function stopCatch() {
185
+ ConditionalEventDefinition.prototype._stopCatch = function stopCatch() {
178
186
  const {
179
187
  executionId,
180
188
  index
@@ -182,6 +190,6 @@ proto._stopCatch = function stopCatch() {
182
190
  this.activity.attachedTo.broker.cancel(`_onend-${executionId}_${index}`);
183
191
  this.broker.cancel(`_api-${executionId}_${index}`);
184
192
  };
185
- proto._debug = function debug(msg) {
193
+ ConditionalEventDefinition.prototype._debug = function debug(msg) {
186
194
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
187
195
  };
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ErrorEventDefinition;
7
- var _shared = require("../shared");
8
- var _messageHelper = require("../messageHelper");
7
+ var _shared = require("../shared.js");
8
+ var _messageHelper = require("../messageHelper.js");
9
9
  const kCompleted = Symbol.for('completed');
10
10
  const kMessageQ = Symbol.for('messageQ');
11
11
  const kExecuteMessage = Symbol.for('executeMessage');
@@ -49,17 +49,16 @@ function ErrorEventDefinition(activity, eventDefinition) {
49
49
  });
50
50
  }
51
51
  }
52
- const proto = ErrorEventDefinition.prototype;
53
- Object.defineProperty(proto, 'executionId', {
52
+ Object.defineProperty(ErrorEventDefinition.prototype, 'executionId', {
54
53
  get() {
55
54
  const message = this[kExecuteMessage];
56
55
  return message && message.content.executionId;
57
56
  }
58
57
  });
59
- proto.execute = function execute(executeMessage) {
58
+ ErrorEventDefinition.prototype.execute = function execute(executeMessage) {
60
59
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
61
60
  };
62
- proto.executeCatch = function executeCatch(executeMessage) {
61
+ ErrorEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
63
62
  this[kExecuteMessage] = executeMessage;
64
63
  this[kCompleted] = false;
65
64
  const executeContent = executeMessage.content;
@@ -87,6 +86,8 @@ proto.executeCatch = function executeCatch(executeMessage) {
87
86
  consumerTag: `_onerror-${executionId}`
88
87
  });
89
88
  broker.publish('execution', 'execute.expect', (0, _messageHelper.cloneContent)(executeContent, {
89
+ pattern: 'activity.error',
90
+ exchange: 'execution',
90
91
  expectRoutingKey,
91
92
  expect: {
92
93
  ...info.message
@@ -103,7 +104,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
103
104
  waitContent.parent = (0, _messageHelper.shiftParent)(parent);
104
105
  broker.publish('event', 'activity.wait', waitContent);
105
106
  };
106
- proto.executeThrow = function executeThrow(executeMessage) {
107
+ ErrorEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
107
108
  const executeContent = executeMessage.content;
108
109
  const {
109
110
  executionId,
@@ -130,7 +131,7 @@ proto.executeThrow = function executeThrow(executeMessage) {
130
131
  }
131
132
  }));
132
133
  };
133
- proto._onErrorMessage = function onErrorMessage(routingKey, message) {
134
+ ErrorEventDefinition.prototype._onErrorMessage = function onErrorMessage(routingKey, message) {
134
135
  const error = message.content.error;
135
136
  if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
136
137
  if (!error) return;
@@ -138,14 +139,14 @@ proto._onErrorMessage = function onErrorMessage(routingKey, message) {
138
139
  if ('' + error.code !== '' + info.message.code) return;
139
140
  return this._catchError(routingKey, message, error);
140
141
  };
141
- proto._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
142
+ ErrorEventDefinition.prototype._onThrowApiMessage = function onThrowApiMessage(routingKey, message) {
142
143
  const error = message.content.message;
143
144
  if (!this[kReferenceElement]) return this._catchError(routingKey, message, error);
144
145
  const info = this[kReferenceInfo];
145
146
  if (info.message.id !== (error && error.id)) return;
146
147
  return this._catchError(routingKey, message, error);
147
148
  };
148
- proto._catchError = function catchError(routingKey, message, error) {
149
+ ErrorEventDefinition.prototype._catchError = function catchError(routingKey, message, error) {
149
150
  this[kCompleted] = true;
150
151
  this._stop();
151
152
  this._debug(`caught ${this[kReferenceInfo].description}`);
@@ -171,7 +172,7 @@ proto._catchError = function catchError(routingKey, message, error) {
171
172
  state: 'catch'
172
173
  }));
173
174
  };
174
- proto._onApiMessage = function onApiMessage(routingKey, message) {
175
+ ErrorEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
175
176
  const messageType = message.properties.type;
176
177
  switch (messageType) {
177
178
  case 'discard':
@@ -187,7 +188,7 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
187
188
  }
188
189
  }
189
190
  };
190
- proto._stop = function stop() {
191
+ ErrorEventDefinition.prototype._stop = function stop() {
191
192
  const broker = this.broker,
192
193
  executionId = this.executionId;
193
194
  broker.cancel(`_onthrow-${executionId}`);
@@ -195,7 +196,7 @@ proto._stop = function stop() {
195
196
  broker.cancel(`_api-${executionId}`);
196
197
  this[kMessageQ].purge();
197
198
  };
198
- proto._getReferenceInfo = function getReferenceInfo(message) {
199
+ ErrorEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(message) {
199
200
  const referenceElement = this[kReferenceElement];
200
201
  if (!referenceElement) {
201
202
  return {
@@ -212,6 +213,6 @@ proto._getReferenceInfo = function getReferenceInfo(message) {
212
213
  if (result.message.code) result.description += ` code ${result.message.code}`;
213
214
  return result;
214
215
  };
215
- proto._debug = function debug(msg) {
216
+ ErrorEventDefinition.prototype._debug = function debug(msg) {
216
217
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
217
218
  };
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = EscalationEventDefinition;
7
- var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue"));
8
- var _shared = require("../shared");
9
- var _messageHelper = require("../messageHelper");
7
+ var _getPropertyValue = _interopRequireDefault(require("../getPropertyValue.js"));
8
+ var _shared = require("../shared.js");
9
+ var _messageHelper = require("../messageHelper.js");
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  const kCompleted = Symbol.for('completed');
12
12
  const kMessageQ = Symbol.for('messageQ');
@@ -50,17 +50,16 @@ function EscalationEventDefinition(activity, eventDefinition) {
50
50
  });
51
51
  }
52
52
  }
53
- const proto = EscalationEventDefinition.prototype;
54
- Object.defineProperty(proto, 'executionId', {
53
+ Object.defineProperty(EscalationEventDefinition.prototype, 'executionId', {
55
54
  get() {
56
55
  const message = this[kExecuteMessage];
57
56
  return message && message.content.executionId;
58
57
  }
59
58
  });
60
- proto.execute = function execute(executeMessage) {
59
+ EscalationEventDefinition.prototype.execute = function execute(executeMessage) {
61
60
  return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
62
61
  };
63
- proto.executeCatch = function executeCatch(executeMessage) {
62
+ EscalationEventDefinition.prototype.executeCatch = function executeCatch(executeMessage) {
64
63
  this[kExecuteMessage] = executeMessage;
65
64
  this[kCompleted] = false;
66
65
  const executeContent = executeMessage.content;
@@ -90,7 +89,7 @@ proto.executeCatch = function executeCatch(executeMessage) {
90
89
  waitContent.parent = (0, _messageHelper.shiftParent)(parent);
91
90
  broker.publish('event', 'activity.wait', waitContent);
92
91
  };
93
- proto.executeThrow = function executeThrow(executeMessage) {
92
+ EscalationEventDefinition.prototype.executeThrow = function executeThrow(executeMessage) {
94
93
  const executeContent = executeMessage.content;
95
94
  const {
96
95
  executionId,
@@ -111,7 +110,7 @@ proto.executeThrow = function executeThrow(executeMessage) {
111
110
  });
112
111
  return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
113
112
  };
114
- proto._onCatchMessage = function onCatchMessage(routingKey, message) {
113
+ EscalationEventDefinition.prototype._onCatchMessage = function onCatchMessage(routingKey, message) {
115
114
  const info = this[kReference];
116
115
  if ((0, _getPropertyValue.default)(message, 'content.message.id') !== info.message.id) return;
117
116
  const output = message.content.message;
@@ -139,7 +138,7 @@ proto._onCatchMessage = function onCatchMessage(routingKey, message) {
139
138
  state: 'catch'
140
139
  }));
141
140
  };
142
- proto._onApiMessage = function onApiMessage(routingKey, message) {
141
+ EscalationEventDefinition.prototype._onApiMessage = function onApiMessage(routingKey, message) {
143
142
  switch (message.properties.type) {
144
143
  case 'escalate':
145
144
  {
@@ -158,13 +157,13 @@ proto._onApiMessage = function onApiMessage(routingKey, message) {
158
157
  }
159
158
  }
160
159
  };
161
- proto._stop = function stop() {
160
+ EscalationEventDefinition.prototype._stop = function stop() {
162
161
  const broker = this.broker,
163
162
  executionId = this.executionId;
164
163
  broker.cancel(`_api-${executionId}`);
165
164
  broker.cancel(`_onescalate-${executionId}`);
166
165
  };
167
- proto._getReferenceInfo = function getReferenceInfo(message) {
166
+ EscalationEventDefinition.prototype._getReferenceInfo = function getReferenceInfo(message) {
168
167
  const referenceElement = this[kReferenceElement];
169
168
  if (!referenceElement) {
170
169
  return {
@@ -180,6 +179,6 @@ proto._getReferenceInfo = function getReferenceInfo(message) {
180
179
  result.description = `${result.message.name} <${result.message.id}>`;
181
180
  return result;
182
181
  };
183
- proto._debug = function debug(msg) {
182
+ EscalationEventDefinition.prototype._debug = function debug(msg) {
184
183
  this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
185
184
  };
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = EventDefinitionExecution;
7
- var _messageHelper = require("../messageHelper");
7
+ var _messageHelper = require("../messageHelper.js");
8
8
  const kCompleted = Symbol.for('completed');
9
9
  const kExecuteMessage = Symbol.for('executeMessage');
10
10
  const kStopped = Symbol.for('stopped');
@@ -18,20 +18,19 @@ function EventDefinitionExecution(activity, eventDefinitions, completedRoutingKe
18
18
  this[kStopped] = false;
19
19
  this[kExecuteMessage] = null;
20
20
  }
21
- const proto = EventDefinitionExecution.prototype;
22
- Object.defineProperty(proto, 'completed', {
21
+ Object.defineProperty(EventDefinitionExecution.prototype, 'completed', {
23
22
  enumerable: true,
24
23
  get() {
25
24
  return this[kCompleted];
26
25
  }
27
26
  });
28
- Object.defineProperty(proto, 'stopped', {
27
+ Object.defineProperty(EventDefinitionExecution.prototype, 'stopped', {
29
28
  enumerable: true,
30
29
  get() {
31
30
  return this[kStopped];
32
31
  }
33
32
  });
34
- proto.execute = function execute(executeMessage) {
33
+ EventDefinitionExecution.prototype.execute = function execute(executeMessage) {
35
34
  const content = executeMessage.content;
36
35
  if (content.isDefinitionScope) return this._executeDefinition(executeMessage);
37
36
  if (!content.isRootScope) return;
@@ -71,7 +70,7 @@ proto.execute = function execute(executeMessage) {
71
70
  broker.publish('execution', 'execute.start', edContent);
72
71
  }
73
72
  };
74
- proto._onApiMessage = function onApiMessage(_, message) {
73
+ EventDefinitionExecution.prototype._onApiMessage = function onApiMessage(_, message) {
75
74
  const messageType = message.properties.type;
76
75
  switch (messageType) {
77
76
  case 'stop':
@@ -79,7 +78,7 @@ proto._onApiMessage = function onApiMessage(_, message) {
79
78
  return this._stop();
80
79
  }
81
80
  };
82
- proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
81
+ EventDefinitionExecution.prototype._onExecuteMessage = function onExecuteMessage(routingKey, message) {
83
82
  switch (routingKey) {
84
83
  case 'execute.completed':
85
84
  {
@@ -103,7 +102,7 @@ proto._onExecuteMessage = function onExecuteMessage(routingKey, message) {
103
102
  }
104
103
  }
105
104
  };
106
- proto._complete = function complete(message) {
105
+ EventDefinitionExecution.prototype._complete = function complete(message) {
107
106
  const {
108
107
  executionId,
109
108
  type,
@@ -122,7 +121,7 @@ proto._complete = function complete(message) {
122
121
  correlationId: message.properties.correlationId
123
122
  });
124
123
  };
125
- proto._executeDefinition = function executeDefinition(message) {
124
+ EventDefinitionExecution.prototype._executeDefinition = function executeDefinition(message) {
126
125
  const {
127
126
  executionId,
128
127
  index
@@ -132,11 +131,11 @@ proto._executeDefinition = function executeDefinition(message) {
132
131
  this._debug(executionId, `execute event definition ${ed.type}, index ${index}`);
133
132
  ed.execute(message);
134
133
  };
135
- proto._stop = function stop() {
134
+ EventDefinitionExecution.prototype._stop = function stop() {
136
135
  this[kStopped] = true;
137
136
  this.broker.cancel('_eventdefinition-execution-execute-tag');
138
137
  this.broker.cancel('_eventdefinition-execution-api-tag');
139
138
  };
140
- proto._debug = function debug(executionId, msg) {
139
+ EventDefinitionExecution.prototype._debug = function debug(executionId, msg) {
141
140
  this.activity.logger.debug(`<${executionId} (${this.id})> ${msg}`);
142
141
  };