@statezero/core
Version:
The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate
58 lines (57 loc) • 2.18 kB
TypeScript
export class QuerysetStore {
constructor(modelClass: any, fetchFn: any, queryset: any, initialGroundTruthPks?: null, initialOperations?: null, options?: {});
modelClass: any;
fetchFn: any;
queryset: any;
operationsMap: Map<any, any>;
groundTruthPks: never[];
isSyncing: boolean;
lastSync: number | null;
isTemp: any;
pruneThreshold: any;
getRootStore: any;
includedPks: Map<any, any>;
qsCache: Cache;
_lastRenderedPks: any[] | null;
renderCallbacks: Set<any>;
_rootUnregister: any;
_currentRootStore: any;
_modelStoreUnregister: any;
get cacheKey(): any;
onHydrated(hydratedData: any): void;
setCache(result: any): void;
clearCache(): void;
get operations(): any[];
get pkField(): any;
get groundTruthSet(): Set<never>;
_emitRenderEvent(): void;
addOperation(operation: any): Promise<void>;
updateOperation(operation: any): Promise<true | undefined>;
confirm(operation: any): Promise<void>;
reject(operation: any): Promise<void>;
setGroundTruth(groundTruthPks: any): Promise<void>;
setOperations(operations: any): Promise<void>;
getTrimmedOperations(): any[];
getInflightOperations(): any[];
prune(): void;
registerRenderCallback(callback: any): () => boolean;
_ensureRootRegistration(): void;
/**
* Helper to validate PKs against the model store and apply local filtering/sorting.
* This is the core of the rendering logic.
* @private
*/
private _getValidatedAndFilteredPks;
render(optimistic?: boolean, fromCache?: boolean): any[];
renderFromRoot(optimistic: boolean | undefined, rootStore: any): any[];
/**
* Render by getting ALL instances from the model store and applying
* the queryset's filters locally. Used for temp stores (e.g., optimistic
* chained filters) that don't have their own ground truth.
*/
renderFromModelStore(optimistic?: boolean): any[];
renderFromData(optimistic?: boolean): any[];
applyOperation(operation: any, currentPks: any): any;
sync(forceFromDb?: boolean): Promise<void>;
}
import { Cache } from '../cache/cache.js';