@signalium/query 1.0.16 → 1.0.18

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @signalium/query
2
2
 
3
+ ## 1.0.18
4
+
5
+ ### Patch Changes
6
+
7
+ - 395730a: Fix entity cache keys to include shapeKey, preventing stale entity validation errors after schema changes
8
+
9
+ ## 1.0.17
10
+
11
+ ### Patch Changes
12
+
13
+ - b244daa: Fix infinite query cache hydration and Hermes Uint32Array compatibility
14
+
15
+ - Fix Hermes (React Native) compatibility by spreading Set to Array before Uint32Array conversion, which prevents empty refIds buffers
16
+ - Fix infinite query cache loading by properly handling the array of pages when parsing entities, ensuring entity proxies resolve correctly after app restart
17
+
3
18
  ## 1.0.16
4
19
 
5
20
  ### Patch Changes
@@ -1139,7 +1139,8 @@ class EntityStore {
1139
1139
  });
1140
1140
  }
1141
1141
  const warn = this.queryClient.getContext().log?.warn;
1142
- return createEntityProxy(record.key, record, shape, entityRelay, this.queryClient, warn);
1142
+ const desc = `${shape.typenameValue}:${id}`;
1143
+ return createEntityProxy(record.key, record, shape, entityRelay, this.queryClient, warn, desc);
1143
1144
  }
1144
1145
  }
1145
1146
  class NetworkManager {
@@ -1331,7 +1332,7 @@ function parseObjectEntities(obj, objectShape, queryClient, entityRefs) {
1331
1332
  throw new Error(`Entity id is required: ${typename}`);
1332
1333
  }
1333
1334
  const desc = `${typename}:${id}`;
1334
- const key = utils.hashValue(desc);
1335
+ const key = utils.hashValue([desc, entityDef.shapeKey]);
1335
1336
  if (entityRefs !== void 0) {
1336
1337
  entityRefs.add(key);
1337
1338
  }
@@ -1846,7 +1847,17 @@ class QueryResultImpl {
1846
1847
  );
1847
1848
  }
1848
1849
  const shape = this.def.shape;
1849
- state.value = shape instanceof ValidatorDef ? parseEntities(cached.value, shape, this.queryClient, /* @__PURE__ */ new Set()) : parseValue(cached.value, shape, this.def.id);
1850
+ if (shape instanceof ValidatorDef) {
1851
+ if (this.def.type === QueryType.InfiniteQuery && Array.isArray(cached.value)) {
1852
+ state.value = cached.value.map(
1853
+ (page) => parseEntities(page, shape, this.queryClient, /* @__PURE__ */ new Set())
1854
+ );
1855
+ } else {
1856
+ state.value = parseEntities(cached.value, shape, this.queryClient, /* @__PURE__ */ new Set());
1857
+ }
1858
+ } else {
1859
+ state.value = parseValue(cached.value, shape, this.def.id);
1860
+ }
1850
1861
  }
1851
1862
  } catch (error) {
1852
1863
  this.queryClient.deleteCachedQuery(this.storageKey);
@@ -2340,7 +2351,7 @@ class MutationResultImpl {
2340
2351
  const entityId = obj[idField];
2341
2352
  if (entityId !== void 0) {
2342
2353
  const typename = entityDef.typenameValue;
2343
- const entityKey = utils.hashValue(`${typename}:${entityId}`);
2354
+ const entityKey = utils.hashValue([`${typename}:${entityId}`, entityDef.shapeKey]);
2344
2355
  this.queryClient.registerOptimisticUpdate(entityKey, obj);
2345
2356
  this._pendingOptimisticKeys.add(entityKey);
2346
2357
  }