export type StoreSubscriber = { storeChanged: (store: ResourceStore) => void } export type AutoSubscriber = StoreSubscriber & { subscriptions: Set> } export type AnyStore = ResourceStore declare class ResourceStore { constructor(name: string) get(id: string, subscriber?: StoreSubscriber): T subscribe(id: string, listener: StoreSubscriber): void unsubscribeAll(listener: StoreSubscriber): void unsubscribe(id: string, listener: StoreSubscriber): void update(id: string, updates: Partial): T insert(...entries: T extends { id: string } ? (T[] | T[][]) : never): T[] upsert(...entries: T extends { id: string } ? (T[] | T[][]) : never): T[] insertWithId(id: string, newEntry: T): T delete(id: string): void getAll(): T[] clear(): void } type StoreType = T extends abstract new (...args: any) => any ? InstanceType : T export function getStore(template: T): { [key in keyof T]: ResourceStore> } export function unsubscribe(store: ReturnType, listener: StoreSubscriber): void export function autoSubscribe(subscriber: AutoSubscriber, callback: () => T): T export function seedStore(store: { [key: string]: ResourceStore }, data: any): void export function clearStore(store: { [key: string]: ResourceStore }): void export function serialize; }>(store: T): { [key in keyof T]: T[key] extends ResourceStore ? Type[] : never; } export type { ResourceStore }