@webiny/api-file-manager 6.3.0 → 6.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/contants.js +2 -1
  2. package/contants.js.map +1 -1
  3. package/delivery/AssetDelivery/Asset.js +50 -56
  4. package/delivery/AssetDelivery/Asset.js.map +1 -1
  5. package/delivery/AssetDelivery/AssetDeliveryConfig.js +70 -83
  6. package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -1
  7. package/delivery/AssetDelivery/AssetRequest.js +20 -19
  8. package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
  9. package/delivery/AssetDelivery/FilesAssetRequestResolver.js +19 -25
  10. package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -1
  11. package/delivery/AssetDelivery/NullAssetOutputStrategy.js +5 -4
  12. package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -1
  13. package/delivery/AssetDelivery/NullAssetReply.js +10 -9
  14. package/delivery/AssetDelivery/NullAssetReply.js.map +1 -1
  15. package/delivery/AssetDelivery/NullAssetResolver.js +5 -4
  16. package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -1
  17. package/delivery/AssetDelivery/NullRequestResolver.js +5 -4
  18. package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -1
  19. package/delivery/AssetDelivery/SetCacheControlHeaders.js +11 -14
  20. package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -1
  21. package/delivery/AssetDelivery/SetResponseHeaders.js +16 -15
  22. package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -1
  23. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +0 -3
  24. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +0 -3
  25. package/delivery/AssetDelivery/abstractions/AssetProcessor.js +0 -3
  26. package/delivery/AssetDelivery/abstractions/AssetReply.js +28 -27
  27. package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
  28. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +0 -3
  29. package/delivery/AssetDelivery/abstractions/AssetResolver.js +0 -3
  30. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +0 -3
  31. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +4 -5
  32. package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -1
  33. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +0 -3
  34. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +15 -14
  35. package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -1
  36. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +5 -4
  37. package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -1
  38. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +14 -16
  39. package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
  40. package/delivery/AssetDelivery/privateFiles/PrivateCache.js +18 -17
  41. package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -1
  42. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +21 -25
  43. package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
  44. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +44 -51
  45. package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
  46. package/delivery/AssetDelivery/privateFiles/PublicCache.js +18 -17
  47. package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -1
  48. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +16 -15
  49. package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -1
  50. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +16 -15
  51. package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -1
  52. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +5 -4
  53. package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -1
  54. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +5 -4
  55. package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -1
  56. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +12 -15
  57. package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
  58. package/delivery/index.js +0 -2
  59. package/delivery/setupAssetDelivery.js +70 -101
  60. package/delivery/setupAssetDelivery.js.map +1 -1
  61. package/domain/file/abstractions.js +2 -5
  62. package/domain/file/abstractions.js.map +1 -1
  63. package/domain/file/errors.js +67 -76
  64. package/domain/file/errors.js.map +1 -1
  65. package/domain/file/file.model.js +57 -49
  66. package/domain/file/file.model.js.map +1 -1
  67. package/domain/file/types.js +0 -3
  68. package/domain/identity/Identity.js +9 -8
  69. package/domain/identity/Identity.js.map +1 -1
  70. package/domain/permissionsSchema.js +26 -15
  71. package/domain/permissionsSchema.js.map +1 -1
  72. package/domain/settings/constants.js +2 -1
  73. package/domain/settings/constants.js.map +1 -1
  74. package/domain/settings/errors.js +22 -24
  75. package/domain/settings/errors.js.map +1 -1
  76. package/domain/settings/types.js +0 -3
  77. package/domain/settings/validation.js +18 -27
  78. package/domain/settings/validation.js.map +1 -1
  79. package/exports/api/file-manager/file.js +0 -2
  80. package/exports/api/file-manager/permissions.js +0 -2
  81. package/exports/api/file-manager/settings.js +0 -2
  82. package/features/FileManagerFeature.js +16 -15
  83. package/features/FileManagerFeature.js.map +1 -1
  84. package/features/file/CreateFile/CreateFileRepository.js +20 -18
  85. package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
  86. package/features/file/CreateFile/CreateFileUseCase.js +68 -75
  87. package/features/file/CreateFile/CreateFileUseCase.js.map +1 -1
  88. package/features/file/CreateFile/abstractions.js +3 -14
  89. package/features/file/CreateFile/abstractions.js.map +1 -1
  90. package/features/file/CreateFile/events.js +17 -26
  91. package/features/file/CreateFile/events.js.map +1 -1
  92. package/features/file/CreateFile/feature.js +7 -6
  93. package/features/file/CreateFile/feature.js.map +1 -1
  94. package/features/file/CreateFile/index.js +0 -2
  95. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +15 -17
  96. package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -1
  97. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +59 -70
  98. package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -1
  99. package/features/file/CreateFilesInBatch/abstractions.js +3 -14
  100. package/features/file/CreateFilesInBatch/abstractions.js.map +1 -1
  101. package/features/file/CreateFilesInBatch/events.js +17 -26
  102. package/features/file/CreateFilesInBatch/events.js.map +1 -1
  103. package/features/file/CreateFilesInBatch/feature.js +7 -6
  104. package/features/file/CreateFilesInBatch/feature.js.map +1 -1
  105. package/features/file/CreateFilesInBatch/index.js +0 -2
  106. package/features/file/DeleteFile/DeleteFileRepository.js +21 -20
  107. package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
  108. package/features/file/DeleteFile/DeleteFileUseCase.js +31 -33
  109. package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -1
  110. package/features/file/DeleteFile/abstractions.js +3 -14
  111. package/features/file/DeleteFile/abstractions.js.map +1 -1
  112. package/features/file/DeleteFile/events.js +17 -26
  113. package/features/file/DeleteFile/events.js.map +1 -1
  114. package/features/file/DeleteFile/feature.js +7 -6
  115. package/features/file/DeleteFile/feature.js.map +1 -1
  116. package/features/file/DeleteFile/index.js +1 -3
  117. package/features/file/FileUrlGenerator/abstractions.js +2 -2
  118. package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
  119. package/features/file/GetFile/GetFileRepository.js +22 -22
  120. package/features/file/GetFile/GetFileRepository.js.map +1 -1
  121. package/features/file/GetFile/GetFileUseCase.js +19 -21
  122. package/features/file/GetFile/GetFileUseCase.js.map +1 -1
  123. package/features/file/GetFile/abstractions.js +3 -14
  124. package/features/file/GetFile/abstractions.js.map +1 -1
  125. package/features/file/GetFile/feature.js +7 -6
  126. package/features/file/GetFile/feature.js.map +1 -1
  127. package/features/file/GetFile/index.js +0 -2
  128. package/features/file/GetFileContentsById/abstractions.d.ts +20 -0
  129. package/features/file/GetFileContentsById/abstractions.js +5 -0
  130. package/features/file/GetFileContentsById/abstractions.js.map +1 -0
  131. package/features/file/GetFileContentsById/index.d.ts +1 -0
  132. package/features/file/GetFileContentsById/index.js +1 -0
  133. package/features/file/GetFileContentsByKey/abstractions.d.ts +17 -0
  134. package/features/file/GetFileContentsByKey/abstractions.js +5 -0
  135. package/features/file/GetFileContentsByKey/abstractions.js.map +1 -0
  136. package/features/file/GetFileContentsByKey/index.d.ts +1 -0
  137. package/features/file/GetFileContentsByKey/index.js +1 -0
  138. package/features/file/ListFiles/ListFilesRepository.js +42 -40
  139. package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
  140. package/features/file/ListFiles/ListFilesUseCase.js +33 -34
  141. package/features/file/ListFiles/ListFilesUseCase.js.map +1 -1
  142. package/features/file/ListFiles/abstractions.js +3 -14
  143. package/features/file/ListFiles/abstractions.js.map +1 -1
  144. package/features/file/ListFiles/feature.js +7 -6
  145. package/features/file/ListFiles/feature.js.map +1 -1
  146. package/features/file/ListFiles/index.js +0 -2
  147. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +31 -28
  148. package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -1
  149. package/features/file/ListImagesByTagTool/feature.js +6 -5
  150. package/features/file/ListImagesByTagTool/feature.js.map +1 -1
  151. package/features/file/ListTags/ListTagsRepository.js +31 -36
  152. package/features/file/ListTags/ListTagsRepository.js.map +1 -1
  153. package/features/file/ListTags/ListTagsUseCase.js +21 -21
  154. package/features/file/ListTags/ListTagsUseCase.js.map +1 -1
  155. package/features/file/ListTags/abstractions.js +3 -14
  156. package/features/file/ListTags/abstractions.js.map +1 -1
  157. package/features/file/ListTags/feature.js +7 -6
  158. package/features/file/ListTags/feature.js.map +1 -1
  159. package/features/file/ListTags/index.js +0 -2
  160. package/features/file/UpdateFile/UpdateFileRepository.js +26 -28
  161. package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
  162. package/features/file/UpdateFile/UpdateFileUseCase.js +57 -65
  163. package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -1
  164. package/features/file/UpdateFile/abstractions.js +3 -14
  165. package/features/file/UpdateFile/abstractions.js.map +1 -1
  166. package/features/file/UpdateFile/events.js +17 -26
  167. package/features/file/UpdateFile/events.js.map +1 -1
  168. package/features/file/UpdateFile/feature.js +7 -6
  169. package/features/file/UpdateFile/feature.js.map +1 -1
  170. package/features/file/UpdateFile/index.js +1 -3
  171. package/features/file/shared/EntryToFileMapper.js +25 -24
  172. package/features/file/shared/EntryToFileMapper.js.map +1 -1
  173. package/features/file/shared/FileInputToEntryInputMapper.js +29 -28
  174. package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -1
  175. package/features/file/shared/FileToEntryMapper.js +28 -27
  176. package/features/file/shared/FileToEntryMapper.js.map +1 -1
  177. package/features/permissions/abstractions.js +2 -1
  178. package/features/permissions/abstractions.js.map +1 -1
  179. package/features/permissions/feature.js +2 -1
  180. package/features/permissions/feature.js.map +1 -1
  181. package/features/settings/GetSettings/GetSettingsUseCase.js +19 -19
  182. package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -1
  183. package/features/settings/GetSettings/abstractions.js +2 -7
  184. package/features/settings/GetSettings/abstractions.js.map +1 -1
  185. package/features/settings/GetSettings/feature.js +6 -5
  186. package/features/settings/GetSettings/feature.js.map +1 -1
  187. package/features/settings/SettingsInstaller/SettingsInstaller.js +25 -24
  188. package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
  189. package/features/settings/SettingsInstaller/feature.js +6 -5
  190. package/features/settings/SettingsInstaller/feature.js.map +1 -1
  191. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +41 -48
  192. package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
  193. package/features/settings/UpdateSettings/abstractions.js +2 -7
  194. package/features/settings/UpdateSettings/abstractions.js.map +1 -1
  195. package/features/settings/UpdateSettings/events.js +17 -26
  196. package/features/settings/UpdateSettings/events.js.map +1 -1
  197. package/features/settings/UpdateSettings/feature.js +6 -5
  198. package/features/settings/UpdateSettings/feature.js.map +1 -1
  199. package/features/settings/UpdateSettings/index.js +0 -2
  200. package/features/shared/abstractions.js +0 -2
  201. package/graphql/baseSchema.js +30 -33
  202. package/graphql/baseSchema.js.map +1 -1
  203. package/graphql/createFilesTypeDefs.js +49 -57
  204. package/graphql/createFilesTypeDefs.js.map +1 -1
  205. package/graphql/filesSchema.js +79 -99
  206. package/graphql/filesSchema.js.map +1 -1
  207. package/graphql/getFileByUrl.js +45 -53
  208. package/graphql/getFileByUrl.js.map +1 -1
  209. package/graphql/index.js +35 -42
  210. package/graphql/index.js.map +1 -1
  211. package/graphql/utils.js +9 -14
  212. package/graphql/utils.js.map +1 -1
  213. package/index.js +19 -30
  214. package/index.js.map +1 -1
  215. package/modelModifier/CmsModelModifier.js +40 -43
  216. package/modelModifier/CmsModelModifier.js.map +1 -1
  217. package/package.json +17 -20
  218. package/types.js +0 -2
  219. package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +0 -1
  220. package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +0 -1
  221. package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +0 -1
  222. package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +0 -1
  223. package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +0 -1
  224. package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +0 -1
  225. package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +0 -1
  226. package/delivery/index.js.map +0 -1
  227. package/domain/file/types.js.map +0 -1
  228. package/domain/settings/types.js.map +0 -1
  229. package/exports/api/file-manager/file.js.map +0 -1
  230. package/exports/api/file-manager/permissions.js.map +0 -1
  231. package/exports/api/file-manager/settings.js.map +0 -1
  232. package/features/ai/AiImageEnrichmentAfterCreateHandler.d.ts +0 -11
  233. package/features/ai/AiImageEnrichmentAfterCreateHandler.js +0 -28
  234. package/features/ai/AiImageEnrichmentAfterCreateHandler.js.map +0 -1
  235. package/features/ai/AiImageEnrichmentFeature.d.ts +0 -4
  236. package/features/ai/AiImageEnrichmentFeature.js +0 -12
  237. package/features/ai/AiImageEnrichmentFeature.js.map +0 -1
  238. package/features/file/CreateFile/index.js.map +0 -1
  239. package/features/file/CreateFilesInBatch/index.js.map +0 -1
  240. package/features/file/DeleteFile/index.js.map +0 -1
  241. package/features/file/GetFile/index.js.map +0 -1
  242. package/features/file/ListFiles/index.js.map +0 -1
  243. package/features/file/ListTags/index.js.map +0 -1
  244. package/features/file/UpdateFile/index.js.map +0 -1
  245. package/features/settings/UpdateSettings/index.js.map +0 -1
  246. package/features/shared/abstractions.js.map +0 -1
  247. package/tasks/AiImageEnrichmentTask.d.ts +0 -35
  248. package/tasks/AiImageEnrichmentTask.js +0 -136
  249. package/tasks/AiImageEnrichmentTask.js.map +0 -1
  250. package/types.js.map +0 -1
@@ -1,21 +1,22 @@
1
1
  import { parse, stringify } from "cache-control-parser";
2
- export class PublicCache {
3
- constructor(strategy) {
4
- this.strategy = strategy;
5
- }
6
- async output(asset) {
7
- const reply = await this.strategy.output(asset);
8
- reply.setHeaders(headers => {
9
- headers.set("cache-control", (value = "") => {
10
- const cacheControl = parse(value);
11
- cacheControl["private"] = false;
12
- cacheControl["public"] = true;
13
- return stringify(cacheControl);
14
- });
15
- return headers;
16
- });
17
- return reply;
18
- }
2
+ class PublicCache {
3
+ constructor(strategy){
4
+ this.strategy = strategy;
5
+ }
6
+ async output(asset) {
7
+ const reply = await this.strategy.output(asset);
8
+ reply.setHeaders((headers)=>{
9
+ headers.set("cache-control", (value = "")=>{
10
+ const cacheControl = parse(value);
11
+ cacheControl["private"] = false;
12
+ cacheControl["public"] = true;
13
+ return stringify(cacheControl);
14
+ });
15
+ return headers;
16
+ });
17
+ return reply;
18
+ }
19
19
  }
20
+ export { PublicCache };
20
21
 
21
22
  //# sourceMappingURL=PublicCache.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["parse","stringify","PublicCache","constructor","strategy","output","asset","reply","setHeaders","headers","set","value","cacheControl"],"sources":["PublicCache.ts"],"sourcesContent":["import { parse, stringify } from \"cache-control-parser\";\nimport type { Asset, AssetOutputStrategy, AssetReply } from \"~/delivery/index.js\";\n\nexport class PublicCache implements AssetOutputStrategy {\n private strategy: AssetOutputStrategy;\n\n constructor(strategy: AssetOutputStrategy) {\n this.strategy = strategy;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const reply = await this.strategy.output(asset);\n\n reply.setHeaders(headers => {\n headers.set(\"cache-control\", (value = \"\") => {\n const cacheControl = parse(value);\n cacheControl[\"private\"] = false;\n cacheControl[\"public\"] = true;\n return stringify(cacheControl);\n });\n return headers;\n });\n\n return reply;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,SAAS,QAAQ,sBAAsB;AAGvD,OAAO,MAAMC,WAAW,CAAgC;EAGpDC,WAAWA,CAACC,QAA6B,EAAE;IACvC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,MAAMA,CAACC,KAAY,EAAuB;IAC5C,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACH,QAAQ,CAACC,MAAM,CAACC,KAAK,CAAC;IAE/CC,KAAK,CAACC,UAAU,CAACC,OAAO,IAAI;MACxBA,OAAO,CAACC,GAAG,CAAC,eAAe,EAAE,CAACC,KAAK,GAAG,EAAE,KAAK;QACzC,MAAMC,YAAY,GAAGZ,KAAK,CAACW,KAAK,CAAC;QACjCC,YAAY,CAAC,SAAS,CAAC,GAAG,KAAK;QAC/BA,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI;QAC7B,OAAOX,SAAS,CAACW,YAAY,CAAC;MAClC,CAAC,CAAC;MACF,OAAOH,OAAO;IAClB,CAAC,CAAC;IAEF,OAAOF,KAAK;EAChB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"delivery/AssetDelivery/privateFiles/PublicCache.js","sources":["../../../../src/delivery/AssetDelivery/privateFiles/PublicCache.ts"],"sourcesContent":["import { parse, stringify } from \"cache-control-parser\";\nimport type { Asset, AssetOutputStrategy, AssetReply } from \"~/delivery/index.js\";\n\nexport class PublicCache implements AssetOutputStrategy {\n private strategy: AssetOutputStrategy;\n\n constructor(strategy: AssetOutputStrategy) {\n this.strategy = strategy;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const reply = await this.strategy.output(asset);\n\n reply.setHeaders(headers => {\n headers.set(\"cache-control\", (value = \"\") => {\n const cacheControl = parse(value);\n cacheControl[\"private\"] = false;\n cacheControl[\"public\"] = true;\n return stringify(cacheControl);\n });\n return headers;\n });\n\n return reply;\n }\n}\n"],"names":["PublicCache","strategy","asset","reply","headers","value","cacheControl","parse","stringify"],"mappings":";AAGO,MAAMA;IAGT,YAAYC,QAA6B,CAAE;QACvC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,OAAOC,KAAY,EAAuB;QAC5C,MAAMC,QAAQ,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAACD;QAEzCC,MAAM,UAAU,CAACC,CAAAA;YACbA,QAAQ,GAAG,CAAC,iBAAiB,CAACC,QAAQ,EAAE;gBACpC,MAAMC,eAAeC,MAAMF;gBAC3BC,YAAY,CAAC,UAAU,GAAG;gBAC1BA,YAAY,CAAC,SAAS,GAAG;gBACzB,OAAOE,UAAUF;YACrB;YACA,OAAOF;QACX;QAEA,OAAOD;IACX;AACJ"}
@@ -1,20 +1,21 @@
1
1
  import { AssetReply } from "../../index.js";
2
2
  import { ResponseHeaders } from "@webiny/handler";
3
- export class RedirectToPrivateUrlOutputStrategy {
4
- constructor(assetRequest) {
5
- this.assetRequest = assetRequest;
6
- }
7
- async output(asset) {
8
- const requestUrl = this.assetRequest.getContext().url;
9
- return new AssetReply({
10
- code: 301,
11
- headers: ResponseHeaders.create({
12
- location: requestUrl.replace("/files/", "/private/"),
13
- "content-type": asset.getContentType(),
14
- "cache-control": `public, max-age=${86400 * 30}`
15
- })
16
- });
17
- }
3
+ class RedirectToPrivateUrlOutputStrategy {
4
+ constructor(assetRequest){
5
+ this.assetRequest = assetRequest;
6
+ }
7
+ async output(asset) {
8
+ const requestUrl = this.assetRequest.getContext().url;
9
+ return new AssetReply({
10
+ code: 301,
11
+ headers: ResponseHeaders.create({
12
+ location: requestUrl.replace("/files/", "/private/"),
13
+ "content-type": asset.getContentType(),
14
+ "cache-control": "public, max-age=2592000"
15
+ })
16
+ });
17
+ }
18
18
  }
19
+ export { RedirectToPrivateUrlOutputStrategy };
19
20
 
20
21
  //# sourceMappingURL=RedirectToPrivateUrlOutputStrategy.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AssetReply","ResponseHeaders","RedirectToPrivateUrlOutputStrategy","constructor","assetRequest","output","asset","requestUrl","getContext","url","code","headers","create","location","replace","getContentType"],"sources":["RedirectToPrivateUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset, AssetOutputStrategy, AssetRequest } from \"~/delivery/index.js\";\nimport { AssetReply } from \"~/delivery/index.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\n\nexport class RedirectToPrivateUrlOutputStrategy implements AssetOutputStrategy {\n private assetRequest: AssetRequest;\n\n constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return new AssetReply({\n code: 301,\n headers: ResponseHeaders.create({\n location: requestUrl.replace(\"/files/\", \"/private/\"),\n \"content-type\": asset.getContentType(),\n \"cache-control\": `public, max-age=${86400 * 30}`\n })\n });\n }\n}\n"],"mappings":"AACA,SAASA,UAAU;AACnB,SAASC,eAAe,QAAQ,iBAAiB;AAEjD,OAAO,MAAMC,kCAAkC,CAAgC;EAG3EC,WAAWA,CAACC,YAA0B,EAAE;IACpC,IAAI,CAACA,YAAY,GAAGA,YAAY;EACpC;EAEA,MAAMC,MAAMA,CAACC,KAAY,EAAuB;IAC5C,MAAMC,UAAU,GAAG,IAAI,CAACH,YAAY,CAACI,UAAU,CAAC,CAAC,CAACC,GAAG;IAErD,OAAO,IAAIT,UAAU,CAAC;MAClBU,IAAI,EAAE,GAAG;MACTC,OAAO,EAAEV,eAAe,CAACW,MAAM,CAAC;QAC5BC,QAAQ,EAAEN,UAAU,CAACO,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC;QACpD,cAAc,EAAER,KAAK,CAACS,cAAc,CAAC,CAAC;QACtC,eAAe,EAAE,mBAAmB,KAAK,GAAG,EAAE;MAClD,CAAC;IACL,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js","sources":["../../../../src/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset, AssetOutputStrategy, AssetRequest } from \"~/delivery/index.js\";\nimport { AssetReply } from \"~/delivery/index.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\n\nexport class RedirectToPrivateUrlOutputStrategy implements AssetOutputStrategy {\n private assetRequest: AssetRequest;\n\n constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return new AssetReply({\n code: 301,\n headers: ResponseHeaders.create({\n location: requestUrl.replace(\"/files/\", \"/private/\"),\n \"content-type\": asset.getContentType(),\n \"cache-control\": `public, max-age=${86400 * 30}`\n })\n });\n }\n}\n"],"names":["RedirectToPrivateUrlOutputStrategy","assetRequest","asset","requestUrl","AssetReply","ResponseHeaders"],"mappings":";;AAIO,MAAMA;IAGT,YAAYC,YAA0B,CAAE;QACpC,IAAI,CAAC,YAAY,GAAGA;IACxB;IAEA,MAAM,OAAOC,KAAY,EAAuB;QAC5C,MAAMC,aAAa,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,GAAG;QAErD,OAAO,IAAIC,WAAW;YAClB,MAAM;YACN,SAASC,gBAAgB,MAAM,CAAC;gBAC5B,UAAUF,WAAW,OAAO,CAAC,WAAW;gBACxC,gBAAgBD,MAAM,cAAc;gBACpC,iBAAiB;YACrB;QACJ;IACJ;AACJ"}
@@ -1,20 +1,21 @@
1
1
  import { AssetReply } from "../../index.js";
2
2
  import { ResponseHeaders } from "@webiny/handler";
3
- export class RedirectToPublicUrlOutputStrategy {
4
- constructor(assetRequest) {
5
- this.assetRequest = assetRequest;
6
- }
7
- async output(asset) {
8
- const requestUrl = this.assetRequest.getContext().url;
9
- return new AssetReply({
10
- code: 301,
11
- headers: ResponseHeaders.create({
12
- location: requestUrl.replace("/private/", "/files/"),
13
- "content-type": asset.getContentType(),
14
- "cache-control": `public, max-age=${86400 * 30}`
15
- })
16
- });
17
- }
3
+ class RedirectToPublicUrlOutputStrategy {
4
+ constructor(assetRequest){
5
+ this.assetRequest = assetRequest;
6
+ }
7
+ async output(asset) {
8
+ const requestUrl = this.assetRequest.getContext().url;
9
+ return new AssetReply({
10
+ code: 301,
11
+ headers: ResponseHeaders.create({
12
+ location: requestUrl.replace("/private/", "/files/"),
13
+ "content-type": asset.getContentType(),
14
+ "cache-control": "public, max-age=2592000"
15
+ })
16
+ });
17
+ }
18
18
  }
19
+ export { RedirectToPublicUrlOutputStrategy };
19
20
 
20
21
  //# sourceMappingURL=RedirectToPublicUrlOutputStrategy.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AssetReply","ResponseHeaders","RedirectToPublicUrlOutputStrategy","constructor","assetRequest","output","asset","requestUrl","getContext","url","code","headers","create","location","replace","getContentType"],"sources":["RedirectToPublicUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset, AssetOutputStrategy, AssetRequest } from \"~/delivery/index.js\";\nimport { AssetReply } from \"~/delivery/index.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\n\nexport class RedirectToPublicUrlOutputStrategy implements AssetOutputStrategy {\n private assetRequest: AssetRequest;\n\n constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return new AssetReply({\n code: 301,\n headers: ResponseHeaders.create({\n location: requestUrl.replace(\"/private/\", \"/files/\"),\n \"content-type\": asset.getContentType(),\n \"cache-control\": `public, max-age=${86400 * 30}`\n })\n });\n }\n}\n"],"mappings":"AACA,SAASA,UAAU;AACnB,SAASC,eAAe,QAAQ,iBAAiB;AAEjD,OAAO,MAAMC,iCAAiC,CAAgC;EAG1EC,WAAWA,CAACC,YAA0B,EAAE;IACpC,IAAI,CAACA,YAAY,GAAGA,YAAY;EACpC;EAEA,MAAMC,MAAMA,CAACC,KAAY,EAAuB;IAC5C,MAAMC,UAAU,GAAG,IAAI,CAACH,YAAY,CAACI,UAAU,CAAC,CAAC,CAACC,GAAG;IAErD,OAAO,IAAIT,UAAU,CAAC;MAClBU,IAAI,EAAE,GAAG;MACTC,OAAO,EAAEV,eAAe,CAACW,MAAM,CAAC;QAC5BC,QAAQ,EAAEN,UAAU,CAACO,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC;QACpD,cAAc,EAAER,KAAK,CAACS,cAAc,CAAC,CAAC;QACtC,eAAe,EAAE,mBAAmB,KAAK,GAAG,EAAE;MAClD,CAAC;IACL,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js","sources":["../../../../src/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset, AssetOutputStrategy, AssetRequest } from \"~/delivery/index.js\";\nimport { AssetReply } from \"~/delivery/index.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\n\nexport class RedirectToPublicUrlOutputStrategy implements AssetOutputStrategy {\n private assetRequest: AssetRequest;\n\n constructor(assetRequest: AssetRequest) {\n this.assetRequest = assetRequest;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const requestUrl = this.assetRequest.getContext().url;\n\n return new AssetReply({\n code: 301,\n headers: ResponseHeaders.create({\n location: requestUrl.replace(\"/private/\", \"/files/\"),\n \"content-type\": asset.getContentType(),\n \"cache-control\": `public, max-age=${86400 * 30}`\n })\n });\n }\n}\n"],"names":["RedirectToPublicUrlOutputStrategy","assetRequest","asset","requestUrl","AssetReply","ResponseHeaders"],"mappings":";;AAIO,MAAMA;IAGT,YAAYC,YAA0B,CAAE;QACpC,IAAI,CAAC,YAAY,GAAGA;IACxB;IAEA,MAAM,OAAOC,KAAY,EAAuB;QAC5C,MAAMC,aAAa,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,GAAG;QAErD,OAAO,IAAIC,WAAW;YAClB,MAAM;YACN,SAASC,gBAAgB,MAAM,CAAC;gBAC5B,UAAUF,WAAW,OAAO,CAAC,aAAa;gBAC1C,gBAAgBD,MAAM,cAAc;gBACpC,iBAAiB;YACrB;QACJ;IACJ;AACJ"}
@@ -1,7 +1,8 @@
1
- export class PassthroughAssetProcessor {
2
- process(assetRequest, asset) {
3
- return Promise.resolve(asset);
4
- }
1
+ class PassthroughAssetProcessor {
2
+ process(assetRequest, asset) {
3
+ return Promise.resolve(asset);
4
+ }
5
5
  }
6
+ export { PassthroughAssetProcessor };
6
7
 
7
8
  //# sourceMappingURL=PassthroughAssetProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PassthroughAssetProcessor","process","assetRequest","asset","Promise","resolve"],"sources":["PassthroughAssetProcessor.ts"],"sourcesContent":["import type { Asset, AssetProcessor, AssetRequest } from \"~/delivery/index.js\";\n\nexport class PassthroughAssetProcessor implements AssetProcessor {\n process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n return Promise.resolve(asset);\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,yBAAyB,CAA2B;EAC7DC,OAAOA,CAACC,YAA0B,EAAEC,KAAY,EAAkB;IAC9D,OAAOC,OAAO,CAACC,OAAO,CAACF,KAAK,CAAC;EACjC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js","sources":["../../../../src/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.ts"],"sourcesContent":["import type { Asset, AssetProcessor, AssetRequest } from \"~/delivery/index.js\";\n\nexport class PassthroughAssetProcessor implements AssetProcessor {\n process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n return Promise.resolve(asset);\n }\n}\n"],"names":["PassthroughAssetProcessor","assetRequest","asset","Promise"],"mappings":"AAEO,MAAMA;IACT,QAAQC,YAA0B,EAAEC,KAAY,EAAkB;QAC9D,OAAOC,QAAQ,OAAO,CAACD;IAC3B;AACJ"}
@@ -1,7 +1,8 @@
1
- export class PassthroughAssetTransformationStrategy {
2
- transform(assetRequest, asset) {
3
- return Promise.resolve(asset);
4
- }
1
+ class PassthroughAssetTransformationStrategy {
2
+ transform(assetRequest, asset) {
3
+ return Promise.resolve(asset);
4
+ }
5
5
  }
6
+ export { PassthroughAssetTransformationStrategy };
6
7
 
7
8
  //# sourceMappingURL=PassthroughAssetTransformationStrategy.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PassthroughAssetTransformationStrategy","transform","assetRequest","asset","Promise","resolve"],"sources":["PassthroughAssetTransformationStrategy.ts"],"sourcesContent":["import type { Asset, AssetTransformationStrategy, AssetRequest } from \"~/delivery/index.js\";\n\nexport class PassthroughAssetTransformationStrategy implements AssetTransformationStrategy {\n transform(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n return Promise.resolve(asset);\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,sCAAsC,CAAwC;EACvFC,SAASA,CAACC,YAA0B,EAAEC,KAAY,EAAkB;IAChE,OAAOC,OAAO,CAACC,OAAO,CAACF,KAAK,CAAC;EACjC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js","sources":["../../../../src/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.ts"],"sourcesContent":["import type { Asset, AssetTransformationStrategy, AssetRequest } from \"~/delivery/index.js\";\n\nexport class PassthroughAssetTransformationStrategy implements AssetTransformationStrategy {\n transform(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n return Promise.resolve(asset);\n }\n}\n"],"names":["PassthroughAssetTransformationStrategy","assetRequest","asset","Promise"],"mappings":"AAEO,MAAMA;IACT,UAAUC,YAA0B,EAAEC,KAAY,EAAkB;QAChE,OAAOC,QAAQ,OAAO,CAACD;IAC3B;AACJ"}
@@ -1,19 +1,16 @@
1
- export class TransformationAssetProcessor {
2
- constructor(strategy) {
3
- this.strategy = strategy;
4
- }
5
- async process(assetRequest, asset) {
6
- const {
7
- original
8
- } = assetRequest.getOptions();
9
-
10
- // If the `original` image was requested, we skip all transformations.
11
- if (original) {
12
- console.log("Skip transformations; original asset was requested.");
13
- return asset;
1
+ class TransformationAssetProcessor {
2
+ constructor(strategy){
3
+ this.strategy = strategy;
4
+ }
5
+ async process(assetRequest, asset) {
6
+ const { original } = assetRequest.getOptions();
7
+ if (original) {
8
+ console.log("Skip transformations; original asset was requested.");
9
+ return asset;
10
+ }
11
+ return this.strategy.transform(assetRequest, asset);
14
12
  }
15
- return this.strategy.transform(assetRequest, asset);
16
- }
17
13
  }
14
+ export { TransformationAssetProcessor };
18
15
 
19
16
  //# sourceMappingURL=TransformationAssetProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["TransformationAssetProcessor","constructor","strategy","process","assetRequest","asset","original","getOptions","console","log","transform"],"sources":["TransformationAssetProcessor.ts"],"sourcesContent":["import type {\n Asset,\n AssetProcessor,\n AssetRequest,\n AssetTransformationStrategy\n} from \"~/delivery/index.js\";\n\nexport class TransformationAssetProcessor implements AssetProcessor {\n private strategy: AssetTransformationStrategy;\n\n constructor(strategy: AssetTransformationStrategy) {\n this.strategy = strategy;\n }\n\n async process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n const { original } = assetRequest.getOptions();\n\n // If the `original` image was requested, we skip all transformations.\n if (original) {\n console.log(\"Skip transformations; original asset was requested.\");\n return asset;\n }\n\n return this.strategy.transform(assetRequest, asset);\n }\n}\n"],"mappings":"AAOA,OAAO,MAAMA,4BAA4B,CAA2B;EAGhEC,WAAWA,CAACC,QAAqC,EAAE;IAC/C,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,OAAOA,CAACC,YAA0B,EAAEC,KAAY,EAAkB;IACpE,MAAM;MAAEC;IAAS,CAAC,GAAGF,YAAY,CAACG,UAAU,CAAC,CAAC;;IAE9C;IACA,IAAID,QAAQ,EAAE;MACVE,OAAO,CAACC,GAAG,CAAC,qDAAqD,CAAC;MAClE,OAAOJ,KAAK;IAChB;IAEA,OAAO,IAAI,CAACH,QAAQ,CAACQ,SAAS,CAACN,YAAY,EAAEC,KAAK,CAAC;EACvD;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"delivery/AssetDelivery/transformation/TransformationAssetProcessor.js","sources":["../../../../src/delivery/AssetDelivery/transformation/TransformationAssetProcessor.ts"],"sourcesContent":["import type {\n Asset,\n AssetProcessor,\n AssetRequest,\n AssetTransformationStrategy\n} from \"~/delivery/index.js\";\n\nexport class TransformationAssetProcessor implements AssetProcessor {\n private strategy: AssetTransformationStrategy;\n\n constructor(strategy: AssetTransformationStrategy) {\n this.strategy = strategy;\n }\n\n async process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n const { original } = assetRequest.getOptions();\n\n // If the `original` image was requested, we skip all transformations.\n if (original) {\n console.log(\"Skip transformations; original asset was requested.\");\n return asset;\n }\n\n return this.strategy.transform(assetRequest, asset);\n }\n}\n"],"names":["TransformationAssetProcessor","strategy","assetRequest","asset","original","console"],"mappings":"AAOO,MAAMA;IAGT,YAAYC,QAAqC,CAAE;QAC/C,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,QAAQC,YAA0B,EAAEC,KAAY,EAAkB;QACpE,MAAM,EAAEC,QAAQ,EAAE,GAAGF,aAAa,UAAU;QAG5C,IAAIE,UAAU;YACVC,QAAQ,GAAG,CAAC;YACZ,OAAOF;QACX;QAEA,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAACD,cAAcC;IACjD;AACJ"}
package/delivery/index.js CHANGED
@@ -8,5 +8,3 @@ export * from "./AssetDelivery/SetCacheControlHeaders.js";
8
8
  export * from "./AssetDelivery/SetResponseHeaders.js";
9
9
  export * from "./AssetDelivery/privateFiles/PublicCache.js";
10
10
  export * from "./AssetDelivery/privateFiles/PrivateCache.js";
11
-
12
- //# sourceMappingURL=index.js.map
@@ -1,114 +1,83 @@
1
- import { createHandlerOnRequest, createModifyFastifyPlugin, createRoute, ResponseHeaders } from "@webiny/handler";
1
+ import { ResponseHeaders, createHandlerOnRequest, createModifyFastifyPlugin, createRoute } from "@webiny/handler";
2
2
  import { PrivateFilesAssetProcessor } from "./AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js";
3
3
  import { PrivateAuthenticatedAuthorizer } from "./AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js";
4
4
  import { PrivateFileAssetRequestResolver } from "./AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js";
5
5
  import { AssetDeliveryConfigBuilder, AssetDeliveryConfigModifierPlugin, FilesAssetRequestResolver, createAssetDeliveryConfig } from "./index.js";
6
6
  const noCacheHeaders = ResponseHeaders.create({
7
- "content-type": "application/json",
8
- "cache-control": "no-cache, no-store, must-revalidate"
7
+ "content-type": "application/json",
8
+ "cache-control": "no-cache, no-store, must-revalidate"
9
9
  });
10
10
  function assertAssetRequestWasResolved(request) {
11
- if (request === undefined) {
12
- throw new Error("Not an AssetRequest!");
13
- }
11
+ if (void 0 === request) throw new Error("Not an AssetRequest!");
14
12
  }
15
13
  function assertAssetWasResolved(asset) {
16
- if (asset === undefined) {
17
- throw new Error("Not an Asset!");
18
- }
14
+ if (void 0 === asset) throw new Error("Not an Asset!");
19
15
  }
20
- export const setupAssetDelivery = () => {
21
- const outputAsset = async (reply, asset) => {
22
- const assetReply = await asset.output();
23
- const headers = assetReply.getHeaders();
24
-
25
- // Set default headers.
26
- headers.set("x-webiny-base64-encoded", "true");
27
- reply.code(assetReply.getCode());
28
- reply.headers(headers.getHeaders());
29
- return reply.send(await assetReply.getBody());
30
- };
31
- return [createModifyFastifyPlugin(app => {
32
- // Config builder allows config modification via plugins.
33
- const configBuilder = new AssetDeliveryConfigBuilder();
34
-
35
- // Apply config modifications.
36
- const configPlugins = app.webiny.plugins.byType(AssetDeliveryConfigModifierPlugin.type);
37
- configPlugins.forEach(configPlugin => configPlugin.buildConfig(configBuilder));
38
- let resolvedRequest;
39
- let resolvedAsset;
40
-
41
- // Create a `HandlerOnRequest` plugin to resolve `tenant`, and allow the system to bootstrap.
42
- const handlerOnRequest = createHandlerOnRequest(async (request, reply) => {
43
- const requestResolver = configBuilder.getAssetRequestResolver();
44
- resolvedRequest = await requestResolver.resolve(request);
45
- if (!resolvedRequest) {
46
- reply.code(404).headers(noCacheHeaders.getHeaders()).send({
47
- error: "Unable to resolve the request!"
48
- }).hijack();
49
- return false;
50
- }
51
- const container = app.webiny.container;
52
- const assetResolver = configBuilder.getAssetResolver(container);
53
- resolvedAsset = await assetResolver.resolve(resolvedRequest);
54
- if (!resolvedAsset) {
55
- reply.code(404).headers(noCacheHeaders.getHeaders()).send({
56
- error: "Asset not found!"
57
- }).hijack();
58
- return false;
59
- }
60
- request.headers = {
61
- ...request.headers,
62
- "x-tenant": resolvedAsset.getTenant()
63
- };
64
- return;
65
- });
66
-
67
- // Create the `Route` plugin, to handle all GET requests, and output the resolved asset.
68
- const deliveryRoute = createRoute(({
69
- onGet,
70
- context
71
- }) => {
72
- onGet("*", async (_, reply) => {
73
- assertAssetRequestWasResolved(resolvedRequest);
74
- assertAssetWasResolved(resolvedAsset);
75
- if (context.wcp.canUsePrivateFiles()) {
76
- configBuilder.decorateAssetProcessor(({
77
- assetProcessor,
78
- context
79
- }) => {
80
- // Currently, we only have one authorizer.
81
- const assetAuthorizer = new PrivateAuthenticatedAuthorizer(context);
82
- return new PrivateFilesAssetProcessor(context, assetAuthorizer, assetProcessor);
83
- });
84
- }
85
- const outputStrategy = configBuilder.getAssetOutputStrategy(context, resolvedRequest, resolvedAsset);
86
- resolvedAsset.setOutputStrategy(outputStrategy);
87
- const assetProcessor = configBuilder.getAssetProcessor(context);
88
- const processedAsset = await assetProcessor.process(resolvedRequest, resolvedAsset);
89
-
90
- // Get reply object (runs the output strategy under the hood).
91
- console.log(`Output asset (size: ${processedAsset.getSize()} bytes).`);
92
- return outputAsset(reply, processedAsset);
93
- }, {
94
- override: true
95
- });
96
- });
97
- app.webiny.plugins.register(handlerOnRequest, deliveryRoute);
98
- }),
99
- // Create the default configuration
100
- createAssetDeliveryConfig(config => {
101
- config.decorateAssetRequestResolver(() => {
102
- // This resolver works with `/files/*` requests.
103
- return new FilesAssetRequestResolver();
104
- });
105
- config.decorateAssetRequestResolver(({
106
- assetRequestResolver
107
- }) => {
108
- // This resolver works with `/private/*` requests.
109
- return new PrivateFileAssetRequestResolver(assetRequestResolver);
110
- });
111
- })];
16
+ const setupAssetDelivery = ()=>{
17
+ const outputAsset = async (reply, asset)=>{
18
+ const assetReply = await asset.output();
19
+ const headers = assetReply.getHeaders();
20
+ headers.set("x-webiny-base64-encoded", "true");
21
+ reply.code(assetReply.getCode());
22
+ reply.headers(headers.getHeaders());
23
+ return reply.send(await assetReply.getBody());
24
+ };
25
+ return [
26
+ createModifyFastifyPlugin((app)=>{
27
+ const configBuilder = new AssetDeliveryConfigBuilder();
28
+ const configPlugins = app.webiny.plugins.byType(AssetDeliveryConfigModifierPlugin.type);
29
+ configPlugins.forEach((configPlugin)=>configPlugin.buildConfig(configBuilder));
30
+ let resolvedRequest;
31
+ let resolvedAsset;
32
+ const handlerOnRequest = createHandlerOnRequest(async (request, reply)=>{
33
+ const requestResolver = configBuilder.getAssetRequestResolver();
34
+ resolvedRequest = await requestResolver.resolve(request);
35
+ if (!resolvedRequest) {
36
+ reply.code(404).headers(noCacheHeaders.getHeaders()).send({
37
+ error: "Unable to resolve the request!"
38
+ }).hijack();
39
+ return false;
40
+ }
41
+ const container = app.webiny.container;
42
+ const assetResolver = configBuilder.getAssetResolver(container);
43
+ resolvedAsset = await assetResolver.resolve(resolvedRequest);
44
+ if (!resolvedAsset) {
45
+ reply.code(404).headers(noCacheHeaders.getHeaders()).send({
46
+ error: "Asset not found!"
47
+ }).hijack();
48
+ return false;
49
+ }
50
+ request.headers = {
51
+ ...request.headers,
52
+ "x-tenant": resolvedAsset.getTenant()
53
+ };
54
+ });
55
+ const deliveryRoute = createRoute(({ onGet, context })=>{
56
+ onGet("*", async (_, reply)=>{
57
+ assertAssetRequestWasResolved(resolvedRequest);
58
+ assertAssetWasResolved(resolvedAsset);
59
+ if (context.wcp.canUsePrivateFiles()) configBuilder.decorateAssetProcessor(({ assetProcessor, context })=>{
60
+ const assetAuthorizer = new PrivateAuthenticatedAuthorizer(context);
61
+ return new PrivateFilesAssetProcessor(context, assetAuthorizer, assetProcessor);
62
+ });
63
+ const outputStrategy = configBuilder.getAssetOutputStrategy(context, resolvedRequest, resolvedAsset);
64
+ resolvedAsset.setOutputStrategy(outputStrategy);
65
+ const assetProcessor = configBuilder.getAssetProcessor(context);
66
+ const processedAsset = await assetProcessor.process(resolvedRequest, resolvedAsset);
67
+ console.log(`Output asset (size: ${processedAsset.getSize()} bytes).`);
68
+ return outputAsset(reply, processedAsset);
69
+ }, {
70
+ override: true
71
+ });
72
+ });
73
+ app.webiny.plugins.register(handlerOnRequest, deliveryRoute);
74
+ }),
75
+ createAssetDeliveryConfig((config)=>{
76
+ config.decorateAssetRequestResolver(()=>new FilesAssetRequestResolver());
77
+ config.decorateAssetRequestResolver(({ assetRequestResolver })=>new PrivateFileAssetRequestResolver(assetRequestResolver));
78
+ })
79
+ ];
112
80
  };
81
+ export { setupAssetDelivery };
113
82
 
114
83
  //# sourceMappingURL=setupAssetDelivery.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createHandlerOnRequest","createModifyFastifyPlugin","createRoute","ResponseHeaders","PrivateFilesAssetProcessor","PrivateAuthenticatedAuthorizer","PrivateFileAssetRequestResolver","AssetDeliveryConfigBuilder","AssetDeliveryConfigModifierPlugin","FilesAssetRequestResolver","createAssetDeliveryConfig","noCacheHeaders","create","assertAssetRequestWasResolved","request","undefined","Error","assertAssetWasResolved","asset","setupAssetDelivery","outputAsset","reply","assetReply","output","headers","getHeaders","set","code","getCode","send","getBody","app","configBuilder","configPlugins","webiny","plugins","byType","type","forEach","configPlugin","buildConfig","resolvedRequest","resolvedAsset","handlerOnRequest","requestResolver","getAssetRequestResolver","resolve","error","hijack","container","assetResolver","getAssetResolver","getTenant","deliveryRoute","onGet","context","_","wcp","canUsePrivateFiles","decorateAssetProcessor","assetProcessor","assetAuthorizer","outputStrategy","getAssetOutputStrategy","setOutputStrategy","getAssetProcessor","processedAsset","process","console","log","getSize","override","register","config","decorateAssetRequestResolver","assetRequestResolver"],"sources":["setupAssetDelivery.ts"],"sourcesContent":["import {\n createHandlerOnRequest,\n createModifyFastifyPlugin,\n createRoute,\n ResponseHeaders\n} from \"@webiny/handler\";\nimport { PrivateFilesAssetProcessor } from \"./AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js\";\nimport { PrivateAuthenticatedAuthorizer } from \"./AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js\";\nimport { PrivateFileAssetRequestResolver } from \"./AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js\";\nimport type { Asset, AssetRequest } from \"./index.js\";\nimport {\n AssetDeliveryConfigBuilder,\n AssetDeliveryConfigModifierPlugin,\n FilesAssetRequestResolver,\n createAssetDeliveryConfig\n} from \"./index.js\";\nimport type { Reply } from \"@webiny/handler/types.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\n\nconst noCacheHeaders = ResponseHeaders.create({\n \"content-type\": \"application/json\",\n \"cache-control\": \"no-cache, no-store, must-revalidate\"\n});\n\nfunction assertAssetRequestWasResolved(request: any): asserts request is AssetRequest {\n if (request === undefined) {\n throw new Error(\"Not an AssetRequest!\");\n }\n}\n\nfunction assertAssetWasResolved(asset: Asset | undefined): asserts asset is Asset {\n if (asset === undefined) {\n throw new Error(\"Not an Asset!\");\n }\n}\n\nexport const setupAssetDelivery = () => {\n const outputAsset = async (reply: Reply, asset: Asset) => {\n const assetReply = await asset.output();\n const headers = assetReply.getHeaders();\n\n // Set default headers.\n headers.set(\"x-webiny-base64-encoded\", \"true\");\n\n reply.code(assetReply.getCode());\n reply.headers(headers.getHeaders());\n return reply.send(await assetReply.getBody());\n };\n\n return [\n createModifyFastifyPlugin(app => {\n // Config builder allows config modification via plugins.\n const configBuilder = new AssetDeliveryConfigBuilder();\n\n // Apply config modifications.\n const configPlugins = app.webiny.plugins.byType<AssetDeliveryConfigModifierPlugin>(\n AssetDeliveryConfigModifierPlugin.type\n );\n\n configPlugins.forEach(configPlugin => configPlugin.buildConfig(configBuilder));\n\n let resolvedRequest: AssetRequest | undefined;\n let resolvedAsset: Asset | undefined;\n\n // Create a `HandlerOnRequest` plugin to resolve `tenant`, and allow the system to bootstrap.\n const handlerOnRequest = createHandlerOnRequest(async (request, reply) => {\n const requestResolver = configBuilder.getAssetRequestResolver();\n resolvedRequest = await requestResolver.resolve(request);\n\n if (!resolvedRequest) {\n reply\n .code(404)\n .headers(noCacheHeaders.getHeaders())\n .send({ error: \"Unable to resolve the request!\" })\n .hijack();\n\n return false;\n }\n\n const container = app.webiny.container;\n const assetResolver = configBuilder.getAssetResolver(container);\n\n resolvedAsset = await assetResolver.resolve(resolvedRequest);\n\n if (!resolvedAsset) {\n reply\n .code(404)\n .headers(noCacheHeaders.getHeaders())\n .send({ error: \"Asset not found!\" })\n .hijack();\n\n return false;\n }\n\n request.headers = {\n ...request.headers,\n \"x-tenant\": resolvedAsset.getTenant()\n };\n\n return;\n });\n\n // Create the `Route` plugin, to handle all GET requests, and output the resolved asset.\n const deliveryRoute = createRoute<ApiCoreContext>(({ onGet, context }) => {\n onGet(\n \"*\",\n async (_, reply) => {\n assertAssetRequestWasResolved(resolvedRequest);\n assertAssetWasResolved(resolvedAsset);\n\n if (context.wcp.canUsePrivateFiles()) {\n configBuilder.decorateAssetProcessor(({ assetProcessor, context }) => {\n // Currently, we only have one authorizer.\n const assetAuthorizer = new PrivateAuthenticatedAuthorizer(context);\n\n return new PrivateFilesAssetProcessor(\n context,\n assetAuthorizer,\n assetProcessor\n );\n });\n }\n\n const outputStrategy = configBuilder.getAssetOutputStrategy(\n context,\n resolvedRequest,\n resolvedAsset\n );\n\n resolvedAsset.setOutputStrategy(outputStrategy);\n\n const assetProcessor = configBuilder.getAssetProcessor(context);\n\n const processedAsset = await assetProcessor.process(\n resolvedRequest,\n resolvedAsset\n );\n\n // Get reply object (runs the output strategy under the hood).\n console.log(`Output asset (size: ${processedAsset.getSize()} bytes).`);\n return outputAsset(reply, processedAsset);\n },\n { override: true }\n );\n });\n\n app.webiny.plugins.register(handlerOnRequest, deliveryRoute);\n }),\n // Create the default configuration\n createAssetDeliveryConfig(config => {\n config.decorateAssetRequestResolver(() => {\n // This resolver works with `/files/*` requests.\n return new FilesAssetRequestResolver();\n });\n\n config.decorateAssetRequestResolver(({ assetRequestResolver }) => {\n // This resolver works with `/private/*` requests.\n return new PrivateFileAssetRequestResolver(assetRequestResolver);\n });\n })\n ];\n};\n"],"mappings":"AAAA,SACIA,sBAAsB,EACtBC,yBAAyB,EACzBC,WAAW,EACXC,eAAe,QACZ,iBAAiB;AACxB,SAASC,0BAA0B;AACnC,SAASC,8BAA8B;AACvC,SAASC,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A4B,CAAC,CAAC;MAAEC;IAAqB,CAAC,KAAK;MAC9D;MACA,OAAO,IAAIrE,+BAA+B,CAACqE,oBAAoB,CAAC;IACpE,CAAC,CAAC;EACN,CAAC,CAAC,CACL;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"delivery/setupAssetDelivery.js","sources":["../../src/delivery/setupAssetDelivery.ts"],"sourcesContent":["import {\n createHandlerOnRequest,\n createModifyFastifyPlugin,\n createRoute,\n ResponseHeaders\n} from \"@webiny/handler\";\nimport { PrivateFilesAssetProcessor } from \"./AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js\";\nimport { PrivateAuthenticatedAuthorizer } from \"./AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js\";\nimport { PrivateFileAssetRequestResolver } from \"./AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js\";\nimport type { Asset, AssetRequest } from \"./index.js\";\nimport {\n AssetDeliveryConfigBuilder,\n AssetDeliveryConfigModifierPlugin,\n FilesAssetRequestResolver,\n createAssetDeliveryConfig\n} from \"./index.js\";\nimport type { Reply } from \"@webiny/handler/types.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\n\nconst noCacheHeaders = ResponseHeaders.create({\n \"content-type\": \"application/json\",\n \"cache-control\": \"no-cache, no-store, must-revalidate\"\n});\n\nfunction assertAssetRequestWasResolved(request: any): asserts request is AssetRequest {\n if (request === undefined) {\n throw new Error(\"Not an AssetRequest!\");\n }\n}\n\nfunction assertAssetWasResolved(asset: Asset | undefined): asserts asset is Asset {\n if (asset === undefined) {\n throw new Error(\"Not an Asset!\");\n }\n}\n\nexport const setupAssetDelivery = () => {\n const outputAsset = async (reply: Reply, asset: Asset) => {\n const assetReply = await asset.output();\n const headers = assetReply.getHeaders();\n\n // Set default headers.\n headers.set(\"x-webiny-base64-encoded\", \"true\");\n\n reply.code(assetReply.getCode());\n reply.headers(headers.getHeaders());\n return reply.send(await assetReply.getBody());\n };\n\n return [\n createModifyFastifyPlugin(app => {\n // Config builder allows config modification via plugins.\n const configBuilder = new AssetDeliveryConfigBuilder();\n\n // Apply config modifications.\n const configPlugins = app.webiny.plugins.byType<AssetDeliveryConfigModifierPlugin>(\n AssetDeliveryConfigModifierPlugin.type\n );\n\n configPlugins.forEach(configPlugin => configPlugin.buildConfig(configBuilder));\n\n let resolvedRequest: AssetRequest | undefined;\n let resolvedAsset: Asset | undefined;\n\n // Create a `HandlerOnRequest` plugin to resolve `tenant`, and allow the system to bootstrap.\n const handlerOnRequest = createHandlerOnRequest(async (request, reply) => {\n const requestResolver = configBuilder.getAssetRequestResolver();\n resolvedRequest = await requestResolver.resolve(request);\n\n if (!resolvedRequest) {\n reply\n .code(404)\n .headers(noCacheHeaders.getHeaders())\n .send({ error: \"Unable to resolve the request!\" })\n .hijack();\n\n return false;\n }\n\n const container = app.webiny.container;\n const assetResolver = configBuilder.getAssetResolver(container);\n\n resolvedAsset = await assetResolver.resolve(resolvedRequest);\n\n if (!resolvedAsset) {\n reply\n .code(404)\n .headers(noCacheHeaders.getHeaders())\n .send({ error: \"Asset not found!\" })\n .hijack();\n\n return false;\n }\n\n request.headers = {\n ...request.headers,\n \"x-tenant\": resolvedAsset.getTenant()\n };\n\n return;\n });\n\n // Create the `Route` plugin, to handle all GET requests, and output the resolved asset.\n const deliveryRoute = createRoute<ApiCoreContext>(({ onGet, context }) => {\n onGet(\n \"*\",\n async (_, reply) => {\n assertAssetRequestWasResolved(resolvedRequest);\n assertAssetWasResolved(resolvedAsset);\n\n if (context.wcp.canUsePrivateFiles()) {\n configBuilder.decorateAssetProcessor(({ assetProcessor, context }) => {\n // Currently, we only have one authorizer.\n const assetAuthorizer = new PrivateAuthenticatedAuthorizer(context);\n\n return new PrivateFilesAssetProcessor(\n context,\n assetAuthorizer,\n assetProcessor\n );\n });\n }\n\n const outputStrategy = configBuilder.getAssetOutputStrategy(\n context,\n resolvedRequest,\n resolvedAsset\n );\n\n resolvedAsset.setOutputStrategy(outputStrategy);\n\n const assetProcessor = configBuilder.getAssetProcessor(context);\n\n const processedAsset = await assetProcessor.process(\n resolvedRequest,\n resolvedAsset\n );\n\n // Get reply object (runs the output strategy under the hood).\n console.log(`Output asset (size: ${processedAsset.getSize()} bytes).`);\n return outputAsset(reply, processedAsset);\n },\n { override: true }\n );\n });\n\n app.webiny.plugins.register(handlerOnRequest, deliveryRoute);\n }),\n // Create the default configuration\n createAssetDeliveryConfig(config => {\n config.decorateAssetRequestResolver(() => {\n // This resolver works with `/files/*` requests.\n return new FilesAssetRequestResolver();\n });\n\n config.decorateAssetRequestResolver(({ assetRequestResolver }) => {\n // This resolver works with `/private/*` requests.\n return new PrivateFileAssetRequestResolver(assetRequestResolver);\n });\n })\n ];\n};\n"],"names":["noCacheHeaders","ResponseHeaders","assertAssetRequestWasResolved","request","undefined","Error","assertAssetWasResolved","asset","setupAssetDelivery","outputAsset","reply","assetReply","headers","createModifyFastifyPlugin","app","configBuilder","AssetDeliveryConfigBuilder","configPlugins","AssetDeliveryConfigModifierPlugin","configPlugin","resolvedRequest","resolvedAsset","handlerOnRequest","createHandlerOnRequest","requestResolver","container","assetResolver","deliveryRoute","createRoute","onGet","context","_","assetProcessor","assetAuthorizer","PrivateAuthenticatedAuthorizer","PrivateFilesAssetProcessor","outputStrategy","processedAsset","console","createAssetDeliveryConfig","config","FilesAssetRequestResolver","assetRequestResolver","PrivateFileAssetRequestResolver"],"mappings":";;;;;AAmBA,MAAMA,iBAAiBC,gBAAgB,MAAM,CAAC;IAC1C,gBAAgB;IAChB,iBAAiB;AACrB;AAEA,SAASC,8BAA8BC,OAAY;IAC/C,IAAIA,AAAYC,WAAZD,SACA,MAAM,IAAIE,MAAM;AAExB;AAEA,SAASC,uBAAuBC,KAAwB;IACpD,IAAIA,AAAUH,WAAVG,OACA,MAAM,IAAIF,MAAM;AAExB;AAEO,MAAMG,qBAAqB;IAC9B,MAAMC,cAAc,OAAOC,OAAcH;QACrC,MAAMI,aAAa,MAAMJ,MAAM,MAAM;QACr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AC9Bd,uBAAuBe;oBAEvB,IAAIS,QAAQ,GAAG,CAAC,kBAAkB,IAC9Bf,cAAc,sBAAsB,CAAC,CAAC,EAAEiB,cAAc,EAAEF,OAAO,EAAE;wBAE7D,MAAMG,kBAAkB,IAAIC,+BAA+BJ;wBAE3D,OAAO,IAAIK,2BACPL,SACAG,iBACAD;oBAER;oBAGJ,MAAMI,iBAAiBrB,cAAc,sBAAsB,CACvDe,SACAV,iBACAC;oBAGJA,cAAc,iBAAiB,CAACe;oBAEhC,MAAMJ,iBAAiBjB,cAAc,iBAAiB,CAACe;oBAEvD,MAAMO,iBAAiB,MAAML,eAAe,OAAO,CAC/CZ,iBACAC;oBAIJiB,QAAQ,GAAG,CAAC,CAAC,oBAAoB,EAAED,eAAe,OAAO,GAAG,QAAQ,CAAC;oBACrE,OAAO5B,YAAYC,OAAO2B;gBAC9B,GACA;oBAAE,UAAU;gBAAK;YAEzB;YAEAvB,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAACQ,kBAAkBK;QAClD;QAEAY,0BAA0BC,CAAAA;YACtBA,OAAO,4BAA4B,CAAC,IAEzB,IAAIC;YAGfD,OAAO,4BAA4B,CAAC,CAAC,EAAEE,oBAAoB,EAAE,GAElD,IAAIC,gCAAgCD;QAEnD;KACH;AACL"}
@@ -1,8 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- /**
3
- * FileModel abstraction - represents the fmFile CMS model.
4
- * This will be registered via container.registerInstance in the composite feature.
5
- */
6
- export const FileModel = createAbstraction("FileModel");
2
+ const FileModel = createAbstraction("FileModel");
3
+ export { FileModel };
7
4
 
8
5
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","FileModel"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\n/**\n * FileModel abstraction - represents the fmFile CMS model.\n * This will be registered via container.registerInstance in the composite feature.\n */\nexport const FileModel = createAbstraction<CmsModel>(\"FileModel\");\n\nexport namespace FileModel {\n export type Interface = CmsModel;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAGvD;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAGD,iBAAiB,CAAW,WAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"domain/file/abstractions.js","sources":["../../../src/domain/file/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\n/**\n * FileModel abstraction - represents the fmFile CMS model.\n * This will be registered via container.registerInstance in the composite feature.\n */\nexport const FileModel = createAbstraction<CmsModel>(\"FileModel\");\n\nexport namespace FileModel {\n export type Interface = CmsModel;\n}\n"],"names":["FileModel","createAbstraction"],"mappings":";AAOO,MAAMA,YAAYC,kBAA4B"}