@webiny/api-headless-cms-aco 0.0.0-unstable.61c048f412 → 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.
Files changed (35) hide show
  1. package/AcoHcmsFeature.d.ts +4 -0
  2. package/AcoHcmsFeature.js +15 -0
  3. package/AcoHcmsFeature.js.map +1 -0
  4. package/features/CmsFolderPermissions/CmsFolderPermissions.d.ts +17 -0
  5. package/features/CmsFolderPermissions/CmsFolderPermissions.js +37 -0
  6. package/features/CmsFolderPermissions/CmsFolderPermissions.js.map +1 -0
  7. package/features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.d.ts +11 -0
  8. package/features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.js +21 -0
  9. package/features/ScheduleEntryFolderGuard/ScheduleEntryFolderGuard.js.map +1 -0
  10. package/features/ScheduleEntryFolderGuard/feature.d.ts +4 -0
  11. package/features/ScheduleEntryFolderGuard/feature.js +11 -0
  12. package/features/ScheduleEntryFolderGuard/feature.js.map +1 -0
  13. package/features/ScheduleEntryFolderGuard/index.d.ts +1 -0
  14. package/features/ScheduleEntryFolderGuard/index.js +1 -0
  15. package/features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.d.ts +17 -0
  16. package/features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.js +33 -0
  17. package/features/SetLocationOnEntryRestore/RestoreEntryFromBinWithFolderFallbackDecorator.js.map +1 -0
  18. package/features/SetLocationOnEntryRestore/feature.d.ts +4 -1
  19. package/features/SetLocationOnEntryRestore/feature.js +7 -6
  20. package/features/SetLocationOnEntryRestore/feature.js.map +1 -1
  21. package/features/SetLocationOnEntryRestore/index.js +0 -2
  22. package/index.d.ts +1 -3
  23. package/index.js +1 -11
  24. package/package.json +28 -20
  25. package/plugins/createCmsFolderModelModifier.js +34 -36
  26. package/plugins/createCmsFolderModelModifier.js.map +1 -1
  27. package/plugins/index.js +0 -2
  28. package/types.js +0 -3
  29. package/features/SetLocationOnEntryRestore/SetLocationOnEntryRestore.d.ts +0 -10
  30. package/features/SetLocationOnEntryRestore/SetLocationOnEntryRestore.js +0 -38
  31. package/features/SetLocationOnEntryRestore/SetLocationOnEntryRestore.js.map +0 -1
  32. package/features/SetLocationOnEntryRestore/index.js.map +0 -1
  33. package/index.js.map +0 -1
  34. package/plugins/index.js.map +0 -1
  35. 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"}
@@ -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"}
@@ -1 +1,4 @@
1
- export declare const SetLocationOnEntryRestoreFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const SetLocationOnEntryRestoreFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1,10 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
- import { SetLocationOnEntryRestoreImpl } from "./SetLocationOnEntryRestore.js";
3
- export const SetLocationOnEntryRestoreFeature = createFeature({
4
- name: "SetLocationOnEntryRestore",
5
- register(container) {
6
- container.register(SetLocationOnEntryRestoreImpl);
7
- }
2
+ import { RestoreEntryFromBinWithFolderFallbackDecorator } from "./RestoreEntryFromBinWithFolderFallbackDecorator.js";
3
+ const SetLocationOnEntryRestoreFeature = createFeature({
4
+ name: "SetLocationOnEntryRestore",
5
+ register (container) {
6
+ container.registerDecorator(RestoreEntryFromBinWithFolderFallbackDecorator);
7
+ }
8
8
  });
9
+ export { SetLocationOnEntryRestoreFeature };
9
10
 
10
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","SetLocationOnEntryRestoreImpl","SetLocationOnEntryRestoreFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SetLocationOnEntryRestoreImpl } from \"./SetLocationOnEntryRestore.js\";\n\nexport const SetLocationOnEntryRestoreFeature = createFeature({\n name: \"SetLocationOnEntryRestore\",\n register(container) {\n container.register(SetLocationOnEntryRestoreImpl);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,6BAA6B;AAEtC,OAAO,MAAMC,gCAAgC,GAAGF,aAAa,CAAC;EAC1DG,IAAI,EAAE,2BAA2B;EACjCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,6BAA6B,CAAC;EACrD;AACJ,CAAC,CAAC","ignoreList":[]}
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"}
@@ -1,3 +1 @@
1
1
  export { SetLocationOnEntryRestoreFeature } from "./feature.js";
2
-
3
- //# sourceMappingURL=index.js.map
package/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import type { HcmsAcoContext } from "./types.js";
3
- export declare const createAcoHcmsContext: () => ContextPlugin<HcmsAcoContext>;
4
1
  export * from "./plugins/index.js";
2
+ export { AcoHcmsFeature } from "./AcoHcmsFeature.js";
package/index.js CHANGED
@@ -1,12 +1,2 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { SetLocationOnEntryRestoreFeature } from "./features/SetLocationOnEntryRestore/index.js";
3
- export const createAcoHcmsContext = () => {
4
- const plugin = new ContextPlugin(context => {
5
- SetLocationOnEntryRestoreFeature.register(context.container);
6
- });
7
- plugin.name = "hcms-aco.createContext";
8
- return plugin;
9
- };
10
1
  export * from "./plugins/index.js";
11
-
12
- //# sourceMappingURL=index.js.map
2
+ export { AcoHcmsFeature } from "./AcoHcmsFeature.js";
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-aco",
3
- "version": "0.0.0-unstable.61c048f412",
3
+ "version": "0.0.0-unstable.676006d08e",
4
4
  "type": "module",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
6
9
  "keywords": [
7
10
  "api-headless-cms-aco-aco:base"
8
11
  ],
@@ -15,27 +18,32 @@
15
18
  "author": "Webiny Ltd.",
16
19
  "license": "MIT",
17
20
  "publishConfig": {
18
- "access": "public",
19
- "directory": "dist"
21
+ "access": "public"
20
22
  },
21
23
  "devDependencies": {
22
- "@webiny/api-core": "0.0.0-unstable.61c048f412",
23
- "@webiny/build-tools": "0.0.0-unstable.61c048f412",
24
- "@webiny/handler-aws": "0.0.0-unstable.61c048f412",
25
- "@webiny/handler-graphql": "0.0.0-unstable.61c048f412",
26
- "@webiny/plugins": "0.0.0-unstable.61c048f412",
27
- "@webiny/project-utils": "0.0.0-unstable.61c048f412",
28
- "@webiny/wcp": "0.0.0-unstable.61c048f412",
29
- "graphql": "16.12.0",
30
- "typescript": "5.9.3"
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",
31
+ "@webiny/di": "2.0.0",
32
+ "@webiny/plugins": "0.0.0-unstable.676006d08e",
33
+ "@webiny/wcp": "0.0.0-unstable.676006d08e",
34
+ "graphql": "16.15.0",
35
+ "typescript": "7.0.2"
31
36
  },
32
37
  "dependencies": {
33
- "@webiny/api": "0.0.0-unstable.61c048f412",
34
- "@webiny/api-aco": "0.0.0-unstable.61c048f412",
35
- "@webiny/api-headless-cms": "0.0.0-unstable.61c048f412",
36
- "@webiny/feature": "0.0.0-unstable.61c048f412",
37
- "@webiny/handler": "0.0.0-unstable.61c048f412",
38
- "vitest": "3.2.4"
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"
39
45
  },
40
- "gitHead": "61c048f412d6b4aa70c1d105aab21e3fa69730f3"
46
+ "webiny": {
47
+ "publishFrom": "dist"
48
+ }
41
49
  }
@@ -1,44 +1,42 @@
1
1
  import { FolderCmsModelModifierPlugin } from "@webiny/api-aco";
2
2
  class FolderModelFieldsModifier {
3
- fields = [];
4
- namespace = "cms";
5
- setFields(fields) {
6
- this.fields = fields;
7
- }
8
- addField(field) {
9
- const {
10
- tags,
11
- modelIds = [],
12
- ...rest
13
- } = field;
14
- const baseTags = [`$namespace:${this.namespace}`];
15
- if (modelIds.length > 0) {
16
- modelIds.forEach(modelId => {
17
- this.fields.push({
18
- ...rest,
19
- id: `${this.namespace}_${modelId}_${field.id}`,
20
- fieldId: `${this.namespace}_${modelId}_${field.fieldId}`,
21
- storageId: `${field.type}@${this.namespace}_${modelId}_${field.id}`,
22
- 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
+ });
19
+ });
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)
23
26
  });
24
- });
25
- } else {
26
- this.fields.push({
27
- ...rest,
28
- id: `${this.namespace}_${field.id}`,
29
- fieldId: `${this.namespace}_${field.fieldId}`,
30
- storageId: `${field.type}@${this.namespace}_${field.id}`,
31
- tags: (tags ?? []).concat(baseTags)
32
- });
33
27
  }
34
- }
28
+ constructor(){
29
+ this.fields = [];
30
+ this.namespace = "cms";
31
+ }
35
32
  }
36
- export const createCmsFolderModelModifier = callback => {
37
- const modifier = new FolderModelFieldsModifier();
38
- return new FolderCmsModelModifierPlugin({
39
- callback,
40
- modifier
41
- });
33
+ const createCmsFolderModelModifier = (callback)=>{
34
+ const modifier = new FolderModelFieldsModifier();
35
+ return new FolderCmsModelModifierPlugin({
36
+ callback,
37
+ modifier
38
+ });
42
39
  };
40
+ export { createCmsFolderModelModifier };
43
41
 
44
42
  //# sourceMappingURL=createCmsFolderModelModifier.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FolderCmsModelModifierPlugin","FolderModelFieldsModifier","fields","namespace","setFields","addField","field","tags","modelIds","rest","baseTags","length","forEach","modelId","push","id","fieldId","storageId","type","concat","createCmsFolderModelModifier","callback","modifier"],"sources":["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"],"mappings":"AACA,SAEIA,4BAA4B,QAEzB,iBAAiB;AAExB,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;AAUA,OAAO,MAAMU,4BAA4B,GAAIC,QAAkC,IAAK;EAChF,MAAMC,QAAQ,GAAG,IAAIrB,yBAAyB,CAAC,CAAC;EAEhD,OAAO,IAAID,4BAA4B,CAAC;IACpCqB,QAAQ;IACRC;EACJ,CAAC,CAAC;AACN,CAAC","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"}
package/plugins/index.js CHANGED
@@ -1,3 +1 @@
1
1
  export * from "./createCmsFolderModelModifier.js";
2
-
3
- //# sourceMappingURL=index.js.map
package/types.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1,10 +0,0 @@
1
- import { EntryBeforeRestoreFromBinEventHandler } from "@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js";
2
- import { GetFolderUseCase } from "@webiny/api-aco/features/folder/GetFolder/abstractions.js";
3
- export declare class SetLocationOnEntryRestore implements EntryBeforeRestoreFromBinEventHandler.Interface {
4
- private getFolderUseCase;
5
- constructor(getFolderUseCase: GetFolderUseCase.Interface);
6
- handle(event: EntryBeforeRestoreFromBinEventHandler.Event): Promise<void>;
7
- }
8
- export declare const SetLocationOnEntryRestoreImpl: typeof SetLocationOnEntryRestore & {
9
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/EventPublisher").IEventHandler<import("@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js").EntryBeforeRestoreFromBinEvent>>;
10
- };
@@ -1,38 +0,0 @@
1
- import { ROOT_FOLDER } from "@webiny/api-headless-cms/constants.js";
2
- import { EntryBeforeRestoreFromBinEventHandler } from "@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js";
3
- import { GetFolderUseCase } from "@webiny/api-aco/features/folder/GetFolder/abstractions.js";
4
- export class SetLocationOnEntryRestore {
5
- constructor(getFolderUseCase) {
6
- this.getFolderUseCase = getFolderUseCase;
7
- }
8
- async handle(event) {
9
- const {
10
- entry
11
- } = event.payload;
12
-
13
- /**
14
- * Skip further execution if folderId is falsy or equals ROOT_FOLDER.
15
- */
16
- if (!entry.location?.folderId || entry.location.folderId === ROOT_FOLDER) {
17
- return;
18
- }
19
-
20
- /**
21
- * Retrieve the folder: if it exists, no additional operations are necessary.
22
- */
23
- const result = await this.getFolderUseCase.execute(entry.location.folderId);
24
-
25
- /**
26
- * If the folder is not found, set ROOT_FOLDER as the location.
27
- */
28
- if (result.isFail()) {
29
- entry.location.folderId = ROOT_FOLDER;
30
- }
31
- }
32
- }
33
- export const SetLocationOnEntryRestoreImpl = EntryBeforeRestoreFromBinEventHandler.createImplementation({
34
- implementation: SetLocationOnEntryRestore,
35
- dependencies: [GetFolderUseCase]
36
- });
37
-
38
- //# sourceMappingURL=SetLocationOnEntryRestore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ROOT_FOLDER","EntryBeforeRestoreFromBinEventHandler","GetFolderUseCase","SetLocationOnEntryRestore","constructor","getFolderUseCase","handle","event","entry","payload","location","folderId","result","execute","isFail","SetLocationOnEntryRestoreImpl","createImplementation","implementation","dependencies"],"sources":["SetLocationOnEntryRestore.ts"],"sourcesContent":["import { ROOT_FOLDER } from \"@webiny/api-headless-cms/constants.js\";\nimport { EntryBeforeRestoreFromBinEventHandler } from \"@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js\";\nimport { GetFolderUseCase } from \"@webiny/api-aco/features/folder/GetFolder/abstractions.js\";\n\nexport class SetLocationOnEntryRestore implements EntryBeforeRestoreFromBinEventHandler.Interface {\n constructor(private getFolderUseCase: GetFolderUseCase.Interface) {}\n\n async handle(event: EntryBeforeRestoreFromBinEventHandler.Event): Promise<void> {\n const { entry } = event.payload;\n\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 /**\n * Retrieve the folder: if it exists, no additional operations are necessary.\n */\n const result = await this.getFolderUseCase.execute(entry.location.folderId);\n\n /**\n * If the folder is not found, set ROOT_FOLDER as the location.\n */\n if (result.isFail()) {\n entry.location.folderId = ROOT_FOLDER;\n }\n }\n}\n\nexport const SetLocationOnEntryRestoreImpl =\n EntryBeforeRestoreFromBinEventHandler.createImplementation({\n implementation: SetLocationOnEntryRestore,\n dependencies: [GetFolderUseCase]\n });\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,uCAAuC;AACnE,SAASC,qCAAqC,QAAQ,8EAA8E;AACpI,SAASC,gBAAgB,QAAQ,2DAA2D;AAE5F,OAAO,MAAMC,yBAAyB,CAA4D;EAC9FC,WAAWA,CAASC,gBAA4C,EAAE;IAAA,KAA9CA,gBAA4C,GAA5CA,gBAA4C;EAAG;EAEnE,MAAMC,MAAMA,CAACC,KAAkD,EAAiB;IAC5E,MAAM;MAAEC;IAAM,CAAC,GAAGD,KAAK,CAACE,OAAO;;IAE/B;AACR;AACA;IACQ,IAAI,CAACD,KAAK,CAACE,QAAQ,EAAEC,QAAQ,IAAIH,KAAK,CAACE,QAAQ,CAACC,QAAQ,KAAKX,WAAW,EAAE;MACtE;IACJ;;IAEA;AACR;AACA;IACQ,MAAMY,MAAM,GAAG,MAAM,IAAI,CAACP,gBAAgB,CAACQ,OAAO,CAACL,KAAK,CAACE,QAAQ,CAACC,QAAQ,CAAC;;IAE3E;AACR;AACA;IACQ,IAAIC,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;MACjBN,KAAK,CAACE,QAAQ,CAACC,QAAQ,GAAGX,WAAW;IACzC;EACJ;AACJ;AAEA,OAAO,MAAMe,6BAA6B,GACtCd,qCAAqC,CAACe,oBAAoB,CAAC;EACvDC,cAAc,EAAEd,yBAAyB;EACzCe,YAAY,EAAE,CAAChB,gBAAgB;AACnC,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["SetLocationOnEntryRestoreFeature"],"sources":["index.ts"],"sourcesContent":["export { SetLocationOnEntryRestoreFeature } from \"./feature.js\";\n"],"mappings":"AAAA,SAASA,gCAAgC","ignoreList":[]}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["ContextPlugin","SetLocationOnEntryRestoreFeature","createAcoHcmsContext","plugin","context","register","container","name"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;AAE3C,SAASC,gCAAgC;AAEzC,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACtC,MAAMC,MAAM,GAAG,IAAIH,aAAa,CAAiBI,OAAO,IAAI;IACxDH,gCAAgC,CAACI,QAAQ,CAACD,OAAO,CAACE,SAAS,CAAC;EAChE,CAAC,CAAC;EAEFH,MAAM,CAACI,IAAI,GAAG,wBAAwB;EAEtC,OAAOJ,MAAM;AACjB,CAAC;AAED","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createCmsFolderModelModifier.js\";\n"],"mappings":"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.js\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Context as BaseContext } from \"@webiny/handler/types.js\";\n\nexport interface HcmsAcoContext extends BaseContext, AcoContext, CmsContext {}\n"],"mappings":"","ignoreList":[]}