import SyncItem from "./SyncItem"; import { SyncOptions, SyncOperation } from "./types/SyncTypes"; import DocId from "./types/DocId"; import Collection from "./Collection"; import Synchronizer from "./Synchronizer"; import CollectionSyncMetadata from "./CollectionSyncMetadata"; declare abstract class SynchronizableCollection implements Collection { private readonly defaultSyncOptions; /** Store history of sync operations. */ private synchronizers; private _parent?; syncMetadata: CollectionSyncMetadata; constructor(syncMetadata: CollectionSyncMetadata); abstract countAll(): number | Promise; abstract findByIds(ids: DocId[]): SyncItem[] | Promise; abstract syncBatch(items: SyncItem[]): SyncItem[] | Promise; abstract itemsNewerThan(date: Date | undefined, limit: number): SyncItem[] | Promise; abstract latestUpdatedItem(): SyncItem | Promise | undefined; abstract initialize(): Promise; /** * Executes before starting to send the data to the destination collection. * If this method returns `false`, syncing will be aborted, and will continue only if * the return value is `true`. */ preExecuteSync(_synchronizer: Synchronizer): Promise; /** * Executes before committing the data. If this method returns `false`, then committing will * be aborted. It will only commit the data if the return value is `true`. */ preCommitSync(_synchronizer: Synchronizer): Promise; commitSync(_itemsToSync: SyncItem[], _ignoredItems: SyncItem[], _conflictItems: SyncItem[]): Promise; rollbackSync(_itemsToSync: SyncItem[], _ignoredItems: SyncItem[], _conflictItems: SyncItem[]): Promise; /** * Executed at the end of each sync operation (whether it succeeded or not). * It's recommended to implement cleaning logic if necessary. */ cleanUp(_synchronizer: Synchronizer): Promise; set parent(p: Collection | undefined); get parent(): Collection | undefined; get lastSynchronizer(): Synchronizer | undefined; needsSync(syncOperation: SyncOperation): Promise; private itemsToFetch; private itemsToPost; /** Gets list of items that can be synced (to either fetch or post). */ itemsToSync(syncOperation: SyncOperation, limit: number): Promise; /** * Wraps sync operation so that `cleanUp` and `rollback` are conveniently placed at the end * and always executed. */ sync(syncOperation: SyncOperation, limit: number, options?: SyncOptions): Promise; syncAux(synchronizer: Synchronizer, syncOperation: SyncOperation, limit: number, options?: SyncOptions): Promise; } export default SynchronizableCollection;