@webiny/api-file-manager 6.4.12-beta.5 → 6.4.12-beta.7

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.
@@ -4,6 +4,10 @@ export declare class SettingsNotFoundError extends BaseError {
4
4
  readonly code: "FileManager/Settings/NotFoundError";
5
5
  constructor();
6
6
  }
7
+ export declare class SettingsNotAuthorizedError extends BaseError {
8
+ readonly code: "FileManager/Settings/NotAuthorizedError";
9
+ constructor();
10
+ }
7
11
  export declare class SettingsUpdateError extends BaseError {
8
12
  readonly code: "FileManager/Settings/UpdateError";
9
13
  constructor(error: Error);
@@ -6,6 +6,13 @@ class SettingsNotFoundError extends BaseError {
6
6
  }), this.code = "FileManager/Settings/NotFoundError";
7
7
  }
8
8
  }
9
+ class SettingsNotAuthorizedError extends BaseError {
10
+ constructor(){
11
+ super({
12
+ message: "Not authorized."
13
+ }), this.code = "FileManager/Settings/NotAuthorizedError";
14
+ }
15
+ }
9
16
  class SettingsUpdateError extends BaseError {
10
17
  constructor(error){
11
18
  super({
@@ -23,6 +30,6 @@ class SettingsValidationError extends BaseError {
23
30
  }), this.code = "FileManager/Settings/ValidationError";
24
31
  }
25
32
  }
26
- export { SettingsNotFoundError, SettingsUpdateError, SettingsValidationError };
33
+ export { SettingsNotAuthorizedError, SettingsNotFoundError, SettingsUpdateError, SettingsValidationError };
27
34
 
28
35
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain/settings/errors.js","sources":["../../../src/domain/settings/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { OutputErrors } from \"@webiny/utils/createZodError.js\";\n\nexport class SettingsNotFoundError extends BaseError {\n override readonly code = \"FileManager/Settings/NotFoundError\" as const;\n\n constructor() {\n super({\n message: \"File manager settings not found.\"\n });\n }\n}\n\nexport class SettingsUpdateError extends BaseError {\n override readonly code = \"FileManager/Settings/UpdateError\" as const;\n\n constructor(error: Error) {\n super({\n message: `Error updating settings: ${error.message}`\n });\n }\n}\n\ninterface ValidationParams {\n invalidFields: OutputErrors;\n}\n\nexport class SettingsValidationError extends BaseError<ValidationParams> {\n override readonly code = \"FileManager/Settings/ValidationError\" as const;\n\n constructor(invalidFields: OutputErrors) {\n super({\n message: \"Validation failed.\",\n data: { invalidFields }\n });\n }\n}\n"],"names":["SettingsNotFoundError","BaseError","SettingsUpdateError","error","SettingsValidationError","invalidFields"],"mappings":";AAGO,MAAMA,8BAA8BC;IAGvC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,4BAA4BD;IAGrC,YAAYE,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAAS,CAAC,yBAAyB,EAAEA,MAAM,OAAO,EAAE;QACxD,SALc,IAAI,GAAG;IAMzB;AACJ;AAMO,MAAMC,gCAAgCH;IAGzC,YAAYI,aAA2B,CAAE;QACrC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBAAEA;YAAc;QAC1B,SANc,IAAI,GAAG;IAOzB;AACJ"}
1
+ {"version":3,"file":"domain/settings/errors.js","sources":["../../../src/domain/settings/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { OutputErrors } from \"@webiny/utils/createZodError.js\";\n\nexport class SettingsNotFoundError extends BaseError {\n override readonly code = \"FileManager/Settings/NotFoundError\" as const;\n\n constructor() {\n super({\n message: \"File manager settings not found.\"\n });\n }\n}\n\nexport class SettingsNotAuthorizedError extends BaseError {\n override readonly code = \"FileManager/Settings/NotAuthorizedError\" as const;\n\n constructor() {\n super({\n message: \"Not authorized.\"\n });\n }\n}\n\nexport class SettingsUpdateError extends BaseError {\n override readonly code = \"FileManager/Settings/UpdateError\" as const;\n\n constructor(error: Error) {\n super({\n message: `Error updating settings: ${error.message}`\n });\n }\n}\n\ninterface ValidationParams {\n invalidFields: OutputErrors;\n}\n\nexport class SettingsValidationError extends BaseError<ValidationParams> {\n override readonly code = \"FileManager/Settings/ValidationError\" as const;\n\n constructor(invalidFields: OutputErrors) {\n super({\n message: \"Validation failed.\",\n data: { invalidFields }\n });\n }\n}\n"],"names":["SettingsNotFoundError","BaseError","SettingsNotAuthorizedError","SettingsUpdateError","error","SettingsValidationError","invalidFields"],"mappings":";AAGO,MAAMA,8BAA8BC;IAGvC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,mCAAmCD;IAG5C,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAME,4BAA4BF;IAGrC,YAAYG,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAAS,CAAC,yBAAyB,EAAEA,MAAM,OAAO,EAAE;QACxD,SALc,IAAI,GAAG;IAMzB;AACJ;AAMO,MAAMC,gCAAgCJ;IAGzC,YAAYK,aAA2B,CAAE;QACrC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBAAEA;YAAc;QAC1B,SANc,IAAI,GAAG;IAOzB;AACJ"}
@@ -2,5 +2,13 @@ import zod from "zod";
2
2
  export declare const updateSettingsValidation: zod.ZodObject<{
3
3
  uploadMinFileSize: zod.ZodOptional<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>, zod.ZodTransform<number, number | null | undefined>>>;
4
4
  uploadMaxFileSize: zod.ZodOptional<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>, zod.ZodTransform<number, number | null | undefined>>>;
5
- srcPrefix: zod.ZodPipe<zod.ZodOptional<zod.ZodString>, zod.ZodTransform<string, string | undefined>>;
5
+ srcPrefix: zod.ZodOptional<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>;
6
+ }, zod.core.$strip>;
7
+ /**
8
+ * Validates the settings after the input has been merged with the stored settings,
9
+ * so rules that span fields also hold for partial updates.
10
+ */
11
+ export declare const mergedSettingsValidation: zod.ZodObject<{
12
+ uploadMinFileSize: zod.ZodNumber;
13
+ uploadMaxFileSize: zod.ZodNumber;
6
14
  }, zod.core.$strip>;
@@ -4,24 +4,46 @@ const MIN_FILE_SIZE = 0;
4
4
  const MAX_FILE_SIZE = 10737418240;
5
5
  const uploadMinFileSizeValidation = zod.number().min(MIN_FILE_SIZE, {
6
6
  message: `Value needs to be greater than or equal to ${MIN_FILE_SIZE}.`
7
+ }).max(MAX_FILE_SIZE, {
8
+ message: `Value needs to be lesser than or equal to ${MAX_FILE_SIZE}.`
7
9
  }).nullish().transform((value)=>value || MIN_FILE_SIZE).optional();
8
10
  const uploadMaxFileSizeValidation = zod.number().max(MAX_FILE_SIZE, {
9
11
  message: `Value needs to be lesser than or equal to ${MAX_FILE_SIZE}.`
10
12
  }).nullish().transform((value)=>value || MAX_FILE_SIZE).optional();
13
+ const isHttpUrl = (value)=>{
14
+ try {
15
+ const url = new URL(value);
16
+ return "https:" === url.protocol || "http:" === url.protocol;
17
+ } catch {
18
+ return false;
19
+ }
20
+ };
21
+ const withTrailingSlash = (value)=>value.endsWith("/") ? value : value + "/";
22
+ const srcPrefixValidation = zod.string().refine((value)=>!value || isHttpUrl(value), {
23
+ message: "Value needs to be an absolute http(s) URL."
24
+ }).transform(async (value)=>{
25
+ if (!value) {
26
+ const manifest = await ServiceDiscovery.load();
27
+ const domain = manifest?.api?.cloudfront?.domain;
28
+ if (!domain) return "";
29
+ return withTrailingSlash(`${domain}/files`);
30
+ }
31
+ return withTrailingSlash(value);
32
+ }).optional();
11
33
  const updateSettingsValidation = zod.object({
12
34
  uploadMinFileSize: uploadMinFileSizeValidation,
13
35
  uploadMaxFileSize: uploadMaxFileSizeValidation,
14
- srcPrefix: zod.string().optional().transform(async (value)=>{
15
- if (!value) {
16
- const manifest = await ServiceDiscovery.load();
17
- if (!manifest || !manifest.api) return "";
18
- const { domain } = manifest.api.cloudfront;
19
- return `https://${domain}/files/`;
20
- }
21
- if ("string" == typeof value) return value.endsWith("/") ? value : value + "/";
22
- return value;
23
- })
36
+ srcPrefix: srcPrefixValidation
37
+ });
38
+ const mergedSettingsValidation = zod.object({
39
+ uploadMinFileSize: zod.number(),
40
+ uploadMaxFileSize: zod.number()
41
+ }).refine((settings)=>settings.uploadMinFileSize <= settings.uploadMaxFileSize, {
42
+ path: [
43
+ "uploadMinFileSize"
44
+ ],
45
+ message: "Value needs to be lesser than or equal to the maximum file upload size."
24
46
  });
25
- export { updateSettingsValidation };
47
+ export { mergedSettingsValidation, updateSettingsValidation };
26
48
 
27
49
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain/settings/validation.js","sources":["../../../src/domain/settings/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { ServiceDiscovery } from \"@webiny/api\";\n\nconst MIN_FILE_SIZE = 0;\nconst MAX_FILE_SIZE = 10737418240;\n\nconst uploadMinFileSizeValidation = zod\n .number()\n .min(MIN_FILE_SIZE, {\n message: `Value needs to be greater than or equal to ${MIN_FILE_SIZE}.`\n })\n .nullish()\n .transform(value => {\n return value || MIN_FILE_SIZE;\n })\n .optional();\n\nconst uploadMaxFileSizeValidation = zod\n .number()\n .max(MAX_FILE_SIZE, {\n message: `Value needs to be lesser than or equal to ${MAX_FILE_SIZE}.`\n })\n .nullish()\n .transform(value => {\n return value || MAX_FILE_SIZE;\n })\n .optional();\n\nexport const updateSettingsValidation = zod.object({\n uploadMinFileSize: uploadMinFileSizeValidation,\n uploadMaxFileSize: uploadMaxFileSizeValidation,\n srcPrefix: zod\n .string()\n .optional()\n .transform(async value => {\n if (!value) {\n const manifest = await ServiceDiscovery.load();\n if (!manifest || !manifest.api) {\n return \"\";\n }\n\n const { domain } = manifest.api.cloudfront;\n\n return `https://${domain}/files/`;\n }\n if (typeof value === \"string\") {\n return value.endsWith(\"/\") ? value : value + \"/\";\n }\n return value;\n })\n});\n"],"names":["MIN_FILE_SIZE","MAX_FILE_SIZE","uploadMinFileSizeValidation","zod","value","uploadMaxFileSizeValidation","updateSettingsValidation","manifest","ServiceDiscovery","domain"],"mappings":";;AAGA,MAAMA,gBAAgB;AACtB,MAAMC,gBAAgB;AAEtB,MAAMC,8BAA8BC,IAAAA,MACzB,GACN,GAAG,CAACH,eAAe;IAChB,SAAS,CAAC,2CAA2C,EAAEA,cAAc,CAAC,CAAC;AAC3E,GACC,OAAO,GACP,SAAS,CAACI,CAAAA,QACAA,SAASJ,eAEnB,QAAQ;AAEb,MAAMK,8BAA8BF,IAAAA,MACzB,GACN,GAAG,CAACF,eAAe;IAChB,SAAS,CAAC,0CAA0C,EAAEA,cAAc,CAAC,CAAC;AAC1E,GACC,OAAO,GACP,SAAS,CAACG,CAAAA,QACAA,SAASH,eAEnB,QAAQ;AAEN,MAAMK,2BAA2BH,IAAI,MAAM,CAAC;IAC/C,mBAAmBD;IACnB,mBAAmBG;IACnB,WAAWF,IAAAA,MACA,GACN,QAAQ,GACR,SAAS,CAAC,OAAMC;QACb,IAAI,CAACA,OAAO;YACR,MAAMG,WAAW,MAAMC,iBAAiB,IAAI;YAC5C,IAAI,CAACD,YAAY,CAACA,SAAS,GAAG,EAC1B,OAAO;YAGX,MAAM,EAAEE,MAAM,EAAE,GAAGF,SAAS,GAAG,CAAC,UAAU;YAE1C,OAAO,CAAC,QAAQ,EAAEE,OAAO,OAAO,CAAC;QACrC;QACA,IAAI,AAAiB,YAAjB,OAAOL,OACP,OAAOA,MAAM,QAAQ,CAAC,OAAOA,QAAQA,QAAQ;QAEjD,OAAOA;IACX;AACR"}
1
+ {"version":3,"file":"domain/settings/validation.js","sources":["../../../src/domain/settings/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { ServiceDiscovery } from \"@webiny/api\";\n\nconst MIN_FILE_SIZE = 0;\nconst MAX_FILE_SIZE = 10737418240;\n\nconst uploadMinFileSizeValidation = zod\n .number()\n .min(MIN_FILE_SIZE, {\n message: `Value needs to be greater than or equal to ${MIN_FILE_SIZE}.`\n })\n .max(MAX_FILE_SIZE, {\n message: `Value needs to be lesser than or equal to ${MAX_FILE_SIZE}.`\n })\n .nullish()\n .transform(value => {\n return value || MIN_FILE_SIZE;\n })\n .optional();\n\nconst uploadMaxFileSizeValidation = zod\n .number()\n .max(MAX_FILE_SIZE, {\n message: `Value needs to be lesser than or equal to ${MAX_FILE_SIZE}.`\n })\n .nullish()\n .transform(value => {\n return value || MAX_FILE_SIZE;\n })\n .optional();\n\nconst isHttpUrl = (value: string): boolean => {\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" || url.protocol === \"http:\";\n } catch {\n return false;\n }\n};\n\nconst withTrailingSlash = (value: string): string => {\n return value.endsWith(\"/\") ? value : value + \"/\";\n};\n\n/**\n * `optional()` wraps the transform, so a missing `srcPrefix` stays missing\n * and a partial update keeps the stored value. An empty string falls back to the API's URL.\n */\nconst srcPrefixValidation = zod\n .string()\n .refine(value => !value || isHttpUrl(value), {\n message: \"Value needs to be an absolute http(s) URL.\"\n })\n .transform(async value => {\n if (!value) {\n const manifest = await ServiceDiscovery.load();\n const domain = manifest?.api?.cloudfront?.domain;\n if (!domain) {\n return \"\";\n }\n // The manifest domain already includes the protocol.\n return withTrailingSlash(`${domain}/files`);\n }\n return withTrailingSlash(value);\n })\n .optional();\n\nexport const updateSettingsValidation = zod.object({\n uploadMinFileSize: uploadMinFileSizeValidation,\n uploadMaxFileSize: uploadMaxFileSizeValidation,\n srcPrefix: srcPrefixValidation\n});\n\n/**\n * Validates the settings after the input has been merged with the stored settings,\n * so rules that span fields also hold for partial updates.\n */\nexport const mergedSettingsValidation = zod\n .object({\n uploadMinFileSize: zod.number(),\n uploadMaxFileSize: zod.number()\n })\n .refine(settings => settings.uploadMinFileSize <= settings.uploadMaxFileSize, {\n path: [\"uploadMinFileSize\"],\n message: \"Value needs to be lesser than or equal to the maximum file upload size.\"\n });\n"],"names":["MIN_FILE_SIZE","MAX_FILE_SIZE","uploadMinFileSizeValidation","zod","value","uploadMaxFileSizeValidation","isHttpUrl","url","URL","withTrailingSlash","srcPrefixValidation","manifest","ServiceDiscovery","domain","updateSettingsValidation","mergedSettingsValidation","settings"],"mappings":";;AAGA,MAAMA,gBAAgB;AACtB,MAAMC,gBAAgB;AAEtB,MAAMC,8BAA8BC,IAAAA,MACzB,GACN,GAAG,CAACH,eAAe;IAChB,SAAS,CAAC,2CAA2C,EAAEA,cAAc,CAAC,CAAC;AAC3E,GACC,GAAG,CAACC,eAAe;IAChB,SAAS,CAAC,0CAA0C,EAAEA,cAAc,CAAC,CAAC;AAC1E,GACC,OAAO,GACP,SAAS,CAACG,CAAAA,QACAA,SAASJ,eAEnB,QAAQ;AAEb,MAAMK,8BAA8BF,IAAAA,MACzB,GACN,GAAG,CAACF,eAAe;IAChB,SAAS,CAAC,0CAA0C,EAAEA,cAAc,CAAC,CAAC;AAC1E,GACC,OAAO,GACP,SAAS,CAACG,CAAAA,QACAA,SAASH,eAEnB,QAAQ;AAEb,MAAMK,YAAY,CAACF;IACf,IAAI;QACA,MAAMG,MAAM,IAAIC,IAAIJ;QACpB,OAAOG,AAAiB,aAAjBA,IAAI,QAAQ,IAAiBA,AAAiB,YAAjBA,IAAI,QAAQ;IACpD,EAAE,OAAM;QACJ,OAAO;IACX;AACJ;AAEA,MAAME,oBAAoB,CAACL,QAChBA,MAAM,QAAQ,CAAC,OAAOA,QAAQA,QAAQ;AAOjD,MAAMM,sBAAsBP,IAAAA,MACjB,GACN,MAAM,CAACC,CAAAA,QAAS,CAACA,SAASE,UAAUF,QAAQ;IACzC,SAAS;AACb,GACC,SAAS,CAAC,OAAMA;IACb,IAAI,CAACA,OAAO;QACR,MAAMO,WAAW,MAAMC,iBAAiB,IAAI;QAC5C,MAAMC,SAASF,UAAU,KAAK,YAAY;QAC1C,IAAI,CAACE,QACD,OAAO;QAGX,OAAOJ,kBAAkB,GAAGI,OAAO,MAAM,CAAC;IAC9C;IACA,OAAOJ,kBAAkBL;AAC7B,GACC,QAAQ;AAEN,MAAMU,2BAA2BX,IAAI,MAAM,CAAC;IAC/C,mBAAmBD;IACnB,mBAAmBG;IACnB,WAAWK;AACf;AAMO,MAAMK,2BAA2BZ,IAAAA,MAC7B,CAAC;IACJ,mBAAmBA,IAAI,MAAM;IAC7B,mBAAmBA,IAAI,MAAM;AACjC,GACC,MAAM,CAACa,CAAAA,WAAYA,SAAS,iBAAiB,IAAIA,SAAS,iBAAiB,EAAE;IAC1E,MAAM;QAAC;KAAoB;IAC3B,SAAS;AACb"}
@@ -1,10 +1,18 @@
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 { FmPermissions } from "../../../features/shared/abstractions.js";
3
4
  import { type IAssetAuthorizer } from "../abstractions.js";
5
+ /**
6
+ * Private files can only be read by identities with File Manager read access in the file's
7
+ * tenant. Being logged in is not enough: API keys (e.g. the public website key) and identities
8
+ * from other tenants are authenticated too.
9
+ */
4
10
  export declare class PrivateAuthenticatedAuthorizer implements IAssetAuthorizer {
5
11
  private identityContext;
6
- constructor(identityContext: IdentityContext.Interface);
12
+ private permissions;
13
+ constructor(identityContext: IdentityContext.Interface, permissions: FmPermissions.Interface);
7
14
  authorize(file: File): Promise<void>;
15
+ private notAuthorized;
8
16
  }
9
17
  export declare const PrivateAuthenticatedAuthorizerImpl: typeof PrivateAuthenticatedAuthorizer & {
10
18
  __abstraction: import("@webiny/di").Abstraction<IAssetAuthorizer>;
@@ -1,24 +1,29 @@
1
1
  import error from "@webiny/error";
2
2
  import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
3
+ import { FmPermissions } from "../../shared/abstractions.js";
3
4
  import { AssetAuthorizer } from "../abstractions.js";
4
5
  class PrivateAuthenticatedAuthorizer {
5
- constructor(identityContext){
6
+ constructor(identityContext, permissions){
6
7
  this.identityContext = identityContext;
8
+ this.permissions = permissions;
7
9
  }
8
10
  async authorize(file) {
9
- if (file.accessControl && "private-authenticated" === file.accessControl.type) {
10
- const identity = this.identityContext.getIdentity();
11
- if (!identity) throw new error({
12
- code: "NOT_AUTHORIZED",
13
- message: "You're not authorized to access this asset!"
14
- });
15
- }
11
+ if (file.accessControl?.type !== "private-authenticated") return;
12
+ if (this.identityContext.getIdentity().isAnonymous()) throw this.notAuthorized();
13
+ if (!await this.permissions.canRead("file")) throw this.notAuthorized();
14
+ }
15
+ notAuthorized() {
16
+ return new error({
17
+ code: "NOT_AUTHORIZED",
18
+ message: "You're not authorized to access this asset!"
19
+ });
16
20
  }
17
21
  }
18
22
  const PrivateAuthenticatedAuthorizerImpl = AssetAuthorizer.createImplementation({
19
23
  implementation: PrivateAuthenticatedAuthorizer,
20
24
  dependencies: [
21
- IdentityContext
25
+ IdentityContext,
26
+ FmPermissions
22
27
  ]
23
28
  });
24
29
  export { PrivateAuthenticatedAuthorizer, PrivateAuthenticatedAuthorizerImpl };
@@ -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 { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { AssetAuthorizer, type IAssetAuthorizer } from \"../abstractions.js\";\n\n/**\n * Private files can only be read by identities with File Manager read access in the file's\n * tenant. Being logged in is not enough: API keys (e.g. the public website key) and identities\n * from other tenants are authenticated too.\n */\nexport class PrivateAuthenticatedAuthorizer implements IAssetAuthorizer {\n private identityContext: IdentityContext.Interface;\n private permissions: FmPermissions.Interface;\n\n constructor(identityContext: IdentityContext.Interface, permissions: FmPermissions.Interface) {\n this.identityContext = identityContext;\n this.permissions = permissions;\n }\n\n async authorize(file: File) {\n if (file.accessControl?.type !== \"private-authenticated\") {\n return;\n }\n\n if (this.identityContext.getIdentity().isAnonymous()) {\n throw this.notAuthorized();\n }\n\n if (!(await this.permissions.canRead(\"file\"))) {\n throw this.notAuthorized();\n }\n }\n\n private notAuthorized() {\n return new Error({\n code: \"NOT_AUTHORIZED\",\n message: \"You're not authorized to access this asset!\"\n });\n }\n}\n\nexport const PrivateAuthenticatedAuthorizerImpl = AssetAuthorizer.createImplementation({\n implementation: PrivateAuthenticatedAuthorizer,\n dependencies: [IdentityContext, FmPermissions]\n});\n"],"names":["PrivateAuthenticatedAuthorizer","identityContext","permissions","file","Error","PrivateAuthenticatedAuthorizerImpl","AssetAuthorizer","IdentityContext","FmPermissions"],"mappings":";;;;AAWO,MAAMA;IAIT,YAAYC,eAA0C,EAAEC,WAAoC,CAAE;QAC1F,IAAI,CAAC,eAAe,GAAGD;QACvB,IAAI,CAAC,WAAW,GAAGC;IACvB;IAEA,MAAM,UAAUC,IAAU,EAAE;QACxB,IAAIA,KAAK,aAAa,EAAE,SAAS,yBAC7B;QAGJ,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,WAAW,IAC9C,MAAM,IAAI,CAAC,aAAa;QAG5B,IAAI,CAAE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,SACjC,MAAM,IAAI,CAAC,aAAa;IAEhC;IAEQ,gBAAgB;QACpB,OAAO,IAAIC,MAAM;YACb,MAAM;YACN,SAAS;QACb;IACJ;AACJ;AAEO,MAAMC,qCAAqCC,gBAAgB,oBAAoB,CAAC;IACnF,gBAAgBN;IAChB,cAAc;QAACO;QAAiBC;KAAc;AAClD"}
@@ -22,6 +22,7 @@ class CreateFileUseCaseImpl {
22
22
  if (validationResult.isFail()) return Result.fail(validationResult.error);
23
23
  const [id] = input.key.split("/");
24
24
  const currentIdentity = this.identityContext.getIdentity();
25
+ const systemInput = !this.identityContext.isAuthorizationEnabled() || await this.identityContext.hasFullAccess() ? input : {};
25
26
  const fileInput = {
26
27
  id: input.id || id,
27
28
  key: input.key,
@@ -35,12 +36,12 @@ class CreateFileUseCaseImpl {
35
36
  tags: input.tags || [],
36
37
  description: input.description ?? "",
37
38
  extensions: meta || {},
38
- createdOn: input.createdOn,
39
- modifiedOn: input.modifiedOn,
40
- savedOn: input.savedOn,
41
- createdBy: input.createdBy ? Identity.from(input.createdBy) : Identity.from(currentIdentity),
42
- modifiedBy: input.modifiedBy ? Identity.from(input.modifiedBy) : void 0,
43
- savedBy: input.savedBy ? Identity.from(input.savedBy) : Identity.from(currentIdentity)
39
+ createdOn: systemInput.createdOn,
40
+ modifiedOn: systemInput.modifiedOn,
41
+ savedOn: systemInput.savedOn,
42
+ createdBy: systemInput.createdBy ? Identity.from(systemInput.createdBy) : Identity.from(currentIdentity),
43
+ modifiedBy: systemInput.modifiedBy ? Identity.from(systemInput.modifiedBy) : void 0,
44
+ savedBy: systemInput.savedBy ? Identity.from(systemInput.savedBy) : Identity.from(currentIdentity)
44
45
  };
45
46
  await this.eventPublisher.publish(new FileBeforeCreateEvent({
46
47
  file: fileInput,
@@ -1 +1 @@
1
- {"version":3,"file":"features/file/CreateFile/CreateFileUseCase.js","sources":["../../../../src/features/file/CreateFile/CreateFileUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n CreateFileUseCase as UseCaseAbstraction,\n CreateFileInput,\n CreateFileRepository\n} from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"../../settings/GetSettings/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File, FileInput } from \"~/domain/file/types.js\";\nimport { FileNotAuthorizedError, InvalidFileSizeError } from \"~/domain/file/errors.js\";\nimport { FileBeforeCreateEvent, FileAfterCreateEvent } from \"./events.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { Identity } from \"~/domain/identity/Identity.js\";\n\nclass CreateFileUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private permissions: FmPermissions.Interface,\n private repository: CreateFileRepository.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(\n input: CreateFileInput,\n meta?: Record<string, any>\n ): Promise<Result<File, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canCreate(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const validationResult = await this.validateInput(input);\n if (validationResult.isFail()) {\n return Result.fail(validationResult.error);\n }\n\n const [id] = input.key.split(\"/\");\n const currentIdentity = this.identityContext.getIdentity();\n\n // Prepare file input\n const fileInput: FileInput = {\n id: input.id || id,\n key: input.key,\n name: input.name,\n size: input.size,\n type: input.type,\n metadata: input.metadata || {},\n location: input.location || { folderId: \"root\" },\n tags: input.tags || [],\n description: input.description ?? \"\",\n extensions: meta || {},\n // system attributes\n createdOn: input.createdOn,\n modifiedOn: input.modifiedOn,\n savedOn: input.savedOn,\n createdBy: input.createdBy\n ? Identity.from(input.createdBy)\n : Identity.from(currentIdentity),\n modifiedBy: input.modifiedBy ? Identity.from(input.modifiedBy) : undefined,\n savedBy: input.savedBy ? Identity.from(input.savedBy) : Identity.from(currentIdentity)\n };\n\n await this.eventPublisher.publish(new FileBeforeCreateEvent({ file: fileInput, meta }));\n\n const result = await this.repository.execute(fileInput);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(new FileAfterCreateEvent({ file: result.value, meta }));\n\n return Result.ok(result.value);\n }\n\n private async validateInput(\n input: CreateFileInput\n ): Promise<Result<void, InvalidFileSizeError>> {\n const settingsResult = await this.getSettings.execute();\n\n if (settingsResult.isFail()) {\n return Result.ok();\n }\n\n const settings = settingsResult.value;\n\n if (settings) {\n // Validate file size\n if (\n input.size < settings.uploadMinFileSize ||\n input.size > settings.uploadMaxFileSize\n ) {\n return Result.fail(\n new InvalidFileSizeError({\n size: input.size,\n minSize: settings.uploadMinFileSize,\n maxSize: settings.uploadMaxFileSize\n })\n );\n }\n }\n\n return Result.ok();\n }\n}\n\nexport const CreateFileUseCase = UseCaseAbstraction.createImplementation({\n implementation: CreateFileUseCaseImpl,\n dependencies: [\n IdentityContext,\n FmPermissions,\n CreateFileRepository,\n GetSettingsUseCase,\n EventPublisher\n ]\n});\n"],"names":["CreateFileUseCaseImpl","identityContext","permissions","repository","getSettings","eventPublisher","input","meta","hasPermission","Result","FileNotAuthorizedError","validationResult","id","currentIdentity","fileInput","Identity","undefined","FileBeforeCreateEvent","result","FileAfterCreateEvent","settingsResult","settings","InvalidFileSizeError","CreateFileUseCase","UseCaseAbstraction","IdentityContext","FmPermissions","CreateFileRepository","GetSettingsUseCase","EventPublisher"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,WAAoC,EACpCC,UAA0C,EAC1CC,WAAyC,EACzCC,cAAwC,CAClD;aALUJ,eAAe,GAAfA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAAsB,EACtBC,IAA0B,EACqB;QAC/C,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;QACvD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,mBAAmB,MAAM,IAAI,CAAC,aAAa,CAACL;QAClD,IAAIK,iBAAiB,MAAM,IACvB,OAAOF,OAAO,IAAI,CAACE,iBAAiB,KAAK;QAG7C,MAAM,CAACC,GAAG,GAAGN,MAAM,GAAG,CAAC,KAAK,CAAC;QAC7B,MAAMO,kBAAkB,IAAI,CAAC,eAAe,CAAC,WAAW;QAGxD,MAAMC,YAAuB;YACzB,IAAIR,MAAM,EAAE,IAAIM;YAChB,KAAKN,MAAM,GAAG;YACd,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChB,UAAUA,MAAM,QAAQ,IAAI,CAAC;YAC7B,UAAUA,MAAM,QAAQ,IAAI;gBAAE,UAAU;YAAO;YAC/C,MAAMA,MAAM,IAAI,IAAI,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AEO,MAAMc,sCAAoBC,kBAAAA,oBAAuC,CAAC;IACrE,gBAAgBxB;IAChB,cAAc;QACVyB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"features/file/CreateFile/CreateFileUseCase.js","sources":["../../../../src/features/file/CreateFile/CreateFileUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n CreateFileUseCase as UseCaseAbstraction,\n CreateFileInput,\n CreateFileRepository\n} from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"../../settings/GetSettings/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File, FileInput } from \"~/domain/file/types.js\";\nimport { FileNotAuthorizedError, InvalidFileSizeError } from \"~/domain/file/errors.js\";\nimport { FileBeforeCreateEvent, FileAfterCreateEvent } from \"./events.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { Identity } from \"~/domain/identity/Identity.js\";\n\nclass CreateFileUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private permissions: FmPermissions.Interface,\n private repository: CreateFileRepository.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(\n input: CreateFileInput,\n meta?: Record<string, any>\n ): Promise<Result<File, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canCreate(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const validationResult = await this.validateInput(input);\n if (validationResult.isFail()) {\n return Result.fail(validationResult.error);\n }\n\n const [id] = input.key.split(\"/\");\n const currentIdentity = this.identityContext.getIdentity();\n\n // Attribution and dates come from the server. Only full access, or code running without\n // authorization (imports, migrations), may set them.\n const systemInput: Partial<CreateFileInput> =\n !this.identityContext.isAuthorizationEnabled() ||\n (await this.identityContext.hasFullAccess())\n ? input\n : {};\n\n // Prepare file input\n const fileInput: FileInput = {\n id: input.id || id,\n key: input.key,\n name: input.name,\n size: input.size,\n type: input.type,\n metadata: input.metadata || {},\n location: input.location || { folderId: \"root\" },\n tags: input.tags || [],\n description: input.description ?? \"\",\n extensions: meta || {},\n // system attributes\n createdOn: systemInput.createdOn,\n modifiedOn: systemInput.modifiedOn,\n savedOn: systemInput.savedOn,\n createdBy: systemInput.createdBy\n ? Identity.from(systemInput.createdBy)\n : Identity.from(currentIdentity),\n modifiedBy: systemInput.modifiedBy ? Identity.from(systemInput.modifiedBy) : undefined,\n savedBy: systemInput.savedBy\n ? Identity.from(systemInput.savedBy)\n : Identity.from(currentIdentity)\n };\n\n await this.eventPublisher.publish(new FileBeforeCreateEvent({ file: fileInput, meta }));\n\n const result = await this.repository.execute(fileInput);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(new FileAfterCreateEvent({ file: result.value, meta }));\n\n return Result.ok(result.value);\n }\n\n private async validateInput(\n input: CreateFileInput\n ): Promise<Result<void, InvalidFileSizeError>> {\n const settingsResult = await this.getSettings.execute();\n\n if (settingsResult.isFail()) {\n return Result.ok();\n }\n\n const settings = settingsResult.value;\n\n if (settings) {\n // Validate file size\n if (\n input.size < settings.uploadMinFileSize ||\n input.size > settings.uploadMaxFileSize\n ) {\n return Result.fail(\n new InvalidFileSizeError({\n size: input.size,\n minSize: settings.uploadMinFileSize,\n maxSize: settings.uploadMaxFileSize\n })\n );\n }\n }\n\n return Result.ok();\n }\n}\n\nexport const CreateFileUseCase = UseCaseAbstraction.createImplementation({\n implementation: CreateFileUseCaseImpl,\n dependencies: [\n IdentityContext,\n FmPermissions,\n CreateFileRepository,\n GetSettingsUseCase,\n EventPublisher\n ]\n});\n"],"names":["CreateFileUseCaseImpl","identityContext","permissions","repository","getSettings","eventPublisher","input","meta","hasPermission","Result","FileNotAuthorizedError","validationResult","id","currentIdentity","systemInput","fileInput","Identity","undefined","FileBeforeCreateEvent","result","FileAfterCreateEvent","settingsResult","settings","InvalidFileSizeError","CreateFileUseCase","UseCaseAbstraction","IdentityContext","FmPermissions","CreateFileRepository","GetSettingsUseCase","EventPublisher"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,WAAoC,EACpCC,UAA0C,EAC1CC,WAAyC,EACzCC,cAAwC,CAClD;aALUJ,eAAe,GAAfA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAAsB,EACtBC,IAA0B,EACqB;QAC/C,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;QACvD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,mBAAmB,MAAM,IAAI,CAAC,aAAa,CAACL;QAClD,IAAIK,iBAAiB,MAAM,IACvB,OAAOF,OAAO,IAAI,CAACE,iBAAiB,KAAK;QAG7C,MAAM,CAACC,GAAG,GAAGN,MAAM,GAAG,CAAC,KAAK,CAAC;QAC7B,MAAMO,kBAAkB,IAAI,CAAC,eAAe,CAAC,WAAW;QAIxD,MAAMC,cACF,CAAC,IAAI,CAAC,eAAe,CAAC,sBAAsB,MAC3C,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,KACnCR,QACA,CAAC;QAGX,MAAMS,YAAuB;YACzB,IAAIT,MAAM,EAAE,IAAIM;YAChB,KAAKN,MAAM,GAAG;YACd,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChB,UAAUA,MAAM,QAAQ,IAAI,CAAC;YAC7B,UAAUA,MAAM,QAAQ,IAAI;gBAAE,UAAU;YAAO;YAC/C,MAAMA,MAAM,IAAI,IAAI,EAAE;YACtB,aAAaA,MAAM,WAAW,IAAI;YAClC,YAAYC,QAAQ,CAAC;YAErB,WAAWO,YAAY,SAAS;YAChC,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;QACAC;QACAC;KACH;AACL"}
@@ -24,6 +24,7 @@ class UpdateFileUseCaseImpl {
24
24
  const canEditFile = await this.permissions.canEdit("file", original);
25
25
  if (!canEditFile) return Result.fail(new FileNotAuthorizedError());
26
26
  const currentIdentity = this.identityContext.getIdentity();
27
+ const systemInput = !this.identityContext.isAuthorizationEnabled() || await this.identityContext.hasFullAccess() ? input : {};
27
28
  const file = {
28
29
  ...original,
29
30
  ...input,
@@ -34,12 +35,12 @@ class UpdateFileUseCaseImpl {
34
35
  tags: void 0 !== input.tags ? input.tags : original.tags,
35
36
  description: void 0 !== input.description ? input.description : original.description,
36
37
  location: void 0 !== input.location ? input.location : original.location,
37
- createdOn: input.createdOn ?? original.createdOn,
38
- modifiedOn: input.modifiedOn ?? void 0,
39
- savedOn: input.savedOn ?? original.savedOn,
40
- createdBy: input.createdBy ? Identity.from(input.createdBy) : original.createdBy,
41
- modifiedBy: input.modifiedBy ? Identity.from(input.modifiedBy) : Identity.from(currentIdentity),
42
- savedBy: input.savedBy ? Identity.from(input.savedBy) : Identity.from(currentIdentity)
38
+ createdOn: systemInput.createdOn ?? original.createdOn,
39
+ modifiedOn: systemInput.modifiedOn ?? void 0,
40
+ savedOn: systemInput.savedOn ?? original.savedOn,
41
+ createdBy: systemInput.createdBy ? Identity.from(systemInput.createdBy) : original.createdBy,
42
+ modifiedBy: systemInput.modifiedBy ? Identity.from(systemInput.modifiedBy) : Identity.from(currentIdentity),
43
+ savedBy: systemInput.savedBy ? Identity.from(systemInput.savedBy) : Identity.from(currentIdentity)
43
44
  };
44
45
  await this.eventPublisher.publish(new FileBeforeUpdateEvent({
45
46
  original,
@@ -1 +1 @@
1
- {"version":3,"file":"features/file/UpdateFile/UpdateFileUseCase.js","sources":["../../../../src/features/file/UpdateFile/UpdateFileUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UpdateFileUseCase as UseCaseAbstraction,\n UpdateFileInput,\n UpdateFileRepository\n} from \"./abstractions.js\";\nimport { GetFileUseCase } from \"../GetFile/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FileBeforeUpdateEvent, FileAfterUpdateEvent } from \"./events.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { Identity } from \"~/domain/identity/Identity.js\";\n\nclass UpdateFileUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private permissions: FmPermissions.Interface,\n private getFile: GetFileUseCase.Interface,\n private repository: UpdateFileRepository.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(input: UpdateFileInput): Promise<Result<File, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canEdit(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n // Get the original file (includes ownership check).\n const getResult = await this.getFile.execute(input.id);\n\n if (getResult.isFail()) {\n return Result.fail(getResult.error);\n }\n\n const original = getResult.value;\n\n // Check ownership-aware edit permission.\n const canEditFile = await this.permissions.canEdit(\"file\", original);\n if (!canEditFile) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const currentIdentity = this.identityContext.getIdentity();\n\n const file: File = {\n ...original,\n ...input,\n // Preserve immutable fields.\n id: original.id,\n key: original.key,\n size: original.size,\n type: original.type,\n // Update mutable fields.\n tags: input.tags !== undefined ? input.tags : original.tags,\n description: input.description !== undefined ? input.description : original.description,\n location: input.location !== undefined ? input.location : original.location,\n // System fields.\n createdOn: input.createdOn ?? original.createdOn,\n modifiedOn: input.modifiedOn ?? undefined,\n savedOn: input.savedOn ?? original.savedOn,\n createdBy: input.createdBy ? Identity.from(input.createdBy) : original.createdBy,\n modifiedBy: input.modifiedBy\n ? Identity.from(input.modifiedBy)\n : Identity.from(currentIdentity),\n savedBy: input.savedBy ? Identity.from(input.savedBy) : Identity.from(currentIdentity)\n };\n\n await this.eventPublisher.publish(new FileBeforeUpdateEvent({ original, file, input }));\n\n const result = await this.repository.update(file);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(new FileAfterUpdateEvent({ original, file, input }));\n\n return Result.ok(file);\n }\n}\n\nexport const UpdateFileUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateFileUseCaseImpl,\n dependencies: [\n IdentityContext,\n FmPermissions,\n GetFileUseCase,\n UpdateFileRepository,\n EventPublisher\n ]\n});\n"],"names":["UpdateFileUseCaseImpl","identityContext","permissions","getFile","repository","eventPublisher","input","hasPermission","Result","FileNotAuthorizedError","getResult","original","canEditFile","currentIdentity","file","undefined","Identity","FileBeforeUpdateEvent","result","FileAfterUpdateEvent","UpdateFileUseCase","UseCaseAbstraction","IdentityContext","FmPermissions","GetFileUseCase","UpdateFileRepository","EventPublisher"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,WAAoC,EACpCC,OAAiC,EACjCC,UAA0C,EAC1CC,cAAwC,CAClD;aALUJ,eAAe,GAAfA;aACAC,WAAW,GAAXA;aACAC,OAAO,GAAPA;aACAC,UAAU,GAAVA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,KAAsB,EAAmD;QACnF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACrD,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAI3B,MAAMC,YAAY,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAACJ,MAAM,EAAE;QAErD,IAAII,UAAU,MAAM,IAChB,OAAOF,OAAO,IAAI,CAACE,UAAU,KAAK;QAGtC,MAAMC,WAAWD,UAAU,KAAK;QAGhC,MAAME,cAAc,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQD;QAC3D,IAAI,CAAC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rB;AACJ;AAEO,MAAMM,sCAAoBC,kBAAAA,oBAAuC,CAAC;IACrE,gBAAgBrB;IAChB,cAAc;QACVsB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"features/file/UpdateFile/UpdateFileUseCase.js","sources":["../../../../src/features/file/UpdateFile/UpdateFileUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UpdateFileUseCase as UseCaseAbstraction,\n UpdateFileInput,\n UpdateFileRepository\n} from \"./abstractions.js\";\nimport { GetFileUseCase } from \"../GetFile/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FileBeforeUpdateEvent, FileAfterUpdateEvent } from \"./events.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { Identity } from \"~/domain/identity/Identity.js\";\n\nclass UpdateFileUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private permissions: FmPermissions.Interface,\n private getFile: GetFileUseCase.Interface,\n private repository: UpdateFileRepository.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(input: UpdateFileInput): Promise<Result<File, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canEdit(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n // Get the original file (includes ownership check).\n const getResult = await this.getFile.execute(input.id);\n\n if (getResult.isFail()) {\n return Result.fail(getResult.error);\n }\n\n const original = getResult.value;\n\n // Check ownership-aware edit permission.\n const canEditFile = await this.permissions.canEdit(\"file\", original);\n if (!canEditFile) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const currentIdentity = this.identityContext.getIdentity();\n\n // Attribution and dates come from the server. Only full access, or code running without\n // authorization (imports, migrations), may set them.\n const systemInput: Partial<typeof input> =\n !this.identityContext.isAuthorizationEnabled() ||\n (await this.identityContext.hasFullAccess())\n ? input\n : {};\n\n const file: File = {\n ...original,\n ...input,\n // Preserve immutable fields.\n id: original.id,\n key: original.key,\n size: original.size,\n type: original.type,\n // Update mutable fields.\n tags: input.tags !== undefined ? input.tags : original.tags,\n description: input.description !== undefined ? input.description : original.description,\n location: input.location !== undefined ? input.location : original.location,\n // System fields.\n createdOn: systemInput.createdOn ?? original.createdOn,\n modifiedOn: systemInput.modifiedOn ?? undefined,\n savedOn: systemInput.savedOn ?? original.savedOn,\n createdBy: systemInput.createdBy\n ? Identity.from(systemInput.createdBy)\n : original.createdBy,\n modifiedBy: systemInput.modifiedBy\n ? Identity.from(systemInput.modifiedBy)\n : Identity.from(currentIdentity),\n savedBy: systemInput.savedBy\n ? Identity.from(systemInput.savedBy)\n : Identity.from(currentIdentity)\n };\n\n await this.eventPublisher.publish(new FileBeforeUpdateEvent({ original, file, input }));\n\n const result = await this.repository.update(file);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(new FileAfterUpdateEvent({ original, file, input }));\n\n return Result.ok(file);\n }\n}\n\nexport const UpdateFileUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateFileUseCaseImpl,\n dependencies: [\n IdentityContext,\n FmPermissions,\n GetFileUseCase,\n UpdateFileRepository,\n EventPublisher\n ]\n});\n"],"names":["UpdateFileUseCaseImpl","identityContext","permissions","getFile","repository","eventPublisher","input","hasPermission","Result","FileNotAuthorizedError","getResult","original","canEditFile","currentIdentity","systemInput","file","undefined","Identity","FileBeforeUpdateEvent","result","FileAfterUpdateEvent","UpdateFileUseCase","UseCaseAbstraction","IdentityContext","FmPermissions","GetFileUseCase","UpdateFileRepository","EventPublisher"],"mappings":";;;;;;;;;AAeA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,WAAoC,EACpCC,OAAiC,EACjCC,UAA0C,EAC1CC,cAAwC,CAClD;a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AO,IAAIH,SAAS,OAAO;YAChD,WAAWG,YAAY,SAAS,GAC1BG,SAAS,IAAI,CAACH,YAAY,SAAS,IACnCH,SAAS,SAAS;YACxB,YAAYG,YAAY,UAAU,GAC5BG,SAAS,IAAI,CAACH,YAAY,UAAU,IACpCG,SAAS,IAAI,CAACJ;YACpB,SAASC,YAAY,OAAO,GACtBG,SAAS,IAAI,CAACH,YAAY,OAAO,IACjCG,SAAS,IAAI,CAACJ;QACxB;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIK,sBAAsB;YAAEP;YAAUI;YAAMT;QAAM;QAEpF,MAAMa,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACJ;QAE5C,IAAII,OAAO,MAAM,IACb,OAAOX,OAAO,IAAI,CAACW,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIC,qBAAqB;YAAET;YAAUI;YAAMT;QAAM;QAEnF,OAAOE,OAAO,EAAE,CAACO;IACrB;AACJ;AAEO,MAAMM,sCAAoBC,kBAAAA,oBAAuC,CAAC;IACrE,gBAAgBtB;IAChB,cAAc;QACVuB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -1,13 +1,15 @@
1
1
  import { AppInstaller } from "@webiny/api-core/features/tenancy/InstallTenant/index.js";
2
2
  import { UpdateSettingsUseCase } from "../../../features/settings/UpdateSettings/abstractions.js";
3
3
  import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
4
5
  declare class SettingsInstallerImpl implements AppInstaller.Interface {
6
+ private identityContext;
5
7
  private updateSettings;
6
8
  private keyValueStore;
7
9
  readonly alwaysRun = true;
8
10
  readonly appName = "FileManager";
9
11
  readonly dependsOn: never[];
10
- constructor(updateSettings: UpdateSettingsUseCase.Interface, keyValueStore: KeyValueStore.Interface);
12
+ constructor(identityContext: IdentityContext.Interface, updateSettings: UpdateSettingsUseCase.Interface, keyValueStore: KeyValueStore.Interface);
11
13
  install(): Promise<void>;
12
14
  uninstall(): Promise<void>;
13
15
  }
@@ -4,8 +4,10 @@ import { AppInstaller } from "@webiny/api-core/features/tenancy/InstallTenant/in
4
4
  import { FILE_MANAGER_GENERAL_SETTINGS } from "../../../domain/settings/constants.js";
5
5
  import { UpdateSettingsUseCase } from "../UpdateSettings/abstractions.js";
6
6
  import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
7
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
7
8
  class SettingsInstallerImpl {
8
- constructor(updateSettings, keyValueStore){
9
+ constructor(identityContext, updateSettings, keyValueStore){
10
+ this.identityContext = identityContext;
9
11
  this.updateSettings = updateSettings;
10
12
  this.keyValueStore = keyValueStore;
11
13
  this.alwaysRun = true;
@@ -14,10 +16,10 @@ class SettingsInstallerImpl {
14
16
  }
15
17
  async install() {
16
18
  const manifest = await ServiceDiscovery.load();
17
- const domain = manifest?.api?.cloudfront.domain;
18
- await this.updateSettings.execute({
19
- srcPrefix: `${domain}/files`
20
- });
19
+ const domain = manifest?.api?.cloudfront?.domain;
20
+ await this.identityContext.withoutAuthorization(()=>this.updateSettings.execute({
21
+ srcPrefix: domain ? `${domain}/files` : ""
22
+ }));
21
23
  }
22
24
  async uninstall() {
23
25
  await this.keyValueStore.delete(FILE_MANAGER_GENERAL_SETTINGS);
@@ -27,6 +29,7 @@ const SettingsInstaller = createImplementation({
27
29
  abstraction: AppInstaller,
28
30
  implementation: SettingsInstallerImpl,
29
31
  dependencies: [
32
+ IdentityContext,
30
33
  UpdateSettingsUseCase,
31
34
  KeyValueStore
32
35
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/SettingsInstaller/SettingsInstaller.js","sources":["../../../../src/features/settings/SettingsInstaller/SettingsInstaller.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { AppInstaller } from \"@webiny/api-core/features/tenancy/InstallTenant/index.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { UpdateSettingsUseCase } from \"~/features/settings/UpdateSettings/abstractions.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\n\nclass SettingsInstallerImpl implements AppInstaller.Interface {\n readonly alwaysRun = true;\n readonly appName = \"FileManager\";\n readonly dependsOn = [];\n\n constructor(\n private updateSettings: UpdateSettingsUseCase.Interface,\n private keyValueStore: KeyValueStore.Interface\n ) {}\n\n async install(): Promise<void> {\n // TODO: move this to api-core with a proper abstraction\n const manifest = await ServiceDiscovery.load();\n\n // If no records in the database, `manifest` object is empty POJO.\n // That's why the heavy `?.` usage.\n const domain = manifest?.api?.cloudfront.domain;\n\n await this.updateSettings.execute({\n srcPrefix: `${domain}/files`\n });\n }\n\n async uninstall(): Promise<void> {\n await this.keyValueStore.delete(FILE_MANAGER_GENERAL_SETTINGS);\n }\n}\n\nexport const SettingsInstaller = createImplementation({\n abstraction: AppInstaller,\n implementation: SettingsInstallerImpl,\n dependencies: [UpdateSettingsUseCase, KeyValueStore]\n});\n"],"names":["SettingsInstallerImpl","updateSettings","keyValueStore","manifest","ServiceDiscovery","domain","FILE_MANAGER_GENERAL_SETTINGS","SettingsInstaller","createImplementation","AppInstaller","UpdateSettingsUseCase","KeyValueStore"],"mappings":";;;;;;AAOA,MAAMA;IAKF,YACYC,cAA+C,EAC/CC,aAAsC,CAChD;aAFUD,cAAc,GAAdA;aACAC,aAAa,GAAbA;aANH,SAAS,GAAG;aACZ,OAAO,GAAG;aACV,SAAS,GAAG,EAAE;IAKpB;IAEH,MAAM,UAAyB;QAE3B,MAAMC,WAAW,MAAMC,iBAAiB,IAAI;QAI5C,MAAMC,SAASF,UAAU,KAAK,WAAW;QAEzC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAC9B,WAAW,GAAGE,OAAO,MAAM,CAAC;QAChC;IACJ;IAEA,MAAM,YAA2B;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAACC;IACpC;AACJ;AAEO,MAAMC,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBT;IAChB,cAAc;QAACU;QAAuBC;KAAc;AACxD"}
1
+ {"version":3,"file":"features/settings/SettingsInstaller/SettingsInstaller.js","sources":["../../../../src/features/settings/SettingsInstaller/SettingsInstaller.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { AppInstaller } from \"@webiny/api-core/features/tenancy/InstallTenant/index.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { UpdateSettingsUseCase } from \"~/features/settings/UpdateSettings/abstractions.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\n\nclass SettingsInstallerImpl implements AppInstaller.Interface {\n readonly alwaysRun = true;\n readonly appName = \"FileManager\";\n readonly dependsOn = [];\n\n constructor(\n private identityContext: IdentityContext.Interface,\n private updateSettings: UpdateSettingsUseCase.Interface,\n private keyValueStore: KeyValueStore.Interface\n ) {}\n\n async install(): Promise<void> {\n // TODO: move this to api-core with a proper abstraction\n const manifest = await ServiceDiscovery.load();\n\n // If no records in the database, `manifest` object is empty POJO.\n // That's why the heavy `?.` usage.\n const domain = manifest?.api?.cloudfront?.domain;\n\n // The installer can run as the caller (e.g. Tenant Manager creating a tenant),\n // and the value comes from the API's own URL, not from caller input.\n await this.identityContext.withoutAuthorization(() => {\n return this.updateSettings.execute({\n // An empty value makes validation fall back to an empty prefix.\n srcPrefix: domain ? `${domain}/files` : \"\"\n });\n });\n }\n\n async uninstall(): Promise<void> {\n await this.keyValueStore.delete(FILE_MANAGER_GENERAL_SETTINGS);\n }\n}\n\nexport const SettingsInstaller = createImplementation({\n abstraction: AppInstaller,\n implementation: SettingsInstallerImpl,\n dependencies: [IdentityContext, UpdateSettingsUseCase, KeyValueStore]\n});\n"],"names":["SettingsInstallerImpl","identityContext","updateSettings","keyValueStore","manifest","ServiceDiscovery","domain","FILE_MANAGER_GENERAL_SETTINGS","SettingsInstaller","createImplementation","AppInstaller","IdentityContext","UpdateSettingsUseCase","KeyValueStore"],"mappings":";;;;;;;AAQA,MAAMA;IAKF,YACYC,eAA0C,EAC1CC,cAA+C,EAC/CC,aAAsC,CAChD;aAHUF,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,aAAa,GAAbA;aAPH,SAAS,GAAG;aACZ,OAAO,GAAG;aACV,SAAS,GAAG,EAAE;IAMpB;IAEH,MAAM,UAAyB;QAE3B,MAAMC,WAAW,MAAMC,iBAAiB,IAAI;QAI5C,MAAMC,SAASF,UAAU,KAAK,YAAY;QAI1C,MAAM,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC,IACrC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBAE/B,WAAWE,SAAS,GAAGA,OAAO,MAAM,CAAC,GAAG;YAC5C;IAER;IAEA,MAAM,YAA2B;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAACC;IACpC;AACJ;AAEO,MAAMC,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAiBC;QAAuBC;KAAc;AACzE"}
@@ -5,11 +5,13 @@ import { GetSettingsUseCase } from "../GetSettings/abstractions.js";
5
5
  import type { FileManagerSettings } from "../../../domain/settings/types.js";
6
6
  import type { UpdateSettingsInput } from "../../../domain/settings/types.js";
7
7
  import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
8
+ import { FmPermissions } from "../../../features/shared/abstractions.js";
8
9
  declare class UpdateSettingsUseCaseImpl implements UseCaseAbstraction.Interface {
10
+ private permissions;
9
11
  private keyValueStore;
10
12
  private getSettings;
11
13
  private eventPublisher;
12
- constructor(keyValueStore: KeyValueStore.Interface, getSettings: GetSettingsUseCase.Interface, eventPublisher: EventPublisher.Interface);
14
+ constructor(permissions: FmPermissions.Interface, keyValueStore: KeyValueStore.Interface, getSettings: GetSettingsUseCase.Interface, eventPublisher: EventPublisher.Interface);
13
15
  execute(input: UpdateSettingsInput): Promise<Result<FileManagerSettings, UseCaseAbstraction.Error>>;
14
16
  }
15
17
  export declare const UpdateSettingsUseCase: typeof UpdateSettingsUseCaseImpl & {
@@ -2,25 +2,29 @@ import { Result } from "@webiny/feature/api";
2
2
  import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
3
3
  import { UpdateSettingsUseCase } from "./abstractions.js";
4
4
  import { GetSettingsUseCase } from "../GetSettings/abstractions.js";
5
- import { SettingsUpdateError, SettingsValidationError } from "../../../domain/settings/errors.js";
5
+ import { SettingsNotAuthorizedError, SettingsUpdateError, SettingsValidationError } from "../../../domain/settings/errors.js";
6
6
  import { FILE_MANAGER_GENERAL_SETTINGS } from "../../../domain/settings/constants.js";
7
7
  import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
8
8
  import { SettingsAfterUpdateEvent, SettingsBeforeUpdateEvent } from "./events.js";
9
- import { updateSettingsValidation } from "../../../domain/settings/validation.js";
9
+ import { mergedSettingsValidation, updateSettingsValidation } from "../../../domain/settings/validation.js";
10
10
  import { createZodError } from "@webiny/utils";
11
+ import { FmPermissions } from "../../shared/abstractions.js";
11
12
  class UpdateSettingsUseCaseImpl {
12
- constructor(keyValueStore, getSettings, eventPublisher){
13
+ constructor(permissions, keyValueStore, getSettings, eventPublisher){
14
+ this.permissions = permissions;
13
15
  this.keyValueStore = keyValueStore;
14
16
  this.getSettings = getSettings;
15
17
  this.eventPublisher = eventPublisher;
16
18
  }
17
19
  async execute(input) {
20
+ const hasPermission = await this.permissions.canAccess("settings");
21
+ if (!hasPermission) return Result.fail(new SettingsNotAuthorizedError());
18
22
  const validationResult = await updateSettingsValidation.safeParseAsync(input);
19
23
  if (!validationResult.success) {
20
24
  const zodError = createZodError(validationResult.error);
21
25
  return Result.fail(new SettingsValidationError(zodError.data.invalidFields));
22
26
  }
23
- const validatedInput = validationResult.data;
27
+ const validatedInput = Object.fromEntries(Object.entries(validationResult.data).filter(([, value])=>void 0 !== value));
24
28
  const existingResult = await this.getSettings.execute();
25
29
  if (existingResult.isFail()) return existingResult;
26
30
  const existing = existingResult.value;
@@ -28,6 +32,11 @@ class UpdateSettingsUseCaseImpl {
28
32
  ...existing,
29
33
  ...validatedInput
30
34
  };
35
+ const mergedValidationResult = mergedSettingsValidation.safeParse(updatedSettings);
36
+ if (!mergedValidationResult.success) {
37
+ const zodError = createZodError(mergedValidationResult.error);
38
+ return Result.fail(new SettingsValidationError(zodError.data.invalidFields));
39
+ }
31
40
  await this.eventPublisher.publish(new SettingsBeforeUpdateEvent({
32
41
  original: existing,
33
42
  settings: updatedSettings,
@@ -46,6 +55,7 @@ class UpdateSettingsUseCaseImpl {
46
55
  const UpdateSettingsUseCase_UpdateSettingsUseCase = UpdateSettingsUseCase.createImplementation({
47
56
  implementation: UpdateSettingsUseCaseImpl,
48
57
  dependencies: [
58
+ FmPermissions,
49
59
  KeyValueStore,
50
60
  GetSettingsUseCase,
51
61
  EventPublisher
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/UpdateSettings/UpdateSettingsUseCase.js","sources":["../../../../src/features/settings/UpdateSettings/UpdateSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { UpdateSettingsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"../GetSettings/abstractions.js\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\nimport type { UpdateSettingsInput } from \"~/domain/settings/types.js\";\nimport { SettingsUpdateError } from \"~/domain/settings/errors.js\";\nimport { SettingsValidationError } from \"~/domain/settings/errors.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { SettingsBeforeUpdateEvent, SettingsAfterUpdateEvent } from \"./events.js\";\nimport { updateSettingsValidation } from \"~/domain/settings/validation.js\";\nimport { createZodError } from \"@webiny/utils\";\n\nclass UpdateSettingsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(\n input: UpdateSettingsInput\n ): Promise<Result<FileManagerSettings, UseCaseAbstraction.Error>> {\n // Validate input\n const validationResult = await updateSettingsValidation.safeParseAsync(input);\n if (!validationResult.success) {\n const zodError = createZodError(validationResult.error);\n return Result.fail(new SettingsValidationError(zodError.data!.invalidFields));\n }\n\n const validatedInput = validationResult.data;\n\n // Get existing settings to merge with new data\n const existingResult = await this.getSettings.execute();\n if (existingResult.isFail()) {\n return existingResult;\n }\n const existing = existingResult.value;\n\n // Prepare merged settings\n const updatedSettings: FileManagerSettings = {\n ...existing,\n ...validatedInput\n };\n\n // Publish BeforeUpdate event\n await this.eventPublisher.publish(\n new SettingsBeforeUpdateEvent({\n original: existing,\n settings: updatedSettings,\n input: validatedInput\n })\n );\n\n const result = await this.keyValueStore.set(FILE_MANAGER_GENERAL_SETTINGS, updatedSettings);\n\n if (result.isFail()) {\n return Result.fail(new SettingsUpdateError(result.error));\n }\n\n // Publish AfterUpdate event\n await this.eventPublisher.publish(\n new SettingsAfterUpdateEvent({\n original: existing,\n settings: updatedSettings,\n input: validatedInput\n })\n );\n\n return Result.ok(updatedSettings);\n }\n}\n\nexport const UpdateSettingsUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateSettingsUseCaseImpl,\n dependencies: [KeyValueStore, GetSettingsUseCase, EventPublisher]\n});\n"],"names":["UpdateSettingsUseCaseImpl","keyValueStore","getSettings","eventPublisher","input","validationResult","updateSettingsValidation","zodError","createZodError","Result","SettingsValidationError","validatedInput","existingResult","existing","updatedSettings","SettingsBeforeUpdateEvent","result","FILE_MANAGER_GENERAL_SETTINGS","SettingsUpdateError","SettingsAfterUpdateEvent","UpdateSettingsUseCase","UseCaseAbstraction","KeyValueStore","GetSettingsUseCase","EventPublisher"],"mappings":";;;;;;;;;;AAcA,MAAMA;IACF,YACYC,aAAsC,EACtCC,WAAyC,EACzCC,cAAwC,CAClD;aAHUF,aAAa,GAAbA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAA0B,EACoC;QAE9D,MAAMC,mBAAmB,MAAMC,yBAAyB,cAAc,CAACF;QACvE,IAAI,CAACC,iBAAiB,OAAO,EAAE;YAC3B,MAAME,WAAWC,eAAeH,iBAAiB,KAAK;YACtD,OAAOI,OAAO,IAAI,CAAC,IAAIC,wBAAwBH,SAAS,IAAI,CAAE,aAAa;QAC/E;QAEA,MAAMI,iBAAiBN,iBAAiB,IAAI;QAG5C,MAAMO,iBAAiB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO;QACrD,IAAIA,eAAe,MAAM,IACrB,OAAOA;QAEX,MAAMC,WAAWD,eAAe,KAAK;QAGrC,MAAME,kBAAuC;YACzC,GAAGD,QAAQ;YACX,GAAGF,cAAc;QACrB;QAGA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAII,0BAA0B;YAC1B,UAAUF;YACV,UAAUC;YACV,OAAOH;QACX;QAGJ,MAAMK,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAACC,+BAA+BH;QAE3E,IAAIE,OAAO,MAAM,IACb,OAAOP,OAAO,IAAI,CAAC,IAAIS,oBAAoBF,OAAO,KAAK;QAI3D,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,yBAAyB;YACzB,UAAUN;YACV,UAAUC;YACV,OAAOH;QACX;QAGJ,OAAOF,OAAO,EAAE,CAACK;IACrB;AACJ;AAEO,MAAMM,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBrB;IAChB,cAAc;QAACsB;QAAeC;QAAoBC;KAAe;AACrE"}
1
+ {"version":3,"file":"features/settings/UpdateSettings/UpdateSettingsUseCase.js","sources":["../../../../src/features/settings/UpdateSettings/UpdateSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { UpdateSettingsUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetSettingsUseCase } from \"../GetSettings/abstractions.js\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\nimport type { UpdateSettingsInput } from \"~/domain/settings/types.js\";\nimport { SettingsUpdateError } from \"~/domain/settings/errors.js\";\nimport { SettingsValidationError } from \"~/domain/settings/errors.js\";\nimport { SettingsNotAuthorizedError } from \"~/domain/settings/errors.js\";\nimport { FILE_MANAGER_GENERAL_SETTINGS } from \"~/domain/settings/constants.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { SettingsBeforeUpdateEvent, SettingsAfterUpdateEvent } from \"./events.js\";\nimport {\n mergedSettingsValidation,\n updateSettingsValidation\n} from \"~/domain/settings/validation.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\n\nclass UpdateSettingsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private keyValueStore: KeyValueStore.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(\n input: UpdateSettingsInput\n ): Promise<Result<FileManagerSettings, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canAccess(\"settings\");\n if (!hasPermission) {\n return Result.fail(new SettingsNotAuthorizedError());\n }\n\n // Validate input\n const validationResult = await updateSettingsValidation.safeParseAsync(input);\n if (!validationResult.success) {\n const zodError = createZodError(validationResult.error);\n return Result.fail(new SettingsValidationError(zodError.data!.invalidFields));\n }\n\n // Drop keys passed as `undefined`, so they don't overwrite stored values.\n const validatedInput = Object.fromEntries(\n Object.entries(validationResult.data).filter(([, value]) => value !== undefined)\n ) as UpdateSettingsInput;\n\n // Get existing settings to merge with new data\n const existingResult = await this.getSettings.execute();\n if (existingResult.isFail()) {\n return existingResult;\n }\n const existing = existingResult.value;\n\n // Prepare merged settings\n const updatedSettings: FileManagerSettings = {\n ...existing,\n ...validatedInput\n };\n\n const mergedValidationResult = mergedSettingsValidation.safeParse(updatedSettings);\n if (!mergedValidationResult.success) {\n const zodError = createZodError(mergedValidationResult.error);\n return Result.fail(new SettingsValidationError(zodError.data!.invalidFields));\n }\n\n // Publish BeforeUpdate event\n await this.eventPublisher.publish(\n new SettingsBeforeUpdateEvent({\n original: existing,\n settings: updatedSettings,\n input: validatedInput\n })\n );\n\n const result = await this.keyValueStore.set(FILE_MANAGER_GENERAL_SETTINGS, updatedSettings);\n\n if (result.isFail()) {\n return Result.fail(new SettingsUpdateError(result.error));\n }\n\n // Publish AfterUpdate event\n await this.eventPublisher.publish(\n new SettingsAfterUpdateEvent({\n original: existing,\n settings: updatedSettings,\n input: validatedInput\n })\n );\n\n return Result.ok(updatedSettings);\n }\n}\n\nexport const UpdateSettingsUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateSettingsUseCaseImpl,\n dependencies: [FmPermissions, KeyValueStore, GetSettingsUseCase, EventPublisher]\n});\n"],"names":["UpdateSettingsUseCaseImpl","permissions","keyValueStore","getSettings","eventPublisher","input","hasPermission","Result","SettingsNotAuthorizedError","validationResult","updateSettingsValidation","zodError","createZodError","SettingsValidationError","validatedInput","Object","value","undefined","existingResult","existing","updatedSettings","mergedValidationResult","mergedSettingsValidation","SettingsBeforeUpdateEvent","result","FILE_MANAGER_GENERAL_SETTINGS","SettingsUpdateError","SettingsAfterUpdateEvent","UpdateSettingsUseCase","UseCaseAbstraction","FmPermissions","KeyValueStore","Get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M,IAAI,CAAC,aAAa,CAAC,GAAG,CAACC,+BAA+BL;QAE3E,IAAII,OAAO,MAAM,IACb,OAAOjB,OAAO,IAAI,CAAC,IAAImB,oBAAoBF,OAAO,KAAK;QAI3D,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,yBAAyB;YACzB,UAAUR;YACV,UAAUC;YACV,OAAON;QACX;QAGJ,OAAOP,OAAO,EAAE,CAACa;IACrB;AACJ;AAEO,MAAMQ,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAeC;QAAeC;QAAoBC;KAAe;AACpF"}
@@ -3,6 +3,7 @@ import type { FileManagerSettings } from "../../../domain/settings/types.js";
3
3
  import type { UpdateSettingsInput } from "../../../domain/settings/types.js";
4
4
  import type { SettingsUpdateError } from "../../../domain/settings/errors.js";
5
5
  import type { SettingsValidationError } from "../../../domain/settings/errors.js";
6
+ import type { SettingsNotAuthorizedError } from "../../../domain/settings/errors.js";
6
7
  /**
7
8
  * UpdateSettings use case interface
8
9
  */
@@ -10,6 +11,7 @@ export interface IUpdateSettingsUseCase {
10
11
  execute(input: UpdateSettingsInput): Promise<Result<FileManagerSettings, UseCaseError>>;
11
12
  }
12
13
  export interface IUpdateSettingsUseCaseErrors {
14
+ notAuthorized: SettingsNotAuthorizedError;
13
15
  updateError: SettingsUpdateError;
14
16
  validationError: SettingsValidationError;
15
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/settings/UpdateSettings/abstractions.js","sources":["../../../../src/features/settings/UpdateSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\nimport type { UpdateSettingsInput } from \"~/domain/settings/types.js\";\nimport type { SettingsUpdateError } from \"~/domain/settings/errors.js\";\nimport type { SettingsValidationError } from \"~/domain/settings/errors.js\";\n\n/**\n * UpdateSettings use case interface\n */\nexport interface IUpdateSettingsUseCase {\n execute(input: UpdateSettingsInput): Promise<Result<FileManagerSettings, UseCaseError>>;\n}\n\nexport interface IUpdateSettingsUseCaseErrors {\n updateError: SettingsUpdateError;\n validationError: SettingsValidationError;\n}\n\ntype UseCaseError = IUpdateSettingsUseCaseErrors[keyof IUpdateSettingsUseCaseErrors];\n\n/** Update file manager settings. */\nexport const UpdateSettingsUseCase =\n createAbstraction<IUpdateSettingsUseCase>(\"UpdateSettingsUseCase\");\n\nexport namespace UpdateSettingsUseCase {\n export type Interface = IUpdateSettingsUseCase;\n export type Error = UseCaseError;\n}\n"],"names":["UpdateSettingsUseCase","createAbstraction"],"mappings":";AAsBO,MAAMA,wBACTC,kBAA0C"}
1
+ {"version":3,"file":"features/settings/UpdateSettings/abstractions.js","sources":["../../../../src/features/settings/UpdateSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\nimport type { UpdateSettingsInput } from \"~/domain/settings/types.js\";\nimport type { SettingsUpdateError } from \"~/domain/settings/errors.js\";\nimport type { SettingsValidationError } from \"~/domain/settings/errors.js\";\nimport type { SettingsNotAuthorizedError } from \"~/domain/settings/errors.js\";\n\n/**\n * UpdateSettings use case interface\n */\nexport interface IUpdateSettingsUseCase {\n execute(input: UpdateSettingsInput): Promise<Result<FileManagerSettings, UseCaseError>>;\n}\n\nexport interface IUpdateSettingsUseCaseErrors {\n notAuthorized: SettingsNotAuthorizedError;\n updateError: SettingsUpdateError;\n validationError: SettingsValidationError;\n}\n\ntype UseCaseError = IUpdateSettingsUseCaseErrors[keyof IUpdateSettingsUseCaseErrors];\n\n/** Update file manager settings. */\nexport const UpdateSettingsUseCase =\n createAbstraction<IUpdateSettingsUseCase>(\"UpdateSettingsUseCase\");\n\nexport namespace UpdateSettingsUseCase {\n export type Interface = IUpdateSettingsUseCase;\n export type Error = UseCaseError;\n}\n"],"names":["UpdateSettingsUseCase","createAbstraction"],"mappings":";AAwBO,MAAMA,wBACTC,kBAA0C"}
@@ -11,6 +11,7 @@ import { UpdateFileUseCase } from "../features/file/UpdateFile/abstractions.js";
11
11
  import { DeleteFileUseCase } from "../features/file/DeleteFile/abstractions.js";
12
12
  import { GetSettingsUseCase } from "../features/settings/GetSettings/abstractions.js";
13
13
  import { FileModel } from "../domain/file/abstractions.js";
14
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
14
15
  const createFilesSchema = (params)=>{
15
16
  const fileManagerGraphQL = new GraphQLSchemaPlugin({
16
17
  typeDefs: createFilesTypeDefs(params),
@@ -32,8 +33,9 @@ const createFilesSchema = (params)=>{
32
33
  },
33
34
  FmQuery: {
34
35
  getFileModel (_, __, context) {
35
- const identity = context.security.getIdentity();
36
- if (!identity) return new NotAuthorizedResponse();
36
+ const identityContext = context.container.resolve(IdentityContext);
37
+ const identity = identityContext.getIdentity();
38
+ if (identity.isAnonymous()) return new NotAuthorizedResponse();
37
39
  return resolve(async ()=>context.container.resolve(FileModel));
38
40
  },
39
41
  async getFile (_, args, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/filesSchema.js","sources":["../../src/graphql/filesSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n GraphQLSchemaPlugin,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql\";\nimport { emptyResolver, resolve } from \"./utils.js\";\nimport type { CreateFilesTypeDefsParams } from \"~/graphql/createFilesTypeDefs.js\";\nimport { createFilesTypeDefs } from \"~/graphql/createFilesTypeDefs.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { GetFileUseCase } from \"~/features/file/GetFile/abstractions.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/abstractions.js\";\nimport { ListTagsUseCase } from \"~/features/file/ListTags/abstractions.js\";\nimport { CreateFileUseCase } from \"~/features/file/CreateFile/abstractions.js\";\nimport { CreateFilesInBatchUseCase } from \"~/features/file/CreateFilesInBatch/abstractions.js\";\nimport { UpdateFileUseCase } from \"~/features/file/UpdateFile/abstractions.js\";\nimport { DeleteFileUseCase } from \"~/features/file/DeleteFile/abstractions.js\";\nimport { GetSettingsUseCase } from \"~/features/settings/GetSettings/abstractions.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\n\nexport const createFilesSchema = (params: CreateFilesTypeDefsParams) => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: createFilesTypeDefs(params),\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmFile: {\n async src(file, _, context) {\n // TODO: create `FileUrlGenerator` service to use here\n const getSettings = context.container.resolve(GetSettingsUseCase);\n const result = await getSettings.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const settings = result.value;\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n FmQuery: {\n getFileModel(_, __, context) {\n const identity = context.security.getIdentity();\n if (!identity) {\n return new NotAuthorizedResponse();\n }\n\n return resolve(async () => {\n return context.container.resolve(FileModel);\n });\n },\n async getFile(_, args: any, context) {\n const getFile = context.container.resolve(GetFileUseCase);\n const result = await getFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async listFiles(_, args, context) {\n const listFiles = context.container.resolve(ListFilesUseCase);\n const result = await listFiles.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse(result.value.items, result.value.meta);\n },\n async listTags(_, args: any, context) {\n const listTags = context.container.resolve(ListTagsUseCase);\n const result = await listTags.execute(args || {});\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n const createFile = context.container.resolve(CreateFileUseCase);\n const result = await createFile.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async createFiles(_, args: any, context) {\n const createFilesInBatch = context.container.resolve(CreateFilesInBatchUseCase);\n const result = await createFilesInBatch.execute({\n files: args.data,\n meta: args.meta\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async updateFile(_, args: any, context) {\n const updateFile = context.container.resolve(UpdateFileUseCase);\n const result = await updateFile.execute({\n id: args.id,\n ...args.data\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async deleteFile(_, args: any, context) {\n const deleteFile = context.container.resolve(DeleteFileUseCase);\n const result = await deleteFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n // TODO: deletion from Cloud storage should be implemented in the `api-file-manager-s3` as an event handler\n return new Response(true);\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.files\";\n\n return fileManagerGraphQL;\n};\n"],"names":["createFilesSchema","params","fileManagerGraphQL","GraphQLSchemaPlugin","createFilesTypeDefs","emptyResolver","file","_","context","getSettings","GetSettingsUseCase","result","settings","__","identity","NotAuthorizedResponse","resolve","FileModel","args","getFile","GetFileUseCase","ErrorResponse","Response","listFiles","ListFilesUseCase","ListResponse","listTags","ListTagsUseCase","createFile","CreateFileUseCase","createFilesInBatch","CreateFilesInBatchUseCase","updateFile","UpdateFileUseCase","deleteFile","DeleteFileUseCase"],"mappings":";;;;;;;;;;;;;AAqBO,MAAMA,oBAAoB,CAACC;IAC9B,MAAMC,qBAAqB,IAAIC,oBAAoC;QAC/D,UAAUC,oBAAoBH;QAC9B,WAAW;YACP,OAAO;gBACH,aAAaI;YACjB;YACA,UAAU;gBACN,aAAaA;YACjB;YACA,QAAQ;gBACJ,MAAM,KAAIC,IAAI,EAAEC,CAAC,EAAEC,OAAO;oBAEtB,MAAMC,cAAcD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBAC9C,MAA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OAAO,KAAK;oBAIzC,OAAO,IAAIW,SAAS;gBACxB;YACJ;QACJ;IACJ;IACApB,mBAAmB,IAAI,GAAG;IAE1B,OAAOA;AACX"}
1
+ {"version":3,"file":"graphql/filesSchema.js","sources":["../../src/graphql/filesSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n GraphQLSchemaPlugin,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql\";\nimport { emptyResolver, resolve } from \"./utils.js\";\nimport type { CreateFilesTypeDefsParams } from \"~/graphql/createFilesTypeDefs.js\";\nimport { createFilesTypeDefs } from \"~/graphql/createFilesTypeDefs.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { GetFileUseCase } from \"~/features/file/GetFile/abstractions.js\";\nimport { ListFilesUseCase } from \"~/features/file/ListFiles/abstractions.js\";\nimport { ListTagsUseCase } from \"~/features/file/ListTags/abstractions.js\";\nimport { CreateFileUseCase } from \"~/features/file/CreateFile/abstractions.js\";\nimport { CreateFilesInBatchUseCase } from \"~/features/file/CreateFilesInBatch/abstractions.js\";\nimport { UpdateFileUseCase } from \"~/features/file/UpdateFile/abstractions.js\";\nimport { DeleteFileUseCase } from \"~/features/file/DeleteFile/abstractions.js\";\nimport { GetSettingsUseCase } from \"~/features/settings/GetSettings/abstractions.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\n\nexport const createFilesSchema = (params: CreateFilesTypeDefsParams) => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: createFilesTypeDefs(params),\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmFile: {\n async src(file, _, context) {\n // TODO: create `FileUrlGenerator` service to use here\n const getSettings = context.container.resolve(GetSettingsUseCase);\n const result = await getSettings.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const settings = result.value;\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n FmQuery: {\n getFileModel(_, __, context) {\n const identityContext = context.container.resolve(IdentityContext);\n const identity = identityContext.getIdentity();\n if (identity.isAnonymous()) {\n return new NotAuthorizedResponse();\n }\n\n return resolve(async () => {\n return context.container.resolve(FileModel);\n });\n },\n async getFile(_, args: any, context) {\n const getFile = context.container.resolve(GetFileUseCase);\n const result = await getFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async listFiles(_, args, context) {\n const listFiles = context.container.resolve(ListFilesUseCase);\n const result = await listFiles.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse(result.value.items, result.value.meta);\n },\n async listTags(_, args: any, context) {\n const listTags = context.container.resolve(ListTagsUseCase);\n const result = await listTags.execute(args || {});\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n const createFile = context.container.resolve(CreateFileUseCase);\n const result = await createFile.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async createFiles(_, args: any, context) {\n const createFilesInBatch = context.container.resolve(CreateFilesInBatchUseCase);\n const result = await createFilesInBatch.execute({\n files: args.data,\n meta: args.meta\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async updateFile(_, args: any, context) {\n const updateFile = context.container.resolve(UpdateFileUseCase);\n const result = await updateFile.execute({\n id: args.id,\n ...args.data\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response(result.value);\n },\n async deleteFile(_, args: any, context) {\n const deleteFile = context.container.resolve(DeleteFileUseCase);\n const result = await deleteFile.execute(args.id);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n // TODO: deletion from Cloud storage should be implemented in the `api-file-manager-s3` as an event handler\n return new Response(true);\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.files\";\n\n return fileManagerGraphQL;\n};\n"],"names":["createFilesSchema","params","fileManagerGraphQL","GraphQLSchemaPlugin","createFilesTypeDefs","emptyResolver","file","_","context","getSettings","GetSettingsUseCase","result","settings","__","identityContext","IdentityContext","identity","NotAuthorizedResponse","resolve","FileModel","args","getFile","GetFileUseCase","ErrorResponse","Response","listFiles","ListFilesUseCase","ListResponse","listTags","ListTagsUseCase","createFile","CreateFileUseCase","createFilesInBatch","CreateFilesInBatchUseCase","updateFile","UpdateFileUseCase","deleteFile","DeleteFileUseCase"],"mappings":";;;;;;;;;;;;;;AAsBO,MAAMA,oBAAoB,CAACC;IAC9B,MAAMC,qBAAqB,IAAIC,oBAAoC;QAC/D,UAAUC,oBAAoBH;QAC9B,WAAW;YACP,OAAO;gBACH,aAAaI;YACjB;YACA,UAAU;gBACN,aAAaA;YACjB;YACA,QAAQ;gBACJ,MAAM,KAAIC,IAAI,EAAEC,CAAC,EAAEC,OAAO;oBAEtB,MAAMC,cAAcD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBAC9C,MAAMC,SAAS,MAAMF,YAAY,OAAO;oBACxC,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,MAAMC,WAAWD,OAAO,KAAK;oBAC7B,OAAQC,AAAAA,CAAAA,UAAU,aAAa,EAAC,IAAKN,KAAK,GAAG;gBACjD;YACJ;YACA,SAAS;gBACL,cAAaC,CAAC,EAAEM,EAAE,EAAEL,OAAO;oBACvB,MAAMM,kBAAkBN,QAAQ,SAAS,CAAC,OAAO,CAACO;oBAClD,MAAMC,WAAWF,gBAAgB,WAAW;oBAC5C,IAAIE,SAAS,WAAW,IACpB,OAAO,IAAIC;oBAGf,OAAOC,QAAQ,UACJV,QAAQ,SAAS,CAAC,OAAO,CAACW;gBAEzC;gBACA,MAAM,SAAQZ,CAAC,EAAEa,IAAS,EAAE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S,CAAC,OAAO,CAACyB;oBACrD,MAAMtB,SAAS,MAAMqB,mBAAmB,OAAO,CAAC;wBAC5C,OAAOZ,KAAK,IAAI;wBAChB,MAAMA,KAAK,IAAI;oBACnB;oBAEA,IAAIT,OAAO,MAAM,IACb,OAAO,IAAIY,cAAcZ,OAAO,KAAK;oBAGzC,OAAO,IAAIa,SAASb,OAAO,KAAK;gBACpC;gBACA,MAAM,YAAWJ,CAAC,EAAEa,IAAS,EAAEZ,OAAO;oBAClC,MAAM0B,aAAa1B,QAAQ,SAAS,CAAC,OAAO,CAAC2B;oBAC7C,MAAMxB,SAAS,MAAMuB,WAAW,OAAO,CAAC;wBACpC,IAAId,KAAK,EAAE;wBACX,GAAGA,KAAK,IAAI;oBAChB;oBAEA,IAAIT,OAAO,MAAM,IACb,OAAO,IAAIY,cAAcZ,OAAO,KAAK;oBAGzC,OAAO,IAAIa,SAASb,OAAO,KAAK;gBACpC;gBACA,MAAM,YAAWJ,CAAC,EAAEa,IAAS,EAAEZ,OAAO;oBAClC,MAAM4B,aAAa5B,QAAQ,SAAS,CAAC,OAAO,CAAC6B;oBAC7C,MAAM1B,SAAS,MAAMyB,WAAW,OAAO,CAAChB,KAAK,EAAE;oBAE/C,IAAIT,OAAO,MAAM,IACb,OAAO,IAAIY,cAAcZ,OAAO,KAAK;oBAIzC,OAAO,IAAIa,SAAS;gBACxB;YACJ;QACJ;IACJ;IACAtB,mBAAmB,IAAI,GAAG;IAE1B,OAAOA;AACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager",
3
- "version": "6.4.12-beta.5",
3
+ "version": "6.4.12-beta.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -22,27 +22,27 @@
22
22
  ],
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@webiny/api": "6.4.12-beta.5",
26
- "@webiny/api-core": "6.4.12-beta.5",
27
- "@webiny/api-headless-cms": "6.4.12-beta.5",
28
- "@webiny/background-tasks": "6.4.12-beta.5",
29
- "@webiny/build-tools": "6.4.12-beta.5",
30
- "@webiny/error": "6.4.12-beta.5",
31
- "@webiny/feature": "6.4.12-beta.5",
32
- "@webiny/handler": "6.4.12-beta.5",
33
- "@webiny/handler-graphql": "6.4.12-beta.5",
34
- "@webiny/plugins": "6.4.12-beta.5",
35
- "@webiny/wcp": "6.4.12-beta.5",
25
+ "@webiny/api": "6.4.12-beta.7",
26
+ "@webiny/api-core": "6.4.12-beta.7",
27
+ "@webiny/api-headless-cms": "6.4.12-beta.7",
28
+ "@webiny/background-tasks": "6.4.12-beta.7",
29
+ "@webiny/build-tools": "6.4.12-beta.7",
30
+ "@webiny/error": "6.4.12-beta.7",
31
+ "@webiny/feature": "6.4.12-beta.7",
32
+ "@webiny/handler": "6.4.12-beta.7",
33
+ "@webiny/handler-graphql": "6.4.12-beta.7",
34
+ "@webiny/plugins": "6.4.12-beta.7",
35
+ "@webiny/wcp": "6.4.12-beta.7",
36
36
  "cache-control-parser": "2.2.0",
37
- "zod": "4.6.5"
37
+ "zod": "4.6.7"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/object-hash": "3.0.6",
41
- "@webiny/handler-aws": "6.4.12-beta.5",
42
- "@webiny/project-utils": "6.4.12-beta.5",
43
- "@webiny/utils": "6.4.12-beta.5",
44
- "@webiny/wcp": "6.4.12-beta.5",
45
- "rimraf": "6.1.3",
41
+ "@webiny/handler-aws": "6.4.12-beta.7",
42
+ "@webiny/project-utils": "6.4.12-beta.7",
43
+ "@webiny/utils": "6.4.12-beta.7",
44
+ "@webiny/wcp": "6.4.12-beta.7",
45
+ "rimraf": "6.1.4",
46
46
  "typescript": "6.0.3"
47
47
  },
48
48
  "publishConfig": {