@webiny/api-aco 0.0.0-unstable.b02d94bba0 → 0.0.0-unstable.b6408e0dea
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/folder/folder.so.js +4 -4
- package/folder/folder.so.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 +17 -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 +27 -20
- 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/acoRecordId.d.ts +6 -0
- package/utils/acoRecordId.js +33 -0
- package/utils/acoRecordId.js.map +1 -0
- 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/getFieldValues.d.ts +4 -1
- package/utils/getFieldValues.js +7 -10
- package/utils/getFieldValues.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,GAA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C;IACjEO,WAAW,EAAE,4BAA4B;IACzCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
|
package/folder/folder.so.js
CHANGED
|
@@ -49,7 +49,7 @@ const createFolderOperations = params => {
|
|
|
49
49
|
parentId
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
return (0, _getFieldValues.
|
|
52
|
+
return (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
55
|
const checkExistingFolder = ({
|
|
@@ -92,7 +92,7 @@ const createFolderOperations = params => {
|
|
|
92
92
|
sort: (0, _createListSort.createListSort)(sort),
|
|
93
93
|
where: (0, _objectSpread2.default)({}, where || {})
|
|
94
94
|
}));
|
|
95
|
-
return [entries.map(entry => (0, _getFieldValues.
|
|
95
|
+
return [entries.map(entry => (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields)), meta];
|
|
96
96
|
});
|
|
97
97
|
},
|
|
98
98
|
createFolder({
|
|
@@ -109,7 +109,7 @@ const createFolderOperations = params => {
|
|
|
109
109
|
const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, data), {}, {
|
|
110
110
|
parentId: data.parentId || null
|
|
111
111
|
}));
|
|
112
|
-
return (0, _getFieldValues.
|
|
112
|
+
return (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
113
113
|
});
|
|
114
114
|
},
|
|
115
115
|
updateFolder({
|
|
@@ -135,7 +135,7 @@ const createFolderOperations = params => {
|
|
|
135
135
|
|
|
136
136
|
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
|
|
137
137
|
const entry = await cms.updateEntry(model, id, input);
|
|
138
|
-
return (0, _getFieldValues.
|
|
138
|
+
return (0, _getFieldValues.getFolderFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
139
139
|
});
|
|
140
140
|
},
|
|
141
141
|
deleteFolder({
|
package/folder/folder.so.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFolderOperations","params","cms","withModel","createOperationsWrapper","modelName","FOLDER_MODEL_ID","getFolder","id","slug","type","parentId","model","entry","getEntryById","getEntry","where","latest","WebinyError","
|
|
1
|
+
{"version":3,"names":["createFolderOperations","params","cms","withModel","createOperationsWrapper","modelName","FOLDER_MODEL_ID","getFolder","id","slug","type","parentId","model","entry","getEntryById","getEntry","where","latest","WebinyError","getFolderFieldValues","baseFields","checkExistingFolder","existings","listLatestEntries","id_not","limit","length","listFolders","sort","entries","meta","createListSort","map","createFolder","data","createEntry","updateFolder","original","undefined","input","updateEntry","deleteFolder","deleteEntry"],"sources":["folder.so.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { FOLDER_MODEL_ID } from \"./folder.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { createListSort } from \"~/utils/createListSort\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { getFolderFieldValues } from \"~/utils/getFieldValues\";\n\nimport { AcoFolderStorageOperations } from \"./folder.types\";\n\ninterface AcoCheckExistingFolderParams {\n params: {\n type: string;\n slug: string;\n parentId?: string | null;\n };\n id?: string;\n}\n\nexport const createFolderOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoFolderStorageOperations => {\n const { cms } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: FOLDER_MODEL_ID\n });\n\n const getFolder: AcoFolderStorageOperations[\"getFolder\"] = ({ id, slug, type, parentId }) => {\n return withModel(async model => {\n let entry;\n\n if (id) {\n entry = await cms.getEntryById(model, id);\n } else if (slug && type) {\n entry = await cms.getEntry(model, {\n where: { slug, type, parentId, latest: true }\n });\n }\n\n if (!entry) {\n throw new WebinyError(\"Could not load folder.\", \"GET_FOLDER_ERROR\", {\n id,\n slug,\n type,\n parentId\n });\n }\n\n return getFolderFieldValues(entry, baseFields);\n });\n };\n\n const checkExistingFolder = ({ id, params }: AcoCheckExistingFolderParams) => {\n return withModel(async model => {\n const { type, slug, parentId } = params;\n\n const [existings] = await cms.listLatestEntries(model, {\n where: {\n type,\n slug,\n parentId,\n id_not: id\n },\n limit: 1\n });\n\n if (existings.length > 0) {\n throw new WebinyError(\n `Folder with slug \"${slug}\" already exists at this level.`,\n \"FOLDER_ALREADY_EXISTS\",\n {\n id,\n params\n }\n );\n }\n\n return;\n });\n };\n\n return {\n getFolder,\n listFolders(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 => getFolderFieldValues(entry, baseFields)), meta];\n });\n },\n createFolder({ data }) {\n return withModel(async model => {\n await checkExistingFolder({\n params: {\n type: data.type,\n slug: data.slug,\n parentId: data.parentId\n }\n });\n\n const entry = await cms.createEntry(model, {\n ...data,\n parentId: data.parentId || null\n });\n\n return getFolderFieldValues(entry, baseFields);\n });\n },\n updateFolder({ id, data }) {\n return withModel(async model => {\n const { slug, parentId } = data;\n\n const original = await getFolder({ id });\n\n await checkExistingFolder({\n id,\n params: {\n type: original.type,\n slug: slug || original.slug,\n parentId: parentId !== undefined ? parentId : original.parentId // parentId can be `null`\n }\n });\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(model, id, input);\n return getFolderFieldValues(entry, baseFields);\n });\n },\n deleteFolder({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, id);\n return true;\n });\n }\n };\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AAaO,MAAMA,sBAAsB,GAC/BC,MAAwC,IACX;EAC7B,MAAM;IAAEC;EAAI,CAAC,GAAGD,MAAM;EAEtB,MAAM;IAAEE;EAAU,CAAC,GAAG,IAAAC,gDAAuB,8DACtCH,MAAM;IACTI,SAAS,EAAEC;EAAe,GAC5B;EAEF,MAAMC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AAK,IAAI;QAC5B,MAAM;UAAEH,IAAI;UAAEE;QAAS,CAAC,GAAGuB,IAAI;QAE/B,MAAMG,QAAQ,GAAG,MAAM9B,SAAS,CAAC;UAAEC;QAAG,CAAC,CAAC;QAExC,MAAMa,mBAAmB,CAAC;UACtBb,EAAE;UACFP,MAAM,EAAE;YACJS,IAAI,EAAE2B,QAAQ,CAAC3B,IAAI;YACnBD,IAAI,EAAEA,IAAI,IAAI4B,QAAQ,CAAC5B,IAAI;YAC3BE,QAAQ,EAAEA,QAAQ,KAAK2B,SAAS,GAAG3B,QAAQ,GAAG0B,QAAQ,CAAC1B,QAAQ,CAAC;UACpE;QACJ,CAAC,CAAC;;QAEF,MAAM4B,KAAK,+DACJF,QAAQ,GACRH,IAAI,CACV;QAED,MAAMrB,KAAK,GAAG,MAAMX,GAAG,CAACsC,WAAW,CAAC5B,KAAK,EAAEJ,EAAE,EAAE+B,KAAK,CAAC;QACrD,OAAO,IAAApB,oCAAoB,EAACN,KAAK,EAAEO,sCAAU,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDqB,YAAY,CAAC;MAAEjC;IAAG,CAAC,EAAE;MACjB,OAAOL,SAAS,CAAC,MAAMS,KAAK,IAAI;QAC5B,MAAMV,GAAG,CAACwC,WAAW,CAAC9B,KAAK,EAAEJ,EAAE,CAAC;QAChC,OAAO,IAAI;MACf,CAAC,CAAC;IACN;EACJ,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.b6408e0dea",
|
|
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.b6408e0dea",
|
|
31
|
+
"@webiny/api-i18n-ddb": "^0.0.0-unstable.b6408e0dea",
|
|
32
|
+
"@webiny/api-security-so-ddb": "^0.0.0-unstable.b6408e0dea",
|
|
33
|
+
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.b6408e0dea",
|
|
34
|
+
"@webiny/api-wcp": "^0.0.0-unstable.b6408e0dea",
|
|
35
|
+
"@webiny/cli": "^0.0.0-unstable.b6408e0dea",
|
|
36
|
+
"@webiny/handler-aws": "^0.0.0-unstable.b6408e0dea",
|
|
37
|
+
"@webiny/plugins": "^0.0.0-unstable.b6408e0dea",
|
|
38
|
+
"@webiny/project-utils": "^0.0.0-unstable.b6408e0dea",
|
|
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.b6408e0dea",
|
|
45
|
+
"@webiny/api-admin-settings": "0.0.0-unstable.b6408e0dea",
|
|
46
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.b6408e0dea",
|
|
47
|
+
"@webiny/api-i18n": "0.0.0-unstable.b6408e0dea",
|
|
48
|
+
"@webiny/api-security": "0.0.0-unstable.b6408e0dea",
|
|
49
|
+
"@webiny/api-tenancy": "0.0.0-unstable.b6408e0dea",
|
|
50
|
+
"@webiny/error": "0.0.0-unstable.b6408e0dea",
|
|
51
|
+
"@webiny/handler": "0.0.0-unstable.b6408e0dea",
|
|
52
|
+
"@webiny/handler-graphql": "0.0.0-unstable.b6408e0dea",
|
|
53
|
+
"@webiny/pubsub": "0.0.0-unstable.b6408e0dea",
|
|
54
|
+
"@webiny/utils": "0.0.0-unstable.b6408e0dea",
|
|
55
55
|
"lodash": "4.17.21"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "b6408e0deaa6ea55327b8bb35391d9ea71afee65"
|
|
58
58
|
}
|
package/record/record.gql.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.searchRecordSchema = void 0;
|
|
|
7
7
|
var _responses = require("@webiny/handler-graphql/responses");
|
|
8
8
|
var _GraphQLSchemaPlugin = require("@webiny/handler-graphql/plugins/GraphQLSchemaPlugin");
|
|
9
9
|
var _resolve = require("../utils/resolve");
|
|
10
|
+
var _utils = require("@webiny/utils");
|
|
11
|
+
var _acoRecordId = require("../utils/acoRecordId");
|
|
10
12
|
const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
11
13
|
typeDefs: /* GraphQL */`
|
|
12
14
|
type SearchRecord {
|
|
@@ -15,7 +17,8 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
15
17
|
location: SearchLocationType!
|
|
16
18
|
title: String!
|
|
17
19
|
content: String
|
|
18
|
-
data: JSON
|
|
20
|
+
data: JSON!
|
|
21
|
+
tags: [String!]!
|
|
19
22
|
savedOn: DateTime
|
|
20
23
|
createdOn: DateTime
|
|
21
24
|
createdBy: AcoUser
|
|
@@ -36,6 +39,7 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
36
39
|
content: String
|
|
37
40
|
location: SearchLocationInput!
|
|
38
41
|
data: JSON
|
|
42
|
+
tags: [String!]
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
input SearchRecordUpdateInput {
|
|
@@ -43,11 +47,15 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
43
47
|
content: String
|
|
44
48
|
location: SearchLocationInput
|
|
45
49
|
data: JSON
|
|
50
|
+
tags: [String!]
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
input SearchRecordListWhereInput {
|
|
49
54
|
type: String!
|
|
50
55
|
location: SearchLocationInput
|
|
56
|
+
tags_in: [String!]
|
|
57
|
+
tags_startsWith: String
|
|
58
|
+
tags_not_startsWith: String
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
type SearchRecordResponse {
|
|
@@ -79,6 +87,14 @@ const searchRecordSchema = new _GraphQLSchemaPlugin.GraphQLSchemaPlugin({
|
|
|
79
87
|
}
|
|
80
88
|
`,
|
|
81
89
|
resolvers: {
|
|
90
|
+
SearchRecord: {
|
|
91
|
+
id: async parent => {
|
|
92
|
+
const {
|
|
93
|
+
id
|
|
94
|
+
} = (0, _utils.parseIdentifier)(parent.id);
|
|
95
|
+
return (0, _acoRecordId.removeAcoRecordPrefix)(id);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
82
98
|
SearchQuery: {
|
|
83
99
|
getRecord: async (_, {
|
|
84
100
|
id
|
package/record/record.gql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["searchRecordSchema","GraphQLSchemaPlugin","typeDefs","resolvers","SearchQuery","getRecord","_","
|
|
1
|
+
{"version":3,"names":["searchRecordSchema","GraphQLSchemaPlugin","typeDefs","resolvers","SearchRecord","id","parent","parseIdentifier","removeAcoRecordPrefix","SearchQuery","getRecord","_","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\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { removeAcoRecordPrefix } from \"~/utils/acoRecordId\";\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 SearchRecord: {\n id: async parent => {\n const { id } = parseIdentifier(parent.id);\n return removeAcoRecordPrefix(id);\n }\n },\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;AAGA;AACA;AAEO,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,YAAY,EAAE;MACVC,EAAE,EAAE,MAAMC,MAAM,IAAI;QAChB,MAAM;UAAED;QAAG,CAAC,GAAG,IAAAE,sBAAe,EAACD,MAAM,CAACD,EAAE,CAAC;QACzC,OAAO,IAAAG,kCAAqB,EAACH,EAAE,CAAC;MACpC;IACJ,CAAC;IACDI,WAAW,EAAE;MACTC,SAAS,EAAE,OAAOC,CAAC,EAAE;QAAEN;MAAG,CAAC,EAAEO,OAAO,KAAK;QACrC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACC,GAAG,CAACX,EAAE,CAAC,CAAC;MACpD,CAAC;MACDY,WAAW,EAAE,OAAON,CAAC,EAAEO,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,OAAOf,CAAC,EAAE;QAAEgB;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,OAAOlB,CAAC,EAAE;QAAEN,EAAE;QAAEsB;MAAK,CAAC,EAAEf,OAAO,KAAK;QAC9C,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACe,MAAM,CAACzB,EAAE,EAAEsB,IAAI,CAAC,CAAC;MAC7D,CAAC;MACDI,YAAY,EAAE,OAAOpB,CAAC,EAAE;QAAEN;MAAG,CAAC,EAAEO,OAAO,KAAK;QACxC,OAAO,IAAAC,gBAAO,EAAC,MAAMD,OAAO,CAACE,GAAG,CAACC,MAAM,CAACiB,MAAM,CAAC3B,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,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__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
|
+
var _acoRecordId = require("../utils/acoRecordId");
|
|
17
|
+
const _excluded = ["tags", "data"];
|
|
16
18
|
const createSearchRecordOperations = params => {
|
|
17
19
|
const {
|
|
18
|
-
cms
|
|
19
|
-
getCmsContext
|
|
20
|
+
cms
|
|
20
21
|
} = params;
|
|
21
22
|
const {
|
|
22
23
|
withModel
|
|
23
24
|
} = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
24
25
|
modelName: _record.SEARCH_RECORD_MODEL_ID
|
|
25
26
|
}));
|
|
26
|
-
const getRecord = async (
|
|
27
|
-
const context = getCmsContext();
|
|
28
|
-
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
29
|
-
model: initialModel,
|
|
30
|
-
plugins: context.plugins
|
|
31
|
-
});
|
|
32
|
-
|
|
27
|
+
const getRecord = async (model, id) => {
|
|
33
28
|
/**
|
|
34
29
|
* The record "id" has been passed by the original entry.
|
|
35
30
|
* We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.
|
|
36
31
|
*/
|
|
37
32
|
const revisions = await cms.storageOperations.entries.getLatestByIds(model, {
|
|
38
|
-
ids: [id]
|
|
33
|
+
ids: [(0, _acoRecordId.attachAcoRecordPrefix)(id)]
|
|
39
34
|
});
|
|
40
35
|
if (revisions.length === 0) {
|
|
41
36
|
throw new _error.default("Record not found.", "NOT_FOUND", {
|
|
@@ -50,7 +45,7 @@ const createSearchRecordOperations = params => {
|
|
|
50
45
|
}) {
|
|
51
46
|
return withModel(async model => {
|
|
52
47
|
const record = await getRecord(model, id);
|
|
53
|
-
return (0, _getFieldValues.
|
|
48
|
+
return (0, _getFieldValues.getRecordFieldValues)(record, _createAcoStorageOperations.baseFields);
|
|
54
49
|
});
|
|
55
50
|
},
|
|
56
51
|
listRecords(params) {
|
|
@@ -63,15 +58,25 @@ const createSearchRecordOperations = params => {
|
|
|
63
58
|
sort: (0, _createListSort.createListSort)(sort),
|
|
64
59
|
where: (0, _objectSpread2.default)({}, where || {})
|
|
65
60
|
}));
|
|
66
|
-
return [entries.map(entry => (0, _getFieldValues.
|
|
61
|
+
return [entries.map(entry => (0, _getFieldValues.getRecordFieldValues)(entry, _createAcoStorageOperations.baseFields)), meta];
|
|
67
62
|
});
|
|
68
63
|
},
|
|
69
64
|
createRecord({
|
|
70
|
-
data
|
|
65
|
+
data: SearchRecordData
|
|
71
66
|
}) {
|
|
72
67
|
return withModel(async model => {
|
|
73
|
-
const
|
|
74
|
-
|
|
68
|
+
const {
|
|
69
|
+
tags = [],
|
|
70
|
+
data = {}
|
|
71
|
+
} = SearchRecordData,
|
|
72
|
+
rest = (0, _objectWithoutProperties2.default)(SearchRecordData, _excluded);
|
|
73
|
+
const entry = await cms.createEntry(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
74
|
+
tags,
|
|
75
|
+
data
|
|
76
|
+
}, rest), {}, {
|
|
77
|
+
id: (0, _acoRecordId.attachAcoRecordPrefix)(rest.id)
|
|
78
|
+
}));
|
|
79
|
+
return (0, _getFieldValues.getRecordFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
75
80
|
});
|
|
76
81
|
},
|
|
77
82
|
updateRecord({
|
|
@@ -79,17 +84,19 @@ const createSearchRecordOperations = params => {
|
|
|
79
84
|
data
|
|
80
85
|
}) {
|
|
81
86
|
return withModel(async model => {
|
|
82
|
-
const original = await getRecord(
|
|
87
|
+
const original = await this.getRecord({
|
|
88
|
+
id
|
|
89
|
+
});
|
|
83
90
|
const input = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
|
|
84
|
-
const entry = await cms.updateEntry(model, original.id, input);
|
|
85
|
-
return (0, _getFieldValues.
|
|
91
|
+
const entry = await cms.updateEntry(model, (0, _acoRecordId.attachAcoRecordPrefix)(original.id), input);
|
|
92
|
+
return (0, _getFieldValues.getRecordFieldValues)(entry, _createAcoStorageOperations.baseFields);
|
|
86
93
|
});
|
|
87
94
|
},
|
|
88
95
|
deleteRecord({
|
|
89
96
|
id
|
|
90
97
|
}) {
|
|
91
98
|
return withModel(async model => {
|
|
92
|
-
await cms.deleteEntry(model, id);
|
|
99
|
+
await cms.deleteEntry(model, (0, _acoRecordId.attachAcoRecordPrefix)(id));
|
|
93
100
|
return true;
|
|
94
101
|
});
|
|
95
102
|
}
|
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","attachAcoRecordPrefix","length","WebinyError","record","getRecordFieldValues","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 { getRecordFieldValues } from \"~/utils/getFieldValues\";\nimport { AcoSearchRecordStorageOperations } from \"./record.types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { attachAcoRecordPrefix } from \"~/utils/acoRecordId\";\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: [attachAcoRecordPrefix(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 getRecordFieldValues(record, baseFields);\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 => getRecordFieldValues(entry, baseFields)), 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, {\n tags,\n data,\n ...rest,\n id: attachAcoRecordPrefix(rest.id)\n });\n\n return getRecordFieldValues(entry, baseFields);\n });\n },\n updateRecord(this: AcoSearchRecordStorageOperations, { id, data }) {\n return withModel(async model => {\n const original = await this.getRecord({ id });\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(\n model,\n attachAcoRecordPrefix(original.id),\n input\n );\n\n return getRecordFieldValues(entry, baseFields);\n });\n },\n deleteRecord({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, attachAcoRecordPrefix(id));\n return true;\n });\n }\n };\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAGA;AAA4D;AAErD,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,CAAC,IAAAC,kCAAqB,EAACN,EAAE,CAAC;IACnC,CAAC,CAAC;IAEF,IAAIC,SAAS,CAACM,MAAM,KAAK,CAAC,EAAE;MACxB,MAAM,IAAIC,cAAW,CAAC,mBAAmB,EAAE,WAAW,EAAE;QACpDR;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,MAAMU,MAAM,GAAG,MAAMX,SAAS,CAACC,KAAK,EAAEC,EAAE,CAAC;QACzC,OAAO,IAAAU,oCAAoB,EAACD,MAAM,EAAEE,sCAAU,CAAC;MACnD,CAAC,CAAC;IACN,CAAC;IACDC,WAAW,CAACpB,MAAM,EAAE;MAChB,OAAOE,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAM;UAAEc,IAAI;UAAEC;QAAM,CAAC,GAAGtB,MAAM;QAE9B,MAAM,CAAC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AK,CACR;QAED,OAAO,IAAAlB,oCAAoB,EAACS,KAAK,EAAER,sCAAU,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDmB,YAAY,CAAC;MAAE9B;IAAG,CAAC,EAAE;MACjB,OAAON,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAMN,GAAG,CAACsC,WAAW,CAAChC,KAAK,EAAE,IAAAO,kCAAqB,EAACN,EAAE,CAAC,CAAC;QACvD,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removeAcoRecordPrefix = exports.attachAcoRecordPrefix = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* !!! DO NOT CHANGE THIS !!!
|
|
9
|
+
* If this is changed, you will need to create new migration which changes the IDs for the users.
|
|
10
|
+
*
|
|
11
|
+
* packages/migrations/src/migrations/5.35.0/006/ddb/PageDataMigration.ts:236
|
|
12
|
+
* packages/migrations/src/migrations/5.35.0/006/ddb-es/PageDataMigration.ts:419
|
|
13
|
+
*/
|
|
14
|
+
const WBY_ACO_PREFIX = "wby-aco-";
|
|
15
|
+
/**
|
|
16
|
+
* 006
|
|
17
|
+
* PageDataMigration in ddb-es and ddb
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const attachAcoRecordPrefix = id => {
|
|
21
|
+
if (id.startsWith(WBY_ACO_PREFIX)) {
|
|
22
|
+
return id;
|
|
23
|
+
}
|
|
24
|
+
return `${WBY_ACO_PREFIX}${id}`;
|
|
25
|
+
};
|
|
26
|
+
exports.attachAcoRecordPrefix = attachAcoRecordPrefix;
|
|
27
|
+
const removeAcoRecordPrefix = id => {
|
|
28
|
+
if (id.startsWith(WBY_ACO_PREFIX) === false) {
|
|
29
|
+
return id;
|
|
30
|
+
}
|
|
31
|
+
return id.substring(WBY_ACO_PREFIX.length);
|
|
32
|
+
};
|
|
33
|
+
exports.removeAcoRecordPrefix = removeAcoRecordPrefix;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WBY_ACO_PREFIX","attachAcoRecordPrefix","id","startsWith","removeAcoRecordPrefix","substring","length"],"sources":["acoRecordId.ts"],"sourcesContent":["/**\n * !!! DO NOT CHANGE THIS !!!\n * If this is changed, you will need to create new migration which changes the IDs for the users.\n *\n * packages/migrations/src/migrations/5.35.0/006/ddb/PageDataMigration.ts:236\n * packages/migrations/src/migrations/5.35.0/006/ddb-es/PageDataMigration.ts:419\n */\nconst WBY_ACO_PREFIX = \"wby-aco-\";\n/**\n * 006\n * PageDataMigration in ddb-es and ddb\n */\n\nexport const attachAcoRecordPrefix = (id: string) => {\n if (id.startsWith(WBY_ACO_PREFIX)) {\n return id;\n }\n return `${WBY_ACO_PREFIX}${id}`;\n};\n\nexport const removeAcoRecordPrefix = (id: string) => {\n if (id.startsWith(WBY_ACO_PREFIX) === false) {\n return id;\n }\n return id.substring(WBY_ACO_PREFIX.length);\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,UAAU;AACjC;AACA;AACA;AACA;;AAEO,MAAMC,qBAAqB,GAAIC,EAAU,IAAK;EACjD,IAAIA,EAAE,CAACC,UAAU,CAACH,cAAc,CAAC,EAAE;IAC/B,OAAOE,EAAE;EACb;EACA,OAAQ,GAAEF,cAAe,GAAEE,EAAG,EAAC;AACnC,CAAC;AAAC;AAEK,MAAME,qBAAqB,GAAIF,EAAU,IAAK;EACjD,IAAIA,EAAE,CAACC,UAAU,CAACH,cAAc,CAAC,KAAK,KAAK,EAAE;IACzC,OAAOE,EAAE;EACb;EACA,OAAOA,EAAE,CAACG,SAAS,CAACL,cAAc,CAACM,MAAM,CAAC;AAC9C,CAAC;AAAC"}
|
|
@@ -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"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
2
|
-
|
|
2
|
+
import { SearchRecord } from "../record/record.types";
|
|
3
|
+
import { Folder } from "../folder/folder.types";
|
|
4
|
+
export declare function getRecordFieldValues(entry: CmsEntry, fields: string[]): SearchRecord<any>;
|
|
5
|
+
export declare function getFolderFieldValues(entry: CmsEntry, fields: string[]): Folder;
|
package/utils/getFieldValues.js
CHANGED
|
@@ -4,16 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.getFolderFieldValues = getFolderFieldValues;
|
|
8
|
+
exports.getRecordFieldValues = getRecordFieldValues;
|
|
8
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
10
|
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = (0, _utils.parseIdentifier)(entry.id);
|
|
16
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _pick.default)(entry, fields)), entry.values), useEntryId && {
|
|
17
|
-
id
|
|
18
|
-
});
|
|
11
|
+
function getRecordFieldValues(entry, fields) {
|
|
12
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _pick.default)(entry, fields)), entry.values);
|
|
13
|
+
}
|
|
14
|
+
function getFolderFieldValues(entry, fields) {
|
|
15
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _pick.default)(entry, fields)), entry.values);
|
|
19
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getRecordFieldValues","entry","fields","pick","values","getFolderFieldValues"],"sources":["getFieldValues.ts"],"sourcesContent":["import pick from \"lodash/pick\";\nimport { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport { SearchRecord } from \"~/record/record.types\";\nimport { Folder } from \"~/folder/folder.types\";\n\nexport function getRecordFieldValues(entry: CmsEntry, fields: string[]) {\n return {\n ...pick(entry, fields),\n ...entry.values\n } as SearchRecord<any>;\n}\n\nexport function getFolderFieldValues(entry: CmsEntry, fields: string[]) {\n return { ...pick(entry, fields), ...entry.values } as Folder;\n}\n"],"mappings":";;;;;;;;;AAAA;AAKO,SAASA,oBAAoB,CAACC,KAAe,EAAEC,MAAgB,EAAE;EACpE,mEACO,IAAAC,aAAI,EAACF,KAAK,EAAEC,MAAM,CAAC,GACnBD,KAAK,CAACG,MAAM;AAEvB;AAEO,SAASC,oBAAoB,CAACJ,KAAe,EAAEC,MAAgB,EAAE;EACpE,mEAAY,IAAAC,aAAI,EAACF,KAAK,EAAEC,MAAM,CAAC,GAAKD,KAAK,CAACG,MAAM;AACpD"}
|
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"}
|