@webiny/api-aco 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AcoFeature.d.ts +5 -0
- package/AcoFeature.js +134 -0
- package/AcoFeature.js.map +1 -0
- package/AcoFolderSchemaFactory.d.ts +32 -0
- package/AcoFolderSchemaFactory.js +82 -0
- package/AcoFolderSchemaFactory.js.map +1 -0
- package/createAcoGraphQL.d.ts +8 -4
- package/createAcoGraphQL.js +56 -96
- package/createAcoGraphQL.js.map +1 -1
- package/domain/folder/abstractions.d.ts +12 -5
- package/domain/folder/abstractions.js +2 -2
- package/domain/folder/abstractions.js.map +1 -1
- package/domain/folder/folder.model.js +2 -1
- package/domain/folder/folder.model.js.map +1 -1
- package/exports/api/aco/flp.d.ts +1 -0
- package/exports/api/aco/flp.js +1 -0
- package/features/ai/CreateFolderTool.d.ts +49 -0
- package/features/ai/CreateFolderTool.js +58 -0
- package/features/ai/CreateFolderTool.js.map +1 -0
- package/features/ai/CreateTeamTool.d.ts +48 -0
- package/features/ai/CreateTeamTool.js +56 -0
- package/features/ai/CreateTeamTool.js.map +1 -0
- package/features/ai/DeleteFolderTool.d.ts +48 -0
- package/features/ai/DeleteFolderTool.js +55 -0
- package/features/ai/DeleteFolderTool.js.map +1 -0
- package/features/ai/GrantFolderAccessTool.d.ts +77 -0
- package/features/ai/GrantFolderAccessTool.js +80 -0
- package/features/ai/GrantFolderAccessTool.js.map +1 -0
- package/features/ai/ListFoldersTool.d.ts +47 -0
- package/features/ai/ListFoldersTool.js +57 -0
- package/features/ai/ListFoldersTool.js.map +1 -0
- package/features/ai/ListRolesTool.d.ts +39 -0
- package/features/ai/ListRolesTool.js +48 -0
- package/features/ai/ListRolesTool.js.map +1 -0
- package/features/ai/ListTeamsTool.d.ts +39 -0
- package/features/ai/ListTeamsTool.js +48 -0
- package/features/ai/ListTeamsTool.js.map +1 -0
- package/features/ai/RevokeFolderAccessTool.d.ts +63 -0
- package/features/ai/RevokeFolderAccessTool.js +69 -0
- package/features/ai/RevokeFolderAccessTool.js.map +1 -0
- package/features/ai/assertTargetIsUsable.d.ts +10 -0
- package/features/ai/assertTargetIsUsable.js +14 -0
- package/features/ai/assertTargetIsUsable.js.map +1 -0
- package/features/ai/feature.d.ts +12 -0
- package/features/ai/feature.js +25 -0
- package/features/ai/feature.js.map +1 -0
- package/features/ai/index.d.ts +9 -0
- package/features/ai/index.js +9 -0
- package/features/ai/loadFolderPermissions.d.ts +16 -0
- package/features/ai/loadFolderPermissions.js +14 -0
- package/features/ai/loadFolderPermissions.js.map +1 -0
- package/features/flp/CreateFlp/CreateFlpUseCase.d.ts +3 -3
- package/features/flp/CreateFlp/CreateFlpUseCase.js +4 -4
- package/features/flp/CreateFlp/CreateFlpUseCase.js.map +1 -1
- package/features/flp/CreateFlp/feature.d.ts +1 -6
- package/features/flp/CreateFlp/feature.js +3 -2
- package/features/flp/CreateFlp/feature.js.map +1 -1
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.d.ts +8 -5
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js +21 -14
- package/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js.map +1 -1
- package/features/flp/DeleteFlp/DeleteFlpUseCase.d.ts +3 -3
- package/features/flp/DeleteFlp/DeleteFlpUseCase.js +3 -3
- package/features/flp/DeleteFlp/DeleteFlpUseCase.js.map +1 -1
- package/features/flp/DeleteFlp/feature.d.ts +1 -6
- package/features/flp/DeleteFlp/feature.js +3 -2
- package/features/flp/DeleteFlp/feature.js.map +1 -1
- package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.d.ts +6 -5
- package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js +16 -13
- package/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js.map +1 -1
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.d.ts +4 -3
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +14 -13
- package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.d.ts +6 -0
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js +6 -2
- package/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js.map +1 -1
- package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.d.ts +13 -0
- package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js +26 -0
- package/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js.map +1 -0
- package/features/flp/GetFlp/feature.d.ts +1 -1
- package/features/flp/GetFlp/feature.js +3 -2
- package/features/flp/GetFlp/feature.js.map +1 -1
- package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.d.ts +13 -0
- package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js +27 -0
- package/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js.map +1 -0
- package/features/flp/ListFlps/feature.d.ts +1 -1
- package/features/flp/ListFlps/feature.js +3 -2
- package/features/flp/ListFlps/feature.js.map +1 -1
- package/features/flp/UpdateFlp/UpdateFlpUseCase.d.ts +15 -8
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js +37 -42
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js.map +1 -1
- package/features/flp/UpdateFlp/abstractions.d.ts +6 -2
- package/features/flp/UpdateFlp/abstractions.js.map +1 -1
- package/features/flp/UpdateFlp/feature.d.ts +1 -6
- package/features/flp/UpdateFlp/feature.js +7 -2
- package/features/flp/UpdateFlp/feature.js.map +1 -1
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.d.ts +8 -5
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js +21 -16
- package/features/flp/UpdateFlpOnFolderUpdated/UpdateFlpOnFolderUpdatedHandler.js.map +1 -1
- package/features/flp/shared/CodeFlpMerger.d.ts +26 -0
- package/features/flp/shared/CodeFlpMerger.js +20 -0
- package/features/flp/shared/CodeFlpMerger.js.map +1 -0
- package/features/flp/shared/CodeFlpPath.d.ts +15 -0
- package/features/flp/shared/CodeFlpPath.js +29 -0
- package/features/flp/shared/CodeFlpPath.js.map +1 -0
- package/features/flp/shared/CodeFlpTarget.d.ts +10 -0
- package/features/flp/shared/CodeFlpTarget.js +26 -0
- package/features/flp/shared/CodeFlpTarget.js.map +1 -0
- package/features/flp/shared/CodeFlpsProvider.d.ts +14 -0
- package/features/flp/shared/CodeFlpsProvider.js +33 -0
- package/features/flp/shared/CodeFlpsProvider.js.map +1 -0
- package/features/flp/shared/abstractions.d.ts +77 -0
- package/features/flp/shared/abstractions.js +19 -0
- package/features/flp/shared/abstractions.js.map +1 -0
- package/features/flp/shared/feature.d.ts +5 -0
- package/features/flp/shared/feature.js +17 -0
- package/features/flp/shared/feature.js.map +1 -0
- package/features/flp/shared/index.d.ts +4 -0
- package/features/flp/shared/index.js +4 -0
- package/features/folder/CreateFolder/CreateFolderRepository.d.ts +3 -3
- package/features/folder/CreateFolder/CreateFolderRepository.js +10 -7
- package/features/folder/CreateFolder/CreateFolderRepository.js.map +1 -1
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.d.ts +9 -1
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js +20 -3
- package/features/folder/CreateFolder/decorators/CreateFolderWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/DeleteFolder/DeleteFolderRepository.d.ts +3 -3
- package/features/folder/DeleteFolder/DeleteFolderRepository.js +6 -5
- package/features/folder/DeleteFolder/DeleteFolderRepository.js.map +1 -1
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.d.ts +1 -3
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +3 -6
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
- package/features/folder/FolderModelProvider.d.ts +26 -0
- package/features/folder/FolderModelProvider.js +22 -0
- package/features/folder/FolderModelProvider.js.map +1 -0
- package/features/folder/GetAncestors/GetAncestorsRepository.d.ts +3 -3
- package/features/folder/GetAncestors/GetAncestorsRepository.js +6 -5
- package/features/folder/GetAncestors/GetAncestorsRepository.js.map +1 -1
- package/features/folder/GetFolder/GetFolderRepository.d.ts +3 -3
- package/features/folder/GetFolder/GetFolderRepository.js +6 -5
- package/features/folder/GetFolder/GetFolderRepository.js.map +1 -1
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.d.ts +3 -3
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js +10 -8
- package/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js.map +1 -1
- package/features/folder/ListFolders/ListFoldersRepository.d.ts +3 -3
- package/features/folder/ListFolders/ListFoldersRepository.js +8 -7
- package/features/folder/ListFolders/ListFoldersRepository.js.map +1 -1
- package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +11 -0
- package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js +38 -0
- package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +1 -0
- package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.d.ts +12 -0
- package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js +24 -0
- package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js.map +1 -0
- package/features/folder/NotifyFolderChange/abstractions.d.ts +28 -0
- package/features/folder/NotifyFolderChange/abstractions.js +8 -0
- package/features/folder/NotifyFolderChange/abstractions.js.map +1 -0
- package/features/folder/NotifyFolderChange/feature.d.ts +9 -0
- package/features/folder/NotifyFolderChange/feature.js +13 -0
- package/features/folder/NotifyFolderChange/feature.js.map +1 -0
- package/features/folder/NotifyFolderChange/index.d.ts +2 -0
- package/features/folder/NotifyFolderChange/index.js +2 -0
- package/features/folder/UpdateFolder/UpdateFolderRepository.d.ts +3 -3
- package/features/folder/UpdateFolder/UpdateFolderRepository.js +11 -8
- package/features/folder/UpdateFolder/UpdateFolderRepository.js.map +1 -1
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.d.ts +14 -1
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js +52 -4
- package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
- package/features/folder/shared/abstractions.d.ts +10 -0
- package/features/folder/shared/abstractions.js +3 -1
- package/features/folder/shared/abstractions.js.map +1 -1
- package/filter/filter.gql.d.ts +2 -3
- package/filter/filter.gql.js +61 -27
- package/filter/filter.gql.js.map +1 -1
- package/filter/filter.model.js +2 -1
- package/filter/filter.model.js.map +1 -1
- package/filter/filter.so.d.ts +2 -4
- package/filter/filter.so.js +21 -9
- package/filter/filter.so.js.map +1 -1
- package/flp/flp.types.d.ts +6 -1
- package/flp/tasks/createFlp.task.d.ts +11 -4
- package/flp/tasks/createFlp.task.js +32 -15
- package/flp/tasks/createFlp.task.js.map +1 -1
- package/flp/tasks/deleteFlp.task.d.ts +9 -4
- package/flp/tasks/deleteFlp.task.js +22 -13
- package/flp/tasks/deleteFlp.task.js.map +1 -1
- package/flp/tasks/index.d.ts +0 -1
- package/flp/tasks/index.js +1 -14
- package/flp/tasks/index.js.map +1 -1
- package/flp/tasks/syncFlp.task.d.ts +9 -4
- package/flp/tasks/syncFlp.task.js +22 -13
- package/flp/tasks/syncFlp.task.js.map +1 -1
- package/flp/tasks/updateFlp.task.d.ts +11 -4
- package/flp/tasks/updateFlp.task.js +40 -19
- package/flp/tasks/updateFlp.task.js.map +1 -1
- package/folder/createFolderTypeDefs.js +4 -1
- package/folder/createFolderTypeDefs.js.map +1 -1
- package/folder/folder.gql.d.ts +1 -1
- package/folder/folder.gql.js +4 -4
- package/folder/folder.gql.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -11
- package/package.json +23 -21
- package/types.d.ts +1 -2
- package/types.js.map +1 -1
- package/utils/createOperationsWrapper.d.ts +4 -4
- package/utils/createOperationsWrapper.js +5 -5
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.js +9 -5
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js +1 -1
- package/utils/resolve.js.map +1 -1
- package/createAcoContext.d.ts +0 -3
- package/createAcoContext.js +0 -112
- package/createAcoContext.js.map +0 -1
- package/createAcoTasks.d.ts +0 -1
- package/createAcoTasks.js +0 -14
- package/createAcoTasks.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -1,35 +1,42 @@
|
|
|
1
|
-
import { CreateFlpUseCase } from "../CreateFlp/abstractions.js";
|
|
2
1
|
import { FolderAfterCreateEventHandler } from "../../folder/CreateFolder/abstractions.js";
|
|
3
2
|
import { CREATE_FLP_TASK_ID } from "../../../flp/tasks/index.js";
|
|
4
3
|
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
4
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
5
6
|
class CreateFlpOnFolderCreatedHandlerImpl {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
7
|
+
constructor(identityContext, tasks, logger){
|
|
8
|
+
this.identityContext = identityContext;
|
|
8
9
|
this.tasks = tasks;
|
|
10
|
+
this.logger = logger;
|
|
9
11
|
}
|
|
10
12
|
async handle(event) {
|
|
11
13
|
const { folder } = event.payload;
|
|
12
14
|
try {
|
|
13
|
-
|
|
15
|
+
const result = await this.tasks.trigger({
|
|
14
16
|
definition: CREATE_FLP_TASK_ID,
|
|
15
17
|
input: {
|
|
16
|
-
folder
|
|
18
|
+
folder,
|
|
19
|
+
notifyIdentityId: this.identityContext.getIdentity()?.id
|
|
17
20
|
}
|
|
18
21
|
});
|
|
19
|
-
|
|
20
|
-
} catch
|
|
22
|
+
if (result.isFail()) this.logFailure(folder.id, result.error);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
this.logFailure(folder.id, error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
logFailure(folderId, error) {
|
|
28
|
+
this.logger.error({
|
|
29
|
+
error,
|
|
30
|
+
folderId
|
|
31
|
+
}, "Could not trigger the task that creates the folder's FLP record.");
|
|
21
32
|
}
|
|
22
33
|
}
|
|
23
34
|
const CreateFlpOnFolderCreatedHandler = FolderAfterCreateEventHandler.createImplementation({
|
|
24
35
|
implementation: CreateFlpOnFolderCreatedHandlerImpl,
|
|
25
36
|
dependencies: [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
optional: true
|
|
31
|
-
}
|
|
32
|
-
]
|
|
37
|
+
IdentityContext,
|
|
38
|
+
TaskService,
|
|
39
|
+
Logger
|
|
33
40
|
]
|
|
34
41
|
});
|
|
35
42
|
export { CreateFlpOnFolderCreatedHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js","sources":["../../../../src/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.js","sources":["../../../../src/features/flp/CreateFlpOnFolderCreated/CreateFlpOnFolderCreatedHandler.ts"],"sourcesContent":["import { FolderAfterCreateEventHandler } from \"~/features/folder/CreateFolder/abstractions.js\";\nimport type { FolderAfterCreateEvent } from \"~/features/folder/CreateFolder/events.js\";\nimport type { ICreateFlpTaskInput } from \"~/types.js\";\nimport { CREATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\n/*\n * Folder reads report permissions from the FLP record, which the task writes later. So the task,\n * not this handler, tells the admin about the new folder, and it needs to know whom to tell.\n */\nclass CreateFlpOnFolderCreatedHandlerImpl implements FolderAfterCreateEventHandler.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private tasks: TaskService.Interface,\n private logger: Logger.Interface\n ) {}\n\n async handle(event: FolderAfterCreateEvent): Promise<void> {\n const { folder } = event.payload;\n\n try {\n const result = await this.tasks.trigger<ICreateFlpTaskInput>({\n definition: CREATE_FLP_TASK_ID,\n // Nobody to tell when there is no identity, as in some system calls.\n input: { folder, notifyIdentityId: this.identityContext.getIdentity()?.id }\n });\n if (result.isFail()) {\n this.logFailure(folder.id, result.error);\n }\n } catch (error) {\n this.logFailure(folder.id, error);\n }\n }\n\n /*\n * The folder change is already saved, so it stands. But the folder is left without an FLP\n * record, and this log is the only trace of why.\n */\n private logFailure(folderId: string, error: unknown): void {\n this.logger.error(\n { error, folderId },\n \"Could not trigger the task that creates the folder's FLP record.\"\n );\n }\n}\n\nexport const CreateFlpOnFolderCreatedHandler = FolderAfterCreateEventHandler.createImplementation({\n implementation: CreateFlpOnFolderCreatedHandlerImpl,\n dependencies: [IdentityContext, TaskService, Logger]\n});\n"],"names":["CreateFlpOnFolderCreatedHandlerImpl","identityContext","tasks","logger","event","folder","result","CREATE_FLP_TASK_ID","error","folderId","CreateFlpOnFolderCreatedHandler","FolderAfterCreateEventHandler","IdentityContext","TaskService","Logger"],"mappings":";;;;;AAYA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,KAA4B,EAC5BC,MAAwB,CAClC;aAHUF,eAAe,GAAfA;aACAC,KAAK,GAALA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,OAAOC,KAA6B,EAAiB;QACvD,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAM,OAAO;QAEhC,IAAI;YACA,MAAME,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB;gBACzD,YAAYC;gBAEZ,OAAO;oBAAEF;oBAAQ,kBAAkB,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI;gBAAG;YAC9E;YACA,IAAIC,OAAO,MAAM,IACb,IAAI,CAAC,UAAU,CAACD,OAAO,EAAE,EAAEC,OAAO,KAAK;QAE/C,EAAE,OAAOE,OAAO;YACZ,IAAI,CAAC,UAAU,CAACH,OAAO,EAAE,EAAEG;QAC/B;IACJ;IAMQ,WAAWC,QAAgB,EAAED,KAAc,EAAQ;QACvD,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;YAAEA;YAAOC;QAAS,GAClB;IAER;AACJ;AAEO,MAAMC,kCAAkCC,8BAA8B,oBAAoB,CAAC;IAC9F,gBAAgBX;IAChB,cAAc;QAACY;QAAiBC;QAAaC;KAAO;AACxD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DeleteFlpUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
2
2
|
import type { Folder } from "../../../folder/folder.types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { AcoFlpCrud } from "../../../features/folder/shared/abstractions.js";
|
|
4
4
|
export declare class DeleteFlpUseCase implements UseCaseAbstraction.Interface {
|
|
5
|
-
private
|
|
6
|
-
constructor(
|
|
5
|
+
private flpCrud;
|
|
6
|
+
constructor(flpCrud: AcoFlpCrud.Interface);
|
|
7
7
|
execute(folder: Folder): Promise<void>;
|
|
8
8
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
2
|
class DeleteFlpUseCase {
|
|
3
|
-
constructor(
|
|
4
|
-
this.
|
|
3
|
+
constructor(flpCrud){
|
|
4
|
+
this.flpCrud = flpCrud;
|
|
5
5
|
}
|
|
6
6
|
async execute(folder) {
|
|
7
7
|
try {
|
|
8
8
|
if (!folder) throw new WebinyError("Missing `folder` from the task input, I can't delete the record from the FLP catalog.", "ERROR_DELETE_FLP_USE_CASE_FOLDER_NOT_PROVIDED", {
|
|
9
9
|
folder
|
|
10
10
|
});
|
|
11
|
-
await this.
|
|
11
|
+
await this.flpCrud.delete(folder.id);
|
|
12
12
|
} catch (error) {
|
|
13
13
|
throw WebinyError.from(error, {
|
|
14
14
|
message: "Error while deleting FLP",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/flp/DeleteFlp/DeleteFlpUseCase.js","sources":["../../../../src/features/flp/DeleteFlp/DeleteFlpUseCase.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { DeleteFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { Folder } from \"~/folder/folder.types.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"features/flp/DeleteFlp/DeleteFlpUseCase.js","sources":["../../../../src/features/flp/DeleteFlp/DeleteFlpUseCase.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { DeleteFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { Folder } from \"~/folder/folder.types.js\";\nimport type { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\n\nexport class DeleteFlpUseCase implements UseCaseAbstraction.Interface {\n constructor(private flpCrud: AcoFlpCrud.Interface) {}\n\n async execute(folder: Folder): Promise<void> {\n try {\n if (!folder) {\n throw new WebinyError(\n \"Missing `folder` from the task input, I can't delete the record from the FLP catalog.\",\n \"ERROR_DELETE_FLP_USE_CASE_FOLDER_NOT_PROVIDED\",\n { folder }\n );\n }\n await this.flpCrud.delete(folder.id);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while deleting FLP\",\n code: \"ERROR_DELETE_FLP_USE_CASE\"\n });\n }\n }\n}\n"],"names":["DeleteFlpUseCase","flpCrud","folder","WebinyError","error"],"mappings":";AAKO,MAAMA;IACT,YAAoBC,OAA6B,CAAE;aAA/BA,OAAO,GAAPA;IAAgC;IAEpD,MAAM,QAAQC,MAAc,EAAiB;QACzC,IAAI;YACA,IAAI,CAACA,QACD,MAAM,IAAIC,YACN,yFACA,iDACA;gBAAED;YAAO;YAGjB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAACA,OAAO,EAAE;QACvC,EAAE,OAAOE,OAAO;YACZ,MAAMD,YAAY,IAAI,CAACC,OAAO;gBAC1B,SAAS;gBACT,MAAM;YACV;QACJ;IACJ;AACJ"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Container } from "@webiny/di";
|
|
2
|
-
import type { AcoContext } from "../../../types.js";
|
|
3
|
-
interface LegacyDeps {
|
|
4
|
-
context: AcoContext;
|
|
5
|
-
}
|
|
6
2
|
export declare const DeleteFlpFeature: {
|
|
7
3
|
name: string;
|
|
8
|
-
register(container: Container
|
|
4
|
+
register(container: Container): void;
|
|
9
5
|
};
|
|
10
|
-
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { DeleteFlpUseCase } from "./DeleteFlpUseCase.js";
|
|
3
3
|
import { DeleteFlpUseCase as external_abstractions_js_DeleteFlpUseCase } from "./abstractions.js";
|
|
4
|
+
import { AcoFlpCrud } from "../../folder/shared/abstractions.js";
|
|
4
5
|
const DeleteFlpFeature = createFeature({
|
|
5
6
|
name: "DeleteFlp",
|
|
6
|
-
register (container
|
|
7
|
-
container.registerFactory(external_abstractions_js_DeleteFlpUseCase, ()=>new DeleteFlpUseCase(
|
|
7
|
+
register (container) {
|
|
8
|
+
container.registerFactory(external_abstractions_js_DeleteFlpUseCase, ()=>new DeleteFlpUseCase(container.resolve(AcoFlpCrud)));
|
|
8
9
|
}
|
|
9
10
|
});
|
|
10
11
|
export { DeleteFlpFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/flp/DeleteFlp/feature.js","sources":["../../../../src/features/flp/DeleteFlp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { DeleteFlpUseCase } from \"./DeleteFlpUseCase.js\";\nimport { DeleteFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport
|
|
1
|
+
{"version":3,"file":"features/flp/DeleteFlp/feature.js","sources":["../../../../src/features/flp/DeleteFlp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { DeleteFlpUseCase } from \"./DeleteFlpUseCase.js\";\nimport { DeleteFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\n\nexport const DeleteFlpFeature = createFeature({\n name: \"DeleteFlp\",\n register(container: Container) {\n container.registerFactory(UseCaseAbstraction, () => {\n return new DeleteFlpUseCase(container.resolve(AcoFlpCrud));\n });\n }\n});\n"],"names":["DeleteFlpFeature","createFeature","container","UseCaseAbstraction","DeleteFlpUseCase","AcoFlpCrud"],"mappings":";;;;AAMO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAoB;QACzBA,UAAU,eAAe,CAACC,2CAAoB,IACnC,IAAIC,iBAAiBF,UAAU,OAAO,CAACG;IAEtD;AACJ"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { DeleteFlpUseCase } from "../DeleteFlp/abstractions.js";
|
|
2
1
|
import { FolderAfterDeleteEventHandler } from "../../../features/folder/DeleteFolder/abstractions.js";
|
|
3
2
|
import type { FolderAfterDeleteEvent } from "../../../features/folder/DeleteFolder/events.js";
|
|
4
3
|
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
4
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
5
5
|
declare class DeleteFlpOnFolderDeletedHandlerImpl implements FolderAfterDeleteEventHandler.Interface {
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
6
|
+
private tasks;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(tasks: TaskService.Interface, logger: Logger.Interface);
|
|
9
9
|
handle(event: FolderAfterDeleteEvent): Promise<void>;
|
|
10
|
+
private logFailure;
|
|
10
11
|
}
|
|
11
12
|
export declare const DeleteFlpOnFolderDeletedHandler: typeof DeleteFlpOnFolderDeletedHandlerImpl & {
|
|
12
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-core/features/eventPublisher").DomainEvent<import("~/features/folder/DeleteFolder/abstractions.js").FolderAfterDeletePayload>>>;
|
|
13
14
|
};
|
|
14
15
|
export {};
|
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import { DeleteFlpUseCase } from "../DeleteFlp/abstractions.js";
|
|
2
1
|
import { FolderAfterDeleteEventHandler } from "../../folder/DeleteFolder/abstractions.js";
|
|
3
2
|
import { DELETE_FLP_TASK_ID } from "../../../flp/tasks/index.js";
|
|
4
3
|
import { TaskService } from "@webiny/api-core/features/task/TaskService/index.js";
|
|
4
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
5
5
|
class DeleteFlpOnFolderDeletedHandlerImpl {
|
|
6
|
-
constructor(
|
|
7
|
-
this.deleteFlpUseCase = deleteFlpUseCase;
|
|
6
|
+
constructor(tasks, logger){
|
|
8
7
|
this.tasks = tasks;
|
|
8
|
+
this.logger = logger;
|
|
9
9
|
}
|
|
10
10
|
async handle(event) {
|
|
11
11
|
const { folder } = event.payload;
|
|
12
12
|
try {
|
|
13
|
-
|
|
13
|
+
const result = await this.tasks.trigger({
|
|
14
14
|
definition: DELETE_FLP_TASK_ID,
|
|
15
15
|
input: {
|
|
16
16
|
folder
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
} catch
|
|
19
|
+
if (result.isFail()) this.logFailure(folder.id, result.error);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
this.logFailure(folder.id, error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
logFailure(folderId, error) {
|
|
25
|
+
this.logger.error({
|
|
26
|
+
error,
|
|
27
|
+
folderId
|
|
28
|
+
}, "Could not trigger the task that deletes the folder's FLP record.");
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
31
|
const DeleteFlpOnFolderDeletedHandler = FolderAfterDeleteEventHandler.createImplementation({
|
|
24
32
|
implementation: DeleteFlpOnFolderDeletedHandlerImpl,
|
|
25
33
|
dependencies: [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
TaskService,
|
|
29
|
-
{
|
|
30
|
-
optional: true
|
|
31
|
-
}
|
|
32
|
-
]
|
|
34
|
+
TaskService,
|
|
35
|
+
Logger
|
|
33
36
|
]
|
|
34
37
|
});
|
|
35
38
|
export { DeleteFlpOnFolderDeletedHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js","sources":["../../../../src/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.js","sources":["../../../../src/features/flp/DeleteFlpOnFolderDeleted/DeleteFlpOnFolderDeletedHandler.ts"],"sourcesContent":["import { FolderAfterDeleteEventHandler } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport type { FolderAfterDeleteEvent } from \"~/features/folder/DeleteFolder/events.js\";\nimport type { IDeleteFlpTaskInput } from \"~/types.js\";\nimport { DELETE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\nclass DeleteFlpOnFolderDeletedHandlerImpl implements FolderAfterDeleteEventHandler.Interface {\n constructor(\n private tasks: TaskService.Interface,\n private logger: Logger.Interface\n ) {}\n\n async handle(event: FolderAfterDeleteEvent): Promise<void> {\n const { folder } = event.payload;\n\n try {\n const result = await this.tasks.trigger<IDeleteFlpTaskInput>({\n definition: DELETE_FLP_TASK_ID,\n input: { folder }\n });\n if (result.isFail()) {\n this.logFailure(folder.id, result.error);\n }\n } catch (error) {\n this.logFailure(folder.id, error);\n }\n }\n\n /*\n * The folder change is already saved, so it stands. But the folder's FLP record is left behind,\n * and this log is the only trace of why.\n */\n private logFailure(folderId: string, error: unknown): void {\n this.logger.error(\n { error, folderId },\n \"Could not trigger the task that deletes the folder's FLP record.\"\n );\n }\n}\n\nexport const DeleteFlpOnFolderDeletedHandler = FolderAfterDeleteEventHandler.createImplementation({\n implementation: DeleteFlpOnFolderDeletedHandlerImpl,\n dependencies: [TaskService, Logger]\n});\n"],"names":["DeleteFlpOnFolderDeletedHandlerImpl","tasks","logger","event","folder","result","DELETE_FLP_TASK_ID","error","folderId","DeleteFlpOnFolderDeletedHandler","FolderAfterDeleteEventHandler","TaskService","Logger"],"mappings":";;;;AAOA,MAAMA;IACF,YACYC,KAA4B,EAC5BC,MAAwB,CAClC;aAFUD,KAAK,GAALA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,OAAOC,KAA6B,EAAiB;QACvD,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAM,OAAO;QAEhC,IAAI;YACA,MAAME,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB;gBACzD,YAAYC;gBACZ,OAAO;oBAAEF;gBAAO;YACpB;YACA,IAAIC,OAAO,MAAM,IACb,IAAI,CAAC,UAAU,CAACD,OAAO,EAAE,EAAEC,OAAO,KAAK;QAE/C,EAAE,OAAOE,OAAO;YACZ,IAAI,CAAC,UAAU,CAACH,OAAO,EAAE,EAAEG;QAC/B;IACJ;IAMQ,WAAWC,QAAgB,EAAED,KAAc,EAAQ;QACvD,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;YAAEA;YAAOC;QAAS,GAClB;IAER;AACJ;AAEO,MAAMC,kCAAkCC,8BAA8B,oBAAoB,CAAC;IAC9F,gBAAgBV;IAChB,cAAc;QAACW;QAAaC;KAAO;AACvC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { FeatureFlags } from "@webiny/api-core/features/featureFlags/abstractions.js";
|
|
3
3
|
import { ListUserTeamsUseCase } from "@webiny/api-core/features/users/ListUserTeams/index.js";
|
|
4
4
|
import { type CanAccessFolderContentParams, type CanAccessFolderParams } from "./useCases/index.js";
|
|
5
5
|
import { FolderLevelPermissions as FolderLevelPermissionsAbstraction } from "./abstractions.js";
|
|
@@ -8,11 +8,11 @@ import { ListFlpsUseCase } from "../../../features/flp/ListFlps/index.js";
|
|
|
8
8
|
import { GetFlpUseCase } from "../../../features/flp/GetFlp/index.js";
|
|
9
9
|
declare class FolderLevelPermissionsImpl implements FolderLevelPermissionsAbstraction.Interface {
|
|
10
10
|
private identityContext;
|
|
11
|
-
private
|
|
11
|
+
private featureFlags;
|
|
12
12
|
private listUserTeamsUseCase;
|
|
13
13
|
private getFlpUseCase;
|
|
14
14
|
private listFlpsUseCase;
|
|
15
|
-
constructor(identityContext: IdentityContext.Interface,
|
|
15
|
+
constructor(identityContext: IdentityContext.Interface, featureFlags: FeatureFlags.Interface, listUserTeamsUseCase: ListUserTeamsUseCase.Interface, getFlpUseCase: GetFlpUseCase.Interface, listFlpsUseCase: ListFlpsUseCase.Interface);
|
|
16
16
|
canUseFolderLevelPermissions(enabled?: boolean): boolean;
|
|
17
17
|
canUseTeams(): boolean;
|
|
18
18
|
canCreateFolderInRoot(): boolean;
|
|
@@ -29,6 +29,7 @@ declare class FolderLevelPermissionsImpl implements FolderLevelPermissionsAbstra
|
|
|
29
29
|
id: string;
|
|
30
30
|
permissions: FolderPermission[];
|
|
31
31
|
}>>;
|
|
32
|
+
private createDefaultPermissions;
|
|
32
33
|
getFolderLevelPermissions(id: string): Promise<FolderPermission[]>;
|
|
33
34
|
}
|
|
34
35
|
export declare const FolderLevelPermissions: import("@webiny/di").Implementation<typeof FolderLevelPermissionsImpl>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/di";
|
|
2
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { FeatureFlags } from "@webiny/api-core/features/featureFlags/abstractions.js";
|
|
4
4
|
import { ListUserTeamsUseCase } from "@webiny/api-core/features/users/ListUserTeams/index.js";
|
|
5
5
|
import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/index.js";
|
|
6
6
|
import { CanAccessFolder, CanAccessFolderContent, CanCreateFolderInRoot, CheckNotInheritedPermissions, GetDefaultPermissions, GetDefaultPermissionsWithTeams } from "./useCases/index.js";
|
|
@@ -8,9 +8,9 @@ import { FolderLevelPermissions } from "./abstractions.js";
|
|
|
8
8
|
import { ListFlpsUseCase } from "../ListFlps/index.js";
|
|
9
9
|
import { GetFlpUseCase } from "../GetFlp/index.js";
|
|
10
10
|
class FolderLevelPermissionsImpl {
|
|
11
|
-
constructor(identityContext,
|
|
11
|
+
constructor(identityContext, featureFlags, listUserTeamsUseCase, getFlpUseCase, listFlpsUseCase){
|
|
12
12
|
this.identityContext = identityContext;
|
|
13
|
-
this.
|
|
13
|
+
this.featureFlags = featureFlags;
|
|
14
14
|
this.listUserTeamsUseCase = listUserTeamsUseCase;
|
|
15
15
|
this.getFlpUseCase = getFlpUseCase;
|
|
16
16
|
this.listFlpsUseCase = listFlpsUseCase;
|
|
@@ -20,10 +20,10 @@ class FolderLevelPermissionsImpl {
|
|
|
20
20
|
const identity = this.identityContext.getIdentity();
|
|
21
21
|
if (!identity) return false;
|
|
22
22
|
if ("admin" !== identity.type) return false;
|
|
23
|
-
return this.
|
|
23
|
+
return this.featureFlags.get().isEnabled("advancedAccessControlLayer.folderLevelPermissions");
|
|
24
24
|
}
|
|
25
25
|
canUseTeams() {
|
|
26
|
-
return this.
|
|
26
|
+
return this.featureFlags.get().isEnabled("advancedAccessControlLayer.teams");
|
|
27
27
|
}
|
|
28
28
|
canCreateFolderInRoot() {
|
|
29
29
|
const canCreateFolderInRootUseCase = new CanCreateFolderInRoot();
|
|
@@ -77,20 +77,21 @@ class FolderLevelPermissionsImpl {
|
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
getDefaultPermissions(permissions) {
|
|
80
|
-
|
|
81
|
-
if (this.canUseTeams()) {
|
|
82
|
-
const getDefaultPermissionsWithTeams = new GetDefaultPermissionsWithTeams(this.identityContext, this.listUserTeamsUseCase, getDefaultPermissionsUseCase);
|
|
83
|
-
return getDefaultPermissionsWithTeams.execute(permissions);
|
|
84
|
-
}
|
|
85
|
-
return getDefaultPermissionsUseCase.execute(permissions);
|
|
80
|
+
return this.createDefaultPermissions().execute(permissions);
|
|
86
81
|
}
|
|
87
82
|
async listFolderLevelPermissions(params) {
|
|
88
83
|
const flps = await this.listFlpsUseCase.execute(params);
|
|
84
|
+
const defaultPermissions = this.createDefaultPermissions();
|
|
89
85
|
return Promise.all(flps.map(async (flp)=>({
|
|
90
86
|
id: flp.id,
|
|
91
|
-
permissions: await
|
|
87
|
+
permissions: await defaultPermissions.execute(flp.permissions)
|
|
92
88
|
})));
|
|
93
89
|
}
|
|
90
|
+
createDefaultPermissions() {
|
|
91
|
+
const getDefaultPermissionsUseCase = new GetDefaultPermissions(this.identityContext);
|
|
92
|
+
if (!this.canUseTeams()) return getDefaultPermissionsUseCase;
|
|
93
|
+
return new GetDefaultPermissionsWithTeams(this.identityContext, this.listUserTeamsUseCase, getDefaultPermissionsUseCase);
|
|
94
|
+
}
|
|
94
95
|
async getFolderLevelPermissions(id) {
|
|
95
96
|
const flp = await this.getFlpUseCase.execute(id);
|
|
96
97
|
return await this.getDefaultPermissions(flp?.permissions ?? []);
|
|
@@ -101,7 +102,7 @@ const FolderLevelPermissions_FolderLevelPermissions = createImplementation({
|
|
|
101
102
|
implementation: FolderLevelPermissionsImpl,
|
|
102
103
|
dependencies: [
|
|
103
104
|
IdentityContext,
|
|
104
|
-
|
|
105
|
+
FeatureFlags,
|
|
105
106
|
ListUserTeamsUseCase,
|
|
106
107
|
GetFlpUseCase,
|
|
107
108
|
ListFlpsUseCase
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/flp/FolderLevelPermissions/FolderLevelPermissions.js","sources":["../../../../src/features/flp/FolderLevelPermissions/FolderLevelPermissions.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { ListUserTeamsUseCase } from \"@webiny/api-core/features/users/ListUserTeams/index.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport {\n CanAccessFolder,\n CanAccessFolderContent,\n type CanAccessFolderContentParams,\n type CanAccessFolderParams,\n CanCreateFolderInRoot,\n CheckNotInheritedPermissions,\n GetDefaultPermissions,\n GetDefaultPermissionsWithTeams\n} from \"./useCases/index.js\";\nimport { FolderLevelPermissions as FolderLevelPermissionsAbstraction } from \"./abstractions.js\";\nimport type { FolderLevelPermission, FolderPermission, ListFlpsParams } from \"~/types.js\";\nimport { ListFlpsUseCase } from \"~/features/flp/ListFlps/index.js\";\nimport { GetFlpUseCase } from \"~/features/flp/GetFlp/index.js\";\n\nclass FolderLevelPermissionsImpl implements FolderLevelPermissionsAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private wcpContext: WcpContext.Interface,\n private listUserTeamsUseCase: ListUserTeamsUseCase.Interface,\n private getFlpUseCase: GetFlpUseCase.Interface,\n private listFlpsUseCase: ListFlpsUseCase.Interface\n ) {}\n\n public canUseFolderLevelPermissions(enabled?: boolean): boolean {\n if (enabled === false) {\n return false;\n }\n\n const identity = this.identityContext.getIdentity();\n\n // FLPs only work with authenticated identities (logged-in users).\n if (!identity) {\n return false;\n }\n\n // At the moment, we only want FLP to be used with identities of type \"admin\".\n // This temporarily addresses the issue of API keys not being able to access content, because\n // FLPs doesn't work with them. Once we start adding FLPs to API keys, we can remove this check.\n if (identity.type !== \"admin\") {\n return false;\n }\n\n return this.wcpContext.canUseFolderLevelPermissions();\n }\n\n public canUseTeams(): boolean {\n return this.wcpContext.canUseTeams();\n }\n\n public canCreateFolderInRoot(): boolean {\n const canCreateFolderInRootUseCase = new CanCreateFolderInRoot();\n return canCreateFolderInRootUseCase.execute();\n }\n\n public permissionsIncludeNonInheritedPermissions(permissions: FolderPermission[]): boolean {\n const checkNotInheritedPermissionsUseCase = new CheckNotInheritedPermissions();\n return checkNotInheritedPermissionsUseCase.execute(permissions);\n }\n\n public async canAccessFolder(params: CanAccessFolderParams): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n const canAccessFolderUseCase = new CanAccessFolder(this.identityContext);\n return await canAccessFolderUseCase.execute(params);\n }\n\n public async canAccessFolderContent(params: CanAccessFolderContentParams): Promise<boolean> {\n const canUseFlp = this.canUseFolderLevelPermissions();\n const authEnabled = this.identityContext.isAuthorizationEnabled();\n\n if (!canUseFlp || !authEnabled) {\n return true;\n }\n\n const canAccessFolderContentUseCase = new CanAccessFolderContent(this.identityContext);\n return await canAccessFolderContentUseCase.execute(params);\n }\n\n public async ensureCanAccessFolder(params: CanAccessFolderParams): Promise<void> {\n const result = await this.canAccessFolder(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async ensureCanAccessFolderContent(params: CanAccessFolderContentParams): Promise<void> {\n const result = await this.canAccessFolderContent(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async canManageFolderContent(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolderContent({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderStructure(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolder({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderPermissions(flp: FolderLevelPermission): Promise<boolean> {\n if (!this.canUseFolderLevelPermissions()) {\n return false;\n }\n\n if (!this.identityContext.isAuthorizationEnabled()) {\n return true;\n }\n\n return await this.canAccessFolder({\n permissions: flp.permissions,\n rwd: \"w\",\n managePermissions: true\n });\n }\n\n public getDefaultPermissions(permissions: FolderPermission[]): Promise<FolderPermission[]> {\n const getDefaultPermissionsUseCase = new GetDefaultPermissions(this.identityContext);\n\n if (this.canUseTeams()) {\n const getDefaultPermissionsWithTeams = new GetDefaultPermissionsWithTeams(\n this.identityContext,\n this.listUserTeamsUseCase,\n getDefaultPermissionsUseCase\n );\n\n return getDefaultPermissionsWithTeams.execute(permissions);\n }\n\n return getDefaultPermissionsUseCase.execute(permissions);\n }\n\n public async listFolderLevelPermissions(params: ListFlpsParams): Promise<\n Array<{\n id: string;\n permissions: FolderPermission[];\n }>\n > {\n const flps = await this.listFlpsUseCase.execute(params);\n\n return Promise.all(\n flps.map(async flp => ({\n id: flp.id,\n permissions: await this.getDefaultPermissions(flp.permissions)\n }))\n );\n }\n\n public async getFolderLevelPermissions(id: string): Promise<FolderPermission[]> {\n const flp = await this.getFlpUseCase.execute(id);\n return await this.getDefaultPermissions(flp?.permissions ?? []);\n }\n}\n\nexport const FolderLevelPermissions = createImplementation({\n abstraction: FolderLevelPermissionsAbstraction,\n implementation: FolderLevelPermissionsImpl,\n dependencies: [\n IdentityContext,\n WcpContext,\n ListUserTeamsUseCase,\n GetFlpUseCase,\n ListFlpsUseCase\n ]\n});\n"],"names":["FolderLevelPermissionsImpl","identityContext","wcpContext","listUserTeamsUseCase","getFlpUseCase","listFlpsUseCase","enabled","identity","canCreateFolderInRootUseCase","CanCreateFolderInRoot","permissions","checkNotInheritedPermissionsUseCase","CheckNotInheritedPermissions","params","canAccessFolderUseCase","CanAccessFolder","canUseFlp","authEnabled","canAccessFolderContentUseCase","CanAccessFolderContent","result","NotAuthorizedError","flp","getDefaultPermissionsUseCase","GetDefaultPermissions","getDefaultPermissionsWithTeams","GetDefaultPermissionsWithTeams","flps","Promise","id","FolderLevelPermissions","createImplementation","FolderLevelPermissionsAbstraction","IdentityContext","WcpContext","ListUserTeamsUseCase","GetFlpUseCase","ListFlpsUseCase"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"features/flp/FolderLevelPermissions/FolderLevelPermissions.js","sources":["../../../../src/features/flp/FolderLevelPermissions/FolderLevelPermissions.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { FeatureFlags } from \"@webiny/api-core/features/featureFlags/abstractions.js\";\nimport { ListUserTeamsUseCase } from \"@webiny/api-core/features/users/ListUserTeams/index.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport {\n CanAccessFolder,\n CanAccessFolderContent,\n type CanAccessFolderContentParams,\n type CanAccessFolderParams,\n CanCreateFolderInRoot,\n CheckNotInheritedPermissions,\n GetDefaultPermissions,\n GetDefaultPermissionsWithTeams,\n type IGetDefaultPermissions\n} from \"./useCases/index.js\";\nimport { FolderLevelPermissions as FolderLevelPermissionsAbstraction } from \"./abstractions.js\";\nimport type { FolderLevelPermission, FolderPermission, ListFlpsParams } from \"~/types.js\";\nimport { ListFlpsUseCase } from \"~/features/flp/ListFlps/index.js\";\nimport { GetFlpUseCase } from \"~/features/flp/GetFlp/index.js\";\n\nclass FolderLevelPermissionsImpl implements FolderLevelPermissionsAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private featureFlags: FeatureFlags.Interface,\n private listUserTeamsUseCase: ListUserTeamsUseCase.Interface,\n private getFlpUseCase: GetFlpUseCase.Interface,\n private listFlpsUseCase: ListFlpsUseCase.Interface\n ) {}\n\n public canUseFolderLevelPermissions(enabled?: boolean): boolean {\n if (enabled === false) {\n return false;\n }\n\n const identity = this.identityContext.getIdentity();\n\n // FLPs only work with authenticated identities (logged-in users).\n if (!identity) {\n return false;\n }\n\n // At the moment, we only want FLP to be used with identities of type \"admin\".\n // This temporarily addresses the issue of API keys not being able to access content, because\n // FLPs doesn't work with them. Once we start adding FLPs to API keys, we can remove this check.\n if (identity.type !== \"admin\") {\n return false;\n }\n\n return this.featureFlags\n .get()\n .isEnabled(\"advancedAccessControlLayer.folderLevelPermissions\");\n }\n\n public canUseTeams(): boolean {\n return this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.teams\");\n }\n\n public canCreateFolderInRoot(): boolean {\n const canCreateFolderInRootUseCase = new CanCreateFolderInRoot();\n return canCreateFolderInRootUseCase.execute();\n }\n\n public permissionsIncludeNonInheritedPermissions(permissions: FolderPermission[]): boolean {\n const checkNotInheritedPermissionsUseCase = new CheckNotInheritedPermissions();\n return checkNotInheritedPermissionsUseCase.execute(permissions);\n }\n\n public async canAccessFolder(params: CanAccessFolderParams): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n const canAccessFolderUseCase = new CanAccessFolder(this.identityContext);\n return await canAccessFolderUseCase.execute(params);\n }\n\n public async canAccessFolderContent(params: CanAccessFolderContentParams): Promise<boolean> {\n const canUseFlp = this.canUseFolderLevelPermissions();\n const authEnabled = this.identityContext.isAuthorizationEnabled();\n\n if (!canUseFlp || !authEnabled) {\n return true;\n }\n\n const canAccessFolderContentUseCase = new CanAccessFolderContent(this.identityContext);\n return await canAccessFolderContentUseCase.execute(params);\n }\n\n public async ensureCanAccessFolder(params: CanAccessFolderParams): Promise<void> {\n const result = await this.canAccessFolder(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async ensureCanAccessFolderContent(params: CanAccessFolderContentParams): Promise<void> {\n const result = await this.canAccessFolderContent(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async canManageFolderContent(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolderContent({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderStructure(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolder({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderPermissions(flp: FolderLevelPermission): Promise<boolean> {\n if (!this.canUseFolderLevelPermissions()) {\n return false;\n }\n\n if (!this.identityContext.isAuthorizationEnabled()) {\n return true;\n }\n\n return await this.canAccessFolder({\n permissions: flp.permissions,\n rwd: \"w\",\n managePermissions: true\n });\n }\n\n // With teams enabled, every call loads the current user's teams through `ListUserTeamsUseCase`\n // (an admin user read plus a team list). Nothing caches them between calls.\n public getDefaultPermissions(permissions: FolderPermission[]): Promise<FolderPermission[]> {\n return this.createDefaultPermissions().execute(permissions);\n }\n\n public async listFolderLevelPermissions(params: ListFlpsParams): Promise<\n Array<{\n id: string;\n permissions: FolderPermission[];\n }>\n > {\n const flps = await this.listFlpsUseCase.execute(params);\n\n // One instance for every listed record: with teams enabled, the user's teams are loaded\n // once per call, not once per record.\n const defaultPermissions = this.createDefaultPermissions();\n return Promise.all(\n flps.map(async flp => ({\n id: flp.id,\n permissions: await defaultPermissions.execute(flp.permissions)\n }))\n );\n }\n\n private createDefaultPermissions(): IGetDefaultPermissions {\n const getDefaultPermissionsUseCase = new GetDefaultPermissions(this.identityContext);\n if (!this.canUseTeams()) {\n return getDefaultPermissionsUseCase;\n }\n return new GetDefaultPermissionsWithTeams(\n this.identityContext,\n this.listUserTeamsUseCase,\n getDefaultPermissionsUseCase\n );\n }\n\n public async getFolderLevelPermissions(id: string): Promise<FolderPermission[]> {\n const flp = await this.getFlpUseCase.execute(id);\n return await this.getDefaultPermissions(flp?.permissions ?? []);\n }\n}\n\nexport const FolderLevelPermissions = createImplementation({\n abstraction: FolderLevelPermissionsAbstraction,\n implementation: FolderLevelPermissionsImpl,\n dependencies: [\n IdentityContext,\n FeatureFlags,\n ListUserTeamsUseCase,\n GetFlpUseCase,\n ListFlpsUseCase\n ]\n});\n"],"names":["FolderLevelPermissionsImpl","identityContext","featureFlags","listUserTeamsUseCase","getFlpUseCase","listFlpsUseCase","enabled","identity","canCreateFolderInRootUseCase","CanCreateFolderInRoot","permissions","checkNotInheritedPermissionsUseCase","CheckNotInheritedPermissions","params","canAccessFolderUseCase","CanAccessFolder","canUseFlp","authEnabled","canAccessFolderContentUseCase","CanAccessFolderContent","result","NotAuthorizedError","flp","flps","defaultPermissions","Promise","getDefaultPermissionsUseCase","GetDefaultPermissions","GetDefaultPermissionsWithTeams","id","FolderLevelPermissions","createImplementation","FolderLevelPermissionsAbstraction","IdentityContext","FeatureFlags","ListUserTeamsUseCase","GetFlpUseCase","ListFlpsUseCase"],"mappings":"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"}
|
|
@@ -6,6 +6,12 @@ export declare class GetDefaultPermissionsWithTeams implements IGetDefaultPermis
|
|
|
6
6
|
private identityContext;
|
|
7
7
|
private listUserTeamsUseCase;
|
|
8
8
|
private decoretee;
|
|
9
|
+
/**
|
|
10
|
+
* The identity's teams, loaded once per instance and identity. An instance lives for one
|
|
11
|
+
* `getDefaultPermissions` call or one `listFolderLevelPermissions` call, so nothing is kept
|
|
12
|
+
* between calls or requests.
|
|
13
|
+
*/
|
|
14
|
+
private loaded;
|
|
9
15
|
constructor(identityContext: IdentityContext.Interface, listUserTeamsUseCase: ListUserTeamsUseCase.Interface, decoretee: IGetDefaultPermissions);
|
|
10
16
|
execute(originalPermissions: FolderPermission[]): Promise<FolderPermission[]>;
|
|
11
17
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
class GetDefaultPermissionsWithTeams {
|
|
2
2
|
constructor(identityContext, listUserTeamsUseCase, decoretee){
|
|
3
|
+
this.loaded = null;
|
|
3
4
|
this.identityContext = identityContext;
|
|
4
5
|
this.listUserTeamsUseCase = listUserTeamsUseCase;
|
|
5
6
|
this.decoretee = decoretee;
|
|
6
7
|
}
|
|
7
8
|
async execute(originalPermissions) {
|
|
8
9
|
const identity = this.identityContext.getIdentity();
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
if (!this.loaded || this.loaded.identityId !== identity.id) this.loaded = {
|
|
11
|
+
identityId: identity.id,
|
|
12
|
+
teams: this.listUserTeamsUseCase.execute(identity.id).then((result)=>result.isOk() ? result.value : [])
|
|
13
|
+
};
|
|
14
|
+
const identityTeams = await this.loaded.teams;
|
|
11
15
|
const permissions = [
|
|
12
16
|
...originalPermissions
|
|
13
17
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js","sources":["../../../../../../src/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.ts"],"sourcesContent":["import type { IGetDefaultPermissions } from \"./IGetDefaultPermissions.js\";\nimport type { FolderPermission } from \"~/flp/flp.types.js\";\nimport type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { ListUserTeamsUseCase } from \"@webiny/api-core/features/users/ListUserTeams/index.js\";\nimport type { Team } from \"@webiny/api-core/types/security.js\";\n\nexport class GetDefaultPermissionsWithTeams implements IGetDefaultPermissions {\n private identityContext: IdentityContext.Interface;\n private listUserTeamsUseCase: ListUserTeamsUseCase.Interface;\n private decoretee: IGetDefaultPermissions;\n\n constructor(\n identityContext: IdentityContext.Interface,\n listUserTeamsUseCase: ListUserTeamsUseCase.Interface,\n decoretee: IGetDefaultPermissions\n ) {\n this.identityContext = identityContext;\n this.listUserTeamsUseCase = listUserTeamsUseCase;\n this.decoretee = decoretee;\n }\n\n async execute(originalPermissions: FolderPermission[]) {\n /**\n * Retrieves the list of teams the current identity belongs to and checks if any of these teams\n * have permissions for the folder. If a team has permissions, the current identity is granted\n * the same permissions, inheriting them from the team.\n */\n const identity = this.identityContext.getIdentity();\n\n // Get teams for current identity
|
|
1
|
+
{"version":3,"file":"features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js","sources":["../../../../../../src/features/flp/FolderLevelPermissions/useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.ts"],"sourcesContent":["import type { IGetDefaultPermissions } from \"./IGetDefaultPermissions.js\";\nimport type { FolderPermission } from \"~/flp/flp.types.js\";\nimport type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { ListUserTeamsUseCase } from \"@webiny/api-core/features/users/ListUserTeams/index.js\";\nimport type { Team } from \"@webiny/api-core/types/security.js\";\n\ninterface LoadedTeams {\n identityId: string;\n teams: Promise<Team[]>;\n}\n\nexport class GetDefaultPermissionsWithTeams implements IGetDefaultPermissions {\n private identityContext: IdentityContext.Interface;\n private listUserTeamsUseCase: ListUserTeamsUseCase.Interface;\n private decoretee: IGetDefaultPermissions;\n /**\n * The identity's teams, loaded once per instance and identity. An instance lives for one\n * `getDefaultPermissions` call or one `listFolderLevelPermissions` call, so nothing is kept\n * between calls or requests.\n */\n private loaded: LoadedTeams | null = null;\n\n constructor(\n identityContext: IdentityContext.Interface,\n listUserTeamsUseCase: ListUserTeamsUseCase.Interface,\n decoretee: IGetDefaultPermissions\n ) {\n this.identityContext = identityContext;\n this.listUserTeamsUseCase = listUserTeamsUseCase;\n this.decoretee = decoretee;\n }\n\n async execute(originalPermissions: FolderPermission[]) {\n /**\n * Retrieves the list of teams the current identity belongs to and checks if any of these teams\n * have permissions for the folder. If a team has permissions, the current identity is granted\n * the same permissions, inheriting them from the team.\n */\n const identity = this.identityContext.getIdentity();\n\n // Get teams for current identity (once per instance and identity).\n if (!this.loaded || this.loaded.identityId !== identity.id) {\n this.loaded = {\n identityId: identity.id,\n teams: this.listUserTeamsUseCase.execute(identity.id).then(result => {\n return result.isOk() ? result.value : [];\n })\n };\n }\n const identityTeams: Team[] = await this.loaded.teams;\n\n const permissions = [...originalPermissions]; // Clone the original permissions to avoid mutation.\n\n if (identity && identityTeams.length) {\n for (const identityTeam of identityTeams) {\n // Check if the team has permissions for the folder.\n const teamPermission = permissions.find(\n p => p.target === `team:${identityTeam.slug}`\n );\n\n if (teamPermission) {\n // Grant the current identity the same permissions as the team, marking them as inherited.\n permissions.push({\n target: `admin:${identity.id}`,\n level: teamPermission.level,\n inheritedFrom: \"team:\" + identityTeam.slug\n });\n }\n }\n }\n\n return await this.decoretee.execute(permissions);\n }\n}\n"],"names":["GetDefaultPermissionsWithTeams","identityContext","listUserTeamsUseCase","decoretee","originalPermissions","identity","result","identityTeams","permissions","identityTeam","teamPermission","p"],"mappings":"AAWO,MAAMA;IAWT,YACIC,eAA0C,EAC1CC,oBAAoD,EACpDC,SAAiC,CACnC;QAPD,KACO,MAAM,GAAuB;QAOjC,IAAI,CAAC,eAAe,GAAGF;QACvB,IAAI,CAAC,oBAAoB,GAAGC;QAC5B,IAAI,CAAC,SAAS,GAAGC;IACrB;IAEA,MAAM,QAAQC,mBAAuC,EAAE;QAMnD,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAGjD,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,KAAKA,SAAS,EAAE,EACtD,IAAI,CAAC,MAAM,GAAG;YACV,YAAYA,SAAS,EAAE;YACvB,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAACA,SAAS,EAAE,EAAE,IAAI,CAACC,CAAAA,SAChDA,OAAO,IAAI,KAAKA,OAAO,KAAK,GAAG,EAAE;QAEhD;QAEJ,MAAMC,gBAAwB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK;QAErD,MAAMC,cAAc;eAAIJ;SAAoB;QAE5C,IAAIC,YAAYE,cAAc,MAAM,EAChC,KAAK,MAAME,gBAAgBF,cAAe;YAEtC,MAAMG,iBAAiBF,YAAY,IAAI,CACnCG,CAAAA,IAAKA,EAAE,MAAM,KAAK,CAAC,KAAK,EAAEF,aAAa,IAAI,EAAE;YAGjD,IAAIC,gBAEAF,YAAY,IAAI,CAAC;gBACb,QAAQ,CAAC,MAAM,EAAEH,SAAS,EAAE,EAAE;gBAC9B,OAAOK,eAAe,KAAK;gBAC3B,eAAe,UAAUD,aAAa,IAAI;YAC9C;QAER;QAGJ,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACD;IACxC;AACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GetFlpUseCase } from "../abstractions.js";
|
|
2
|
+
import { CodeFlpsProvider } from "../../../../features/flp/shared/index.js";
|
|
3
|
+
import type { FolderLevelPermission } from "../../../../flp/flp.types.js";
|
|
4
|
+
declare class GetFlpWithCodeFlpsImpl implements GetFlpUseCase.Interface {
|
|
5
|
+
private codeFlpsProvider;
|
|
6
|
+
private decoratee;
|
|
7
|
+
constructor(codeFlpsProvider: CodeFlpsProvider.Interface, decoratee: GetFlpUseCase.Interface);
|
|
8
|
+
execute(id: string): Promise<FolderLevelPermission | null>;
|
|
9
|
+
}
|
|
10
|
+
export declare const GetFlpWithCodeFlps: typeof GetFlpWithCodeFlpsImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("../abstractions.js").IGetFolderPermission>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GetFlpUseCase } from "../abstractions.js";
|
|
2
|
+
import { CodeFlpMerger, CodeFlpsProvider } from "../../shared/index.js";
|
|
3
|
+
class GetFlpWithCodeFlpsImpl {
|
|
4
|
+
constructor(codeFlpsProvider, decoratee){
|
|
5
|
+
this.codeFlpsProvider = codeFlpsProvider;
|
|
6
|
+
this.decoratee = decoratee;
|
|
7
|
+
}
|
|
8
|
+
async execute(id) {
|
|
9
|
+
const flp = await this.decoratee.execute(id);
|
|
10
|
+
if (!flp) return null;
|
|
11
|
+
const codePermissions = await this.codeFlpsProvider.getPermissions({
|
|
12
|
+
type: flp.type,
|
|
13
|
+
path: flp.path
|
|
14
|
+
});
|
|
15
|
+
return CodeFlpMerger.merge(flp, codePermissions);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const GetFlpWithCodeFlps = GetFlpUseCase.createDecorator({
|
|
19
|
+
decorator: GetFlpWithCodeFlpsImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
CodeFlpsProvider
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { GetFlpWithCodeFlps };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=GetFlpWithCodeFlps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/flp/GetFlp/decorators/GetFlpWithCodeFlps.js","sources":["../../../../../src/features/flp/GetFlp/decorators/GetFlpWithCodeFlps.ts"],"sourcesContent":["import { GetFlpUseCase } from \"../abstractions.js\";\nimport { CodeFlpMerger, CodeFlpsProvider } from \"~/features/flp/shared/index.js\";\nimport type { FolderLevelPermission } from \"~/flp/flp.types.js\";\n\nclass GetFlpWithCodeFlpsImpl implements GetFlpUseCase.Interface {\n constructor(\n private codeFlpsProvider: CodeFlpsProvider.Interface,\n private decoratee: GetFlpUseCase.Interface\n ) {}\n\n async execute(id: string): Promise<FolderLevelPermission | null> {\n const flp = await this.decoratee.execute(id);\n\n if (!flp) {\n return null;\n }\n\n const codePermissions = await this.codeFlpsProvider.getPermissions({\n type: flp.type,\n path: flp.path\n });\n\n return CodeFlpMerger.merge(flp, codePermissions);\n }\n}\n\nexport const GetFlpWithCodeFlps = GetFlpUseCase.createDecorator({\n decorator: GetFlpWithCodeFlpsImpl,\n dependencies: [CodeFlpsProvider]\n});\n"],"names":["GetFlpWithCodeFlpsImpl","codeFlpsProvider","decoratee","id","flp","codePermissions","CodeFlpMerger","GetFlpWithCodeFlps","GetFlpUseCase","CodeFlpsProvider"],"mappings":";;AAIA,MAAMA;IACF,YACYC,gBAA4C,EAC5CC,SAAkC,CAC5C;aAFUD,gBAAgB,GAAhBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,EAAU,EAAyC;QAC7D,MAAMC,MAAM,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACD;QAEzC,IAAI,CAACC,KACD,OAAO;QAGX,MAAMC,kBAAkB,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC;YAC/D,MAAMD,IAAI,IAAI;YACd,MAAMA,IAAI,IAAI;QAClB;QAEA,OAAOE,cAAc,KAAK,CAACF,KAAKC;IACpC;AACJ;AAEO,MAAME,qBAAqBC,cAAc,eAAe,CAAC;IAC5D,WAAWR;IACX,cAAc;QAACS;KAAiB;AACpC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { GetFlpUseCase } from "./GetFlpUseCase.js";
|
|
3
3
|
import { GetFlpUseCase as external_abstractions_js_GetFlpUseCase } from "./abstractions.js";
|
|
4
|
+
import { AcoFlpCrud } from "../../folder/shared/abstractions.js";
|
|
4
5
|
const GetFlpFeature = createFeature({
|
|
5
6
|
name: "GetFlpFeature",
|
|
6
|
-
register (container
|
|
7
|
-
container.registerFactory(external_abstractions_js_GetFlpUseCase, ()=>new GetFlpUseCase(
|
|
7
|
+
register (container) {
|
|
8
|
+
container.registerFactory(external_abstractions_js_GetFlpUseCase, ()=>new GetFlpUseCase(container.resolve(AcoFlpCrud).get));
|
|
8
9
|
}
|
|
9
10
|
});
|
|
10
11
|
export { GetFlpFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/flp/GetFlp/feature.js","sources":["../../../../src/features/flp/GetFlp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetFlpUseCase } from \"./GetFlpUseCase.js\";\nimport { GetFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport
|
|
1
|
+
{"version":3,"file":"features/flp/GetFlp/feature.js","sources":["../../../../src/features/flp/GetFlp/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetFlpUseCase } from \"./GetFlpUseCase.js\";\nimport { GetFlpUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { AcoFlpCrud } from \"~/features/folder/shared/abstractions.js\";\n\nexport const GetFlpFeature = createFeature({\n name: \"GetFlpFeature\",\n register(container) {\n container.registerFactory(UseCaseAbstraction, () => {\n return new GetFlpUseCase(container.resolve(AcoFlpCrud).get);\n });\n }\n});\n"],"names":["GetFlpFeature","createFeature","container","UseCaseAbstraction","GetFlpUseCase","AcoFlpCrud"],"mappings":";;;;AAKO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,eAAe,CAACC,wCAAoB,IACnC,IAAIC,cAAcF,UAAU,OAAO,CAACG,YAAY,GAAG;IAElE;AACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ListFlpsUseCase } from "../abstractions.js";
|
|
2
|
+
import { CodeFlpsProvider } from "../../../../features/flp/shared/index.js";
|
|
3
|
+
import type { FolderLevelPermission, ListFlpsParams } from "../../../../flp/flp.types.js";
|
|
4
|
+
declare class ListFlpsWithCodeFlpsImpl implements ListFlpsUseCase.Interface {
|
|
5
|
+
private codeFlpsProvider;
|
|
6
|
+
private decoratee;
|
|
7
|
+
constructor(codeFlpsProvider: CodeFlpsProvider.Interface, decoratee: ListFlpsUseCase.Interface);
|
|
8
|
+
execute(params: ListFlpsParams): Promise<FolderLevelPermission[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare const ListFlpsWithCodeFlps: typeof ListFlpsWithCodeFlpsImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("../abstractions.js").IListFlps>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ListFlpsUseCase } from "../abstractions.js";
|
|
2
|
+
import { CodeFlpMerger, CodeFlpsProvider } from "../../shared/index.js";
|
|
3
|
+
class ListFlpsWithCodeFlpsImpl {
|
|
4
|
+
constructor(codeFlpsProvider, decoratee){
|
|
5
|
+
this.codeFlpsProvider = codeFlpsProvider;
|
|
6
|
+
this.decoratee = decoratee;
|
|
7
|
+
}
|
|
8
|
+
async execute(params) {
|
|
9
|
+
const flps = await this.decoratee.execute(params);
|
|
10
|
+
return Promise.all(flps.map(async (flp)=>{
|
|
11
|
+
const codePermissions = await this.codeFlpsProvider.getPermissions({
|
|
12
|
+
type: flp.type,
|
|
13
|
+
path: flp.path
|
|
14
|
+
});
|
|
15
|
+
return CodeFlpMerger.merge(flp, codePermissions);
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const ListFlpsWithCodeFlps = ListFlpsUseCase.createDecorator({
|
|
20
|
+
decorator: ListFlpsWithCodeFlpsImpl,
|
|
21
|
+
dependencies: [
|
|
22
|
+
CodeFlpsProvider
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
export { ListFlpsWithCodeFlps };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=ListFlpsWithCodeFlps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.js","sources":["../../../../../src/features/flp/ListFlps/decorators/ListFlpsWithCodeFlps.ts"],"sourcesContent":["import { ListFlpsUseCase } from \"../abstractions.js\";\nimport { CodeFlpMerger, CodeFlpsProvider } from \"~/features/flp/shared/index.js\";\nimport type { FolderLevelPermission, ListFlpsParams } from \"~/flp/flp.types.js\";\n\nclass ListFlpsWithCodeFlpsImpl implements ListFlpsUseCase.Interface {\n constructor(\n private codeFlpsProvider: CodeFlpsProvider.Interface,\n private decoratee: ListFlpsUseCase.Interface\n ) {}\n\n async execute(params: ListFlpsParams): Promise<FolderLevelPermission[]> {\n const flps = await this.decoratee.execute(params);\n\n return Promise.all(\n flps.map(async flp => {\n const codePermissions = await this.codeFlpsProvider.getPermissions({\n type: flp.type,\n path: flp.path\n });\n\n return CodeFlpMerger.merge(flp, codePermissions);\n })\n );\n }\n}\n\nexport const ListFlpsWithCodeFlps = ListFlpsUseCase.createDecorator({\n decorator: ListFlpsWithCodeFlpsImpl,\n dependencies: [CodeFlpsProvider]\n});\n"],"names":["ListFlpsWithCodeFlpsImpl","codeFlpsProvider","decoratee","params","flps","Promise","flp","codePermissions","CodeFlpMerger","ListFlpsWithCodeFlps","ListFlpsUseCase","CodeFlpsProvider"],"mappings":";;AAIA,MAAMA;IACF,YACYC,gBAA4C,EAC5CC,SAAoC,CAC9C;aAFUD,gBAAgB,GAAhBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,MAAsB,EAAoC;QACpE,MAAMC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACD;QAE1C,OAAOE,QAAQ,GAAG,CACdD,KAAK,GAAG,CAAC,OAAME;YACX,MAAMC,kBAAkB,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC;gBAC/D,MAAMD,IAAI,IAAI;gBACd,MAAMA,IAAI,IAAI;YAClB;YAEA,OAAOE,cAAc,KAAK,CAACF,KAAKC;QACpC;IAER;AACJ;AAEO,MAAME,uBAAuBC,gBAAgB,eAAe,CAAC;IAChE,WAAWV;IACX,cAAc;QAACW;KAAiB;AACpC"}
|