import Collection from './Collection'; import type { BaseItem, CollectionOptions } from './Collection'; import type { Changeset, LoadResponse } from './types/PersistenceAdapter'; interface ReplicationOptions, I> { pull: () => Promise>; push?(changes: Changeset, items: T[]): Promise; registerRemoteChange?: (onChange: (data?: LoadResponse) => void | Promise) => Promise; } /** * Creates a persistence adapter for replicating a collection, enabling pull and push * operations for synchronizing with a remote source. Supports optional remote change registration. * @template T - The type of the items being replicated. * @template I - The type of the unique identifier for the items. * @param options - The options for configuring the replication adapter. * @param options.pull - A function to fetch data from the remote source. * @param options.push - An optional function to send changes and items to the remote source. * @param options.registerRemoteChange - An optional function to register a listener for remote changes. * @returns A persistence adapter configured for replication. */ export declare function createReplicationAdapter, I>(options: ReplicationOptions): import("./types/PersistenceAdapter").default; export type ReplicatedCollectionOptions, I, E extends BaseItem = T, U = E> = CollectionOptions & ReplicationOptions; /** * Extends the `Collection` class to support replication with remote sources. * Handles pull and push operations, remote change registration, and enhanced loading states. * @template T - The type of the items in the collection. * @template I - The type of the unique identifier for the items. * @template U - The transformed item type after applying transformations (default is T). */ export default class ReplicatedCollection = BaseItem, I = any, E extends BaseItem = T, U = E> extends Collection { private isPullingRemoteSignal; private isPushingRemoteSignal; /** * Creates a new instance of the `ReplicatedCollection` class. * Sets up the replication adapter, combining it with an optional persistence adapter, and * initializes signals for tracking remote pull and push operations. * @param options - The configuration options for the replicated collection. * @param options.pull - A function to fetch data from the remote source. * @param options.push - An optional function to send changes and items to the remote source. * @param options.registerRemoteChange - An optional function to register a listener for remote changes. * @param options.persistence - An optional persistence adapter to combine with replication. * @param options.reactivity - A reactivity adapter for observing changes in the collection. * @param options.transform - A transformation function to apply to items when retrieving them. * @param options.indices - An array of index providers for optimized querying. * @param options.enableDebugMode - A boolean to enable or disable debug mode. */ constructor(options: ReplicatedCollectionOptions); /** * Checks whether the collection is currently performing any loading operation, * including pulling or pushing data from/to the remote source, or standard * persistence adapter operations. * ⚡️ this function is reactive! * @returns A boolean indicating if the collection is currently loading or synchronizing. */ isLoading(): boolean; } export {};