Zeichen's app for both server and client.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

47 líneas
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. }