@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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
3
|
+
import { FolderModelProvider as Abstraction } from "../../domain/folder/abstractions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the tenant's ACO folder model on demand, replacing the per-request hook
|
|
6
|
+
* (`AcoInitializer`) that used to push an already-resolved model into the container.
|
|
7
|
+
*
|
|
8
|
+
* No memoization: `ModelsFetcher` already caches the model list per request (`ModelCache` is a
|
|
9
|
+
* per-request `createMemoryCache()`). No `withoutAuthorization` either — the folder model is
|
|
10
|
+
* private, and `PrivateModelBuilder` sets `authorization: false`, which short-circuits
|
|
11
|
+
* `canAccessModel()` to true for every identity, so the wrapper the initializer used changed
|
|
12
|
+
* nothing.
|
|
13
|
+
*
|
|
14
|
+
* `GetModelUseCase` is an ordinary constructor dependency: this provider is only constructed when a
|
|
15
|
+
* consumer first awaits `get()`, during request handling — after the CMS has registered everything
|
|
16
|
+
* the use case needs. That timing is what forced the initializer's lazy `container.resolve()`.
|
|
17
|
+
*/
|
|
18
|
+
declare class FolderModelProviderImpl implements Abstraction.Interface {
|
|
19
|
+
private getModel;
|
|
20
|
+
constructor(getModel: GetModelUseCase.Interface);
|
|
21
|
+
get(): Promise<CmsModel>;
|
|
22
|
+
}
|
|
23
|
+
export declare const FolderModelProvider: typeof FolderModelProviderImpl & {
|
|
24
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/domain/folder/abstractions.js").IFolderModelProvider>;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
2
|
+
import { FolderModelProvider } from "../../domain/folder/abstractions.js";
|
|
3
|
+
import { FOLDER_MODEL_ID } from "../../domain/folder/folder.model.js";
|
|
4
|
+
class FolderModelProviderImpl {
|
|
5
|
+
constructor(getModel){
|
|
6
|
+
this.getModel = getModel;
|
|
7
|
+
}
|
|
8
|
+
async get() {
|
|
9
|
+
const result = await this.getModel.execute(FOLDER_MODEL_ID);
|
|
10
|
+
if (result.isFail()) throw result.error;
|
|
11
|
+
return result.value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const FolderModelProvider_FolderModelProvider = FolderModelProvider.createImplementation({
|
|
15
|
+
implementation: FolderModelProviderImpl,
|
|
16
|
+
dependencies: [
|
|
17
|
+
GetModelUseCase
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
export { FolderModelProvider_FolderModelProvider as FolderModelProvider };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=FolderModelProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/folder/FolderModelProvider.js","sources":["../../../src/features/folder/FolderModelProvider.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { FolderModelProvider as Abstraction } from \"~/domain/folder/abstractions.js\";\nimport { FOLDER_MODEL_ID } from \"~/domain/folder/folder.model.js\";\n\n/**\n * Resolves the tenant's ACO folder model on demand, replacing the per-request hook\n * (`AcoInitializer`) that used to push an already-resolved model into the container.\n *\n * No memoization: `ModelsFetcher` already caches the model list per request (`ModelCache` is a\n * per-request `createMemoryCache()`). No `withoutAuthorization` either — the folder model is\n * private, and `PrivateModelBuilder` sets `authorization: false`, which short-circuits\n * `canAccessModel()` to true for every identity, so the wrapper the initializer used changed\n * nothing.\n *\n * `GetModelUseCase` is an ordinary constructor dependency: this provider is only constructed when a\n * consumer first awaits `get()`, during request handling — after the CMS has registered everything\n * the use case needs. That timing is what forced the initializer's lazy `container.resolve()`.\n */\nclass FolderModelProviderImpl implements Abstraction.Interface {\n constructor(private getModel: GetModelUseCase.Interface) {}\n\n async get(): Promise<CmsModel> {\n const result = await this.getModel.execute(FOLDER_MODEL_ID);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n}\n\nexport const FolderModelProvider = Abstraction.createImplementation({\n implementation: FolderModelProviderImpl,\n dependencies: [GetModelUseCase]\n});\n"],"names":["FolderModelProviderImpl","getModel","result","FOLDER_MODEL_ID","FolderModelProvider","Abstraction","GetModelUseCase"],"mappings":";;;AAmBA,MAAMA;IACF,YAAoBC,QAAmC,CAAE;aAArCA,QAAQ,GAARA;IAAsC;IAE1D,MAAM,MAAyB;QAC3B,MAAMC,SAAS,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACC;QAC3C,IAAID,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAEtB,OAAOA,OAAO,KAAK;IACvB;AACJ;AAEO,MAAME,0CAAsBC,oBAAAA,oBAAgC,CAAC;IAChE,gBAAgBL;IAChB,cAAc;QAACM;KAAgB;AACnC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { type GetAncestorsParams, GetAncestorsRepository as RepositoryAbstraction, type IGetAncestorsRepository } from "./abstractions.js";
|
|
3
3
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
4
|
-
import {
|
|
4
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
5
5
|
import type { Folder } from "../../../folder/folder.types.js";
|
|
6
6
|
declare class GetAncestorsRepositoryImpl implements IGetAncestorsRepository {
|
|
7
7
|
private listLatestEntries;
|
|
8
|
-
private
|
|
9
|
-
constructor(listLatestEntries: ListLatestEntriesUseCase.Interface,
|
|
8
|
+
private folderModelProvider;
|
|
9
|
+
constructor(listLatestEntries: ListLatestEntriesUseCase.Interface, folderModelProvider: FolderModelProvider.Interface);
|
|
10
10
|
execute(params: GetAncestorsParams): Promise<Result<Folder[], RepositoryAbstraction.Error>>;
|
|
11
11
|
}
|
|
12
12
|
export declare const GetAncestorsRepository: typeof GetAncestorsRepositoryImpl & {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetAncestorsRepository } from "./abstractions.js";
|
|
3
3
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
4
|
-
import {
|
|
4
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
5
5
|
import { EntryToFolderMapper } from "../shared/EntryToFolderMapper.js";
|
|
6
6
|
import { FolderPersistenceError } from "../../../domain/folder/errors.js";
|
|
7
7
|
import { ROOT_FOLDER } from "../../../constants.js";
|
|
8
8
|
class GetAncestorsRepositoryImpl {
|
|
9
|
-
constructor(listLatestEntries,
|
|
9
|
+
constructor(listLatestEntries, folderModelProvider){
|
|
10
10
|
this.listLatestEntries = listLatestEntries;
|
|
11
|
-
this.
|
|
11
|
+
this.folderModelProvider = folderModelProvider;
|
|
12
12
|
}
|
|
13
13
|
async execute(params) {
|
|
14
|
+
const folderModel = await this.folderModelProvider.get();
|
|
14
15
|
const { folder } = params;
|
|
15
16
|
if (!folder) return Result.ok([]);
|
|
16
17
|
if (!folder.parentId) return Result.ok([
|
|
@@ -21,7 +22,7 @@ class GetAncestorsRepositoryImpl {
|
|
|
21
22
|
ROOT_FOLDER,
|
|
22
23
|
...parts.slice(0, index + 1)
|
|
23
24
|
].join("/"));
|
|
24
|
-
const result = await this.listLatestEntries.execute(
|
|
25
|
+
const result = await this.listLatestEntries.execute(folderModel, {
|
|
25
26
|
where: {
|
|
26
27
|
values: {
|
|
27
28
|
type: folder.type,
|
|
@@ -50,7 +51,7 @@ const GetAncestorsRepository_GetAncestorsRepository = GetAncestorsRepository.cre
|
|
|
50
51
|
implementation: GetAncestorsRepositoryImpl,
|
|
51
52
|
dependencies: [
|
|
52
53
|
ListLatestEntriesUseCase,
|
|
53
|
-
|
|
54
|
+
FolderModelProvider
|
|
54
55
|
]
|
|
55
56
|
});
|
|
56
57
|
export { GetAncestorsRepository_GetAncestorsRepository as GetAncestorsRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/folder/GetAncestors/GetAncestorsRepository.js","sources":["../../../../src/features/folder/GetAncestors/GetAncestorsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type GetAncestorsParams,\n GetAncestorsRepository as RepositoryAbstraction,\n type IGetAncestorsRepository\n} from \"./abstractions.js\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/folder/GetAncestors/GetAncestorsRepository.js","sources":["../../../../src/features/folder/GetAncestors/GetAncestorsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type GetAncestorsParams,\n GetAncestorsRepository as RepositoryAbstraction,\n type IGetAncestorsRepository\n} from \"./abstractions.js\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport { FolderModelProvider } from \"~/domain/folder/abstractions.js\";\nimport type { CmsEntryFolder, Folder } from \"~/folder/folder.types.js\";\nimport { EntryToFolderMapper } from \"../shared/EntryToFolderMapper.js\";\nimport { FolderPersistenceError } from \"~/domain/folder/errors.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\n\nclass GetAncestorsRepositoryImpl implements IGetAncestorsRepository {\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private folderModelProvider: FolderModelProvider.Interface\n ) {}\n\n async execute(\n params: GetAncestorsParams\n ): Promise<Result<Folder[], RepositoryAbstraction.Error>> {\n const folderModel = await this.folderModelProvider.get();\n const { folder } = params;\n\n // No folder found: return an empty array\n if (!folder) {\n return Result.ok([]);\n }\n\n // The folder has no parent (it's at root level): return an array with the folder\n if (!folder.parentId) {\n return Result.ok([folder]);\n }\n\n // Construct paths for all ancestors of the folder\n const parts = folder.path.split(\"/\").slice(1);\n const paths = parts.map((_, index) => {\n return [ROOT_FOLDER, ...parts.slice(0, index + 1)].join(\"/\");\n });\n\n // Retrieve all folders that match the specified type and any of the constructed paths\n const result = await this.listLatestEntries.execute<CmsEntryFolder>(folderModel, {\n where: {\n values: {\n type: folder.type,\n path_in: paths\n }\n }\n });\n\n if (result.isFail()) {\n return Result.fail(new FolderPersistenceError(result.error));\n }\n\n const { entries } = result.value;\n const folders = entries.map(entry => EntryToFolderMapper.toFolder(entry));\n\n // Create a Map with folders, using folder.id as key\n const folderMap = new Map<string, Folder>();\n folders.forEach(f => folderMap.set(f.id, f));\n\n const findParents = (next: Folder[], current: Folder): Folder[] => {\n // No folder found: return the result\n if (!current) {\n return next;\n }\n\n // Push the current folder into the accumulator array\n next.push(current);\n\n // No parentId found: return the result\n if (!current.parentId) {\n return next;\n }\n\n const parent = folderMap.get(current.parentId);\n\n // No parent found: return the result\n if (!parent) {\n return next;\n }\n\n // Go ahead and find parent for the current parent\n return findParents(next, parent);\n };\n\n // Recursively find parents for a given folder id\n const ancestors = findParents([], folder);\n return Result.ok(ancestors);\n }\n}\n\nexport const GetAncestorsRepository = RepositoryAbstraction.createImplementation({\n implementation: GetAncestorsRepositoryImpl,\n dependencies: [ListLatestEntriesUseCase, FolderModelProvider]\n});\n"],"names":["GetAncestorsRepositoryImpl","listLatestEntries","folderModelProvider","params","folderModel","folder","Result","parts","paths","_","index","ROOT_FOLDER","result","FolderPersistenceError","entries","folders","entry","EntryToFolderMapper","folderMap","Map","f","findParents","next","current","parent","ancestors","GetAncestorsRepository","RepositoryAbstraction","ListLatestEntriesUseCase","FolderModelProvider"],"mappings":";;;;;;;AAaA,MAAMA;IACF,YACYC,iBAAqD,EACrDC,mBAAkD,CAC5D;aAFUD,iBAAiB,GAAjBA;aACAC,mBAAmB,GAAnBA;IACT;IAEH,MAAM,QACFC,MAA0B,EAC4B;QACtD,MAAMC,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG;QACtD,MAAM,EAAEC,MAAM,EAAE,GAAGF;QAGnB,IAAI,CAACE,QACD,OAAOC,OAAO,EAAE,CAAC,EAAE;QAIvB,IAAI,CAACD,OAAO,QAAQ,EAChB,OAAOC,OAAO,EAAE,CAAC;YAACD;SAAO;QAI7B,MAAME,QAAQF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;QAC3C,MAAMG,QAAQD,MAAM,GAAG,CAAC,CAACE,GAAGC,QACjB;gBAACC;mBAAgBJ,MAAM,KAAK,CAAC,GAAGG,QAAQ;aAAG,CAAC,IAAI,CAAC;QAI5D,MAAME,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAiBR,aAAa;YAC7E,OAAO;gBACH,QAAQ;oBACJ,MAAMC,OAAO,IAAI;oBACjB,SAASG;gBACb;YACJ;QACJ;QAEA,IAAII,OAAO,MAAM,IACb,OAAON,OAAO,IAAI,CAAC,IAAIO,uBAAuBD,OAAO,KAAK;QAG9D,MAAM,EAAEE,OAAO,EAAE,GAAGF,OAAO,KAAK;QAChC,MAAMG,UAAUD,QAAQ,GAAG,CAACE,CAAAA,QAASC,oBAAoB,QAAQ,CAACD;QAGlE,MAAME,YAAY,IAAIC;QACtBJ,QAAQ,OAAO,CAACK,CAAAA,IAAKF,UAAU,GAAG,CAACE,EAAE,EAAE,EAAEA;QAEzC,MAAMC,cAAc,CAACC,MAAgBC;YAEjC,IAAI,CAACA,SACD,OAAOD;YAIXA,KAAK,IAAI,CAACC;YAGV,IAAI,CAACA,QAAQ,QAAQ,EACjB,OAAOD;YAGX,MAAME,SAASN,UAAU,GAAG,CAACK,QAAQ,QAAQ;YAG7C,IAAI,CAACC,QACD,OAAOF;YAIX,OAAOD,YAAYC,MAAME;QAC7B;QAGA,MAAMC,YAAYJ,YAAY,EAAE,EAAEhB;QAClC,OAAOC,OAAO,EAAE,CAACmB;IACrB;AACJ;AAEO,MAAMC,gDAAyBC,uBAAAA,oBAA0C,CAAC;IAC7E,gBAAgB3B;IAChB,cAAc;QAAC4B;QAA0BC;KAAoB;AACjE"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetFolderRepository as RepositoryAbstraction, type IGetFolderRepository } from "./abstractions.js";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
|
-
import {
|
|
4
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
5
5
|
import type { Folder } from "../../../folder/folder.types.js";
|
|
6
6
|
declare class GetFolderRepositoryImpl implements IGetFolderRepository {
|
|
7
7
|
private getEntryById;
|
|
8
|
-
private
|
|
9
|
-
constructor(getEntryById: GetEntryByIdUseCase.Interface,
|
|
8
|
+
private folderModelProvider;
|
|
9
|
+
constructor(getEntryById: GetEntryByIdUseCase.Interface, folderModelProvider: FolderModelProvider.Interface);
|
|
10
10
|
execute(id: string): Promise<Result<Folder, RepositoryAbstraction.Error>>;
|
|
11
11
|
}
|
|
12
12
|
export declare const GetFolderRepository: typeof GetFolderRepositoryImpl & {
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetFolderRepository } from "./abstractions.js";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
|
-
import {
|
|
4
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
5
5
|
import { EntryToFolderMapper } from "../shared/EntryToFolderMapper.js";
|
|
6
6
|
import { FolderNotFoundError, FolderPersistenceError } from "../../../domain/folder/errors.js";
|
|
7
7
|
import { EntryId } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
8
8
|
class GetFolderRepositoryImpl {
|
|
9
|
-
constructor(getEntryById,
|
|
9
|
+
constructor(getEntryById, folderModelProvider){
|
|
10
10
|
this.getEntryById = getEntryById;
|
|
11
|
-
this.
|
|
11
|
+
this.folderModelProvider = folderModelProvider;
|
|
12
12
|
}
|
|
13
13
|
async execute(id) {
|
|
14
|
+
const folderModel = await this.folderModelProvider.get();
|
|
14
15
|
const entryId = EntryId.from(id);
|
|
15
|
-
const result = await this.getEntryById.execute(
|
|
16
|
+
const result = await this.getEntryById.execute(folderModel, entryId.toString());
|
|
16
17
|
if (result.isFail()) {
|
|
17
18
|
if ("Cms/Entry/NotFound" === result.error.code) return Result.fail(new FolderNotFoundError(id));
|
|
18
19
|
return Result.fail(new FolderPersistenceError(result.error));
|
|
@@ -25,7 +26,7 @@ const GetFolderRepository_GetFolderRepository = GetFolderRepository.createImplem
|
|
|
25
26
|
implementation: GetFolderRepositoryImpl,
|
|
26
27
|
dependencies: [
|
|
27
28
|
GetEntryByIdUseCase,
|
|
28
|
-
|
|
29
|
+
FolderModelProvider
|
|
29
30
|
]
|
|
30
31
|
});
|
|
31
32
|
export { GetFolderRepository_GetFolderRepository as GetFolderRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/folder/GetFolder/GetFolderRepository.js","sources":["../../../../src/features/folder/GetFolder/GetFolderRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetFolderRepository as RepositoryAbstraction,\n type IGetFolderRepository\n} from \"./abstractions.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/folder/GetFolder/GetFolderRepository.js","sources":["../../../../src/features/folder/GetFolder/GetFolderRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetFolderRepository as RepositoryAbstraction,\n type IGetFolderRepository\n} from \"./abstractions.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { FolderModelProvider } from \"~/domain/folder/abstractions.js\";\nimport type { CmsEntryFolder, Folder } from \"~/folder/folder.types.js\";\nimport { EntryToFolderMapper } from \"../shared/EntryToFolderMapper.js\";\nimport { FolderNotFoundError, FolderPersistenceError } from \"~/domain/folder/errors.js\";\nimport { EntryId } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\n\nclass GetFolderRepositoryImpl implements IGetFolderRepository {\n constructor(\n private getEntryById: GetEntryByIdUseCase.Interface,\n private folderModelProvider: FolderModelProvider.Interface\n ) {}\n\n async execute(id: string): Promise<Result<Folder, RepositoryAbstraction.Error>> {\n const folderModel = await this.folderModelProvider.get();\n const entryId = EntryId.from(id);\n const result = await this.getEntryById.execute<CmsEntryFolder>(\n folderModel,\n entryId.toString()\n );\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new FolderNotFoundError(id));\n }\n\n return Result.fail(new FolderPersistenceError(result.error));\n }\n\n const folder = EntryToFolderMapper.toFolder(result.value);\n return Result.ok(folder);\n }\n}\n\nexport const GetFolderRepository = RepositoryAbstraction.createImplementation({\n implementation: GetFolderRepositoryImpl,\n dependencies: [GetEntryByIdUseCase, FolderModelProvider]\n});\n"],"names":["GetFolderRepositoryImpl","getEntryById","folderModelProvider","id","folderModel","entryId","EntryId","result","Result","FolderNotFoundError","FolderPersistenceError","folder","EntryToFolderMapper","GetFolderRepository","RepositoryAbstraction","GetEntryByIdUseCase","FolderModelProvider"],"mappings":";;;;;;;AAYA,MAAMA;IACF,YACYC,YAA2C,EAC3CC,mBAAkD,CAC5D;aAFUD,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;IACT;IAEH,MAAM,QAAQC,EAAU,EAAwD;QAC5E,MAAMC,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG;QACtD,MAAMC,UAAUC,QAAQ,IAAI,CAACH;QAC7B,MAAMI,SAAS,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAC1CH,aACAC,QAAQ,QAAQ;QAGpB,IAAIE,OAAO,MAAM,IAAI;YACjB,IAAIA,AAAsB,yBAAtBA,OAAO,KAAK,CAAC,IAAI,EACjB,OAAOC,OAAO,IAAI,CAAC,IAAIC,oBAAoBN;YAG/C,OAAOK,OAAO,IAAI,CAAC,IAAIE,uBAAuBH,OAAO,KAAK;QAC9D;QAEA,MAAMI,SAASC,oBAAoB,QAAQ,CAACL,OAAO,KAAK;QACxD,OAAOC,OAAO,EAAE,CAACG;IACrB;AACJ;AAEO,MAAME,0CAAsBC,oBAAAA,oBAA0C,CAAC;IAC1E,gBAAgBd;IAChB,cAAc;QAACe;QAAqBC;KAAoB;AAC5D"}
|
|
@@ -2,13 +2,13 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { GetFolderHierarchyRepository as RepositoryAbstraction, type IGetFolderHierarchyRepository } from "./abstractions.js";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
5
|
-
import {
|
|
5
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
6
6
|
import type { GetFolderHierarchyParams, GetFolderHierarchyResponse } from "../../../folder/folder.types.js";
|
|
7
7
|
declare class GetFolderHierarchyRepositoryImpl implements IGetFolderHierarchyRepository {
|
|
8
8
|
private getEntryById;
|
|
9
9
|
private listLatestEntries;
|
|
10
|
-
private
|
|
11
|
-
constructor(getEntryById: GetEntryByIdUseCase.Interface, listLatestEntries: ListLatestEntriesUseCase.Interface,
|
|
10
|
+
private folderModelProvider;
|
|
11
|
+
constructor(getEntryById: GetEntryByIdUseCase.Interface, listLatestEntries: ListLatestEntriesUseCase.Interface, folderModelProvider: FolderModelProvider.Interface);
|
|
12
12
|
execute(params: GetFolderHierarchyParams): Promise<Result<GetFolderHierarchyResponse, RepositoryAbstraction.Error>>;
|
|
13
13
|
private getFolderParent;
|
|
14
14
|
}
|
|
@@ -3,21 +3,22 @@ import { GetFolderHierarchyRepository } from "./abstractions.js";
|
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
5
5
|
import { EntryId } from "@webiny/api-headless-cms/exports/api/cms/entry.js";
|
|
6
|
-
import {
|
|
6
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
7
7
|
import { EntryToFolderMapper } from "../shared/EntryToFolderMapper.js";
|
|
8
8
|
import { FolderPersistenceError } from "../../../domain/folder/errors.js";
|
|
9
9
|
import { ROOT_FOLDER } from "../../../constants.js";
|
|
10
10
|
const FIXED_FOLDER_LISTING_LIMIT = 10000;
|
|
11
11
|
class GetFolderHierarchyRepositoryImpl {
|
|
12
|
-
constructor(getEntryById, listLatestEntries,
|
|
12
|
+
constructor(getEntryById, listLatestEntries, folderModelProvider){
|
|
13
13
|
this.getEntryById = getEntryById;
|
|
14
14
|
this.listLatestEntries = listLatestEntries;
|
|
15
|
-
this.
|
|
15
|
+
this.folderModelProvider = folderModelProvider;
|
|
16
16
|
}
|
|
17
17
|
async execute(params) {
|
|
18
|
+
const folderModel = await this.folderModelProvider.get();
|
|
18
19
|
const parents = [];
|
|
19
20
|
const siblings = [];
|
|
20
|
-
const rootFoldersResult = await this.listLatestEntries.execute(
|
|
21
|
+
const rootFoldersResult = await this.listLatestEntries.execute(folderModel, {
|
|
21
22
|
where: {
|
|
22
23
|
values: {
|
|
23
24
|
type: params.type,
|
|
@@ -34,14 +35,14 @@ class GetFolderHierarchyRepositoryImpl {
|
|
|
34
35
|
siblings
|
|
35
36
|
});
|
|
36
37
|
const entryId = EntryId.from(params.id);
|
|
37
|
-
const folderResult = await this.getEntryById.execute(
|
|
38
|
+
const folderResult = await this.getEntryById.execute(folderModel, entryId.toString());
|
|
38
39
|
if (folderResult.isFail()) return Result.fail(new FolderPersistenceError(folderResult.error));
|
|
39
40
|
const folder = EntryToFolderMapper.toFolder(folderResult.value);
|
|
40
41
|
parents.push(folder);
|
|
41
42
|
const getFolderParentResult = await this.getFolderParent(folder, parents);
|
|
42
43
|
if (getFolderParentResult.isFail()) return Result.fail(getFolderParentResult.error);
|
|
43
44
|
const parentIds = parents.map((f)=>f.id);
|
|
44
|
-
const childFoldersResult = await this.listLatestEntries.execute(
|
|
45
|
+
const childFoldersResult = await this.listLatestEntries.execute(folderModel, {
|
|
45
46
|
where: {
|
|
46
47
|
entryId_not_in: parentIds,
|
|
47
48
|
values: {
|
|
@@ -60,9 +61,10 @@ class GetFolderHierarchyRepositoryImpl {
|
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
async getFolderParent(folder, parents) {
|
|
64
|
+
const folderModel = await this.folderModelProvider.get();
|
|
63
65
|
let currentFolder = folder;
|
|
64
66
|
while(currentFolder.parentId){
|
|
65
|
-
const parentResult = await this.getEntryById.execute(
|
|
67
|
+
const parentResult = await this.getEntryById.execute(folderModel, EntryId.from(currentFolder.parentId).toString());
|
|
66
68
|
if (parentResult.isFail()) return Result.fail(new FolderPersistenceError(parentResult.error));
|
|
67
69
|
const parentFolder = EntryToFolderMapper.toFolder(parentResult.value);
|
|
68
70
|
parents.push(parentFolder);
|
|
@@ -76,7 +78,7 @@ const GetFolderHierarchyRepository_GetFolderHierarchyRepository = GetFolderHiera
|
|
|
76
78
|
dependencies: [
|
|
77
79
|
GetEntryByIdUseCase,
|
|
78
80
|
ListLatestEntriesUseCase,
|
|
79
|
-
|
|
81
|
+
FolderModelProvider
|
|
80
82
|
]
|
|
81
83
|
});
|
|
82
84
|
export { GetFolderHierarchyRepository_GetFolderHierarchyRepository as GetFolderHierarchyRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js","sources":["../../../../src/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetFolderHierarchyRepository as RepositoryAbstraction,\n type IGetFolderHierarchyRepository\n} from \"./abstractions.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport { EntryId } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.js","sources":["../../../../src/features/folder/GetFolderHierarchy/GetFolderHierarchyRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetFolderHierarchyRepository as RepositoryAbstraction,\n type IGetFolderHierarchyRepository\n} from \"./abstractions.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport { EntryId } from \"@webiny/api-headless-cms/exports/api/cms/entry.js\";\nimport { FolderModelProvider } from \"~/domain/folder/abstractions.js\";\nimport type {\n CmsEntryFolder,\n Folder,\n GetFolderHierarchyParams,\n GetFolderHierarchyResponse\n} from \"~/folder/folder.types.js\";\nimport { EntryToFolderMapper } from \"../shared/EntryToFolderMapper.js\";\nimport { FolderPersistenceError } from \"~/domain/folder/errors.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\n\nconst FIXED_FOLDER_LISTING_LIMIT = 10_000;\n\nclass GetFolderHierarchyRepositoryImpl implements IGetFolderHierarchyRepository {\n constructor(\n private getEntryById: GetEntryByIdUseCase.Interface,\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private folderModelProvider: FolderModelProvider.Interface\n ) {}\n\n async execute(\n params: GetFolderHierarchyParams\n ): Promise<Result<GetFolderHierarchyResponse, RepositoryAbstraction.Error>> {\n const folderModel = await this.folderModelProvider.get();\n const parents: Folder[] = [];\n const siblings: Folder[] = [];\n\n // Get root folders (siblings at root level)\n const rootFoldersResult = await this.listLatestEntries.execute<CmsEntryFolder>(\n folderModel,\n {\n where: {\n values: {\n type: params.type,\n parentId: null\n }\n },\n limit: FIXED_FOLDER_LISTING_LIMIT\n }\n );\n\n if (rootFoldersResult.isFail()) {\n return Result.fail(new FolderPersistenceError(rootFoldersResult.error));\n }\n\n const { entries: rootEntries } = rootFoldersResult.value;\n siblings.push(...rootEntries.map(entry => EntryToFolderMapper.toFolder(entry)));\n\n if (params.id === ROOT_FOLDER) {\n return Result.ok({\n parents,\n siblings\n });\n }\n\n // Get the folder by id\n const entryId = EntryId.from(params.id);\n const folderResult = await this.getEntryById.execute<CmsEntryFolder>(\n folderModel,\n entryId.toString()\n );\n\n if (folderResult.isFail()) {\n return Result.fail(new FolderPersistenceError(folderResult.error));\n }\n\n const folder = EntryToFolderMapper.toFolder(folderResult.value);\n parents.push(folder);\n\n // Recursively get all parent folders\n const getFolderParentResult = await this.getFolderParent(folder, parents);\n if (getFolderParentResult.isFail()) {\n return Result.fail(getFolderParentResult.error);\n }\n\n // Get all child folders of all parents (these are siblings at different levels)\n const parentIds = parents.map(f => f.id);\n\n const childFoldersResult = await this.listLatestEntries.execute<CmsEntryFolder>(\n folderModel,\n {\n where: {\n entryId_not_in: parentIds,\n values: {\n type: folder.type,\n parentId_in: parentIds\n }\n },\n limit: FIXED_FOLDER_LISTING_LIMIT\n }\n );\n\n if (childFoldersResult.isFail()) {\n return Result.fail(new FolderPersistenceError(childFoldersResult.error));\n }\n\n const { entries: childEntries } = childFoldersResult.value;\n siblings.push(...childEntries.map(entry => EntryToFolderMapper.toFolder(entry)));\n\n return Result.ok({\n parents,\n siblings\n });\n }\n\n private async getFolderParent(\n folder: Folder,\n parents: Folder[]\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n const folderModel = await this.folderModelProvider.get();\n let currentFolder = folder;\n\n while (currentFolder.parentId) {\n const parentResult = await this.getEntryById.execute<CmsEntryFolder>(\n folderModel,\n EntryId.from(currentFolder.parentId).toString()\n );\n\n if (parentResult.isFail()) {\n return Result.fail(new FolderPersistenceError(parentResult.error));\n }\n\n const parentFolder = EntryToFolderMapper.toFolder(parentResult.value);\n parents.push(parentFolder);\n currentFolder = parentFolder;\n }\n\n return Result.ok();\n }\n}\n\nexport const GetFolderHierarchyRepository = RepositoryAbstraction.createImplementation({\n implementation: GetFolderHierarchyRepositoryImpl,\n dependencies: [GetEntryByIdUseCase, ListLatestEntriesUseCase, FolderModelProvider]\n});\n"],"names":["FIXED_FOLDER_LISTING_LIMIT","GetFolderHierarchyRepositoryImpl","getEntryById","listLatestEntries","folderModelProvider","params","folderModel","parents","siblings","rootFoldersResult","Result","FolderPersistenceError","rootEntries","entry","EntryToFolderMapper","ROOT_FOLDER","entryId","EntryId","folderResult","folder","getFolderParentResult","parentIds","f","childFoldersResult","childEntries","currentFolder","parentResult","parentFolder","GetFolderHierarchyRepository","RepositoryAbstraction","GetEntryByIdUseCase","ListLatestEntriesUseCase","FolderModelProvider"],"mappings":";;;;;;;;;AAmBA,MAAMA,6BAA6B;AAEnC,MAAMC;IACF,YACYC,YAA2C,EAC3CC,iBAAqD,EACrDC,mBAAkD,CAC5D;aAHUF,YAAY,GAAZA;aACAC,iBAAiB,GAAjBA;aACAC,mBAAmB,GAAnBA;IACT;IAEH,MAAM,QACFC,MAAgC,EACwC;QACxE,MAAMC,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG;QACtD,MAAMC,UAAoB,EAAE;QAC5B,MAAMC,WAAqB,EAAE;QAG7B,MAAMC,oBAAoB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAC1DH,aACA;YACI,OAAO;gBACH,QAAQ;oBACJ,MAAMD,OAAO,IAAI;oBACjB,UAAU;gBACd;YACJ;YACA,OAAOL;QACX;QAGJ,IAAIS,kBAAkB,MAAM,IACxB,OAAOC,OAAO,IAAI,CAAC,IAAIC,uBAAuBF,kBAAkB,KAAK;QAGzE,MAAM,EAAE,SAASG,WAAW,EAAE,GAAGH,kBAAkB,KAAK;QACxDD,SAAS,IAAI,IAAII,YAAY,GAAG,CAACC,CAAAA,QAASC,oBAAoB,QAAQ,CAACD;QAEvE,IAAIR,OAAO,EAAE,KAAKU,aACd,OAAOL,OAAO,EAAE,CAAC;YACbH;YACAC;QACJ;QAIJ,MAAMQ,UAAUC,QAAQ,IAAI,CAACZ,OAAO,EAAE;QACtC,MAAMa,eAAe,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAChDZ,aACAU,QAAQ,QAAQ;QAGpB,IAAIE,aAAa,MAAM,IACnB,OAAOR,OAAO,IAAI,CAAC,IAAIC,uBAAuBO,aAAa,KAAK;QAGpE,MAAMC,SAASL,oBAAoB,QAAQ,CAACI,aAAa,KAAK;QAC9DX,QAAQ,IAAI,CAACY;QAGb,MAAMC,wBAAwB,MAAM,IAAI,CAAC,eAAe,CAACD,QAAQZ;QACjE,IAAIa,sBAAsB,MAAM,IAC5B,OAAOV,OAAO,IAAI,CAACU,sBAAsB,KAAK;QAIlD,MAAMC,YAAYd,QAAQ,GAAG,CAACe,CAAAA,IAAKA,EAAE,EAAE;QAEvC,MAAMC,qBAAqB,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAC3DjB,aACA;YACI,OAAO;gBACH,gBAAgBe;gBAChB,QAAQ;oBACJ,MAAMF,OAAO,IAAI;oBACjB,aAAaE;gBACjB;YACJ;YACA,OAAOrB;QACX;QAGJ,IAAIuB,mBAAmB,MAAM,IACzB,OAAOb,OAAO,IAAI,CAAC,IAAIC,uBAAuBY,mBAAmB,KAAK;QAG1E,MAAM,EAAE,SAASC,YAAY,EAAE,GAAGD,mBAAmB,KAAK;QAC1Df,SAAS,IAAI,IAAIgB,aAAa,GAAG,CAACX,CAAAA,QAASC,oBAAoB,QAAQ,CAACD;QAExE,OAAOH,OAAO,EAAE,CAAC;YACbH;YACAC;QACJ;IACJ;IAEA,MAAc,gBACVW,MAAc,EACdZ,OAAiB,EACiC;QAClD,MAAMD,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG;QACtD,IAAImB,gBAAgBN;QAEpB,MAAOM,cAAc,QAAQ,CAAE;YAC3B,MAAMC,eAAe,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAChDpB,aACAW,QAAQ,IAAI,CAACQ,cAAc,QAAQ,EAAE,QAAQ;YAGjD,IAAIC,aAAa,MAAM,IACnB,OAAOhB,OAAO,IAAI,CAAC,IAAIC,uBAAuBe,aAAa,KAAK;YAGpE,MAAMC,eAAeb,oBAAoB,QAAQ,CAACY,aAAa,KAAK;YACpEnB,QAAQ,IAAI,CAACoB;YACbF,gBAAgBE;QACpB;QAEA,OAAOjB,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMkB,4DAA+BC,6BAAAA,oBAA0C,CAAC;IACnF,gBAAgB5B;IAChB,cAAc;QAAC6B;QAAqBC;QAA0BC;KAAoB;AACtF"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type IListFoldersRepository, ListFoldersRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
2
2
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
3
|
-
import {
|
|
3
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
4
4
|
import type { ListFoldersParams } from "../../../folder/folder.types.js";
|
|
5
5
|
import { CmsSortMapper, CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
6
6
|
declare class ListFoldersRepositoryImpl implements IListFoldersRepository {
|
|
7
7
|
private listLatestEntries;
|
|
8
|
-
private
|
|
8
|
+
private folderModelProvider;
|
|
9
9
|
private cmsWhereMapper;
|
|
10
10
|
private cmsSortMapper;
|
|
11
|
-
constructor(listLatestEntries: ListLatestEntriesUseCase.Interface,
|
|
11
|
+
constructor(listLatestEntries: ListLatestEntriesUseCase.Interface, folderModelProvider: FolderModelProvider.Interface, cmsWhereMapper: CmsWhereMapper.Interface, cmsSortMapper: CmsSortMapper.Interface);
|
|
12
12
|
execute(params: ListFoldersParams): RepositoryAbstraction.Return;
|
|
13
13
|
}
|
|
14
14
|
export declare const ListFoldersRepository: typeof ListFoldersRepositoryImpl & {
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListFoldersRepository } from "./abstractions.js";
|
|
3
3
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
4
|
-
import {
|
|
4
|
+
import { FolderModelProvider } from "../../../domain/folder/abstractions.js";
|
|
5
5
|
import { EntryToFolderMapper } from "../shared/EntryToFolderMapper.js";
|
|
6
6
|
import { FolderPersistenceError } from "../../../domain/folder/errors.js";
|
|
7
7
|
import { createListSort } from "../../../utils/createListSort.js";
|
|
8
8
|
import { CmsSortMapper, CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
9
9
|
class ListFoldersRepositoryImpl {
|
|
10
|
-
constructor(listLatestEntries,
|
|
10
|
+
constructor(listLatestEntries, folderModelProvider, cmsWhereMapper, cmsSortMapper){
|
|
11
11
|
this.listLatestEntries = listLatestEntries;
|
|
12
|
-
this.
|
|
12
|
+
this.folderModelProvider = folderModelProvider;
|
|
13
13
|
this.cmsWhereMapper = cmsWhereMapper;
|
|
14
14
|
this.cmsSortMapper = cmsSortMapper;
|
|
15
15
|
}
|
|
16
16
|
async execute(params) {
|
|
17
|
+
const folderModel = await this.folderModelProvider.get();
|
|
17
18
|
const { sort, where } = params;
|
|
18
19
|
const listSort = sort || {
|
|
19
20
|
values_title: "ASC"
|
|
20
21
|
};
|
|
21
|
-
const result = await this.listLatestEntries.execute(
|
|
22
|
+
const result = await this.listLatestEntries.execute(folderModel, {
|
|
22
23
|
...params,
|
|
23
24
|
sort: this.cmsSortMapper.map({
|
|
24
25
|
input: createListSort(listSort),
|
|
25
|
-
fields:
|
|
26
|
+
fields: folderModel.fields
|
|
26
27
|
}),
|
|
27
28
|
where: this.cmsWhereMapper.map({
|
|
28
29
|
input: where,
|
|
29
|
-
fields:
|
|
30
|
+
fields: folderModel.fields
|
|
30
31
|
})
|
|
31
32
|
});
|
|
32
33
|
if (result.isFail()) return Result.fail(new FolderPersistenceError(result.error));
|
|
@@ -42,7 +43,7 @@ const ListFoldersRepository_ListFoldersRepository = ListFoldersRepository.create
|
|
|
42
43
|
implementation: ListFoldersRepositoryImpl,
|
|
43
44
|
dependencies: [
|
|
44
45
|
ListLatestEntriesUseCase,
|
|
45
|
-
|
|
46
|
+
FolderModelProvider,
|
|
46
47
|
CmsWhereMapper,
|
|
47
48
|
CmsSortMapper
|
|
48
49
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/folder/ListFolders/ListFoldersRepository.js","sources":["../../../../src/features/folder/ListFolders/ListFoldersRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type IListFoldersRepository,\n ListFoldersRepository as RepositoryAbstraction\n} from \"./abstractions.js\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/folder/ListFolders/ListFoldersRepository.js","sources":["../../../../src/features/folder/ListFolders/ListFoldersRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n type IListFoldersRepository,\n ListFoldersRepository as RepositoryAbstraction\n} from \"./abstractions.js\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport { FolderModelProvider } from \"~/domain/folder/abstractions.js\";\nimport type { CmsEntryFolder, ListFoldersParams } from \"~/folder/folder.types.js\";\nimport { EntryToFolderMapper } from \"../shared/EntryToFolderMapper.js\";\nimport { FolderPersistenceError } from \"~/domain/folder/errors.js\";\nimport { createListSort } from \"~/utils/createListSort.js\";\nimport type { ListSort } from \"~/types.js\";\nimport { CmsSortMapper, CmsWhereMapper } from \"@webiny/api-headless-cms\";\n\nclass ListFoldersRepositoryImpl implements IListFoldersRepository {\n constructor(\n private listLatestEntries: ListLatestEntriesUseCase.Interface,\n private folderModelProvider: FolderModelProvider.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface,\n private cmsSortMapper: CmsSortMapper.Interface\n ) {}\n\n async execute(params: ListFoldersParams): RepositoryAbstraction.Return {\n const folderModel = await this.folderModelProvider.get();\n const { sort, where } = params;\n\n const listSort =\n sort ||\n ({\n values_title: \"ASC\"\n } as unknown as ListSort);\n\n const result = await this.listLatestEntries.execute<CmsEntryFolder>(folderModel, {\n ...params,\n sort: this.cmsSortMapper.map({\n input: createListSort(listSort),\n fields: folderModel.fields\n }),\n where: this.cmsWhereMapper.map({\n input: where,\n fields: folderModel.fields\n })\n });\n\n if (result.isFail()) {\n return Result.fail(new FolderPersistenceError(result.error));\n }\n\n const { entries, meta } = result.value;\n const folders = entries.map(entry => EntryToFolderMapper.toFolder(entry));\n return Result.ok({ folders, meta });\n }\n}\n\nexport const ListFoldersRepository = RepositoryAbstraction.createImplementation({\n implementation: ListFoldersRepositoryImpl,\n dependencies: [ListLatestEntriesUseCase, FolderModelProvider, CmsWhereMapper, CmsSortMapper]\n});\n"],"names":["ListFoldersRepositoryImpl","listLatestEntries","folderModelProvider","cmsWhereMapper","cmsSortMapper","params","folderModel","sort","where","listSort","result","createListSort","Result","FolderPersistenceError","entries","meta","folders","entry","EntryToFolderMapper","ListFoldersRepository","RepositoryAbstraction","ListLatestEntriesUseCase","FolderModelProvider","CmsWhereMapper","CmsSortMapper"],"mappings":";;;;;;;;AAcA,MAAMA;IACF,YACYC,iBAAqD,EACrDC,mBAAkD,EAClDC,cAAwC,EACxCC,aAAsC,CAChD;aAJUH,iBAAiB,GAAjBA;aACAC,mBAAmB,GAAnBA;aACAC,cAAc,GAAdA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QAAQC,MAAyB,EAAgC;QACnE,MAAMC,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG;QACtD,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGH;QAExB,MAAMI,WACFF,QACC;YACG,cAAc;QAClB;QAEJ,MAAMG,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAiBJ,aAAa;YAC7E,GAAGD,MAAM;YACT,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;gBACzB,OAAOM,eAAeF;gBACtB,QAAQH,YAAY,MAAM;YAC9B;YACA,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC3B,OAAOE;gBACP,QAAQF,YAAY,MAAM;YAC9B;QACJ;QAEA,IAAII,OAAO,MAAM,IACb,OAAOE,OAAO,IAAI,CAAC,IAAIC,uBAAuBH,OAAO,KAAK;QAG9D,MAAM,EAAEI,OAAO,EAAEC,IAAI,EAAE,GAAGL,OAAO,KAAK;QACtC,MAAMM,UAAUF,QAAQ,GAAG,CAACG,CAAAA,QAASC,oBAAoB,QAAQ,CAACD;QAClE,OAAOL,OAAO,EAAE,CAAC;YAAEI;YAASD;QAAK;IACrC;AACJ;AAEO,MAAMI,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBpB;IAChB,cAAc;QAACqB;QAA0BC;QAAqBC;QAAgBC;KAAc;AAChG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
2
|
+
import { WebsocketsSendToIdentityUseCase } from "@webiny/api-websockets/exports/api.js";
|
|
3
|
+
import { NotifyFolderChangeUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
4
|
+
declare class NotifyFolderChangeUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
5
|
+
private identityContext;
|
|
6
|
+
private sendToIdentity;
|
|
7
|
+
constructor(identityContext: IdentityContext.Interface, sendToIdentity: WebsocketsSendToIdentityUseCase.Interface);
|
|
8
|
+
execute({ id, change, identityId }: UseCaseAbstraction.Params): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const NotifyFolderChangeUseCase: import("@webiny/di").Implementation<typeof NotifyFolderChangeUseCaseImpl>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
3
|
+
import { WebsocketsSendToIdentityUseCase } from "@webiny/api-websockets/exports/api.js";
|
|
4
|
+
import { FOLDER_CREATED_WEBSOCKET_ACTION, FOLDER_DELETED_WEBSOCKET_ACTION, FOLDER_UPDATED_WEBSOCKET_ACTION, NotifyFolderChangeUseCase } from "./abstractions.js";
|
|
5
|
+
const ACTIONS = {
|
|
6
|
+
created: FOLDER_CREATED_WEBSOCKET_ACTION,
|
|
7
|
+
updated: FOLDER_UPDATED_WEBSOCKET_ACTION,
|
|
8
|
+
deleted: FOLDER_DELETED_WEBSOCKET_ACTION
|
|
9
|
+
};
|
|
10
|
+
class NotifyFolderChangeUseCaseImpl {
|
|
11
|
+
constructor(identityContext, sendToIdentity){
|
|
12
|
+
this.identityContext = identityContext;
|
|
13
|
+
this.sendToIdentity = sendToIdentity;
|
|
14
|
+
}
|
|
15
|
+
async execute({ id, change, identityId }) {
|
|
16
|
+
const recipient = identityId ?? this.identityContext.getIdentity()?.id;
|
|
17
|
+
if (!recipient) return;
|
|
18
|
+
await this.sendToIdentity.execute({
|
|
19
|
+
id: recipient
|
|
20
|
+
}, {
|
|
21
|
+
action: ACTIONS[change],
|
|
22
|
+
data: {
|
|
23
|
+
id
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const NotifyFolderChangeUseCase_NotifyFolderChangeUseCase = createImplementation({
|
|
29
|
+
abstraction: NotifyFolderChangeUseCase,
|
|
30
|
+
implementation: NotifyFolderChangeUseCaseImpl,
|
|
31
|
+
dependencies: [
|
|
32
|
+
IdentityContext,
|
|
33
|
+
WebsocketsSendToIdentityUseCase
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
export { NotifyFolderChangeUseCase_NotifyFolderChangeUseCase as NotifyFolderChangeUseCase };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=NotifyFolderChangeUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js","sources":["../../../../src/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { WebsocketsSendToIdentityUseCase } from \"@webiny/api-websockets/exports/api.js\";\nimport {\n FOLDER_CREATED_WEBSOCKET_ACTION,\n FOLDER_DELETED_WEBSOCKET_ACTION,\n FOLDER_UPDATED_WEBSOCKET_ACTION,\n NotifyFolderChangeUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\n\nconst ACTIONS: Record<UseCaseAbstraction.Params[\"change\"], string> = {\n created: FOLDER_CREATED_WEBSOCKET_ACTION,\n updated: FOLDER_UPDATED_WEBSOCKET_ACTION,\n deleted: FOLDER_DELETED_WEBSOCKET_ACTION\n};\n\n/*\n * The change is already saved whether or not the message goes out, so the send's result is not the\n * caller's result. When it fails, the admin shows the change after its next reload, as it did before.\n */\nclass NotifyFolderChangeUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface\n ) {}\n\n async execute({ id, change, identityId }: UseCaseAbstraction.Params): Promise<void> {\n const recipient = identityId ?? this.identityContext.getIdentity()?.id;\n if (!recipient) {\n return;\n }\n\n await this.sendToIdentity.execute(\n { id: recipient },\n { action: ACTIONS[change], data: { id } }\n );\n }\n}\n\nexport const NotifyFolderChangeUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: NotifyFolderChangeUseCaseImpl,\n dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]\n});\n"],"names":["ACTIONS","FOLDER_CREATED_WEBSOCKET_ACTION","FOLDER_UPDATED_WEBSOCKET_ACTION","FOLDER_DELETED_WEBSOCKET_ACTION","NotifyFolderChangeUseCaseImpl","identityContext","sendToIdentity","id","change","identityId","recipient","NotifyFolderChangeUseCase","createImplementation","UseCaseAbstraction","IdentityContext","WebsocketsSendToIdentityUseCase"],"mappings":";;;;AAUA,MAAMA,UAA+D;IACjE,SAASC;IACT,SAASC;IACT,SAASC;AACb;AAMA,MAAMC;IACF,YACYC,eAA0C,EAC1CC,cAAyD,CACnE;aAFUD,eAAe,GAAfA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,UAAU,EAA6B,EAAiB;QAChF,MAAMC,YAAYD,cAAc,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI;QACpE,IAAI,CAACC,WACD;QAGJ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B;YAAE,IAAIA;QAAU,GAChB;YAAE,QAAQV,OAAO,CAACQ,OAAO;YAAE,MAAM;gBAAED;YAAG;QAAE;IAEhD;AACJ;AAEO,MAAMI,sDAA4BC,qBAAqB;IAC1D,aAAaC;IACb,gBAAgBT;IAChB,cAAc;QAACU;QAAiBC;KAAgC;AACpE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FolderAfterDeleteEventHandler } from "../../../features/folder/DeleteFolder/abstractions.js";
|
|
2
|
+
import type { FolderAfterDeleteEvent } from "../../../features/folder/DeleteFolder/events.js";
|
|
3
|
+
import { NotifyFolderChangeUseCase } from "./abstractions.js";
|
|
4
|
+
declare class NotifyOnFolderDeletedHandlerImpl implements FolderAfterDeleteEventHandler.Interface {
|
|
5
|
+
private notifyFolderChange;
|
|
6
|
+
constructor(notifyFolderChange: NotifyFolderChangeUseCase.Interface);
|
|
7
|
+
handle(event: FolderAfterDeleteEvent): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const NotifyOnFolderDeletedHandler: typeof NotifyOnFolderDeletedHandlerImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<import("@webiny/api-core/features/eventPublisher/abstractions.js").DomainEvent<import("~/features/folder/DeleteFolder/abstractions.js").FolderAfterDeletePayload>>>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FolderAfterDeleteEventHandler } from "../DeleteFolder/abstractions.js";
|
|
2
|
+
import { NotifyFolderChangeUseCase } from "./abstractions.js";
|
|
3
|
+
class NotifyOnFolderDeletedHandlerImpl {
|
|
4
|
+
constructor(notifyFolderChange){
|
|
5
|
+
this.notifyFolderChange = notifyFolderChange;
|
|
6
|
+
}
|
|
7
|
+
async handle(event) {
|
|
8
|
+
try {
|
|
9
|
+
await this.notifyFolderChange.execute({
|
|
10
|
+
id: event.payload.folder.id,
|
|
11
|
+
change: "deleted"
|
|
12
|
+
});
|
|
13
|
+
} catch {}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const NotifyOnFolderDeletedHandler = FolderAfterDeleteEventHandler.createImplementation({
|
|
17
|
+
implementation: NotifyOnFolderDeletedHandlerImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
NotifyFolderChangeUseCase
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
export { NotifyOnFolderDeletedHandler };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=NotifyOnFolderDeletedHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js","sources":["../../../../src/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.ts"],"sourcesContent":["import { FolderAfterDeleteEventHandler } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport type { FolderAfterDeleteEvent } from \"~/features/folder/DeleteFolder/events.js\";\nimport { NotifyFolderChangeUseCase } from \"./abstractions.js\";\n\n/*\n * Created and updated folders are announced by the FLP tasks, once the admin can read them back. A\n * deleted folder is only dropped from the admin's cache, so there is nothing to wait for.\n */\nclass NotifyOnFolderDeletedHandlerImpl implements FolderAfterDeleteEventHandler.Interface {\n constructor(private notifyFolderChange: NotifyFolderChangeUseCase.Interface) {}\n\n async handle(event: FolderAfterDeleteEvent): Promise<void> {\n try {\n await this.notifyFolderChange.execute({\n id: event.payload.folder.id,\n change: \"deleted\"\n });\n } catch {\n // The folder is gone either way; the admin drops it on its next reload.\n }\n }\n}\n\nexport const NotifyOnFolderDeletedHandler = FolderAfterDeleteEventHandler.createImplementation({\n implementation: NotifyOnFolderDeletedHandlerImpl,\n dependencies: [NotifyFolderChangeUseCase]\n});\n"],"names":["NotifyOnFolderDeletedHandlerImpl","notifyFolderChange","event","NotifyOnFolderDeletedHandler","FolderAfterDeleteEventHandler","NotifyFolderChangeUseCase"],"mappings":";;AAQA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAA6B,EAAiB;QACvD,IAAI;YACA,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAClC,IAAIA,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE;gBAC3B,QAAQ;YACZ;QACJ,EAAE,OAAM,CAER;IACJ;AACJ;AAEO,MAAMC,+BAA+BC,8BAA8B,oBAAoB,CAAC;IAC3F,gBAAgBJ;IAChB,cAAc;QAACK;KAA0B;AAC7C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sent to the user's open admin tabs when a folder changes. The admin keeps its own folder cache,
|
|
3
|
+
* and a change made on the server never passes through it, so without these the admin shows the old
|
|
4
|
+
* state until a reload. Each carries the folder id only; the admin reads the folder back.
|
|
5
|
+
*
|
|
6
|
+
* `created` and `updated` go out when the FLP tasks finish, since folder reads report permissions
|
|
7
|
+
* from the FLP records. `deleted` goes out right after the delete: nothing is read back.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FOLDER_CREATED_WEBSOCKET_ACTION = "aco.folder.created";
|
|
10
|
+
export declare const FOLDER_UPDATED_WEBSOCKET_ACTION = "aco.folder.updated";
|
|
11
|
+
export declare const FOLDER_DELETED_WEBSOCKET_ACTION = "aco.folder.deleted";
|
|
12
|
+
export interface NotifyFolderChangeParams {
|
|
13
|
+
id: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whose open tabs to tell. Defaults to the current identity. The FLP tasks pass the identity
|
|
16
|
+
* that made the change, because they run later, outside that request.
|
|
17
|
+
*/
|
|
18
|
+
identityId?: string;
|
|
19
|
+
change: "created" | "updated" | "deleted";
|
|
20
|
+
}
|
|
21
|
+
export interface INotifyFolderChangeUseCase {
|
|
22
|
+
execute(params: NotifyFolderChangeParams): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare const NotifyFolderChangeUseCase: import("@webiny/di").Abstraction<INotifyFolderChangeUseCase>;
|
|
25
|
+
export declare namespace NotifyFolderChangeUseCase {
|
|
26
|
+
type Interface = INotifyFolderChangeUseCase;
|
|
27
|
+
type Params = NotifyFolderChangeParams;
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const FOLDER_CREATED_WEBSOCKET_ACTION = "aco.folder.created";
|
|
3
|
+
const FOLDER_UPDATED_WEBSOCKET_ACTION = "aco.folder.updated";
|
|
4
|
+
const FOLDER_DELETED_WEBSOCKET_ACTION = "aco.folder.deleted";
|
|
5
|
+
const NotifyFolderChangeUseCase = createAbstraction("Aco/NotifyFolderChangeUseCase");
|
|
6
|
+
export { FOLDER_CREATED_WEBSOCKET_ACTION, FOLDER_DELETED_WEBSOCKET_ACTION, FOLDER_UPDATED_WEBSOCKET_ACTION, NotifyFolderChangeUseCase };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/folder/NotifyFolderChange/abstractions.js","sources":["../../../../src/features/folder/NotifyFolderChange/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Sent to the user's open admin tabs when a folder changes. The admin keeps its own folder cache,\n * and a change made on the server never passes through it, so without these the admin shows the old\n * state until a reload. Each carries the folder id only; the admin reads the folder back.\n *\n * `created` and `updated` go out when the FLP tasks finish, since folder reads report permissions\n * from the FLP records. `deleted` goes out right after the delete: nothing is read back.\n */\nexport const FOLDER_CREATED_WEBSOCKET_ACTION = \"aco.folder.created\";\nexport const FOLDER_UPDATED_WEBSOCKET_ACTION = \"aco.folder.updated\";\nexport const FOLDER_DELETED_WEBSOCKET_ACTION = \"aco.folder.deleted\";\n\nexport interface NotifyFolderChangeParams {\n id: string;\n /**\n * Whose open tabs to tell. Defaults to the current identity. The FLP tasks pass the identity\n * that made the change, because they run later, outside that request.\n */\n identityId?: string;\n change: \"created\" | \"updated\" | \"deleted\";\n}\n\nexport interface INotifyFolderChangeUseCase {\n execute(params: NotifyFolderChangeParams): Promise<void>;\n}\n\nexport const NotifyFolderChangeUseCase = createAbstraction<INotifyFolderChangeUseCase>(\n \"Aco/NotifyFolderChangeUseCase\"\n);\n\nexport namespace NotifyFolderChangeUseCase {\n export type Interface = INotifyFolderChangeUseCase;\n export type Params = NotifyFolderChangeParams;\n}\n"],"names":["FOLDER_CREATED_WEBSOCKET_ACTION","FOLDER_UPDATED_WEBSOCKET_ACTION","FOLDER_DELETED_WEBSOCKET_ACTION","NotifyFolderChangeUseCase","createAbstraction"],"mappings":";AAUO,MAAMA,kCAAkC;AACxC,MAAMC,kCAAkC;AACxC,MAAMC,kCAAkC;AAgBxC,MAAMC,4BAA4BC,kBACrC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells the user's open admin tabs when a folder is created, updated or deleted. The FLP tasks send
|
|
3
|
+
* created and updated (see `CreateFlpOnFolderCreated` and `UpdateFlpOnFolderUpdated`); deleted goes
|
|
4
|
+
* out from here.
|
|
5
|
+
*/
|
|
6
|
+
export declare const NotifyFolderChangeFeature: {
|
|
7
|
+
name: string;
|
|
8
|
+
register(container: import("@webiny/di").Container): void;
|
|
9
|
+
};
|