@webiny/api-headless-cms-aco 5.40.0-beta.3
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 +3 -0
- package/index.js +22 -0
- package/index.js.map +1 -0
- package/package.json +53 -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 { 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 { 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,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAcoHcmsContext = void 0;
|
|
7
|
+
var _api = require("@webiny/api");
|
|
8
|
+
var _entry = require("./hooks/entry");
|
|
9
|
+
const createAcoHcmsContext = () => {
|
|
10
|
+
const plugin = new _api.ContextPlugin(async context => {
|
|
11
|
+
if (!context.aco) {
|
|
12
|
+
console.log(`There is no ACO initialized so we will not initialize the HCMS ACO.`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
(0, _entry.createEntryHooks)(context);
|
|
16
|
+
});
|
|
17
|
+
plugin.name = "hcms-aco.createContext";
|
|
18
|
+
return plugin;
|
|
19
|
+
};
|
|
20
|
+
exports.createAcoHcmsContext = createAcoHcmsContext;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_api","require","_entry","createAcoHcmsContext","plugin","ContextPlugin","context","aco","console","log","createEntryHooks","name","exports"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { createEntryHooks } from \"~/hooks/entry\";\nimport { HcmsAcoContext } from \"~/types\";\n\nexport const createAcoHcmsContext = () => {\n const plugin = new ContextPlugin<HcmsAcoContext>(async context => {\n if (!context.aco) {\n console.log(`There is no ACO initialized so we will not initialize the HCMS ACO.`);\n return;\n }\n createEntryHooks(context);\n });\n\n plugin.name = \"hcms-aco.createContext\";\n\n return plugin;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGO,MAAME,oBAAoB,GAAGA,CAAA,KAAM;EACtC,MAAMC,MAAM,GAAG,IAAIC,kBAAa,CAAiB,MAAMC,OAAO,IAAI;IAC9D,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;MACdC,OAAO,CAACC,GAAG,CAAE,qEAAoE,CAAC;MAClF;IACJ;IACA,IAAAC,uBAAgB,EAACJ,OAAO,CAAC;EAC7B,CAAC,CAAC;EAEFF,MAAM,CAACO,IAAI,GAAG,wBAAwB;EAEtC,OAAOP,MAAM;AACjB,CAAC;AAACQ,OAAA,CAAAT,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-headless-cms-aco",
|
|
3
|
+
"version": "5.40.0-beta.3",
|
|
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": "yarn webiny run build",
|
|
18
|
+
"watch": "yarn webiny run watch"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"directory": "dist"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@babel/cli": "7.24.1",
|
|
26
|
+
"@babel/core": "7.24.3",
|
|
27
|
+
"@babel/preset-env": "7.24.3",
|
|
28
|
+
"@babel/preset-typescript": "7.24.1",
|
|
29
|
+
"@babel/runtime": "7.24.1",
|
|
30
|
+
"@webiny/api-admin-users": "5.40.0-beta.3",
|
|
31
|
+
"@webiny/api-i18n": "5.40.0-beta.3",
|
|
32
|
+
"@webiny/api-security": "5.40.0-beta.3",
|
|
33
|
+
"@webiny/api-tenancy": "5.40.0-beta.3",
|
|
34
|
+
"@webiny/api-wcp": "5.40.0-beta.3",
|
|
35
|
+
"@webiny/cli": "5.40.0-beta.3",
|
|
36
|
+
"@webiny/handler-aws": "5.40.0-beta.3",
|
|
37
|
+
"@webiny/handler-graphql": "5.40.0-beta.3",
|
|
38
|
+
"@webiny/plugins": "5.40.0-beta.3",
|
|
39
|
+
"@webiny/project-utils": "5.40.0-beta.3",
|
|
40
|
+
"@webiny/wcp": "5.40.0-beta.3",
|
|
41
|
+
"graphql": "15.8.0",
|
|
42
|
+
"ttypescript": "1.5.15",
|
|
43
|
+
"typescript": "4.7.4"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@webiny/api": "5.40.0-beta.3",
|
|
47
|
+
"@webiny/api-aco": "5.40.0-beta.3",
|
|
48
|
+
"@webiny/api-headless-cms": "5.40.0-beta.3",
|
|
49
|
+
"@webiny/error": "5.40.0-beta.3",
|
|
50
|
+
"@webiny/handler": "5.40.0-beta.3"
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "638d8b84063906cd1aa979ed6e0487ad26fbcf2f"
|
|
53
|
+
}
|
package/types.d.ts
ADDED
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { AcoContext } from \"@webiny/api-aco/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\n\nexport interface HcmsAcoContext extends BaseContext, AcoContext, CmsContext {}\n"],"mappings":"","ignoreList":[]}
|