@tachybase/module-multi-app 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/externalVersion.js +5 -5
  2. package/dist/node_modules/mariadb/callback.js +43 -8
  3. package/dist/node_modules/mariadb/check-node.js +30 -0
  4. package/dist/node_modules/mariadb/lib/cluster-callback.js +84 -0
  5. package/dist/node_modules/mariadb/lib/cluster.js +446 -0
  6. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +576 -177
  7. package/dist/node_modules/mariadb/lib/cmd/change-user.js +54 -44
  8. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +3 -2
  9. package/dist/node_modules/mariadb/lib/cmd/class/prepare-cache-wrapper.js +46 -0
  10. package/dist/node_modules/mariadb/lib/cmd/class/prepare-result-packet.js +141 -0
  11. package/dist/node_modules/mariadb/lib/cmd/class/prepare-wrapper.js +70 -0
  12. package/dist/node_modules/mariadb/lib/cmd/close-prepare.js +38 -0
  13. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +145 -47
  14. package/dist/node_modules/mariadb/lib/cmd/command.js +41 -75
  15. package/dist/node_modules/mariadb/lib/cmd/decoder/binary-decoder.js +282 -0
  16. package/dist/node_modules/mariadb/lib/cmd/decoder/text-decoder.js +210 -0
  17. package/dist/node_modules/mariadb/lib/cmd/{common-binary-cmd.js → encoder/binary-encoder.js} +34 -77
  18. package/dist/node_modules/mariadb/lib/cmd/encoder/text-encoder.js +311 -0
  19. package/dist/node_modules/mariadb/lib/cmd/execute-stream.js +61 -0
  20. package/dist/node_modules/mariadb/lib/cmd/execute.js +338 -0
  21. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +25 -62
  22. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +39 -6
  23. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +48 -16
  24. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/handshake.js +198 -0
  25. package/dist/node_modules/mariadb/lib/cmd/handshake/{initial-handshake.js → auth/initial-handshake.js} +10 -8
  26. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +22 -9
  27. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +9 -4
  28. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/parsec-auth.js +115 -0
  29. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +12 -5
  30. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +44 -33
  31. package/dist/node_modules/mariadb/lib/cmd/handshake/authentication.js +335 -0
  32. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +20 -19
  33. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +6 -3
  34. package/dist/node_modules/mariadb/lib/cmd/parser.js +861 -0
  35. package/dist/node_modules/mariadb/lib/cmd/ping.js +17 -18
  36. package/dist/node_modules/mariadb/lib/cmd/prepare.js +170 -0
  37. package/dist/node_modules/mariadb/lib/cmd/query.js +281 -144
  38. package/dist/node_modules/mariadb/lib/cmd/quit.js +9 -6
  39. package/dist/node_modules/mariadb/lib/cmd/reset.js +15 -19
  40. package/dist/node_modules/mariadb/lib/cmd/stream.js +21 -6
  41. package/dist/node_modules/mariadb/lib/config/cluster-options.js +23 -0
  42. package/dist/node_modules/mariadb/lib/config/connection-options.js +196 -132
  43. package/dist/node_modules/mariadb/lib/config/pool-options.js +27 -19
  44. package/dist/node_modules/mariadb/lib/connection-callback.js +492 -120
  45. package/dist/node_modules/mariadb/lib/connection-promise.js +372 -0
  46. package/dist/node_modules/mariadb/lib/connection.js +1739 -1016
  47. package/dist/node_modules/mariadb/lib/const/capabilities.js +36 -30
  48. package/dist/node_modules/mariadb/lib/const/collations.js +972 -36
  49. package/dist/node_modules/mariadb/lib/const/connection_status.js +3 -0
  50. package/dist/node_modules/mariadb/lib/const/error-code.js +35 -11
  51. package/dist/node_modules/mariadb/lib/const/field-detail.js +3 -0
  52. package/dist/node_modules/mariadb/lib/const/field-type.js +7 -4
  53. package/dist/node_modules/mariadb/lib/const/server-status.js +4 -1
  54. package/dist/node_modules/mariadb/lib/const/state-change.js +3 -0
  55. package/dist/node_modules/mariadb/lib/filtered-cluster-callback.js +136 -0
  56. package/dist/node_modules/mariadb/lib/filtered-cluster.js +118 -0
  57. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +14 -13
  58. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +21 -18
  59. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +75 -64
  60. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +13 -9
  61. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +12 -10
  62. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +402 -134
  63. package/dist/node_modules/mariadb/lib/io/packet.js +287 -202
  64. package/dist/node_modules/mariadb/lib/lru-prepare-cache.js +84 -0
  65. package/dist/node_modules/mariadb/lib/misc/connection-information.js +15 -32
  66. package/dist/node_modules/mariadb/lib/misc/errors.js +68 -25
  67. package/dist/node_modules/mariadb/lib/misc/parse.js +207 -711
  68. package/dist/node_modules/mariadb/lib/misc/utils.js +34 -62
  69. package/dist/node_modules/mariadb/lib/pool-callback.js +213 -174
  70. package/dist/node_modules/mariadb/lib/pool-promise.js +228 -94
  71. package/dist/node_modules/mariadb/lib/pool.js +951 -0
  72. package/dist/node_modules/mariadb/package.json +1 -1
  73. package/dist/node_modules/mariadb/promise.js +1 -34
  74. package/dist/node_modules/mariadb/types/callback.d.ts +207 -0
  75. package/dist/node_modules/mariadb/types/index.d.ts +94 -674
  76. package/dist/node_modules/mariadb/types/share.d.ts +804 -0
  77. package/dist/node_modules/qs/package.json +1 -1
  78. package/dist/server/actions/apps.js +2 -2
  79. package/dist/server/app-lifecycle.d.ts +1 -1
  80. package/dist/server/app-lifecycle.js +4 -4
  81. package/dist/server/models/application.d.ts +1 -1
  82. package/package.json +7 -7
  83. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  84. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  85. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  86. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  87. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  88. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  89. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  90. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  91. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  92. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  93. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  94. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
@@ -1,3 +1,6 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  'use strict';
2
5
 
3
6
  const Status = {
@@ -1,8 +1,11 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  'use strict';
2
5
 
3
6
  /**
4
7
  * File generated using test/tools/generate-mariadb.js
5
- * from MariaDB 10.5
8
+ * from MariaDB 10.9
6
9
  *
7
10
  * !!!!!! DO NOT CHANGE MANUALLY !!!!!!
8
11
  */
@@ -69,7 +72,6 @@ codes[179] = 'HA_ERR_INDEX_COL_TOO_LONG';
69
72
  codes[180] = 'HA_ERR_INDEX_CORRUPT';
70
73
  codes[181] = 'HA_ERR_UNDO_REC_TOO_BIG';
71
74
  codes[182] = 'HA_FTS_INVALID_DOCID';
72
- codes[183] = 'HA_ERR_TABLE_IN_FK_CHECK';
73
75
  codes[184] = 'HA_ERR_TABLESPACE_EXISTS';
74
76
  codes[185] = 'HA_ERR_TOO_MANY_FIELDS';
75
77
  codes[186] = 'HA_ERR_ROW_IN_WRONG_PARTITION';
@@ -83,6 +85,8 @@ codes[193] = 'HA_ERR_FK_DEPTH_EXCEEDED';
83
85
  codes[194] = 'HA_ERR_TABLESPACE_MISSING';
84
86
  codes[195] = 'HA_ERR_SEQUENCE_INVALID_DATA';
85
87
  codes[196] = 'HA_ERR_SEQUENCE_RUN_OUT';
88
+ codes[197] = 'HA_ERR_COMMIT_ERROR';
89
+ codes[198] = 'HA_ERR_PARTITION_LIST';
86
90
  codes[1000] = 'ER_HASHCHK';
87
91
  codes[1001] = 'ER_NISAMCHK';
88
92
  codes[1002] = 'ER_NO';
@@ -155,7 +159,7 @@ codes[1068] = 'ER_MULTIPLE_PRI_KEY';
155
159
  codes[1069] = 'ER_TOO_MANY_KEYS';
156
160
  codes[1070] = 'ER_TOO_MANY_KEY_PARTS';
157
161
  codes[1071] = 'ER_TOO_LONG_KEY';
158
- codes[1072] = 'ER_KEY_COLUMN_DOES_NOT_EXITS';
162
+ codes[1072] = 'ER_KEY_COLUMN_DOES_NOT_EXIST';
159
163
  codes[1073] = 'ER_BLOB_USED_AS_KEY';
160
164
  codes[1074] = 'ER_TOO_BIG_FIELDLENGTH';
161
165
  codes[1075] = 'ER_WRONG_AUTO_KEY';
@@ -259,7 +263,7 @@ codes[1172] = 'ER_TOO_MANY_ROWS';
259
263
  codes[1173] = 'ER_REQUIRES_PRIMARY_KEY';
260
264
  codes[1174] = 'ER_NO_RAID_COMPILED';
261
265
  codes[1175] = 'ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE';
262
- codes[1176] = 'ER_KEY_DOES_NOT_EXITS';
266
+ codes[1176] = 'ER_KEY_DOES_NOT_EXISTS';
263
267
  codes[1177] = 'ER_CHECK_NO_SUCH_TABLE';
264
268
  codes[1178] = 'ER_CHECK_NOT_IMPLEMENTED';
265
269
  codes[1179] = 'ER_CANT_DO_THIS_DURING_AN_TRANSACTION';
@@ -589,8 +593,8 @@ codes[1502] = 'ER_BLOB_FIELD_IN_PART_FUNC_ERROR';
589
593
  codes[1503] = 'ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF';
590
594
  codes[1504] = 'ER_NO_PARTS_ERROR';
591
595
  codes[1505] = 'ER_PARTITION_MGMT_ON_NONPARTITIONED';
592
- codes[1506] = 'ER_FOREIGN_KEY_ON_PARTITIONED';
593
- codes[1507] = 'ER_DROP_PARTITION_NON_EXISTENT';
596
+ codes[1506] = 'ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING';
597
+ codes[1507] = 'ER_PARTITION_DOES_NOT_EXIST';
594
598
  codes[1508] = 'ER_DROP_LAST_PARTITION';
595
599
  codes[1509] = 'ER_COALESCE_ONLY_ON_HASH_PARTITION';
596
600
  codes[1510] = 'ER_REORG_HASH_ONLY_ON_SAME_NO';
@@ -808,8 +812,8 @@ codes[1721] = 'ER_UNUSED_16';
808
812
  codes[1722] = 'ER_BINLOG_UNSAFE_WRITE_AUTOINC_SELECT';
809
813
  codes[1723] = 'ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC';
810
814
  codes[1724] = 'ER_BINLOG_UNSAFE_INSERT_TWO_KEYS';
811
- codes[1725] = 'ER_TABLE_IN_FK_CHECK';
812
- codes[1726] = 'ER_UNUSED_1';
815
+ codes[1725] = 'ER_UNUSED_28';
816
+ codes[1726] = 'ER_VERS_NOT_ALLOWED';
813
817
  codes[1727] = 'ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST';
814
818
  codes[1728] = 'ER_CANNOT_LOAD_FROM_TABLE_V2';
815
819
  codes[1729] = 'ER_MASTER_DELAY_VALUE_OUT_OF_RANGE';
@@ -1108,8 +1112,8 @@ codes[3057] = 'ER_USER_LOCK_WRONG_NAME';
1108
1112
  codes[3058] = 'ER_USER_LOCK_DEADLOCK';
1109
1113
  codes[3059] = 'ER_REPLACE_INACCESSIBLE_ROWS';
1110
1114
  codes[3060] = 'ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS';
1111
- codes[4000] = 'ER_COMMULTI_BADCONTEXT';
1112
- codes[4001] = 'ER_BAD_COMMAND_IN_MULTI';
1115
+ codes[4000] = 'ER_UNUSED_26';
1116
+ codes[4001] = 'ER_UNUSED_27';
1113
1117
  codes[4002] = 'ER_WITH_COL_WRONG_LIST';
1114
1118
  codes[4003] = 'ER_TOO_MANY_DEFINITIONS_IN_WITH_CLAUSE';
1115
1119
  codes[4004] = 'ER_DUP_QUERY_NAME';
@@ -1155,7 +1159,7 @@ codes[4043] = 'ER_JSON_PATH_DEPTH';
1155
1159
  codes[4044] = 'ER_JSON_PATH_NO_WILDCARD';
1156
1160
  codes[4045] = 'ER_JSON_PATH_ARRAY';
1157
1161
  codes[4046] = 'ER_JSON_ONE_OR_ALL';
1158
- codes[4047] = 'ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE';
1162
+ codes[4047] = 'ER_UNSUPPORTED_COMPRESSED_TABLE';
1159
1163
  codes[4048] = 'ER_GEOJSON_INCORRECT';
1160
1164
  codes[4049] = 'ER_GEOJSON_TOO_FEW_POINTS';
1161
1165
  codes[4050] = 'ER_GEOJSON_NOT_CLOSED';
@@ -1278,5 +1282,25 @@ codes[4166] = 'ER_LOAD_INFILE_CAPABILITY_DISABLED';
1278
1282
  codes[4167] = 'ER_NO_SECURE_TRANSPORTS_CONFIGURED';
1279
1283
  codes[4168] = 'ER_SLAVE_IGNORED_SHARED_TABLE';
1280
1284
  codes[4169] = 'ER_NO_AUTOINCREMENT_WITH_UNIQUE';
1285
+ codes[4170] = 'ER_KEY_CONTAINS_PERIOD_FIELDS';
1286
+ codes[4171] = 'ER_KEY_CANT_HAVE_WITHOUT_OVERLAPS';
1287
+ codes[4172] = 'ER_NOT_ALLOWED_IN_THIS_CONTEXT';
1288
+ codes[4173] = 'ER_DATA_WAS_COMMITED_UNDER_ROLLBACK';
1289
+ codes[4174] = 'ER_PK_INDEX_CANT_BE_IGNORED';
1290
+ codes[4175] = 'ER_BINLOG_UNSAFE_SKIP_LOCKED';
1291
+ codes[4176] = 'ER_JSON_TABLE_ERROR_ON_FIELD';
1292
+ codes[4177] = 'ER_JSON_TABLE_ALIAS_REQUIRED';
1293
+ codes[4178] = 'ER_JSON_TABLE_SCALAR_EXPECTED';
1294
+ codes[4179] = 'ER_JSON_TABLE_MULTIPLE_MATCHES';
1295
+ codes[4180] = 'ER_WITH_TIES_NEEDS_ORDER';
1296
+ codes[4181] = 'ER_REMOVED_ORPHAN_TRIGGER';
1297
+ codes[4182] = 'ER_STORAGE_ENGINE_DISABLED';
1298
+ codes[4183] = 'WARN_SFORMAT_ERROR';
1299
+ codes[4184] = 'ER_PARTITION_CONVERT_SUBPARTITIONED';
1300
+ codes[4185] = 'ER_PROVIDER_NOT_LOADED';
1301
+ codes[4186] = 'ER_JSON_HISTOGRAM_PARSE_FAILED';
1302
+ codes[4187] = 'ER_SF_OUT_INOUT_ARG_NOT_ALLOWED';
1303
+ codes[4188] = 'ER_INCONSISTENT_SLAVE_TEMP_TABLE';
1304
+ codes[4189] = 'ER_VERS_HIST_PART_FAILED';
1281
1305
 
1282
1306
  module.exports.codes = codes;
@@ -1,3 +1,6 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  /**
2
5
  * Column definition packet "Field detail" flag value
3
6
  * see : https://mariadb.com/kb/en/library/resultset/#field-detail-flag
@@ -1,3 +1,6 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  /**
2
5
  * Field types
3
6
  * see https://mariadb.com/kb/en/library/resultset/#field-types
@@ -6,12 +9,12 @@
6
9
  module.exports.DECIMAL = 0;
7
10
  module.exports.TINY = 1;
8
11
  module.exports.SHORT = 2;
9
- module.exports.LONG = 3;
12
+ module.exports.INT = 3;
10
13
  module.exports.FLOAT = 4;
11
14
  module.exports.DOUBLE = 5;
12
15
  module.exports.NULL = 6;
13
16
  module.exports.TIMESTAMP = 7;
14
- module.exports.LONGLONG = 8;
17
+ module.exports.BIGINT = 8;
15
18
  module.exports.INT24 = 9;
16
19
  module.exports.DATE = 10;
17
20
  module.exports.TIME = 11;
@@ -39,12 +42,12 @@ const typeNames = [];
39
42
  typeNames[0] = 'DECIMAL';
40
43
  typeNames[1] = 'TINY';
41
44
  typeNames[2] = 'SHORT';
42
- typeNames[3] = 'LONG';
45
+ typeNames[3] = 'INT';
43
46
  typeNames[4] = 'FLOAT';
44
47
  typeNames[5] = 'DOUBLE';
45
48
  typeNames[6] = 'NULL';
46
49
  typeNames[7] = 'TIMESTAMP';
47
- typeNames[8] = 'LONGLONG';
50
+ typeNames[8] = 'BIGINT';
48
51
  typeNames[9] = 'INT24';
49
52
  typeNames[10] = 'DATE';
50
53
  typeNames[11] = 'TIME';
@@ -1,3 +1,6 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  /**
2
5
  * possible server status flag value
3
6
  * see https://mariadb.com/kb/en/library/ok_packet/#server-status-flag
@@ -19,7 +22,7 @@ module.exports.STATUS_LAST_ROW_SENT = 128;
19
22
  module.exports.STATUS_DB_DROPPED = 1 << 8;
20
23
  //current escape mode is "no backslash escape"
21
24
  module.exports.STATUS_NO_BACKSLASH_ESCAPES = 1 << 9;
22
- //A DDL change did have an impact on an existing PREPARE (an automatic reprepare has been executed)
25
+ //A DDL change did have an impact on an existing PREPARE (an automatic re-prepare has been executed)
23
26
  module.exports.STATUS_METADATA_CHANGED = 1 << 10;
24
27
  module.exports.QUERY_WAS_SLOW = 1 << 11;
25
28
  //this result-set contain stored procedure output parameter
@@ -1,3 +1,6 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  /**
2
5
  * Session change type.
3
6
  * see : https://mariadb.com/kb/en/library/ok_packet/#session-change-type
@@ -0,0 +1,136 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
4
+ /**
5
+ * Similar to pool cluster with a pre-set pattern and selector.
6
+ * Additional method query
7
+ *
8
+ * @param poolCluster cluster
9
+ * @param patternArg pre-set pattern
10
+ * @param selectorArg pre-set selector
11
+ * @constructor
12
+ */
13
+ class FilteredClusterCallback {
14
+ #cluster;
15
+ #pattern;
16
+ #selector;
17
+
18
+ constructor(poolCluster, patternArg, selectorArg) {
19
+ this.#cluster = poolCluster;
20
+ this.#pattern = patternArg;
21
+ this.#selector = selectorArg;
22
+ }
23
+
24
+ /**
25
+ * Get a connection according to a previously indicated pattern and selector.
26
+ */
27
+ getConnection(callback) {
28
+ const cal = callback ? callback : (err, conn) => {};
29
+ return this.#cluster.getConnection(this.#pattern, this.#selector, cal);
30
+ }
31
+
32
+ /**
33
+ * Execute a text query on one connection from an available pools matching pattern
34
+ * in cluster.
35
+ *
36
+ * @param sql sql command
37
+ * @param value parameter value of SQL command (not mandatory)
38
+ * @param callback callback parameters
39
+ * @return {Promise}
40
+ */
41
+ query(sql, value, callback) {
42
+ let sq = sql,
43
+ val = value,
44
+ cal = callback;
45
+ if (typeof value === 'function') {
46
+ val = null;
47
+ cal = value;
48
+ }
49
+ const endingFct = cal ? cal : () => {};
50
+
51
+ this.getConnection((err, conn) => {
52
+ if (err) {
53
+ endingFct(err);
54
+ } else {
55
+ conn.query(sq, val, (err, res, meta) => {
56
+ conn.release(() => {});
57
+ if (err) {
58
+ endingFct(err);
59
+ } else {
60
+ endingFct(null, res, meta);
61
+ }
62
+ });
63
+ }
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Execute a binary query on one connection from an available pools matching pattern
69
+ * in cluster.
70
+ *
71
+ * @param sql sql command
72
+ * @param value parameter value of SQL command (not mandatory)
73
+ * @param callback callback function
74
+ */
75
+ execute(sql, value, callback) {
76
+ let sq = sql,
77
+ val = value,
78
+ cal = callback;
79
+ if (typeof value === 'function') {
80
+ val = null;
81
+ cal = value;
82
+ }
83
+ const endingFct = cal ? cal : () => {};
84
+
85
+ this.getConnection((err, conn) => {
86
+ if (err) {
87
+ endingFct(err);
88
+ } else {
89
+ conn.execute(sq, val, (err, res, meta) => {
90
+ conn.release(() => {});
91
+ if (err) {
92
+ endingFct(err);
93
+ } else {
94
+ endingFct(null, res, meta);
95
+ }
96
+ });
97
+ }
98
+ });
99
+ }
100
+
101
+ /**
102
+ * Execute a batch on one connection from an available pools matching pattern
103
+ * in cluster.
104
+ *
105
+ * @param sql sql command
106
+ * @param value parameter value of SQL command
107
+ * @param callback callback function
108
+ */
109
+ batch(sql, value, callback) {
110
+ let sq = sql,
111
+ val = value,
112
+ cal = callback;
113
+ if (typeof value === 'function') {
114
+ val = null;
115
+ cal = value;
116
+ }
117
+ const endingFct = cal ? cal : () => {};
118
+
119
+ this.getConnection((err, conn) => {
120
+ if (err) {
121
+ endingFct(err);
122
+ } else {
123
+ conn.batch(sq, val, (err, res, meta) => {
124
+ conn.release(() => {});
125
+ if (err) {
126
+ endingFct(err);
127
+ } else {
128
+ endingFct(null, res, meta);
129
+ }
130
+ });
131
+ }
132
+ });
133
+ }
134
+ }
135
+
136
+ module.exports = FilteredClusterCallback;
@@ -0,0 +1,118 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
4
+ /**
5
+ * Similar to pool cluster with pre-set pattern and selector.
6
+ * Additional method query
7
+ *
8
+ * @param poolCluster cluster
9
+ * @param patternArg pre-set pattern
10
+ * @param selectorArg pre-set selector
11
+ * @constructor
12
+ */
13
+ class FilteredCluster {
14
+ #cluster;
15
+ #pattern;
16
+ #selector;
17
+
18
+ constructor(poolCluster, patternArg, selectorArg) {
19
+ this.#cluster = poolCluster;
20
+ this.#pattern = patternArg;
21
+ this.#selector = selectorArg;
22
+ }
23
+
24
+ /**
25
+ * Get a connection according to a previously indicated pattern and selector.
26
+ *
27
+ * @return {Promise}
28
+ */
29
+ getConnection() {
30
+ return this.#cluster.getConnection(this.#pattern, this.#selector);
31
+ }
32
+
33
+ /**
34
+ * Execute a text query on one connection from an available pools matching pattern
35
+ * in cluster.
36
+ *
37
+ * @param sql sql command
38
+ * @param value parameter value of sql command (not mandatory)
39
+ * @return {Promise}
40
+ */
41
+ query(sql, value) {
42
+ return this.#cluster
43
+ .getConnection(this.#pattern, this.#selector)
44
+ .then((conn) => {
45
+ return conn
46
+ .query(sql, value)
47
+ .then((res) => {
48
+ conn.release();
49
+ return res;
50
+ })
51
+ .catch((err) => {
52
+ conn.release();
53
+ return Promise.reject(err);
54
+ });
55
+ })
56
+ .catch((err) => {
57
+ return Promise.reject(err);
58
+ });
59
+ }
60
+
61
+ /**
62
+ * Execute a binary query on one connection from available pools matching pattern
63
+ * in cluster.
64
+ *
65
+ * @param sql sql command
66
+ * @param value parameter value of sql command (not mandatory)
67
+ * @return {Promise}
68
+ */
69
+ execute(sql, value) {
70
+ return this.#cluster
71
+ .getConnection(this.#pattern, this.#selector)
72
+ .then((conn) => {
73
+ return conn
74
+ .execute(sql, value)
75
+ .then((res) => {
76
+ conn.release();
77
+ return res;
78
+ })
79
+ .catch((err) => {
80
+ conn.release();
81
+ return Promise.reject(err);
82
+ });
83
+ })
84
+ .catch((err) => {
85
+ return Promise.reject(err);
86
+ });
87
+ }
88
+
89
+ /**
90
+ * Execute a batch on one connection from available pools matching pattern
91
+ * in cluster.
92
+ *
93
+ * @param sql sql command
94
+ * @param value parameter value of sql command
95
+ * @return {Promise}
96
+ */
97
+ batch(sql, value) {
98
+ return this.#cluster
99
+ .getConnection(this.#pattern, this.#selector)
100
+ .then((conn) => {
101
+ return conn
102
+ .batch(sql, value)
103
+ .then((res) => {
104
+ conn.release();
105
+ return res;
106
+ })
107
+ .catch((err) => {
108
+ conn.release();
109
+ return Promise.reject(err);
110
+ });
111
+ })
112
+ .catch((err) => {
113
+ return Promise.reject(err);
114
+ });
115
+ }
116
+ }
117
+
118
+ module.exports = FilteredCluster;
@@ -1,3 +1,6 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  'use strict';
2
5
 
3
6
  const ZLib = require('zlib');
@@ -26,15 +29,14 @@ class CompressionInputStream {
26
29
  receivePacket(chunk) {
27
30
  let cmd = this.currentCmd();
28
31
  if (this.opts.debugCompress) {
29
- console.log(
30
- '<== conn:%d %s (compress)\n%s',
31
- this.info.threadId ? this.info.threadId : -1,
32
- cmd
33
- ? cmd.onPacketReceive
34
- ? cmd.constructor.name + '.' + cmd.onPacketReceive.name
35
- : cmd.constructor.name
36
- : 'no command',
37
- Utils.log(this.opts, chunk, 0, chunk.length, this.header)
32
+ this.opts.logger.network(
33
+ `<== conn:${this.info.threadId ? this.info.threadId : -1} ${
34
+ cmd
35
+ ? cmd.onPacketReceive
36
+ ? cmd.constructor.name + '.' + cmd.onPacketReceive.name
37
+ : cmd.constructor.name
38
+ : 'no command'
39
+ } (compress)\n${Utils.log(this.opts, chunk, 0, chunk.length, this.header)}`
38
40
  );
39
41
  }
40
42
  if (cmd) cmd.compressSequenceNo = this.header[3];
@@ -89,8 +91,7 @@ class CompressionInputStream {
89
91
  while (chunkLen - pos > 0) {
90
92
  this.header[this.headerLen++] = chunk[pos++];
91
93
  if (this.headerLen === 7) {
92
- this.compressPacketLen =
93
- this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
94
+ this.compressPacketLen = this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
94
95
  this.packetLen = this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
95
96
  if (this.packetLen === 0) this.packetLen = this.compressPacketLen;
96
97
  length = this.compressPacketLen;
@@ -101,7 +102,7 @@ class CompressionInputStream {
101
102
 
102
103
  if (length) {
103
104
  if (chunkLen - pos >= length) {
104
- const buf = chunk.slice(pos, pos + length);
105
+ const buf = chunk.subarray(pos, pos + length);
105
106
  pos += length;
106
107
  if (this.parts) {
107
108
  this.parts.push(buf);
@@ -122,7 +123,7 @@ class CompressionInputStream {
122
123
  }
123
124
  this.resetHeader();
124
125
  } else {
125
- const buf = chunk.slice(pos, chunkLen);
126
+ const buf = chunk.subarray(pos, chunkLen);
126
127
  if (!this.parts) {
127
128
  this.parts = [buf];
128
129
  this.partsTotalLen = chunkLen - pos;
@@ -1,3 +1,6 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2024 MariaDB Corporation Ab
3
+
1
4
  'use strict';
2
5
 
3
6
  const Utils = require('../misc/utils');
@@ -50,6 +53,9 @@ class CompressionOutputStream {
50
53
  writeBuf(arr, cmd) {
51
54
  let off = 0,
52
55
  len = arr.length;
56
+ if (arr instanceof Uint8Array) {
57
+ arr = Buffer.from(arr);
58
+ }
53
59
  if (len > this.buf.length - this.pos) {
54
60
  if (this.buf.length !== MAX_BUFFER_SIZE) {
55
61
  this.growBuffer(len);
@@ -96,21 +102,20 @@ class CompressionOutputStream {
96
102
  this.buf[6] = 0;
97
103
 
98
104
  if (this.opts.debugCompress) {
99
- console.log(
100
- '==> conn:%d %s (compress)\n%s',
101
- this.info.threadId ? this.info.threadId : -1,
102
- cmd ? cmd.constructor.name + '(0,' + this.pos + ')' : 'unknown',
103
- Utils.log(this.opts, this.buf, 0, this.pos)
105
+ this.opts.logger.network(
106
+ `==> conn:${this.info.threadId ? this.info.threadId : -1} ${
107
+ cmd ? cmd.constructor.name + '(0,' + this.pos + ')' : 'unknown'
108
+ } (compress)\n${Utils.log(this.opts, this.buf, 0, this.pos)}`
104
109
  );
105
110
  }
106
111
 
107
- this.writer(this.buf.slice(0, this.pos));
112
+ this.writer(this.buf.subarray(0, this.pos));
108
113
  } else {
109
114
  //*******************************************************************************
110
115
  // compressing packet
111
116
  //*******************************************************************************
112
117
  //use synchronous inflating, to ensure FIFO packet order
113
- const compressChunk = ZLib.deflateSync(this.buf.slice(7, this.pos));
118
+ const compressChunk = ZLib.deflateSync(this.buf.subarray(7, this.pos));
114
119
  const compressChunkLen = compressChunk.length;
115
120
 
116
121
  this.header[0] = compressChunkLen;
@@ -122,17 +127,16 @@ class CompressionOutputStream {
122
127
  this.header[6] = (this.pos - 7) >>> 16;
123
128
 
124
129
  if (this.opts.debugCompress) {
125
- console.log(
126
- '==> conn:%d %s (compress)\n%s',
127
- this.info.threadId ? this.info.threadId : -1,
128
- cmd ? cmd.constructor.name + '(0,' + this.pos + '=>' + compressChunkLen + ')' : 'unknown',
129
- Utils.log(this.opts, compressChunk, 0, compressChunkLen, this.header)
130
+ this.opts.logger.network(
131
+ `==> conn:${this.info.threadId ? this.info.threadId : -1} ${
132
+ cmd ? cmd.constructor.name + '(0,' + this.pos + '=>' + compressChunkLen + ')' : 'unknown'
133
+ } (compress)\n${Utils.log(this.opts, compressChunk, 0, compressChunkLen, this.header)}`
130
134
  );
131
135
  }
132
136
 
133
137
  this.writer(this.header);
134
138
  this.writer(compressChunk);
135
- if (cmdEnd && this.pos === MAX_BUFFER_SIZE) this.writeEmptyPacket(cmd);
139
+ if (cmdEnd && compressChunkLen === MAX_BUFFER_SIZE) this.writeEmptyPacket(cmd);
136
140
  this.header = Buffer.allocUnsafe(7);
137
141
  }
138
142
  this.buf = remainingLen
@@ -156,11 +160,10 @@ class CompressionOutputStream {
156
160
  const emptyBuf = Buffer.from([0x00, 0x00, 0x00, cmd.compressSequenceNo, 0x00, 0x00, 0x00]);
157
161
 
158
162
  if (this.opts.debugCompress) {
159
- console.log(
160
- '==> conn:%d %s (compress)\n%s',
161
- this.info.threadId ? this.info.threadId : -1,
162
- cmd ? cmd.constructor.name + '(0,' + this.pos + ')' : 'unknown',
163
- Utils.log(this.opts, emptyBuf, 0, 7)
163
+ this.opts.logger.network(
164
+ `==> conn:${this.info.threadId ? this.info.threadId : -1} ${
165
+ cmd ? cmd.constructor.name + '(0,' + this.pos + ')' : 'unknown'
166
+ } (compress)\n${Utils.log(this.opts, emptyBuf, 0, 7)}`
164
167
  );
165
168
  }
166
169