@ocap/indexdb-memory 1.31.8 → 1.32.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.
@@ -4,6 +4,7 @@ import { TIndexedTransaction } from "@ocap/types";
4
4
  //#region src/table/transaction.d.ts
5
5
  declare class Transaction extends MemoryIndex<TIndexedTransaction> {
6
6
  _insert(row: Record<string, unknown>): TIndexedTransaction & Record<string, unknown>;
7
+ _update(key: string | Record<string, unknown>, updates: Record<string, unknown>): (TIndexedTransaction & Record<string, unknown>) | null;
7
8
  }
8
9
  //#endregion
9
10
  export { Transaction as default };
@@ -6,6 +6,10 @@ var Transaction = class extends base_default {
6
6
  _insert(row) {
7
7
  return super._insert(formatTxBeforeInsert(row));
8
8
  }
9
+ _update(key, updates) {
10
+ const normalized = updates?.tx?.itxJson ? formatTxBeforeInsert(updates) : updates;
11
+ return super._update(key, normalized);
12
+ }
9
13
  };
10
14
  var transaction_default = Transaction;
11
15
 
@@ -1,14 +1,14 @@
1
1
  import LocalBaseIndexDB from "./base.cjs";
2
2
  import { IIndexDB, IIndexTable, IndexTableTypeMap } from "@ocap/types";
3
3
  import { md5 } from "@ocap/util/lib/md5";
4
- import Loki from "lokijs";
4
+ import Lokijs from "lokijs";
5
5
 
6
6
  //#region src/db/index.d.ts
7
7
  declare class MemoryIndexDB extends LocalBaseIndexDB implements IIndexDB {
8
8
  name: string;
9
9
  version: string;
10
10
  md5: typeof md5;
11
- db: Loki;
11
+ db: Lokijs;
12
12
  tx: IIndexTable<IndexTableTypeMap['tx']>;
13
13
  account: IIndexTable<IndexTableTypeMap['account']>;
14
14
  asset: IIndexTable<IndexTableTypeMap['asset']>;
@@ -1,18 +1,18 @@
1
1
  import { BaseIndex } from "@ocap/indexdb";
2
2
  import { IIndexTable } from "@ocap/types";
3
- import Loki from "lokijs";
3
+ import Lokijs from "lokijs";
4
4
 
5
5
  //#region src/table/base.d.ts
6
6
  type UniqueIndex = string | string[];
7
7
  declare class MemoryIndex<T = unknown> extends BaseIndex<T> implements IIndexTable<T> {
8
- collection: Loki.Collection<T & Record<string, unknown>>;
8
+ collection: Lokijs.Collection<T & Record<string, unknown>>;
9
9
  /**
10
10
  * @param name table name
11
11
  * @param uniqIndex primary key(s)
12
12
  * @param db LokiJS database instance
13
13
  */
14
- constructor(name: string, uniqIndex: UniqueIndex, db: Loki);
15
- count(...args: Parameters<Loki.Collection['count']>): number;
14
+ constructor(name: string, uniqIndex: UniqueIndex, db: Lokijs);
15
+ count(...args: Parameters<Lokijs.Collection['count']>): number;
16
16
  _insert(row: Record<string, unknown>): T & Record<string, unknown>;
17
17
  _get(key: string | Record<string, unknown>): (T & Record<string, unknown>) | null;
18
18
  _update(key: string | Record<string, unknown>, updates: Record<string, unknown>): T & Record<string, unknown>;
@@ -8,6 +8,10 @@ var Transaction = class extends require_table_base.default {
8
8
  _insert(row) {
9
9
  return super._insert((0, _ocap_indexdb.formatTxBeforeInsert)(row));
10
10
  }
11
+ _update(key, updates) {
12
+ const normalized = updates?.tx?.itxJson ? (0, _ocap_indexdb.formatTxBeforeInsert)(updates) : updates;
13
+ return super._update(key, normalized);
14
+ }
11
15
  };
12
16
  var transaction_default = Transaction;
13
17
 
@@ -4,6 +4,7 @@ import { TIndexedTransaction } from "@ocap/types";
4
4
  //#region src/table/transaction.d.ts
5
5
  declare class Transaction extends MemoryIndex<TIndexedTransaction> {
6
6
  _insert(row: Record<string, unknown>): TIndexedTransaction & Record<string, unknown>;
7
+ _update(key: string | Record<string, unknown>, updates: Record<string, unknown>): (TIndexedTransaction & Record<string, unknown>) | null;
7
8
  }
8
9
  //#endregion
9
10
  export { Transaction as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/indexdb-memory",
3
3
  "description": "OCAP indexdb adapter that uses memory as backend, just for test purpose",
4
- "version": "1.31.8",
4
+ "version": "1.32.0",
5
5
  "type": "module",
6
6
  "author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
7
7
  "bugs": {
@@ -15,7 +15,7 @@
15
15
  "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)"
16
16
  ],
17
17
  "devDependencies": {
18
- "@ocap/indexdb-test": "1.31.8",
18
+ "@ocap/indexdb-test": "1.32.0",
19
19
  "@types/debug": "^4.1.12",
20
20
  "@types/lodash": "^4.17.10",
21
21
  "@types/lokijs": "^1.5.14",
@@ -79,10 +79,10 @@
79
79
  },
80
80
  "gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e",
81
81
  "dependencies": {
82
- "@arcblock/did": "1.31.8",
83
- "@ocap/indexdb": "1.31.8",
84
- "@ocap/types": "1.31.8",
85
- "@ocap/util": "1.31.8",
82
+ "@arcblock/did": "1.32.0",
83
+ "@ocap/indexdb": "1.32.0",
84
+ "@ocap/types": "1.32.0",
85
+ "@ocap/util": "1.32.0",
86
86
  "debug": "^4.4.3",
87
87
  "lodash": "^4.17.23",
88
88
  "lokijs": "^1.5.12"