@shapio/local 0.5.5 → 0.5.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/{advisoryLocks-COlJQc1r.js → advisoryLocks-ajVNBhfa.js} +15 -1
- package/dist/{advisoryLocks-COlJQc1r.js.map → advisoryLocks-ajVNBhfa.js.map} +1 -1
- package/dist/{errors-SK0PwPKC.js → errors-nQvt9bs7.js} +8 -2
- package/dist/{errors-SK0PwPKC.js.map → errors-nQvt9bs7.js.map} +1 -1
- package/dist/index.js +525 -157
- package/dist/index.js.map +1 -1
- package/dist/{migrator-CIKnDfZy.js → migrator-CO5sXosL.js} +2 -2
- package/dist/{migrator-CIKnDfZy.js.map → migrator-CO5sXosL.js.map} +1 -1
- package/dist/{s3Adapter-BqCKtI3Y.js → s3Adapter-BC5QP2rS.js} +2 -2
- package/dist/{s3Adapter-BqCKtI3Y.js.map → s3Adapter-BC5QP2rS.js.map} +1 -1
- package/package.json +4 -4
|
@@ -3,6 +3,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { EventEmitter } from "node:events";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
|
+
import { closeSync, openSync } from "node:fs";
|
|
6
7
|
import { DatabaseSync } from "node:sqlite";
|
|
7
8
|
//#region ../../apps/api/src/helpers/appError.ts
|
|
8
9
|
/**
|
|
@@ -3486,6 +3487,18 @@ const registerFunctions = (database, hooks) => {
|
|
|
3486
3487
|
//#region ../../apps/api/src/db/sqlite/connection.ts
|
|
3487
3488
|
const STATEMENT_CACHE_SIZE = 500;
|
|
3488
3489
|
/**
|
|
3490
|
+
* Creates a new database file readable by its owner only (it holds password hashes and, without
|
|
3491
|
+
* SESSION_SECRET, the generated signing secret). `node:sqlite` takes no file mode, so the empty file is made
|
|
3492
|
+
* first; SQLite gives its `-wal` and `-shm` files the same permissions. An existing file is left as it is.
|
|
3493
|
+
*/
|
|
3494
|
+
const createPrivateFile = (path) => {
|
|
3495
|
+
try {
|
|
3496
|
+
closeSync(openSync(path, "wx", 384));
|
|
3497
|
+
} catch (error) {
|
|
3498
|
+
if (error.code !== "EEXIST") throw error;
|
|
3499
|
+
}
|
|
3500
|
+
};
|
|
3501
|
+
/**
|
|
3489
3502
|
* One `node:sqlite` connection. The writer runs every write transaction; readers run read-only
|
|
3490
3503
|
* transactions and autocommit reads (WAL lets them read while the writer works). Calls are synchronous:
|
|
3491
3504
|
* a statement blocks the event loop while it runs.
|
|
@@ -3501,6 +3514,7 @@ var SqliteConnection = class {
|
|
|
3501
3514
|
constructor(options) {
|
|
3502
3515
|
this.#options = options;
|
|
3503
3516
|
this.role = options.role;
|
|
3517
|
+
if (options.location !== ":memory:") createPrivateFile(options.location);
|
|
3504
3518
|
this.#database = new DatabaseSync(options.location, { enableForeignKeyConstraints: true });
|
|
3505
3519
|
this.#database.exec(`pragma busy_timeout = ${options.busyTimeoutMs}`);
|
|
3506
3520
|
if (options.location !== ":memory:") {
|
|
@@ -4178,4 +4192,4 @@ const lockKeyFromId = (id) => createHash("sha256").update(id).digest().readInt32
|
|
|
4178
4192
|
//#endregion
|
|
4179
4193
|
export { mysqlDriverOf as a, assertNotNested as c, toDatetimeText as d, AppError as f, createMysqlDb as i, withConnectionScope as l, createSqliteDb as n, DEFAULT_POOL_ACQUIRE_TIMEOUT_MS as o, sqliteDriverOf as r, pgAcquireError as s, lockKeyFromId as t, toStoredTimestamp as u };
|
|
4180
4194
|
|
|
4181
|
-
//# sourceMappingURL=advisoryLocks-
|
|
4195
|
+
//# sourceMappingURL=advisoryLocks-ajVNBhfa.js.map
|