@webiny/api-aco 6.5.2-beta.4 → 6.5.2-beta.6
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.
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { GetUniqueFieldValuesUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues/abstractions.js";
|
|
2
2
|
import { createDecorator } from "@webiny/feature/api";
|
|
3
3
|
import { FolderLevelPermissions } from "../../flp/FolderLevelPermissions/index.js";
|
|
4
|
+
import { FM_FILE_TYPE } from "../../../constants.js";
|
|
5
|
+
const FM_FILE_MODEL_IDS = [
|
|
6
|
+
"wbyFmFile",
|
|
7
|
+
"fmFile"
|
|
8
|
+
];
|
|
9
|
+
const getFolderType = (model)=>{
|
|
10
|
+
if (FM_FILE_MODEL_IDS.includes(model.modelId)) return FM_FILE_TYPE;
|
|
11
|
+
return `cms:${model.modelId}`;
|
|
12
|
+
};
|
|
4
13
|
class GetUniqueFieldValuesWithFlpDecoratorImpl {
|
|
5
14
|
constructor(folderLevelPermissions, decoratee){
|
|
6
15
|
this.folderLevelPermissions = folderLevelPermissions;
|
|
@@ -29,7 +38,7 @@ class GetUniqueFieldValuesWithFlpDecoratorImpl {
|
|
|
29
38
|
async listDeniedFolderIds(model) {
|
|
30
39
|
const flps = await this.folderLevelPermissions.listFolderLevelPermissions({
|
|
31
40
|
where: {
|
|
32
|
-
type:
|
|
41
|
+
type: getFolderType(model)
|
|
33
42
|
}
|
|
34
43
|
});
|
|
35
44
|
const denied = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/cms/decorators/GetUniqueFieldValuesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/GetUniqueFieldValuesWithFlpDecorator.ts"],"sourcesContent":["import { GetUniqueFieldValuesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues/abstractions.js\";\nimport { createDecorator } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\n\n/**\n * Security: unique values are aggregated in storage, so entries cannot be filtered afterwards.\n * Instead, entries located in folders the identity cannot read are excluded in the query.\n */\nclass GetUniqueFieldValuesWithFlpDecoratorImpl implements GetUniqueFieldValuesUseCase.Interface {\n constructor(\n private folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: GetUniqueFieldValuesUseCase.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n params: GetUniqueFieldValuesUseCase.Params\n ): GetUniqueFieldValuesUseCase.Return {\n if (!this.folderLevelPermissions.canUseFolderLevelPermissions()) {\n return this.decoratee.execute(model, params);\n }\n\n const deniedFolderIds = await this.listDeniedFolderIds(model);\n if (!deniedFolderIds.length) {\n return this.decoratee.execute(model, params);\n }\n\n const { AND, ...where } = params.where;\n return this.decoratee.execute(model, {\n ...params,\n where: {\n ...where,\n AND: [\n ...(Array.isArray(AND) ? AND : []),\n { wbyAco_location: { folderId_not_in: deniedFolderIds } }\n ]\n }\n });\n }\n\n private async listDeniedFolderIds(model: CmsModel): Promise<string[]> {\n const flps = await this.folderLevelPermissions.listFolderLevelPermissions({\n where: { type:
|
|
1
|
+
{"version":3,"file":"features/cms/decorators/GetUniqueFieldValuesWithFlpDecorator.js","sources":["../../../../src/features/cms/decorators/GetUniqueFieldValuesWithFlpDecorator.ts"],"sourcesContent":["import { GetUniqueFieldValuesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetUniqueFieldValues/abstractions.js\";\nimport { createDecorator } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { FolderLevelPermissions } from \"~/features/flp/FolderLevelPermissions/index.js\";\nimport { FM_FILE_TYPE } from \"~/constants.js\";\n\n/**\n * File Manager files are stored in the File Manager file model, but their folders use the \"FmFile\" type.\n */\nconst FM_FILE_MODEL_IDS = [\"wbyFmFile\", \"fmFile\"];\n\nconst getFolderType = (model: CmsModel): string => {\n if (FM_FILE_MODEL_IDS.includes(model.modelId)) {\n return FM_FILE_TYPE;\n }\n return `cms:${model.modelId}`;\n};\n\n/**\n * Security: unique values are aggregated in storage, so entries cannot be filtered afterwards.\n * Instead, entries located in folders the identity cannot read are excluded in the query.\n */\nclass GetUniqueFieldValuesWithFlpDecoratorImpl implements GetUniqueFieldValuesUseCase.Interface {\n constructor(\n private folderLevelPermissions: FolderLevelPermissions.Interface,\n private decoratee: GetUniqueFieldValuesUseCase.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n params: GetUniqueFieldValuesUseCase.Params\n ): GetUniqueFieldValuesUseCase.Return {\n if (!this.folderLevelPermissions.canUseFolderLevelPermissions()) {\n return this.decoratee.execute(model, params);\n }\n\n const deniedFolderIds = await this.listDeniedFolderIds(model);\n if (!deniedFolderIds.length) {\n return this.decoratee.execute(model, params);\n }\n\n const { AND, ...where } = params.where;\n return this.decoratee.execute(model, {\n ...params,\n where: {\n ...where,\n AND: [\n ...(Array.isArray(AND) ? AND : []),\n { wbyAco_location: { folderId_not_in: deniedFolderIds } }\n ]\n }\n });\n }\n\n private async listDeniedFolderIds(model: CmsModel): Promise<string[]> {\n const flps = await this.folderLevelPermissions.listFolderLevelPermissions({\n where: { type: getFolderType(model) }\n });\n\n const denied: string[] = [];\n for (const flp of flps) {\n const canRead = await this.folderLevelPermissions.canAccessFolderContent({\n permissions: flp.permissions,\n rwd: \"r\"\n });\n if (!canRead) {\n denied.push(flp.id);\n }\n }\n return denied;\n }\n}\n\nexport const GetUniqueFieldValuesWithFlpDecorator = createDecorator({\n abstraction: GetUniqueFieldValuesUseCase,\n decorator: GetUniqueFieldValuesWithFlpDecoratorImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["FM_FILE_MODEL_IDS","getFolderType","model","FM_FILE_TYPE","GetUniqueFieldValuesWithFlpDecoratorImpl","folderLevelPermissions","decoratee","params","deniedFolderIds","AND","where","Array","flps","denied","flp","canRead","GetUniqueFieldValuesWithFlpDecorator","createDecorator","GetUniqueFieldValuesUseCase","FolderLevelPermissions"],"mappings":";;;;AASA,MAAMA,oBAAoB;IAAC;IAAa;CAAS;AAEjD,MAAMC,gBAAgB,CAACC;IACnB,IAAIF,kBAAkB,QAAQ,CAACE,MAAM,OAAO,GACxC,OAAOC;IAEX,OAAO,CAAC,IAAI,EAAED,MAAM,OAAO,EAAE;AACjC;AAMA,MAAME;IACF,YACYC,sBAAwD,EACxDC,SAAgD,CAC1D;aAFUD,sBAAsB,GAAtBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QACFJ,KAAe,EACfK,MAA0C,EACR;QAClC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,4BAA4B,IACzD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACL,OAAOK;QAGzC,MAAMC,kBAAkB,MAAM,IAAI,CAAC,mBAAmB,CAACN;QACvD,IAAI,CAACM,gBAAgB,MAAM,EACvB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACN,OAAOK;QAGzC,MAAM,EAAEE,GAAG,EAAE,GAAGC,OAAO,GAAGH,OAAO,KAAK;QACtC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACL,OAAO;YACjC,GAAGK,MAAM;YACT,OAAO;gBACH,GAAGG,KAAK;gBACR,KAAK;uBACGC,MAAM,OAAO,CAACF,OAAOA,MAAM,EAAE;oBACjC;wBAAE,iBAAiB;4BAAE,iBAAiBD;wBAAgB;oBAAE;iBAC3D;YACL;QACJ;IACJ;IAEA,MAAc,oBAAoBN,KAAe,EAAqB;QAClE,MAAMU,OAAO,MAAM,IAAI,CAAC,sBAAsB,CAAC,0BAA0B,CAAC;YACtE,OAAO;gBAAE,MAAMX,cAAcC;YAAO;QACxC;QAEA,MAAMW,SAAmB,EAAE;QAC3B,KAAK,MAAMC,OAAOF,KAAM;YACpB,MAAMG,UAAU,MAAM,IAAI,CAAC,sBAAsB,CAAC,sBAAsB,CAAC;gBACrE,aAAaD,IAAI,WAAW;gBAC5B,KAAK;YACT;YACA,IAAI,CAACC,SACDF,OAAO,IAAI,CAACC,IAAI,EAAE;QAE1B;QACA,OAAOD;IACX;AACJ;AAEO,MAAMG,uCAAuCC,gBAAgB;IAChE,aAAaC;IACb,WAAWd;IACX,cAAc;QAACe;KAAuB;AAC1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco",
|
|
3
|
-
"version": "6.5.2-beta.
|
|
3
|
+
"version": "6.5.2-beta.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -21,28 +21,28 @@
|
|
|
21
21
|
".": "./index.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webiny/api": "6.5.2-beta.
|
|
25
|
-
"@webiny/api-core": "6.5.2-beta.
|
|
26
|
-
"@webiny/api-headless-cms": "6.5.2-beta.
|
|
27
|
-
"@webiny/background-tasks": "6.5.2-beta.
|
|
24
|
+
"@webiny/api": "6.5.2-beta.6",
|
|
25
|
+
"@webiny/api-core": "6.5.2-beta.6",
|
|
26
|
+
"@webiny/api-headless-cms": "6.5.2-beta.6",
|
|
27
|
+
"@webiny/background-tasks": "6.5.2-beta.6",
|
|
28
28
|
"@webiny/di": "1.1.0",
|
|
29
|
-
"@webiny/error": "6.5.2-beta.
|
|
30
|
-
"@webiny/feature": "6.5.2-beta.
|
|
31
|
-
"@webiny/handler": "6.5.2-beta.
|
|
32
|
-
"@webiny/handler-graphql": "6.5.2-beta.
|
|
33
|
-
"@webiny/shared-aco": "6.5.2-beta.
|
|
34
|
-
"@webiny/utils": "6.5.2-beta.
|
|
35
|
-
"@webiny/validation": "6.5.2-beta.
|
|
29
|
+
"@webiny/error": "6.5.2-beta.6",
|
|
30
|
+
"@webiny/feature": "6.5.2-beta.6",
|
|
31
|
+
"@webiny/handler": "6.5.2-beta.6",
|
|
32
|
+
"@webiny/handler-graphql": "6.5.2-beta.6",
|
|
33
|
+
"@webiny/shared-aco": "6.5.2-beta.6",
|
|
34
|
+
"@webiny/utils": "6.5.2-beta.6",
|
|
35
|
+
"@webiny/validation": "6.5.2-beta.6",
|
|
36
36
|
"lodash": "4.18.1",
|
|
37
37
|
"zod": "4.6.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@webiny/api-file-manager": "6.5.2-beta.
|
|
41
|
-
"@webiny/build-tools": "6.5.2-beta.
|
|
42
|
-
"@webiny/handler-aws": "6.5.2-beta.
|
|
43
|
-
"@webiny/plugins": "6.5.2-beta.
|
|
44
|
-
"@webiny/project-utils": "6.5.2-beta.
|
|
45
|
-
"@webiny/wcp": "6.5.2-beta.
|
|
40
|
+
"@webiny/api-file-manager": "6.5.2-beta.6",
|
|
41
|
+
"@webiny/build-tools": "6.5.2-beta.6",
|
|
42
|
+
"@webiny/handler-aws": "6.5.2-beta.6",
|
|
43
|
+
"@webiny/plugins": "6.5.2-beta.6",
|
|
44
|
+
"@webiny/project-utils": "6.5.2-beta.6",
|
|
45
|
+
"@webiny/wcp": "6.5.2-beta.6",
|
|
46
46
|
"graphql": "16.15.0",
|
|
47
47
|
"rimraf": "6.1.4",
|
|
48
48
|
"typescript": "7.0.2",
|