@webiny/api-aco 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7

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 (241) hide show
  1. package/AcoFeature.d.ts +5 -0
  2. package/AcoFeature.js +134 -0
  3. package/AcoFeature.js.map +1 -0
  4. package/AcoFolderSchemaFactory.d.ts +32 -0
  5. package/AcoFolderSchemaFactory.js +82 -0
  6. package/AcoFolderSchemaFactory.js.map +1 -0
  7. package/createAcoGraphQL.d.ts +8 -4
  8. package/createAcoGraphQL.js +56 -96
  9. package/createAcoGraphQL.js.map +1 -1
  10. package/domain/folder/abstractions.d.ts +12 -5
  11. package/domain/folder/abstractions.js +2 -2
  12. package/domain/folder/abstractions.js.map +1 -1
  13. package/domain/folder/folder.model.js +2 -1
  14. package/domain/folder/folder.model.js.map +1 -1
  15. package/exports/api/aco/flp.d.ts +1 -0
  16. package/exports/api/aco/flp.js +1 -0
  17. package/exports/api/aco/folder.d.ts +2 -1
  18. package/exports/api/aco/folder.js +1 -1
  19. package/features/ai/CreateFolderTool.d.ts +49 -0
  20. package/features/ai/CreateFolderTool.js +58 -0
  21. package/features/ai/CreateFolderTool.js.map +1 -0
  22. package/features/ai/CreateTeamTool.d.ts +48 -0
  23. package/features/ai/CreateTeamTool.js +56 -0
  24. package/features/ai/CreateTeamTool.js.map +1 -0
  25. package/features/ai/DeleteFolderTool.d.ts +48 -0
  26. package/features/ai/DeleteFolderTool.js +55 -0
  27. package/features/ai/DeleteFolderTool.js.map +1 -0
  28. package/features/ai/GrantFolderAccessTool.d.ts +77 -0
  29. package/features/ai/GrantFolderAccessTool.js +80 -0
  30. package/features/ai/GrantFolderAccessTool.js.map +1 -0
  31. package/features/ai/ListFoldersTool.d.ts +47 -0
  32. package/features/ai/ListFoldersTool.js +57 -0
  33. package/features/ai/ListFoldersTool.js.map +1 -0
  34. package/features/ai/ListRolesTool.d.ts +39 -0
  35. package/features/ai/ListRolesTool.js +48 -0
  36. package/features/ai/ListRolesTool.js.map +1 -0
  37. package/features/ai/ListTeamsTool.d.ts +39 -0
  38. package/features/ai/ListTeamsTool.js +48 -0
  39. package/features/ai/ListTeamsTool.js.map +1 -0
  40. package/features/ai/RevokeFolderAccessTool.d.ts +63 -0
  41. package/features/ai/RevokeFolderAccessTool.js +69 -0
  42. package/features/ai/RevokeFolderAccessTool.js.map +1 -0
  43. package/features/ai/assertTargetIsUsable.d.ts +10 -0
  44. package/features/ai/assertTargetIsUsable.js +14 -0
  45. package/features/ai/assertTargetIsUsable.js.map +1 -0
  46. package/features/ai/feature.d.ts +12 -0
  47. package/features/ai/feature.js +25 -0
  48. package/features/ai/feature.js.map +1 -0
  49. package/features/ai/index.d.ts +9 -0
  50. package/features/ai/index.js +9 -0
  51. package/features/ai/loadFolderPermissions.d.ts +16 -0
  52. package/features/ai/loadFolderPermissions.js +14 -0
  53. package/features/ai/loadFolderPermissions.js.map +1 -0
  54. package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js +1 -0
  55. package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js.map +1 -1
  56. package/features/cms/decorators/ListEntriesWithFlpDecorator.js +1 -0
  57. package/features/cms/decorators/ListEntriesWithFlpDecorator.js.map +1 -1
  58. package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js +1 -0
  59. package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js.map +1 -1
  60. package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js +1 -0
  61. package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js.map +1 -1
  62. package/features/cms/decorators/MoveEntryWithFlpDecorator.d.ts +1 -1
  63. package/features/flp/CreateFlp/CreateFlpUseCase.d.ts +3 -3
  64. package/features/flp/CreateFlp/CreateFlpUseCase.js +4 -4
  65. package/features/flp/CreateFlp/CreateFlpUseCase.js.map +1 -1
  66. package/features/flp/CreateFlp/feature.d.ts +1 -6
  67. package/features/flp/CreateFlp/feature.js +3 -2
  68. package/features/flp/CreateFlp/feature.js.map +1 -1
  69. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.d.ts +8 -5
  70. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js +21 -14
  71. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js.map +1 -1
  72. package/features/flp/DeleteFlp/DeleteFlpUseCase.d.ts +3 -3
  73. package/features/flp/DeleteFlp/DeleteFlpUseCase.js +3 -3
  74. package/features/flp/DeleteFlp/DeleteFlpUseCase.js.map +1 -1
  75. package/features/flp/DeleteFlp/feature.d.ts +1 -6
  76. package/features/flp/DeleteFlp/feature.js +3 -2
  77. package/features/flp/DeleteFlp/feature.js.map +1 -1
  78. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.d.ts +6 -5
  79. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js +16 -13
  80. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js.map +1 -1
  81. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.d.ts +3 -3
  82. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +6 -6
  83. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
  84. package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.d.ts +25 -0
  85. package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js +48 -0
  86. package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js.map +1 -0
  87. package/features/flp/FolderLevelPermissions/index.d.ts +1 -0
  88. package/features/flp/FolderLevelPermissions/index.js +1 -0
  89. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.d.ts +13 -0
  90. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js +26 -0
  91. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js.map +1 -0
  92. package/features/flp/GetFlp/feature.d.ts +1 -1
  93. package/features/flp/GetFlp/feature.js +3 -2
  94. package/features/flp/GetFlp/feature.js.map +1 -1
  95. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.d.ts +13 -0
  96. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js +27 -0
  97. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js.map +1 -0
  98. package/features/flp/ListFlps/feature.d.ts +1 -1
  99. package/features/flp/ListFlps/feature.js +3 -2
  100. package/features/flp/ListFlps/feature.js.map +1 -1
  101. package/features/flp/UpdateFlp/UpdateFlpUseCase.d.ts +15 -8
  102. package/features/flp/UpdateFlp/UpdateFlpUseCase.js +37 -42
  103. package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
  104. package/features/flp/UpdateFlp/abstractions.d.ts +6 -2
  105. package/features/flp/UpdateFlp/abstractions.js.map +1 -1
  106. package/features/flp/UpdateFlp/feature.d.ts +1 -6
  107. package/features/flp/UpdateFlp/feature.js +7 -2
  108. package/features/flp/UpdateFlp/feature.js.map +1 -1
  109. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.d.ts +8 -5
  110. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js +21 -16
  111. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js.map +1 -1
  112. package/features/flp/shared/CodeFlpMerger.d.ts +26 -0
  113. package/features/flp/shared/CodeFlpMerger.js +20 -0
  114. package/features/flp/shared/CodeFlpMerger.js.map +1 -0
  115. package/features/flp/shared/CodeFlpPath.d.ts +15 -0
  116. package/features/flp/shared/CodeFlpPath.js +29 -0
  117. package/features/flp/shared/CodeFlpPath.js.map +1 -0
  118. package/features/flp/shared/CodeFlpTarget.d.ts +10 -0
  119. package/features/flp/shared/CodeFlpTarget.js +26 -0
  120. package/features/flp/shared/CodeFlpTarget.js.map +1 -0
  121. package/features/flp/shared/CodeFlpsProvider.d.ts +14 -0
  122. package/features/flp/shared/CodeFlpsProvider.js +33 -0
  123. package/features/flp/shared/CodeFlpsProvider.js.map +1 -0
  124. package/features/flp/shared/abstractions.d.ts +77 -0
  125. package/features/flp/shared/abstractions.js +19 -0
  126. package/features/flp/shared/abstractions.js.map +1 -0
  127. package/features/flp/shared/feature.d.ts +5 -0
  128. package/features/flp/shared/feature.js +17 -0
  129. package/features/flp/shared/feature.js.map +1 -0
  130. package/features/flp/shared/index.d.ts +4 -0
  131. package/features/flp/shared/index.js +4 -0
  132. package/features/folder/CreateFolder/CreateFolderRepository.d.ts +3 -3
  133. package/features/folder/CreateFolder/CreateFolderRepository.js +10 -7
  134. package/features/folder/CreateFolder/CreateFolderRepository.js.map +1 -1
  135. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.d.ts +9 -1
  136. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js +20 -3
  137. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js.map +1 -1
  138. package/features/folder/DeleteFolder/DeleteFolderRepository.d.ts +3 -3
  139. package/features/folder/DeleteFolder/DeleteFolderRepository.js +6 -5
  140. package/features/folder/DeleteFolder/DeleteFolderRepository.js.map +1 -1
  141. package/features/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.d.ts +1 -1
  142. package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +4 -0
  143. package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
  144. package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js +4 -0
  145. package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js.map +1 -1
  146. package/features/folder/FolderModelProvider.d.ts +26 -0
  147. package/features/folder/FolderModelProvider.js +22 -0
  148. package/features/folder/FolderModelProvider.js.map +1 -0
  149. package/features/folder/GetAncestors/GetAncestorsRepository.d.ts +3 -3
  150. package/features/folder/GetAncestors/GetAncestorsRepository.js +6 -5
  151. package/features/folder/GetAncestors/GetAncestorsRepository.js.map +1 -1
  152. package/features/folder/GetFolder/GetFolderRepository.d.ts +3 -3
  153. package/features/folder/GetFolder/GetFolderRepository.js +6 -5
  154. package/features/folder/GetFolder/GetFolderRepository.js.map +1 -1
  155. package/features/folder/GetFolder/decorators/GetFolderWithFolderLevelPermissions.d.ts +8 -8
  156. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.d.ts +3 -3
  157. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js +10 -8
  158. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js.map +1 -1
  159. package/features/folder/ListFolders/ListFoldersRepository.d.ts +3 -3
  160. package/features/folder/ListFolders/ListFoldersRepository.js +8 -7
  161. package/features/folder/ListFolders/ListFoldersRepository.js.map +1 -1
  162. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +11 -0
  163. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js +38 -0
  164. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +1 -0
  165. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.d.ts +12 -0
  166. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js +24 -0
  167. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js.map +1 -0
  168. package/features/folder/NotifyFolderChange/abstractions.d.ts +28 -0
  169. package/features/folder/NotifyFolderChange/abstractions.js +8 -0
  170. package/features/folder/NotifyFolderChange/abstractions.js.map +1 -0
  171. package/features/folder/NotifyFolderChange/feature.d.ts +9 -0
  172. package/features/folder/NotifyFolderChange/feature.js +13 -0
  173. package/features/folder/NotifyFolderChange/feature.js.map +1 -0
  174. package/features/folder/NotifyFolderChange/index.d.ts +2 -0
  175. package/features/folder/NotifyFolderChange/index.js +2 -0
  176. package/features/folder/UpdateFolder/UpdateFolderRepository.d.ts +3 -3
  177. package/features/folder/UpdateFolder/UpdateFolderRepository.js +11 -8
  178. package/features/folder/UpdateFolder/UpdateFolderRepository.js.map +1 -1
  179. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.d.ts +14 -1
  180. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js +52 -4
  181. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
  182. package/features/folder/shared/abstractions.d.ts +14 -0
  183. package/features/folder/shared/abstractions.js +4 -1
  184. package/features/folder/shared/abstractions.js.map +1 -1
  185. package/filter/filter.gql.d.ts +2 -3
  186. package/filter/filter.gql.js +61 -27
  187. package/filter/filter.gql.js.map +1 -1
  188. package/filter/filter.model.js +2 -1
  189. package/filter/filter.model.js.map +1 -1
  190. package/filter/filter.so.d.ts +8 -2
  191. package/filter/filter.so.js +21 -9
  192. package/filter/filter.so.js.map +1 -1
  193. package/flp/flp.types.d.ts +6 -1
  194. package/flp/index.d.ts +0 -1
  195. package/flp/index.js +0 -1
  196. package/flp/tasks/createFlp.task.d.ts +12 -5
  197. package/flp/tasks/createFlp.task.js +32 -15
  198. package/flp/tasks/createFlp.task.js.map +1 -1
  199. package/flp/tasks/deleteFlp.task.d.ts +10 -5
  200. package/flp/tasks/deleteFlp.task.js +22 -13
  201. package/flp/tasks/deleteFlp.task.js.map +1 -1
  202. package/flp/tasks/index.d.ts +0 -1
  203. package/flp/tasks/index.js +1 -14
  204. package/flp/tasks/index.js.map +1 -1
  205. package/flp/tasks/syncFlp.task.d.ts +10 -5
  206. package/flp/tasks/syncFlp.task.js +34 -13
  207. package/flp/tasks/syncFlp.task.js.map +1 -1
  208. package/flp/tasks/updateFlp.task.d.ts +12 -5
  209. package/flp/tasks/updateFlp.task.js +40 -19
  210. package/flp/tasks/updateFlp.task.js.map +1 -1
  211. package/folder/createFolderTypeDefs.js +4 -1
  212. package/folder/createFolderTypeDefs.js.map +1 -1
  213. package/folder/folder.gql.d.ts +1 -1
  214. package/folder/folder.gql.js +10 -4
  215. package/folder/folder.gql.js.map +1 -1
  216. package/index.d.ts +1 -6
  217. package/index.js +1 -11
  218. package/package.json +25 -26
  219. package/types.d.ts +1 -2
  220. package/types.js.map +1 -1
  221. package/utils/createOperationsWrapper.d.ts +5 -2
  222. package/utils/createOperationsWrapper.js +5 -5
  223. package/utils/createOperationsWrapper.js.map +1 -1
  224. package/utils/decorators/CmsEntriesCrudDecorators.js +9 -5
  225. package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
  226. package/utils/resolve.d.ts +2 -2
  227. package/utils/resolve.js +1 -1
  228. package/utils/resolve.js.map +1 -1
  229. package/createAcoContext.d.ts +0 -9
  230. package/createAcoContext.js +0 -109
  231. package/createAcoContext.js.map +0 -1
  232. package/createAcoStorageOperations.d.ts +0 -12
  233. package/createAcoStorageOperations.js +0 -9
  234. package/createAcoStorageOperations.js.map +0 -1
  235. package/createAcoTasks.d.ts +0 -1
  236. package/createAcoTasks.js +0 -14
  237. package/createAcoTasks.js.map +0 -1
  238. package/flp/flp.so.d.ts +0 -20
  239. package/flp/flp.so.js +0 -183
  240. package/flp/flp.so.js.map +0 -1
  241. package/index.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import error from "@webiny/error";
1
+ import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
2
2
  const createOperationsWrapper = (params)=>{
3
- const { security, cms, modelName } = params;
3
+ const { identityContext, container, modelName } = params;
4
4
  const withModel = async (cb)=>{
5
- const model = await security.withoutAuthorization(()=>cms.getModel(modelName));
6
- if (!model) throw new error(`Could not find "${modelName}" model.`, "MODEL_NOT_FOUND_ERROR");
7
- return cb(model);
5
+ const result = await identityContext.withoutAuthorization(()=>container.resolve(GetModelUseCase).execute(modelName));
6
+ if (result.isFail()) throw result.error;
7
+ return cb(result.value);
8
8
  };
9
9
  return {
10
10
  withModel
@@ -1 +1 @@
1
- {"version":3,"file":"utils/createOperationsWrapper.js","sources":["../../src/utils/createOperationsWrapper.ts"],"sourcesContent":["import type { CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { security, cms, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n const model = await security.withoutAuthorization(() => {\n return cms.getModel(modelName);\n });\n\n if (!model) {\n throw new WebinyError(`Could not find \"${modelName}\" model.`, \"MODEL_NOT_FOUND_ERROR\");\n }\n\n return cb(model);\n };\n\n return { withModel };\n};\n"],"names":["createOperationsWrapper","params","security","cms","modelName","withModel","cb","model","WebinyError"],"mappings":";AAQO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,SAAS,EAAE,GAAGH;IAErC,MAAMI,YAAY,OACdC;QAEA,MAAMC,QAAQ,MAAML,SAAS,oBAAoB,CAAC,IACvCC,IAAI,QAAQ,CAACC;QAGxB,IAAI,CAACG,OACD,MAAM,IAAIC,MAAY,CAAC,gBAAgB,EAAEJ,UAAU,QAAQ,CAAC,EAAE;QAGlE,OAAOE,GAAGC;IACd;IAEA,OAAO;QAAEF;IAAU;AACvB"}
1
+ {"version":3,"file":"utils/createOperationsWrapper.js","sources":["../../src/utils/createOperationsWrapper.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type { Container } from \"@webiny/di\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\n\ninterface CreateOperationsWrapperParams {\n container: Container;\n identityContext: IdentityContext.Interface;\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { identityContext, container, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n const result = await identityContext.withoutAuthorization(() => {\n return container.resolve(GetModelUseCase).execute(modelName);\n });\n if (result.isFail()) {\n throw result.error;\n }\n\n return cb(result.value);\n };\n\n return { withModel };\n};\n"],"names":["createOperationsWrapper","params","identityContext","container","modelName","withModel","cb","result","GetModelUseCase"],"mappings":";AAWO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,eAAe,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGH;IAElD,MAAMI,YAAY,OACdC;QAEA,MAAMC,SAAS,MAAML,gBAAgB,oBAAoB,CAAC,IAC/CC,UAAU,OAAO,CAACK,iBAAiB,OAAO,CAACJ;QAEtD,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAGtB,OAAOD,GAAGC,OAAO,KAAK;IAC1B;IAEA,OAAO;QAAEF;IAAU;AACvB"}
@@ -3,6 +3,8 @@ import { ListEntriesFactory } from "./ListEntriesFactory.js";
3
3
  import { FilterEntriesByFolderFactory } from "./FilterEntriesByFolderFactory.js";
4
4
  import { decorateIfModelAuthorizationEnabled } from "./decorateIfModelAuthorizationEnabled.js";
5
5
  import { FolderLevelPermissions } from "../../features/flp/FolderLevelPermissions/index.js";
6
+ import { GetRevisionByIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js";
7
+ import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
6
8
  class CmsEntriesCrudDecorators {
7
9
  constructor({ context }){
8
10
  this.context = context;
@@ -10,6 +12,8 @@ class CmsEntriesCrudDecorators {
10
12
  decorate() {
11
13
  const context = this.context;
12
14
  const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);
15
+ const getRevisionById = context.container.resolve(GetRevisionByIdStorageOperation);
16
+ const getLatestRevisionByEntryId = context.container.resolve(GetLatestRevisionByEntryIdStorageOperation);
13
17
  const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);
14
18
  const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);
15
19
  decorateIfModelAuthorizationEnabled(context, "listEntries", async (...allParams)=>{
@@ -91,7 +95,7 @@ class CmsEntriesCrudDecorators {
91
95
  });
92
96
  decorateIfModelAuthorizationEnabled(context, "createEntryRevisionFrom", async (...allParams)=>{
93
97
  const [decoratee, model, id, input, options] = allParams;
94
- const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
98
+ const entry = await getRevisionById.execute(model, {
95
99
  id
96
100
  });
97
101
  const folderId = entry?.location?.folderId;
@@ -105,7 +109,7 @@ class CmsEntriesCrudDecorators {
105
109
  });
106
110
  decorateIfModelAuthorizationEnabled(context, "updateEntry", async (...allParams)=>{
107
111
  const [decoratee, model, id, input, meta, options] = allParams;
108
- const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
112
+ const entry = await getRevisionById.execute(model, {
109
113
  id
110
114
  });
111
115
  const folderId = entry?.location?.folderId;
@@ -119,7 +123,7 @@ class CmsEntriesCrudDecorators {
119
123
  });
120
124
  decorateIfModelAuthorizationEnabled(context, "deleteEntry", async (...allParams)=>{
121
125
  const [decoratee, model, id, options] = allParams;
122
- const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(model, {
126
+ const entry = await getLatestRevisionByEntryId.execute(model, {
123
127
  id
124
128
  });
125
129
  const folderId = entry?.location?.folderId;
@@ -133,7 +137,7 @@ class CmsEntriesCrudDecorators {
133
137
  });
134
138
  decorateIfModelAuthorizationEnabled(context, "deleteEntryRevision", async (...allParams)=>{
135
139
  const [decoratee, model, id] = allParams;
136
- const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
140
+ const entry = await getRevisionById.execute(model, {
137
141
  id
138
142
  });
139
143
  const folderId = entry?.location?.folderId;
@@ -147,7 +151,7 @@ class CmsEntriesCrudDecorators {
147
151
  });
148
152
  decorateIfModelAuthorizationEnabled(context, "moveEntry", async (...allParams)=>{
149
153
  const [decoratee, model, id, targetFolderId] = allParams;
150
- const entry = await context.cms.storageOperations.entries.getRevisionById(model, {
154
+ const entry = await getRevisionById.execute(model, {
151
155
  id
152
156
  });
153
157
  const folderId = entry?.location?.folderId || ROOT_FOLDER;
@@ -1 +1 @@
1
- {"version":3,"file":"utils/decorators/CmsEntriesCrudDecorators.js","sources":["../../../src/utils/decorators/CmsEntriesCrudDecorators.ts"],"sourcesContent":["// @ts-nocheck Being removed\nimport type { AcoContext } from \"~/types.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport { ListEntriesFactory } from \"./ListEntriesFactory.js\";\nimport { FilterEntriesByFolderFactory } from \"./FilterEntriesByFolderFactory.js\";\nimport { decorateIfModelAuthorizationEnabled } from \"./decorateIfModelAuthorizationEnabled.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\n\ntype Context = AcoContext;\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);\n\n const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);\n const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context, \"listEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"listLatestEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"listPublishedEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"listDeletedEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntry\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntryById\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getLatestEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getPublishedEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, params, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, params, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"createEntryRevisionFrom\",\n async (...allParams) => {\n const [decoratee, model, id, input, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, options);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, options);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"updateEntry\", async (...allParams) => {\n const [decoratee, model, id, input, meta, options] = allParams;\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, meta, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, meta, options);\n });\n\n decorateIfModelAuthorizationEnabled(context, \"deleteEntry\", async (...allParams) => {\n const [decoratee, model, id, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id\n }\n );\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"deleteEntryRevision\",\n async (...allParams) => {\n const [decoratee, model, id] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"moveEntry\", async (...allParams) => {\n const [decoratee, model, id, targetFolderId] = allParams;\n\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return decoratee(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n\n return decoratee(model, id, targetFolderId);\n });\n }\n}\n"],"names":["CmsEntriesCrudDecorators","context","folderLevelPermissions","FolderLevelPermissions","filterEntriesByFolder","FilterEntriesByFolderFactory","listEntriesHandler","ListEntriesFactory","decorateIfModelAuthorizationEnabled","allParams","decoratee","model","initialParams","params","entry","folderId","ROOT_FOLDER","permissions","ids","entries","options","id","input","meta","targetFolderId"],"mappings":";;;;;AAcO,MAAMA;IAGT,YAAmB,EAAEC,OAAO,EAAoC,CAAE;QAC9D,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEO,WAAW;QACd,MAAMA,UAAU,IAAI,CAAC,OAAO;QAC5B,MAAMC,yBAAyBD,QAAQ,SAAS,CAAC,OAAO,C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/B,MAAMK,QAAQ,MAAMb,QAAQ,GAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAACU,OAAO;gBAC7EU;YACJ;YAEA,MAAMN,WAAWD,OAAO,UAAU;YAClC,IAAI,CAACC,YAAYA,aAAaC,aAC1B,OAAON,UAAUC,OAAOU;YAG5B,MAAMJ,cACF,MAAMf,uBAAuB,yBAAyB,CAACa;YAC3D,MAAMb,uBAAuB,4BAA4B,CAAC;gBACtDe;gBACA,KAAK;YACT;YAEA,OAAOP,UAAUC,OAAOU;QAC5B;QAGJb,oCAAoCP,SAAS,aAAa,OAAO,GAAGQ;YAChE,MAAM,CAACC,WAAWC,OAAOU,IAAIG,eAAe,GAAGf;YAK/C,MAAMK,QAAQ,MAAMb,QAAQ,GAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAACU,OAAO;gBAC7EU;YACJ;YAEA,MAAMN,WAAWD,OAAO,UAAU,YAAYE;YAI9C,IAAID,aAAaS,gBACb,OAAOd,UAAUC,OAAOU,IAAIG;YACzB,IAAIT,aAAaC,aAAa;gBAIjC,MAAMC,cACF,MAAMf,uBAAuB,yBAAyB,CAACa;gBAC3D,MAAMb,uBAAuB,4BAA4B,CAAC;oBACtDe;oBACA,KAAK;gBACT;YACJ;YAIA,IAAIO,mBAAmBR,aAAa;gBAChC,MAAMC,cACF,MAAMf,uBAAuB,yBAAyB,CAACa;gBAC3D,MAAMb,uBAAuB,4BAA4B,CAAC;oBACtDe;oBACA,KAAK;gBACT;YACJ;YAEA,OAAOP,UAAUC,OAAOU,IAAIG;QAChC;IACJ;AACJ"}
1
+ {"version":3,"file":"utils/decorators/CmsEntriesCrudDecorators.js","sources":["../../../src/utils/decorators/CmsEntriesCrudDecorators.ts"],"sourcesContent":["// @ts-nocheck Being removed\nimport type { AcoContext } from \"~/types.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport { ListEntriesFactory } from \"./ListEntriesFactory.js\";\nimport { FilterEntriesByFolderFactory } from \"./FilterEntriesByFolderFactory.js\";\nimport { decorateIfModelAuthorizationEnabled } from \"./decorateIfModelAuthorizationEnabled.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetRevisionByIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js\";\nimport { GetLatestRevisionByEntryIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js\";\n\ntype Context = AcoContext;\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);\n const getRevisionById = context.container.resolve(GetRevisionByIdStorageOperation);\n const getLatestRevisionByEntryId = context.container.resolve(\n GetLatestRevisionByEntryIdStorageOperation\n );\n\n const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);\n const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context, \"listEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"listLatestEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"listPublishedEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"listDeletedEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntry\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntryById\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getLatestEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getPublishedEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, params, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, params, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"createEntryRevisionFrom\",\n async (...allParams) => {\n const [decoratee, model, id, input, options] = allParams;\n\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, options);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, options);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"updateEntry\", async (...allParams) => {\n const [decoratee, model, id, input, meta, options] = allParams;\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, meta, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, meta, options);\n });\n\n decorateIfModelAuthorizationEnabled(context, \"deleteEntry\", async (...allParams) => {\n const [decoratee, model, id, options] = allParams;\n\n const entry = await getLatestRevisionByEntryId.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"deleteEntryRevision\",\n async (...allParams) => {\n const [decoratee, model, id] = allParams;\n\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"moveEntry\", async (...allParams) => {\n const [decoratee, model, id, targetFolderId] = allParams;\n\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return decoratee(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n\n return decoratee(model, id, targetFolderId);\n });\n }\n}\n"],"names":["CmsEntriesCrudDecorators","context","folderLevelPermissions","FolderLevelPermissions","getRevisionById","GetRevisionByIdStorageOperation","getLatestRevisionByEntryId","GetLatestRevisionByEntryIdStorageOperation","filterEntriesByFolder","FilterEntriesByFolderFactory","listEntriesHandler","ListEntriesFactory","decorateIfModelAuthorizationEnabled","allParams","decoratee","model","initialParams","params","entry","folderId","ROOT_FOLDER","permissions","ids","entries","options","id","input","meta","targetFolderId"],"mappings":";;;;;;;AAgBO,MAAMA;IAGT,YAAmB,EAAEC,OAAO,EAAoC,CAAE;QAC9D,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEO,WAAW;QACd,MAAMA,UAAU,IAAI,CAAC,OAAO;QAC5B,MAAMC,yBAAyBD,QAAQ,SAAS,CAAC,OAAO,CAACE;QACzD,MAAMC,kBAAkBH,QAAQ,SAAS,CAAC,OAAO,CAACI;QAClD,MAAMC,6BAA6BL,QAAQ,SAAS,CAAC,OAAO,CACxDM;QAGJ,MAAMC,wBAAwB,IAAIC,6BAA6BP;QAC/D,MAAMQ,qBAAqB,IAAIC,mBAAmBT;QAElDU,oCAAoCX,SAAS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,CAACiB;YAC3D,MAAMjB,uBAAuB,4BAA4B,CAAC;gBACtDmB;gBACA,KAAK;YACT;YAEA,OAAOP,UAAUC,OAAOU;QAC5B;QAGJb,oCAAoCX,SAAS,aAAa,OAAO,GAAGY;YAChE,MAAM,CAACC,WAAWC,OAAOU,IAAIG,eAAe,GAAGf;YAK/C,MAAMK,QAAQ,MAAMd,gBAAgB,OAAO,CAACW,OAAO;gBAC/CU;YACJ;YAEA,MAAMN,WAAWD,OAAO,UAAU,YAAYE;YAI9C,IAAID,aAAaS,gBACb,OAAOd,UAAUC,OAAOU,IAAIG;YACzB,IAAIT,aAAaC,aAAa;gBAIjC,MAAMC,cACF,MAAMnB,uBAAuB,yBAAyB,CAACiB;gBAC3D,MAAMjB,uBAAuB,4BAA4B,CAAC;oBACtDmB;oBACA,KAAK;gBACT;YACJ;YAIA,IAAIO,mBAAmBR,aAAa;gBAChC,MAAMC,cACF,MAAMnB,uBAAuB,yBAAyB,CAACiB;gBAC3D,MAAMjB,uBAAuB,4BAA4B,CAAC;oBACtDmB;oBACA,KAAK;gBACT;YACJ;YAEA,OAAOP,UAAUC,OAAOU,IAAIG;QAChC;IACJ;AACJ"}
@@ -1,2 +1,2 @@
1
- import { ErrorResponse, Response } from "@webiny/handler-graphql";
2
- export declare const resolve: (fn: () => Promise<any>) => Promise<Response<any> | ErrorResponse>;
1
+ import { ErrorResponse, Response } from "@webiny/api-graphql";
2
+ export declare const resolve: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
package/utils/resolve.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ErrorResponse, Response } from "@webiny/handler-graphql";
1
+ import { ErrorResponse, Response } from "@webiny/api-graphql";
2
2
  const resolve = async (fn)=>{
3
3
  try {
4
4
  return new Response(await fn());
@@ -1 +1 @@
1
- {"version":3,"file":"utils/resolve.js","sources":["../../src/utils/resolve.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/handler-graphql\";\n\nexport const resolve = async (fn: () => Promise<any>) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"names":["resolve","fn","Response","e","ErrorResponse"],"mappings":";AAEO,MAAMA,UAAU,OAAOC;IAC1B,IAAI;QACA,OAAO,IAAIC,SAAS,MAAMD;IAC9B,EAAE,OAAOE,GAAG;QACR,OAAO,IAAIC,cAAcD;IAC7B;AACJ"}
1
+ {"version":3,"file":"utils/resolve.js","sources":["../../src/utils/resolve.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/api-graphql\";\n\nexport const resolve = async (fn: () => Promise<any>) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"names":["resolve","fn","Response","e","ErrorResponse"],"mappings":";AAEO,MAAMA,UAAU,OAAOC;IAC1B,IAAI;QACA,OAAO,IAAIC,SAAS,MAAMD;IAC9B,EAAE,OAAOE,GAAG;QACR,OAAO,IAAIC,cAAcD;IAC7B;AACJ"}
@@ -1,9 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
- import type { AcoContext } from "./types.js";
4
- interface CreateAcoContextParams {
5
- useFolderLevelPermissions?: boolean;
6
- documentClient: DynamoDBDocument;
7
- }
8
- export declare const createAcoContext: (params: CreateAcoContextParams) => (ContextPlugin<AcoContext> | import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types").Context>)[];
9
- export {};
@@ -1,109 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { isHeadlessCmsReady } from "@webiny/api-headless-cms";
3
- import { createAcoStorageOperations } from "./createAcoStorageOperations.js";
4
- import { createFilterCrudMethods } from "./filter/filter.crud.js";
5
- import { createFlpCrudMethods } from "./flp/index.js";
6
- import { FolderLevelPermissions, FolderLevelPermissionsFeature } from "./features/flp/FolderLevelPermissions/index.js";
7
- import { UpdateFolderFeature } from "./features/folder/UpdateFolder/index.js";
8
- import { DeleteFolderFeature } from "./features/folder/DeleteFolder/index.js";
9
- import { CreateFolderFeature } from "./features/folder/CreateFolder/index.js";
10
- import { GetFolderFeature } from "./features/folder/GetFolder/index.js";
11
- import { ListFoldersFeature } from "./features/folder/ListFolders/index.js";
12
- import { GetFolderHierarchyFeature } from "./features/folder/GetFolderHierarchy/index.js";
13
- import { GetAncestorsFeature } from "./features/folder/GetAncestors/index.js";
14
- import { UpdateFlpOnFolderUpdatedFeature } from "./features/flp/UpdateFlpOnFolderUpdated/index.js";
15
- import { DeleteFlpOnFolderDeletedFeature } from "./features/flp/DeleteFlpOnFolderDeleted/index.js";
16
- import { EnsureHcmsFolderIsEmptyOnDeleteFeature } from "./features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js";
17
- import { CreateFlpFeature } from "./features/flp/CreateFlp/index.js";
18
- import { DeleteFlpFeature } from "./features/flp/DeleteFlp/index.js";
19
- import { UpdateFlpFeature } from "./features/flp/UpdateFlp/index.js";
20
- import { EnsureFolderIsEmptyOnDeleteFeature } from "./features/folder/EnsureFolderIsEmptyOnDelete/index.js";
21
- import { FilterStorageOperations } from "./features/folder/shared/abstractions.js";
22
- import { ListFlpsFeature } from "./features/flp/ListFlps/feature.js";
23
- import { GetFlpFeature } from "./features/flp/GetFlp/feature.js";
24
- import { ListFolderLevelPermissionsTargetsFeature } from "./features/folder/ListFolderLevelPermissionsTargets/feature.js";
25
- import { CmsFlpFeature } from "./features/cms/index.js";
26
- import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
27
- import { FolderModel } from "./domain/folder/abstractions.js";
28
- import { CreateFlpOnFolderCreatedFeature } from "./features/flp/CreateFlpOnFolderCreated/index.js";
29
- import { EnsureFolderIsEmptyFeature } from "./features/folder/EnsureFolderIsEmpty/feature.js";
30
- import { FOLDER_MODEL_ID, FolderModel as folder_model_js_FolderModel } from "./domain/folder/folder.model.js";
31
- import { FilterPrivateModel } from "./filter/filter.model.js";
32
- import { createRegisterExtensionPlugin } from "@webiny/handler";
33
- const setupAcoContext = async (context, setupAcoContextParams)=>{
34
- const { tenancy, security } = context;
35
- const getModel = context.container.resolve(GetModelUseCase);
36
- await context.security.withoutAuthorization(async ()=>{
37
- const folderModel = await getModel.execute(FOLDER_MODEL_ID);
38
- context.container.registerInstance(FolderModel, folderModel.value);
39
- });
40
- const getTenant = ()=>tenancy.getCurrentTenant();
41
- const storageOperations = await createAcoStorageOperations({
42
- cms: context.cms,
43
- container: context.container,
44
- documentClient: setupAcoContextParams.documentClient,
45
- security
46
- });
47
- const flpCrudMethods = createFlpCrudMethods({
48
- getTenant,
49
- storageOperations
50
- });
51
- FolderLevelPermissionsFeature.register(context.container);
52
- context.container.registerInstance(FilterStorageOperations, storageOperations.filter);
53
- CreateFolderFeature.register(context.container);
54
- UpdateFolderFeature.register(context.container);
55
- DeleteFolderFeature.register(context.container);
56
- GetFolderFeature.register(context.container);
57
- ListFoldersFeature.register(context.container);
58
- ListFolderLevelPermissionsTargetsFeature.register(context.container);
59
- GetFolderHierarchyFeature.register(context.container);
60
- GetAncestorsFeature.register(context.container);
61
- EnsureFolderIsEmptyFeature.register(context.container);
62
- CreateFlpFeature.register(context.container, {
63
- context
64
- });
65
- UpdateFlpFeature.register(context.container, {
66
- context
67
- });
68
- DeleteFlpFeature.register(context.container, {
69
- context
70
- });
71
- ListFlpsFeature.register(context.container, flpCrudMethods);
72
- GetFlpFeature.register(context.container, flpCrudMethods);
73
- CreateFlpOnFolderCreatedFeature.register(context.container);
74
- UpdateFlpOnFolderUpdatedFeature.register(context.container);
75
- DeleteFlpOnFolderDeletedFeature.register(context.container);
76
- EnsureFolderIsEmptyOnDeleteFeature.register(context.container);
77
- EnsureHcmsFolderIsEmptyOnDeleteFeature.register(context.container);
78
- const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);
79
- context.aco = {
80
- filter: createFilterCrudMethods({
81
- container: context.container,
82
- getTenant,
83
- storageOperations,
84
- folderLevelPermissions
85
- }),
86
- flp: flpCrudMethods
87
- };
88
- if (context.wcp.canUseFolderLevelPermissions()) CmsFlpFeature.register(context.container);
89
- };
90
- const createAcoContext = (params)=>{
91
- const modelsPlugin = createRegisterExtensionPlugin((context)=>{
92
- context.container.register(folder_model_js_FolderModel);
93
- context.container.register(FilterPrivateModel);
94
- });
95
- const acoContextPlugin = new ContextPlugin(async (context)=>{
96
- if (!await isHeadlessCmsReady(context)) return;
97
- await context.benchmark.measure("aco.context.setup", async ()=>{
98
- await setupAcoContext(context, params);
99
- });
100
- });
101
- acoContextPlugin.name = "aco.createContext";
102
- return [
103
- acoContextPlugin,
104
- modelsPlugin
105
- ];
106
- };
107
- export { createAcoContext };
108
-
109
- //# sourceMappingURL=createAcoContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAcoContext.js","sources":["../src/createAcoContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createAcoStorageOperations } from \"~/createAcoStorageOperations.js\";\nimport type { AcoContext } from \"~/types.js\";\nimport { createFilterCrudMethods } from \"~/filter/filter.crud.js\";\nimport { createFlpCrudMethods } from \"~/flp/index.js\";\nimport {\n FolderLevelPermissions,\n FolderLevelPermissionsFeature\n} from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { UpdateFolderFeature } from \"~/features/folder/UpdateFolder/index.js\";\nimport { DeleteFolderFeature } from \"~/features/folder/DeleteFolder/index.js\";\nimport { CreateFolderFeature } from \"~/features/folder/CreateFolder/index.js\";\nimport { GetFolderFeature } from \"~/features/folder/GetFolder/index.js\";\nimport { ListFoldersFeature } from \"~/features/folder/ListFolders/index.js\";\nimport { GetFolderHierarchyFeature } from \"~/features/folder/GetFolderHierarchy/index.js\";\nimport { GetAncestorsFeature } from \"~/features/folder/GetAncestors/index.js\";\nimport { UpdateFlpOnFolderUpdatedFeature } from \"~/features/flp/UpdateFlpOnFolderUpdated/index.js\";\nimport { DeleteFlpOnFolderDeletedFeature } from \"~/features/flp/DeleteFlpOnFolderDeleted/index.js\";\nimport { EnsureHcmsFolderIsEmptyOnDeleteFeature } from \"~/features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js\";\nimport { CreateFlpFeature } from \"~/features/flp/CreateFlp/index.js\";\nimport { DeleteFlpFeature } from \"~/features/flp/DeleteFlp/index.js\";\nimport { UpdateFlpFeature } from \"~/features/flp/UpdateFlp/index.js\";\nimport { EnsureFolderIsEmptyOnDeleteFeature } from \"~/features/folder/EnsureFolderIsEmptyOnDelete/index.js\";\nimport { FilterStorageOperations } from \"~/features/folder/shared/abstractions.js\";\nimport { ListFlpsFeature } from \"~/features/flp/ListFlps/feature.js\";\nimport { GetFlpFeature } from \"~/features/flp/GetFlp/feature.js\";\nimport { ListFolderLevelPermissionsTargetsFeature } from \"~/features/folder/ListFolderLevelPermissionsTargets/feature.js\";\nimport { Tenant } from \"@webiny/api-core/types/tenancy\";\nimport { CmsFlpFeature } from \"~/features/cms/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { FolderModel as FolderModelAbstraction } from \"~/domain/folder/abstractions.js\";\nimport { CreateFlpOnFolderCreatedFeature } from \"~/features/flp/CreateFlpOnFolderCreated/index.js\";\nimport { EnsureFolderIsEmptyFeature } from \"~/features/folder/EnsureFolderIsEmpty/feature.js\";\nimport { FOLDER_MODEL_ID, FolderModel } from \"~/domain/folder/folder.model.js\";\nimport { FilterPrivateModel } from \"~/filter/filter.model.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\n\ninterface CreateAcoContextParams {\n useFolderLevelPermissions?: boolean;\n documentClient: DynamoDBDocument;\n}\n\nconst setupAcoContext = async (\n context: AcoContext,\n setupAcoContextParams: CreateAcoContextParams\n): Promise<void> => {\n const { tenancy, security } = context;\n\n const getModel = context.container.resolve(GetModelUseCase);\n\n await context.security.withoutAuthorization(async () => {\n const folderModel = await getModel.execute(FOLDER_MODEL_ID);\n context.container.registerInstance(FolderModelAbstraction, folderModel.value);\n });\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const storageOperations = await 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 container: context.container,\n documentClient: setupAcoContextParams.documentClient,\n security\n });\n\n const flpCrudMethods = createFlpCrudMethods({\n getTenant,\n storageOperations\n });\n\n FolderLevelPermissionsFeature.register(context.container);\n\n /**\n * Register legacy dependencies via abstractions\n */\n context.container.registerInstance(FilterStorageOperations, storageOperations.filter);\n\n /**\n * Register folder features into DI container\n */\n CreateFolderFeature.register(context.container);\n\n UpdateFolderFeature.register(context.container);\n\n DeleteFolderFeature.register(context.container);\n\n GetFolderFeature.register(context.container);\n\n ListFoldersFeature.register(context.container);\n\n ListFolderLevelPermissionsTargetsFeature.register(context.container);\n\n GetFolderHierarchyFeature.register(context.container);\n\n GetAncestorsFeature.register(context.container);\n\n EnsureFolderIsEmptyFeature.register(context.container);\n\n /**\n * Register FLP use cases and event handlers\n */\n CreateFlpFeature.register(context.container, { context });\n UpdateFlpFeature.register(context.container, { context });\n DeleteFlpFeature.register(context.container, { context });\n ListFlpsFeature.register(context.container, flpCrudMethods);\n GetFlpFeature.register(context.container, flpCrudMethods);\n\n CreateFlpOnFolderCreatedFeature.register(context.container);\n\n UpdateFlpOnFolderUpdatedFeature.register(context.container);\n\n DeleteFlpOnFolderDeletedFeature.register(context.container);\n\n /**\n * Register folder event handlers\n */\n EnsureFolderIsEmptyOnDeleteFeature.register(context.container);\n EnsureHcmsFolderIsEmptyOnDeleteFeature.register(context.container);\n\n /**\n * Setup legacy context\n */\n const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);\n\n context.aco = {\n filter: createFilterCrudMethods({\n container: context.container,\n getTenant,\n storageOperations,\n folderLevelPermissions\n }),\n flp: flpCrudMethods\n };\n\n if (context.wcp.canUseFolderLevelPermissions()) {\n CmsFlpFeature.register(context.container);\n }\n};\n\nexport const createAcoContext = (params: CreateAcoContextParams) => {\n const modelsPlugin = createRegisterExtensionPlugin(context => {\n context.container.register(FolderModel);\n context.container.register(FilterPrivateModel);\n });\n\n const acoContextPlugin = new ContextPlugin<AcoContext>(async context => {\n /**\n * We can skip the ACO initialization if the installation is pending.\n */\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n await context.benchmark.measure(\"aco.context.setup\", async () => {\n await setupAcoContext(context, params);\n });\n });\n\n acoContextPlugin.name = \"aco.createContext\";\n\n return [acoContextPlugin, modelsPlugin];\n};\n"],"names":["setupAcoContext","context","setupAcoContextParams","tenancy","security","getModel","GetModelUseCase","folderModel","FOLDER_MODEL_ID","FolderModelAbstraction","getTenant","storageOperations","createAcoStorageOperations","flpCrudMethods","createFlpCrudMethods","FolderLevelPermissionsFeature","FilterStorageOperations","CreateFolderFeature","UpdateFolderFeature","DeleteFolderFeature","GetFolderFeature","ListFoldersFeature","ListFolderLevelPermissionsTargetsFeature","GetFolderHierarchyFeature","GetAncestorsFeature","EnsureFolderIsEmptyFeature","CreateFlpFeature","UpdateFlpFeature","DeleteFlpFeature","ListFlpsFeature","GetFlpFeature","CreateFlpOnFolderCreatedFeature","UpdateFlpOnFolderUpdatedFeature","DeleteFlpOnFolderDeletedFeature","EnsureFolderIsEmptyOnDeleteFeature","EnsureHcmsFolderIsEmptyOnDeleteFeature","folderLevelPermissions","FolderLevelPermissions","createFilterCrudMethods","CmsFlpFeature","createAcoContext","params","modelsPlugin","createRegisterExtensionPlugin","FolderModel","FilterPrivateModel","acoContextPlugin","ContextPlugin","isHeadlessCmsReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,kBAAkB,OACpBC,SACAC;IAEA,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGH;IAE9B,MAAMI,WAAWJ,QAAQ,SAAS,CAAC,OAAO,CA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AgC,QAAQ,CAAC9B,QAAQ,SAAS;IAE1D+B,gCAAgC,QAAQ,CAAC/B,QAAQ,SAAS;IAE1DgC,gCAAgC,QAAQ,CAAChC,QAAQ,SAAS;IAK1DiC,mCAAmC,QAAQ,CAACjC,QAAQ,SAAS;IAC7DkC,uCAAuC,QAAQ,CAAClC,QAAQ,SAAS;IAKjE,MAAMmC,yBAAyBnC,QAAQ,SAAS,CAAC,OAAO,CAACoC;IAEzDpC,QAAQ,GAAG,GAAG;QACV,QAAQqC,wBAAwB;YAC5B,WAAWrC,QAAQ,SAAS;YAC5BS;YACAC;YACAyB;QACJ;QACA,KAAKvB;IACT;IAEA,IAAIZ,QAAQ,GAAG,CAAC,4BAA4B,IACxCsC,cAAc,QAAQ,CAACtC,QAAQ,SAAS;AAEhD;AAEO,MAAMuC,mBAAmB,CAACC;IAC7B,MAAMC,eAAeC,8BAA8B1C,CAAAA;QAC/CA,QAAQ,SAAS,CAAC,QAAQ,CAAC2C;QAC3B3C,QAAQ,SAAS,CAAC,QAAQ,CAAC4C;IAC/B;IAEA,MAAMC,mBAAmB,IAAIC,cAA0B,OAAM9C;QAIzD,IAAI,CAAE,MAAM+C,mBAAmB/C,UAC3B;QAGJ,MAAMA,QAAQ,SAAS,CAAC,OAAO,CAAC,qBAAqB;YACjD,MAAMD,gBAAgBC,SAASwC;QACnC;IACJ;IAEAK,iBAAiB,IAAI,GAAG;IAExB,OAAO;QAACA;QAAkBJ;KAAa;AAC3C"}
@@ -1,12 +0,0 @@
1
- import type { HeadlessCms } from "@webiny/api-headless-cms/types/index.js";
2
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
- import type { AcoStorageOperations } from "./types.js";
4
- import type { Security } from "@webiny/api-core/types/security.js";
5
- import type { Container } from "@webiny/di";
6
- export interface CreateAcoStorageOperationsParams {
7
- cms: HeadlessCms;
8
- security: Security;
9
- container: Container;
10
- documentClient: DynamoDBDocument;
11
- }
12
- export declare const createAcoStorageOperations: (params: CreateAcoStorageOperationsParams) => Promise<AcoStorageOperations>;
@@ -1,9 +0,0 @@
1
- import { createFilterOperations } from "./filter/filter.so.js";
2
- import { createFlpOperations } from "./flp/index.js";
3
- const createAcoStorageOperations = async (params)=>({
4
- filter: createFilterOperations(params),
5
- flp: createFlpOperations(params)
6
- });
7
- export { createAcoStorageOperations };
8
-
9
- //# sourceMappingURL=createAcoStorageOperations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAcoStorageOperations.js","sources":["../src/createAcoStorageOperations.ts"],"sourcesContent":["import type { HeadlessCms } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createFilterOperations } from \"~/filter/filter.so.js\";\nimport type { AcoStorageOperations } from \"~/types.js\";\nimport { createFlpOperations } from \"~/flp/index.js\";\nimport type { Security } from \"@webiny/api-core/types/security.js\";\nimport type { Container } from \"@webiny/di\";\n\nexport interface CreateAcoStorageOperationsParams {\n cms: HeadlessCms;\n security: Security;\n container: Container;\n documentClient: DynamoDBDocument;\n}\n\nexport const createAcoStorageOperations = async (\n params: CreateAcoStorageOperationsParams\n): Promise<AcoStorageOperations> => {\n return {\n filter: createFilterOperations(params),\n flp: createFlpOperations(params)\n };\n};\n"],"names":["createAcoStorageOperations","params","createFilterOperations","createFlpOperations"],"mappings":";;AAeO,MAAMA,6BAA6B,OACtCC,SAEO;QACH,QAAQC,uBAAuBD;QAC/B,KAAKE,oBAAoBF;IAC7B"}
@@ -1 +0,0 @@
1
- export declare const createAcoTasks: () => import("@webiny/api").ContextPlugin<import("@webiny/api/types").Context>;
package/createAcoTasks.js DELETED
@@ -1,14 +0,0 @@
1
- import { createContextPlugin } from "@webiny/api";
2
- import { CreateFlpTask } from "./flp/tasks/createFlp.task.js";
3
- import { UpdateFlpTask } from "./flp/tasks/updateFlp.task.js";
4
- import { DeleteFlpTask } from "./flp/tasks/deleteFlp.task.js";
5
- import { SyncFlpTask } from "./flp/tasks/syncFlp.task.js";
6
- const createAcoTasks = ()=>createContextPlugin((context)=>{
7
- context.container.register(CreateFlpTask);
8
- context.container.register(UpdateFlpTask);
9
- context.container.register(DeleteFlpTask);
10
- context.container.register(SyncFlpTask);
11
- });
12
- export { createAcoTasks };
13
-
14
- //# sourceMappingURL=createAcoTasks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAcoTasks.js","sources":["../src/createAcoTasks.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { CreateFlpTask } from \"~/flp/tasks/createFlp.task.js\";\nimport { UpdateFlpTask } from \"~/flp/tasks/updateFlp.task.js\";\nimport { DeleteFlpTask } from \"~/flp/tasks/deleteFlp.task.js\";\nimport { SyncFlpTask } from \"~/flp/tasks/syncFlp.task.js\";\n\nexport const createAcoTasks = () => {\n return createContextPlugin(context => {\n context.container.register(CreateFlpTask);\n context.container.register(UpdateFlpTask);\n context.container.register(DeleteFlpTask);\n context.container.register(SyncFlpTask);\n });\n};\n"],"names":["createAcoTasks","createContextPlugin","context","CreateFlpTask","UpdateFlpTask","DeleteFlpTask","SyncFlpTask"],"mappings":";;;;;AAMO,MAAMA,iBAAiB,IACnBC,oBAAoBC,CAAAA;QACvBA,QAAQ,SAAS,CAAC,QAAQ,CAACC;QAC3BD,QAAQ,SAAS,CAAC,QAAQ,CAACE;QAC3BF,QAAQ,SAAS,CAAC,QAAQ,CAACG;QAC3BH,QAAQ,SAAS,CAAC,QAAQ,CAACI;IAC/B"}
package/flp/flp.so.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
- import type { AcoFolderLevelPermissionsStorageOperations as IAcoFolderLevelPermissionsStorageOperations, FolderLevelPermission, StorageOperationsBatchUpdateFlpParams, StorageOperationsCreateFlpParams, StorageOperationsDeleteFlpParams, StorageOperationsGetFlpParams, StorageOperationsListFlpsParams, StorageOperationsUpdateFlpParams } from "../flp/flp.types.js";
3
- interface StorageOperationsConfig {
4
- documentClient: DynamoDBDocument;
5
- }
6
- declare class FolderLevelPermissionsStorageOperations implements IAcoFolderLevelPermissionsStorageOperations {
7
- private readonly entity;
8
- private readonly table;
9
- constructor({ documentClient }: StorageOperationsConfig);
10
- list({ where: { tenant, type, path_startsWith, parentId } }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]>;
11
- get({ tenant, id }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null>;
12
- create({ data }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission>;
13
- update({ data: inputData, original }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission>;
14
- delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void>;
15
- batchUpdate({ items }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]>;
16
- private createKeys;
17
- private createGsiKeys;
18
- }
19
- export declare const createFlpOperations: (params: StorageOperationsConfig) => FolderLevelPermissionsStorageOperations;
20
- export {};
package/flp/flp.so.js DELETED
@@ -1,183 +0,0 @@
1
- import { createStandardEntity, createTable } from "@webiny/db-dynamodb";
2
- import { WebinyError } from "@webiny/error";
3
- import { executeWithRetry } from "@webiny/utils";
4
- class FolderLevelPermissionsStorageOperations {
5
- constructor({ documentClient }){
6
- this.table = createTable({
7
- name: String(process.env.DB_TABLE),
8
- documentClient
9
- });
10
- this.entity = createStandardEntity({
11
- table: this.table.table,
12
- name: "ACO.flp"
13
- });
14
- }
15
- async list({ where: { tenant, type, path_startsWith, parentId } }) {
16
- try {
17
- if (parentId) {
18
- const entries = await this.entity.queryAll({
19
- partitionKey: `T#${tenant}#FLP`,
20
- options: {
21
- index: "GSI2",
22
- eq: parentId
23
- }
24
- });
25
- return entries.map((entry)=>entry.data);
26
- }
27
- if (path_startsWith) {
28
- const entries = await this.entity.queryAll({
29
- partitionKey: `T#${tenant}#AT#${type}#FLP`,
30
- options: {
31
- index: "GSI1",
32
- beginsWith: path_startsWith
33
- }
34
- });
35
- return entries.map((entry)=>entry.data);
36
- }
37
- throw new WebinyError("Missing required parameters.", "LIST_FLP_MISSING_PARAMETERS", {
38
- tenant,
39
- type,
40
- path_startsWith,
41
- parentId
42
- });
43
- } catch (err) {
44
- throw WebinyError.from(err, {
45
- message: "Could not list folder level permissions.",
46
- code: "LIST_FLP_ERROR"
47
- });
48
- }
49
- }
50
- async get({ tenant, id }) {
51
- try {
52
- const entry = await this.entity.get(this.createKeys({
53
- tenant,
54
- id
55
- }));
56
- if (!entry) return null;
57
- return entry.data;
58
- } catch (err) {
59
- throw WebinyError.from(err, {
60
- message: "Could not load folder level permission.",
61
- code: "GET_FLP_ERROR",
62
- data: {
63
- tenant,
64
- id
65
- }
66
- });
67
- }
68
- }
69
- async create({ data }) {
70
- const keys = {
71
- ...this.createKeys(data),
72
- ...this.createGsiKeys(data)
73
- };
74
- try {
75
- await this.entity.put({
76
- ...keys,
77
- data
78
- });
79
- return data;
80
- } catch (err) {
81
- throw WebinyError.from(err, {
82
- message: "Could not create folder level permission.",
83
- code: "CREATE_FLP_ERROR",
84
- data: {
85
- keys,
86
- data
87
- }
88
- });
89
- }
90
- }
91
- async update({ data: inputData, original }) {
92
- try {
93
- const data = {
94
- ...original,
95
- ...inputData
96
- };
97
- const keys = {
98
- ...this.createKeys(data),
99
- ...this.createGsiKeys(data)
100
- };
101
- await this.entity.put({
102
- ...keys,
103
- data
104
- });
105
- return data;
106
- } catch (err) {
107
- throw WebinyError.from(err, {
108
- message: "Could not update folder level permission.",
109
- code: "UPDATE_FLP_ERROR",
110
- data: {
111
- inputData,
112
- original
113
- }
114
- });
115
- }
116
- }
117
- async delete({ flp }) {
118
- const keys = this.createKeys(flp);
119
- try {
120
- await this.entity.delete(keys);
121
- } catch (err) {
122
- throw WebinyError.from(err, {
123
- message: "Could not delete folder level permission.",
124
- code: "DELETE_FLP_ERROR",
125
- data: {
126
- keys,
127
- flp
128
- }
129
- });
130
- }
131
- }
132
- async batchUpdate({ items }) {
133
- try {
134
- const batch = this.entity.createEntityWriter();
135
- const updatedItems = [];
136
- for (const { original, data: inputData } of items){
137
- const data = {
138
- ...original,
139
- ...inputData
140
- };
141
- const keys = {
142
- ...this.createKeys(data),
143
- ...this.createGsiKeys(data)
144
- };
145
- batch.put({
146
- ...keys,
147
- data
148
- });
149
- updatedItems.push(data);
150
- }
151
- await executeWithRetry(async ()=>await batch.execute());
152
- return updatedItems;
153
- } catch (err) {
154
- throw WebinyError.from(err, {
155
- message: "Could not batch update folder level permissions.",
156
- code: "BATCH_UPDATE_FLP_ERROR",
157
- data: {
158
- items
159
- }
160
- });
161
- }
162
- }
163
- createKeys({ id, tenant }) {
164
- return {
165
- PK: `T#${tenant}#FLP#${id}`,
166
- SK: "A",
167
- TYPE: "aco.flp"
168
- };
169
- }
170
- createGsiKeys({ tenant, type, path, parentId }) {
171
- return {
172
- GSI1_PK: `T#${tenant}#AT#${type}#FLP`,
173
- GSI1_SK: path,
174
- GSI2_PK: `T#${tenant}#FLP`,
175
- GSI2_SK: parentId,
176
- GSI_TENANT: tenant
177
- };
178
- }
179
- }
180
- const createFlpOperations = (params)=>new FolderLevelPermissionsStorageOperations(params);
181
- export { createFlpOperations };
182
-
183
- //# sourceMappingURL=flp.so.js.map
package/flp/flp.so.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"flp/flp.so.js","sources":["../../src/flp/flp.so.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStandardEntity, createTable } from \"@webiny/db-dynamodb\";\n\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n AcoFolderLevelPermissionsStorageOperations as IAcoFolderLevelPermissionsStorageOperations,\n FolderLevelPermission,\n StorageOperationsBatchUpdateFlpParams,\n StorageOperationsCreateFlpParams,\n StorageOperationsDeleteFlpParams,\n StorageOperationsGetFlpParams,\n StorageOperationsListFlpsParams,\n StorageOperationsUpdateFlpParams\n} from \"~/flp/flp.types.js\";\nimport { executeWithRetry } from \"@webiny/utils\";\n\ninterface StorageOperationsConfig {\n documentClient: DynamoDBDocument;\n}\n\ninterface CreateKeysParams {\n tenant: string;\n id: string;\n}\n\ninterface CreateGsiKeysParams {\n tenant: string;\n id: string;\n type: string;\n path: string;\n parentId: string;\n}\n\nclass FolderLevelPermissionsStorageOperations implements IAcoFolderLevelPermissionsStorageOperations {\n private readonly entity;\n private readonly table;\n\n constructor({ documentClient }: StorageOperationsConfig) {\n this.table = createTable({\n name: String(process.env.DB_TABLE),\n documentClient\n });\n\n this.entity = createStandardEntity<FolderLevelPermission>({\n table: this.table.table,\n name: \"ACO.flp\"\n });\n }\n\n public async list({\n where: { tenant, type, path_startsWith, parentId }\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n try {\n if (parentId) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#FLP`,\n options: {\n index: \"GSI2\",\n eq: parentId\n }\n });\n return entries.map(entry => entry.data);\n }\n\n if (path_startsWith) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#AT#${type}#FLP`,\n options: {\n index: \"GSI1\",\n beginsWith: path_startsWith\n }\n });\n return entries.map(entry => entry.data);\n }\n\n throw new WebinyError(\"Missing required parameters.\", \"LIST_FLP_MISSING_PARAMETERS\", {\n tenant,\n type,\n path_startsWith,\n parentId\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list folder level permissions.\",\n code: \"LIST_FLP_ERROR\"\n });\n }\n }\n\n public async get({\n tenant,\n id\n }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null> {\n try {\n const entry = await this.entity.get(this.createKeys({ tenant, id }));\n\n if (!entry) {\n return null;\n }\n\n return entry.data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not load folder level permission.\",\n code: \"GET_FLP_ERROR\",\n data: { tenant, id }\n });\n }\n }\n\n public async create({\n data\n }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission> {\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n try {\n await this.entity.put({\n ...keys,\n data\n });\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not create folder level permission.\",\n code: \"CREATE_FLP_ERROR\",\n data: { keys, data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n try {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n await this.entity.put({\n ...keys,\n data\n });\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update folder level permission.\",\n code: \"UPDATE_FLP_ERROR\",\n data: { inputData, original }\n });\n }\n }\n\n public async delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void> {\n const keys = this.createKeys(flp);\n\n try {\n await this.entity.delete(keys);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: {\n keys,\n flp\n }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n try {\n const batch = this.entity.createEntityWriter();\n\n const updatedItems: FolderLevelPermission[] = [];\n\n for (const { original, data: inputData } of items) {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n batch.put({\n ...keys,\n data\n });\n\n updatedItems.push(data);\n }\n\n await executeWithRetry(async () => {\n return await batch.execute();\n });\n\n return updatedItems;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not batch update folder level permissions.\",\n code: \"BATCH_UPDATE_FLP_ERROR\",\n data: { items }\n });\n }\n }\n\n private createKeys({ id, tenant }: CreateKeysParams) {\n return {\n PK: `T#${tenant}#FLP#${id}`,\n SK: `A`,\n TYPE: \"aco.flp\"\n };\n }\n\n private createGsiKeys({ tenant, type, path, parentId }: CreateGsiKeysParams) {\n return {\n GSI1_PK: `T#${tenant}#AT#${type}#FLP`,\n GSI1_SK: path,\n GSI2_PK: `T#${tenant}#FLP`,\n GSI2_SK: parentId,\n GSI_TENANT: tenant\n };\n }\n}\n\nexport const createFlpOperations = (params: StorageOperationsConfig) => {\n return new FolderLevelPermissionsStorageOperations(params);\n};\n"],"names":["FolderLevelPermissionsStorageOperations","documentClient","createTable","String","process","createStandardEntity","tenant","type","path_startsWith","parentId","entries","entry","WebinyError","err","id","data","keys","inputData","original","flp","items","batch","updatedItems","executeWithRetry","path","createFlpOperations","params"],"mappings":";;;AAiCA,MAAMA;IAIF,YAAY,EAAEC,cAAc,EAA2B,CAAE;QACrD,IAAI,CAAC,KAAK,GAAGC,YAAY;YACrB,MAAMC,OAAOC,QAAQ,GAAG,CAAC,QAAQ;YACjCH;QACJ;QAEA,IAAI,CAAC,MAAM,GAAGI,qBAA4C;YACtD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;YACvB,MAAM;QACV;IACJ;IAEA,MAAa,KAAK,EACd,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAEC,eAAe,EAAEC,QAAQ,EAAE,EACpB,EAAoC;QAClE,IAAI;YACA,IAAIA,UAAU;gBACV,MAAMC,UAAU,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;oBACvC,cAAc,CAAC,EAAE,EAAEJ,OAAO,IAAI,CAAC;oBAC/B,SAAS;wBACL,OAAO;wBACP,IAAIG;oBACR;gBACJ;gBACA,OAAOC,QAAQ,GAAG,CAACC,CAAAA,QAASA,MAAM,IAAI;YAC1C;YAEA,IAAIH,iBAAiB;gBACjB,MAAME,UAAU,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;oBACvC,cAAc,CAAC,EAAE,EAAEJ,OAAO,IAAI,EAAEC,KAAK,IAAI,CAAC;oBAC1C,SAAS;wBACL,OAAO;wBACP,YAAYC;oBAChB;gBACJ;gBACA,OAAOE,QAAQ,GAAG,CAACC,CAAAA,QAASA,MAAM,IAAI;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,EAAE;QACjD,OAAO;YACH,IAAI,CAAC,EAAE,EAAEA,OAAO,KAAK,EAAEQ,IAAI;YAC3B,IAAI;YACJ,MAAM;QACV;IACJ;IAEQ,cAAc,EAAER,MAAM,EAAEC,IAAI,EAAEiB,IAAI,EAAEf,QAAQ,EAAuB,EAAE;QACzE,OAAO;YACH,SAAS,CAAC,EAAE,EAAEH,OAAO,IAAI,EAAEC,KAAK,IAAI,CAAC;YACrC,SAASiB;YACT,SAAS,CAAC,EAAE,EAAElB,OAAO,IAAI,CAAC;YAC1B,SAASG;YACT,YAAYH;QAChB;IACJ;AACJ;AAEO,MAAMmB,sBAAsB,CAACC,SACzB,IAAI1B,wCAAwC0B"}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createAcoContext } from \"~/createAcoContext.js\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL.js\";\nimport { createAcoTasks } from \"~/createAcoTasks.js\";\n\nexport { FILTER_MODEL_ID } from \"./filter/filter.model.js\";\n\nexport interface CreateAcoParams {\n documentClient: DynamoDBDocument;\n useFolderLevelPermissions?: boolean;\n}\n\nexport const createAco = (params: CreateAcoParams) => {\n return [createAcoContext(params), ...createAcoGraphQL(), createAcoTasks()];\n};\n\nexport * from \"./folder/createFolderModelModifier.js\";\n"],"names":["createAco","params","createAcoContext","createAcoGraphQL","createAcoTasks"],"mappings":";;;;AAYO,MAAMA,YAAY,CAACC,SACf;QAACC,iBAAiBD;WAAYE;QAAoBC;KAAiB"}