@webiny/api-file-manager 0.0.0-unstable.6f45466a1d → 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/contants.js +2 -1
- package/contants.js.map +1 -1
- package/delivery/AssetDelivery/Asset.js +50 -56
- package/delivery/AssetDelivery/Asset.js.map +1 -1
- package/delivery/AssetDelivery/AssetRequest.js +20 -19
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
- package/delivery/AssetDelivery/abstractions/AssetReply.js +28 -27
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +4 -5
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -1
- package/delivery/index.d.ts +3 -12
- package/delivery/index.js +2 -8
- package/delivery/setupAssetDelivery.d.ts +1 -2
- package/delivery/setupAssetDelivery.js +60 -105
- package/delivery/setupAssetDelivery.js.map +1 -1
- package/domain/file/abstractions.js +2 -5
- package/domain/file/abstractions.js.map +1 -1
- package/domain/file/errors.js +67 -76
- package/domain/file/errors.js.map +1 -1
- package/domain/file/file.model.js +57 -45
- package/domain/file/file.model.js.map +1 -1
- package/domain/file/types.d.ts +2 -0
- package/domain/file/types.js +0 -3
- package/domain/identity/Identity.js +9 -8
- package/domain/identity/Identity.js.map +1 -1
- package/domain/permissionsSchema.d.ts +16 -0
- package/domain/permissionsSchema.js +30 -0
- package/domain/permissionsSchema.js.map +1 -0
- package/domain/settings/constants.js +2 -1
- package/domain/settings/constants.js.map +1 -1
- package/domain/settings/errors.js +22 -24
- package/domain/settings/errors.js.map +1 -1
- package/domain/settings/types.js +0 -3
- package/domain/settings/validation.d.ts +4 -12
- package/domain/settings/validation.js +18 -27
- package/domain/settings/validation.js.map +1 -1
- 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 -1
- package/features/FileManagerFeature.js +17 -14
- package/features/FileManagerFeature.js.map +1 -1
- 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.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.js +20 -18
- package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
- package/features/file/CreateFile/CreateFileUseCase.d.ts +4 -4
- package/features/file/CreateFile/CreateFileUseCase.js +70 -78
- package/features/file/CreateFile/CreateFileUseCase.js.map +1 -1
- package/features/file/CreateFile/abstractions.d.ts +3 -0
- package/features/file/CreateFile/abstractions.js +3 -12
- package/features/file/CreateFile/abstractions.js.map +1 -1
- package/features/file/CreateFile/events.d.ts +8 -6
- package/features/file/CreateFile/events.js +18 -23
- package/features/file/CreateFile/events.js.map +1 -1
- package/features/file/CreateFile/feature.d.ts +4 -1
- package/features/file/CreateFile/feature.js +7 -6
- package/features/file/CreateFile/feature.js.map +1 -1
- package/features/file/CreateFile/index.d.ts +1 -1
- package/features/file/CreateFile/index.js +1 -3
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +15 -17
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -1
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.d.ts +4 -4
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +61 -75
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -1
- package/features/file/CreateFilesInBatch/abstractions.d.ts +2 -0
- package/features/file/CreateFilesInBatch/abstractions.js +3 -12
- package/features/file/CreateFilesInBatch/abstractions.js.map +1 -1
- package/features/file/CreateFilesInBatch/events.d.ts +8 -6
- package/features/file/CreateFilesInBatch/events.js +18 -23
- package/features/file/CreateFilesInBatch/events.js.map +1 -1
- package/features/file/CreateFilesInBatch/feature.d.ts +4 -1
- package/features/file/CreateFilesInBatch/feature.js +7 -6
- package/features/file/CreateFilesInBatch/feature.js.map +1 -1
- package/features/file/CreateFilesInBatch/index.js +0 -2
- package/features/file/DeleteFile/DeleteFileRepository.js +21 -20
- package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
- package/features/file/DeleteFile/DeleteFileUseCase.d.ts +4 -4
- package/features/file/DeleteFile/DeleteFileUseCase.js +33 -38
- package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -1
- package/features/file/DeleteFile/abstractions.d.ts +2 -0
- package/features/file/DeleteFile/abstractions.js +3 -12
- package/features/file/DeleteFile/abstractions.js.map +1 -1
- package/features/file/DeleteFile/events.d.ts +8 -6
- package/features/file/DeleteFile/events.js +18 -23
- package/features/file/DeleteFile/events.js.map +1 -1
- package/features/file/DeleteFile/feature.d.ts +4 -1
- package/features/file/DeleteFile/feature.js +7 -6
- package/features/file/DeleteFile/feature.js.map +1 -1
- package/features/file/DeleteFile/index.d.ts +1 -1
- package/features/file/DeleteFile/index.js +1 -3
- package/features/file/FileUrlGenerator/abstractions.d.ts +1 -0
- package/features/file/FileUrlGenerator/abstractions.js +2 -1
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
- package/features/file/GetFile/GetFileRepository.js +22 -22
- package/features/file/GetFile/GetFileRepository.js.map +1 -1
- package/features/file/GetFile/GetFileUseCase.d.ts +3 -3
- package/features/file/GetFile/GetFileUseCase.js +20 -30
- package/features/file/GetFile/GetFileUseCase.js.map +1 -1
- package/features/file/GetFile/abstractions.d.ts +2 -0
- package/features/file/GetFile/abstractions.js +3 -12
- package/features/file/GetFile/abstractions.js.map +1 -1
- package/features/file/GetFile/feature.d.ts +4 -1
- package/features/file/GetFile/feature.js +7 -6
- package/features/file/GetFile/feature.js.map +1 -1
- package/features/file/GetFile/index.js +0 -2
- 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 +3 -1
- package/features/file/ListFiles/ListFilesRepository.js +42 -34
- package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
- package/features/file/ListFiles/ListFilesUseCase.d.ts +4 -4
- package/features/file/ListFiles/ListFilesUseCase.js +35 -39
- package/features/file/ListFiles/ListFilesUseCase.js.map +1 -1
- package/features/file/ListFiles/abstractions.d.ts +2 -0
- package/features/file/ListFiles/abstractions.js +3 -12
- package/features/file/ListFiles/abstractions.js.map +1 -1
- package/features/file/ListFiles/feature.d.ts +4 -1
- package/features/file/ListFiles/feature.js +7 -6
- package/features/file/ListFiles/feature.js.map +1 -1
- package/features/file/ListFiles/index.js +0 -2
- 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.js +31 -36
- package/features/file/ListTags/ListTagsRepository.js.map +1 -1
- package/features/file/ListTags/ListTagsUseCase.d.ts +3 -3
- package/features/file/ListTags/ListTagsUseCase.js +22 -23
- package/features/file/ListTags/ListTagsUseCase.js.map +1 -1
- package/features/file/ListTags/abstractions.d.ts +2 -0
- package/features/file/ListTags/abstractions.js +3 -12
- package/features/file/ListTags/abstractions.js.map +1 -1
- package/features/file/ListTags/feature.d.ts +4 -1
- package/features/file/ListTags/feature.js +7 -6
- package/features/file/ListTags/feature.js.map +1 -1
- package/features/file/ListTags/index.js +0 -2
- package/features/file/UpdateFile/UpdateFileRepository.js +26 -28
- package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
- package/features/file/UpdateFile/UpdateFileUseCase.d.ts +5 -5
- package/features/file/UpdateFile/UpdateFileUseCase.js +60 -70
- package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -1
- package/features/file/UpdateFile/abstractions.d.ts +3 -0
- package/features/file/UpdateFile/abstractions.js +3 -12
- package/features/file/UpdateFile/abstractions.js.map +1 -1
- package/features/file/UpdateFile/events.d.ts +8 -6
- package/features/file/UpdateFile/events.js +18 -23
- package/features/file/UpdateFile/events.js.map +1 -1
- package/features/file/UpdateFile/feature.d.ts +4 -1
- package/features/file/UpdateFile/feature.js +7 -6
- package/features/file/UpdateFile/feature.js.map +1 -1
- package/features/file/UpdateFile/index.d.ts +1 -1
- package/features/file/UpdateFile/index.js +1 -3
- package/features/file/shared/EntryToFileMapper.js +25 -23
- package/features/file/shared/EntryToFileMapper.js.map +1 -1
- package/features/file/shared/FileInputToEntryInputMapper.js +29 -27
- package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -1
- package/features/file/shared/FileToEntryMapper.js +28 -26
- package/features/file/shared/FileToEntryMapper.js.map +1 -1
- 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.js +19 -19
- package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/settings/GetSettings/abstractions.d.ts +1 -0
- package/features/settings/GetSettings/abstractions.js +2 -6
- package/features/settings/GetSettings/abstractions.js.map +1 -1
- package/features/settings/GetSettings/feature.d.ts +4 -1
- package/features/settings/GetSettings/feature.js +6 -5
- package/features/settings/GetSettings/feature.js.map +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.d.ts +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js +26 -25
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
- package/features/settings/SettingsInstaller/feature.d.ts +4 -1
- package/features/settings/SettingsInstaller/feature.js +6 -5
- package/features/settings/SettingsInstaller/feature.js.map +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.d.ts +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +42 -49
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
- package/features/settings/UpdateSettings/abstractions.d.ts +1 -0
- package/features/settings/UpdateSettings/abstractions.js +2 -6
- package/features/settings/UpdateSettings/abstractions.js.map +1 -1
- package/features/settings/UpdateSettings/events.d.ts +8 -6
- package/features/settings/UpdateSettings/events.js +18 -23
- package/features/settings/UpdateSettings/events.js.map +1 -1
- package/features/settings/UpdateSettings/feature.d.ts +4 -1
- package/features/settings/UpdateSettings/feature.js +6 -5
- package/features/settings/UpdateSettings/feature.js.map +1 -1
- package/features/settings/UpdateSettings/index.d.ts +1 -1
- package/features/settings/UpdateSettings/index.js +1 -3
- package/features/shared/abstractions.d.ts +1 -13
- package/features/shared/abstractions.js +1 -5
- package/graphql/baseSchema.js +30 -33
- package/graphql/baseSchema.js.map +1 -1
- package/graphql/createFilesTypeDefs.d.ts +3 -2
- package/graphql/createFilesTypeDefs.js +61 -66
- package/graphql/createFilesTypeDefs.js.map +1 -1
- package/graphql/filesSchema.js +79 -99
- package/graphql/filesSchema.js.map +1 -1
- package/graphql/getFileByUrl.js +45 -53
- package/graphql/getFileByUrl.js.map +1 -1
- package/graphql/index.js +37 -43
- package/graphql/index.js.map +1 -1
- package/graphql/utils.js +9 -14
- package/graphql/utils.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +31 -39
- package/index.js.map +1 -1
- package/modelModifier/CmsModelModifier.js +40 -43
- package/modelModifier/CmsModelModifier.js.map +1 -1
- package/package.json +28 -23
- package/types.d.ts +1 -3
- package/types.js +1 -3
- package/delivery/AssetDelivery/AssetDeliveryConfig.d.ts +0 -65
- package/delivery/AssetDelivery/AssetDeliveryConfig.js +0 -94
- package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +0 -1
- package/delivery/AssetDelivery/FilesAssetRequestResolver.d.ts +0 -6
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js +0 -30
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +0 -1
- package/delivery/AssetDelivery/NullAssetOutputStrategy.d.ts +0 -4
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js +0 -8
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +0 -1
- package/delivery/AssetDelivery/NullAssetReply.js +0 -13
- package/delivery/AssetDelivery/NullAssetReply.js.map +0 -1
- package/delivery/AssetDelivery/NullAssetResolver.d.ts +0 -5
- package/delivery/AssetDelivery/NullAssetResolver.js +0 -7
- package/delivery/AssetDelivery/NullAssetResolver.js.map +0 -1
- package/delivery/AssetDelivery/NullRequestResolver.d.ts +0 -4
- package/delivery/AssetDelivery/NullRequestResolver.js +0 -7
- package/delivery/AssetDelivery/NullRequestResolver.js.map +0 -1
- package/delivery/AssetDelivery/SetCacheControlHeaders.d.ts +0 -8
- package/delivery/AssetDelivery/SetCacheControlHeaders.js +0 -18
- package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +0 -1
- package/delivery/AssetDelivery/SetResponseHeaders.d.ts +0 -18
- package/delivery/AssetDelivery/SetResponseHeaders.js +0 -18
- package/delivery/AssetDelivery/SetResponseHeaders.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.d.ts +0 -4
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.d.ts +0 -4
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetProcessor.d.ts +0 -4
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.d.ts +0 -5
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetResolver.d.ts +0 -4
- package/delivery/AssetDelivery/abstractions/AssetResolver.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.d.ts +0 -4
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.d.ts +0 -4
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +0 -3
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +0 -4
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +0 -19
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +0 -4
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +0 -8
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +0 -8
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +0 -20
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/PrivateCache.d.ts +0 -6
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js +0 -21
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +0 -8
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +0 -30
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +0 -13
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +0 -63
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +0 -6
- package/delivery/AssetDelivery/privateFiles/PublicCache.js +0 -21
- package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +0 -7
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +0 -20
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +0 -7
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +0 -20
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +0 -1
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.d.ts +0 -4
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +0 -7
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +0 -1
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +0 -4
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +0 -7
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +0 -1
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.d.ts +0 -6
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +0 -19
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +0 -1
- package/delivery/index.js.map +0 -1
- package/domain/file/types.js.map +0 -1
- package/domain/settings/types.js.map +0 -1
- package/features/file/CreateFile/index.js.map +0 -1
- package/features/file/CreateFilesInBatch/index.js.map +0 -1
- package/features/file/DeleteFile/index.js.map +0 -1
- package/features/file/GetFile/index.js.map +0 -1
- package/features/file/ListFiles/index.js.map +0 -1
- package/features/file/ListTags/index.js.map +0 -1
- package/features/file/UpdateFile/index.js.map +0 -1
- package/features/settings/UpdateSettings/index.js.map +0 -1
- package/features/shared/abstractions.js.map +0 -1
- package/permissions/FilesPermissions.d.ts +0 -4
- package/permissions/FilesPermissions.js +0 -4
- package/permissions/FilesPermissions.js.map +0 -1
- package/permissions/SettingsPermissions.d.ts +0 -4
- package/permissions/SettingsPermissions.js +0 -4
- package/permissions/SettingsPermissions.js.map +0 -1
- package/types.js.map +0 -1
- /package/{delivery/AssetDelivery → features/assetDelivery}/NullAssetReply.d.ts +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
|
+
import { GetFileUseCase } from "../../file/GetFile/index.js";
|
|
3
|
+
import { NotAuthorizedOutputStrategy } from "./NotAuthorizedOutputStrategy.js";
|
|
4
|
+
import { RedirectToPublicUrlOutputStrategy } from "./RedirectToPublicUrlOutputStrategy.js";
|
|
5
|
+
import { RedirectToPrivateUrlOutputStrategy } from "./RedirectToPrivateUrlOutputStrategy.js";
|
|
6
|
+
import { PrivateCache } from "./PrivateCache.js";
|
|
7
|
+
import { PublicCache } from "./PublicCache.js";
|
|
8
|
+
import { AssetAuthorizer, AssetProcessor } from "../abstractions.js";
|
|
9
|
+
class PrivateFilesAssetProcessor {
|
|
10
|
+
constructor(identityContext, getFile, assetAuthorizer, assetProcessor){
|
|
11
|
+
this.identityContext = identityContext;
|
|
12
|
+
this.getFile = getFile;
|
|
13
|
+
this.assetAuthorizer = assetAuthorizer;
|
|
14
|
+
this.assetProcessor = assetProcessor;
|
|
15
|
+
}
|
|
16
|
+
async process(assetRequest, asset) {
|
|
17
|
+
const id = asset.getId();
|
|
18
|
+
const file = await this.identityContext.withoutAuthorization(async ()=>{
|
|
19
|
+
const fileResult = await this.getFile.execute(id);
|
|
20
|
+
if (fileResult.isFail()) throw fileResult.error;
|
|
21
|
+
return fileResult.value;
|
|
22
|
+
});
|
|
23
|
+
const isPrivateFile = this.isPrivate(file);
|
|
24
|
+
if (!isPrivateFile && this.requestedViaPrivateEndpoint(assetRequest)) {
|
|
25
|
+
asset.setOutputStrategy(new RedirectToPublicUrlOutputStrategy(assetRequest));
|
|
26
|
+
return asset;
|
|
27
|
+
}
|
|
28
|
+
if (isPrivateFile && this.requestedViaPublicEndpoint(assetRequest)) {
|
|
29
|
+
asset.setOutputStrategy(new RedirectToPrivateUrlOutputStrategy(assetRequest));
|
|
30
|
+
return asset;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
await this.assetAuthorizer.authorize(file);
|
|
34
|
+
} catch {
|
|
35
|
+
asset.setOutputStrategy(new NotAuthorizedOutputStrategy());
|
|
36
|
+
return asset;
|
|
37
|
+
}
|
|
38
|
+
const processedAsset = await this.assetProcessor.process(assetRequest, asset);
|
|
39
|
+
processedAsset.setOutputStrategy((strategy)=>{
|
|
40
|
+
if (!strategy) throw Error("No asset output strategy is configured!");
|
|
41
|
+
return isPrivateFile ? new PrivateCache(strategy) : new PublicCache(strategy);
|
|
42
|
+
});
|
|
43
|
+
return processedAsset;
|
|
44
|
+
}
|
|
45
|
+
isPrivate(file) {
|
|
46
|
+
return file.accessControl && file.accessControl.type.startsWith("private-");
|
|
47
|
+
}
|
|
48
|
+
requestedViaPrivateEndpoint(assetRequest) {
|
|
49
|
+
return assetRequest.getContext().private;
|
|
50
|
+
}
|
|
51
|
+
requestedViaPublicEndpoint(assetRequest) {
|
|
52
|
+
return !this.requestedViaPrivateEndpoint(assetRequest);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const PrivateFilesAssetProcessorDecorator = AssetProcessor.createDecorator({
|
|
56
|
+
decorator: PrivateFilesAssetProcessor,
|
|
57
|
+
dependencies: [
|
|
58
|
+
IdentityContext,
|
|
59
|
+
GetFileUseCase,
|
|
60
|
+
AssetAuthorizer
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
export { PrivateFilesAssetProcessor, PrivateFilesAssetProcessorDecorator };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=PrivateFilesAssetProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.ts"],"sourcesContent":["import type { File } from \"~/domain/file/types.js\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { GetFileUseCase } from \"~/features/file/GetFile/index.js\";\nimport { NotAuthorizedOutputStrategy } from \"./NotAuthorizedOutputStrategy.js\";\nimport { RedirectToPublicUrlOutputStrategy } from \"./RedirectToPublicUrlOutputStrategy.js\";\nimport { RedirectToPrivateUrlOutputStrategy } from \"./RedirectToPrivateUrlOutputStrategy.js\";\nimport { PrivateCache } from \"./PrivateCache.js\";\nimport { PublicCache } from \"./PublicCache.js\";\nimport {\n AssetProcessor,\n AssetAuthorizer,\n type IAssetProcessor,\n type IAssetAuthorizer\n} from \"../abstractions.js\";\n\ninterface MaybePrivate {\n private?: boolean;\n}\n\nexport class PrivateFilesAssetProcessor implements IAssetProcessor {\n private readonly identityContext: IdentityContext.Interface;\n private readonly getFile: GetFileUseCase.Interface;\n private readonly assetAuthorizer: IAssetAuthorizer;\n private readonly assetProcessor: IAssetProcessor;\n\n constructor(\n identityContext: IdentityContext.Interface,\n getFile: GetFileUseCase.Interface,\n assetAuthorizer: IAssetAuthorizer,\n assetProcessor: IAssetProcessor\n ) {\n this.identityContext = identityContext;\n this.getFile = getFile;\n this.assetAuthorizer = assetAuthorizer;\n this.assetProcessor = assetProcessor;\n }\n\n async process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n const id = asset.getId();\n\n const file = await this.identityContext.withoutAuthorization(async () => {\n const fileResult = await this.getFile.execute(id);\n if (fileResult.isFail()) {\n throw fileResult.error;\n }\n return fileResult.value;\n });\n\n const isPrivateFile = this.isPrivate(file);\n\n if (!isPrivateFile && this.requestedViaPrivateEndpoint(assetRequest)) {\n asset.setOutputStrategy(new RedirectToPublicUrlOutputStrategy(assetRequest));\n return asset;\n }\n\n if (isPrivateFile && this.requestedViaPublicEndpoint(assetRequest)) {\n asset.setOutputStrategy(new RedirectToPrivateUrlOutputStrategy(assetRequest));\n return asset;\n }\n\n try {\n await this.assetAuthorizer.authorize(file);\n } catch {\n asset.setOutputStrategy(new NotAuthorizedOutputStrategy());\n return asset;\n }\n\n const processedAsset = await this.assetProcessor.process(assetRequest, asset);\n\n processedAsset.setOutputStrategy(strategy => {\n if (!strategy) {\n throw Error(`No asset output strategy is configured!`);\n }\n return isPrivateFile ? new PrivateCache(strategy) : new PublicCache(strategy);\n });\n\n return processedAsset;\n }\n\n private isPrivate(file: File) {\n return file.accessControl && file.accessControl.type.startsWith(\"private-\");\n }\n\n private requestedViaPrivateEndpoint(assetRequest: AssetRequest) {\n return assetRequest.getContext<MaybePrivate>().private;\n }\n\n private requestedViaPublicEndpoint(assetRequest: AssetRequest) {\n return !this.requestedViaPrivateEndpoint(assetRequest);\n }\n}\n\nexport const PrivateFilesAssetProcessorDecorator = AssetProcessor.createDecorator({\n decorator: PrivateFilesAssetProcessor,\n dependencies: [IdentityContext, GetFileUseCase, AssetAuthorizer]\n});\n"],"names":["PrivateFilesAssetProcessor","identityContext","getFile","assetAuthorizer","assetProcessor","assetRequest","asset","id","file","fileResult","isPrivateFile","RedirectToPublicUrlOutputStrategy","RedirectToPrivateUrlOutputStrategy","NotAuthorizedOutputStrategy","processedAsset","strategy","Error","PrivateCache","PublicCache","PrivateFilesAssetProcessorDecorator","AssetProcessor","IdentityContext","GetFileUseCase","AssetAuthorizer"],"mappings":";;;;;;;;AAqBO,MAAMA;IAMT,YACIC,eAA0C,EAC1CC,OAAiC,EACjCC,eAAiC,EACjCC,cAA+B,CACjC;QACE,IAAI,CAAC,eAAe,GAAGH;QACvB,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QAAQC,YAA0B,EAAEC,KAAY,EAAkB;QACpE,MAAMC,KAAKD,MAAM,KAAK;QAEtB,MAAME,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC;YACzD,MAAMC,aAAa,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAACF;YAC9C,IAAIE,WAAW,MAAM,IACjB,MAAMA,WAAW,KAAK;YAE1B,OAAOA,WAAW,KAAK;QAC3B;QAEA,MAAMC,gBAAgB,IAAI,CAAC,SAAS,CAACF;QAErC,IAAI,CAACE,iBAAiB,IAAI,CAAC,2BAA2B,CAACL,eAAe;YAClEC,MAAM,iBAAiB,CAAC,IAAIK,kCAAkCN;YAC9D,OAAOC;QACX;QAEA,IAAII,iBAAiB,IAAI,CAAC,0BAA0B,CAACL,eAAe;YAChEC,MAAM,iBAAiB,CAAC,IAAIM,mCAAmCP;YAC/D,OAAOC;QACX;QAEA,IAAI;YACA,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAACE;QACzC,EAAE,OAAM;YACJF,MAAM,iBAAiB,CAAC,IAAIO;YAC5B,OAAOP;QACX;QAEA,MAAMQ,iBAAiB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACT,cAAcC;QAEvEQ,eAAe,iBAAiB,CAACC,CAAAA;YAC7B,IAAI,CAACA,UACD,MAAMC,MAAM;YAEhB,OAAON,gBAAgB,IAAIO,aAAaF,YAAY,IAAIG,YAAYH;QACxE;QAEA,OAAOD;IACX;IAEQ,UAAUN,IAAU,EAAE;QAC1B,OAAOA,KAAK,aAAa,IAAIA,KAAK,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC;IACpE;IAEQ,4BAA4BH,YAA0B,EAAE;QAC5D,OAAOA,aAAa,UAAU,GAAiB,OAAO;IAC1D;IAEQ,2BAA2BA,YAA0B,EAAE;QAC3D,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAACA;IAC7C;AACJ;AAEO,MAAMc,sCAAsCC,eAAe,eAAe,CAAC;IAC9E,WAAWpB;IACX,cAAc;QAACqB;QAAiBC;QAAgBC;KAAgB;AACpE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
|
+
import type { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
3
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
4
|
+
export declare class PublicCache implements IAssetOutputStrategy {
|
|
5
|
+
private strategy;
|
|
6
|
+
constructor(strategy: IAssetOutputStrategy);
|
|
7
|
+
output(asset: Asset): Promise<AssetReply>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parse, stringify } from "cache-control-parser";
|
|
2
|
+
class PublicCache {
|
|
3
|
+
constructor(strategy){
|
|
4
|
+
this.strategy = strategy;
|
|
5
|
+
}
|
|
6
|
+
async output(asset) {
|
|
7
|
+
const reply = await this.strategy.output(asset);
|
|
8
|
+
reply.setHeaders((headers)=>{
|
|
9
|
+
headers.set("cache-control", (value = "")=>{
|
|
10
|
+
const cacheControl = parse(value);
|
|
11
|
+
cacheControl["private"] = false;
|
|
12
|
+
cacheControl["public"] = true;
|
|
13
|
+
return stringify(cacheControl);
|
|
14
|
+
});
|
|
15
|
+
return headers;
|
|
16
|
+
});
|
|
17
|
+
return reply;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export { PublicCache };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=PublicCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PublicCache.js","sources":["../../../../src/features/assetDelivery/privateFiles/PublicCache.ts"],"sourcesContent":["import { parse, stringify } from \"cache-control-parser\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class PublicCache implements IAssetOutputStrategy {\n private strategy: IAssetOutputStrategy;\n\n constructor(strategy: IAssetOutputStrategy) {\n this.strategy = strategy;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const reply = await this.strategy.output(asset);\n\n reply.setHeaders(headers => {\n headers.set(\"cache-control\", (value = \"\") => {\n const cacheControl = parse(value);\n cacheControl[\"private\"] = false;\n cacheControl[\"public\"] = true;\n return stringify(cacheControl);\n });\n return headers;\n });\n\n return reply;\n }\n}\n"],"names":["PublicCache","strategy","asset","reply","headers","value","cacheControl","parse","stringify"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,QAA8B,CAAE;QACxC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,OAAOC,KAAY,EAAuB;QAC5C,MAAMC,QAAQ,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAACD;QAEzCC,MAAM,UAAU,CAACC,CAAAA;YACbA,QAAQ,GAAG,CAAC,iBAAiB,CAACC,QAAQ,EAAE;gBACpC,MAAMC,eAAeC,MAAMF;gBAC3BC,YAAY,CAAC,UAAU,GAAG;gBAC1BA,YAAY,CAAC,SAAS,GAAG;gBACzB,OAAOE,UAAUF;YACrB;YACA,OAAOF;QACX;QAEA,OAAOD;IACX;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
|
+
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
|
+
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
4
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
5
|
+
export declare class RedirectToPrivateUrlOutputStrategy implements IAssetOutputStrategy {
|
|
6
|
+
private assetRequest;
|
|
7
|
+
constructor(assetRequest: AssetRequest);
|
|
8
|
+
output(asset: Asset): Promise<AssetReply>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
|
+
import { ResponseHeaders } from "@webiny/handler";
|
|
3
|
+
class RedirectToPrivateUrlOutputStrategy {
|
|
4
|
+
constructor(assetRequest){
|
|
5
|
+
this.assetRequest = assetRequest;
|
|
6
|
+
}
|
|
7
|
+
async output(asset) {
|
|
8
|
+
const requestUrl = this.assetRequest.getContext().url;
|
|
9
|
+
return new AssetReply({
|
|
10
|
+
code: 301,
|
|
11
|
+
headers: ResponseHeaders.create({
|
|
12
|
+
location: requestUrl.replace("/files/", "/private/"),
|
|
13
|
+
"content-type": asset.getContentType(),
|
|
14
|
+
"cache-control": "public, max-age=2592000"
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { RedirectToPrivateUrlOutputStrategy };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=RedirectToPrivateUrlOutputStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class RedirectToPrivateUrlOutputStrategy implements IAssetOutputStrategy {\n private assetRequest: AssetRequest;\n\n constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return new AssetReply({\n code: 301,\n headers: ResponseHeaders.create({\n location: requestUrl.replace(\"/files/\", \"/private/\"),\n \"content-type\": asset.getContentType(),\n \"cache-control\": `public, max-age=${86400 * 30}`\n })\n });\n }\n}\n"],"names":["RedirectToPrivateUrlOutputStrategy","assetRequest","asset","requestUrl","AssetReply","ResponseHeaders"],"mappings":";;AAMO,MAAMA;IAGT,YAAYC,YAA0B,CAAE;QACpC,IAAI,CAAC,YAAY,GAAGA;IACxB;IAEA,MAAM,OAAOC,KAAY,EAAuB;QAC5C,MAAMC,aAAa,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,GAAG;QAErD,OAAO,IAAIC,WAAW;YAClB,MAAM;YACN,SAASC,gBAAgB,MAAM,CAAC;gBAC5B,UAAUF,WAAW,OAAO,CAAC,WAAW;gBACxC,gBAAgBD,MAAM,cAAc;gBACpC,iBAAiB;YACrB;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
|
+
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
|
+
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
4
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
5
|
+
export declare class RedirectToPublicUrlOutputStrategy implements IAssetOutputStrategy {
|
|
6
|
+
private assetRequest;
|
|
7
|
+
constructor(assetRequest: AssetRequest);
|
|
8
|
+
output(asset: Asset): Promise<AssetReply>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
|
+
import { ResponseHeaders } from "@webiny/handler";
|
|
3
|
+
class RedirectToPublicUrlOutputStrategy {
|
|
4
|
+
constructor(assetRequest){
|
|
5
|
+
this.assetRequest = assetRequest;
|
|
6
|
+
}
|
|
7
|
+
async output(asset) {
|
|
8
|
+
const requestUrl = this.assetRequest.getContext().url;
|
|
9
|
+
return new AssetReply({
|
|
10
|
+
code: 301,
|
|
11
|
+
headers: ResponseHeaders.create({
|
|
12
|
+
location: requestUrl.replace("/private/", "/files/"),
|
|
13
|
+
"content-type": asset.getContentType(),
|
|
14
|
+
"cache-control": "public, max-age=2592000"
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { RedirectToPublicUrlOutputStrategy };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=RedirectToPublicUrlOutputStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class RedirectToPublicUrlOutputStrategy implements IAssetOutputStrategy {\n private assetRequest: AssetRequest;\n\n constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return new AssetReply({\n code: 301,\n headers: ResponseHeaders.create({\n location: requestUrl.replace(\"/private/\", \"/files/\"),\n \"content-type\": asset.getContentType(),\n \"cache-control\": `public, max-age=${86400 * 30}`\n })\n });\n }\n}\n"],"names":["RedirectToPublicUrlOutputStrategy","assetRequest","asset","requestUrl","AssetReply","ResponseHeaders"],"mappings":";;AAMO,MAAMA;IAGT,YAAYC,YAA0B,CAAE;QACpC,IAAI,CAAC,YAAY,GAAGA;IACxB;IAEA,MAAM,OAAOC,KAAY,EAAuB;QAC5C,MAAMC,aAAa,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,GAAG;QAErD,OAAO,IAAIC,WAAW;YAClB,MAAM;YACN,SAASC,gBAAgB,MAAM,CAAC;gBAC5B,UAAUF,WAAW,OAAO,CAAC,aAAa;gBAC1C,gBAAgBD,MAAM,cAAc;gBACpC,iBAAiB;YACrB;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
|
+
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
|
+
import { type IAssetTransformationStrategy } from "../abstractions.js";
|
|
4
|
+
export declare class PassthroughAssetTransformationStrategy implements IAssetTransformationStrategy {
|
|
5
|
+
transform(assetRequest: AssetRequest, asset: Asset): Promise<Asset>;
|
|
6
|
+
}
|
|
7
|
+
export declare const PassthroughAssetTransformationStrategyImpl: typeof PassthroughAssetTransformationStrategy & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<IAssetTransformationStrategy>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AssetTransformationStrategy } from "../abstractions.js";
|
|
2
|
+
class PassthroughAssetTransformationStrategy {
|
|
3
|
+
transform(assetRequest, asset) {
|
|
4
|
+
return Promise.resolve(asset);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
const PassthroughAssetTransformationStrategyImpl = AssetTransformationStrategy.createImplementation({
|
|
8
|
+
implementation: PassthroughAssetTransformationStrategy,
|
|
9
|
+
dependencies: []
|
|
10
|
+
});
|
|
11
|
+
export { PassthroughAssetTransformationStrategy, PassthroughAssetTransformationStrategyImpl };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=PassthroughAssetTransformationStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js","sources":["../../../../src/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetTransformationStrategy, type IAssetTransformationStrategy } from \"../abstractions.js\";\n\nexport class PassthroughAssetTransformationStrategy implements IAssetTransformationStrategy {\n transform(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n return Promise.resolve(asset);\n }\n}\n\nexport const PassthroughAssetTransformationStrategyImpl =\n AssetTransformationStrategy.createImplementation({\n implementation: PassthroughAssetTransformationStrategy,\n dependencies: []\n });\n"],"names":["PassthroughAssetTransformationStrategy","assetRequest","asset","Promise","PassthroughAssetTransformationStrategyImpl","AssetTransformationStrategy"],"mappings":";AAIO,MAAMA;IACT,UAAUC,YAA0B,EAAEC,KAAY,EAAkB;QAChE,OAAOC,QAAQ,OAAO,CAACD;IAC3B;AACJ;AAEO,MAAME,6CACTC,4BAA4B,oBAAoB,CAAC;IAC7C,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
|
+
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
|
+
import { type IAssetProcessor, type IAssetTransformationStrategy } from "../abstractions.js";
|
|
4
|
+
export declare class TransformationAssetProcessor implements IAssetProcessor {
|
|
5
|
+
private strategy;
|
|
6
|
+
constructor(strategy: IAssetTransformationStrategy);
|
|
7
|
+
process(assetRequest: AssetRequest, asset: Asset): Promise<Asset>;
|
|
8
|
+
}
|
|
9
|
+
export declare const TransformationAssetProcessorImpl: typeof TransformationAssetProcessor & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<IAssetProcessor>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AssetProcessor, AssetTransformationStrategy } from "../abstractions.js";
|
|
2
|
+
class TransformationAssetProcessor {
|
|
3
|
+
constructor(strategy){
|
|
4
|
+
this.strategy = strategy;
|
|
5
|
+
}
|
|
6
|
+
async process(assetRequest, asset) {
|
|
7
|
+
const { original } = assetRequest.getOptions();
|
|
8
|
+
if (original) {
|
|
9
|
+
console.log("Skip transformations; original asset was requested.");
|
|
10
|
+
return asset;
|
|
11
|
+
}
|
|
12
|
+
return this.strategy.transform(assetRequest, asset);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const TransformationAssetProcessorImpl = AssetProcessor.createImplementation({
|
|
16
|
+
implementation: TransformationAssetProcessor,
|
|
17
|
+
dependencies: [
|
|
18
|
+
AssetTransformationStrategy
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
export { TransformationAssetProcessor, TransformationAssetProcessorImpl };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=TransformationAssetProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/transformation/TransformationAssetProcessor.js","sources":["../../../../src/features/assetDelivery/transformation/TransformationAssetProcessor.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport {\n AssetProcessor,\n AssetTransformationStrategy,\n type IAssetProcessor,\n type IAssetTransformationStrategy\n} from \"../abstractions.js\";\n\nexport class TransformationAssetProcessor implements IAssetProcessor {\n private strategy: IAssetTransformationStrategy;\n\n constructor(strategy: IAssetTransformationStrategy) {\n this.strategy = strategy;\n }\n\n async process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n const { original } = assetRequest.getOptions();\n\n if (original) {\n console.log(\"Skip transformations; original asset was requested.\");\n return asset;\n }\n\n return this.strategy.transform(assetRequest, asset);\n }\n}\n\nexport const TransformationAssetProcessorImpl = AssetProcessor.createImplementation({\n implementation: TransformationAssetProcessor,\n dependencies: [AssetTransformationStrategy]\n});\n"],"names":["TransformationAssetProcessor","strategy","assetRequest","asset","original","console","TransformationAssetProcessorImpl","AssetProcessor","AssetTransformationStrategy"],"mappings":";AASO,MAAMA;IAGT,YAAYC,QAAsC,CAAE;QAChD,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,QAAQC,YAA0B,EAAEC,KAAY,EAAkB;QACpE,MAAM,EAAEC,QAAQ,EAAE,GAAGF,aAAa,UAAU;QAE5C,IAAIE,UAAU;YACVC,QAAQ,GAAG,CAAC;YACZ,OAAOF;QACX;QAEA,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAACD,cAAcC;IACjD;AACJ;AAEO,MAAMG,mCAAmCC,eAAe,oBAAoB,CAAC;IAChF,gBAAgBP;IAChB,cAAc;QAACQ;KAA4B;AAC/C"}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import { CreateFileRepository
|
|
2
|
+
import { CreateFileRepository } from "./abstractions.js";
|
|
3
3
|
import { CreateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/CreateEntry";
|
|
4
4
|
import { FileModel } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { EntryToFileMapper } from "../shared/EntryToFileMapper.js";
|
|
6
6
|
import { FileNotAuthorizedError, FilePersistenceError } from "../../../domain/file/errors.js";
|
|
7
7
|
import { FileInputToEntryInputMapper } from "../shared/FileInputToEntryInputMapper.js";
|
|
8
8
|
class CreateFileRepositoryImpl {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
constructor(createEntry, fileModel){
|
|
10
|
+
this.createEntry = createEntry;
|
|
11
|
+
this.fileModel = fileModel;
|
|
12
|
+
}
|
|
13
|
+
async execute(data) {
|
|
14
|
+
const result = await this.createEntry.execute(this.fileModel, FileInputToEntryInputMapper.toEntry(data));
|
|
15
|
+
if (result.isFail()) {
|
|
16
|
+
if ("Cms/Entry/NotAuthorized" === result.error.code) return Result.fail(new FileNotAuthorizedError());
|
|
17
|
+
return Result.fail(new FilePersistenceError(result.error));
|
|
18
|
+
}
|
|
19
|
+
const file = EntryToFileMapper.toFile(result.value);
|
|
20
|
+
return Result.ok(file);
|
|
20
21
|
}
|
|
21
|
-
const file = EntryToFileMapper.toFile(result.value);
|
|
22
|
-
return Result.ok(file);
|
|
23
|
-
}
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const CreateFileRepository_CreateFileRepository = CreateFileRepository.createImplementation({
|
|
24
|
+
implementation: CreateFileRepositoryImpl,
|
|
25
|
+
dependencies: [
|
|
26
|
+
CreateEntryUseCase,
|
|
27
|
+
FileModel
|
|
28
|
+
]
|
|
28
29
|
});
|
|
30
|
+
export { CreateFileRepository_CreateFileRepository as CreateFileRepository };
|
|
29
31
|
|
|
30
32
|
//# sourceMappingURL=CreateFileRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/CreateFile/CreateFileRepository.js","sources":["../../../../src/features/file/CreateFile/CreateFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CreateFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { CreateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/CreateEntry\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\nimport type { File, FileInput } from \"~/domain/file/types.js\";\nimport { EntryToFileMapper } from \"../shared/EntryToFileMapper.js\";\nimport { FileNotAuthorizedError, FilePersistenceError } from \"~/domain/file/errors.js\";\nimport { FileInputToEntryInputMapper } from \"~/features/file/shared/FileInputToEntryInputMapper.js\";\n\nclass CreateFileRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private createEntry: CreateEntryUseCase.Interface,\n private fileModel: FileModel.Interface\n ) {}\n\n async execute(data: FileInput): Promise<Result<File, RepositoryAbstraction.Error>> {\n const result = await this.createEntry.execute(\n this.fileModel,\n FileInputToEntryInputMapper.toEntry(data)\n );\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotAuthorized\") {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n const file = EntryToFileMapper.toFile(result.value);\n return Result.ok(file);\n }\n}\n\nexport const CreateFileRepository = RepositoryAbstraction.createImplementation({\n implementation: CreateFileRepositoryImpl,\n dependencies: [CreateEntryUseCase, FileModel]\n});\n"],"names":["CreateFileRepositoryImpl","createEntry","fileModel","data","result","FileInputToEntryInputMapper","Result","FileNotAuthorizedError","FilePersistenceError","file","EntryToFileMapper","CreateFileRepository","RepositoryAbstraction","CreateEntryUseCase","FileModel"],"mappings":";;;;;;;AASA,MAAMA;IACF,YACYC,WAAyC,EACzCC,SAA8B,CACxC;aAFUD,WAAW,GAAXA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,IAAe,EAAsD;QAC/E,MAAMC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CACzC,IAAI,CAAC,SAAS,EACdC,4BAA4B,OAAO,CAACF;QAGxC,IAAIC,OAAO,MAAM,IAAI;YACjB,IAAIA,AAAsB,8BAAtBA,OAAO,KAAK,CAAC,IAAI,EACjB,OAAOE,OAAO,IAAI,CAAC,IAAIC;YAG3B,OAAOD,OAAO,IAAI,CAAC,IAAIE,qBAAqBJ,OAAO,KAAK;QAC5D;QAEA,MAAMK,OAAOC,kBAAkB,MAAM,CAACN,OAAO,KAAK;QAClD,OAAOE,OAAO,EAAE,CAACG;IACrB;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAA0C,CAAC;IAC3E,gBAAgBZ;IAChB,cAAc;QAACa;QAAoBC;KAAU;AACjD"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateFileUseCase as UseCaseAbstraction, CreateFileInput, CreateFileRepository } from "./abstractions.js";
|
|
3
3
|
import { GetSettingsUseCase } from "../../settings/GetSettings/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import type { File } from "../../../domain/file/types.js";
|
|
6
|
-
import {
|
|
6
|
+
import { FmPermissions } from "../../../features/shared/abstractions.js";
|
|
7
7
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
8
8
|
declare class CreateFileUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
9
9
|
private identityContext;
|
|
10
|
-
private
|
|
10
|
+
private permissions;
|
|
11
11
|
private repository;
|
|
12
12
|
private getSettings;
|
|
13
13
|
private eventPublisher;
|
|
14
|
-
constructor(identityContext: IdentityContext.Interface,
|
|
14
|
+
constructor(identityContext: IdentityContext.Interface, permissions: FmPermissions.Interface, repository: CreateFileRepository.Interface, getSettings: GetSettingsUseCase.Interface, eventPublisher: EventPublisher.Interface);
|
|
15
15
|
execute(input: CreateFileInput, meta?: Record<string, any>): Promise<Result<File, UseCaseAbstraction.Error>>;
|
|
16
16
|
private validateInput;
|
|
17
17
|
}
|
|
@@ -1,91 +1,83 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
2
|
+
import { CreateFileRepository, CreateFileUseCase } from "./abstractions.js";
|
|
3
3
|
import { GetSettingsUseCase } from "../../settings/GetSettings/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import { FileNotAuthorizedError, InvalidFileSizeError } from "../../../domain/file/errors.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { FileAfterCreateEvent, FileBeforeCreateEvent } from "./events.js";
|
|
7
|
+
import { FmPermissions } from "../../shared/abstractions.js";
|
|
8
8
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
9
9
|
import { Identity } from "../../../domain/identity/Identity.js";
|
|
10
10
|
class CreateFileUseCaseImpl {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
async execute(input, meta) {
|
|
19
|
-
const hasPermission = await this.filePermissions.ensure({
|
|
20
|
-
rwd: "w"
|
|
21
|
-
});
|
|
22
|
-
if (!hasPermission) {
|
|
23
|
-
return Result.fail(new FileNotAuthorizedError());
|
|
11
|
+
constructor(identityContext, permissions, repository, getSettings, eventPublisher){
|
|
12
|
+
this.identityContext = identityContext;
|
|
13
|
+
this.permissions = permissions;
|
|
14
|
+
this.repository = repository;
|
|
15
|
+
this.getSettings = getSettings;
|
|
16
|
+
this.eventPublisher = eventPublisher;
|
|
24
17
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
await this.eventPublisher.publish(new FileAfterCreateEvent({
|
|
62
|
-
file: result.value,
|
|
63
|
-
meta
|
|
64
|
-
}));
|
|
65
|
-
return Result.ok(result.value);
|
|
66
|
-
}
|
|
67
|
-
async validateInput(input) {
|
|
68
|
-
const settingsResult = await this.getSettings.execute();
|
|
69
|
-
if (settingsResult.isFail()) {
|
|
70
|
-
return Result.ok();
|
|
71
|
-
}
|
|
72
|
-
const settings = settingsResult.value;
|
|
73
|
-
if (settings) {
|
|
74
|
-
// Validate file size
|
|
75
|
-
if (input.size < settings.uploadMinFileSize || input.size > settings.uploadMaxFileSize) {
|
|
76
|
-
return Result.fail(new InvalidFileSizeError({
|
|
77
|
-
size: input.size,
|
|
78
|
-
minSize: settings.uploadMinFileSize,
|
|
79
|
-
maxSize: settings.uploadMaxFileSize
|
|
18
|
+
async execute(input, meta) {
|
|
19
|
+
const hasPermission = await this.permissions.canCreate("file");
|
|
20
|
+
if (!hasPermission) return Result.fail(new FileNotAuthorizedError());
|
|
21
|
+
const validationResult = await this.validateInput(input);
|
|
22
|
+
if (validationResult.isFail()) return Result.fail(validationResult.error);
|
|
23
|
+
const [id] = input.key.split("/");
|
|
24
|
+
const currentIdentity = this.identityContext.getIdentity();
|
|
25
|
+
const fileInput = {
|
|
26
|
+
id: input.id || id,
|
|
27
|
+
key: input.key,
|
|
28
|
+
name: input.name,
|
|
29
|
+
size: input.size,
|
|
30
|
+
type: input.type,
|
|
31
|
+
metadata: input.metadata || {},
|
|
32
|
+
location: input.location || {
|
|
33
|
+
folderId: "root"
|
|
34
|
+
},
|
|
35
|
+
tags: input.tags || [],
|
|
36
|
+
description: input.description ?? "",
|
|
37
|
+
extensions: meta || {},
|
|
38
|
+
createdOn: input.createdOn,
|
|
39
|
+
modifiedOn: input.modifiedOn,
|
|
40
|
+
savedOn: input.savedOn,
|
|
41
|
+
createdBy: input.createdBy ? Identity.from(input.createdBy) : Identity.from(currentIdentity),
|
|
42
|
+
modifiedBy: input.modifiedBy ? Identity.from(input.modifiedBy) : void 0,
|
|
43
|
+
savedBy: input.savedBy ? Identity.from(input.savedBy) : Identity.from(currentIdentity)
|
|
44
|
+
};
|
|
45
|
+
await this.eventPublisher.publish(new FileBeforeCreateEvent({
|
|
46
|
+
file: fileInput,
|
|
47
|
+
meta
|
|
48
|
+
}));
|
|
49
|
+
const result = await this.repository.execute(fileInput);
|
|
50
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
51
|
+
await this.eventPublisher.publish(new FileAfterCreateEvent({
|
|
52
|
+
file: result.value,
|
|
53
|
+
meta
|
|
80
54
|
}));
|
|
81
|
-
|
|
55
|
+
return Result.ok(result.value);
|
|
56
|
+
}
|
|
57
|
+
async validateInput(input) {
|
|
58
|
+
const settingsResult = await this.getSettings.execute();
|
|
59
|
+
if (settingsResult.isFail()) return Result.ok();
|
|
60
|
+
const settings = settingsResult.value;
|
|
61
|
+
if (settings) {
|
|
62
|
+
if (input.size < settings.uploadMinFileSize || input.size > settings.uploadMaxFileSize) return Result.fail(new InvalidFileSizeError({
|
|
63
|
+
size: input.size,
|
|
64
|
+
minSize: settings.uploadMinFileSize,
|
|
65
|
+
maxSize: settings.uploadMaxFileSize
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
return Result.ok();
|
|
82
69
|
}
|
|
83
|
-
return Result.ok();
|
|
84
|
-
}
|
|
85
70
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
const CreateFileUseCase_CreateFileUseCase = CreateFileUseCase.createImplementation({
|
|
72
|
+
implementation: CreateFileUseCaseImpl,
|
|
73
|
+
dependencies: [
|
|
74
|
+
IdentityContext,
|
|
75
|
+
FmPermissions,
|
|
76
|
+
CreateFileRepository,
|
|
77
|
+
GetSettingsUseCase,
|
|
78
|
+
EventPublisher
|
|
79
|
+
]
|
|
89
80
|
});
|
|
81
|
+
export { CreateFileUseCase_CreateFileUseCase as CreateFileUseCase };
|
|
90
82
|
|
|
91
83
|
//# sourceMappingURL=CreateFileUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/file/CreateFile/CreateFileUseCase.js","sources":["../../../../src/features/file/CreateFile/CreateFileUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n CreateFileUseCase as UseCaseAbstraction,\n CreateFileInput,\n CreateFileRepository\n} from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"../../settings/GetSettings/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File, FileInput } from \"~/domain/file/types.js\";\nimport { FileNotAuthorizedError, InvalidFileSizeError } from \"~/domain/file/errors.js\";\nimport { FileBeforeCreateEvent, FileAfterCreateEvent } from \"./events.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { Identity } from \"~/domain/identity/Identity.js\";\n\nclass CreateFileUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private permissions: FmPermissions.Interface,\n private repository: CreateFileRepository.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(\n input: CreateFileInput,\n meta?: Record<string, any>\n ): Promise<Result<File, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canCreate(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const validationResult = await this.validateInput(input);\n if (validationResult.isFail()) {\n return Result.fail(validationResult.error);\n }\n\n const [id] = input.key.split(\"/\");\n const currentIdentity = this.identityContext.getIdentity();\n\n // Prepare file input\n const fileInput: FileInput = {\n id: input.id || id,\n key: input.key,\n name: input.name,\n size: input.size,\n type: input.type,\n metadata: input.metadata || {},\n location: input.location || { folderId: \"root\" },\n tags: input.tags || [],\n description: input.description ?? \"\",\n extensions: meta || {},\n // system attributes\n createdOn: input.createdOn,\n modifiedOn: input.modifiedOn,\n savedOn: input.savedOn,\n createdBy: input.createdBy\n ? Identity.from(input.createdBy)\n : Identity.from(currentIdentity),\n modifiedBy: input.modifiedBy ? Identity.from(input.modifiedBy) : undefined,\n savedBy: input.savedBy ? Identity.from(input.savedBy) : Identity.from(currentIdentity)\n };\n\n await this.eventPublisher.publish(new FileBeforeCreateEvent({ file: fileInput, meta }));\n\n const result = await this.repository.execute(fileInput);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(new FileAfterCreateEvent({ file: result.value, meta }));\n\n return Result.ok(result.value);\n }\n\n private async validateInput(\n input: CreateFileInput\n ): Promise<Result<void, InvalidFileSizeError>> {\n const settingsResult = await this.getSettings.execute();\n\n if (settingsResult.isFail()) {\n return Result.ok();\n }\n\n const settings = settingsResult.value;\n\n if (settings) {\n // Validate file size\n if (\n input.size < settings.uploadMinFileSize ||\n input.size > settings.uploadMaxFileSize\n ) {\n return Result.fail(\n new InvalidFileSizeError({\n size: input.size,\n minSize: settings.uploadMinFileSize,\n maxSize: settings.uploadMaxFileSize\n })\n );\n }\n }\n\n return Result.ok();\n }\n}\n\nexport const CreateFileUseCase = UseCaseAbstraction.createImplementation({\n implementation: CreateFileUseCaseImpl,\n dependencies: [\n IdentityContext,\n FmPermissions,\n CreateFileRepository,\n GetSettingsUseCase,\n EventPublisher\n ]\n});\n"],"names":["CreateFileUseCaseImpl","identityContext","permissions","repository","getSettings","eventPublisher","input","meta","hasPermission","Result","FileNotAuthorizedError","validationResult","id","currentIdentity","fileInput","Identity","undefined","FileBeforeCreateEvent","result","FileAfterCreateEvent","settingsResult","settings","InvalidFileSizeError","CreateFileUseCase","UseCaseAbstraction","IdentityContext","FmPermissions","CreateFileRepository","GetSettingsUseCase","EventPublisher"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,WAAoC,EACpCC,UAA0C,EAC1CC,WAAyC,EACzCC,cAAwC,CAClD;aALUJ,eAAe,GAAfA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAAsB,EACtBC,IAA0B,EACqB;QAC/C,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;QACvD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,mBAAmB,MAAM,IAAI,CAAC,aAAa,CAACL;QAClD,IAAIK,iBAAiB,MAAM,IACvB,OAAOF,OAAO,IAAI,CAACE,iBAAiB,KAAK;QAG7C,MAAM,CAACC,GAAG,GAAGN,MAAM,GAAG,CAAC,KAAK,CAAC;QAC7B,MAAMO,kBAAkB,IAAI,CAAC,eAAe,CAAC,WAAW;QAGxD,MAAMC,YAAuB;YACzB,IAAIR,MAAM,EAAE,IAAIM;YAChB,KAAKN,MAAM,GAAG;YACd,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChB,UAAUA,MAAM,QAAQ,IAAI,CAAC;YAC7B,UAAUA,MAAM,QAAQ,IAAI;gBAAE,UAAU;YAAO;YAC/C,MAAMA,MAAM,IAAI,IAAI,EAAE;YACtB,aAAaA,MAAM,WAAW,IAAI;YAClC,YAAYC,QAAQ,CAAC;YAErB,WAAWD,MAAM,SAAS;YAC1B,YAAYA,MAAM,UAAU;YAC5B,SAASA,MAAM,OAAO;YACtB,WAAWA,MAAM,SAAS,GACpBS,SAAS,IAAI,CAACT,MAAM,SAAS,IAC7BS,SAAS,IAAI,CAACF;YACpB,YAAYP,MAAM,UAAU,GAAGS,SAAS,IAAI,CAACT,MAAM,UAAU,IAAIU;YACjE,SAASV,MAAM,OAAO,GAAGS,SAAS,IAAI,CAACT,MAAM,OAAO,IAAIS,SAAS,IAAI,CAACF;QAC1E;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAII,sBAAsB;YAAE,MAAMH;YAAWP;QAAK;QAEpF,MAAMW,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACJ;QAE7C,IAAII,OAAO,MAAM,IACb,OAAOT,OAAO,IAAI,CAACS,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIC,qBAAqB;YAAE,MAAMD,OAAO,KAAK;YAAEX;QAAK;QAEtF,OAAOE,OAAO,EAAE,CAACS,OAAO,KAAK;IACjC;IAEA,MAAc,cACVZ,KAAsB,EACqB;QAC3C,MAAMc,iBAAiB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO;QAErD,IAAIA,eAAe,MAAM,IACrB,OAAOX,OAAO,EAAE;QAGpB,MAAMY,WAAWD,eAAe,KAAK;QAErC,IAAIC,UAEA;YAAA,IACIf,MAAM,IAAI,GAAGe,SAAS,iBAAiB,IACvCf,MAAM,IAAI,GAAGe,SAAS,iBAAiB,EAEvC,OAAOZ,OAAO,IAAI,CACd,IAAIa,qBAAqB;gBACrB,MAAMhB,MAAM,IAAI;gBAChB,SAASe,SAAS,iBAAiB;gBACnC,SAASA,SAAS,iBAAiB;YACvC;QAER;QAGJ,OAAOZ,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMc,sCAAoBC,kBAAAA,oBAAuC,CAAC;IACrE,gBAAgBxB;IAChB,cAAc;QACVyB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -10,6 +10,7 @@ export interface CreateFileInput {
|
|
|
10
10
|
metadata?: Record<string, any>;
|
|
11
11
|
extensions?: Record<string, any>;
|
|
12
12
|
tags?: string[];
|
|
13
|
+
description?: string;
|
|
13
14
|
location?: {
|
|
14
15
|
folderId: string;
|
|
15
16
|
};
|
|
@@ -31,6 +32,7 @@ export interface ICreateFileRepositoryErrors {
|
|
|
31
32
|
persistence: FilePersistenceError;
|
|
32
33
|
}
|
|
33
34
|
type RepositoryError = ICreateFileRepositoryErrors[keyof ICreateFileRepositoryErrors];
|
|
35
|
+
/** Persist a newly created file. */
|
|
34
36
|
export declare const CreateFileRepository: import("@webiny/di").Abstraction<ICreateFileRepository>;
|
|
35
37
|
export declare namespace CreateFileRepository {
|
|
36
38
|
type Interface = ICreateFileRepository;
|
|
@@ -49,6 +51,7 @@ export interface ICreateFileUseCaseErrors {
|
|
|
49
51
|
alreadyExists: FileAlreadyExistsError;
|
|
50
52
|
}
|
|
51
53
|
type UseCaseError = ICreateFileUseCaseErrors[keyof ICreateFileUseCaseErrors];
|
|
54
|
+
/** Upload and create a new file. */
|
|
52
55
|
export declare const CreateFileUseCase: import("@webiny/di").Abstraction<ICreateFileUseCase>;
|
|
53
56
|
export declare namespace CreateFileUseCase {
|
|
54
57
|
type Interface = ICreateFileUseCase;
|