@carllee1983/dbcli 1.10.0 → 1.11.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.
- package/CHANGELOG.md +32 -0
- package/assets/SKILL.md +8 -0
- package/assets/snippets/diag/blocking-queries.postgres.sql +17 -0
- package/assets/snippets/diag/cache-hit.mysql.sql +1 -0
- package/assets/snippets/diag/cache-hit.postgres.sql +1 -0
- package/assets/snippets/diag/client-list.redis.sql +8 -0
- package/assets/snippets/diag/cluster-info.redis.sql +8 -0
- package/assets/snippets/diag/connections.mysql.sql +1 -0
- package/assets/snippets/diag/connections.postgres.sql +1 -0
- package/assets/snippets/diag/db-size.mysql.sql +1 -0
- package/assets/snippets/diag/db-size.postgres.sql +1 -0
- package/assets/snippets/diag/es-cluster-health.elasticsearch.sql +1 -0
- package/assets/snippets/diag/hot-threads.elasticsearch.sql +9 -0
- package/assets/snippets/diag/index-stats.elasticsearch.sql +16 -0
- package/assets/snippets/diag/index-usage.mysql.sql +1 -0
- package/assets/snippets/diag/index-usage.postgres.sql +1 -0
- package/assets/snippets/diag/locks.mysql.sql +1 -0
- package/assets/snippets/diag/locks.postgres.sql +1 -0
- package/assets/snippets/diag/long-running.mysql.sql +1 -0
- package/assets/snippets/diag/long-running.postgres.sql +1 -0
- package/assets/snippets/diag/memory-usage.redis.sql +8 -0
- package/assets/snippets/diag/missing-indexes.mysql.sql +1 -0
- package/assets/snippets/diag/missing-indexes.postgres.sql +1 -0
- package/assets/snippets/diag/pending-tasks.elasticsearch.sql +9 -0
- package/assets/snippets/diag/redis-key-stats.redis.sql +1 -0
- package/assets/snippets/diag/slowlog.redis.sql +12 -0
- package/assets/snippets/diag/table-sizes.mysql.sql +1 -0
- package/assets/snippets/diag/table-sizes.postgres.sql +1 -0
- package/assets/snippets/diag/unassigned-shards.elasticsearch.sql +9 -0
- package/dist/cli.mjs +854 -303
- package/package.json +14 -16
package/dist/cli.mjs
CHANGED
|
@@ -31536,7 +31536,7 @@ var require_umd = __commonJS((exports, module) => {
|
|
|
31536
31536
|
});
|
|
31537
31537
|
});
|
|
31538
31538
|
|
|
31539
|
-
// node_modules/
|
|
31539
|
+
// node_modules/iconv-lite/lib/bom-handling.js
|
|
31540
31540
|
var require_bom_handling2 = __commonJS((exports) => {
|
|
31541
31541
|
var BOMChar = "\uFEFF";
|
|
31542
31542
|
exports.PrependBOM = PrependBOMWrapper;
|
|
@@ -31579,7 +31579,7 @@ var require_bom_handling2 = __commonJS((exports) => {
|
|
|
31579
31579
|
};
|
|
31580
31580
|
});
|
|
31581
31581
|
|
|
31582
|
-
// node_modules/
|
|
31582
|
+
// node_modules/iconv-lite/lib/helpers/merge-exports.js
|
|
31583
31583
|
var require_merge_exports = __commonJS((exports, module) => {
|
|
31584
31584
|
var hasOwn = typeof Object.hasOwn === "undefined" ? Function.call.bind(Object.prototype.hasOwnProperty) : Object.hasOwn;
|
|
31585
31585
|
function mergeModules(target, module2) {
|
|
@@ -31592,7 +31592,7 @@ var require_merge_exports = __commonJS((exports, module) => {
|
|
|
31592
31592
|
module.exports = mergeModules;
|
|
31593
31593
|
});
|
|
31594
31594
|
|
|
31595
|
-
// node_modules/
|
|
31595
|
+
// node_modules/iconv-lite/encodings/internal.js
|
|
31596
31596
|
var require_internal2 = __commonJS((exports, module) => {
|
|
31597
31597
|
var Buffer2 = require_safer().Buffer;
|
|
31598
31598
|
module.exports = {
|
|
@@ -31765,7 +31765,7 @@ var require_internal2 = __commonJS((exports, module) => {
|
|
|
31765
31765
|
};
|
|
31766
31766
|
});
|
|
31767
31767
|
|
|
31768
|
-
// node_modules/
|
|
31768
|
+
// node_modules/iconv-lite/encodings/utf32.js
|
|
31769
31769
|
var require_utf32 = __commonJS((exports) => {
|
|
31770
31770
|
var Buffer2 = require_safer().Buffer;
|
|
31771
31771
|
exports._utf32 = Utf32Codec;
|
|
@@ -31999,7 +31999,7 @@ var require_utf32 = __commonJS((exports) => {
|
|
|
31999
31999
|
}
|
|
32000
32000
|
});
|
|
32001
32001
|
|
|
32002
|
-
// node_modules/
|
|
32002
|
+
// node_modules/iconv-lite/encodings/utf16.js
|
|
32003
32003
|
var require_utf162 = __commonJS((exports) => {
|
|
32004
32004
|
var Buffer2 = require_safer().Buffer;
|
|
32005
32005
|
exports.utf16be = Utf16BECodec;
|
|
@@ -32142,7 +32142,7 @@ var require_utf162 = __commonJS((exports) => {
|
|
|
32142
32142
|
}
|
|
32143
32143
|
});
|
|
32144
32144
|
|
|
32145
|
-
// node_modules/
|
|
32145
|
+
// node_modules/iconv-lite/encodings/utf7.js
|
|
32146
32146
|
var require_utf72 = __commonJS((exports) => {
|
|
32147
32147
|
var Buffer2 = require_safer().Buffer;
|
|
32148
32148
|
exports.utf7 = Utf7Codec;
|
|
@@ -32356,7 +32356,7 @@ var require_utf72 = __commonJS((exports) => {
|
|
|
32356
32356
|
};
|
|
32357
32357
|
});
|
|
32358
32358
|
|
|
32359
|
-
// node_modules/
|
|
32359
|
+
// node_modules/iconv-lite/encodings/sbcs-codec.js
|
|
32360
32360
|
var require_sbcs_codec2 = __commonJS((exports) => {
|
|
32361
32361
|
var Buffer2 = require_safer().Buffer;
|
|
32362
32362
|
exports._sbcs = SBCSCodec;
|
|
@@ -32413,7 +32413,7 @@ var require_sbcs_codec2 = __commonJS((exports) => {
|
|
|
32413
32413
|
SBCSDecoder.prototype.end = function() {};
|
|
32414
32414
|
});
|
|
32415
32415
|
|
|
32416
|
-
// node_modules/
|
|
32416
|
+
// node_modules/iconv-lite/encodings/sbcs-data.js
|
|
32417
32417
|
var require_sbcs_data2 = __commonJS((exports, module) => {
|
|
32418
32418
|
module.exports = {
|
|
32419
32419
|
10029: "maccenteuro",
|
|
@@ -32561,7 +32561,7 @@ var require_sbcs_data2 = __commonJS((exports, module) => {
|
|
|
32561
32561
|
};
|
|
32562
32562
|
});
|
|
32563
32563
|
|
|
32564
|
-
// node_modules/
|
|
32564
|
+
// node_modules/iconv-lite/encodings/sbcs-data-generated.js
|
|
32565
32565
|
var require_sbcs_data_generated2 = __commonJS((exports, module) => {
|
|
32566
32566
|
module.exports = {
|
|
32567
32567
|
"437": "cp437",
|
|
@@ -33018,7 +33018,7 @@ var require_sbcs_data_generated2 = __commonJS((exports, module) => {
|
|
|
33018
33018
|
};
|
|
33019
33019
|
});
|
|
33020
33020
|
|
|
33021
|
-
// node_modules/
|
|
33021
|
+
// node_modules/iconv-lite/encodings/dbcs-codec.js
|
|
33022
33022
|
var require_dbcs_codec2 = __commonJS((exports) => {
|
|
33023
33023
|
var Buffer2 = require_safer().Buffer;
|
|
33024
33024
|
exports._dbcs = DBCSCodec;
|
|
@@ -33476,7 +33476,7 @@ var require_dbcs_codec2 = __commonJS((exports) => {
|
|
|
33476
33476
|
}
|
|
33477
33477
|
});
|
|
33478
33478
|
|
|
33479
|
-
// node_modules/
|
|
33479
|
+
// node_modules/iconv-lite/encodings/tables/shiftjis.json
|
|
33480
33480
|
var require_shiftjis2 = __commonJS((exports, module) => {
|
|
33481
33481
|
module.exports = [
|
|
33482
33482
|
["0", "\x00", 128],
|
|
@@ -33605,7 +33605,7 @@ var require_shiftjis2 = __commonJS((exports, module) => {
|
|
|
33605
33605
|
];
|
|
33606
33606
|
});
|
|
33607
33607
|
|
|
33608
|
-
// node_modules/
|
|
33608
|
+
// node_modules/iconv-lite/encodings/tables/eucjp.json
|
|
33609
33609
|
var require_eucjp2 = __commonJS((exports, module) => {
|
|
33610
33610
|
module.exports = [
|
|
33611
33611
|
["0", "\x00", 127],
|
|
@@ -33791,7 +33791,7 @@ var require_eucjp2 = __commonJS((exports, module) => {
|
|
|
33791
33791
|
];
|
|
33792
33792
|
});
|
|
33793
33793
|
|
|
33794
|
-
// node_modules/
|
|
33794
|
+
// node_modules/iconv-lite/encodings/tables/cp936.json
|
|
33795
33795
|
var require_cp9362 = __commonJS((exports, module) => {
|
|
33796
33796
|
module.exports = [
|
|
33797
33797
|
["0", "\x00", 127, "\u20AC"],
|
|
@@ -34059,7 +34059,7 @@ var require_cp9362 = __commonJS((exports, module) => {
|
|
|
34059
34059
|
];
|
|
34060
34060
|
});
|
|
34061
34061
|
|
|
34062
|
-
// node_modules/
|
|
34062
|
+
// node_modules/iconv-lite/encodings/tables/gbk-added.json
|
|
34063
34063
|
var require_gbk_added2 = __commonJS((exports, module) => {
|
|
34064
34064
|
module.exports = [
|
|
34065
34065
|
["a140", "\uE4C6", 62],
|
|
@@ -34119,12 +34119,12 @@ var require_gbk_added2 = __commonJS((exports, module) => {
|
|
|
34119
34119
|
];
|
|
34120
34120
|
});
|
|
34121
34121
|
|
|
34122
|
-
// node_modules/
|
|
34122
|
+
// node_modules/iconv-lite/encodings/tables/gb18030-ranges.json
|
|
34123
34123
|
var require_gb18030_ranges2 = __commonJS((exports, module) => {
|
|
34124
34124
|
module.exports = { uChars: [128, 165, 169, 178, 184, 216, 226, 235, 238, 244, 248, 251, 253, 258, 276, 284, 300, 325, 329, 334, 364, 463, 465, 467, 469, 471, 473, 475, 477, 506, 594, 610, 712, 716, 730, 930, 938, 962, 970, 1026, 1104, 1106, 8209, 8215, 8218, 8222, 8231, 8241, 8244, 8246, 8252, 8365, 8452, 8454, 8458, 8471, 8482, 8556, 8570, 8596, 8602, 8713, 8720, 8722, 8726, 8731, 8737, 8740, 8742, 8748, 8751, 8760, 8766, 8777, 8781, 8787, 8802, 8808, 8816, 8854, 8858, 8870, 8896, 8979, 9322, 9372, 9548, 9588, 9616, 9622, 9634, 9652, 9662, 9672, 9676, 9680, 9702, 9735, 9738, 9793, 9795, 11906, 11909, 11913, 11917, 11928, 11944, 11947, 11951, 11956, 11960, 11964, 11979, 12284, 12292, 12312, 12319, 12330, 12351, 12436, 12447, 12535, 12543, 12586, 12842, 12850, 12964, 13200, 13215, 13218, 13253, 13263, 13267, 13270, 13384, 13428, 13727, 13839, 13851, 14617, 14703, 14801, 14816, 14964, 15183, 15471, 15585, 16471, 16736, 17208, 17325, 17330, 17374, 17623, 17997, 18018, 18212, 18218, 18301, 18318, 18760, 18811, 18814, 18820, 18823, 18844, 18848, 18872, 19576, 19620, 19738, 19887, 40870, 59244, 59336, 59367, 59413, 59417, 59423, 59431, 59437, 59443, 59452, 59460, 59478, 59493, 63789, 63866, 63894, 63976, 63986, 64016, 64018, 64021, 64025, 64034, 64037, 64042, 65074, 65093, 65107, 65112, 65127, 65132, 65375, 65510, 65536], gbChars: [0, 36, 38, 45, 50, 81, 89, 95, 96, 100, 103, 104, 105, 109, 126, 133, 148, 172, 175, 179, 208, 306, 307, 308, 309, 310, 311, 312, 313, 341, 428, 443, 544, 545, 558, 741, 742, 749, 750, 805, 819, 820, 7922, 7924, 7925, 7927, 7934, 7943, 7944, 7945, 7950, 8062, 8148, 8149, 8152, 8164, 8174, 8236, 8240, 8262, 8264, 8374, 8380, 8381, 8384, 8388, 8390, 8392, 8393, 8394, 8396, 8401, 8406, 8416, 8419, 8424, 8437, 8439, 8445, 8482, 8485, 8496, 8521, 8603, 8936, 8946, 9046, 9050, 9063, 9066, 9076, 9092, 9100, 9108, 9111, 9113, 9131, 9162, 9164, 9218, 9219, 11329, 11331, 11334, 11336, 11346, 11361, 11363, 11366, 11370, 11372, 11375, 11389, 11682, 11686, 11687, 11692, 11694, 11714, 11716, 11723, 11725, 11730, 11736, 11982, 11989, 12102, 12336, 12348, 12350, 12384, 12393, 12395, 12397, 12510, 12553, 12851, 12962, 12973, 13738, 13823, 13919, 13933, 14080, 14298, 14585, 14698, 15583, 15847, 16318, 16434, 16438, 16481, 16729, 17102, 17122, 17315, 17320, 17402, 17418, 17859, 17909, 17911, 17915, 17916, 17936, 17939, 17961, 18664, 18703, 18814, 18962, 19043, 33469, 33470, 33471, 33484, 33485, 33490, 33497, 33501, 33505, 33513, 33520, 33536, 33550, 37845, 37921, 37948, 38029, 38038, 38064, 38065, 38066, 38069, 38075, 38076, 38078, 39108, 39109, 39113, 39114, 39115, 39116, 39265, 39394, 189000] };
|
|
34125
34125
|
});
|
|
34126
34126
|
|
|
34127
|
-
// node_modules/
|
|
34127
|
+
// node_modules/iconv-lite/encodings/tables/cp949.json
|
|
34128
34128
|
var require_cp9492 = __commonJS((exports, module) => {
|
|
34129
34129
|
module.exports = [
|
|
34130
34130
|
["0", "\x00", 127],
|
|
@@ -34401,7 +34401,7 @@ var require_cp9492 = __commonJS((exports, module) => {
|
|
|
34401
34401
|
];
|
|
34402
34402
|
});
|
|
34403
34403
|
|
|
34404
|
-
// node_modules/
|
|
34404
|
+
// node_modules/iconv-lite/encodings/tables/cp950.json
|
|
34405
34405
|
var require_cp9502 = __commonJS((exports, module) => {
|
|
34406
34406
|
module.exports = [
|
|
34407
34407
|
["0", "\x00", 127],
|
|
@@ -34582,7 +34582,7 @@ var require_cp9502 = __commonJS((exports, module) => {
|
|
|
34582
34582
|
];
|
|
34583
34583
|
});
|
|
34584
34584
|
|
|
34585
|
-
// node_modules/
|
|
34585
|
+
// node_modules/iconv-lite/encodings/tables/big5-added.json
|
|
34586
34586
|
var require_big5_added2 = __commonJS((exports, module) => {
|
|
34587
34587
|
module.exports = [
|
|
34588
34588
|
["8740", "\u43F0\u4C32\u4603\u45A6\u4578\uD85C\uDE67\u4D77\u45B3\uD85F\uDCB1\u4CE2\uD85F\uDCC5\u3B95\u4736\u4744\u4C47\u4C40\uD850\uDEBF\uD84D\uDE17\uD85C\uDF52\uD85B\uDE8B\uD85C\uDCD2\u4C57\uD868\uDF51\u474F\u45DA\u4C85\uD85F\uDC6C\u4D07\u4AA4\u46A1\uD85A\uDF23\u7225\uD856\uDE54\uD846\uDE63\uD84F\uDE06\uD84F\uDF61\u664D\u56FB"],
|
|
@@ -34708,7 +34708,7 @@ var require_big5_added2 = __commonJS((exports, module) => {
|
|
|
34708
34708
|
];
|
|
34709
34709
|
});
|
|
34710
34710
|
|
|
34711
|
-
// node_modules/
|
|
34711
|
+
// node_modules/iconv-lite/encodings/dbcs-data.js
|
|
34712
34712
|
var require_dbcs_data2 = __commonJS((exports, module) => {
|
|
34713
34713
|
module.exports = {
|
|
34714
34714
|
shiftjis: {
|
|
@@ -34879,7 +34879,7 @@ var require_dbcs_data2 = __commonJS((exports, module) => {
|
|
|
34879
34879
|
};
|
|
34880
34880
|
});
|
|
34881
34881
|
|
|
34882
|
-
// node_modules/
|
|
34882
|
+
// node_modules/iconv-lite/encodings/index.js
|
|
34883
34883
|
var require_encodings2 = __commonJS((exports, module) => {
|
|
34884
34884
|
var mergeModules = require_merge_exports();
|
|
34885
34885
|
var modules = [
|
|
@@ -34901,7 +34901,7 @@ var require_encodings2 = __commonJS((exports, module) => {
|
|
|
34901
34901
|
var i;
|
|
34902
34902
|
});
|
|
34903
34903
|
|
|
34904
|
-
// node_modules/
|
|
34904
|
+
// node_modules/iconv-lite/lib/streams.js
|
|
34905
34905
|
var require_streams2 = __commonJS((exports, module) => {
|
|
34906
34906
|
var Buffer2 = require_safer().Buffer;
|
|
34907
34907
|
module.exports = function(streamModule) {
|
|
@@ -34999,7 +34999,7 @@ var require_streams2 = __commonJS((exports, module) => {
|
|
|
34999
34999
|
};
|
|
35000
35000
|
});
|
|
35001
35001
|
|
|
35002
|
-
// node_modules/
|
|
35002
|
+
// node_modules/iconv-lite/lib/index.js
|
|
35003
35003
|
var require_lib7 = __commonJS((exports, module) => {
|
|
35004
35004
|
var Buffer2 = require_safer().Buffer;
|
|
35005
35005
|
var bomHandling = require_bom_handling2();
|
|
@@ -35334,20 +35334,16 @@ var require_packet = __commonJS((exports, module) => {
|
|
|
35334
35334
|
readInt64() {
|
|
35335
35335
|
const word0 = this.readInt32();
|
|
35336
35336
|
const word1 = this.readInt32();
|
|
35337
|
-
|
|
35337
|
+
const res = new Long(word0, word1, true);
|
|
35338
35338
|
const resNumber = res.toNumber();
|
|
35339
|
-
|
|
35340
|
-
res = resNumber.toString() === resString ? resNumber : resString;
|
|
35341
|
-
return res;
|
|
35339
|
+
return Number.isSafeInteger(resNumber) ? resNumber : res.toString();
|
|
35342
35340
|
}
|
|
35343
35341
|
readSInt64() {
|
|
35344
35342
|
const word0 = this.readInt32();
|
|
35345
35343
|
const word1 = this.readInt32();
|
|
35346
|
-
|
|
35344
|
+
const res = new Long(word0, word1, false);
|
|
35347
35345
|
const resNumber = res.toNumber();
|
|
35348
|
-
|
|
35349
|
-
res = resNumber.toString() === resString ? resNumber : resString;
|
|
35350
|
-
return res;
|
|
35346
|
+
return Number.isSafeInteger(resNumber) ? resNumber : res.toString();
|
|
35351
35347
|
}
|
|
35352
35348
|
isEOF() {
|
|
35353
35349
|
return this.buffer[this.offset] === 254 && this.length() < 13;
|
|
@@ -35392,8 +35388,10 @@ var require_packet = __commonJS((exports, module) => {
|
|
|
35392
35388
|
res = new Long(word0, word1, !signed);
|
|
35393
35389
|
const resNumber = res.toNumber();
|
|
35394
35390
|
const resString = res.toString();
|
|
35395
|
-
|
|
35396
|
-
|
|
35391
|
+
if (bigNumberStrings || !Number.isSafeInteger(resNumber)) {
|
|
35392
|
+
return resString;
|
|
35393
|
+
}
|
|
35394
|
+
return resNumber;
|
|
35397
35395
|
}
|
|
35398
35396
|
console.trace();
|
|
35399
35397
|
throw new Error(`Should not reach here: ${tag}`);
|
|
@@ -35450,6 +35448,9 @@ var require_packet = __commonJS((exports, module) => {
|
|
|
35450
35448
|
return new Date(y, m - 1, d, H, M, S, ms);
|
|
35451
35449
|
}
|
|
35452
35450
|
let str = this.readDateTimeString(6, "T", null);
|
|
35451
|
+
if (!str) {
|
|
35452
|
+
return INVALID_DATE;
|
|
35453
|
+
}
|
|
35453
35454
|
if (str.length === 10) {
|
|
35454
35455
|
str += "T00:00:00";
|
|
35455
35456
|
}
|
|
@@ -35587,7 +35588,7 @@ var require_packet = __commonJS((exports, module) => {
|
|
|
35587
35588
|
if (numDigits >= 15) {
|
|
35588
35589
|
str = this.readString(end - this.offset, "binary");
|
|
35589
35590
|
result = parseInt(str, 10);
|
|
35590
|
-
if (
|
|
35591
|
+
if (Number.isSafeInteger(sign * result)) {
|
|
35591
35592
|
return sign * result;
|
|
35592
35593
|
}
|
|
35593
35594
|
return sign === -1 ? `-${str}` : str;
|
|
@@ -35609,11 +35610,10 @@ var require_packet = __commonJS((exports, module) => {
|
|
|
35609
35610
|
if (!supportBigNumbers) {
|
|
35610
35611
|
return num;
|
|
35611
35612
|
}
|
|
35612
|
-
|
|
35613
|
-
if (num.toString() === str) {
|
|
35613
|
+
if (Number.isSafeInteger(num)) {
|
|
35614
35614
|
return num;
|
|
35615
35615
|
}
|
|
35616
|
-
return
|
|
35616
|
+
return this.buffer.toString("ascii", start, end);
|
|
35617
35617
|
}
|
|
35618
35618
|
parseIntNoBigCheck(len) {
|
|
35619
35619
|
if (len === null) {
|
|
@@ -36400,6 +36400,7 @@ var require_commands = __commonJS((exports, module) => {
|
|
|
36400
36400
|
STMT_FETCH: 28,
|
|
36401
36401
|
DAEMON: 29,
|
|
36402
36402
|
BINLOG_DUMP_GTID: 30,
|
|
36403
|
+
RESET_CONNECTION: 31,
|
|
36403
36404
|
UNKNOWN: 255
|
|
36404
36405
|
};
|
|
36405
36406
|
});
|
|
@@ -36458,6 +36459,7 @@ var require_client3 = __commonJS((exports) => {
|
|
|
36458
36459
|
exports.PLUGIN_AUTH_LENENC_CLIENT_DATA = 2097152;
|
|
36459
36460
|
exports.CAN_HANDLE_EXPIRED_PASSWORDS = 4194304;
|
|
36460
36461
|
exports.SESSION_TRACK = 8388608;
|
|
36462
|
+
exports.CLIENT_QUERY_ATTRIBUTES = 134217728;
|
|
36461
36463
|
exports.SSL_VERIFY_SERVER_CERT = 1073741824;
|
|
36462
36464
|
exports.REMEMBER_OPTIONS = 2147483648;
|
|
36463
36465
|
exports.MULTI_FACTOR_AUTHENTICATION = 268435456;
|
|
@@ -37173,17 +37175,15 @@ var require_cursor = __commonJS((exports, module) => {
|
|
|
37173
37175
|
NO_CURSOR: 0,
|
|
37174
37176
|
READ_ONLY: 1,
|
|
37175
37177
|
FOR_UPDATE: 2,
|
|
37176
|
-
SCROLLABLE: 3
|
|
37178
|
+
SCROLLABLE: 3,
|
|
37179
|
+
PARAMETER_COUNT_AVAILABLE: 8
|
|
37177
37180
|
};
|
|
37178
37181
|
});
|
|
37179
37182
|
|
|
37180
|
-
// node_modules/mysql2/lib/packets/
|
|
37181
|
-
var
|
|
37182
|
-
var CursorType = require_cursor();
|
|
37183
|
-
var CommandCodes = require_commands();
|
|
37183
|
+
// node_modules/mysql2/lib/packets/encode_parameter.js
|
|
37184
|
+
var require_encode_parameter = __commonJS((exports, module) => {
|
|
37184
37185
|
var Types = require_types();
|
|
37185
37186
|
var Packet = require_packet();
|
|
37186
|
-
var CharsetToEncoding = require_charset_encodings();
|
|
37187
37187
|
function isJSON(value) {
|
|
37188
37188
|
return Array.isArray(value) || value.constructor === Object || typeof value.toJSON === "function" && !Buffer.isBuffer(value);
|
|
37189
37189
|
}
|
|
@@ -37235,13 +37235,27 @@ var require_execute = __commonJS((exports, module) => {
|
|
|
37235
37235
|
}
|
|
37236
37236
|
return { value, type, length, writer };
|
|
37237
37237
|
}
|
|
37238
|
+
module.exports = { toParameter, isJSON };
|
|
37239
|
+
});
|
|
37240
|
+
|
|
37241
|
+
// node_modules/mysql2/lib/packets/execute.js
|
|
37242
|
+
var require_execute = __commonJS((exports, module) => {
|
|
37243
|
+
var CursorType = require_cursor();
|
|
37244
|
+
var CommandCodes = require_commands();
|
|
37245
|
+
var ClientConstants = require_client3();
|
|
37246
|
+
var Types = require_types();
|
|
37247
|
+
var Packet = require_packet();
|
|
37248
|
+
var CharsetToEncoding = require_charset_encodings();
|
|
37249
|
+
var { toParameter } = require_encode_parameter();
|
|
37238
37250
|
|
|
37239
37251
|
class Execute {
|
|
37240
|
-
constructor(id, parameters, charsetNumber, timezone) {
|
|
37252
|
+
constructor(id, parameters, charsetNumber, timezone, attributes, clientFlags) {
|
|
37241
37253
|
this.id = id;
|
|
37242
37254
|
this.parameters = parameters;
|
|
37243
37255
|
this.encoding = CharsetToEncoding[charsetNumber];
|
|
37244
37256
|
this.timezone = timezone;
|
|
37257
|
+
this.attributes = attributes;
|
|
37258
|
+
this.clientFlags = clientFlags || 0;
|
|
37245
37259
|
}
|
|
37246
37260
|
static fromPacket(packet, encoding) {
|
|
37247
37261
|
const stmtId = packet.readInt32();
|
|
@@ -37283,27 +37297,32 @@ var require_execute = __commonJS((exports, module) => {
|
|
|
37283
37297
|
}
|
|
37284
37298
|
return { stmtId, flags, iterationCount, values };
|
|
37285
37299
|
}
|
|
37286
|
-
|
|
37287
|
-
|
|
37288
|
-
|
|
37289
|
-
|
|
37290
|
-
|
|
37291
|
-
|
|
37292
|
-
|
|
37293
|
-
parameters = this.parameters.map((value) => toParameter(value, this.encoding, this.timezone));
|
|
37294
|
-
length += parameters.reduce((accumulator, parameter) => accumulator + parameter.length, 0);
|
|
37295
|
-
}
|
|
37296
|
-
const buffer = Buffer.allocUnsafe(length);
|
|
37297
|
-
const packet = new Packet(0, buffer, 0, length);
|
|
37300
|
+
_serializeToBuffer(buffer) {
|
|
37301
|
+
const useQueryAttributes = this.clientFlags & ClientConstants.CLIENT_QUERY_ATTRIBUTES;
|
|
37302
|
+
const attrNames = useQueryAttributes && this.attributes ? Object.keys(this.attributes) : [];
|
|
37303
|
+
const numParams = this.parameters ? this.parameters.length : 0;
|
|
37304
|
+
const numAttrs = attrNames.length;
|
|
37305
|
+
const totalParams = numParams + numAttrs;
|
|
37306
|
+
const packet = new Packet(0, buffer, 0, buffer.length);
|
|
37298
37307
|
packet.offset = 4;
|
|
37299
37308
|
packet.writeInt8(CommandCodes.STMT_EXECUTE);
|
|
37300
37309
|
packet.writeInt32(this.id);
|
|
37301
|
-
|
|
37310
|
+
let cursorFlags = CursorType.NO_CURSOR;
|
|
37311
|
+
if (useQueryAttributes) {
|
|
37312
|
+
cursorFlags |= CursorType.PARAMETER_COUNT_AVAILABLE;
|
|
37313
|
+
}
|
|
37314
|
+
packet.writeInt8(cursorFlags);
|
|
37302
37315
|
packet.writeInt32(1);
|
|
37303
|
-
if (
|
|
37316
|
+
if (useQueryAttributes) {
|
|
37317
|
+
packet.writeLengthCodedNumber(totalParams);
|
|
37318
|
+
}
|
|
37319
|
+
if (totalParams > 0) {
|
|
37320
|
+
const bindParams = numParams > 0 ? this.parameters.map((v) => toParameter(v, this.encoding, this.timezone)) : [];
|
|
37321
|
+
const attrParams = attrNames.map((name) => toParameter(this.attributes[name], this.encoding, this.timezone));
|
|
37322
|
+
const allParams = bindParams.concat(attrParams);
|
|
37304
37323
|
let bitmap = 0;
|
|
37305
37324
|
let bitValue = 1;
|
|
37306
|
-
|
|
37325
|
+
allParams.forEach((parameter) => {
|
|
37307
37326
|
if (parameter.type === Types.NULL) {
|
|
37308
37327
|
bitmap += bitValue;
|
|
37309
37328
|
}
|
|
@@ -37318,11 +37337,15 @@ var require_execute = __commonJS((exports, module) => {
|
|
|
37318
37337
|
packet.writeInt8(bitmap);
|
|
37319
37338
|
}
|
|
37320
37339
|
packet.writeInt8(1);
|
|
37321
|
-
|
|
37322
|
-
packet.writeInt8(
|
|
37340
|
+
for (let i = 0;i < allParams.length; i++) {
|
|
37341
|
+
packet.writeInt8(allParams[i].type);
|
|
37323
37342
|
packet.writeInt8(0);
|
|
37324
|
-
|
|
37325
|
-
|
|
37343
|
+
if (useQueryAttributes) {
|
|
37344
|
+
const name = i < numParams ? "" : attrNames[i - numParams];
|
|
37345
|
+
packet.writeLengthCodedString(name, this.encoding);
|
|
37346
|
+
}
|
|
37347
|
+
}
|
|
37348
|
+
allParams.forEach((parameter) => {
|
|
37326
37349
|
if (parameter.type !== Types.NULL) {
|
|
37327
37350
|
parameter.writer.call(packet, parameter.value);
|
|
37328
37351
|
}
|
|
@@ -37330,6 +37353,10 @@ var require_execute = __commonJS((exports, module) => {
|
|
|
37330
37353
|
}
|
|
37331
37354
|
return packet;
|
|
37332
37355
|
}
|
|
37356
|
+
toPacket() {
|
|
37357
|
+
const p = this._serializeToBuffer(Packet.MockBuffer());
|
|
37358
|
+
return this._serializeToBuffer(Buffer.allocUnsafe(p.offset));
|
|
37359
|
+
}
|
|
37333
37360
|
}
|
|
37334
37361
|
module.exports = Execute;
|
|
37335
37362
|
});
|
|
@@ -37527,11 +37554,11 @@ var require_handshake_response = __commonJS((exports, module) => {
|
|
|
37527
37554
|
const p = this.serializeResponse(Packet.MockBuffer());
|
|
37528
37555
|
return this.serializeResponse(Buffer.alloc(p.offset));
|
|
37529
37556
|
}
|
|
37530
|
-
static fromPacket(packet) {
|
|
37557
|
+
static fromPacket(packet, serverFlags = 4294967295) {
|
|
37531
37558
|
const args = {};
|
|
37532
37559
|
args.clientFlags = packet.readInt32();
|
|
37533
37560
|
function isSet(flag) {
|
|
37534
|
-
return args.clientFlags & ClientConstants[flag];
|
|
37561
|
+
return args.clientFlags & serverFlags & ClientConstants[flag];
|
|
37535
37562
|
}
|
|
37536
37563
|
args.maxPacketSize = packet.readInt32();
|
|
37537
37564
|
args.charsetNumber = packet.readInt8();
|
|
@@ -37618,23 +37645,79 @@ var require_query3 = __commonJS((exports, module) => {
|
|
|
37618
37645
|
var CommandCode = require_commands();
|
|
37619
37646
|
var StringParser = require_string();
|
|
37620
37647
|
var CharsetToEncoding = require_charset_encodings();
|
|
37648
|
+
var ClientConstants = require_client3();
|
|
37649
|
+
var Types = require_types();
|
|
37650
|
+
var { toParameter } = require_encode_parameter();
|
|
37621
37651
|
|
|
37622
37652
|
class Query2 {
|
|
37623
|
-
constructor(sql, charsetNumber) {
|
|
37653
|
+
constructor(sql, charsetNumber, attributes, clientFlags) {
|
|
37624
37654
|
this.query = sql;
|
|
37625
37655
|
this.charsetNumber = charsetNumber;
|
|
37626
37656
|
this.encoding = CharsetToEncoding[charsetNumber];
|
|
37657
|
+
this.attributes = attributes;
|
|
37658
|
+
this.clientFlags = clientFlags || 0;
|
|
37627
37659
|
}
|
|
37628
|
-
|
|
37629
|
-
const
|
|
37630
|
-
const
|
|
37631
|
-
const
|
|
37632
|
-
const packet = new Packet(0, buffer, 0, length);
|
|
37660
|
+
serializeToBuffer(buffer) {
|
|
37661
|
+
const useQueryAttributes = this.clientFlags & ClientConstants.CLIENT_QUERY_ATTRIBUTES;
|
|
37662
|
+
const sqlBuf = StringParser.encode(this.query, this.encoding);
|
|
37663
|
+
const packet = new Packet(0, buffer, 0, buffer.length);
|
|
37633
37664
|
packet.offset = 4;
|
|
37634
37665
|
packet.writeInt8(CommandCode.QUERY);
|
|
37635
|
-
|
|
37666
|
+
if (useQueryAttributes) {
|
|
37667
|
+
const attrs = this.attributes;
|
|
37668
|
+
const names = attrs ? Object.keys(attrs) : [];
|
|
37669
|
+
const paramCount = names.length;
|
|
37670
|
+
packet.writeLengthCodedNumber(paramCount);
|
|
37671
|
+
packet.writeLengthCodedNumber(1);
|
|
37672
|
+
if (paramCount > 0) {
|
|
37673
|
+
const parameters = names.map((name) => toParameter(attrs[name], this.encoding, "local"));
|
|
37674
|
+
let bitmap = 0;
|
|
37675
|
+
let bitValue = 1;
|
|
37676
|
+
parameters.forEach((parameter) => {
|
|
37677
|
+
if (parameter.type === Types.NULL) {
|
|
37678
|
+
bitmap += bitValue;
|
|
37679
|
+
}
|
|
37680
|
+
bitValue *= 2;
|
|
37681
|
+
if (bitValue === 256) {
|
|
37682
|
+
packet.writeInt8(bitmap);
|
|
37683
|
+
bitmap = 0;
|
|
37684
|
+
bitValue = 1;
|
|
37685
|
+
}
|
|
37686
|
+
});
|
|
37687
|
+
if (bitValue !== 1) {
|
|
37688
|
+
packet.writeInt8(bitmap);
|
|
37689
|
+
}
|
|
37690
|
+
packet.writeInt8(1);
|
|
37691
|
+
for (let i = 0;i < paramCount; i++) {
|
|
37692
|
+
packet.writeInt8(parameters[i].type);
|
|
37693
|
+
packet.writeInt8(0);
|
|
37694
|
+
packet.writeLengthCodedString(names[i], this.encoding);
|
|
37695
|
+
}
|
|
37696
|
+
parameters.forEach((parameter) => {
|
|
37697
|
+
if (parameter.type !== Types.NULL) {
|
|
37698
|
+
parameter.writer.call(packet, parameter.value);
|
|
37699
|
+
}
|
|
37700
|
+
});
|
|
37701
|
+
}
|
|
37702
|
+
}
|
|
37703
|
+
packet.writeBuffer(sqlBuf);
|
|
37636
37704
|
return packet;
|
|
37637
37705
|
}
|
|
37706
|
+
toPacket() {
|
|
37707
|
+
const useQueryAttributes = this.clientFlags & ClientConstants.CLIENT_QUERY_ATTRIBUTES;
|
|
37708
|
+
if (!useQueryAttributes) {
|
|
37709
|
+
const buf = StringParser.encode(this.query, this.encoding);
|
|
37710
|
+
const length = 5 + buf.length;
|
|
37711
|
+
const buffer = Buffer.allocUnsafe(length);
|
|
37712
|
+
const packet = new Packet(0, buffer, 0, length);
|
|
37713
|
+
packet.offset = 4;
|
|
37714
|
+
packet.writeInt8(CommandCode.QUERY);
|
|
37715
|
+
packet.writeBuffer(buf);
|
|
37716
|
+
return packet;
|
|
37717
|
+
}
|
|
37718
|
+
const p = this.serializeToBuffer(Packet.MockBuffer());
|
|
37719
|
+
return this.serializeToBuffer(Buffer.allocUnsafe(p.offset));
|
|
37720
|
+
}
|
|
37638
37721
|
}
|
|
37639
37722
|
module.exports = Query2;
|
|
37640
37723
|
});
|
|
@@ -37676,6 +37759,23 @@ var require_register_slave = __commonJS((exports, module) => {
|
|
|
37676
37759
|
module.exports = RegisterSlave;
|
|
37677
37760
|
});
|
|
37678
37761
|
|
|
37762
|
+
// node_modules/mysql2/lib/packets/reset_connection.js
|
|
37763
|
+
var require_reset_connection = __commonJS((exports, module) => {
|
|
37764
|
+
var Packet = require_packet();
|
|
37765
|
+
var CommandCodes = require_commands();
|
|
37766
|
+
|
|
37767
|
+
class ResetConnection {
|
|
37768
|
+
constructor() {}
|
|
37769
|
+
toPacket() {
|
|
37770
|
+
const packet = new Packet(0, Buffer.alloc(5), 0, 5);
|
|
37771
|
+
packet.offset = 4;
|
|
37772
|
+
packet.writeInt8(CommandCodes.RESET_CONNECTION);
|
|
37773
|
+
return packet;
|
|
37774
|
+
}
|
|
37775
|
+
}
|
|
37776
|
+
module.exports = ResetConnection;
|
|
37777
|
+
});
|
|
37778
|
+
|
|
37679
37779
|
// node_modules/mysql2/lib/constants/server_status.js
|
|
37680
37780
|
var require_server_status = __commonJS((exports) => {
|
|
37681
37781
|
exports.SERVER_STATUS_IN_TRANS = 1;
|
|
@@ -37791,7 +37891,7 @@ var require_resultset_header = __commonJS((exports, module) => {
|
|
|
37791
37891
|
let stateChanges = null;
|
|
37792
37892
|
if (isSet("SESSION_TRACK") && packet.offset < packet.end) {
|
|
37793
37893
|
this.info = packet.readLengthCodedString(encoding);
|
|
37794
|
-
if (this.serverStatus
|
|
37894
|
+
if (this.serverStatus & ServerSatusFlags.SERVER_SESSION_STATE_CHANGED) {
|
|
37795
37895
|
let len = packet.offset < packet.end ? packet.readLengthCodedNumber() : 0;
|
|
37796
37896
|
const end = packet.offset + len;
|
|
37797
37897
|
let type, key2, stateEnd;
|
|
@@ -37950,6 +38050,7 @@ var require_packets = __commonJS((exports, module) => {
|
|
|
37950
38050
|
var PreparedStatementHeader = require_prepared_statement_header();
|
|
37951
38051
|
var Query2 = require_query3();
|
|
37952
38052
|
var RegisterSlave = require_register_slave();
|
|
38053
|
+
var ResetConnection = require_reset_connection();
|
|
37953
38054
|
var ResultSetHeader = require_resultset_header();
|
|
37954
38055
|
var SSLRequest = require_ssl_request();
|
|
37955
38056
|
var TextRow = require_text_row();
|
|
@@ -37970,6 +38071,7 @@ var require_packets = __commonJS((exports, module) => {
|
|
|
37970
38071
|
PreparedStatementHeader,
|
|
37971
38072
|
Query: Query2,
|
|
37972
38073
|
RegisterSlave,
|
|
38074
|
+
ResetConnection,
|
|
37973
38075
|
ResultSetHeader,
|
|
37974
38076
|
SSLRequest,
|
|
37975
38077
|
TextRow
|
|
@@ -38320,6 +38422,15 @@ var require_auth_switch = __commonJS((exports, module) => {
|
|
|
38320
38422
|
});
|
|
38321
38423
|
return;
|
|
38322
38424
|
}
|
|
38425
|
+
if (pluginName === "mysql_clear_password") {
|
|
38426
|
+
const hasCustomPlugin = connection.config.authPlugins && Object.prototype.hasOwnProperty.call(connection.config.authPlugins, "mysql_clear_password");
|
|
38427
|
+
if (!hasCustomPlugin && !connection.config.enableCleartextPlugin) {
|
|
38428
|
+
const err = new Error("Server requested authentication using mysql_clear_password, " + "which sends the password in plaintext over the network and is " + "disabled by default. To enable it, set the `enableCleartextPlugin` " + "option to `true` in your connection configuration, or provide a " + "custom `mysql_clear_password` auth plugin via the `authPlugins` " + "option. Only use this over a secure connection (TLS/SSL).");
|
|
38429
|
+
err.code = "MYSQL_CLEAR_PASSWORD_NOT_ENABLED";
|
|
38430
|
+
err.fatal = true;
|
|
38431
|
+
throw err;
|
|
38432
|
+
}
|
|
38433
|
+
}
|
|
38323
38434
|
const authPlugin = getAuthPlugin(pluginName, connection);
|
|
38324
38435
|
if (!authPlugin) {
|
|
38325
38436
|
throw new Error(`Server requests authentication using unknown plugin ${pluginName}. See ${"TODO: add plugins doco here"} on how to configure or author authentication plugins.`);
|
|
@@ -38539,7 +38650,7 @@ var require_client_handshake = __commonJS((exports, module) => {
|
|
|
38539
38650
|
]).slice(0, 20) : Buffer.alloc(20);
|
|
38540
38651
|
const hasCustomAuthPlugin = connection.config.authPlugins && Object.prototype.hasOwnProperty.call(connection.config.authPlugins, serverAuthMethod);
|
|
38541
38652
|
const hasLegacyAuthSwitchHandler = typeof connection.config.authSwitchHandler === "function";
|
|
38542
|
-
const canUseDirectAuth = !hasCustomAuthPlugin && !hasLegacyAuthSwitchHandler && this.canUseAuthMethodDirectly(serverAuthMethod, isSecureConnection);
|
|
38653
|
+
const canUseDirectAuth = !hasCustomAuthPlugin && !hasLegacyAuthSwitchHandler && this.canUseAuthMethodDirectly(serverAuthMethod, isSecureConnection) && (serverAuthMethod !== "mysql_clear_password" || connection.config.enableCleartextPlugin);
|
|
38543
38654
|
const clientAuthMethod = canUseDirectAuth ? serverAuthMethod : "mysql_native_password";
|
|
38544
38655
|
const authToken = this.calculateAuthToken(clientAuthMethod, this.password, authPluginData);
|
|
38545
38656
|
if (connection.config.debug) {
|
|
@@ -38682,7 +38793,9 @@ var require_client_handshake = __commonJS((exports, module) => {
|
|
|
38682
38793
|
}
|
|
38683
38794
|
return ClientHandshake.prototype.handshakeResult;
|
|
38684
38795
|
} catch (err) {
|
|
38685
|
-
err.code
|
|
38796
|
+
if (!err.code) {
|
|
38797
|
+
err.code = "AUTH_SWITCH_PLUGIN_ERROR";
|
|
38798
|
+
}
|
|
38686
38799
|
err.fatal = true;
|
|
38687
38800
|
if (this.onResult) {
|
|
38688
38801
|
this.onResult(err);
|
|
@@ -38744,7 +38857,7 @@ var require_server_handshake = __commonJS((exports, module) => {
|
|
|
38744
38857
|
return ServerHandshake.prototype.readClientReply;
|
|
38745
38858
|
}
|
|
38746
38859
|
readClientReply(packet, connection) {
|
|
38747
|
-
const clientHelloReply = Packets.HandshakeResponse.fromPacket(packet);
|
|
38860
|
+
const clientHelloReply = Packets.HandshakeResponse.fromPacket(packet, this.args.capabilityFlags);
|
|
38748
38861
|
connection.clientHelloReply = clientHelloReply;
|
|
38749
38862
|
if (this.args.authCallback) {
|
|
38750
38863
|
this.args.authCallback({
|
|
@@ -39748,7 +39861,8 @@ var require_query4 = __commonJS((exports, module) => {
|
|
|
39748
39861
|
this._connection = connection;
|
|
39749
39862
|
this.options = Object.assign({}, connection.config, this._queryOptions);
|
|
39750
39863
|
this._setTimeout();
|
|
39751
|
-
const
|
|
39864
|
+
const clientFlags = connection.config.clientFlags & (connection.serverCapabilityFlags || 0);
|
|
39865
|
+
const cmdPacket = new Packets.Query(this.sql, connection.config.charsetNumber, this._queryOptions.attributes, clientFlags);
|
|
39752
39866
|
connection.writePacket(cmdPacket.toPacket(1));
|
|
39753
39867
|
return Query2.prototype.resultsetHeader;
|
|
39754
39868
|
}
|
|
@@ -40377,7 +40491,8 @@ var require_execute2 = __commonJS((exports, module) => {
|
|
|
40377
40491
|
this._connection = connection;
|
|
40378
40492
|
this.options = Object.assign({}, connection.config, this._executeOptions);
|
|
40379
40493
|
this._setTimeout();
|
|
40380
|
-
const
|
|
40494
|
+
const clientFlags = connection.config.clientFlags & (connection.serverCapabilityFlags || 0);
|
|
40495
|
+
const executePacket = new Packets.Execute(this.statement.id, this.parameters, connection.config.charsetNumber, connection.config.timezone, this._executeOptions.attributes, clientFlags);
|
|
40381
40496
|
try {
|
|
40382
40497
|
connection.writePacket(executePacket.toPacket(1));
|
|
40383
40498
|
} catch (error) {
|
|
@@ -40838,6 +40953,34 @@ var require_change_user2 = __commonJS((exports, module) => {
|
|
|
40838
40953
|
module.exports = ChangeUser;
|
|
40839
40954
|
});
|
|
40840
40955
|
|
|
40956
|
+
// node_modules/mysql2/lib/commands/reset_connection.js
|
|
40957
|
+
var require_reset_connection2 = __commonJS((exports, module) => {
|
|
40958
|
+
var Command2 = require_command2();
|
|
40959
|
+
var Packets = require_packets();
|
|
40960
|
+
|
|
40961
|
+
class ResetConnection extends Command2 {
|
|
40962
|
+
constructor(callback) {
|
|
40963
|
+
super();
|
|
40964
|
+
this.onResult = callback;
|
|
40965
|
+
}
|
|
40966
|
+
start(packet, connection) {
|
|
40967
|
+
const req = new Packets.ResetConnection;
|
|
40968
|
+
connection.writePacket(req.toPacket());
|
|
40969
|
+
return ResetConnection.prototype.resetConnectionResponse;
|
|
40970
|
+
}
|
|
40971
|
+
resetConnectionResponse(packet, connection) {
|
|
40972
|
+
if (connection._statements) {
|
|
40973
|
+
connection._statements.clear();
|
|
40974
|
+
}
|
|
40975
|
+
if (this.onResult) {
|
|
40976
|
+
process.nextTick(this.onResult.bind(this, null));
|
|
40977
|
+
}
|
|
40978
|
+
return null;
|
|
40979
|
+
}
|
|
40980
|
+
}
|
|
40981
|
+
module.exports = ResetConnection;
|
|
40982
|
+
});
|
|
40983
|
+
|
|
40841
40984
|
// node_modules/mysql2/lib/commands/quit.js
|
|
40842
40985
|
var require_quit = __commonJS((exports, module) => {
|
|
40843
40986
|
var Command2 = require_command2();
|
|
@@ -40874,6 +41017,7 @@ var require_commands2 = __commonJS((exports, module) => {
|
|
|
40874
41017
|
var RegisterSlave = require_register_slave2();
|
|
40875
41018
|
var BinlogDump = require_binlog_dump2();
|
|
40876
41019
|
var ChangeUser = require_change_user2();
|
|
41020
|
+
var ResetConnection = require_reset_connection2();
|
|
40877
41021
|
var Quit = require_quit();
|
|
40878
41022
|
module.exports = {
|
|
40879
41023
|
ClientHandshake,
|
|
@@ -40886,6 +41030,7 @@ var require_commands2 = __commonJS((exports, module) => {
|
|
|
40886
41030
|
RegisterSlave,
|
|
40887
41031
|
BinlogDump,
|
|
40888
41032
|
ChangeUser,
|
|
41033
|
+
ResetConnection,
|
|
40889
41034
|
Quit
|
|
40890
41035
|
};
|
|
40891
41036
|
});
|
|
@@ -40894,7 +41039,7 @@ var require_commands2 = __commonJS((exports, module) => {
|
|
|
40894
41039
|
var require_package = __commonJS((exports, module) => {
|
|
40895
41040
|
module.exports = {
|
|
40896
41041
|
name: "mysql2",
|
|
40897
|
-
version: "3.
|
|
41042
|
+
version: "3.22.3",
|
|
40898
41043
|
description: "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
|
|
40899
41044
|
main: "index.js",
|
|
40900
41045
|
typings: "typings/mysql/index",
|
|
@@ -40962,7 +41107,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
40962
41107
|
devDependencies: {
|
|
40963
41108
|
"@eslint/eslintrc": "^3.3.3",
|
|
40964
41109
|
"@eslint/js": "^9.39.2",
|
|
40965
|
-
"@eslint/markdown": "^
|
|
41110
|
+
"@eslint/markdown": "^8.0.1",
|
|
40966
41111
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
|
|
40967
41112
|
"@pokujs/multi-suite": "^1.0.0",
|
|
40968
41113
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
@@ -44177,11 +44322,13 @@ var require_connection_config = __commonJS((exports, module) => {
|
|
|
44177
44322
|
uri: 1,
|
|
44178
44323
|
user: 1,
|
|
44179
44324
|
disableEval: 1,
|
|
44325
|
+
enableCleartextPlugin: 1,
|
|
44180
44326
|
connectionLimit: 1,
|
|
44181
44327
|
maxIdle: 1,
|
|
44182
44328
|
idleTimeout: 1,
|
|
44183
44329
|
Promise: 1,
|
|
44184
44330
|
queueLimit: 1,
|
|
44331
|
+
resetOnRelease: 1,
|
|
44185
44332
|
waitForConnections: 1,
|
|
44186
44333
|
jsonStrings: 1,
|
|
44187
44334
|
gracefulEnd: 1
|
|
@@ -44247,6 +44394,7 @@ var require_connection_config = __commonJS((exports, module) => {
|
|
|
44247
44394
|
this.nestTables = options.nestTables === undefined ? undefined : options.nestTables;
|
|
44248
44395
|
this.typeCast = options.typeCast === undefined ? true : options.typeCast;
|
|
44249
44396
|
this.disableEval = Boolean(options.disableEval);
|
|
44397
|
+
this.enableCleartextPlugin = Boolean(options.enableCleartextPlugin);
|
|
44250
44398
|
if (this.timezone[0] === " ") {
|
|
44251
44399
|
this.timezone = `+${this.timezone.slice(1)}`;
|
|
44252
44400
|
}
|
|
@@ -44313,7 +44461,8 @@ var require_connection_config = __commonJS((exports, module) => {
|
|
|
44313
44461
|
"MULTI_RESULTS",
|
|
44314
44462
|
"TRANSACTIONS",
|
|
44315
44463
|
"SESSION_TRACK",
|
|
44316
|
-
"CONNECT_ATTRS"
|
|
44464
|
+
"CONNECT_ATTRS",
|
|
44465
|
+
"CLIENT_QUERY_ATTRIBUTES"
|
|
44317
44466
|
];
|
|
44318
44467
|
if (options && options.multipleStatements) {
|
|
44319
44468
|
defaultFlags.push("MULTI_STATEMENTS");
|
|
@@ -45247,6 +45396,9 @@ var require_connection2 = __commonJS((exports, module) => {
|
|
|
45247
45396
|
ping(cb) {
|
|
45248
45397
|
return this.addCommand(new Commands.Ping(cb));
|
|
45249
45398
|
}
|
|
45399
|
+
reset(cb) {
|
|
45400
|
+
return this.addCommand(new Commands.ResetConnection(cb));
|
|
45401
|
+
}
|
|
45250
45402
|
_registerSlave(opts, cb) {
|
|
45251
45403
|
return this.addCommand(new Commands.RegisterSlave(opts, cb));
|
|
45252
45404
|
}
|
|
@@ -45407,18 +45559,34 @@ var require_connection2 = __commonJS((exports, module) => {
|
|
|
45407
45559
|
module.exports = BaseConnection;
|
|
45408
45560
|
});
|
|
45409
45561
|
|
|
45562
|
+
// node_modules/mysql2/lib/promise/capture_local_err.js
|
|
45563
|
+
var require_capture_local_err = __commonJS((exports, module) => {
|
|
45564
|
+
function captureStackHolder(constructorOpt) {
|
|
45565
|
+
const holder = {};
|
|
45566
|
+
Error.captureStackTrace(holder, constructorOpt);
|
|
45567
|
+
return holder;
|
|
45568
|
+
}
|
|
45569
|
+
function applyCapturedStack(err, holder) {
|
|
45570
|
+
const stack = holder && holder.stack;
|
|
45571
|
+
if (typeof stack !== "string" || !stack)
|
|
45572
|
+
return;
|
|
45573
|
+
const lines2 = stack.split(`
|
|
45574
|
+
`);
|
|
45575
|
+
lines2[0] = `${err.name}: ${err.message}`;
|
|
45576
|
+
err.stack = lines2.join(`
|
|
45577
|
+
`);
|
|
45578
|
+
}
|
|
45579
|
+
module.exports = { captureStackHolder, applyCapturedStack };
|
|
45580
|
+
});
|
|
45581
|
+
|
|
45410
45582
|
// node_modules/mysql2/lib/promise/make_done_cb.js
|
|
45411
45583
|
var require_make_done_cb = __commonJS((exports, module) => {
|
|
45412
|
-
|
|
45584
|
+
var { applyCapturedStack } = require_capture_local_err();
|
|
45585
|
+
function makeDoneCb(resolve2, reject, stackHolder) {
|
|
45413
45586
|
return function(err, rows, fields) {
|
|
45414
45587
|
if (err) {
|
|
45415
|
-
|
|
45416
|
-
|
|
45417
|
-
localErr.errno = err.errno;
|
|
45418
|
-
localErr.sql = err.sql;
|
|
45419
|
-
localErr.sqlState = err.sqlState;
|
|
45420
|
-
localErr.sqlMessage = err.sqlMessage;
|
|
45421
|
-
reject(localErr);
|
|
45588
|
+
applyCapturedStack(err, stackHolder);
|
|
45589
|
+
reject(err);
|
|
45422
45590
|
} else {
|
|
45423
45591
|
resolve2([rows, fields]);
|
|
45424
45592
|
}
|
|
@@ -45429,6 +45597,7 @@ var require_make_done_cb = __commonJS((exports, module) => {
|
|
|
45429
45597
|
|
|
45430
45598
|
// node_modules/mysql2/lib/promise/prepared_statement_info.js
|
|
45431
45599
|
var require_prepared_statement_info = __commonJS((exports, module) => {
|
|
45600
|
+
var { captureStackHolder } = require_capture_local_err();
|
|
45432
45601
|
var makeDoneCb = require_make_done_cb();
|
|
45433
45602
|
|
|
45434
45603
|
class PromisePreparedStatementInfo {
|
|
@@ -45438,9 +45607,9 @@ var require_prepared_statement_info = __commonJS((exports, module) => {
|
|
|
45438
45607
|
}
|
|
45439
45608
|
execute(parameters) {
|
|
45440
45609
|
const s = this.statement;
|
|
45441
|
-
const
|
|
45610
|
+
const stackHolder = captureStackHolder(PromisePreparedStatementInfo.prototype.execute);
|
|
45442
45611
|
return new this.Promise((resolve2, reject) => {
|
|
45443
|
-
const done = makeDoneCb(resolve2, reject,
|
|
45612
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
45444
45613
|
if (parameters) {
|
|
45445
45614
|
s.execute(parameters, done);
|
|
45446
45615
|
} else {
|
|
@@ -45484,6 +45653,10 @@ var require_inherit_events = __commonJS((exports, module) => {
|
|
|
45484
45653
|
var require_connection3 = __commonJS((exports, module) => {
|
|
45485
45654
|
var EventEmitter = __require("events").EventEmitter;
|
|
45486
45655
|
var PromisePreparedStatementInfo = require_prepared_statement_info();
|
|
45656
|
+
var {
|
|
45657
|
+
captureStackHolder,
|
|
45658
|
+
applyCapturedStack
|
|
45659
|
+
} = require_capture_local_err();
|
|
45487
45660
|
var makeDoneCb = require_make_done_cb();
|
|
45488
45661
|
var inheritEvents = require_inherit_events();
|
|
45489
45662
|
var BaseConnection = require_connection2();
|
|
@@ -45506,12 +45679,12 @@ var require_connection3 = __commonJS((exports, module) => {
|
|
|
45506
45679
|
}
|
|
45507
45680
|
query(query, params) {
|
|
45508
45681
|
const c = this.connection;
|
|
45509
|
-
const
|
|
45682
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.query);
|
|
45510
45683
|
if (typeof params === "function") {
|
|
45511
45684
|
throw new Error("Callback function is not available with promise clients.");
|
|
45512
45685
|
}
|
|
45513
45686
|
return new this.Promise((resolve2, reject) => {
|
|
45514
|
-
const done = makeDoneCb(resolve2, reject,
|
|
45687
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
45515
45688
|
if (params !== undefined) {
|
|
45516
45689
|
c.query(query, params, done);
|
|
45517
45690
|
} else {
|
|
@@ -45521,12 +45694,12 @@ var require_connection3 = __commonJS((exports, module) => {
|
|
|
45521
45694
|
}
|
|
45522
45695
|
execute(query, params) {
|
|
45523
45696
|
const c = this.connection;
|
|
45524
|
-
const
|
|
45697
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.execute);
|
|
45525
45698
|
if (typeof params === "function") {
|
|
45526
45699
|
throw new Error("Callback function is not available with promise clients.");
|
|
45527
45700
|
}
|
|
45528
45701
|
return new this.Promise((resolve2, reject) => {
|
|
45529
|
-
const done = makeDoneCb(resolve2, reject,
|
|
45702
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
45530
45703
|
if (params !== undefined) {
|
|
45531
45704
|
c.execute(query, params, done);
|
|
45532
45705
|
} else {
|
|
@@ -45546,58 +45719,64 @@ var require_connection3 = __commonJS((exports, module) => {
|
|
|
45546
45719
|
}
|
|
45547
45720
|
beginTransaction() {
|
|
45548
45721
|
const c = this.connection;
|
|
45549
|
-
const
|
|
45722
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.beginTransaction);
|
|
45550
45723
|
return new this.Promise((resolve2, reject) => {
|
|
45551
|
-
const done = makeDoneCb(resolve2, reject,
|
|
45724
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
45552
45725
|
c.beginTransaction(done);
|
|
45553
45726
|
});
|
|
45554
45727
|
}
|
|
45555
45728
|
commit() {
|
|
45556
45729
|
const c = this.connection;
|
|
45557
|
-
const
|
|
45730
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.commit);
|
|
45558
45731
|
return new this.Promise((resolve2, reject) => {
|
|
45559
|
-
const done = makeDoneCb(resolve2, reject,
|
|
45732
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
45560
45733
|
c.commit(done);
|
|
45561
45734
|
});
|
|
45562
45735
|
}
|
|
45563
45736
|
rollback() {
|
|
45564
45737
|
const c = this.connection;
|
|
45565
|
-
const
|
|
45738
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.rollback);
|
|
45566
45739
|
return new this.Promise((resolve2, reject) => {
|
|
45567
|
-
const done = makeDoneCb(resolve2, reject,
|
|
45740
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
45568
45741
|
c.rollback(done);
|
|
45569
45742
|
});
|
|
45570
45743
|
}
|
|
45571
45744
|
ping() {
|
|
45572
45745
|
const c = this.connection;
|
|
45573
|
-
const
|
|
45746
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.ping);
|
|
45574
45747
|
return new this.Promise((resolve2, reject) => {
|
|
45575
45748
|
c.ping((err) => {
|
|
45576
45749
|
if (err) {
|
|
45577
|
-
|
|
45578
|
-
|
|
45579
|
-
localErr.errno = err.errno;
|
|
45580
|
-
localErr.sqlState = err.sqlState;
|
|
45581
|
-
localErr.sqlMessage = err.sqlMessage;
|
|
45582
|
-
reject(localErr);
|
|
45750
|
+
applyCapturedStack(err, stackHolder);
|
|
45751
|
+
reject(err);
|
|
45583
45752
|
} else {
|
|
45584
45753
|
resolve2(true);
|
|
45585
45754
|
}
|
|
45586
45755
|
});
|
|
45587
45756
|
});
|
|
45588
45757
|
}
|
|
45758
|
+
reset() {
|
|
45759
|
+
const c = this.connection;
|
|
45760
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.reset);
|
|
45761
|
+
return new this.Promise((resolve2, reject) => {
|
|
45762
|
+
c.reset((err) => {
|
|
45763
|
+
if (err) {
|
|
45764
|
+
applyCapturedStack(err, stackHolder);
|
|
45765
|
+
reject(err);
|
|
45766
|
+
} else {
|
|
45767
|
+
resolve2();
|
|
45768
|
+
}
|
|
45769
|
+
});
|
|
45770
|
+
});
|
|
45771
|
+
}
|
|
45589
45772
|
connect() {
|
|
45590
45773
|
const c = this.connection;
|
|
45591
|
-
const
|
|
45774
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.connect);
|
|
45592
45775
|
return new this.Promise((resolve2, reject) => {
|
|
45593
45776
|
c.connect((err, param) => {
|
|
45594
45777
|
if (err) {
|
|
45595
|
-
|
|
45596
|
-
|
|
45597
|
-
localErr.errno = err.errno;
|
|
45598
|
-
localErr.sqlState = err.sqlState;
|
|
45599
|
-
localErr.sqlMessage = err.sqlMessage;
|
|
45600
|
-
reject(localErr);
|
|
45778
|
+
applyCapturedStack(err, stackHolder);
|
|
45779
|
+
reject(err);
|
|
45601
45780
|
} else {
|
|
45602
45781
|
resolve2(param);
|
|
45603
45782
|
}
|
|
@@ -45607,16 +45786,12 @@ var require_connection3 = __commonJS((exports, module) => {
|
|
|
45607
45786
|
prepare(options) {
|
|
45608
45787
|
const c = this.connection;
|
|
45609
45788
|
const promiseImpl = this.Promise;
|
|
45610
|
-
const
|
|
45789
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.prepare);
|
|
45611
45790
|
return new this.Promise((resolve2, reject) => {
|
|
45612
45791
|
c.prepare(options, (err, statement) => {
|
|
45613
45792
|
if (err) {
|
|
45614
|
-
|
|
45615
|
-
|
|
45616
|
-
localErr.errno = err.errno;
|
|
45617
|
-
localErr.sqlState = err.sqlState;
|
|
45618
|
-
localErr.sqlMessage = err.sqlMessage;
|
|
45619
|
-
reject(localErr);
|
|
45793
|
+
applyCapturedStack(err, stackHolder);
|
|
45794
|
+
reject(err);
|
|
45620
45795
|
} else {
|
|
45621
45796
|
const wrappedStatement = new PromisePreparedStatementInfo(statement, promiseImpl);
|
|
45622
45797
|
resolve2(wrappedStatement);
|
|
@@ -45626,16 +45801,12 @@ var require_connection3 = __commonJS((exports, module) => {
|
|
|
45626
45801
|
}
|
|
45627
45802
|
changeUser(options) {
|
|
45628
45803
|
const c = this.connection;
|
|
45629
|
-
const
|
|
45804
|
+
const stackHolder = captureStackHolder(PromiseConnection.prototype.changeUser);
|
|
45630
45805
|
return new this.Promise((resolve2, reject) => {
|
|
45631
45806
|
c.changeUser(options, (err) => {
|
|
45632
45807
|
if (err) {
|
|
45633
|
-
|
|
45634
|
-
|
|
45635
|
-
localErr.errno = err.errno;
|
|
45636
|
-
localErr.sqlState = err.sqlState;
|
|
45637
|
-
localErr.sqlMessage = err.sqlMessage;
|
|
45638
|
-
reject(localErr);
|
|
45808
|
+
applyCapturedStack(err, stackHolder);
|
|
45809
|
+
reject(err);
|
|
45639
45810
|
} else {
|
|
45640
45811
|
resolve2();
|
|
45641
45812
|
}
|
|
@@ -45873,7 +46044,29 @@ var require_pool = __commonJS((exports, module) => {
|
|
|
45873
46044
|
cb = this._connectionQueue.shift();
|
|
45874
46045
|
process4.nextTick(this.getConnection.bind(this, cb));
|
|
45875
46046
|
}
|
|
45876
|
-
|
|
46047
|
+
return;
|
|
46048
|
+
}
|
|
46049
|
+
if (this.config.resetOnRelease && connection.reset) {
|
|
46050
|
+
connection.reset((err) => {
|
|
46051
|
+
if (err) {
|
|
46052
|
+
connection._pool = null;
|
|
46053
|
+
spliceConnection(this._allConnections, connection);
|
|
46054
|
+
connection.destroy();
|
|
46055
|
+
if (this._connectionQueue.length) {
|
|
46056
|
+
cb = this._connectionQueue.shift();
|
|
46057
|
+
process4.nextTick(this.getConnection.bind(this, cb));
|
|
46058
|
+
}
|
|
46059
|
+
return;
|
|
46060
|
+
}
|
|
46061
|
+
this._handleSuccessfulRelease(connection);
|
|
46062
|
+
});
|
|
46063
|
+
} else {
|
|
46064
|
+
this._handleSuccessfulRelease(connection);
|
|
46065
|
+
}
|
|
46066
|
+
}
|
|
46067
|
+
_handleSuccessfulRelease(connection) {
|
|
46068
|
+
let cb;
|
|
46069
|
+
if (this._connectionQueue.length) {
|
|
45877
46070
|
cb = this._connectionQueue.shift();
|
|
45878
46071
|
process4.nextTick(() => {
|
|
45879
46072
|
connection._released = false;
|
|
@@ -46025,6 +46218,10 @@ var require_pool = __commonJS((exports, module) => {
|
|
|
46025
46218
|
// node_modules/mysql2/lib/promise/pool.js
|
|
46026
46219
|
var require_pool2 = __commonJS((exports, module) => {
|
|
46027
46220
|
var EventEmitter = __require("events").EventEmitter;
|
|
46221
|
+
var {
|
|
46222
|
+
captureStackHolder,
|
|
46223
|
+
applyCapturedStack
|
|
46224
|
+
} = require_capture_local_err();
|
|
46028
46225
|
var makeDoneCb = require_make_done_cb();
|
|
46029
46226
|
var PromisePoolConnection = require_pool_connection();
|
|
46030
46227
|
var inheritEvents = require_inherit_events();
|
|
@@ -46055,12 +46252,12 @@ var require_pool2 = __commonJS((exports, module) => {
|
|
|
46055
46252
|
}
|
|
46056
46253
|
query(sql, args) {
|
|
46057
46254
|
const corePool = this.pool;
|
|
46058
|
-
const
|
|
46255
|
+
const stackHolder = captureStackHolder(PromisePool.prototype.query);
|
|
46059
46256
|
if (typeof args === "function") {
|
|
46060
46257
|
throw new Error("Callback function is not available with promise clients.");
|
|
46061
46258
|
}
|
|
46062
46259
|
return new this.Promise((resolve2, reject) => {
|
|
46063
|
-
const done = makeDoneCb(resolve2, reject,
|
|
46260
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
46064
46261
|
if (args !== undefined) {
|
|
46065
46262
|
corePool.query(sql, args, done);
|
|
46066
46263
|
} else {
|
|
@@ -46070,12 +46267,12 @@ var require_pool2 = __commonJS((exports, module) => {
|
|
|
46070
46267
|
}
|
|
46071
46268
|
execute(sql, args) {
|
|
46072
46269
|
const corePool = this.pool;
|
|
46073
|
-
const
|
|
46270
|
+
const stackHolder = captureStackHolder(PromisePool.prototype.execute);
|
|
46074
46271
|
if (typeof args === "function") {
|
|
46075
46272
|
throw new Error("Callback function is not available with promise clients.");
|
|
46076
46273
|
}
|
|
46077
46274
|
return new this.Promise((resolve2, reject) => {
|
|
46078
|
-
const done = makeDoneCb(resolve2, reject,
|
|
46275
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
46079
46276
|
if (args) {
|
|
46080
46277
|
corePool.execute(sql, args, done);
|
|
46081
46278
|
} else {
|
|
@@ -46085,16 +46282,12 @@ var require_pool2 = __commonJS((exports, module) => {
|
|
|
46085
46282
|
}
|
|
46086
46283
|
end() {
|
|
46087
46284
|
const corePool = this.pool;
|
|
46088
|
-
const
|
|
46285
|
+
const stackHolder = captureStackHolder(PromisePool.prototype.end);
|
|
46089
46286
|
return new this.Promise((resolve2, reject) => {
|
|
46090
46287
|
corePool.end((err) => {
|
|
46091
46288
|
if (err) {
|
|
46092
|
-
|
|
46093
|
-
|
|
46094
|
-
localErr.errno = err.errno;
|
|
46095
|
-
localErr.sqlState = err.sqlState;
|
|
46096
|
-
localErr.sqlMessage = err.sqlMessage;
|
|
46097
|
-
reject(localErr);
|
|
46289
|
+
applyCapturedStack(err, stackHolder);
|
|
46290
|
+
reject(err);
|
|
46098
46291
|
} else {
|
|
46099
46292
|
resolve2();
|
|
46100
46293
|
}
|
|
@@ -46154,6 +46347,7 @@ var require_pool_config = __commonJS((exports, module) => {
|
|
|
46154
46347
|
this.maxIdle = isNaN(options.maxIdle) ? this.connectionLimit : Number(options.maxIdle);
|
|
46155
46348
|
this.idleTimeout = isNaN(options.idleTimeout) ? 60000 : Number(options.idleTimeout);
|
|
46156
46349
|
this.queueLimit = isNaN(options.queueLimit) ? 0 : Number(options.queueLimit);
|
|
46350
|
+
this.resetOnRelease = options.resetOnRelease === undefined ? false : Boolean(options.resetOnRelease);
|
|
46157
46351
|
}
|
|
46158
46352
|
}
|
|
46159
46353
|
module.exports = PoolConfig;
|
|
@@ -46484,6 +46678,7 @@ var require_create_pool_cluster = __commonJS((exports, module) => {
|
|
|
46484
46678
|
|
|
46485
46679
|
// node_modules/mysql2/lib/promise/pool_cluster.js
|
|
46486
46680
|
var require_pool_cluster2 = __commonJS((exports, module) => {
|
|
46681
|
+
var { captureStackHolder } = require_capture_local_err();
|
|
46487
46682
|
var PromisePoolConnection = require_pool_connection();
|
|
46488
46683
|
var makeDoneCb = require_make_done_cb();
|
|
46489
46684
|
|
|
@@ -46506,23 +46701,23 @@ var require_pool_cluster2 = __commonJS((exports, module) => {
|
|
|
46506
46701
|
}
|
|
46507
46702
|
query(sql, values) {
|
|
46508
46703
|
const corePoolNamespace = this.poolNamespace;
|
|
46509
|
-
const
|
|
46704
|
+
const stackHolder = captureStackHolder(PromisePoolNamespace.prototype.query);
|
|
46510
46705
|
if (typeof values === "function") {
|
|
46511
46706
|
throw new Error("Callback function is not available with promise clients.");
|
|
46512
46707
|
}
|
|
46513
46708
|
return new this.Promise((resolve2, reject) => {
|
|
46514
|
-
const done = makeDoneCb(resolve2, reject,
|
|
46709
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
46515
46710
|
corePoolNamespace.query(sql, values, done);
|
|
46516
46711
|
});
|
|
46517
46712
|
}
|
|
46518
46713
|
execute(sql, values) {
|
|
46519
46714
|
const corePoolNamespace = this.poolNamespace;
|
|
46520
|
-
const
|
|
46715
|
+
const stackHolder = captureStackHolder(PromisePoolNamespace.prototype.execute);
|
|
46521
46716
|
if (typeof values === "function") {
|
|
46522
46717
|
throw new Error("Callback function is not available with promise clients.");
|
|
46523
46718
|
}
|
|
46524
46719
|
return new this.Promise((resolve2, reject) => {
|
|
46525
|
-
const done = makeDoneCb(resolve2, reject,
|
|
46720
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
46526
46721
|
corePoolNamespace.execute(sql, values, done);
|
|
46527
46722
|
});
|
|
46528
46723
|
}
|
|
@@ -46541,13 +46736,17 @@ var require_promise = __commonJS((exports) => {
|
|
|
46541
46736
|
var createPoolCluster = require_create_pool_cluster();
|
|
46542
46737
|
var PromiseConnection = require_connection3();
|
|
46543
46738
|
var PromisePool = require_pool2();
|
|
46739
|
+
var {
|
|
46740
|
+
captureStackHolder,
|
|
46741
|
+
applyCapturedStack
|
|
46742
|
+
} = require_capture_local_err();
|
|
46544
46743
|
var makeDoneCb = require_make_done_cb();
|
|
46545
46744
|
var PromisePoolConnection = require_pool_connection();
|
|
46546
46745
|
var inheritEvents = require_inherit_events();
|
|
46547
46746
|
var PromisePoolNamespace = require_pool_cluster2();
|
|
46548
46747
|
function createConnectionPromise(opts) {
|
|
46549
46748
|
const coreConnection = createConnection(opts);
|
|
46550
|
-
const
|
|
46749
|
+
const stackHolder = captureStackHolder(createConnectionPromise);
|
|
46551
46750
|
const thePromise = opts.Promise || Promise;
|
|
46552
46751
|
if (!thePromise) {
|
|
46553
46752
|
throw new Error("no Promise implementation available." + "Use promise-enabled node version or pass userland Promise" + " implementation as parameter, for example: { Promise: require('bluebird') }");
|
|
@@ -46557,11 +46756,8 @@ var require_promise = __commonJS((exports) => {
|
|
|
46557
46756
|
resolve2(new PromiseConnection(coreConnection, thePromise));
|
|
46558
46757
|
});
|
|
46559
46758
|
coreConnection.once("error", (err) => {
|
|
46560
|
-
|
|
46561
|
-
|
|
46562
|
-
createConnectionErr.errno = err.errno;
|
|
46563
|
-
createConnectionErr.sqlState = err.sqlState;
|
|
46564
|
-
reject(createConnectionErr);
|
|
46759
|
+
applyCapturedStack(err, stackHolder);
|
|
46760
|
+
reject(err);
|
|
46565
46761
|
});
|
|
46566
46762
|
});
|
|
46567
46763
|
}
|
|
@@ -46595,23 +46791,23 @@ var require_promise = __commonJS((exports) => {
|
|
|
46595
46791
|
}
|
|
46596
46792
|
query(sql, args) {
|
|
46597
46793
|
const corePoolCluster = this.poolCluster;
|
|
46598
|
-
const
|
|
46794
|
+
const stackHolder = captureStackHolder(PromisePoolCluster.prototype.query);
|
|
46599
46795
|
if (typeof args === "function") {
|
|
46600
46796
|
throw new Error("Callback function is not available with promise clients.");
|
|
46601
46797
|
}
|
|
46602
46798
|
return new this.Promise((resolve2, reject) => {
|
|
46603
|
-
const done = makeDoneCb(resolve2, reject,
|
|
46799
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
46604
46800
|
corePoolCluster.query(sql, args, done);
|
|
46605
46801
|
});
|
|
46606
46802
|
}
|
|
46607
46803
|
execute(sql, args) {
|
|
46608
46804
|
const corePoolCluster = this.poolCluster;
|
|
46609
|
-
const
|
|
46805
|
+
const stackHolder = captureStackHolder(PromisePoolCluster.prototype.execute);
|
|
46610
46806
|
if (typeof args === "function") {
|
|
46611
46807
|
throw new Error("Callback function is not available with promise clients.");
|
|
46612
46808
|
}
|
|
46613
46809
|
return new this.Promise((resolve2, reject) => {
|
|
46614
|
-
const done = makeDoneCb(resolve2, reject,
|
|
46810
|
+
const done = makeDoneCb(resolve2, reject, stackHolder);
|
|
46615
46811
|
corePoolCluster.execute(sql, args, done);
|
|
46616
46812
|
});
|
|
46617
46813
|
}
|
|
@@ -46620,16 +46816,12 @@ var require_promise = __commonJS((exports) => {
|
|
|
46620
46816
|
}
|
|
46621
46817
|
end() {
|
|
46622
46818
|
const corePoolCluster = this.poolCluster;
|
|
46623
|
-
const
|
|
46819
|
+
const stackHolder = captureStackHolder(PromisePoolCluster.prototype.end);
|
|
46624
46820
|
return new this.Promise((resolve2, reject) => {
|
|
46625
46821
|
corePoolCluster.end((err) => {
|
|
46626
46822
|
if (err) {
|
|
46627
|
-
|
|
46628
|
-
|
|
46629
|
-
localErr.errno = err.errno;
|
|
46630
|
-
localErr.sqlState = err.sqlState;
|
|
46631
|
-
localErr.sqlMessage = err.sqlMessage;
|
|
46632
|
-
reject(localErr);
|
|
46823
|
+
applyCapturedStack(err, stackHolder);
|
|
46824
|
+
reject(err);
|
|
46633
46825
|
} else {
|
|
46634
46826
|
resolve2();
|
|
46635
46827
|
}
|
|
@@ -78148,7 +78340,11 @@ var init_redis = __esm(() => {
|
|
|
78148
78340
|
"SCAN",
|
|
78149
78341
|
"HSCAN",
|
|
78150
78342
|
"SSCAN",
|
|
78151
|
-
"ZSCAN"
|
|
78343
|
+
"ZSCAN",
|
|
78344
|
+
"CLIENT",
|
|
78345
|
+
"INFO",
|
|
78346
|
+
"CLUSTER",
|
|
78347
|
+
"SLOWLOG"
|
|
78152
78348
|
]);
|
|
78153
78349
|
REDIS_HARD_REJECT = new Set([
|
|
78154
78350
|
"FLUSHDB",
|
|
@@ -78424,6 +78620,7 @@ function parseFrontmatter(yaml, input) {
|
|
|
78424
78620
|
const params = normaliseParams(raw.params, input);
|
|
78425
78621
|
const tags = Array.isArray(raw.tags) ? raw.tags.map(String) : [];
|
|
78426
78622
|
const index = typeof raw.index === "string" ? raw.index : undefined;
|
|
78623
|
+
const intent = normaliseIntent(raw.intent, input);
|
|
78427
78624
|
return {
|
|
78428
78625
|
meta: {
|
|
78429
78626
|
name: typeof raw.name === "string" ? raw.name : "",
|
|
@@ -78432,11 +78629,20 @@ function parseFrontmatter(yaml, input) {
|
|
|
78432
78629
|
engine,
|
|
78433
78630
|
index,
|
|
78434
78631
|
params,
|
|
78435
|
-
tags
|
|
78632
|
+
tags,
|
|
78633
|
+
intent
|
|
78436
78634
|
},
|
|
78437
78635
|
warnings
|
|
78438
78636
|
};
|
|
78439
78637
|
}
|
|
78638
|
+
function normaliseIntent(value, input) {
|
|
78639
|
+
if (value === undefined || value === null)
|
|
78640
|
+
return;
|
|
78641
|
+
if (typeof value !== "string" || value.length === 0 || !INTENT_RE.test(value)) {
|
|
78642
|
+
throw new SavedQueryError(`Snippet '${input.key}' has invalid intent: '${String(value)}' (must match ${INTENT_RE.source})`, "INVALID_INTENT", input.file);
|
|
78643
|
+
}
|
|
78644
|
+
return value;
|
|
78645
|
+
}
|
|
78440
78646
|
function normaliseEngine(value, warnings, input) {
|
|
78441
78647
|
if (value === undefined || value === null || value === "") {
|
|
78442
78648
|
warnings.push("Snippet has no engine declaration; assuming any engine");
|
|
@@ -78573,13 +78779,14 @@ function stripCommentsAndStrings2(sql) {
|
|
|
78573
78779
|
}
|
|
78574
78780
|
return out;
|
|
78575
78781
|
}
|
|
78576
|
-
var MAX_BYTES, VALID_TYPES, VALID_ENGINES;
|
|
78782
|
+
var MAX_BYTES, VALID_TYPES, VALID_ENGINES, INTENT_RE;
|
|
78577
78783
|
var init_parser = __esm(() => {
|
|
78578
78784
|
init_strategies();
|
|
78579
78785
|
init_types2();
|
|
78580
78786
|
MAX_BYTES = 64 * 1024;
|
|
78581
78787
|
VALID_TYPES = ["int", "string", "float", "bool", "date", "datetime"];
|
|
78582
78788
|
VALID_ENGINES = ["postgres", "mysql", "elasticsearch", "redis"];
|
|
78789
|
+
INTENT_RE = /^[a-z][a-z0-9.-]*$/;
|
|
78583
78790
|
});
|
|
78584
78791
|
|
|
78585
78792
|
// src/core/saved-queries/loader.ts
|
|
@@ -78734,26 +78941,55 @@ var init_runner = __esm(() => {
|
|
|
78734
78941
|
init_types2();
|
|
78735
78942
|
});
|
|
78736
78943
|
|
|
78944
|
+
// src/utils/package-root.ts
|
|
78945
|
+
import * as path from "path";
|
|
78946
|
+
function findPackageRoot() {
|
|
78947
|
+
if (cached)
|
|
78948
|
+
return cached;
|
|
78949
|
+
let dir = HERE;
|
|
78950
|
+
for (let i = 0;i < 6; i++) {
|
|
78951
|
+
if (Bun.file(path.join(dir, "package.json")).size > 0) {
|
|
78952
|
+
cached = dir;
|
|
78953
|
+
return dir;
|
|
78954
|
+
}
|
|
78955
|
+
const parent = path.dirname(dir);
|
|
78956
|
+
if (parent === dir)
|
|
78957
|
+
break;
|
|
78958
|
+
dir = parent;
|
|
78959
|
+
}
|
|
78960
|
+
cached = path.resolve(HERE, "..", "..");
|
|
78961
|
+
return cached;
|
|
78962
|
+
}
|
|
78963
|
+
function packageAssetPath(...segments) {
|
|
78964
|
+
return path.join(findPackageRoot(), "assets", ...segments);
|
|
78965
|
+
}
|
|
78966
|
+
var cached = null, HERE;
|
|
78967
|
+
var init_package_root = __esm(() => {
|
|
78968
|
+
HERE = import.meta.dir;
|
|
78969
|
+
});
|
|
78970
|
+
|
|
78737
78971
|
// src/core/saved-queries/snippet-paths.ts
|
|
78738
|
-
import { join as
|
|
78972
|
+
import { join as join12 } from "path";
|
|
78739
78973
|
function resolveBuiltinDir() {
|
|
78740
|
-
return
|
|
78974
|
+
return packageAssetPath("snippets");
|
|
78741
78975
|
}
|
|
78742
78976
|
function resolveSnippetDirs(workspaceRoot) {
|
|
78743
78977
|
return {
|
|
78744
78978
|
builtinDir: resolveBuiltinDir(),
|
|
78745
|
-
sharedDir:
|
|
78746
|
-
localDir:
|
|
78979
|
+
sharedDir: join12(workspaceRoot, ".dbcli-shared", "queries"),
|
|
78980
|
+
localDir: join12(workspaceRoot, ".dbcli", "queries")
|
|
78747
78981
|
};
|
|
78748
78982
|
}
|
|
78749
78983
|
function snippetKeyToFile(workspaceRoot, key2, source) {
|
|
78750
78984
|
const rel = key2.replace(/^@/, "") + ".sql";
|
|
78751
78985
|
if (source === "builtin")
|
|
78752
|
-
return
|
|
78986
|
+
return join12(resolveBuiltinDir(), rel);
|
|
78753
78987
|
const dir = source === "shared" ? ".dbcli-shared/queries" : ".dbcli/queries";
|
|
78754
|
-
return
|
|
78988
|
+
return join12(workspaceRoot, dir, rel);
|
|
78755
78989
|
}
|
|
78756
|
-
var init_snippet_paths = () => {
|
|
78990
|
+
var init_snippet_paths = __esm(() => {
|
|
78991
|
+
init_package_root();
|
|
78992
|
+
});
|
|
78757
78993
|
|
|
78758
78994
|
// src/core/saved-queries/engine-map.ts
|
|
78759
78995
|
function mapSystemToEngine(system) {
|
|
@@ -78826,8 +79062,8 @@ var exports_queries_rename = {};
|
|
|
78826
79062
|
__export(exports_queries_rename, {
|
|
78827
79063
|
queriesRename: () => queriesRename
|
|
78828
79064
|
});
|
|
78829
|
-
import { rename, mkdir } from "fs/promises";
|
|
78830
|
-
import { dirname } from "path";
|
|
79065
|
+
import { rename, mkdir as mkdir2 } from "fs/promises";
|
|
79066
|
+
import { dirname as dirname2 } from "path";
|
|
78831
79067
|
async function queriesRename(oldName, newName, options = {}) {
|
|
78832
79068
|
if (!oldName.startsWith("@") || !newName.startsWith("@")) {
|
|
78833
79069
|
throw new Error(`Both names must start with '@'`);
|
|
@@ -78848,7 +79084,7 @@ async function queriesRename(oldName, newName, options = {}) {
|
|
|
78848
79084
|
for (const v of local) {
|
|
78849
79085
|
const dst = snippetKeyToFile(cwd, newName, "local");
|
|
78850
79086
|
const dstWithSuffix = preserveEngineSuffix(v.query.file, dst);
|
|
78851
|
-
await
|
|
79087
|
+
await mkdir2(dirname2(dstWithSuffix), { recursive: true });
|
|
78852
79088
|
await rename(v.query.file, dstWithSuffix);
|
|
78853
79089
|
await rewriteFrontmatterName(dstWithSuffix, newName.slice(1));
|
|
78854
79090
|
console.log(`renamed ${v.query.file} \u2192 ${dstWithSuffix}`);
|
|
@@ -78874,8 +79110,8 @@ var exports_queries_copy = {};
|
|
|
78874
79110
|
__export(exports_queries_copy, {
|
|
78875
79111
|
queriesCopy: () => queriesCopy
|
|
78876
79112
|
});
|
|
78877
|
-
import { mkdir as
|
|
78878
|
-
import { dirname as
|
|
79113
|
+
import { mkdir as mkdir3, copyFile } from "fs/promises";
|
|
79114
|
+
import { dirname as dirname3, basename as basename2 } from "path";
|
|
78879
79115
|
async function queriesCopy(src, dst, options = {}) {
|
|
78880
79116
|
if (!src.startsWith("@") || !dst.startsWith("@")) {
|
|
78881
79117
|
throw new Error(`Both names must start with '@'`);
|
|
@@ -78893,7 +79129,7 @@ async function queriesCopy(src, dst, options = {}) {
|
|
|
78893
79129
|
}
|
|
78894
79130
|
for (const v of variants) {
|
|
78895
79131
|
const dstFile = mapEngineSuffix(v.query.file, snippetKeyToFile(cwd, dst, "local"));
|
|
78896
|
-
await
|
|
79132
|
+
await mkdir3(dirname3(dstFile), { recursive: true });
|
|
78897
79133
|
await copyFile(v.query.file, dstFile);
|
|
78898
79134
|
console.log(`copied ${v.query.file} \u2192 ${dstFile}`);
|
|
78899
79135
|
}
|
|
@@ -78911,8 +79147,8 @@ var exports_queries_import = {};
|
|
|
78911
79147
|
__export(exports_queries_import, {
|
|
78912
79148
|
queriesImport: () => queriesImport
|
|
78913
79149
|
});
|
|
78914
|
-
import { stat, mkdir as
|
|
78915
|
-
import { basename as basename3, join as
|
|
79150
|
+
import { stat, mkdir as mkdir4, copyFile as copyFile2 } from "fs/promises";
|
|
79151
|
+
import { basename as basename3, join as join13, extname } from "path";
|
|
78916
79152
|
async function queriesImport(filePath, options = {}) {
|
|
78917
79153
|
const cwd = options.cwd ?? process.cwd();
|
|
78918
79154
|
if (extname(filePath) !== ".sql") {
|
|
@@ -78923,9 +79159,9 @@ async function queriesImport(filePath, options = {}) {
|
|
|
78923
79159
|
const baseName = options.as ? options.as.replace(/^@/, "") : basename3(filePath, ".sql").replace(/\.(postgres|mysql)$/, "");
|
|
78924
79160
|
const key2 = "@" + baseName;
|
|
78925
79161
|
parseSavedQuery({ key: key2, file: filePath, source: "local", text: text2 });
|
|
78926
|
-
const targetDir =
|
|
78927
|
-
await
|
|
78928
|
-
const target =
|
|
79162
|
+
const targetDir = join13(cwd, ".dbcli/queries");
|
|
79163
|
+
await mkdir4(targetDir, { recursive: true });
|
|
79164
|
+
const target = join13(targetDir, basename3(filePath));
|
|
78929
79165
|
if (await Bun.file(target).exists()) {
|
|
78930
79166
|
if (!options.force) {
|
|
78931
79167
|
const ok = await esm_default4({ message: `Overwrite ${target}?`, default: false });
|
|
@@ -78995,7 +79231,7 @@ var {
|
|
|
78995
79231
|
// package.json
|
|
78996
79232
|
var package_default = {
|
|
78997
79233
|
name: "@carllee1983/dbcli",
|
|
78998
|
-
version: "1.
|
|
79234
|
+
version: "1.11.0",
|
|
78999
79235
|
description: "Database CLI for AI agents",
|
|
79000
79236
|
type: "module",
|
|
79001
79237
|
publishConfig: {
|
|
@@ -79046,31 +79282,29 @@ var package_default = {
|
|
|
79046
79282
|
"test:docker": "docker compose -f docker-compose.test.yml up -d --wait && bun test tests/integration/adapters; docker compose -f docker-compose.test.yml down",
|
|
79047
79283
|
typecheck: "tsc --noEmit --pretty false",
|
|
79048
79284
|
"test:perf": "bun test ./tests/perf/*.bench.ts",
|
|
79049
|
-
lint: "eslint src tests --ext .ts",
|
|
79050
|
-
"lint:fix": "eslint src tests --ext .ts --fix",
|
|
79285
|
+
lint: "eslint src tests --ext .ts --max-warnings=0",
|
|
79286
|
+
"lint:fix": "eslint src tests --ext .ts --fix --max-warnings=0",
|
|
79051
79287
|
format: 'prettier --write "src/**/*.ts" "tests/**/*.ts"'
|
|
79052
79288
|
},
|
|
79053
79289
|
dependencies: {
|
|
79054
|
-
"cli-table3": "^0.6.
|
|
79290
|
+
"cli-table3": "^0.6.5",
|
|
79055
79291
|
commander: "13.0.0",
|
|
79056
79292
|
mongodb: "^7.2.0",
|
|
79057
|
-
mysql2: "^3.
|
|
79293
|
+
mysql2: "^3.22.3",
|
|
79058
79294
|
pg: "^8.20.0",
|
|
79059
79295
|
picocolors: "^1.1.1",
|
|
79060
|
-
zod: "^3.
|
|
79296
|
+
zod: "^3.25.76"
|
|
79061
79297
|
},
|
|
79062
79298
|
devDependencies: {
|
|
79063
|
-
"@eslint/js": "^9.
|
|
79064
|
-
"@inquirer/prompts": "^5.
|
|
79299
|
+
"@eslint/js": "^9.39.4",
|
|
79300
|
+
"@inquirer/prompts": "^5.5.0",
|
|
79065
79301
|
"@types/bun": "latest",
|
|
79066
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
79067
|
-
"@typescript-eslint/parser": "^7.
|
|
79068
|
-
eslint: "^9.
|
|
79069
|
-
|
|
79070
|
-
|
|
79071
|
-
|
|
79072
|
-
typescript: "^5.3.3",
|
|
79073
|
-
"typescript-eslint": "^8.57.2"
|
|
79302
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
79303
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
79304
|
+
eslint: "^9.39.4",
|
|
79305
|
+
prettier: "^3.8.3",
|
|
79306
|
+
typescript: "^5.9.3",
|
|
79307
|
+
"typescript-eslint": "^8.59.2"
|
|
79074
79308
|
}
|
|
79075
79309
|
};
|
|
79076
79310
|
// resources/lang/en/messages.json
|
|
@@ -79163,7 +79397,15 @@ var messages_default = {
|
|
|
79163
79397
|
first_run_hint: "Tip: commit .dbcli-shared/ to share snippets with your team.",
|
|
79164
79398
|
no_snippets: "No snippets found. Create one with: dbcli queries new @<name>",
|
|
79165
79399
|
check_ok: "\u2713 {count} snippets parsed successfully",
|
|
79166
|
-
check_failed: "\u2717 {count} snippet(s) have errors"
|
|
79400
|
+
check_failed: "\u2717 {count} snippet(s) have errors",
|
|
79401
|
+
search_description: "Search snippets by keywords (fuzzy ranking)",
|
|
79402
|
+
suggest_description: "Suggest snippets by intent prefix",
|
|
79403
|
+
search_no_keywords: "Provide at least one keyword, or try 'queries list' / 'queries suggest'.",
|
|
79404
|
+
search_no_results: "No snippets matched. Try 'queries list' or 'queries suggest <intent>'.",
|
|
79405
|
+
suggest_missing_intent: "Provide an intent (or prefix). Available: {available}",
|
|
79406
|
+
suggest_invalid_intent: "Invalid intent '{value}'. Must match ^[a-z][a-z0-9.-]*$",
|
|
79407
|
+
suggest_no_results: "No snippets with intent prefix '{intent}'. Available: {available}",
|
|
79408
|
+
no_active_connection_hint: "No active connection; showing snippets across all engines."
|
|
79167
79409
|
},
|
|
79168
79410
|
errors: {
|
|
79169
79411
|
message: "Error: {message}",
|
|
@@ -79380,7 +79622,15 @@ var messages_default2 = {
|
|
|
79380
79622
|
first_run_hint: "\u63D0\u793A\uFF1A\u5C07 .dbcli-shared/ commit \u9032\u7248\u63A7\u53EF\u8207\u5718\u968A\u5171\u4EAB\u7247\u6BB5\u3002",
|
|
79381
79623
|
no_snippets: "\u5C1A\u7121\u4EFB\u4F55\u7247\u6BB5\u3002\u57F7\u884C dbcli queries new @<name> \u5EFA\u7ACB\u3002",
|
|
79382
79624
|
check_ok: "\u2713 \u6210\u529F\u89E3\u6790 {count} \u500B\u7247\u6BB5",
|
|
79383
|
-
check_failed: "\u2717 \u6709 {count} \u500B\u7247\u6BB5\u89E3\u6790\u5931\u6557"
|
|
79625
|
+
check_failed: "\u2717 \u6709 {count} \u500B\u7247\u6BB5\u89E3\u6790\u5931\u6557",
|
|
79626
|
+
search_description: "\u4F9D\u95DC\u9375\u5B57\u641C\u5C0B snippet\uFF08fuzzy \u6392\u5E8F\uFF09",
|
|
79627
|
+
suggest_description: "\u4F9D intent prefix \u63A8\u85A6 snippet",
|
|
79628
|
+
search_no_keywords: "\u81F3\u5C11\u63D0\u4F9B\u4E00\u500B\u95DC\u9375\u5B57\uFF0C\u6216\u8A66\u8A66 'queries list' / 'queries suggest'\u3002",
|
|
79629
|
+
search_no_results: "\u6C92\u6709\u547D\u4E2D\u7684 snippet\u3002\u8A66\u8A66 'queries list' \u6216 'queries suggest <intent>'\u3002",
|
|
79630
|
+
suggest_missing_intent: "\u8ACB\u63D0\u4F9B intent\uFF08\u6216 prefix\uFF09\u3002\u53EF\u7528\uFF1A{available}",
|
|
79631
|
+
suggest_invalid_intent: "Intent '{value}' \u683C\u5F0F\u932F\u8AA4\uFF0C\u5FC5\u9808\u7B26\u5408 ^[a-z][a-z0-9.-]*$",
|
|
79632
|
+
suggest_no_results: "\u6C92\u6709 intent prefix \u70BA '{intent}' \u7684 snippet\u3002\u53EF\u7528\uFF1A{available}",
|
|
79633
|
+
no_active_connection_hint: "\u5C1A\u672A\u8A2D\u5B9A connection\uFF1B\u5217\u51FA\u6240\u6709\u5F15\u64CE\u7684 snippet\u3002"
|
|
79384
79634
|
},
|
|
79385
79635
|
errors: {
|
|
79386
79636
|
message: "\u932F\u8AA4\uFF1A{message}",
|
|
@@ -79827,6 +80077,7 @@ async function loadEnvFile(filePath) {
|
|
|
79827
80077
|
|
|
79828
80078
|
// src/core/config-binding.ts
|
|
79829
80079
|
import { createHash } from "crypto";
|
|
80080
|
+
import { mkdir, unlink } from "fs/promises";
|
|
79830
80081
|
import { homedir } from "os";
|
|
79831
80082
|
import { basename, join, resolve } from "path";
|
|
79832
80083
|
var BINDING_FILE_NAME = "config.json";
|
|
@@ -79882,11 +80133,11 @@ async function migrateLegacyProjectEnvLocal(projectPath, storagePath = getProjec
|
|
|
79882
80133
|
if (!await projectEnvFile.exists())
|
|
79883
80134
|
return;
|
|
79884
80135
|
const storageEnvPath = join(storagePath, ".env.local");
|
|
79885
|
-
await
|
|
80136
|
+
await mkdir(storagePath, { recursive: true });
|
|
79886
80137
|
if (!await Bun.file(storageEnvPath).exists()) {
|
|
79887
80138
|
await Bun.file(storageEnvPath).write(await projectEnvFile.text());
|
|
79888
80139
|
}
|
|
79889
|
-
await
|
|
80140
|
+
await unlink(projectEnvPath);
|
|
79890
80141
|
}
|
|
79891
80142
|
|
|
79892
80143
|
// src/core/config-v2.ts
|
|
@@ -84767,18 +85018,22 @@ async function qCommand(name, options, command) {
|
|
|
84767
85018
|
}));
|
|
84768
85019
|
return;
|
|
84769
85020
|
}
|
|
85021
|
+
const blacklistManager = new BlacklistManager(config);
|
|
85022
|
+
const blacklistValidator = new BlacklistValidator(blacklistManager);
|
|
85023
|
+
const family = engineFamily(engine);
|
|
85024
|
+
const targetName = family === "sql" ? extractTableName(prepared.rewrittenSql) ?? "" : family === "es" ? prepared.execHints?.index ?? "" : "";
|
|
85025
|
+
if (family !== "redis" && targetName) {
|
|
85026
|
+
blacklistValidator.checkTableBlacklist("SELECT", targetName);
|
|
85027
|
+
}
|
|
84770
85028
|
const adapter = AdapterFactory.createAdapter(config.connection);
|
|
84771
85029
|
await adapter.connect();
|
|
84772
85030
|
try {
|
|
84773
|
-
const blacklistManager = new BlacklistManager(config);
|
|
84774
|
-
const blacklistValidator = new BlacklistValidator(blacklistManager);
|
|
84775
|
-
const family = engineFamily(engine);
|
|
84776
85031
|
const indexParams = family === "es" && prepared.execHints?.index ? [prepared.execHints.index] : [];
|
|
84777
85032
|
const start = performance.now();
|
|
84778
85033
|
const result = await adapter.execute(prepared.driver.sql, family === "sql" ? prepared.driver.values : indexParams);
|
|
84779
85034
|
const executionTimeMs = Math.round(performance.now() - start);
|
|
84780
85035
|
const columnNames = result.rows[0] ? Object.keys(result.rows[0]) : [];
|
|
84781
|
-
const filtered = family === "redis" ? { filteredRows: result.rows, omittedColumns: [] } : blacklistValidator.filterColumns(
|
|
85036
|
+
const filtered = family === "redis" ? { filteredRows: result.rows, omittedColumns: [] } : blacklistValidator.filterColumns(targetName, result.rows, columnNames);
|
|
84782
85037
|
const formatter = new QueryResultFormatter;
|
|
84783
85038
|
const out = formatter.format({
|
|
84784
85039
|
rows: filtered.filteredRows,
|
|
@@ -84790,7 +85045,7 @@ async function qCommand(name, options, command) {
|
|
|
84790
85045
|
statement: "SELECT",
|
|
84791
85046
|
affectedRows: 0,
|
|
84792
85047
|
...filtered.omittedColumns.length > 0 ? {
|
|
84793
|
-
securityNotification: blacklistValidator.buildSecurityNotification(
|
|
85048
|
+
securityNotification: blacklistValidator.buildSecurityNotification(targetName, filtered.omittedColumns)
|
|
84794
85049
|
} : {}
|
|
84795
85050
|
}
|
|
84796
85051
|
}, { format: options.format ?? "table" });
|
|
@@ -84812,10 +85067,10 @@ function parseCliParams(list) {
|
|
|
84812
85067
|
}
|
|
84813
85068
|
return out;
|
|
84814
85069
|
}
|
|
84815
|
-
async function readParamFile(
|
|
84816
|
-
if (!
|
|
85070
|
+
async function readParamFile(path2) {
|
|
85071
|
+
if (!path2)
|
|
84817
85072
|
return {};
|
|
84818
|
-
const text2 = await Bun.file(
|
|
85073
|
+
const text2 = await Bun.file(path2).text();
|
|
84819
85074
|
const parsed = JSON.parse(text2);
|
|
84820
85075
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
84821
85076
|
throw new Error(`--param-file must be a JSON object (got ${typeof parsed})`);
|
|
@@ -84844,10 +85099,168 @@ function handleQError(error) {
|
|
|
84844
85099
|
}
|
|
84845
85100
|
|
|
84846
85101
|
// src/commands/queries.ts
|
|
84847
|
-
import { mkdir as
|
|
84848
|
-
import { dirname as
|
|
85102
|
+
import { mkdir as mkdir5, writeFile as writeFile2 } from "fs/promises";
|
|
85103
|
+
import { dirname as dirname4 } from "path";
|
|
84849
85104
|
import { spawn } from "child_process";
|
|
84850
85105
|
init_saved_queries();
|
|
85106
|
+
|
|
85107
|
+
// src/core/saved-queries/fold.ts
|
|
85108
|
+
var SOURCE_RANK2 = { builtin: 0, shared: 1, local: 2 };
|
|
85109
|
+
function foldVariants(key2, variants) {
|
|
85110
|
+
const sources = unique(variants.map((v) => v.query.source)).sort();
|
|
85111
|
+
const engines = unique(variants.flatMap((v) => v.query.meta.engine ?? [])).sort();
|
|
85112
|
+
const tags = unique(variants.flatMap((v) => v.query.meta.tags ?? []));
|
|
85113
|
+
const top = variants.slice().sort((a, b) => SOURCE_RANK2[b.query.source] - SOURCE_RANK2[a.query.source])[0];
|
|
85114
|
+
return {
|
|
85115
|
+
name: key2,
|
|
85116
|
+
sources,
|
|
85117
|
+
engines,
|
|
85118
|
+
params: top.query.meta.params.map((p) => p.name),
|
|
85119
|
+
description: top.query.meta.description ?? "",
|
|
85120
|
+
tags,
|
|
85121
|
+
intent: top.query.meta.intent,
|
|
85122
|
+
hasLocalOverride: variants.some((v) => v.hasLocalOverride)
|
|
85123
|
+
};
|
|
85124
|
+
}
|
|
85125
|
+
function unique(xs) {
|
|
85126
|
+
return [...new Set(xs)];
|
|
85127
|
+
}
|
|
85128
|
+
|
|
85129
|
+
// src/core/saved-queries/search.ts
|
|
85130
|
+
var WEIGHT_NAME = 3;
|
|
85131
|
+
var WEIGHT_INTENT = 2;
|
|
85132
|
+
var WEIGHT_TAGS = 2;
|
|
85133
|
+
var WEIGHT_DESCRIPTION = 1;
|
|
85134
|
+
var SOURCE_RANK3 = { local: 0, shared: 1, builtin: 2 };
|
|
85135
|
+
function searchSnippets(folded, input) {
|
|
85136
|
+
const tokens = input.query.trim().toLowerCase().split(/\s+/).filter((t2) => t2.length > 0);
|
|
85137
|
+
if (tokens.length === 0)
|
|
85138
|
+
return [];
|
|
85139
|
+
const scored = [];
|
|
85140
|
+
for (const r of folded) {
|
|
85141
|
+
if (input.engineFilter && r.engines.length > 0 && !r.engines.includes(input.engineFilter)) {
|
|
85142
|
+
continue;
|
|
85143
|
+
}
|
|
85144
|
+
if (input.source && input.source !== "all" && !r.sources.includes(input.source)) {
|
|
85145
|
+
continue;
|
|
85146
|
+
}
|
|
85147
|
+
const name = r.name.toLowerCase();
|
|
85148
|
+
const description = r.description.toLowerCase();
|
|
85149
|
+
const intent = (r.intent ?? "").toLowerCase();
|
|
85150
|
+
const tagsJoined = r.tags.join(" ").toLowerCase();
|
|
85151
|
+
const matched = [];
|
|
85152
|
+
let totalWeight = 0;
|
|
85153
|
+
let allHit = true;
|
|
85154
|
+
for (const tok of tokens) {
|
|
85155
|
+
let bestForToken = 0;
|
|
85156
|
+
if (name.includes(tok))
|
|
85157
|
+
bestForToken = Math.max(bestForToken, WEIGHT_NAME);
|
|
85158
|
+
if (intent && intent.includes(tok))
|
|
85159
|
+
bestForToken = Math.max(bestForToken, WEIGHT_INTENT);
|
|
85160
|
+
if (tagsJoined.includes(tok))
|
|
85161
|
+
bestForToken = Math.max(bestForToken, WEIGHT_TAGS);
|
|
85162
|
+
if (description.includes(tok))
|
|
85163
|
+
bestForToken = Math.max(bestForToken, WEIGHT_DESCRIPTION);
|
|
85164
|
+
if (bestForToken === 0) {
|
|
85165
|
+
allHit = false;
|
|
85166
|
+
break;
|
|
85167
|
+
}
|
|
85168
|
+
matched.push(tok);
|
|
85169
|
+
totalWeight += bestForToken;
|
|
85170
|
+
}
|
|
85171
|
+
if (!allHit)
|
|
85172
|
+
continue;
|
|
85173
|
+
const score = totalWeight / (WEIGHT_NAME * tokens.length);
|
|
85174
|
+
const source = pickTopSource(r.sources);
|
|
85175
|
+
scored.push({
|
|
85176
|
+
name: r.name,
|
|
85177
|
+
engine: r.engines[0] ?? null,
|
|
85178
|
+
source,
|
|
85179
|
+
score,
|
|
85180
|
+
matched,
|
|
85181
|
+
description: r.description,
|
|
85182
|
+
intent: r.intent,
|
|
85183
|
+
tags: r.tags
|
|
85184
|
+
});
|
|
85185
|
+
}
|
|
85186
|
+
scored.sort((a, b) => {
|
|
85187
|
+
if (a.score !== b.score)
|
|
85188
|
+
return b.score - a.score;
|
|
85189
|
+
const sa = SOURCE_RANK3[a.source];
|
|
85190
|
+
const sb = SOURCE_RANK3[b.source];
|
|
85191
|
+
if (sa !== sb)
|
|
85192
|
+
return sa - sb;
|
|
85193
|
+
return a.name.localeCompare(b.name);
|
|
85194
|
+
});
|
|
85195
|
+
const limit = input.limit ?? 10;
|
|
85196
|
+
return scored.slice(0, limit);
|
|
85197
|
+
}
|
|
85198
|
+
function pickTopSource(sources) {
|
|
85199
|
+
let best = "builtin";
|
|
85200
|
+
let bestRank = SOURCE_RANK3.builtin;
|
|
85201
|
+
for (const s of sources) {
|
|
85202
|
+
if (SOURCE_RANK3[s] < bestRank) {
|
|
85203
|
+
bestRank = SOURCE_RANK3[s];
|
|
85204
|
+
best = s;
|
|
85205
|
+
}
|
|
85206
|
+
}
|
|
85207
|
+
return best;
|
|
85208
|
+
}
|
|
85209
|
+
|
|
85210
|
+
// src/core/saved-queries/suggest.ts
|
|
85211
|
+
var SOURCE_RANK4 = { local: 0, shared: 1, builtin: 2 };
|
|
85212
|
+
function suggestSnippets(folded, input) {
|
|
85213
|
+
const target = input.intent;
|
|
85214
|
+
const out = [];
|
|
85215
|
+
for (const r of folded) {
|
|
85216
|
+
if (!r.intent)
|
|
85217
|
+
continue;
|
|
85218
|
+
if (!matchesIntentPrefix(r.intent, target))
|
|
85219
|
+
continue;
|
|
85220
|
+
if (input.engineFilter && r.engines.length > 0 && !r.engines.includes(input.engineFilter)) {
|
|
85221
|
+
continue;
|
|
85222
|
+
}
|
|
85223
|
+
if (input.source && input.source !== "all" && !r.sources.includes(input.source)) {
|
|
85224
|
+
continue;
|
|
85225
|
+
}
|
|
85226
|
+
out.push({
|
|
85227
|
+
name: r.name,
|
|
85228
|
+
engine: r.engines[0] ?? null,
|
|
85229
|
+
source: pickTopSource2(r.sources),
|
|
85230
|
+
intent: r.intent,
|
|
85231
|
+
description: r.description,
|
|
85232
|
+
tags: r.tags
|
|
85233
|
+
});
|
|
85234
|
+
}
|
|
85235
|
+
out.sort((a, b) => {
|
|
85236
|
+
if (a.intent !== b.intent)
|
|
85237
|
+
return a.intent.localeCompare(b.intent);
|
|
85238
|
+
const ea = a.engine ?? "";
|
|
85239
|
+
const eb = b.engine ?? "";
|
|
85240
|
+
if (ea !== eb)
|
|
85241
|
+
return ea.localeCompare(eb);
|
|
85242
|
+
return a.name.localeCompare(b.name);
|
|
85243
|
+
});
|
|
85244
|
+
return out;
|
|
85245
|
+
}
|
|
85246
|
+
function matchesIntentPrefix(intent, target) {
|
|
85247
|
+
if (intent === target)
|
|
85248
|
+
return true;
|
|
85249
|
+
return intent.startsWith(target + ".");
|
|
85250
|
+
}
|
|
85251
|
+
function pickTopSource2(sources) {
|
|
85252
|
+
let best = "builtin";
|
|
85253
|
+
let bestRank = SOURCE_RANK4.builtin;
|
|
85254
|
+
for (const s of sources) {
|
|
85255
|
+
if (SOURCE_RANK4[s] < bestRank) {
|
|
85256
|
+
bestRank = SOURCE_RANK4[s];
|
|
85257
|
+
best = s;
|
|
85258
|
+
}
|
|
85259
|
+
}
|
|
85260
|
+
return best;
|
|
85261
|
+
}
|
|
85262
|
+
|
|
85263
|
+
// src/commands/queries.ts
|
|
84851
85264
|
async function deriveEngine() {
|
|
84852
85265
|
try {
|
|
84853
85266
|
const cfg = await configModule.read(resolveConfigPath(undefined, {}));
|
|
@@ -84884,25 +85297,6 @@ async function queriesList(options) {
|
|
|
84884
85297
|
for (const c of cells)
|
|
84885
85298
|
console.log(fmt(c));
|
|
84886
85299
|
}
|
|
84887
|
-
var FOLD_SOURCE_RANK = { builtin: 0, shared: 1, local: 2 };
|
|
84888
|
-
function foldVariants(key2, variants) {
|
|
84889
|
-
const sources = unique(variants.map((v) => v.query.source)).sort();
|
|
84890
|
-
const engines = unique(variants.flatMap((v) => v.query.meta.engine ?? [])).sort();
|
|
84891
|
-
const tags = unique(variants.flatMap((v) => v.query.meta.tags ?? []));
|
|
84892
|
-
const top = variants.slice().sort((a, b) => FOLD_SOURCE_RANK[b.query.source] - FOLD_SOURCE_RANK[a.query.source])[0];
|
|
84893
|
-
return {
|
|
84894
|
-
name: key2,
|
|
84895
|
-
sources,
|
|
84896
|
-
engines,
|
|
84897
|
-
params: top.query.meta.params.map((p) => p.name),
|
|
84898
|
-
description: top.query.meta.description ?? "",
|
|
84899
|
-
tags,
|
|
84900
|
-
hasLocalOverride: variants.some((v) => v.hasLocalOverride)
|
|
84901
|
-
};
|
|
84902
|
-
}
|
|
84903
|
-
function unique(xs) {
|
|
84904
|
-
return [...new Set(xs)];
|
|
84905
|
-
}
|
|
84906
85300
|
function snippetToJson(s) {
|
|
84907
85301
|
return {
|
|
84908
85302
|
name: s.query.meta.key,
|
|
@@ -84975,7 +85369,7 @@ async function queriesNew(name, options) {
|
|
|
84975
85369
|
process.exit(1);
|
|
84976
85370
|
return;
|
|
84977
85371
|
}
|
|
84978
|
-
await
|
|
85372
|
+
await mkdir5(dirname4(file), { recursive: true });
|
|
84979
85373
|
await writeFile2(file, scaffold(name), "utf8");
|
|
84980
85374
|
console.log(`Created ${file}`);
|
|
84981
85375
|
if (source === "shared")
|
|
@@ -85037,6 +85431,170 @@ async function queriesCheck(options) {
|
|
|
85037
85431
|
console.log(`\u2713 ${total} snippets parsed successfully`);
|
|
85038
85432
|
}
|
|
85039
85433
|
}
|
|
85434
|
+
async function queriesSearch(keywords, options) {
|
|
85435
|
+
const query = keywords.join(" ").trim();
|
|
85436
|
+
if (!query) {
|
|
85437
|
+
console.error(t("queries.search_no_keywords"));
|
|
85438
|
+
process.exit(2);
|
|
85439
|
+
return;
|
|
85440
|
+
}
|
|
85441
|
+
const allowed = ["postgres", "mysql", "redis", "elasticsearch", "all"];
|
|
85442
|
+
if (options.engine && !allowed.includes(options.engine)) {
|
|
85443
|
+
console.error(`Unknown engine '${options.engine}'. Allowed: ${allowed.join(", ")}.`);
|
|
85444
|
+
process.exit(2);
|
|
85445
|
+
return;
|
|
85446
|
+
}
|
|
85447
|
+
const limit = options.limit !== undefined ? Number(options.limit) : 10;
|
|
85448
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
85449
|
+
console.error(`--limit must be a positive integer (got '${options.limit}')`);
|
|
85450
|
+
process.exit(2);
|
|
85451
|
+
return;
|
|
85452
|
+
}
|
|
85453
|
+
const map = await loadSnippets(resolveSnippetDirs(process.cwd()));
|
|
85454
|
+
const folded = [...map.entries()].map(([key2, variants]) => foldVariants(key2, variants));
|
|
85455
|
+
let engineFilter;
|
|
85456
|
+
if (options.engine && options.engine !== "all") {
|
|
85457
|
+
engineFilter = options.engine;
|
|
85458
|
+
} else if (!options.engine) {
|
|
85459
|
+
const inferred = await deriveEngineOrNull();
|
|
85460
|
+
if (inferred)
|
|
85461
|
+
engineFilter = inferred;
|
|
85462
|
+
else
|
|
85463
|
+
console.error(t("queries.no_active_connection_hint"));
|
|
85464
|
+
}
|
|
85465
|
+
const input = {
|
|
85466
|
+
query,
|
|
85467
|
+
engineFilter,
|
|
85468
|
+
source: options.source,
|
|
85469
|
+
limit
|
|
85470
|
+
};
|
|
85471
|
+
const hits = searchSnippets(folded, input);
|
|
85472
|
+
if (options.format === "json") {
|
|
85473
|
+
console.log(JSON.stringify(hits.map(toSearchJson), null, 2));
|
|
85474
|
+
return;
|
|
85475
|
+
}
|
|
85476
|
+
if (hits.length === 0) {
|
|
85477
|
+
console.log(t("queries.search_no_results"));
|
|
85478
|
+
return;
|
|
85479
|
+
}
|
|
85480
|
+
renderSearchTable(hits, options.includeInternal === true);
|
|
85481
|
+
}
|
|
85482
|
+
async function deriveEngineOrNull() {
|
|
85483
|
+
try {
|
|
85484
|
+
const cfg = await configModule.read(resolveConfigPath(undefined, {}));
|
|
85485
|
+
if (cfg.connection) {
|
|
85486
|
+
const e = mapSystemToEngine(cfg.connection.system);
|
|
85487
|
+
if (e !== "mongodb")
|
|
85488
|
+
return e;
|
|
85489
|
+
}
|
|
85490
|
+
} catch {}
|
|
85491
|
+
return null;
|
|
85492
|
+
}
|
|
85493
|
+
function toSearchJson(h) {
|
|
85494
|
+
return {
|
|
85495
|
+
name: h.name,
|
|
85496
|
+
engine: h.engine,
|
|
85497
|
+
source: h.source,
|
|
85498
|
+
intent: h.intent ?? null,
|
|
85499
|
+
description: h.description,
|
|
85500
|
+
tags: h.tags,
|
|
85501
|
+
score: h.score
|
|
85502
|
+
};
|
|
85503
|
+
}
|
|
85504
|
+
function renderSearchTable(hits, includeScore) {
|
|
85505
|
+
const header = includeScore ? ["NAME", "ENGINE", "SOURCE", "INTENT", "SCORE", "DESCRIPTION"] : ["NAME", "ENGINE", "SOURCE", "INTENT", "DESCRIPTION"];
|
|
85506
|
+
const rows = hits.map((h) => {
|
|
85507
|
+
const base = [h.name, h.engine ?? "-", h.source, h.intent ?? "-"];
|
|
85508
|
+
if (includeScore)
|
|
85509
|
+
base.push(h.score.toFixed(3));
|
|
85510
|
+
base.push(h.description);
|
|
85511
|
+
return base;
|
|
85512
|
+
});
|
|
85513
|
+
const widths = header.map((c, i) => Math.max(c.length, ...rows.map((r) => (r[i] ?? "").length)));
|
|
85514
|
+
const fmt = (line) => line.map((c, i) => (c ?? "").padEnd(widths[i] ?? 0)).join(" ");
|
|
85515
|
+
console.log(fmt(header));
|
|
85516
|
+
for (const r of rows)
|
|
85517
|
+
console.log(fmt(r));
|
|
85518
|
+
}
|
|
85519
|
+
var INTENT_RE_CLI = /^[a-z][a-z0-9.-]*$/;
|
|
85520
|
+
async function queriesSuggest(intent, options) {
|
|
85521
|
+
const map = await loadSnippets(resolveSnippetDirs(process.cwd()));
|
|
85522
|
+
const folded = [...map.entries()].map(([key2, variants]) => foldVariants(key2, variants));
|
|
85523
|
+
const availableIntents = collectIntentPrefixes(folded);
|
|
85524
|
+
if (!intent) {
|
|
85525
|
+
console.error(t_vars("queries.suggest_missing_intent", {
|
|
85526
|
+
available: availableIntents.slice(0, 10).join(", ")
|
|
85527
|
+
}));
|
|
85528
|
+
process.exit(2);
|
|
85529
|
+
return;
|
|
85530
|
+
}
|
|
85531
|
+
if (!INTENT_RE_CLI.test(intent)) {
|
|
85532
|
+
console.error(t_vars("queries.suggest_invalid_intent", { value: intent }));
|
|
85533
|
+
process.exit(2);
|
|
85534
|
+
return;
|
|
85535
|
+
}
|
|
85536
|
+
const allowed = ["postgres", "mysql", "redis", "elasticsearch", "all"];
|
|
85537
|
+
if (options.engine && !allowed.includes(options.engine)) {
|
|
85538
|
+
console.error(`Unknown engine '${options.engine}'. Allowed: ${allowed.join(", ")}.`);
|
|
85539
|
+
process.exit(2);
|
|
85540
|
+
return;
|
|
85541
|
+
}
|
|
85542
|
+
let engineFilter;
|
|
85543
|
+
if (options.engine && options.engine !== "all") {
|
|
85544
|
+
engineFilter = options.engine;
|
|
85545
|
+
} else if (!options.engine) {
|
|
85546
|
+
const inferred = await deriveEngineOrNull();
|
|
85547
|
+
if (inferred)
|
|
85548
|
+
engineFilter = inferred;
|
|
85549
|
+
else
|
|
85550
|
+
console.error(t("queries.no_active_connection_hint"));
|
|
85551
|
+
}
|
|
85552
|
+
const input = { intent, engineFilter, source: options.source };
|
|
85553
|
+
const hits = suggestSnippets(folded, input);
|
|
85554
|
+
if (options.format === "json") {
|
|
85555
|
+
console.log(JSON.stringify(hits.map(toSuggestJson), null, 2));
|
|
85556
|
+
return;
|
|
85557
|
+
}
|
|
85558
|
+
if (hits.length === 0) {
|
|
85559
|
+
console.log(t_vars("queries.suggest_no_results", {
|
|
85560
|
+
intent,
|
|
85561
|
+
available: availableIntents.slice(0, 5).join(", ")
|
|
85562
|
+
}));
|
|
85563
|
+
return;
|
|
85564
|
+
}
|
|
85565
|
+
renderSuggestTable(hits);
|
|
85566
|
+
}
|
|
85567
|
+
function collectIntentPrefixes(folded) {
|
|
85568
|
+
const seen = new Set;
|
|
85569
|
+
for (const r of folded) {
|
|
85570
|
+
if (!r.intent)
|
|
85571
|
+
continue;
|
|
85572
|
+
seen.add(r.intent);
|
|
85573
|
+
const dot = r.intent.indexOf(".");
|
|
85574
|
+
if (dot > 0)
|
|
85575
|
+
seen.add(r.intent.slice(0, dot));
|
|
85576
|
+
}
|
|
85577
|
+
return [...seen].sort();
|
|
85578
|
+
}
|
|
85579
|
+
function toSuggestJson(h) {
|
|
85580
|
+
return {
|
|
85581
|
+
name: h.name,
|
|
85582
|
+
engine: h.engine,
|
|
85583
|
+
source: h.source,
|
|
85584
|
+
intent: h.intent,
|
|
85585
|
+
description: h.description,
|
|
85586
|
+
tags: h.tags
|
|
85587
|
+
};
|
|
85588
|
+
}
|
|
85589
|
+
function renderSuggestTable(hits) {
|
|
85590
|
+
const header = ["INTENT", "NAME", "ENGINE", "SOURCE", "DESCRIPTION"];
|
|
85591
|
+
const rows = hits.map((h) => [h.intent, h.name, h.engine ?? "-", h.source, h.description]);
|
|
85592
|
+
const widths = header.map((c, i) => Math.max(c.length, ...rows.map((r) => (r[i] ?? "").length)));
|
|
85593
|
+
const fmt = (line) => line.map((c, i) => (c ?? "").padEnd(widths[i] ?? 0)).join(" ");
|
|
85594
|
+
console.log(fmt(header));
|
|
85595
|
+
for (const r of rows)
|
|
85596
|
+
console.log(fmt(r));
|
|
85597
|
+
}
|
|
85040
85598
|
function scaffold(name) {
|
|
85041
85599
|
return [
|
|
85042
85600
|
"-- ---",
|
|
@@ -85102,10 +85660,10 @@ queriesCommand.command("copy <src> <dst>").description(t("queries.copy_descripti
|
|
|
85102
85660
|
process.exit(1);
|
|
85103
85661
|
}
|
|
85104
85662
|
});
|
|
85105
|
-
queriesCommand.command("import <path>").description(t("queries.import_description")).option("--force", "Overwrite existing file without prompting").option("--as <name>", "Override snippet name (defaults to filename)").action(async (
|
|
85663
|
+
queriesCommand.command("import <path>").description(t("queries.import_description")).option("--force", "Overwrite existing file without prompting").option("--as <name>", "Override snippet name (defaults to filename)").action(async (path2, options) => {
|
|
85106
85664
|
try {
|
|
85107
85665
|
const { queriesImport: queriesImport2 } = await Promise.resolve().then(() => (init_queries_import(), exports_queries_import));
|
|
85108
|
-
await queriesImport2(
|
|
85666
|
+
await queriesImport2(path2, options);
|
|
85109
85667
|
} catch (e) {
|
|
85110
85668
|
console.error(e.message);
|
|
85111
85669
|
process.exit(1);
|
|
@@ -85120,6 +85678,12 @@ queriesCommand.command("export <name>").description(t("queries.export_descriptio
|
|
|
85120
85678
|
process.exit(1);
|
|
85121
85679
|
}
|
|
85122
85680
|
});
|
|
85681
|
+
queriesCommand.command("search [keywords...]").description(t("queries.search_description")).option("--format <type>", "Output format: table, json", "table").option("--engine <engine>", "Filter: postgres | mysql | redis | elasticsearch | all").option("--source <source>", "Filter: local | shared | builtin | all").option("--limit <n>", "Max results (default 10)").option("--include-internal", "Show ranking score").action(async (keywords, options) => {
|
|
85682
|
+
await queriesSearch(keywords, options);
|
|
85683
|
+
});
|
|
85684
|
+
queriesCommand.command("suggest [intent]").description(t("queries.suggest_description")).option("--format <type>", "Output format: table, json", "table").option("--engine <engine>", "Filter: postgres | mysql | redis | elasticsearch | all").option("--source <source>", "Filter: local | shared | builtin | all").action(async (intent, options) => {
|
|
85685
|
+
await queriesSuggest(intent, options);
|
|
85686
|
+
});
|
|
85123
85687
|
|
|
85124
85688
|
// src/core/data-executor.ts
|
|
85125
85689
|
init_permission_guard();
|
|
@@ -85626,18 +86190,17 @@ function parseWhereClause(whereClause) {
|
|
|
85626
86190
|
if (valueStr === undefined || column === undefined) {
|
|
85627
86191
|
throw new Error(`Cannot parse WHERE clause: "${part}". Use format "column=value" or "col1=val1 AND col2=val2"`);
|
|
85628
86192
|
}
|
|
85629
|
-
|
|
85630
|
-
|
|
85631
|
-
|
|
85632
|
-
|
|
85633
|
-
|
|
85634
|
-
value = Number(value);
|
|
86193
|
+
const trimmed = valueStr.trim();
|
|
86194
|
+
const stripped = trimmed.startsWith("'") && trimmed.endsWith("'") || trimmed.startsWith('"') && trimmed.endsWith('"') ? trimmed.slice(1, -1) : trimmed;
|
|
86195
|
+
let value = stripped;
|
|
86196
|
+
if (stripped !== "" && !isNaN(Number(stripped))) {
|
|
86197
|
+
value = Number(stripped);
|
|
85635
86198
|
}
|
|
85636
|
-
if (
|
|
86199
|
+
if (stripped === "true")
|
|
85637
86200
|
value = true;
|
|
85638
|
-
if (
|
|
86201
|
+
else if (stripped === "false")
|
|
85639
86202
|
value = false;
|
|
85640
|
-
if (
|
|
86203
|
+
else if (stripped === "null")
|
|
85641
86204
|
value = null;
|
|
85642
86205
|
conditions[column] = value;
|
|
85643
86206
|
}
|
|
@@ -85845,19 +86408,17 @@ function parseWhereClause2(whereClause) {
|
|
|
85845
86408
|
throw new Error(`Cannot parse WHERE clause: "${part}". Use format "column=value" or "col1=val1 AND col2=val2"`);
|
|
85846
86409
|
}
|
|
85847
86410
|
const column = match[1];
|
|
85848
|
-
const
|
|
85849
|
-
|
|
85850
|
-
|
|
85851
|
-
|
|
85852
|
-
|
|
85853
|
-
if (!isNaN(value) && value !== "") {
|
|
85854
|
-
value = Number(value);
|
|
86411
|
+
const trimmed = match[2].trim();
|
|
86412
|
+
const stripped = trimmed.startsWith("'") && trimmed.endsWith("'") || trimmed.startsWith('"') && trimmed.endsWith('"') ? trimmed.slice(1, -1) : trimmed;
|
|
86413
|
+
let value = stripped;
|
|
86414
|
+
if (stripped !== "" && !isNaN(Number(stripped))) {
|
|
86415
|
+
value = Number(stripped);
|
|
85855
86416
|
}
|
|
85856
|
-
if (
|
|
86417
|
+
if (stripped === "true")
|
|
85857
86418
|
value = true;
|
|
85858
|
-
if (
|
|
86419
|
+
else if (stripped === "false")
|
|
85859
86420
|
value = false;
|
|
85860
|
-
if (
|
|
86421
|
+
else if (stripped === "null")
|
|
85861
86422
|
value = null;
|
|
85862
86423
|
conditions[column] = value;
|
|
85863
86424
|
}
|
|
@@ -86137,9 +86698,7 @@ async function redisExportBranch(command, options, config) {
|
|
|
86137
86698
|
columnNames
|
|
86138
86699
|
};
|
|
86139
86700
|
const formatter = new QueryResultFormatter;
|
|
86140
|
-
const formatted = formatter.format(queryResult, {
|
|
86141
|
-
format: options.format
|
|
86142
|
-
});
|
|
86701
|
+
const formatted = formatter.format(queryResult, { format: options.format });
|
|
86143
86702
|
if (options.output) {
|
|
86144
86703
|
const file = Bun.file(options.output);
|
|
86145
86704
|
const exists = await file.exists();
|
|
@@ -86277,20 +86836,11 @@ function escapeCsvField(value) {
|
|
|
86277
86836
|
|
|
86278
86837
|
// src/commands/skill.ts
|
|
86279
86838
|
var {$ } = globalThis.Bun;
|
|
86280
|
-
import * as
|
|
86839
|
+
import * as path2 from "path";
|
|
86281
86840
|
import { homedir as homedir2 } from "os";
|
|
86282
|
-
|
|
86283
|
-
|
|
86284
|
-
|
|
86285
|
-
if (Bun.file(path.join(dir, "package.json")).size > 0) {
|
|
86286
|
-
return dir;
|
|
86287
|
-
}
|
|
86288
|
-
dir = path.dirname(dir);
|
|
86289
|
-
}
|
|
86290
|
-
return path.resolve(import.meta.dir, "../..");
|
|
86291
|
-
}
|
|
86292
|
-
var SKILL_SOURCE_PATH = path.join(findPackageRoot(), "assets", "SKILL.md");
|
|
86293
|
-
var REFERENCE_SOURCE_PATH = path.join(findPackageRoot(), "assets", "reference.md");
|
|
86841
|
+
init_package_root();
|
|
86842
|
+
var SKILL_SOURCE_PATH = packageAssetPath("SKILL.md");
|
|
86843
|
+
var REFERENCE_SOURCE_PATH = packageAssetPath("reference.md");
|
|
86294
86844
|
var SUPPORTED_PLATFORMS = ["claude", "gemini", "copilot", "cursor"];
|
|
86295
86845
|
async function skillCommand(_program, options) {
|
|
86296
86846
|
try {
|
|
@@ -86349,28 +86899,28 @@ function getInstallPath(platform) {
|
|
|
86349
86899
|
const platformLower = platform.toLowerCase();
|
|
86350
86900
|
switch (platformLower) {
|
|
86351
86901
|
case "claude":
|
|
86352
|
-
return
|
|
86902
|
+
return path2.join(home, ".claude", "skills", "dbcli", "SKILL.md");
|
|
86353
86903
|
case "gemini":
|
|
86354
|
-
return
|
|
86904
|
+
return path2.join(home, ".gemini", "skills", "dbcli", "SKILL.md");
|
|
86355
86905
|
case "copilot":
|
|
86356
|
-
return
|
|
86906
|
+
return path2.join(process.cwd(), ".github", "skills", "dbcli", "SKILL.md");
|
|
86357
86907
|
case "cursor":
|
|
86358
|
-
return
|
|
86908
|
+
return path2.join(process.cwd(), ".cursor", "rules", "dbcli.mdc");
|
|
86359
86909
|
default:
|
|
86360
86910
|
throw new Error(`Unknown platform: ${platform}. Supported platforms: ${SUPPORTED_PLATFORMS.join(", ")}`);
|
|
86361
86911
|
}
|
|
86362
86912
|
}
|
|
86363
86913
|
async function writeSkillInstall(platform, installPath, skillMarkdown, referenceMarkdown) {
|
|
86364
86914
|
const platformLower = platform.toLowerCase();
|
|
86365
|
-
await ensureDir(
|
|
86915
|
+
await ensureDir(path2.dirname(installPath));
|
|
86366
86916
|
await Bun.file(installPath).write(skillMarkdown);
|
|
86367
86917
|
if (platformLower === "cursor") {
|
|
86368
|
-
const refPath2 =
|
|
86369
|
-
await ensureDir(
|
|
86918
|
+
const refPath2 = path2.join(process.cwd(), ".cursor", "skills", "dbcli", "reference.md");
|
|
86919
|
+
await ensureDir(path2.dirname(refPath2));
|
|
86370
86920
|
await Bun.file(refPath2).write(referenceMarkdown);
|
|
86371
86921
|
return { referencePath: refPath2 };
|
|
86372
86922
|
}
|
|
86373
|
-
const refPath =
|
|
86923
|
+
const refPath = path2.join(path2.dirname(installPath), "reference.md");
|
|
86374
86924
|
await Bun.file(refPath).write(referenceMarkdown);
|
|
86375
86925
|
return { referencePath: refPath };
|
|
86376
86926
|
}
|
|
@@ -86379,8 +86929,8 @@ async function ensureDir(dirPath) {
|
|
|
86379
86929
|
await $`mkdir -p ${dirPath}`.quiet();
|
|
86380
86930
|
} catch {
|
|
86381
86931
|
try {
|
|
86382
|
-
const { mkdir:
|
|
86383
|
-
await
|
|
86932
|
+
const { mkdir: mkdir6 } = await import("fs/promises");
|
|
86933
|
+
await mkdir6(dirPath, { recursive: true });
|
|
86384
86934
|
} catch {
|
|
86385
86935
|
throw new Error(`Cannot create directory: ${dirPath}`);
|
|
86386
86936
|
}
|
|
@@ -86410,15 +86960,16 @@ class AgentTaskError extends Error {
|
|
|
86410
86960
|
}
|
|
86411
86961
|
}
|
|
86412
86962
|
// src/core/agent-tasks/task-paths.ts
|
|
86413
|
-
|
|
86963
|
+
init_package_root();
|
|
86964
|
+
import { join as join15 } from "path";
|
|
86414
86965
|
function resolveBuiltinDir2() {
|
|
86415
|
-
return
|
|
86966
|
+
return packageAssetPath("tasks");
|
|
86416
86967
|
}
|
|
86417
86968
|
function resolveAgentTaskDirs(workspaceRoot) {
|
|
86418
86969
|
return {
|
|
86419
86970
|
builtinDir: resolveBuiltinDir2(),
|
|
86420
|
-
sharedDir:
|
|
86421
|
-
localDir:
|
|
86971
|
+
sharedDir: join15(workspaceRoot, ".dbcli-shared", "tasks"),
|
|
86972
|
+
localDir: join15(workspaceRoot, ".dbcli", "tasks")
|
|
86422
86973
|
};
|
|
86423
86974
|
}
|
|
86424
86975
|
// src/core/agent-tasks/parser.ts
|
|
@@ -86556,7 +87107,7 @@ function parseSteps(value, input) {
|
|
|
86556
87107
|
}
|
|
86557
87108
|
// src/core/agent-tasks/loader.ts
|
|
86558
87109
|
import { readdir as readdir2 } from "fs/promises";
|
|
86559
|
-
import { join as
|
|
87110
|
+
import { join as join16, relative as relative2, sep as sep2 } from "path";
|
|
86560
87111
|
async function loadAgentTasks(opts, flags) {
|
|
86561
87112
|
const errors3 = [];
|
|
86562
87113
|
const builtin = await walkAndParse2(opts.builtinDir, "builtin", errors3);
|
|
@@ -86613,7 +87164,7 @@ async function safeCollectMd(root) {
|
|
|
86613
87164
|
return;
|
|
86614
87165
|
}
|
|
86615
87166
|
for (const e of entries) {
|
|
86616
|
-
const full =
|
|
87167
|
+
const full = join16(dir, e.name);
|
|
86617
87168
|
if (e.isDirectory())
|
|
86618
87169
|
await walk(full);
|
|
86619
87170
|
else
|
|
@@ -87561,7 +88112,7 @@ var statusCommand = new Command("status").description("Show current configuratio
|
|
|
87561
88112
|
// src/commands/doctor.ts
|
|
87562
88113
|
init_validation();
|
|
87563
88114
|
init_schema_path();
|
|
87564
|
-
import { join as
|
|
88115
|
+
import { join as join17 } from "path";
|
|
87565
88116
|
import { resolveSrv as resolveSrv2 } from "dns/promises";
|
|
87566
88117
|
var ALLOWED_FORMATS8 = ["text", "json"];
|
|
87567
88118
|
var SENSITIVE_PATTERNS = [
|
|
@@ -87635,7 +88186,7 @@ var runDoctorChecks = {
|
|
|
87635
88186
|
}
|
|
87636
88187
|
},
|
|
87637
88188
|
async checkConfigExists(configPath, existsFn) {
|
|
87638
|
-
const exists = existsFn ? await existsFn(configPath) : await Bun.file(configPath).exists() || await Bun.file(
|
|
88189
|
+
const exists = existsFn ? await existsFn(configPath) : await Bun.file(configPath).exists() || await Bun.file(join17(configPath, "config.json")).exists();
|
|
87639
88190
|
return {
|
|
87640
88191
|
group: "Configuration",
|
|
87641
88192
|
label: "Config exists",
|
|
@@ -87792,7 +88343,7 @@ var runDoctorChecks = {
|
|
|
87792
88343
|
async checkV2Config(configPath) {
|
|
87793
88344
|
const results = [];
|
|
87794
88345
|
const storagePath = await resolveConfigStoragePath(configPath);
|
|
87795
|
-
const configFile = Bun.file(
|
|
88346
|
+
const configFile = Bun.file(join17(storagePath, "config.json"));
|
|
87796
88347
|
if (!await configFile.exists())
|
|
87797
88348
|
return results;
|
|
87798
88349
|
let raw;
|
|
@@ -87832,7 +88383,7 @@ var runDoctorChecks = {
|
|
|
87832
88383
|
}
|
|
87833
88384
|
for (const [name, conn] of Object.entries(config.connections)) {
|
|
87834
88385
|
if (conn.envFile) {
|
|
87835
|
-
const envPath =
|
|
88386
|
+
const envPath = join17(storagePath, conn.envFile);
|
|
87836
88387
|
const exists = await Bun.file(envPath).exists();
|
|
87837
88388
|
results.push({
|
|
87838
88389
|
group: "Configuration",
|
|
@@ -88051,7 +88602,7 @@ var doctorCommand = new Command("doctor").description("Run diagnostic checks on
|
|
|
88051
88602
|
}
|
|
88052
88603
|
try {
|
|
88053
88604
|
const schemaConnName = await getSchemaIsolationConnectionName(configPath);
|
|
88054
|
-
const indexPath =
|
|
88605
|
+
const indexPath = join17(resolveSchemaPath(storagePath, schemaConnName), "index.json");
|
|
88055
88606
|
const indexFile = Bun.file(indexPath);
|
|
88056
88607
|
let indexParsed = null;
|
|
88057
88608
|
if (await indexFile.exists()) {
|
|
@@ -88093,7 +88644,7 @@ var doctorCommand = new Command("doctor").description("Run diagnostic checks on
|
|
|
88093
88644
|
});
|
|
88094
88645
|
|
|
88095
88646
|
// src/commands/completion.ts
|
|
88096
|
-
import { join as
|
|
88647
|
+
import { join as join18 } from "path";
|
|
88097
88648
|
import { homedir as homedir3 } from "os";
|
|
88098
88649
|
function extractCommands(program2) {
|
|
88099
88650
|
return program2.commands.map((cmd) => ({
|
|
@@ -88195,11 +88746,11 @@ function getInstallPath2(shell) {
|
|
|
88195
88746
|
const home = homedir3();
|
|
88196
88747
|
switch (shell) {
|
|
88197
88748
|
case "bash":
|
|
88198
|
-
return
|
|
88749
|
+
return join18(home, ".bashrc");
|
|
88199
88750
|
case "zsh":
|
|
88200
|
-
return
|
|
88751
|
+
return join18(home, ".zshrc");
|
|
88201
88752
|
case "fish":
|
|
88202
|
-
return
|
|
88753
|
+
return join18(home, ".config", "fish", "completions", "dbcli.fish");
|
|
88203
88754
|
default:
|
|
88204
88755
|
throw new Error(`Unsupported shell: ${shell}. Supported: bash, zsh, fish`);
|
|
88205
88756
|
}
|
|
@@ -88219,7 +88770,7 @@ var MARKER_END = "# <<< dbcli completion <<<";
|
|
|
88219
88770
|
async function installCompletion(shell, script) {
|
|
88220
88771
|
const targetPath = getInstallPath2(shell);
|
|
88221
88772
|
if (shell === "fish") {
|
|
88222
|
-
const dir =
|
|
88773
|
+
const dir = join18(homedir3(), ".config", "fish", "completions");
|
|
88223
88774
|
await Bun.$`mkdir -p ${dir}`.quiet();
|
|
88224
88775
|
await Bun.file(targetPath).write(script);
|
|
88225
88776
|
console.log(colors.success(`\u2713 Fish completion installed to ${targetPath}`));
|
|
@@ -88446,7 +88997,7 @@ ${t("upgrade.failed")}`));
|
|
|
88446
88997
|
|
|
88447
88998
|
// src/commands/shell.ts
|
|
88448
88999
|
import { createInterface as createInterface2 } from "readline";
|
|
88449
|
-
import { join as
|
|
89000
|
+
import { join as join19 } from "path";
|
|
88450
89001
|
import { homedir as homedir4 } from "os";
|
|
88451
89002
|
|
|
88452
89003
|
// src/core/repl/types.ts
|
|
@@ -88791,7 +89342,7 @@ function isKnownCommand(name) {
|
|
|
88791
89342
|
|
|
88792
89343
|
// src/core/repl/history-manager.ts
|
|
88793
89344
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
88794
|
-
import { dirname as
|
|
89345
|
+
import { dirname as dirname6 } from "path";
|
|
88795
89346
|
var DEFAULT_MAX = 1000;
|
|
88796
89347
|
|
|
88797
89348
|
class HistoryManager {
|
|
@@ -88819,7 +89370,7 @@ class HistoryManager {
|
|
|
88819
89370
|
return this.entries;
|
|
88820
89371
|
}
|
|
88821
89372
|
async save() {
|
|
88822
|
-
const dir =
|
|
89373
|
+
const dir = dirname6(this.filePath);
|
|
88823
89374
|
if (!existsSync(dir)) {
|
|
88824
89375
|
mkdirSync(dir, { recursive: true });
|
|
88825
89376
|
}
|
|
@@ -89169,7 +89720,7 @@ class MongoShellAdapter {
|
|
|
89169
89720
|
}
|
|
89170
89721
|
|
|
89171
89722
|
// src/commands/shell.ts
|
|
89172
|
-
var HISTORY_PATH =
|
|
89723
|
+
var HISTORY_PATH = join19(homedir4(), ".dbcli_history");
|
|
89173
89724
|
var MONGO_COMPLETION_EAGER_THRESHOLD = 20;
|
|
89174
89725
|
async function populateMongoColumns(mongoAdapter, collectionNames, threshold = MONGO_COMPLETION_EAGER_THRESHOLD) {
|
|
89175
89726
|
const columnsByTable = {};
|
|
@@ -90140,7 +90691,7 @@ addExecOpts(migrateCommand.command("drop-enum <name>").description(t("migrate.dr
|
|
|
90140
90691
|
});
|
|
90141
90692
|
|
|
90142
90693
|
// src/commands/use.ts
|
|
90143
|
-
import { join as
|
|
90694
|
+
import { join as join20 } from "path";
|
|
90144
90695
|
async function switchDefault(configPath, name, config) {
|
|
90145
90696
|
if (!config.connections[name]) {
|
|
90146
90697
|
const available = Object.keys(config.connections).join(", ");
|
|
@@ -90163,7 +90714,7 @@ function listConnectionsForDisplay(config) {
|
|
|
90163
90714
|
}
|
|
90164
90715
|
async function ensureV2Config(configPath) {
|
|
90165
90716
|
const storagePath = await resolveConfigStoragePath(configPath);
|
|
90166
|
-
const configFile = Bun.file(
|
|
90717
|
+
const configFile = Bun.file(join20(storagePath, "config.json"));
|
|
90167
90718
|
const legacyFile = Bun.file(configPath);
|
|
90168
90719
|
if (!await configFile.exists() && !await legacyFile.exists()) {
|
|
90169
90720
|
throw new ConfigError(t("init.config_not_found"));
|
|
@@ -90225,7 +90776,7 @@ var useCommand = new Command("use").description("Switch or display the default d
|
|
|
90225
90776
|
});
|
|
90226
90777
|
|
|
90227
90778
|
// src/cli.ts
|
|
90228
|
-
import { join as
|
|
90779
|
+
import { join as join21 } from "path";
|
|
90229
90780
|
var _bgVersionCheckResult;
|
|
90230
90781
|
function shouldSkipBackgroundChecks() {
|
|
90231
90782
|
return process.env.DBCLI_NO_UPDATE_CHECK === "1" || process.env.DBCLI_NO_UPDATE_CHECK === "true" || false;
|
|
@@ -90254,7 +90805,7 @@ program2.hook("preAction", (thisCommand, actionCommand) => {
|
|
|
90254
90805
|
try {
|
|
90255
90806
|
let cache = null;
|
|
90256
90807
|
try {
|
|
90257
|
-
const cacheFile = Bun.file(
|
|
90808
|
+
const cacheFile = Bun.file(join21(configPath, "version-check.json"));
|
|
90258
90809
|
if (await cacheFile.exists()) {
|
|
90259
90810
|
cache = await cacheFile.json();
|
|
90260
90811
|
}
|