amplifyquery 2.0.5 → 2.0.6
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/service.js +41 -1
- package/package.json +1 -1
package/dist/service.js
CHANGED
|
@@ -31,7 +31,47 @@ function signatureForModelItem(item) {
|
|
|
31
31
|
const id = typeof (item === null || item === void 0 ? void 0 : item.id) === "string" ? item.id : "";
|
|
32
32
|
const updatedAt = typeof (item === null || item === void 0 ? void 0 : item.updatedAt) === "string" ? item.updatedAt : "";
|
|
33
33
|
const createdAt = typeof (item === null || item === void 0 ? void 0 : item.createdAt) === "string" ? item.createdAt : "";
|
|
34
|
-
|
|
34
|
+
// Some list/customList queries may not include `updatedAt` depending on the selection set.
|
|
35
|
+
// If we only compare by (id, updatedAt|createdAt), we can incorrectly treat real updates
|
|
36
|
+
// (e.g. status changes) as "no-op" and skip cache updates.
|
|
37
|
+
//
|
|
38
|
+
// Use a cheap "version-ish" marker when available, otherwise include a shallow signature.
|
|
39
|
+
const versionMarker = typeof (item === null || item === void 0 ? void 0 : item._lastChangedAt) === "number"
|
|
40
|
+
? String(item._lastChangedAt)
|
|
41
|
+
: typeof (item === null || item === void 0 ? void 0 : item._version) === "number"
|
|
42
|
+
? String(item._version)
|
|
43
|
+
: typeof (item === null || item === void 0 ? void 0 : item.version) === "number"
|
|
44
|
+
? String(item.version)
|
|
45
|
+
: "";
|
|
46
|
+
const shallowSig = (() => {
|
|
47
|
+
if (!item || typeof item !== "object")
|
|
48
|
+
return "";
|
|
49
|
+
const keys = Object.keys(item).sort();
|
|
50
|
+
const parts = [];
|
|
51
|
+
for (const key of keys) {
|
|
52
|
+
if (key === "__typename")
|
|
53
|
+
continue;
|
|
54
|
+
const v = item[key];
|
|
55
|
+
if (v === null || v === undefined) {
|
|
56
|
+
parts.push(`${key}=null`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const t = typeof v;
|
|
60
|
+
if (t === "string" || t === "number" || t === "boolean") {
|
|
61
|
+
parts.push(`${key}=${String(v)}`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(v)) {
|
|
65
|
+
parts.push(`${key}=[${v.length}]`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// Object (nested) - avoid deep/large stringify, just mark presence
|
|
69
|
+
parts.push(`${key}={}`);
|
|
70
|
+
}
|
|
71
|
+
// Keep it bounded to avoid huge signatures
|
|
72
|
+
return parts.join("|").slice(0, 500);
|
|
73
|
+
})();
|
|
74
|
+
return `${id}::${updatedAt || ""}::${createdAt || ""}::${versionMarker}::${shallowSig}`;
|
|
35
75
|
}
|
|
36
76
|
function areItemArraysEquivalentById(a, b) {
|
|
37
77
|
if (a === b)
|