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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/client/{db3a142b120d6553.js → 00b71fff3c8c7167.js} +1 -1
  2. package/dist/client/Migrate.d.ts +10 -0
  3. package/dist/client/index.js +1 -1
  4. package/dist/externalVersion.js +7 -7
  5. package/dist/locale/en-US.json +3 -2
  6. package/dist/locale/zh-CN.json +3 -2
  7. package/dist/node_modules/p-queue/dist/index.d.ts +101 -0
  8. package/dist/node_modules/p-queue/dist/index.js +1 -0
  9. package/dist/node_modules/p-queue/dist/lower-bound.d.ts +1 -0
  10. package/dist/node_modules/p-queue/dist/lower-bound.js +21 -0
  11. package/dist/node_modules/p-queue/dist/options.d.ts +64 -0
  12. package/dist/node_modules/p-queue/dist/options.js +2 -0
  13. package/dist/node_modules/p-queue/dist/priority-queue.d.ts +12 -0
  14. package/dist/node_modules/p-queue/dist/priority-queue.js +32 -0
  15. package/dist/node_modules/p-queue/dist/queue.d.ts +7 -0
  16. package/dist/node_modules/p-queue/dist/queue.js +2 -0
  17. package/dist/node_modules/p-queue/license +9 -0
  18. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.d.ts +134 -0
  19. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
  20. package/dist/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
  21. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.js +340 -0
  22. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.min.js +1 -0
  23. package/dist/node_modules/p-queue/package.json +1 -0
  24. package/dist/server/adapters/legacy-adapter.d.ts +43 -0
  25. package/dist/server/adapters/legacy-adapter.js +207 -0
  26. package/dist/server/server.d.ts +4 -6
  27. package/dist/server/server.js +38 -191
  28. package/package.json +2 -2
  29. package/dist/node_modules/mariadb/LICENSE +0 -502
  30. package/dist/node_modules/mariadb/callback.js +0 -41
  31. package/dist/node_modules/mariadb/lib/cmd/batch-bulk.js +0 -278
  32. package/dist/node_modules/mariadb/lib/cmd/batch-rewrite.js +0 -372
  33. package/dist/node_modules/mariadb/lib/cmd/change-user.js +0 -149
  34. package/dist/node_modules/mariadb/lib/cmd/class/ok-packet.js +0 -17
  35. package/dist/node_modules/mariadb/lib/cmd/column-definition.js +0 -102
  36. package/dist/node_modules/mariadb/lib/cmd/command.js +0 -168
  37. package/dist/node_modules/mariadb/lib/cmd/common-binary-cmd.js +0 -327
  38. package/dist/node_modules/mariadb/lib/cmd/common-text-cmd.js +0 -427
  39. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js +0 -168
  40. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/clear-password-auth.js +0 -23
  41. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/ed25519-password-auth.js +0 -761
  42. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/native-password-auth.js +0 -55
  43. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/pam-password-auth.js +0 -58
  44. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/plugin-auth.js +0 -19
  45. package/dist/node_modules/mariadb/lib/cmd/handshake/auth/sha256-password-auth.js +0 -142
  46. package/dist/node_modules/mariadb/lib/cmd/handshake/client-capabilities.js +0 -74
  47. package/dist/node_modules/mariadb/lib/cmd/handshake/client-handshake-response.js +0 -126
  48. package/dist/node_modules/mariadb/lib/cmd/handshake/handshake.js +0 -292
  49. package/dist/node_modules/mariadb/lib/cmd/handshake/initial-handshake.js +0 -74
  50. package/dist/node_modules/mariadb/lib/cmd/handshake/ssl-request.js +0 -29
  51. package/dist/node_modules/mariadb/lib/cmd/ping.js +0 -52
  52. package/dist/node_modules/mariadb/lib/cmd/query.js +0 -255
  53. package/dist/node_modules/mariadb/lib/cmd/quit.js +0 -28
  54. package/dist/node_modules/mariadb/lib/cmd/reset.js +0 -54
  55. package/dist/node_modules/mariadb/lib/cmd/resultset.js +0 -607
  56. package/dist/node_modules/mariadb/lib/cmd/stream.js +0 -45
  57. package/dist/node_modules/mariadb/lib/config/connection-options.js +0 -258
  58. package/dist/node_modules/mariadb/lib/config/pool-cluster-options.js +0 -19
  59. package/dist/node_modules/mariadb/lib/config/pool-options.js +0 -47
  60. package/dist/node_modules/mariadb/lib/connection-callback.js +0 -160
  61. package/dist/node_modules/mariadb/lib/connection.js +0 -1460
  62. package/dist/node_modules/mariadb/lib/const/capabilities.js +0 -64
  63. package/dist/node_modules/mariadb/lib/const/collations.js +0 -473
  64. package/dist/node_modules/mariadb/lib/const/connection_status.js +0 -13
  65. package/dist/node_modules/mariadb/lib/const/error-code.js +0 -1282
  66. package/dist/node_modules/mariadb/lib/const/field-detail.js +0 -35
  67. package/dist/node_modules/mariadb/lib/const/field-type.js +0 -71
  68. package/dist/node_modules/mariadb/lib/const/server-status.js +0 -30
  69. package/dist/node_modules/mariadb/lib/const/state-change.js +0 -12
  70. package/dist/node_modules/mariadb/lib/filtered-pool-cluster.js +0 -81
  71. package/dist/node_modules/mariadb/lib/io/bulk-packet.js +0 -590
  72. package/dist/node_modules/mariadb/lib/io/compression-input-stream.js +0 -141
  73. package/dist/node_modules/mariadb/lib/io/compression-output-stream.js +0 -171
  74. package/dist/node_modules/mariadb/lib/io/packet-input-stream.js +0 -193
  75. package/dist/node_modules/mariadb/lib/io/packet-node-encoded.js +0 -36
  76. package/dist/node_modules/mariadb/lib/io/packet-node-iconv.js +0 -37
  77. package/dist/node_modules/mariadb/lib/io/packet-output-stream.js +0 -502
  78. package/dist/node_modules/mariadb/lib/io/packet.js +0 -515
  79. package/dist/node_modules/mariadb/lib/io/rewrite-packet.js +0 -481
  80. package/dist/node_modules/mariadb/lib/misc/connection-information.js +0 -96
  81. package/dist/node_modules/mariadb/lib/misc/errors.js +0 -123
  82. package/dist/node_modules/mariadb/lib/misc/parse.js +0 -1033
  83. package/dist/node_modules/mariadb/lib/misc/utils.js +0 -298
  84. package/dist/node_modules/mariadb/lib/pool-base.js +0 -611
  85. package/dist/node_modules/mariadb/lib/pool-callback.js +0 -202
  86. package/dist/node_modules/mariadb/lib/pool-cluster-callback.js +0 -66
  87. package/dist/node_modules/mariadb/lib/pool-cluster.js +0 -407
  88. package/dist/node_modules/mariadb/lib/pool-promise.js +0 -108
  89. package/dist/node_modules/mariadb/node_modules/@types/node/assert/strict.d.ts +0 -8
  90. package/dist/node_modules/mariadb/node_modules/@types/node/assert.d.ts +0 -912
  91. package/dist/node_modules/mariadb/node_modules/@types/node/async_hooks.d.ts +0 -501
  92. package/dist/node_modules/mariadb/node_modules/@types/node/buffer.d.ts +0 -2232
  93. package/dist/node_modules/mariadb/node_modules/@types/node/child_process.d.ts +0 -1366
  94. package/dist/node_modules/mariadb/node_modules/@types/node/cluster.d.ts +0 -414
  95. package/dist/node_modules/mariadb/node_modules/@types/node/console.d.ts +0 -412
  96. package/dist/node_modules/mariadb/node_modules/@types/node/constants.d.ts +0 -18
  97. package/dist/node_modules/mariadb/node_modules/@types/node/crypto.d.ts +0 -3338
  98. package/dist/node_modules/mariadb/node_modules/@types/node/dgram.d.ts +0 -545
  99. package/dist/node_modules/mariadb/node_modules/@types/node/diagnostics_channel.d.ts +0 -152
  100. package/dist/node_modules/mariadb/node_modules/@types/node/dns/promises.d.ts +0 -370
  101. package/dist/node_modules/mariadb/node_modules/@types/node/dns.d.ts +0 -659
  102. package/dist/node_modules/mariadb/node_modules/@types/node/domain.d.ts +0 -169
  103. package/dist/node_modules/mariadb/node_modules/@types/node/events.d.ts +0 -651
  104. package/dist/node_modules/mariadb/node_modules/@types/node/fs/promises.d.ts +0 -1091
  105. package/dist/node_modules/mariadb/node_modules/@types/node/fs.d.ts +0 -3869
  106. package/dist/node_modules/mariadb/node_modules/@types/node/globals.d.ts +0 -294
  107. package/dist/node_modules/mariadb/node_modules/@types/node/globals.global.d.ts +0 -1
  108. package/dist/node_modules/mariadb/node_modules/@types/node/http.d.ts +0 -1396
  109. package/dist/node_modules/mariadb/node_modules/@types/node/http2.d.ts +0 -2101
  110. package/dist/node_modules/mariadb/node_modules/@types/node/https.d.ts +0 -391
  111. package/dist/node_modules/mariadb/node_modules/@types/node/index.d.ts +0 -129
  112. package/dist/node_modules/mariadb/node_modules/@types/node/inspector.d.ts +0 -2744
  113. package/dist/node_modules/mariadb/node_modules/@types/node/module.d.ts +0 -114
  114. package/dist/node_modules/mariadb/node_modules/@types/node/net.d.ts +0 -791
  115. package/dist/node_modules/mariadb/node_modules/@types/node/os.d.ts +0 -455
  116. package/dist/node_modules/mariadb/node_modules/@types/node/package.json +0 -220
  117. package/dist/node_modules/mariadb/node_modules/@types/node/path.d.ts +0 -180
  118. package/dist/node_modules/mariadb/node_modules/@types/node/perf_hooks.d.ts +0 -557
  119. package/dist/node_modules/mariadb/node_modules/@types/node/process.d.ts +0 -1481
  120. package/dist/node_modules/mariadb/node_modules/@types/node/punycode.d.ts +0 -117
  121. package/dist/node_modules/mariadb/node_modules/@types/node/querystring.d.ts +0 -131
  122. package/dist/node_modules/mariadb/node_modules/@types/node/readline.d.ts +0 -650
  123. package/dist/node_modules/mariadb/node_modules/@types/node/repl.d.ts +0 -424
  124. package/dist/node_modules/mariadb/node_modules/@types/node/stream/consumers.d.ts +0 -24
  125. package/dist/node_modules/mariadb/node_modules/@types/node/stream/promises.d.ts +0 -42
  126. package/dist/node_modules/mariadb/node_modules/@types/node/stream/web.d.ts +0 -330
  127. package/dist/node_modules/mariadb/node_modules/@types/node/stream.d.ts +0 -1249
  128. package/dist/node_modules/mariadb/node_modules/@types/node/string_decoder.d.ts +0 -67
  129. package/dist/node_modules/mariadb/node_modules/@types/node/timers/promises.d.ts +0 -68
  130. package/dist/node_modules/mariadb/node_modules/@types/node/timers.d.ts +0 -94
  131. package/dist/node_modules/mariadb/node_modules/@types/node/tls.d.ts +0 -1020
  132. package/dist/node_modules/mariadb/node_modules/@types/node/trace_events.d.ts +0 -161
  133. package/dist/node_modules/mariadb/node_modules/@types/node/tty.d.ts +0 -204
  134. package/dist/node_modules/mariadb/node_modules/@types/node/url.d.ts +0 -891
  135. package/dist/node_modules/mariadb/node_modules/@types/node/util.d.ts +0 -1594
  136. package/dist/node_modules/mariadb/node_modules/@types/node/v8.d.ts +0 -378
  137. package/dist/node_modules/mariadb/node_modules/@types/node/vm.d.ts +0 -507
  138. package/dist/node_modules/mariadb/node_modules/@types/node/wasi.d.ts +0 -158
  139. package/dist/node_modules/mariadb/node_modules/@types/node/worker_threads.d.ts +0 -649
  140. package/dist/node_modules/mariadb/node_modules/@types/node/zlib.d.ts +0 -517
  141. package/dist/node_modules/mariadb/package.json +0 -1
  142. package/dist/node_modules/mariadb/promise.js +0 -34
  143. package/dist/node_modules/mariadb/types/index.d.ts +0 -870
@@ -1,149 +0,0 @@
1
- 'use strict';
2
-
3
- const Iconv = require('iconv-lite');
4
- const Capabilities = require('../const/capabilities');
5
- const Ed25519PasswordAuth = require('./handshake/auth/ed25519-password-auth');
6
- const NativePasswordAuth = require('./handshake/auth/native-password-auth');
7
- const Collations = require('../const/collations');
8
- const Handshake = require('./handshake/handshake');
9
-
10
- /**
11
- * send a COM_CHANGE_USER: resets the connection and re-authenticates with the given credentials
12
- * see https://mariadb.com/kb/en/library/com_change_user/
13
- */
14
- class ChangeUser extends Handshake {
15
- constructor(options, resolve, reject, addCommand) {
16
- super(resolve, reject, () => {}, addCommand);
17
- this.opts = options;
18
- }
19
-
20
- start(out, opts, info) {
21
- this.configAssign(opts, this.opts);
22
- let authToken;
23
- const pwd = Array.isArray(this.opts.password) ? this.opts.password[0] : this.opts.password;
24
- switch (info.defaultPluginName) {
25
- case 'mysql_native_password':
26
- case '':
27
- authToken = NativePasswordAuth.encryptPassword(pwd, info.seed, 'sha1');
28
- break;
29
- case 'client_ed25519':
30
- authToken = Ed25519PasswordAuth.encryptPassword(pwd, info.seed);
31
- break;
32
- default:
33
- authToken = Buffer.alloc(0);
34
- break;
35
- }
36
-
37
- out.startPacket(this);
38
- out.writeInt8(0x11);
39
- out.writeString(this.opts.user || '');
40
- out.writeInt8(0);
41
-
42
- if (info.serverCapabilities & Capabilities.SECURE_CONNECTION) {
43
- out.writeInt8(authToken.length);
44
- out.writeBuffer(authToken, 0, authToken.length);
45
- } else {
46
- out.writeBuffer(authToken, 0, authToken.length);
47
- out.writeInt8(0);
48
- }
49
-
50
- if (info.clientCapabilities & Capabilities.CONNECT_WITH_DB) {
51
- out.writeString(this.opts.database);
52
- out.writeInt8(0);
53
- info.database = this.opts.database;
54
- }
55
-
56
- out.writeInt16(this.opts.collation.index);
57
-
58
- if (info.clientCapabilities & Capabilities.PLUGIN_AUTH) {
59
- out.writeString(info.defaultPluginName);
60
- out.writeInt8(0);
61
- }
62
-
63
- if (info.clientCapabilities & Capabilities.CONNECT_ATTRS) {
64
- out.writeInt8(0xfc);
65
- let initPos = out.pos; //save position, assuming connection attributes length will be less than 2 bytes length
66
- out.writeInt16(0);
67
-
68
- const encoding = this.opts.collation.charset;
69
-
70
- writeParam(out, '_client_name', encoding);
71
- writeParam(out, 'MariaDB connector/Node', encoding);
72
-
73
- let packageJson = require('../../package.json');
74
- writeParam(out, '_client_version', encoding);
75
- writeParam(out, packageJson.version, encoding);
76
-
77
- writeParam(out, '_node_version', encoding);
78
- writeParam(out, process.versions.node, encoding);
79
-
80
- if (opts.connectAttributes !== true) {
81
- let attrNames = Object.keys(this.opts.connectAttributes);
82
- for (let k = 0; k < attrNames.length; ++k) {
83
- writeParam(out, attrNames[k], encoding);
84
- writeParam(out, this.opts.connectAttributes[attrNames[k]], encoding);
85
- }
86
- }
87
-
88
- //write end size
89
- out.writeInt16AtPos(initPos);
90
- }
91
-
92
- out.flushBuffer(true);
93
- this.onPacketReceive = this.handshakeResult;
94
- }
95
-
96
- /**
97
- * Assign global configuration option used by result-set to current query option.
98
- * a little faster than Object.assign() since doest copy all information
99
- *
100
- * @param connOpts connection global configuration
101
- * @param opt current options
102
- */
103
- configAssign(connOpts, opt) {
104
- if (!opt) {
105
- this.opts = connOpts;
106
- return;
107
- }
108
- this.opts.database = opt.database ? opt.database : connOpts.database;
109
- this.opts.connectAttributes = opt.connectAttributes
110
- ? opt.connectAttributes
111
- : connOpts.connectAttributes;
112
-
113
- if (opt.charset && typeof opt.charset === 'string') {
114
- this.opts.collation = Collations.fromCharset(opt.charset.toLowerCase());
115
- if (this.opts.collation === undefined) {
116
- this.opts.collation = Collations.fromName(opt.charset.toUpperCase());
117
- if (this.opts.collation !== undefined) {
118
- console.log(
119
- "warning: please use option 'collation' " +
120
- "in replacement of 'charset' when using a collation name ('" +
121
- opt.charset +
122
- "')\n" +
123
- "(collation looks like 'UTF8MB4_UNICODE_CI', charset like 'utf8')."
124
- );
125
- }
126
- }
127
- if (this.opts.collation === undefined)
128
- throw new RangeError("Unknown charset '" + opt.charset + "'");
129
- } else if (opt.collation && typeof opt.collation === 'string') {
130
- const initial = opt.collation;
131
- this.opts.collation = Collations.fromName(initial.toUpperCase());
132
- if (this.opts.collation === undefined)
133
- throw new RangeError("Unknown collation '" + initial + "'");
134
- } else {
135
- this.opts.collation = Collations.fromIndex(opt.charsetNumber) || connOpts.collation;
136
- }
137
- connOpts.password = opt.password;
138
- }
139
- }
140
-
141
- function writeParam(out, val, encoding) {
142
- let param = Buffer.isEncoding(encoding)
143
- ? Buffer.from(val, encoding)
144
- : Iconv.encode(val, encoding);
145
- out.writeLengthCoded(param.length);
146
- out.writeBuffer(param, 0, param.length);
147
- }
148
-
149
- module.exports = ChangeUser;
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- const Command = require('../command');
4
-
5
- /**
6
- * Ok_Packet
7
- * see https://mariadb.com/kb/en/ok_packet/
8
- */
9
- class OkPacket {
10
- constructor(affectedRows, insertId, warningStatus) {
11
- this.affectedRows = affectedRows;
12
- this.insertId = insertId;
13
- this.warningStatus = warningStatus;
14
- }
15
- }
16
-
17
- module.exports = OkPacket;
@@ -1,102 +0,0 @@
1
- 'use strict';
2
-
3
- const Collations = require('../const/collations.js');
4
- const FieldType = require('../const/field-type');
5
- const Capabilities = require('../const/capabilities');
6
-
7
- /**
8
- * Column definition
9
- * see https://mariadb.com/kb/en/library/resultset/#column-definition-packet
10
- */
11
- class ColumnDef {
12
- constructor(packet, info) {
13
- this._parse = new StringParser(packet);
14
- if (info.serverCapabilities & Capabilities.MARIADB_CLIENT_EXTENDED_TYPE_INFO) {
15
- const subPacket = packet.subPacketLengthEncoded();
16
- while (subPacket.remaining()) {
17
- switch (subPacket.readUInt8()) {
18
- case 0:
19
- this.dataTypeName = subPacket.readAsciiStringLengthEncoded();
20
- break;
21
-
22
- case 1:
23
- this.dataTypeFormat = subPacket.readAsciiStringLengthEncoded();
24
- break;
25
-
26
- default:
27
- // skip data
28
- const len = subPacket.readUnsignedLength();
29
- if (len) {
30
- subPacket.skip(len);
31
- }
32
- break;
33
- }
34
- }
35
- }
36
-
37
- packet.skip(1); // length of fixed fields
38
- this.collation = Collations.fromIndex(packet.readUInt16());
39
- this.columnLength = packet.readUInt32();
40
- this.columnType = packet.readUInt8();
41
- this.flags = packet.readUInt16();
42
- this.scale = packet.readUInt8();
43
- this.type = FieldType.TYPES[this.columnType];
44
- }
45
-
46
- db() {
47
- return this._parse.packet.readString(this._parse.dbOffset, this._parse.dbLength);
48
- }
49
-
50
- schema() {
51
- return this._parse.packet.readString(this._parse.dbOffset, this._parse.dbLength);
52
- }
53
-
54
- table() {
55
- return this._parse.packet.readString(this._parse.tableOffset, this._parse.tableLength);
56
- }
57
-
58
- orgTable() {
59
- return this._parse.packet.readString(this._parse.orgTableOffset, this._parse.orgTableLength);
60
- }
61
-
62
- name() {
63
- return this._parse.packet.readString(this._parse.nameOffset, this._parse.nameLength);
64
- }
65
-
66
- orgName() {
67
- return this._parse.packet.readString(this._parse.orgNameOffset, this._parse.orgNameLength);
68
- }
69
- }
70
-
71
- /**
72
- * String parser.
73
- * This object permits to avoid listing all private information to metadata object.
74
- */
75
- class StringParser {
76
- constructor(packet) {
77
- packet.skip(4); // skip 'def'
78
-
79
- this.dbLength = packet.readUnsignedLength();
80
- this.dbOffset = packet.pos;
81
- packet.skip(this.dbLength);
82
-
83
- this.tableLength = packet.readUnsignedLength();
84
- this.tableOffset = packet.pos;
85
- packet.skip(this.tableLength);
86
-
87
- this.orgTableLength = packet.readUnsignedLength();
88
- this.orgTableOffset = packet.pos;
89
- packet.skip(this.orgTableLength);
90
-
91
- this.nameLength = packet.readUnsignedLength();
92
- this.nameOffset = packet.pos;
93
- packet.skip(this.nameLength);
94
-
95
- this.orgNameLength = packet.readUnsignedLength();
96
- this.orgNameOffset = packet.pos;
97
- packet.skip(this.orgNameLength);
98
- this.packet = packet;
99
- }
100
- }
101
-
102
- module.exports = ColumnDef;
@@ -1,168 +0,0 @@
1
- 'use strict';
2
-
3
- const EventEmitter = require('events');
4
- const Errors = require('../misc/errors');
5
- const ServerStatus = require('../const/server-status');
6
- const StateChange = require('../const/state-change');
7
- const Collations = require('../const/collations');
8
- const OkPacket = require('./class/ok-packet');
9
-
10
- /**
11
- * Default command interface.
12
- */
13
- class Command extends EventEmitter {
14
- constructor(resolve, reject) {
15
- super();
16
- this.sequenceNo = -1;
17
- this.compressSequenceNo = -1;
18
- this.resolve = resolve;
19
- this.reject = reject;
20
- this.sending = false;
21
- }
22
-
23
- displaySql() {
24
- return null;
25
- }
26
-
27
- /**
28
- * Throw an an unexpected error.
29
- * server exchange will still be read to keep connection in a good state, but promise will be rejected.
30
- *
31
- * @param msg message
32
- * @param fatal is error fatal for connection
33
- * @param info current server state information
34
- * @param sqlState error sqlState
35
- * @param errno error number
36
- */
37
- throwUnexpectedError(msg, fatal, info, sqlState, errno) {
38
- if (this.reject) {
39
- process.nextTick(
40
- this.reject,
41
- Errors.createError(msg, this.displaySql(), fatal, info, sqlState, errno, this.stack, false)
42
- );
43
- this.resolve = null;
44
- this.reject = null;
45
- }
46
- }
47
-
48
- /**
49
- * Create and throw new Error from error information
50
- * only first called throwing an error or successfully end will be executed.
51
- *
52
- * @param msg message
53
- * @param fatal is error fatal for connection
54
- * @param info current server state information
55
- * @param sqlState error sqlState
56
- * @param errno error number
57
- */
58
- throwNewError(msg, fatal, info, sqlState, errno) {
59
- this.onPacketReceive = null;
60
- if (this.reject) {
61
- process.nextTick(
62
- this.reject,
63
- Errors.createError(msg, this.displaySql(), fatal, info, sqlState, errno, this.stack, false)
64
- );
65
- this.resolve = null;
66
- this.reject = null;
67
- }
68
- this.emit('end');
69
- }
70
-
71
- /**
72
- * Throw Error
73
- * only first called throwing an error or successfully end will be executed.
74
- *
75
- * @param err error to be thrown
76
- * @param info current server state information
77
- */
78
- throwError(err, info) {
79
- this.onPacketReceive = null;
80
- if (this.reject) {
81
- if (this.stack) {
82
- err = Errors.createError(
83
- err.message,
84
- err.sql,
85
- err.fatal,
86
- info,
87
- err.sqlState,
88
- err.errno,
89
- this.stack,
90
- false
91
- );
92
- }
93
- this.resolve = null;
94
- process.nextTick(this.reject, err);
95
- this.reject = null;
96
- }
97
- this.emit('end', err);
98
- }
99
-
100
- /**
101
- * Successfully end command.
102
- * only first called throwing an error or successfully end will be executed.
103
- *
104
- * @param val return value.
105
- */
106
- successEnd(val) {
107
- this.onPacketReceive = null;
108
- if (this.resolve) {
109
- this.reject = null;
110
- process.nextTick(this.resolve, val);
111
- this.resolve = null;
112
- }
113
- this.emit('end');
114
- }
115
-
116
- parseOkPacket(packet, out, opts, info) {
117
- packet.skip(1); //skip header
118
-
119
- const affectedRows = packet.readUnsignedLength();
120
- const insertId = opts.supportBigInt
121
- ? packet.readSignedLengthBigInt()
122
- : packet.readSignedLength();
123
-
124
- info.status = packet.readUInt16();
125
-
126
- const okPacket = new OkPacket(affectedRows, insertId, packet.readUInt16());
127
-
128
- if (info.status & ServerStatus.SESSION_STATE_CHANGED) {
129
- packet.skipLengthCodedNumber();
130
- while (packet.remaining()) {
131
- const subPacket = packet.subPacketLengthEncoded();
132
- while (subPacket.remaining()) {
133
- const type = subPacket.readUInt8();
134
- switch (type) {
135
- case StateChange.SESSION_TRACK_SYSTEM_VARIABLES:
136
- const subSubPacket = subPacket.subPacketLengthEncoded();
137
- const variable = subSubPacket.readStringLength();
138
- const value = subSubPacket.readStringLength();
139
-
140
- switch (variable) {
141
- case 'character_set_client':
142
- opts.collation = Collations.fromCharset(value);
143
- if (opts.collation === undefined) {
144
- this.throwError(new Error("unknown charset : '" + value + "'"), info);
145
- return;
146
- }
147
- opts.emit('collation', opts.collation);
148
- break;
149
-
150
- default:
151
- //variable not used by driver
152
- }
153
- break;
154
-
155
- case StateChange.SESSION_TRACK_SCHEMA:
156
- const subSubPacket2 = subPacket.subPacketLengthEncoded();
157
- info.database = subSubPacket2.readStringLength();
158
- break;
159
- }
160
- }
161
- }
162
- }
163
-
164
- return okPacket;
165
- }
166
- }
167
-
168
- module.exports = Command;