@webiny/api-headless-cms-ddb-es 0.0.0-ee-vpcs.549378cf03
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/LICENSE +21 -0
- package/README.md +35 -0
- package/configurations.d.ts +12 -0
- package/configurations.js +43 -0
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +8 -0
- package/definitions/entry.js +90 -0
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +8 -0
- package/definitions/entryElasticsearch.js +42 -0
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +8 -0
- package/definitions/group.js +70 -0
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +8 -0
- package/definitions/model.js +97 -0
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +8 -0
- package/definitions/settings.js +58 -0
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +8 -0
- package/definitions/system.js +46 -0
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +8 -0
- package/definitions/table.js +24 -0
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +8 -0
- package/definitions/tableElasticsearch.js +24 -0
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -0
- package/dynamoDb/index.js +16 -0
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +3 -0
- package/dynamoDb/storage/date.js +99 -0
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +10 -0
- package/dynamoDb/storage/longText.js +108 -0
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +7 -0
- package/dynamoDb/storage/richText.js +128 -0
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +60 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +43 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +2 -0
- package/elasticsearch/index.js +16 -0
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +3 -0
- package/elasticsearch/indexing/dateTimeIndexing.js +103 -0
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +3 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js +47 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.d.ts +2 -0
- package/elasticsearch/indexing/index.js +24 -0
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +7 -0
- package/elasticsearch/indexing/longTextIndexing.js +52 -0
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.d.ts +3 -0
- package/elasticsearch/indexing/numberIndexing.js +48 -0
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +12 -0
- package/elasticsearch/indexing/objectIndexing.js +223 -0
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.d.ts +3 -0
- package/elasticsearch/indexing/richTextIndexing.js +34 -0
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +15 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +16 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +3 -0
- package/elasticsearch/search/index.js +14 -0
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -0
- package/elasticsearch/search/refSearch.js +35 -0
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -0
- package/elasticsearch/search/timeSearch.js +33 -0
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/entryIndexHelpers.d.ts +18 -0
- package/helpers/entryIndexHelpers.js +204 -0
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +18 -0
- package/helpers/index.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +275 -0
- package/index.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +51 -0
- package/operations/entry/dataLoaders.js +365 -0
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +13 -0
- package/operations/entry/elasticsearch/body.js +162 -0
- package/operations/entry/elasticsearch/body.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +9 -0
- package/operations/entry/elasticsearch/fields.js +248 -0
- package/operations/entry/elasticsearch/fields.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
- package/operations/entry/elasticsearch/filtering/exec.js +215 -0
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
- package/operations/entry/elasticsearch/filtering/path.js +52 -0
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/populated.js +30 -0
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/values.js +28 -0
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
- package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
- package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
- package/operations/entry/elasticsearch/initialQuery.js +117 -0
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
- package/operations/entry/elasticsearch/keyword.d.ts +2 -0
- package/operations/entry/elasticsearch/keyword.js +38 -0
- package/operations/entry/elasticsearch/keyword.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
- package/operations/entry/elasticsearch/plugins/operator.js +45 -0
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
- package/operations/entry/elasticsearch/plugins/search.js +30 -0
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +12 -0
- package/operations/entry/elasticsearch/sort.js +92 -0
- package/operations/entry/elasticsearch/sort.js.map +1 -0
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
- package/operations/entry/elasticsearch/types.d.ts +41 -0
- package/operations/entry/elasticsearch/types.js +5 -0
- package/operations/entry/elasticsearch/types.js.map +1 -0
- package/operations/entry/elasticsearchFields.d.ts +2 -0
- package/operations/entry/elasticsearchFields.js +38 -0
- package/operations/entry/elasticsearchFields.js.map +1 -0
- package/operations/entry/index.d.ts +11 -0
- package/operations/entry/index.js +1251 -0
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.d.ts +12 -0
- package/operations/entry/keys.js +40 -0
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +24 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/group/index.d.ts +8 -0
- package/operations/group/index.js +195 -0
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +8 -0
- package/operations/model/index.js +204 -0
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +6 -0
- package/operations/settings/index.js +135 -0
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +6 -0
- package/operations/system/index.js +99 -0
- package/operations/system/index.js.map +1 -0
- package/package.json +68 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +20 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +12 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +17 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +17 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +31 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +83 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +164 -0
- package/types.js +47 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasKeyword = void 0;
|
|
7
|
+
const noKeywordFields = ["date", "datetime", "number", "boolean"];
|
|
8
|
+
|
|
9
|
+
const hasKeyword = field => {
|
|
10
|
+
/**
|
|
11
|
+
* We defined some field types that MUST have no keyword added to the field path
|
|
12
|
+
*/
|
|
13
|
+
if (noKeywordFields.includes(field.type)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* If field has unmapped type defined, do not add keyword.
|
|
18
|
+
*/
|
|
19
|
+
//
|
|
20
|
+
else if (field.unmappedType) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* And if specifically defined that field has no keyword, do not add it.
|
|
25
|
+
*/
|
|
26
|
+
//
|
|
27
|
+
else if (field.keyword === false) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* All other fields have keyword added.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.hasKeyword = hasKeyword;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["noKeywordFields","hasKeyword","field","includes","type","unmappedType","keyword"],"sources":["keyword.ts"],"sourcesContent":["import { ModelField } from \"./types\";\n\nconst noKeywordFields: string[] = [\"date\", \"datetime\", \"number\", \"boolean\"];\nexport const hasKeyword = (field: ModelField): boolean => {\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(field.type)) {\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":";;;;;;AAEA,MAAMA,eAAyB,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,QAArB,EAA+B,SAA/B,CAAlC;;AACO,MAAMC,UAAU,GAAIC,KAAD,IAAgC;EACtD;AACJ;AACA;EACI,IAAIF,eAAe,CAACG,QAAhB,CAAyBD,KAAK,CAACE,IAA/B,CAAJ,EAA0C;IACtC,OAAO,KAAP;EACH;EACD;AACJ;AACA;EACI;EANA,KAOK,IAAIF,KAAK,CAACG,YAAV,EAAwB;IACzB,OAAO,KAAP;EACH;EACD;AACJ;AACA;EACI;EANK,KAOA,IAAIH,KAAK,CAACI,OAAN,KAAkB,KAAtB,EAA6B;IAC9B,OAAO,KAAP;EACH;EACD;AACJ;AACA;;;EACI,OAAO,IAAP;AACH,CAzBM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins";
|
|
2
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
+
interface Params {
|
|
5
|
+
plugins: PluginsContainer;
|
|
6
|
+
model: CmsModel;
|
|
7
|
+
}
|
|
8
|
+
export declare const createBodyModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchBodyModifierPlugin[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBodyModifierPluginList = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugins = require("../../../../plugins");
|
|
9
|
+
|
|
10
|
+
const createBodyModifierPluginList = ({
|
|
11
|
+
plugins,
|
|
12
|
+
model
|
|
13
|
+
}) => {
|
|
14
|
+
return plugins.byType(_plugins.CmsEntryElasticsearchBodyModifierPlugin.type).filter(pl => {
|
|
15
|
+
return !pl.modelId || pl.modelId === model.modelId;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.createBodyModifierPluginList = createBodyModifierPluginList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createBodyModifierPluginList","plugins","model","byType","CmsEntryElasticsearchBodyModifierPlugin","type","filter","pl","modelId"],"sources":["bodyModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\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;;AAQO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,OAAF;EAAWC;AAAX,CAAD,KAAgC;EACxE,OAAOD,OAAO,CACTE,MADE,CAECC,gDAAA,CAAwCC,IAFzC,EAIFC,MAJE,CAIKC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAeN,KAAK,CAACM,OAA3C;EACH,CANE,CAAP;AAOH,CARM"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
+
import { ElasticsearchQueryBuilderOperatorPlugins } from "../types";
|
|
3
|
+
interface Params {
|
|
4
|
+
plugins: PluginsContainer;
|
|
5
|
+
locale: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const createOperatorPluginList: (params: Params) => ElasticsearchQueryBuilderOperatorPlugins;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createOperatorPluginList = void 0;
|
|
7
|
+
|
|
8
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
9
|
+
|
|
10
|
+
const createOperatorPluginList = params => {
|
|
11
|
+
const {
|
|
12
|
+
plugins,
|
|
13
|
+
locale
|
|
14
|
+
} = params;
|
|
15
|
+
/**
|
|
16
|
+
* We always set the last one operator plugin added.
|
|
17
|
+
* This way user can override the plugins.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
return plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
|
|
21
|
+
const operator = plugin.getOperator();
|
|
22
|
+
/**
|
|
23
|
+
* We only allow the plugins which can pass the locale test.
|
|
24
|
+
* The default plugins always return true.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
if (plugin.isLocaleSupported(locale) === false) {
|
|
28
|
+
return acc;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* We also only allow the override of the plugins if the new plugin is NOT a default one.
|
|
32
|
+
* If a user sets the plugin name ending with .default, we cannot do anything about it.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if (!!acc[operator] && (plugin.name || "").match(/\.default$/)) {
|
|
37
|
+
return acc;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
acc[operator] = plugin;
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.createOperatorPluginList = createOperatorPluginList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createOperatorPluginList","params","plugins","locale","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","operator","getOperator","isLocaleSupported","name","match"],"sources":["operator.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchQueryBuilderOperatorPlugins } from \"../types\";\n\ninterface Params {\n plugins: PluginsContainer;\n locale: string;\n}\nexport const createOperatorPluginList = (\n params: Params\n): ElasticsearchQueryBuilderOperatorPlugins => {\n const { plugins, locale } = 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 only allow the plugins which can pass the locale test.\n * The default plugins always return true.\n */\n if (plugin.isLocaleSupported(locale) === false) {\n return acc;\n }\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;;AAOO,MAAMA,wBAAwB,GACjCC,MADoC,IAEO;EAC3C,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAsBF,MAA5B;EACA;AACJ;AACA;AACA;;EACI,OAAOC,OAAO,CACTE,MADE,CAECC,yDAAA,CAAwCC,IAFzC,EAIFC,MAJE,CAI+C,CAACC,GAAD,EAAMC,MAAN,KAAiB;IAC/D,MAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAP,EAAjB;IACA;AACZ;AACA;AACA;;IACY,IAAIF,MAAM,CAACG,iBAAP,CAAyBT,MAAzB,MAAqC,KAAzC,EAAgD;MAC5C,OAAOK,GAAP;IACH;IACD;AACZ;AACA;AACA;;;IACY,IAAI,CAAC,CAACA,GAAG,CAACE,QAAD,CAAL,IAAmB,CAACD,MAAM,CAACI,IAAP,IAAe,EAAhB,EAAoBC,KAApB,CAA0B,YAA1B,CAAvB,EAAgE;MAC5D,OAAON,GAAP;IACH;;IACDA,GAAG,CAACE,QAAD,CAAH,GAAgBD,MAAhB;IACA,OAAOD,GAAP;EACH,CAtBE,EAsBA,EAtBA,CAAP;AAuBH,CA/BM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CmsEntryElasticsearchQueryModifierPlugin } from "../../../../plugins";
|
|
2
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
+
interface Params {
|
|
5
|
+
plugins: PluginsContainer;
|
|
6
|
+
model: CmsModel;
|
|
7
|
+
}
|
|
8
|
+
export declare const createQueryModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchQueryModifierPlugin[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createQueryModifierPluginList = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugins = require("../../../../plugins");
|
|
9
|
+
|
|
10
|
+
const createQueryModifierPluginList = ({
|
|
11
|
+
plugins,
|
|
12
|
+
model
|
|
13
|
+
}) => {
|
|
14
|
+
return plugins.byType(_plugins.CmsEntryElasticsearchQueryModifierPlugin.type).filter(pl => {
|
|
15
|
+
return !pl.modelId || pl.modelId === model.modelId;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.createQueryModifierPluginList = createQueryModifierPluginList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createQueryModifierPluginList","plugins","model","byType","CmsEntryElasticsearchQueryModifierPlugin","type","filter","pl","modelId"],"sources":["queryModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\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;;AAQO,MAAMA,6BAA6B,GAAG,CAAC;EAAEC,OAAF;EAAWC;AAAX,CAAD,KAAgC;EACzE,OAAOD,OAAO,CACTE,MADE,CAECC,iDAAA,CAAyCC,IAF1C,EAIFC,MAJE,CAIKC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAeN,KAAK,CAACM,OAA3C;EACH,CANE,CAAP;AAOH,CARM"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
+
import { ElasticsearchQuerySearchValuePlugins } from "../types";
|
|
3
|
+
interface Params {
|
|
4
|
+
plugins: PluginsContainer;
|
|
5
|
+
}
|
|
6
|
+
export declare const createSearchPluginList: ({ plugins }: Params) => ElasticsearchQuerySearchValuePlugins;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createSearchPluginList = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
var _plugins = require("../../../../plugins");
|
|
13
|
+
|
|
14
|
+
const createSearchPluginList = ({
|
|
15
|
+
plugins
|
|
16
|
+
}) => {
|
|
17
|
+
return plugins.byType(_plugins.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type).reduce((plugins, plugin) => {
|
|
18
|
+
if (plugins[plugin.fieldType]) {
|
|
19
|
+
throw new _error.default("There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.", "PLUGIN_ALREADY_EXISTS", {
|
|
20
|
+
fieldType: plugin.fieldType,
|
|
21
|
+
name: plugin.name || "unknown"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
plugins[plugin.fieldType] = plugin;
|
|
26
|
+
return plugins;
|
|
27
|
+
}, {});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.createSearchPluginList = createSearchPluginList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSearchPluginList","plugins","byType","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","type","reduce","plugin","fieldType","WebinyError","name"],"sources":["search.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQuerySearchValuePlugins } from \"../types\";\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;;AACA;;AAOO,MAAMA,sBAAsB,GAAG,CAAC;EACnCC;AADmC,CAAD,KAEc;EAChD,OAAOA,OAAO,CACTC,MADE,CAECC,2DAAA,CAAmDC,IAFpD,EAIFC,MAJE,CAI2C,CAACJ,OAAD,EAAUK,MAAV,KAAqB;IAC/D,IAAIL,OAAO,CAACK,MAAM,CAACC,SAAR,CAAX,EAA+B;MAC3B,MAAM,IAAIC,cAAJ,CACF,mFADE,EAEF,uBAFE,EAGF;QACID,SAAS,EAAED,MAAM,CAACC,SADtB;QAEIE,IAAI,EAAEH,MAAM,CAACG,IAAP,IAAe;MAFzB,CAHE,CAAN;IAQH;;IACDR,OAAO,CAACK,MAAM,CAACC,SAAR,CAAP,GAA4BD,MAA5B;IAEA,OAAOL,OAAP;EACH,CAlBE,EAkBA,EAlBA,CAAP;AAmBH,CAtBM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CmsEntryElasticsearchSortModifierPlugin } from "../../../../plugins";
|
|
2
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
+
interface Params {
|
|
5
|
+
plugins: PluginsContainer;
|
|
6
|
+
model: CmsModel;
|
|
7
|
+
}
|
|
8
|
+
export declare const createSortModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchSortModifierPlugin[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createSortModifierPluginList = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugins = require("../../../../plugins");
|
|
9
|
+
|
|
10
|
+
const createSortModifierPluginList = ({
|
|
11
|
+
plugins,
|
|
12
|
+
model
|
|
13
|
+
}) => {
|
|
14
|
+
return plugins.byType(_plugins.CmsEntryElasticsearchSortModifierPlugin.type).filter(pl => {
|
|
15
|
+
return !pl.modelId || pl.modelId === model.modelId;
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.createSortModifierPluginList = createSortModifierPluginList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSortModifierPluginList","plugins","model","byType","CmsEntryElasticsearchSortModifierPlugin","type","filter","pl","modelId"],"sources":["sortModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\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;;AAQO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,OAAF;EAAWC;AAAX,CAAD,KAAgC;EACxE,OAAOD,OAAO,CACTE,MADE,CAECC,gDAAA,CAAwCC,IAFzC,EAIFC,MAJE,CAIKC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAeN,KAAK,CAACM,OAA3C;EACH,CANE,CAAP;AAOH,CARM"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Sort as esSort } from "@webiny/api-elasticsearch/types";
|
|
2
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
+
import { ModelFields } from "./types";
|
|
5
|
+
interface Params {
|
|
6
|
+
plugins: PluginsContainer;
|
|
7
|
+
sort?: CmsEntryListSort;
|
|
8
|
+
modelFields: ModelFields;
|
|
9
|
+
model: CmsModel;
|
|
10
|
+
}
|
|
11
|
+
export declare const createElasticsearchSort: (params: Params) => esSort;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createElasticsearchSort = void 0;
|
|
7
|
+
|
|
8
|
+
var _plugins = require("../../../plugins");
|
|
9
|
+
|
|
10
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
11
|
+
|
|
12
|
+
var _keyword = require("./keyword");
|
|
13
|
+
|
|
14
|
+
var _search = require("./plugins/search");
|
|
15
|
+
|
|
16
|
+
var _path = require("./filtering/path");
|
|
17
|
+
|
|
18
|
+
const createElasticsearchSort = params => {
|
|
19
|
+
const {
|
|
20
|
+
sort,
|
|
21
|
+
modelFields,
|
|
22
|
+
plugins
|
|
23
|
+
} = params;
|
|
24
|
+
|
|
25
|
+
if (!sort || sort.length === 0) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const searchPlugins = (0, _search.createSearchPluginList)({
|
|
30
|
+
plugins
|
|
31
|
+
});
|
|
32
|
+
const createFieldPath = (0, _path.createFieldPathFactory)({
|
|
33
|
+
plugins: searchPlugins
|
|
34
|
+
});
|
|
35
|
+
const fieldIdToStorageIdIdMap = {};
|
|
36
|
+
const sortPlugins = Object.values(modelFields).reduce((plugins, field) => {
|
|
37
|
+
/**
|
|
38
|
+
* We do not support sorting by nested fields.
|
|
39
|
+
*/
|
|
40
|
+
if (field.parents.length > 0) {
|
|
41
|
+
return plugins;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
fieldId,
|
|
46
|
+
storageId
|
|
47
|
+
} = field.field;
|
|
48
|
+
fieldIdToStorageIdIdMap[fieldId] = fieldId;
|
|
49
|
+
const {
|
|
50
|
+
path
|
|
51
|
+
} = createFieldPath({
|
|
52
|
+
key: storageId,
|
|
53
|
+
field,
|
|
54
|
+
value: "",
|
|
55
|
+
keyword: false
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
plugins[fieldId] = new _plugins.CmsEntryElasticsearchFieldPlugin({
|
|
62
|
+
unmappedType: field.unmappedType,
|
|
63
|
+
keyword: (0, _keyword.hasKeyword)(field),
|
|
64
|
+
sortable: field.isSortable,
|
|
65
|
+
searchable: field.isSearchable,
|
|
66
|
+
field: fieldId,
|
|
67
|
+
path
|
|
68
|
+
});
|
|
69
|
+
return plugins;
|
|
70
|
+
}, {});
|
|
71
|
+
const transformedSort = sort.map(value => {
|
|
72
|
+
const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);
|
|
73
|
+
|
|
74
|
+
if (!matched) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const [, fieldId, order] = matched;
|
|
79
|
+
|
|
80
|
+
if (fieldIdToStorageIdIdMap[fieldId]) {
|
|
81
|
+
return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return value;
|
|
85
|
+
}).filter(Boolean);
|
|
86
|
+
return (0, _apiElasticsearch.createSort)({
|
|
87
|
+
fieldPlugins: sortPlugins,
|
|
88
|
+
sort: transformedSort
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.createElasticsearchSort = createElasticsearchSort;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElasticsearchSort","params","sort","modelFields","plugins","length","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","keyword","CmsEntryElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","isSortable","searchable","isSearchable","transformedSort","map","matched","match","order","filter","Boolean","createSort","fieldPlugins"],"sources":["sort.ts"],"sourcesContent":["import { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryElasticsearchFieldPlugin } from \"~/plugins\";\nimport { createSort } from \"@webiny/api-elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<\n Record<string, CmsEntryElasticsearchFieldPlugin>\n >((plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value: \"\",\n keyword: false\n });\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new CmsEntryElasticsearchFieldPlugin({\n unmappedType: field.unmappedType,\n keyword: hasKeyword(field),\n sortable: field.isSortable,\n searchable: field.isSearchable,\n field: fieldId,\n path\n });\n return plugins;\n }, {});\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n"],"mappings":";;;;;;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAQO,MAAMA,uBAAuB,GAAIC,MAAD,IAA4B;EAC/D,MAAM;IAAEC,IAAF;IAAQC,WAAR;IAAqBC;EAArB,IAAiCH,MAAvC;;EAEA,IAAI,CAACC,IAAD,IAASA,IAAI,CAACG,MAAL,KAAgB,CAA7B,EAAgC;IAC5B,OAAO,EAAP;EACH;;EAED,MAAMC,aAAa,GAAG,IAAAC,8BAAA,EAAuB;IACzCH;EADyC,CAAvB,CAAtB;EAIA,MAAMI,eAAe,GAAG,IAAAC,4BAAA,EAAuB;IAC3CL,OAAO,EAAEE;EADkC,CAAvB,CAAxB;EAIA,MAAMI,uBAA+C,GAAG,EAAxD;EAEA,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAP,CAAcV,WAAd,EAA2BW,MAA3B,CAElB,CAACV,OAAD,EAAUW,KAAV,KAAoB;IAClB;AACR;AACA;IACQ,IAAIA,KAAK,CAACC,OAAN,CAAcX,MAAd,GAAuB,CAA3B,EAA8B;MAC1B,OAAOD,OAAP;IACH;;IACD,MAAM;MAAEa,OAAF;MAAWC;IAAX,IAAyBH,KAAK,CAACA,KAArC;IAEAL,uBAAuB,CAACO,OAAD,CAAvB,GAAmCA,OAAnC;IAEA,MAAM;MAAEE;IAAF,IAAWX,eAAe,CAAC;MAC7BY,GAAG,EAAEF,SADwB;MAE7BH,KAF6B;MAG7BM,KAAK,EAAE,EAHsB;MAI7BC,OAAO,EAAE;IAJoB,CAAD,CAAhC;IAMA;AACR;AACA;;IACQlB,OAAO,CAACa,OAAD,CAAP,GAAmB,IAAIM,yCAAJ,CAAqC;MACpDC,YAAY,EAAET,KAAK,CAACS,YADgC;MAEpDF,OAAO,EAAE,IAAAG,mBAAA,EAAWV,KAAX,CAF2C;MAGpDW,QAAQ,EAAEX,KAAK,CAACY,UAHoC;MAIpDC,UAAU,EAAEb,KAAK,CAACc,YAJkC;MAKpDd,KAAK,EAAEE,OAL6C;MAMpDE;IANoD,CAArC,CAAnB;IAQA,OAAOf,OAAP;EACH,CA/BmB,EA+BjB,EA/BiB,CAApB;EAiCA,MAAM0B,eAAe,GAAG5B,IAAI,CACvB6B,GADmB,CACfV,KAAK,IAAI;IACV,MAAMW,OAAO,GAAGX,KAAK,CAACY,KAAN,CAAY,+BAAZ,CAAhB;;IACA,IAAI,CAACD,OAAL,EAAc;MACV,OAAO,IAAP;IACH;;IACD,MAAM,GAAGf,OAAH,EAAYiB,KAAZ,IAAqBF,OAA3B;;IACA,IAAItB,uBAAuB,CAACO,OAAD,CAA3B,EAAsC;MAClC,OAAQ,GAAEP,uBAAuB,CAACO,OAAD,CAAU,IAAGiB,KAAM,EAApD;IACH;;IAED,OAAOb,KAAP;EACH,CAZmB,EAanBc,MAbmB,CAaZC,OAbY,CAAxB;EAcA,OAAO,IAAAC,4BAAA,EAAW;IACdC,YAAY,EAAE3B,WADA;IAEdT,IAAI,EAAE4B;EAFQ,CAAX,CAAP;AAIH,CApEM"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use any for input and output because they really can be anything.
|
|
3
|
+
* Plugin, if exists, makes sure that response value is correct.
|
|
4
|
+
*/
|
|
5
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
6
|
+
import { ElasticsearchQuerySearchValuePlugins } from "./types";
|
|
7
|
+
interface Params {
|
|
8
|
+
plugins: ElasticsearchQuerySearchValuePlugins;
|
|
9
|
+
field: CmsModelField;
|
|
10
|
+
value: any;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Transformed value can be anything.
|
|
14
|
+
*/
|
|
15
|
+
export declare const transformValueForSearch: (params: Params) => any;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformValueForSearch = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* We use any for input and output because they really can be anything.
|
|
10
|
+
* Plugin, if exists, makes sure that response value is correct.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Transformed value can be anything.
|
|
15
|
+
*/
|
|
16
|
+
const transformValueForSearch = params => {
|
|
17
|
+
const {
|
|
18
|
+
field,
|
|
19
|
+
plugins,
|
|
20
|
+
value
|
|
21
|
+
} = params;
|
|
22
|
+
const plugin = plugins[field.type];
|
|
23
|
+
|
|
24
|
+
if (!plugin) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return plugin.transform({
|
|
29
|
+
field,
|
|
30
|
+
value
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.transformValueForSearch = transformValueForSearch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["transformValueForSearch","params","field","plugins","value","plugin","type","transform"],"sources":["transformValueForSearch.ts"],"sourcesContent":["/**\n * We use any for input and output because they really can be anything.\n * Plugin, if exists, makes sure that response value is correct.\n */\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { ElasticsearchQuerySearchValuePlugins } from \"./types\";\n\ninterface Params {\n plugins: ElasticsearchQuerySearchValuePlugins;\n field: CmsModelField;\n value: any;\n}\n\n/**\n * Transformed value can be anything.\n */\nexport const transformValueForSearch = (params: Params): any => {\n const { field, plugins, value } = params;\n const plugin = plugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.transform({ field, value });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAIC,MAAD,IAAyB;EAC5D,MAAM;IAAEC,KAAF;IAASC,OAAT;IAAkBC;EAAlB,IAA4BH,MAAlC;EACA,MAAMI,MAAM,GAAGF,OAAO,CAACD,KAAK,CAACI,IAAP,CAAtB;;EACA,IAAI,CAACD,MAAL,EAAa;IACT,OAAOD,KAAP;EACH;;EACD,OAAOC,MAAM,CAACE,SAAP,CAAiB;IAAEL,KAAF;IAASE;EAAT,CAAjB,CAAP;AACH,CAPM"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../../plugins";
|
|
2
|
+
import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
|
|
3
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
4
|
+
/**
|
|
5
|
+
* ./fields
|
|
6
|
+
*/
|
|
7
|
+
declare type ModelFieldPath = string | ((value: string) => string);
|
|
8
|
+
export declare type FieldType = "text" | "date" | "datetime" | "time" | "number" | "boolean" | string;
|
|
9
|
+
export interface ModelFieldParent {
|
|
10
|
+
fieldId: string;
|
|
11
|
+
storageId: string;
|
|
12
|
+
type: FieldType;
|
|
13
|
+
}
|
|
14
|
+
export interface ModelField {
|
|
15
|
+
unmappedType?: string;
|
|
16
|
+
keyword?: boolean;
|
|
17
|
+
isSearchable: boolean;
|
|
18
|
+
isSortable: boolean;
|
|
19
|
+
type: FieldType;
|
|
20
|
+
isSystemField?: boolean;
|
|
21
|
+
field: CmsModelField;
|
|
22
|
+
path?: ModelFieldPath;
|
|
23
|
+
fullTextSearch?: boolean;
|
|
24
|
+
parents: ModelFieldParent[];
|
|
25
|
+
}
|
|
26
|
+
export interface ModelFields {
|
|
27
|
+
[fieldId: string]: ModelField;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* ./plugins/operator
|
|
31
|
+
*/
|
|
32
|
+
export interface ElasticsearchQueryBuilderOperatorPlugins {
|
|
33
|
+
[key: string]: ElasticsearchQueryBuilderOperatorPlugin;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ./plugins/search
|
|
37
|
+
*/
|
|
38
|
+
export interface ElasticsearchQuerySearchValuePlugins {
|
|
39
|
+
[fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\n/**\n * ./fields\n */\ntype ModelFieldPath = string | ((value: string) => string);\n\nexport type FieldType = \"text\" | \"date\" | \"datetime\" | \"time\" | \"number\" | \"boolean\" | string;\n\nexport interface ModelFieldParent {\n fieldId: string;\n storageId: string;\n type: FieldType;\n}\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n isSearchable: boolean;\n isSortable: boolean;\n type: FieldType;\n isSystemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n fullTextSearch?: boolean;\n parents: ModelFieldParent[];\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\n/**\n * ./plugins/operator\n */\nexport interface ElasticsearchQueryBuilderOperatorPlugins {\n [key: string]: ElasticsearchQueryBuilderOperatorPlugin;\n}\n/**\n * ./plugins/search\n */\nexport interface ElasticsearchQuerySearchValuePlugins {\n [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.elasticsearchFields = void 0;
|
|
7
|
+
|
|
8
|
+
var _CmsEntryElasticsearchFieldPlugin = require("../../plugins/CmsEntryElasticsearchFieldPlugin");
|
|
9
|
+
|
|
10
|
+
const elasticsearchFields = [new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
11
|
+
field: "createdOn",
|
|
12
|
+
unmappedType: "date"
|
|
13
|
+
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
14
|
+
field: "savedOn",
|
|
15
|
+
unmappedType: "date"
|
|
16
|
+
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
17
|
+
field: "publishedOn",
|
|
18
|
+
unmappedType: "date"
|
|
19
|
+
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
20
|
+
field: "ownedBy",
|
|
21
|
+
path: "ownedBy.id"
|
|
22
|
+
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
23
|
+
field: "createdBy",
|
|
24
|
+
path: "createdBy.id"
|
|
25
|
+
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
26
|
+
field: "version",
|
|
27
|
+
path: "version"
|
|
28
|
+
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
29
|
+
field: "status",
|
|
30
|
+
path: "status"
|
|
31
|
+
}),
|
|
32
|
+
/**
|
|
33
|
+
* Always add the ALL fields plugin because of the keyword/path build.
|
|
34
|
+
*/
|
|
35
|
+
new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
36
|
+
field: _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin.ALL
|
|
37
|
+
})];
|
|
38
|
+
exports.elasticsearchFields = elasticsearchFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["elasticsearchFields","CmsEntryElasticsearchFieldPlugin","field","unmappedType","path","ALL"],"sources":["elasticsearchFields.ts"],"sourcesContent":["import { CmsEntryElasticsearchFieldPlugin } from \"~/plugins/CmsEntryElasticsearchFieldPlugin\";\n\nexport const elasticsearchFields = [\n new CmsEntryElasticsearchFieldPlugin({\n field: \"createdOn\",\n unmappedType: \"date\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"savedOn\",\n unmappedType: \"date\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"publishedOn\",\n unmappedType: \"date\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"ownedBy\",\n path: \"ownedBy.id\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"version\",\n path: \"version\"\n }),\n new CmsEntryElasticsearchFieldPlugin({\n field: \"status\",\n path: \"status\"\n }),\n /**\n * Always add the ALL fields plugin because of the keyword/path build.\n */\n new CmsEntryElasticsearchFieldPlugin({\n field: CmsEntryElasticsearchFieldPlugin.ALL\n })\n];\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,mBAAmB,GAAG,CAC/B,IAAIC,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,WAD0B;EAEjCC,YAAY,EAAE;AAFmB,CAArC,CAD+B,EAK/B,IAAIF,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,SAD0B;EAEjCC,YAAY,EAAE;AAFmB,CAArC,CAL+B,EAS/B,IAAIF,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,aAD0B;EAEjCC,YAAY,EAAE;AAFmB,CAArC,CAT+B,EAa/B,IAAIF,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,SAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CAb+B,EAiB/B,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,WAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CAjB+B,EAqB/B,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,SAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CArB+B,EAyB/B,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAE,QAD0B;EAEjCE,IAAI,EAAE;AAF2B,CAArC,CAzB+B;AA6B/B;AACJ;AACA;AACI,IAAIH,kEAAJ,CAAqC;EACjCC,KAAK,EAAED,kEAAA,CAAiCI;AADP,CAArC,CAhC+B,CAA5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CmsEntryStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { Entity } from "dynamodb-toolbox";
|
|
3
|
+
import { Client } from "@elastic/elasticsearch";
|
|
4
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
5
|
+
export interface CreateEntriesStorageOperationsParams {
|
|
6
|
+
entity: Entity<any>;
|
|
7
|
+
esEntity: Entity<any>;
|
|
8
|
+
elasticsearch: Client;
|
|
9
|
+
plugins: PluginsContainer;
|
|
10
|
+
}
|
|
11
|
+
export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;
|