@webiny/api-aco 0.0.0-unstable.b02d94bba0 → 0.0.0-unstable.c2780f51fe
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/README.md +6 -6
- package/createAcoModels.js +0 -2
- package/createAcoModels.js.map +1 -1
- package/folder/folder.model.d.ts +2 -4
- package/folder/folder.model.js +2 -6
- package/folder/folder.model.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/package.json +22 -22
- package/record/record.model.d.ts +2 -4
- package/record/record.model.js +4 -10
- package/record/record.model.js.map +1 -1
- package/record/record.so.js +2 -10
- package/record/record.so.js.map +1 -1
- package/types.d.ts +4 -0
- package/types.js.map +1 -1
- package/utils/createModelField.d.ts +0 -1
- package/utils/createModelField.js +2 -4
- package/utils/createModelField.js.map +1 -1
- package/utils/createOperationsWrapper.js +8 -8
- package/utils/createOperationsWrapper.js.map +1 -1
- package/utils/modelFactory.d.ts +3 -5
- package/utils/modelFactory.js +4 -2
- package/utils/modelFactory.js.map +1 -1
package/README.md
CHANGED
|
@@ -18,16 +18,16 @@ yarn add @webiny/api-aco
|
|
|
18
18
|
```
|
|
19
19
|
## Testing
|
|
20
20
|
|
|
21
|
-
To run tests api-
|
|
21
|
+
To run tests api-aco tests with targeted storage operations loaded use:
|
|
22
22
|
|
|
23
23
|
### DynamoDB
|
|
24
24
|
|
|
25
25
|
```
|
|
26
|
-
yarn test packages/api-aco --keyword=cms:ddb --keyword=aco:base
|
|
26
|
+
yarn test packages/api-aco/* --keyword=cms:ddb --keyword=aco:base
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
### DynamoDB + ElasticSearch
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
```
|
|
32
|
+
yarn test packages/api-aco/* --keyword=cms:ddb-es --keyword=aco:base
|
|
33
|
+
```
|
package/createAcoModels.js
CHANGED
|
@@ -26,7 +26,6 @@ const createAcoModels = context => {
|
|
|
26
26
|
})) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
context.security.disableAuthorization();
|
|
30
29
|
const locale = context.i18n.getContentLocale();
|
|
31
30
|
if (!locale) {
|
|
32
31
|
throw new _error.default("Missing content locale in api-aco/storageOperations/index.ts", "LOCALE_ERROR");
|
|
@@ -62,6 +61,5 @@ const createAcoModels = context => {
|
|
|
62
61
|
* Register them so that they are accessible in cms context
|
|
63
62
|
*/
|
|
64
63
|
context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);
|
|
65
|
-
context.security.enableAuthorization();
|
|
66
64
|
};
|
|
67
65
|
exports.createAcoModels = createAcoModels;
|
package/createAcoModels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAcoModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","
|
|
1
|
+
{"version":3,"names":["createAcoModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","modelDefinitions","createFolderModelDefinition","createSearchModelDefinition","cmsModelPlugins","map","modelDefinition","modelFactory","group","contentModelGroup","tenant","getCurrentTenant","code","plugins","register"],"sources":["createAcoModels.ts"],"sourcesContent":["import { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createFolderModelDefinition } from \"~/folder/folder.model\";\nimport { createSearchModelDefinition } from \"~/record/record.model\";\nimport { modelFactory } from \"~/utils/modelFactory\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\n\nexport const createAcoModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n const groupId = \"contentModelGroup_aco\";\n\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"aco\",\n name: \"ACO\",\n description: \"Group for Advanced Content Organisation and Search\",\n icon: \"fas/folder\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const modelDefinitions = [createFolderModelDefinition(), createSearchModelDefinition()];\n const cmsModelPlugins = modelDefinitions.map(modelDefinition => {\n return modelFactory({\n group: cmsGroupPlugin.contentModelGroup,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: locale.code,\n modelDefinition\n });\n });\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AAEO,MAAMA,eAAe,GAAIC,OAAmB,IAAK;EACpD;AACJ;AACA;AACA;EACI,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,iCAAiC,CAAC;IAC/C;EACJ;EAEA,IAAI,IAAAC,4CAAqB,EAAC;IAAEC,OAAO,EAAEL,OAAO,CAACK,OAAO;IAAEC,IAAI,EAAEN,OAAO,CAACM;EAAK,CAAC,CAAC,EAAE;IACzE;EACJ;EAEA,MAAMC,MAAM,GAAGP,OAAO,CAACM,IAAI,CAACE,gBAAgB,EAAE;EAC9C,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CACjB,8DAA8D,EAC9D,cAAc,CACjB;EACL;EAEA,MAAMC,OAAO,GAAG,uBAAuB;;EAEvC;AACJ;AACA;EACI,MAAMC,cAAc,GAAG,IAAIC,8BAAc,CAAC;IACtCC,EAAE,EAAEH,OAAO;IACXI,IAAI,EAAE,KAAK;IACXC,IAAI,EAAE,KAAK;IACXC,WAAW,EAAE,oDAAoD;IACjEC,IAAI,EAAE,YAAY;IAClBC,SAAS,EAAE;EACf,CAAC,CAAC;;EAEF;AACJ;AACA;EACI,MAAMC,gBAAgB,GAAG,CAAC,IAAAC,mCAA2B,GAAE,EAAE,IAAAC,mCAA2B,GAAE,CAAC;EACvF,MAAMC,eAAe,GAAGH,gBAAgB,CAACI,GAAG,CAACC,eAAe,IAAI;IAC5D,OAAO,IAAAC,0BAAY,EAAC;MAChBC,KAAK,EAAEf,cAAc,CAACgB,iBAAiB;MACvCC,MAAM,EAAE5B,OAAO,CAACK,OAAO,CAACwB,gBAAgB,EAAE,CAAChB,EAAE;MAC7CN,MAAM,EAAEA,MAAM,CAACuB,IAAI;MACnBN;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;EACIxB,OAAO,CAAC+B,OAAO,CAACC,QAAQ,CAAC,CAACrB,cAAc,EAAEW,eAAe,CAAC,CAAC;AAC/D,CAAC;AAAC"}
|
package/folder/folder.model.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type FolderModelDefinition =
|
|
3
|
-
isPrivate: true;
|
|
4
|
-
};
|
|
1
|
+
import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
|
|
2
|
+
export declare type FolderModelDefinition = Omit<CmsPrivateModelFull, "noValidate" | "group">;
|
|
5
3
|
export declare const FOLDER_MODEL_ID = "acoFolder";
|
|
6
4
|
export declare const createFolderModelDefinition: () => FolderModelDefinition;
|
package/folder/folder.model.js
CHANGED
|
@@ -8,7 +8,6 @@ var _createModelField = require("../utils/createModelField");
|
|
|
8
8
|
const titleField = () => (0, _createModelField.createModelField)({
|
|
9
9
|
label: "Title",
|
|
10
10
|
type: "text",
|
|
11
|
-
parent: "folder",
|
|
12
11
|
validation: [{
|
|
13
12
|
name: "required",
|
|
14
13
|
message: "Value is required."
|
|
@@ -23,7 +22,6 @@ const titleField = () => (0, _createModelField.createModelField)({
|
|
|
23
22
|
const slugField = () => (0, _createModelField.createModelField)({
|
|
24
23
|
label: "Slug",
|
|
25
24
|
type: "text",
|
|
26
|
-
parent: "folder",
|
|
27
25
|
validation: [{
|
|
28
26
|
name: "required",
|
|
29
27
|
message: "Value is required."
|
|
@@ -52,7 +50,6 @@ const slugField = () => (0, _createModelField.createModelField)({
|
|
|
52
50
|
const typeField = () => (0, _createModelField.createModelField)({
|
|
53
51
|
label: "Type",
|
|
54
52
|
type: "text",
|
|
55
|
-
parent: "folder",
|
|
56
53
|
validation: [{
|
|
57
54
|
name: "required",
|
|
58
55
|
message: "Value is required."
|
|
@@ -60,8 +57,7 @@ const typeField = () => (0, _createModelField.createModelField)({
|
|
|
60
57
|
});
|
|
61
58
|
const parentIdField = () => (0, _createModelField.createModelField)({
|
|
62
59
|
label: "Parent Id",
|
|
63
|
-
type: "text"
|
|
64
|
-
parent: "folder"
|
|
60
|
+
type: "text"
|
|
65
61
|
});
|
|
66
62
|
const FOLDER_MODEL_ID = "acoFolder";
|
|
67
63
|
exports.FOLDER_MODEL_ID = FOLDER_MODEL_ID;
|
|
@@ -70,7 +66,7 @@ const createFolderModelDefinition = () => {
|
|
|
70
66
|
name: "ACO - Folder",
|
|
71
67
|
modelId: FOLDER_MODEL_ID,
|
|
72
68
|
titleFieldId: "title",
|
|
73
|
-
layout: [["
|
|
69
|
+
layout: [["title"], ["slug"], ["type"], ["parentId"]],
|
|
74
70
|
fields: [titleField(), slugField(), typeField(), parentIdField()],
|
|
75
71
|
description: "ACO - Folder content model",
|
|
76
72
|
isPrivate: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["titleField","createModelField","label","type","
|
|
1
|
+
{"version":3,"names":["titleField","createModelField","label","type","validation","name","message","settings","value","slugField","preset","regex","flags","typeField","parentIdField","FOLDER_MODEL_ID","createFolderModelDefinition","modelId","titleFieldId","layout","fields","description","isPrivate"],"sources":["folder.model.ts"],"sourcesContent":["import { createModelField } from \"~/utils/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\nexport type FolderModelDefinition = Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n }\n ]\n });\n\nconst slugField = () =>\n createModelField({\n label: \"Slug\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n },\n {\n name: \"maxLength\",\n settings: {\n value: \"100\"\n },\n message: \"Value is too long.\"\n },\n {\n name: \"pattern\",\n settings: {\n preset: \"custom\",\n regex: \"^[a-z0-9]+(-[a-z0-9]+)*$\",\n flags: \"g\"\n },\n message: \"Value must consist of only 'a-z', '0-9' and '-'.\"\n }\n ]\n });\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst parentIdField = () =>\n createModelField({\n label: \"Parent Id\",\n type: \"text\"\n });\n\nexport const FOLDER_MODEL_ID = \"acoFolder\";\n\nexport const createFolderModelDefinition = (): FolderModelDefinition => {\n return {\n name: \"ACO - Folder\",\n modelId: FOLDER_MODEL_ID,\n titleFieldId: \"title\",\n layout: [[\"title\"], [\"slug\"], [\"type\"], [\"parentId\"]],\n fields: [titleField(), slugField(), typeField(), parentIdField()],\n description: \"ACO - Folder content model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AAAA;AAKA,MAAMA,UAAU,GAAG,MACf,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC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AAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IACrDC,MAAM,EAAE,CAACpB,UAAU,EAAE,EAAES,SAAS,EAAE,EAAEI,SAAS,EAAE,EAAEC,aAAa,EAAE,CAAC;IACjEO,WAAW,EAAE,4BAA4B;IACzCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const createAco: () => (import("@webiny/api").ContextPlugin<import("./types").AcoContext> | import("@webiny/api-headless-cms/types").CmsModelFieldToGraphQLPlugin<import("@webiny/api-headless-cms/types").CmsModelField>[] | import("@webiny/api").ContextPlugin<import("@webiny/api-admin-settings/types").AdminSettingsContext>)[];
|
package/index.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createAco = void 0;
|
|
7
7
|
var _apiAdminSettings = require("@webiny/api-admin-settings");
|
|
8
8
|
var _createAcoContext = require("./createAcoContext");
|
|
9
9
|
var _createAcoFields = require("./createAcoFields");
|
|
10
10
|
var _createAcoGraphQL = require("./createAcoGraphQL");
|
|
11
|
-
const
|
|
11
|
+
const createAco = () => {
|
|
12
12
|
return [...(0, _apiAdminSettings.createAdminSettingsContext)(), (0, _createAcoContext.createAcoContext)(), (0, _createAcoFields.createAcoFields)(), (0, _createAcoGraphQL.createAcoGraphQL)()];
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
14
|
+
exports.createAco = createAco;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createAco","createAdminSettingsContext","createAcoContext","createAcoFields","createAcoGraphQL"],"sources":["index.ts"],"sourcesContent":["import { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nimport { createAcoContext } from \"~/createAcoContext\";\nimport { createAcoFields } from \"~/createAcoFields\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL\";\n\nexport const createAco = () => {\n return [\n ...createAdminSettingsContext(),\n createAcoContext(),\n createAcoFields(),\n createAcoGraphQL()\n ];\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAEO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,CACH,GAAG,IAAAC,4CAA0B,GAAE,EAC/B,IAAAC,kCAAgB,GAAE,EAClB,IAAAC,gCAAe,GAAE,EACjB,IAAAC,kCAAgB,GAAE,CACrB;AACL,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.c2780f51fe",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aco:base"
|
|
@@ -27,32 +27,32 @@
|
|
|
27
27
|
"@babel/preset-env": "^7.19.4",
|
|
28
28
|
"@babel/preset-typescript": "^7.18.6",
|
|
29
29
|
"@babel/runtime": "^7.19.0",
|
|
30
|
-
"@webiny/api-headless-cms-ddb": "^0.0.0-unstable.
|
|
31
|
-
"@webiny/api-i18n-ddb": "^0.0.0-unstable.
|
|
32
|
-
"@webiny/api-security-so-ddb": "^0.0.0-unstable.
|
|
33
|
-
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.
|
|
34
|
-
"@webiny/api-wcp": "^0.0.0-unstable.
|
|
35
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
36
|
-
"@webiny/handler-aws": "^0.0.0-unstable.
|
|
37
|
-
"@webiny/plugins": "^0.0.0-unstable.
|
|
38
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
30
|
+
"@webiny/api-headless-cms-ddb": "^0.0.0-unstable.c2780f51fe",
|
|
31
|
+
"@webiny/api-i18n-ddb": "^0.0.0-unstable.c2780f51fe",
|
|
32
|
+
"@webiny/api-security-so-ddb": "^0.0.0-unstable.c2780f51fe",
|
|
33
|
+
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.c2780f51fe",
|
|
34
|
+
"@webiny/api-wcp": "^0.0.0-unstable.c2780f51fe",
|
|
35
|
+
"@webiny/cli": "^0.0.0-unstable.c2780f51fe",
|
|
36
|
+
"@webiny/handler-aws": "^0.0.0-unstable.c2780f51fe",
|
|
37
|
+
"@webiny/plugins": "^0.0.0-unstable.c2780f51fe",
|
|
38
|
+
"@webiny/project-utils": "^0.0.0-unstable.c2780f51fe",
|
|
39
39
|
"rimraf": "^3.0.2",
|
|
40
40
|
"ttypescript": "^1.5.13",
|
|
41
41
|
"typescript": "^4.7.4"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@webiny/api": "0.0.0-unstable.
|
|
45
|
-
"@webiny/api-admin-settings": "0.0.0-unstable.
|
|
46
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
47
|
-
"@webiny/api-i18n": "0.0.0-unstable.
|
|
48
|
-
"@webiny/api-security": "0.0.0-unstable.
|
|
49
|
-
"@webiny/api-tenancy": "0.0.0-unstable.
|
|
50
|
-
"@webiny/error": "0.0.0-unstable.
|
|
51
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
52
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
53
|
-
"@webiny/pubsub": "0.0.0-unstable.
|
|
54
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
44
|
+
"@webiny/api": "0.0.0-unstable.c2780f51fe",
|
|
45
|
+
"@webiny/api-admin-settings": "0.0.0-unstable.c2780f51fe",
|
|
46
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.c2780f51fe",
|
|
47
|
+
"@webiny/api-i18n": "0.0.0-unstable.c2780f51fe",
|
|
48
|
+
"@webiny/api-security": "0.0.0-unstable.c2780f51fe",
|
|
49
|
+
"@webiny/api-tenancy": "0.0.0-unstable.c2780f51fe",
|
|
50
|
+
"@webiny/error": "0.0.0-unstable.c2780f51fe",
|
|
51
|
+
"@webiny/handler": "0.0.0-unstable.c2780f51fe",
|
|
52
|
+
"@webiny/handler-graphql": "0.0.0-unstable.c2780f51fe",
|
|
53
|
+
"@webiny/pubsub": "0.0.0-unstable.c2780f51fe",
|
|
54
|
+
"@webiny/utils": "0.0.0-unstable.c2780f51fe",
|
|
55
55
|
"lodash": "4.17.21"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "c2780f51fe628e1ef0f6b55c2bce9b74d3470d79"
|
|
58
58
|
}
|
package/record/record.model.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type SearchRecordModelDefinition =
|
|
3
|
-
isPrivate: true;
|
|
4
|
-
};
|
|
1
|
+
import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
|
|
2
|
+
export declare type SearchRecordModelDefinition = Omit<CmsPrivateModelFull, "noValidate" | "group">;
|
|
5
3
|
export declare const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
6
4
|
export declare const createSearchModelDefinition: () => SearchRecordModelDefinition;
|
package/record/record.model.js
CHANGED
|
@@ -8,7 +8,6 @@ var _createModelField = require("../utils/createModelField");
|
|
|
8
8
|
const typeField = () => (0, _createModelField.createModelField)({
|
|
9
9
|
label: "Type",
|
|
10
10
|
type: "text",
|
|
11
|
-
parent: "searchRecord",
|
|
12
11
|
validation: [{
|
|
13
12
|
name: "required",
|
|
14
13
|
message: "Value is required."
|
|
@@ -16,18 +15,15 @@ const typeField = () => (0, _createModelField.createModelField)({
|
|
|
16
15
|
});
|
|
17
16
|
const titleField = () => (0, _createModelField.createModelField)({
|
|
18
17
|
label: "Title",
|
|
19
|
-
type: "text"
|
|
20
|
-
parent: "searchRecord"
|
|
18
|
+
type: "text"
|
|
21
19
|
});
|
|
22
20
|
const contentField = () => (0, _createModelField.createModelField)({
|
|
23
21
|
label: "Content",
|
|
24
|
-
type: "text"
|
|
25
|
-
parent: "searchRecord"
|
|
22
|
+
type: "text"
|
|
26
23
|
});
|
|
27
24
|
const locationField = fields => (0, _createModelField.createModelField)({
|
|
28
25
|
label: "Location",
|
|
29
26
|
type: "object",
|
|
30
|
-
parent: "searchRecord",
|
|
31
27
|
multipleValues: false,
|
|
32
28
|
settings: {
|
|
33
29
|
fields
|
|
@@ -36,7 +32,6 @@ const locationField = fields => (0, _createModelField.createModelField)({
|
|
|
36
32
|
const locationFolderIdField = () => (0, _createModelField.createModelField)({
|
|
37
33
|
label: "Folder Id",
|
|
38
34
|
type: "text",
|
|
39
|
-
parent: "searchRecord Location",
|
|
40
35
|
validation: [{
|
|
41
36
|
name: "required",
|
|
42
37
|
message: "Value is required."
|
|
@@ -44,8 +39,7 @@ const locationFolderIdField = () => (0, _createModelField.createModelField)({
|
|
|
44
39
|
});
|
|
45
40
|
const dataField = () => (0, _createModelField.createModelField)({
|
|
46
41
|
label: "Data",
|
|
47
|
-
type: "wby-aco-json"
|
|
48
|
-
parent: "searchRecord"
|
|
42
|
+
type: "wby-aco-json"
|
|
49
43
|
});
|
|
50
44
|
const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
51
45
|
exports.SEARCH_RECORD_MODEL_ID = SEARCH_RECORD_MODEL_ID;
|
|
@@ -54,7 +48,7 @@ const createSearchModelDefinition = () => {
|
|
|
54
48
|
name: "ACO - Search Record",
|
|
55
49
|
modelId: SEARCH_RECORD_MODEL_ID,
|
|
56
50
|
titleFieldId: "title",
|
|
57
|
-
layout: [["
|
|
51
|
+
layout: [["type"], ["title"], ["content"], ["location"], ["data"]],
|
|
58
52
|
fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField()],
|
|
59
53
|
description: "ACO - Search record model",
|
|
60
54
|
isPrivate: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["typeField","createModelField","label","type","
|
|
1
|
+
{"version":3,"names":["typeField","createModelField","label","type","validation","name","message","titleField","contentField","locationField","fields","multipleValues","settings","locationFolderIdField","dataField","SEARCH_RECORD_MODEL_ID","createSearchModelDefinition","modelId","titleFieldId","layout","description","isPrivate"],"sources":["record.model.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createModelField } from \"~/utils/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\nexport type SearchRecordModelDefinition = Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\"\n });\n\nconst contentField = () =>\n createModelField({\n label: \"Content\",\n type: \"text\"\n });\n\nconst locationField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Location\",\n type: \"object\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst locationFolderIdField = () =>\n createModelField({\n label: \"Folder Id\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst dataField = () =>\n createModelField({\n label: \"Data\",\n type: \"wby-aco-json\"\n });\n\nexport const SEARCH_RECORD_MODEL_ID = \"acoSearchRecord\";\n\nexport const createSearchModelDefinition = (): SearchRecordModelDefinition => {\n return {\n name: \"ACO - Search Record\",\n modelId: SEARCH_RECORD_MODEL_ID,\n titleFieldId: \"title\",\n layout: [[\"type\"], [\"title\"], [\"content\"], [\"location\"], [\"data\"]],\n fields: [\n typeField(),\n titleField(),\n contentField(),\n locationField([locationFolderIdField()]),\n dataField()\n ],\n description: \"ACO - Search record model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AACA;AAKA,MAAMA,SAAS,GAAG,MACd,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM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CAACI,qBAAqB,EAAE,CAAC,CAAC,EACxCC,SAAS,EAAE,CACd;IACDM,WAAW,EAAE,2BAA2B;IACxCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
|
package/record/record.so.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createSearchRecordOperations = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _valueKeyStorageConverter = require("@webiny/api-headless-cms/utils/converters/valueKeyStorageConverter");
|
|
10
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
10
|
var _record = require("./record.model");
|
|
12
11
|
var _createAcoStorageOperations = require("../createAcoStorageOperations");
|
|
@@ -15,21 +14,14 @@ var _createOperationsWrapper = require("../utils/createOperationsWrapper");
|
|
|
15
14
|
var _getFieldValues = require("../utils/getFieldValues");
|
|
16
15
|
const createSearchRecordOperations = params => {
|
|
17
16
|
const {
|
|
18
|
-
cms
|
|
19
|
-
getCmsContext
|
|
17
|
+
cms
|
|
20
18
|
} = params;
|
|
21
19
|
const {
|
|
22
20
|
withModel
|
|
23
21
|
} = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
24
22
|
modelName: _record.SEARCH_RECORD_MODEL_ID
|
|
25
23
|
}));
|
|
26
|
-
const getRecord = async (
|
|
27
|
-
const context = getCmsContext();
|
|
28
|
-
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
29
|
-
model: initialModel,
|
|
30
|
-
plugins: context.plugins
|
|
31
|
-
});
|
|
32
|
-
|
|
24
|
+
const getRecord = async (model, id) => {
|
|
33
25
|
/**
|
|
34
26
|
* The record "id" has been passed by the original entry.
|
|
35
27
|
* We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.
|
package/record/record.so.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSearchRecordOperations","params","cms","
|
|
1
|
+
{"version":3,"names":["createSearchRecordOperations","params","cms","withModel","createOperationsWrapper","modelName","SEARCH_RECORD_MODEL_ID","getRecord","model","id","revisions","storageOperations","entries","getLatestByIds","ids","length","WebinyError","record","getFieldValues","baseFields","listRecords","sort","where","meta","listLatestEntries","createListSort","map","entry","createRecord","data","createEntry","updateRecord","original","input","updateEntry","deleteRecord","deleteEntry"],"sources":["record.so.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { SEARCH_RECORD_MODEL_ID } from \"./record.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { createListSort } from \"~/utils/createListSort\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { getFieldValues } from \"~/utils/getFieldValues\";\nimport { AcoSearchRecordStorageOperations } from \"./record.types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport const createSearchRecordOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoSearchRecordStorageOperations => {\n const { cms } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: SEARCH_RECORD_MODEL_ID\n });\n\n const getRecord = async (model: CmsModel, id: string) => {\n /**\n * The record \"id\" has been passed by the original entry.\n * We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.\n */\n const revisions = await cms.storageOperations.entries.getLatestByIds(model, {\n ids: [id]\n });\n\n if (revisions.length === 0) {\n throw new WebinyError(\"Record not found.\", \"NOT_FOUND\", {\n id\n });\n }\n\n return revisions[0];\n };\n\n return {\n async getRecord({ id }) {\n return withModel(async model => {\n const record = await getRecord(model, id);\n return getFieldValues(record, baseFields, true);\n });\n },\n listRecords(params) {\n return withModel(async model => {\n const { sort, where } = params;\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n sort: createListSort(sort),\n where: {\n ...(where || {})\n }\n });\n\n return [entries.map(entry => getFieldValues(entry, baseFields, true)), meta];\n });\n },\n createRecord({ data }) {\n return withModel(async model => {\n const entry = await cms.createEntry(model, data);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n updateRecord({ id, data }) {\n return withModel(async model => {\n const original = await getRecord(model, id);\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(model, original.id, input);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n deleteRecord({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, id);\n return true;\n });\n }\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAIO,MAAMA,4BAA4B,GACrCC,MAAwC,IACL;EACnC,MAAM;IAAEC;EAAI,CAAC,GAAGD,MAAM;EAEtB,MAAM;IAAEE;EAAU,CAAC,GAAG,IAAAC,gDAAuB,8DACtCH,MAAM;IACTI,SAAS,EAAEC;EAAsB,GACnC;EAEF,MAAMC,SAAS,GAAG,OAAOC,KAAe,EAAEC,EAAU,KAAK;IACrD;AACR;AACA;AACA;IACQ,MAAMC,SAAS,GAAG,MAAMR,GAAG,CAACS,iBAAiB,CAACC,OAAO,CAACC,cAAc,CAACL,KAAK,EAAE;MACxEM,GAAG,EAAE,CAACL,EAAE;IACZ,CAAC,CAAC;IAEF,IAAIC,SAAS,CAACK,MAAM,KAAK,CAAC,EAAE;MACxB,MAAM,IAAIC,cAAW,CAAC,mBAAmB,EAAE,WAAW,EAAE;QACpDP;MACJ,CAAC,CAAC;IACN;IAEA,OAAOC,SAAS,CAAC,CAAC,CAAC;EACvB,CAAC;EAED,OAAO;IACH,MAAMH,SAAS,CAAC;MAAEE;IAAG,CAAC,EAAE;MACpB,OAAON,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAMS,MAAM,GAAG,MAAMV,SAAS,CAACC,KAAK,EAAEC,EAAE,CAAC;QACzC,OAAO,IAAAS,8BAAc,EAACD,MAAM,EAAEE,sCAAU,EAAE,IAAI,CAAC;MACnD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I,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDgB,YAAY,CAAC;MAAE1B;IAAG,CAAC,EAAE;MACjB,OAAON,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAMN,GAAG,CAACkC,WAAW,CAAC5B,KAAK,EAAEC,EAAE,CAAC;QAChC,OAAO,IAAI;MACf,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/types.d.ts
CHANGED
|
@@ -41,3 +41,7 @@ export declare type AcoStorageOperations = AcoFolderStorageOperations & AcoSearc
|
|
|
41
41
|
export interface AcoContext extends BaseContext, I18NContext, TenancyContext, SecurityContext, CmsContext {
|
|
42
42
|
aco: AdvancedContentOrganisation;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use AcoContext instead
|
|
46
|
+
*/
|
|
47
|
+
export declare type ACOContext = AcoContext;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ListSortDirection"],"sources":["types.ts"],"sourcesContent":["import { Tenant, TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoSearchRecordCrud, AcoSearchRecordStorageOperations } from \"~/record/record.types\";\nimport { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n}\n\nexport interface CreateAcoParams {\n getIdentity: () => SecurityIdentity;\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n}\n\nexport type AcoStorageOperations = AcoFolderStorageOperations & AcoSearchRecordStorageOperations;\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n CmsContext {\n aco: AdvancedContentOrganisation;\n}\n"],"mappings":";;;;;;IAoBYA,iBAAiB;AAAA;AAAA,WAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,iCAAjBA,iBAAiB"}
|
|
1
|
+
{"version":3,"names":["ListSortDirection"],"sources":["types.ts"],"sourcesContent":["import { Tenant, TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoSearchRecordCrud, AcoSearchRecordStorageOperations } from \"~/record/record.types\";\nimport { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n}\n\nexport interface CreateAcoParams {\n getIdentity: () => SecurityIdentity;\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n}\n\nexport type AcoStorageOperations = AcoFolderStorageOperations & AcoSearchRecordStorageOperations;\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n CmsContext {\n aco: AdvancedContentOrganisation;\n}\n\n/**\n * @deprecated Use AcoContext instead\n */\nexport type ACOContext = AcoContext;\n"],"mappings":";;;;;;IAoBYA,iBAAiB;AAAA;AAAA,WAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,iCAAjBA,iBAAiB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
2
|
export interface CreateModelFieldParams extends Omit<CmsModelField, "id" | "storageId" | "fieldId"> {
|
|
3
3
|
fieldId?: string;
|
|
4
|
-
parent: string;
|
|
5
4
|
}
|
|
6
5
|
export declare const createModelField: (params: CreateModelFieldParams) => CmsModelField;
|
|
@@ -11,7 +11,6 @@ const createModelField = params => {
|
|
|
11
11
|
label,
|
|
12
12
|
fieldId: initialFieldId,
|
|
13
13
|
type,
|
|
14
|
-
parent,
|
|
15
14
|
settings = {},
|
|
16
15
|
listValidation = [],
|
|
17
16
|
validation = [],
|
|
@@ -22,10 +21,9 @@ const createModelField = params => {
|
|
|
22
21
|
}
|
|
23
22
|
} = params;
|
|
24
23
|
const fieldId = initialFieldId ? (0, _camelCase.default)(initialFieldId) : (0, _camelCase.default)(label);
|
|
25
|
-
const id = `${(0, _camelCase.default)(parent)}_${fieldId}`;
|
|
26
24
|
return {
|
|
27
|
-
id,
|
|
28
|
-
storageId: fieldId
|
|
25
|
+
id: fieldId,
|
|
26
|
+
storageId: `${type}@${fieldId}`,
|
|
29
27
|
fieldId,
|
|
30
28
|
label,
|
|
31
29
|
type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createModelField","params","label","fieldId","initialFieldId","type","
|
|
1
|
+
{"version":3,"names":["createModelField","params","label","fieldId","initialFieldId","type","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","camelCase","id","storageId"],"sources":["createModelField.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport camelCase from \"lodash/camelCase\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n fieldId?: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n const {\n label,\n fieldId: initialFieldId,\n type,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n }\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n\n return {\n id: fieldId,\n storageId: `${type}@${fieldId}`,\n fieldId,\n label,\n type,\n settings,\n listValidation,\n validation,\n multipleValues,\n predefinedValues\n };\n};\n"],"mappings":";;;;;;;AACA;AAOO,MAAMA,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E,MAAM;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,IAAI;IACJC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb;EACJ,CAAC,GAAGX,MAAM;EAEV,MAAME,OAAO,GAAGC,cAAc,GAAG,IAAAS,kBAAS,EAACT,cAAc,CAAC,GAAG,IAAAS,kBAAS,EAACX,KAAK,CAAC;EAE7E,OAAO;IACHY,EAAE,EAAEX,OAAO;IACXY,SAAS,EAAG,GAAEV,IAAK,IAAGF,OAAQ,EAAC;IAC/BA,OAAO;IACPD,KAAK;IACLG,IAAI;IACJC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -13,14 +13,14 @@ const createOperationsWrapper = params => {
|
|
|
13
13
|
modelName
|
|
14
14
|
} = params;
|
|
15
15
|
const withModel = async cb => {
|
|
16
|
-
security.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
return security.withoutAuthorization(async () => {
|
|
17
|
+
const model = await cms.getModel(modelName);
|
|
18
|
+
if (!model) {
|
|
19
|
+
throw new _error.default(`Could not find "${modelName}" model.`, "MODEL_NOT_FOUND_ERROR");
|
|
20
|
+
}
|
|
21
|
+
const result = await cb(model);
|
|
22
|
+
return result;
|
|
23
|
+
});
|
|
24
24
|
};
|
|
25
25
|
return {
|
|
26
26
|
withModel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createOperationsWrapper","params","cms","security","modelName","withModel","cb","
|
|
1
|
+
{"version":3,"names":["createOperationsWrapper","params","cms","security","modelName","withModel","cb","withoutAuthorization","model","getModel","WebinyError","result"],"sources":["createOperationsWrapper.ts"],"sourcesContent":["import { CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { cms, security, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n return security.withoutAuthorization(async () => {\n const model = await cms.getModel(modelName);\n\n if (!model) {\n throw new WebinyError(\n `Could not find \"${modelName}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n\n const result = await cb(model);\n\n return result;\n });\n };\n\n return {\n withModel\n };\n};\n"],"mappings":";;;;;;;AAEA;AAMO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAE3C,MAAMI,SAAS,GAAG,MACdC,EAAyC,IACtB;IACnB,OAAOH,QAAQ,CAACI,oBAAoB,CAAC,YAAY;MAC7C,MAAMC,KAAK,GAAG,MAAMN,GAAG,CAACO,QAAQ,CAACL,SAAS,CAAC;MAE3C,IAAI,CAACI,KAAK,EAAE;QACR,MAAM,IAAIE,cAAW,CAChB,mBAAkBN,SAAU,UAAS,EACtC,uBAAuB,CAC1B;MACL;MAEA,MAAMO,MAAM,GAAG,MAAML,EAAE,CAACE,KAAK,CAAC;MAE9B,OAAOG,MAAM;IACjB,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACHN;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/utils/modelFactory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CmsModelPlugin } from "@webiny/api-headless-cms";
|
|
2
|
-
import {
|
|
1
|
+
import { CmsModelPlugin, CmsPrivateModelFull } from "@webiny/api-headless-cms";
|
|
2
|
+
import { CmsGroup } from "@webiny/api-headless-cms/types";
|
|
3
3
|
interface Params {
|
|
4
4
|
group: Pick<CmsGroup, "id" | "name">;
|
|
5
5
|
/**
|
|
@@ -9,9 +9,7 @@ interface Params {
|
|
|
9
9
|
*/
|
|
10
10
|
locale?: string;
|
|
11
11
|
tenant?: string;
|
|
12
|
-
modelDefinition: Omit<
|
|
13
|
-
isPrivate: true;
|
|
14
|
-
};
|
|
12
|
+
modelDefinition: Omit<CmsPrivateModelFull, "noValidate" | "group">;
|
|
15
13
|
}
|
|
16
14
|
export declare const modelFactory: (params: Params) => CmsModelPlugin;
|
|
17
15
|
export {};
|
package/utils/modelFactory.js
CHANGED
|
@@ -14,10 +14,12 @@ const modelFactory = params => {
|
|
|
14
14
|
tenant,
|
|
15
15
|
modelDefinition
|
|
16
16
|
} = params;
|
|
17
|
-
return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)({
|
|
17
|
+
return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
18
18
|
group,
|
|
19
19
|
locale,
|
|
20
20
|
tenant
|
|
21
|
-
}, modelDefinition)
|
|
21
|
+
}, modelDefinition), {}, {
|
|
22
|
+
noValidate: true
|
|
23
|
+
}));
|
|
22
24
|
};
|
|
23
25
|
exports.modelFactory = modelFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["modelFactory","params","group","locale","tenant","modelDefinition","createCmsModel"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, createCmsModel } from \"@webiny/api-headless-cms\";\nimport {
|
|
1
|
+
{"version":3,"names":["modelFactory","params","group","locale","tenant","modelDefinition","createCmsModel","noValidate"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { CmsGroup } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n group: Pick<CmsGroup, \"id\" | \"name\">;\n /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n}\n\nexport const modelFactory = (params: Params): CmsModelPlugin => {\n const { group, locale, tenant, modelDefinition } = params;\n\n return createCmsModel({\n group,\n locale,\n tenant,\n ...modelDefinition,\n noValidate: true\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAeO,MAAMA,YAAY,GAAIC,MAAc,IAAqB;EAC5D,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,MAAM;EAEzD,OAAO,IAAAK,8BAAc;IACjBJ,KAAK;IACLC,MAAM;IACNC;EAAM,GACHC,eAAe;IAClBE,UAAU,EAAE;EAAI,GAClB;AACN,CAAC;AAAC"}
|