@webiny/api-headless-cms-aco 6.5.0-beta.2 → 6.5.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ import { 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,9 +1,9 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
- import { SetLocationOnEntryRestoreImpl } from "./SetLocationOnEntryRestore.js";
2
+ import { RestoreEntryFromBinWithFolderFallbackDecorator } from "./RestoreEntryFromBinWithFolderFallbackDecorator.js";
3
3
  const SetLocationOnEntryRestoreFeature = createFeature({
4
4
  name: "SetLocationOnEntryRestore",
5
5
  register (container) {
6
- container.register(SetLocationOnEntryRestoreImpl);
6
+ container.registerDecorator(RestoreEntryFromBinWithFolderFallbackDecorator);
7
7
  }
8
8
  });
9
9
  export { SetLocationOnEntryRestoreFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"features/SetLocationOnEntryRestore/feature.js","sources":["../../../src/features/SetLocationOnEntryRestore/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"],"names":["SetLocationOnEntryRestoreFeature","createFeature","container","SetLocationOnEntryRestoreImpl"],"mappings":";;AAGO,MAAMA,mCAAmCC,cAAc;IAC1D,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-aco",
3
- "version": "6.5.0-beta.2",
3
+ "version": "6.5.0-beta.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -21,22 +21,22 @@
21
21
  "access": "public"
22
22
  },
23
23
  "devDependencies": {
24
- "@webiny/api-core": "6.5.0-beta.2",
25
- "@webiny/build-tools": "6.5.0-beta.2",
26
- "@webiny/handler-aws": "6.5.0-beta.2",
27
- "@webiny/handler-graphql": "6.5.0-beta.2",
28
- "@webiny/plugins": "6.5.0-beta.2",
29
- "@webiny/project-utils": "6.5.0-beta.2",
30
- "@webiny/wcp": "6.5.0-beta.2",
24
+ "@webiny/api-core": "6.5.0-beta.4",
25
+ "@webiny/build-tools": "6.5.0-beta.4",
26
+ "@webiny/handler-aws": "6.5.0-beta.4",
27
+ "@webiny/handler-graphql": "6.5.0-beta.4",
28
+ "@webiny/plugins": "6.5.0-beta.4",
29
+ "@webiny/project-utils": "6.5.0-beta.4",
30
+ "@webiny/wcp": "6.5.0-beta.4",
31
31
  "graphql": "16.14.2",
32
32
  "typescript": "7.0.2"
33
33
  },
34
34
  "dependencies": {
35
- "@webiny/api": "6.5.0-beta.2",
36
- "@webiny/api-aco": "6.5.0-beta.2",
37
- "@webiny/api-headless-cms": "6.5.0-beta.2",
38
- "@webiny/feature": "6.5.0-beta.2",
39
- "@webiny/handler": "6.5.0-beta.2",
35
+ "@webiny/api": "6.5.0-beta.4",
36
+ "@webiny/api-aco": "6.5.0-beta.4",
37
+ "@webiny/api-headless-cms": "6.5.0-beta.4",
38
+ "@webiny/feature": "6.5.0-beta.4",
39
+ "@webiny/handler": "6.5.0-beta.4",
40
40
  "vitest": "4.1.10"
41
41
  },
42
42
  "webiny": {
@@ -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,23 +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
- class SetLocationOnEntryRestore {
5
- constructor(getFolderUseCase){
6
- this.getFolderUseCase = getFolderUseCase;
7
- }
8
- async handle(event) {
9
- const { entry } = event.payload;
10
- if (!entry.location?.folderId || entry.location.folderId === ROOT_FOLDER) return;
11
- const result = await this.getFolderUseCase.execute(entry.location.folderId);
12
- if (result.isFail()) entry.location.folderId = ROOT_FOLDER;
13
- }
14
- }
15
- const SetLocationOnEntryRestoreImpl = EntryBeforeRestoreFromBinEventHandler.createImplementation({
16
- implementation: SetLocationOnEntryRestore,
17
- dependencies: [
18
- GetFolderUseCase
19
- ]
20
- });
21
- export { SetLocationOnEntryRestore, SetLocationOnEntryRestoreImpl };
22
-
23
- //# sourceMappingURL=SetLocationOnEntryRestore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/SetLocationOnEntryRestore/SetLocationOnEntryRestore.js","sources":["../../../src/features/SetLocationOnEntryRestore/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"],"names":["SetLocationOnEntryRestore","getFolderUseCase","event","entry","ROOT_FOLDER","result","SetLocationOnEntryRestoreImpl","EntryBeforeRestoreFromBinEventHandler","GetFolderUseCase"],"mappings":";;;AAIO,MAAMA;IACT,YAAoBC,gBAA4C,CAAE;aAA9CA,gBAAgB,GAAhBA;IAA+C;IAEnE,MAAM,OAAOC,KAAkD,EAAiB;QAC5E,MAAM,EAAEC,KAAK,EAAE,GAAGD,MAAM,OAAO;QAK/B,IAAI,CAACC,MAAM,QAAQ,EAAE,YAAYA,MAAM,QAAQ,CAAC,QAAQ,KAAKC,aACzD;QAMJ,MAAMC,SAAS,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAACF,MAAM,QAAQ,CAAC,QAAQ;QAK1E,IAAIE,OAAO,MAAM,IACbF,MAAM,QAAQ,CAAC,QAAQ,GAAGC;IAElC;AACJ;AAEO,MAAME,gCACTC,sCAAsC,oBAAoB,CAAC;IACvD,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC"}