import { WithDeleted } from 'nxdb-old/src/types/rx-storage'; /** * Notice that the conflict handler input/output * does not work on RxDocumentData, but only on WithDeleted. * This is because the _meta attributes are meant for the local storing of document data, they not replicated * and therefore cannot be used to resolve conflicts. */ export type RxConflictHandlerInput = { assumedMasterState?: WithDeleted; realMasterState: WithDeleted; newDocumentState: WithDeleted; }; /** * The conflict handler either returns: * - The resolved new document state * - A flag to identify the given 'realMasterState' and 'newDocumentState' * as being exactly equal, so no conflict has to be resolved. */ export type RxConflictHandlerOutput = { isEqual: false; documentData: WithDeleted; } | { isEqual: true; }; export type RxConflictHandler = ( i: RxConflictHandlerInput, context: string ) => Promise>; export type RxConflictResultionTask = { /** * Unique id for that single task. */ id: string; /** * Tasks must have a context * which makes it easy to filter/identify them again * with plugins or other hacky stuff. */ context: string; input: RxConflictHandlerInput; }; export type RxConflictResultionTaskSolution = { /** * Id of the RxConflictResultionTask */ id: string; output: RxConflictHandlerOutput; };