@signalium/query 1.1.0 → 1.1.1
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 +6 -0
- package/dist/cjs/development/index.js +40 -0
- package/dist/cjs/development/index.js.map +1 -1
- package/dist/cjs/production/index.js +40 -0
- package/dist/cjs/production/index.js.map +1 -1
- package/dist/esm/EntityMap.d.ts.map +1 -1
- package/dist/esm/development/index.js +40 -0
- package/dist/esm/development/index.js.map +1 -1
- package/dist/esm/production/index.js +40 -0
- package/dist/esm/production/index.js.map +1 -1
- package/dist/esm/proxy.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @signalium/query
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bb0a5a9: Fix entity proxies not being created for preloaded entities from cache, and `__entityRef` not being resolved in proxy get handler. This fixes validation errors when accessing nested entities loaded from persistent cache.
|
|
8
|
+
|
|
3
9
|
## 1.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -912,6 +912,43 @@ function createEntityProxy(id, entityRecord, def, entityRelay, scopeOwner, warn
|
|
|
912
912
|
if (!Object.hasOwnProperty.call(shape, prop)) {
|
|
913
913
|
return value;
|
|
914
914
|
}
|
|
915
|
+
if (value && typeof value === "object") {
|
|
916
|
+
const ownerWithHydrate = scopeOwner;
|
|
917
|
+
if (typeof value.__entityRef === "number") {
|
|
918
|
+
const nestedRecord = ownerWithHydrate.hydrateEntity?.(
|
|
919
|
+
value.__entityRef,
|
|
920
|
+
propDef
|
|
921
|
+
);
|
|
922
|
+
if (nestedRecord && nestedRecord.proxy) {
|
|
923
|
+
cache.set(prop, nestedRecord.proxy);
|
|
924
|
+
return nestedRecord.proxy;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
928
|
+
const firstItem = value[0];
|
|
929
|
+
if (firstItem && typeof firstItem === "object" && typeof firstItem.__entityRef === "number") {
|
|
930
|
+
const arrayTypeDef = propDef;
|
|
931
|
+
const isArrayType = typeof arrayTypeDef.mask === "number" && (arrayTypeDef.mask & Mask.ARRAY) !== 0;
|
|
932
|
+
const itemDef = isArrayType ? arrayTypeDef.shape : void 0;
|
|
933
|
+
if (itemDef) {
|
|
934
|
+
const hydratedArray = value.map((item) => {
|
|
935
|
+
if (item && typeof item === "object" && typeof item.__entityRef === "number") {
|
|
936
|
+
const nestedRecord = ownerWithHydrate.hydrateEntity?.(
|
|
937
|
+
item.__entityRef,
|
|
938
|
+
itemDef
|
|
939
|
+
);
|
|
940
|
+
if (nestedRecord && nestedRecord.proxy) {
|
|
941
|
+
return nestedRecord.proxy;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return item;
|
|
945
|
+
});
|
|
946
|
+
cache.set(prop, hydratedArray);
|
|
947
|
+
return hydratedArray;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
915
952
|
const parsed = parseValue(value, propDef, `[[${desc}]].${prop}`, false, warn);
|
|
916
953
|
cache.set(prop, parsed);
|
|
917
954
|
return parsed;
|
|
@@ -1052,6 +1089,9 @@ class EntityStore {
|
|
|
1052
1089
|
record.data = mergeValues(record.data, obj);
|
|
1053
1090
|
record.notifier.notify();
|
|
1054
1091
|
record.cache.clear();
|
|
1092
|
+
if (record.proxy === void 0) {
|
|
1093
|
+
record.proxy = this.createEntityProxy(record, shape);
|
|
1094
|
+
}
|
|
1055
1095
|
}
|
|
1056
1096
|
record.entityRefs = entityRefs;
|
|
1057
1097
|
return record;
|