diff --git a/promise.d.ts b/promise.d.ts index 50435b0d83..f0c56b7e27 100644 --- a/promise.d.ts +++ b/promise.d.ts @@ -8,6 +8,7 @@ import { QueryOptions, ConnectionOptions, PoolOptions, + PoolClusterOptions, Pool as CorePool, } from './index.js'; import { ExecutableBase as ExecutableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/ExecutableBase.js'; @@ -95,6 +96,30 @@ export interface Pool extends Connection { pool: CorePool; } +export interface PoolNamespace extends QueryableAndExecutableBase { + getConnection(): Promise; +} + +export interface PoolCluster extends EventEmitter { + config: PoolClusterOptions; + + add(config: PoolOptions): void; + add(group: string, connectionUri: string): void; + add(group: string, config: PoolOptions): void; + + end(): Promise; + + getConnection(): Promise; + getConnection(group: string): Promise; + getConnection(group: string, selector: string): Promise; + + of(pattern: string, selector?: string): PoolNamespace; + + on(event: string, listener: (args: any[]) => void): this; + on(event: 'remove', listener: (nodeId: number) => void): this; + on(event: 'connection', listener: (connection: PoolConnection) => void): this; +} + export function createConnection(connectionUri: string): Promise; export function createConnection( config: ConnectionOptions @@ -102,3 +127,5 @@ export function createConnection( export function createPool(connectionUri: string): Pool; export function createPool(config: PoolOptions): Pool; + +export function createPoolCluster(config?: PoolClusterOptions): PoolCluster; diff --git a/typings/mysql/index.d.ts b/typings/mysql/index.d.ts index ee5835036c..b7fd83a90c 100644 --- a/typings/mysql/index.d.ts +++ b/typings/mysql/index.d.ts @@ -12,6 +12,7 @@ import { import { PoolCluster as BasePoolCluster, PoolClusterOptions, + PoolNamespace, } from './lib/PoolCluster.js'; import { PoolConnection as BasePoolConnection } from './lib/PoolConnection.js'; import { @@ -25,6 +26,7 @@ export { SslOptions, PoolOptions, PoolClusterOptions, + PoolNamespace, QueryOptions, QueryError, PrepareStatementInfo,