mysql2 3.3.5 → 3.4.1
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.
- package/index.d.ts +1 -205
- package/lib/packets/resultset_header.js +7 -0
- package/package.json +4 -9
- package/promise.d.ts +67 -91
- package/promise.js +19 -0
- package/typings/mysql/index.d.ts +81 -65
- package/typings/mysql/lib/Auth.d.ts +30 -0
- package/typings/mysql/lib/Connection.d.ts +355 -274
- package/typings/mysql/lib/Pool.d.ts +75 -74
- package/typings/mysql/lib/PoolCluster.d.ts +75 -45
- package/typings/mysql/lib/PoolConnection.d.ts +6 -5
- package/typings/mysql/lib/Server.d.ts +4 -6
- package/typings/mysql/lib/constants/CharsetToEncoding.d.ts +8 -0
- package/typings/mysql/lib/constants/Charsets.d.ts +326 -0
- package/typings/mysql/lib/constants/Types.d.ts +68 -0
- package/typings/mysql/lib/constants/index.d.ts +5 -0
- package/typings/mysql/lib/parsers/ParserCache.d.ts +4 -0
- package/typings/mysql/lib/parsers/index.d.ts +3 -0
- package/typings/mysql/lib/protocol/packets/Field.d.ts +12 -13
- package/typings/mysql/lib/protocol/packets/FieldPacket.d.ts +18 -19
- package/typings/mysql/lib/protocol/packets/OkPacket.d.ts +12 -13
- package/typings/mysql/lib/protocol/packets/ResultSetHeader.d.ts +11 -12
- package/typings/mysql/lib/protocol/packets/RowDataPacket.d.ts +6 -7
- package/typings/mysql/lib/protocol/packets/index.d.ts +14 -15
- package/typings/mysql/lib/protocol/packets/params/ErrorPacketParams.d.ts +1 -1
- package/typings/mysql/lib/protocol/packets/params/OkPacketParams.d.ts +1 -1
- package/typings/mysql/lib/protocol/sequences/ExecutableBase.ts +104 -0
- package/typings/mysql/lib/protocol/sequences/Prepare.d.ts +55 -42
- package/typings/mysql/lib/protocol/sequences/Query.d.ts +145 -142
- package/typings/mysql/lib/protocol/sequences/QueryableBase.ts +104 -0
- package/typings/mysql/lib/protocol/sequences/Sequence.d.ts +3 -3
- package/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.ts +69 -0
- package/typings/mysql/lib/protocol/sequences/promise/QueryableBase.ts +69 -0
package/index.d.ts
CHANGED
|
@@ -1,205 +1 @@
|
|
|
1
|
-
|
|
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
|
-
unprepare(sql: string): mysql.PrepareStatementInfo;
|
|
75
|
-
prepare(sql: string, callback?: (err: mysql.QueryError | null, statement: mysql.PrepareStatementInfo) => any): mysql.Prepare;
|
|
76
|
-
serverHandshake(args: any): any;
|
|
77
|
-
writeOk(args?: mysql.OkPacketParams): void;
|
|
78
|
-
writeError(args?: mysql.ErrorPacketParams): void;
|
|
79
|
-
writeEof(warnings?: number, statusFlags?: number): void;
|
|
80
|
-
writeTextResult(rows?: Array<any>, columns?: Array<any>): void;
|
|
81
|
-
writePacket(packet: any): void;
|
|
82
|
-
promise(promiseImpl?: PromiseConstructor): PromiseConnection;
|
|
83
|
-
sequenceId: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface PoolConnection extends mysql.PoolConnection {
|
|
87
|
-
promise(promiseImpl?: PromiseConstructor): PromisePool;
|
|
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
|
-
releaseConnection(connection: PoolConnection | PromisePoolConnection): void;
|
|
157
|
-
on(event: 'connection', listener: (connection: PoolConnection) => any): this;
|
|
158
|
-
on(event: 'acquire', listener: (connection: PoolConnection) => any): this;
|
|
159
|
-
on(event: 'release', listener: (connection: PoolConnection) => any): this;
|
|
160
|
-
on(event: 'enqueue', listener: () => any): this;
|
|
161
|
-
unprepare(sql: string): mysql.PrepareStatementInfo;
|
|
162
|
-
prepare(sql: string, callback?: (err: mysql.QueryError | null, statement: mysql.PrepareStatementInfo) => any): mysql.Prepare;
|
|
163
|
-
promise(promiseImpl?: PromiseConstructor): PromisePool;
|
|
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;
|
|
1
|
+
export * from './typings/mysql/index.js';
|
|
@@ -50,6 +50,7 @@ class ResultSetHeader {
|
|
|
50
50
|
stateChanges = {
|
|
51
51
|
systemVariables: {},
|
|
52
52
|
schema: null,
|
|
53
|
+
gtids: [],
|
|
53
54
|
trackStateChange: null
|
|
54
55
|
};
|
|
55
56
|
}
|
|
@@ -72,6 +73,12 @@ class ResultSetHeader {
|
|
|
72
73
|
stateChanges.trackStateChange = packet.readLengthCodedString(
|
|
73
74
|
encoding
|
|
74
75
|
);
|
|
76
|
+
} else if (type === sessionInfoTypes.STATE_GTIDS) {
|
|
77
|
+
// TODO: find if the first length coded string means anything. Usually comes as empty
|
|
78
|
+
// eslint-disable-next-line no-unused-vars
|
|
79
|
+
const _unknownString = packet.readLengthCodedString(encoding);
|
|
80
|
+
const gtid = packet.readLengthCodedString(encoding);
|
|
81
|
+
stateChanges.gtids = gtid.split(',');
|
|
75
82
|
} else {
|
|
76
83
|
// unsupported session track type. For now just ignore
|
|
77
84
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql2",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"typings": "typings/mysql/index",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "npm run lint:docs && npm run lint:code",
|
|
12
|
-
"lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"",
|
|
12
|
+
"lint:code": "eslint index.js promise.js index.d.ts promise.d.ts \"typings/**/*.ts\" \"lib/**/*.js\" \"test/**/*.{js,ts}\" \"benchmarks/**/*.js\"",
|
|
13
13
|
"lint:docs": "eslint Contributing.md README.md \"documentation/**/*.md\" \"examples/*.js\"",
|
|
14
14
|
"test": "node ./test/run.js",
|
|
15
15
|
"test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"",
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
"prettier:docs": "prettier --single-quote --trailing-comma none --write README.md documentation/*",
|
|
20
20
|
"precommit": "lint-staged",
|
|
21
21
|
"eslint-check": "eslint --print-config .eslintrc | eslint-config-prettier-check",
|
|
22
|
-
"wait-port": "wait-on"
|
|
23
|
-
"type-test": "node ./node_modules/typescript/bin/tsc -p tests.json && mocha typings/test --timeout 10000"
|
|
22
|
+
"wait-port": "wait-on"
|
|
24
23
|
},
|
|
25
24
|
"lint-staged": {
|
|
26
25
|
"*.js": [
|
|
@@ -67,15 +66,12 @@
|
|
|
67
66
|
"sqlstring": "^2.3.2"
|
|
68
67
|
},
|
|
69
68
|
"devDependencies": {
|
|
70
|
-
"@types/chai": "^4.3.4",
|
|
71
|
-
"@types/mocha": "^10.0.0",
|
|
72
69
|
"@types/node": "^20.0.0",
|
|
73
70
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
74
71
|
"@typescript-eslint/parser": "^5.42.1",
|
|
75
72
|
"assert-diff": "^3.0.2",
|
|
76
73
|
"benchmark": "^2.1.4",
|
|
77
|
-
"c8": "^
|
|
78
|
-
"chai": "^4.3.7",
|
|
74
|
+
"c8": "^8.0.0",
|
|
79
75
|
"error-stack-parser": "^2.0.3",
|
|
80
76
|
"eslint": "^8.27.0",
|
|
81
77
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -83,7 +79,6 @@
|
|
|
83
79
|
"eslint-plugin-markdown": "^3.0.0",
|
|
84
80
|
"husky": "^8.0.2",
|
|
85
81
|
"lint-staged": "^13.0.3",
|
|
86
|
-
"mocha": "^10.0.0",
|
|
87
82
|
"portfinder": "^1.0.28",
|
|
88
83
|
"prettier": "^2.4.1",
|
|
89
84
|
"progress": "^2.0.3",
|
package/promise.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
RowDataPacket,
|
|
3
5
|
OkPacket,
|
|
@@ -6,64 +8,56 @@ import {
|
|
|
6
8
|
QueryOptions,
|
|
7
9
|
ConnectionOptions,
|
|
8
10
|
PoolOptions,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
PoolClusterOptions,
|
|
12
|
+
Pool as CorePool,
|
|
13
|
+
} from './index.js';
|
|
14
|
+
import { ExecutableBase as ExecutableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/ExecutableBase.js';
|
|
15
|
+
import { QueryableBase as QueryableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/QueryableBase.js';
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
export * from './index.js';
|
|
18
|
+
|
|
19
|
+
// Expose class interfaces
|
|
20
|
+
declare class QueryableAndExecutableBase extends QueryableBaseClass(
|
|
21
|
+
ExecutableBaseClass(EventEmitter)
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
export interface PreparedStatementInfo {
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
execute(
|
|
27
|
+
paramaters: any | any[] | { [param: string]: any }
|
|
28
|
+
): Promise<
|
|
29
|
+
[
|
|
30
|
+
(
|
|
31
|
+
| RowDataPacket[][]
|
|
32
|
+
| RowDataPacket[]
|
|
33
|
+
| OkPacket
|
|
34
|
+
| OkPacket[]
|
|
35
|
+
| ResultSetHeader
|
|
36
|
+
),
|
|
37
|
+
FieldPacket[]
|
|
38
|
+
]
|
|
39
|
+
>;
|
|
40
|
+
}
|
|
14
41
|
|
|
15
|
-
export interface Connection extends
|
|
42
|
+
export interface Connection extends QueryableAndExecutableBase {
|
|
16
43
|
config: ConnectionOptions;
|
|
44
|
+
|
|
17
45
|
threadId: number;
|
|
18
46
|
|
|
19
47
|
connect(): Promise<void>;
|
|
48
|
+
|
|
20
49
|
ping(): Promise<void>;
|
|
21
50
|
|
|
22
51
|
beginTransaction(): Promise<void>;
|
|
52
|
+
|
|
23
53
|
commit(): Promise<void>;
|
|
54
|
+
|
|
24
55
|
rollback(): Promise<void>;
|
|
25
56
|
|
|
26
57
|
changeUser(options: ConnectionOptions): Promise<void>;
|
|
27
58
|
|
|
28
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
29
|
-
sql: string
|
|
30
|
-
): Promise<[T, FieldPacket[]]>;
|
|
31
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
32
|
-
sql: string,
|
|
33
|
-
values: any | any[] | { [param: string]: any }
|
|
34
|
-
): Promise<[T, FieldPacket[]]>;
|
|
35
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
36
|
-
options: QueryOptions
|
|
37
|
-
): Promise<[T, FieldPacket[]]>;
|
|
38
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
39
|
-
options: QueryOptions,
|
|
40
|
-
values: any | any[] | { [param: string]: any }
|
|
41
|
-
): Promise<[T, FieldPacket[]]>;
|
|
42
|
-
|
|
43
|
-
execute<
|
|
44
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
45
|
-
>(
|
|
46
|
-
sql: string
|
|
47
|
-
): Promise<[T, FieldPacket[]]>;
|
|
48
|
-
execute<
|
|
49
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
50
|
-
>(
|
|
51
|
-
sql: string,
|
|
52
|
-
values: any | any[] | { [param: string]: any }
|
|
53
|
-
): Promise<[T, FieldPacket[]]>;
|
|
54
|
-
execute<
|
|
55
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
56
|
-
>(
|
|
57
|
-
options: QueryOptions
|
|
58
|
-
): Promise<[T, FieldPacket[]]>;
|
|
59
|
-
execute<
|
|
60
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
61
|
-
>(
|
|
62
|
-
options: QueryOptions,
|
|
63
|
-
values: any | any[] | { [param: string]: any }
|
|
64
|
-
): Promise<[T, FieldPacket[]]>;
|
|
65
|
-
|
|
66
59
|
prepare(options: string | QueryOptions): Promise<PreparedStatementInfo>;
|
|
60
|
+
|
|
67
61
|
unprepare(sql: string | QueryOptions): void;
|
|
68
62
|
|
|
69
63
|
end(options?: any): Promise<void>;
|
|
@@ -87,69 +81,51 @@ export interface PoolConnection extends Connection {
|
|
|
87
81
|
connection: Connection;
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
export interface Pool extends
|
|
91
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
92
|
-
sql: string
|
|
93
|
-
): Promise<[T, FieldPacket[]]>;
|
|
94
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
95
|
-
sql: string,
|
|
96
|
-
values: any | any[] | { [param: string]: any }
|
|
97
|
-
): Promise<[T, FieldPacket[]]>;
|
|
98
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
99
|
-
options: QueryOptions
|
|
100
|
-
): Promise<[T, FieldPacket[]]>;
|
|
101
|
-
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(
|
|
102
|
-
options: QueryOptions,
|
|
103
|
-
values: any | any[] | { [param: string]: any }
|
|
104
|
-
): Promise<[T, FieldPacket[]]>;
|
|
105
|
-
|
|
106
|
-
execute<
|
|
107
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
108
|
-
>(
|
|
109
|
-
sql: string
|
|
110
|
-
): Promise<[T, FieldPacket[]]>;
|
|
111
|
-
execute<
|
|
112
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
113
|
-
>(
|
|
114
|
-
sql: string,
|
|
115
|
-
values: any | any[] | { [param: string]: any }
|
|
116
|
-
): Promise<[T, FieldPacket[]]>;
|
|
117
|
-
execute<
|
|
118
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
119
|
-
>(
|
|
120
|
-
options: QueryOptions
|
|
121
|
-
): Promise<[T, FieldPacket[]]>;
|
|
122
|
-
execute<
|
|
123
|
-
T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader
|
|
124
|
-
>(
|
|
125
|
-
options: QueryOptions,
|
|
126
|
-
values: any | any[] | { [param: string]: any }
|
|
127
|
-
): Promise<[T, FieldPacket[]]>;
|
|
128
|
-
|
|
84
|
+
export interface Pool extends Connection {
|
|
129
85
|
getConnection(): Promise<PoolConnection>;
|
|
86
|
+
|
|
130
87
|
releaseConnection(connection: PoolConnection): void;
|
|
88
|
+
|
|
131
89
|
on(event: 'connection', listener: (connection: PoolConnection) => any): this;
|
|
132
90
|
on(event: 'acquire', listener: (connection: PoolConnection) => any): this;
|
|
133
91
|
on(event: 'release', listener: (connection: PoolConnection) => any): this;
|
|
134
92
|
on(event: 'enqueue', listener: () => any): this;
|
|
93
|
+
|
|
135
94
|
end(): Promise<void>;
|
|
136
95
|
|
|
137
|
-
escape(value: any): string;
|
|
138
|
-
escapeId(value: string): string;
|
|
139
|
-
escapeId(values: string[]): string;
|
|
140
|
-
format(sql: string, values?: any | any[] | { [param: string]: any }): string;
|
|
141
|
-
|
|
142
96
|
pool: CorePool;
|
|
143
97
|
}
|
|
144
98
|
|
|
99
|
+
export interface PoolNamespace extends QueryableAndExecutableBase {
|
|
100
|
+
getConnection(): Promise<PoolConnection>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface PoolCluster extends EventEmitter {
|
|
104
|
+
config: PoolClusterOptions;
|
|
105
|
+
|
|
106
|
+
add(config: PoolOptions): void;
|
|
107
|
+
add(group: string, connectionUri: string): void;
|
|
108
|
+
add(group: string, config: PoolOptions): void;
|
|
109
|
+
|
|
110
|
+
end(): Promise<void>;
|
|
111
|
+
|
|
112
|
+
getConnection(): Promise<PoolConnection>;
|
|
113
|
+
getConnection(group: string): Promise<PoolConnection>;
|
|
114
|
+
getConnection(group: string, selector: string): Promise<PoolConnection>;
|
|
115
|
+
|
|
116
|
+
of(pattern: string, selector?: string): PoolNamespace;
|
|
117
|
+
|
|
118
|
+
on(event: string, listener: (args: any[]) => void): this;
|
|
119
|
+
on(event: 'remove', listener: (nodeId: number) => void): this;
|
|
120
|
+
on(event: 'connection', listener: (connection: PoolConnection) => void): this;
|
|
121
|
+
}
|
|
122
|
+
|
|
145
123
|
export function createConnection(connectionUri: string): Promise<Connection>;
|
|
146
124
|
export function createConnection(
|
|
147
125
|
config: ConnectionOptions
|
|
148
126
|
): Promise<Connection>;
|
|
127
|
+
|
|
149
128
|
export function createPool(connectionUri: string): Pool;
|
|
150
129
|
export function createPool(config: PoolOptions): Pool;
|
|
151
130
|
|
|
152
|
-
export
|
|
153
|
-
close(): Promise<void>;
|
|
154
|
-
execute(parameters: any[]): Promise<[RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader, FieldPacket[]]>;
|
|
155
|
-
}
|
|
131
|
+
export function createPoolCluster(config?: PoolClusterOptions): PoolCluster;
|
package/promise.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const core = require('./index.js');
|
|
4
4
|
const EventEmitter = require('events').EventEmitter;
|
|
5
|
+
const parserCache = require('./lib/parsers/parser_cache.js');
|
|
5
6
|
|
|
6
7
|
function makeDoneCb(resolve, reject, localErr) {
|
|
7
8
|
return function (err, rows, fields) {
|
|
@@ -563,3 +564,21 @@ exports.raw = core.raw;
|
|
|
563
564
|
exports.PromisePool = PromisePool;
|
|
564
565
|
exports.PromiseConnection = PromiseConnection;
|
|
565
566
|
exports.PromisePoolConnection = PromisePoolConnection;
|
|
567
|
+
|
|
568
|
+
exports.__defineGetter__('Types', () => require('./lib/constants/types.js'));
|
|
569
|
+
|
|
570
|
+
exports.__defineGetter__('Charsets', () =>
|
|
571
|
+
require('./lib/constants/charsets.js')
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
exports.__defineGetter__('CharsetToEncoding', () =>
|
|
575
|
+
require('./lib/constants/charset_encodings.js')
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
exports.setMaxParserCache = function(max) {
|
|
579
|
+
parserCache.setMaxCache(max);
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
exports.clearParserCache = function() {
|
|
583
|
+
parserCache.clearCache();
|
|
584
|
+
};
|
package/typings/mysql/index.d.ts
CHANGED
|
@@ -1,78 +1,94 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export function format(sql: string): string;
|
|
24
|
-
export function format(sql: string, values: any[], stringifyObjects?: boolean, timeZone?: string): string;
|
|
25
|
-
export function format(sql: string, values: any, stringifyObjects?: boolean, timeZone?: string): string;
|
|
26
|
-
export function raw(sql: string): {
|
|
27
|
-
toSqlString: () => string
|
|
28
|
-
};
|
|
29
|
-
export function createServer(handler: (conn: BaseConnection) => any): Server;
|
|
1
|
+
import { Pool as BasePool, PoolOptions } from './lib/Pool.js';
|
|
2
|
+
import {
|
|
3
|
+
Connection as BaseConnection,
|
|
4
|
+
ConnectionOptions,
|
|
5
|
+
SslOptions,
|
|
6
|
+
} from './lib/Connection.js';
|
|
7
|
+
import {
|
|
8
|
+
Query as BaseQuery,
|
|
9
|
+
QueryOptions,
|
|
10
|
+
QueryError,
|
|
11
|
+
} from './lib/protocol/sequences/Query.js';
|
|
12
|
+
import {
|
|
13
|
+
PoolCluster as BasePoolCluster,
|
|
14
|
+
PoolClusterOptions,
|
|
15
|
+
PoolNamespace,
|
|
16
|
+
} from './lib/PoolCluster.js';
|
|
17
|
+
import { PoolConnection as BasePoolConnection } from './lib/PoolConnection.js';
|
|
18
|
+
import {
|
|
19
|
+
Prepare as BasePrepare,
|
|
20
|
+
PrepareStatementInfo,
|
|
21
|
+
} from './lib/protocol/sequences/Prepare.js';
|
|
22
|
+
import { Server } from './lib/Server.js';
|
|
30
23
|
|
|
31
24
|
export {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
ConnectionOptions,
|
|
26
|
+
SslOptions,
|
|
27
|
+
PoolOptions,
|
|
28
|
+
PoolClusterOptions,
|
|
29
|
+
PoolNamespace,
|
|
30
|
+
QueryOptions,
|
|
31
|
+
QueryError,
|
|
32
|
+
PrepareStatementInfo,
|
|
39
33
|
};
|
|
40
|
-
|
|
34
|
+
|
|
35
|
+
export * from './lib/protocol/packets/index.js';
|
|
36
|
+
export * from './lib/Auth.js';
|
|
37
|
+
export * from './lib/constants/index.js';
|
|
38
|
+
export * from './lib/parsers/index.js';
|
|
41
39
|
|
|
42
40
|
// Expose class interfaces
|
|
43
|
-
export interface Connection extends BaseConnection {
|
|
44
|
-
promise(promiseImpl?: PromiseConstructor): PromiseConnection;
|
|
45
|
-
}
|
|
46
|
-
export interface PoolConnection extends BasePoolConnection {}
|
|
41
|
+
export interface Connection extends BaseConnection {}
|
|
47
42
|
export interface Pool extends BasePool {}
|
|
43
|
+
export interface PoolConnection extends BasePoolConnection {}
|
|
48
44
|
export interface PoolCluster extends BasePoolCluster {}
|
|
49
45
|
export interface Query extends BaseQuery {}
|
|
50
46
|
export interface Prepare extends BasePrepare {}
|
|
51
47
|
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
) => Promise<string> | string | Buffer | Promise<Buffer> | null;
|
|
48
|
+
export function createConnection(connectionUri: string): BaseConnection;
|
|
49
|
+
export function createConnection(config: ConnectionOptions): BaseConnection;
|
|
50
|
+
|
|
51
|
+
export function createPool(connectionUri: string): BasePool;
|
|
52
|
+
export function createPool(config: PoolOptions): BasePool;
|
|
58
53
|
|
|
59
|
-
|
|
54
|
+
export function createPoolCluster(config?: PoolClusterOptions): PoolCluster;
|
|
60
55
|
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
56
|
+
export function escape(value: any): string;
|
|
57
|
+
|
|
58
|
+
export function escapeId(value: any): string;
|
|
59
|
+
|
|
60
|
+
export function format(sql: string): string;
|
|
61
|
+
export function format(
|
|
62
|
+
sql: string,
|
|
63
|
+
values: any[],
|
|
64
|
+
stringifyObjects?: boolean,
|
|
65
|
+
timeZone?: string
|
|
66
|
+
): string;
|
|
67
|
+
|
|
68
|
+
export function format(
|
|
69
|
+
sql: string,
|
|
70
|
+
values: any,
|
|
71
|
+
stringifyObjects?: boolean,
|
|
72
|
+
timeZone?: string
|
|
73
|
+
): string;
|
|
74
|
+
|
|
75
|
+
export function raw(sql: string): {
|
|
76
|
+
toSqlString: () => string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export interface ConnectionConfig extends ConnectionOptions {
|
|
80
|
+
mergeFlags(defaultFlags: string[], userFlags: string[] | string): number;
|
|
81
|
+
getDefaultFlags(options?: ConnectionOptions): string[];
|
|
82
|
+
getCharsetNumber(charset: string): number;
|
|
83
|
+
getSSLProfile(name: string): { ca: string[] };
|
|
84
|
+
parseUrl(url: string): {
|
|
85
|
+
host: string;
|
|
86
|
+
port: number;
|
|
87
|
+
database: string;
|
|
88
|
+
user: string;
|
|
89
|
+
password: string;
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
};
|
|
78
92
|
}
|
|
93
|
+
|
|
94
|
+
export function createServer(handler: (conn: BaseConnection) => any): Server;
|