@webiny/api-aco 0.0.0-unstable.b02d94bba0 → 0.0.0-unstable.b14eaecf38
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/createAcoFields.js +2 -2
- package/createAcoFields.js.map +1 -1
- 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 +3 -1
- package/index.js +17 -3
- package/index.js.map +1 -1
- package/package.json +22 -22
- package/record/record.gql.js +7 -1
- package/record/record.gql.js.map +1 -1
- package/record/record.model.d.ts +2 -4
- package/record/record.model.js +10 -11
- package/record/record.model.js.map +1 -1
- package/record/record.so.js +14 -12
- package/record/record.so.js.map +1 -1
- package/record/record.types.d.ts +9 -4
- package/record/record.types.js.map +1 -1
- package/types.d.ts +6 -0
- package/types.js +27 -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/createAcoFields.js
CHANGED
|
@@ -9,8 +9,8 @@ const jsonField = {
|
|
|
9
9
|
name: "cms-model-field-to-graphql-json",
|
|
10
10
|
type: "cms-model-field-to-graphql",
|
|
11
11
|
fieldType: "wby-aco-json",
|
|
12
|
-
isSortable:
|
|
13
|
-
isSearchable:
|
|
12
|
+
isSortable: true,
|
|
13
|
+
isSearchable: true,
|
|
14
14
|
read: {
|
|
15
15
|
createTypeField({
|
|
16
16
|
field
|
package/createAcoFields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsonField","name","type","fieldType","isSortable","isSearchable","read","createTypeField","field","fieldId","createGetFilters","manage","createInputField","createAcoFields"],"sources":["createAcoFields.ts"],"sourcesContent":["import { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\n\n// Creating an internal JSON field, we are using it inside the `record` type\nconst jsonField: CmsModelFieldToGraphQLPlugin = {\n name: \"cms-model-field-to-graphql-json\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"wby-aco-json\",\n isSortable:
|
|
1
|
+
{"version":3,"names":["jsonField","name","type","fieldType","isSortable","isSearchable","read","createTypeField","field","fieldId","createGetFilters","manage","createInputField","createAcoFields"],"sources":["createAcoFields.ts"],"sourcesContent":["import { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\n\n// Creating an internal JSON field, we are using it inside the `record` type\nconst jsonField: CmsModelFieldToGraphQLPlugin = {\n name: \"cms-model-field-to-graphql-json\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"wby-aco-json\",\n isSortable: true,\n isSearchable: true,\n read: {\n createTypeField({ field }) {\n return `${field.fieldId}: JSON`;\n },\n createGetFilters({ field }) {\n return `${field.fieldId}: JSON`;\n }\n },\n manage: {\n createTypeField({ field }) {\n return `${field.fieldId}: JSON`;\n },\n createInputField({ field }) {\n return field.fieldId + \": JSON\";\n }\n }\n};\n\nexport const createAcoFields = (): CmsModelFieldToGraphQLPlugin[] => [jsonField];\n"],"mappings":";;;;;;AAEA;AACA,MAAMA,SAAuC,GAAG;EAC5CC,IAAI,EAAE,iCAAiC;EACvCC,IAAI,EAAE,4BAA4B;EAClCC,SAAS,EAAE,cAAc;EACzBC,UAAU,EAAE,IAAI;EAChBC,YAAY,EAAE,IAAI;EAClBC,IAAI,EAAE;IACFC,eAAe,CAAC;MAAEC;IAAM,CAAC,EAAE;MACvB,OAAQ,GAAEA,KAAK,CAACC,OAAQ,QAAO;IACnC,CAAC;IACDC,gBAAgB,CAAC;MAAEF;IAAM,CAAC,EAAE;MACxB,OAAQ,GAAEA,KAAK,CAACC,OAAQ,QAAO;IACnC;EACJ,CAAC;EACDE,MAAM,EAAE;IACJJ,eAAe,CAAC;MAAEC;IAAM,CAAC,EAAE;MACvB,OAAQ,GAAEA,KAAK,CAACC,OAAQ,QAAO;IACnC,CAAC;IACDG,gBAAgB,CAAC;MAAEJ;IAAM,CAAC,EAAE;MACxB,OAAOA,KAAK,CAACC,OAAO,GAAG,QAAQ;IACnC;EACJ;AACJ,CAAC;AAEM,MAAMI,eAAe,GAAG,MAAsC,CAACb,SAAS,CAAC;AAAC"}
|
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,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMG,SAAS,GAAG,MACd,IAAAR,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,SAAS;IACfE,QAAQ,EAAE;MACNG,MAAM,EAAE,QAAQ;MAChBC,KAAK,EAAE,0BAA0B;MACjCC,KAAK,EAAE;IACX,CAAC;IACDN,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMO,SAAS,GAAG,MACd,IAAAZ,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,aAAa,GAAG,MAClB,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC;AAEC,MAAMY,eAAe,GAAG,WAAW;AAAC;AAEpC,MAAMC,2BAA2B,GAAG,MAA6B;EACpE,OAAO;IACHX,IAAI,EAAE,cAAc;IACpBY,OAAO,EAAEF,eAAe;IACxBG,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,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,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { SEARCH_RECORD_MODEL_ID } from "./record/record.model";
|
|
2
|
+
export { FOLDER_MODEL_ID } from "./folder/folder.model";
|
|
3
|
+
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,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "FOLDER_MODEL_ID", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _folder.FOLDER_MODEL_ID;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SEARCH_RECORD_MODEL_ID", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _record.SEARCH_RECORD_MODEL_ID;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.createAco = void 0;
|
|
7
19
|
var _apiAdminSettings = require("@webiny/api-admin-settings");
|
|
8
20
|
var _createAcoContext = require("./createAcoContext");
|
|
9
21
|
var _createAcoFields = require("./createAcoFields");
|
|
10
22
|
var _createAcoGraphQL = require("./createAcoGraphQL");
|
|
11
|
-
|
|
23
|
+
var _record = require("./record/record.model");
|
|
24
|
+
var _folder = require("./folder/folder.model");
|
|
25
|
+
const createAco = () => {
|
|
12
26
|
return [...(0, _apiAdminSettings.createAdminSettingsContext)(), (0, _createAcoContext.createAcoContext)(), (0, _createAcoFields.createAcoFields)(), (0, _createAcoGraphQL.createAcoGraphQL)()];
|
|
13
27
|
};
|
|
14
|
-
exports.
|
|
28
|
+
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 { SEARCH_RECORD_MODEL_ID } from \"./record/record.model\";\nexport { FOLDER_MODEL_ID } from \"./folder/folder.model\";\n\nexport const createAco = () => {\n return [\n ...createAdminSettingsContext(),\n createAcoContext(),\n createAcoFields(),\n createAcoGraphQL()\n ];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAEA;AACA;AACA;AAEA;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.b14eaecf38",
|
|
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.b14eaecf38",
|
|
31
|
+
"@webiny/api-i18n-ddb": "^0.0.0-unstable.b14eaecf38",
|
|
32
|
+
"@webiny/api-security-so-ddb": "^0.0.0-unstable.b14eaecf38",
|
|
33
|
+
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.b14eaecf38",
|
|
34
|
+
"@webiny/api-wcp": "^0.0.0-unstable.b14eaecf38",
|
|
35
|
+
"@webiny/cli": "^0.0.0-unstable.b14eaecf38",
|
|
36
|
+
"@webiny/handler-aws": "^0.0.0-unstable.b14eaecf38",
|
|
37
|
+
"@webiny/plugins": "^0.0.0-unstable.b14eaecf38",
|
|
38
|
+
"@webiny/project-utils": "^0.0.0-unstable.b14eaecf38",
|
|
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.b14eaecf38",
|
|
45
|
+
"@webiny/api-admin-settings": "0.0.0-unstable.b14eaecf38",
|
|
46
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.b14eaecf38",
|
|
47
|
+
"@webiny/api-i18n": "0.0.0-unstable.b14eaecf38",
|
|
48
|
+
"@webiny/api-security": "0.0.0-unstable.b14eaecf38",
|
|
49
|
+
"@webiny/api-tenancy": "0.0.0-unstable.b14eaecf38",
|
|
50
|
+
"@webiny/error": "0.0.0-unstable.b14eaecf38",
|
|
51
|
+
"@webiny/handler": "0.0.0-unstable.b14eaecf38",
|
|
52
|
+
"@webiny/handler-graphql": "0.0.0-unstable.b14eaecf38",
|
|
53
|
+
"@webiny/pubsub": "0.0.0-unstable.b14eaecf38",
|
|
54
|
+
"@webiny/utils": "0.0.0-unstable.b14eaecf38",
|
|
55
55
|
"lodash": "4.17.21"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "b14eaecf387253ed23cb96f8d31b7d16b5061936"
|
|
58
58
|
}
|
package/record/record.gql.js
CHANGED
|
@@ -15,7 +15,8 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
15
15
|
location: SearchLocationType!
|
|
16
16
|
title: String!
|
|
17
17
|
content: String
|
|
18
|
-
data: JSON
|
|
18
|
+
data: JSON!
|
|
19
|
+
tags: [String!]!
|
|
19
20
|
savedOn: DateTime
|
|
20
21
|
createdOn: DateTime
|
|
21
22
|
createdBy: AcoUser
|
|
@@ -36,6 +37,7 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
36
37
|
content: String
|
|
37
38
|
location: SearchLocationInput!
|
|
38
39
|
data: JSON
|
|
40
|
+
tags: [String!]
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
input SearchRecordUpdateInput {
|
|
@@ -43,11 +45,15 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
43
45
|
content: String
|
|
44
46
|
location: SearchLocationInput
|
|
45
47
|
data: JSON
|
|
48
|
+
tags: [String!]
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
input SearchRecordListWhereInput {
|
|
49
52
|
type: String!
|
|
50
53
|
location: SearchLocationInput
|
|
54
|
+
tags_in: [String!]
|
|
55
|
+
tags_startsWith: String
|
|
56
|
+
tags_not_startsWith: String
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
type SearchRecordResponse {
|
package/record/record.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["searchRecordSchema","GraphQLSchemaPlugin","typeDefs","resolvers","SearchQuery","getRecord","_","id","context","resolve","aco","search","get","listRecords","args","entries","meta","list","ListResponse","e","ErrorResponse","SearchMutation","createRecord","data","create","updateRecord","update","deleteRecord","delete"],"sources":["record.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\n\nimport { resolve } from \"~/utils/resolve\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const searchRecordSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type SearchRecord {\n id: ID!\n type: String!\n location: SearchLocationType!\n title: String!\n content: String\n data: JSON
|
|
1
|
+
{"version":3,"names":["searchRecordSchema","GraphQLSchemaPlugin","typeDefs","resolvers","SearchQuery","getRecord","_","id","context","resolve","aco","search","get","listRecords","args","entries","meta","list","ListResponse","e","ErrorResponse","SearchMutation","createRecord","data","create","updateRecord","update","deleteRecord","delete"],"sources":["record.gql.ts"],"sourcesContent":["import { ErrorResponse, ListResponse } from \"@webiny/handler-graphql/responses\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin\";\n\nimport { resolve } from \"~/utils/resolve\";\n\nimport { AcoContext } from \"~/types\";\n\nexport const searchRecordSchema = new GraphQLSchemaPlugin<AcoContext>({\n typeDefs: /* GraphQL */ `\n type SearchRecord {\n id: ID!\n type: String!\n location: SearchLocationType!\n title: String!\n content: String\n data: JSON!\n tags: [String!]!\n savedOn: DateTime\n createdOn: DateTime\n createdBy: AcoUser\n }\n\n type SearchLocationType {\n folderId: ID!\n }\n\n input SearchLocationInput {\n folderId: ID!\n }\n\n input SearchRecordCreateInput {\n id: String!\n type: String!\n title: String!\n content: String\n location: SearchLocationInput!\n data: JSON\n tags: [String!]\n }\n\n input SearchRecordUpdateInput {\n title: String\n content: String\n location: SearchLocationInput\n data: JSON\n tags: [String!]\n }\n\n input SearchRecordListWhereInput {\n type: String!\n location: SearchLocationInput\n tags_in: [String!]\n tags_startsWith: String\n tags_not_startsWith: String\n }\n\n type SearchRecordResponse {\n data: SearchRecord\n error: AcoError\n }\n\n type SearchRecordListResponse {\n data: [SearchRecord]\n error: AcoError\n meta: AcoMeta\n }\n\n extend type SearchQuery {\n getRecord(id: ID!): SearchRecordResponse\n listRecords(\n where: SearchRecordListWhereInput\n search: String\n limit: Int\n after: String\n sort: AcoSort\n ): SearchRecordListResponse\n }\n\n extend type SearchMutation {\n createRecord(data: SearchRecordCreateInput!): SearchRecordResponse\n updateRecord(id: ID!, data: SearchRecordUpdateInput!): SearchRecordResponse\n deleteRecord(id: ID!): AcoBooleanResponse\n }\n `,\n resolvers: {\n SearchQuery: {\n getRecord: async (_, { id }, context) => {\n return resolve(() => context.aco.search.get(id));\n },\n listRecords: async (_, args: any, context) => {\n try {\n const [entries, meta] = await context.aco.search.list(args);\n return new ListResponse(entries, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n SearchMutation: {\n createRecord: async (_, { data }, context) => {\n return resolve(() => context.aco.search.create(data));\n },\n updateRecord: async (_, { id, data }, context) => {\n return resolve(() => context.aco.search.update(id, data));\n },\n deleteRecord: async (_, { id }, context) => {\n return resolve(() => context.aco.search.delete(id));\n }\n }\n }\n});\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAIO,MAAMA,kBAAkB,GAAG,IAAIC,wCAAmB,CAAa;EAClEC,QAAQ,EAAE,aAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;EACDC,SAAS,EAAE;IACPC,WAAW,EAAE;MACTC,SAAS,EAAE,OAAOC,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACrC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACC,GAAG,CAACL,EAAE,CAAC,CAAC;MACpD,CAAC;MACDM,WAAW,EAAE,OAAOP,CAAC,EAAEQ,IAAS,EAAEN,OAAO,KAAK;QAC1C,IAAI;UACA,MAAM,CAACO,OAAO,EAAEC,IAAI,CAAC,GAAG,MAAMR,OAAO,CAACE,GAAG,CAACC,MAAM,CAACM,IAAI,CAACH,IAAI,CAAC;UAC3D,OAAO,IAAII,uBAAY,CAACH,OAAO,EAAEC,IAAI,CAAC;QAC1C,CAAC,CAAC,OAAOG,CAAC,EAAE;UACR,OAAO,IAAIC,wBAAa,CAACD,CAAC,CAAC;QAC/B;MACJ;IACJ,CAAC;IACDE,cAAc,EAAE;MACZC,YAAY,EAAE,OAAOhB,CAAC,EAAE;QAAEiB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC1C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACa,MAAM,CAACD,IAAI,CAAC,CAAC;MACzD,CAAC;MACDE,YAAY,EAAE,OAAOnB,CAAC,EAAE;QAAEC,EAAE;QAAEgB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC9C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACe,MAAM,CAACnB,EAAE,EAAEgB,IAAI,CAAC,CAAC;MAC7D,CAAC;MACDI,YAAY,EAAE,OAAOrB,CAAC,EAAE;QAAEC;MAAG,CAAC,EAAEC,OAAO,KAAK;QACxC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACiB,MAAM,CAACrB,EAAE,CAAC,CAAC;MACvD;IACJ;EACJ;AACJ,CAAC,CAAC;AAAC"}
|
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,12 @@ const locationFolderIdField = () => (0, _createModelField.createModelField)({
|
|
|
44
39
|
});
|
|
45
40
|
const dataField = () => (0, _createModelField.createModelField)({
|
|
46
41
|
label: "Data",
|
|
47
|
-
type: "wby-aco-json"
|
|
48
|
-
|
|
42
|
+
type: "wby-aco-json"
|
|
43
|
+
});
|
|
44
|
+
const tagsField = () => (0, _createModelField.createModelField)({
|
|
45
|
+
label: "Tags",
|
|
46
|
+
type: "text",
|
|
47
|
+
multipleValues: true
|
|
49
48
|
});
|
|
50
49
|
const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
|
|
51
50
|
exports.SEARCH_RECORD_MODEL_ID = SEARCH_RECORD_MODEL_ID;
|
|
@@ -54,8 +53,8 @@ const createSearchModelDefinition = () => {
|
|
|
54
53
|
name: "ACO - Search Record",
|
|
55
54
|
modelId: SEARCH_RECORD_MODEL_ID,
|
|
56
55
|
titleFieldId: "title",
|
|
57
|
-
layout: [["
|
|
58
|
-
fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField()],
|
|
56
|
+
layout: [["type"], ["title"], ["content"], ["location"], ["data"], ["tags"]],
|
|
57
|
+
fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField(), tagsField()],
|
|
59
58
|
description: "ACO - Search record model",
|
|
60
59
|
isPrivate: true
|
|
61
60
|
};
|
|
@@ -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","tagsField","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\nconst tagsField = () =>\n createModelField({\n label: \"Tags\",\n type: \"text\",\n multipleValues: true\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\"], [\"tags\"]],\n fields: [\n typeField(),\n titleField(),\n contentField(),\n locationField([locationFolderIdField()]),\n dataField(),\n tagsField()\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;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,UAAU,GAAG,MACf,IAAAN,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE;AACV,CAAC,CAAC;AAEN,MAAMK,YAAY,GAAG,MACjB,IAAAP,kCAAgB,EAAC;EACbC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC;AAEN,MAAMM,aAAa,GAAIC,MAAuB,IAC1C,IAAAT,kCAAgB,EAAC;EACbC,KAAK,EAAE,UAAU;EACjBC,IAAI,EAAE,QAAQ;EACdQ,cAAc,EAAE,KAAK;EACrBC,QAAQ,EAAE;IAAEF;EAAO;AACvB,CAAC,CAAC;AAEN,MAAMG,qBAAqB,GAAG,MAC1B,IAAAZ,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,SAAS,GAAG,MACd,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE;AACV,CAAC,CAAC;AAEN,MAAMY,SAAS,GAAG,MACd,IAAAd,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZQ,cAAc,EAAE;AACpB,CAAC,CAAC;AAEC,MAAMK,sBAAsB,GAAG,iBAAiB;AAAC;AAEjD,MAAMC,2BAA2B,GAAG,MAAmC;EAC1E,OAAO;IACHZ,IAAI,EAAE,qBAAqB;IAC3Ba,OAAO,EAAEF,sBAAsB;IAC/BG,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAC5EV,MAAM,EAAE,CACJV,SAAS,EAAE,EACXO,UAAU,EAAE,EACZC,YAAY,EAAE,EACdC,aAAa,CAAC,CAACI,qBAAqB,EAAE,CAAC,CAAC,EACxCC,SAAS,EAAE,EACXC,SAAS,EAAE,CACd;IACDM,WAAW,EAAE,2BAA2B;IACxCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
|
package/record/record.so.js
CHANGED
|
@@ -5,31 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createSearchRecordOperations = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
8
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _valueKeyStorageConverter = require("@webiny/api-headless-cms/utils/converters/valueKeyStorageConverter");
|
|
10
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
11
|
var _record = require("./record.model");
|
|
12
12
|
var _createAcoStorageOperations = require("../createAcoStorageOperations");
|
|
13
13
|
var _createListSort = require("../utils/createListSort");
|
|
14
14
|
var _createOperationsWrapper = require("../utils/createOperationsWrapper");
|
|
15
15
|
var _getFieldValues = require("../utils/getFieldValues");
|
|
16
|
+
const _excluded = ["tags", "data"];
|
|
16
17
|
const createSearchRecordOperations = params => {
|
|
17
18
|
const {
|
|
18
|
-
cms
|
|
19
|
-
getCmsContext
|
|
19
|
+
cms
|
|
20
20
|
} = params;
|
|
21
21
|
const {
|
|
22
22
|
withModel
|
|
23
23
|
} = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
24
24
|
modelName: _record.SEARCH_RECORD_MODEL_ID
|
|
25
25
|
}));
|
|
26
|
-
const getRecord = async (
|
|
27
|
-
const context = getCmsContext();
|
|
28
|
-
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
29
|
-
model: initialModel,
|
|
30
|
-
plugins: context.plugins
|
|
31
|
-
});
|
|
32
|
-
|
|
26
|
+
const getRecord = async (model, id) => {
|
|
33
27
|
/**
|
|
34
28
|
* The record "id" has been passed by the original entry.
|
|
35
29
|
* We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.
|
|
@@ -67,10 +61,18 @@ const createSearchRecordOperations = params => {
|
|
|
67
61
|
});
|
|
68
62
|
},
|
|
69
63
|
createRecord({
|
|
70
|
-
data
|
|
64
|
+
data: SearchRecordData
|
|
71
65
|
}) {
|
|
72
66
|
return withModel(async model => {
|
|
73
|
-
const
|
|
67
|
+
const {
|
|
68
|
+
tags = [],
|
|
69
|
+
data = {}
|
|
70
|
+
} = SearchRecordData,
|
|
71
|
+
rest = (0, _objectWithoutProperties2.default)(SearchRecordData, _excluded);
|
|
72
|
+
const entry = await cms.createEntry(model, (0, _objectSpread2.default)({
|
|
73
|
+
tags,
|
|
74
|
+
data
|
|
75
|
+
}, rest));
|
|
74
76
|
return (0, _getFieldValues.getFieldValues)(entry, _createAcoStorageOperations.baseFields, true);
|
|
75
77
|
});
|
|
76
78
|
},
|
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","SearchRecordData","tags","rest","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: SearchRecordData }) {\n return withModel(async model => {\n const { tags = [], data = {}, ...rest } = SearchRecordData;\n const entry = await cms.createEntry(model, { tags, data, ...rest });\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;AAAwD;AAIjD,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,CAAC,CAAC;IACN,CAAC;IACDC,WAAW,CAACnB,MAAM,EAAE;MAChB,OAAOE,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAM;UAAEa,IAAI;UAAEC;QAAM,CAAC,GAAGrB,MAAM;QAE9B,MAAM,CAACW,OAAO,EAAEW,IAAI,CAAC,GAAG,MAAMrB,GAAG,CAACsB,iBAAiB,CAAChB,KAAK,8DAClDP,MAAM;UACToB,IAAI,EAAE,IAAAI,8BAAc,EAACJ,IAAI,CAAC;UAC1BC,KAAK,kCACGA,KAAK,IAAI,CAAC,CAAC;QAClB,GACH;QAEF,OAAO,CAACV,OAAO,CAACc,GAAG,CAACC,KAAK,IAAI,IAAAT,8BAAc,EAACS,KAAK,EAAER,sCAAU,EAAE,IAAI,CAAC,CAAC,EAAEI,IAAI,CAAC;MAChF,CAAC,CAAC;IACN,CAAC;IACDK,YAAY,CAAC;MAAEC,IAAI,EAAEC;IAAiB,CAAC,EAAE;MACrC,OAAO3B,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAM;YAAEuB,IAAI,GAAG,EAAE;YAAEF,IAAI,GAAG,CAAC;UAAW,CAAC,GAAGC,gBAAgB;UAAzBE,IAAI,0CAAKF,gBAAgB;QAC1D,MAAMH,KAAK,GAAG,MAAMzB,GAAG,CAAC+B,WAAW,CAACzB,KAAK;UAAIuB,IAAI;UAAEF;QAAI,GAAKG,IAAI,EAAG;QAEnE,OAAO,IAAAd,8BAAc,EAACS,KAAK,EAAER,sCAAU,EAAE,IAAI,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDe,YAAY,CAAC;MAAEzB,EAAE;MAAEoB;IAAK,CAAC,EAAE;MACvB,OAAO1B,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAM2B,QAAQ,GAAG,MAAM5B,SAAS,CAACC,KAAK,EAAEC,EAAE,CAAC;QAE3C,MAAM2B,KAAK,+DACJD,QAAQ,GACRN,IAAI,CACV;QAED,MAAMF,KAAK,GAAG,MAAMzB,GAAG,CAACmC,WAAW,CAAC7B,KAAK,EAAE2B,QAAQ,CAAC1B,EAAE,EAAE2B,KAAK,CAAC;QAE9D,OAAO,IAAAlB,8BAAc,EAACS,KAAK,EAAER,sCAAU,EAAE,IAAI,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDmB,YAAY,CAAC;MAAE7B;IAAG,CAAC,EAAE;MACjB,OAAON,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAMN,GAAG,CAACqC,WAAW,CAAC/B,KAAK,EAAEC,EAAE,CAAC;QAChC,OAAO,IAAI;MACf,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/record/record.types.d.ts
CHANGED
|
@@ -8,16 +8,20 @@ export interface Location {
|
|
|
8
8
|
}
|
|
9
9
|
export interface SearchRecord<TData extends GenericSearchData = GenericSearchData> extends AcoBaseFields {
|
|
10
10
|
type: string;
|
|
11
|
-
title
|
|
11
|
+
title: string;
|
|
12
12
|
content?: string;
|
|
13
|
-
location
|
|
14
|
-
data
|
|
13
|
+
location: Location;
|
|
14
|
+
data: TData;
|
|
15
|
+
tags: string[];
|
|
15
16
|
}
|
|
16
17
|
export interface ListSearchRecordsWhere {
|
|
17
18
|
type: string;
|
|
18
19
|
location?: {
|
|
19
20
|
folderId: string;
|
|
20
21
|
};
|
|
22
|
+
tags_in?: string[];
|
|
23
|
+
tags_startsWith?: string;
|
|
24
|
+
tags_not_startsWith?: string;
|
|
21
25
|
}
|
|
22
26
|
export interface ListSearchRecordsParams {
|
|
23
27
|
where?: ListSearchRecordsWhere;
|
|
@@ -26,12 +30,13 @@ export interface ListSearchRecordsParams {
|
|
|
26
30
|
limit?: number;
|
|
27
31
|
after?: string | null;
|
|
28
32
|
}
|
|
29
|
-
export declare type CreateSearchRecordParams<TData> = Pick<SearchRecord<TData>, "id" | "title" | "content" | "type" | "location" | "data">;
|
|
33
|
+
export declare type CreateSearchRecordParams<TData> = Pick<SearchRecord<TData>, "id" | "title" | "content" | "type" | "location" | "data" | "tags">;
|
|
30
34
|
export interface UpdateSearchRecordParams<TData extends GenericSearchData> {
|
|
31
35
|
title?: string;
|
|
32
36
|
content?: string;
|
|
33
37
|
location?: Location;
|
|
34
38
|
data?: TData;
|
|
39
|
+
tags?: string[];
|
|
35
40
|
}
|
|
36
41
|
export interface DeleteSearchRecordParams {
|
|
37
42
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["record.types.ts"],"sourcesContent":["import { AcoBaseFields, ListMeta, ListSort } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport type GenericSearchData = {\n [key: string]: any;\n};\n\nexport interface Location {\n folderId: string;\n}\n\nexport interface SearchRecord<TData extends GenericSearchData = GenericSearchData>\n extends AcoBaseFields {\n type: string;\n title
|
|
1
|
+
{"version":3,"names":[],"sources":["record.types.ts"],"sourcesContent":["import { AcoBaseFields, ListMeta, ListSort } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport type GenericSearchData = {\n [key: string]: any;\n};\n\nexport interface Location {\n folderId: string;\n}\n\nexport interface SearchRecord<TData extends GenericSearchData = GenericSearchData>\n extends AcoBaseFields {\n type: string;\n title: string;\n content?: string;\n location: Location;\n data: TData;\n tags: string[];\n}\n\nexport interface ListSearchRecordsWhere {\n type: string;\n location?: {\n folderId: string;\n };\n tags_in?: string[];\n tags_startsWith?: string;\n tags_not_startsWith?: string;\n}\n\nexport interface ListSearchRecordsParams {\n where?: ListSearchRecordsWhere;\n search?: string;\n sort?: ListSort;\n limit?: number;\n after?: string | null;\n}\n\nexport type CreateSearchRecordParams<TData> = Pick<\n SearchRecord<TData>,\n \"id\" | \"title\" | \"content\" | \"type\" | \"location\" | \"data\" | \"tags\"\n>;\n\nexport interface UpdateSearchRecordParams<TData extends GenericSearchData> {\n title?: string;\n content?: string;\n location?: Location;\n data?: TData;\n tags?: string[];\n}\n\nexport interface DeleteSearchRecordParams {\n id: string;\n}\n\nexport interface StorageOperationsGetSearchRecordParams {\n id: string;\n}\n\nexport type StorageOperationsListSearchRecordsParams = ListSearchRecordsParams;\n\nexport interface StorageOperationsCreateSearchRecordParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n data: CreateSearchRecordParams<TData>;\n}\nexport interface StorageOperationsUpdateSearchRecordParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n id: string;\n data: UpdateSearchRecordParams<TData>;\n}\nexport type StorageOperationsDeleteSearchRecordParams = DeleteSearchRecordParams;\n\nexport interface OnSearchRecordBeforeCreateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n input: CreateSearchRecordParams<TData>;\n}\n\nexport interface OnSearchRecordAfterCreateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n record: SearchRecord<TData>;\n}\n\nexport interface OnSearchRecordBeforeUpdateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n original: SearchRecord<TData>;\n input: Record<string, any>;\n}\n\nexport interface OnSearchRecordAfterUpdateTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n original: SearchRecord<TData>;\n record: SearchRecord<TData>;\n input: Record<string, any>;\n}\n\nexport interface OnSearchRecordBeforeDeleteTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n record: SearchRecord<TData>;\n}\n\nexport interface OnSearchRecordAfterDeleteTopicParams<\n TData extends GenericSearchData = GenericSearchData\n> {\n record: SearchRecord<TData>;\n}\n\nexport interface AcoSearchRecordCrud {\n get<TData>(id: string): Promise<SearchRecord<TData>>;\n list<TData>(params: ListSearchRecordsParams): Promise<[SearchRecord<TData>[], ListMeta]>;\n create<TData>(data: CreateSearchRecordParams<TData>): Promise<SearchRecord<TData>>;\n update<TData>(id: string, data: UpdateSearchRecordParams<TData>): Promise<SearchRecord<TData>>;\n delete(id: string): Promise<Boolean>;\n onSearchRecordBeforeCreate: Topic<OnSearchRecordBeforeCreateTopicParams>;\n onSearchRecordAfterCreate: Topic<OnSearchRecordAfterCreateTopicParams>;\n onSearchRecordBeforeUpdate: Topic<OnSearchRecordBeforeUpdateTopicParams>;\n onSearchRecordAfterUpdate: Topic<OnSearchRecordAfterUpdateTopicParams>;\n onSearchRecordBeforeDelete: Topic<OnSearchRecordBeforeDeleteTopicParams>;\n onSearchRecordAfterDelete: Topic<OnSearchRecordAfterDeleteTopicParams>;\n}\nexport interface AcoSearchRecordStorageOperations {\n getRecord<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsGetSearchRecordParams\n ): Promise<SearchRecord<TData>>;\n listRecords<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsListSearchRecordsParams\n ): Promise<[SearchRecord<TData>[], ListMeta]>;\n createRecord<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsCreateSearchRecordParams<TData>\n ): Promise<SearchRecord<TData>>;\n updateRecord<TData extends GenericSearchData = GenericSearchData>(\n params: StorageOperationsUpdateSearchRecordParams<TData>\n ): Promise<SearchRecord<TData>>;\n deleteRecord(params: StorageOperationsDeleteSearchRecordParams): Promise<boolean>;\n}\n"],"mappings":""}
|
package/types.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { SecurityContext, SecurityIdentity } from "@webiny/api-security/types";
|
|
|
5
5
|
import { CmsContext } from "@webiny/api-headless-cms/types";
|
|
6
6
|
import { AcoSearchRecordCrud, AcoSearchRecordStorageOperations } from "./record/record.types";
|
|
7
7
|
import { AcoFolderCrud, AcoFolderStorageOperations } from "./folder/folder.types";
|
|
8
|
+
export * from "./folder/folder.types";
|
|
9
|
+
export * from "./record/record.types";
|
|
8
10
|
export interface User {
|
|
9
11
|
id: string;
|
|
10
12
|
type: string;
|
|
@@ -41,3 +43,7 @@ export declare type AcoStorageOperations = AcoFolderStorageOperations & AcoSearc
|
|
|
41
43
|
export interface AcoContext extends BaseContext, I18NContext, TenancyContext, SecurityContext, CmsContext {
|
|
42
44
|
aco: AdvancedContentOrganisation;
|
|
43
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use AcoContext instead
|
|
48
|
+
*/
|
|
49
|
+
export declare type ACOContext = AcoContext;
|
package/types.js
CHANGED
|
@@ -3,7 +3,34 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
ListSortDirection: true
|
|
8
|
+
};
|
|
6
9
|
exports.ListSortDirection = void 0;
|
|
10
|
+
var _folder = require("./folder/folder.types");
|
|
11
|
+
Object.keys(_folder).forEach(function (key) {
|
|
12
|
+
if (key === "default" || key === "__esModule") return;
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
14
|
+
if (key in exports && exports[key] === _folder[key]) return;
|
|
15
|
+
Object.defineProperty(exports, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _folder[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
var _record = require("./record/record.types");
|
|
23
|
+
Object.keys(_record).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
+
if (key in exports && exports[key] === _record[key]) return;
|
|
27
|
+
Object.defineProperty(exports, key, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _record[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
7
34
|
let ListSortDirection;
|
|
8
35
|
exports.ListSortDirection = ListSortDirection;
|
|
9
36
|
(function (ListSortDirection) {
|
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":"
|
|
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 * from \"./folder/folder.types\";\nexport * from \"./record/record.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":";;;;;;;;;AAQA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAAsC,IAc1BA,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"}
|