@webiny/api-elasticsearch 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 +1 -0
- package/client.d.ts +5 -0
- package/client.js +55 -0
- package/client.js.map +1 -0
- package/compression.d.ts +6 -0
- package/compression.js +68 -0
- package/compression.js.map +1 -0
- package/cursors.d.ts +10 -0
- package/cursors.js +55 -0
- package/cursors.js.map +1 -0
- package/index.d.ts +21 -0
- package/index.js +203 -0
- package/index.js.map +1 -0
- package/indexConfiguration/base.d.ts +6 -0
- package/indexConfiguration/base.js +45 -0
- package/indexConfiguration/base.js.map +1 -0
- package/indexConfiguration/common.d.ts +9 -0
- package/indexConfiguration/common.js +45 -0
- package/indexConfiguration/common.js.map +1 -0
- package/indexConfiguration/index.d.ts +3 -0
- package/indexConfiguration/index.js +44 -0
- package/indexConfiguration/index.js.map +1 -0
- package/indexConfiguration/japanese.d.ts +6 -0
- package/indexConfiguration/japanese.js +124 -0
- package/indexConfiguration/japanese.js.map +1 -0
- package/indices.d.ts +9 -0
- package/indices.js +35 -0
- package/indices.js.map +1 -0
- package/limit.d.ts +1 -0
- package/limit.js +45 -0
- package/limit.js.map +1 -0
- package/normalize.d.ts +5 -0
- package/normalize.js +24 -0
- package/normalize.js.map +1 -0
- package/operators.d.ts +9 -0
- package/operators.js +56 -0
- package/operators.js.map +1 -0
- package/package.json +49 -0
- package/plugins/GzipCompression.d.ts +24 -0
- package/plugins/GzipCompression.js +86 -0
- package/plugins/GzipCompression.js.map +1 -0
- package/plugins/definition/CompressionPlugin.d.ts +20 -0
- package/plugins/definition/CompressionPlugin.js +17 -0
- package/plugins/definition/CompressionPlugin.js.map +1 -0
- package/plugins/definition/ElasticsearchBodyModifierPlugin.d.ts +13 -0
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js +35 -0
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/definition/ElasticsearchFieldPlugin.d.ts +81 -0
- package/plugins/definition/ElasticsearchFieldPlugin.js +104 -0
- package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/definition/ElasticsearchIndexPlugin.d.ts +18 -0
- package/plugins/definition/ElasticsearchIndexPlugin.js +46 -0
- package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +14 -0
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +29 -0
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -0
- package/plugins/definition/ElasticsearchQueryModifierPlugin.d.ts +14 -0
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js +35 -0
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/definition/ElasticsearchSortModifierPlugin.d.ts +13 -0
- package/plugins/definition/ElasticsearchSortModifierPlugin.js +35 -0
- package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/definition/index.d.ts +7 -0
- package/plugins/definition/index.js +96 -0
- package/plugins/definition/index.js.map +1 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +31 -0
- package/plugins/index.js.map +1 -0
- package/plugins/operator/andIn.d.ts +7 -0
- package/plugins/operator/andIn.js +56 -0
- package/plugins/operator/andIn.js.map +1 -0
- package/plugins/operator/between.d.ts +7 -0
- package/plugins/operator/between.js +52 -0
- package/plugins/operator/between.js.map +1 -0
- package/plugins/operator/contains.d.ts +7 -0
- package/plugins/operator/contains.js +43 -0
- package/plugins/operator/contains.js.map +1 -0
- package/plugins/operator/equal.d.ts +7 -0
- package/plugins/operator/equal.js +74 -0
- package/plugins/operator/equal.js.map +1 -0
- package/plugins/operator/gt.d.ts +7 -0
- package/plugins/operator/gt.js +40 -0
- package/plugins/operator/gt.js.map +1 -0
- package/plugins/operator/gte.d.ts +7 -0
- package/plugins/operator/gte.js +40 -0
- package/plugins/operator/gte.js.map +1 -0
- package/plugins/operator/in.d.ts +7 -0
- package/plugins/operator/in.js +48 -0
- package/plugins/operator/in.js.map +1 -0
- package/plugins/operator/index.d.ts +16 -0
- package/plugins/operator/index.js +213 -0
- package/plugins/operator/index.js.map +1 -0
- package/plugins/operator/japanese/contains.d.ts +8 -0
- package/plugins/operator/japanese/contains.js +58 -0
- package/plugins/operator/japanese/contains.js.map +1 -0
- package/plugins/operator/lt.d.ts +7 -0
- package/plugins/operator/lt.js +40 -0
- package/plugins/operator/lt.js.map +1 -0
- package/plugins/operator/lte.d.ts +7 -0
- package/plugins/operator/lte.js +40 -0
- package/plugins/operator/lte.js.map +1 -0
- package/plugins/operator/not.d.ts +7 -0
- package/plugins/operator/not.js +62 -0
- package/plugins/operator/not.js.map +1 -0
- package/plugins/operator/notBetween.d.ts +7 -0
- package/plugins/operator/notBetween.js +52 -0
- package/plugins/operator/notBetween.js.map +1 -0
- package/plugins/operator/notContains.d.ts +7 -0
- package/plugins/operator/notContains.js +43 -0
- package/plugins/operator/notContains.js.map +1 -0
- package/plugins/operator/notIn.d.ts +7 -0
- package/plugins/operator/notIn.js +47 -0
- package/plugins/operator/notIn.js.map +1 -0
- package/plugins/operator/notStartsWith.d.ts +7 -0
- package/plugins/operator/notStartsWith.js +38 -0
- package/plugins/operator/notStartsWith.js.map +1 -0
- package/plugins/operator/startsWith.d.ts +7 -0
- package/plugins/operator/startsWith.js +38 -0
- package/plugins/operator/startsWith.js.map +1 -0
- package/sort.d.ts +13 -0
- package/sort.js +75 -0
- package/sort.js.map +1 -0
- package/types.d.ts +208 -0
- package/types.js +30 -0
- package/types.js.map +1 -0
- package/where.d.ts +17 -0
- package/where.js +107 -0
- package/where.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @webiny/api-elasticsearch
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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.createElasticsearchClient = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
|
|
14
|
+
var _elasticsearch = require("@elastic/elasticsearch");
|
|
15
|
+
|
|
16
|
+
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
17
|
+
|
|
18
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
19
|
+
|
|
20
|
+
var _awsElasticsearchConnector = _interopRequireDefault(require("aws-elasticsearch-connector"));
|
|
21
|
+
|
|
22
|
+
const _excluded = ["endpoint", "node"];
|
|
23
|
+
|
|
24
|
+
const createElasticsearchClient = options => {
|
|
25
|
+
const {
|
|
26
|
+
endpoint,
|
|
27
|
+
node
|
|
28
|
+
} = options,
|
|
29
|
+
rest = (0, _objectWithoutProperties2.default)(options, _excluded);
|
|
30
|
+
const clientOptions = (0, _objectSpread2.default)({
|
|
31
|
+
node: endpoint || node
|
|
32
|
+
}, rest);
|
|
33
|
+
|
|
34
|
+
if (!clientOptions.auth) {
|
|
35
|
+
/**
|
|
36
|
+
* If no `auth` configuration is present, we setup AWS connector.
|
|
37
|
+
*/
|
|
38
|
+
Object.assign(clientOptions, (0, _awsElasticsearchConnector.default)(_awsSdk.default.config));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
return new _elasticsearch.Client(clientOptions);
|
|
43
|
+
} catch (ex) {
|
|
44
|
+
const data = (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
45
|
+
error: ex,
|
|
46
|
+
node: endpoint || node
|
|
47
|
+
}, rest), {}, {
|
|
48
|
+
auth: undefined
|
|
49
|
+
});
|
|
50
|
+
console.log((0, _objectSpread2.default)({}, data));
|
|
51
|
+
throw new _error.default("Could not connect to Elasticsearch.", "ELASTICSEARCH_CLIENT_ERROR", data);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.createElasticsearchClient = createElasticsearchClient;
|
package/client.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElasticsearchClient","options","endpoint","node","rest","clientOptions","auth","Object","assign","createAwsElasticsearchConnector","AWS","config","Client","ex","data","error","undefined","console","log","WebinyError"],"sources":["client.ts"],"sourcesContent":["import { Client, ClientOptions } from \"@elastic/elasticsearch\";\nimport AWS from \"aws-sdk\";\nimport WebinyError from \"@webiny/error\";\n/**\n * Package aws-elasticsearch-connector does not have types.\n */\n// @ts-ignore\nimport createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions) => {\n const { endpoint, node, ...rest } = options;\n\n const clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n /**\n * If no `auth` configuration is present, we setup AWS connector.\n */\n Object.assign(clientOptions, createAwsElasticsearchConnector(AWS.config));\n }\n\n try {\n return new Client(clientOptions);\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.log({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"ELASTICSEARCH_CLIENT_ERROR\",\n data\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAKA;;;;AAMO,MAAMA,yBAAyB,GAAIC,OAAD,IAAyC;EAC9E,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAA8BF,OAApC;EAAA,MAA2BG,IAA3B,0CAAoCH,OAApC;EAEA,MAAMI,aAA4B;IAC9BF,IAAI,EAAED,QAAQ,IAAIC;EADY,GAE3BC,IAF2B,CAAlC;;EAKA,IAAI,CAACC,aAAa,CAACC,IAAnB,EAAyB;IACrB;AACR;AACA;IACQC,MAAM,CAACC,MAAP,CAAcH,aAAd,EAA6B,IAAAI,kCAAA,EAAgCC,eAAA,CAAIC,MAApC,CAA7B;EACH;;EAED,IAAI;IACA,OAAO,IAAIC,qBAAJ,CAAWP,aAAX,CAAP;EACH,CAFD,CAEE,OAAOQ,EAAP,EAAW;IACT,MAAMC,IAAI;MACNC,KAAK,EAAEF,EADD;MAENV,IAAI,EAAED,QAAQ,IAAIC;IAFZ,GAGHC,IAHG;MAINE,IAAI,EAAEU;IAJA,EAAV;IAMAC,OAAO,CAACC,GAAR,iCACOJ,IADP;IAGA,MAAM,IAAIK,cAAJ,CACF,qCADE,EAEF,4BAFE,EAGFL,IAHE,CAAN;EAKH;AACJ,CAjCM"}
|
package/compression.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
+
/**
|
|
3
|
+
* Method to compress the elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.
|
|
4
|
+
*/
|
|
5
|
+
export declare const compress: (pluginsContainer: PluginsContainer, data: Record<string, any>) => Promise<Record<string, any>>;
|
|
6
|
+
export declare const decompress: (pluginsContainer: PluginsContainer, data: Record<string, any>) => Promise<Record<string, any>>;
|
package/compression.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decompress = exports.compress = void 0;
|
|
7
|
+
|
|
8
|
+
var _CompressionPlugin = require("./plugins/definition/CompressionPlugin");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Get the compression plugins, in reverse order, because we want to use the last one added - first.
|
|
12
|
+
*/
|
|
13
|
+
const getCompressionPlugins = plugins => {
|
|
14
|
+
return plugins.byType(_CompressionPlugin.CompressionPlugin.type).reverse();
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Method to compress the elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const compress = async (pluginsContainer, data) => {
|
|
22
|
+
const plugins = getCompressionPlugins(pluginsContainer);
|
|
23
|
+
|
|
24
|
+
if (plugins.length === 0) {
|
|
25
|
+
console.log("No compression plugins");
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for (const plugin of plugins) {
|
|
30
|
+
if (plugin.canCompress(data) === false) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return await plugin.compress(data);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Possibly no plugins that can compress, just return the data.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.compress = compress;
|
|
45
|
+
|
|
46
|
+
const decompress = async (pluginsContainer, data) => {
|
|
47
|
+
const plugins = getCompressionPlugins(pluginsContainer);
|
|
48
|
+
|
|
49
|
+
if (plugins.length === 0) {
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (const plugin of plugins) {
|
|
54
|
+
if (plugin.canDecompress(data) === false) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return await plugin.decompress(data);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Possibly no plugins that can decompress, just return the data.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
return data;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
exports.decompress = decompress;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCompressionPlugins","plugins","byType","CompressionPlugin","type","reverse","compress","pluginsContainer","data","length","console","log","plugin","canCompress","decompress","canDecompress"],"sources":["compression.ts"],"sourcesContent":["import { CompressionPlugin } from \"~/plugins/definition/CompressionPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * Get the compression plugins, in reverse order, because we want to use the last one added - first.\n */\nconst getCompressionPlugins = (plugins: PluginsContainer): CompressionPlugin[] => {\n return plugins.byType<CompressionPlugin>(CompressionPlugin.type).reverse();\n};\n/**\n * Method to compress the elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.\n */\nexport const compress = async (\n pluginsContainer: PluginsContainer,\n data: Record<string, any>\n): Promise<Record<string, any>> => {\n const plugins = getCompressionPlugins(pluginsContainer);\n if (plugins.length === 0) {\n console.log(\"No compression plugins\");\n return data;\n }\n for (const plugin of plugins) {\n if (plugin.canCompress(data) === false) {\n continue;\n }\n return await plugin.compress(data);\n }\n /**\n * Possibly no plugins that can compress, just return the data.\n */\n return data;\n};\n\nexport const decompress = async (\n pluginsContainer: PluginsContainer,\n data: Record<string, any>\n): Promise<Record<string, any>> => {\n const plugins = getCompressionPlugins(pluginsContainer);\n if (plugins.length === 0) {\n return data;\n }\n for (const plugin of plugins) {\n if (plugin.canDecompress(data) === false) {\n continue;\n }\n return await plugin.decompress(data);\n }\n /**\n * Possibly no plugins that can decompress, just return the data.\n */\n return data;\n};\n"],"mappings":";;;;;;;AAAA;;AAGA;AACA;AACA;AACA,MAAMA,qBAAqB,GAAIC,OAAD,IAAoD;EAC9E,OAAOA,OAAO,CAACC,MAAR,CAAkCC,oCAAA,CAAkBC,IAApD,EAA0DC,OAA1D,EAAP;AACH,CAFD;AAGA;AACA;AACA;;;AACO,MAAMC,QAAQ,GAAG,OACpBC,gBADoB,EAEpBC,IAFoB,KAGW;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAD,CAArC;;EACA,IAAIN,OAAO,CAACQ,MAAR,KAAmB,CAAvB,EAA0B;IACtBC,OAAO,CAACC,GAAR,CAAY,wBAAZ;IACA,OAAOH,IAAP;EACH;;EACD,KAAK,MAAMI,MAAX,IAAqBX,OAArB,EAA8B;IAC1B,IAAIW,MAAM,CAACC,WAAP,CAAmBL,IAAnB,MAA6B,KAAjC,EAAwC;MACpC;IACH;;IACD,OAAO,MAAMI,MAAM,CAACN,QAAP,CAAgBE,IAAhB,CAAb;EACH;EACD;AACJ;AACA;;;EACI,OAAOA,IAAP;AACH,CAnBM;;;;AAqBA,MAAMM,UAAU,GAAG,OACtBP,gBADsB,EAEtBC,IAFsB,KAGS;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAD,CAArC;;EACA,IAAIN,OAAO,CAACQ,MAAR,KAAmB,CAAvB,EAA0B;IACtB,OAAOD,IAAP;EACH;;EACD,KAAK,MAAMI,MAAX,IAAqBX,OAArB,EAA8B;IAC1B,IAAIW,MAAM,CAACG,aAAP,CAAqBP,IAArB,MAA+B,KAAnC,EAA0C;MACtC;IACH;;IACD,OAAO,MAAMI,MAAM,CAACE,UAAP,CAAkBN,IAAlB,CAAb;EACH;EACD;AACJ;AACA;;;EACI,OAAOA,IAAP;AACH,CAlBM"}
|
package/cursors.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PrimitiveValue } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Encode a received cursor value into something that can be passed on to the user.
|
|
4
|
+
*/
|
|
5
|
+
export declare const encodeCursor: (cursor?: string | string[] | null) => string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Decode a received value into a Elasticsearch cursor.
|
|
8
|
+
* If no value is received or is not decodable, return undefined.
|
|
9
|
+
*/
|
|
10
|
+
export declare const decodeCursor: (cursor?: string | null) => PrimitiveValue[] | undefined;
|
package/cursors.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.encodeCursor = exports.decodeCursor = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Encode a received cursor value into something that can be passed on to the user.
|
|
10
|
+
*/
|
|
11
|
+
const encodeCursor = cursor => {
|
|
12
|
+
if (!cursor) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
cursor = Array.isArray(cursor) ? cursor.map(encodeURIComponent) : encodeURIComponent(cursor);
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
return Buffer.from(JSON.stringify(cursor)).toString("base64");
|
|
20
|
+
} catch (ex) {
|
|
21
|
+
console.error(ex.message);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Decode a received value into a Elasticsearch cursor.
|
|
28
|
+
* If no value is received or is not decodable, return undefined.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
exports.encodeCursor = encodeCursor;
|
|
33
|
+
|
|
34
|
+
const decodeCursor = cursor => {
|
|
35
|
+
if (!cursor) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const value = JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
|
|
41
|
+
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return value.map(decodeURIComponent);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const decoded = decodeURIComponent(value);
|
|
47
|
+
return decoded ? [decoded] : undefined;
|
|
48
|
+
} catch (ex) {
|
|
49
|
+
console.error(ex.message);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return undefined;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.decodeCursor = decodeCursor;
|
package/cursors.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["encodeCursor","cursor","undefined","Array","isArray","map","encodeURIComponent","Buffer","from","JSON","stringify","toString","ex","console","error","message","decodeCursor","value","parse","decodeURIComponent","decoded"],"sources":["cursors.ts"],"sourcesContent":["import { PrimitiveValue } from \"~/types\";\n\n/**\n * Encode a received cursor value into something that can be passed on to the user.\n */\nexport const encodeCursor = (cursor?: string | string[] | null): string | undefined => {\n if (!cursor) {\n return undefined;\n }\n\n cursor = Array.isArray(cursor) ? cursor.map(encodeURIComponent) : encodeURIComponent(cursor);\n\n try {\n return Buffer.from(JSON.stringify(cursor)).toString(\"base64\");\n } catch (ex) {\n console.error(ex.message);\n }\n return undefined;\n};\n/**\n * Decode a received value into a Elasticsearch cursor.\n * If no value is received or is not decodable, return undefined.\n */\nexport const decodeCursor = (cursor?: string | null): PrimitiveValue[] | undefined => {\n if (!cursor) {\n return undefined;\n }\n try {\n const value = JSON.parse(Buffer.from(cursor, \"base64\").toString(\"ascii\"));\n if (Array.isArray(value)) {\n return value.map(decodeURIComponent);\n }\n const decoded = decodeURIComponent(value);\n return decoded ? [decoded] : undefined;\n } catch (ex) {\n console.error(ex.message);\n }\n return undefined;\n};\n"],"mappings":";;;;;;;AAEA;AACA;AACA;AACO,MAAMA,YAAY,GAAIC,MAAD,IAA2D;EACnF,IAAI,CAACA,MAAL,EAAa;IACT,OAAOC,SAAP;EACH;;EAEDD,MAAM,GAAGE,KAAK,CAACC,OAAN,CAAcH,MAAd,IAAwBA,MAAM,CAACI,GAAP,CAAWC,kBAAX,CAAxB,GAAyDA,kBAAkB,CAACL,MAAD,CAApF;;EAEA,IAAI;IACA,OAAOM,MAAM,CAACC,IAAP,CAAYC,IAAI,CAACC,SAAL,CAAeT,MAAf,CAAZ,EAAoCU,QAApC,CAA6C,QAA7C,CAAP;EACH,CAFD,CAEE,OAAOC,EAAP,EAAW;IACTC,OAAO,CAACC,KAAR,CAAcF,EAAE,CAACG,OAAjB;EACH;;EACD,OAAOb,SAAP;AACH,CAbM;AAcP;AACA;AACA;AACA;;;;;AACO,MAAMc,YAAY,GAAIf,MAAD,IAA0D;EAClF,IAAI,CAACA,MAAL,EAAa;IACT,OAAOC,SAAP;EACH;;EACD,IAAI;IACA,MAAMe,KAAK,GAAGR,IAAI,CAACS,KAAL,CAAWX,MAAM,CAACC,IAAP,CAAYP,MAAZ,EAAoB,QAApB,EAA8BU,QAA9B,CAAuC,OAAvC,CAAX,CAAd;;IACA,IAAIR,KAAK,CAACC,OAAN,CAAca,KAAd,CAAJ,EAA0B;MACtB,OAAOA,KAAK,CAACZ,GAAN,CAAUc,kBAAV,CAAP;IACH;;IACD,MAAMC,OAAO,GAAGD,kBAAkB,CAACF,KAAD,CAAlC;IACA,OAAOG,OAAO,GAAG,CAACA,OAAD,CAAH,GAAelB,SAA7B;EACH,CAPD,CAOE,OAAOU,EAAP,EAAW;IACTC,OAAO,CAACC,KAAR,CAAcF,EAAE,CAACG,OAAjB;EACH;;EACD,OAAOb,SAAP;AACH,CAfM"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ElasticsearchContext } from "./types";
|
|
2
|
+
import { ContextPlugin } from "@webiny/api";
|
|
3
|
+
import { ElasticsearchClientOptions } from "./client";
|
|
4
|
+
import { Client } from "@elastic/elasticsearch";
|
|
5
|
+
export * from "./indexConfiguration";
|
|
6
|
+
export * from "./plugins";
|
|
7
|
+
export * from "./sort";
|
|
8
|
+
export * from "./indices";
|
|
9
|
+
export * from "./where";
|
|
10
|
+
export * from "./limit";
|
|
11
|
+
export * from "./normalize";
|
|
12
|
+
export * from "./compression";
|
|
13
|
+
export * from "./operators";
|
|
14
|
+
export * from "./cursors";
|
|
15
|
+
export * from "./client";
|
|
16
|
+
export { createGzipCompression } from "./plugins/GzipCompression";
|
|
17
|
+
/**
|
|
18
|
+
* We must accept either Elasticsearch client or options that create the client.
|
|
19
|
+
*/
|
|
20
|
+
declare const _default: (params: ElasticsearchClientOptions | Client) => ContextPlugin<ElasticsearchContext>;
|
|
21
|
+
export default _default;
|
package/index.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {
|
|
9
|
+
createGzipCompression: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "createGzipCompression", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _GzipCompression.createGzipCompression;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
exports.default = void 0;
|
|
18
|
+
|
|
19
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
20
|
+
|
|
21
|
+
var _api = require("@webiny/api");
|
|
22
|
+
|
|
23
|
+
var _client = require("./client");
|
|
24
|
+
|
|
25
|
+
Object.keys(_client).forEach(function (key) {
|
|
26
|
+
if (key === "default" || key === "__esModule") return;
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
+
if (key in exports && exports[key] === _client[key]) return;
|
|
29
|
+
Object.defineProperty(exports, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return _client[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
var _operators = require("./operators");
|
|
38
|
+
|
|
39
|
+
Object.keys(_operators).forEach(function (key) {
|
|
40
|
+
if (key === "default" || key === "__esModule") return;
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
42
|
+
if (key in exports && exports[key] === _operators[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _operators[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var _elasticsearch = require("@elastic/elasticsearch");
|
|
52
|
+
|
|
53
|
+
var _indexConfiguration = require("./indexConfiguration");
|
|
54
|
+
|
|
55
|
+
Object.keys(_indexConfiguration).forEach(function (key) {
|
|
56
|
+
if (key === "default" || key === "__esModule") return;
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
58
|
+
if (key in exports && exports[key] === _indexConfiguration[key]) return;
|
|
59
|
+
Object.defineProperty(exports, key, {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () {
|
|
62
|
+
return _indexConfiguration[key];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
var _plugins = require("./plugins");
|
|
68
|
+
|
|
69
|
+
Object.keys(_plugins).forEach(function (key) {
|
|
70
|
+
if (key === "default" || key === "__esModule") return;
|
|
71
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
72
|
+
if (key in exports && exports[key] === _plugins[key]) return;
|
|
73
|
+
Object.defineProperty(exports, key, {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return _plugins[key];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
var _sort = require("./sort");
|
|
82
|
+
|
|
83
|
+
Object.keys(_sort).forEach(function (key) {
|
|
84
|
+
if (key === "default" || key === "__esModule") return;
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
86
|
+
if (key in exports && exports[key] === _sort[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _sort[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
var _indices = require("./indices");
|
|
96
|
+
|
|
97
|
+
Object.keys(_indices).forEach(function (key) {
|
|
98
|
+
if (key === "default" || key === "__esModule") return;
|
|
99
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
100
|
+
if (key in exports && exports[key] === _indices[key]) return;
|
|
101
|
+
Object.defineProperty(exports, key, {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return _indices[key];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
var _where = require("./where");
|
|
110
|
+
|
|
111
|
+
Object.keys(_where).forEach(function (key) {
|
|
112
|
+
if (key === "default" || key === "__esModule") return;
|
|
113
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
114
|
+
if (key in exports && exports[key] === _where[key]) return;
|
|
115
|
+
Object.defineProperty(exports, key, {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return _where[key];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
var _limit = require("./limit");
|
|
124
|
+
|
|
125
|
+
Object.keys(_limit).forEach(function (key) {
|
|
126
|
+
if (key === "default" || key === "__esModule") return;
|
|
127
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
128
|
+
if (key in exports && exports[key] === _limit[key]) return;
|
|
129
|
+
Object.defineProperty(exports, key, {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () {
|
|
132
|
+
return _limit[key];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
var _normalize = require("./normalize");
|
|
138
|
+
|
|
139
|
+
Object.keys(_normalize).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
142
|
+
if (key in exports && exports[key] === _normalize[key]) return;
|
|
143
|
+
Object.defineProperty(exports, key, {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function () {
|
|
146
|
+
return _normalize[key];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
var _compression = require("./compression");
|
|
152
|
+
|
|
153
|
+
Object.keys(_compression).forEach(function (key) {
|
|
154
|
+
if (key === "default" || key === "__esModule") return;
|
|
155
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
156
|
+
if (key in exports && exports[key] === _compression[key]) return;
|
|
157
|
+
Object.defineProperty(exports, key, {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function () {
|
|
160
|
+
return _compression[key];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
var _cursors = require("./cursors");
|
|
166
|
+
|
|
167
|
+
Object.keys(_cursors).forEach(function (key) {
|
|
168
|
+
if (key === "default" || key === "__esModule") return;
|
|
169
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
170
|
+
if (key in exports && exports[key] === _cursors[key]) return;
|
|
171
|
+
Object.defineProperty(exports, key, {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
get: function () {
|
|
174
|
+
return _cursors[key];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
var _GzipCompression = require("./plugins/GzipCompression");
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* TODO File should contain only exports from other files.
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* We must accept either Elasticsearch client or options that create the client.
|
|
187
|
+
*/
|
|
188
|
+
var _default = params => {
|
|
189
|
+
return new _api.ContextPlugin(context => {
|
|
190
|
+
if (context.elasticsearch) {
|
|
191
|
+
throw new _error.default("Elasticsearch client is already initialized, no need to define it again. Check your code for duplicate initializations.", "ELASTICSEARCH_ALREADY_INITIALIZED");
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Initialize the Elasticsearch client.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
context.elasticsearch = params instanceof _elasticsearch.Client ? params : (0, _client.createElasticsearchClient)(params);
|
|
199
|
+
context.plugins.register((0, _operators.getElasticsearchOperators)());
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
exports.default = _default;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["params","ContextPlugin","context","elasticsearch","WebinyError","Client","createElasticsearchClient","plugins","register","getElasticsearchOperators"],"sources":["index.ts"],"sourcesContent":["/**\n * TODO File should contain only exports from other files.\n */\nimport WebinyError from \"@webiny/error\";\nimport { ElasticsearchContext } from \"~/types\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { createElasticsearchClient, ElasticsearchClientOptions } from \"~/client\";\nimport { getElasticsearchOperators } from \"~/operators\";\nimport { Client } from \"@elastic/elasticsearch\";\n\nexport * from \"./indexConfiguration\";\nexport * from \"./plugins\";\nexport * from \"./sort\";\nexport * from \"./indices\";\nexport * from \"./where\";\nexport * from \"./limit\";\nexport * from \"./normalize\";\nexport * from \"./compression\";\nexport * from \"./operators\";\nexport * from \"./cursors\";\nexport * from \"./client\";\nexport { createGzipCompression } from \"./plugins/GzipCompression\";\n\n/**\n * We must accept either Elasticsearch client or options that create the client.\n */\nexport default (\n params: ElasticsearchClientOptions | Client\n): ContextPlugin<ElasticsearchContext> => {\n return new ContextPlugin<ElasticsearchContext>(context => {\n if (context.elasticsearch) {\n throw new WebinyError(\n \"Elasticsearch client is already initialized, no need to define it again. Check your code for duplicate initializations.\",\n \"ELASTICSEARCH_ALREADY_INITIALIZED\"\n );\n }\n /**\n * Initialize the Elasticsearch client.\n */\n context.elasticsearch =\n params instanceof Client ? params : createElasticsearchClient(params);\n\n context.plugins.register(getElasticsearchOperators());\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAGA;;AAEA;;AACA;;AAcA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAbA;;AAWA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAVA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AArBA;AACA;AACA;;AAqBA;AACA;AACA;eAEIA,MADW,IAE2B;EACtC,OAAO,IAAIC,kBAAJ,CAAwCC,OAAO,IAAI;IACtD,IAAIA,OAAO,CAACC,aAAZ,EAA2B;MACvB,MAAM,IAAIC,cAAJ,CACF,yHADE,EAEF,mCAFE,CAAN;IAIH;IACD;AACR;AACA;;;IACQF,OAAO,CAACC,aAAR,GACIH,MAAM,YAAYK,qBAAlB,GAA2BL,MAA3B,GAAoC,IAAAM,iCAAA,EAA0BN,MAA1B,CADxC;IAGAE,OAAO,CAACK,OAAR,CAAgBC,QAAhB,CAAyB,IAAAC,oCAAA,GAAzB;EACH,CAdM,CAAP;AAeH,C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ElasticsearchIndexRequestBody } from "../types";
|
|
2
|
+
interface Modifier {
|
|
3
|
+
(config: ElasticsearchIndexRequestBody): ElasticsearchIndexRequestBody;
|
|
4
|
+
}
|
|
5
|
+
export declare const getBaseConfiguration: (modifier?: Modifier) => ElasticsearchIndexRequestBody;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBaseConfiguration = void 0;
|
|
7
|
+
|
|
8
|
+
var _common = require("./common");
|
|
9
|
+
|
|
10
|
+
const config = {
|
|
11
|
+
mappings: {
|
|
12
|
+
dynamic_templates: (0, _common.getCommonMappings)(mappings => {
|
|
13
|
+
return mappings.concat([{
|
|
14
|
+
strings: {
|
|
15
|
+
match_mapping_type: "string",
|
|
16
|
+
mapping: {
|
|
17
|
+
type: "text",
|
|
18
|
+
fields: {
|
|
19
|
+
keyword: {
|
|
20
|
+
type: "keyword",
|
|
21
|
+
ignore_above: 256
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}]);
|
|
27
|
+
}),
|
|
28
|
+
properties: {
|
|
29
|
+
rawValues: {
|
|
30
|
+
type: "object",
|
|
31
|
+
enabled: false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const getBaseConfiguration = modifier => {
|
|
38
|
+
if (!modifier) {
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return modifier(config);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.getBaseConfiguration = getBaseConfiguration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["config","mappings","dynamic_templates","getCommonMappings","concat","strings","match_mapping_type","mapping","type","fields","keyword","ignore_above","properties","rawValues","enabled","getBaseConfiguration","modifier"],"sources":["base.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBody } from \"~/types\";\nimport { getCommonMappings } from \"./common\";\n\nconst config: ElasticsearchIndexRequestBody = {\n mappings: {\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n }\n }\n }\n }\n ]);\n }),\n properties: {\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n};\n\ninterface Modifier {\n (config: ElasticsearchIndexRequestBody): ElasticsearchIndexRequestBody;\n}\nexport const getBaseConfiguration = (modifier?: Modifier) => {\n if (!modifier) {\n return config;\n }\n return modifier(config);\n};\n"],"mappings":";;;;;;;AACA;;AAEA,MAAMA,MAAqC,GAAG;EAC1CC,QAAQ,EAAE;IACNC,iBAAiB,EAAE,IAAAC,yBAAA,EAAkBF,QAAQ,IAAI;MAC7C,OAAOA,QAAQ,CAACG,MAAT,CAAgB,CACnB;QACIC,OAAO,EAAE;UACLC,kBAAkB,EAAE,QADf;UAELC,OAAO,EAAE;YACLC,IAAI,EAAE,MADD;YAELC,MAAM,EAAE;cACJC,OAAO,EAAE;gBACLF,IAAI,EAAE,SADD;gBAELG,YAAY,EAAE;cAFT;YADL;UAFH;QAFJ;MADb,CADmB,CAAhB,CAAP;IAgBH,CAjBkB,CADb;IAmBNC,UAAU,EAAE;MACRC,SAAS,EAAE;QACPL,IAAI,EAAE,QADC;QAEPM,OAAO,EAAE;MAFF;IADH;EAnBN;AADgC,CAA9C;;AAgCO,MAAMC,oBAAoB,GAAIC,QAAD,IAAyB;EACzD,IAAI,CAACA,QAAL,EAAe;IACX,OAAOhB,MAAP;EACH;;EACD,OAAOgB,QAAQ,CAAChB,MAAD,CAAf;AACH,CALM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from "../types";
|
|
2
|
+
interface Modifier {
|
|
3
|
+
(mappings: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[]): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const getCommonMappings: (cb?: Modifier) => ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCommonMappings = void 0;
|
|
7
|
+
|
|
8
|
+
const getDefaultMappings = () => {
|
|
9
|
+
return [{
|
|
10
|
+
dates: {
|
|
11
|
+
match: "^createdOn|savedOn|publishedOn$",
|
|
12
|
+
mapping: {
|
|
13
|
+
type: "date"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}, {
|
|
17
|
+
numbers: {
|
|
18
|
+
match: "number@*",
|
|
19
|
+
mapping: {
|
|
20
|
+
type: "scaled_float",
|
|
21
|
+
scaling_factor: 10000
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
booleans: {
|
|
26
|
+
match: "boolean@*",
|
|
27
|
+
mapping: {
|
|
28
|
+
type: "boolean"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
const getCommonMappings = cb => {
|
|
38
|
+
if (!cb) {
|
|
39
|
+
return getDefaultMappings();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return cb(getDefaultMappings());
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.getCommonMappings = getCommonMappings;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getDefaultMappings","dates","match","mapping","type","numbers","scaling_factor","booleans","getCommonMappings","cb"],"sources":["common.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types\";\n\nconst getDefaultMappings = (): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[] => {\n return [\n {\n dates: {\n match: \"^createdOn|savedOn|publishedOn$\",\n mapping: {\n type: \"date\"\n }\n }\n },\n {\n numbers: {\n match: \"number@*\",\n mapping: {\n type: \"scaled_float\",\n scaling_factor: 10000\n }\n }\n },\n {\n booleans: {\n match: \"boolean@*\",\n mapping: {\n type: \"boolean\"\n }\n }\n }\n ];\n};\n\ninterface Modifier {\n (\n mappings: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[]\n ): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];\n}\n/**\n * @internal\n */\nexport const getCommonMappings = (\n cb?: Modifier\n): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[] => {\n if (!cb) {\n return getDefaultMappings();\n }\n\n return cb(getDefaultMappings());\n};\n"],"mappings":";;;;;;;AAEA,MAAMA,kBAAkB,GAAG,MAA8D;EACrF,OAAO,CACH;IACIC,KAAK,EAAE;MACHC,KAAK,EAAE,iCADJ;MAEHC,OAAO,EAAE;QACLC,IAAI,EAAE;MADD;IAFN;EADX,CADG,EASH;IACIC,OAAO,EAAE;MACLH,KAAK,EAAE,UADF;MAELC,OAAO,EAAE;QACLC,IAAI,EAAE,cADD;QAELE,cAAc,EAAE;MAFX;IAFJ;EADb,CATG,EAkBH;IACIC,QAAQ,EAAE;MACNL,KAAK,EAAE,WADD;MAENC,OAAO,EAAE;QACLC,IAAI,EAAE;MADD;IAFH;EADd,CAlBG,CAAP;AA2BH,CA5BD;;AAmCA;AACA;AACA;AACO,MAAMI,iBAAiB,GAC1BC,EAD6B,IAE4B;EACzD,IAAI,CAACA,EAAL,EAAS;IACL,OAAOT,kBAAkB,EAAzB;EACH;;EAED,OAAOS,EAAE,CAACT,kBAAkB,EAAnB,CAAT;AACH,CARM"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _base = require("./base");
|
|
8
|
+
|
|
9
|
+
Object.keys(_base).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _base[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _base[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _common = require("./common");
|
|
21
|
+
|
|
22
|
+
Object.keys(_common).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _common[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _common[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _japanese = require("./japanese");
|
|
34
|
+
|
|
35
|
+
Object.keys(_japanese).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _japanese[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _japanese[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./base\";\nexport * from \"./common\";\nexport * from \"./japanese\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|