import { EventEmitter } from 'node:events'; import type { MongoConnectionContract, MongoConnectionManagerContract } from '../types/database.js'; import type { MongoDBConnectionConfig } from '../define_config.js'; /** * Connection node represents a single connection with its * configuration and current state */ type ConnectionNode = { name: string; config: MongoDBConnectionConfig; connection?: MongoConnectionContract; state: 'registered' | 'open' | 'closed'; }; /** * Connection manager exposes the API to manage multiple named connections */ export declare class MongoConnectionManager implements MongoConnectionManagerContract { private logger; private emitter; /** * A map of registered connections with their config */ private connections; constructor(logger: any, emitter: EventEmitter); /** * Handles event when a connection is closed */ private handleDisconnect; /** * Handles event when a new connection is added */ private handleConnect; /** * Monitors a given connection by listening for lifecycle events */ private monitorConnection; /** * Add a new connection with its configuration. The connection is not established * right away and one must call `connect` to establish the connection. */ add(name: string, config: MongoDBConnectionConfig): MongoConnectionContract; /** * Connect to the database using config for a given named connection */ connect(connectionName: string): void; /** * Returns the connection node for a given named connection */ getConnectionNode(connectionName: string): ConnectionNode | undefined; /** * Returns the connection for a given named connection */ get(connectionName: string): MongoConnectionContract; /** * Returns a boolean telling if we have connection details for * a given named connection. This method doesn't tell if * connection is connected or not. */ has(connectionName: string): boolean; /** * Returns a boolean telling if connection has been established * with the database or not */ isConnected(connectionName: string): boolean; /** * Close a given connection */ close(connectionName: string): Promise; /** * Close all connections */ closeAll(): Promise; } export {};