@webiny/api-aco 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.e9333b3f0b
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.d.ts +5 -0
- package/AcoFeature.js +132 -0
- package/AcoFeature.js.map +1 -0
- package/AcoFolderSchemaFactory.d.ts +32 -0
- package/AcoFolderSchemaFactory.js +82 -0
- package/AcoFolderSchemaFactory.js.map +1 -0
- package/constants.js +2 -1
- package/constants.js.map +1 -1
- package/createAcoGraphQL.d.ts +8 -4
- package/createAcoGraphQL.js +56 -97
- package/createAcoGraphQL.js.map +1 -1
- package/domain/folder/abstractions.d.ts +12 -5
- package/domain/folder/abstractions.js +2 -5
- package/domain/folder/abstractions.js.map +1 -1
- package/domain/folder/errors.js +42 -47
- package/domain/folder/errors.js.map +1 -1
- package/domain/folder/folder.model.js +53 -36
- package/domain/folder/folder.model.js.map +1 -1
- package/exports/api/aco/flp.d.ts +1 -0
- package/exports/api/aco/flp.js +1 -2
- package/exports/api/aco/folder.d.ts +2 -1
- package/exports/api/aco/folder.js +5 -7
- package/features/ai/CreateFolderTool.d.ts +51 -0
- package/features/ai/CreateFolderTool.js +65 -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 +50 -0
- package/features/ai/DeleteFolderTool.js +62 -0
- package/features/ai/DeleteFolderTool.js.map +1 -0
- package/features/ai/GrantFolderAccessTool.d.ts +79 -0
- package/features/ai/GrantFolderAccessTool.js +87 -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/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +11 -0
- package/features/ai/NotifyFolderChange/NotifyFolderChangeUseCase.js +37 -0
- package/features/ai/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +1 -0
- package/features/ai/NotifyFolderChange/abstractions.d.ts +20 -0
- package/features/ai/NotifyFolderChange/abstractions.js +8 -0
- package/features/ai/NotifyFolderChange/abstractions.js.map +1 -0
- package/features/ai/NotifyFolderChange/index.d.ts +1 -0
- package/features/ai/NotifyFolderChange/index.js +1 -0
- package/features/ai/RevokeFolderAccessTool.d.ts +65 -0
- package/features/ai/RevokeFolderAccessTool.js +76 -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 +27 -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/CreateEntryRevisionFromWithFlpDecorator.js +27 -31
- package/features/cms/decorators/CreateEntryRevisionFromWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/CreateEntryWithFlpDecorator.js +22 -25
- package/features/cms/decorators/CreateEntryWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/DeleteEntryRevisionWithFlpDecorator.js +27 -31
- package/features/cms/decorators/DeleteEntryRevisionWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/DeleteEntryWithFlpDecorator.js +29 -33
- package/features/cms/decorators/DeleteEntryWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/GetEntryByIdWithFlpDecorator.js +25 -30
- package/features/cms/decorators/GetEntryByIdWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/GetEntryWithFlpDecorator.js +25 -30
- package/features/cms/decorators/GetEntryWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/GetLatestEntriesByIdsWithFlpDecorator.js +31 -35
- package/features/cms/decorators/GetLatestEntriesByIdsWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/GetPublishedEntriesByIdsWithFlpDecorator.js +31 -34
- package/features/cms/decorators/GetPublishedEntriesByIdsWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js +28 -28
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js +28 -27
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js +28 -28
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js +28 -28
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/MoveEntryWithFlpDecorator.d.ts +1 -1
- package/features/cms/decorators/MoveEntryWithFlpDecorator.js +37 -51
- package/features/cms/decorators/MoveEntryWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/UpdateEntryWithFlpDecorator.d.ts +1 -2
- package/features/cms/decorators/UpdateEntryWithFlpDecorator.js +27 -31
- package/features/cms/decorators/UpdateEntryWithFlpDecorator.js.map +1 -1
- package/features/cms/feature.js +19 -25
- package/features/cms/feature.js.map +1 -1
- package/features/cms/index.js +0 -2
- package/features/flp/CreateFlp/CreateFlpUseCase.d.ts +3 -3
- package/features/flp/CreateFlp/CreateFlpUseCase.js +26 -33
- package/features/flp/CreateFlp/CreateFlpUseCase.js.map +1 -1
- package/features/flp/CreateFlp/abstractions.js +2 -5
- package/features/flp/CreateFlp/abstractions.js.map +1 -1
- package/features/flp/CreateFlp/feature.d.ts +1 -6
- package/features/flp/CreateFlp/feature.js +8 -8
- package/features/flp/CreateFlp/feature.js.map +1 -1
- package/features/flp/CreateFlp/index.js +0 -2
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js +27 -27
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js.map +1 -1
- package/features/flp/CreateFlpOnFolderCreated/feature.js +6 -5
- package/features/flp/CreateFlpOnFolderCreated/feature.js.map +1 -1
- package/features/flp/CreateFlpOnFolderCreated/index.js +0 -2
- package/features/flp/DeleteFlp/DeleteFlpUseCase.d.ts +3 -3
- package/features/flp/DeleteFlp/DeleteFlpUseCase.js +17 -18
- package/features/flp/DeleteFlp/DeleteFlpUseCase.js.map +1 -1
- package/features/flp/DeleteFlp/abstractions.js +2 -5
- package/features/flp/DeleteFlp/abstractions.js.map +1 -1
- package/features/flp/DeleteFlp/feature.d.ts +1 -6
- package/features/flp/DeleteFlp/feature.js +8 -8
- package/features/flp/DeleteFlp/feature.js.map +1 -1
- package/features/flp/DeleteFlp/index.js +0 -2
- package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js +27 -27
- package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js.map +1 -1
- package/features/flp/DeleteFlpOnFolderDeleted/feature.js +6 -5
- package/features/flp/DeleteFlpOnFolderDeleted/feature.js.map +1 -1
- package/features/flp/DeleteFlpOnFolderDeleted/index.js +0 -2
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.d.ts +3 -3
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +88 -109
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.d.ts +25 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js +48 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js.map +1 -0
- package/features/flp/FolderLevelPermissions/abstractions.js +2 -2
- package/features/flp/FolderLevelPermissions/abstractions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/feature.js +6 -5
- package/features/flp/FolderLevelPermissions/feature.js.map +1 -1
- package/features/flp/FolderLevelPermissions/index.d.ts +1 -0
- package/features/flp/FolderLevelPermissions/index.js +1 -2
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolder/CanAccessFolder.js +14 -36
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolder/CanAccessFolder.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolder/ICanAccessFolder.js +0 -3
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolder/index.js +0 -2
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolderContent/CanAccessFolderContent.js +12 -29
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolderContent/CanAccessFolderContent.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolderContent/ICanAccessFolderContent.js +0 -3
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolderContent/index.js +0 -2
- package/features/flp/FolderLevelPermissions/useCases/CanCreateFolderInRoot/CanCreateFolderInRoot.js +5 -4
- package/features/flp/FolderLevelPermissions/useCases/CanCreateFolderInRoot/CanCreateFolderInRoot.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/CanCreateFolderInRoot/ICanCreateFolderInRoot.js +0 -3
- package/features/flp/FolderLevelPermissions/useCases/CanCreateFolderInRoot/index.js +0 -2
- package/features/flp/FolderLevelPermissions/useCases/CheckNotInheritedPermissions/CheckNotInheritedPermissions.js +5 -4
- package/features/flp/FolderLevelPermissions/useCases/CheckNotInheritedPermissions/CheckNotInheritedPermissions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/CheckNotInheritedPermissions/ICheckNotInheritedPermissions.js +0 -3
- package/features/flp/FolderLevelPermissions/useCases/CheckNotInheritedPermissions/index.js +0 -2
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/DefaultPermissionsMerger.js +43 -66
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/DefaultPermissionsMerger.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissions.js +10 -9
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js +22 -33
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/IGetDefaultPermissions.js +0 -3
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/index.js +0 -2
- package/features/flp/FolderLevelPermissions/useCases/index.js +0 -2
- package/features/flp/GetFlp/GetFlpUseCase.js +8 -7
- package/features/flp/GetFlp/GetFlpUseCase.js.map +1 -1
- package/features/flp/GetFlp/abstractions.js +2 -2
- package/features/flp/GetFlp/abstractions.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.d.ts +1 -1
- package/features/flp/GetFlp/feature.js +8 -8
- package/features/flp/GetFlp/feature.js.map +1 -1
- package/features/flp/GetFlp/index.js +0 -2
- package/features/flp/ListFlps/ListFlpsUseCase.js +8 -7
- package/features/flp/ListFlps/ListFlpsUseCase.js.map +1 -1
- package/features/flp/ListFlps/abstractions.js +2 -2
- 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.d.ts +1 -1
- package/features/flp/ListFlps/feature.js +8 -8
- package/features/flp/ListFlps/feature.js.map +1 -1
- package/features/flp/ListFlps/index.js +0 -2
- package/features/flp/UpdateFlp/UpdateFlpUseCase.d.ts +15 -8
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js +130 -186
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
- package/features/flp/UpdateFlp/abstractions.d.ts +6 -2
- package/features/flp/UpdateFlp/abstractions.js +2 -5
- package/features/flp/UpdateFlp/abstractions.js.map +1 -1
- package/features/flp/UpdateFlp/feature.d.ts +1 -6
- package/features/flp/UpdateFlp/feature.js +12 -8
- package/features/flp/UpdateFlp/feature.js.map +1 -1
- package/features/flp/UpdateFlp/index.js +0 -2
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js +29 -29
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js.map +1 -1
- package/features/flp/UpdateFlpOnFolderUpdated/feature.js +6 -5
- package/features/flp/UpdateFlpOnFolderUpdated/feature.js.map +1 -1
- package/features/flp/UpdateFlpOnFolderUpdated/index.js +0 -2
- 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 +14 -0
- package/features/flp/shared/CodeFlpsProvider.js +33 -0
- package/features/flp/shared/CodeFlpsProvider.js.map +1 -0
- package/features/flp/shared/abstractions.d.ts +77 -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 +71 -91
- package/features/folder/CreateFolder/CreateFolderRepository.js.map +1 -1
- package/features/folder/CreateFolder/CreateFolderUseCase.js +27 -30
- package/features/folder/CreateFolder/CreateFolderUseCase.js.map +1 -1
- package/features/folder/CreateFolder/abstractions.js +5 -22
- package/features/folder/CreateFolder/abstractions.js.map +1 -1
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.d.ts +9 -1
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js +45 -33
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/CreateFolder/events.js +16 -14
- package/features/folder/CreateFolder/events.js.map +1 -1
- package/features/folder/CreateFolder/feature.js +8 -7
- package/features/folder/CreateFolder/feature.js.map +1 -1
- package/features/folder/CreateFolder/index.js +1 -3
- package/features/folder/DeleteFolder/DeleteFolderRepository.d.ts +3 -3
- package/features/folder/DeleteFolder/DeleteFolderRepository.js +24 -21
- package/features/folder/DeleteFolder/DeleteFolderRepository.js.map +1 -1
- package/features/folder/DeleteFolder/DeleteFolderUseCase.js +35 -43
- package/features/folder/DeleteFolder/DeleteFolderUseCase.js.map +1 -1
- package/features/folder/DeleteFolder/abstractions.js +5 -22
- package/features/folder/DeleteFolder/abstractions.js.map +1 -1
- package/features/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.d.ts +1 -1
- package/features/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.js +21 -20
- package/features/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/DeleteFolder/events.js +16 -14
- package/features/folder/DeleteFolder/events.js.map +1 -1
- package/features/folder/DeleteFolder/feature.js +8 -7
- package/features/folder/DeleteFolder/feature.js.map +1 -1
- package/features/folder/DeleteFolder/index.js +1 -3
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +47 -44
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
- package/features/folder/EnsureFolderIsEmpty/abstractions.js +2 -2
- package/features/folder/EnsureFolderIsEmpty/abstractions.js.map +1 -1
- package/features/folder/EnsureFolderIsEmpty/feature.js +6 -5
- package/features/folder/EnsureFolderIsEmpty/feature.js.map +1 -1
- package/features/folder/EnsureFolderIsEmpty/index.js +0 -2
- package/features/folder/EnsureFolderIsEmptyOnDelete/GenericFolderBeforeDeleteHandler.js +16 -20
- package/features/folder/EnsureFolderIsEmptyOnDelete/GenericFolderBeforeDeleteHandler.js.map +1 -1
- package/features/folder/EnsureFolderIsEmptyOnDelete/feature.js +6 -12
- package/features/folder/EnsureFolderIsEmptyOnDelete/feature.js.map +1 -1
- package/features/folder/EnsureFolderIsEmptyOnDelete/index.js +0 -2
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js +40 -44
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js.map +1 -1
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/feature.js +6 -5
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/feature.js.map +1 -1
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js +0 -2
- 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 +47 -76
- package/features/folder/GetAncestors/GetAncestorsRepository.js.map +1 -1
- package/features/folder/GetAncestors/GetAncestorsUseCase.js +14 -11
- package/features/folder/GetAncestors/GetAncestorsUseCase.js.map +1 -1
- package/features/folder/GetAncestors/abstractions.js +3 -14
- package/features/folder/GetAncestors/abstractions.js.map +1 -1
- package/features/folder/GetAncestors/feature.js +7 -6
- package/features/folder/GetAncestors/feature.js.map +1 -1
- package/features/folder/GetAncestors/index.js +0 -2
- package/features/folder/GetFolder/GetFolderRepository.d.ts +3 -3
- package/features/folder/GetFolder/GetFolderRepository.js +23 -20
- package/features/folder/GetFolder/GetFolderRepository.js.map +1 -1
- package/features/folder/GetFolder/GetFolderUseCase.js +14 -11
- package/features/folder/GetFolder/GetFolderUseCase.js.map +1 -1
- package/features/folder/GetFolder/abstractions.js +5 -21
- package/features/folder/GetFolder/abstractions.js.map +1 -1
- package/features/folder/GetFolder/decorators/GetFolderWithFolderLevelPermissions.d.ts +8 -8
- package/features/folder/GetFolder/decorators/GetFolderWithFolderLevelPermissions.js +23 -26
- package/features/folder/GetFolder/decorators/GetFolderWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/GetFolder/feature.js +8 -7
- package/features/folder/GetFolder/feature.js.map +1 -1
- package/features/folder/GetFolder/index.js +0 -2
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.d.ts +3 -3
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js +70 -87
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js.map +1 -1
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyUseCase.js +14 -11
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyUseCase.js.map +1 -1
- package/features/folder/GetFolderHierarchy/abstractions.js +3 -14
- package/features/folder/GetFolderHierarchy/abstractions.js.map +1 -1
- package/features/folder/GetFolderHierarchy/decorators/GetFolderHierarchyWithFolderLevelPermissions.js +55 -56
- package/features/folder/GetFolderHierarchy/decorators/GetFolderHierarchyWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/GetFolderHierarchy/feature.js +8 -7
- package/features/folder/GetFolderHierarchy/feature.js.map +1 -1
- package/features/folder/GetFolderHierarchy/index.js +0 -2
- package/features/folder/ListFolderLevelPermissionsTargets/ListFolderLevelPermissionsTargetsUseCase.js +65 -58
- package/features/folder/ListFolderLevelPermissionsTargets/ListFolderLevelPermissionsTargetsUseCase.js.map +1 -1
- package/features/folder/ListFolderLevelPermissionsTargets/abstractions.js +2 -5
- package/features/folder/ListFolderLevelPermissionsTargets/abstractions.js.map +1 -1
- package/features/folder/ListFolderLevelPermissionsTargets/feature.js +6 -5
- package/features/folder/ListFolderLevelPermissionsTargets/feature.js.map +1 -1
- package/features/folder/ListFolderLevelPermissionsTargets/index.js +0 -2
- package/features/folder/ListFolders/ListFoldersRepository.d.ts +3 -3
- package/features/folder/ListFolders/ListFoldersRepository.js +41 -42
- package/features/folder/ListFolders/ListFoldersRepository.js.map +1 -1
- package/features/folder/ListFolders/ListFoldersUseCase.js +14 -11
- package/features/folder/ListFolders/ListFoldersUseCase.js.map +1 -1
- package/features/folder/ListFolders/abstractions.js +3 -14
- package/features/folder/ListFolders/abstractions.js.map +1 -1
- package/features/folder/ListFolders/decorators/ListFoldersWithFolderLevelPermissions.js +55 -67
- package/features/folder/ListFolders/decorators/ListFoldersWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/ListFolders/feature.js +8 -7
- package/features/folder/ListFolders/feature.js.map +1 -1
- package/features/folder/ListFolders/index.js +0 -2
- package/features/folder/UpdateFolder/UpdateFolderRepository.d.ts +3 -3
- package/features/folder/UpdateFolder/UpdateFolderRepository.js +70 -93
- package/features/folder/UpdateFolder/UpdateFolderRepository.js.map +1 -1
- package/features/folder/UpdateFolder/UpdateFolderUseCase.js +38 -45
- package/features/folder/UpdateFolder/UpdateFolderUseCase.js.map +1 -1
- package/features/folder/UpdateFolder/abstractions.js +5 -22
- package/features/folder/UpdateFolder/abstractions.js.map +1 -1
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.d.ts +14 -1
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js +91 -62
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/UpdateFolder/events.js +16 -14
- package/features/folder/UpdateFolder/events.js.map +1 -1
- package/features/folder/UpdateFolder/feature.js +8 -7
- package/features/folder/UpdateFolder/feature.js.map +1 -1
- package/features/folder/UpdateFolder/index.js +0 -2
- package/features/folder/shared/EntryToFolderMapper.js +20 -19
- package/features/folder/shared/EntryToFolderMapper.js.map +1 -1
- package/features/folder/shared/abstractions.d.ts +14 -0
- package/features/folder/shared/abstractions.js +5 -2
- package/features/folder/shared/abstractions.js.map +1 -1
- package/filter/filter.crud.js +28 -31
- package/filter/filter.crud.js.map +1 -1
- package/filter/filter.gql.d.ts +2 -3
- package/filter/filter.gql.js +72 -54
- package/filter/filter.gql.js.map +1 -1
- package/filter/filter.model.js +45 -35
- package/filter/filter.model.js.map +1 -1
- package/filter/filter.so.d.ts +8 -2
- package/filter/filter.so.js +85 -93
- package/filter/filter.so.js.map +1 -1
- package/filter/filter.types.js +5 -4
- package/filter/filter.types.js.map +1 -1
- package/flp/flp.crud.js +69 -86
- package/flp/flp.crud.js.map +1 -1
- package/flp/flp.types.d.ts +2 -1
- package/flp/flp.types.js +0 -3
- package/flp/index.d.ts +0 -1
- package/flp/index.js +0 -3
- package/flp/tasks/createFlp.task.d.ts +14 -8
- package/flp/tasks/createFlp.task.js +37 -28
- package/flp/tasks/createFlp.task.js.map +1 -1
- package/flp/tasks/deleteFlp.task.d.ts +14 -8
- package/flp/tasks/deleteFlp.task.js +37 -28
- package/flp/tasks/deleteFlp.task.js.map +1 -1
- package/flp/tasks/index.d.ts +0 -1
- package/flp/tasks/index.js +5 -17
- package/flp/tasks/index.js.map +1 -1
- package/flp/tasks/syncFlp.task.d.ts +14 -8
- package/flp/tasks/syncFlp.task.js +107 -114
- package/flp/tasks/syncFlp.task.js.map +1 -1
- package/flp/tasks/updateFlp.task.d.ts +14 -8
- package/flp/tasks/updateFlp.task.js +48 -33
- package/flp/tasks/updateFlp.task.js.map +1 -1
- package/folder/createFolderModelModifier.js +50 -50
- package/folder/createFolderModelModifier.js.map +1 -1
- package/folder/createFolderTypeDefs.js +43 -51
- package/folder/createFolderTypeDefs.js.map +1 -1
- package/folder/folder.gql.d.ts +1 -1
- package/folder/folder.gql.js +109 -136
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.types.js +0 -3
- package/index.d.ts +1 -6
- package/index.js +2 -9
- package/package.json +30 -29
- package/types.d.ts +1 -1
- package/types.js +5 -4
- package/types.js.map +1 -1
- package/utils/FoldersCacheFactory.js +20 -19
- package/utils/FoldersCacheFactory.js.map +1 -1
- package/utils/ListCache.js +20 -19
- package/utils/ListCache.js.map +1 -1
- package/utils/Path.js +5 -6
- package/utils/Path.js.map +1 -1
- package/utils/compress.js +8 -7
- package/utils/compress.js.map +1 -1
- package/utils/createListSort.js +4 -7
- package/utils/createListSort.js.map +1 -1
- package/utils/createOperationsWrapper.d.ts +5 -2
- package/utils/createOperationsWrapper.js +12 -19
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.js +169 -196
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
- package/utils/decorators/FilterEntriesByFolderFactory.js +18 -19
- package/utils/decorators/FilterEntriesByFolderFactory.js.map +1 -1
- package/utils/decorators/ListEntriesFactory.js +65 -98
- package/utils/decorators/ListEntriesFactory.js.map +1 -1
- package/utils/decorators/hasRootFolderId.js +6 -12
- package/utils/decorators/hasRootFolderId.js.map +1 -1
- package/utils/decorators/isPageModel.js +5 -10
- package/utils/decorators/isPageModel.js.map +1 -1
- package/utils/ensureAuthentication.js +6 -7
- package/utils/ensureAuthentication.js.map +1 -1
- package/utils/pickEntryFieldValues.js +24 -18
- package/utils/pickEntryFieldValues.js.map +1 -1
- package/utils/resolve.d.ts +2 -2
- package/utils/resolve.js +8 -7
- package/utils/resolve.js.map +1 -1
- package/createAcoContext.d.ts +0 -9
- package/createAcoContext.js +0 -137
- package/createAcoContext.js.map +0 -1
- package/createAcoStorageOperations.d.ts +0 -12
- package/createAcoStorageOperations.js +0 -10
- package/createAcoStorageOperations.js.map +0 -1
- package/createAcoTasks.d.ts +0 -1
- package/createAcoTasks.js +0 -15
- package/createAcoTasks.js.map +0 -1
- package/exports/api/aco/flp.js.map +0 -1
- package/exports/api/aco/folder.js.map +0 -1
- package/features/cms/index.js.map +0 -1
- package/features/flp/CreateFlp/index.js.map +0 -1
- package/features/flp/CreateFlpOnFolderCreated/index.js.map +0 -1
- package/features/flp/DeleteFlp/index.js.map +0 -1
- package/features/flp/DeleteFlpOnFolderDeleted/index.js.map +0 -1
- package/features/flp/FolderLevelPermissions/index.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolder/ICanAccessFolder.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolder/index.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolderContent/ICanAccessFolderContent.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CanAccessFolderContent/index.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CanCreateFolderInRoot/ICanCreateFolderInRoot.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CanCreateFolderInRoot/index.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CheckNotInheritedPermissions/ICheckNotInheritedPermissions.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/CheckNotInheritedPermissions/index.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/IGetDefaultPermissions.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/index.js.map +0 -1
- package/features/flp/FolderLevelPermissions/useCases/index.js.map +0 -1
- package/features/flp/GetFlp/index.js.map +0 -1
- package/features/flp/ListFlps/index.js.map +0 -1
- package/features/flp/UpdateFlp/index.js.map +0 -1
- package/features/flp/UpdateFlpOnFolderUpdated/index.js.map +0 -1
- package/features/folder/CreateFolder/index.js.map +0 -1
- package/features/folder/DeleteFolder/index.js.map +0 -1
- package/features/folder/EnsureFolderIsEmpty/index.js.map +0 -1
- package/features/folder/EnsureFolderIsEmptyOnDelete/index.js.map +0 -1
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js.map +0 -1
- package/features/folder/GetAncestors/index.js.map +0 -1
- package/features/folder/GetFolder/index.js.map +0 -1
- package/features/folder/GetFolderHierarchy/index.js.map +0 -1
- package/features/folder/ListFolderLevelPermissionsTargets/index.js.map +0 -1
- package/features/folder/ListFolders/index.js.map +0 -1
- package/features/folder/UpdateFolder/index.js.map +0 -1
- package/flp/flp.so.d.ts +0 -20
- package/flp/flp.so.js +0 -220
- package/flp/flp.so.js.map +0 -1
- package/flp/flp.types.js.map +0 -1
- package/flp/index.js.map +0 -1
- package/folder/folder.types.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/ListFlps/feature.js","sources":["../../../../src/features/flp/ListFlps/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListFlpsUseCase } from \"./ListFlpsUseCase.js\";\nimport { ListFlpsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\n\nexport const ListFlpsFeature = createFeature({\n name: \"ListFlpsFeature\",\n register(container) {\n container.registerFactory(UseCaseAbstraction, () => {\n return new ListFlpsUseCase(container.resolve(AcoFlpCrud).list);\n });\n }\n});\n"],"names":["ListFlpsFeature","createFeature","container","UseCaseAbstraction","ListFlpsUseCase","AcoFlpCrud"],"mappings":";;;;AAKO,MAAMA,kBAAkBC,cAAc;IACzC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,eAAe,CAACC,0CAAoB,IACnC,IAAIC,gBAAgBF,UAAU,OAAO,CAACG,YAAY,IAAI;IAErE;AACJ"}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import type { UpdateFlpParams, UpdateFlpUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AcoFlpCrud } from "../../../features/folder/shared/abstractions.js";
|
|
3
|
+
import type { ListFoldersUseCase } from "../../../features/folder/ListFolders/index.js";
|
|
4
|
+
import type { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
5
|
+
import type { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js";
|
|
6
|
+
import type { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
3
7
|
export declare class UpdateFlpUseCase implements UseCaseAbstraction.Interface {
|
|
4
|
-
private
|
|
8
|
+
private flpCrud;
|
|
9
|
+
private listFoldersUseCase;
|
|
10
|
+
private folderModelProvider;
|
|
11
|
+
private updateEntryUseCase;
|
|
12
|
+
private identityContext;
|
|
5
13
|
private isCloseToTimeout?;
|
|
6
14
|
private handleTimeout?;
|
|
7
|
-
private readonly
|
|
15
|
+
private readonly completed;
|
|
8
16
|
private readonly flpsToUpdate;
|
|
9
|
-
|
|
17
|
+
private timedOut;
|
|
18
|
+
private completedThisRun;
|
|
19
|
+
constructor(flpCrud: AcoFlpCrud.Interface, listFoldersUseCase: ListFoldersUseCase.Interface, folderModelProvider: FolderModelProvider.Interface, updateEntryUseCase: UpdateEntryUseCase.Interface, identityContext: IdentityContext.Interface);
|
|
10
20
|
execute(params: UpdateFlpParams): Promise<void>;
|
|
11
21
|
private collectBranchForUpdate;
|
|
22
|
+
private stopForTimeout;
|
|
12
23
|
private executeBatchUpdate;
|
|
13
|
-
private getQueuedList;
|
|
14
|
-
private setQueued;
|
|
15
|
-
private isQueued;
|
|
16
|
-
private clearQueuedList;
|
|
17
24
|
private listDirectChildren;
|
|
18
25
|
private getFlp;
|
|
19
26
|
}
|
|
@@ -1,203 +1,147 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
2
|
import { Path } from "../../../utils/Path.js";
|
|
3
3
|
import { Permissions, ROOT_FOLDER } from "@webiny/shared-aco";
|
|
4
|
-
import { ListFoldersUseCase } from "../../folder/ListFolders/index.js";
|
|
5
|
-
import { FolderModel } from "../../../domain/folder/abstractions.js";
|
|
6
4
|
import { EntryId } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
class UpdateFlpUseCase {
|
|
6
|
+
constructor(flpCrud, listFoldersUseCase, folderModelProvider, updateEntryUseCase, identityContext){
|
|
7
|
+
this.flpCrud = flpCrud;
|
|
8
|
+
this.listFoldersUseCase = listFoldersUseCase;
|
|
9
|
+
this.folderModelProvider = folderModelProvider;
|
|
10
|
+
this.updateEntryUseCase = updateEntryUseCase;
|
|
11
|
+
this.identityContext = identityContext;
|
|
12
|
+
this.completed = new Set();
|
|
13
|
+
this.flpsToUpdate = new Map();
|
|
14
|
+
this.timedOut = false;
|
|
15
|
+
this.completedThisRun = 0;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
17
|
+
async execute(params) {
|
|
18
|
+
this.isCloseToTimeout = params.isCloseToTimeout;
|
|
19
|
+
this.handleTimeout = params.handleTimeout;
|
|
20
|
+
this.completed.clear();
|
|
21
|
+
this.timedOut = false;
|
|
22
|
+
this.completedThisRun = 0;
|
|
23
|
+
if (params.completed) params.completed.forEach((id)=>this.completed.add(id));
|
|
24
|
+
try {
|
|
25
|
+
const { folder } = params;
|
|
26
|
+
if (!folder) throw new WebinyError("Missing `folder`, I can't update the FLP record.", "ERROR_UPDATING_FLP_USE_CASE_FOLDER_NOT_PROVIDED", {
|
|
27
|
+
folder
|
|
28
|
+
});
|
|
29
|
+
const flp = await this.getFlp(folder);
|
|
30
|
+
const parentFlp = folder.parentId ? await this.flpCrud.get(folder.parentId) : null;
|
|
31
|
+
this.flpsToUpdate.set(folder.id, {
|
|
32
|
+
slug: folder.slug,
|
|
33
|
+
parentId: folder.parentId ?? ROOT_FOLDER,
|
|
34
|
+
path: Path.create(folder.slug, parentFlp?.path),
|
|
35
|
+
permissions: Permissions.create(folder.permissions, parentFlp)
|
|
36
|
+
});
|
|
37
|
+
const directChildren = await this.listDirectChildren(flp);
|
|
38
|
+
for (const child of directChildren){
|
|
39
|
+
await this.collectBranchForUpdate(child, flp);
|
|
40
|
+
if (this.timedOut) return;
|
|
41
|
+
}
|
|
42
|
+
await this.executeBatchUpdate();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
this.flpsToUpdate.clear();
|
|
45
|
+
this.completed.clear();
|
|
46
|
+
throw WebinyError.from(error, {
|
|
47
|
+
message: "Error while updating FLP",
|
|
48
|
+
code: "ERROR_UPDATING_FLP_USE_CASE"
|
|
49
|
+
});
|
|
49
50
|
}
|
|
50
|
-
await this.collectBranchForUpdate(child, flp);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Execute batch update
|
|
54
|
-
await this.executeBatchUpdate();
|
|
55
|
-
} catch (error) {
|
|
56
|
-
// Clear the update collection in case of error
|
|
57
|
-
this.flpsToUpdate.clear();
|
|
58
|
-
this.queued.clear();
|
|
59
|
-
throw WebinyError.from(error, {
|
|
60
|
-
message: "Error while updating FLP",
|
|
61
|
-
code: "ERROR_UPDATING_FLP_USE_CASE"
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async collectBranchForUpdate(flp, parentFlp) {
|
|
66
|
-
if (this.isQueued(flp.id)) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Get the parent's permissions from the update collection if available
|
|
71
|
-
const parentFlpData = this.flpsToUpdate.get(parentFlp.id);
|
|
72
|
-
const currentParentFlp = {
|
|
73
|
-
...parentFlp,
|
|
74
|
-
...(parentFlpData && {
|
|
75
|
-
...parentFlpData
|
|
76
|
-
})
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// Add the FLP to the update collection with inherited permissions
|
|
80
|
-
this.flpsToUpdate.set(flp.id, {
|
|
81
|
-
slug: flp.slug,
|
|
82
|
-
parentId: flp.parentId,
|
|
83
|
-
path: Path.create(flp.slug, currentParentFlp.path),
|
|
84
|
-
permissions: Permissions.create(flp.permissions, currentParentFlp)
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Add the FLP to the queue list so we don't fetch it again
|
|
88
|
-
this.setQueued(flp.id);
|
|
89
|
-
|
|
90
|
-
// Process all children of this folder before moving to siblings
|
|
91
|
-
const children = await this.listDirectChildren(flp);
|
|
92
|
-
for (const child of children) {
|
|
93
|
-
if (this.isCloseToTimeout?.()) {
|
|
94
|
-
await this.executeBatchUpdate();
|
|
95
|
-
this.handleTimeout?.(this.getQueuedList());
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
// Pass the current FLP as the parent for the child
|
|
99
|
-
await this.collectBranchForUpdate(child, flp);
|
|
100
51
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
id,
|
|
112
|
-
data: {
|
|
113
|
-
slug,
|
|
114
|
-
parentId,
|
|
115
|
-
path,
|
|
116
|
-
permissions
|
|
117
|
-
}
|
|
52
|
+
async collectBranchForUpdate(flp, parentFlp) {
|
|
53
|
+
if (this.completed.has(flp.id)) return;
|
|
54
|
+
if (this.isCloseToTimeout?.()) return void await this.stopForTimeout();
|
|
55
|
+
const parentFlpData = this.flpsToUpdate.get(parentFlp.id);
|
|
56
|
+
const currentParentFlp = {
|
|
57
|
+
...parentFlp,
|
|
58
|
+
...parentFlpData && {
|
|
59
|
+
...parentFlpData
|
|
60
|
+
}
|
|
118
61
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (const item of items) {
|
|
125
|
-
const {
|
|
126
|
-
id,
|
|
127
|
-
data
|
|
128
|
-
} = item;
|
|
129
|
-
// Directly update the folder in CMS storage to bypass any folder update event triggers.
|
|
130
|
-
const entryId = EntryId.from(id);
|
|
131
|
-
await this.context.cms.updateEntry(folderModel, entryId.toString(), {
|
|
132
|
-
values: {
|
|
133
|
-
path: data.path
|
|
134
|
-
}
|
|
62
|
+
this.flpsToUpdate.set(flp.id, {
|
|
63
|
+
slug: flp.slug,
|
|
64
|
+
parentId: flp.parentId,
|
|
65
|
+
path: Path.create(flp.slug, currentParentFlp.path),
|
|
66
|
+
permissions: Permissions.create(flp.permissions, currentParentFlp)
|
|
135
67
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
code: "BATCH_UPDATE_FLP_ERROR",
|
|
141
|
-
data: {
|
|
142
|
-
items: Array.from(this.flpsToUpdate.keys())
|
|
68
|
+
const children = await this.listDirectChildren(flp);
|
|
69
|
+
for (const child of children){
|
|
70
|
+
await this.collectBranchForUpdate(child, flp);
|
|
71
|
+
if (this.timedOut) return;
|
|
143
72
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.flpsToUpdate.clear();
|
|
148
|
-
|
|
149
|
-
//Let's remove all the updated FLPs ids from the queue cache
|
|
150
|
-
this.clearQueuedList();
|
|
73
|
+
for (const child of children)this.completed.delete(child.id);
|
|
74
|
+
this.completed.add(flp.id);
|
|
75
|
+
this.completedThisRun++;
|
|
151
76
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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);
|
|
83
|
+
}
|
|
84
|
+
async executeBatchUpdate() {
|
|
85
|
+
const folderModel = await this.folderModelProvider.get();
|
|
86
|
+
try {
|
|
87
|
+
const items = Array.from(this.flpsToUpdate.entries()).map(([id, { slug, parentId, path, permissions }])=>({
|
|
88
|
+
id,
|
|
89
|
+
data: {
|
|
90
|
+
slug,
|
|
91
|
+
parentId,
|
|
92
|
+
path,
|
|
93
|
+
permissions
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
await this.flpCrud.batchUpdate(items);
|
|
97
|
+
for (const item of items){
|
|
98
|
+
const { id, data } = item;
|
|
99
|
+
const entryId = EntryId.from(id);
|
|
100
|
+
const updateResult = await this.updateEntryUseCase.execute(folderModel, entryId.toString(), {
|
|
101
|
+
values: {
|
|
102
|
+
path: data.path
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
if (updateResult.isFail()) throw updateResult.error;
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
throw WebinyError.from(error, {
|
|
109
|
+
message: "Error while executing batch update of FLPs",
|
|
110
|
+
code: "BATCH_UPDATE_FLP_ERROR",
|
|
111
|
+
data: {
|
|
112
|
+
items: Array.from(this.flpsToUpdate.keys())
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
} finally{
|
|
116
|
+
this.flpsToUpdate.clear();
|
|
172
117
|
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
if (result.isFail()) {
|
|
176
|
-
throw result.error;
|
|
177
118
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
119
|
+
async listDirectChildren(flp) {
|
|
120
|
+
const result = await this.identityContext.withoutAuthorization(()=>this.listFoldersUseCase.execute({
|
|
121
|
+
where: {
|
|
122
|
+
type: flp.type,
|
|
123
|
+
parentId: flp.id
|
|
124
|
+
}
|
|
125
|
+
}));
|
|
126
|
+
if (result.isFail()) throw result.error;
|
|
127
|
+
return await Promise.all(result.value.folders.map((folder)=>this.getFlp(folder)));
|
|
128
|
+
}
|
|
129
|
+
async getFlp({ id, type, parentId, slug, permissions }) {
|
|
130
|
+
const flp = await this.flpCrud.get(id);
|
|
131
|
+
if (!flp) {
|
|
132
|
+
const parentFlp = parentId ? await this.flpCrud.get(parentId) : null;
|
|
133
|
+
return await this.flpCrud.create({
|
|
134
|
+
id,
|
|
135
|
+
type,
|
|
136
|
+
slug,
|
|
137
|
+
parentId: parentId ?? ROOT_FOLDER,
|
|
138
|
+
path: Path.create(slug, parentFlp?.path),
|
|
139
|
+
permissions: Permissions.create(permissions, parentFlp)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return flp;
|
|
198
143
|
}
|
|
199
|
-
return flp;
|
|
200
|
-
}
|
|
201
144
|
}
|
|
145
|
+
export { UpdateFlpUseCase };
|
|
202
146
|
|
|
203
147
|
//# sourceMappingURL=UpdateFlpUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","Path","Permissions","ROOT_FOLDER","ListFoldersUseCase","FolderModel","EntryId","UpdateFlpUseCase","queued","Set","flpsToUpdate","Map","constructor","context","execute","params","isCloseToTimeout","handleTimeout","forEach","id","add","folder","flp","getFlp","parentFlp","parentId","aco","get","set","slug","path","create","permissions","setQueued","directChildren","listDirectChildren","child","executeBatchUpdate","getQueuedList","collectBranchForUpdate","error","clear","from","message","code","isQueued","parentFlpData","currentParentFlp","children","items","Array","entries","map","data","batchUpdate","folderModel","container","resolve","item","entryId","cms","updateEntry","toString","values","keys","clearQueuedList","has","listFolders","result","security","withoutAuthorization","where","type","isFail","Promise","all","value","folders"],"sources":["UpdateFlpUseCase.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { Path } from \"~/utils/Path.js\";\nimport { Permissions, ROOT_FOLDER } from \"@webiny/shared-aco\";\nimport type { UpdateFlpParams, UpdateFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { AcoContext, Folder, FolderLevelPermission, FolderPermission } from \"~/types.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/index.js\";\nimport { FolderModel } from \"~/domain/folder/abstractions.js\";\nimport { EntryId } from \"@webiny/api-headless-cms/exports/api/cms/entry.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 context: AcoContext;\n private isCloseToTimeout?: () => boolean;\n private handleTimeout?: (updated: string[]) => void;\n\n private readonly queued: Set<string> = new Set();\n private readonly flpsToUpdate: Map<string, FlpUpdateData> = new Map();\n\n constructor(context: AcoContext) {\n this.context = context;\n }\n\n async execute(params: UpdateFlpParams): Promise<void> {\n this.isCloseToTimeout = params.isCloseToTimeout;\n this.handleTimeout = params.handleTimeout;\n\n if (params.queued) {\n params.queued.forEach(id => this.queued.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\n ? await this.context.aco.flp.get(folder.parentId)\n : 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 // Let's set the FLP as in queue\n this.setQueued(flp.id);\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 if (this.isCloseToTimeout?.()) {\n await this.executeBatchUpdate();\n this.handleTimeout?.(this.getQueuedList());\n return;\n }\n await this.collectBranchForUpdate(child, flp);\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.queued.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.isQueued(flp.id)) {\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 // Add the FLP to the queue list so we don't fetch it again\n this.setQueued(flp.id);\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 if (this.isCloseToTimeout?.()) {\n await this.executeBatchUpdate();\n this.handleTimeout?.(this.getQueuedList());\n return;\n }\n // Pass the current FLP as the parent for the child\n await this.collectBranchForUpdate(child, flp);\n }\n }\n\n private async executeBatchUpdate(): Promise<void> {\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.context.aco.flp.batchUpdate(items);\n\n // Update all folders with the new path\n const folderModel = this.context.container.resolve(FolderModel);\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 await this.context.cms.updateEntry(folderModel, entryId.toString(), {\n values: {\n path: data.path\n }\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 // Clear the update collection after the batch update\n this.flpsToUpdate.clear();\n\n //Let's remove all the updated FLPs ids from the queue cache\n this.clearQueuedList();\n }\n }\n\n private getQueuedList(): string[] {\n return Array.from(this.queued);\n }\n\n private setQueued(id: string): void {\n this.queued.add(id);\n }\n\n private isQueued(id: string): boolean {\n return this.queued.has(id);\n }\n\n private clearQueuedList(): void {\n this.queued.clear();\n }\n\n private async listDirectChildren(flp: FolderLevelPermission): Promise<FolderLevelPermission[]> {\n const listFolders = this.context.container.resolve(ListFoldersUseCase);\n\n const result = await this.context.security.withoutAuthorization(() => {\n return listFolders.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.context.aco.flp.get(id);\n\n if (!flp) {\n const parentFlp = parentId ? await this.context.aco.flp.get(parentId) : null;\n\n return await this.context.aco.flp.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"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,IAAI;AACb,SAASC,WAAW,EAAEC,WAAW,QAAQ,oBAAoB;AAG7D,SAASC,kBAAkB;AAC3B,SAASC,WAAW;AACpB,SAASC,OAAO,QAAQ,mDAAmD;AAS3E,OAAO,MAAMC,gBAAgB,CAAyC;EAKjDC,MAAM,GAAgB,IAAIC,GAAG,CAAC,CAAC;EAC/BC,YAAY,GAA+B,IAAIC,GAAG,CAAC,CAAC;EAErEC,WAAWA,CAACC,OAAmB,EAAE;IAC7B,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAACC,MAAuB,EAAiB;IAClD,IAAI,CAACC,gBAAgB,GAAGD,MAAM,CAACC,gBAAgB;IAC/C,IAAI,CAACC,aAAa,GAAGF,MAAM,CAACE,aAAa;IAEzC,IAAIF,MAAM,CAACP,MAAM,EAAE;MACfO,MAAM,CAACP,MAAM,CAACU,OAAO,CAACC,EAAE,IAAI,IAAI,CAACX,MAAM,CAACY,GAAG,CAACD,EAAE,CAAC,CAAC;IACpD;IAEA,IAAI;MACA,MAAM;QAAEE;MAAO,CAAC,GAAGN,MAAM;MAEzB,IAAI,CAACM,MAAM,EAAE;QACT,MAAM,IAAIrB,WAAW,CACjB,kDAAkD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CAACF,MAAM,CAAC,CAAC,CAAC;EACrF;EAEA,MAAcE,MAAMA,CAAC;IACjBJ,EAAE;IACFqD,IAAI;IACJ/C,QAAQ;IACRI,IAAI;IACJG;EACI,CAAC,EAAkC;IACvC,MAAMV,GAAG,GAAG,MAAM,IAAI,CAACT,OAAO,CAACa,GAAG,CAACJ,GAAG,CAACK,GAAG,CAACR,EAAE,CAAC;IAE9C,IAAI,CAACG,GAAG,EAAE;MACN,MAAME,SAAS,GAAGC,QAAQ,GAAG,MAAM,IAAI,CAACZ,OAAO,CAACa,GAAG,CAACJ,GAAG,CAACK,GAAG,CAACF,QAAQ,CAAC,GAAG,IAAI;MAE5E,OAAO,MAAM,IAAI,CAACZ,OAAO,CAACa,GAAG,CAACJ,GAAG,CAACS,MAAM,CAAC;QACrCZ,EAAE;QACFqD,IAAI;QACJ3C,IAAI;QACJJ,QAAQ,EAAEA,QAAQ,IAAItB,WAAW;QACjC2B,IAAI,EAAE7B,IAAI,CAAC8B,MAAM,CAACF,IAAI,EAAEL,SAAS,EAAEM,IAAI,CAAC;QACxCE,WAAW,EAAE9B,WAAW,CAAC6B,MAAM,CAACC,WAAW,EAAER,SAAS;MAC1D,CAAC,CAAC;IACN;IAEA,OAAOF,GAAG;EACd;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"features/flp/UpdateFlp/UpdateFlpUseCase.js","sources":["../../../../src/features/flp/UpdateFlp/UpdateFlpUseCase.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { Path } from \"~/utils/Path.js\";\nimport { Permissions, ROOT_FOLDER } from \"@webiny/shared-aco\";\nimport type { UpdateFlpParams, UpdateFlpUseCase as UseCaseAbstraction } from \"./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/index.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":";;;;AAmBO,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,mDACA;gBAAED;YAAO;YAIjB,MAAME,MAAM,MAAM,IAAI,CAAC,MAAM,CAACF;YAC9B,MAAM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Y,MAAM,CAACc,aAAajB;YACjD;QACJ;QAEA,OAAOD;IACX;AACJ"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Folder } from "../../../folder/folder.types.js";
|
|
2
2
|
export interface UpdateFlpParams {
|
|
3
3
|
folder: Folder;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Folders whose whole subtree an earlier run of the same update already wrote. Passed back
|
|
6
|
+
* through `handleTimeout`, so a continued run skips them.
|
|
7
|
+
*/
|
|
8
|
+
completed?: string[];
|
|
5
9
|
isCloseToTimeout?: () => boolean;
|
|
6
|
-
handleTimeout?: (
|
|
10
|
+
handleTimeout?: (completed: string[]) => void;
|
|
7
11
|
}
|
|
8
12
|
export interface IUpdateFlpUseCase {
|
|
9
13
|
execute: (params: UpdateFlpParams) => Promise<void>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** Update a folder-level permission. */
|
|
6
|
-
export const UpdateFlpUseCase = createAbstraction("UpdateFlpUseCase");
|
|
2
|
+
const UpdateFlpUseCase = createAbstraction("UpdateFlpUseCase");
|
|
3
|
+
export { UpdateFlpUseCase };
|
|
7
4
|
|
|
8
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/UpdateFlp/abstractions.js","sources":["../../../../src/features/flp/UpdateFlp/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Folder } from \"~/folder/folder.types.js\";\n\nexport interface UpdateFlpParams {\n folder: Folder;\n /**\n * Folders whose whole subtree an earlier run of the same update already wrote. Passed back\n * through `handleTimeout`, so a continued run skips them.\n */\n completed?: string[];\n isCloseToTimeout?: () => boolean;\n handleTimeout?: (completed: string[]) => void;\n}\n\n// Use Case Abstraction\nexport interface IUpdateFlpUseCase {\n execute: (params: UpdateFlpParams) => Promise<void>;\n}\n\n/** Update a folder-level permission. */\nexport const UpdateFlpUseCase = createAbstraction<IUpdateFlpUseCase>(\"UpdateFlpUseCase\");\n\nexport namespace UpdateFlpUseCase {\n export type Interface = IUpdateFlpUseCase;\n}\n"],"names":["UpdateFlpUseCase","createAbstraction"],"mappings":";AAoBO,MAAMA,mBAAmBC,kBAAqC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Container } from "@webiny/di";
|
|
2
|
-
import type { AcoContext } from "../../../types.js";
|
|
3
|
-
interface LegacyDeps {
|
|
4
|
-
context: AcoContext;
|
|
5
|
-
}
|
|
6
2
|
export declare const UpdateFlpFeature: {
|
|
7
3
|
name: string;
|
|
8
|
-
register(container: Container
|
|
4
|
+
register(container: Container): void;
|
|
9
5
|
};
|
|
10
|
-
export {};
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateFlpUseCase } from "./UpdateFlpUseCase.js";
|
|
3
|
-
import { UpdateFlpUseCase as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { UpdateFlpUseCase as external_abstractions_js_UpdateFlpUseCase } from "./abstractions.js";
|
|
4
|
+
import { AcoFlpCrud } from "../../folder/shared/abstractions.js";
|
|
5
|
+
import { ListFoldersUseCase } from "../../folder/ListFolders/index.js";
|
|
6
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
7
|
+
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js";
|
|
8
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
9
|
+
const UpdateFlpFeature = createFeature({
|
|
10
|
+
name: "UpdateFlp",
|
|
11
|
+
register (container) {
|
|
12
|
+
container.registerFactory(external_abstractions_js_UpdateFlpUseCase, ()=>new UpdateFlpUseCase(container.resolve(AcoFlpCrud), container.resolve(ListFoldersUseCase), container.resolve(FolderModelProvider), container.resolve(UpdateEntryUseCase), container.resolve(IdentityContext)));
|
|
13
|
+
}
|
|
11
14
|
});
|
|
15
|
+
export { UpdateFlpFeature };
|
|
12
16
|
|
|
13
17
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/UpdateFlp/feature.js","sources":["../../../../src/features/flp/UpdateFlp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { UpdateFlpUseCase } from \"./UpdateFlpUseCase.js\";\nimport { UpdateFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/index.js\";\nimport { FolderModelProvider } from \"~/domain/folder/abstractions.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\nexport const UpdateFlpFeature = createFeature({\n name: \"UpdateFlp\",\n register(container: Container) {\n container.registerFactory(UseCaseAbstraction, () => {\n return new UpdateFlpUseCase(\n container.resolve(AcoFlpCrud),\n container.resolve(ListFoldersUseCase),\n container.resolve(FolderModelProvider),\n container.resolve(UpdateEntryUseCase),\n container.resolve(IdentityContext)\n );\n });\n }\n});\n"],"names":["UpdateFlpFeature","createFeature","container","UseCaseAbstraction","UpdateFlpUseCase","AcoFlpCrud","ListFoldersUseCase","FolderModelProvider","UpdateEntryUseCase","IdentityContext"],"mappings":";;;;;;;;AAUO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAoB;QACzBA,UAAU,eAAe,CAACC,2CAAoB,IACnC,IAAIC,iBACPF,UAAU,OAAO,CAACG,aAClBH,UAAU,OAAO,CAACI,qBAClBJ,UAAU,OAAO,CAACK,sBAClBL,UAAU,OAAO,CAACM,qBAClBN,UAAU,OAAO,CAACO;IAG9B;AACJ"}
|
|
@@ -3,37 +3,37 @@ import { UpdateFlpUseCase } from "../UpdateFlp/abstractions.js";
|
|
|
3
3
|
import { UPDATE_FLP_TASK_ID } from "../../../flp/tasks/index.js";
|
|
4
4
|
import { FolderAfterUpdateEventHandler } from "../../folder/UpdateFolder/index.js";
|
|
5
5
|
class UpdateFlpOnFolderUpdatedHandlerImpl {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
await this.updateFlpUseCase.execute({
|
|
24
|
-
folder
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
} catch {
|
|
28
|
-
// Ignore errors
|
|
6
|
+
constructor(updateFlpUseCase, tasks){
|
|
7
|
+
this.updateFlpUseCase = updateFlpUseCase;
|
|
8
|
+
this.tasks = tasks;
|
|
9
|
+
}
|
|
10
|
+
async handle(event) {
|
|
11
|
+
const { folder } = event.payload;
|
|
12
|
+
try {
|
|
13
|
+
if (this.tasks) await this.tasks.trigger({
|
|
14
|
+
definition: UPDATE_FLP_TASK_ID,
|
|
15
|
+
input: {
|
|
16
|
+
folder
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
else await this.updateFlpUseCase.execute({
|
|
20
|
+
folder
|
|
21
|
+
});
|
|
22
|
+
} catch {}
|
|
29
23
|
}
|
|
30
|
-
}
|
|
31
24
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
const UpdateFlpOnFolderUpdatedHandler = FolderAfterUpdateEventHandler.createImplementation({
|
|
26
|
+
implementation: UpdateFlpOnFolderUpdatedHandlerImpl,
|
|
27
|
+
dependencies: [
|
|
28
|
+
UpdateFlpUseCase,
|
|
29
|
+
[
|
|
30
|
+
TaskService,
|
|
31
|
+
{
|
|
32
|
+
optional: true
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
]
|
|
37
36
|
});
|
|
37
|
+
export { UpdateFlpOnFolderUpdatedHandler };
|
|
38
38
|
|
|
39
39
|
//# sourceMappingURL=UpdateFlpOnFolderUpdatedHandler.js.map
|