@webiny/api-headless-cms-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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 +15 -8
- package/configurations.js +29 -12
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +6 -5
- package/definitions/entry.js +111 -20
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +6 -5
- package/definitions/entryElasticsearch.js +11 -16
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +6 -5
- package/definitions/group.js +8 -16
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -5
- package/definitions/model.js +30 -16
- package/definitions/model.js.map +1 -0
- package/definitions/system.d.ts +6 -5
- package/definitions/system.js +8 -16
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +6 -6
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +6 -6
- package/definitions/tableElasticsearch.js +7 -6
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -1
- package/dynamoDb/index.js +10 -12
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +75 -62
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -8
- package/dynamoDb/storage/richText.js +49 -100
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +40 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +38 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +3 -6
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +21 -22
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +17 -10
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.js +5 -11
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
- package/elasticsearch/indexing/jsonIndexing.js +28 -0
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +5 -1
- package/elasticsearch/indexing/longTextIndexing.js +16 -10
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +2 -9
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +10 -1
- package/elasticsearch/indexing/objectIndexing.js +37 -36
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +2 -5
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +13 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +14 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +14 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +2 -2
- package/elasticsearch/search/index.js +6 -9
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -3
- package/elasticsearch/search/refSearch.js +24 -17
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/searchableJson.d.ts +2 -0
- package/elasticsearch/search/searchableJson.js +60 -0
- package/elasticsearch/search/searchableJson.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -3
- package/elasticsearch/search/timeSearch.js +18 -16
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/entryIndexHelpers.d.ts +3 -3
- package/helpers/entryIndexHelpers.js +59 -58
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/fieldIdentifier.d.ts +6 -0
- package/helpers/fieldIdentifier.js +43 -0
- package/helpers/fieldIdentifier.js.map +1 -0
- package/helpers/index.d.ts +1 -1
- package/helpers/index.js +11 -13
- package/helpers/index.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +132 -78
- package/index.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +10 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +52 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +52 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +62 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +40 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +7 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +21 -38
- package/operations/entry/dataLoaders.js +59 -290
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +13 -0
- package/operations/entry/elasticsearch/body.js +142 -0
- package/operations/entry/elasticsearch/body.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +10 -0
- package/operations/entry/elasticsearch/fields.js +315 -0
- package/operations/entry/elasticsearch/fields.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +60 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
- package/operations/entry/elasticsearch/filtering/exec.js +175 -0
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/path.d.ts +16 -0
- package/operations/entry/elasticsearch/filtering/path.js +48 -0
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +30 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +15 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +69 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +57 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/populated.js +25 -0
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/values.js +24 -0
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
- package/operations/entry/elasticsearch/fullTextSearch.js +91 -0
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js +27 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
- package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
- package/operations/entry/elasticsearch/initialQuery.js +106 -0
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
- package/operations/entry/elasticsearch/keyword.d.ts +2 -0
- package/operations/entry/elasticsearch/keyword.js +36 -0
- package/operations/entry/elasticsearch/keyword.js.map +1 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +9 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +26 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
- package/operations/entry/elasticsearch/plugins/operator.js +39 -0
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
- package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +9 -9
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +13 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +12 -0
- package/operations/entry/elasticsearch/sort.js +89 -0
- package/operations/entry/elasticsearch/sort.js.map +1 -0
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js +32 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
- package/operations/entry/elasticsearch/types.d.ts +41 -0
- package/operations/entry/elasticsearch/types.js +7 -0
- package/operations/entry/elasticsearch/types.js.map +1 -0
- package/operations/entry/index.d.ts +6 -8
- package/operations/entry/index.js +1422 -693
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +2 -9
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +20 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
- package/operations/entry/transformations/convertEntryKeys.js +38 -0
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
- package/operations/entry/transformations/index.d.ts +29 -0
- package/operations/entry/transformations/index.js +127 -0
- package/operations/entry/transformations/index.js.map +1 -0
- package/operations/entry/transformations/modifyEntryValues.d.ts +58 -0
- package/operations/entry/transformations/modifyEntryValues.js +28 -0
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
- package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
- package/operations/entry/transformations/transformEntryKeys.js +27 -0
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
- package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
- package/operations/entry/transformations/transformEntryToIndex.js +31 -0
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
- package/operations/group/index.d.ts +5 -5
- package/operations/group/index.js +40 -63
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +5 -5
- package/operations/model/index.js +56 -78
- package/operations/model/index.js.map +1 -0
- package/operations/system/index.d.ts +4 -4
- package/operations/system/index.js +20 -31
- package/operations/system/index.js.map +1 -0
- package/operations/system/indexes.d.ts +10 -0
- package/operations/system/indexes.js +41 -0
- package/operations/system/indexes.js.map +1 -0
- package/package.json +38 -40
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js +52 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +9 -4
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +10 -13
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +27 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +13 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +32 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +40 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +6 -4
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +10 -13
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +6 -4
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +10 -13
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js +50 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +22 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +8 -0
- package/plugins/index.js +95 -0
- package/plugins/index.js.map +1 -0
- package/tasks/createIndexTaskPlugin.d.ts +2 -0
- package/tasks/createIndexTaskPlugin.js +67 -0
- package/tasks/createIndexTaskPlugin.js.map +1 -0
- package/types.d.ts +30 -52
- package/types.js +5 -23
- package/types.js.map +1 -0
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +20 -0
- package/values/NoValueContainer.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -375
- package/helpers/fields.d.ts +0 -77
- package/helpers/fields.js +0 -174
- package/helpers/operatorPluginsList.d.ts +0 -7
- package/helpers/operatorPluginsList.js +0 -30
- package/helpers/searchPluginsList.d.ts +0 -6
- package/helpers/transformValueForSearch.d.ts +0 -9
- package/helpers/transformValueForSearch.js +0 -26
- package/operations/entry/elasticsearchFields.d.ts +0 -2
- package/operations/entry/elasticsearchFields.js +0 -32
- package/operations/entry/fields.d.ts +0 -3
- package/operations/entry/fields.js +0 -60
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -141
- package/operations/system/createElasticsearchTemplate.d.ts +0 -5
- package/operations/system/createElasticsearchTemplate.js +0 -62
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -16
- package/upgrades/utils.d.ts +0 -1
- package/upgrades/utils.js +0 -16
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
- package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
- package/upgrades/v5.0.0/entryValueFixer.js +0 -124
- package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
- package/upgrades/v5.0.0/fieldFinder.js +0 -42
- package/upgrades/v5.0.0/helpers.d.ts +0 -4
- package/upgrades/v5.0.0/helpers.js +0 -57
- package/upgrades/v5.0.0/index.d.ts +0 -4
- package/upgrades/v5.0.0/index.js +0 -232
- package/upgrades/v5.8.0/index.d.ts +0 -4
- package/upgrades/v5.8.0/index.js +0 -426
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exec = require("./exec");
|
|
7
|
+
Object.keys(_exec).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _exec[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _exec[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_exec","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./exec\";\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ElasticsearchQuerySearchValuePlugins, ModelField } from "../types";
|
|
2
|
+
interface FieldPathFactoryParams {
|
|
3
|
+
plugins: ElasticsearchQuerySearchValuePlugins;
|
|
4
|
+
}
|
|
5
|
+
interface FieldPathParams {
|
|
6
|
+
field: ModelField;
|
|
7
|
+
key: string;
|
|
8
|
+
value: any;
|
|
9
|
+
originalValue: any;
|
|
10
|
+
keyword: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const createFieldPathFactory: ({ plugins }: FieldPathFactoryParams) => (params: FieldPathParams) => {
|
|
13
|
+
basePath: string;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFieldPathFactory = void 0;
|
|
7
|
+
const createFieldPathFactory = ({
|
|
8
|
+
plugins
|
|
9
|
+
}) => {
|
|
10
|
+
return params => {
|
|
11
|
+
const {
|
|
12
|
+
field,
|
|
13
|
+
key,
|
|
14
|
+
value,
|
|
15
|
+
keyword,
|
|
16
|
+
originalValue
|
|
17
|
+
} = params;
|
|
18
|
+
const plugin = plugins[field.type];
|
|
19
|
+
let fieldPath = null;
|
|
20
|
+
if (plugin) {
|
|
21
|
+
fieldPath = plugin.createPath({
|
|
22
|
+
field: field.field,
|
|
23
|
+
value,
|
|
24
|
+
key,
|
|
25
|
+
originalValue
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (!fieldPath) {
|
|
29
|
+
fieldPath = field.field.storageId;
|
|
30
|
+
if (field.path) {
|
|
31
|
+
fieldPath = typeof field.path === "function" ? field.path(value) : field.path;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const result = [];
|
|
35
|
+
if (!field.systemField) {
|
|
36
|
+
result.push("values");
|
|
37
|
+
}
|
|
38
|
+
result.push(...field.parents.map(p => p.storageId));
|
|
39
|
+
result.push(fieldPath);
|
|
40
|
+
return {
|
|
41
|
+
basePath: result.join("."),
|
|
42
|
+
path: result.concat(keyword ? ["keyword"] : []).join(".")
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.createFieldPathFactory = createFieldPathFactory;
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFieldPathFactory","plugins","params","field","key","value","keyword","originalValue","plugin","type","fieldPath","createPath","storageId","path","result","systemField","push","parents","map","p","basePath","join","concat","exports"],"sources":["path.ts"],"sourcesContent":["import type {\n ElasticsearchQuerySearchValuePlugins,\n ModelField\n} from \"~/operations/entry/elasticsearch/types\";\n\ninterface FieldPathFactoryParams {\n plugins: ElasticsearchQuerySearchValuePlugins;\n}\ninterface FieldPathParams {\n field: ModelField;\n key: string;\n value: any;\n originalValue: any;\n keyword: boolean;\n}\n\nexport const createFieldPathFactory = ({ plugins }: FieldPathFactoryParams) => {\n return (params: FieldPathParams) => {\n const { field, key, value, keyword, originalValue } = params;\n const plugin = plugins[field.type];\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field: field.field, value, key, originalValue });\n }\n if (!fieldPath) {\n fieldPath = field.field.storageId;\n if (field.path) {\n fieldPath = typeof field.path === \"function\" ? field.path(value) : field.path;\n }\n }\n\n const result: string[] = [];\n if (!field.systemField) {\n result.push(\"values\");\n }\n result.push(...field.parents.map(p => p.storageId));\n result.push(fieldPath);\n\n return {\n basePath: result.join(\".\"),\n path: result.concat(keyword ? [\"keyword\"] : []).join(\".\")\n };\n };\n};\n"],"mappings":";;;;;;AAgBO,MAAMA,sBAAsB,GAAGA,CAAC;EAAEC;AAAgC,CAAC,KAAK;EAC3E,OAAQC,MAAuB,IAAK;IAChC,MAAM;MAAEC,KAAK;MAAEC,GAAG;MAAEC,KAAK;MAAEC,OAAO;MAAEC;IAAc,CAAC,GAAGL,MAAM;IAC5D,MAAMM,MAAM,GAAGP,OAAO,CAACE,KAAK,CAACM,IAAI,CAAC;IAElC,IAAIC,SAAwB,GAAG,IAAI;IACnC,IAAIF,MAAM,EAAE;MACRE,SAAS,GAAGF,MAAM,CAACG,UAAU,CAAC;QAAER,KAAK,EAAEA,KAAK,CAACA,KAAK;QAAEE,KAAK;QAAED,GAAG;QAAEG;MAAc,CAAC,CAAC;IACpF;IACA,IAAI,CAACG,SAAS,EAAE;MACZA,SAAS,GAAGP,KAAK,CAACA,KAAK,CAACS,SAAS;MACjC,IAAIT,KAAK,CAACU,IAAI,EAAE;QACZH,SAAS,GAAG,OAAOP,KAAK,CAACU,IAAI,KAAK,UAAU,GAAGV,KAAK,CAACU,IAAI,CAACR,KAAK,CAAC,GAAGF,KAAK,CAACU,IAAI;MACjF;IACJ;IAEA,MAAMC,MAAgB,GAAG,EAAE;IAC3B,IAAI,CAACX,KAAK,CAACY,WAAW,EAAE;MACpBD,MAAM,CAACE,IAAI,CAAC,QAAQ,CAAC;IACzB;IACAF,MAAM,CAACE,IAAI,CAAC,GAAGb,KAAK,CAACc,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACP,SAAS,CAAC,CAAC;IACnDE,MAAM,CAACE,IAAI,CAACN,SAAS,CAAC;IAEtB,OAAO;MACHU,QAAQ,EAAEN,MAAM,CAACO,IAAI,CAAC,GAAG,CAAC;MAC1BR,IAAI,EAAEC,MAAM,CAACQ,MAAM,CAAChB,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAACe,IAAI,CAAC,GAAG;IAC5D,CAAC;EACL,CAAC;AACL,CAAC;AAACE,OAAA,CAAAvB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createDefaultFilterPlugin = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
|
|
10
|
+
const createDefaultFilterPlugin = () => {
|
|
11
|
+
const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
|
|
12
|
+
fieldType: _CmsEntryFilterPlugin.CmsEntryFilterPlugin.ALL,
|
|
13
|
+
exec: params => {
|
|
14
|
+
const {
|
|
15
|
+
applyFiltering,
|
|
16
|
+
field
|
|
17
|
+
} = params;
|
|
18
|
+
if (!params.field.searchable) {
|
|
19
|
+
const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(".");
|
|
20
|
+
throw new _error.default(`Field "${identifier}" is not searchable.`);
|
|
21
|
+
}
|
|
22
|
+
applyFiltering(params);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
plugin.name = `${plugin.type}.default.all`;
|
|
26
|
+
return plugin;
|
|
27
|
+
};
|
|
28
|
+
exports.createDefaultFilterPlugin = createDefaultFilterPlugin;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=defaultFilterPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","createDefaultFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","ALL","exec","params","applyFiltering","field","searchable","identifier","parents","map","p","fieldId","join","WebinyError","name","type","exports"],"sources":["defaultFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport const createDefaultFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: CmsEntryFilterPlugin.ALL,\n exec: params => {\n const { applyFiltering, field } = params;\n if (!params.field.searchable) {\n const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(\n \".\"\n );\n throw new WebinyError(`Field \"${identifier}\" is not searchable.`);\n }\n applyFiltering(params);\n }\n });\n\n plugin.name = `${plugin.type}.default.all`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAED,0CAAoB,CAACE,GAAG;IACnCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC;MAAM,CAAC,GAAGF,MAAM;MACxC,IAAI,CAACA,MAAM,CAACE,KAAK,CAACC,UAAU,EAAE;QAC1B,MAAMC,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACG,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAEN,KAAK,CAACA,KAAK,CAACM,OAAO,CAAC,CAACC,IAAI,CAC/E,GACJ,CAAC;QACD,MAAM,IAAIC,cAAW,CAAC,UAAUN,UAAU,sBAAsB,CAAC;MACrE;MACAH,cAAc,CAACD,MAAM,CAAC;IAC1B;EACJ,CAAC,CAAC;EAEFL,MAAM,CAACgB,IAAI,GAAG,GAAGhB,MAAM,CAACiB,IAAI,cAAc;EAE1C,OAAOjB,MAAM;AACjB,CAAC;AAACkB,OAAA,CAAAnB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createFilterPlugins: () => import("../../../../../plugins/CmsEntryFilterPlugin").CmsEntryFilterPlugin[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFilterPlugins = void 0;
|
|
7
|
+
var _defaultFilterPlugin = require("./defaultFilterPlugin");
|
|
8
|
+
var _objectFilterPlugin = require("./objectFilterPlugin");
|
|
9
|
+
var _refFilterPlugin = require("./refFilterPlugin");
|
|
10
|
+
const createFilterPlugins = () => {
|
|
11
|
+
return [(0, _defaultFilterPlugin.createDefaultFilterPlugin)(), (0, _objectFilterPlugin.createObjectFilterPlugin)(), (0, _refFilterPlugin.createRefFilterPlugin)()];
|
|
12
|
+
};
|
|
13
|
+
exports.createFilterPlugins = createFilterPlugins;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_defaultFilterPlugin","require","_objectFilterPlugin","_refFilterPlugin","createFilterPlugins","createDefaultFilterPlugin","createObjectFilterPlugin","createRefFilterPlugin","exports"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterPlugin } from \"./defaultFilterPlugin\";\nimport { createObjectFilterPlugin } from \"./objectFilterPlugin\";\nimport { createRefFilterPlugin } from \"./refFilterPlugin\";\n\nexport const createFilterPlugins = () => {\n return [createDefaultFilterPlugin(), createObjectFilterPlugin(), createRefFilterPlugin()];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAEO,MAAMG,mBAAmB,GAAGA,CAAA,KAAM;EACrC,OAAO,CAAC,IAAAC,8CAAyB,EAAC,CAAC,EAAE,IAAAC,4CAAwB,EAAC,CAAC,EAAE,IAAAC,sCAAqB,EAAC,CAAC,CAAC;AAC7F,CAAC;AAACC,OAAA,CAAAJ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createObjectFilterPlugin = void 0;
|
|
8
|
+
var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
|
|
9
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
const createObjectFilterPlugin = () => {
|
|
12
|
+
const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
|
|
13
|
+
fieldType: "object",
|
|
14
|
+
exec: params => {
|
|
15
|
+
const {
|
|
16
|
+
applyFiltering,
|
|
17
|
+
value: where,
|
|
18
|
+
fields,
|
|
19
|
+
field: parentField,
|
|
20
|
+
getFilterPlugin,
|
|
21
|
+
query
|
|
22
|
+
} = params;
|
|
23
|
+
/**
|
|
24
|
+
* Because this is an object field, we must construct filters based on the value property.
|
|
25
|
+
* Value property is actually a where condition.
|
|
26
|
+
*/
|
|
27
|
+
for (const key in where) {
|
|
28
|
+
const value = where[key];
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const {
|
|
33
|
+
field: whereFieldId,
|
|
34
|
+
operator
|
|
35
|
+
} = (0, _apiElasticsearch.parseWhereKey)(key);
|
|
36
|
+
const identifier = [...parentField.parents.map(p => p.fieldId), parentField.field.fieldId, whereFieldId].join(".");
|
|
37
|
+
const field = fields[identifier];
|
|
38
|
+
if (!field) {
|
|
39
|
+
throw new _error.default(`There is no field "${identifier}".`, "OBJECT_FILTER_FIELD_ERROR", {
|
|
40
|
+
fields: Object.keys(fields)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* We need to find the filter plugin for the child field.
|
|
45
|
+
* This will throw error if no plugin can be found.
|
|
46
|
+
*/
|
|
47
|
+
const plugin = getFilterPlugin(field.type);
|
|
48
|
+
/**
|
|
49
|
+
* Basically this allows us to go into depth as much as we want with the object fields.
|
|
50
|
+
*/
|
|
51
|
+
plugin.exec({
|
|
52
|
+
applyFiltering,
|
|
53
|
+
getFilterPlugin,
|
|
54
|
+
key,
|
|
55
|
+
value,
|
|
56
|
+
operator,
|
|
57
|
+
field,
|
|
58
|
+
fields,
|
|
59
|
+
query
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
plugin.name = `${plugin.type}.default.object`;
|
|
65
|
+
return plugin;
|
|
66
|
+
};
|
|
67
|
+
exports.createObjectFilterPlugin = createObjectFilterPlugin;
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=objectFilterPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_CmsEntryFilterPlugin","require","_apiElasticsearch","_error","_interopRequireDefault","createObjectFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","parseWhereKey","identifier","parents","map","p","fieldId","join","WebinyError","Object","keys","type","name","exports"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createObjectFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"object\",\n exec: params => {\n const {\n applyFiltering,\n value: where,\n fields,\n field: parentField,\n getFilterPlugin,\n query\n } = params;\n /**\n * Because this is an object field, we must construct filters based on the value property.\n * Value property is actually a where condition.\n */\n for (const key in where) {\n const value = where[key];\n if (value === undefined) {\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n const identifier = [\n ...parentField.parents.map(p => p.fieldId),\n parentField.field.fieldId,\n whereFieldId\n ].join(\".\");\n const field = fields[identifier];\n if (!field) {\n throw new WebinyError(\n `There is no field \"${identifier}\".`,\n \"OBJECT_FILTER_FIELD_ERROR\",\n {\n fields: Object.keys(fields)\n }\n );\n }\n /**\n * We need to find the filter plugin for the child field.\n * This will throw error if no plugin can be found.\n */\n const plugin = getFilterPlugin(field.type);\n /**\n * Basically this allows us to go into depth as much as we want with the object fields.\n */\n plugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.object`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEO,MAAMI,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cAAc;QACdC,KAAK,EAAEC,KAAK;QACZC,MAAM;QACNC,KAAK,EAAEC,WAAW;QAClBC,eAAe;QACfC;MACJ,CAAC,GAAGR,MAAM;MACV;AACZ;AACA;AACA;MACY,KAAK,MAAMS,GAAG,IAAIN,KAAK,EAAE;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAG,CAAC;QACxB,IAAIP,KAAK,KAAKQ,SAAS,EAAE;UACrB;QACJ;QACA,MAAM;UAAEL,KAAK,EAAEM,YAAY;UAAEC;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACJ,GAAG,CAAC;QAE5D,MAAMK,UAAU,GAAG,CACf,GAAGR,WAAW,CAACS,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAC1CZ,WAAW,CAACD,KAAK,CAACa,OAAO,EACzBP,YAAY,CACf,CAACQ,IAAI,CAAC,GAAG,CAAC;QACX,MAAMd,KAAK,GAAGD,MAAM,CAACU,UAAU,CAAC;QAChC,IAAI,CAACT,KAAK,EAAE;UACR,MAAM,IAAIe,cAAW,CACjB,sBAAsBN,UAAU,IAAI,EACpC,2BAA2B,EAC3B;YACIV,MAAM,EAAEiB,MAAM,CAACC,IAAI,CAAClB,MAAM;UAC9B,CACJ,CAAC;QACL;QACA;AAChB;AACA;AACA;QACgB,MAAMR,MAAM,GAAGW,eAAe,CAACF,KAAK,CAACkB,IAAI,CAAC;QAC1C;AAChB;AACA;QACgB3B,MAAM,CAACG,IAAI,CAAC;UACRE,cAAc;UACdM,eAAe;UACfE,GAAG;UACHP,KAAK;UACLU,QAAQ;UACRP,KAAK;UACLD,MAAM;UACNI;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFZ,MAAM,CAAC4B,IAAI,GAAG,GAAG5B,MAAM,CAAC2B,IAAI,iBAAiB;EAE7C,OAAO3B,MAAM;AACjB,CAAC;AAAC6B,OAAA,CAAA9B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createRefFilterPlugin = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
|
|
10
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
11
|
+
const createRefFilterPlugin = () => {
|
|
12
|
+
const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
|
|
13
|
+
fieldType: "ref",
|
|
14
|
+
exec: params => {
|
|
15
|
+
const {
|
|
16
|
+
applyFiltering,
|
|
17
|
+
query,
|
|
18
|
+
field
|
|
19
|
+
} = params;
|
|
20
|
+
let values = params.value;
|
|
21
|
+
/**
|
|
22
|
+
* We must have an object when querying in the ref field.
|
|
23
|
+
*/
|
|
24
|
+
if (typeof values !== "object") {
|
|
25
|
+
throw new _error.default(`When querying by ref field, value of the field must be an object.`, "OBJECT_REQUIRED", {
|
|
26
|
+
value: values
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (values === null || values === undefined) {
|
|
30
|
+
values = {
|
|
31
|
+
entryId: null
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
for (const key in values) {
|
|
35
|
+
const {
|
|
36
|
+
operator
|
|
37
|
+
} = (0, _apiElasticsearch.parseWhereKey)(key);
|
|
38
|
+
const value = values[key];
|
|
39
|
+
if (value === undefined) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
applyFiltering({
|
|
43
|
+
query,
|
|
44
|
+
field,
|
|
45
|
+
operator,
|
|
46
|
+
key,
|
|
47
|
+
value
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
plugin.name = `${plugin.type}.default.ref`;
|
|
53
|
+
return plugin;
|
|
54
|
+
};
|
|
55
|
+
exports.createRefFilterPlugin = createRefFilterPlugin;
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=refFilterPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","_apiElasticsearch","createRefFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","query","field","values","value","WebinyError","undefined","entryId","key","operator","parseWhereKey","name","type","exports"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\n\nexport const createRefFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"ref\",\n exec: params => {\n const { applyFiltering, query, field } = params;\n\n let values = params.value;\n /**\n * We must have an object when querying in the ref field.\n */\n if (typeof values !== \"object\") {\n throw new WebinyError(\n `When querying by ref field, value of the field must be an object.`,\n \"OBJECT_REQUIRED\",\n {\n value: values\n }\n );\n }\n\n if (values === null || values === undefined) {\n values = {\n entryId: null\n };\n }\n\n for (const key in values) {\n const { operator } = parseWhereKey(key);\n const value = values[key];\n if (value === undefined) {\n continue;\n }\n\n applyFiltering({\n query,\n field,\n operator,\n key,\n value\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.ref`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC;MAAM,CAAC,GAAGH,MAAM;MAE/C,IAAII,MAAM,GAAGJ,MAAM,CAACK,KAAK;MACzB;AACZ;AACA;MACY,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIE,cAAW,CACjB,mEAAmE,EACnE,iBAAiB,EACjB;UACID,KAAK,EAAED;QACX,CACJ,CAAC;MACL;MAEA,IAAIA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKG,SAAS,EAAE;QACzCH,MAAM,GAAG;UACLI,OAAO,EAAE;QACb,CAAC;MACL;MAEA,KAAK,MAAMC,GAAG,IAAIL,MAAM,EAAE;QACtB,MAAM;UAAEM;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACF,GAAG,CAAC;QACvC,MAAMJ,KAAK,GAAGD,MAAM,CAACK,GAAG,CAAC;QACzB,IAAIJ,KAAK,KAAKE,SAAS,EAAE;UACrB;QACJ;QAEAN,cAAc,CAAC;UACXC,KAAK;UACLC,KAAK;UACLO,QAAQ;UACRD,GAAG;UACHJ;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFT,MAAM,CAACgB,IAAI,GAAG,GAAGhB,MAAM,CAACiB,IAAI,cAAc;EAE1C,OAAOjB,MAAM;AACjB,CAAC;AAACkB,OAAA,CAAAnB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPopulated = void 0;
|
|
7
|
+
const getPopulated = query => {
|
|
8
|
+
const result = {};
|
|
9
|
+
let key;
|
|
10
|
+
for (key in query) {
|
|
11
|
+
const value = query[key];
|
|
12
|
+
if (value === undefined || Array.isArray(value) && value.length === 0) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* TODO figure out better types.
|
|
17
|
+
*/
|
|
18
|
+
// @ts-expect-error
|
|
19
|
+
result[key] = value;
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
exports.getPopulated = getPopulated;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=populated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getPopulated","query","result","key","value","undefined","Array","isArray","length","exports"],"sources":["populated.ts"],"sourcesContent":["import type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\n\nexport const getPopulated = (\n query: ElasticsearchBoolQueryConfig\n): Partial<ElasticsearchBoolQueryConfig> => {\n const result: Partial<ElasticsearchBoolQueryConfig> = {};\n let key: keyof ElasticsearchBoolQueryConfig;\n for (key in query) {\n const value = query[key];\n if (value === undefined || (Array.isArray(value) && value.length === 0)) {\n continue;\n }\n /**\n * TODO figure out better types.\n */\n // @ts-expect-error\n result[key] = value;\n }\n return result;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GACrBC,KAAmC,IACK;EACxC,MAAMC,MAA6C,GAAG,CAAC,CAAC;EACxD,IAAIC,GAAuC;EAC3C,KAAKA,GAAG,IAAIF,KAAK,EAAE;IACf,MAAMG,KAAK,GAAGH,KAAK,CAACE,GAAG,CAAC;IACxB,IAAIC,KAAK,KAAKC,SAAS,IAAKC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAIA,KAAK,CAACI,MAAM,KAAK,CAAE,EAAE;MACrE;IACJ;IACA;AACR;AACA;IACQ;IACAN,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK;EACvB;EACA,OAAOF,MAAM;AACjB,CAAC;AAACO,OAAA,CAAAT,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getWhereValues = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
const getWhereValues = (value, condition) => {
|
|
10
|
+
const values = value;
|
|
11
|
+
if (!Array.isArray(values)) {
|
|
12
|
+
throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
|
|
13
|
+
value
|
|
14
|
+
});
|
|
15
|
+
} else if (values.length === 0) {
|
|
16
|
+
throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
|
|
17
|
+
value
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return values;
|
|
21
|
+
};
|
|
22
|
+
exports.getWhereValues = getWhereValues;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","getWhereValues","value","condition","values","Array","isArray","WebinyError","length","exports"],"sources":["values.ts"],"sourcesContent":["import type { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getWhereValues = (value: unknown, condition: \"AND\" | \"OR\") => {\n const values = value as CmsEntryListWhere[] | undefined;\n if (!Array.isArray(values)) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is not an array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n } else if (values.length === 0) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is empty array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n }\n return values;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,cAAc,GAAGA,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIG,cAAW,CACjB,iCAAiCJ,SAAS,wCAAwC,EAClF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CACjB,iCAAiCJ,SAAS,uCAAuC,EACjF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAACK,OAAA,CAAAR,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
|
|
2
|
+
import type { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
interface Params {
|
|
5
|
+
plugins: PluginsContainer;
|
|
6
|
+
model: CmsModel;
|
|
7
|
+
query: ElasticsearchBoolQueryConfig;
|
|
8
|
+
term?: string;
|
|
9
|
+
fields: CmsModelField[];
|
|
10
|
+
}
|
|
11
|
+
export declare const applyFullTextSearch: (params: Params) => void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyFullTextSearch = void 0;
|
|
7
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
8
|
+
var _plugins = require("../../../plugins");
|
|
9
|
+
/**
|
|
10
|
+
* Our default plugin is working with the AND operator for the multiple words query string.
|
|
11
|
+
*/
|
|
12
|
+
const defaultPlugin = (0, _plugins.createCmsEntryElasticsearchFullTextSearchPlugin)({
|
|
13
|
+
apply: params => {
|
|
14
|
+
const {
|
|
15
|
+
query,
|
|
16
|
+
term,
|
|
17
|
+
fields,
|
|
18
|
+
createFieldPath,
|
|
19
|
+
prepareTerm
|
|
20
|
+
} = params;
|
|
21
|
+
query.must.push({
|
|
22
|
+
query_string: {
|
|
23
|
+
allow_leading_wildcard: true,
|
|
24
|
+
fields: fields.map(createFieldPath),
|
|
25
|
+
query: `*${prepareTerm(term)}*`,
|
|
26
|
+
default_operator: "and"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
defaultPlugin.name = "headless-cms.elasticsearch.entry.fullTextSearch.default";
|
|
32
|
+
const getPlugin = params => {
|
|
33
|
+
const {
|
|
34
|
+
container,
|
|
35
|
+
model
|
|
36
|
+
} = params;
|
|
37
|
+
/**
|
|
38
|
+
* We need to reverse the plugins, so we can take the last one first - possibility to override existing plugins.
|
|
39
|
+
*/
|
|
40
|
+
const plugins = container.byType(_plugins.CmsEntryElasticsearchFullTextSearchPlugin.type).reverse();
|
|
41
|
+
/**
|
|
42
|
+
* We need to find the most specific plugin for the given model.
|
|
43
|
+
* Also, we need to use the first possible plugin if the specific one is not found.
|
|
44
|
+
*/
|
|
45
|
+
let plugin = null;
|
|
46
|
+
for (const pl of plugins) {
|
|
47
|
+
const models = pl.models || [];
|
|
48
|
+
/**
|
|
49
|
+
* We take the first available plugin for the given model.
|
|
50
|
+
*/
|
|
51
|
+
if (models.includes(model.modelId)) {
|
|
52
|
+
return pl;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Then we set the first possible plugin, which has no models defined, as the default one.
|
|
56
|
+
* It is important not to set the plugin which has models defined as they are specifically for the targeted model.
|
|
57
|
+
*/
|
|
58
|
+
//
|
|
59
|
+
else if (!plugin && models.length === 0) {
|
|
60
|
+
plugin = pl;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return plugin || defaultPlugin;
|
|
64
|
+
};
|
|
65
|
+
const applyFullTextSearch = params => {
|
|
66
|
+
const {
|
|
67
|
+
plugins,
|
|
68
|
+
query,
|
|
69
|
+
term,
|
|
70
|
+
fields,
|
|
71
|
+
model
|
|
72
|
+
} = params;
|
|
73
|
+
if (!term || term.length === 0 || fields.length === 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const plugin = getPlugin({
|
|
77
|
+
container: plugins,
|
|
78
|
+
model
|
|
79
|
+
});
|
|
80
|
+
plugin.apply({
|
|
81
|
+
model,
|
|
82
|
+
createFieldPath: field => `values.${field.storageId}`,
|
|
83
|
+
fields,
|
|
84
|
+
query,
|
|
85
|
+
term,
|
|
86
|
+
prepareTerm: _apiElasticsearch.normalizeValue
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
exports.applyFullTextSearch = applyFullTextSearch;
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=fullTextSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_apiElasticsearch","require","_plugins","defaultPlugin","createCmsEntryElasticsearchFullTextSearchPlugin","apply","params","query","term","fields","createFieldPath","prepareTerm","must","push","query_string","allow_leading_wildcard","map","default_operator","name","getPlugin","container","model","plugins","byType","CmsEntryElasticsearchFullTextSearchPlugin","type","reverse","plugin","pl","models","includes","modelId","length","applyFullTextSearch","field","storageId","normalizeValue","exports"],"sources":["fullTextSearch.ts"],"sourcesContent":["import type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { normalizeValue } from \"@webiny/api-elasticsearch\";\nimport type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntryElasticsearchFullTextSearchPlugin,\n createCmsEntryElasticsearchFullTextSearchPlugin\n} from \"~/plugins\";\n\n/**\n * Our default plugin is working with the AND operator for the multiple words query string.\n */\nconst defaultPlugin = createCmsEntryElasticsearchFullTextSearchPlugin({\n apply: params => {\n const { query, term, fields, createFieldPath, prepareTerm } = params;\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fields.map(createFieldPath),\n query: `*${prepareTerm(term)}*`,\n default_operator: \"and\"\n }\n });\n }\n});\ndefaultPlugin.name = \"headless-cms.elasticsearch.entry.fullTextSearch.default\";\n\ninterface GetPluginParams {\n container: PluginsContainer;\n model: CmsModel;\n}\nconst getPlugin = (params: GetPluginParams): CmsEntryElasticsearchFullTextSearchPlugin => {\n const { container, model } = params;\n /**\n * We need to reverse the plugins, so we can take the last one first - possibility to override existing plugins.\n */\n const plugins = container\n .byType<CmsEntryElasticsearchFullTextSearchPlugin>(\n CmsEntryElasticsearchFullTextSearchPlugin.type\n )\n .reverse();\n /**\n * We need to find the most specific plugin for the given model.\n * Also, we need to use the first possible plugin if the specific one is not found.\n */\n let plugin: CmsEntryElasticsearchFullTextSearchPlugin | null = null;\n for (const pl of plugins) {\n const models = pl.models || [];\n /**\n * We take the first available plugin for the given model.\n */\n if (models.includes(model.modelId)) {\n return pl;\n }\n /**\n * Then we set the first possible plugin, which has no models defined, as the default one.\n * It is important not to set the plugin which has models defined as they are specifically for the targeted model.\n */\n //\n else if (!plugin && models.length === 0) {\n plugin = pl;\n }\n }\n\n return plugin || defaultPlugin;\n};\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n query: ElasticsearchBoolQueryConfig;\n term?: string;\n fields: CmsModelField[];\n}\nexport const applyFullTextSearch = (params: Params): void => {\n const { plugins, query, term, fields, model } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const plugin = getPlugin({\n container: plugins,\n model\n });\n\n plugin.apply({\n model,\n createFieldPath: field => `values.${field.storageId}`,\n fields,\n query,\n term,\n prepareTerm: normalizeValue\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AAKA;AACA;AACA;AACA,MAAME,aAAa,GAAG,IAAAC,wDAA+C,EAAC;EAClEC,KAAK,EAAEC,MAAM,IAAI;IACb,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC,MAAM;MAAEC,eAAe;MAAEC;IAAY,CAAC,GAAGL,MAAM;IAEpEC,KAAK,CAACK,IAAI,CAACC,IAAI,CAAC;MACZC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IAAI;QAC5BN,MAAM,EAAEA,MAAM,CAACO,GAAG,CAACN,eAAe,CAAC;QACnCH,KAAK,EAAE,IAAII,WAAW,CAACH,IAAI,CAAC,GAAG;QAC/BS,gBAAgB,EAAE;MACtB;IACJ,CAAC,CAAC;EACN;AACJ,CAAC,CAAC;AACFd,aAAa,CAACe,IAAI,GAAG,yDAAyD;AAM9E,MAAMC,SAAS,GAAIb,MAAuB,IAAgD;EACtF,MAAM;IAAEc,SAAS;IAAEC;EAAM,CAAC,GAAGf,MAAM;EACnC;AACJ;AACA;EACI,MAAMgB,OAAO,GAAGF,SAAS,CACpBG,MAAM,CACHC,kDAAyC,CAACC,IAC9C,CAAC,CACAC,OAAO,CAAC,CAAC;EACd;AACJ;AACA;AACA;EACI,IAAIC,MAAwD,GAAG,IAAI;EACnE,KAAK,MAAMC,EAAE,IAAIN,OAAO,EAAE;IACtB,MAAMO,MAAM,GAAGD,EAAE,CAACC,MAAM,IAAI,EAAE;IAC9B;AACR;AACA;IACQ,IAAIA,MAAM,CAACC,QAAQ,CAACT,KAAK,CAACU,OAAO,CAAC,EAAE;MAChC,OAAOH,EAAE;IACb;IACA;AACR;AACA;AACA;IACQ;IAAA,KACK,IAAI,CAACD,MAAM,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;MACrCL,MAAM,GAAGC,EAAE;IACf;EACJ;EAEA,OAAOD,MAAM,IAAIxB,aAAa;AAClC,CAAC;AASM,MAAM8B,mBAAmB,GAAI3B,MAAc,IAAW;EACzD,MAAM;IAAEgB,OAAO;IAAEf,KAAK;IAAEC,IAAI;IAAEC,MAAM;IAAEY;EAAM,CAAC,GAAGf,MAAM;EACtD,IAAI,CAACE,IAAI,IAAIA,IAAI,CAACwB,MAAM,KAAK,CAAC,IAAIvB,MAAM,CAACuB,MAAM,KAAK,CAAC,EAAE;IACnD;EACJ;EAEA,MAAML,MAAM,GAAGR,SAAS,CAAC;IACrBC,SAAS,EAAEE,OAAO;IAClBD;EACJ,CAAC,CAAC;EAEFM,MAAM,CAACtB,KAAK,CAAC;IACTgB,KAAK;IACLX,eAAe,EAAEwB,KAAK,IAAI,UAAUA,KAAK,CAACC,SAAS,EAAE;IACrD1B,MAAM;IACNF,KAAK;IACLC,IAAI;IACJG,WAAW,EAAEyB;EACjB,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAJ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFullTextSearchFields = void 0;
|
|
7
|
+
const createFullTextSearchFields = params => {
|
|
8
|
+
const {
|
|
9
|
+
term,
|
|
10
|
+
model,
|
|
11
|
+
fields
|
|
12
|
+
} = params;
|
|
13
|
+
if (!fields || fields.length === 0 || !term || term.trim().length === 0) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
return fields.reduce((collection, fieldId) => {
|
|
17
|
+
const field = model.fields.find(f => f.fieldId === fieldId);
|
|
18
|
+
if (!field) {
|
|
19
|
+
return collection;
|
|
20
|
+
}
|
|
21
|
+
collection.push(field);
|
|
22
|
+
return collection;
|
|
23
|
+
}, []);
|
|
24
|
+
};
|
|
25
|
+
exports.createFullTextSearchFields = createFullTextSearchFields;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=fullTextSearchFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFullTextSearchFields","params","term","model","fields","length","trim","reduce","collection","fieldId","field","find","f","push","exports"],"sources":["fullTextSearchFields.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\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":";;;;;;AAOO,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;AAACM,OAAA,CAAAd,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
|
|
2
|
+
import type { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export declare const createBaseQuery: () => ElasticsearchBoolQueryConfig;
|
|
4
|
+
interface Params {
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
where: CmsEntryListWhere;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.
|
|
10
|
+
* We allow either published or either latest.
|
|
11
|
+
* Latest is used in the manage API and published in the read API.
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* We add the query.filter terms because we do not need scored search here and it is a bit faster.
|
|
15
|
+
*/
|
|
16
|
+
export declare const createInitialQuery: (params: Params) => ElasticsearchBoolQueryConfig;
|
|
17
|
+
export {};
|