@webiny/api-aco 6.4.5 → 6.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AcoFeature.d.ts +5 -0
- package/AcoFeature.js +122 -0
- package/AcoFeature.js.map +1 -0
- package/AcoInitializer.d.ts +25 -0
- package/AcoInitializer.js +79 -0
- package/AcoInitializer.js.map +1 -0
- package/createAcoGraphQL.d.ts +7 -4
- package/createAcoGraphQL.js +56 -96
- package/createAcoGraphQL.js.map +1 -1
- package/exports/api/aco/folder.d.ts +1 -1
- package/exports/api/aco/folder.js +1 -1
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListDeletedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListLatestEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js +1 -0
- package/features/cms/decorators/ListPublishedEntriesWithFlpDecorator.js.map +1 -1
- package/features/cms/decorators/MoveEntryWithFlpDecorator.d.ts +1 -1
- 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/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/FolderLevelPermissions/NoopFolderLevelPermissions.d.ts +25 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js +48 -0
- package/features/flp/FolderLevelPermissions/NoopFolderLevelPermissions.js.map +1 -0
- package/features/flp/FolderLevelPermissions/index.d.ts +1 -0
- package/features/flp/FolderLevelPermissions/index.js +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/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 +11 -3
- package/features/flp/UpdateFlp/UpdateFlpUseCase.js +14 -13
- package/features/flp/UpdateFlp/UpdateFlpUseCase.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/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.d.ts +1 -1
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +4 -0
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js +4 -0
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js.map +1 -1
- package/features/folder/GetFolder/decorators/GetFolderWithFolderLevelPermissions.d.ts +8 -8
- package/features/folder/shared/abstractions.d.ts +14 -0
- package/features/folder/shared/abstractions.js +4 -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.so.d.ts +10 -2
- package/filter/filter.so.js +2 -2
- package/filter/filter.so.js.map +1 -1
- package/flp/index.d.ts +0 -1
- package/flp/index.js +0 -1
- package/flp/tasks/createFlp.task.d.ts +2 -2
- package/flp/tasks/deleteFlp.task.d.ts +2 -2
- 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 +2 -2
- package/flp/tasks/syncFlp.task.js +12 -0
- package/flp/tasks/syncFlp.task.js.map +1 -1
- package/flp/tasks/updateFlp.task.d.ts +2 -2
- package/folder/folder.gql.d.ts +1 -1
- package/folder/folder.gql.js +9 -3
- package/folder/folder.gql.js.map +1 -1
- package/index.d.ts +1 -6
- package/index.js +1 -11
- package/package.json +20 -22
- package/utils/createOperationsWrapper.d.ts +5 -2
- package/utils/createOperationsWrapper.js +2 -2
- 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 +2 -2
- package/utils/resolve.js +1 -1
- package/utils/resolve.js.map +1 -1
- package/createAcoContext.d.ts +0 -9
- package/createAcoContext.js +0 -109
- package/createAcoContext.js.map +0 -1
- package/createAcoStorageOperations.d.ts +0 -12
- package/createAcoStorageOperations.js +0 -9
- package/createAcoStorageOperations.js.map +0 -1
- package/createAcoTasks.d.ts +0 -1
- package/createAcoTasks.js +0 -14
- package/createAcoTasks.js.map +0 -1
- package/flp/flp.so.d.ts +0 -20
- package/flp/flp.so.js +0 -183
- package/flp/flp.so.js.map +0 -1
- package/index.js.map +0 -1
package/folder/folder.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder/folder.gql.js","sources":["../../src/folder/folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\n\nimport type { CreateFolderTypeDefsParams } from \"./createFolderTypeDefs.js\";\nimport { createFolderTypeDefs } from \"./createFolderTypeDefs.js\";\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication.js\";\nimport { resolve } from \"~/utils/resolve.js\";\nimport type { AcoContext, Folder } from \"~/types.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\nimport { CreateFolderUseCase } from \"~/features/folder/CreateFolder/abstractions.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/abstractions.js\";\nimport { DeleteFolderUseCase } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport { GetFolderHierarchyUseCase } from \"~/features/folder/GetFolderHierarchy/abstractions.js\";\nimport { ListFolderLevelPermissionsTargetsUseCase } from \"~/features/folder/ListFolderLevelPermissionsTargets/abstractions.js\";\nimport { FolderModel } from \"~/domain/folder/abstractions.js\";\n\nexport const createFoldersSchema = (params: CreateFolderTypeDefsParams) => {\n const folderGraphQL = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: createFolderTypeDefs(params),\n resolvers: {\n Folder: {\n hasNonInheritedPermissions: (folder: Folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.permissionsIncludeNonInheritedPermissions(folder.permissions ?? []);\n },\n canManageStructure: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderStructure(folder);\n },\n canManagePermissions: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderPermissions(folder);\n },\n canManageContent: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderContent(folder);\n }\n },\n AcoQuery: {\n getFolderModel(_, __, context) {\n return resolve(async () => {\n ensureAuthentication(context);\n return context.container.resolve(FolderModel);\n });\n },\n getFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderUseCase = context.container.resolve(GetFolderUseCase);\n const result = await getFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listFoldersUseCase = context.container.resolve(ListFoldersUseCase);\n const result = await listFoldersUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n const { folders, meta } = result.value;\n return new ListResponse(folders, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n getFolderHierarchy: async (_, args: any, context) => {\n try {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderHierarchyUseCase =\n context.container.resolve(GetFolderHierarchyUseCase);\n const result = await getFolderHierarchyUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listFolderLevelPermissionsTargets: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listTargetsUseCase = context.container.resolve(\n ListFolderLevelPermissionsTargetsUseCase\n );\n const result = await listTargetsUseCase.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const [entries, meta] = result.value;\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const createFolderUseCase = context.container.resolve(CreateFolderUseCase);\n const result = await createFolderUseCase.execute(data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const updateFolderUseCase = context.container.resolve(UpdateFolderUseCase);\n const result = await updateFolderUseCase.execute(id, data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const deleteFolderUseCase = context.container.resolve(DeleteFolderUseCase);\n const result = await deleteFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return true;\n });\n }\n }\n }\n });\n\n folderGraphQL.name = \"aco.graphql.folders\";\n\n return folderGraphQL;\n};\n"],"names":["createFoldersSchema","params","folderGraphQL","GraphQLSchemaPlugin","createFolderTypeDefs","folder","_","context","flp","FolderLevelPermissions","__","resolve","ensureAuthentication","FolderModel","id","getFolderUseCase","GetFolderUseCase","result","args","listFoldersUseCase","ListFoldersUseCase","folders","meta","ListResponse","e","ErrorResponse","getFolderHierarchyUseCase","GetFolderHierarchyUseCase","listTargetsUseCase","ListFolderLevelPermissionsTargetsUseCase","entries","data","createFolderUseCase","CreateFolderUseCase","updateFolderUseCase","UpdateFolderUseCase","deleteFolderUseCase","DeleteFolderUseCase"],"mappings":";;;;;;;;;;;;;;AAkBO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,gBAAgB,IAAIC,oBAAgC;QACtD,UAAUC,qBAAqBH;QAC/B,WAAW;YACP,QAAQ;gBACJ,4BAA4B,CAACI,QAAgBC,GAAGC;oBAC5C,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,yCAAyC,CAACH,OAAO,WAAW,IAAI,EAAE;gBACjF;gBACA,oBAAoB,CAACA,QAAQC,GAAGC;oBAC5B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,wBAAwB,CAACH;gBACxC;gBACA,sBAAsB,CAACA,QAAQC,GAAGC;oBAC9B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,0BAA0B,CAACH;gBAC1C;gBACA,kBAAkB,CAACA,QAAQC,GAAGC;oBAC1B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,sBAAsB,CAACH;gBACtC;YACJ;YACA,UAAU;gBACN,gBAAeC,CAAC,EAAEI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":"folder/folder.gql.js","sources":["../../src/folder/folder.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/api-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/api-graphql/plugins/GraphQLSchemaPlugin.js\";\n\nimport type { CreateFolderTypeDefsParams } from \"./createFolderTypeDefs.js\";\nimport { createFolderTypeDefs } from \"./createFolderTypeDefs.js\";\nimport { ensureAuthentication } from \"~/utils/ensureAuthentication.js\";\nimport { resolve } from \"~/utils/resolve.js\";\nimport type { AcoContext, Folder } from \"~/types.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/abstractions.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/abstractions.js\";\nimport { CreateFolderUseCase } from \"~/features/folder/CreateFolder/abstractions.js\";\nimport { UpdateFolderUseCase } from \"~/features/folder/UpdateFolder/abstractions.js\";\nimport { DeleteFolderUseCase } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport { GetFolderHierarchyUseCase } from \"~/features/folder/GetFolderHierarchy/abstractions.js\";\nimport { ListFolderLevelPermissionsTargetsUseCase } from \"~/features/folder/ListFolderLevelPermissionsTargets/abstractions.js\";\nimport { FolderModel } from \"~/domain/folder/abstractions.js\";\nimport { ValuesSelectionGenerator } from \"@webiny/api-headless-cms/features/contentModel/ValuesSelectionGenerator/abstractions.js\";\n\nexport const createFoldersSchema = (params: CreateFolderTypeDefsParams) => {\n const folderGraphQL = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: createFolderTypeDefs(params),\n resolvers: {\n Folder: {\n hasNonInheritedPermissions: (folder: Folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.permissionsIncludeNonInheritedPermissions(folder.permissions ?? []);\n },\n canManageStructure: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderStructure(folder);\n },\n canManagePermissions: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderPermissions(folder);\n },\n canManageContent: (folder, _, context) => {\n const flp = context.container.resolve(FolderLevelPermissions);\n return flp.canManageFolderContent(folder);\n }\n },\n AcoQuery: {\n getFolderModel(_, __, context) {\n return resolve(async () => {\n ensureAuthentication(context);\n const model = context.container.resolve(FolderModel);\n const generator = context.container.resolve(ValuesSelectionGenerator);\n return {\n ...model,\n valuesSelection: generator.generate(model)\n };\n });\n },\n getFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderUseCase = context.container.resolve(GetFolderUseCase);\n const result = await getFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listFolders: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listFoldersUseCase = context.container.resolve(ListFoldersUseCase);\n const result = await listFoldersUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n const { folders, meta } = result.value;\n return new ListResponse(folders, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n getFolderHierarchy: async (_, args: any, context) => {\n try {\n return resolve(async () => {\n ensureAuthentication(context);\n const getFolderHierarchyUseCase =\n context.container.resolve(GetFolderHierarchyUseCase);\n const result = await getFolderHierarchyUseCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listFolderLevelPermissionsTargets: async (_, args: any, context) => {\n try {\n ensureAuthentication(context);\n const listTargetsUseCase = context.container.resolve(\n ListFolderLevelPermissionsTargetsUseCase\n );\n const result = await listTargetsUseCase.execute();\n if (result.isFail()) {\n throw result.error;\n }\n const [entries, meta] = result.value;\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n AcoMutation: {\n createFolder: async (_, { data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const createFolderUseCase = context.container.resolve(CreateFolderUseCase);\n const result = await createFolderUseCase.execute(data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n updateFolder: async (_, { id, data }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const updateFolderUseCase = context.container.resolve(UpdateFolderUseCase);\n const result = await updateFolderUseCase.execute(id, data);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n deleteFolder: async (_, { id }, context) => {\n return resolve(async () => {\n ensureAuthentication(context);\n const deleteFolderUseCase = context.container.resolve(DeleteFolderUseCase);\n const result = await deleteFolderUseCase.execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n return true;\n });\n }\n }\n }\n });\n\n folderGraphQL.name = \"aco.graphql.folders\";\n\n return folderGraphQL;\n};\n"],"names":["createFoldersSchema","params","folderGraphQL","GraphQLSchemaPlugin","createFolderTypeDefs","folder","_","context","flp","FolderLevelPermissions","__","resolve","ensureAuthentication","model","FolderModel","generator","ValuesSelectionGenerator","id","getFolderUseCase","GetFolderUseCase","result","args","listFoldersUseCase","ListFoldersUseCase","folders","meta","ListResponse","e","ErrorResponse","getFolderHierarchyUseCase","GetFolderHierarchyUseCase","listTargetsUseCase","ListFolderLevelPermissionsTargetsUseCase","entries","data","createFolderUseCase","CreateFolderUseCase","updateFolderUseCase","UpdateFolderUseCase","deleteFolderUseCase","DeleteFolderUseCase"],"mappings":";;;;;;;;;;;;;;;AAmBO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,gBAAgB,IAAIC,oBAAgC;QACtD,UAAUC,qBAAqBH;QAC/B,WAAW;YACP,QAAQ;gBACJ,4BAA4B,CAACI,QAAgBC,GAAGC;oBAC5C,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,yCAAyC,CAACH,OAAO,WAAW,IAAI,EAAE;gBACjF;gBACA,oBAAoB,CAACA,QAAQC,GAAGC;oBAC5B,MAAMC,MAAMD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBACtC,OAAOD,IAAI,wBA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OAAO,CAACpB,IAAIiB;wBACrD,IAAId,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAOA,OAAO,KAAK;oBACvB;gBAEJ,cAAc,OAAOd,GAAG,EAAEW,EAAE,EAAE,EAAEV,UACrBI,QAAQ;wBACXC,qBAAqBL;wBACrB,MAAMgC,sBAAsBhC,QAAQ,SAAS,CAAC,OAAO,CAACiC;wBACtD,MAAMpB,SAAS,MAAMmB,oBAAoB,OAAO,CAACtB;wBACjD,IAAIG,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;wBAEtB,OAAO;oBACX;YAER;QACJ;IACJ;IAEAlB,cAAc,IAAI,GAAG;IAErB,OAAOA;AACX"}
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
1
|
export { FILTER_MODEL_ID } from "./filter/filter.model.js";
|
|
3
|
-
export interface CreateAcoParams {
|
|
4
|
-
documentClient: DynamoDBDocument;
|
|
5
|
-
useFolderLevelPermissions?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare const createAco: (params: CreateAcoParams) => (import("@webiny/api/index.js").ContextPlugin<import("@webiny/api/types.js").Context> | (import("@webiny/api/index.js").ContextPlugin<import("./types.js").AcoContext> | import("@webiny/handler/index.js").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>)[] | import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<import("./types.js").AcoContext>)[];
|
|
8
2
|
export * from "./folder/createFolderModelModifier.js";
|
|
3
|
+
export { AcoFeature } from "./AcoFeature.js";
|
package/index.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { createAcoContext } from "./createAcoContext.js";
|
|
2
|
-
import { createAcoGraphQL } from "./createAcoGraphQL.js";
|
|
3
|
-
import { createAcoTasks } from "./createAcoTasks.js";
|
|
4
1
|
export * from "./folder/createFolderModelModifier.js";
|
|
5
|
-
const createAco = (params)=>[
|
|
6
|
-
createAcoContext(params),
|
|
7
|
-
...createAcoGraphQL(),
|
|
8
|
-
createAcoTasks()
|
|
9
|
-
];
|
|
10
2
|
export { FILTER_MODEL_ID } from "./filter/filter.model.js";
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
3
|
+
export { AcoFeature } from "./AcoFeature.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -21,33 +21,31 @@
|
|
|
21
21
|
".": "./index.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webiny/api": "6.
|
|
25
|
-
"@webiny/api-
|
|
26
|
-
"@webiny/api-headless-cms": "6.
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/background-tasks": "6.4.5",
|
|
29
|
-
"@webiny/db-dynamodb": "6.4.5",
|
|
24
|
+
"@webiny/api-core": "6.6.0-alpha.0",
|
|
25
|
+
"@webiny/api-graphql": "6.6.0-alpha.0",
|
|
26
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.0",
|
|
27
|
+
"@webiny/background-tasks": "6.6.0-alpha.0",
|
|
30
28
|
"@webiny/di": "1.0.2",
|
|
31
|
-
"@webiny/error": "6.
|
|
32
|
-
"@webiny/
|
|
33
|
-
"@webiny/
|
|
34
|
-
"@webiny/handler
|
|
35
|
-
"@webiny/shared-aco": "6.
|
|
36
|
-
"@webiny/utils": "6.
|
|
37
|
-
"@webiny/validation": "6.
|
|
29
|
+
"@webiny/error": "6.6.0-alpha.0",
|
|
30
|
+
"@webiny/event-handler-core": "6.6.0-alpha.0",
|
|
31
|
+
"@webiny/feature": "6.6.0-alpha.0",
|
|
32
|
+
"@webiny/handler": "6.6.0-alpha.0",
|
|
33
|
+
"@webiny/shared-aco": "6.6.0-alpha.0",
|
|
34
|
+
"@webiny/utils": "6.6.0-alpha.0",
|
|
35
|
+
"@webiny/validation": "6.6.0-alpha.0",
|
|
38
36
|
"lodash": "4.18.1"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
|
-
"@webiny/api-core-
|
|
42
|
-
"@webiny/api-file-manager": "6.
|
|
43
|
-
"@webiny/
|
|
44
|
-
"@webiny/
|
|
45
|
-
"@webiny/plugins": "6.
|
|
46
|
-
"@webiny/project-utils": "6.
|
|
47
|
-
"@webiny/wcp": "6.
|
|
39
|
+
"@webiny/api-core-testing": "6.6.0-alpha.0",
|
|
40
|
+
"@webiny/api-file-manager": "6.6.0-alpha.0",
|
|
41
|
+
"@webiny/api-headless-cms-testing": "6.6.0-alpha.0",
|
|
42
|
+
"@webiny/build-tools": "6.6.0-alpha.0",
|
|
43
|
+
"@webiny/plugins": "6.6.0-alpha.0",
|
|
44
|
+
"@webiny/project-utils": "6.6.0-alpha.0",
|
|
45
|
+
"@webiny/wcp": "6.6.0-alpha.0",
|
|
48
46
|
"graphql": "16.14.2",
|
|
49
47
|
"rimraf": "6.1.3",
|
|
50
|
-
"typescript": "
|
|
48
|
+
"typescript": "7.0.2",
|
|
51
49
|
"vitest": "4.1.10"
|
|
52
50
|
},
|
|
53
51
|
"webiny": {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HeadlessCms } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
2
3
|
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
interface CreateOperationsWrapperParams
|
|
4
|
+
interface CreateOperationsWrapperParams {
|
|
5
|
+
cms: HeadlessCms;
|
|
6
|
+
identityContext: IdentityContext.Interface;
|
|
4
7
|
modelName: string;
|
|
5
8
|
}
|
|
6
9
|
export declare const createOperationsWrapper: (params: CreateOperationsWrapperParams) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import error from "@webiny/error";
|
|
2
2
|
const createOperationsWrapper = (params)=>{
|
|
3
|
-
const {
|
|
3
|
+
const { identityContext, cms, modelName } = params;
|
|
4
4
|
const withModel = async (cb)=>{
|
|
5
|
-
const model = await
|
|
5
|
+
const model = await identityContext.withoutAuthorization(()=>cms.getModel(modelName));
|
|
6
6
|
if (!model) throw new error(`Could not find "${modelName}" model.`, "MODEL_NOT_FOUND_ERROR");
|
|
7
7
|
return cb(model);
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/createOperationsWrapper.js","sources":["../../src/utils/createOperationsWrapper.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"utils/createOperationsWrapper.js","sources":["../../src/utils/createOperationsWrapper.ts"],"sourcesContent":["import type { HeadlessCms } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams {\n cms: HeadlessCms;\n identityContext: IdentityContext.Interface;\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { identityContext, cms, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n const model = await identityContext.withoutAuthorization(() => {\n return cms.getModel(modelName);\n });\n\n if (!model) {\n throw new WebinyError(`Could not find \"${modelName}\" model.`, \"MODEL_NOT_FOUND_ERROR\");\n }\n\n return cb(model);\n };\n\n return { withModel };\n};\n"],"names":["createOperationsWrapper","params","identityContext","cms","modelName","withModel","cb","model","WebinyError"],"mappings":";AAWO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,eAAe,EAAEC,GAAG,EAAEC,SAAS,EAAE,GAAGH;IAE5C,MAAMI,YAAY,OACdC;QAEA,MAAMC,QAAQ,MAAML,gBAAgB,oBAAoB,CAAC,IAC9CC,IAAI,QAAQ,CAACC;QAGxB,IAAI,CAACG,OACD,MAAM,IAAIC,MAAY,CAAC,gBAAgB,EAAEJ,UAAU,QAAQ,CAAC,EAAE;QAGlE,OAAOE,GAAGC;IACd;IAEA,OAAO;QAAEF;IAAU;AACvB"}
|
|
@@ -3,6 +3,8 @@ import { ListEntriesFactory } from "./ListEntriesFactory.js";
|
|
|
3
3
|
import { FilterEntriesByFolderFactory } from "./FilterEntriesByFolderFactory.js";
|
|
4
4
|
import { decorateIfModelAuthorizationEnabled } from "./decorateIfModelAuthorizationEnabled.js";
|
|
5
5
|
import { FolderLevelPermissions } from "../../features/flp/FolderLevelPermissions/index.js";
|
|
6
|
+
import { GetRevisionByIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js";
|
|
7
|
+
import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
|
|
6
8
|
class CmsEntriesCrudDecorators {
|
|
7
9
|
constructor({ context }){
|
|
8
10
|
this.context = context;
|
|
@@ -10,6 +12,8 @@ class CmsEntriesCrudDecorators {
|
|
|
10
12
|
decorate() {
|
|
11
13
|
const context = this.context;
|
|
12
14
|
const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);
|
|
15
|
+
const getRevisionById = context.container.resolve(GetRevisionByIdStorageOperation);
|
|
16
|
+
const getLatestRevisionByEntryId = context.container.resolve(GetLatestRevisionByEntryIdStorageOperation);
|
|
13
17
|
const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);
|
|
14
18
|
const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);
|
|
15
19
|
decorateIfModelAuthorizationEnabled(context, "listEntries", async (...allParams)=>{
|
|
@@ -91,7 +95,7 @@ class CmsEntriesCrudDecorators {
|
|
|
91
95
|
});
|
|
92
96
|
decorateIfModelAuthorizationEnabled(context, "createEntryRevisionFrom", async (...allParams)=>{
|
|
93
97
|
const [decoratee, model, id, input, options] = allParams;
|
|
94
|
-
const entry = await
|
|
98
|
+
const entry = await getRevisionById.execute(model, {
|
|
95
99
|
id
|
|
96
100
|
});
|
|
97
101
|
const folderId = entry?.location?.folderId;
|
|
@@ -105,7 +109,7 @@ class CmsEntriesCrudDecorators {
|
|
|
105
109
|
});
|
|
106
110
|
decorateIfModelAuthorizationEnabled(context, "updateEntry", async (...allParams)=>{
|
|
107
111
|
const [decoratee, model, id, input, meta, options] = allParams;
|
|
108
|
-
const entry = await
|
|
112
|
+
const entry = await getRevisionById.execute(model, {
|
|
109
113
|
id
|
|
110
114
|
});
|
|
111
115
|
const folderId = entry?.location?.folderId;
|
|
@@ -119,7 +123,7 @@ class CmsEntriesCrudDecorators {
|
|
|
119
123
|
});
|
|
120
124
|
decorateIfModelAuthorizationEnabled(context, "deleteEntry", async (...allParams)=>{
|
|
121
125
|
const [decoratee, model, id, options] = allParams;
|
|
122
|
-
const entry = await
|
|
126
|
+
const entry = await getLatestRevisionByEntryId.execute(model, {
|
|
123
127
|
id
|
|
124
128
|
});
|
|
125
129
|
const folderId = entry?.location?.folderId;
|
|
@@ -133,7 +137,7 @@ class CmsEntriesCrudDecorators {
|
|
|
133
137
|
});
|
|
134
138
|
decorateIfModelAuthorizationEnabled(context, "deleteEntryRevision", async (...allParams)=>{
|
|
135
139
|
const [decoratee, model, id] = allParams;
|
|
136
|
-
const entry = await
|
|
140
|
+
const entry = await getRevisionById.execute(model, {
|
|
137
141
|
id
|
|
138
142
|
});
|
|
139
143
|
const folderId = entry?.location?.folderId;
|
|
@@ -147,7 +151,7 @@ class CmsEntriesCrudDecorators {
|
|
|
147
151
|
});
|
|
148
152
|
decorateIfModelAuthorizationEnabled(context, "moveEntry", async (...allParams)=>{
|
|
149
153
|
const [decoratee, model, id, targetFolderId] = allParams;
|
|
150
|
-
const entry = await
|
|
154
|
+
const entry = await getRevisionById.execute(model, {
|
|
151
155
|
id
|
|
152
156
|
});
|
|
153
157
|
const folderId = entry?.location?.folderId || ROOT_FOLDER;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/decorators/CmsEntriesCrudDecorators.js","sources":["../../../src/utils/decorators/CmsEntriesCrudDecorators.ts"],"sourcesContent":["// @ts-nocheck Being removed\nimport type { AcoContext } from \"~/types.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport { ListEntriesFactory } from \"./ListEntriesFactory.js\";\nimport { FilterEntriesByFolderFactory } from \"./FilterEntriesByFolderFactory.js\";\nimport { decorateIfModelAuthorizationEnabled } from \"./decorateIfModelAuthorizationEnabled.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\n\ntype Context = AcoContext;\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);\n\n const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);\n const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context, \"listEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"listLatestEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"listPublishedEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"listDeletedEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntry\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntryById\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getLatestEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getPublishedEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, params, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, params, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"createEntryRevisionFrom\",\n async (...allParams) => {\n const [decoratee, model, id, input, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, options);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, options);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"updateEntry\", async (...allParams) => {\n const [decoratee, model, id, input, meta, options] = allParams;\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, meta, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, meta, options);\n });\n\n decorateIfModelAuthorizationEnabled(context, \"deleteEntry\", async (...allParams) => {\n const [decoratee, model, id, options] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getLatestRevisionByEntryId(\n model,\n {\n id\n }\n );\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"deleteEntryRevision\",\n async (...allParams) => {\n const [decoratee, model, id] = allParams;\n\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"moveEntry\", async (...allParams) => {\n const [decoratee, model, id, targetFolderId] = allParams;\n\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await context.cms.storageOperations.entries.getRevisionById(model, {\n id\n });\n\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return decoratee(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n\n return decoratee(model, id, targetFolderId);\n });\n }\n}\n"],"names":["CmsEntriesCrudDecorators","context","folderLevelPermissions","FolderLevelPermissions","filterEntriesByFolder","FilterEntriesByFolderFactory","listEntriesHandler","ListEntriesFactory","decorateIfModelAuthorizationEnabled","allParams","decoratee","model","initialParams","params","entry","folderId","ROOT_FOLDER","permissions","ids","entries","options","id","input","meta","targetFolderId"],"mappings":";;;;;AAcO,MAAMA;IAGT,YAAmB,EAAEC,OAAO,EAAoC,CAAE;QAC9D,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEO,WAAW;QACd,MAAMA,UAAU,IAAI,CAAC,OAAO;QAC5B,MAAMC,yBAAyBD,QAAQ,SAAS,CAAC,OAAO,CAACE;QAEzD,MAAMC,wBAAwB,IAAIC,6BAA6BH;QAC/D,MAAMI,qBAAqB,IAAIC,mBAAmBL;QA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O;gBAC7EU;YACJ;YAEA,MAAMN,WAAWD,OAAO,UAAU;YAClC,IAAI,CAACC,YAAYA,aAAaC,aAC1B,OAAON,UAAUC,OAAOU;YAG5B,MAAMJ,cACF,MAAMf,uBAAuB,yBAAyB,CAACa;YAC3D,MAAMb,uBAAuB,4BAA4B,CAAC;gBACtDe;gBACA,KAAK;YACT;YAEA,OAAOP,UAAUC,OAAOU;QAC5B;QAGJb,oCAAoCP,SAAS,aAAa,OAAO,GAAGQ;YAChE,MAAM,CAACC,WAAWC,OAAOU,IAAIG,eAAe,GAAGf;YAK/C,MAAMK,QAAQ,MAAMb,QAAQ,GAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAACU,OAAO;gBAC7EU;YACJ;YAEA,MAAMN,WAAWD,OAAO,UAAU,YAAYE;YAI9C,IAAID,aAAaS,gBACb,OAAOd,UAAUC,OAAOU,IAAIG;YACzB,IAAIT,aAAaC,aAAa;gBAIjC,MAAMC,cACF,MAAMf,uBAAuB,yBAAyB,CAACa;gBAC3D,MAAMb,uBAAuB,4BAA4B,CAAC;oBACtDe;oBACA,KAAK;gBACT;YACJ;YAIA,IAAIO,mBAAmBR,aAAa;gBAChC,MAAMC,cACF,MAAMf,uBAAuB,yBAAyB,CAACa;gBAC3D,MAAMb,uBAAuB,4BAA4B,CAAC;oBACtDe;oBACA,KAAK;gBACT;YACJ;YAEA,OAAOP,UAAUC,OAAOU,IAAIG;QAChC;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"utils/decorators/CmsEntriesCrudDecorators.js","sources":["../../../src/utils/decorators/CmsEntriesCrudDecorators.ts"],"sourcesContent":["// @ts-nocheck Being removed\nimport type { AcoContext } from \"~/types.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\nimport { ListEntriesFactory } from \"./ListEntriesFactory.js\";\nimport { FilterEntriesByFolderFactory } from \"./FilterEntriesByFolderFactory.js\";\nimport { decorateIfModelAuthorizationEnabled } from \"./decorateIfModelAuthorizationEnabled.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { GetRevisionByIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js\";\nimport { GetLatestRevisionByEntryIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js\";\n\ntype Context = AcoContext;\n\ninterface EntryManagerCrudDecoratorsParams {\n context: Context;\n}\n\nexport class CmsEntriesCrudDecorators {\n private readonly context: Context;\n\n public constructor({ context }: EntryManagerCrudDecoratorsParams) {\n this.context = context;\n }\n\n public decorate() {\n const context = this.context;\n const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);\n const getRevisionById = context.container.resolve(GetRevisionByIdStorageOperation);\n const getLatestRevisionByEntryId = context.container.resolve(\n GetLatestRevisionByEntryIdStorageOperation\n );\n\n const filterEntriesByFolder = new FilterEntriesByFolderFactory(folderLevelPermissions);\n const listEntriesHandler = new ListEntriesFactory(folderLevelPermissions);\n\n decorateIfModelAuthorizationEnabled(context, \"listEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"listLatestEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"listPublishedEntries\",\n async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"listDeletedEntries\", async (...allParams) => {\n const [decoratee, model, initialParams] = allParams;\n return await listEntriesHandler.execute({ decoratee, model, initialParams });\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntry\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(context, \"getEntryById\", async (...allParams) => {\n const [decoratee, model, params] = allParams;\n const entry = await decoratee(model, params);\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return entry;\n }\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"r\"\n });\n return entry;\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getLatestEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"getPublishedEntriesByIds\",\n async (...allParams) => {\n const [decoratee, model, ids] = allParams;\n\n const entries = await decoratee(model, ids);\n return filterEntriesByFolder.execute(entries);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"createEntry\", async (...allParams) => {\n const [decoratee, model, params, options] = allParams;\n const folderId = params.wbyAco_location?.folderId || params.location?.folderId;\n\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, params, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, params, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"createEntryRevisionFrom\",\n async (...allParams) => {\n const [decoratee, model, id, input, options] = allParams;\n\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, options);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, options);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"updateEntry\", async (...allParams) => {\n const [decoratee, model, id, input, meta, options] = allParams;\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, input, meta, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n\n return decoratee(model, id, input, meta, options);\n });\n\n decorateIfModelAuthorizationEnabled(context, \"deleteEntry\", async (...allParams) => {\n const [decoratee, model, id, options] = allParams;\n\n const entry = await getLatestRevisionByEntryId.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id, options);\n }\n\n const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id, options);\n });\n\n decorateIfModelAuthorizationEnabled(\n context,\n \"deleteEntryRevision\",\n async (...allParams) => {\n const [decoratee, model, id] = allParams;\n\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId;\n if (!folderId || folderId === ROOT_FOLDER) {\n return decoratee(model, id);\n }\n\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"d\"\n });\n\n return decoratee(model, id);\n }\n );\n\n decorateIfModelAuthorizationEnabled(context, \"moveEntry\", async (...allParams) => {\n const [decoratee, model, id, targetFolderId] = allParams;\n\n /**\n * First we need to check if user has access to the entries existing folder.\n */\n const entry = await getRevisionById.execute(model, {\n id\n });\n\n const folderId = entry?.location?.folderId || ROOT_FOLDER;\n /**\n * If the entry is in the same folder we are trying to move it to, just continue.\n */\n if (folderId === targetFolderId) {\n return decoratee(model, id, targetFolderId);\n } else if (folderId !== ROOT_FOLDER) {\n /**\n * If entry current folder is not a root, check for access\n */\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n /**\n * If target folder is not a ROOT_FOLDER, check for access.\n */\n if (targetFolderId !== ROOT_FOLDER) {\n const permissions =\n await folderLevelPermissions.getFolderLevelPermissions(folderId);\n await folderLevelPermissions.ensureCanAccessFolderContent({\n permissions,\n rwd: \"w\"\n });\n }\n\n return decoratee(model, id, targetFolderId);\n });\n }\n}\n"],"names":["CmsEntriesCrudDecorators","context","folderLevelPermissions","FolderLevelPermissions","getRevisionById","GetRevisionByIdStorageOperation","getLatestRevisionByEntryId","GetLatestRevisionByEntryIdStorageOperation","filterEntriesByFolder","FilterEntriesByFolderFactory","listEntriesHandler","ListEntriesFactory","decorateIfModelAuthorizationEnabled","allParams","decoratee","model","initialParams","params","entry","folderId","ROOT_FOLDER","permissions","ids","entries","options","id","input","meta","targetFolderId"],"mappings":";;;;;;;AAgBO,MAAMA;IAGT,YAAmB,EAAEC,OAAO,EAAoC,CAAE;QAC9D,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEO,WAAW;QACd,MAAMA,UAAU,IAAI,CAAC,OAAO;QAC5B,MAAMC,yBAAyBD,QAAQ,SAAS,CAAC,OAAO,CAACE;QACzD,MAAMC,kBAAkBH,QAAQ,SAAS,CAAC,OAAO,CAACI;QAClD,MAAMC,6BAA6BL,QAAQ,SAAS,CAAC,OAAO,CACxDM;QAGJ,MAAMC,wBAAwB,IAAIC,6BAA6BP;QAC/D,MAAMQ,qBAAqB,IAAIC,mBAAmBT;QAElDU,oCAAoCX,SAAS,eAAe,OAAO,GAAGY;YAClE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,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OAAOP,UAAUC,OAAOU;QAC5B;QAGJb,oCAAoCX,SAAS,aAAa,OAAO,GAAGY;YAChE,MAAM,CAACC,WAAWC,OAAOU,IAAIG,eAAe,GAAGf;YAK/C,MAAMK,QAAQ,MAAMd,gBAAgB,OAAO,CAACW,OAAO;gBAC/CU;YACJ;YAEA,MAAMN,WAAWD,OAAO,UAAU,YAAYE;YAI9C,IAAID,aAAaS,gBACb,OAAOd,UAAUC,OAAOU,IAAIG;YACzB,IAAIT,aAAaC,aAAa;gBAIjC,MAAMC,cACF,MAAMnB,uBAAuB,yBAAyB,CAACiB;gBAC3D,MAAMjB,uBAAuB,4BAA4B,CAAC;oBACtDmB;oBACA,KAAK;gBACT;YACJ;YAIA,IAAIO,mBAAmBR,aAAa;gBAChC,MAAMC,cACF,MAAMnB,uBAAuB,yBAAyB,CAACiB;gBAC3D,MAAMjB,uBAAuB,4BAA4B,CAAC;oBACtDmB;oBACA,KAAK;gBACT;YACJ;YAEA,OAAOP,UAAUC,OAAOU,IAAIG;QAChC;IACJ;AACJ"}
|
package/utils/resolve.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ErrorResponse, Response } from "@webiny/
|
|
2
|
-
export declare const resolve: (fn: () => Promise<any>) => Promise<Response<any
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
2
|
+
export declare const resolve: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
|
package/utils/resolve.js
CHANGED
package/utils/resolve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/resolve.js","sources":["../../src/utils/resolve.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/
|
|
1
|
+
{"version":3,"file":"utils/resolve.js","sources":["../../src/utils/resolve.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/api-graphql\";\n\nexport const resolve = async (fn: () => Promise<any>) => {\n try {\n return new Response(await fn());\n } catch (e) {\n return new ErrorResponse(e);\n }\n};\n"],"names":["resolve","fn","Response","e","ErrorResponse"],"mappings":";AAEO,MAAMA,UAAU,OAAOC;IAC1B,IAAI;QACA,OAAO,IAAIC,SAAS,MAAMD;IAC9B,EAAE,OAAOE,GAAG;QACR,OAAO,IAAIC,cAAcD;IAC7B;AACJ"}
|
package/createAcoContext.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
|
-
import type { AcoContext } from "./types.js";
|
|
4
|
-
interface CreateAcoContextParams {
|
|
5
|
-
useFolderLevelPermissions?: boolean;
|
|
6
|
-
documentClient: DynamoDBDocument;
|
|
7
|
-
}
|
|
8
|
-
export declare const createAcoContext: (params: CreateAcoContextParams) => (ContextPlugin<AcoContext> | import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types").Context>)[];
|
|
9
|
-
export {};
|
package/createAcoContext.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import { isHeadlessCmsReady } from "@webiny/api-headless-cms";
|
|
3
|
-
import { createAcoStorageOperations } from "./createAcoStorageOperations.js";
|
|
4
|
-
import { createFilterCrudMethods } from "./filter/filter.crud.js";
|
|
5
|
-
import { createFlpCrudMethods } from "./flp/index.js";
|
|
6
|
-
import { FolderLevelPermissions, FolderLevelPermissionsFeature } from "./features/flp/FolderLevelPermissions/index.js";
|
|
7
|
-
import { UpdateFolderFeature } from "./features/folder/UpdateFolder/index.js";
|
|
8
|
-
import { DeleteFolderFeature } from "./features/folder/DeleteFolder/index.js";
|
|
9
|
-
import { CreateFolderFeature } from "./features/folder/CreateFolder/index.js";
|
|
10
|
-
import { GetFolderFeature } from "./features/folder/GetFolder/index.js";
|
|
11
|
-
import { ListFoldersFeature } from "./features/folder/ListFolders/index.js";
|
|
12
|
-
import { GetFolderHierarchyFeature } from "./features/folder/GetFolderHierarchy/index.js";
|
|
13
|
-
import { GetAncestorsFeature } from "./features/folder/GetAncestors/index.js";
|
|
14
|
-
import { UpdateFlpOnFolderUpdatedFeature } from "./features/flp/UpdateFlpOnFolderUpdated/index.js";
|
|
15
|
-
import { DeleteFlpOnFolderDeletedFeature } from "./features/flp/DeleteFlpOnFolderDeleted/index.js";
|
|
16
|
-
import { EnsureHcmsFolderIsEmptyOnDeleteFeature } from "./features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js";
|
|
17
|
-
import { CreateFlpFeature } from "./features/flp/CreateFlp/index.js";
|
|
18
|
-
import { DeleteFlpFeature } from "./features/flp/DeleteFlp/index.js";
|
|
19
|
-
import { UpdateFlpFeature } from "./features/flp/UpdateFlp/index.js";
|
|
20
|
-
import { EnsureFolderIsEmptyOnDeleteFeature } from "./features/folder/EnsureFolderIsEmptyOnDelete/index.js";
|
|
21
|
-
import { FilterStorageOperations } from "./features/folder/shared/abstractions.js";
|
|
22
|
-
import { ListFlpsFeature } from "./features/flp/ListFlps/feature.js";
|
|
23
|
-
import { GetFlpFeature } from "./features/flp/GetFlp/feature.js";
|
|
24
|
-
import { ListFolderLevelPermissionsTargetsFeature } from "./features/folder/ListFolderLevelPermissionsTargets/feature.js";
|
|
25
|
-
import { CmsFlpFeature } from "./features/cms/index.js";
|
|
26
|
-
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
27
|
-
import { FolderModel } from "./domain/folder/abstractions.js";
|
|
28
|
-
import { CreateFlpOnFolderCreatedFeature } from "./features/flp/CreateFlpOnFolderCreated/index.js";
|
|
29
|
-
import { EnsureFolderIsEmptyFeature } from "./features/folder/EnsureFolderIsEmpty/feature.js";
|
|
30
|
-
import { FOLDER_MODEL_ID, FolderModel as folder_model_js_FolderModel } from "./domain/folder/folder.model.js";
|
|
31
|
-
import { FilterPrivateModel } from "./filter/filter.model.js";
|
|
32
|
-
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
33
|
-
const setupAcoContext = async (context, setupAcoContextParams)=>{
|
|
34
|
-
const { tenancy, security } = context;
|
|
35
|
-
const getModel = context.container.resolve(GetModelUseCase);
|
|
36
|
-
await context.security.withoutAuthorization(async ()=>{
|
|
37
|
-
const folderModel = await getModel.execute(FOLDER_MODEL_ID);
|
|
38
|
-
context.container.registerInstance(FolderModel, folderModel.value);
|
|
39
|
-
});
|
|
40
|
-
const getTenant = ()=>tenancy.getCurrentTenant();
|
|
41
|
-
const storageOperations = await createAcoStorageOperations({
|
|
42
|
-
cms: context.cms,
|
|
43
|
-
container: context.container,
|
|
44
|
-
documentClient: setupAcoContextParams.documentClient,
|
|
45
|
-
security
|
|
46
|
-
});
|
|
47
|
-
const flpCrudMethods = createFlpCrudMethods({
|
|
48
|
-
getTenant,
|
|
49
|
-
storageOperations
|
|
50
|
-
});
|
|
51
|
-
FolderLevelPermissionsFeature.register(context.container);
|
|
52
|
-
context.container.registerInstance(FilterStorageOperations, storageOperations.filter);
|
|
53
|
-
CreateFolderFeature.register(context.container);
|
|
54
|
-
UpdateFolderFeature.register(context.container);
|
|
55
|
-
DeleteFolderFeature.register(context.container);
|
|
56
|
-
GetFolderFeature.register(context.container);
|
|
57
|
-
ListFoldersFeature.register(context.container);
|
|
58
|
-
ListFolderLevelPermissionsTargetsFeature.register(context.container);
|
|
59
|
-
GetFolderHierarchyFeature.register(context.container);
|
|
60
|
-
GetAncestorsFeature.register(context.container);
|
|
61
|
-
EnsureFolderIsEmptyFeature.register(context.container);
|
|
62
|
-
CreateFlpFeature.register(context.container, {
|
|
63
|
-
context
|
|
64
|
-
});
|
|
65
|
-
UpdateFlpFeature.register(context.container, {
|
|
66
|
-
context
|
|
67
|
-
});
|
|
68
|
-
DeleteFlpFeature.register(context.container, {
|
|
69
|
-
context
|
|
70
|
-
});
|
|
71
|
-
ListFlpsFeature.register(context.container, flpCrudMethods);
|
|
72
|
-
GetFlpFeature.register(context.container, flpCrudMethods);
|
|
73
|
-
CreateFlpOnFolderCreatedFeature.register(context.container);
|
|
74
|
-
UpdateFlpOnFolderUpdatedFeature.register(context.container);
|
|
75
|
-
DeleteFlpOnFolderDeletedFeature.register(context.container);
|
|
76
|
-
EnsureFolderIsEmptyOnDeleteFeature.register(context.container);
|
|
77
|
-
EnsureHcmsFolderIsEmptyOnDeleteFeature.register(context.container);
|
|
78
|
-
const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);
|
|
79
|
-
context.aco = {
|
|
80
|
-
filter: createFilterCrudMethods({
|
|
81
|
-
container: context.container,
|
|
82
|
-
getTenant,
|
|
83
|
-
storageOperations,
|
|
84
|
-
folderLevelPermissions
|
|
85
|
-
}),
|
|
86
|
-
flp: flpCrudMethods
|
|
87
|
-
};
|
|
88
|
-
if (context.wcp.canUseFolderLevelPermissions()) CmsFlpFeature.register(context.container);
|
|
89
|
-
};
|
|
90
|
-
const createAcoContext = (params)=>{
|
|
91
|
-
const modelsPlugin = createRegisterExtensionPlugin((context)=>{
|
|
92
|
-
context.container.register(folder_model_js_FolderModel);
|
|
93
|
-
context.container.register(FilterPrivateModel);
|
|
94
|
-
});
|
|
95
|
-
const acoContextPlugin = new ContextPlugin(async (context)=>{
|
|
96
|
-
if (!await isHeadlessCmsReady(context)) return;
|
|
97
|
-
await context.benchmark.measure("aco.context.setup", async ()=>{
|
|
98
|
-
await setupAcoContext(context, params);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
acoContextPlugin.name = "aco.createContext";
|
|
102
|
-
return [
|
|
103
|
-
acoContextPlugin,
|
|
104
|
-
modelsPlugin
|
|
105
|
-
];
|
|
106
|
-
};
|
|
107
|
-
export { createAcoContext };
|
|
108
|
-
|
|
109
|
-
//# sourceMappingURL=createAcoContext.js.map
|
package/createAcoContext.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createAcoContext.js","sources":["../src/createAcoContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { isHeadlessCmsReady } from \"@webiny/api-headless-cms\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createAcoStorageOperations } from \"~/createAcoStorageOperations.js\";\nimport type { AcoContext } from \"~/types.js\";\nimport { createFilterCrudMethods } from \"~/filter/filter.crud.js\";\nimport { createFlpCrudMethods } from \"~/flp/index.js\";\nimport {\n FolderLevelPermissions,\n FolderLevelPermissionsFeature\n} from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { UpdateFolderFeature } from \"~/features/folder/UpdateFolder/index.js\";\nimport { DeleteFolderFeature } from \"~/features/folder/DeleteFolder/index.js\";\nimport { CreateFolderFeature } from \"~/features/folder/CreateFolder/index.js\";\nimport { GetFolderFeature } from \"~/features/folder/GetFolder/index.js\";\nimport { ListFoldersFeature } from \"~/features/folder/ListFolders/index.js\";\nimport { GetFolderHierarchyFeature } from \"~/features/folder/GetFolderHierarchy/index.js\";\nimport { GetAncestorsFeature } from \"~/features/folder/GetAncestors/index.js\";\nimport { UpdateFlpOnFolderUpdatedFeature } from \"~/features/flp/UpdateFlpOnFolderUpdated/index.js\";\nimport { DeleteFlpOnFolderDeletedFeature } from \"~/features/flp/DeleteFlpOnFolderDeleted/index.js\";\nimport { EnsureHcmsFolderIsEmptyOnDeleteFeature } from \"~/features/folder/EnsureHcmsFolderIsEmptyOnDelete/index.js\";\nimport { CreateFlpFeature } from \"~/features/flp/CreateFlp/index.js\";\nimport { DeleteFlpFeature } from \"~/features/flp/DeleteFlp/index.js\";\nimport { UpdateFlpFeature } from \"~/features/flp/UpdateFlp/index.js\";\nimport { EnsureFolderIsEmptyOnDeleteFeature } from \"~/features/folder/EnsureFolderIsEmptyOnDelete/index.js\";\nimport { FilterStorageOperations } from \"~/features/folder/shared/abstractions.js\";\nimport { ListFlpsFeature } from \"~/features/flp/ListFlps/feature.js\";\nimport { GetFlpFeature } from \"~/features/flp/GetFlp/feature.js\";\nimport { ListFolderLevelPermissionsTargetsFeature } from \"~/features/folder/ListFolderLevelPermissionsTargets/feature.js\";\nimport { Tenant } from \"@webiny/api-core/types/tenancy\";\nimport { CmsFlpFeature } from \"~/features/cms/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { FolderModel as FolderModelAbstraction } from \"~/domain/folder/abstractions.js\";\nimport { CreateFlpOnFolderCreatedFeature } from \"~/features/flp/CreateFlpOnFolderCreated/index.js\";\nimport { EnsureFolderIsEmptyFeature } from \"~/features/folder/EnsureFolderIsEmpty/feature.js\";\nimport { FOLDER_MODEL_ID, FolderModel } from \"~/domain/folder/folder.model.js\";\nimport { FilterPrivateModel } from \"~/filter/filter.model.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\n\ninterface CreateAcoContextParams {\n useFolderLevelPermissions?: boolean;\n documentClient: DynamoDBDocument;\n}\n\nconst setupAcoContext = async (\n context: AcoContext,\n setupAcoContextParams: CreateAcoContextParams\n): Promise<void> => {\n const { tenancy, security } = context;\n\n const getModel = context.container.resolve(GetModelUseCase);\n\n await context.security.withoutAuthorization(async () => {\n const folderModel = await getModel.execute(FOLDER_MODEL_ID);\n context.container.registerInstance(FolderModelAbstraction, folderModel.value);\n });\n\n const getTenant = (): Tenant => {\n return tenancy.getCurrentTenant();\n };\n\n const storageOperations = await createAcoStorageOperations({\n /**\n * TODO: We need to figure out a way to pass \"cms\" from outside (e.g. apps/api/graphql)\n */\n cms: context.cms,\n container: context.container,\n documentClient: setupAcoContextParams.documentClient,\n security\n });\n\n const flpCrudMethods = createFlpCrudMethods({\n getTenant,\n storageOperations\n });\n\n FolderLevelPermissionsFeature.register(context.container);\n\n /**\n * Register legacy dependencies via abstractions\n */\n context.container.registerInstance(FilterStorageOperations, storageOperations.filter);\n\n /**\n * Register folder features into DI container\n */\n CreateFolderFeature.register(context.container);\n\n UpdateFolderFeature.register(context.container);\n\n DeleteFolderFeature.register(context.container);\n\n GetFolderFeature.register(context.container);\n\n ListFoldersFeature.register(context.container);\n\n ListFolderLevelPermissionsTargetsFeature.register(context.container);\n\n GetFolderHierarchyFeature.register(context.container);\n\n GetAncestorsFeature.register(context.container);\n\n EnsureFolderIsEmptyFeature.register(context.container);\n\n /**\n * Register FLP use cases and event handlers\n */\n CreateFlpFeature.register(context.container, { context });\n UpdateFlpFeature.register(context.container, { context });\n DeleteFlpFeature.register(context.container, { context });\n ListFlpsFeature.register(context.container, flpCrudMethods);\n GetFlpFeature.register(context.container, flpCrudMethods);\n\n CreateFlpOnFolderCreatedFeature.register(context.container);\n\n UpdateFlpOnFolderUpdatedFeature.register(context.container);\n\n DeleteFlpOnFolderDeletedFeature.register(context.container);\n\n /**\n * Register folder event handlers\n */\n EnsureFolderIsEmptyOnDeleteFeature.register(context.container);\n EnsureHcmsFolderIsEmptyOnDeleteFeature.register(context.container);\n\n /**\n * Setup legacy context\n */\n const folderLevelPermissions = context.container.resolve(FolderLevelPermissions);\n\n context.aco = {\n filter: createFilterCrudMethods({\n container: context.container,\n getTenant,\n storageOperations,\n folderLevelPermissions\n }),\n flp: flpCrudMethods\n };\n\n if (context.wcp.canUseFolderLevelPermissions()) {\n CmsFlpFeature.register(context.container);\n }\n};\n\nexport const createAcoContext = (params: CreateAcoContextParams) => {\n const modelsPlugin = createRegisterExtensionPlugin(context => {\n context.container.register(FolderModel);\n context.container.register(FilterPrivateModel);\n });\n\n const acoContextPlugin = new ContextPlugin<AcoContext>(async context => {\n /**\n * We can skip the ACO initialization if the installation is pending.\n */\n if (!(await isHeadlessCmsReady(context))) {\n return;\n }\n\n await context.benchmark.measure(\"aco.context.setup\", async () => {\n await setupAcoContext(context, params);\n });\n });\n\n acoContextPlugin.name = \"aco.createContext\";\n\n return [acoContextPlugin, modelsPlugin];\n};\n"],"names":["setupAcoContext","context","setupAcoContextParams","tenancy","security","getModel","GetModelUseCase","folderModel","FOLDER_MODEL_ID","FolderModelAbstraction","getTenant","storageOperations","createAcoStorageOperations","flpCrudMethods","createFlpCrudMethods","FolderLevelPermissionsFeature","FilterStorageOperations","CreateFolderFeature","UpdateFolderFeature","DeleteFolderFeature","GetFolderFeature","ListFoldersFeature","ListFolderLevelPermissionsTargetsFeature","GetFolderHierarchyFeature","GetAncestorsFeature","EnsureFolderIsEmptyFeature","CreateFlpFeature","UpdateFlpFeature","DeleteFlpFeature","ListFlpsFeature","GetFlpFeature","CreateFlpOnFolderCreatedFeature","UpdateFlpOnFolderUpdatedFeature","DeleteFlpOnFolderDeletedFeature","EnsureFolderIsEmptyOnDeleteFeature","EnsureHcmsFolderIsEmptyOnDeleteFeature","folderLevelPermissions","FolderLevelPermissions","createFilterCrudMethods","CmsFlpFeature","createAcoContext","params","modelsPlugin","createRegisterExtensionPlugin","FolderModel","FilterPrivateModel","acoContextPlugin","ContextPlugin","isHeadlessCmsReady"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,kBAAkB,OACpBC,SACAC;IAEA,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGH;IAE9B,MAAMI,WAAWJ,QAAQ,SAAS,CAAC,OAAO,CAACK;IAE3C,MAAML,QAAQ,QAAQ,CAAC,oBAAoB,CAAC;QACxC,MAAMM,cAAc,MAAMF,SAAS,OAAO,CAACG;QAC3CP,QAAQ,SAAS,CAAC,gBAAgB,CAACQ,aAAwBF,YAAY,KAAK;IAChF;IAEA,MAAMG,YAAY,IACPP,QAAQ,gBAAgB;IAGnC,MAAMQ,oBAAoB,MAAMC,2BAA2B;QAIvD,KAAKX,QAAQ,GAAG;QAChB,WAAWA,QAAQ,SAAS;QAC5B,gBAAgBC,sBAAsB,cAAc;QACpDE;IACJ;IAEA,MAAMS,iBAAiBC,qBAAqB;QACxCJ;QACAC;IACJ;IAEAI,8BAA8B,QAAQ,CAACd,QAAQ,SAAS;IAKxDA,QAAQ,SAAS,CAAC,gBAAgB,CAACe,yBAAyBL,kBAAkB,MAAM;IAKpFM,oBAAoB,QAAQ,CAAChB,QAAQ,SAAS;IAE9Ci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AAA;QAC/CA,QAAQ,SAAS,CAAC,QAAQ,CAAC2C;QAC3B3C,QAAQ,SAAS,CAAC,QAAQ,CAAC4C;IAC/B;IAEA,MAAMC,mBAAmB,IAAIC,cAA0B,OAAM9C;QAIzD,IAAI,CAAE,MAAM+C,mBAAmB/C,UAC3B;QAGJ,MAAMA,QAAQ,SAAS,CAAC,OAAO,CAAC,qBAAqB;YACjD,MAAMD,gBAAgBC,SAASwC;QACnC;IACJ;IAEAK,iBAAiB,IAAI,GAAG;IAExB,OAAO;QAACA;QAAkBJ;KAAa;AAC3C"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { HeadlessCms } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
|
-
import type { AcoStorageOperations } from "./types.js";
|
|
4
|
-
import type { Security } from "@webiny/api-core/types/security.js";
|
|
5
|
-
import type { Container } from "@webiny/di";
|
|
6
|
-
export interface CreateAcoStorageOperationsParams {
|
|
7
|
-
cms: HeadlessCms;
|
|
8
|
-
security: Security;
|
|
9
|
-
container: Container;
|
|
10
|
-
documentClient: DynamoDBDocument;
|
|
11
|
-
}
|
|
12
|
-
export declare const createAcoStorageOperations: (params: CreateAcoStorageOperationsParams) => Promise<AcoStorageOperations>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createFilterOperations } from "./filter/filter.so.js";
|
|
2
|
-
import { createFlpOperations } from "./flp/index.js";
|
|
3
|
-
const createAcoStorageOperations = async (params)=>({
|
|
4
|
-
filter: createFilterOperations(params),
|
|
5
|
-
flp: createFlpOperations(params)
|
|
6
|
-
});
|
|
7
|
-
export { createAcoStorageOperations };
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=createAcoStorageOperations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createAcoStorageOperations.js","sources":["../src/createAcoStorageOperations.ts"],"sourcesContent":["import type { HeadlessCms } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createFilterOperations } from \"~/filter/filter.so.js\";\nimport type { AcoStorageOperations } from \"~/types.js\";\nimport { createFlpOperations } from \"~/flp/index.js\";\nimport type { Security } from \"@webiny/api-core/types/security.js\";\nimport type { Container } from \"@webiny/di\";\n\nexport interface CreateAcoStorageOperationsParams {\n cms: HeadlessCms;\n security: Security;\n container: Container;\n documentClient: DynamoDBDocument;\n}\n\nexport const createAcoStorageOperations = async (\n params: CreateAcoStorageOperationsParams\n): Promise<AcoStorageOperations> => {\n return {\n filter: createFilterOperations(params),\n flp: createFlpOperations(params)\n };\n};\n"],"names":["createAcoStorageOperations","params","createFilterOperations","createFlpOperations"],"mappings":";;AAeO,MAAMA,6BAA6B,OACtCC,SAEO;QACH,QAAQC,uBAAuBD;QAC/B,KAAKE,oBAAoBF;IAC7B"}
|
package/createAcoTasks.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createAcoTasks: () => import("@webiny/api").ContextPlugin<import("@webiny/api/types").Context>;
|
package/createAcoTasks.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createContextPlugin } from "@webiny/api";
|
|
2
|
-
import { CreateFlpTask } from "./flp/tasks/createFlp.task.js";
|
|
3
|
-
import { UpdateFlpTask } from "./flp/tasks/updateFlp.task.js";
|
|
4
|
-
import { DeleteFlpTask } from "./flp/tasks/deleteFlp.task.js";
|
|
5
|
-
import { SyncFlpTask } from "./flp/tasks/syncFlp.task.js";
|
|
6
|
-
const createAcoTasks = ()=>createContextPlugin((context)=>{
|
|
7
|
-
context.container.register(CreateFlpTask);
|
|
8
|
-
context.container.register(UpdateFlpTask);
|
|
9
|
-
context.container.register(DeleteFlpTask);
|
|
10
|
-
context.container.register(SyncFlpTask);
|
|
11
|
-
});
|
|
12
|
-
export { createAcoTasks };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=createAcoTasks.js.map
|
package/createAcoTasks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createAcoTasks.js","sources":["../src/createAcoTasks.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { CreateFlpTask } from \"~/flp/tasks/createFlp.task.js\";\nimport { UpdateFlpTask } from \"~/flp/tasks/updateFlp.task.js\";\nimport { DeleteFlpTask } from \"~/flp/tasks/deleteFlp.task.js\";\nimport { SyncFlpTask } from \"~/flp/tasks/syncFlp.task.js\";\n\nexport const createAcoTasks = () => {\n return createContextPlugin(context => {\n context.container.register(CreateFlpTask);\n context.container.register(UpdateFlpTask);\n context.container.register(DeleteFlpTask);\n context.container.register(SyncFlpTask);\n });\n};\n"],"names":["createAcoTasks","createContextPlugin","context","CreateFlpTask","UpdateFlpTask","DeleteFlpTask","SyncFlpTask"],"mappings":";;;;;AAMO,MAAMA,iBAAiB,IACnBC,oBAAoBC,CAAAA;QACvBA,QAAQ,SAAS,CAAC,QAAQ,CAACC;QAC3BD,QAAQ,SAAS,CAAC,QAAQ,CAACE;QAC3BF,QAAQ,SAAS,CAAC,QAAQ,CAACG;QAC3BH,QAAQ,SAAS,CAAC,QAAQ,CAACI;IAC/B"}
|
package/flp/flp.so.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
-
import type { AcoFolderLevelPermissionsStorageOperations as IAcoFolderLevelPermissionsStorageOperations, FolderLevelPermission, StorageOperationsBatchUpdateFlpParams, StorageOperationsCreateFlpParams, StorageOperationsDeleteFlpParams, StorageOperationsGetFlpParams, StorageOperationsListFlpsParams, StorageOperationsUpdateFlpParams } from "../flp/flp.types.js";
|
|
3
|
-
interface StorageOperationsConfig {
|
|
4
|
-
documentClient: DynamoDBDocument;
|
|
5
|
-
}
|
|
6
|
-
declare class FolderLevelPermissionsStorageOperations implements IAcoFolderLevelPermissionsStorageOperations {
|
|
7
|
-
private readonly entity;
|
|
8
|
-
private readonly table;
|
|
9
|
-
constructor({ documentClient }: StorageOperationsConfig);
|
|
10
|
-
list({ where: { tenant, type, path_startsWith, parentId } }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]>;
|
|
11
|
-
get({ tenant, id }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null>;
|
|
12
|
-
create({ data }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission>;
|
|
13
|
-
update({ data: inputData, original }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission>;
|
|
14
|
-
delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void>;
|
|
15
|
-
batchUpdate({ items }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]>;
|
|
16
|
-
private createKeys;
|
|
17
|
-
private createGsiKeys;
|
|
18
|
-
}
|
|
19
|
-
export declare const createFlpOperations: (params: StorageOperationsConfig) => FolderLevelPermissionsStorageOperations;
|
|
20
|
-
export {};
|