import { LocalStorage, CRUDEvents } from "../../storage"; import { Client } from "urql"; import { Model } from "../../Model"; import { NetworkIndicator } from "../network/NetworkIndicator"; import { ReplicatorMutations } from "./ReplicatorMutations"; import { GlobalReplicationConfig } from "../api/ReplicationConfig"; interface MutationReplicationOptions { storage: LocalStorage; client: Client; networkIndicator: NetworkIndicator; } /** * Interface that is injected into model in order to add new items to replication engine */ export interface ModelChangeReplication { /** * Save replication request * @param model * @param data * @param eventType * @param store */ saveChangeForReplication(model: Model, data: any, eventType: CRUDEvents, store: LocalStorage): Promise; } export interface ModelMap { [name: string]: { documents: ReplicatorMutations; model: Model; }; } /** * Queue that manages replication of the mutations for all local edits. */ export declare class MutationsReplicationQueue implements ModelChangeReplication { private modelMap; private open?; private processing; private replicating; private options; constructor(options: MutationReplicationOptions); /** * Add models that should be replicated to the server * * @param models * @param globalConfig */ addModels(models: Model[], globalConfig: GlobalReplicationConfig): void; /** * Initialize networkstatus and Queue to make sure that it is in proper state after startup. */ init(models: Model[], globalConfig: GlobalReplicationConfig): void; /** * Save user change to bereplicated by engine */ saveChangeForReplication(model: Model, data: any, eventType: CRUDEvents, store: LocalStorage): Promise; process(): Promise; /** * Helper method to flag that replication and start * processing the mutation queue. * */ startReplication(): void; /** * Helper method to stop replication and stop the * processing of the mutation queue. */ stopReplication(): void; private getStoredMutations; private getMutationDocument; private dequeueRequest; private enqueueRequest; /** * Handler for mutation error * @param error */ private errorHandler; private swapIdsInQueue; private resultProcessor; } export {};