better-auth 0.0.6 → 0.0.7

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.js CHANGED
@@ -1,806 +1,3 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
-
33
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/util.js
34
- var require_util = __commonJS({
35
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/util.js"(exports) {
36
- "use strict";
37
- exports.getBooleanOption = (options, key) => {
38
- let value = false;
39
- if (key in options && typeof (value = options[key]) !== "boolean") {
40
- throw new TypeError(`Expected the "${key}" option to be a boolean`);
41
- }
42
- return value;
43
- };
44
- exports.cppdb = Symbol();
45
- exports.inspect = Symbol.for("nodejs.util.inspect.custom");
46
- }
47
- });
48
-
49
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/sqlite-error.js
50
- var require_sqlite_error = __commonJS({
51
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/sqlite-error.js"(exports, module) {
52
- "use strict";
53
- var descriptor = { value: "SqliteError", writable: true, enumerable: false, configurable: true };
54
- function SqliteError(message, code) {
55
- if (new.target !== SqliteError) {
56
- return new SqliteError(message, code);
57
- }
58
- if (typeof code !== "string") {
59
- throw new TypeError("Expected second argument to be a string");
60
- }
61
- Error.call(this, message);
62
- descriptor.value = "" + message;
63
- Object.defineProperty(this, "message", descriptor);
64
- Error.captureStackTrace(this, SqliteError);
65
- this.code = code;
66
- }
67
- Object.setPrototypeOf(SqliteError, Error);
68
- Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
69
- Object.defineProperty(SqliteError.prototype, "name", descriptor);
70
- module.exports = SqliteError;
71
- }
72
- });
73
-
74
- // ../../node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js
75
- var require_file_uri_to_path = __commonJS({
76
- "../../node_modules/.pnpm/file-uri-to-path@1.0.0/node_modules/file-uri-to-path/index.js"(exports, module) {
77
- "use strict";
78
- var sep = __require("path").sep || "/";
79
- module.exports = fileUriToPath;
80
- function fileUriToPath(uri) {
81
- if ("string" != typeof uri || uri.length <= 7 || "file://" != uri.substring(0, 7)) {
82
- throw new TypeError("must pass in a file:// URI to convert to a file path");
83
- }
84
- var rest = decodeURI(uri.substring(7));
85
- var firstSlash = rest.indexOf("/");
86
- var host = rest.substring(0, firstSlash);
87
- var path3 = rest.substring(firstSlash + 1);
88
- if ("localhost" == host) host = "";
89
- if (host) {
90
- host = sep + sep + host;
91
- }
92
- path3 = path3.replace(/^(.+)\|/, "$1:");
93
- if (sep == "\\") {
94
- path3 = path3.replace(/\//g, "\\");
95
- }
96
- if (/^.+\:/.test(path3)) {
97
- } else {
98
- path3 = sep + path3;
99
- }
100
- return host + path3;
101
- }
102
- }
103
- });
104
-
105
- // ../../node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js
106
- var require_bindings = __commonJS({
107
- "../../node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js"(exports, module) {
108
- "use strict";
109
- var fs = __require("fs");
110
- var path3 = __require("path");
111
- var fileURLToPath = require_file_uri_to_path();
112
- var join = path3.join;
113
- var dirname = path3.dirname;
114
- var exists = fs.accessSync && function(path4) {
115
- try {
116
- fs.accessSync(path4);
117
- } catch (e) {
118
- return false;
119
- }
120
- return true;
121
- } || fs.existsSync || path3.existsSync;
122
- var defaults = {
123
- arrow: process.env.NODE_BINDINGS_ARROW || " \u2192 ",
124
- compiled: process.env.NODE_BINDINGS_COMPILED_DIR || "compiled",
125
- platform: process.platform,
126
- arch: process.arch,
127
- nodePreGyp: "node-v" + process.versions.modules + "-" + process.platform + "-" + process.arch,
128
- version: process.versions.node,
129
- bindings: "bindings.node",
130
- try: [
131
- // node-gyp's linked version in the "build" dir
132
- ["module_root", "build", "bindings"],
133
- // node-waf and gyp_addon (a.k.a node-gyp)
134
- ["module_root", "build", "Debug", "bindings"],
135
- ["module_root", "build", "Release", "bindings"],
136
- // Debug files, for development (legacy behavior, remove for node v0.9)
137
- ["module_root", "out", "Debug", "bindings"],
138
- ["module_root", "Debug", "bindings"],
139
- // Release files, but manually compiled (legacy behavior, remove for node v0.9)
140
- ["module_root", "out", "Release", "bindings"],
141
- ["module_root", "Release", "bindings"],
142
- // Legacy from node-waf, node <= 0.4.x
143
- ["module_root", "build", "default", "bindings"],
144
- // Production "Release" buildtype binary (meh...)
145
- ["module_root", "compiled", "version", "platform", "arch", "bindings"],
146
- // node-qbs builds
147
- ["module_root", "addon-build", "release", "install-root", "bindings"],
148
- ["module_root", "addon-build", "debug", "install-root", "bindings"],
149
- ["module_root", "addon-build", "default", "install-root", "bindings"],
150
- // node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
151
- ["module_root", "lib", "binding", "nodePreGyp", "bindings"]
152
- ]
153
- };
154
- function bindings(opts) {
155
- if (typeof opts == "string") {
156
- opts = { bindings: opts };
157
- } else if (!opts) {
158
- opts = {};
159
- }
160
- Object.keys(defaults).map(function(i2) {
161
- if (!(i2 in opts)) opts[i2] = defaults[i2];
162
- });
163
- if (!opts.module_root) {
164
- opts.module_root = exports.getRoot(exports.getFileName());
165
- }
166
- if (path3.extname(opts.bindings) != ".node") {
167
- opts.bindings += ".node";
168
- }
169
- var requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
170
- var tries = [], i = 0, l = opts.try.length, n, b, err;
171
- for (; i < l; i++) {
172
- n = join.apply(
173
- null,
174
- opts.try[i].map(function(p) {
175
- return opts[p] || p;
176
- })
177
- );
178
- tries.push(n);
179
- try {
180
- b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
181
- if (!opts.path) {
182
- b.path = n;
183
- }
184
- return b;
185
- } catch (e) {
186
- if (e.code !== "MODULE_NOT_FOUND" && e.code !== "QUALIFIED_PATH_RESOLUTION_FAILED" && !/not find/i.test(e.message)) {
187
- throw e;
188
- }
189
- }
190
- }
191
- err = new Error(
192
- "Could not locate the bindings file. Tried:\n" + tries.map(function(a) {
193
- return opts.arrow + a;
194
- }).join("\n")
195
- );
196
- err.tries = tries;
197
- throw err;
198
- }
199
- module.exports = exports = bindings;
200
- exports.getFileName = function getFileName(calling_file) {
201
- var origPST = Error.prepareStackTrace, origSTL = Error.stackTraceLimit, dummy = {}, fileName;
202
- Error.stackTraceLimit = 10;
203
- Error.prepareStackTrace = function(e, st) {
204
- for (var i = 0, l = st.length; i < l; i++) {
205
- fileName = st[i].getFileName();
206
- if (fileName !== __filename) {
207
- if (calling_file) {
208
- if (fileName !== calling_file) {
209
- return;
210
- }
211
- } else {
212
- return;
213
- }
214
- }
215
- }
216
- };
217
- Error.captureStackTrace(dummy);
218
- dummy.stack;
219
- Error.prepareStackTrace = origPST;
220
- Error.stackTraceLimit = origSTL;
221
- var fileSchema = "file://";
222
- if (fileName.indexOf(fileSchema) === 0) {
223
- fileName = fileURLToPath(fileName);
224
- }
225
- return fileName;
226
- };
227
- exports.getRoot = function getRoot(file) {
228
- var dir = dirname(file), prev;
229
- while (true) {
230
- if (dir === ".") {
231
- dir = process.cwd();
232
- }
233
- if (exists(join(dir, "package.json")) || exists(join(dir, "node_modules"))) {
234
- return dir;
235
- }
236
- if (prev === dir) {
237
- throw new Error(
238
- 'Could not find module root given file: "' + file + '". Do you have a `package.json` file? '
239
- );
240
- }
241
- prev = dir;
242
- dir = join(dir, "..");
243
- }
244
- };
245
- }
246
- });
247
-
248
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/wrappers.js
249
- var require_wrappers = __commonJS({
250
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/wrappers.js"(exports) {
251
- "use strict";
252
- var { cppdb } = require_util();
253
- exports.prepare = function prepare(sql) {
254
- return this[cppdb].prepare(sql, this, false);
255
- };
256
- exports.exec = function exec(sql) {
257
- this[cppdb].exec(sql);
258
- return this;
259
- };
260
- exports.close = function close() {
261
- this[cppdb].close();
262
- return this;
263
- };
264
- exports.loadExtension = function loadExtension(...args) {
265
- this[cppdb].loadExtension(...args);
266
- return this;
267
- };
268
- exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
269
- this[cppdb].defaultSafeIntegers(...args);
270
- return this;
271
- };
272
- exports.unsafeMode = function unsafeMode(...args) {
273
- this[cppdb].unsafeMode(...args);
274
- return this;
275
- };
276
- exports.getters = {
277
- name: {
278
- get: function name() {
279
- return this[cppdb].name;
280
- },
281
- enumerable: true
282
- },
283
- open: {
284
- get: function open() {
285
- return this[cppdb].open;
286
- },
287
- enumerable: true
288
- },
289
- inTransaction: {
290
- get: function inTransaction() {
291
- return this[cppdb].inTransaction;
292
- },
293
- enumerable: true
294
- },
295
- readonly: {
296
- get: function readonly() {
297
- return this[cppdb].readonly;
298
- },
299
- enumerable: true
300
- },
301
- memory: {
302
- get: function memory() {
303
- return this[cppdb].memory;
304
- },
305
- enumerable: true
306
- }
307
- };
308
- }
309
- });
310
-
311
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/transaction.js
312
- var require_transaction = __commonJS({
313
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/transaction.js"(exports, module) {
314
- "use strict";
315
- var { cppdb } = require_util();
316
- var controllers = /* @__PURE__ */ new WeakMap();
317
- module.exports = function transaction(fn) {
318
- if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
319
- const db = this[cppdb];
320
- const controller = getController(db, this);
321
- const { apply } = Function.prototype;
322
- const properties = {
323
- default: { value: wrapTransaction(apply, fn, db, controller.default) },
324
- deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
325
- immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
326
- exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
327
- database: { value: this, enumerable: true }
328
- };
329
- Object.defineProperties(properties.default.value, properties);
330
- Object.defineProperties(properties.deferred.value, properties);
331
- Object.defineProperties(properties.immediate.value, properties);
332
- Object.defineProperties(properties.exclusive.value, properties);
333
- return properties.default.value;
334
- };
335
- var getController = (db, self) => {
336
- let controller = controllers.get(db);
337
- if (!controller) {
338
- const shared = {
339
- commit: db.prepare("COMMIT", self, false),
340
- rollback: db.prepare("ROLLBACK", self, false),
341
- savepoint: db.prepare("SAVEPOINT ` _bs3. `", self, false),
342
- release: db.prepare("RELEASE ` _bs3. `", self, false),
343
- rollbackTo: db.prepare("ROLLBACK TO ` _bs3. `", self, false)
344
- };
345
- controllers.set(db, controller = {
346
- default: Object.assign({ begin: db.prepare("BEGIN", self, false) }, shared),
347
- deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false) }, shared),
348
- immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false) }, shared),
349
- exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false) }, shared)
350
- });
351
- }
352
- return controller;
353
- };
354
- var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
355
- let before, after, undo;
356
- if (db.inTransaction) {
357
- before = savepoint;
358
- after = release;
359
- undo = rollbackTo;
360
- } else {
361
- before = begin;
362
- after = commit;
363
- undo = rollback;
364
- }
365
- before.run();
366
- try {
367
- const result = apply.call(fn, this, arguments);
368
- after.run();
369
- return result;
370
- } catch (ex) {
371
- if (db.inTransaction) {
372
- undo.run();
373
- if (undo !== rollback) after.run();
374
- }
375
- throw ex;
376
- }
377
- };
378
- }
379
- });
380
-
381
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/pragma.js
382
- var require_pragma = __commonJS({
383
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/pragma.js"(exports, module) {
384
- "use strict";
385
- var { getBooleanOption, cppdb } = require_util();
386
- module.exports = function pragma(source, options) {
387
- if (options == null) options = {};
388
- if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
389
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
390
- const simple = getBooleanOption(options, "simple");
391
- const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true);
392
- return simple ? stmt.pluck().get() : stmt.all();
393
- };
394
- }
395
- });
396
-
397
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/backup.js
398
- var require_backup = __commonJS({
399
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/backup.js"(exports, module) {
400
- "use strict";
401
- var fs = __require("fs");
402
- var path3 = __require("path");
403
- var { promisify } = __require("util");
404
- var { cppdb } = require_util();
405
- var fsAccess = promisify(fs.access);
406
- module.exports = async function backup(filename, options) {
407
- if (options == null) options = {};
408
- if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
409
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
410
- filename = filename.trim();
411
- const attachedName = "attached" in options ? options.attached : "main";
412
- const handler = "progress" in options ? options.progress : null;
413
- if (!filename) throw new TypeError("Backup filename cannot be an empty string");
414
- if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
415
- if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
416
- if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
417
- if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
418
- await fsAccess(path3.dirname(filename)).catch(() => {
419
- throw new TypeError("Cannot save backup because the directory does not exist");
420
- });
421
- const isNewFile = await fsAccess(filename).then(() => false, () => true);
422
- return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
423
- };
424
- var runBackup = (backup, handler) => {
425
- let rate = 0;
426
- let useDefault = true;
427
- return new Promise((resolve, reject) => {
428
- setImmediate(function step() {
429
- try {
430
- const progress = backup.transfer(rate);
431
- if (!progress.remainingPages) {
432
- backup.close();
433
- resolve(progress);
434
- return;
435
- }
436
- if (useDefault) {
437
- useDefault = false;
438
- rate = 100;
439
- }
440
- if (handler) {
441
- const ret = handler(progress);
442
- if (ret !== void 0) {
443
- if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
444
- else throw new TypeError("Expected progress callback to return a number or undefined");
445
- }
446
- }
447
- setImmediate(step);
448
- } catch (err) {
449
- backup.close();
450
- reject(err);
451
- }
452
- });
453
- });
454
- };
455
- }
456
- });
457
-
458
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/serialize.js
459
- var require_serialize = __commonJS({
460
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/serialize.js"(exports, module) {
461
- "use strict";
462
- var { cppdb } = require_util();
463
- module.exports = function serialize(options) {
464
- if (options == null) options = {};
465
- if (typeof options !== "object") throw new TypeError("Expected first argument to be an options object");
466
- const attachedName = "attached" in options ? options.attached : "main";
467
- if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
468
- if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
469
- return this[cppdb].serialize(attachedName);
470
- };
471
- }
472
- });
473
-
474
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/function.js
475
- var require_function = __commonJS({
476
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/function.js"(exports, module) {
477
- "use strict";
478
- var { getBooleanOption, cppdb } = require_util();
479
- module.exports = function defineFunction(name, options, fn) {
480
- if (options == null) options = {};
481
- if (typeof options === "function") {
482
- fn = options;
483
- options = {};
484
- }
485
- if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
486
- if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
487
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
488
- if (!name) throw new TypeError("User-defined function name cannot be an empty string");
489
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
490
- const deterministic = getBooleanOption(options, "deterministic");
491
- const directOnly = getBooleanOption(options, "directOnly");
492
- const varargs = getBooleanOption(options, "varargs");
493
- let argCount = -1;
494
- if (!varargs) {
495
- argCount = fn.length;
496
- if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
497
- if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
498
- }
499
- this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
500
- return this;
501
- };
502
- }
503
- });
504
-
505
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/aggregate.js
506
- var require_aggregate = __commonJS({
507
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/aggregate.js"(exports, module) {
508
- "use strict";
509
- var { getBooleanOption, cppdb } = require_util();
510
- module.exports = function defineAggregate(name, options) {
511
- if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
512
- if (typeof options !== "object" || options === null) throw new TypeError("Expected second argument to be an options object");
513
- if (!name) throw new TypeError("User-defined function name cannot be an empty string");
514
- const start = "start" in options ? options.start : null;
515
- const step = getFunctionOption(options, "step", true);
516
- const inverse = getFunctionOption(options, "inverse", false);
517
- const result = getFunctionOption(options, "result", false);
518
- const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
519
- const deterministic = getBooleanOption(options, "deterministic");
520
- const directOnly = getBooleanOption(options, "directOnly");
521
- const varargs = getBooleanOption(options, "varargs");
522
- let argCount = -1;
523
- if (!varargs) {
524
- argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
525
- if (argCount > 0) argCount -= 1;
526
- if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
527
- }
528
- this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
529
- return this;
530
- };
531
- var getFunctionOption = (options, key, required) => {
532
- const value = key in options ? options[key] : null;
533
- if (typeof value === "function") return value;
534
- if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
535
- if (required) throw new TypeError(`Missing required option "${key}"`);
536
- return null;
537
- };
538
- var getLength = ({ length }) => {
539
- if (Number.isInteger(length) && length >= 0) return length;
540
- throw new TypeError("Expected function.length to be a positive integer");
541
- };
542
- }
543
- });
544
-
545
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/table.js
546
- var require_table = __commonJS({
547
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/table.js"(exports, module) {
548
- "use strict";
549
- var { cppdb } = require_util();
550
- module.exports = function defineTable(name, factory) {
551
- if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
552
- if (!name) throw new TypeError("Virtual table module name cannot be an empty string");
553
- let eponymous = false;
554
- if (typeof factory === "object" && factory !== null) {
555
- eponymous = true;
556
- factory = defer(parseTableDefinition(factory, "used", name));
557
- } else {
558
- if (typeof factory !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
559
- factory = wrapFactory(factory);
560
- }
561
- this[cppdb].table(factory, name, eponymous);
562
- return this;
563
- };
564
- function wrapFactory(factory) {
565
- return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
566
- const thisObject = {
567
- module: moduleName,
568
- database: databaseName,
569
- table: tableName
570
- };
571
- const def = apply.call(factory, thisObject, args);
572
- if (typeof def !== "object" || def === null) {
573
- throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
574
- }
575
- return parseTableDefinition(def, "returned", moduleName);
576
- };
577
- }
578
- function parseTableDefinition(def, verb, moduleName) {
579
- if (!hasOwnProperty.call(def, "rows")) {
580
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
581
- }
582
- if (!hasOwnProperty.call(def, "columns")) {
583
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
584
- }
585
- const rows = def.rows;
586
- if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
587
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
588
- }
589
- let columns = def.columns;
590
- if (!Array.isArray(columns) || !(columns = [...columns]).every((x) => typeof x === "string")) {
591
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
592
- }
593
- if (columns.length !== new Set(columns).size) {
594
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
595
- }
596
- if (!columns.length) {
597
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
598
- }
599
- let parameters;
600
- if (hasOwnProperty.call(def, "parameters")) {
601
- parameters = def.parameters;
602
- if (!Array.isArray(parameters) || !(parameters = [...parameters]).every((x) => typeof x === "string")) {
603
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
604
- }
605
- } else {
606
- parameters = inferParameters(rows);
607
- }
608
- if (parameters.length !== new Set(parameters).size) {
609
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
610
- }
611
- if (parameters.length > 32) {
612
- throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
613
- }
614
- for (const parameter of parameters) {
615
- if (columns.includes(parameter)) {
616
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
617
- }
618
- }
619
- let safeIntegers = 2;
620
- if (hasOwnProperty.call(def, "safeIntegers")) {
621
- const bool = def.safeIntegers;
622
- if (typeof bool !== "boolean") {
623
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
624
- }
625
- safeIntegers = +bool;
626
- }
627
- let directOnly = false;
628
- if (hasOwnProperty.call(def, "directOnly")) {
629
- directOnly = def.directOnly;
630
- if (typeof directOnly !== "boolean") {
631
- throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
632
- }
633
- }
634
- const columnDefinitions = [
635
- ...parameters.map(identifier).map((str) => `${str} HIDDEN`),
636
- ...columns.map(identifier)
637
- ];
638
- return [
639
- `CREATE TABLE x(${columnDefinitions.join(", ")});`,
640
- wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
641
- parameters,
642
- safeIntegers,
643
- directOnly
644
- ];
645
- }
646
- function wrapGenerator(generator, columnMap, moduleName) {
647
- return function* virtualTable(...args) {
648
- const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
649
- for (let i = 0; i < columnMap.size; ++i) {
650
- output.push(null);
651
- }
652
- for (const row of generator(...args)) {
653
- if (Array.isArray(row)) {
654
- extractRowArray(row, output, columnMap.size, moduleName);
655
- yield output;
656
- } else if (typeof row === "object" && row !== null) {
657
- extractRowObject(row, output, columnMap, moduleName);
658
- yield output;
659
- } else {
660
- throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
661
- }
662
- }
663
- };
664
- }
665
- function extractRowArray(row, output, columnCount, moduleName) {
666
- if (row.length !== columnCount) {
667
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
668
- }
669
- const offset = output.length - columnCount;
670
- for (let i = 0; i < columnCount; ++i) {
671
- output[i + offset] = row[i];
672
- }
673
- }
674
- function extractRowObject(row, output, columnMap, moduleName) {
675
- let count = 0;
676
- for (const key of Object.keys(row)) {
677
- const index = columnMap.get(key);
678
- if (index === void 0) {
679
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
680
- }
681
- output[index] = row[key];
682
- count += 1;
683
- }
684
- if (count !== columnMap.size) {
685
- throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
686
- }
687
- }
688
- function inferParameters({ length }) {
689
- if (!Number.isInteger(length) || length < 0) {
690
- throw new TypeError("Expected function.length to be a positive integer");
691
- }
692
- const params = [];
693
- for (let i = 0; i < length; ++i) {
694
- params.push(`$${i + 1}`);
695
- }
696
- return params;
697
- }
698
- var { hasOwnProperty } = Object.prototype;
699
- var { apply } = Function.prototype;
700
- var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
701
- });
702
- var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
703
- var defer = (x) => () => x;
704
- }
705
- });
706
-
707
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/inspect.js
708
- var require_inspect = __commonJS({
709
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/methods/inspect.js"(exports, module) {
710
- "use strict";
711
- var DatabaseInspection = function Database2() {
712
- };
713
- module.exports = function inspect(depth, opts) {
714
- return Object.assign(new DatabaseInspection(), this);
715
- };
716
- }
717
- });
718
-
719
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/database.js
720
- var require_database = __commonJS({
721
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/database.js"(exports, module) {
722
- "use strict";
723
- var fs = __require("fs");
724
- var path3 = __require("path");
725
- var util = require_util();
726
- var SqliteError = require_sqlite_error();
727
- var DEFAULT_ADDON;
728
- function Database2(filenameGiven, options) {
729
- if (new.target == null) {
730
- return new Database2(filenameGiven, options);
731
- }
732
- let buffer;
733
- if (Buffer.isBuffer(filenameGiven)) {
734
- buffer = filenameGiven;
735
- filenameGiven = ":memory:";
736
- }
737
- if (filenameGiven == null) filenameGiven = "";
738
- if (options == null) options = {};
739
- if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
740
- if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
741
- if ("readOnly" in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
742
- if ("memory" in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
743
- const filename = filenameGiven.trim();
744
- const anonymous = filename === "" || filename === ":memory:";
745
- const readonly = util.getBooleanOption(options, "readonly");
746
- const fileMustExist = util.getBooleanOption(options, "fileMustExist");
747
- const timeout = "timeout" in options ? options.timeout : 5e3;
748
- const verbose = "verbose" in options ? options.verbose : null;
749
- const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
750
- if (readonly && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
751
- if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
752
- if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
753
- if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
754
- if (nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
755
- let addon;
756
- if (nativeBinding == null) {
757
- addon = DEFAULT_ADDON || (DEFAULT_ADDON = require_bindings()("better_sqlite3.node"));
758
- } else if (typeof nativeBinding === "string") {
759
- const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
760
- addon = requireFunc(path3.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
761
- } else {
762
- addon = nativeBinding;
763
- }
764
- if (!addon.isInitialized) {
765
- addon.setErrorConstructor(SqliteError);
766
- addon.isInitialized = true;
767
- }
768
- if (!anonymous && !fs.existsSync(path3.dirname(filename))) {
769
- throw new TypeError("Cannot open database because the directory does not exist");
770
- }
771
- Object.defineProperties(this, {
772
- [util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
773
- ...wrappers.getters
774
- });
775
- }
776
- var wrappers = require_wrappers();
777
- Database2.prototype.prepare = wrappers.prepare;
778
- Database2.prototype.transaction = require_transaction();
779
- Database2.prototype.pragma = require_pragma();
780
- Database2.prototype.backup = require_backup();
781
- Database2.prototype.serialize = require_serialize();
782
- Database2.prototype.function = require_function();
783
- Database2.prototype.aggregate = require_aggregate();
784
- Database2.prototype.table = require_table();
785
- Database2.prototype.loadExtension = wrappers.loadExtension;
786
- Database2.prototype.exec = wrappers.exec;
787
- Database2.prototype.close = wrappers.close;
788
- Database2.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
789
- Database2.prototype.unsafeMode = wrappers.unsafeMode;
790
- Database2.prototype[util.inspect] = require_inspect();
791
- module.exports = Database2;
792
- }
793
- });
794
-
795
- // ../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/index.js
796
- var require_lib = __commonJS({
797
- "../../node_modules/.pnpm/better-sqlite3@11.1.2/node_modules/better-sqlite3/lib/index.js"(exports, module) {
798
- "use strict";
799
- module.exports = require_database();
800
- module.exports.SqliteError = require_sqlite_error();
801
- }
802
- });
803
-
804
1
  // src/cli/index.ts
805
2
  import { Command as Command2 } from "commander";
806
3
  import "dotenv/config";
@@ -910,7 +107,7 @@ import { existsSync } from "fs";
910
107
  import path2 from "path";
911
108
 
912
109
  // src/adapters/kysely.ts
913
- var import_better_sqlite3 = __toESM(require_lib(), 1);
110
+ import Database from "better-sqlite3";
914
111
  import { Kysely } from "kysely";
915
112
  import {
916
113
  MysqlDialect,
@@ -948,7 +145,7 @@ var getDialect = (config) => {
948
145
  dialect = new MysqlDialect({ pool });
949
146
  }
950
147
  if (provider === "sqlite") {
951
- const db = new import_better_sqlite3.default(connectionString);
148
+ const db = new Database(connectionString);
952
149
  dialect = new SqliteDialect({
953
150
  database: db
954
151
  });
@@ -1145,7 +342,7 @@ var postgresMap = {
1145
342
  "real",
1146
343
  "double precision"
1147
344
  ],
1148
- boolean: ["boolean"],
345
+ boolean: ["bool", "boolean"],
1149
346
  date: ["timestamp", "date"]
1150
347
  };
1151
348
  var mysqlMap = {