@webiny/api-aco 6.4.12-beta.4 → 6.5.0-beta.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/createAcoContext.d.ts +1 -7
- package/createAcoContext.js +42 -38
- package/createAcoContext.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/MoveEntryWithFlpDecorator.d.ts +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/folder/DeleteFolder/decorators/DeleteFolderWithFolderLevelPermissions.d.ts +1 -1
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js +1 -1
- package/features/folder/EnsureFolderIsEmpty/EnsureFolderIsEmpty.js.map +1 -1
- package/features/folder/EnsureHcmsFolderIsEmptyOnDelete/ModelFolderBeforeDeleteHandler.js +4 -1
- 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 +4 -0
- package/features/folder/shared/abstractions.js +2 -1
- package/features/folder/shared/abstractions.js.map +1 -1
- package/filter/filter.so.d.ts +10 -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/syncFlp.task.d.ts +2 -2
- package/flp/tasks/syncFlp.task.js +7 -1
- package/flp/tasks/syncFlp.task.js.map +1 -1
- package/flp/tasks/updateFlp.task.d.ts +2 -2
- package/folder/folder.gql.js +7 -1
- package/folder/folder.gql.js.map +1 -1
- package/index.d.ts +1 -6
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/package.json +21 -24
- package/utils/createOperationsWrapper.d.ts +5 -2
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.js +1 -1
- package/utils/decorators/CmsEntriesCrudDecorators.js.map +1 -1
- package/utils/decorators/isPageModel.js +1 -1
- package/utils/decorators/isPageModel.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/createAcoStorageOperations.d.ts +0 -12
- package/createAcoStorageOperations.js +0 -9
- package/createAcoStorageOperations.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flp/tasks/syncFlp.task.js","sources":["../../../src/flp/tasks/syncFlp.task.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { SYNC_FLP_TASK_ID, UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type ISyncFlpTaskInput, type IUpdateFlpTaskInput } from \"~/types.js\";\nimport { FM_FILE_TYPE } from \"~/constants.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/index.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/index.js\";\n\nclass SyncFlpTaskImpl implements TaskDefinition.Interface<ISyncFlpTaskInput> {\n public readonly id = SYNC_FLP_TASK_ID;\n public readonly title = \"ACO - Sync FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by updating the FLP record and its descendants.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n public constructor(\n private getFolder: GetFolderUseCase.Interface,\n private listFolders: ListFoldersUseCase.Interface,\n private listModels: ListModelsUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskDefinition.RunParams<ISyncFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n /**\n * `folderId` provided in the task input. We need to:\n *\n * - update the FLP records for the found folder and all its descendants.\n */\n if (input.folderId) {\n const result = await this.getFolder.execute(input.folderId
|
|
1
|
+
{"version":3,"file":"flp/tasks/syncFlp.task.js","sources":["../../../src/flp/tasks/syncFlp.task.ts"],"sourcesContent":["import { TaskDefinition } from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { SYNC_FLP_TASK_ID, UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type ISyncFlpTaskInput, type IUpdateFlpTaskInput } from \"~/types.js\";\nimport { FM_FILE_TYPE } from \"~/constants.js\";\nimport { GetFolderUseCase } from \"~/features/folder/GetFolder/index.js\";\nimport { ListFoldersUseCase } from \"~/features/folder/ListFolders/index.js\";\n\nclass SyncFlpTaskImpl implements TaskDefinition.Interface<ISyncFlpTaskInput> {\n public readonly id = SYNC_FLP_TASK_ID;\n public readonly title = \"ACO - Sync FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by updating the FLP record and its descendants.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n public constructor(\n private getFolder: GetFolderUseCase.Interface,\n private listFolders: ListFoldersUseCase.Interface,\n private listModels: ListModelsUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskDefinition.RunParams<ISyncFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n /**\n * `folderId` provided in the task input. We need to:\n *\n * - update the FLP records for the found folder and all its descendants.\n */\n if (input.folderId) {\n const result = await this.getFolder.execute(input.folderId);\n if (result.isFail()) {\n return controller.response.error(result.error);\n }\n const folder = result.value;\n\n await controller.task.trigger<IUpdateFlpTaskInput>({\n definition: UPDATE_FLP_TASK_ID,\n input: {\n folder\n }\n });\n\n return controller.response.done(\n `Task completed successfully: all FLP records for folderId \"${input.folderId}\" and its children have been queued to be synchronized.`\n );\n }\n\n /**\n * Full update required. We need to:\n *\n * - list cms models to collect their types, together with the default ones [FM_FILE_TYPE]\n * - list all root folders\n * - update the FLP records for the found folders and all its descendants.\n */\n if (input.type && input.type === \"*\") {\n // Some folder types are fixed: pages and files.\n const folderTypes = [FM_FILE_TYPE];\n\n // List all non-private models\n const modelsResult = await this.listModels.execute();\n if (modelsResult.isOk()) {\n const models = modelsResult.value;\n for (const model of models) {\n folderTypes.push(`cms:${model.modelId}`);\n }\n }\n\n for (const folderType of folderTypes) {\n const result = await this.listFolders.execute({\n where: {\n type: folderType,\n parentId: null\n }\n });\n if (result.isFail()) {\n await controller.logger.error({\n message: `Failed to list root folders for type ${folderType}`,\n data: {\n type: folderType,\n error: result.error\n }\n });\n continue;\n }\n\n const { folders } = result.value;\n\n for (const folder of folders) {\n await controller.task.trigger<IUpdateFlpTaskInput>({\n definition: UPDATE_FLP_TASK_ID,\n input: {\n folder\n }\n });\n }\n\n await controller.logger.info({\n message: `FLP Update task triggered for type ${folderType}`,\n data: {\n type: folderType\n }\n });\n }\n\n return controller.response.done(\n `Task completed successfully: all FLP records have been queued to be synchronized.`\n );\n }\n\n /**\n * `type` provided in the task input. We need to:\n *\n * - list all root folders for the provided type\n * - update the FLP records for the found folders and all its descendants.\n */\n if (input.type) {\n const result = await this.listFolders.execute({\n where: {\n type: input.type!,\n parentId: null\n }\n });\n if (result.isFail()) {\n return controller.response.error(result.error);\n }\n\n const { folders } = result.value;\n\n for (const folder of folders) {\n await controller.task.trigger<IUpdateFlpTaskInput>({\n definition: UPDATE_FLP_TASK_ID,\n input: {\n folder\n }\n });\n }\n\n return controller.response.done(\n `Task completed successfully: all FLP records for type \"${input.type}\" have been queued to be synchronized.`\n );\n }\n\n return controller.response.error(\n \"Invalid input: please provide either `type` or `folderId`.\"\n );\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nexport const SyncFlpTask = TaskDefinition.createImplementation({\n implementation: SyncFlpTaskImpl,\n dependencies: [GetFolderUseCase, ListFoldersUseCase, ListModelsUseCase]\n});\n"],"names":["SyncFlpTaskImpl","getFolder","listFolders","listModels","SYNC_FLP_TASK_ID","input","controller","result","folder","UPDATE_FLP_TASK_ID","folderTypes","FM_FILE_TYPE","modelsResult","models","model","folderType","folders","error","SyncFlpTask","TaskDefinition","GetFolderUseCase","ListFoldersUseCase","ListModelsUseCase"],"mappings":";;;;;;AAQA,MAAMA;IASF,YACYC,SAAqC,EACrCC,WAAyC,EACzCC,UAAuC,CACjD;aAHUF,SAAS,GAATA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;aAXI,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,WAAW,GACvB;aACY,YAAY,GAAG;aACf,SAAS,GAAG;aACZ,WAAW,GAAG;YAAC;YAAsB;SAAmB;IAMrE;IAEH,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAA+C,EAAE;QAC1E,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAQtC,IAAID,MAAM,QAAQ,EAAE;gBAChB,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF,MAAM,QAAQ;gBAC1D,IAAIE,OAAO,MAAM,IACb,OAAOD,WAAW,QAAQ,CAAC,KAAK,CAACC,OAAO,KAAK;gBAEjD,MAAMC,SAASD,OAAO,KAAK;gBAE3B,MAAMD,WAAW,IAAI,CAAC,OAAO,CAAsB;oBAC/C,YAAYG;oBACZ,OAAO;wBACHD;oBACJ;gBACJ;gBAEA,OAAOF,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,2DAA2D,EAAED,MAAM,Q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AO,MAAM,IACb,OAAOD,WAAW,QAAQ,CAAC,KAAK,CAACC,OAAO,KAAK;gBAGjD,MAAM,EAAES,OAAO,EAAE,GAAGT,OAAO,KAAK;gBAEhC,KAAK,MAAMC,UAAUQ,QACjB,MAAMV,WAAW,IAAI,CAAC,OAAO,CAAsB;oBAC/C,YAAYG;oBACZ,OAAO;wBACHD;oBACJ;gBACJ;gBAGJ,OAAOF,WAAW,QAAQ,CAAC,IAAI,CAC3B,CAAC,uDAAuD,EAAED,MAAM,IAAI,CAAC,sCAAsC,CAAC;YAEpH;YAEA,OAAOC,WAAW,QAAQ,CAAC,KAAK,CAC5B;QAER,EAAE,OAAOW,OAAO;YACZ,OAAOX,WAAW,QAAQ,CAAC,KAAK,CAACW;QACrC;IACJ;AACJ;AAEO,MAAMC,cAAcC,eAAe,oBAAoB,CAAC;IAC3D,gBAAgBnB;IAChB,cAAc;QAACoB;QAAkBC;QAAoBC;KAAkB;AAC3E"}
|
|
@@ -8,9 +8,9 @@ declare class UpdateFlpTaskImpl implements TaskDefinition.Interface<IUpdateFlpTa
|
|
|
8
8
|
readonly description = "Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.";
|
|
9
9
|
readonly databaseLogs = false;
|
|
10
10
|
readonly isPrivate = true;
|
|
11
|
-
readonly selfCleanup: ("
|
|
11
|
+
readonly selfCleanup: ("onAbort" | "onSuccess")[];
|
|
12
12
|
constructor(updateFlp: UpdateFlpUseCase.Interface);
|
|
13
|
-
run({ input, controller }: TaskDefinition.RunParams<IUpdateFlpTaskInput>): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions").
|
|
13
|
+
run({ input, controller }: TaskDefinition.RunParams<IUpdateFlpTaskInput>): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultError | TaskDefinition.ResultDone<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
|
14
14
|
}
|
|
15
15
|
export declare const UpdateFlpTask: typeof UpdateFlpTaskImpl & {
|
|
16
16
|
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskDefinition<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskInput, import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
|
package/folder/folder.gql.js
CHANGED
|
@@ -12,6 +12,7 @@ import { DeleteFolderUseCase } from "../features/folder/DeleteFolder/abstraction
|
|
|
12
12
|
import { GetFolderHierarchyUseCase } from "../features/folder/GetFolderHierarchy/abstractions.js";
|
|
13
13
|
import { ListFolderLevelPermissionsTargetsUseCase } from "../features/folder/ListFolderLevelPermissionsTargets/abstractions.js";
|
|
14
14
|
import { FolderModel } from "../domain/folder/abstractions.js";
|
|
15
|
+
import { ValuesSelectionGenerator } from "@webiny/api-headless-cms/features/contentModel/ValuesSelectionGenerator/abstractions.js";
|
|
15
16
|
const createFoldersSchema = (params)=>{
|
|
16
17
|
const folderGraphQL = new GraphQLSchemaPlugin({
|
|
17
18
|
typeDefs: createFolderTypeDefs(params),
|
|
@@ -38,7 +39,12 @@ const createFoldersSchema = (params)=>{
|
|
|
38
39
|
getFolderModel (_, __, context) {
|
|
39
40
|
return resolve(async ()=>{
|
|
40
41
|
ensureAuthentication(context);
|
|
41
|
-
|
|
42
|
+
const model = context.container.resolve(FolderModel);
|
|
43
|
+
const generator = context.container.resolve(ValuesSelectionGenerator);
|
|
44
|
+
return {
|
|
45
|
+
...model,
|
|
46
|
+
valuesSelection: generator.generate(model)
|
|
47
|
+
};
|
|
42
48
|
});
|
|
43
49
|
},
|
|
44
50
|
getFolder: async (_, { id }, context)=>resolve(async ()=>{
|
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,sBAAs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AAc,IAAI,GAAG;IAErB,OAAOA;AACX"}
|
|
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\";\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,M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S,CAAC,OAAO,CAAC+B;wBACtD,MAAMlB,SAAS,MAAMiB,oBAAoB,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
|
|
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>)[];
|
|
2
|
+
export declare const createAco: () => ((import("@webiny/api/index.js").ContextPlugin<import("./types.js").AcoContext> | import("@webiny/handler/index.js").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>)[] | import("@webiny/api/index.js").ContextPlugin<import("./types.js").AcoContext> | import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<import("./types.js").AcoContext>)[];
|
|
8
3
|
export * from "./folder/createFolderModelModifier.js";
|
package/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { createAcoContext } from "./createAcoContext.js";
|
|
|
2
2
|
import { createAcoGraphQL } from "./createAcoGraphQL.js";
|
|
3
3
|
import { createAcoTasks } from "./createAcoTasks.js";
|
|
4
4
|
export * from "./folder/createFolderModelModifier.js";
|
|
5
|
-
const createAco = (
|
|
6
|
-
createAcoContext(
|
|
5
|
+
const createAco = ()=>[
|
|
6
|
+
createAcoContext(),
|
|
7
7
|
...createAcoGraphQL(),
|
|
8
8
|
createAcoTasks()
|
|
9
9
|
];
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createAcoContext } from \"~/createAcoContext.js\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL.js\";\nimport { createAcoTasks } from \"~/createAcoTasks.js\";\n\nexport { FILTER_MODEL_ID } from \"./filter/filter.model.js\";\n\nexport const createAco = () => {\n return [createAcoContext(), ...createAcoGraphQL(), createAcoTasks()];\n};\n\nexport * from \"./folder/createFolderModelModifier.js\";\n"],"names":["createAco","createAcoContext","createAcoGraphQL","createAcoTasks"],"mappings":";;;;AAMO,MAAMA,YAAY,IACd;QAACC;WAAuBC;QAAoBC;KAAiB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -21,34 +21,31 @@
|
|
|
21
21
|
".": "./index.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webiny/api": "6.
|
|
25
|
-
"@webiny/api-core": "6.
|
|
26
|
-
"@webiny/api-headless-cms": "6.
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/
|
|
30
|
-
"@webiny/
|
|
31
|
-
"@webiny/
|
|
32
|
-
"@webiny/
|
|
33
|
-
"@webiny/
|
|
34
|
-
"@webiny/
|
|
35
|
-
"@webiny/
|
|
36
|
-
"@webiny/utils": "6.4.12-beta.4",
|
|
37
|
-
"@webiny/validation": "6.4.12-beta.4",
|
|
24
|
+
"@webiny/api": "6.5.0-beta.0",
|
|
25
|
+
"@webiny/api-core": "6.5.0-beta.0",
|
|
26
|
+
"@webiny/api-headless-cms": "6.5.0-beta.0",
|
|
27
|
+
"@webiny/background-tasks": "6.5.0-beta.0",
|
|
28
|
+
"@webiny/di": "1.0.2",
|
|
29
|
+
"@webiny/error": "6.5.0-beta.0",
|
|
30
|
+
"@webiny/feature": "6.5.0-beta.0",
|
|
31
|
+
"@webiny/handler": "6.5.0-beta.0",
|
|
32
|
+
"@webiny/handler-graphql": "6.5.0-beta.0",
|
|
33
|
+
"@webiny/shared-aco": "6.5.0-beta.0",
|
|
34
|
+
"@webiny/utils": "6.5.0-beta.0",
|
|
35
|
+
"@webiny/validation": "6.5.0-beta.0",
|
|
38
36
|
"lodash": "4.18.1"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
|
-
"@webiny/api-
|
|
42
|
-
"@webiny/
|
|
43
|
-
"@webiny/
|
|
44
|
-
"@webiny/
|
|
45
|
-
"@webiny/
|
|
46
|
-
"@webiny/
|
|
47
|
-
"@webiny/wcp": "6.4.12-beta.4",
|
|
39
|
+
"@webiny/api-file-manager": "6.5.0-beta.0",
|
|
40
|
+
"@webiny/build-tools": "6.5.0-beta.0",
|
|
41
|
+
"@webiny/handler-aws": "6.5.0-beta.0",
|
|
42
|
+
"@webiny/plugins": "6.5.0-beta.0",
|
|
43
|
+
"@webiny/project-utils": "6.5.0-beta.0",
|
|
44
|
+
"@webiny/wcp": "6.5.0-beta.0",
|
|
48
45
|
"graphql": "16.14.2",
|
|
49
46
|
"rimraf": "6.1.3",
|
|
50
|
-
"typescript": "
|
|
51
|
-
"vitest": "
|
|
47
|
+
"typescript": "7.0.2",
|
|
48
|
+
"vitest": "4.1.10"
|
|
52
49
|
},
|
|
53
50
|
"webiny": {
|
|
54
51
|
"publishFrom": "dist"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HeadlessCms } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { Security } from "@webiny/api-core/types/security.js";
|
|
2
3
|
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
-
interface CreateOperationsWrapperParams
|
|
4
|
+
interface CreateOperationsWrapperParams {
|
|
5
|
+
cms: HeadlessCms;
|
|
6
|
+
security: Security;
|
|
4
7
|
modelName: string;
|
|
5
8
|
}
|
|
6
9
|
export declare const createOperationsWrapper: (params: CreateOperationsWrapperParams) => {
|
|
@@ -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 { Security } from \"@webiny/api-core/types/security.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams {\n cms: HeadlessCms;\n security: Security;\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { security, cms, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n const model = await security.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","security","cms","modelName","withModel","cb","model","WebinyError"],"mappings":";AAWO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,SAAS,EAAE,GAAGH;IAErC,MAAMI,YAAY,OACdC;QAEA,MAAMC,QAAQ,MAAML,SAAS,oBAAoB,CAAC,IACvCC,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"}
|
|
@@ -152,7 +152,7 @@ class CmsEntriesCrudDecorators {
|
|
|
152
152
|
});
|
|
153
153
|
const folderId = entry?.location?.folderId || ROOT_FOLDER;
|
|
154
154
|
if (folderId === targetFolderId) return decoratee(model, id, targetFolderId);
|
|
155
|
-
|
|
155
|
+
if (folderId !== ROOT_FOLDER) {
|
|
156
156
|
const permissions = await folderLevelPermissions.getFolderLevelPermissions(folderId);
|
|
157
157
|
await folderLevelPermissions.ensureCanAccessFolderContent({
|
|
158
158
|
permissions,
|
|
@@ -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;QAElDM,oCAAoCP,SAAS,eAAe,OAAO,GAAGQ;YAClE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAEAJ,oCAAoCP,SAAS,qBAAqB,OAAO,GAAGQ;YACxE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAEAJ,oCACIP,SACA,wBACA,OAAO,GAAGQ;YACN,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,CAAC;gBAAEI;gBAAWC;gBAAOC;YAAc;QAC9E;QAGJJ,oCAAoCP,SAAS,sBAAsB,OAAO,GAAGQ;YACzE,MAAM,CAACC,WAAWC,OAAOC,cAAc,GAAGH;YAC1C,OAAO,MAAMH,mBAAmB,OAAO,C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AACa;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\";\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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U,GAAG,GAAGZ;YAE/B,MAAMK,QAAQ,MAAMb,QAAQ,GAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAACU,OAAO;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/decorators/isPageModel.js","sources":["../../../src/utils/decorators/isPageModel.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\n/**\n * Keep this until we figure out how to fetch the folders.\n */\nexport const isPageModel = (model: CmsModel): boolean => {\n if (model.modelId === \"pbPage\") {\n return true;\n } else if (model.modelId === \"acoSearchRecord-pbpage\") {\n return true;\n }\n return false;\n};\n"],"names":["isPageModel","model"],"mappings":"AAKO,MAAMA,cAAc,CAACC;IACxB,IAAIA,AAAkB,aAAlBA,MAAM,OAAO,EACb,OAAO;
|
|
1
|
+
{"version":3,"file":"utils/decorators/isPageModel.js","sources":["../../../src/utils/decorators/isPageModel.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\n/**\n * Keep this until we figure out how to fetch the folders.\n */\nexport const isPageModel = (model: CmsModel): boolean => {\n if (model.modelId === \"pbPage\") {\n return true;\n } else if (model.modelId === \"acoSearchRecord-pbpage\") {\n return true;\n }\n return false;\n};\n"],"names":["isPageModel","model"],"mappings":"AAKO,MAAMA,cAAc,CAACC;IACxB,IAAIA,AAAkB,aAAlBA,MAAM,OAAO,EACb,OAAO;IACJ,IAAIA,AAAkB,6BAAlBA,MAAM,OAAO,EACpB,OAAO;IAEX,OAAO;AACX"}
|
package/utils/resolve.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ErrorResponse, Response } from "@webiny/handler-graphql";
|
|
2
|
-
export declare const resolve: (fn: () => Promise<any>) => Promise<Response<any
|
|
2
|
+
export declare const resolve: (fn: () => Promise<any>) => Promise<ErrorResponse | Response<any>>;
|
|
@@ -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/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 {};
|
package/flp/flp.so.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { createStandardEntity, createTable } from "@webiny/db-dynamodb";
|
|
2
|
-
import { WebinyError } from "@webiny/error";
|
|
3
|
-
import { executeWithRetry } from "@webiny/utils";
|
|
4
|
-
class FolderLevelPermissionsStorageOperations {
|
|
5
|
-
constructor({ documentClient }){
|
|
6
|
-
this.table = createTable({
|
|
7
|
-
name: String(process.env.DB_TABLE),
|
|
8
|
-
documentClient
|
|
9
|
-
});
|
|
10
|
-
this.entity = createStandardEntity({
|
|
11
|
-
table: this.table.table,
|
|
12
|
-
name: "ACO.flp"
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
async list({ where: { tenant, type, path_startsWith, parentId } }) {
|
|
16
|
-
try {
|
|
17
|
-
if (parentId) {
|
|
18
|
-
const entries = await this.entity.queryAll({
|
|
19
|
-
partitionKey: `T#${tenant}#FLP`,
|
|
20
|
-
options: {
|
|
21
|
-
index: "GSI2",
|
|
22
|
-
eq: parentId
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return entries.map((entry)=>entry.data);
|
|
26
|
-
}
|
|
27
|
-
if (path_startsWith) {
|
|
28
|
-
const entries = await this.entity.queryAll({
|
|
29
|
-
partitionKey: `T#${tenant}#AT#${type}#FLP`,
|
|
30
|
-
options: {
|
|
31
|
-
index: "GSI1",
|
|
32
|
-
beginsWith: path_startsWith
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return entries.map((entry)=>entry.data);
|
|
36
|
-
}
|
|
37
|
-
throw new WebinyError("Missing required parameters.", "LIST_FLP_MISSING_PARAMETERS", {
|
|
38
|
-
tenant,
|
|
39
|
-
type,
|
|
40
|
-
path_startsWith,
|
|
41
|
-
parentId
|
|
42
|
-
});
|
|
43
|
-
} catch (err) {
|
|
44
|
-
throw WebinyError.from(err, {
|
|
45
|
-
message: "Could not list folder level permissions.",
|
|
46
|
-
code: "LIST_FLP_ERROR"
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async get({ tenant, id }) {
|
|
51
|
-
try {
|
|
52
|
-
const entry = await this.entity.get(this.createKeys({
|
|
53
|
-
tenant,
|
|
54
|
-
id
|
|
55
|
-
}));
|
|
56
|
-
if (!entry) return null;
|
|
57
|
-
return entry.data;
|
|
58
|
-
} catch (err) {
|
|
59
|
-
throw WebinyError.from(err, {
|
|
60
|
-
message: "Could not load folder level permission.",
|
|
61
|
-
code: "GET_FLP_ERROR",
|
|
62
|
-
data: {
|
|
63
|
-
tenant,
|
|
64
|
-
id
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async create({ data }) {
|
|
70
|
-
const keys = {
|
|
71
|
-
...this.createKeys(data),
|
|
72
|
-
...this.createGsiKeys(data)
|
|
73
|
-
};
|
|
74
|
-
try {
|
|
75
|
-
await this.entity.put({
|
|
76
|
-
...keys,
|
|
77
|
-
data
|
|
78
|
-
});
|
|
79
|
-
return data;
|
|
80
|
-
} catch (err) {
|
|
81
|
-
throw WebinyError.from(err, {
|
|
82
|
-
message: "Could not create folder level permission.",
|
|
83
|
-
code: "CREATE_FLP_ERROR",
|
|
84
|
-
data: {
|
|
85
|
-
keys,
|
|
86
|
-
data
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async update({ data: inputData, original }) {
|
|
92
|
-
try {
|
|
93
|
-
const data = {
|
|
94
|
-
...original,
|
|
95
|
-
...inputData
|
|
96
|
-
};
|
|
97
|
-
const keys = {
|
|
98
|
-
...this.createKeys(data),
|
|
99
|
-
...this.createGsiKeys(data)
|
|
100
|
-
};
|
|
101
|
-
await this.entity.put({
|
|
102
|
-
...keys,
|
|
103
|
-
data
|
|
104
|
-
});
|
|
105
|
-
return data;
|
|
106
|
-
} catch (err) {
|
|
107
|
-
throw WebinyError.from(err, {
|
|
108
|
-
message: "Could not update folder level permission.",
|
|
109
|
-
code: "UPDATE_FLP_ERROR",
|
|
110
|
-
data: {
|
|
111
|
-
inputData,
|
|
112
|
-
original
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
async delete({ flp }) {
|
|
118
|
-
const keys = this.createKeys(flp);
|
|
119
|
-
try {
|
|
120
|
-
await this.entity.delete(keys);
|
|
121
|
-
} catch (err) {
|
|
122
|
-
throw WebinyError.from(err, {
|
|
123
|
-
message: "Could not delete folder level permission.",
|
|
124
|
-
code: "DELETE_FLP_ERROR",
|
|
125
|
-
data: {
|
|
126
|
-
keys,
|
|
127
|
-
flp
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async batchUpdate({ items }) {
|
|
133
|
-
try {
|
|
134
|
-
const batch = this.entity.createEntityWriter();
|
|
135
|
-
const updatedItems = [];
|
|
136
|
-
for (const { original, data: inputData } of items){
|
|
137
|
-
const data = {
|
|
138
|
-
...original,
|
|
139
|
-
...inputData
|
|
140
|
-
};
|
|
141
|
-
const keys = {
|
|
142
|
-
...this.createKeys(data),
|
|
143
|
-
...this.createGsiKeys(data)
|
|
144
|
-
};
|
|
145
|
-
batch.put({
|
|
146
|
-
...keys,
|
|
147
|
-
data
|
|
148
|
-
});
|
|
149
|
-
updatedItems.push(data);
|
|
150
|
-
}
|
|
151
|
-
await executeWithRetry(async ()=>await batch.execute());
|
|
152
|
-
return updatedItems;
|
|
153
|
-
} catch (err) {
|
|
154
|
-
throw WebinyError.from(err, {
|
|
155
|
-
message: "Could not batch update folder level permissions.",
|
|
156
|
-
code: "BATCH_UPDATE_FLP_ERROR",
|
|
157
|
-
data: {
|
|
158
|
-
items
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
createKeys({ id, tenant }) {
|
|
164
|
-
return {
|
|
165
|
-
PK: `T#${tenant}#FLP#${id}`,
|
|
166
|
-
SK: "A",
|
|
167
|
-
TYPE: "aco.flp"
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
createGsiKeys({ tenant, type, path, parentId }) {
|
|
171
|
-
return {
|
|
172
|
-
GSI1_PK: `T#${tenant}#AT#${type}#FLP`,
|
|
173
|
-
GSI1_SK: path,
|
|
174
|
-
GSI2_PK: `T#${tenant}#FLP`,
|
|
175
|
-
GSI2_SK: parentId,
|
|
176
|
-
GSI_TENANT: tenant
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
const createFlpOperations = (params)=>new FolderLevelPermissionsStorageOperations(params);
|
|
181
|
-
export { createFlpOperations };
|
|
182
|
-
|
|
183
|
-
//# sourceMappingURL=flp.so.js.map
|