1 | import {
|
2 | Connection as PromiseConnection,
|
3 | Pool as PromisePool,
|
4 | PoolConnection as PromisePoolConnection,
|
5 | } from './promise';
|
6 |
|
7 | import * as mysql from './typings/mysql';
|
8 | export * from './typings/mysql';
|
9 |
|
10 | export interface Connection extends mysql.Connection {
|
11 | execute<
|
12 | T extends
|
13 | | mysql.RowDataPacket[][]
|
14 | | mysql.RowDataPacket[]
|
15 | | mysql.OkPacket
|
16 | | mysql.OkPacket[]
|
17 | | mysql.ResultSetHeader
|
18 | >(
|
19 | sql: string,
|
20 | callback?: (
|
21 | err: mysql.QueryError | null,
|
22 | result: T,
|
23 | fields: mysql.FieldPacket[]
|
24 | ) => any
|
25 | ): mysql.Query;
|
26 | execute<
|
27 | T extends
|
28 | | mysql.RowDataPacket[][]
|
29 | | mysql.RowDataPacket[]
|
30 | | mysql.OkPacket
|
31 | | mysql.OkPacket[]
|
32 | | mysql.ResultSetHeader
|
33 | >(
|
34 | sql: string,
|
35 | values: any | any[] | { [param: string]: any },
|
36 | callback?: (
|
37 | err: mysql.QueryError | null,
|
38 | result: T,
|
39 | fields: mysql.FieldPacket[]
|
40 | ) => any
|
41 | ): mysql.Query;
|
42 | execute<
|
43 | T extends
|
44 | | mysql.RowDataPacket[][]
|
45 | | mysql.RowDataPacket[]
|
46 | | mysql.OkPacket
|
47 | | mysql.OkPacket[]
|
48 | | mysql.ResultSetHeader
|
49 | >(
|
50 | options: mysql.QueryOptions,
|
51 | callback?: (
|
52 | err: mysql.QueryError | null,
|
53 | result: T,
|
54 | fields?: mysql.FieldPacket[]
|
55 | ) => any
|
56 | ): mysql.Query;
|
57 | execute<
|
58 | T extends
|
59 | | mysql.RowDataPacket[][]
|
60 | | mysql.RowDataPacket[]
|
61 | | mysql.OkPacket
|
62 | | mysql.OkPacket[]
|
63 | | mysql.ResultSetHeader
|
64 | >(
|
65 | options: mysql.QueryOptions,
|
66 | values: any | any[] | { [param: string]: any },
|
67 | callback?: (
|
68 | err: mysql.QueryError | null,
|
69 | result: T,
|
70 | fields: mysql.FieldPacket[]
|
71 | ) => any
|
72 | ): mysql.Query;
|
73 | ping(callback?: (err: mysql.QueryError | null) => any): void;
|
74 | promise(promiseImpl?: PromiseConstructor): PromiseConnection;
|
75 | unprepare(sql: string): mysql.PrepareStatementInfo;
|
76 | prepare(sql: string, callback?: (err: mysql.QueryError | null, statement: mysql.PrepareStatementInfo) => any): mysql.Prepare;
|
77 | serverHandshake(args: any): any;
|
78 | writeOk(args?: mysql.OkPacketParams): void;
|
79 | writeError(args?: mysql.ErrorPacketParams): void;
|
80 | writeEof(warnings?: number, statusFlags?: number): void;
|
81 | writeTextResult(rows?: Array<any>, columns?: Array<any>): void;
|
82 | writePacket(packet: any): void;
|
83 | sequenceId: number;
|
84 | }
|
85 |
|
86 | export interface PoolConnection extends mysql.PoolConnection, Connection {
|
87 | promise(promiseImpl?: PromiseConstructor): PromisePoolConnection;
|
88 | }
|
89 |
|
90 | export interface Pool extends mysql.Connection {
|
91 | execute<
|
92 | T extends
|
93 | | mysql.RowDataPacket[][]
|
94 | | mysql.RowDataPacket[]
|
95 | | mysql.OkPacket
|
96 | | mysql.OkPacket[]
|
97 | | mysql.ResultSetHeader
|
98 | >(
|
99 | sql: string,
|
100 | callback?: (
|
101 | err: mysql.QueryError | null,
|
102 | result: T,
|
103 | fields: mysql.FieldPacket[]
|
104 | ) => any
|
105 | ): mysql.Query;
|
106 | execute<
|
107 | T extends
|
108 | | mysql.RowDataPacket[][]
|
109 | | mysql.RowDataPacket[]
|
110 | | mysql.OkPacket
|
111 | | mysql.OkPacket[]
|
112 | | mysql.ResultSetHeader
|
113 | >(
|
114 | sql: string,
|
115 | values: any | any[] | { [param: string]: any },
|
116 | callback?: (
|
117 | err: mysql.QueryError | null,
|
118 | result: T,
|
119 | fields: mysql.FieldPacket[]
|
120 | ) => any
|
121 | ): mysql.Query;
|
122 | execute<
|
123 | T extends
|
124 | | mysql.RowDataPacket[][]
|
125 | | mysql.RowDataPacket[]
|
126 | | mysql.OkPacket
|
127 | | mysql.OkPacket[]
|
128 | | mysql.ResultSetHeader
|
129 | >(
|
130 | options: mysql.QueryOptions,
|
131 | callback?: (
|
132 | err: mysql.QueryError | null,
|
133 | result: T,
|
134 | fields?: mysql.FieldPacket[]
|
135 | ) => any
|
136 | ): mysql.Query;
|
137 | execute<
|
138 | T extends
|
139 | | mysql.RowDataPacket[][]
|
140 | | mysql.RowDataPacket[]
|
141 | | mysql.OkPacket
|
142 | | mysql.OkPacket[]
|
143 | | mysql.ResultSetHeader
|
144 | >(
|
145 | options: mysql.QueryOptions,
|
146 | values: any | any[] | { [param: string]: any },
|
147 | callback?: (
|
148 | err: mysql.QueryError | null,
|
149 | result: T,
|
150 | fields: mysql.FieldPacket[]
|
151 | ) => any
|
152 | ): mysql.Query;
|
153 | getConnection(
|
154 | callback: (err: NodeJS.ErrnoException, connection: PoolConnection) => any
|
155 | ): void;
|
156 | on(event: 'connection', listener: (connection: PoolConnection) => any): this;
|
157 | on(event: 'acquire', listener: (connection: PoolConnection) => any): this;
|
158 | on(event: 'release', listener: (connection: PoolConnection) => any): this;
|
159 | on(event: 'enqueue', listener: () => any): this;
|
160 | promise(promiseImpl?: PromiseConstructor): PromisePool;
|
161 | unprepare(sql: string): mysql.PrepareStatementInfo;
|
162 | prepare(sql: string, callback?: (err: mysql.QueryError | null, statement: mysql.PrepareStatementInfo) => any): mysql.Prepare;
|
163 |
|
164 | config: mysql.PoolOptions;
|
165 | }
|
166 |
|
167 | export interface ConnectionOptions extends mysql.ConnectionOptions {
|
168 | charsetNumber?: number;
|
169 | compress?: boolean;
|
170 | authSwitchHandler?: (data: any, callback: () => void) => any;
|
171 | connectAttributes?: { [param: string]: any };
|
172 | decimalNumbers?: boolean;
|
173 | isServer?: boolean;
|
174 | maxPreparedStatements?: number;
|
175 | namedPlaceholders?: boolean;
|
176 | nestTables?: boolean | string;
|
177 | passwordSha1?: string;
|
178 | pool?: any;
|
179 | rowsAsArray?: boolean;
|
180 | stream?: any;
|
181 | uri?: string;
|
182 | connectionLimit?: number;
|
183 | maxIdle?: number;
|
184 | idleTimeout?: number;
|
185 | Promise?: any;
|
186 | queueLimit?: number;
|
187 | waitForConnections?: boolean;
|
188 | authPlugins?: {
|
189 | [key: string]: mysql.AuthPlugin;
|
190 | };
|
191 | }
|
192 |
|
193 | export interface ConnectionConfig extends ConnectionOptions {
|
194 | mergeFlags(defaultFlags: string[], userFlags: string[] | string): number;
|
195 | getDefaultFlags(options?: ConnectionOptions): string[];
|
196 | getCharsetNumber(charset: string): number;
|
197 | getSSLProfile(name: string): { ca: string[] };
|
198 | parseUrl(url: string): { host: string, port: number, database: string, user: string, password: string, [key: string]: any };
|
199 | }
|
200 |
|
201 | export interface PoolOptions extends mysql.PoolOptions, ConnectionOptions {}
|
202 |
|
203 | export function createConnection(connectionUri: string): Connection;
|
204 | export function createConnection(config: ConnectionOptions): Connection;
|
205 | export function createPool(config: PoolOptions): Pool;
|