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,35 @@
|
|
|
1
|
+
import { IConfiguration, IConfigurationManager } from '../interfaces/IConfiguration';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration manager that handles loading and validating configuration from config.json
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConfigurationManager implements IConfigurationManager {
|
|
6
|
+
private static instance;
|
|
7
|
+
private cachedConfig;
|
|
8
|
+
private readonly configPath;
|
|
9
|
+
private constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Get singleton instance of ConfigurationManager
|
|
12
|
+
*/
|
|
13
|
+
static getInstance(): ConfigurationManager;
|
|
14
|
+
/**
|
|
15
|
+
* Load configuration from config.json file
|
|
16
|
+
* @returns Validated configuration object
|
|
17
|
+
* @throws ConfigurationError if file doesn't exist or is invalid
|
|
18
|
+
*/
|
|
19
|
+
loadConfig(): IConfiguration;
|
|
20
|
+
/**
|
|
21
|
+
* Validate configuration schema
|
|
22
|
+
* @param config - Configuration object to validate
|
|
23
|
+
* @throws ConfigurationError if validation fails
|
|
24
|
+
*/
|
|
25
|
+
validateConfig(config: any): void;
|
|
26
|
+
/**
|
|
27
|
+
* Clear cached configuration (useful for testing)
|
|
28
|
+
*/
|
|
29
|
+
clearCache(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the configuration file path
|
|
32
|
+
*/
|
|
33
|
+
getConfigPath(): string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ConfigurationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationManager.d.ts","sourceRoot":"","sources":["../../src/components/ConfigurationManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAIrF;;GAEG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAChE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAuB;IAC9C,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC,OAAO;IAKP;;OAEG;WACW,WAAW,IAAI,oBAAoB;IAOjD;;;;OAIG;IACI,UAAU,IAAI,cAAc;IA+CnC;;;;OAIG;IACI,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAIxC;;OAEG;IACI,UAAU,IAAI,IAAI;IAIzB;;OAEG;IACI,aAAa,IAAI,MAAM;CAG/B"}
|
|
@@ -0,0 +1,118 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConfigurationManager = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const IErrors_1 = require("../interfaces/IErrors");
|
|
40
|
+
const configSchema_1 = require("../utils/configSchema");
|
|
41
|
+
/**
|
|
42
|
+
* Configuration manager that handles loading and validating configuration from config.json
|
|
43
|
+
*/
|
|
44
|
+
class ConfigurationManager {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.cachedConfig = null;
|
|
47
|
+
// Config file should be at project root
|
|
48
|
+
this.configPath = path.join(process.cwd(), 'config.json');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get singleton instance of ConfigurationManager
|
|
52
|
+
*/
|
|
53
|
+
static getInstance() {
|
|
54
|
+
if (!ConfigurationManager.instance) {
|
|
55
|
+
ConfigurationManager.instance = new ConfigurationManager();
|
|
56
|
+
}
|
|
57
|
+
return ConfigurationManager.instance;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Load configuration from config.json file
|
|
61
|
+
* @returns Validated configuration object
|
|
62
|
+
* @throws ConfigurationError if file doesn't exist or is invalid
|
|
63
|
+
*/
|
|
64
|
+
loadConfig() {
|
|
65
|
+
// Return cached config if available
|
|
66
|
+
if (this.cachedConfig) {
|
|
67
|
+
return this.cachedConfig;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
// Check if config file exists
|
|
71
|
+
if (!fs.existsSync(this.configPath)) {
|
|
72
|
+
throw new IErrors_1.ConfigurationError(`Configuration file not found at ${this.configPath}. Please create a config.json file in your project root.`, { configPath: this.configPath });
|
|
73
|
+
}
|
|
74
|
+
// Read and parse config file
|
|
75
|
+
const configContent = fs.readFileSync(this.configPath, 'utf-8');
|
|
76
|
+
let parsedConfig;
|
|
77
|
+
try {
|
|
78
|
+
parsedConfig = JSON.parse(configContent);
|
|
79
|
+
}
|
|
80
|
+
catch (parseError) {
|
|
81
|
+
throw new IErrors_1.ConfigurationError(`Invalid JSON in configuration file: ${parseError instanceof Error ? parseError.message : 'Unknown parsing error'}`, { configPath: this.configPath, parseError });
|
|
82
|
+
}
|
|
83
|
+
// Validate configuration schema
|
|
84
|
+
this.validateConfig(parsedConfig);
|
|
85
|
+
// Cache the validated configuration
|
|
86
|
+
this.cachedConfig = parsedConfig;
|
|
87
|
+
return this.cachedConfig;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof IErrors_1.ConfigurationError) {
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
throw new IErrors_1.ConfigurationError(`Failed to load configuration: ${error instanceof Error ? error.message : 'Unknown error'}`, { configPath: this.configPath, originalError: error });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Validate configuration schema
|
|
98
|
+
* @param config - Configuration object to validate
|
|
99
|
+
* @throws ConfigurationError if validation fails
|
|
100
|
+
*/
|
|
101
|
+
validateConfig(config) {
|
|
102
|
+
(0, configSchema_1.validateConfigurationSchema)(config);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Clear cached configuration (useful for testing)
|
|
106
|
+
*/
|
|
107
|
+
clearCache() {
|
|
108
|
+
this.cachedConfig = null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get the configuration file path
|
|
112
|
+
*/
|
|
113
|
+
getConfigPath() {
|
|
114
|
+
return this.configPath;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.ConfigurationManager = ConfigurationManager;
|
|
118
|
+
//# sourceMappingURL=ConfigurationManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationManager.js","sourceRoot":"","sources":["../../src/components/ConfigurationManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,mDAA2D;AAC3D,wDAAoE;AAEpE;;GAEG;AACH,MAAa,oBAAoB;IAK/B;QAHQ,iBAAY,GAA0B,IAAI,CAAC;QAIjD,wCAAwC;QACxC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC;YACnC,oBAAoB,CAAC,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7D,CAAC;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACI,UAAU;QACf,oCAAoC;QACpC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC;YACH,8BAA8B;YAC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AAW;QAC/B,IAAA,0CAA2B,EAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,UAAU;QACf,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED;;OAEG;IACI,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AA9FD,oDA8FC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as amqp from 'amqplib';
|
|
2
|
+
import { IConnectionManager } from '../interfaces/IConnection';
|
|
3
|
+
import { IConfiguration } from '../interfaces/IConfiguration';
|
|
4
|
+
/**
|
|
5
|
+
* Connection states for tracking connection status
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ConnectionState {
|
|
8
|
+
DISCONNECTED = "disconnected",
|
|
9
|
+
CONNECTING = "connecting",
|
|
10
|
+
CONNECTED = "connected",
|
|
11
|
+
RECONNECTING = "reconnecting",
|
|
12
|
+
FAILED = "failed"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ConnectionManager implements singleton pattern for RabbitMQ connections
|
|
16
|
+
* Manages connection state and provides auto-reconnection capabilities
|
|
17
|
+
*/
|
|
18
|
+
export declare class ConnectionManager implements IConnectionManager {
|
|
19
|
+
private static instance;
|
|
20
|
+
private connection;
|
|
21
|
+
private connectionState;
|
|
22
|
+
private config;
|
|
23
|
+
private connectionLostCallbacks;
|
|
24
|
+
private operationQueue;
|
|
25
|
+
private reconnectAttempts;
|
|
26
|
+
private maxReconnectAttempts;
|
|
27
|
+
private baseRetryDelay;
|
|
28
|
+
private maxRetryDelay;
|
|
29
|
+
private reconnectTimer;
|
|
30
|
+
private logger;
|
|
31
|
+
/**
|
|
32
|
+
* Private constructor to enforce singleton pattern
|
|
33
|
+
*/
|
|
34
|
+
private constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Get singleton instance of ConnectionManager
|
|
37
|
+
*/
|
|
38
|
+
static getInstance(config: IConfiguration): ConnectionManager;
|
|
39
|
+
/**
|
|
40
|
+
* Establish connection to RabbitMQ
|
|
41
|
+
*/
|
|
42
|
+
connect(): Promise<amqp.Connection>;
|
|
43
|
+
/**
|
|
44
|
+
* Get current connection instance
|
|
45
|
+
*/
|
|
46
|
+
getConnection(): amqp.Connection | null;
|
|
47
|
+
/**
|
|
48
|
+
* Check if currently connected
|
|
49
|
+
*/
|
|
50
|
+
isConnected(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Disconnect from RabbitMQ
|
|
53
|
+
*/
|
|
54
|
+
disconnect(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Register callback for connection lost events
|
|
57
|
+
*/
|
|
58
|
+
onConnectionLost(callback: () => void): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get current connection state
|
|
61
|
+
*/
|
|
62
|
+
getConnectionState(): ConnectionState;
|
|
63
|
+
/**
|
|
64
|
+
* Queue operation to be executed after reconnection
|
|
65
|
+
*/
|
|
66
|
+
queueOperation(operation: () => Promise<void>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Execute operation with automatic queuing during reconnection
|
|
69
|
+
*/
|
|
70
|
+
executeOperation<T>(operation: () => Promise<T>): Promise<T>;
|
|
71
|
+
/**
|
|
72
|
+
* Set up event handlers for connection
|
|
73
|
+
*/
|
|
74
|
+
private setupConnectionEventHandlers;
|
|
75
|
+
/**
|
|
76
|
+
* Handle connection loss and initiate reconnection
|
|
77
|
+
*/
|
|
78
|
+
private handleConnectionLoss;
|
|
79
|
+
/**
|
|
80
|
+
* Start reconnection process with exponential backoff
|
|
81
|
+
* Implements exponential backoff: 1s, 2s, 4s, 8s, 16s, 30s (max)
|
|
82
|
+
*/
|
|
83
|
+
private startReconnection;
|
|
84
|
+
/**
|
|
85
|
+
* Process operations that were queued during reconnection
|
|
86
|
+
*/
|
|
87
|
+
private processQueuedOperations;
|
|
88
|
+
/**
|
|
89
|
+
* Reset singleton instance (for testing purposes)
|
|
90
|
+
*/
|
|
91
|
+
static resetInstance(): void;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ConnectionManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionManager.d.ts","sourceRoot":"","sources":["../../src/components/ConnectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D;;GAEG;AACH,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,MAAM,WAAW;CAClB;AAED;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkC;IACzD,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,eAAe,CAAiD;IACxE,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,oBAAoB,CAAM;IAClC,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,MAAM,CAAS;IAEvB;;OAEG;IACH,OAAO;IAKP;;OAEG;WACW,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,iBAAiB;IAOpE;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;IA6ChD;;OAEG;IACI,aAAa,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI;IAI9C;;OAEG;IACI,WAAW,IAAI,OAAO;IAI7B;;OAEG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBxC;;OAEG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAInD;;OAEG;IACI,kBAAkB,IAAI,eAAe;IAI5C;;OAEG;IACI,cAAc,CAAC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAe3D;;OAEG;IACU,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAmBzE;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAsBpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA0B5B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAkEzB;;OAEG;YACW,uBAAuB;IA8BrC;;OAEG;WACW,aAAa,IAAI,IAAI;CAGpC"}
|
|
@@ -0,0 +1,349 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConnectionManager = exports.ConnectionState = void 0;
|
|
37
|
+
const amqp = __importStar(require("amqplib"));
|
|
38
|
+
const Logger_1 = require("./Logger");
|
|
39
|
+
/**
|
|
40
|
+
* Connection states for tracking connection status
|
|
41
|
+
*/
|
|
42
|
+
var ConnectionState;
|
|
43
|
+
(function (ConnectionState) {
|
|
44
|
+
ConnectionState["DISCONNECTED"] = "disconnected";
|
|
45
|
+
ConnectionState["CONNECTING"] = "connecting";
|
|
46
|
+
ConnectionState["CONNECTED"] = "connected";
|
|
47
|
+
ConnectionState["RECONNECTING"] = "reconnecting";
|
|
48
|
+
ConnectionState["FAILED"] = "failed";
|
|
49
|
+
})(ConnectionState || (exports.ConnectionState = ConnectionState = {}));
|
|
50
|
+
/**
|
|
51
|
+
* ConnectionManager implements singleton pattern for RabbitMQ connections
|
|
52
|
+
* Manages connection state and provides auto-reconnection capabilities
|
|
53
|
+
*/
|
|
54
|
+
class ConnectionManager {
|
|
55
|
+
/**
|
|
56
|
+
* Private constructor to enforce singleton pattern
|
|
57
|
+
*/
|
|
58
|
+
constructor(config) {
|
|
59
|
+
this.connection = null;
|
|
60
|
+
this.connectionState = ConnectionState.DISCONNECTED;
|
|
61
|
+
this.connectionLostCallbacks = [];
|
|
62
|
+
this.operationQueue = [];
|
|
63
|
+
this.reconnectAttempts = 0;
|
|
64
|
+
this.maxReconnectAttempts = 10;
|
|
65
|
+
this.baseRetryDelay = 1000; // 1 second
|
|
66
|
+
this.maxRetryDelay = 30000; // 30 seconds
|
|
67
|
+
this.reconnectTimer = null;
|
|
68
|
+
this.config = config;
|
|
69
|
+
this.logger = Logger_1.Logger.createComponentLogger('ConnectionManager', config.logging);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get singleton instance of ConnectionManager
|
|
73
|
+
*/
|
|
74
|
+
static getInstance(config) {
|
|
75
|
+
if (!ConnectionManager.instance) {
|
|
76
|
+
ConnectionManager.instance = new ConnectionManager(config);
|
|
77
|
+
}
|
|
78
|
+
return ConnectionManager.instance;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Establish connection to RabbitMQ
|
|
82
|
+
*/
|
|
83
|
+
async connect() {
|
|
84
|
+
if (this.connection && this.connectionState === ConnectionState.CONNECTED) {
|
|
85
|
+
return this.connection;
|
|
86
|
+
}
|
|
87
|
+
if (this.connectionState === ConnectionState.CONNECTING ||
|
|
88
|
+
this.connectionState === ConnectionState.RECONNECTING) {
|
|
89
|
+
// Wait for existing connection attempt
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
const checkConnection = () => {
|
|
92
|
+
if (this.connection && this.connectionState === ConnectionState.CONNECTED) {
|
|
93
|
+
resolve(this.connection);
|
|
94
|
+
}
|
|
95
|
+
else if (this.connectionState === ConnectionState.FAILED) {
|
|
96
|
+
reject(new Error('Connection failed'));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
setTimeout(checkConnection, 100);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
checkConnection();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
this.connectionState = ConnectionState.CONNECTING;
|
|
106
|
+
try {
|
|
107
|
+
this.connection = await amqp.connect(this.config.url);
|
|
108
|
+
this.connectionState = ConnectionState.CONNECTED;
|
|
109
|
+
this.reconnectAttempts = 0;
|
|
110
|
+
this.logger.logConnectionState(ConnectionState.CONNECTED, { url: this.config.url });
|
|
111
|
+
// Set up connection event handlers
|
|
112
|
+
this.setupConnectionEventHandlers();
|
|
113
|
+
// Process queued operations
|
|
114
|
+
await this.processQueuedOperations();
|
|
115
|
+
return this.connection;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
this.connectionState = ConnectionState.FAILED;
|
|
119
|
+
this.logger.logError('Failed to connect to RabbitMQ', error, { url: this.config.url });
|
|
120
|
+
throw new Error(`Failed to connect to RabbitMQ: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get current connection instance
|
|
125
|
+
*/
|
|
126
|
+
getConnection() {
|
|
127
|
+
return this.connection;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Check if currently connected
|
|
131
|
+
*/
|
|
132
|
+
isConnected() {
|
|
133
|
+
return this.connectionState === ConnectionState.CONNECTED && this.connection !== null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Disconnect from RabbitMQ
|
|
137
|
+
*/
|
|
138
|
+
async disconnect() {
|
|
139
|
+
if (this.reconnectTimer) {
|
|
140
|
+
clearTimeout(this.reconnectTimer);
|
|
141
|
+
this.reconnectTimer = null;
|
|
142
|
+
}
|
|
143
|
+
if (this.connection) {
|
|
144
|
+
try {
|
|
145
|
+
await this.connection.close();
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
// Ignore errors during disconnect
|
|
149
|
+
}
|
|
150
|
+
this.connection = null;
|
|
151
|
+
}
|
|
152
|
+
this.connectionState = ConnectionState.DISCONNECTED;
|
|
153
|
+
this.reconnectAttempts = 0;
|
|
154
|
+
this.operationQueue = [];
|
|
155
|
+
this.logger.logConnectionState(ConnectionState.DISCONNECTED);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Register callback for connection lost events
|
|
159
|
+
*/
|
|
160
|
+
onConnectionLost(callback) {
|
|
161
|
+
this.connectionLostCallbacks.push(callback);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get current connection state
|
|
165
|
+
*/
|
|
166
|
+
getConnectionState() {
|
|
167
|
+
return this.connectionState;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Queue operation to be executed after reconnection
|
|
171
|
+
*/
|
|
172
|
+
queueOperation(operation) {
|
|
173
|
+
if (this.connectionState === ConnectionState.RECONNECTING ||
|
|
174
|
+
this.connectionState === ConnectionState.CONNECTING) {
|
|
175
|
+
this.operationQueue.push(operation);
|
|
176
|
+
}
|
|
177
|
+
else if (this.connectionState === ConnectionState.CONNECTED) {
|
|
178
|
+
// Execute immediately if connected
|
|
179
|
+
operation().catch(error => {
|
|
180
|
+
this.logger.logError('Error executing queued operation', error);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// Queue for later if disconnected
|
|
185
|
+
this.operationQueue.push(operation);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Execute operation with automatic queuing during reconnection
|
|
190
|
+
*/
|
|
191
|
+
async executeOperation(operation) {
|
|
192
|
+
if (this.connectionState === ConnectionState.CONNECTED && this.connection) {
|
|
193
|
+
return await operation();
|
|
194
|
+
}
|
|
195
|
+
// Queue operation and wait for reconnection
|
|
196
|
+
return new Promise((resolve, reject) => {
|
|
197
|
+
const wrappedOperation = async () => {
|
|
198
|
+
try {
|
|
199
|
+
const result = await operation();
|
|
200
|
+
resolve(result);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
reject(error);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
this.queueOperation(wrappedOperation);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Set up event handlers for connection
|
|
211
|
+
*/
|
|
212
|
+
setupConnectionEventHandlers() {
|
|
213
|
+
if (!this.connection)
|
|
214
|
+
return;
|
|
215
|
+
this.connection.on('error', (error) => {
|
|
216
|
+
this.logger.logError('RabbitMQ connection error', error);
|
|
217
|
+
this.handleConnectionLoss();
|
|
218
|
+
});
|
|
219
|
+
this.connection.on('close', () => {
|
|
220
|
+
this.logger.warn('RabbitMQ connection closed');
|
|
221
|
+
this.handleConnectionLoss();
|
|
222
|
+
});
|
|
223
|
+
this.connection.on('blocked', (reason) => {
|
|
224
|
+
this.logger.warn('RabbitMQ connection blocked', { reason });
|
|
225
|
+
});
|
|
226
|
+
this.connection.on('unblocked', () => {
|
|
227
|
+
this.logger.info('RabbitMQ connection unblocked');
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Handle connection loss and initiate reconnection
|
|
232
|
+
*/
|
|
233
|
+
handleConnectionLoss() {
|
|
234
|
+
if (this.connectionState === ConnectionState.RECONNECTING ||
|
|
235
|
+
this.connectionState === ConnectionState.DISCONNECTED) {
|
|
236
|
+
return; // Already handling reconnection or intentionally disconnected
|
|
237
|
+
}
|
|
238
|
+
this.connection = null;
|
|
239
|
+
this.connectionState = ConnectionState.RECONNECTING;
|
|
240
|
+
this.logger.logConnectionState(ConnectionState.RECONNECTING, {
|
|
241
|
+
queuedOperations: this.operationQueue.length
|
|
242
|
+
});
|
|
243
|
+
// Notify callbacks about connection loss
|
|
244
|
+
this.connectionLostCallbacks.forEach(callback => {
|
|
245
|
+
try {
|
|
246
|
+
callback();
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
this.logger.logError('Error in connection lost callback', error);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
// Start reconnection process
|
|
253
|
+
this.startReconnection();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Start reconnection process with exponential backoff
|
|
257
|
+
* Implements exponential backoff: 1s, 2s, 4s, 8s, 16s, 30s (max)
|
|
258
|
+
*/
|
|
259
|
+
startReconnection() {
|
|
260
|
+
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
261
|
+
this.logger.error('Max reconnection attempts reached. Connection failed permanently.', {
|
|
262
|
+
maxAttempts: this.maxReconnectAttempts,
|
|
263
|
+
queuedOperations: this.operationQueue.length
|
|
264
|
+
});
|
|
265
|
+
this.connectionState = ConnectionState.FAILED;
|
|
266
|
+
this.logger.logConnectionState(ConnectionState.FAILED);
|
|
267
|
+
// Reject all queued operations
|
|
268
|
+
this.operationQueue.forEach(operation => {
|
|
269
|
+
operation().catch(() => {
|
|
270
|
+
// Operations will fail, but we need to clear the queue
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
this.operationQueue = [];
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
// Calculate exponential backoff delay: 1s, 2s, 4s, 8s, 16s, max 30s
|
|
277
|
+
const delay = Math.min(this.baseRetryDelay * Math.pow(2, this.reconnectAttempts), this.maxRetryDelay);
|
|
278
|
+
this.logger.info('Connection lost. Starting reconnection process', {
|
|
279
|
+
queuedOperations: this.operationQueue.length,
|
|
280
|
+
delayMs: delay,
|
|
281
|
+
attempt: this.reconnectAttempts + 1,
|
|
282
|
+
maxAttempts: this.maxReconnectAttempts
|
|
283
|
+
});
|
|
284
|
+
this.reconnectTimer = setTimeout(async () => {
|
|
285
|
+
this.reconnectAttempts++;
|
|
286
|
+
try {
|
|
287
|
+
this.logger.logOperation('reconnect', `Attempting reconnection ${this.reconnectAttempts}/${this.maxReconnectAttempts}`);
|
|
288
|
+
// Set state to connecting before attempting connection
|
|
289
|
+
this.connectionState = ConnectionState.CONNECTING;
|
|
290
|
+
this.connection = await amqp.connect(this.config.url);
|
|
291
|
+
this.connectionState = ConnectionState.CONNECTED;
|
|
292
|
+
this.logger.logConnectionState(ConnectionState.CONNECTED, { url: this.config.url });
|
|
293
|
+
// Set up connection event handlers
|
|
294
|
+
this.setupConnectionEventHandlers();
|
|
295
|
+
// Process queued operations
|
|
296
|
+
await this.processQueuedOperations();
|
|
297
|
+
this.logger.info('Successfully reconnected to RabbitMQ', {
|
|
298
|
+
queuedOperations: this.operationQueue.length,
|
|
299
|
+
attempt: this.reconnectAttempts
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
this.connectionState = ConnectionState.RECONNECTING;
|
|
304
|
+
this.logger.logError(`Reconnection attempt ${this.reconnectAttempts} failed`, error, {
|
|
305
|
+
attempt: this.reconnectAttempts,
|
|
306
|
+
maxAttempts: this.maxReconnectAttempts
|
|
307
|
+
});
|
|
308
|
+
this.startReconnection(); // Try again with increased delay
|
|
309
|
+
}
|
|
310
|
+
}, delay);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Process operations that were queued during reconnection
|
|
314
|
+
*/
|
|
315
|
+
async processQueuedOperations() {
|
|
316
|
+
if (this.operationQueue.length === 0) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
this.logger.logOperation('processQueue', `Processing ${this.operationQueue.length} queued operations after reconnection`);
|
|
320
|
+
const operations = [...this.operationQueue];
|
|
321
|
+
this.operationQueue = [];
|
|
322
|
+
let successCount = 0;
|
|
323
|
+
let errorCount = 0;
|
|
324
|
+
for (const operation of operations) {
|
|
325
|
+
try {
|
|
326
|
+
await operation();
|
|
327
|
+
successCount++;
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
errorCount++;
|
|
331
|
+
this.logger.logError('Error processing queued operation', error);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
this.logger.info('Processed queued operations', {
|
|
335
|
+
successful: successCount,
|
|
336
|
+
failed: errorCount,
|
|
337
|
+
total: operations.length
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Reset singleton instance (for testing purposes)
|
|
342
|
+
*/
|
|
343
|
+
static resetInstance() {
|
|
344
|
+
ConnectionManager.instance = null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
exports.ConnectionManager = ConnectionManager;
|
|
348
|
+
ConnectionManager.instance = null;
|
|
349
|
+
//# sourceMappingURL=ConnectionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../src/components/ConnectionManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAGhC,qCAAkC;AAElC;;GAEG;AACH,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,gDAA6B,CAAA;IAC7B,4CAAyB,CAAA;IACzB,0CAAuB,CAAA;IACvB,gDAA6B,CAAA;IAC7B,oCAAiB,CAAA;AACnB,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED;;;GAGG;AACH,MAAa,iBAAiB;IAc5B;;OAEG;IACH,YAAoB,MAAsB;QAflC,eAAU,GAA2B,IAAI,CAAC;QAC1C,oBAAe,GAAoB,eAAe,CAAC,YAAY,CAAC;QAEhE,4BAAuB,GAAmB,EAAE,CAAC;QAC7C,mBAAc,GAA4B,EAAE,CAAC;QAC7C,sBAAiB,GAAG,CAAC,CAAC;QACtB,yBAAoB,GAAG,EAAE,CAAC;QAC1B,mBAAc,GAAG,IAAI,CAAC,CAAC,WAAW;QAClC,kBAAa,GAAG,KAAK,CAAC,CAAC,aAAa;QACpC,mBAAc,GAAyC,IAAI,CAAC;QAOlE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC,qBAAqB,CAAC,mBAAmB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAClF,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,WAAW,CAAC,MAAsB;QAC9C,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;YAChC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,iBAAiB,CAAC,QAAQ,CA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