@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.3386f66516
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/configurations.d.ts +2 -2
- package/configurations.js +18 -7
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +2 -2
- package/definitions/entry.js +6 -7
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +2 -2
- package/definitions/entryElasticsearch.js +3 -7
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +2 -2
- package/definitions/group.js +3 -7
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +2 -2
- package/definitions/model.js +8 -7
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +2 -2
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +2 -2
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +2 -2
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +2 -2
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +4 -6
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +3 -3
- package/dynamoDb/storage/date.js +80 -46
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +79 -54
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -3
- package/dynamoDb/storage/richText.js +85 -67
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +60 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +43 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +1 -1
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.js +1 -1
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
- package/elasticsearch/indexing/longTextIndexing.js +20 -4
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
- package/elasticsearch/indexing/objectIndexing.js +32 -9
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +15 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +16 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +2 -2
- package/elasticsearch/search/index.js +3 -5
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -3
- package/elasticsearch/search/refSearch.js +27 -16
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -3
- package/elasticsearch/search/timeSearch.js +22 -14
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/entryIndexHelpers.js +33 -18
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/index.d.ts +0 -1
- package/helpers/index.js +0 -13
- package/helpers/index.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +132 -34
- package/index.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +6 -2
- package/operations/entry/dataLoaders.js +31 -13
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +13 -0
- package/operations/entry/elasticsearch/body.js +162 -0
- package/operations/entry/elasticsearch/body.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +9 -0
- package/operations/entry/elasticsearch/fields.js +248 -0
- package/operations/entry/elasticsearch/fields.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
- package/operations/entry/elasticsearch/filtering/exec.js +215 -0
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
- package/operations/entry/elasticsearch/filtering/path.js +52 -0
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/populated.js +30 -0
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/values.js +28 -0
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
- package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
- package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
- package/operations/entry/elasticsearch/initialQuery.js +117 -0
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
- package/operations/entry/elasticsearch/keyword.d.ts +2 -0
- package/operations/entry/elasticsearch/keyword.js +38 -0
- package/operations/entry/elasticsearch/keyword.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
- package/operations/entry/elasticsearch/plugins/operator.js +45 -0
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
- package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +9 -5
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +12 -0
- package/operations/entry/elasticsearch/sort.js +97 -0
- package/operations/entry/elasticsearch/sort.js.map +1 -0
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
- package/operations/entry/elasticsearch/types.d.ts +41 -0
- package/operations/entry/elasticsearch/types.js +5 -0
- package/operations/entry/elasticsearch/types.js.map +1 -0
- package/operations/entry/index.d.ts +2 -4
- package/operations/entry/index.js +473 -374
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +24 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/group/index.d.ts +2 -2
- package/operations/group/index.js +8 -15
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +2 -2
- package/operations/model/index.js +38 -39
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +2 -2
- package/operations/settings/index.js +7 -13
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +5 -11
- package/operations/system/index.js.map +1 -0
- package/package.json +24 -29
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +7 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +11 -5
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +11 -5
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +11 -5
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +31 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +83 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +7 -34
- package/types.js +0 -13
- package/types.js.map +1 -0
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -375
- package/helpers/fields.d.ts +0 -77
- package/helpers/fields.js +0 -174
- package/helpers/operatorPluginsList.d.ts +0 -7
- package/helpers/operatorPluginsList.js +0 -30
- package/helpers/searchPluginsList.d.ts +0 -6
- package/helpers/transformValueForSearch.d.ts +0 -9
- package/helpers/transformValueForSearch.js +0 -26
- package/operations/entry/elasticsearchFields.d.ts +0 -2
- package/operations/entry/elasticsearchFields.js +0 -32
- package/operations/entry/fields.d.ts +0 -3
- package/operations/entry/fields.js +0 -60
- package/operations/system/createElasticsearchTemplate.d.ts +0 -5
- package/operations/system/createElasticsearchTemplate.js +0 -62
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -16
- package/upgrades/utils.d.ts +0 -1
- package/upgrades/utils.js +0 -16
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
- package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
- package/upgrades/v5.0.0/entryValueFixer.js +0 -124
- package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
- package/upgrades/v5.0.0/fieldFinder.js +0 -42
- package/upgrades/v5.0.0/helpers.d.ts +0 -4
- package/upgrades/v5.0.0/helpers.js +0 -57
- package/upgrades/v5.0.0/index.d.ts +0 -4
- package/upgrades/v5.0.0/index.js +0 -232
- package/upgrades/v5.8.0/index.d.ts +0 -4
- package/upgrades/v5.8.0/index.js +0 -426
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createElasticsearchSort = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugins = require("../../../plugins");
|
|
9
|
+
|
|
10
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
11
|
+
|
|
12
|
+
var _keyword = require("./keyword");
|
|
13
|
+
|
|
14
|
+
var _search = require("./plugins/search");
|
|
15
|
+
|
|
16
|
+
var _path = require("./filtering/path");
|
|
17
|
+
|
|
18
|
+
const createElasticsearchSort = params => {
|
|
19
|
+
const {
|
|
20
|
+
sort,
|
|
21
|
+
modelFields,
|
|
22
|
+
plugins
|
|
23
|
+
} = params;
|
|
24
|
+
|
|
25
|
+
if (!sort || sort.length === 0) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const searchPlugins = (0, _search.createSearchPluginList)({
|
|
30
|
+
plugins
|
|
31
|
+
});
|
|
32
|
+
const createFieldPath = (0, _path.createFieldPathFactory)({
|
|
33
|
+
plugins: searchPlugins
|
|
34
|
+
});
|
|
35
|
+
const fieldIdToStorageIdIdMap = {};
|
|
36
|
+
const sortPlugins = Object.values(modelFields).reduce((plugins, field) => {
|
|
37
|
+
/**
|
|
38
|
+
* We do not support sorting by nested fields.
|
|
39
|
+
*/
|
|
40
|
+
if (field.parents.length > 0) {
|
|
41
|
+
return plugins;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
fieldId,
|
|
46
|
+
storageId
|
|
47
|
+
} = field.field;
|
|
48
|
+
fieldIdToStorageIdIdMap[fieldId] = fieldId;
|
|
49
|
+
const {
|
|
50
|
+
path
|
|
51
|
+
} = createFieldPath({
|
|
52
|
+
key: storageId,
|
|
53
|
+
field,
|
|
54
|
+
value: "",
|
|
55
|
+
keyword: false
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
plugins[fieldId] = new _plugins.CmsEntryElasticsearchFieldPlugin({
|
|
62
|
+
unmappedType: field.unmappedType,
|
|
63
|
+
keyword: (0, _keyword.hasKeyword)(field),
|
|
64
|
+
sortable: field.isSortable,
|
|
65
|
+
searchable: field.isSearchable,
|
|
66
|
+
field: fieldId,
|
|
67
|
+
path
|
|
68
|
+
});
|
|
69
|
+
return plugins;
|
|
70
|
+
}, {
|
|
71
|
+
["*"]: new _plugins.CmsEntryElasticsearchFieldPlugin({
|
|
72
|
+
field: _plugins.CmsEntryElasticsearchFieldPlugin.ALL,
|
|
73
|
+
keyword: false
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
const transformedSort = sort.map(value => {
|
|
77
|
+
const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);
|
|
78
|
+
|
|
79
|
+
if (!matched) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const [, fieldId, order] = matched;
|
|
84
|
+
|
|
85
|
+
if (fieldIdToStorageIdIdMap[fieldId]) {
|
|
86
|
+
return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return value;
|
|
90
|
+
}).filter(Boolean);
|
|
91
|
+
return (0, _apiElasticsearch.createSort)({
|
|
92
|
+
fieldPlugins: sortPlugins,
|
|
93
|
+
sort: transformedSort
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
exports.createElasticsearchSort = createElasticsearchSort;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElasticsearchSort","params","sort","modelFields","plugins","length","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","keyword","CmsEntryElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","isSortable","searchable","isSearchable","ALL","transformedSort","map","matched","match","order","filter","Boolean","createSort","fieldPlugins"],"sources":["sort.ts"],"sourcesContent":["import { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryElasticsearchFieldPlugin } from \"~/plugins\";\nimport { createSort } from \"@webiny/api-elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<\n Record<string, CmsEntryElasticsearchFieldPlugin>\n >(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value: \"\",\n keyword: false\n });\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new CmsEntryElasticsearchFieldPlugin({\n unmappedType: field.unmappedType,\n keyword: hasKeyword(field),\n sortable: field.isSortable,\n searchable: field.isSearchable,\n field: fieldId,\n path\n });\n return plugins;\n },\n {\n [\"*\"]: new CmsEntryElasticsearchFieldPlugin({\n field: CmsEntryElasticsearchFieldPlugin.ALL,\n keyword: false\n })\n }\n );\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n"],"mappings":";;;;;;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAQO,MAAMA,uBAAuB,GAAIC,MAAD,IAA4B;EAC/D,MAAM;IAAEC,IAAF;IAAQC,WAAR;IAAqBC;EAArB,IAAiCH,MAAvC;;EAEA,IAAI,CAACC,IAAD,IAASA,IAAI,CAACG,MAAL,KAAgB,CAA7B,EAAgC;IAC5B,OAAO,EAAP;EACH;;EAED,MAAMC,aAAa,GAAG,IAAAC,8BAAA,EAAuB;IACzCH;EADyC,CAAvB,CAAtB;EAIA,MAAMI,eAAe,GAAG,IAAAC,4BAAA,EAAuB;IAC3CL,OAAO,EAAEE;EADkC,CAAvB,CAAxB;EAIA,MAAMI,uBAA+C,GAAG,EAAxD;EAEA,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAP,CAAcV,WAAd,EAA2BW,MAA3B,CAGhB,CAACV,OAAD,EAAUW,KAAV,KAAoB;IAChB;AACZ;AACA;IACY,IAAIA,KAAK,CAACC,OAAN,CAAcX,MAAd,GAAuB,CAA3B,EAA8B;MAC1B,OAAOD,OAAP;IACH;;IACD,MAAM;MAAEa,OAAF;MAAWC;IAAX,IAAyBH,KAAK,CAACA,KAArC;IAEAL,uBAAuB,CAACO,OAAD,CAAvB,GAAmCA,OAAnC;IAEA,MAAM;MAAEE;IAAF,IAAWX,eAAe,CAAC;MAC7BY,GAAG,EAAEF,SADwB;MAE7BH,KAF6B;MAG7BM,KAAK,EAAE,EAHsB;MAI7BC,OAAO,EAAE;IAJoB,CAAD,CAAhC;IAMA;AACZ;AACA;;IACYlB,OAAO,CAACa,OAAD,CAAP,GAAmB,IAAIM,yCAAJ,CAAqC;MACpDC,YAAY,EAAET,KAAK,CAACS,YADgC;MAEpDF,OAAO,EAAE,IAAAG,mBAAA,EAAWV,KAAX,CAF2C;MAGpDW,QAAQ,EAAEX,KAAK,CAACY,UAHoC;MAIpDC,UAAU,EAAEb,KAAK,CAACc,YAJkC;MAKpDd,KAAK,EAAEE,OAL6C;MAMpDE;IANoD,CAArC,CAAnB;IAQA,OAAOf,OAAP;EACH,CAhCe,EAiChB;IACI,CAAC,GAAD,GAAO,IAAImB,yCAAJ,CAAqC;MACxCR,KAAK,EAAEQ,yCAAA,CAAiCO,GADA;MAExCR,OAAO,EAAE;IAF+B,CAArC;EADX,CAjCgB,CAApB;EAyCA,MAAMS,eAAe,GAAG7B,IAAI,CACvB8B,GADmB,CACfX,KAAK,IAAI;IACV,MAAMY,OAAO,GAAGZ,KAAK,CAACa,KAAN,CAAY,+BAAZ,CAAhB;;IACA,IAAI,CAACD,OAAL,EAAc;MACV,OAAO,IAAP;IACH;;IACD,MAAM,GAAGhB,OAAH,EAAYkB,KAAZ,IAAqBF,OAA3B;;IACA,IAAIvB,uBAAuB,CAACO,OAAD,CAA3B,EAAsC;MAClC,OAAQ,GAAEP,uBAAuB,CAACO,OAAD,CAAU,IAAGkB,KAAM,EAApD;IACH;;IAED,OAAOd,KAAP;EACH,CAZmB,EAanBe,MAbmB,CAaZC,OAbY,CAAxB;EAcA,OAAO,IAAAC,4BAAA,EAAW;IACdC,YAAY,EAAE5B,WADA;IAEdT,IAAI,EAAE6B;EAFQ,CAAX,CAAP;AAIH,CA5EM"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use any for input and output because they really can be anything.
|
|
3
|
+
* Plugin, if exists, makes sure that response value is correct.
|
|
4
|
+
*/
|
|
5
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
6
|
+
import { ElasticsearchQuerySearchValuePlugins } from "./types";
|
|
7
|
+
interface Params {
|
|
8
|
+
plugins: ElasticsearchQuerySearchValuePlugins;
|
|
9
|
+
field: CmsModelField;
|
|
10
|
+
value: any;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Transformed value can be anything.
|
|
14
|
+
*/
|
|
15
|
+
export declare const transformValueForSearch: (params: Params) => any;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformValueForSearch = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* We use any for input and output because they really can be anything.
|
|
10
|
+
* Plugin, if exists, makes sure that response value is correct.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Transformed value can be anything.
|
|
15
|
+
*/
|
|
16
|
+
const transformValueForSearch = params => {
|
|
17
|
+
const {
|
|
18
|
+
field,
|
|
19
|
+
plugins,
|
|
20
|
+
value
|
|
21
|
+
} = params;
|
|
22
|
+
const plugin = plugins[field.type];
|
|
23
|
+
|
|
24
|
+
if (!plugin) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return plugin.transform({
|
|
29
|
+
field,
|
|
30
|
+
value
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.transformValueForSearch = transformValueForSearch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["transformValueForSearch","params","field","plugins","value","plugin","type","transform"],"sources":["transformValueForSearch.ts"],"sourcesContent":["/**\n * We use any for input and output because they really can be anything.\n * Plugin, if exists, makes sure that response value is correct.\n */\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { ElasticsearchQuerySearchValuePlugins } from \"./types\";\n\ninterface Params {\n plugins: ElasticsearchQuerySearchValuePlugins;\n field: CmsModelField;\n value: any;\n}\n\n/**\n * Transformed value can be anything.\n */\nexport const transformValueForSearch = (params: Params): any => {\n const { field, plugins, value } = params;\n const plugin = plugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.transform({ field, value });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAIC,MAAD,IAAyB;EAC5D,MAAM;IAAEC,KAAF;IAASC,OAAT;IAAkBC;EAAlB,IAA4BH,MAAlC;EACA,MAAMI,MAAM,GAAGF,OAAO,CAACD,KAAK,CAACI,IAAP,CAAtB;;EACA,IAAI,CAACD,MAAL,EAAa;IACT,OAAOD,KAAP;EACH;;EACD,OAAOC,MAAM,CAACE,SAAP,CAAiB;IAAEL,KAAF;IAASE;EAAT,CAAjB,CAAP;AACH,CAPM"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../../plugins";
|
|
2
|
+
import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
|
|
3
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
4
|
+
/**
|
|
5
|
+
* ./fields
|
|
6
|
+
*/
|
|
7
|
+
declare type ModelFieldPath = string | ((value: string) => string);
|
|
8
|
+
export declare type FieldType = "text" | "date" | "datetime" | "time" | "number" | "boolean" | string;
|
|
9
|
+
export interface ModelFieldParent {
|
|
10
|
+
fieldId: string;
|
|
11
|
+
storageId: string;
|
|
12
|
+
type: FieldType;
|
|
13
|
+
}
|
|
14
|
+
export interface ModelField {
|
|
15
|
+
unmappedType?: string;
|
|
16
|
+
keyword?: boolean;
|
|
17
|
+
isSearchable: boolean;
|
|
18
|
+
isSortable: boolean;
|
|
19
|
+
type: FieldType;
|
|
20
|
+
isSystemField?: boolean;
|
|
21
|
+
field: CmsModelField;
|
|
22
|
+
path?: ModelFieldPath;
|
|
23
|
+
fullTextSearch?: boolean;
|
|
24
|
+
parents: ModelFieldParent[];
|
|
25
|
+
}
|
|
26
|
+
export interface ModelFields {
|
|
27
|
+
[fieldId: string]: ModelField;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* ./plugins/operator
|
|
31
|
+
*/
|
|
32
|
+
export interface ElasticsearchQueryBuilderOperatorPlugins {
|
|
33
|
+
[key: string]: ElasticsearchQueryBuilderOperatorPlugin;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ./plugins/search
|
|
37
|
+
*/
|
|
38
|
+
export interface ElasticsearchQuerySearchValuePlugins {
|
|
39
|
+
[fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\n/**\n * ./fields\n */\ntype ModelFieldPath = string | ((value: string) => string);\n\nexport type FieldType = \"text\" | \"date\" | \"datetime\" | \"time\" | \"number\" | \"boolean\" | string;\n\nexport interface ModelFieldParent {\n fieldId: string;\n storageId: string;\n type: FieldType;\n}\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n isSearchable: boolean;\n isSortable: boolean;\n type: FieldType;\n isSystemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n fullTextSearch?: boolean;\n parents: ModelFieldParent[];\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\n/**\n * ./plugins/operator\n */\nexport interface ElasticsearchQueryBuilderOperatorPlugins {\n [key: string]: ElasticsearchQueryBuilderOperatorPlugin;\n}\n/**\n * ./plugins/search\n */\nexport interface ElasticsearchQuerySearchValuePlugins {\n [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n}\n"],"mappings":""}
|
|
@@ -2,12 +2,10 @@ import { CmsEntryStorageOperations } from "@webiny/api-headless-cms/types";
|
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
3
|
import { Client } from "@elastic/elasticsearch";
|
|
4
4
|
import { PluginsContainer } from "@webiny/plugins";
|
|
5
|
-
export
|
|
6
|
-
export declare const createPublishedType: () => string;
|
|
7
|
-
export interface Params {
|
|
5
|
+
export interface CreateEntriesStorageOperationsParams {
|
|
8
6
|
entity: Entity<any>;
|
|
9
7
|
esEntity: Entity<any>;
|
|
10
8
|
elasticsearch: Client;
|
|
11
9
|
plugins: PluginsContainer;
|
|
12
10
|
}
|
|
13
|
-
export declare const createEntriesStorageOperations: (params:
|
|
11
|
+
export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;
|