@webiny/api-headless-cms-aco 0.0.0-unstable.81ae05e56b → 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"}
@@ -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.81ae05e56b",
3
+ "version": "0.0.0-unstable.9609e4e0c9",
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,31 @@
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.81ae05e56b",
23
- "@webiny/build-tools": "0.0.0-unstable.81ae05e56b",
24
- "@webiny/handler-aws": "0.0.0-unstable.81ae05e56b",
25
- "@webiny/handler-graphql": "0.0.0-unstable.81ae05e56b",
26
- "@webiny/plugins": "0.0.0-unstable.81ae05e56b",
27
- "@webiny/project-utils": "0.0.0-unstable.81ae05e56b",
28
- "@webiny/wcp": "0.0.0-unstable.81ae05e56b",
29
- "graphql": "16.13.1",
30
- "typescript": "5.9.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"
31
36
  },
32
37
  "dependencies": {
33
- "@webiny/api": "0.0.0-unstable.81ae05e56b",
34
- "@webiny/api-aco": "0.0.0-unstable.81ae05e56b",
35
- "@webiny/api-headless-cms": "0.0.0-unstable.81ae05e56b",
36
- "@webiny/feature": "0.0.0-unstable.81ae05e56b",
37
- "@webiny/handler": "0.0.0-unstable.81ae05e56b",
38
- "vitest": "4.1.0"
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"
39
44
  },
40
- "gitHead": "81ae05e56bcc774d1e077ca615a0005e736aa5a6"
45
+ "webiny": {
46
+ "publishFrom": "dist"
47
+ }
41
48
  }
@@ -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":[]}