@nocobase/plugin-multi-app-manager 2.0.0-alpha.7 → 2.0.0-alpha.71

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 (161) hide show
  1. package/dist/client/00b71fff3c8c7167.js +10 -0
  2. package/dist/client/Migrate.d.ts +10 -0
  3. package/dist/client/index.d.ts +1 -0
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/settings/schemas/applications.d.ts +63 -1
  6. package/dist/externalVersion.js +8 -7
  7. package/dist/locale/de-DE.json +19 -7
  8. package/dist/locale/en-US.json +21 -7
  9. package/dist/locale/es-ES.json +23 -6
  10. package/dist/locale/fr-FR.json +26 -0
  11. package/dist/locale/hu-HU.json +26 -0
  12. package/dist/locale/id-ID.json +26 -0
  13. package/dist/locale/it-IT.json +19 -7
  14. package/dist/locale/ja-JP.json +18 -6
  15. package/dist/locale/ko-KR.json +22 -7
  16. package/dist/locale/nl-NL.json +24 -9
  17. package/dist/locale/pt-BR.json +23 -6
  18. package/dist/locale/ru-RU.json +26 -0
  19. package/dist/locale/tr-TR.json +26 -0
  20. package/dist/locale/uk-UA.json +26 -0
  21. package/dist/locale/vi-VN.json +26 -0
  22. package/dist/locale/zh-CN.json +17 -15
  23. package/dist/locale/zh-TW.json +26 -0
  24. package/dist/node_modules/p-queue/dist/index.d.ts +101 -0
  25. package/dist/node_modules/p-queue/dist/index.js +1 -0
  26. package/dist/node_modules/p-queue/dist/lower-bound.d.ts +1 -0
  27. package/dist/node_modules/p-queue/dist/lower-bound.js +21 -0
  28. package/dist/node_modules/p-queue/dist/options.d.ts +64 -0
  29. package/dist/node_modules/p-queue/dist/options.js +2 -0
  30. package/dist/node_modules/p-queue/dist/priority-queue.d.ts +12 -0
  31. package/dist/node_modules/p-queue/dist/priority-queue.js +32 -0
  32. package/dist/node_modules/p-queue/dist/queue.d.ts +7 -0
  33. package/dist/node_modules/p-queue/dist/queue.js +2 -0
  34. package/dist/node_modules/p-queue/license +9 -0
  35. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.d.ts +134 -0
  36. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
  37. package/dist/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
  38. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.js +340 -0
  39. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.min.js +1 -0
  40. package/dist/node_modules/p-queue/package.json +1 -0
  41. package/dist/server/adapters/legacy-adapter.d.ts +43 -0
  42. package/dist/server/adapters/legacy-adapter.js +207 -0
  43. package/dist/server/server.d.ts +7 -6
  44. package/dist/server/server.js +110 -186
  45. package/package.json +5 -2
  46. package/dist/client/bd12299af6cdc73a.js +0 -10
  47. package/dist/node_modules/mariadb/LICENSE +0 -502
  48. package/dist/node_modules/mariadb/callback.js +0 -41
  49. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  50. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  51. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  52. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  53. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  54. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  55. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  56. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  57. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  58. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  59. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  60. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  61. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  62. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  63. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  64. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  65. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  66. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  67. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  68. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  69. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  70. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  71. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  72. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  73. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  74. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  75. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  76. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  77. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  78. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  79. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  80. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  81. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  82. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  83. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  84. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  85. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  86. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  87. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  88. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  89. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  90. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  91. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  92. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  93. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  94. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  95. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  96. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  97. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  98. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  99. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  100. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  101. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  102. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  103. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  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
  106. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  107. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  108. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  109. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  110. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  111. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  112. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  113. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  114. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  115. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  116. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  117. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  118. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  119. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  120. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  121. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  122. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  123. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  124. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  125. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  126. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  127. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  128. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  129. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  130. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  131. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  132. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  133. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  134. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  135. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  136. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  137. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  138. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  139. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  140. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  141. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  142. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  143. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  144. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  145. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  146. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  147. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  148. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  149. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  150. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  151. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  152. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  153. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  154. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  155. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  156. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  157. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  158. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  159. package/dist/node_modules/mariadb/package.json +0 -1
  160. package/dist/node_modules/mariadb/promise.js +0 -34
  161. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
@@ -1,141 +0,0 @@
1
- 'use strict';
2
-
3
- const ZLib = require('zlib');
4
- const Utils = require('../misc/utils');
5
-
6
- /**
7
- * MySQL packet parser
8
- * see : https://mariadb.com/kb/en/library/0-packet/
9
- */
10
- class CompressionInputStream {
11
- constructor(reader, receiveQueue, opts, info) {
12
- this.reader = reader;
13
- this.receiveQueue = receiveQueue;
14
- this.info = info;
15
- this.opts = opts;
16
- this.header = Buffer.allocUnsafe(7);
17
- this.headerLen = 0;
18
- this.compressPacketLen = null;
19
- this.packetLen = null;
20
- this.remainingLen = null;
21
-
22
- this.parts = null;
23
- this.partsTotalLen = 0;
24
- }
25
-
26
- receivePacket(chunk) {
27
- let cmd = this.currentCmd();
28
- 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)
38
- );
39
- }
40
- if (cmd) cmd.compressSequenceNo = this.header[3];
41
- const unCompressLen = this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
42
- if (unCompressLen === 0) {
43
- this.reader.onData(chunk);
44
- } else {
45
- //use synchronous inflating, to ensure FIFO packet order
46
- const unCompressChunk = ZLib.inflateSync(chunk);
47
- this.reader.onData(unCompressChunk);
48
- }
49
- }
50
-
51
- currentCmd() {
52
- let cmd;
53
- while ((cmd = this.receiveQueue.peek())) {
54
- if (cmd.onPacketReceive) return cmd;
55
- this.receiveQueue.shift();
56
- }
57
- return null;
58
- }
59
-
60
- resetHeader() {
61
- this.remainingLen = null;
62
- this.headerLen = 0;
63
- }
64
-
65
- onData(chunk) {
66
- let pos = 0;
67
- let length;
68
- const chunkLen = chunk.length;
69
-
70
- do {
71
- if (this.remainingLen) {
72
- length = this.remainingLen;
73
- } else if (this.headerLen === 0 && chunkLen - pos >= 7) {
74
- this.header[0] = chunk[pos];
75
- this.header[1] = chunk[pos + 1];
76
- this.header[2] = chunk[pos + 2];
77
- this.header[3] = chunk[pos + 3];
78
- this.header[4] = chunk[pos + 4];
79
- this.header[5] = chunk[pos + 5];
80
- this.header[6] = chunk[pos + 6];
81
- this.headerLen = 7;
82
- pos += 7;
83
- this.compressPacketLen = this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
84
- this.packetLen = this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
85
- if (this.packetLen === 0) this.packetLen = this.compressPacketLen;
86
- length = this.compressPacketLen;
87
- } else {
88
- length = null;
89
- while (chunkLen - pos > 0) {
90
- this.header[this.headerLen++] = chunk[pos++];
91
- if (this.headerLen === 7) {
92
- this.compressPacketLen =
93
- this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
94
- this.packetLen = this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
95
- if (this.packetLen === 0) this.packetLen = this.compressPacketLen;
96
- length = this.compressPacketLen;
97
- break;
98
- }
99
- }
100
- }
101
-
102
- if (length) {
103
- if (chunkLen - pos >= length) {
104
- const buf = chunk.slice(pos, pos + length);
105
- pos += length;
106
- if (this.parts) {
107
- this.parts.push(buf);
108
- this.partsTotalLen += length;
109
-
110
- if (this.compressPacketLen < 0xffffff) {
111
- let buf = Buffer.concat(this.parts, this.partsTotalLen);
112
- this.parts = null;
113
- this.receivePacket(buf);
114
- }
115
- } else {
116
- if (this.compressPacketLen < 0xffffff) {
117
- this.receivePacket(buf);
118
- } else {
119
- this.parts = [buf];
120
- this.partsTotalLen = length;
121
- }
122
- }
123
- this.resetHeader();
124
- } else {
125
- const buf = chunk.slice(pos, chunkLen);
126
- if (!this.parts) {
127
- this.parts = [buf];
128
- this.partsTotalLen = chunkLen - pos;
129
- } else {
130
- this.parts.push(buf);
131
- this.partsTotalLen += chunkLen - pos;
132
- }
133
- this.remainingLen = length - (chunkLen - pos);
134
- return;
135
- }
136
- }
137
- } while (pos < chunkLen);
138
- }
139
- }
140
-
141
- module.exports = CompressionInputStream;
@@ -1,171 +0,0 @@
1
- 'use strict';
2
-
3
- const Utils = require('../misc/utils');
4
- const ZLib = require('zlib');
5
-
6
- //increase by level to avoid buffer copy.
7
- const SMALL_BUFFER_SIZE = 2048;
8
- const MEDIUM_BUFFER_SIZE = 131072; //128k
9
- const LARGE_BUFFER_SIZE = 1048576; //1M
10
- const MAX_BUFFER_SIZE = 16777222; //16M + 7
11
-
12
- /**
13
- /**
14
- * MySQL compression filter.
15
- * see https://mariadb.com/kb/en/library/0-packet/#compressed-packet
16
- */
17
- class CompressionOutputStream {
18
- /**
19
- * Constructor
20
- *
21
- * @param socket current socket
22
- * @param opts current connection options
23
- * @param info current connection information
24
- * @constructor
25
- */
26
- constructor(socket, opts, info) {
27
- this.info = info;
28
- this.opts = opts;
29
- this.pos = 7;
30
- this.header = Buffer.allocUnsafe(7);
31
- this.buf = Buffer.allocUnsafe(SMALL_BUFFER_SIZE);
32
- this.writer = (buffer) => {
33
- socket.write(buffer);
34
- };
35
- }
36
-
37
- growBuffer(len) {
38
- let newCapacity;
39
- if (len + this.pos < MEDIUM_BUFFER_SIZE) {
40
- newCapacity = MEDIUM_BUFFER_SIZE;
41
- } else if (len + this.pos < LARGE_BUFFER_SIZE) {
42
- newCapacity = LARGE_BUFFER_SIZE;
43
- } else newCapacity = MAX_BUFFER_SIZE;
44
-
45
- let newBuf = Buffer.allocUnsafe(newCapacity);
46
- this.buf.copy(newBuf, 0, 0, this.pos);
47
- this.buf = newBuf;
48
- }
49
-
50
- writeBuf(arr, cmd) {
51
- let off = 0,
52
- len = arr.length;
53
- if (len > this.buf.length - this.pos) {
54
- if (this.buf.length !== MAX_BUFFER_SIZE) {
55
- this.growBuffer(len);
56
- }
57
-
58
- //max buffer size
59
- if (len > this.buf.length - this.pos) {
60
- //not enough space in buffer, will stream :
61
- // fill buffer and flush until all data are snd
62
- let remainingLen = len;
63
-
64
- while (true) {
65
- //filling buffer
66
- let lenToFillBuffer = Math.min(MAX_BUFFER_SIZE - this.pos, remainingLen);
67
- arr.copy(this.buf, this.pos, off, off + lenToFillBuffer);
68
- remainingLen -= lenToFillBuffer;
69
- off += lenToFillBuffer;
70
- this.pos += lenToFillBuffer;
71
-
72
- if (remainingLen === 0) return;
73
- this.flush(false, cmd, remainingLen);
74
- }
75
- }
76
- }
77
- arr.copy(this.buf, this.pos, off, off + len);
78
- this.pos += len;
79
- }
80
-
81
- /**
82
- * Flush the internal buffer.
83
- */
84
- flush(cmdEnd, cmd, remainingLen) {
85
- if (this.pos < 1536) {
86
- //*******************************************************************************
87
- // small packet, no compression
88
- //*******************************************************************************
89
-
90
- this.buf[0] = this.pos - 7;
91
- this.buf[1] = (this.pos - 7) >>> 8;
92
- this.buf[2] = (this.pos - 7) >>> 16;
93
- this.buf[3] = ++cmd.compressSequenceNo;
94
- this.buf[4] = 0;
95
- this.buf[5] = 0;
96
- this.buf[6] = 0;
97
-
98
- 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)
104
- );
105
- }
106
-
107
- this.writer(this.buf.slice(0, this.pos));
108
- } else {
109
- //*******************************************************************************
110
- // compressing packet
111
- //*******************************************************************************
112
- //use synchronous inflating, to ensure FIFO packet order
113
- const compressChunk = ZLib.deflateSync(this.buf.slice(7, this.pos));
114
- const compressChunkLen = compressChunk.length;
115
-
116
- this.header[0] = compressChunkLen;
117
- this.header[1] = compressChunkLen >>> 8;
118
- this.header[2] = compressChunkLen >>> 16;
119
- this.header[3] = ++cmd.compressSequenceNo;
120
- this.header[4] = this.pos - 7;
121
- this.header[5] = (this.pos - 7) >>> 8;
122
- this.header[6] = (this.pos - 7) >>> 16;
123
-
124
- 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
- );
131
- }
132
-
133
- this.writer(this.header);
134
- this.writer(compressChunk);
135
- if (cmdEnd && this.pos === MAX_BUFFER_SIZE) this.writeEmptyPacket(cmd);
136
- this.header = Buffer.allocUnsafe(7);
137
- }
138
- this.buf = remainingLen
139
- ? CompressionOutputStream.allocateBuffer(remainingLen)
140
- : Buffer.allocUnsafe(SMALL_BUFFER_SIZE);
141
- this.pos = 7;
142
- }
143
-
144
- static allocateBuffer(len) {
145
- if (len + 4 < SMALL_BUFFER_SIZE) {
146
- return Buffer.allocUnsafe(SMALL_BUFFER_SIZE);
147
- } else if (len + 4 < MEDIUM_BUFFER_SIZE) {
148
- return Buffer.allocUnsafe(MEDIUM_BUFFER_SIZE);
149
- } else if (len + 4 < LARGE_BUFFER_SIZE) {
150
- return Buffer.allocUnsafe(LARGE_BUFFER_SIZE);
151
- }
152
- return Buffer.allocUnsafe(MAX_BUFFER_SIZE);
153
- }
154
-
155
- writeEmptyPacket(cmd) {
156
- const emptyBuf = Buffer.from([0x00, 0x00, 0x00, cmd.compressSequenceNo, 0x00, 0x00, 0x00]);
157
-
158
- 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)
164
- );
165
- }
166
-
167
- this.writer(emptyBuf);
168
- }
169
- }
170
-
171
- module.exports = CompressionOutputStream;
@@ -1,193 +0,0 @@
1
- 'use strict';
2
-
3
- const PacketNodeEncoded = require('./packet-node-encoded');
4
- const PacketIconvEncoded = require('./packet-node-iconv');
5
-
6
- const Utils = require('../misc/utils');
7
-
8
- /**
9
- * MySQL packet parser
10
- * see : https://mariadb.com/kb/en/library/0-packet/
11
- */
12
- class PacketInputStream {
13
- constructor(unexpectedPacket, receiveQueue, out, opts, info) {
14
- this.unexpectedPacket = unexpectedPacket;
15
- this.opts = opts;
16
- this.receiveQueue = receiveQueue;
17
- this.info = info;
18
- this.out = out;
19
-
20
- //in case packet is not complete
21
- this.header = Buffer.allocUnsafe(4);
22
- this.headerLen = 0;
23
- this.packetLen = null;
24
- this.remainingLen = null;
25
-
26
- this.parts = null;
27
- this.partsTotalLen = 0;
28
- this.changeEncoding(this.opts.collation);
29
- this.changeDebug(this.opts.logPackets, this.opts.debug);
30
- this.opts.on('collation', this.changeEncoding.bind(this));
31
- this.opts.on('debug', this.changeDebug.bind(this));
32
- }
33
-
34
- changeEncoding(collation) {
35
- this.encoding = collation.charset;
36
- this.packetConstructor = Buffer.isEncoding(this.encoding)
37
- ? PacketNodeEncoded
38
- : PacketIconvEncoded;
39
- }
40
-
41
- changeDebug(logPackets, debug) {
42
- this.logPackets = logPackets;
43
- this.debug = debug;
44
- this.receivePacket =
45
- this.logPackets || this.debug ? this.receivePacketDebug : this.receivePacketBasic;
46
- }
47
-
48
- receivePacketDebug(packet) {
49
- let cmd = this.currentCmd();
50
-
51
- if (packet) {
52
- const packetStr = Utils.log(this.opts, packet.buf, packet.pos, packet.end, this.header);
53
- if (this.opts.logPackets) {
54
- this.info.addPacket(
55
- '<== conn:' +
56
- (this.info.threadId ? this.info.threadId : -1) +
57
- ' ' +
58
- (cmd
59
- ? cmd.onPacketReceive
60
- ? cmd.constructor.name + '.' + cmd.onPacketReceive.name
61
- : cmd.constructor.name
62
- : 'no command') +
63
- ' (' +
64
- packet.pos +
65
- ',' +
66
- packet.end +
67
- '))\n' +
68
- packetStr
69
- );
70
- }
71
- if (this.opts.debug) {
72
- console.log(
73
- '<== conn:%d %s (%d,%d)\n%s',
74
- this.info.threadId ? this.info.threadId : -1,
75
- cmd
76
- ? cmd.onPacketReceive
77
- ? cmd.constructor.name + '.' + cmd.onPacketReceive.name
78
- : cmd.constructor.name
79
- : 'no command',
80
- packet.pos,
81
- packet.end,
82
- packetStr
83
- );
84
- }
85
- }
86
-
87
- if (!cmd) {
88
- this.unexpectedPacket(packet);
89
- return;
90
- }
91
-
92
- cmd.sequenceNo = this.header[3];
93
- cmd.onPacketReceive(packet, this.out, this.opts, this.info);
94
- if (!cmd.onPacketReceive) this.receiveQueue.shift();
95
- }
96
-
97
- receivePacketBasic(packet) {
98
- let cmd = this.currentCmd();
99
- if (!cmd) {
100
- this.unexpectedPacket(packet);
101
- return;
102
- }
103
- cmd.sequenceNo = this.header[3];
104
- cmd.onPacketReceive(packet, this.out, this.opts, this.info);
105
- if (!cmd.onPacketReceive) this.receiveQueue.shift();
106
- }
107
-
108
- resetHeader() {
109
- this.remainingLen = null;
110
- this.headerLen = 0;
111
- }
112
-
113
- currentCmd() {
114
- let cmd;
115
- while ((cmd = this.receiveQueue.peek())) {
116
- if (cmd.onPacketReceive) return cmd;
117
- this.receiveQueue.shift();
118
- }
119
- return null;
120
- }
121
-
122
- onData(chunk) {
123
- let pos = 0;
124
- let length;
125
- const chunkLen = chunk.length;
126
-
127
- do {
128
- //read header
129
- if (this.remainingLen) {
130
- length = this.remainingLen;
131
- } else if (this.headerLen === 0 && chunkLen - pos >= 4) {
132
- this.header[0] = chunk[pos];
133
- this.header[1] = chunk[pos + 1];
134
- this.header[2] = chunk[pos + 2];
135
- this.header[3] = chunk[pos + 3];
136
- pos += 4;
137
- this.headerLen = 4;
138
- this.packetLen = this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
139
- length = this.packetLen;
140
- } else {
141
- length = null;
142
- while (chunkLen - pos > 0) {
143
- this.header[this.headerLen++] = chunk[pos++];
144
- if (this.headerLen === 4) {
145
- this.packetLen = this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
146
- length = this.packetLen;
147
- break;
148
- }
149
- }
150
- }
151
-
152
- if (length) {
153
- if (chunkLen - pos >= length) {
154
- const buf = chunk.slice(pos, pos + length);
155
- pos += length;
156
- if (this.parts) {
157
- this.parts.push(buf);
158
- this.partsTotalLen += length;
159
-
160
- if (this.packetLen < 0xffffff) {
161
- let buf = Buffer.concat(this.parts, this.partsTotalLen);
162
- this.parts = null;
163
- const packet = new this.packetConstructor(buf, 0, this.partsTotalLen, this.encoding);
164
- this.receivePacket(packet);
165
- }
166
- } else {
167
- if (this.packetLen < 0xffffff) {
168
- const packet = new this.packetConstructor(buf, 0, length, this.encoding);
169
- this.receivePacket(packet);
170
- } else {
171
- this.parts = [buf];
172
- this.partsTotalLen = length;
173
- }
174
- }
175
- this.resetHeader();
176
- } else {
177
- const buf = chunk.slice(pos, chunkLen);
178
- if (!this.parts) {
179
- this.parts = [buf];
180
- this.partsTotalLen = chunkLen - pos;
181
- } else {
182
- this.parts.push(buf);
183
- this.partsTotalLen += chunkLen - pos;
184
- }
185
- this.remainingLen = length - (chunkLen - pos);
186
- return;
187
- }
188
- }
189
- } while (pos < chunkLen);
190
- }
191
- }
192
-
193
- module.exports = PacketInputStream;
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- const Packet = require('./packet');
4
-
5
- class PacketNodeEncoded extends Packet {
6
- constructor(buf, pos, end, encoding) {
7
- super(buf, pos, end);
8
- this.encoding = encoding;
9
- }
10
-
11
- readStringLength() {
12
- const len = this.readUnsignedLength();
13
- if (len === null) return null;
14
-
15
- this.pos += len;
16
- return this.buf.toString(this.encoding, this.pos - len, this.pos);
17
- }
18
-
19
- readString(beg, len) {
20
- return this.buf.toString(this.encoding, beg, beg + len);
21
- }
22
-
23
- subPacketLengthEncoded() {
24
- const len = this.readUnsignedLength();
25
- this.skip(len);
26
- return new PacketNodeEncoded(this.buf, this.pos - len, this.pos, this.encoding);
27
- }
28
-
29
- readStringRemaining() {
30
- const str = this.buf.toString(this.encoding, this.pos, this.end);
31
- this.pos = this.end;
32
- return str;
33
- }
34
- }
35
-
36
- module.exports = PacketNodeEncoded;
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- const Packet = require('./packet');
4
- const Iconv = require('iconv-lite');
5
-
6
- class PacketIconvEncoded extends Packet {
7
- constructor(buf, pos, end, encoding) {
8
- super(buf, pos, end);
9
- this.encoding = encoding;
10
- }
11
-
12
- readStringLength() {
13
- const len = this.readUnsignedLength();
14
- if (len === null) return null;
15
-
16
- this.pos += len;
17
- return Iconv.decode(this.buf.slice(this.pos - len, this.pos), this.encoding);
18
- }
19
-
20
- readString(beg, len) {
21
- return Iconv.decode(this.buf.slice(beg, beg + len), this.encoding);
22
- }
23
-
24
- subPacketLengthEncoded() {
25
- const len = this.readUnsignedLength();
26
- this.skip(len);
27
- return new PacketIconvEncoded(this.buf, this.pos - len, this.pos, this.encoding);
28
- }
29
-
30
- readStringRemaining() {
31
- const str = Iconv.decode(this.buf.slice(this.pos, this.end), this.encoding);
32
- this.pos = this.end;
33
- return str;
34
- }
35
- }
36
-
37
- module.exports = PacketIconvEncoded;