logixia 1.0.0 → 1.0.2

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.
@@ -0,0 +1,531 @@
1
+ const require_chunk = require('./chunk-BTgCAUrQ.js');
2
+
3
+ //#region node_modules/sqlite/build/utils/format-error.js
4
+ var require_format_error = /* @__PURE__ */ require_chunk.__commonJS({ "node_modules/sqlite/build/utils/format-error.js": ((exports) => {
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ function formatError(err) {
7
+ if (err instanceof Error) return err;
8
+ if (typeof err === "object") {
9
+ const newError = /* @__PURE__ */ new Error();
10
+ for (let prop in err) newError[prop] = err[prop];
11
+ if (err.message) newError.message = err.message;
12
+ return newError;
13
+ }
14
+ if (typeof err === "string") return new Error(err);
15
+ return new Error(err);
16
+ }
17
+ exports.formatError = formatError;
18
+ }) });
19
+
20
+ //#endregion
21
+ //#region node_modules/sqlite/build/Statement.js
22
+ var require_Statement = /* @__PURE__ */ require_chunk.__commonJS({ "node_modules/sqlite/build/Statement.js": ((exports) => {
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const format_error_1$1 = require_format_error();
25
+ /**
26
+ * Promisified wrapper for the sqlite3#Statement interface.
27
+ */
28
+ var Statement = class {
29
+ constructor(stmt) {
30
+ this.stmt = stmt;
31
+ }
32
+ /**
33
+ * Returns the underlying sqlite3 Statement instance
34
+ */
35
+ getStatementInstance() {
36
+ return this.stmt;
37
+ }
38
+ /**
39
+ * Binds parameters to the prepared statement.
40
+ *
41
+ * Binding parameters with this function completely resets the statement object and row cursor
42
+ * and removes all previously bound parameters, if any.
43
+ */
44
+ bind(...params) {
45
+ return new Promise((resolve, reject) => {
46
+ this.stmt.bind(...params, (err) => {
47
+ if (err) return reject((0, format_error_1$1.formatError)(err));
48
+ resolve();
49
+ });
50
+ });
51
+ }
52
+ /**
53
+ * Resets the row cursor of the statement and preserves the parameter bindings.
54
+ * Use this function to re-execute the same query with the same bindings.
55
+ */
56
+ reset() {
57
+ return new Promise((resolve) => {
58
+ this.stmt.reset(() => {
59
+ resolve();
60
+ });
61
+ });
62
+ }
63
+ /**
64
+ * Finalizes the statement. This is typically optional, but if you experience long delays before
65
+ * the next query is executed, explicitly finalizing your statement might be necessary.
66
+ * This might be the case when you run an exclusive query (see section Control Flow).
67
+ * After the statement is finalized, all further function calls on that statement object
68
+ * will throw errors.
69
+ */
70
+ finalize() {
71
+ return new Promise((resolve, reject) => {
72
+ this.stmt.finalize((err) => {
73
+ if (err) return reject((0, format_error_1$1.formatError)(err));
74
+ resolve();
75
+ });
76
+ });
77
+ }
78
+ /**
79
+ * Binds parameters and executes the statement.
80
+ *
81
+ * If you specify bind parameters, they will be bound to the statement before it is executed.
82
+ * Note that the bindings and the row cursor are reset when you specify even a single bind parameter.
83
+ *
84
+ * The execution behavior is identical to the Database#run method with the difference that the
85
+ * statement will not be finalized after it is run. This means you can run it multiple times.
86
+ *
87
+ * @param {any} [params, ...] When the SQL statement contains placeholders, you
88
+ * can pass them in here. They will be bound to the statement before it is
89
+ * executed. There are three ways of passing bind parameters: directly in
90
+ * the function's arguments, as an array, and as an object for named
91
+ * parameters. This automatically sanitizes inputs.
92
+ */
93
+ run(...params) {
94
+ return new Promise((resolve, reject) => {
95
+ const stmt = this;
96
+ this.stmt.run(...params, function(err) {
97
+ if (err) return reject((0, format_error_1$1.formatError)(err));
98
+ resolve({
99
+ stmt,
100
+ lastID: this.lastID,
101
+ changes: this.changes
102
+ });
103
+ });
104
+ });
105
+ }
106
+ /**
107
+ * Binds parameters, executes the statement and retrieves the first result row.
108
+ * The parameters are the same as the Statement#run function, with the following differences:
109
+ *
110
+ * Using this method can leave the database locked, as the database awaits further
111
+ * calls to Statement#get to retrieve subsequent rows. To inform the database that you
112
+ * are finished retrieving rows, you should either finalize (with Statement#finalize)
113
+ * or reset (with Statement#reset) the statement.
114
+ *
115
+ * @param {any} [params, ...] When the SQL statement contains placeholders, you
116
+ * can pass them in here. They will be bound to the statement before it is
117
+ * executed. There are three ways of passing bind parameters: directly in
118
+ * the function's arguments, as an array, and as an object for named
119
+ * parameters. This automatically sanitizes inputs.
120
+ */
121
+ get(...params) {
122
+ return new Promise((resolve, reject) => {
123
+ this.stmt.get(...params, (err, row) => {
124
+ if (err) return reject((0, format_error_1$1.formatError)(err));
125
+ resolve(row);
126
+ });
127
+ });
128
+ }
129
+ /**
130
+ * Binds parameters, executes the statement and calls the callback with all result rows.
131
+ * The parameters are the same as the Statement#run function, with the following differences:
132
+ *
133
+ * If the result set is empty, it will resolve to an empty array, otherwise it contains an
134
+ * object for each result row which in turn contains the values of that row.
135
+ * Like with Statement#run, the statement will not be finalized after executing this function.
136
+ *
137
+ * @param {any} [params, ...] When the SQL statement contains placeholders, you
138
+ * can pass them in here. They will be bound to the statement before it is
139
+ * executed. There are three ways of passing bind parameters: directly in
140
+ * the function's arguments, as an array, and as an object for named
141
+ * parameters. This automatically sanitizes inputs.
142
+ *
143
+ * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseallsql-param--callback
144
+ */
145
+ all(...params) {
146
+ return new Promise((resolve, reject) => {
147
+ this.stmt.all(...params, (err, rows) => {
148
+ if (err) return reject((0, format_error_1$1.formatError)(err));
149
+ resolve(rows);
150
+ });
151
+ });
152
+ }
153
+ each(...params) {
154
+ return new Promise((resolve, reject) => {
155
+ const callback = params.pop();
156
+ if (!callback || typeof callback !== "function") throw new Error("sqlite: Last param of Statement#each() must be a callback function");
157
+ if (params.length > 0) {
158
+ const positional = params.pop();
159
+ if (typeof positional === "function") throw new Error("sqlite: Statement#each() should only have a single callback defined. See readme for usage.");
160
+ params.push(positional);
161
+ }
162
+ this.stmt.each(...params, (err, row) => {
163
+ if (err) return callback((0, format_error_1$1.formatError)(err), null);
164
+ callback(null, row);
165
+ }, (err, count) => {
166
+ if (err) return reject((0, format_error_1$1.formatError)(err));
167
+ resolve(count);
168
+ });
169
+ });
170
+ }
171
+ };
172
+ exports.Statement = Statement;
173
+ }) });
174
+
175
+ //#endregion
176
+ //#region node_modules/sqlite/build/utils/migrate.js
177
+ var require_migrate = /* @__PURE__ */ require_chunk.__commonJS({ "node_modules/sqlite/build/utils/migrate.js": ((exports) => {
178
+ Object.defineProperty(exports, "__esModule", { value: true });
179
+ const fs = require("fs");
180
+ const path = require("path");
181
+ async function readMigrations(migrationPath) {
182
+ const migrationsPath = migrationPath || path.join(process.cwd(), "migrations");
183
+ const location = path.resolve(migrationsPath);
184
+ const migrationFiles = await new Promise((resolve, reject) => {
185
+ fs.readdir(location, (err, files) => {
186
+ if (err) return reject(err);
187
+ resolve(files.map((x) => x.match(/^(\d+).(.*?)\.sql$/)).filter((x) => x !== null).map((x) => ({
188
+ id: Number(x[1]),
189
+ name: x[2],
190
+ filename: x[0]
191
+ })).sort((a, b) => Math.sign(a.id - b.id)));
192
+ });
193
+ });
194
+ if (!migrationFiles.length) throw new Error(`No migration files found in '${location}'.`);
195
+ return Promise.all(migrationFiles.map((migration) => new Promise((resolve, reject) => {
196
+ const filename = path.join(location, migration.filename);
197
+ fs.readFile(filename, "utf-8", (err, data) => {
198
+ if (err) return reject(err);
199
+ const [up, down] = data.split(/^--\s+?down\b/im);
200
+ const migrationData = migration;
201
+ migrationData.up = up.replace(/^-- .*?$/gm, "").trim();
202
+ migrationData.down = down ? down.trim() : "";
203
+ resolve(migrationData);
204
+ });
205
+ })));
206
+ }
207
+ exports.readMigrations = readMigrations;
208
+ /**
209
+ * Migrates database schema to the latest version
210
+ */
211
+ async function migrate(db, config = {}) {
212
+ config.force = config.force || false;
213
+ config.table = config.table || "migrations";
214
+ const { force, table } = config;
215
+ const migrations = config.migrations ? config.migrations : await readMigrations(config.migrationsPath);
216
+ await db.run(`CREATE TABLE IF NOT EXISTS "${table}" (
217
+ id INTEGER PRIMARY KEY,
218
+ name TEXT NOT NULL,
219
+ up TEXT NOT NULL,
220
+ down TEXT NOT NULL
221
+ )`);
222
+ let dbMigrations = await db.all(`SELECT id, name, up, down FROM "${table}" ORDER BY id ASC`);
223
+ const lastMigration = migrations[migrations.length - 1];
224
+ for (const migration of dbMigrations.slice().sort((a, b) => Math.sign(b.id - a.id))) if (!migrations.some((x) => x.id === migration.id) || force && migration.id === lastMigration.id) {
225
+ await db.run("BEGIN");
226
+ try {
227
+ await db.exec(migration.down);
228
+ await db.run(`DELETE FROM "${table}" WHERE id = ?`, migration.id);
229
+ await db.run("COMMIT");
230
+ dbMigrations = dbMigrations.filter((x) => x.id !== migration.id);
231
+ } catch (err) {
232
+ await db.run("ROLLBACK");
233
+ throw err;
234
+ }
235
+ } else break;
236
+ const lastMigrationId = dbMigrations.length ? dbMigrations[dbMigrations.length - 1].id : 0;
237
+ for (const migration of migrations) if (migration.id > lastMigrationId) {
238
+ await db.run("BEGIN");
239
+ try {
240
+ await db.exec(migration.up);
241
+ await db.run(`INSERT INTO "${table}" (id, name, up, down) VALUES (?, ?, ?, ?)`, migration.id, migration.name, migration.up, migration.down);
242
+ await db.run("COMMIT");
243
+ } catch (err) {
244
+ await db.run("ROLLBACK");
245
+ throw err;
246
+ }
247
+ }
248
+ }
249
+ exports.migrate = migrate;
250
+ }) });
251
+
252
+ //#endregion
253
+ //#region node_modules/sqlite/build/utils/strings.js
254
+ var require_strings = /* @__PURE__ */ require_chunk.__commonJS({ "node_modules/sqlite/build/utils/strings.js": ((exports) => {
255
+ Object.defineProperty(exports, "__esModule", { value: true });
256
+ /**
257
+ * Allows for using strings and `sql-template-strings`. Converts both to a
258
+ * format that's usable by the SQL methods
259
+ *
260
+ * @param sql A SQL string or `sql-template-strings` object
261
+ * @param params An array of parameters
262
+ */
263
+ function toSqlParams(sql, params = []) {
264
+ if (typeof sql === "string") return {
265
+ sql,
266
+ params
267
+ };
268
+ return {
269
+ sql: sql.sql,
270
+ params: sql.values
271
+ };
272
+ }
273
+ exports.toSqlParams = toSqlParams;
274
+ }) });
275
+
276
+ //#endregion
277
+ //#region node_modules/sqlite/build/Database.js
278
+ var require_Database = /* @__PURE__ */ require_chunk.__commonJS({ "node_modules/sqlite/build/Database.js": ((exports) => {
279
+ Object.defineProperty(exports, "__esModule", { value: true });
280
+ const Statement_1 = require_Statement();
281
+ const migrate_1 = require_migrate();
282
+ const strings_1 = require_strings();
283
+ const format_error_1 = require_format_error();
284
+ /**
285
+ * Promisified wrapper for the sqlite3#Database interface.
286
+ */
287
+ var Database$1 = class {
288
+ constructor(config) {
289
+ this.config = config;
290
+ this.db = null;
291
+ }
292
+ /**
293
+ * Event handler when verbose mode is enabled.
294
+ * @see https://github.com/mapbox/node-sqlite3/wiki/Debugging
295
+ */
296
+ on(event, listener) {
297
+ this.db.on(event, listener);
298
+ }
299
+ /**
300
+ * Returns the underlying sqlite3 Database instance
301
+ */
302
+ getDatabaseInstance() {
303
+ return this.db;
304
+ }
305
+ /**
306
+ * Opens the database
307
+ */
308
+ open() {
309
+ return new Promise((resolve, reject) => {
310
+ let { filename, mode, driver } = this.config;
311
+ if (filename === null || filename === void 0) throw new Error("sqlite: filename cannot be null / undefined");
312
+ if (!driver) throw new Error("sqlite: driver is not defined");
313
+ if (mode) this.db = new driver(filename, mode, (err) => {
314
+ if (err) return reject((0, format_error_1.formatError)(err));
315
+ resolve();
316
+ });
317
+ else this.db = new driver(filename, (err) => {
318
+ if (err) return reject((0, format_error_1.formatError)(err));
319
+ resolve();
320
+ });
321
+ });
322
+ }
323
+ /**
324
+ * Closes the database.
325
+ */
326
+ close() {
327
+ return new Promise((resolve, reject) => {
328
+ this.db.close((err) => {
329
+ if (err) return reject((0, format_error_1.formatError)(err));
330
+ resolve();
331
+ });
332
+ });
333
+ }
334
+ /**
335
+ * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseconfigureoption-value
336
+ */
337
+ configure(option, value) {
338
+ this.db.configure(option, value);
339
+ }
340
+ /**
341
+ * Runs the SQL query with the specified parameters. It does not retrieve any result data.
342
+ * The function returns the Database object for which it was called to allow for function chaining.
343
+ *
344
+ * @param {string} sql The SQL query to run.
345
+ *
346
+ * @param {any} [params, ...] When the SQL statement contains placeholders, you
347
+ * can pass them in here. They will be bound to the statement before it is
348
+ * executed. There are three ways of passing bind parameters: directly in
349
+ * the function's arguments, as an array, and as an object for named
350
+ * parameters. This automatically sanitizes inputs.
351
+ *
352
+ * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaserunsql-param--callback
353
+ */
354
+ run(sql, ...params) {
355
+ return new Promise((resolve, reject) => {
356
+ const sqlObj = (0, strings_1.toSqlParams)(sql, params);
357
+ this.db.run(sqlObj.sql, ...sqlObj.params, function(err) {
358
+ if (err) return reject((0, format_error_1.formatError)(err));
359
+ resolve({
360
+ stmt: new Statement_1.Statement(this.stmt),
361
+ lastID: this.lastID,
362
+ changes: this.changes
363
+ });
364
+ });
365
+ });
366
+ }
367
+ /**
368
+ * Runs the SQL query with the specified parameters and resolves with
369
+ * with the first result row afterwards. If the result set is empty, returns undefined.
370
+ *
371
+ * The property names correspond to the column names of the result set.
372
+ * It is impossible to access them by column index; the only supported way is by column name.
373
+ *
374
+ * @param {string} sql The SQL query to run.
375
+ *
376
+ * @param {any} [params, ...] When the SQL statement contains placeholders, you
377
+ * can pass them in here. They will be bound to the statement before it is
378
+ * executed. There are three ways of passing bind parameters: directly in
379
+ * the function's arguments, as an array, and as an object for named
380
+ * parameters. This automatically sanitizes inputs.
381
+ *
382
+ * @see https://github.com/mapbox/node-sqlite3/wiki/API#databasegetsql-param--callback
383
+ */
384
+ get(sql, ...params) {
385
+ return new Promise((resolve, reject) => {
386
+ const sqlObj = (0, strings_1.toSqlParams)(sql, params);
387
+ this.db.get(sqlObj.sql, ...sqlObj.params, (err, row) => {
388
+ if (err) return reject((0, format_error_1.formatError)(err));
389
+ resolve(row);
390
+ });
391
+ });
392
+ }
393
+ each(sql, ...params) {
394
+ return new Promise((resolve, reject) => {
395
+ const callback = params.pop();
396
+ if (!callback || typeof callback !== "function") throw new Error("sqlite: Last param of Database#each() must be a callback function");
397
+ if (params.length > 0) {
398
+ const positional = params.pop();
399
+ if (typeof positional === "function") throw new Error("sqlite: Database#each() should only have a single callback defined. See readme for usage.");
400
+ params.push(positional);
401
+ }
402
+ const sqlObj = (0, strings_1.toSqlParams)(sql, params);
403
+ this.db.each(sqlObj.sql, ...sqlObj.params, (err, row) => {
404
+ if (err) return callback((0, format_error_1.formatError)(err), null);
405
+ callback(null, row);
406
+ }, (err, count) => {
407
+ if (err) return reject((0, format_error_1.formatError)(err));
408
+ resolve(count);
409
+ });
410
+ });
411
+ }
412
+ /**
413
+ * Runs the SQL query with the specified parameters. The parameters are the same as the
414
+ * Database#run function, with the following differences:
415
+ *
416
+ * If the result set is empty, it will be an empty array, otherwise it will
417
+ * have an object for each result row which
418
+ * in turn contains the values of that row, like the Database#get function.
419
+ *
420
+ * Note that it first retrieves all result rows and stores them in memory.
421
+ * For queries that have potentially large result sets, use the Database#each
422
+ * function to retrieve all rows or Database#prepare followed by multiple
423
+ * Statement#get calls to retrieve a previously unknown amount of rows.
424
+ *
425
+ * @param {string} sql The SQL query to run.
426
+ *
427
+ * @param {any} [params, ...] When the SQL statement contains placeholders, you
428
+ * can pass them in here. They will be bound to the statement before it is
429
+ * executed. There are three ways of passing bind parameters: directly in
430
+ * the function's arguments, as an array, and as an object for named
431
+ * parameters. This automatically sanitizes inputs.
432
+ *
433
+ * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseallsql-param--callback
434
+ */
435
+ all(sql, ...params) {
436
+ return new Promise((resolve, reject) => {
437
+ const sqlObj = (0, strings_1.toSqlParams)(sql, params);
438
+ this.db.all(sqlObj.sql, ...sqlObj.params, (err, rows) => {
439
+ if (err) return reject((0, format_error_1.formatError)(err));
440
+ resolve(rows);
441
+ });
442
+ });
443
+ }
444
+ /**
445
+ * Runs all SQL queries in the supplied string. No result rows are retrieved. If a query fails,
446
+ * no subsequent statements will be executed (wrap it in a transaction if you want all
447
+ * or none to be executed).
448
+ *
449
+ * Note: This function will only execute statements up to the first NULL byte.
450
+ * Comments are not allowed and will lead to runtime errors.
451
+ *
452
+ * @param {string} sql The SQL query to run.
453
+ * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseexecsql-callback
454
+ */
455
+ exec(sql) {
456
+ return new Promise((resolve, reject) => {
457
+ const sqlObj = (0, strings_1.toSqlParams)(sql);
458
+ this.db.exec(sqlObj.sql, (err) => {
459
+ if (err) return reject((0, format_error_1.formatError)(err));
460
+ resolve();
461
+ });
462
+ });
463
+ }
464
+ /**
465
+ * Prepares the SQL statement and optionally binds the specified parameters.
466
+ * When bind parameters are supplied, they are bound to the prepared statement.
467
+ *
468
+ * @param {string} sql The SQL query to run.
469
+ * @param {any} [params, ...] When the SQL statement contains placeholders, you
470
+ * can pass them in here. They will be bound to the statement before it is
471
+ * executed. There are three ways of passing bind parameters: directly in
472
+ * the function's arguments, as an array, and as an object for named
473
+ * parameters. This automatically sanitizes inputs.
474
+ * @returns Promise<Statement> Statement object
475
+ */
476
+ prepare(sql, ...params) {
477
+ return new Promise((resolve, reject) => {
478
+ const sqlObj = (0, strings_1.toSqlParams)(sql, params);
479
+ const stmt = this.db.prepare(sqlObj.sql, ...sqlObj.params, (err) => {
480
+ if (err) return reject(err);
481
+ resolve(new Statement_1.Statement(stmt));
482
+ });
483
+ });
484
+ }
485
+ /**
486
+ * Loads a compiled SQLite extension into the database connection object.
487
+ *
488
+ * @param {string} path Filename of the extension to load
489
+ */
490
+ loadExtension(path$1) {
491
+ return new Promise((resolve, reject) => {
492
+ this.db.loadExtension(path$1, (err) => {
493
+ if (err) return reject((0, format_error_1.formatError)(err));
494
+ resolve();
495
+ });
496
+ });
497
+ }
498
+ /**
499
+ * Performs a database migration.
500
+ */
501
+ async migrate(config) {
502
+ await (0, migrate_1.migrate)(this, config);
503
+ }
504
+ /**
505
+ * The methods underneath requires creative work to implement. PRs / proposals accepted!
506
+ */
507
+ serialize() {
508
+ throw new Error("sqlite: Currently not implemented. Use getDatabaseInstance().serialize() instead.");
509
+ }
510
+ parallelize() {
511
+ throw new Error("sqlite: Currently not implemented. Use getDatabaseInstance().parallelize() instead.");
512
+ }
513
+ };
514
+ exports.Database = Database$1;
515
+ }) });
516
+
517
+ //#endregion
518
+ //#region node_modules/sqlite/build/index.mjs
519
+ var import_Database = /* @__PURE__ */ require_chunk.__toESM(require_Database(), 1);
520
+ /**
521
+ * Opens a database for manipulation. Most users will call this to get started.
522
+ */
523
+ async function open(config) {
524
+ const db = new import_Database.Database(config);
525
+ await db.open();
526
+ return db;
527
+ }
528
+
529
+ //#endregion
530
+ exports.open = open;
531
+ //# sourceMappingURL=build-C67p8wVr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-C67p8wVr.js","names":["format_error_1","Database","path"],"sources":["../node_modules/sqlite/build/utils/format-error.js","../node_modules/sqlite/build/Statement.js","../node_modules/sqlite/build/utils/migrate.js","../node_modules/sqlite/build/utils/strings.js","../node_modules/sqlite/build/Database.js","../node_modules/sqlite/build/index.mjs"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.formatError = void 0;\nfunction formatError(err) {\n if (err instanceof Error) {\n return err;\n }\n if (typeof err === 'object') {\n const newError = new Error();\n for (let prop in err) {\n newError[prop] = err[prop];\n }\n // message isn't part of the enumerable set\n if (err.message) {\n newError.message = err.message;\n }\n return newError;\n }\n if (typeof err === 'string') {\n return new Error(err);\n }\n return new Error(err);\n}\nexports.formatError = formatError;\n//# sourceMappingURL=format-error.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Statement = void 0;\nconst format_error_1 = require(\"./utils/format-error\");\n/**\n * Promisified wrapper for the sqlite3#Statement interface.\n */\nclass Statement {\n constructor(stmt) {\n this.stmt = stmt;\n }\n /**\n * Returns the underlying sqlite3 Statement instance\n */\n getStatementInstance() {\n return this.stmt;\n }\n /**\n * Binds parameters to the prepared statement.\n *\n * Binding parameters with this function completely resets the statement object and row cursor\n * and removes all previously bound parameters, if any.\n */\n bind(...params) {\n return new Promise((resolve, reject) => {\n this.stmt.bind(...params, err => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve();\n });\n });\n }\n /**\n * Resets the row cursor of the statement and preserves the parameter bindings.\n * Use this function to re-execute the same query with the same bindings.\n */\n reset() {\n return new Promise(resolve => {\n this.stmt.reset(() => {\n resolve();\n });\n });\n }\n /**\n * Finalizes the statement. This is typically optional, but if you experience long delays before\n * the next query is executed, explicitly finalizing your statement might be necessary.\n * This might be the case when you run an exclusive query (see section Control Flow).\n * After the statement is finalized, all further function calls on that statement object\n * will throw errors.\n */\n finalize() {\n return new Promise((resolve, reject) => {\n this.stmt.finalize(err => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve();\n });\n });\n }\n /**\n * Binds parameters and executes the statement.\n *\n * If you specify bind parameters, they will be bound to the statement before it is executed.\n * Note that the bindings and the row cursor are reset when you specify even a single bind parameter.\n *\n * The execution behavior is identical to the Database#run method with the difference that the\n * statement will not be finalized after it is run. This means you can run it multiple times.\n *\n * @param {any} [params, ...] When the SQL statement contains placeholders, you\n * can pass them in here. They will be bound to the statement before it is\n * executed. There are three ways of passing bind parameters: directly in\n * the function's arguments, as an array, and as an object for named\n * parameters. This automatically sanitizes inputs.\n */\n run(...params) {\n return new Promise((resolve, reject) => {\n const stmt = this;\n this.stmt.run(...params, function (err) {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve({\n stmt,\n lastID: this.lastID,\n changes: this.changes\n });\n });\n });\n }\n /**\n * Binds parameters, executes the statement and retrieves the first result row.\n * The parameters are the same as the Statement#run function, with the following differences:\n *\n * Using this method can leave the database locked, as the database awaits further\n * calls to Statement#get to retrieve subsequent rows. To inform the database that you\n * are finished retrieving rows, you should either finalize (with Statement#finalize)\n * or reset (with Statement#reset) the statement.\n *\n * @param {any} [params, ...] When the SQL statement contains placeholders, you\n * can pass them in here. They will be bound to the statement before it is\n * executed. There are three ways of passing bind parameters: directly in\n * the function's arguments, as an array, and as an object for named\n * parameters. This automatically sanitizes inputs.\n */\n get(...params) {\n return new Promise((resolve, reject) => {\n this.stmt.get(...params, (err, row) => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve(row);\n });\n });\n }\n /**\n * Binds parameters, executes the statement and calls the callback with all result rows.\n * The parameters are the same as the Statement#run function, with the following differences:\n *\n * If the result set is empty, it will resolve to an empty array, otherwise it contains an\n * object for each result row which in turn contains the values of that row.\n * Like with Statement#run, the statement will not be finalized after executing this function.\n *\n * @param {any} [params, ...] When the SQL statement contains placeholders, you\n * can pass them in here. They will be bound to the statement before it is\n * executed. There are three ways of passing bind parameters: directly in\n * the function's arguments, as an array, and as an object for named\n * parameters. This automatically sanitizes inputs.\n *\n * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseallsql-param--callback\n */\n all(...params) {\n return new Promise((resolve, reject) => {\n this.stmt.all(...params, (err, rows) => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve(rows);\n });\n });\n }\n each(...params) {\n return new Promise((resolve, reject) => {\n const callback = params.pop();\n if (!callback || typeof callback !== 'function') {\n throw new Error('sqlite: Last param of Statement#each() must be a callback function');\n }\n if (params.length > 0) {\n const positional = params.pop();\n if (typeof positional === 'function') {\n throw new Error('sqlite: Statement#each() should only have a single callback defined. See readme for usage.');\n }\n params.push(positional);\n }\n this.stmt.each(...params, (err, row) => {\n if (err) {\n return callback((0, format_error_1.formatError)(err), null);\n }\n callback(null, row);\n }, (err, count) => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve(count);\n });\n });\n }\n}\nexports.Statement = Statement;\n//# sourceMappingURL=Statement.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.migrate = exports.readMigrations = void 0;\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nasync function readMigrations(migrationPath) {\n const migrationsPath = migrationPath || path.join(process.cwd(), 'migrations');\n const location = path.resolve(migrationsPath);\n // Get the list of migration files, for example:\n // { id: 1, name: 'initial', filename: '001-initial.sql' }\n // { id: 2, name: 'feature', filename: '002-feature.sql' }\n const migrationFiles = await new Promise((resolve, reject) => {\n fs.readdir(location, (err, files) => {\n if (err) {\n return reject(err);\n }\n resolve(files\n .map(x => x.match(/^(\\d+).(.*?)\\.sql$/))\n .filter(x => x !== null)\n .map(x => ({ id: Number(x[1]), name: x[2], filename: x[0] }))\n .sort((a, b) => Math.sign(a.id - b.id)));\n });\n });\n if (!migrationFiles.length) {\n throw new Error(`No migration files found in '${location}'.`);\n }\n // Get the list of migrations, for example:\n // { id: 1, name: 'initial', filename: '001-initial.sql', up: ..., down: ... }\n // { id: 2, name: 'feature', filename: '002-feature.sql', up: ..., down: ... }\n return Promise.all(migrationFiles.map(migration => new Promise((resolve, reject) => {\n const filename = path.join(location, migration.filename);\n fs.readFile(filename, 'utf-8', (err, data) => {\n if (err) {\n return reject(err);\n }\n const [up, down] = data.split(/^--\\s+?down\\b/im);\n const migrationData = migration;\n migrationData.up = up.replace(/^-- .*?$/gm, '').trim(); // Remove comments\n migrationData.down = down ? down.trim() : ''; // and trim whitespaces\n resolve(migrationData);\n });\n })));\n}\nexports.readMigrations = readMigrations;\n/**\n * Migrates database schema to the latest version\n */\nasync function migrate(db, config = {}) {\n config.force = config.force || false;\n config.table = config.table || 'migrations';\n const { force, table } = config;\n const migrations = config.migrations\n ? config.migrations\n : await readMigrations(config.migrationsPath);\n // Create a database table for migrations meta data if it doesn't exist\n await db.run(`CREATE TABLE IF NOT EXISTS \"${table}\" (\n id INTEGER PRIMARY KEY,\n name TEXT NOT NULL,\n up TEXT NOT NULL,\n down TEXT NOT NULL\n)`);\n // Get the list of already applied migrations\n let dbMigrations = await db.all(`SELECT id, name, up, down FROM \"${table}\" ORDER BY id ASC`);\n // Undo migrations that exist only in the database but not in files,\n // also undo the last migration if the `force` option is enabled.\n const lastMigration = migrations[migrations.length - 1];\n for (const migration of dbMigrations\n .slice()\n .sort((a, b) => Math.sign(b.id - a.id))) {\n if (!migrations.some(x => x.id === migration.id) ||\n (force && migration.id === lastMigration.id)) {\n await db.run('BEGIN');\n try {\n await db.exec(migration.down);\n await db.run(`DELETE FROM \"${table}\" WHERE id = ?`, migration.id);\n await db.run('COMMIT');\n dbMigrations = dbMigrations.filter(x => x.id !== migration.id);\n }\n catch (err) {\n await db.run('ROLLBACK');\n throw err;\n }\n }\n else {\n break;\n }\n }\n // Apply pending migrations\n const lastMigrationId = dbMigrations.length\n ? dbMigrations[dbMigrations.length - 1].id\n : 0;\n for (const migration of migrations) {\n if (migration.id > lastMigrationId) {\n await db.run('BEGIN');\n try {\n await db.exec(migration.up);\n await db.run(`INSERT INTO \"${table}\" (id, name, up, down) VALUES (?, ?, ?, ?)`, migration.id, migration.name, migration.up, migration.down);\n await db.run('COMMIT');\n }\n catch (err) {\n await db.run('ROLLBACK');\n throw err;\n }\n }\n }\n}\nexports.migrate = migrate;\n//# sourceMappingURL=migrate.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.toSqlParams = void 0;\n/**\n * Allows for using strings and `sql-template-strings`. Converts both to a\n * format that's usable by the SQL methods\n *\n * @param sql A SQL string or `sql-template-strings` object\n * @param params An array of parameters\n */\nfunction toSqlParams(sql, params = []) {\n if (typeof sql === 'string') {\n return {\n sql,\n params\n };\n }\n return {\n sql: sql.sql,\n params: sql.values\n };\n}\nexports.toSqlParams = toSqlParams;\n//# sourceMappingURL=strings.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Database = void 0;\nconst Statement_1 = require(\"./Statement\");\nconst migrate_1 = require(\"./utils/migrate\");\nconst strings_1 = require(\"./utils/strings\");\nconst format_error_1 = require(\"./utils/format-error\");\n/**\n * Promisified wrapper for the sqlite3#Database interface.\n */\nclass Database {\n constructor(config) {\n this.config = config;\n this.db = null;\n }\n /**\n * Event handler when verbose mode is enabled.\n * @see https://github.com/mapbox/node-sqlite3/wiki/Debugging\n */\n on(event, listener) {\n this.db.on(event, listener);\n }\n /**\n * Returns the underlying sqlite3 Database instance\n */\n getDatabaseInstance() {\n return this.db;\n }\n /**\n * Opens the database\n */\n open() {\n return new Promise((resolve, reject) => {\n let { filename, mode, driver } = this.config;\n // https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n if (filename === null || filename === undefined) {\n throw new Error('sqlite: filename cannot be null / undefined');\n }\n if (!driver) {\n throw new Error('sqlite: driver is not defined');\n }\n if (mode) {\n this.db = new driver(filename, mode, err => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve();\n });\n }\n else {\n this.db = new driver(filename, err => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve();\n });\n }\n });\n }\n /**\n * Closes the database.\n */\n close() {\n return new Promise((resolve, reject) => {\n this.db.close(err => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve();\n });\n });\n }\n /**\n * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseconfigureoption-value\n */\n configure(option, value) {\n this.db.configure(option, value);\n }\n /**\n * Runs the SQL query with the specified parameters. It does not retrieve any result data.\n * The function returns the Database object for which it was called to allow for function chaining.\n *\n * @param {string} sql The SQL query to run.\n *\n * @param {any} [params, ...] When the SQL statement contains placeholders, you\n * can pass them in here. They will be bound to the statement before it is\n * executed. There are three ways of passing bind parameters: directly in\n * the function's arguments, as an array, and as an object for named\n * parameters. This automatically sanitizes inputs.\n *\n * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaserunsql-param--callback\n */\n run(sql, ...params) {\n return new Promise((resolve, reject) => {\n const sqlObj = (0, strings_1.toSqlParams)(sql, params);\n this.db.run(sqlObj.sql, ...sqlObj.params, function (err) {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve({\n stmt: new Statement_1.Statement(this.stmt),\n lastID: this.lastID,\n changes: this.changes\n });\n });\n });\n }\n /**\n * Runs the SQL query with the specified parameters and resolves with\n * with the first result row afterwards. If the result set is empty, returns undefined.\n *\n * The property names correspond to the column names of the result set.\n * It is impossible to access them by column index; the only supported way is by column name.\n *\n * @param {string} sql The SQL query to run.\n *\n * @param {any} [params, ...] When the SQL statement contains placeholders, you\n * can pass them in here. They will be bound to the statement before it is\n * executed. There are three ways of passing bind parameters: directly in\n * the function's arguments, as an array, and as an object for named\n * parameters. This automatically sanitizes inputs.\n *\n * @see https://github.com/mapbox/node-sqlite3/wiki/API#databasegetsql-param--callback\n */\n get(sql, ...params) {\n return new Promise((resolve, reject) => {\n const sqlObj = (0, strings_1.toSqlParams)(sql, params);\n this.db.get(sqlObj.sql, ...sqlObj.params, (err, row) => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve(row);\n });\n });\n }\n each(sql, ...params) {\n return new Promise((resolve, reject) => {\n const callback = params.pop();\n if (!callback || typeof callback !== 'function') {\n throw new Error('sqlite: Last param of Database#each() must be a callback function');\n }\n if (params.length > 0) {\n const positional = params.pop();\n if (typeof positional === 'function') {\n throw new Error('sqlite: Database#each() should only have a single callback defined. See readme for usage.');\n }\n params.push(positional);\n }\n const sqlObj = (0, strings_1.toSqlParams)(sql, params);\n this.db.each(sqlObj.sql, ...sqlObj.params, (err, row) => {\n if (err) {\n return callback((0, format_error_1.formatError)(err), null);\n }\n callback(null, row);\n }, (err, count) => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve(count);\n });\n });\n }\n /**\n * Runs the SQL query with the specified parameters. The parameters are the same as the\n * Database#run function, with the following differences:\n *\n * If the result set is empty, it will be an empty array, otherwise it will\n * have an object for each result row which\n * in turn contains the values of that row, like the Database#get function.\n *\n * Note that it first retrieves all result rows and stores them in memory.\n * For queries that have potentially large result sets, use the Database#each\n * function to retrieve all rows or Database#prepare followed by multiple\n * Statement#get calls to retrieve a previously unknown amount of rows.\n *\n * @param {string} sql The SQL query to run.\n *\n * @param {any} [params, ...] When the SQL statement contains placeholders, you\n * can pass them in here. They will be bound to the statement before it is\n * executed. There are three ways of passing bind parameters: directly in\n * the function's arguments, as an array, and as an object for named\n * parameters. This automatically sanitizes inputs.\n *\n * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseallsql-param--callback\n */\n all(sql, ...params) {\n return new Promise((resolve, reject) => {\n const sqlObj = (0, strings_1.toSqlParams)(sql, params);\n this.db.all(sqlObj.sql, ...sqlObj.params, (err, rows) => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve(rows);\n });\n });\n }\n /**\n * Runs all SQL queries in the supplied string. No result rows are retrieved. If a query fails,\n * no subsequent statements will be executed (wrap it in a transaction if you want all\n * or none to be executed).\n *\n * Note: This function will only execute statements up to the first NULL byte.\n * Comments are not allowed and will lead to runtime errors.\n *\n * @param {string} sql The SQL query to run.\n * @see https://github.com/mapbox/node-sqlite3/wiki/API#databaseexecsql-callback\n */\n exec(sql) {\n return new Promise((resolve, reject) => {\n const sqlObj = (0, strings_1.toSqlParams)(sql);\n this.db.exec(sqlObj.sql, err => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve();\n });\n });\n }\n /**\n * Prepares the SQL statement and optionally binds the specified parameters.\n * When bind parameters are supplied, they are bound to the prepared statement.\n *\n * @param {string} sql The SQL query to run.\n * @param {any} [params, ...] When the SQL statement contains placeholders, you\n * can pass them in here. They will be bound to the statement before it is\n * executed. There are three ways of passing bind parameters: directly in\n * the function's arguments, as an array, and as an object for named\n * parameters. This automatically sanitizes inputs.\n * @returns Promise<Statement> Statement object\n */\n prepare(sql, ...params) {\n return new Promise((resolve, reject) => {\n const sqlObj = (0, strings_1.toSqlParams)(sql, params);\n const stmt = this.db.prepare(sqlObj.sql, ...sqlObj.params, err => {\n if (err) {\n return reject(err);\n }\n resolve(new Statement_1.Statement(stmt));\n });\n });\n }\n /**\n * Loads a compiled SQLite extension into the database connection object.\n *\n * @param {string} path Filename of the extension to load\n */\n loadExtension(path) {\n return new Promise((resolve, reject) => {\n this.db.loadExtension(path, err => {\n if (err) {\n return reject((0, format_error_1.formatError)(err));\n }\n resolve();\n });\n });\n }\n /**\n * Performs a database migration.\n */\n async migrate(config) {\n await (0, migrate_1.migrate)(this, config);\n }\n /**\n * The methods underneath requires creative work to implement. PRs / proposals accepted!\n */\n /*\n * Unsure if serialize can be made into a promise.\n */\n serialize() {\n throw new Error('sqlite: Currently not implemented. Use getDatabaseInstance().serialize() instead.');\n }\n /*\n * Unsure if parallelize can be made into a promise.\n */\n parallelize() {\n throw new Error('sqlite: Currently not implemented. Use getDatabaseInstance().parallelize() instead.');\n }\n}\nexports.Database = Database;\n//# sourceMappingURL=Database.js.map","export * from \"./Statement.js\";\nexport * from \"./Database.js\";\nimport Database from \"./Database.js\";\n\n/**\n * Opens a database for manipulation. Most users will call this to get started.\n */\nexport async function open(config) {\n const db = new Database.Database(config);\n await db.open();\n return db;\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5],"mappings":";;;;AACA,QAAO,eAAe,SAAS,cAAc,EAAE,OAAO,MAAM,CAAC;CAE7D,SAAS,YAAY,KAAK;AACtB,MAAI,eAAe,MACf,QAAO;AAEX,MAAI,OAAO,QAAQ,UAAU;GACzB,MAAM,2BAAW,IAAI,OAAO;AAC5B,QAAK,IAAI,QAAQ,IACb,UAAS,QAAQ,IAAI;AAGzB,OAAI,IAAI,QACJ,UAAS,UAAU,IAAI;AAE3B,UAAO;;AAEX,MAAI,OAAO,QAAQ,SACf,QAAO,IAAI,MAAM,IAAI;AAEzB,SAAO,IAAI,MAAM,IAAI;;AAEzB,SAAQ,cAAc;;;;;;ACtBtB,QAAO,eAAe,SAAS,cAAc,EAAE,OAAO,MAAM,CAAC;CAE7D,MAAMA;;;;CAIN,IAAM,YAAN,MAAgB;EACZ,YAAY,MAAM;AACd,QAAK,OAAO;;;;;EAKhB,uBAAuB;AACnB,UAAO,KAAK;;;;;;;;EAQhB,KAAK,GAAG,QAAQ;AACZ,UAAO,IAAI,SAAS,SAAS,WAAW;AACpC,SAAK,KAAK,KAAK,GAAG,SAAQ,QAAO;AAC7B,SAAI,IACA,QAAO,QAAQ,GAAGA,iBAAe,aAAa,IAAI,C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