@webiny/api-file-manager 6.6.0-alpha.10 → 6.6.0-alpha.12

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 (55) hide show
  1. package/delivery/AssetDeliveryRoute.d.ts +10 -3
  2. package/delivery/AssetDeliveryRoute.js +23 -18
  3. package/delivery/AssetDeliveryRoute.js.map +1 -1
  4. package/domain/file/FileMimeType.d.ts +12 -0
  5. package/domain/file/FileMimeType.js +24 -0
  6. package/domain/file/FileMimeType.js.map +1 -0
  7. package/domain/file/StoreFileInput.d.ts +52 -0
  8. package/domain/file/StoreFileInput.js +106 -0
  9. package/domain/file/StoreFileInput.js.map +1 -0
  10. package/domain/file/mimeTypes.js.map +1 -0
  11. package/exports/api/file-manager/file.d.ts +3 -0
  12. package/exports/api/file-manager/file.js +2 -0
  13. package/features/FileManagerFeature.js +2 -0
  14. package/features/FileManagerFeature.js.map +1 -1
  15. package/features/assetDelivery/feature.js +3 -1
  16. package/features/assetDelivery/feature.js.map +1 -1
  17. package/features/assetDelivery/privateFiles/PrivateAssetDeliveryRouteDefinition.d.ts +11 -0
  18. package/features/assetDelivery/privateFiles/PrivateAssetDeliveryRouteDefinition.js +17 -0
  19. package/features/assetDelivery/privateFiles/PrivateAssetDeliveryRouteDefinition.js.map +1 -0
  20. package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +1 -2
  21. package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
  22. package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +1 -0
  23. package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
  24. package/features/extractMetadata/ExtractMetadataHandler.d.ts +3 -1
  25. package/features/extractMetadata/ExtractMetadataHandler.js +10 -3
  26. package/features/extractMetadata/ExtractMetadataHandler.js.map +1 -1
  27. package/features/file/FileContentsStorage/abstractions.d.ts +41 -0
  28. package/features/file/FileContentsStorage/abstractions.js +5 -0
  29. package/features/file/FileContentsStorage/abstractions.js.map +1 -0
  30. package/features/file/FileContentsStorage/index.d.ts +1 -0
  31. package/features/file/FileContentsStorage/index.js +1 -0
  32. package/features/file/StoreFile/StoreFileUseCase.d.ts +38 -0
  33. package/features/file/StoreFile/StoreFileUseCase.js +156 -0
  34. package/features/file/StoreFile/StoreFileUseCase.js.map +1 -0
  35. package/features/file/StoreFile/abstractions.d.ts +33 -0
  36. package/features/file/StoreFile/abstractions.js +5 -0
  37. package/features/file/StoreFile/abstractions.js.map +1 -0
  38. package/features/file/StoreFile/feature.d.ts +4 -0
  39. package/features/file/StoreFile/feature.js +11 -0
  40. package/features/file/StoreFile/feature.js.map +1 -0
  41. package/features/file/StoreFile/index.d.ts +4 -0
  42. package/features/file/StoreFile/index.js +2 -0
  43. package/features/upload/index.d.ts +4 -1
  44. package/features/upload/index.js +2 -2
  45. package/features/upload/utils/FileExtension.js +2 -2
  46. package/features/upload/utils/FileExtension.js.map +1 -1
  47. package/features/upload/utils/FileNormalizer.js +2 -8
  48. package/features/upload/utils/FileNormalizer.js.map +1 -1
  49. package/features/upload/utils/FileUploadModifier.d.ts +12 -2
  50. package/features/upload/utils/FileUploadModifier.js +5 -3
  51. package/features/upload/utils/FileUploadModifier.js.map +1 -1
  52. package/package.json +16 -16
  53. package/features/upload/utils/mimeTypes.js.map +0 -1
  54. /package/{features/upload/utils → domain/file}/mimeTypes.d.ts +0 -0
  55. /package/{features/upload/utils → domain/file}/mimeTypes.js +0 -0
@@ -1,8 +1,15 @@
1
1
  import { HttpRouteDefinition, HttpRouteHandler } from "@webiny/event-handler-core";
2
- import type { Container } from "@webiny/di";
2
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
+ import { GetTenantByIdUseCase } from "@webiny/api-core/features/tenancy/GetTenantById/index.js";
4
+ import { AssetRequestResolver, AssetResolver, AssetProcessor, AssetOutputStrategy } from "../features/assetDelivery/abstractions.js";
3
5
  declare class AssetDeliveryRouteImpl implements HttpRouteHandler.Interface {
4
- private container;
5
- constructor(container: Container);
6
+ private requestResolver;
7
+ private assetResolver;
8
+ private assetProcessor;
9
+ private outputStrategy;
10
+ private tenantContext;
11
+ private getTenantById;
12
+ constructor(requestResolver: AssetRequestResolver.Interface, assetResolver: AssetResolver.Interface, assetProcessor: AssetProcessor.Interface, outputStrategy: AssetOutputStrategy.Interface, tenantContext: TenantContext.Interface, getTenantById: GetTenantByIdUseCase.Interface);
6
13
  handle(request: HttpRouteHandler.Request, response: HttpRouteHandler.Response): Promise<import("@webiny/event-handler-core").IHttpResponseBuilder>;
7
14
  private deliver;
8
15
  }
@@ -1,44 +1,44 @@
1
- import { HttpRouteDefinition, HttpRouteHandler, RequestContainer } from "@webiny/event-handler-core";
1
+ import { HttpRouteDefinition, HttpRouteHandler } from "@webiny/event-handler-core";
2
2
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
3
  import { GetTenantByIdUseCase } from "@webiny/api-core/features/tenancy/GetTenantById/index.js";
4
4
  import { AssetOutputStrategy, AssetProcessor, AssetRequestResolver, AssetResolver } from "../features/assetDelivery/abstractions.js";
5
5
  const NO_CACHE = "no-cache, no-store, must-revalidate";
6
6
  class AssetDeliveryRouteImpl {
7
- constructor(container){
8
- this.container = container;
7
+ constructor(requestResolver, assetResolver, assetProcessor, outputStrategy, tenantContext, getTenantById){
8
+ this.requestResolver = requestResolver;
9
+ this.assetResolver = assetResolver;
10
+ this.assetProcessor = assetProcessor;
11
+ this.outputStrategy = outputStrategy;
12
+ this.tenantContext = tenantContext;
13
+ this.getTenantById = getTenantById;
9
14
  }
10
15
  async handle(request, response) {
11
- const requestResolver = this.container.resolve(AssetRequestResolver);
12
- const assetResolver = this.container.resolve(AssetResolver);
13
- const tenantContext = this.container.resolve(TenantContext);
14
- const getTenantById = this.container.resolve(GetTenantByIdUseCase);
16
+ const search = new URLSearchParams(request.query ?? {}).toString();
15
17
  const fakeRequest = {
16
- url: request.path,
18
+ url: search ? `${request.path}?${search}` : request.path,
17
19
  params: {
18
- "*": request.path.replace("/files/", "")
20
+ "*": request.path
19
21
  },
20
22
  query: request.query ?? {},
21
23
  headers: request.headers ?? {}
22
24
  };
23
- const resolvedRequest = await requestResolver.resolve(fakeRequest);
25
+ const resolvedRequest = await this.requestResolver.resolve(fakeRequest);
24
26
  if (!resolvedRequest) return response.status(404).header("cache-control", NO_CACHE).json({
25
27
  error: "Unable to resolve the request!"
26
28
  });
27
- const resolvedAsset = await assetResolver.resolve(resolvedRequest);
29
+ const resolvedAsset = await this.assetResolver.resolve(resolvedRequest);
28
30
  if (!resolvedAsset) return response.status(404).header("cache-control", NO_CACHE).json({
29
31
  error: "Asset not found!"
30
32
  });
31
- const tenantResult = await getTenantById.execute(resolvedAsset.getTenant());
33
+ const tenantResult = await this.getTenantById.execute(resolvedAsset.getTenant());
32
34
  if (tenantResult.isFail()) return response.status(404).header("cache-control", NO_CACHE).json({
33
35
  error: "Asset not found!"
34
36
  });
35
- return tenantContext.withTenant(tenantResult.value, ()=>this.deliver(resolvedRequest, resolvedAsset, response));
37
+ return this.tenantContext.withTenant(tenantResult.value, ()=>this.deliver(resolvedRequest, resolvedAsset, response));
36
38
  }
37
39
  async deliver(resolvedRequest, resolvedAsset, response) {
38
- const assetProcessor = this.container.resolve(AssetProcessor);
39
- const outputStrategy = this.container.resolve(AssetOutputStrategy);
40
- resolvedAsset.setOutputStrategy(outputStrategy);
41
- const processedAsset = await assetProcessor.process(resolvedRequest, resolvedAsset);
40
+ resolvedAsset.setOutputStrategy(this.outputStrategy);
41
+ const processedAsset = await this.assetProcessor.process(resolvedRequest, resolvedAsset);
42
42
  const assetReply = await processedAsset.output();
43
43
  const rawHeaders = assetReply.getHeaders().getHeaders();
44
44
  for (const [k, v] of Object.entries(rawHeaders))if (void 0 !== v) response.header(k, String(v));
@@ -49,7 +49,12 @@ class AssetDeliveryRouteImpl {
49
49
  const AssetDeliveryRoute = HttpRouteHandler.createImplementation({
50
50
  implementation: AssetDeliveryRouteImpl,
51
51
  dependencies: [
52
- RequestContainer
52
+ AssetRequestResolver,
53
+ AssetResolver,
54
+ AssetProcessor,
55
+ AssetOutputStrategy,
56
+ TenantContext,
57
+ GetTenantByIdUseCase
53
58
  ]
54
59
  });
55
60
  class AssetDeliveryRouteDefinitionImpl {
@@ -1 +1 @@
1
- {"version":3,"file":"delivery/AssetDeliveryRoute.js","sources":["../../src/delivery/AssetDeliveryRoute.ts"],"sourcesContent":["import {\n HttpRouteDefinition,\n HttpRouteHandler,\n RequestContainer\n} from \"@webiny/event-handler-core\";\nimport type { Container } from \"@webiny/di\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { GetTenantByIdUseCase } from \"@webiny/api-core/features/tenancy/GetTenantById/index.js\";\nimport {\n AssetRequestResolver,\n AssetResolver,\n AssetProcessor,\n AssetOutputStrategy\n} from \"~/features/assetDelivery/abstractions.js\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\n\nconst NO_CACHE = \"no-cache, no-store, must-revalidate\";\n\nclass AssetDeliveryRouteImpl implements HttpRouteHandler.Interface {\n constructor(private container: Container) {}\n\n async handle(request: HttpRouteHandler.Request, response: HttpRouteHandler.Response) {\n // Resolve asset-delivery collaborators lazily (request time), not as constructor deps.\n // HttpRouter eagerly constructs every route to match paths, and AssetProcessor's\n // PrivateFilesAssetProcessor decorator pulls in GetFileUseCase -> CMS entry repositories\n // that depend on EntryFromStorageTransform, which is only registered while a CMS GraphQL\n // request is in flight. Resolving here keeps route construction cheap so non-asset\n // requests (e.g. /graphql) don't trigger that chain before it is registered.\n const requestResolver = this.container.resolve(AssetRequestResolver);\n const assetResolver = this.container.resolve(AssetResolver);\n const tenantContext = this.container.resolve(TenantContext);\n const getTenantById = this.container.resolve(GetTenantByIdUseCase);\n\n // Reconstruct a minimal request object compatible with IAssetRequestResolver\n const fakeRequest = {\n url: request.path,\n params: { \"*\": request.path.replace(\"/files/\", \"\") },\n query: request.query ?? {},\n headers: request.headers ?? {}\n };\n\n const resolvedRequest = await requestResolver.resolve(fakeRequest as any);\n if (!resolvedRequest) {\n return response\n .status(404)\n .header(\"cache-control\", NO_CACHE)\n .json({ error: \"Unable to resolve the request!\" });\n }\n\n const resolvedAsset = await assetResolver.resolve(resolvedRequest);\n if (!resolvedAsset) {\n return response\n .status(404)\n .header(\"cache-control\", NO_CACHE)\n .json({ error: \"Asset not found!\" });\n }\n\n // Delivery requests carry no tenant header, so up to this point the request runs in the\n // root tenant. Now that we know which tenant owns the asset, switch to it for the rest of\n // the request, so processors, authorizers and output strategies (e.g. the private files\n // check, which loads the tenant-scoped file entry) all run in the asset's tenant.\n const tenantResult = await getTenantById.execute(resolvedAsset.getTenant());\n if (tenantResult.isFail()) {\n return response\n .status(404)\n .header(\"cache-control\", NO_CACHE)\n .json({ error: \"Asset not found!\" });\n }\n\n return tenantContext.withTenant(tenantResult.value, () =>\n this.deliver(resolvedRequest, resolvedAsset, response)\n );\n }\n\n private async deliver(\n resolvedRequest: AssetRequest,\n resolvedAsset: Asset,\n response: HttpRouteHandler.Response\n ) {\n const assetProcessor = this.container.resolve(AssetProcessor);\n const outputStrategy = this.container.resolve(AssetOutputStrategy);\n\n resolvedAsset.setOutputStrategy(outputStrategy);\n\n const processedAsset = await assetProcessor.process(resolvedRequest, resolvedAsset);\n const assetReply = await processedAsset.output();\n\n const rawHeaders = assetReply.getHeaders().getHeaders();\n for (const [k, v] of Object.entries(rawHeaders)) {\n if (v !== undefined) {\n response.header(k, String(v));\n }\n }\n\n const body = await assetReply.getBody();\n\n // `end()` (not `send()`) so the raw body passes through untouched and the asset's OWN\n // Content-Type — set from `rawHeaders` above — is preserved. The transport translator\n // (e.g. httpResponseToApiGatewayResult) base64-encodes Buffers and sets isBase64Encoded so\n // API Gateway returns proper binary. Pre-encoding to a base64 STRING here defeated that —\n // the string passed through undecoded and browsers received base64 text, not an image.\n return response.status(assetReply.getCode()).end(body ?? \"\");\n }\n}\n\nexport const AssetDeliveryRoute = HttpRouteHandler.createImplementation({\n implementation: AssetDeliveryRouteImpl,\n dependencies: [RequestContainer]\n});\n\nclass AssetDeliveryRouteDefinitionImpl implements HttpRouteDefinition.Interface {\n readonly name = \"asset-delivery\";\n readonly method = \"GET\";\n readonly path = \"/files/*\";\n readonly handler = AssetDeliveryRoute;\n}\n\n/** What the router matches on. Zero dependencies, so building it costs nothing. */\nexport const AssetDeliveryRouteDefinition = HttpRouteDefinition.createImplementation({\n implementation: AssetDeliveryRouteDefinitionImpl,\n dependencies: []\n});\n"],"names":["NO_CACHE","AssetDeliveryRouteImpl","container","request","response","requestResolver","AssetRequestResolver","assetResolver","AssetResolver","tenantContext","TenantContext","getTenantById","GetTenantByIdUseCase","fakeRequest","resolvedRequest","resolvedAsset","tenantResult","assetProcessor","AssetProcessor","outputStrategy","AssetOutputStrategy","processedAsset","assetReply","rawHeaders","k","v","Object","undefined","String","body","AssetDeliveryRoute","HttpRouteHandler","RequestContainer","AssetDeliveryRouteDefinitionImpl","AssetDeliveryRouteDefinition","HttpRouteDefinition"],"mappings":";;;;AAiBA,MAAMA,WAAW;AAEjB,MAAMC;IACF,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAE3C,MAAM,OAAOC,OAAiC,EAAEC,QAAmC,EAAE;QAOjF,MAAMC,kBAAkB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC/C,MAAMC,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7C,MAAMC,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAC7C,MAAMC,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAACC;QAG7C,MAAMC,cAAc;YAChB,KAAKV,QAAQ,IAAI;YACjB,QAAQ;gBAAE,KAAKA,QAAQ,IAAI,CAAC,OAAO,CAAC,WAAW;YAAI;YACnD,OAAOA,QAAQ,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I,GAAG,CAACO,QAAQ;IAC7D;AACJ;AAEO,MAAMC,qBAAqBC,iBAAiB,oBAAoB,CAAC;IACpE,gBAAgB9B;IAChB,cAAc;QAAC+B;KAAiB;AACpC;AAEA,MAAMC;;aACO,IAAI,GAAG;aACP,MAAM,GAAG;aACT,IAAI,GAAG;aACP,OAAO,GAAGH;;AACvB;AAGO,MAAMI,+BAA+BC,oBAAoB,oBAAoB,CAAC;IACjF,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"delivery/AssetDeliveryRoute.js","sources":["../../src/delivery/AssetDeliveryRoute.ts"],"sourcesContent":["import { HttpRouteDefinition, HttpRouteHandler } from \"@webiny/event-handler-core\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { GetTenantByIdUseCase } from \"@webiny/api-core/features/tenancy/GetTenantById/index.js\";\nimport {\n AssetRequestResolver,\n AssetResolver,\n AssetProcessor,\n AssetOutputStrategy\n} from \"~/features/assetDelivery/abstractions.js\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\n\nconst NO_CACHE = \"no-cache, no-store, must-revalidate\";\n\nclass AssetDeliveryRouteImpl implements HttpRouteHandler.Interface {\n constructor(\n private requestResolver: AssetRequestResolver.Interface,\n private assetResolver: AssetResolver.Interface,\n private assetProcessor: AssetProcessor.Interface,\n private outputStrategy: AssetOutputStrategy.Interface,\n private tenantContext: TenantContext.Interface,\n private getTenantById: GetTenantByIdUseCase.Interface\n ) {}\n\n async handle(request: HttpRouteHandler.Request, response: HttpRouteHandler.Response) {\n // Reconstruct a minimal request object compatible with IAssetRequestResolver. Each resolver\n // strips its own prefix from the path. `url` keeps the query string, so the redirects\n // between `/files/` and `/private/` keep `?width` and `?original`.\n const search = new URLSearchParams(request.query ?? {}).toString();\n const fakeRequest = {\n url: search ? `${request.path}?${search}` : request.path,\n params: { \"*\": request.path },\n query: request.query ?? {},\n headers: request.headers ?? {}\n };\n\n const resolvedRequest = await this.requestResolver.resolve(fakeRequest as any);\n if (!resolvedRequest) {\n return response\n .status(404)\n .header(\"cache-control\", NO_CACHE)\n .json({ error: \"Unable to resolve the request!\" });\n }\n\n const resolvedAsset = await this.assetResolver.resolve(resolvedRequest);\n if (!resolvedAsset) {\n return response\n .status(404)\n .header(\"cache-control\", NO_CACHE)\n .json({ error: \"Asset not found!\" });\n }\n\n // Delivery requests carry no tenant header, so up to this point the request runs in the\n // root tenant. Now that we know which tenant owns the asset, switch to it for the rest of\n // the request, so processors, authorizers and output strategies (e.g. the private files\n // check, which loads the tenant-scoped file entry) all run in the asset's tenant.\n const tenantResult = await this.getTenantById.execute(resolvedAsset.getTenant());\n if (tenantResult.isFail()) {\n return response\n .status(404)\n .header(\"cache-control\", NO_CACHE)\n .json({ error: \"Asset not found!\" });\n }\n\n return this.tenantContext.withTenant(tenantResult.value, () =>\n this.deliver(resolvedRequest, resolvedAsset, response)\n );\n }\n\n private async deliver(\n resolvedRequest: AssetRequest,\n resolvedAsset: Asset,\n response: HttpRouteHandler.Response\n ) {\n resolvedAsset.setOutputStrategy(this.outputStrategy);\n\n const processedAsset = await this.assetProcessor.process(resolvedRequest, resolvedAsset);\n const assetReply = await processedAsset.output();\n\n const rawHeaders = assetReply.getHeaders().getHeaders();\n for (const [k, v] of Object.entries(rawHeaders)) {\n if (v !== undefined) {\n response.header(k, String(v));\n }\n }\n\n const body = await assetReply.getBody();\n\n // `end()` (not `send()`) so the raw body passes through untouched and the asset's OWN\n // Content-Type — set from `rawHeaders` above — is preserved. The transport translator\n // (e.g. httpResponseToApiGatewayResult) base64-encodes Buffers and sets isBase64Encoded so\n // API Gateway returns proper binary. Pre-encoding to a base64 STRING here defeated that —\n // the string passed through undecoded and browsers received base64 text, not an image.\n return response.status(assetReply.getCode()).end(body ?? \"\");\n }\n}\n\nexport const AssetDeliveryRoute = HttpRouteHandler.createImplementation({\n implementation: AssetDeliveryRouteImpl,\n dependencies: [\n AssetRequestResolver,\n AssetResolver,\n AssetProcessor,\n AssetOutputStrategy,\n TenantContext,\n GetTenantByIdUseCase\n ]\n});\n\nclass AssetDeliveryRouteDefinitionImpl implements HttpRouteDefinition.Interface {\n readonly name = \"asset-delivery\";\n readonly method = \"GET\";\n readonly path = \"/files/*\";\n readonly handler = AssetDeliveryRoute;\n}\n\n/** What the router matches on. Zero dependencies, so building it costs nothing. */\nexport const AssetDeliveryRouteDefinition = HttpRouteDefinition.createImplementation({\n implementation: AssetDeliveryRouteDefinitionImpl,\n dependencies: []\n});\n"],"names":["NO_CACHE","AssetDeliveryRouteImpl","requestResolver","assetResolver","assetProcessor","outputStrategy","tenantContext","getTenantById","request","response","search","URLSearchParams","fakeRequest","resolvedRequest","resolvedAsset","tenantResult","processedAsset","assetReply","rawHeaders","k","v","Object","undefined","String","body","AssetDeliveryRoute","HttpRouteHandler","AssetRequestResolver","AssetResolver","AssetProcessor","AssetOutputStrategy","TenantContext","GetTenantByIdUseCase","AssetDeliveryRouteDefinitionImpl","AssetDeliveryRouteDefinition","HttpRouteDefinition"],"mappings":";;;;AAYA,MAAMA,WAAW;AAEjB,MAAMC;IACF,YACYC,eAA+C,EAC/CC,aAAsC,EACtCC,cAAwC,EACxCC,cAA6C,EAC7CC,aAAsC,EACtCC,aAA6C,CACvD;aANUL,eAAe,GAAfA;aACAC,aAAa,GAAbA;aACAC,cAAc,GAAdA;aACAC,cAAc,GAAdA;aACAC,aAAa,GAAbA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,OAAOC,OAAiC,EAAEC,QAAmC,EAAE;QAIjF,MAAMC,SAAS,IAAIC,gBAAgBH,QAAQ,KAAK,IAAI,CAAC,GAAG,QAAQ;QAChE,MAAMI,cAAc;YAChB,KAAKF,SAAS,GAAGF,QAAQ,IAAI,CAAC,CAAC,EAAEE,QAAQ,GAAGF,QAAQ,IAAI;YACxD,QAAQ;gBAAE,KAAKA,QAAQ,IAAI;YAAC;YAC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G,CAACO,QAAQ;IAC7D;AACJ;AAEO,MAAMC,qBAAqBC,iBAAiB,oBAAoB,CAAC;IACpE,gBAAgBzB;IAChB,cAAc;QACV0B;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL;AAEA,MAAMC;;aACO,IAAI,GAAG;aACP,MAAM,GAAG;aACT,IAAI,GAAG;aACP,OAAO,GAAGR;;AACvB;AAGO,MAAMS,+BAA+BC,oBAAoB,oBAAoB,CAAC;IACjF,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A file's MIME type. When none is given, it comes from the file name's extension, and an
3
+ * unknown extension falls back to `application/octet-stream`.
4
+ */
5
+ export declare class FileMimeType {
6
+ static readonly DEFAULT = "application/octet-stream";
7
+ private readonly value;
8
+ private constructor();
9
+ static from(type: string | undefined): FileMimeType;
10
+ static fromName(name: string): FileMimeType;
11
+ toString(): string;
12
+ }
@@ -0,0 +1,24 @@
1
+ import { mimeTypes as external_mimeTypes_js_mimeTypes } from "./mimeTypes.js";
2
+ const extensionToMime = new Map();
3
+ for (const [mime, extensions] of Object.entries(external_mimeTypes_js_mimeTypes))for (const ext of extensions)if (!extensionToMime.has(ext)) extensionToMime.set(ext, mime);
4
+ class FileMimeType {
5
+ static{
6
+ this.DEFAULT = "application/octet-stream";
7
+ }
8
+ constructor(value){
9
+ this.value = value;
10
+ }
11
+ static from(type) {
12
+ return new FileMimeType(type || FileMimeType.DEFAULT);
13
+ }
14
+ static fromName(name) {
15
+ const ext = name.slice(name.lastIndexOf(".") + 1).toLowerCase();
16
+ return new FileMimeType(extensionToMime.get(ext) || FileMimeType.DEFAULT);
17
+ }
18
+ toString() {
19
+ return this.value;
20
+ }
21
+ }
22
+ export { FileMimeType };
23
+
24
+ //# sourceMappingURL=FileMimeType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain/file/FileMimeType.js","sources":["../../../src/domain/file/FileMimeType.ts"],"sourcesContent":["import { mimeTypes } from \"./mimeTypes.js\";\n\nconst extensionToMime = new Map<string, string>();\nfor (const [mime, extensions] of Object.entries(mimeTypes)) {\n for (const ext of extensions) {\n if (!extensionToMime.has(ext)) {\n extensionToMime.set(ext, mime);\n }\n }\n}\n\n/**\n * A file's MIME type. When none is given, it comes from the file name's extension, and an\n * unknown extension falls back to `application/octet-stream`.\n */\nexport class FileMimeType {\n static readonly DEFAULT = \"application/octet-stream\";\n\n private readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n }\n\n static from(type: string | undefined): FileMimeType {\n return new FileMimeType(type || FileMimeType.DEFAULT);\n }\n\n static fromName(name: string): FileMimeType {\n const ext = name.slice(name.lastIndexOf(\".\") + 1).toLowerCase();\n return new FileMimeType(extensionToMime.get(ext) || FileMimeType.DEFAULT);\n }\n\n toString(): string {\n return this.value;\n }\n}\n"],"names":["extensionToMime","Map","mime","extensions","Object","mimeTypes","ext","FileMimeType","value","type","name"],"mappings":";AAEA,MAAMA,kBAAkB,IAAIC;AAC5B,KAAK,MAAM,CAACC,MAAMC,WAAW,IAAIC,OAAO,OAAO,CAACC,iCAC5C,KAAK,MAAMC,OAAOH,WACd,IAAI,CAACH,gBAAgB,GAAG,CAACM,MACrBN,gBAAgB,GAAG,CAACM,KAAKJ;AAS9B,MAAMK;;aACO,OAAO,GAAG;;IAI1B,YAAoBC,KAAa,CAAE;QAC/B,IAAI,CAAC,KAAK,GAAGA;IACjB;IAEA,OAAO,KAAKC,IAAwB,EAAgB;QAChD,OAAO,IAAIF,aAAaE,QAAQF,aAAa,OAAO;IACxD;IAEA,OAAO,SAASG,IAAY,EAAgB;QACxC,MAAMJ,MAAMI,KAAK,KAAK,CAACA,KAAK,WAAW,CAAC,OAAO,GAAG,WAAW;QAC7D,OAAO,IAAIH,aAAaP,gBAAgB,GAAG,CAACM,QAAQC,aAAa,OAAO;IAC5E;IAEA,WAAmB;QACf,OAAO,IAAI,CAAC,KAAK;IACrB;AACJ"}
@@ -0,0 +1,52 @@
1
+ export interface StoreFileInputOptions {
2
+ name: string;
3
+ /** MIME type. Resolved from the name's extension when not set. */
4
+ type?: string;
5
+ /** A stable ID, so storing the same file twice fails with `alreadyExists` instead of creating a duplicate. */
6
+ id?: string;
7
+ /** Defaults to `"root"`. */
8
+ folderId?: string;
9
+ tags?: string[];
10
+ description?: string;
11
+ metadata?: Record<string, any>;
12
+ }
13
+ /**
14
+ * Input for `StoreFileUseCase`: a file's bytes and the attributes of its record.
15
+ *
16
+ * Mutable: build it with `fromBuffer` / `fromString`, then change it with the `set*` methods, which
17
+ * return `this`. The size always comes from the bytes. It doesn't validate anything: the use case
18
+ * checks the size, the key and permissions and returns a `Result` error.
19
+ */
20
+ export declare class StoreFileInput {
21
+ private contents;
22
+ private name;
23
+ private type;
24
+ private id;
25
+ private folderId;
26
+ private tags;
27
+ private description;
28
+ private metadata;
29
+ private constructor();
30
+ static fromBuffer(buffer: Buffer | Uint8Array, options: StoreFileInputOptions): StoreFileInput;
31
+ static fromString(text: string, options: StoreFileInputOptions): StoreFileInput;
32
+ setContents(buffer: Buffer | Uint8Array): this;
33
+ setName(name: string): this;
34
+ setType(type: string | undefined): this;
35
+ setId(id: string | undefined): this;
36
+ setFolder(folderId: string | undefined): this;
37
+ setTags(tags: string[]): this;
38
+ addTag(tag: string): this;
39
+ setDescription(description: string): this;
40
+ setMetadata(metadata: Record<string, any>): this;
41
+ getContents(): Buffer;
42
+ getSize(): number;
43
+ getName(): string;
44
+ getType(): string;
45
+ getId(): string | undefined;
46
+ getFolderId(): string;
47
+ getTags(): string[];
48
+ getDescription(): string;
49
+ getMetadata(): Record<string, any>;
50
+ private applyOptions;
51
+ private static toBuffer;
52
+ }
@@ -0,0 +1,106 @@
1
+ import { FileMimeType } from "./FileMimeType.js";
2
+ const ROOT_FOLDER_ID = "root";
3
+ class StoreFileInput {
4
+ constructor(contents, name){
5
+ this.type = void 0;
6
+ this.id = void 0;
7
+ this.folderId = ROOT_FOLDER_ID;
8
+ this.tags = [];
9
+ this.description = "";
10
+ this.metadata = {};
11
+ this.contents = contents;
12
+ this.name = name;
13
+ }
14
+ static fromBuffer(buffer, options) {
15
+ const input = new StoreFileInput(StoreFileInput.toBuffer(buffer), options.name);
16
+ return input.applyOptions(options);
17
+ }
18
+ static fromString(text, options) {
19
+ return StoreFileInput.fromBuffer(Buffer.from(text, "utf8"), options);
20
+ }
21
+ setContents(buffer) {
22
+ this.contents = StoreFileInput.toBuffer(buffer);
23
+ return this;
24
+ }
25
+ setName(name) {
26
+ this.name = name;
27
+ return this;
28
+ }
29
+ setType(type) {
30
+ this.type = type || void 0;
31
+ return this;
32
+ }
33
+ setId(id) {
34
+ this.id = id || void 0;
35
+ return this;
36
+ }
37
+ setFolder(folderId) {
38
+ this.folderId = folderId || ROOT_FOLDER_ID;
39
+ return this;
40
+ }
41
+ setTags(tags) {
42
+ this.tags = [];
43
+ for (const tag of tags)this.addTag(tag);
44
+ return this;
45
+ }
46
+ addTag(tag) {
47
+ if (!this.tags.includes(tag)) this.tags.push(tag);
48
+ return this;
49
+ }
50
+ setDescription(description) {
51
+ this.description = description;
52
+ return this;
53
+ }
54
+ setMetadata(metadata) {
55
+ this.metadata = {
56
+ ...metadata
57
+ };
58
+ return this;
59
+ }
60
+ getContents() {
61
+ return this.contents;
62
+ }
63
+ getSize() {
64
+ return this.contents.byteLength;
65
+ }
66
+ getName() {
67
+ return this.name;
68
+ }
69
+ getType() {
70
+ const mimeType = this.type ? FileMimeType.from(this.type) : FileMimeType.fromName(this.name);
71
+ return mimeType.toString();
72
+ }
73
+ getId() {
74
+ return this.id;
75
+ }
76
+ getFolderId() {
77
+ return this.folderId;
78
+ }
79
+ getTags() {
80
+ return [
81
+ ...this.tags
82
+ ];
83
+ }
84
+ getDescription() {
85
+ return this.description;
86
+ }
87
+ getMetadata() {
88
+ return {
89
+ ...this.metadata
90
+ };
91
+ }
92
+ applyOptions(options) {
93
+ this.setType(options.type).setId(options.id).setFolder(options.folderId);
94
+ if (options.tags) this.setTags(options.tags);
95
+ if (void 0 !== options.description) this.setDescription(options.description);
96
+ if (options.metadata) this.setMetadata(options.metadata);
97
+ return this;
98
+ }
99
+ static toBuffer(buffer) {
100
+ if (Buffer.isBuffer(buffer)) return buffer;
101
+ return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
102
+ }
103
+ }
104
+ export { StoreFileInput };
105
+
106
+ //# sourceMappingURL=StoreFileInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain/file/StoreFileInput.js","sources":["../../../src/domain/file/StoreFileInput.ts"],"sourcesContent":["import { FileMimeType } from \"./FileMimeType.js\";\n\nexport interface StoreFileInputOptions {\n name: string;\n /** MIME type. Resolved from the name's extension when not set. */\n type?: string;\n /** A stable ID, so storing the same file twice fails with `alreadyExists` instead of creating a duplicate. */\n id?: string;\n /** Defaults to `\"root\"`. */\n folderId?: string;\n tags?: string[];\n description?: string;\n metadata?: Record<string, any>;\n}\n\nconst ROOT_FOLDER_ID = \"root\";\n\n/**\n * Input for `StoreFileUseCase`: a file's bytes and the attributes of its record.\n *\n * Mutable: build it with `fromBuffer` / `fromString`, then change it with the `set*` methods, which\n * return `this`. The size always comes from the bytes. It doesn't validate anything: the use case\n * checks the size, the key and permissions and returns a `Result` error.\n */\nexport class StoreFileInput {\n private contents: Buffer;\n private name: string;\n private type: string | undefined = undefined;\n private id: string | undefined = undefined;\n private folderId = ROOT_FOLDER_ID;\n private tags: string[] = [];\n private description = \"\";\n private metadata: Record<string, any> = {};\n\n private constructor(contents: Buffer, name: string) {\n this.contents = contents;\n this.name = name;\n }\n\n static fromBuffer(buffer: Buffer | Uint8Array, options: StoreFileInputOptions): StoreFileInput {\n const input = new StoreFileInput(StoreFileInput.toBuffer(buffer), options.name);\n return input.applyOptions(options);\n }\n\n static fromString(text: string, options: StoreFileInputOptions): StoreFileInput {\n return StoreFileInput.fromBuffer(Buffer.from(text, \"utf8\"), options);\n }\n\n setContents(buffer: Buffer | Uint8Array): this {\n this.contents = StoreFileInput.toBuffer(buffer);\n return this;\n }\n\n setName(name: string): this {\n this.name = name;\n return this;\n }\n\n setType(type: string | undefined): this {\n this.type = type || undefined;\n return this;\n }\n\n setId(id: string | undefined): this {\n this.id = id || undefined;\n return this;\n }\n\n setFolder(folderId: string | undefined): this {\n this.folderId = folderId || ROOT_FOLDER_ID;\n return this;\n }\n\n setTags(tags: string[]): this {\n this.tags = [];\n for (const tag of tags) {\n this.addTag(tag);\n }\n return this;\n }\n\n addTag(tag: string): this {\n if (!this.tags.includes(tag)) {\n this.tags.push(tag);\n }\n return this;\n }\n\n setDescription(description: string): this {\n this.description = description;\n return this;\n }\n\n setMetadata(metadata: Record<string, any>): this {\n this.metadata = { ...metadata };\n return this;\n }\n\n getContents(): Buffer {\n return this.contents;\n }\n\n getSize(): number {\n return this.contents.byteLength;\n }\n\n getName(): string {\n return this.name;\n }\n\n getType(): string {\n const mimeType = this.type\n ? FileMimeType.from(this.type)\n : FileMimeType.fromName(this.name);\n return mimeType.toString();\n }\n\n getId(): string | undefined {\n return this.id;\n }\n\n getFolderId(): string {\n return this.folderId;\n }\n\n getTags(): string[] {\n return [...this.tags];\n }\n\n getDescription(): string {\n return this.description;\n }\n\n getMetadata(): Record<string, any> {\n return { ...this.metadata };\n }\n\n private applyOptions(options: StoreFileInputOptions): this {\n this.setType(options.type).setId(options.id).setFolder(options.folderId);\n if (options.tags) {\n this.setTags(options.tags);\n }\n if (options.description !== undefined) {\n this.setDescription(options.description);\n }\n if (options.metadata) {\n this.setMetadata(options.metadata);\n }\n return this;\n }\n\n private static toBuffer(buffer: Buffer | Uint8Array): Buffer {\n if (Buffer.isBuffer(buffer)) {\n return buffer;\n }\n return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n}\n"],"names":["ROOT_FOLDER_ID","StoreFileInput","contents","name","undefined","buffer","options","input","text","Buffer","type","id","folderId","tags","tag","description","metadata","mimeType","FileMimeType"],"mappings":";AAeA,MAAMA,iBAAiB;AAShB,MAAMC;IAUT,YAA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,OAAe,SAASD,MAA2B,EAAU;QACzD,IAAII,OAAO,QAAQ,CAACJ,SAChB,OAAOA;QAEX,OAAOI,OAAO,IAAI,CAACJ,OAAO,MAAM,EAAEA,OAAO,UAAU,EAAEA,OAAO,UAAU;IAC1E;AACJ"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain/file/mimeTypes.js","sources":["../../../src/domain/file/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"}
@@ -12,3 +12,6 @@ export { GetFileByUrlUseCase } from "../../../features/file/GetFileByUrl/abstrac
12
12
  export { GetFileContentsByIdUseCase } from "../../../features/file/GetFileContentsById/abstractions.js";
13
13
  export { ListFilesRepository, ListFilesUseCase } from "../../../features/file/ListFiles/abstractions.js";
14
14
  export { ListTagsRepository, ListTagsUseCase } from "../../../features/file/ListTags/abstractions.js";
15
+ export { StoreFileUseCase } from "../../../features/file/StoreFile/abstractions.js";
16
+ export { StoreFileInput } from "../../../domain/file/StoreFileInput.js";
17
+ export type { StoreFileInputOptions } from "../../../domain/file/StoreFileInput.js";
@@ -12,3 +12,5 @@ export { GetFileByUrlUseCase } from "../../../features/file/GetFileByUrl/abstrac
12
12
  export { GetFileContentsByIdUseCase } from "../../../features/file/GetFileContentsById/abstractions.js";
13
13
  export { ListFilesRepository, ListFilesUseCase } from "../../../features/file/ListFiles/abstractions.js";
14
14
  export { ListTagsRepository, ListTagsUseCase } from "../../../features/file/ListTags/abstractions.js";
15
+ export { StoreFileUseCase } from "../../../features/file/StoreFile/abstractions.js";
16
+ export { StoreFileInput } from "../../../domain/file/StoreFileInput.js";
@@ -1,5 +1,6 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { CreateFileFeature } from "./file/CreateFile/feature.js";
3
+ import { StoreFileFeature } from "./file/StoreFile/feature.js";
3
4
  import { CreateFilesInBatchFeature } from "./file/CreateFilesInBatch/feature.js";
4
5
  import { DeleteFileFeature } from "./file/DeleteFile/feature.js";
5
6
  import { GetFileFeature } from "./file/GetFile/feature.js";
@@ -18,6 +19,7 @@ const FileManagerFeature = createFeature({
18
19
  name: "FileManager",
19
20
  register (container) {
20
21
  CreateFileFeature.register(container);
22
+ StoreFileFeature.register(container);
21
23
  CreateFilesInBatchFeature.register(container);
22
24
  UpdateFileFeature.register(container);
23
25
  DeleteFileFeature.register(container);
@@ -1 +1 @@
1
- {"version":3,"file":"features/FileManagerFeature.js","sources":["../../src/features/FileManagerFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CreateFileFeature } from \"~/features/file/CreateFile/feature.js\";\nimport { CreateFilesInBatchFeature } from \"~/features/file/CreateFilesInBatch/feature.js\";\nimport { DeleteFileFeature } from \"~/features/file/DeleteFile/feature.js\";\nimport { GetFileFeature } from \"~/features/file/GetFile/feature.js\";\nimport { ListFilesFeature } from \"~/features/file/ListFiles/feature.js\";\nimport { ListTagsFeature } from \"~/features/file/ListTags/feature.js\";\nimport { UpdateFileFeature } from \"~/features/file/UpdateFile/feature.js\";\nimport { SettingsInstallerFeature } from \"~/features/settings/SettingsInstaller/feature.js\";\nimport { DefaultSrcPrefixFeature } from \"~/features/settings/DefaultSrcPrefix/feature.js\";\nimport { GetSettingsFeature } from \"~/features/settings/GetSettings/feature.js\";\nimport { UpdateSettingsFeature } from \"~/features/settings/UpdateSettings/feature.js\";\nimport { ListImagesByTagToolFeature } from \"~/features/file/ListImagesByTagTool/feature.js\";\nimport { FileUrlGeneratorFeature } from \"~/features/file/FileUrlGenerator/feature.js\";\nimport { GetFileByUrlFeature } from \"~/features/file/GetFileByUrl/feature.js\";\nimport { FmGraphQLSchema } from \"~/graphql/FmGraphQLSchema.js\";\n\nexport const FileManagerFeature = createFeature({\n name: \"FileManager\",\n register(container) {\n CreateFileFeature.register(container);\n CreateFilesInBatchFeature.register(container);\n UpdateFileFeature.register(container);\n DeleteFileFeature.register(container);\n GetFileFeature.register(container);\n ListFilesFeature.register(container);\n ListTagsFeature.register(container);\n SettingsInstallerFeature.register(container);\n DefaultSrcPrefixFeature.register(container);\n GetSettingsFeature.register(container);\n UpdateSettingsFeature.register(container);\n ListImagesByTagToolFeature.register(container);\n FileUrlGeneratorFeature.register(container);\n GetFileByUrlFeature.register(container);\n\n /* GraphQL schema factory. */\n container.register(FmGraphQLSchema);\n }\n});\n"],"names":["FileManagerFeature","createFeature","container","CreateFileFeature","CreateFilesInBatchFeature","UpdateFileFeature","DeleteFileFeature","GetFileFeature","ListFilesFeature","ListTagsFeature","SettingsInstallerFeature","DefaultSrcPrefixFeature","GetSettingsFeature","UpdateSettingsFeature","ListImagesByTagToolFeature","FileUrlGeneratorFeature","GetFileByUrlFeature","FmGraphQLSchema"],"mappings":";;;;;;;;;;;;;;;;AAiBO,MAAMA,qBAAqBC,cAAc;IAC5C,MAAM;IACN,UAASC,SAAS;QACdC,kBAAkB,QAAQ,CAACD;QAC3BE,0BAA0B,QAAQ,CAACF;QACnCG,kBAAkB,QAAQ,CAACH;QAC3BI,kBAAkB,QAAQ,CAACJ;QAC3BK,eAAe,QAAQ,CAACL;QACxBM,iBAAiB,QAAQ,CAACN;QAC1BO,gBAAgB,QAAQ,CAACP;QACzBQ,yBAAyB,QAAQ,CAACR;QAClCS,wBAAwB,QAAQ,CAACT;QACjCU,mBAAmB,QAAQ,CAACV;QAC5BW,sBAAsB,QAAQ,CAACX;QAC/BY,2BAA2B,QAAQ,CAACZ;QACpCa,wBAAwB,QAAQ,CAACb;QACjCc,oBAAoB,QAAQ,CAACd;QAG7BA,UAAU,QAAQ,CAACe;IACvB;AACJ"}
1
+ {"version":3,"file":"features/FileManagerFeature.js","sources":["../../src/features/FileManagerFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CreateFileFeature } from \"~/features/file/CreateFile/feature.js\";\nimport { StoreFileFeature } from \"~/features/file/StoreFile/feature.js\";\nimport { CreateFilesInBatchFeature } from \"~/features/file/CreateFilesInBatch/feature.js\";\nimport { DeleteFileFeature } from \"~/features/file/DeleteFile/feature.js\";\nimport { GetFileFeature } from \"~/features/file/GetFile/feature.js\";\nimport { ListFilesFeature } from \"~/features/file/ListFiles/feature.js\";\nimport { ListTagsFeature } from \"~/features/file/ListTags/feature.js\";\nimport { UpdateFileFeature } from \"~/features/file/UpdateFile/feature.js\";\nimport { SettingsInstallerFeature } from \"~/features/settings/SettingsInstaller/feature.js\";\nimport { DefaultSrcPrefixFeature } from \"~/features/settings/DefaultSrcPrefix/feature.js\";\nimport { GetSettingsFeature } from \"~/features/settings/GetSettings/feature.js\";\nimport { UpdateSettingsFeature } from \"~/features/settings/UpdateSettings/feature.js\";\nimport { ListImagesByTagToolFeature } from \"~/features/file/ListImagesByTagTool/feature.js\";\nimport { FileUrlGeneratorFeature } from \"~/features/file/FileUrlGenerator/feature.js\";\nimport { GetFileByUrlFeature } from \"~/features/file/GetFileByUrl/feature.js\";\nimport { FmGraphQLSchema } from \"~/graphql/FmGraphQLSchema.js\";\n\nexport const FileManagerFeature = createFeature({\n name: \"FileManager\",\n register(container) {\n CreateFileFeature.register(container);\n StoreFileFeature.register(container);\n CreateFilesInBatchFeature.register(container);\n UpdateFileFeature.register(container);\n DeleteFileFeature.register(container);\n GetFileFeature.register(container);\n ListFilesFeature.register(container);\n ListTagsFeature.register(container);\n SettingsInstallerFeature.register(container);\n DefaultSrcPrefixFeature.register(container);\n GetSettingsFeature.register(container);\n UpdateSettingsFeature.register(container);\n ListImagesByTagToolFeature.register(container);\n FileUrlGeneratorFeature.register(container);\n GetFileByUrlFeature.register(container);\n\n /* GraphQL schema factory. */\n container.register(FmGraphQLSchema);\n }\n});\n"],"names":["FileManagerFeature","createFeature","container","CreateFileFeature","StoreFileFeature","CreateFilesInBatchFeature","UpdateFileFeature","DeleteFileFeature","GetFileFeature","ListFilesFeature","ListTagsFeature","SettingsInstallerFeature","DefaultSrcPrefixFeature","GetSettingsFeature","UpdateSettingsFeature","ListImagesByTagToolFeature","FileUrlGeneratorFeature","GetFileByUrlFeature","FmGraphQLSchema"],"mappings":";;;;;;;;;;;;;;;;;AAkBO,MAAMA,qBAAqBC,cAAc;IAC5C,MAAM;IACN,UAASC,SAAS;QACdC,kBAAkB,QAAQ,CAACD;QAC3BE,iBAAiB,QAAQ,CAACF;QAC1BG,0BAA0B,QAAQ,CAACH;QACnCI,kBAAkB,QAAQ,CAACJ;QAC3BK,kBAAkB,QAAQ,CAACL;QAC3BM,eAAe,QAAQ,CAACN;QACxBO,iBAAiB,QAAQ,CAACP;QAC1BQ,gBAAgB,QAAQ,CAACR;QACzBS,yBAAyB,QAAQ,CAACT;QAClCU,wBAAwB,QAAQ,CAACV;QACjCW,mBAAmB,QAAQ,CAACX;QAC5BY,sBAAsB,QAAQ,CAACZ;QAC/Ba,2BAA2B,QAAQ,CAACb;QACpCc,wBAAwB,QAAQ,CAACd;QACjCe,oBAAoB,QAAQ,CAACf;QAG7BA,UAAU,QAAQ,CAACgB;IACvB;AACJ"}
@@ -12,6 +12,7 @@ import { ImageAssetType } from "./assetTypes/image/ImageAssetType.js";
12
12
  import { PrivateFileAssetRequestResolverDecorator } from "./privateFiles/PrivateFileAssetRequestResolver.js";
13
13
  import { PrivateAuthenticatedAuthorizerImpl } from "./privateFiles/PrivateAuthenticatedAuthorizer.js";
14
14
  import { PrivateFilesAssetProcessorDecorator } from "./privateFiles/PrivateFilesAssetProcessor.js";
15
+ import { PrivateAssetDeliveryRouteDefinition } from "./privateFiles/PrivateAssetDeliveryRouteDefinition.js";
15
16
  const AssetDeliveryFeature = createFeature({
16
17
  name: "AssetDelivery",
17
18
  register (container) {
@@ -23,8 +24,9 @@ const AssetDeliveryFeature = createFeature({
23
24
  container.register(StreamAssetReply).inSingletonScope();
24
25
  container.register(ImageAssetType);
25
26
  container.registerInstance(AssetProcessor, new TransformationAssetProcessor(container));
26
- container.registerDecorator(PrivateFileAssetRequestResolverDecorator);
27
27
  if (container.resolve(FeatureFlags).get().isEnabled("advancedAccessControlLayer.privateFiles")) {
28
+ container.register(PrivateAssetDeliveryRouteDefinition);
29
+ container.registerDecorator(PrivateFileAssetRequestResolverDecorator);
28
30
  container.register(PrivateAuthenticatedAuthorizerImpl);
29
31
  container.registerDecorator(PrivateFilesAssetProcessorDecorator);
30
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/assetDelivery/feature.js","sources":["../../../src/features/assetDelivery/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { FeatureFlags } from \"@webiny/api-core/features/featureFlags/abstractions.js\";\nimport { AssetProcessor } from \"./abstractions.js\";\nimport { FilesAssetRequestResolverImpl } from \"./FilesAssetRequestResolver.js\";\nimport { NullAssetResolverImpl } from \"./NullAssetResolver.js\";\nimport { NullAssetOutputStrategyImpl } from \"./NullAssetOutputStrategy.js\";\nimport { AssetFactory } from \"./Asset/Asset.js\";\nimport { ObjectKey } from \"./ObjectKey/ObjectKey.js\";\nimport { StreamAssetReply } from \"./StreamAssetReply/StreamAssetReply.js\";\nimport { TransformationAssetProcessor } from \"./transformation/TransformationAssetProcessor.js\";\nimport { ImageAssetType } from \"./assetTypes/image/ImageAssetType.js\";\nimport { PrivateFileAssetRequestResolverDecorator } from \"./privateFiles/PrivateFileAssetRequestResolver.js\";\nimport { PrivateAuthenticatedAuthorizerImpl } from \"./privateFiles/PrivateAuthenticatedAuthorizer.js\";\nimport { PrivateFilesAssetProcessorDecorator } from \"./privateFiles/PrivateFilesAssetProcessor.js\";\n\nexport const AssetDeliveryFeature = createFeature({\n name: \"AssetDelivery\",\n register(container) {\n container.register(FilesAssetRequestResolverImpl);\n container.register(NullAssetResolverImpl);\n container.register(NullAssetOutputStrategyImpl);\n container.register(AssetFactory).inSingletonScope();\n container.register(ObjectKey).inSingletonScope();\n container.register(StreamAssetReply).inSingletonScope();\n container.register(ImageAssetType);\n container.registerInstance(AssetProcessor, new TransformationAssetProcessor(container));\n\n container.registerDecorator(PrivateFileAssetRequestResolverDecorator);\n\n // Register-time gate on the effective feature flags (userFlag && live WCP license). Valid at\n // register() time because the license is refreshed PRE-register (WcpLicenseLoader.load in\n // registerApiRequestStack) and FeatureFlags reads that process cache — and it re-evaluates per\n // request since the child re-registers, so a license change takes effect on the next request.\n if (\n container\n .resolve(FeatureFlags)\n .get()\n .isEnabled(\"advancedAccessControlLayer.privateFiles\")\n ) {\n container.register(PrivateAuthenticatedAuthorizerImpl);\n container.registerDecorator(PrivateFilesAssetProcessorDecorator);\n }\n }\n});\n"],"names":["AssetDeliveryFeature","createFeature","container","FilesAssetRequestResolverImpl","NullAssetResolverImpl","NullAssetOutputStrategyImpl","AssetFactory","ObjectKey","StreamAssetReply","ImageAssetType","AssetProcessor","TransformationAssetProcessor","PrivateFileAssetRequestResolverDecorator","FeatureFlags","PrivateAuthenticatedAuthorizerImpl","PrivateFilesAssetProcessorDecorator"],"mappings":";;;;;;;;;;;;;;AAeO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI,cAAc,gBAAgB;QACjDJ,UAAU,QAAQ,CAACK,WAAW,gBAAgB;QAC9CL,UAAU,QAAQ,CAACM,kBAAkB,gBAAgB;QACrDN,UAAU,QAAQ,CAACO;QACnBP,UAAU,gBAAgB,CAACQ,gBAAgB,IAAIC,6BAA6BT;QAE5EA,UAAU,iBAAiB,CAACU;QAM5B,IACIV,UACK,OAAO,CAACW,cACR,GAAG,GACH,SAAS,CAAC,4CACjB;YACEX,UAAU,QAAQ,CAACY;YACnBZ,UAAU,iBAAiB,CAACa;QAChC;IACJ;AACJ"}
1
+ {"version":3,"file":"features/assetDelivery/feature.js","sources":["../../../src/features/assetDelivery/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { FeatureFlags } from \"@webiny/api-core/features/featureFlags/abstractions.js\";\nimport { AssetProcessor } from \"./abstractions.js\";\nimport { FilesAssetRequestResolverImpl } from \"./FilesAssetRequestResolver.js\";\nimport { NullAssetResolverImpl } from \"./NullAssetResolver.js\";\nimport { NullAssetOutputStrategyImpl } from \"./NullAssetOutputStrategy.js\";\nimport { AssetFactory } from \"./Asset/Asset.js\";\nimport { ObjectKey } from \"./ObjectKey/ObjectKey.js\";\nimport { StreamAssetReply } from \"./StreamAssetReply/StreamAssetReply.js\";\nimport { TransformationAssetProcessor } from \"./transformation/TransformationAssetProcessor.js\";\nimport { ImageAssetType } from \"./assetTypes/image/ImageAssetType.js\";\nimport { PrivateFileAssetRequestResolverDecorator } from \"./privateFiles/PrivateFileAssetRequestResolver.js\";\nimport { PrivateAuthenticatedAuthorizerImpl } from \"./privateFiles/PrivateAuthenticatedAuthorizer.js\";\nimport { PrivateFilesAssetProcessorDecorator } from \"./privateFiles/PrivateFilesAssetProcessor.js\";\nimport { PrivateAssetDeliveryRouteDefinition } from \"./privateFiles/PrivateAssetDeliveryRouteDefinition.js\";\n\nexport const AssetDeliveryFeature = createFeature({\n name: \"AssetDelivery\",\n register(container) {\n container.register(FilesAssetRequestResolverImpl);\n container.register(NullAssetResolverImpl);\n container.register(NullAssetOutputStrategyImpl);\n container.register(AssetFactory).inSingletonScope();\n container.register(ObjectKey).inSingletonScope();\n container.register(StreamAssetReply).inSingletonScope();\n container.register(ImageAssetType);\n container.registerInstance(AssetProcessor, new TransformationAssetProcessor(container));\n\n // Register-time gate on the effective feature flags (userFlag && live WCP license). Valid at\n // register() time because the license is refreshed PRE-register (WcpLicenseLoader.load in\n // registerApiRequestStack) and FeatureFlags reads that process cache — and it re-evaluates per\n // request since the child re-registers, so a license change takes effect on the next request.\n if (\n container\n .resolve(FeatureFlags)\n .get()\n .isEnabled(\"advancedAccessControlLayer.privateFiles\")\n ) {\n container.register(PrivateAssetDeliveryRouteDefinition);\n container.registerDecorator(PrivateFileAssetRequestResolverDecorator);\n container.register(PrivateAuthenticatedAuthorizerImpl);\n container.registerDecorator(PrivateFilesAssetProcessorDecorator);\n }\n }\n});\n"],"names":["AssetDeliveryFeature","createFeature","container","FilesAssetRequestResolverImpl","NullAssetResolverImpl","NullAssetOutputStrategyImpl","AssetFactory","ObjectKey","StreamAssetReply","ImageAssetType","AssetProcessor","TransformationAssetProcessor","FeatureFlags","PrivateAssetDeliveryRouteDefinition","PrivateFileAssetRequestResolverDecorator","PrivateAuthenticatedAuthorizerImpl","PrivateFilesAssetProcessorDecorator"],"mappings":";;;;;;;;;;;;;;;AAgBO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI,cAAc,gBAAgB;QACjDJ,UAAU,QAAQ,CAACK,WAAW,gBAAgB;QAC9CL,UAAU,QAAQ,CAACM,kBAAkB,gBAAgB;QACrDN,UAAU,QAAQ,CAACO;QACnBP,UAAU,gBAAgB,CAACQ,gBAAgB,IAAIC,6BAA6BT;QAM5E,IACIA,UACK,OAAO,CAACU,cACR,GAAG,GACH,SAAS,CAAC,4CACjB;YACEV,UAAU,QAAQ,CAACW;YACnBX,UAAU,iBAAiB,CAACY;YAC5BZ,UAAU,QAAQ,CAACa;YACnBb,UAAU,iBAAiB,CAACc;QAChC;IACJ;AACJ"}
@@ -0,0 +1,11 @@
1
+ import { HttpRouteDefinition } from "@webiny/event-handler-core";
2
+ declare class PrivateAssetDeliveryRouteDefinitionImpl implements HttpRouteDefinition.Interface {
3
+ readonly name = "private-asset-delivery";
4
+ readonly method = "GET";
5
+ readonly path = "/private/*";
6
+ readonly handler: HttpRouteDefinition.Interface["handler"];
7
+ }
8
+ export declare const PrivateAssetDeliveryRouteDefinition: typeof PrivateAssetDeliveryRouteDefinitionImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRouteDefinition>;
10
+ };
11
+ export {};
@@ -0,0 +1,17 @@
1
+ import { HttpRouteDefinition } from "@webiny/event-handler-core";
2
+ import { AssetDeliveryRoute } from "../../../delivery/AssetDeliveryRoute.js";
3
+ class PrivateAssetDeliveryRouteDefinitionImpl {
4
+ constructor(){
5
+ this.name = "private-asset-delivery";
6
+ this.method = "GET";
7
+ this.path = "/private/*";
8
+ this.handler = AssetDeliveryRoute;
9
+ }
10
+ }
11
+ const PrivateAssetDeliveryRouteDefinition = HttpRouteDefinition.createImplementation({
12
+ implementation: PrivateAssetDeliveryRouteDefinitionImpl,
13
+ dependencies: []
14
+ });
15
+ export { PrivateAssetDeliveryRouteDefinition };
16
+
17
+ //# sourceMappingURL=PrivateAssetDeliveryRouteDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/assetDelivery/privateFiles/PrivateAssetDeliveryRouteDefinition.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateAssetDeliveryRouteDefinition.ts"],"sourcesContent":["import { HttpRouteDefinition } from \"@webiny/event-handler-core\";\nimport { AssetDeliveryRoute } from \"~/delivery/AssetDeliveryRoute.js\";\n\n/*\n * Private files are delivered from `/private/*`: a private file requested via `/files/*` is\n * redirected here, and `PrivateFileAssetRequestResolver` only handles this prefix. Same handler as\n * `/files/*`, the resolvers pick the request apart by its path.\n */\nclass PrivateAssetDeliveryRouteDefinitionImpl implements HttpRouteDefinition.Interface {\n readonly name = \"private-asset-delivery\";\n readonly method = \"GET\";\n readonly path = \"/private/*\";\n // Typed as the interface's field: inferred, the declaration would expose the handler's private\n // members, which an exported anonymous class type cannot carry.\n readonly handler: HttpRouteDefinition.Interface[\"handler\"] = AssetDeliveryRoute;\n}\n\nexport const PrivateAssetDeliveryRouteDefinition = HttpRouteDefinition.createImplementation({\n implementation: PrivateAssetDeliveryRouteDefinitionImpl,\n dependencies: []\n});\n"],"names":["PrivateAssetDeliveryRouteDefinitionImpl","AssetDeliveryRoute","PrivateAssetDeliveryRouteDefinition","HttpRouteDefinition"],"mappings":";;AAQA,MAAMA;;aACO,IAAI,GAAG;aACP,MAAM,GAAG;aACT,IAAI,GAAG;aAGP,OAAO,GAA6CC;;AACjE;AAEO,MAAMC,sCAAsCC,oBAAoB,oBAAoB,CAAC;IACxF,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -7,8 +7,7 @@ class PrivateAuthenticatedAuthorizer {
7
7
  }
8
8
  async authorize(file) {
9
9
  if (file.accessControl && "private-authenticated" === file.accessControl.type) {
10
- const identity = this.identityContext.getIdentity();
11
- if (!identity) throw new error({
10
+ if (this.identityContext.getIdentity().isAnonymous()) throw new error({
12
11
  code: "NOT_AUTHORIZED",
13
12
  message: "You're not authorized to access this asset!"
14
13
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { AssetAuthorizer, type IAssetAuthorizer } from \"../abstractions.js\";\n\nexport class PrivateAuthenticatedAuthorizer implements IAssetAuthorizer {\n private identityContext: IdentityContext.Interface;\n\n constructor(identityContext: IdentityContext.Interface) {\n this.identityContext = identityContext;\n }\n\n async authorize(file: File) {\n if (file.accessControl && file.accessControl.type === \"private-authenticated\") {\n const identity = this.identityContext.getIdentity();\n\n if (!identity) {\n throw new Error({\n code: \"NOT_AUTHORIZED\",\n message: \"You're not authorized to access this asset!\"\n });\n }\n }\n }\n}\n\nexport const PrivateAuthenticatedAuthorizerImpl = AssetAuthorizer.createImplementation({\n implementation: PrivateAuthenticatedAuthorizer,\n dependencies: [IdentityContext]\n});\n"],"names":["PrivateAuthenticatedAuthorizer","identityContext","file","identity","Error","PrivateAuthenticatedAuthorizerImpl","AssetAuthorizer","IdentityContext"],"mappings":";;;AAKO,MAAMA;IAGT,YAAYC,eAA0C,CAAE;QACpD,IAAI,CAAC,eAAe,GAAGA;IAC3B;IAEA,MAAM,UAAUC,IAAU,EAAE;QACxB,IAAIA,KAAK,aAAa,IAAIA,AAA4B,4BAA5BA,KAAK,aAAa,CAAC,IAAI,EAA8B;YAC3E,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;YAEjD,IAAI,CAACA,UACD,MAAM,IAAIC,MAAM;gBACZ,MAAM;gBACN,SAAS;YACb;QAER;IACJ;AACJ;AAEO,MAAMC,qCAAqCC,gBAAgB,oBAAoB,CAAC;IACnF,gBAAgBN;IAChB,cAAc;QAACO;KAAgB;AACnC"}
1
+ {"version":3,"file":"features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { AssetAuthorizer, type IAssetAuthorizer } from \"../abstractions.js\";\n\nexport class PrivateAuthenticatedAuthorizer implements IAssetAuthorizer {\n private identityContext: IdentityContext.Interface;\n\n constructor(identityContext: IdentityContext.Interface) {\n this.identityContext = identityContext;\n }\n\n async authorize(file: File) {\n if (file.accessControl && file.accessControl.type === \"private-authenticated\") {\n // A request without a token still has an identity: the anonymous one.\n if (this.identityContext.getIdentity().isAnonymous()) {\n throw new Error({\n code: \"NOT_AUTHORIZED\",\n message: \"You're not authorized to access this asset!\"\n });\n }\n }\n }\n}\n\nexport const PrivateAuthenticatedAuthorizerImpl = AssetAuthorizer.createImplementation({\n implementation: PrivateAuthenticatedAuthorizer,\n dependencies: [IdentityContext]\n});\n"],"names":["PrivateAuthenticatedAuthorizer","identityContext","file","Error","PrivateAuthenticatedAuthorizerImpl","AssetAuthorizer","IdentityContext"],"mappings":";;;AAKO,MAAMA;IAGT,YAAYC,eAA0C,CAAE;QACpD,IAAI,CAAC,eAAe,GAAGA;IAC3B;IAEA,MAAM,UAAUC,IAAU,EAAE;QACxB,IAAIA,KAAK,aAAa,IAAIA,AAA4B,4BAA5BA,KAAK,aAAa,CAAC,IAAI,EAE7C;YAAA,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,WAAW,IAC9C,MAAM,IAAIC,MAAM;gBACZ,MAAM;gBACN,SAAS;YACb;QACJ;IAER;AACJ;AAEO,MAAMC,qCAAqCC,gBAAgB,oBAAoB,CAAC;IACnF,gBAAgBL;IAChB,cAAc;QAACM;KAAgB;AACnC"}
@@ -17,6 +17,7 @@ class PrivateFileAssetRequestResolver {
17
17
  },
18
18
  options: {
19
19
  ...query,
20
+ original: "original" in query,
20
21
  width: query.width ? parseInt(query.width) : void 0
21
22
  }
22
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.ts"],"sourcesContent":["import type { Request } from \"@webiny/handler/types.js\";\nimport { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetRequestResolver, type IAssetRequestResolver } from \"../abstractions.js\";\n\nexport class PrivateFileAssetRequestResolver implements IAssetRequestResolver {\n private readonly resolver: IAssetRequestResolver;\n\n constructor(resolver: IAssetRequestResolver) {\n this.resolver = resolver;\n }\n\n async resolve(request: Request): Promise<AssetRequest | undefined> {\n if (!request.url?.startsWith(\"/private/\")) {\n return this.resolver.resolve(request);\n }\n\n const params = (request.params ?? {}) as Record<string, any>;\n const query = (request.query ?? {}) as Record<string, any>;\n\n const path = params[\"*\"];\n\n return new AssetRequest({\n key: decodeURI(path).replace(\"/private/\", \"\"),\n context: {\n url: request.url ?? \"\",\n private: true\n },\n options: {\n ...query,\n width: query.width ? parseInt(query.width) : undefined\n }\n });\n }\n}\n\nexport const PrivateFileAssetRequestResolverDecorator = AssetRequestResolver.createDecorator({\n decorator: PrivateFileAssetRequestResolver,\n dependencies: []\n});\n"],"names":["PrivateFileAssetRequestResolver","resolver","request","params","query","path","AssetRequest","decodeURI","parseInt","undefined","PrivateFileAssetRequestResolverDecorator","AssetRequestResolver"],"mappings":";;AAIO,MAAMA;IAGT,YAAYC,QAA+B,CAAE;QACzC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,QAAQC,OAAgB,EAAqC;QAC/D,IAAI,CAACA,QAAQ,GAAG,EAAE,WAAW,cACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACA;QAGjC,MAAMC,SAAUD,QAAQ,MAAM,IAAI,CAAC;QACnC,MAAME,QAASF,QAAQ,KAAK,IAAI,CAAC;QAEjC,MAAMG,OAAOF,MAAM,CAAC,IAAI;QAExB,OAAO,IAAIG,aAAa;YACpB,KAAKC,UAAUF,MAAM,OAAO,CAAC,aAAa;YAC1C,SAAS;gBACL,KAAKH,QAAQ,GAAG,IAAI;gBACpB,SAAS;YACb;YACA,SAAS;gBACL,GAAGE,KAAK;gBACR,OAAOA,MAAM,KAAK,GAAGI,SAASJ,MAAM,KAAK,IAAIK;YACjD;QACJ;IACJ;AACJ;AAEO,MAAMC,2CAA2CC,qBAAqB,eAAe,CAAC;IACzF,WAAWX;IACX,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.ts"],"sourcesContent":["import type { Request } from \"@webiny/handler/types.js\";\nimport { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetRequestResolver, type IAssetRequestResolver } from \"../abstractions.js\";\n\nexport class PrivateFileAssetRequestResolver implements IAssetRequestResolver {\n private readonly resolver: IAssetRequestResolver;\n\n constructor(resolver: IAssetRequestResolver) {\n this.resolver = resolver;\n }\n\n async resolve(request: Request): Promise<AssetRequest | undefined> {\n if (!request.url?.startsWith(\"/private/\")) {\n return this.resolver.resolve(request);\n }\n\n const params = (request.params ?? {}) as Record<string, any>;\n const query = (request.query ?? {}) as Record<string, any>;\n\n const path = params[\"*\"];\n\n return new AssetRequest({\n key: decodeURI(path).replace(\"/private/\", \"\"),\n context: {\n url: request.url ?? \"\",\n private: true\n },\n options: {\n ...query,\n // A presence flag, as in `FilesAssetRequestResolver`: a bare `?original` is \"\".\n original: \"original\" in query,\n width: query.width ? parseInt(query.width) : undefined\n }\n });\n }\n}\n\nexport const PrivateFileAssetRequestResolverDecorator = AssetRequestResolver.createDecorator({\n decorator: PrivateFileAssetRequestResolver,\n dependencies: []\n});\n"],"names":["PrivateFileAssetRequestResolver","resolver","request","params","query","path","AssetRequest","decodeURI","parseInt","undefined","PrivateFileAssetRequestResolverDecorator","AssetRequestResolver"],"mappings":";;AAIO,MAAMA;IAGT,YAAYC,QAA+B,CAAE;QACzC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,QAAQC,OAAgB,EAAqC;QAC/D,IAAI,CAACA,QAAQ,GAAG,EAAE,WAAW,cACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACA;QAGjC,MAAMC,SAAUD,QAAQ,MAAM,IAAI,CAAC;QACnC,MAAME,QAASF,QAAQ,KAAK,IAAI,CAAC;QAEjC,MAAMG,OAAOF,MAAM,CAAC,IAAI;QAExB,OAAO,IAAIG,aAAa;YACpB,KAAKC,UAAUF,MAAM,OAAO,CAAC,aAAa;YAC1C,SAAS;gBACL,KAAKH,QAAQ,GAAG,IAAI;gBACpB,SAAS;YACb;YACA,SAAS;gBACL,GAAGE,KAAK;gBAER,UAAU,cAAcA;gBACxB,OAAOA,MAAM,KAAK,GAAGI,SAASJ,MAAM,KAAK,IAAIK;YACjD;QACJ;IACJ;AACJ;AAEO,MAAMC,2CAA2CC,qBAAqB,eAAe,CAAC;IACzF,WAAWX;IACX,cAAc,EAAE;AACpB"}
@@ -1,8 +1,10 @@
1
1
  import { FileAfterCreateEventHandler } from "../file/CreateFile/events.js";
2
2
  import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
3
+ import { Logger } from "@webiny/api-core/features/logger/index.js";
3
4
  declare class ExtractMetadataHandlerImpl implements FileAfterCreateEventHandler.Interface {
4
5
  private readonly taskService;
5
- constructor(taskService: TaskService.Interface);
6
+ private readonly logger;
7
+ constructor(taskService: TaskService.Interface, logger: Logger.Interface);
6
8
  handle(event: FileAfterCreateEventHandler.Event): Promise<void>;
7
9
  }
8
10
  export declare const ExtractMetadataHandler: typeof ExtractMetadataHandlerImpl & {
@@ -1,23 +1,30 @@
1
1
  import { FileAfterCreateEventHandler } from "../file/CreateFile/events.js";
2
2
  import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
3
+ import { Logger } from "@webiny/api-core/features/logger/index.js";
3
4
  class ExtractMetadataHandlerImpl {
4
- constructor(taskService){
5
+ constructor(taskService, logger){
5
6
  this.taskService = taskService;
7
+ this.logger = logger;
6
8
  }
7
9
  async handle(event) {
8
10
  const { file } = event.payload;
9
- await this.taskService.trigger({
11
+ const result = await this.taskService.trigger({
10
12
  definition: "fileManagerExtractMetadata",
11
13
  input: {
12
14
  fileId: file.id
13
15
  }
14
16
  });
17
+ if (result.isFail()) this.logger.error({
18
+ error: result.error,
19
+ fileId: file.id
20
+ }, "Could not start the metadata extraction.");
15
21
  }
16
22
  }
17
23
  const ExtractMetadataHandler = FileAfterCreateEventHandler.createImplementation({
18
24
  implementation: ExtractMetadataHandlerImpl,
19
25
  dependencies: [
20
- TaskService
26
+ TaskService,
27
+ Logger
21
28
  ]
22
29
  });
23
30
  export { ExtractMetadataHandler };