@webiny/api-aco 6.3.0-beta.4 → 6.4.0-beta.0
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.js +69 -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.js +7 -4
- package/index.js.map +1 -1
- package/package.json +24 -24
- 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
package/flp/flp.crud.js
CHANGED
|
@@ -1,91 +1,74 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
2
|
import { EntryId } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
const createFlpCrudMethods = ({ storageOperations, getTenant })=>({
|
|
4
|
+
async create (params) {
|
|
5
|
+
return await storageOperations.flp.create({
|
|
6
|
+
data: {
|
|
7
|
+
...params,
|
|
8
|
+
tenant: getTenant().id
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
async update (id, data) {
|
|
13
|
+
const original = await this.get(id);
|
|
14
|
+
if (!original) throw new WebinyError(`Folder level permission with id "${id}" not found.`, "GET_ITEM_UPDATE_FLP_ERROR", {
|
|
15
|
+
id,
|
|
16
|
+
data
|
|
17
|
+
});
|
|
18
|
+
return await storageOperations.flp.update({
|
|
19
|
+
original,
|
|
20
|
+
data: {
|
|
21
|
+
...data,
|
|
22
|
+
tenant: getTenant().id
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
async batchUpdate (items) {
|
|
27
|
+
const batchItems = (await Promise.all(items.map(async ({ id, data })=>{
|
|
28
|
+
const original = await this.get(id);
|
|
29
|
+
if (!original) return null;
|
|
30
|
+
return {
|
|
31
|
+
original,
|
|
32
|
+
data: {
|
|
33
|
+
...data,
|
|
34
|
+
tenant: getTenant().id
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}))).filter((item)=>null !== item);
|
|
38
|
+
if (0 === batchItems.length) return [];
|
|
39
|
+
return await storageOperations.flp.batchUpdate({
|
|
40
|
+
items: batchItems
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
async delete (id) {
|
|
44
|
+
const flp = await this.get(id);
|
|
45
|
+
if (!flp) throw new WebinyError(`Folder level permission with id "${id}" not found.`, "GET_ITEM_DELETE_FLP_ERROR", {
|
|
46
|
+
id
|
|
47
|
+
});
|
|
48
|
+
await storageOperations.flp.delete({
|
|
49
|
+
flp: {
|
|
50
|
+
...flp,
|
|
51
|
+
tenant: getTenant().id
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return true;
|
|
55
|
+
},
|
|
56
|
+
async get (id) {
|
|
57
|
+
const entryId = EntryId.from(id);
|
|
58
|
+
return await storageOperations.flp.get({
|
|
59
|
+
id: entryId.id,
|
|
60
|
+
tenant: getTenant().id
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
async list ({ where }) {
|
|
64
|
+
return await storageOperations.flp.list({
|
|
65
|
+
where: {
|
|
66
|
+
...where,
|
|
67
|
+
tenant: getTenant().id
|
|
68
|
+
}
|
|
69
|
+
});
|
|
13
70
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async update(id, data) {
|
|
17
|
-
const original = await this.get(id);
|
|
18
|
-
if (!original) {
|
|
19
|
-
throw new WebinyError(`Folder level permission with id "${id}" not found.`, "GET_ITEM_UPDATE_FLP_ERROR", {
|
|
20
|
-
id,
|
|
21
|
-
data
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return await storageOperations.flp.update({
|
|
25
|
-
original,
|
|
26
|
-
data: {
|
|
27
|
-
...data,
|
|
28
|
-
tenant: getTenant().id
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
async batchUpdate(items) {
|
|
33
|
-
const batchItems = (await Promise.all(items.map(async ({
|
|
34
|
-
id,
|
|
35
|
-
data
|
|
36
|
-
}) => {
|
|
37
|
-
const original = await this.get(id);
|
|
38
|
-
if (!original) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
original,
|
|
43
|
-
data: {
|
|
44
|
-
...data,
|
|
45
|
-
tenant: getTenant().id
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}))).filter(item => item !== null);
|
|
49
|
-
if (batchItems.length === 0) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
return await storageOperations.flp.batchUpdate({
|
|
53
|
-
items: batchItems
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
async delete(id) {
|
|
57
|
-
const flp = await this.get(id);
|
|
58
|
-
if (!flp) {
|
|
59
|
-
throw new WebinyError(`Folder level permission with id "${id}" not found.`, "GET_ITEM_DELETE_FLP_ERROR", {
|
|
60
|
-
id
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
await storageOperations.flp.delete({
|
|
64
|
-
flp: {
|
|
65
|
-
...flp,
|
|
66
|
-
tenant: getTenant().id
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
return true;
|
|
70
|
-
},
|
|
71
|
-
async get(id) {
|
|
72
|
-
const entryId = EntryId.from(id);
|
|
73
|
-
return await storageOperations.flp.get({
|
|
74
|
-
id: entryId.id,
|
|
75
|
-
tenant: getTenant().id
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
async list({
|
|
79
|
-
where
|
|
80
|
-
}) {
|
|
81
|
-
return await storageOperations.flp.list({
|
|
82
|
-
where: {
|
|
83
|
-
...where,
|
|
84
|
-
tenant: getTenant().id
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
};
|
|
71
|
+
});
|
|
72
|
+
export { createFlpCrudMethods };
|
|
90
73
|
|
|
91
74
|
//# sourceMappingURL=flp.crud.js.map
|
package/flp/flp.crud.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"flp/flp.crud.js","sources":["../../src/flp/flp.crud.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport {\n type AcoFolderLevelPermissionsCrud,\n type AcoStorageOperations,\n type CreateFlpParams,\n type UpdateFlpParams\n} from \"~/types.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\nimport { EntryId } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\n\nexport interface CreateFlpCrudMethodsParams {\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n}\n\nexport const createFlpCrudMethods = ({\n storageOperations,\n getTenant\n}: CreateFlpCrudMethodsParams): AcoFolderLevelPermissionsCrud => {\n return {\n async create(params: CreateFlpParams) {\n return await storageOperations.flp.create({\n data: { ...params, tenant: getTenant().id }\n });\n },\n async update(id: string, data: UpdateFlpParams) {\n const original = await this.get(id);\n if (!original) {\n throw new WebinyError(\n `Folder level permission with id \"${id}\" not found.`,\n \"GET_ITEM_UPDATE_FLP_ERROR\",\n {\n id,\n data\n }\n );\n }\n\n return await storageOperations.flp.update({\n original,\n data: {\n ...data,\n tenant: getTenant().id\n }\n });\n },\n async batchUpdate(items: Array<{ id: string; data: UpdateFlpParams }>) {\n const batchItems = (\n await Promise.all(\n items.map(async ({ id, data }) => {\n const original = await this.get(id);\n if (!original) {\n return null;\n }\n return {\n original,\n data: {\n ...data,\n tenant: getTenant().id\n }\n };\n })\n )\n ).filter((item): item is NonNullable<typeof item> => item !== null);\n\n if (batchItems.length === 0) {\n return [];\n }\n\n return await storageOperations.flp.batchUpdate({\n items: batchItems\n });\n },\n async delete(id: string) {\n const flp = await this.get(id);\n if (!flp) {\n throw new WebinyError(\n `Folder level permission with id \"${id}\" not found.`,\n \"GET_ITEM_DELETE_FLP_ERROR\",\n {\n id\n }\n );\n }\n\n await storageOperations.flp.delete({\n flp: {\n ...flp,\n tenant: getTenant().id\n }\n });\n\n return true;\n },\n async get(id: string) {\n const entryId = EntryId.from(id);\n return await storageOperations.flp.get({\n id: entryId.id,\n tenant: getTenant().id\n });\n },\n async list({ where }) {\n return await storageOperations.flp.list({\n where: {\n ...where,\n tenant: getTenant().id\n }\n });\n }\n };\n};\n"],"names":["createFlpCrudMethods","storageOperations","getTenant","params","id","data","original","WebinyError","items","batchItems","Promise","item","flp","entry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,CAAC,EACpD,6BACA;gBACIA;YACJ;YAIR,MAAMH,kBAAkB,GAAG,CAAC,MAAM,CAAC;gBAC/B,KAAK;oBACD,GAAGW,GAAG;oBACN,QAAQV,YAAY,EAAE;gBAC1B;YACJ;YAEA,OAAO;QACX;QACA,MAAM,KAAIE,EAAU;YAChB,MAAMS,UAAUC,QAAQ,IAAI,CAACV;YAC7B,OAAO,MAAMH,kBAAkB,GAAG,CAAC,GAAG,CAAC;gBACnC,IAAIY,QAAQ,EAAE;gBACd,QAAQX,YAAY,EAAE;YAC1B;QACJ;QACA,MAAM,MAAK,EAAEa,KAAK,EAAE;YAChB,OAAO,MAAMd,kBAAkB,GAAG,CAAC,IAAI,CAAC;gBACpC,OAAO;oBACH,GAAGc,KAAK;oBACR,QAAQb,YAAY,EAAE;gBAC1B;YACJ;QACJ;IACJ"}
|
package/flp/flp.so.js
CHANGED
|
@@ -2,219 +2,182 @@ import { createStandardEntity, createTable } from "@webiny/db-dynamodb";
|
|
|
2
2
|
import { WebinyError } from "@webiny/error";
|
|
3
3
|
import { executeWithRetry } from "@webiny/utils";
|
|
4
4
|
class FolderLevelPermissionsStorageOperations {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
name: String(process.env.DB_TABLE),
|
|
10
|
-
documentClient
|
|
11
|
-
});
|
|
12
|
-
this.entity = createStandardEntity({
|
|
13
|
-
table: this.table.table,
|
|
14
|
-
name: "ACO.flp"
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
async list({
|
|
18
|
-
where: {
|
|
19
|
-
tenant,
|
|
20
|
-
type,
|
|
21
|
-
path_startsWith,
|
|
22
|
-
parentId
|
|
23
|
-
}
|
|
24
|
-
}) {
|
|
25
|
-
try {
|
|
26
|
-
if (parentId) {
|
|
27
|
-
const entries = await this.entity.queryAll({
|
|
28
|
-
partitionKey: `T#${tenant}#FLP`,
|
|
29
|
-
options: {
|
|
30
|
-
index: "GSI2",
|
|
31
|
-
eq: parentId
|
|
32
|
-
}
|
|
5
|
+
constructor({ documentClient }){
|
|
6
|
+
this.table = createTable({
|
|
7
|
+
name: String(process.env.DB_TABLE),
|
|
8
|
+
documentClient
|
|
33
9
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const entries = await this.entity.queryAll({
|
|
38
|
-
partitionKey: `T#${tenant}#AT#${type}#FLP`,
|
|
39
|
-
options: {
|
|
40
|
-
index: "GSI1",
|
|
41
|
-
beginsWith: path_startsWith
|
|
42
|
-
}
|
|
10
|
+
this.entity = createStandardEntity({
|
|
11
|
+
table: this.table.table,
|
|
12
|
+
name: "ACO.flp"
|
|
43
13
|
});
|
|
44
|
-
return entries.map(entry => entry.data);
|
|
45
|
-
}
|
|
46
|
-
throw new WebinyError("Missing required parameters.", "LIST_FLP_MISSING_PARAMETERS", {
|
|
47
|
-
tenant,
|
|
48
|
-
type,
|
|
49
|
-
path_startsWith,
|
|
50
|
-
parentId
|
|
51
|
-
});
|
|
52
|
-
} catch (err) {
|
|
53
|
-
throw WebinyError.from(err, {
|
|
54
|
-
message: "Could not list folder level permissions.",
|
|
55
|
-
code: "LIST_FLP_ERROR"
|
|
56
|
-
});
|
|
57
14
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
15
|
+
async list({ where: { tenant, type, path_startsWith, parentId } }) {
|
|
16
|
+
try {
|
|
17
|
+
if (parentId) {
|
|
18
|
+
const entries = await this.entity.queryAll({
|
|
19
|
+
partitionKey: `T#${tenant}#FLP`,
|
|
20
|
+
options: {
|
|
21
|
+
index: "GSI2",
|
|
22
|
+
eq: parentId
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return entries.map((entry)=>entry.data);
|
|
26
|
+
}
|
|
27
|
+
if (path_startsWith) {
|
|
28
|
+
const entries = await this.entity.queryAll({
|
|
29
|
+
partitionKey: `T#${tenant}#AT#${type}#FLP`,
|
|
30
|
+
options: {
|
|
31
|
+
index: "GSI1",
|
|
32
|
+
beginsWith: path_startsWith
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return entries.map((entry)=>entry.data);
|
|
36
|
+
}
|
|
37
|
+
throw new WebinyError("Missing required parameters.", "LIST_FLP_MISSING_PARAMETERS", {
|
|
38
|
+
tenant,
|
|
39
|
+
type,
|
|
40
|
+
path_startsWith,
|
|
41
|
+
parentId
|
|
42
|
+
});
|
|
43
|
+
} catch (err) {
|
|
44
|
+
throw WebinyError.from(err, {
|
|
45
|
+
message: "Could not list folder level permissions.",
|
|
46
|
+
code: "LIST_FLP_ERROR"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async get({ tenant, id }) {
|
|
51
|
+
try {
|
|
52
|
+
const entry = await this.entity.get(this.createKeys({
|
|
53
|
+
tenant,
|
|
54
|
+
id
|
|
55
|
+
}));
|
|
56
|
+
if (!entry) return null;
|
|
57
|
+
return entry.data;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
throw WebinyError.from(err, {
|
|
60
|
+
message: "Could not load folder level permission.",
|
|
61
|
+
code: "GET_FLP_ERROR",
|
|
62
|
+
data: {
|
|
63
|
+
tenant,
|
|
64
|
+
id
|
|
65
|
+
}
|
|
66
|
+
});
|
|
79
67
|
}
|
|
80
|
-
});
|
|
81
68
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
data
|
|
69
|
+
async create({ data }) {
|
|
70
|
+
const keys = {
|
|
71
|
+
...this.createKeys(data),
|
|
72
|
+
...this.createGsiKeys(data)
|
|
73
|
+
};
|
|
74
|
+
try {
|
|
75
|
+
await this.entity.put({
|
|
76
|
+
...keys,
|
|
77
|
+
data
|
|
78
|
+
});
|
|
79
|
+
return data;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
throw WebinyError.from(err, {
|
|
82
|
+
message: "Could not create folder level permission.",
|
|
83
|
+
code: "CREATE_FLP_ERROR",
|
|
84
|
+
data: {
|
|
85
|
+
keys,
|
|
86
|
+
data
|
|
87
|
+
}
|
|
88
|
+
});
|
|
103
89
|
}
|
|
104
|
-
});
|
|
105
90
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
inputData,
|
|
131
|
-
original
|
|
91
|
+
async update({ data: inputData, original }) {
|
|
92
|
+
try {
|
|
93
|
+
const data = {
|
|
94
|
+
...original,
|
|
95
|
+
...inputData
|
|
96
|
+
};
|
|
97
|
+
const keys = {
|
|
98
|
+
...this.createKeys(data),
|
|
99
|
+
...this.createGsiKeys(data)
|
|
100
|
+
};
|
|
101
|
+
await this.entity.put({
|
|
102
|
+
...keys,
|
|
103
|
+
data
|
|
104
|
+
});
|
|
105
|
+
return data;
|
|
106
|
+
} catch (err) {
|
|
107
|
+
throw WebinyError.from(err, {
|
|
108
|
+
message: "Could not update folder level permission.",
|
|
109
|
+
code: "UPDATE_FLP_ERROR",
|
|
110
|
+
data: {
|
|
111
|
+
inputData,
|
|
112
|
+
original
|
|
113
|
+
}
|
|
114
|
+
});
|
|
132
115
|
}
|
|
133
|
-
});
|
|
134
116
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
flp
|
|
117
|
+
async delete({ flp }) {
|
|
118
|
+
const keys = this.createKeys(flp);
|
|
119
|
+
try {
|
|
120
|
+
await this.entity.delete(keys);
|
|
121
|
+
} catch (err) {
|
|
122
|
+
throw WebinyError.from(err, {
|
|
123
|
+
message: "Could not delete folder level permission.",
|
|
124
|
+
code: "DELETE_FLP_ERROR",
|
|
125
|
+
data: {
|
|
126
|
+
keys,
|
|
127
|
+
flp
|
|
128
|
+
}
|
|
129
|
+
});
|
|
149
130
|
}
|
|
150
|
-
});
|
|
151
131
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
132
|
+
async batchUpdate({ items }) {
|
|
133
|
+
try {
|
|
134
|
+
const batch = this.entity.createEntityWriter();
|
|
135
|
+
const updatedItems = [];
|
|
136
|
+
for (const { original, data: inputData } of items){
|
|
137
|
+
const data = {
|
|
138
|
+
...original,
|
|
139
|
+
...inputData
|
|
140
|
+
};
|
|
141
|
+
const keys = {
|
|
142
|
+
...this.createKeys(data),
|
|
143
|
+
...this.createGsiKeys(data)
|
|
144
|
+
};
|
|
145
|
+
batch.put({
|
|
146
|
+
...keys,
|
|
147
|
+
data
|
|
148
|
+
});
|
|
149
|
+
updatedItems.push(data);
|
|
150
|
+
}
|
|
151
|
+
await executeWithRetry(async ()=>await batch.execute());
|
|
152
|
+
return updatedItems;
|
|
153
|
+
} catch (err) {
|
|
154
|
+
throw WebinyError.from(err, {
|
|
155
|
+
message: "Could not batch update folder level permissions.",
|
|
156
|
+
code: "BATCH_UPDATE_FLP_ERROR",
|
|
157
|
+
data: {
|
|
158
|
+
items
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
createKeys({ id, tenant }) {
|
|
164
|
+
return {
|
|
165
|
+
PK: `T#${tenant}#FLP#${id}`,
|
|
166
|
+
SK: "A",
|
|
167
|
+
TYPE: "aco.flp"
|
|
166
168
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
}
|
|
170
|
+
createGsiKeys({ tenant, type, path, parentId }) {
|
|
171
|
+
return {
|
|
172
|
+
GSI1_PK: `T#${tenant}#AT#${type}#FLP`,
|
|
173
|
+
GSI1_SK: path,
|
|
174
|
+
GSI2_PK: `T#${tenant}#FLP`,
|
|
175
|
+
GSI2_SK: parentId,
|
|
176
|
+
GSI_TENANT: tenant
|
|
170
177
|
};
|
|
171
|
-
batch.put({
|
|
172
|
-
...keys,
|
|
173
|
-
data
|
|
174
|
-
});
|
|
175
|
-
updatedItems.push(data);
|
|
176
|
-
}
|
|
177
|
-
await executeWithRetry(async () => {
|
|
178
|
-
return await batch.execute();
|
|
179
|
-
});
|
|
180
|
-
return updatedItems;
|
|
181
|
-
} catch (err) {
|
|
182
|
-
throw WebinyError.from(err, {
|
|
183
|
-
message: "Could not batch update folder level permissions.",
|
|
184
|
-
code: "BATCH_UPDATE_FLP_ERROR",
|
|
185
|
-
data: {
|
|
186
|
-
items
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
178
|
}
|
|
190
|
-
}
|
|
191
|
-
createKeys({
|
|
192
|
-
id,
|
|
193
|
-
tenant
|
|
194
|
-
}) {
|
|
195
|
-
return {
|
|
196
|
-
PK: `T#${tenant}#FLP#${id}`,
|
|
197
|
-
SK: `A`,
|
|
198
|
-
TYPE: "aco.flp"
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
createGsiKeys({
|
|
202
|
-
tenant,
|
|
203
|
-
type,
|
|
204
|
-
path,
|
|
205
|
-
parentId
|
|
206
|
-
}) {
|
|
207
|
-
return {
|
|
208
|
-
GSI1_PK: `T#${tenant}#AT#${type}#FLP`,
|
|
209
|
-
GSI1_SK: path,
|
|
210
|
-
GSI2_PK: `T#${tenant}#FLP`,
|
|
211
|
-
GSI2_SK: parentId,
|
|
212
|
-
GSI_TENANT: tenant
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
179
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
};
|
|
180
|
+
const createFlpOperations = (params)=>new FolderLevelPermissionsStorageOperations(params);
|
|
181
|
+
export { createFlpOperations };
|
|
219
182
|
|
|
220
183
|
//# sourceMappingURL=flp.so.js.map
|
package/flp/flp.so.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createStandardEntity","createTable","WebinyError","executeWithRetry","FolderLevelPermissionsStorageOperations","constructor","documentClient","table","name","String","process","env","DB_TABLE","entity","list","where","tenant","type","path_startsWith","parentId","entries","queryAll","partitionKey","options","index","eq","map","entry","data","beginsWith","err","from","message","code","get","id","createKeys","create","keys","createGsiKeys","put","update","inputData","original","delete","flp","batchUpdate","items","batch","createEntityWriter","updatedItems","push","execute","PK","SK","TYPE","path","GSI1_PK","GSI1_SK","GSI2_PK","GSI2_SK","GSI_TENANT","createFlpOperations","params"],"sources":["flp.so.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStandardEntity, createTable } from \"@webiny/db-dynamodb\";\n\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n AcoFolderLevelPermissionsStorageOperations as IAcoFolderLevelPermissionsStorageOperations,\n FolderLevelPermission,\n StorageOperationsBatchUpdateFlpParams,\n StorageOperationsCreateFlpParams,\n StorageOperationsDeleteFlpParams,\n StorageOperationsGetFlpParams,\n StorageOperationsListFlpsParams,\n StorageOperationsUpdateFlpParams\n} from \"~/flp/flp.types.js\";\nimport { executeWithRetry } from \"@webiny/utils\";\n\ninterface StorageOperationsConfig {\n documentClient: DynamoDBDocument;\n}\n\ninterface CreateKeysParams {\n tenant: string;\n id: string;\n}\n\ninterface CreateGsiKeysParams {\n tenant: string;\n id: string;\n type: string;\n path: string;\n parentId: string;\n}\n\nclass FolderLevelPermissionsStorageOperations implements IAcoFolderLevelPermissionsStorageOperations {\n private readonly entity;\n private readonly table;\n\n constructor({ documentClient }: StorageOperationsConfig) {\n this.table = createTable({\n name: String(process.env.DB_TABLE),\n documentClient\n });\n\n this.entity = createStandardEntity<FolderLevelPermission>({\n table: this.table.table,\n name: \"ACO.flp\"\n });\n }\n\n public async list({\n where: { tenant, type, path_startsWith, parentId }\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n try {\n if (parentId) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#FLP`,\n options: {\n index: \"GSI2\",\n eq: parentId\n }\n });\n return entries.map(entry => entry.data);\n }\n\n if (path_startsWith) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#AT#${type}#FLP`,\n options: {\n index: \"GSI1\",\n beginsWith: path_startsWith\n }\n });\n return entries.map(entry => entry.data);\n }\n\n throw new WebinyError(\"Missing required parameters.\", \"LIST_FLP_MISSING_PARAMETERS\", {\n tenant,\n type,\n path_startsWith,\n parentId\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list folder level permissions.\",\n code: \"LIST_FLP_ERROR\"\n });\n }\n }\n\n public async get({\n tenant,\n id\n }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null> {\n try {\n const entry = await this.entity.get(this.createKeys({ tenant, id }));\n\n if (!entry) {\n return null;\n }\n\n return entry.data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not load folder level permission.\",\n code: \"GET_FLP_ERROR\",\n data: { tenant, id }\n });\n }\n }\n\n public async create({\n data\n }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission> {\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n try {\n await this.entity.put({\n ...keys,\n data\n });\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not create folder level permission.\",\n code: \"CREATE_FLP_ERROR\",\n data: { keys, data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n try {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n await this.entity.put({\n ...keys,\n data\n });\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update folder level permission.\",\n code: \"UPDATE_FLP_ERROR\",\n data: { inputData, original }\n });\n }\n }\n\n public async delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void> {\n const keys = this.createKeys(flp);\n\n try {\n await this.entity.delete(keys);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: {\n keys,\n flp\n }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n try {\n const batch = this.entity.createEntityWriter();\n\n const updatedItems: FolderLevelPermission[] = [];\n\n for (const { original, data: inputData } of items) {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n batch.put({\n ...keys,\n data\n });\n\n updatedItems.push(data);\n }\n\n await executeWithRetry(async () => {\n return await batch.execute();\n });\n\n return updatedItems;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not batch update folder level permissions.\",\n code: \"BATCH_UPDATE_FLP_ERROR\",\n data: { items }\n });\n }\n }\n\n private createKeys({ id, tenant }: CreateKeysParams) {\n return {\n PK: `T#${tenant}#FLP#${id}`,\n SK: `A`,\n TYPE: \"aco.flp\"\n };\n }\n\n private createGsiKeys({ tenant, type, path, parentId }: CreateGsiKeysParams) {\n return {\n GSI1_PK: `T#${tenant}#AT#${type}#FLP`,\n GSI1_SK: path,\n GSI2_PK: `T#${tenant}#FLP`,\n GSI2_SK: parentId,\n GSI_TENANT: tenant\n };\n }\n}\n\nexport const createFlpOperations = (params: StorageOperationsConfig) => {\n return new FolderLevelPermissionsStorageOperations(params);\n};\n"],"mappings":"AACA,SAASA,oBAAoB,EAAEC,WAAW,QAAQ,qBAAqB;AAEvE,SAASC,WAAW,QAAQ,eAAe;AAW3C,SAASC,gBAAgB,QAAQ,eAAe;AAmBhD,MAAMC,uCAAuC,CAAwD;EAIjGC,WAAWA,CAAC;IAAEC;EAAwC,CAAC,EAAE;IACrD,IAAI,CAACC,KAAK,GAAGN,WAAW,CAAC;MACrBO,IAAI,EAAEC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,QAAQ,CAAC;MAClCN;IACJ,CAAC,CAAC;IAEF,IAAI,CAACO,MAAM,GAAGb,oBAAoB,CAAwB;MACtDO,KAAK,EAAE,IAAI,CAACA,KAAK,CAACA,KAAK;MACvBC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;EAEA,MAAaM,IAAIA,CAAC;IACdC,KAAK,EAAE;MAAEC,MAAM;MAAEC,IAAI;MAAEC,eAAe;MAAEC;IAAS;EACpB,CAAC,EAAoC;IAClE,IAAI;MACA,IAAIA,QAAQ,EAAE;QACV,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACP,MAAM,CAACQ,QAAQ,CAAC;UACvCC,YAAY,EAAE,KAAKN,MAAM,MAAM;UAC/BO,OAAO,EAAE;YACLC,KAAK,EAAE,MAAM;YACbC,EAAE,EAAEN;UACR;QACJ,CAAC,CAAC;QACF,OAAOC,OAAO,CAACM,GAAG,CAACC,KAAK,IAAIA,KAAK,CAACC,IAAI,CAAC;MAC3C;MAEA,IAAIV,eAAe,EAAE;QACjB,MAA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G;MACPC,IAAI,EAAE;IACV,CAAC;EACL;EAEQhB,aAAaA,CAAC;IAAEvB,MAAM;IAAEC,IAAI;IAAEuC,IAAI;IAAErC;EAA8B,CAAC,EAAE;IACzE,OAAO;MACHsC,OAAO,EAAE,KAAKzC,MAAM,OAAOC,IAAI,MAAM;MACrCyC,OAAO,EAAEF,IAAI;MACbG,OAAO,EAAE,KAAK3C,MAAM,MAAM;MAC1B4C,OAAO,EAAEzC,QAAQ;MACjB0C,UAAU,EAAE7C;IAChB,CAAC;EACL;AACJ;AAEA,OAAO,MAAM8C,mBAAmB,GAAIC,MAA+B,IAAK;EACpE,OAAO,IAAI3D,uCAAuC,CAAC2D,MAAM,CAAC;AAC9D,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"flp/flp.so.js","sources":["../../src/flp/flp.so.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStandardEntity, createTable } from \"@webiny/db-dynamodb\";\n\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n AcoFolderLevelPermissionsStorageOperations as IAcoFolderLevelPermissionsStorageOperations,\n FolderLevelPermission,\n StorageOperationsBatchUpdateFlpParams,\n StorageOperationsCreateFlpParams,\n StorageOperationsDeleteFlpParams,\n StorageOperationsGetFlpParams,\n StorageOperationsListFlpsParams,\n StorageOperationsUpdateFlpParams\n} from \"~/flp/flp.types.js\";\nimport { executeWithRetry } from \"@webiny/utils\";\n\ninterface StorageOperationsConfig {\n documentClient: DynamoDBDocument;\n}\n\ninterface CreateKeysParams {\n tenant: string;\n id: string;\n}\n\ninterface CreateGsiKeysParams {\n tenant: string;\n id: string;\n type: string;\n path: string;\n parentId: string;\n}\n\nclass FolderLevelPermissionsStorageOperations implements IAcoFolderLevelPermissionsStorageOperations {\n private readonly entity;\n private readonly table;\n\n constructor({ documentClient }: StorageOperationsConfig) {\n this.table = createTable({\n name: String(process.env.DB_TABLE),\n documentClient\n });\n\n this.entity = createStandardEntity<FolderLevelPermission>({\n table: this.table.table,\n name: \"ACO.flp\"\n });\n }\n\n public async list({\n where: { tenant, type, path_startsWith, parentId }\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n try {\n if (parentId) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#FLP`,\n options: {\n index: \"GSI2\",\n eq: parentId\n }\n });\n return entries.map(entry => entry.data);\n }\n\n if (path_startsWith) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#AT#${type}#FLP`,\n options: {\n index: \"GSI1\",\n beginsWith: path_startsWith\n }\n });\n return entries.map(entry => entry.data);\n }\n\n throw new WebinyError(\"Missing required parameters.\", \"LIST_FLP_MISSING_PARAMETERS\", {\n tenant,\n type,\n path_startsWith,\n parentId\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list folder level permissions.\",\n code: \"LIST_FLP_ERROR\"\n });\n }\n }\n\n public async get({\n tenant,\n id\n }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null> {\n try {\n const entry = await this.entity.get(this.createKeys({ tenant, id }));\n\n if (!entry) {\n return null;\n }\n\n return entry.data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not load folder level permission.\",\n code: \"GET_FLP_ERROR\",\n data: { tenant, id }\n });\n }\n }\n\n public async create({\n data\n }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission> {\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n try {\n await this.entity.put({\n ...keys,\n data\n });\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not create folder level permission.\",\n code: \"CREATE_FLP_ERROR\",\n data: { keys, data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n try {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n await this.entity.put({\n ...keys,\n data\n });\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update folder level permission.\",\n code: \"UPDATE_FLP_ERROR\",\n data: { inputData, original }\n });\n }\n }\n\n public async delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void> {\n const keys = this.createKeys(flp);\n\n try {\n await this.entity.delete(keys);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: {\n keys,\n flp\n }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n try {\n const batch = this.entity.createEntityWriter();\n\n const updatedItems: FolderLevelPermission[] = [];\n\n for (const { original, data: inputData } of items) {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n batch.put({\n ...keys,\n data\n });\n\n updatedItems.push(data);\n }\n\n await executeWithRetry(async () => {\n return await batch.execute();\n });\n\n return updatedItems;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not batch update folder level permissions.\",\n code: \"BATCH_UPDATE_FLP_ERROR\",\n data: { items }\n });\n }\n }\n\n private createKeys({ id, tenant }: CreateKeysParams) {\n return {\n PK: `T#${tenant}#FLP#${id}`,\n SK: `A`,\n TYPE: \"aco.flp\"\n };\n }\n\n private createGsiKeys({ tenant, type, path, parentId }: CreateGsiKeysParams) {\n return {\n GSI1_PK: `T#${tenant}#AT#${type}#FLP`,\n GSI1_SK: path,\n GSI2_PK: `T#${tenant}#FLP`,\n GSI2_SK: parentId,\n GSI_TENANT: tenant\n };\n }\n}\n\nexport const createFlpOperations = (params: StorageOperationsConfig) => {\n return new FolderLevelPermissionsStorageOperations(params);\n};\n"],"names":["FolderLevelPermissionsStorageOperations","documentClient","createTable","String","process","createStandardEntity","tenant","type","path_startsWith","parentId","entries","entry","WebinyError","err","id","data","keys","inputData","original","flp","items","batch","updatedItems","executeWithRetry","path","createFlpO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