@devflow-tools/database 0.14.0 → 0.16.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.
@@ -8,10 +8,10 @@ exports.NodeSqliteDatabase = void 0;
8
8
  // @ts-expect-error - node:sqlite types not available in @types/node@20
9
9
  const node_sqlite_1 = require("node:sqlite");
10
10
  class NodeSqliteDatabase {
11
- constructor(path) {
11
+ constructor(path, busyTimeoutMs = 10000) {
12
12
  this.db = new node_sqlite_1.DatabaseSync(path);
13
+ this.db.exec(`PRAGMA busy_timeout = ${Math.max(0, Math.floor(busyTimeoutMs))}`);
13
14
  this.db.exec('PRAGMA journal_mode = WAL');
14
- this.db.exec('PRAGMA busy_timeout = 10000');
15
15
  this.db.exec('PRAGMA synchronous = NORMAL');
16
16
  }
17
17
  exec(sql) {
@@ -21,17 +21,17 @@ class NodeSqliteDatabase {
21
21
  const stmt = this.db.prepare(sql);
22
22
  return {
23
23
  run: (...params) => {
24
- const result = stmt.run(...params);
24
+ const result = stmt.run(...normalizeParams(params));
25
25
  return {
26
26
  changes: result.changes,
27
27
  lastInsertRowid: result.lastInsertRowid,
28
28
  };
29
29
  },
30
30
  get: (...params) => {
31
- return stmt.get(...params);
31
+ return stmt.get(...normalizeParams(params));
32
32
  },
33
33
  all: (...params) => {
34
- return stmt.all(...params);
34
+ return stmt.all(...normalizeParams(params));
35
35
  },
36
36
  };
37
37
  }
@@ -52,3 +52,6 @@ class NodeSqliteDatabase {
52
52
  }
53
53
  }
54
54
  exports.NodeSqliteDatabase = NodeSqliteDatabase;
55
+ function normalizeParams(params) {
56
+ return params.map(value => typeof value === 'boolean' ? Number(value) : value);
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devflow-tools/database",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "DevFlow SQLite database package",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,5 +13,5 @@
13
13
  "typescript": "^5.5.0",
14
14
  "vitest": "^2.0.0"
15
15
  },
16
- "gitHead": "af6ac81c0242d77fe11ae205a9733d92926c0ac9"
16
+ "gitHead": "2f52776bda72517354d44453756cccb9e8de9afa"
17
17
  }