@webiny/api-aco 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.de38392959

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +6 -6
  2. package/apps/AcoApp.d.ts +21 -0
  3. package/apps/AcoApp.js +143 -0
  4. package/apps/AcoApp.js.map +1 -0
  5. package/apps/AcoApps.d.ts +10 -0
  6. package/apps/AcoApps.js +75 -0
  7. package/apps/AcoApps.js.map +1 -0
  8. package/apps/app.gql.d.ts +3 -0
  9. package/apps/app.gql.js +60 -0
  10. package/apps/app.gql.js.map +1 -0
  11. package/apps/index.d.ts +2 -0
  12. package/apps/index.js +29 -0
  13. package/apps/index.js.map +1 -0
  14. package/createAcoContext.d.ts +5 -1
  15. package/createAcoContext.js +159 -28
  16. package/createAcoContext.js.map +1 -1
  17. package/createAcoGraphQL.d.ts +2 -2
  18. package/createAcoGraphQL.js +49 -15
  19. package/createAcoGraphQL.js.map +1 -1
  20. package/createAcoHooks.js +9 -3
  21. package/createAcoHooks.js.map +1 -1
  22. package/createAcoModels.js +6 -44
  23. package/createAcoModels.js.map +1 -1
  24. package/createAcoStorageOperations.d.ts +0 -1
  25. package/createAcoStorageOperations.js +10 -7
  26. package/createAcoStorageOperations.js.map +1 -1
  27. package/filter/filter.crud.d.ts +3 -0
  28. package/filter/filter.crud.js +94 -0
  29. package/filter/filter.crud.js.map +1 -0
  30. package/filter/filter.gql.d.ts +3 -0
  31. package/filter/filter.gql.js +153 -0
  32. package/filter/filter.gql.js.map +1 -0
  33. package/filter/filter.model.d.ts +2 -0
  34. package/filter/filter.model.js +125 -0
  35. package/filter/filter.model.js.map +1 -0
  36. package/filter/filter.so.d.ts +3 -0
  37. package/filter/filter.so.js +98 -0
  38. package/filter/filter.so.js.map +1 -0
  39. package/filter/filter.types.d.ts +95 -0
  40. package/filter/filter.types.js +14 -0
  41. package/filter/filter.types.js.map +1 -0
  42. package/folder/folder.crud.d.ts +8 -1
  43. package/folder/folder.crud.js +201 -4
  44. package/folder/folder.crud.js.map +1 -1
  45. package/folder/folder.gql.js +99 -7
  46. package/folder/folder.gql.js.map +1 -1
  47. package/folder/folder.model.d.ts +2 -4
  48. package/folder/folder.model.js +56 -31
  49. package/folder/folder.model.js.map +1 -1
  50. package/folder/folder.so.d.ts +1 -6
  51. package/folder/folder.so.js +127 -112
  52. package/folder/folder.so.js.map +1 -1
  53. package/folder/folder.types.d.ts +36 -4
  54. package/folder/folder.types.js +3 -1
  55. package/folder/folder.types.js.map +1 -1
  56. package/folder/onFolderBeforeDeleteAco.hook.d.ts +2 -0
  57. package/folder/onFolderBeforeDeleteAco.hook.js +67 -0
  58. package/folder/onFolderBeforeDeleteAco.hook.js.map +1 -0
  59. package/folder/onFolderBeforeDeleteFm.hook.d.ts +2 -0
  60. package/folder/onFolderBeforeDeleteFm.hook.js +49 -0
  61. package/folder/onFolderBeforeDeleteFm.hook.js.map +1 -0
  62. package/folder/onFolderBeforeDeleteHcms.hook.d.ts +2 -0
  63. package/folder/onFolderBeforeDeleteHcms.hook.js +56 -0
  64. package/folder/onFolderBeforeDeleteHcms.hook.js.map +1 -0
  65. package/index.d.ts +9 -1
  66. package/index.js +57 -6
  67. package/index.js.map +1 -1
  68. package/package.json +38 -31
  69. package/plugins/AcoAppModifierPlugin.d.ts +43 -0
  70. package/plugins/AcoAppModifierPlugin.js +58 -0
  71. package/plugins/AcoAppModifierPlugin.js.map +1 -0
  72. package/plugins/AcoAppRegisterPlugin.d.ts +8 -0
  73. package/plugins/AcoAppRegisterPlugin.js +21 -0
  74. package/plugins/AcoAppRegisterPlugin.js.map +1 -0
  75. package/plugins/index.d.ts +2 -0
  76. package/plugins/index.js +29 -0
  77. package/plugins/index.js.map +1 -0
  78. package/record/graphql/createAppResolvers.d.ts +14 -0
  79. package/record/graphql/createAppResolvers.js +115 -0
  80. package/record/graphql/createAppResolvers.js.map +1 -0
  81. package/record/graphql/createAppSchema.d.ts +9 -0
  82. package/record/graphql/createAppSchema.js +147 -0
  83. package/record/graphql/createAppSchema.js.map +1 -0
  84. package/record/record.crud.js +49 -13
  85. package/record/record.crud.js.map +1 -1
  86. package/record/record.gql.d.ts +8 -3
  87. package/record/record.gql.js +38 -113
  88. package/record/record.gql.js.map +1 -1
  89. package/record/record.model.d.ts +8 -4
  90. package/record/record.model.js +44 -33
  91. package/record/record.model.js.map +1 -1
  92. package/record/record.so.d.ts +1 -6
  93. package/record/record.so.js +126 -64
  94. package/record/record.so.js.map +1 -1
  95. package/record/record.types.d.ts +69 -17
  96. package/record/record.types.js +3 -1
  97. package/record/record.types.js.map +1 -1
  98. package/types.d.ts +78 -8
  99. package/types.js +56 -1
  100. package/types.js.map +1 -1
  101. package/utils/FolderLevelPermissions.d.ts +71 -0
  102. package/utils/FolderLevelPermissions.js +353 -0
  103. package/utils/FolderLevelPermissions.js.map +1 -0
  104. package/utils/acoRecordId.d.ts +6 -0
  105. package/utils/acoRecordId.js +35 -0
  106. package/utils/acoRecordId.js.map +1 -0
  107. package/utils/createListSort.d.ts +2 -0
  108. package/utils/createListSort.js +15 -0
  109. package/utils/createListSort.js.map +1 -0
  110. package/utils/createModelField.d.ts +0 -1
  111. package/utils/createModelField.js +5 -5
  112. package/utils/createModelField.js.map +1 -1
  113. package/utils/createOperationsWrapper.d.ts +9 -0
  114. package/utils/createOperationsWrapper.js +31 -0
  115. package/utils/createOperationsWrapper.js.map +1 -0
  116. package/utils/decorators/CmsEntriesCrudDecorators.d.ts +11 -0
  117. package/utils/decorators/CmsEntriesCrudDecorators.js +190 -0
  118. package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -0
  119. package/utils/decorators/constants.d.ts +1 -0
  120. package/utils/decorators/constants.js +10 -0
  121. package/utils/decorators/constants.js.map +1 -0
  122. package/utils/decorators/createFolderType.d.ts +2 -0
  123. package/utils/decorators/createFolderType.js +18 -0
  124. package/utils/decorators/createFolderType.js.map +1 -0
  125. package/utils/decorators/filterEntriesByFolderFactory.d.ts +6 -0
  126. package/utils/decorators/filterEntriesByFolderFactory.js +37 -0
  127. package/utils/decorators/filterEntriesByFolderFactory.js.map +1 -0
  128. package/utils/decorators/isPageModel.d.ts +5 -0
  129. package/utils/decorators/isPageModel.js +20 -0
  130. package/utils/decorators/isPageModel.js.map +1 -0
  131. package/utils/decorators/where.d.ts +15 -0
  132. package/utils/decorators/where.js +60 -0
  133. package/utils/decorators/where.js.map +1 -0
  134. package/utils/ensureAuthentication.d.ts +2 -0
  135. package/utils/ensureAuthentication.js +16 -0
  136. package/utils/ensureAuthentication.js.map +1 -0
  137. package/utils/getFolderAndItsAncestors.d.ts +7 -0
  138. package/utils/getFolderAndItsAncestors.js +53 -0
  139. package/utils/getFolderAndItsAncestors.js.map +1 -0
  140. package/utils/isInstallationPending.js +3 -1
  141. package/utils/isInstallationPending.js.map +1 -1
  142. package/utils/modelFactory.d.ts +2 -4
  143. package/utils/modelFactory.js +7 -8
  144. package/utils/modelFactory.js.map +1 -1
  145. package/utils/pickEntryFieldValues.d.ts +3 -0
  146. package/utils/pickEntryFieldValues.js +31 -0
  147. package/utils/pickEntryFieldValues.js.map +1 -0
  148. package/utils/resolve.d.ts +3 -2
  149. package/utils/resolve.js +13 -2
  150. package/utils/resolve.js.map +1 -1
  151. package/context/folders.d.ts +0 -2
  152. package/context/folders.js +0 -261
  153. package/context/folders.js.map +0 -1
  154. package/context/index.d.ts +0 -2
  155. package/context/index.js +0 -22
  156. package/context/index.js.map +0 -1
  157. package/context/links.d.ts +0 -2
  158. package/context/links.js +0 -270
  159. package/context/links.js.map +0 -1
  160. package/createAcoCrud.d.ts +0 -2
  161. package/createAcoCrud.js +0 -17
  162. package/createAcoCrud.js.map +0 -1
  163. package/createAcoFields.d.ts +0 -2
  164. package/createAcoFields.js +0 -40
  165. package/createAcoFields.js.map +0 -1
  166. package/folder/onFolderBeforeDelete.hook.d.ts +0 -2
  167. package/folder/onFolderBeforeDelete.hook.js +0 -53
  168. package/folder/onFolderBeforeDelete.hook.js.map +0 -1
  169. package/graphql/base.gql.d.ts +0 -3
  170. package/graphql/base.gql.js +0 -63
  171. package/graphql/base.gql.js.map +0 -1
  172. package/graphql/folders.gql.d.ts +0 -3
  173. package/graphql/folders.gql.js +0 -126
  174. package/graphql/folders.gql.js.map +0 -1
  175. package/graphql/index.d.ts +0 -1
  176. package/graphql/index.js +0 -15
  177. package/graphql/index.js.map +0 -1
  178. package/graphql/links.gql.d.ts +0 -3
  179. package/graphql/links.gql.js +0 -123
  180. package/graphql/links.gql.js.map +0 -1
  181. package/subscriptions/afterFolderDelete.d.ts +0 -3
  182. package/subscriptions/afterFolderDelete.js +0 -62
  183. package/subscriptions/afterFolderDelete.js.map +0 -1
  184. package/subscriptions/index.d.ts +0 -3
  185. package/subscriptions/index.js +0 -14
  186. package/subscriptions/index.js.map +0 -1
  187. package/utils/fieldResolver.d.ts +0 -16
  188. package/utils/fieldResolver.js +0 -44
  189. package/utils/fieldResolver.js.map +0 -1
  190. package/utils/getFieldValues.d.ts +0 -2
  191. package/utils/getFieldValues.js +0 -12
  192. package/utils/getFieldValues.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["setupAcoContext","context","tenancy","security","i18n","isInstallationPending","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","getIdentity","aco","createAcoCrud","storageOperations","createAcoStorageOperations","cms","getCmsContext","createAcoContext","ContextPlugin","createAcoHooks"],"sources":["createAcoContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createAcoCrud } from \"~/createAcoCrud\";\nimport { createAcoHooks } from \"~/createAcoHooks\";\nimport { createAcoStorageOperations } from \"~/createAcoStorageOperations\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\n\nimport { AcoContext } from \"~/types\";\n\nconst setupAcoContext = (context: AcoContext) => {\n const { tenancy, security, i18n } = context;\n\n if (isInstallationPending({ tenancy, i18n })) {\n return;\n }\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const getIdentity = () => security.getIdentity();\n\n context.aco = createAcoCrud({\n getLocale,\n getIdentity,\n getTenant,\n storageOperations: createAcoStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context,\n security\n })\n });\n};\n\nexport const createAcoContext = () => {\n return new ContextPlugin<AcoContext>(async context => {\n if (isInstallationPending(context)) {\n return;\n }\n\n await setupAcoContext(context);\n await createAcoHooks(context);\n });\n};\n"],"mappings":";;;;;;;AAAA;AAGA;AAEA;AACA;AACA;AACA;AAIA,MAAMA,eAAe,GAAIC,OAAmB,IAAK;EAC7C,MAAM;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EAAK,CAAC,GAAGH,OAAO;EAE3C,IAAI,IAAAI,4CAAqB,EAAC;IAAEH,OAAO;IAAEE;EAAK,CAAC,CAAC,EAAE;IAC1C;EACJ;EAEA,MAAME,SAAS,GAAG,MAAkB;IAChC,MAAMC,MAAM,GAAGH,IAAI,CAACI,gBAAgB,EAAE;IACtC,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,sDAAsD,EACtD,cAAc,CACjB;IACL;IAEA,OAAOF,MAAM;EACjB,CAAC;EAED,MAAMG,SAAS,GAAG,MAAc;IAC5B,OAAOR,OAAO,CAACS,gBAAgB,EAAE;EACrC,CAAC;EAED,MAAMC,WAAW,GAAG,MAAMT,QAAQ,CAACS,WAAW,EAAE;EAEhDX,OAAO,CAACY,GAAG,GAAG,IAAAC,4BAAa,EAAC;IACxBR,SAAS;IACTM,WAAW;IACXF,SAAS;IACTK,iBAAiB,EAAE,IAAAC,sDAA0B,EAAC;MAC1C;AACZ;AACA;MACYC,GAAG,EAAEhB,OAAO,CAACgB,GAAG;MAChB;AACZ;AACA;MACYC,aAAa,EAAE,MAAMjB,OAAO;MAC5BE;IACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAEM,MAAMgB,gBAAgB,GAAG,MAAM;EAClC,OAAO,IAAIC,kBAAa,CAAa,MAAMnB,OAAO,IAAI;IAClD,IAAI,IAAAI,4CAAqB,EAACJ,OAAO,CAAC,EAAE;MAChC;IACJ;IAEA,MAAMD,eAAe,CAACC,OAAO,CAAC;IAC9B,MAAM,IAAAoB,8BAAc,EAACpB,OAAO,CAAC;EACjC,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_api","_createAcoHooks","_createAcoStorageOperations","_isInstallationPending","_folder","_record","_apps","_record2","_plugins","_FolderLevelPermissions","_CmsEntriesCrudDecorators","_folder2","_createOperationsWrapper","_pickEntryFieldValues","_filter","setupAcoContext","context","setupAcoContextParams","tenancy","security","i18n","getLocale","locale","getContentLocale","WebinyError","getTenant","getCurrentTenant","storageOperations","createAcoStorageOperations","cms","getCmsContext","folderLevelPermissions","FolderLevelPermissions","getIdentity","getIdentityTeam","withoutAuthorization","identity","adminUser","adminUsers","getUser","where","id","team","getTeam","listPermissions","listAllFolders","type","withModel","createOperationsWrapper","modelName","FOLDER_MODEL_ID","model","results","entries","list","limit","latest","sort","items","map","pickEntryFieldValues","canUseTeams","wcp","canUseFolderLevelPermissions","useFolderLevelPermissions","isAuthorizationEnabled","params","defaultRecordModel","getModel","SEARCH_RECORD_MODEL_ID","apps","AcoApps","plugins","byType","AcoAppRegisterPlugin","plugin","register","app","listAdminUsers","listUsers","listTeams","aco","folder","createFolderCrudMethods","search","createSearchRecordCrudMethods","filter","createFilterCrudMethods","getApp","name","get","listApps","registerApp","CmsEntriesCrudDecorators","decorate","createAcoContext","ContextPlugin","isInstallationPending","benchmark","measure","createAcoHooks","exports"],"sources":["createAcoContext.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { createAcoHooks } from \"~/createAcoHooks\";\nimport { createAcoStorageOperations } from \"~/createAcoStorageOperations\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\nimport { AcoContext, CreateAcoParams, Folder, IAcoAppRegisterParams } from \"~/types\";\nimport { createFolderCrudMethods } from \"~/folder/folder.crud\";\nimport { createSearchRecordCrudMethods } from \"~/record/record.crud\";\nimport { AcoApps } from \"./apps\";\nimport { SEARCH_RECORD_MODEL_ID } from \"~/record/record.model\";\nimport { AcoAppRegisterPlugin } from \"~/plugins\";\nimport { FolderLevelPermissions } from \"~/utils/FolderLevelPermissions\";\nimport { CmsEntriesCrudDecorators } from \"~/utils/decorators/CmsEntriesCrudDecorators\";\nimport { FOLDER_MODEL_ID } from \"~/folder/folder.model\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { pickEntryFieldValues } from \"~/utils/pickEntryFieldValues\";\nimport { createFilterCrudMethods } from \"~/filter/filter.crud\";\n\ninterface CreateAcoContextParams {\n useFolderLevelPermissions?: boolean;\n}\n\nconst setupAcoContext = async (\n context: AcoContext,\n setupAcoContextParams: CreateAcoContextParams\n): Promise<void> => {\n const { tenancy, security, i18n } = context;\n\n const getLocale = (): I18NLocale => {\n const locale = i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/plugins/context.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n return locale;\n };\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const storageOperations = createAcoStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n /**\n * TODO: This is required for \"entryFieldFromStorageTransform\" which access plugins from context.\n */\n getCmsContext: () => context,\n security\n });\n\n const folderLevelPermissions = new FolderLevelPermissions({\n getIdentity: () => security.getIdentity(),\n getIdentityTeam: async () => {\n return security.withoutAuthorization(async () => {\n const identity = security.getIdentity();\n if (!identity) {\n return null;\n }\n\n const adminUser = await context.adminUsers.getUser({ where: { id: identity.id } });\n if (!adminUser) {\n return null;\n }\n\n if (!adminUser.team) {\n return null;\n }\n\n return context.security.getTeam({ where: { id: adminUser.team } });\n });\n },\n listPermissions: () => security.listPermissions(),\n listAllFolders: type => {\n // When retrieving a list of all folders, we want to do it in the\n // fastest way and that is by directly using CMS's storage operations.\n const { withModel } = createOperationsWrapper({\n modelName: FOLDER_MODEL_ID,\n cms: context.cms,\n getCmsContext: () => context,\n security\n });\n\n return withModel(async model => {\n const results = await context.cms.storageOperations.entries.list(model, {\n limit: 100_000,\n where: {\n type,\n\n // Folders always work with latest entries. We never publish them.\n latest: true\n },\n sort: [\"title_ASC\"]\n });\n\n return results.items.map(pickEntryFieldValues<Folder>);\n });\n },\n canUseTeams: () => context.wcp.canUseTeams(),\n canUseFolderLevelPermissions: () => {\n if (setupAcoContextParams.useFolderLevelPermissions === false) {\n return false;\n }\n\n return context.wcp.canUseFolderLevelPermissions();\n },\n isAuthorizationEnabled: () => context.security.isAuthorizationEnabled()\n });\n\n const params: CreateAcoParams = {\n getLocale,\n getTenant,\n storageOperations,\n folderLevelPermissions\n };\n\n const defaultRecordModel = await context.security.withoutAuthorization(async () => {\n return context.cms.getModel(SEARCH_RECORD_MODEL_ID);\n });\n\n if (!defaultRecordModel) {\n throw new WebinyError(`There is no default record model in ${SEARCH_RECORD_MODEL_ID}`);\n }\n\n /**\n * First we need to create all the apps.\n */\n const apps = new AcoApps(context, params);\n const plugins = context.plugins.byType<AcoAppRegisterPlugin>(AcoAppRegisterPlugin.type);\n for (const plugin of plugins) {\n await apps.register({\n model: defaultRecordModel,\n ...plugin.app\n });\n }\n\n const listAdminUsers = () => {\n return security.withoutAuthorization(async () => {\n return context.adminUsers.listUsers();\n });\n };\n const listTeams = () => {\n return security.withoutAuthorization(async () => {\n return context.security.listTeams();\n });\n };\n\n context.aco = {\n folder: createFolderCrudMethods({\n ...params,\n listAdminUsers,\n listTeams\n }),\n search: createSearchRecordCrudMethods(params),\n folderLevelPermissions,\n filter: createFilterCrudMethods(params),\n apps,\n getApp: (name: string) => apps.get(name),\n listApps: () => apps.list(),\n registerApp: async (params: IAcoAppRegisterParams) => {\n return apps.register({\n model: defaultRecordModel,\n ...params\n });\n }\n };\n\n if (context.wcp.canUseFolderLevelPermissions()) {\n new CmsEntriesCrudDecorators({ context }).decorate();\n\n // PB decorators registered here: packages/api-page-builder-aco/src/index.ts\n // new PageBuilderCrudDecorators({ context }).decorate();\n }\n};\n\nexport const createAcoContext = (params: CreateAcoContextParams = {}) => {\n const plugin = new ContextPlugin<AcoContext>(async context => {\n /**\n * We can skip the ACO initialization if the installation is pending.\n */\n if (isInstallationPending(context)) {\n return;\n }\n await context.benchmark.measure(\"aco.context.setup\", async () => {\n await setupAcoContext(context, params);\n });\n\n await context.benchmark.measure(\"aco.context.hooks\", async () => {\n await createAcoHooks(context);\n });\n });\n\n plugin.name = \"aco.createContext\";\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAGA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,uBAAA,GAAAV,OAAA;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C;EACN,CAAC,CAAC;EAEF2D,MAAM,CAACc,IAAI,GAAG,mBAAmB;EAEjC,OAAOd,MAAM;AACjB,CAAC;AAAC0B,OAAA,CAAAN,gBAAA,GAAAA,gBAAA"}
@@ -1,3 +1,3 @@
1
- import { ContextPlugin } from "@webiny/api";
1
+ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
2
2
  import { AcoContext } from "./types";
3
- export declare const createAcoGraphQL: () => ContextPlugin<AcoContext>;
3
+ export declare const createAcoGraphQL: () => GraphQLSchemaPlugin<AcoContext>[];
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createAcoGraphQL = void 0;
7
- var _api = require("@webiny/api");
8
7
  var _handlerGraphql = require("@webiny/handler-graphql");
8
+ var _filter = require("./filter/filter.gql");
9
9
  var _folder = require("./folder/folder.gql");
10
- var _record = require("./record/record.gql");
10
+ var _app = require("./apps/app.gql");
11
11
  const emptyResolver = () => ({});
12
12
  const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
13
13
  typeDefs: /* GraphQL */`
@@ -51,15 +51,49 @@ const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
51
51
  error: AcoError
52
52
  }
53
53
 
54
- enum AcoListSort {
55
- id_ASC
56
- id_DESC
57
- savedOn_ASC
58
- savedOn_DESC
59
- createdOn_ASC
60
- createdOn_DESC
61
- title_ASC
62
- title_DESC
54
+ enum AcoSortDirection {
55
+ ASC
56
+ DESC
57
+ }
58
+
59
+ input AcoSort {
60
+ id: AcoSortDirection
61
+ createdOn: AcoSortDirection
62
+ modifiedOn: AcoSortDirection
63
+ savedOn: AcoSortDirection
64
+ title: AcoSortDirection
65
+ }
66
+
67
+ input AcoSearchRecordTagListWhereInput {
68
+ tags_in: [String!]
69
+ tags_startsWith: String
70
+ tags_not_startsWith: String
71
+ createdBy: ID
72
+ AND: [AcoSearchRecordTagListWhereInput!]
73
+ OR: [AcoSearchRecordTagListWhereInput!]
74
+ }
75
+
76
+ type AcoSearchRecordMoveResponse {
77
+ data: Boolean
78
+ error: AcoError
79
+ }
80
+
81
+ type TagItem {
82
+ tag: String!
83
+ count: Int!
84
+ }
85
+
86
+ type AcoSearchRecordTagListResponse {
87
+ data: [TagItem!]
88
+ error: AcoError
89
+ meta: AcoMeta
90
+ }
91
+
92
+ type AcoSearchLocationType {
93
+ folderId: ID!
94
+ }
95
+ input AcoSearchLocationInput {
96
+ folderId: ID!
63
97
  }
64
98
 
65
99
  extend type Query {
@@ -84,8 +118,8 @@ const baseSchema = new _handlerGraphql.GraphQLSchemaPlugin({
84
118
  }
85
119
  });
86
120
  const createAcoGraphQL = () => {
87
- return new _api.ContextPlugin(context => {
88
- context.plugins.register([baseSchema, _folder.folderSchema, _record.searchRecordSchema]);
89
- });
121
+ return [baseSchema, _app.appGql, _folder.folderSchema, _filter.filterSchema];
90
122
  };
91
- exports.createAcoGraphQL = createAcoGraphQL;
123
+ exports.createAcoGraphQL = createAcoGraphQL;
124
+
125
+ //# sourceMappingURL=createAcoGraphQL.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","aco","search","Mutation","createAcoGraphQL","ContextPlugin","context","plugins","register","folderSchema","searchRecordSchema"],"sources":["createAcoGraphQL.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\n\nimport { folderSchema } from \"~/folder/folder.gql\";\nimport { searchRecordSchema } from \"~/record/record.gql\";\n\nimport { AcoContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type AcoQuery {\n _empty: String\n }\n\n type AcoMutation {\n _empty: String\n }\n\n type SearchQuery {\n _empty: String\n }\n\n type SearchMutation {\n _empty: String\n }\n\n type AcoMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n\n type AcoUser {\n id: ID\n displayName: String\n type: String\n }\n\n type AcoError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AcoBooleanResponse {\n data: Boolean\n error: AcoError\n }\n\n enum AcoListSort {\n id_ASC\n id_DESC\n savedOn_ASC\n savedOn_DESC\n createdOn_ASC\n createdOn_DESC\n title_ASC\n title_DESC\n }\n\n extend type Query {\n aco: AcoQuery\n search: SearchQuery\n }\n\n extend type Mutation {\n aco: AcoMutation\n search: SearchMutation\n }\n `,\n resolvers: {\n Query: {\n aco: emptyResolver,\n search: emptyResolver\n },\n Mutation: {\n aco: emptyResolver,\n search: emptyResolver\n }\n }\n});\n\nexport const createAcoGraphQL = () => {\n return new ContextPlugin<AcoContext>(context => {\n context.plugins.register([baseSchema, folderSchema, searchRecordSchema]);\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AACA;AAIA,MAAMA,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ,CAAC;IACDQ,QAAQ,EAAE;MACNF,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ;EACJ;AACJ,CAAC,CAAC;AAEK,MAAMS,gBAAgB,GAAG,MAAM;EAClC,OAAO,IAAIC,kBAAa,CAAaC,OAAO,IAAI;IAC5CA,OAAO,CAACC,OAAO,CAACC,QAAQ,CAAC,CAACZ,UAAU,EAAEa,oBAAY,EAAEC,0BAAkB,CAAC,CAAC;EAC5E,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["_handlerGraphql","require","_filter","_folder","_app","emptyResolver","baseSchema","GraphQLSchemaPlugin","typeDefs","resolvers","Query","aco","search","Mutation","createAcoGraphQL","appGql","folderSchema","filterSchema","exports"],"sources":["createAcoGraphQL.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { filterSchema } from \"~/filter/filter.gql\";\nimport { folderSchema } from \"~/folder/folder.gql\";\nimport { appGql } from \"~/apps/app.gql\";\nimport { AcoContext } from \"~/types\";\n\nconst emptyResolver = () => ({});\n\nconst baseSchema = new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type AcoQuery {\n _empty: String\n }\n\n type AcoMutation {\n _empty: String\n }\n\n type SearchQuery {\n _empty: String\n }\n\n type SearchMutation {\n _empty: String\n }\n\n type AcoMeta {\n hasMoreItems: Boolean\n totalCount: Int\n cursor: String\n }\n\n type AcoUser {\n id: ID\n displayName: String\n type: String\n }\n\n type AcoError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AcoBooleanResponse {\n data: Boolean\n error: AcoError\n }\n\n enum AcoSortDirection {\n ASC\n DESC\n }\n\n input AcoSort {\n id: AcoSortDirection\n createdOn: AcoSortDirection\n modifiedOn: AcoSortDirection\n savedOn: AcoSortDirection\n title: AcoSortDirection\n }\n\n input AcoSearchRecordTagListWhereInput {\n tags_in: [String!]\n tags_startsWith: String\n tags_not_startsWith: String\n createdBy: ID\n AND: [AcoSearchRecordTagListWhereInput!]\n OR: [AcoSearchRecordTagListWhereInput!]\n }\n\n type AcoSearchRecordMoveResponse {\n data: Boolean\n error: AcoError\n }\n\n type TagItem {\n tag: String!\n count: Int!\n }\n\n type AcoSearchRecordTagListResponse {\n data: [TagItem!]\n error: AcoError\n meta: AcoMeta\n }\n\n type AcoSearchLocationType {\n folderId: ID!\n }\n input AcoSearchLocationInput {\n folderId: ID!\n }\n\n extend type Query {\n aco: AcoQuery\n search: SearchQuery\n }\n\n extend type Mutation {\n aco: AcoMutation\n search: SearchMutation\n }\n `,\n resolvers: {\n Query: {\n aco: emptyResolver,\n search: emptyResolver\n },\n Mutation: {\n aco: emptyResolver,\n search: emptyResolver\n }\n }\n});\n\nexport const createAcoGraphQL = (): GraphQLSchemaPlugin<AcoContext>[] => {\n return [baseSchema, appGql, folderSchema, filterSchema];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAGA,MAAMI,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAEhC,MAAMC,UAAU,GAAG,IAAIC,mCAAmB,CAAC;EACvCC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,KAAK,EAAE;MACHC,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ,CAAC;IACDQ,QAAQ,EAAE;MACNF,GAAG,EAAEN,aAAa;MAClBO,MAAM,EAAEP;IACZ;EACJ;AACJ,CAAC,CAAC;AAEK,MAAMS,gBAAgB,GAAGA,CAAA,KAAyC;EACrE,OAAO,CAACR,UAAU,EAAES,WAAM,EAAEC,oBAAY,EAAEC,oBAAY,CAAC;AAC3D,CAAC;AAACC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
package/createAcoHooks.js CHANGED
@@ -4,8 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createAcoHooks = void 0;
7
- var _onFolderBeforeDelete = require("./folder/onFolderBeforeDelete.hook");
7
+ var _onFolderBeforeDeleteAco = require("./folder/onFolderBeforeDeleteAco.hook");
8
+ var _onFolderBeforeDeleteHcms = require("./folder/onFolderBeforeDeleteHcms.hook");
9
+ var _onFolderBeforeDeleteFm = require("./folder/onFolderBeforeDeleteFm.hook");
8
10
  const createAcoHooks = context => {
9
- (0, _onFolderBeforeDelete.onFolderBeforeDeleteHook)(context);
11
+ (0, _onFolderBeforeDeleteAco.onFolderBeforeDeleteAcoHook)(context);
12
+ (0, _onFolderBeforeDeleteHcms.onFolderBeforeDeleteHcmsHook)(context);
13
+ (0, _onFolderBeforeDeleteFm.onFolderBeforeDeleteFmHook)(context);
10
14
  };
11
- exports.createAcoHooks = createAcoHooks;
15
+ exports.createAcoHooks = createAcoHooks;
16
+
17
+ //# sourceMappingURL=createAcoHooks.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAcoHooks","context","onFolderBeforeDeleteHook"],"sources":["createAcoHooks.ts"],"sourcesContent":["import { onFolderBeforeDeleteHook } from \"~/folder/onFolderBeforeDelete.hook\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const createAcoHooks = (context: AcoContext) => {\n onFolderBeforeDeleteHook(context);\n};\n"],"mappings":";;;;;;AAAA;AAIO,MAAMA,cAAc,GAAIC,OAAmB,IAAK;EACnD,IAAAC,8CAAwB,EAACD,OAAO,CAAC;AACrC,CAAC;AAAC"}
1
+ {"version":3,"names":["_onFolderBeforeDeleteAco","require","_onFolderBeforeDeleteHcms","_onFolderBeforeDeleteFm","createAcoHooks","context","onFolderBeforeDeleteAcoHook","onFolderBeforeDeleteHcmsHook","onFolderBeforeDeleteFmHook","exports"],"sources":["createAcoHooks.ts"],"sourcesContent":["import { onFolderBeforeDeleteAcoHook } from \"~/folder/onFolderBeforeDeleteAco.hook\";\nimport { onFolderBeforeDeleteHcmsHook } from \"~/folder/onFolderBeforeDeleteHcms.hook\";\nimport { onFolderBeforeDeleteFmHook } from \"~/folder/onFolderBeforeDeleteFm.hook\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const createAcoHooks = (context: AcoContext) => {\n onFolderBeforeDeleteAcoHook(context);\n onFolderBeforeDeleteHcmsHook(context);\n onFolderBeforeDeleteFmHook(context);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AAIO,MAAMG,cAAc,GAAIC,OAAmB,IAAK;EACnD,IAAAC,oDAA2B,EAACD,OAAO,CAAC;EACpC,IAAAE,sDAA4B,EAACF,OAAO,CAAC;EACrC,IAAAG,kDAA0B,EAACH,OAAO,CAAC;AACvC,CAAC;AAACI,OAAA,CAAAL,cAAA,GAAAA,cAAA"}
@@ -1,59 +1,20 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.createAcoModels = void 0;
8
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
9
- var _error = _interopRequireDefault(require("@webiny/error"));
7
+ var _filter = require("./filter/filter.model");
10
8
  var _folder = require("./folder/folder.model");
11
9
  var _record = require("./record/record.model");
12
10
  var _modelFactory = require("./utils/modelFactory");
13
- var _isInstallationPending = require("./utils/isInstallationPending");
14
11
  const createAcoModels = context => {
15
- /**
16
- * This should never happen in the actual project.
17
- * It is to make sure that we load setup context before the CRUD init in our internal code.
18
- */
19
- if (!context.cms) {
20
- console.warn("Creating model before cms init.");
21
- return;
22
- }
23
- if ((0, _isInstallationPending.isInstallationPending)({
24
- tenancy: context.tenancy,
25
- i18n: context.i18n
26
- })) {
27
- return;
28
- }
29
- context.security.disableAuthorization();
30
- const locale = context.i18n.getContentLocale();
31
- if (!locale) {
32
- throw new _error.default("Missing content locale in api-aco/storageOperations/index.ts", "LOCALE_ERROR");
33
- }
34
- const groupId = "contentModelGroup_aco";
35
-
36
- /**
37
- * Create a CmsGroup.
38
- */
39
- const cmsGroupPlugin = new _apiHeadlessCms.CmsGroupPlugin({
40
- id: groupId,
41
- slug: "aco",
42
- name: "ACO",
43
- description: "Group for Advanced Content Organisation and Search",
44
- icon: "fas/folder",
45
- isPrivate: true
46
- });
47
-
48
12
  /**
49
13
  * Create CmsModel plugins.
50
14
  */
51
- const modelDefinitions = [(0, _folder.createFolderModelDefinition)(), (0, _record.createSearchModelDefinition)()];
15
+ const modelDefinitions = [(0, _folder.createFolderModelDefinition)(), (0, _record.createSearchModelDefinition)(), (0, _filter.createFilterModelDefinition)()];
52
16
  const cmsModelPlugins = modelDefinitions.map(modelDefinition => {
53
17
  return (0, _modelFactory.modelFactory)({
54
- group: cmsGroupPlugin.contentModelGroup,
55
- tenant: context.tenancy.getCurrentTenant().id,
56
- locale: locale.code,
57
18
  modelDefinition
58
19
  });
59
20
  });
@@ -61,7 +22,8 @@ const createAcoModels = context => {
61
22
  /**
62
23
  * Register them so that they are accessible in cms context
63
24
  */
64
- context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);
65
- context.security.enableAuthorization();
25
+ context.plugins.register([cmsModelPlugins]);
66
26
  };
67
- exports.createAcoModels = createAcoModels;
27
+ exports.createAcoModels = createAcoModels;
28
+
29
+ //# sourceMappingURL=createAcoModels.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAcoModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","security","disableAuthorization","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","modelDefinitions","createFolderModelDefinition","createSearchModelDefinition","cmsModelPlugins","map","modelDefinition","modelFactory","group","contentModelGroup","tenant","getCurrentTenant","code","plugins","register","enableAuthorization"],"sources":["createAcoModels.ts"],"sourcesContent":["import { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createFolderModelDefinition } from \"~/folder/folder.model\";\nimport { createSearchModelDefinition } from \"~/record/record.model\";\nimport { modelFactory } from \"~/utils/modelFactory\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\n\nexport const createAcoModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n context.security.disableAuthorization();\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n const groupId = \"contentModelGroup_aco\";\n\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"aco\",\n name: \"ACO\",\n description: \"Group for Advanced Content Organisation and Search\",\n icon: \"fas/folder\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const modelDefinitions = [createFolderModelDefinition(), createSearchModelDefinition()];\n const cmsModelPlugins = modelDefinitions.map(modelDefinition => {\n return modelFactory({\n group: cmsGroupPlugin.contentModelGroup,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: locale.code,\n modelDefinition\n });\n });\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cms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BN;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;EACI1B,OAAO,CAACiC,OAAO,CAACC,QAAQ,CAAC,CAACrB,cAAc,EAAEW,eAAe,CAAC,CAAC;EAE3DxB,OAAO,CAACO,QAAQ,CAAC4B,mBAAmB,EAAE;AAC1C,CAAC;AAAC"}
1
+ {"version":3,"names":["_filter","require","_folder","_record","_modelFactory","createAcoModels","context","modelDefinitions","createFolderModelDefinition","createSearchModelDefinition","createFilterModelDefinition","cmsModelPlugins","map","modelDefinition","modelFactory","plugins","register","exports"],"sources":["createAcoModels.ts"],"sourcesContent":["import { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { createFilterModelDefinition } from \"~/filter/filter.model\";\nimport { createFolderModelDefinition } from \"~/folder/folder.model\";\nimport { createSearchModelDefinition } from \"~/record/record.model\";\nimport { modelFactory } from \"~/utils/modelFactory\";\n\nexport const createAcoModels = (context: CmsContext) => {\n /**\n * Create CmsModel plugins.\n */\n const modelDefinitions = [\n createFolderModelDefinition(),\n createSearchModelDefinition(),\n createFilterModelDefinition()\n ];\n const cmsModelPlugins = modelDefinitions.map(modelDefinition => {\n return modelFactory({\n modelDefinition\n });\n });\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsModelPlugins]);\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEO,MAAMI,eAAe,GAAIC,OAAmB,IAAK;EACpD;AACJ;AACA;EACI,MAAMC,gBAAgB,GAAG,CACrB,IAAAC,mCAA2B,EAAC,CAAC,EAC7B,IAAAC,mCAA2B,EAAC,CAAC,EAC7B,IAAAC,mCAA2B,EAAC,CAAC,CAChC;EACD,MAAMC,eAAe,GAAGJ,gBAAgB,CAACK,GAAG,CAACC,eAAe,IAAI;IAC5D,OAAO,IAAAC,0BAAY,EAAC;MAChBD;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;EACIP,OAAO,CAACS,OAAO,CAACC,QAAQ,CAAC,CAACL,eAAe,CAAC,CAAC;AAC/C,CAAC;AAACM,OAAA,CAAAZ,eAAA,GAAAA,eAAA"}
@@ -6,5 +6,4 @@ export interface CreateAcoStorageOperationsParams {
6
6
  security: Security;
7
7
  getCmsContext: () => CmsContext;
8
8
  }
9
- export declare const baseFields: string[];
10
9
  export declare const createAcoStorageOperations: (params: CreateAcoStorageOperationsParams) => AcoStorageOperations;
@@ -1,19 +1,22 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.createAcoStorageOperations = exports.baseFields = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
6
+ exports.createAcoStorageOperations = void 0;
7
+ var _filter = require("./filter/filter.so");
9
8
  var _folder = require("./folder/folder.so");
10
9
  var _record = require("./record/record.so");
11
10
  var _createAcoModels = require("./createAcoModels");
12
- const baseFields = ["id", "entryId", "createdBy", "createdOn", "savedOn"];
13
- exports.baseFields = baseFields;
14
11
  const createAcoStorageOperations = params => {
15
12
  const context = params.getCmsContext();
16
13
  (0, _createAcoModels.createAcoModels)(context);
17
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _folder.createFolderOperations)(params)), (0, _record.createSearchRecordOperations)(params));
14
+ return {
15
+ ...(0, _folder.createFolderOperations)(params),
16
+ ...(0, _record.createSearchRecordOperations)(params),
17
+ ...(0, _filter.createFilterOperations)(params)
18
+ };
18
19
  };
19
- exports.createAcoStorageOperations = createAcoStorageOperations;
20
+ exports.createAcoStorageOperations = createAcoStorageOperations;
21
+
22
+ //# sourceMappingURL=createAcoStorageOperations.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["baseFields","createAcoStorageOperations","params","context","getCmsContext","createAcoModels","createFolderOperations","createSearchRecordOperations"],"sources":["createAcoStorageOperations.ts"],"sourcesContent":["import { CmsContext, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\nimport { createFolderOperations } from \"~/folder/folder.so\";\nimport { createSearchRecordOperations } from \"~/record/record.so\";\nimport { createAcoModels } from \"~/createAcoModels\";\n\nimport { AcoStorageOperations } from \"~/types\";\n\nexport interface CreateAcoStorageOperationsParams {\n cms: HeadlessCms;\n security: Security;\n getCmsContext: () => CmsContext;\n}\n\nexport const baseFields = [\"id\", \"entryId\", \"createdBy\", \"createdOn\", \"savedOn\"];\n\nexport const createAcoStorageOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoStorageOperations => {\n const context = params.getCmsContext();\n\n createAcoModels(context);\n\n return {\n ...createFolderOperations(params),\n ...createSearchRecordOperations(params)\n };\n};\n"],"mappings":";;;;;;;;AAGA;AACA;AACA;AAUO,MAAMA,UAAU,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,CAAC;AAAC;AAE1E,MAAMC,0BAA0B,GACnCC,MAAwC,IACjB;EACvB,MAAMC,OAAO,GAAGD,MAAM,CAACE,aAAa,EAAE;EAEtC,IAAAC,gCAAe,EAACF,OAAO,CAAC;EAExB,mEACO,IAAAG,8BAAsB,EAACJ,MAAM,CAAC,GAC9B,IAAAK,oCAA4B,EAACL,MAAM,CAAC;AAE/C,CAAC;AAAC"}
1
+ {"version":3,"names":["_filter","require","_folder","_record","_createAcoModels","createAcoStorageOperations","params","context","getCmsContext","createAcoModels","createFolderOperations","createSearchRecordOperations","createFilterOperations","exports"],"sources":["createAcoStorageOperations.ts"],"sourcesContent":["import { CmsContext, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\n\nimport { createFilterOperations } from \"~/filter/filter.so\";\nimport { createFolderOperations } from \"~/folder/folder.so\";\nimport { createSearchRecordOperations } from \"~/record/record.so\";\nimport { createAcoModels } from \"~/createAcoModels\";\n\nimport { AcoStorageOperations } from \"~/types\";\n\nexport interface CreateAcoStorageOperationsParams {\n cms: HeadlessCms;\n security: Security;\n getCmsContext: () => CmsContext;\n}\n\nexport const createAcoStorageOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoStorageOperations => {\n const context = params.getCmsContext();\n\n createAcoModels(context);\n\n return {\n ...createFolderOperations(params),\n ...createSearchRecordOperations(params),\n ...createFilterOperations(params)\n };\n};\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAUO,MAAMI,0BAA0B,GACnCC,MAAwC,IACjB;EACvB,MAAMC,OAAO,GAAGD,MAAM,CAACE,aAAa,CAAC,CAAC;EAEtC,IAAAC,gCAAe,EAACF,OAAO,CAAC;EAExB,OAAO;IACH,GAAG,IAAAG,8BAAsB,EAACJ,MAAM,CAAC;IACjC,GAAG,IAAAK,oCAA4B,EAACL,MAAM,CAAC;IACvC,GAAG,IAAAM,8BAAsB,EAACN,MAAM;EACpC,CAAC;AACL,CAAC;AAACO,OAAA,CAAAR,0BAAA,GAAAA,0BAAA"}
@@ -0,0 +1,3 @@
1
+ import { CreateAcoParams } from "../types";
2
+ import { AcoFilterCrud } from "./filter.types";
3
+ export declare const createFilterCrudMethods: ({ storageOperations }: CreateAcoParams) => AcoFilterCrud;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFilterCrudMethods = void 0;
7
+ var _pubsub = require("@webiny/pubsub");
8
+ const createFilterCrudMethods = ({
9
+ storageOperations
10
+ }) => {
11
+ // create
12
+ const onFilterBeforeCreate = (0, _pubsub.createTopic)("aco.onFilterBeforeCreate");
13
+ const onFilterAfterCreate = (0, _pubsub.createTopic)("aco.onFilterAfterCreate");
14
+ // update
15
+ const onFilterBeforeUpdate = (0, _pubsub.createTopic)("aco.onFilterBeforeUpdate");
16
+ const onFilterAfterUpdate = (0, _pubsub.createTopic)("aco.onFilterAfterUpdate");
17
+ // delete
18
+ const onFilterBeforeDelete = (0, _pubsub.createTopic)("aco.onFilterBeforeDelete");
19
+ const onFilterAfterDelete = (0, _pubsub.createTopic)("aco.onFilterAfterDelete");
20
+ return {
21
+ /**
22
+ * Lifecycle events
23
+ */
24
+ onFilterBeforeCreate,
25
+ onFilterAfterCreate,
26
+ onFilterBeforeUpdate,
27
+ onFilterAfterUpdate,
28
+ onFilterBeforeDelete,
29
+ onFilterAfterDelete,
30
+ async get(id) {
31
+ return storageOperations.getFilter({
32
+ id
33
+ });
34
+ },
35
+ async list(params) {
36
+ return storageOperations.listFilters(params);
37
+ },
38
+ async create(data) {
39
+ await onFilterBeforeCreate.publish({
40
+ input: data
41
+ });
42
+ const filter = await storageOperations.createFilter({
43
+ data
44
+ });
45
+ await onFilterAfterCreate.publish({
46
+ filter
47
+ });
48
+ return filter;
49
+ },
50
+ async update(id, data) {
51
+ const original = await storageOperations.getFilter({
52
+ id
53
+ });
54
+ await onFilterBeforeUpdate.publish({
55
+ original,
56
+ input: {
57
+ id,
58
+ data
59
+ }
60
+ });
61
+ const filter = await storageOperations.updateFilter({
62
+ id,
63
+ data
64
+ });
65
+ await onFilterAfterUpdate.publish({
66
+ original,
67
+ input: {
68
+ id,
69
+ data
70
+ },
71
+ filter
72
+ });
73
+ return filter;
74
+ },
75
+ async delete(id) {
76
+ const filter = await storageOperations.getFilter({
77
+ id
78
+ });
79
+ await onFilterBeforeDelete.publish({
80
+ filter
81
+ });
82
+ await storageOperations.deleteFilter({
83
+ id
84
+ });
85
+ await onFilterAfterDelete.publish({
86
+ filter
87
+ });
88
+ return true;
89
+ }
90
+ };
91
+ };
92
+ exports.createFilterCrudMethods = createFilterCrudMethods;
93
+
94
+ //# sourceMappingURL=filter.crud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_pubsub","require","createFilterCrudMethods","storageOperations","onFilterBeforeCreate","createTopic","onFilterAfterCreate","onFilterBeforeUpdate","onFilterAfterUpdate","onFilterBeforeDelete","onFilterAfterDelete","get","id","getFilter","list","params","listFilters","create","data","publish","input","filter","createFilter","update","original","updateFilter","delete","deleteFilter","exports"],"sources":["filter.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\n\nimport { CreateAcoParams } from \"~/types\";\nimport {\n AcoFilterCrud,\n OnFilterAfterCreateTopicParams,\n OnFilterAfterDeleteTopicParams,\n OnFilterAfterUpdateTopicParams,\n OnFilterBeforeCreateTopicParams,\n OnFilterBeforeDeleteTopicParams,\n OnFilterBeforeUpdateTopicParams\n} from \"./filter.types\";\n\nexport const createFilterCrudMethods = ({ storageOperations }: CreateAcoParams): AcoFilterCrud => {\n // create\n const onFilterBeforeCreate = createTopic<OnFilterBeforeCreateTopicParams>(\n \"aco.onFilterBeforeCreate\"\n );\n const onFilterAfterCreate =\n createTopic<OnFilterAfterCreateTopicParams>(\"aco.onFilterAfterCreate\");\n // update\n const onFilterBeforeUpdate = createTopic<OnFilterBeforeUpdateTopicParams>(\n \"aco.onFilterBeforeUpdate\"\n );\n const onFilterAfterUpdate =\n createTopic<OnFilterAfterUpdateTopicParams>(\"aco.onFilterAfterUpdate\");\n // delete\n const onFilterBeforeDelete = createTopic<OnFilterBeforeDeleteTopicParams>(\n \"aco.onFilterBeforeDelete\"\n );\n const onFilterAfterDelete =\n createTopic<OnFilterAfterDeleteTopicParams>(\"aco.onFilterAfterDelete\");\n\n return {\n /**\n * Lifecycle events\n */\n onFilterBeforeCreate,\n onFilterAfterCreate,\n onFilterBeforeUpdate,\n onFilterAfterUpdate,\n onFilterBeforeDelete,\n onFilterAfterDelete,\n async get(id) {\n return storageOperations.getFilter({ id });\n },\n async list(params) {\n return storageOperations.listFilters(params);\n },\n async create(data) {\n await onFilterBeforeCreate.publish({ input: data });\n const filter = await storageOperations.createFilter({ data });\n await onFilterAfterCreate.publish({ filter });\n return filter;\n },\n async update(id, data) {\n const original = await storageOperations.getFilter({ id });\n await onFilterBeforeUpdate.publish({ original, input: { id, data } });\n const filter = await storageOperations.updateFilter({ id, data });\n await onFilterAfterUpdate.publish({ original, input: { id, data }, filter });\n return filter;\n },\n async delete(id: string) {\n const filter = await storageOperations.getFilter({ id });\n await onFilterBeforeDelete.publish({ filter });\n await storageOperations.deleteFilter({ id });\n await onFilterAfterDelete.publish({ filter });\n return true;\n }\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAaO,MAAMC,uBAAuB,GAAGA,CAAC;EAAEC;AAAmC,CAAC,KAAoB;EAC9F;EACA,MAAMC,oBAAoB,GAAG,IAAAC,mBAAW,EACpC,0BACJ,CAAC;EACD,MAAMC,mBAAmB,GACrB,IAAAD,mBAAW,EAAiC,yBAAyB,CAAC;EAC1E;EACA,MAAME,oBAAoB,GAAG,IAAAF,mBAAW,EACpC,0BACJ,CAAC;EACD,MAAMG,mBAAmB,GACrB,IAAAH,mBAAW,EAAiC,yBAAyB,CAAC;EAC1E;EACA,MAAMI,oBAAoB,GAAG,IAAAJ,mBAAW,EACpC,0BACJ,CAAC;EACD,MAAMK,mBAAmB,GACrB,IAAAL,mBAAW,EAAiC,yBAAyB,CAAC;EAE1E,OAAO;IACH;AACR;AACA;IACQD,oBAAoB;IACpBE,mBAAmB;IACnBC,oBAAoB;IACpBC,mBAAmB;IACnBC,oBAAoB;IACpBC,mBAAmB;IACnB,MAAMC,GAAGA,CAACC,EAAE,EAAE;MACV,OAAOT,iBAAiB,CAACU,SAAS,CAAC;QAAED;MAAG,CAAC,CAAC;IAC9C,CAAC;IACD,MAAME,IAAIA,CAACC,MAAM,EAAE;MACf,OAAOZ,iBAAiB,CAACa,WAAW,CAACD,MAAM,CAAC;IAChD,CAAC;IACD,MAAME,MAAMA,CAACC,IAAI,EAAE;MACf,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from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin";
2
+ import { AcoContext } from "../types";
3
+ export declare const filterSchema: GraphQLSchemaPlugin<AcoContext>;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterSchema = void 0;
7
+ var _responses = require("@webiny/handler-graphql/responses");
8
+ var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
9
+ var _ensureAuthentication = require("../utils/ensureAuthentication");
10
+ var _resolve = require("../utils/resolve");
11
+ const filterSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
12
+ typeDefs: /* GraphQL */`
13
+ enum OperationEnum {
14
+ AND
15
+ OR
16
+ }
17
+
18
+ type GroupFilter {
19
+ field: String!
20
+ condition: String!
21
+ value: String!
22
+ }
23
+
24
+ type Group {
25
+ operation: OperationEnum!
26
+ filters: [GroupFilter]!
27
+ }
28
+
29
+ type Filter {
30
+ id: ID!
31
+ name: String!
32
+ description: String
33
+ namespace: String!
34
+ operation: OperationEnum!
35
+ groups: [Group]!
36
+ createdOn: DateTime
37
+ modifiedOn: DateTime
38
+ savedOn: DateTime
39
+ createdBy: AcoUser
40
+ modifiedBy: AcoUser
41
+ savedBy: AcoUser
42
+ }
43
+
44
+ input GroupFilterInput {
45
+ field: String!
46
+ condition: String!
47
+ value: String!
48
+ }
49
+
50
+ input GroupInput {
51
+ operation: OperationEnum!
52
+ filters: [GroupFilterInput]!
53
+ }
54
+
55
+ input FilterCreateInput {
56
+ id: ID!
57
+ name: String!
58
+ description: String
59
+ namespace: String!
60
+ operation: OperationEnum!
61
+ groups: [GroupInput]!
62
+ }
63
+
64
+ input FilterUpdateInput {
65
+ name: String
66
+ description: String
67
+ namespace: String
68
+ operation: OperationEnum
69
+ groups: [GroupInput]
70
+ }
71
+
72
+ input FiltersListWhereInput {
73
+ namespace: String
74
+ }
75
+
76
+ type FilterResponse {
77
+ data: Filter
78
+ error: AcoError
79
+ }
80
+
81
+ type FilterListResponse {
82
+ data: [Filter]
83
+ error: AcoError
84
+ }
85
+
86
+ extend type AcoQuery {
87
+ getFilter(id: ID!): FilterResponse
88
+ listFilters(
89
+ where: FiltersListWhereInput!
90
+ limit: Int
91
+ after: String
92
+ sort: AcoSort
93
+ ): FilterListResponse
94
+ }
95
+
96
+ extend type AcoMutation {
97
+ createFilter(data: FilterCreateInput!): FilterResponse
98
+ updateFilter(id: ID!, data: FilterUpdateInput!): FilterResponse
99
+ deleteFilter(id: ID!): AcoBooleanResponse
100
+ }
101
+ `,
102
+ resolvers: {
103
+ AcoQuery: {
104
+ getFilter: async (_, {
105
+ id
106
+ }, context) => {
107
+ return (0, _resolve.resolve)(() => {
108
+ (0, _ensureAuthentication.ensureAuthentication)(context);
109
+ return context.aco.filter.get(id);
110
+ });
111
+ },
112
+ listFilters: async (_, args, context) => {
113
+ try {
114
+ (0, _ensureAuthentication.ensureAuthentication)(context);
115
+ const [entries, meta] = await context.aco.filter.list(args);
116
+ return new _responses.ListResponse(entries, meta);
117
+ } catch (e) {
118
+ return new _responses.ErrorResponse(e);
119
+ }
120
+ }
121
+ },
122
+ AcoMutation: {
123
+ createFilter: async (_, {
124
+ data
125
+ }, context) => {
126
+ return (0, _resolve.resolve)(() => {
127
+ (0, _ensureAuthentication.ensureAuthentication)(context);
128
+ return context.aco.filter.create(data);
129
+ });
130
+ },
131
+ updateFilter: async (_, {
132
+ id,
133
+ data
134
+ }, context) => {
135
+ return (0, _resolve.resolve)(() => {
136
+ (0, _ensureAuthentication.ensureAuthentication)(context);
137
+ return context.aco.filter.update(id, data);
138
+ });
139
+ },
140
+ deleteFilter: async (_, {
141
+ id
142
+ }, context) => {
143
+ return (0, _resolve.resolve)(() => {
144
+ (0, _ensureAuthentication.ensureAuthentication)(context);
145
+ return context.aco.filter.delete(id);
146
+ });
147
+ }
148
+ }
149
+ }
150
+ });
151
+ exports.filterSchema = filterSchema;
152
+
153
+ //# sourceMappingURL=filter.gql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_responses","require","_GraphQLSchemaPlugin","_ensureAuthentication","_resolve","filterSchema","GraphQLSchemaPlugin","typeDefs","resolvers","AcoQuery","getFilter","_","id","context","resolve","ensureAuthentication","aco","filter","get","listFilters","args","entries","meta","list","ListResponse","e","ErrorResponse","AcoMutation","createFilter","data","create","updateFilter","update","deleteFilter","delete","exports"],"sources":["filter.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\n\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication\";\nimport { resolve } from \"~/utils/resolve\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const filterSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n enum OperationEnum {\n AND\n OR\n }\n\n type GroupFilter {\n field: String!\n condition: String!\n value: String!\n }\n\n type Group {\n operation: OperationEnum!\n filters: [GroupFilter]!\n }\n\n type Filter {\n id: ID!\n name: String!\n description: String\n namespace: String!\n operation: OperationEnum!\n groups: [Group]!\n createdOn: DateTime\n modifiedOn: DateTime\n savedOn: DateTime\n createdBy: AcoUser\n modifiedBy: AcoUser\n savedBy: AcoUser\n }\n\n input GroupFilterInput {\n field: String!\n condition: String!\n value: String!\n }\n\n input GroupInput {\n operation: OperationEnum!\n filters: [GroupFilterInput]!\n }\n\n input FilterCreateInput {\n id: ID!\n name: String!\n description: String\n namespace: String!\n operation: OperationEnum!\n groups: [GroupInput]!\n }\n\n input FilterUpdateInput {\n name: String\n description: String\n namespace: String\n operation: OperationEnum\n groups: [GroupInput]\n }\n\n input FiltersListWhereInput {\n namespace: String\n }\n\n type FilterResponse {\n data: Filter\n error: AcoError\n }\n\n type FilterListResponse {\n data: [Filter]\n error: AcoError\n }\n\n extend type AcoQuery {\n getFilter(id: ID!): FilterResponse\n listFilters(\n where: FiltersListWhereInput!\n limit: Int\n after: String\n sort: AcoSort\n ): FilterListResponse\n }\n\n extend type AcoMutation {\n createFilter(data: FilterCreateInput!): FilterResponse\n updateFilter(id: ID!, data: FilterUpdateInput!): FilterResponse\n deleteFilter(id: ID!): AcoBooleanResponse\n }\n `,\n resolvers: {\n AcoQuery: {\n getFilter: async (_, { id }, context) => {\n return resolve(() => {\n ensureAuthentication(context);\n return context.aco.filter.get(id);\n });\n },\n listFilters: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const [entries, meta] = await context.aco.filter.list(args);\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFilter: async (_, { data }, context) => {\n return resolve(() => {\n ensureAuthentication(context);\n return context.aco.filter.create(data);\n });\n },\n updateFilter: async (_, { id, data }, context) => {\n return resolve(() => {\n ensureAuthentication(context);\n return context.aco.filter.update(id, data);\n });\n },\n deleteFilter: async (_, { id }, context) => {\n return resolve(() => {\n ensureAuthentication(context);\n return context.aco.filter.delete(id);\n });\n }\n }\n }\n});\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAIO,MAAMI,YAAY,GAAG,IAAIC,wCAAmB,CAAa;EAC5DC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AM;UACjB,IAAAC,0CAAoB,EAACF,OAAO,CAAC;UAC7B,OAAOA,OAAO,CAACG,GAAG,CAACC,MAAM,CAACe,MAAM,CAACpB,EAAE,EAAEiB,IAAI,CAAC;QAC9C,CAAC,CAAC;MACN,CAAC;MACDI,YAAY,EAAE,MAAAA,CAAOtB,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACxC,OAAO,IAAAC,gBAAO,EAAC,MAAM;UACjB,IAAAC,0CAAoB,EAACF,OAAO,CAAC;UAC7B,OAAOA,OAAO,CAACG,GAAG,CAACC,MAAM,CAACiB,MAAM,CAACtB,EAAE,CAAC;QACxC,CAAC,CAAC;MACN;IACJ;EACJ;AACJ,CAAC,CAAC;AAACuB,OAAA,CAAA9B,YAAA,GAAAA,YAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const FILTER_MODEL_ID = "acoFilter";
2
+ export declare const createFilterModelDefinition: () => import("@webiny/api-headless-cms").CmsPrivateModelFull;