rabbitmq-sdk 0.0.1-security → 1.2.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.
Potentially problematic release.
This version of rabbitmq-sdk might be problematic. Click here for more details.
- package/.eslintrc.js +23 -0
- package/.kiro/specs/sdk-rabbitmq/design.md +369 -0
- package/.kiro/specs/sdk-rabbitmq/requirements.md +97 -0
- package/.kiro/specs/sdk-rabbitmq/tasks.md +248 -0
- package/README.md +273 -5
- package/bun.lock +790 -0
- package/config.example.json +13 -0
- package/dist/components/ConfigurationManager.d.ts +35 -0
- package/dist/components/ConfigurationManager.d.ts.map +1 -0
- package/dist/components/ConfigurationManager.js +118 -0
- package/dist/components/ConfigurationManager.js.map +1 -0
- package/dist/components/ConnectionManager.d.ts +93 -0
- package/dist/components/ConnectionManager.d.ts.map +1 -0
- package/dist/components/ConnectionManager.js +349 -0
- package/dist/components/ConnectionManager.js.map +1 -0
- package/dist/components/DLQHandler.d.ts +81 -0
- package/dist/components/DLQHandler.d.ts.map +1 -0
- package/dist/components/DLQHandler.js +228 -0
- package/dist/components/DLQHandler.js.map +1 -0
- package/dist/components/Logger.d.ts +77 -0
- package/dist/components/Logger.d.ts.map +1 -0
- package/dist/components/Logger.js +193 -0
- package/dist/components/Logger.js.map +1 -0
- package/dist/components/MessagePublisher.d.ts +49 -0
- package/dist/components/MessagePublisher.d.ts.map +1 -0
- package/dist/components/MessagePublisher.js +158 -0
- package/dist/components/MessagePublisher.js.map +1 -0
- package/dist/components/MessageSubscriber.d.ts +108 -0
- package/dist/components/MessageSubscriber.d.ts.map +1 -0
- package/dist/components/MessageSubscriber.js +503 -0
- package/dist/components/MessageSubscriber.js.map +1 -0
- package/dist/components/ResourceCreator.d.ts +89 -0
- package/dist/components/ResourceCreator.d.ts.map +1 -0
- package/dist/components/ResourceCreator.js +352 -0
- package/dist/components/ResourceCreator.js.map +1 -0
- package/dist/components/SdkRabbitmq.d.ts +103 -0
- package/dist/components/SdkRabbitmq.d.ts.map +1 -0
- package/dist/components/SdkRabbitmq.js +364 -0
- package/dist/components/SdkRabbitmq.js.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +20 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/IConfiguration.d.ts +35 -0
- package/dist/interfaces/IConfiguration.d.ts.map +1 -0
- package/dist/interfaces/IConfiguration.js +3 -0
- package/dist/interfaces/IConfiguration.js.map +1 -0
- package/dist/interfaces/IConnection.d.ts +21 -0
- package/dist/interfaces/IConnection.d.ts.map +1 -0
- package/dist/interfaces/IConnection.js +3 -0
- package/dist/interfaces/IConnection.js.map +1 -0
- package/dist/interfaces/IDLQ.d.ts +12 -0
- package/dist/interfaces/IDLQ.d.ts.map +1 -0
- package/dist/interfaces/IDLQ.js +3 -0
- package/dist/interfaces/IDLQ.js.map +1 -0
- package/dist/interfaces/IErrors.d.ts +33 -0
- package/dist/interfaces/IErrors.d.ts.map +1 -0
- package/dist/interfaces/IErrors.js +56 -0
- package/dist/interfaces/IErrors.js.map +1 -0
- package/dist/interfaces/ILogger.d.ts +14 -0
- package/dist/interfaces/ILogger.d.ts.map +1 -0
- package/dist/interfaces/ILogger.js +3 -0
- package/dist/interfaces/ILogger.js.map +1 -0
- package/dist/interfaces/IMessage.d.ts +52 -0
- package/dist/interfaces/IMessage.d.ts.map +1 -0
- package/dist/interfaces/IMessage.js +3 -0
- package/dist/interfaces/IMessage.js.map +1 -0
- package/dist/interfaces/IResource.d.ts +31 -0
- package/dist/interfaces/IResource.d.ts.map +1 -0
- package/dist/interfaces/IResource.js +3 -0
- package/dist/interfaces/IResource.js.map +1 -0
- package/dist/interfaces/ISdkRabbitmq.d.ts +17 -0
- package/dist/interfaces/ISdkRabbitmq.d.ts.map +1 -0
- package/dist/interfaces/ISdkRabbitmq.js +3 -0
- package/dist/interfaces/ISdkRabbitmq.js.map +1 -0
- package/dist/interfaces/index.d.ts +9 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +33 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/utils/configSchema.d.ts +8 -0
- package/dist/utils/configSchema.d.ts.map +1 -0
- package/dist/utils/configSchema.js +51 -0
- package/dist/utils/configSchema.js.map +1 -0
- package/docker-compose.yml +24 -0
- package/example.ts +65 -0
- package/examples/README-dynamic-routing.md +155 -0
- package/examples/bind-unbind-example.js +56 -0
- package/examples/test-chatbot-exchange.ts +83 -0
- package/examples/test-dynamic-routing-flow.js +299 -0
- package/examples/test-dynamic-routing-flow.ts +355 -0
- package/examples/test-no-disconnect.ts +0 -0
- package/examples/test-raw-rabbitmq.js +68 -0
- package/examples/test-same-channel.ts +81 -0
- package/examples/test-schedule-flow.ts +713 -0
- package/examples/test-simple-greeting.ts +66 -0
- package/examples/test-simple-schedule.ts +76 -0
- package/examples/test-wildcard.ts +364 -0
- package/jest.config.js +17 -0
- package/package.json +42 -4
- package/preinstall.js +1 -0
- package/prompts/test-dynamic-routing-flow.md +46 -0
- package/run.js +4 -0
- package/scripts/run-dynamic-routing-test.ts +31 -0
- package/src/.gitkeep +1 -0
- package/src/components/.gitkeep +1 -0
- package/src/components/ConfigurationManager.ts +104 -0
- package/src/components/ConnectionManager.ts +357 -0
- package/src/components/DLQHandler.ts +271 -0
- package/src/components/Logger.ts +224 -0
- package/src/components/MessagePublisher.ts +180 -0
- package/src/components/MessageSubscriber.ts +597 -0
- package/src/components/ResourceCreator.ts +411 -0
- package/src/components/SdkRabbitmq.ts +443 -0
- package/src/components/__tests__/ConfigurationManager.test.ts +357 -0
- package/src/components/__tests__/ConnectionManager.test.ts +387 -0
- package/src/components/__tests__/DLQHandler.test.ts +399 -0
- package/src/components/__tests__/Logger.test.ts +354 -0
- package/src/components/__tests__/MessagePublisher.test.ts +337 -0
- package/src/components/__tests__/MessageSubscriber.test.ts +542 -0
- package/src/components/__tests__/ResourceCreator.test.ts +465 -0
- package/src/components/__tests__/SdkRabbitmq.integration.test.ts +433 -0
- package/src/components/index.ts +8 -0
- package/src/index.ts +11 -0
- package/src/interfaces/.gitkeep +1 -0
- package/src/interfaces/IConfiguration.ts +38 -0
- package/src/interfaces/IConnection.ts +27 -0
- package/src/interfaces/IDLQ.ts +13 -0
- package/src/interfaces/IErrors.ts +53 -0
- package/src/interfaces/ILogger.ts +16 -0
- package/src/interfaces/IMessage.ts +65 -0
- package/src/interfaces/IResource.ts +35 -0
- package/src/interfaces/ISdkRabbitmq.ts +26 -0
- package/src/interfaces/index.ts +23 -0
- package/src/utils/.gitkeep +1 -0
- package/src/utils/configSchema.ts +58 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SdkRabbitmq = void 0;
|
|
4
|
+
const ConfigurationManager_1 = require("./ConfigurationManager");
|
|
5
|
+
const ConnectionManager_1 = require("./ConnectionManager");
|
|
6
|
+
const MessagePublisher_1 = require("./MessagePublisher");
|
|
7
|
+
const MessageSubscriber_1 = require("./MessageSubscriber");
|
|
8
|
+
const ResourceCreator_1 = require("./ResourceCreator");
|
|
9
|
+
const DLQHandler_1 = require("./DLQHandler");
|
|
10
|
+
const Logger_1 = require("./Logger");
|
|
11
|
+
/**
|
|
12
|
+
* Main SdkRabbitmq singleton class that provides the public API
|
|
13
|
+
* Implements singleton pattern to ensure single connection per application
|
|
14
|
+
*/
|
|
15
|
+
class SdkRabbitmq {
|
|
16
|
+
/**
|
|
17
|
+
* Private constructor to enforce singleton pattern
|
|
18
|
+
*/
|
|
19
|
+
constructor() {
|
|
20
|
+
this.isInitialized = false;
|
|
21
|
+
// Initialize configuration manager first
|
|
22
|
+
this.configurationManager = ConfigurationManager_1.ConfigurationManager.getInstance();
|
|
23
|
+
// Load configuration
|
|
24
|
+
this.config = this.configurationManager.loadConfig();
|
|
25
|
+
// Initialize logger with configuration
|
|
26
|
+
this.logger = Logger_1.Logger.createComponentLogger('SdkRabbitmq', this.config.logging);
|
|
27
|
+
this.logger.info('SdkRabbitmq instance created', {
|
|
28
|
+
url: this.config.url,
|
|
29
|
+
dlqActive: this.config.dlq.active
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get singleton instance of SdkRabbitmq
|
|
34
|
+
* Returns existing instance if available, creates new one otherwise
|
|
35
|
+
*/
|
|
36
|
+
static async getInstance() {
|
|
37
|
+
// Return existing instance if available and initialized
|
|
38
|
+
if (SdkRabbitmq.instance && SdkRabbitmq.instance.isInitialized) {
|
|
39
|
+
return SdkRabbitmq.instance;
|
|
40
|
+
}
|
|
41
|
+
// Prevent multiple simultaneous initialization attempts
|
|
42
|
+
if (SdkRabbitmq.isInitializing) {
|
|
43
|
+
// Wait for initialization to complete
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
const checkInitialization = () => {
|
|
46
|
+
if (SdkRabbitmq.instance && SdkRabbitmq.instance.isInitialized && !SdkRabbitmq.isInitializing) {
|
|
47
|
+
resolve(SdkRabbitmq.instance);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
setTimeout(checkInitialization, 50);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
checkInitialization();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
SdkRabbitmq.isInitializing = true;
|
|
57
|
+
try {
|
|
58
|
+
// Create instance if it doesn't exist
|
|
59
|
+
if (!SdkRabbitmq.instance) {
|
|
60
|
+
SdkRabbitmq.instance = new SdkRabbitmq();
|
|
61
|
+
}
|
|
62
|
+
// Initialize all components
|
|
63
|
+
await SdkRabbitmq.instance.initializeComponents();
|
|
64
|
+
SdkRabbitmq.instance.isInitialized = true;
|
|
65
|
+
SdkRabbitmq.isInitializing = false;
|
|
66
|
+
return SdkRabbitmq.instance;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
SdkRabbitmq.isInitializing = false;
|
|
70
|
+
SdkRabbitmq.instance = null;
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Initialize all SDK components and establish connection
|
|
76
|
+
*/
|
|
77
|
+
async initializeComponents() {
|
|
78
|
+
try {
|
|
79
|
+
this.logger.info('Initializing SDK components');
|
|
80
|
+
// Initialize connection manager
|
|
81
|
+
this.connectionManager = ConnectionManager_1.ConnectionManager.getInstance(this.config);
|
|
82
|
+
// Initialize resource creator
|
|
83
|
+
this.resourceCreator = new ResourceCreator_1.ResourceCreator(this.connectionManager, this.config.logging);
|
|
84
|
+
// Initialize DLQ handler
|
|
85
|
+
this.dlqHandler = new DLQHandler_1.DLQHandler(this.config, this.connectionManager, this.resourceCreator);
|
|
86
|
+
// Initialize message publisher
|
|
87
|
+
this.messagePublisher = new MessagePublisher_1.MessagePublisher(this.connectionManager, this.resourceCreator, this.config.logging);
|
|
88
|
+
// Initialize message subscriber
|
|
89
|
+
this.messageSubscriber = new MessageSubscriber_1.MessageSubscriber(this.connectionManager, this.resourceCreator, this.dlqHandler, this.config.logging);
|
|
90
|
+
// Establish connection to RabbitMQ
|
|
91
|
+
await this.connectionManager.connect();
|
|
92
|
+
this.logger.info('SDK components initialized successfully');
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.logger.logError('Failed to initialize SDK components', error);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
|
|
101
|
+
* Publish a message to an exchange
|
|
102
|
+
* @param exchange Exchange name (required)
|
|
103
|
+
* @param routingKey Routing key for message routing (required)
|
|
104
|
+
* @param payload Message payload to be JSON serialized (required)
|
|
105
|
+
* @returns Promise<boolean> - true for success, false for failure
|
|
106
|
+
*/
|
|
107
|
+
async publish(exchange, routingKey, payload) {
|
|
108
|
+
// Parameter validation at API level
|
|
109
|
+
this.validatePublishParameters(exchange, routingKey, payload);
|
|
110
|
+
if (!this.isInitialized) {
|
|
111
|
+
throw new Error('SDK is not initialized. Please wait for initialization to complete.');
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
this.logger.logOperation('publish', 'Publishing message', {
|
|
115
|
+
exchange,
|
|
116
|
+
routingKey,
|
|
117
|
+
payloadType: typeof payload
|
|
118
|
+
});
|
|
119
|
+
// Delegate to MessagePublisher
|
|
120
|
+
const result = await this.messagePublisher.publish(exchange, routingKey, payload);
|
|
121
|
+
this.logger.logOperation('publish', 'Message published successfully', {
|
|
122
|
+
exchange,
|
|
123
|
+
routingKey,
|
|
124
|
+
success: result
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
this.logger.logError('Failed to publish message', error, {
|
|
130
|
+
exchange,
|
|
131
|
+
routingKey,
|
|
132
|
+
payloadType: typeof payload
|
|
133
|
+
});
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Subscribe to messages from a queue
|
|
139
|
+
* @param exchange Exchange name (required)
|
|
140
|
+
* @param queue Queue name (required)
|
|
141
|
+
* @param routingKey Routing key for binding (required)
|
|
142
|
+
* @param callback Message callback function (required)
|
|
143
|
+
*/
|
|
144
|
+
async subscribe(exchange, queue, routingKey, callback) {
|
|
145
|
+
// Parameter validation at API level
|
|
146
|
+
this.validateSubscribeParameters(exchange, queue, routingKey, callback);
|
|
147
|
+
if (!this.isInitialized) {
|
|
148
|
+
throw new Error('SDK is not initialized. Please wait for initialization to complete.');
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
this.logger.logOperation('subscribe', 'Setting up subscription', {
|
|
152
|
+
exchange,
|
|
153
|
+
queue,
|
|
154
|
+
routingKey
|
|
155
|
+
});
|
|
156
|
+
// Delegate to MessageSubscriber
|
|
157
|
+
await this.messageSubscriber.subscribe(exchange, queue, routingKey, callback);
|
|
158
|
+
this.logger.logOperation('subscribe', 'Subscription established successfully', {
|
|
159
|
+
exchange,
|
|
160
|
+
queue,
|
|
161
|
+
routingKey
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
this.logger.logError('Failed to subscribe to messages', error, {
|
|
166
|
+
exchange,
|
|
167
|
+
queue,
|
|
168
|
+
routingKey
|
|
169
|
+
});
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Disconnect from RabbitMQ gracefully
|
|
175
|
+
* Performs cleanup of all components and closes connection
|
|
176
|
+
*/
|
|
177
|
+
async disconnect() {
|
|
178
|
+
if (!this.isInitialized) {
|
|
179
|
+
this.logger.warn('SDK is not initialized, nothing to disconnect');
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
this.logger.info('Starting graceful shutdown');
|
|
184
|
+
// Cleanup message subscriber (unsubscribe from all queues)
|
|
185
|
+
if (this.messageSubscriber) {
|
|
186
|
+
await this.messageSubscriber.cleanup();
|
|
187
|
+
}
|
|
188
|
+
// Disconnect from RabbitMQ
|
|
189
|
+
if (this.connectionManager) {
|
|
190
|
+
await this.connectionManager.disconnect();
|
|
191
|
+
}
|
|
192
|
+
// Clear component caches
|
|
193
|
+
if (this.resourceCreator) {
|
|
194
|
+
this.resourceCreator.clearCache();
|
|
195
|
+
}
|
|
196
|
+
if (this.dlqHandler) {
|
|
197
|
+
this.dlqHandler.clearCache();
|
|
198
|
+
}
|
|
199
|
+
// Reset initialization state
|
|
200
|
+
this.isInitialized = false;
|
|
201
|
+
this.logger.info('SDK disconnected successfully');
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
this.logger.logError('Error during disconnect', error);
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Validate publish method parameters
|
|
210
|
+
* @param exchange Exchange name
|
|
211
|
+
* @param routingKey Routing key
|
|
212
|
+
* @param payload Message payload
|
|
213
|
+
*/
|
|
214
|
+
validatePublishParameters(exchange, routingKey, payload) {
|
|
215
|
+
if (!exchange || typeof exchange !== 'string') {
|
|
216
|
+
throw new Error('Exchange parameter is required and must be a non-empty string');
|
|
217
|
+
}
|
|
218
|
+
if (!routingKey || typeof routingKey !== 'string') {
|
|
219
|
+
throw new Error('RoutingKey parameter is required and must be a non-empty string');
|
|
220
|
+
}
|
|
221
|
+
if (payload === undefined || payload === null) {
|
|
222
|
+
throw new Error('Payload parameter is required and cannot be null or undefined');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Validate subscribe method parameters
|
|
227
|
+
* @param exchange Exchange name
|
|
228
|
+
* @param queue Queue name
|
|
229
|
+
* @param routingKey Routing key
|
|
230
|
+
* @param callback Message callback function
|
|
231
|
+
*/
|
|
232
|
+
validateSubscribeParameters(exchange, queue, routingKey, callback) {
|
|
233
|
+
if (!exchange || typeof exchange !== 'string') {
|
|
234
|
+
throw new Error('Exchange parameter is required and must be a non-empty string');
|
|
235
|
+
}
|
|
236
|
+
if (!queue || typeof queue !== 'string') {
|
|
237
|
+
throw new Error('Queue parameter is required and must be a non-empty string');
|
|
238
|
+
}
|
|
239
|
+
if (!routingKey || typeof routingKey !== 'string') {
|
|
240
|
+
throw new Error('RoutingKey parameter is required and must be a non-empty string');
|
|
241
|
+
}
|
|
242
|
+
if (!callback || typeof callback !== 'function') {
|
|
243
|
+
throw new Error('Callback parameter is required and must be a function');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Validate bind/unbind method parameters
|
|
248
|
+
* @param queue Queue name
|
|
249
|
+
* @param exchange Exchange name
|
|
250
|
+
* @param routingKey Routing key
|
|
251
|
+
*/
|
|
252
|
+
validateBindParameters(queue, exchange, routingKey) {
|
|
253
|
+
if (!queue || typeof queue !== 'string') {
|
|
254
|
+
throw new Error('Queue parameter is required and must be a non-empty string');
|
|
255
|
+
}
|
|
256
|
+
if (!exchange || typeof exchange !== 'string') {
|
|
257
|
+
throw new Error('Exchange parameter is required and must be a non-empty string');
|
|
258
|
+
}
|
|
259
|
+
if (!routingKey || typeof routingKey !== 'string') {
|
|
260
|
+
throw new Error('RoutingKey parameter is required and must be a non-empty string');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Get SDK initialization status
|
|
265
|
+
*/
|
|
266
|
+
isReady() {
|
|
267
|
+
return this.isInitialized && this.connectionManager?.isConnected();
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Bind a queue to an exchange with a routing key
|
|
271
|
+
* @param queue Queue name (required)
|
|
272
|
+
* @param exchange Exchange name (required)
|
|
273
|
+
* @param routingKey Routing key for binding (required)
|
|
274
|
+
*/
|
|
275
|
+
async bind(queue, exchange, routingKey) {
|
|
276
|
+
// Parameter validation at API level
|
|
277
|
+
this.validateBindParameters(queue, exchange, routingKey);
|
|
278
|
+
if (!this.isInitialized) {
|
|
279
|
+
throw new Error('SDK is not initialized. Please wait for initialization to complete.');
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
this.logger.logOperation('bind', 'Binding queue to exchange', {
|
|
283
|
+
queue,
|
|
284
|
+
exchange,
|
|
285
|
+
routingKey
|
|
286
|
+
});
|
|
287
|
+
// Delegate to ResourceCreator
|
|
288
|
+
await this.resourceCreator.bindQueue(queue, exchange, routingKey);
|
|
289
|
+
this.logger.logOperation('bind', 'Queue bound to exchange successfully', {
|
|
290
|
+
queue,
|
|
291
|
+
exchange,
|
|
292
|
+
routingKey
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
this.logger.logError('Failed to bind queue to exchange', error, {
|
|
297
|
+
queue,
|
|
298
|
+
exchange,
|
|
299
|
+
routingKey
|
|
300
|
+
});
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Unbind a queue from an exchange with a routing key
|
|
306
|
+
* @param queue Queue name (required)
|
|
307
|
+
* @param exchange Exchange name (required)
|
|
308
|
+
* @param routingKey Routing key for unbinding (required)
|
|
309
|
+
*/
|
|
310
|
+
async unbind(queue, exchange, routingKey) {
|
|
311
|
+
// Parameter validation at API level
|
|
312
|
+
this.validateBindParameters(queue, exchange, routingKey);
|
|
313
|
+
if (!this.isInitialized) {
|
|
314
|
+
throw new Error('SDK is not initialized. Please wait for initialization to complete.');
|
|
315
|
+
}
|
|
316
|
+
try {
|
|
317
|
+
this.logger.logOperation('unbind', 'Unbinding queue from exchange', {
|
|
318
|
+
queue,
|
|
319
|
+
exchange,
|
|
320
|
+
routingKey
|
|
321
|
+
});
|
|
322
|
+
// Delegate to ResourceCreator
|
|
323
|
+
await this.resourceCreator.unbindQueue(queue, exchange, routingKey);
|
|
324
|
+
this.logger.logOperation('unbind', 'Queue unbound from exchange successfully', {
|
|
325
|
+
queue,
|
|
326
|
+
exchange,
|
|
327
|
+
routingKey
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
this.logger.logError('Failed to unbind queue from exchange', error, {
|
|
332
|
+
queue,
|
|
333
|
+
exchange,
|
|
334
|
+
routingKey
|
|
335
|
+
});
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get active consumers for monitoring
|
|
341
|
+
*/
|
|
342
|
+
getActiveConsumers() {
|
|
343
|
+
if (!this.messageSubscriber) {
|
|
344
|
+
return [];
|
|
345
|
+
}
|
|
346
|
+
return this.messageSubscriber.getActiveConsumers();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Reset singleton instance (for testing purposes)
|
|
350
|
+
*/
|
|
351
|
+
static resetInstance() {
|
|
352
|
+
if (SdkRabbitmq.instance) {
|
|
353
|
+
SdkRabbitmq.instance.disconnect().catch(() => {
|
|
354
|
+
// Ignore errors during reset
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
SdkRabbitmq.instance = null;
|
|
358
|
+
SdkRabbitmq.isInitializing = false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
exports.SdkRabbitmq = SdkRabbitmq;
|
|
362
|
+
SdkRabbitmq.instance = null;
|
|
363
|
+
SdkRabbitmq.isInitializing = false;
|
|
364
|
+
//# sourceMappingURL=SdkRabbitmq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdkRabbitmq.js","sourceRoot":"","sources":["../../src/components/SdkRabbitmq.ts"],"names":[],"mappings":";;;AAEA,iEAA8D;AAC9D,2DAAwD;AACxD,yDAAsD;AACtD,2DAAwD;AACxD,uDAAoD;AACpD,6CAA0C;AAC1C,qCAAkC;AAGlC;;;GAGG;AACH,MAAa,WAAW;IActB;;OAEG;IACH;QALQ,kBAAa,GAAG,KAAK,CAAC;QAM5B,yCAAyC;QACzC,IAAI,CAAC,oBAAoB,GAAG,2CAAoB,CAAC,WAAW,EAAE,CAAC;QAE/D,qBAAqB;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,CAAC;QAErD,uCAAuC;QACvC,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC,qBAAqB,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE/E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE;YAC/C,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG;YACpB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM;SAClC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW;QAC7B,wDAAwD;QACxD,IAAI,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ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CAAC,iBAAiB,EAAE,CAAC;YAC5B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,aAAa;QACzB,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;YACzB,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC3C,6BAA6B;YAC/B,CAAC,CAAC,CAAC;QACL,CAAC;QACD,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC5B,WAAW,CAAC,cAAc,GAAG,KAAK,CAAC;IACrC,CAAC;;AA1aH,kCA2aC;AA1agB,oBAAQ,GAAuB,IAAI,AAA3B,CAA4B;AACpC,0BAAc,GAAG,KAAK,AAAR,CAAS"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ConfigurationManager } from './ConfigurationManager';
|
|
2
|
+
export { ConnectionManager } from './ConnectionManager';
|
|
3
|
+
export { ResourceCreator } from './ResourceCreator';
|
|
4
|
+
export { MessagePublisher } from './MessagePublisher';
|
|
5
|
+
export { MessageSubscriber } from './MessageSubscriber';
|
|
6
|
+
export { DLQHandler } from './DLQHandler';
|
|
7
|
+
export { Logger } from './Logger';
|
|
8
|
+
export { SdkRabbitmq } from './SdkRabbitmq';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SdkRabbitmq = exports.Logger = exports.DLQHandler = exports.MessageSubscriber = exports.MessagePublisher = exports.ResourceCreator = exports.ConnectionManager = exports.ConfigurationManager = void 0;
|
|
4
|
+
var ConfigurationManager_1 = require("./ConfigurationManager");
|
|
5
|
+
Object.defineProperty(exports, "ConfigurationManager", { enumerable: true, get: function () { return ConfigurationManager_1.ConfigurationManager; } });
|
|
6
|
+
var ConnectionManager_1 = require("./ConnectionManager");
|
|
7
|
+
Object.defineProperty(exports, "ConnectionManager", { enumerable: true, get: function () { return ConnectionManager_1.ConnectionManager; } });
|
|
8
|
+
var ResourceCreator_1 = require("./ResourceCreator");
|
|
9
|
+
Object.defineProperty(exports, "ResourceCreator", { enumerable: true, get: function () { return ResourceCreator_1.ResourceCreator; } });
|
|
10
|
+
var MessagePublisher_1 = require("./MessagePublisher");
|
|
11
|
+
Object.defineProperty(exports, "MessagePublisher", { enumerable: true, get: function () { return MessagePublisher_1.MessagePublisher; } });
|
|
12
|
+
var MessageSubscriber_1 = require("./MessageSubscriber");
|
|
13
|
+
Object.defineProperty(exports, "MessageSubscriber", { enumerable: true, get: function () { return MessageSubscriber_1.MessageSubscriber; } });
|
|
14
|
+
var DLQHandler_1 = require("./DLQHandler");
|
|
15
|
+
Object.defineProperty(exports, "DLQHandler", { enumerable: true, get: function () { return DLQHandler_1.DLQHandler; } });
|
|
16
|
+
var Logger_1 = require("./Logger");
|
|
17
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return Logger_1.Logger; } });
|
|
18
|
+
var SdkRabbitmq_1 = require("./SdkRabbitmq");
|
|
19
|
+
Object.defineProperty(exports, "SdkRabbitmq", { enumerable: true, get: function () { return SdkRabbitmq_1.SdkRabbitmq; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,6CAA4C;AAAnC,0GAAA,WAAW,OAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAG7B,cAAc,cAAc,CAAC;AAG7B,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SdkRabbitmq = void 0;
|
|
18
|
+
// Export all interfaces
|
|
19
|
+
__exportStar(require("./interfaces"), exports);
|
|
20
|
+
// Export components
|
|
21
|
+
__exportStar(require("./components"), exports);
|
|
22
|
+
// Export utilities
|
|
23
|
+
__exportStar(require("./utils/configSchema"), exports);
|
|
24
|
+
// Main SDK class
|
|
25
|
+
var SdkRabbitmq_1 = require("./components/SdkRabbitmq");
|
|
26
|
+
Object.defineProperty(exports, "SdkRabbitmq", { enumerable: true, get: function () { return SdkRabbitmq_1.SdkRabbitmq; } });
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wBAAwB;AACxB,+CAA6B;AAE7B,oBAAoB;AACpB,+CAA6B;AAE7B,mBAAmB;AACnB,uDAAqC;AAErC,iBAAiB;AACjB,wDAAuD;AAA9C,0GAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration interface for the SDK RabbitMQ
|
|
3
|
+
*/
|
|
4
|
+
export interface IConfiguration {
|
|
5
|
+
/** RabbitMQ connection URL */
|
|
6
|
+
url: string;
|
|
7
|
+
/** Dead Letter Queue configuration */
|
|
8
|
+
dlq: {
|
|
9
|
+
/** Whether DLQ is active */
|
|
10
|
+
active: boolean;
|
|
11
|
+
/** Time to live for messages in DLQ (milliseconds) */
|
|
12
|
+
ttl?: number;
|
|
13
|
+
/** Maximum number of retries before sending to DLQ */
|
|
14
|
+
maxRetries?: number;
|
|
15
|
+
/** Delay between retries (milliseconds) */
|
|
16
|
+
retryDelay?: number;
|
|
17
|
+
};
|
|
18
|
+
/** Logging configuration */
|
|
19
|
+
logging?: {
|
|
20
|
+
/** Log level */
|
|
21
|
+
level: 'error' | 'warn' | 'info' | 'debug';
|
|
22
|
+
/** Log format */
|
|
23
|
+
format: 'json' | 'text';
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configuration manager interface
|
|
28
|
+
*/
|
|
29
|
+
export interface IConfigurationManager {
|
|
30
|
+
/** Load configuration from config.json */
|
|
31
|
+
loadConfig(): IConfiguration;
|
|
32
|
+
/** Validate configuration schema */
|
|
33
|
+
validateConfig(config: IConfiguration): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=IConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConfiguration.d.ts","sourceRoot":"","sources":["../../src/interfaces/IConfiguration.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IAEZ,sCAAsC;IACtC,GAAG,EAAE;QACH,4BAA4B;QAC5B,MAAM,EAAE,OAAO,CAAC;QAChB,sDAAsD;QACtD,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,sDAAsD;QACtD,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,2CAA2C;QAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF,4BAA4B;IAC5B,OAAO,CAAC,EAAE;QACR,gBAAgB;QAChB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAC3C,iBAAiB;QACjB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;KACzB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,UAAU,IAAI,cAAc,CAAC;IAE7B,oCAAoC;IACpC,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConfiguration.js","sourceRoot":"","sources":["../../src/interfaces/IConfiguration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as amqp from 'amqplib';
|
|
2
|
+
/**
|
|
3
|
+
* Connection manager interface for managing RabbitMQ connections
|
|
4
|
+
*/
|
|
5
|
+
export interface IConnectionManager {
|
|
6
|
+
/** Establish connection to RabbitMQ */
|
|
7
|
+
connect(): Promise<amqp.Connection>;
|
|
8
|
+
/** Get current connection instance */
|
|
9
|
+
getConnection(): amqp.Connection | null;
|
|
10
|
+
/** Check if currently connected */
|
|
11
|
+
isConnected(): boolean;
|
|
12
|
+
/** Disconnect from RabbitMQ */
|
|
13
|
+
disconnect(): Promise<void>;
|
|
14
|
+
/** Register callback for connection lost events */
|
|
15
|
+
onConnectionLost(callback: () => void): void;
|
|
16
|
+
/** Queue operation to be executed after reconnection */
|
|
17
|
+
queueOperation(operation: () => Promise<void>): void;
|
|
18
|
+
/** Execute operation with automatic queuing during reconnection */
|
|
19
|
+
executeOperation<T>(operation: () => Promise<T>): Promise<T>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=IConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConnection.d.ts","sourceRoot":"","sources":["../../src/interfaces/IConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEpC,sCAAsC;IACtC,aAAa,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAExC,mCAAmC;IACnC,WAAW,IAAI,OAAO,CAAC;IAEvB,+BAA+B;IAC/B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B,mDAAmD;IACnD,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAE7C,wDAAwD;IACxD,cAAc,CAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAErD,mEAAmE;IACnE,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConnection.js","sourceRoot":"","sources":["../../src/interfaces/IConnection.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dead Letter Queue handler interface
|
|
3
|
+
*/
|
|
4
|
+
export interface IDLQHandler {
|
|
5
|
+
/** Set up DLQ for a given original queue */
|
|
6
|
+
setupDLQ(originalQueue: string): Promise<string>;
|
|
7
|
+
/** Handle a failed message by routing to DLQ */
|
|
8
|
+
handleFailedMessage(message: any, originalQueue: string): Promise<void>;
|
|
9
|
+
/** Check if DLQ is enabled in configuration */
|
|
10
|
+
isEnabled(): boolean;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=IDLQ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDLQ.d.ts","sourceRoot":"","sources":["../../src/interfaces/IDLQ.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjD,gDAAgD;IAChD,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE,+CAA+C;IAC/C,SAAS,IAAI,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDLQ.js","sourceRoot":"","sources":["../../src/interfaces/IDLQ.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base SDK RabbitMQ error class
|
|
3
|
+
*/
|
|
4
|
+
export declare class SdkRabbitmqError extends Error {
|
|
5
|
+
code: string;
|
|
6
|
+
context?: any | undefined;
|
|
7
|
+
constructor(message: string, code: string, context?: any | undefined);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Configuration related errors
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConfigurationError extends SdkRabbitmqError {
|
|
13
|
+
constructor(message: string, context?: any);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Connection related errors
|
|
17
|
+
*/
|
|
18
|
+
export declare class ConnectionError extends SdkRabbitmqError {
|
|
19
|
+
constructor(message: string, context?: any);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Message publishing errors
|
|
23
|
+
*/
|
|
24
|
+
export declare class PublishError extends SdkRabbitmqError {
|
|
25
|
+
constructor(message: string, context?: any);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Message subscription errors
|
|
29
|
+
*/
|
|
30
|
+
export declare class SubscriptionError extends SdkRabbitmqError {
|
|
31
|
+
constructor(message: string, context?: any);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=IErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IErrors.d.ts","sourceRoot":"","sources":["../../src/interfaces/IErrors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAGhC,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,GAAG;gBAFpB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,GAAG,YAAA;CAKvB;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB;gBAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,gBAAgB;gBACvC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB;gBACzC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C"}
|