@webiny/api-file-manager 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/domain/permissionsSchema.d.ts +16 -0
- package/{permissions/schema.js → domain/permissionsSchema.js} +4 -6
- package/domain/permissionsSchema.js.map +1 -0
- package/features/file/CreateFile/CreateFileUseCase.d.ts +1 -1
- package/features/file/CreateFile/CreateFileUseCase.js +2 -2
- package/features/file/CreateFile/CreateFileUseCase.js.map +1 -1
- package/features/file/CreateFile/events.d.ts +2 -2
- package/features/file/CreateFile/events.js +1 -1
- package/features/file/CreateFile/events.js.map +1 -1
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.d.ts +1 -1
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +2 -2
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -1
- package/features/file/CreateFilesInBatch/events.d.ts +2 -2
- package/features/file/CreateFilesInBatch/events.js +1 -1
- package/features/file/CreateFilesInBatch/events.js.map +1 -1
- package/features/file/DeleteFile/DeleteFileUseCase.d.ts +1 -1
- package/features/file/DeleteFile/DeleteFileUseCase.js +2 -2
- package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -1
- package/features/file/DeleteFile/events.d.ts +2 -2
- package/features/file/DeleteFile/events.js +1 -1
- package/features/file/DeleteFile/events.js.map +1 -1
- package/features/file/GetFile/GetFileUseCase.js +1 -1
- package/features/file/GetFile/GetFileUseCase.js.map +1 -1
- package/features/file/ListFiles/ListFilesUseCase.js +1 -1
- package/features/file/ListFiles/ListFilesUseCase.js.map +1 -1
- package/features/file/ListTags/ListTagsUseCase.js +1 -1
- package/features/file/ListTags/ListTagsUseCase.js.map +1 -1
- package/features/file/UpdateFile/UpdateFileUseCase.d.ts +1 -1
- package/features/file/UpdateFile/UpdateFileUseCase.js +2 -2
- package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -1
- package/features/file/UpdateFile/events.d.ts +2 -2
- package/features/file/UpdateFile/events.js +1 -1
- package/features/file/UpdateFile/events.js.map +1 -1
- package/features/permissions/abstractions.d.ts +21 -0
- package/features/permissions/abstractions.js +5 -0
- package/features/permissions/abstractions.js.map +1 -0
- package/features/permissions/feature.d.ts +1 -0
- package/features/permissions/feature.js +6 -0
- package/features/permissions/feature.js.map +1 -0
- package/features/settings/SettingsInstaller/SettingsInstaller.d.ts +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.d.ts +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
- package/features/settings/UpdateSettings/events.d.ts +2 -2
- package/features/settings/UpdateSettings/events.js +1 -1
- package/features/settings/UpdateSettings/events.js.map +1 -1
- package/features/shared/abstractions.d.ts +1 -1
- package/features/shared/abstractions.js +1 -1
- package/features/shared/abstractions.js.map +1 -1
- package/graphql/createFilesTypeDefs.d.ts +3 -2
- package/graphql/createFilesTypeDefs.js +5 -5
- package/graphql/createFilesTypeDefs.js.map +1 -1
- package/graphql/index.js +6 -5
- package/graphql/index.js.map +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/package.json +15 -15
- package/permissions/schema.d.ts +0 -74
- package/permissions/schema.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const FM_PERMISSIONS_SCHEMA: {
|
|
2
|
+
readonly prefix: "fm";
|
|
3
|
+
readonly fullAccess: true;
|
|
4
|
+
readonly entities: readonly [{
|
|
5
|
+
readonly id: "file";
|
|
6
|
+
readonly permission: "fm.file";
|
|
7
|
+
readonly scopes: readonly ["full", "own"];
|
|
8
|
+
readonly actions: readonly [{
|
|
9
|
+
readonly name: "rwd";
|
|
10
|
+
}];
|
|
11
|
+
}, {
|
|
12
|
+
readonly id: "settings";
|
|
13
|
+
readonly permission: "fm.settings";
|
|
14
|
+
readonly scopes: readonly ["full"];
|
|
15
|
+
}];
|
|
16
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
1
|
+
import { createPermissionSchema } from "@webiny/api-core/exports/api/security.js";
|
|
2
|
+
export const FM_PERMISSIONS_SCHEMA = createPermissionSchema({
|
|
3
3
|
prefix: "fm",
|
|
4
4
|
fullAccess: true,
|
|
5
5
|
entities: [{
|
|
@@ -14,8 +14,6 @@ const schema = {
|
|
|
14
14
|
permission: "fm.settings",
|
|
15
15
|
scopes: ["full"]
|
|
16
16
|
}]
|
|
17
|
-
};
|
|
18
|
-
/** File manager permission checks. */
|
|
19
|
-
export const FmPermissions = createPermissions(schema);
|
|
17
|
+
});
|
|
20
18
|
|
|
21
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=permissionsSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPermissionSchema","FM_PERMISSIONS_SCHEMA","prefix","fullAccess","entities","id","permission","scopes","actions","name"],"sources":["permissionsSchema.ts"],"sourcesContent":["import { createPermissionSchema } from \"@webiny/api-core/exports/api/security.js\";\n\nexport const FM_PERMISSIONS_SCHEMA = createPermissionSchema({\n prefix: \"fm\",\n fullAccess: true,\n entities: [\n {\n id: \"file\",\n permission: \"fm.file\",\n scopes: [\"full\", \"own\"],\n actions: [{ name: \"rwd\" }]\n },\n {\n id: \"settings\",\n permission: \"fm.settings\",\n scopes: [\"full\"]\n }\n ]\n});\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,0CAA0C;AAEjF,OAAO,MAAMC,qBAAqB,GAAGD,sBAAsB,CAAC;EACxDE,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,IAAI;EAChBC,QAAQ,EAAE,CACN;IACIC,EAAE,EAAE,MAAM;IACVC,UAAU,EAAE,SAAS;IACrBC,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACvBC,OAAO,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAM,CAAC;EAC7B,CAAC,EACD;IACIJ,EAAE,EAAE,UAAU;IACdC,UAAU,EAAE,aAAa;IACzBC,MAAM,EAAE,CAAC,MAAM;EACnB,CAAC;AAET,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateFileUseCase as UseCaseAbstraction, CreateFileInput, CreateFileRepository } from "./abstractions.js";
|
|
3
3
|
import { GetSettingsUseCase } from "../../settings/GetSettings/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import type { File } from "../../../domain/file/types.js";
|
|
6
6
|
import { FmPermissions } from "../../../features/shared/abstractions.js";
|
|
7
7
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateFileUseCase as UseCaseAbstraction, CreateFileRepository } from "./abstractions.js";
|
|
3
3
|
import { GetSettingsUseCase } from "../../settings/GetSettings/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import { FileNotAuthorizedError, InvalidFileSizeError } from "../../../domain/file/errors.js";
|
|
6
6
|
import { FileBeforeCreateEvent, FileAfterCreateEvent } from "./events.js";
|
|
7
7
|
import { FmPermissions } from "../../shared/abstractions.js";
|
|
@@ -83,7 +83,7 @@ class CreateFileUseCaseImpl {
|
|
|
83
83
|
}
|
|
84
84
|
export const CreateFileUseCase = UseCaseAbstraction.createImplementation({
|
|
85
85
|
implementation: CreateFileUseCaseImpl,
|
|
86
|
-
dependencies: [IdentityContext, FmPermissions
|
|
86
|
+
dependencies: [IdentityContext, FmPermissions, CreateFileRepository, GetSettingsUseCase, EventPublisher]
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
//# sourceMappingURL=CreateFileUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","CreateFileUseCase","UseCaseAbstraction","CreateFileRepository","GetSettingsUseCase","EventPublisher","FileNotAuthorizedError","InvalidFileSizeError","FileBeforeCreateEvent","FileAfterCreateEvent","FmPermissions","IdentityContext","Identity","CreateFileUseCaseImpl","constructor","identityContext","permissions","repository","getSettings","eventPublisher","execute","input","meta","hasPermission","canCreate","fail","validationResult","validateInput","isFail","error","id","key","split","currentIdentity","getIdentity","fileInput","name","size","type","metadata","location","folderId","tags","extensions","createdOn","modifiedOn","savedOn","createdBy","from","modifiedBy","undefined","savedBy","publish","file","result","value","ok","settingsResult","settings","uploadMinFileSize","uploadMaxFileSize","minSize","maxSize","createImplementation","implementation","dependencies"
|
|
1
|
+
{"version":3,"names":["Result","CreateFileUseCase","UseCaseAbstraction","CreateFileRepository","GetSettingsUseCase","EventPublisher","FileNotAuthorizedError","InvalidFileSizeError","FileBeforeCreateEvent","FileAfterCreateEvent","FmPermissions","IdentityContext","Identity","CreateFileUseCaseImpl","constructor","identityContext","permissions","repository","getSettings","eventPublisher","execute","input","meta","hasPermission","canCreate","fail","validationResult","validateInput","isFail","error","id","key","split","currentIdentity","getIdentity","fileInput","name","size","type","metadata","location","folderId","tags","extensions","createdOn","modifiedOn","savedOn","createdBy","from","modifiedBy","undefined","savedBy","publish","file","result","value","ok","settingsResult","settings","uploadMinFileSize","uploadMaxFileSize","minSize","maxSize","createImplementation","implementation","dependencies"],"sources":["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 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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,iBAAiB,IAAIC,kBAAkB,EAEvCC,oBAAoB;AAExB,SAASC,kBAAkB;AAC3B,SAASC,cAAc,QAAQ,mDAAmD;AAElF,SAASC,sBAAsB,EAAEC,oBAAoB;AACrD,SAASC,qBAAqB,EAAEC,oBAAoB;AACpD,SAASC,aAAa;AACtB,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,QAAQ;AAEjB,MAAMC,qBAAqB,CAAyC;EAChEC,WAAWA,CACCC,eAA0C,EAC1CC,WAAoC,EACpCC,UAA0C,EAC1CC,WAAyC,EACzCC,cAAwC,EAClD;IAAA,KALUJ,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,UAA0C,GAA1CA,UAA0C;IAAA,KAC1CC,WAAyC,GAAzCA,WAAyC;IAAA,KACzCC,cAAwC,GAAxCA,cAAwC;EACjD;EAEH,MAAMC,OAAOA,CACTC,KAAsB,EACtBC,IAA0B,EACqB;IAC/C,MAAMC,aAAa,GAAG,MA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CAACC,iBAAiB,IACvCtC,KAAK,CAACgB,IAAI,GAAGqB,QAAQ,CAACE,iBAAiB,EACzC;QACE,OAAO5D,MAAM,CAACyB,IAAI,CACd,IAAIlB,oBAAoB,CAAC;UACrB8B,IAAI,EAAEhB,KAAK,CAACgB,IAAI;UAChBwB,OAAO,EAAEH,QAAQ,CAACC,iBAAiB;UACnCG,OAAO,EAAEJ,QAAQ,CAACE;QACtB,CAAC,CACL,CAAC;MACL;IACJ;IAEA,OAAO5D,MAAM,CAACwD,EAAE,CAAC,CAAC;EACtB;AACJ;AAEA,OAAO,MAAMvD,iBAAiB,GAAGC,kBAAkB,CAAC6D,oBAAoB,CAAC;EACrEC,cAAc,EAAEnD,qBAAqB;EACrCoD,YAAY,EAAE,CACVtD,eAAe,EACfD,aAAa,EACbP,oBAAoB,EACpBC,kBAAkB,EAClBC,cAAc;AAEtB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { File, FileInput } from "../../../domain/file/types.js";
|
|
4
4
|
export interface FileBeforeCreatePayload {
|
|
5
5
|
file: FileInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// FileBeforeCreate Event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeCreateEvent","eventType","getHandlerAbstraction","FileBeforeCreateEventHandler","FileAfterCreateEvent","FileAfterCreateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeCreateEvent","eventType","getHandlerAbstraction","FileBeforeCreateEventHandler","FileAfterCreateEvent","FileAfterCreateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File, FileInput } from \"~/domain/file/types.js\";\n\n// ============================================================================\n// FileBeforeCreate Event\n// ============================================================================\n\nexport interface FileBeforeCreatePayload {\n file: FileInput;\n meta?: Record<string, any>;\n}\n\nexport class FileBeforeCreateEvent extends DomainEvent<FileBeforeCreatePayload> {\n eventType = \"FileManager/File/BeforeCreate\" as const;\n\n getHandlerAbstraction() {\n return FileBeforeCreateEventHandler;\n }\n}\n\n/** Hook into file lifecycle before a file is created. */\nexport const FileBeforeCreateEventHandler = createAbstraction<IEventHandler<FileBeforeCreateEvent>>(\n \"FileBeforeCreateEventHandler\"\n);\n\nexport namespace FileBeforeCreateEventHandler {\n export type Interface = IEventHandler<FileBeforeCreateEvent>;\n export type Event = FileBeforeCreateEvent;\n}\n\n// ============================================================================\n// FileAfterCreate Event\n// ============================================================================\n\nexport interface FileAfterCreatePayload {\n file: File;\n meta?: Record<string, any>;\n}\n\nexport class FileAfterCreateEvent extends DomainEvent<FileAfterCreatePayload> {\n eventType = \"FileManager/File/AfterCreate\" as const;\n\n getHandlerAbstraction() {\n return FileAfterCreateEventHandler;\n }\n}\n\n/** Hook into file lifecycle after a file is created. */\nexport const FileAfterCreateEventHandler = createAbstraction<IEventHandler<FileAfterCreateEvent>>(\n \"FileAfterCreateEventHandler\"\n);\n\nexport namespace FileAfterCreateEventHandler {\n export type Interface = IEventHandler<FileAfterCreateEvent>;\n export type Event = FileAfterCreateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAI/E;AACA;AACA;;AAOA,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,4BAA4B;EACvC;AACJ;;AAEA;AACA,OAAO,MAAMA,4BAA4B,GAAGL,iBAAiB,CACzD,8BACJ,CAAC;;AAOD;AACA;AACA;;AAOA,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,8BAA8B;EAE1CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,2BAA2B;EACtC;AACJ;;AAEA;AACA,OAAO,MAAMA,2BAA2B,GAAGP,iBAAiB,CACxD,6BACJ,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateFilesInBatchUseCase as UseCaseAbstraction, CreateFilesInBatchInput, CreateFilesInBatchRepository } from "./abstractions.js";
|
|
3
3
|
import { GetSettingsUseCase } from "../../settings/GetSettings/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import type { File } from "../../../domain/file/types.js";
|
|
6
6
|
import { FmPermissions } from "../../../features/shared/abstractions.js";
|
|
7
7
|
declare class CreateFilesInBatchUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateFilesInBatchUseCase as UseCaseAbstraction, CreateFilesInBatchRepository } from "./abstractions.js";
|
|
3
3
|
import { GetSettingsUseCase } from "../../settings/GetSettings/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import { FileNotAuthorizedError, InvalidFileSizeError } from "../../../domain/file/errors.js";
|
|
6
6
|
import { FileBeforeBatchCreateEvent, FileAfterBatchCreateEvent } from "./events.js";
|
|
7
7
|
import { FmPermissions } from "../../shared/abstractions.js";
|
|
@@ -78,7 +78,7 @@ class CreateFilesInBatchUseCaseImpl {
|
|
|
78
78
|
}
|
|
79
79
|
export const CreateFilesInBatchUseCase = UseCaseAbstraction.createImplementation({
|
|
80
80
|
implementation: CreateFilesInBatchUseCaseImpl,
|
|
81
|
-
dependencies: [FmPermissions
|
|
81
|
+
dependencies: [FmPermissions, CreateFilesInBatchRepository, GetSettingsUseCase, EventPublisher]
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
//# sourceMappingURL=CreateFilesInBatchUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","CreateFilesInBatchUseCase","UseCaseAbstraction","CreateFilesInBatchRepository","GetSettingsUseCase","EventPublisher","FileNotAuthorizedError","InvalidFileSizeError","FileBeforeBatchCreateEvent","FileAfterBatchCreateEvent","FmPermissions","CreateFilesInBatchUseCaseImpl","constructor","permissions","repository","getSettings","eventPublisher","execute","input","hasPermission","canCreate","fail","validationResult","validateInput","files","isFail","error","fileInputs","map","file","id","key","split","name","size","type","metadata","location","folderId","tags","extensions","meta","publish","result","createBatch","value","ok","settingsResult","settings","uploadMinFileSize","uploadMaxFileSize","minSize","maxSize","createImplementation","implementation","dependencies"
|
|
1
|
+
{"version":3,"names":["Result","CreateFilesInBatchUseCase","UseCaseAbstraction","CreateFilesInBatchRepository","GetSettingsUseCase","EventPublisher","FileNotAuthorizedError","InvalidFileSizeError","FileBeforeBatchCreateEvent","FileAfterBatchCreateEvent","FmPermissions","CreateFilesInBatchUseCaseImpl","constructor","permissions","repository","getSettings","eventPublisher","execute","input","hasPermission","canCreate","fail","validationResult","validateInput","files","isFail","error","fileInputs","map","file","id","key","split","name","size","type","metadata","location","folderId","tags","extensions","meta","publish","result","createBatch","value","ok","settingsResult","settings","uploadMinFileSize","uploadMaxFileSize","minSize","maxSize","createImplementation","implementation","dependencies"],"sources":["CreateFilesInBatchUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n CreateFilesInBatchUseCase as UseCaseAbstraction,\n CreateFilesInBatchInput,\n CreateFilesInBatchRepository\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 { FileBeforeBatchCreateEvent, FileAfterBatchCreateEvent } from \"./events.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { CreateFileInput } from \"~/features/file/CreateFile/abstractions.js\";\n\nclass CreateFilesInBatchUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private permissions: FmPermissions.Interface,\n private repository: CreateFilesInBatchRepository.Interface,\n private getSettings: GetSettingsUseCase.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n public async execute(\n input: CreateFilesInBatchInput\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 // Validate all files\n const validationResult = await this.validateInput(input.files);\n if (validationResult.isFail()) {\n return Result.fail(validationResult.error);\n }\n\n // Prepare file inputs with defaults\n const fileInputs: FileInput[] = input.files.map(file => {\n const [id] = file.key.split(\"/\");\n return {\n id: file.id || id,\n key: file.key,\n name: file.name,\n size: file.size,\n type: file.type,\n metadata: file.metadata || {},\n location: file.location || { folderId: \"root\" },\n tags: file.tags || [],\n extensions: input.meta || {}\n };\n });\n\n await this.eventPublisher.publish(\n new FileBeforeBatchCreateEvent({ files: fileInputs, meta: input.meta })\n );\n\n const result = await this.repository.createBatch(fileInputs);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new FileAfterBatchCreateEvent({ files: result.value, meta: input.meta })\n );\n\n return Result.ok(result.value);\n }\n\n private async validateInput(\n files: 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 for (const input of files) {\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\n return Result.ok();\n }\n}\n\nexport const CreateFilesInBatchUseCase = UseCaseAbstraction.createImplementation({\n implementation: CreateFilesInBatchUseCaseImpl,\n dependencies: [FmPermissions, CreateFilesInBatchRepository, GetSettingsUseCase, EventPublisher]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,yBAAyB,IAAIC,kBAAkB,EAE/CC,4BAA4B;AAEhC,SAASC,kBAAkB;AAC3B,SAASC,cAAc,QAAQ,mDAAmD;AAElF,SAASC,sBAAsB,EAAEC,oBAAoB;AACrD,SAASC,0BAA0B,EAAEC,yBAAyB;AAC9D,SAASC,aAAa;AAGtB,MAAMC,6BAA6B,CAAyC;EACjEC,WAAWA,CACNC,WAAoC,EACpCC,UAAkD,EAClDC,WAAyC,EACzCC,cAAwC,EAClD;IAAA,KAJUH,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,UAAkD,GAAlDA,UAAkD;IAAA,KAClDC,WAAyC,GAAzCA,WAAyC;IAAA,KACzCC,cAAwC,GAAxCA,cAAwC;EACjD;EAEH,MAAaC,OAAOA,CAChBC,KAA8B,EACmB;IACjD,MAAMC,a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,CAAC;EAC7EC,cAAc,EAAE3C,6BAA6B;EAC7C4C,YAAY,EAAE,CAAC7C,aAAa,EAAEP,4BAA4B,EAAEC,kBAAkB,EAAEC,cAAc;AAClG,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { File, FileInput } from "../../../domain/file/types.js";
|
|
4
4
|
export interface FileBeforeBatchCreatePayload {
|
|
5
5
|
files: FileInput[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// FileBeforeBatchCreate Event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeBatchCreateEvent","eventType","getHandlerAbstraction","FileBeforeBatchCreateEventHandler","FileAfterBatchCreateEvent","FileAfterBatchCreateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeBatchCreateEvent","eventType","getHandlerAbstraction","FileBeforeBatchCreateEventHandler","FileAfterBatchCreateEvent","FileAfterBatchCreateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File, FileInput } from \"~/domain/file/types.js\";\n\n// ============================================================================\n// FileBeforeBatchCreate Event\n// ============================================================================\n\nexport interface FileBeforeBatchCreatePayload {\n files: FileInput[];\n meta?: Record<string, any>;\n}\n\nexport class FileBeforeBatchCreateEvent extends DomainEvent<FileBeforeBatchCreatePayload> {\n eventType = \"FileManager/File/BeforeBatchCreate\" as const;\n\n getHandlerAbstraction() {\n return FileBeforeBatchCreateEventHandler;\n }\n}\n\n/** Hook into file lifecycle before files are created in batch. */\nexport const FileBeforeBatchCreateEventHandler = createAbstraction<\n IEventHandler<FileBeforeBatchCreateEvent>\n>(\"FileBeforeBatchCreateEventHandler\");\n\nexport namespace FileBeforeBatchCreateEventHandler {\n export type Interface = IEventHandler<FileBeforeBatchCreateEvent>;\n export type Event = FileBeforeBatchCreateEvent;\n}\n\n// ============================================================================\n// FileAfterBatchCreate Event\n// ============================================================================\n\nexport interface FileAfterBatchCreatePayload {\n files: File[];\n meta?: Record<string, any>;\n}\n\nexport class FileAfterBatchCreateEvent extends DomainEvent<FileAfterBatchCreatePayload> {\n eventType = \"FileManager/File/AfterBatchCreate\" as const;\n\n getHandlerAbstraction() {\n return FileAfterBatchCreateEventHandler;\n }\n}\n\n/** Hook into file lifecycle after files are created in batch. */\nexport const FileAfterBatchCreateEventHandler = createAbstraction<\n IEventHandler<FileAfterBatchCreateEvent>\n>(\"FileAfterBatchCreateEventHandler\");\n\nexport namespace FileAfterBatchCreateEventHandler {\n export type Interface = IEventHandler<FileAfterBatchCreateEvent>;\n export type Event = FileAfterBatchCreateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAI/E;AACA;AACA;;AAOA,OAAO,MAAMC,0BAA0B,SAASD,WAAW,CAA+B;EACtFE,SAAS,GAAG,oCAAoC;EAEhDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,iCAAiC;EAC5C;AACJ;;AAEA;AACA,OAAO,MAAMA,iCAAiC,GAAGL,iBAAiB,CAEhE,mCAAmC,CAAC;;AAOtC;AACA;AACA;;AAOA,OAAO,MAAMM,yBAAyB,SAASL,WAAW,CAA8B;EACpFE,SAAS,GAAG,mCAAmC;EAE/CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,gCAAgC;EAC3C;AACJ;;AAEA;AACA,OAAO,MAAMA,gCAAgC,GAAGP,iBAAiB,CAE/D,kCAAkC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { DeleteFileUseCase as UseCaseAbstraction, DeleteFileRepository } from "./abstractions.js";
|
|
3
3
|
import { GetFileUseCase } from "../GetFile/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import { FmPermissions } from "../../../features/shared/abstractions.js";
|
|
6
6
|
declare class DeleteFileUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
7
|
private permissions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { DeleteFileUseCase as UseCaseAbstraction, DeleteFileRepository } from "./abstractions.js";
|
|
3
3
|
import { GetFileUseCase } from "../GetFile/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import { FileNotAuthorizedError } from "../../../domain/file/errors.js";
|
|
6
6
|
import { FileBeforeDeleteEvent, FileAfterDeleteEvent } from "./events.js";
|
|
7
7
|
import { FmPermissions } from "../../shared/abstractions.js";
|
|
@@ -39,7 +39,7 @@ class DeleteFileUseCaseImpl {
|
|
|
39
39
|
}
|
|
40
40
|
export const DeleteFileUseCase = UseCaseAbstraction.createImplementation({
|
|
41
41
|
implementation: DeleteFileUseCaseImpl,
|
|
42
|
-
dependencies: [FmPermissions
|
|
42
|
+
dependencies: [FmPermissions, GetFileUseCase, DeleteFileRepository, EventPublisher]
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
//# sourceMappingURL=DeleteFileUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","DeleteFileUseCase","UseCaseAbstraction","DeleteFileRepository","GetFileUseCase","EventPublisher","FileNotAuthorizedError","FileBeforeDeleteEvent","FileAfterDeleteEvent","FmPermissions","DeleteFileUseCaseImpl","constructor","permissions","getFile","repository","eventPublisher","execute","id","hasPermission","canDelete","fail","getResult","isFail","error","file","value","publish","result","delete","ok","createImplementation","implementation","dependencies"
|
|
1
|
+
{"version":3,"names":["Result","DeleteFileUseCase","UseCaseAbstraction","DeleteFileRepository","GetFileUseCase","EventPublisher","FileNotAuthorizedError","FileBeforeDeleteEvent","FileAfterDeleteEvent","FmPermissions","DeleteFileUseCaseImpl","constructor","permissions","getFile","repository","eventPublisher","execute","id","hasPermission","canDelete","fail","getResult","isFail","error","file","value","publish","result","delete","ok","createImplementation","implementation","dependencies"],"sources":["DeleteFileUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteFileUseCase as UseCaseAbstraction, DeleteFileRepository } from \"./abstractions.js\";\nimport { GetFileUseCase } from \"../GetFile/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FileBeforeDeleteEvent, FileAfterDeleteEvent } from \"./events.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\n\nclass DeleteFileUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private getFile: GetFileUseCase.Interface,\n private repository: DeleteFileRepository.Interface,\n private eventPublisher: EventPublisher.Interface\n ) {}\n\n async execute(id: string): Promise<Result<void, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canDelete(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n // Get file (includes ownership check)\n const getResult = await this.getFile.execute(id);\n if (getResult.isFail()) {\n return Result.fail(getResult.error);\n }\n\n const file = getResult.value;\n\n await this.eventPublisher.publish(new FileBeforeDeleteEvent({ file }));\n\n const result = await this.repository.delete(file);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(new FileAfterDeleteEvent({ file }));\n\n return Result.ok();\n }\n}\n\nexport const DeleteFileUseCase = UseCaseAbstraction.createImplementation({\n implementation: DeleteFileUseCaseImpl,\n dependencies: [FmPermissions, GetFileUseCase, DeleteFileRepository, EventPublisher]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,iBAAiB,IAAIC,kBAAkB,EAAEC,oBAAoB;AACtE,SAASC,cAAc;AACvB,SAASC,cAAc,QAAQ,mDAAmD;AAClF,SAASC,sBAAsB;AAC/B,SAASC,qBAAqB,EAAEC,oBAAoB;AACpD,SAASC,aAAa;AAEtB,MAAMC,qBAAqB,CAAyC;EAChEC,WAAWA,CACCC,WAAoC,EACpCC,OAAiC,EACjCC,UAA0C,EAC1CC,cAAwC,EAClD;IAAA,KAJUH,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,OAAiC,GAAjCA,OAAiC;IAAA,KACjCC,UAA0C,GAA1CA,UAA0C;IAAA,KAC1CC,cAAwC,GAAxCA,cAAwC;EACjD;EAEH,MAAMC,OAAOA,CAACC,EAAU,EAAmD;IACvE,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACN,WAAW,CAACO,SAAS,CAAC,MAAM,CAAC;IAC9D,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOlB,MAAM,CAACoB,IAAI,CAAC,IAAId,sBAAsB,CAAC,CAAC,CAAC;IACpD;;IAEA;IACA,MAAMe,SAAS,GAAG,MAAM,IAAI,CAACR,OAAO,CAACG,OAAO,CAACC,EAAE,CAAC;IAChD,IAAII,SAAS,CAACC,MAAM,CAAC,CAAC,EAAE;MACpB,OAAOtB,MAAM,CAACoB,IAAI,CAACC,SAAS,CAACE,KAAK,CAAC;IACvC;IAEA,MAAMC,IAAI,GAAGH,SAAS,CAACI,KAAK;IAE5B,MAAM,IAAI,CAACV,cAAc,CAACW,OAAO,CAAC,IAAInB,qBAAqB,CAAC;MAAEiB;IAAK,CAAC,CAAC,CAAC;IAEtE,MAAMG,MAAM,GAAG,MAAM,IAAI,CAACb,UAAU,CAACc,MAAM,CAACJ,IAAI,CAAC;IAEjD,IAAIG,MAAM,CAACL,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOtB,MAAM,CAACoB,IAAI,CAACO,MAAM,CAACJ,KAAK,CAAC;IACpC;IAEA,MAAM,IAAI,CAACR,cAAc,CAACW,OAAO,CAAC,IAAIlB,oBAAoB,CAAC;MAAEgB;IAAK,CAAC,CAAC,CAAC;IAErE,OAAOxB,MAAM,CAAC6B,EAAE,CAAC,CAAC;EACtB;AACJ;AAEA,OAAO,MAAM5B,iBAAiB,GAAGC,kBAAkB,CAAC4B,oBAAoB,CAAC;EACrEC,cAAc,EAAErB,qBAAqB;EACrCsB,YAAY,EAAE,CAACvB,aAAa,EAAEL,cAAc,EAAED,oBAAoB,EAAEE,cAAc;AACtF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { File } from "../../../domain/file/types.js";
|
|
4
4
|
export interface FileBeforeDeletePayload {
|
|
5
5
|
file: File;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// FileBeforeDelete Event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeDeleteEvent","eventType","getHandlerAbstraction","FileBeforeDeleteEventHandler","FileAfterDeleteEvent","FileAfterDeleteEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeDeleteEvent","eventType","getHandlerAbstraction","FileBeforeDeleteEventHandler","FileAfterDeleteEvent","FileAfterDeleteEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File } from \"~/domain/file/types.js\";\n\n// ============================================================================\n// FileBeforeDelete Event\n// ============================================================================\n\nexport interface FileBeforeDeletePayload {\n file: File;\n}\n\nexport class FileBeforeDeleteEvent extends DomainEvent<FileBeforeDeletePayload> {\n eventType = \"FileManager/File/BeforeDelete\" as const;\n\n getHandlerAbstraction() {\n return FileBeforeDeleteEventHandler;\n }\n}\n\n/** Hook into file lifecycle before a file is deleted. */\nexport const FileBeforeDeleteEventHandler = createAbstraction<IEventHandler<FileBeforeDeleteEvent>>(\n \"FileBeforeDeleteEventHandler\"\n);\n\nexport namespace FileBeforeDeleteEventHandler {\n export type Interface = IEventHandler<FileBeforeDeleteEvent>;\n export type Event = FileBeforeDeleteEvent;\n}\n\n// ============================================================================\n// FileAfterDelete Event\n// ============================================================================\n\nexport interface FileAfterDeletePayload {\n file: File;\n}\n\nexport class FileAfterDeleteEvent extends DomainEvent<FileAfterDeletePayload> {\n eventType = \"FileManager/File/AfterDelete\" as const;\n\n getHandlerAbstraction() {\n return FileAfterDeleteEventHandler;\n }\n}\n\n/** Hook into file lifecycle after a file is deleted. */\nexport const FileAfterDeleteEventHandler = createAbstraction<IEventHandler<FileAfterDeleteEvent>>(\n \"FileAfterDeleteEventHandler\"\n);\n\nexport namespace FileAfterDeleteEventHandler {\n export type Interface = IEventHandler<FileAfterDeleteEvent>;\n export type Event = FileAfterDeleteEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAI/E;AACA;AACA;;AAMA,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,4BAA4B;EACvC;AACJ;;AAEA;AACA,OAAO,MAAMA,4BAA4B,GAAGL,iBAAiB,CACzD,8BACJ,CAAC;;AAOD;AACA;AACA;;AAMA,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,8BAA8B;EAE1CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,2BAA2B;EACtC;AACJ;;AAEA;AACA,OAAO,MAAMA,2BAA2B,GAAGP,iBAAiB,CACxD,6BACJ,CAAC","ignoreList":[]}
|
|
@@ -25,7 +25,7 @@ class GetFileUseCaseImpl {
|
|
|
25
25
|
}
|
|
26
26
|
export const GetFileUseCase = UseCaseAbstraction.createImplementation({
|
|
27
27
|
implementation: GetFileUseCaseImpl,
|
|
28
|
-
dependencies: [FmPermissions
|
|
28
|
+
dependencies: [FmPermissions, GetFileRepository]
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
//# sourceMappingURL=GetFileUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","GetFileUseCase","UseCaseAbstraction","GetFileRepository","FileNotAuthorizedError","FmPermissions","GetFileUseCaseImpl","constructor","permissions","repository","execute","id","hasPermission","canRead","fail","result","isFail","error","file","value","canAccess","ok","createImplementation","implementation","dependencies"
|
|
1
|
+
{"version":3,"names":["Result","GetFileUseCase","UseCaseAbstraction","GetFileRepository","FileNotAuthorizedError","FmPermissions","GetFileUseCaseImpl","constructor","permissions","repository","execute","id","hasPermission","canRead","fail","result","isFail","error","file","value","canAccess","ok","createImplementation","implementation","dependencies"],"sources":["GetFileUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetFileUseCase as UseCaseAbstraction, GetFileRepository } from \"./abstractions.js\";\nimport type { File } from \"~/domain/file/types.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\n\nclass GetFileUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private repository: GetFileRepository.Interface\n ) {}\n\n async execute(id: string): Promise<Result<File, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canRead(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const result = await this.repository.execute(id);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const file = result.value;\n\n if (!(await this.permissions.canAccess(\"file\", file))) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n return Result.ok(file);\n }\n}\n\nexport const GetFileUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetFileUseCaseImpl,\n dependencies: [FmPermissions, GetFileRepository]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,cAAc,IAAIC,kBAAkB,EAAEC,iBAAiB;AAEhE,SAASC,sBAAsB;AAC/B,SAASC,aAAa;AAEtB,MAAMC,kBAAkB,CAAyC;EAC7DC,WAAWA,CACCC,WAAoC,EACpCC,UAAuC,EACjD;IAAA,KAFUD,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,UAAuC,GAAvCA,UAAuC;EAChD;EAEH,MAAMC,OAAOA,CAACC,EAAU,EAAmD;IACvE,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACJ,WAAW,CAACK,OAAO,CAAC,MAAM,CAAC;IAC5D,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOZ,MAAM,CAACc,IAAI,CAAC,IAAIV,sBAAsB,CAAC,CAAC,CAAC;IACpD;IAEA,MAAMW,MAAM,GAAG,MAAM,IAAI,CAACN,UAAU,CAACC,OAAO,CAACC,EAAE,CAAC;IAEhD,IAAII,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOhB,MAAM,CAACc,IAAI,CAACC,MAAM,CAACE,KAAK,CAAC;IACpC;IAEA,MAAMC,IAAI,GAAGH,MAAM,CAACI,KAAK;IAEzB,IAAI,EAAE,MAAM,IAAI,CAACX,WAAW,CAACY,SAAS,CAAC,MAAM,EAAEF,IAAI,CAAC,CAAC,EAAE;MACnD,OAAOlB,MAAM,CAACc,IAAI,CAAC,IAAIV,sBAAsB,CAAC,CAAC,CAAC;IACpD;IAEA,OAAOJ,MAAM,CAACqB,EAAE,CAACH,IAAI,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMjB,cAAc,GAAGC,kBAAkB,CAACoB,oBAAoB,CAAC;EAClEC,cAAc,EAAEjB,kBAAkB;EAClCkB,YAAY,EAAE,CAACnB,aAAa,EAAEF,iBAAiB;AACnD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -39,7 +39,7 @@ class ListFilesUseCaseImpl {
|
|
|
39
39
|
}
|
|
40
40
|
export const ListFilesUseCase = UseCaseAbstraction.createImplementation({
|
|
41
41
|
implementation: ListFilesUseCaseImpl,
|
|
42
|
-
dependencies: [FmPermissions
|
|
42
|
+
dependencies: [FmPermissions, IdentityContext, ListFilesRepository]
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
//# sourceMappingURL=ListFilesUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","ListFilesUseCase","UseCaseAbstraction","ListFilesRepository","FileNotAuthorizedError","FmPermissions","IdentityContext","ListFilesUseCaseImpl","constructor","permissions","identityContext","repository","execute","input","hasPermission","canRead","fail","where","onlyOwnRecords","identity","getIdentity","createdBy","id","result","limit","sort","length","isFail","error","ok","value","createImplementation","implementation","dependencies"
|
|
1
|
+
{"version":3,"names":["Result","ListFilesUseCase","UseCaseAbstraction","ListFilesRepository","FileNotAuthorizedError","FmPermissions","IdentityContext","ListFilesUseCaseImpl","constructor","permissions","identityContext","repository","execute","input","hasPermission","canRead","fail","where","onlyOwnRecords","identity","getIdentity","createdBy","id","result","limit","sort","length","isFail","error","ok","value","createImplementation","implementation","dependencies"],"sources":["ListFilesUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListFilesUseCase as UseCaseAbstraction,\n ListFilesInput,\n ListFilesOutput,\n ListFilesRepository\n} from \"./abstractions.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\n\nclass ListFilesUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private identityContext: IdentityContext.Interface,\n private repository: ListFilesRepository.Interface\n ) {}\n\n async execute(\n input: ListFilesInput\n ): Promise<Result<ListFilesOutput, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canRead(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n // Build where clause.\n const where: ListFilesInput[\"where\"] = {\n ...(input.where || {})\n };\n\n // Filter by createdBy if user can only access own records.\n if (await this.permissions.onlyOwnRecords(\"file\")) {\n const identity = this.identityContext.getIdentity();\n where.createdBy = identity.id;\n }\n\n const result = await this.repository.execute({\n ...input,\n where,\n limit: input.limit || 40,\n sort: input.sort && input.sort.length > 0 ? input.sort : [\"id_DESC\"]\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const ListFilesUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListFilesUseCaseImpl,\n dependencies: [FmPermissions, IdentityContext, ListFilesRepository]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,gBAAgB,IAAIC,kBAAkB,EAGtCC,mBAAmB;AAEvB,SAASC,sBAAsB;AAC/B,SAASC,aAAa;AACtB,SAASC,eAAe,QAAQ,6DAA6D;AAE7F,MAAMC,oBAAoB,CAAyC;EAC/DC,WAAWA,CACCC,WAAoC,EACpCC,eAA0C,EAC1CC,UAAyC,EACnD;IAAA,KAHUF,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,UAAyC,GAAzCA,UAAyC;EAClD;EAEH,MAAMC,OAAOA,CACTC,KAAqB,EACqC;IAC1D,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACL,WAAW,CAACM,OAAO,CAAC,MAAM,CAAC;IAC5D,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOd,MAAM,CAACgB,IAAI,CAAC,IAAIZ,sBAAsB,CAAC,CAAC,CAAC;IACpD;;IAEA;IACA,MAAMa,KAA8B,GAAG;MACnC,IAAIJ,KAAK,CAACI,KAAK,IAAI,CAAC,CAAC;IACzB,CAAC;;IAED;IACA,IAAI,MAAM,IAAI,CAACR,WAAW,CAACS,cAAc,CAAC,MAAM,CAAC,EAAE;MAC/C,MAAMC,QAAQ,GAAG,IAAI,CAACT,eAAe,CAACU,WAAW,CAAC,CAAC;MACnDH,KAAK,CAACI,SAAS,GAAGF,QAAQ,CAACG,EAAE;IACjC;IAEA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACZ,UAAU,CAACC,OAAO,CAAC;MACzC,GAAGC,KAAK;MACRI,KAAK;MACLO,KAAK,EAAEX,KAAK,CAACW,KAAK,IAAI,EAAE;MACxBC,IAAI,EAAEZ,KAAK,CAACY,IAAI,IAAIZ,KAAK,CAACY,IAAI,CAACC,MAAM,GAAG,CAAC,GAAGb,KAAK,CAACY,IAAI,GAAG,CAAC,SAAS;IACvE,CAAC,CAAC;IAEF,IAAIF,MAAM,CAACI,MAAM,CAAC,CAAC,EAAE;MACjB,OAAO3B,MAAM,CAACgB,IAAI,CAACO,MAAM,CAACK,KAAK,CAAC;IACpC;IAEA,OAAO5B,MAAM,CAAC6B,EAAE,CAACN,MAAM,CAACO,KAAK,CAAC;EAClC;AACJ;AAEA,OAAO,MAAM7B,gBAAgB,GAAGC,kBAAkB,CAAC6B,oBAAoB,CAAC;EACpEC,cAAc,EAAEzB,oBAAoB;EACpC0B,YAAY,EAAE,CAAC5B,aAAa,EAAEC,eAAe,EAAEH,mBAAmB;AACtE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -25,7 +25,7 @@ class ListTagsUseCaseImpl {
|
|
|
25
25
|
}
|
|
26
26
|
export const ListTagsUseCase = UseCaseAbstraction.createImplementation({
|
|
27
27
|
implementation: ListTagsUseCaseImpl,
|
|
28
|
-
dependencies: [FmPermissions
|
|
28
|
+
dependencies: [FmPermissions, ListTagsRepository]
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
//# sourceMappingURL=ListTagsUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","ListTagsUseCase","UseCaseAbstraction","ListTagsRepository","FileNotAuthorizedError","FmPermissions","ListTagsUseCaseImpl","constructor","permissions","repository","execute","input","hasPermission","canAccess","fail","enrichedInput","limit","result","isFail","error","ok","value","createImplementation","implementation","dependencies"
|
|
1
|
+
{"version":3,"names":["Result","ListTagsUseCase","UseCaseAbstraction","ListTagsRepository","FileNotAuthorizedError","FmPermissions","ListTagsUseCaseImpl","constructor","permissions","repository","execute","input","hasPermission","canAccess","fail","enrichedInput","limit","result","isFail","error","ok","value","createImplementation","implementation","dependencies"],"sources":["ListTagsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListTagsUseCase as UseCaseAbstraction,\n ListTagsInput,\n TagItem,\n ListTagsRepository\n} from \"./abstractions.js\";\nimport { FileNotAuthorizedError } from \"~/domain/file/errors.js\";\nimport { FmPermissions } from \"~/features/shared/abstractions.js\";\n\nclass ListTagsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private permissions: FmPermissions.Interface,\n private repository: ListTagsRepository.Interface\n ) {}\n\n async execute(input: ListTagsInput): Promise<Result<TagItem[], UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canAccess(\"file\");\n if (!hasPermission) {\n return Result.fail(new FileNotAuthorizedError());\n }\n\n const enrichedInput: ListTagsInput = {\n ...input,\n limit: input.limit || 1000000\n };\n\n const result = await this.repository.execute(enrichedInput);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const ListTagsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListTagsUseCaseImpl,\n dependencies: [FmPermissions, ListTagsRepository]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,eAAe,IAAIC,kBAAkB,EAGrCC,kBAAkB;AAEtB,SAASC,sBAAsB;AAC/B,SAASC,aAAa;AAEtB,MAAMC,mBAAmB,CAAyC;EAC9DC,WAAWA,CACCC,WAAoC,EACpCC,UAAwC,EAClD;IAAA,KAFUD,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,UAAwC,GAAxCA,UAAwC;EACjD;EAEH,MAAMC,OAAOA,CAACC,KAAoB,EAAwD;IACtF,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACJ,WAAW,CAACK,SAAS,CAAC,MAAM,CAAC;IAC9D,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOZ,MAAM,CAACc,IAAI,CAAC,IAAIV,sBAAsB,CAAC,CAAC,CAAC;IACpD;IAEA,MAAMW,aAA4B,GAAG;MACjC,GAAGJ,KAAK;MACRK,KAAK,EAAEL,KAAK,CAACK,KAAK,IAAI;IAC1B,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACR,UAAU,CAACC,OAAO,CAACK,aAAa,CAAC;IAE3D,IAAIE,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOlB,MAAM,CAACc,IAAI,CAACG,MAAM,CAACE,KAAK,CAAC;IACpC;IAEA,OAAOnB,MAAM,CAACoB,EAAE,CAACH,MAAM,CAACI,KAAK,CAAC;EAClC;AACJ;AAEA,OAAO,MAAMpB,eAAe,GAAGC,kBAAkB,CAACoB,oBAAoB,CAAC;EACnEC,cAAc,EAAEjB,mBAAmB;EACnCkB,YAAY,EAAE,CAACnB,aAAa,EAAEF,kBAAkB;AACpD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateFileUseCase as UseCaseAbstraction, UpdateFileInput, UpdateFileRepository } from "./abstractions.js";
|
|
3
3
|
import { GetFileUseCase } from "../GetFile/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import type { File } from "../../../domain/file/types.js";
|
|
6
6
|
import { FmPermissions } from "../../../features/shared/abstractions.js";
|
|
7
7
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateFileUseCase as UseCaseAbstraction, UpdateFileRepository } from "./abstractions.js";
|
|
3
3
|
import { GetFileUseCase } from "../GetFile/abstractions.js";
|
|
4
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
4
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
5
5
|
import { FileNotAuthorizedError } from "../../../domain/file/errors.js";
|
|
6
6
|
import { FileBeforeUpdateEvent, FileAfterUpdateEvent } from "./events.js";
|
|
7
7
|
import { FmPermissions } from "../../shared/abstractions.js";
|
|
@@ -72,7 +72,7 @@ class UpdateFileUseCaseImpl {
|
|
|
72
72
|
}
|
|
73
73
|
export const UpdateFileUseCase = UseCaseAbstraction.createImplementation({
|
|
74
74
|
implementation: UpdateFileUseCaseImpl,
|
|
75
|
-
dependencies: [IdentityContext, FmPermissions
|
|
75
|
+
dependencies: [IdentityContext, FmPermissions, GetFileUseCase, UpdateFileRepository, EventPublisher]
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
//# sourceMappingURL=UpdateFileUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","UpdateFileUseCase","UseCaseAbstraction","UpdateFileRepository","GetFileUseCase","EventPublisher","FileNotAuthorizedError","FileBeforeUpdateEvent","FileAfterUpdateEvent","FmPermissions","IdentityContext","Identity","UpdateFileUseCaseImpl","constructor","identityContext","permissions","getFile","repository","eventPublisher","execute","input","hasPermission","canEdit","fail","getResult","id","isFail","error","original","value","canEditFile","currentIdentity","getIdentity","file","key","size","type","tags","undefined","location","createdOn","modifiedOn","savedOn","createdBy","from","modifiedBy","savedBy","publish","result","update","ok","createImplementation","implementation","dependencies"
|
|
1
|
+
{"version":3,"names":["Result","UpdateFileUseCase","UseCaseAbstraction","UpdateFileRepository","GetFileUseCase","EventPublisher","FileNotAuthorizedError","FileBeforeUpdateEvent","FileAfterUpdateEvent","FmPermissions","IdentityContext","Identity","UpdateFileUseCaseImpl","constructor","identityContext","permissions","getFile","repository","eventPublisher","execute","input","hasPermission","canEdit","fail","getResult","id","isFail","error","original","value","canEditFile","currentIdentity","getIdentity","file","key","size","type","tags","undefined","location","createdOn","modifiedOn","savedOn","createdBy","from","modifiedBy","savedBy","publish","result","update","ok","createImplementation","implementation","dependencies"],"sources":["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 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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,iBAAiB,IAAIC,kBAAkB,EAEvCC,oBAAoB;AAExB,SAASC,cAAc;AACvB,SAASC,cAAc,QAAQ,mDAAmD;AAElF,SAASC,sBAAsB;AAC/B,SAASC,qBAAqB,EAAEC,oBAAoB;AACpD,SAASC,aAAa;AACtB,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,QAAQ;AAEjB,MAAMC,qBAAqB,CAAyC;EAChEC,WAAWA,CACCC,eAA0C,EAC1CC,WAAoC,EACpCC,OAAiC,EACjCC,UAA0C,EAC1CC,cAAwC,EAClD;IAAA,KALUJ,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,WAAoC,GAApCA,WAAoC;IAAA,KACpCC,OAAiC,GAAjCA,OAAiC;IAAA,KACjCC,UAA0C,GAA1CA,UAA0C;IAAA,KAC1CC,cAAwC,GAAxCA,cAAwC;EACjD;EAEH,MAAMC,OAAOA,CAACC,KAAsB,EAAmD;IACnF,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACN,WAAW,CAACO,OAAO,CAAC,MAAM,CAAC;IAC5D,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOrB,MAAM,CAACuB,IAAI,CAAC,IAAIjB,sBAAsB,CAAC,CAAC,CAAC;IACpD;;IAEA;IACA,MAAMkB,SAAS,GAAG,M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ACxB,KAAK,CAACuB,SAAS,CAAC,GAAGf,QAAQ,CAACe,SAAS;MAChFE,UAAU,EAAEzB,KAAK,CAACyB,UAAU,GACtBlC,QAAQ,CAACiC,IAAI,CAACxB,KAAK,CAACyB,UAAU,CAAC,GAC/BlC,QAAQ,CAACiC,IAAI,CAACb,eAAe,CAAC;MACpCe,OAAO,EAAE1B,KAAK,CAAC0B,OAAO,GAAGnC,QAAQ,CAACiC,IAAI,CAACxB,KAAK,CAAC0B,OAAO,CAAC,GAAGnC,QAAQ,CAACiC,IAAI,CAACb,eAAe;IACzF,CAAC;IAED,MAAM,IAAI,CAACb,cAAc,CAAC6B,OAAO,CAAC,IAAIxC,qBAAqB,CAAC;MAAEqB,QAAQ;MAAEK,IAAI;MAAEb;IAAM,CAAC,CAAC,CAAC;IAEvF,MAAM4B,MAAM,GAAG,MAAM,IAAI,CAAC/B,UAAU,CAACgC,MAAM,CAAChB,IAAI,CAAC;IAEjD,IAAIe,MAAM,CAACtB,MAAM,CAAC,CAAC,EAAE;MACjB,OAAO1B,MAAM,CAACuB,IAAI,CAACyB,MAAM,CAACrB,KAAK,CAAC;IACpC;IAEA,MAAM,IAAI,CAACT,cAAc,CAAC6B,OAAO,CAAC,IAAIvC,oBAAoB,CAAC;MAAEoB,QAAQ;MAAEK,IAAI;MAAEb;IAAM,CAAC,CAAC,CAAC;IAEtF,OAAOpB,MAAM,CAACkD,EAAE,CAACjB,IAAI,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMhC,iBAAiB,GAAGC,kBAAkB,CAACiD,oBAAoB,CAAC;EACrEC,cAAc,EAAExC,qBAAqB;EACrCyC,YAAY,EAAE,CACV3C,eAAe,EACfD,aAAa,EACbL,cAAc,EACdD,oBAAoB,EACpBE,cAAc;AAEtB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { File } from "../../../domain/file/types.js";
|
|
4
4
|
import type { UpdateFileInput } from "./abstractions.js";
|
|
5
5
|
export interface FileBeforeUpdatePayload {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// FileBeforeUpdate Event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeUpdateEvent","eventType","getHandlerAbstraction","FileBeforeUpdateEventHandler","FileAfterUpdateEvent","FileAfterUpdateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","FileBeforeUpdateEvent","eventType","getHandlerAbstraction","FileBeforeUpdateEventHandler","FileAfterUpdateEvent","FileAfterUpdateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { File } from \"~/domain/file/types.js\";\nimport type { UpdateFileInput } from \"./abstractions.js\";\n\n// ============================================================================\n// FileBeforeUpdate Event\n// ============================================================================\n\nexport interface FileBeforeUpdatePayload {\n original: File;\n file: File;\n input: UpdateFileInput;\n}\n\nexport class FileBeforeUpdateEvent extends DomainEvent<FileBeforeUpdatePayload> {\n eventType = \"FileManager/File/BeforeUpdate\" as const;\n\n getHandlerAbstraction() {\n return FileBeforeUpdateEventHandler;\n }\n}\n\n/** Hook into file lifecycle before a file is updated. */\nexport const FileBeforeUpdateEventHandler = createAbstraction<IEventHandler<FileBeforeUpdateEvent>>(\n \"FileBeforeUpdateEventHandler\"\n);\n\nexport namespace FileBeforeUpdateEventHandler {\n export type Interface = IEventHandler<FileBeforeUpdateEvent>;\n export type Event = FileBeforeUpdateEvent;\n}\n\n// ============================================================================\n// FileAfterUpdate Event\n// ============================================================================\n\nexport interface FileAfterUpdatePayload {\n original: File;\n file: File;\n input: UpdateFileInput;\n}\n\nexport class FileAfterUpdateEvent extends DomainEvent<FileAfterUpdatePayload> {\n eventType = \"FileManager/File/AfterUpdate\" as const;\n\n getHandlerAbstraction() {\n return FileAfterUpdateEventHandler;\n }\n}\n\n/** Hook into file lifecycle after a file is updated. */\nexport const FileAfterUpdateEventHandler = createAbstraction<IEventHandler<FileAfterUpdateEvent>>(\n \"FileAfterUpdateEventHandler\"\n);\n\nexport namespace FileAfterUpdateEventHandler {\n export type Interface = IEventHandler<FileAfterUpdateEvent>;\n export type Event = FileAfterUpdateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAQA,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,4BAA4B;EACvC;AACJ;;AAEA;AACA,OAAO,MAAMA,4BAA4B,GAAGL,iBAAiB,CACzD,8BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,8BAA8B;EAE1CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,2BAA2B;EACtC;AACJ;;AAEA;AACA,OAAO,MAAMA,2BAA2B,GAAGP,iBAAiB,CACxD,6BACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Permissions } from "@webiny/api-core/features/security/permissions/index.js";
|
|
2
|
+
import { FM_PERMISSIONS_SCHEMA } from "../../domain/permissionsSchema.js";
|
|
3
|
+
export declare const FmPermissions: import("@webiny/di").Abstraction<import("@webiny/api-core/features/security/permissions/types").PermissionsTyped<{
|
|
4
|
+
readonly prefix: "fm";
|
|
5
|
+
readonly fullAccess: true;
|
|
6
|
+
readonly entities: readonly [{
|
|
7
|
+
readonly id: "file";
|
|
8
|
+
readonly permission: "fm.file";
|
|
9
|
+
readonly scopes: readonly ["full", "own"];
|
|
10
|
+
readonly actions: readonly [{
|
|
11
|
+
readonly name: "rwd";
|
|
12
|
+
}];
|
|
13
|
+
}, {
|
|
14
|
+
readonly id: "settings";
|
|
15
|
+
readonly permission: "fm.settings";
|
|
16
|
+
readonly scopes: readonly ["full"];
|
|
17
|
+
}];
|
|
18
|
+
}>>;
|
|
19
|
+
export declare namespace FmPermissions {
|
|
20
|
+
type Interface = Permissions<typeof FM_PERMISSIONS_SCHEMA>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createPermissionsAbstraction } from "@webiny/api-core/features/security/permissions/index.js";
|
|
2
|
+
import { FM_PERMISSIONS_SCHEMA } from "../../domain/permissionsSchema.js";
|
|
3
|
+
export const FmPermissions = createPermissionsAbstraction(FM_PERMISSIONS_SCHEMA);
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPermissionsAbstraction","FM_PERMISSIONS_SCHEMA","FmPermissions"],"sources":["abstractions.ts"],"sourcesContent":["import { createPermissionsAbstraction } from \"@webiny/api-core/features/security/permissions/index.js\";\nimport type { Permissions } from \"@webiny/api-core/features/security/permissions/index.js\";\nimport { FM_PERMISSIONS_SCHEMA } from \"~/domain/permissionsSchema.js\";\n\nexport const FmPermissions = createPermissionsAbstraction(FM_PERMISSIONS_SCHEMA);\n\nexport namespace FmPermissions {\n export type Interface = Permissions<typeof FM_PERMISSIONS_SCHEMA>;\n}\n"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,yDAAyD;AAEtG,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,aAAa,GAAGF,4BAA4B,CAACC,qBAAqB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FmPermissionsFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createPermissionsFeature } from "@webiny/api-core/exports/api/security.js";
|
|
2
|
+
import { FM_PERMISSIONS_SCHEMA } from "../../domain/permissionsSchema.js";
|
|
3
|
+
import { FmPermissions } from "./abstractions.js";
|
|
4
|
+
export const FmPermissionsFeature = createPermissionsFeature(FM_PERMISSIONS_SCHEMA, FmPermissions);
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPermissionsFeature","FM_PERMISSIONS_SCHEMA","FmPermissions","FmPermissionsFeature"],"sources":["feature.ts"],"sourcesContent":["import { createPermissionsFeature } from \"@webiny/api-core/exports/api/security.js\";\nimport { FM_PERMISSIONS_SCHEMA } from \"~/domain/permissionsSchema.js\";\nimport { FmPermissions } from \"./abstractions.js\";\n\nexport const FmPermissionsFeature = createPermissionsFeature(FM_PERMISSIONS_SCHEMA, FmPermissions);\n"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,0CAA0C;AACnF,SAASC,qBAAqB;AAC9B,SAASC,aAAa;AAEtB,OAAO,MAAMC,oBAAoB,GAAGH,wBAAwB,CAACC,qBAAqB,EAAEC,aAAa,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppInstaller } from "@webiny/api-core/features/InstallTenant";
|
|
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
4
|
declare class SettingsInstallerImpl implements AppInstaller.Interface {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServiceDiscovery } from "@webiny/api";
|
|
2
2
|
import { createImplementation } from "@webiny/feature/api";
|
|
3
|
-
import { AppInstaller } from "@webiny/api-core/features/InstallTenant";
|
|
3
|
+
import { AppInstaller } from "@webiny/api-core/features/tenancy/InstallTenant/index.js";
|
|
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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServiceDiscovery","createImplementation","AppInstaller","FILE_MANAGER_GENERAL_SETTINGS","UpdateSettingsUseCase","KeyValueStore","SettingsInstallerImpl","alwaysRun","appName","dependsOn","constructor","updateSettings","keyValueStore","install","manifest","load","domain","api","cloudfront","execute","srcPrefix","uninstall","delete","SettingsInstaller","abstraction","implementation","dependencies"],"sources":["SettingsInstaller.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { AppInstaller } from \"@webiny/api-core/features/InstallTenant\";\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 const { domain } = manifest?.api.cloudfront;\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"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,YAAY,QAAQ,
|
|
1
|
+
{"version":3,"names":["ServiceDiscovery","createImplementation","AppInstaller","FILE_MANAGER_GENERAL_SETTINGS","UpdateSettingsUseCase","KeyValueStore","SettingsInstallerImpl","alwaysRun","appName","dependsOn","constructor","updateSettings","keyValueStore","install","manifest","load","domain","api","cloudfront","execute","srcPrefix","uninstall","delete","SettingsInstaller","abstraction","implementation","dependencies"],"sources":["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 const { domain } = manifest?.api.cloudfront;\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"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,YAAY,QAAQ,0DAA0D;AACvF,SAASC,6BAA6B;AACtC,SAASC,qBAAqB;AAC9B,SAASC,aAAa,QAAQ,kDAAkD;AAEhF,MAAMC,qBAAqB,CAAmC;EACjDC,SAAS,GAAG,IAAI;EAChBC,OAAO,GAAG,aAAa;EACvBC,SAAS,GAAG,EAAE;EAEvBC,WAAWA,CACCC,cAA+C,EAC/CC,aAAsC,EAChD;IAAA,KAFUD,cAA+C,GAA/CA,cAA+C;IAAA,KAC/CC,aAAsC,GAAtCA,aAAsC;EAC/C;EAEH,MAAMC,OAAOA,CAAA,EAAkB;IAC3B;IACA,MAAMC,QAAQ,GAAG,MAAMd,gBAAgB,CAACe,IAAI,CAAC,CAAC;IAC9C,MAAM;MAAEC;IAAO,CAAC,GAAGF,QAAQ,EAAEG,GAAG,CAACC,UAAU;IAE3C,MAAM,IAAI,CAACP,cAAc,CAACQ,OAAO,CAAC;MAC9BC,SAAS,EAAE,GAAGJ,MAAM;IACxB,CAAC,CAAC;EACN;EAEA,MAAMK,SAASA,CAAA,EAAkB;IAC7B,MAAM,IAAI,CAACT,aAAa,CAACU,MAAM,CAACnB,6BAA6B,CAAC;EAClE;AACJ;AAEA,OAAO,MAAMoB,iBAAiB,GAAGtB,oBAAoB,CAAC;EAClDuB,WAAW,EAAEtB,YAAY;EACzBuB,cAAc,EAAEnB,qBAAqB;EACrCoB,YAAY,EAAE,CAACtB,qBAAqB,EAAEC,aAAa;AACvD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ import { UpdateSettingsUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
|
4
4
|
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
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
7
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
8
8
|
declare class UpdateSettingsUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
9
9
|
private keyValueStore;
|
|
10
10
|
private getSettings;
|
|
@@ -5,7 +5,7 @@ import { GetSettingsUseCase } from "../GetSettings/abstractions.js";
|
|
|
5
5
|
import { SettingsUpdateError } from "../../../domain/settings/errors.js";
|
|
6
6
|
import { SettingsValidationError } from "../../../domain/settings/errors.js";
|
|
7
7
|
import { FILE_MANAGER_GENERAL_SETTINGS } from "../../../domain/settings/constants.js";
|
|
8
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
8
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
9
9
|
import { SettingsBeforeUpdateEvent, SettingsAfterUpdateEvent } from "./events.js";
|
|
10
10
|
import { updateSettingsValidation } from "../../../domain/settings/validation.js";
|
|
11
11
|
import { createZodError } from "@webiny/utils";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","KeyValueStore","UpdateSettingsUseCase","UseCaseAbstraction","GetSettingsUseCase","SettingsUpdateError","SettingsValidationError","FILE_MANAGER_GENERAL_SETTINGS","EventPublisher","SettingsBeforeUpdateEvent","SettingsAfterUpdateEvent","updateSettingsValidation","createZodError","UpdateSettingsUseCaseImpl","constructor","keyValueStore","getSettings","eventPublisher","execute","input","validationResult","safeParseAsync","success","zodError","error","fail","data","invalidFields","validatedInput","existingResult","existing","value","updatedSettings","publish","original","settings","result","set","isFail","ok","createImplementation","implementation","dependencies"],"sources":["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/
|
|
1
|
+
{"version":3,"names":["Result","KeyValueStore","UpdateSettingsUseCase","UseCaseAbstraction","GetSettingsUseCase","SettingsUpdateError","SettingsValidationError","FILE_MANAGER_GENERAL_SETTINGS","EventPublisher","SettingsBeforeUpdateEvent","SettingsAfterUpdateEvent","updateSettingsValidation","createZodError","UpdateSettingsUseCaseImpl","constructor","keyValueStore","getSettings","eventPublisher","execute","input","validationResult","safeParseAsync","success","zodError","error","fail","data","invalidFields","validatedInput","existingResult","existing","value","updatedSettings","publish","original","settings","result","set","isFail","ok","createImplementation","implementation","dependencies"],"sources":["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 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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,aAAa,QAAQ,kDAAkD;AAChF,SAASC,qBAAqB,IAAIC,kBAAkB;AACpD,SAASC,kBAAkB;AAG3B,SAASC,mBAAmB;AAC5B,SAASC,uBAAu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3F,IAAII,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOtC,MAAM,CAACyB,IAAI,CAAC,IAAIpB,mBAAmB,CAAC+B,MAAM,CAACZ,KAAK,CAAC,CAAC;IAC7D;;IAEA;IACA,MAAM,IAAI,CAACP,cAAc,CAACgB,OAAO,CAC7B,IAAIvB,wBAAwB,CAAC;MACzBwB,QAAQ,EAAEJ,QAAQ;MAClBK,QAAQ,EAAEH,eAAe;MACzBb,KAAK,EAAES;IACX,CAAC,CACL,CAAC;IAED,OAAO5B,MAAM,CAACuC,EAAE,CAACP,eAAe,CAAC;EACrC;AACJ;AAEA,OAAO,MAAM9B,qBAAqB,GAAGC,kBAAkB,CAACqC,oBAAoB,CAAC;EACzEC,cAAc,EAAE5B,yBAAyB;EACzC6B,YAAY,EAAE,CAACzC,aAAa,EAAEG,kBAAkB,EAAEI,cAAc;AACpE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { FileManagerSettings } from "../../../domain/settings/types.js";
|
|
4
4
|
import type { UpdateSettingsInput } from "../../../domain/settings/types.js";
|
|
5
5
|
export interface SettingsBeforeUpdatePayload {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// SettingsBeforeUpdate Event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DomainEvent","SettingsBeforeUpdateEvent","eventType","getHandlerAbstraction","SettingsBeforeUpdateEventHandler","SettingsAfterUpdateEvent","SettingsAfterUpdateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","SettingsBeforeUpdateEvent","eventType","getHandlerAbstraction","SettingsBeforeUpdateEventHandler","SettingsAfterUpdateEvent","SettingsAfterUpdateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { FileManagerSettings } from \"~/domain/settings/types.js\";\nimport type { UpdateSettingsInput } from \"~/domain/settings/types.js\";\n\n// ============================================================================\n// SettingsBeforeUpdate Event\n// ============================================================================\n\nexport interface SettingsBeforeUpdatePayload {\n original: FileManagerSettings;\n settings: FileManagerSettings;\n input: UpdateSettingsInput;\n}\n\nexport class SettingsBeforeUpdateEvent extends DomainEvent<SettingsBeforeUpdatePayload> {\n eventType = \"FileManager/Settings/BeforeUpdate\" as const;\n\n getHandlerAbstraction() {\n return SettingsBeforeUpdateEventHandler;\n }\n}\n\n/** Hook into settings lifecycle before settings are updated. */\nexport const SettingsBeforeUpdateEventHandler = createAbstraction<\n IEventHandler<SettingsBeforeUpdateEvent>\n>(\"SettingsBeforeUpdateEventHandler\");\n\nexport namespace SettingsBeforeUpdateEventHandler {\n export type Interface = IEventHandler<SettingsBeforeUpdateEvent>;\n export type Event = SettingsBeforeUpdateEvent;\n}\n\n// ============================================================================\n// SettingsAfterUpdate Event\n// ============================================================================\n\nexport interface SettingsAfterUpdatePayload {\n original: FileManagerSettings;\n settings: FileManagerSettings;\n input: UpdateSettingsInput;\n}\n\nexport class SettingsAfterUpdateEvent extends DomainEvent<SettingsAfterUpdatePayload> {\n eventType = \"FileManager/Settings/AfterUpdate\" as const;\n\n getHandlerAbstraction() {\n return SettingsAfterUpdateEventHandler;\n }\n}\n\n/** Hook into settings lifecycle after settings are updated. */\nexport const SettingsAfterUpdateEventHandler = createAbstraction<\n IEventHandler<SettingsAfterUpdateEvent>\n>(\"SettingsAfterUpdateEventHandler\");\n\nexport namespace SettingsAfterUpdateEventHandler {\n export type Interface = IEventHandler<SettingsAfterUpdateEvent>;\n export type Event = SettingsAfterUpdateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAQA,OAAO,MAAMC,yBAAyB,SAASD,WAAW,CAA8B;EACpFE,SAAS,GAAG,mCAAmC;EAE/CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,gCAAgC;EAC3C;AACJ;;AAEA;AACA,OAAO,MAAMA,gCAAgC,GAAGL,iBAAiB,CAE/D,kCAAkC,CAAC;;AAOrC;AACA;AACA;;AAQA,OAAO,MAAMM,wBAAwB,SAASL,WAAW,CAA6B;EAClFE,SAAS,GAAG,kCAAkC;EAE9CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,+BAA+B;EAC1C;AACJ;;AAEA;AACA,OAAO,MAAMA,+BAA+B,GAAGP,iBAAiB,CAE9D,iCAAiC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FmPermissions } from "../../permissions/
|
|
1
|
+
export { FmPermissions } from "../../features/permissions/abstractions.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FmPermissions"],"sources":["abstractions.ts"],"sourcesContent":["export { FmPermissions } from \"~/permissions/
|
|
1
|
+
{"version":3,"names":["FmPermissions"],"sources":["abstractions.ts"],"sourcesContent":["export { FmPermissions } from \"~/features/permissions/abstractions.js\";\n"],"mappings":"AAAA,SAASA,aAAa","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
2
3
|
export interface CreateFilesTypeDefsParams {
|
|
3
4
|
model: CmsModel;
|
|
4
5
|
models: CmsModel[];
|
|
5
|
-
|
|
6
|
+
fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
|
|
6
7
|
}
|
|
7
8
|
export declare const createFilesTypeDefs: (params: CreateFilesTypeDefsParams) => string;
|
|
@@ -22,7 +22,7 @@ export const createFilesTypeDefs = params => {
|
|
|
22
22
|
const {
|
|
23
23
|
model,
|
|
24
24
|
models,
|
|
25
|
-
|
|
25
|
+
fieldRegistry
|
|
26
26
|
} = params;
|
|
27
27
|
const {
|
|
28
28
|
fields
|
|
@@ -32,25 +32,25 @@ export const createFilesTypeDefs = params => {
|
|
|
32
32
|
model,
|
|
33
33
|
fields,
|
|
34
34
|
type: "manage",
|
|
35
|
-
|
|
35
|
+
fieldRegistry
|
|
36
36
|
});
|
|
37
37
|
const inputCreateFields = renderInputFields({
|
|
38
38
|
models,
|
|
39
39
|
model,
|
|
40
40
|
fields,
|
|
41
|
-
|
|
41
|
+
fieldRegistry
|
|
42
42
|
});
|
|
43
43
|
const inputUpdateFields = renderInputFields({
|
|
44
44
|
models,
|
|
45
45
|
model,
|
|
46
46
|
fields: createUpdateFields(fields),
|
|
47
|
-
|
|
47
|
+
fieldRegistry
|
|
48
48
|
});
|
|
49
49
|
const listFilterFieldsRender = renderListFilterFields({
|
|
50
50
|
model,
|
|
51
51
|
fields: model.fields,
|
|
52
52
|
type: "manage",
|
|
53
|
-
|
|
53
|
+
fieldRegistry,
|
|
54
54
|
excludeFields: ["entryId", "status"]
|
|
55
55
|
});
|
|
56
56
|
return /* GraphQL */`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["renderFields","renderInputFields","renderListFilterFields","removeFieldRequiredValidation","field","validation","filter","name","listValidation","v","createUpdateFields","fields","reduce","collection","push","createFilesTypeDefs","params","model","models","
|
|
1
|
+
{"version":3,"names":["renderFields","renderInputFields","renderListFilterFields","removeFieldRequiredValidation","field","validation","filter","name","listValidation","v","createUpdateFields","fields","reduce","collection","push","createFilesTypeDefs","params","model","models","fieldRegistry","fieldTypes","type","inputCreateFields","inputUpdateFields","listFilterFieldsRender","excludeFields","map","f","typeDefs","join","allFiltersAsString"],"sources":["createFilesTypeDefs.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields.js\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nexport interface CreateFilesTypeDefsParams {\n model: CmsModel;\n models: CmsModel[];\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createFilesTypeDefs = (params: CreateFilesTypeDefsParams): string => {\n const { model, models, fieldRegistry } = params;\n const { fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldRegistry\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldRegistry\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldRegistry\n });\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldRegistry,\n excludeFields: [\"entryId\", \"status\"]\n });\n\n return /* GraphQL */ `\n type FmFile_Location {\n folderId: ID!\n }\n\n input FmFile_LocationInput {\n folderId: ID!\n }\n\n input FmFile_LocationWhereInput {\n folderId: ID\n folderId_in: [ID!]\n folderId_not: ID\n folderId_not_in: [ID!]\n }\n \n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n\n type FmFile {\n id: ID!\n createdOn: DateTime!\n modifiedOn: DateTime\n savedOn: DateTime!\n createdBy: FmCreatedBy!\n modifiedBy: FmCreatedBy\n savedBy: FmCreatedBy!\n location: FmFile_Location!\n src: String\n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input FmCreatedByInput {\n id: ID!\n displayName: String!\n type: String!\n }\n\n input FmFileCreateInput {\n id: ID!\n createdOn: DateTime\n modifiedOn: DateTime\n savedOn: DateTime\n createdBy: FmCreatedByInput\n modifiedBy: FmCreatedByInput\n savedBy: FmCreatedByInput\n location: FmFile_LocationInput\n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n input FmFileUpdateInput {\n createdOn: DateTime\n modifiedOn: DateTime\n savedOn: DateTime\n createdBy: FmCreatedByInput\n modifiedBy: FmCreatedByInput\n savedBy: FmCreatedByInput\n location: FmFile_LocationInput\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type FmFileResponse {\n data: FmFile\n error: FmError\n }\n\n input FmFileListWhereInput {\n ${listFilterFieldsRender.allFiltersAsString()}\n location: FmFile_LocationWhereInput\n AND: [FmFileListWhereInput!]\n OR: [FmFileListWhereInput!]\n }\n\n type FmFileListResponse {\n data: [FmFile!]\n error: FmError\n meta: FmListMeta\n }\n\n enum FmFileListSorter {\n savedOn_ASC\n savedOn_DESC\n createdOn_ASC\n createdOn_DESC\n name_ASC\n name_DESC\n key_ASC\n key_DESC\n type_ASC\n type_DESC\n size_ASC\n size_DESC\n }\n\n input FmTagsListWhereInput {\n createdBy: String\n tags_startsWith: String\n tags_not_startsWith: String\n }\n\n type FmTag {\n tag: String!\n count: Number!\n }\n\n type FmTagsListResponse {\n data: [FmTag!]\n error: FmError\n }\n\n type FmCreateFilesResponse {\n data: [FmFile!]\n error: FmError\n }\n \n type FmFileModelResponse {\n data: JSON\n error: FmError\n }\n\n extend type FmQuery {\n getFileModel: FmFileModelResponse!\n getFile(id: ID!): FmFileResponse!\n listFiles(\n search: String\n where: FmFileListWhereInput\n limit: Int\n after: String\n sort: [FmFileListSorter!]\n ): FmFileListResponse!\n listTags(where: FmTagsListWhereInput): FmTagsListResponse!\n }\n\n extend type FmMutation {\n createFile(data: FmFileCreateInput!): FmFileResponse!\n createFiles(data: [FmFileCreateInput!]!): FmCreateFilesResponse!\n updateFile(id: ID!, data: FmFileUpdateInput!): FmFileResponse!\n deleteFile(id: ID!): FmBooleanResponse!\n }\n `;\n};\n"],"mappings":"AACA,SAASA,YAAY,QAAQ,gDAAgD;AAC7E,SAASC,iBAAiB,QAAQ,qDAAqD;AACvF,SAASC,sBAAsB,QAAQ,0DAA0D;AASjG,MAAMC,6BAA6B,GAAIC,KAAoB,IAAK;EAC5D,IAAIA,KAAK,CAACC,UAAU,EAAE;IAClBD,KAAK,CAACC,UAAU,GAAGD,KAAK,CAACC,UAAU,CAACC,MAAM,CAACD,UAAU,IAAIA,UAAU,CAACE,IAAI,KAAK,UAAU,CAAC;EAC5F;EACA,IAAIH,KAAK,CAACI,cAAc,EAAE;IACtBJ,KAAK,CAACI,cAAc,GAAGJ,KAAK,CAACI,cAAc,CAACF,MAAM,CAACG,CAAC,IAAIA,CAAC,CAACF,IAAI,KAAK,UAAU,CAAC;EAClF;EACA,OAAOH,KAAK;AAChB,CAAC;AAED,MAAMM,kBAAkB,GAAIC,MAAuB,IAAsB;EACrE,OAAOA,MAAM,CAACC,MAAM,CAAkB,CAACC,UAAU,EAAET,KAAK,KAAK;IAC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D;AACA;AACA,UAAUP,iBAAiB,CAACI,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcP,iBAAiB,CAACI,GAAG,CAACC,CAAC,IAAIA,CAAC,CAAChB,MAAM,CAAC,CAACkB,IAAI,CAAC,IAAI,CAAC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcN,iBAAiB,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAAChB,MAAM,CAAC,CAACkB,IAAI,CAAC,IAAI,CAAC;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcL,sBAAsB,CAACM,kBAAkB,CAAC,CAAC;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,CAAC","ignoreList":[]}
|
package/graphql/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ContextPlugin } from "@webiny/api";
|
|
2
2
|
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql";
|
|
3
3
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
4
|
-
import { createFieldTypePluginRecords } from "@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.js";
|
|
5
4
|
import { createGraphQLSchemaPluginFromFieldPlugins } from "@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js";
|
|
6
5
|
import { createBaseSchema } from "./baseSchema.js";
|
|
7
6
|
import { createFilesSchema } from "./filesSchema.js";
|
|
8
7
|
import { getFileByUrl } from "./getFileByUrl.js";
|
|
9
8
|
import { FileModel } from "../domain/file/abstractions.js";
|
|
10
|
-
import { TenantContext } from "@webiny/api-core/features/TenantContext";
|
|
9
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
10
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
11
11
|
export const createGraphQLSchemaPlugin = () => {
|
|
12
12
|
return [createBaseSchema(),
|
|
13
13
|
// Files schema is generated dynamically, based on a CMS model, so we need to
|
|
@@ -19,17 +19,18 @@ export const createGraphQLSchemaPlugin = () => {
|
|
|
19
19
|
}
|
|
20
20
|
const fileModel = context.container.resolve(FileModel);
|
|
21
21
|
const listModels = context.container.resolve(ListModelsUseCase);
|
|
22
|
+
const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);
|
|
22
23
|
await context.security.withoutAuthorization(async () => {
|
|
23
24
|
const modelsResult = await listModels.execute();
|
|
24
25
|
const models = modelsResult.value;
|
|
25
|
-
|
|
26
|
+
|
|
26
27
|
/**
|
|
27
28
|
* We need to register all plugins for all the CMS fields.
|
|
28
29
|
*/
|
|
29
30
|
const plugins = createGraphQLSchemaPluginFromFieldPlugins({
|
|
30
31
|
models,
|
|
31
32
|
type: "manage",
|
|
32
|
-
|
|
33
|
+
fieldRegistry,
|
|
33
34
|
createPlugin: ({
|
|
34
35
|
schema,
|
|
35
36
|
type,
|
|
@@ -43,7 +44,7 @@ export const createGraphQLSchemaPlugin = () => {
|
|
|
43
44
|
const graphQlPlugin = createFilesSchema({
|
|
44
45
|
model: fileModel,
|
|
45
46
|
models,
|
|
46
|
-
|
|
47
|
+
fieldRegistry
|
|
47
48
|
});
|
|
48
49
|
context.plugins.register([...plugins, graphQlPlugin, getFileByUrl()]);
|
|
49
50
|
});
|
package/graphql/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ContextPlugin","GraphQLSchemaPlugin","ListModelsUseCase","
|
|
1
|
+
{"version":3,"names":["ContextPlugin","GraphQLSchemaPlugin","ListModelsUseCase","createGraphQLSchemaPluginFromFieldPlugins","createBaseSchema","createFilesSchema","getFileByUrl","FileModel","TenantContext","CmsModelFieldToGraphQLRegistry","createGraphQLSchemaPlugin","context","tenantContext","container","resolve","getTenant","fileModel","listModels","fieldRegistry","security","withoutAuthorization","modelsResult","execute","models","value","plugins","type","createPlugin","schema","fieldType","plugin","name","graphQlPlugin","model","register"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { createGraphQLSchemaPluginFromFieldPlugins } from \"@webiny/api-headless-cms/utils/getSchemaFromFieldPlugins.js\";\nimport { createBaseSchema } from \"~/graphql/baseSchema.js\";\nimport { createFilesSchema } from \"~/graphql/filesSchema.js\";\nimport { getFileByUrl } from \"~/graphql/getFileByUrl.js\";\nimport { FileModel } from \"~/domain/file/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nexport const createGraphQLSchemaPlugin = () => {\n return [\n createBaseSchema(),\n // Files schema is generated dynamically, based on a CMS model, so we need to\n // register it from a ContextPlugin, to perform additional bootstrap.\n new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n if (!tenantContext.getTenant()) {\n return;\n }\n\n const fileModel = context.container.resolve(FileModel);\n const listModels = context.container.resolve(ListModelsUseCase);\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n\n await context.security.withoutAuthorization(async () => {\n const modelsResult = await listModels.execute();\n const models = modelsResult.value;\n\n /**\n * We need to register all plugins for all the CMS fields.\n */\n const plugins = createGraphQLSchemaPluginFromFieldPlugins({\n models,\n type: \"manage\",\n fieldRegistry,\n createPlugin: ({ schema, type, fieldType }) => {\n const plugin = new GraphQLSchemaPlugin(schema);\n plugin.name = `fm.graphql.schema.${type}.field.${fieldType}`;\n return plugin;\n }\n });\n\n const graphQlPlugin = createFilesSchema({\n model: fileModel,\n models,\n fieldRegistry\n });\n\n context.plugins.register([...plugins, graphQlPlugin, getFileByUrl()]);\n });\n })\n ];\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;AAE3C,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,iBAAiB,QAAQ,oEAAoE;AACtG,SAASC,yCAAyC,QAAQ,6DAA6D;AACvH,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,YAAY;AACrB,SAASC,SAAS;AAClB,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,8BAA8B,QAAQ,qDAAqD;AAEpG,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,CACHN,gBAAgB,CAAC,CAAC;EAClB;EACA;EACA,IAAIJ,aAAa,CAAiB,MAAMW,OAAO,IAAI;IAC/C,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACN,aAAa,CAAC;IAC9D,IAAI,CAACI,aAAa,CAACG,SAAS,CAAC,CAAC,EAAE;MAC5B;IACJ;IAEA,MAAMC,SAAS,GAAGL,OAAO,CAACE,SAAS,CAACC,OAAO,CAACP,SAAS,CAAC;IACtD,MAAMU,UAAU,GAAGN,OAAO,CAACE,SAAS,CAACC,OAAO,CAACZ,iBAAiB,CAAC;IAC/D,MAAMgB,aAAa,GAAGP,OAAO,CAACE,SAAS,CAACC,OAAO,CAACL,8BAA8B,CAAC;IAE/E,MAAME,OAAO,CAACQ,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,YAAY,GAAG,MAAMJ,UAAU,CAACK,OAAO,CAAC,CAAC;MAC/C,MAAMC,MAAM,GAAGF,YAAY,CAACG,KAAK;;MAEjC;AAChB;AACA;MACgB,MAAMC,OAAO,GAAGtB,yCAAyC,CAAC;QACtDoB,MAAM;QACNG,IAAI,EAAE,QAAQ;QACdR,aAAa;QACbS,YAAY,EAAEA,CAAC;UAAEC,MAAM;UAAEF,IAAI;UAAEG;QAAU,CAAC,KAAK;UAC3C,MAAMC,MAAM,GAAG,IAAI7B,mBAAmB,CAAC2B,MAAM,CAAC;UAC9CE,MAAM,CAACC,IAAI,GAAG,qBAAqBL,IAAI,UAAUG,SAAS,EAAE;UAC5D,OAAOC,MAAM;QACjB;MACJ,CAAC,CAAC;MAEF,MAAME,aAAa,GAAG3B,iBAAiB,CAAC;QACpC4B,KAAK,EAAEjB,SAAS;QAChBO,MAAM;QACNL;MACJ,CAAC,CAAC;MAEFP,OAAO,CAACc,OAAO,CAACS,QAAQ,CAAC,CAAC,GAAGT,OAAO,EAAEO,aAAa,EAAE1B,YAAY,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC,CAAC;EACN,CAAC,CAAC,CACL;AACL,CAAC","ignoreList":[]}
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ContextPlugin } from "@webiny/api";
|
|
|
2
2
|
import { setupAssetDelivery } from "./delivery/setupAssetDelivery.js";
|
|
3
3
|
import { createGraphQLSchemaPlugin } from "./graphql/index.js";
|
|
4
4
|
import { FileManagerFeature } from "./features/FileManagerFeature.js";
|
|
5
|
-
import {
|
|
5
|
+
import { FmPermissionsFeature } from "./features/permissions/feature.js";
|
|
6
6
|
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
7
7
|
import { FileModel as FileModelAbstraction } from "./domain/file/abstractions.js";
|
|
8
8
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
@@ -21,7 +21,7 @@ export const createFileManagerContext = () => {
|
|
|
21
21
|
const fileModel = await getModel.execute(FILE_MODEL_ID);
|
|
22
22
|
context.container.registerInstance(FileModelAbstraction, fileModel.value);
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
FmPermissionsFeature.register(context.container);
|
|
25
25
|
FileManagerFeature.register(context.container);
|
|
26
26
|
});
|
|
27
27
|
plugin.name = "file-manager.createContext";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ContextPlugin","setupAssetDelivery","createGraphQLSchemaPlugin","FileManagerFeature","
|
|
1
|
+
{"version":3,"names":["ContextPlugin","setupAssetDelivery","createGraphQLSchemaPlugin","FileManagerFeature","FmPermissionsFeature","GetModelUseCase","FileModel","FileModelAbstraction","TenantContext","FILE_MODEL_ID","createFileManagerContext","plugin","context","tenantContext","container","resolve","getModel","getTenant","register","security","withoutAuthorization","fileModel","execute","registerInstance","value","name","createFileManagerGraphQL","createAssetDelivery"],"sources":["index.ts"],"sourcesContent":["import type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { setupAssetDelivery } from \"./delivery/setupAssetDelivery.js\";\nimport { createGraphQLSchemaPlugin } from \"./graphql/index.js\";\nimport { FileManagerFeature } from \"~/features/FileManagerFeature.js\";\nimport { FmPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { FileModel as FileModelAbstraction } from \"~/domain/file/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { FileModel, FILE_MODEL_ID } from \"~/domain/file/file.model.js\";\n\nexport * from \"./modelModifier/CmsModelModifier.js\";\nexport * from \"./delivery/index.js\";\n\nexport const createFileManagerContext = () => {\n const plugin = new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const getModel = context.container.resolve(GetModelUseCase);\n\n if (!tenantContext.getTenant()) {\n return;\n }\n\n context.container.register(FileModel);\n\n await context.security.withoutAuthorization(async () => {\n const fileModel = await getModel.execute(FILE_MODEL_ID);\n context.container.registerInstance(FileModelAbstraction, fileModel.value);\n });\n\n FmPermissionsFeature.register(context.container);\n\n FileManagerFeature.register(context.container);\n });\n\n plugin.name = \"file-manager.createContext\";\n\n return plugin;\n};\n\nexport const createFileManagerGraphQL = () => {\n return createGraphQLSchemaPlugin();\n};\n\nexport const createAssetDelivery = () => {\n return setupAssetDelivery();\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,kEAAkE;AAClG,SAASC,SAAS,IAAIC,oBAAoB;AAC1C,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASF,SAAS,EAAEG,aAAa;AAEjC;AACA;AAEA,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIX,aAAa,CAAiB,MAAMY,OAAO,IAAI;IAC9D,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACP,aAAa,CAAC;IAC9D,MAAMQ,QAAQ,GAAGJ,OAAO,CAACE,SAAS,CAACC,OAAO,CAACV,eAAe,CAAC;IAE3D,IAAI,CAACQ,aAAa,CAACI,SAAS,CAAC,CAAC,EAAE;MAC5B;IACJ;IAEAL,OAAO,CAACE,SAAS,CAACI,QAAQ,CAACZ,SAAS,CAAC;IAErC,MAAMM,OAAO,CAACO,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,SAAS,GAAG,MAAML,QAAQ,CAACM,OAAO,CAACb,aAAa,CAAC;MACvDG,OAAO,CAACE,SAAS,CAACS,gBAAgB,CAAChB,oBAAoB,EAAEc,SAAS,CAACG,KAAK,CAAC;IAC7E,CAAC,CAAC;IAEFpB,oBAAoB,CAACc,QAAQ,CAACN,OAAO,CAACE,SAAS,CAAC;IAEhDX,kBAAkB,CAACe,QAAQ,CAACN,OAAO,CAACE,SAAS,CAAC;EAClD,CAAC,CAAC;EAEFH,MAAM,CAACc,IAAI,GAAG,4BAA4B;EAE1C,OAAOd,MAAM;AACjB,CAAC;AAED,OAAO,MAAMe,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,OAAOxB,yBAAyB,CAAC,CAAC;AACtC,CAAC;AAED,OAAO,MAAMyB,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAO1B,kBAAkB,CAAC,CAAC;AAC/B,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -19,25 +19,25 @@
|
|
|
19
19
|
],
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@webiny/api": "6.
|
|
23
|
-
"@webiny/api-core": "6.
|
|
24
|
-
"@webiny/api-headless-cms": "6.
|
|
25
|
-
"@webiny/build-tools": "6.
|
|
22
|
+
"@webiny/api": "6.2.0",
|
|
23
|
+
"@webiny/api-core": "6.2.0",
|
|
24
|
+
"@webiny/api-headless-cms": "6.2.0",
|
|
25
|
+
"@webiny/build-tools": "6.2.0",
|
|
26
26
|
"@webiny/di": "0.2.3",
|
|
27
|
-
"@webiny/error": "6.
|
|
28
|
-
"@webiny/feature": "6.
|
|
29
|
-
"@webiny/handler": "6.
|
|
30
|
-
"@webiny/handler-graphql": "6.
|
|
31
|
-
"@webiny/plugins": "6.
|
|
32
|
-
"@webiny/wcp": "6.
|
|
27
|
+
"@webiny/error": "6.2.0",
|
|
28
|
+
"@webiny/feature": "6.2.0",
|
|
29
|
+
"@webiny/handler": "6.2.0",
|
|
30
|
+
"@webiny/handler-graphql": "6.2.0",
|
|
31
|
+
"@webiny/plugins": "6.2.0",
|
|
32
|
+
"@webiny/wcp": "6.2.0",
|
|
33
33
|
"cache-control-parser": "2.2.0",
|
|
34
34
|
"zod": "4.3.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/object-hash": "3.0.6",
|
|
38
|
-
"@webiny/handler-aws": "6.
|
|
39
|
-
"@webiny/project-utils": "6.
|
|
40
|
-
"@webiny/utils": "6.
|
|
38
|
+
"@webiny/handler-aws": "6.2.0",
|
|
39
|
+
"@webiny/project-utils": "6.2.0",
|
|
40
|
+
"@webiny/utils": "6.2.0",
|
|
41
41
|
"@webiny/wcp": "0.0.0",
|
|
42
42
|
"rimraf": "6.1.3",
|
|
43
43
|
"typescript": "5.9.3"
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "3d3148358b6febbc857371930871743bec3b3939"
|
|
63
63
|
}
|
package/permissions/schema.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { Permissions } from "@webiny/api-core/features/security/permissions/index.js";
|
|
2
|
-
declare const schema: {
|
|
3
|
-
readonly prefix: "fm";
|
|
4
|
-
readonly fullAccess: true;
|
|
5
|
-
readonly entities: readonly [{
|
|
6
|
-
readonly id: "file";
|
|
7
|
-
readonly permission: "fm.file";
|
|
8
|
-
readonly scopes: readonly ["full", "own"];
|
|
9
|
-
readonly actions: readonly [{
|
|
10
|
-
readonly name: "rwd";
|
|
11
|
-
}];
|
|
12
|
-
}, {
|
|
13
|
-
readonly id: "settings";
|
|
14
|
-
readonly permission: "fm.settings";
|
|
15
|
-
readonly scopes: readonly ["full"];
|
|
16
|
-
}];
|
|
17
|
-
};
|
|
18
|
-
type FmSchema = typeof schema;
|
|
19
|
-
/** File manager permission checks. */
|
|
20
|
-
export declare const FmPermissions: {
|
|
21
|
-
Abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/security/permissions/types").PermissionsTyped<{
|
|
22
|
-
readonly prefix: "fm";
|
|
23
|
-
readonly fullAccess: true;
|
|
24
|
-
readonly entities: readonly [{
|
|
25
|
-
readonly id: "file";
|
|
26
|
-
readonly permission: "fm.file";
|
|
27
|
-
readonly scopes: readonly ["full", "own"];
|
|
28
|
-
readonly actions: readonly [{
|
|
29
|
-
readonly name: "rwd";
|
|
30
|
-
}];
|
|
31
|
-
}, {
|
|
32
|
-
readonly id: "settings";
|
|
33
|
-
readonly permission: "fm.settings";
|
|
34
|
-
readonly scopes: readonly ["full"];
|
|
35
|
-
}];
|
|
36
|
-
}>>;
|
|
37
|
-
Implementation: import("@webiny/di").Constructor<import("@webiny/api-core/features/security/permissions/types").PermissionsTyped<{
|
|
38
|
-
readonly prefix: "fm";
|
|
39
|
-
readonly fullAccess: true;
|
|
40
|
-
readonly entities: readonly [{
|
|
41
|
-
readonly id: "file";
|
|
42
|
-
readonly permission: "fm.file";
|
|
43
|
-
readonly scopes: readonly ["full", "own"];
|
|
44
|
-
readonly actions: readonly [{
|
|
45
|
-
readonly name: "rwd";
|
|
46
|
-
}];
|
|
47
|
-
}, {
|
|
48
|
-
readonly id: "settings";
|
|
49
|
-
readonly permission: "fm.settings";
|
|
50
|
-
readonly scopes: readonly ["full"];
|
|
51
|
-
}];
|
|
52
|
-
}>> & {
|
|
53
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/security/permissions/types").PermissionsTyped<{
|
|
54
|
-
readonly prefix: "fm";
|
|
55
|
-
readonly fullAccess: true;
|
|
56
|
-
readonly entities: readonly [{
|
|
57
|
-
readonly id: "file";
|
|
58
|
-
readonly permission: "fm.file";
|
|
59
|
-
readonly scopes: readonly ["full", "own"];
|
|
60
|
-
readonly actions: readonly [{
|
|
61
|
-
readonly name: "rwd";
|
|
62
|
-
}];
|
|
63
|
-
}, {
|
|
64
|
-
readonly id: "settings";
|
|
65
|
-
readonly permission: "fm.settings";
|
|
66
|
-
readonly scopes: readonly ["full"];
|
|
67
|
-
}];
|
|
68
|
-
}>>;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
export declare namespace FmPermissions {
|
|
72
|
-
type Interface = Permissions<FmSchema>;
|
|
73
|
-
}
|
|
74
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createPermissions","schema","prefix","fullAccess","entities","id","permission","scopes","actions","name","FmPermissions"],"sources":["schema.ts"],"sourcesContent":["import type { Permissions } from \"@webiny/api-core/features/security/permissions/index.js\";\nimport { createPermissions } from \"@webiny/api-core/features/security/permissions/index.js\";\n\nconst schema = {\n prefix: \"fm\",\n fullAccess: true,\n entities: [\n {\n id: \"file\",\n permission: \"fm.file\",\n scopes: [\"full\", \"own\"],\n actions: [{ name: \"rwd\" }]\n },\n {\n id: \"settings\",\n permission: \"fm.settings\",\n scopes: [\"full\"]\n }\n ]\n} as const;\n\ntype FmSchema = typeof schema;\n\n/** File manager permission checks. */\nexport const FmPermissions = createPermissions(schema);\n\nexport namespace FmPermissions {\n export type Interface = Permissions<FmSchema>;\n}\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,yDAAyD;AAE3F,MAAMC,MAAM,GAAG;EACXC,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,IAAI;EAChBC,QAAQ,EAAE,CACN;IACIC,EAAE,EAAE,MAAM;IACVC,UAAU,EAAE,SAAS;IACrBC,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACvBC,OAAO,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAM,CAAC;EAC7B,CAAC,EACD;IACIJ,EAAE,EAAE,UAAU;IACdC,UAAU,EAAE,aAAa;IACzBC,MAAM,EAAE,CAAC,MAAM;EACnB,CAAC;AAET,CAAU;AAIV;AACA,OAAO,MAAMG,aAAa,GAAGV,iBAAiB,CAACC,MAAM,CAAC","ignoreList":[]}
|