import NodeStore from "./nodeStore"; import GroupStore from "./groupStore"; import UserStore from "./userStore"; import { ESPCDFGroup } from "../entities/ESPCDFGroup"; import { ESPCDFNode } from "../entities/ESPCDFNode"; import ScheduleStore from "./scheduleStore"; import AutomationStore from "./automationStore"; import SceneStore from "./sceneStore"; import SubscriptionStore from "./subscriptionStore"; import { ESPCDFconfig, ESPSDKAdaptor } from "../types"; import { AdaptorRegistry } from "../registry"; /** * The root store that manages all individual stores. */ export declare class ESPCDF { #private; static instance: ESPCDF | null; accessor sdkAdaptorRegistry: AdaptorRegistry; accessor nodeStore: NodeStore; accessor groupStore: GroupStore; accessor userStore: UserStore; accessor scheduleStore: ScheduleStore; accessor automationStore: AutomationStore; accessor sceneStore: SceneStore; accessor subscriptionStore: SubscriptionStore; /** * Bumped by every store action, synchronizer and event handler that changes the * home tree (groups, nodes, params). Cheap to watch: the snapshot persister * reacts to this counter instead of tracking the whole tree. */ accessor treeVersion: number; constructor(config: ESPCDFconfig); /** Records that the home tree changed. Called by the stores, synchronizers and event handlers. */ markTreeChanged(): void; /** `true` while the tree was restored from disk and no live sync has completed yet. */ get isSnapshot(): boolean; /** * Saves the current tree to disk. Returns `false` when snapshots are off, there * is nothing to save, or the content already on disk is the same. */ persistSnapshot(): Promise; /** * Restores the tree from disk when the store is empty and a usable snapshot * exists for this adaptor and user. Returns `true` when something was restored. */ hydrateSnapshot(): Promise; /** Deletes the snapshot of the signed-in user (logout, account deletion). */ clearSnapshot(): Promise; /** * Adds a custom store to the root store. * @param storeName - The name of the custom store. * @param StoreClass - The class of the custom store. * * Example: * ```ts * import { makeAutoObservable, action } from "mobx"; * import { CDF } from "./index"; * * class CustomStore { * rootStore: CDF; * customValue = "custom value"; * * constructor(rootStore: CDF) { * this.rootStore = rootStore; * makeAutoObservable(this); * } * * @action setCustomValue(value: string) { * this.customValue = value; * } * } * * store.addStore("customStore", CustomStore); * ``` */ addStore(storeName: string, StoreClass: new (rootStore: ESPCDF) => any): void; /** * Gets an SDK adaptor by identifier. * @param adaptorIdentifier - The identifier of the adaptor to retrieve * @returns The SDK adaptor instance */ adaptor(adaptorIdentifier: string): ESPSDKAdaptor; /** * Returns the identifier of the currently active SDK adaptor, or null if none is set. * @returns The active adaptor identifier, or null */ getActiveAdaptorIdentifier(): string | null; /** * Returns the currently selected home group, or undefined if none is set. */ getCurrentHome(): ESPCDFGroup | undefined; /** * Returns nodes that belong to the current home's nodeIds. */ getNodesForCurrentHome(): ESPCDFNode[]; static getInstance(config: ESPCDFconfig): ESPCDF; /** * Releases every entity subscription held by this instance's stores. * * Each store owns its synchronizer as a private field, so teardown has to be * forwarded store by store — there is no way to reach them from outside. */ dispose(): void; /** * Tears down the singleton so the next {@link initCDF} builds a fresh one. * * `getInstance` returns the cached instance and ignores the config it is * handed, so a host that needs to re-initialise against a DIFFERENT backend * (a deployment switch) must clear the singleton first or it silently keeps * running on the previous backend's stores. */ static dispose(): void; } /** * Initializes and returns the singleton CDF store instance. * * Creates a new CDF instance if one doesn't exist, or returns the existing instance. * Validates that the config and SDK registry are provided. * @param config - CDF configuration containing SDK registry * @returns The singleton CDF store instance * @throws Error if config or SDK registry is missing */ export declare const initCDF: (config: ESPCDFconfig) => Promise; /** * Disposes the singleton CDF store instance, the counterpart to {@link initCDF}. * * Safe to call when no instance exists. Call this before re-initialising against * a different backend; without it `initCDF` hands back the existing instance and * discards the new config. */ export declare const disposeCDF: () => void;