@webiny/api-file-manager 6.4.12-beta.4 → 6.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{contants.js → constants.js} +1 -1
- package/constants.js.map +1 -0
- package/delivery/AssetDelivery/Asset.d.ts +2 -1
- package/delivery/AssetDelivery/Asset.js +4 -1
- package/delivery/AssetDelivery/Asset.js.map +1 -1
- package/delivery/AssetDelivery/AssetRequest.d.ts +4 -3
- package/delivery/AssetDelivery/AssetRequest.js +3 -0
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
- package/delivery/AssetDelivery/abstractions/AssetReply.d.ts +2 -1
- package/delivery/AssetDelivery/abstractions/AssetReply.js +5 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
- package/delivery/index.d.ts +3 -3
- package/delivery/index.js +0 -2
- package/delivery/setupAssetDelivery.js +4 -1
- package/delivery/setupAssetDelivery.js.map +1 -1
- package/domain/file/file.model.js +5 -1
- package/domain/file/file.model.js.map +1 -1
- package/domain/settings/validation.js +1 -1
- package/domain/settings/validation.js.map +1 -1
- package/exports/api/file-manager/assetDelivery.d.ts +18 -0
- package/exports/api/file-manager/assetDelivery.js +15 -0
- package/exports/api/file-manager/file.d.ts +1 -0
- package/exports/api/file-manager/file.js +1 -0
- package/features/FileManagerFeature.js +12 -0
- package/features/FileManagerFeature.js.map +1 -1
- package/features/assetDelivery/Asset/Asset.d.ts +8 -0
- package/features/assetDelivery/Asset/Asset.js +14 -0
- package/features/assetDelivery/Asset/Asset.js.map +1 -0
- package/features/assetDelivery/Asset/abstractions.d.ts +10 -0
- package/features/assetDelivery/Asset/abstractions.js +5 -0
- package/features/assetDelivery/Asset/abstractions.js.map +1 -0
- package/features/assetDelivery/Asset/index.d.ts +1 -0
- package/features/assetDelivery/Asset/index.js +1 -0
- package/features/assetDelivery/AssetRequest/AssetRequest.d.ts +8 -0
- package/features/assetDelivery/AssetRequest/AssetRequest.js +14 -0
- package/features/assetDelivery/AssetRequest/AssetRequest.js.map +1 -0
- package/features/assetDelivery/AssetRequest/abstractions.d.ts +11 -0
- package/features/assetDelivery/AssetRequest/abstractions.js +5 -0
- package/features/assetDelivery/AssetRequest/abstractions.js.map +1 -0
- package/features/assetDelivery/AssetRequest/index.d.ts +1 -0
- package/features/assetDelivery/AssetRequest/index.js +1 -0
- package/features/assetDelivery/FilesAssetRequestResolver.d.ts +9 -7
- package/features/assetDelivery/FilesAssetRequestResolver.js +19 -15
- package/features/assetDelivery/FilesAssetRequestResolver.js.map +1 -1
- package/features/assetDelivery/NullAssetOutputStrategy.d.ts +6 -6
- package/features/assetDelivery/NullAssetOutputStrategy.js +6 -6
- package/features/assetDelivery/NullAssetOutputStrategy.js.map +1 -1
- package/features/assetDelivery/NullAssetReply.d.ts +2 -1
- package/features/assetDelivery/NullAssetReply.js +3 -0
- package/features/assetDelivery/NullAssetReply.js.map +1 -1
- package/features/assetDelivery/NullAssetResolver.d.ts +6 -6
- package/features/assetDelivery/NullAssetResolver.js +5 -5
- package/features/assetDelivery/NullAssetResolver.js.map +1 -1
- package/features/assetDelivery/ObjectKey/ObjectKey.d.ts +8 -0
- package/features/assetDelivery/ObjectKey/ObjectKey.js +28 -0
- package/features/assetDelivery/ObjectKey/ObjectKey.js.map +1 -0
- package/features/assetDelivery/ObjectKey/abstractions.d.ts +12 -0
- package/features/assetDelivery/ObjectKey/abstractions.js +5 -0
- package/features/assetDelivery/ObjectKey/abstractions.js.map +1 -0
- package/features/assetDelivery/ObjectKey/index.d.ts +1 -0
- package/features/assetDelivery/ObjectKey/index.js +1 -0
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.d.ts +8 -0
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.js +22 -0
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.js.map +1 -0
- package/features/assetDelivery/StreamAssetReply/abstractions.d.ts +11 -0
- package/features/assetDelivery/StreamAssetReply/abstractions.js +5 -0
- package/features/assetDelivery/StreamAssetReply/abstractions.js.map +1 -0
- package/features/assetDelivery/StreamAssetReply/index.d.ts +1 -0
- package/features/assetDelivery/StreamAssetReply/index.js +1 -0
- package/features/assetDelivery/abstractions/AssetAuthorizer.d.ts +9 -0
- package/features/assetDelivery/abstractions/AssetAuthorizer.js +5 -0
- package/features/assetDelivery/abstractions/AssetAuthorizer.js.map +1 -0
- package/features/assetDelivery/abstractions/AssetContentsReader.d.ts +9 -0
- package/features/assetDelivery/abstractions/AssetContentsReader.js +5 -0
- package/features/assetDelivery/abstractions/AssetContentsReader.js.map +1 -0
- package/features/assetDelivery/abstractions/AssetOutputStrategy.d.ts +11 -0
- package/features/assetDelivery/abstractions/AssetOutputStrategy.js +5 -0
- package/features/assetDelivery/abstractions/AssetOutputStrategy.js.map +1 -0
- package/features/assetDelivery/abstractions/AssetProcessor.d.ts +11 -0
- package/features/assetDelivery/abstractions/AssetProcessor.js +5 -0
- package/features/assetDelivery/abstractions/AssetProcessor.js.map +1 -0
- package/features/assetDelivery/abstractions/AssetRequestResolver.d.ts +11 -0
- package/features/assetDelivery/abstractions/AssetRequestResolver.js +5 -0
- package/features/assetDelivery/abstractions/AssetRequestResolver.js.map +1 -0
- package/features/assetDelivery/abstractions/AssetResolver.d.ts +11 -0
- package/features/assetDelivery/abstractions/AssetResolver.js +5 -0
- package/features/assetDelivery/abstractions/AssetResolver.js.map +1 -0
- package/features/assetDelivery/abstractions/AssetTransformationStrategy.d.ts +11 -0
- package/features/assetDelivery/abstractions/AssetTransformationStrategy.js +5 -0
- package/features/assetDelivery/abstractions/AssetTransformationStrategy.js.map +1 -0
- package/features/assetDelivery/abstractions/AssetType.d.ts +17 -0
- package/features/assetDelivery/abstractions/AssetType.js +5 -0
- package/features/assetDelivery/abstractions/AssetType.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/AssetKeyGenerator.d.ts +12 -0
- package/features/assetDelivery/assetTypes/image/AssetKeyGenerator.js +30 -0
- package/features/assetDelivery/assetTypes/image/AssetKeyGenerator.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetType.d.ts +9 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetType.js +18 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetType.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetTypeHandler.d.ts +5 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetTypeHandler.js +5 -0
- package/features/assetDelivery/assetTypes/image/ImageAssetTypeHandler.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/WidthCollection.d.ts +8 -0
- package/features/assetDelivery/assetTypes/image/WidthCollection.js +22 -0
- package/features/assetDelivery/assetTypes/image/WidthCollection.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/imageFormat.d.ts +26 -0
- package/features/assetDelivery/assetTypes/image/imageFormat.js +51 -0
- package/features/assetDelivery/assetTypes/image/imageFormat.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/imageTypes.d.ts +39 -0
- package/features/assetDelivery/assetTypes/image/imageTypes.js +0 -0
- package/features/assetDelivery/assetTypes/image/index.d.ts +5 -0
- package/features/assetDelivery/assetTypes/image/index.js +4 -0
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.d.ts +6 -0
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.js +56 -0
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/transformImage.d.ts +59 -0
- package/features/assetDelivery/assetTypes/image/transformImage.js +146 -0
- package/features/assetDelivery/assetTypes/image/transformImage.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/utils.d.ts +26 -0
- package/features/assetDelivery/assetTypes/image/utils.js +47 -0
- package/features/assetDelivery/assetTypes/image/utils.js.map +1 -0
- package/features/assetDelivery/feature.js +25 -16
- package/features/assetDelivery/feature.js.map +1 -1
- package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +2 -2
- package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +3 -3
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +1 -1
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateCache.d.ts +3 -3
- package/features/assetDelivery/privateFiles/PrivateCache.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +9 -8
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +15 -12
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +8 -8
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js +8 -7
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
- package/features/assetDelivery/privateFiles/PublicCache.d.ts +3 -3
- package/features/assetDelivery/privateFiles/PublicCache.js.map +1 -1
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +5 -4
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +4 -1
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -1
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +5 -4
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +4 -1
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -1
- package/features/assetDelivery/transformation/CallableContentsReader.d.ts +11 -0
- package/features/assetDelivery/transformation/CallableContentsReader.js +14 -0
- package/features/assetDelivery/transformation/CallableContentsReader.js.map +1 -0
- package/features/assetDelivery/transformation/TransformationAssetProcessor.d.ts +6 -10
- package/features/assetDelivery/transformation/TransformationAssetProcessor.js +13 -11
- package/features/assetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
- package/features/assetDelivery/transformation/index.d.ts +5 -0
- package/features/assetDelivery/transformation/index.js +4 -0
- package/features/extractMetadata/ExtractMetadataHandler.d.ts +11 -0
- package/features/extractMetadata/ExtractMetadataHandler.js +25 -0
- package/features/extractMetadata/ExtractMetadataHandler.js.map +1 -0
- package/features/extractMetadata/ExtractMetadataInput.d.ts +3 -0
- package/features/extractMetadata/ExtractMetadataInput.js +0 -0
- package/features/file/FileUrlGenerator/FileUrlGenerator.d.ts +15 -0
- package/features/file/FileUrlGenerator/FileUrlGenerator.js +33 -0
- package/features/file/FileUrlGenerator/FileUrlGenerator.js.map +1 -0
- package/features/file/FileUrlGenerator/abstractions.d.ts +3 -4
- package/features/file/FileUrlGenerator/abstractions.js +1 -1
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
- package/features/file/FileUrlGenerator/feature.d.ts +4 -0
- package/features/file/FileUrlGenerator/feature.js +11 -0
- package/features/file/FileUrlGenerator/feature.js.map +1 -0
- package/features/file/FileUrlGenerator/index.d.ts +1 -0
- package/features/file/FileUrlGenerator/index.js +1 -0
- package/features/file/GetFileByUrl/GetFileByUrlUseCase.d.ts +15 -0
- package/features/file/GetFileByUrl/GetFileByUrlUseCase.js +37 -0
- package/features/file/GetFileByUrl/GetFileByUrlUseCase.js.map +1 -0
- package/features/file/GetFileByUrl/abstractions.d.ts +18 -0
- package/features/file/GetFileByUrl/abstractions.js +5 -0
- package/features/file/GetFileByUrl/abstractions.js.map +1 -0
- package/features/file/GetFileByUrl/feature.d.ts +4 -0
- package/features/file/GetFileByUrl/feature.js +11 -0
- package/features/file/GetFileByUrl/feature.js.map +1 -0
- package/features/file/GetFileByUrl/index.d.ts +1 -0
- package/features/file/GetFileByUrl/index.js +1 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.js +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
- package/features/upload/CompleteMultiPartUpload/abstractions.d.ts +12 -0
- package/features/upload/CompleteMultiPartUpload/abstractions.js +5 -0
- package/features/upload/CompleteMultiPartUpload/abstractions.js.map +1 -0
- package/features/upload/CompleteMultiPartUpload/index.d.ts +1 -0
- package/features/upload/CompleteMultiPartUpload/index.js +1 -0
- package/features/upload/CreateMultiPartUpload/abstractions.d.ts +14 -0
- package/features/upload/CreateMultiPartUpload/abstractions.js +5 -0
- package/features/upload/CreateMultiPartUpload/abstractions.js.map +1 -0
- package/features/upload/CreateMultiPartUpload/index.d.ts +1 -0
- package/features/upload/CreateMultiPartUpload/index.js +1 -0
- package/features/upload/GetUploadPayload/abstractions.d.ts +10 -0
- package/features/upload/GetUploadPayload/abstractions.js +5 -0
- package/features/upload/GetUploadPayload/abstractions.js.map +1 -0
- package/features/upload/GetUploadPayload/index.d.ts +1 -0
- package/features/upload/GetUploadPayload/index.js +1 -0
- package/features/upload/ReadFileMetadata/MetadataReader.d.ts +11 -0
- package/features/upload/ReadFileMetadata/MetadataReader.js +21 -0
- package/features/upload/ReadFileMetadata/MetadataReader.js.map +1 -0
- package/features/upload/ReadFileMetadata/abstractions.d.ts +15 -0
- package/features/upload/ReadFileMetadata/abstractions.js +5 -0
- package/features/upload/ReadFileMetadata/abstractions.js.map +1 -0
- package/features/upload/ReadFileMetadata/feature.d.ts +4 -0
- package/features/upload/ReadFileMetadata/feature.js +11 -0
- package/features/upload/ReadFileMetadata/feature.js.map +1 -0
- package/features/upload/ReadFileMetadata/index.d.ts +1 -0
- package/features/upload/ReadFileMetadata/index.js +1 -0
- package/features/upload/WriteFileMetadata/MetadataWriter.d.ts +14 -0
- package/features/upload/WriteFileMetadata/MetadataWriter.js +36 -0
- package/features/upload/WriteFileMetadata/MetadataWriter.js.map +1 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.d.ts +11 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js +20 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js.map +1 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterCreateHandler.d.ts +11 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterCreateHandler.js +22 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterCreateHandler.js.map +1 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterUpdateHandler.d.ts +11 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterUpdateHandler.js +22 -0
- package/features/upload/WriteFileMetadata/WriteMetadataAfterUpdateHandler.js.map +1 -0
- package/features/upload/WriteFileMetadata/abstractions.d.ts +9 -0
- package/features/upload/WriteFileMetadata/abstractions.js +5 -0
- package/features/upload/WriteFileMetadata/abstractions.js.map +1 -0
- package/features/upload/WriteFileMetadata/feature.d.ts +4 -0
- package/features/upload/WriteFileMetadata/feature.js +17 -0
- package/features/upload/WriteFileMetadata/feature.js.map +1 -0
- package/features/upload/index.d.ts +17 -0
- package/features/upload/index.js +10 -0
- package/features/upload/types.d.ts +28 -0
- package/features/upload/types.js +0 -0
- package/features/upload/utils/FileExtension.d.ts +6 -0
- package/features/upload/utils/FileExtension.js +16 -0
- package/features/upload/utils/FileExtension.js.map +1 -0
- package/features/upload/utils/FileKey.d.ts +11 -0
- package/features/upload/utils/FileKey.js +33 -0
- package/features/upload/utils/FileKey.js.map +1 -0
- package/features/upload/utils/FileNormalizer.d.ts +13 -0
- package/features/upload/utils/FileNormalizer.js +41 -0
- package/features/upload/utils/FileNormalizer.js.map +1 -0
- package/features/upload/utils/FileUploadModifier.d.ts +30 -0
- package/features/upload/utils/FileUploadModifier.js +39 -0
- package/features/upload/utils/FileUploadModifier.js.map +1 -0
- package/features/upload/utils/checkPermissions.d.ts +5 -0
- package/features/upload/utils/checkPermissions.js +22 -0
- package/features/upload/utils/checkPermissions.js.map +1 -0
- package/features/upload/utils/createFileNormalizerFromContext.d.ts +3 -0
- package/features/upload/utils/createFileNormalizerFromContext.js +9 -0
- package/features/upload/utils/createFileNormalizerFromContext.js.map +1 -0
- package/features/upload/utils/mimeTypes.d.ts +1 -0
- package/features/upload/utils/mimeTypes.js +9 -0
- package/features/upload/utils/mimeTypes.js.map +1 -0
- package/graphql/FmGraphQLSchema.d.ts +25 -0
- package/graphql/FmGraphQLSchema.js +451 -0
- package/graphql/FmGraphQLSchema.js.map +1 -0
- package/graphql/FmUploadGraphQLSchema.d.ts +11 -0
- package/graphql/FmUploadGraphQLSchema.js +231 -0
- package/graphql/FmUploadGraphQLSchema.js.map +1 -0
- package/index.d.ts +0 -3
- package/index.js +16 -17
- package/index.js.map +1 -1
- package/package.json +24 -18
- package/contants.js.map +0 -1
- package/features/assetDelivery/abstractions.d.ts +0 -54
- package/features/assetDelivery/abstractions.js +0 -11
- package/features/assetDelivery/abstractions.js.map +0 -1
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +0 -9
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js +0 -13
- package/features/assetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +0 -1
- package/graphql/baseSchema.d.ts +0 -3
- package/graphql/baseSchema.js +0 -100
- package/graphql/baseSchema.js.map +0 -1
- package/graphql/createFilesTypeDefs.d.ts +0 -8
- package/graphql/createFilesTypeDefs.js +0 -191
- package/graphql/createFilesTypeDefs.js.map +0 -1
- package/graphql/filesSchema.d.ts +0 -4
- package/graphql/filesSchema.js +0 -97
- package/graphql/filesSchema.js.map +0 -1
- package/graphql/getFileByUrl.d.ts +0 -3
- package/graphql/getFileByUrl.js +0 -64
- package/graphql/getFileByUrl.js.map +0 -1
- package/graphql/index.d.ts +0 -4
- package/graphql/index.js +0 -48
- package/graphql/index.js.map +0 -1
- package/graphql/utils.d.ts +0 -11
- package/graphql/utils.js +0 -12
- package/graphql/utils.js.map +0 -1
- package/modelModifier/CmsModelModifier.d.ts +0 -26
- package/modelModifier/CmsModelModifier.js +0 -51
- package/modelModifier/CmsModelModifier.js.map +0 -1
- /package/{contants.d.ts → constants.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/feature.js","sources":["../../../src/features/assetDelivery/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/feature.js","sources":["../../../src/features/assetDelivery/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { AssetFactory } from \"./Asset/Asset.js\";\nimport { AssetRequestFactory } from \"./AssetRequest/AssetRequest.js\";\nimport { FilesAssetRequestResolver } from \"./FilesAssetRequestResolver.js\";\nimport { NullAssetResolver } from \"./NullAssetResolver.js\";\nimport { NullAssetOutputStrategy } from \"./NullAssetOutputStrategy.js\";\nimport { StreamAssetReply } from \"./StreamAssetReply/StreamAssetReply.js\";\nimport { ObjectKey } from \"./ObjectKey/ObjectKey.js\";\nimport { AssetProcessor } from \"./abstractions/AssetProcessor.js\";\nimport { TransformationAssetProcessor } from \"./transformation/TransformationAssetProcessor.js\";\nimport { ImageAssetType } from \"./assetTypes/image/ImageAssetType.js\";\nimport { PrivateFileAssetRequestResolver } from \"./privateFiles/PrivateFileAssetRequestResolver.js\";\nimport { PrivateAuthenticatedAuthorizer } from \"./privateFiles/PrivateAuthenticatedAuthorizer.js\";\nimport { PrivateFilesAssetProcessor } from \"./privateFiles/PrivateFilesAssetProcessor.js\";\n\nexport const AssetDeliveryFeature = createFeature({\n name: \"AssetDelivery\",\n register(container) {\n container.register(AssetFactory).inSingletonScope();\n container.register(AssetRequestFactory).inSingletonScope();\n container.register(FilesAssetRequestResolver).inSingletonScope();\n container.register(NullAssetResolver).inSingletonScope();\n container.register(NullAssetOutputStrategy).inSingletonScope();\n container.register(StreamAssetReply).inSingletonScope();\n container.register(ObjectKey).inSingletonScope();\n container.register(ImageAssetType);\n container.registerInstance(AssetProcessor, new TransformationAssetProcessor(container));\n\n container.registerDecorator(PrivateFileAssetRequestResolver);\n\n const wcp = container.resolve(WcpContext);\n if (wcp.canUsePrivateFiles()) {\n container.register(PrivateAuthenticatedAuthorizer);\n container.registerDecorator(PrivateFilesAssetProcessor);\n }\n }\n});\n"],"names":["AssetDeliveryFeature","createFeature","container","AssetFactory","AssetRequestFactory","FilesAssetRequestResolver","NullAssetResolver","NullAssetOutputStrategy","StreamAssetReply","ObjectKey","ImageAssetType","AssetProcessor","TransformationAssetProcessor","PrivateFileAssetRequestResolver","wcp","WcpContext","PrivateAuthenticatedAuthorizer","PrivateFilesAssetProcessor"],"mappings":";;;;;;;;;;;;;;;AAgBO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,cAAc,gBAAgB;QACjDD,UAAU,QAAQ,CAACE,qBAAqB,gBAAgB;QACxDF,UAAU,QAAQ,CAACG,2BAA2B,gBAAgB;QAC9DH,UAAU,QAAQ,CAACI,mBAAmB,gBAAgB;QACtDJ,UAAU,QAAQ,CAACK,yBAAyB,gBAAgB;QAC5DL,UAAU,QAAQ,CAACM,kBAAkB,gBAAgB;QACrDN,UAAU,QAAQ,CAACO,WAAW,gBAAgB;QAC9CP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,gBAAgB,CAACS,gBAAgB,IAAIC,6BAA6BV;QAE5EA,UAAU,iBAAiB,CAACW;QAE5B,MAAMC,MAAMZ,UAAU,OAAO,CAACa;QAC9B,IAAID,IAAI,kBAAkB,IAAI;YAC1BZ,UAAU,QAAQ,CAACc;YACnBd,UAAU,iBAAiB,CAACe;QAChC;IACJ;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
|
-
import
|
|
3
|
-
export declare class NotAuthorizedOutputStrategy implements
|
|
2
|
+
import { AssetOutputStrategy } from "../abstractions/AssetOutputStrategy.js";
|
|
3
|
+
export declare class NotAuthorizedOutputStrategy implements AssetOutputStrategy.Interface {
|
|
4
4
|
output(): Promise<AssetReply>;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.ts"],"sourcesContent":["import type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { NotAuthorizedAssetReply } from \"./NotAuthorizedAssetReply.js\";\nimport
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.ts"],"sourcesContent":["import type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { NotAuthorizedAssetReply } from \"./NotAuthorizedAssetReply.js\";\nimport { AssetOutputStrategy } from \"../abstractions/AssetOutputStrategy.js\";\n\nexport class NotAuthorizedOutputStrategy implements AssetOutputStrategy.Interface {\n async output(): Promise<AssetReply> {\n return new NotAuthorizedAssetReply();\n }\n}\n"],"names":["NotAuthorizedOutputStrategy","NotAuthorizedAssetReply"],"mappings":";AAIO,MAAMA;IACT,MAAM,SAA8B;QAChC,OAAO,IAAIC;IACf;AACJ"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { File } from "../../../domain/file/types.js";
|
|
2
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
-
import {
|
|
4
|
-
export declare class PrivateAuthenticatedAuthorizer implements
|
|
3
|
+
import { AssetAuthorizer } from "../abstractions/AssetAuthorizer.js";
|
|
4
|
+
export declare class PrivateAuthenticatedAuthorizer implements AssetAuthorizer.Interface {
|
|
5
5
|
private identityContext;
|
|
6
6
|
constructor(identityContext: IdentityContext.Interface);
|
|
7
7
|
authorize(file: File): Promise<void>;
|
|
8
8
|
}
|
|
9
9
|
export declare const PrivateAuthenticatedAuthorizerImpl: typeof PrivateAuthenticatedAuthorizer & {
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<IAssetAuthorizer>;
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("../abstractions/AssetAuthorizer.js").IAssetAuthorizer>;
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
-
import { AssetAuthorizer } from "../abstractions.js";
|
|
3
|
+
import { AssetAuthorizer } from "../abstractions/AssetAuthorizer.js";
|
|
4
4
|
class PrivateAuthenticatedAuthorizer {
|
|
5
5
|
constructor(identityContext){
|
|
6
6
|
this.identityContext = identityContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { AssetAuthorizer
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { AssetAuthorizer } from \"../abstractions/AssetAuthorizer.js\";\n\nexport class PrivateAuthenticatedAuthorizer implements AssetAuthorizer.Interface {\n private identityContext: IdentityContext.Interface;\n\n constructor(identityContext: IdentityContext.Interface) {\n this.identityContext = identityContext;\n }\n\n async authorize(file: File) {\n if (file.accessControl && file.accessControl.type === \"private-authenticated\") {\n const identity = this.identityContext.getIdentity();\n\n if (!identity) {\n throw new Error({\n code: \"NOT_AUTHORIZED\",\n message: \"You're not authorized to access this asset!\"\n });\n }\n }\n }\n}\n\nexport const PrivateAuthenticatedAuthorizerImpl = AssetAuthorizer.createImplementation({\n implementation: PrivateAuthenticatedAuthorizer,\n dependencies: [IdentityContext]\n});\n"],"names":["PrivateAuthenticatedAuthorizer","identityContext","file","identity","Error","PrivateAuthenticatedAuthorizerImpl","AssetAuthorizer","IdentityContext"],"mappings":";;;AAKO,MAAMA;IAGT,YAAYC,eAA0C,CAAE;QACpD,IAAI,CAAC,eAAe,GAAGA;IAC3B;IAEA,MAAM,UAAUC,IAAU,EAAE;QACxB,IAAIA,KAAK,aAAa,IAAIA,AAA4B,4BAA5BA,KAAK,aAAa,CAAC,IAAI,EAA8B;YAC3E,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;YAEjD,IAAI,CAACA,UACD,MAAM,IAAIC,MAAM;gBACZ,MAAM;gBACN,SAAS;YACb;QAER;IACJ;AACJ;AAEO,MAAMC,qCAAqCC,gBAAgB,oBAAoB,CAAC;IACnF,gBAAgBN;IAChB,cAAc;QAACO;KAAgB;AACnC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
3
|
-
import
|
|
4
|
-
export declare class PrivateCache implements
|
|
3
|
+
import { AssetOutputStrategy } from "../abstractions/AssetOutputStrategy.js";
|
|
4
|
+
export declare class PrivateCache implements AssetOutputStrategy.Interface {
|
|
5
5
|
private strategy;
|
|
6
|
-
constructor(strategy:
|
|
6
|
+
constructor(strategy: AssetOutputStrategy.Interface);
|
|
7
7
|
output(asset: Asset): Promise<AssetReply>;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateCache.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateCache.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
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateCache.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateCache.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 { AssetOutputStrategy } from \"../abstractions/AssetOutputStrategy.js\";\n\nexport class PrivateCache implements AssetOutputStrategy.Interface {\n private strategy: AssetOutputStrategy.Interface;\n\n constructor(strategy: AssetOutputStrategy.Interface) {\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\"] = true;\n cacheControl[\"public\"] = false;\n return stringify(cacheControl);\n });\n return headers;\n });\n\n return reply;\n }\n}\n"],"names":["PrivateCache","strategy","asset","reply","headers","value","cacheControl","parse","stringify"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,QAAuC,CAAE;QACjD,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"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { AssetRequestResolver } from "../abstractions/AssetRequestResolver.js";
|
|
2
|
+
import { AssetRequestFactory } from "../AssetRequest/abstractions.js";
|
|
3
|
+
declare class PrivateFileAssetRequestResolverImpl implements AssetRequestResolver.Interface {
|
|
4
|
+
private readonly assetRequestFactory;
|
|
5
5
|
private readonly resolver;
|
|
6
|
-
constructor(resolver:
|
|
7
|
-
resolve(request: Request): Promise<AssetRequest | undefined>;
|
|
6
|
+
constructor(assetRequestFactory: AssetRequestFactory.Interface, resolver: AssetRequestResolver.Interface);
|
|
7
|
+
resolve(request: AssetRequestResolver.Request): Promise<AssetRequestResolver.AssetRequest | undefined>;
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<IAssetRequestResolver>;
|
|
9
|
+
export declare const PrivateFileAssetRequestResolver: typeof PrivateFileAssetRequestResolverImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("../abstractions/AssetRequestResolver.js").IAssetRequestResolver>;
|
|
11
11
|
};
|
|
12
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
class
|
|
4
|
-
constructor(resolver){
|
|
1
|
+
import { AssetRequestResolver } from "../abstractions/AssetRequestResolver.js";
|
|
2
|
+
import { AssetRequestFactory } from "../AssetRequest/abstractions.js";
|
|
3
|
+
class PrivateFileAssetRequestResolverImpl {
|
|
4
|
+
constructor(assetRequestFactory, resolver){
|
|
5
|
+
this.assetRequestFactory = assetRequestFactory;
|
|
5
6
|
this.resolver = resolver;
|
|
6
7
|
}
|
|
7
8
|
async resolve(request) {
|
|
@@ -9,23 +10,25 @@ class PrivateFileAssetRequestResolver {
|
|
|
9
10
|
const params = request.params ?? {};
|
|
10
11
|
const query = request.query ?? {};
|
|
11
12
|
const path = params["*"];
|
|
12
|
-
return
|
|
13
|
+
return this.assetRequestFactory.create({
|
|
13
14
|
key: decodeURI(path).replace("/private/", ""),
|
|
14
15
|
context: {
|
|
15
16
|
url: request.url,
|
|
16
|
-
private: true
|
|
17
|
+
private: true,
|
|
18
|
+
accept: request.headers?.accept
|
|
17
19
|
},
|
|
18
20
|
options: {
|
|
19
|
-
...query
|
|
20
|
-
width: query.width ? parseInt(query.width) : void 0
|
|
21
|
+
...query
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
const
|
|
26
|
-
decorator:
|
|
27
|
-
dependencies: [
|
|
26
|
+
const PrivateFileAssetRequestResolver = AssetRequestResolver.createDecorator({
|
|
27
|
+
decorator: PrivateFileAssetRequestResolverImpl,
|
|
28
|
+
dependencies: [
|
|
29
|
+
AssetRequestFactory
|
|
30
|
+
]
|
|
28
31
|
});
|
|
29
|
-
export { PrivateFileAssetRequestResolver
|
|
32
|
+
export { PrivateFileAssetRequestResolver };
|
|
30
33
|
|
|
31
34
|
//# sourceMappingURL=PrivateFileAssetRequestResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.ts"],"sourcesContent":["import { AssetRequestResolver } from \"../abstractions/AssetRequestResolver.js\";\nimport { AssetRequestFactory } from \"../AssetRequest/abstractions.js\";\n\nclass PrivateFileAssetRequestResolverImpl implements AssetRequestResolver.Interface {\n private readonly assetRequestFactory: AssetRequestFactory.Interface;\n private readonly resolver: AssetRequestResolver.Interface;\n\n constructor(\n assetRequestFactory: AssetRequestFactory.Interface,\n resolver: AssetRequestResolver.Interface\n ) {\n this.assetRequestFactory = assetRequestFactory;\n this.resolver = resolver;\n }\n\n async resolve(\n request: AssetRequestResolver.Request\n ): Promise<AssetRequestResolver.AssetRequest | undefined> {\n if (!request.url.startsWith(\"/private/\")) {\n return this.resolver.resolve(request);\n }\n\n const params = (request.params ?? {}) as Record<string, any>;\n const query = (request.query ?? {}) as Record<string, any>;\n\n const path = params[\"*\"];\n\n return this.assetRequestFactory.create({\n key: decodeURI(path).replace(\"/private/\", \"\"),\n context: {\n url: request.url,\n private: true,\n accept: request.headers?.accept as string | undefined\n },\n options: { ...query }\n });\n }\n}\n\nexport const PrivateFileAssetRequestResolver = AssetRequestResolver.createDecorator({\n decorator: PrivateFileAssetRequestResolverImpl,\n dependencies: [AssetRequestFactory]\n});\n"],"names":["PrivateFileAssetRequestResolverImpl","assetRequestFactory","resolver","request","params","query","path","decodeURI","PrivateFileAssetRequestResolver","AssetRequestResolver","AssetRequestFactory"],"mappings":";;AAGA,MAAMA;IAIF,YACIC,mBAAkD,EAClDC,QAAwC,CAC1C;QACE,IAAI,CAAC,mBAAmB,GAAGD;QAC3B,IAAI,CAAC,QAAQ,GAAGC;IACpB;IAEA,MAAM,QACFC,OAAqC,EACiB;QACtD,IAAI,CAACA,QAAQ,GAAG,CAAC,UAAU,CAAC,cACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACA;QAGjC,MAAMC,SAAUD,QAAQ,MAAM,IAAI,CAAC;QACnC,MAAME,QAASF,QAAQ,KAAK,IAAI,CAAC;QAEjC,MAAMG,OAAOF,MAAM,CAAC,IAAI;QAExB,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;YACnC,KAAKG,UAAUD,MAAM,OAAO,CAAC,aAAa;YAC1C,SAAS;gBACL,KAAKH,QAAQ,GAAG;gBAChB,SAAS;gBACT,QAAQA,QAAQ,OAAO,EAAE;YAC7B;YACA,SAAS;gBAAE,GAAGE,KAAK;YAAC;QACxB;IACJ;AACJ;AAEO,MAAMG,kCAAkCC,qBAAqB,eAAe,CAAC;IAChF,WAAWT;IACX,cAAc;QAACU;KAAoB;AACvC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
|
-
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
1
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
2
|
import { GetFileUseCase } from "../../../features/file/GetFile/index.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
3
|
+
import { AssetAuthorizer } from "../abstractions/AssetAuthorizer.js";
|
|
4
|
+
import { AssetProcessor } from "../abstractions/AssetProcessor.js";
|
|
5
|
+
declare class PrivateFilesAssetProcessorImpl implements AssetProcessor.Interface {
|
|
7
6
|
private readonly identityContext;
|
|
8
7
|
private readonly getFile;
|
|
9
8
|
private readonly assetAuthorizer;
|
|
10
9
|
private readonly assetProcessor;
|
|
11
|
-
constructor(identityContext: IdentityContext.Interface, getFile: GetFileUseCase.Interface, assetAuthorizer:
|
|
12
|
-
process(assetRequest: AssetRequest, asset: Asset): Promise<Asset>;
|
|
10
|
+
constructor(identityContext: IdentityContext.Interface, getFile: GetFileUseCase.Interface, assetAuthorizer: AssetAuthorizer.Interface, assetProcessor: AssetProcessor.Interface);
|
|
11
|
+
process(assetRequest: AssetProcessor.AssetRequest, asset: AssetProcessor.Asset): Promise<AssetProcessor.Asset>;
|
|
13
12
|
private isPrivate;
|
|
14
13
|
private requestedViaPrivateEndpoint;
|
|
15
14
|
private requestedViaPublicEndpoint;
|
|
16
15
|
}
|
|
17
|
-
export declare const
|
|
18
|
-
__abstraction: import("@webiny/di").Abstraction<IAssetProcessor>;
|
|
16
|
+
export declare const PrivateFilesAssetProcessor: typeof PrivateFilesAssetProcessorImpl & {
|
|
17
|
+
__abstraction: import("@webiny/di").Abstraction<import("../abstractions/AssetProcessor.js").IAssetProcessor>;
|
|
19
18
|
};
|
|
19
|
+
export {};
|
|
@@ -5,8 +5,9 @@ import { RedirectToPublicUrlOutputStrategy } from "./RedirectToPublicUrlOutputSt
|
|
|
5
5
|
import { RedirectToPrivateUrlOutputStrategy } from "./RedirectToPrivateUrlOutputStrategy.js";
|
|
6
6
|
import { PrivateCache } from "./PrivateCache.js";
|
|
7
7
|
import { PublicCache } from "./PublicCache.js";
|
|
8
|
-
import { AssetAuthorizer
|
|
9
|
-
|
|
8
|
+
import { AssetAuthorizer } from "../abstractions/AssetAuthorizer.js";
|
|
9
|
+
import { AssetProcessor } from "../abstractions/AssetProcessor.js";
|
|
10
|
+
class PrivateFilesAssetProcessorImpl {
|
|
10
11
|
constructor(identityContext, getFile, assetAuthorizer, assetProcessor){
|
|
11
12
|
this.identityContext = identityContext;
|
|
12
13
|
this.getFile = getFile;
|
|
@@ -22,11 +23,11 @@ class PrivateFilesAssetProcessor {
|
|
|
22
23
|
});
|
|
23
24
|
const isPrivateFile = this.isPrivate(file);
|
|
24
25
|
if (!isPrivateFile && this.requestedViaPrivateEndpoint(assetRequest)) {
|
|
25
|
-
asset.setOutputStrategy(
|
|
26
|
+
asset.setOutputStrategy(RedirectToPublicUrlOutputStrategy.create(assetRequest));
|
|
26
27
|
return asset;
|
|
27
28
|
}
|
|
28
29
|
if (isPrivateFile && this.requestedViaPublicEndpoint(assetRequest)) {
|
|
29
|
-
asset.setOutputStrategy(
|
|
30
|
+
asset.setOutputStrategy(RedirectToPrivateUrlOutputStrategy.create(assetRequest));
|
|
30
31
|
return asset;
|
|
31
32
|
}
|
|
32
33
|
try {
|
|
@@ -52,14 +53,14 @@ class PrivateFilesAssetProcessor {
|
|
|
52
53
|
return !this.requestedViaPrivateEndpoint(assetRequest);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
const
|
|
56
|
-
decorator:
|
|
56
|
+
const PrivateFilesAssetProcessor = AssetProcessor.createDecorator({
|
|
57
|
+
decorator: PrivateFilesAssetProcessorImpl,
|
|
57
58
|
dependencies: [
|
|
58
59
|
IdentityContext,
|
|
59
60
|
GetFileUseCase,
|
|
60
61
|
AssetAuthorizer
|
|
61
62
|
]
|
|
62
63
|
});
|
|
63
|
-
export { PrivateFilesAssetProcessor
|
|
64
|
+
export { PrivateFilesAssetProcessor };
|
|
64
65
|
|
|
65
66
|
//# sourceMappingURL=PrivateFilesAssetProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.ts"],"sourcesContent":["import { 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 { AssetAuthorizer } from \"../abstractions/AssetAuthorizer.js\";\nimport { AssetProcessor } from \"../abstractions/AssetProcessor.js\";\nimport type { File as IFile } from \"~/domain/file/types.js\";\n\ninterface MaybePrivate {\n private?: boolean;\n}\n\nclass PrivateFilesAssetProcessorImpl implements AssetProcessor.Interface {\n constructor(\n private readonly identityContext: IdentityContext.Interface,\n private readonly getFile: GetFileUseCase.Interface,\n private readonly assetAuthorizer: AssetAuthorizer.Interface,\n private readonly assetProcessor: AssetProcessor.Interface\n ) {}\n\n async process(\n assetRequest: AssetProcessor.AssetRequest,\n asset: AssetProcessor.Asset\n ): Promise<AssetProcessor.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(RedirectToPublicUrlOutputStrategy.create(assetRequest));\n return asset;\n }\n\n if (isPrivateFile && this.requestedViaPublicEndpoint(assetRequest)) {\n asset.setOutputStrategy(RedirectToPrivateUrlOutputStrategy.create(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: IFile) {\n return file.accessControl && file.accessControl.type.startsWith(\"private-\");\n }\n\n private requestedViaPrivateEndpoint(assetRequest: AssetProcessor.AssetRequest) {\n return assetRequest.getContext<MaybePrivate>().private;\n }\n\n private requestedViaPublicEndpoint(assetRequest: AssetProcessor.AssetRequest) {\n return !this.requestedViaPrivateEndpoint(assetRequest);\n }\n}\n\nexport const PrivateFilesAssetProcessor = AssetProcessor.createDecorator({\n decorator: PrivateFilesAssetProcessorImpl,\n dependencies: [IdentityContext, GetFileUseCase, AssetAuthorizer]\n});\n"],"names":["PrivateFilesAssetProcessorImpl","identityContext","getFile","assetAuthorizer","assetProcessor","assetRequest","asset","id","file","fileResult","isPrivateFile","RedirectToPublicUrlOutputStrategy","RedirectToPrivateUrlOutputStrategy","NotAuthorizedOutputStrategy","processedAsset","strategy","Error","PrivateCache","PublicCache","PrivateFilesAssetProcessor","AssetProcessor","IdentityContext","GetFileUseCase","AssetAuthorizer"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACqBC,eAA0C,EAC1CC,OAAiC,EACjCC,eAA0C,EAC1CC,cAAwC,CAC3D;aAJmBH,eAAe,GAAfA;aACAC,OAAO,GAAPA;aACAC,eAAe,GAAfA;aACAC,cAAc,GAAdA;IAClB;IAEH,MAAM,QACFC,YAAyC,EACzCC,KAA2B,EACE;QAC7B,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,CAACK,kCAAkC,MAAM,CAACN;YACjE,OAAOC;QACX;QAEA,IAAII,iBAAiB,IAAI,CAAC,0BAA0B,CAACL,eAAe;YAChEC,MAAM,iBAAiB,CAACM,mCAAmC,MAAM,CAACP;YAClE,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,IAAW,EAAE;QAC3B,OAAOA,KAAK,aAAa,IAAIA,KAAK,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC;IACpE;IAEQ,4BAA4BH,YAAyC,EAAE;QAC3E,OAAOA,aAAa,UAAU,GAAiB,OAAO;IAC1D;IAEQ,2BAA2BA,YAAyC,EAAE;QAC1E,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAACA;IAC7C;AACJ;AAEO,MAAMc,6BAA6BC,eAAe,eAAe,CAAC;IACrE,WAAWpB;IACX,cAAc;QAACqB;QAAiBC;QAAgBC;KAAgB;AACpE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
3
|
-
import
|
|
4
|
-
export declare class PublicCache implements
|
|
3
|
+
import { AssetOutputStrategy } from "../abstractions/AssetOutputStrategy.js";
|
|
4
|
+
export declare class PublicCache implements AssetOutputStrategy.Interface {
|
|
5
5
|
private strategy;
|
|
6
|
-
constructor(strategy:
|
|
6
|
+
constructor(strategy: AssetOutputStrategy.Interface);
|
|
7
7
|
output(asset: Asset): Promise<AssetReply>;
|
|
8
8
|
}
|
|
@@ -1 +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
|
|
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 { AssetOutputStrategy } from \"../abstractions/AssetOutputStrategy.js\";\n\nexport class PublicCache implements AssetOutputStrategy.Interface {\n private strategy: AssetOutputStrategy.Interface;\n\n constructor(strategy: AssetOutputStrategy.Interface) {\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,QAAuC,CAAE;QACjD,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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
3
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
4
|
-
import
|
|
5
|
-
export declare class RedirectToPrivateUrlOutputStrategy implements
|
|
6
|
-
private assetRequest;
|
|
7
|
-
|
|
4
|
+
import { AssetOutputStrategy } from "../abstractions/AssetOutputStrategy.js";
|
|
5
|
+
export declare class RedirectToPrivateUrlOutputStrategy implements AssetOutputStrategy.Interface {
|
|
6
|
+
private readonly assetRequest;
|
|
7
|
+
static create(assetRequest: AssetRequest): RedirectToPrivateUrlOutputStrategy;
|
|
8
|
+
private constructor();
|
|
8
9
|
output(asset: Asset): Promise<AssetReply>;
|
|
9
10
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
2
|
import { ResponseHeaders } from "@webiny/handler";
|
|
3
3
|
class RedirectToPrivateUrlOutputStrategy {
|
|
4
|
+
static create(assetRequest) {
|
|
5
|
+
return new RedirectToPrivateUrlOutputStrategy(assetRequest);
|
|
6
|
+
}
|
|
4
7
|
constructor(assetRequest){
|
|
5
8
|
this.assetRequest = assetRequest;
|
|
6
9
|
}
|
|
7
10
|
async output(asset) {
|
|
8
11
|
const requestUrl = this.assetRequest.getContext().url;
|
|
9
|
-
return
|
|
12
|
+
return AssetReply.create({
|
|
10
13
|
code: 301,
|
|
11
14
|
headers: ResponseHeaders.create({
|
|
12
15
|
location: requestUrl.replace("/files/", "/private/"),
|
|
@@ -1 +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
|
|
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 { AssetOutputStrategy } from \"../abstractions/AssetOutputStrategy.js\";\n\nexport class RedirectToPrivateUrlOutputStrategy implements AssetOutputStrategy.Interface {\n private readonly assetRequest: AssetRequest;\n\n public static create(assetRequest: AssetRequest) {\n return new RedirectToPrivateUrlOutputStrategy(assetRequest);\n }\n\n private constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n public async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return AssetReply.create({\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,OAAc,OAAOC,YAA0B,EAAE;QAC7C,OAAO,IAAID,mCAAmCC;IAClD;IAEA,YAAoBA,YAA0B,CAAE;QAC5C,IAAI,CAAC,YAAY,GAAGA;IACxB;IAEA,MAAa,OAAOC,KAAY,EAAuB;QACnD,MAAMC,aAAa,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,GAAG;QAErD,OAAOC,WAAW,MAAM,CAAC;YACrB,MAAM;YACN,SAASC,gBAAgB,MAAM,CAAC;gBAC5B,UAAUF,WAAW,OAAO,CAAC,WAAW;gBACxC,gBAAgBD,MAAM,cAAc;gBACpC,iBAAiB;YACrB;QACJ;IACJ;AACJ"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
3
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
4
|
-
import
|
|
5
|
-
export declare class RedirectToPublicUrlOutputStrategy implements
|
|
6
|
-
private assetRequest;
|
|
7
|
-
|
|
4
|
+
import { AssetOutputStrategy } from "../abstractions/AssetOutputStrategy.js";
|
|
5
|
+
export declare class RedirectToPublicUrlOutputStrategy implements AssetOutputStrategy.Interface {
|
|
6
|
+
private readonly assetRequest;
|
|
7
|
+
static create(assetRequest: AssetRequest): RedirectToPublicUrlOutputStrategy;
|
|
8
|
+
private constructor();
|
|
8
9
|
output(asset: Asset): Promise<AssetReply>;
|
|
9
10
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
2
|
import { ResponseHeaders } from "@webiny/handler";
|
|
3
3
|
class RedirectToPublicUrlOutputStrategy {
|
|
4
|
+
static create(assetRequest) {
|
|
5
|
+
return new RedirectToPublicUrlOutputStrategy(assetRequest);
|
|
6
|
+
}
|
|
4
7
|
constructor(assetRequest){
|
|
5
8
|
this.assetRequest = assetRequest;
|
|
6
9
|
}
|
|
7
10
|
async output(asset) {
|
|
8
11
|
const requestUrl = this.assetRequest.getContext().url;
|
|
9
|
-
return
|
|
12
|
+
return AssetReply.create({
|
|
10
13
|
code: 301,
|
|
11
14
|
headers: ResponseHeaders.create({
|
|
12
15
|
location: requestUrl.replace("/private/", "/files/"),
|
|
@@ -1 +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
|
|
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 { AssetOutputStrategy } from \"../abstractions/AssetOutputStrategy.js\";\n\nexport class RedirectToPublicUrlOutputStrategy implements AssetOutputStrategy.Interface {\n private readonly assetRequest: AssetRequest;\n\n public static create(assetRequest: AssetRequest) {\n return new RedirectToPublicUrlOutputStrategy(assetRequest);\n }\n\n private constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n public async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return AssetReply.create({\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,OAAc,OAAOC,YAA0B,EAAE;QAC7C,OAAO,IAAID,kCAAkCC;IACjD;IAEA,YAAoBA,YAA0B,CAAE;QAC5C,IAAI,CAAC,YAAY,GAAGA;IACxB;IAEA,MAAa,OAAOC,KAAY,EAAuB;QACnD,MAAMC,aAAa,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,GAAG;QAErD,OAAOC,WAAW,MAAM,CAAC;YACrB,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,11 @@
|
|
|
1
|
+
import { AssetContentsReader } from "../../../features/assetDelivery/abstractions/AssetContentsReader.js";
|
|
2
|
+
interface ContentsCallable {
|
|
3
|
+
(): Promise<Buffer> | Buffer;
|
|
4
|
+
}
|
|
5
|
+
export declare class CallableContentsReader implements AssetContentsReader.Interface {
|
|
6
|
+
private readonly callable;
|
|
7
|
+
static create(callable: ContentsCallable): CallableContentsReader;
|
|
8
|
+
private constructor();
|
|
9
|
+
read(): Promise<Buffer>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CallableContentsReader {
|
|
2
|
+
static create(callable) {
|
|
3
|
+
return new CallableContentsReader(callable);
|
|
4
|
+
}
|
|
5
|
+
constructor(callable){
|
|
6
|
+
this.callable = callable;
|
|
7
|
+
}
|
|
8
|
+
async read() {
|
|
9
|
+
return this.callable();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export { CallableContentsReader };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=CallableContentsReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/transformation/CallableContentsReader.js","sources":["../../../../src/features/assetDelivery/transformation/CallableContentsReader.ts"],"sourcesContent":["import { AssetContentsReader } from \"~/features/assetDelivery/abstractions/AssetContentsReader.js\";\n\ninterface ContentsCallable {\n (): Promise<Buffer> | Buffer;\n}\n\nexport class CallableContentsReader implements AssetContentsReader.Interface {\n private readonly callable: ContentsCallable;\n\n public static create(callable: ContentsCallable) {\n return new CallableContentsReader(callable);\n }\n\n private constructor(callable: ContentsCallable) {\n this.callable = callable;\n }\n\n public async read(): Promise<Buffer> {\n return this.callable();\n }\n}\n"],"names":["CallableContentsReader","callable"],"mappings":"AAMO,MAAMA;IAGT,OAAc,OAAOC,QAA0B,EAAE;QAC7C,OAAO,IAAID,uBAAuBC;IACtC;IAEA,YAAoBA,QAA0B,CAAE;QAC5C,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAa,OAAwB;QACjC,OAAO,IAAI,CAAC,QAAQ;IACxB;AACJ"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
process(assetRequest: AssetRequest, asset: Asset): Promise<Asset>;
|
|
1
|
+
import type { Container } from "@webiny/di";
|
|
2
|
+
import { AssetProcessor } from "../abstractions/AssetProcessor.js";
|
|
3
|
+
export declare class TransformationAssetProcessor implements AssetProcessor.Interface {
|
|
4
|
+
private readonly container;
|
|
5
|
+
constructor(container: Container);
|
|
6
|
+
process(assetRequest: AssetProcessor.AssetRequest, asset: AssetProcessor.Asset): Promise<AssetProcessor.Asset>;
|
|
8
7
|
}
|
|
9
|
-
export declare const TransformationAssetProcessorImpl: typeof TransformationAssetProcessor & {
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<IAssetProcessor>;
|
|
11
|
-
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AssetType } from "../abstractions/AssetType.js";
|
|
2
2
|
class TransformationAssetProcessor {
|
|
3
|
-
constructor(
|
|
4
|
-
this.
|
|
3
|
+
constructor(container){
|
|
4
|
+
this.container = container;
|
|
5
5
|
}
|
|
6
6
|
async process(assetRequest, asset) {
|
|
7
7
|
const { original } = assetRequest.getOptions();
|
|
@@ -9,15 +9,17 @@ class TransformationAssetProcessor {
|
|
|
9
9
|
console.log("Skip transformations; original asset was requested.");
|
|
10
10
|
return asset;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const assetTypes = this.container.resolveAll(AssetType);
|
|
13
|
+
const match = assetTypes.find((assetType)=>assetType.canHandle(asset));
|
|
14
|
+
if (!match) return asset;
|
|
15
|
+
try {
|
|
16
|
+
const handler = this.container.resolve(match.getHandlerAbstraction());
|
|
17
|
+
return handler.handle(assetRequest, asset);
|
|
18
|
+
} catch {
|
|
19
|
+
return asset;
|
|
20
|
+
}
|
|
13
21
|
}
|
|
14
22
|
}
|
|
15
|
-
|
|
16
|
-
implementation: TransformationAssetProcessor,
|
|
17
|
-
dependencies: [
|
|
18
|
-
AssetTransformationStrategy
|
|
19
|
-
]
|
|
20
|
-
});
|
|
21
|
-
export { TransformationAssetProcessor, TransformationAssetProcessorImpl };
|
|
23
|
+
export { TransformationAssetProcessor };
|
|
22
24
|
|
|
23
25
|
//# sourceMappingURL=TransformationAssetProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/transformation/TransformationAssetProcessor.js","sources":["../../../../src/features/assetDelivery/transformation/TransformationAssetProcessor.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/transformation/TransformationAssetProcessor.js","sources":["../../../../src/features/assetDelivery/transformation/TransformationAssetProcessor.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { AssetProcessor } from \"../abstractions/AssetProcessor.js\";\nimport { AssetType } from \"../abstractions/AssetType.js\";\n\nexport class TransformationAssetProcessor implements AssetProcessor.Interface {\n constructor(private readonly container: Container) {}\n\n async process(\n assetRequest: AssetProcessor.AssetRequest,\n asset: AssetProcessor.Asset\n ): Promise<AssetProcessor.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 const assetTypes = this.container.resolveAll(AssetType);\n const match = assetTypes.find(assetType => assetType.canHandle(asset));\n\n if (!match) {\n return asset;\n }\n\n try {\n const handler = this.container.resolve(match.getHandlerAbstraction());\n return handler.handle(assetRequest, asset);\n } catch {\n return asset;\n }\n }\n}\n"],"names":["TransformationAssetProcessor","container","assetRequest","asset","original","console","assetTypes","AssetType","match","assetType","handler"],"mappings":";AAIO,MAAMA;IACT,YAA6BC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEpD,MAAM,QACFC,YAAyC,EACzCC,KAA2B,EACE;QAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,aAAa,UAAU;QAE5C,IAAIE,UAAU;YACVC,QAAQ,GAAG,CAAC;YACZ,OAAOF;QACX;QAEA,MAAMG,aAAa,IAAI,CAAC,SAAS,CAAC,UAAU,CAACC;QAC7C,MAAMC,QAAQF,WAAW,IAAI,CAACG,CAAAA,YAAaA,UAAU,SAAS,CAACN;QAE/D,IAAI,CAACK,OACD,OAAOL;QAGX,IAAI;YACA,MAAMO,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF,MAAM,qBAAqB;YAClE,OAAOE,QAAQ,MAAM,CAACR,cAAcC;QACxC,EAAE,OAAM;YACJ,OAAOA;QACX;IACJ;AACJ"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CallableContentsReader } from "./CallableContentsReader.js";
|
|
2
|
+
export { WidthCollection } from "../assetTypes/image/WidthCollection.js";
|
|
3
|
+
export { type ImageFormat, SUPPORTED_OUTPUT_FORMATS, DEFAULT_IMAGE_QUALITY, contentTypeForFormat, formatFromContentType, resolveRequestedFormat, clampQuality } from "../assetTypes/image/imageFormat.js";
|
|
4
|
+
export { ImageAssetType, ImageAssetTypeHandler, AssetKeyGenerator, SUPPORTED_TRANSFORMABLE_IMAGES, getImageKey, getCropSignature, getOptimizedImageKeyPrefix, getOptimizedTransformedImageKeyPrefix } from "../assetTypes/image/index.js";
|
|
5
|
+
export type { AssetCrop, AssetImageEdit } from "../assetTypes/image/index.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CallableContentsReader } from "./CallableContentsReader.js";
|
|
2
|
+
export { WidthCollection } from "../assetTypes/image/WidthCollection.js";
|
|
3
|
+
export { DEFAULT_IMAGE_QUALITY, SUPPORTED_OUTPUT_FORMATS, clampQuality, contentTypeForFormat, formatFromContentType, resolveRequestedFormat } from "../assetTypes/image/imageFormat.js";
|
|
4
|
+
export { AssetKeyGenerator, ImageAssetType, ImageAssetTypeHandler, SUPPORTED_TRANSFORMABLE_IMAGES, getCropSignature, getImageKey, getOptimizedImageKeyPrefix, getOptimizedTransformedImageKeyPrefix } from "../assetTypes/image/index.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FileAfterCreateEventHandler } from "../file/CreateFile/events.js";
|
|
2
|
+
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
3
|
+
declare class ExtractMetadataHandlerImpl implements FileAfterCreateEventHandler.Interface {
|
|
4
|
+
private readonly taskService;
|
|
5
|
+
constructor(taskService: TaskService.Interface);
|
|
6
|
+
handle(event: FileAfterCreateEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const ExtractMetadataHandler: typeof ExtractMetadataHandlerImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("../file/CreateFile/events.js").FileAfterCreateEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FileAfterCreateEventHandler } from "../file/CreateFile/events.js";
|
|
2
|
+
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
3
|
+
class ExtractMetadataHandlerImpl {
|
|
4
|
+
constructor(taskService){
|
|
5
|
+
this.taskService = taskService;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
const { file } = event.payload;
|
|
9
|
+
await this.taskService.trigger({
|
|
10
|
+
definition: "fileManagerExtractMetadata",
|
|
11
|
+
input: {
|
|
12
|
+
fileId: file.id
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const ExtractMetadataHandler = FileAfterCreateEventHandler.createImplementation({
|
|
18
|
+
implementation: ExtractMetadataHandlerImpl,
|
|
19
|
+
dependencies: [
|
|
20
|
+
TaskService
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
export { ExtractMetadataHandler };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=ExtractMetadataHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/extractMetadata/ExtractMetadataHandler.js","sources":["../../../src/features/extractMetadata/ExtractMetadataHandler.ts"],"sourcesContent":["import { FileAfterCreateEventHandler } from \"../file/CreateFile/events.js\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport type { ExtractMetadataInput } from \"./ExtractMetadataInput.js\";\n\nclass ExtractMetadataHandlerImpl implements FileAfterCreateEventHandler.Interface {\n constructor(private readonly taskService: TaskService.Interface) {}\n\n async handle(event: FileAfterCreateEventHandler.Event): Promise<void> {\n const { file } = event.payload;\n\n await this.taskService.trigger<ExtractMetadataInput>({\n definition: \"fileManagerExtractMetadata\",\n input: {\n fileId: file.id\n }\n });\n }\n}\n\nexport const ExtractMetadataHandler = FileAfterCreateEventHandler.createImplementation({\n implementation: ExtractMetadataHandlerImpl,\n dependencies: [TaskService]\n});\n"],"names":["ExtractMetadataHandlerImpl","taskService","event","file","ExtractMetadataHandler","FileAfterCreateEventHandler","TaskService"],"mappings":";;AAIA,MAAMA;IACF,YAA6BC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAElE,MAAM,OAAOC,KAAwC,EAAiB;QAClE,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAM,OAAO;QAE9B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAuB;YACjD,YAAY;YACZ,OAAO;gBACH,QAAQC,KAAK,EAAE;YACnB;QACJ;IACJ;AACJ;AAEO,MAAMC,yBAAyBC,4BAA4B,oBAAoB,CAAC;IACnF,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
|
|
File without changes
|