@webiny/api-aco 6.3.0 → 6.4.0-beta.1
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/constants.js +2 -1
- package/constants.js.map +1 -1
- package/createAcoContext.d.ts +1 -1
- package/createAcoContext.js +75 -103
- package/createAcoContext.js.map +1 -1
- package/createAcoGraphQL.js +42 -43
- package/createAcoGraphQL.js.map +1 -1
- package/createAcoStorageOperations.js +5 -6
- package/createAcoStorageOperations.js.map +1 -1
- package/createAcoTasks.js +7 -8
- package/createAcoTasks.js.map +1 -1
- 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 +52 -36
- package/domain/folder/folder.model.js.map +1 -1
- package/exports/api/aco/flp.js +0 -2
- package/exports/api/aco/folder.js +4 -6
- 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 +27 -28
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js +27 -27
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js +27 -28
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js +27 -28
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js.map +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.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.js +7 -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.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.js +7 -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.js +87 -108
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
- 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.js +0 -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/feature.js +7 -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/feature.js +7 -8
- package/features/flp/ListFlps/feature.js.map +1 -1
- package/features/flp/ListFlps/index.js +0 -2
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js +133 -184
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
- package/features/flp/UpdateFlp/abstractions.js +2 -5
- package/features/flp/UpdateFlp/abstractions.js.map +1 -1
- package/features/flp/UpdateFlp/feature.js +7 -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/folder/CreateFolder/CreateFolderRepository.js +67 -90
- 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.js +29 -34
- 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.js +22 -20
- 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.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 +43 -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 +36 -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/GetAncestors/GetAncestorsRepository.js +45 -75
- 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.js +21 -19
- 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.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.js +67 -86
- 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.js +39 -41
- 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.js +66 -92
- 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.js +45 -64
- 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.js +2 -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.js +32 -48
- package/filter/filter.gql.js.map +1 -1
- package/filter/filter.model.js +44 -35
- package/filter/filter.model.js.map +1 -1
- package/filter/filter.so.js +73 -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.so.js +162 -199
- package/flp/flp.so.js.map +1 -1
- package/flp/flp.types.js +0 -3
- package/flp/index.js +0 -2
- package/flp/tasks/createFlp.task.js +26 -27
- package/flp/tasks/createFlp.task.js.map +1 -1
- package/flp/tasks/deleteFlp.task.js +26 -27
- package/flp/tasks/deleteFlp.task.js.map +1 -1
- package/flp/tasks/index.js +13 -12
- package/flp/tasks/index.js.map +1 -1
- package/flp/tasks/syncFlp.task.js +83 -112
- package/flp/tasks/syncFlp.task.js.map +1 -1
- package/flp/tasks/updateFlp.task.js +33 -32
- 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 +39 -50
- package/folder/createFolderTypeDefs.js.map +1 -1
- package/folder/folder.gql.js +100 -133
- package/folder/folder.gql.js.map +1 -1
- package/folder/folder.types.js +0 -3
- package/index.d.ts +1 -1
- package/index.js +7 -4
- package/index.js.map +1 -1
- package/package.json +25 -25
- 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.js +12 -19
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.js +165 -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.js +7 -6
- package/utils/resolve.js.map +1 -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.types.js.map +0 -1
- package/flp/index.js.map +0 -1
- package/folder/folder.types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js","sources":["../../../../../../src/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.ts"],"sourcesContent":["import type { IGetDefaultPermissions } from \"./IGetDefaultPermissions.js\";\nimport type { FolderPermission } from \"~/flp/flp.types.js\";\nimport type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { ListUserTeamsUseCase } from \"@webiny/api-core/features/users/ListUserTeams/index.js\";\nimport type { Team } from \"@webiny/api-core/types/security.js\";\n\nexport class GetDefaultPermissionsWithTeams implements IGetDefaultPermissions {\n private identityContext: IdentityContext.Interface;\n private listUserTeamsUseCase: ListUserTeamsUseCase.Interface;\n private decoretee: IGetDefaultPermissions;\n\n constructor(\n identityContext: IdentityContext.Interface,\n listUserTeamsUseCase: ListUserTeamsUseCase.Interface,\n decoretee: IGetDefaultPermissions\n ) {\n this.identityContext = identityContext;\n this.listUserTeamsUseCase = listUserTeamsUseCase;\n this.decoretee = decoretee;\n }\n\n async execute(originalPermissions: FolderPermission[]) {\n /**\n * Retrieves the list of teams the current identity belongs to and checks if any of these teams\n * have permissions for the folder. If a team has permissions, the current identity is granted\n * the same permissions, inheriting them from the team.\n */\n const identity = this.identityContext.getIdentity();\n\n // Get teams for current identity\n const listTeamsResult = await this.listUserTeamsUseCase.execute(identity.id);\n const identityTeams: Team[] = listTeamsResult.isOk() ? listTeamsResult.value : [];\n\n const permissions = [...originalPermissions]; // Clone the original permissions to avoid mutation.\n\n if (identity && identityTeams.length) {\n for (const identityTeam of identityTeams) {\n // Check if the team has permissions for the folder.\n const teamPermission = permissions.find(\n p => p.target === `team:${identityTeam.slug}`\n );\n\n if (teamPermission) {\n // Grant the current identity the same permissions as the team, marking them as inherited.\n permissions.push({\n target: `admin:${identity.id}`,\n level: teamPermission.level,\n inheritedFrom: \"team:\" + identityTeam.slug\n });\n }\n }\n }\n\n return await this.decoretee.execute(permissions);\n }\n}\n"],"names":["GetDefaultPermissionsWithTeams","identityContext","listUserTeamsUseCase","decoretee","originalPermissions","identity","listTeamsResult","identityTeams","permissions","identityTeam","teamPermission","p"],"mappings":"AAMO,MAAMA;IAKT,YACIC,eAA0C,EAC1CC,oBAAoD,EACpDC,SAAiC,CACnC;QACE,IAAI,CAAC,eAAe,GAAGF;QACvB,IAAI,CAAC,oBAAoB,GAAGC;QAC5B,IAAI,CAAC,SAAS,GAAGC;IACrB;IAEA,MAAM,QAAQC,mBAAuC,EAAE;QAMnD,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAGjD,MAAMC,kBAAkB,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACD,SAAS,EAAE;QAC3E,MAAME,gBAAwBD,gBAAgB,IAAI,KAAKA,gBAAgB,KAAK,GAAG,EAAE;QAEjF,MAAME,cAAc;eAAIJ;SAAoB;QAE5C,IAAIC,YAAYE,cAAc,MAAM,EAChC,KAAK,MAAME,gBAAgBF,cAAe;YAEtC,MAAMG,iBAAiBF,YAAY,IAAI,CACnCG,CAAAA,IAAKA,EAAE,MAAM,KAAK,CAAC,KAAK,EAAEF,aAAa,IAAI,EAAE;YAGjD,IAAIC,gBAEAF,YAAY,IAAI,CAAC;gBACb,QAAQ,CAAC,MAAM,EAAEH,SAAS,EAAE,EAAE;gBAC9B,OAAOK,eAAe,KAAK;gBAC3B,eAAe,UAAUD,aAAa,IAAI;YAC9C;QAER;QAGJ,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACD;IACxC;AACJ"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
class GetFlpUseCase {
|
|
2
|
+
constructor(get){
|
|
3
|
+
this.get = get;
|
|
4
|
+
}
|
|
5
|
+
async execute(id) {
|
|
6
|
+
return this.get(id);
|
|
7
|
+
}
|
|
8
8
|
}
|
|
9
|
+
export { GetFlpUseCase };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=GetFlpUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/GetFlp/GetFlpUseCase.js","sources":["../../../../src/features/flp/GetFlp/GetFlpUseCase.ts"],"sourcesContent":["import type { GetFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { AcoFolderLevelPermissionsCrud, FolderLevelPermission } from \"~/flp/flp.types.js\";\n\nexport class GetFlpUseCase implements UseCaseAbstraction.Interface {\n private readonly get: AcoFolderLevelPermissionsCrud[\"get\"];\n\n constructor(get: AcoFolderLevelPermissionsCrud[\"get\"]) {\n this.get = get;\n }\n\n async execute(id: string): Promise<FolderLevelPermission | null> {\n return this.get(id);\n }\n}\n"],"names":["GetFlpUseCase","get","id"],"mappings":"AAGO,MAAMA;IAGT,YAAYC,GAAyC,CAAE;QACnD,IAAI,CAAC,GAAG,GAAGA;IACf;IAEA,MAAM,QAAQC,EAAU,EAAyC;QAC7D,OAAO,IAAI,CAAC,GAAG,CAACA;IACpB;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
const GetFlpUseCase = createAbstraction("GetFlpUseCase");
|
|
3
|
+
export { GetFlpUseCase };
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/GetFlp/abstractions.js","sources":["../../../../src/features/flp/GetFlp/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { FolderLevelPermission } from \"~/types.js\";\n\nexport interface IGetFolderPermission {\n execute: (id: string) => Promise<FolderLevelPermission | null>;\n}\n\n/** Retrieve a folder-level permission. */\nexport const GetFlpUseCase = createAbstraction<IGetFolderPermission>(\"GetFlpUseCase\");\n\nexport namespace GetFlpUseCase {\n export type Interface = IGetFolderPermission;\n}\n"],"names":["GetFlpUseCase","createAbstraction"],"mappings":";AAQO,MAAMA,gBAAgBC,kBAAwC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { GetFlpUseCase } from "./GetFlpUseCase.js";
|
|
3
|
-
import { GetFlpUseCase as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
}
|
|
3
|
+
import { GetFlpUseCase as external_abstractions_js_GetFlpUseCase } from "./abstractions.js";
|
|
4
|
+
const GetFlpFeature = createFeature({
|
|
5
|
+
name: "GetFlpFeature",
|
|
6
|
+
register (container, context) {
|
|
7
|
+
container.registerFactory(external_abstractions_js_GetFlpUseCase, ()=>new GetFlpUseCase(context.get));
|
|
8
|
+
}
|
|
11
9
|
});
|
|
10
|
+
export { GetFlpFeature };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/GetFlp/feature.js","sources":["../../../../src/features/flp/GetFlp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetFlpUseCase } from \"./GetFlpUseCase.js\";\nimport { GetFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { AcoContext } from \"~/types.js\";\n\nexport const GetFlpFeature = createFeature<AcoContext[\"aco\"][\"flp\"]>({\n name: \"GetFlpFeature\",\n register(container, context) {\n container.registerFactory(UseCaseAbstraction, () => {\n return new GetFlpUseCase(context.get);\n });\n }\n});\n"],"names":["GetFlpFeature","createFeature","container","context","UseCaseAbstraction","GetFlpUseCase"],"mappings":";;;AAKO,MAAMA,gBAAgBC,cAAwC;IACjE,MAAM;IACN,UAASC,SAAS,EAAEC,OAAO;QACvBD,UAAU,eAAe,CAACE,wCAAoB,IACnC,IAAIC,cAAcF,QAAQ,GAAG;IAE5C;AACJ"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
class ListFlpsUseCase {
|
|
2
|
+
constructor(list){
|
|
3
|
+
this.list = list;
|
|
4
|
+
}
|
|
5
|
+
async execute(params) {
|
|
6
|
+
return this.list(params);
|
|
7
|
+
}
|
|
8
8
|
}
|
|
9
|
+
export { ListFlpsUseCase };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=ListFlpsUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/ListFlps/ListFlpsUseCase.js","sources":["../../../../src/features/flp/ListFlps/ListFlpsUseCase.ts"],"sourcesContent":["import type { ListFlpsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { AcoFolderLevelPermissionsCrud, ListFlpsParams } from \"~/flp/flp.types.js\";\n\nexport class ListFlpsUseCase implements UseCaseAbstraction.Interface {\n private readonly list: AcoFolderLevelPermissionsCrud[\"list\"];\n\n constructor(list: AcoFolderLevelPermissionsCrud[\"list\"]) {\n this.list = list;\n }\n\n async execute(params: ListFlpsParams) {\n return this.list(params);\n }\n}\n"],"names":["ListFlpsUseCase","list","params"],"mappings":"AAGO,MAAMA;IAGT,YAAYC,IAA2C,CAAE;QACrD,IAAI,CAAC,IAAI,GAAGA;IAChB;IAEA,MAAM,QAAQC,MAAsB,EAAE;QAClC,OAAO,IAAI,CAAC,IAAI,CAACA;IACrB;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
const ListFlpsUseCase = createAbstraction("ListFlpsUseCase");
|
|
3
|
+
export { ListFlpsUseCase };
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/flp/ListFlps/abstractions.js","sources":["../../../../src/features/flp/ListFlps/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { FolderLevelPermission } from \"~/types.js\";\n\ninterface ListFlpsParams {\n where: {\n path_startsWith?: string;\n parentId?: string;\n type: string;\n };\n}\n\nexport interface IListFlps {\n execute: (params: ListFlpsParams) => Promise<FolderLevelPermission[]>;\n}\n\n/** List folder-level permissions. */\nexport const ListFlpsUseCase = createAbstraction<IListFlps>(\"ListFlpsUseCase\");\n\nexport namespace ListFlpsUseCase {\n export type Interface = IListFlps;\n}\n"],"names":["ListFlpsUseCase","createAbstraction"],"mappings":";AAgBO,MAAMA,kBAAkBC,kBAA6B"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { ListFlpsUseCase } from "./ListFlpsUseCase.js";
|
|
3
|
-
import { ListFlpsUseCase as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
}
|
|
3
|
+
import { ListFlpsUseCase as external_abstractions_js_ListFlpsUseCase } from "./abstractions.js";
|
|
4
|
+
const ListFlpsFeature = createFeature({
|
|
5
|
+
name: "ListFlpsFeature",
|
|
6
|
+
register (container, context) {
|
|
7
|
+
container.registerFactory(external_abstractions_js_ListFlpsUseCase, ()=>new ListFlpsUseCase(context.list));
|
|
8
|
+
}
|
|
11
9
|
});
|
|
10
|
+
export { ListFlpsFeature };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=feature.js.map
|
|
@@ -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 type { AcoContext } from \"~/types.js\";\n\nexport const ListFlpsFeature = createFeature<AcoContext[\"aco\"][\"flp\"]>({\n name: \"ListFlpsFeature\",\n register(container, context) {\n container.registerFactory(UseCaseAbstraction, () => {\n return new ListFlpsUseCase(context.list);\n });\n }\n});\n"],"names":["ListFlpsFeature","createFeature","container","context","UseCaseAbstraction","ListFlpsUseCase"],"mappings":";;;AAKO,MAAMA,kBAAkBC,cAAwC;IACnE,MAAM;IACN,UAASC,SAAS,EAAEC,OAAO;QACvBD,UAAU,eAAe,CAACE,0CAAoB,IACnC,IAAIC,gBAAgBF,QAAQ,IAAI;IAE/C;AACJ"}
|
|
@@ -4,200 +4,149 @@ import { Permissions, ROOT_FOLDER } from "@webiny/shared-aco";
|
|
|
4
4
|
import { ListFoldersUseCase } from "../../folder/ListFolders/index.js";
|
|
5
5
|
import { FolderModel } from "../../../domain/folder/abstractions.js";
|
|
6
6
|
import { EntryId } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
async execute(params) {
|
|
14
|
-
this.isCloseToTimeout = params.isCloseToTimeout;
|
|
15
|
-
this.handleTimeout = params.handleTimeout;
|
|
16
|
-
if (params.queued) {
|
|
17
|
-
params.queued.forEach(id => this.queued.add(id));
|
|
7
|
+
class UpdateFlpUseCase {
|
|
8
|
+
constructor(context){
|
|
9
|
+
this.queued = new Set();
|
|
10
|
+
this.flpsToUpdate = new Map();
|
|
11
|
+
this.context = context;
|
|
18
12
|
}
|
|
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
|
-
|
|
13
|
+
async execute(params) {
|
|
14
|
+
this.isCloseToTimeout = params.isCloseToTimeout;
|
|
15
|
+
this.handleTimeout = params.handleTimeout;
|
|
16
|
+
if (params.queued) params.queued.forEach((id)=>this.queued.add(id));
|
|
17
|
+
try {
|
|
18
|
+
const { folder } = params;
|
|
19
|
+
if (!folder) throw new WebinyError("Missing `folder`, I can't update the FLP record.", "ERROR_UPDATING_FLP_USE_CASE_FOLDER_NOT_PROVIDED", {
|
|
20
|
+
folder
|
|
21
|
+
});
|
|
22
|
+
const flp = await this.getFlp(folder);
|
|
23
|
+
const parentFlp = folder.parentId ? await this.context.aco.flp.get(folder.parentId) : null;
|
|
24
|
+
this.flpsToUpdate.set(folder.id, {
|
|
25
|
+
slug: folder.slug,
|
|
26
|
+
parentId: folder.parentId ?? ROOT_FOLDER,
|
|
27
|
+
path: Path.create(folder.slug, parentFlp?.path),
|
|
28
|
+
permissions: Permissions.create(folder.permissions, parentFlp)
|
|
29
|
+
});
|
|
30
|
+
this.setQueued(flp.id);
|
|
31
|
+
const directChildren = await this.listDirectChildren(flp);
|
|
32
|
+
for (const child of directChildren){
|
|
33
|
+
if (this.isCloseToTimeout?.()) {
|
|
34
|
+
await this.executeBatchUpdate();
|
|
35
|
+
this.handleTimeout?.(this.getQueuedList());
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
await this.collectBranchForUpdate(child, flp);
|
|
39
|
+
}
|
|
40
|
+
await this.executeBatchUpdate();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
this.flpsToUpdate.clear();
|
|
43
|
+
this.queued.clear();
|
|
44
|
+
throw WebinyError.from(error, {
|
|
45
|
+
message: "Error while updating FLP",
|
|
46
|
+
code: "ERROR_UPDATING_FLP_USE_CASE"
|
|
47
|
+
});
|
|
49
48
|
}
|
|
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
49
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async executeBatchUpdate() {
|
|
103
|
-
try {
|
|
104
|
-
const items = Array.from(this.flpsToUpdate.entries()).map(([id, {
|
|
105
|
-
slug,
|
|
106
|
-
parentId,
|
|
107
|
-
path,
|
|
108
|
-
permissions
|
|
109
|
-
}]) => {
|
|
110
|
-
return {
|
|
111
|
-
id,
|
|
112
|
-
data: {
|
|
113
|
-
slug,
|
|
114
|
-
parentId,
|
|
115
|
-
path,
|
|
116
|
-
permissions
|
|
117
|
-
}
|
|
50
|
+
async collectBranchForUpdate(flp, parentFlp) {
|
|
51
|
+
if (this.isQueued(flp.id)) return;
|
|
52
|
+
const parentFlpData = this.flpsToUpdate.get(parentFlp.id);
|
|
53
|
+
const currentParentFlp = {
|
|
54
|
+
...parentFlp,
|
|
55
|
+
...parentFlpData && {
|
|
56
|
+
...parentFlpData
|
|
57
|
+
}
|
|
118
58
|
};
|
|
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
|
-
}
|
|
59
|
+
this.flpsToUpdate.set(flp.id, {
|
|
60
|
+
slug: flp.slug,
|
|
61
|
+
parentId: flp.parentId,
|
|
62
|
+
path: Path.create(flp.slug, currentParentFlp.path),
|
|
63
|
+
permissions: Permissions.create(flp.permissions, currentParentFlp)
|
|
135
64
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
65
|
+
this.setQueued(flp.id);
|
|
66
|
+
const children = await this.listDirectChildren(flp);
|
|
67
|
+
for (const child of children){
|
|
68
|
+
if (this.isCloseToTimeout?.()) {
|
|
69
|
+
await this.executeBatchUpdate();
|
|
70
|
+
this.handleTimeout?.(this.getQueuedList());
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await this.collectBranchForUpdate(child, flp);
|
|
143
74
|
}
|
|
144
|
-
});
|
|
145
|
-
} finally {
|
|
146
|
-
// Clear the update collection after the batch update
|
|
147
|
-
this.flpsToUpdate.clear();
|
|
148
|
-
|
|
149
|
-
//Let's remove all the updated FLPs ids from the queue cache
|
|
150
|
-
this.clearQueuedList();
|
|
151
75
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
76
|
+
async executeBatchUpdate() {
|
|
77
|
+
try {
|
|
78
|
+
const items = Array.from(this.flpsToUpdate.entries()).map(([id, { slug, parentId, path, permissions }])=>({
|
|
79
|
+
id,
|
|
80
|
+
data: {
|
|
81
|
+
slug,
|
|
82
|
+
parentId,
|
|
83
|
+
path,
|
|
84
|
+
permissions
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
await this.context.aco.flp.batchUpdate(items);
|
|
88
|
+
const folderModel = this.context.container.resolve(FolderModel);
|
|
89
|
+
for (const item of items){
|
|
90
|
+
const { id, data } = item;
|
|
91
|
+
const entryId = EntryId.from(id);
|
|
92
|
+
await this.context.cms.updateEntry(folderModel, entryId.toString(), {
|
|
93
|
+
values: {
|
|
94
|
+
path: data.path
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
throw WebinyError.from(error, {
|
|
100
|
+
message: "Error while executing batch update of FLPs",
|
|
101
|
+
code: "BATCH_UPDATE_FLP_ERROR",
|
|
102
|
+
data: {
|
|
103
|
+
items: Array.from(this.flpsToUpdate.keys())
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} finally{
|
|
107
|
+
this.flpsToUpdate.clear();
|
|
108
|
+
this.clearQueuedList();
|
|
172
109
|
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
if (result.isFail()) {
|
|
176
|
-
throw result.error;
|
|
177
110
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
id
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
111
|
+
getQueuedList() {
|
|
112
|
+
return Array.from(this.queued);
|
|
113
|
+
}
|
|
114
|
+
setQueued(id) {
|
|
115
|
+
this.queued.add(id);
|
|
116
|
+
}
|
|
117
|
+
isQueued(id) {
|
|
118
|
+
return this.queued.has(id);
|
|
119
|
+
}
|
|
120
|
+
clearQueuedList() {
|
|
121
|
+
this.queued.clear();
|
|
122
|
+
}
|
|
123
|
+
async listDirectChildren(flp) {
|
|
124
|
+
const listFolders = this.context.container.resolve(ListFoldersUseCase);
|
|
125
|
+
const result = await this.context.security.withoutAuthorization(()=>listFolders.execute({
|
|
126
|
+
where: {
|
|
127
|
+
type: flp.type,
|
|
128
|
+
parentId: flp.id
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
if (result.isFail()) throw result.error;
|
|
132
|
+
return await Promise.all(result.value.folders.map((folder)=>this.getFlp(folder)));
|
|
133
|
+
}
|
|
134
|
+
async getFlp({ id, type, parentId, slug, permissions }) {
|
|
135
|
+
const flp = await this.context.aco.flp.get(id);
|
|
136
|
+
if (!flp) {
|
|
137
|
+
const parentFlp = parentId ? await this.context.aco.flp.get(parentId) : null;
|
|
138
|
+
return await this.context.aco.flp.create({
|
|
139
|
+
id,
|
|
140
|
+
type,
|
|
141
|
+
slug,
|
|
142
|
+
parentId: parentId ?? ROOT_FOLDER,
|
|
143
|
+
path: Path.create(slug, parentFlp?.path),
|
|
144
|
+
permissions: Permissions.create(permissions, parentFlp)
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return flp;
|
|
198
148
|
}
|
|
199
|
-
return flp;
|
|
200
|
-
}
|
|
201
149
|
}
|
|
150
|
+
export { UpdateFlpUseCase };
|
|
202
151
|
|
|
203
152
|
//# 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,gBAAg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;UACHC,IAAI,EAAElD,GAAG,CAACkD,IAAI;UACd/C,QAAQ,EAAEH,GAAG,CAACH;QAClB;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,IAAIiD,MAAM,CAACK,MAAM,CAAC,CAAC,EAAE;MACjB,MAAML,MAAM,CAAC5B,KAAK;IACtB;IAEA,OAAO,MAAMkC,OAAO,CAACC,GAAG,CAACP,MAAM,CAACQ,KAAK,CAACC,OAAO,CAACzB,GAAG,CAAC/B,MAAM,IAAI,IAAI,CAACE,MAAM,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 { 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"],"names":["UpdateFlpUseCase","context","Set","Map","params","id","folder","WebinyError","flp","parentFlp","ROOT_FOLDER","Path","Permissions","directChildren","child","error","parentFlpData","currentParentFlp","children","items","Array","slug","parentId","path","permissions","folderModel","FolderModel","item","data","entryId","EntryId","listFolders","ListFoldersUseCase","result","Promise","type"],"mappings":";;;;;;AAgBO,MAAMA;IAQT,YAAYC,OAAmB,CAAE;aAHhB,MAAM,GAAgB,IAAIC;aAC1B,YAAY,GAA+B,IAAIC;QAG5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E;gBACpB;YACJ;QAGJ,IAAIyB,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAGtB,OAAO,MAAMC,QAAQ,GAAG,CAACD,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC3B,CAAAA,SAAU,IAAI,CAAC,MAAM,CAACA;IAC5E;IAEA,MAAc,OAAO,EACjBD,EAAE,EACF8B,IAAI,EACJb,QAAQ,EACRD,IAAI,EACJG,WAAW,EACN,EAAkC;QACvC,MAAMhB,MAAM,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAACH;QAE3C,IAAI,CAACG,KAAK;YACN,MAAMC,YAAYa,WAAW,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAACA,YAAY;YAExE,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;gBACrCjB;gBACA8B;gBACAd;gBACA,UAAUC,YAAYZ;gBACtB,MAAMC,KAAK,MAAM,CAACU,MAAMZ,WAAW;gBACnC,aAAaG,YAAY,MAAM,CAACY,aAAaf;YACjD;QACJ;QAEA,OAAOD;IACX;AACJ"}
|
|
@@ -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
|