@webiny/api-headless-cms-aco 0.0.0-unstable.e53eceafb5
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/LICENSE +21 -0
- package/README.md +18 -0
- package/hooks/entry/index.d.ts +3 -0
- package/hooks/entry/index.js +19 -0
- package/hooks/entry/index.js.map +1 -0
- package/hooks/entry/onEntryBeforeRestoreFromBin.hook.d.ts +2 -0
- package/hooks/entry/onEntryBeforeRestoreFromBin.hook.js +47 -0
- package/hooks/entry/onEntryBeforeRestoreFromBin.hook.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +37 -0
- package/index.js.map +1 -0
- package/package.json +46 -0
- package/plugins/createCmsFolderModelModifier.d.ts +9 -0
- package/plugins/createCmsFolderModelModifier.js +51 -0
- package/plugins/createCmsFolderModelModifier.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +18 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +5 -0
- package/types.js +7 -0
- package/types.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @webiny/api-headless-cms-aco
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@webiny/api-headless-cms-aco)
|
|
4
|
+
[](https://www.npmjs.com/package/@webiny/api-headless-cms-aco)
|
|
5
|
+
[](https://github.com/prettier/prettier)
|
|
6
|
+
[](http://makeapullrequest.com)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install --save @webiny/api-headless-cms-aco
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or if you prefer yarn:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
yarn add @webiny/api-headless-cms-aco
|
|
18
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-headless-cms-aco",
|
|
3
|
+
"version": "0.0.0-unstable.e53eceafb5",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"api-headless-cms-aco-aco:base"
|
|
7
|
+
],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
11
|
+
"directory": "packages/api-headless-cms-aco"
|
|
12
|
+
},
|
|
13
|
+
"description": "Connect Headless CMS to ACO",
|
|
14
|
+
"author": "Webiny Ltd.",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "node ../cli/bin.js run build",
|
|
18
|
+
"watch": "node ../cli/bin.js run watch"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"directory": "dist"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@webiny/api-admin-users": "0.0.0-unstable.e53eceafb5",
|
|
26
|
+
"@webiny/api-i18n": "0.0.0-unstable.e53eceafb5",
|
|
27
|
+
"@webiny/api-security": "0.0.0-unstable.e53eceafb5",
|
|
28
|
+
"@webiny/api-tenancy": "0.0.0-unstable.e53eceafb5",
|
|
29
|
+
"@webiny/api-wcp": "0.0.0-unstable.e53eceafb5",
|
|
30
|
+
"@webiny/handler-aws": "0.0.0-unstable.e53eceafb5",
|
|
31
|
+
"@webiny/handler-graphql": "0.0.0-unstable.e53eceafb5",
|
|
32
|
+
"@webiny/plugins": "0.0.0-unstable.e53eceafb5",
|
|
33
|
+
"@webiny/project-utils": "0.0.0-unstable.e53eceafb5",
|
|
34
|
+
"@webiny/wcp": "0.0.0-unstable.e53eceafb5",
|
|
35
|
+
"graphql": "15.9.0",
|
|
36
|
+
"typescript": "5.3.3"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@webiny/api": "0.0.0-unstable.e53eceafb5",
|
|
40
|
+
"@webiny/api-aco": "0.0.0-unstable.e53eceafb5",
|
|
41
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.e53eceafb5",
|
|
42
|
+
"@webiny/error": "0.0.0-unstable.e53eceafb5",
|
|
43
|
+
"@webiny/handler": "0.0.0-unstable.e53eceafb5"
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "e53eceafb5ce1a3872c9b4548939bb2eae5b1aef"
|
|
46
|
+
}
|
|
@@ -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,51 @@
|
|
|
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");
|
|
8
|
+
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}`)
|
|
29
|
+
});
|
|
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
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const createCmsFolderModelModifier = callback => {
|
|
43
|
+
const modifier = new FolderModelFieldsModifier();
|
|
44
|
+
return new _apiAco.FolderCmsModelModifierPlugin({
|
|
45
|
+
callback,
|
|
46
|
+
modifier
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
exports.createCmsFolderModelModifier = createCmsFolderModelModifier;
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=createCmsFolderModelModifier.js.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./createCmsFolderModelModifier";
|
package/plugins/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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.d.ts
ADDED
|
@@ -0,0 +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";
|
|
4
|
+
export interface HcmsAcoContext extends BaseContext, AcoContext, CmsContext {
|
|
5
|
+
}
|
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|