@tachybase/module-multi-app 1.6.0 → 1.6.2

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 (105) hide show
  1. package/README.md +34 -34
  2. package/README.zh-CN.md +34 -34
  3. package/client.d.ts +1 -1
  4. package/client.js +1 -1
  5. package/dist/externalVersion.js +5 -5
  6. package/dist/locale/en-US.json +48 -48
  7. package/dist/locale/es-ES.json +9 -9
  8. package/dist/locale/ko_KR.json +11 -11
  9. package/dist/locale/pt-BR.json +9 -9
  10. package/dist/locale/zh-CN.json +58 -58
  11. package/dist/node_modules/mariadb/callback.js +43 -8
  12. package/dist/node_modules/mariadb/check-node.js +30 -0
  13. package/dist/node_modules/mariadb/lib/cluster-callback.js +84 -0
  14. package/dist/node_modules/mariadb/lib/cluster.js +446 -0
  15. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +576 -177
  16. package/dist/node_modules/mariadb/lib/cmd/change-user.js +54 -44
  17. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +3 -2
  18. package/dist/node_modules/mariadb/lib/cmd/class/prepare-cache-wrapper.js +46 -0
  19. package/dist/node_modules/mariadb/lib/cmd/class/prepare-result-packet.js +141 -0
  20. package/dist/node_modules/mariadb/lib/cmd/class/prepare-wrapper.js +70 -0
  21. package/dist/node_modules/mariadb/lib/cmd/close-prepare.js +38 -0
  22. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +145 -47
  23. package/dist/node_modules/mariadb/lib/cmd/command.js +41 -75
  24. package/dist/node_modules/mariadb/lib/cmd/decoder/binary-decoder.js +282 -0
  25. package/dist/node_modules/mariadb/lib/cmd/decoder/text-decoder.js +210 -0
  26. package/dist/node_modules/mariadb/lib/cmd/{common-binary-cmd.js → encoder/binary-encoder.js} +34 -77
  27. package/dist/node_modules/mariadb/lib/cmd/encoder/text-encoder.js +311 -0
  28. package/dist/node_modules/mariadb/lib/cmd/execute-stream.js +61 -0
  29. package/dist/node_modules/mariadb/lib/cmd/execute.js +338 -0
  30. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +25 -62
  31. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +39 -6
  32. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +48 -16
  33. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/handshake.js +198 -0
  34. package/dist/node_modules/mariadb/lib/cmd/handshake/{initial-handshake.js → auth/initial-handshake.js} +10 -8
  35. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +22 -9
  36. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +9 -4
  37. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/parsec-auth.js +115 -0
  38. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +12 -5
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +44 -33
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/authentication.js +335 -0
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +20 -19
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +6 -3
  43. package/dist/node_modules/mariadb/lib/cmd/parser.js +861 -0
  44. package/dist/node_modules/mariadb/lib/cmd/ping.js +17 -18
  45. package/dist/node_modules/mariadb/lib/cmd/prepare.js +170 -0
  46. package/dist/node_modules/mariadb/lib/cmd/query.js +281 -144
  47. package/dist/node_modules/mariadb/lib/cmd/quit.js +9 -6
  48. package/dist/node_modules/mariadb/lib/cmd/reset.js +15 -19
  49. package/dist/node_modules/mariadb/lib/cmd/stream.js +21 -6
  50. package/dist/node_modules/mariadb/lib/config/cluster-options.js +23 -0
  51. package/dist/node_modules/mariadb/lib/config/connection-options.js +196 -132
  52. package/dist/node_modules/mariadb/lib/config/pool-options.js +27 -19
  53. package/dist/node_modules/mariadb/lib/connection-callback.js +492 -120
  54. package/dist/node_modules/mariadb/lib/connection-promise.js +372 -0
  55. package/dist/node_modules/mariadb/lib/connection.js +1739 -1016
  56. package/dist/node_modules/mariadb/lib/const/capabilities.js +36 -30
  57. package/dist/node_modules/mariadb/lib/const/collations.js +972 -36
  58. package/dist/node_modules/mariadb/lib/const/connection_status.js +3 -0
  59. package/dist/node_modules/mariadb/lib/const/error-code.js +35 -11
  60. package/dist/node_modules/mariadb/lib/const/field-detail.js +3 -0
  61. package/dist/node_modules/mariadb/lib/const/field-type.js +7 -4
  62. package/dist/node_modules/mariadb/lib/const/server-status.js +4 -1
  63. package/dist/node_modules/mariadb/lib/const/state-change.js +3 -0
  64. package/dist/node_modules/mariadb/lib/filtered-cluster-callback.js +136 -0
  65. package/dist/node_modules/mariadb/lib/filtered-cluster.js +118 -0
  66. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +14 -13
  67. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +21 -18
  68. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +75 -64
  69. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +13 -9
  70. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +12 -10
  71. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +402 -134
  72. package/dist/node_modules/mariadb/lib/io/packet.js +287 -202
  73. package/dist/node_modules/mariadb/lib/lru-prepare-cache.js +84 -0
  74. package/dist/node_modules/mariadb/lib/misc/connection-information.js +15 -32
  75. package/dist/node_modules/mariadb/lib/misc/errors.js +68 -25
  76. package/dist/node_modules/mariadb/lib/misc/parse.js +207 -711
  77. package/dist/node_modules/mariadb/lib/misc/utils.js +34 -62
  78. package/dist/node_modules/mariadb/lib/pool-callback.js +213 -174
  79. package/dist/node_modules/mariadb/lib/pool-promise.js +228 -94
  80. package/dist/node_modules/mariadb/lib/pool.js +951 -0
  81. package/dist/node_modules/mariadb/package.json +1 -1
  82. package/dist/node_modules/mariadb/promise.js +1 -34
  83. package/dist/node_modules/mariadb/types/callback.d.ts +207 -0
  84. package/dist/node_modules/mariadb/types/index.d.ts +94 -674
  85. package/dist/node_modules/mariadb/types/share.d.ts +804 -0
  86. package/dist/node_modules/qs/package.json +1 -1
  87. package/dist/server/actions/apps.js +2 -2
  88. package/dist/server/app-lifecycle.d.ts +1 -1
  89. package/dist/server/app-lifecycle.js +4 -4
  90. package/dist/server/models/application.d.ts +1 -1
  91. package/package.json +7 -7
  92. package/server.d.ts +2 -2
  93. package/server.js +1 -1
  94. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  95. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  96. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  97. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  98. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  99. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  100. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  101. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  102. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  103. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  104. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  105. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
@@ -1,476 +1,47 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2025 MariaDB Corporation Ab
3
+
1
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
5
  // Type definitions for mariadb 2.5
3
6
  // Project: https://github.com/mariadb-corporation/mariadb-connector-nodejs
4
- // Definitions by: Diego Dupin <https://github.com/rusher>
7
+ // Definitions by: Diego Dupin <https://github.com/rusher>
5
8
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
9
  // TypeScript Version: 2.1
7
10
 
8
- import tls = require('tls');
9
- import stream = require('stream');
10
- import geojson = require('geojson');
11
-
12
- export const version: string;
13
- export function createConnection(connectionUri: string | ConnectionConfig): Promise<Connection>;
14
- export function createPool(config: PoolConfig | string): Pool;
15
- export function createPoolCluster(config?: PoolClusterConfig): PoolCluster;
16
- export function defaultOptions(connectionUri?: string | ConnectionConfig): any;
17
-
18
- export type TypeCastResult =
19
- | boolean
20
- | number
21
- | string
22
- | symbol
23
- | null
24
- | Date
25
- | geojson.Geometry
26
- | Buffer;
27
- export type TypeCastNextFunction = () => TypeCastResult;
28
- export type TypeCastFunction = (field: FieldInfo, next: TypeCastNextFunction) => TypeCastResult;
29
-
30
- export interface QueryConfig {
31
- /**
32
- * Presents result-sets by table to avoid results with colliding fields. See the query() description for more information.
33
- */
34
- nestTables?: boolean | string;
35
-
36
- /**
37
- * Allows to cast result types.
38
- */
39
- typeCast?: TypeCastFunction;
11
+ import { Readable } from 'stream';
12
+ import { EventEmitter } from 'events';
40
13
 
41
- /**
42
- * Return result-sets as array, rather than a JSON object. This is a faster way to get results
43
- */
44
- rowsAsArray?: boolean;
45
-
46
- /**
47
- * Whether to retrieve dates as strings or as Date objects.
48
- */
49
- dateStrings?: boolean;
14
+ import type {
15
+ ConnectionConfig,
16
+ ImportFileConfig,
17
+ SqlError,
18
+ QueryOptions,
19
+ UpsertResult,
20
+ PoolConfig,
21
+ PoolClusterConfig,
22
+ SqlImportOptions,
23
+ ConnectionInfo,
24
+ UserConnectionConfig
25
+ } from './share';
50
26
 
51
- /**
52
- * Forces use of the indicated timezone, rather than the current Node.js timezone.
53
- * Possible values are Z for UTC, local or ±HH:MM format
54
- */
55
- timezone?: string;
56
-
57
- /**
58
- * Allows the use of named placeholders.
59
- */
60
- namedPlaceholders?: boolean;
61
-
62
- /**
63
- * permit to indicate server global variable max_allowed_packet value to ensure efficient batching.
64
- * default is 4Mb. see batch documentation
65
- */
66
- maxAllowedPacket?: number;
67
-
68
- /**
69
- * When an integer is not in the safe range, the Connector interprets the value as a Long object.
70
- */
71
- supportBigNumbers?: boolean;
72
-
73
- /**
74
- * Compatibility option to permit setting multiple value by a JSON object to replace one question mark.
75
- * key values will replace the question mark with format like key1=val,key2='val2'.
76
- * Since it doesn't respect the usual prepared statement format that one value is for one question mark,
77
- * this can lead to incomprehension, even if badly use to possible injection.
78
- */
79
- permitSetMultiParamEntries?: boolean;
80
-
81
- /**
82
- * When an integer is not in the safe range, the Connector interprets the value as a string
83
- */
84
- bigNumberStrings?: boolean;
85
-
86
- /**
87
- * disabled bulk command in batch.
88
- */
89
- bulk?: boolean;
90
-
91
- /**
92
- * Sends queries one by one without waiting on the results of the previous entry.
93
- * (Default: true)
94
- */
95
- pipelining?: boolean;
96
-
97
- /**
98
- * Force server version check by explicitly using SELECT VERSION(), not relying on server initial handshake
99
- * information
100
- */
101
- forceVersionCheck?: boolean;
102
-
103
- /**
104
- * Allows the use of LOAD DATA INFILE statements.
105
- * Loading data from a file from the client may be a security issue, as a man-in-the-middle proxy server can change
106
- * the actual file the server loads. Being able to execute a query on the client gives you access to files on
107
- * the client.
108
- * (Default: false)
109
- */
110
- permitLocalInfile?: boolean;
111
-
112
- /**
113
- * Database server port number
114
- */
115
- port?: number;
116
- }
117
-
118
- export interface QueryOptions extends QueryConfig {
119
- /**
120
- * SQL command to execute
121
- */
122
- sql: string;
123
- }
124
-
125
- export interface UserConnectionConfig {
126
- /**
127
- * Name of the database to use for this connection
128
- */
129
- database?: string;
130
-
131
- /**
132
- * When enabled, sends information during connection to server
133
- * - client name
134
- * - version
135
- * - operating system
136
- * - Node.js version
137
- *
138
- * If JSON is set, add JSON key/value to those values.
139
- *
140
- * When Performance Schema is enabled, server can display client information on each connection.
141
- */
142
- connectAttributes?: any;
143
-
144
- /**
145
- * Protocol character set used with the server.
146
- * Connection collation will be the default collation associated with charset.
147
- * It's mainly used for micro-optimizations. The default is often sufficient.
148
- * example 'UTF8MB4', 'CP1250'.
149
- * (default 'UTF8MB4')
150
- */
151
- charset?: string;
152
-
153
- /**
154
- * Permit to defined collation used for connection.
155
- * This will defined the charset encoding used for exchanges with database and defines the order used when
156
- * comparing strings. It's mainly used for micro-optimizations
157
- * (Default: 'UTF8MB4_UNICODE_CI')
158
- */
159
- collation?: string;
160
-
161
- /**
162
- * The MySQL user to authenticate as
163
- */
164
- user?: string;
165
-
166
- /**
167
- * The password of that MySQL user
168
- */
169
- password?: string;
170
- }
171
-
172
- export interface ConnectionConfig extends UserConnectionConfig, QueryConfig {
173
- /**
174
- * The hostname of the database you are connecting to. (Default: localhost)
175
- */
176
- host?: string;
177
-
178
- /**
179
- * The port number to connect to. (Default: 3306)
180
- */
181
- port?: number;
182
-
183
- /**
184
- * The path to a unix domain socket to connect to. When used host and port are ignored
185
- */
186
- socketPath?: string;
187
-
188
- /**
189
- * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
190
- */
191
- connectTimeout?: number;
192
-
193
- /**
194
- * Socket timeout in milliseconds after the connection is established
195
- */
196
- socketTimeout?: number;
197
-
198
- /**
199
- * This will print all incoming and outgoing packets on stdout.
200
- * (Default: false)
201
- */
202
- debug?: boolean;
203
-
204
- /**
205
- * This will print all incoming and outgoing compressed packets on stdout.
206
- * (Default: false)
207
- */
208
- debugCompress?: boolean;
209
-
210
- /**
211
- * When debugging, maximum packet length to write to console.
212
- * (Default: 256)
213
- */
214
- debugLen?: number;
215
-
216
- /**
217
- * Adds the stack trace at the time of query creation to the error stack trace, making it easier to identify the
218
- * part of the code that issued the query.
219
- * Note: This feature is disabled by default due to the performance cost of stack creation.
220
- * Only turn it on when you need to debug issues.
221
- * (Default: false)
222
- */
223
- trace?: boolean;
224
-
225
- /**
226
- * Allow multiple mysql statements per query. Be careful with this, it exposes you to SQL injection attacks.
227
- * (Default: false)
228
- */
229
- multipleStatements?: boolean;
230
-
231
- /**
232
- * object with ssl parameters or a boolean to enable ssl without setting any other ssl option.
233
- * see
234
- * https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/master/documentation/connection-options.md#ssl
235
- * for more information
236
- */
237
- ssl?: boolean | (tls.SecureContextOptions & { rejectUnauthorized?: boolean });
238
-
239
- /**
240
- * Compress exchanges with database using gzip.
241
- * This can give you better performance when accessing a database in a different location.
242
- * (Default: false)
243
- */
244
- compress?: boolean;
245
-
246
- /**
247
- * Debug option : permit to save last exchanged packet.
248
- * Error messages will display those last exchanged packet.
249
- *
250
- * (Default: false)
251
- */
252
- logPackets?: boolean;
253
-
254
- /**
255
- * Force server version check by explicitly using SELECT VERSION(), not relying on server initial packet.
256
- * (Default: false)
257
- */
258
- forceVersionCheck?: boolean;
259
-
260
- /**
261
- * indicate to throw an exception if result-set will not contain some data due to having duplicate identifier
262
- * (Default: true)
263
- */
264
- checkDuplicate?: boolean;
265
-
266
- /**
267
- * When enabled, the update number corresponds to update rows.
268
- * When disabled, it indicates the real rows changed.
269
- */
270
- foundRows?: boolean;
271
-
272
- /**
273
- * When a connection is established, permit to execute commands before using connection
274
- */
275
- initSql?: string | string[];
276
-
277
- /**
278
- * Permit to set session variables when connecting.
279
- * Example: sessionVariables:{'idle_transaction_timeout':10000}
280
- */
281
- sessionVariables?: any;
282
-
283
- /**
284
- * Indicate if array are included in parenthesis. This option permit compatibility with version < 2.5
285
- */
286
- arrayParenthesis?: boolean;
287
-
288
- /**
289
- * indicate if JSON fields for MariaDB server 10.5.2+ results in JSON format (or String if disabled)
290
- */
291
- autoJsonMap?: boolean;
292
-
293
- /**
294
- * permit to enable socket keep alive, setting delay. 0 means not enabled. Keep in mind that this don't reset server [@@wait_timeout](https://mariadb.com/kb/en/library/server-system-variables/#wait_timeout) (use pool option idleTimeout for that).
295
- * in ms
296
- * (Default: 0)
297
- */
298
- keepAliveDelay?: number;
27
+ export * from './share';
299
28
 
300
- /**
301
- * Indicate path/content to MySQL server RSA public key.
302
- * use requires Node.js v11.6+
303
- */
304
- rsaPublicKey?: string;
305
-
306
- /**
307
- * Indicate path/content to MySQL server caching RSA public key.
308
- * use requires Node.js v11.6+
309
- */
310
- cachingRsaPublicKey?: string;
311
-
312
- /**
313
- * Indicate that if `rsaPublicKey` or `cachingRsaPublicKey` public key are not provided, if client can ask server to send public key.
314
- * default: false
315
- */
316
- allowPublicKeyRetrieval?: boolean;
317
-
318
- /**
319
- * Whether resultset should return javascript ES2020 [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
320
- * for [BIGINT](https://mariadb.com/kb/en/bigint/) data type.
321
- * This ensures having expected value even for value > 2^53
322
- * (see [safe](documentation/connection-options.md#support-for-big-integer) range).
323
- *
324
- * default false
325
- */
326
- supportBigInt?: boolean;
327
- }
328
-
329
- export interface PoolConfig extends ConnectionConfig {
330
- /**
331
- * The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout,
332
- * because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds)
333
- */
334
- acquireTimeout?: number;
335
-
336
- /**
337
- * The maximum number of connections to create at once. (Default: 10)
338
- */
339
- connectionLimit?: number;
340
-
341
- /**
342
- * Indicate idle time after which a pool connection is released.
343
- * Value must be lower than [@@wait_timeout](https://mariadb.com/kb/en/library/server-system-variables/#wait_timeout).
344
- * In seconds (0 means never release)
345
- * Default: 1800 ( = 30 minutes)
346
- */
347
- idleTimeout?: number;
348
-
349
- /**
350
- * Timeout after which pool give up creating new connection.
351
- */
352
- initializationTimeout?: number;
353
-
354
- /**
355
- * When asking a connection to pool, the pool will validate the connection state.
356
- * "minDelayValidation" permits disabling this validation if the connection has been borrowed recently avoiding
357
- * useless verifications in case of frequent reuse of connections.
358
- * 0 means validation is done each time the connection is asked. (in ms)
359
- * Default: 500 (in millisecond)
360
- */
361
- minDelayValidation?: number;
362
-
363
- /**
364
- * Permit to set a minimum number of connection in pool.
365
- * **Recommendation is to use fixed pool, so not setting this value**
366
- */
367
- minimumIdle?: number;
368
-
369
- /**
370
- * Use COM_STMT_RESET when releasing a connection to pool.
371
- * Default: true
372
- */
373
- resetAfterUse?: boolean;
374
-
375
- /**
376
- * No rollback or reset when releasing a connection to pool.
377
- * Default: false
378
- */
379
- noControlAfterUse?: boolean;
380
-
381
- /**
382
- * Permit to indicate a timeout to log connection borrowed from pool.
383
- * When a connection is borrowed from pool and this timeout is reached,
384
- * a message will be logged to console indicating a possible connection leak.
385
- * Another message will tell if the possible logged leak has been released.
386
- * A value of 0 (default) meaning Leak detection is disable
387
- */
388
- leakDetectionTimeout?: number;
389
- }
390
-
391
- export interface PoolClusterConfig {
392
- /**
393
- * If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)
394
- */
395
- canRetry?: boolean;
396
-
397
- /**
398
- * If connection fails, node's errorCount increases. When errorCount is greater than removeNodeErrorCount,
399
- * remove a node in the PoolCluster. (Default: 5)
400
- */
401
- removeNodeErrorCount?: number;
402
-
403
- /**
404
- * If connection fails, specifies the number of milliseconds before another connection attempt will be made.
405
- * If set to 0, then node will be removed instead and never re-used. (Default: 0)
406
- */
407
- restoreNodeTimeout?: number;
408
-
409
- /**
410
- * The default selector. (Default: RR)
411
- * RR: Select one alternately. (Round-Robin)
412
- * RANDOM: Select the node by random function.
413
- * ORDER: Select the first node available unconditionally.
414
- */
415
- defaultSelector?: string;
416
- }
417
-
418
- export interface ServerVersion {
419
- /**
420
- * Raw string that database server send to connector.
421
- * example : "10.4.3-MariaDB-1:10.4.3+maria~bionic-log"
422
- */
423
- readonly raw: string;
424
-
425
- /**
426
- * indicate if server is a MariaDB or a MySQL server
427
- */
428
- readonly mariaDb: boolean;
429
-
430
- /**
431
- * Server major version.
432
- * Example for raw version "10.4.3-MariaDB" is 10
433
- */
434
- readonly major: number;
435
-
436
- /**
437
- * Server major version.
438
- * Example for raw version "10.4.3-MariaDB" is 4
439
- */
440
- readonly minor: number;
441
-
442
- /**
443
- * Server major version.
444
- * Example for raw version "10.4.3-MariaDB" is 3
445
- */
446
- readonly patch: number;
447
- }
448
-
449
- export interface ConnectionInfo {
450
- /**
451
- * Server connection identifier value
452
- */
453
- readonly threadId: number | null;
454
-
455
- /**
456
- * connection status flag
457
- * see https://mariadb.com/kb/en/library/ok_packet/#server-status-flag
458
- */
459
- readonly status: number;
460
-
461
- /**
462
- * Server version information
463
- */
464
- serverVersion: ServerVersion;
29
+ export const version: string;
30
+ export function createConnection(connectionUri: string | ConnectionConfig): Promise<Connection>;
31
+ export function importFile(config: ImportFileConfig): Promise<void>;
465
32
 
33
+ export interface Prepare {
34
+ id: number;
35
+ execute<T = any>(values?: any): Promise<T>;
466
36
  /**
467
- * Server capabilities
468
- * see https://mariadb.com/kb/en/library/connection/#capabilities
37
+ * Execute query returning a Readable Object that will emit columns/data/end/error events
38
+ * to permit streaming big result-set
469
39
  */
470
- readonly serverCapabilities: number;
40
+ executeStream(values?: any): Readable;
41
+ close(): void;
471
42
  }
472
43
 
473
- export interface Connection {
44
+ export interface Connection extends EventEmitter {
474
45
  /**
475
46
  * Connection information
476
47
  */
@@ -482,7 +53,7 @@ export interface Connection {
482
53
  readonly threadId: number | null;
483
54
 
484
55
  /**
485
- * Permit to change user during connection.
56
+ * Permit changing user during connection.
486
57
  * All user variables will be reset, Prepare commands will be released.
487
58
  * !!! mysql has a bug when CONNECT_ATTRS capability is set, that is default !!!!
488
59
  */
@@ -506,35 +77,50 @@ export interface Connection {
506
77
  /**
507
78
  * Execute query using text protocol.
508
79
  */
509
- query(sql: string | QueryOptions, values?: any): Promise<any>;
80
+ query<T = any>(sql: string | QueryOptions, values?: any): Promise<T>;
81
+
82
+ /**
83
+ * Prepare query.
84
+ */
85
+ prepare(sql: string | QueryOptions): Promise<Prepare>;
510
86
 
511
87
  /**
512
- * Execute batch using text protocol.
88
+ * Execute query using binary (prepare) protocol
513
89
  */
514
- batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
90
+ execute<T = any>(sql: string | QueryOptions, values?: any): Promise<T>;
91
+
92
+ /**
93
+ * Execute batch. Values are Array of Array.
94
+ */
95
+ batch<T = UpsertResult | UpsertResult[]>(sql: string | QueryOptions, values?: any): Promise<T>;
515
96
 
516
97
  /**
517
98
  * Execute query returning a Readable Object that will emit columns/data/end/error events
518
99
  * to permit streaming big result-set
519
100
  */
520
- queryStream(sql: string | QueryOptions, values?: any): stream.Readable;
101
+ queryStream(sql: string | QueryOptions, values?: any): Readable;
521
102
 
522
103
  /**
523
- * Send an empty MySQL packet to ensure connection is active, and reset @@wait_timeout
104
+ * Send an empty MySQL packet to ensure the connection is active, and reset @@wait_timeout
524
105
  */
525
106
  ping(): Promise<void>;
526
107
 
527
108
  /**
528
109
  * Send a reset command that will
529
- * - rollback any open transaction
110
+ * - roll back any open transaction
530
111
  * - reset transaction isolation level
531
112
  * - reset session variables
532
113
  * - delete user variables
533
114
  * - remove temporary tables
534
- * - remove all PREPARE statement
115
+ * - remove all PREPARE statements
535
116
  */
536
117
  reset(): Promise<void>;
537
118
 
119
+ /**
120
+ * import sql file
121
+ */
122
+ importFile(config: SqlImportOptions): Promise<void>;
123
+
538
124
  /**
539
125
  * Indicates the state of the connection as the driver knows it
540
126
  */
@@ -546,7 +132,12 @@ export interface Connection {
546
132
  end(): Promise<void>;
547
133
 
548
134
  /**
549
- * Force connection termination by closing the underlying socket and killing server process if any.
135
+ * @deprecated alias for end().
136
+ */
137
+ close(): Promise<void>;
138
+
139
+ /**
140
+ * Force connection termination by closing the underlying socket and killing a server process if any.
550
141
  */
551
142
  destroy(): void;
552
143
 
@@ -569,15 +160,17 @@ export interface Connection {
569
160
  debugCompress(value: boolean): void;
570
161
 
571
162
  /**
572
- * This function permit to escape a parameter properly according to parameter type to avoid injection.
163
+ * This function permits escaping a parameter properly, according to a parameter type, to avoid injection.
573
164
  * @param value parameter
574
165
  */
575
166
  escape(value: any): string;
576
167
 
577
168
  /**
578
- * This function permit to escape a Identifier properly . See Identifier Names for escaping. Value will be enclosed by '`' character if content doesn't satisfy:
169
+ * This function permits escaping an Identifier properly. See Identifier Names for escaping. Value will be enclosed
170
+ * by '`' character if content doesn't satisfy:
579
171
  * <OL>
580
- * <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign, underscore)</LI>
172
+ * <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign,
173
+ * underscore)</LI>
581
174
  * <LI>Extended: U+0080 .. U+FFFF and escaping '`' character if needed.</LI>
582
175
  * </OL>
583
176
  * @param identifier identifier
@@ -586,6 +179,9 @@ export interface Connection {
586
179
 
587
180
  on(ev: 'end', callback: () => void): Connection;
588
181
  on(ev: 'error', callback: (err: SqlError) => void): Connection;
182
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
183
+ listeners(ev: 'end'): (() => void)[];
184
+ listeners(ev: 'error'): ((err: SqlError) => void)[];
589
185
  }
590
186
 
591
187
  export interface PoolConnection extends Connection {
@@ -596,9 +192,10 @@ export interface PoolConnection extends Connection {
596
192
  }
597
193
 
598
194
  export interface Pool {
195
+ closed: boolean;
599
196
  /**
600
- * Retrieve a connection from pool.
601
- * Create a new one, if limit is not reached.
197
+ * Retrieve a connection from the pool.
198
+ * Create a new one if the limit is not reached.
602
199
  * wait until acquireTimeout.
603
200
  */
604
201
  getConnection(): Promise<PoolConnection>;
@@ -606,30 +203,40 @@ export interface Pool {
606
203
  /**
607
204
  * Execute a query on one connection from pool.
608
205
  */
609
- query(sql: string | QueryOptions, values?: any): Promise<any>;
206
+ query<T = any>(sql: string | QueryOptions, values?: any): Promise<T>;
610
207
 
611
208
  /**
612
209
  * Execute a batch on one connection from pool.
613
210
  */
614
- batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
211
+ batch<T = UpsertResult | UpsertResult[]>(sql: string | QueryOptions, values?: any): Promise<T>;
212
+
213
+ /**
214
+ * Execute query using binary (prepare) protocol
215
+ */
216
+ execute<T = any>(sql: string | QueryOptions, values?: any): Promise<T>;
615
217
 
616
218
  /**
617
219
  * Close all connection in pool
618
220
  */
619
221
  end(): Promise<void>;
620
222
 
223
+ /**
224
+ * import sql file
225
+ */
226
+ importFile(config: SqlImportOptions): Promise<void>;
227
+
621
228
  /**
622
229
  * Get current active connections.
623
230
  */
624
231
  activeConnections(): number;
625
232
 
626
233
  /**
627
- * Get current total connection number.
234
+ * Get the current total connection number.
628
235
  */
629
236
  totalConnections(): number;
630
237
 
631
238
  /**
632
- * Get current idle connection number.
239
+ * Get the current idle connection number.
633
240
  */
634
241
  idleConnections(): number;
635
242
 
@@ -639,15 +246,17 @@ export interface Pool {
639
246
  taskQueueSize(): number;
640
247
 
641
248
  /**
642
- * This function permit to escape a parameter properly according to parameter type to avoid injection.
249
+ * This function permits escaping a parameter properly, according to a parameter type, to avoid injection.
643
250
  * @param value parameter
644
251
  */
645
252
  escape(value: any): string;
646
253
 
647
254
  /**
648
- * This function permit to escape a Identifier properly . See Identifier Names for escaping. Value will be enclosed by '`' character if content doesn't satisfy:
255
+ * This function permits escaping an Identifier properly. See Identifier Names for escaping. Value will be enclosed
256
+ * by '`' character if content doesn't satisfy:
649
257
  * <OL>
650
- * <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign, underscore)</LI>
258
+ * <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign,
259
+ * underscore)</LI>
651
260
  * <LI>Extended: U+0080 .. U+FFFF and escaping '`' character if needed.</LI>
652
261
  * </OL>
653
262
  * @param identifier identifier
@@ -662,8 +271,9 @@ export interface Pool {
662
271
 
663
272
  export interface FilteredPoolCluster {
664
273
  getConnection(): Promise<PoolConnection>;
665
- query(sql: string | QueryOptions, values?: any): Promise<any>;
666
- batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
274
+ query<T = any>(sql: string | QueryOptions, values?: any): Promise<T>;
275
+ batch<T = UpsertResult | UpsertResult[]>(sql: string | QueryOptions, values?: any): Promise<T>;
276
+ execute<T = any>(sql: string | QueryOptions, values?: any): Promise<T>;
667
277
  }
668
278
 
669
279
  export interface PoolCluster {
@@ -676,195 +286,5 @@ export interface PoolCluster {
676
286
 
677
287
  on(ev: 'remove', callback: (nodekey: string) => void): PoolCluster;
678
288
  }
679
-
680
- export interface UpsertResult {
681
- affectedRows: number;
682
- insertId: number;
683
- warningStatus: number;
684
- }
685
-
686
- export interface SqlError extends Error {
687
- /**
688
- * Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'),
689
- * a node.js error (e.g. 'ECONNREFUSED') or an internal error
690
- * (e.g. 'PROTOCOL_CONNECTION_LOST').
691
- */
692
- code: string | null;
693
-
694
- /**
695
- * original error message value
696
- */
697
- text: string | null;
698
-
699
- /**
700
- * The sql command associate
701
- */
702
- sql: string | null;
703
-
704
- /**
705
- * The error number for the error code
706
- */
707
- errno: number;
708
-
709
- /**
710
- * The sql state
711
- */
712
- sqlState?: string | null;
713
-
714
- /**
715
- * Boolean, indicating if this error is terminal to the connection object.
716
- */
717
- fatal: boolean;
718
- }
719
-
720
- interface SqlErrorConstructor extends ErrorConstructor {
721
- new (
722
- msg: string,
723
- fatal?: boolean,
724
- info?: { threadId?: number },
725
- sqlState?: string | null,
726
- errno?: number,
727
- additionalStack?: string,
728
- addHeader?: boolean
729
- ): SqlError;
730
- readonly prototype: SqlError;
731
- }
732
-
733
- declare const SqlError: SqlErrorConstructor;
734
-
735
- export const enum TypeNumbers {
736
- DECIMAL = 0,
737
- TINY = 1,
738
- SHORT = 2,
739
- LONG = 3,
740
- FLOAT = 4,
741
- DOUBLE = 5,
742
- NULL = 6,
743
- TIMESTAMP = 7,
744
- LONGLONG = 8,
745
- INT24 = 9,
746
- DATE = 10,
747
- TIME = 11,
748
- DATETIME = 12,
749
- YEAR = 13,
750
- NEWDATE = 14,
751
- VARCHAR = 15,
752
- BIT = 16,
753
- TIMESTAMP2 = 17,
754
- DATETIME2 = 18,
755
- TIME2 = 19,
756
- JSON = 245, //only for MySQ,
757
- NEWDECIMAL = 246,
758
- ENUM = 247,
759
- SET = 248,
760
- TINY_BLOB = 249,
761
- MEDIUM_BLOB = 250,
762
- LONG_BLOB = 251,
763
- BLOB = 252,
764
- VAR_STRING = 253,
765
- STRING = 254,
766
- GEOMETRY = 255
767
- }
768
-
769
- export const enum Flags {
770
- // field cannot be null
771
- NOT_NULL = 1,
772
- // field is a primary key
773
- PRIMARY_KEY = 2,
774
- //field is unique
775
- UNIQUE_KEY = 4,
776
- //field is in a multiple key
777
- MULTIPLE_KEY = 8,
778
- //is this field a Blob
779
- BLOB = 1 << 4,
780
- // is this field unsigned
781
- UNSIGNED = 1 << 5,
782
- //is this field a zerofill
783
- ZEROFILL_FLAG = 1 << 6,
784
- //whether this field has a binary collation
785
- BINARY_COLLATION = 1 << 7,
786
- //Field is an enumeration
787
- ENUM = 1 << 8,
788
- //field auto-increment
789
- AUTO_INCREMENT = 1 << 9,
790
- //field is a timestamp value
791
- TIMESTAMP = 1 << 10,
792
- //field is a SET
793
- SET = 1 << 11,
794
- //field doesn't have default value
795
- NO_DEFAULT_VALUE_FLAG = 1 << 12,
796
- //field is set to NOW on UPDATE
797
- ON_UPDATE_NOW_FLAG = 1 << 13,
798
- //field is num
799
- NUM_FLAG = 1 << 14
800
- }
801
-
802
- export const enum Types {
803
- DECIMAL = 'DECIMAL',
804
- TINY = 'TINY',
805
- SHORT = 'SHORT',
806
- LONG = 'LONG',
807
- FLOAT = 'FLOAT',
808
- DOUBLE = 'DOUBLE',
809
- NULL = 'NULL',
810
- TIMESTAMP = 'TIMESTAMP',
811
- LONGLONG = 'LONGLONG',
812
- INT24 = 'INT24',
813
- DATE = 'DATE',
814
- TIME = 'TIME',
815
- DATETIME = 'DATETIME',
816
- YEAR = 'YEAR',
817
- NEWDATE = 'NEWDATE',
818
- VARCHAR = 'VARCHAR',
819
- BIT = 'BIT',
820
- TIMESTAMP2 = 'TIMESTAMP2',
821
- DATETIME2 = 'DATETIME2',
822
- TIME2 = 'TIME2',
823
- JSON = 'JSON',
824
- NEWDECIMAL = 'NEWDECIMAL',
825
- ENUM = 'ENUM',
826
- SET = 'SET',
827
- TINY_BLOB = 'TINY_BLOB',
828
- MEDIUM_BLOB = 'MEDIUM_BLOB',
829
- LONG_BLOB = 'LONG_BLOB',
830
- BLOB = 'BLOB',
831
- VAR_STRING = 'VAR_STRING',
832
- STRING = 'STRING',
833
- GEOMETRY = 'GEOMETRY'
834
- }
835
-
836
- export interface Collation {
837
- index: number;
838
- name: string;
839
- encoding: string;
840
- fromEncoding(encoding: string): Collation;
841
- fromIndex(index: number): Collation;
842
- fromName(name: string): Collation;
843
- }
844
-
845
- export interface FieldInfo {
846
- collation: Collation;
847
- columnLength: number;
848
- columnType: TypeNumbers;
849
- scale: number;
850
- type: Types;
851
- flags: Flags;
852
- db(): string;
853
- schema(): string; // Alias for db()
854
- table(): string;
855
- orgTable(): string;
856
- name(): string;
857
- orgName(): string;
858
-
859
- // Note that you may only call *one* of these functions
860
- // when decoding a column via the typeCast callback.
861
- // Calling additional functions will give you incorrect results.
862
- string(): string | null;
863
- buffer(): Buffer | null;
864
- float(): number | null;
865
- int(): number | null;
866
- long(): number | null;
867
- decimal(): number | null;
868
- date(): Date | null;
869
- geometry(): geojson.Geometry | null;
870
- }
289
+ export function createPool(config: PoolConfig | string): Pool;
290
+ export function createPoolCluster(config?: PoolClusterConfig): PoolCluster;