kb-tool 0.1.0 → 0.1.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 +37 -782
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-C5Q7R5PP.js +0 -53
- package/dist/chunk-C5Q7R5PP.js.map +0 -1
- package/dist/chunk-QJ5CPQJK.js +0 -2053
- package/dist/chunk-QJ5CPQJK.js.map +0 -1
- package/dist/fileFromPath-V2EETFVE.js +0 -130
- package/dist/fileFromPath-V2EETFVE.js.map +0 -1
- package/dist/pdf-parse-DNR3SHDS.js +0 -239472
- package/dist/pdf-parse-DNR3SHDS.js.map +0 -1
- package/dist/sdk-M7HXOGZH.js +0 -7458
- package/dist/sdk-M7HXOGZH.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
7
33
|
|
|
8
34
|
// ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js
|
|
9
35
|
var require_parser = __commonJS({
|
|
@@ -2000,777 +2026,6 @@ var require_toml = __commonJS({
|
|
|
2000
2026
|
}
|
|
2001
2027
|
});
|
|
2002
2028
|
|
|
2003
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/util.js
|
|
2004
|
-
var require_util = __commonJS({
|
|
2005
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/util.js"(exports2) {
|
|
2006
|
-
"use strict";
|
|
2007
|
-
exports2.getBooleanOption = (options2, key) => {
|
|
2008
|
-
let value = false;
|
|
2009
|
-
if (key in options2 && typeof (value = options2[key]) !== "boolean") {
|
|
2010
|
-
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
2011
|
-
}
|
|
2012
|
-
return value;
|
|
2013
|
-
};
|
|
2014
|
-
exports2.cppdb = /* @__PURE__ */ Symbol();
|
|
2015
|
-
exports2.inspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
2016
|
-
}
|
|
2017
|
-
});
|
|
2018
|
-
|
|
2019
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/sqlite-error.js
|
|
2020
|
-
var require_sqlite_error = __commonJS({
|
|
2021
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/sqlite-error.js"(exports2, module2) {
|
|
2022
|
-
"use strict";
|
|
2023
|
-
var descriptor2 = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
2024
|
-
function SqliteError(message, code) {
|
|
2025
|
-
if (new.target !== SqliteError) {
|
|
2026
|
-
return new SqliteError(message, code);
|
|
2027
|
-
}
|
|
2028
|
-
if (typeof code !== "string") {
|
|
2029
|
-
throw new TypeError("Expected second argument to be a string");
|
|
2030
|
-
}
|
|
2031
|
-
Error.call(this, message);
|
|
2032
|
-
descriptor2.value = "" + message;
|
|
2033
|
-
Object.defineProperty(this, "message", descriptor2);
|
|
2034
|
-
Error.captureStackTrace(this, SqliteError);
|
|
2035
|
-
this.code = code;
|
|
2036
|
-
}
|
|
2037
|
-
Object.setPrototypeOf(SqliteError, Error);
|
|
2038
|
-
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
2039
|
-
Object.defineProperty(SqliteError.prototype, "name", descriptor2);
|
|
2040
|
-
module2.exports = SqliteError;
|
|
2041
|
-
}
|
|
2042
|
-
});
|
|
2043
|
-
|
|
2044
|
-
// ../../node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js
|
|
2045
|
-
var require_file_uri_to_path = __commonJS({
|
|
2046
|
-
"../../node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js"(exports2, module2) {
|
|
2047
|
-
"use strict";
|
|
2048
|
-
var sep = __require("path").sep || "/";
|
|
2049
|
-
module2.exports = fileUriToPath;
|
|
2050
|
-
function fileUriToPath(uri) {
|
|
2051
|
-
if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
|
|
2052
|
-
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
2053
|
-
}
|
|
2054
|
-
var rest = decodeURI(uri.substring(7));
|
|
2055
|
-
var firstSlash = rest.indexOf("/");
|
|
2056
|
-
var host = rest.substring(0, firstSlash);
|
|
2057
|
-
var path = rest.substring(firstSlash + 1);
|
|
2058
|
-
if ("localhost" == host) host = "";
|
|
2059
|
-
if (host) {
|
|
2060
|
-
host = sep + sep + host;
|
|
2061
|
-
}
|
|
2062
|
-
path = path.replace(/^(.+)\|/, "$1:");
|
|
2063
|
-
if (sep == "\\") {
|
|
2064
|
-
path = path.replace(/\//g, "\\");
|
|
2065
|
-
}
|
|
2066
|
-
if (/^.+\:/.test(path)) {
|
|
2067
|
-
} else {
|
|
2068
|
-
path = sep + path;
|
|
2069
|
-
}
|
|
2070
|
-
return host + path;
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
});
|
|
2074
|
-
|
|
2075
|
-
// ../../node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js
|
|
2076
|
-
var require_bindings = __commonJS({
|
|
2077
|
-
"../../node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js"(exports2, module2) {
|
|
2078
|
-
"use strict";
|
|
2079
|
-
var fs = __require("fs");
|
|
2080
|
-
var path = __require("path");
|
|
2081
|
-
var fileURLToPath = require_file_uri_to_path();
|
|
2082
|
-
var join11 = path.join;
|
|
2083
|
-
var dirname3 = path.dirname;
|
|
2084
|
-
var exists = fs.accessSync && function(path2) {
|
|
2085
|
-
try {
|
|
2086
|
-
fs.accessSync(path2);
|
|
2087
|
-
} catch (e) {
|
|
2088
|
-
return false;
|
|
2089
|
-
}
|
|
2090
|
-
return true;
|
|
2091
|
-
} || fs.existsSync || path.existsSync;
|
|
2092
|
-
var defaults = {
|
|
2093
|
-
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
2094
|
-
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
2095
|
-
platform: process.platform,
|
|
2096
|
-
arch: process.arch,
|
|
2097
|
-
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
2098
|
-
version: process.versions.node,
|
|
2099
|
-
bindings: "bindings.node",
|
|
2100
|
-
try: [
|
|
2101
|
-
// node-gyp's linked version in the "build" dir
|
|
2102
|
-
["module_root", "build", "bindings"],
|
|
2103
|
-
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
2104
|
-
["module_root", "build", "Debug", "bindings"],
|
|
2105
|
-
["module_root", "build", "Release", "bindings"],
|
|
2106
|
-
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
2107
|
-
["module_root", "out", "Debug", "bindings"],
|
|
2108
|
-
["module_root", "Debug", "bindings"],
|
|
2109
|
-
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
2110
|
-
["module_root", "out", "Release", "bindings"],
|
|
2111
|
-
["module_root", "Release", "bindings"],
|
|
2112
|
-
// Legacy from node-waf, node <= 0.4.x
|
|
2113
|
-
["module_root", "build", "default", "bindings"],
|
|
2114
|
-
// Production "Release" buildtype binary (meh...)
|
|
2115
|
-
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
2116
|
-
// node-qbs builds
|
|
2117
|
-
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
2118
|
-
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
2119
|
-
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
2120
|
-
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
2121
|
-
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
2122
|
-
]
|
|
2123
|
-
};
|
|
2124
|
-
function bindings(opts) {
|
|
2125
|
-
if (typeof opts == "string") {
|
|
2126
|
-
opts = { bindings: opts };
|
|
2127
|
-
} else if (!opts) {
|
|
2128
|
-
opts = {};
|
|
2129
|
-
}
|
|
2130
|
-
Object.keys(defaults).map(function(i2) {
|
|
2131
|
-
if (!(i2 in opts)) opts[i2] = defaults[i2];
|
|
2132
|
-
});
|
|
2133
|
-
if (!opts.module_root) {
|
|
2134
|
-
opts.module_root = exports2.getRoot(exports2.getFileName());
|
|
2135
|
-
}
|
|
2136
|
-
if (path.extname(opts.bindings) != ".node") {
|
|
2137
|
-
opts.bindings += ".node";
|
|
2138
|
-
}
|
|
2139
|
-
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
2140
|
-
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
2141
|
-
for (; i < l; i++) {
|
|
2142
|
-
n = join11.apply(
|
|
2143
|
-
null,
|
|
2144
|
-
opts.try[i].map(function(p) {
|
|
2145
|
-
return opts[p] || p;
|
|
2146
|
-
})
|
|
2147
|
-
);
|
|
2148
|
-
tries.push(n);
|
|
2149
|
-
try {
|
|
2150
|
-
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
2151
|
-
if (!opts.path) {
|
|
2152
|
-
b.path = n;
|
|
2153
|
-
}
|
|
2154
|
-
return b;
|
|
2155
|
-
} catch (e) {
|
|
2156
|
-
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
2157
|
-
throw e;
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
err = new Error(
|
|
2162
|
-
"Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
|
|
2163
|
-
return opts.arrow + a;
|
|
2164
|
-
}).join("\n")
|
|
2165
|
-
);
|
|
2166
|
-
err.tries = tries;
|
|
2167
|
-
throw err;
|
|
2168
|
-
}
|
|
2169
|
-
module2.exports = exports2 = bindings;
|
|
2170
|
-
exports2.getFileName = function getFileName(calling_file) {
|
|
2171
|
-
var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
|
|
2172
|
-
Error.stackTraceLimit = 10;
|
|
2173
|
-
Error.prepareStackTrace = function(e, st) {
|
|
2174
|
-
for (var i = 0, l = st.length; i < l; i++) {
|
|
2175
|
-
fileName = st[i].getFileName();
|
|
2176
|
-
if (fileName !== __filename) {
|
|
2177
|
-
if (calling_file) {
|
|
2178
|
-
if (fileName !== calling_file) {
|
|
2179
|
-
return;
|
|
2180
|
-
}
|
|
2181
|
-
} else {
|
|
2182
|
-
return;
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
};
|
|
2187
|
-
Error.captureStackTrace(dummy);
|
|
2188
|
-
dummy.stack;
|
|
2189
|
-
Error.prepareStackTrace = origPST;
|
|
2190
|
-
Error.stackTraceLimit = origSTL;
|
|
2191
|
-
var fileSchema = "file://";
|
|
2192
|
-
if (fileName.indexOf(fileSchema) === 0) {
|
|
2193
|
-
fileName = fileURLToPath(fileName);
|
|
2194
|
-
}
|
|
2195
|
-
return fileName;
|
|
2196
|
-
};
|
|
2197
|
-
exports2.getRoot = function getRoot(file) {
|
|
2198
|
-
var dir = dirname3(file), prev;
|
|
2199
|
-
while (true) {
|
|
2200
|
-
if (dir === ".") {
|
|
2201
|
-
dir = process.cwd();
|
|
2202
|
-
}
|
|
2203
|
-
if (exists(join11(dir, "package.json")) || exists(join11(dir, "node_modules"))) {
|
|
2204
|
-
return dir;
|
|
2205
|
-
}
|
|
2206
|
-
if (prev === dir) {
|
|
2207
|
-
throw new Error(
|
|
2208
|
-
'Could not find module root given file: "' + file + '". Do you have a `package.json` file? '
|
|
2209
|
-
);
|
|
2210
|
-
}
|
|
2211
|
-
prev = dir;
|
|
2212
|
-
dir = join11(dir, "..");
|
|
2213
|
-
}
|
|
2214
|
-
};
|
|
2215
|
-
}
|
|
2216
|
-
});
|
|
2217
|
-
|
|
2218
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
2219
|
-
var require_wrappers = __commonJS({
|
|
2220
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/wrappers.js"(exports2) {
|
|
2221
|
-
"use strict";
|
|
2222
|
-
var { cppdb } = require_util();
|
|
2223
|
-
exports2.prepare = function prepare(sql) {
|
|
2224
|
-
return this[cppdb].prepare(sql, this, false);
|
|
2225
|
-
};
|
|
2226
|
-
exports2.exec = function exec(sql) {
|
|
2227
|
-
this[cppdb].exec(sql);
|
|
2228
|
-
return this;
|
|
2229
|
-
};
|
|
2230
|
-
exports2.close = function close() {
|
|
2231
|
-
this[cppdb].close();
|
|
2232
|
-
return this;
|
|
2233
|
-
};
|
|
2234
|
-
exports2.loadExtension = function loadExtension(...args) {
|
|
2235
|
-
this[cppdb].loadExtension(...args);
|
|
2236
|
-
return this;
|
|
2237
|
-
};
|
|
2238
|
-
exports2.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
2239
|
-
this[cppdb].defaultSafeIntegers(...args);
|
|
2240
|
-
return this;
|
|
2241
|
-
};
|
|
2242
|
-
exports2.unsafeMode = function unsafeMode(...args) {
|
|
2243
|
-
this[cppdb].unsafeMode(...args);
|
|
2244
|
-
return this;
|
|
2245
|
-
};
|
|
2246
|
-
exports2.getters = {
|
|
2247
|
-
name: {
|
|
2248
|
-
get: function name() {
|
|
2249
|
-
return this[cppdb].name;
|
|
2250
|
-
},
|
|
2251
|
-
enumerable: true
|
|
2252
|
-
},
|
|
2253
|
-
open: {
|
|
2254
|
-
get: function open() {
|
|
2255
|
-
return this[cppdb].open;
|
|
2256
|
-
},
|
|
2257
|
-
enumerable: true
|
|
2258
|
-
},
|
|
2259
|
-
inTransaction: {
|
|
2260
|
-
get: function inTransaction() {
|
|
2261
|
-
return this[cppdb].inTransaction;
|
|
2262
|
-
},
|
|
2263
|
-
enumerable: true
|
|
2264
|
-
},
|
|
2265
|
-
readonly: {
|
|
2266
|
-
get: function readonly() {
|
|
2267
|
-
return this[cppdb].readonly;
|
|
2268
|
-
},
|
|
2269
|
-
enumerable: true
|
|
2270
|
-
},
|
|
2271
|
-
memory: {
|
|
2272
|
-
get: function memory() {
|
|
2273
|
-
return this[cppdb].memory;
|
|
2274
|
-
},
|
|
2275
|
-
enumerable: true
|
|
2276
|
-
}
|
|
2277
|
-
};
|
|
2278
|
-
}
|
|
2279
|
-
});
|
|
2280
|
-
|
|
2281
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/transaction.js
|
|
2282
|
-
var require_transaction = __commonJS({
|
|
2283
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/transaction.js"(exports2, module2) {
|
|
2284
|
-
"use strict";
|
|
2285
|
-
var { cppdb } = require_util();
|
|
2286
|
-
var controllers = /* @__PURE__ */ new WeakMap();
|
|
2287
|
-
module2.exports = function transaction(fn) {
|
|
2288
|
-
if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
|
|
2289
|
-
const db = this[cppdb];
|
|
2290
|
-
const controller = getController(db, this);
|
|
2291
|
-
const { apply } = Function.prototype;
|
|
2292
|
-
const properties = {
|
|
2293
|
-
default: { value: wrapTransaction(apply, fn, db, controller.default) },
|
|
2294
|
-
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
|
|
2295
|
-
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
|
|
2296
|
-
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
|
|
2297
|
-
database: { value: this, enumerable: true }
|
|
2298
|
-
};
|
|
2299
|
-
Object.defineProperties(properties.default.value, properties);
|
|
2300
|
-
Object.defineProperties(properties.deferred.value, properties);
|
|
2301
|
-
Object.defineProperties(properties.immediate.value, properties);
|
|
2302
|
-
Object.defineProperties(properties.exclusive.value, properties);
|
|
2303
|
-
return properties.default.value;
|
|
2304
|
-
};
|
|
2305
|
-
var getController = (db, self) => {
|
|
2306
|
-
let controller = controllers.get(db);
|
|
2307
|
-
if (!controller) {
|
|
2308
|
-
const shared = {
|
|
2309
|
-
commit: db.prepare("COMMIT", self, false),
|
|
2310
|
-
rollback: db.prepare("ROLLBACK", self, false),
|
|
2311
|
-
savepoint: db.prepare("SAVEPOINT ` _bs3. `", self, false),
|
|
2312
|
-
release: db.prepare("RELEASE ` _bs3. `", self, false),
|
|
2313
|
-
rollbackTo: db.prepare("ROLLBACK TO ` _bs3. `", self, false)
|
|
2314
|
-
};
|
|
2315
|
-
controllers.set(db, controller = {
|
|
2316
|
-
default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
|
|
2317
|
-
deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
2318
|
-
immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
2319
|
-
exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
2320
|
-
});
|
|
2321
|
-
}
|
|
2322
|
-
return controller;
|
|
2323
|
-
};
|
|
2324
|
-
var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
2325
|
-
let before, after, undo;
|
|
2326
|
-
if (db.inTransaction) {
|
|
2327
|
-
before = savepoint;
|
|
2328
|
-
after = release;
|
|
2329
|
-
undo = rollbackTo;
|
|
2330
|
-
} else {
|
|
2331
|
-
before = begin;
|
|
2332
|
-
after = commit;
|
|
2333
|
-
undo = rollback;
|
|
2334
|
-
}
|
|
2335
|
-
before.run();
|
|
2336
|
-
try {
|
|
2337
|
-
const result = apply.call(fn, this, arguments);
|
|
2338
|
-
after.run();
|
|
2339
|
-
return result;
|
|
2340
|
-
} catch (ex) {
|
|
2341
|
-
if (db.inTransaction) {
|
|
2342
|
-
undo.run();
|
|
2343
|
-
if (undo !== rollback) after.run();
|
|
2344
|
-
}
|
|
2345
|
-
throw ex;
|
|
2346
|
-
}
|
|
2347
|
-
};
|
|
2348
|
-
}
|
|
2349
|
-
});
|
|
2350
|
-
|
|
2351
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/pragma.js
|
|
2352
|
-
var require_pragma = __commonJS({
|
|
2353
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/pragma.js"(exports2, module2) {
|
|
2354
|
-
"use strict";
|
|
2355
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
2356
|
-
module2.exports = function pragma(source, options2) {
|
|
2357
|
-
if (options2 == null) options2 = {};
|
|
2358
|
-
if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
|
|
2359
|
-
if (typeof options2 !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
2360
|
-
const simple = getBooleanOption(options2, "simple");
|
|
2361
|
-
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
2362
|
-
return simple ? stmt.pluck().get() : stmt.all();
|
|
2363
|
-
};
|
|
2364
|
-
}
|
|
2365
|
-
});
|
|
2366
|
-
|
|
2367
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/backup.js
|
|
2368
|
-
var require_backup = __commonJS({
|
|
2369
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/backup.js"(exports2, module2) {
|
|
2370
|
-
"use strict";
|
|
2371
|
-
var fs = __require("fs");
|
|
2372
|
-
var path = __require("path");
|
|
2373
|
-
var { promisify } = __require("util");
|
|
2374
|
-
var { cppdb } = require_util();
|
|
2375
|
-
var fsAccess = promisify(fs.access);
|
|
2376
|
-
module2.exports = async function backup(filename, options2) {
|
|
2377
|
-
if (options2 == null) options2 = {};
|
|
2378
|
-
if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
|
|
2379
|
-
if (typeof options2 !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
2380
|
-
filename = filename.trim();
|
|
2381
|
-
const attachedName = "attached" in options2 ? options2.attached : "main";
|
|
2382
|
-
const handler = "progress" in options2 ? options2.progress : null;
|
|
2383
|
-
if (!filename) throw new TypeError("Backup filename cannot be an empty string");
|
|
2384
|
-
if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
|
|
2385
|
-
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
2386
|
-
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
2387
|
-
if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
|
|
2388
|
-
await fsAccess(path.dirname(filename)).catch(() => {
|
|
2389
|
-
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
2390
|
-
});
|
|
2391
|
-
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
2392
|
-
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
2393
|
-
};
|
|
2394
|
-
var runBackup = (backup, handler) => {
|
|
2395
|
-
let rate = 0;
|
|
2396
|
-
let useDefault = true;
|
|
2397
|
-
return new Promise((resolve4, reject) => {
|
|
2398
|
-
setImmediate(function step() {
|
|
2399
|
-
try {
|
|
2400
|
-
const progress = backup.transfer(rate);
|
|
2401
|
-
if (!progress.remainingPages) {
|
|
2402
|
-
backup.close();
|
|
2403
|
-
resolve4(progress);
|
|
2404
|
-
return;
|
|
2405
|
-
}
|
|
2406
|
-
if (useDefault) {
|
|
2407
|
-
useDefault = false;
|
|
2408
|
-
rate = 100;
|
|
2409
|
-
}
|
|
2410
|
-
if (handler) {
|
|
2411
|
-
const ret = handler(progress);
|
|
2412
|
-
if (ret !== void 0) {
|
|
2413
|
-
if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
2414
|
-
else throw new TypeError("Expected progress callback to return a number or undefined");
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
setImmediate(step);
|
|
2418
|
-
} catch (err) {
|
|
2419
|
-
backup.close();
|
|
2420
|
-
reject(err);
|
|
2421
|
-
}
|
|
2422
|
-
});
|
|
2423
|
-
});
|
|
2424
|
-
};
|
|
2425
|
-
}
|
|
2426
|
-
});
|
|
2427
|
-
|
|
2428
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/serialize.js
|
|
2429
|
-
var require_serialize = __commonJS({
|
|
2430
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/serialize.js"(exports2, module2) {
|
|
2431
|
-
"use strict";
|
|
2432
|
-
var { cppdb } = require_util();
|
|
2433
|
-
module2.exports = function serialize(options2) {
|
|
2434
|
-
if (options2 == null) options2 = {};
|
|
2435
|
-
if (typeof options2 !== "object") throw new TypeError("Expected first argument to be an options object");
|
|
2436
|
-
const attachedName = "attached" in options2 ? options2.attached : "main";
|
|
2437
|
-
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
2438
|
-
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
2439
|
-
return this[cppdb].serialize(attachedName);
|
|
2440
|
-
};
|
|
2441
|
-
}
|
|
2442
|
-
});
|
|
2443
|
-
|
|
2444
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/function.js
|
|
2445
|
-
var require_function = __commonJS({
|
|
2446
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/function.js"(exports2, module2) {
|
|
2447
|
-
"use strict";
|
|
2448
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
2449
|
-
module2.exports = function defineFunction(name, options2, fn) {
|
|
2450
|
-
if (options2 == null) options2 = {};
|
|
2451
|
-
if (typeof options2 === "function") {
|
|
2452
|
-
fn = options2;
|
|
2453
|
-
options2 = {};
|
|
2454
|
-
}
|
|
2455
|
-
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
2456
|
-
if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
|
|
2457
|
-
if (typeof options2 !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
2458
|
-
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
2459
|
-
const safeIntegers = "safeIntegers" in options2 ? +getBooleanOption(options2, "safeIntegers") : 2;
|
|
2460
|
-
const deterministic = getBooleanOption(options2, "deterministic");
|
|
2461
|
-
const directOnly = getBooleanOption(options2, "directOnly");
|
|
2462
|
-
const varargs = getBooleanOption(options2, "varargs");
|
|
2463
|
-
let argCount = -1;
|
|
2464
|
-
if (!varargs) {
|
|
2465
|
-
argCount = fn.length;
|
|
2466
|
-
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
|
|
2467
|
-
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
2468
|
-
}
|
|
2469
|
-
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
2470
|
-
return this;
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
});
|
|
2474
|
-
|
|
2475
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
2476
|
-
var require_aggregate = __commonJS({
|
|
2477
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/aggregate.js"(exports2, module2) {
|
|
2478
|
-
"use strict";
|
|
2479
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
2480
|
-
module2.exports = function defineAggregate(name, options2) {
|
|
2481
|
-
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
2482
|
-
if (typeof options2 !== "object" || options2 === null) throw new TypeError("Expected second argument to be an options object");
|
|
2483
|
-
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
2484
|
-
const start = "start" in options2 ? options2.start : null;
|
|
2485
|
-
const step = getFunctionOption(options2, "step", true);
|
|
2486
|
-
const inverse = getFunctionOption(options2, "inverse", false);
|
|
2487
|
-
const result = getFunctionOption(options2, "result", false);
|
|
2488
|
-
const safeIntegers = "safeIntegers" in options2 ? +getBooleanOption(options2, "safeIntegers") : 2;
|
|
2489
|
-
const deterministic = getBooleanOption(options2, "deterministic");
|
|
2490
|
-
const directOnly = getBooleanOption(options2, "directOnly");
|
|
2491
|
-
const varargs = getBooleanOption(options2, "varargs");
|
|
2492
|
-
let argCount = -1;
|
|
2493
|
-
if (!varargs) {
|
|
2494
|
-
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
2495
|
-
if (argCount > 0) argCount -= 1;
|
|
2496
|
-
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
2497
|
-
}
|
|
2498
|
-
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
2499
|
-
return this;
|
|
2500
|
-
};
|
|
2501
|
-
var getFunctionOption = (options2, key, required) => {
|
|
2502
|
-
const value = key in options2 ? options2[key] : null;
|
|
2503
|
-
if (typeof value === "function") return value;
|
|
2504
|
-
if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
2505
|
-
if (required) throw new TypeError(`Missing required option "${key}"`);
|
|
2506
|
-
return null;
|
|
2507
|
-
};
|
|
2508
|
-
var getLength = ({ length }) => {
|
|
2509
|
-
if (Number.isInteger(length) && length >= 0) return length;
|
|
2510
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
2511
|
-
};
|
|
2512
|
-
}
|
|
2513
|
-
});
|
|
2514
|
-
|
|
2515
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/table.js
|
|
2516
|
-
var require_table = __commonJS({
|
|
2517
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/table.js"(exports2, module2) {
|
|
2518
|
-
"use strict";
|
|
2519
|
-
var { cppdb } = require_util();
|
|
2520
|
-
module2.exports = function defineTable(name, factory) {
|
|
2521
|
-
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
2522
|
-
if (!name) throw new TypeError("Virtual table module name cannot be an empty string");
|
|
2523
|
-
let eponymous = false;
|
|
2524
|
-
if (typeof factory === "object" && factory !== null) {
|
|
2525
|
-
eponymous = true;
|
|
2526
|
-
factory = defer(parseTableDefinition(factory, "used", name));
|
|
2527
|
-
} else {
|
|
2528
|
-
if (typeof factory !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
2529
|
-
factory = wrapFactory(factory);
|
|
2530
|
-
}
|
|
2531
|
-
this[cppdb].table(factory, name, eponymous);
|
|
2532
|
-
return this;
|
|
2533
|
-
};
|
|
2534
|
-
function wrapFactory(factory) {
|
|
2535
|
-
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
2536
|
-
const thisObject = {
|
|
2537
|
-
module: moduleName,
|
|
2538
|
-
database: databaseName,
|
|
2539
|
-
table: tableName
|
|
2540
|
-
};
|
|
2541
|
-
const def = apply.call(factory, thisObject, args);
|
|
2542
|
-
if (typeof def !== "object" || def === null) {
|
|
2543
|
-
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
2544
|
-
}
|
|
2545
|
-
return parseTableDefinition(def, "returned", moduleName);
|
|
2546
|
-
};
|
|
2547
|
-
}
|
|
2548
|
-
function parseTableDefinition(def, verb, moduleName) {
|
|
2549
|
-
if (!hasOwnProperty2.call(def, "rows")) {
|
|
2550
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
2551
|
-
}
|
|
2552
|
-
if (!hasOwnProperty2.call(def, "columns")) {
|
|
2553
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
2554
|
-
}
|
|
2555
|
-
const rows = def.rows;
|
|
2556
|
-
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
2557
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
2558
|
-
}
|
|
2559
|
-
let columns = def.columns;
|
|
2560
|
-
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
2561
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
2562
|
-
}
|
|
2563
|
-
if (columns.length !== new Set(columns).size) {
|
|
2564
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
2565
|
-
}
|
|
2566
|
-
if (!columns.length) {
|
|
2567
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
2568
|
-
}
|
|
2569
|
-
let parameters;
|
|
2570
|
-
if (hasOwnProperty2.call(def, "parameters")) {
|
|
2571
|
-
parameters = def.parameters;
|
|
2572
|
-
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
2573
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
2574
|
-
}
|
|
2575
|
-
} else {
|
|
2576
|
-
parameters = inferParameters(rows);
|
|
2577
|
-
}
|
|
2578
|
-
if (parameters.length !== new Set(parameters).size) {
|
|
2579
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
2580
|
-
}
|
|
2581
|
-
if (parameters.length > 32) {
|
|
2582
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
2583
|
-
}
|
|
2584
|
-
for (const parameter of parameters) {
|
|
2585
|
-
if (columns.includes(parameter)) {
|
|
2586
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
2587
|
-
}
|
|
2588
|
-
}
|
|
2589
|
-
let safeIntegers = 2;
|
|
2590
|
-
if (hasOwnProperty2.call(def, "safeIntegers")) {
|
|
2591
|
-
const bool = def.safeIntegers;
|
|
2592
|
-
if (typeof bool !== "boolean") {
|
|
2593
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
2594
|
-
}
|
|
2595
|
-
safeIntegers = +bool;
|
|
2596
|
-
}
|
|
2597
|
-
let directOnly = false;
|
|
2598
|
-
if (hasOwnProperty2.call(def, "directOnly")) {
|
|
2599
|
-
directOnly = def.directOnly;
|
|
2600
|
-
if (typeof directOnly !== "boolean") {
|
|
2601
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
2602
|
-
}
|
|
2603
|
-
}
|
|
2604
|
-
const columnDefinitions = [
|
|
2605
|
-
...parameters.map(identifier).map((str2) => `${str2} HIDDEN`),
|
|
2606
|
-
...columns.map(identifier)
|
|
2607
|
-
];
|
|
2608
|
-
return [
|
|
2609
|
-
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
2610
|
-
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
2611
|
-
parameters,
|
|
2612
|
-
safeIntegers,
|
|
2613
|
-
directOnly
|
|
2614
|
-
];
|
|
2615
|
-
}
|
|
2616
|
-
function wrapGenerator(generator, columnMap, moduleName) {
|
|
2617
|
-
return function* virtualTable(...args) {
|
|
2618
|
-
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
2619
|
-
for (let i = 0; i < columnMap.size; ++i) {
|
|
2620
|
-
output.push(null);
|
|
2621
|
-
}
|
|
2622
|
-
for (const row of generator(...args)) {
|
|
2623
|
-
if (Array.isArray(row)) {
|
|
2624
|
-
extractRowArray(row, output, columnMap.size, moduleName);
|
|
2625
|
-
yield output;
|
|
2626
|
-
} else if (typeof row === "object" && row !== null) {
|
|
2627
|
-
extractRowObject(row, output, columnMap, moduleName);
|
|
2628
|
-
yield output;
|
|
2629
|
-
} else {
|
|
2630
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
};
|
|
2634
|
-
}
|
|
2635
|
-
function extractRowArray(row, output, columnCount, moduleName) {
|
|
2636
|
-
if (row.length !== columnCount) {
|
|
2637
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
2638
|
-
}
|
|
2639
|
-
const offset = output.length - columnCount;
|
|
2640
|
-
for (let i = 0; i < columnCount; ++i) {
|
|
2641
|
-
output[i + offset] = row[i];
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
function extractRowObject(row, output, columnMap, moduleName) {
|
|
2645
|
-
let count = 0;
|
|
2646
|
-
for (const key of Object.keys(row)) {
|
|
2647
|
-
const index = columnMap.get(key);
|
|
2648
|
-
if (index === void 0) {
|
|
2649
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
2650
|
-
}
|
|
2651
|
-
output[index] = row[key];
|
|
2652
|
-
count += 1;
|
|
2653
|
-
}
|
|
2654
|
-
if (count !== columnMap.size) {
|
|
2655
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
function inferParameters({ length }) {
|
|
2659
|
-
if (!Number.isInteger(length) || length < 0) {
|
|
2660
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
2661
|
-
}
|
|
2662
|
-
const params = [];
|
|
2663
|
-
for (let i = 0; i < length; ++i) {
|
|
2664
|
-
params.push(`$${i + 1}`);
|
|
2665
|
-
}
|
|
2666
|
-
return params;
|
|
2667
|
-
}
|
|
2668
|
-
var { hasOwnProperty: hasOwnProperty2 } = Object.prototype;
|
|
2669
|
-
var { apply } = Function.prototype;
|
|
2670
|
-
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
2671
|
-
});
|
|
2672
|
-
var identifier = (str2) => `"${str2.replace(/"/g, '""')}"`;
|
|
2673
|
-
var defer = (x) => () => x;
|
|
2674
|
-
}
|
|
2675
|
-
});
|
|
2676
|
-
|
|
2677
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/inspect.js
|
|
2678
|
-
var require_inspect = __commonJS({
|
|
2679
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/methods/inspect.js"(exports2, module2) {
|
|
2680
|
-
"use strict";
|
|
2681
|
-
var DatabaseInspection = function Database2() {
|
|
2682
|
-
};
|
|
2683
|
-
module2.exports = function inspect(depth, opts) {
|
|
2684
|
-
return Object.assign(new DatabaseInspection(), this);
|
|
2685
|
-
};
|
|
2686
|
-
}
|
|
2687
|
-
});
|
|
2688
|
-
|
|
2689
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/database.js
|
|
2690
|
-
var require_database = __commonJS({
|
|
2691
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/database.js"(exports2, module2) {
|
|
2692
|
-
"use strict";
|
|
2693
|
-
var fs = __require("fs");
|
|
2694
|
-
var path = __require("path");
|
|
2695
|
-
var util = require_util();
|
|
2696
|
-
var SqliteError = require_sqlite_error();
|
|
2697
|
-
var DEFAULT_ADDON;
|
|
2698
|
-
function Database2(filenameGiven, options2) {
|
|
2699
|
-
if (new.target == null) {
|
|
2700
|
-
return new Database2(filenameGiven, options2);
|
|
2701
|
-
}
|
|
2702
|
-
let buffer;
|
|
2703
|
-
if (Buffer.isBuffer(filenameGiven)) {
|
|
2704
|
-
buffer = filenameGiven;
|
|
2705
|
-
filenameGiven = ":memory:";
|
|
2706
|
-
}
|
|
2707
|
-
if (filenameGiven == null) filenameGiven = "";
|
|
2708
|
-
if (options2 == null) options2 = {};
|
|
2709
|
-
if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
|
|
2710
|
-
if (typeof options2 !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
2711
|
-
if ("readOnly" in options2) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
2712
|
-
if ("memory" in options2) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
2713
|
-
const filename = filenameGiven.trim();
|
|
2714
|
-
const anonymous = filename === "" || filename === ":memory:";
|
|
2715
|
-
const readonly = util.getBooleanOption(options2, "readonly");
|
|
2716
|
-
const fileMustExist = util.getBooleanOption(options2, "fileMustExist");
|
|
2717
|
-
const timeout = "timeout" in options2 ? options2.timeout : 5e3;
|
|
2718
|
-
const verbose = "verbose" in options2 ? options2.verbose : null;
|
|
2719
|
-
const nativeBinding = "nativeBinding" in options2 ? options2.nativeBinding : null;
|
|
2720
|
-
if (readonly && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
2721
|
-
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
2722
|
-
if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
2723
|
-
if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
|
|
2724
|
-
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
2725
|
-
let addon;
|
|
2726
|
-
if (nativeBinding == null) {
|
|
2727
|
-
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
2728
|
-
} else if (typeof nativeBinding === "string") {
|
|
2729
|
-
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
2730
|
-
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
2731
|
-
} else {
|
|
2732
|
-
addon = nativeBinding;
|
|
2733
|
-
}
|
|
2734
|
-
if (!addon.isInitialized) {
|
|
2735
|
-
addon.setErrorConstructor(SqliteError);
|
|
2736
|
-
addon.isInitialized = true;
|
|
2737
|
-
}
|
|
2738
|
-
if (!anonymous && !fs.existsSync(path.dirname(filename))) {
|
|
2739
|
-
throw new TypeError("Cannot open database because the directory does not exist");
|
|
2740
|
-
}
|
|
2741
|
-
Object.defineProperties(this, {
|
|
2742
|
-
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
2743
|
-
...wrappers.getters
|
|
2744
|
-
});
|
|
2745
|
-
}
|
|
2746
|
-
var wrappers = require_wrappers();
|
|
2747
|
-
Database2.prototype.prepare = wrappers.prepare;
|
|
2748
|
-
Database2.prototype.transaction = require_transaction();
|
|
2749
|
-
Database2.prototype.pragma = require_pragma();
|
|
2750
|
-
Database2.prototype.backup = require_backup();
|
|
2751
|
-
Database2.prototype.serialize = require_serialize();
|
|
2752
|
-
Database2.prototype.function = require_function();
|
|
2753
|
-
Database2.prototype.aggregate = require_aggregate();
|
|
2754
|
-
Database2.prototype.table = require_table();
|
|
2755
|
-
Database2.prototype.loadExtension = wrappers.loadExtension;
|
|
2756
|
-
Database2.prototype.exec = wrappers.exec;
|
|
2757
|
-
Database2.prototype.close = wrappers.close;
|
|
2758
|
-
Database2.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
2759
|
-
Database2.prototype.unsafeMode = wrappers.unsafeMode;
|
|
2760
|
-
Database2.prototype[util.inspect] = require_inspect();
|
|
2761
|
-
module2.exports = Database2;
|
|
2762
|
-
}
|
|
2763
|
-
});
|
|
2764
|
-
|
|
2765
|
-
// ../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/index.js
|
|
2766
|
-
var require_lib = __commonJS({
|
|
2767
|
-
"../../node_modules/.pnpm/better-sqlite3@9.6.0/node_modules/better-sqlite3/lib/index.js"(exports2, module2) {
|
|
2768
|
-
"use strict";
|
|
2769
|
-
module2.exports = require_database();
|
|
2770
|
-
module2.exports.SqliteError = require_sqlite_error();
|
|
2771
|
-
}
|
|
2772
|
-
});
|
|
2773
|
-
|
|
2774
2029
|
// ../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js
|
|
2775
2030
|
var require_kind_of = __commonJS({
|
|
2776
2031
|
"../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js"(exports2, module2) {
|
|
@@ -4081,7 +3336,7 @@ var require_regexp = __commonJS({
|
|
|
4081
3336
|
});
|
|
4082
3337
|
|
|
4083
3338
|
// ../../node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
|
4084
|
-
var
|
|
3339
|
+
var require_function = __commonJS({
|
|
4085
3340
|
"../../node_modules/.pnpm/js-yaml@3.14.2/node_modules/js-yaml/lib/js-yaml/type/js/function.js"(exports2, module2) {
|
|
4086
3341
|
"use strict";
|
|
4087
3342
|
var esprima;
|
|
@@ -4147,7 +3402,7 @@ var require_default_full = __commonJS({
|
|
|
4147
3402
|
explicit: [
|
|
4148
3403
|
require_undefined(),
|
|
4149
3404
|
require_regexp(),
|
|
4150
|
-
|
|
3405
|
+
require_function()
|
|
4151
3406
|
]
|
|
4152
3407
|
});
|
|
4153
3408
|
}
|
|
@@ -6266,13 +5521,13 @@ import chalk from "chalk";
|
|
|
6266
5521
|
// ../core/dist/index.js
|
|
6267
5522
|
var import_toml = __toESM(require_toml(), 1);
|
|
6268
5523
|
var import_toml2 = __toESM(require_toml(), 1);
|
|
6269
|
-
var import_better_sqlite3 = __toESM(require_lib(), 1);
|
|
6270
5524
|
var import_gray_matter = __toESM(require_gray_matter(), 1);
|
|
6271
5525
|
import { mkdir, writeFile, access, rm } from "fs/promises";
|
|
6272
5526
|
import { join, basename } from "path";
|
|
6273
5527
|
import { readFile } from "fs/promises";
|
|
6274
5528
|
import { access as access2 } from "fs/promises";
|
|
6275
5529
|
import { join as join2, dirname, resolve } from "path";
|
|
5530
|
+
import Database from "better-sqlite3";
|
|
6276
5531
|
import { join as join3 } from "path";
|
|
6277
5532
|
import { readFile as readFile2 } from "fs/promises";
|
|
6278
5533
|
import { createHash } from "crypto";
|
|
@@ -6682,7 +5937,7 @@ CREATE TABLE IF NOT EXISTS page_meta (
|
|
|
6682
5937
|
`;
|
|
6683
5938
|
function openDb(project) {
|
|
6684
5939
|
const dbPath = join3(project.kbDir, "index.db");
|
|
6685
|
-
const db = new
|
|
5940
|
+
const db = new Database(dbPath);
|
|
6686
5941
|
db.pragma("journal_mode = WAL");
|
|
6687
5942
|
db.exec(SCHEMA_SQL);
|
|
6688
5943
|
return db;
|
|
@@ -6920,7 +6175,7 @@ function stripHtml(html) {
|
|
|
6920
6175
|
return text;
|
|
6921
6176
|
}
|
|
6922
6177
|
async function readPdf(filePath) {
|
|
6923
|
-
const pdfParse = await import("
|
|
6178
|
+
const pdfParse = await import("pdf-parse").then((m) => m.default ?? m);
|
|
6924
6179
|
const buffer = await readFile4(filePath);
|
|
6925
6180
|
const data = await pdfParse(buffer);
|
|
6926
6181
|
return data.text;
|
|
@@ -6970,7 +6225,7 @@ function createAnthropicAdapter(model) {
|
|
|
6970
6225
|
if (!apiKey) {
|
|
6971
6226
|
throw new Error("ANTHROPIC_API_KEY environment variable is not set");
|
|
6972
6227
|
}
|
|
6973
|
-
const Anthropic = await import("
|
|
6228
|
+
const Anthropic = await import("@anthropic-ai/sdk").then((m) => m.default ?? m);
|
|
6974
6229
|
const client = new Anthropic({ apiKey });
|
|
6975
6230
|
const response = await client.messages.create({
|
|
6976
6231
|
model,
|