@wxn0brp/db-storage-sqlite 0.120.0 → 0.120.2-alpha.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/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { ValtheraClass } from "@wxn0brp/db-core";
1
+ import { Id, ValtheraClass } from "@wxn0brp/db-core";
2
2
  import { ActionsBase } from "@wxn0brp/db-core/base/actions";
3
3
  import { Data } from "@wxn0brp/db-core/types/data";
4
4
  import { VQueryT } from "@wxn0brp/db-core/types/query";
5
+ import { TransactionHandle } from "@wxn0brp/db-core/types/transaction";
5
6
  import { AffinityMap, SupportedDB, VStatement } from "./types.js";
6
7
  export declare class SQLiteValthera extends ActionsBase {
7
8
  db: SupportedDB;
@@ -12,6 +13,7 @@ export declare class SQLiteValthera extends ActionsBase {
12
13
  _pendingStmts: Map<string, Promise<VStatement>>;
13
14
  _tableColumns: Map<string, Set<string>>;
14
15
  _tableAffinities: Map<string, AffinityMap>;
16
+ version: string;
15
17
  constructor(db: SupportedDB, primaryKey?: Record<string, string>);
16
18
  _getTableInfo(collection: string): Promise<Record<string, string>>;
17
19
  _invalidateTableCache(collection: string): Promise<void>;
@@ -33,6 +35,9 @@ export declare class SQLiteValthera extends ActionsBase {
33
35
  removeCollection(collection: string): Promise<boolean>;
34
36
  issetCollection(collection: string): Promise<boolean>;
35
37
  ensureCollection(collection: string): Promise<boolean>;
38
+ beginTransaction(id: Id): Promise<TransactionHandle>;
39
+ commitTransaction(handle: TransactionHandle): Promise<void>;
40
+ rollbackTransaction(handle: TransactionHandle): Promise<void>;
36
41
  }
37
42
  export declare function createSQLiteValthera<T extends Record<string, Data> = {}>(sqlDB: SupportedDB): ValtheraClass & { [K in keyof T]: import("@wxn0brp/db-core/helpers/collection").Collection<T[K]>; };
38
43
  export declare const DYNAMIC: {
package/dist/index.js CHANGED
@@ -4,8 +4,9 @@ import { addId } from "@wxn0brp/db-core/helpers/addId";
4
4
  import { MAX_STMT_CACHE } from "./const.js";
5
5
  import { find } from "./find.js";
6
6
  import { remove } from "./remove.js";
7
- import { execStmt, computeAffinity, qid, toSqlValue } from "./utils.js";
8
7
  import { update } from "./update.js";
8
+ import { computeAffinity, execStmt, qid, toSqlValue } from "./utils.js";
9
+ import { version } from "./version.js";
9
10
  export class SQLiteValthera extends ActionsBase {
10
11
  db;
11
12
  primaryKey;
@@ -15,6 +16,7 @@ export class SQLiteValthera extends ActionsBase {
15
16
  _pendingStmts = new Map();
16
17
  _tableColumns = new Map();
17
18
  _tableAffinities = new Map();
19
+ version = version;
18
20
  constructor(db, primaryKey = {}) {
19
21
  super();
20
22
  this.db = db;
@@ -183,6 +185,21 @@ export class SQLiteValthera extends ActionsBase {
183
185
  }
184
186
  return true;
185
187
  }
188
+ async beginTransaction(id) {
189
+ const stmt = await this._prepare("BEGIN");
190
+ await execStmt(stmt, "run");
191
+ return {
192
+ id,
193
+ };
194
+ }
195
+ async commitTransaction(handle) {
196
+ const stmt = await this._prepare("COMMIT");
197
+ await execStmt(stmt, "run");
198
+ }
199
+ async rollbackTransaction(handle) {
200
+ const stmt = await this._prepare("ROLLBACK");
201
+ await execStmt(stmt, "run");
202
+ }
186
203
  }
187
204
  export function createSQLiteValthera(sqlDB) {
188
205
  const adapter = new SQLiteValthera(sqlDB);
@@ -0,0 +1 @@
1
+ export declare const version = "0.120.2-alpha.0";
@@ -0,0 +1 @@
1
+ export const version = "0.120.2-alpha.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db-storage-sqlite",
3
- "version": "0.120.0",
3
+ "version": "0.120.2-alpha.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "A pure SQLite storage adapter for the ValtheraDB database library",
@@ -18,24 +18,22 @@
18
18
  "vdb-adapter",
19
19
  "sqlite"
20
20
  ],
21
+ "dependencies": {
22
+ "@wxn0brp/db-core": "^0.12.4-alpha.0"
23
+ },
21
24
  "devDependencies": {
22
25
  "@types/better-sqlite3": "^9.6.0",
23
26
  "@types/bun": "*",
24
27
  "@types/node": "*",
25
28
  "@wxn0brp/biome": "*",
26
- "@wxn0brp/db-core": "^0.12.0",
27
29
  "better-sqlite3": "^13.0.3",
28
30
  "tsc-alias": "^1",
29
31
  "typescript": "^7"
30
32
  },
31
33
  "peerDependencies": {
32
- "@wxn0brp/db-core": "^0.12.0",
33
34
  "better-sqlite3": "^13.0.3"
34
35
  },
35
36
  "peerDependenciesMeta": {
36
- "@wxn0brp/db-core": {
37
- "optional": false
38
- },
39
37
  "better-sqlite3": {
40
38
  "optional": true
41
39
  }