@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,28 +0,0 @@
1
- 'use strict';
2
-
3
- const Command = require('./command');
4
-
5
- /**
6
- * Quit (close connection)
7
- * see https://mariadb.com/kb/en/library/com_quit/
8
- */
9
- class Quit extends Command {
10
- constructor(resolve, reject) {
11
- super(resolve, reject);
12
- }
13
-
14
- start(out, opts, info) {
15
- out.startPacket(this);
16
- out.writeInt8(0x01);
17
- out.flushBuffer(true);
18
- this.emit('send_end');
19
- this.successEnd();
20
- this.onPacketReceive = this.skipResults;
21
- }
22
-
23
- skipResults(packet, out, opts, info) {
24
- //deliberately empty, if server send answer
25
- }
26
- }
27
-
28
- module.exports = Quit;
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- const Command = require('./command');
4
- const Errors = require('../misc/errors');
5
-
6
- /**
7
- * send a COM_RESET_CONNECTION: permits to reset a connection without re-authentication.
8
- * see https://mariadb.com/kb/en/library/com_reset_connection/
9
- */
10
- class Reset extends Command {
11
- constructor(resolve, reject) {
12
- super(resolve, reject);
13
- }
14
-
15
- start(out, opts, info) {
16
- out.startPacket(this);
17
- out.writeInt8(0x1f);
18
- out.flushBuffer(true);
19
- this.emit('send_end');
20
- this.onPacketReceive = this.readResetResponsePacket;
21
- }
22
-
23
- /**
24
- * Read response packet.
25
- * packet can be :
26
- * - an ERR_Packet
27
- * - a OK_Packet
28
- *
29
- * @param packet query response
30
- * @param out output writer
31
- * @param opts connection options
32
- * @param info connection info
33
- */
34
- readResetResponsePacket(packet, out, opts, info) {
35
- if (packet.peek() !== 0x00) {
36
- return this.throwNewError(
37
- 'unexpected packet',
38
- false,
39
- info,
40
- '42000',
41
- Errors.ER_RESET_BAD_PACKET
42
- );
43
- }
44
-
45
- packet.skip(1); //skip header
46
- packet.skipLengthCodedNumber(); //affected rows
47
- packet.skipLengthCodedNumber(); //insert ids
48
-
49
- info.status = packet.readUInt16();
50
- this.successEnd(null);
51
- }
52
- }
53
-
54
- module.exports = Reset;
@@ -1,607 +0,0 @@
1
- 'use strict';
2
-
3
- const Command = require('./command');
4
- const ServerStatus = require('../const/server-status');
5
- const ColumnDefinition = require('./column-definition');
6
- const Errors = require('../misc/errors');
7
- const fs = require('fs');
8
- const Parse = require('../misc/parse');
9
-
10
- /**
11
- * handle COM_QUERY / COM_STMT_EXECUTE results
12
- * see : https://mariadb.com/kb/en/library/4-server-response-packets/
13
- */
14
- class ResultSet extends Command {
15
- constructor(resolve, reject) {
16
- super(resolve, reject);
17
- this._responseIndex = 0;
18
- this._rows = [];
19
- }
20
-
21
- /**
22
- * Read Query response packet.
23
- * packet can be :
24
- * - a result-set
25
- * - an ERR_Packet
26
- * - a OK_Packet
27
- * - LOCAL_INFILE Packet
28
- *
29
- * @param packet query response
30
- * @param out output writer
31
- * @param opts connection options
32
- * @param info connection info
33
- */
34
- readResponsePacket(packet, out, opts, info) {
35
- switch (packet.peek()) {
36
- //*********************************************************************************************************
37
- //* OK response
38
- //*********************************************************************************************************
39
- case 0x00:
40
- return this.readOKPacket(packet, out, opts, info);
41
-
42
- //*********************************************************************************************************
43
- //* ERROR response
44
- //*********************************************************************************************************
45
- case 0xff:
46
- const err = packet.readError(info, this.displaySql(), this.stack);
47
- //force in transaction status, since query will have created a transaction if autocommit is off
48
- //goal is to avoid unnecessary COMMIT/ROLLBACK.
49
- info.status |= ServerStatus.STATUS_IN_TRANS;
50
- return this.throwError(err, info);
51
-
52
- //*********************************************************************************************************
53
- //* LOCAL INFILE response
54
- //*********************************************************************************************************
55
- case 0xfb:
56
- return this.readLocalInfile(packet, out, opts, info);
57
-
58
- //*********************************************************************************************************
59
- //* ResultSet
60
- //*********************************************************************************************************
61
- default:
62
- return this.readResultSet(packet);
63
- }
64
- }
65
-
66
- /**
67
- * Read result-set packets :
68
- * see https://mariadb.com/kb/en/library/resultset/
69
- *
70
- * @param packet Column count packet
71
- * @returns {ResultSet.readColumn} next packet handler
72
- */
73
- readResultSet(packet) {
74
- this._columnCount = packet.readUnsignedLength();
75
- this._getValue = this.opts.typeCast ? this.readCastValue : this.readRowData;
76
- this._rows.push([]);
77
- this._columns = [];
78
-
79
- this.onPacketReceive = this.readColumn;
80
- }
81
-
82
- /**
83
- * Assign global configuration option used by result-set to current query option.
84
- * a little faster than Object.assign() since doest copy all information
85
- *
86
- * @param connOpts connection global configuration
87
- * @param cmdOpts specific command options
88
- */
89
- configAssign(connOpts, cmdOpts) {
90
- if (!cmdOpts) {
91
- this.opts = connOpts;
92
- return;
93
- }
94
- this.opts = {
95
- timeout: cmdOpts.timeout,
96
- autoJsonMap: connOpts.autoJsonMap,
97
- arrayParenthesis: connOpts.arrayParenthesis,
98
- supportBigInt:
99
- cmdOpts.supportBigInt != undefined ? cmdOpts.supportBigInt : connOpts.supportBigInt,
100
- checkDuplicate:
101
- cmdOpts.checkDuplicate != undefined ? cmdOpts.checkDuplicate : connOpts.checkDuplicate,
102
- typeCast: cmdOpts.typeCast != undefined ? cmdOpts.typeCast : connOpts.typeCast,
103
- rowsAsArray: cmdOpts.rowsAsArray != undefined ? cmdOpts.rowsAsArray : connOpts.rowsAsArray,
104
- nestTables: cmdOpts.nestTables != undefined ? cmdOpts.nestTables : connOpts.nestTables,
105
- dateStrings: cmdOpts.dateStrings != undefined ? cmdOpts.dateStrings : connOpts.dateStrings,
106
- tz: cmdOpts.tz != undefined ? cmdOpts.tz : connOpts.tz,
107
- pipelining: connOpts.pipelining,
108
- _localTz: cmdOpts.localTz != undefined ? cmdOpts.localTz : connOpts._localTz,
109
- namedPlaceholders:
110
- cmdOpts.namedPlaceholders != undefined
111
- ? cmdOpts.namedPlaceholders
112
- : connOpts.namedPlaceholders,
113
- maxAllowedPacket:
114
- cmdOpts.maxAllowedPacket != undefined
115
- ? cmdOpts.maxAllowedPacket
116
- : connOpts.maxAllowedPacket,
117
- supportBigNumbers:
118
- cmdOpts.supportBigNumbers != undefined
119
- ? cmdOpts.supportBigNumbers
120
- : connOpts.supportBigNumbers,
121
- permitSetMultiParamEntries:
122
- cmdOpts.permitSetMultiParamEntries != undefined
123
- ? cmdOpts.permitSetMultiParamEntries
124
- : connOpts.permitSetMultiParamEntries,
125
- bigNumberStrings:
126
- cmdOpts.bigNumberStrings != undefined ? cmdOpts.bigNumberStrings : connOpts.bigNumberStrings
127
- };
128
- }
129
-
130
- /**
131
- * Read OK_Packet.
132
- * see https://mariadb.com/kb/en/library/ok_packet/
133
- *
134
- * @param packet OK_Packet
135
- * @param opts connection options
136
- * @param info connection information
137
- * @param out output writer
138
- * @returns {*} null or {Resultset.readResponsePacket} in case of multi-result-set
139
- */
140
- readOKPacket(packet, out, opts, info) {
141
- const okPacket = this.parseOkPacket(packet, out, opts, info);
142
- this._rows.push(okPacket);
143
-
144
- if (info.status & ServerStatus.MORE_RESULTS_EXISTS) {
145
- this._responseIndex++;
146
- return (this.onPacketReceive = this.readResponsePacket);
147
- }
148
- this.success(this._responseIndex === 0 ? this._rows[0] : this._rows);
149
- }
150
-
151
- /**
152
- * Read COM_STMT_PREPARE response Packet.
153
- * see https://mariadb.com/kb/en/library/com_stmt_prepare/#com_stmt_prepare-response
154
- *
155
- * @param packet COM_STMT_PREPARE_OK packet
156
- * @param opts connection options
157
- * @param info connection information
158
- * @param out output writer
159
- * @returns {*} null or {Resultset.readResponsePacket} in case of multi-result-set
160
- */
161
- readPrepareResultPacket(packet, out, opts, info) {
162
- switch (packet.peek()) {
163
- //*********************************************************************************************************
164
- //* OK response
165
- //*********************************************************************************************************
166
- case 0x00:
167
- packet.skip(1); //skip header
168
- this.statementId = packet.readInt32();
169
- this.columnNo = packet.readUInt16();
170
- this.parameterNo = packet.readUInt16();
171
-
172
- if (this.columnNo > 0) return (this.onPacketReceive = this.skipColumnsPacket);
173
- if (this.parameterNo > 0) return (this.onPacketReceive = this.skipParameterPacket);
174
- return this.success();
175
-
176
- //*********************************************************************************************************
177
- //* ERROR response
178
- //*********************************************************************************************************
179
- case 0xff:
180
- const err = packet.readError(info, this.displaySql(), this.stack);
181
- //force in transaction status, since query will have created a transaction if autocommit is off
182
- //goal is to avoid unnecessary COMMIT/ROLLBACK.
183
- info.status |= ServerStatus.STATUS_IN_TRANS;
184
- this.onPacketReceive = this.readResponsePacket;
185
- return this.throwError(err, info);
186
-
187
- //*********************************************************************************************************
188
- //* Unexpected response
189
- //*********************************************************************************************************
190
- default:
191
- info.status |= ServerStatus.STATUS_IN_TRANS;
192
- this.onPacketReceive = this.readResponsePacket;
193
- return this.throwError(Errors.ER_UNEXPECTED_PACKET, info);
194
- }
195
- }
196
-
197
- skipColumnsPacket(packet, out, opts, info) {
198
- this.columnNo--;
199
- if (this.columnNo === 0) {
200
- if (info.eofDeprecated) {
201
- if (this.parameterNo > 0) return (this.onPacketReceive = this.skipParameterPacket);
202
- this.success();
203
- }
204
- return (this.onPacketReceive = this.skipEofPacket);
205
- }
206
- }
207
-
208
- skipEofPacket(packet, out, opts, info) {
209
- if (this.parameterNo > 0) return (this.onPacketReceive = this.skipParameterPacket);
210
- this.success();
211
- }
212
-
213
- skipParameterPacket(packet, out, opts, info) {
214
- this.parameterNo--;
215
- if (this.parameterNo === 0) {
216
- if (info.eofDeprecated) return this.success();
217
- return (this.onPacketReceive = this.skipEofPacket);
218
- }
219
- }
220
-
221
- success(val) {
222
- this.successEnd(val);
223
- this._columns = null;
224
- this._rows = null;
225
- }
226
-
227
- /**
228
- * Read column information metadata
229
- * see https://mariadb.com/kb/en/library/resultset/#column-definition-packet
230
- *
231
- * @param packet column definition packet
232
- * @param out output writer
233
- * @param opts connection options
234
- * @param info connection information
235
- * @returns {*}
236
- */
237
- readColumn(packet, out, opts, info) {
238
- if (this._columns.length !== this._columnCount) {
239
- this._columns.push(new ColumnDefinition(packet, info));
240
- }
241
-
242
- // last column
243
- if (this._columns.length === this._columnCount) {
244
- if (this.opts.rowsAsArray) {
245
- this.parseRow = this.parseRowAsArray;
246
- } else {
247
- this.tableHeader = new Array(this._columnCount);
248
- if (this.opts.nestTables) {
249
- this.parseRow = this.parseRowStd;
250
- if (typeof this.opts.nestTables === 'string') {
251
- for (let i = 0; i < this._columnCount; i++) {
252
- this.tableHeader[i] =
253
- this._columns[i].table() + this.opts.nestTables + this._columns[i].name();
254
- }
255
- this.checkDuplicates();
256
- } else if (this.opts.nestTables === true) {
257
- this.parseRow = this.parseRowNested;
258
- for (let i = 0; i < this._columnCount; i++) {
259
- this.tableHeader[i] = [this._columns[i].table(), this._columns[i].name()];
260
- }
261
- this.checkNestTablesDuplicates();
262
- }
263
- } else {
264
- this.parseRow = this.parseRowStd;
265
- for (let i = 0; i < this._columnCount; i++) {
266
- this.tableHeader[i] = this._columns[i].name();
267
- }
268
- this.checkDuplicates();
269
- }
270
- }
271
-
272
- this.emit('fields', this._columns);
273
-
274
- return (this.onPacketReceive = info.eofDeprecated
275
- ? this.readResultSetRow
276
- : this.readIntermediateEOF);
277
- }
278
- }
279
-
280
- checkDuplicates() {
281
- if (this.opts.checkDuplicate) {
282
- for (let i = 0; i < this._columnCount; i++) {
283
- if (this.tableHeader.indexOf(this.tableHeader[i], i + 1) > 0) {
284
- const dupes = this.tableHeader.reduce(
285
- (acc, v, i, arr) =>
286
- arr.indexOf(v) !== i && acc.indexOf(v) === -1 ? acc.concat(v) : acc,
287
- []
288
- );
289
- this.throwUnexpectedError(
290
- 'Error in results, duplicate field name `' +
291
- dupes[0] +
292
- '`.\n' +
293
- '(see option `checkDuplicate`)',
294
- false,
295
- null,
296
- '42000',
297
- Errors.ER_DUPLICATE_FIELD
298
- );
299
- }
300
- }
301
- }
302
- }
303
-
304
- checkNestTablesDuplicates() {
305
- if (this.opts.checkDuplicate) {
306
- for (let i = 0; i < this._columnCount; i++) {
307
- for (let j = 0; j < i; j++) {
308
- if (
309
- this.tableHeader[j][0] === this.tableHeader[i][0] &&
310
- this.tableHeader[j][1] === this.tableHeader[i][1]
311
- ) {
312
- this.throwUnexpectedError(
313
- 'Error in results, duplicate field name `' +
314
- this.tableHeader[i][0] +
315
- '`.`' +
316
- this.tableHeader[i][1] +
317
- '`\n' +
318
- '(see option `checkDuplicate`)',
319
- false,
320
- null,
321
- '42000',
322
- Errors.ER_DUPLICATE_FIELD
323
- );
324
- }
325
- }
326
- }
327
- }
328
- }
329
-
330
- /**
331
- * Read intermediate EOF.
332
- * _only for server before MariaDB 10.2 / MySQL 5.7 that doesn't have CLIENT_DEPRECATE_EOF capability_
333
- * see https://mariadb.com/kb/en/library/eof_packet/
334
- *
335
- * @param packet EOF Packet
336
- * @param out output writer
337
- * @param opts connection options
338
- * @param info connection information
339
- * @returns {*}
340
- */
341
- readIntermediateEOF(packet, out, opts, info) {
342
- if (packet.peek() !== 0xfe) {
343
- return this.throwNewError(
344
- 'Error in protocol, expected EOF packet',
345
- true,
346
- info,
347
- '42000',
348
- Errors.ER_EOF_EXPECTED
349
- );
350
- }
351
-
352
- //before MySQL 5.7.5, last EOF doesn't contain the good flag SERVER_MORE_RESULTS_EXISTS
353
- //for OUT parameters. It must be checked here
354
- //(5.7.5 does have the CLIENT_DEPRECATE_EOF capability, so this packet in not even send)
355
- packet.skip(3);
356
- info.status = packet.readUInt16();
357
- this.isOutParameter = info.status & ServerStatus.PS_OUT_PARAMS;
358
-
359
- this.onPacketReceive = this.readResultSetRow;
360
- }
361
-
362
- handleNewRows(row) {
363
- this._rows[this._responseIndex].push(row);
364
- }
365
-
366
- /**
367
- * Check if packet is result-set end = EOF of OK_Packet with EOF header according to CLIENT_DEPRECATE_EOF capability
368
- * or a result-set row
369
- *
370
- * @param packet current packet
371
- * @param out output writer
372
- * @param opts connection options
373
- * @param info connection information
374
- * @returns {*}
375
- */
376
- readResultSetRow(packet, out, opts, info) {
377
- if (packet.peek() >= 0xfe) {
378
- if (packet.peek() === 0xff) {
379
- const err = packet.readError(info, this.displaySql(), this.stack);
380
- //force in transaction status, since query will have created a transaction if autocommit is off
381
- //goal is to avoid unnecessary COMMIT/ROLLBACK.
382
- info.status |= ServerStatus.STATUS_IN_TRANS;
383
- return this.throwError(err, info);
384
- }
385
-
386
- if (
387
- (!info.eofDeprecated && packet.length() < 13) ||
388
- (info.eofDeprecated && packet.length() < 0xffffff)
389
- ) {
390
- if (!info.eofDeprecated) {
391
- packet.skip(3);
392
- info.status = packet.readUInt16();
393
- } else {
394
- packet.skip(1); //skip header
395
- packet.skipLengthCodedNumber(); //skip update count
396
- packet.skipLengthCodedNumber(); //skip insert id
397
- info.status = packet.readUInt16();
398
- }
399
-
400
- if (opts.metaAsArray) {
401
- //return promise object as array :
402
- // example for SELECT 1 =>
403
- // [
404
- // [ {"1": 1} ], //rows
405
- // [ColumnDefinition] //meta
406
- // ]
407
- if (!this._meta) {
408
- this._meta = new Array(this._responseIndex);
409
- }
410
-
411
- this._meta[this._responseIndex] = this._columns;
412
-
413
- if (info.status & ServerStatus.MORE_RESULTS_EXISTS || this.isOutParameter) {
414
- this._responseIndex++;
415
- return (this.onPacketReceive = this.readResponsePacket);
416
- }
417
- this.success(
418
- this._responseIndex === 0 ? [this._rows[0], this._meta[0]] : [this._rows, this._meta]
419
- );
420
- } else {
421
- //return promise object as rows that have meta property :
422
- // example for SELECT 1 =>
423
- // [
424
- // {"1": 1},
425
- // meta: [ColumnDefinition]
426
- // ]
427
- this._rows[this._responseIndex].meta = this._columns;
428
- if (info.status & ServerStatus.MORE_RESULTS_EXISTS || this.isOutParameter) {
429
- this._responseIndex++;
430
- return (this.onPacketReceive = this.readResponsePacket);
431
- }
432
- this.success(this._responseIndex === 0 ? this._rows[0] : this._rows);
433
- }
434
-
435
- return;
436
- }
437
- }
438
-
439
- const row = this.parseRow(this._columns, packet, opts);
440
- this.handleNewRows(row);
441
- }
442
-
443
- /**
444
- * Display current SQL with parameters (truncated if too big)
445
- *
446
- * @returns {string}
447
- */
448
- displaySql() {
449
- if (this.opts && this.initialValues) {
450
- if (this.sql.length > this.opts.debugLen) {
451
- return this.sql.substring(0, this.opts.debugLen) + '...';
452
- }
453
-
454
- let sqlMsg = this.sql + ' - parameters:';
455
- return this.logParameters(sqlMsg, this.initialValues);
456
- }
457
- return this.sql + ' - parameters:[]';
458
- }
459
-
460
- logParameters(sqlMsg, values) {
461
- if (this.opts.namedPlaceholders) {
462
- sqlMsg += '{';
463
- let first = true;
464
- for (let key in values) {
465
- if (first) {
466
- first = false;
467
- } else {
468
- sqlMsg += ',';
469
- }
470
- sqlMsg += "'" + key + "':";
471
- let param = values[key];
472
- sqlMsg = ResultSet.logParam(sqlMsg, param);
473
- if (sqlMsg.length > this.opts.debugLen) {
474
- sqlMsg = sqlMsg.substr(0, this.opts.debugLen) + '...';
475
- break;
476
- }
477
- }
478
- sqlMsg += '}';
479
- } else {
480
- sqlMsg += '[';
481
- if (Array.isArray(values)) {
482
- for (let i = 0; i < values.length; i++) {
483
- if (i !== 0) sqlMsg += ',';
484
- let param = values[i];
485
- sqlMsg = ResultSet.logParam(sqlMsg, param);
486
- if (sqlMsg.length > this.opts.debugLen) {
487
- sqlMsg = sqlMsg.substr(0, this.opts.debugLen) + '...';
488
- break;
489
- }
490
- }
491
- } else {
492
- sqlMsg = ResultSet.logParam(sqlMsg, values);
493
- if (sqlMsg.length > this.opts.debugLen) {
494
- sqlMsg = sqlMsg.substr(0, this.opts.debugLen) + '...';
495
- }
496
- }
497
- sqlMsg += ']';
498
- }
499
- return sqlMsg;
500
- }
501
-
502
- readLocalInfile(packet, out, opts, info) {
503
- packet.skip(1); //skip header
504
- out.startPacket(this);
505
-
506
- const fileName = packet.readStringRemaining();
507
-
508
- if (!Parse.validateFileName(this.sql, this.initialValues, fileName)) {
509
- out.writeEmptyPacket();
510
- const error = Errors.createError(
511
- "LOCAL INFILE wrong filename. '" +
512
- fileName +
513
- "' doesn't correspond to query " +
514
- this.sql +
515
- '. Query cancelled. Check for malicious server / proxy',
516
- this.sql,
517
- false,
518
- info,
519
- 'HY000',
520
- Errors.ER_LOCAL_INFILE_WRONG_FILENAME
521
- );
522
-
523
- process.nextTick(this.reject, error);
524
- this.reject = null;
525
- this.resolve = null;
526
- return (this.onPacketReceive = this.readResponsePacket);
527
- }
528
-
529
- // this.sequenceNo = 2;
530
- // this.compressSequenceNo = 2;
531
- const stream = fs.createReadStream(fileName);
532
- stream.on('error', (err) => {
533
- out.writeEmptyPacket();
534
- const error = Errors.createError(
535
- 'LOCAL INFILE command failed: ' + err.message,
536
- this.sql,
537
- false,
538
- info,
539
- '22000',
540
- Errors.ER_LOCAL_INFILE_NOT_READABLE
541
- );
542
- process.nextTick(this.reject, error);
543
- this.reject = null;
544
- this.resolve = null;
545
- });
546
- stream.on('data', (chunk) => {
547
- out.writeBuffer(chunk, 0, chunk.length);
548
- });
549
- stream.on('end', () => {
550
- if (!out.isEmpty()) {
551
- out.flushBuffer(false);
552
- }
553
- out.writeEmptyPacket();
554
- });
555
- this.onPacketReceive = this.readResponsePacket;
556
- }
557
-
558
- static logParam(sqlMsg, param) {
559
- if (param === undefined || param === null) {
560
- sqlMsg += param === undefined ? 'undefined' : 'null';
561
- } else {
562
- switch (param.constructor.name) {
563
- case 'Buffer':
564
- sqlMsg += '0x' + param.toString('hex', 0, Math.min(1024, param.length)) + '';
565
- break;
566
-
567
- case 'String':
568
- sqlMsg += "'" + param + "'";
569
- break;
570
-
571
- case 'Date':
572
- sqlMsg += getStringDate(param);
573
- break;
574
-
575
- case 'Object':
576
- sqlMsg += JSON.stringify(param);
577
- break;
578
-
579
- default:
580
- sqlMsg += param.toString();
581
- }
582
- }
583
- return sqlMsg;
584
- }
585
- }
586
-
587
- function getStringDate(param) {
588
- return (
589
- "'" +
590
- ('00' + (param.getMonth() + 1)).slice(-2) +
591
- '/' +
592
- ('00' + param.getDate()).slice(-2) +
593
- '/' +
594
- param.getFullYear() +
595
- ' ' +
596
- ('00' + param.getHours()).slice(-2) +
597
- ':' +
598
- ('00' + param.getMinutes()).slice(-2) +
599
- ':' +
600
- ('00' + param.getSeconds()).slice(-2) +
601
- '.' +
602
- ('000' + param.getMilliseconds()).slice(-3) +
603
- "'"
604
- );
605
- }
606
-
607
- module.exports = ResultSet;