@dangao/bun-server 3.0.0 → 3.0.1

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/dist/index.js CHANGED
@@ -16625,771 +16625,6 @@ var init_decorators6 = __esm(() => {
16625
16625
  SERVICE_REGISTRY_METADATA_KEY = Symbol("service-registry:metadata");
16626
16626
  });
16627
16627
 
16628
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/util.js
16629
- var require_util2 = __commonJS((exports) => {
16630
- exports.getBooleanOption = (options, key) => {
16631
- let value = false;
16632
- if (key in options && typeof (value = options[key]) !== "boolean") {
16633
- throw new TypeError(`Expected the "${key}" option to be a boolean`);
16634
- }
16635
- return value;
16636
- };
16637
- exports.cppdb = Symbol();
16638
- exports.inspect = Symbol.for("nodejs.util.inspect.custom");
16639
- });
16640
-
16641
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/sqlite-error.js
16642
- var require_sqlite_error = __commonJS((exports, module) => {
16643
- var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
16644
- function SqliteError(message, code) {
16645
- if (new.target !== SqliteError) {
16646
- return new SqliteError(message, code);
16647
- }
16648
- if (typeof code !== "string") {
16649
- throw new TypeError("Expected second argument to be a string");
16650
- }
16651
- Error.call(this, message);
16652
- descriptor.value = "" + message;
16653
- Object.defineProperty(this, "message", descriptor);
16654
- Error.captureStackTrace(this, SqliteError);
16655
- this.code = code;
16656
- }
16657
- Object.setPrototypeOf(SqliteError, Error);
16658
- Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
16659
- Object.defineProperty(SqliteError.prototype, "name", descriptor);
16660
- module.exports = SqliteError;
16661
- });
16662
-
16663
- // ../../node_modules/.bun/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js
16664
- var require_file_uri_to_path = __commonJS((exports, module) => {
16665
- var sep2 = __require("path").sep || "/";
16666
- module.exports = fileUriToPath;
16667
- function fileUriToPath(uri) {
16668
- if (typeof uri != "string" || uri.length <= 7 || uri.substring(0, 7) != "file://") {
16669
- throw new TypeError("must pass in a file:// URI to convert to a file path");
16670
- }
16671
- var rest = decodeURI(uri.substring(7));
16672
- var firstSlash = rest.indexOf("/");
16673
- var host = rest.substring(0, firstSlash);
16674
- var path = rest.substring(firstSlash + 1);
16675
- if (host == "localhost")
16676
- host = "";
16677
- if (host) {
16678
- host = sep2 + sep2 + host;
16679
- }
16680
- path = path.replace(/^(.+)\|/, "$1:");
16681
- if (sep2 == "\\") {
16682
- path = path.replace(/\//g, "\\");
16683
- }
16684
- if (/^.+\:/.test(path)) {} else {
16685
- path = sep2 + path;
16686
- }
16687
- return host + path;
16688
- }
16689
- });
16690
-
16691
- // ../../node_modules/.bun/bindings@1.5.0/node_modules/bindings/bindings.js
16692
- var require_bindings = __commonJS((exports, module) => {
16693
- var __filename = "/Users/dg/work-dg/bun-server-project/bun-server/node_modules/.bun/bindings@1.5.0/node_modules/bindings/bindings.js";
16694
- var fs = __require("fs");
16695
- var path = __require("path");
16696
- var fileURLToPath = require_file_uri_to_path();
16697
- var join2 = path.join;
16698
- var dirname = path.dirname;
16699
- var exists = fs.accessSync && function(path2) {
16700
- try {
16701
- fs.accessSync(path2);
16702
- } catch (e) {
16703
- return false;
16704
- }
16705
- return true;
16706
- } || fs.existsSync || path.existsSync;
16707
- var defaults = {
16708
- arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
16709
- compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
16710
- platform: process.platform,
16711
- arch: process.arch,
16712
- nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
16713
- version: process.versions.node,
16714
- bindings: "bindings.node",
16715
- try: [
16716
- ["module_root", "build", "bindings"],
16717
- ["module_root", "build", "Debug", "bindings"],
16718
- ["module_root", "build", "Release", "bindings"],
16719
- ["module_root", "out", "Debug", "bindings"],
16720
- ["module_root", "Debug", "bindings"],
16721
- ["module_root", "out", "Release", "bindings"],
16722
- ["module_root", "Release", "bindings"],
16723
- ["module_root", "build", "default", "bindings"],
16724
- ["module_root", "compiled", "version", "platform", "arch", "bindings"],
16725
- ["module_root", "addon-build", "release", "install-root", "bindings"],
16726
- ["module_root", "addon-build", "debug", "install-root", "bindings"],
16727
- ["module_root", "addon-build", "default", "install-root", "bindings"],
16728
- ["module_root", "lib", "binding", "nodePreGyp", "bindings"]
16729
- ]
16730
- };
16731
- function bindings(opts) {
16732
- if (typeof opts == "string") {
16733
- opts = { bindings: opts };
16734
- } else if (!opts) {
16735
- opts = {};
16736
- }
16737
- Object.keys(defaults).map(function(i2) {
16738
- if (!(i2 in opts))
16739
- opts[i2] = defaults[i2];
16740
- });
16741
- if (!opts.module_root) {
16742
- opts.module_root = exports.getRoot(exports.getFileName());
16743
- }
16744
- if (path.extname(opts.bindings) != ".node") {
16745
- opts.bindings += ".node";
16746
- }
16747
- var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
16748
- var tries = [], i = 0, l = opts.try.length, n, b2, err;
16749
- for (;i < l; i++) {
16750
- n = join2.apply(null, opts.try[i].map(function(p) {
16751
- return opts[p] || p;
16752
- }));
16753
- tries.push(n);
16754
- try {
16755
- b2 = opts.path ? requireFunc.resolve(n) : requireFunc(n);
16756
- if (!opts.path) {
16757
- b2.path = n;
16758
- }
16759
- return b2;
16760
- } catch (e) {
16761
- if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
16762
- throw e;
16763
- }
16764
- }
16765
- }
16766
- err = new Error(`Could not locate the bindings file. Tried:
16767
- ` + tries.map(function(a) {
16768
- return opts.arrow + a;
16769
- }).join(`
16770
- `));
16771
- err.tries = tries;
16772
- throw err;
16773
- }
16774
- module.exports = exports = bindings;
16775
- exports.getFileName = function getFileName(calling_file) {
16776
- var { prepareStackTrace: origPST, stackTraceLimit: origSTL } = Error, dummy = {}, fileName;
16777
- Error.stackTraceLimit = 10;
16778
- Error.prepareStackTrace = function(e, st) {
16779
- for (var i = 0, l = st.length;i < l; i++) {
16780
- fileName = st[i].getFileName();
16781
- if (fileName !== __filename) {
16782
- if (calling_file) {
16783
- if (fileName !== calling_file) {
16784
- return;
16785
- }
16786
- } else {
16787
- return;
16788
- }
16789
- }
16790
- }
16791
- };
16792
- Error.captureStackTrace(dummy);
16793
- dummy.stack;
16794
- Error.prepareStackTrace = origPST;
16795
- Error.stackTraceLimit = origSTL;
16796
- var fileSchema = "file://";
16797
- if (fileName.indexOf(fileSchema) === 0) {
16798
- fileName = fileURLToPath(fileName);
16799
- }
16800
- return fileName;
16801
- };
16802
- exports.getRoot = function getRoot(file) {
16803
- var dir = dirname(file), prev;
16804
- while (true) {
16805
- if (dir === ".") {
16806
- dir = process.cwd();
16807
- }
16808
- if (exists(join2(dir, "package.json")) || exists(join2(dir, "node_modules"))) {
16809
- return dir;
16810
- }
16811
- if (prev === dir) {
16812
- throw new Error('Could not find module root given file: "' + file + '". Do you have a `package.json` file? ');
16813
- }
16814
- prev = dir;
16815
- dir = join2(dir, "..");
16816
- }
16817
- };
16818
- });
16819
-
16820
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/wrappers.js
16821
- var require_wrappers = __commonJS((exports) => {
16822
- var { cppdb } = require_util2();
16823
- exports.prepare = function prepare(sql) {
16824
- return this[cppdb].prepare(sql, this, false);
16825
- };
16826
- exports.exec = function exec(sql) {
16827
- this[cppdb].exec(sql);
16828
- return this;
16829
- };
16830
- exports.close = function close() {
16831
- this[cppdb].close();
16832
- return this;
16833
- };
16834
- exports.loadExtension = function loadExtension(...args) {
16835
- this[cppdb].loadExtension(...args);
16836
- return this;
16837
- };
16838
- exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
16839
- this[cppdb].defaultSafeIntegers(...args);
16840
- return this;
16841
- };
16842
- exports.unsafeMode = function unsafeMode(...args) {
16843
- this[cppdb].unsafeMode(...args);
16844
- return this;
16845
- };
16846
- exports.getters = {
16847
- name: {
16848
- get: function name() {
16849
- return this[cppdb].name;
16850
- },
16851
- enumerable: true
16852
- },
16853
- open: {
16854
- get: function open() {
16855
- return this[cppdb].open;
16856
- },
16857
- enumerable: true
16858
- },
16859
- inTransaction: {
16860
- get: function inTransaction() {
16861
- return this[cppdb].inTransaction;
16862
- },
16863
- enumerable: true
16864
- },
16865
- readonly: {
16866
- get: function readonly() {
16867
- return this[cppdb].readonly;
16868
- },
16869
- enumerable: true
16870
- },
16871
- memory: {
16872
- get: function memory() {
16873
- return this[cppdb].memory;
16874
- },
16875
- enumerable: true
16876
- }
16877
- };
16878
- });
16879
-
16880
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/transaction.js
16881
- var require_transaction = __commonJS((exports, module) => {
16882
- var { cppdb } = require_util2();
16883
- var controllers = new WeakMap;
16884
- module.exports = function transaction(fn) {
16885
- if (typeof fn !== "function")
16886
- throw new TypeError("Expected first argument to be a function");
16887
- const db2 = this[cppdb];
16888
- const controller = getController(db2, this);
16889
- const { apply } = Function.prototype;
16890
- const properties = {
16891
- default: { value: wrapTransaction(apply, fn, db2, controller.default) },
16892
- deferred: { value: wrapTransaction(apply, fn, db2, controller.deferred) },
16893
- immediate: { value: wrapTransaction(apply, fn, db2, controller.immediate) },
16894
- exclusive: { value: wrapTransaction(apply, fn, db2, controller.exclusive) },
16895
- database: { value: this, enumerable: true }
16896
- };
16897
- Object.defineProperties(properties.default.value, properties);
16898
- Object.defineProperties(properties.deferred.value, properties);
16899
- Object.defineProperties(properties.immediate.value, properties);
16900
- Object.defineProperties(properties.exclusive.value, properties);
16901
- return properties.default.value;
16902
- };
16903
- var getController = (db2, self2) => {
16904
- let controller = controllers.get(db2);
16905
- if (!controller) {
16906
- const shared = {
16907
- commit: db2.prepare("COMMIT", self2, false),
16908
- rollback: db2.prepare("ROLLBACK", self2, false),
16909
- savepoint: db2.prepare("SAVEPOINT `\t_bs3.\t`", self2, false),
16910
- release: db2.prepare("RELEASE `\t_bs3.\t`", self2, false),
16911
- rollbackTo: db2.prepare("ROLLBACK TO `\t_bs3.\t`", self2, false)
16912
- };
16913
- controllers.set(db2, controller = {
16914
- default: Object.assign({ begin: db2.prepare("BEGIN", self2, false) }, shared),
16915
- deferred: Object.assign({ begin: db2.prepare("BEGIN DEFERRED", self2, false) }, shared),
16916
- immediate: Object.assign({ begin: db2.prepare("BEGIN IMMEDIATE", self2, false) }, shared),
16917
- exclusive: Object.assign({ begin: db2.prepare("BEGIN EXCLUSIVE", self2, false) }, shared)
16918
- });
16919
- }
16920
- return controller;
16921
- };
16922
- var wrapTransaction = (apply, fn, db2, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
16923
- let before, after, undo;
16924
- if (db2.inTransaction) {
16925
- before = savepoint;
16926
- after = release;
16927
- undo = rollbackTo;
16928
- } else {
16929
- before = begin;
16930
- after = commit;
16931
- undo = rollback;
16932
- }
16933
- before.run();
16934
- try {
16935
- const result = apply.call(fn, this, arguments);
16936
- if (result && typeof result.then === "function") {
16937
- throw new TypeError("Transaction function cannot return a promise");
16938
- }
16939
- after.run();
16940
- return result;
16941
- } catch (ex) {
16942
- if (db2.inTransaction) {
16943
- undo.run();
16944
- if (undo !== rollback)
16945
- after.run();
16946
- }
16947
- throw ex;
16948
- }
16949
- };
16950
- });
16951
-
16952
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/pragma.js
16953
- var require_pragma = __commonJS((exports, module) => {
16954
- var { getBooleanOption, cppdb } = require_util2();
16955
- module.exports = function pragma(source, options) {
16956
- if (options == null)
16957
- options = {};
16958
- if (typeof source !== "string")
16959
- throw new TypeError("Expected first argument to be a string");
16960
- if (typeof options !== "object")
16961
- throw new TypeError("Expected second argument to be an options object");
16962
- const simple = getBooleanOption(options, "simple");
16963
- const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
16964
- return simple ? stmt.pluck().get() : stmt.all();
16965
- };
16966
- });
16967
-
16968
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/backup.js
16969
- var require_backup = __commonJS((exports, module) => {
16970
- var fs = __require("fs");
16971
- var path = __require("path");
16972
- var { promisify } = __require("util");
16973
- var { cppdb } = require_util2();
16974
- var fsAccess = promisify(fs.access);
16975
- module.exports = async function backup(filename, options) {
16976
- if (options == null)
16977
- options = {};
16978
- if (typeof filename !== "string")
16979
- throw new TypeError("Expected first argument to be a string");
16980
- if (typeof options !== "object")
16981
- throw new TypeError("Expected second argument to be an options object");
16982
- filename = filename.trim();
16983
- const attachedName = "attached" in options ? options.attached : "main";
16984
- const handler = "progress" in options ? options.progress : null;
16985
- if (!filename)
16986
- throw new TypeError("Backup filename cannot be an empty string");
16987
- if (filename === ":memory:")
16988
- throw new TypeError('Invalid backup filename ":memory:"');
16989
- if (typeof attachedName !== "string")
16990
- throw new TypeError('Expected the "attached" option to be a string');
16991
- if (!attachedName)
16992
- throw new TypeError('The "attached" option cannot be an empty string');
16993
- if (handler != null && typeof handler !== "function")
16994
- throw new TypeError('Expected the "progress" option to be a function');
16995
- await fsAccess(path.dirname(filename)).catch(() => {
16996
- throw new TypeError("Cannot save backup because the directory does not exist");
16997
- });
16998
- const isNewFile = await fsAccess(filename).then(() => false, () => true);
16999
- return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
17000
- };
17001
- var runBackup = (backup, handler) => {
17002
- let rate = 0;
17003
- let useDefault = true;
17004
- return new Promise((resolve2, reject) => {
17005
- setImmediate(function step() {
17006
- try {
17007
- const progress = backup.transfer(rate);
17008
- if (!progress.remainingPages) {
17009
- backup.close();
17010
- resolve2(progress);
17011
- return;
17012
- }
17013
- if (useDefault) {
17014
- useDefault = false;
17015
- rate = 100;
17016
- }
17017
- if (handler) {
17018
- const ret = handler(progress);
17019
- if (ret !== undefined) {
17020
- if (typeof ret === "number" && ret === ret)
17021
- rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
17022
- else
17023
- throw new TypeError("Expected progress callback to return a number or undefined");
17024
- }
17025
- }
17026
- setImmediate(step);
17027
- } catch (err) {
17028
- backup.close();
17029
- reject(err);
17030
- }
17031
- });
17032
- });
17033
- };
17034
- });
17035
-
17036
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/serialize.js
17037
- var require_serialize = __commonJS((exports, module) => {
17038
- var { cppdb } = require_util2();
17039
- module.exports = function serialize(options) {
17040
- if (options == null)
17041
- options = {};
17042
- if (typeof options !== "object")
17043
- throw new TypeError("Expected first argument to be an options object");
17044
- const attachedName = "attached" in options ? options.attached : "main";
17045
- if (typeof attachedName !== "string")
17046
- throw new TypeError('Expected the "attached" option to be a string');
17047
- if (!attachedName)
17048
- throw new TypeError('The "attached" option cannot be an empty string');
17049
- return this[cppdb].serialize(attachedName);
17050
- };
17051
- });
17052
-
17053
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/function.js
17054
- var require_function = __commonJS((exports, module) => {
17055
- var { getBooleanOption, cppdb } = require_util2();
17056
- module.exports = function defineFunction(name, options, fn) {
17057
- if (options == null)
17058
- options = {};
17059
- if (typeof options === "function") {
17060
- fn = options;
17061
- options = {};
17062
- }
17063
- if (typeof name !== "string")
17064
- throw new TypeError("Expected first argument to be a string");
17065
- if (typeof fn !== "function")
17066
- throw new TypeError("Expected last argument to be a function");
17067
- if (typeof options !== "object")
17068
- throw new TypeError("Expected second argument to be an options object");
17069
- if (!name)
17070
- throw new TypeError("User-defined function name cannot be an empty string");
17071
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
17072
- const deterministic = getBooleanOption(options, "deterministic");
17073
- const directOnly = getBooleanOption(options, "directOnly");
17074
- const varargs = getBooleanOption(options, "varargs");
17075
- let argCount = -1;
17076
- if (!varargs) {
17077
- argCount = fn.length;
17078
- if (!Number.isInteger(argCount) || argCount < 0)
17079
- throw new TypeError("Expected function.length to be a positive integer");
17080
- if (argCount > 100)
17081
- throw new RangeError("User-defined functions cannot have more than 100 arguments");
17082
- }
17083
- this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
17084
- return this;
17085
- };
17086
- });
17087
-
17088
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/aggregate.js
17089
- var require_aggregate = __commonJS((exports, module) => {
17090
- var { getBooleanOption, cppdb } = require_util2();
17091
- module.exports = function defineAggregate(name, options) {
17092
- if (typeof name !== "string")
17093
- throw new TypeError("Expected first argument to be a string");
17094
- if (typeof options !== "object" || options === null)
17095
- throw new TypeError("Expected second argument to be an options object");
17096
- if (!name)
17097
- throw new TypeError("User-defined function name cannot be an empty string");
17098
- const start = "start" in options ? options.start : null;
17099
- const step = getFunctionOption(options, "step", true);
17100
- const inverse = getFunctionOption(options, "inverse", false);
17101
- const result = getFunctionOption(options, "result", false);
17102
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
17103
- const deterministic = getBooleanOption(options, "deterministic");
17104
- const directOnly = getBooleanOption(options, "directOnly");
17105
- const varargs = getBooleanOption(options, "varargs");
17106
- let argCount = -1;
17107
- if (!varargs) {
17108
- argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
17109
- if (argCount > 0)
17110
- argCount -= 1;
17111
- if (argCount > 100)
17112
- throw new RangeError("User-defined functions cannot have more than 100 arguments");
17113
- }
17114
- this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
17115
- return this;
17116
- };
17117
- var getFunctionOption = (options, key, required) => {
17118
- const value = key in options ? options[key] : null;
17119
- if (typeof value === "function")
17120
- return value;
17121
- if (value != null)
17122
- throw new TypeError(`Expected the "${key}" option to be a function`);
17123
- if (required)
17124
- throw new TypeError(`Missing required option "${key}"`);
17125
- return null;
17126
- };
17127
- var getLength = ({ length }) => {
17128
- if (Number.isInteger(length) && length >= 0)
17129
- return length;
17130
- throw new TypeError("Expected function.length to be a positive integer");
17131
- };
17132
- });
17133
-
17134
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/table.js
17135
- var require_table = __commonJS((exports, module) => {
17136
- var { cppdb } = require_util2();
17137
- module.exports = function defineTable(name, factory) {
17138
- if (typeof name !== "string")
17139
- throw new TypeError("Expected first argument to be a string");
17140
- if (!name)
17141
- throw new TypeError("Virtual table module name cannot be an empty string");
17142
- let eponymous = false;
17143
- if (typeof factory === "object" && factory !== null) {
17144
- eponymous = true;
17145
- factory = defer(parseTableDefinition(factory, "used", name));
17146
- } else {
17147
- if (typeof factory !== "function")
17148
- throw new TypeError("Expected second argument to be a function or a table definition object");
17149
- factory = wrapFactory(factory);
17150
- }
17151
- this[cppdb].table(factory, name, eponymous);
17152
- return this;
17153
- };
17154
- function wrapFactory(factory) {
17155
- return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
17156
- const thisObject = {
17157
- module: moduleName,
17158
- database: databaseName,
17159
- table: tableName
17160
- };
17161
- const def = apply.call(factory, thisObject, args);
17162
- if (typeof def !== "object" || def === null) {
17163
- throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
17164
- }
17165
- return parseTableDefinition(def, "returned", moduleName);
17166
- };
17167
- }
17168
- function parseTableDefinition(def, verb, moduleName) {
17169
- if (!hasOwnProperty.call(def, "rows")) {
17170
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
17171
- }
17172
- if (!hasOwnProperty.call(def, "columns")) {
17173
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
17174
- }
17175
- const rows = def.rows;
17176
- if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
17177
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
17178
- }
17179
- let columns = def.columns;
17180
- if (!Array.isArray(columns) || !(columns = [...columns]).every((x2) => typeof x2 === "string")) {
17181
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
17182
- }
17183
- if (columns.length !== new Set(columns).size) {
17184
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
17185
- }
17186
- if (!columns.length) {
17187
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
17188
- }
17189
- let parameters;
17190
- if (hasOwnProperty.call(def, "parameters")) {
17191
- parameters = def.parameters;
17192
- if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x2) => typeof x2 === "string")) {
17193
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
17194
- }
17195
- } else {
17196
- parameters = inferParameters(rows);
17197
- }
17198
- if (parameters.length !== new Set(parameters).size) {
17199
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
17200
- }
17201
- if (parameters.length > 32) {
17202
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
17203
- }
17204
- for (const parameter of parameters) {
17205
- if (columns.includes(parameter)) {
17206
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
17207
- }
17208
- }
17209
- let safeIntegers = 2;
17210
- if (hasOwnProperty.call(def, "safeIntegers")) {
17211
- const bool = def.safeIntegers;
17212
- if (typeof bool !== "boolean") {
17213
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
17214
- }
17215
- safeIntegers = +bool;
17216
- }
17217
- let directOnly = false;
17218
- if (hasOwnProperty.call(def, "directOnly")) {
17219
- directOnly = def.directOnly;
17220
- if (typeof directOnly !== "boolean") {
17221
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
17222
- }
17223
- }
17224
- const columnDefinitions = [
17225
- ...parameters.map(identifier).map((str) => `${str} HIDDEN`),
17226
- ...columns.map(identifier)
17227
- ];
17228
- return [
17229
- `CREATE TABLE x(${columnDefinitions.join(", ")});`,
17230
- wrapGenerator(rows, new Map(columns.map((x2, i) => [x2, parameters.length + i])), moduleName),
17231
- parameters,
17232
- safeIntegers,
17233
- directOnly
17234
- ];
17235
- }
17236
- function wrapGenerator(generator2, columnMap, moduleName) {
17237
- return function* virtualTable(...args) {
17238
- const output = args.map((x2) => Buffer.isBuffer(x2) ? Buffer.from(x2) : x2);
17239
- for (let i = 0;i < columnMap.size; ++i) {
17240
- output.push(null);
17241
- }
17242
- for (const row of generator2(...args)) {
17243
- if (Array.isArray(row)) {
17244
- extractRowArray(row, output, columnMap.size, moduleName);
17245
- yield output;
17246
- } else if (typeof row === "object" && row !== null) {
17247
- extractRowObject(row, output, columnMap, moduleName);
17248
- yield output;
17249
- } else {
17250
- throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
17251
- }
17252
- }
17253
- };
17254
- }
17255
- function extractRowArray(row, output, columnCount, moduleName) {
17256
- if (row.length !== columnCount) {
17257
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
17258
- }
17259
- const offset = output.length - columnCount;
17260
- for (let i = 0;i < columnCount; ++i) {
17261
- output[i + offset] = row[i];
17262
- }
17263
- }
17264
- function extractRowObject(row, output, columnMap, moduleName) {
17265
- let count = 0;
17266
- for (const key of Object.keys(row)) {
17267
- const index = columnMap.get(key);
17268
- if (index === undefined) {
17269
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
17270
- }
17271
- output[index] = row[key];
17272
- count += 1;
17273
- }
17274
- if (count !== columnMap.size) {
17275
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
17276
- }
17277
- }
17278
- function inferParameters({ length }) {
17279
- if (!Number.isInteger(length) || length < 0) {
17280
- throw new TypeError("Expected function.length to be a positive integer");
17281
- }
17282
- const params = [];
17283
- for (let i = 0;i < length; ++i) {
17284
- params.push(`$${i + 1}`);
17285
- }
17286
- return params;
17287
- }
17288
- var { hasOwnProperty } = Object.prototype;
17289
- var { apply } = Function.prototype;
17290
- var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {});
17291
- var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
17292
- var defer = (x2) => () => x2;
17293
- });
17294
-
17295
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/methods/inspect.js
17296
- var require_inspect = __commonJS((exports, module) => {
17297
- var DatabaseInspection = function Database() {};
17298
- module.exports = function inspect(depth, opts) {
17299
- return Object.assign(new DatabaseInspection, this);
17300
- };
17301
- });
17302
-
17303
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/database.js
17304
- var require_database = __commonJS((exports, module) => {
17305
- var fs = __require("fs");
17306
- var path = __require("path");
17307
- var util = require_util2();
17308
- var SqliteError = require_sqlite_error();
17309
- var DEFAULT_ADDON;
17310
- function Database(filenameGiven, options) {
17311
- if (new.target == null) {
17312
- return new Database(filenameGiven, options);
17313
- }
17314
- let buffer;
17315
- if (Buffer.isBuffer(filenameGiven)) {
17316
- buffer = filenameGiven;
17317
- filenameGiven = ":memory:";
17318
- }
17319
- if (filenameGiven == null)
17320
- filenameGiven = "";
17321
- if (options == null)
17322
- options = {};
17323
- if (typeof filenameGiven !== "string")
17324
- throw new TypeError("Expected first argument to be a string");
17325
- if (typeof options !== "object")
17326
- throw new TypeError("Expected second argument to be an options object");
17327
- if ("readOnly" in options)
17328
- throw new TypeError('Misspelled option "readOnly" should be "readonly"');
17329
- if ("memory" in options)
17330
- throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
17331
- const filename = filenameGiven.trim();
17332
- const anonymous = filename === "" || filename === ":memory:";
17333
- const readonly = util.getBooleanOption(options, "readonly");
17334
- const fileMustExist = util.getBooleanOption(options, "fileMustExist");
17335
- const timeout = "timeout" in options ? options.timeout : 5000;
17336
- const verbose = "verbose" in options ? options.verbose : null;
17337
- const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
17338
- if (readonly && anonymous && !buffer)
17339
- throw new TypeError("In-memory/temporary databases cannot be readonly");
17340
- if (!Number.isInteger(timeout) || timeout < 0)
17341
- throw new TypeError('Expected the "timeout" option to be a positive integer');
17342
- if (timeout > 2147483647)
17343
- throw new RangeError('Option "timeout" cannot be greater than 2147483647');
17344
- if (verbose != null && typeof verbose !== "function")
17345
- throw new TypeError('Expected the "verbose" option to be a function');
17346
- if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object")
17347
- throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
17348
- let addon;
17349
- if (nativeBinding == null) {
17350
- addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
17351
- } else if (typeof nativeBinding === "string") {
17352
- const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
17353
- addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
17354
- } else {
17355
- addon = nativeBinding;
17356
- }
17357
- if (!addon.isInitialized) {
17358
- addon.setErrorConstructor(SqliteError);
17359
- addon.isInitialized = true;
17360
- }
17361
- if (!anonymous && !filename.startsWith("file:") && !fs.existsSync(path.dirname(filename))) {
17362
- throw new TypeError("Cannot open database because the directory does not exist");
17363
- }
17364
- Object.defineProperties(this, {
17365
- [util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
17366
- ...wrappers.getters
17367
- });
17368
- }
17369
- var wrappers = require_wrappers();
17370
- Database.prototype.prepare = wrappers.prepare;
17371
- Database.prototype.transaction = require_transaction();
17372
- Database.prototype.pragma = require_pragma();
17373
- Database.prototype.backup = require_backup();
17374
- Database.prototype.serialize = require_serialize();
17375
- Database.prototype.function = require_function();
17376
- Database.prototype.aggregate = require_aggregate();
17377
- Database.prototype.table = require_table();
17378
- Database.prototype.loadExtension = wrappers.loadExtension;
17379
- Database.prototype.exec = wrappers.exec;
17380
- Database.prototype.close = wrappers.close;
17381
- Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
17382
- Database.prototype.unsafeMode = wrappers.unsafeMode;
17383
- Database.prototype[util.inspect] = require_inspect();
17384
- module.exports = Database;
17385
- });
17386
-
17387
- // ../../node_modules/.bun/better-sqlite3@12.8.0/node_modules/better-sqlite3/lib/index.js
17388
- var require_lib2 = __commonJS((exports, module) => {
17389
- module.exports = require_database();
17390
- module.exports.SqliteError = require_sqlite_error();
17391
- });
17392
-
17393
16628
  // ../../node_modules/.bun/postgres@3.4.9/node_modules/postgres/src/query.js
17394
16629
  function cachedError(xs) {
17395
16630
  if (originCache.has(xs))
@@ -19381,7 +18616,7 @@ var init_src = __esm(() => {
19381
18616
  });
19382
18617
 
19383
18618
  // ../../node_modules/.bun/sql-escaper@1.3.3/node_modules/sql-escaper/lib/index.js
19384
- var require_lib3 = __commonJS((exports) => {
18619
+ var require_lib2 = __commonJS((exports) => {
19385
18620
  Object.defineProperty(exports, "__esModule", { value: true });
19386
18621
  exports.raw = exports.format = exports.escape = exports.arrayToList = exports.bufferToString = exports.objectToValues = exports.escapeId = exports.dateToString = undefined;
19387
18622
  var node_buffer_1 = __require("buffer");
@@ -19720,7 +18955,7 @@ var require_lib3 = __commonJS((exports) => {
19720
18955
  });
19721
18956
 
19722
18957
  // ../../node_modules/.bun/lru.min@1.1.4/node_modules/lru.min/lib/index.js
19723
- var require_lib4 = __commonJS((exports) => {
18958
+ var require_lib3 = __commonJS((exports) => {
19724
18959
  Object.defineProperty(exports, "__esModule", { value: true });
19725
18960
  exports.createLRU = undefined;
19726
18961
  var createLRU = (options) => {
@@ -19955,7 +19190,7 @@ var require_lib4 = __commonJS((exports) => {
19955
19190
 
19956
19191
  // ../../node_modules/.bun/mysql2@3.21.0+def1111dec9d54b0/node_modules/mysql2/lib/parsers/parser_cache.js
19957
19192
  var require_parser_cache = __commonJS((exports, module) => {
19958
- var { createLRU } = require_lib4();
19193
+ var { createLRU } = require_lib3();
19959
19194
  var parserCache = createLRU({
19960
19195
  max: 15000
19961
19196
  });
@@ -28750,7 +27985,7 @@ var require_streams = __commonJS((exports, module) => {
28750
27985
  });
28751
27986
 
28752
27987
  // ../../node_modules/.bun/iconv-lite@0.7.2/node_modules/iconv-lite/lib/index.js
28753
- var require_lib5 = __commonJS((exports, module) => {
27988
+ var require_lib4 = __commonJS((exports, module) => {
28754
27989
  var Buffer2 = require_safer().Buffer;
28755
27990
  var bomHandling = require_bom_handling();
28756
27991
  var mergeModules = require_merge_exports();
@@ -28877,8 +28112,8 @@ var require_lib5 = __commonJS((exports, module) => {
28877
28112
 
28878
28113
  // ../../node_modules/.bun/mysql2@3.21.0+def1111dec9d54b0/node_modules/mysql2/lib/parsers/string.js
28879
28114
  var require_string = __commonJS((exports) => {
28880
- var Iconv = require_lib5();
28881
- var { createLRU } = require_lib4();
28115
+ var Iconv = require_lib4();
28116
+ var { createLRU } = require_lib3();
28882
28117
  var decoderCache = createLRU({
28883
28118
  max: 500
28884
28119
  });
@@ -37936,7 +37171,7 @@ var require_proxies = __commonJS((exports) => {
37936
37171
  });
37937
37172
 
37938
37173
  // ../../node_modules/.bun/aws-ssl-profiles@1.1.2/node_modules/aws-ssl-profiles/lib/index.js
37939
- var require_lib6 = __commonJS((exports, module) => {
37174
+ var require_lib5 = __commonJS((exports, module) => {
37940
37175
  Object.defineProperty(exports, "__esModule", { value: true });
37941
37176
  var defaults_js_1 = require_defaults();
37942
37177
  var proxies_js_1 = require_proxies();
@@ -37953,7 +37188,7 @@ var require_lib6 = __commonJS((exports, module) => {
37953
37188
 
37954
37189
  // ../../node_modules/.bun/mysql2@3.21.0+def1111dec9d54b0/node_modules/mysql2/lib/constants/ssl_profiles.js
37955
37190
  var require_ssl_profiles = __commonJS((exports) => {
37956
- var awsCaBundle = require_lib6();
37191
+ var awsCaBundle = require_lib5();
37957
37192
  exports["Amazon RDS"] = {
37958
37193
  ca: awsCaBundle.ca
37959
37194
  };
@@ -38329,7 +37564,7 @@ var require_named_placeholders = __commonJS((exports, module) => {
38329
37564
  cache = config.cache;
38330
37565
  }
38331
37566
  if (config.cache !== false && !cache) {
38332
- cache = require_lib4().createLRU({ max: ncache });
37567
+ cache = require_lib3().createLRU({ max: ncache });
38333
37568
  }
38334
37569
  function toArrayParams(tree, params) {
38335
37570
  const arr = [];
@@ -38423,8 +37658,8 @@ var require_connection = __commonJS((exports, module) => {
38423
37658
  var EventEmitter = __require("events").EventEmitter;
38424
37659
  var Readable2 = __require("stream").Readable;
38425
37660
  var Queue2 = require_denque();
38426
- var SqlString = require_lib3();
38427
- var { createLRU } = require_lib4();
37661
+ var SqlString = require_lib2();
37662
+ var { createLRU } = require_lib3();
38428
37663
  var PacketParser = require_packet_parser();
38429
37664
  var Packets = require_packets();
38430
37665
  var Commands = require_commands2();
@@ -39611,7 +38846,7 @@ var require_pool_connection2 = __commonJS((exports, module) => {
39611
38846
  // ../../node_modules/.bun/mysql2@3.21.0+def1111dec9d54b0/node_modules/mysql2/lib/base/pool.js
39612
38847
  var require_pool = __commonJS((exports, module) => {
39613
38848
  var process2 = __require("process");
39614
- var SqlString = require_lib3();
38849
+ var SqlString = require_lib2();
39615
38850
  var EventEmitter = __require("events").EventEmitter;
39616
38851
  var PoolConnection = require_pool_connection2();
39617
38852
  var Queue2 = require_denque();
@@ -40367,7 +39602,7 @@ var require_pool_cluster2 = __commonJS((exports, module) => {
40367
39602
 
40368
39603
  // ../../node_modules/.bun/mysql2@3.21.0+def1111dec9d54b0/node_modules/mysql2/promise.js
40369
39604
  var require_promise = __commonJS((exports) => {
40370
- var SqlString = require_lib3();
39605
+ var SqlString = require_lib2();
40371
39606
  var EventEmitter = __require("events").EventEmitter;
40372
39607
  var parserCache = require_parser_cache();
40373
39608
  var PoolCluster = require_pool_cluster();
@@ -46866,8 +46101,8 @@ class ConnectionPool {
46866
46101
  const { Database } = await import("bun:sqlite");
46867
46102
  return new Database(config.path);
46868
46103
  }
46869
- const BetterSqlite3 = require_lib2();
46870
- return BetterSqlite3(config.path);
46104
+ const sqlite3 = __require("@vscode/sqlite3");
46105
+ return new sqlite3.Database(config.path);
46871
46106
  }
46872
46107
  async createPostgresConnection(config) {
46873
46108
  const url = `postgres://${config.user}:${config.password}@${config.host}:${config.port}/${config.database}`;
@@ -47033,11 +46268,25 @@ class DatabaseConnectionManager {
47033
46268
  }
47034
46269
  async healthCheckSqlite(connection2) {
47035
46270
  try {
47036
- if (connection2 && typeof connection2 === "object" && "query" in connection2 && typeof connection2.query === "function") {
46271
+ if (!connection2 || typeof connection2 !== "object") {
46272
+ return false;
46273
+ }
46274
+ if ("query" in connection2 && typeof connection2.query === "function" && !(("all" in connection2) && ("run" in connection2))) {
47037
46275
  const db2 = connection2;
47038
46276
  db2.query("SELECT 1").all();
47039
46277
  return true;
47040
46278
  }
46279
+ if ("all" in connection2 && typeof connection2.all === "function") {
46280
+ await new Promise((resolve2, reject) => {
46281
+ connection2.all("SELECT 1", [], (err) => {
46282
+ if (err)
46283
+ reject(err);
46284
+ else
46285
+ resolve2();
46286
+ });
46287
+ });
46288
+ return true;
46289
+ }
47041
46290
  return false;
47042
46291
  } catch (_error) {
47043
46292
  return false;
@@ -47147,12 +46396,22 @@ class DatabaseService2 {
47147
46396
  throw new Error(`Query not supported for database type: ${dbType}`);
47148
46397
  }
47149
46398
  querySqlite(connection2, sql, params) {
47150
- if (connection2 && typeof connection2 === "object" && "query" in connection2 && typeof connection2.query === "function") {
46399
+ if (connection2 && typeof connection2 === "object" && "query" in connection2 && typeof connection2.query === "function" && !(("all" in connection2) && ("run" in connection2))) {
47151
46400
  const db2 = connection2;
47152
46401
  const statement = db2.query(sql);
47153
46402
  const result = params && params.length > 0 ? statement.all(...params) : statement.all();
47154
46403
  return result;
47155
46404
  }
46405
+ if (connection2 && typeof connection2 === "object" && "all" in connection2 && typeof connection2.all === "function") {
46406
+ return new Promise((resolve2, reject) => {
46407
+ connection2.all(sql, params ?? [], (err, rows) => {
46408
+ if (err)
46409
+ reject(err);
46410
+ else
46411
+ resolve2(rows ?? []);
46412
+ });
46413
+ });
46414
+ }
47156
46415
  throw new Error("Invalid SQLite connection");
47157
46416
  }
47158
46417
  async queryBunSQL(connection2, sql, params) {
@@ -47323,24 +46582,29 @@ class SqliteAdapter {
47323
46582
  }
47324
46583
  this.db = db2;
47325
46584
  } else {
47326
- const BetterSqlite3 = require_lib2();
47327
- const db2 = BetterSqlite3(config.database);
46585
+ const sqlite3 = __require("@vscode/sqlite3");
46586
+ const db2 = new sqlite3.Database(config.database);
47328
46587
  if (config.wal !== false) {
47329
- db2.exec("PRAGMA journal_mode = WAL;");
46588
+ db2.run("PRAGMA journal_mode = WAL;");
47330
46589
  }
47331
46590
  this.db = db2;
47332
46591
  }
47333
46592
  this.semaphore = new Semaphore(config.maxWriteConcurrency ?? 1);
47334
46593
  }
47335
- query(sql, params = []) {
46594
+ async query(sql, params = []) {
47336
46595
  if (this.isBun) {
47337
- const db3 = this.db;
47338
- const stmt2 = db3.query(sql);
47339
- return stmt2.all(...params);
46596
+ const db2 = this.db;
46597
+ const stmt = db2.query(sql);
46598
+ return stmt.all(...params);
47340
46599
  }
47341
- const db2 = this.db;
47342
- const stmt = db2.prepare(sql);
47343
- return stmt.all(...params);
46600
+ return new Promise((resolve2, reject) => {
46601
+ this.db.all(sql, params, (err, rows) => {
46602
+ if (err)
46603
+ reject(err);
46604
+ else
46605
+ resolve2(rows ?? []);
46606
+ });
46607
+ });
47344
46608
  }
47345
46609
  async execute(sql, params = []) {
47346
46610
  if (this.isBun) {
@@ -47348,9 +46612,14 @@ class SqliteAdapter {
47348
46612
  const stmt = db2.query(sql);
47349
46613
  stmt.run(...params);
47350
46614
  } else {
47351
- const db2 = this.db;
47352
- const stmt = db2.prepare(sql);
47353
- stmt.run(...params);
46615
+ return new Promise((resolve2, reject) => {
46616
+ this.db.run(sql, params, (err) => {
46617
+ if (err)
46618
+ reject(err);
46619
+ else
46620
+ resolve2();
46621
+ });
46622
+ });
47354
46623
  }
47355
46624
  }
47356
46625
  close() {