diff --git a/promise.d.ts b/promise.d.ts index 4afb6a7c5d..3997609b93 100644 --- a/promise.d.ts +++ b/promise.d.ts @@ -7,9 +7,11 @@ import { FieldPacket, QueryOptions, ConnectionOptions, + Connection as CoreConnection, PoolOptions, PoolClusterOptions, Pool as CorePool, + PoolConnection as CorePoolConnection, } from './index.js'; import { ExecutableBase as ExecutableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/ExecutableBase.js'; import { QueryableBase as QueryableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/QueryableBase.js'; @@ -42,6 +44,8 @@ export interface PreparedStatementInfo { export interface Connection extends QueryableAndExecutableBase { config: ConnectionOptions; + connection: CoreConnection; + threadId: number; connect(): Promise; @@ -78,17 +82,16 @@ export interface Connection extends QueryableAndExecutableBase { export interface PoolConnection extends Connection { release(): void; - connection: Connection; } -export interface Pool extends Connection { +export interface Pool extends QueryableAndExecutableBase, Pick { getConnection(): Promise; releaseConnection(connection: PoolConnection): void; - on(event: 'connection', listener: (connection: PoolConnection) => any): this; - on(event: 'acquire', listener: (connection: PoolConnection) => any): this; - on(event: 'release', listener: (connection: PoolConnection) => any): this; + on(event: 'connection', listener: (connection: CorePoolConnection) => any): this; + on(event: 'acquire', listener: (connection: CorePoolConnection) => any): this; + on(event: 'release', listener: (connection: CorePoolConnection) => any): this; on(event: 'enqueue', listener: () => any): this; end(): Promise; diff --git a/typings/mysql/lib/Connection.d.ts b/typings/mysql/lib/Connection.d.ts index dffc2a8ce2..e4737b2750 100644 --- a/typings/mysql/lib/Connection.d.ts +++ b/typings/mysql/lib/Connection.d.ts @@ -337,7 +337,9 @@ export interface ConnectionOptions { jsonStrings?: boolean; } -declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) { +declare class BaseConnection extends QueryableBase( + ExecutableBase(EventEmitter), +) { config: ConnectionOptions; threadId: number; @@ -408,8 +410,6 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) { serverHandshake(args: any): any; - promise(promiseImpl?: PromiseConstructor): PromiseConnection; - ping(callback?: (err: QueryError | null) => any): void; writeOk(args?: OkPacketParams): void; @@ -425,4 +425,7 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) { sequenceId: number; } -export { Connection }; +declare class Connection extends BaseConnection { + promise(promiseImpl?: PromiseConstructor): PromiseConnection; +} +export { Connection, BaseConnection }; diff --git a/typings/mysql/lib/Pool.d.ts b/typings/mysql/lib/Pool.d.ts index 90ed5e9bad..d6dd40cdb4 100644 --- a/typings/mysql/lib/Pool.d.ts +++ b/typings/mysql/lib/Pool.d.ts @@ -63,6 +63,13 @@ declare class Pool extends QueryableBase(ExecutableBase(EventEmitter)) { promise(promiseImpl?: PromiseConstructor): PromisePool; + format(sql: string, values?: any | any[] | { [param: string]: any }): string; + + escape(value: any): string; + + escapeId(value: string | string[]): string; + escapeId(values: string[]): string; + config: PoolOptions; } diff --git a/typings/mysql/lib/PoolConnection.d.ts b/typings/mysql/lib/PoolConnection.d.ts index cce4ef726e..26fd81bb0d 100644 --- a/typings/mysql/lib/PoolConnection.d.ts +++ b/typings/mysql/lib/PoolConnection.d.ts @@ -1,7 +1,7 @@ -import { Connection } from './Connection.js'; +import { Connection, BaseConnection } from './Connection.js'; import { Pool as PromisePool } from '../../../promise.js'; -declare class PoolConnection extends Connection { +declare class PoolConnection extends BaseConnection { connection: Connection; release(): void; promise(promiseImpl?: PromiseConstructor): PromisePool;