Zeichen's app for both server and client.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

47 lines
1.3 KiB

  1. import Config from '../../zeichen.config'
  2. export const load = state => async (collectionId: string, itemId?: unknown) => {
  3. const collectionVersions = await Promise.all(
  4. Config.plugins
  5. .filter(p => p['type'] === 'storage')
  6. .map(Plugin => {
  7. const pluginInstance = new Plugin(state)
  8. return pluginInstance.load(collectionId, itemId)
  9. })
  10. )
  11. // TODO reduce collectionVersions to get the most correct version.
  12. return collectionVersions
  13. }
  14. export const save = state => (collectionId: string) => async (item: unknown) => {
  15. const collectionVersions = await Promise.all(
  16. Config.plugins
  17. .filter(p => p['type'] === 'storage')
  18. .map(Plugin => {
  19. const pluginInstance = new Plugin(state)
  20. return pluginInstance.save(collectionId, item)
  21. })
  22. )
  23. // TODO reduce collectionVersions to get the most correct version.
  24. return collectionVersions
  25. }
  26. export const remove = state => (collectionId: string) => async (item: unknown) => {
  27. const collectionVersions = await Promise.all(
  28. Config.plugins
  29. .filter(p => p['type'] === 'storage')
  30. .map(Plugin => {
  31. const pluginInstance = new Plugin(state)
  32. return pluginInstance.remove(collectionId, item)
  33. })
  34. )
  35. // TODO reduce collectionVersions to get the most correct version.
  36. return collectionVersions
  37. }