@webiny/api-file-manager-s3 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.eb81deee7e
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/FileManagerS3Feature.d.ts +9 -0
- package/FileManagerS3Feature.js +27 -0
- package/FileManagerS3Feature.js.map +1 -0
- package/README.md +11 -1
- package/assetDelivery/abstractions.d.ts +11 -0
- package/assetDelivery/abstractions.js +7 -0
- package/assetDelivery/abstractions.js.map +1 -0
- package/assetDelivery/assetDeliveryConfig.d.ts +2 -2
- package/assetDelivery/assetDeliveryConfig.js +10 -49
- package/assetDelivery/assetDeliveryConfig.js.map +1 -1
- package/assetDelivery/createAssetDelivery.d.ts +3 -3
- package/assetDelivery/createAssetDelivery.js +7 -28
- package/assetDelivery/createAssetDelivery.js.map +1 -1
- package/assetDelivery/feature.d.ts +5 -0
- package/assetDelivery/feature.js +36 -0
- package/assetDelivery/feature.js.map +1 -0
- package/assetDelivery/index.d.ts +8 -9
- package/assetDelivery/index.js +8 -70
- package/assetDelivery/s3/LazySharpTransform.d.ts +34 -0
- package/assetDelivery/s3/LazySharpTransform.js +34 -0
- package/assetDelivery/s3/LazySharpTransform.js.map +1 -0
- package/assetDelivery/s3/S3AssetResolver.d.ts +9 -4
- package/assetDelivery/s3/S3AssetResolver.js +34 -32
- package/assetDelivery/s3/S3AssetResolver.js.map +1 -1
- package/assetDelivery/s3/S3ContentsReader.d.ts +1 -3
- package/assetDelivery/s3/S3ContentsReader.js +12 -22
- package/assetDelivery/s3/S3ContentsReader.js.map +1 -1
- package/assetDelivery/s3/S3ErrorAssetReply.js +11 -17
- package/assetDelivery/s3/S3ErrorAssetReply.js.map +1 -1
- package/assetDelivery/s3/S3OutputStrategy.d.ts +6 -6
- package/assetDelivery/s3/S3OutputStrategy.js +35 -35
- package/assetDelivery/s3/S3OutputStrategy.js.map +1 -1
- package/assetDelivery/s3/S3RedirectAssetReply.js +14 -20
- package/assetDelivery/s3/S3RedirectAssetReply.js.map +1 -1
- package/assetDelivery/s3/S3StreamAssetReply.js +14 -20
- package/assetDelivery/s3/S3StreamAssetReply.js.map +1 -1
- package/assetDelivery/s3/SharpTransform.d.ts +22 -14
- package/assetDelivery/s3/SharpTransform.js +163 -182
- package/assetDelivery/s3/SharpTransform.js.map +1 -1
- package/assetDelivery/s3/transformation/AssetKeyGenerator.js +17 -25
- package/assetDelivery/s3/transformation/AssetKeyGenerator.js.map +1 -1
- package/assetDelivery/s3/transformation/CallableContentsReader.d.ts +0 -2
- package/assetDelivery/s3/transformation/CallableContentsReader.js +7 -13
- package/assetDelivery/s3/transformation/CallableContentsReader.js.map +1 -1
- package/assetDelivery/s3/transformation/WidthCollection.js +14 -22
- package/assetDelivery/s3/transformation/WidthCollection.js.map +1 -1
- package/assetDelivery/s3/transformation/utils.d.ts +1 -3
- package/assetDelivery/s3/transformation/utils.js +26 -28
- package/assetDelivery/s3/transformation/utils.js.map +1 -1
- package/assetDelivery/threatDetection/ObjectKey.d.ts +7 -0
- package/assetDelivery/threatDetection/ObjectKey.js +18 -0
- package/assetDelivery/threatDetection/ObjectKey.js.map +1 -0
- package/assetDelivery/threatDetection/createThreatDetectionEventHandler.d.ts +22 -2
- package/assetDelivery/threatDetection/createThreatDetectionEventHandler.js +49 -58
- package/assetDelivery/threatDetection/createThreatDetectionEventHandler.js.map +1 -1
- package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.d.ts +1 -1
- package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.js +3 -11
- package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.js.map +1 -1
- package/assetDelivery/threatDetection/index.d.ts +2 -2
- package/assetDelivery/threatDetection/index.js +2 -29
- package/assetDelivery/threatDetection/processThreatScanResult.d.ts +3 -2
- package/assetDelivery/threatDetection/processThreatScanResult.js +56 -61
- package/assetDelivery/threatDetection/processThreatScanResult.js.map +1 -1
- package/assetDelivery/threatDetection/types.d.ts +0 -4
- package/assetDelivery/threatDetection/types.js +0 -7
- package/assetDelivery/types.d.ts +4 -2
- package/assetDelivery/types.js +0 -7
- package/enterprise/ApplyThreatScanning/CreateFileWithThreatScanDecorator.d.ts +13 -0
- package/enterprise/ApplyThreatScanning/CreateFileWithThreatScanDecorator.js +28 -0
- package/enterprise/ApplyThreatScanning/CreateFileWithThreatScanDecorator.js.map +1 -0
- package/enterprise/ApplyThreatScanning/feature.d.ts +4 -0
- package/enterprise/ApplyThreatScanning/feature.js +11 -0
- package/enterprise/ApplyThreatScanning/feature.js.map +1 -0
- package/features/DeleteFileFromBucket/DeleteFileFromBucketHandler.d.ts +15 -0
- package/features/DeleteFileFromBucket/DeleteFileFromBucketHandler.js +35 -0
- package/features/DeleteFileFromBucket/DeleteFileFromBucketHandler.js.map +1 -0
- package/features/DeleteFileFromBucket/DeleteS3FolderTask.d.ts +37 -0
- package/features/DeleteFileFromBucket/DeleteS3FolderTask.js +57 -0
- package/features/DeleteFileFromBucket/DeleteS3FolderTask.js.map +1 -0
- package/features/DeleteFileFromBucket/feature.d.ts +4 -0
- package/features/DeleteFileFromBucket/feature.js +13 -0
- package/features/DeleteFileFromBucket/feature.js.map +1 -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/ExtractMetadataTask.d.ts +29 -0
- package/features/ExtractMetadata/ExtractMetadataTask.js +99 -0
- package/features/ExtractMetadata/ExtractMetadataTask.js.map +1 -0
- package/features/ExtractMetadata/feature.d.ts +4 -0
- package/features/ExtractMetadata/feature.js +13 -0
- package/features/ExtractMetadata/feature.js.map +1 -0
- package/features/FlushCache/FlushCacheOnFileDeleteHandler.d.ts +12 -0
- package/features/FlushCache/FlushCacheOnFileDeleteHandler.js +28 -0
- package/features/FlushCache/FlushCacheOnFileDeleteHandler.js.map +1 -0
- package/features/FlushCache/FlushCacheOnFileUpdateHandler.d.ts +12 -0
- package/features/FlushCache/FlushCacheOnFileUpdateHandler.js +31 -0
- package/features/FlushCache/FlushCacheOnFileUpdateHandler.js.map +1 -0
- package/features/FlushCache/InvalidateCacheTask.d.ts +31 -0
- package/features/FlushCache/InvalidateCacheTask.js +84 -0
- package/features/FlushCache/InvalidateCacheTask.js.map +1 -0
- package/features/FlushCache/feature.d.ts +4 -0
- package/features/FlushCache/feature.js +15 -0
- package/features/FlushCache/feature.js.map +1 -0
- package/features/GetFileContentsById/GetFileContentsByIdUseCase.d.ts +13 -0
- package/features/GetFileContentsById/GetFileContentsByIdUseCase.js +40 -0
- package/features/GetFileContentsById/GetFileContentsByIdUseCase.js.map +1 -0
- package/features/GetFileContentsById/feature.d.ts +4 -0
- package/features/GetFileContentsById/feature.js +11 -0
- package/features/GetFileContentsById/feature.js.map +1 -0
- package/features/GetFileContentsByKey/GetFileContentsByKeyUseCase.d.ts +13 -0
- package/features/GetFileContentsByKey/GetFileContentsByKeyUseCase.js +40 -0
- package/features/GetFileContentsByKey/GetFileContentsByKeyUseCase.js.map +1 -0
- package/features/GetFileContentsByKey/feature.d.ts +4 -0
- package/features/GetFileContentsByKey/feature.js +11 -0
- package/features/GetFileContentsByKey/feature.js.map +1 -0
- package/features/WriteFileMetadata/MetadataReader.d.ts +14 -0
- package/features/WriteFileMetadata/MetadataReader.js +13 -0
- package/features/WriteFileMetadata/MetadataReader.js.map +1 -0
- package/features/WriteFileMetadata/MetadataWriter.d.ts +10 -0
- package/features/WriteFileMetadata/MetadataWriter.js +28 -0
- package/features/WriteFileMetadata/MetadataWriter.js.map +1 -0
- package/features/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.d.ts +12 -0
- package/features/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js +23 -0
- package/features/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js.map +1 -0
- package/features/WriteFileMetadata/WriteMetadataAfterCreateHandler.d.ts +12 -0
- package/features/WriteFileMetadata/WriteMetadataAfterCreateHandler.js +25 -0
- package/features/WriteFileMetadata/WriteMetadataAfterCreateHandler.js.map +1 -0
- package/features/WriteFileMetadata/feature.d.ts +4 -0
- package/features/WriteFileMetadata/feature.js +13 -0
- package/features/WriteFileMetadata/feature.js.map +1 -0
- package/graphql/S3GraphQLSchema.d.ts +10 -0
- package/graphql/S3GraphQLSchema.js +233 -0
- package/graphql/S3GraphQLSchema.js.map +1 -0
- package/graphql/checkPermissions.d.ts +5 -0
- package/graphql/checkPermissions.js +22 -0
- package/graphql/checkPermissions.js.map +1 -0
- package/index.d.ts +4 -5
- package/index.js +3 -36
- package/multiPartUpload/CompleteMultiPartUploadUseCase.d.ts +1 -1
- package/multiPartUpload/CompleteMultiPartUploadUseCase.js +49 -59
- package/multiPartUpload/CompleteMultiPartUploadUseCase.js.map +1 -1
- package/multiPartUpload/CreateMultiPartUploadUseCase.d.ts +2 -2
- package/multiPartUpload/CreateMultiPartUploadUseCase.js +30 -44
- package/multiPartUpload/CreateMultiPartUploadUseCase.js.map +1 -1
- package/package.json +36 -34
- package/types.d.ts +2 -1
- package/types.js +1 -7
- package/utils/CdnPathsGenerator.d.ts +3 -0
- package/utils/CdnPathsGenerator.js +11 -0
- package/utils/CdnPathsGenerator.js.map +1 -0
- package/utils/FileExtension.d.ts +1 -1
- package/utils/FileExtension.js +11 -19
- package/utils/FileExtension.js.map +1 -1
- package/utils/FileKey.d.ts +1 -1
- package/utils/FileKey.js +29 -29
- package/utils/FileKey.js.map +1 -1
- package/utils/FileKey.test.js +50 -51
- package/utils/FileKey.test.js.map +1 -1
- package/utils/FileNormalizer.d.ts +2 -2
- package/utils/FileNormalizer.js +35 -43
- package/utils/FileNormalizer.js.map +1 -1
- package/utils/FileUploadModifier.d.ts +9 -3
- package/utils/FileUploadModifier.js +36 -44
- package/utils/FileUploadModifier.js.map +1 -1
- package/utils/createFileNormalizerFromContext.d.ts +2 -2
- package/utils/createFileNormalizerFromContext.js +6 -12
- package/utils/createFileNormalizerFromContext.js.map +1 -1
- package/utils/getPresignedPostPayload.d.ts +4 -3
- package/utils/getPresignedPostPayload.js +38 -40
- package/utils/getPresignedPostPayload.js.map +1 -1
- package/utils/mimeTypes.js +6 -20
- package/utils/mimeTypes.js.map +1 -1
- package/utils/uploadFileToS3.d.ts +2 -5
- package/utils/uploadFileToS3.js +11 -23
- package/utils/uploadFileToS3.js.map +1 -1
- package/assetDelivery/createCustomAssetDelivery.d.ts +0 -12
- package/assetDelivery/createCustomAssetDelivery.js +0 -28
- package/assetDelivery/createCustomAssetDelivery.js.map +0 -1
- package/assetDelivery/customAssets/CustomAsset.d.ts +0 -6
- package/assetDelivery/customAssets/CustomAsset.js +0 -14
- package/assetDelivery/customAssets/CustomAsset.js.map +0 -1
- package/assetDelivery/customAssets/CustomAssetProcessor.d.ts +0 -10
- package/assetDelivery/customAssets/CustomAssetProcessor.js +0 -25
- package/assetDelivery/customAssets/CustomAssetProcessor.js.map +0 -1
- package/assetDelivery/customAssets/S3CustomAssetResolver.d.ts +0 -15
- package/assetDelivery/customAssets/S3CustomAssetResolver.js +0 -90
- package/assetDelivery/customAssets/S3CustomAssetResolver.js.map +0 -1
- package/assetDelivery/customAssets/customAssetDeliveryConfig.d.ts +0 -1
- package/assetDelivery/customAssets/customAssetDeliveryConfig.js +0 -30
- package/assetDelivery/customAssets/customAssetDeliveryConfig.js.map +0 -1
- package/assetDelivery/index.js.map +0 -1
- package/assetDelivery/s3/S3AssetMetadataReader.d.ts +0 -15
- package/assetDelivery/s3/S3AssetMetadataReader.js +0 -36
- package/assetDelivery/s3/S3AssetMetadataReader.js.map +0 -1
- package/assetDelivery/s3/transformation/legacyUtils.d.ts +0 -12
- package/assetDelivery/s3/transformation/legacyUtils.js +0 -34
- package/assetDelivery/s3/transformation/legacyUtils.js.map +0 -1
- package/assetDelivery/threatDetection/index.js.map +0 -1
- package/assetDelivery/threatDetection/types.js.map +0 -1
- package/assetDelivery/types.js.map +0 -1
- package/flushCdnCache/CdnPathsGenerator.d.ts +0 -4
- package/flushCdnCache/CdnPathsGenerator.js +0 -14
- package/flushCdnCache/CdnPathsGenerator.js.map +0 -1
- package/flushCdnCache/InvalidateCacheTask.d.ts +0 -18
- package/flushCdnCache/InvalidateCacheTask.js +0 -78
- package/flushCdnCache/InvalidateCacheTask.js.map +0 -1
- package/flushCdnCache/flushCacheOnFileDelete.d.ts +0 -3
- package/flushCdnCache/flushCacheOnFileDelete.js +0 -34
- package/flushCdnCache/flushCacheOnFileDelete.js.map +0 -1
- package/flushCdnCache/flushCacheOnFileUpdate.d.ts +0 -3
- package/flushCdnCache/flushCacheOnFileUpdate.js +0 -40
- package/flushCdnCache/flushCacheOnFileUpdate.js.map +0 -1
- package/flushCdnCache/index.d.ts +0 -1
- package/flushCdnCache/index.js +0 -15
- package/flushCdnCache/index.js.map +0 -1
- package/flushCdnCache/invalidateCacheTaskDefinition.d.ts +0 -2
- package/flushCdnCache/invalidateCacheTaskDefinition.js +0 -22
- package/flushCdnCache/invalidateCacheTaskDefinition.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/addFileMetadata.d.ts +0 -10
- package/plugins/addFileMetadata.js +0 -67
- package/plugins/addFileMetadata.js.map +0 -1
- package/plugins/checkPermissions.d.ts +0 -4
- package/plugins/checkPermissions.js +0 -44
- package/plugins/checkPermissions.js.map +0 -1
- package/plugins/fileStorageS3.d.ts +0 -3
- package/plugins/fileStorageS3.js +0 -60
- package/plugins/fileStorageS3.js.map +0 -1
- package/plugins/graphqlFileStorageS3.d.ts +0 -4
- package/plugins/graphqlFileStorageS3.js +0 -213
- package/plugins/graphqlFileStorageS3.js.map +0 -1
- package/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager-s3",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.eb81deee7e",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"repository": {
|
|
6
10
|
"type": "git",
|
|
7
11
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
@@ -10,42 +14,40 @@
|
|
|
10
14
|
"author": "Webiny Ltd",
|
|
11
15
|
"license": "MIT",
|
|
12
16
|
"dependencies": {
|
|
13
|
-
"@webiny/api": "0.0.0-unstable.
|
|
14
|
-
"@webiny/api-
|
|
15
|
-
"@webiny/api-
|
|
16
|
-
"@webiny/api-
|
|
17
|
-
"@webiny/api-websockets": "0.0.0-unstable.
|
|
18
|
-
"@webiny/aws-sdk": "0.0.0-unstable.
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
22
|
-
"@webiny/handler-
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
17
|
+
"@webiny/api": "0.0.0-unstable.eb81deee7e",
|
|
18
|
+
"@webiny/api-core": "0.0.0-unstable.eb81deee7e",
|
|
19
|
+
"@webiny/api-file-manager": "0.0.0-unstable.eb81deee7e",
|
|
20
|
+
"@webiny/api-graphql": "0.0.0-unstable.eb81deee7e",
|
|
21
|
+
"@webiny/api-websockets": "0.0.0-unstable.eb81deee7e",
|
|
22
|
+
"@webiny/aws-sdk": "0.0.0-unstable.eb81deee7e",
|
|
23
|
+
"@webiny/background-tasks": "0.0.0-unstable.eb81deee7e",
|
|
24
|
+
"@webiny/di": "1.1.0",
|
|
25
|
+
"@webiny/event-handler-aws": "0.0.0-unstable.eb81deee7e",
|
|
26
|
+
"@webiny/event-handler-core": "0.0.0-unstable.eb81deee7e",
|
|
27
|
+
"@webiny/feature": "0.0.0-unstable.eb81deee7e",
|
|
28
|
+
"@webiny/handler": "0.0.0-unstable.eb81deee7e",
|
|
29
|
+
"@webiny/plugins": "0.0.0-unstable.eb81deee7e",
|
|
30
|
+
"@webiny/utils": "0.0.0-unstable.eb81deee7e",
|
|
31
|
+
"@webiny/validation": "0.0.0-unstable.eb81deee7e",
|
|
32
|
+
"exifreader": "4.43.0",
|
|
33
|
+
"mime": "4.1.0",
|
|
30
34
|
"object-hash": "3.0.0",
|
|
31
|
-
"p-map": "
|
|
32
|
-
"p-reduce": "
|
|
33
|
-
"sanitize-filename": "1.6.
|
|
34
|
-
"sharp": "0.
|
|
35
|
+
"p-map": "7.0.6",
|
|
36
|
+
"p-reduce": "3.0.0",
|
|
37
|
+
"sanitize-filename": "1.6.4",
|
|
38
|
+
"sharp": "0.35.3"
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
+
"@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
|
|
42
|
+
"rimraf": "6.1.3",
|
|
43
|
+
"typescript": "7.0.2",
|
|
44
|
+
"vitest": "4.1.11"
|
|
41
45
|
},
|
|
42
46
|
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
44
|
-
"directory": "dist"
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "node ../cli/bin.js run build",
|
|
48
|
-
"watch": "node ../cli/bin.js run watch"
|
|
47
|
+
"access": "public"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
|
|
50
|
+
"webiny": {
|
|
51
|
+
"publishFrom": "dist"
|
|
52
|
+
}
|
|
51
53
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { PresignedPost } from "@webiny/aws-sdk/client-s3";
|
|
1
|
+
import type { PresignedPost } from "@webiny/aws-sdk/client-s3/index.js";
|
|
2
|
+
import "@webiny/background-tasks/api/features/TaskController/augmentation.js";
|
|
2
3
|
export interface PresignedPostPayloadData {
|
|
3
4
|
name: string;
|
|
4
5
|
type: string;
|
package/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils/CdnPathsGenerator.js","sources":["../../src/utils/CdnPathsGenerator.ts"],"sourcesContent":["export class CdnPathsGenerator {\n generate(fileId: string): string[] {\n return [`/files/${fileId}/*`, `/private/${fileId}/*`];\n }\n}\n"],"names":["CdnPathsGenerator","fileId"],"mappings":"AAAO,MAAMA;IACT,SAASC,MAAc,EAAY;QAC/B,OAAO;YAAC,CAAC,OAAO,EAAEA,OAAO,EAAE,CAAC;YAAE,CAAC,SAAS,EAAEA,OAAO,EAAE,CAAC;SAAC;IACzD;AACJ"}
|
package/utils/FileExtension.d.ts
CHANGED
package/utils/FileExtension.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.FileExtension = void 0;
|
|
7
|
-
var _mimeTypes = require("./mimeTypes");
|
|
1
|
+
import { mimeTypes as external_mimeTypes_js_mimeTypes } from "./mimeTypes.js";
|
|
8
2
|
class FileExtension {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
constructor(data){
|
|
4
|
+
this.data = data;
|
|
5
|
+
}
|
|
6
|
+
getValue() {
|
|
7
|
+
const name = (this.data.key || this.data.name).toLowerCase();
|
|
8
|
+
const maybeExt = name.split(".").pop();
|
|
9
|
+
const extensions = external_mimeTypes_js_mimeTypes[this.data.type];
|
|
10
|
+
if (extensions && !extensions.includes(maybeExt)) return extensions[0];
|
|
11
|
+
return "";
|
|
18
12
|
}
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
13
|
}
|
|
22
|
-
|
|
14
|
+
export { FileExtension };
|
|
23
15
|
|
|
24
16
|
//# sourceMappingURL=FileExtension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/FileExtension.js","sources":["../../src/utils/FileExtension.ts"],"sourcesContent":["import { mimeTypes } from \"~/utils/mimeTypes.js\";\nimport type { PresignedPostPayloadData } from \"~/types.js\";\n\nexport class FileExtension {\n private data: PresignedPostPayloadData;\n\n constructor(data: PresignedPostPayloadData) {\n this.data = data;\n }\n\n getValue() {\n const name = (this.data.key || this.data.name).toLowerCase();\n\n const maybeExt = name.split(\".\").pop() as string;\n const extensions = mimeTypes[this.data.type];\n if (extensions && !extensions.includes(maybeExt)) {\n return extensions[0];\n }\n\n return \"\";\n }\n}\n"],"names":["FileExtension","data","name","maybeExt","extensions","mimeTypes"],"mappings":";AAGO,MAAMA;IAGT,YAAYC,IAA8B,CAAE;QACxC,IAAI,CAAC,IAAI,GAAGA;IAChB;IAEA,WAAW;QACP,MAAMC,OAAQ,KAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAG,EAAG,WAAW;QAE1D,MAAMC,WAAWD,KAAK,KAAK,CAAC,KAAK,GAAG;QACpC,MAAME,aAAaC,+BAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5C,IAAID,cAAc,CAACA,WAAW,QAAQ,CAACD,WACnC,OAAOC,UAAU,CAAC,EAAE;QAGxB,OAAO;IACX;AACJ"}
|
package/utils/FileKey.d.ts
CHANGED
package/utils/FileKey.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.FileKey = void 0;
|
|
8
|
-
var _sanitizeFilename = _interopRequireDefault(require("sanitize-filename"));
|
|
9
|
-
var _FileExtension = require("./FileExtension");
|
|
1
|
+
import sanitize_filename from "sanitize-filename";
|
|
2
|
+
import { FileExtension } from "./FileExtension.js";
|
|
10
3
|
class FileKey {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
constructor(data){
|
|
5
|
+
this.data = data;
|
|
6
|
+
this.extension = new FileExtension(data);
|
|
7
|
+
this.key = this.getSanitizedKey();
|
|
8
|
+
}
|
|
9
|
+
getExtension() {
|
|
10
|
+
return this.extension.getValue();
|
|
11
|
+
}
|
|
12
|
+
setKey(key) {
|
|
13
|
+
this.key = key;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
return [
|
|
18
|
+
this.data.keyPrefix,
|
|
19
|
+
this.data.id,
|
|
20
|
+
this.key
|
|
21
|
+
].filter(Boolean).join("/");
|
|
22
|
+
}
|
|
23
|
+
getSanitizedKey() {
|
|
24
|
+
const key = sanitize_filename(this.data.key || this.data.name).replace(/\s/g, "");
|
|
25
|
+
return [
|
|
26
|
+
key,
|
|
27
|
+
this.getExtension()
|
|
28
|
+
].filter(Boolean).join(".");
|
|
29
|
+
}
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
export { FileKey };
|
|
32
32
|
|
|
33
33
|
//# sourceMappingURL=FileKey.js.map
|
package/utils/FileKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/FileKey.js","sources":["../../src/utils/FileKey.ts"],"sourcesContent":["import sanitizeFilename from \"sanitize-filename\";\nimport type { PresignedPostPayloadData } from \"~/types.js\";\nimport { FileExtension } from \"~/utils/FileExtension.js\";\n\nexport class FileKey {\n private data: PresignedPostPayloadData;\n private extension: FileExtension;\n private key: string;\n\n constructor(data: PresignedPostPayloadData) {\n this.data = data;\n this.extension = new FileExtension(data);\n this.key = this.getSanitizedKey();\n }\n\n getExtension() {\n return this.extension.getValue();\n }\n\n setKey(key: string) {\n this.key = key;\n return this;\n }\n\n toString() {\n return [this.data.keyPrefix, this.data.id, this.key].filter(Boolean).join(\"/\");\n }\n\n private getSanitizedKey() {\n const key = sanitizeFilename(this.data.key || this.data.name).replace(/\\s/g, \"\");\n\n return [key, this.getExtension()].filter(Boolean).join(\".\");\n }\n}\n"],"names":["FileKey","data","FileExtension","key","Boolean","sanitizeFilename"],"mappings":";;AAIO,MAAMA;IAKT,YAAYC,IAA8B,CAAE;QACxC,IAAI,CAAC,IAAI,GAAGA;QACZ,IAAI,CAAC,SAAS,GAAG,IAAIC,cAAcD;QACnC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,eAAe;IACnC;IAEA,eAAe;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ;IAClC;IAEA,OAAOE,GAAW,EAAE;QAChB,IAAI,CAAC,GAAG,GAAGA;QACX,OAAO,IAAI;IACf;IAEA,WAAW;QACP,OAAO;YAAC,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAAE,IAAI,CAAC,GAAG;SAAC,CAAC,MAAM,CAACC,SAAS,IAAI,CAAC;IAC9E;IAEQ,kBAAkB;QACtB,MAAMD,MAAME,kBAAiB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO;QAE7E,OAAO;YAACF;YAAK,IAAI,CAAC,YAAY;SAAG,CAAC,MAAM,CAACC,SAAS,IAAI,CAAC;IAC3D;AACJ"}
|
package/utils/FileKey.test.js
CHANGED
|
@@ -1,60 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { FileKey } from "./FileKey.js";
|
|
3
|
+
describe("FileKey", ()=>{
|
|
4
|
+
it("should generate a file key (extension is included in the name)", ()=>{
|
|
5
|
+
const fileKey = new FileKey({
|
|
6
|
+
size: 1071690,
|
|
7
|
+
name: "image-14.jpg",
|
|
8
|
+
type: "image/jpeg"
|
|
9
|
+
});
|
|
10
|
+
expect(fileKey.toString()).toEqual("image-14.jpg");
|
|
10
11
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
it("should generate a file key (extension derived from file type)", ()=>{
|
|
13
|
+
const fileKey = new FileKey({
|
|
14
|
+
size: 1071690,
|
|
15
|
+
name: "image-14",
|
|
16
|
+
type: "image/jpeg"
|
|
17
|
+
});
|
|
18
|
+
expect(fileKey.toString()).toEqual("image-14.jpg");
|
|
18
19
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
it("should generate a file key containing id", ()=>{
|
|
21
|
+
const fileKey = new FileKey({
|
|
22
|
+
size: 1071690,
|
|
23
|
+
name: "image-14.jpeg",
|
|
24
|
+
type: "image/jpeg",
|
|
25
|
+
id: "12345678"
|
|
26
|
+
});
|
|
27
|
+
expect(fileKey.toString()).toEqual("12345678/image-14.jpeg");
|
|
27
28
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
it("should generate a file key containing prefix", ()=>{
|
|
30
|
+
const fileKey = new FileKey({
|
|
31
|
+
size: 1071690,
|
|
32
|
+
name: "image-14.jpeg",
|
|
33
|
+
type: "image/jpeg",
|
|
34
|
+
keyPrefix: "prefix"
|
|
35
|
+
});
|
|
36
|
+
expect(fileKey.toString()).toEqual("prefix/image-14.jpeg");
|
|
36
37
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
it("should generate a file key containing id and prefix", ()=>{
|
|
39
|
+
const fileKey = new FileKey({
|
|
40
|
+
size: 1071690,
|
|
41
|
+
name: "image-14.jpeg",
|
|
42
|
+
type: "image/jpeg",
|
|
43
|
+
id: "12345678",
|
|
44
|
+
keyPrefix: "prefix"
|
|
45
|
+
});
|
|
46
|
+
expect(fileKey.toString()).toEqual("prefix/12345678/image-14.jpeg");
|
|
46
47
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
it("should use the key defined in the input", ()=>{
|
|
49
|
+
const fileKey = new FileKey({
|
|
50
|
+
size: 1071690,
|
|
51
|
+
name: "image",
|
|
52
|
+
type: "image/jpeg",
|
|
53
|
+
key: "image-14.jpg"
|
|
54
|
+
});
|
|
55
|
+
expect(fileKey.toString()).toEqual("image-14.jpg");
|
|
55
56
|
});
|
|
56
|
-
expect(fileKey.toString()).toEqual("image-14.jpg");
|
|
57
|
-
});
|
|
58
57
|
});
|
|
59
58
|
|
|
60
59
|
//# sourceMappingURL=FileKey.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/FileKey.test.js","sources":["../../src/utils/FileKey.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { FileKey } from \"./FileKey.js\";\n\ndescribe(\"FileKey\", () => {\n it(\"should generate a file key (extension is included in the name)\", () => {\n const fileKey = new FileKey({\n size: 1071690,\n name: \"image-14.jpg\",\n type: \"image/jpeg\"\n });\n\n expect(fileKey.toString()).toEqual(\"image-14.jpg\");\n });\n\n it(\"should generate a file key (extension derived from file type)\", () => {\n const fileKey = new FileKey({\n size: 1071690,\n name: \"image-14\",\n type: \"image/jpeg\"\n });\n\n expect(fileKey.toString()).toEqual(\"image-14.jpg\");\n });\n\n it(\"should generate a file key containing id\", () => {\n const fileKey = new FileKey({\n size: 1071690,\n name: \"image-14.jpeg\",\n type: \"image/jpeg\",\n id: \"12345678\"\n });\n\n expect(fileKey.toString()).toEqual(\"12345678/image-14.jpeg\");\n });\n\n it(\"should generate a file key containing prefix\", () => {\n const fileKey = new FileKey({\n size: 1071690,\n name: \"image-14.jpeg\",\n type: \"image/jpeg\",\n keyPrefix: \"prefix\"\n });\n\n expect(fileKey.toString()).toEqual(\"prefix/image-14.jpeg\");\n });\n\n it(\"should generate a file key containing id and prefix\", () => {\n const fileKey = new FileKey({\n size: 1071690,\n name: \"image-14.jpeg\",\n type: \"image/jpeg\",\n id: \"12345678\",\n keyPrefix: \"prefix\"\n });\n\n expect(fileKey.toString()).toEqual(\"prefix/12345678/image-14.jpeg\");\n });\n\n it(\"should use the key defined in the input\", () => {\n const fileKey = new FileKey({\n size: 1071690,\n name: \"image\",\n type: \"image/jpeg\",\n key: \"image-14.jpg\"\n });\n\n expect(fileKey.toString()).toEqual(\"image-14.jpg\");\n });\n});\n"],"names":["describe","it","fileKey","FileKey","expect"],"mappings":";;AAGAA,SAAS,WAAW;IAChBC,GAAG,kEAAkE;QACjE,MAAMC,UAAU,IAAIC,QAAQ;YACxB,MAAM;YACN,MAAM;YACN,MAAM;QACV;QAEAC,OAAOF,QAAQ,QAAQ,IAAI,OAAO,CAAC;IACvC;IAEAD,GAAG,iEAAiE;QAChE,MAAMC,UAAU,IAAIC,QAAQ;YACxB,MAAM;YACN,MAAM;YACN,MAAM;QACV;QAEAC,OAAOF,QAAQ,QAAQ,IAAI,OAAO,CAAC;IACvC;IAEAD,GAAG,4CAA4C;QAC3C,MAAMC,UAAU,IAAIC,QAAQ;YACxB,MAAM;YACN,MAAM;YACN,MAAM;YACN,IAAI;QACR;QAEAC,OAAOF,QAAQ,QAAQ,IAAI,OAAO,CAAC;IACvC;IAEAD,GAAG,gDAAgD;QAC/C,MAAMC,UAAU,IAAIC,QAAQ;YACxB,MAAM;YACN,MAAM;YACN,MAAM;YACN,WAAW;QACf;QAEAC,OAAOF,QAAQ,QAAQ,IAAI,OAAO,CAAC;IACvC;IAEAD,GAAG,uDAAuD;QACtD,MAAMC,UAAU,IAAIC,QAAQ;YACxB,MAAM;YACN,MAAM;YACN,MAAM;YACN,IAAI;YACJ,WAAW;QACf;QAEAC,OAAOF,QAAQ,QAAQ,IAAI,OAAO,CAAC;IACvC;IAEAD,GAAG,2CAA2C;QAC1C,MAAMC,UAAU,IAAIC,QAAQ;YACxB,MAAM;YACN,MAAM;YACN,MAAM;YACN,KAAK;QACT;QAEAC,OAAOF,QAAQ,QAAQ,IAAI,OAAO,CAAC;IACvC;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FileData, PresignedPostPayloadData } from "../types";
|
|
2
|
-
import type { FileModifier } from "./FileUploadModifier";
|
|
1
|
+
import type { FileData, PresignedPostPayloadData } from "../types.js";
|
|
2
|
+
import type { FileModifier } from "./FileUploadModifier.js";
|
|
3
3
|
export interface FileToSign {
|
|
4
4
|
name: string;
|
|
5
5
|
key: string;
|
package/utils/FileNormalizer.js
CHANGED
|
@@ -1,49 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* FileNormalizer normalizes file data, before it's signed for upload to S3.
|
|
11
|
-
* It generates a unique file id, and makes sure that the file key includes the unique id.
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
1
|
+
import { mdbid } from "@webiny/utils";
|
|
2
|
+
import { FileKey } from "./FileKey.js";
|
|
3
|
+
import { mimeTypes as external_mimeTypes_js_mimeTypes } from "./mimeTypes.js";
|
|
4
|
+
const extensionToMime = new Map();
|
|
5
|
+
for (const [mime, extensions] of Object.entries(external_mimeTypes_js_mimeTypes))for (const ext of extensions)if (!extensionToMime.has(ext)) extensionToMime.set(ext, mime);
|
|
6
|
+
function resolveTypeFromName(name) {
|
|
7
|
+
const ext = name.slice(name.lastIndexOf(".") + 1).toLowerCase();
|
|
8
|
+
return extensionToMime.get(ext) || "application/octet-stream";
|
|
9
|
+
}
|
|
14
10
|
class FileNormalizer {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
async normalizeFile(payload) {
|
|
19
|
-
const data = {
|
|
20
|
-
...payload,
|
|
21
|
-
id: payload.id || (0, _utils.mdbid)(),
|
|
22
|
-
type: payload.type || "application/octet-stream"
|
|
23
|
-
};
|
|
24
|
-
const key = new _FileKey.FileKey(data);
|
|
25
|
-
const defaultKey = key.toString();
|
|
26
|
-
const file = {
|
|
27
|
-
name: data.name,
|
|
28
|
-
type: data.type,
|
|
29
|
-
key: defaultKey,
|
|
30
|
-
size: data.size
|
|
31
|
-
};
|
|
32
|
-
if (this.modifier) {
|
|
33
|
-
Object.assign(file, await this.modifier(file));
|
|
11
|
+
constructor(modifier){
|
|
12
|
+
this.modifier = modifier;
|
|
34
13
|
}
|
|
35
|
-
|
|
36
|
-
|
|
14
|
+
async normalizeFile(payload) {
|
|
15
|
+
const data = {
|
|
16
|
+
...payload,
|
|
17
|
+
id: payload.id || mdbid(),
|
|
18
|
+
type: payload.type || resolveTypeFromName(payload.name)
|
|
19
|
+
};
|
|
20
|
+
const key = new FileKey(data);
|
|
21
|
+
const defaultKey = key.toString();
|
|
22
|
+
const file = {
|
|
23
|
+
name: data.name,
|
|
24
|
+
type: data.type,
|
|
25
|
+
key: defaultKey,
|
|
26
|
+
size: data.size
|
|
27
|
+
};
|
|
28
|
+
if (this.modifier) Object.assign(file, await this.modifier(file));
|
|
29
|
+
if (defaultKey !== file.key) key.setKey(file.key);
|
|
30
|
+
return {
|
|
31
|
+
id: data.id,
|
|
32
|
+
key: key.toString(),
|
|
33
|
+
name: file.name,
|
|
34
|
+
size: file.size,
|
|
35
|
+
type: file.type
|
|
36
|
+
};
|
|
37
37
|
}
|
|
38
|
-
return {
|
|
39
|
-
id: data.id,
|
|
40
|
-
key: key.toString(),
|
|
41
|
-
name: file.name,
|
|
42
|
-
size: file.size,
|
|
43
|
-
type: file.type
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
38
|
}
|
|
47
|
-
|
|
39
|
+
export { FileNormalizer };
|
|
48
40
|
|
|
49
41
|
//# sourceMappingURL=FileNormalizer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/FileNormalizer.js","sources":["../../src/utils/FileNormalizer.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport type { FileData, PresignedPostPayloadData } from \"~/types.js\";\nimport { FileKey } from \"~/utils/FileKey.js\";\nimport { mimeTypes } from \"~/utils/mimeTypes.js\";\nimport type { FileModifier } from \"./FileUploadModifier.js\";\n\nexport interface FileToSign {\n name: string;\n key: string;\n type: string;\n size: number;\n}\n\nconst extensionToMime = new Map<string, string>();\nfor (const [mime, extensions] of Object.entries(mimeTypes)) {\n for (const ext of extensions) {\n if (!extensionToMime.has(ext)) {\n extensionToMime.set(ext, mime);\n }\n }\n}\n\nfunction resolveTypeFromName(name: string): string {\n const ext = name.slice(name.lastIndexOf(\".\") + 1).toLowerCase();\n return extensionToMime.get(ext) || \"application/octet-stream\";\n}\n\n/**\n * FileNormalizer normalizes file data, before it's signed for upload to S3.\n * It generates a unique file id, and makes sure that the file key includes the unique id.\n *\n */\nexport class FileNormalizer {\n private readonly modifier: FileModifier | undefined;\n\n constructor(modifier?: FileModifier) {\n this.modifier = modifier;\n }\n\n async normalizeFile(payload: PresignedPostPayloadData): Promise<FileData> {\n const data = {\n ...payload,\n id: payload.id || mdbid(),\n type: payload.type || resolveTypeFromName(payload.name)\n };\n\n const key = new FileKey(data);\n const defaultKey = key.toString();\n\n const file: FileToSign = {\n name: data.name,\n type: data.type,\n key: defaultKey,\n size: data.size\n };\n\n if (this.modifier) {\n Object.assign(file, await this.modifier(file));\n }\n\n if (defaultKey !== file.key) {\n key.setKey(file.key);\n }\n\n return {\n id: data.id,\n key: key.toString(),\n name: file.name,\n size: file.size,\n type: file.type\n };\n }\n}\n"],"names":["extensionToMime","Map","mime","extensions","Object","mimeTypes","ext","resolveTypeFromName","name","FileNormalizer","modifier","payload","data","mdbid","key","FileKey","defaultKey","file"],"mappings":";;;AAaA,MAAMA,kBAAkB,IAAIC;AAC5B,KAAK,MAAM,CAACC,MAAMC,WAAW,IAAIC,OAAO,OAAO,CAACC,iCAC5C,KAAK,MAAMC,OAAOH,WACd,IAAI,CAACH,gBAAgB,GAAG,CAACM,MACrBN,gBAAgB,GAAG,CAACM,KAAKJ;AAKrC,SAASK,oBAAoBC,IAAY;IACrC,MAAMF,MAAME,KAAK,KAAK,CAACA,KAAK,WAAW,CAAC,OAAO,GAAG,WAAW;IAC7D,OAAOR,gBAAgB,GAAG,CAACM,QAAQ;AACvC;AAOO,MAAMG;IAGT,YAAYC,QAAuB,CAAE;QACjC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,cAAcC,OAAiC,EAAqB;QACtE,MAAMC,OAAO;YACT,GAAGD,OAAO;YACV,IAAIA,QAAQ,EAAE,IAAIE;YAClB,MAAMF,QAAQ,IAAI,IAAIJ,oBAAoBI,QAAQ,IAAI;QAC1D;QAEA,MAAMG,MAAM,IAAIC,QAAQH;QACxB,MAAMI,aAAaF,IAAI,QAAQ;QAE/B,MAAMG,OAAmB;YACrB,MAAML,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,KAAKI;YACL,MAAMJ,KAAK,IAAI;QACnB;QAEA,IAAI,IAAI,CAAC,QAAQ,EACbR,OAAO,MAAM,CAACa,MAAM,MAAM,IAAI,CAAC,QAAQ,CAACA;QAG5C,IAAID,eAAeC,KAAK,GAAG,EACvBH,IAAI,MAAM,CAACG,KAAK,GAAG;QAGvB,OAAO;YACH,IAAIL,KAAK,EAAE;YACX,KAAKE,IAAI,QAAQ;YACjB,MAAMG,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;QACnB;IACJ;AACJ"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { FileToSign } from "
|
|
2
|
+
import type { FileToSign } from "../utils/FileNormalizer.js";
|
|
3
3
|
interface Setter<T> {
|
|
4
4
|
(param: T): T;
|
|
5
5
|
}
|
|
6
|
-
declare class
|
|
6
|
+
declare class FileUploadModifierBuilder {
|
|
7
7
|
private fileSetters;
|
|
8
8
|
setFile(setter: Setter<FileToSign>): void;
|
|
9
9
|
execute(file: FileToSign): Promise<FileToSign>;
|
|
10
10
|
}
|
|
11
11
|
interface FileUploadModifierCallbackParams {
|
|
12
12
|
modifier: {
|
|
13
|
-
setFile:
|
|
13
|
+
setFile: FileUploadModifierBuilder["setFile"];
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
export declare class FileUploadModifierPlugin extends Plugin {
|
|
@@ -23,6 +23,12 @@ interface FileUploadModifierCallable {
|
|
|
23
23
|
(params: FileUploadModifierCallbackParams): void;
|
|
24
24
|
}
|
|
25
25
|
export declare const createFileUploadModifier: (cb: FileUploadModifierCallable) => FileUploadModifierPlugin;
|
|
26
|
+
/**
|
|
27
|
+
* DI multiple-abstraction for file-upload modifiers. Replaces the old
|
|
28
|
+
* `context.plugins.byType(FileUploadModifierPlugin.type)` lookup in createFileNormalizerFromContext.
|
|
29
|
+
* Extensions register modifiers via `container.registerInstance(FileUploadModifier, createFileUploadModifier(cb))`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const FileUploadModifier: import("@webiny/di").Abstraction<FileUploadModifierPlugin>;
|
|
26
32
|
export interface FileModifier {
|
|
27
33
|
(file: FileToSign): Promise<Partial<FileToSign>> | Partial<FileToSign>;
|
|
28
34
|
}
|