UNPKG

@statezero/core

Version:

The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate

69 lines (68 loc) 2.48 kB
/** * A dynamic wrapper that always returns the latest queryset results * This class proxies array operations to always reflect the current state * of the underlying QuerysetStore. */ export class LiveQueryset { constructor(queryset: any); /** * Serializes the lqs as a simple array of objects, for freezing e.g in the metric stores */ serialize(): any; /** * Refresh the queryset data from the database * Delegates to the underlying store's sync method */ refreshFromDb(): any; /** * Get the current items from the store * @private * @returns {Array} The current items in the queryset */ private getCurrentItems; #private; } export class QuerysetStoreRegistry { _stores: Map<any, any>; _tempStores: WeakMap<object, any>; followingQuerysets: Map<any, any>; syncManager: () => void; querysetStoreGraph: QuerysetStoreGraph; clear(): void; setSyncManager(syncManager: any): void; /** * Add a queryset to the following set for a semantic key */ addFollowingQueryset(semanticKey: any, queryset: any): void; getStore(queryset: any, seed?: boolean): any; /** * Function to return the root store for a queryset */ getRootStore(queryset: any): { isRoot: boolean; rootStore: any; }; /** * Get the current state of the queryset, wrapped in a LiveQueryset * @param {Object} queryset - The queryset * @param {Boolean} seed - Should we optimistically seed the queryset with relevant items from the parent? * @param {Boolean} sync - Schedule a sync of the queryset with the backend * @returns {LiveQueryset} - A live view of the queryset */ getEntity(queryset: Object, seed?: boolean, sync?: boolean): LiveQueryset; /** * Set ground truth for a queryset * @param {Object} queryset - The queryset * @param {Array} instances - Array of instances to set as ground truth * @returns {Array} - The set instances */ setEntity(queryset: Object, instances: any[]): any[]; /** * Get all queryset stores for a specific model class * @param {ModelClass} ModelClass - The model class to get stores for * @returns {Array} - Array of queryset stores for this model */ getAllStoresForModel(ModelClass: any): any[]; } export const querysetStoreRegistry: QuerysetStoreRegistry; import { QuerysetStoreGraph } from './querysetStoreGraph.js';