@depup/mysql2 3.19.0-depup.0

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.
Files changed (124) hide show
  1. package/License +19 -0
  2. package/README.md +114 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +77 -0
  5. package/lib/auth_41.js +95 -0
  6. package/lib/auth_plugins/caching_sha2_password.js +114 -0
  7. package/lib/auth_plugins/caching_sha2_password.md +18 -0
  8. package/lib/auth_plugins/index.js +8 -0
  9. package/lib/auth_plugins/mysql_clear_password.js +17 -0
  10. package/lib/auth_plugins/mysql_native_password.js +34 -0
  11. package/lib/auth_plugins/sha256_password.js +68 -0
  12. package/lib/base/connection.js +988 -0
  13. package/lib/base/pool.js +282 -0
  14. package/lib/base/pool_connection.js +77 -0
  15. package/lib/commands/auth_switch.js +129 -0
  16. package/lib/commands/binlog_dump.js +109 -0
  17. package/lib/commands/change_user.js +68 -0
  18. package/lib/commands/client_handshake.js +383 -0
  19. package/lib/commands/close_statement.js +18 -0
  20. package/lib/commands/command.js +54 -0
  21. package/lib/commands/execute.js +112 -0
  22. package/lib/commands/index.js +27 -0
  23. package/lib/commands/ping.js +36 -0
  24. package/lib/commands/prepare.js +143 -0
  25. package/lib/commands/query.js +361 -0
  26. package/lib/commands/quit.js +29 -0
  27. package/lib/commands/register_slave.js +27 -0
  28. package/lib/commands/server_handshake.js +202 -0
  29. package/lib/compressed_protocol.js +153 -0
  30. package/lib/connection.js +12 -0
  31. package/lib/connection_config.js +293 -0
  32. package/lib/constants/charset_encodings.js +317 -0
  33. package/lib/constants/charsets.js +317 -0
  34. package/lib/constants/client.js +38 -0
  35. package/lib/constants/commands.js +36 -0
  36. package/lib/constants/cursor.js +8 -0
  37. package/lib/constants/encoding_charset.js +50 -0
  38. package/lib/constants/errors.js +3973 -0
  39. package/lib/constants/field_flags.js +20 -0
  40. package/lib/constants/server_status.js +44 -0
  41. package/lib/constants/session_track.js +11 -0
  42. package/lib/constants/ssl_profiles.js +11 -0
  43. package/lib/constants/types.js +64 -0
  44. package/lib/create_connection.js +10 -0
  45. package/lib/create_pool.js +10 -0
  46. package/lib/create_pool_cluster.js +9 -0
  47. package/lib/helpers.js +83 -0
  48. package/lib/packet_parser.js +195 -0
  49. package/lib/packets/auth_next_factor.js +35 -0
  50. package/lib/packets/auth_switch_request.js +38 -0
  51. package/lib/packets/auth_switch_request_more_data.js +33 -0
  52. package/lib/packets/auth_switch_response.js +30 -0
  53. package/lib/packets/binary_row.js +95 -0
  54. package/lib/packets/binlog_dump.js +33 -0
  55. package/lib/packets/binlog_query_statusvars.js +115 -0
  56. package/lib/packets/change_user.js +97 -0
  57. package/lib/packets/close_statement.js +21 -0
  58. package/lib/packets/column_definition.js +291 -0
  59. package/lib/packets/execute.js +214 -0
  60. package/lib/packets/handshake.js +112 -0
  61. package/lib/packets/handshake_response.js +173 -0
  62. package/lib/packets/index.js +152 -0
  63. package/lib/packets/packet.js +946 -0
  64. package/lib/packets/prepare_statement.js +27 -0
  65. package/lib/packets/prepared_statement_header.js +16 -0
  66. package/lib/packets/query.js +27 -0
  67. package/lib/packets/register_slave.js +46 -0
  68. package/lib/packets/resultset_header.js +124 -0
  69. package/lib/packets/ssl_request.js +25 -0
  70. package/lib/packets/text_row.js +47 -0
  71. package/lib/parsers/binary_parser.js +235 -0
  72. package/lib/parsers/parser_cache.js +68 -0
  73. package/lib/parsers/static_binary_parser.js +213 -0
  74. package/lib/parsers/static_text_parser.js +152 -0
  75. package/lib/parsers/string.js +50 -0
  76. package/lib/parsers/text_parser.js +214 -0
  77. package/lib/pool.js +12 -0
  78. package/lib/pool_cluster.js +375 -0
  79. package/lib/pool_config.js +30 -0
  80. package/lib/pool_connection.js +12 -0
  81. package/lib/promise/connection.js +228 -0
  82. package/lib/promise/inherit_events.js +27 -0
  83. package/lib/promise/make_done_cb.js +19 -0
  84. package/lib/promise/pool.js +118 -0
  85. package/lib/promise/pool_cluster.js +54 -0
  86. package/lib/promise/pool_connection.js +23 -0
  87. package/lib/promise/prepared_statement_info.js +32 -0
  88. package/lib/results_stream.js +38 -0
  89. package/lib/server.js +37 -0
  90. package/package.json +96 -0
  91. package/promise.d.ts +139 -0
  92. package/promise.js +208 -0
  93. package/typings/mysql/LICENSE.txt +15 -0
  94. package/typings/mysql/index.d.ts +84 -0
  95. package/typings/mysql/info.txt +1 -0
  96. package/typings/mysql/lib/Auth.d.ts +30 -0
  97. package/typings/mysql/lib/Connection.d.ts +442 -0
  98. package/typings/mysql/lib/Pool.d.ts +71 -0
  99. package/typings/mysql/lib/PoolCluster.d.ts +92 -0
  100. package/typings/mysql/lib/PoolConnection.d.ts +11 -0
  101. package/typings/mysql/lib/Server.d.ts +11 -0
  102. package/typings/mysql/lib/constants/CharsetToEncoding.d.ts +8 -0
  103. package/typings/mysql/lib/constants/Charsets.d.ts +326 -0
  104. package/typings/mysql/lib/constants/Types.d.ts +70 -0
  105. package/typings/mysql/lib/constants/index.d.ts +5 -0
  106. package/typings/mysql/lib/parsers/ParserCache.d.ts +4 -0
  107. package/typings/mysql/lib/parsers/index.d.ts +18 -0
  108. package/typings/mysql/lib/parsers/typeCast.d.ts +54 -0
  109. package/typings/mysql/lib/protocol/packets/Field.d.ts +10 -0
  110. package/typings/mysql/lib/protocol/packets/FieldPacket.d.ts +27 -0
  111. package/typings/mysql/lib/protocol/packets/OkPacket.d.ts +23 -0
  112. package/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts +13 -0
  113. package/typings/mysql/lib/protocol/packets/ResultSetHeader.d.ts +18 -0
  114. package/typings/mysql/lib/protocol/packets/RowDataPacket.d.ts +9 -0
  115. package/typings/mysql/lib/protocol/packets/index.d.ts +28 -0
  116. package/typings/mysql/lib/protocol/packets/params/ErrorPacketParams.d.ts +6 -0
  117. package/typings/mysql/lib/protocol/packets/params/OkPacketParams.d.ts +9 -0
  118. package/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts +41 -0
  119. package/typings/mysql/lib/protocol/sequences/Prepare.d.ts +65 -0
  120. package/typings/mysql/lib/protocol/sequences/Query.d.ts +228 -0
  121. package/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts +41 -0
  122. package/typings/mysql/lib/protocol/sequences/Sequence.d.ts +5 -0
  123. package/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts +17 -0
  124. package/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts +18 -0
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ const EventEmitter = require('events').EventEmitter;
4
+ const makeDoneCb = require('./make_done_cb.js');
5
+ const PromisePoolConnection = require('./pool_connection.js');
6
+ const inheritEvents = require('./inherit_events.js');
7
+ const BasePool = require('../base/pool.js');
8
+
9
+ class PromisePool extends EventEmitter {
10
+ constructor(pool, thePromise) {
11
+ super();
12
+ this.pool = pool;
13
+ this.Promise = thePromise || Promise;
14
+ inheritEvents(pool, this, ['acquire', 'connection', 'enqueue', 'release']);
15
+ }
16
+
17
+ getConnection() {
18
+ const corePool = this.pool;
19
+ return new this.Promise((resolve, reject) => {
20
+ corePool.getConnection((err, coreConnection) => {
21
+ if (err) {
22
+ reject(err);
23
+ } else {
24
+ resolve(new PromisePoolConnection(coreConnection, this.Promise));
25
+ }
26
+ });
27
+ });
28
+ }
29
+
30
+ releaseConnection(connection) {
31
+ if (connection instanceof PromisePoolConnection) connection.release();
32
+ }
33
+
34
+ query(sql, args) {
35
+ const corePool = this.pool;
36
+ const localErr = new Error();
37
+ if (typeof args === 'function') {
38
+ throw new Error(
39
+ 'Callback function is not available with promise clients.'
40
+ );
41
+ }
42
+ return new this.Promise((resolve, reject) => {
43
+ const done = makeDoneCb(resolve, reject, localErr);
44
+ if (args !== undefined) {
45
+ corePool.query(sql, args, done);
46
+ } else {
47
+ corePool.query(sql, done);
48
+ }
49
+ });
50
+ }
51
+
52
+ execute(sql, args) {
53
+ const corePool = this.pool;
54
+ const localErr = new Error();
55
+ if (typeof args === 'function') {
56
+ throw new Error(
57
+ 'Callback function is not available with promise clients.'
58
+ );
59
+ }
60
+ return new this.Promise((resolve, reject) => {
61
+ const done = makeDoneCb(resolve, reject, localErr);
62
+ if (args) {
63
+ corePool.execute(sql, args, done);
64
+ } else {
65
+ corePool.execute(sql, done);
66
+ }
67
+ });
68
+ }
69
+
70
+ end() {
71
+ const corePool = this.pool;
72
+ const localErr = new Error();
73
+ return new this.Promise((resolve, reject) => {
74
+ corePool.end((err) => {
75
+ if (err) {
76
+ localErr.message = err.message;
77
+ localErr.code = err.code;
78
+ localErr.errno = err.errno;
79
+ localErr.sqlState = err.sqlState;
80
+ localErr.sqlMessage = err.sqlMessage;
81
+ reject(localErr);
82
+ } else {
83
+ resolve();
84
+ }
85
+ });
86
+ });
87
+ }
88
+
89
+ async [Symbol.asyncDispose]() {
90
+ if (!this.pool._closed) {
91
+ await this.end();
92
+ }
93
+ }
94
+ }
95
+
96
+ (function (functionsToWrap) {
97
+ for (let i = 0; functionsToWrap && i < functionsToWrap.length; i++) {
98
+ const func = functionsToWrap[i];
99
+
100
+ if (
101
+ typeof BasePool.prototype[func] === 'function' &&
102
+ PromisePool.prototype[func] === undefined
103
+ ) {
104
+ PromisePool.prototype[func] = (function factory(funcName) {
105
+ return function () {
106
+ return BasePool.prototype[funcName].apply(this.pool, arguments);
107
+ };
108
+ })(func);
109
+ }
110
+ }
111
+ })([
112
+ // synchronous functions
113
+ 'escape',
114
+ 'escapeId',
115
+ 'format',
116
+ ]);
117
+
118
+ module.exports = PromisePool;
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ const PromisePoolConnection = require('./pool_connection');
4
+ const makeDoneCb = require('./make_done_cb');
5
+
6
+ class PromisePoolNamespace {
7
+ constructor(poolNamespace, thePromise) {
8
+ this.poolNamespace = poolNamespace;
9
+ this.Promise = thePromise || Promise;
10
+ }
11
+
12
+ getConnection() {
13
+ const corePoolNamespace = this.poolNamespace;
14
+ return new this.Promise((resolve, reject) => {
15
+ corePoolNamespace.getConnection((err, coreConnection) => {
16
+ if (err) {
17
+ reject(err);
18
+ } else {
19
+ resolve(new PromisePoolConnection(coreConnection, this.Promise));
20
+ }
21
+ });
22
+ });
23
+ }
24
+
25
+ query(sql, values) {
26
+ const corePoolNamespace = this.poolNamespace;
27
+ const localErr = new Error();
28
+ if (typeof values === 'function') {
29
+ throw new Error(
30
+ 'Callback function is not available with promise clients.'
31
+ );
32
+ }
33
+ return new this.Promise((resolve, reject) => {
34
+ const done = makeDoneCb(resolve, reject, localErr);
35
+ corePoolNamespace.query(sql, values, done);
36
+ });
37
+ }
38
+
39
+ execute(sql, values) {
40
+ const corePoolNamespace = this.poolNamespace;
41
+ const localErr = new Error();
42
+ if (typeof values === 'function') {
43
+ throw new Error(
44
+ 'Callback function is not available with promise clients.'
45
+ );
46
+ }
47
+ return new this.Promise((resolve, reject) => {
48
+ const done = makeDoneCb(resolve, reject, localErr);
49
+ corePoolNamespace.execute(sql, values, done);
50
+ });
51
+ }
52
+ }
53
+
54
+ module.exports = PromisePoolNamespace;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ const PromiseConnection = require('./connection.js');
4
+ const BasePoolConnection = require('../base/pool_connection.js');
5
+
6
+ class PromisePoolConnection extends PromiseConnection {
7
+ constructor(connection, promiseImpl) {
8
+ super(connection, promiseImpl);
9
+ }
10
+
11
+ destroy() {
12
+ return BasePoolConnection.prototype.destroy.apply(
13
+ this.connection,
14
+ arguments
15
+ );
16
+ }
17
+
18
+ async [Symbol.asyncDispose]() {
19
+ this.release();
20
+ }
21
+ }
22
+
23
+ module.exports = PromisePoolConnection;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ const makeDoneCb = require('./make_done_cb.js');
4
+
5
+ class PromisePreparedStatementInfo {
6
+ constructor(statement, promiseImpl) {
7
+ this.statement = statement;
8
+ this.Promise = promiseImpl;
9
+ }
10
+
11
+ execute(parameters) {
12
+ const s = this.statement;
13
+ const localErr = new Error();
14
+ return new this.Promise((resolve, reject) => {
15
+ const done = makeDoneCb(resolve, reject, localErr);
16
+ if (parameters) {
17
+ s.execute(parameters, done);
18
+ } else {
19
+ s.execute(done);
20
+ }
21
+ });
22
+ }
23
+
24
+ close() {
25
+ return new this.Promise((resolve) => {
26
+ this.statement.close();
27
+ resolve();
28
+ });
29
+ }
30
+ }
31
+
32
+ module.exports = PromisePreparedStatementInfo;
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ const Readable = require('stream').Readable;
4
+
5
+ // copy-paste from https://github.com/mysqljs/mysql/blob/master/lib/protocol/sequences/Query.js
6
+ module.exports = function (command, connectionStream) {
7
+ command.stream = function (options) {
8
+ let stream;
9
+
10
+ options = options || {};
11
+ options.objectMode = true;
12
+ ((stream = new Readable(options)),
13
+ (stream._read = function () {
14
+ connectionStream.resume();
15
+ }));
16
+
17
+ this.on('result', (row, i) => {
18
+ if (!stream.push(row)) {
19
+ connectionStream.pause();
20
+ }
21
+ stream.emit('result', row, i); // replicate old emitter
22
+ });
23
+
24
+ this.on('error', (err) => {
25
+ stream.emit('error', err); // Pass on any errors
26
+ });
27
+
28
+ this.on('end', () => {
29
+ stream.push(null); // pushing null, indicating EOF
30
+ });
31
+
32
+ this.on('fields', (fields, i) => {
33
+ stream.emit('fields', fields, i); // replicate old emitter
34
+ });
35
+
36
+ return stream;
37
+ };
38
+ };
package/lib/server.js ADDED
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ const net = require('net');
4
+ const EventEmitter = require('events').EventEmitter;
5
+
6
+ const Connection = require('./connection');
7
+ const ConnectionConfig = require('./connection_config');
8
+
9
+ // TODO: inherit Server from net.Server
10
+ class Server extends EventEmitter {
11
+ constructor() {
12
+ super();
13
+ this.connections = [];
14
+ this._server = net.createServer(this._handleConnection.bind(this));
15
+ }
16
+
17
+ _handleConnection(socket) {
18
+ const connectionConfig = new ConnectionConfig({
19
+ stream: socket,
20
+ isServer: true,
21
+ });
22
+ const connection = new Connection({ config: connectionConfig });
23
+ this.emit('connection', connection);
24
+ }
25
+
26
+ listen(port) {
27
+ this._port = port;
28
+ this._server.listen.apply(this._server, arguments);
29
+ return this;
30
+ }
31
+
32
+ close(cb) {
33
+ this._server.close(cb);
34
+ }
35
+ }
36
+
37
+ module.exports = Server;
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@depup/mysql2",
3
+ "version": "3.19.0-depup.0",
4
+ "description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
5
+ "main": "index.js",
6
+ "typings": "typings/mysql/index",
7
+ "type": "commonjs",
8
+ "scripts": {
9
+ "lint": "eslint . && prettier --check .",
10
+ "lint:fix": "eslint . --fix && prettier --write .",
11
+ "test": "npm run test:parallel && npm run test:global",
12
+ "test:parallel": "poku -c=\"poku.config.mjs\" test",
13
+ "test:global": "cross-env SUITE=global poku -c=\"poku.config.mjs\" test/global",
14
+ "test:bun": "npm run test:bun:parallel && npm run test:bun:global",
15
+ "test:bun:parallel": "bun poku -c=\"poku.config.mjs\" test",
16
+ "test:bun:global": "cross-env SUITE=global bun poku -c=\"poku.config.mjs\" test/global",
17
+ "test:deno": "npm run test:deno:parallel && npm run test:deno:global",
18
+ "test:deno:parallel": "deno run --allow-read --allow-env --allow-run npm:poku@canary -c=\"poku.config.mjs\" test",
19
+ "test:deno:global": "cross-env SUITE=global deno run --allow-read --allow-env --allow-run npm:poku@canary -c=\"poku.config.mjs\" test/global",
20
+ "test:docker:up": "docker compose -f test/docker-compose.yml up --abort-on-container-exit --remove-orphans",
21
+ "test:docker:down": "docker compose -f test/docker-compose.yml down",
22
+ "test:docker:node": "npm run test:docker:up -- node && npm run test:docker:down",
23
+ "test:docker:bun": "npm run test:docker:up -- bun && npm run test:docker:down",
24
+ "test:docker:deno": "npm run test:docker:up -- deno && npm run test:docker:down",
25
+ "test:docker:coverage": "npm run test:docker:up -- coverage && npm run test:docker:down",
26
+ "test:coverage": "c8 npm test",
27
+ "typecheck": "cd \"test/tsc-build\" && tsc -p \"tsconfig.json\" && cd .. && tsc -p \"tsconfig.json\" --noEmit",
28
+ "benchmark": "node ./benchmarks/benchmark.js",
29
+ "wait-port": "wait-on"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/sidorares/node-mysql2.git"
34
+ },
35
+ "homepage": "https://sidorares.github.io/node-mysql2/docs",
36
+ "keywords": [
37
+ "mysql",
38
+ "client",
39
+ "server"
40
+ ],
41
+ "files": [
42
+ "lib",
43
+ "typings/mysql",
44
+ "index.js",
45
+ "index.d.ts",
46
+ "promise.js",
47
+ "promise.d.ts"
48
+ ],
49
+ "exports": {
50
+ ".": "./index.js",
51
+ "./package.json": "./package.json",
52
+ "./promise": "./promise.js",
53
+ "./promise.js": "./promise.js"
54
+ },
55
+ "engines": {
56
+ "node": ">= 8.0"
57
+ },
58
+ "author": "Andrey Sidorov <andrey.sidorov@gmail.com>",
59
+ "license": "MIT",
60
+ "dependencies": {
61
+ "aws-ssl-profiles": "^1.1.2",
62
+ "denque": "^2.1.0",
63
+ "generate-function": "^2.3.1",
64
+ "iconv-lite": "^0.7.2",
65
+ "long": "^5.3.2",
66
+ "lru.min": "^1.1.4",
67
+ "named-placeholders": "^1.1.6",
68
+ "sql-escaper": "^1.3.3"
69
+ },
70
+ "peerDependencies": {
71
+ "@types/node": ">= 8"
72
+ },
73
+ "devDependencies": {
74
+ "@eslint/eslintrc": "^3.3.3",
75
+ "@eslint/js": "^9.39.2",
76
+ "@eslint/markdown": "^7.5.1",
77
+ "@ianvs/prettier-plugin-sort-imports": "^4.7.1",
78
+ "@types/node": "^25.3.0",
79
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
80
+ "@typescript-eslint/parser": "^8.56.0",
81
+ "assert-diff": "^3.0.4",
82
+ "benchmark": "^2.1.4",
83
+ "c8": "^11.0.0",
84
+ "cross-env": "^10.1.0",
85
+ "error-stack-parser": "^2.1.4",
86
+ "eslint-config-prettier": "^10.1.8",
87
+ "eslint-plugin-async-await": "^0.0.0",
88
+ "eslint-plugin-prettier": "^5.5.5",
89
+ "globals": "^17.3.0",
90
+ "poku": "^3.0.3-canary.8f374795",
91
+ "portfinder": "^1.0.38",
92
+ "prettier": "^3.8.1",
93
+ "tsx": "^4.21.0",
94
+ "typescript": "^5.9.3"
95
+ }
96
+ }
package/promise.d.ts ADDED
@@ -0,0 +1,139 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ import {
4
+ RowDataPacket,
5
+ OkPacket,
6
+ ResultSetHeader,
7
+ FieldPacket,
8
+ QueryOptions,
9
+ ConnectionOptions,
10
+ PoolOptions,
11
+ PoolClusterOptions,
12
+ Pool as CorePool,
13
+ ConnectionState,
14
+ } from './index.js';
15
+ import { ExecutableBase as ExecutableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/ExecutableBase.js';
16
+ import { QueryableBase as QueryableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/QueryableBase.js';
17
+
18
+ export * from './index.js';
19
+
20
+ // Expose class interfaces
21
+ declare class QueryableAndExecutableBase extends QueryableBaseClass(
22
+ ExecutableBaseClass(EventEmitter)
23
+ ) {}
24
+
25
+ export interface PreparedStatementInfo {
26
+ close(): Promise<void>;
27
+ execute(
28
+ parameters: any | any[] | { [param: string]: any }
29
+ ): Promise<
30
+ [
31
+ (
32
+ | RowDataPacket[][]
33
+ | RowDataPacket[]
34
+ | OkPacket
35
+ | OkPacket[]
36
+ | ResultSetHeader
37
+ ),
38
+ FieldPacket[],
39
+ ]
40
+ >;
41
+ }
42
+
43
+ export interface Connection extends QueryableAndExecutableBase {
44
+ config: ConnectionOptions;
45
+
46
+ threadId: number;
47
+
48
+ readonly state: ConnectionState;
49
+
50
+ connect(): Promise<void>;
51
+
52
+ ping(): Promise<void>;
53
+
54
+ beginTransaction(): Promise<void>;
55
+
56
+ commit(): Promise<void>;
57
+
58
+ rollback(): Promise<void>;
59
+
60
+ changeUser(options: ConnectionOptions): Promise<void>;
61
+
62
+ prepare(options: string | QueryOptions): Promise<PreparedStatementInfo>;
63
+
64
+ unprepare(sql: string | QueryOptions): void;
65
+
66
+ end(options?: any): Promise<void>;
67
+
68
+ [Symbol.asyncDispose](): Promise<void>;
69
+
70
+ destroy(): void;
71
+
72
+ pause(): void;
73
+
74
+ resume(): void;
75
+
76
+ escape(value: any): string;
77
+
78
+ escapeId(value: string): string;
79
+ escapeId(values: string[]): string;
80
+
81
+ format(sql: string, values?: any | any[] | { [param: string]: any }): string;
82
+ }
83
+
84
+ export interface PoolConnection extends Connection {
85
+ release(): void;
86
+ connection: Connection;
87
+ [Symbol.asyncDispose](): Promise<void>;
88
+ }
89
+
90
+ export interface Pool extends Connection {
91
+ getConnection(): Promise<PoolConnection>;
92
+
93
+ releaseConnection(connection: PoolConnection): void;
94
+
95
+ on(event: 'connection', listener: (connection: PoolConnection) => any): this;
96
+ on(event: 'acquire', listener: (connection: PoolConnection) => any): this;
97
+ on(event: 'release', listener: (connection: PoolConnection) => any): this;
98
+ on(event: 'enqueue', listener: () => any): this;
99
+
100
+ end(): Promise<void>;
101
+
102
+ pool: CorePool;
103
+ }
104
+
105
+ export interface PoolNamespace extends QueryableAndExecutableBase {
106
+ getConnection(): Promise<PoolConnection>;
107
+ }
108
+
109
+ export interface PoolCluster extends EventEmitter {
110
+ config: PoolClusterOptions;
111
+
112
+ add(config: PoolOptions): void;
113
+ add(group: string, connectionUri: string): void;
114
+ add(group: string, config: PoolOptions): void;
115
+
116
+ end(): Promise<void>;
117
+
118
+ [Symbol.asyncDispose](): Promise<void>;
119
+
120
+ getConnection(): Promise<PoolConnection>;
121
+ getConnection(group: string): Promise<PoolConnection>;
122
+ getConnection(group: string, selector: string): Promise<PoolConnection>;
123
+
124
+ of(pattern: string, selector?: string): PoolNamespace;
125
+
126
+ on(event: string, listener: (...args: any[]) => void): this;
127
+ on(event: 'remove', listener: (nodeId: number) => void): this;
128
+ on(event: 'warn', listener: (err: Error) => void): this;
129
+ }
130
+
131
+ export function createConnection(connectionUri: string): Promise<Connection>;
132
+ export function createConnection(
133
+ config: ConnectionOptions
134
+ ): Promise<Connection>;
135
+
136
+ export function createPool(connectionUri: string): Pool;
137
+ export function createPool(config: PoolOptions): Pool;
138
+
139
+ export function createPoolCluster(config?: PoolClusterOptions): PoolCluster;