@webiny/api-aco 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2

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 (217) 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/features/ai/CreateFolderTool.d.ts +49 -0
  18. package/features/ai/CreateFolderTool.js +58 -0
  19. package/features/ai/CreateFolderTool.js.map +1 -0
  20. package/features/ai/CreateTeamTool.d.ts +48 -0
  21. package/features/ai/CreateTeamTool.js +56 -0
  22. package/features/ai/CreateTeamTool.js.map +1 -0
  23. package/features/ai/DeleteFolderTool.d.ts +48 -0
  24. package/features/ai/DeleteFolderTool.js +55 -0
  25. package/features/ai/DeleteFolderTool.js.map +1 -0
  26. package/features/ai/GrantFolderAccessTool.d.ts +77 -0
  27. package/features/ai/GrantFolderAccessTool.js +80 -0
  28. package/features/ai/GrantFolderAccessTool.js.map +1 -0
  29. package/features/ai/ListFoldersTool.d.ts +47 -0
  30. package/features/ai/ListFoldersTool.js +57 -0
  31. package/features/ai/ListFoldersTool.js.map +1 -0
  32. package/features/ai/ListRolesTool.d.ts +39 -0
  33. package/features/ai/ListRolesTool.js +48 -0
  34. package/features/ai/ListRolesTool.js.map +1 -0
  35. package/features/ai/ListTeamsTool.d.ts +39 -0
  36. package/features/ai/ListTeamsTool.js +48 -0
  37. package/features/ai/ListTeamsTool.js.map +1 -0
  38. package/features/ai/RevokeFolderAccessTool.d.ts +63 -0
  39. package/features/ai/RevokeFolderAccessTool.js +69 -0
  40. package/features/ai/RevokeFolderAccessTool.js.map +1 -0
  41. package/features/ai/assertTargetIsUsable.d.ts +10 -0
  42. package/features/ai/assertTargetIsUsable.js +14 -0
  43. package/features/ai/assertTargetIsUsable.js.map +1 -0
  44. package/features/ai/feature.d.ts +12 -0
  45. package/features/ai/feature.js +25 -0
  46. package/features/ai/feature.js.map +1 -0
  47. package/features/ai/index.d.ts +9 -0
  48. package/features/ai/index.js +9 -0
  49. package/features/ai/loadFolderPermissions.d.ts +16 -0
  50. package/features/ai/loadFolderPermissions.js +14 -0
  51. package/features/ai/loadFolderPermissions.js.map +1 -0
  52. package/features/flp/CreateFlp/CreateFlpUseCase.d.ts +3 -3
  53. package/features/flp/CreateFlp/CreateFlpUseCase.js +4 -4
  54. package/features/flp/CreateFlp/CreateFlpUseCase.js.map +1 -1
  55. package/features/flp/CreateFlp/feature.d.ts +1 -6
  56. package/features/flp/CreateFlp/feature.js +3 -2
  57. package/features/flp/CreateFlp/feature.js.map +1 -1
  58. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.d.ts +8 -5
  59. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js +21 -14
  60. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js.map +1 -1
  61. package/features/flp/DeleteFlp/DeleteFlpUseCase.d.ts +3 -3
  62. package/features/flp/DeleteFlp/DeleteFlpUseCase.js +3 -3
  63. package/features/flp/DeleteFlp/DeleteFlpUseCase.js.map +1 -1
  64. package/features/flp/DeleteFlp/feature.d.ts +1 -6
  65. package/features/flp/DeleteFlp/feature.js +3 -2
  66. package/features/flp/DeleteFlp/feature.js.map +1 -1
  67. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.d.ts +6 -5
  68. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js +16 -13
  69. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js.map +1 -1
  70. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.d.ts +4 -3
  71. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +14 -13
  72. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
  73. package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.d.ts +6 -0
  74. package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js +6 -2
  75. package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js.map +1 -1
  76. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.d.ts +13 -0
  77. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js +26 -0
  78. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js.map +1 -0
  79. package/features/flp/GetFlp/feature.d.ts +1 -1
  80. package/features/flp/GetFlp/feature.js +3 -2
  81. package/features/flp/GetFlp/feature.js.map +1 -1
  82. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.d.ts +13 -0
  83. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js +27 -0
  84. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js.map +1 -0
  85. package/features/flp/ListFlps/feature.d.ts +1 -1
  86. package/features/flp/ListFlps/feature.js +3 -2
  87. package/features/flp/ListFlps/feature.js.map +1 -1
  88. package/features/flp/UpdateFlp/UpdateFlpUseCase.d.ts +15 -8
  89. package/features/flp/UpdateFlp/UpdateFlpUseCase.js +37 -42
  90. package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
  91. package/features/flp/UpdateFlp/abstractions.d.ts +6 -2
  92. package/features/flp/UpdateFlp/abstractions.js.map +1 -1
  93. package/features/flp/UpdateFlp/feature.d.ts +1 -6
  94. package/features/flp/UpdateFlp/feature.js +7 -2
  95. package/features/flp/UpdateFlp/feature.js.map +1 -1
  96. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.d.ts +8 -5
  97. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js +21 -16
  98. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js.map +1 -1
  99. package/features/flp/shared/CodeFlpMerger.d.ts +26 -0
  100. package/features/flp/shared/CodeFlpMerger.js +20 -0
  101. package/features/flp/shared/CodeFlpMerger.js.map +1 -0
  102. package/features/flp/shared/CodeFlpPath.d.ts +15 -0
  103. package/features/flp/shared/CodeFlpPath.js +29 -0
  104. package/features/flp/shared/CodeFlpPath.js.map +1 -0
  105. package/features/flp/shared/CodeFlpTarget.d.ts +10 -0
  106. package/features/flp/shared/CodeFlpTarget.js +26 -0
  107. package/features/flp/shared/CodeFlpTarget.js.map +1 -0
  108. package/features/flp/shared/CodeFlpsProvider.d.ts +14 -0
  109. package/features/flp/shared/CodeFlpsProvider.js +33 -0
  110. package/features/flp/shared/CodeFlpsProvider.js.map +1 -0
  111. package/features/flp/shared/abstractions.d.ts +77 -0
  112. package/features/flp/shared/abstractions.js +19 -0
  113. package/features/flp/shared/abstractions.js.map +1 -0
  114. package/features/flp/shared/feature.d.ts +5 -0
  115. package/features/flp/shared/feature.js +17 -0
  116. package/features/flp/shared/feature.js.map +1 -0
  117. package/features/flp/shared/index.d.ts +4 -0
  118. package/features/flp/shared/index.js +4 -0
  119. package/features/folder/CreateFolder/CreateFolderRepository.d.ts +3 -3
  120. package/features/folder/CreateFolder/CreateFolderRepository.js +10 -7
  121. package/features/folder/CreateFolder/CreateFolderRepository.js.map +1 -1
  122. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.d.ts +9 -1
  123. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js +20 -3
  124. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js.map +1 -1
  125. package/features/folder/DeleteFolder/DeleteFolderRepository.d.ts +3 -3
  126. package/features/folder/DeleteFolder/DeleteFolderRepository.js +6 -5
  127. package/features/folder/DeleteFolder/DeleteFolderRepository.js.map +1 -1
  128. package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.d.ts +1 -3
  129. package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +3 -6
  130. package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
  131. package/features/folder/FolderModelProvider.d.ts +26 -0
  132. package/features/folder/FolderModelProvider.js +22 -0
  133. package/features/folder/FolderModelProvider.js.map +1 -0
  134. package/features/folder/GetAncestors/GetAncestorsRepository.d.ts +3 -3
  135. package/features/folder/GetAncestors/GetAncestorsRepository.js +6 -5
  136. package/features/folder/GetAncestors/GetAncestorsRepository.js.map +1 -1
  137. package/features/folder/GetFolder/GetFolderRepository.d.ts +3 -3
  138. package/features/folder/GetFolder/GetFolderRepository.js +6 -5
  139. package/features/folder/GetFolder/GetFolderRepository.js.map +1 -1
  140. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.d.ts +3 -3
  141. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js +10 -8
  142. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js.map +1 -1
  143. package/features/folder/ListFolders/ListFoldersRepository.d.ts +3 -3
  144. package/features/folder/ListFolders/ListFoldersRepository.js +8 -7
  145. package/features/folder/ListFolders/ListFoldersRepository.js.map +1 -1
  146. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +11 -0
  147. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js +38 -0
  148. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +1 -0
  149. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.d.ts +12 -0
  150. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js +24 -0
  151. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js.map +1 -0
  152. package/features/folder/NotifyFolderChange/abstractions.d.ts +28 -0
  153. package/features/folder/NotifyFolderChange/abstractions.js +8 -0
  154. package/features/folder/NotifyFolderChange/abstractions.js.map +1 -0
  155. package/features/folder/NotifyFolderChange/feature.d.ts +9 -0
  156. package/features/folder/NotifyFolderChange/feature.js +13 -0
  157. package/features/folder/NotifyFolderChange/feature.js.map +1 -0
  158. package/features/folder/NotifyFolderChange/index.d.ts +2 -0
  159. package/features/folder/NotifyFolderChange/index.js +2 -0
  160. package/features/folder/UpdateFolder/UpdateFolderRepository.d.ts +3 -3
  161. package/features/folder/UpdateFolder/UpdateFolderRepository.js +11 -8
  162. package/features/folder/UpdateFolder/UpdateFolderRepository.js.map +1 -1
  163. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.d.ts +14 -1
  164. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js +52 -4
  165. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
  166. package/features/folder/shared/abstractions.d.ts +10 -0
  167. package/features/folder/shared/abstractions.js +3 -1
  168. package/features/folder/shared/abstractions.js.map +1 -1
  169. package/filter/filter.gql.d.ts +2 -3
  170. package/filter/filter.gql.js +61 -27
  171. package/filter/filter.gql.js.map +1 -1
  172. package/filter/filter.model.js +2 -1
  173. package/filter/filter.model.js.map +1 -1
  174. package/filter/filter.so.d.ts +2 -4
  175. package/filter/filter.so.js +21 -9
  176. package/filter/filter.so.js.map +1 -1
  177. package/flp/flp.types.d.ts +6 -1
  178. package/flp/tasks/createFlp.task.d.ts +11 -4
  179. package/flp/tasks/createFlp.task.js +32 -15
  180. package/flp/tasks/createFlp.task.js.map +1 -1
  181. package/flp/tasks/deleteFlp.task.d.ts +9 -4
  182. package/flp/tasks/deleteFlp.task.js +22 -13
  183. package/flp/tasks/deleteFlp.task.js.map +1 -1
  184. package/flp/tasks/index.d.ts +0 -1
  185. package/flp/tasks/index.js +1 -14
  186. package/flp/tasks/index.js.map +1 -1
  187. package/flp/tasks/syncFlp.task.d.ts +9 -4
  188. package/flp/tasks/syncFlp.task.js +22 -13
  189. package/flp/tasks/syncFlp.task.js.map +1 -1
  190. package/flp/tasks/updateFlp.task.d.ts +11 -4
  191. package/flp/tasks/updateFlp.task.js +40 -19
  192. package/flp/tasks/updateFlp.task.js.map +1 -1
  193. package/folder/createFolderTypeDefs.js +4 -1
  194. package/folder/createFolderTypeDefs.js.map +1 -1
  195. package/folder/folder.gql.d.ts +1 -1
  196. package/folder/folder.gql.js +4 -4
  197. package/folder/folder.gql.js.map +1 -1
  198. package/index.d.ts +1 -1
  199. package/index.js +1 -11
  200. package/package.json +23 -21
  201. package/types.d.ts +1 -2
  202. package/types.js.map +1 -1
  203. package/utils/createOperationsWrapper.d.ts +4 -4
  204. package/utils/createOperationsWrapper.js +5 -5
  205. package/utils/createOperationsWrapper.js.map +1 -1
  206. package/utils/decorators/CmsEntriesCrudDecorators.js +9 -5
  207. package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
  208. package/utils/resolve.d.ts +1 -1
  209. package/utils/resolve.js +1 -1
  210. package/utils/resolve.js.map +1 -1
  211. package/createAcoContext.d.ts +0 -3
  212. package/createAcoContext.js +0 -112
  213. package/createAcoContext.js.map +0 -1
  214. package/createAcoTasks.d.ts +0 -1
  215. package/createAcoTasks.js +0 -14
  216. package/createAcoTasks.js.map +0 -1
  217. package/index.js.map +0 -1
@@ -1,30 +1,32 @@
1
- import { TaskDefinition } from "@webiny/api-core/features/task/TaskDefinition/index.js";
1
+ import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
2
  import { UPDATE_FLP_TASK_ID } from "./index.js";
3
3
  import { UpdateFlpUseCase } from "../../features/flp/UpdateFlp/index.js";
4
- class UpdateFlpTaskImpl {
5
- constructor(updateFlp){
4
+ import { NotifyFolderChangeUseCase } from "../../features/folder/NotifyFolderChange/index.js";
5
+ class UpdateFlpTaskHandlerImpl {
6
+ constructor(updateFlp, notifyFolderChange){
6
7
  this.updateFlp = updateFlp;
7
- this.id = UPDATE_FLP_TASK_ID;
8
- this.title = "ACO - Update FLP record";
9
- this.description = "Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.";
10
- this.databaseLogs = false;
11
- this.isPrivate = true;
12
- this.selfCleanup = [
13
- "onSuccess",
14
- "onAbort"
15
- ];
8
+ this.notifyFolderChange = notifyFolderChange;
16
9
  }
17
10
  async run({ input, controller }) {
18
11
  try {
19
12
  if (controller.runtime.isAborted()) return controller.response.aborted();
13
+ let continuation;
20
14
  await this.updateFlp.execute({
21
15
  folder: input.folder,
22
- queued: input.queued,
16
+ completed: input.completed,
23
17
  isCloseToTimeout: controller.runtime.isCloseToTimeout,
24
- handleTimeout: (queued)=>controller.response.continue({
18
+ handleTimeout: (completed)=>{
19
+ continuation = controller.response.continue({
25
20
  ...input,
26
- queued
27
- })
21
+ completed
22
+ });
23
+ }
24
+ });
25
+ if (continuation) return continuation;
26
+ if (input.notifyIdentityId) await this.notifyFolderChange.execute({
27
+ id: input.folder.id,
28
+ change: "updated",
29
+ identityId: input.notifyIdentityId
28
30
  });
29
31
  return controller.response.done("Task done: FLP record updated.");
30
32
  } catch (error) {
@@ -32,12 +34,31 @@ class UpdateFlpTaskImpl {
32
34
  }
33
35
  }
34
36
  }
35
- const UpdateFlpTask = TaskDefinition.createImplementation({
36
- implementation: UpdateFlpTaskImpl,
37
+ const UpdateFlpTaskHandler = TaskHandler.createImplementation({
38
+ implementation: UpdateFlpTaskHandlerImpl,
37
39
  dependencies: [
38
- UpdateFlpUseCase
40
+ UpdateFlpUseCase,
41
+ NotifyFolderChangeUseCase
39
42
  ]
40
43
  });
44
+ class UpdateFlpTaskImpl {
45
+ constructor(){
46
+ this.id = UPDATE_FLP_TASK_ID;
47
+ this.title = "ACO - Update FLP record";
48
+ this.description = "Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.";
49
+ this.databaseLogs = false;
50
+ this.isPrivate = true;
51
+ this.selfCleanup = [
52
+ "onSuccess",
53
+ "onAbort"
54
+ ];
55
+ this.handler = UpdateFlpTaskHandler;
56
+ }
57
+ }
58
+ const UpdateFlpTask = TaskDefinition.createImplementation({
59
+ implementation: UpdateFlpTaskImpl,
60
+ dependencies: []
61
+ });
41
62
  export { UpdateFlpTask };
42
63
 
43
64
  //# sourceMappingURL=updateFlp.task.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flp/tasks/updateFlp.task.js","sources":["../../../src/flp/tasks/updateFlp.task.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type IUpdateFlpTaskInput } from \"~/types.js\";\nimport { UpdateFlpUseCase } from \"~/features/flp/UpdateFlp/index.js\";\n\nclass UpdateFlpTaskImpl implements TaskDefinition.Interface<IUpdateFlpTaskInput> {\n public readonly id = UPDATE_FLP_TASK_ID;\n public readonly title = \"ACO - Update FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n public constructor(private updateFlp: UpdateFlpUseCase.Interface) {}\n\n async run({ input, controller }: TaskDefinition.RunParams<IUpdateFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n await this.updateFlp.execute({\n folder: input.folder,\n queued: input.queued,\n isCloseToTimeout: controller.runtime.isCloseToTimeout,\n handleTimeout: queued => controller.response.continue({ ...input, queued })\n });\n\n return controller.response.done(\"Task done: FLP record updated.\");\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nexport const UpdateFlpTask = TaskDefinition.createImplementation({\n implementation: UpdateFlpTaskImpl,\n dependencies: [UpdateFlpUseCase]\n});\n"],"names":["UpdateFlpTaskImpl","updateFlp","UPDATE_FLP_TASK_ID","input","controller","queued","error","UpdateFlpTask","TaskDefinition","UpdateFlpUseCase"],"mappings":";;;AAKA,MAAMA;IASF,YAA2BC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;aARX,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,WAAW,GACvB;aACY,YAAY,GAAG;aACf,SAAS,GAAG;aACZ,WAAW,GAAG;YAAC;YAAsB;SAAmB;IAEL;IAEnE,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAiD,EAAE;QAC5E,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAGtC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACzB,QAAQD,MAAM,MAAM;gBACpB,QAAQA,MAAM,MAAM;gBACpB,kBAAkBC,WAAW,OAAO,CAAC,gBAAgB;gBACrD,eAAeC,CAAAA,SAAUD,WAAW,QAAQ,CAAC,QAAQ,CAAC;wBAAE,GAAGD,KAAK;wBAAEE;oBAAO;YAC7E;YAEA,OAAOD,WAAW,QAAQ,CAAC,IAAI,CAAC;QACpC,EAAE,OAAOE,OAAO;YACZ,OAAOF,WAAW,QAAQ,CAAC,KAAK,CAACE;QACrC;IACJ;AACJ;AAEO,MAAMC,gBAAgBC,eAAe,oBAAoB,CAAC;IAC7D,gBAAgBR;IAChB,cAAc;QAACS;KAAiB;AACpC"}
1
+ {"version":3,"file":"flp/tasks/updateFlp.task.js","sources":["../../../src/flp/tasks/updateFlp.task.ts"],"sourcesContent":["import {\n TaskDefinition,\n TaskHandler\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type IUpdateFlpTaskInput } from \"~/types.js\";\nimport { UpdateFlpUseCase } from \"~/features/flp/UpdateFlp/index.js\";\nimport { NotifyFolderChangeUseCase } from \"~/features/folder/NotifyFolderChange/index.js\";\n\nclass UpdateFlpTaskHandlerImpl implements TaskHandler.Interface<IUpdateFlpTaskInput> {\n public constructor(\n private updateFlp: UpdateFlpUseCase.Interface,\n private notifyFolderChange: NotifyFolderChangeUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskHandler.RunParams<IUpdateFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n /*\n * `response.continue()` only builds the result; it does nothing until the task returns\n * it. Returning `done` regardless used to drop the continuation, leaving the rest of a\n * large subtree with its old permissions.\n */\n let continuation: ReturnType<typeof controller.response.continue> | undefined;\n\n await this.updateFlp.execute({\n folder: input.folder,\n completed: input.completed,\n isCloseToTimeout: controller.runtime.isCloseToTimeout,\n handleTimeout: completed => {\n continuation = controller.response.continue({ ...input, completed });\n }\n });\n\n if (continuation) {\n return continuation;\n }\n\n // Only the last run tells the admin: before it, part of the subtree is still stale.\n if (input.notifyIdentityId) {\n await this.notifyFolderChange.execute({\n id: input.folder.id,\n change: \"updated\",\n identityId: input.notifyIdentityId\n });\n }\n\n return controller.response.done(\"Task done: FLP record updated.\");\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nconst UpdateFlpTaskHandler = TaskHandler.createImplementation({\n implementation: UpdateFlpTaskHandlerImpl,\n dependencies: [UpdateFlpUseCase, NotifyFolderChangeUseCase]\n});\n\nclass UpdateFlpTaskImpl implements TaskDefinition.Interface {\n public readonly id = UPDATE_FLP_TASK_ID;\n public readonly title = \"ACO - Update FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n handler = UpdateFlpTaskHandler;\n}\n\nexport const UpdateFlpTask = TaskDefinition.createImplementation({\n implementation: UpdateFlpTaskImpl,\n dependencies: []\n});\n"],"names":["UpdateFlpTaskHandlerImpl","updateFlp","notifyFolderChange","input","controller","continuation","completed","error","UpdateFlpTaskHandler","TaskHandler","UpdateFlpUseCase","NotifyFolderChangeUseCase","UpdateFlpTaskImpl","UPDATE_FLP_TASK_ID","UpdateFlpTask","TaskDefinition"],"mappings":";;;;AASA,MAAMA;IACF,YACYC,SAAqC,EACrCC,kBAAuD,CACjE;aAFUD,SAAS,GAATA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAA8C,EAAE;QACzE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAQtC,IAAIC;YAEJ,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACzB,QAAQF,MAAM,MAAM;gBACpB,WAAWA,MAAM,SAAS;gBAC1B,kBAAkBC,WAAW,OAAO,CAAC,gBAAgB;gBACrD,eAAeE,CAAAA;oBACXD,eAAeD,WAAW,QAAQ,CAAC,QAAQ,CAAC;wBAAE,GAAGD,KAAK;wBAAEG;oBAAU;gBACtE;YACJ;YAEA,IAAID,cACA,OAAOA;YAIX,IAAIF,MAAM,gBAAgB,EACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAClC,IAAIA,MAAM,MAAM,CAAC,EAAE;gBACnB,QAAQ;gBACR,YAAYA,MAAM,gBAAgB;YACtC;YAGJ,OAAOC,WAAW,QAAQ,CAAC,IAAI,CAAC;QACpC,EAAE,OAAOG,OAAO;YACZ,OAAOH,WAAW,QAAQ,CAAC,KAAK,CAACG;QACrC;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,YAAY,oBAAoB,CAAC;IAC1D,gBAAgBT;IAChB,cAAc;QAACU;QAAkBC;KAA0B;AAC/D;AAEA,MAAMC;;aACc,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,WAAW,GACvB;aACY,YAAY,GAAG;aACf,SAAS,GAAG;aACZ,WAAW,GAAG;YAAC;YAAsB;SAAmB;aAExE,OAAO,GAAGL;;AACd;AAEO,MAAMM,gBAAgBC,eAAe,oBAAoB,CAAC;IAC7D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -163,8 +163,11 @@ const createFolderTypeDefs = (params)=>{
163
163
 
164
164
  extend type AcoFolder_Permissions {
165
165
  inheritedFrom: ID
166
+ # Set on permissions contributed from code, via an "FlpFactory". Read-only by design:
167
+ # deliberately absent from the input type below, so it cannot be assigned via the API.
168
+ plugin: Boolean
166
169
  }
167
-
170
+
168
171
  extend input AcoFolder_PermissionsInput {
169
172
  inheritedFrom: ID
170
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"folder/createFolderTypeDefs.js","sources":["../../src/folder/createFolderTypeDefs.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nexport interface CreateFolderTypeDefsParams {\n model: CmsModel;\n models: CmsModel[];\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createFolderTypeDefs = (params: CreateFolderTypeDefsParams): string => {\n const { model, models, fieldRegistry } = params;\n const { fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldRegistry\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldRegistry\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldRegistry\n });\n\n return /* GraphQL */ `\n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n \n type Folder {\n id: ID!\n # Tells us if the current user can manage folder structure.\n canManageStructure: Boolean\n\n # Tells us if the current user can manage folder permissions.\n canManagePermissions: Boolean\n\n # Tells us if the current user can manage folder content.\n canManageContent: Boolean\n\n # Tells us if the folder contains non-inherited permissions.\n hasNonInheritedPermissions: Boolean\n\n createdOn: DateTime\n modifiedOn: DateTime\n savedOn: DateTime\n createdBy: AcoUser\n modifiedBy: AcoUser\n savedBy: AcoUser\n \n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input FolderCreateInput {\n # Pass an ID if you want to create a folder with a specific ID.\n id: ID \n \n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n \n input FolderUpdateInput {\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n \n input FoldersListWhereInput {\n type: String!\n parentId: ID\n parentId_in: [ID]\n slug: String\n slug_not: String\n slug_contains: String\n slug_not_contains: String\n slug_in: [String]\n slug_not_in: [String]\n slug_startsWith: String\n slug_not_startsWith: String\n path: String\n path_not: String\n path_contains: String\n path_not_contains: String\n path_in: [String]\n path_not_in: [String]\n path_startsWith: String\n path_not_startsWith: String\n createdBy: ID\n }\n \n type FolderResponse {\n data: Folder\n error: AcoError\n }\n\n type FoldersListResponse {\n data: [Folder]\n error: AcoError\n meta: AcoMeta\n }\n\n type FoldersHierarchyData {\n parents: [Folder]\n siblings: [Folder]\n }\n\n type FoldersHierarchyResponse {\n data: FoldersHierarchyData\n error: AcoError\n }\n\n type FolderLevelPermissionsTarget {\n id: ID!\n type: String!\n target: ID!\n name: String!\n meta: JSON\n }\n\n type FolderLevelPermissionsTargetsListMeta {\n totalCount: Int!\n }\n\n type FolderLevelPermissionsTargetsListResponse {\n data: [FolderLevelPermissionsTarget]\n meta: FolderLevelPermissionsTargetsListMeta\n error: AcoError\n }\n \n type FolderModelResponse {\n data: JSON\n error: AcoError\n }\n\n extend type AcoQuery {\n getFolderModel: FolderModelResponse!\n getFolder(id: ID!): FolderResponse\n listFolders(\n where: FoldersListWhereInput!\n limit: Int\n after: String\n sort: AcoSort\n ): FoldersListResponse\n getFolderHierarchy(type: String!, id: ID!): FoldersHierarchyResponse\n listFolderLevelPermissionsTargets: FolderLevelPermissionsTargetsListResponse\n }\n\n extend type AcoMutation {\n createFolder(data: FolderCreateInput!): FolderResponse\n updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse\n deleteFolder(id: ID!): AcoBooleanResponse\n }\n \n # The base type is dynamically generated from a Folder model\n \n extend type AcoFolder_Permissions {\n inheritedFrom: ID\n }\n \n extend input AcoFolder_PermissionsInput {\n inheritedFrom: ID\n }\n `;\n};\n"],"names":["removeFieldRequiredValidation","field","validation","v","createUpdateFields","fields","collection","createFolderTypeDefs","params","model","models","fieldRegistry","fieldTypes","renderFields","inputCreateFields","renderInputFields","inputUpdateFields","f"],"mappings":";;AAWA,MAAMA,gCAAgC,CAACC;IACnC,IAAIA,MAAM,UAAU,EAChBA,MAAM,UAAU,GAAGA,MAAM,UAAU,CAAC,MAAM,CAACC,CAAAA,aAAcA,AAAoB,eAApBA,WAAW,IAAI;IAE5E,IAAID,MAAM,cAAc,EACpBA,MAAM,cAAc,GAAGA,MAAM,cAAc,CAAC,MAAM,CAACE,CAAAA,IAAKA,AAAW,eAAXA,EAAE,IAAI;IAElE,OAAOF;AACX;AAEA,MAAMG,qBAAqB,CAACC,SACjBA,OAAO,MAAM,CAAkB,CAACC,YAAYL;QAC/CK,WAAW,IAAI,CAACN,8BAA8B;YAAE,GAAGC,KAAK;QAAC;QACzD,OAAOK;IACX,GAAG,EAAE;AAGF,MAAMC,uBAAuB,CAACC;IACjC,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,aAAa,EAAE,GAAGH;IACzC,MAAM,EAAEH,MAAM,EAAE,GAAGI;IAEnB,MAAMG,aAAaC,aAAa;QAC5BH;QACAD;QACAJ;QACA,MAAM;QACNM;IACJ;IACA,MAAMG,oBAAoBC,kBAAkB;QACxCL;QACAD;QACAJ;QACAM;IACJ;IACA,MAAMK,oBAAoBD,kBAAkB;QACxCL;QACAD;QACA,QAAQL,mBAAmBC;QAC3BM;IACJ;IAEA,OAAqB,CAAC;QAClB,EAAEC,WAAW,GAAG,CAACK,CAAAA,IAAKA,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;YAuBzC,EAAEL,WAAW,GAAG,CAACK,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;;;QAG/C,EAAEH,kBAAkB,GAAG,CAACG,CAAAA,IAAKA,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM;;;;;;aAM/C,EAAEH,kBAAkB,GAAG,CAACG,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;;;;YAInD,EAAED,kBAAkB,GAAG,CAACC,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkG1D,CAAC;AACL"}
1
+ {"version":3,"file":"folder/createFolderTypeDefs.js","sources":["../../src/folder/createFolderTypeDefs.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nexport interface CreateFolderTypeDefsParams {\n model: CmsModel;\n models: CmsModel[];\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createFolderTypeDefs = (params: CreateFolderTypeDefsParams): string => {\n const { model, models, fieldRegistry } = params;\n const { fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldRegistry\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldRegistry\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldRegistry\n });\n\n return /* GraphQL */ `\n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n \n type Folder {\n id: ID!\n # Tells us if the current user can manage folder structure.\n canManageStructure: Boolean\n\n # Tells us if the current user can manage folder permissions.\n canManagePermissions: Boolean\n\n # Tells us if the current user can manage folder content.\n canManageContent: Boolean\n\n # Tells us if the folder contains non-inherited permissions.\n hasNonInheritedPermissions: Boolean\n\n createdOn: DateTime\n modifiedOn: DateTime\n savedOn: DateTime\n createdBy: AcoUser\n modifiedBy: AcoUser\n savedBy: AcoUser\n \n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input FolderCreateInput {\n # Pass an ID if you want to create a folder with a specific ID.\n id: ID \n \n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n \n input FolderUpdateInput {\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n \n input FoldersListWhereInput {\n type: String!\n parentId: ID\n parentId_in: [ID]\n slug: String\n slug_not: String\n slug_contains: String\n slug_not_contains: String\n slug_in: [String]\n slug_not_in: [String]\n slug_startsWith: String\n slug_not_startsWith: String\n path: String\n path_not: String\n path_contains: String\n path_not_contains: String\n path_in: [String]\n path_not_in: [String]\n path_startsWith: String\n path_not_startsWith: String\n createdBy: ID\n }\n \n type FolderResponse {\n data: Folder\n error: AcoError\n }\n\n type FoldersListResponse {\n data: [Folder]\n error: AcoError\n meta: AcoMeta\n }\n\n type FoldersHierarchyData {\n parents: [Folder]\n siblings: [Folder]\n }\n\n type FoldersHierarchyResponse {\n data: FoldersHierarchyData\n error: AcoError\n }\n\n type FolderLevelPermissionsTarget {\n id: ID!\n type: String!\n target: ID!\n name: String!\n meta: JSON\n }\n\n type FolderLevelPermissionsTargetsListMeta {\n totalCount: Int!\n }\n\n type FolderLevelPermissionsTargetsListResponse {\n data: [FolderLevelPermissionsTarget]\n meta: FolderLevelPermissionsTargetsListMeta\n error: AcoError\n }\n \n type FolderModelResponse {\n data: JSON\n error: AcoError\n }\n\n extend type AcoQuery {\n getFolderModel: FolderModelResponse!\n getFolder(id: ID!): FolderResponse\n listFolders(\n where: FoldersListWhereInput!\n limit: Int\n after: String\n sort: AcoSort\n ): FoldersListResponse\n getFolderHierarchy(type: String!, id: ID!): FoldersHierarchyResponse\n listFolderLevelPermissionsTargets: FolderLevelPermissionsTargetsListResponse\n }\n\n extend type AcoMutation {\n createFolder(data: FolderCreateInput!): FolderResponse\n updateFolder(id: ID!, data: FolderUpdateInput!): FolderResponse\n deleteFolder(id: ID!): AcoBooleanResponse\n }\n \n # The base type is dynamically generated from a Folder model\n \n extend type AcoFolder_Permissions {\n inheritedFrom: ID\n # Set on permissions contributed from code, via an \"FlpFactory\". Read-only by design:\n # deliberately absent from the input type below, so it cannot be assigned via the API.\n plugin: Boolean\n }\n\n extend input AcoFolder_PermissionsInput {\n inheritedFrom: ID\n }\n `;\n};\n"],"names":["removeFieldRequiredValidation","field","validation","v","createUpdateFields","fields","collection","createFolderTypeDefs","params","model","models","fieldRegistry","fieldTypes","renderFields","inputCreateFields","renderInputFields","inputUpdateFields","f"],"mappings":";;AAWA,MAAMA,gCAAgC,CAACC;IACnC,IAAIA,MAAM,UAAU,EAChBA,MAAM,UAAU,GAAGA,MAAM,UAAU,CAAC,MAAM,CAACC,CAAAA,aAAcA,AAAoB,eAApBA,WAAW,IAAI;IAE5E,IAAID,MAAM,cAAc,EACpBA,MAAM,cAAc,GAAGA,MAAM,cAAc,CAAC,MAAM,CAACE,CAAAA,IAAKA,AAAW,eAAXA,EAAE,IAAI;IAElE,OAAOF;AACX;AAEA,MAAMG,qBAAqB,CAACC,SACjBA,OAAO,MAAM,CAAkB,CAACC,YAAYL;QAC/CK,WAAW,IAAI,CAACN,8BAA8B;YAAE,GAAGC,KAAK;QAAC;QACzD,OAAOK;IACX,GAAG,EAAE;AAGF,MAAMC,uBAAuB,CAACC;IACjC,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,aAAa,EAAE,GAAGH;IACzC,MAAM,EAAEH,MAAM,EAAE,GAAGI;IAEnB,MAAMG,aAAaC,aAAa;QAC5BH;QACAD;QACAJ;QACA,MAAM;QACNM;IACJ;IACA,MAAMG,oBAAoBC,kBAAkB;QACxCL;QACAD;QACAJ;QACAM;IACJ;IACA,MAAMK,oBAAoBD,kBAAkB;QACxCL;QACAD;QACA,QAAQL,mBAAmBC;QAC3BM;IACJ;IAEA,OAAqB,CAAC;QAClB,EAAEC,WAAW,GAAG,CAACK,CAAAA,IAAKA,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;YAuBzC,EAAEL,WAAW,GAAG,CAACK,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;;;QAG/C,EAAEH,kBAAkB,GAAG,CAACG,CAAAA,IAAKA,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM;;;;;;aAM/C,EAAEH,kBAAkB,GAAG,CAACG,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;;;;YAInD,EAAED,kBAAkB,GAAG,CAACC,CAAAA,IAAKA,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqG1D,CAAC;AACL"}
@@ -1,4 +1,4 @@
1
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
1
+ import { GraphQLSchemaPlugin } from "@webiny/api-graphql/plugins/GraphQLSchemaPlugin.js";
2
2
  import type { CreateFolderTypeDefsParams } from "./createFolderTypeDefs.js";
3
3
  import type { AcoContext } from "../types.js";
4
4
  export declare const createFoldersSchema: (params: CreateFolderTypeDefsParams) => GraphQLSchemaPlugin<AcoContext>;
@@ -1,5 +1,5 @@
1
- import { ErrorResponse, ListResponse } from "@webiny/handler-graphql/responses.js";
2
- import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
1
+ import { ErrorResponse, ListResponse } from "@webiny/api-graphql/responses.js";
2
+ import { GraphQLSchemaPlugin } from "@webiny/api-graphql/plugins/GraphQLSchemaPlugin.js";
3
3
  import { createFolderTypeDefs } from "./createFolderTypeDefs.js";
4
4
  import { ensureAuthentication } from "../utils/ensureAuthentication.js";
5
5
  import { resolve } from "../utils/resolve.js";
@@ -11,7 +11,7 @@ import { UpdateFolderUseCase } from "../features/folder/UpdateFolder/abstraction
11
11
  import { DeleteFolderUseCase } from "../features/folder/DeleteFolder/abstractions.js";
12
12
  import { GetFolderHierarchyUseCase } from "../features/folder/GetFolderHierarchy/abstractions.js";
13
13
  import { ListFolderLevelPermissionsTargetsUseCase } from "../features/folder/ListFolderLevelPermissionsTargets/abstractions.js";
14
- import { FolderModel } from "../domain/folder/abstractions.js";
14
+ import { FolderModelProvider } from "../domain/folder/abstractions.js";
15
15
  import { ValuesSelectionGenerator } from "@webiny/api-headless-cms/features/contentModel/ValuesSelectionGenerator/abstractions.js";
16
16
  const createFoldersSchema = (params)=>{
17
17
  const folderGraphQL = new GraphQLSchemaPlugin({
@@ -39,7 +39,7 @@ const createFoldersSchema = (params)=>{
39
39
  getFolderModel (_, __, context) {
40
40
  return resolve(async ()=>{
41
41
  ensureAuthentication(context);
42
- const model = context.container.resolve(FolderModel);
42
+ const model = await context.container.resolve(FolderModelProvider).get();
43
43
  const generator = context.container.resolve(ValuesSelectionGenerator);
44
44
  return {
45
45
  ...model,
@@ -1 +1 @@
1
- {"version":3,"file":"folder/folder.gql.js","sources":["../../src/folder/folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\n\nimport type { CreateFolderTypeDefsParams } from \"./createFolderTypeDefs.js\";\nimport { createFolderTypeDefs } from \"./createFolderTypeDefs.js\";\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication.js\";\nimport { resolve } from \"~/utils/resolve.js\";\nimport type { AcoContext, Folder } from \"~/types.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\nimport { CreateFolderUseCase } from \"~/features/folder/CreateFolder/abstractions.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/abstractions.js\";\nimport { DeleteFolderUseCase } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport { GetFolderHierarchyUseCase } from \"~/features/folder/GetFolderHierarchy/abstractions.js\";\nimport { ListFolderLevelPermissionsTargetsUseCase } from \"~/features/folder/ListFolderLevelPermissionsTargets/abstractions.js\";\nimport { FolderModel } from \"~/domain/folder/abstractions.js\";\nimport { ValuesSelectionGenerator } from \"@webiny/api-headless-cms/features/contentModel/ValuesSelectionGenerator/abstractions.js\";\n\nexport const createFoldersSchema = (params: CreateFolderTypeDefsParams) => {\n const folderGraphQL = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: createFolderTypeDefs(params),\n resolvers: {\n Folder: {\n hasNonInheritedPermissions: (folder: Folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.permissionsIncludeNonInheritedPermissions(folder.permissions ?? []);\n },\n canManageStructure: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderStructure(folder);\n },\n canManagePermissions: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderPermissions(folder);\n },\n canManageContent: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderContent(folder);\n }\n },\n AcoQuery: {\n getFolderModel(_, __, context) {\n return resolve(async () => {\n ensureAuthentication(context);\n const model = context.container.resolve(FolderModel);\n const generator = context.container.resolve(ValuesSelectionGenerator);\n return {\n ...model,\n valuesSelection: generator.generate(model)\n };\n });\n },\n getFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderUseCase = context.container.resolve(GetFolderUseCase);\n const result = await getFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listFoldersUseCase = context.container.resolve(ListFoldersUseCase);\n const result = await listFoldersUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n const { folders, meta } = result.value;\n return new ListResponse(folders, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n getFolderHierarchy: async (_, args: any, context) => {\n try {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderHierarchyUseCase =\n context.container.resolve(GetFolderHierarchyUseCase);\n const result = await getFolderHierarchyUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listFolderLevelPermissionsTargets: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listTargetsUseCase = context.container.resolve(\n ListFolderLevelPermissionsTargetsUseCase\n );\n const result = await listTargetsUseCase.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const [entries, meta] = result.value;\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const createFolderUseCase = context.container.resolve(CreateFolderUseCase);\n const result = await createFolderUseCase.execute(data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const updateFolderUseCase = context.container.resolve(UpdateFolderUseCase);\n const result = await updateFolderUseCase.execute(id, data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const deleteFolderUseCase = context.container.resolve(DeleteFolderUseCase);\n const result = await deleteFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return true;\n });\n }\n }\n }\n });\n\n folderGraphQL.name = \"aco.graphql.folders\";\n\n return folderGraphQL;\n};\n"],"names":["createFoldersSchema","params","folderGraphQL","GraphQLSchemaPlugin","createFolderTypeDefs","folder","_","context","flp","FolderLevelPermissions","__","resolve","ensureAuthentication","model","FolderModel","generator","ValuesSelectionGenerator","id","getFolderUseCase","GetFolderUseCase","result","args","listFoldersUseCase","ListFoldersUseCase","folders","meta","ListResponse","e","ErrorResponse","getFolderHierarchyUseCase","GetFolderHierarchyUseCase","listTargetsUseCase","ListFolderLevelPermissionsTargetsUseCase","entries","data","createFolderUseCase","CreateFolderUseCase","updateFolderUseCase","UpdateFolderUseCase","deleteFolderUseCase","DeleteFolderUseCase"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,gBAAgB,IAAIC,oBAAgC;QACtD,UAAUC,qBAAqBH;QAC/B,WAAW;YACP,QAAQ;gBACJ,4BAA4B,CAACI,QAAgBC,GAAGC;oBAC5C,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,yCAAyC,CAACH,OAAO,WAAW,IAAI,EAAE;gBACjF;gBACA,oBAAoB,CAACA,QAAQC,GAAGC;oBAC5B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,wBAAwB,CAACH;gBACxC;gBACA,sBAAsB,CAACA,QAAQC,GAAGC;oBAC9B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,0BAA0B,CAACH;gBAC1C;gBACA,kBAAkB,CAACA,QAAQC,GAAGC;oBAC1B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,sBAAsB,CAACH;gBACtC;YACJ;YACA,UAAU;gBACN,gBAAeC,CAAC,EAAEI,EAAE,EAAEH,OAAO;oBACzB,OAAOI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAMM,QAAQN,QAAQ,SAAS,CAAC,OAAO,CAACO;wBACxC,MAAMC,YAAYR,QAAQ,SAAS,CAAC,OAAO,CAACS;wBAC5C,OAAO;4BACH,GAAGH,KAAK;4BACR,iBAAiBE,UAAU,QAAQ,CAACF;wBACxC;oBACJ;gBACJ;gBACA,WAAW,OAAOP,GAAG,EAAEW,EAAE,EAAE,EAAEV,UAClBI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAMW,mBAAmBX,QAAQ,SAAS,CAAC,OAAO,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AAcD;oBAC7B;gBACJ;YACJ;YACA,aAAa;gBACT,cAAc,OAAOrB,GAAG,EAAE4B,IAAI,EAAE,EAAE3B,UACvBI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAM4B,sBAAsB5B,QAAQ,SAAS,CAAC,OAAO,CAAC6B;wBACtD,MAAMhB,SAAS,MAAMe,oBAAoB,OAAO,CAACD;wBACjD,IAAId,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAOA,OAAO,KAAK;oBACvB;gBAEJ,cAAc,OAAOd,GAAG,EAAEW,EAAE,EAAEiB,IAAI,EAAE,EAAE3B,UAC3BI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAM8B,sBAAsB9B,QAAQ,SAAS,CAAC,OAAO,CAAC+B;wBACtD,MAAMlB,SAAS,MAAMiB,oBAAoB,OAAO,CAACpB,IAAIiB;wBACrD,IAAId,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAOA,OAAO,KAAK;oBACvB;gBAEJ,cAAc,OAAOd,GAAG,EAAEW,EAAE,EAAE,EAAEV,UACrBI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAMgC,sBAAsBhC,QAAQ,SAAS,CAAC,OAAO,CAACiC;wBACtD,MAAMpB,SAAS,MAAMmB,oBAAoB,OAAO,CAACtB;wBACjD,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAO;oBACX;YAER;QACJ;IACJ;IAEAlB,cAAc,IAAI,GAAG;IAErB,OAAOA;AACX"}
1
+ {"version":3,"file":"folder/folder.gql.js","sources":["../../src/folder/folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/api-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/api-graphql/plugins/GraphQLSchemaPlugin.js\";\n\nimport type { CreateFolderTypeDefsParams } from \"./createFolderTypeDefs.js\";\nimport { createFolderTypeDefs } from \"./createFolderTypeDefs.js\";\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication.js\";\nimport { resolve } from \"~/utils/resolve.js\";\nimport type { AcoContext, Folder } from \"~/types.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\nimport { CreateFolderUseCase } from \"~/features/folder/CreateFolder/abstractions.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/abstractions.js\";\nimport { DeleteFolderUseCase } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport { GetFolderHierarchyUseCase } from \"~/features/folder/GetFolderHierarchy/abstractions.js\";\nimport { ListFolderLevelPermissionsTargetsUseCase } from \"~/features/folder/ListFolderLevelPermissionsTargets/abstractions.js\";\nimport { FolderModelProvider } from \"~/domain/folder/abstractions.js\";\nimport { ValuesSelectionGenerator } from \"@webiny/api-headless-cms/features/contentModel/ValuesSelectionGenerator/abstractions.js\";\n\nexport const createFoldersSchema = (params: CreateFolderTypeDefsParams) => {\n const folderGraphQL = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: createFolderTypeDefs(params),\n resolvers: {\n Folder: {\n hasNonInheritedPermissions: (folder: Folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.permissionsIncludeNonInheritedPermissions(folder.permissions ?? []);\n },\n canManageStructure: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderStructure(folder);\n },\n canManagePermissions: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderPermissions(folder);\n },\n canManageContent: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderContent(folder);\n }\n },\n AcoQuery: {\n getFolderModel(_, __, context) {\n return resolve(async () => {\n ensureAuthentication(context);\n const model = await context.container.resolve(FolderModelProvider).get();\n const generator = context.container.resolve(ValuesSelectionGenerator);\n return {\n ...model,\n valuesSelection: generator.generate(model)\n };\n });\n },\n getFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderUseCase = context.container.resolve(GetFolderUseCase);\n const result = await getFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listFoldersUseCase = context.container.resolve(ListFoldersUseCase);\n const result = await listFoldersUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n const { folders, meta } = result.value;\n return new ListResponse(folders, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n getFolderHierarchy: async (_, args: any, context) => {\n try {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderHierarchyUseCase =\n context.container.resolve(GetFolderHierarchyUseCase);\n const result = await getFolderHierarchyUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listFolderLevelPermissionsTargets: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listTargetsUseCase = context.container.resolve(\n ListFolderLevelPermissionsTargetsUseCase\n );\n const result = await listTargetsUseCase.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const [entries, meta] = result.value;\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const createFolderUseCase = context.container.resolve(CreateFolderUseCase);\n const result = await createFolderUseCase.execute(data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const updateFolderUseCase = context.container.resolve(UpdateFolderUseCase);\n const result = await updateFolderUseCase.execute(id, data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const deleteFolderUseCase = context.container.resolve(DeleteFolderUseCase);\n const result = await deleteFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return true;\n });\n }\n }\n }\n });\n\n folderGraphQL.name = \"aco.graphql.folders\";\n\n return folderGraphQL;\n};\n"],"names":["createFoldersSchema","params","folderGraphQL","GraphQLSchemaPlugin","createFolderTypeDefs","folder","_","context","flp","FolderLevelPermissions","__","resolve","ensureAuthentication","model","FolderModelProvider","generator","ValuesSelectionGenerator","id","getFolderUseCase","GetFolderUseCase","result","args","listFoldersUseCase","ListFoldersUseCase","folders","meta","ListResponse","e","ErrorResponse","getFolderHierarchyUseCase","GetFolderHierarchyUseCase","listTargetsUseCase","ListFolderLevelPermissionsTargetsUseCase","entries","data","createFolderUseCase","CreateFolderUseCase","updateFolderUseCase","UpdateFolderUseCase","deleteFolderUseCase","DeleteFolderUseCase"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,gBAAgB,IAAIC,oBAAgC;QACtD,UAAUC,qBAAqBH;QAC/B,WAAW;YACP,QAAQ;gBACJ,4BAA4B,CAACI,QAAgBC,GAAGC;oBAC5C,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,yCAAyC,CAACH,OAAO,WAAW,IAAI,EAAE;gBACjF;gBACA,oBAAoB,CAACA,QAAQC,GAAGC;oBAC5B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,wBAAwB,CAACH;gBACxC;gBACA,sBAAsB,CAACA,QAAQC,GAAGC;oBAC9B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,0BAA0B,CAACH;gBAC1C;gBACA,kBAAkB,CAACA,QAAQC,GAAGC;oBAC1B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,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SAAS,CAAC,OAAO,CAACiC;wBACtD,MAAMpB,SAAS,MAAMmB,oBAAoB,OAAO,CAACtB;wBACjD,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAO;oBACX;YAER;QACJ;IACJ;IAEAlB,cAAc,IAAI,GAAG;IAErB,OAAOA;AACX"}
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { FILTER_MODEL_ID } from "./filter/filter.model.js";
2
- export declare const createAco: () => ((import("@webiny/api/index.js").ContextPlugin<import("./types.js").AcoContext> | import("@webiny/handler/index.js").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>)[] | import("@webiny/api/index.js").ContextPlugin<import("./types.js").AcoContext> | import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<import("./types.js").AcoContext>)[];
3
2
  export * from "./folder/createFolderModelModifier.js";
3
+ export { AcoFeature } from "./AcoFeature.js";
package/index.js CHANGED
@@ -1,13 +1,3 @@
1
- import { createAcoContext } from "./createAcoContext.js";
2
- import { createAcoGraphQL } from "./createAcoGraphQL.js";
3
- import { createAcoTasks } from "./createAcoTasks.js";
4
1
  export * from "./folder/createFolderModelModifier.js";
5
- const createAco = ()=>[
6
- createAcoContext(),
7
- ...createAcoGraphQL(),
8
- createAcoTasks()
9
- ];
10
2
  export { FILTER_MODEL_ID } from "./filter/filter.model.js";
11
- export { createAco };
12
-
13
- //# sourceMappingURL=index.js.map
3
+ export { AcoFeature } from "./AcoFeature.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco",
3
- "version": "0.0.0-unstable.a4f3e4ea8b",
3
+ "version": "0.0.0-unstable.a85ef555b2",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "aco:base"
@@ -21,31 +21,33 @@
21
21
  ".": "./index.js"
22
22
  },
23
23
  "dependencies": {
24
- "@webiny/api": "0.0.0-unstable.a4f3e4ea8b",
25
- "@webiny/api-core": "0.0.0-unstable.a4f3e4ea8b",
26
- "@webiny/api-headless-cms": "0.0.0-unstable.a4f3e4ea8b",
27
- "@webiny/background-tasks": "0.0.0-unstable.a4f3e4ea8b",
28
- "@webiny/di": "1.0.2",
29
- "@webiny/error": "0.0.0-unstable.a4f3e4ea8b",
30
- "@webiny/feature": "0.0.0-unstable.a4f3e4ea8b",
31
- "@webiny/handler": "0.0.0-unstable.a4f3e4ea8b",
32
- "@webiny/handler-graphql": "0.0.0-unstable.a4f3e4ea8b",
33
- "@webiny/shared-aco": "0.0.0-unstable.a4f3e4ea8b",
34
- "@webiny/utils": "0.0.0-unstable.a4f3e4ea8b",
35
- "@webiny/validation": "0.0.0-unstable.a4f3e4ea8b",
36
- "lodash": "4.18.1"
24
+ "@webiny/api-core": "0.0.0-unstable.a85ef555b2",
25
+ "@webiny/api-graphql": "0.0.0-unstable.a85ef555b2",
26
+ "@webiny/api-headless-cms": "0.0.0-unstable.a85ef555b2",
27
+ "@webiny/api-websockets": "0.0.0-unstable.a85ef555b2",
28
+ "@webiny/di": "2.0.0",
29
+ "@webiny/error": "0.0.0-unstable.a85ef555b2",
30
+ "@webiny/event-handler-core": "0.0.0-unstable.a85ef555b2",
31
+ "@webiny/feature": "0.0.0-unstable.a85ef555b2",
32
+ "@webiny/handler": "0.0.0-unstable.a85ef555b2",
33
+ "@webiny/shared-aco": "0.0.0-unstable.a85ef555b2",
34
+ "@webiny/utils": "0.0.0-unstable.a85ef555b2",
35
+ "@webiny/validation": "0.0.0-unstable.a85ef555b2",
36
+ "lodash": "4.18.1",
37
+ "zod": "4.4.3"
37
38
  },
38
39
  "devDependencies": {
39
- "@webiny/api-file-manager": "0.0.0-unstable.a4f3e4ea8b",
40
- "@webiny/build-tools": "0.0.0-unstable.a4f3e4ea8b",
41
- "@webiny/handler-aws": "0.0.0-unstable.a4f3e4ea8b",
42
- "@webiny/plugins": "0.0.0-unstable.a4f3e4ea8b",
43
- "@webiny/project-utils": "0.0.0-unstable.a4f3e4ea8b",
44
- "@webiny/wcp": "0.0.0-unstable.a4f3e4ea8b",
40
+ "@webiny/api": "0.0.0-unstable.a85ef555b2",
41
+ "@webiny/api-core-testing": "0.0.0-unstable.a85ef555b2",
42
+ "@webiny/api-file-manager": "0.0.0-unstable.a85ef555b2",
43
+ "@webiny/api-headless-cms-testing": "0.0.0-unstable.a85ef555b2",
44
+ "@webiny/build-tools": "0.0.0-unstable.a85ef555b2",
45
+ "@webiny/plugins": "0.0.0-unstable.a85ef555b2",
46
+ "@webiny/wcp": "0.0.0-unstable.a85ef555b2",
45
47
  "graphql": "16.14.2",
46
48
  "rimraf": "6.1.3",
47
49
  "typescript": "7.0.2",
48
- "vitest": "4.1.10"
50
+ "vitest": "4.1.11"
49
51
  },
50
52
  "webiny": {
51
53
  "publishFrom": "dist"
package/types.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { Context as BaseContext } from "@webiny/handler/types.js";
2
- import type { Context as TasksContext } from "@webiny/background-tasks/api/types.js";
3
2
  import type { CmsContext } from "@webiny/api-headless-cms/types/index.js";
4
3
  import type { AcoFilterCrud, AcoFilterStorageOperations } from "./filter/filter.types.js";
5
4
  import type { AcoFolderLevelPermissionsCrud, AcoFolderLevelPermissionsStorageOperations } from "./flp/flp.types.js";
@@ -49,6 +48,6 @@ export interface AcoStorageOperations {
49
48
  filter: AcoFilterStorageOperations;
50
49
  flp: AcoFolderLevelPermissionsStorageOperations;
51
50
  }
52
- export interface AcoContext extends BaseContext, ApiCoreContext, CmsContext, TasksContext {
51
+ export interface AcoContext extends BaseContext, ApiCoreContext, CmsContext {
53
52
  aco: AdvancedContentOrganisation;
54
53
  }
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { Context as TasksContext } from \"@webiny/background-tasks/api/types.js\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { AcoFilterCrud, AcoFilterStorageOperations } from \"~/filter/filter.types.js\";\nimport type {\n AcoFolderLevelPermissionsCrud,\n AcoFolderLevelPermissionsStorageOperations\n} from \"~/flp/flp.types.js\";\nimport type { Container } from \"@webiny/di\";\nimport { FolderLevelPermissions } from \"./features/flp/FolderLevelPermissions/index.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\nexport * from \"./filter/filter.types.js\";\nexport type * from \"./folder/folder.types.js\";\nexport type * from \"./flp/flp.types.js\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: User;\n modifiedBy: User | null;\n savedBy: User;\n}\n\nexport interface AdvancedContentOrganisation {\n filter: AcoFilterCrud;\n flp: AcoFolderLevelPermissionsCrud;\n}\n\nexport interface CreateAcoParams {\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n folderLevelPermissions: FolderLevelPermissions.Interface;\n container: Container;\n}\n\nexport interface AcoStorageOperations {\n filter: AcoFilterStorageOperations;\n flp: AcoFolderLevelPermissionsStorageOperations;\n}\n\nexport interface AcoContext extends BaseContext, ApiCoreContext, CmsContext, TasksContext {\n aco: AdvancedContentOrganisation;\n}\n"],"names":["ListSortDirection"],"mappings":";AA6BO,IAAKA,0BAAiBA,WAAAA,GAAAA,SAAjBA,iBAAiB;;;WAAjBA"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Context as BaseContext } from \"@webiny/handler/types.js\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { AcoFilterCrud, AcoFilterStorageOperations } from \"~/filter/filter.types.js\";\nimport type {\n AcoFolderLevelPermissionsCrud,\n AcoFolderLevelPermissionsStorageOperations\n} from \"~/flp/flp.types.js\";\nimport type { Container } from \"@webiny/di\";\nimport { FolderLevelPermissions } from \"./features/flp/FolderLevelPermissions/index.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\nexport * from \"./filter/filter.types.js\";\nexport type * from \"./folder/folder.types.js\";\nexport type * from \"./flp/flp.types.js\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: User;\n modifiedBy: User | null;\n savedBy: User;\n}\n\nexport interface AdvancedContentOrganisation {\n filter: AcoFilterCrud;\n flp: AcoFolderLevelPermissionsCrud;\n}\n\nexport interface CreateAcoParams {\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n folderLevelPermissions: FolderLevelPermissions.Interface;\n container: Container;\n}\n\nexport interface AcoStorageOperations {\n filter: AcoFilterStorageOperations;\n flp: AcoFolderLevelPermissionsStorageOperations;\n}\n\nexport interface AcoContext extends BaseContext, ApiCoreContext, CmsContext {\n aco: AdvancedContentOrganisation;\n}\n"],"names":["ListSortDirection"],"mappings":";AA4BO,IAAKA,0BAAiBA,WAAAA,GAAAA,SAAjBA,iBAAiB;;;WAAjBA"}
@@ -1,9 +1,9 @@
1
- import type { HeadlessCms } from "@webiny/api-headless-cms/types/index.js";
2
- import type { Security } from "@webiny/api-core/types/security.js";
1
+ import type { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
2
+ import type { Container } from "@webiny/di";
3
3
  import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
4
  interface CreateOperationsWrapperParams {
5
- cms: HeadlessCms;
6
- security: Security;
5
+ container: Container;
6
+ identityContext: IdentityContext.Interface;
7
7
  modelName: string;
8
8
  }
9
9
  export declare const createOperationsWrapper: (params: CreateOperationsWrapperParams) => {
@@ -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 { HeadlessCms } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Security } from \"@webiny/api-core/types/security.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams {\n cms: HeadlessCms;\n security: Security;\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":";AAWO,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,CAACE;QAEzD,MAAMC,wBAAwB,IAAIC,6BAA6BH;QAC/D,MAAMI,qBAAqB,IAAIC,mBAAmBL;QAElDM,oCAAoCP,SAAS,eAAe,OAAO,GAAGQ;YAClE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAEAJ,oCAAoCP,SAAS,qBAAqB,OAAO,GAAGQ;YACxE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAEAJ,oCACIP,SACA,wBACA,OAAO,GAAGQ;YACN,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;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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,eAAe,OAAO,GAAGY;YAClE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAEAJ,oCAAoCX,SAAS,qBAAqB,OAAO,GAAGY;YACxE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAEAJ,oCACIX,SACA,wBACA,OAAO,GAAGY;YACN,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAGJJ,oCAAoCX,SAAS,sBAAsB,OAAO,GAAGY;YACzE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1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B,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";
1
+ import { ErrorResponse, Response } from "@webiny/api-graphql";
2
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,3 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import type { AcoContext } from "./types.js";
3
- export declare const createAcoContext: () => (ContextPlugin<AcoContext> | import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types").Context>)[];