@nocobase/plugin-multi-app-manager 1.2.12-alpha → 1.3.0-alpha.20240710084543

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 (175) hide show
  1. package/package.json +2 -2
  2. package/dist/client/AppManager.d.ts +0 -10
  3. package/dist/client/AppNameInput.d.ts +0 -10
  4. package/dist/client/MultiAppManagerProvider.d.ts +0 -10
  5. package/dist/client/MultiAppManagerProvider.style.d.ts +0 -13
  6. package/dist/client/Settings.d.ts +0 -10
  7. package/dist/client/index.d.ts +0 -14
  8. package/dist/client/index.js +0 -10
  9. package/dist/client/settings/schemas/applications.d.ts +0 -18
  10. package/dist/client/utils.d.ts +0 -12
  11. package/dist/externalVersion.js +0 -25
  12. package/dist/index.d.ts +0 -10
  13. package/dist/index.js +0 -48
  14. package/dist/locale/en-US.json +0 -11
  15. package/dist/locale/es-ES.json +0 -9
  16. package/dist/locale/index.d.ts +0 -9
  17. package/dist/locale/index.js +0 -36
  18. package/dist/locale/ko_KR.json +0 -11
  19. package/dist/locale/pt-BR.json +0 -9
  20. package/dist/locale/zh-CN.json +0 -14
  21. package/dist/node_modules/mariadb/LICENSE +0 -502
  22. package/dist/node_modules/mariadb/callback.js +0 -41
  23. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  24. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  25. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  26. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  27. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  28. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  29. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  30. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  31. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  32. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  33. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  34. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  35. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  36. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  37. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  38. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  43. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  44. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  45. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  46. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  47. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  48. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  49. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  50. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  51. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  52. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  53. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  54. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  55. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  56. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  57. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  58. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  59. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  60. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  61. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  62. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  63. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  64. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  65. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  66. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  67. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  68. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  69. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  70. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  71. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  72. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  73. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  74. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  75. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  76. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  77. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  78. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  79. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
  80. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  81. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  82. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  83. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  84. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  85. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  86. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  87. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  88. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  89. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  90. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  91. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  92. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  93. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  94. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  95. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  96. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  97. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  98. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  99. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  100. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  101. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  102. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  103. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  104. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  105. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  106. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  107. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  108. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  109. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  110. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  111. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  112. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  113. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  114. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  115. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  116. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  117. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  118. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  119. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  120. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  121. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  122. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  123. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  124. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  125. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  126. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  127. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  128. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  129. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  130. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  131. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  132. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  133. package/dist/node_modules/mariadb/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  134. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
  135. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
  136. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
  137. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
  138. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/modules.xml +0 -8
  139. package/dist/node_modules/mariadb/node_modules/iconv-lite/.idea/vcs.xml +0 -6
  140. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -597
  141. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/dbcs-data.js +0 -188
  142. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/index.js +0 -23
  143. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/internal.js +0 -198
  144. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  145. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  146. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/sbcs-data.js +0 -179
  147. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  148. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  149. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  150. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  151. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  152. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  153. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
  154. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  155. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf16.js +0 -197
  156. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf32.js +0 -319
  157. package/dist/node_modules/mariadb/node_modules/iconv-lite/encodings/utf7.js +0 -290
  158. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  159. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.d.ts +0 -41
  160. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/index.js +0 -180
  161. package/dist/node_modules/mariadb/node_modules/iconv-lite/lib/streams.js +0 -109
  162. package/dist/node_modules/mariadb/node_modules/iconv-lite/package.json +0 -44
  163. package/dist/node_modules/mariadb/package.json +0 -1
  164. package/dist/node_modules/mariadb/promise.js +0 -34
  165. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
  166. package/dist/server/collections/applications.d.ts +0 -10
  167. package/dist/server/collections/applications.js +0 -75
  168. package/dist/server/index.d.ts +0 -11
  169. package/dist/server/index.js +0 -40
  170. package/dist/server/models/application.d.ts +0 -18
  171. package/dist/server/models/application.js +0 -50
  172. package/dist/server/server.d.ts +0 -26
  173. package/dist/server/server.js +0 -310
  174. package/dist/swagger/index.d.ts +0 -195
  175. package/dist/swagger/index.js +0 -226
@@ -1,515 +0,0 @@
1
- 'use strict';
2
-
3
- const Errors = require('../misc/errors');
4
- const Iconv = require('iconv-lite');
5
- const Long = require('long');
6
- const moment = require('moment-timezone');
7
-
8
- /**
9
- * Object to easily parse buffer.
10
- *
11
- */
12
- class Packet {
13
- constructor(buf, pos, end) {
14
- this.buf = buf;
15
- this.pos = pos;
16
- this.end = end;
17
- }
18
-
19
- skip(n) {
20
- this.pos += n;
21
- }
22
-
23
- readGeometry(dataTypeName) {
24
- const geoBuf = this.readBufferLengthEncoded();
25
- if (geoBuf === null || geoBuf.length === 0) {
26
- if (dataTypeName) {
27
- switch (dataTypeName) {
28
- case 'point':
29
- return { type: 'Point' };
30
- case 'linestring':
31
- return { type: 'LineString' };
32
- case 'polygon':
33
- return { type: 'Polygon' };
34
- case 'multipoint':
35
- return { type: 'MultiPoint' };
36
- case 'multilinestring':
37
- return { type: 'MultiLineString' };
38
- case 'multipolygon':
39
- return { type: 'MultiPolygon' };
40
- default:
41
- return { type: dataTypeName };
42
- }
43
- }
44
- return null;
45
- }
46
- let geoPos = 4;
47
- return readGeometryObject(false);
48
-
49
- function parseCoordinates(byteOrder) {
50
- geoPos += 16;
51
- const x = byteOrder ? geoBuf.readDoubleLE(geoPos - 16) : geoBuf.readDoubleBE(geoPos - 16);
52
- const y = byteOrder ? geoBuf.readDoubleLE(geoPos - 8) : geoBuf.readDoubleBE(geoPos - 8);
53
- return [x, y];
54
- }
55
-
56
- function readGeometryObject(inner) {
57
- const byteOrder = geoBuf[geoPos++];
58
- const wkbType = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
59
- geoPos += 4;
60
- switch (wkbType) {
61
- case 1: //wkbPoint
62
- const coords = parseCoordinates(byteOrder);
63
-
64
- if (inner) return coords;
65
- return {
66
- type: 'Point',
67
- coordinates: coords
68
- };
69
-
70
- case 2: //wkbLineString
71
- const pointNumber = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
72
- geoPos += 4;
73
- let coordinates = [];
74
- for (let i = 0; i < pointNumber; i++) {
75
- coordinates.push(parseCoordinates(byteOrder));
76
- }
77
- if (inner) return coordinates;
78
- return {
79
- type: 'LineString',
80
- coordinates: coordinates
81
- };
82
-
83
- case 3: //wkbPolygon
84
- let polygonCoordinates = [];
85
- const numRings = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
86
- geoPos += 4;
87
- for (let ring = 0; ring < numRings; ring++) {
88
- const pointNumber = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
89
- geoPos += 4;
90
- let linesCoordinates = [];
91
- for (let i = 0; i < pointNumber; i++) {
92
- linesCoordinates.push(parseCoordinates(byteOrder));
93
- }
94
- polygonCoordinates.push(linesCoordinates);
95
- }
96
-
97
- if (inner) return polygonCoordinates;
98
- return {
99
- type: 'Polygon',
100
- coordinates: polygonCoordinates
101
- };
102
-
103
- case 4: //wkbMultiPoint
104
- return {
105
- type: 'MultiPoint',
106
- coordinates: parseGeomArray(byteOrder, true)
107
- };
108
-
109
- case 5: //wkbMultiLineString
110
- return {
111
- type: 'MultiLineString',
112
- coordinates: parseGeomArray(byteOrder, true)
113
- };
114
- case 6: //wkbMultiPolygon
115
- return {
116
- type: 'MultiPolygon',
117
- coordinates: parseGeomArray(byteOrder, true)
118
- };
119
- case 7: //wkbGeometryCollection
120
- return {
121
- type: 'GeometryCollection',
122
- geometries: parseGeomArray(byteOrder, false)
123
- };
124
- }
125
- return null;
126
- }
127
-
128
- function parseGeomArray(byteOrder, inner) {
129
- let coordinates = [];
130
- const number = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
131
- geoPos += 4;
132
- for (let i = 0; i < number; i++) {
133
- coordinates.push(readGeometryObject(inner));
134
- }
135
- return coordinates;
136
- }
137
- }
138
-
139
- peek() {
140
- return this.buf[this.pos];
141
- }
142
-
143
- remaining() {
144
- return this.end - this.pos > 0;
145
- }
146
-
147
- readUInt8() {
148
- return this.buf[this.pos++];
149
- }
150
-
151
- readUInt16() {
152
- return this.buf[this.pos++] + (this.buf[this.pos++] << 8);
153
- }
154
-
155
- readUInt24() {
156
- return this.buf[this.pos++] + (this.buf[this.pos++] << 8) + (this.buf[this.pos++] << 16);
157
- }
158
-
159
- readUInt32() {
160
- return (
161
- this.buf[this.pos++] +
162
- (this.buf[this.pos++] << 8) +
163
- (this.buf[this.pos++] << 16) +
164
- this.buf[this.pos++] * 0x1000000
165
- );
166
- }
167
-
168
- readInt32() {
169
- return (
170
- this.buf[this.pos++] +
171
- (this.buf[this.pos++] << 8) +
172
- (this.buf[this.pos++] << 16) +
173
- (this.buf[this.pos++] << 24)
174
- );
175
- }
176
-
177
- readInt32LE() {
178
- return (
179
- (this.buf[this.pos++] << 24) +
180
- (this.buf[this.pos++] << 16) +
181
- (this.buf[this.pos++] << 8) +
182
- this.buf[this.pos++]
183
- );
184
- }
185
-
186
- readInt64() {
187
- // could use readBigInt64LE when support would be 10.20+
188
- const val =
189
- this.buf[this.pos + 4] +
190
- this.buf[this.pos + 5] * 2 ** 8 +
191
- this.buf[this.pos + 6] * 2 ** 16 +
192
- (this.buf[this.pos + 7] << 24);
193
- const vv =
194
- (BigInt(val) << BigInt(32)) +
195
- BigInt(
196
- this.buf[this.pos] +
197
- this.buf[this.pos + 1] * 2 ** 8 +
198
- this.buf[this.pos + 2] * 2 ** 16 +
199
- this.buf[this.pos + 3] * 2 ** 24
200
- );
201
- this.pos += 8;
202
- return vv;
203
- }
204
-
205
- readUnsignedLength() {
206
- const type = this.buf[this.pos++] & 0xff;
207
- switch (type) {
208
- case 0xfb:
209
- return null;
210
- case 0xfc:
211
- return this.readUInt16();
212
- case 0xfd:
213
- return this.readUInt24();
214
- case 0xfe:
215
- // limitation to BigInt signed value
216
- return Number(this.readInt64());
217
- default:
218
- return type;
219
- }
220
- }
221
-
222
- readBuffer(len) {
223
- this.pos += len;
224
- return this.buf.slice(this.pos - len, this.pos);
225
- }
226
-
227
- readBufferRemaining() {
228
- let b = this.buf.slice(this.pos, this.end);
229
- this.pos = this.end;
230
- return b;
231
- }
232
-
233
- readBufferLengthEncoded() {
234
- const len = this.readUnsignedLength();
235
- if (len === null) return null;
236
- this.pos += len;
237
- return this.buf.slice(this.pos - len, this.pos);
238
- }
239
-
240
- readStringNullEnded() {
241
- let initialPosition = this.pos;
242
- let cnt = 0;
243
- while (this.remaining() > 0 && this.buf[this.pos++] !== 0) {
244
- cnt++;
245
- }
246
- return this.buf.toString('utf8', initialPosition, initialPosition + cnt);
247
- }
248
-
249
- readSignedLength() {
250
- const type = this.buf[this.pos++];
251
- switch (type) {
252
- case 0xfb:
253
- return null;
254
- case 0xfc:
255
- return this.readUInt16();
256
- case 0xfd:
257
- return this.readUInt24();
258
- case 0xfe:
259
- return Number(this.readInt64());
260
- default:
261
- return type;
262
- }
263
- }
264
-
265
- readSignedLengthBigInt() {
266
- const type = this.buf[this.pos++];
267
- switch (type) {
268
- case 0xfb:
269
- return null;
270
- case 0xfc:
271
- return BigInt(this.readUInt16());
272
- case 0xfd:
273
- return BigInt(this.readUInt24());
274
- case 0xfe:
275
- return this.readInt64();
276
- default:
277
- return BigInt(type);
278
- }
279
- }
280
-
281
- readAsciiStringLengthEncoded() {
282
- const len = this.readUnsignedLength();
283
- if (len === null) return null;
284
- this.pos += len;
285
- return this.buf.toString('ascii', this.pos - len, this.pos);
286
- }
287
-
288
- readStringLength() {
289
- throw new Error(
290
- 'code is normally superseded by Node encoder or Iconv depending on charset used'
291
- );
292
- }
293
-
294
- readStringLengthEncoded(encoding) {
295
- const len = this.readUnsignedLength();
296
- if (len === null) return null;
297
-
298
- this.pos += len;
299
- if (Buffer.isEncoding(encoding)) {
300
- return this.buf.toString(encoding, this.pos - len, this.pos);
301
- }
302
- return Iconv.decode(this.buf.slice(this.pos - len, this.pos), encoding);
303
- }
304
-
305
- readLongLengthEncoded(supportBigInt, supportBigNumbers, bigNumberStrings, unsigned) {
306
- const len = this.readUnsignedLength();
307
- if (len === null) return null;
308
-
309
- if (supportBigInt) {
310
- const str = this.buf.toString('ascii', this.pos, this.pos + len);
311
- this.pos += len;
312
- return BigInt(str);
313
- }
314
-
315
- let result = 0;
316
- let negate = false;
317
- let begin = this.pos;
318
-
319
- //minus sign
320
- if (len > 0 && this.buf[begin] === 45) {
321
- negate = true;
322
- begin++;
323
- }
324
- for (; begin < this.pos + len; begin++) {
325
- result = result * 10 + (this.buf[begin] - 48);
326
- }
327
-
328
- let val = negate ? -1 * result : result;
329
- this.pos += len;
330
-
331
- if (!Number.isSafeInteger(val)) {
332
- const str = this.buf.toString('ascii', this.pos - len, this.pos);
333
- if (bigNumberStrings) return str;
334
- if (supportBigNumbers) {
335
- return Long.fromString(str, unsigned, 10);
336
- }
337
- }
338
- return val;
339
- }
340
-
341
- readDecimalLengthEncoded(bigNumberStrings) {
342
- const len = this.readUnsignedLength();
343
- if (len === null) return null;
344
-
345
- this.pos += len;
346
- let str = this.buf.toString('ascii', this.pos - len, this.pos);
347
- return bigNumberStrings ? str : +str;
348
- }
349
-
350
- readDate() {
351
- const len = this.readUnsignedLength();
352
- if (len === null) return null;
353
-
354
- let res = [];
355
- let value = 0;
356
- let initPos = this.pos;
357
- this.pos += len;
358
- while (initPos < this.pos) {
359
- const char = this.buf[initPos++];
360
- if (char === 45) {
361
- //minus separator
362
- res.push(value);
363
- value = 0;
364
- } else {
365
- value = value * 10 + char - 48;
366
- }
367
- }
368
- res.push(value);
369
-
370
- //handle zero-date as null
371
- if (res[0] === 0 && res[1] === 0 && res[2] === 0) return null;
372
-
373
- return new Date(res[0], res[1] - 1, res[2]);
374
- }
375
-
376
- readDateTime(opts) {
377
- const len = this.readUnsignedLength();
378
- if (len === null) return null;
379
- this.pos += len;
380
- const str = this.buf.toString('ascii', this.pos - len, this.pos);
381
- if (str.startsWith('0000-00-00 00:00:00')) return null;
382
-
383
- if (opts.tz) {
384
- return new Date(
385
- moment.tz(str, opts.tz).clone().tz(opts._localTz).format('YYYY-MM-DD HH:mm:ss.SSSSSS')
386
- );
387
- }
388
- return new Date(str);
389
- }
390
-
391
- readIntLengthEncoded() {
392
- const len = this.readUnsignedLength();
393
- if (len === null) return null;
394
-
395
- let result = 0;
396
- let negate = false;
397
- let begin = this.pos;
398
-
399
- if (len > 0 && this.buf[begin] === 45) {
400
- //minus sign
401
- negate = true;
402
- begin++;
403
- }
404
- for (; begin < this.pos + len; begin++) {
405
- result = result * 10 + (this.buf[begin] - 48);
406
- }
407
- this.pos += len;
408
- return negate ? -1 * result : result;
409
- }
410
-
411
- readFloatLengthCoded() {
412
- const len = this.readUnsignedLength();
413
- if (len === null) return null;
414
- this.pos += len;
415
- return +this.buf.toString('ascii', this.pos - len, this.pos);
416
- }
417
-
418
- skipLengthCodedNumber() {
419
- const type = this.buf[this.pos++] & 0xff;
420
- switch (type) {
421
- case 251:
422
- return;
423
- case 252:
424
- this.pos +=
425
- 2 + (0xffff & ((this.buf[this.pos] & 0xff) + ((this.buf[this.pos + 1] & 0xff) << 8)));
426
- return;
427
- case 253:
428
- this.pos +=
429
- 3 +
430
- (0xffffff &
431
- ((this.buf[this.pos] & 0xff) +
432
- ((this.buf[this.pos + 1] & 0xff) << 8) +
433
- ((this.buf[this.pos + 2] & 0xff) << 16)));
434
- return;
435
- case 254:
436
- this.pos +=
437
- 8 +
438
- ((this.buf[this.pos] & 0xff) +
439
- ((this.buf[this.pos + 1] & 0xff) << 8) +
440
- ((this.buf[this.pos + 2] & 0xff) << 16) +
441
- ((this.buf[this.pos + 3] & 0xff) << 24) +
442
- ((this.buf[this.pos + 4] & 0xff) << 32) +
443
- ((this.buf[this.pos + 5] & 0xff) << 40) +
444
- ((this.buf[this.pos + 6] & 0xff) << 48) +
445
- ((this.buf[this.pos + 7] & 0xff) << 56));
446
- return;
447
- default:
448
- this.pos += type;
449
- return;
450
- }
451
- }
452
-
453
- positionFromEnd(num) {
454
- this.pos = this.end - num;
455
- }
456
-
457
- /**
458
- * For testing purpose only
459
- */
460
- _toBuf() {
461
- return this.buf.slice(this.pos, this.end);
462
- }
463
-
464
- forceOffset(off) {
465
- this.pos = off;
466
- }
467
-
468
- length() {
469
- return this.end - this.pos;
470
- }
471
-
472
- subPacketLengthEncoded() {
473
- const len = this.readUnsignedLength();
474
- this.skip(len);
475
- return new Packet(this.buf, this.pos - len, this.pos);
476
- }
477
-
478
- /**
479
- * Parse ERR_Packet : https://mariadb.com/kb/en/library/err_packet/
480
- *
481
- * @param info current connection info
482
- * @param sql command sql
483
- * @param stack additional stack trace
484
- * @returns {Error}
485
- */
486
- readError(info, sql, stack) {
487
- this.skip(1);
488
- let errorCode = this.readUInt16();
489
- let sqlState = '';
490
-
491
- if (this.peek() === 0x23) {
492
- this.skip(6);
493
- sqlState = this.buf.toString('utf8', this.pos - 5, this.pos);
494
- }
495
-
496
- let msg = this.buf.toString('utf8', this.pos, this.end);
497
- let fatal = sqlState.startsWith('08') || sqlState === '70100';
498
- if (fatal) {
499
- const packetMsgs = info.getLastPackets();
500
- if (packetMsgs !== '')
501
- return Errors.createError(
502
- msg + '\nlast received packets:\n' + packetMsgs,
503
- sql,
504
- fatal,
505
- info,
506
- sqlState,
507
- errorCode,
508
- stack
509
- );
510
- }
511
- return Errors.createError(msg, sql, fatal, info, sqlState, errorCode, stack);
512
- }
513
- }
514
-
515
- module.exports = Packet;