@hasna/brains 0.0.1 → 0.0.4
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/cli/index.js +556 -837
- package/dist/db/index.d.ts +3 -3
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/schema.d.ts +76 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/index.js +75 -814
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/package-metadata.d.ts +2 -0
- package/dist/lib/package-metadata.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +74 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +380 -1085
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +47 -7
- package/package.json +1 -3
package/dist/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
2
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
3
|
var __export = (target, all) => {
|
|
20
4
|
for (var name in all)
|
|
21
5
|
__defProp(target, name, {
|
|
@@ -25,774 +9,8 @@ var __export = (target, all) => {
|
|
|
25
9
|
set: (newValue) => all[name] = () => newValue
|
|
26
10
|
});
|
|
27
11
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// node_modules/better-sqlite3/lib/util.js
|
|
31
|
-
var require_util = __commonJS((exports) => {
|
|
32
|
-
exports.getBooleanOption = (options, key) => {
|
|
33
|
-
let value = false;
|
|
34
|
-
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
35
|
-
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
};
|
|
39
|
-
exports.cppdb = Symbol();
|
|
40
|
-
exports.inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// node_modules/better-sqlite3/lib/sqlite-error.js
|
|
44
|
-
var require_sqlite_error = __commonJS((exports, module) => {
|
|
45
|
-
var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
|
|
46
|
-
function SqliteError(message, code) {
|
|
47
|
-
if (new.target !== SqliteError) {
|
|
48
|
-
return new SqliteError(message, code);
|
|
49
|
-
}
|
|
50
|
-
if (typeof code !== "string") {
|
|
51
|
-
throw new TypeError("Expected second argument to be a string");
|
|
52
|
-
}
|
|
53
|
-
Error.call(this, message);
|
|
54
|
-
descriptor.value = "" + message;
|
|
55
|
-
Object.defineProperty(this, "message", descriptor);
|
|
56
|
-
Error.captureStackTrace(this, SqliteError);
|
|
57
|
-
this.code = code;
|
|
58
|
-
}
|
|
59
|
-
Object.setPrototypeOf(SqliteError, Error);
|
|
60
|
-
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
|
61
|
-
Object.defineProperty(SqliteError.prototype, "name", descriptor);
|
|
62
|
-
module.exports = SqliteError;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// node_modules/file-uri-to-path/index.js
|
|
66
|
-
var require_file_uri_to_path = __commonJS((exports, module) => {
|
|
67
|
-
var sep = __require("path").sep || "/";
|
|
68
|
-
module.exports = fileUriToPath;
|
|
69
|
-
function fileUriToPath(uri) {
|
|
70
|
-
if (typeof uri != "string" || uri.length <= 7 || uri.substring(0, 7) != "file://") {
|
|
71
|
-
throw new TypeError("must pass in a file:// URI to convert to a file path");
|
|
72
|
-
}
|
|
73
|
-
var rest = decodeURI(uri.substring(7));
|
|
74
|
-
var firstSlash = rest.indexOf("/");
|
|
75
|
-
var host = rest.substring(0, firstSlash);
|
|
76
|
-
var path = rest.substring(firstSlash + 1);
|
|
77
|
-
if (host == "localhost")
|
|
78
|
-
host = "";
|
|
79
|
-
if (host) {
|
|
80
|
-
host = sep + sep + host;
|
|
81
|
-
}
|
|
82
|
-
path = path.replace(/^(.+)\|/, "$1:");
|
|
83
|
-
if (sep == "\\") {
|
|
84
|
-
path = path.replace(/\//g, "\\");
|
|
85
|
-
}
|
|
86
|
-
if (/^.+\:/.test(path)) {} else {
|
|
87
|
-
path = sep + path;
|
|
88
|
-
}
|
|
89
|
-
return host + path;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// node_modules/bindings/bindings.js
|
|
94
|
-
var require_bindings = __commonJS((exports, module) => {
|
|
95
|
-
var __filename = "/Users/hasna/Workspace/hasna/opensource/opensourcedev/open-brains/node_modules/bindings/bindings.js";
|
|
96
|
-
var fs = __require("fs");
|
|
97
|
-
var path = __require("path");
|
|
98
|
-
var fileURLToPath = require_file_uri_to_path();
|
|
99
|
-
var join = path.join;
|
|
100
|
-
var dirname = path.dirname;
|
|
101
|
-
var exists = fs.accessSync && function(path2) {
|
|
102
|
-
try {
|
|
103
|
-
fs.accessSync(path2);
|
|
104
|
-
} catch (e) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
} || fs.existsSync || path.existsSync;
|
|
109
|
-
var defaults = {
|
|
110
|
-
arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
|
|
111
|
-
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
|
|
112
|
-
platform: process.platform,
|
|
113
|
-
arch: process.arch,
|
|
114
|
-
nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
|
|
115
|
-
version: process.versions.node,
|
|
116
|
-
bindings: "bindings.node",
|
|
117
|
-
try: [
|
|
118
|
-
["module_root", "build", "bindings"],
|
|
119
|
-
["module_root", "build", "Debug", "bindings"],
|
|
120
|
-
["module_root", "build", "Release", "bindings"],
|
|
121
|
-
["module_root", "out", "Debug", "bindings"],
|
|
122
|
-
["module_root", "Debug", "bindings"],
|
|
123
|
-
["module_root", "out", "Release", "bindings"],
|
|
124
|
-
["module_root", "Release", "bindings"],
|
|
125
|
-
["module_root", "build", "default", "bindings"],
|
|
126
|
-
["module_root", "compiled", "version", "platform", "arch", "bindings"],
|
|
127
|
-
["module_root", "addon-build", "release", "install-root", "bindings"],
|
|
128
|
-
["module_root", "addon-build", "debug", "install-root", "bindings"],
|
|
129
|
-
["module_root", "addon-build", "default", "install-root", "bindings"],
|
|
130
|
-
["module_root", "lib", "binding", "nodePreGyp", "bindings"]
|
|
131
|
-
]
|
|
132
|
-
};
|
|
133
|
-
function bindings(opts) {
|
|
134
|
-
if (typeof opts == "string") {
|
|
135
|
-
opts = { bindings: opts };
|
|
136
|
-
} else if (!opts) {
|
|
137
|
-
opts = {};
|
|
138
|
-
}
|
|
139
|
-
Object.keys(defaults).map(function(i2) {
|
|
140
|
-
if (!(i2 in opts))
|
|
141
|
-
opts[i2] = defaults[i2];
|
|
142
|
-
});
|
|
143
|
-
if (!opts.module_root) {
|
|
144
|
-
opts.module_root = exports.getRoot(exports.getFileName());
|
|
145
|
-
}
|
|
146
|
-
if (path.extname(opts.bindings) != ".node") {
|
|
147
|
-
opts.bindings += ".node";
|
|
148
|
-
}
|
|
149
|
-
var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
150
|
-
var tries = [], i = 0, l = opts.try.length, n, b, err;
|
|
151
|
-
for (;i < l; i++) {
|
|
152
|
-
n = join.apply(null, opts.try[i].map(function(p) {
|
|
153
|
-
return opts[p] || p;
|
|
154
|
-
}));
|
|
155
|
-
tries.push(n);
|
|
156
|
-
try {
|
|
157
|
-
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
158
|
-
if (!opts.path) {
|
|
159
|
-
b.path = n;
|
|
160
|
-
}
|
|
161
|
-
return b;
|
|
162
|
-
} catch (e) {
|
|
163
|
-
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
|
|
164
|
-
throw e;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
err = new Error(`Could not locate the bindings file. Tried:
|
|
169
|
-
` + tries.map(function(a) {
|
|
170
|
-
return opts.arrow + a;
|
|
171
|
-
}).join(`
|
|
172
|
-
`));
|
|
173
|
-
err.tries = tries;
|
|
174
|
-
throw err;
|
|
175
|
-
}
|
|
176
|
-
module.exports = exports = bindings;
|
|
177
|
-
exports.getFileName = function getFileName(calling_file) {
|
|
178
|
-
var { prepareStackTrace: origPST, stackTraceLimit: origSTL } = Error, dummy = {}, fileName;
|
|
179
|
-
Error.stackTraceLimit = 10;
|
|
180
|
-
Error.prepareStackTrace = function(e, st) {
|
|
181
|
-
for (var i = 0, l = st.length;i < l; i++) {
|
|
182
|
-
fileName = st[i].getFileName();
|
|
183
|
-
if (fileName !== __filename) {
|
|
184
|
-
if (calling_file) {
|
|
185
|
-
if (fileName !== calling_file) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
} else {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
Error.captureStackTrace(dummy);
|
|
195
|
-
dummy.stack;
|
|
196
|
-
Error.prepareStackTrace = origPST;
|
|
197
|
-
Error.stackTraceLimit = origSTL;
|
|
198
|
-
var fileSchema = "file://";
|
|
199
|
-
if (fileName.indexOf(fileSchema) === 0) {
|
|
200
|
-
fileName = fileURLToPath(fileName);
|
|
201
|
-
}
|
|
202
|
-
return fileName;
|
|
203
|
-
};
|
|
204
|
-
exports.getRoot = function getRoot(file) {
|
|
205
|
-
var dir = dirname(file), prev;
|
|
206
|
-
while (true) {
|
|
207
|
-
if (dir === ".") {
|
|
208
|
-
dir = process.cwd();
|
|
209
|
-
}
|
|
210
|
-
if (exists(join(dir, "package.json")) || exists(join(dir, "node_modules"))) {
|
|
211
|
-
return dir;
|
|
212
|
-
}
|
|
213
|
-
if (prev === dir) {
|
|
214
|
-
throw new Error('Could not find module root given file: "' + file + '". Do you have a `package.json` file? ');
|
|
215
|
-
}
|
|
216
|
-
prev = dir;
|
|
217
|
-
dir = join(dir, "..");
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
223
|
-
var require_wrappers = __commonJS((exports) => {
|
|
224
|
-
var { cppdb } = require_util();
|
|
225
|
-
exports.prepare = function prepare(sql) {
|
|
226
|
-
return this[cppdb].prepare(sql, this, false);
|
|
227
|
-
};
|
|
228
|
-
exports.exec = function exec(sql) {
|
|
229
|
-
this[cppdb].exec(sql);
|
|
230
|
-
return this;
|
|
231
|
-
};
|
|
232
|
-
exports.close = function close() {
|
|
233
|
-
this[cppdb].close();
|
|
234
|
-
return this;
|
|
235
|
-
};
|
|
236
|
-
exports.loadExtension = function loadExtension(...args) {
|
|
237
|
-
this[cppdb].loadExtension(...args);
|
|
238
|
-
return this;
|
|
239
|
-
};
|
|
240
|
-
exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
241
|
-
this[cppdb].defaultSafeIntegers(...args);
|
|
242
|
-
return this;
|
|
243
|
-
};
|
|
244
|
-
exports.unsafeMode = function unsafeMode(...args) {
|
|
245
|
-
this[cppdb].unsafeMode(...args);
|
|
246
|
-
return this;
|
|
247
|
-
};
|
|
248
|
-
exports.getters = {
|
|
249
|
-
name: {
|
|
250
|
-
get: function name() {
|
|
251
|
-
return this[cppdb].name;
|
|
252
|
-
},
|
|
253
|
-
enumerable: true
|
|
254
|
-
},
|
|
255
|
-
open: {
|
|
256
|
-
get: function open() {
|
|
257
|
-
return this[cppdb].open;
|
|
258
|
-
},
|
|
259
|
-
enumerable: true
|
|
260
|
-
},
|
|
261
|
-
inTransaction: {
|
|
262
|
-
get: function inTransaction() {
|
|
263
|
-
return this[cppdb].inTransaction;
|
|
264
|
-
},
|
|
265
|
-
enumerable: true
|
|
266
|
-
},
|
|
267
|
-
readonly: {
|
|
268
|
-
get: function readonly() {
|
|
269
|
-
return this[cppdb].readonly;
|
|
270
|
-
},
|
|
271
|
-
enumerable: true
|
|
272
|
-
},
|
|
273
|
-
memory: {
|
|
274
|
-
get: function memory() {
|
|
275
|
-
return this[cppdb].memory;
|
|
276
|
-
},
|
|
277
|
-
enumerable: true
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// node_modules/better-sqlite3/lib/methods/transaction.js
|
|
283
|
-
var require_transaction = __commonJS((exports, module) => {
|
|
284
|
-
var { cppdb } = require_util();
|
|
285
|
-
var controllers = new WeakMap;
|
|
286
|
-
module.exports = function transaction(fn) {
|
|
287
|
-
if (typeof fn !== "function")
|
|
288
|
-
throw new TypeError("Expected first argument to be a function");
|
|
289
|
-
const db = this[cppdb];
|
|
290
|
-
const controller = getController(db, this);
|
|
291
|
-
const { apply } = Function.prototype;
|
|
292
|
-
const properties = {
|
|
293
|
-
default: { value: wrapTransaction(apply, fn, db, controller.default) },
|
|
294
|
-
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
|
|
295
|
-
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
|
|
296
|
-
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
|
|
297
|
-
database: { value: this, enumerable: true }
|
|
298
|
-
};
|
|
299
|
-
Object.defineProperties(properties.default.value, properties);
|
|
300
|
-
Object.defineProperties(properties.deferred.value, properties);
|
|
301
|
-
Object.defineProperties(properties.immediate.value, properties);
|
|
302
|
-
Object.defineProperties(properties.exclusive.value, properties);
|
|
303
|
-
return properties.default.value;
|
|
304
|
-
};
|
|
305
|
-
var getController = (db, self) => {
|
|
306
|
-
let controller = controllers.get(db);
|
|
307
|
-
if (!controller) {
|
|
308
|
-
const shared = {
|
|
309
|
-
commit: db.prepare("COMMIT", self, false),
|
|
310
|
-
rollback: db.prepare("ROLLBACK", self, false),
|
|
311
|
-
savepoint: db.prepare("SAVEPOINT `\t_bs3.\t`", self, false),
|
|
312
|
-
release: db.prepare("RELEASE `\t_bs3.\t`", self, false),
|
|
313
|
-
rollbackTo: db.prepare("ROLLBACK TO `\t_bs3.\t`", self, false)
|
|
314
|
-
};
|
|
315
|
-
controllers.set(db, controller = {
|
|
316
|
-
default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
|
|
317
|
-
deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
|
|
318
|
-
immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
|
|
319
|
-
exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
return controller;
|
|
323
|
-
};
|
|
324
|
-
var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
325
|
-
let before, after, undo;
|
|
326
|
-
if (db.inTransaction) {
|
|
327
|
-
before = savepoint;
|
|
328
|
-
after = release;
|
|
329
|
-
undo = rollbackTo;
|
|
330
|
-
} else {
|
|
331
|
-
before = begin;
|
|
332
|
-
after = commit;
|
|
333
|
-
undo = rollback;
|
|
334
|
-
}
|
|
335
|
-
before.run();
|
|
336
|
-
try {
|
|
337
|
-
const result = apply.call(fn, this, arguments);
|
|
338
|
-
if (result && typeof result.then === "function") {
|
|
339
|
-
throw new TypeError("Transaction function cannot return a promise");
|
|
340
|
-
}
|
|
341
|
-
after.run();
|
|
342
|
-
return result;
|
|
343
|
-
} catch (ex) {
|
|
344
|
-
if (db.inTransaction) {
|
|
345
|
-
undo.run();
|
|
346
|
-
if (undo !== rollback)
|
|
347
|
-
after.run();
|
|
348
|
-
}
|
|
349
|
-
throw ex;
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// node_modules/better-sqlite3/lib/methods/pragma.js
|
|
355
|
-
var require_pragma = __commonJS((exports, module) => {
|
|
356
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
357
|
-
module.exports = function pragma(source, options) {
|
|
358
|
-
if (options == null)
|
|
359
|
-
options = {};
|
|
360
|
-
if (typeof source !== "string")
|
|
361
|
-
throw new TypeError("Expected first argument to be a string");
|
|
362
|
-
if (typeof options !== "object")
|
|
363
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
364
|
-
const simple = getBooleanOption(options, "simple");
|
|
365
|
-
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
|
|
366
|
-
return simple ? stmt.pluck().get() : stmt.all();
|
|
367
|
-
};
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
// node_modules/better-sqlite3/lib/methods/backup.js
|
|
371
|
-
var require_backup = __commonJS((exports, module) => {
|
|
372
|
-
var fs = __require("fs");
|
|
373
|
-
var path = __require("path");
|
|
374
|
-
var { promisify } = __require("util");
|
|
375
|
-
var { cppdb } = require_util();
|
|
376
|
-
var fsAccess = promisify(fs.access);
|
|
377
|
-
module.exports = async function backup(filename, options) {
|
|
378
|
-
if (options == null)
|
|
379
|
-
options = {};
|
|
380
|
-
if (typeof filename !== "string")
|
|
381
|
-
throw new TypeError("Expected first argument to be a string");
|
|
382
|
-
if (typeof options !== "object")
|
|
383
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
384
|
-
filename = filename.trim();
|
|
385
|
-
const attachedName = "attached" in options ? options.attached : "main";
|
|
386
|
-
const handler = "progress" in options ? options.progress : null;
|
|
387
|
-
if (!filename)
|
|
388
|
-
throw new TypeError("Backup filename cannot be an empty string");
|
|
389
|
-
if (filename === ":memory:")
|
|
390
|
-
throw new TypeError('Invalid backup filename ":memory:"');
|
|
391
|
-
if (typeof attachedName !== "string")
|
|
392
|
-
throw new TypeError('Expected the "attached" option to be a string');
|
|
393
|
-
if (!attachedName)
|
|
394
|
-
throw new TypeError('The "attached" option cannot be an empty string');
|
|
395
|
-
if (handler != null && typeof handler !== "function")
|
|
396
|
-
throw new TypeError('Expected the "progress" option to be a function');
|
|
397
|
-
await fsAccess(path.dirname(filename)).catch(() => {
|
|
398
|
-
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
399
|
-
});
|
|
400
|
-
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
401
|
-
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
402
|
-
};
|
|
403
|
-
var runBackup = (backup, handler) => {
|
|
404
|
-
let rate = 0;
|
|
405
|
-
let useDefault = true;
|
|
406
|
-
return new Promise((resolve, reject) => {
|
|
407
|
-
setImmediate(function step() {
|
|
408
|
-
try {
|
|
409
|
-
const progress = backup.transfer(rate);
|
|
410
|
-
if (!progress.remainingPages) {
|
|
411
|
-
backup.close();
|
|
412
|
-
resolve(progress);
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
if (useDefault) {
|
|
416
|
-
useDefault = false;
|
|
417
|
-
rate = 100;
|
|
418
|
-
}
|
|
419
|
-
if (handler) {
|
|
420
|
-
const ret = handler(progress);
|
|
421
|
-
if (ret !== undefined) {
|
|
422
|
-
if (typeof ret === "number" && ret === ret)
|
|
423
|
-
rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
424
|
-
else
|
|
425
|
-
throw new TypeError("Expected progress callback to return a number or undefined");
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
setImmediate(step);
|
|
429
|
-
} catch (err) {
|
|
430
|
-
backup.close();
|
|
431
|
-
reject(err);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
// node_modules/better-sqlite3/lib/methods/serialize.js
|
|
439
|
-
var require_serialize = __commonJS((exports, module) => {
|
|
440
|
-
var { cppdb } = require_util();
|
|
441
|
-
module.exports = function serialize(options) {
|
|
442
|
-
if (options == null)
|
|
443
|
-
options = {};
|
|
444
|
-
if (typeof options !== "object")
|
|
445
|
-
throw new TypeError("Expected first argument to be an options object");
|
|
446
|
-
const attachedName = "attached" in options ? options.attached : "main";
|
|
447
|
-
if (typeof attachedName !== "string")
|
|
448
|
-
throw new TypeError('Expected the "attached" option to be a string');
|
|
449
|
-
if (!attachedName)
|
|
450
|
-
throw new TypeError('The "attached" option cannot be an empty string');
|
|
451
|
-
return this[cppdb].serialize(attachedName);
|
|
452
|
-
};
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
// node_modules/better-sqlite3/lib/methods/function.js
|
|
456
|
-
var require_function = __commonJS((exports, module) => {
|
|
457
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
458
|
-
module.exports = function defineFunction(name, options, fn) {
|
|
459
|
-
if (options == null)
|
|
460
|
-
options = {};
|
|
461
|
-
if (typeof options === "function") {
|
|
462
|
-
fn = options;
|
|
463
|
-
options = {};
|
|
464
|
-
}
|
|
465
|
-
if (typeof name !== "string")
|
|
466
|
-
throw new TypeError("Expected first argument to be a string");
|
|
467
|
-
if (typeof fn !== "function")
|
|
468
|
-
throw new TypeError("Expected last argument to be a function");
|
|
469
|
-
if (typeof options !== "object")
|
|
470
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
471
|
-
if (!name)
|
|
472
|
-
throw new TypeError("User-defined function name cannot be an empty string");
|
|
473
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
474
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
475
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
476
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
477
|
-
let argCount = -1;
|
|
478
|
-
if (!varargs) {
|
|
479
|
-
argCount = fn.length;
|
|
480
|
-
if (!Number.isInteger(argCount) || argCount < 0)
|
|
481
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
482
|
-
if (argCount > 100)
|
|
483
|
-
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
484
|
-
}
|
|
485
|
-
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
486
|
-
return this;
|
|
487
|
-
};
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
// node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
491
|
-
var require_aggregate = __commonJS((exports, module) => {
|
|
492
|
-
var { getBooleanOption, cppdb } = require_util();
|
|
493
|
-
module.exports = function defineAggregate(name, options) {
|
|
494
|
-
if (typeof name !== "string")
|
|
495
|
-
throw new TypeError("Expected first argument to be a string");
|
|
496
|
-
if (typeof options !== "object" || options === null)
|
|
497
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
498
|
-
if (!name)
|
|
499
|
-
throw new TypeError("User-defined function name cannot be an empty string");
|
|
500
|
-
const start = "start" in options ? options.start : null;
|
|
501
|
-
const step = getFunctionOption(options, "step", true);
|
|
502
|
-
const inverse = getFunctionOption(options, "inverse", false);
|
|
503
|
-
const result = getFunctionOption(options, "result", false);
|
|
504
|
-
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
505
|
-
const deterministic = getBooleanOption(options, "deterministic");
|
|
506
|
-
const directOnly = getBooleanOption(options, "directOnly");
|
|
507
|
-
const varargs = getBooleanOption(options, "varargs");
|
|
508
|
-
let argCount = -1;
|
|
509
|
-
if (!varargs) {
|
|
510
|
-
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
511
|
-
if (argCount > 0)
|
|
512
|
-
argCount -= 1;
|
|
513
|
-
if (argCount > 100)
|
|
514
|
-
throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
515
|
-
}
|
|
516
|
-
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
517
|
-
return this;
|
|
518
|
-
};
|
|
519
|
-
var getFunctionOption = (options, key, required) => {
|
|
520
|
-
const value = key in options ? options[key] : null;
|
|
521
|
-
if (typeof value === "function")
|
|
522
|
-
return value;
|
|
523
|
-
if (value != null)
|
|
524
|
-
throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
525
|
-
if (required)
|
|
526
|
-
throw new TypeError(`Missing required option "${key}"`);
|
|
527
|
-
return null;
|
|
528
|
-
};
|
|
529
|
-
var getLength = ({ length }) => {
|
|
530
|
-
if (Number.isInteger(length) && length >= 0)
|
|
531
|
-
return length;
|
|
532
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
533
|
-
};
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
// node_modules/better-sqlite3/lib/methods/table.js
|
|
537
|
-
var require_table = __commonJS((exports, module) => {
|
|
538
|
-
var { cppdb } = require_util();
|
|
539
|
-
module.exports = function defineTable(name, factory) {
|
|
540
|
-
if (typeof name !== "string")
|
|
541
|
-
throw new TypeError("Expected first argument to be a string");
|
|
542
|
-
if (!name)
|
|
543
|
-
throw new TypeError("Virtual table module name cannot be an empty string");
|
|
544
|
-
let eponymous = false;
|
|
545
|
-
if (typeof factory === "object" && factory !== null) {
|
|
546
|
-
eponymous = true;
|
|
547
|
-
factory = defer(parseTableDefinition(factory, "used", name));
|
|
548
|
-
} else {
|
|
549
|
-
if (typeof factory !== "function")
|
|
550
|
-
throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
551
|
-
factory = wrapFactory(factory);
|
|
552
|
-
}
|
|
553
|
-
this[cppdb].table(factory, name, eponymous);
|
|
554
|
-
return this;
|
|
555
|
-
};
|
|
556
|
-
function wrapFactory(factory) {
|
|
557
|
-
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
558
|
-
const thisObject = {
|
|
559
|
-
module: moduleName,
|
|
560
|
-
database: databaseName,
|
|
561
|
-
table: tableName
|
|
562
|
-
};
|
|
563
|
-
const def = apply.call(factory, thisObject, args);
|
|
564
|
-
if (typeof def !== "object" || def === null) {
|
|
565
|
-
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
566
|
-
}
|
|
567
|
-
return parseTableDefinition(def, "returned", moduleName);
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
function parseTableDefinition(def, verb, moduleName) {
|
|
571
|
-
if (!hasOwnProperty.call(def, "rows")) {
|
|
572
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
573
|
-
}
|
|
574
|
-
if (!hasOwnProperty.call(def, "columns")) {
|
|
575
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
576
|
-
}
|
|
577
|
-
const rows = def.rows;
|
|
578
|
-
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
579
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
580
|
-
}
|
|
581
|
-
let columns = def.columns;
|
|
582
|
-
if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
|
|
583
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
584
|
-
}
|
|
585
|
-
if (columns.length !== new Set(columns).size) {
|
|
586
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
587
|
-
}
|
|
588
|
-
if (!columns.length) {
|
|
589
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
590
|
-
}
|
|
591
|
-
let parameters;
|
|
592
|
-
if (hasOwnProperty.call(def, "parameters")) {
|
|
593
|
-
parameters = def.parameters;
|
|
594
|
-
if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
|
|
595
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
596
|
-
}
|
|
597
|
-
} else {
|
|
598
|
-
parameters = inferParameters(rows);
|
|
599
|
-
}
|
|
600
|
-
if (parameters.length !== new Set(parameters).size) {
|
|
601
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
602
|
-
}
|
|
603
|
-
if (parameters.length > 32) {
|
|
604
|
-
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
605
|
-
}
|
|
606
|
-
for (const parameter of parameters) {
|
|
607
|
-
if (columns.includes(parameter)) {
|
|
608
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
let safeIntegers = 2;
|
|
612
|
-
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
613
|
-
const bool = def.safeIntegers;
|
|
614
|
-
if (typeof bool !== "boolean") {
|
|
615
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
616
|
-
}
|
|
617
|
-
safeIntegers = +bool;
|
|
618
|
-
}
|
|
619
|
-
let directOnly = false;
|
|
620
|
-
if (hasOwnProperty.call(def, "directOnly")) {
|
|
621
|
-
directOnly = def.directOnly;
|
|
622
|
-
if (typeof directOnly !== "boolean") {
|
|
623
|
-
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
const columnDefinitions = [
|
|
627
|
-
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
628
|
-
...columns.map(identifier)
|
|
629
|
-
];
|
|
630
|
-
return [
|
|
631
|
-
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
632
|
-
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
633
|
-
parameters,
|
|
634
|
-
safeIntegers,
|
|
635
|
-
directOnly
|
|
636
|
-
];
|
|
637
|
-
}
|
|
638
|
-
function wrapGenerator(generator, columnMap, moduleName) {
|
|
639
|
-
return function* virtualTable(...args) {
|
|
640
|
-
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
641
|
-
for (let i = 0;i < columnMap.size; ++i) {
|
|
642
|
-
output.push(null);
|
|
643
|
-
}
|
|
644
|
-
for (const row of generator(...args)) {
|
|
645
|
-
if (Array.isArray(row)) {
|
|
646
|
-
extractRowArray(row, output, columnMap.size, moduleName);
|
|
647
|
-
yield output;
|
|
648
|
-
} else if (typeof row === "object" && row !== null) {
|
|
649
|
-
extractRowObject(row, output, columnMap, moduleName);
|
|
650
|
-
yield output;
|
|
651
|
-
} else {
|
|
652
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
function extractRowArray(row, output, columnCount, moduleName) {
|
|
658
|
-
if (row.length !== columnCount) {
|
|
659
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
660
|
-
}
|
|
661
|
-
const offset = output.length - columnCount;
|
|
662
|
-
for (let i = 0;i < columnCount; ++i) {
|
|
663
|
-
output[i + offset] = row[i];
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function extractRowObject(row, output, columnMap, moduleName) {
|
|
667
|
-
let count = 0;
|
|
668
|
-
for (const key of Object.keys(row)) {
|
|
669
|
-
const index = columnMap.get(key);
|
|
670
|
-
if (index === undefined) {
|
|
671
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
672
|
-
}
|
|
673
|
-
output[index] = row[key];
|
|
674
|
-
count += 1;
|
|
675
|
-
}
|
|
676
|
-
if (count !== columnMap.size) {
|
|
677
|
-
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
function inferParameters({ length }) {
|
|
681
|
-
if (!Number.isInteger(length) || length < 0) {
|
|
682
|
-
throw new TypeError("Expected function.length to be a positive integer");
|
|
683
|
-
}
|
|
684
|
-
const params = [];
|
|
685
|
-
for (let i = 0;i < length; ++i) {
|
|
686
|
-
params.push(`$${i + 1}`);
|
|
687
|
-
}
|
|
688
|
-
return params;
|
|
689
|
-
}
|
|
690
|
-
var { hasOwnProperty } = Object.prototype;
|
|
691
|
-
var { apply } = Function.prototype;
|
|
692
|
-
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {});
|
|
693
|
-
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
694
|
-
var defer = (x) => () => x;
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
// node_modules/better-sqlite3/lib/methods/inspect.js
|
|
698
|
-
var require_inspect = __commonJS((exports, module) => {
|
|
699
|
-
var DatabaseInspection = function Database() {};
|
|
700
|
-
module.exports = function inspect(depth, opts) {
|
|
701
|
-
return Object.assign(new DatabaseInspection, this);
|
|
702
|
-
};
|
|
703
|
-
});
|
|
704
|
-
|
|
705
|
-
// node_modules/better-sqlite3/lib/database.js
|
|
706
|
-
var require_database = __commonJS((exports, module) => {
|
|
707
|
-
var fs = __require("fs");
|
|
708
|
-
var path = __require("path");
|
|
709
|
-
var util = require_util();
|
|
710
|
-
var SqliteError = require_sqlite_error();
|
|
711
|
-
var DEFAULT_ADDON;
|
|
712
|
-
function Database(filenameGiven, options) {
|
|
713
|
-
if (new.target == null) {
|
|
714
|
-
return new Database(filenameGiven, options);
|
|
715
|
-
}
|
|
716
|
-
let buffer;
|
|
717
|
-
if (Buffer.isBuffer(filenameGiven)) {
|
|
718
|
-
buffer = filenameGiven;
|
|
719
|
-
filenameGiven = ":memory:";
|
|
720
|
-
}
|
|
721
|
-
if (filenameGiven == null)
|
|
722
|
-
filenameGiven = "";
|
|
723
|
-
if (options == null)
|
|
724
|
-
options = {};
|
|
725
|
-
if (typeof filenameGiven !== "string")
|
|
726
|
-
throw new TypeError("Expected first argument to be a string");
|
|
727
|
-
if (typeof options !== "object")
|
|
728
|
-
throw new TypeError("Expected second argument to be an options object");
|
|
729
|
-
if ("readOnly" in options)
|
|
730
|
-
throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
731
|
-
if ("memory" in options)
|
|
732
|
-
throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
733
|
-
const filename = filenameGiven.trim();
|
|
734
|
-
const anonymous = filename === "" || filename === ":memory:";
|
|
735
|
-
const readonly = util.getBooleanOption(options, "readonly");
|
|
736
|
-
const fileMustExist = util.getBooleanOption(options, "fileMustExist");
|
|
737
|
-
const timeout = "timeout" in options ? options.timeout : 5000;
|
|
738
|
-
const verbose = "verbose" in options ? options.verbose : null;
|
|
739
|
-
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
740
|
-
if (readonly && anonymous && !buffer)
|
|
741
|
-
throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
742
|
-
if (!Number.isInteger(timeout) || timeout < 0)
|
|
743
|
-
throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
744
|
-
if (timeout > 2147483647)
|
|
745
|
-
throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
746
|
-
if (verbose != null && typeof verbose !== "function")
|
|
747
|
-
throw new TypeError('Expected the "verbose" option to be a function');
|
|
748
|
-
if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object")
|
|
749
|
-
throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
750
|
-
let addon;
|
|
751
|
-
if (nativeBinding == null) {
|
|
752
|
-
addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
|
|
753
|
-
} else if (typeof nativeBinding === "string") {
|
|
754
|
-
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
755
|
-
addon = requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
756
|
-
} else {
|
|
757
|
-
addon = nativeBinding;
|
|
758
|
-
}
|
|
759
|
-
if (!addon.isInitialized) {
|
|
760
|
-
addon.setErrorConstructor(SqliteError);
|
|
761
|
-
addon.isInitialized = true;
|
|
762
|
-
}
|
|
763
|
-
if (!anonymous && !fs.existsSync(path.dirname(filename))) {
|
|
764
|
-
throw new TypeError("Cannot open database because the directory does not exist");
|
|
765
|
-
}
|
|
766
|
-
Object.defineProperties(this, {
|
|
767
|
-
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
768
|
-
...wrappers.getters
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
var wrappers = require_wrappers();
|
|
772
|
-
Database.prototype.prepare = wrappers.prepare;
|
|
773
|
-
Database.prototype.transaction = require_transaction();
|
|
774
|
-
Database.prototype.pragma = require_pragma();
|
|
775
|
-
Database.prototype.backup = require_backup();
|
|
776
|
-
Database.prototype.serialize = require_serialize();
|
|
777
|
-
Database.prototype.function = require_function();
|
|
778
|
-
Database.prototype.aggregate = require_aggregate();
|
|
779
|
-
Database.prototype.table = require_table();
|
|
780
|
-
Database.prototype.loadExtension = wrappers.loadExtension;
|
|
781
|
-
Database.prototype.exec = wrappers.exec;
|
|
782
|
-
Database.prototype.close = wrappers.close;
|
|
783
|
-
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
784
|
-
Database.prototype.unsafeMode = wrappers.unsafeMode;
|
|
785
|
-
Database.prototype[util.inspect] = require_inspect();
|
|
786
|
-
module.exports = Database;
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
// node_modules/better-sqlite3/lib/index.js
|
|
790
|
-
var require_lib = __commonJS((exports, module) => {
|
|
791
|
-
module.exports = require_database();
|
|
792
|
-
module.exports.SqliteError = require_sqlite_error();
|
|
793
|
-
});
|
|
794
|
-
// node_modules/drizzle-orm/better-sqlite3/driver.js
|
|
795
|
-
var import_better_sqlite3 = __toESM(require_lib(), 1);
|
|
12
|
+
// node_modules/drizzle-orm/bun-sqlite/driver.js
|
|
13
|
+
import { Database } from "bun:sqlite";
|
|
796
14
|
|
|
797
15
|
// node_modules/drizzle-orm/entity.js
|
|
798
16
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
@@ -4276,32 +3494,39 @@ class SQLiteTransaction extends BaseSQLiteDatabase {
|
|
|
4276
3494
|
}
|
|
4277
3495
|
}
|
|
4278
3496
|
|
|
4279
|
-
// node_modules/drizzle-orm/
|
|
4280
|
-
class
|
|
3497
|
+
// node_modules/drizzle-orm/bun-sqlite/session.js
|
|
3498
|
+
class SQLiteBunSession extends SQLiteSession {
|
|
4281
3499
|
constructor(client, dialect, schema, options = {}) {
|
|
4282
3500
|
super(dialect);
|
|
4283
3501
|
this.client = client;
|
|
4284
3502
|
this.schema = schema;
|
|
4285
3503
|
this.logger = options.logger ?? new NoopLogger;
|
|
4286
3504
|
}
|
|
4287
|
-
static [entityKind] = "
|
|
3505
|
+
static [entityKind] = "SQLiteBunSession";
|
|
4288
3506
|
logger;
|
|
3507
|
+
exec(query) {
|
|
3508
|
+
this.client.exec(query);
|
|
3509
|
+
}
|
|
4289
3510
|
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
|
|
4290
3511
|
const stmt = this.client.prepare(query.sql);
|
|
4291
3512
|
return new PreparedQuery(stmt, query, this.logger, fields, executeMethod, isResponseInArrayMode, customResultMapper);
|
|
4292
3513
|
}
|
|
4293
3514
|
transaction(transaction, config = {}) {
|
|
4294
|
-
const tx = new
|
|
4295
|
-
|
|
4296
|
-
|
|
3515
|
+
const tx = new SQLiteBunTransaction("sync", this.dialect, this, this.schema);
|
|
3516
|
+
let result;
|
|
3517
|
+
const nativeTx = this.client.transaction(() => {
|
|
3518
|
+
result = transaction(tx);
|
|
3519
|
+
});
|
|
3520
|
+
nativeTx[config.behavior ?? "deferred"]();
|
|
3521
|
+
return result;
|
|
4297
3522
|
}
|
|
4298
3523
|
}
|
|
4299
3524
|
|
|
4300
|
-
class
|
|
4301
|
-
static [entityKind] = "
|
|
3525
|
+
class SQLiteBunTransaction extends SQLiteTransaction {
|
|
3526
|
+
static [entityKind] = "SQLiteBunTransaction";
|
|
4302
3527
|
transaction(transaction) {
|
|
4303
3528
|
const savepointName = `sp${this.nestedIndex}`;
|
|
4304
|
-
const tx = new
|
|
3529
|
+
const tx = new SQLiteBunTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
|
4305
3530
|
this.session.run(sql.raw(`savepoint ${savepointName}`));
|
|
4306
3531
|
try {
|
|
4307
3532
|
const result = transaction(tx);
|
|
@@ -4323,14 +3548,14 @@ class PreparedQuery extends SQLitePreparedQuery {
|
|
|
4323
3548
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
4324
3549
|
this.customResultMapper = customResultMapper;
|
|
4325
3550
|
}
|
|
4326
|
-
static [entityKind] = "
|
|
3551
|
+
static [entityKind] = "SQLiteBunPreparedQuery";
|
|
4327
3552
|
run(placeholderValues) {
|
|
4328
3553
|
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
4329
3554
|
this.logger.logQuery(this.query.sql, params);
|
|
4330
3555
|
return this.stmt.run(...params);
|
|
4331
3556
|
}
|
|
4332
3557
|
all(placeholderValues) {
|
|
4333
|
-
const { fields,
|
|
3558
|
+
const { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;
|
|
4334
3559
|
if (!fields && !customResultMapper) {
|
|
4335
3560
|
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
|
4336
3561
|
logger.logQuery(query.sql, params);
|
|
@@ -4345,14 +3570,14 @@ class PreparedQuery extends SQLitePreparedQuery {
|
|
|
4345
3570
|
get(placeholderValues) {
|
|
4346
3571
|
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
4347
3572
|
this.logger.logQuery(this.query.sql, params);
|
|
4348
|
-
const
|
|
4349
|
-
if (!fields && !customResultMapper) {
|
|
4350
|
-
return stmt.get(...params);
|
|
4351
|
-
}
|
|
4352
|
-
const row = stmt.raw().get(...params);
|
|
3573
|
+
const row = this.stmt.values(...params)[0];
|
|
4353
3574
|
if (!row) {
|
|
4354
3575
|
return;
|
|
4355
3576
|
}
|
|
3577
|
+
const { fields, joinsNotNullableMap, customResultMapper } = this;
|
|
3578
|
+
if (!fields && !customResultMapper) {
|
|
3579
|
+
return row;
|
|
3580
|
+
}
|
|
4356
3581
|
if (customResultMapper) {
|
|
4357
3582
|
return customResultMapper([row]);
|
|
4358
3583
|
}
|
|
@@ -4361,16 +3586,16 @@ class PreparedQuery extends SQLitePreparedQuery {
|
|
|
4361
3586
|
values(placeholderValues) {
|
|
4362
3587
|
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
|
4363
3588
|
this.logger.logQuery(this.query.sql, params);
|
|
4364
|
-
return this.stmt.
|
|
3589
|
+
return this.stmt.values(...params);
|
|
4365
3590
|
}
|
|
4366
3591
|
isResponseInArrayMode() {
|
|
4367
3592
|
return this._isResponseInArrayMode;
|
|
4368
3593
|
}
|
|
4369
3594
|
}
|
|
4370
3595
|
|
|
4371
|
-
// node_modules/drizzle-orm/
|
|
4372
|
-
class
|
|
4373
|
-
static [entityKind] = "
|
|
3596
|
+
// node_modules/drizzle-orm/bun-sqlite/driver.js
|
|
3597
|
+
class BunSQLiteDatabase extends BaseSQLiteDatabase {
|
|
3598
|
+
static [entityKind] = "BunSQLiteDatabase";
|
|
4374
3599
|
}
|
|
4375
3600
|
function construct(client, config = {}) {
|
|
4376
3601
|
const dialect = new SQLiteSyncDialect({ casing: config.casing });
|
|
@@ -4389,14 +3614,14 @@ function construct(client, config = {}) {
|
|
|
4389
3614
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
4390
3615
|
};
|
|
4391
3616
|
}
|
|
4392
|
-
const session = new
|
|
4393
|
-
const db = new
|
|
3617
|
+
const session = new SQLiteBunSession(client, dialect, schema, { logger });
|
|
3618
|
+
const db = new BunSQLiteDatabase("sync", dialect, session, schema);
|
|
4394
3619
|
db.$client = client;
|
|
4395
3620
|
return db;
|
|
4396
3621
|
}
|
|
4397
3622
|
function drizzle(...params) {
|
|
4398
3623
|
if (params[0] === undefined || typeof params[0] === "string") {
|
|
4399
|
-
const instance = params[0] === undefined ? new
|
|
3624
|
+
const instance = params[0] === undefined ? new Database : new Database(params[0]);
|
|
4400
3625
|
return construct(instance, params[1]);
|
|
4401
3626
|
}
|
|
4402
3627
|
if (isConfig(params[0])) {
|
|
@@ -4404,11 +3629,12 @@ function drizzle(...params) {
|
|
|
4404
3629
|
if (client)
|
|
4405
3630
|
return construct(client, drizzleConfig);
|
|
4406
3631
|
if (typeof connection === "object") {
|
|
4407
|
-
const { source, ...
|
|
4408
|
-
const
|
|
3632
|
+
const { source, ...opts } = connection;
|
|
3633
|
+
const options = Object.values(opts).filter((v) => v !== undefined).length ? opts : undefined;
|
|
3634
|
+
const instance2 = new Database(source, options);
|
|
4409
3635
|
return construct(instance2, drizzleConfig);
|
|
4410
3636
|
}
|
|
4411
|
-
const instance = new
|
|
3637
|
+
const instance = new Database(connection);
|
|
4412
3638
|
return construct(instance, drizzleConfig);
|
|
4413
3639
|
}
|
|
4414
3640
|
return construct(params[0], params[1]);
|
|
@@ -4421,7 +3647,7 @@ function drizzle(...params) {
|
|
|
4421
3647
|
})(drizzle || (drizzle = {}));
|
|
4422
3648
|
|
|
4423
3649
|
// src/db/index.ts
|
|
4424
|
-
|
|
3650
|
+
import { Database as Database2 } from "bun:sqlite";
|
|
4425
3651
|
import { mkdirSync } from "fs";
|
|
4426
3652
|
import { dirname, join } from "path";
|
|
4427
3653
|
import { homedir } from "os";
|
|
@@ -4442,6 +3668,10 @@ var fineTunedModels = sqliteTable("fine_tuned_models", {
|
|
|
4442
3668
|
enum: ["pending", "running", "succeeded", "failed", "cancelled"]
|
|
4443
3669
|
}).notNull().default("pending"),
|
|
4444
3670
|
fineTuneJobId: text("fine_tune_job_id"),
|
|
3671
|
+
displayName: text("display_name"),
|
|
3672
|
+
description: text("description"),
|
|
3673
|
+
collection: text("collection"),
|
|
3674
|
+
tags: text("tags"),
|
|
4445
3675
|
createdAt: integer("created_at").notNull(),
|
|
4446
3676
|
updatedAt: integer("updated_at").notNull()
|
|
4447
3677
|
});
|
|
@@ -4480,6 +3710,10 @@ function createTables(sqlite) {
|
|
|
4480
3710
|
provider TEXT NOT NULL,
|
|
4481
3711
|
status TEXT NOT NULL DEFAULT 'pending',
|
|
4482
3712
|
fine_tune_job_id TEXT,
|
|
3713
|
+
display_name TEXT,
|
|
3714
|
+
description TEXT,
|
|
3715
|
+
collection TEXT,
|
|
3716
|
+
tags TEXT,
|
|
4483
3717
|
created_at INTEGER NOT NULL,
|
|
4484
3718
|
updated_at INTEGER NOT NULL
|
|
4485
3719
|
);
|
|
@@ -4508,9 +3742,9 @@ function createTables(sqlite) {
|
|
|
4508
3742
|
function getDb(dbPath) {
|
|
4509
3743
|
const resolvedPath = dbPath ?? DEFAULT_DB_PATH;
|
|
4510
3744
|
ensureDir(resolvedPath);
|
|
4511
|
-
const sqlite = new
|
|
4512
|
-
sqlite.
|
|
4513
|
-
sqlite.
|
|
3745
|
+
const sqlite = new Database2(resolvedPath);
|
|
3746
|
+
sqlite.run("PRAGMA journal_mode = WAL");
|
|
3747
|
+
sqlite.run("PRAGMA foreign_keys = ON");
|
|
4514
3748
|
createTables(sqlite);
|
|
4515
3749
|
return drizzle(sqlite, { schema: exports_schema });
|
|
4516
3750
|
}
|
|
@@ -10169,6 +9403,32 @@ class ThinkerLabsProvider {
|
|
|
10169
9403
|
return cancelJob(jobId);
|
|
10170
9404
|
}
|
|
10171
9405
|
}
|
|
9406
|
+
// src/lib/package-metadata.ts
|
|
9407
|
+
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
9408
|
+
import { dirname as dirname2, resolve } from "path";
|
|
9409
|
+
import { fileURLToPath } from "url";
|
|
9410
|
+
var DEFAULT_VERSION = "0.0.0";
|
|
9411
|
+
var cachedVersion;
|
|
9412
|
+
function getPackageJsonPath() {
|
|
9413
|
+
return resolve(dirname2(fileURLToPath(import.meta.url)), "../../package.json");
|
|
9414
|
+
}
|
|
9415
|
+
function getPackageVersion() {
|
|
9416
|
+
if (cachedVersion) {
|
|
9417
|
+
return cachedVersion;
|
|
9418
|
+
}
|
|
9419
|
+
const packageJsonPath = getPackageJsonPath();
|
|
9420
|
+
if (!existsSync(packageJsonPath)) {
|
|
9421
|
+
cachedVersion = DEFAULT_VERSION;
|
|
9422
|
+
return cachedVersion;
|
|
9423
|
+
}
|
|
9424
|
+
try {
|
|
9425
|
+
const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
9426
|
+
cachedVersion = typeof packageJson.version === "string" ? packageJson.version : DEFAULT_VERSION;
|
|
9427
|
+
} catch {
|
|
9428
|
+
cachedVersion = DEFAULT_VERSION;
|
|
9429
|
+
}
|
|
9430
|
+
return cachedVersion;
|
|
9431
|
+
}
|
|
10172
9432
|
export {
|
|
10173
9433
|
uploadTrainingFile,
|
|
10174
9434
|
uploadTrainingData,
|
|
@@ -10178,6 +9438,7 @@ export {
|
|
|
10178
9438
|
listModels,
|
|
10179
9439
|
listFineTunedModels,
|
|
10180
9440
|
getStatus,
|
|
9441
|
+
getPackageVersion,
|
|
10181
9442
|
getFineTuneStatus,
|
|
10182
9443
|
getDb,
|
|
10183
9444
|
fineTunedModels,
|