import { PluginInstance , MagnetarPlugin , WhereClause , OrderByClause , Limit , } from '../../../core/src' ; import { writeActionFactory , insertActionFactory , deletePropActionFactory , deleteActionFactory , fetchActionFactory , streamActionFactory , revertActionFactory , } from './actions' ; export type RemoteStoreOptions = { storeName : string ; } ; export interface StorePluginModuleConfig { path ? : string ; initialData ? : Record < string , any > | [ string , Record < string , any > ] [ ] ; where ? : WhereClause [ ] ; orderBy ? : OrderByClause [ ] ; limit ? : Limit ; } export const CreatePlugin = ( storePluginOptions ) : PluginInstance => { const fetch = fetchActionFactory ( storePluginOptions ) ; const stream = streamActionFactory ( storePluginOptions ) ; const insert = insertActionFactory ( storePluginOptions ) ; const _merge = writeActionFactory ( storePluginOptions , 'merge' ) ; const assign = writeActionFactory ( storePluginOptions , 'assign' ) ; const replace = writeActionFactory ( storePluginOptions , 'replace' ) ; const deleteProp = deletePropActionFactory ( storePluginOptions ) ; const _delete = deleteActionFactory ( storePluginOptions ) ; const revert = revertActionFactory ( storePluginOptions ) ; const instance = { revert , actions : { fetch , stream , insert , merge : _merge , deleteProp , assign , replace , delete : _delete , } , } ; return instance ; } ;