@webiny/api-file-manager 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FileManagerAppFeature.d.ts +5 -0
- package/FileManagerAppFeature.js +21 -0
- package/FileManagerAppFeature.js.map +1 -0
- package/{constants.js → contants.js} +1 -1
- package/contants.js.map +1 -0
- package/delivery/AssetDelivery/Asset.d.ts +1 -2
- package/delivery/AssetDelivery/Asset.js +1 -4
- package/delivery/AssetDelivery/Asset.js.map +1 -1
- package/delivery/AssetDelivery/AssetRequest.d.ts +2 -3
- package/delivery/AssetDelivery/AssetRequest.js +0 -3
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
- package/delivery/AssetDelivery/abstractions/AssetReply.d.ts +1 -2
- package/delivery/AssetDelivery/abstractions/AssetReply.js +0 -5
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
- package/delivery/AssetDeliveryRoute.d.ts +24 -0
- package/delivery/AssetDeliveryRoute.js +69 -0
- package/delivery/AssetDeliveryRoute.js.map +1 -0
- package/delivery/index.d.ts +3 -3
- package/delivery/index.js +2 -0
- package/delivery/setupAssetDelivery.d.ts +1 -1
- package/delivery/setupAssetDelivery.js +1 -69
- package/delivery/setupAssetDelivery.js.map +1 -1
- package/domain/file/abstractions.d.ts +13 -5
- package/domain/file/abstractions.js +2 -2
- package/domain/file/abstractions.js.map +1 -1
- package/domain/file/file.model.d.ts +3 -3
- package/domain/file/file.model.js +7 -6
- package/domain/file/file.model.js.map +1 -1
- package/domain/settings/validation.js +3 -10
- package/domain/settings/validation.js.map +1 -1
- package/exports/api/file-manager/assetDelivery.d.ts +1 -9
- package/exports/api/file-manager/assetDelivery.js +1 -8
- package/exports/api/file-manager/file.d.ts +1 -1
- package/exports/api/file-manager/file.js +1 -1
- package/features/FileManagerFeature.js +0 -6
- package/features/FileManagerFeature.js.map +1 -1
- package/features/assetDelivery/Asset/Asset.js +1 -1
- package/features/assetDelivery/Asset/Asset.js.map +1 -1
- package/features/assetDelivery/FilesAssetRequestResolver.d.ts +7 -9
- package/features/assetDelivery/FilesAssetRequestResolver.js +16 -20
- package/features/assetDelivery/FilesAssetRequestResolver.js.map +1 -1
- package/features/assetDelivery/NullAssetOutputStrategy.d.ts +6 -6
- package/features/assetDelivery/NullAssetOutputStrategy.js +6 -6
- package/features/assetDelivery/NullAssetOutputStrategy.js.map +1 -1
- package/features/assetDelivery/NullAssetReply.d.ts +1 -2
- package/features/assetDelivery/NullAssetReply.js +0 -3
- package/features/assetDelivery/NullAssetReply.js.map +1 -1
- package/features/assetDelivery/NullAssetResolver.d.ts +6 -6
- package/features/assetDelivery/NullAssetResolver.js +5 -5
- package/features/assetDelivery/NullAssetResolver.js.map +1 -1
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.js +1 -1
- package/features/assetDelivery/StreamAssetReply/StreamAssetReply.js.map +1 -1
- package/features/assetDelivery/abstractions.d.ts +65 -0
- package/features/assetDelivery/abstractions.js +11 -0
- package/features/assetDelivery/abstractions.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/SharpTransformer.d.ts +18 -0
- package/features/assetDelivery/assetTypes/image/SharpTransformer.js +47 -0
- package/features/assetDelivery/assetTypes/image/SharpTransformer.js.map +1 -0
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.js +1 -1
- package/features/assetDelivery/assetTypes/image/normalizeImageOptions.js.map +1 -1
- package/features/assetDelivery/feature.js +17 -20
- package/features/assetDelivery/feature.js.map +1 -1
- package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +2 -2
- package/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +3 -3
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +1 -1
- package/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateCache.d.ts +3 -3
- package/features/assetDelivery/privateFiles/PrivateCache.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +8 -9
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +14 -17
- package/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +8 -8
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js +7 -8
- package/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
- package/features/assetDelivery/privateFiles/PublicCache.d.ts +3 -3
- package/features/assetDelivery/privateFiles/PublicCache.js.map +1 -1
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +4 -5
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +1 -4
- package/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -1
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +4 -5
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +1 -4
- package/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -1
- package/features/assetDelivery/transformation/CallableContentsReader.d.ts +1 -1
- package/features/assetDelivery/transformation/CallableContentsReader.js.map +1 -1
- package/features/assetDelivery/transformation/TransformationAssetProcessor.d.ts +5 -3
- package/features/assetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
- package/features/file/CreateFile/CreateFileRepository.d.ts +3 -3
- package/features/file/CreateFile/CreateFileRepository.js +6 -5
- package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
- package/features/file/DeleteFile/DeleteFileRepository.d.ts +3 -3
- package/features/file/DeleteFile/DeleteFileRepository.js +6 -5
- package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
- package/features/file/FileModelProvider.d.ts +31 -0
- package/features/file/FileModelProvider.js +22 -0
- package/features/file/FileModelProvider.js.map +1 -0
- package/features/file/FileUrlGenerator/FileUrlGenerator.d.ts +3 -6
- package/features/file/FileUrlGenerator/FileUrlGenerator.js +5 -19
- package/features/file/FileUrlGenerator/FileUrlGenerator.js.map +1 -1
- package/features/file/FileUrlGenerator/SettingsFileUrlPrefixProvider.d.ts +13 -0
- package/features/file/FileUrlGenerator/SettingsFileUrlPrefixProvider.js +29 -0
- package/features/file/FileUrlGenerator/SettingsFileUrlPrefixProvider.js.map +1 -0
- package/features/file/FileUrlGenerator/abstractions.d.ts +12 -0
- package/features/file/FileUrlGenerator/abstractions.js +2 -1
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
- package/features/file/FileUrlGenerator/feature.js +2 -0
- package/features/file/FileUrlGenerator/feature.js.map +1 -1
- package/features/file/FileUrlGenerator/index.d.ts +1 -0
- package/features/file/FileUrlGenerator/index.js +1 -1
- package/features/file/GetFile/GetFileRepository.d.ts +3 -3
- package/features/file/GetFile/GetFileRepository.js +6 -5
- package/features/file/GetFile/GetFileRepository.js.map +1 -1
- package/features/file/ListFiles/ListFilesRepository.d.ts +3 -3
- package/features/file/ListFiles/ListFilesRepository.js +8 -7
- package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.d.ts +15 -5
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +21 -7
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -1
- package/features/file/ListTags/ListTagsRepository.d.ts +3 -3
- package/features/file/ListTags/ListTagsRepository.js +7 -6
- package/features/file/ListTags/ListTagsRepository.js.map +1 -1
- package/features/file/UpdateFile/UpdateFileRepository.d.ts +3 -3
- package/features/file/UpdateFile/UpdateFileRepository.js +6 -5
- package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js +1 -4
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.d.ts +3 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +10 -3
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
- package/graphql/FmGraphQLSchema.d.ts +8 -9
- package/graphql/FmGraphQLSchema.js +27 -19
- package/graphql/FmGraphQLSchema.js.map +1 -1
- package/index.d.ts +4 -4
- package/index.js +4 -33
- package/index.js.map +1 -1
- package/package.json +18 -18
- package/constants.js.map +0 -1
- package/features/assetDelivery/AssetRequest/AssetRequest.d.ts +0 -8
- package/features/assetDelivery/AssetRequest/AssetRequest.js +0 -14
- package/features/assetDelivery/AssetRequest/AssetRequest.js.map +0 -1
- package/features/assetDelivery/AssetRequest/abstractions.d.ts +0 -11
- package/features/assetDelivery/AssetRequest/abstractions.js +0 -5
- package/features/assetDelivery/AssetRequest/abstractions.js.map +0 -1
- package/features/assetDelivery/AssetRequest/index.d.ts +0 -1
- package/features/assetDelivery/AssetRequest/index.js +0 -1
- package/features/assetDelivery/abstractions/AssetAuthorizer.d.ts +0 -9
- package/features/assetDelivery/abstractions/AssetAuthorizer.js +0 -5
- package/features/assetDelivery/abstractions/AssetAuthorizer.js.map +0 -1
- package/features/assetDelivery/abstractions/AssetContentsReader.d.ts +0 -9
- package/features/assetDelivery/abstractions/AssetContentsReader.js +0 -5
- package/features/assetDelivery/abstractions/AssetContentsReader.js.map +0 -1
- package/features/assetDelivery/abstractions/AssetOutputStrategy.d.ts +0 -11
- package/features/assetDelivery/abstractions/AssetOutputStrategy.js +0 -5
- package/features/assetDelivery/abstractions/AssetOutputStrategy.js.map +0 -1
- package/features/assetDelivery/abstractions/AssetProcessor.d.ts +0 -11
- package/features/assetDelivery/abstractions/AssetProcessor.js +0 -5
- package/features/assetDelivery/abstractions/AssetProcessor.js.map +0 -1
- package/features/assetDelivery/abstractions/AssetRequestResolver.d.ts +0 -11
- package/features/assetDelivery/abstractions/AssetRequestResolver.js +0 -5
- package/features/assetDelivery/abstractions/AssetRequestResolver.js.map +0 -1
- package/features/assetDelivery/abstractions/AssetResolver.d.ts +0 -11
- package/features/assetDelivery/abstractions/AssetResolver.js +0 -5
- package/features/assetDelivery/abstractions/AssetResolver.js.map +0 -1
- package/features/assetDelivery/abstractions/AssetTransformationStrategy.d.ts +0 -11
- package/features/assetDelivery/abstractions/AssetTransformationStrategy.js +0 -5
- package/features/assetDelivery/abstractions/AssetTransformationStrategy.js.map +0 -1
- package/graphql/FmUploadGraphQLSchema.d.ts +0 -11
- package/graphql/FmUploadGraphQLSchema.js +0 -231
- package/graphql/FmUploadGraphQLSchema.js.map +0 -1
- /package/{constants.d.ts → contants.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
|
-
import {
|
|
3
|
-
export declare class NotAuthorizedOutputStrategy implements
|
|
2
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
3
|
+
export declare class NotAuthorizedOutputStrategy implements IAssetOutputStrategy {
|
|
4
4
|
output(): Promise<AssetReply>;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.ts"],"sourcesContent":["import type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { NotAuthorizedAssetReply } from \"./NotAuthorizedAssetReply.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/NotAuthorizedOutputStrategy.ts"],"sourcesContent":["import type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { NotAuthorizedAssetReply } from \"./NotAuthorizedAssetReply.js\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class NotAuthorizedOutputStrategy implements IAssetOutputStrategy {\n async output(): Promise<AssetReply> {\n return new NotAuthorizedAssetReply();\n }\n}\n"],"names":["NotAuthorizedOutputStrategy","NotAuthorizedAssetReply"],"mappings":";AAIO,MAAMA;IACT,MAAM,SAA8B;QAChC,OAAO,IAAIC;IACf;AACJ"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { File } from "../../../domain/file/types.js";
|
|
2
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
-
import {
|
|
4
|
-
export declare class PrivateAuthenticatedAuthorizer implements
|
|
3
|
+
import { type IAssetAuthorizer } from "../abstractions.js";
|
|
4
|
+
export declare class PrivateAuthenticatedAuthorizer implements IAssetAuthorizer {
|
|
5
5
|
private identityContext;
|
|
6
6
|
constructor(identityContext: IdentityContext.Interface);
|
|
7
7
|
authorize(file: File): Promise<void>;
|
|
8
8
|
}
|
|
9
9
|
export declare const PrivateAuthenticatedAuthorizerImpl: typeof PrivateAuthenticatedAuthorizer & {
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<IAssetAuthorizer>;
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
-
import { AssetAuthorizer } from "../abstractions
|
|
3
|
+
import { AssetAuthorizer } from "../abstractions.js";
|
|
4
4
|
class PrivateAuthenticatedAuthorizer {
|
|
5
5
|
constructor(identityContext){
|
|
6
6
|
this.identityContext = identityContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.ts"],"sourcesContent":["import Error from \"@webiny/error\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { AssetAuthorizer } from \"../abstractions
|
|
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,8 +1,8 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
3
|
-
import {
|
|
4
|
-
export declare class PrivateCache implements
|
|
3
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
4
|
+
export declare class PrivateCache implements IAssetOutputStrategy {
|
|
5
5
|
private strategy;
|
|
6
|
-
constructor(strategy:
|
|
6
|
+
constructor(strategy: IAssetOutputStrategy);
|
|
7
7
|
output(asset: Asset): Promise<AssetReply>;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateCache.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateCache.ts"],"sourcesContent":["import { parse, stringify } from \"cache-control-parser\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateCache.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateCache.ts"],"sourcesContent":["import { parse, stringify } from \"cache-control-parser\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class PrivateCache implements IAssetOutputStrategy {\n private strategy: IAssetOutputStrategy;\n\n constructor(strategy: IAssetOutputStrategy) {\n this.strategy = strategy;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const reply = await this.strategy.output(asset);\n\n reply.setHeaders(headers => {\n headers.set(\"cache-control\", (value = \"\") => {\n const cacheControl = parse(value);\n cacheControl[\"private\"] = true;\n cacheControl[\"public\"] = false;\n return stringify(cacheControl);\n });\n return headers;\n });\n\n return reply;\n }\n}\n"],"names":["PrivateCache","strategy","asset","reply","headers","value","cacheControl","parse","stringify"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,QAA8B,CAAE;QACxC,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,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { Request } from "@webiny/handler/types.js";
|
|
2
|
+
import { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
|
+
import { type IAssetRequestResolver } from "../abstractions.js";
|
|
4
|
+
export declare class PrivateFileAssetRequestResolver implements IAssetRequestResolver {
|
|
5
5
|
private readonly resolver;
|
|
6
|
-
constructor(
|
|
7
|
-
resolve(request:
|
|
6
|
+
constructor(resolver: IAssetRequestResolver);
|
|
7
|
+
resolve(request: Request): Promise<AssetRequest | undefined>;
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
10
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
9
|
+
export declare const PrivateFileAssetRequestResolverDecorator: typeof PrivateFileAssetRequestResolver & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<IAssetRequestResolver>;
|
|
11
11
|
};
|
|
12
|
-
export {};
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
class
|
|
4
|
-
constructor(
|
|
5
|
-
this.assetRequestFactory = assetRequestFactory;
|
|
1
|
+
import { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
2
|
+
import { AssetRequestResolver } from "../abstractions.js";
|
|
3
|
+
class PrivateFileAssetRequestResolver {
|
|
4
|
+
constructor(resolver){
|
|
6
5
|
this.resolver = resolver;
|
|
7
6
|
}
|
|
8
7
|
async resolve(request) {
|
|
9
|
-
if (!request.url
|
|
8
|
+
if (!request.url?.startsWith("/private/")) return this.resolver.resolve(request);
|
|
10
9
|
const params = request.params ?? {};
|
|
11
10
|
const query = request.query ?? {};
|
|
12
11
|
const path = params["*"];
|
|
13
|
-
return
|
|
12
|
+
return new AssetRequest({
|
|
14
13
|
key: decodeURI(path).replace("/private/", ""),
|
|
15
14
|
context: {
|
|
16
|
-
url: request.url,
|
|
17
|
-
private: true
|
|
18
|
-
accept: request.headers?.accept
|
|
15
|
+
url: request.url ?? "",
|
|
16
|
+
private: true
|
|
19
17
|
},
|
|
20
18
|
options: {
|
|
21
|
-
...query
|
|
19
|
+
...query,
|
|
20
|
+
width: query.width ? parseInt(query.width) : void 0
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
const
|
|
27
|
-
decorator:
|
|
28
|
-
dependencies: [
|
|
29
|
-
AssetRequestFactory
|
|
30
|
-
]
|
|
25
|
+
const PrivateFileAssetRequestResolverDecorator = AssetRequestResolver.createDecorator({
|
|
26
|
+
decorator: PrivateFileAssetRequestResolver,
|
|
27
|
+
dependencies: []
|
|
31
28
|
});
|
|
32
|
-
export { PrivateFileAssetRequestResolver };
|
|
29
|
+
export { PrivateFileAssetRequestResolver, PrivateFileAssetRequestResolverDecorator };
|
|
33
30
|
|
|
34
31
|
//# sourceMappingURL=PrivateFileAssetRequestResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFileAssetRequestResolver.ts"],"sourcesContent":["import 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,19 +1,19 @@
|
|
|
1
|
+
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
|
+
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
1
3
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
4
|
import { GetFileUseCase } from "../../../features/file/GetFile/index.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
declare class PrivateFilesAssetProcessorImpl implements AssetProcessor.Interface {
|
|
5
|
+
import { type IAssetProcessor, type IAssetAuthorizer } from "../abstractions.js";
|
|
6
|
+
export declare class PrivateFilesAssetProcessor implements IAssetProcessor {
|
|
6
7
|
private readonly identityContext;
|
|
7
8
|
private readonly getFile;
|
|
8
9
|
private readonly assetAuthorizer;
|
|
9
10
|
private readonly assetProcessor;
|
|
10
|
-
constructor(identityContext: IdentityContext.Interface, getFile: GetFileUseCase.Interface, assetAuthorizer:
|
|
11
|
-
process(assetRequest:
|
|
11
|
+
constructor(identityContext: IdentityContext.Interface, getFile: GetFileUseCase.Interface, assetAuthorizer: IAssetAuthorizer, assetProcessor: IAssetProcessor);
|
|
12
|
+
process(assetRequest: AssetRequest, asset: Asset): Promise<Asset>;
|
|
12
13
|
private isPrivate;
|
|
13
14
|
private requestedViaPrivateEndpoint;
|
|
14
15
|
private requestedViaPublicEndpoint;
|
|
15
16
|
}
|
|
16
|
-
export declare const
|
|
17
|
-
__abstraction: import("@webiny/di").Abstraction<
|
|
17
|
+
export declare const PrivateFilesAssetProcessorDecorator: typeof PrivateFilesAssetProcessor & {
|
|
18
|
+
__abstraction: import("@webiny/di").Abstraction<IAssetProcessor>;
|
|
18
19
|
};
|
|
19
|
-
export {};
|
|
@@ -5,9 +5,8 @@ import { RedirectToPublicUrlOutputStrategy } from "./RedirectToPublicUrlOutputSt
|
|
|
5
5
|
import { RedirectToPrivateUrlOutputStrategy } from "./RedirectToPrivateUrlOutputStrategy.js";
|
|
6
6
|
import { PrivateCache } from "./PrivateCache.js";
|
|
7
7
|
import { PublicCache } from "./PublicCache.js";
|
|
8
|
-
import { AssetAuthorizer } from "../abstractions
|
|
9
|
-
|
|
10
|
-
class PrivateFilesAssetProcessorImpl {
|
|
8
|
+
import { AssetAuthorizer, AssetProcessor } from "../abstractions.js";
|
|
9
|
+
class PrivateFilesAssetProcessor {
|
|
11
10
|
constructor(identityContext, getFile, assetAuthorizer, assetProcessor){
|
|
12
11
|
this.identityContext = identityContext;
|
|
13
12
|
this.getFile = getFile;
|
|
@@ -23,11 +22,11 @@ class PrivateFilesAssetProcessorImpl {
|
|
|
23
22
|
});
|
|
24
23
|
const isPrivateFile = this.isPrivate(file);
|
|
25
24
|
if (!isPrivateFile && this.requestedViaPrivateEndpoint(assetRequest)) {
|
|
26
|
-
asset.setOutputStrategy(RedirectToPublicUrlOutputStrategy
|
|
25
|
+
asset.setOutputStrategy(new RedirectToPublicUrlOutputStrategy(assetRequest));
|
|
27
26
|
return asset;
|
|
28
27
|
}
|
|
29
28
|
if (isPrivateFile && this.requestedViaPublicEndpoint(assetRequest)) {
|
|
30
|
-
asset.setOutputStrategy(RedirectToPrivateUrlOutputStrategy
|
|
29
|
+
asset.setOutputStrategy(new RedirectToPrivateUrlOutputStrategy(assetRequest));
|
|
31
30
|
return asset;
|
|
32
31
|
}
|
|
33
32
|
try {
|
|
@@ -53,14 +52,14 @@ class PrivateFilesAssetProcessorImpl {
|
|
|
53
52
|
return !this.requestedViaPrivateEndpoint(assetRequest);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
const
|
|
57
|
-
decorator:
|
|
55
|
+
const PrivateFilesAssetProcessorDecorator = AssetProcessor.createDecorator({
|
|
56
|
+
decorator: PrivateFilesAssetProcessor,
|
|
58
57
|
dependencies: [
|
|
59
58
|
IdentityContext,
|
|
60
59
|
GetFileUseCase,
|
|
61
60
|
AssetAuthorizer
|
|
62
61
|
]
|
|
63
62
|
});
|
|
64
|
-
export { PrivateFilesAssetProcessor };
|
|
63
|
+
export { PrivateFilesAssetProcessor, PrivateFilesAssetProcessorDecorator };
|
|
65
64
|
|
|
66
65
|
//# sourceMappingURL=PrivateFilesAssetProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { GetFileUseCase } from \"~/features/file/GetFile/index.js\";\nimport { NotAuthorizedOutputStrategy } from \"./NotAuthorizedOutputStrategy.js\";\nimport { RedirectToPublicUrlOutputStrategy } from \"./RedirectToPublicUrlOutputStrategy.js\";\nimport { RedirectToPrivateUrlOutputStrategy } from \"./RedirectToPrivateUrlOutputStrategy.js\";\nimport { PrivateCache } from \"./PrivateCache.js\";\nimport { PublicCache } from \"./PublicCache.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.js","sources":["../../../../src/features/assetDelivery/privateFiles/PrivateFilesAssetProcessor.ts"],"sourcesContent":["import type { File } from \"~/domain/file/types.js\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { GetFileUseCase } from \"~/features/file/GetFile/index.js\";\nimport { NotAuthorizedOutputStrategy } from \"./NotAuthorizedOutputStrategy.js\";\nimport { RedirectToPublicUrlOutputStrategy } from \"./RedirectToPublicUrlOutputStrategy.js\";\nimport { RedirectToPrivateUrlOutputStrategy } from \"./RedirectToPrivateUrlOutputStrategy.js\";\nimport { PrivateCache } from \"./PrivateCache.js\";\nimport { PublicCache } from \"./PublicCache.js\";\nimport {\n AssetProcessor,\n AssetAuthorizer,\n type IAssetProcessor,\n type IAssetAuthorizer\n} from \"../abstractions.js\";\n\ninterface MaybePrivate {\n private?: boolean;\n}\n\nexport class PrivateFilesAssetProcessor implements IAssetProcessor {\n private readonly identityContext: IdentityContext.Interface;\n private readonly getFile: GetFileUseCase.Interface;\n private readonly assetAuthorizer: IAssetAuthorizer;\n private readonly assetProcessor: IAssetProcessor;\n\n constructor(\n identityContext: IdentityContext.Interface,\n getFile: GetFileUseCase.Interface,\n assetAuthorizer: IAssetAuthorizer,\n assetProcessor: IAssetProcessor\n ) {\n this.identityContext = identityContext;\n this.getFile = getFile;\n this.assetAuthorizer = assetAuthorizer;\n this.assetProcessor = assetProcessor;\n }\n\n async process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n // Only registered when private files are licensed (register-time gate in AssetDeliveryFeature),\n // so no per-request license guard is needed here.\n const id = asset.getId();\n\n const file = await this.identityContext.withoutAuthorization(async () => {\n const fileResult = await this.getFile.execute(id);\n if (fileResult.isFail()) {\n throw fileResult.error;\n }\n return fileResult.value;\n });\n\n const isPrivateFile = this.isPrivate(file);\n\n if (!isPrivateFile && this.requestedViaPrivateEndpoint(assetRequest)) {\n asset.setOutputStrategy(new RedirectToPublicUrlOutputStrategy(assetRequest));\n return asset;\n }\n\n if (isPrivateFile && this.requestedViaPublicEndpoint(assetRequest)) {\n asset.setOutputStrategy(new RedirectToPrivateUrlOutputStrategy(assetRequest));\n return asset;\n }\n\n try {\n await this.assetAuthorizer.authorize(file);\n } catch {\n asset.setOutputStrategy(new NotAuthorizedOutputStrategy());\n return asset;\n }\n\n const processedAsset = await this.assetProcessor.process(assetRequest, asset);\n\n processedAsset.setOutputStrategy(strategy => {\n if (!strategy) {\n throw Error(`No asset output strategy is configured!`);\n }\n return isPrivateFile ? new PrivateCache(strategy) : new PublicCache(strategy);\n });\n\n return processedAsset;\n }\n\n private isPrivate(file: File) {\n return file.accessControl && file.accessControl.type.startsWith(\"private-\");\n }\n\n private requestedViaPrivateEndpoint(assetRequest: AssetRequest) {\n return assetRequest.getContext<MaybePrivate>().private;\n }\n\n private requestedViaPublicEndpoint(assetRequest: AssetRequest) {\n return !this.requestedViaPrivateEndpoint(assetRequest);\n }\n}\n\nexport const PrivateFilesAssetProcessorDecorator = AssetProcessor.createDecorator({\n decorator: PrivateFilesAssetProcessor,\n dependencies: [IdentityContext, GetFileUseCase, AssetAuthorizer]\n});\n"],"names":["PrivateFilesAssetProcessor","identityContext","getFile","assetAuthorizer","assetProcessor","assetRequest","asset","id","file","fileResult","isPrivateFile","RedirectToPublicUrlOutputStrategy","RedirectToPrivateUrlOutputStrategy","NotAuthorizedOutputStrategy","processedAsset","strategy","Error","PrivateCache","PublicCache","PrivateFilesAssetProcessorDecorator","AssetProcessor","IdentityContext","GetFileUseCase","AssetAuthorizer"],"mappings":";;;;;;;;AAqBO,MAAMA;IAMT,YACIC,eAA0C,EAC1CC,OAAiC,EACjCC,eAAiC,EACjCC,cAA+B,CACjC;QACE,IAAI,CAAC,eAAe,GAAGH;QACvB,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QAAQC,YAA0B,EAAEC,KAAY,EAAkB;QAGpE,MAAMC,KAAKD,MAAM,KAAK;QAEtB,MAAME,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC;YACzD,MAAMC,aAAa,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAACF;YAC9C,IAAIE,WAAW,MAAM,IACjB,MAAMA,WAAW,KAAK;YAE1B,OAAOA,WAAW,KAAK;QAC3B;QAEA,MAAMC,gBAAgB,IAAI,CAAC,SAAS,CAACF;QAErC,IAAI,CAACE,iBAAiB,IAAI,CAAC,2BAA2B,CAACL,eAAe;YAClEC,MAAM,iBAAiB,CAAC,IAAIK,kCAAkCN;YAC9D,OAAOC;QACX;QAEA,IAAII,iBAAiB,IAAI,CAAC,0BAA0B,CAACL,eAAe;YAChEC,MAAM,iBAAiB,CAAC,IAAIM,mCAAmCP;YAC/D,OAAOC;QACX;QAEA,IAAI;YACA,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAACE;QACzC,EAAE,OAAM;YACJF,MAAM,iBAAiB,CAAC,IAAIO;YAC5B,OAAOP;QACX;QAEA,MAAMQ,iBAAiB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACT,cAAcC;QAEvEQ,eAAe,iBAAiB,CAACC,CAAAA;YAC7B,IAAI,CAACA,UACD,MAAMC,MAAM;YAEhB,OAAON,gBAAgB,IAAIO,aAAaF,YAAY,IAAIG,YAAYH;QACxE;QAEA,OAAOD;IACX;IAEQ,UAAUN,IAAU,EAAE;QAC1B,OAAOA,KAAK,aAAa,IAAIA,KAAK,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC;IACpE;IAEQ,4BAA4BH,YAA0B,EAAE;QAC5D,OAAOA,aAAa,UAAU,GAAiB,OAAO;IAC1D;IAEQ,2BAA2BA,YAA0B,EAAE;QAC3D,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAACA;IAC7C;AACJ;AAEO,MAAMc,sCAAsCC,eAAe,eAAe,CAAC;IAC9E,WAAWpB;IACX,cAAc;QAACqB;QAAiBC;QAAgBC;KAAgB;AACpE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
3
|
-
import {
|
|
4
|
-
export declare class PublicCache implements
|
|
3
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
4
|
+
export declare class PublicCache implements IAssetOutputStrategy {
|
|
5
5
|
private strategy;
|
|
6
|
-
constructor(strategy:
|
|
6
|
+
constructor(strategy: IAssetOutputStrategy);
|
|
7
7
|
output(asset: Asset): Promise<AssetReply>;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/PublicCache.js","sources":["../../../../src/features/assetDelivery/privateFiles/PublicCache.ts"],"sourcesContent":["import { parse, stringify } from \"cache-control-parser\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/PublicCache.js","sources":["../../../../src/features/assetDelivery/privateFiles/PublicCache.ts"],"sourcesContent":["import { parse, stringify } from \"cache-control-parser\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class PublicCache implements IAssetOutputStrategy {\n private strategy: IAssetOutputStrategy;\n\n constructor(strategy: IAssetOutputStrategy) {\n this.strategy = strategy;\n }\n\n async output(asset: Asset): Promise<AssetReply> {\n const reply = await this.strategy.output(asset);\n\n reply.setHeaders(headers => {\n headers.set(\"cache-control\", (value = \"\") => {\n const cacheControl = parse(value);\n cacheControl[\"private\"] = false;\n cacheControl[\"public\"] = true;\n return stringify(cacheControl);\n });\n return headers;\n });\n\n return reply;\n }\n}\n"],"names":["PublicCache","strategy","asset","reply","headers","value","cacheControl","parse","stringify"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,QAA8B,CAAE;QACxC,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,10 +1,9 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
3
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
4
|
-
import {
|
|
5
|
-
export declare class RedirectToPrivateUrlOutputStrategy implements
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
private constructor();
|
|
4
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
5
|
+
export declare class RedirectToPrivateUrlOutputStrategy implements IAssetOutputStrategy {
|
|
6
|
+
private assetRequest;
|
|
7
|
+
constructor(assetRequest: AssetRequest);
|
|
9
8
|
output(asset: Asset): Promise<AssetReply>;
|
|
10
9
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
2
|
import { ResponseHeaders } from "@webiny/handler";
|
|
3
3
|
class RedirectToPrivateUrlOutputStrategy {
|
|
4
|
-
static create(assetRequest) {
|
|
5
|
-
return new RedirectToPrivateUrlOutputStrategy(assetRequest);
|
|
6
|
-
}
|
|
7
4
|
constructor(assetRequest){
|
|
8
5
|
this.assetRequest = assetRequest;
|
|
9
6
|
}
|
|
10
7
|
async output(asset) {
|
|
11
8
|
const requestUrl = this.assetRequest.getContext().url;
|
|
12
|
-
return AssetReply
|
|
9
|
+
return new AssetReply({
|
|
13
10
|
code: 301,
|
|
14
11
|
headers: ResponseHeaders.create({
|
|
15
12
|
location: requestUrl.replace("/files/", "/private/"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class RedirectToPrivateUrlOutputStrategy implements IAssetOutputStrategy {\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":";;AAMO,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,10 +1,9 @@
|
|
|
1
1
|
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
2
2
|
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
3
3
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
4
|
-
import {
|
|
5
|
-
export declare class RedirectToPublicUrlOutputStrategy implements
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
private constructor();
|
|
4
|
+
import type { IAssetOutputStrategy } from "../abstractions.js";
|
|
5
|
+
export declare class RedirectToPublicUrlOutputStrategy implements IAssetOutputStrategy {
|
|
6
|
+
private assetRequest;
|
|
7
|
+
constructor(assetRequest: AssetRequest);
|
|
9
8
|
output(asset: Asset): Promise<AssetReply>;
|
|
10
9
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { AssetReply } from "../../../delivery/AssetDelivery/abstractions/AssetReply.js";
|
|
2
2
|
import { ResponseHeaders } from "@webiny/handler";
|
|
3
3
|
class RedirectToPublicUrlOutputStrategy {
|
|
4
|
-
static create(assetRequest) {
|
|
5
|
-
return new RedirectToPublicUrlOutputStrategy(assetRequest);
|
|
6
|
-
}
|
|
7
4
|
constructor(assetRequest){
|
|
8
5
|
this.assetRequest = assetRequest;
|
|
9
6
|
}
|
|
10
7
|
async output(asset) {
|
|
11
8
|
const requestUrl = this.assetRequest.getContext().url;
|
|
12
|
-
return AssetReply
|
|
9
|
+
return new AssetReply({
|
|
13
10
|
code: 301,
|
|
14
11
|
headers: ResponseHeaders.create({
|
|
15
12
|
location: requestUrl.replace("/private/", "/files/"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js","sources":["../../../../src/features/assetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.ts"],"sourcesContent":["import type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\nimport { ResponseHeaders } from \"@webiny/handler\";\nimport type { IAssetOutputStrategy } from \"../abstractions.js\";\n\nexport class RedirectToPublicUrlOutputStrategy implements IAssetOutputStrategy {\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":";;AAMO,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/transformation/CallableContentsReader.js","sources":["../../../../src/features/assetDelivery/transformation/CallableContentsReader.ts"],"sourcesContent":["import { AssetContentsReader } from \"~/features/assetDelivery/abstractions
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/transformation/CallableContentsReader.js","sources":["../../../../src/features/assetDelivery/transformation/CallableContentsReader.ts"],"sourcesContent":["import { AssetContentsReader } from \"~/features/assetDelivery/abstractions.js\";\n\ninterface ContentsCallable {\n (): Promise<Buffer> | Buffer;\n}\n\nexport class CallableContentsReader implements AssetContentsReader.Interface {\n private readonly callable: ContentsCallable;\n\n public static create(callable: ContentsCallable) {\n return new CallableContentsReader(callable);\n }\n\n private constructor(callable: ContentsCallable) {\n this.callable = callable;\n }\n\n public async read(): Promise<Buffer> {\n return this.callable();\n }\n}\n"],"names":["CallableContentsReader","callable"],"mappings":"AAMO,MAAMA;IAGT,OAAc,OAAOC,QAA0B,EAAE;QAC7C,OAAO,IAAID,uBAAuBC;IACtC;IAEA,YAAoBA,QAA0B,CAAE;QAC5C,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAa,OAAwB;QACjC,OAAO,IAAI,CAAC,QAAQ;IACxB;AACJ"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Container } from "@webiny/di";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import type { Asset } from "../../../delivery/AssetDelivery/Asset.js";
|
|
3
|
+
import type { AssetRequest } from "../../../delivery/AssetDelivery/AssetRequest.js";
|
|
4
|
+
import type { IAssetProcessor } from "../abstractions.js";
|
|
5
|
+
export declare class TransformationAssetProcessor implements IAssetProcessor {
|
|
4
6
|
private readonly container;
|
|
5
7
|
constructor(container: Container);
|
|
6
|
-
process(assetRequest:
|
|
8
|
+
process(assetRequest: AssetRequest, asset: Asset): Promise<Asset>;
|
|
7
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/assetDelivery/transformation/TransformationAssetProcessor.js","sources":["../../../../src/features/assetDelivery/transformation/TransformationAssetProcessor.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/assetDelivery/transformation/TransformationAssetProcessor.js","sources":["../../../../src/features/assetDelivery/transformation/TransformationAssetProcessor.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport type { Asset } from \"~/delivery/AssetDelivery/Asset.js\";\nimport type { AssetRequest } from \"~/delivery/AssetDelivery/AssetRequest.js\";\nimport type { IAssetProcessor } from \"../abstractions.js\";\nimport { AssetType } from \"../abstractions/AssetType.js\";\n\nexport class TransformationAssetProcessor implements IAssetProcessor {\n constructor(private readonly container: Container) {}\n\n async process(assetRequest: AssetRequest, asset: Asset): Promise<Asset> {\n const { original } = assetRequest.getOptions();\n\n if (original) {\n console.log(\"Skip transformations; original asset was requested.\");\n return asset;\n }\n\n const assetTypes = this.container.resolveAll(AssetType);\n const match = assetTypes.find(assetType => assetType.canHandle(asset));\n\n if (!match) {\n return asset;\n }\n\n try {\n const handler = this.container.resolve(match.getHandlerAbstraction());\n return handler.handle(assetRequest, asset);\n } catch {\n return asset;\n }\n }\n}\n"],"names":["TransformationAssetProcessor","container","assetRequest","asset","original","console","assetTypes","AssetType","match","assetType","handler"],"mappings":";AAMO,MAAMA;IACT,YAA6BC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IAEpD,MAAM,QAAQC,YAA0B,EAAEC,KAAY,EAAkB;QACpE,MAAM,EAAEC,QAAQ,EAAE,GAAGF,aAAa,UAAU;QAE5C,IAAIE,UAAU;YACVC,QAAQ,GAAG,CAAC;YACZ,OAAOF;QACX;QAEA,MAAMG,aAAa,IAAI,CAAC,SAAS,CAAC,UAAU,CAACC;QAC7C,MAAMC,QAAQF,WAAW,IAAI,CAACG,CAAAA,YAAaA,UAAU,SAAS,CAACN;QAE/D,IAAI,CAACK,OACD,OAAOL;QAGX,IAAI;YACA,MAAMO,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF,MAAM,qBAAqB;YAClE,OAAOE,QAAQ,MAAM,CAACR,cAAcC;QACxC,EAAE,OAAM;YACJ,OAAOA;QACX;IACJ;AACJ"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateFileRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
3
3
|
import { CreateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/CreateEntry";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import type { File, FileInput } from "../../../domain/file/types.js";
|
|
6
6
|
declare class CreateFileRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
7
|
private createEntry;
|
|
8
|
-
private
|
|
9
|
-
constructor(createEntry: CreateEntryUseCase.Interface,
|
|
8
|
+
private fileModelProvider;
|
|
9
|
+
constructor(createEntry: CreateEntryUseCase.Interface, fileModelProvider: FileModelProvider.Interface);
|
|
10
10
|
execute(data: FileInput): Promise<Result<File, RepositoryAbstraction.Error>>;
|
|
11
11
|
}
|
|
12
12
|
export declare const CreateFileRepository: typeof CreateFileRepositoryImpl & {
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateFileRepository } from "./abstractions.js";
|
|
3
3
|
import { CreateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/CreateEntry";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { EntryToFileMapper } from "../shared/EntryToFileMapper.js";
|
|
6
6
|
import { FileNotAuthorizedError, FilePersistenceError } from "../../../domain/file/errors.js";
|
|
7
7
|
import { FileInputToEntryInputMapper } from "../shared/FileInputToEntryInputMapper.js";
|
|
8
8
|
class CreateFileRepositoryImpl {
|
|
9
|
-
constructor(createEntry,
|
|
9
|
+
constructor(createEntry, fileModelProvider){
|
|
10
10
|
this.createEntry = createEntry;
|
|
11
|
-
this.
|
|
11
|
+
this.fileModelProvider = fileModelProvider;
|
|
12
12
|
}
|
|
13
13
|
async execute(data) {
|
|
14
|
-
const
|
|
14
|
+
const fileModel = await this.fileModelProvider.get();
|
|
15
|
+
const result = await this.createEntry.execute(fileModel, FileInputToEntryInputMapper.toEntry(data));
|
|
15
16
|
if (result.isFail()) {
|
|
16
17
|
if ("Cms/Entry/NotAuthorized" === result.error.code) return Result.fail(new FileNotAuthorizedError());
|
|
17
18
|
return Result.fail(new FilePersistenceError(result.error));
|
|
@@ -24,7 +25,7 @@ const CreateFileRepository_CreateFileRepository = CreateFileRepository.createImp
|
|
|
24
25
|
implementation: CreateFileRepositoryImpl,
|
|
25
26
|
dependencies: [
|
|
26
27
|
CreateEntryUseCase,
|
|
27
|
-
|
|
28
|
+
FileModelProvider
|
|
28
29
|
]
|
|
29
30
|
});
|
|
30
31
|
export { CreateFileRepository_CreateFileRepository as CreateFileRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/file/CreateFile/CreateFileRepository.js","sources":["../../../../src/features/file/CreateFile/CreateFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CreateFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { CreateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/CreateEntry\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/file/CreateFile/CreateFileRepository.js","sources":["../../../../src/features/file/CreateFile/CreateFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CreateFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { CreateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/CreateEntry\";\nimport { FileModelProvider } from \"~/domain/file/abstractions.js\";\nimport type { File, FileInput } from \"~/domain/file/types.js\";\nimport { EntryToFileMapper } from \"../shared/EntryToFileMapper.js\";\nimport { FileNotAuthorizedError, FilePersistenceError } from \"~/domain/file/errors.js\";\nimport { FileInputToEntryInputMapper } from \"~/features/file/shared/FileInputToEntryInputMapper.js\";\n\nclass CreateFileRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private createEntry: CreateEntryUseCase.Interface,\n private fileModelProvider: FileModelProvider.Interface\n ) {}\n\n async execute(data: FileInput): Promise<Result<File, RepositoryAbstraction.Error>> {\n const fileModel = await this.fileModelProvider.get();\n const result = await this.createEntry.execute(\n fileModel,\n FileInputToEntryInputMapper.toEntry(data)\n );\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotAuthorized\") {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n const file = EntryToFileMapper.toFile(result.value);\n return Result.ok(file);\n }\n}\n\nexport const CreateFileRepository = RepositoryAbstraction.createImplementation({\n implementation: CreateFileRepositoryImpl,\n dependencies: [CreateEntryUseCase, FileModelProvider]\n});\n"],"names":["CreateFileRepositoryImpl","createEntry","fileModelProvider","data","fileModel","result","FileInputToEntryInputMapper","Result","FileNotAuthorizedError","FilePersistenceError","file","EntryToFileMapper","CreateFileRepository","RepositoryAbstraction","CreateEntryUseCase","FileModelProvider"],"mappings":";;;;;;;AASA,MAAMA;IACF,YACYC,WAAyC,EACzCC,iBAA8C,CACxD;aAFUD,WAAW,GAAXA;aACAC,iBAAiB,GAAjBA;IACT;IAEH,MAAM,QAAQC,IAAe,EAAsD;QAC/E,MAAMC,YAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG;QAClD,MAAMC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CACzCD,WACAE,4BAA4B,OAAO,CAACH;QAGxC,IAAIE,OAAO,MAAM,IAAI;YACjB,IAAIA,AAAsB,8BAAtBA,OAAO,KAAK,CAAC,IAAI,EACjB,OAAOE,OAAO,IAAI,CAAC,IAAIC;YAG3B,OAAOD,OAAO,IAAI,CAAC,IAAIE,qBAAqBJ,OAAO,KAAK;QAC5D;QAEA,MAAMK,OAAOC,kBAAkB,MAAM,CAACN,OAAO,KAAK;QAClD,OAAOE,OAAO,EAAE,CAACG;IACrB;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAA0C,CAAC;IAC3E,gBAAgBb;IAChB,cAAc;QAACc;QAAoBC;KAAkB;AACzD"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry";
|
|
3
3
|
import { DeleteFileRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { File } from "../../../domain/file/types.js";
|
|
6
6
|
declare class DeleteFileRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
7
|
private deleteEntry;
|
|
8
|
-
private
|
|
9
|
-
constructor(deleteEntry: DeleteEntryUseCase.Interface,
|
|
8
|
+
private fileModelProvider;
|
|
9
|
+
constructor(deleteEntry: DeleteEntryUseCase.Interface, fileModelProvider: FileModelProvider.Interface);
|
|
10
10
|
delete(file: File): Promise<Result<void, RepositoryAbstraction.Error>>;
|
|
11
11
|
}
|
|
12
12
|
export declare const DeleteFileRepository: typeof DeleteFileRepositoryImpl & {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry";
|
|
3
3
|
import { DeleteFileRepository } from "./abstractions.js";
|
|
4
|
-
import {
|
|
4
|
+
import { FileModelProvider } from "../../../domain/file/abstractions.js";
|
|
5
5
|
import { FileNotFoundError, FilePersistenceError } from "../../../domain/file/errors.js";
|
|
6
6
|
class DeleteFileRepositoryImpl {
|
|
7
|
-
constructor(deleteEntry,
|
|
7
|
+
constructor(deleteEntry, fileModelProvider){
|
|
8
8
|
this.deleteEntry = deleteEntry;
|
|
9
|
-
this.
|
|
9
|
+
this.fileModelProvider = fileModelProvider;
|
|
10
10
|
}
|
|
11
11
|
async delete(file) {
|
|
12
12
|
const entryId = `${file.id}#0001`;
|
|
13
|
-
const
|
|
13
|
+
const fileModel = await this.fileModelProvider.get();
|
|
14
|
+
const result = await this.deleteEntry.execute(fileModel, entryId);
|
|
14
15
|
if (result.isFail()) {
|
|
15
16
|
const error = result.error;
|
|
16
17
|
if ("Cms/Entry/NotFound" === error.code) return Result.fail(new FileNotFoundError(file.id));
|
|
@@ -23,7 +24,7 @@ const DeleteFileRepository_DeleteFileRepository = DeleteFileRepository.createImp
|
|
|
23
24
|
implementation: DeleteFileRepositoryImpl,
|
|
24
25
|
dependencies: [
|
|
25
26
|
DeleteEntryUseCase,
|
|
26
|
-
|
|
27
|
+
FileModelProvider
|
|
27
28
|
]
|
|
28
29
|
});
|
|
29
30
|
export { DeleteFileRepository_DeleteFileRepository as DeleteFileRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/file/DeleteFile/DeleteFileRepository.js","sources":["../../../../src/features/file/DeleteFile/DeleteFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry\";\nimport { DeleteFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/file/DeleteFile/DeleteFileRepository.js","sources":["../../../../src/features/file/DeleteFile/DeleteFileRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry\";\nimport { DeleteFileRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { FileModelProvider } from \"~/domain/file/abstractions.js\";\nimport { FileNotFoundError, FilePersistenceError } from \"~/domain/file/errors.js\";\nimport { File } from \"~/domain/file/types.js\";\n\nclass DeleteFileRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private deleteEntry: DeleteEntryUseCase.Interface,\n private fileModelProvider: FileModelProvider.Interface\n ) {}\n\n async delete(file: File): Promise<Result<void, RepositoryAbstraction.Error>> {\n // Files are not versioned, so we're always deleting the same revision\n const entryId = `${file.id}#0001`;\n\n const fileModel = await this.fileModelProvider.get();\n const result = await this.deleteEntry.execute(fileModel, entryId);\n\n if (result.isFail()) {\n const error = result.error;\n if (error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new FileNotFoundError(file.id));\n }\n return Result.fail(new FilePersistenceError(result.error));\n }\n\n return Result.ok();\n }\n}\n\nexport const DeleteFileRepository = RepositoryAbstraction.createImplementation({\n implementation: DeleteFileRepositoryImpl,\n dependencies: [DeleteEntryUseCase, FileModelProvider]\n});\n"],"names":["DeleteFileRepositoryImpl","deleteEntry","fileModelProvider","file","entryId","fileModel","result","error","Result","FileNotFoundError","FilePersistenceError","DeleteFileRepository","RepositoryAbstraction","DeleteEntryUseCase","FileModelProvider"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,WAAyC,EACzCC,iBAA8C,CACxD;aAFUD,WAAW,GAAXA;aACAC,iBAAiB,GAAjBA;IACT;IAEH,MAAM,OAAOC,IAAU,EAAsD;QAEzE,MAAMC,UAAU,GAAGD,KAAK,EAAE,CAAC,KAAK,CAAC;QAEjC,MAAME,YAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG;QAClD,MAAMC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACD,WAAWD;QAEzD,IAAIE,OAAO,MAAM,IAAI;YACjB,MAAMC,QAAQD,OAAO,KAAK;YAC1B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAOC,OAAO,IAAI,CAAC,IAAIC,kBAAkBN,KAAK,EAAE;YAEpD,OAAOK,OAAO,IAAI,CAAC,IAAIE,qBAAqBJ,OAAO,KAAK;QAC5D;QAEA,OAAOE,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMG,4CAAuBC,qBAAAA,oBAA0C,CAAC;IAC3E,gBAAgBZ;IAChB,cAAc;QAACa;QAAoBC;KAAkB;AACzD"}
|