@webiny/api-headless-cms-aco 0.0.0-unstable.5387e5f7c8 → 0.0.0-unstable.676006d08e

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/AcoHcmsFeature.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { SetLocationOnEntryRestoreFeature } from "./features/SetLocationOnEntryRestore/index.js";
3
+ import { ScheduleEntryFolderGuardFeature } from "./features/ScheduleEntryFolderGuard/index.js";
4
+ import { CmsFolderPermissions } from "./features/CmsFolderPermissions/CmsFolderPermissions.js";
3
5
  const AcoHcmsFeature = createFeature({
4
6
  name: "AcoHcms",
5
7
  register (container) {
6
8
  SetLocationOnEntryRestoreFeature.register(container);
9
+ ScheduleEntryFolderGuardFeature.register(container);
10
+ container.register(CmsFolderPermissions);
7
11
  }
8
12
  });
9
13
  export { AcoHcmsFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"AcoHcmsFeature.js","sources":["../src/AcoHcmsFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SetLocationOnEntryRestoreFeature } from \"~/features/SetLocationOnEntryRestore/index.js\";\n\nexport const AcoHcmsFeature = createFeature({\n name: \"AcoHcms\",\n register(container) {\n SetLocationOnEntryRestoreFeature.register(container);\n }\n});\n"],"names":["AcoHcmsFeature","createFeature","container","SetLocationOnEntryRestoreFeature"],"mappings":";;AAGO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAS;QACdC,iCAAiC,QAAQ,CAACD;IAC9C;AACJ"}
1
+ {"version":3,"file":"AcoHcmsFeature.js","sources":["../src/AcoHcmsFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SetLocationOnEntryRestoreFeature } from \"~/features/SetLocationOnEntryRestore/index.js\";\nimport { ScheduleEntryFolderGuardFeature } from \"~/features/ScheduleEntryFolderGuard/index.js\";\nimport { CmsFolderPermissions } from \"~/features/CmsFolderPermissions/CmsFolderPermissions.js\";\n\nexport const AcoHcmsFeature = createFeature({\n name: \"AcoHcms\",\n register(container) {\n SetLocationOnEntryRestoreFeature.register(container);\n ScheduleEntryFolderGuardFeature.register(container);\n container.register(CmsFolderPermissions);\n }\n});\n"],"names":["AcoHcmsFeature","createFeature","container","SetLocationOnEntryRestoreFeature","ScheduleEntryFolderGuardFeature","CmsFolderPermissions"],"mappings":";;;;AAKO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAS;QACdC,iCAAiC,QAAQ,CAACD;QAC1CE,gCAAgC,QAAQ,CAACF;QACzCA,UAAU,QAAQ,CAACG;IACvB;AACJ"}
@@ -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"}
@@ -0,0 +1,11 @@
1
+ import { ScheduleEntryGuard } from "@webiny/api-headless-cms-scheduler/exports/api/cms/scheduler.js";
2
+ import { FolderLevelPermissions } from "@webiny/api-aco/features/flp/FolderLevelPermissions/index.js";
3
+ declare class ScheduleEntryFolderGuardImpl implements ScheduleEntryGuard.Interface {
4
+ private flp;
5
+ constructor(flp: FolderLevelPermissions.Interface);
6
+ canSchedule({ entry }: ScheduleEntryGuard.Params): Promise<boolean>;
7
+ }
8
+ export declare const ScheduleEntryFolderGuard: typeof ScheduleEntryFolderGuardImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms-scheduler/features/ScheduleEntryGuard/abstractions").IScheduleEntryGuard>;
10
+ };
11
+ export {};
@@ -0,0 +1,21 @@
1
+ import { ScheduleEntryGuard } from "@webiny/api-headless-cms-scheduler/exports/api/cms/scheduler.js";
2
+ import { FolderLevelPermissions } from "@webiny/api-aco/features/flp/FolderLevelPermissions/index.js";
3
+ import { canAccessEntryFolder } from "@webiny/api-aco/features/cms/decorators/canAccessEntryFolder.js";
4
+ class ScheduleEntryFolderGuardImpl {
5
+ constructor(flp){
6
+ this.flp = flp;
7
+ }
8
+ async canSchedule({ entry }) {
9
+ if (!this.flp.canUseFolderLevelPermissions()) return true;
10
+ return canAccessEntryFolder(this.flp, entry.location?.folderId, "w");
11
+ }
12
+ }
13
+ const ScheduleEntryFolderGuard = ScheduleEntryGuard.createImplementation({
14
+ implementation: ScheduleEntryFolderGuardImpl,
15
+ dependencies: [
16
+ FolderLevelPermissions
17
+ ]
18
+ });
19
+ export { ScheduleEntryFolderGuard };
20
+
21
+ //# sourceMappingURL=ScheduleEntryFolderGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.js","sources":["../../../src/features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.ts"],"sourcesContent":["import { ScheduleEntryGuard } from \"@webiny/api-headless-cms-scheduler/exports/api/cms/scheduler.js\";\nimport { FolderLevelPermissions } from \"@webiny/api-aco/features/flp/FolderLevelPermissions/index.js\";\nimport { canAccessEntryFolder } from \"@webiny/api-aco/features/cms/decorators/canAccessEntryFolder.js\";\n\nclass ScheduleEntryFolderGuardImpl implements ScheduleEntryGuard.Interface {\n public constructor(private flp: FolderLevelPermissions.Interface) {}\n\n public async canSchedule({ entry }: ScheduleEntryGuard.Params): Promise<boolean> {\n if (!this.flp.canUseFolderLevelPermissions()) {\n return true;\n }\n\n // Scheduling a publish or unpublish changes the entry later without authorization,\n // so the folder must allow writing now, same as publishing directly.\n return canAccessEntryFolder(this.flp, entry.location?.folderId, \"w\");\n }\n}\n\nexport const ScheduleEntryFolderGuard = ScheduleEntryGuard.createImplementation({\n implementation: ScheduleEntryFolderGuardImpl,\n dependencies: [FolderLevelPermissions]\n});\n"],"names":["ScheduleEntryFolderGuardImpl","flp","entry","canAccessEntryFolder","ScheduleEntryFolderGuard","ScheduleEntryGuard","FolderLevelPermissions"],"mappings":";;;AAIA,MAAMA;IACF,YAA2BC,GAAqC,CAAE;aAAvCA,GAAG,GAAHA;IAAwC;IAEnE,MAAa,YAAY,EAAEC,KAAK,EAA6B,EAAoB;QAC7E,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,4BAA4B,IACtC,OAAO;QAKX,OAAOC,qBAAqB,IAAI,CAAC,GAAG,EAAED,MAAM,QAAQ,EAAE,UAAU;IACpE;AACJ;AAEO,MAAME,2BAA2BC,mBAAmB,oBAAoB,CAAC;IAC5E,gBAAgBL;IAChB,cAAc;QAACM;KAAuB;AAC1C"}
@@ -0,0 +1,4 @@
1
+ export declare const ScheduleEntryFolderGuardFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { ScheduleEntryFolderGuard } from "./ScheduleEntryFolderGuard.js";
3
+ const ScheduleEntryFolderGuardFeature = createFeature({
4
+ name: "ScheduleEntryFolderGuard",
5
+ register (container) {
6
+ container.register(ScheduleEntryFolderGuard);
7
+ }
8
+ });
9
+ export { ScheduleEntryFolderGuardFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/ScheduleEntryFolderGuard/feature.js","sources":["../../../src/features/ScheduleEntryFolderGuard/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ScheduleEntryFolderGuard } from \"./ScheduleEntryFolderGuard.js\";\n\nexport const ScheduleEntryFolderGuardFeature = createFeature({\n name: \"ScheduleEntryFolderGuard\",\n register(container) {\n container.register(ScheduleEntryFolderGuard);\n }\n});\n"],"names":["ScheduleEntryFolderGuardFeature","createFeature","container","ScheduleEntryFolderGuard"],"mappings":";;AAGO,MAAMA,kCAAkCC,cAAc;IACzD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -0,0 +1 @@
1
+ export { ScheduleEntryFolderGuardFeature } from "./feature.js";
@@ -0,0 +1 @@
1
+ export { ScheduleEntryFolderGuardFeature } from "./feature.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-aco",
3
- "version": "0.0.0-unstable.5387e5f7c8",
3
+ "version": "0.0.0-unstable.676006d08e",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -21,26 +21,27 @@
21
21
  "access": "public"
22
22
  },
23
23
  "devDependencies": {
24
- "@webiny/api": "0.0.0-unstable.5387e5f7c8",
25
- "@webiny/api-core": "0.0.0-unstable.5387e5f7c8",
26
- "@webiny/api-core-testing": "0.0.0-unstable.5387e5f7c8",
27
- "@webiny/api-graphql": "0.0.0-unstable.5387e5f7c8",
28
- "@webiny/api-websockets": "0.0.0-unstable.5387e5f7c8",
29
- "@webiny/build-tools": "0.0.0-unstable.5387e5f7c8",
24
+ "@webiny/api": "0.0.0-unstable.676006d08e",
25
+ "@webiny/api-core": "0.0.0-unstable.676006d08e",
26
+ "@webiny/api-core-testing": "0.0.0-unstable.676006d08e",
27
+ "@webiny/api-graphql": "0.0.0-unstable.676006d08e",
28
+ "@webiny/api-kernel-core": "0.0.0-unstable.676006d08e",
29
+ "@webiny/api-scheduler": "0.0.0-unstable.676006d08e",
30
+ "@webiny/build-tools": "0.0.0-unstable.676006d08e",
30
31
  "@webiny/di": "2.0.0",
31
- "@webiny/event-handler-core": "0.0.0-unstable.5387e5f7c8",
32
- "@webiny/plugins": "0.0.0-unstable.5387e5f7c8",
33
- "@webiny/wcp": "0.0.0-unstable.5387e5f7c8",
34
- "graphql": "16.14.2",
32
+ "@webiny/plugins": "0.0.0-unstable.676006d08e",
33
+ "@webiny/wcp": "0.0.0-unstable.676006d08e",
34
+ "graphql": "16.15.0",
35
35
  "typescript": "7.0.2"
36
36
  },
37
37
  "dependencies": {
38
- "@webiny/api-aco": "0.0.0-unstable.5387e5f7c8",
39
- "@webiny/api-graphql": "0.0.0-unstable.5387e5f7c8",
40
- "@webiny/api-headless-cms": "0.0.0-unstable.5387e5f7c8",
41
- "@webiny/feature": "0.0.0-unstable.5387e5f7c8",
42
- "@webiny/handler": "0.0.0-unstable.5387e5f7c8",
43
- "vitest": "4.1.11"
38
+ "@webiny/api-aco": "0.0.0-unstable.676006d08e",
39
+ "@webiny/api-graphql": "0.0.0-unstable.676006d08e",
40
+ "@webiny/api-headless-cms": "0.0.0-unstable.676006d08e",
41
+ "@webiny/api-headless-cms-scheduler": "0.0.0-unstable.676006d08e",
42
+ "@webiny/feature": "0.0.0-unstable.676006d08e",
43
+ "@webiny/handler": "0.0.0-unstable.676006d08e",
44
+ "vitest": "5.1.1"
44
45
  },
45
46
  "webiny": {
46
47
  "publishFrom": "dist"