@webiny/api-headless-cms-aco 0.0.0-unstable.e0bfc55d5a β†’ 0.0.0-unstable.e1999482d0

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.
Files changed (41) hide show
  1. package/AcoHcmsFeature.d.ts +4 -0
  2. package/AcoHcmsFeature.js +15 -0
  3. package/AcoHcmsFeature.js.map +1 -0
  4. package/README.md +6 -13
  5. package/features/CmsFolderPermissions/CmsFolderPermissions.d.ts +17 -0
  6. package/features/CmsFolderPermissions/CmsFolderPermissions.js +37 -0
  7. package/features/CmsFolderPermissions/CmsFolderPermissions.js.map +1 -0
  8. package/features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.d.ts +11 -0
  9. package/features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.js +21 -0
  10. package/features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.js.map +1 -0
  11. package/features/ScheduleEntryFolderGuard/feature.d.ts +4 -0
  12. package/features/ScheduleEntryFolderGuard/feature.js +11 -0
  13. package/features/ScheduleEntryFolderGuard/feature.js.map +1 -0
  14. package/features/ScheduleEntryFolderGuard/index.d.ts +1 -0
  15. package/features/ScheduleEntryFolderGuard/index.js +1 -0
  16. package/features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.d.ts +17 -0
  17. package/features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.js +33 -0
  18. package/features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.js.map +1 -0
  19. package/features/SetLocationOnEntryRestore/feature.d.ts +4 -0
  20. package/features/SetLocationOnEntryRestore/feature.js +11 -0
  21. package/features/SetLocationOnEntryRestore/feature.js.map +1 -0
  22. package/features/SetLocationOnEntryRestore/index.d.ts +1 -0
  23. package/features/SetLocationOnEntryRestore/index.js +1 -0
  24. package/index.d.ts +2 -4
  25. package/index.js +2 -37
  26. package/package.json +29 -26
  27. package/plugins/createCmsFolderModelModifier.js +35 -44
  28. package/plugins/createCmsFolderModelModifier.js.map +1 -1
  29. package/plugins/index.d.ts +1 -1
  30. package/plugins/index.js +1 -18
  31. package/types.d.ts +3 -3
  32. package/types.js +0 -7
  33. package/hooks/entry/index.d.ts +0 -3
  34. package/hooks/entry/index.js +0 -19
  35. package/hooks/entry/index.js.map +0 -1
  36. package/hooks/entry/onEntryBeforeRestoreFromBin.hook.d.ts +0 -2
  37. package/hooks/entry/onEntryBeforeRestoreFromBin.hook.js +0 -47
  38. package/hooks/entry/onEntryBeforeRestoreFromBin.hook.js.map +0 -1
  39. package/index.js.map +0 -1
  40. package/plugins/index.js.map +0 -1
  41. package/types.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ export declare const AcoHcmsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,15 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { SetLocationOnEntryRestoreFeature } from "./features/SetLocationOnEntryRestore/index.js";
3
+ import { ScheduleEntryFolderGuardFeature } from "./features/ScheduleEntryFolderGuard/index.js";
4
+ import { CmsFolderPermissions } from "./features/CmsFolderPermissions/CmsFolderPermissions.js";
5
+ const AcoHcmsFeature = createFeature({
6
+ name: "AcoHcms",
7
+ register (container) {
8
+ SetLocationOnEntryRestoreFeature.register(container);
9
+ ScheduleEntryFolderGuardFeature.register(container);
10
+ container.register(CmsFolderPermissions);
11
+ }
12
+ });
13
+ export { AcoHcmsFeature };
14
+
15
+ //# sourceMappingURL=AcoHcmsFeature.js.map
@@ -0,0 +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\";\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"}
package/README.md CHANGED
@@ -1,18 +1,11 @@
1
1
  # @webiny/api-headless-cms-aco
2
2
 
3
- [![](https://img.shields.io/npm/dw/@webiny/api-headless-cms-aco.svg)](https://www.npmjs.com/package/@webiny/api-headless-cms-aco)
4
- [![](https://img.shields.io/npm/v/@webiny/api-headless-cms-aco.svg)](https://www.npmjs.com/package/@webiny/api-headless-cms-aco)
5
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
7
6
 
8
- ## Install
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
9
8
 
10
- ```
11
- npm install --save @webiny/api-headless-cms-aco
12
- ```
9
+ ---
13
10
 
14
- Or if you prefer yarn:
15
-
16
- ```
17
- yarn add @webiny/api-headless-cms-aco
18
- ```
11
+ _This README file is automatically generated during the publish process._
@@ -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";
@@ -0,0 +1,17 @@
1
+ import { RestoreEntryFromBinRepository } from "@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/index.js";
2
+ import type { CmsEntry, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
3
+ import { GetFolderUseCase } from "@webiny/api-aco/features/folder/GetFolder/abstractions.js";
4
+ /**
5
+ * Restores the entry to ROOT_FOLDER if its original folder no longer exists.
6
+ *
7
+ * This is a repository decorator (not an event handler), so the fallback also applies
8
+ * to models which do not publish entry lifecycle events.
9
+ */
10
+ declare class RestoreEntryFromBinWithFolderFallbackDecoratorImpl implements RestoreEntryFromBinRepository.Interface {
11
+ private getFolderUseCase;
12
+ private decoratee;
13
+ constructor(getFolderUseCase: GetFolderUseCase.Interface, decoratee: RestoreEntryFromBinRepository.Interface);
14
+ execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, entry: CmsEntry<T>): Promise<import("@webiny/feature/api").Result<CmsEntry<T>, import("@webiny/api-headless-cms/domain/contentEntry/errors").EntryPersistenceError>>;
15
+ }
16
+ export declare const RestoreEntryFromBinWithFolderFallbackDecorator: typeof RestoreEntryFromBinWithFolderFallbackDecoratorImpl;
17
+ export {};
@@ -0,0 +1,33 @@
1
+ import { createDecorator } from "@webiny/feature/api";
2
+ import { ROOT_FOLDER } from "@webiny/api-headless-cms/constants.js";
3
+ import { RestoreEntryFromBinRepository } from "@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/index.js";
4
+ import { GetFolderUseCase } from "@webiny/api-aco/features/folder/GetFolder/abstractions.js";
5
+ class RestoreEntryFromBinWithFolderFallbackDecoratorImpl {
6
+ constructor(getFolderUseCase, decoratee){
7
+ this.getFolderUseCase = getFolderUseCase;
8
+ this.decoratee = decoratee;
9
+ }
10
+ async execute(model, entry) {
11
+ const folderId = entry.location?.folderId;
12
+ if (!folderId || folderId === ROOT_FOLDER) return this.decoratee.execute(model, entry);
13
+ const result = await this.getFolderUseCase.execute(folderId);
14
+ if (result.isOk()) return this.decoratee.execute(model, entry);
15
+ return this.decoratee.execute(model, {
16
+ ...entry,
17
+ location: {
18
+ ...entry.location,
19
+ folderId: ROOT_FOLDER
20
+ }
21
+ });
22
+ }
23
+ }
24
+ const RestoreEntryFromBinWithFolderFallbackDecorator = createDecorator({
25
+ abstraction: RestoreEntryFromBinRepository,
26
+ decorator: RestoreEntryFromBinWithFolderFallbackDecoratorImpl,
27
+ dependencies: [
28
+ GetFolderUseCase
29
+ ]
30
+ });
31
+ export { RestoreEntryFromBinWithFolderFallbackDecorator };
32
+
33
+ //# sourceMappingURL=RestoreEntryFromBinWithFolderFallbackDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.js","sources":["../../../src/features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { ROOT_FOLDER } from \"@webiny/api-headless-cms/constants.js\";\nimport { RestoreEntryFromBinRepository } from \"@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/index.js\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetFolderUseCase } from \"@webiny/api-aco/features/folder/GetFolder/abstractions.js\";\n\n/**\n * Restores the entry to ROOT_FOLDER if its original folder no longer exists.\n *\n * This is a repository decorator (not an event handler), so the fallback also applies\n * to models which do not publish entry lifecycle events.\n */\nclass RestoreEntryFromBinWithFolderFallbackDecoratorImpl\n implements RestoreEntryFromBinRepository.Interface\n{\n constructor(\n private getFolderUseCase: GetFolderUseCase.Interface,\n private decoratee: RestoreEntryFromBinRepository.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, entry: CmsEntry<T>) {\n const folderId = entry.location?.folderId;\n\n /**\n * Skip further execution if folderId is falsy or equals ROOT_FOLDER.\n */\n if (!folderId || folderId === ROOT_FOLDER) {\n return this.decoratee.execute<T>(model, entry);\n }\n\n /**\n * Retrieve the folder: if it exists, no additional operations are necessary.\n */\n const result = await this.getFolderUseCase.execute(folderId);\n if (result.isOk()) {\n return this.decoratee.execute<T>(model, entry);\n }\n\n /**\n * If the folder is not found, set ROOT_FOLDER as the location.\n */\n return this.decoratee.execute<T>(model, {\n ...entry,\n location: {\n ...entry.location,\n folderId: ROOT_FOLDER\n }\n });\n }\n}\n\nexport const RestoreEntryFromBinWithFolderFallbackDecorator = createDecorator({\n abstraction: RestoreEntryFromBinRepository,\n decorator: RestoreEntryFromBinWithFolderFallbackDecoratorImpl,\n dependencies: [GetFolderUseCase]\n});\n"],"names":["RestoreEntryFromBinWithFolderFallbackDecoratorImpl","getFolderUseCase","decoratee","model","entry","folderId","ROOT_FOLDER","result","RestoreEntryFromBinWithFolderFallbackDecorator","createDecorator","RestoreEntryFromBinRepository","GetFolderUseCase"],"mappings":";;;;AAYA,MAAMA;IAGF,YACYC,gBAA4C,EAC5CC,SAAkD,CAC5D;aAFUD,gBAAgB,GAAhBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAmDC,KAAe,EAAEC,KAAkB,EAAE;QAC1F,MAAMC,WAAWD,MAAM,QAAQ,EAAE;QAKjC,IAAI,CAACC,YAAYA,aAAaC,aAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIH,OAAOC;QAM5C,MAAMG,SAAS,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAACF;QACnD,IAAIE,OAAO,IAAI,IACX,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAIJ,OAAOC;QAM5C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAID,OAAO;YACpC,GAAGC,KAAK;YACR,UAAU;gBACN,GAAGA,MAAM,QAAQ;gBACjB,UAAUE;YACd;QACJ;IACJ;AACJ;AAEO,MAAME,iDAAiDC,gBAAgB;IAC1E,aAAaC;IACb,WAAWV;IACX,cAAc;QAACW;KAAiB;AACpC"}
@@ -0,0 +1,4 @@
1
+ export declare const SetLocationOnEntryRestoreFeature: {
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 { RestoreEntryFromBinWithFolderFallbackDecorator } from "./RestoreEntryFromBinWithFolderFallbackDecorator.js";
3
+ const SetLocationOnEntryRestoreFeature = createFeature({
4
+ name: "SetLocationOnEntryRestore",
5
+ register (container) {
6
+ container.registerDecorator(RestoreEntryFromBinWithFolderFallbackDecorator);
7
+ }
8
+ });
9
+ export { SetLocationOnEntryRestoreFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SetLocationOnEntryRestore/feature.js","sources":["../../../src/features/SetLocationOnEntryRestore/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { RestoreEntryFromBinWithFolderFallbackDecorator } from \"./RestoreEntryFromBinWithFolderFallbackDecorator.js\";\n\nexport const SetLocationOnEntryRestoreFeature = createFeature({\n name: \"SetLocationOnEntryRestore\",\n register(container) {\n container.registerDecorator(RestoreEntryFromBinWithFolderFallbackDecorator);\n }\n});\n"],"names":["SetLocationOnEntryRestoreFeature","createFeature","container","RestoreEntryFromBinWithFolderFallbackDecorator"],"mappings":";;AAGO,MAAMA,mCAAmCC,cAAc;IAC1D,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,iBAAiB,CAACC;IAChC;AACJ"}
@@ -0,0 +1 @@
1
+ export { SetLocationOnEntryRestoreFeature } from "./feature.js";
@@ -0,0 +1 @@
1
+ export { SetLocationOnEntryRestoreFeature } from "./feature.js";
package/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import type { HcmsAcoContext } from "./types";
3
- export declare const createAcoHcmsContext: () => ContextPlugin<HcmsAcoContext>;
4
- export * from "./plugins";
1
+ export * from "./plugins/index.js";
2
+ export { AcoHcmsFeature } from "./AcoHcmsFeature.js";
package/index.js CHANGED
@@ -1,37 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- createAcoHcmsContext: true
8
- };
9
- exports.createAcoHcmsContext = void 0;
10
- var _api = require("@webiny/api");
11
- var _entry = require("./hooks/entry");
12
- var _plugins = require("./plugins");
13
- Object.keys(_plugins).forEach(function (key) {
14
- if (key === "default" || key === "__esModule") return;
15
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
16
- if (key in exports && exports[key] === _plugins[key]) return;
17
- Object.defineProperty(exports, key, {
18
- enumerable: true,
19
- get: function () {
20
- return _plugins[key];
21
- }
22
- });
23
- });
24
- const createAcoHcmsContext = () => {
25
- const plugin = new _api.ContextPlugin(async context => {
26
- if (!context.aco) {
27
- console.log(`There is no ACO initialized so we will not initialize the HCMS ACO.`);
28
- return;
29
- }
30
- (0, _entry.createEntryHooks)(context);
31
- });
32
- plugin.name = "hcms-aco.createContext";
33
- return plugin;
34
- };
35
- exports.createAcoHcmsContext = createAcoHcmsContext;
36
-
37
- //# sourceMappingURL=index.js.map
1
+ export * from "./plugins/index.js";
2
+ export { AcoHcmsFeature } from "./AcoHcmsFeature.js";
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-aco",
3
- "version": "0.0.0-unstable.e0bfc55d5a",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.e1999482d0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "keywords": [
6
10
  "api-headless-cms-aco-aco:base"
7
11
  ],
@@ -13,34 +17,33 @@
13
17
  "description": "Connect Headless CMS to ACO",
14
18
  "author": "Webiny Ltd.",
15
19
  "license": "MIT",
16
- "scripts": {
17
- "build": "node ../cli/bin.js run build",
18
- "watch": "node ../cli/bin.js run watch"
19
- },
20
20
  "publishConfig": {
21
- "access": "public",
22
- "directory": "dist"
21
+ "access": "public"
23
22
  },
24
23
  "devDependencies": {
25
- "@webiny/api-admin-users": "0.0.0-unstable.e0bfc55d5a",
26
- "@webiny/api-i18n": "0.0.0-unstable.e0bfc55d5a",
27
- "@webiny/api-security": "0.0.0-unstable.e0bfc55d5a",
28
- "@webiny/api-tenancy": "0.0.0-unstable.e0bfc55d5a",
29
- "@webiny/api-wcp": "0.0.0-unstable.e0bfc55d5a",
30
- "@webiny/handler-aws": "0.0.0-unstable.e0bfc55d5a",
31
- "@webiny/handler-graphql": "0.0.0-unstable.e0bfc55d5a",
32
- "@webiny/plugins": "0.0.0-unstable.e0bfc55d5a",
33
- "@webiny/project-utils": "0.0.0-unstable.e0bfc55d5a",
34
- "@webiny/wcp": "0.0.0-unstable.e0bfc55d5a",
35
- "graphql": "15.9.0",
36
- "typescript": "5.3.3"
24
+ "@webiny/api": "0.0.0-unstable.e1999482d0",
25
+ "@webiny/api-core": "0.0.0-unstable.e1999482d0",
26
+ "@webiny/api-core-testing": "0.0.0-unstable.e1999482d0",
27
+ "@webiny/api-graphql": "0.0.0-unstable.e1999482d0",
28
+ "@webiny/api-kernel-core": "0.0.0-unstable.e1999482d0",
29
+ "@webiny/api-scheduler": "0.0.0-unstable.e1999482d0",
30
+ "@webiny/build-tools": "0.0.0-unstable.e1999482d0",
31
+ "@webiny/di": "2.0.0",
32
+ "@webiny/plugins": "0.0.0-unstable.e1999482d0",
33
+ "@webiny/wcp": "0.0.0-unstable.e1999482d0",
34
+ "graphql": "16.15.0",
35
+ "typescript": "7.0.2"
37
36
  },
38
37
  "dependencies": {
39
- "@webiny/api": "0.0.0-unstable.e0bfc55d5a",
40
- "@webiny/api-aco": "0.0.0-unstable.e0bfc55d5a",
41
- "@webiny/api-headless-cms": "0.0.0-unstable.e0bfc55d5a",
42
- "@webiny/error": "0.0.0-unstable.e0bfc55d5a",
43
- "@webiny/handler": "0.0.0-unstable.e0bfc55d5a"
38
+ "@webiny/api-aco": "0.0.0-unstable.e1999482d0",
39
+ "@webiny/api-graphql": "0.0.0-unstable.e1999482d0",
40
+ "@webiny/api-headless-cms": "0.0.0-unstable.e1999482d0",
41
+ "@webiny/api-headless-cms-scheduler": "0.0.0-unstable.e1999482d0",
42
+ "@webiny/feature": "0.0.0-unstable.e1999482d0",
43
+ "@webiny/handler": "0.0.0-unstable.e1999482d0",
44
+ "vitest": "5.1.1"
44
45
  },
45
- "gitHead": "e0bfc55d5a4d6a42b32e6558d9fb2eb6753e331b"
46
+ "webiny": {
47
+ "publishFrom": "dist"
48
+ }
46
49
  }
@@ -1,51 +1,42 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createCmsFolderModelModifier = void 0;
7
- var _apiAco = require("@webiny/api-aco");
1
+ import { FolderCmsModelModifierPlugin } from "@webiny/api-aco";
8
2
  class FolderModelFieldsModifier {
9
- fields = [];
10
- namespace = "cms";
11
- setFields(fields) {
12
- this.fields = fields;
13
- }
14
- addField(field) {
15
- const {
16
- tags,
17
- modelIds = [],
18
- ...rest
19
- } = field;
20
- const baseTags = [`$namespace:${this.namespace}`];
21
- if (modelIds.length > 0) {
22
- modelIds.forEach(modelId => {
23
- this.fields.push({
24
- ...rest,
25
- id: `${this.namespace}_${modelId}_${field.id}`,
26
- fieldId: `${this.namespace}_${modelId}_${field.fieldId}`,
27
- storageId: `${field.type}@${this.namespace}_${modelId}_${field.id}`,
28
- tags: (tags ?? []).concat(baseTags, `$modelId:${modelId}`)
3
+ setFields(fields) {
4
+ this.fields = fields;
5
+ }
6
+ addField(field) {
7
+ const { tags, modelIds = [], ...rest } = field;
8
+ const baseTags = [
9
+ `$namespace:${this.namespace}`
10
+ ];
11
+ if (modelIds.length > 0) modelIds.forEach((modelId)=>{
12
+ this.fields.push({
13
+ ...rest,
14
+ id: `${this.namespace}_${modelId}_${field.id}`,
15
+ fieldId: `${this.namespace}_${modelId}_${field.fieldId}`,
16
+ storageId: `${field.type}@${this.namespace}_${modelId}_${field.id}`,
17
+ tags: (tags ?? []).concat(baseTags, `$modelId:${modelId}`)
18
+ });
29
19
  });
30
- });
31
- } else {
32
- this.fields.push({
33
- ...rest,
34
- id: `${this.namespace}_${field.id}`,
35
- fieldId: `${this.namespace}_${field.fieldId}`,
36
- storageId: `${field.type}@${this.namespace}_${field.id}`,
37
- tags: (tags ?? []).concat(baseTags)
38
- });
20
+ else this.fields.push({
21
+ ...rest,
22
+ id: `${this.namespace}_${field.id}`,
23
+ fieldId: `${this.namespace}_${field.fieldId}`,
24
+ storageId: `${field.type}@${this.namespace}_${field.id}`,
25
+ tags: (tags ?? []).concat(baseTags)
26
+ });
27
+ }
28
+ constructor(){
29
+ this.fields = [];
30
+ this.namespace = "cms";
39
31
  }
40
- }
41
32
  }
42
- const createCmsFolderModelModifier = callback => {
43
- const modifier = new FolderModelFieldsModifier();
44
- return new _apiAco.FolderCmsModelModifierPlugin({
45
- callback,
46
- modifier
47
- });
33
+ const createCmsFolderModelModifier = (callback)=>{
34
+ const modifier = new FolderModelFieldsModifier();
35
+ return new FolderCmsModelModifierPlugin({
36
+ callback,
37
+ modifier
38
+ });
48
39
  };
49
- exports.createCmsFolderModelModifier = createCmsFolderModelModifier;
40
+ export { createCmsFolderModelModifier };
50
41
 
51
42
  //# sourceMappingURL=createCmsFolderModelModifier.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_apiAco","require","FolderModelFieldsModifier","fields","namespace","setFields","addField","field","tags","modelIds","rest","baseTags","length","forEach","modelId","push","id","fieldId","storageId","type","concat","createCmsFolderModelModifier","callback","modifier","FolderCmsModelModifierPlugin","exports"],"sources":["createCmsFolderModelModifier.ts"],"sourcesContent":["import type { CmsModelField as BaseModelField } from \"@webiny/api-headless-cms/types\";\nimport {\n type CmsModelField,\n FolderCmsModelModifierPlugin,\n type IFolderModelFieldsModifier\n} from \"@webiny/api-aco\";\n\nclass FolderModelFieldsModifier implements IFolderModelFieldsModifier {\n private fields: BaseModelField[] = [];\n private readonly namespace = \"cms\";\n\n setFields(fields: BaseModelField[]) {\n this.fields = fields;\n }\n\n addField(field: CmsModelField) {\n const { tags, modelIds = [], ...rest } = field;\n const baseTags = [`$namespace:${this.namespace}`];\n\n if (modelIds.length > 0) {\n modelIds.forEach(modelId => {\n this.fields.push({\n ...rest,\n id: `${this.namespace}_${modelId}_${field.id}`,\n fieldId: `${this.namespace}_${modelId}_${field.fieldId}`,\n storageId: `${field.type}@${this.namespace}_${modelId}_${field.id}`,\n tags: (tags ?? []).concat(baseTags, `$modelId:${modelId}`)\n });\n });\n } else {\n this.fields.push({\n ...rest,\n id: `${this.namespace}_${field.id}`,\n fieldId: `${this.namespace}_${field.fieldId}`,\n storageId: `${field.type}@${this.namespace}_${field.id}`,\n tags: (tags ?? []).concat(baseTags)\n });\n }\n }\n}\n\ninterface CmsModelModifierCallableParams {\n modifier: IFolderModelFieldsModifier;\n}\n\ninterface CmsModelModifierCallable {\n (params: CmsModelModifierCallableParams): Promise<void> | void;\n}\n\nexport const createCmsFolderModelModifier = (callback: CmsModelModifierCallable) => {\n const modifier = new FolderModelFieldsModifier();\n\n return new FolderCmsModelModifierPlugin({\n callback,\n modifier\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAMA,MAAMC,yBAAyB,CAAuC;EAC1DC,MAAM,GAAqB,EAAE;EACpBC,SAAS,GAAG,KAAK;EAElCC,SAASA,CAACF,MAAwB,EAAE;IAChC,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEAG,QAAQA,CAACC,KAAoB,EAAE;IAC3B,MAAM;MAAEC,IAAI;MAAEC,QAAQ,GAAG,EAAE;MAAE,GAAGC;IAAK,CAAC,GAAGH,KAAK;IAC9C,MAAMI,QAAQ,GAAG,CAAC,cAAc,IAAI,CAACP,SAAS,EAAE,CAAC;IAEjD,IAAIK,QAAQ,CAACG,MAAM,GAAG,CAAC,EAAE;MACrBH,QAAQ,CAACI,OAAO,CAACC,OAAO,IAAI;QACxB,IAAI,CAACX,MAAM,CAACY,IAAI,CAAC;UACb,GAAGL,IAAI;UACPM,EAAE,EAAE,GAAG,IAAI,CAACZ,SAAS,IAAIU,OAAO,IAAIP,KAAK,CAACS,EAAE,EAAE;UAC9CC,OAAO,EAAE,GAAG,IAAI,CAACb,SAAS,IAAIU,OAAO,IAAIP,KAAK,CAACU,OAAO,EAAE;UACxDC,SAAS,EAAE,GAAGX,KAAK,CAACY,IAAI,IAAI,IAAI,CAACf,SAAS,IAAIU,OAAO,IAAIP,KAAK,CAACS,EAAE,EAAE;UACnER,IAAI,EAAE,CAACA,IAAI,IAAI,EAAE,EAAEY,MAAM,CAACT,QAAQ,EAAE,YAAYG,OAAO,EAAE;QAC7D,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC,MAAM;MACH,IAAI,CAACX,MAAM,CAACY,IAAI,CAAC;QACb,GAAGL,IAAI;QACPM,EAAE,EAAE,GAAG,IAAI,CAACZ,SAAS,IAAIG,KAAK,CAACS,EAAE,EAAE;QACnCC,OAAO,EAAE,GAAG,IAAI,CAACb,SAAS,IAAIG,KAAK,CAACU,OAAO,EAAE;QAC7CC,SAAS,EAAE,GAAGX,KAAK,CAACY,IAAI,IAAI,IAAI,CAACf,SAAS,IAAIG,KAAK,CAACS,EAAE,EAAE;QACxDR,IAAI,EAAE,CAACA,IAAI,IAAI,EAAE,EAAEY,MAAM,CAACT,QAAQ;MACtC,CAAC,CAAC;IACN;EACJ;AACJ;AAUO,MAAMU,4BAA4B,GAAIC,QAAkC,IAAK;EAChF,MAAMC,QAAQ,GAAG,IAAIrB,yBAAyB,CAAC,CAAC;EAEhD,OAAO,IAAIsB,oCAA4B,CAAC;IACpCF,QAAQ;IACRC;EACJ,CAAC,CAAC;AACN,CAAC;AAACE,OAAA,CAAAJ,4BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"file":"plugins/createCmsFolderModelModifier.js","sources":["../../src/plugins/createCmsFolderModelModifier.ts"],"sourcesContent":["import type { CmsModelField as BaseModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport {\n type CmsModelField,\n FolderCmsModelModifierPlugin,\n type IFolderModelFieldsModifier\n} from \"@webiny/api-aco\";\n\nclass FolderModelFieldsModifier implements IFolderModelFieldsModifier {\n private fields: BaseModelField[] = [];\n private readonly namespace = \"cms\";\n\n setFields(fields: BaseModelField[]) {\n this.fields = fields;\n }\n\n addField(field: CmsModelField) {\n const { tags, modelIds = [], ...rest } = field;\n const baseTags = [`$namespace:${this.namespace}`];\n\n if (modelIds.length > 0) {\n modelIds.forEach(modelId => {\n this.fields.push({\n ...rest,\n id: `${this.namespace}_${modelId}_${field.id}`,\n fieldId: `${this.namespace}_${modelId}_${field.fieldId}`,\n storageId: `${field.type}@${this.namespace}_${modelId}_${field.id}`,\n tags: (tags ?? []).concat(baseTags, `$modelId:${modelId}`)\n });\n });\n } else {\n this.fields.push({\n ...rest,\n id: `${this.namespace}_${field.id}`,\n fieldId: `${this.namespace}_${field.fieldId}`,\n storageId: `${field.type}@${this.namespace}_${field.id}`,\n tags: (tags ?? []).concat(baseTags)\n });\n }\n }\n}\n\ninterface CmsModelModifierCallableParams {\n modifier: IFolderModelFieldsModifier;\n}\n\ninterface CmsModelModifierCallable {\n (params: CmsModelModifierCallableParams): Promise<void> | void;\n}\n\nexport const createCmsFolderModelModifier = (callback: CmsModelModifierCallable) => {\n const modifier = new FolderModelFieldsModifier();\n\n return new FolderCmsModelModifierPlugin({\n callback,\n modifier\n });\n};\n"],"names":["FolderModelFieldsModifier","fields","field","tags","modelIds","rest","baseTags","modelId","createCmsFolderModelModifier","callback","modifier","FolderCmsModelModifierPlugin"],"mappings":";AAOA,MAAMA;IAIF,UAAUC,MAAwB,EAAE;QAChC,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,SAASC,KAAoB,EAAE;QAC3B,MAAM,EAAEC,IAAI,EAAEC,WAAW,EAAE,EAAE,GAAGC,MAAM,GAAGH;QACzC,MAAMI,WAAW;YAAC,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE;SAAC;QAEjD,IAAIF,SAAS,MAAM,GAAG,GAClBA,SAAS,OAAO,CAACG,CAAAA;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBACb,GAAGF,IAAI;gBACP,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEE,QAAQ,CAAC,EAAEL,MAAM,EAAE,EAAE;gBAC9C,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEK,QAAQ,CAAC,EAAEL,MAAM,OAAO,EAAE;gBACxD,WAAW,GAAGA,MAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEK,QAAQ,CAAC,EAAEL,MAAM,EAAE,EAAE;gBACnE,MAAOC,AAAAA,CAAAA,QAAQ,EAAC,EAAG,MAAM,CAACG,UAAU,CAAC,SAAS,EAAEC,SAAS;YAC7D;QACJ;aAEA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACb,GAAGF,IAAI;YACP,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEH,MAAM,EAAE,EAAE;YACnC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEA,MAAM,OAAO,EAAE;YAC7C,WAAW,GAAGA,MAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEA,MAAM,EAAE,EAAE;YACxD,MAAOC,AAAAA,CAAAA,QAAQ,EAAC,EAAG,MAAM,CAACG;QAC9B;IAER;;aA9BQ,MAAM,GAAqB,EAAE;aACpB,SAAS,GAAG;;AA8BjC;AAUO,MAAME,+BAA+B,CAACC;IACzC,MAAMC,WAAW,IAAIV;IAErB,OAAO,IAAIW,6BAA6B;QACpCF;QACAC;IACJ;AACJ"}
@@ -1 +1 @@
1
- export * from "./createCmsFolderModelModifier";
1
+ export * from "./createCmsFolderModelModifier.js";
package/plugins/index.js CHANGED
@@ -1,18 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _createCmsFolderModelModifier = require("./createCmsFolderModelModifier");
7
- Object.keys(_createCmsFolderModelModifier).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _createCmsFolderModelModifier[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _createCmsFolderModelModifier[key];
14
- }
15
- });
16
- });
17
-
18
- //# sourceMappingURL=index.js.map
1
+ export * from "./createCmsFolderModelModifier.js";
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { AcoContext } from "@webiny/api-aco/types";
2
- import type { CmsContext } from "@webiny/api-headless-cms/types";
3
- import type { Context as BaseContext } from "@webiny/handler/types";
1
+ import type { AcoContext } from "@webiny/api-aco/types.js";
2
+ import type { CmsContext } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { Context as BaseContext } from "@webiny/handler/types.js";
4
4
  export interface HcmsAcoContext extends BaseContext, AcoContext, CmsContext {
5
5
  }
package/types.js CHANGED
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=types.js.map
@@ -1,3 +0,0 @@
1
- export { onEntryBeforeRestoreFromBinHook } from "./onEntryBeforeRestoreFromBin.hook";
2
- import type { HcmsAcoContext } from "../../types";
3
- export declare const createEntryHooks: (context: HcmsAcoContext) => void;
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createEntryHooks = void 0;
7
- Object.defineProperty(exports, "onEntryBeforeRestoreFromBinHook", {
8
- enumerable: true,
9
- get: function () {
10
- return _onEntryBeforeRestoreFromBin.onEntryBeforeRestoreFromBinHook;
11
- }
12
- });
13
- var _onEntryBeforeRestoreFromBin = require("./onEntryBeforeRestoreFromBin.hook");
14
- const createEntryHooks = context => {
15
- (0, _onEntryBeforeRestoreFromBin.onEntryBeforeRestoreFromBinHook)(context);
16
- };
17
- exports.createEntryHooks = createEntryHooks;
18
-
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_onEntryBeforeRestoreFromBin","require","createEntryHooks","context","onEntryBeforeRestoreFromBinHook","exports"],"sources":["index.ts"],"sourcesContent":["import { onEntryBeforeRestoreFromBinHook } from \"~/hooks/entry/onEntryBeforeRestoreFromBin.hook\";\n\nexport { onEntryBeforeRestoreFromBinHook } from \"./onEntryBeforeRestoreFromBin.hook\";\n\nimport type { HcmsAcoContext } from \"~/types\";\n\nexport const createEntryHooks = (context: HcmsAcoContext) => {\n onEntryBeforeRestoreFromBinHook(context);\n};\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,4BAAA,GAAAC,OAAA;AAMO,MAAMC,gBAAgB,GAAIC,OAAuB,IAAK;EACzD,IAAAC,4DAA+B,EAACD,OAAO,CAAC;AAC5C,CAAC;AAACE,OAAA,CAAAH,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- import type { HcmsAcoContext } from "../../types";
2
- export declare const onEntryBeforeRestoreFromBinHook: (context: HcmsAcoContext) => void;
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.onEntryBeforeRestoreFromBinHook = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _constants = require("@webiny/api-headless-cms/constants");
10
- const onEntryBeforeRestoreFromBinHook = context => {
11
- const {
12
- aco,
13
- cms
14
- } = context;
15
- cms.onEntryBeforeRestoreFromBin.subscribe(async ({
16
- entry
17
- }) => {
18
- /**
19
- * Skip further execution if folderId is falsy or equals ROOT_FOLDER.
20
- */
21
- if (!entry.location?.folderId || entry.location.folderId === _constants.ROOT_FOLDER) {
22
- return;
23
- }
24
- try {
25
- /**
26
- * Retrieve the folder: if it exists, no additional operations are necessary.
27
- */
28
- await aco.folder.get(entry.location.folderId);
29
- return;
30
- } catch (error) {
31
- /**
32
- * If the folder is not found, set ROOT_FOLDER as the location.
33
- */
34
- if (error.code === "NOT_FOUND") {
35
- entry.location.folderId = _constants.ROOT_FOLDER;
36
- return;
37
- }
38
- throw _error.default.from(error, {
39
- message: "Error while executing onEntryBeforeRestoreFromBin hook",
40
- code: "HCMS_ACO_BEFORE_RESTORE_FROM_BIN_HOOK"
41
- });
42
- }
43
- });
44
- };
45
- exports.onEntryBeforeRestoreFromBinHook = onEntryBeforeRestoreFromBinHook;
46
-
47
- //# sourceMappingURL=onEntryBeforeRestoreFromBin.hook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_constants","onEntryBeforeRestoreFromBinHook","context","aco","cms","onEntryBeforeRestoreFromBin","subscribe","entry","location","folderId","ROOT_FOLDER","folder","get","error","code","WebinyError","from","message","exports"],"sources":["onEntryBeforeRestoreFromBin.hook.ts"],"sourcesContent":["import type { HcmsAcoContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { ROOT_FOLDER } from \"@webiny/api-headless-cms/constants\";\n\nexport const onEntryBeforeRestoreFromBinHook = (context: HcmsAcoContext) => {\n const { aco, cms } = context;\n\n cms.onEntryBeforeRestoreFromBin.subscribe(async ({ entry }) => {\n /**\n * Skip further execution if folderId is falsy or equals ROOT_FOLDER.\n */\n if (!entry.location?.folderId || entry.location.folderId === ROOT_FOLDER) {\n return;\n }\n\n try {\n /**\n * Retrieve the folder: if it exists, no additional operations are necessary.\n */\n await aco.folder.get(entry.location.folderId);\n return;\n } catch (error) {\n /**\n * If the folder is not found, set ROOT_FOLDER as the location.\n */\n if (error.code === \"NOT_FOUND\") {\n entry.location.folderId = ROOT_FOLDER;\n return;\n }\n\n throw WebinyError.from(error, {\n message: \"Error while executing onEntryBeforeRestoreFromBin hook\",\n code: \"HCMS_ACO_BEFORE_RESTORE_FROM_BIN_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEO,MAAME,+BAA+B,GAAIC,OAAuB,IAAK;EACxE,MAAM;IAAEC,GAAG;IAAEC;EAAI,CAAC,GAAGF,OAAO;EAE5BE,GAAG,CAACC,2BAA2B,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAM,CAAC,KAAK;IAC3D;AACR;AACA;IACQ,IAAI,CAACA,KAAK,CAACC,QAAQ,EAAEC,QAAQ,IAAIF,KAAK,CAACC,QAAQ,CAACC,QAAQ,KAAKC,sBAAW,EAAE;MACtE;IACJ;IAEA,IAAI;MACA;AACZ;AACA;MACY,MAAMP,GAAG,CAACQ,MAAM,CAACC,GAAG,CAACL,KAAK,CAACC,QAAQ,CAACC,QAAQ,CAAC;MAC7C;IACJ,CAAC,CAAC,OAAOI,KAAK,EAAE;MACZ;AACZ;AACA;MACY,IAAIA,KAAK,CAACC,IAAI,KAAK,WAAW,EAAE;QAC5BP,KAAK,CAACC,QAAQ,CAACC,QAAQ,GAAGC,sBAAW;QACrC;MACJ;MAEA,MAAMK,cAAW,CAACC,IAAI,CAACH,KAAK,EAAE;QAC1BI,OAAO,EAAE,wDAAwD;QACjEH,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAjB,+BAAA,GAAAA,+BAAA","ignoreList":[]}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["_api","require","_entry","_plugins","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","createAcoHcmsContext","plugin","ContextPlugin","context","aco","console","log","createEntryHooks","name"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { createEntryHooks } from \"~/hooks/entry\";\nimport type { HcmsAcoContext } from \"~/types\";\n\nexport const createAcoHcmsContext = () => {\n const plugin = new ContextPlugin<HcmsAcoContext>(async context => {\n if (!context.aco) {\n console.log(`There is no ACO initialized so we will not initialize the HCMS ACO.`);\n return;\n }\n createEntryHooks(context);\n });\n\n plugin.name = \"hcms-aco.createContext\";\n\n return plugin;\n};\n\nexport * from \"./plugins\";\n"],"mappings":";;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAiBA,IAAAE,QAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,QAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,QAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,QAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAdO,MAAMS,oBAAoB,GAAGA,CAAA,KAAM;EACtC,MAAMC,MAAM,GAAG,IAAIC,kBAAa,CAAiB,MAAMC,OAAO,IAAI;IAC9D,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;MACdC,OAAO,CAACC,GAAG,CAAC,qEAAqE,CAAC;MAClF;IACJ;IACA,IAAAC,uBAAgB,EAACJ,OAAO,CAAC;EAC7B,CAAC,CAAC;EAEFF,MAAM,CAACO,IAAI,GAAG,wBAAwB;EAEtC,OAAOP,MAAM;AACjB,CAAC;AAACL,OAAA,CAAAI,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_createCmsFolderModelModifier","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./createCmsFolderModelModifier\";\n"],"mappings":";;;;;AAAA,IAAAA,6BAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,6BAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,6BAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,6BAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { AcoContext } from \"@webiny/api-aco/types\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport type { Context as BaseContext } from \"@webiny/handler/types\";\n\nexport interface HcmsAcoContext extends BaseContext, AcoContext, CmsContext {}\n"],"mappings":"","ignoreList":[]}