@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,65 @@
1
+ import { Sequence } from './Sequence.js';
2
+ import { Query, QueryError, StreamOptions } from '../sequences/Query.js';
3
+ import {
4
+ OkPacket,
5
+ FieldPacket,
6
+ RowDataPacket,
7
+ ResultSetHeader,
8
+ } from '../packets/index.js';
9
+ import { Readable } from 'stream';
10
+
11
+ export class PrepareStatementInfo {
12
+ close(): void;
13
+ execute<
14
+ T extends
15
+ | RowDataPacket[][]
16
+ | RowDataPacket[]
17
+ | OkPacket
18
+ | OkPacket[]
19
+ | ResultSetHeader,
20
+ >(
21
+ parameters: any | any[] | { [param: string]: any },
22
+ callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
23
+ ): Query;
24
+ }
25
+
26
+ declare class Prepare extends Sequence {
27
+ /**
28
+ * The SQL for a constructed query
29
+ */
30
+ sql: string;
31
+
32
+ /**
33
+ * Emits a query packet to start the query
34
+ */
35
+ start(): void;
36
+
37
+ /**
38
+ * Determines the packet class to use given the first byte of the packet.
39
+ *
40
+ * @param firstByte The first byte of the packet
41
+ * @param parser The packet parser
42
+ */
43
+ determinePacket(firstByte: number, parser: any): any;
44
+
45
+ /**
46
+ * Creates a Readable stream with the given options
47
+ *
48
+ * @param options The options for the stream.
49
+ */
50
+ stream(options?: StreamOptions): Readable;
51
+
52
+ on(event: string, listener: (args: []) => void): this;
53
+ on(event: 'error', listener: (err: QueryError) => any): this;
54
+ on(
55
+ event: 'fields',
56
+ listener: (fields: FieldPacket, index: number) => any
57
+ ): this;
58
+ on(
59
+ event: 'result',
60
+ listener: (result: RowDataPacket | OkPacket, index: number) => any
61
+ ): this;
62
+ on(event: 'end', listener: () => any): this;
63
+ }
64
+
65
+ export { Prepare };
@@ -0,0 +1,228 @@
1
+ import { Sequence } from './Sequence.js';
2
+ import { OkPacket, RowDataPacket, FieldPacket } from '../packets/index.js';
3
+ import { Readable } from 'stream';
4
+ import { Raw, Timezone } from 'sql-escaper';
5
+ import { TypeCast } from '../../parsers/typeCast.js';
6
+
7
+ export type ExecuteValues =
8
+ | string
9
+ | number
10
+ | bigint
11
+ | boolean
12
+ | Date
13
+ | null
14
+ | Blob
15
+ | Buffer
16
+ | Uint8Array
17
+ | ExecuteValues[]
18
+ | { [key: string]: ExecuteValues };
19
+
20
+ export type QueryValues =
21
+ | string
22
+ | number
23
+ | bigint
24
+ | boolean
25
+ | Date
26
+ | null
27
+ | undefined
28
+ | Blob
29
+ | Buffer
30
+ | Uint8Array
31
+ | Raw
32
+ | ({} | null | undefined)[]
33
+ | { [key: string]: QueryValues };
34
+
35
+ export interface QueryOptions {
36
+ /**
37
+ * The SQL for the query
38
+ */
39
+ sql: string;
40
+
41
+ /**
42
+ * The values for the query
43
+ */
44
+ values?: QueryValues;
45
+
46
+ /**
47
+ * This overrides the namedPlaceholders option set at the connection level.
48
+ */
49
+ namedPlaceholders?: boolean;
50
+
51
+ /**
52
+ * Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for
53
+ * operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout
54
+ * operations through the client. This means that when a timeout is reached, the connection it occurred on will be
55
+ * destroyed and no further operations can be performed.
56
+ */
57
+ timeout?: number;
58
+
59
+ /**
60
+ * Either a boolean or string. If true, tables will be nested objects. If string (e.g. '_'), tables will be
61
+ * nested as tableName_fieldName
62
+ */
63
+ nestTables?: any;
64
+
65
+ /**
66
+ * Determines if column values should be converted to native JavaScript types.
67
+ *
68
+ * @default true
69
+ *
70
+ * It is not recommended (and may go away / change in the future) to disable type casting, but you can currently do so on either the connection or query level.
71
+ *
72
+ * ---
73
+ *
74
+ * You can also specify a function to do the type casting yourself:
75
+ * ```ts
76
+ * (field: Field, next: () => unknown) => {
77
+ * return next();
78
+ * }
79
+ * ```
80
+ *
81
+ * ---
82
+ *
83
+ * **WARNING:**
84
+ *
85
+ * YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once:
86
+ *
87
+ * ```js
88
+ * field.string();
89
+ * field.buffer();
90
+ * field.geometry();
91
+ * ```
92
+
93
+ * Which are aliases for:
94
+ *
95
+ * ```js
96
+ * parser.parseLengthCodedString();
97
+ * parser.parseLengthCodedBuffer();
98
+ * parser.parseGeometryValue();
99
+ * ```
100
+ *
101
+ * You can find which field function you need to use by looking at `RowDataPacket.prototype._typeCast`.
102
+ */
103
+ typeCast?: TypeCast;
104
+
105
+ /**
106
+ * This overrides the same option set at the connection level.
107
+ *
108
+ */
109
+ rowsAsArray?: boolean;
110
+
111
+ /**
112
+ * By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
113
+ */
114
+ infileStreamFactory?: (path: string) => Readable;
115
+
116
+ /**
117
+ * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option
118
+ * (Default: false)
119
+ */
120
+ supportBigNumbers?: boolean;
121
+
122
+ /**
123
+ * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be
124
+ * always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving
125
+ * bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately
126
+ * represented with JavaScript Number objects (which happens when they exceed the [-2^53, +2^53] range),
127
+ * otherwise they will be returned as Number objects.
128
+ * This option is ignored if supportBigNumbers is disabled.
129
+ */
130
+ bigNumberStrings?: boolean;
131
+
132
+ /**
133
+ * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date
134
+ * objects. Can be true/false or an array of type names to keep as strings.
135
+ *
136
+ * (Default: false)
137
+ */
138
+ dateStrings?: boolean | Array<'TIMESTAMP' | 'DATETIME' | 'DATE'>;
139
+
140
+ /**
141
+ * The timezone used to store local dates. (Default: 'local')
142
+ */
143
+ timezone?: Timezone;
144
+ }
145
+
146
+ export interface StreamOptions {
147
+ /**
148
+ * Sets the max buffer size in objects of a stream
149
+ */
150
+ highWaterMark?: number;
151
+
152
+ /**
153
+ * The object mode of the stream is always set to `true`
154
+ */
155
+ objectMode?: true;
156
+ }
157
+
158
+ export interface QueryError extends NodeJS.ErrnoException {
159
+ /**
160
+ * Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'),
161
+ * a node.js error (e.g. 'ECONNREFUSED') or an internal error
162
+ * (e.g. 'PROTOCOL_CONNECTION_LOST').
163
+ */
164
+ code: string;
165
+
166
+ /**
167
+ * The sql state marker
168
+ */
169
+ sqlStateMarker?: string;
170
+
171
+ /**
172
+ * The sql state
173
+ */
174
+ sqlState?: string;
175
+
176
+ /**
177
+ * The field count
178
+ */
179
+ fieldCount?: number;
180
+
181
+ /**
182
+ * Boolean, indicating if this error is terminal to the connection object.
183
+ */
184
+ fatal: boolean;
185
+ }
186
+
187
+ declare class Query extends Sequence {
188
+ /**
189
+ * The SQL for a constructed query
190
+ */
191
+ sql: string;
192
+
193
+ /**
194
+ * Emits a query packet to start the query
195
+ */
196
+ start(): void;
197
+
198
+ /**
199
+ * Determines the packet class to use given the first byte of the packet.
200
+ *
201
+ * @param firstByte The first byte of the packet
202
+ * @param parser The packet parser
203
+ */
204
+ determinePacket(firstByte: number, parser: any): any;
205
+
206
+ /**
207
+ * Creates a Readable stream with the given options
208
+ *
209
+ * @param options The options for the stream.
210
+ */
211
+ stream(options?: StreamOptions): Readable;
212
+
213
+ on(event: string, listener: (...args: any[]) => void): this;
214
+ on(event: 'error', listener: (err: QueryError) => any): this;
215
+ on(
216
+ event: 'fields',
217
+ listener: (fields: FieldPacket, index: number) => any
218
+ ): this;
219
+ on(
220
+ event: 'result',
221
+ listener: (result: RowDataPacket | OkPacket, index: number) => any
222
+ ): this;
223
+ on(event: 'end', listener: () => any): this;
224
+ }
225
+
226
+ export type QueryableConstructor<T = object> = new (...args: any[]) => T;
227
+
228
+ export { Query };
@@ -0,0 +1,41 @@
1
+ import { FieldPacket, QueryResult } from '../packets/index.js';
2
+ import {
3
+ Query,
4
+ QueryError,
5
+ QueryOptions,
6
+ QueryValues,
7
+ QueryableConstructor,
8
+ } from './Query.js';
9
+
10
+ export declare function QueryableBase<T extends QueryableConstructor>(
11
+ Base?: T
12
+ ): {
13
+ new (...args: any[]): {
14
+ query<T extends QueryResult>(
15
+ sql: string,
16
+ callback?:
17
+ | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
18
+ | undefined
19
+ ): Query;
20
+ query<T extends QueryResult>(
21
+ sql: string,
22
+ values: QueryValues,
23
+ callback?:
24
+ | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
25
+ | undefined
26
+ ): Query;
27
+ query<T extends QueryResult>(
28
+ options: QueryOptions,
29
+ callback?:
30
+ | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
31
+ | undefined
32
+ ): Query;
33
+ query<T extends QueryResult>(
34
+ options: QueryOptions,
35
+ values: QueryValues,
36
+ callback?:
37
+ | ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
38
+ | undefined
39
+ ): Query;
40
+ };
41
+ } & T;
@@ -0,0 +1,5 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ declare class Sequence extends EventEmitter {}
4
+
5
+ export { Sequence };
@@ -0,0 +1,17 @@
1
+ import { FieldPacket, QueryResult } from '../../packets/index.js';
2
+ import { QueryOptions, QueryableConstructor, ExecuteValues } from '../Query.js';
3
+
4
+ export declare function ExecutableBase<T extends QueryableConstructor>(
5
+ Base?: T
6
+ ): {
7
+ new (...args: any[]): {
8
+ execute<T extends QueryResult>(
9
+ sql: string,
10
+ values?: ExecuteValues
11
+ ): Promise<[T, FieldPacket[]]>;
12
+ execute<T extends QueryResult>(
13
+ options: QueryOptions,
14
+ values?: ExecuteValues
15
+ ): Promise<[T, FieldPacket[]]>;
16
+ };
17
+ } & T;
@@ -0,0 +1,18 @@
1
+ import { FieldPacket, QueryResult } from '../../packets/index.js';
2
+ import { QueryOptions, QueryValues, QueryableConstructor } from '../Query.js';
3
+
4
+ export declare function QueryableBase<T extends QueryableConstructor>(
5
+ Base?: T
6
+ ): {
7
+ new (...args: any[]): {
8
+ query<T extends QueryResult>(
9
+ sql: string,
10
+ values?: QueryValues
11
+ ): Promise<[T, FieldPacket[]]>;
12
+
13
+ query<T extends QueryResult>(
14
+ options: QueryOptions,
15
+ values?: QueryValues
16
+ ): Promise<[T, FieldPacket[]]>;
17
+ };
18
+ } & T;