@webiny/api-headless-cms-aco 6.3.0-beta.4 → 6.4.0-beta.0
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/features/SetLocationOnEntryRestore/SetLocationOnEntryRestore.js +14 -29
- package/features/SetLocationOnEntryRestore/SetLocationOnEntryRestore.js.map +1 -1
- package/features/SetLocationOnEntryRestore/feature.js +6 -5
- package/features/SetLocationOnEntryRestore/feature.js.map +1 -1
- package/features/SetLocationOnEntryRestore/index.js +0 -2
- package/index.js +8 -7
- package/index.js.map +1 -1
- package/package.json +16 -16
- package/plugins/createCmsFolderModelModifier.js +34 -36
- package/plugins/createCmsFolderModelModifier.js.map +1 -1
- package/plugins/index.js +0 -2
- package/types.js +0 -3
- package/features/SetLocationOnEntryRestore/index.js.map +0 -1
- package/plugins/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
import { ROOT_FOLDER } from "@webiny/api-headless-cms/constants.js";
|
|
2
2
|
import { EntryBeforeRestoreFromBinEventHandler } from "@webiny/api-headless-cms/features/contentEntry/RestoreEntryFromBin/events.js";
|
|
3
3
|
import { GetFolderUseCase } from "@webiny/api-aco/features/folder/GetFolder/abstractions.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
4
|
+
class SetLocationOnEntryRestore {
|
|
5
|
+
constructor(getFolderUseCase){
|
|
6
|
+
this.getFolderUseCase = getFolderUseCase;
|
|
18
7
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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;
|
|
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;
|
|
30
13
|
}
|
|
31
|
-
}
|
|
32
14
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
const SetLocationOnEntryRestoreImpl = EntryBeforeRestoreFromBinEventHandler.createImplementation({
|
|
16
|
+
implementation: SetLocationOnEntryRestore,
|
|
17
|
+
dependencies: [
|
|
18
|
+
GetFolderUseCase
|
|
19
|
+
]
|
|
36
20
|
});
|
|
21
|
+
export { SetLocationOnEntryRestore, SetLocationOnEntryRestoreImpl };
|
|
37
22
|
|
|
38
23
|
//# sourceMappingURL=SetLocationOnEntryRestore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { SetLocationOnEntryRestoreImpl } from "./SetLocationOnEntryRestore.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const SetLocationOnEntryRestoreFeature = createFeature({
|
|
4
|
+
name: "SetLocationOnEntryRestore",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(SetLocationOnEntryRestoreImpl);
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { SetLocationOnEntryRestoreFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ContextPlugin } from "@webiny/api";
|
|
2
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
3
|
export * from "./plugins/index.js";
|
|
4
|
+
const createAcoHcmsContext = ()=>{
|
|
5
|
+
const plugin = new ContextPlugin((context)=>{
|
|
6
|
+
SetLocationOnEntryRestoreFeature.register(context.container);
|
|
7
|
+
});
|
|
8
|
+
plugin.name = "hcms-aco.createContext";
|
|
9
|
+
return plugin;
|
|
10
|
+
};
|
|
11
|
+
export { createAcoHcmsContext };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/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"],"names":["createAcoHcmsContext","plugin","ContextPlugin","context","SetLocationOnEntryRestoreFeature"],"mappings":";;;AAIO,MAAMA,uBAAuB;IAChC,MAAMC,SAAS,IAAIC,cAA8BC,CAAAA;QAC7CC,iCAAiC,QAAQ,CAACD,QAAQ,SAAS;IAC/D;IAEAF,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-aco",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
"directory": "dist"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@webiny/api-core": "6.
|
|
26
|
-
"@webiny/build-tools": "6.
|
|
27
|
-
"@webiny/handler-aws": "6.
|
|
28
|
-
"@webiny/handler-graphql": "6.
|
|
29
|
-
"@webiny/plugins": "6.
|
|
30
|
-
"@webiny/project-utils": "6.
|
|
31
|
-
"@webiny/wcp": "6.
|
|
32
|
-
"graphql": "16.
|
|
25
|
+
"@webiny/api-core": "6.4.0-beta.0",
|
|
26
|
+
"@webiny/build-tools": "6.4.0-beta.0",
|
|
27
|
+
"@webiny/handler-aws": "6.4.0-beta.0",
|
|
28
|
+
"@webiny/handler-graphql": "6.4.0-beta.0",
|
|
29
|
+
"@webiny/plugins": "6.4.0-beta.0",
|
|
30
|
+
"@webiny/project-utils": "6.4.0-beta.0",
|
|
31
|
+
"@webiny/wcp": "6.4.0-beta.0",
|
|
32
|
+
"graphql": "16.14.0",
|
|
33
33
|
"typescript": "6.0.3"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@webiny/api": "6.
|
|
37
|
-
"@webiny/api-aco": "6.
|
|
38
|
-
"@webiny/api-headless-cms": "6.
|
|
39
|
-
"@webiny/feature": "6.
|
|
40
|
-
"@webiny/handler": "6.
|
|
41
|
-
"vitest": "4.1.
|
|
36
|
+
"@webiny/api": "6.4.0-beta.0",
|
|
37
|
+
"@webiny/api-aco": "6.4.0-beta.0",
|
|
38
|
+
"@webiny/api-headless-cms": "6.4.0-beta.0",
|
|
39
|
+
"@webiny/feature": "6.4.0-beta.0",
|
|
40
|
+
"@webiny/handler": "6.4.0-beta.0",
|
|
41
|
+
"vitest": "4.1.6"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "a545d7529828af07d08d49c3da1bcb967483b9ce"
|
|
44
44
|
}
|
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
import { FolderCmsModelModifierPlugin } from "@webiny/api-aco";
|
|
2
2
|
class FolderModelFieldsModifier {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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,"
|
|
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
package/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SetLocationOnEntryRestoreFeature"],"sources":["index.ts"],"sourcesContent":["export { SetLocationOnEntryRestoreFeature } from \"./feature.js\";\n"],"mappings":"AAAA,SAASA,gCAAgC","ignoreList":[]}
|
package/plugins/index.js.map
DELETED
|
@@ -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":[]}
|