@nocobase/plugin-multi-app-manager 1.2.13-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,278 +0,0 @@
1
- 'use strict';
2
-
3
- const CommonBinary = require('./common-binary-cmd');
4
- const Errors = require('../misc/errors');
5
- const Parse = require('../misc/parse');
6
- const BulkPacket = require('../io/bulk-packet');
7
-
8
- /**
9
- * Protocol COM_STMT_BULK_EXECUTE
10
- * see : https://mariadb.com/kb/en/library/com_stmt_bulk_execute/
11
- */
12
- class BatchBulk extends CommonBinary {
13
- constructor(resolve, reject, options, connOpts, sql, values) {
14
- super(resolve, reject, options, connOpts, sql, values);
15
- this.onPacketReceive = this.readPrepareResultPacket;
16
- }
17
-
18
- /**
19
- * Send COM_STMT_BULK_EXECUTE
20
- *
21
- * @param out output writer
22
- * @param opts connection options
23
- * @param info connection information
24
- */
25
- start(out, opts, info) {
26
- this.sending = true;
27
- this.info = info;
28
- this.values = this.initialValues;
29
-
30
- if (this.opts.timeout) {
31
- const err = Errors.createError(
32
- 'Cannot use timeout for Batch statement',
33
- this.sql,
34
- false,
35
- info,
36
- 'HY000',
37
- Errors.ER_TIMEOUT_NOT_SUPPORTED
38
- );
39
- this.emit('send_end');
40
- this.throwError(err, info);
41
- return;
42
- }
43
-
44
- let questionMarkSql = this.sql;
45
- if (this.opts.namedPlaceholders) {
46
- const res = Parse.searchPlaceholder(
47
- this.sql,
48
- info,
49
- this.initialValues,
50
- this.displaySql.bind(this)
51
- );
52
- questionMarkSql = res.sql;
53
- this.values = res.values;
54
- }
55
-
56
- if (!this.validateParameters(info)) {
57
- this.sending = false;
58
- return;
59
- }
60
-
61
- //send COM_STMT_PREPARE command
62
- this.out = out;
63
- this.packet = new BulkPacket(this.opts, out, this.values[0]);
64
-
65
- out.startPacket(this);
66
- out.writeInt8(0x16);
67
- out.writeString(questionMarkSql);
68
- out.flushBuffer(true);
69
-
70
- if (this.opts.pipelining) {
71
- out.startPacket(this);
72
- this.valueIdx = 0;
73
- this.sendQueries();
74
- } else {
75
- this.out = out;
76
- }
77
- }
78
-
79
- sendQueries() {
80
- let flushed = false;
81
- while (!flushed && this.sending && this.valueIdx < this.values.length) {
82
- this.valueRow = this.values[this.valueIdx++];
83
-
84
- //********************************************
85
- // send params
86
- //********************************************
87
- const len = this.valueRow.length;
88
- for (let i = 0; i < len; i++) {
89
- const value = this.valueRow[i];
90
- if (value === null) {
91
- flushed = this.packet.writeInt8(0x01) || flushed;
92
- continue;
93
- }
94
-
95
- //********************************************
96
- // param has no stream. directly write in buffer
97
- //********************************************
98
- flushed = this.writeParam(this.packet, value, this.opts, this.info) || flushed;
99
- }
100
- const last = this.valueIdx === this.values.length;
101
- flushed = this.packet.mark(last, last ? null : this.values[this.valueIdx]) || flushed;
102
- }
103
-
104
- if (this.valueIdx < this.values.length && !this.packet.haveErrorResponse) {
105
- //there is still data to send
106
- setImmediate(this.sendQueries.bind(this));
107
- } else {
108
- if (this.sending && this.valueIdx === this.values.length) this.emit('send_end');
109
- this.sending = false;
110
- }
111
- }
112
-
113
- displaySql() {
114
- if (this.opts && this.initialValues) {
115
- if (this.sql.length > this.opts.debugLen) {
116
- return this.sql.substring(0, this.opts.debugLen) + '...';
117
- }
118
-
119
- let sqlMsg = this.sql + ' - parameters:';
120
- sqlMsg += '[';
121
- for (let i = 0; i < this.initialValues.length; i++) {
122
- if (i !== 0) sqlMsg += ',';
123
- let param = this.initialValues[i];
124
- sqlMsg = this.logParameters(sqlMsg, param);
125
- if (sqlMsg.length > this.opts.debugLen) {
126
- sqlMsg = sqlMsg.substr(0, this.opts.debugLen) + '...';
127
- break;
128
- }
129
- }
130
- sqlMsg += ']';
131
- return sqlMsg;
132
- }
133
- return this.sql + ' - parameters:[]';
134
- }
135
-
136
- success(val) {
137
- this.packet.waitingResponseNo--;
138
-
139
- if (!this.opts.pipelining && this.packet.statementId === -1) {
140
- this.packet.statementId = this.statementId;
141
- this.out.startPacket(this);
142
- this.valueIdx = 0;
143
- this.sendQueries();
144
- this._responseIndex++;
145
- this.onPacketReceive = this.readResponsePacket;
146
- return;
147
- }
148
-
149
- if (!this.sending && this.packet.waitingResponseNo === 0) {
150
- //send COM_STMT_CLOSE packet
151
- if (!this.firstError || !this.firstError.fatal) {
152
- this.sequenceNo = -1;
153
- this.compressSequenceNo = -1;
154
- this.out.startPacket(this);
155
- this.out.writeInt8(0x19);
156
- this.out.writeInt32(this.statementId);
157
- this.out.flushBuffer(true);
158
- }
159
- this.sending = false;
160
- this.emit('send_end');
161
-
162
- if (this.packet.haveErrorResponse) {
163
- this.packet = null;
164
- this.resolve = null;
165
- this.onPacketReceive = null;
166
- this._columns = null;
167
- this._rows = null;
168
- process.nextTick(this.reject, this.firstError);
169
- this.reject = null;
170
- this.emit('end', this.firstError);
171
- } else {
172
- this.packet = null;
173
- let totalAffectedRows = 0;
174
- this._rows.forEach((row) => {
175
- totalAffectedRows += row.affectedRows;
176
- });
177
-
178
- const rs = {
179
- affectedRows: totalAffectedRows,
180
- insertId: this._rows[0].insertId,
181
- warningStatus: this._rows[this._rows.length - 1].warningStatus
182
- };
183
- this.successEnd(rs);
184
- this._columns = null;
185
- this._rows = null;
186
- }
187
- return;
188
- }
189
-
190
- if (!this.packet.haveErrorResponse) {
191
- this._responseIndex++;
192
- this.onPacketReceive = this.readResponsePacket;
193
- }
194
- }
195
-
196
- throwError(err, info) {
197
- this.packet.waitingResponseNo--;
198
- this.sending = false;
199
- if (this.packet && !this.packet.haveErrorResponse) {
200
- if (err.fatal) {
201
- this.packet.waitingResponseNo = 0;
202
- }
203
- if (this.stack) {
204
- err = Errors.createError(
205
- err.message,
206
- this.sql,
207
- err.fatal,
208
- info,
209
- err.sqlState,
210
- err.errno,
211
- this.stack,
212
- false
213
- );
214
- }
215
- this.firstError = err;
216
- this.packet.endedWithError();
217
- }
218
-
219
- if (!this.sending && this.packet.waitingResponseNo === 0) {
220
- this.resolve = null;
221
-
222
- //send COM_STMT_CLOSE packet
223
- if (!err.fatal && this.statementId) {
224
- this.sequenceNo = -1;
225
- this.compressSequenceNo = -1;
226
- this.out.startPacket(this);
227
- this.out.writeInt8(0x19);
228
- this.out.writeInt32(this.statementId);
229
- this.out.flushBuffer(true);
230
- }
231
- this.emit('send_end');
232
- process.nextTick(this.reject, this.firstError);
233
- this.reject = null;
234
- this.onPacketReceive = null;
235
- this.emit('end', this.firstError);
236
- } else {
237
- this._responseIndex++;
238
- this.onPacketReceive = this.readResponsePacket;
239
- }
240
- }
241
-
242
- /**
243
- * Validate that parameters exists and are defined.
244
- *
245
- * @param info connection info
246
- * @returns {boolean} return false if any error occur.
247
- */
248
- validateParameters(info) {
249
- //validate parameter size.
250
- for (let r = 0; r < this.values.length; r++) {
251
- if (!Array.isArray(this.values[r])) this.values[r] = [this.values[r]];
252
-
253
- //validate parameter is defined.
254
- for (let i = 0; i < this.values[r].length; i++) {
255
- if (this.values[r][i] === undefined) {
256
- this.emit('send_end');
257
- this.throwNewError(
258
- 'Parameter at position ' +
259
- (i + 1) +
260
- ' is undefined for values ' +
261
- r +
262
- '\n' +
263
- this.displaySql(),
264
- false,
265
- info,
266
- 'HY000',
267
- Errors.ER_PARAMETER_UNDEFINED
268
- );
269
- return false;
270
- }
271
- }
272
- }
273
-
274
- return true;
275
- }
276
- }
277
-
278
- module.exports = BatchBulk;
@@ -1,372 +0,0 @@
1
- 'use strict';
2
-
3
- const CommonText = require('./common-text-cmd');
4
- const Errors = require('../misc/errors');
5
- const Parse = require('../misc/parse');
6
- const RewritePacket = require('../io/rewrite-packet');
7
- const QUOTE = 0x27;
8
-
9
- /**
10
- * Protocol COM_QUERY
11
- * see : https://mariadb.com/kb/en/library/com_query/
12
- */
13
- class BatchRewrite extends CommonText {
14
- constructor(resolve, reject, options, connOpts, sql, values) {
15
- super(resolve, reject, options, connOpts, sql, values);
16
- }
17
-
18
- /**
19
- * Send COM_QUERY
20
- *
21
- * @param out output writer
22
- * @param opts connection options
23
- * @param info connection information
24
- */
25
- start(out, opts, info) {
26
- this.sending = true;
27
- this.info = info;
28
- if (this.opts.timeout) {
29
- const err = Errors.createError(
30
- 'Cannot use timeout for Batch statement',
31
- this.sql,
32
- false,
33
- info,
34
- 'HY000',
35
- Errors.ER_TIMEOUT_NOT_SUPPORTED
36
- );
37
- this.emit('send_end');
38
- this.throwError(err, info);
39
- return;
40
- }
41
-
42
- if (this.initialValues.length === 0) this.initialValues = [[]];
43
- if (this.opts.namedPlaceholders) {
44
- this.parseResults = Parse.splitRewritableNamedParameterQuery(this.sql, this.initialValues);
45
- this.values = this.parseResults.values;
46
- } else {
47
- this.parseResults = Parse.splitRewritableQuery(this.sql);
48
- this.values = this.initialValues;
49
- if (!this.validateParameters(info)) {
50
- this.sending = false;
51
- return;
52
- }
53
- }
54
-
55
- out.startPacket(this);
56
- this.packet = new RewritePacket(
57
- this.opts.maxAllowedPacket,
58
- out,
59
- this.parseResults.partList[0],
60
- this.parseResults.partList[this.parseResults.partList.length - 1]
61
- );
62
-
63
- this.onPacketReceive = this.readResponsePacket;
64
- this.valueIdx = 0;
65
- this.sendQueries();
66
- }
67
-
68
- sendQueries() {
69
- let flushed = false;
70
- while (!flushed && this.sending && this.valueIdx < this.values.length) {
71
- this.valueRow = this.values[this.valueIdx++];
72
-
73
- //********************************************
74
- // send params
75
- //********************************************
76
- const len = this.parseResults.partList.length - 3;
77
- for (let i = 0; i < len; i++) {
78
- const value = this.valueRow[i];
79
- flushed = this.packet.writeString(this.parseResults.partList[i + 1]) || flushed;
80
- if (value === null) {
81
- flushed = this.packet.writeStringAscii('NULL') || flushed;
82
- continue;
83
- }
84
-
85
- if (
86
- typeof value === 'object' &&
87
- typeof value.pipe === 'function' &&
88
- typeof value.read === 'function'
89
- ) {
90
- //********************************************
91
- // param is stream,
92
- // now all params will be written by event
93
- //********************************************
94
- this.registerStreamSendEvent(this.packet, this.info);
95
- this.currentParam = i;
96
- this.packet.writeInt8(QUOTE); //'
97
-
98
- value.on(
99
- 'data',
100
- function (chunk) {
101
- this.packet.writeBufferEscape(chunk);
102
- }.bind(this)
103
- );
104
-
105
- value.on(
106
- 'end',
107
- function () {
108
- this.packet.writeInt8(QUOTE); //'
109
- this.currentParam++;
110
- this.paramWritten();
111
- }.bind(this)
112
- );
113
-
114
- return;
115
- } else {
116
- //********************************************
117
- // param isn't stream. directly write in buffer
118
- //********************************************
119
- flushed = this.writeParam(this.packet, value, this.opts, this.info) || flushed;
120
- }
121
- }
122
- this.packet.writeString(this.parseResults.partList[this.parseResults.partList.length - 2]);
123
- this.packet.mark(!this.parseResults.reWritable || this.valueIdx === this.values.length);
124
- }
125
-
126
- if (this.valueIdx < this.values.length && !this.packet.haveErrorResponse) {
127
- //there is still data to send
128
- setImmediate(this.sendQueries.bind(this));
129
- } else {
130
- if (this.sending && this.valueIdx === this.values.length) this.emit('send_end');
131
- this.sending = false;
132
- }
133
- }
134
-
135
- displaySql() {
136
- if (this.opts && this.initialValues) {
137
- if (this.sql.length > this.opts.debugLen) {
138
- return 'sql: ' + this.sql.substring(0, this.opts.debugLen) + '...';
139
- }
140
-
141
- let sqlMsg = 'sql: ' + this.sql + ' - parameters:';
142
- sqlMsg += '[';
143
- for (let i = 0; i < this.initialValues.length; i++) {
144
- if (i !== 0) sqlMsg += ',';
145
- let param = this.initialValues[i];
146
- sqlMsg = this.logParameters(sqlMsg, param);
147
- if (sqlMsg.length > this.opts.debugLen) {
148
- sqlMsg = sqlMsg.substr(0, this.opts.debugLen) + '...';
149
- break;
150
- }
151
- }
152
- sqlMsg += ']';
153
- return sqlMsg;
154
- }
155
- return 'sql: ' + this.sql + ' - parameters:[]';
156
- }
157
-
158
- success(val) {
159
- this.packet.waitingResponseNo--;
160
-
161
- if (this.packet.haveErrorResponse) {
162
- if (!this.sending && this.packet.waitingResponseNo === 0) {
163
- this.packet = null;
164
- this.onPacketReceive = null;
165
- this.resolve = null;
166
- this._columns = null;
167
- this._rows = null;
168
- process.nextTick(this.reject, this.firstError);
169
- this.reject = null;
170
- this.emit('end', this.firstError);
171
- }
172
- } else {
173
- if (!this.sending && this.packet.waitingResponseNo === 0) {
174
- if (this.parseResults.reWritable) {
175
- this.packet = null;
176
- let totalAffectedRows = 0;
177
- this._rows.forEach((row) => {
178
- totalAffectedRows += row.affectedRows;
179
- });
180
-
181
- const rs = {
182
- affectedRows: totalAffectedRows,
183
- insertId: this._rows[0].insertId,
184
- warningStatus: this._rows[this._rows.length - 1].warningStatus
185
- };
186
- this.successEnd(rs);
187
- return;
188
- } else {
189
- this.successEnd(this._rows);
190
- }
191
- this._columns = null;
192
- this._rows = null;
193
- return;
194
- }
195
- this._responseIndex++;
196
- this.onPacketReceive = this.readResponsePacket;
197
- }
198
- }
199
-
200
- throwError(err, info) {
201
- this.packet.waitingResponseNo--;
202
- this.sending = false;
203
-
204
- if (this.packet && !this.packet.haveErrorResponse) {
205
- if (err.fatal) {
206
- this.packet.waitingResponseNo = 0;
207
- }
208
- if (this.stack) {
209
- err = Errors.createError(
210
- err.message,
211
- this.sql,
212
- err.fatal,
213
- info,
214
- err.sqlState,
215
- err.errno,
216
- this.stack,
217
- false
218
- );
219
- }
220
- this.firstError = err;
221
- this.packet.endedWithError();
222
- }
223
-
224
- if (!this.sending && this.packet.waitingResponseNo === 0) {
225
- this.packet = null;
226
- this.onPacketReceive = null;
227
- this.resolve = null;
228
- process.nextTick(this.reject, this.firstError);
229
- this.reject = null;
230
- this.emit('end', this.firstError);
231
- } else {
232
- this._responseIndex++;
233
- this.onPacketReceive = this.readResponsePacket;
234
- }
235
- }
236
-
237
- /**
238
- * Validate that parameters exists and are defined.
239
- *
240
- * @param info connection info
241
- * @returns {boolean} return false if any error occur.
242
- */
243
- validateParameters(info) {
244
- //validate parameter size.
245
- for (let r = 0; r < this.values.length; r++) {
246
- let val = this.values[r];
247
- if (!Array.isArray(val)) {
248
- val = [val];
249
- this.values[r] = val;
250
- }
251
-
252
- if (this.parseResults.partList.length - 3 > val.length) {
253
- this.emit('send_end');
254
- this.throwNewError(
255
- 'Parameter at position ' +
256
- val.length +
257
- ' is not set for values ' +
258
- r +
259
- '\n' +
260
- this.displaySql(),
261
- false,
262
- info,
263
- 'HY000',
264
- Errors.ER_MISSING_PARAMETER
265
- );
266
- return false;
267
- }
268
-
269
- //validate parameter is defined.
270
- for (let i = 0; i < this.parseResults.partList.length - 3; i++) {
271
- if (val[i] === undefined) {
272
- this.emit('send_end');
273
- this.throwNewError(
274
- 'Parameter at position ' +
275
- (i + 1) +
276
- ' is undefined for values ' +
277
- r +
278
- '\n' +
279
- this.displaySql(),
280
- false,
281
- info,
282
- 'HY000',
283
- Errors.ER_PARAMETER_UNDEFINED
284
- );
285
- return false;
286
- }
287
- }
288
- }
289
-
290
- return true;
291
- }
292
-
293
- /**
294
- * Define params events.
295
- * Each parameter indicate that he is written to socket,
296
- * emitting event so next parameter can be written.
297
- */
298
- registerStreamSendEvent(packet, info) {
299
- this.paramWritten = function () {
300
- let flushed = false;
301
- while (!flushed) {
302
- if (this.packet.haveErrorResponse) {
303
- this.sending = false;
304
- this.emit('send_end');
305
- return;
306
- }
307
- if (this.currentParam === this.valueRow.length) {
308
- // all parameters from row are written.
309
- flushed =
310
- packet.writeString(this.parseResults.partList[this.parseResults.partList.length - 2]) ||
311
- flushed;
312
- flushed =
313
- packet.mark(!this.parseResults.reWritable || this.valueIdx === this.values.length) ||
314
- flushed;
315
- if (this.valueIdx < this.values.length) {
316
- // still remaining rows
317
- this.valueRow = this.values[this.valueIdx++];
318
- this.currentParam = 0;
319
- } else {
320
- // all rows are written
321
- this.sending = false;
322
- this.emit('send_end');
323
- return;
324
- }
325
- }
326
-
327
- flushed = packet.writeString(this.parseResults.partList[this.currentParam + 1]) || flushed;
328
- const value = this.valueRow[this.currentParam];
329
-
330
- if (value === null) {
331
- flushed = packet.writeStringAscii('NULL') || flushed;
332
- this.currentParam++;
333
- continue;
334
- }
335
-
336
- if (
337
- typeof value === 'object' &&
338
- typeof value.pipe === 'function' &&
339
- typeof value.read === 'function'
340
- ) {
341
- //********************************************
342
- // param is stream,
343
- //********************************************
344
- flushed = packet.writeInt8(QUOTE) || flushed;
345
- value.once(
346
- 'end',
347
- function () {
348
- packet.writeInt8(QUOTE);
349
- this.currentParam++;
350
- this.paramWritten();
351
- }.bind(this)
352
- );
353
-
354
- value.on('data', function (chunk) {
355
- packet.writeBufferEscape(chunk);
356
- });
357
- return;
358
- }
359
-
360
- //********************************************
361
- // param isn't stream. directly write in buffer
362
- //********************************************
363
- flushed = this.writeParam(packet, value, this.opts, info) || flushed;
364
- this.currentParam++;
365
- }
366
-
367
- if (this.sending) setImmediate(this.paramWritten.bind(this));
368
- }.bind(this);
369
- }
370
- }
371
-
372
- module.exports = BatchRewrite;