@webiny/api-headless-cms-aco 0.0.0-unstable.8b6c57b569 β†’ 0.0.0-unstable.9609e4e0c9

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,4 @@
1
+ export declare const AcoHcmsFeature: {
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 { SetLocationOnEntryRestoreFeature } from "./features/SetLocationOnEntryRestore/index.js";
3
+ const AcoHcmsFeature = createFeature({
4
+ name: "AcoHcms",
5
+ register (container) {
6
+ SetLocationOnEntryRestoreFeature.register(container);
7
+ }
8
+ });
9
+ export { AcoHcmsFeature };
10
+
11
+ //# 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\";\n\nexport const AcoHcmsFeature = createFeature({\n name: \"AcoHcms\",\n register(container) {\n SetLocationOnEntryRestoreFeature.register(container);\n }\n});\n"],"names":["AcoHcmsFeature","createFeature","container","SetLocationOnEntryRestoreFeature"],"mappings":";;AAGO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAS;QACdC,iCAAiC,QAAQ,CAACD;IAC9C;AACJ"}
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 { 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.8b6c57b569",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.9609e4e0c9",
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,32 @@
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.8b6c57b569",
26
- "@webiny/api-i18n": "0.0.0-unstable.8b6c57b569",
27
- "@webiny/api-security": "0.0.0-unstable.8b6c57b569",
28
- "@webiny/api-tenancy": "0.0.0-unstable.8b6c57b569",
29
- "@webiny/api-wcp": "0.0.0-unstable.8b6c57b569",
30
- "@webiny/handler-aws": "0.0.0-unstable.8b6c57b569",
31
- "@webiny/handler-graphql": "0.0.0-unstable.8b6c57b569",
32
- "@webiny/plugins": "0.0.0-unstable.8b6c57b569",
33
- "@webiny/project-utils": "0.0.0-unstable.8b6c57b569",
34
- "@webiny/wcp": "0.0.0-unstable.8b6c57b569",
35
- "graphql": "15.9.0",
36
- "typescript": "5.3.3"
24
+ "@webiny/api": "0.0.0-unstable.9609e4e0c9",
25
+ "@webiny/api-core": "0.0.0-unstable.9609e4e0c9",
26
+ "@webiny/api-core-testing": "0.0.0-unstable.9609e4e0c9",
27
+ "@webiny/api-graphql": "0.0.0-unstable.9609e4e0c9",
28
+ "@webiny/api-websockets": "0.0.0-unstable.9609e4e0c9",
29
+ "@webiny/build-tools": "0.0.0-unstable.9609e4e0c9",
30
+ "@webiny/di": "2.0.0",
31
+ "@webiny/event-handler-core": "0.0.0-unstable.9609e4e0c9",
32
+ "@webiny/plugins": "0.0.0-unstable.9609e4e0c9",
33
+ "@webiny/wcp": "0.0.0-unstable.9609e4e0c9",
34
+ "graphql": "16.14.2",
35
+ "typescript": "7.0.2"
37
36
  },
38
37
  "dependencies": {
39
- "@webiny/api": "0.0.0-unstable.8b6c57b569",
40
- "@webiny/api-aco": "0.0.0-unstable.8b6c57b569",
41
- "@webiny/api-headless-cms": "0.0.0-unstable.8b6c57b569",
42
- "@webiny/error": "0.0.0-unstable.8b6c57b569",
43
- "@webiny/handler": "0.0.0-unstable.8b6c57b569"
38
+ "@webiny/api-aco": "0.0.0-unstable.9609e4e0c9",
39
+ "@webiny/api-graphql": "0.0.0-unstable.9609e4e0c9",
40
+ "@webiny/api-headless-cms": "0.0.0-unstable.9609e4e0c9",
41
+ "@webiny/feature": "0.0.0-unstable.9609e4e0c9",
42
+ "@webiny/handler": "0.0.0-unstable.9609e4e0c9",
43
+ "vitest": "5.0.5"
44
44
  },
45
- "gitHead": "8b6c57b56947ee57acf428f703bc1b8c35617a95"
45
+ "webiny": {
46
+ "publishFrom": "dist"
47
+ }
46
48
  }
@@ -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":[]}