@webiny/api-file-manager 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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/README.md +7 -13
- package/contants.d.ts +1 -0
- package/contants.js +4 -0
- package/contants.js.map +1 -0
- package/delivery/AssetDelivery/Asset.d.ts +28 -0
- package/delivery/AssetDelivery/Asset.js +53 -0
- package/delivery/AssetDelivery/Asset.js.map +1 -0
- package/delivery/AssetDelivery/AssetRequest.d.ts +25 -0
- package/delivery/AssetDelivery/AssetRequest.js +23 -0
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.d.ts +25 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.js +32 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.d.ts +2 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +7 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -0
- package/delivery/index.d.ts +7 -0
- package/delivery/index.js +6 -0
- package/delivery/setupAssetDelivery.d.ts +1 -0
- package/delivery/setupAssetDelivery.js +69 -0
- package/delivery/setupAssetDelivery.js.map +1 -0
- package/domain/file/abstractions.d.ts +9 -0
- package/domain/file/abstractions.js +5 -0
- package/domain/file/abstractions.js.map +1 -0
- package/domain/file/errors.d.ts +59 -0
- package/domain/file/errors.js +80 -0
- package/domain/file/errors.js.map +1 -0
- package/domain/file/file.model.d.ts +12 -0
- package/domain/file/file.model.js +65 -0
- package/domain/file/file.model.js.map +1 -0
- package/domain/file/types.d.ts +53 -0
- package/domain/file/types.js +0 -0
- package/domain/identity/Identity.d.ts +9 -0
- package/domain/identity/Identity.js +12 -0
- package/domain/identity/Identity.js.map +1 -0
- package/domain/permissionsSchema.d.ts +16 -0
- package/domain/permissionsSchema.js +30 -0
- package/domain/permissionsSchema.js.map +1 -0
- package/domain/settings/constants.d.ts +1 -0
- package/domain/settings/constants.js +4 -0
- package/domain/settings/constants.js.map +1 -0
- package/domain/settings/errors.d.ts +18 -0
- package/domain/settings/errors.js +28 -0
- package/domain/settings/errors.js.map +1 -0
- package/domain/settings/types.d.ts +10 -0
- package/domain/settings/types.js +0 -0
- package/domain/settings/validation.d.ts +6 -0
- package/domain/settings/validation.js +27 -0
- package/domain/settings/validation.js.map +1 -0
- package/exports/api/file-manager/file.d.ts +12 -0
- package/exports/api/file-manager/file.js +12 -0
- package/exports/api/file-manager/permissions.d.ts +1 -0
- package/exports/api/file-manager/permissions.js +1 -0
- package/exports/api/file-manager/settings.d.ts +3 -0
- package/exports/api/file-manager/settings.js +3 -0
- package/features/FileManagerFeature.d.ts +4 -0
- package/features/FileManagerFeature.js +31 -0
- package/features/FileManagerFeature.js.map +1 -0
- package/features/assetDelivery/FilesAssetRequestResolver.d.ts +9 -0
- package/features/assetDelivery/FilesAssetRequestResolver.js +29 -0
- package/features/assetDelivery/FilesAssetRequestResolver.js.map +1 -0
- package/features/assetDelivery/NullAssetOutputStrategy.d.ts +8 -0
- package/features/assetDelivery/NullAssetOutputStrategy.js +14 -0
- package/features/assetDelivery/NullAssetOutputStrategy.js.map +1 -0
- package/features/assetDelivery/NullAssetReply.d.ts +4 -0
- package/features/assetDelivery/NullAssetReply.js +14 -0
- package/features/assetDelivery/NullAssetReply.js.map +1 -0
- package/features/assetDelivery/NullAssetResolver.d.ts +8 -0
- package/features/assetDelivery/NullAssetResolver.js +13 -0
- package/features/assetDelivery/NullAssetResolver.js.map +1 -0
- package/features/assetDelivery/abstractions.d.ts +54 -0
- package/features/assetDelivery/abstractions.js +11 -0
- package/features/assetDelivery/abstractions.js.map +1 -0
- package/features/assetDelivery/feature.d.ts +4 -0
- package/features/assetDelivery/feature.js +29 -0
- package/features/assetDelivery/feature.js.map +1 -0
- package/features/assetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +4 -0
- package/features/assetDelivery/privateFiles/NotAuthorizedAssetReply.js +20 -0
- package/features/assetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -0
- package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +5 -0
- package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +9 -0
- package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -0
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +11 -0
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +26 -0
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -0
- package/features/assetDelivery/privateFiles/PrivateCache.d.ts +8 -0
- package/features/assetDelivery/privateFiles/PrivateCache.js +22 -0
- package/features/assetDelivery/privateFiles/PrivateCache.js.map +1 -0
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +11 -0
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +31 -0
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -0
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +19 -0
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js +65 -0
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -0
- package/features/assetDelivery/privateFiles/PublicCache.d.ts +8 -0
- package/features/assetDelivery/privateFiles/PublicCache.js +22 -0
- package/features/assetDelivery/privateFiles/PublicCache.js.map +1 -0
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +9 -0
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +21 -0
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -0
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +9 -0
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +21 -0
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -0
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +9 -0
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js +13 -0
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -0
- package/features/assetDelivery/transformation/TransformationAssetProcessor.d.ts +11 -0
- package/features/assetDelivery/transformation/TransformationAssetProcessor.js +23 -0
- package/features/assetDelivery/transformation/TransformationAssetProcessor.js.map +1 -0
- package/features/file/CreateFile/CreateFileRepository.d.ts +15 -0
- package/features/file/CreateFile/CreateFileRepository.js +32 -0
- package/features/file/CreateFile/CreateFileRepository.js.map +1 -0
- package/features/file/CreateFile/CreateFileUseCase.d.ts +21 -0
- package/features/file/CreateFile/CreateFileUseCase.js +83 -0
- package/features/file/CreateFile/CreateFileUseCase.js.map +1 -0
- package/features/file/CreateFile/abstractions.d.ts +60 -0
- package/features/file/CreateFile/abstractions.js +6 -0
- package/features/file/CreateFile/abstractions.js.map +1 -0
- package/features/file/CreateFile/events.d.ts +31 -0
- package/features/file/CreateFile/events.js +23 -0
- package/features/file/CreateFile/events.js.map +1 -0
- package/features/file/CreateFile/feature.d.ts +4 -0
- package/features/file/CreateFile/feature.js +13 -0
- package/features/file/CreateFile/feature.js.map +1 -0
- package/features/file/CreateFile/index.d.ts +2 -0
- package/features/file/CreateFile/index.js +2 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.d.ts +13 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +22 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.d.ts +19 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +73 -0
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -0
- package/features/file/CreateFilesInBatch/abstractions.d.ts +42 -0
- package/features/file/CreateFilesInBatch/abstractions.js +6 -0
- package/features/file/CreateFilesInBatch/abstractions.js.map +1 -0
- package/features/file/CreateFilesInBatch/events.d.ts +31 -0
- package/features/file/CreateFilesInBatch/events.js +23 -0
- package/features/file/CreateFilesInBatch/events.js.map +1 -0
- package/features/file/CreateFilesInBatch/feature.d.ts +4 -0
- package/features/file/CreateFilesInBatch/feature.js +13 -0
- package/features/file/CreateFilesInBatch/feature.js.map +1 -0
- package/features/file/CreateFilesInBatch/index.d.ts +1 -0
- package/features/file/CreateFilesInBatch/index.js +1 -0
- package/features/file/DeleteFile/DeleteFileRepository.d.ts +15 -0
- package/features/file/DeleteFile/DeleteFileRepository.js +31 -0
- package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -0
- package/features/file/DeleteFile/DeleteFileUseCase.d.ts +17 -0
- package/features/file/DeleteFile/DeleteFileUseCase.js +43 -0
- package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -0
- package/features/file/DeleteFile/abstractions.d.ts +39 -0
- package/features/file/DeleteFile/abstractions.js +6 -0
- package/features/file/DeleteFile/abstractions.js.map +1 -0
- package/features/file/DeleteFile/events.d.ts +29 -0
- package/features/file/DeleteFile/events.js +23 -0
- package/features/file/DeleteFile/events.js.map +1 -0
- package/features/file/DeleteFile/feature.d.ts +4 -0
- package/features/file/DeleteFile/feature.js +13 -0
- package/features/file/DeleteFile/feature.js.map +1 -0
- package/features/file/DeleteFile/index.d.ts +2 -0
- package/features/file/DeleteFile/index.js +2 -0
- package/features/file/FileUrlGenerator/abstractions.d.ts +9 -0
- package/features/file/FileUrlGenerator/abstractions.js +5 -0
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -0
- package/features/file/GetFile/GetFileRepository.d.ts +15 -0
- package/features/file/GetFile/GetFileRepository.js +33 -0
- package/features/file/GetFile/GetFileRepository.js.map +1 -0
- package/features/file/GetFile/GetFileUseCase.d.ts +14 -0
- package/features/file/GetFile/GetFileUseCase.js +29 -0
- package/features/file/GetFile/GetFileUseCase.js.map +1 -0
- package/features/file/GetFile/abstractions.d.ts +40 -0
- package/features/file/GetFile/abstractions.js +6 -0
- package/features/file/GetFile/abstractions.js.map +1 -0
- package/features/file/GetFile/feature.d.ts +4 -0
- package/features/file/GetFile/feature.js +13 -0
- package/features/file/GetFile/feature.js.map +1 -0
- package/features/file/GetFile/index.d.ts +1 -0
- package/features/file/GetFile/index.js +1 -0
- package/features/file/GetFileContentsById/abstractions.d.ts +20 -0
- package/features/file/GetFileContentsById/abstractions.js +5 -0
- package/features/file/GetFileContentsById/abstractions.js.map +1 -0
- package/features/file/GetFileContentsById/index.d.ts +1 -0
- package/features/file/GetFileContentsById/index.js +1 -0
- package/features/file/GetFileContentsByKey/abstractions.d.ts +17 -0
- package/features/file/GetFileContentsByKey/abstractions.js +5 -0
- package/features/file/GetFileContentsByKey/abstractions.js.map +1 -0
- package/features/file/GetFileContentsByKey/index.d.ts +1 -0
- package/features/file/GetFileContentsByKey/index.js +1 -0
- package/features/file/ListFiles/ListFilesRepository.d.ts +18 -0
- package/features/file/ListFiles/ListFilesRepository.js +53 -0
- package/features/file/ListFiles/ListFilesRepository.js.map +1 -0
- package/features/file/ListFiles/ListFilesUseCase.d.ts +15 -0
- package/features/file/ListFiles/ListFilesUseCase.js +44 -0
- package/features/file/ListFiles/ListFilesUseCase.js.map +1 -0
- package/features/file/ListFiles/abstractions.d.ts +49 -0
- package/features/file/ListFiles/abstractions.js +6 -0
- package/features/file/ListFiles/abstractions.js.map +1 -0
- package/features/file/ListFiles/feature.d.ts +4 -0
- package/features/file/ListFiles/feature.js +13 -0
- package/features/file/ListFiles/feature.js.map +1 -0
- package/features/file/ListFiles/index.d.ts +1 -0
- package/features/file/ListFiles/index.js +1 -0
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.d.ts +27 -0
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +42 -0
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -0
- package/features/file/ListImagesByTagTool/feature.d.ts +4 -0
- package/features/file/ListImagesByTagTool/feature.js +11 -0
- package/features/file/ListImagesByTagTool/feature.js.map +1 -0
- package/features/file/ListTags/ListTagsRepository.d.ts +16 -0
- package/features/file/ListTags/ListTagsRepository.js +42 -0
- package/features/file/ListTags/ListTagsRepository.js.map +1 -0
- package/features/file/ListTags/ListTagsUseCase.d.ts +13 -0
- package/features/file/ListTags/ListTagsUseCase.js +31 -0
- package/features/file/ListTags/ListTagsUseCase.js.map +1 -0
- package/features/file/ListTags/abstractions.d.ts +45 -0
- package/features/file/ListTags/abstractions.js +6 -0
- package/features/file/ListTags/abstractions.js.map +1 -0
- package/features/file/ListTags/feature.d.ts +4 -0
- package/features/file/ListTags/feature.js +13 -0
- package/features/file/ListTags/feature.js.map +1 -0
- package/features/file/ListTags/index.d.ts +1 -0
- package/features/file/ListTags/index.js +1 -0
- package/features/file/UpdateFile/UpdateFileRepository.d.ts +15 -0
- package/features/file/UpdateFile/UpdateFileRepository.js +37 -0
- package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -0
- package/features/file/UpdateFile/UpdateFileUseCase.d.ts +20 -0
- package/features/file/UpdateFile/UpdateFileUseCase.js +71 -0
- package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -0
- package/features/file/UpdateFile/abstractions.d.ts +56 -0
- package/features/file/UpdateFile/abstractions.js +6 -0
- package/features/file/UpdateFile/abstractions.js.map +1 -0
- package/features/file/UpdateFile/events.d.ts +34 -0
- package/features/file/UpdateFile/events.js +23 -0
- package/features/file/UpdateFile/events.js.map +1 -0
- package/features/file/UpdateFile/feature.d.ts +4 -0
- package/features/file/UpdateFile/feature.js +13 -0
- package/features/file/UpdateFile/feature.js.map +1 -0
- package/features/file/UpdateFile/index.d.ts +2 -0
- package/features/file/UpdateFile/index.js +2 -0
- package/features/file/shared/EntryToFileMapper.d.ts +5 -0
- package/features/file/shared/EntryToFileMapper.js +28 -0
- package/features/file/shared/EntryToFileMapper.js.map +1 -0
- package/features/file/shared/FileInputToEntryInputMapper.d.ts +5 -0
- package/features/file/shared/FileInputToEntryInputMapper.js +32 -0
- package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -0
- package/features/file/shared/FileToEntryMapper.d.ts +5 -0
- package/features/file/shared/FileToEntryMapper.js +31 -0
- package/features/file/shared/FileToEntryMapper.js.map +1 -0
- package/features/permissions/abstractions.d.ts +21 -0
- package/features/permissions/abstractions.js +6 -0
- package/features/permissions/abstractions.js.map +1 -0
- package/features/permissions/feature.d.ts +4 -0
- package/features/permissions/feature.js +7 -0
- package/features/permissions/feature.js.map +1 -0
- package/features/settings/GetSettings/GetSettingsUseCase.d.ts +13 -0
- package/features/settings/GetSettings/GetSettingsUseCase.js +28 -0
- package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -0
- package/features/settings/GetSettings/abstractions.d.ts +18 -0
- package/features/settings/GetSettings/abstractions.js +5 -0
- package/features/settings/GetSettings/abstractions.js.map +1 -0
- package/features/settings/GetSettings/feature.d.ts +4 -0
- package/features/settings/GetSettings/feature.js +11 -0
- package/features/settings/GetSettings/feature.js.map +1 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.d.ts +15 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.js +36 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -0
- package/features/settings/SettingsInstaller/feature.d.ts +4 -0
- package/features/settings/SettingsInstaller/feature.js +11 -0
- package/features/settings/SettingsInstaller/feature.js.map +1 -0
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.d.ts +18 -0
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +55 -0
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -0
- package/features/settings/UpdateSettings/abstractions.d.ts +23 -0
- package/features/settings/UpdateSettings/abstractions.js +5 -0
- package/features/settings/UpdateSettings/abstractions.js.map +1 -0
- package/features/settings/UpdateSettings/events.d.ts +34 -0
- package/features/settings/UpdateSettings/events.js +23 -0
- package/features/settings/UpdateSettings/events.js.map +1 -0
- package/features/settings/UpdateSettings/feature.d.ts +4 -0
- package/features/settings/UpdateSettings/feature.js +11 -0
- package/features/settings/UpdateSettings/feature.js.map +1 -0
- package/features/settings/UpdateSettings/index.d.ts +2 -0
- package/features/settings/UpdateSettings/index.js +2 -0
- package/features/shared/abstractions.d.ts +1 -0
- package/features/shared/abstractions.js +1 -0
- package/graphql/baseSchema.d.ts +3 -0
- package/graphql/baseSchema.js +100 -0
- package/graphql/baseSchema.js.map +1 -0
- package/graphql/createFilesTypeDefs.d.ts +8 -0
- package/graphql/createFilesTypeDefs.js +191 -0
- package/graphql/createFilesTypeDefs.js.map +1 -0
- package/graphql/filesSchema.d.ts +4 -0
- package/graphql/filesSchema.js +96 -0
- package/graphql/filesSchema.js.map +1 -0
- package/graphql/getFileByUrl.d.ts +3 -0
- package/graphql/getFileByUrl.js +61 -0
- package/graphql/getFileByUrl.js.map +1 -0
- package/graphql/index.d.ts +4 -0
- package/graphql/index.js +47 -0
- package/graphql/index.js.map +1 -0
- package/graphql/utils.d.ts +11 -0
- package/graphql/utils.js +12 -0
- package/graphql/utils.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.js +44 -0
- package/index.js.map +1 -0
- package/modelModifier/CmsModelModifier.d.ts +26 -0
- package/modelModifier/CmsModelModifier.js +51 -0
- package/modelModifier/CmsModelModifier.js.map +1 -0
- package/package.json +34 -42
- package/types.d.ts +2 -356
- package/types.js +1 -5
- package/handlers/download/index.d.ts +0 -3
- package/handlers/download/index.js +0 -132
- package/handlers/download/index.js.map +0 -1
- package/handlers/manage/index.d.ts +0 -5
- package/handlers/manage/index.js +0 -71
- package/handlers/manage/index.js.map +0 -1
- package/handlers/transform/index.d.ts +0 -2
- package/handlers/transform/index.js +0 -91
- package/handlers/transform/index.js.map +0 -1
- package/handlers/transform/loaders/imageLoader.d.ts +0 -30
- package/handlers/transform/loaders/imageLoader.js +0 -105
- package/handlers/transform/loaders/imageLoader.js.map +0 -1
- package/handlers/transform/loaders/index.d.ts +0 -8
- package/handlers/transform/loaders/index.js +0 -13
- package/handlers/transform/loaders/index.js.map +0 -1
- package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +0 -11
- package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -58
- package/handlers/transform/loaders/sanitizeImageTransformations.js.map +0 -1
- package/handlers/transform/managers/imageManager.d.ts +0 -15
- package/handlers/transform/managers/imageManager.js +0 -63
- package/handlers/transform/managers/imageManager.js.map +0 -1
- package/handlers/transform/managers/index.d.ts +0 -5
- package/handlers/transform/managers/index.js +0 -13
- package/handlers/transform/managers/index.js.map +0 -1
- package/handlers/transform/optimizeImage.d.ts +0 -3
- package/handlers/transform/optimizeImage.js +0 -48
- package/handlers/transform/optimizeImage.js.map +0 -1
- package/handlers/transform/transformImage.d.ts +0 -10
- package/handlers/transform/transformImage.js +0 -30
- package/handlers/transform/transformImage.js.map +0 -1
- package/handlers/transform/utils.d.ts +0 -12
- package/handlers/transform/utils.js +0 -46
- package/handlers/transform/utils.js.map +0 -1
- package/handlers/types.d.ts +0 -8
- package/handlers/types.js +0 -5
- package/handlers/types.js.map +0 -1
- package/handlers/utils/getEnvironment.d.ts +0 -5
- package/handlers/utils/getEnvironment.js +0 -13
- package/handlers/utils/getEnvironment.js.map +0 -1
- package/handlers/utils/getObjectParams.d.ts +0 -9
- package/handlers/utils/getObjectParams.js +0 -25
- package/handlers/utils/getObjectParams.js.map +0 -1
- package/handlers/utils/index.d.ts +0 -2
- package/handlers/utils/index.js +0 -23
- package/handlers/utils/index.js.map +0 -1
- package/plugins/crud/files/validation.d.ts +0 -3
- package/plugins/crud/files/validation.js +0 -41
- package/plugins/crud/files/validation.js.map +0 -1
- package/plugins/crud/files.crud.d.ts +0 -4
- package/plugins/crud/files.crud.js +0 -431
- package/plugins/crud/files.crud.js.map +0 -1
- package/plugins/crud/settings.crud.d.ts +0 -5
- package/plugins/crud/settings.crud.js +0 -116
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/crud/system.crud.d.ts +0 -4
- package/plugins/crud/system.crud.js +0 -153
- package/plugins/crud/system.crud.js.map +0 -1
- package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
- package/plugins/crud/utils/checkBasePermissions.js +0 -33
- package/plugins/crud/utils/checkBasePermissions.js.map +0 -1
- package/plugins/crud/utils/createFileModel.d.ts +0 -5
- package/plugins/crud/utils/createFileModel.js +0 -77
- package/plugins/crud/utils/createFileModel.js.map +0 -1
- package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
- package/plugins/crud/utils/lifecycleEvents.js +0 -38
- package/plugins/crud/utils/lifecycleEvents.js.map +0 -1
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +0 -21
- package/plugins/definitions/FilePhysicalStoragePlugin.js +0 -42
- package/plugins/definitions/FilePhysicalStoragePlugin.js.map +0 -1
- package/plugins/definitions/FilePlugin.d.ts +0 -136
- package/plugins/definitions/FilePlugin.js +0 -70
- package/plugins/definitions/FilePlugin.js.map +0 -1
- package/plugins/definitions/FileStorageTransformPlugin.d.ts +0 -34
- package/plugins/definitions/FileStorageTransformPlugin.js +0 -51
- package/plugins/definitions/FileStorageTransformPlugin.js.map +0 -1
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/InstallationPlugin.d.ts +0 -19
- package/plugins/definitions/InstallationPlugin.js +0 -42
- package/plugins/definitions/InstallationPlugin.js.map +0 -1
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/graphql.d.ts +0 -4
- package/plugins/graphql.js +0 -290
- package/plugins/graphql.js.map +0 -1
- package/plugins/index.d.ts +0 -2
- package/plugins/index.js +0 -24
- package/plugins/index.js.map +0 -1
- package/plugins/storage/FileStorage.d.ts +0 -30
- package/plugins/storage/FileStorage.js +0 -103
- package/plugins/storage/FileStorage.js.map +0 -1
- package/plugins/storage/index.d.ts +0 -4
- package/plugins/storage/index.js +0 -26
- package/plugins/storage/index.js.map +0 -1
- package/types.js.map +0 -1
- package/utils.d.ts +0 -4
- package/utils.js +0 -16
- package/utils.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js";
|
|
3
|
+
import { ListFilesRepository } from "./abstractions.js";
|
|
4
|
+
import { FileModel } from "../../../domain/file/abstractions.js";
|
|
5
|
+
import { FilePersistenceError } from "../../../domain/file/errors.js";
|
|
6
|
+
import { EntryToFileMapper } from "../shared/EntryToFileMapper.js";
|
|
7
|
+
import { CmsSortMapper, CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
8
|
+
class ListFilesRepositoryImpl {
|
|
9
|
+
constructor(listLatestEntries, fileModel, cmsWhereMapper, cmsSortMapper){
|
|
10
|
+
this.listLatestEntries = listLatestEntries;
|
|
11
|
+
this.fileModel = fileModel;
|
|
12
|
+
this.cmsWhereMapper = cmsWhereMapper;
|
|
13
|
+
this.cmsSortMapper = cmsSortMapper;
|
|
14
|
+
}
|
|
15
|
+
async execute(input) {
|
|
16
|
+
const where = this.cmsWhereMapper.map({
|
|
17
|
+
input: input.where || {},
|
|
18
|
+
fields: this.fileModel.fields
|
|
19
|
+
});
|
|
20
|
+
const sort = this.cmsSortMapper.map({
|
|
21
|
+
input: input.sort,
|
|
22
|
+
fields: this.fileModel.fields
|
|
23
|
+
});
|
|
24
|
+
const result = await this.listLatestEntries.execute(this.fileModel, {
|
|
25
|
+
where,
|
|
26
|
+
limit: input.limit || 40,
|
|
27
|
+
after: input.after || void 0,
|
|
28
|
+
sort: sort || [
|
|
29
|
+
"id_DESC"
|
|
30
|
+
],
|
|
31
|
+
search: input.search
|
|
32
|
+
});
|
|
33
|
+
if (result.isFail()) return Result.fail(new FilePersistenceError(result.error));
|
|
34
|
+
const { entries, meta } = result.value;
|
|
35
|
+
const files = entries.map((entry)=>EntryToFileMapper.toFile(entry));
|
|
36
|
+
return Result.ok({
|
|
37
|
+
items: files,
|
|
38
|
+
meta
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const ListFilesRepository_ListFilesRepository = ListFilesRepository.createImplementation({
|
|
43
|
+
implementation: ListFilesRepositoryImpl,
|
|
44
|
+
dependencies: [
|
|
45
|
+
ListLatestEntriesUseCase,
|
|
46
|
+
FileModel,
|
|
47
|
+
CmsWhereMapper,
|
|
48
|
+
CmsSortMapper
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
export { ListFilesRepository_ListFilesRepository as ListFilesRepository };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=ListFilesRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListFiles/ListFilesRepository.js","sources":["../../../../src/features/file/ListFiles/ListFilesRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries/index.js\";\nimport {\n ListFilesInput,\n ListFilesOutput,\n ListFilesRepository as RepositoryAbstraction\n} from \"./abstractions.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\nimport { FilePersistenceError } from \"~/domain/file/errors.js\";\nimport { EntryToFileMapper } from \"../shared/EntryToFileMapper.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport { CmsSortMapper } from \"@webiny/api-headless-cms\";\nimport { GenericRecord } from \"@webiny/api/types.js\";\n\nclass ListFilesRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private fileModel: FileModel.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface,\n private cmsSortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute(\n input: ListFilesInput\n ): Promise<Result<ListFilesOutput, RepositoryAbstraction.Error>> {\n const where = this.cmsWhereMapper.map<GenericRecord>({\n input: input.where || {},\n fields: this.fileModel.fields\n });\n\n const sort = this.cmsSortMapper.map({\n input: input.sort,\n fields: this.fileModel.fields\n });\n\n const result = await this.listLatestEntries.execute(this.fileModel, {\n where,\n limit: input.limit || 40,\n after: input.after || undefined,\n sort: sort || [\"id_DESC\"],\n search: input.search\n });\n\n if (result.isFail()) {\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n const { entries, meta } = result.value;\n\n const files = entries.map(entry => EntryToFileMapper.toFile(entry));\n\n return Result.ok({\n items: files,\n meta\n });\n }\n}\n\nexport const ListFilesRepository = RepositoryAbstraction.createImplementation({\n implementation: ListFilesRepositoryImpl,\n dependencies: [ListLatestEntriesUseCase, FileModel, CmsWhereMapper, CmsSortMapper]\n});\n"],"names":["ListFilesRepositoryImpl","listLatestEntries","fileModel","cmsWhereMapper","cmsSortMapper","input","where","sort","result","undefined","Result","FilePersistenceError","entries","meta","files","entry","EntryToFileMapper","ListFilesRepository","RepositoryAbstraction","ListLatestEntriesUseCase","FileModel","CmsWhereMapper","CmsSortMapper"],"mappings":";;;;;;;AAcA,MAAMA;IACF,YACYC,iBAAqD,EACrDC,SAA8B,EAC9BC,cAAwC,EACxCC,aAAsC,CAChD;aAJUH,iBAAiB,GAAjBA;aACAC,SAAS,GAATA;aACAC,cAAc,GAAdA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QACFC,KAAqB,EACwC;QAC7D,MAAMC,QAAQ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAgB;YACjD,OAAOD,MAAM,KAAK,IAAI,CAAC;YACvB,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;QACjC;QAEA,MAAME,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;YAChC,OAAOF,MAAM,IAAI;YACjB,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;QACjC;QAEA,MAAMG,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;YAChEF;YACA,OAAOD,MAAM,KAAK,IAAI;YACtB,OAAOA,MAAM,KAAK,IAAII;YACtB,MAAMF,QAAQ;gBAAC;aAAU;YACzB,QAAQF,MAAM,MAAM;QACxB;QAEA,IAAIG,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAAC,IAAIC,qBAAqBH,OAAO,KAAK;QAG5D,MAAM,EAAEI,OAAO,EAAEC,IAAI,EAAE,GAAGL,OAAO,KAAK;QAEtC,MAAMM,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAASC,kBAAkB,MAAM,CAACD;QAE5D,OAAOL,OAAO,EAAE,CAAC;YACb,OAAOI;YACPD;QACJ;IACJ;AACJ;AAEO,MAAMI,0CAAsBC,oBAAAA,oBAA0C,CAAC;IAC1E,gBAAgBlB;IAChB,cAAc;QAACmB;QAA0BC;QAAWC;QAAgBC;KAAc;AACtF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ListFilesUseCase as UseCaseAbstraction, ListFilesInput, ListFilesOutput, ListFilesRepository } from "./abstractions.js";
|
|
3
|
+
import { FmPermissions } from "../../../features/shared/abstractions.js";
|
|
4
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
|
+
declare class ListFilesUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
|
+
private permissions;
|
|
7
|
+
private identityContext;
|
|
8
|
+
private repository;
|
|
9
|
+
constructor(permissions: FmPermissions.Interface, identityContext: IdentityContext.Interface, repository: ListFilesRepository.Interface);
|
|
10
|
+
execute(input: ListFilesInput): Promise<Result<ListFilesOutput, UseCaseAbstraction.Error>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const ListFilesUseCase: typeof ListFilesUseCaseImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListFilesUseCase>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ListFilesRepository, ListFilesUseCase } from "./abstractions.js";
|
|
3
|
+
import { FileNotAuthorizedError } from "../../../domain/file/errors.js";
|
|
4
|
+
import { FmPermissions } from "../../shared/abstractions.js";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
|
+
class ListFilesUseCaseImpl {
|
|
7
|
+
constructor(permissions, identityContext, repository){
|
|
8
|
+
this.permissions = permissions;
|
|
9
|
+
this.identityContext = identityContext;
|
|
10
|
+
this.repository = repository;
|
|
11
|
+
}
|
|
12
|
+
async execute(input) {
|
|
13
|
+
const hasPermission = await this.permissions.canRead("file");
|
|
14
|
+
if (!hasPermission) return Result.fail(new FileNotAuthorizedError());
|
|
15
|
+
const where = {
|
|
16
|
+
...input.where || {}
|
|
17
|
+
};
|
|
18
|
+
if (await this.permissions.onlyOwnRecords("file")) {
|
|
19
|
+
const identity = this.identityContext.getIdentity();
|
|
20
|
+
where.createdBy = identity.id;
|
|
21
|
+
}
|
|
22
|
+
const result = await this.repository.execute({
|
|
23
|
+
...input,
|
|
24
|
+
where,
|
|
25
|
+
limit: input.limit || 40,
|
|
26
|
+
sort: input.sort && input.sort.length > 0 ? input.sort : [
|
|
27
|
+
"id_DESC"
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
31
|
+
return Result.ok(result.value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const ListFilesUseCase_ListFilesUseCase = ListFilesUseCase.createImplementation({
|
|
35
|
+
implementation: ListFilesUseCaseImpl,
|
|
36
|
+
dependencies: [
|
|
37
|
+
FmPermissions,
|
|
38
|
+
IdentityContext,
|
|
39
|
+
ListFilesRepository
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
export { ListFilesUseCase_ListFilesUseCase as ListFilesUseCase };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=ListFilesUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListFiles/ListFilesUseCase.js","sources":["../../../../src/features/file/ListFiles/ListFilesUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListFilesUseCase as UseCaseAbstraction,\n ListFilesInput,\n ListFilesOutput,\n ListFilesRepository\n} from \"./abstractions.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\n\nclass ListFilesUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private identityContext: IdentityContext.Interface,\n private repository: ListFilesRepository.Interface\n ) {}\n\n async execute(\n input: ListFilesInput\n ): Promise<Result<ListFilesOutput, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canRead(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n // Build where clause.\n const where: ListFilesInput[\"where\"] = {\n ...(input.where || {})\n };\n\n // Filter by createdBy if user can only access own records.\n if (await this.permissions.onlyOwnRecords(\"file\")) {\n const identity = this.identityContext.getIdentity();\n where.createdBy = identity.id;\n }\n\n const result = await this.repository.execute({\n ...input,\n where,\n limit: input.limit || 40,\n sort: input.sort && input.sort.length > 0 ? input.sort : [\"id_DESC\"]\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const ListFilesUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListFilesUseCaseImpl,\n dependencies: [FmPermissions, IdentityContext, ListFilesRepository]\n});\n"],"names":["ListFilesUseCaseImpl","permissions","identityContext","repository","input","hasPermission","Result","FileNotAuthorizedError","where","identity","result","ListFilesUseCase","UseCaseAbstraction","FmPermissions","IdentityContext","ListFilesRepository"],"mappings":";;;;;AAWA,MAAMA;IACF,YACYC,WAAoC,EACpCC,eAA0C,EAC1CC,UAAyC,CACnD;aAHUF,WAAW,GAAXA;aACAC,eAAe,GAAfA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QACFC,KAAqB,EACqC;QAC1D,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACrD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAI3B,MAAMC,QAAiC;YACnC,GAAIJ,MAAM,KAAK,IAAI,CAAC,CAAC;QACzB;QAGA,IAAI,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS;YAC/C,MAAMK,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;YACjDD,MAAM,SAAS,GAAGC,SAAS,EAAE;QACjC;QAEA,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACzC,GAAGN,KAAK;YACRI;YACA,OAAOJ,MAAM,KAAK,IAAI;YACtB,MAAMA,MAAM,IAAI,IAAIA,MAAM,IAAI,CAAC,MAAM,GAAG,IAAIA,MAAM,IAAI,GAAG;gBAAC;aAAU;QACxE;QAEA,IAAIM,OAAO,MAAM,IACb,OAAOJ,OAAO,IAAI,CAACI,OAAO,KAAK;QAGnC,OAAOJ,OAAO,EAAE,CAACI,OAAO,KAAK;IACjC;AACJ;AAEO,MAAMC,oCAAmBC,iBAAAA,oBAAuC,CAAC;IACpE,gBAAgBZ;IAChB,cAAc;QAACa;QAAeC;QAAiBC;KAAoB;AACvE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { File } from "../../../domain/file/types.js";
|
|
3
|
+
import { type FilePersistenceError, FileNotAuthorizedError } from "../../../domain/file/errors.js";
|
|
4
|
+
import type { CmsEntryMeta } from "@webiny/api-headless-cms/types";
|
|
5
|
+
export interface ListFilesInput {
|
|
6
|
+
limit?: number;
|
|
7
|
+
after?: string | null;
|
|
8
|
+
where?: Record<string, any>;
|
|
9
|
+
sort?: Array<`${string}_ASC` | `${string}_DESC`>;
|
|
10
|
+
search?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ListFilesOutput {
|
|
13
|
+
items: File[];
|
|
14
|
+
meta: CmsEntryMeta;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ListFiles repository interface
|
|
18
|
+
*/
|
|
19
|
+
export interface IListFilesRepository {
|
|
20
|
+
execute(input: ListFilesInput): Promise<Result<ListFilesOutput, RepositoryError>>;
|
|
21
|
+
}
|
|
22
|
+
export interface IListFilesRepositoryErrors {
|
|
23
|
+
persistence: FilePersistenceError;
|
|
24
|
+
}
|
|
25
|
+
type RepositoryError = IListFilesRepositoryErrors[keyof IListFilesRepositoryErrors];
|
|
26
|
+
/** Fetch files from storage with filtering. */
|
|
27
|
+
export declare const ListFilesRepository: import("@webiny/di").Abstraction<IListFilesRepository>;
|
|
28
|
+
export declare namespace ListFilesRepository {
|
|
29
|
+
type Interface = IListFilesRepository;
|
|
30
|
+
type Error = RepositoryError;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* ListFiles use case interface
|
|
34
|
+
*/
|
|
35
|
+
export interface IListFilesUseCase {
|
|
36
|
+
execute(input: ListFilesInput): Promise<Result<ListFilesOutput, UseCaseError>>;
|
|
37
|
+
}
|
|
38
|
+
export interface IListFilesUseCaseErrors {
|
|
39
|
+
notAuthorized: FileNotAuthorizedError;
|
|
40
|
+
persistence: FilePersistenceError;
|
|
41
|
+
}
|
|
42
|
+
type UseCaseError = IListFilesUseCaseErrors[keyof IListFilesUseCaseErrors];
|
|
43
|
+
/** List files with filtering and pagination. */
|
|
44
|
+
export declare const ListFilesUseCase: import("@webiny/di").Abstraction<IListFilesUseCase>;
|
|
45
|
+
export declare namespace ListFilesUseCase {
|
|
46
|
+
type Interface = IListFilesUseCase;
|
|
47
|
+
type Error = UseCaseError;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const ListFilesRepository = createAbstraction("ListFilesRepository");
|
|
3
|
+
const ListFilesUseCase = createAbstraction("ListFilesUseCase");
|
|
4
|
+
export { ListFilesRepository, ListFilesUseCase };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListFiles/abstractions.js","sources":["../../../../src/features/file/ListFiles/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { type FilePersistenceError, FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport type { CmsEntryMeta } from \"@webiny/api-headless-cms/types\";\n\nexport interface ListFilesInput {\n limit?: number;\n after?: string | null;\n where?: Record<string, any>;\n sort?: Array<`${string}_ASC` | `${string}_DESC`>;\n search?: string;\n}\n\nexport interface ListFilesOutput {\n items: File[];\n meta: CmsEntryMeta;\n}\n\n/**\n * ListFiles repository interface\n */\nexport interface IListFilesRepository {\n execute(input: ListFilesInput): Promise<Result<ListFilesOutput, RepositoryError>>;\n}\n\nexport interface IListFilesRepositoryErrors {\n persistence: FilePersistenceError;\n}\n\ntype RepositoryError = IListFilesRepositoryErrors[keyof IListFilesRepositoryErrors];\n\n/** Fetch files from storage with filtering. */\nexport const ListFilesRepository = createAbstraction<IListFilesRepository>(\"ListFilesRepository\");\n\nexport namespace ListFilesRepository {\n export type Interface = IListFilesRepository;\n export type Error = RepositoryError;\n}\n\n/**\n * ListFiles use case interface\n */\nexport interface IListFilesUseCase {\n execute(input: ListFilesInput): Promise<Result<ListFilesOutput, UseCaseError>>;\n}\n\nexport interface IListFilesUseCaseErrors {\n notAuthorized: FileNotAuthorizedError;\n persistence: FilePersistenceError;\n}\n\ntype UseCaseError = IListFilesUseCaseErrors[keyof IListFilesUseCaseErrors];\n\n/** List files with filtering and pagination. */\nexport const ListFilesUseCase = createAbstraction<IListFilesUseCase>(\"ListFilesUseCase\");\n\nexport namespace ListFilesUseCase {\n export type Interface = IListFilesUseCase;\n export type Error = UseCaseError;\n}\n"],"names":["ListFilesRepository","createAbstraction","ListFilesUseCase"],"mappings":";AAiCO,MAAMA,sBAAsBC,kBAAwC;AAsBpE,MAAMC,mBAAmBD,kBAAqC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListFilesRepository } from "./ListFilesRepository.js";
|
|
3
|
+
import { ListFilesUseCase } from "./ListFilesUseCase.js";
|
|
4
|
+
const ListFilesFeature = createFeature({
|
|
5
|
+
name: "FileManager/ListFiles",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListFilesUseCase);
|
|
8
|
+
container.register(ListFilesRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { ListFilesFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListFiles/feature.js","sources":["../../../../src/features/file/ListFiles/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListFilesRepository } from \"./ListFilesRepository.js\";\nimport { ListFilesUseCase } from \"./ListFilesUseCase.js\";\n\nexport const ListFilesFeature = createFeature({\n name: \"FileManager/ListFiles\",\n register(container) {\n container.register(ListFilesUseCase);\n container.register(ListFilesRepository).inSingletonScope();\n }\n});\n"],"names":["ListFilesFeature","createFeature","container","ListFilesUseCase","ListFilesRepository"],"mappings":";;;AAIO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,qBAAqB,gBAAgB;IAC5D;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListFilesUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListFilesUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type IAiSdkTool } from "@webiny/api-core/features/ai/index.js";
|
|
3
|
+
import { ListFilesUseCase } from "../../../features/file/ListFiles/index.js";
|
|
4
|
+
declare const inputSchema: z.ZodObject<{
|
|
5
|
+
tag: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
type Input = z.infer<typeof inputSchema>;
|
|
8
|
+
interface ImageItem {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
tags: string[];
|
|
13
|
+
}
|
|
14
|
+
declare class ListImagesByTagToolImpl implements IAiSdkTool<Input> {
|
|
15
|
+
private listFiles;
|
|
16
|
+
readonly name = "listImagesByTag";
|
|
17
|
+
readonly description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
|
|
18
|
+
readonly inputSchema: z.ZodObject<{
|
|
19
|
+
tag: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
constructor(listFiles: ListFilesUseCase.Interface);
|
|
22
|
+
execute(input: Input): Promise<ImageItem[]>;
|
|
23
|
+
}
|
|
24
|
+
export declare const ListImagesByTagTool: typeof ListImagesByTagToolImpl & {
|
|
25
|
+
__abstraction: import("@webiny/di").Abstraction<IAiSdkTool<any>>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkTool } from "@webiny/api-core/features/ai/index.js";
|
|
3
|
+
import { ListFilesUseCase } from "../ListFiles/index.js";
|
|
4
|
+
const inputSchema = z.object({
|
|
5
|
+
tag: z.string().describe("Tag to filter images by")
|
|
6
|
+
});
|
|
7
|
+
class ListImagesByTagToolImpl {
|
|
8
|
+
constructor(listFiles){
|
|
9
|
+
this.listFiles = listFiles;
|
|
10
|
+
this.name = "listImagesByTag";
|
|
11
|
+
this.description = "Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.";
|
|
12
|
+
this.inputSchema = inputSchema;
|
|
13
|
+
}
|
|
14
|
+
async execute(input) {
|
|
15
|
+
console.log("Call images tool", input);
|
|
16
|
+
const result = await this.listFiles.execute({
|
|
17
|
+
where: {
|
|
18
|
+
type_startsWith: "image/",
|
|
19
|
+
tags_in: [
|
|
20
|
+
input.tag
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
limit: 50
|
|
24
|
+
});
|
|
25
|
+
if (result.isFail()) return [];
|
|
26
|
+
return result.value.items.map((file)=>({
|
|
27
|
+
id: file.id,
|
|
28
|
+
name: file.name,
|
|
29
|
+
type: file.type,
|
|
30
|
+
tags: file.tags
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const ListImagesByTagTool = AiSdkTool.createImplementation({
|
|
35
|
+
implementation: ListImagesByTagToolImpl,
|
|
36
|
+
dependencies: [
|
|
37
|
+
ListFilesUseCase
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
export { ListImagesByTagTool };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=ListImagesByTagTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListImagesByTagTool/ListImagesByTagTool.js","sources":["../../../../src/features/file/ListImagesByTagTool/ListImagesByTagTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkTool, type IAiSdkTool } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/index.js\";\n\nconst inputSchema = z.object({\n tag: z.string().describe(\"Tag to filter images by\")\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface ImageItem {\n id: string;\n name: string;\n type: string;\n tags: string[];\n}\n\nclass ListImagesByTagToolImpl implements IAiSdkTool<Input> {\n readonly name = \"listImagesByTag\";\n readonly description =\n \"Lists images from the file manager filtered by a given tag. Returns name, type, and tags for each image.\";\n readonly inputSchema = inputSchema;\n\n constructor(private listFiles: ListFilesUseCase.Interface) {}\n\n async execute(input: Input): Promise<ImageItem[]> {\n console.log(\"Call images tool\", input);\n const result = await this.listFiles.execute({\n where: {\n type_startsWith: \"image/\",\n tags_in: [input.tag]\n },\n limit: 50\n });\n\n if (result.isFail()) {\n return [];\n }\n\n return result.value.items.map(file => ({\n id: file.id,\n name: file.name,\n type: file.type,\n tags: file.tags\n }));\n }\n}\n\nexport const ListImagesByTagTool = AiSdkTool.createImplementation({\n implementation: ListImagesByTagToolImpl,\n dependencies: [ListFilesUseCase]\n});\n"],"names":["inputSchema","z","ListImagesByTagToolImpl","listFiles","input","console","result","file","ListImagesByTagTool","AiSdkTool","ListFilesUseCase"],"mappings":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,KAAKA,EAAE,MAAM,GAAG,QAAQ,CAAC;AAC7B;AAWA,MAAMC;IAMF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;aALX,IAAI,GAAG;aACP,WAAW,GAChB;aACK,WAAW,GAAGH;IAEqC;IAE5D,MAAM,QAAQI,KAAY,EAAwB;QAC9CC,QAAQ,GAAG,CAAC,oBAAoBD;QAChC,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YACxC,OAAO;gBACH,iBAAiB;gBACjB,SAAS;oBAACF,MAAM,GAAG;iBAAC;YACxB;YACA,OAAO;QACX;QAEA,IAAIE,OAAO,MAAM,IACb,OAAO,EAAE;QAGb,OAAOA,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAACC,CAAAA,OAAS;gBACnC,IAAIA,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;IACJ;AACJ;AAEO,MAAMC,sBAAsBC,UAAU,oBAAoB,CAAC;IAC9D,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListImagesByTagTool } from "./ListImagesByTagTool.js";
|
|
3
|
+
const ListImagesByTagToolFeature = createFeature({
|
|
4
|
+
name: "AiPowerUps/ListImagesByTagTool",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(ListImagesByTagTool);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { ListImagesByTagToolFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListImagesByTagTool/feature.js","sources":["../../../../src/features/file/ListImagesByTagTool/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListImagesByTagTool } from \"./ListImagesByTagTool.js\";\n\nexport const ListImagesByTagToolFeature = createFeature({\n name: \"AiPowerUps/ListImagesByTagTool\",\n register(container) {\n container.register(ListImagesByTagTool);\n }\n});\n"],"names":["ListImagesByTagToolFeature","createFeature","container","ListImagesByTagTool"],"mappings":";;AAGO,MAAMA,6BAA6BC,cAAc;IACpD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { GetUniqueFieldValuesUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues";
|
|
3
|
+
import { ListTagsInput, ListTagsRepository as RepositoryAbstraction, TagItem } from "./abstractions.js";
|
|
4
|
+
import { FileModel } from "../../../domain/file/abstractions.js";
|
|
5
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
6
|
+
declare class ListTagsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
|
+
private getUniqueFieldValues;
|
|
8
|
+
private fileModel;
|
|
9
|
+
private cmsWhereMapper;
|
|
10
|
+
constructor(getUniqueFieldValues: GetUniqueFieldValuesUseCase.Interface, fileModel: FileModel.Interface, cmsWhereMapper: CmsWhereMapper.Interface);
|
|
11
|
+
execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryAbstraction.Error>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const ListTagsRepository: typeof ListTagsRepositoryImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListTagsRepository>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { GetUniqueFieldValuesUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues";
|
|
3
|
+
import { ListTagsRepository } from "./abstractions.js";
|
|
4
|
+
import { FileModel } from "../../../domain/file/abstractions.js";
|
|
5
|
+
import { FilePersistenceError } from "../../../domain/file/errors.js";
|
|
6
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
7
|
+
class ListTagsRepositoryImpl {
|
|
8
|
+
constructor(getUniqueFieldValues, fileModel, cmsWhereMapper){
|
|
9
|
+
this.getUniqueFieldValues = getUniqueFieldValues;
|
|
10
|
+
this.fileModel = fileModel;
|
|
11
|
+
this.cmsWhereMapper = cmsWhereMapper;
|
|
12
|
+
}
|
|
13
|
+
async execute(input) {
|
|
14
|
+
const result = await this.getUniqueFieldValues.execute(this.fileModel, {
|
|
15
|
+
fieldId: "tags",
|
|
16
|
+
where: this.cmsWhereMapper.map({
|
|
17
|
+
input: {
|
|
18
|
+
...input.where || {},
|
|
19
|
+
latest: true
|
|
20
|
+
},
|
|
21
|
+
fields: this.fileModel.fields
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
if (result.isFail()) return Result.fail(new FilePersistenceError(result.error));
|
|
25
|
+
const tags = result.value.map((uv)=>({
|
|
26
|
+
tag: uv.value,
|
|
27
|
+
count: uv.count
|
|
28
|
+
})).sort((a, b)=>a.tag < b.tag ? -1 : 1).sort((a, b)=>a.count > b.count ? -1 : 1);
|
|
29
|
+
return Result.ok(tags);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const ListTagsRepository_ListTagsRepository = ListTagsRepository.createImplementation({
|
|
33
|
+
implementation: ListTagsRepositoryImpl,
|
|
34
|
+
dependencies: [
|
|
35
|
+
GetUniqueFieldValuesUseCase,
|
|
36
|
+
FileModel,
|
|
37
|
+
CmsWhereMapper
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
export { ListTagsRepository_ListTagsRepository as ListTagsRepository };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=ListTagsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/ListTagsRepository.js","sources":["../../../../src/features/file/ListTags/ListTagsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetUniqueFieldValuesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues\";\nimport {\n ListTagsInput,\n ListTagsRepository as RepositoryAbstraction,\n TagItem\n} from \"./abstractions.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\nimport { FilePersistenceError } from \"~/domain/file/errors.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\n\nclass ListTagsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private getUniqueFieldValues: GetUniqueFieldValuesUseCase.Interface,\n private fileModel: FileModel.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface\n ) {}\n\n async execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryAbstraction.Error>> {\n const result = await this.getUniqueFieldValues.execute(this.fileModel, {\n fieldId: \"tags\",\n // TODO fix with proper types\n // @ts-expect-error\n where: this.cmsWhereMapper.map({\n input: {\n ...(input.where || {}),\n latest: true\n },\n fields: this.fileModel.fields\n })\n });\n\n if (result.isFail()) {\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n // Map to TagItem format\n const tags: TagItem[] = result.value\n .map(uv => ({\n tag: uv.value as string,\n count: uv.count\n }))\n // Sort by tag name alphabetically\n .sort((a, b) => (a.tag < b.tag ? -1 : 1))\n // Then sort by count descending (most used first)\n .sort((a, b) => (a.count > b.count ? -1 : 1));\n\n return Result.ok(tags);\n }\n}\n\nexport const ListTagsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListTagsRepositoryImpl,\n dependencies: [GetUniqueFieldValuesUseCase, FileModel, CmsWhereMapper]\n});\n"],"names":["ListTagsRepositoryImpl","getUniqueFieldValues","fileModel","cmsWhereMapper","input","result","Result","FilePersistenceError","tags","uv","a","b","ListTagsRepository","RepositoryAbstraction","GetUniqueFieldValuesUseCase","FileModel","CmsWhereMapper"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACYC,oBAA2D,EAC3DC,SAA8B,EAC9BC,cAAwC,CAClD;aAHUF,oBAAoB,GAApBA;aACAC,SAAS,GAATA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,KAAoB,EAA2D;QACzF,MAAMC,SAAS,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;YACnE,SAAS;YAGT,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC3B,OAAO;oBACH,GAAID,MAAM,KAAK,IAAI,CAAC,CAAC;oBACrB,QAAQ;gBACZ;gBACA,QAAQ,IAAI,CAAC,SAAS,CAAC,MAAM;YACjC;QACJ;QAEA,IAAIC,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,qBAAqBF,OAAO,KAAK;QAI5D,MAAMG,OAAkBH,OAAO,KAAK,CAC/B,GAAG,CAACI,CAAAA,KAAO;gBACR,KAAKA,GAAG,KAAK;gBACb,OAAOA,GAAG,KAAK;YACnB,IAEC,IAAI,CAAC,CAACC,GAAGC,IAAOD,EAAE,GAAG,GAAGC,EAAE,GAAG,GAAG,KAAK,GAErC,IAAI,CAAC,CAACD,GAAGC,IAAOD,EAAE,KAAK,GAAGC,EAAE,KAAK,GAAG,KAAK;QAE9C,OAAOL,OAAO,EAAE,CAACE;IACrB;AACJ;AAEO,MAAMI,wCAAqBC,mBAAAA,oBAA0C,CAAC;IACzE,gBAAgBb;IAChB,cAAc;QAACc;QAA6BC;QAAWC;KAAe;AAC1E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ListTagsUseCase as UseCaseAbstraction, ListTagsInput, TagItem, ListTagsRepository } from "./abstractions.js";
|
|
3
|
+
import { FmPermissions } from "../../../features/shared/abstractions.js";
|
|
4
|
+
declare class ListTagsUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
5
|
+
private permissions;
|
|
6
|
+
private repository;
|
|
7
|
+
constructor(permissions: FmPermissions.Interface, repository: ListTagsRepository.Interface);
|
|
8
|
+
execute(input: ListTagsInput): Promise<Result<TagItem[], UseCaseAbstraction.Error>>;
|
|
9
|
+
}
|
|
10
|
+
export declare const ListTagsUseCase: typeof ListTagsUseCaseImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IListTagsUseCase>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { ListTagsRepository, ListTagsUseCase } from "./abstractions.js";
|
|
3
|
+
import { FileNotAuthorizedError } from "../../../domain/file/errors.js";
|
|
4
|
+
import { FmPermissions } from "../../shared/abstractions.js";
|
|
5
|
+
class ListTagsUseCaseImpl {
|
|
6
|
+
constructor(permissions, repository){
|
|
7
|
+
this.permissions = permissions;
|
|
8
|
+
this.repository = repository;
|
|
9
|
+
}
|
|
10
|
+
async execute(input) {
|
|
11
|
+
const hasPermission = await this.permissions.canAccess("file");
|
|
12
|
+
if (!hasPermission) return Result.fail(new FileNotAuthorizedError());
|
|
13
|
+
const enrichedInput = {
|
|
14
|
+
...input,
|
|
15
|
+
limit: input.limit || 1000000
|
|
16
|
+
};
|
|
17
|
+
const result = await this.repository.execute(enrichedInput);
|
|
18
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
19
|
+
return Result.ok(result.value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const ListTagsUseCase_ListTagsUseCase = ListTagsUseCase.createImplementation({
|
|
23
|
+
implementation: ListTagsUseCaseImpl,
|
|
24
|
+
dependencies: [
|
|
25
|
+
FmPermissions,
|
|
26
|
+
ListTagsRepository
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { ListTagsUseCase_ListTagsUseCase as ListTagsUseCase };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=ListTagsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/ListTagsUseCase.js","sources":["../../../../src/features/file/ListTags/ListTagsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListTagsUseCase as UseCaseAbstraction,\n ListTagsInput,\n TagItem,\n ListTagsRepository\n} from \"./abstractions.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\n\nclass ListTagsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private repository: ListTagsRepository.Interface\n ) {}\n\n async execute(input: ListTagsInput): Promise<Result<TagItem[], UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canAccess(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const enrichedInput: ListTagsInput = {\n ...input,\n limit: input.limit || 1000000\n };\n\n const result = await this.repository.execute(enrichedInput);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const ListTagsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListTagsUseCaseImpl,\n dependencies: [FmPermissions, ListTagsRepository]\n});\n"],"names":["ListTagsUseCaseImpl","permissions","repository","input","hasPermission","Result","FileNotAuthorizedError","enrichedInput","result","ListTagsUseCase","UseCaseAbstraction","FmPermissions","ListTagsRepository"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAAoC,EACpCC,UAAwC,CAClD;aAFUD,WAAW,GAAXA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,KAAoB,EAAwD;QACtF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;QACvD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,gBAA+B;YACjC,GAAGJ,KAAK;YACR,OAAOA,MAAM,KAAK,IAAI;QAC1B;QAEA,MAAMK,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD;QAE7C,IAAIC,OAAO,MAAM,IACb,OAAOH,OAAO,IAAI,CAACG,OAAO,KAAK;QAGnC,OAAOH,OAAO,EAAE,CAACG,OAAO,KAAK;IACjC;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAAuC,CAAC;IACnE,gBAAgBV;IAChB,cAAc;QAACW;QAAeC;KAAmB;AACrD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Result } from "@webiny/feature/api";
|
|
2
|
+
import { type FilePersistenceError, FileNotAuthorizedError } from "../../../domain/file/errors.js";
|
|
3
|
+
export interface ListTagsInput {
|
|
4
|
+
where?: Record<string, any>;
|
|
5
|
+
after?: string | null;
|
|
6
|
+
limit?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TagItem {
|
|
9
|
+
tag: string;
|
|
10
|
+
count: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ListTags repository interface
|
|
14
|
+
*/
|
|
15
|
+
export interface IListTagsRepository {
|
|
16
|
+
execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryError>>;
|
|
17
|
+
}
|
|
18
|
+
export interface IListTagsRepositoryErrors {
|
|
19
|
+
persistence: FilePersistenceError;
|
|
20
|
+
}
|
|
21
|
+
type RepositoryError = IListTagsRepositoryErrors[keyof IListTagsRepositoryErrors];
|
|
22
|
+
/** Fetch file tags from storage. */
|
|
23
|
+
export declare const ListTagsRepository: import("@webiny/di").Abstraction<IListTagsRepository>;
|
|
24
|
+
export declare namespace ListTagsRepository {
|
|
25
|
+
type Interface = IListTagsRepository;
|
|
26
|
+
type Error = RepositoryError;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* ListTags use case interface
|
|
30
|
+
*/
|
|
31
|
+
export interface IListTagsUseCase {
|
|
32
|
+
execute(input: ListTagsInput): Promise<Result<TagItem[], UseCaseError>>;
|
|
33
|
+
}
|
|
34
|
+
export interface IListTagsUseCaseErrors {
|
|
35
|
+
notAuthorized: FileNotAuthorizedError;
|
|
36
|
+
persistence: FilePersistenceError;
|
|
37
|
+
}
|
|
38
|
+
type UseCaseError = IListTagsUseCaseErrors[keyof IListTagsUseCaseErrors];
|
|
39
|
+
/** List all file tags. */
|
|
40
|
+
export declare const ListTagsUseCase: import("@webiny/di").Abstraction<IListTagsUseCase>;
|
|
41
|
+
export declare namespace ListTagsUseCase {
|
|
42
|
+
type Interface = IListTagsUseCase;
|
|
43
|
+
type Error = UseCaseError;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const ListTagsRepository = createAbstraction("ListTagsRepository");
|
|
3
|
+
const ListTagsUseCase = createAbstraction("ListTagsUseCase");
|
|
4
|
+
export { ListTagsRepository, ListTagsUseCase };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/abstractions.js","sources":["../../../../src/features/file/ListTags/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport { type FilePersistenceError, FileNotAuthorizedError } from \"~/domain/file/errors.js\";\n\nexport interface ListTagsInput {\n where?: Record<string, any>;\n after?: string | null;\n limit?: number;\n}\n\nexport interface TagItem {\n tag: string;\n count: number;\n}\n\n/**\n * ListTags repository interface\n */\nexport interface IListTagsRepository {\n execute(input: ListTagsInput): Promise<Result<TagItem[], RepositoryError>>;\n}\n\nexport interface IListTagsRepositoryErrors {\n persistence: FilePersistenceError;\n}\n\ntype RepositoryError = IListTagsRepositoryErrors[keyof IListTagsRepositoryErrors];\n\n/** Fetch file tags from storage. */\nexport const ListTagsRepository = createAbstraction<IListTagsRepository>(\"ListTagsRepository\");\n\nexport namespace ListTagsRepository {\n export type Interface = IListTagsRepository;\n export type Error = RepositoryError;\n}\n\n/**\n * ListTags use case interface\n */\nexport interface IListTagsUseCase {\n execute(input: ListTagsInput): Promise<Result<TagItem[], UseCaseError>>;\n}\n\nexport interface IListTagsUseCaseErrors {\n notAuthorized: FileNotAuthorizedError;\n persistence: FilePersistenceError;\n}\n\ntype UseCaseError = IListTagsUseCaseErrors[keyof IListTagsUseCaseErrors];\n\n/** List all file tags. */\nexport const ListTagsUseCase = createAbstraction<IListTagsUseCase>(\"ListTagsUseCase\");\n\nexport namespace ListTagsUseCase {\n export type Interface = IListTagsUseCase;\n export type Error = UseCaseError;\n}\n"],"names":["ListTagsRepository","createAbstraction","ListTagsUseCase"],"mappings":";AA6BO,MAAMA,qBAAqBC,kBAAuC;AAsBlE,MAAMC,kBAAkBD,kBAAoC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListTagsRepository } from "./ListTagsRepository.js";
|
|
3
|
+
import { ListTagsUseCase } from "./ListTagsUseCase.js";
|
|
4
|
+
const ListTagsFeature = createFeature({
|
|
5
|
+
name: "FileManager/ListTags",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListTagsUseCase);
|
|
8
|
+
container.register(ListTagsRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { ListTagsFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/ListTags/feature.js","sources":["../../../../src/features/file/ListTags/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListTagsRepository } from \"./ListTagsRepository.js\";\nimport { ListTagsUseCase } from \"./ListTagsUseCase.js\";\n\nexport const ListTagsFeature = createFeature({\n name: \"FileManager/ListTags\",\n register(container) {\n container.register(ListTagsUseCase);\n container.register(ListTagsRepository).inSingletonScope();\n }\n});\n"],"names":["ListTagsFeature","createFeature","container","ListTagsUseCase","ListTagsRepository"],"mappings":";;;AAIO,MAAMA,kBAAkBC,cAAc;IACzC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,oBAAoB,gBAAgB;IAC3D;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListTagsUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListTagsUseCase } from "./abstractions.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
|
|
3
|
+
import { UpdateFileRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
+
import { FileModel } from "../../../domain/file/abstractions.js";
|
|
5
|
+
import type { File } from "../../../domain/file/types.js";
|
|
6
|
+
declare class UpdateFileRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
|
+
private updateEntry;
|
|
8
|
+
private fileModel;
|
|
9
|
+
constructor(updateEntry: UpdateEntryUseCase.Interface, fileModel: FileModel.Interface);
|
|
10
|
+
update(file: File): Promise<Result<void, RepositoryAbstraction.Error>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const UpdateFileRepository: typeof UpdateFileRepositoryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateFileRepository>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
|
|
3
|
+
import { UpdateFileRepository } from "./abstractions.js";
|
|
4
|
+
import { FileModel } from "../../../domain/file/abstractions.js";
|
|
5
|
+
import { FileNotAuthorizedError, FileNotFoundError, FilePersistenceError } from "../../../domain/file/errors.js";
|
|
6
|
+
import { FileToEntryMapper } from "../shared/FileToEntryMapper.js";
|
|
7
|
+
class UpdateFileRepositoryImpl {
|
|
8
|
+
constructor(updateEntry, fileModel){
|
|
9
|
+
this.updateEntry = updateEntry;
|
|
10
|
+
this.fileModel = fileModel;
|
|
11
|
+
}
|
|
12
|
+
async update(file) {
|
|
13
|
+
const entry = FileToEntryMapper.toEntry(file);
|
|
14
|
+
const id = `${file.id}#0001`;
|
|
15
|
+
const result = await this.updateEntry.execute(this.fileModel, id, {
|
|
16
|
+
wbyAco_location: file.location,
|
|
17
|
+
values: entry.values
|
|
18
|
+
});
|
|
19
|
+
if (result.isFail()) {
|
|
20
|
+
const error = result.error;
|
|
21
|
+
if ("Cms/Entry/NotFound" === error.code) return Result.fail(new FileNotFoundError(id));
|
|
22
|
+
if ("Cms/Entry/NotAuthorized" === error.code) return Result.fail(new FileNotAuthorizedError());
|
|
23
|
+
return Result.fail(new FilePersistenceError(result.error));
|
|
24
|
+
}
|
|
25
|
+
return Result.ok();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const UpdateFileRepository_UpdateFileRepository = UpdateFileRepository.createImplementation({
|
|
29
|
+
implementation: UpdateFileRepositoryImpl,
|
|
30
|
+
dependencies: [
|
|
31
|
+
UpdateEntryUseCase,
|
|
32
|
+
FileModel
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
export { UpdateFileRepository_UpdateFileRepository as UpdateFileRepository };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=UpdateFileRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/file/UpdateFile/UpdateFileRepository.js","sources":["../../../../src/features/file/UpdateFile/UpdateFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { UpdateFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\nimport type { File } from \"~/domain/file/types.js\";\nimport {\n FileNotAuthorizedError,\n FileNotFoundError,\n FilePersistenceError\n} from \"~/domain/file/errors.js\";\nimport { FileToEntryMapper } from \"../shared/FileToEntryMapper.js\";\n\nclass UpdateFileRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private updateEntry: UpdateEntryUseCase.Interface,\n private fileModel: FileModel.Interface\n ) {}\n\n async update(file: File): Promise<Result<void, RepositoryAbstraction.Error>> {\n const entry = FileToEntryMapper.toEntry(file);\n\n // Files are not versioned, so we're always updating the same revision\n const id = `${file.id}#0001`;\n\n const result = await this.updateEntry.execute(this.fileModel, id, {\n wbyAco_location: file.location,\n values: entry.values\n });\n\n if (result.isFail()) {\n const error = result.error;\n if (error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new FileNotFoundError(id));\n }\n\n if (error.code === \"Cms/Entry/NotAuthorized\") {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n return Result.ok();\n }\n}\n\nexport const UpdateFileRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateFileRepositoryImpl,\n dependencies: [UpdateEntryUseCase, FileModel]\n});\n"],"names":["UpdateFileRepositoryImpl","updateEntry","fileModel","file","entry","FileToEntryMapper","id","result","error","Result","FileNotFoundError","FileNotAuthorizedError","FilePersistenceError","UpdateFileRepository","RepositoryAbstraction","UpdateEntryUseCase","FileModel"],"mappings":";;;;;;AAYA,MAAMA;IACF,YACYC,WAAyC,EACzCC,SAA8B,CACxC;aAFUD,WAAW,GAAXA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,OAAOC,IAAU,EAAsD;QACzE,MAAMC,QAAQC,kBAAkB,OAAO,CAACF;QAGxC,MAAMG,KAAK,GAAGH,KAAK,EAAE,CAAC,KAAK,CAAC;QAE5B,MAAMI,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAED,IAAI;YAC9D,iBAAiBH,KAAK,QAAQ;YAC9B,QAAQC,MAAM,MAAM;QACxB;QAEA,IAAIG,OAAO,MAAM,IAAI;YACjB,MAAMC,QAAQD,OAAO,KAAK;YAC1B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAOC,OAAO,IAAI,CAAC,IAAIC,kBAAkBJ;YAG7C,IAAIE,AAAe,8BAAfA,MAAM,IAAI,EACV,OAAOC,OAAO,IAAI,CAAC,IAAIE;YAG3B,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBL,OAAO,KAAK;QAC5D;QAEA,OAAOE,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMI,4CAAuBC,qBAAAA,oBAA0C,CAAC;IAC3E,gBAAgBd;IAChB,cAAc;QAACe;QAAoBC;KAAU;AACjD"}
|