@statezero/core 0.1.11 → 0.1.12
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.
|
@@ -68,7 +68,7 @@ export class QuerysetStore {
|
|
|
68
68
|
}
|
|
69
69
|
async addOperation(operation) {
|
|
70
70
|
this.operationsMap.set(operation.operationId, operation);
|
|
71
|
-
if (this.operationsMap.size > this.pruneThreshold) {
|
|
71
|
+
if (this.operationsMap.size > this.pruneThreshold && !this.isSyncing) {
|
|
72
72
|
this.prune();
|
|
73
73
|
}
|
|
74
74
|
this._emitRenderEvent();
|
|
@@ -116,6 +116,10 @@ export class QuerysetStore {
|
|
|
116
116
|
operation.status != Status.REJECTED);
|
|
117
117
|
}
|
|
118
118
|
prune() {
|
|
119
|
+
if (this.isSyncing) {
|
|
120
|
+
console.log(`[ModelStore ${this.modelClass.modelName}] Skipping prune - sync in progress`);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
119
123
|
const renderedPks = this.render(false);
|
|
120
124
|
this.setGroundTruth(renderedPks);
|
|
121
125
|
this.setOperations(this.getInflightOperations());
|
|
@@ -182,8 +186,16 @@ export class QuerysetStore {
|
|
|
182
186
|
ast: this.queryset.build(),
|
|
183
187
|
modelClass: this.modelClass
|
|
184
188
|
});
|
|
189
|
+
if (!response || typeof response !== "object") {
|
|
190
|
+
throw new Error(`Invalid response structure from fetchFn`);
|
|
191
|
+
}
|
|
185
192
|
const { data, included } = response;
|
|
186
193
|
console.log(`[${id}] Sync fetch completed. Received: ${JSON.stringify(data)}.`);
|
|
194
|
+
if (!Array.isArray(data)) {
|
|
195
|
+
console.warn(`[${id}] fetchFn returned non-array data:`, typeof data);
|
|
196
|
+
// Don't update ground truth with invalid data
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
187
199
|
// Persists all the instances (including nested instances) to the model store
|
|
188
200
|
processIncludedEntities(modelStoreRegistry, included, this.modelClass);
|
|
189
201
|
this.setGroundTruth(data);
|
package/package.json
CHANGED