import { ESPCDFBatchOperationResult, ESPSDKAdaptorGroupsPaginationMap, ESPSDKAdaptorGroupsPaginationData, ESPCDFGroupsByIDMap, ESPCDFGroupSharingRequestsByIDMap, ESPSDKAdaptorGroupSharingRequestsPaginationMap, ESPCDFPaginatedAPIResponse, ESPCDFAttachNodesOptions } from "../types"; import { ESPCDF } from "./index"; import { ESPCDFGroup } from "../entities/ESPCDFGroup"; import type { ESPCDFNode } from "../entities/ESPCDFNode"; import { ESPCDFGroupSharingRequest } from "../entities/ESPCDFGroupSharingRequest"; declare class GroupStore { #private; accessor groupsByIDMap: ESPCDFGroupsByIDMap; accessor currentHomeId: string | null; accessor sdkAdaptorGroupsPaginationMap: ESPSDKAdaptorGroupsPaginationMap; accessor issuedGroupSharingRequestsByIDMap: ESPCDFGroupSharingRequestsByIDMap; accessor receivedGroupSharingRequestsByIDMap: ESPCDFGroupSharingRequestsByIDMap; accessor sdkAdaptorIssuedGroupSharingRequestsPaginationMap: ESPSDKAdaptorGroupSharingRequestsPaginationMap; accessor sdkAdaptorReceivedGroupSharingRequestsPaginationMap: ESPSDKAdaptorGroupSharingRequestsPaginationMap; /** * `true` once a full home sync has completed and nothing has marked the tree * stale since. While `true`, `user.syncHomeWithNodes()` serves the store. * Bookkeeping only, so deliberately not observable. */ treeSynced: boolean; /** `snapshot` while the tree was restored from disk and no live sync has completed yet. */ accessor dataSource: "network" | "snapshot"; [key: string]: any; constructor(rootStore: ESPCDF); /** Records that a full home sync finished; releases snapshot waiters. */ markTreeSynced(): void; /** The tree was just restored from disk: not synced, waiters hold until a live sync. */ markSnapshot(): void; /** Resolves when live data has replaced a snapshot; immediately when the data is already live. */ whenLive(timeoutMs: number): Promise; /** Marks the tree stale, so the next `syncHomeWithNodes()` fetches it. */ invalidateTree(): void; /** Releases this store's entity subscriptions. Called by `ESPCDF.dispose`. */ dispose(): void; get rootStore(): ESPCDF; get groupsList(): ESPCDFGroup[]; get _groupsByID(): Record; get issuedGroupSharingRequestsList(): ESPCDFGroupSharingRequest[]; get receivedGroupSharingRequestsList(): ESPCDFGroupSharingRequest[]; get issuedGroupSharingRequests(): Record; get receivedGroupSharingRequests(): Record; /** * Replaces the group tree with `groups` while keeping the instances the UI * already holds: groups (and sub-groups) with a known id are updated in place, * new ones are added, and ids missing from `groups` are removed and detached. * Snapshot nodes that no home in `groups` lists are deleted from the node store. */ setGroupsList(groups: ESPCDFGroup[]): void; /** * Attaches fetched nodes to a group: upserts them into the node store, then * points the group's `nodeIds` / `nodeDetails` at the store instances. When the * group is a home, each room is filled from the same nodes by its `nodeIds` * (a room's nodes are always a subset of its home's), so one fetch per home * serves every room with no further calls. * With `complete`, snapshot nodes the group lists but `nodes` lacks are deleted. * @param groupId - Home or room the nodes were fetched for * @param nodes - Freshly transformed nodes from the adaptor * @param options - `complete` when `nodes` is the group's full fetch result */ attachNodesToGroup(groupId: string, nodes: ESPCDFNode[], options?: ESPCDFAttachNodesOptions): void; /** * Adds a newly created room (or other sub-group) under its parent. The room * is made observable and attached like any group from a sync, so later edits * on it re-render. A room already under the parent is merged in place. * @param parentId - Home (or group) the room was created in * @param subGroup - Freshly transformed room from the adaptor * @returns The store's instance of the room */ addSubGroup(parentId: string, subGroup: ESPCDFGroup): ESPCDFGroup; /** * Applies plain field changes (name, description, custom data, ...) to a home * or a room in place. Rooms are not top-level entries, so they are found by * walking the tree. */ patchGroup(groupId: string, update: Partial): void; addGroup(group: ESPCDFGroup): ESPCDFGroup; updateGroup(groupId: string, update: Partial): void; /** * Replaces a group in the store (same {@link ESPCDFGroup.id}). * Used when Matter conversion returns a new {@link ESPCDFGroup} / fabric instance from the SDK. */ replaceGroup(groupId: string, group: ESPCDFGroup): ESPCDFGroup; deleteGroup(group: ESPCDFGroup): void; getGroupById(groupId: string): ESPCDFGroup | undefined; /** * Removes a node from all groups' nodes arrays * Called when a node is deleted from nodeStore to maintain consistency * @param nodeId - The ID of the node to remove from groups */ removeNodeFromAllGroups(nodeId: string): void; clear(): void; /** * Sync groups from registered SDKs that match this store type. * This method fetches only the first page of groups from each registered SDK * and stores pagination context for on-demand loading of additional pages. */ syncGroupsList(): Promise>; /** * Helper method to fetch the first page of groups from a single SDK and store pagination context. * @param sdk - The SDK adapter to fetch groups from * @returns Promise resolving to an array of CDF groups */ private fetchFirstPageGroupsFromSDK; /** * Action to set pagination context for a specific SDK. */ setGroupsPaginationContextForSDKAdaptor(sdkIdentifier: string, context: ESPSDKAdaptorGroupsPaginationData): void; /** * Fetch next page of groups from a specific SDK. */ fetchNextPageGroupsForSDK(sdkIdentifier: string): Promise; processGetGroupsRes(response: ESPCDFPaginatedAPIResponse, sdkIdentifier: string): void; /** * Keeps only valid homes in the store (used after first page and each next page in home sync). */ retainOnlyValidHomes(): void; addIssuedGroupSharingRequest(request: ESPCDFGroupSharingRequest): ESPCDFGroupSharingRequest; addReceivedGroupSharingRequest(request: ESPCDFGroupSharingRequest): ESPCDFGroupSharingRequest; setIssuedGroupSharingRequests(requests: ESPCDFGroupSharingRequest[]): void; setReceivedGroupSharingRequests(requests: ESPCDFGroupSharingRequest[]): void; /** * Processes the issued group sharing request response from SDK * Transforms SDK response to entities and stores pagination context */ processIssuedGroupSharingRequestsRes(response: ESPCDFPaginatedAPIResponse, sdkIdentifier: string): { sharedRequests: Record; fetchNext: () => Promise<{ sharedRequests: Record; }>; hasNext: boolean; }; /** * Processes the received group sharing request response from SDK * Transforms SDK response to entities and stores pagination context */ processReceivedGroupSharingRequestsRes(response: ESPCDFPaginatedAPIResponse, sdkIdentifier: string): { sharedRequests: Record; fetchNext: () => Promise<{ sharedRequests: Record; }>; hasNext: boolean; }; /** * Fetch next page of issued group sharing requests from a specific SDK */ fetchNextIssuedGroupSharingRequests(sdkIdentifier: string): Promise<{ sharedRequests: Record; }>; /** * Fetch next page of received group sharing requests from a specific SDK */ fetchNextReceivedGroupSharingRequests(sdkIdentifier: string): Promise<{ sharedRequests: Record; }>; /** * Dynamically adds an observable property to the store. * @param propertyName - The name of the property to add. * @param initialValue - The initial value of the property. */ addProperty(propertyName: string, initialValue: any): void; } export default GroupStore;