@webiny/api-headless-cms-ddb-es 6.0.0-alpha.5 → 6.0.0-rc.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/README.md +6 -30
- package/configurations.d.ts +4 -5
- package/configurations.js +12 -24
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +4 -6
- package/definitions/entry.js +5 -174
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +6 -7
- package/definitions/group.js +5 -58
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +6 -7
- package/definitions/model.js +5 -102
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +59 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -2
- package/dynamoDb/index.js +5 -13
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/longText.js +10 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +10 -18
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/createElasticsearchIndex.js +7 -15
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js +3 -10
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +3 -11
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +1 -8
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +1 -8
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.d.ts +1 -1
- package/elasticsearch/indexing/index.js +8 -16
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
- package/elasticsearch/indexing/jsonIndexing.js +1 -8
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +1 -8
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +1 -8
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
- package/elasticsearch/indexing/objectIndexing.js +6 -13
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +1 -8
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.d.ts +1 -1
- package/elasticsearch/indices/base.js +4 -10
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.d.ts +1 -1
- package/elasticsearch/indices/index.js +3 -11
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/search/index.d.ts +1 -1
- package/elasticsearch/search/index.js +4 -11
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.d.ts +1 -1
- package/elasticsearch/search/refSearch.js +3 -10
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/elasticsearch/search/searchableJson.d.ts +1 -1
- package/elasticsearch/search/searchableJson.js +9 -16
- package/elasticsearch/search/searchableJson.js.map +1 -1
- package/elasticsearch/search/timeSearch.d.ts +1 -1
- package/elasticsearch/search/timeSearch.js +3 -10
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.d.ts +9 -9
- package/helpers/entryIndexHelpers.js +32 -26
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +1 -1
- package/helpers/fieldIdentifier.js +2 -10
- package/helpers/fieldIdentifier.js.map +1 -1
- package/helpers/index.d.ts +2 -2
- package/helpers/index.js +2 -27
- package/helpers/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +98 -133
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +0 -2
- package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +1 -7
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +23 -35
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +3 -3
- package/operations/entry/dataLoader/index.js +10 -31
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +3 -4
- package/operations/entry/dataLoader/types.js +1 -5
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +13 -13
- package/operations/entry/dataLoaders.js +15 -25
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +2 -2
- package/operations/entry/elasticsearch/body.js +21 -28
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +2 -2
- package/operations/entry/elasticsearch/fields.js +110 -24
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +9 -17
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +6 -5
- package/operations/entry/elasticsearch/filtering/exec.js +48 -45
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +1 -16
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/path.js +5 -15
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +6 -14
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.js +5 -12
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +7 -15
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +7 -15
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +1 -8
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +4 -12
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/fullTextSearch.js +6 -12
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +1 -8
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
- package/operations/entry/elasticsearch/initialQuery.js +9 -27
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.d.ts +1 -1
- package/operations/entry/elasticsearch/keyword.js +4 -9
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +1 -2
- package/operations/entry/elasticsearch/plugins/operator.js +4 -19
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +1 -1
- package/operations/entry/elasticsearch/plugins/search.js +5 -13
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +1 -8
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.d.ts +3 -3
- package/operations/entry/elasticsearch/sort.js +51 -33
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js +4 -9
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +2 -2
- package/operations/entry/elasticsearch/types.js +1 -5
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +5 -4
- package/operations/entry/index.js +333 -515
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +31 -1
- package/operations/entry/keys.js +56 -19
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +3 -12
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
- package/operations/entry/transformations/convertEntryKeys.js +2 -10
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +16 -16
- package/operations/entry/transformations/index.js +22 -30
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +27 -34
- package/operations/entry/transformations/modifyEntryValues.js +1 -8
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
- package/operations/entry/transformations/transformEntryKeys.js +4 -11
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +6 -6
- package/operations/entry/transformations/transformEntryToIndex.js +3 -10
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.d.ts +5 -4
- package/operations/group/index.js +39 -73
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +38 -57
- package/operations/model/index.js.map +1 -1
- package/package.json +27 -32
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
- package/plugins/CmsElasticsearchModelFieldPlugin.js +2 -8
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -9
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +12 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js +4 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js +2 -9
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/plugins/index.d.ts +8 -8
- package/plugins/index.js +8 -93
- package/plugins/index.js.map +1 -1
- package/tasks/createIndexTaskPlugin.d.ts +2 -2
- package/tasks/createIndexTaskPlugin.js +36 -62
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.d.ts +23 -26
- package/types.js +5 -8
- package/types.js.map +1 -1
- package/values/NoValueContainer.js +1 -8
- package/values/NoValueContainer.js.map +1 -1
- package/definitions/entryElasticsearch.d.ts +0 -9
- package/definitions/entryElasticsearch.js +0 -41
- package/definitions/entryElasticsearch.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/definitions/table.d.ts +0 -8
- package/definitions/table.js +0 -25
- package/definitions/table.js.map +0 -1
- package/definitions/tableElasticsearch.d.ts +0 -8
- package/definitions/tableElasticsearch.js +0 -25
- package/definitions/tableElasticsearch.js.map +0 -1
- package/elasticsearch/indices/japanese.d.ts +0 -2
- package/elasticsearch/indices/japanese.js +0 -14
- package/elasticsearch/indices/japanese.js.map +0 -1
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +0 -9
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +0 -26
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +0 -1
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
- package/operations/system/indexes.d.ts +0 -10
- package/operations/system/indexes.js +0 -41
- package/operations/system/indexes.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFullTextSearchFields","params","term","model","fields","length","trim","reduce","collection","fieldId","field","find","f","push"
|
|
1
|
+
{"version":3,"names":["createFullTextSearchFields","params","term","model","fields","length","trim","reduce","collection","fieldId","field","find","f","push"],"sources":["fullTextSearchFields.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n model: CmsModel;\n term?: string;\n fields?: string[];\n}\nexport const createFullTextSearchFields = (params: Params): CmsModelField[] => {\n const { term, model, fields } = params;\n if (!fields || fields.length === 0 || !term || term.trim().length === 0) {\n return [];\n }\n return fields.reduce<CmsModelField[]>((collection, fieldId) => {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n return collection;\n }\n collection.push(field);\n return collection;\n }, []);\n};\n"],"mappings":"AAOA,OAAO,MAAMA,0BAA0B,GAAIC,MAAc,IAAsB;EAC3E,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGH,MAAM;EACtC,IAAI,CAACG,MAAM,IAAIA,MAAM,CAACC,MAAM,KAAK,CAAC,IAAI,CAACH,IAAI,IAAIA,IAAI,CAACI,IAAI,CAAC,CAAC,CAACD,MAAM,KAAK,CAAC,EAAE;IACrE,OAAO,EAAE;EACb;EACA,OAAOD,MAAM,CAACG,MAAM,CAAkB,CAACC,UAAU,EAAEC,OAAO,KAAK;IAC3D,MAAMC,KAAK,GAAGP,KAAK,CAACC,MAAM,CAACO,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,KAAKA,OAAO,CAAC;IAC3D,IAAI,CAACC,KAAK,EAAE;MACR,OAAOF,UAAU;IACrB;IACAA,UAAU,CAACK,IAAI,CAACH,KAAK,CAAC;IACtB,OAAOF,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
|
|
2
|
-
import type { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types.js";
|
|
2
|
+
import type { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
3
|
export declare const createBaseQuery: () => ElasticsearchBoolQueryConfig;
|
|
4
4
|
interface Params {
|
|
5
5
|
model: CmsModel;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createInitialQuery = exports.createBaseQuery = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _recordType = require("../recordType");
|
|
10
|
-
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
11
|
-
const createBaseQuery = () => {
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { createLatestRecordType, createPublishedRecordType } from "../recordType.js";
|
|
3
|
+
import { isSharedElasticsearchIndex } from "@webiny/api-elasticsearch";
|
|
4
|
+
export const createBaseQuery = () => {
|
|
12
5
|
return {
|
|
13
6
|
must: [],
|
|
14
7
|
must_not: [],
|
|
@@ -16,7 +9,6 @@ const createBaseQuery = () => {
|
|
|
16
9
|
filter: []
|
|
17
10
|
};
|
|
18
11
|
};
|
|
19
|
-
exports.createBaseQuery = createBaseQuery;
|
|
20
12
|
/**
|
|
21
13
|
* Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.
|
|
22
14
|
* We allow either published or either latest.
|
|
@@ -25,7 +17,7 @@ exports.createBaseQuery = createBaseQuery;
|
|
|
25
17
|
*
|
|
26
18
|
* We add the query.filter terms because we do not need scored search here and it is a bit faster.
|
|
27
19
|
*/
|
|
28
|
-
const createInitialQuery = params => {
|
|
20
|
+
export const createInitialQuery = params => {
|
|
29
21
|
const {
|
|
30
22
|
model,
|
|
31
23
|
where
|
|
@@ -37,7 +29,7 @@ const createInitialQuery = params => {
|
|
|
37
29
|
*
|
|
38
30
|
* TODO determine if we want to search across tenants in shared index?
|
|
39
31
|
*/
|
|
40
|
-
const sharedIndex =
|
|
32
|
+
const sharedIndex = isSharedElasticsearchIndex();
|
|
41
33
|
if (sharedIndex) {
|
|
42
34
|
/**
|
|
43
35
|
* Tenant for the filtering is taken from the model.
|
|
@@ -57,15 +49,6 @@ const createInitialQuery = params => {
|
|
|
57
49
|
"modelId.keyword": model.modelId
|
|
58
50
|
}
|
|
59
51
|
});
|
|
60
|
-
/**
|
|
61
|
-
* TODO determine if we want to search across locales?
|
|
62
|
-
* This search would anyway work for a single model and when sharing index.
|
|
63
|
-
*/
|
|
64
|
-
query.filter.push({
|
|
65
|
-
term: {
|
|
66
|
-
"locale.keyword": model.locale
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
52
|
}
|
|
70
53
|
|
|
71
54
|
/**
|
|
@@ -74,13 +57,13 @@ const createInitialQuery = params => {
|
|
|
74
57
|
if (where.published === true) {
|
|
75
58
|
query.filter.push({
|
|
76
59
|
term: {
|
|
77
|
-
"__type.keyword":
|
|
60
|
+
"__type.keyword": createPublishedRecordType()
|
|
78
61
|
}
|
|
79
62
|
});
|
|
80
63
|
} else if (where.latest === true) {
|
|
81
64
|
query.filter.push({
|
|
82
65
|
term: {
|
|
83
|
-
"__type.keyword":
|
|
66
|
+
"__type.keyword": createLatestRecordType()
|
|
84
67
|
}
|
|
85
68
|
});
|
|
86
69
|
}
|
|
@@ -89,7 +72,7 @@ const createInitialQuery = params => {
|
|
|
89
72
|
* We do not allow filtering without the published or latest parameter.
|
|
90
73
|
* Also, we do not want to set the default one, as there is a large possibility for user error when filtering.
|
|
91
74
|
*/else {
|
|
92
|
-
throw new
|
|
75
|
+
throw new WebinyError(`Cannot call Elasticsearch query when not setting "published" or "latest".`, "OPENSEARCH_UNSUPPORTED_QUERY", {
|
|
93
76
|
where
|
|
94
77
|
});
|
|
95
78
|
}
|
|
@@ -101,6 +84,5 @@ const createInitialQuery = params => {
|
|
|
101
84
|
delete where.latest;
|
|
102
85
|
return query;
|
|
103
86
|
};
|
|
104
|
-
exports.createInitialQuery = createInitialQuery;
|
|
105
87
|
|
|
106
88
|
//# sourceMappingURL=initialQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","createLatestRecordType","createPublishedRecordType","isSharedElasticsearchIndex","createBaseQuery","must","must_not","should","filter","createInitialQuery","params","model","where","query","sharedIndex","push","term","tenant","modelId","published","latest"],"sources":["initialQuery.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types.js\";\nimport type { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createLatestRecordType, createPublishedRecordType } from \"../recordType.js\";\nimport { isSharedElasticsearchIndex } from \"@webiny/api-elasticsearch\";\n\nexport const createBaseQuery = (): ElasticsearchBoolQueryConfig => {\n return {\n must: [],\n must_not: [],\n should: [],\n filter: []\n };\n};\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere;\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 *\n *\n * We add the query.filter terms because we do not need scored search here and it is a bit faster.\n */\nexport const createInitialQuery = (params: Params): ElasticsearchBoolQueryConfig => {\n const { model, where } = params;\n\n const query = createBaseQuery();\n\n /**\n * When ES index is shared between tenants, we need to filter records by tenant ID\n *\n * TODO determine if we want to search across tenants in shared index?\n */\n const sharedIndex = isSharedElasticsearchIndex();\n if (sharedIndex) {\n /**\n * Tenant for the filtering is taken from the model.\n *\n * TODO determine if we want to send it in the \"where\" parameter?\n */\n query.filter.push({\n term: {\n \"tenant.keyword\": model.tenant\n }\n });\n /**\n * Also, we must search only in selected model.\n */\n query.filter.push({\n term: {\n \"modelId.keyword\": model.modelId\n }\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.filter.push({\n term: {\n \"__type.keyword\": createPublishedRecordType()\n }\n });\n } else if (where.latest === true) {\n query.filter.push({\n term: {\n \"__type.keyword\": createLatestRecordType()\n }\n });\n }\n //\n /**\n * We do not allow filtering without the published or latest parameter.\n * Also, we do not want to set the default one, as there is a large possibility for user error when filtering.\n */\n else {\n throw new WebinyError(\n `Cannot call Elasticsearch query when not setting \"published\" or \"latest\".`,\n \"OPENSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n /**\n * We need to remove fields that actually do not exist on the record - it will break otherwise.\n * This will modify the original object, which is what we want.\n */\n delete where.published;\n delete where.latest;\n\n return query;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAGvC,SAASC,sBAAsB,EAAEC,yBAAyB;AAC1D,SAASC,0BAA0B,QAAQ,2BAA2B;AAEtE,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAoC;EAC/D,OAAO;IACHC,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE,EAAE;IACZC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE;EACZ,CAAC;AACL,CAAC;AAMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAIC,MAAc,IAAmC;EAChF,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAE/B,MAAMG,KAAK,GAAGT,eAAe,CAAC,CAAC;;EAE/B;AACJ;AACA;AACA;AACA;EACI,MAAMU,WAAW,GAAGX,0BAA0B,CAAC,CAAC;EAChD,IAAIW,WAAW,EAAE;IACb;AACR;AACA;AACA;AACA;IACQD,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAEL,KAAK,CAACM;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQJ,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,iBAAiB,EAAEL,KAAK,CAACO;MAC7B;IACJ,CAAC,CAAC;EACN;;EAEA;AACJ;AACA;EACI,IAAIN,KAAK,CAACO,SAAS,KAAK,IAAI,EAAE;IAC1BN,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAEd,yBAAyB,CAAC;MAChD;IACJ,CAAC,CAAC;EACN,CAAC,MAAM,IAAIU,KAAK,CAACQ,MAAM,KAAK,IAAI,EAAE;IAC9BP,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAEf,sBAAsB,CAAC;MAC7C;IACJ,CAAC,CAAC;EACN;EACA;EACA;AACJ;AACA;AACA,KAHI,KAIK;IACD,MAAM,IAAID,WAAW,CACjB,2EAA2E,EAC3E,8BAA8B,EAC9B;MACIY;IACJ,CACJ,CAAC;EACL;EACA;AACJ;AACA;AACA;EACI,OAAOA,KAAK,CAACO,SAAS;EACtB,OAAOP,KAAK,CAACQ,MAAM;EAEnB,OAAOP,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ModelField } from "./types";
|
|
1
|
+
import type { ModelField } from "./types.js";
|
|
2
2
|
export declare const hasKeyword: (field: ModelField) => boolean;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.hasKeyword = void 0;
|
|
1
|
+
import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
|
|
7
2
|
const noKeywordFields = ["date", "datetime", "number", "boolean"];
|
|
8
|
-
const hasKeyword = field => {
|
|
3
|
+
export const hasKeyword = field => {
|
|
4
|
+
const fieldType = getBaseFieldType(field);
|
|
9
5
|
/**
|
|
10
6
|
* We defined some field types that MUST have no keyword added to the field path
|
|
11
7
|
*/
|
|
12
|
-
if (noKeywordFields.includes(
|
|
8
|
+
if (noKeywordFields.includes(fieldType)) {
|
|
13
9
|
return false;
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
@@ -31,6 +27,5 @@ const hasKeyword = field => {
|
|
|
31
27
|
*/
|
|
32
28
|
return true;
|
|
33
29
|
};
|
|
34
|
-
exports.hasKeyword = hasKeyword;
|
|
35
30
|
|
|
36
31
|
//# sourceMappingURL=keyword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["noKeywordFields","hasKeyword","field","
|
|
1
|
+
{"version":3,"names":["getBaseFieldType","noKeywordFields","hasKeyword","field","fieldType","includes","unmappedType","keyword"],"sources":["keyword.ts"],"sourcesContent":["import type { ModelField } from \"./types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nconst noKeywordFields: string[] = [\"date\", \"datetime\", \"number\", \"boolean\"];\nexport const hasKeyword = (field: ModelField): boolean => {\n const fieldType = getBaseFieldType(field);\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(fieldType)) {\n return false;\n }\n /**\n * If field has unmapped type defined, do not add keyword.\n */\n //\n else if (field.unmappedType) {\n return false;\n }\n /**\n * And if specifically defined that field has no keyword, do not add it.\n */\n //\n else if (field.keyword === false) {\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,oDAAoD;AAErF,MAAMC,eAAyB,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC;AAC3E,OAAO,MAAMC,UAAU,GAAIC,KAAiB,IAAc;EACtD,MAAMC,SAAS,GAAGJ,gBAAgB,CAACG,KAAK,CAAC;EACzC;AACJ;AACA;EACI,IAAIF,eAAe,CAACI,QAAQ,CAACD,SAAS,CAAC,EAAE;IACrC,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAID,KAAK,CAACG,YAAY,EAAE;IACzB,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAIH,KAAK,CAACI,OAAO,KAAK,KAAK,EAAE;IAC9B,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins";
|
|
1
|
+
import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins/index.js";
|
|
2
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
4
|
interface Params {
|
|
5
5
|
plugins: PluginsContainer;
|
|
6
6
|
model: CmsModel;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBodyModifierPluginList = void 0;
|
|
7
|
-
var _plugins = require("../../../../plugins");
|
|
8
|
-
const createBodyModifierPluginList = ({
|
|
1
|
+
import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins/index.js";
|
|
2
|
+
export const createBodyModifierPluginList = ({
|
|
9
3
|
plugins,
|
|
10
4
|
model
|
|
11
5
|
}) => {
|
|
12
|
-
return plugins.byType(
|
|
6
|
+
return plugins.byType(CmsEntryElasticsearchBodyModifierPlugin.type).filter(pl => {
|
|
13
7
|
return !pl.modelId || pl.modelId === model.modelId;
|
|
14
8
|
});
|
|
15
9
|
};
|
|
16
|
-
exports.createBodyModifierPluginList = createBodyModifierPluginList;
|
|
17
10
|
|
|
18
11
|
//# sourceMappingURL=bodyModifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["CmsEntryElasticsearchBodyModifierPlugin","createBodyModifierPluginList","plugins","model","byType","type","filter","pl","modelId"],"sources":["bodyModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createBodyModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":"AAAA,SAASA,uCAAuC;AAQhD,OAAO,MAAMC,4BAA4B,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACxE,OAAOD,OAAO,CACTE,MAAM,CACHJ,uCAAuC,CAACK,IAC5C,CAAC,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKL,KAAK,CAACK,OAAO;EACtD,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import type { ElasticsearchQueryBuilderOperatorPlugins } from "../types";
|
|
2
|
+
import type { ElasticsearchQueryBuilderOperatorPlugins } from "../types.js";
|
|
3
3
|
interface Params {
|
|
4
4
|
plugins: PluginsContainer;
|
|
5
|
-
locale: string;
|
|
6
5
|
}
|
|
7
6
|
export declare const createOperatorPluginList: (params: Params) => ElasticsearchQueryBuilderOperatorPlugins;
|
|
8
7
|
export {};
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createOperatorPluginList = void 0;
|
|
7
|
-
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
8
|
-
const createOperatorPluginList = params => {
|
|
1
|
+
import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
|
|
2
|
+
export const createOperatorPluginList = params => {
|
|
9
3
|
const {
|
|
10
|
-
plugins
|
|
11
|
-
locale
|
|
4
|
+
plugins
|
|
12
5
|
} = params;
|
|
13
6
|
/**
|
|
14
7
|
* We always set the last one operator plugin added.
|
|
15
8
|
* This way user can override the plugins.
|
|
16
9
|
*/
|
|
17
|
-
return plugins.byType(
|
|
10
|
+
return plugins.byType(ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
|
|
18
11
|
const operator = plugin.getOperator();
|
|
19
|
-
/**
|
|
20
|
-
* We only allow the plugins which can pass the locale test.
|
|
21
|
-
* The default plugins always return true.
|
|
22
|
-
*/
|
|
23
|
-
if (plugin.isLocaleSupported(locale) === false) {
|
|
24
|
-
return acc;
|
|
25
|
-
}
|
|
26
12
|
/**
|
|
27
13
|
* We also only allow the override of the plugins if the new plugin is NOT a default one.
|
|
28
14
|
* If a user sets the plugin name ending with .default, we cannot do anything about it.
|
|
@@ -34,6 +20,5 @@ const createOperatorPluginList = params => {
|
|
|
34
20
|
return acc;
|
|
35
21
|
}, {});
|
|
36
22
|
};
|
|
37
|
-
exports.createOperatorPluginList = createOperatorPluginList;
|
|
38
23
|
|
|
39
24
|
//# sourceMappingURL=operator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ElasticsearchQueryBuilderOperatorPlugin","createOperatorPluginList","params","plugins","byType","type","reduce","acc","plugin","operator","getOperator","name","match"],"sources":["operator.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport type { ElasticsearchQueryBuilderOperatorPlugins } from \"../types.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n}\nexport const createOperatorPluginList = (\n params: Params\n): ElasticsearchQueryBuilderOperatorPlugins => {\n const { plugins } = params;\n /**\n * We always set the last one operator plugin added.\n * This way user can override the plugins.\n */\n return plugins\n .byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n )\n .reduce<ElasticsearchQueryBuilderOperatorPlugins>((acc, plugin) => {\n const operator = plugin.getOperator();\n /**\n * We also only allow the override of the plugins if the new plugin is NOT a default one.\n * If a user sets the plugin name ending with .default, we cannot do anything about it.\n */\n if (!!acc[operator] && (plugin.name || \"\").match(/\\.default$/)) {\n return acc;\n }\n acc[operator] = plugin;\n return acc;\n }, {});\n};\n"],"mappings":"AACA,SAASA,uCAAuC,QAAQ,2BAA2B;AAMnF,OAAO,MAAMC,wBAAwB,GACjCC,MAAc,IAC6B;EAC3C,MAAM;IAAEC;EAAQ,CAAC,GAAGD,MAAM;EAC1B;AACJ;AACA;AACA;EACI,OAAOC,OAAO,CACTC,MAAM,CACHJ,uCAAuC,CAACK,IAC5C,CAAC,CACAC,MAAM,CAA2C,CAACC,GAAG,EAAEC,MAAM,KAAK;IAC/D,MAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;IACrC;AACZ;AACA;AACA;IACY,IAAI,CAAC,CAACH,GAAG,CAACE,QAAQ,CAAC,IAAI,CAACD,MAAM,CAACG,IAAI,IAAI,EAAE,EAAEC,KAAK,CAAC,YAAY,CAAC,EAAE;MAC5D,OAAOL,GAAG;IACd;IACAA,GAAG,CAACE,QAAQ,CAAC,GAAGD,MAAM;IACtB,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsEntryElasticsearchQueryModifierPlugin } from "../../../../plugins";
|
|
1
|
+
import { CmsEntryElasticsearchQueryModifierPlugin } from "../../../../plugins/index.js";
|
|
2
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
4
|
interface Params {
|
|
5
5
|
plugins: PluginsContainer;
|
|
6
6
|
model: CmsModel;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createQueryModifierPluginList = void 0;
|
|
7
|
-
var _plugins = require("../../../../plugins");
|
|
8
|
-
const createQueryModifierPluginList = ({
|
|
1
|
+
import { CmsEntryElasticsearchQueryModifierPlugin } from "../../../../plugins/index.js";
|
|
2
|
+
export const createQueryModifierPluginList = ({
|
|
9
3
|
plugins,
|
|
10
4
|
model
|
|
11
5
|
}) => {
|
|
12
|
-
return plugins.byType(
|
|
6
|
+
return plugins.byType(CmsEntryElasticsearchQueryModifierPlugin.type).filter(pl => {
|
|
13
7
|
return !pl.modelId || pl.modelId === model.modelId;
|
|
14
8
|
});
|
|
15
9
|
};
|
|
16
|
-
exports.createQueryModifierPluginList = createQueryModifierPluginList;
|
|
17
10
|
|
|
18
11
|
//# sourceMappingURL=queryModifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["CmsEntryElasticsearchQueryModifierPlugin","createQueryModifierPluginList","plugins","model","byType","type","filter","pl","modelId"],"sources":["queryModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createQueryModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":"AAAA,SAASA,wCAAwC;AAQjD,OAAO,MAAMC,6BAA6B,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACzE,OAAOD,OAAO,CACTE,MAAM,CACHJ,wCAAwC,CAACK,IAC7C,CAAC,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKL,KAAK,CAACK,OAAO;EACtD,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createSearchPluginList = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _plugins = require("../../../../plugins");
|
|
10
|
-
const createSearchPluginList = ({
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../../../plugins/index.js";
|
|
3
|
+
export const createSearchPluginList = ({
|
|
11
4
|
plugins
|
|
12
5
|
}) => {
|
|
13
|
-
return plugins.byType(
|
|
6
|
+
return plugins.byType(CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type).reduce((plugins, plugin) => {
|
|
14
7
|
if (plugins[plugin.fieldType]) {
|
|
15
|
-
throw new
|
|
8
|
+
throw new WebinyError("There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.", "PLUGIN_ALREADY_EXISTS", {
|
|
16
9
|
fieldType: plugin.fieldType,
|
|
17
10
|
name: plugin.name || "unknown"
|
|
18
11
|
});
|
|
@@ -21,6 +14,5 @@ const createSearchPluginList = ({
|
|
|
21
14
|
return plugins;
|
|
22
15
|
}, {});
|
|
23
16
|
};
|
|
24
|
-
exports.createSearchPluginList = createSearchPluginList;
|
|
25
17
|
|
|
26
18
|
//# sourceMappingURL=search.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","createSearchPluginList","plugins","byType","type","reduce","plugin","fieldType","name"],"sources":["search.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { ElasticsearchQuerySearchValuePlugins } from \"../types.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n}\nexport const createSearchPluginList = ({\n plugins\n}: Params): ElasticsearchQuerySearchValuePlugins => {\n return plugins\n .byType<CmsEntryElasticsearchQueryBuilderValueSearchPlugin>(\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type\n )\n .reduce<ElasticsearchQuerySearchValuePlugins>((plugins, plugin) => {\n if (plugins[plugin.fieldType]) {\n throw new WebinyError(\n \"There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.\",\n \"PLUGIN_ALREADY_EXISTS\",\n {\n fieldType: plugin.fieldType,\n name: plugin.name || \"unknown\"\n }\n );\n }\n plugins[plugin.fieldType] = plugin;\n\n return plugins;\n }, {});\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,kDAAkD;AAO3D,OAAO,MAAMC,sBAAsB,GAAGA,CAAC;EACnCC;AACI,CAAC,KAA2C;EAChD,OAAOA,OAAO,CACTC,MAAM,CACHH,kDAAkD,CAACI,IACvD,CAAC,CACAC,MAAM,CAAuC,CAACH,OAAO,EAAEI,MAAM,KAAK;IAC/D,IAAIJ,OAAO,CAACI,MAAM,CAACC,SAAS,CAAC,EAAE;MAC3B,MAAM,IAAIR,WAAW,CACjB,mFAAmF,EACnF,uBAAuB,EACvB;QACIQ,SAAS,EAAED,MAAM,CAACC,SAAS;QAC3BC,IAAI,EAAEF,MAAM,CAACE,IAAI,IAAI;MACzB,CACJ,CAAC;IACL;IACAN,OAAO,CAACI,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAElC,OAAOJ,OAAO;EAClB,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsEntryElasticsearchSortModifierPlugin } from "../../../../plugins";
|
|
1
|
+
import { CmsEntryElasticsearchSortModifierPlugin } from "../../../../plugins/index.js";
|
|
2
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
4
|
interface Params {
|
|
5
5
|
plugins: PluginsContainer;
|
|
6
6
|
model: CmsModel;
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createSortModifierPluginList = void 0;
|
|
7
|
-
var _plugins = require("../../../../plugins");
|
|
8
|
-
const createSortModifierPluginList = ({
|
|
1
|
+
import { CmsEntryElasticsearchSortModifierPlugin } from "../../../../plugins/index.js";
|
|
2
|
+
export const createSortModifierPluginList = ({
|
|
9
3
|
plugins,
|
|
10
4
|
model
|
|
11
5
|
}) => {
|
|
12
|
-
return plugins.byType(
|
|
6
|
+
return plugins.byType(CmsEntryElasticsearchSortModifierPlugin.type).filter(pl => {
|
|
13
7
|
return !pl.modelId || pl.modelId === model.modelId;
|
|
14
8
|
});
|
|
15
9
|
};
|
|
16
|
-
exports.createSortModifierPluginList = createSortModifierPluginList;
|
|
17
10
|
|
|
18
11
|
//# sourceMappingURL=sortModifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["CmsEntryElasticsearchSortModifierPlugin","createSortModifierPluginList","plugins","model","byType","type","filter","pl","modelId"],"sources":["sortModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createSortModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":"AAAA,SAASA,uCAAuC;AAQhD,OAAO,MAAMC,4BAA4B,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACxE,OAAOD,OAAO,CACTE,MAAM,CACHJ,uCAAuC,CAACK,IAC5C,CAAC,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKL,KAAK,CAACK,OAAO;EACtD,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.shouldIgnoreEsResponseError = void 0;
|
|
7
1
|
const IGNORED_ES_SEARCH_EXCEPTIONS = ["index_not_found_exception", "search_phase_execution_exception"];
|
|
8
|
-
const shouldIgnoreEsResponseError = error => {
|
|
2
|
+
export const shouldIgnoreEsResponseError = error => {
|
|
9
3
|
return IGNORED_ES_SEARCH_EXCEPTIONS.includes(error.message);
|
|
10
4
|
};
|
|
11
|
-
exports.shouldIgnoreEsResponseError = shouldIgnoreEsResponseError;
|
|
12
5
|
|
|
13
6
|
//# sourceMappingURL=shouldIgnoreEsResponseError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["IGNORED_ES_SEARCH_EXCEPTIONS","shouldIgnoreEsResponseError","error","includes","message"
|
|
1
|
+
{"version":3,"names":["IGNORED_ES_SEARCH_EXCEPTIONS","shouldIgnoreEsResponseError","error","includes","message"],"sources":["shouldIgnoreEsResponseError.ts"],"sourcesContent":["import type WebinyError from \"@webiny/error\";\n\nconst IGNORED_ES_SEARCH_EXCEPTIONS = [\n \"index_not_found_exception\",\n \"search_phase_execution_exception\"\n];\n\nexport const shouldIgnoreEsResponseError = (error: WebinyError) => {\n return IGNORED_ES_SEARCH_EXCEPTIONS.includes(error.message);\n};\n"],"mappings":"AAEA,MAAMA,4BAA4B,GAAG,CACjC,2BAA2B,EAC3B,kCAAkC,CACrC;AAED,OAAO,MAAMC,2BAA2B,GAAIC,KAAkB,IAAK;EAC/D,OAAOF,4BAA4B,CAACG,QAAQ,CAACD,KAAK,CAACE,OAAO,CAAC;AAC/D,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Sort as esSort } from "@webiny/api-elasticsearch/types";
|
|
1
|
+
import type { Sort as esSort } from "@webiny/api-elasticsearch/types.js";
|
|
2
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import type { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
-
import type { ModelFields } from "./types";
|
|
3
|
+
import type { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
|
+
import type { ModelFields } from "./types.js";
|
|
5
5
|
interface Params {
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
sort?: CmsEntryListSort;
|
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { createSort, ElasticsearchFieldPlugin } from "@webiny/api-elasticsearch";
|
|
2
|
+
import { hasKeyword } from "./keyword.js";
|
|
3
|
+
import { createSearchPluginList } from "./plugins/search.js";
|
|
4
|
+
import { createFieldPathFactory } from "./filtering/path.js";
|
|
5
|
+
import { NoValueContainer } from "../../../values/NoValueContainer.js";
|
|
6
|
+
const matchField = input => {
|
|
7
|
+
const valuesMatch = input.match(/^values_([a-zA-Z-0-9_]+)_(ASC|DESC)$/);
|
|
8
|
+
if (valuesMatch) {
|
|
9
|
+
const [, fieldId, order] = valuesMatch;
|
|
10
|
+
return {
|
|
11
|
+
fieldId,
|
|
12
|
+
isValues: true,
|
|
13
|
+
order: order
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const nonValues = input.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);
|
|
17
|
+
if (!nonValues) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const [, fieldId, order] = nonValues;
|
|
21
|
+
return {
|
|
22
|
+
fieldId,
|
|
23
|
+
isValues: false,
|
|
24
|
+
order: order
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export const createElasticsearchSort = params => {
|
|
13
28
|
const {
|
|
14
29
|
sort,
|
|
15
30
|
modelFields,
|
|
@@ -22,10 +37,10 @@ const createElasticsearchSort = params => {
|
|
|
22
37
|
}
|
|
23
38
|
}];
|
|
24
39
|
}
|
|
25
|
-
const searchPlugins =
|
|
40
|
+
const searchPlugins = createSearchPluginList({
|
|
26
41
|
plugins
|
|
27
42
|
});
|
|
28
|
-
const createFieldPath =
|
|
43
|
+
const createFieldPath = createFieldPathFactory({
|
|
29
44
|
plugins: searchPlugins
|
|
30
45
|
});
|
|
31
46
|
const fieldIdToStorageIdIdMap = {};
|
|
@@ -33,29 +48,28 @@ const createElasticsearchSort = params => {
|
|
|
33
48
|
/**
|
|
34
49
|
* We do not support sorting by nested fields.
|
|
35
50
|
*/
|
|
36
|
-
|
|
51
|
+
const isValues = field.parents.length === 1 && field.parents[0].fieldId === "values";
|
|
52
|
+
if (field.parents.length > 0 && !isValues) {
|
|
37
53
|
return plugins;
|
|
38
54
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} = field.field;
|
|
43
|
-
fieldIdToStorageIdIdMap[fieldId] = fieldId;
|
|
55
|
+
const fieldId = field.field.fieldId;
|
|
56
|
+
const fieldIdPath = isValues ? `values.${fieldId}` : fieldId;
|
|
57
|
+
fieldIdToStorageIdIdMap[fieldIdPath] = fieldIdPath;
|
|
44
58
|
const {
|
|
45
59
|
path
|
|
46
60
|
} = createFieldPath({
|
|
47
|
-
key: storageId,
|
|
61
|
+
key: field.field.storageId,
|
|
48
62
|
field,
|
|
49
|
-
value:
|
|
63
|
+
value: NoValueContainer.create(),
|
|
50
64
|
keyword: false,
|
|
51
|
-
originalValue:
|
|
65
|
+
originalValue: NoValueContainer.create()
|
|
52
66
|
});
|
|
53
67
|
/**
|
|
54
68
|
* Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
|
|
55
69
|
*/
|
|
56
|
-
plugins[
|
|
70
|
+
plugins[fieldIdPath] = new ElasticsearchFieldPlugin({
|
|
57
71
|
unmappedType: field.unmappedType,
|
|
58
|
-
keyword:
|
|
72
|
+
keyword: hasKeyword(field),
|
|
59
73
|
sortable: field.sortable,
|
|
60
74
|
searchable: field.searchable,
|
|
61
75
|
field: fieldId,
|
|
@@ -63,27 +77,31 @@ const createElasticsearchSort = params => {
|
|
|
63
77
|
});
|
|
64
78
|
return plugins;
|
|
65
79
|
}, {
|
|
66
|
-
["*"]: new
|
|
67
|
-
field:
|
|
80
|
+
["*"]: new ElasticsearchFieldPlugin({
|
|
81
|
+
field: ElasticsearchFieldPlugin.ALL,
|
|
68
82
|
keyword: false
|
|
69
83
|
})
|
|
70
84
|
});
|
|
71
85
|
const transformedSort = sort.map(value => {
|
|
72
|
-
const matched = value
|
|
86
|
+
const matched = matchField(value);
|
|
73
87
|
if (!matched) {
|
|
74
88
|
return null;
|
|
75
89
|
}
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
const {
|
|
91
|
+
fieldId,
|
|
92
|
+
order,
|
|
93
|
+
isValues
|
|
94
|
+
} = matched;
|
|
95
|
+
const key = isValues ? `values.${fieldId}` : fieldId;
|
|
96
|
+
if (fieldIdToStorageIdIdMap[key]) {
|
|
97
|
+
return `${fieldIdToStorageIdIdMap[key]}_${order}`;
|
|
79
98
|
}
|
|
80
99
|
return value;
|
|
81
100
|
}).filter(Boolean);
|
|
82
|
-
return
|
|
101
|
+
return createSort({
|
|
83
102
|
fieldPlugins: sortPlugins,
|
|
84
103
|
sort: transformedSort
|
|
85
104
|
});
|
|
86
105
|
};
|
|
87
|
-
exports.createElasticsearchSort = createElasticsearchSort;
|
|
88
106
|
|
|
89
107
|
//# sourceMappingURL=sort.js.map
|