@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,108 +1,242 @@
1
+ // SPDX-License-Identifier: LGPL-2.1-or-later
2
+ // Copyright (c) 2015-2025 MariaDB Corporation Ab
3
+
1
4
  'use strict';
2
5
 
3
- const Connection = require('./connection');
4
- const PoolBase = require('./pool-base');
6
+ const { EventEmitter } = require('events');
7
+
8
+ const Pool = require('./pool');
9
+ const ConnectionPromise = require('./connection-promise');
5
10
  const Errors = require('./misc/errors');
6
- const util = require('util');
7
-
8
- function PoolPromise(options) {
9
- const processTaskPromise = function (conn, sql, values, isBatch) {
10
- if (sql) {
11
- const fct = isBatch ? conn.batch : conn.query;
12
- return fct(sql, values)
13
- .then((res) => {
14
- conn.releaseWithoutError();
15
- return Promise.resolve(res);
16
- })
17
- .catch((err) => {
18
- conn.releaseWithoutError();
19
- return Promise.reject(err);
20
- });
21
- }
22
- return Promise.resolve(conn);
23
- };
11
+
12
+ class PoolPromise extends EventEmitter {
13
+ #pool;
14
+ constructor(options) {
15
+ super();
16
+ this.#pool = new Pool(options);
17
+ this.#pool.on('acquire', this.emit.bind(this, 'acquire'));
18
+ this.#pool.on('connection', this.emit.bind(this, 'connection'));
19
+ this.#pool.on('enqueue', this.emit.bind(this, 'enqueue'));
20
+ this.#pool.on('release', this.emit.bind(this, 'release'));
21
+ this.#pool.on('error', this.emit.bind(this, 'error'));
22
+ }
23
+
24
+ get closed() {
25
+ return this.#pool.closed;
26
+ }
27
+
28
+ /**
29
+ * Get current total connection number.
30
+ * @return {number}
31
+ */
32
+ totalConnections() {
33
+ return this.#pool.totalConnections();
34
+ }
35
+
36
+ /**
37
+ * Get current active connections.
38
+ * @return {number}
39
+ */
40
+ activeConnections() {
41
+ return this.#pool.activeConnections();
42
+ }
43
+
44
+ /**
45
+ * Get current idle connection number.
46
+ * @return {number}
47
+ */
48
+ idleConnections() {
49
+ return this.#pool.idleConnections();
50
+ }
51
+
52
+ /**
53
+ * Get current stacked connection request.
54
+ * @return {number}
55
+ */
56
+ taskQueueSize() {
57
+ return this.#pool.taskQueueSize();
58
+ }
59
+
60
+ escape(value) {
61
+ return this.#pool.escape(value);
62
+ }
63
+
64
+ escapeId(value) {
65
+ return this.#pool.escapeId(value);
66
+ }
67
+
68
+ /**
69
+ * Ends pool
70
+ *
71
+ * @return Promise
72
+ **/
73
+ end() {
74
+ return this.#pool.end();
75
+ }
76
+
77
+ /**
78
+ * Retrieve a connection from pool.
79
+ * Create a new one, if limit is not reached.
80
+ * wait until acquireTimeout.
81
+ *
82
+ */
83
+ async getConnection() {
84
+ const cmdParam = {};
85
+ if (this.#pool.opts.connOptions.trace) Error.captureStackTrace(cmdParam);
86
+ return new Promise((resolve, reject) => {
87
+ this.#pool.getConnection(cmdParam, (err, baseConn) => {
88
+ if (err) {
89
+ reject(err);
90
+ } else {
91
+ const conn = new ConnectionPromise(baseConn);
92
+ conn.release = () => new Promise(baseConn.release);
93
+ conn.end = conn.release;
94
+ conn.close = conn.release;
95
+ resolve(conn);
96
+ }
97
+ });
98
+ });
99
+ }
24
100
 
25
101
  /**
26
- * Add connection to pool.
102
+ * Execute query using text protocol with callback emit columns/data/end/error
103
+ * events to permit streaming big result-set
104
+ *
105
+ * @param sql sql parameter Object can be used to supersede default option.
106
+ * Object must then have sql property.
107
+ * @param values object / array of placeholder values (not mandatory)
27
108
  */
28
- const createConnectionPoolPromise = function (pool) {
29
- const conn = new Connection(options.connOptions);
30
- return conn
31
- .connect()
32
- .then(() => {
33
- if (pool.closed) {
34
- conn
35
- .end()
36
- .then(() => {})
37
- .catch(() => {});
38
- return Promise.reject(
39
- Errors.createError(
40
- 'Cannot create new connection to pool, pool closed',
41
- null,
42
- true,
43
- null,
44
- '08S01',
45
- Errors.ER_ADD_CONNECTION_CLOSED_POOL,
46
- null
47
- )
109
+ query(sql, values) {
110
+ const cmdParam = ConnectionPromise.paramSetter(sql, values);
111
+ if (this.#pool.opts.connOptions.trace) Error.captureStackTrace(cmdParam);
112
+ return new Promise((resolve, reject) => {
113
+ return this.#pool.getConnection(cmdParam, (err, baseConn) => {
114
+ if (err) {
115
+ reject(err);
116
+ } else {
117
+ baseConn.query(
118
+ cmdParam,
119
+ (res) => {
120
+ this.#pool.release(baseConn);
121
+ resolve(res);
122
+ },
123
+ (err) => {
124
+ this.#pool.release(baseConn);
125
+ reject(err);
126
+ }
48
127
  );
49
128
  }
129
+ });
130
+ });
131
+ }
50
132
 
51
- conn.releaseWithoutError = () => {
52
- conn.release().catch(() => {});
53
- };
54
-
55
- conn.forceEnd = conn.end;
56
-
57
- conn.release = () => {
58
- if (pool.closed) {
59
- pool._discardConnection(conn);
60
- return Promise.resolve();
61
- }
62
- if (options.noControlAfterUse) {
63
- pool._releaseConnection(conn);
64
- return Promise.resolve();
65
- }
66
-
67
- //if server permit it, reset the connection, or rollback only if not
68
- // COM_RESET_CONNECTION exist since mysql 5.7.3 and mariadb 10.2.4
69
- // but not possible to use it with mysql waiting for https://bugs.mysql.com/bug.php?id=97633 correction.
70
- // and mariadb only since https://jira.mariadb.org/browse/MDEV-18281
71
- let revertFunction = conn.rollback;
72
- if (
73
- options.resetAfterUse &&
74
- conn.info.isMariaDB() &&
75
- ((conn.info.serverVersion.minor === 2 && conn.info.hasMinVersion(10, 2, 22)) ||
76
- conn.info.hasMinVersion(10, 3, 13))
77
- ) {
78
- revertFunction = conn.reset;
79
- }
80
-
81
- return revertFunction()
82
- .then(() => {
83
- pool._releaseConnection(conn);
84
- return Promise.resolve();
85
- })
86
- .catch((err) => {
87
- //uncertain connection state.
88
- // discard it
89
- pool._discardConnection(conn);
90
- return Promise.resolve();
91
- });
92
- };
93
- conn.end = conn.release;
94
- return Promise.resolve(conn);
95
- })
96
- .catch((err) => {
97
- return Promise.reject(err);
133
+ /**
134
+ * Execute query using binary protocol with callback emit columns/data/end/error
135
+ * events to permit streaming big result-set
136
+ *
137
+ * @param sql sql parameter Object can be used to supersede default option.
138
+ * Object must then have sql property.
139
+ * @param values object / array of placeholder values (not mandatory)
140
+ */
141
+ execute(sql, values) {
142
+ const cmdParam = ConnectionPromise.paramSetter(sql, values);
143
+ if (this.#pool.opts.connOptions.trace) Error.captureStackTrace(cmdParam);
144
+ return new Promise((resolve, reject) => {
145
+ return this.#pool.getConnection(cmdParam, (err, baseConn) => {
146
+ if (err) {
147
+ reject(err);
148
+ } else {
149
+ baseConn.prepareExecute(
150
+ cmdParam,
151
+ (res) => {
152
+ this.#pool.release(baseConn);
153
+ resolve(res);
154
+ },
155
+ (err) => {
156
+ this.#pool.release(baseConn);
157
+ reject(err);
158
+ }
159
+ );
160
+ }
98
161
  });
99
- };
162
+ });
163
+ }
100
164
 
101
- PoolBase.call(this, options, processTaskPromise, createConnectionPoolPromise, (conn) =>
102
- conn.ping(options.pingTimeout)
103
- );
104
- }
165
+ /**
166
+ * execute a batch
167
+ *
168
+ * @param sql sql parameter Object can be used to supersede default option.
169
+ * Object must then have sql property.
170
+ * @param values array of placeholder values
171
+ */
172
+ batch(sql, values) {
173
+ const cmdParam = ConnectionPromise.paramSetter(sql, values);
174
+ if (this.#pool.opts.connOptions.trace) Error.captureStackTrace(cmdParam);
175
+ return new Promise((resolve, reject) => {
176
+ return this.#pool.getConnection(cmdParam, (err, baseConn) => {
177
+ if (err) {
178
+ reject(err);
179
+ } else {
180
+ baseConn.batch(
181
+ cmdParam,
182
+ (res) => {
183
+ this.#pool.release(baseConn);
184
+ resolve(res);
185
+ },
186
+ (err) => {
187
+ this.#pool.release(baseConn);
188
+ reject(err);
189
+ }
190
+ );
191
+ }
192
+ });
193
+ });
194
+ }
195
+
196
+ /**
197
+ * Import sql file.
198
+ *
199
+ * @param opts JSON array with 2 possible fields: file and database
200
+ */
201
+ importFile(opts) {
202
+ if (!opts) {
203
+ return Promise.reject(
204
+ Errors.createError(
205
+ 'SQL file parameter is mandatory',
206
+ Errors.ER_MISSING_SQL_PARAMETER,
207
+ null,
208
+ 'HY000',
209
+ null,
210
+ false,
211
+ null
212
+ )
213
+ );
214
+ }
105
215
 
106
- util.inherits(PoolPromise, PoolBase);
216
+ return new Promise((resolve, reject) => {
217
+ return this.#pool.getConnection({}, (err, baseConn) => {
218
+ if (err) {
219
+ reject(err);
220
+ } else {
221
+ baseConn.importFile(
222
+ { file: opts.file, database: opts.database },
223
+ (res) => {
224
+ this.#pool.release(baseConn);
225
+ resolve(res);
226
+ },
227
+ (err) => {
228
+ this.#pool.release(baseConn);
229
+ reject(err);
230
+ }
231
+ );
232
+ }
233
+ });
234
+ });
235
+ }
236
+
237
+ toString() {
238
+ return 'poolPromise(' + this.#pool.toString() + ')';
239
+ }
240
+ }
107
241
 
108
242
  module.exports = PoolPromise;