@webiny/api-headless-cms-ddb-es 5.33.1 → 5.33.2-beta.1
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/elasticsearch/createElasticsearchIndex.js +2 -2
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/indices/base.js +2 -10
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.d.ts +1 -1
- package/elasticsearch/indices/japanese.js +2 -10
- package/elasticsearch/indices/japanese.js.map +1 -1
- package/helpers/createElasticsearchQueryBody.js +20 -22
- package/helpers/createElasticsearchQueryBody.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +66 -7
- package/index.js.map +1 -1
- package/operations/entry/index.js +6 -10
- package/operations/entry/index.js.map +1 -1
- package/package.json +14 -14
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +4 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +83 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +5 -2
- package/types.js.map +1 -1
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -10
- package/upgrades/index.js.map +0 -1
|
@@ -11,7 +11,7 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
11
11
|
|
|
12
12
|
var _CmsEntryElasticsearchIndexPlugin = require("../plugins/CmsEntryElasticsearchIndexPlugin");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
15
15
|
|
|
16
16
|
var _configurations = require("../configurations");
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ const createElasticsearchIndex = async params => {
|
|
|
21
21
|
plugins: container,
|
|
22
22
|
model
|
|
23
23
|
} = params;
|
|
24
|
-
const plugin = (0,
|
|
24
|
+
const plugin = (0, _apiElasticsearch.getLastAddedIndexPlugin)({
|
|
25
25
|
container,
|
|
26
26
|
type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
|
|
27
27
|
locale: model.locale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createElasticsearchIndex","params","elasticsearch","plugins","container","model","plugin","getLastAddedIndexPlugin","type","CmsEntryElasticsearchIndexPlugin","locale","index","configurations","es","response","indices","exists","body","create","ex","WebinyError","message","code","error","tenant"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch
|
|
1
|
+
{"version":3,"names":["createElasticsearchIndex","params","elasticsearch","plugins","container","model","plugin","getLastAddedIndexPlugin","type","CmsEntryElasticsearchIndexPlugin","locale","index","configurations","es","response","indices","exists","body","create","ex","WebinyError","message","code","error","tenant"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreateElasticsearchIndexParams {\n elasticsearch: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { elasticsearch, plugins: container, model } = params;\n\n const plugin = getLastAddedIndexPlugin<CmsEntryElasticsearchIndexPlugin>({\n container,\n type: CmsEntryElasticsearchIndexPlugin.type,\n locale: model.locale\n });\n\n const { index } = configurations.es({\n model\n });\n\n try {\n const response = await elasticsearch.indices.exists({\n index\n });\n if (response.body) {\n return;\n }\n await elasticsearch.indices.create({\n index,\n body: plugin.body\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create Elasticsearch index for the Headless CMS model.\",\n ex.code || \"CMS_ELASTICSEARCH_INDEX_ERROR\",\n {\n error: ex,\n type: CmsEntryElasticsearchIndexPlugin.type,\n locale: model.locale,\n tenant: model.tenant,\n body: plugin.body\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGA;;AACA;;AACA;;AASO,MAAMA,wBAAwB,GAAG,MAAOC,MAAP,IAAkD;EACtF,MAAM;IAAEC,aAAF;IAAiBC,OAAO,EAAEC,SAA1B;IAAqCC;EAArC,IAA+CJ,MAArD;EAEA,MAAMK,MAAM,GAAG,IAAAC,yCAAA,EAA0D;IACrEH,SADqE;IAErEI,IAAI,EAAEC,kEAAA,CAAiCD,IAF8B;IAGrEE,MAAM,EAAEL,KAAK,CAACK;EAHuD,CAA1D,CAAf;;EAMA,MAAM;IAAEC;EAAF,IAAYC,8BAAA,CAAeC,EAAf,CAAkB;IAChCR;EADgC,CAAlB,CAAlB;;EAIA,IAAI;IACA,MAAMS,QAAQ,GAAG,MAAMZ,aAAa,CAACa,OAAd,CAAsBC,MAAtB,CAA6B;MAChDL;IADgD,CAA7B,CAAvB;;IAGA,IAAIG,QAAQ,CAACG,IAAb,EAAmB;MACf;IACH;;IACD,MAAMf,aAAa,CAACa,OAAd,CAAsBG,MAAtB,CAA6B;MAC/BP,KAD+B;MAE/BM,IAAI,EAAEX,MAAM,CAACW;IAFkB,CAA7B,CAAN;EAIH,CAXD,CAWE,OAAOE,EAAP,EAAW;IACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,kEADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,+BAFT,EAGF;MACIC,KAAK,EAAEJ,EADX;MAEIX,IAAI,EAAEC,kEAAA,CAAiCD,IAF3C;MAGIE,MAAM,EAAEL,KAAK,CAACK,MAHlB;MAIIc,MAAM,EAAEnB,KAAK,CAACmB,MAJlB;MAKIP,IAAI,EAAEX,MAAM,CAACW;IALjB,CAHE,CAAN;EAWH;AACJ,CArCM"}
|
package/elasticsearch/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => (import("../types").CmsModelFieldToElasticsearchPlugin[] | import("
|
|
1
|
+
declare const _default: () => (import("../types").CmsModelFieldToElasticsearchPlugin[] | import("..").CmsEntryElasticsearchQueryBuilderValueSearchPlugin[])[];
|
|
2
2
|
export default _default;
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.base = void 0;
|
|
9
7
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _base = require("@webiny/api-elasticsearch/indexConfiguration/base");
|
|
8
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
13
9
|
|
|
14
10
|
var _CmsEntryElasticsearchIndexPlugin = require("../../plugins/CmsEntryElasticsearchIndexPlugin");
|
|
15
11
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
12
|
const base = new _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin({
|
|
21
|
-
body:
|
|
13
|
+
body: (0, _apiElasticsearch.getBaseConfiguration)()
|
|
22
14
|
});
|
|
23
15
|
exports.base = base;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["base","CmsEntryElasticsearchIndexPlugin","body","
|
|
1
|
+
{"version":3,"names":["base","CmsEntryElasticsearchIndexPlugin","body","getBaseConfiguration"],"sources":["base.ts"],"sourcesContent":["import { getBaseConfiguration } from \"@webiny/api-elasticsearch\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\n\nexport const base = new CmsEntryElasticsearchIndexPlugin({\n body: getBaseConfiguration()\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,IAAI,GAAG,IAAIC,kEAAJ,CAAqC;EACrDC,IAAI,EAAE,IAAAC,sCAAA;AAD+C,CAArC,CAAb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const elasticsearchIndexPlugins: () => import("
|
|
1
|
+
export declare const elasticsearchIndexPlugins: () => import("../..").CmsEntryElasticsearchIndexPlugin[];
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.japanese = void 0;
|
|
9
7
|
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
8
|
var _CmsEntryElasticsearchIndexPlugin = require("../../plugins/CmsEntryElasticsearchIndexPlugin");
|
|
13
9
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
19
11
|
|
|
20
12
|
const japanese = new _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin({
|
|
21
|
-
body:
|
|
13
|
+
body: (0, _apiElasticsearch.getJapaneseConfiguration)(),
|
|
22
14
|
locales: ["ja", "ja-jp"]
|
|
23
15
|
});
|
|
24
16
|
exports.japanese = japanese;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["japanese","CmsEntryElasticsearchIndexPlugin","body","
|
|
1
|
+
{"version":3,"names":["japanese","CmsEntryElasticsearchIndexPlugin","body","getJapaneseConfiguration","locales"],"sources":["japanese.ts"],"sourcesContent":["import { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { getJapaneseConfiguration } from \"@webiny/api-elasticsearch\";\n\nexport const japanese = new CmsEntryElasticsearchIndexPlugin({\n body: getJapaneseConfiguration(),\n locales: [\"ja\", \"ja-jp\"]\n});\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,QAAQ,GAAG,IAAIC,kEAAJ,CAAqC;EACzDC,IAAI,EAAE,IAAAC,0CAAA,GADmD;EAEzDC,OAAO,EAAE,CAAC,IAAD,EAAO,OAAP;AAFgD,CAArC,CAAjB"}
|
|
@@ -15,16 +15,12 @@ var _transformValueForSearch = require("./transformValueForSearch");
|
|
|
15
15
|
|
|
16
16
|
var _searchPluginsList = require("./searchPluginsList");
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _sort = require("@webiny/api-elasticsearch/sort");
|
|
18
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
21
19
|
|
|
22
20
|
var _fields = require("./fields");
|
|
23
21
|
|
|
24
22
|
var _CmsEntryElasticsearchFieldPlugin = require("../plugins/CmsEntryElasticsearchFieldPlugin");
|
|
25
23
|
|
|
26
|
-
var _where = require("@webiny/api-elasticsearch/where");
|
|
27
|
-
|
|
28
24
|
var _entry = require("../operations/entry");
|
|
29
25
|
|
|
30
26
|
var _CmsEntryElasticsearchQueryModifierPlugin = require("../plugins/CmsEntryElasticsearchQueryModifierPlugin");
|
|
@@ -33,10 +29,6 @@ var _CmsEntryElasticsearchSortModifierPlugin = require("../plugins/CmsEntryElast
|
|
|
33
29
|
|
|
34
30
|
var _CmsEntryElasticsearchBodyModifierPlugin = require("../plugins/CmsEntryElasticsearchBodyModifierPlugin");
|
|
35
31
|
|
|
36
|
-
var _operators = require("@webiny/api-elasticsearch/operators");
|
|
37
|
-
|
|
38
|
-
var _normalize = require("@webiny/api-elasticsearch/normalize");
|
|
39
|
-
|
|
40
32
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
33
|
|
|
42
34
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -98,7 +90,7 @@ const createElasticsearchSortParams = args => {
|
|
|
98
90
|
|
|
99
91
|
return value;
|
|
100
92
|
}).filter(Boolean);
|
|
101
|
-
return (0,
|
|
93
|
+
return (0, _apiElasticsearch.createSort)({
|
|
102
94
|
fieldPlugins: sortPlugins,
|
|
103
95
|
sort: transformedSort
|
|
104
96
|
});
|
|
@@ -366,7 +358,7 @@ const applyFullTextSearch = params => {
|
|
|
366
358
|
query_string: {
|
|
367
359
|
allow_leading_wildcard: true,
|
|
368
360
|
fields: fieldPaths,
|
|
369
|
-
query: (0,
|
|
361
|
+
query: (0, _apiElasticsearch.normalizeValue)(term),
|
|
370
362
|
default_operator: "or"
|
|
371
363
|
}
|
|
372
364
|
});
|
|
@@ -414,7 +406,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
414
406
|
return query;
|
|
415
407
|
}
|
|
416
408
|
|
|
417
|
-
const operatorPlugins = (0,
|
|
409
|
+
const operatorPlugins = (0, _apiElasticsearch.getElasticsearchOperatorPluginsByLocale)(plugins, model.locale);
|
|
418
410
|
|
|
419
411
|
for (const key in where) {
|
|
420
412
|
if (where.hasOwnProperty(key) === false) {
|
|
@@ -436,7 +428,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
436
428
|
const {
|
|
437
429
|
field,
|
|
438
430
|
operator
|
|
439
|
-
} = (0,
|
|
431
|
+
} = (0, _apiElasticsearch.parseWhereKey)(key);
|
|
440
432
|
/**
|
|
441
433
|
* TODO This will be required until the storage operations receive the fieldId instead of field storageId.
|
|
442
434
|
* TODO For this to work without field searching, we need to refactor how the query looks like.
|
|
@@ -484,7 +476,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
484
476
|
for (const whereKey in value) {
|
|
485
477
|
const {
|
|
486
478
|
operator
|
|
487
|
-
} = (0,
|
|
479
|
+
} = (0, _apiElasticsearch.parseWhereKey)(whereKey);
|
|
488
480
|
applyFiltering({
|
|
489
481
|
query,
|
|
490
482
|
modelField,
|
|
@@ -533,15 +525,20 @@ const createElasticsearchQueryBody = params => {
|
|
|
533
525
|
const modelFields = (0, _fields.createModelFields)(plugins, model);
|
|
534
526
|
const searchPlugins = (0, _searchPluginsList.searchPluginsList)(plugins);
|
|
535
527
|
const fullTextSearchFields = [];
|
|
528
|
+
/**
|
|
529
|
+
* No point in going through fields if there is no search performed.
|
|
530
|
+
*/
|
|
536
531
|
|
|
537
|
-
|
|
538
|
-
|
|
532
|
+
if (!!search) {
|
|
533
|
+
for (const fieldId of fields) {
|
|
534
|
+
const field = model.fields.find(f => f.fieldId === fieldId);
|
|
539
535
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
536
|
+
if (!field) {
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
543
539
|
|
|
544
|
-
|
|
540
|
+
fullTextSearchFields.push(field);
|
|
541
|
+
}
|
|
545
542
|
}
|
|
546
543
|
|
|
547
544
|
const query = execElasticsearchBuildQueryPlugins({
|
|
@@ -599,7 +596,7 @@ const createElasticsearchQueryBody = params => {
|
|
|
599
596
|
sort,
|
|
600
597
|
size: (limit || 0) + 1,
|
|
601
598
|
// eslint-disable-next-line
|
|
602
|
-
search_after: (0,
|
|
599
|
+
search_after: (0, _apiElasticsearch.decodeCursor)(after),
|
|
603
600
|
// eslint-disable-next-line
|
|
604
601
|
track_total_hits: true
|
|
605
602
|
};
|
|
@@ -610,7 +607,8 @@ const createElasticsearchQueryBody = params => {
|
|
|
610
607
|
for (const pl of bodyPlugins) {
|
|
611
608
|
pl.modifyBody({
|
|
612
609
|
body,
|
|
613
|
-
model
|
|
610
|
+
model,
|
|
611
|
+
where
|
|
614
612
|
});
|
|
615
613
|
}
|
|
616
614
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["specialFields","noKeywordFields","createElasticsearchSortParams","args","sort","modelFields","parentPath","searchPlugins","length","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","plugins","modelField","searchPlugin","type","fieldId","storageId","field","CmsEntryElasticsearchFieldPlugin","unmappedType","keyword","hasKeyword","sortable","isSortable","searchable","isSearchable","path","createFieldPath","key","transformedSort","map","value","matched","match","order","filter","Boolean","createSort","fieldPlugins","findFieldByFieldId","model","fields","find","createInitialQueryValue","params","where","initialWhere","query","must","must_not","should","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","push","term","tenant","locale","published","createPublishedType","latest","createLatestType","WebinyError","createPath","id","isSystemField","includes","nonRefFieldTypes","isRefFieldFiltering","typeOf","Array","isArray","Date","toISOString","fieldPathFactory","plugin","fieldPath","keywordValue","applyFiltering","operator","initialValue","operatorPlugins","fieldSearchPlugin","transformValueForSearch","apply","basePath","applyFullTextSearch","fieldPaths","collection","query_string","allow_leading_wildcard","normalizeValue","default_operator","execElasticsearchBuildQueryPlugins","fullTextSearch","sf","keys","getElasticsearchOperatorPluginsByLocale","hasOwnProperty","undefined","parseWhereKey","cmsModelField","cmsField","whereKey","createElasticsearchQueryBody","after","limit","initialSort","search","createModelFields","searchPluginsList","fullTextSearchFields","f","queryPlugins","byType","CmsEntryElasticsearchQueryModifierPlugin","pl","modelId","modifyQuery","CmsEntryElasticsearchSortModifierPlugin","modifySort","body","bool","size","search_after","decodeCursor","track_total_hits","bodyPlugins","CmsEntryElasticsearchBodyModifierPlugin","modifyBody"],"sources":["createElasticsearchQueryBody.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"./transformValueForSearch\";\nimport { searchPluginsList } from \"./searchPluginsList\";\nimport {\n CmsEntryListParams,\n CmsEntryListSort,\n CmsEntryListWhere,\n CmsModel,\n CmsModelField\n} from \"@webiny/api-headless-cms/types\";\nimport {\n SearchBody as esSearchBody,\n Sort as esSort,\n ElasticsearchBoolQueryConfig\n} from \"@webiny/api-elasticsearch/types\";\nimport { decodeCursor } from \"@webiny/api-elasticsearch/cursors\";\nimport { createSort } from \"@webiny/api-elasticsearch/sort\";\nimport { createModelFields, ModelField, ModelFields } from \"./fields\";\nimport { CmsEntryElasticsearchFieldPlugin } from \"~/plugins/CmsEntryElasticsearchFieldPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch/where\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createLatestType, createPublishedType } from \"~/operations/entry\";\nimport { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins/CmsEntryElasticsearchQueryModifierPlugin\";\nimport { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins/CmsEntryElasticsearchSortModifierPlugin\";\nimport { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins/CmsEntryElasticsearchBodyModifierPlugin\";\nimport {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallableParams\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\nimport { getElasticsearchOperatorPluginsByLocale } from \"@webiny/api-elasticsearch/operators\";\nimport { normalizeValue } from \"@webiny/api-elasticsearch/normalize\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\n\ninterface CreateElasticsearchParams {\n plugins: PluginsContainer;\n model: CmsModel;\n args: CmsEntryListParams;\n parentPath?: string;\n}\n\ninterface CreateElasticsearchSortParams {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n parentPath?: string | null;\n model: CmsModel;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n}\n\ninterface CreateElasticsearchQueryArgs {\n model: CmsModel;\n plugins: PluginsContainer;\n where: CmsEntryListWhere;\n modelFields: ModelFields;\n parentPath?: string | null;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n fullTextSearch: {\n term?: string;\n fields: CmsModelField[];\n };\n}\n\nconst specialFields: (keyof Partial<CmsEntryListWhere>)[] = [\"published\", \"latest\"];\nconst noKeywordFields = [\"date\", \"datetime\", \"number\", \"boolean\"];\n\nconst createElasticsearchSortParams = (args: CreateElasticsearchSortParams): esSort => {\n const { sort, modelFields, parentPath, searchPlugins } = args;\n\n if (!sort || sort.length === 0) {\n return [];\n }\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce((plugins, modelField) => {\n const searchPlugin = searchPlugins[modelField.type];\n\n const { fieldId, storageId } = modelField.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\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: modelField.unmappedType,\n keyword: hasKeyword(modelField),\n sortable: modelField.isSortable,\n searchable: modelField.isSearchable,\n field: fieldId,\n path: createFieldPath({\n key: storageId,\n parentPath,\n modelField,\n searchPlugin\n })\n });\n return plugins;\n }, {} as Record<string, CmsEntryElasticsearchFieldPlugin>);\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\nconst findFieldByFieldId = (model: CmsModel, fieldId: string): CmsModelField | undefined => {\n return model.fields.find(field => {\n return field.fieldId === fieldId;\n });\n};\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n */\nconst createInitialQueryValue = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const { model, where: initialWhere } = params;\n /**\n * Cast as partial so we can remove unnecessary keys.\n */\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n const query: ElasticsearchBoolQueryConfig = {\n must: [],\n must_not: [],\n should: [],\n filter: []\n };\n\n // When ES index is shared between tenants, we need to filter records by tenant ID\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex) {\n query.must.push({ term: { \"tenant.keyword\": model.tenant } });\n }\n\n query.must.push({\n term: {\n \"locale.keyword\": model.locale\n }\n });\n\n /**\n * We must transform published and latest where args into something that is understandable by our Elasticsearch\n */\n if (where.published === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createPublishedType()\n }\n });\n } else if (where.latest === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createLatestType()\n }\n });\n }\n // we do not allow not published and not latest\n else {\n throw new WebinyError(\n `Cannot call Elasticsearch query when not setting \"published\" or \"latest\".`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n //\n return query;\n};\n\ninterface CreateFieldPathParams {\n modelField: ModelField;\n key: string;\n searchPlugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n parentPath?: string | null;\n}\nconst createFieldPath = ({\n modelField,\n searchPlugin,\n parentPath,\n key\n}: CreateFieldPathParams): string => {\n let path: string | null = null;\n if (searchPlugin && typeof searchPlugin.createPath === \"function\") {\n path = searchPlugin.createPath({\n field: modelField.field,\n value: null,\n key\n });\n } else if (typeof modelField.path === \"function\") {\n path = modelField.path(modelField.field.storageId);\n }\n if (!path) {\n /**\n * We know that modelFieldPath is a string or undefined at this point.\n */\n path = (modelField.path as string) || modelField.field.storageId || modelField.field.id;\n }\n return modelField.isSystemField || !parentPath || path.match(parentPath)\n ? path\n : `${parentPath}.${path}`;\n};\n\nconst hasKeyword = (modelField: ModelField): boolean => {\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(modelField.type)) {\n return false;\n } else if (modelField.unmappedType) {\n /**\n * If modelField has unmapped type defined, do not add keyword.\n */\n return false;\n } else if (modelField.keyword === false) {\n /**\n * And if specifically defined that modelField has no keyword, do not add it.\n */\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n\ninterface IsRefFieldFilteringParams {\n key: string;\n value: any;\n field: CmsModelField;\n}\n\n/**\n * A list of typeof strings that are 100% not ref field filtering.\n * We also need to check for array and date.\n */\nconst nonRefFieldTypes: string[] = [\n \"string\",\n \"number\",\n \"undefined\",\n \"symbol\",\n \"bigint\",\n \"function\",\n \"boolean\"\n];\nconst isRefFieldFiltering = (params: IsRefFieldFilteringParams): boolean => {\n const { key, value, field } = params;\n const typeOf = typeof value;\n if (\n !value ||\n nonRefFieldTypes.includes(typeOf) ||\n Array.isArray(value) ||\n value instanceof Date ||\n !!value.toISOString\n ) {\n return false;\n } else if (typeOf === \"object\" && field.type === \"ref\") {\n return true;\n }\n throw new WebinyError(\n \"Could not determine if the search value is ref field search.\",\n \"REF_FIELD_SEARCH_ERROR\",\n {\n value,\n field,\n key\n }\n );\n};\n\ninterface FieldPathFactoryParams extends Omit<CreatePathCallableParams, \"field\"> {\n plugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n modelField: ModelField;\n key: string;\n parentPath?: string | null;\n keyword?: boolean;\n}\nconst fieldPathFactory = (params: FieldPathFactoryParams): string => {\n const { plugin, modelField, value, parentPath, keyword, key } = params;\n\n const field = modelField.field;\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.storageId;\n if (modelField.path) {\n fieldPath =\n typeof modelField.path === \"function\" ? modelField.path(value) : modelField.path;\n }\n }\n\n const keywordValue = keyword ? \".keyword\" : \"\";\n if (!parentPath) {\n return `${fieldPath}${keywordValue}`;\n }\n return `${parentPath}.${fieldPath}${keywordValue}`;\n};\n\ninterface ApplyFilteringParams {\n query: ElasticsearchBoolQueryConfig;\n modelField: ModelField;\n operator: string;\n key: string;\n value: any;\n operatorPlugins: Record<string, ElasticsearchQueryBuilderOperatorPlugin>;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n parentPath?: string | null;\n}\nconst applyFiltering = (params: ApplyFilteringParams) => {\n const {\n query,\n modelField,\n operator,\n key,\n value: initialValue,\n operatorPlugins,\n searchPlugins,\n parentPath\n } = params;\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\"Operator plugin missing.\", \"PLUGIN_MISSING\", {\n operator\n });\n }\n const fieldSearchPlugin = searchPlugins[modelField.type];\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: modelField.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(modelField);\n plugin.apply(query, {\n basePath: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n parentPath: modelField.isSystemField ? null : parentPath,\n value,\n key\n }),\n path: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n value,\n parentPath: modelField.isSystemField ? null : parentPath,\n keyword,\n key\n }),\n value,\n keyword\n });\n};\n\ninterface ApplyFullTextSearchParams {\n query: ElasticsearchBoolQueryConfig;\n modelFields: ModelFields;\n term?: string;\n fields: CmsModelField[];\n}\nconst applyFullTextSearch = (params: ApplyFullTextSearchParams): void => {\n const { query, modelFields, term, fields } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const fieldPaths = fields.reduce((collection, field) => {\n const modelField = modelFields[field.fieldId];\n if (!modelField) {\n return collection;\n }\n\n collection.push(`values.${field.storageId}`);\n\n return collection;\n }, [] as string[]);\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fieldPaths,\n query: normalizeValue(term),\n default_operator: \"or\"\n }\n });\n};\n\n/*\n * Iterate through where keys and apply plugins where necessary\n */\nconst execElasticsearchBuildQueryPlugins = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const {\n model,\n where: initialWhere,\n modelFields,\n parentPath,\n plugins,\n searchPlugins,\n fullTextSearch\n } = params;\n\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n const query = createInitialQueryValue({\n ...params,\n where\n });\n\n /**\n * Add full text search for requested fields.\n */\n applyFullTextSearch({\n query,\n modelFields,\n term: fullTextSearch.term,\n fields: fullTextSearch.fields\n });\n\n /**\n * Always remove special fields, as these do not exist in Elasticsearch.\n */\n for (const sf of specialFields) {\n delete where[sf];\n }\n\n if (Object.keys(where).length === 0) {\n return query;\n }\n\n const operatorPlugins = getElasticsearchOperatorPluginsByLocale(plugins, model.locale);\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n /**\n * We do not need to go further if value is undefined.\n * There are few hardcoded possibilities when value is undefined, for example, ownedBy.\n */\n // TODO figure out how to have type.\n const value = (where as any)[key];\n if (value === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n\n let fieldId = field;\n const cmsModelField = findFieldByFieldId(model, fieldId);\n if (!cmsModelField && !modelFields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const modelField = modelFields[fieldId];\n\n if (!modelField) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const { isSearchable = false, field: cmsField } = modelField;\n if (!isSearchable) {\n throw new WebinyError(`Field \"${fieldId}\" is not searchable.`);\n }\n /**\n * There is a possibility that value is an object.\n * In that case, check if field is ref field and continue a bit differently.\n */\n if (isRefFieldFiltering({ key, value, field: cmsField })) {\n /**\n * We we need to go through each key in where[key] to determine the filters.\n */\n for (const whereKey in value) {\n const { operator } = parseWhereKey(whereKey);\n applyFiltering({\n query,\n modelField,\n operator,\n key: whereKey,\n value: value[whereKey],\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n continue;\n }\n applyFiltering({\n query,\n modelField,\n operator,\n key,\n value,\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n\n return query;\n};\n\nexport const createElasticsearchQueryBody = (params: CreateElasticsearchParams): esSearchBody => {\n const { plugins, model, args, parentPath = null } = params;\n const { where = {}, after, limit, sort: initialSort, search, fields = [] } = args;\n\n const modelFields = createModelFields(plugins, model);\n const searchPlugins = searchPluginsList(plugins);\n\n const fullTextSearchFields: CmsModelField[] = [];\n for (const fieldId of fields) {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n continue;\n }\n fullTextSearchFields.push(field);\n }\n\n const query = execElasticsearchBuildQueryPlugins({\n model,\n plugins,\n where,\n modelFields,\n parentPath,\n searchPlugins,\n fullTextSearch: {\n term: search,\n fields: fullTextSearchFields\n }\n });\n\n const queryPlugins = plugins\n .byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of queryPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSortParams({\n plugins,\n sort: initialSort,\n modelFields,\n parentPath,\n model,\n searchPlugins\n });\n\n const sortPlugins = plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of sortPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const body: esSearchBody = {\n query: {\n bool: {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n }\n },\n sort,\n size: (limit || 0) + 1,\n // eslint-disable-next-line\n search_after: decodeCursor(after) as any,\n // eslint-disable-next-line\n track_total_hits: true\n };\n\n const bodyPlugins = plugins\n .byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of bodyPlugins) {\n pl.modifyBody({\n body,\n model\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAaA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;;;;;;AAgCA,MAAMA,aAAmD,GAAG,CAAC,WAAD,EAAc,QAAd,CAA5D;AACA,MAAMC,eAAe,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,QAArB,EAA+B,SAA/B,CAAxB;;AAEA,MAAMC,6BAA6B,GAAIC,IAAD,IAAiD;EACnF,MAAM;IAAEC,IAAF;IAAQC,WAAR;IAAqBC,UAArB;IAAiCC;EAAjC,IAAmDJ,IAAzD;;EAEA,I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AA6CmD,SAFrD;QAGFlD,MAAM,EAAEH,KAAK,CAACG,MAAN,CAAa7C,MAAb,GAAsB,CAAtB,GAA0B0C,KAAK,CAACG,MAAhC,GAAyCkD,SAH/C;QAIFjE,MAAM,EAAEY,KAAK,CAACZ,MAAN,CAAa9B,MAAb,GAAsB,CAAtB,GAA0B0C,KAAK,CAACZ,MAAhC,GAAyCiE;MAJ/C;IADH,CADgB;IASvBnG,IATuB;IAUvB2H,IAAI,EAAE,CAACjB,KAAK,IAAI,CAAV,IAAe,CAVE;IAWvB;IACAkB,YAAY,EAAE,IAAAC,qBAAA,EAAapB,KAAb,CAZS;IAavB;IACAqB,gBAAgB,EAAE;EAdK,CAA3B;EAiBA,MAAMC,WAAW,GAAGrH,OAAO,CACtBwG,MADe,CAEZc,gFAAA,CAAwCnH,IAF5B,EAIfqB,MAJe,CAIRkF,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAe9E,KAAK,CAAC8E,OAA3C;EACH,CANe,CAApB;;EAOA,KAAK,MAAMD,EAAX,IAAiBW,WAAjB,EAA8B;IAC1BX,EAAE,CAACa,UAAH,CAAc;MACVR,IADU;MAEVlF;IAFU,CAAd;EAIH;;EAED,OAAOkF,IAAP;AACH,CA/FM"}
|
|
1
|
+
{"version":3,"names":["specialFields","noKeywordFields","createElasticsearchSortParams","args","sort","modelFields","parentPath","searchPlugins","length","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","plugins","modelField","searchPlugin","type","fieldId","storageId","field","CmsEntryElasticsearchFieldPlugin","unmappedType","keyword","hasKeyword","sortable","isSortable","searchable","isSearchable","path","createFieldPath","key","transformedSort","map","value","matched","match","order","filter","Boolean","createSort","fieldPlugins","findFieldByFieldId","model","fields","find","createInitialQueryValue","params","where","initialWhere","query","must","must_not","should","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","push","term","tenant","locale","published","createPublishedType","latest","createLatestType","WebinyError","createPath","id","isSystemField","includes","nonRefFieldTypes","isRefFieldFiltering","typeOf","Array","isArray","Date","toISOString","fieldPathFactory","plugin","fieldPath","keywordValue","applyFiltering","operator","initialValue","operatorPlugins","fieldSearchPlugin","transformValueForSearch","apply","basePath","applyFullTextSearch","fieldPaths","collection","query_string","allow_leading_wildcard","normalizeValue","default_operator","execElasticsearchBuildQueryPlugins","fullTextSearch","sf","keys","getElasticsearchOperatorPluginsByLocale","hasOwnProperty","undefined","parseWhereKey","cmsModelField","cmsField","whereKey","createElasticsearchQueryBody","after","limit","initialSort","search","createModelFields","searchPluginsList","fullTextSearchFields","f","queryPlugins","byType","CmsEntryElasticsearchQueryModifierPlugin","pl","modelId","modifyQuery","CmsEntryElasticsearchSortModifierPlugin","modifySort","body","bool","size","search_after","decodeCursor","track_total_hits","bodyPlugins","CmsEntryElasticsearchBodyModifierPlugin","modifyBody"],"sources":["createElasticsearchQueryBody.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"./transformValueForSearch\";\nimport { searchPluginsList } from \"./searchPluginsList\";\nimport {\n CmsEntryListParams,\n CmsEntryListSort,\n CmsEntryListWhere,\n CmsModel,\n CmsModelField\n} from \"@webiny/api-headless-cms/types\";\nimport {\n SearchBody as esSearchBody,\n Sort as esSort,\n ElasticsearchBoolQueryConfig\n} from \"@webiny/api-elasticsearch/types\";\nimport {\n decodeCursor,\n createSort,\n parseWhereKey,\n ElasticsearchQueryBuilderOperatorPlugin,\n normalizeValue,\n getElasticsearchOperatorPluginsByLocale\n} from \"@webiny/api-elasticsearch\";\nimport { createModelFields, ModelField, ModelFields } from \"./fields\";\nimport { CmsEntryElasticsearchFieldPlugin } from \"~/plugins/CmsEntryElasticsearchFieldPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createLatestType, createPublishedType } from \"~/operations/entry\";\nimport { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins/CmsEntryElasticsearchQueryModifierPlugin\";\nimport { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins/CmsEntryElasticsearchSortModifierPlugin\";\nimport { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins/CmsEntryElasticsearchBodyModifierPlugin\";\nimport {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallableParams\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\ninterface CreateElasticsearchParams {\n plugins: PluginsContainer;\n model: CmsModel;\n args: CmsEntryListParams;\n parentPath?: string;\n}\n\ninterface CreateElasticsearchSortParams {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n parentPath?: string | null;\n model: CmsModel;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n}\n\ninterface CreateElasticsearchQueryArgs {\n model: CmsModel;\n plugins: PluginsContainer;\n where: CmsEntryListWhere;\n modelFields: ModelFields;\n parentPath?: string | null;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n fullTextSearch: {\n term?: string;\n fields: CmsModelField[];\n };\n}\n\nconst specialFields: (keyof Partial<CmsEntryListWhere>)[] = [\"published\", \"latest\"];\nconst noKeywordFields = [\"date\", \"datetime\", \"number\", \"boolean\"];\n\nconst createElasticsearchSortParams = (args: CreateElasticsearchSortParams): esSort => {\n const { sort, modelFields, parentPath, searchPlugins } = args;\n\n if (!sort || sort.length === 0) {\n return [];\n }\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce((plugins, modelField) => {\n const searchPlugin = searchPlugins[modelField.type];\n\n const { fieldId, storageId } = modelField.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\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: modelField.unmappedType,\n keyword: hasKeyword(modelField),\n sortable: modelField.isSortable,\n searchable: modelField.isSearchable,\n field: fieldId,\n path: createFieldPath({\n key: storageId,\n parentPath,\n modelField,\n searchPlugin\n })\n });\n return plugins;\n }, {} as Record<string, CmsEntryElasticsearchFieldPlugin>);\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\nconst findFieldByFieldId = (model: CmsModel, fieldId: string): CmsModelField | undefined => {\n return model.fields.find(field => {\n return field.fieldId === fieldId;\n });\n};\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n */\nconst createInitialQueryValue = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const { model, where: initialWhere } = params;\n /**\n * Cast as partial so we can remove unnecessary keys.\n */\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n const query: ElasticsearchBoolQueryConfig = {\n must: [],\n must_not: [],\n should: [],\n filter: []\n };\n\n // When ES index is shared between tenants, we need to filter records by tenant ID\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex) {\n query.must.push({ term: { \"tenant.keyword\": model.tenant } });\n }\n\n query.must.push({\n term: {\n \"locale.keyword\": model.locale\n }\n });\n\n /**\n * We must transform published and latest where args into something that is understandable by our Elasticsearch\n */\n if (where.published === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createPublishedType()\n }\n });\n } else if (where.latest === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createLatestType()\n }\n });\n }\n // we do not allow not published and not latest\n else {\n throw new WebinyError(\n `Cannot call Elasticsearch query when not setting \"published\" or \"latest\".`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n //\n return query;\n};\n\ninterface CreateFieldPathParams {\n modelField: ModelField;\n key: string;\n searchPlugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n parentPath?: string | null;\n}\nconst createFieldPath = ({\n modelField,\n searchPlugin,\n parentPath,\n key\n}: CreateFieldPathParams): string => {\n let path: string | null = null;\n if (searchPlugin && typeof searchPlugin.createPath === \"function\") {\n path = searchPlugin.createPath({\n field: modelField.field,\n value: null,\n key\n });\n } else if (typeof modelField.path === \"function\") {\n path = modelField.path(modelField.field.storageId);\n }\n if (!path) {\n /**\n * We know that modelFieldPath is a string or undefined at this point.\n */\n path = (modelField.path as string) || modelField.field.storageId || modelField.field.id;\n }\n return modelField.isSystemField || !parentPath || path.match(parentPath)\n ? path\n : `${parentPath}.${path}`;\n};\n\nconst hasKeyword = (modelField: ModelField): boolean => {\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(modelField.type)) {\n return false;\n } else if (modelField.unmappedType) {\n /**\n * If modelField has unmapped type defined, do not add keyword.\n */\n return false;\n } else if (modelField.keyword === false) {\n /**\n * And if specifically defined that modelField has no keyword, do not add it.\n */\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n\ninterface IsRefFieldFilteringParams {\n key: string;\n value: any;\n field: CmsModelField;\n}\n\n/**\n * A list of typeof strings that are 100% not ref field filtering.\n * We also need to check for array and date.\n */\nconst nonRefFieldTypes: string[] = [\n \"string\",\n \"number\",\n \"undefined\",\n \"symbol\",\n \"bigint\",\n \"function\",\n \"boolean\"\n];\nconst isRefFieldFiltering = (params: IsRefFieldFilteringParams): boolean => {\n const { key, value, field } = params;\n const typeOf = typeof value;\n if (\n !value ||\n nonRefFieldTypes.includes(typeOf) ||\n Array.isArray(value) ||\n value instanceof Date ||\n !!value.toISOString\n ) {\n return false;\n } else if (typeOf === \"object\" && field.type === \"ref\") {\n return true;\n }\n throw new WebinyError(\n \"Could not determine if the search value is ref field search.\",\n \"REF_FIELD_SEARCH_ERROR\",\n {\n value,\n field,\n key\n }\n );\n};\n\ninterface FieldPathFactoryParams extends Omit<CreatePathCallableParams, \"field\"> {\n plugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n modelField: ModelField;\n key: string;\n parentPath?: string | null;\n keyword?: boolean;\n}\nconst fieldPathFactory = (params: FieldPathFactoryParams): string => {\n const { plugin, modelField, value, parentPath, keyword, key } = params;\n\n const field = modelField.field;\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.storageId;\n if (modelField.path) {\n fieldPath =\n typeof modelField.path === \"function\" ? modelField.path(value) : modelField.path;\n }\n }\n\n const keywordValue = keyword ? \".keyword\" : \"\";\n if (!parentPath) {\n return `${fieldPath}${keywordValue}`;\n }\n return `${parentPath}.${fieldPath}${keywordValue}`;\n};\n\ninterface ApplyFilteringParams {\n query: ElasticsearchBoolQueryConfig;\n modelField: ModelField;\n operator: string;\n key: string;\n value: any;\n operatorPlugins: Record<string, ElasticsearchQueryBuilderOperatorPlugin>;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n parentPath?: string | null;\n}\nconst applyFiltering = (params: ApplyFilteringParams) => {\n const {\n query,\n modelField,\n operator,\n key,\n value: initialValue,\n operatorPlugins,\n searchPlugins,\n parentPath\n } = params;\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\"Operator plugin missing.\", \"PLUGIN_MISSING\", {\n operator\n });\n }\n const fieldSearchPlugin = searchPlugins[modelField.type];\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: modelField.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(modelField);\n plugin.apply(query, {\n basePath: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n parentPath: modelField.isSystemField ? null : parentPath,\n value,\n key\n }),\n path: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n value,\n parentPath: modelField.isSystemField ? null : parentPath,\n keyword,\n key\n }),\n value,\n keyword\n });\n};\n\ninterface ApplyFullTextSearchParams {\n query: ElasticsearchBoolQueryConfig;\n modelFields: ModelFields;\n term?: string;\n fields: CmsModelField[];\n}\nconst applyFullTextSearch = (params: ApplyFullTextSearchParams): void => {\n const { query, modelFields, term, fields } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const fieldPaths = fields.reduce((collection, field) => {\n const modelField = modelFields[field.fieldId];\n if (!modelField) {\n return collection;\n }\n\n collection.push(`values.${field.storageId}`);\n\n return collection;\n }, [] as string[]);\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fieldPaths,\n query: normalizeValue(term),\n default_operator: \"or\"\n }\n });\n};\n\n/*\n * Iterate through where keys and apply plugins where necessary\n */\nconst execElasticsearchBuildQueryPlugins = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const {\n model,\n where: initialWhere,\n modelFields,\n parentPath,\n plugins,\n searchPlugins,\n fullTextSearch\n } = params;\n\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n const query = createInitialQueryValue({\n ...params,\n where\n });\n\n /**\n * Add full text search for requested fields.\n */\n applyFullTextSearch({\n query,\n modelFields,\n term: fullTextSearch.term,\n fields: fullTextSearch.fields\n });\n\n /**\n * Always remove special fields, as these do not exist in Elasticsearch.\n */\n for (const sf of specialFields) {\n delete where[sf];\n }\n\n if (Object.keys(where).length === 0) {\n return query;\n }\n\n const operatorPlugins = getElasticsearchOperatorPluginsByLocale(plugins, model.locale);\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n /**\n * We do not need to go further if value is undefined.\n * There are few hardcoded possibilities when value is undefined, for example, ownedBy.\n */\n // TODO figure out how to have type.\n const value = (where as any)[key];\n if (value === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n\n let fieldId = field;\n const cmsModelField = findFieldByFieldId(model, fieldId);\n if (!cmsModelField && !modelFields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const modelField = modelFields[fieldId];\n\n if (!modelField) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const { isSearchable = false, field: cmsField } = modelField;\n if (!isSearchable) {\n throw new WebinyError(`Field \"${fieldId}\" is not searchable.`);\n }\n /**\n * There is a possibility that value is an object.\n * In that case, check if field is ref field and continue a bit differently.\n */\n if (isRefFieldFiltering({ key, value, field: cmsField })) {\n /**\n * We we need to go through each key in where[key] to determine the filters.\n */\n for (const whereKey in value) {\n const { operator } = parseWhereKey(whereKey);\n applyFiltering({\n query,\n modelField,\n operator,\n key: whereKey,\n value: value[whereKey],\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n continue;\n }\n applyFiltering({\n query,\n modelField,\n operator,\n key,\n value,\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n\n return query;\n};\n\nexport const createElasticsearchQueryBody = (params: CreateElasticsearchParams): esSearchBody => {\n const { plugins, model, args, parentPath = null } = params;\n const { where = {}, after, limit, sort: initialSort, search, fields = [] } = args;\n\n const modelFields = createModelFields(plugins, model);\n const searchPlugins = searchPluginsList(plugins);\n\n const fullTextSearchFields: CmsModelField[] = [];\n /**\n * No point in going through fields if there is no search performed.\n */\n if (!!search) {\n for (const fieldId of fields) {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n continue;\n }\n fullTextSearchFields.push(field);\n }\n }\n\n const query = execElasticsearchBuildQueryPlugins({\n model,\n plugins,\n where,\n modelFields,\n parentPath,\n searchPlugins,\n fullTextSearch: {\n term: search,\n fields: fullTextSearchFields\n }\n });\n\n const queryPlugins = plugins\n .byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of queryPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSortParams({\n plugins,\n sort: initialSort,\n modelFields,\n parentPath,\n model,\n searchPlugins\n });\n\n const sortPlugins = plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of sortPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const body: esSearchBody = {\n query: {\n bool: {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n }\n },\n sort,\n size: (limit || 0) + 1,\n // eslint-disable-next-line\n search_after: decodeCursor(after) as any,\n // eslint-disable-next-line\n track_total_hits: true\n };\n\n const bodyPlugins = plugins\n .byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of bodyPlugins) {\n pl.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAaA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAmCA,MAAMA,aAAmD,GAAG,CAAC,WAAD,EAAc,QAAd,CAA5D;AACA,MAAMC,eAAe,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,QAArB,EAA+B,SAA/B,CAAxB;;AAEA,MAAMC,6BAA6B,GAAIC,IAAD,IAAiD;EACnF,MAAM;IAAEC,IAAF;IAAQC,WAAR;IAAqBC,UAArB;IAAiC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QAAQ,EAAEF,KAAK,CAACE,QAAN,CAAe5C,MAAf,GAAwB,CAAxB,GAA4B0C,KAAK,CAACE,QAAlC,GAA6CmD,SAFrD;QAGFlD,MAAM,EAAEH,KAAK,CAACG,MAAN,CAAa7C,MAAb,GAAsB,CAAtB,GAA0B0C,KAAK,CAACG,MAAhC,GAAyCkD,SAH/C;QAIFjE,MAAM,EAAEY,KAAK,CAACZ,MAAN,CAAa9B,MAAb,GAAsB,CAAtB,GAA0B0C,KAAK,CAACZ,MAAhC,GAAyCiE;MAJ/C;IADH,CADgB;IASvBnG,IATuB;IAUvB2H,IAAI,EAAE,CAACjB,KAAK,IAAI,CAAV,IAAe,CAVE;IAWvB;IACAkB,YAAY,EAAE,IAAAC,8BAAA,EAAapB,KAAb,CAZS;IAavB;IACAqB,gBAAgB,EAAE;EAdK,CAA3B;EAiBA,MAAMC,WAAW,GAAGrH,OAAO,CACtBwG,MADe,CAEZc,gFAAA,CAAwCnH,IAF5B,EAIfqB,MAJe,CAIRkF,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAe9E,KAAK,CAAC8E,OAA3C;EACH,CANe,CAApB;;EAOA,KAAK,MAAMD,EAAX,IAAiBW,WAAjB,EAA8B;IAC1BX,EAAE,CAACa,UAAH,CAAc;MACVR,IADU;MAEVlF,KAFU;MAGVK;IAHU,CAAd;EAKH;;EAED,OAAO6E,IAAP;AACH,CArGM"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -5,6 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
var _exportNames = {
|
|
9
|
+
createStorageOperations: true
|
|
10
|
+
};
|
|
8
11
|
exports.createStorageOperations = void 0;
|
|
9
12
|
|
|
10
13
|
var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
|
|
@@ -45,7 +48,7 @@ var _plugins = require("@webiny/plugins");
|
|
|
45
48
|
|
|
46
49
|
var _group2 = require("./operations/group");
|
|
47
50
|
|
|
48
|
-
var
|
|
51
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
49
52
|
|
|
50
53
|
var _elasticsearchFields = require("./operations/entry/elasticsearchFields");
|
|
51
54
|
|
|
@@ -53,6 +56,20 @@ var _indices = require("./elasticsearch/indices");
|
|
|
53
56
|
|
|
54
57
|
var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
|
|
55
58
|
|
|
59
|
+
var _plugins2 = require("./plugins");
|
|
60
|
+
|
|
61
|
+
Object.keys(_plugins2).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
64
|
+
if (key in exports && exports[key] === _plugins2[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _plugins2[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
56
73
|
const createStorageOperations = params => {
|
|
57
74
|
const {
|
|
58
75
|
attributes,
|
|
@@ -103,10 +120,6 @@ const createStorageOperations = params => {
|
|
|
103
120
|
})
|
|
104
121
|
};
|
|
105
122
|
const plugins = new _plugins.PluginsContainer([
|
|
106
|
-
/**
|
|
107
|
-
* User defined custom plugins.
|
|
108
|
-
*/
|
|
109
|
-
...(userPlugins || []),
|
|
110
123
|
/**
|
|
111
124
|
* Plugins of type CmsModelFieldToGraphQLPlugin.
|
|
112
125
|
*/
|
|
@@ -122,7 +135,7 @@ const createStorageOperations = params => {
|
|
|
122
135
|
/**
|
|
123
136
|
* Elasticsearch operators.
|
|
124
137
|
*/
|
|
125
|
-
(0,
|
|
138
|
+
(0, _apiElasticsearch.getElasticsearchOperators)(),
|
|
126
139
|
/**
|
|
127
140
|
* Field plugins for DynamoDB.
|
|
128
141
|
*/
|
|
@@ -134,14 +147,51 @@ const createStorageOperations = params => {
|
|
|
134
147
|
/**
|
|
135
148
|
* Built-in Elasticsearch index templates.
|
|
136
149
|
*/
|
|
137
|
-
(0, _indices.elasticsearchIndexPlugins)()
|
|
150
|
+
(0, _indices.elasticsearchIndexPlugins)(),
|
|
151
|
+
/**
|
|
152
|
+
* User defined custom plugins.
|
|
153
|
+
* They are at the end because we can then override existing plugins.
|
|
154
|
+
*/
|
|
155
|
+
...(userPlugins || [])]);
|
|
138
156
|
return {
|
|
139
157
|
beforeInit: async context => {
|
|
158
|
+
/**
|
|
159
|
+
* Attach the elasticsearch into context if it is not already attached.
|
|
160
|
+
*/
|
|
161
|
+
if (!context.elasticsearch) {
|
|
162
|
+
context.elasticsearch = elasticsearch;
|
|
163
|
+
}
|
|
140
164
|
/**
|
|
141
165
|
* Collect all required plugins from parent context.
|
|
142
166
|
*/
|
|
167
|
+
|
|
168
|
+
|
|
143
169
|
const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
|
|
144
170
|
plugins.register(fieldPlugins);
|
|
171
|
+
/**
|
|
172
|
+
* We need to get all the operator plugins from the main plugin container.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
const elasticsearchOperatorPlugins = context.plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type);
|
|
176
|
+
plugins.register(elasticsearchOperatorPlugins);
|
|
177
|
+
/**
|
|
178
|
+
* We need to get all the query modifier plugins
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
const queryModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchQueryModifierPlugin.type);
|
|
182
|
+
plugins.register(queryModifierPlugins);
|
|
183
|
+
/**
|
|
184
|
+
* We need to get all the sort modifier plugins
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
const sortModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchSortModifierPlugin.type);
|
|
188
|
+
plugins.register(sortModifierPlugins);
|
|
189
|
+
/**
|
|
190
|
+
* We need to get all the body modifier plugins
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
const bodyModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchBodyModifierPlugin.type);
|
|
194
|
+
plugins.register(bodyModifierPlugins);
|
|
145
195
|
/**
|
|
146
196
|
* Pass the plugins to the parent context.
|
|
147
197
|
*/
|
|
@@ -179,6 +229,15 @@ const createStorageOperations = params => {
|
|
|
179
229
|
model
|
|
180
230
|
});
|
|
181
231
|
});
|
|
232
|
+
context.cms.onModelInitialize.subscribe(async ({
|
|
233
|
+
model
|
|
234
|
+
}) => {
|
|
235
|
+
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
|
|
236
|
+
elasticsearch,
|
|
237
|
+
model,
|
|
238
|
+
plugins
|
|
239
|
+
});
|
|
240
|
+
});
|
|
182
241
|
},
|
|
183
242
|
getEntities: () => entities,
|
|
184
243
|
getTable: () => tableInstance,
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","cmsEntryElasticsearchFields","dynamoDbValueFilters","getElasticsearchOperators","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","beforeInit","context","fieldPlugins","byType","register","init","cms","onBeforeModelCreate","subscribe","model","createElasticsearchIndex","onBeforeModelCreateFrom","onAfterModelDelete","deleteElasticsearchIndex","getEntities","getTable","getEsTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","esEntity"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSettingsStorageOperations } from \"./operations/settings\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport { getElasticsearchOperators } from \"@webiny/api-elasticsearch/operators\";\nimport { elasticsearchFields as cmsEntryElasticsearchFields } from \"~/operations/entry/elasticsearchFields\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n }),\n entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * User defined custom plugins.\n */\n ...(userPlugins || []),\n /**\n * Plugins of type CmsModelFieldToGraphQLPlugin.\n */\n /**\n * Elasticsearch field definitions for the entry record.\n */\n cmsEntryElasticsearchFields,\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Elasticsearch operators.\n */\n getElasticsearchOperators(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins()\n ]);\n\n return {\n beforeInit: async context => {\n /**\n * Collect all required plugins from parent context.\n */\n const fieldPlugins = context.plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n plugins.register(fieldPlugins);\n\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n },\n init: async context => {\n /**\n * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n context.cms.onBeforeModelCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onBeforeModelCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onAfterModelDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n elasticsearch,\n model\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n })\n };\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UADE;IAEFC,KAFE;IAGFC,OAHE;IAIFC,cAJE;IAKFC,aALE;IAMFC,OAAO,EAAEC;EANP,IAOFP,MAPJ;EASA,MAAMQ,aAAa,GAAG,IAAAC,kBAAA,EAAY;IAC9BP,KAD8B;IAE9BE;EAF8B,CAAZ,CAAtB;EAIA,MAAMM,0BAA0B,GAAG,IAAAC,4CAAA,EAAyB;IACxDT,KAAK,EAAEC,OADiD;IAExDC;EAFwD,CAAzB,CAAnC;EAKA,MAAMQ,QAAQ,GAAG;IACbC,QAAQ,EAAE,IAAAC,+BAAA,EAAqB;MAC3BC,UAAU,EAAEC,eAAA,CAASC,QADM;MAE3Bf,KAAK,EAAEM,aAFoB;MAG3BP,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACe,eAAA,CAASC,QAAV,CAAb,GAAmC;IAH9B,CAArB,CADG;IAM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AzChB;IA0CH2C,QAAQ,EAAE,MAAM/C,aA1Cb;IA2CHgD,UAAU,EAAE,MAAM9C,0BA3Cf;IA4CHQ,MAAM,EAAE,IAAAuC,qCAAA,EAA8B;MAClCC,MAAM,EAAE9C,QAAQ,CAACM;IADiB,CAA9B,CA5CL;IA+CHL,QAAQ,EAAE,IAAA8C,yCAAA,EAAgC;MACtCD,MAAM,EAAE9C,QAAQ,CAACC;IADqB,CAAhC,CA/CP;IAkDHQ,MAAM,EAAE,IAAAuC,qCAAA,EAA8B;MAClCF,MAAM,EAAE9C,QAAQ,CAACS,MADiB;MAElCf;IAFkC,CAA9B,CAlDL;IAsDHkB,MAAM,EAAE,IAAAqC,oCAAA,EAA8B;MAClCH,MAAM,EAAE9C,QAAQ,CAACY,MADiB;MAElCnB;IAFkC,CAA9B,CAtDL;IA0DHsB,OAAO,EAAE,IAAAmC,qCAAA,EAA+B;MACpCJ,MAAM,EAAE9C,QAAQ,CAACe,OADmB;MAEpCoC,QAAQ,EAAEnD,QAAQ,CAACkB,SAFiB;MAGpCxB,OAHoC;MAIpCD;IAJoC,CAA/B;EA1DN,CAAP;AAiEH,CAvJM"}
|
|
1
|
+
{"version":3,"names":["createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","cmsEntryElasticsearchFields","dynamoDbValueFilters","getElasticsearchOperators","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","beforeInit","context","fieldPlugins","byType","register","elasticsearchOperatorPlugins","ElasticsearchQueryBuilderOperatorPlugin","type","queryModifierPlugins","CmsEntryElasticsearchQueryModifierPlugin","sortModifierPlugins","CmsEntryElasticsearchSortModifierPlugin","bodyModifierPlugins","CmsEntryElasticsearchBodyModifierPlugin","init","cms","onBeforeModelCreate","subscribe","model","createElasticsearchIndex","onBeforeModelCreateFrom","onAfterModelDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","esEntity"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSettingsStorageOperations } from \"./operations/settings\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugin,\n getElasticsearchOperators\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchFields as cmsEntryElasticsearchFields } from \"~/operations/entry/elasticsearchFields\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport {\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin\n} from \"~/plugins\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n }),\n entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * Plugins of type CmsModelFieldToGraphQLPlugin.\n */\n /**\n * Elasticsearch field definitions for the entry record.\n */\n cmsEntryElasticsearchFields,\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Elasticsearch operators.\n */\n getElasticsearchOperators(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n return {\n beforeInit: async context => {\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n /**\n * Collect all required plugins from parent context.\n */\n const fieldPlugins = context.plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n plugins.register(fieldPlugins);\n /**\n * We need to get all the operator plugins from the main plugin container.\n */\n const elasticsearchOperatorPlugins =\n context.plugins.byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n );\n plugins.register(elasticsearchOperatorPlugins);\n /**\n * We need to get all the query modifier plugins\n */\n const queryModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n );\n plugins.register(queryModifierPlugins);\n /**\n * We need to get all the sort modifier plugins\n */\n const sortModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n );\n plugins.register(sortModifierPlugins);\n /**\n * We need to get all the body modifier plugins\n */\n const bodyModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n );\n plugins.register(bodyModifierPlugins);\n\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n },\n init: async context => {\n /**\n * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n context.cms.onBeforeModelCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onBeforeModelCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onAfterModelDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n })\n };\n};\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AAMA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UADE;IAEFC,KAFE;IAGFC,OAHE;IAIFC,cAJE;IAKFC,aALE;IAMFC,OAAO,EAAEC;EANP,IAOFP,MAPJ;EASA,MAAMQ,aAAa,GAAG,IAAAC,kBAAA,EAAY;IAC9BP,KAD8B;IAE9BE;EAF8B,CAAZ,CAAtB;EAIA,MAAMM,0BAA0B,GAAG,IAAAC,4CAAA,EAAyB;IACxDT,KAAK,EAAEC,OADiD;IAExDC;EAFwD,CAAzB,CAAnC;EAKA,MAAMQ,QAAQ,GAAG;IACbC,QAAQ,EAAE,IAAAC,+BAAA,EAAqB;MAC3BC,UAAU,EAAEC,eAAA,CAASC,QADM;MAE3Bf,KAAK,EAAEM,aAFoB;MAG3BP,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACe,eAAA,CAASC,QAAV,CAAb,GAAmC;IAH9B,CAArB,CADG;IAMbC,M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