/** * Transfer data structure. * * Generic parameter `T` allows strict-typing when the transfer shape is known * (e.g. via codegen-generated interfaces). Falls back to an open index signature * when omitted so existing untyped code keeps compiling. * */ export interface TransferData { __identifier?: string; __signedIdentifier?: string; __typename?: string; /** Index signature preserved for backwards-compatibility when T = Record */ [key: string]: unknown; } /** * Strict transfer data — a TransferData whose *own* properties conform to `T`. * * Use this alias in generated code and userland APIs where the exact field set is * known at compile time. The intersection keeps the internal `__*` fields from * `TransferData` while adding compile-time keys from `T`. * * @typeParam T - Strict field definitions (e.g. `{ name: string; age: number }`) */ export type StrictTransferData = Record> = TransferData & T; /** * Data store state per transfer type. */ export interface TransferState { data: TransferData | null; originalData: TransferData | null; isDirty: boolean; isLoading: boolean; error: Error | null; } /** * Full store state. */ export interface DataStoreState { transfers: Map; version: number; } /** * Selector for fine-grained subscriptions. */ export type DataSelector = (state: DataStoreState) => T; /** * Create empty transfer state. */ export declare function createEmptyTransferState(): TransferState; /** * Data store with selector-based subscriptions. * Provides fine-grained reactivity by only notifying subscribers * when their selected value actually changes. */ export declare class DataStore { private state; private subscribers; private selectorCache; /** * Subscribe to specific data slice. * Only notifies when selected value changes. * * @param selector - Function to select data from state * @param callback - Callback to invoke when selected data changes * @returns Unsubscribe function */ subscribe(selector: DataSelector, callback: () => void): () => void; /** * Get current snapshot for selector. * * @param selector - Function to select data from state * @returns Selected value */ getSnapshot(selector: DataSelector): T; /** * Get the full state snapshot. * Used for debugging and testing. * * @returns Current state */ getState(): DataStoreState; /** * Get transfer state by ID. * * When called with an explicit type parameter the returned `data` / `originalData` * fields are narrowed to `StrictTransferData | null`. * * @typeParam T - Optional strict transfer shape * @param transferId - Transfer identifier * @returns Transfer state (optionally narrowed) or undefined */ getTransfer = Record>(transferId: string): (TransferState & { data: StrictTransferData | null; originalData: StrictTransferData | null; }) | undefined; /** * Set transfer data. * Resets dirty state and error. * * @typeParam T - Optional strict transfer shape * @param transferId - Transfer identifier * @param data - Transfer data (typed when T is provided) */ setTransferData = Record>(transferId: string, data: StrictTransferData): void; /** * Update a single field on a transfer. * If the transfer doesn't exist, creates it with just this field. * * When `T` is provided the `field` parameter is restricted to `keyof T` * and `value` is narrowed to the matching property type. * * @typeParam T - Optional strict transfer shape * @param transferId - Transfer identifier * @param field - Field name (restricted to `keyof T` when strict) * @param value - New value (typed to `T[K]` when strict) */ updateTransferField = Record, K extends string & keyof T = string & keyof T>(transferId: string, field: K, value: T[K]): void; /** * Set transfer loading state. * * @param transferId - Transfer identifier * @param isLoading - Loading state */ setTransferLoading(transferId: string, isLoading: boolean): void; /** * Set transfer error state. * * @param transferId - Transfer identifier * @param error - Error or null to clear */ setTransferError(transferId: string, error: Error | null): void; /** * Reset transfer to original data. * * @param transferId - Transfer identifier */ resetTransfer(transferId: string): void; /** * Clear transfer from store. * * @param transferId - Transfer identifier */ clearTransfer(transferId: string): void; /** * Clear all transfers from store. */ clearAll(): void; /** * Update multiple fields at once. * * When `T` is provided the `updates` object is restricted to partial keys of `T`. * * @typeParam T - Optional strict transfer shape * @param transferId - Transfer identifier * @param updates - Object with field updates (typed to `Partial` when strict) */ updateTransferFields = Record>(transferId: string, updates: Partial): void; /** * Internal method to update state and notify subscribers. */ private updateState; /** * Notify subscribers whose selected values have changed. */ private notifySubscribers; } //# sourceMappingURL=data-store.d.ts.map