rocketmq-client-nodejs-bate 1.0.12

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 (209) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +186 -0
  3. package/dist/client/BaseClient.d.ts +95 -0
  4. package/dist/client/BaseClient.js +324 -0
  5. package/dist/client/ClientId.d.ts +24 -0
  6. package/dist/client/ClientId.js +33 -0
  7. package/dist/client/Logger.d.ts +25 -0
  8. package/dist/client/Logger.js +33 -0
  9. package/dist/client/RpcClient.d.ts +48 -0
  10. package/dist/client/RpcClient.js +219 -0
  11. package/dist/client/RpcClientManager.d.ts +42 -0
  12. package/dist/client/RpcClientManager.js +144 -0
  13. package/dist/client/SessionCredentials.d.ts +21 -0
  14. package/dist/client/SessionCredentials.js +19 -0
  15. package/dist/client/Settings.d.ts +31 -0
  16. package/dist/client/Settings.js +40 -0
  17. package/dist/client/TelemetrySession.d.ts +27 -0
  18. package/dist/client/TelemetrySession.js +110 -0
  19. package/dist/client/UserAgent.d.ts +25 -0
  20. package/dist/client/UserAgent.js +47 -0
  21. package/dist/client/index.d.ts +26 -0
  22. package/dist/client/index.js +43 -0
  23. package/dist/consumer/Assignment.d.ts +23 -0
  24. package/dist/consumer/Assignment.js +40 -0
  25. package/dist/consumer/Assignments.d.ts +24 -0
  26. package/dist/consumer/Assignments.js +47 -0
  27. package/dist/consumer/ConsumeResult.d.ts +20 -0
  28. package/dist/consumer/ConsumeResult.js +25 -0
  29. package/dist/consumer/ConsumeService.d.ts +28 -0
  30. package/dist/consumer/ConsumeService.js +49 -0
  31. package/dist/consumer/ConsumeTask.d.ts +24 -0
  32. package/dist/consumer/ConsumeTask.js +40 -0
  33. package/dist/consumer/Consumer.d.ts +38 -0
  34. package/dist/consumer/Consumer.js +111 -0
  35. package/dist/consumer/FifoConsumeService.d.ts +25 -0
  36. package/dist/consumer/FifoConsumeService.js +123 -0
  37. package/dist/consumer/FilterExpression.d.ts +25 -0
  38. package/dist/consumer/FilterExpression.js +40 -0
  39. package/dist/consumer/MessageListener.d.ts +21 -0
  40. package/dist/consumer/MessageListener.js +19 -0
  41. package/dist/consumer/ProcessQueue.d.ts +39 -0
  42. package/dist/consumer/ProcessQueue.js +286 -0
  43. package/dist/consumer/PushConsumer.d.ts +68 -0
  44. package/dist/consumer/PushConsumer.js +377 -0
  45. package/dist/consumer/PushSubscriptionSettings.d.ts +31 -0
  46. package/dist/consumer/PushSubscriptionSettings.js +97 -0
  47. package/dist/consumer/SimpleConsumer.d.ts +50 -0
  48. package/dist/consumer/SimpleConsumer.js +122 -0
  49. package/dist/consumer/SimpleSubscriptionSettings.d.ts +28 -0
  50. package/dist/consumer/SimpleSubscriptionSettings.js +57 -0
  51. package/dist/consumer/StandardConsumeService.d.ts +24 -0
  52. package/dist/consumer/StandardConsumeService.js +42 -0
  53. package/dist/consumer/SubscriptionLoadBalancer.d.ts +23 -0
  54. package/dist/consumer/SubscriptionLoadBalancer.js +46 -0
  55. package/dist/consumer/index.d.ts +32 -0
  56. package/dist/consumer/index.js +49 -0
  57. package/dist/exception/BadRequestException.d.ts +20 -0
  58. package/dist/exception/BadRequestException.js +28 -0
  59. package/dist/exception/ClientException.d.ts +20 -0
  60. package/dist/exception/ClientException.js +31 -0
  61. package/dist/exception/ForbiddenException.d.ts +20 -0
  62. package/dist/exception/ForbiddenException.js +28 -0
  63. package/dist/exception/InternalErrorException.d.ts +20 -0
  64. package/dist/exception/InternalErrorException.js +28 -0
  65. package/dist/exception/NotFoundException.d.ts +20 -0
  66. package/dist/exception/NotFoundException.js +28 -0
  67. package/dist/exception/PayloadTooLargeException.d.ts +20 -0
  68. package/dist/exception/PayloadTooLargeException.js +28 -0
  69. package/dist/exception/PaymentRequiredException.d.ts +20 -0
  70. package/dist/exception/PaymentRequiredException.js +28 -0
  71. package/dist/exception/ProxyTimeoutException.d.ts +20 -0
  72. package/dist/exception/ProxyTimeoutException.js +28 -0
  73. package/dist/exception/RequestHeaderFieldsTooLargeException.d.ts +20 -0
  74. package/dist/exception/RequestHeaderFieldsTooLargeException.js +28 -0
  75. package/dist/exception/StatusChecker.d.ts +20 -0
  76. package/dist/exception/StatusChecker.js +98 -0
  77. package/dist/exception/TooManyRequestsException.d.ts +20 -0
  78. package/dist/exception/TooManyRequestsException.js +28 -0
  79. package/dist/exception/UnauthorizedException.d.ts +20 -0
  80. package/dist/exception/UnauthorizedException.js +28 -0
  81. package/dist/exception/UnsupportedException.d.ts +20 -0
  82. package/dist/exception/UnsupportedException.js +28 -0
  83. package/dist/exception/index.d.ts +29 -0
  84. package/dist/exception/index.js +46 -0
  85. package/dist/index.d.ts +22 -0
  86. package/dist/index.js +39 -0
  87. package/dist/message/Message.d.ts +38 -0
  88. package/dist/message/Message.js +57 -0
  89. package/dist/message/MessageId.d.ts +59 -0
  90. package/dist/message/MessageId.js +123 -0
  91. package/dist/message/MessageView.d.ts +38 -0
  92. package/dist/message/MessageView.js +90 -0
  93. package/dist/message/PublishingMessage.d.ts +30 -0
  94. package/dist/message/PublishingMessage.js +100 -0
  95. package/dist/message/index.d.ts +20 -0
  96. package/dist/message/index.js +37 -0
  97. package/dist/producer/Producer.d.ts +55 -0
  98. package/dist/producer/Producer.js +318 -0
  99. package/dist/producer/PublishingLoadBalancer.d.ts +24 -0
  100. package/dist/producer/PublishingLoadBalancer.js +82 -0
  101. package/dist/producer/PublishingSettings.d.ts +28 -0
  102. package/dist/producer/PublishingSettings.js +70 -0
  103. package/dist/producer/RecallReceipt.d.ts +25 -0
  104. package/dist/producer/RecallReceipt.js +34 -0
  105. package/dist/producer/SendReceipt.d.ts +29 -0
  106. package/dist/producer/SendReceipt.js +60 -0
  107. package/dist/producer/Transaction.d.ts +28 -0
  108. package/dist/producer/Transaction.js +70 -0
  109. package/dist/producer/TransactionChecker.d.ts +21 -0
  110. package/dist/producer/TransactionChecker.js +19 -0
  111. package/dist/producer/index.d.ts +22 -0
  112. package/dist/producer/index.js +40 -0
  113. package/dist/retry/ExponentialBackoffRetryPolicy.d.ts +27 -0
  114. package/dist/retry/ExponentialBackoffRetryPolicy.js +64 -0
  115. package/dist/retry/RetryPolicy.d.ts +46 -0
  116. package/dist/retry/RetryPolicy.js +19 -0
  117. package/dist/retry/index.d.ts +18 -0
  118. package/dist/retry/index.js +35 -0
  119. package/dist/route/Broker.d.ts +25 -0
  120. package/dist/route/Broker.js +40 -0
  121. package/dist/route/Endpoints.d.ts +30 -0
  122. package/dist/route/Endpoints.js +71 -0
  123. package/dist/route/MessageQueue.d.ts +27 -0
  124. package/dist/route/MessageQueue.js +47 -0
  125. package/dist/route/TopicRouteData.d.ts +24 -0
  126. package/dist/route/TopicRouteData.js +37 -0
  127. package/dist/route/index.d.ts +20 -0
  128. package/dist/route/index.js +37 -0
  129. package/dist/util/index.d.ts +35 -0
  130. package/dist/util/index.js +88 -0
  131. package/package.json +62 -0
  132. package/proto/apache/rocketmq/v2/admin.proto +43 -0
  133. package/proto/apache/rocketmq/v2/admin_grpc_pb.d.ts +41 -0
  134. package/proto/apache/rocketmq/v2/admin_grpc_pb.js +60 -0
  135. package/proto/apache/rocketmq/v2/admin_pb.d.ts +56 -0
  136. package/proto/apache/rocketmq/v2/admin_pb.js +340 -0
  137. package/proto/apache/rocketmq/v2/definition.proto +570 -0
  138. package/proto/apache/rocketmq/v2/definition_grpc_pb.js +1 -0
  139. package/proto/apache/rocketmq/v2/definition_pb.d.ts +885 -0
  140. package/proto/apache/rocketmq/v2/definition_pb.js +6141 -0
  141. package/proto/apache/rocketmq/v2/service.proto +443 -0
  142. package/proto/apache/rocketmq/v2/service_grpc_pb.d.ts +294 -0
  143. package/proto/apache/rocketmq/v2/service_grpc_pb.js +637 -0
  144. package/proto/apache/rocketmq/v2/service_pb.d.ts +1249 -0
  145. package/proto/apache/rocketmq/v2/service_pb.js +9723 -0
  146. package/src/client/BaseClient.ts +404 -0
  147. package/src/client/ClientId.ts +31 -0
  148. package/src/client/Logger.ts +36 -0
  149. package/src/client/RpcClient.ts +258 -0
  150. package/src/client/RpcClientManager.ts +180 -0
  151. package/src/client/SessionCredentials.ts +22 -0
  152. package/src/client/Settings.ts +46 -0
  153. package/src/client/TelemetrySession.ts +130 -0
  154. package/src/client/UserAgent.ts +45 -0
  155. package/src/client/index.ts +27 -0
  156. package/src/consumer/Assignment.ts +39 -0
  157. package/src/consumer/Assignments.ts +46 -0
  158. package/src/consumer/ConsumeResult.ts +21 -0
  159. package/src/consumer/ConsumeService.ts +54 -0
  160. package/src/consumer/ConsumeTask.ts +40 -0
  161. package/src/consumer/Consumer.ts +129 -0
  162. package/src/consumer/FifoConsumeService.ts +136 -0
  163. package/src/consumer/FilterExpression.ts +42 -0
  164. package/src/consumer/MessageListener.ts +23 -0
  165. package/src/consumer/ProcessQueue.ts +326 -0
  166. package/src/consumer/PushConsumer.ts +473 -0
  167. package/src/consumer/PushSubscriptionSettings.ts +123 -0
  168. package/src/consumer/SimpleConsumer.ts +153 -0
  169. package/src/consumer/SimpleSubscriptionSettings.ts +64 -0
  170. package/src/consumer/StandardConsumeService.ts +44 -0
  171. package/src/consumer/SubscriptionLoadBalancer.ts +47 -0
  172. package/src/consumer/index.ts +33 -0
  173. package/src/exception/BadRequestException.ts +25 -0
  174. package/src/exception/ClientException.ts +29 -0
  175. package/src/exception/ForbiddenException.ts +25 -0
  176. package/src/exception/InternalErrorException.ts +25 -0
  177. package/src/exception/NotFoundException.ts +25 -0
  178. package/src/exception/PayloadTooLargeException.ts +25 -0
  179. package/src/exception/PaymentRequiredException.ts +25 -0
  180. package/src/exception/ProxyTimeoutException.ts +25 -0
  181. package/src/exception/RequestHeaderFieldsTooLargeException.ts +25 -0
  182. package/src/exception/StatusChecker.ts +94 -0
  183. package/src/exception/TooManyRequestsException.ts +25 -0
  184. package/src/exception/UnauthorizedException.ts +25 -0
  185. package/src/exception/UnsupportedException.ts +25 -0
  186. package/src/exception/index.ts +30 -0
  187. package/src/index.ts +23 -0
  188. package/src/message/Message.ts +67 -0
  189. package/src/message/MessageId.ts +123 -0
  190. package/src/message/MessageView.ts +94 -0
  191. package/src/message/PublishingMessage.ts +104 -0
  192. package/src/message/index.ts +21 -0
  193. package/src/producer/Producer.ts +388 -0
  194. package/src/producer/PublishingLoadBalancer.ts +85 -0
  195. package/src/producer/PublishingSettings.ts +78 -0
  196. package/src/producer/RecallReceipt.ts +32 -0
  197. package/src/producer/SendReceipt.ts +63 -0
  198. package/src/producer/Transaction.ts +86 -0
  199. package/src/producer/TransactionChecker.ts +23 -0
  200. package/src/producer/index.ts +24 -0
  201. package/src/retry/ExponentialBackoffRetryPolicy.ts +76 -0
  202. package/src/retry/RetryPolicy.ts +51 -0
  203. package/src/retry/index.ts +19 -0
  204. package/src/route/Broker.ts +39 -0
  205. package/src/route/Endpoints.ts +70 -0
  206. package/src/route/MessageQueue.ts +49 -0
  207. package/src/route/TopicRouteData.ts +38 -0
  208. package/src/route/index.ts +21 -0
  209. package/src/util/index.ts +83 -0
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.SimpleConsumer = void 0;
20
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
21
+ const service_pb_1 = require("../../proto/apache/rocketmq/v2/service_pb");
22
+ const util_1 = require("../util");
23
+ const FilterExpression_1 = require("./FilterExpression");
24
+ const SimpleSubscriptionSettings_1 = require("./SimpleSubscriptionSettings");
25
+ const SubscriptionLoadBalancer_1 = require("./SubscriptionLoadBalancer");
26
+ const Consumer_1 = require("./Consumer");
27
+ const RANDOM_INDEX = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
28
+ class SimpleConsumer extends Consumer_1.Consumer {
29
+ #simpleSubscriptionSettings;
30
+ #subscriptionExpressions = new Map();
31
+ #subscriptionRouteDataCache = new Map();
32
+ #awaitDuration;
33
+ #topicIndex = RANDOM_INDEX;
34
+ constructor(options) {
35
+ options.topics = Array.from(options.subscriptions.keys());
36
+ super(options);
37
+ for (const [topic, filter] of options.subscriptions.entries()) {
38
+ if (typeof filter === 'string') {
39
+ // filter is tag string
40
+ this.#subscriptionExpressions.set(topic, new FilterExpression_1.FilterExpression(filter));
41
+ }
42
+ else {
43
+ this.#subscriptionExpressions.set(topic, filter);
44
+ }
45
+ }
46
+ this.#awaitDuration = options.awaitDuration ?? 30000;
47
+ this.#simpleSubscriptionSettings = new SimpleSubscriptionSettings_1.SimpleSubscriptionSettings(options.namespace, this.clientId, this.endpoints, this.consumerGroup, this.requestTimeout, this.#awaitDuration, this.#subscriptionExpressions);
48
+ }
49
+ getSettings() {
50
+ return this.#simpleSubscriptionSettings;
51
+ }
52
+ wrapHeartbeatRequest() {
53
+ return new service_pb_1.HeartbeatRequest()
54
+ .setClientType(definition_pb_1.ClientType.SIMPLE_CONSUMER)
55
+ .setGroup((0, util_1.createResource)(this.consumerGroup));
56
+ }
57
+ wrapNotifyClientTerminationRequest() {
58
+ return new service_pb_1.NotifyClientTerminationRequest()
59
+ .setGroup((0, util_1.createResource)(this.consumerGroup));
60
+ }
61
+ onTopicRouteDataUpdate(topic, topicRouteData) {
62
+ this.#updateSubscriptionLoadBalancer(topic, topicRouteData);
63
+ }
64
+ #updateSubscriptionLoadBalancer(topic, topicRouteData) {
65
+ let subscriptionLoadBalancer = this.#subscriptionRouteDataCache.get(topic);
66
+ if (!subscriptionLoadBalancer) {
67
+ subscriptionLoadBalancer = new SubscriptionLoadBalancer_1.SubscriptionLoadBalancer(topicRouteData);
68
+ }
69
+ else {
70
+ subscriptionLoadBalancer = subscriptionLoadBalancer.update(topicRouteData);
71
+ }
72
+ this.#subscriptionRouteDataCache.set(topic, subscriptionLoadBalancer);
73
+ return subscriptionLoadBalancer;
74
+ }
75
+ async #getSubscriptionLoadBalancer(topic) {
76
+ let loadBalancer = this.#subscriptionRouteDataCache.get(topic);
77
+ if (!loadBalancer) {
78
+ const topicRouteData = await this.getRouteData(topic);
79
+ loadBalancer = this.#updateSubscriptionLoadBalancer(topic, topicRouteData);
80
+ }
81
+ return loadBalancer;
82
+ }
83
+ async subscribe(topic, filterExpression) {
84
+ await this.getRouteData(topic);
85
+ this.#subscriptionExpressions.set(topic, filterExpression);
86
+ }
87
+ unsubscribe(topic) {
88
+ this.#subscriptionExpressions.delete(topic);
89
+ }
90
+ async receive(maxMessageNum = 10, invisibleDuration = 15000) {
91
+ if (maxMessageNum <= 0) {
92
+ throw new Error(`maxMessageNum must be greater than 0, but got ${maxMessageNum}`);
93
+ }
94
+ const topic = this.#nextTopic();
95
+ const filterExpression = this.#subscriptionExpressions.get(topic);
96
+ if (!filterExpression) {
97
+ throw new Error(`No subscription found for topic=${topic}, please subscribe first`);
98
+ }
99
+ const loadBalancer = await this.#getSubscriptionLoadBalancer(topic);
100
+ const mq = loadBalancer.takeMessageQueue();
101
+ const request = this.wrapReceiveMessageRequest(maxMessageNum, mq, filterExpression, invisibleDuration, this.#awaitDuration);
102
+ return await this.receiveMessage(request, mq, this.#awaitDuration);
103
+ }
104
+ async ack(message) {
105
+ await this.ackMessage(message);
106
+ }
107
+ async changeInvisibleDuration(message, invisibleDuration) {
108
+ const response = await this.invisibleDuration(message, invisibleDuration);
109
+ // Refresh receipt handle manually
110
+ message.receiptHandle = response;
111
+ }
112
+ #nextTopic() {
113
+ const topics = Array.from(this.#subscriptionExpressions.keys());
114
+ if (topics.length === 0) {
115
+ throw new Error('No subscriptions available to receive messages');
116
+ }
117
+ const index = Math.abs(this.#topicIndex++ % topics.length);
118
+ return topics[index];
119
+ }
120
+ }
121
+ exports.SimpleConsumer = SimpleConsumer;
122
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2ltcGxlQ29uc3VtZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uc3VtZXIvU2ltcGxlQ29uc3VtZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBRUgsZ0ZBQTBFO0FBQzFFLDBFQUE2RztBQUc3RyxrQ0FBeUM7QUFDekMseURBQXNEO0FBQ3RELDZFQUEwRTtBQUMxRSx5RUFBc0U7QUFDdEUseUNBQXVEO0FBRXZELE1BQU0sWUFBWSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLE1BQU0sQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO0FBa0J6RSxNQUFhLGNBQWUsU0FBUSxtQkFBUTtJQUNqQywyQkFBMkIsQ0FBNkI7SUFDeEQsd0JBQXdCLEdBQUcsSUFBSSxHQUFHLEVBQTRCLENBQUM7SUFDL0QsMkJBQTJCLEdBQUcsSUFBSSxHQUFHLEVBQW9DLENBQUM7SUFDMUUsY0FBYyxDQUFTO0lBQ2hDLFdBQVcsR0FBRyxZQUFZLENBQUM7SUFFM0IsWUFBWSxPQUE4QjtRQUN4QyxPQUFPLENBQUMsTUFBTSxHQUFHLEtBQUssQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLGFBQWEsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFDO1FBQzFELEtBQUssQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUNmLEtBQUssTUFBTSxDQUFFLEtBQUssRUFBRSxNQUFNLENBQUUsSUFBSS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ssQ0FBQyxDQUFDO0lBQ3ZCLENBQUM7Q0FDRjtBQTNHRCx3Q0EyR0MifQ==
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Settings as SettingsPB } from '../../proto/apache/rocketmq/v2/definition_pb';
18
+ import { Endpoints } from '../route';
19
+ import { Settings } from '../client';
20
+ import { FilterExpression } from './FilterExpression';
21
+ export declare class SimpleSubscriptionSettings extends Settings {
22
+ readonly longPollingTimeout: number;
23
+ readonly group: string;
24
+ readonly subscriptionExpressions: Map<string, FilterExpression>;
25
+ constructor(namespace: string, clientId: string, accessPoint: Endpoints, group: string, requestTimeout: number, longPollingTimeout: number, subscriptionExpressions: Map<string, FilterExpression>);
26
+ toProtobuf(): SettingsPB;
27
+ sync(settings: SettingsPB): void;
28
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.SimpleSubscriptionSettings = void 0;
20
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
21
+ const client_1 = require("../client");
22
+ const util_1 = require("../util");
23
+ class SimpleSubscriptionSettings extends client_1.Settings {
24
+ longPollingTimeout;
25
+ group;
26
+ subscriptionExpressions;
27
+ constructor(namespace, clientId, accessPoint, group, requestTimeout, longPollingTimeout, subscriptionExpressions) {
28
+ super(namespace, clientId, definition_pb_1.ClientType.SIMPLE_CONSUMER, accessPoint, requestTimeout);
29
+ this.longPollingTimeout = longPollingTimeout;
30
+ this.group = group;
31
+ this.subscriptionExpressions = subscriptionExpressions;
32
+ }
33
+ toProtobuf() {
34
+ const subscription = new definition_pb_1.Subscription()
35
+ .setGroup((0, util_1.createResource)(this.group))
36
+ .setLongPollingTimeout((0, util_1.createDuration)(this.longPollingTimeout));
37
+ for (const [topic, filterExpression] of this.subscriptionExpressions.entries()) {
38
+ subscription.addSubscriptions()
39
+ .setTopic((0, util_1.createResource)(topic))
40
+ .setExpression(filterExpression.toProtobuf());
41
+ }
42
+ return new definition_pb_1.Settings()
43
+ .setClientType(this.clientType)
44
+ .setAccessPoint(this.accessPoint.toProtobuf())
45
+ .setRequestTimeout((0, util_1.createDuration)(this.requestTimeout))
46
+ .setSubscription(subscription)
47
+ .setUserAgent(client_1.UserAgent.INSTANCE.toProtobuf());
48
+ }
49
+ sync(settings) {
50
+ if (settings.getPubSubCase() !== definition_pb_1.Settings.PubSubCase.SUBSCRIPTION) {
51
+ // log.error("[Bug] Issued settings not match with the client type, clientId={}, pubSubCase={}, "
52
+ // + "clientType={}", clientId, pubSubCase, clientType);
53
+ }
54
+ }
55
+ }
56
+ exports.SimpleSubscriptionSettings = SimpleSubscriptionSettings;
57
+ //# sourceMappingURL=data:application/json;base64,eyJ2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SyxFQUFFLGdCQUFnQixDQUFFLElBQUksSUFBSSxDQUFDLHVCQUF1QixDQUFDLE9BQU8sRUFBRSxFQUFFLENBQUM7WUFDakYsWUFBWSxDQUFDLGdCQUFnQixFQUFFO2lCQUM1QixRQUFRLENBQUMsSUFBQSxxQkFBYyxFQUFDLEtBQUssQ0FBQyxDQUFDO2lCQUMvQixhQUFhLENBQUMsZ0JBQWdCLENBQUMsVUFBVSxFQUFFLENBQUMsQ0FBQztRQUNsRCxDQUFDO1FBQ0QsT0FBTyxJQUFJLHdCQUFVLEVBQUU7YUFDcEIsYUFBYSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUM7YUFDOUIsY0FBYyxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsVUFBVSxFQUFFLENBQUM7YUFDN0MsaUJBQWlCLENBQUMsSUFBQSxxQkFBYyxFQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQzthQUN0RCxlQUFlLENBQUMsWUFBWSxDQUFDO2FBQzdCLFlBQVksQ0FBQyxrQkFBUyxDQUFDLFFBQVEsQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO0lBQ25ELENBQUM7SUFFRCxJQUFJLENBQUMsUUFBb0I7UUFDdkIsSUFBSSxRQUFRLENBQUMsYUFBYSxFQUFFLEtBQUssd0JBQVUsQ0FBQyxVQUFVLENBQUMsWUFBWSxFQUFFLENBQUM7WUFDcEUsaUdBQWlHO1lBQ2pHLDhEQUE4RDtRQUNoRSxDQUFDO0lBQ0gsQ0FBQztDQUNGO0FBcENELGdFQW9DQyJ9
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { MessageView } from '../message';
18
+ import { ConsumeService } from './ConsumeService';
19
+ import { MessageListener } from './MessageListener';
20
+ import type { ProcessQueue } from './ProcessQueue';
21
+ export declare class StandardConsumeService extends ConsumeService {
22
+ constructor(clientId: string, messageListener: MessageListener);
23
+ consume(pq: ProcessQueue, messageViews: MessageView[]): void;
24
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.StandardConsumeService = void 0;
20
+ const ConsumeService_1 = require("./ConsumeService");
21
+ class StandardConsumeService extends ConsumeService_1.ConsumeService {
22
+ constructor(clientId, messageListener) {
23
+ super(clientId, messageListener);
24
+ }
25
+ consume(pq, messageViews) {
26
+ for (const messageView of messageViews) {
27
+ if (messageView.corrupted) {
28
+ pq.discardMessage(messageView);
29
+ continue;
30
+ }
31
+ this.consumeMessage(messageView)
32
+ .then(result => {
33
+ pq.eraseMessage(messageView, result);
34
+ })
35
+ .catch(() => {
36
+ // Should never reach here.
37
+ });
38
+ }
39
+ }
40
+ }
41
+ exports.StandardConsumeService = StandardConsumeService;
42
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU3RhbmRhcmRDb25zdW1lU2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb25zdW1lci9TdGFuZGFyZENvbnN1bWVTZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQUdILHFEQUFrRDtBQUlsRCxNQUFhLHNCQUF1QixTQUFRLCtCQUFjO0lBQ3hELFlBQVksUUFBZ0IsRUFBRSxlQUFnQztRQUM1RCxLQUFLLENBQUMsUUFBUSxFQUFFLGVBQWUsQ0FBQyxDQUFDO0lBQ25DLENBQUM7SUFFRCxPQUFPLENBQUMsRUFBZ0IsRUFBRSxZQUEyQjtRQUNuRCxLQUFLLE1BQU0sV0FBVyxJQUFJLFlBQVksRUFBRSxDQUFDO1lBQ3ZDLElBQUksV0FBVyxDQUFDLFNBQVMsRUFBRSxDQUFDO2dCQUMxQixFQUFFLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFDO2dCQUMvQixTQUFTO1lBQ1gsQ0FBQztZQUVELElBQUksQ0FBQyxjQUFjLENBQUMsV0FBVyxDQUFDO2lCQUM3QixJQUFJLENBQUMsTUFBTSxDQUFDLEVBQUU7Z0JBQ2IsRUFBRSxDQUFDLFlBQVksQ0FBQyxXQUFXLEVBQUUsTUFBTSxDQUFDLENBQUM7WUFDdkMsQ0FBQyxDQUFDO2lCQUNELEtBQUssQ0FBQyxHQUFHLEVBQUU7Z0JBQ1YsMkJBQTJCO1lBQzdCLENBQUMsQ0FBQyxDQUFDO1FBQ1AsQ0FBQztJQUNILENBQUM7Q0FDRjtBQXJCRCx3REFxQkMifQ==
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { MessageQueue, TopicRouteData } from '../route';
18
+ export declare class SubscriptionLoadBalancer {
19
+ #private;
20
+ constructor(topicRouteData: TopicRouteData, index?: number);
21
+ update(topicRouteData: TopicRouteData): SubscriptionLoadBalancer;
22
+ takeMessageQueue(): MessageQueue;
23
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.SubscriptionLoadBalancer = void 0;
20
+ const node_crypto_1 = require("node:crypto");
21
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
22
+ const util_1 = require("../util");
23
+ class SubscriptionLoadBalancer {
24
+ #index;
25
+ #messageQueues;
26
+ constructor(topicRouteData, index) {
27
+ this.#messageQueues = topicRouteData.messageQueues.filter(mq => {
28
+ return mq.queueId === util_1.MASTER_BROKER_ID && (mq.permission === definition_pb_1.Permission.READ || mq.permission === definition_pb_1.Permission.READ_WRITE);
29
+ });
30
+ this.#index = index === undefined ? (0, node_crypto_1.randomInt)(this.#messageQueues.length) : index;
31
+ if (this.#messageQueues.length === 0) {
32
+ throw new Error(`No readable message queue found, topicRouteData=${JSON.stringify(topicRouteData)}`);
33
+ }
34
+ }
35
+ update(topicRouteData) {
36
+ return new SubscriptionLoadBalancer(topicRouteData, this.#index);
37
+ }
38
+ takeMessageQueue() {
39
+ if (this.#index >= this.#messageQueues.length) {
40
+ this.#index = 0;
41
+ }
42
+ return this.#messageQueues[this.#index++];
43
+ }
44
+ }
45
+ exports.SubscriptionLoadBalancer = SubscriptionLoadBalancer;
46
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU3Vic2NyaXB0aW9uTG9hZEJhbGFuY2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnN1bWVyL1N1YnNjcmlwdGlvbkxvYWRCYWxhbmNlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFFSCw2Q0FBd0M7QUFDeEMsZ0ZBQTBFO0FBRTFFLGtDQUEyQztBQUUzQyxNQUFhLHdCQUF3QjtJQUNuQyxNQUFNLENBQVM7SUFDZixjQUFjLENBQWlCO0lBRS9CLFlBQVksY0FBOEIsRUFBRSxLQUFjO1FBQ3hELElBQUksQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFDLGFBQWEsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLEVBQUU7WUFDN0QsT0FBTyxFQUFFLENBQUMsT0FBTyxLQUFLLHVCQUFnQixJQUFJLENBQUMsRUFBRSxDQUFDLFVBQVUsS0FBSywwQkFBVSxDQUFDLElBQUksSUFBSSxFQUFFLENBQUMsVUFBVSxLQUFLLDBCQUFVLENBQUMsVUFBVSxDQUFDLENBQUM7UUFDM0gsQ0FBQyxDQUFDLENBQUM7UUFDSCxJQUFJLENBQUMsTUFBTSxHQUFHLEtBQUssS0FBSyxTQUFTLENBQUMsQ0FBQyxDQUFDLElBQUEsdUJBQVMsRUFBQyxJQUFJLENBQUMsY0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUM7UUFDbEYsSUFBSSxJQUFJLENBQUMsY0FBYyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUUsQ0FBQztZQUNyQyxNQUFNLElBQUksS0FBSyxDQUFDLG1EQUFtRCxJQUFJLENBQUMsU0FBUyxDQUFDLGNBQWMsQ0FBQyxFQUFFLENBQUMsQ0FBQztRQUN2RyxDQUFDO0lBQ0gsQ0FBQztJQUVELE1BQU0sQ0FBQyxjQUE4QjtRQUNuQyxPQUFPLElBQUksd0JBQXdCLENBQUMsY0FBYyxFQUFFLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNuRSxDQUFDO0lBRUQsZ0JBQWdCO1FBQ2QsSUFBSSxJQUFJLENBQUMsTUFBTSxJQUFJLElBQUksQ0FBQyxjQUFjLENBQUMsTUFBTSxFQUFFLENBQUM7WUFDOUMsSUFBSSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7UUFDbEIsQ0FBQztRQUNELE9BQU8sSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsQ0FBQztJQUM1QyxDQUFDO0NBQ0Y7QUF4QkQsNERBd0JDIn0=
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './Consumer';
18
+ export * from './FilterExpression';
19
+ export * from './SimpleConsumer';
20
+ export * from './SimpleSubscriptionSettings';
21
+ export * from './SubscriptionLoadBalancer';
22
+ export * from './ConsumeResult';
23
+ export * from './MessageListener';
24
+ export * from './Assignment';
25
+ export * from './Assignments';
26
+ export * from './PushSubscriptionSettings';
27
+ export * from './ConsumeTask';
28
+ export * from './ConsumeService';
29
+ export * from './StandardConsumeService';
30
+ export * from './FifoConsumeService';
31
+ export * from './ProcessQueue';
32
+ export * from './PushConsumer';
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ __exportStar(require("./Consumer"), exports);
34
+ __exportStar(require("./FilterExpression"), exports);
35
+ __exportStar(require("./SimpleConsumer"), exports);
36
+ __exportStar(require("./SimpleSubscriptionSettings"), exports);
37
+ __exportStar(require("./SubscriptionLoadBalancer"), exports);
38
+ __exportStar(require("./ConsumeResult"), exports);
39
+ __exportStar(require("./MessageListener"), exports);
40
+ __exportStar(require("./Assignment"), exports);
41
+ __exportStar(require("./Assignments"), exports);
42
+ __exportStar(require("./PushSubscriptionSettings"), exports);
43
+ __exportStar(require("./ConsumeTask"), exports);
44
+ __exportStar(require("./ConsumeService"), exports);
45
+ __exportStar(require("./StandardConsumeService"), exports);
46
+ __exportStar(require("./FifoConsumeService"), exports);
47
+ __exportStar(require("./ProcessQueue"), exports);
48
+ __exportStar(require("./PushConsumer"), exports);
49
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uc3VtZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILDZDQUEyQjtBQUMzQixxREFBbUM7QUFDbkMsbURBQWlDO0FBQ2pDLCtEQUE2QztBQUM3Qyw2REFBMkM7QUFDM0Msa0RBQWdDO0FBQ2hDLG9EQUFrQztBQUNsQywrQ0FBNkI7QUFDN0IsZ0RBQThCO0FBQzlCLDZEQUEyQztBQUMzQyxnREFBOEI7QUFDOUIsbURBQWlDO0FBQ2pDLDJEQUF5QztBQUN6Qyx1REFBcUM7QUFDckMsaURBQStCO0FBQy9CLGlEQUErQiJ9
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ClientException } from './ClientException';
18
+ export declare class BadRequestException extends ClientException {
19
+ constructor(code: number, message: string, requestId?: string);
20
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.BadRequestException = void 0;
20
+ const ClientException_1 = require("./ClientException");
21
+ class BadRequestException extends ClientException_1.ClientException {
22
+ constructor(code, message, requestId) {
23
+ super(code, message, requestId);
24
+ this.name = 'BadRequestException';
25
+ }
26
+ }
27
+ exports.BadRequestException = BadRequestException;
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmFkUmVxdWVzdEV4Y2VwdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9leGNlcHRpb24vQmFkUmVxdWVzdEV4Y2VwdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFFSCx1REFBb0Q7QUFFcEQsTUFBYSxtQkFBb0IsU0FBUSxpQ0FBZTtJQUN0RCxZQUFZLElBQVksRUFBRSxPQUFlLEVBQUUsU0FBa0I7UUFDM0QsS0FBSyxDQUFDLElBQUksRUFBRSxPQUFPLEVBQUUsU0FBUyxDQUFDLENBQUM7UUFDaEMsSUFBSSxDQUFDLElBQUksR0FBRyxxQkFBcUIsQ0FBQztJQUNwQyxDQUFDO0NBQ0Y7QUFMRCxrREFLQyJ9
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare class ClientException extends Error {
18
+ code: number;
19
+ constructor(code: number, message: string, requestId?: string);
20
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ClientException = void 0;
20
+ const REQUEST_ID_KEY = 'request-id';
21
+ const RESPONSE_CODE_KEY = 'response-code';
22
+ class ClientException extends Error {
23
+ code;
24
+ constructor(code, message, requestId) {
25
+ super(`[${REQUEST_ID_KEY}=${requestId}, ${RESPONSE_CODE_KEY}=${code}] ${message}`);
26
+ this.code = code;
27
+ this.name = 'ClientException';
28
+ }
29
+ }
30
+ exports.ClientException = ClientException;
31
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2xpZW50RXhjZXB0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2V4Y2VwdGlvbi9DbGllbnRFeGNlcHRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBRUgsTUFBTSxjQUFjLEdBQUcsWUFBWSxDQUFDO0FBQ3BDLE1BQU0saUJBQWlCLEdBQUcsZUFBZSxDQUFDO0FBRTFDLE1BQWEsZUFBZ0IsU0FBUSxLQUFLO0lBQ3hDLElBQUksQ0FBUztJQUViLFlBQVksSUFBWSxFQUFFLE9BQWUsRUFBRSxTQUFrQjtRQUMzRCxLQUFLLENBQUMsSUFBSSxjQUFjLElBQUksU0FBUyxLQUFLLGlCQUFpQixJQUFJLElBQUksS0FBSyxPQUFPLEVBQUUsQ0FBQyxDQUFDO1FBQ25GLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxJQUFJLEdBQUcsaUJBQWlCLENBQUM7SUFDaEMsQ0FBQztDQUNGO0FBUkQsMENBUUMifQ==
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ClientException } from './ClientException';
18
+ export declare class ForbiddenException extends ClientException {
19
+ constructor(code: number, message: string, requestId?: string);
20
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ForbiddenException = void 0;
20
+ const ClientException_1 = require("./ClientException");
21
+ class ForbiddenException extends ClientException_1.ClientException {
22
+ constructor(code, message, requestId) {
23
+ super(code, message, requestId);
24
+ this.name = 'ForbiddenException';
25
+ }
26
+ }
27
+ exports.ForbiddenException = ForbiddenException;
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRm9yYmlkZGVuRXhjZXB0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2V4Y2VwdGlvbi9Gb3JiaWRkZW5FeGNlcHRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBRUgsdURBQW9EO0FBRXBELE1BQWEsa0JBQW1CLFNBQVEsaUNBQWU7SUFDckQsWUFBWSxJQUFZLEVBQUUsT0FBZSxFQUFFLFNBQWtCO1FBQzNELEtBQUssQ0FBQyxJQUFJLEVBQUUsT0FBTyxFQUFFLFNBQVMsQ0FBQyxDQUFDO1FBQ2hDLElBQUksQ0FBQyxJQUFJLEdBQUcsb0JBQW9CLENBQUM7SUFDbkMsQ0FBQztDQUNGO0FBTEQsZ0RBS0MifQ==
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ClientException } from './ClientException';
18
+ export declare class InternalErrorException extends ClientException {
19
+ constructor(code: number, message: string, requestId?: string);
20
+ }