@nocobase/plugin-multi-app-manager 2.0.0-beta.8 → 2.0.0

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 (143) hide show
  1. package/dist/client/{db3a142b120d6553.js → 00b71fff3c8c7167.js} +1 -1
  2. package/dist/client/Migrate.d.ts +10 -0
  3. package/dist/client/index.js +1 -1
  4. package/dist/externalVersion.js +7 -7
  5. package/dist/locale/en-US.json +3 -2
  6. package/dist/locale/zh-CN.json +3 -2
  7. package/dist/node_modules/p-queue/dist/index.d.ts +101 -0
  8. package/dist/node_modules/p-queue/dist/index.js +1 -0
  9. package/dist/node_modules/p-queue/dist/lower-bound.d.ts +1 -0
  10. package/dist/node_modules/p-queue/dist/lower-bound.js +21 -0
  11. package/dist/node_modules/p-queue/dist/options.d.ts +64 -0
  12. package/dist/node_modules/p-queue/dist/options.js +2 -0
  13. package/dist/node_modules/p-queue/dist/priority-queue.d.ts +12 -0
  14. package/dist/node_modules/p-queue/dist/priority-queue.js +32 -0
  15. package/dist/node_modules/p-queue/dist/queue.d.ts +7 -0
  16. package/dist/node_modules/p-queue/dist/queue.js +2 -0
  17. package/dist/node_modules/p-queue/license +9 -0
  18. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.d.ts +134 -0
  19. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
  20. package/dist/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
  21. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.js +340 -0
  22. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.min.js +1 -0
  23. package/dist/node_modules/p-queue/package.json +1 -0
  24. package/dist/server/adapters/legacy-adapter.d.ts +43 -0
  25. package/dist/server/adapters/legacy-adapter.js +207 -0
  26. package/dist/server/server.d.ts +4 -6
  27. package/dist/server/server.js +38 -191
  28. package/package.json +2 -2
  29. package/dist/node_modules/mariadb/LICENSE +0 -502
  30. package/dist/node_modules/mariadb/callback.js +0 -41
  31. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  32. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  33. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  34. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  35. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  36. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  37. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  38. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  43. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  44. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  45. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  46. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  47. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  48. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  49. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  50. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  51. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  52. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  53. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  54. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  55. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  56. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  57. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  58. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  59. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  60. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  61. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  62. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  63. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  64. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  65. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  66. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  67. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  68. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  69. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  70. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  71. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  72. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  73. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  74. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  75. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  76. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  77. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  78. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  79. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  80. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  81. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  82. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  83. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  84. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  85. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  86. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  87. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
  88. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  89. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  90. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  91. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  92. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  93. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  94. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  95. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  96. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  97. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  98. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  99. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  100. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  101. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  102. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  103. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  104. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  105. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  106. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  107. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  108. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  109. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  110. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  111. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  112. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  113. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  114. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  115. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  116. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  117. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  118. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  119. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  120. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  121. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  122. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  123. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  124. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  125. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  126. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  127. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  128. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  129. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  130. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  131. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  132. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  133. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  134. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  135. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  136. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  137. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  138. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  139. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  140. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  141. package/dist/node_modules/mariadb/package.json +0 -1
  142. package/dist/node_modules/mariadb/promise.js +0 -34
  143. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
@@ -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;