@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,35 +1,40 @@
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 Collations = require('../const/collations.js');
4
7
  const FieldType = require('../const/field-type');
8
+ const FieldDetails = require('../const/field-detail');
5
9
  const Capabilities = require('../const/capabilities');
6
10
 
11
+ // noinspection JSBitwiseOperatorUsage
7
12
  /**
8
13
  * Column definition
9
14
  * see https://mariadb.com/kb/en/library/resultset/#column-definition-packet
10
15
  */
11
16
  class ColumnDef {
12
- constructor(packet, info) {
13
- this._parse = new StringParser(packet);
14
- if (info.serverCapabilities & Capabilities.MARIADB_CLIENT_EXTENDED_TYPE_INFO) {
15
- const subPacket = packet.subPacketLengthEncoded();
16
- while (subPacket.remaining()) {
17
- switch (subPacket.readUInt8()) {
18
- case 0:
19
- this.dataTypeName = subPacket.readAsciiStringLengthEncoded();
20
- break;
21
-
22
- case 1:
23
- this.dataTypeFormat = subPacket.readAsciiStringLengthEncoded();
24
- break;
25
-
26
- default:
27
- // skip data
28
- const len = subPacket.readUnsignedLength();
29
- if (len) {
30
- subPacket.skip(len);
31
- }
32
- break;
17
+ #stringParser;
18
+ constructor(packet, info, skipName) {
19
+ this.#stringParser = skipName ? new StringParser(packet) : new StringParserWithName(packet);
20
+ if (info.clientCapabilities & Capabilities.MARIADB_CLIENT_EXTENDED_METADATA) {
21
+ const len = packet.readUnsignedLength();
22
+ if (len > 0) {
23
+ const subPacket = packet.subPacketLengthEncoded(len);
24
+ while (subPacket.remaining()) {
25
+ switch (subPacket.readUInt8()) {
26
+ case 0:
27
+ this.dataTypeName = subPacket.readAsciiStringLengthEncoded();
28
+ break;
29
+
30
+ case 1:
31
+ this.dataTypeFormat = subPacket.readAsciiStringLengthEncoded();
32
+ break;
33
+
34
+ default:
35
+ subPacket.skip(subPacket.readUnsignedLength());
36
+ break;
37
+ }
33
38
  }
34
39
  }
35
40
  }
@@ -43,59 +48,152 @@ class ColumnDef {
43
48
  this.type = FieldType.TYPES[this.columnType];
44
49
  }
45
50
 
51
+ __getDefaultGeomVal() {
52
+ if (this.dataTypeName) {
53
+ switch (this.dataTypeName) {
54
+ case 'point':
55
+ return { type: 'Point' };
56
+ case 'linestring':
57
+ return { type: 'LineString' };
58
+ case 'polygon':
59
+ return { type: 'Polygon' };
60
+ case 'multipoint':
61
+ return { type: 'MultiPoint' };
62
+ case 'multilinestring':
63
+ return { type: 'MultiLineString' };
64
+ case 'multipolygon':
65
+ return { type: 'MultiPolygon' };
66
+ default:
67
+ return { type: this.dataTypeName };
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+
46
73
  db() {
47
- return this._parse.packet.readString(this._parse.dbOffset, this._parse.dbLength);
74
+ return this.#stringParser.db();
48
75
  }
49
76
 
50
77
  schema() {
51
- return this._parse.packet.readString(this._parse.dbOffset, this._parse.dbLength);
78
+ return this.#stringParser.schema();
52
79
  }
53
80
 
54
81
  table() {
55
- return this._parse.packet.readString(this._parse.tableOffset, this._parse.tableLength);
82
+ return this.#stringParser.table();
56
83
  }
57
84
 
58
85
  orgTable() {
59
- return this._parse.packet.readString(this._parse.orgTableOffset, this._parse.orgTableLength);
86
+ return this.#stringParser.orgTable();
60
87
  }
61
88
 
62
89
  name() {
63
- return this._parse.packet.readString(this._parse.nameOffset, this._parse.nameLength);
90
+ return this.#stringParser.name();
64
91
  }
65
92
 
66
93
  orgName() {
67
- return this._parse.packet.readString(this._parse.orgNameOffset, this._parse.orgNameLength);
94
+ return this.#stringParser.orgName();
95
+ }
96
+
97
+ signed() {
98
+ return (this.flags & FieldDetails.UNSIGNED) === 0;
99
+ }
100
+
101
+ isSet() {
102
+ return (this.flags & FieldDetails.SET) !== 0;
68
103
  }
69
104
  }
70
105
 
71
106
  /**
72
107
  * String parser.
73
- * This object permits to avoid listing all private information to metadata object.
108
+ * This object permits avoiding listing all private information to a metadata object.
74
109
  */
75
- class StringParser {
76
- constructor(packet) {
77
- packet.skip(4); // skip 'def'
78
110
 
79
- this.dbLength = packet.readUnsignedLength();
80
- this.dbOffset = packet.pos;
81
- packet.skip(this.dbLength);
111
+ class BaseStringParser {
112
+ constructor(encoding, readFct, saveBuf, initialPos) {
113
+ this.buf = saveBuf;
114
+ this.encoding = encoding;
115
+ this.readString = readFct;
116
+ this.initialPos = initialPos;
117
+ }
118
+
119
+ _readIdentifier(skip) {
120
+ let pos = this.initialPos;
121
+ while (skip-- > 0) {
122
+ const type = this.buf[pos++];
123
+ pos += type < 0xfb ? type : 2 + this.buf[pos] + this.buf[pos + 1] * 2 ** 8;
124
+ }
125
+
126
+ const type = this.buf[pos++];
127
+ const len = type < 0xfb ? type : this.buf[pos++] + this.buf[pos++] * 2 ** 8;
128
+
129
+ return this.readString(this.encoding, this.buf, pos, len);
130
+ }
131
+
132
+ name() {
133
+ return this._readIdentifier(3);
134
+ }
135
+
136
+ db() {
137
+ let pos = this.initialPos;
138
+ return this.readString(this.encoding, this.buf, pos + 1, this.buf[pos]);
139
+ }
140
+
141
+ schema() {
142
+ return this.db();
143
+ }
144
+
145
+ table() {
146
+ let pos = this.initialPos + 1 + this.buf[this.initialPos];
82
147
 
83
- this.tableLength = packet.readUnsignedLength();
84
- this.tableOffset = packet.pos;
85
- packet.skip(this.tableLength);
148
+ const type = this.buf[pos++];
149
+ const len = type < 0xfb ? type : this.buf[pos++] + this.buf[pos++] * 2 ** 8;
150
+ return this.readString(this.encoding, this.buf, pos, len);
151
+ }
86
152
 
87
- this.orgTableLength = packet.readUnsignedLength();
88
- this.orgTableOffset = packet.pos;
89
- packet.skip(this.orgTableLength);
153
+ orgTable() {
154
+ return this._readIdentifier(2);
155
+ }
90
156
 
91
- this.nameLength = packet.readUnsignedLength();
92
- this.nameOffset = packet.pos;
93
- packet.skip(this.nameLength);
157
+ orgName() {
158
+ return this._readIdentifier(4);
159
+ }
160
+ }
94
161
 
95
- this.orgNameLength = packet.readUnsignedLength();
96
- this.orgNameOffset = packet.pos;
97
- packet.skip(this.orgNameLength);
98
- this.packet = packet;
162
+ class StringParser extends BaseStringParser {
163
+ constructor(packet) {
164
+ packet.skip(packet.readUInt8()); //catalog
165
+ const initPos = packet.pos;
166
+ packet.skip(packet.readUInt8()); //schema
167
+ packet.skip(packet.readMetadataLength()); //table alias
168
+ packet.skip(packet.readUInt8()); //table
169
+ packet.skip(packet.readMetadataLength()); //column alias
170
+ packet.skip(packet.readUInt8()); //column
171
+
172
+ super(packet.encoding, packet.constructor.readString, packet.buf, initPos);
173
+ }
174
+ }
175
+
176
+ /**
177
+ * String parser.
178
+ * This object permits to avoid listing all private information to metadata object.
179
+ */
180
+ class StringParserWithName extends BaseStringParser {
181
+ colName;
182
+ constructor(packet) {
183
+ packet.skip(packet.readUInt8()); //catalog
184
+ const initPos = packet.pos;
185
+ packet.skip(packet.readUInt8()); //schema
186
+ packet.skip(packet.readMetadataLength()); //table alias
187
+ packet.skip(packet.readUInt8()); //table
188
+ const colName = packet.readStringLengthEncoded(); //column alias
189
+ packet.skip(packet.readUInt8()); //column
190
+
191
+ super(packet.encoding, packet.constructor.readString, packet.buf, initPos);
192
+ this.colName = colName;
193
+ }
194
+
195
+ name() {
196
+ return this.colName;
99
197
  }
100
198
  }
101
199
 
@@ -1,23 +1,24 @@
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 EventEmitter = require('events');
4
7
  const Errors = require('../misc/errors');
5
- const ServerStatus = require('../const/server-status');
6
- const StateChange = require('../const/state-change');
7
- const Collations = require('../const/collations');
8
- const OkPacket = require('./class/ok-packet');
9
8
 
10
9
  /**
11
10
  * Default command interface.
12
11
  */
13
12
  class Command extends EventEmitter {
14
- constructor(resolve, reject) {
13
+ constructor(cmdParam, resolve, reject) {
15
14
  super();
15
+ this.cmdParam = cmdParam;
16
16
  this.sequenceNo = -1;
17
17
  this.compressSequenceNo = -1;
18
18
  this.resolve = resolve;
19
19
  this.reject = reject;
20
20
  this.sending = false;
21
+ this.unexpectedError = this.throwUnexpectedError.bind(this);
21
22
  }
22
23
 
23
24
  displaySql() {
@@ -25,7 +26,7 @@ class Command extends EventEmitter {
25
26
  }
26
27
 
27
28
  /**
28
- * Throw an an unexpected error.
29
+ * Throw an unexpected error.
29
30
  * server exchange will still be read to keep connection in a good state, but promise will be rejected.
30
31
  *
31
32
  * @param msg message
@@ -35,14 +36,22 @@ class Command extends EventEmitter {
35
36
  * @param errno error number
36
37
  */
37
38
  throwUnexpectedError(msg, fatal, info, sqlState, errno) {
39
+ const err = Errors.createError(
40
+ msg,
41
+ errno,
42
+ info,
43
+ sqlState,
44
+ this.opts && this.opts.logParam ? this.displaySql() : this.sql,
45
+ fatal,
46
+ this.cmdParam ? this.cmdParam.stack : null,
47
+ false
48
+ );
38
49
  if (this.reject) {
39
- process.nextTick(
40
- this.reject,
41
- Errors.createError(msg, this.displaySql(), fatal, info, sqlState, errno, this.stack, false)
42
- );
50
+ process.nextTick(this.reject, err);
43
51
  this.resolve = null;
44
52
  this.reject = null;
45
53
  }
54
+ return err;
46
55
  }
47
56
 
48
57
  /**
@@ -57,15 +66,23 @@ class Command extends EventEmitter {
57
66
  */
58
67
  throwNewError(msg, fatal, info, sqlState, errno) {
59
68
  this.onPacketReceive = null;
60
- if (this.reject) {
61
- process.nextTick(
62
- this.reject,
63
- Errors.createError(msg, this.displaySql(), fatal, info, sqlState, errno, this.stack, false)
64
- );
65
- this.resolve = null;
66
- this.reject = null;
67
- }
69
+ const err = this.throwUnexpectedError(msg, fatal, info, sqlState, errno);
68
70
  this.emit('end');
71
+ return err;
72
+ }
73
+
74
+ /**
75
+ * When command cannot be sent due to error.
76
+ * (this is only on start command)
77
+ *
78
+ * @param msg error message
79
+ * @param errno error number
80
+ * @param info connection information
81
+ */
82
+ sendCancelled(msg, errno, info) {
83
+ const err = Errors.createError(msg, errno, info, 'HY000', this.opts.logParam ? this.displaySql() : this.sql);
84
+ this.emit('send_end');
85
+ this.throwError(err, info);
69
86
  }
70
87
 
71
88
  /**
@@ -78,15 +95,15 @@ class Command extends EventEmitter {
78
95
  throwError(err, info) {
79
96
  this.onPacketReceive = null;
80
97
  if (this.reject) {
81
- if (this.stack) {
98
+ if (this.cmdParam && this.cmdParam.stack) {
82
99
  err = Errors.createError(
83
- err.message,
84
- err.sql,
85
- err.fatal,
100
+ err.text ? err.text : err.message,
101
+ err.errno,
86
102
  info,
87
103
  err.sqlState,
88
- err.errno,
89
- this.stack,
104
+ err.sql,
105
+ err.fatal,
106
+ this.cmdParam.stack,
90
107
  false
91
108
  );
92
109
  }
@@ -112,57 +129,6 @@ class Command extends EventEmitter {
112
129
  }
113
130
  this.emit('end');
114
131
  }
115
-
116
- parseOkPacket(packet, out, opts, info) {
117
- packet.skip(1); //skip header
118
-
119
- const affectedRows = packet.readUnsignedLength();
120
- const insertId = opts.supportBigInt
121
- ? packet.readSignedLengthBigInt()
122
- : packet.readSignedLength();
123
-
124
- info.status = packet.readUInt16();
125
-
126
- const okPacket = new OkPacket(affectedRows, insertId, packet.readUInt16());
127
-
128
- if (info.status & ServerStatus.SESSION_STATE_CHANGED) {
129
- packet.skipLengthCodedNumber();
130
- while (packet.remaining()) {
131
- const subPacket = packet.subPacketLengthEncoded();
132
- while (subPacket.remaining()) {
133
- const type = subPacket.readUInt8();
134
- switch (type) {
135
- case StateChange.SESSION_TRACK_SYSTEM_VARIABLES:
136
- const subSubPacket = subPacket.subPacketLengthEncoded();
137
- const variable = subSubPacket.readStringLength();
138
- const value = subSubPacket.readStringLength();
139
-
140
- switch (variable) {
141
- case 'character_set_client':
142
- opts.collation = Collations.fromCharset(value);
143
- if (opts.collation === undefined) {
144
- this.throwError(new Error("unknown charset : '" + value + "'"), info);
145
- return;
146
- }
147
- opts.emit('collation', opts.collation);
148
- break;
149
-
150
- default:
151
- //variable not used by driver
152
- }
153
- break;
154
-
155
- case StateChange.SESSION_TRACK_SCHEMA:
156
- const subSubPacket2 = subPacket.subPacketLengthEncoded();
157
- info.database = subSubPacket2.readStringLength();
158
- break;
159
- }
160
- }
161
- }
162
- }
163
-
164
- return okPacket;
165
- }
166
132
  }
167
133
 
168
134
  module.exports = Command;