@webiny/api-aco 6.6.0-alpha.0 → 6.6.0-alpha.10
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.
- package/AcoFeature.js +23 -38
- package/AcoFeature.js.map +1 -1
- package/AcoFolderSchemaFactory.d.ts +32 -0
- package/AcoFolderSchemaFactory.js +82 -0
- package/AcoFolderSchemaFactory.js.map +1 -0
- package/createAcoGraphQL.d.ts +3 -2
- package/createAcoGraphQL.js.map +1 -1
- package/domain/folder/abstractions.d.ts +12 -5
- package/domain/folder/abstractions.js +2 -2
- package/domain/folder/abstractions.js.map +1 -1
- package/domain/folder/folder.model.js +2 -1
- package/domain/folder/folder.model.js.map +1 -1
- package/exports/api/aco/flp.d.ts +3 -3
- package/exports/api/aco/flp.js +2 -3
- package/features/ai/CreateFolderTool.d.ts +49 -0
- package/features/ai/CreateFolderTool.js +58 -0
- package/features/ai/CreateFolderTool.js.map +1 -0
- package/features/ai/CreateTeamTool.d.ts +48 -0
- package/features/ai/CreateTeamTool.js +56 -0
- package/features/ai/CreateTeamTool.js.map +1 -0
- package/features/ai/DeleteFolderTool.d.ts +48 -0
- package/features/ai/DeleteFolderTool.js +55 -0
- package/features/ai/DeleteFolderTool.js.map +1 -0
- package/features/ai/GrantFolderAccessTool.d.ts +77 -0
- package/features/ai/GrantFolderAccessTool.js +80 -0
- package/features/ai/GrantFolderAccessTool.js.map +1 -0
- package/features/ai/ListFoldersTool.d.ts +47 -0
- package/features/ai/ListFoldersTool.js +57 -0
- package/features/ai/ListFoldersTool.js.map +1 -0
- package/features/ai/ListRolesTool.d.ts +39 -0
- package/features/ai/ListRolesTool.js +48 -0
- package/features/ai/ListRolesTool.js.map +1 -0
- package/features/ai/ListTeamsTool.d.ts +39 -0
- package/features/ai/ListTeamsTool.js +48 -0
- package/features/ai/ListTeamsTool.js.map +1 -0
- package/features/ai/RevokeFolderAccessTool.d.ts +63 -0
- package/features/ai/RevokeFolderAccessTool.js +69 -0
- package/features/ai/RevokeFolderAccessTool.js.map +1 -0
- package/features/ai/assertTargetIsUsable.d.ts +10 -0
- package/features/ai/assertTargetIsUsable.js +14 -0
- package/features/ai/assertTargetIsUsable.js.map +1 -0
- package/features/ai/feature.d.ts +12 -0
- package/features/ai/feature.js +25 -0
- package/features/ai/feature.js.map +1 -0
- package/features/ai/index.d.ts +9 -0
- package/features/ai/index.js +9 -0
- package/features/ai/loadFolderPermissions.d.ts +16 -0
- package/features/ai/loadFolderPermissions.js +14 -0
- package/features/ai/loadFolderPermissions.js.map +1 -0
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.d.ts +4 -4
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js +7 -8
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListEntriesWithFlpDecorator.d.ts +3 -3
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js +7 -8
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.d.ts +4 -4
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js +7 -8
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.d.ts +4 -4
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js +7 -8
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js.map +1 -1
- package/features/flp/CreateFlp/index.d.ts +0 -1
- package/features/flp/CreateFlp/index.js +0 -1
- package/features/flp/DeleteFlp/index.d.ts +0 -1
- package/features/flp/DeleteFlp/index.js +0 -1
- package/features/flp/FolderAccessListFilter/abstractions.d.ts +33 -0
- package/features/flp/FolderAccessListFilter/abstractions.js +5 -0
- package/features/flp/FolderAccessListFilter/abstractions.js.map +1 -0
- package/features/flp/FolderAccessListFilter/index.d.ts +1 -0
- package/features/flp/FolderAccessListFilter/index.js +1 -0
- package/features/flp/FolderCatalogSync/FolderCatalogSyncHandlersFeature.d.ts +8 -0
- package/features/flp/FolderCatalogSync/FolderCatalogSyncHandlersFeature.js +15 -0
- package/features/flp/FolderCatalogSync/FolderCatalogSyncHandlersFeature.js.map +1 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderCreatedHandler.d.ts +11 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderCreatedHandler.js +19 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderCreatedHandler.js.map +1 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderDeletedHandler.d.ts +11 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderDeletedHandler.js +19 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderDeletedHandler.js.map +1 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderUpdatedHandler.d.ts +11 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderUpdatedHandler.js +23 -0
- package/features/flp/FolderCatalogSync/SyncFolderCatalogOnFolderUpdatedHandler.js.map +1 -0
- package/features/flp/FolderCatalogSync/abstractions.d.ts +25 -0
- package/features/flp/FolderCatalogSync/abstractions.js +5 -0
- package/features/flp/FolderCatalogSync/abstractions.js.map +1 -0
- package/features/flp/FolderCatalogSync/index.d.ts +2 -0
- package/features/flp/FolderCatalogSync/index.js +2 -0
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.d.ts +8 -5
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +25 -11
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.d.ts +1 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js +3 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/abstractions.d.ts +8 -2
- package/features/flp/FolderLevelPermissions/abstractions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.d.ts +12 -0
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js +22 -14
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js.map +1 -1
- package/features/flp/FolderPermissionsRepository/abstractions.d.ts +28 -0
- package/features/flp/FolderPermissionsRepository/abstractions.js +5 -0
- package/features/flp/FolderPermissionsRepository/abstractions.js.map +1 -0
- package/features/flp/FolderPermissionsRepository/index.d.ts +1 -0
- package/features/flp/FolderPermissionsRepository/index.js +1 -0
- package/features/flp/GetFlp/GetFlpUseCase.d.ts +10 -5
- package/features/flp/GetFlp/GetFlpUseCase.js +13 -5
- package/features/flp/GetFlp/GetFlpUseCase.js.map +1 -1
- package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.d.ts +13 -0
- package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js +26 -0
- package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js.map +1 -0
- package/features/flp/GetFlp/feature.js +1 -3
- package/features/flp/GetFlp/feature.js.map +1 -1
- package/features/flp/ListFlps/ListFlpsUseCase.d.ts +11 -6
- package/features/flp/ListFlps/ListFlpsUseCase.js +13 -5
- package/features/flp/ListFlps/ListFlpsUseCase.js.map +1 -1
- package/features/flp/ListFlps/abstractions.d.ts +3 -9
- package/features/flp/ListFlps/abstractions.js.map +1 -1
- package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.d.ts +13 -0
- package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js +27 -0
- package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js.map +1 -0
- package/features/flp/ListFlps/feature.js +1 -3
- package/features/flp/ListFlps/feature.js.map +1 -1
- package/features/flp/ListFolderAccess/GetUserEntryAccessUseCase.d.ts +14 -0
- package/features/flp/ListFolderAccess/GetUserEntryAccessUseCase.js +36 -0
- package/features/flp/ListFolderAccess/GetUserEntryAccessUseCase.js.map +1 -0
- package/features/flp/ListFolderAccess/GetUserFolderAccessUseCase.d.ts +25 -0
- package/features/flp/ListFolderAccess/GetUserFolderAccessUseCase.js +75 -0
- package/features/flp/ListFolderAccess/GetUserFolderAccessUseCase.js.map +1 -0
- package/features/flp/ListFolderAccess/ListEntryAccessUseCase.d.ts +13 -0
- package/features/flp/ListFolderAccess/ListEntryAccessUseCase.js +28 -0
- package/features/flp/ListFolderAccess/ListEntryAccessUseCase.js.map +1 -0
- package/features/flp/ListFolderAccess/ListFolderAccessUseCase.d.ts +24 -0
- package/features/flp/ListFolderAccess/ListFolderAccessUseCase.js +107 -0
- package/features/flp/ListFolderAccess/ListFolderAccessUseCase.js.map +1 -0
- package/features/flp/ListFolderAccess/ListUserFolderAccessUseCase.d.ts +28 -0
- package/features/flp/ListFolderAccess/ListUserFolderAccessUseCase.js +98 -0
- package/features/flp/ListFolderAccess/ListUserFolderAccessUseCase.js.map +1 -0
- package/features/flp/ListFolderAccess/UserFolderCandidates.d.ts +13 -0
- package/features/flp/ListFolderAccess/UserFolderCandidates.js +26 -0
- package/features/flp/ListFolderAccess/UserFolderCandidates.js.map +1 -0
- package/features/flp/ListFolderAccess/abstractions.d.ts +182 -0
- package/features/flp/ListFolderAccess/abstractions.js +10 -0
- package/features/flp/ListFolderAccess/abstractions.js.map +1 -0
- package/features/flp/{UpdateFlpOnFolderUpdated → ListFolderAccess}/feature.d.ts +1 -1
- package/features/flp/ListFolderAccess/feature.js +21 -0
- package/features/flp/ListFolderAccess/feature.js.map +1 -0
- package/features/flp/ListFolderAccess/index.d.ts +2 -0
- package/features/flp/ListFolderAccess/index.js +2 -0
- package/features/flp/ListFolderAccess/mayAskAboutUser.d.ts +3 -0
- package/features/flp/ListFolderAccess/mayAskAboutUser.js +9 -0
- package/features/flp/ListFolderAccess/mayAskAboutUser.js.map +1 -0
- package/features/flp/ListFolderAccess/userFolderLevel.d.ts +31 -0
- package/features/flp/ListFolderAccess/userFolderLevel.js +48 -0
- package/features/flp/ListFolderAccess/userFolderLevel.js.map +1 -0
- package/features/flp/UpdateFlp/abstractions.d.ts +6 -2
- package/features/flp/UpdateFlp/abstractions.js.map +1 -1
- package/features/flp/UpdateFlp/index.d.ts +0 -1
- package/features/flp/UpdateFlp/index.js +0 -1
- package/features/flp/shared/CodeFlpMerger.d.ts +26 -0
- package/features/flp/shared/CodeFlpMerger.js +20 -0
- package/features/flp/shared/CodeFlpMerger.js.map +1 -0
- package/features/flp/shared/CodeFlpPath.d.ts +15 -0
- package/features/flp/shared/CodeFlpPath.js +29 -0
- package/features/flp/shared/CodeFlpPath.js.map +1 -0
- package/features/flp/shared/CodeFlpTarget.d.ts +10 -0
- package/features/flp/shared/CodeFlpTarget.js +26 -0
- package/features/flp/shared/CodeFlpTarget.js.map +1 -0
- package/features/flp/shared/CodeFlpsProvider.d.ts +15 -0
- package/features/flp/shared/CodeFlpsProvider.js +36 -0
- package/features/flp/shared/CodeFlpsProvider.js.map +1 -0
- package/features/flp/shared/abstractions.d.ts +79 -0
- package/features/flp/shared/abstractions.js +19 -0
- package/features/flp/shared/abstractions.js.map +1 -0
- package/features/flp/shared/feature.d.ts +5 -0
- package/features/flp/shared/feature.js +17 -0
- package/features/flp/shared/feature.js.map +1 -0
- package/features/flp/shared/index.d.ts +4 -0
- package/features/flp/shared/index.js +4 -0
- package/features/folder/CreateFolder/CreateFolderRepository.d.ts +3 -3
- package/features/folder/CreateFolder/CreateFolderRepository.js +10 -7
- package/features/folder/CreateFolder/CreateFolderRepository.js.map +1 -1
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.d.ts +9 -1
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js +20 -3
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/DeleteFolder/DeleteFolderRepository.d.ts +3 -3
- package/features/folder/DeleteFolder/DeleteFolderRepository.js +6 -5
- package/features/folder/DeleteFolder/DeleteFolderRepository.js.map +1 -1
- package/features/folder/FolderModelProvider.d.ts +26 -0
- package/features/folder/FolderModelProvider.js +22 -0
- package/features/folder/FolderModelProvider.js.map +1 -0
- package/features/folder/GetAncestors/GetAncestorsRepository.d.ts +3 -3
- package/features/folder/GetAncestors/GetAncestorsRepository.js +6 -5
- package/features/folder/GetAncestors/GetAncestorsRepository.js.map +1 -1
- package/features/folder/GetFolder/GetFolderRepository.d.ts +3 -3
- package/features/folder/GetFolder/GetFolderRepository.js +6 -5
- package/features/folder/GetFolder/GetFolderRepository.js.map +1 -1
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.d.ts +3 -3
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js +10 -8
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js.map +1 -1
- package/features/folder/ListFolders/ListFoldersRepository.d.ts +3 -3
- package/features/folder/ListFolders/ListFoldersRepository.js +8 -7
- package/features/folder/ListFolders/ListFoldersRepository.js.map +1 -1
- package/features/folder/ListFolders/decorators/ListFoldersWithFolderLevelPermissions.d.ts +3 -7
- package/features/folder/ListFolders/decorators/ListFoldersWithFolderLevelPermissions.js +5 -50
- package/features/folder/ListFolders/decorators/ListFoldersWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +11 -0
- package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js +38 -0
- package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +1 -0
- package/features/{flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.d.ts → folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.d.ts} +5 -7
- package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js +24 -0
- package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js.map +1 -0
- package/features/folder/NotifyFolderChange/abstractions.d.ts +28 -0
- package/features/folder/NotifyFolderChange/abstractions.js +8 -0
- package/features/folder/NotifyFolderChange/abstractions.js.map +1 -0
- package/features/folder/NotifyFolderChange/feature.d.ts +8 -0
- package/features/folder/NotifyFolderChange/feature.js +13 -0
- package/features/folder/NotifyFolderChange/feature.js.map +1 -0
- package/features/folder/NotifyFolderChange/index.d.ts +2 -0
- package/features/folder/NotifyFolderChange/index.js +2 -0
- package/features/folder/UpdateFolder/UpdateFolderRepository.d.ts +3 -3
- package/features/folder/UpdateFolder/UpdateFolderRepository.js +11 -8
- package/features/folder/UpdateFolder/UpdateFolderRepository.js.map +1 -1
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.d.ts +14 -1
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js +52 -4
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
- package/filter/filter.model.js +2 -1
- package/filter/filter.model.js.map +1 -1
- package/filter/filter.so.d.ts +0 -2
- package/filter/filter.so.js +20 -8
- package/filter/filter.so.js.map +1 -1
- package/flp/flp.types.d.ts +6 -1
- package/flp/index.d.ts +0 -1
- package/flp/index.js +0 -1
- package/flpTaskCatalog/CatalogFolderPermissionsRepository.d.ts +17 -0
- package/flpTaskCatalog/CatalogFolderPermissionsRepository.js +34 -0
- package/flpTaskCatalog/CatalogFolderPermissionsRepository.js.map +1 -0
- package/flpTaskCatalog/PostLoadFolderAccessListFilter.d.ts +24 -0
- package/flpTaskCatalog/PostLoadFolderAccessListFilter.js +63 -0
- package/flpTaskCatalog/PostLoadFolderAccessListFilter.js.map +1 -0
- package/flpTaskCatalog/TaskCatalogFlpFeature.d.ts +12 -0
- package/flpTaskCatalog/TaskCatalogFlpFeature.js +49 -0
- package/flpTaskCatalog/TaskCatalogFlpFeature.js.map +1 -0
- package/flpTaskCatalog/TaskFolderCatalogSync.d.ts +29 -0
- package/flpTaskCatalog/TaskFolderCatalogSync.js +57 -0
- package/flpTaskCatalog/TaskFolderCatalogSync.js.map +1 -0
- package/{flp → flpTaskCatalog}/flp.crud.d.ts +1 -1
- package/flpTaskCatalog/flp.crud.js.map +1 -0
- package/flpTaskCatalog/index.d.ts +1 -0
- package/flpTaskCatalog/index.js +1 -0
- package/{utils/decorators → flpTaskCatalog/listEntries}/ListEntriesFactory.d.ts +1 -1
- package/flpTaskCatalog/listEntries/ListEntriesFactory.js.map +1 -0
- package/flpTaskCatalog/listEntries/hasRootFolderId.js.map +1 -0
- package/{utils/decorators → flpTaskCatalog/listEntries}/isPageModel.js +1 -1
- package/flpTaskCatalog/listEntries/isPageModel.js.map +1 -0
- package/flpTaskCatalog/tasks/createFlp.task.d.ts +25 -0
- package/{flp → flpTaskCatalog}/tasks/createFlp.task.js +34 -17
- package/flpTaskCatalog/tasks/createFlp.task.js.map +1 -0
- package/flpTaskCatalog/tasks/deleteFlp.task.d.ts +23 -0
- package/{flp → flpTaskCatalog}/tasks/deleteFlp.task.js +24 -15
- package/flpTaskCatalog/tasks/deleteFlp.task.js.map +1 -0
- package/{flp → flpTaskCatalog}/tasks/syncFlp.task.d.ts +11 -6
- package/{flp → flpTaskCatalog}/tasks/syncFlp.task.js +25 -16
- package/flpTaskCatalog/tasks/syncFlp.task.js.map +1 -0
- package/flpTaskCatalog/tasks/updateFlp.task.d.ts +25 -0
- package/flpTaskCatalog/tasks/updateFlp.task.js +64 -0
- package/flpTaskCatalog/tasks/updateFlp.task.js.map +1 -0
- package/flpTaskCatalog/useCases/CreateFlpUseCase.d.ts +8 -0
- package/{features/flp/CreateFlp → flpTaskCatalog/useCases}/CreateFlpUseCase.js +1 -1
- package/flpTaskCatalog/useCases/CreateFlpUseCase.js.map +1 -0
- package/flpTaskCatalog/useCases/DeleteFlpUseCase.d.ts +8 -0
- package/flpTaskCatalog/useCases/DeleteFlpUseCase.js.map +1 -0
- package/{features/flp/UpdateFlp → flpTaskCatalog/useCases}/UpdateFlpUseCase.d.ts +10 -11
- package/{features/flp/UpdateFlp → flpTaskCatalog/useCases}/UpdateFlpUseCase.js +27 -33
- package/flpTaskCatalog/useCases/UpdateFlpUseCase.js.map +1 -0
- package/folder/createFolderTypeDefs.js +4 -1
- package/folder/createFolderTypeDefs.js.map +1 -1
- package/folder/folder.gql.js +2 -2
- package/folder/folder.gql.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +23 -22
- package/types.d.ts +2 -3
- package/types.js.map +1 -1
- package/utils/createOperationsWrapper.d.ts +2 -2
- package/utils/createOperationsWrapper.js +5 -5
- package/utils/createOperationsWrapper.js.map +1 -1
- package/AcoInitializer.d.ts +0 -25
- package/AcoInitializer.js +0 -79
- package/AcoInitializer.js.map +0 -1
- package/features/flp/CreateFlp/CreateFlpUseCase.d.ts +0 -8
- package/features/flp/CreateFlp/CreateFlpUseCase.js.map +0 -1
- package/features/flp/CreateFlp/feature.d.ts +0 -5
- package/features/flp/CreateFlp/feature.js +0 -13
- package/features/flp/CreateFlp/feature.js.map +0 -1
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.d.ts +0 -14
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js +0 -37
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js.map +0 -1
- package/features/flp/CreateFlpOnFolderCreated/feature.d.ts +0 -4
- package/features/flp/CreateFlpOnFolderCreated/feature.js +0 -11
- package/features/flp/CreateFlpOnFolderCreated/feature.js.map +0 -1
- package/features/flp/CreateFlpOnFolderCreated/index.d.ts +0 -1
- package/features/flp/CreateFlpOnFolderCreated/index.js +0 -1
- package/features/flp/DeleteFlp/DeleteFlpUseCase.d.ts +0 -8
- package/features/flp/DeleteFlp/DeleteFlpUseCase.js.map +0 -1
- package/features/flp/DeleteFlp/feature.d.ts +0 -5
- package/features/flp/DeleteFlp/feature.js +0 -13
- package/features/flp/DeleteFlp/feature.js.map +0 -1
- package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js +0 -37
- package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js.map +0 -1
- package/features/flp/DeleteFlpOnFolderDeleted/feature.d.ts +0 -4
- package/features/flp/DeleteFlpOnFolderDeleted/feature.js +0 -11
- package/features/flp/DeleteFlpOnFolderDeleted/feature.js.map +0 -1
- package/features/flp/DeleteFlpOnFolderDeleted/index.d.ts +0 -1
- package/features/flp/DeleteFlpOnFolderDeleted/index.js +0 -1
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +0 -1
- package/features/flp/UpdateFlp/feature.d.ts +0 -5
- package/features/flp/UpdateFlp/feature.js +0 -17
- package/features/flp/UpdateFlp/feature.js.map +0 -1
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.d.ts +0 -14
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js +0 -39
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js.map +0 -1
- package/features/flp/UpdateFlpOnFolderUpdated/feature.js +0 -11
- package/features/flp/UpdateFlpOnFolderUpdated/feature.js.map +0 -1
- package/features/flp/UpdateFlpOnFolderUpdated/index.d.ts +0 -1
- package/features/flp/UpdateFlpOnFolderUpdated/index.js +0 -1
- package/flp/flp.crud.js.map +0 -1
- package/flp/tasks/createFlp.task.d.ts +0 -18
- package/flp/tasks/createFlp.task.js.map +0 -1
- package/flp/tasks/deleteFlp.task.d.ts +0 -18
- package/flp/tasks/deleteFlp.task.js.map +0 -1
- package/flp/tasks/syncFlp.task.js.map +0 -1
- package/flp/tasks/updateFlp.task.d.ts +0 -18
- package/flp/tasks/updateFlp.task.js +0 -43
- package/flp/tasks/updateFlp.task.js.map +0 -1
- package/utils/decorators/CmsEntriesCrudDecorators.d.ts +0 -11
- package/utils/decorators/CmsEntriesCrudDecorators.js +0 -179
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +0 -1
- package/utils/decorators/FilterEntriesByFolderFactory.d.ts +0 -7
- package/utils/decorators/FilterEntriesByFolderFactory.js +0 -22
- package/utils/decorators/FilterEntriesByFolderFactory.js.map +0 -1
- package/utils/decorators/ListEntriesFactory.js.map +0 -1
- package/utils/decorators/hasRootFolderId.js.map +0 -1
- package/utils/decorators/isPageModel.js.map +0 -1
- /package/{flp → flpTaskCatalog}/flp.crud.js +0 -0
- /package/{utils/decorators → flpTaskCatalog/listEntries}/ListEntriesFactory.js +0 -0
- /package/{utils/decorators → flpTaskCatalog/listEntries}/hasRootFolderId.d.ts +0 -0
- /package/{utils/decorators → flpTaskCatalog/listEntries}/hasRootFolderId.js +0 -0
- /package/{utils/decorators → flpTaskCatalog/listEntries}/isPageModel.d.ts +0 -0
- /package/{features/flp/DeleteFlp → flpTaskCatalog/useCases}/DeleteFlpUseCase.js +0 -0
|
@@ -1,23 +1,14 @@
|
|
|
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 { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
|
-
import { SYNC_FLP_TASK_ID, UPDATE_FLP_TASK_ID } from "
|
|
3
|
+
import { SYNC_FLP_TASK_ID, UPDATE_FLP_TASK_ID } from "../../flp/tasks/index.js";
|
|
4
4
|
import { FM_FILE_TYPE } from "../../constants.js";
|
|
5
|
-
import { GetFolderUseCase } from "../../features/folder/GetFolder/
|
|
6
|
-
import { ListFoldersUseCase } from "../../features/folder/ListFolders/
|
|
7
|
-
class
|
|
5
|
+
import { GetFolderUseCase } from "../../features/folder/GetFolder/abstractions.js";
|
|
6
|
+
import { ListFoldersUseCase } from "../../features/folder/ListFolders/abstractions.js";
|
|
7
|
+
class SyncFlpTaskHandlerImpl {
|
|
8
8
|
constructor(getFolder, listFolders, listModels){
|
|
9
9
|
this.getFolder = getFolder;
|
|
10
10
|
this.listFolders = listFolders;
|
|
11
11
|
this.listModels = listModels;
|
|
12
|
-
this.id = SYNC_FLP_TASK_ID;
|
|
13
|
-
this.title = "ACO - Sync FLP record";
|
|
14
|
-
this.description = "Synchronizes the FLP catalog by updating the FLP record and its descendants.";
|
|
15
|
-
this.databaseLogs = false;
|
|
16
|
-
this.isPrivate = true;
|
|
17
|
-
this.selfCleanup = [
|
|
18
|
-
"onSuccess",
|
|
19
|
-
"onAbort"
|
|
20
|
-
];
|
|
21
12
|
}
|
|
22
13
|
async run({ input, controller }) {
|
|
23
14
|
try {
|
|
@@ -99,14 +90,32 @@ class SyncFlpTaskImpl {
|
|
|
99
90
|
}
|
|
100
91
|
}
|
|
101
92
|
}
|
|
102
|
-
const
|
|
103
|
-
implementation:
|
|
93
|
+
const SyncFlpTaskHandler = TaskHandler.createImplementation({
|
|
94
|
+
implementation: SyncFlpTaskHandlerImpl,
|
|
104
95
|
dependencies: [
|
|
105
96
|
GetFolderUseCase,
|
|
106
97
|
ListFoldersUseCase,
|
|
107
98
|
ListModelsUseCase
|
|
108
99
|
]
|
|
109
100
|
});
|
|
101
|
+
class SyncFlpTaskImpl {
|
|
102
|
+
constructor(){
|
|
103
|
+
this.id = SYNC_FLP_TASK_ID;
|
|
104
|
+
this.title = "ACO - Sync FLP record";
|
|
105
|
+
this.description = "Synchronizes the FLP catalog by updating the FLP record and its descendants.";
|
|
106
|
+
this.databaseLogs = false;
|
|
107
|
+
this.isPrivate = true;
|
|
108
|
+
this.selfCleanup = [
|
|
109
|
+
"onSuccess",
|
|
110
|
+
"onAbort"
|
|
111
|
+
];
|
|
112
|
+
this.handler = SyncFlpTaskHandler;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const SyncFlpTask = TaskDefinition.createImplementation({
|
|
116
|
+
implementation: SyncFlpTaskImpl,
|
|
117
|
+
dependencies: []
|
|
118
|
+
});
|
|
110
119
|
export { SyncFlpTask };
|
|
111
120
|
|
|
112
121
|
//# sourceMappingURL=syncFlp.task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flpTaskCatalog/tasks/syncFlp.task.js","sources":["../../../src/flpTaskCatalog/tasks/syncFlp.task.ts"],"sourcesContent":["import {\n TaskDefinition,\n TaskHandler\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { SYNC_FLP_TASK_ID, UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type ISyncFlpTaskInput, type IUpdateFlpTaskInput } from \"~/types.js\";\nimport { FM_FILE_TYPE } from \"~/constants.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\n\nclass SyncFlpTaskHandlerImpl implements TaskHandler.Interface<ISyncFlpTaskInput> {\n public constructor(\n private getFolder: GetFolderUseCase.Interface,\n private listFolders: ListFoldersUseCase.Interface,\n private listModels: ListModelsUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskHandler.RunParams<ISyncFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n /**\n * `folderId` provided in the task input. We need to:\n *\n * - update the FLP records for the found folder and all its descendants.\n */\n if (input.folderId) {\n const result = await this.getFolder.execute(input.folderId);\n if (result.isFail()) {\n return controller.response.error(result.error);\n }\n const folder = result.value;\n\n await controller.task.trigger<IUpdateFlpTaskInput>({\n definition: UPDATE_FLP_TASK_ID,\n input: {\n folder\n }\n });\n\n return controller.response.done(\n `Task completed successfully: all FLP records for folderId \"${input.folderId}\" and its children have been queued to be synchronized.`\n );\n }\n\n /**\n * Full update required. We need to:\n *\n * - list cms models to collect their types, together with the default ones [FM_FILE_TYPE]\n * - list all root folders\n * - update the FLP records for the found folders and all its descendants.\n */\n if (input.type && input.type === \"*\") {\n // Some folder types are fixed: pages and files.\n const folderTypes = [FM_FILE_TYPE];\n\n // List all non-private models\n const modelsResult = await this.listModels.execute();\n if (modelsResult.isOk()) {\n const models = modelsResult.value;\n for (const model of models) {\n folderTypes.push(`cms:${model.modelId}`);\n }\n }\n\n for (const folderType of folderTypes) {\n const result = await this.listFolders.execute({\n where: {\n type: folderType,\n parentId: null\n }\n });\n if (result.isFail()) {\n await controller.logger.error({\n message: `Failed to list root folders for type ${folderType}`,\n data: {\n type: folderType,\n error: result.error\n }\n });\n continue;\n }\n\n const { folders } = result.value;\n\n for (const folder of folders) {\n await controller.task.trigger<IUpdateFlpTaskInput>({\n definition: UPDATE_FLP_TASK_ID,\n input: {\n folder\n }\n });\n }\n\n await controller.logger.info({\n message: `FLP Update task triggered for type ${folderType}`,\n data: {\n type: folderType\n }\n });\n }\n\n return controller.response.done(\n `Task completed successfully: all FLP records have been queued to be synchronized.`\n );\n }\n\n /**\n * `type` provided in the task input. We need to:\n *\n * - list all root folders for the provided type\n * - update the FLP records for the found folders and all its descendants.\n */\n if (input.type) {\n const result = await this.listFolders.execute({\n where: {\n type: input.type!,\n parentId: null\n }\n });\n if (result.isFail()) {\n return controller.response.error(result.error);\n }\n\n const { folders } = result.value;\n\n for (const folder of folders) {\n await controller.task.trigger<IUpdateFlpTaskInput>({\n definition: UPDATE_FLP_TASK_ID,\n input: {\n folder\n }\n });\n }\n\n return controller.response.done(\n `Task completed successfully: all FLP records for type \"${input.type}\" have been queued to be synchronized.`\n );\n }\n\n return controller.response.error(\n \"Invalid input: please provide either `type` or `folderId`.\"\n );\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nconst SyncFlpTaskHandler = TaskHandler.createImplementation({\n implementation: SyncFlpTaskHandlerImpl,\n dependencies: [GetFolderUseCase, ListFoldersUseCase, ListModelsUseCase]\n});\n\nclass SyncFlpTaskImpl implements TaskDefinition.Interface {\n public readonly id = SYNC_FLP_TASK_ID;\n public readonly title = \"ACO - Sync FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by updating the FLP record and its descendants.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n handler = SyncFlpTaskHandler;\n}\n\nexport const SyncFlpTask = TaskDefinition.createImplementation({\n implementation: SyncFlpTaskImpl,\n dependencies: []\n});\n"],"names":["SyncFlpTaskHandlerImpl","getFolder","listFolders","listModels","input","controller","result","folder","UPDATE_FLP_TASK_ID","folderTypes","FM_FILE_TYPE","modelsResult","models","model","folderType","folders","error","SyncFlpTaskHandler","TaskHandler","GetFolderUseCase","ListFoldersUseCase","ListModelsUseCase","SyncFlpTaskImpl","SYNC_FLP_TASK_ID","SyncFlpTask","TaskDefinition"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACYC,SAAqC,EACrCC,WAAyC,EACzCC,UAAuC,CACjD;aAHUF,SAAS,GAATA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAA4C,EAAE;QACvE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAQtC,IAAID,MAAM,QAAQ,EAAE;gBAChB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF,MAAM,QAAQ;gBAC1D,IAAIE,OAAO,MAAM,IACb,OAAOD,WAAW,QAAQ,CAAC,KAAK,CAACC,OAAO,KAAK;gBAEjD,MAAMC,SAASD,OAAO,KAAK;gBAE3B,MAAMD,WAAW,IAAI,CAAC,OAAO,CAAsB;oBAC/C,YAAYG;oBACZ,OAAO;wBACHD;oBACJ;gBACJ;gBAEA,OAAOF,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,2DAA2D,EAAED,MAAM,QAAQ,CAAC,uDAAuD,CAAC;YAE7I;YASA,IAAIA,MAAM,IAAI,IAAIA,AAAe,QAAfA,MAAM,IAAI,EAA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AE,GAAGT,OAAO,KAAK;gBAEhC,KAAK,MAAMC,UAAUQ,QACjB,MAAMV,WAAW,IAAI,CAAC,OAAO,CAAsB;oBAC/C,YAAYG;oBACZ,OAAO;wBACHD;oBACJ;gBACJ;gBAGJ,OAAOF,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,uDAAuD,EAAED,MAAM,IAAI,CAAC,sCAAsC,CAAC;YAEpH;YAEA,OAAOC,WAAW,QAAQ,CAAC,KAAK,CAC5B;QAER,EAAE,OAAOW,OAAO;YACZ,OAAOX,WAAW,QAAQ,CAAC,KAAK,CAACW;QACrC;IACJ;AACJ;AAEA,MAAMC,qBAAqBC,YAAY,oBAAoB,CAAC;IACxD,gBAAgBlB;IAChB,cAAc;QAACmB;QAAkBC;QAAoBC;KAAkB;AAC3E;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,GAAGN;;AACd;AAEO,MAAMO,cAAcC,eAAe,oBAAoB,CAAC;IAC3D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
import { type IUpdateFlpTaskInput } from "../../types.js";
|
|
3
|
+
import { UpdateFlpUseCase } from "../../features/flp/UpdateFlp/abstractions.js";
|
|
4
|
+
import { NotifyFolderChangeUseCase } from "../../features/folder/NotifyFolderChange/abstractions.js";
|
|
5
|
+
declare class UpdateFlpTaskHandlerImpl implements TaskHandler.Interface<IUpdateFlpTaskInput> {
|
|
6
|
+
private updateFlp;
|
|
7
|
+
private notifyFolderChange;
|
|
8
|
+
constructor(updateFlp: UpdateFlpUseCase.Interface, notifyFolderChange: NotifyFolderChangeUseCase.Interface);
|
|
9
|
+
run({ input, controller }: TaskHandler.RunParams<IUpdateFlpTaskInput>): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultError | TaskDefinition.ResultContinue<IUpdateFlpTaskInput> | TaskDefinition.ResultDone<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
10
|
+
}
|
|
11
|
+
declare class UpdateFlpTaskImpl implements TaskDefinition.Interface {
|
|
12
|
+
readonly id = "acoUpdateFlp";
|
|
13
|
+
readonly title = "ACO - Update FLP record";
|
|
14
|
+
readonly description = "Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.";
|
|
15
|
+
readonly databaseLogs = false;
|
|
16
|
+
readonly isPrivate = true;
|
|
17
|
+
readonly selfCleanup: ("onAbort" | "onSuccess")[];
|
|
18
|
+
handler: typeof UpdateFlpTaskHandlerImpl & {
|
|
19
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskHandler<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare const UpdateFlpTask: typeof UpdateFlpTaskImpl & {
|
|
23
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
|
|
2
|
+
import { UPDATE_FLP_TASK_ID } from "../../flp/tasks/index.js";
|
|
3
|
+
import { UpdateFlpUseCase } from "../../features/flp/UpdateFlp/abstractions.js";
|
|
4
|
+
import { NotifyFolderChangeUseCase } from "../../features/folder/NotifyFolderChange/abstractions.js";
|
|
5
|
+
class UpdateFlpTaskHandlerImpl {
|
|
6
|
+
constructor(updateFlp, notifyFolderChange){
|
|
7
|
+
this.updateFlp = updateFlp;
|
|
8
|
+
this.notifyFolderChange = notifyFolderChange;
|
|
9
|
+
}
|
|
10
|
+
async run({ input, controller }) {
|
|
11
|
+
try {
|
|
12
|
+
if (controller.runtime.isAborted()) return controller.response.aborted();
|
|
13
|
+
let continuation;
|
|
14
|
+
await this.updateFlp.execute({
|
|
15
|
+
folder: input.folder,
|
|
16
|
+
completed: input.completed,
|
|
17
|
+
isCloseToTimeout: controller.runtime.isCloseToTimeout,
|
|
18
|
+
handleTimeout: (completed)=>{
|
|
19
|
+
continuation = controller.response.continue({
|
|
20
|
+
...input,
|
|
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
|
|
30
|
+
});
|
|
31
|
+
return controller.response.done("Task done: FLP record updated.");
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return controller.response.error(error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const UpdateFlpTaskHandler = TaskHandler.createImplementation({
|
|
38
|
+
implementation: UpdateFlpTaskHandlerImpl,
|
|
39
|
+
dependencies: [
|
|
40
|
+
UpdateFlpUseCase,
|
|
41
|
+
NotifyFolderChangeUseCase
|
|
42
|
+
]
|
|
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
|
+
});
|
|
62
|
+
export { UpdateFlpTask };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=updateFlp.task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flpTaskCatalog/tasks/updateFlp.task.js","sources":["../../../src/flpTaskCatalog/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/abstractions.js\";\nimport { NotifyFolderChangeUseCase } from \"~/features/folder/NotifyFolderChange/abstractions.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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CreateFlpUseCase as UseCaseAbstraction } from "../../features/flp/CreateFlp/abstractions.js";
|
|
2
|
+
import type { Folder } from "../../folder/folder.types.js";
|
|
3
|
+
import type { AcoFlpCrud } from "../../features/folder/shared/abstractions.js";
|
|
4
|
+
export declare class CreateFlpUseCase implements UseCaseAbstraction.Interface {
|
|
5
|
+
private flpCrud;
|
|
6
|
+
constructor(flpCrud: AcoFlpCrud.Interface);
|
|
7
|
+
execute(folder: Folder): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flpTaskCatalog/useCases/CreateFlpUseCase.js","sources":["../../../src/flpTaskCatalog/useCases/CreateFlpUseCase.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { Path } from \"~/utils/Path.js\";\nimport { Permissions, ROOT_FOLDER } from \"@webiny/shared-aco\";\nimport type { CreateFlpUseCase as UseCaseAbstraction } from \"~/features/flp/CreateFlp/abstractions.js\";\nimport type { FolderLevelPermission as IFolderLevelPermission } from \"~/flp/flp.types.js\";\nimport type { Folder } from \"~/folder/folder.types.js\";\nimport type { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\n\nexport class CreateFlpUseCase implements UseCaseAbstraction.Interface {\n constructor(private flpCrud: AcoFlpCrud.Interface) {}\n\n async execute(folder: Folder): Promise<void> {\n try {\n const { id, type, slug, parentId, permissions } = folder;\n let parentFlp: IFolderLevelPermission | null = null;\n\n if (parentId) {\n parentFlp = await this.flpCrud.get(parentId);\n\n if (!parentFlp) {\n throw new WebinyError(\n \"Parent folder level permission not found. Unable to create a new record in the FLP catalog.\",\n \"ERROR_CREATE_FLP_USE_CASE_PARENT_FLP_NOT_FOUND\"\n );\n }\n }\n\n await this.flpCrud.create({\n id,\n type,\n slug,\n parentId: parentId ?? ROOT_FOLDER,\n path: Path.create(slug, parentFlp?.path),\n permissions: Permissions.create(permissions, parentFlp)\n });\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while creating FLP\",\n code: \"ERROR_CREATE_FLP_USE_CASE\"\n });\n }\n }\n}\n"],"names":["CreateFlpUseCase","flpCrud","folder","id","type","slug","parentId","permissions","parentFlp","WebinyError","ROOT_FOLDER","Path","Permissions","error"],"mappings":";;;AAQO,MAAMA;IACT,YAAoBC,OAA6B,CAAE;aAA/BA,OAAO,GAAPA;IAAgC;IAEpD,MAAM,QAAQC,MAAc,EAAiB;QACzC,IAAI;YACA,MAAM,EAAEC,EAAE,EAAEC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGL;YAClD,IAAIM,YAA2C;YAE/C,IAAIF,UAAU;gBACVE,YAAY,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAACF;gBAEnC,IAAI,CAACE,WACD,MAAM,IAAIC,YACN,+FACA;YAGZ;YAEA,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;gBACtBN;gBACAC;gBACAC;gBACA,UAAUC,YAAYI;gBACtB,MAAMC,KAAK,MAAM,CAACN,MAAMG,WAAW;gBACnC,aAAaI,YAAY,MAAM,CAACL,aAAaC;YACjD;QACJ,EAAE,OAAOK,OAAO;YACZ,MAAMJ,YAAY,IAAI,CAACI,OAAO;gBAC1B,SAAS;gBACT,MAAM;YACV;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DeleteFlpUseCase as UseCaseAbstraction } from "../../features/flp/DeleteFlp/abstractions.js";
|
|
2
|
+
import type { Folder } from "../../folder/folder.types.js";
|
|
3
|
+
import type { AcoFlpCrud } from "../../features/folder/shared/abstractions.js";
|
|
4
|
+
export declare class DeleteFlpUseCase implements UseCaseAbstraction.Interface {
|
|
5
|
+
private flpCrud;
|
|
6
|
+
constructor(flpCrud: AcoFlpCrud.Interface);
|
|
7
|
+
execute(folder: Folder): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flpTaskCatalog/useCases/DeleteFlpUseCase.js","sources":["../../../src/flpTaskCatalog/useCases/DeleteFlpUseCase.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { DeleteFlpUseCase as UseCaseAbstraction } from \"~/features/flp/DeleteFlp/abstractions.js\";\nimport type { Folder } from \"~/folder/folder.types.js\";\nimport type { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\n\nexport class DeleteFlpUseCase implements UseCaseAbstraction.Interface {\n constructor(private flpCrud: AcoFlpCrud.Interface) {}\n\n async execute(folder: Folder): Promise<void> {\n try {\n if (!folder) {\n throw new WebinyError(\n \"Missing `folder` from the task input, I can't delete the record from the FLP catalog.\",\n \"ERROR_DELETE_FLP_USE_CASE_FOLDER_NOT_PROVIDED\",\n { folder }\n );\n }\n await this.flpCrud.delete(folder.id);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while deleting FLP\",\n code: \"ERROR_DELETE_FLP_USE_CASE\"\n });\n }\n }\n}\n"],"names":["DeleteFlpUseCase","flpCrud","folder","WebinyError","error"],"mappings":";AAKO,MAAMA;IACT,YAAoBC,OAA6B,CAAE;aAA/BA,OAAO,GAAPA;IAAgC;IAEpD,MAAM,QAAQC,MAAc,EAAiB;QACzC,IAAI;YACA,IAAI,CAACA,QACD,MAAM,IAAIC,YACN,yFACA,iDACA;gBAAED;YAAO;YAGjB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAACA,OAAO,EAAE;QACvC,EAAE,OAAOE,OAAO;YACZ,MAAMD,YAAY,IAAI,CAACC,OAAO;gBAC1B,SAAS;gBACT,MAAM;YACV;QACJ;IACJ;AACJ"}
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import type { UpdateFlpParams, UpdateFlpUseCase as UseCaseAbstraction } from "
|
|
2
|
-
import type { AcoFlpCrud } from "
|
|
3
|
-
import type { ListFoldersUseCase } from "
|
|
4
|
-
import type {
|
|
1
|
+
import type { UpdateFlpParams, UpdateFlpUseCase as UseCaseAbstraction } from "../../features/flp/UpdateFlp/abstractions.js";
|
|
2
|
+
import type { AcoFlpCrud } from "../../features/folder/shared/abstractions.js";
|
|
3
|
+
import type { ListFoldersUseCase } from "../../features/folder/ListFolders/abstractions.js";
|
|
4
|
+
import type { FolderModelProvider } from "../../domain/folder/abstractions.js";
|
|
5
5
|
import type { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js";
|
|
6
6
|
import type { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
7
7
|
export declare class UpdateFlpUseCase implements UseCaseAbstraction.Interface {
|
|
8
8
|
private flpCrud;
|
|
9
9
|
private listFoldersUseCase;
|
|
10
|
-
private
|
|
10
|
+
private folderModelProvider;
|
|
11
11
|
private updateEntryUseCase;
|
|
12
12
|
private identityContext;
|
|
13
13
|
private isCloseToTimeout?;
|
|
14
14
|
private handleTimeout?;
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly completed;
|
|
16
16
|
private readonly flpsToUpdate;
|
|
17
|
-
|
|
17
|
+
private timedOut;
|
|
18
|
+
private completedThisRun;
|
|
19
|
+
constructor(flpCrud: AcoFlpCrud.Interface, listFoldersUseCase: ListFoldersUseCase.Interface, folderModelProvider: FolderModelProvider.Interface, updateEntryUseCase: UpdateEntryUseCase.Interface, identityContext: IdentityContext.Interface);
|
|
18
20
|
execute(params: UpdateFlpParams): Promise<void>;
|
|
19
21
|
private collectBranchForUpdate;
|
|
22
|
+
private stopForTimeout;
|
|
20
23
|
private executeBatchUpdate;
|
|
21
|
-
private getQueuedList;
|
|
22
|
-
private setQueued;
|
|
23
|
-
private isQueued;
|
|
24
|
-
private clearQueuedList;
|
|
25
24
|
private listDirectChildren;
|
|
26
25
|
private getFlp;
|
|
27
26
|
}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
|
-
import { Path } from "
|
|
2
|
+
import { Path } from "../../utils/Path.js";
|
|
3
3
|
import { Permissions, ROOT_FOLDER } from "@webiny/shared-aco";
|
|
4
4
|
import { EntryId } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
5
5
|
class UpdateFlpUseCase {
|
|
6
|
-
constructor(flpCrud, listFoldersUseCase,
|
|
6
|
+
constructor(flpCrud, listFoldersUseCase, folderModelProvider, updateEntryUseCase, identityContext){
|
|
7
7
|
this.flpCrud = flpCrud;
|
|
8
8
|
this.listFoldersUseCase = listFoldersUseCase;
|
|
9
|
-
this.
|
|
9
|
+
this.folderModelProvider = folderModelProvider;
|
|
10
10
|
this.updateEntryUseCase = updateEntryUseCase;
|
|
11
11
|
this.identityContext = identityContext;
|
|
12
|
-
this.
|
|
12
|
+
this.completed = new Set();
|
|
13
13
|
this.flpsToUpdate = new Map();
|
|
14
|
+
this.timedOut = false;
|
|
15
|
+
this.completedThisRun = 0;
|
|
14
16
|
}
|
|
15
17
|
async execute(params) {
|
|
16
18
|
this.isCloseToTimeout = params.isCloseToTimeout;
|
|
17
19
|
this.handleTimeout = params.handleTimeout;
|
|
18
|
-
|
|
20
|
+
this.completed.clear();
|
|
21
|
+
this.timedOut = false;
|
|
22
|
+
this.completedThisRun = 0;
|
|
23
|
+
if (params.completed) params.completed.forEach((id)=>this.completed.add(id));
|
|
19
24
|
try {
|
|
20
25
|
const { folder } = params;
|
|
21
26
|
if (!folder) throw new WebinyError("Missing `folder`, I can't update the FLP record.", "ERROR_UPDATING_FLP_USE_CASE_FOLDER_NOT_PROVIDED", {
|
|
@@ -29,20 +34,15 @@ class UpdateFlpUseCase {
|
|
|
29
34
|
path: Path.create(folder.slug, parentFlp?.path),
|
|
30
35
|
permissions: Permissions.create(folder.permissions, parentFlp)
|
|
31
36
|
});
|
|
32
|
-
this.setQueued(flp.id);
|
|
33
37
|
const directChildren = await this.listDirectChildren(flp);
|
|
34
38
|
for (const child of directChildren){
|
|
35
|
-
if (this.isCloseToTimeout?.()) {
|
|
36
|
-
await this.executeBatchUpdate();
|
|
37
|
-
this.handleTimeout?.(this.getQueuedList());
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
39
|
await this.collectBranchForUpdate(child, flp);
|
|
40
|
+
if (this.timedOut) return;
|
|
41
41
|
}
|
|
42
42
|
await this.executeBatchUpdate();
|
|
43
43
|
} catch (error) {
|
|
44
44
|
this.flpsToUpdate.clear();
|
|
45
|
-
this.
|
|
45
|
+
this.completed.clear();
|
|
46
46
|
throw WebinyError.from(error, {
|
|
47
47
|
message: "Error while updating FLP",
|
|
48
48
|
code: "ERROR_UPDATING_FLP_USE_CASE"
|
|
@@ -50,7 +50,8 @@ class UpdateFlpUseCase {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
async collectBranchForUpdate(flp, parentFlp) {
|
|
53
|
-
if (this.
|
|
53
|
+
if (this.completed.has(flp.id)) return;
|
|
54
|
+
if (this.isCloseToTimeout?.()) return void await this.stopForTimeout();
|
|
54
55
|
const parentFlpData = this.flpsToUpdate.get(parentFlp.id);
|
|
55
56
|
const currentParentFlp = {
|
|
56
57
|
...parentFlp,
|
|
@@ -64,18 +65,24 @@ class UpdateFlpUseCase {
|
|
|
64
65
|
path: Path.create(flp.slug, currentParentFlp.path),
|
|
65
66
|
permissions: Permissions.create(flp.permissions, currentParentFlp)
|
|
66
67
|
});
|
|
67
|
-
this.setQueued(flp.id);
|
|
68
68
|
const children = await this.listDirectChildren(flp);
|
|
69
69
|
for (const child of children){
|
|
70
|
-
if (this.isCloseToTimeout?.()) {
|
|
71
|
-
await this.executeBatchUpdate();
|
|
72
|
-
this.handleTimeout?.(this.getQueuedList());
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
70
|
await this.collectBranchForUpdate(child, flp);
|
|
71
|
+
if (this.timedOut) return;
|
|
76
72
|
}
|
|
73
|
+
for (const child of children)this.completed.delete(child.id);
|
|
74
|
+
this.completed.add(flp.id);
|
|
75
|
+
this.completedThisRun++;
|
|
76
|
+
}
|
|
77
|
+
async stopForTimeout() {
|
|
78
|
+
this.timedOut = true;
|
|
79
|
+
await this.executeBatchUpdate();
|
|
80
|
+
if (0 === this.completedThisRun) throw new WebinyError("The FLP update ran out of time before finishing any folder, so continuing would repeat the same work.", "UPDATE_FLP_NO_PROGRESS");
|
|
81
|
+
const completed = Array.from(this.completed);
|
|
82
|
+
this.handleTimeout?.(completed);
|
|
77
83
|
}
|
|
78
84
|
async executeBatchUpdate() {
|
|
85
|
+
const folderModel = await this.folderModelProvider.get();
|
|
79
86
|
try {
|
|
80
87
|
const items = Array.from(this.flpsToUpdate.entries()).map(([id, { slug, parentId, path, permissions }])=>({
|
|
81
88
|
id,
|
|
@@ -90,7 +97,7 @@ class UpdateFlpUseCase {
|
|
|
90
97
|
for (const item of items){
|
|
91
98
|
const { id, data } = item;
|
|
92
99
|
const entryId = EntryId.from(id);
|
|
93
|
-
const updateResult = await this.updateEntryUseCase.execute(
|
|
100
|
+
const updateResult = await this.updateEntryUseCase.execute(folderModel, entryId.toString(), {
|
|
94
101
|
values: {
|
|
95
102
|
path: data.path
|
|
96
103
|
}
|
|
@@ -107,21 +114,8 @@ class UpdateFlpUseCase {
|
|
|
107
114
|
});
|
|
108
115
|
} finally{
|
|
109
116
|
this.flpsToUpdate.clear();
|
|
110
|
-
this.clearQueuedList();
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
|
-
getQueuedList() {
|
|
114
|
-
return Array.from(this.queued);
|
|
115
|
-
}
|
|
116
|
-
setQueued(id) {
|
|
117
|
-
this.queued.add(id);
|
|
118
|
-
}
|
|
119
|
-
isQueued(id) {
|
|
120
|
-
return this.queued.has(id);
|
|
121
|
-
}
|
|
122
|
-
clearQueuedList() {
|
|
123
|
-
this.queued.clear();
|
|
124
|
-
}
|
|
125
119
|
async listDirectChildren(flp) {
|
|
126
120
|
const result = await this.identityContext.withoutAuthorization(()=>this.listFoldersUseCase.execute({
|
|
127
121
|
where: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flpTaskCatalog/useCases/UpdateFlpUseCase.js","sources":["../../../src/flpTaskCatalog/useCases/UpdateFlpUseCase.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { Path } from \"~/utils/Path.js\";\nimport { Permissions, ROOT_FOLDER } from \"@webiny/shared-aco\";\nimport type {\n UpdateFlpParams,\n UpdateFlpUseCase as UseCaseAbstraction\n} from \"~/features/flp/UpdateFlp/abstractions.js\";\nimport type { Folder, FolderLevelPermission, FolderPermission } from \"~/types.js\";\nimport type { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\nimport type { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\nimport type { FolderModelProvider } from \"~/domain/folder/abstractions.js\";\nimport { EntryId } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport type { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\ninterface FlpUpdateData {\n parentId: string;\n slug: string;\n path: string;\n permissions: FolderPermission[];\n}\n\nexport class UpdateFlpUseCase implements UseCaseAbstraction.Interface {\n private isCloseToTimeout?: () => boolean;\n private handleTimeout?: (updated: string[]) => void;\n\n /*\n * Folders whose whole subtree has been written, carried across task runs as `completed` so a\n * continued run skips them. A folder is added only after all of its descendants are written: one\n * entered but not finished when time ran out has to be walked again, or the rest of its subtree\n * would never be updated.\n *\n * Only the topmost finished folders are kept. When a folder completes, its children leave the\n * set, since skipping the folder already skips them. The set travels in the task input on every\n * continuation, and listing every finished folder would outgrow it on exactly the large trees\n * that need continuing.\n */\n private readonly completed: Set<string> = new Set();\n private readonly flpsToUpdate: Map<string, FlpUpdateData> = new Map();\n private timedOut = false;\n // How many folders this run finished, so a run that finished none can refuse to hand over.\n private completedThisRun = 0;\n\n constructor(\n private flpCrud: AcoFlpCrud.Interface,\n private listFoldersUseCase: ListFoldersUseCase.Interface,\n private folderModelProvider: FolderModelProvider.Interface,\n private updateEntryUseCase: UpdateEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(params: UpdateFlpParams): Promise<void> {\n this.isCloseToTimeout = params.isCloseToTimeout;\n this.handleTimeout = params.handleTimeout;\n\n // Fresh per run, so an instance that ever gets reused does not carry the last run's state.\n this.completed.clear();\n this.timedOut = false;\n this.completedThisRun = 0;\n\n if (params.completed) {\n params.completed.forEach(id => this.completed.add(id));\n }\n\n try {\n const { folder } = params;\n\n if (!folder) {\n throw new WebinyError(\n \"Missing `folder`, I can't update the FLP record.\",\n \"ERROR_UPDATING_FLP_USE_CASE_FOLDER_NOT_PROVIDED\",\n { folder }\n );\n }\n\n const flp = await this.getFlp(folder);\n const parentFlp = folder.parentId ? await this.flpCrud.get(folder.parentId) : null;\n\n // Add the root folder to the update collection\n this.flpsToUpdate.set(folder.id, {\n slug: folder.slug,\n parentId: folder.parentId ?? ROOT_FOLDER,\n path: Path.create(folder.slug, parentFlp?.path),\n permissions: Permissions.create(folder.permissions, parentFlp)\n });\n\n // Get direct children and process each branch completely\n const directChildren = await this.listDirectChildren(flp);\n\n for (const child of directChildren) {\n await this.collectBranchForUpdate(child, flp);\n if (this.timedOut) {\n return;\n }\n }\n\n // Execute batch update\n await this.executeBatchUpdate();\n } catch (error) {\n // Clear the update collection in case of error\n this.flpsToUpdate.clear();\n this.completed.clear();\n throw WebinyError.from(error, {\n message: \"Error while updating FLP\",\n code: \"ERROR_UPDATING_FLP_USE_CASE\"\n });\n }\n }\n\n private async collectBranchForUpdate(\n flp: FolderLevelPermission,\n parentFlp: FolderLevelPermission\n ): Promise<void> {\n if (this.completed.has(flp.id)) {\n return;\n }\n\n if (this.isCloseToTimeout?.()) {\n await this.stopForTimeout();\n return;\n }\n\n // Get the parent's permissions from the update collection if available\n const parentFlpData = this.flpsToUpdate.get(parentFlp.id);\n const currentParentFlp = {\n ...parentFlp,\n ...(parentFlpData && { ...parentFlpData })\n };\n\n // Add the FLP to the update collection with inherited permissions\n this.flpsToUpdate.set(flp.id, {\n slug: flp.slug,\n parentId: flp.parentId,\n path: Path.create(flp.slug, currentParentFlp.path),\n permissions: Permissions.create(flp.permissions, currentParentFlp)\n });\n\n // Process all children of this folder before moving to siblings\n const children = await this.listDirectChildren(flp);\n\n for (const child of children) {\n // Pass the current FLP as the parent for the child\n await this.collectBranchForUpdate(child, flp);\n if (this.timedOut) {\n return;\n }\n }\n\n // Only now is everything below this folder collected.\n for (const child of children) {\n this.completed.delete(child.id);\n }\n this.completed.add(flp.id);\n this.completedThisRun++;\n }\n\n /*\n * Writes what has been collected and hands over to a continued run. Every level of the walk\n * checks `timedOut` and stops, rather than carrying on with its remaining children.\n *\n * A run that finished no folder would hand the next run the same input, which would do the same\n * work and hand over again, forever. That fails the task instead.\n */\n private async stopForTimeout(): Promise<void> {\n this.timedOut = true;\n await this.executeBatchUpdate();\n\n if (this.completedThisRun === 0) {\n throw new WebinyError(\n \"The FLP update ran out of time before finishing any folder, so continuing would repeat the same work.\",\n \"UPDATE_FLP_NO_PROGRESS\"\n );\n }\n\n const completed = Array.from(this.completed);\n this.handleTimeout?.(completed);\n }\n\n private async executeBatchUpdate(): Promise<void> {\n const folderModel = await this.folderModelProvider.get();\n try {\n const items = Array.from(this.flpsToUpdate.entries()).map(\n ([id, { slug, parentId, path, permissions }]) => {\n return {\n id,\n data: {\n slug,\n parentId,\n path,\n permissions\n }\n };\n }\n );\n\n await this.flpCrud.batchUpdate(items);\n\n // Update all folders with the new path\n for (const item of items) {\n const { id, data } = item;\n // Directly update the folder in CMS storage to bypass any folder update event triggers.\n const entryId = EntryId.from(id);\n const updateResult = await this.updateEntryUseCase.execute(\n folderModel,\n entryId.toString(),\n { values: { path: data.path } }\n );\n if (updateResult.isFail()) {\n throw updateResult.error;\n }\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing batch update of FLPs\",\n code: \"BATCH_UPDATE_FLP_ERROR\",\n data: {\n items: Array.from(this.flpsToUpdate.keys())\n }\n });\n } finally {\n /*\n * Clear the update collection after the batch update. `completed` is kept: it is what a\n * continued run needs to know.\n */\n this.flpsToUpdate.clear();\n }\n }\n\n private async listDirectChildren(flp: FolderLevelPermission): Promise<FolderLevelPermission[]> {\n const result = await this.identityContext.withoutAuthorization(() => {\n return this.listFoldersUseCase.execute({\n where: {\n type: flp.type,\n parentId: flp.id\n }\n });\n });\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return await Promise.all(result.value.folders.map(folder => this.getFlp(folder)));\n }\n\n private async getFlp({\n id,\n type,\n parentId,\n slug,\n permissions\n }: Folder): Promise<FolderLevelPermission> {\n const flp = await this.flpCrud.get(id);\n\n if (!flp) {\n const parentFlp = parentId ? await this.flpCrud.get(parentId) : null;\n\n return await this.flpCrud.create({\n id,\n type,\n slug,\n parentId: parentId ?? ROOT_FOLDER,\n path: Path.create(slug, parentFlp?.path),\n permissions: Permissions.create(permissions, parentFlp)\n });\n }\n\n return flp;\n }\n}\n"],"names":["UpdateFlpUseCase","flpCrud","listFoldersUseCase","folderModelProvider","updateEntryUseCase","identityContext","Set","Map","params","id","folder","WebinyError","flp","parentFlp","ROOT_FOLDER","Path","Permissions","directChildren","child","error","parentFlpData","currentParentFlp","children","completed","Array","folderModel","items","slug","parentId","path","permissions","item","data","entryId","EntryId","updateResult","result","Promise","type"],"mappings":";;;;AAsBO,MAAMA;IAqBT,YACYC,OAA6B,EAC7BC,kBAAgD,EAChDC,mBAAkD,EAClDC,kBAAgD,EAChDC,eAA0C,CACpD;aALUJ,OAAO,GAAPA;aACAC,kBAAkB,GAAlBA;aACAC,mBAAmB,GAAnBA;aACAC,kBAAkB,GAAlBA;aACAC,eAAe,GAAfA;QAZX,KACgB,SAAS,GAAgB,IAAIC;aAC7B,YAAY,GAA+B,IAAIC;aACxD,QAAQ,GAAG;aAEX,gBAAgB,GAAG;IAQxB;IAEH,MAAM,QAAQC,MAAuB,EAAiB;QAClD,IAAI,CAAC,gBAAgB,GAAGA,OAAO,gBAAgB;QAC/C,IAAI,CAAC,aAAa,GAAGA,OAAO,aAAa;QAGzC,IAAI,CAAC,SAAS,CAAC,KAAK;QACpB,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,gBAAgB,GAAG;QAExB,IAAIA,OAAO,SAAS,EAChBA,OAAO,SAAS,CAAC,OAAO,CAACC,CAAAA,KAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA;QAGtD,IAAI;YACA,MAAM,EAAEC,MAAM,EAAE,GAAGF;YAEnB,IAAI,CAACE,QACD,MAAM,IAAIC,YACN,oDACA,m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,UAAUC,YAAYd;gBACtB,MAAMC,KAAK,MAAM,CAACY,MAAMd,WAAW;gBACnC,aAAaG,YAAY,MAAM,CAACc,aAAajB;YACjD;QACJ;QAEA,OAAOD;IACX;AACJ"}
|
|
@@ -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
|
|
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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AqG1D,CAAC;AACL"}
|
package/folder/folder.gql.js
CHANGED
|
@@ -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 {
|
|
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(
|
|
42
|
+
const model = await context.container.resolve(FolderModelProvider).get();
|
|
43
43
|
const generator = context.container.resolve(ValuesSelectionGenerator);
|
|
44
44
|
return {
|
|
45
45
|
...model,
|
package/folder/folder.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 { 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,OAAO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tB,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;gBACj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