@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.
Files changed (232) hide show
  1. package/FileManagerS3Feature.d.ts +9 -0
  2. package/FileManagerS3Feature.js +27 -0
  3. package/FileManagerS3Feature.js.map +1 -0
  4. package/README.md +11 -1
  5. package/assetDelivery/abstractions.d.ts +11 -0
  6. package/assetDelivery/abstractions.js +7 -0
  7. package/assetDelivery/abstractions.js.map +1 -0
  8. package/assetDelivery/assetDeliveryConfig.d.ts +2 -2
  9. package/assetDelivery/assetDeliveryConfig.js +10 -49
  10. package/assetDelivery/assetDeliveryConfig.js.map +1 -1
  11. package/assetDelivery/createAssetDelivery.d.ts +3 -3
  12. package/assetDelivery/createAssetDelivery.js +7 -28
  13. package/assetDelivery/createAssetDelivery.js.map +1 -1
  14. package/assetDelivery/feature.d.ts +5 -0
  15. package/assetDelivery/feature.js +36 -0
  16. package/assetDelivery/feature.js.map +1 -0
  17. package/assetDelivery/index.d.ts +8 -9
  18. package/assetDelivery/index.js +8 -70
  19. package/assetDelivery/s3/LazySharpTransform.d.ts +34 -0
  20. package/assetDelivery/s3/LazySharpTransform.js +34 -0
  21. package/assetDelivery/s3/LazySharpTransform.js.map +1 -0
  22. package/assetDelivery/s3/S3AssetResolver.d.ts +9 -4
  23. package/assetDelivery/s3/S3AssetResolver.js +34 -32
  24. package/assetDelivery/s3/S3AssetResolver.js.map +1 -1
  25. package/assetDelivery/s3/S3ContentsReader.d.ts +1 -3
  26. package/assetDelivery/s3/S3ContentsReader.js +12 -22
  27. package/assetDelivery/s3/S3ContentsReader.js.map +1 -1
  28. package/assetDelivery/s3/S3ErrorAssetReply.js +11 -17
  29. package/assetDelivery/s3/S3ErrorAssetReply.js.map +1 -1
  30. package/assetDelivery/s3/S3OutputStrategy.d.ts +6 -6
  31. package/assetDelivery/s3/S3OutputStrategy.js +35 -35
  32. package/assetDelivery/s3/S3OutputStrategy.js.map +1 -1
  33. package/assetDelivery/s3/S3RedirectAssetReply.js +14 -20
  34. package/assetDelivery/s3/S3RedirectAssetReply.js.map +1 -1
  35. package/assetDelivery/s3/S3StreamAssetReply.js +14 -20
  36. package/assetDelivery/s3/S3StreamAssetReply.js.map +1 -1
  37. package/assetDelivery/s3/SharpTransform.d.ts +22 -14
  38. package/assetDelivery/s3/SharpTransform.js +163 -182
  39. package/assetDelivery/s3/SharpTransform.js.map +1 -1
  40. package/assetDelivery/s3/transformation/AssetKeyGenerator.js +17 -25
  41. package/assetDelivery/s3/transformation/AssetKeyGenerator.js.map +1 -1
  42. package/assetDelivery/s3/transformation/CallableContentsReader.d.ts +0 -2
  43. package/assetDelivery/s3/transformation/CallableContentsReader.js +7 -13
  44. package/assetDelivery/s3/transformation/CallableContentsReader.js.map +1 -1
  45. package/assetDelivery/s3/transformation/WidthCollection.js +14 -22
  46. package/assetDelivery/s3/transformation/WidthCollection.js.map +1 -1
  47. package/assetDelivery/s3/transformation/utils.d.ts +1 -3
  48. package/assetDelivery/s3/transformation/utils.js +26 -28
  49. package/assetDelivery/s3/transformation/utils.js.map +1 -1
  50. package/assetDelivery/threatDetection/ObjectKey.d.ts +7 -0
  51. package/assetDelivery/threatDetection/ObjectKey.js +18 -0
  52. package/assetDelivery/threatDetection/ObjectKey.js.map +1 -0
  53. package/assetDelivery/threatDetection/createThreatDetectionEventHandler.d.ts +22 -2
  54. package/assetDelivery/threatDetection/createThreatDetectionEventHandler.js +49 -58
  55. package/assetDelivery/threatDetection/createThreatDetectionEventHandler.js.map +1 -1
  56. package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.d.ts +1 -1
  57. package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.js +3 -11
  58. package/assetDelivery/threatDetection/createThreatDetectionPluginLoader.js.map +1 -1
  59. package/assetDelivery/threatDetection/index.d.ts +2 -2
  60. package/assetDelivery/threatDetection/index.js +2 -29
  61. package/assetDelivery/threatDetection/processThreatScanResult.d.ts +3 -2
  62. package/assetDelivery/threatDetection/processThreatScanResult.js +56 -61
  63. package/assetDelivery/threatDetection/processThreatScanResult.js.map +1 -1
  64. package/assetDelivery/threatDetection/types.d.ts +0 -4
  65. package/assetDelivery/threatDetection/types.js +0 -7
  66. package/assetDelivery/types.d.ts +4 -2
  67. package/assetDelivery/types.js +0 -7
  68. package/enterprise/ApplyThreatScanning/CreateFileWithThreatScanDecorator.d.ts +13 -0
  69. package/enterprise/ApplyThreatScanning/CreateFileWithThreatScanDecorator.js +28 -0
  70. package/enterprise/ApplyThreatScanning/CreateFileWithThreatScanDecorator.js.map +1 -0
  71. package/enterprise/ApplyThreatScanning/feature.d.ts +4 -0
  72. package/enterprise/ApplyThreatScanning/feature.js +11 -0
  73. package/enterprise/ApplyThreatScanning/feature.js.map +1 -0
  74. package/features/DeleteFileFromBucket/DeleteFileFromBucketHandler.d.ts +15 -0
  75. package/features/DeleteFileFromBucket/DeleteFileFromBucketHandler.js +35 -0
  76. package/features/DeleteFileFromBucket/DeleteFileFromBucketHandler.js.map +1 -0
  77. package/features/DeleteFileFromBucket/DeleteS3FolderTask.d.ts +37 -0
  78. package/features/DeleteFileFromBucket/DeleteS3FolderTask.js +57 -0
  79. package/features/DeleteFileFromBucket/DeleteS3FolderTask.js.map +1 -0
  80. package/features/DeleteFileFromBucket/feature.d.ts +4 -0
  81. package/features/DeleteFileFromBucket/feature.js +13 -0
  82. package/features/DeleteFileFromBucket/feature.js.map +1 -0
  83. package/features/ExtractMetadata/ExtractMetadataHandler.d.ts +11 -0
  84. package/features/ExtractMetadata/ExtractMetadataHandler.js +25 -0
  85. package/features/ExtractMetadata/ExtractMetadataHandler.js.map +1 -0
  86. package/features/ExtractMetadata/ExtractMetadataTask.d.ts +29 -0
  87. package/features/ExtractMetadata/ExtractMetadataTask.js +99 -0
  88. package/features/ExtractMetadata/ExtractMetadataTask.js.map +1 -0
  89. package/features/ExtractMetadata/feature.d.ts +4 -0
  90. package/features/ExtractMetadata/feature.js +13 -0
  91. package/features/ExtractMetadata/feature.js.map +1 -0
  92. package/features/FlushCache/FlushCacheOnFileDeleteHandler.d.ts +12 -0
  93. package/features/FlushCache/FlushCacheOnFileDeleteHandler.js +28 -0
  94. package/features/FlushCache/FlushCacheOnFileDeleteHandler.js.map +1 -0
  95. package/features/FlushCache/FlushCacheOnFileUpdateHandler.d.ts +12 -0
  96. package/features/FlushCache/FlushCacheOnFileUpdateHandler.js +31 -0
  97. package/features/FlushCache/FlushCacheOnFileUpdateHandler.js.map +1 -0
  98. package/features/FlushCache/InvalidateCacheTask.d.ts +31 -0
  99. package/features/FlushCache/InvalidateCacheTask.js +84 -0
  100. package/features/FlushCache/InvalidateCacheTask.js.map +1 -0
  101. package/features/FlushCache/feature.d.ts +4 -0
  102. package/features/FlushCache/feature.js +15 -0
  103. package/features/FlushCache/feature.js.map +1 -0
  104. package/features/GetFileContentsById/GetFileContentsByIdUseCase.d.ts +13 -0
  105. package/features/GetFileContentsById/GetFileContentsByIdUseCase.js +40 -0
  106. package/features/GetFileContentsById/GetFileContentsByIdUseCase.js.map +1 -0
  107. package/features/GetFileContentsById/feature.d.ts +4 -0
  108. package/features/GetFileContentsById/feature.js +11 -0
  109. package/features/GetFileContentsById/feature.js.map +1 -0
  110. package/features/GetFileContentsByKey/GetFileContentsByKeyUseCase.d.ts +13 -0
  111. package/features/GetFileContentsByKey/GetFileContentsByKeyUseCase.js +40 -0
  112. package/features/GetFileContentsByKey/GetFileContentsByKeyUseCase.js.map +1 -0
  113. package/features/GetFileContentsByKey/feature.d.ts +4 -0
  114. package/features/GetFileContentsByKey/feature.js +11 -0
  115. package/features/GetFileContentsByKey/feature.js.map +1 -0
  116. package/features/WriteFileMetadata/MetadataReader.d.ts +14 -0
  117. package/features/WriteFileMetadata/MetadataReader.js +13 -0
  118. package/features/WriteFileMetadata/MetadataReader.js.map +1 -0
  119. package/features/WriteFileMetadata/MetadataWriter.d.ts +10 -0
  120. package/features/WriteFileMetadata/MetadataWriter.js +28 -0
  121. package/features/WriteFileMetadata/MetadataWriter.js.map +1 -0
  122. package/features/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.d.ts +12 -0
  123. package/features/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js +23 -0
  124. package/features/WriteFileMetadata/WriteMetadataAfterBatchCreateHandler.js.map +1 -0
  125. package/features/WriteFileMetadata/WriteMetadataAfterCreateHandler.d.ts +12 -0
  126. package/features/WriteFileMetadata/WriteMetadataAfterCreateHandler.js +25 -0
  127. package/features/WriteFileMetadata/WriteMetadataAfterCreateHandler.js.map +1 -0
  128. package/features/WriteFileMetadata/feature.d.ts +4 -0
  129. package/features/WriteFileMetadata/feature.js +13 -0
  130. package/features/WriteFileMetadata/feature.js.map +1 -0
  131. package/graphql/S3GraphQLSchema.d.ts +10 -0
  132. package/graphql/S3GraphQLSchema.js +233 -0
  133. package/graphql/S3GraphQLSchema.js.map +1 -0
  134. package/graphql/checkPermissions.d.ts +5 -0
  135. package/graphql/checkPermissions.js +22 -0
  136. package/graphql/checkPermissions.js.map +1 -0
  137. package/index.d.ts +4 -5
  138. package/index.js +3 -36
  139. package/multiPartUpload/CompleteMultiPartUploadUseCase.d.ts +1 -1
  140. package/multiPartUpload/CompleteMultiPartUploadUseCase.js +49 -59
  141. package/multiPartUpload/CompleteMultiPartUploadUseCase.js.map +1 -1
  142. package/multiPartUpload/CreateMultiPartUploadUseCase.d.ts +2 -2
  143. package/multiPartUpload/CreateMultiPartUploadUseCase.js +30 -44
  144. package/multiPartUpload/CreateMultiPartUploadUseCase.js.map +1 -1
  145. package/package.json +36 -34
  146. package/types.d.ts +2 -1
  147. package/types.js +1 -7
  148. package/utils/CdnPathsGenerator.d.ts +3 -0
  149. package/utils/CdnPathsGenerator.js +11 -0
  150. package/utils/CdnPathsGenerator.js.map +1 -0
  151. package/utils/FileExtension.d.ts +1 -1
  152. package/utils/FileExtension.js +11 -19
  153. package/utils/FileExtension.js.map +1 -1
  154. package/utils/FileKey.d.ts +1 -1
  155. package/utils/FileKey.js +29 -29
  156. package/utils/FileKey.js.map +1 -1
  157. package/utils/FileKey.test.js +50 -51
  158. package/utils/FileKey.test.js.map +1 -1
  159. package/utils/FileNormalizer.d.ts +2 -2
  160. package/utils/FileNormalizer.js +35 -43
  161. package/utils/FileNormalizer.js.map +1 -1
  162. package/utils/FileUploadModifier.d.ts +9 -3
  163. package/utils/FileUploadModifier.js +36 -44
  164. package/utils/FileUploadModifier.js.map +1 -1
  165. package/utils/createFileNormalizerFromContext.d.ts +2 -2
  166. package/utils/createFileNormalizerFromContext.js +6 -12
  167. package/utils/createFileNormalizerFromContext.js.map +1 -1
  168. package/utils/getPresignedPostPayload.d.ts +4 -3
  169. package/utils/getPresignedPostPayload.js +38 -40
  170. package/utils/getPresignedPostPayload.js.map +1 -1
  171. package/utils/mimeTypes.js +6 -20
  172. package/utils/mimeTypes.js.map +1 -1
  173. package/utils/uploadFileToS3.d.ts +2 -5
  174. package/utils/uploadFileToS3.js +11 -23
  175. package/utils/uploadFileToS3.js.map +1 -1
  176. package/assetDelivery/createCustomAssetDelivery.d.ts +0 -12
  177. package/assetDelivery/createCustomAssetDelivery.js +0 -28
  178. package/assetDelivery/createCustomAssetDelivery.js.map +0 -1
  179. package/assetDelivery/customAssets/CustomAsset.d.ts +0 -6
  180. package/assetDelivery/customAssets/CustomAsset.js +0 -14
  181. package/assetDelivery/customAssets/CustomAsset.js.map +0 -1
  182. package/assetDelivery/customAssets/CustomAssetProcessor.d.ts +0 -10
  183. package/assetDelivery/customAssets/CustomAssetProcessor.js +0 -25
  184. package/assetDelivery/customAssets/CustomAssetProcessor.js.map +0 -1
  185. package/assetDelivery/customAssets/S3CustomAssetResolver.d.ts +0 -15
  186. package/assetDelivery/customAssets/S3CustomAssetResolver.js +0 -90
  187. package/assetDelivery/customAssets/S3CustomAssetResolver.js.map +0 -1
  188. package/assetDelivery/customAssets/customAssetDeliveryConfig.d.ts +0 -1
  189. package/assetDelivery/customAssets/customAssetDeliveryConfig.js +0 -30
  190. package/assetDelivery/customAssets/customAssetDeliveryConfig.js.map +0 -1
  191. package/assetDelivery/index.js.map +0 -1
  192. package/assetDelivery/s3/S3AssetMetadataReader.d.ts +0 -15
  193. package/assetDelivery/s3/S3AssetMetadataReader.js +0 -36
  194. package/assetDelivery/s3/S3AssetMetadataReader.js.map +0 -1
  195. package/assetDelivery/s3/transformation/legacyUtils.d.ts +0 -12
  196. package/assetDelivery/s3/transformation/legacyUtils.js +0 -34
  197. package/assetDelivery/s3/transformation/legacyUtils.js.map +0 -1
  198. package/assetDelivery/threatDetection/index.js.map +0 -1
  199. package/assetDelivery/threatDetection/types.js.map +0 -1
  200. package/assetDelivery/types.js.map +0 -1
  201. package/flushCdnCache/CdnPathsGenerator.d.ts +0 -4
  202. package/flushCdnCache/CdnPathsGenerator.js +0 -14
  203. package/flushCdnCache/CdnPathsGenerator.js.map +0 -1
  204. package/flushCdnCache/InvalidateCacheTask.d.ts +0 -18
  205. package/flushCdnCache/InvalidateCacheTask.js +0 -78
  206. package/flushCdnCache/InvalidateCacheTask.js.map +0 -1
  207. package/flushCdnCache/flushCacheOnFileDelete.d.ts +0 -3
  208. package/flushCdnCache/flushCacheOnFileDelete.js +0 -34
  209. package/flushCdnCache/flushCacheOnFileDelete.js.map +0 -1
  210. package/flushCdnCache/flushCacheOnFileUpdate.d.ts +0 -3
  211. package/flushCdnCache/flushCacheOnFileUpdate.js +0 -40
  212. package/flushCdnCache/flushCacheOnFileUpdate.js.map +0 -1
  213. package/flushCdnCache/index.d.ts +0 -1
  214. package/flushCdnCache/index.js +0 -15
  215. package/flushCdnCache/index.js.map +0 -1
  216. package/flushCdnCache/invalidateCacheTaskDefinition.d.ts +0 -2
  217. package/flushCdnCache/invalidateCacheTaskDefinition.js +0 -22
  218. package/flushCdnCache/invalidateCacheTaskDefinition.js.map +0 -1
  219. package/index.js.map +0 -1
  220. package/plugins/addFileMetadata.d.ts +0 -10
  221. package/plugins/addFileMetadata.js +0 -67
  222. package/plugins/addFileMetadata.js.map +0 -1
  223. package/plugins/checkPermissions.d.ts +0 -4
  224. package/plugins/checkPermissions.js +0 -44
  225. package/plugins/checkPermissions.js.map +0 -1
  226. package/plugins/fileStorageS3.d.ts +0 -3
  227. package/plugins/fileStorageS3.js +0 -60
  228. package/plugins/fileStorageS3.js.map +0 -1
  229. package/plugins/graphqlFileStorageS3.d.ts +0 -4
  230. package/plugins/graphqlFileStorageS3.js +0 -213
  231. package/plugins/graphqlFileStorageS3.js.map +0 -1
  232. package/types.js.map +0 -1
@@ -1,49 +1,41 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createModifierFromPlugins = exports.createFileUploadModifier = exports.FileUploadModifierPlugin = void 0;
8
- var _pReduce = _interopRequireDefault(require("p-reduce"));
9
- var _plugins = require("@webiny/plugins");
10
- class FileUploadModifier {
11
- fileSetters = [];
12
- setFile(setter) {
13
- this.fileSetters.push(setter);
14
- }
15
- execute(file) {
16
- return (0, _pReduce.default)(this.fileSetters, async (file, setter) => {
17
- // We need to spread the original file, then add (potentially) partial changes.
18
- return {
19
- ...file,
20
- ...(await setter(file))
21
- };
22
- }, file);
23
- }
1
+ import p_reduce from "p-reduce";
2
+ import { Plugin } from "@webiny/plugins";
3
+ import { createAbstraction } from "@webiny/feature/api";
4
+ class FileUploadModifierBuilder {
5
+ setFile(setter) {
6
+ this.fileSetters.push(setter);
7
+ }
8
+ execute(file) {
9
+ return p_reduce(this.fileSetters, async (file, setter)=>({
10
+ ...file,
11
+ ...await setter(file)
12
+ }), file);
13
+ }
14
+ constructor(){
15
+ this.fileSetters = [];
16
+ }
24
17
  }
25
- class FileUploadModifierPlugin extends _plugins.Plugin {
26
- static type = "fm.s3.uploadModifier";
27
- constructor(cb) {
28
- super();
29
- this.cb = cb;
30
- }
31
- execute(params) {
32
- return this.cb(params);
33
- }
18
+ class FileUploadModifierPlugin extends Plugin {
19
+ static{
20
+ this.type = "fm.s3.uploadModifier";
21
+ }
22
+ constructor(cb){
23
+ super();
24
+ this.cb = cb;
25
+ }
26
+ execute(params) {
27
+ return this.cb(params);
28
+ }
34
29
  }
35
- exports.FileUploadModifierPlugin = FileUploadModifierPlugin;
36
- const createFileUploadModifier = cb => {
37
- return new FileUploadModifierPlugin(cb);
38
- };
39
- exports.createFileUploadModifier = createFileUploadModifier;
40
- const createModifierFromPlugins = (plugins = []) => {
41
- const modifier = new FileUploadModifier();
42
- plugins.forEach(pl => pl.execute({
43
- modifier
44
- }));
45
- return file => modifier.execute(file);
30
+ const createFileUploadModifier = (cb)=>new FileUploadModifierPlugin(cb);
31
+ const FileUploadModifier = createAbstraction("FileUploadModifier");
32
+ const createModifierFromPlugins = (plugins = [])=>{
33
+ const modifier = new FileUploadModifierBuilder();
34
+ plugins.forEach((pl)=>pl.execute({
35
+ modifier
36
+ }));
37
+ return (file)=>modifier.execute(file);
46
38
  };
47
- exports.createModifierFromPlugins = createModifierFromPlugins;
39
+ export { FileUploadModifier, FileUploadModifierPlugin, createFileUploadModifier, createModifierFromPlugins };
48
40
 
49
41
  //# sourceMappingURL=FileUploadModifier.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_pReduce","_interopRequireDefault","require","_plugins","FileUploadModifier","fileSetters","setFile","setter","push","execute","file","pReduce","FileUploadModifierPlugin","Plugin","type","constructor","cb","params","exports","createFileUploadModifier","createModifierFromPlugins","plugins","modifier","forEach","pl"],"sources":["FileUploadModifier.ts"],"sourcesContent":["import pReduce from \"p-reduce\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { FileToSign } from \"~/utils/FileNormalizer\";\n\ninterface Setter<T> {\n (param: T): T;\n}\n\nclass FileUploadModifier {\n private fileSetters: Setter<FileToSign>[] = [];\n\n setFile(setter: Setter<FileToSign>): void {\n this.fileSetters.push(setter);\n }\n\n execute(file: FileToSign) {\n return pReduce(\n this.fileSetters,\n async (file, setter) => {\n // We need to spread the original file, then add (potentially) partial changes.\n return { ...file, ...(await setter(file)) };\n },\n file\n );\n }\n}\n\ninterface FileUploadModifierCallbackParams {\n modifier: {\n setFile: FileUploadModifier[\"setFile\"];\n };\n}\n\nexport class FileUploadModifierPlugin extends Plugin {\n public static override type = \"fm.s3.uploadModifier\";\n private readonly cb: FileUploadModifierCallable;\n\n constructor(cb: FileUploadModifierCallable) {\n super();\n this.cb = cb;\n }\n\n execute(params: FileUploadModifierCallbackParams) {\n return this.cb(params);\n }\n}\n\ninterface FileUploadModifierCallable {\n (params: FileUploadModifierCallbackParams): void;\n}\n\nexport const createFileUploadModifier = (cb: FileUploadModifierCallable) => {\n return new FileUploadModifierPlugin(cb);\n};\n\nexport interface FileModifier {\n (file: FileToSign): Promise<Partial<FileToSign>> | Partial<FileToSign>;\n}\n\nexport const createModifierFromPlugins = (\n plugins: FileUploadModifierPlugin[] = []\n): FileModifier => {\n const modifier = new FileUploadModifier();\n plugins.forEach(pl => pl.execute({ modifier }));\n\n return (file: FileToSign) => modifier.execute(file);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,MAAME,kBAAkB,CAAC;EACbC,WAAW,GAAyB,EAAE;EAE9CC,OAAOA,CAACC,MAA0B,EAAQ;IACtC,IAAI,CAACF,WAAW,CAACG,IAAI,CAACD,MAAM,CAAC;EACjC;EAEAE,OAAOA,CAACC,IAAgB,EAAE;IACtB,OAAO,IAAAC,gBAAO,EACV,IAAI,CAACN,WAAW,EAChB,OAAOK,IAAI,EAAEH,MAAM,KAAK;MACpB;MACA,OAAO;QAAE,GAAGG,IAAI;QAAE,IAAI,MAAMH,MAAM,CAACG,IAAI,CAAC;MAAE,CAAC;IAC/C,CAAC,EACDA,IACJ,CAAC;EACL;AACJ;AAQO,MAAME,wBAAwB,SAASC,eAAM,CAAC;EACjD,OAAuBC,IAAI,GAAG,sBAAsB;EAGpDC,WAAWA,CAACC,EAA8B,EAAE;IACxC,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEAP,OAAOA,CAACQ,MAAwC,EAAE;IAC9C,OAAO,IAAI,CAACD,EAAE,CAACC,MAAM,CAAC;EAC1B;AACJ;AAACC,OAAA,CAAAN,wBAAA,GAAAA,wBAAA;AAMM,MAAMO,wBAAwB,GAAIH,EAA8B,IAAK;EACxE,OAAO,IAAIJ,wBAAwB,CAACI,EAAE,CAAC;AAC3C,CAAC;AAACE,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAMK,MAAMC,yBAAyB,GAAGA,CACrCC,OAAmC,GAAG,EAAE,KACzB;EACf,MAAMC,QAAQ,GAAG,IAAIlB,kBAAkB,CAAC,CAAC;EACzCiB,OAAO,CAACE,OAAO,CAACC,EAAE,IAAIA,EAAE,CAACf,OAAO,CAAC;IAAEa;EAAS,CAAC,CAAC,CAAC;EAE/C,OAAQZ,IAAgB,IAAKY,QAAQ,CAACb,OAAO,CAACC,IAAI,CAAC;AACvD,CAAC;AAACQ,OAAA,CAAAE,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"file":"utils/FileUploadModifier.js","sources":["../../src/utils/FileUploadModifier.ts"],"sourcesContent":["import pReduce from \"p-reduce\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { FileToSign } from \"~/utils/FileNormalizer.js\";\n\ninterface Setter<T> {\n (param: T): T;\n}\n\nclass FileUploadModifierBuilder {\n private fileSetters: Setter<FileToSign>[] = [];\n\n setFile(setter: Setter<FileToSign>): void {\n this.fileSetters.push(setter);\n }\n\n execute(file: FileToSign) {\n return pReduce(\n this.fileSetters,\n async (file, setter) => {\n // We need to spread the original file, then add (potentially) partial changes.\n return { ...file, ...(await setter(file)) };\n },\n file\n );\n }\n}\n\ninterface FileUploadModifierCallbackParams {\n modifier: {\n setFile: FileUploadModifierBuilder[\"setFile\"];\n };\n}\n\nexport class FileUploadModifierPlugin extends Plugin {\n public static override type = \"fm.s3.uploadModifier\";\n private readonly cb: FileUploadModifierCallable;\n\n constructor(cb: FileUploadModifierCallable) {\n super();\n this.cb = cb;\n }\n\n execute(params: FileUploadModifierCallbackParams) {\n return this.cb(params);\n }\n}\n\ninterface FileUploadModifierCallable {\n (params: FileUploadModifierCallbackParams): void;\n}\n\nexport const createFileUploadModifier = (cb: FileUploadModifierCallable) => {\n return new FileUploadModifierPlugin(cb);\n};\n\n/**\n * DI multiple-abstraction for file-upload modifiers. Replaces the old\n * `context.plugins.byType(FileUploadModifierPlugin.type)` lookup in createFileNormalizerFromContext.\n * Extensions register modifiers via `container.registerInstance(FileUploadModifier, createFileUploadModifier(cb))`.\n */\nexport const FileUploadModifier = createAbstraction<FileUploadModifierPlugin>(\"FileUploadModifier\");\n\nexport interface FileModifier {\n (file: FileToSign): Promise<Partial<FileToSign>> | Partial<FileToSign>;\n}\n\nexport const createModifierFromPlugins = (\n plugins: FileUploadModifierPlugin[] = []\n): FileModifier => {\n const modifier = new FileUploadModifierBuilder();\n plugins.forEach(pl => pl.execute({ modifier }));\n\n return (file: FileToSign) => modifier.execute(file);\n};\n"],"names":["FileUploadModifierBuilder","setter","file","pReduce","FileUploadModifierPlugin","Plugin","cb","params","createFileUploadModifier","FileUploadModifier","createAbstraction","createModifierFromPlugins","plugins","modifier","pl"],"mappings":";;;AASA,MAAMA;IAGF,QAAQC,MAA0B,EAAQ;QACtC,IAAI,CAAC,WAAW,CAAC,IAAI,CAACA;IAC1B;IAEA,QAAQC,IAAgB,EAAE;QACtB,OAAOC,SACH,IAAI,CAAC,WAAW,EAChB,OAAOD,MAAMD,SAEF;gBAAE,GAAGC,IAAI;gBAAE,GAAI,MAAMD,OAAOC,KAAK;YAAE,IAE9CA;IAER;;aAfQ,WAAW,GAAyB,EAAE;;AAgBlD;AAQO,MAAME,iCAAiCC;;aACnB,IAAI,GAAG;;IAG9B,YAAYC,EAA8B,CAAE;QACxC,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,QAAQC,MAAwC,EAAE;QAC9C,OAAO,IAAI,CAAC,EAAE,CAACA;IACnB;AACJ;AAMO,MAAMC,2BAA2B,CAACF,KAC9B,IAAIF,yBAAyBE;AAQjC,MAAMG,qBAAqBC,kBAA4C;AAMvE,MAAMC,4BAA4B,CACrCC,UAAsC,EAAE;IAExC,MAAMC,WAAW,IAAIb;IACrBY,QAAQ,OAAO,CAACE,CAAAA,KAAMA,GAAG,OAAO,CAAC;YAAED;QAAS;IAE5C,OAAO,CAACX,OAAqBW,SAAS,OAAO,CAACX;AAClD"}
@@ -1,3 +1,3 @@
1
- import type { Context } from "@webiny/api/types";
2
- import { FileNormalizer } from "./FileNormalizer";
1
+ import type { Context } from "@webiny/api/types.js";
2
+ import { FileNormalizer } from "../utils/FileNormalizer.js";
3
3
  export declare const createFileNormalizerFromContext: (context: Context) => FileNormalizer;
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFileNormalizerFromContext = void 0;
7
- var _FileNormalizer = require("./FileNormalizer");
8
- var _FileUploadModifier = require("./FileUploadModifier");
9
- const createFileNormalizerFromContext = context => {
10
- const modifierPlugins = context.plugins.byType(_FileUploadModifier.FileUploadModifierPlugin.type);
11
- return new _FileNormalizer.FileNormalizer((0, _FileUploadModifier.createModifierFromPlugins)(modifierPlugins));
1
+ import { FileNormalizer } from "./FileNormalizer.js";
2
+ import { FileUploadModifier, createModifierFromPlugins } from "./FileUploadModifier.js";
3
+ const createFileNormalizerFromContext = (context)=>{
4
+ const modifierPlugins = context.container.resolveAll(FileUploadModifier);
5
+ return new FileNormalizer(createModifierFromPlugins(modifierPlugins));
12
6
  };
13
- exports.createFileNormalizerFromContext = createFileNormalizerFromContext;
7
+ export { createFileNormalizerFromContext };
14
8
 
15
9
  //# sourceMappingURL=createFileNormalizerFromContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_FileNormalizer","require","_FileUploadModifier","createFileNormalizerFromContext","context","modifierPlugins","plugins","byType","FileUploadModifierPlugin","type","FileNormalizer","createModifierFromPlugins","exports"],"sources":["createFileNormalizerFromContext.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types\";\nimport { FileNormalizer } from \"~/utils/FileNormalizer\";\nimport { createModifierFromPlugins, FileUploadModifierPlugin } from \"~/utils/FileUploadModifier\";\n\nexport const createFileNormalizerFromContext = (context: Context) => {\n const modifierPlugins = context.plugins.byType<FileUploadModifierPlugin>(\n FileUploadModifierPlugin.type\n );\n\n return new FileNormalizer(createModifierFromPlugins(modifierPlugins));\n};\n"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAIC,OAAgB,IAAK;EACjE,MAAMC,eAAe,GAAGD,OAAO,CAACE,OAAO,CAACC,MAAM,CAC1CC,4CAAwB,CAACC,IAC7B,CAAC;EAED,OAAO,IAAIC,8BAAc,CAAC,IAAAC,6CAAyB,EAACN,eAAe,CAAC,CAAC;AACzE,CAAC;AAACO,OAAA,CAAAT,+BAAA,GAAAA,+BAAA","ignoreList":[]}
1
+ {"version":3,"file":"utils/createFileNormalizerFromContext.js","sources":["../../src/utils/createFileNormalizerFromContext.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types.js\";\nimport { FileNormalizer } from \"~/utils/FileNormalizer.js\";\nimport { createModifierFromPlugins, FileUploadModifier } from \"~/utils/FileUploadModifier.js\";\n\nexport const createFileNormalizerFromContext = (context: Context) => {\n // Modifiers are registered as DI instances (FileUploadModifier) — was\n // context.plugins.byType(FileUploadModifierPlugin.type).\n const modifierPlugins = context.container.resolveAll(FileUploadModifier);\n\n return new FileNormalizer(createModifierFromPlugins(modifierPlugins));\n};\n"],"names":["createFileNormalizerFromContext","context","modifierPlugins","FileUploadModifier","FileNormalizer","createModifierFromPlugins"],"mappings":";;AAIO,MAAMA,kCAAkC,CAACC;IAG5C,MAAMC,kBAAkBD,QAAQ,SAAS,CAAC,UAAU,CAACE;IAErD,OAAO,IAAIC,eAAeC,0BAA0BH;AACxD"}
@@ -1,3 +1,4 @@
1
- import type { FileManagerSettings } from "@webiny/api-file-manager/types";
2
- import type { FileData, PresignedPostPayloadDataResponse } from "../types";
3
- export declare const getPresignedPostPayload: (file: FileData, settings: FileManagerSettings) => Promise<PresignedPostPayloadDataResponse>;
1
+ import type { FileData, PresignedPostPayloadDataResponse } from "../types.js";
2
+ import type { FileManagerSettings } from "@webiny/api-file-manager/domain/settings/types.js";
3
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
4
+ export declare const getPresignedPostPayload: (file: FileData, settings: FileManagerSettings, tenantContext: TenantContext.Interface) => Promise<PresignedPostPayloadDataResponse>;
@@ -1,45 +1,43 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getPresignedPostPayload = void 0;
7
- var _clientS = require("@webiny/aws-sdk/client-s3");
8
- var _validation = require("@webiny/validation");
1
+ import { S3Client, createPresignedPost } from "@webiny/aws-sdk/client-s3/index.js";
2
+ import { validation } from "@webiny/validation";
9
3
  const S3_BUCKET = process.env.S3_BUCKET;
10
- const UPLOAD_MAX_FILE_SIZE_DEFAULT = 1099511627776; // 1TB
11
-
12
- const sanitizeFileSizeValue = (value, defaultValue) => {
13
- try {
14
- _validation.validation.validateSync(value, "required,numeric,gte:0");
15
- return value;
16
- } catch (e) {
17
- // TODO @ts-refactor No need to log the error?
18
- return defaultValue;
19
- }
20
- };
21
- const getPresignedPostPayload = async (file, settings) => {
22
- const uploadMinFileSize = sanitizeFileSizeValue(settings.uploadMinFileSize, 0);
23
- const uploadMaxFileSize = sanitizeFileSizeValue(settings.uploadMaxFileSize, UPLOAD_MAX_FILE_SIZE_DEFAULT);
24
- const params = {
25
- Key: file.key,
26
- Expires: 60,
27
- Bucket: S3_BUCKET,
28
- Conditions: [["content-length-range", uploadMinFileSize, uploadMaxFileSize]],
29
- Fields: {
30
- "Content-Type": file.type
4
+ const UPLOAD_MAX_FILE_SIZE_DEFAULT = 1099511627776;
5
+ const sanitizeFileSizeValue = (value, defaultValue)=>{
6
+ try {
7
+ validation.validateSync(value, "required,numeric,gte:0");
8
+ return value;
9
+ } catch {
10
+ return defaultValue;
31
11
  }
32
- };
33
- if (params.Key.startsWith("/")) {
34
- params.Key = params.Key.slice(1);
35
- }
36
- const s3 = new _clientS.S3Client();
37
- const payload = await (0, _clientS.createPresignedPost)(s3, params);
38
- return {
39
- data: payload,
40
- file
41
- };
42
12
  };
43
- exports.getPresignedPostPayload = getPresignedPostPayload;
13
+ const getPresignedPostPayload = async (file, settings, tenantContext)=>{
14
+ const uploadMinFileSize = sanitizeFileSizeValue(settings.uploadMinFileSize, 0);
15
+ const uploadMaxFileSize = sanitizeFileSizeValue(settings.uploadMaxFileSize, UPLOAD_MAX_FILE_SIZE_DEFAULT);
16
+ const tenant = tenantContext.getTenant();
17
+ const storageKey = `tenants/${tenant.id}/files/${file.key}`;
18
+ const params = {
19
+ Key: storageKey,
20
+ Expires: 60,
21
+ Bucket: S3_BUCKET,
22
+ Conditions: [
23
+ [
24
+ "content-length-range",
25
+ uploadMinFileSize,
26
+ uploadMaxFileSize
27
+ ]
28
+ ],
29
+ Fields: {
30
+ "Content-Type": file.type
31
+ }
32
+ };
33
+ if (params.Key.startsWith("/")) params.Key = params.Key.slice(1);
34
+ const s3 = new S3Client();
35
+ const payload = await createPresignedPost(s3, params);
36
+ return {
37
+ data: payload,
38
+ file
39
+ };
40
+ };
41
+ export { getPresignedPostPayload };
44
42
 
45
43
  //# sourceMappingURL=getPresignedPostPayload.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_clientS","require","_validation","S3_BUCKET","process","env","UPLOAD_MAX_FILE_SIZE_DEFAULT","sanitizeFileSizeValue","value","defaultValue","validation","validateSync","e","getPresignedPostPayload","file","settings","uploadMinFileSize","uploadMaxFileSize","params","Key","key","Expires","Bucket","Conditions","Fields","type","startsWith","slice","s3","S3Client","payload","createPresignedPost","data","exports"],"sources":["getPresignedPostPayload.ts"],"sourcesContent":["import type { PresignedPostOptions } from \"@webiny/aws-sdk/client-s3\";\nimport { S3Client, createPresignedPost } from \"@webiny/aws-sdk/client-s3\";\nimport { validation } from \"@webiny/validation\";\nimport type { FileManagerSettings } from \"@webiny/api-file-manager/types\";\nimport type { FileData, PresignedPostPayloadDataResponse } from \"~/types\";\n\nconst S3_BUCKET = process.env.S3_BUCKET;\nconst UPLOAD_MAX_FILE_SIZE_DEFAULT = 1099511627776; // 1TB\n\nconst sanitizeFileSizeValue = (value: number, defaultValue: number): number => {\n try {\n validation.validateSync(value, \"required,numeric,gte:0\");\n return value;\n } catch (e) {\n // TODO @ts-refactor No need to log the error?\n return defaultValue;\n }\n};\n\nexport const getPresignedPostPayload = async (\n file: FileData,\n settings: FileManagerSettings\n): Promise<PresignedPostPayloadDataResponse> => {\n const uploadMinFileSize = sanitizeFileSizeValue(settings.uploadMinFileSize, 0);\n const uploadMaxFileSize = sanitizeFileSizeValue(\n settings.uploadMaxFileSize,\n UPLOAD_MAX_FILE_SIZE_DEFAULT\n );\n\n const params = {\n Key: file.key,\n Expires: 60,\n Bucket: S3_BUCKET as string,\n Conditions: [\n [\"content-length-range\", uploadMinFileSize, uploadMaxFileSize]\n ] as PresignedPostOptions[\"Conditions\"],\n Fields: {\n \"Content-Type\": file.type\n }\n };\n\n if (params.Key.startsWith(\"/\")) {\n params.Key = params.Key.slice(1);\n }\n\n const s3 = new S3Client();\n const payload = await createPresignedPost(s3, params);\n\n return {\n data: payload,\n file\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA,MAAME,SAAS,GAAGC,OAAO,CAACC,GAAG,CAACF,SAAS;AACvC,MAAMG,4BAA4B,GAAG,aAAa,CAAC,CAAC;;AAEpD,MAAMC,qBAAqB,GAAGA,CAACC,KAAa,EAAEC,YAAoB,KAAa;EAC3E,IAAI;IACAC,sBAAU,CAACC,YAAY,CAACH,KAAK,EAAE,wBAAwB,CAAC;IACxD,OAAOA,KAAK;EAChB,CAAC,CAAC,OAAOI,CAAC,EAAE;IACR;IACA,OAAOH,YAAY;EACvB;AACJ,CAAC;AAEM,MAAMI,uBAAuB,GAAG,MAAAA,CACnCC,IAAc,EACdC,QAA6B,KACe;EAC5C,MAAMC,iBAAiB,GAAGT,qBAAqB,CAACQ,QAAQ,CAACC,iBAAiB,EAAE,CAAC,CAAC;EAC9E,MAAMC,iBAAiB,GAAGV,qBAAqB,CAC3CQ,QAAQ,CAACE,iBAAiB,EAC1BX,4BACJ,CAAC;EAED,MAAMY,MAAM,GAAG;IACXC,GAAG,EAAEL,IAAI,CAACM,GAAG;IACbC,OAAO,EAAE,EAAE;IACXC,MAAM,EAAEnB,SAAmB;IAC3BoB,UAAU,EAAE,CACR,CAAC,sBAAsB,EAAEP,iBAAiB,EAAEC,iBAAiB,CAAC,CAC3B;IACvCO,MAAM,EAAE;MACJ,cAAc,EAAEV,IAAI,CAACW;IACzB;EACJ,CAAC;EAED,IAAIP,MAAM,CAACC,GAAG,CAACO,UAAU,CAAC,GAAG,CAAC,EAAE;IAC5BR,MAAM,CAACC,GAAG,GAAGD,MAAM,CAACC,GAAG,CAACQ,KAAK,CAAC,CAAC,CAAC;EACpC;EAEA,MAAMC,EAAE,GAAG,IAAIC,iBAAQ,CAAC,CAAC;EACzB,MAAMC,OAAO,GAAG,MAAM,IAAAC,4BAAmB,EAACH,EAAE,EAAEV,MAAM,CAAC;EAErD,OAAO;IACHc,IAAI,EAAEF,OAAO;IACbhB;EACJ,CAAC;AACL,CAAC;AAACmB,OAAA,CAAApB,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"file":"utils/getPresignedPostPayload.js","sources":["../../src/utils/getPresignedPostPayload.ts"],"sourcesContent":["import type { PresignedPostOptions } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { S3Client, createPresignedPost } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { validation } from \"@webiny/validation\";\nimport type { FileData, PresignedPostPayloadDataResponse } from \"~/types.js\";\nimport type { FileManagerSettings } from \"@webiny/api-file-manager/domain/settings/types.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\n\nconst S3_BUCKET = process.env.S3_BUCKET;\nconst UPLOAD_MAX_FILE_SIZE_DEFAULT = 1099511627776; // 1TB\n\nconst sanitizeFileSizeValue = (value: number, defaultValue: number): number => {\n try {\n validation.validateSync(value, \"required,numeric,gte:0\");\n return value;\n } catch {\n // TODO @ts-refactor No need to log the error?\n return defaultValue;\n }\n};\n\nexport const getPresignedPostPayload = async (\n file: FileData,\n settings: FileManagerSettings,\n tenantContext: TenantContext.Interface\n): Promise<PresignedPostPayloadDataResponse> => {\n const uploadMinFileSize = sanitizeFileSizeValue(settings.uploadMinFileSize, 0);\n const uploadMaxFileSize = sanitizeFileSizeValue(\n settings.uploadMaxFileSize,\n UPLOAD_MAX_FILE_SIZE_DEFAULT\n );\n\n const tenant = tenantContext.getTenant();\n const storageKey = `tenants/${tenant.id}/files/${file.key}`;\n\n const params = {\n Key: storageKey,\n Expires: 60,\n Bucket: S3_BUCKET as string,\n Conditions: [\n [\"content-length-range\", uploadMinFileSize, uploadMaxFileSize]\n ] as PresignedPostOptions[\"Conditions\"],\n Fields: {\n \"Content-Type\": file.type\n }\n };\n\n if (params.Key.startsWith(\"/\")) {\n params.Key = params.Key.slice(1);\n }\n\n const s3 = new S3Client();\n const payload = await createPresignedPost(s3, params);\n\n return {\n data: payload,\n file\n };\n};\n"],"names":["S3_BUCKET","process","UPLOAD_MAX_FILE_SIZE_DEFAULT","sanitizeFileSizeValue","value","defaultValue","validation","getPresignedPostPayload","file","settings","tenantContext","uploadMinFileSize","uploadMaxFileSize","tenant","storageKey","params","s3","S3Client","payload","createPresignedPost"],"mappings":";;AAOA,MAAMA,YAAYC,QAAQ,GAAG,CAAC,SAAS;AACvC,MAAMC,+BAA+B;AAErC,MAAMC,wBAAwB,CAACC,OAAeC;IAC1C,IAAI;QACAC,WAAW,YAAY,CAACF,OAAO;QAC/B,OAAOA;IACX,EAAE,OAAM;QAEJ,OAAOC;IACX;AACJ;AAEO,MAAME,0BAA0B,OACnCC,MACAC,UACAC;IAEA,MAAMC,oBAAoBR,sBAAsBM,SAAS,iBAAiB,EAAE;IAC5E,MAAMG,oBAAoBT,sBACtBM,SAAS,iBAAiB,EAC1BP;IAGJ,MAAMW,SAASH,cAAc,SAAS;IACtC,MAAMI,aAAa,CAAC,QAAQ,EAAED,OAAO,EAAE,CAAC,OAAO,EAAEL,KAAK,GAAG,EAAE;IAE3D,MAAMO,SAAS;QACX,KAAKD;QACL,SAAS;QACT,QAAQd;QACR,YAAY;YACR;gBAAC;gBAAwBW;gBAAmBC;aAAkB;SACjE;QACD,QAAQ;YACJ,gBAAgBJ,KAAK,IAAI;QAC7B;IACJ;IAEA,IAAIO,OAAO,GAAG,CAAC,UAAU,CAAC,MACtBA,OAAO,GAAG,GAAGA,OAAO,GAAG,CAAC,KAAK,CAAC;IAGlC,MAAMC,KAAK,IAAIC;IACf,MAAMC,UAAU,MAAMC,oBAAoBH,IAAID;IAE9C,OAAO;QACH,MAAMG;QACNV;IACJ;AACJ"}
@@ -1,23 +1,9 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.mimeTypes = void 0;
8
- var _other = _interopRequireDefault(require("mime/types/other"));
9
- var _standard = _interopRequireDefault(require("mime/types/standard"));
10
- // @ts-expect-error
11
-
12
- // @ts-expect-error
13
-
14
- /**
15
- * We need to get all extensions that are defined for a specific content type.
16
- * This operation is not available via the `mime` package, so we create such an object ourselves.
17
- */
18
- const mimeTypes = exports.mimeTypes = {
19
- ..._other.default,
20
- ..._standard.default
1
+ import other from "mime/types/other.js";
2
+ import standard from "mime/types/standard.js";
3
+ const mimeTypes_mimeTypes = {
4
+ ...other,
5
+ ...standard
21
6
  };
7
+ export { mimeTypes_mimeTypes as mimeTypes };
22
8
 
23
9
  //# sourceMappingURL=mimeTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_other","_interopRequireDefault","require","_standard","mimeTypes","exports","vendorTypes","standardTypes"],"sources":["mimeTypes.ts"],"sourcesContent":["// @ts-expect-error\nimport vendorTypes from \"mime/types/other\";\n// @ts-expect-error\nimport standardTypes from \"mime/types/standard\";\n\n/**\n * We need to get all extensions that are defined for a specific content type.\n * This operation is not available via the `mime` package, so we create such an object ourselves.\n */\nexport const mimeTypes: Record<string, string[]> = {\n ...vendorTypes,\n ...standardTypes\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AAHA;;AAEA;;AAGA;AACA;AACA;AACA;AACO,MAAME,SAAmC,GAAAC,OAAA,CAAAD,SAAA,GAAG;EAC/C,GAAGE,cAAW;EACd,GAAGC;AACP,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/mimeTypes.js","sources":["../../src/utils/mimeTypes.ts"],"sourcesContent":["import vendorTypes from \"mime/types/other.js\";\nimport standardTypes from \"mime/types/standard.js\";\n\n/**\n * We need to get all extensions that are defined for a specific content type.\n * This operation is not available via the `mime` package, so we create such an object ourselves.\n */\nexport const mimeTypes: Record<string, string[]> = {\n ...vendorTypes,\n ...standardTypes\n};\n"],"names":["mimeTypes","vendorTypes","standardTypes"],"mappings":";;AAOO,MAAMA,sBAAsC;IAC/C,GAAGC,KAAW;IACd,GAAGC,QAAa;AACpB"}
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { Response } from "node-fetch";
4
- import type { PresignedPost } from "@webiny/aws-sdk/client-s3";
5
- declare const _default: (buffer: Buffer, preSignedPostPayload: PresignedPost) => Promise<Response>;
1
+ import type { PresignedPost } from "@webiny/aws-sdk/client-s3/index.js";
6
2
  export default _default;
3
+ declare function _default(buffer: Buffer, preSignedPostPayload: PresignedPost): Promise<Response>;
@@ -1,26 +1,14 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _formData = _interopRequireDefault(require("form-data"));
9
- var _nodeFetch = _interopRequireDefault(require("node-fetch"));
10
- var _default = async (buffer, preSignedPostPayload) => {
11
- const formData = new _formData.default();
12
- // Add all pre signed payload field to "FormData".
13
- Object.keys(preSignedPostPayload.fields).forEach(key => {
14
- formData.append(key, preSignedPostPayload.fields[key]);
15
- });
16
- // Add file content to "FormData".
17
- formData.append("file", buffer);
18
- // Finally make the upload request to S3.
19
- return (0, _nodeFetch.default)(preSignedPostPayload.url, {
20
- method: "POST",
21
- body: formData
22
- });
1
+ const uploadFileToS3 = async (buffer, preSignedPostPayload)=>{
2
+ const formData = new FormData();
3
+ for (const [key, value] of Object.entries(preSignedPostPayload.fields))formData.append(key, value);
4
+ formData.append("file", new Blob([
5
+ Buffer.from(buffer)
6
+ ]));
7
+ return fetch(preSignedPostPayload.url, {
8
+ method: "POST",
9
+ body: formData
10
+ });
23
11
  };
24
- exports.default = _default;
12
+ export default uploadFileToS3;
25
13
 
26
14
  //# sourceMappingURL=uploadFileToS3.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_formData","_interopRequireDefault","require","_nodeFetch","_default","buffer","preSignedPostPayload","formData","FormData","Object","keys","fields","forEach","key","append","fetch","url","method","body","exports","default"],"sources":["uploadFileToS3.ts"],"sourcesContent":["import FormData from \"form-data\";\nimport type { Response } from \"node-fetch\";\nimport fetch from \"node-fetch\";\nimport type { PresignedPost } from \"@webiny/aws-sdk/client-s3\";\n\nexport default async (buffer: Buffer, preSignedPostPayload: PresignedPost): Promise<Response> => {\n const formData = new FormData();\n // Add all pre signed payload field to \"FormData\".\n Object.keys(preSignedPostPayload.fields).forEach(key => {\n formData.append(key, preSignedPostPayload.fields[key]);\n });\n // Add file content to \"FormData\".\n formData.append(\"file\", buffer);\n // Finally make the upload request to S3.\n return fetch(preSignedPostPayload.url, {\n method: \"POST\",\n body: formData\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA+B,IAAAE,QAAA,GAGhB,MAAAA,CAAOC,MAAc,EAAEC,oBAAmC,KAAwB;EAC7F,MAAMC,QAAQ,GAAG,IAAIC,iBAAQ,CAAC,CAAC;EAC/B;EACAC,MAAM,CAACC,IAAI,CAACJ,oBAAoB,CAACK,MAAM,CAAC,CAACC,OAAO,CAACC,GAAG,IAAI;IACpDN,QAAQ,CAACO,MAAM,CAACD,GAAG,EAAEP,oBAAoB,CAACK,MAAM,CAACE,GAAG,CAAC,CAAC;EAC1D,CAAC,CAAC;EACF;EACAN,QAAQ,CAACO,MAAM,CAAC,MAAM,EAAET,MAAM,CAAC;EAC/B;EACA,OAAO,IAAAU,kBAAK,EAACT,oBAAoB,CAACU,GAAG,EAAE;IACnCC,MAAM,EAAE,MAAM;IACdC,IAAI,EAAEX;EACV,CAAC,CAAC;AACN,CAAC;AAAAY,OAAA,CAAAC,OAAA,GAAAhB,QAAA","ignoreList":[]}
1
+ {"version":3,"file":"utils/uploadFileToS3.js","sources":["../../src/utils/uploadFileToS3.ts"],"sourcesContent":["import type { PresignedPost } from \"@webiny/aws-sdk/client-s3/index.js\";\n\nexport default async (buffer: Buffer, preSignedPostPayload: PresignedPost): Promise<Response> => {\n const formData = new FormData();\n\n for (const [key, value] of Object.entries(preSignedPostPayload.fields)) {\n formData.append(key, value);\n }\n\n formData.append(\"file\", new Blob([Buffer.from(buffer)]));\n\n return fetch(preSignedPostPayload.url, {\n method: \"POST\",\n body: formData\n });\n};\n"],"names":["buffer","preSignedPostPayload","formData","FormData","key","value","Object","Blob","Buffer","fetch"],"mappings":"AAEA,uBAAe,OAAOA,QAAgBC;IAClC,MAAMC,WAAW,IAAIC;IAErB,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAO,OAAO,CAACL,qBAAqB,MAAM,EACjEC,SAAS,MAAM,CAACE,KAAKC;IAGzBH,SAAS,MAAM,CAAC,QAAQ,IAAIK,KAAK;QAACC,OAAO,IAAI,CAACR;KAAQ;IAEtD,OAAOS,MAAMR,qBAAqB,GAAG,EAAE;QACnC,QAAQ;QACR,MAAMC;IACV;AACJ"}
@@ -1,12 +0,0 @@
1
- /**
2
- * !! EXPERIMENTAL !!
3
- *
4
- * This plugin is used to enable delivery of assets derived from the original asset uploaded via the FM.
5
- * These are usually files that go through background processing, video transcoding, image optimization, etc.
6
- * Since these derived files are not managed through the File Manager, the default delivery mechanism will not be able
7
- * to resolve them.
8
- *
9
- * With this plugin, we add a custom asset resolver, which tries to resolve the requested asset within the folder
10
- * it's located in, and if found, it will simply be delivered back to the client, without any transformations applied.
11
- */
12
- export declare const createCustomAssetDelivery: () => import("@webiny/plugins/types").PluginFactory;
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createCustomAssetDelivery = void 0;
7
- var _apiFileManager = require("@webiny/api-file-manager");
8
- /**
9
- * !! EXPERIMENTAL !!
10
- *
11
- * This plugin is used to enable delivery of assets derived from the original asset uploaded via the FM.
12
- * These are usually files that go through background processing, video transcoding, image optimization, etc.
13
- * Since these derived files are not managed through the File Manager, the default delivery mechanism will not be able
14
- * to resolve them.
15
- *
16
- * With this plugin, we add a custom asset resolver, which tries to resolve the requested asset within the folder
17
- * it's located in, and if found, it will simply be delivered back to the client, without any transformations applied.
18
- */
19
- const createCustomAssetDelivery = () => {
20
- return (0, _apiFileManager.createAssetDeliveryPluginLoader)(async () => {
21
- return import(/* webpackChunkName: "customAssetDelivery" */"./customAssets/customAssetDeliveryConfig").then(({
22
- customAssetDeliveryConfig
23
- }) => customAssetDeliveryConfig());
24
- });
25
- };
26
- exports.createCustomAssetDelivery = createCustomAssetDelivery;
27
-
28
- //# sourceMappingURL=createCustomAssetDelivery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_apiFileManager","require","createCustomAssetDelivery","createAssetDeliveryPluginLoader","then","customAssetDeliveryConfig","exports"],"sources":["createCustomAssetDelivery.ts"],"sourcesContent":["import { createAssetDeliveryPluginLoader } from \"@webiny/api-file-manager\";\n\n/**\n * !! EXPERIMENTAL !!\n *\n * This plugin is used to enable delivery of assets derived from the original asset uploaded via the FM.\n * These are usually files that go through background processing, video transcoding, image optimization, etc.\n * Since these derived files are not managed through the File Manager, the default delivery mechanism will not be able\n * to resolve them.\n *\n * With this plugin, we add a custom asset resolver, which tries to resolve the requested asset within the folder\n * it's located in, and if found, it will simply be delivered back to the client, without any transformations applied.\n */\nexport const createCustomAssetDelivery = () => {\n return createAssetDeliveryPluginLoader(async () => {\n return import(\n /* webpackChunkName: \"customAssetDelivery\" */ \"./customAssets/customAssetDeliveryConfig\"\n ).then(({ customAssetDeliveryConfig }) => customAssetDeliveryConfig());\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,IAAAC,+CAA+B,EAAC,YAAY;IAC/C,OAAO,MAAM,CACT,uFACJ,CAAC,CAACC,IAAI,CAAC,CAAC;MAAEC;IAA0B,CAAC,KAAKA,yBAAyB,CAAC,CAAC,CAAC;EAC1E,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAJ,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- import { Asset } from "@webiny/api-file-manager";
2
- /**
3
- * This class is used to differentiate between regular and custom assets.
4
- */
5
- export declare class CustomAsset extends Asset {
6
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CustomAsset = void 0;
7
- var _apiFileManager = require("@webiny/api-file-manager");
8
- /**
9
- * This class is used to differentiate between regular and custom assets.
10
- */
11
- class CustomAsset extends _apiFileManager.Asset {}
12
- exports.CustomAsset = CustomAsset;
13
-
14
- //# sourceMappingURL=CustomAsset.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_apiFileManager","require","CustomAsset","Asset","exports"],"sources":["CustomAsset.ts"],"sourcesContent":["import { Asset } from \"@webiny/api-file-manager\";\n\n/**\n * This class is used to differentiate between regular and custom assets.\n */\nexport class CustomAsset extends Asset {}\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,MAAMC,WAAW,SAASC,qBAAK,CAAC;AAAEC,OAAA,CAAAF,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import type { Asset, AssetProcessor, AssetRequest } from "@webiny/api-file-manager";
2
- /**
3
- * We don't want to run any kind of transformations on custom assets.
4
- * Custom assets are usually pre-processed and ready to be delivered to the client.
5
- */
6
- export declare class CustomAssetProcessor implements AssetProcessor {
7
- private assetProcessor;
8
- constructor(assetProcessor: AssetProcessor);
9
- process(assetRequest: AssetRequest, asset: Asset): Promise<Asset>;
10
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CustomAssetProcessor = void 0;
7
- var _CustomAsset = require("./CustomAsset");
8
- /**
9
- * We don't want to run any kind of transformations on custom assets.
10
- * Custom assets are usually pre-processed and ready to be delivered to the client.
11
- */
12
- class CustomAssetProcessor {
13
- constructor(assetProcessor) {
14
- this.assetProcessor = assetProcessor;
15
- }
16
- async process(assetRequest, asset) {
17
- if (asset instanceof _CustomAsset.CustomAsset) {
18
- return asset;
19
- }
20
- return this.assetProcessor.process(assetRequest, asset);
21
- }
22
- }
23
- exports.CustomAssetProcessor = CustomAssetProcessor;
24
-
25
- //# sourceMappingURL=CustomAssetProcessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_CustomAsset","require","CustomAssetProcessor","constructor","assetProcessor","process","assetRequest","asset","CustomAsset","exports"],"sources":["CustomAssetProcessor.ts"],"sourcesContent":["import type { Asset, AssetProcessor, AssetRequest } from \"@webiny/api-file-manager\";\nimport { CustomAsset } from \"./CustomAsset\";\n\n/**\n * We don't want to run any kind of transformations on custom assets.\n * Custom assets are usually pre-processed and ready to be delivered to the client.\n */\nexport class CustomAssetProcessor implements AssetProcessor {\n private assetProcessor: AssetProcessor;\n\n constructor(assetProcessor: AssetProcessor) {\n this.assetProcessor = assetProcessor;\n }\n\n async process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n if (asset instanceof CustomAsset) {\n return asset;\n }\n\n return this.assetProcessor.process(assetRequest, asset);\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,CAA2B;EAGxDC,WAAWA,CAACC,cAA8B,EAAE;IACxC,IAAI,CAACA,cAAc,GAAGA,cAAc;EACxC;EAEA,MAAMC,OAAOA,CAACC,YAA0B,EAAEC,KAAY,EAAkB;IACpE,IAAIA,KAAK,YAAYC,wBAAW,EAAE;MAC9B,OAAOD,KAAK;IAChB;IAEA,OAAO,IAAI,CAACH,cAAc,CAACC,OAAO,CAACC,YAAY,EAAEC,KAAK,CAAC;EAC3D;AACJ;AAACE,OAAA,CAAAP,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1,15 +0,0 @@
1
- import type { S3 } from "@webiny/aws-sdk/client-s3";
2
- import type { Asset, AssetRequest, AssetResolver } from "@webiny/api-file-manager";
3
- /**
4
- * This asset resolver kicks in only if the default resolution fails to resolve an asset.
5
- * The goal of this resolver is to fetch .metadata from the original file that was uploaded via th File Manager.
6
- */
7
- export declare class S3CustomAssetResolver implements AssetResolver {
8
- private readonly s3;
9
- private readonly bucket;
10
- private assetResolver;
11
- constructor(s3: S3, bucket: string, assetResolver: AssetResolver);
12
- resolve(request: AssetRequest): Promise<Asset | undefined>;
13
- private findMetadata;
14
- private getFileAttributes;
15
- }
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.S3CustomAssetResolver = void 0;
8
- var _path = _interopRequireDefault(require("path"));
9
- var _S3AssetMetadataReader = require("../s3/S3AssetMetadataReader");
10
- var _S3ContentsReader = require("../s3/S3ContentsReader");
11
- var _CustomAsset = require("./CustomAsset");
12
- /**
13
- * This asset resolver kicks in only if the default resolution fails to resolve an asset.
14
- * The goal of this resolver is to fetch .metadata from the original file that was uploaded via th File Manager.
15
- */
16
- class S3CustomAssetResolver {
17
- constructor(s3, bucket, assetResolver) {
18
- this.assetResolver = assetResolver;
19
- this.s3 = s3;
20
- this.bucket = bucket;
21
- }
22
- async resolve(request) {
23
- const resolvedAsset = await this.assetResolver.resolve(request);
24
- if (resolvedAsset) {
25
- return resolvedAsset;
26
- }
27
- try {
28
- const originalFileMetadataKey = await this.findMetadata(request);
29
- if (!originalFileMetadataKey) {
30
- return undefined;
31
- }
32
-
33
- // We need to fetch the actual size and content type of the file.
34
- const attrs = await this.getFileAttributes(request.getKey());
35
- if (!attrs) {
36
- return undefined;
37
- }
38
- const metadataReader = new _S3AssetMetadataReader.S3AssetMetadataReader(this.s3, this.bucket);
39
- const metadata = await metadataReader.getMetadata(originalFileMetadataKey.replace(".metadata", ""));
40
- const asset = new _CustomAsset.CustomAsset({
41
- // These attributes do not change between the original and derived files.
42
- id: metadata.id,
43
- tenant: metadata.tenant,
44
- locale: metadata.locale,
45
- // Assign the size and content type of the requested file.
46
- size: attrs.size,
47
- contentType: attrs.contentType,
48
- key: request.getKey()
49
- });
50
- asset.setContentsReader(new _S3ContentsReader.S3ContentsReader(this.s3, this.bucket));
51
- return asset;
52
- } catch (error) {
53
- console.error(error);
54
- return undefined;
55
- }
56
- }
57
-
58
- // https://d1s78zhy5i2noq.cloudfront.net/files/65a99721c20390000869e3d3/9l9iafhgn-17.jpeg
59
-
60
- async findMetadata(request) {
61
- const requestFolder = _path.default.dirname(request.getKey());
62
- const assetList = await this.s3.listObjects({
63
- Bucket: this.bucket,
64
- Prefix: requestFolder + "/"
65
- });
66
- if (!assetList.Contents) {
67
- return undefined;
68
- }
69
-
70
- // We assume that there's only one asset with the `.metadata`, and that's the original file.
71
- const metadata = assetList.Contents.find(file => file.Key?.endsWith(".metadata"));
72
- return metadata ? metadata.Key : undefined;
73
- }
74
- async getFileAttributes(key) {
75
- const head = await this.s3.headObject({
76
- Bucket: this.bucket,
77
- Key: key
78
- });
79
- if (!head) {
80
- return undefined;
81
- }
82
- return {
83
- size: head.ContentLength || 0,
84
- contentType: head.ContentType || ""
85
- };
86
- }
87
- }
88
- exports.S3CustomAssetResolver = S3CustomAssetResolver;
89
-
90
- //# sourceMappingURL=S3CustomAssetResolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_path","_interopRequireDefault","require","_S3AssetMetadataReader","_S3ContentsReader","_CustomAsset","S3CustomAssetResolver","constructor","s3","bucket","assetResolver","resolve","request","resolvedAsset","originalFileMetadataKey","findMetadata","undefined","attrs","getFileAttributes","getKey","metadataReader","S3AssetMetadataReader","metadata","getMetadata","replace","asset","CustomAsset","id","tenant","locale","size","contentType","key","setContentsReader","S3ContentsReader","error","console","requestFolder","path","dirname","assetList","listObjects","Bucket","Prefix","Contents","find","file","Key","endsWith","head","headObject","ContentLength","ContentType","exports"],"sources":["S3CustomAssetResolver.ts"],"sourcesContent":["import path from \"path\";\nimport type { S3 } from \"@webiny/aws-sdk/client-s3\";\nimport type { Asset, AssetRequest, AssetResolver } from \"@webiny/api-file-manager\";\nimport { S3AssetMetadataReader } from \"~/assetDelivery/s3/S3AssetMetadataReader\";\nimport { S3ContentsReader } from \"~/assetDelivery/s3/S3ContentsReader\";\nimport { CustomAsset } from \"./CustomAsset\";\n\n/**\n * This asset resolver kicks in only if the default resolution fails to resolve an asset.\n * The goal of this resolver is to fetch .metadata from the original file that was uploaded via th File Manager.\n */\nexport class S3CustomAssetResolver implements AssetResolver {\n private readonly s3: S3;\n private readonly bucket: string;\n private assetResolver: AssetResolver;\n\n constructor(s3: S3, bucket: string, assetResolver: AssetResolver) {\n this.assetResolver = assetResolver;\n this.s3 = s3;\n this.bucket = bucket;\n }\n\n async resolve(request: AssetRequest): Promise<Asset | undefined> {\n const resolvedAsset = await this.assetResolver.resolve(request);\n\n if (resolvedAsset) {\n return resolvedAsset;\n }\n\n try {\n const originalFileMetadataKey = await this.findMetadata(request);\n\n if (!originalFileMetadataKey) {\n return undefined;\n }\n\n // We need to fetch the actual size and content type of the file.\n const attrs = await this.getFileAttributes(request.getKey());\n\n if (!attrs) {\n return undefined;\n }\n\n const metadataReader = new S3AssetMetadataReader(this.s3, this.bucket);\n const metadata = await metadataReader.getMetadata(\n originalFileMetadataKey.replace(\".metadata\", \"\")\n );\n\n const asset = new CustomAsset({\n // These attributes do not change between the original and derived files.\n id: metadata.id,\n tenant: metadata.tenant,\n locale: metadata.locale,\n // Assign the size and content type of the requested file.\n size: attrs.size,\n contentType: attrs.contentType,\n key: request.getKey()\n });\n\n asset.setContentsReader(new S3ContentsReader(this.s3, this.bucket));\n\n return asset;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n }\n\n // https://d1s78zhy5i2noq.cloudfront.net/files/65a99721c20390000869e3d3/9l9iafhgn-17.jpeg\n\n private async findMetadata(request: AssetRequest) {\n const requestFolder = path.dirname(request.getKey());\n\n const assetList = await this.s3.listObjects({\n Bucket: this.bucket,\n Prefix: requestFolder + \"/\"\n });\n\n if (!assetList.Contents) {\n return undefined;\n }\n\n // We assume that there's only one asset with the `.metadata`, and that's the original file.\n const metadata = assetList.Contents.find(file => file.Key?.endsWith(\".metadata\"));\n\n return metadata ? metadata.Key : undefined;\n }\n\n private async getFileAttributes(key: string) {\n const head = await this.s3.headObject({\n Bucket: this.bucket,\n Key: key\n });\n\n if (!head) {\n return undefined;\n }\n\n return {\n size: head.ContentLength || 0,\n contentType: head.ContentType || \"\"\n };\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACO,MAAMI,qBAAqB,CAA0B;EAKxDC,WAAWA,CAACC,EAAM,EAAEC,MAAc,EAAEC,aAA4B,EAAE;IAC9D,IAAI,CAACA,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACF,EAAE,GAAGA,EAAE;IACZ,IAAI,CAACC,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAME,OAAOA,CAACC,OAAqB,EAA8B;IAC7D,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACH,aAAa,CAACC,OAAO,CAACC,OAAO,CAAC;IAE/D,IAAIC,aAAa,EAAE;MACf,OAAOA,aAAa;IACxB;IAEA,IAAI;MACA,MAAMC,uBAAuB,GAAG,MAAM,IAAI,CAACC,YAAY,CAACH,OAAO,CAAC;MAEhE,IAAI,CAACE,uBAAuB,EAAE;QAC1B,OAAOE,SAAS;MACpB;;MAEA;MACA,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACC,iBAAiB,CAACN,OAAO,CAACO,MAAM,CAAC,CAAC,CAAC;MAE5D,IAAI,CAACF,KAAK,EAAE;QACR,OAAOD,SAAS;MACpB;MAEA,MAAMI,cAAc,GAAG,IAAIC,4CAAqB,CAAC,IAAI,CAACb,EAAE,EAAE,IAAI,CAACC,MAAM,CAAC;MACtE,MAAMa,QAAQ,GAAG,MAAMF,cAAc,CAACG,WAAW,CAC7CT,uBAAuB,CAACU,OAAO,CAAC,WAAW,EAAE,EAAE,CACnD,CAAC;MAED,MAAMC,KAAK,GAAG,IAAIC,wBAAW,CAAC;QAC1B;QACAC,EAAE,EAAEL,QAAQ,CAACK,EAAE;QACfC,MAAM,EAAEN,QAAQ,CAACM,MAAM;QACvBC,MAAM,EAAEP,QAAQ,CAACO,MAAM;QACvB;QACAC,IAAI,EAAEb,KAAK,CAACa,IAAI;QAChBC,WAAW,EAAEd,KAAK,CAACc,WAAW;QAC9BC,GAAG,EAAEpB,OAAO,CAACO,MAAM,CAAC;MACxB,CAAC,CAAC;MAEFM,KAAK,CAACQ,iBAAiB,CAAC,IAAIC,kCAAgB,CAAC,IAAI,CAAC1B,EAAE,EAAE,IAAI,CAACC,MAAM,CAAC,CAAC;MAEnE,OAAOgB,KAAK;IAChB,CAAC,CAAC,OAAOU,KAAK,EAAE;MACZC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;MACpB,OAAOnB,SAAS;IACpB;EACJ;;EAEA;;EAEA,MAAcD,YAAYA,CAACH,OAAqB,EAAE;IAC9C,MAAMyB,aAAa,GAAGC,aAAI,CAACC,OAAO,CAAC3B,OAAO,CAACO,MAAM,CAAC,CAAC,CAAC;IAEpD,MAAMqB,SAAS,GAAG,MAAM,IAAI,CAAChC,EAAE,CAACiC,WAAW,CAAC;MACxCC,MAAM,EAAE,IAAI,CAACjC,MAAM;MACnBkC,MAAM,EAAEN,aAAa,GAAG;IAC5B,CAAC,CAAC;IAEF,IAAI,CAACG,SAAS,CAACI,QAAQ,EAAE;MACrB,OAAO5B,SAAS;IACpB;;IAEA;IACA,MAAMM,QAAQ,GAAGkB,SAAS,CAACI,QAAQ,CAACC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,GAAG,EAAEC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEjF,OAAO1B,QAAQ,GAAGA,QAAQ,CAACyB,GAAG,GAAG/B,SAAS;EAC9C;EAEA,MAAcE,iBAAiBA,CAACc,GAAW,EAAE;IACzC,MAAMiB,IAAI,GAAG,MAAM,IAAI,CAACzC,EAAE,CAAC0C,UAAU,CAAC;MAClCR,MAAM,EAAE,IAAI,CAACjC,MAAM;MACnBsC,GAAG,EAAEf;IACT,CAAC,CAAC;IAEF,IAAI,CAACiB,IAAI,EAAE;MACP,OAAOjC,SAAS;IACpB;IAEA,OAAO;MACHc,IAAI,EAAEmB,IAAI,CAACE,aAAa,IAAI,CAAC;MAC7BpB,WAAW,EAAEkB,IAAI,CAACG,WAAW,IAAI;IACrC,CAAC;EACL;AACJ;AAACC,OAAA,CAAA/C,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- export declare const customAssetDeliveryConfig: () => import("@webiny/api-file-manager").AssetDeliveryConfigModifierPlugin;