@ocap/statedb 1.30.25 → 1.31.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/esm/table.mjs CHANGED
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
3
3
  import { isValid } from "@arcblock/did";
4
4
  import { toAddress } from "@ocap/util";
5
5
  import Kareem from "kareem";
6
+ import cloneDeep from "lodash/cloneDeep.js";
6
7
  import omit from "lodash/omit.js";
7
8
  import pick from "lodash/pick.js";
8
9
 
@@ -49,7 +50,7 @@ var StateDBTable = class extends Ready {
49
50
  events.push({
50
51
  table: this.name,
51
52
  name: x,
52
- data: omit(result, "$loki"),
53
+ data: cloneDeep(omit(result, "$loki")),
53
54
  ctx: pick(ctx, Object.keys(ctx).filter((k) => [
54
55
  "events",
55
56
  "states",
@@ -107,14 +108,15 @@ var StateDBTable = class extends Ready {
107
108
  const cacheStates = context.cacheStates || {};
108
109
  if (!cacheStates[this.name]) cacheStates[this.name] = {};
109
110
  const cacheKey = this.generatePrimaryKey(data);
110
- cacheStates[this.name][cacheKey] = data;
111
+ cacheStates[this.name][cacheKey] = cloneDeep(data);
111
112
  context.cacheStates = cacheStates;
112
113
  }
113
114
  /** get data from cache for context */
114
115
  getCache(key, context) {
115
116
  const cacheStates = context.cacheStates || {};
116
117
  const cacheKey = this.generatePrimaryKey(key);
117
- return cacheStates[this.name]?.[cacheKey] || null;
118
+ const cached = cacheStates[this.name]?.[cacheKey];
119
+ return cached ? cloneDeep(cached) : null;
118
120
  }
119
121
  };
120
122
  var table_default = StateDBTable;
package/lib/table.cjs CHANGED
@@ -7,6 +7,8 @@ let _arcblock_did = require("@arcblock/did");
7
7
  let _ocap_util = require("@ocap/util");
8
8
  let kareem = require("kareem");
9
9
  kareem = require_rolldown_runtime.__toESM(kareem);
10
+ let lodash_cloneDeep = require("lodash/cloneDeep");
11
+ lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
10
12
  let lodash_omit = require("lodash/omit");
11
13
  lodash_omit = require_rolldown_runtime.__toESM(lodash_omit);
12
14
  let lodash_pick = require("lodash/pick");
@@ -55,7 +57,7 @@ var StateDBTable = class extends _ocap_util_lib_ready.Ready {
55
57
  events.push({
56
58
  table: this.name,
57
59
  name: x,
58
- data: (0, lodash_omit.default)(result, "$loki"),
60
+ data: (0, lodash_cloneDeep.default)((0, lodash_omit.default)(result, "$loki")),
59
61
  ctx: (0, lodash_pick.default)(ctx, Object.keys(ctx).filter((k) => [
60
62
  "events",
61
63
  "states",
@@ -113,14 +115,15 @@ var StateDBTable = class extends _ocap_util_lib_ready.Ready {
113
115
  const cacheStates = context.cacheStates || {};
114
116
  if (!cacheStates[this.name]) cacheStates[this.name] = {};
115
117
  const cacheKey = this.generatePrimaryKey(data);
116
- cacheStates[this.name][cacheKey] = data;
118
+ cacheStates[this.name][cacheKey] = (0, lodash_cloneDeep.default)(data);
117
119
  context.cacheStates = cacheStates;
118
120
  }
119
121
  /** get data from cache for context */
120
122
  getCache(key, context) {
121
123
  const cacheStates = context.cacheStates || {};
122
124
  const cacheKey = this.generatePrimaryKey(key);
123
- return cacheStates[this.name]?.[cacheKey] || null;
125
+ const cached = cacheStates[this.name]?.[cacheKey];
126
+ return cached ? (0, lodash_cloneDeep.default)(cached) : null;
124
127
  }
125
128
  };
126
129
  var table_default = StateDBTable;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.30.25",
6
+ "version": "1.31.0",
7
7
  "description": "Defines the basic interface for OCAP StateDB",
8
8
  "type": "module",
9
9
  "main": "./lib/index.cjs",
@@ -44,10 +44,10 @@
44
44
  "license": "MIT",
45
45
  "devDependencies": {},
46
46
  "dependencies": {
47
- "@arcblock/did": "1.30.25",
48
- "@ocap/state": "1.30.25",
49
- "@ocap/types": "1.30.25",
50
- "@ocap/util": "1.30.25",
47
+ "@arcblock/did": "1.31.0",
48
+ "@ocap/state": "1.31.0",
49
+ "@ocap/types": "1.31.0",
50
+ "@ocap/util": "1.31.0",
51
51
  "kareem": "^2.4.1",
52
52
  "lodash": "^4.17.23"
53
53
  }