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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/AcoFeature.d.ts +5 -0
  2. package/AcoFeature.js +134 -0
  3. package/AcoFeature.js.map +1 -0
  4. package/AcoFolderSchemaFactory.d.ts +32 -0
  5. package/AcoFolderSchemaFactory.js +82 -0
  6. package/AcoFolderSchemaFactory.js.map +1 -0
  7. package/createAcoGraphQL.d.ts +8 -4
  8. package/createAcoGraphQL.js +56 -96
  9. package/createAcoGraphQL.js.map +1 -1
  10. package/domain/folder/abstractions.d.ts +12 -5
  11. package/domain/folder/abstractions.js +2 -2
  12. package/domain/folder/abstractions.js.map +1 -1
  13. package/domain/folder/folder.model.js +2 -1
  14. package/domain/folder/folder.model.js.map +1 -1
  15. package/exports/api/aco/flp.d.ts +1 -0
  16. package/exports/api/aco/flp.js +1 -0
  17. package/exports/api/aco/folder.d.ts +2 -1
  18. package/exports/api/aco/folder.js +1 -1
  19. package/features/ai/CreateFolderTool.d.ts +49 -0
  20. package/features/ai/CreateFolderTool.js +58 -0
  21. package/features/ai/CreateFolderTool.js.map +1 -0
  22. package/features/ai/CreateTeamTool.d.ts +48 -0
  23. package/features/ai/CreateTeamTool.js +56 -0
  24. package/features/ai/CreateTeamTool.js.map +1 -0
  25. package/features/ai/DeleteFolderTool.d.ts +48 -0
  26. package/features/ai/DeleteFolderTool.js +55 -0
  27. package/features/ai/DeleteFolderTool.js.map +1 -0
  28. package/features/ai/GrantFolderAccessTool.d.ts +77 -0
  29. package/features/ai/GrantFolderAccessTool.js +80 -0
  30. package/features/ai/GrantFolderAccessTool.js.map +1 -0
  31. package/features/ai/ListFoldersTool.d.ts +47 -0
  32. package/features/ai/ListFoldersTool.js +57 -0
  33. package/features/ai/ListFoldersTool.js.map +1 -0
  34. package/features/ai/ListRolesTool.d.ts +39 -0
  35. package/features/ai/ListRolesTool.js +48 -0
  36. package/features/ai/ListRolesTool.js.map +1 -0
  37. package/features/ai/ListTeamsTool.d.ts +39 -0
  38. package/features/ai/ListTeamsTool.js +48 -0
  39. package/features/ai/ListTeamsTool.js.map +1 -0
  40. package/features/ai/RevokeFolderAccessTool.d.ts +63 -0
  41. package/features/ai/RevokeFolderAccessTool.js +69 -0
  42. package/features/ai/RevokeFolderAccessTool.js.map +1 -0
  43. package/features/ai/assertTargetIsUsable.d.ts +10 -0
  44. package/features/ai/assertTargetIsUsable.js +14 -0
  45. package/features/ai/assertTargetIsUsable.js.map +1 -0
  46. package/features/ai/feature.d.ts +12 -0
  47. package/features/ai/feature.js +25 -0
  48. package/features/ai/feature.js.map +1 -0
  49. package/features/ai/index.d.ts +9 -0
  50. package/features/ai/index.js +9 -0
  51. package/features/ai/loadFolderPermissions.d.ts +16 -0
  52. package/features/ai/loadFolderPermissions.js +14 -0
  53. package/features/ai/loadFolderPermissions.js.map +1 -0
  54. package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js +1 -0
  55. package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js.map +1 -1
  56. package/features/cms/decorators/ListEntriesWithFlpDecorator.js +1 -0
  57. package/features/cms/decorators/ListEntriesWithFlpDecorator.js.map +1 -1
  58. package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js +1 -0
  59. package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js.map +1 -1
  60. package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js +1 -0
  61. package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js.map +1 -1
  62. package/features/cms/decorators/MoveEntryWithFlpDecorator.d.ts +1 -1
  63. package/features/flp/CreateFlp/CreateFlpUseCase.d.ts +3 -3
  64. package/features/flp/CreateFlp/CreateFlpUseCase.js +4 -4
  65. package/features/flp/CreateFlp/CreateFlpUseCase.js.map +1 -1
  66. package/features/flp/CreateFlp/feature.d.ts +1 -6
  67. package/features/flp/CreateFlp/feature.js +3 -2
  68. package/features/flp/CreateFlp/feature.js.map +1 -1
  69. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.d.ts +8 -5
  70. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js +21 -14
  71. package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js.map +1 -1
  72. package/features/flp/DeleteFlp/DeleteFlpUseCase.d.ts +3 -3
  73. package/features/flp/DeleteFlp/DeleteFlpUseCase.js +3 -3
  74. package/features/flp/DeleteFlp/DeleteFlpUseCase.js.map +1 -1
  75. package/features/flp/DeleteFlp/feature.d.ts +1 -6
  76. package/features/flp/DeleteFlp/feature.js +3 -2
  77. package/features/flp/DeleteFlp/feature.js.map +1 -1
  78. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.d.ts +6 -5
  79. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js +16 -13
  80. package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js.map +1 -1
  81. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.d.ts +3 -3
  82. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +6 -6
  83. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
  84. package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.d.ts +25 -0
  85. package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js +48 -0
  86. package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js.map +1 -0
  87. package/features/flp/FolderLevelPermissions/index.d.ts +1 -0
  88. package/features/flp/FolderLevelPermissions/index.js +1 -0
  89. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.d.ts +13 -0
  90. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js +26 -0
  91. package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js.map +1 -0
  92. package/features/flp/GetFlp/feature.d.ts +1 -1
  93. package/features/flp/GetFlp/feature.js +3 -2
  94. package/features/flp/GetFlp/feature.js.map +1 -1
  95. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.d.ts +13 -0
  96. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js +27 -0
  97. package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js.map +1 -0
  98. package/features/flp/ListFlps/feature.d.ts +1 -1
  99. package/features/flp/ListFlps/feature.js +3 -2
  100. package/features/flp/ListFlps/feature.js.map +1 -1
  101. package/features/flp/UpdateFlp/UpdateFlpUseCase.d.ts +15 -8
  102. package/features/flp/UpdateFlp/UpdateFlpUseCase.js +37 -42
  103. package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
  104. package/features/flp/UpdateFlp/abstractions.d.ts +6 -2
  105. package/features/flp/UpdateFlp/abstractions.js.map +1 -1
  106. package/features/flp/UpdateFlp/feature.d.ts +1 -6
  107. package/features/flp/UpdateFlp/feature.js +7 -2
  108. package/features/flp/UpdateFlp/feature.js.map +1 -1
  109. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.d.ts +8 -5
  110. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js +21 -16
  111. package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js.map +1 -1
  112. package/features/flp/shared/CodeFlpMerger.d.ts +26 -0
  113. package/features/flp/shared/CodeFlpMerger.js +20 -0
  114. package/features/flp/shared/CodeFlpMerger.js.map +1 -0
  115. package/features/flp/shared/CodeFlpPath.d.ts +15 -0
  116. package/features/flp/shared/CodeFlpPath.js +29 -0
  117. package/features/flp/shared/CodeFlpPath.js.map +1 -0
  118. package/features/flp/shared/CodeFlpTarget.d.ts +10 -0
  119. package/features/flp/shared/CodeFlpTarget.js +26 -0
  120. package/features/flp/shared/CodeFlpTarget.js.map +1 -0
  121. package/features/flp/shared/CodeFlpsProvider.d.ts +14 -0
  122. package/features/flp/shared/CodeFlpsProvider.js +33 -0
  123. package/features/flp/shared/CodeFlpsProvider.js.map +1 -0
  124. package/features/flp/shared/abstractions.d.ts +77 -0
  125. package/features/flp/shared/abstractions.js +19 -0
  126. package/features/flp/shared/abstractions.js.map +1 -0
  127. package/features/flp/shared/feature.d.ts +5 -0
  128. package/features/flp/shared/feature.js +17 -0
  129. package/features/flp/shared/feature.js.map +1 -0
  130. package/features/flp/shared/index.d.ts +4 -0
  131. package/features/flp/shared/index.js +4 -0
  132. package/features/folder/CreateFolder/CreateFolderRepository.d.ts +3 -3
  133. package/features/folder/CreateFolder/CreateFolderRepository.js +10 -7
  134. package/features/folder/CreateFolder/CreateFolderRepository.js.map +1 -1
  135. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.d.ts +9 -1
  136. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js +20 -3
  137. package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js.map +1 -1
  138. package/features/folder/DeleteFolder/DeleteFolderRepository.d.ts +3 -3
  139. package/features/folder/DeleteFolder/DeleteFolderRepository.js +6 -5
  140. package/features/folder/DeleteFolder/DeleteFolderRepository.js.map +1 -1
  141. package/features/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.d.ts +1 -1
  142. package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +4 -0
  143. package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
  144. package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js +4 -0
  145. package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js.map +1 -1
  146. package/features/folder/FolderModelProvider.d.ts +26 -0
  147. package/features/folder/FolderModelProvider.js +22 -0
  148. package/features/folder/FolderModelProvider.js.map +1 -0
  149. package/features/folder/GetAncestors/GetAncestorsRepository.d.ts +3 -3
  150. package/features/folder/GetAncestors/GetAncestorsRepository.js +6 -5
  151. package/features/folder/GetAncestors/GetAncestorsRepository.js.map +1 -1
  152. package/features/folder/GetFolder/GetFolderRepository.d.ts +3 -3
  153. package/features/folder/GetFolder/GetFolderRepository.js +6 -5
  154. package/features/folder/GetFolder/GetFolderRepository.js.map +1 -1
  155. package/features/folder/GetFolder/decorators/GetFolderWithFolderLevelPermissions.d.ts +8 -8
  156. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.d.ts +3 -3
  157. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js +10 -8
  158. package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js.map +1 -1
  159. package/features/folder/ListFolders/ListFoldersRepository.d.ts +3 -3
  160. package/features/folder/ListFolders/ListFoldersRepository.js +8 -7
  161. package/features/folder/ListFolders/ListFoldersRepository.js.map +1 -1
  162. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +11 -0
  163. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js +38 -0
  164. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +1 -0
  165. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.d.ts +12 -0
  166. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js +24 -0
  167. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js.map +1 -0
  168. package/features/folder/NotifyFolderChange/abstractions.d.ts +28 -0
  169. package/features/folder/NotifyFolderChange/abstractions.js +8 -0
  170. package/features/folder/NotifyFolderChange/abstractions.js.map +1 -0
  171. package/features/folder/NotifyFolderChange/feature.d.ts +9 -0
  172. package/features/folder/NotifyFolderChange/feature.js +13 -0
  173. package/features/folder/NotifyFolderChange/feature.js.map +1 -0
  174. package/features/folder/NotifyFolderChange/index.d.ts +2 -0
  175. package/features/folder/NotifyFolderChange/index.js +2 -0
  176. package/features/folder/UpdateFolder/UpdateFolderRepository.d.ts +3 -3
  177. package/features/folder/UpdateFolder/UpdateFolderRepository.js +11 -8
  178. package/features/folder/UpdateFolder/UpdateFolderRepository.js.map +1 -1
  179. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.d.ts +14 -1
  180. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js +52 -4
  181. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
  182. package/features/folder/shared/abstractions.d.ts +14 -0
  183. package/features/folder/shared/abstractions.js +4 -1
  184. package/features/folder/shared/abstractions.js.map +1 -1
  185. package/filter/filter.gql.d.ts +2 -3
  186. package/filter/filter.gql.js +61 -27
  187. package/filter/filter.gql.js.map +1 -1
  188. package/filter/filter.model.js +2 -1
  189. package/filter/filter.model.js.map +1 -1
  190. package/filter/filter.so.d.ts +8 -2
  191. package/filter/filter.so.js +21 -9
  192. package/filter/filter.so.js.map +1 -1
  193. package/flp/flp.types.d.ts +6 -1
  194. package/flp/index.d.ts +0 -1
  195. package/flp/index.js +0 -1
  196. package/flp/tasks/createFlp.task.d.ts +12 -5
  197. package/flp/tasks/createFlp.task.js +32 -15
  198. package/flp/tasks/createFlp.task.js.map +1 -1
  199. package/flp/tasks/deleteFlp.task.d.ts +10 -5
  200. package/flp/tasks/deleteFlp.task.js +22 -13
  201. package/flp/tasks/deleteFlp.task.js.map +1 -1
  202. package/flp/tasks/index.d.ts +0 -1
  203. package/flp/tasks/index.js +1 -14
  204. package/flp/tasks/index.js.map +1 -1
  205. package/flp/tasks/syncFlp.task.d.ts +10 -5
  206. package/flp/tasks/syncFlp.task.js +34 -13
  207. package/flp/tasks/syncFlp.task.js.map +1 -1
  208. package/flp/tasks/updateFlp.task.d.ts +12 -5
  209. package/flp/tasks/updateFlp.task.js +40 -19
  210. package/flp/tasks/updateFlp.task.js.map +1 -1
  211. package/folder/createFolderTypeDefs.js +4 -1
  212. package/folder/createFolderTypeDefs.js.map +1 -1
  213. package/folder/folder.gql.d.ts +1 -1
  214. package/folder/folder.gql.js +10 -4
  215. package/folder/folder.gql.js.map +1 -1
  216. package/index.d.ts +1 -6
  217. package/index.js +1 -11
  218. package/package.json +25 -26
  219. package/types.d.ts +1 -2
  220. package/types.js.map +1 -1
  221. package/utils/createOperationsWrapper.d.ts +5 -2
  222. package/utils/createOperationsWrapper.js +5 -5
  223. package/utils/createOperationsWrapper.js.map +1 -1
  224. package/utils/decorators/CmsEntriesCrudDecorators.js +9 -5
  225. package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
  226. package/utils/resolve.d.ts +2 -2
  227. package/utils/resolve.js +1 -1
  228. package/utils/resolve.js.map +1 -1
  229. package/createAcoContext.d.ts +0 -9
  230. package/createAcoContext.js +0 -109
  231. package/createAcoContext.js.map +0 -1
  232. package/createAcoStorageOperations.d.ts +0 -12
  233. package/createAcoStorageOperations.js +0 -9
  234. package/createAcoStorageOperations.js.map +0 -1
  235. package/createAcoTasks.d.ts +0 -1
  236. package/createAcoTasks.js +0 -14
  237. package/createAcoTasks.js.map +0 -1
  238. package/flp/flp.so.d.ts +0 -20
  239. package/flp/flp.so.js +0 -183
  240. package/flp/flp.so.js.map +0 -1
  241. package/index.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
+ import { ListRolesUseCase } from "@webiny/api-core/features/security/roles/ListRoles/index.js";
4
+ interface RoleSummary {
5
+ id: string;
6
+ name: string;
7
+ slug: string;
8
+ description?: string;
9
+ }
10
+ declare class ListRolesToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {
11
+ private listRoles;
12
+ constructor(listRoles: ListRolesUseCase.Interface);
13
+ execute(): Promise<RoleSummary[]>;
14
+ }
15
+ /**
16
+ * Resolves role names to the IDs `createTeam` takes. Separate from the write, so the user approves a
17
+ * team with roles that were looked up rather than guessed.
18
+ *
19
+ * Returns the slug too, because it is what a human recognises and what the admin UI shows, while
20
+ * `id` is what a team actually stores. Nothing at the type level separates the two, so `createTeam`
21
+ * accepts either and resolves it rather than making the caller guess which one that field wants.
22
+ */
23
+ declare class ListRolesToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {
24
+ readonly name = "listRoles";
25
+ readonly title = "List roles";
26
+ readonly description = "Lists the security roles in this project. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.";
27
+ readonly inputSchema: z.ZodObject<{}, z.core.$strip>;
28
+ readonly annotations: {
29
+ readOnlyHint: boolean;
30
+ idempotentHint: boolean;
31
+ };
32
+ readonly handler: typeof ListRolesToolHandlerImpl & {
33
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
34
+ };
35
+ }
36
+ export declare const ListRolesTool: typeof ListRolesToolImpl & {
37
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
38
+ };
39
+ export {};
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
+ import { ListRolesUseCase } from "@webiny/api-core/features/security/roles/ListRoles/index.js";
4
+ const inputSchema = z.object({});
5
+ class ListRolesToolHandlerImpl {
6
+ constructor(listRoles){
7
+ this.listRoles = listRoles;
8
+ }
9
+ async execute() {
10
+ const result = await this.listRoles.execute();
11
+ if (result.isFail()) throw new Error(`Could not list roles: ${result.error.message}`);
12
+ return result.value.map((role)=>{
13
+ const summary = {
14
+ id: role.id,
15
+ name: role.name,
16
+ slug: role.slug
17
+ };
18
+ if (role.description) summary.description = role.description;
19
+ return summary;
20
+ });
21
+ }
22
+ }
23
+ const ListRolesToolHandler = AiSdkToolHandler.createImplementation({
24
+ implementation: ListRolesToolHandlerImpl,
25
+ dependencies: [
26
+ ListRolesUseCase
27
+ ]
28
+ });
29
+ class ListRolesToolImpl {
30
+ constructor(){
31
+ this.name = "listRoles";
32
+ this.title = "List roles";
33
+ this.description = "Lists the security roles in this project. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.";
34
+ this.inputSchema = inputSchema;
35
+ this.annotations = {
36
+ readOnlyHint: true,
37
+ idempotentHint: true
38
+ };
39
+ this.handler = ListRolesToolHandler;
40
+ }
41
+ }
42
+ const ListRolesTool = AiSdkToolDefinition.createImplementation({
43
+ implementation: ListRolesToolImpl,
44
+ dependencies: []
45
+ });
46
+ export { ListRolesTool };
47
+
48
+ //# sourceMappingURL=ListRolesTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/ListRolesTool.js","sources":["../../../src/features/ai/ListRolesTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListRolesUseCase } from \"@webiny/api-core/features/security/roles/ListRoles/index.js\";\n\nconst inputSchema = z.object({});\n\ninterface RoleSummary {\n id: string;\n name: string;\n slug: string;\n description?: string;\n}\n\nclass ListRolesToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {\n constructor(private listRoles: ListRolesUseCase.Interface) {}\n\n async execute(): Promise<RoleSummary[]> {\n const result = await this.listRoles.execute();\n\n if (result.isFail()) {\n throw new Error(`Could not list roles: ${result.error.message}`);\n }\n\n return result.value.map(role => {\n const summary: RoleSummary = {\n id: role.id,\n name: role.name,\n slug: role.slug\n };\n\n if (role.description) {\n summary.description = role.description;\n }\n\n return summary;\n });\n }\n}\n\nconst ListRolesToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListRolesToolHandlerImpl,\n dependencies: [ListRolesUseCase]\n});\n\n/**\n * Resolves role names to the IDs `createTeam` takes. Separate from the write, so the user approves a\n * team with roles that were looked up rather than guessed.\n *\n * Returns the slug too, because it is what a human recognises and what the admin UI shows, while\n * `id` is what a team actually stores. Nothing at the type level separates the two, so `createTeam`\n * accepts either and resolves it rather than making the caller guess which one that field wants.\n */\nclass ListRolesToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {\n readonly name = \"listRoles\";\n readonly title = \"List roles\";\n readonly description =\n \"Lists the security roles in this project. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListRolesToolHandler;\n}\n\nexport const ListRolesTool = AiSdkToolDefinition.createImplementation({\n implementation: ListRolesToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListRolesToolHandlerImpl","listRoles","result","Error","role","summary","ListRolesToolHandler","AiSdkToolHandler","ListRolesUseCase","ListRolesToolImpl","ListRolesTool","AiSdkToolDefinition"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC,CAAC;AAS9B,MAAMC;IACF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;IAAwC;IAE5D,MAAM,UAAkC;QACpC,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAE3C,IAAIA,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGnE,OAAOA,OAAO,KAAK,CAAC,GAAG,CAACE,CAAAA;YACpB,MAAMC,UAAuB;gBACzB,IAAID,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;YAEA,IAAIA,KAAK,WAAW,EAChBC,QAAQ,WAAW,GAAGD,KAAK,WAAW;YAG1C,OAAOC;QACX;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,iBAAiB,oBAAoB,CAAC;IAC/D,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC;AAUA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGX;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGQ;;AACvB;AAEO,MAAMI,gBAAgBC,oBAAoB,oBAAoB,CAAC;IAClE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
+ import { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
4
+ declare const inputSchema: z.ZodObject<{}, z.core.$strip>;
5
+ type Input = z.infer<typeof inputSchema>;
6
+ interface TeamSummary {
7
+ id: string;
8
+ name: string;
9
+ slug: string;
10
+ description?: string;
11
+ }
12
+ declare class ListTeamsToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
13
+ private listTeams;
14
+ constructor(listTeams: ListTeamsUseCase.Interface);
15
+ execute(): Promise<TeamSummary[]>;
16
+ }
17
+ /**
18
+ * Resolves human names ("team A") to the ids folder permissions actually take.
19
+ *
20
+ * Kept separate from setFolderPermissions rather than accepting a team name there: the user approves
21
+ * the arguments of a write, so the id has to be looked up and shown, not guessed inside the write.
22
+ */
23
+ declare class ListTeamsToolImpl implements AiSdkToolDefinition.Interface<Input> {
24
+ readonly name = "listTeams";
25
+ readonly title = "List teams";
26
+ readonly description = "Lists the teams in this project with their ids, names and slugs. Folder permission targets use the SLUG (`team:<slug>`), not the id.";
27
+ readonly inputSchema: z.ZodObject<{}, z.core.$strip>;
28
+ readonly annotations: {
29
+ readOnlyHint: boolean;
30
+ idempotentHint: boolean;
31
+ };
32
+ readonly handler: typeof ListTeamsToolHandlerImpl & {
33
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
34
+ };
35
+ }
36
+ export declare const ListTeamsTool: typeof ListTeamsToolImpl & {
37
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
38
+ };
39
+ export {};
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
+ import { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
4
+ const inputSchema = z.object({});
5
+ class ListTeamsToolHandlerImpl {
6
+ constructor(listTeams){
7
+ this.listTeams = listTeams;
8
+ }
9
+ async execute() {
10
+ const result = await this.listTeams.execute();
11
+ if (result.isFail()) throw new Error(`Could not list teams: ${result.error.message}`);
12
+ return result.value.map((team)=>{
13
+ const summary = {
14
+ id: team.id,
15
+ name: team.name,
16
+ slug: team.slug
17
+ };
18
+ if (team.description) summary.description = team.description;
19
+ return summary;
20
+ });
21
+ }
22
+ }
23
+ const ListTeamsToolHandler = AiSdkToolHandler.createImplementation({
24
+ implementation: ListTeamsToolHandlerImpl,
25
+ dependencies: [
26
+ ListTeamsUseCase
27
+ ]
28
+ });
29
+ class ListTeamsToolImpl {
30
+ constructor(){
31
+ this.name = "listTeams";
32
+ this.title = "List teams";
33
+ this.description = "Lists the teams in this project with their ids, names and slugs. Folder permission targets use the SLUG (`team:<slug>`), not the id.";
34
+ this.inputSchema = inputSchema;
35
+ this.annotations = {
36
+ readOnlyHint: true,
37
+ idempotentHint: true
38
+ };
39
+ this.handler = ListTeamsToolHandler;
40
+ }
41
+ }
42
+ const ListTeamsTool = AiSdkToolDefinition.createImplementation({
43
+ implementation: ListTeamsToolImpl,
44
+ dependencies: []
45
+ });
46
+ export { ListTeamsTool };
47
+
48
+ //# sourceMappingURL=ListTeamsTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/ListTeamsTool.js","sources":["../../../src/features/ai/ListTeamsTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListTeamsUseCase } from \"@webiny/api-core/features/security/teams/ListTeams/index.js\";\n\nconst inputSchema = z.object({});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface TeamSummary {\n id: string;\n name: string;\n slug: string;\n description?: string;\n}\n\nclass ListTeamsToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private listTeams: ListTeamsUseCase.Interface) {}\n\n async execute(): Promise<TeamSummary[]> {\n const result = await this.listTeams.execute();\n\n if (result.isFail()) {\n throw new Error(`Could not list teams: ${result.error.message}`);\n }\n\n return result.value.map(team => {\n const summary: TeamSummary = {\n id: team.id,\n name: team.name,\n slug: team.slug\n };\n\n if (team.description) {\n summary.description = team.description;\n }\n\n return summary;\n });\n }\n}\n\nconst ListTeamsToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListTeamsToolHandlerImpl,\n dependencies: [ListTeamsUseCase]\n});\n\n/**\n * Resolves human names (\"team A\") to the ids folder permissions actually take.\n *\n * Kept separate from setFolderPermissions rather than accepting a team name there: the user approves\n * the arguments of a write, so the id has to be looked up and shown, not guessed inside the write.\n */\nclass ListTeamsToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"listTeams\";\n readonly title = \"List teams\";\n readonly description =\n \"Lists the teams in this project with their ids, names and slugs. Folder permission targets use the SLUG (`team:<slug>`), not the id.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListTeamsToolHandler;\n}\n\nexport const ListTeamsTool = AiSdkToolDefinition.createImplementation({\n implementation: ListTeamsToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListTeamsToolHandlerImpl","listTeams","result","Error","team","summary","ListTeamsToolHandler","AiSdkToolHandler","ListTeamsUseCase","ListTeamsToolImpl","ListTeamsTool","AiSdkToolDefinition"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC,CAAC;AAW9B,MAAMC;IACF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;IAAwC;IAE5D,MAAM,UAAkC;QACpC,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAE3C,IAAIA,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGnE,OAAOA,OAAO,KAAK,CAAC,GAAG,CAACE,CAAAA;YACpB,MAAMC,UAAuB;gBACzB,IAAID,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;YAEA,IAAIA,KAAK,WAAW,EAChBC,QAAQ,WAAW,GAAGD,KAAK,WAAW;YAG1C,OAAOC;QACX;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,iBAAiB,oBAAoB,CAAC;IAC/D,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC;AAQA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGX;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGQ;;AACvB;AAEO,MAAMI,gBAAgBC,oBAAoB,oBAAoB,CAAC;IAClE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,63 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
+ import { GetFolderUseCase } from "../../features/folder/GetFolder/index.js";
4
+ import { UpdateFolderUseCase } from "../../features/folder/UpdateFolder/index.js";
5
+ declare const inputSchema: z.ZodObject<{
6
+ folderId: z.ZodString;
7
+ target: z.ZodString;
8
+ }, z.core.$strip>;
9
+ type Input = z.infer<typeof inputSchema>;
10
+ interface RevokeResult {
11
+ folderId: string;
12
+ title: string;
13
+ path: string;
14
+ removed: {
15
+ target: string;
16
+ level: string;
17
+ };
18
+ /**
19
+ * Every direct rule remaining afterwards.
20
+ *
21
+ * This is the set the update was asked to store, not an independent read of it:
22
+ * `UpdateFolderWithFolderLevelPermissions` returns the permissions it derived from the input
23
+ * rather than the ones the repository wrote. Treating it as a verification would let the tool
24
+ * confirm its own request back to itself.
25
+ */
26
+ permissions: {
27
+ target: string;
28
+ level: string;
29
+ }[];
30
+ }
31
+ declare class RevokeFolderAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
32
+ private getFolder;
33
+ private updateFolder;
34
+ constructor(getFolder: GetFolderUseCase.Interface, updateFolder: UpdateFolderUseCase.Interface);
35
+ execute(input: Input): Promise<RevokeResult>;
36
+ }
37
+ /**
38
+ * Removes one target's direct access to one folder.
39
+ *
40
+ * Destructive: somebody loses access, and there is no undo. Refuses when the target has no DIRECT rule
41
+ * rather than reporting a removal that changed nothing — an inherited grant cannot be revoked here,
42
+ * only where it is defined, and saying otherwise would leave the user believing access was withdrawn.
43
+ */
44
+ declare class RevokeFolderAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {
45
+ readonly name = "revokeFolderAccess";
46
+ readonly title = "Revoke folder access";
47
+ readonly description = "Removes one team's or user's direct access to one folder, leaving all other permissions untouched. Cannot remove inherited access. Requires user approval.";
48
+ readonly inputSchema: z.ZodObject<{
49
+ folderId: z.ZodString;
50
+ target: z.ZodString;
51
+ }, z.core.$strip>;
52
+ readonly annotations: {
53
+ readOnlyHint: boolean;
54
+ destructiveHint: boolean;
55
+ };
56
+ readonly handler: typeof RevokeFolderAccessToolHandlerImpl & {
57
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions.js").IAiSdkToolHandler<any>>;
58
+ };
59
+ }
60
+ export declare const RevokeFolderAccessTool: typeof RevokeFolderAccessToolImpl & {
61
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions.js").IAiSdkToolDefinition<any>>;
62
+ };
63
+ export {};
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
+ import { GetFolderUseCase } from "../folder/GetFolder/index.js";
4
+ import { UpdateFolderUseCase } from "../folder/UpdateFolder/index.js";
5
+ import { loadFolderPermissions } from "./loadFolderPermissions.js";
6
+ const inputSchema = z.object({
7
+ folderId: z.string().describe("Folder id as returned by listFolders."),
8
+ target: z.string().describe("Whose access to remove: 'team:<slug>' or 'admin:<userId>', exactly as listFolders reports it.")
9
+ });
10
+ class RevokeFolderAccessToolHandlerImpl {
11
+ constructor(getFolder, updateFolder){
12
+ this.getFolder = getFolder;
13
+ this.updateFolder = updateFolder;
14
+ }
15
+ async execute(input) {
16
+ const loaded = await loadFolderPermissions(this.getFolder, input.folderId);
17
+ const existing = loaded.direct.find((permission)=>String(permission.target) === input.target);
18
+ if (!existing) {
19
+ if (loaded.inheritedTargets.has(input.target)) throw new Error(`"${input.target}" has inherited access to this folder, not a direct rule, so it cannot be revoked here. Change it where it is defined.`);
20
+ throw new Error(`"${input.target}" has no direct access to this folder, so there is nothing to revoke.`);
21
+ }
22
+ const permissions = loaded.direct.filter((permission)=>String(permission.target) !== input.target);
23
+ const result = await this.updateFolder.execute(input.folderId, {
24
+ permissions
25
+ });
26
+ if (result.isFail()) throw new Error(`Could not revoke access: ${result.error.message}`);
27
+ const folder = result.value;
28
+ return {
29
+ folderId: folder.id,
30
+ title: folder.title,
31
+ path: folder.path,
32
+ removed: {
33
+ target: input.target,
34
+ level: existing.level
35
+ },
36
+ permissions: (folder.permissions ?? []).filter((permission)=>!permission.inheritedFrom).map((permission)=>({
37
+ target: String(permission.target),
38
+ level: permission.level
39
+ }))
40
+ };
41
+ }
42
+ }
43
+ const RevokeFolderAccessToolHandler = AiSdkToolHandler.createImplementation({
44
+ implementation: RevokeFolderAccessToolHandlerImpl,
45
+ dependencies: [
46
+ GetFolderUseCase,
47
+ UpdateFolderUseCase
48
+ ]
49
+ });
50
+ class RevokeFolderAccessToolImpl {
51
+ constructor(){
52
+ this.name = "revokeFolderAccess";
53
+ this.title = "Revoke folder access";
54
+ this.description = "Removes one team's or user's direct access to one folder, leaving all other permissions untouched. Cannot remove inherited access. Requires user approval.";
55
+ this.inputSchema = inputSchema;
56
+ this.annotations = {
57
+ readOnlyHint: false,
58
+ destructiveHint: true
59
+ };
60
+ this.handler = RevokeFolderAccessToolHandler;
61
+ }
62
+ }
63
+ const RevokeFolderAccessTool = AiSdkToolDefinition.createImplementation({
64
+ implementation: RevokeFolderAccessToolImpl,
65
+ dependencies: []
66
+ });
67
+ export { RevokeFolderAccessTool };
68
+
69
+ //# sourceMappingURL=RevokeFolderAccessTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/RevokeFolderAccessTool.js","sources":["../../../src/features/ai/RevokeFolderAccessTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/index.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/index.js\";\nimport { loadFolderPermissions } from \"./loadFolderPermissions.js\";\n\nconst inputSchema = z.object({\n folderId: z.string().describe(\"Folder id as returned by listFolders.\"),\n target: z\n .string()\n .describe(\n \"Whose access to remove: 'team:<slug>' or 'admin:<userId>', exactly as listFolders reports it.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface RevokeResult {\n folderId: string;\n title: string;\n path: string;\n removed: { target: string; level: string };\n /**\n * Every direct rule remaining afterwards.\n *\n * This is the set the update was asked to store, not an independent read of it:\n * `UpdateFolderWithFolderLevelPermissions` returns the permissions it derived from the input\n * rather than the ones the repository wrote. Treating it as a verification would let the tool\n * confirm its own request back to itself.\n */\n permissions: { target: string; level: string }[];\n}\n\nclass RevokeFolderAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(\n private getFolder: GetFolderUseCase.Interface,\n private updateFolder: UpdateFolderUseCase.Interface\n ) {}\n\n async execute(input: Input): Promise<RevokeResult> {\n const loaded = await loadFolderPermissions(this.getFolder, input.folderId);\n\n const existing = loaded.direct.find(\n permission => String(permission.target) === input.target\n );\n\n if (!existing) {\n if (loaded.inheritedTargets.has(input.target)) {\n throw new Error(\n `\"${input.target}\" has inherited access to this folder, not a direct rule, so it cannot be revoked here. Change it where it is defined.`\n );\n }\n\n throw new Error(\n `\"${input.target}\" has no direct access to this folder, so there is nothing to revoke.`\n );\n }\n\n const permissions = loaded.direct.filter(\n permission => String(permission.target) !== input.target\n );\n\n const result = await this.updateFolder.execute(input.folderId, { permissions });\n\n if (result.isFail()) {\n throw new Error(`Could not revoke access: ${result.error.message}`);\n }\n\n const folder = result.value;\n\n return {\n folderId: folder.id,\n title: folder.title,\n path: folder.path,\n removed: { target: input.target, level: existing.level },\n permissions: (folder.permissions ?? [])\n .filter(permission => !permission.inheritedFrom)\n .map(permission => ({ target: String(permission.target), level: permission.level }))\n };\n }\n}\n\nconst RevokeFolderAccessToolHandler = AiSdkToolHandler.createImplementation({\n implementation: RevokeFolderAccessToolHandlerImpl,\n dependencies: [GetFolderUseCase, UpdateFolderUseCase]\n});\n\n/**\n * Removes one target's direct access to one folder.\n *\n * Destructive: somebody loses access, and there is no undo. Refuses when the target has no DIRECT rule\n * rather than reporting a removal that changed nothing — an inherited grant cannot be revoked here,\n * only where it is defined, and saying otherwise would leave the user believing access was withdrawn.\n */\nclass RevokeFolderAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"revokeFolderAccess\";\n readonly title = \"Revoke folder access\";\n readonly description =\n \"Removes one team's or user's direct access to one folder, leaving all other permissions untouched. Cannot remove inherited access. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false, destructiveHint: true };\n readonly handler = RevokeFolderAccessToolHandler;\n}\n\nexport const RevokeFolderAccessTool = AiSdkToolDefinition.createImplementation({\n implementation: RevokeFolderAccessToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","RevokeFolderAccessToolHandlerImpl","getFolder","updateFolder","input","loaded","loadFolderPermissions","existing","permission","String","Error","permissions","result","folder","RevokeFolderAccessToolHandler","AiSdkToolHandler","GetFolderUseCase","UpdateFolderUseCase","RevokeFolderAccessToolImpl","RevokeFolderAccessTool","AiSdkToolDefinition"],"mappings":";;;;;AAMA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,UAAUA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B,QAAQA,EAAAA,MACG,GACN,QAAQ,CACL;AAEZ;AAoBA,MAAMC;IACF,YACYC,SAAqC,EACrCC,YAA2C,CACrD;aAFUD,SAAS,GAATA;aACAC,YAAY,GAAZA;IACT;IAEH,MAAM,QAAQC,KAAY,EAAyB;QAC/C,MAAMC,SAAS,MAAMC,sBAAsB,IAAI,CAAC,SAAS,EAAEF,MAAM,QAAQ;QAEzE,MAAMG,WAAWF,OAAO,MAAM,CAAC,IAAI,CAC/BG,CAAAA,aAAcC,OAAOD,WAAW,MAAM,MAAMJ,MAAM,MAAM;QAG5D,IAAI,CAACG,UAAU;YACX,IAAIF,OAAO,gBAAgB,CAAC,GAAG,CAACD,MAAM,MAAM,GACxC,MAAM,IAAIM,MACN,CAAC,CAAC,EAAEN,MAAM,MAAM,CAAC,sHAAsH,CAAC;YAIhJ,MAAM,IAAIM,MACN,CAAC,CAAC,EAAEN,MAAM,MAAM,CAAC,qEAAqE,CAAC;QAE/F;QAEA,MAAMO,cAAcN,OAAO,MAAM,CAAC,MAAM,CACpCG,CAAAA,aAAcC,OAAOD,WAAW,MAAM,MAAMJ,MAAM,MAAM;QAG5D,MAAMQ,SAAS,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAACR,MAAM,QAAQ,EAAE;YAAEO;QAAY;QAE7E,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIF,MAAM,CAAC,yBAAyB,EAAEE,OAAO,KAAK,CAAC,OAAO,EAAE;QAGtE,MAAMC,SAASD,OAAO,KAAK;QAE3B,OAAO;YACH,UAAUC,OAAO,EAAE;YACnB,OAAOA,OAAO,KAAK;YACnB,MAAMA,OAAO,IAAI;YACjB,SAAS;gBAAE,QAAQT,MAAM,MAAM;gBAAE,OAAOG,SAAS,KAAK;YAAC;YACvD,aAAcM,AAAAA,CAAAA,OAAO,WAAW,IAAI,EAAC,EAChC,MAAM,CAACL,CAAAA,aAAc,CAACA,WAAW,aAAa,EAC9C,GAAG,CAACA,CAAAA,aAAe;oBAAE,QAAQC,OAAOD,WAAW,MAAM;oBAAG,OAAOA,WAAW,KAAK;gBAAC;QACzF;IACJ;AACJ;AAEA,MAAMM,gCAAgCC,iBAAiB,oBAAoB,CAAC;IACxE,gBAAgBd;IAChB,cAAc;QAACe;QAAkBC;KAAoB;AACzD;AASA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGnB;aACd,WAAW,GAAG;YAAE,cAAc;YAAO,iBAAiB;QAAK;aAC3D,OAAO,GAAGe;;AACvB;AAEO,MAAMK,yBAAyBC,oBAAoB,oBAAoB,CAAC;IAC3E,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,10 @@
1
+ import type { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
2
+ /**
3
+ * Rejects a permission target that would be stored happily and then match nobody.
4
+ *
5
+ * A folder rule identifies a team by SLUG (`team:<slug>`) and a user by id (`admin:<userId>`) — see
6
+ * ListFolderLevelPermissionsTargets. The field is only typed as a template string, so a team id where
7
+ * a slug belongs is accepted and silently grants nothing. Also refuses a target the folder inherits,
8
+ * since rewriting it as a direct rule detaches the folder from where the grant came from.
9
+ */
10
+ export declare const assertTargetIsUsable: (listTeams: ListTeamsUseCase.Interface, target: string, inheritedTargets: Set<string>) => Promise<void>;
@@ -0,0 +1,14 @@
1
+ const assertTargetIsUsable = async (listTeams, target, inheritedTargets)=>{
2
+ if (inheritedTargets.has(target)) throw new Error(`"${target}" is inherited from an ancestor folder or a role, so it cannot be changed on this folder. Change it where it is defined.`);
3
+ if (!target.startsWith("team:")) return;
4
+ const result = await listTeams.execute();
5
+ if (result.isFail()) throw new Error(`Could not verify the teams: ${result.error.message}`);
6
+ const value = target.slice(5);
7
+ if (result.value.some((team)=>team.slug === value)) return;
8
+ const byId = result.value.find((team)=>team.id === value);
9
+ if (byId) throw new Error(`"${target}" uses a team id. Use the slug instead: "team:${byId.slug}".`);
10
+ throw new Error(`"${target}" is not a known team. Call listTeams first.`);
11
+ };
12
+ export { assertTargetIsUsable };
13
+
14
+ //# sourceMappingURL=assertTargetIsUsable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/assertTargetIsUsable.js","sources":["../../../src/features/ai/assertTargetIsUsable.ts"],"sourcesContent":["import type { ListTeamsUseCase } from \"@webiny/api-core/features/security/teams/ListTeams/index.js\";\n\n/**\n * Rejects a permission target that would be stored happily and then match nobody.\n *\n * A folder rule identifies a team by SLUG (`team:<slug>`) and a user by id (`admin:<userId>`) — see\n * ListFolderLevelPermissionsTargets. The field is only typed as a template string, so a team id where\n * a slug belongs is accepted and silently grants nothing. Also refuses a target the folder inherits,\n * since rewriting it as a direct rule detaches the folder from where the grant came from.\n */\nexport const assertTargetIsUsable = async (\n listTeams: ListTeamsUseCase.Interface,\n target: string,\n inheritedTargets: Set<string>\n): Promise<void> => {\n if (inheritedTargets.has(target)) {\n throw new Error(\n `\"${target}\" is inherited from an ancestor folder or a role, so it cannot be changed on this folder. Change it where it is defined.`\n );\n }\n\n if (!target.startsWith(\"team:\")) {\n return;\n }\n\n const result = await listTeams.execute();\n\n if (result.isFail()) {\n throw new Error(`Could not verify the teams: ${result.error.message}`);\n }\n\n const value = target.slice(\"team:\".length);\n\n if (result.value.some(team => team.slug === value)) {\n return;\n }\n\n const byId = result.value.find(team => team.id === value);\n\n if (byId) {\n throw new Error(`\"${target}\" uses a team id. Use the slug instead: \"team:${byId.slug}\".`);\n }\n\n throw new Error(`\"${target}\" is not a known team. Call listTeams first.`);\n};\n"],"names":["assertTargetIsUsable","listTeams","target","inheritedTargets","Error","result","value","team","byId"],"mappings":"AAUO,MAAMA,uBAAuB,OAChCC,WACAC,QACAC;IAEA,IAAIA,iBAAiB,GAAG,CAACD,SACrB,MAAM,IAAIE,MACN,CAAC,CAAC,EAAEF,OAAO,wHAAwH,CAAC;IAI5I,IAAI,CAACA,OAAO,UAAU,CAAC,UACnB;IAGJ,MAAMG,SAAS,MAAMJ,UAAU,OAAO;IAEtC,IAAII,OAAO,MAAM,IACb,MAAM,IAAID,MAAM,CAAC,4BAA4B,EAAEC,OAAO,KAAK,CAAC,OAAO,EAAE;IAGzE,MAAMC,QAAQJ,OAAO,KAAK,CAAC;IAE3B,IAAIG,OAAO,KAAK,CAAC,IAAI,CAACE,CAAAA,OAAQA,KAAK,IAAI,KAAKD,QACxC;IAGJ,MAAME,OAAOH,OAAO,KAAK,CAAC,IAAI,CAACE,CAAAA,OAAQA,KAAK,EAAE,KAAKD;IAEnD,IAAIE,MACA,MAAM,IAAIJ,MAAM,CAAC,CAAC,EAAEF,OAAO,8CAA8C,EAAEM,KAAK,IAAI,CAAC,EAAE,CAAC;IAG5F,MAAM,IAAIJ,MAAM,CAAC,CAAC,EAAEF,OAAO,4CAA4C,CAAC;AAC5E"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Folder and team tools for AI callers.
3
+ *
4
+ * The list tools are read-only and run unattended. Anything that creates, deletes or changes access is a write,
5
+ * so it pauses for the user to approve the exact arguments. Access changes are deliberately one target
6
+ * per call — granting and revoking separately means the approval block shows the entire change, rather
7
+ * than a desired end state whose omissions quietly remove somebody's access.
8
+ */
9
+ export declare const AcoAiToolsFeature: {
10
+ name: string;
11
+ register(container: import("@webiny/di").Container): void;
12
+ };
@@ -0,0 +1,25 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { ListTeamsTool } from "./ListTeamsTool.js";
3
+ import { ListFoldersTool } from "./ListFoldersTool.js";
4
+ import { GrantFolderAccessTool } from "./GrantFolderAccessTool.js";
5
+ import { RevokeFolderAccessTool } from "./RevokeFolderAccessTool.js";
6
+ import { CreateFolderTool } from "./CreateFolderTool.js";
7
+ import { DeleteFolderTool } from "./DeleteFolderTool.js";
8
+ import { CreateTeamTool } from "./CreateTeamTool.js";
9
+ import { ListRolesTool } from "./ListRolesTool.js";
10
+ const AcoAiToolsFeature = createFeature({
11
+ name: "Aco/AiTools",
12
+ register (container) {
13
+ container.register(ListTeamsTool);
14
+ container.register(ListFoldersTool);
15
+ container.register(GrantFolderAccessTool);
16
+ container.register(RevokeFolderAccessTool);
17
+ container.register(CreateFolderTool);
18
+ container.register(DeleteFolderTool);
19
+ container.register(CreateTeamTool);
20
+ container.register(ListRolesTool);
21
+ }
22
+ });
23
+ export { AcoAiToolsFeature };
24
+
25
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/feature.js","sources":["../../../src/features/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListTeamsTool } from \"./ListTeamsTool.js\";\nimport { ListFoldersTool } from \"./ListFoldersTool.js\";\nimport { GrantFolderAccessTool } from \"./GrantFolderAccessTool.js\";\nimport { RevokeFolderAccessTool } from \"./RevokeFolderAccessTool.js\";\nimport { CreateFolderTool } from \"./CreateFolderTool.js\";\nimport { DeleteFolderTool } from \"./DeleteFolderTool.js\";\nimport { CreateTeamTool } from \"./CreateTeamTool.js\";\nimport { ListRolesTool } from \"./ListRolesTool.js\";\n\n/**\n * Folder and team tools for AI callers.\n *\n * The list tools are read-only and run unattended. Anything that creates, deletes or changes access is a write,\n * so it pauses for the user to approve the exact arguments. Access changes are deliberately one target\n * per call — granting and revoking separately means the approval block shows the entire change, rather\n * than a desired end state whose omissions quietly remove somebody's access.\n */\nexport const AcoAiToolsFeature = createFeature({\n name: \"Aco/AiTools\",\n register(container) {\n container.register(ListTeamsTool);\n container.register(ListFoldersTool);\n container.register(GrantFolderAccessTool);\n container.register(RevokeFolderAccessTool);\n container.register(CreateFolderTool);\n container.register(DeleteFolderTool);\n container.register(CreateTeamTool);\n container.register(ListRolesTool);\n }\n});\n"],"names":["AcoAiToolsFeature","createFeature","container","ListTeamsTool","ListFoldersTool","GrantFolderAccessTool","RevokeFolderAccessTool","CreateFolderTool","DeleteFolderTool","CreateTeamTool","ListRolesTool"],"mappings":";;;;;;;;;AAkBO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;IACvB;AACJ"}
@@ -0,0 +1,9 @@
1
+ export { AcoAiToolsFeature } from "./feature.js";
2
+ export { ListTeamsTool } from "./ListTeamsTool.js";
3
+ export { ListFoldersTool } from "./ListFoldersTool.js";
4
+ export { ListRolesTool } from "./ListRolesTool.js";
5
+ export { GrantFolderAccessTool } from "./GrantFolderAccessTool.js";
6
+ export { RevokeFolderAccessTool } from "./RevokeFolderAccessTool.js";
7
+ export { CreateFolderTool } from "./CreateFolderTool.js";
8
+ export { DeleteFolderTool } from "./DeleteFolderTool.js";
9
+ export { CreateTeamTool } from "./CreateTeamTool.js";
@@ -0,0 +1,9 @@
1
+ export { AcoAiToolsFeature } from "./feature.js";
2
+ export { ListTeamsTool } from "./ListTeamsTool.js";
3
+ export { ListFoldersTool } from "./ListFoldersTool.js";
4
+ export { ListRolesTool } from "./ListRolesTool.js";
5
+ export { GrantFolderAccessTool } from "./GrantFolderAccessTool.js";
6
+ export { RevokeFolderAccessTool } from "./RevokeFolderAccessTool.js";
7
+ export { CreateFolderTool } from "./CreateFolderTool.js";
8
+ export { DeleteFolderTool } from "./DeleteFolderTool.js";
9
+ export { CreateTeamTool } from "./CreateTeamTool.js";
@@ -0,0 +1,16 @@
1
+ import type { GetFolderUseCase } from "../../features/folder/GetFolder/index.js";
2
+ import type { Folder, FolderPermission } from "../../types.js";
3
+ export interface LoadedFolderPermissions {
4
+ folder: Folder;
5
+ /** Rules set on this folder. The only ones it may change. */
6
+ direct: FolderPermission[];
7
+ /** Targets granted by an ancestor or a role. Writing these back would detach the inheritance. */
8
+ inheritedTargets: Set<string>;
9
+ }
10
+ /**
11
+ * Reads a folder and separates the rules it owns from the ones it merely inherits.
12
+ *
13
+ * Every permission write starts here, because the field holds both kinds and a change has to preserve
14
+ * the direct rules while leaving the inherited ones alone.
15
+ */
16
+ export declare const loadFolderPermissions: (getFolder: GetFolderUseCase.Interface, folderId: string) => Promise<LoadedFolderPermissions>;
@@ -0,0 +1,14 @@
1
+ const loadFolderPermissions = async (getFolder, folderId)=>{
2
+ const result = await getFolder.execute(folderId);
3
+ if (result.isFail()) throw new Error(`Folder "${folderId}" not found: ${result.error.message}. Call listFolders for valid ids.`);
4
+ const folder = result.value;
5
+ const permissions = folder.permissions ?? [];
6
+ return {
7
+ folder,
8
+ direct: permissions.filter((permission)=>!permission.inheritedFrom),
9
+ inheritedTargets: new Set(permissions.filter((permission)=>permission.inheritedFrom).map((p)=>String(p.target)))
10
+ };
11
+ };
12
+ export { loadFolderPermissions };
13
+
14
+ //# sourceMappingURL=loadFolderPermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ai/loadFolderPermissions.js","sources":["../../../src/features/ai/loadFolderPermissions.ts"],"sourcesContent":["import type { GetFolderUseCase } from \"~/features/folder/GetFolder/index.js\";\nimport type { Folder, FolderPermission } from \"~/types.js\";\n\nexport interface LoadedFolderPermissions {\n folder: Folder;\n /** Rules set on this folder. The only ones it may change. */\n direct: FolderPermission[];\n /** Targets granted by an ancestor or a role. Writing these back would detach the inheritance. */\n inheritedTargets: Set<string>;\n}\n\n/**\n * Reads a folder and separates the rules it owns from the ones it merely inherits.\n *\n * Every permission write starts here, because the field holds both kinds and a change has to preserve\n * the direct rules while leaving the inherited ones alone.\n */\nexport const loadFolderPermissions = async (\n getFolder: GetFolderUseCase.Interface,\n folderId: string\n): Promise<LoadedFolderPermissions> => {\n const result = await getFolder.execute(folderId);\n\n if (result.isFail()) {\n throw new Error(\n `Folder \"${folderId}\" not found: ${result.error.message}. Call listFolders for valid ids.`\n );\n }\n\n const folder = result.value;\n const permissions = folder.permissions ?? [];\n\n return {\n folder,\n direct: permissions.filter(permission => !permission.inheritedFrom),\n inheritedTargets: new Set(\n permissions.filter(permission => permission.inheritedFrom).map(p => String(p.target))\n )\n };\n};\n"],"names":["loadFolderPermissions","getFolder","folderId","result","Error","folder","permissions","permission","Set","p","String"],"mappings":"AAiBO,MAAMA,wBAAwB,OACjCC,WACAC;IAEA,MAAMC,SAAS,MAAMF,UAAU,OAAO,CAACC;IAEvC,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIC,MACN,CAAC,QAAQ,EAAEF,SAAS,aAAa,EAAEC,OAAO,KAAK,CAAC,OAAO,CAAC,iCAAiC,CAAC;IAIlG,MAAME,SAASF,OAAO,KAAK;IAC3B,MAAMG,cAAcD,OAAO,WAAW,IAAI,EAAE;IAE5C,OAAO;QACHA;QACA,QAAQC,YAAY,MAAM,CAACC,CAAAA,aAAc,CAACA,WAAW,aAAa;QAClE,kBAAkB,IAAIC,IAClBF,YAAY,MAAM,CAACC,CAAAA,aAAcA,WAAW,aAAa,EAAE,GAAG,CAACE,CAAAA,IAAKC,OAAOD,EAAE,MAAM;IAE3F;AACJ"}
@@ -10,6 +10,7 @@ class ListDeletedEntriesWithFlpDecoratorImpl {
10
10
  async execute(model, params) {
11
11
  const loader = async (params)=>{
12
12
  const result = await this.decoratee.execute(model, params);
13
+ if (result.isFail()) throw result.error;
13
14
  return result.value;
14
15
  };
15
16
  const { entries, meta } = await this.listEntriesHandler.execute({
@@ -1 +1 @@
1
- {"version":3,"file":"features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListDeletedEntriesWithFlpDecoratorImpl implements ListDeletedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListDeletedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListDeletedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListDeletedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListDeletedEntriesUseCase,\n decorator: ListDeletedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListDeletedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListDeletedEntriesWithFlpDecorator","createDecorator","ListDeletedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA8C,CACxD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACQ;QACnC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,OAAOE,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,qCAAqCC,gBAAgB;IAC9D,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
1
+ {"version":3,"file":"features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListDeletedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListDeletedEntriesWithFlpDecoratorImpl implements ListDeletedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListDeletedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListDeletedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListDeletedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListDeletedEntriesUseCase,\n decorator: ListDeletedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListDeletedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListDeletedEntriesWithFlpDecorator","createDecorator","ListDeletedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA8C,CACxD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACQ;QACnC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,qCAAqCC,gBAAgB;IAC9D,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
@@ -10,6 +10,7 @@ class ListEntriesWithFlpDecoratorImpl {
10
10
  async execute(model, params) {
11
11
  const loader = async (params)=>{
12
12
  const result = await this.decoratee.execute(model, params);
13
+ if (result.isFail()) throw result.error;
13
14
  return result.value;
14
15
  };
15
16
  const { entries, meta } = await this.listEntriesHandler.execute({
@@ -1 +1 @@
1
- {"version":3,"file":"features/cms/decorators/ListEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator, Result } from \"@webiny/feature/api\";\nimport { ListEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsEntryListParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListEntriesWithFlpDecoratorImpl implements ListEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListEntriesWithFlpDecorator = createDecorator({\n abstraction: ListEntriesUseCase,\n decorator: ListEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListEntriesWithFlpDecorator","createDecorator","ListEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAUA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAuC,CACjD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACC;QAC5B,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,OAAOE,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,8BAA8BC,gBAAgB;IACvD,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
1
+ {"version":3,"file":"features/cms/decorators/ListEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator, Result } from \"@webiny/feature/api\";\nimport { ListEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsEntryListParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListEntriesWithFlpDecoratorImpl implements ListEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListEntriesWithFlpDecorator = createDecorator({\n abstraction: ListEntriesUseCase,\n decorator: ListEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListEntriesWithFlpDecorator","createDecorator","ListEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAUA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAuC,CACjD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACC;QAC5B,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,8BAA8BC,gBAAgB;IACvD,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
@@ -10,6 +10,7 @@ class ListLatestEntriesWithFlpDecoratorImpl {
10
10
  async execute(model, params) {
11
11
  const loader = async (params)=>{
12
12
  const result = await this.decoratee.execute(model, params);
13
+ if (result.isFail()) throw result.error;
13
14
  return result.value;
14
15
  };
15
16
  const { entries, meta } = await this.listEntriesHandler.execute({
@@ -1 +1 @@
1
- {"version":3,"file":"features/cms/decorators/ListLatestEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListLatestEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListLatestEntriesWithFlpDecoratorImpl implements ListLatestEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListLatestEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListLatestEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListLatestEntriesWithFlpDecorator = createDecorator({\n abstraction: ListLatestEntriesUseCase,\n decorator: ListLatestEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListLatestEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListLatestEntriesWithFlpDecorator","createDecorator","ListLatestEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA6C,CACvD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACO;QAClC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,OAAOE,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,oCAAoCC,gBAAgB;IAC7D,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
1
+ {"version":3,"file":"features/cms/decorators/ListLatestEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListLatestEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListLatestEntriesWithFlpDecoratorImpl implements ListLatestEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListLatestEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListLatestEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListLatestEntriesWithFlpDecorator = createDecorator({\n abstraction: ListLatestEntriesUseCase,\n decorator: ListLatestEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListLatestEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListLatestEntriesWithFlpDecorator","createDecorator","ListLatestEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAA6C,CACvD;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACO;QAClC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,oCAAoCC,gBAAgB;IAC7D,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
@@ -10,6 +10,7 @@ class ListPublishedEntriesWithFlpDecoratorImpl {
10
10
  async execute(model, params) {
11
11
  const loader = async (params)=>{
12
12
  const result = await this.decoratee.execute(model, params);
13
+ if (result.isFail()) throw result.error;
13
14
  return result.value;
14
15
  };
15
16
  const { entries, meta } = await this.listEntriesHandler.execute({
@@ -1 +1 @@
1
- {"version":3,"file":"features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListPublishedEntriesWithFlpDecoratorImpl implements ListPublishedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListPublishedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListPublishedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListPublishedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListPublishedEntriesUseCase,\n decorator: ListPublishedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListPublishedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListPublishedEntriesWithFlpDecorator","createDecorator","ListPublishedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAgD,CAC1D;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACU;QACrC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,OAAOE,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,uCAAuCC,gBAAgB;IAChE,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
1
+ {"version":3,"file":"features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ListPublishedEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/abstractions.js\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { ListEntriesFactory } from \"~/utils/decorators/ListEntriesFactory.js\";\n\nclass ListPublishedEntriesWithFlpDecoratorImpl implements ListPublishedEntriesUseCase.Interface {\n private readonly listEntriesHandler: ListEntriesFactory;\n\n constructor(\n folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: ListPublishedEntriesUseCase.Interface\n ) {\n this.listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ): ListPublishedEntriesUseCase.Return<T> {\n const loader = async (params?: CmsEntryListParams) => {\n const result = await this.decoratee.execute<T>(model, params);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n\n const { entries, meta } = await this.listEntriesHandler.execute<T>({\n model,\n dataLoader: loader,\n initialParams: params\n });\n\n return Result.ok({ entries, meta });\n }\n}\n\nexport const ListPublishedEntriesWithFlpDecorator = createDecorator({\n abstraction: ListPublishedEntriesUseCase,\n decorator: ListPublishedEntriesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ListPublishedEntriesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","ListEntriesFactory","model","params","loader","result","entries","meta","Result","ListPublishedEntriesWithFlpDecorator","createDecorator","ListPublishedEntriesUseCase","FolderLevelPermissions"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,sBAAwD,EAChDC,SAAgD,CAC1D;aADUA,SAAS,GAATA;QAER,IAAI,CAAC,kBAAkB,GAAG,IAAIC,mBAAmBF;IACrD;IAEA,MAAM,QACFG,KAAe,EACfC,MAA2B,EACU;QACrC,MAAMC,SAAS,OAAOD;YAClB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;YACtD,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAEtB,OAAOA,OAAO,KAAK;QACvB;QAEA,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAI;YAC/DL;YACA,YAAYE;YACZ,eAAeD;QACnB;QAEA,OAAOK,OAAO,EAAE,CAAC;YAAEF;YAASC;QAAK;IACrC;AACJ;AAEO,MAAME,uCAAuCC,gBAAgB;IAChE,aAAaC;IACb,WAAWb;IACX,cAAc;QAACc;KAAuB;AAC1C"}
@@ -9,7 +9,7 @@ declare class MoveEntryWithFlpDecoratorImpl implements MoveEntryUseCase.Interfac
9
9
  private getRevisionById;
10
10
  private decoratee;
11
11
  constructor(folderLevelPermissions: FolderLevelPermissions.Interface, getRevisionById: GetRevisionByIdUseCase.Interface, decoratee: MoveEntryUseCase.Interface);
12
- execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, id: string, targetFolderId: string): Promise<Result<import("@webiny/api-headless-cms/types/types").CmsEntry<T>, EntryNotAuthorizedError | import("@webiny/api-headless-cms/domain/contentEntry/errors.js").EntryPersistenceError | import("@webiny/api-headless-cms/domain/contentEntry/errors.js").EntryNotFoundError>>;
12
+ execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, id: string, targetFolderId: string): Promise<Result<import("@webiny/api-headless-cms/types/types").CmsEntry<T>, EntryNotAuthorizedError | import("@webiny/api-headless-cms/domain/contentEntry/errors.js").EntryNotFoundError | import("@webiny/api-headless-cms/domain/contentEntry/errors.js").EntryPersistenceError>>;
13
13
  }
14
14
  export declare const MoveEntryWithFlpDecorator: typeof MoveEntryWithFlpDecoratorImpl;
15
15
  export {};