import Config from '../../zeichen.config' export const load = state => async (collectionId: string, itemId?: unknown) => { const collectionVersions = await Promise.all( Config.plugins .filter(p => p['type'] === 'storage') .map(Plugin => { const pluginInstance = new Plugin(state) return pluginInstance.load(collectionId, itemId) }) ) // TODO reduce collectionVersions to get the most correct version. return collectionVersions } export const save = state => (collectionId: string) => async (item: unknown) => { const collectionVersions = await Promise.all( Config.plugins .filter(p => p['type'] === 'storage') .map(Plugin => { const pluginInstance = new Plugin(state) return pluginInstance.save(collectionId, item) }) ) // TODO reduce collectionVersions to get the most correct version. return collectionVersions } export const remove = state => (collectionId: string) => async (item: unknown) => { const collectionVersions = await Promise.all( Config.plugins .filter(p => p['type'] === 'storage') .map(Plugin => { const pluginInstance = new Plugin(state) return pluginInstance.remove(collectionId, item) }) ) // TODO reduce collectionVersions to get the most correct version. return collectionVersions }