@webiny/api-elasticsearch 5.34.8 → 5.35.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +4 -16
- package/client.js.map +1 -1
- package/compression.js +0 -17
- package/compression.js.map +1 -1
- package/cursors.js +0 -12
- package/cursors.js.map +1 -1
- package/index.js +0 -32
- package/index.js.map +1 -1
- package/indexConfiguration/base.js +0 -5
- package/indexConfiguration/base.js.map +1 -1
- package/indexConfiguration/common.js +0 -4
- package/indexConfiguration/common.js.map +1 -1
- package/indexConfiguration/index.js +0 -6
- package/indexConfiguration/index.js.map +1 -1
- package/indexConfiguration/japanese.js +0 -5
- package/indexConfiguration/japanese.js.map +1 -1
- package/indices.js +0 -7
- package/indices.js.map +1 -1
- package/limit.js +0 -8
- package/limit.js.map +1 -1
- package/normalize.js +3 -7
- package/normalize.js.map +1 -1
- package/operators.js +0 -11
- package/operators.js.map +1 -1
- package/package.json +9 -9
- package/plugins/GzipCompression.js +0 -18
- package/plugins/GzipCompression.js.map +1 -1
- package/plugins/definition/CompressionPlugin.js +0 -5
- package/plugins/definition/CompressionPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js +0 -9
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/definition/ElasticsearchFieldPlugin.js +0 -23
- package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchIndexPlugin.js +0 -10
- package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +0 -6
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js +0 -9
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchSortModifierPlugin.js +0 -9
- package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/definition/index.js +0 -14
- package/plugins/definition/index.js.map +1 -1
- package/plugins/index.js +0 -4
- package/plugins/index.js.map +1 -1
- package/plugins/operator/andIn.js +2 -13
- package/plugins/operator/andIn.js.map +1 -1
- package/plugins/operator/between.js +2 -12
- package/plugins/operator/between.js.map +1 -1
- package/plugins/operator/contains.js +0 -9
- package/plugins/operator/contains.js.map +1 -1
- package/plugins/operator/equal.js +0 -14
- package/plugins/operator/equal.js.map +1 -1
- package/plugins/operator/gt.js +0 -8
- package/plugins/operator/gt.js.map +1 -1
- package/plugins/operator/gte.js +0 -8
- package/plugins/operator/gte.js.map +1 -1
- package/plugins/operator/in.js +2 -11
- package/plugins/operator/in.js.map +1 -1
- package/plugins/operator/index.js +0 -32
- package/plugins/operator/index.js.map +1 -1
- package/plugins/operator/japanese/contains.js +0 -11
- package/plugins/operator/japanese/contains.js.map +1 -1
- package/plugins/operator/lt.js +0 -8
- package/plugins/operator/lt.js.map +1 -1
- package/plugins/operator/lte.js +0 -8
- package/plugins/operator/lte.js.map +1 -1
- package/plugins/operator/not.js +0 -12
- package/plugins/operator/not.js.map +1 -1
- package/plugins/operator/notBetween.js +2 -12
- package/plugins/operator/notBetween.js.map +1 -1
- package/plugins/operator/notContains.js +0 -9
- package/plugins/operator/notContains.js.map +1 -1
- package/plugins/operator/notIn.js +0 -10
- package/plugins/operator/notIn.js.map +1 -1
- package/plugins/operator/notStartsWith.js +0 -8
- package/plugins/operator/notStartsWith.js.map +1 -1
- package/plugins/operator/startsWith.js +0 -8
- package/plugins/operator/startsWith.js.map +1 -1
- package/sort.js +0 -16
- package/sort.js.map +1 -1
- package/types.d.ts +1 -0
- package/types.js +0 -3
- package/types.js.map +1 -1
- package/where.js +2 -23
- package/where.js.map +1 -1
package/limit.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createLimit = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* This is the max limit of the Elasticsearch.
|
|
10
9
|
* Change here if it changes (and if it is necessary).
|
|
@@ -13,9 +12,7 @@ const ES_LIMIT_MAX = 10000;
|
|
|
13
12
|
/**
|
|
14
13
|
* Our system default limit.
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
15
|
const ES_LIMIT_DEFAULT = 50;
|
|
18
|
-
|
|
19
16
|
const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
|
|
20
17
|
/**
|
|
21
18
|
* Limit can possibly be null/undefined or less than 1.
|
|
@@ -28,8 +25,6 @@ const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
|
|
|
28
25
|
* Users input limit cannot be greater than the Elasticsearch one.
|
|
29
26
|
* Elasticsearch query breaks because of that.
|
|
30
27
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
28
|
if (limit < ES_LIMIT_MAX) {
|
|
34
29
|
return limit;
|
|
35
30
|
}
|
|
@@ -37,9 +32,6 @@ const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
|
|
|
37
32
|
* Always reduce by 1 because we check if there are more items by adding 1 to the limit
|
|
38
33
|
* and then remove that last one loaded.
|
|
39
34
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
35
|
return ES_LIMIT_MAX - 1;
|
|
43
36
|
};
|
|
44
|
-
|
|
45
37
|
exports.createLimit = createLimit;
|
package/limit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"sources":["limit.ts"],"sourcesContent":["/**\n * This is the max limit of the Elasticsearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the Elasticsearch one.\n * Elasticsearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"sources":["limit.ts"],"sourcesContent":["/**\n * This is the max limit of the Elasticsearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the Elasticsearch one.\n * Elasticsearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,KAAK;AAC1B;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,EAAE;AAEpB,MAAMC,WAAW,GAAG,CAACC,KAAc,EAAEC,YAAY,GAAGH,gBAAgB,KAAa;EACpF;AACJ;AACA;AACA;EACI,IAAI,CAACE,KAAK,IAAIA,KAAK,GAAG,CAAC,EAAE;IACrB,OAAOC,YAAY;EACvB;EACA;AACJ;AACA;AACA;EACI,IAAID,KAAK,GAAGH,YAAY,EAAE;IACtB,OAAOG,KAAK;EAChB;EACA;AACJ;AACA;AACA;EACI,OAAOH,YAAY,GAAG,CAAC;AAC3B,CAAC;AAAC"}
|
package/normalize.js
CHANGED
|
@@ -4,27 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.normalizeValue = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Before performing the query, we need to escape all special characters.
|
|
10
9
|
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
|
|
11
10
|
*/
|
|
11
|
+
|
|
12
12
|
const specialCharacterToSpace = ["-"];
|
|
13
|
-
const specialCharacters = ["\\\\", "\\+",
|
|
13
|
+
const specialCharacters = ["\\\\", "\\+",
|
|
14
|
+
// "\\-",
|
|
14
15
|
"\\=", "\\&\\&", "\\|\\|", ">", "<", "\\!", "\\(", "\\)", "\\{", "\\}", "\\[", "\\]", "\\^", '\\"', "\\~", "\\*", "\\?", "\\:", "\\/", "\\#"];
|
|
15
|
-
|
|
16
16
|
const normalizeValue = value => {
|
|
17
17
|
let result = value || "";
|
|
18
|
-
|
|
19
18
|
for (const character of specialCharacterToSpace) {
|
|
20
19
|
result = result.replace(new RegExp(character, "g"), " ");
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
for (const character of specialCharacters) {
|
|
24
22
|
result = result.replace(new RegExp(character, "g"), `\\${character}`);
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
return result || "";
|
|
28
25
|
};
|
|
29
|
-
|
|
30
26
|
exports.normalizeValue = normalizeValue;
|
package/normalize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp"],"sources":["normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters\n */\n\nconst specialCharacterToSpace = [\"-\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n \"\\\\&\\\\&\",\n \"\\\\|\\\\|\",\n \">\",\n \"<\",\n \"\\\\!\",\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n \"\\\\?\",\n \"\\\\:\",\n \"\\\\/\",\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp"],"sources":["normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters\n */\n\nconst specialCharacterToSpace = [\"-\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n \"\\\\&\\\\&\",\n \"\\\\|\\\\|\",\n \">\",\n \"<\",\n \"\\\\!\",\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n \"\\\\?\",\n \"\\\\:\",\n \"\\\\/\",\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAEA,MAAMA,uBAAuB,GAAG,CAAC,GAAG,CAAC;AAErC,MAAMC,iBAAiB,GAAG,CACtB,MAAM,EACN,KAAK;AACL;AACA,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,GAAG,EACH,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,CACR;AAEM,MAAMC,cAAc,GAAIC,KAAa,IAAK;EAC7C,IAAIC,MAAM,GAAGD,KAAK,IAAI,EAAE;EACxB,KAAK,MAAME,SAAS,IAAIL,uBAAuB,EAAE;IAC7CI,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC;EAC5D;EAEA,KAAK,MAAMA,SAAS,IAAIJ,iBAAiB,EAAE;IACvCG,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAG,KAAIA,SAAU,EAAC,CAAC;EACzE;EAEA,OAAOD,MAAM,IAAI,EAAE;AACvB,CAAC;AAAC"}
|
package/operators.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getElasticsearchOperators = exports.getElasticsearchOperatorPluginsByLocale = void 0;
|
|
7
|
-
|
|
8
7
|
var _operator = require("./plugins/operator");
|
|
9
|
-
|
|
10
8
|
var _ElasticsearchQueryBuilderOperatorPlugin = require("./plugins/definition/ElasticsearchQueryBuilderOperatorPlugin");
|
|
11
|
-
|
|
12
9
|
const operators = [new _operator.ElasticsearchQueryBuilderOperatorBetweenPlugin(), new _operator.ElasticsearchQueryBuilderOperatorNotBetweenPlugin(), new _operator.ElasticsearchQueryBuilderOperatorContainsPlugin(), new _operator.ElasticsearchQueryBuilderOperatorNotContainsPlugin(), new _operator.ElasticsearchQueryBuilderOperatorEqualPlugin(), new _operator.ElasticsearchQueryBuilderOperatorNotPlugin(), new _operator.ElasticsearchQueryBuilderOperatorGreaterThanPlugin(), new _operator.ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(), new _operator.ElasticsearchQueryBuilderOperatorLesserThanPlugin(), new _operator.ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin(), new _operator.ElasticsearchQueryBuilderOperatorInPlugin(), new _operator.ElasticsearchQueryBuilderOperatorAndInPlugin(), new _operator.ElasticsearchQueryBuilderOperatorNotInPlugin(), new _operator.ElasticsearchQueryBuilderOperatorStartsWithPlugin(), new _operator.ElasticsearchQueryBuilderOperatorNotStartsWithPlugin(),
|
|
13
10
|
/**
|
|
14
11
|
* Japanese
|
|
@@ -18,11 +15,8 @@ new _operator.ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin()];
|
|
|
18
15
|
* We export as a function because there might be something to be sent to the operators at some point.
|
|
19
16
|
* This way, we make it easier to upgrade.
|
|
20
17
|
*/
|
|
21
|
-
|
|
22
18
|
const getElasticsearchOperators = () => operators;
|
|
23
|
-
|
|
24
19
|
exports.getElasticsearchOperators = getElasticsearchOperators;
|
|
25
|
-
|
|
26
20
|
const getElasticsearchOperatorPluginsByLocale = (plugins, locale) => {
|
|
27
21
|
/**
|
|
28
22
|
* We always set the last one operator plugin added.
|
|
@@ -34,7 +28,6 @@ const getElasticsearchOperatorPluginsByLocale = (plugins, locale) => {
|
|
|
34
28
|
* We only allow the plugins which can pass the locale test.
|
|
35
29
|
* The default plugins always return true.
|
|
36
30
|
*/
|
|
37
|
-
|
|
38
31
|
if (plugin.isLocaleSupported(locale) === false) {
|
|
39
32
|
return acc;
|
|
40
33
|
}
|
|
@@ -42,15 +35,11 @@ const getElasticsearchOperatorPluginsByLocale = (plugins, locale) => {
|
|
|
42
35
|
* We also only allow the override of the plugins if the new plugin is NOT a default one.
|
|
43
36
|
* If a user names the plugin with .default, we cannot do anything about it.
|
|
44
37
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
38
|
if (!!acc[op] && (plugin.name || "").match(/\.default$/)) {
|
|
48
39
|
return acc;
|
|
49
40
|
}
|
|
50
|
-
|
|
51
41
|
acc[op] = plugin;
|
|
52
42
|
return acc;
|
|
53
43
|
}, {});
|
|
54
44
|
};
|
|
55
|
-
|
|
56
45
|
exports.getElasticsearchOperatorPluginsByLocale = getElasticsearchOperatorPluginsByLocale;
|
package/operators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["operators","ElasticsearchQueryBuilderOperatorBetweenPlugin","ElasticsearchQueryBuilderOperatorNotBetweenPlugin","ElasticsearchQueryBuilderOperatorContainsPlugin","ElasticsearchQueryBuilderOperatorNotContainsPlugin","ElasticsearchQueryBuilderOperatorEqualPlugin","ElasticsearchQueryBuilderOperatorNotPlugin","ElasticsearchQueryBuilderOperatorGreaterThanPlugin","ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin","ElasticsearchQueryBuilderOperatorLesserThanPlugin","ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin","ElasticsearchQueryBuilderOperatorInPlugin","ElasticsearchQueryBuilderOperatorAndInPlugin","ElasticsearchQueryBuilderOperatorNotInPlugin","ElasticsearchQueryBuilderOperatorStartsWithPlugin","ElasticsearchQueryBuilderOperatorNotStartsWithPlugin","ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin","getElasticsearchOperators","getElasticsearchOperatorPluginsByLocale","plugins","locale","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","op","getOperator","isLocaleSupported","name","match"],"sources":["operators.ts"],"sourcesContent":["import {\n ElasticsearchQueryBuilderOperatorBetweenPlugin,\n ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin,\n ElasticsearchQueryBuilderOperatorAndInPlugin,\n ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin,\n ElasticsearchQueryBuilderOperatorGreaterThanPlugin,\n ElasticsearchQueryBuilderOperatorContainsPlugin,\n ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin,\n ElasticsearchQueryBuilderOperatorInPlugin,\n ElasticsearchQueryBuilderOperatorLesserThanPlugin,\n ElasticsearchQueryBuilderOperatorNotBetweenPlugin,\n ElasticsearchQueryBuilderOperatorNotContainsPlugin,\n ElasticsearchQueryBuilderOperatorNotPlugin,\n ElasticsearchQueryBuilderOperatorNotInPlugin,\n ElasticsearchQueryBuilderOperatorEqualPlugin,\n ElasticsearchQueryBuilderOperatorStartsWithPlugin,\n ElasticsearchQueryBuilderOperatorNotStartsWithPlugin\n} from \"~/plugins/operator\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\n\nconst operators = [\n new ElasticsearchQueryBuilderOperatorBetweenPlugin(),\n new ElasticsearchQueryBuilderOperatorNotBetweenPlugin(),\n new ElasticsearchQueryBuilderOperatorContainsPlugin(),\n new ElasticsearchQueryBuilderOperatorNotContainsPlugin(),\n new ElasticsearchQueryBuilderOperatorEqualPlugin(),\n new ElasticsearchQueryBuilderOperatorNotPlugin(),\n new ElasticsearchQueryBuilderOperatorGreaterThanPlugin(),\n new ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(),\n new ElasticsearchQueryBuilderOperatorLesserThanPlugin(),\n new ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin(),\n new ElasticsearchQueryBuilderOperatorInPlugin(),\n new ElasticsearchQueryBuilderOperatorAndInPlugin(),\n new ElasticsearchQueryBuilderOperatorNotInPlugin(),\n new ElasticsearchQueryBuilderOperatorStartsWithPlugin(),\n new ElasticsearchQueryBuilderOperatorNotStartsWithPlugin(),\n /**\n * Japanese\n */\n new ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin()\n];\n/**\n * We export as a function because there might be something to be sent to the operators at some point.\n * This way, we make it easier to upgrade.\n */\nexport const getElasticsearchOperators = () => operators;\n\nexport const getElasticsearchOperatorPluginsByLocale = (\n plugins: PluginsContainer,\n locale: string\n): Record<string, ElasticsearchQueryBuilderOperatorPlugin> => {\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((acc, plugin) => {\n const op = 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 names the plugin with .default, we cannot do anything about it.\n */\n if (!!acc[op] && (plugin.name || \"\").match(/\\.default$/)) {\n return acc;\n }\n acc[op] = plugin;\n return acc;\n }, {} as Record<string, ElasticsearchQueryBuilderOperatorPlugin>);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["operators","ElasticsearchQueryBuilderOperatorBetweenPlugin","ElasticsearchQueryBuilderOperatorNotBetweenPlugin","ElasticsearchQueryBuilderOperatorContainsPlugin","ElasticsearchQueryBuilderOperatorNotContainsPlugin","ElasticsearchQueryBuilderOperatorEqualPlugin","ElasticsearchQueryBuilderOperatorNotPlugin","ElasticsearchQueryBuilderOperatorGreaterThanPlugin","ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin","ElasticsearchQueryBuilderOperatorLesserThanPlugin","ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin","ElasticsearchQueryBuilderOperatorInPlugin","ElasticsearchQueryBuilderOperatorAndInPlugin","ElasticsearchQueryBuilderOperatorNotInPlugin","ElasticsearchQueryBuilderOperatorStartsWithPlugin","ElasticsearchQueryBuilderOperatorNotStartsWithPlugin","ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin","getElasticsearchOperators","getElasticsearchOperatorPluginsByLocale","plugins","locale","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","op","getOperator","isLocaleSupported","name","match"],"sources":["operators.ts"],"sourcesContent":["import {\n ElasticsearchQueryBuilderOperatorBetweenPlugin,\n ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin,\n ElasticsearchQueryBuilderOperatorAndInPlugin,\n ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin,\n ElasticsearchQueryBuilderOperatorGreaterThanPlugin,\n ElasticsearchQueryBuilderOperatorContainsPlugin,\n ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin,\n ElasticsearchQueryBuilderOperatorInPlugin,\n ElasticsearchQueryBuilderOperatorLesserThanPlugin,\n ElasticsearchQueryBuilderOperatorNotBetweenPlugin,\n ElasticsearchQueryBuilderOperatorNotContainsPlugin,\n ElasticsearchQueryBuilderOperatorNotPlugin,\n ElasticsearchQueryBuilderOperatorNotInPlugin,\n ElasticsearchQueryBuilderOperatorEqualPlugin,\n ElasticsearchQueryBuilderOperatorStartsWithPlugin,\n ElasticsearchQueryBuilderOperatorNotStartsWithPlugin\n} from \"~/plugins/operator\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin\";\n\nconst operators = [\n new ElasticsearchQueryBuilderOperatorBetweenPlugin(),\n new ElasticsearchQueryBuilderOperatorNotBetweenPlugin(),\n new ElasticsearchQueryBuilderOperatorContainsPlugin(),\n new ElasticsearchQueryBuilderOperatorNotContainsPlugin(),\n new ElasticsearchQueryBuilderOperatorEqualPlugin(),\n new ElasticsearchQueryBuilderOperatorNotPlugin(),\n new ElasticsearchQueryBuilderOperatorGreaterThanPlugin(),\n new ElasticsearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(),\n new ElasticsearchQueryBuilderOperatorLesserThanPlugin(),\n new ElasticsearchQueryBuilderOperatorLesserThanOrEqualToPlugin(),\n new ElasticsearchQueryBuilderOperatorInPlugin(),\n new ElasticsearchQueryBuilderOperatorAndInPlugin(),\n new ElasticsearchQueryBuilderOperatorNotInPlugin(),\n new ElasticsearchQueryBuilderOperatorStartsWithPlugin(),\n new ElasticsearchQueryBuilderOperatorNotStartsWithPlugin(),\n /**\n * Japanese\n */\n new ElasticsearchQueryBuilderJapaneseOperatorContainsPlugin()\n];\n/**\n * We export as a function because there might be something to be sent to the operators at some point.\n * This way, we make it easier to upgrade.\n */\nexport const getElasticsearchOperators = () => operators;\n\nexport const getElasticsearchOperatorPluginsByLocale = (\n plugins: PluginsContainer,\n locale: string\n): Record<string, ElasticsearchQueryBuilderOperatorPlugin> => {\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((acc, plugin) => {\n const op = 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 names the plugin with .default, we cannot do anything about it.\n */\n if (!!acc[op] && (plugin.name || \"\").match(/\\.default$/)) {\n return acc;\n }\n acc[op] = plugin;\n return acc;\n }, {} as Record<string, ElasticsearchQueryBuilderOperatorPlugin>);\n};\n"],"mappings":";;;;;;AAAA;AAmBA;AAEA,MAAMA,SAAS,GAAG,CACd,IAAIC,wDAA8C,EAAE,EACpD,IAAIC,2DAAiD,EAAE,EACvD,IAAIC,yDAA+C,EAAE,EACrD,IAAIC,4DAAkD,EAAE,EACxD,IAAIC,sDAA4C,EAAE,EAClD,IAAIC,oDAA0C,EAAE,EAChD,IAAIC,4DAAkD,EAAE,EACxD,IAAIC,qEAA2D,EAAE,EACjE,IAAIC,2DAAiD,EAAE,EACvD,IAAIC,oEAA0D,EAAE,EAChE,IAAIC,mDAAyC,EAAE,EAC/C,IAAIC,sDAA4C,EAAE,EAClD,IAAIC,sDAA4C,EAAE,EAClD,IAAIC,2DAAiD,EAAE,EACvD,IAAIC,8DAAoD,EAAE;AAC1D;AACJ;AACA;AACI,IAAIC,iEAAuD,EAAE,CAChE;AACD;AACA;AACA;AACA;AACO,MAAMC,yBAAyB,GAAG,MAAMjB,SAAS;AAAC;AAElD,MAAMkB,uCAAuC,GAAG,CACnDC,OAAyB,EACzBC,MAAc,KAC4C;EAC1D;AACJ;AACA;AACA;EACI,OAAOD,OAAO,CACTE,MAAM,CACHC,gFAAuC,CAACC,IAAI,CAC/C,CACAC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;IACrB,MAAMC,EAAE,GAAGD,MAAM,CAACE,WAAW,EAAE;IAC/B;AACZ;AACA;AACA;IACY,IAAIF,MAAM,CAACG,iBAAiB,CAACT,MAAM,CAAC,KAAK,KAAK,EAAE;MAC5C,OAAOK,GAAG;IACd;IACA;AACZ;AACA;AACA;IACY,IAAI,CAAC,CAACA,GAAG,CAACE,EAAE,CAAC,IAAI,CAACD,MAAM,CAACI,IAAI,IAAI,EAAE,EAAEC,KAAK,CAAC,YAAY,CAAC,EAAE;MACtD,OAAON,GAAG;IACd;IACAA,GAAG,CAACE,EAAE,CAAC,GAAGD,MAAM;IAChB,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAA4D;AACzE,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-elasticsearch",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.35.0-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/webiny/webiny-js.git",
|
|
@@ -13,19 +13,19 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@elastic/elasticsearch": "7.12.0",
|
|
16
|
-
"@webiny/api": "5.
|
|
17
|
-
"@webiny/error": "5.
|
|
18
|
-
"@webiny/plugins": "5.
|
|
19
|
-
"@webiny/utils": "5.
|
|
16
|
+
"@webiny/api": "5.35.0-beta.0",
|
|
17
|
+
"@webiny/error": "5.35.0-beta.0",
|
|
18
|
+
"@webiny/plugins": "5.35.0-beta.0",
|
|
19
|
+
"@webiny/utils": "5.35.0-beta.0",
|
|
20
20
|
"aws-elasticsearch-connector": "9.2.0",
|
|
21
|
-
"aws-sdk": "2.
|
|
21
|
+
"aws-sdk": "2.1310.0",
|
|
22
22
|
"elastic-ts": "0.8.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@babel/cli": "^7.19.3",
|
|
26
26
|
"@babel/core": "^7.19.3",
|
|
27
|
-
"@webiny/cli": "^5.
|
|
28
|
-
"@webiny/project-utils": "^5.
|
|
27
|
+
"@webiny/cli": "^5.35.0-beta.0",
|
|
28
|
+
"@webiny/project-utils": "^5.35.0-beta.0",
|
|
29
29
|
"rimraf": "^3.0.2",
|
|
30
30
|
"ttypescript": "^1.5.12",
|
|
31
31
|
"typescript": "4.7.4"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
]
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8acc9e8892842cabb3980ce0b6432fde55968d5b"
|
|
49
49
|
}
|
|
@@ -4,23 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.createGzipCompression = void 0;
|
|
7
|
-
|
|
8
7
|
var _CompressionPlugin = require("./definition/CompressionPlugin");
|
|
9
|
-
|
|
10
8
|
var _gzip = require("@webiny/utils/compression/gzip");
|
|
11
|
-
|
|
12
9
|
const GZIP = "gzip";
|
|
13
10
|
const TO_STORAGE_ENCODING = "base64";
|
|
14
11
|
const FROM_STORAGE_ENCODING = "utf8";
|
|
15
|
-
|
|
16
12
|
const convertToBuffer = value => {
|
|
17
13
|
if (typeof value === "string") {
|
|
18
14
|
return Buffer.from(value, TO_STORAGE_ENCODING);
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
return value;
|
|
22
17
|
};
|
|
23
|
-
|
|
24
18
|
class GzipCompression extends _CompressionPlugin.CompressionPlugin {
|
|
25
19
|
canCompress(data) {
|
|
26
20
|
/**
|
|
@@ -30,13 +24,10 @@ class GzipCompression extends _CompressionPlugin.CompressionPlugin {
|
|
|
30
24
|
if (data.compression !== "GZIP") {
|
|
31
25
|
console.log(`Data is already compressed with "${data.compression}".`);
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
return false;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
return true;
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
async compress(data) {
|
|
41
32
|
const value = await (0, _gzip.compress)(JSON.stringify(data));
|
|
42
33
|
return {
|
|
@@ -44,7 +35,6 @@ class GzipCompression extends _CompressionPlugin.CompressionPlugin {
|
|
|
44
35
|
value: value.toString(TO_STORAGE_ENCODING)
|
|
45
36
|
};
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
canDecompress(data) {
|
|
49
39
|
if (!data || !data.compression) {
|
|
50
40
|
return false;
|
|
@@ -52,10 +42,8 @@ class GzipCompression extends _CompressionPlugin.CompressionPlugin {
|
|
|
52
42
|
console.log(`Could not decompress given data since its compression is not "${GZIP}". It is "${data.compression}".`);
|
|
53
43
|
return false;
|
|
54
44
|
}
|
|
55
|
-
|
|
56
45
|
return true;
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
async decompress(data) {
|
|
60
48
|
try {
|
|
61
49
|
const buf = await (0, _gzip.decompress)(convertToBuffer(data.value));
|
|
@@ -65,9 +53,7 @@ class GzipCompression extends _CompressionPlugin.CompressionPlugin {
|
|
|
65
53
|
return null;
|
|
66
54
|
}
|
|
67
55
|
}
|
|
68
|
-
|
|
69
56
|
}
|
|
70
|
-
|
|
71
57
|
const createGzipCompression = () => {
|
|
72
58
|
return new GzipCompression();
|
|
73
59
|
};
|
|
@@ -75,12 +61,8 @@ const createGzipCompression = () => {
|
|
|
75
61
|
* Left due to backward compatibility with older systems.
|
|
76
62
|
* Remove when upgraded the system to run from @webiny/api-serverless-cms-aws
|
|
77
63
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
64
|
exports.createGzipCompression = createGzipCompression;
|
|
81
|
-
|
|
82
65
|
var _default = () => {
|
|
83
66
|
return createGzipCompression();
|
|
84
67
|
};
|
|
85
|
-
|
|
86
68
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","GzipCompression","CompressionPlugin","canCompress","data","compression","console","log","compress","gzip","JSON","stringify","toString","canDecompress","decompress","buf","ungzip","parse","ex","createGzipCompression"],"sources":["GzipCompression.ts"],"sourcesContent":["import { CompressionPlugin } from \"~/plugins/definition/CompressionPlugin\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer) => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface CompressedData {\n compression: string;\n value: string;\n}\n\ninterface OriginalData {\n [key: string]: any;\n}\n\nclass GzipCompression extends CompressionPlugin {\n public canCompress(data: any): boolean {\n /**\n * If already compressed, skip this.\n */\n if (data.compression) {\n if (data.compression !== \"GZIP\") {\n console.log(`Data is already compressed with \"${data.compression}\".`);\n }\n return false;\n }\n return true;\n }\n public async compress(data: any) {\n const value = await gzip(JSON.stringify(data));\n\n return {\n compression: GZIP,\n value: value.toString(TO_STORAGE_ENCODING)\n };\n }\n\n public canDecompress(data: CompressedData | Record<string, any>): boolean {\n if (!data || !data.compression) {\n return false;\n } else if (data.compression !== GZIP) {\n console.log(\n `Could not decompress given data since its compression is not \"${GZIP}\". It is \"${data.compression}\".`\n );\n return false;\n }\n return true;\n }\n\n public async decompress(data: CompressedData): Promise<OriginalData | null> {\n try {\n const buf = await ungzip(convertToBuffer(data.value));\n const value = buf.toString(FROM_STORAGE_ENCODING);\n return JSON.parse(value);\n } catch (ex) {\n return null;\n }\n }\n}\n\nexport const createGzipCompression = () => {\n return new GzipCompression();\n};\n/**\n * Left due to backward compatibility with older systems.\n * Remove when upgraded the system to run from @webiny/api-serverless-cms-aws\n */\nexport default () => {\n return createGzipCompression();\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","GzipCompression","CompressionPlugin","canCompress","data","compression","console","log","compress","gzip","JSON","stringify","toString","canDecompress","decompress","buf","ungzip","parse","ex","createGzipCompression"],"sources":["GzipCompression.ts"],"sourcesContent":["import { CompressionPlugin } from \"~/plugins/definition/CompressionPlugin\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer) => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface CompressedData {\n compression: string;\n value: string;\n}\n\ninterface OriginalData {\n [key: string]: any;\n}\n\nclass GzipCompression extends CompressionPlugin {\n public canCompress(data: any): boolean {\n /**\n * If already compressed, skip this.\n */\n if (data.compression) {\n if (data.compression !== \"GZIP\") {\n console.log(`Data is already compressed with \"${data.compression}\".`);\n }\n return false;\n }\n return true;\n }\n public async compress(data: any) {\n const value = await gzip(JSON.stringify(data));\n\n return {\n compression: GZIP,\n value: value.toString(TO_STORAGE_ENCODING)\n };\n }\n\n public canDecompress(data: CompressedData | Record<string, any>): boolean {\n if (!data || !data.compression) {\n return false;\n } else if (data.compression !== GZIP) {\n console.log(\n `Could not decompress given data since its compression is not \"${GZIP}\". It is \"${data.compression}\".`\n );\n return false;\n }\n return true;\n }\n\n public async decompress(data: CompressedData): Promise<OriginalData | null> {\n try {\n const buf = await ungzip(convertToBuffer(data.value));\n const value = buf.toString(FROM_STORAGE_ENCODING);\n return JSON.parse(value);\n } catch (ex) {\n return null;\n }\n }\n}\n\nexport const createGzipCompression = () => {\n return new GzipCompression();\n};\n/**\n * Left due to backward compatibility with older systems.\n * Remove when upgraded the system to run from @webiny/api-serverless-cms-aws\n */\nexport default () => {\n return createGzipCompression();\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA,MAAMA,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAK;EAChD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAWD,MAAMG,eAAe,SAASC,oCAAiB,CAAC;EACrCC,WAAW,CAACC,IAAS,EAAW;IACnC;AACR;AACA;IACQ,IAAIA,IAAI,CAACC,WAAW,EAAE;MAClB,IAAID,IAAI,CAACC,WAAW,KAAK,MAAM,EAAE;QAC7BC,OAAO,CAACC,GAAG,CAAE,oCAAmCH,IAAI,CAACC,WAAY,IAAG,CAAC;MACzE;MACA,OAAO,KAAK;IAChB;IACA,OAAO,IAAI;EACf;EACA,MAAaG,QAAQ,CAACJ,IAAS,EAAE;IAC7B,MAAMN,KAAK,GAAG,MAAM,IAAAW,cAAI,EAACC,IAAI,CAACC,SAAS,CAACP,IAAI,CAAC,CAAC;IAE9C,OAAO;MACHC,WAAW,EAAEX,IAAI;MACjBI,KAAK,EAAEA,KAAK,CAACc,QAAQ,CAACjB,mBAAmB;IAC7C,CAAC;EACL;EAEOkB,aAAa,CAACT,IAA0C,EAAW;IACtE,IAAI,CAACA,IAAI,IAAI,CAACA,IAAI,CAACC,WAAW,EAAE;MAC5B,OAAO,KAAK;IAChB,CAAC,MAAM,IAAID,IAAI,CAACC,WAAW,KAAKX,IAAI,EAAE;MAClCY,OAAO,CAACC,GAAG,CACN,iEAAgEb,IAAK,aAAYU,IAAI,CAACC,WAAY,IAAG,CACzG;MACD,OAAO,KAAK;IAChB;IACA,OAAO,IAAI;EACf;EAEA,MAAaS,UAAU,CAACV,IAAoB,EAAgC;IACxE,IAAI;MACA,MAAMW,GAAG,GAAG,MAAM,IAAAC,gBAAM,EAACnB,eAAe,CAACO,IAAI,CAACN,KAAK,CAAC,CAAC;MACrD,MAAMA,KAAK,GAAGiB,GAAG,CAACH,QAAQ,CAAChB,qBAAqB,CAAC;MACjD,OAAOc,IAAI,CAACO,KAAK,CAACnB,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOoB,EAAE,EAAE;MACT,OAAO,IAAI;IACf;EACJ;AACJ;AAEO,MAAMC,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIlB,eAAe,EAAE;AAChC,CAAC;AACD;AACA;AACA;AACA;AAHA;AAAA,eAIe,MAAM;EACjB,OAAOkB,qBAAqB,EAAE;AAClC,CAAC;AAAA"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.CompressionPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
class CompressionPlugin extends _plugins.Plugin {}
|
|
15
|
-
|
|
16
11
|
exports.CompressionPlugin = CompressionPlugin;
|
|
17
12
|
(0, _defineProperty2.default)(CompressionPlugin, "type", "elasticsearch.compression");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CompressionPlugin","Plugin"],"sources":["CompressionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport abstract class CompressionPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.compression\";\n /**\n * Check if data can be compressed.\n */\n public abstract canCompress(data: any): boolean;\n /**\n * Pass the data to get the compressed one back.\n */\n public abstract compress(data: any): Promise<any>;\n /**\n * Check if data can be decompressed.\n */\n public abstract canDecompress(data: any): boolean;\n /**\n * Passed the compressed data to get the original data back.\n */\n public abstract decompress(data: any): Promise<any>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CompressionPlugin","Plugin"],"sources":["CompressionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\n\nexport abstract class CompressionPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.compression\";\n /**\n * Check if data can be compressed.\n */\n public abstract canCompress(data: any): boolean;\n /**\n * Pass the data to get the compressed one back.\n */\n public abstract compress(data: any): Promise<any>;\n /**\n * Check if data can be decompressed.\n */\n public abstract canDecompress(data: any): boolean;\n /**\n * Passed the compressed data to get the original data back.\n */\n public abstract decompress(data: any): Promise<any>;\n}\n"],"mappings":";;;;;;;;AAAA;AAEO,MAAeA,iBAAiB,SAASC,eAAM,CAAC;AAkBtD;AAAA,8BAlBqBD,iBAAiB,UACY,2BAA2B"}
|
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ElasticsearchBodyModifierPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
10
|
var _plugins = require("@webiny/plugins");
|
|
15
|
-
|
|
16
11
|
class ElasticsearchBodyModifierPlugin extends _plugins.Plugin {
|
|
17
12
|
constructor(callable) {
|
|
18
13
|
super();
|
|
19
14
|
(0, _defineProperty2.default)(this, "callable", void 0);
|
|
20
15
|
this.callable = callable;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
modifyBody(params) {
|
|
24
18
|
if (typeof this.callable !== "function") {
|
|
25
19
|
throw new _error.default(`Missing modification for the body.`, "BODY_MODIFICATION_MISSING", {
|
|
26
20
|
params
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
this.callable(params);
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
exports.ElasticsearchBodyModifierPlugin = ElasticsearchBodyModifierPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ElasticsearchBodyModifierPlugin","Plugin","constructor","callable","modifyBody","params","WebinyError"],"sources":["ElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { SearchBody } from \"elastic-ts\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ElasticsearchBodyModifierPlugin","Plugin","constructor","callable","modifyBody","params","WebinyError"],"sources":["ElasticsearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { SearchBody } from \"elastic-ts\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class ElasticsearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAWO,MAAeA,+BAA+B,SAE3CC,eAAM,CAAC;EAGNC,WAAW,CAACC,QAAgC,EAAE;IACjD,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAU,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIG,cAAW,CAChB,oCAAmC,EACpC,2BAA2B,EAC3B;QACID;MACJ,CAAC,CACJ;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ;AAAC"}
|
|
@@ -48,7 +48,7 @@ export interface ElasticsearchFieldPluginParams {
|
|
|
48
48
|
*/
|
|
49
49
|
toSearchValue?: (params: ToSearchValueParams) => any;
|
|
50
50
|
}
|
|
51
|
-
export declare
|
|
51
|
+
export declare class ElasticsearchFieldPlugin extends Plugin {
|
|
52
52
|
static readonly type: string;
|
|
53
53
|
static readonly ALL: string;
|
|
54
54
|
readonly field: string;
|
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ElasticsearchFieldPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _plugins = require("@webiny/plugins");
|
|
15
|
-
|
|
16
11
|
const keywordLessUnmappedType = ["date", "long"];
|
|
17
|
-
|
|
18
12
|
const unmappedTypeHasKeyword = type => {
|
|
19
13
|
if (!type) {
|
|
20
14
|
return true;
|
|
21
15
|
} else if (keywordLessUnmappedType.includes(type)) {
|
|
22
16
|
return false;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
return true;
|
|
26
19
|
};
|
|
27
|
-
|
|
28
20
|
class ElasticsearchFieldPlugin extends _plugins.Plugin {
|
|
29
21
|
constructor(params) {
|
|
30
22
|
super();
|
|
@@ -38,28 +30,22 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
|
|
|
38
30
|
this.path = params.path || params.field;
|
|
39
31
|
this.keyword = params.keyword === undefined ? true : params.keyword;
|
|
40
32
|
this.unmappedType = params.unmappedType;
|
|
41
|
-
|
|
42
33
|
if (unmappedTypeHasKeyword(params.unmappedType) === false) {
|
|
43
34
|
this.keyword = false;
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
this.sortable = params.sortable === undefined ? true : params.sortable;
|
|
47
37
|
this.searchable = params.searchable === undefined ? true : params.searchable;
|
|
48
38
|
}
|
|
49
39
|
/**
|
|
50
40
|
* The default sort options. Extend in your own plugin if you want to add more options.
|
|
51
41
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
42
|
getSortOptions(order) {
|
|
55
43
|
const options = {
|
|
56
44
|
order
|
|
57
45
|
};
|
|
58
|
-
|
|
59
46
|
if (!this.unmappedType) {
|
|
60
47
|
return options;
|
|
61
48
|
}
|
|
62
|
-
|
|
63
49
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, options), {}, {
|
|
64
50
|
unmapped_type: this.unmappedType
|
|
65
51
|
});
|
|
@@ -68,8 +54,6 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
|
|
|
68
54
|
* The default path generator. Extend in your own plugin if you want to add more options.
|
|
69
55
|
* Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.
|
|
70
56
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
57
|
getPath(field) {
|
|
74
58
|
return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
|
|
75
59
|
}
|
|
@@ -78,27 +62,20 @@ class ElasticsearchFieldPlugin extends _plugins.Plugin {
|
|
|
78
62
|
*
|
|
79
63
|
* This is the default base path generator. Basically it replaces ALL with given field name.
|
|
80
64
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
65
|
getBasePath(field) {
|
|
84
66
|
if (this.path === ElasticsearchFieldPlugin.ALL) {
|
|
85
67
|
return field;
|
|
86
68
|
}
|
|
87
|
-
|
|
88
69
|
return this.path;
|
|
89
70
|
}
|
|
90
71
|
/**
|
|
91
72
|
* The default transformer. Just returns the value by default.
|
|
92
73
|
* Override to implement what ever is required.
|
|
93
74
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
75
|
toSearchValue(params) {
|
|
97
76
|
return params.value;
|
|
98
77
|
}
|
|
99
|
-
|
|
100
78
|
}
|
|
101
|
-
|
|
102
79
|
exports.ElasticsearchFieldPlugin = ElasticsearchFieldPlugin;
|
|
103
80
|
(0, _defineProperty2.default)(ElasticsearchFieldPlugin, "type", "elasticsearch.fieldDefinition");
|
|
104
81
|
(0, _defineProperty2.default)(ElasticsearchFieldPlugin, "ALL", "*");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","ElasticsearchFieldPlugin","Plugin","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","ALL","toSearchValue","value"],"sources":["ElasticsearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FieldSortOptions, SortOrder } from \"elastic-ts\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface ElasticsearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport
|
|
1
|
+
{"version":3,"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","ElasticsearchFieldPlugin","Plugin","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","ALL","toSearchValue","value"],"sources":["ElasticsearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { FieldSortOptions, SortOrder } from \"elastic-ts\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface ElasticsearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class ElasticsearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"elasticsearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: ElasticsearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n unmapped_type: this.unmappedType\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === ElasticsearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAKA,MAAMA,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAEhD,MAAMC,sBAAsB,GAAIC,IAAa,IAAc;EACvD,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAIF,uBAAuB,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;IAC/C,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAkDM,MAAME,wBAAwB,SAASC,eAAM,CAAC;EAWjDC,WAAW,CAACC,MAAsC,EAAE;IAChD,KAAK,EAAE;IAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IACR,IAAI,CAACC,KAAK,GAAGD,MAAM,CAACC,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI,IAAIF,MAAM,CAACC,KAAK;IACvC,IAAI,CAACE,OAAO,GAAGH,MAAM,CAACG,OAAO,KAAKC,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACG,OAAO;IACnE,IAAI,CAACE,YAAY,GAAGL,MAAM,CAACK,YAAY;IACvC,IAAIX,sBAAsB,CAACM,MAAM,CAACK,YAAY,CAAC,KAAK,KAAK,EAAE;MACvD,IAAI,CAACF,OAAO,GAAG,KAAK;IACxB;IACA,IAAI,CAACG,QAAQ,GAAGN,MAAM,CAACM,QAAQ,KAAKF,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACM,QAAQ;IACtE,IAAI,CAACC,UAAU,GAAGP,MAAM,CAACO,UAAU,KAAKH,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACO,UAAU;EAChF;EACA;AACJ;AACA;EACWC,cAAc,CAACC,KAAgB,EAAoB;IACtD,MAAMC,OAAO,GAAG;MACZD;IACJ,CAAC;IACD,IAAI,CAAC,IAAI,CAACJ,YAAY,EAAE;MACpB,OAAOK,OAAO;IAClB;IACA,mEACOA,OAAO;MACVC,aAAa,EAAE,IAAI,CAACN;IAAY;EAExC;EACA;AACJ;AACA;AACA;EACWO,OAAO,CAACX,KAAa,EAAU;IAClC,OAAQ,GAAE,IAAI,CAACY,WAAW,CAACZ,KAAK,CAAE,GAAE,IAAI,CAACE,OAAO,GAAG,UAAU,GAAG,EAAG,EAAC;EACxE;EACA;AACJ;AACA;AACA;AACA;EACWU,WAAW,CAACZ,KAAa,EAAU;IACtC,IAAI,IAAI,CAACC,IAAI,KAAKL,wBAAwB,CAACiB,GAAG,EAAE;MAC5C,OAAOb,KAAK;IAChB;IACA,OAAO,IAAI,CAACC,IAAI;EACpB;EACA;AACJ;AACA;AACA;EACWa,aAAa,CAACf,MAA2B,EAAO;IACnD,OAAOA,MAAM,CAACgB,KAAK;EACvB;AACJ;AAAC;AAAA,8BA/DYnB,wBAAwB,UACc,+BAA+B;AAAA,8BADrEA,wBAAwB,SAEI,GAAG"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ElasticsearchIndexPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
11
|
var _plugins = require("@webiny/plugins");
|
|
17
|
-
|
|
18
12
|
class ElasticsearchIndexPlugin extends _plugins.Plugin {
|
|
19
13
|
constructor(params) {
|
|
20
14
|
super();
|
|
@@ -27,7 +21,6 @@ class ElasticsearchIndexPlugin extends _plugins.Plugin {
|
|
|
27
21
|
this.body = (0, _objectSpread2.default)({}, body);
|
|
28
22
|
this.locales = locales ? locales.map(locale => locale.toLowerCase()) : undefined;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
canUse(locale) {
|
|
32
25
|
if (!this.locales) {
|
|
33
26
|
return true;
|
|
@@ -37,10 +30,7 @@ class ElasticsearchIndexPlugin extends _plugins.Plugin {
|
|
|
37
30
|
locales: this.locales
|
|
38
31
|
});
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
return this.locales.includes(locale.toLowerCase());
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
exports.ElasticsearchIndexPlugin = ElasticsearchIndexPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ElasticsearchIndexPlugin","Plugin","constructor","params","locales","body","map","locale","toLowerCase","undefined","canUse","length","WebinyError","includes"],"sources":["ElasticsearchIndexPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchIndexRequestBody } from \"~/types\";\n\nexport interface ElasticsearchIndexPluginParams {\n /**\n * For which locales are we applying this plugin.\n * Options:\n * - locale codes to target specific locale\n * - null for all\n */\n locales?: string[];\n body: ElasticsearchIndexRequestBody;\n}\n\nexport abstract class ElasticsearchIndexPlugin extends Plugin {\n public readonly body: ElasticsearchIndexRequestBody;\n private readonly locales: string[] | undefined;\n\n public constructor(params: ElasticsearchIndexPluginParams) {\n super();\n const { locales, body } = params;\n this.body = {\n ...body\n };\n this.locales = locales ? locales.map(locale => locale.toLowerCase()) : undefined;\n }\n\n public canUse(locale: string): boolean {\n if (!this.locales) {\n return true;\n } else if (this.locales.length === 0) {\n throw new WebinyError(\n \"Cannot have Elasticsearch Index Template plugin with no locales defined.\",\n \"LOCALES_ERROR\",\n {\n body: this.body,\n locales: this.locales\n }\n );\n }\n return this.locales.includes(locale.toLowerCase());\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ElasticsearchIndexPlugin","Plugin","constructor","params","locales","body","map","locale","toLowerCase","undefined","canUse","length","WebinyError","includes"],"sources":["ElasticsearchIndexPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { ElasticsearchIndexRequestBody } from \"~/types\";\n\nexport interface ElasticsearchIndexPluginParams {\n /**\n * For which locales are we applying this plugin.\n * Options:\n * - locale codes to target specific locale\n * - null for all\n */\n locales?: string[];\n body: ElasticsearchIndexRequestBody;\n}\n\nexport abstract class ElasticsearchIndexPlugin extends Plugin {\n public readonly body: ElasticsearchIndexRequestBody;\n private readonly locales: string[] | undefined;\n\n public constructor(params: ElasticsearchIndexPluginParams) {\n super();\n const { locales, body } = params;\n this.body = {\n ...body\n };\n this.locales = locales ? locales.map(locale => locale.toLowerCase()) : undefined;\n }\n\n public canUse(locale: string): boolean {\n if (!this.locales) {\n return true;\n } else if (this.locales.length === 0) {\n throw new WebinyError(\n \"Cannot have Elasticsearch Index Template plugin with no locales defined.\",\n \"LOCALES_ERROR\",\n {\n body: this.body,\n locales: this.locales\n }\n );\n }\n return this.locales.includes(locale.toLowerCase());\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AAcO,MAAeA,wBAAwB,SAASC,eAAM,CAAC;EAInDC,WAAW,CAACC,MAAsC,EAAE;IACvD,KAAK,EAAE;IAAC;IAAA;IACR,MAAM;MAAEC,OAAO;MAAEC;IAAK,CAAC,GAAGF,MAAM;IAChC,IAAI,CAACE,IAAI,mCACFA,IAAI,CACV;IACD,IAAI,CAACD,OAAO,GAAGA,OAAO,GAAGA,OAAO,CAACE,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACC,WAAW,EAAE,CAAC,GAAGC,SAAS;EACpF;EAEOC,MAAM,CAACH,MAAc,EAAW;IACnC,IAAI,CAAC,IAAI,CAACH,OAAO,EAAE;MACf,OAAO,IAAI;IACf,CAAC,MAAM,IAAI,IAAI,CAACA,OAAO,CAACO,MAAM,KAAK,CAAC,EAAE;MAClC,MAAM,IAAIC,cAAW,CACjB,0EAA0E,EAC1E,eAAe,EACf;QACIP,IAAI,EAAE,IAAI,CAACA,IAAI;QACfD,OAAO,EAAE,IAAI,CAACA;MAClB,CAAC,CACJ;IACL;IACA,OAAO,IAAI,CAACA,OAAO,CAACS,QAAQ,CAACN,MAAM,CAACC,WAAW,EAAE,CAAC;EACtD;AACJ;AAAC"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ElasticsearchQueryBuilderOperatorPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
|
|
16
12
|
*/
|
|
@@ -22,8 +18,6 @@ class ElasticsearchQueryBuilderOperatorPlugin extends _plugins.Plugin {
|
|
|
22
18
|
isLocaleSupported(_) {
|
|
23
19
|
return true;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
exports.ElasticsearchQueryBuilderOperatorPlugin = ElasticsearchQueryBuilderOperatorPlugin;
|
|
29
23
|
(0, _defineProperty2.default)(ElasticsearchQueryBuilderOperatorPlugin, "type", "elasticsearch.queryBuilder.operator");
|