@webiny/api-headless-cms-ddb-es 5.25.0 → 5.25.1-beta.0
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 -1
- 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/indexing/dateTimeIndexing.js +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +23 -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 +24 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/helpers/createElasticsearchQueryBody.js +83 -28
- package/helpers/createElasticsearchQueryBody.js.map +1 -1
- package/index.js +49 -14
- package/index.js.map +1 -1
- package/operations/entry/index.js +37 -47
- package/operations/entry/index.js.map +1 -1
- package/operations/group/index.js +1 -3
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +18 -36
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +1 -3
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +1 -3
- package/operations/system/index.js.map +1 -1
- package/package.json +15 -17
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/types.d.ts +2 -2
- package/types.js.map +1 -1
- package/upgrades/index.d.ts +1 -1
- package/upgrades/index.js +1 -7
- package/upgrades/index.js.map +1 -1
- package/helpers/operatorPluginsList.d.ts +0 -6
- package/helpers/operatorPluginsList.js +0 -30
- package/helpers/operatorPluginsList.js.map +0 -1
- package/operations/system/createElasticsearchTemplate.d.ts +0 -5
- package/operations/system/createElasticsearchTemplate.js +0 -62
- package/operations/system/createElasticsearchTemplate.js.map +0 -1
- package/upgrades/utils.d.ts +0 -4
- package/upgrades/utils.js +0 -20
- package/upgrades/utils.js.map +0 -1
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -9
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -20
- package/upgrades/v5.0.0/cleanDatabaseRecord.js.map +0 -1
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
- package/upgrades/v5.0.0/createOldVersionIndiceName.js.map +0 -1
- package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -7
- package/upgrades/v5.0.0/entryValueFixer.js +0 -124
- package/upgrades/v5.0.0/entryValueFixer.js.map +0 -1
- package/upgrades/v5.0.0/fieldFinder.d.ts +0 -9
- package/upgrades/v5.0.0/fieldFinder.js +0 -46
- package/upgrades/v5.0.0/fieldFinder.js.map +0 -1
- package/upgrades/v5.0.0/helpers.d.ts +0 -4
- package/upgrades/v5.0.0/helpers.js +0 -57
- package/upgrades/v5.0.0/helpers.js.map +0 -1
- package/upgrades/v5.0.0/index.d.ts +0 -4
- package/upgrades/v5.0.0/index.js +0 -232
- package/upgrades/v5.0.0/index.js.map +0 -1
- package/upgrades/v5.8.0/index.d.ts +0 -7
- package/upgrades/v5.8.0/index.js +0 -426
- package/upgrades/v5.8.0/index.js.map +0 -1
package/configurations.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ interface CmsElasticsearchParams {
|
|
|
8
8
|
interface Configurations {
|
|
9
9
|
es: (params: CmsElasticsearchParams) => ElasticsearchConfig;
|
|
10
10
|
}
|
|
11
|
-
declare const configurations: Configurations;
|
|
12
|
-
export
|
|
11
|
+
export declare const configurations: Configurations;
|
|
12
|
+
export {};
|
package/configurations.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports.
|
|
8
|
+
exports.configurations = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
7
12
|
const configurations = {
|
|
8
13
|
es({
|
|
9
14
|
model
|
|
@@ -12,21 +17,27 @@ const configurations = {
|
|
|
12
17
|
tenant,
|
|
13
18
|
locale
|
|
14
19
|
} = model;
|
|
20
|
+
|
|
21
|
+
if (!tenant) {
|
|
22
|
+
throw new _error.default(`Missing "tenant" parameter when trying to create Elasticsearch index name.`, "TENANT_ERROR");
|
|
23
|
+
} else if (!locale) {
|
|
24
|
+
throw new _error.default(`Missing "locale" parameter when trying to create Elasticsearch index name.`, "LOCALE_ERROR");
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
|
|
16
28
|
const index = [sharedIndex ? "root" : tenant, "headless-cms", locale, model.modelId].join("-").toLowerCase();
|
|
17
|
-
const prefix = process.env.ELASTIC_SEARCH_INDEX_PREFIX;
|
|
29
|
+
const prefix = process.env.ELASTIC_SEARCH_INDEX_PREFIX || "";
|
|
18
30
|
|
|
19
|
-
if (prefix) {
|
|
31
|
+
if (!prefix) {
|
|
20
32
|
return {
|
|
21
|
-
index
|
|
33
|
+
index
|
|
22
34
|
};
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
return {
|
|
26
|
-
index
|
|
38
|
+
index: prefix + index
|
|
27
39
|
};
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
};
|
|
31
|
-
|
|
32
|
-
exports.default = _default;
|
|
43
|
+
exports.configurations = configurations;
|
package/configurations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["configurations.ts"],"names":["configurations","es","model","tenant","locale","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","index","modelId","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["configurations.ts"],"names":["configurations","es","model","tenant","locale","WebinyError","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","index","modelId","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX"],"mappings":";;;;;;;;;AACA;;AAaO,MAAMA,cAA8B,GAAG;AAC1CC,EAAAA,EAAE,CAAC;AAAEC,IAAAA;AAAF,GAAD,EAAY;AACV,UAAM;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,QAAqBF,KAA3B;;AAEA,QAAI,CAACC,MAAL,EAAa;AACT,YAAM,IAAIE,cAAJ,CACD,4EADC,EAEF,cAFE,CAAN;AAIH,KALD,MAKO,IAAI,CAACD,MAAL,EAAa;AAChB,YAAM,IAAIC,cAAJ,CACD,4EADC,EAEF,cAFE,CAAN;AAIH;;AAED,UAAMC,WAAW,GAAGC,OAAO,CAACC,GAAR,CAAYC,4BAAZ,KAA6C,MAAjE;AACA,UAAMC,KAAK,GAAG,CAACJ,WAAW,GAAG,MAAH,GAAYH,MAAxB,EAAgC,cAAhC,EAAgDC,MAAhD,EAAwDF,KAAK,CAACS,OAA9D,EACTC,IADS,CACJ,GADI,EAETC,WAFS,EAAd;AAIA,UAAMC,MAAM,GAAGP,OAAO,CAACC,GAAR,CAAYO,2BAAZ,IAA2C,EAA1D;;AACA,QAAI,CAACD,MAAL,EAAa;AACT,aAAO;AACHJ,QAAAA;AADG,OAAP;AAGH;;AACD,WAAO;AACHA,MAAAA,KAAK,EAAEI,MAAM,GAAGJ;AADb,KAAP;AAGH;;AA9ByC,CAAvC","sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface ElasticsearchConfig {\n index: string;\n}\n\ninterface CmsElasticsearchParams {\n model: CmsModel;\n}\ninterface Configurations {\n es: (params: CmsElasticsearchParams) => ElasticsearchConfig;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant, locale } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n } else if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", locale, model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = process.env.ELASTIC_SEARCH_INDEX_PREFIX || \"\";\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n }\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "@elastic/elasticsearch";
|
|
2
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
+
export interface CreateElasticsearchIndexParams {
|
|
5
|
+
elasticsearch: Client;
|
|
6
|
+
plugins: PluginsContainer;
|
|
7
|
+
model: CmsModel;
|
|
8
|
+
}
|
|
9
|
+
export declare const createElasticsearchIndex: (params: CreateElasticsearchIndexParams) => Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createElasticsearchIndex = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
var _CmsEntryElasticsearchIndexPlugin = require("../plugins/CmsEntryElasticsearchIndexPlugin");
|
|
13
|
+
|
|
14
|
+
var _indices = require("@webiny/api-elasticsearch/indices");
|
|
15
|
+
|
|
16
|
+
var _configurations = require("../configurations");
|
|
17
|
+
|
|
18
|
+
const createElasticsearchIndex = async params => {
|
|
19
|
+
const {
|
|
20
|
+
elasticsearch,
|
|
21
|
+
plugins: container,
|
|
22
|
+
model
|
|
23
|
+
} = params;
|
|
24
|
+
const plugin = (0, _indices.getLastAddedIndexPlugin)({
|
|
25
|
+
container,
|
|
26
|
+
type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
|
|
27
|
+
locale: model.locale
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
index
|
|
32
|
+
} = _configurations.configurations.es({
|
|
33
|
+
model
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const response = await elasticsearch.indices.exists({
|
|
38
|
+
index
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (response.body) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await elasticsearch.indices.create({
|
|
46
|
+
index,
|
|
47
|
+
body: plugin.body
|
|
48
|
+
});
|
|
49
|
+
} catch (ex) {
|
|
50
|
+
throw new _error.default(ex.message || "Could not create Elasticsearch index for the Headless CMS model.", ex.code || "CMS_ELASTICSEARCH_INDEX_ERROR", {
|
|
51
|
+
error: ex,
|
|
52
|
+
type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
|
|
53
|
+
locale: model.locale,
|
|
54
|
+
tenant: model.tenant,
|
|
55
|
+
body: plugin.body
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.createElasticsearchIndex = createElasticsearchIndex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["createElasticsearchIndex.ts"],"names":["createElasticsearchIndex","params","elasticsearch","plugins","container","model","plugin","type","CmsEntryElasticsearchIndexPlugin","locale","index","configurations","es","response","indices","exists","body","create","ex","WebinyError","message","code","error","tenant"],"mappings":";;;;;;;;;AAAA;;AAGA;;AACA;;AACA;;AASO,MAAMA,wBAAwB,GAAG,MAAOC,MAAP,IAAkD;AACtF,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,OAAO,EAAEC,SAA1B;AAAqCC,IAAAA;AAArC,MAA+CJ,MAArD;AAEA,QAAMK,MAAM,GAAG,sCAA0D;AACrEF,IAAAA,SADqE;AAErEG,IAAAA,IAAI,EAAEC,mEAAiCD,IAF8B;AAGrEE,IAAAA,MAAM,EAAEJ,KAAK,CAACI;AAHuD,GAA1D,CAAf;;AAMA,QAAM;AAAEC,IAAAA;AAAF,MAAYC,+BAAeC,EAAf,CAAkB;AAChCP,IAAAA;AADgC,GAAlB,CAAlB;;AAIA,MAAI;AACA,UAAMQ,QAAQ,GAAG,MAAMX,aAAa,CAACY,OAAd,CAAsBC,MAAtB,CAA6B;AAChDL,MAAAA;AADgD,KAA7B,CAAvB;;AAGA,QAAIG,QAAQ,CAACG,IAAb,EAAmB;AACf;AACH;;AACD,UAAMd,aAAa,CAACY,OAAd,CAAsBG,MAAtB,CAA6B;AAC/BP,MAAAA,KAD+B;AAE/BM,MAAAA,IAAI,EAAEV,MAAM,CAACU;AAFkB,KAA7B,CAAN;AAIH,GAXD,CAWE,OAAOE,EAAP,EAAW;AACT,UAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,kEADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,+BAFT,EAGF;AACIC,MAAAA,KAAK,EAAEJ,EADX;AAEIX,MAAAA,IAAI,EAAEC,mEAAiCD,IAF3C;AAGIE,MAAAA,MAAM,EAAEJ,KAAK,CAACI,MAHlB;AAIIc,MAAAA,MAAM,EAAElB,KAAK,CAACkB,MAJlB;AAKIP,MAAAA,IAAI,EAAEV,MAAM,CAACU;AALjB,KAHE,CAAN;AAWH;AACJ,CArCM","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/indices\";\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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Client } from "@elastic/elasticsearch";
|
|
2
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
interface DeleteElasticsearchIndexParams {
|
|
4
|
+
elasticsearch: Client;
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
}
|
|
7
|
+
export declare const deleteElasticsearchIndex: (params: DeleteElasticsearchIndexParams) => Promise<void>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deleteElasticsearchIndex = void 0;
|
|
7
|
+
|
|
8
|
+
var _configurations = require("../configurations");
|
|
9
|
+
|
|
10
|
+
const deleteElasticsearchIndex = async params => {
|
|
11
|
+
const {
|
|
12
|
+
elasticsearch,
|
|
13
|
+
model
|
|
14
|
+
} = params;
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
index
|
|
18
|
+
} = _configurations.configurations.es({
|
|
19
|
+
model
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
body: exists
|
|
24
|
+
} = await elasticsearch.indices.exists({
|
|
25
|
+
index
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (!exists) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await elasticsearch.indices.delete({
|
|
34
|
+
index,
|
|
35
|
+
ignore_unavailable: true
|
|
36
|
+
});
|
|
37
|
+
} catch (ex) {
|
|
38
|
+
console.log(`Could not delete Elasticsearch index "${index}". Please do it manually.`);
|
|
39
|
+
console.log(ex.message);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.deleteElasticsearchIndex = deleteElasticsearchIndex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["deleteElasticsearchIndex.ts"],"names":["deleteElasticsearchIndex","params","elasticsearch","model","index","configurations","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message"],"mappings":";;;;;;;AAEA;;AAOO,MAAMA,wBAAwB,GAAG,MACpCC,MADoC,IAEpB;AAChB,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAA2BF,MAAjC;;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAYC,+BAAeC,EAAf,CAAkB;AAChCH,IAAAA;AADgC,GAAlB,CAAlB;;AAGA,QAAM;AAAEI,IAAAA,IAAI,EAAEC;AAAR,MAAmB,MAAMN,aAAa,CAACO,OAAd,CAAsBD,MAAtB,CAA6B;AACxDJ,IAAAA;AADwD,GAA7B,CAA/B;;AAGA,MAAI,CAACI,MAAL,EAAa;AACT;AACH;;AAED,MAAI;AACA,UAAMN,aAAa,CAACO,OAAd,CAAsBC,MAAtB,CAA6B;AAC/BN,MAAAA,KAD+B;AAE/BO,MAAAA,kBAAkB,EAAE;AAFW,KAA7B,CAAN;AAIH,GALD,CAKE,OAAOC,EAAP,EAAW;AACTC,IAAAA,OAAO,CAACC,GAAR,CAAa,yCAAwCV,KAAM,2BAA3D;AACAS,IAAAA,OAAO,CAACC,GAAR,CAAYF,EAAE,CAACG,OAAf;AACH;AACJ,CAxBM","sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { configurations } from \"~/configurations\";\n\ninterface DeleteElasticsearchIndexParams {\n elasticsearch: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { elasticsearch, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await elasticsearch.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"]}
|
|
@@ -43,7 +43,7 @@ const convertValueFromIndex = (value, field) => {
|
|
|
43
43
|
return value;
|
|
44
44
|
} else if (type === "date") {
|
|
45
45
|
const dateValue = new Date(value);
|
|
46
|
-
return dateValue.toISOString().
|
|
46
|
+
return dateValue.toISOString().slice(0, 10);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return new Date(value).toISOString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["dateTimeIndexing.ts"],"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","String","match","Math","floor","v","padStart","join","convertValueFromIndex","field","type","settings","dateValue","Date","toISOString","
|
|
1
|
+
{"version":3,"sources":["dateTimeIndexing.ts"],"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","String","match","Math","floor","v","padStart","join","convertValueFromIndex","field","type","settings","dateValue","Date","toISOString","slice","convertValueToIndex","name","fieldType","unmappedType","toIndex","fromIndex"],"mappings":"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","sourcesContent":["import { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n // TODO remove when v5 goes out\n // this is a fix for pre beta.5\n if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {\n return String(value);\n }\n //\n const hours = Math.floor(value / 60 / 60);\n\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-datetime\",\n fieldType: \"datetime\",\n unmappedType: () => {\n return \"date\";\n },\n toIndex({ field, value }) {\n const dateValue = convertValueToIndex(value, field as CmsModelDateTimeField);\n return {\n value: dateValue\n };\n },\n fromIndex({ field, value }) {\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n});\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.base = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _base = require("@webiny/api-elasticsearch/indexConfiguration/base");
|
|
13
|
+
|
|
14
|
+
var _CmsEntryElasticsearchIndexPlugin = require("../../plugins/CmsEntryElasticsearchIndexPlugin");
|
|
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; }
|
|
19
|
+
|
|
20
|
+
const base = new _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin({
|
|
21
|
+
body: _objectSpread({}, _base.base)
|
|
22
|
+
});
|
|
23
|
+
exports.base = base;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["base.ts"],"names":["base","CmsEntryElasticsearchIndexPlugin","body","baseConfiguration"],"mappings":";;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,IAAI,GAAG,IAAIC,kEAAJ,CAAqC;AACrDC,EAAAA,IAAI,oBACGC,UADH;AADiD,CAArC,CAAb","sourcesContent":["import { base as baseConfiguration } from \"@webiny/api-elasticsearch/indexConfiguration/base\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\n\nexport const base = new CmsEntryElasticsearchIndexPlugin({\n body: {\n ...baseConfiguration\n }\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const elasticsearchIndexPlugins: () => import("../../plugins/CmsEntryElasticsearchIndexPlugin").CmsEntryElasticsearchIndexPlugin[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.elasticsearchIndexPlugins = void 0;
|
|
7
|
+
|
|
8
|
+
var _base = require("./base");
|
|
9
|
+
|
|
10
|
+
var _japanese = require("./japanese");
|
|
11
|
+
|
|
12
|
+
const elasticsearchIndexPlugins = () => {
|
|
13
|
+
return [_base.base, _japanese.japanese];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.elasticsearchIndexPlugins = elasticsearchIndexPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["elasticsearchIndexPlugins","base","japanese"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;AAC3C,SAAO,CAACC,UAAD,EAAOC,kBAAP,CAAP;AACH,CAFM","sourcesContent":["import { base } from \"./base\";\nimport { japanese } from \"./japanese\";\n\nexport const elasticsearchIndexPlugins = () => {\n return [base, japanese];\n};\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.japanese = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _CmsEntryElasticsearchIndexPlugin = require("../../plugins/CmsEntryElasticsearchIndexPlugin");
|
|
13
|
+
|
|
14
|
+
var _japanese = require("@webiny/api-elasticsearch/indexConfiguration/japanese");
|
|
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; }
|
|
19
|
+
|
|
20
|
+
const japanese = new _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin({
|
|
21
|
+
body: _objectSpread({}, _japanese.japanese),
|
|
22
|
+
locales: ["ja", "ja-jp"]
|
|
23
|
+
});
|
|
24
|
+
exports.japanese = japanese;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["japanese.ts"],"names":["japanese","CmsEntryElasticsearchIndexPlugin","body","japaneseConfiguration","locales"],"mappings":";;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,QAAQ,GAAG,IAAIC,kEAAJ,CAAqC;AACzDC,EAAAA,IAAI,oBACGC,kBADH,CADqD;AAIzDC,EAAAA,OAAO,EAAE,CAAC,IAAD,EAAO,OAAP;AAJgD,CAArC,CAAjB","sourcesContent":["import { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin\";\nimport { japanese as japaneseConfiguration } from \"@webiny/api-elasticsearch/indexConfiguration/japanese\";\n\nexport const japanese = new CmsEntryElasticsearchIndexPlugin({\n body: {\n ...japaneseConfiguration\n },\n locales: [\"ja\", \"ja-jp\"]\n});\n"]}
|
|
@@ -11,8 +11,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
14
|
-
var _operatorPluginsList = require("./operatorPluginsList");
|
|
15
|
-
|
|
16
14
|
var _transformValueForSearch = require("./transformValueForSearch");
|
|
17
15
|
|
|
18
16
|
var _searchPluginsList = require("./searchPluginsList");
|
|
@@ -35,11 +33,15 @@ var _CmsEntryElasticsearchSortModifierPlugin = require("../plugins/CmsEntryElast
|
|
|
35
33
|
|
|
36
34
|
var _CmsEntryElasticsearchBodyModifierPlugin = require("../plugins/CmsEntryElasticsearchBodyModifierPlugin");
|
|
37
35
|
|
|
36
|
+
var _operators = require("@webiny/api-elasticsearch/operators");
|
|
37
|
+
|
|
38
|
+
var _normalize = require("@webiny/api-elasticsearch/normalize");
|
|
39
|
+
|
|
38
40
|
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; }
|
|
39
41
|
|
|
40
42
|
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; }
|
|
41
43
|
|
|
42
|
-
const specialFields = ["published", "latest"
|
|
44
|
+
const specialFields = ["published", "latest"];
|
|
43
45
|
const noKeywordFields = ["date", "number", "boolean"];
|
|
44
46
|
|
|
45
47
|
const createElasticsearchSortParams = args => {
|
|
@@ -83,11 +85,17 @@ const createElasticsearchSortParams = args => {
|
|
|
83
85
|
*/
|
|
84
86
|
|
|
85
87
|
|
|
86
|
-
const createInitialQueryValue =
|
|
88
|
+
const createInitialQueryValue = params => {
|
|
89
|
+
const {
|
|
90
|
+
model,
|
|
91
|
+
where: initialWhere
|
|
92
|
+
} = params;
|
|
87
93
|
/**
|
|
88
94
|
* Cast as partial so we can remove unnecessary keys.
|
|
89
95
|
*/
|
|
90
|
-
|
|
96
|
+
|
|
97
|
+
const where = _objectSpread({}, initialWhere);
|
|
98
|
+
|
|
91
99
|
const query = {
|
|
92
100
|
must: [],
|
|
93
101
|
must_not: [],
|
|
@@ -97,25 +105,19 @@ const createInitialQueryValue = args => {
|
|
|
97
105
|
|
|
98
106
|
const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
|
|
99
107
|
|
|
100
|
-
if (sharedIndex
|
|
101
|
-
query.must.push({
|
|
102
|
-
term: {
|
|
103
|
-
"tenant.keyword": where.tenant
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
delete where["tenant"];
|
|
109
|
-
|
|
110
|
-
if (where.locale) {
|
|
108
|
+
if (sharedIndex) {
|
|
111
109
|
query.must.push({
|
|
112
110
|
term: {
|
|
113
|
-
"
|
|
111
|
+
"tenant.keyword": model.tenant
|
|
114
112
|
}
|
|
115
113
|
});
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
|
|
116
|
+
query.must.push({
|
|
117
|
+
term: {
|
|
118
|
+
"locale.keyword": model.locale
|
|
119
|
+
}
|
|
120
|
+
});
|
|
119
121
|
/**
|
|
120
122
|
* We must transform published and latest where args into something that is understandable by our Elasticsearch
|
|
121
123
|
*/
|
|
@@ -306,6 +308,38 @@ const applyFiltering = params => {
|
|
|
306
308
|
keyword
|
|
307
309
|
});
|
|
308
310
|
};
|
|
311
|
+
|
|
312
|
+
const applyFullTextSearch = params => {
|
|
313
|
+
const {
|
|
314
|
+
query,
|
|
315
|
+
modelFields,
|
|
316
|
+
term,
|
|
317
|
+
fields
|
|
318
|
+
} = params;
|
|
319
|
+
|
|
320
|
+
if (!term || term.length === 0 || fields.length === 0) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const fieldPaths = fields.reduce((collection, field) => {
|
|
325
|
+
const modelField = modelFields[field];
|
|
326
|
+
|
|
327
|
+
if (!modelField) {
|
|
328
|
+
return collection;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
collection.push(`values.${field}`);
|
|
332
|
+
return collection;
|
|
333
|
+
}, []);
|
|
334
|
+
query.must.push({
|
|
335
|
+
query_string: {
|
|
336
|
+
allow_leading_wildcard: true,
|
|
337
|
+
fields: fieldPaths,
|
|
338
|
+
query: (0, _normalize.normalizeValue)(term),
|
|
339
|
+
default_operator: "or"
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
};
|
|
309
343
|
/*
|
|
310
344
|
* Iterate through where keys and apply plugins where necessary
|
|
311
345
|
*/
|
|
@@ -313,11 +347,13 @@ const applyFiltering = params => {
|
|
|
313
347
|
|
|
314
348
|
const execElasticsearchBuildQueryPlugins = params => {
|
|
315
349
|
const {
|
|
350
|
+
model,
|
|
316
351
|
where: initialWhere,
|
|
317
352
|
modelFields,
|
|
318
353
|
parentPath,
|
|
319
354
|
plugins,
|
|
320
|
-
searchPlugins
|
|
355
|
+
searchPlugins,
|
|
356
|
+
fullTextSearch
|
|
321
357
|
} = params;
|
|
322
358
|
|
|
323
359
|
const where = _objectSpread({}, initialWhere);
|
|
@@ -325,6 +361,16 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
325
361
|
const query = createInitialQueryValue(_objectSpread(_objectSpread({}, params), {}, {
|
|
326
362
|
where
|
|
327
363
|
}));
|
|
364
|
+
/**
|
|
365
|
+
* Add full text search for requested fields.
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
applyFullTextSearch({
|
|
369
|
+
query,
|
|
370
|
+
modelFields,
|
|
371
|
+
term: fullTextSearch.term,
|
|
372
|
+
fields: fullTextSearch.fields
|
|
373
|
+
});
|
|
328
374
|
/**
|
|
329
375
|
* Always remove special fields, as these do not exist in Elasticsearch.
|
|
330
376
|
*/
|
|
@@ -337,7 +383,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
337
383
|
return query;
|
|
338
384
|
}
|
|
339
385
|
|
|
340
|
-
const operatorPlugins = (0,
|
|
386
|
+
const operatorPlugins = (0, _operators.getElasticsearchOperatorPluginsByLocale)(plugins, model.locale);
|
|
341
387
|
|
|
342
388
|
for (const key in where) {
|
|
343
389
|
if (where.hasOwnProperty(key) === false) {
|
|
@@ -347,9 +393,12 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
347
393
|
* We do not need to go further if value is undefined.
|
|
348
394
|
* There are few hardcoded possibilities when value is undefined, for example, ownedBy.
|
|
349
395
|
*/
|
|
396
|
+
// TODO figure out how to have type.
|
|
397
|
+
|
|
350
398
|
|
|
399
|
+
const value = where[key];
|
|
351
400
|
|
|
352
|
-
if (
|
|
401
|
+
if (value === undefined) {
|
|
353
402
|
continue;
|
|
354
403
|
}
|
|
355
404
|
|
|
@@ -379,13 +428,13 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
379
428
|
|
|
380
429
|
if (isRefFieldFiltering({
|
|
381
430
|
key,
|
|
382
|
-
value
|
|
431
|
+
value,
|
|
383
432
|
field: cmsField
|
|
384
433
|
})) {
|
|
385
434
|
/**
|
|
386
435
|
* We we need to go through each key in where[key] to determine the filters.
|
|
387
436
|
*/
|
|
388
|
-
for (const whereKey in
|
|
437
|
+
for (const whereKey in value) {
|
|
389
438
|
const {
|
|
390
439
|
operator
|
|
391
440
|
} = (0, _where.parseWhereKey)(whereKey);
|
|
@@ -394,7 +443,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
394
443
|
modelField,
|
|
395
444
|
operator,
|
|
396
445
|
key: whereKey,
|
|
397
|
-
value:
|
|
446
|
+
value: value[whereKey],
|
|
398
447
|
searchPlugins,
|
|
399
448
|
operatorPlugins,
|
|
400
449
|
parentPath
|
|
@@ -409,7 +458,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
409
458
|
modelField,
|
|
410
459
|
operator,
|
|
411
460
|
key,
|
|
412
|
-
value
|
|
461
|
+
value,
|
|
413
462
|
searchPlugins,
|
|
414
463
|
operatorPlugins,
|
|
415
464
|
parentPath
|
|
@@ -427,10 +476,12 @@ const createElasticsearchQueryBody = params => {
|
|
|
427
476
|
parentPath = null
|
|
428
477
|
} = params;
|
|
429
478
|
const {
|
|
430
|
-
where,
|
|
479
|
+
where = {},
|
|
431
480
|
after,
|
|
432
481
|
limit,
|
|
433
|
-
sort: initialSort
|
|
482
|
+
sort: initialSort,
|
|
483
|
+
search,
|
|
484
|
+
fields
|
|
434
485
|
} = args;
|
|
435
486
|
const modelFields = (0, _fields.createModelFields)(plugins, model);
|
|
436
487
|
const searchPlugins = (0, _searchPluginsList.searchPluginsList)(plugins);
|
|
@@ -440,7 +491,11 @@ const createElasticsearchQueryBody = params => {
|
|
|
440
491
|
where,
|
|
441
492
|
modelFields,
|
|
442
493
|
parentPath,
|
|
443
|
-
searchPlugins
|
|
494
|
+
searchPlugins,
|
|
495
|
+
fullTextSearch: {
|
|
496
|
+
term: search,
|
|
497
|
+
fields: fields || []
|
|
498
|
+
}
|
|
444
499
|
});
|
|
445
500
|
const queryPlugins = plugins.byType(_CmsEntryElasticsearchQueryModifierPlugin.CmsEntryElasticsearchQueryModifierPlugin.type).filter(pl => {
|
|
446
501
|
return !pl.modelId || pl.modelId === model.modelId;
|