@tachybase/module-multi-app 0.23.8

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 (117) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/README.md +34 -0
  3. package/README.zh-CN.md +34 -0
  4. package/client.d.ts +1 -0
  5. package/client.js +1 -0
  6. package/dist/client/AppManager.d.ts +2 -0
  7. package/dist/client/AppNameInput.d.ts +2 -0
  8. package/dist/client/MultiAppBlockInitializer.d.ts +2 -0
  9. package/dist/client/MultiAppManagerProvider.d.ts +2 -0
  10. package/dist/client/MultiAppManagerProvider.style.d.ts +5 -0
  11. package/dist/client/Settings.d.ts +2 -0
  12. package/dist/client/index.d.ts +6 -0
  13. package/dist/client/index.js +1 -0
  14. package/dist/client/settings/schemas/applications.d.ts +13 -0
  15. package/dist/client/utils.d.ts +4 -0
  16. package/dist/constants.d.ts +1 -0
  17. package/dist/constants.js +27 -0
  18. package/dist/externalVersion.js +16 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +39 -0
  21. package/dist/locale/en-US.json +27 -0
  22. package/dist/locale/es-ES.json +9 -0
  23. package/dist/locale/ko_KR.json +11 -0
  24. package/dist/locale/pt-BR.json +9 -0
  25. package/dist/locale/zh-CN.json +27 -0
  26. package/dist/node_modules/mariadb/LICENSE +502 -0
  27. package/dist/node_modules/mariadb/callback.js +41 -0
  28. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +278 -0
  29. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +372 -0
  30. package/dist/node_modules/mariadb/lib/cmd/change-user.js +149 -0
  31. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +17 -0
  32. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +102 -0
  33. package/dist/node_modules/mariadb/lib/cmd/command.js +168 -0
  34. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +327 -0
  35. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +427 -0
  36. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +168 -0
  37. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +23 -0
  38. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +761 -0
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +55 -0
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +58 -0
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +19 -0
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +142 -0
  43. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +74 -0
  44. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +126 -0
  45. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +292 -0
  46. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +74 -0
  47. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +29 -0
  48. package/dist/node_modules/mariadb/lib/cmd/ping.js +52 -0
  49. package/dist/node_modules/mariadb/lib/cmd/query.js +255 -0
  50. package/dist/node_modules/mariadb/lib/cmd/quit.js +28 -0
  51. package/dist/node_modules/mariadb/lib/cmd/reset.js +54 -0
  52. package/dist/node_modules/mariadb/lib/cmd/resultset.js +607 -0
  53. package/dist/node_modules/mariadb/lib/cmd/stream.js +45 -0
  54. package/dist/node_modules/mariadb/lib/config/connection-options.js +258 -0
  55. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +19 -0
  56. package/dist/node_modules/mariadb/lib/config/pool-options.js +47 -0
  57. package/dist/node_modules/mariadb/lib/connection-callback.js +160 -0
  58. package/dist/node_modules/mariadb/lib/connection.js +1460 -0
  59. package/dist/node_modules/mariadb/lib/const/capabilities.js +64 -0
  60. package/dist/node_modules/mariadb/lib/const/collations.js +473 -0
  61. package/dist/node_modules/mariadb/lib/const/connection_status.js +13 -0
  62. package/dist/node_modules/mariadb/lib/const/error-code.js +1282 -0
  63. package/dist/node_modules/mariadb/lib/const/field-detail.js +35 -0
  64. package/dist/node_modules/mariadb/lib/const/field-type.js +71 -0
  65. package/dist/node_modules/mariadb/lib/const/server-status.js +30 -0
  66. package/dist/node_modules/mariadb/lib/const/state-change.js +12 -0
  67. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +81 -0
  68. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +590 -0
  69. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +141 -0
  70. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +171 -0
  71. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +193 -0
  72. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +36 -0
  73. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +37 -0
  74. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +502 -0
  75. package/dist/node_modules/mariadb/lib/io/packet.js +515 -0
  76. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +481 -0
  77. package/dist/node_modules/mariadb/lib/misc/connection-information.js +96 -0
  78. package/dist/node_modules/mariadb/lib/misc/errors.js +123 -0
  79. package/dist/node_modules/mariadb/lib/misc/parse.js +1033 -0
  80. package/dist/node_modules/mariadb/lib/misc/utils.js +298 -0
  81. package/dist/node_modules/mariadb/lib/pool-base.js +611 -0
  82. package/dist/node_modules/mariadb/lib/pool-callback.js +202 -0
  83. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +66 -0
  84. package/dist/node_modules/mariadb/lib/pool-cluster.js +407 -0
  85. package/dist/node_modules/mariadb/lib/pool-promise.js +108 -0
  86. package/dist/node_modules/mariadb/package.json +1 -0
  87. package/dist/node_modules/mariadb/promise.js +34 -0
  88. package/dist/node_modules/mariadb/types/index.d.ts +870 -0
  89. package/dist/server/actions/apps.d.ts +5 -0
  90. package/dist/server/actions/apps.js +117 -0
  91. package/dist/server/app-lifecycle.d.ts +8 -0
  92. package/dist/server/app-lifecycle.js +99 -0
  93. package/dist/server/app-start-env.d.ts +2 -0
  94. package/dist/server/app-start-env.js +105 -0
  95. package/dist/server/collections/applications.d.ts +2 -0
  96. package/dist/server/collections/applications.js +82 -0
  97. package/dist/server/index.d.ts +4 -0
  98. package/dist/server/index.js +29 -0
  99. package/dist/server/middlewares/app-selector.d.ts +1 -0
  100. package/dist/server/middlewares/app-selector.js +47 -0
  101. package/dist/server/middlewares/index.d.ts +2 -0
  102. package/dist/server/middlewares/index.js +23 -0
  103. package/dist/server/middlewares/inject-app-list.d.ts +1 -0
  104. package/dist/server/middlewares/inject-app-list.js +48 -0
  105. package/dist/server/migrations/20240820153000-add-apps-tmpl.d.ts +6 -0
  106. package/dist/server/migrations/20240820153000-add-apps-tmpl.js +47 -0
  107. package/dist/server/migrations/20241126124904-add-createdBy.d.ts +6 -0
  108. package/dist/server/migrations/20241126124904-add-createdBy.js +41 -0
  109. package/dist/server/models/application.d.ts +10 -0
  110. package/dist/server/models/application.js +57 -0
  111. package/dist/server/server.d.ts +19 -0
  112. package/dist/server/server.js +246 -0
  113. package/dist/swagger/index.d.ts +197 -0
  114. package/dist/swagger/index.js +227 -0
  115. package/package.json +38 -0
  116. package/server.d.ts +2 -0
  117. package/server.js +1 -0
@@ -0,0 +1,870 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ // Type definitions for mariadb 2.5
3
+ // Project: https://github.com/mariadb-corporation/mariadb-connector-nodejs
4
+ // Definitions by: Diego Dupin <https://github.com/rusher>
5
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
+ // TypeScript Version: 2.1
7
+
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;
40
+
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;
50
+
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;
299
+
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;
465
+
466
+ /**
467
+ * Server capabilities
468
+ * see https://mariadb.com/kb/en/library/connection/#capabilities
469
+ */
470
+ readonly serverCapabilities: number;
471
+ }
472
+
473
+ export interface Connection {
474
+ /**
475
+ * Connection information
476
+ */
477
+ info: ConnectionInfo | null;
478
+
479
+ /**
480
+ * Alias of info.threadId for compatibility
481
+ */
482
+ readonly threadId: number | null;
483
+
484
+ /**
485
+ * Permit to change user during connection.
486
+ * All user variables will be reset, Prepare commands will be released.
487
+ * !!! mysql has a bug when CONNECT_ATTRS capability is set, that is default !!!!
488
+ */
489
+ changeUser(options?: UserConnectionConfig): Promise<void>;
490
+
491
+ /**
492
+ * Start transaction
493
+ */
494
+ beginTransaction(): Promise<void>;
495
+
496
+ /**
497
+ * Commit a transaction.
498
+ */
499
+ commit(): Promise<void>;
500
+
501
+ /**
502
+ * Roll back a transaction.
503
+ */
504
+ rollback(): Promise<void>;
505
+
506
+ /**
507
+ * Execute query using text protocol.
508
+ */
509
+ query(sql: string | QueryOptions, values?: any): Promise<any>;
510
+
511
+ /**
512
+ * Execute batch using text protocol.
513
+ */
514
+ batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
515
+
516
+ /**
517
+ * Execute query returning a Readable Object that will emit columns/data/end/error events
518
+ * to permit streaming big result-set
519
+ */
520
+ queryStream(sql: string | QueryOptions, values?: any): stream.Readable;
521
+
522
+ /**
523
+ * Send an empty MySQL packet to ensure connection is active, and reset @@wait_timeout
524
+ */
525
+ ping(): Promise<void>;
526
+
527
+ /**
528
+ * Send a reset command that will
529
+ * - rollback any open transaction
530
+ * - reset transaction isolation level
531
+ * - reset session variables
532
+ * - delete user variables
533
+ * - remove temporary tables
534
+ * - remove all PREPARE statement
535
+ */
536
+ reset(): Promise<void>;
537
+
538
+ /**
539
+ * Indicates the state of the connection as the driver knows it
540
+ */
541
+ isValid(): boolean;
542
+
543
+ /**
544
+ * Terminate connection gracefully.
545
+ */
546
+ end(): Promise<void>;
547
+
548
+ /**
549
+ * Force connection termination by closing the underlying socket and killing server process if any.
550
+ */
551
+ destroy(): void;
552
+
553
+ pause(): void;
554
+ resume(): void;
555
+
556
+ /**
557
+ * Alias for info.serverVersion.raw
558
+ */
559
+ serverVersion(): string;
560
+
561
+ /**
562
+ * Change option "debug" during connection.
563
+ */
564
+ debug(value: boolean): void;
565
+
566
+ /**
567
+ * Change option "debugCompress" during connection.
568
+ */
569
+ debugCompress(value: boolean): void;
570
+
571
+ /**
572
+ * This function permit to escape a parameter properly according to parameter type to avoid injection.
573
+ * @param value parameter
574
+ */
575
+ escape(value: any): string;
576
+
577
+ /**
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:
579
+ * <OL>
580
+ * <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign, underscore)</LI>
581
+ * <LI>Extended: U+0080 .. U+FFFF and escaping '`' character if needed.</LI>
582
+ * </OL>
583
+ * @param identifier identifier
584
+ */
585
+ escapeId(identifier: string): string;
586
+
587
+ on(ev: 'end', callback: () => void): Connection;
588
+ on(ev: 'error', callback: (err: SqlError) => void): Connection;
589
+ }
590
+
591
+ export interface PoolConnection extends Connection {
592
+ /**
593
+ * Release the connection to pool internal cache.
594
+ */
595
+ release(): Promise<void>;
596
+ }
597
+
598
+ export interface Pool {
599
+ /**
600
+ * Retrieve a connection from pool.
601
+ * Create a new one, if limit is not reached.
602
+ * wait until acquireTimeout.
603
+ */
604
+ getConnection(): Promise<PoolConnection>;
605
+
606
+ /**
607
+ * Execute a query on one connection from pool.
608
+ */
609
+ query(sql: string | QueryOptions, values?: any): Promise<any>;
610
+
611
+ /**
612
+ * Execute a batch on one connection from pool.
613
+ */
614
+ batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
615
+
616
+ /**
617
+ * Close all connection in pool
618
+ */
619
+ end(): Promise<void>;
620
+
621
+ /**
622
+ * Get current active connections.
623
+ */
624
+ activeConnections(): number;
625
+
626
+ /**
627
+ * Get current total connection number.
628
+ */
629
+ totalConnections(): number;
630
+
631
+ /**
632
+ * Get current idle connection number.
633
+ */
634
+ idleConnections(): number;
635
+
636
+ /**
637
+ * Get current stacked connection request.
638
+ */
639
+ taskQueueSize(): number;
640
+
641
+ /**
642
+ * This function permit to escape a parameter properly according to parameter type to avoid injection.
643
+ * @param value parameter
644
+ */
645
+ escape(value: any): string;
646
+
647
+ /**
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:
649
+ * <OL>
650
+ * <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign, underscore)</LI>
651
+ * <LI>Extended: U+0080 .. U+FFFF and escaping '`' character if needed.</LI>
652
+ * </OL>
653
+ * @param identifier identifier
654
+ */
655
+ escapeId(identifier: string): string;
656
+
657
+ on(ev: 'acquire', callback: (conn: Connection) => void): Pool;
658
+ on(ev: 'connection', callback: (conn: Connection) => void): Pool;
659
+ on(ev: 'enqueue', callback: () => void): Pool;
660
+ on(ev: 'release', callback: (conn: Connection) => void): Pool;
661
+ }
662
+
663
+ export interface FilteredPoolCluster {
664
+ getConnection(): Promise<PoolConnection>;
665
+ query(sql: string | QueryOptions, values?: any): Promise<any>;
666
+ batch(sql: string | QueryOptions, values?: any): Promise<UpsertResult[]>;
667
+ }
668
+
669
+ export interface PoolCluster {
670
+ add(id: string, config: PoolConfig): void;
671
+ end(): Promise<void>;
672
+ of(pattern: string, selector?: string): FilteredPoolCluster;
673
+ of(pattern: undefined | null | false, selector: string): FilteredPoolCluster;
674
+ remove(pattern: string): void;
675
+ getConnection(pattern?: string, selector?: string): Promise<PoolConnection>;
676
+
677
+ on(ev: 'remove', callback: (nodekey: string) => void): PoolCluster;
678
+ }
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
+ }