@webiny/api-headless-cms-aco 6.0.0-beta.0 β†’ 6.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,10 @@
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
+ };
@@ -0,0 +1,38 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1 @@
1
+ export declare const SetLocationOnEntryRestoreFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -0,0 +1,10 @@
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
+ }
8
+ });
9
+
10
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1 @@
1
+ export { SetLocationOnEntryRestoreFeature } from "./feature.js";
@@ -0,0 +1,3 @@
1
+ export { SetLocationOnEntryRestoreFeature } from "./feature.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SetLocationOnEntryRestoreFeature"],"sources":["index.ts"],"sourcesContent":["export { SetLocationOnEntryRestoreFeature } from \"./feature.js\";\n"],"mappings":"AAAA,SAASA,gCAAgC","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { ContextPlugin } from "@webiny/api";
2
- import { HcmsAcoContext } from "./types";
2
+ import type { HcmsAcoContext } from "./types.js";
3
3
  export declare const createAcoHcmsContext: () => ContextPlugin<HcmsAcoContext>;
4
+ export * from "./plugins/index.js";
package/index.js CHANGED
@@ -1,22 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createAcoHcmsContext = void 0;
7
- var _api = require("@webiny/api");
8
- var _entry = require("./hooks/entry");
9
- const createAcoHcmsContext = () => {
10
- const plugin = new _api.ContextPlugin(async context => {
11
- if (!context.aco) {
12
- console.log(`There is no ACO initialized so we will not initialize the HCMS ACO.`);
13
- return;
14
- }
15
- (0, _entry.createEntryHooks)(context);
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);
16
6
  });
17
7
  plugin.name = "hcms-aco.createContext";
18
8
  return plugin;
19
9
  };
20
- exports.createAcoHcmsContext = createAcoHcmsContext;
10
+ export * from "./plugins/index.js";
21
11
 
22
12
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_api","require","_entry","createAcoHcmsContext","plugin","ContextPlugin","context","aco","console","log","createEntryHooks","name","exports"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { createEntryHooks } from \"~/hooks/entry\";\nimport { 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"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,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,CAAE,qEAAoE,CAAC;MAClF;IACJ;IACA,IAAAC,uBAAgB,EAACJ,OAAO,CAAC;EAC7B,CAAC,CAAC;EAEFF,MAAM,CAACO,IAAI,GAAG,wBAAwB;EAEtC,OAAOP,MAAM;AACjB,CAAC;AAACQ,OAAA,CAAAT,oBAAA,GAAAA,oBAAA","ignoreList":[]}
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":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-aco",
3
- "version": "6.0.0-beta.0",
3
+ "version": "6.0.0-rc.1",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "keywords": [
6
7
  "api-headless-cms-aco-aco:base"
@@ -13,41 +14,28 @@
13
14
  "description": "Connect Headless CMS to ACO",
14
15
  "author": "Webiny Ltd.",
15
16
  "license": "MIT",
16
- "scripts": {
17
- "build": "yarn webiny run build",
18
- "watch": "yarn webiny run watch"
19
- },
20
17
  "publishConfig": {
21
18
  "access": "public",
22
19
  "directory": "dist"
23
20
  },
24
21
  "devDependencies": {
25
- "@babel/cli": "7.24.1",
26
- "@babel/core": "7.24.3",
27
- "@babel/preset-env": "7.24.3",
28
- "@babel/preset-typescript": "7.24.1",
29
- "@babel/runtime": "7.24.1",
30
- "@webiny/api-admin-users": "6.0.0-beta.0",
31
- "@webiny/api-i18n": "6.0.0-beta.0",
32
- "@webiny/api-security": "6.0.0-beta.0",
33
- "@webiny/api-tenancy": "6.0.0-beta.0",
34
- "@webiny/api-wcp": "6.0.0-beta.0",
35
- "@webiny/cli": "6.0.0-beta.0",
36
- "@webiny/handler-aws": "6.0.0-beta.0",
37
- "@webiny/handler-graphql": "6.0.0-beta.0",
38
- "@webiny/plugins": "6.0.0-beta.0",
39
- "@webiny/project-utils": "6.0.0-beta.0",
40
- "@webiny/wcp": "6.0.0-beta.0",
41
- "graphql": "15.8.0",
42
- "ttypescript": "1.5.15",
43
- "typescript": "4.7.4"
22
+ "@webiny/api-core": "6.0.0-rc.1",
23
+ "@webiny/build-tools": "6.0.0-rc.1",
24
+ "@webiny/handler-aws": "6.0.0-rc.1",
25
+ "@webiny/handler-graphql": "6.0.0-rc.1",
26
+ "@webiny/plugins": "6.0.0-rc.1",
27
+ "@webiny/project-utils": "6.0.0-rc.1",
28
+ "@webiny/wcp": "6.0.0-rc.1",
29
+ "graphql": "16.12.0",
30
+ "typescript": "5.9.3"
44
31
  },
45
32
  "dependencies": {
46
- "@webiny/api": "6.0.0-beta.0",
47
- "@webiny/api-aco": "6.0.0-beta.0",
48
- "@webiny/api-headless-cms": "6.0.0-beta.0",
49
- "@webiny/error": "6.0.0-beta.0",
50
- "@webiny/handler": "6.0.0-beta.0"
33
+ "@webiny/api": "6.0.0-rc.1",
34
+ "@webiny/api-aco": "6.0.0-rc.1",
35
+ "@webiny/api-headless-cms": "6.0.0-rc.1",
36
+ "@webiny/feature": "6.0.0-rc.1",
37
+ "@webiny/handler": "6.0.0-rc.1",
38
+ "vitest": "4.0.18"
51
39
  },
52
- "gitHead": "aa8dbfbbd5ad13ec271adba6f2431e02991a300f"
40
+ "gitHead": "36d702721ff9ed39fb21d6f5fe7922a2a8716e63"
53
41
  }
@@ -0,0 +1,9 @@
1
+ import { FolderCmsModelModifierPlugin, type IFolderModelFieldsModifier } from "@webiny/api-aco";
2
+ interface CmsModelModifierCallableParams {
3
+ modifier: IFolderModelFieldsModifier;
4
+ }
5
+ interface CmsModelModifierCallable {
6
+ (params: CmsModelModifierCallableParams): Promise<void> | void;
7
+ }
8
+ export declare const createCmsFolderModelModifier: (callback: CmsModelModifierCallable) => FolderCmsModelModifierPlugin;
9
+ export {};
@@ -0,0 +1,44 @@
1
+ import { FolderCmsModelModifierPlugin } from "@webiny/api-aco";
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}`)
23
+ });
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
+ }
34
+ }
35
+ }
36
+ export const createCmsFolderModelModifier = callback => {
37
+ const modifier = new FolderModelFieldsModifier();
38
+ return new FolderCmsModelModifierPlugin({
39
+ callback,
40
+ modifier
41
+ });
42
+ };
43
+
44
+ //# sourceMappingURL=createCmsFolderModelModifier.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1 @@
1
+ export * from "./createCmsFolderModelModifier.js";
@@ -0,0 +1,3 @@
1
+ export * from "./createCmsFolderModelModifier.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createCmsFolderModelModifier.js\";\n"],"mappings":"AAAA","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { AcoContext } from "@webiny/api-aco/types";
2
- import { CmsContext } from "@webiny/api-headless-cms/types";
3
- import { 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 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { AcoContext } from \"@webiny/api-aco/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\n\nexport interface HcmsAcoContext extends BaseContext, AcoContext, CmsContext {}\n"],"mappings":"","ignoreList":[]}
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":[]}
@@ -1,3 +0,0 @@
1
- export { onEntryBeforeRestoreFromBinHook } from "./onEntryBeforeRestoreFromBin.hook";
2
- import { 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 { 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 { 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 { 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":[]}