@carllee1983/dbcli 1.10.1 → 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.
Files changed (31) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/assets/SKILL.md +8 -0
  3. package/assets/snippets/diag/blocking-queries.postgres.sql +17 -0
  4. package/assets/snippets/diag/cache-hit.mysql.sql +1 -0
  5. package/assets/snippets/diag/cache-hit.postgres.sql +1 -0
  6. package/assets/snippets/diag/client-list.redis.sql +8 -0
  7. package/assets/snippets/diag/cluster-info.redis.sql +8 -0
  8. package/assets/snippets/diag/connections.mysql.sql +1 -0
  9. package/assets/snippets/diag/connections.postgres.sql +1 -0
  10. package/assets/snippets/diag/db-size.mysql.sql +1 -0
  11. package/assets/snippets/diag/db-size.postgres.sql +1 -0
  12. package/assets/snippets/diag/es-cluster-health.elasticsearch.sql +1 -0
  13. package/assets/snippets/diag/hot-threads.elasticsearch.sql +9 -0
  14. package/assets/snippets/diag/index-stats.elasticsearch.sql +16 -0
  15. package/assets/snippets/diag/index-usage.mysql.sql +1 -0
  16. package/assets/snippets/diag/index-usage.postgres.sql +1 -0
  17. package/assets/snippets/diag/locks.mysql.sql +1 -0
  18. package/assets/snippets/diag/locks.postgres.sql +1 -0
  19. package/assets/snippets/diag/long-running.mysql.sql +1 -0
  20. package/assets/snippets/diag/long-running.postgres.sql +1 -0
  21. package/assets/snippets/diag/memory-usage.redis.sql +8 -0
  22. package/assets/snippets/diag/missing-indexes.mysql.sql +1 -0
  23. package/assets/snippets/diag/missing-indexes.postgres.sql +1 -0
  24. package/assets/snippets/diag/pending-tasks.elasticsearch.sql +9 -0
  25. package/assets/snippets/diag/redis-key-stats.redis.sql +1 -0
  26. package/assets/snippets/diag/slowlog.redis.sql +12 -0
  27. package/assets/snippets/diag/table-sizes.mysql.sql +1 -0
  28. package/assets/snippets/diag/table-sizes.postgres.sql +1 -0
  29. package/assets/snippets/diag/unassigned-shards.elasticsearch.sql +9 -0
  30. package/dist/cli.mjs +742 -211
  31. package/package.json +12 -14
package/dist/cli.mjs CHANGED
@@ -31536,7 +31536,7 @@ var require_umd = __commonJS((exports, module) => {
31536
31536
  });
31537
31537
  });
31538
31538
 
31539
- // node_modules/mysql2/node_modules/iconv-lite/lib/bom-handling.js
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/mysql2/node_modules/iconv-lite/lib/helpers/merge-exports.js
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/mysql2/node_modules/iconv-lite/encodings/internal.js
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/mysql2/node_modules/iconv-lite/encodings/utf32.js
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/mysql2/node_modules/iconv-lite/encodings/utf16.js
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/mysql2/node_modules/iconv-lite/encodings/utf7.js
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/mysql2/node_modules/iconv-lite/encodings/sbcs-codec.js
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/mysql2/node_modules/iconv-lite/encodings/sbcs-data.js
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/mysql2/node_modules/iconv-lite/encodings/sbcs-data-generated.js
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/mysql2/node_modules/iconv-lite/encodings/dbcs-codec.js
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/mysql2/node_modules/iconv-lite/encodings/tables/shiftjis.json
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/mysql2/node_modules/iconv-lite/encodings/tables/eucjp.json
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/mysql2/node_modules/iconv-lite/encodings/tables/cp936.json
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/mysql2/node_modules/iconv-lite/encodings/tables/gbk-added.json
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/mysql2/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json
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/mysql2/node_modules/iconv-lite/encodings/tables/cp949.json
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/mysql2/node_modules/iconv-lite/encodings/tables/cp950.json
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/mysql2/node_modules/iconv-lite/encodings/tables/big5-added.json
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/mysql2/node_modules/iconv-lite/encodings/dbcs-data.js
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/mysql2/node_modules/iconv-lite/encodings/index.js
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/mysql2/node_modules/iconv-lite/lib/streams.js
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/mysql2/node_modules/iconv-lite/lib/index.js
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
- let res = new Long(word0, word1, true);
35337
+ const res = new Long(word0, word1, true);
35338
35338
  const resNumber = res.toNumber();
35339
- const resString = res.toString();
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
- let res = new Long(word0, word1, false);
35344
+ const res = new Long(word0, word1, false);
35347
35345
  const resNumber = res.toNumber();
35348
- const resString = res.toString();
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
- res = resNumber.toString() === resString ? resNumber : resString;
35396
- return bigNumberStrings ? resString : res;
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 (result.toString() === str) {
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
- str = this.buffer.toString("ascii", start, end);
35613
- if (num.toString() === str) {
35613
+ if (Number.isSafeInteger(num)) {
35614
35614
  return num;
35615
35615
  }
35616
- return str;
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/execute.js
37181
- var require_execute = __commonJS((exports, module) => {
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
- toPacket() {
37287
- let length = 14;
37288
- let parameters;
37289
- if (this.parameters && this.parameters.length > 0) {
37290
- length += Math.floor((this.parameters.length + 7) / 8);
37291
- length += 1;
37292
- length += 2 * this.parameters.length;
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
- packet.writeInt8(CursorType.NO_CURSOR);
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 (parameters) {
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
- parameters.forEach((parameter) => {
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
- parameters.forEach((parameter) => {
37322
- packet.writeInt8(parameter.type);
37340
+ for (let i = 0;i < allParams.length; i++) {
37341
+ packet.writeInt8(allParams[i].type);
37323
37342
  packet.writeInt8(0);
37324
- });
37325
- parameters.forEach((parameter) => {
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
- toPacket() {
37629
- const buf = StringParser.encode(this.query, this.encoding);
37630
- const length = 5 + buf.length;
37631
- const buffer = Buffer.allocUnsafe(length);
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
- packet.writeBuffer(buf);
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 && ServerSatusFlags.SERVER_SESSION_STATE_CHANGED) {
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 = "AUTH_SWITCH_PLUGIN_ERROR";
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 cmdPacket = new Packets.Query(this.sql, connection.config.charsetNumber);
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 executePacket = new Packets.Execute(this.statement.id, this.parameters, connection.config.charsetNumber, connection.config.timezone);
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.20.0",
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": "^7.5.1",
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
- function makeDoneCb(resolve2, reject, localErr) {
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
- localErr.message = err.message;
45416
- localErr.code = err.code;
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 localErr = new Error;
45610
+ const stackHolder = captureStackHolder(PromisePreparedStatementInfo.prototype.execute);
45442
45611
  return new this.Promise((resolve2, reject) => {
45443
- const done = makeDoneCb(resolve2, reject, localErr);
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 localErr = new Error;
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, localErr);
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 localErr = new Error;
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, localErr);
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 localErr = new Error;
45722
+ const stackHolder = captureStackHolder(PromiseConnection.prototype.beginTransaction);
45550
45723
  return new this.Promise((resolve2, reject) => {
45551
- const done = makeDoneCb(resolve2, reject, localErr);
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 localErr = new Error;
45730
+ const stackHolder = captureStackHolder(PromiseConnection.prototype.commit);
45558
45731
  return new this.Promise((resolve2, reject) => {
45559
- const done = makeDoneCb(resolve2, reject, localErr);
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 localErr = new Error;
45738
+ const stackHolder = captureStackHolder(PromiseConnection.prototype.rollback);
45566
45739
  return new this.Promise((resolve2, reject) => {
45567
- const done = makeDoneCb(resolve2, reject, localErr);
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 localErr = new Error;
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
- localErr.message = err.message;
45578
- localErr.code = err.code;
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 localErr = new Error;
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
- localErr.message = err.message;
45596
- localErr.code = err.code;
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 localErr = new Error;
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
- localErr.message = err.message;
45615
- localErr.code = err.code;
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 localErr = new Error;
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
- localErr.message = err.message;
45634
- localErr.code = err.code;
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
- } else if (this._connectionQueue.length) {
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 localErr = new Error;
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, localErr);
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 localErr = new Error;
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, localErr);
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 localErr = new Error;
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
- localErr.message = err.message;
46093
- localErr.code = err.code;
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 localErr = new Error;
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, localErr);
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 localErr = new Error;
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, localErr);
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 createConnectionErr = new Error;
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
- createConnectionErr.message = err.message;
46561
- createConnectionErr.code = err.code;
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 localErr = new Error;
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, localErr);
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 localErr = new Error;
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, localErr);
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 localErr = new Error;
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
- localErr.message = err.message;
46628
- localErr.code = err.code;
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
@@ -78855,7 +79062,7 @@ var exports_queries_rename = {};
78855
79062
  __export(exports_queries_rename, {
78856
79063
  queriesRename: () => queriesRename
78857
79064
  });
78858
- import { rename, mkdir } from "fs/promises";
79065
+ import { rename, mkdir as mkdir2 } from "fs/promises";
78859
79066
  import { dirname as dirname2 } from "path";
78860
79067
  async function queriesRename(oldName, newName, options = {}) {
78861
79068
  if (!oldName.startsWith("@") || !newName.startsWith("@")) {
@@ -78877,7 +79084,7 @@ async function queriesRename(oldName, newName, options = {}) {
78877
79084
  for (const v of local) {
78878
79085
  const dst = snippetKeyToFile(cwd, newName, "local");
78879
79086
  const dstWithSuffix = preserveEngineSuffix(v.query.file, dst);
78880
- await mkdir(dirname2(dstWithSuffix), { recursive: true });
79087
+ await mkdir2(dirname2(dstWithSuffix), { recursive: true });
78881
79088
  await rename(v.query.file, dstWithSuffix);
78882
79089
  await rewriteFrontmatterName(dstWithSuffix, newName.slice(1));
78883
79090
  console.log(`renamed ${v.query.file} \u2192 ${dstWithSuffix}`);
@@ -78903,7 +79110,7 @@ var exports_queries_copy = {};
78903
79110
  __export(exports_queries_copy, {
78904
79111
  queriesCopy: () => queriesCopy
78905
79112
  });
78906
- import { mkdir as mkdir2, copyFile } from "fs/promises";
79113
+ import { mkdir as mkdir3, copyFile } from "fs/promises";
78907
79114
  import { dirname as dirname3, basename as basename2 } from "path";
78908
79115
  async function queriesCopy(src, dst, options = {}) {
78909
79116
  if (!src.startsWith("@") || !dst.startsWith("@")) {
@@ -78922,7 +79129,7 @@ async function queriesCopy(src, dst, options = {}) {
78922
79129
  }
78923
79130
  for (const v of variants) {
78924
79131
  const dstFile = mapEngineSuffix(v.query.file, snippetKeyToFile(cwd, dst, "local"));
78925
- await mkdir2(dirname3(dstFile), { recursive: true });
79132
+ await mkdir3(dirname3(dstFile), { recursive: true });
78926
79133
  await copyFile(v.query.file, dstFile);
78927
79134
  console.log(`copied ${v.query.file} \u2192 ${dstFile}`);
78928
79135
  }
@@ -78940,7 +79147,7 @@ var exports_queries_import = {};
78940
79147
  __export(exports_queries_import, {
78941
79148
  queriesImport: () => queriesImport
78942
79149
  });
78943
- import { stat, mkdir as mkdir3, copyFile as copyFile2 } from "fs/promises";
79150
+ import { stat, mkdir as mkdir4, copyFile as copyFile2 } from "fs/promises";
78944
79151
  import { basename as basename3, join as join13, extname } from "path";
78945
79152
  async function queriesImport(filePath, options = {}) {
78946
79153
  const cwd = options.cwd ?? process.cwd();
@@ -78953,7 +79160,7 @@ async function queriesImport(filePath, options = {}) {
78953
79160
  const key2 = "@" + baseName;
78954
79161
  parseSavedQuery({ key: key2, file: filePath, source: "local", text: text2 });
78955
79162
  const targetDir = join13(cwd, ".dbcli/queries");
78956
- await mkdir3(targetDir, { recursive: true });
79163
+ await mkdir4(targetDir, { recursive: true });
78957
79164
  const target = join13(targetDir, basename3(filePath));
78958
79165
  if (await Bun.file(target).exists()) {
78959
79166
  if (!options.force) {
@@ -79024,7 +79231,7 @@ var {
79024
79231
  // package.json
79025
79232
  var package_default = {
79026
79233
  name: "@carllee1983/dbcli",
79027
- version: "1.10.1",
79234
+ version: "1.11.0",
79028
79235
  description: "Database CLI for AI agents",
79029
79236
  type: "module",
79030
79237
  publishConfig: {
@@ -79080,26 +79287,24 @@ var package_default = {
79080
79287
  format: 'prettier --write "src/**/*.ts" "tests/**/*.ts"'
79081
79288
  },
79082
79289
  dependencies: {
79083
- "cli-table3": "^0.6.3",
79290
+ "cli-table3": "^0.6.5",
79084
79291
  commander: "13.0.0",
79085
79292
  mongodb: "^7.2.0",
79086
- mysql2: "^3.20.0",
79293
+ mysql2: "^3.22.3",
79087
79294
  pg: "^8.20.0",
79088
79295
  picocolors: "^1.1.1",
79089
- zod: "^3.22.4"
79296
+ zod: "^3.25.76"
79090
79297
  },
79091
79298
  devDependencies: {
79092
- "@eslint/js": "^9.0.0",
79093
- "@inquirer/prompts": "^5.0.0",
79299
+ "@eslint/js": "^9.39.4",
79300
+ "@inquirer/prompts": "^5.5.0",
79094
79301
  "@types/bun": "latest",
79095
- "@typescript-eslint/eslint-plugin": "^7.0.0",
79096
- "@typescript-eslint/parser": "^7.0.0",
79097
- eslint: "^9.0.0",
79098
- "happy-dom": "^12.0.0",
79099
- jsdom: "^23.0.0",
79100
- prettier: "^3.0.0",
79101
- typescript: "^5.3.3",
79102
- "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"
79103
79308
  }
79104
79309
  };
79105
79310
  // resources/lang/en/messages.json
@@ -79192,7 +79397,15 @@ var messages_default = {
79192
79397
  first_run_hint: "Tip: commit .dbcli-shared/ to share snippets with your team.",
79193
79398
  no_snippets: "No snippets found. Create one with: dbcli queries new @<name>",
79194
79399
  check_ok: "\u2713 {count} snippets parsed successfully",
79195
- 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."
79196
79409
  },
79197
79410
  errors: {
79198
79411
  message: "Error: {message}",
@@ -79409,7 +79622,15 @@ var messages_default2 = {
79409
79622
  first_run_hint: "\u63D0\u793A\uFF1A\u5C07 .dbcli-shared/ commit \u9032\u7248\u63A7\u53EF\u8207\u5718\u968A\u5171\u4EAB\u7247\u6BB5\u3002",
79410
79623
  no_snippets: "\u5C1A\u7121\u4EFB\u4F55\u7247\u6BB5\u3002\u57F7\u884C dbcli queries new @<name> \u5EFA\u7ACB\u3002",
79411
79624
  check_ok: "\u2713 \u6210\u529F\u89E3\u6790 {count} \u500B\u7247\u6BB5",
79412
- 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"
79413
79634
  },
79414
79635
  errors: {
79415
79636
  message: "\u932F\u8AA4\uFF1A{message}",
@@ -79856,6 +80077,7 @@ async function loadEnvFile(filePath) {
79856
80077
 
79857
80078
  // src/core/config-binding.ts
79858
80079
  import { createHash } from "crypto";
80080
+ import { mkdir, unlink } from "fs/promises";
79859
80081
  import { homedir } from "os";
79860
80082
  import { basename, join, resolve } from "path";
79861
80083
  var BINDING_FILE_NAME = "config.json";
@@ -79911,11 +80133,11 @@ async function migrateLegacyProjectEnvLocal(projectPath, storagePath = getProjec
79911
80133
  if (!await projectEnvFile.exists())
79912
80134
  return;
79913
80135
  const storageEnvPath = join(storagePath, ".env.local");
79914
- await Bun.$`mkdir -p ${storagePath}`;
80136
+ await mkdir(storagePath, { recursive: true });
79915
80137
  if (!await Bun.file(storageEnvPath).exists()) {
79916
80138
  await Bun.file(storageEnvPath).write(await projectEnvFile.text());
79917
80139
  }
79918
- await Bun.$`rm -f ${projectEnvPath}`;
80140
+ await unlink(projectEnvPath);
79919
80141
  }
79920
80142
 
79921
80143
  // src/core/config-v2.ts
@@ -84877,10 +85099,168 @@ function handleQError(error) {
84877
85099
  }
84878
85100
 
84879
85101
  // src/commands/queries.ts
84880
- import { mkdir as mkdir4, writeFile as writeFile2 } from "fs/promises";
85102
+ import { mkdir as mkdir5, writeFile as writeFile2 } from "fs/promises";
84881
85103
  import { dirname as dirname4 } from "path";
84882
85104
  import { spawn } from "child_process";
84883
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
84884
85264
  async function deriveEngine() {
84885
85265
  try {
84886
85266
  const cfg = await configModule.read(resolveConfigPath(undefined, {}));
@@ -84917,25 +85297,6 @@ async function queriesList(options) {
84917
85297
  for (const c of cells)
84918
85298
  console.log(fmt(c));
84919
85299
  }
84920
- var FOLD_SOURCE_RANK = { builtin: 0, shared: 1, local: 2 };
84921
- function foldVariants(key2, variants) {
84922
- const sources = unique(variants.map((v) => v.query.source)).sort();
84923
- const engines = unique(variants.flatMap((v) => v.query.meta.engine ?? [])).sort();
84924
- const tags = unique(variants.flatMap((v) => v.query.meta.tags ?? []));
84925
- const top = variants.slice().sort((a, b) => FOLD_SOURCE_RANK[b.query.source] - FOLD_SOURCE_RANK[a.query.source])[0];
84926
- return {
84927
- name: key2,
84928
- sources,
84929
- engines,
84930
- params: top.query.meta.params.map((p) => p.name),
84931
- description: top.query.meta.description ?? "",
84932
- tags,
84933
- hasLocalOverride: variants.some((v) => v.hasLocalOverride)
84934
- };
84935
- }
84936
- function unique(xs) {
84937
- return [...new Set(xs)];
84938
- }
84939
85300
  function snippetToJson(s) {
84940
85301
  return {
84941
85302
  name: s.query.meta.key,
@@ -85008,7 +85369,7 @@ async function queriesNew(name, options) {
85008
85369
  process.exit(1);
85009
85370
  return;
85010
85371
  }
85011
- await mkdir4(dirname4(file), { recursive: true });
85372
+ await mkdir5(dirname4(file), { recursive: true });
85012
85373
  await writeFile2(file, scaffold(name), "utf8");
85013
85374
  console.log(`Created ${file}`);
85014
85375
  if (source === "shared")
@@ -85070,6 +85431,170 @@ async function queriesCheck(options) {
85070
85431
  console.log(`\u2713 ${total} snippets parsed successfully`);
85071
85432
  }
85072
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
+ }
85073
85598
  function scaffold(name) {
85074
85599
  return [
85075
85600
  "-- ---",
@@ -85153,6 +85678,12 @@ queriesCommand.command("export <name>").description(t("queries.export_descriptio
85153
85678
  process.exit(1);
85154
85679
  }
85155
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
+ });
85156
85687
 
85157
85688
  // src/core/data-executor.ts
85158
85689
  init_permission_guard();
@@ -86398,8 +86929,8 @@ async function ensureDir(dirPath) {
86398
86929
  await $`mkdir -p ${dirPath}`.quiet();
86399
86930
  } catch {
86400
86931
  try {
86401
- const { mkdir: mkdir5 } = await import("fs/promises");
86402
- await mkdir5(dirPath, { recursive: true });
86932
+ const { mkdir: mkdir6 } = await import("fs/promises");
86933
+ await mkdir6(dirPath, { recursive: true });
86403
86934
  } catch {
86404
86935
  throw new Error(`Cannot create directory: ${dirPath}`);
86405
86936
  }