import type { WithDeleted } from './rx-storage.d.ts'; /** * 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 RxConflictHandlerOld = ( i: RxConflictHandlerInput, context: string ) => Promise>; export type RxConflictHandler = { /** * This must be non-async * because it will be called very often and must be fast. */ isEqual: ( a: WithDeleted, b: WithDeleted, context: string ) => boolean; resolve: ( i: RxConflictHandlerInput, context: string ) => Promise>; };