@webiny/api-headless-cms-aco 6.4.12-beta.1 → 6.4.12-beta.10

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.
@@ -0,0 +1,17 @@
1
+ import { FolderTypePermissions } from "@webiny/api-aco/features/folder/FolderTypePermissions/index.js";
2
+ import { AccessControl } from "@webiny/api-headless-cms/features/shared/abstractions.js";
3
+ import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
4
+ /** Headless CMS folders ("cms:<modelId>") require entry access on that model. */
5
+ declare class CmsFolderPermissionsImpl implements FolderTypePermissions.Interface {
6
+ private accessControl;
7
+ private getModel;
8
+ constructor(accessControl: AccessControl.Interface, getModel: GetModelUseCase.Interface);
9
+ canHandle(type: string): boolean;
10
+ canRead(type: string): Promise<boolean>;
11
+ canWrite(type: string): Promise<boolean>;
12
+ private canAccessEntries;
13
+ }
14
+ export declare const CmsFolderPermissions: typeof CmsFolderPermissionsImpl & {
15
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-aco/features/folder/FolderTypePermissions/abstractions").IFolderTypePermissions>;
16
+ };
17
+ export {};
@@ -0,0 +1,37 @@
1
+ import { FolderTypePermissions } from "@webiny/api-aco/features/folder/FolderTypePermissions/index.js";
2
+ import { AccessControl } from "@webiny/api-headless-cms/features/shared/abstractions.js";
3
+ import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
4
+ const PREFIX = "cms:";
5
+ class CmsFolderPermissionsImpl {
6
+ constructor(accessControl, getModel){
7
+ this.accessControl = accessControl;
8
+ this.getModel = getModel;
9
+ }
10
+ canHandle(type) {
11
+ return type.startsWith(PREFIX);
12
+ }
13
+ canRead(type) {
14
+ return this.canAccessEntries(type, "r");
15
+ }
16
+ canWrite(type) {
17
+ return this.canAccessEntries(type, "w");
18
+ }
19
+ async canAccessEntries(type, rwd) {
20
+ const model = await this.getModel.execute(type.slice(PREFIX.length));
21
+ if (model.isFail()) return false;
22
+ return this.accessControl.canAccessEntry({
23
+ model: model.value,
24
+ rwd
25
+ });
26
+ }
27
+ }
28
+ const CmsFolderPermissions = FolderTypePermissions.createImplementation({
29
+ implementation: CmsFolderPermissionsImpl,
30
+ dependencies: [
31
+ AccessControl,
32
+ GetModelUseCase
33
+ ]
34
+ });
35
+ export { CmsFolderPermissions };
36
+
37
+ //# sourceMappingURL=CmsFolderPermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CmsFolderPermissions/CmsFolderPermissions.js","sources":["../../../src/features/CmsFolderPermissions/CmsFolderPermissions.ts"],"sourcesContent":["import { FolderTypePermissions } from \"@webiny/api-aco/features/folder/FolderTypePermissions/index.js\";\nimport { AccessControl } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\n\nconst PREFIX = \"cms:\";\n\n/** Headless CMS folders (\"cms:<modelId>\") require entry access on that model. */\nclass CmsFolderPermissionsImpl implements FolderTypePermissions.Interface {\n constructor(\n private accessControl: AccessControl.Interface,\n private getModel: GetModelUseCase.Interface\n ) {}\n\n canHandle(type: string): boolean {\n return type.startsWith(PREFIX);\n }\n\n canRead(type: string): Promise<boolean> {\n return this.canAccessEntries(type, \"r\");\n }\n\n canWrite(type: string): Promise<boolean> {\n return this.canAccessEntries(type, \"w\");\n }\n\n private async canAccessEntries(type: string, rwd: \"r\" | \"w\"): Promise<boolean> {\n const model = await this.getModel.execute(type.slice(PREFIX.length));\n if (model.isFail()) {\n return false;\n }\n return this.accessControl.canAccessEntry({ model: model.value, rwd });\n }\n}\n\nexport const CmsFolderPermissions = FolderTypePermissions.createImplementation({\n implementation: CmsFolderPermissionsImpl,\n dependencies: [AccessControl, GetModelUseCase]\n});\n"],"names":["PREFIX","CmsFolderPermissionsImpl","accessControl","getModel","type","rwd","model","CmsFolderPermissions","FolderTypePermissions","AccessControl","GetModelUseCase"],"mappings":";;;AAIA,MAAMA,SAAS;AAGf,MAAMC;IACF,YACYC,aAAsC,EACtCC,QAAmC,CAC7C;aAFUD,aAAa,GAAbA;aACAC,QAAQ,GAARA;IACT;IAEH,UAAUC,IAAY,EAAW;QAC7B,OAAOA,KAAK,UAAU,CAACJ;IAC3B;IAEA,QAAQI,IAAY,EAAoB;QACpC,OAAO,IAAI,CAAC,gBAAgB,CAACA,MAAM;IACvC;IAEA,SAASA,IAAY,EAAoB;QACrC,OAAO,IAAI,CAAC,gBAAgB,CAACA,MAAM;IACvC;IAEA,MAAc,iBAAiBA,IAAY,EAAEC,GAAc,EAAoB;QAC3E,MAAMC,QAAQ,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACF,KAAK,KAAK,CAACJ,OAAO,MAAM;QAClE,IAAIM,MAAM,MAAM,IACZ,OAAO;QAEX,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAE,OAAOA,MAAM,KAAK;YAAED;QAAI;IACvE;AACJ;AAEO,MAAME,uBAAuBC,sBAAsB,oBAAoB,CAAC;IAC3E,gBAAgBP;IAChB,cAAc;QAACQ;QAAeC;KAAgB;AAClD"}
package/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { ContextPlugin } from "@webiny/api";
2
+ import { CmsFolderPermissions } from "./features/CmsFolderPermissions/CmsFolderPermissions.js";
2
3
  import { SetLocationOnEntryRestoreFeature } from "./features/SetLocationOnEntryRestore/index.js";
3
4
  export * from "./plugins/index.js";
4
5
  const createAcoHcmsContext = ()=>{
5
6
  const plugin = new ContextPlugin((context)=>{
6
7
  SetLocationOnEntryRestoreFeature.register(context.container);
8
+ context.container.register(CmsFolderPermissions);
7
9
  });
8
10
  plugin.name = "hcms-aco.createContext";
9
11
  return plugin;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { HcmsAcoContext } from \"~/types.js\";\nimport { SetLocationOnEntryRestoreFeature } from \"~/features/SetLocationOnEntryRestore/index.js\";\n\nexport const createAcoHcmsContext = () => {\n const plugin = new ContextPlugin<HcmsAcoContext>(context => {\n SetLocationOnEntryRestoreFeature.register(context.container);\n });\n\n plugin.name = \"hcms-aco.createContext\";\n\n return plugin;\n};\n\nexport * from \"./plugins/index.js\";\n"],"names":["createAcoHcmsContext","plugin","ContextPlugin","context","SetLocationOnEntryRestoreFeature"],"mappings":";;;AAIO,MAAMA,uBAAuB;IAChC,MAAMC,SAAS,IAAIC,cAA8BC,CAAAA;QAC7CC,iCAAiC,QAAQ,CAACD,QAAQ,SAAS;IAC/D;IAEAF,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { CmsFolderPermissions } from \"~/features/CmsFolderPermissions/CmsFolderPermissions.js\";\nimport type { HcmsAcoContext } from \"~/types.js\";\nimport { SetLocationOnEntryRestoreFeature } from \"~/features/SetLocationOnEntryRestore/index.js\";\n\nexport const createAcoHcmsContext = () => {\n const plugin = new ContextPlugin<HcmsAcoContext>(context => {\n SetLocationOnEntryRestoreFeature.register(context.container);\n context.container.register(CmsFolderPermissions);\n });\n\n plugin.name = \"hcms-aco.createContext\";\n\n return plugin;\n};\n\nexport * from \"./plugins/index.js\";\n"],"names":["createAcoHcmsContext","plugin","ContextPlugin","context","SetLocationOnEntryRestoreFeature","CmsFolderPermissions"],"mappings":";;;;AAKO,MAAMA,uBAAuB;IAChC,MAAMC,SAAS,IAAIC,cAA8BC,CAAAA;QAC7CC,iCAAiC,QAAQ,CAACD,QAAQ,SAAS;QAC3DA,QAAQ,SAAS,CAAC,QAAQ,CAACE;IAC/B;IAEAJ,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-aco",
3
- "version": "6.4.12-beta.1",
3
+ "version": "6.4.12-beta.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -21,23 +21,23 @@
21
21
  "access": "public"
22
22
  },
23
23
  "devDependencies": {
24
- "@webiny/api-core": "6.4.12-beta.1",
25
- "@webiny/build-tools": "6.4.12-beta.1",
26
- "@webiny/handler-aws": "6.4.12-beta.1",
27
- "@webiny/handler-graphql": "6.4.12-beta.1",
28
- "@webiny/plugins": "6.4.12-beta.1",
29
- "@webiny/project-utils": "6.4.12-beta.1",
30
- "@webiny/wcp": "6.4.12-beta.1",
31
- "graphql": "16.14.2",
24
+ "@webiny/api-core": "6.4.12-beta.10",
25
+ "@webiny/build-tools": "6.4.12-beta.10",
26
+ "@webiny/handler-aws": "6.4.12-beta.10",
27
+ "@webiny/handler-graphql": "6.4.12-beta.10",
28
+ "@webiny/plugins": "6.4.12-beta.10",
29
+ "@webiny/project-utils": "6.4.12-beta.10",
30
+ "@webiny/wcp": "6.4.12-beta.10",
31
+ "graphql": "16.15.0",
32
32
  "typescript": "6.0.3"
33
33
  },
34
34
  "dependencies": {
35
- "@webiny/api": "6.4.12-beta.1",
36
- "@webiny/api-aco": "6.4.12-beta.1",
37
- "@webiny/api-headless-cms": "6.4.12-beta.1",
38
- "@webiny/feature": "6.4.12-beta.1",
39
- "@webiny/handler": "6.4.12-beta.1",
40
- "vitest": "5.0.1"
35
+ "@webiny/api": "6.4.12-beta.10",
36
+ "@webiny/api-aco": "6.4.12-beta.10",
37
+ "@webiny/api-headless-cms": "6.4.12-beta.10",
38
+ "@webiny/feature": "6.4.12-beta.10",
39
+ "@webiny/handler": "6.4.12-beta.10",
40
+ "vitest": "5.1.0"
41
41
  },
42
42
  "webiny": {
43
43
  "publishFrom": "dist"