import { PluginRevertAction , PluginRevertActionPayload } from '../../../../core/src' ; import { StorePluginModuleConfig , StorePluginOptions , MakeRestoreBackup } from '../CreatePlugin' ; import { throwIfEmulatedError } from '../../helpers' ; export function revertActionFactory ( data , storePluginOptions , restoreBackup ) { return function ( { payload , collectionPath , docId , pluginModuleConfig , actionName , error , } ) : void { throwIfEmulatedError ( payload , storePluginOptions ) ; if ( docId && [ 'insert' , 'merge' , 'assign' , 'replace' , 'delete' , 'deleteProp' ] . includes ( actionName ) ) { restoreBackup ( collectionPath , docId ) ; return ; } if ( ! docId && actionName === 'insert' ) actionName = 'insert on collections' as any ; console . error ( `[@magnetarjs/test-utils] revert not yet implemented for ${ actionName }` ) ; } ; }