@solgate/server 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/app-CB9x11xM.d.ts +415 -0
- package/dist/chunk-MCKGQKYU.js +15 -0
- package/dist/chunk-MSHXG5G3.js +1358 -0
- package/dist/chunk-MYF3SW4P.js +43 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +12 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.js +56 -0
- package/dist/lib-HMVXUU3V.js +694 -0
- package/dist/node.d.ts +9 -0
- package/dist/node.js +10 -0
- package/package.json +57 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require
|
|
4
|
+
} from "./chunk-MCKGQKYU.js";
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/util.js
|
|
7
|
+
var require_util = __commonJS({
|
|
8
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/util.js"(exports) {
|
|
9
|
+
"use strict";
|
|
10
|
+
exports.getBooleanOption = (options, key) => {
|
|
11
|
+
let value = false;
|
|
12
|
+
if (key in options && typeof (value = options[key]) !== "boolean") {
|
|
13
|
+
throw new TypeError(`Expected the "${key}" option to be a boolean`);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
exports.cppdb = /* @__PURE__ */ Symbol();
|
|
18
|
+
exports.inspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/sqlite-error.js
|
|
23
|
+
var require_sqlite_error = __commonJS({
|
|
24
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/sqlite-error.js"(exports, module) {
|
|
25
|
+
"use strict";
|
|
26
|
+
var SqliteError = class _SqliteError extends Error {
|
|
27
|
+
constructor(message, code) {
|
|
28
|
+
if (typeof code !== "string") {
|
|
29
|
+
throw new TypeError("Expected second argument to be a string");
|
|
30
|
+
}
|
|
31
|
+
super("" + message);
|
|
32
|
+
this.code = code;
|
|
33
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
34
|
+
Error.captureStackTrace(this, _SqliteError);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(SqliteError.prototype, "name", {
|
|
39
|
+
value: "SqliteError",
|
|
40
|
+
writable: true,
|
|
41
|
+
enumerable: false,
|
|
42
|
+
configurable: true
|
|
43
|
+
});
|
|
44
|
+
module.exports = SqliteError;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/wrappers.js
|
|
49
|
+
var require_wrappers = __commonJS({
|
|
50
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/wrappers.js"(exports) {
|
|
51
|
+
"use strict";
|
|
52
|
+
var { cppdb } = require_util();
|
|
53
|
+
exports.prepare = function prepare(sql) {
|
|
54
|
+
return this[cppdb].prepare(sql, this, false, false);
|
|
55
|
+
};
|
|
56
|
+
exports.exec = function exec(sql) {
|
|
57
|
+
this[cppdb].exec(sql);
|
|
58
|
+
return this;
|
|
59
|
+
};
|
|
60
|
+
exports.close = function close() {
|
|
61
|
+
this[cppdb].close();
|
|
62
|
+
return this;
|
|
63
|
+
};
|
|
64
|
+
exports.loadExtension = function loadExtension(...args) {
|
|
65
|
+
this[cppdb].loadExtension(...args);
|
|
66
|
+
return this;
|
|
67
|
+
};
|
|
68
|
+
exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
|
|
69
|
+
this[cppdb].defaultSafeIntegers(...args);
|
|
70
|
+
return this;
|
|
71
|
+
};
|
|
72
|
+
exports.unsafeMode = function unsafeMode(...args) {
|
|
73
|
+
this[cppdb].unsafeMode(...args);
|
|
74
|
+
return this;
|
|
75
|
+
};
|
|
76
|
+
exports.getters = {
|
|
77
|
+
name: {
|
|
78
|
+
get: function name() {
|
|
79
|
+
return this[cppdb].name;
|
|
80
|
+
},
|
|
81
|
+
enumerable: true
|
|
82
|
+
},
|
|
83
|
+
open: {
|
|
84
|
+
get: function open() {
|
|
85
|
+
return this[cppdb].open;
|
|
86
|
+
},
|
|
87
|
+
enumerable: true
|
|
88
|
+
},
|
|
89
|
+
inTransaction: {
|
|
90
|
+
get: function inTransaction() {
|
|
91
|
+
return this[cppdb].inTransaction;
|
|
92
|
+
},
|
|
93
|
+
enumerable: true
|
|
94
|
+
},
|
|
95
|
+
readonly: {
|
|
96
|
+
get: function readonly() {
|
|
97
|
+
return this[cppdb].readonly;
|
|
98
|
+
},
|
|
99
|
+
enumerable: true
|
|
100
|
+
},
|
|
101
|
+
memory: {
|
|
102
|
+
get: function memory() {
|
|
103
|
+
return this[cppdb].memory;
|
|
104
|
+
},
|
|
105
|
+
enumerable: true
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/transaction.js
|
|
112
|
+
var require_transaction = __commonJS({
|
|
113
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/transaction.js"(exports, module) {
|
|
114
|
+
"use strict";
|
|
115
|
+
var { cppdb } = require_util();
|
|
116
|
+
var controllers = /* @__PURE__ */ new WeakMap();
|
|
117
|
+
module.exports = function transaction(fn) {
|
|
118
|
+
if (typeof fn !== "function") throw new TypeError("Expected first argument to be a function");
|
|
119
|
+
const db = this[cppdb];
|
|
120
|
+
const controller = getController(db, this);
|
|
121
|
+
const { apply } = Function.prototype;
|
|
122
|
+
const properties = {
|
|
123
|
+
default: { value: wrapTransaction(apply, fn, db, controller.default) },
|
|
124
|
+
deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
|
|
125
|
+
immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
|
|
126
|
+
exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
|
|
127
|
+
database: { value: this, enumerable: true }
|
|
128
|
+
};
|
|
129
|
+
Object.defineProperties(properties.default.value, properties);
|
|
130
|
+
Object.defineProperties(properties.deferred.value, properties);
|
|
131
|
+
Object.defineProperties(properties.immediate.value, properties);
|
|
132
|
+
Object.defineProperties(properties.exclusive.value, properties);
|
|
133
|
+
return properties.default.value;
|
|
134
|
+
};
|
|
135
|
+
var getController = (db, self) => {
|
|
136
|
+
let controller = controllers.get(db);
|
|
137
|
+
if (!controller) {
|
|
138
|
+
const shared = {
|
|
139
|
+
commit: db.prepare("COMMIT", self, false, false),
|
|
140
|
+
rollback: db.prepare("ROLLBACK", self, false, false),
|
|
141
|
+
savepoint: db.prepare("SAVEPOINT ` _bs3. `", self, false, false),
|
|
142
|
+
release: db.prepare("RELEASE ` _bs3. `", self, false, false),
|
|
143
|
+
rollbackTo: db.prepare("ROLLBACK TO ` _bs3. `", self, false, false)
|
|
144
|
+
};
|
|
145
|
+
controllers.set(db, controller = {
|
|
146
|
+
default: Object.assign({ begin: db.prepare("BEGIN", self, false, false) }, shared),
|
|
147
|
+
deferred: Object.assign({ begin: db.prepare("BEGIN DEFERRED", self, false, false) }, shared),
|
|
148
|
+
immediate: Object.assign({ begin: db.prepare("BEGIN IMMEDIATE", self, false, false) }, shared),
|
|
149
|
+
exclusive: Object.assign({ begin: db.prepare("BEGIN EXCLUSIVE", self, false, false) }, shared)
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return controller;
|
|
153
|
+
};
|
|
154
|
+
var wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
|
|
155
|
+
let before, after, undo;
|
|
156
|
+
if (db.inTransaction) {
|
|
157
|
+
before = savepoint;
|
|
158
|
+
after = release;
|
|
159
|
+
undo = rollbackTo;
|
|
160
|
+
} else {
|
|
161
|
+
before = begin;
|
|
162
|
+
after = commit;
|
|
163
|
+
undo = rollback;
|
|
164
|
+
}
|
|
165
|
+
before.run();
|
|
166
|
+
try {
|
|
167
|
+
const result = apply.call(fn, this, arguments);
|
|
168
|
+
if (result && typeof result.then === "function") {
|
|
169
|
+
throw new TypeError("Transaction function cannot return a promise");
|
|
170
|
+
}
|
|
171
|
+
after.run();
|
|
172
|
+
return result;
|
|
173
|
+
} catch (ex) {
|
|
174
|
+
if (db.inTransaction) {
|
|
175
|
+
undo.run();
|
|
176
|
+
if (undo !== rollback) after.run();
|
|
177
|
+
}
|
|
178
|
+
throw ex;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/pragma.js
|
|
185
|
+
var require_pragma = __commonJS({
|
|
186
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/pragma.js"(exports, module) {
|
|
187
|
+
"use strict";
|
|
188
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
189
|
+
module.exports = function pragma(source, options) {
|
|
190
|
+
if (options == null) options = {};
|
|
191
|
+
if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
|
|
192
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
193
|
+
const simple = getBooleanOption(options, "simple");
|
|
194
|
+
const stmt = this[cppdb].prepare(`PRAGMA ${source}`, this, true, false);
|
|
195
|
+
return simple ? stmt.pluck().get() : stmt.all();
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/explain.js
|
|
201
|
+
var require_explain = __commonJS({
|
|
202
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/explain.js"(exports, module) {
|
|
203
|
+
"use strict";
|
|
204
|
+
var { cppdb } = require_util();
|
|
205
|
+
module.exports = function explain(source) {
|
|
206
|
+
if (typeof source !== "string") throw new TypeError("Expected first argument to be a string");
|
|
207
|
+
const stmt = this[cppdb].prepare(`EXPLAIN ${source}`, this, false, true);
|
|
208
|
+
return stmt.all();
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/backup.js
|
|
214
|
+
var require_backup = __commonJS({
|
|
215
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/backup.js"(exports, module) {
|
|
216
|
+
"use strict";
|
|
217
|
+
var fs = __require("fs");
|
|
218
|
+
var path = __require("path");
|
|
219
|
+
var { promisify } = __require("util");
|
|
220
|
+
var { cppdb } = require_util();
|
|
221
|
+
var fsAccess = promisify(fs.access);
|
|
222
|
+
module.exports = async function backup(filename, options) {
|
|
223
|
+
if (options == null) options = {};
|
|
224
|
+
if (typeof filename !== "string") throw new TypeError("Expected first argument to be a string");
|
|
225
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
226
|
+
filename = filename.trim();
|
|
227
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
228
|
+
const handler = "progress" in options ? options.progress : null;
|
|
229
|
+
if (!filename) throw new TypeError("Backup filename cannot be an empty string");
|
|
230
|
+
if (filename === ":memory:") throw new TypeError('Invalid backup filename ":memory:"');
|
|
231
|
+
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
232
|
+
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
233
|
+
if (handler != null && typeof handler !== "function") throw new TypeError('Expected the "progress" option to be a function');
|
|
234
|
+
await fsAccess(path.dirname(filename)).catch(() => {
|
|
235
|
+
throw new TypeError("Cannot save backup because the directory does not exist");
|
|
236
|
+
});
|
|
237
|
+
const isNewFile = await fsAccess(filename).then(() => false, () => true);
|
|
238
|
+
return runBackup(this[cppdb].backup(this, attachedName, filename, isNewFile), handler || null);
|
|
239
|
+
};
|
|
240
|
+
var runBackup = (backup, handler) => {
|
|
241
|
+
let rate = 0;
|
|
242
|
+
let useDefault = true;
|
|
243
|
+
return new Promise((resolve, reject) => {
|
|
244
|
+
setImmediate(function step() {
|
|
245
|
+
try {
|
|
246
|
+
const progress = backup.transfer(rate);
|
|
247
|
+
if (!progress.remainingPages) {
|
|
248
|
+
backup.close();
|
|
249
|
+
resolve(progress);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (useDefault) {
|
|
253
|
+
useDefault = false;
|
|
254
|
+
rate = 100;
|
|
255
|
+
}
|
|
256
|
+
if (handler) {
|
|
257
|
+
const ret = handler(progress);
|
|
258
|
+
if (ret !== void 0) {
|
|
259
|
+
if (typeof ret === "number" && ret === ret) rate = Math.max(0, Math.min(2147483647, Math.round(ret)));
|
|
260
|
+
else throw new TypeError("Expected progress callback to return a number or undefined");
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
setImmediate(step);
|
|
264
|
+
} catch (err) {
|
|
265
|
+
backup.close();
|
|
266
|
+
reject(err);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/serialize.js
|
|
275
|
+
var require_serialize = __commonJS({
|
|
276
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/serialize.js"(exports, module) {
|
|
277
|
+
"use strict";
|
|
278
|
+
var { cppdb } = require_util();
|
|
279
|
+
module.exports = function serialize(options) {
|
|
280
|
+
if (options == null) options = {};
|
|
281
|
+
if (typeof options !== "object") throw new TypeError("Expected first argument to be an options object");
|
|
282
|
+
const attachedName = "attached" in options ? options.attached : "main";
|
|
283
|
+
if (typeof attachedName !== "string") throw new TypeError('Expected the "attached" option to be a string');
|
|
284
|
+
if (!attachedName) throw new TypeError('The "attached" option cannot be an empty string');
|
|
285
|
+
return this[cppdb].serialize(attachedName);
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/function.js
|
|
291
|
+
var require_function = __commonJS({
|
|
292
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/function.js"(exports, module) {
|
|
293
|
+
"use strict";
|
|
294
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
295
|
+
module.exports = function defineFunction(name, options, fn) {
|
|
296
|
+
if (options == null) options = {};
|
|
297
|
+
if (typeof options === "function") {
|
|
298
|
+
fn = options;
|
|
299
|
+
options = {};
|
|
300
|
+
}
|
|
301
|
+
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
302
|
+
if (typeof fn !== "function") throw new TypeError("Expected last argument to be a function");
|
|
303
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
304
|
+
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
305
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
306
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
307
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
308
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
309
|
+
let argCount = -1;
|
|
310
|
+
if (!varargs) {
|
|
311
|
+
argCount = fn.length;
|
|
312
|
+
if (!Number.isInteger(argCount) || argCount < 0) throw new TypeError("Expected function.length to be a positive integer");
|
|
313
|
+
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
314
|
+
}
|
|
315
|
+
this[cppdb].function(fn, name, argCount, safeIntegers, deterministic, directOnly);
|
|
316
|
+
return this;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/aggregate.js
|
|
322
|
+
var require_aggregate = __commonJS({
|
|
323
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/aggregate.js"(exports, module) {
|
|
324
|
+
"use strict";
|
|
325
|
+
var { getBooleanOption, cppdb } = require_util();
|
|
326
|
+
module.exports = function defineAggregate(name, options) {
|
|
327
|
+
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
328
|
+
if (typeof options !== "object" || options === null) throw new TypeError("Expected second argument to be an options object");
|
|
329
|
+
if (!name) throw new TypeError("User-defined function name cannot be an empty string");
|
|
330
|
+
const start = "start" in options ? options.start : null;
|
|
331
|
+
const step = getFunctionOption(options, "step", true);
|
|
332
|
+
const inverse = getFunctionOption(options, "inverse", false);
|
|
333
|
+
const result = getFunctionOption(options, "result", false);
|
|
334
|
+
const safeIntegers = "safeIntegers" in options ? +getBooleanOption(options, "safeIntegers") : 2;
|
|
335
|
+
const deterministic = getBooleanOption(options, "deterministic");
|
|
336
|
+
const directOnly = getBooleanOption(options, "directOnly");
|
|
337
|
+
const varargs = getBooleanOption(options, "varargs");
|
|
338
|
+
let argCount = -1;
|
|
339
|
+
if (!varargs) {
|
|
340
|
+
argCount = Math.max(getLength(step), inverse ? getLength(inverse) : 0);
|
|
341
|
+
if (argCount > 0) argCount -= 1;
|
|
342
|
+
if (argCount > 100) throw new RangeError("User-defined functions cannot have more than 100 arguments");
|
|
343
|
+
}
|
|
344
|
+
this[cppdb].aggregate(start, step, inverse, result, name, argCount, safeIntegers, deterministic, directOnly);
|
|
345
|
+
return this;
|
|
346
|
+
};
|
|
347
|
+
var getFunctionOption = (options, key, required) => {
|
|
348
|
+
const value = key in options ? options[key] : null;
|
|
349
|
+
if (typeof value === "function") return value;
|
|
350
|
+
if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`);
|
|
351
|
+
if (required) throw new TypeError(`Missing required option "${key}"`);
|
|
352
|
+
return null;
|
|
353
|
+
};
|
|
354
|
+
var getLength = ({ length }) => {
|
|
355
|
+
if (Number.isInteger(length) && length >= 0) return length;
|
|
356
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/table.js
|
|
362
|
+
var require_table = __commonJS({
|
|
363
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/table.js"(exports, module) {
|
|
364
|
+
"use strict";
|
|
365
|
+
var { cppdb } = require_util();
|
|
366
|
+
module.exports = function defineTable(name, factory) {
|
|
367
|
+
if (typeof name !== "string") throw new TypeError("Expected first argument to be a string");
|
|
368
|
+
if (!name) throw new TypeError("Virtual table module name cannot be an empty string");
|
|
369
|
+
let eponymous = false;
|
|
370
|
+
if (typeof factory === "object" && factory !== null) {
|
|
371
|
+
eponymous = true;
|
|
372
|
+
factory = defer(parseTableDefinition(factory, "used", name));
|
|
373
|
+
} else {
|
|
374
|
+
if (typeof factory !== "function") throw new TypeError("Expected second argument to be a function or a table definition object");
|
|
375
|
+
factory = wrapFactory(factory);
|
|
376
|
+
}
|
|
377
|
+
this[cppdb].table(factory, name, eponymous);
|
|
378
|
+
return this;
|
|
379
|
+
};
|
|
380
|
+
function wrapFactory(factory) {
|
|
381
|
+
return function virtualTableFactory(moduleName, databaseName, tableName, ...args) {
|
|
382
|
+
const thisObject = {
|
|
383
|
+
module: moduleName,
|
|
384
|
+
database: databaseName,
|
|
385
|
+
table: tableName
|
|
386
|
+
};
|
|
387
|
+
const def = apply.call(factory, thisObject, args);
|
|
388
|
+
if (typeof def !== "object" || def === null) {
|
|
389
|
+
throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`);
|
|
390
|
+
}
|
|
391
|
+
return parseTableDefinition(def, "returned", moduleName);
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function parseTableDefinition(def, verb, moduleName) {
|
|
395
|
+
if (!hasOwnProperty.call(def, "rows")) {
|
|
396
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "rows" property`);
|
|
397
|
+
}
|
|
398
|
+
if (!hasOwnProperty.call(def, "columns")) {
|
|
399
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition without a "columns" property`);
|
|
400
|
+
}
|
|
401
|
+
const rows = def.rows;
|
|
402
|
+
if (typeof rows !== "function" || Object.getPrototypeOf(rows) !== GeneratorFunctionPrototype) {
|
|
403
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "rows" property (should be a generator function)`);
|
|
404
|
+
}
|
|
405
|
+
let columns = def.columns;
|
|
406
|
+
if (!Array.isArray(columns) || !isStringArray(columns = [...columns])) {
|
|
407
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "columns" property (should be an array of strings)`);
|
|
408
|
+
}
|
|
409
|
+
if (columns.length !== new Set(columns).size) {
|
|
410
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate column names`);
|
|
411
|
+
}
|
|
412
|
+
if (!columns.length) {
|
|
413
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with zero columns`);
|
|
414
|
+
}
|
|
415
|
+
let parameters;
|
|
416
|
+
if (hasOwnProperty.call(def, "parameters")) {
|
|
417
|
+
parameters = def.parameters;
|
|
418
|
+
if (!Array.isArray(parameters) || !isStringArray(parameters = [...parameters])) {
|
|
419
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "parameters" property (should be an array of strings)`);
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
parameters = inferParameters(rows);
|
|
423
|
+
}
|
|
424
|
+
if (parameters.length !== new Set(parameters).size) {
|
|
425
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with duplicate parameter names`);
|
|
426
|
+
}
|
|
427
|
+
if (parameters.length > 32) {
|
|
428
|
+
throw new RangeError(`Virtual table module "${moduleName}" ${verb} a table definition with more than the maximum number of 32 parameters`);
|
|
429
|
+
}
|
|
430
|
+
for (const parameter of parameters) {
|
|
431
|
+
if (columns.includes(parameter)) {
|
|
432
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with column "${parameter}" which was ambiguously defined as both a column and parameter`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
let safeIntegers = 2;
|
|
436
|
+
if (hasOwnProperty.call(def, "safeIntegers")) {
|
|
437
|
+
const bool = def.safeIntegers;
|
|
438
|
+
if (typeof bool !== "boolean") {
|
|
439
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "safeIntegers" property (should be a boolean)`);
|
|
440
|
+
}
|
|
441
|
+
safeIntegers = +bool;
|
|
442
|
+
}
|
|
443
|
+
let directOnly = false;
|
|
444
|
+
if (hasOwnProperty.call(def, "directOnly")) {
|
|
445
|
+
directOnly = def.directOnly;
|
|
446
|
+
if (typeof directOnly !== "boolean") {
|
|
447
|
+
throw new TypeError(`Virtual table module "${moduleName}" ${verb} a table definition with an invalid "directOnly" property (should be a boolean)`);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const columnDefinitions = [
|
|
451
|
+
...parameters.map(identifier).map((str) => `${str} HIDDEN`),
|
|
452
|
+
...columns.map(identifier)
|
|
453
|
+
];
|
|
454
|
+
return [
|
|
455
|
+
`CREATE TABLE x(${columnDefinitions.join(", ")});`,
|
|
456
|
+
wrapGenerator(rows, new Map(columns.map((x, i) => [x, parameters.length + i])), moduleName),
|
|
457
|
+
parameters,
|
|
458
|
+
safeIntegers,
|
|
459
|
+
directOnly
|
|
460
|
+
];
|
|
461
|
+
}
|
|
462
|
+
function wrapGenerator(generator, columnMap, moduleName) {
|
|
463
|
+
return function* virtualTable(...args) {
|
|
464
|
+
const output = args.map((x) => Buffer.isBuffer(x) ? Buffer.from(x) : x);
|
|
465
|
+
for (let i = 0; i < columnMap.size; ++i) {
|
|
466
|
+
output.push(null);
|
|
467
|
+
}
|
|
468
|
+
for (const row of generator(...args)) {
|
|
469
|
+
if (Array.isArray(row)) {
|
|
470
|
+
extractRowArray(row, output, columnMap.size, moduleName);
|
|
471
|
+
yield output;
|
|
472
|
+
} else if (typeof row === "object" && row !== null) {
|
|
473
|
+
extractRowObject(row, output, columnMap, moduleName);
|
|
474
|
+
yield output;
|
|
475
|
+
} else {
|
|
476
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded something that isn't a valid row object`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function extractRowArray(row, output, columnCount, moduleName) {
|
|
482
|
+
if (row.length !== columnCount) {
|
|
483
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an incorrect number of columns`);
|
|
484
|
+
}
|
|
485
|
+
const offset = output.length - columnCount;
|
|
486
|
+
for (let i = 0; i < columnCount; ++i) {
|
|
487
|
+
output[i + offset] = row[i];
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function extractRowObject(row, output, columnMap, moduleName) {
|
|
491
|
+
let count = 0;
|
|
492
|
+
for (const key of Object.keys(row)) {
|
|
493
|
+
const index = columnMap.get(key);
|
|
494
|
+
if (index === void 0) {
|
|
495
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with an undeclared column "${key}"`);
|
|
496
|
+
}
|
|
497
|
+
output[index] = row[key];
|
|
498
|
+
count += 1;
|
|
499
|
+
}
|
|
500
|
+
if (count !== columnMap.size) {
|
|
501
|
+
throw new TypeError(`Virtual table module "${moduleName}" yielded a row with missing columns`);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function inferParameters({ length }) {
|
|
505
|
+
if (!Number.isInteger(length) || length < 0) {
|
|
506
|
+
throw new TypeError("Expected function.length to be a positive integer");
|
|
507
|
+
}
|
|
508
|
+
const params = [];
|
|
509
|
+
for (let i = 0; i < length; ++i) {
|
|
510
|
+
params.push(`$${i + 1}`);
|
|
511
|
+
}
|
|
512
|
+
return params;
|
|
513
|
+
}
|
|
514
|
+
var { hasOwnProperty } = Object.prototype;
|
|
515
|
+
var { apply } = Function.prototype;
|
|
516
|
+
var GeneratorFunctionPrototype = Object.getPrototypeOf(function* () {
|
|
517
|
+
});
|
|
518
|
+
var identifier = (str) => `"${str.replace(/"/g, '""')}"`;
|
|
519
|
+
var defer = (x) => () => x;
|
|
520
|
+
var isStringArray = (arr) => {
|
|
521
|
+
for (let i = 0; i < arr.length; ++i) {
|
|
522
|
+
if (typeof arr[i] !== "string") return false;
|
|
523
|
+
}
|
|
524
|
+
return true;
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/inspect.js
|
|
530
|
+
var require_inspect = __commonJS({
|
|
531
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/methods/inspect.js"(exports, module) {
|
|
532
|
+
"use strict";
|
|
533
|
+
var DatabaseInspection = function Database() {
|
|
534
|
+
};
|
|
535
|
+
module.exports = function inspect(depth, opts) {
|
|
536
|
+
return Object.assign(new DatabaseInspection(), this);
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/database.js
|
|
542
|
+
var require_database = __commonJS({
|
|
543
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/database.js"(exports, module) {
|
|
544
|
+
"use strict";
|
|
545
|
+
var fs = __require("fs");
|
|
546
|
+
var path = __require("path");
|
|
547
|
+
var util = require_util();
|
|
548
|
+
var SqliteError = require_sqlite_error();
|
|
549
|
+
module.exports = function createDatabase(getAddon, allowNativeBinding) {
|
|
550
|
+
function Database(filenameGiven, options) {
|
|
551
|
+
if (new.target == null) {
|
|
552
|
+
return new Database(filenameGiven, options);
|
|
553
|
+
}
|
|
554
|
+
let buffer;
|
|
555
|
+
if (Buffer.isBuffer(filenameGiven)) {
|
|
556
|
+
buffer = filenameGiven;
|
|
557
|
+
filenameGiven = ":memory:";
|
|
558
|
+
}
|
|
559
|
+
if (filenameGiven == null) filenameGiven = "";
|
|
560
|
+
if (options == null) options = {};
|
|
561
|
+
if (typeof filenameGiven !== "string") throw new TypeError("Expected first argument to be a string");
|
|
562
|
+
if (typeof options !== "object") throw new TypeError("Expected second argument to be an options object");
|
|
563
|
+
if ("readOnly" in options) throw new TypeError('Misspelled option "readOnly" should be "readonly"');
|
|
564
|
+
if ("memory" in options) throw new TypeError('Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)');
|
|
565
|
+
const filename = filenameGiven.trim();
|
|
566
|
+
const anonymous = filename === "" || filename === ":memory:";
|
|
567
|
+
const readonly = util.getBooleanOption(options, "readonly");
|
|
568
|
+
const fileMustExist = util.getBooleanOption(options, "fileMustExist");
|
|
569
|
+
const timeout = "timeout" in options ? options.timeout : 5e3;
|
|
570
|
+
const verbose = "verbose" in options ? options.verbose : null;
|
|
571
|
+
const nativeBinding = "nativeBinding" in options ? options.nativeBinding : null;
|
|
572
|
+
if (readonly && anonymous && !buffer) throw new TypeError("In-memory/temporary databases cannot be readonly");
|
|
573
|
+
if (!Number.isInteger(timeout) || timeout < 0) throw new TypeError('Expected the "timeout" option to be a positive integer');
|
|
574
|
+
if (timeout > 2147483647) throw new RangeError('Option "timeout" cannot be greater than 2147483647');
|
|
575
|
+
if (verbose != null && typeof verbose !== "function") throw new TypeError('Expected the "verbose" option to be a function');
|
|
576
|
+
if (!allowNativeBinding && "nativeBinding" in options) throw new TypeError('The "nativeBinding" option is only supported by the default better-sqlite3 entrypoint');
|
|
577
|
+
if (allowNativeBinding && nativeBinding != null && typeof nativeBinding !== "string" && typeof nativeBinding !== "object") throw new TypeError('Expected the "nativeBinding" option to be a string or addon object');
|
|
578
|
+
const addon = getAddon(nativeBinding);
|
|
579
|
+
if (!addon.isInitialized) {
|
|
580
|
+
addon.initialize(SqliteError, arrayFactory, arrayAppender, rowFactory, recordFactory);
|
|
581
|
+
addon.isInitialized = true;
|
|
582
|
+
}
|
|
583
|
+
if (!anonymous && !filename.startsWith("file:") && !fs.existsSync(path.dirname(filename))) {
|
|
584
|
+
throw new TypeError("Cannot open database because the directory does not exist");
|
|
585
|
+
}
|
|
586
|
+
Object.defineProperties(this, {
|
|
587
|
+
[util.cppdb]: { value: new addon.Database(filename, filenameGiven, anonymous, readonly, fileMustExist, timeout, verbose || null, buffer || null) },
|
|
588
|
+
...wrappers.getters
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
const wrappers = require_wrappers();
|
|
592
|
+
Database.prototype.prepare = wrappers.prepare;
|
|
593
|
+
Database.prototype.transaction = require_transaction();
|
|
594
|
+
Database.prototype.pragma = require_pragma();
|
|
595
|
+
Database.prototype.explain = require_explain();
|
|
596
|
+
Database.prototype.backup = require_backup();
|
|
597
|
+
Database.prototype.serialize = require_serialize();
|
|
598
|
+
Database.prototype.function = require_function();
|
|
599
|
+
Database.prototype.aggregate = require_aggregate();
|
|
600
|
+
Database.prototype.table = require_table();
|
|
601
|
+
Database.prototype.loadExtension = wrappers.loadExtension;
|
|
602
|
+
Database.prototype.exec = wrappers.exec;
|
|
603
|
+
Database.prototype.close = wrappers.close;
|
|
604
|
+
Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
|
|
605
|
+
Database.prototype.unsafeMode = wrappers.unsafeMode;
|
|
606
|
+
Database.prototype[util.inspect] = require_inspect();
|
|
607
|
+
return Database;
|
|
608
|
+
};
|
|
609
|
+
function arrayFactory(...values) {
|
|
610
|
+
return values;
|
|
611
|
+
}
|
|
612
|
+
function arrayAppender(array, ...values) {
|
|
613
|
+
const offset = array.length;
|
|
614
|
+
for (let i = 0; i < values.length; ++i) {
|
|
615
|
+
array[offset + i] = values[i];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
function rowFactory(...keys) {
|
|
619
|
+
if (!keys.includes("__proto__")) {
|
|
620
|
+
const parameters = keys.map((_, index) => `v${index}`).join(",");
|
|
621
|
+
const properties = keys.map((key, index) => `${JSON.stringify(key)}:v${index}`).join(",");
|
|
622
|
+
return Function(`return (${parameters}) => ({${properties}})`)();
|
|
623
|
+
}
|
|
624
|
+
return (...values) => {
|
|
625
|
+
const row = {};
|
|
626
|
+
for (let i = 0; i < keys.length; ++i) row[keys[i]] = values[i];
|
|
627
|
+
return row;
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
function recordFactory(value) {
|
|
631
|
+
return { value, done: false };
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/binding.js
|
|
637
|
+
var require_binding = __commonJS({
|
|
638
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/binding.js"(exports, module) {
|
|
639
|
+
"use strict";
|
|
640
|
+
var fs = __require("fs");
|
|
641
|
+
var path = __require("path");
|
|
642
|
+
var PREBUILD_PLATFORMS = ["linux", "darwin", "win32"];
|
|
643
|
+
var PREBUILD_ARCHS = ["x64", "arm64"];
|
|
644
|
+
var DEFAULT_ADDON;
|
|
645
|
+
function getBinding(nativeBinding) {
|
|
646
|
+
if (typeof nativeBinding === "string") {
|
|
647
|
+
const requireFunc = typeof __non_webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
648
|
+
return requireFunc(path.resolve(nativeBinding).replace(/(\.node)?$/, ".node"));
|
|
649
|
+
}
|
|
650
|
+
if (typeof nativeBinding === "object" && nativeBinding !== null) {
|
|
651
|
+
return nativeBinding;
|
|
652
|
+
}
|
|
653
|
+
if (DEFAULT_ADDON) {
|
|
654
|
+
return DEFAULT_ADDON;
|
|
655
|
+
}
|
|
656
|
+
let filename = getPrebuildPath();
|
|
657
|
+
if (filename) {
|
|
658
|
+
return DEFAULT_ADDON = __require(filename);
|
|
659
|
+
}
|
|
660
|
+
filename = path.join(__dirname, "..", "build", "Debug", "better_sqlite3.node");
|
|
661
|
+
if (!fs.existsSync(filename)) {
|
|
662
|
+
filename = path.join(__dirname, "..", "build", "Release", "better_sqlite3.node");
|
|
663
|
+
}
|
|
664
|
+
return DEFAULT_ADDON = __require(filename);
|
|
665
|
+
}
|
|
666
|
+
function getPrebuildPath() {
|
|
667
|
+
if (PREBUILD_PLATFORMS.includes(process.platform) && PREBUILD_ARCHS.includes(process.arch)) {
|
|
668
|
+
const target = `${isLinuxMusl() ? "linuxmusl" : process.platform}-${process.arch}`;
|
|
669
|
+
const filename = path.join(__dirname, "..", "prebuilds", `${target}.node`);
|
|
670
|
+
if (fs.existsSync(filename)) {
|
|
671
|
+
return filename;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return null;
|
|
675
|
+
}
|
|
676
|
+
function isLinuxMusl() {
|
|
677
|
+
return process.platform === "linux" && !process.report.getReport().header.glibcVersionRuntime;
|
|
678
|
+
}
|
|
679
|
+
exports.getBinding = getBinding;
|
|
680
|
+
exports.getPrebuildPath = getPrebuildPath;
|
|
681
|
+
if (__require.main === module) {
|
|
682
|
+
process.stdout.write(getPrebuildPath() ? "1" : "0");
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
// ../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/index.js
|
|
688
|
+
var require_lib = __commonJS({
|
|
689
|
+
"../../node_modules/.pnpm/better-sqlite3@13.0.3/node_modules/better-sqlite3/lib/index.js"(exports, module) {
|
|
690
|
+
module.exports = require_database()(require_binding().getBinding, true);
|
|
691
|
+
module.exports.SqliteError = require_sqlite_error();
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
export default require_lib();
|