@webiny/api-elasticsearch 5.34.8 → 5.35.0-beta.1
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/client.js
CHANGED
|
@@ -1,43 +1,32 @@
|
|
|
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.createElasticsearchClient = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _elasticsearch = require("@elastic/elasticsearch");
|
|
15
|
-
|
|
16
11
|
var _awsSdk = _interopRequireDefault(require("aws-sdk"));
|
|
17
|
-
|
|
18
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
19
|
-
|
|
20
13
|
var _awsElasticsearchConnector = _interopRequireDefault(require("aws-elasticsearch-connector"));
|
|
21
|
-
|
|
22
14
|
const _excluded = ["endpoint", "node"];
|
|
23
|
-
|
|
24
15
|
const createElasticsearchClient = options => {
|
|
25
16
|
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
endpoint,
|
|
18
|
+
node
|
|
19
|
+
} = options,
|
|
20
|
+
rest = (0, _objectWithoutProperties2.default)(options, _excluded);
|
|
30
21
|
const clientOptions = (0, _objectSpread2.default)({
|
|
31
22
|
node: endpoint || node
|
|
32
23
|
}, rest);
|
|
33
|
-
|
|
34
24
|
if (!clientOptions.auth) {
|
|
35
25
|
/**
|
|
36
26
|
* If no `auth` configuration is present, we setup AWS connector.
|
|
37
27
|
*/
|
|
38
28
|
Object.assign(clientOptions, (0, _awsElasticsearchConnector.default)(_awsSdk.default.config));
|
|
39
29
|
}
|
|
40
|
-
|
|
41
30
|
try {
|
|
42
31
|
return new _elasticsearch.Client(clientOptions);
|
|
43
32
|
} catch (ex) {
|
|
@@ -51,5 +40,4 @@ const createElasticsearchClient = options => {
|
|
|
51
40
|
throw new _error.default("Could not connect to Elasticsearch.", "ELASTICSEARCH_CLIENT_ERROR", data);
|
|
52
41
|
}
|
|
53
42
|
};
|
|
54
|
-
|
|
55
43
|
exports.createElasticsearchClient = createElasticsearchClient;
|
package/client.js.map
CHANGED
|
@@ -1 +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":"
|
|
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;AAA0E;AAMnE,MAAMA,yBAAyB,GAAIC,OAAmC,IAAK;EAC9E,MAAM;MAAEC,QAAQ;MAAEC;IAAc,CAAC,GAAGF,OAAO;IAAhBG,IAAI,0CAAKH,OAAO;EAE3C,MAAMI,aAA4B;IAC9BF,IAAI,EAAED,QAAQ,IAAIC;EAAI,GACnBC,IAAI,CACV;EAED,IAAI,CAACC,aAAa,CAACC,IAAI,EAAE;IACrB;AACR;AACA;IACQC,MAAM,CAACC,MAAM,CAACH,aAAa,EAAE,IAAAI,kCAA+B,EAACC,eAAG,CAACC,MAAM,CAAC,CAAC;EAC7E;EAEA,IAAI;IACA,OAAO,IAAIC,qBAAM,CAACP,aAAa,CAAC;EACpC,CAAC,CAAC,OAAOQ,EAAE,EAAE;IACT,MAAMC,IAAI;MACNC,KAAK,EAAEF,EAAE;MACTV,IAAI,EAAED,QAAQ,IAAIC;IAAI,GACnBC,IAAI;MACPE,IAAI,EAAEU;IAAS,EAClB;IACDC,OAAO,CAACC,GAAG,iCACJJ,IAAI,EACT;IACF,MAAM,IAAIK,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BL,IAAI,CACP;EACL;AACJ,CAAC;AAAC"}
|
package/compression.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.decompress = exports.compress = void 0;
|
|
7
|
-
|
|
8
7
|
var _CompressionPlugin = require("./plugins/definition/CompressionPlugin");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Get the compression plugins, in reverse order, because we want to use the last one added - first.
|
|
12
10
|
*/
|
|
@@ -16,53 +14,38 @@ const getCompressionPlugins = plugins => {
|
|
|
16
14
|
/**
|
|
17
15
|
* Method to compress the elasticsearch data that is going to be stored into the DynamoDB table that is meant for elasticsearch.
|
|
18
16
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
17
|
const compress = async (pluginsContainer, data) => {
|
|
22
18
|
const plugins = getCompressionPlugins(pluginsContainer);
|
|
23
|
-
|
|
24
19
|
if (plugins.length === 0) {
|
|
25
20
|
console.log("No compression plugins");
|
|
26
21
|
return data;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
for (const plugin of plugins) {
|
|
30
24
|
if (plugin.canCompress(data) === false) {
|
|
31
25
|
continue;
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
return await plugin.compress(data);
|
|
35
28
|
}
|
|
36
29
|
/**
|
|
37
30
|
* Possibly no plugins that can compress, just return the data.
|
|
38
31
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
32
|
return data;
|
|
42
33
|
};
|
|
43
|
-
|
|
44
34
|
exports.compress = compress;
|
|
45
|
-
|
|
46
35
|
const decompress = async (pluginsContainer, data) => {
|
|
47
36
|
const plugins = getCompressionPlugins(pluginsContainer);
|
|
48
|
-
|
|
49
37
|
if (plugins.length === 0) {
|
|
50
38
|
return data;
|
|
51
39
|
}
|
|
52
|
-
|
|
53
40
|
for (const plugin of plugins) {
|
|
54
41
|
if (plugin.canDecompress(data) === false) {
|
|
55
42
|
continue;
|
|
56
43
|
}
|
|
57
|
-
|
|
58
44
|
return await plugin.decompress(data);
|
|
59
45
|
}
|
|
60
46
|
/**
|
|
61
47
|
* Possibly no plugins that can decompress, just return the data.
|
|
62
48
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
49
|
return data;
|
|
66
50
|
};
|
|
67
|
-
|
|
68
51
|
exports.decompress = decompress;
|
package/compression.js.map
CHANGED
|
@@ -1 +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":"
|
|
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,OAAyB,IAA0B;EAC9E,OAAOA,OAAO,CAACC,MAAM,CAAoBC,oCAAiB,CAACC,IAAI,CAAC,CAACC,OAAO,EAAE;AAC9E,CAAC;AACD;AACA;AACA;AACO,MAAMC,QAAQ,GAAG,OACpBC,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAgB,CAAC;EACvD,IAAIN,OAAO,CAACQ,MAAM,KAAK,CAAC,EAAE;IACtBC,OAAO,CAACC,GAAG,CAAC,wBAAwB,CAAC;IACrC,OAAOH,IAAI;EACf;EACA,KAAK,MAAMI,MAAM,IAAIX,OAAO,EAAE;IAC1B,IAAIW,MAAM,CAACC,WAAW,CAACL,IAAI,CAAC,KAAK,KAAK,EAAE;MACpC;IACJ;IACA,OAAO,MAAMI,MAAM,CAACN,QAAQ,CAACE,IAAI,CAAC;EACtC;EACA;AACJ;AACA;EACI,OAAOA,IAAI;AACf,CAAC;AAAC;AAEK,MAAMM,UAAU,GAAG,OACtBP,gBAAkC,EAClCC,IAAyB,KACM;EAC/B,MAAMP,OAAO,GAAGD,qBAAqB,CAACO,gBAAgB,CAAC;EACvD,IAAIN,OAAO,CAACQ,MAAM,KAAK,CAAC,EAAE;IACtB,OAAOD,IAAI;EACf;EACA,KAAK,MAAMI,MAAM,IAAIX,OAAO,EAAE;IAC1B,IAAIW,MAAM,CAACG,aAAa,CAACP,IAAI,CAAC,KAAK,KAAK,EAAE;MACtC;IACJ;IACA,OAAO,MAAMI,MAAM,CAACE,UAAU,CAACN,IAAI,CAAC;EACxC;EACA;AACJ;AACA;EACI,OAAOA,IAAI;AACf,CAAC;AAAC"}
|
package/cursors.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.encodeCursor = exports.decodeCursor = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Encode a received cursor value into something that can be passed on to the user.
|
|
10
9
|
*/
|
|
@@ -12,44 +11,33 @@ const encodeCursor = cursor => {
|
|
|
12
11
|
if (!cursor) {
|
|
13
12
|
return undefined;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
cursor = Array.isArray(cursor) ? cursor.map(encodeURIComponent) : encodeURIComponent(cursor);
|
|
17
|
-
|
|
18
15
|
try {
|
|
19
16
|
return Buffer.from(JSON.stringify(cursor)).toString("base64");
|
|
20
17
|
} catch (ex) {
|
|
21
18
|
console.error(ex.message);
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
return undefined;
|
|
25
21
|
};
|
|
26
22
|
/**
|
|
27
23
|
* Decode a received value into a Elasticsearch cursor.
|
|
28
24
|
* If no value is received or is not decodable, return undefined.
|
|
29
25
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
26
|
exports.encodeCursor = encodeCursor;
|
|
33
|
-
|
|
34
27
|
const decodeCursor = cursor => {
|
|
35
28
|
if (!cursor) {
|
|
36
29
|
return undefined;
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
try {
|
|
40
32
|
const value = JSON.parse(Buffer.from(cursor, "base64").toString("ascii"));
|
|
41
|
-
|
|
42
33
|
if (Array.isArray(value)) {
|
|
43
34
|
return value.map(decodeURIComponent);
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
const decoded = decodeURIComponent(value);
|
|
47
37
|
return decoded ? [decoded] : undefined;
|
|
48
38
|
} catch (ex) {
|
|
49
39
|
console.error(ex.message);
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
return undefined;
|
|
53
42
|
};
|
|
54
|
-
|
|
55
43
|
exports.decodeCursor = decodeCursor;
|
package/cursors.js.map
CHANGED
|
@@ -1 +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":"
|
|
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,MAAiC,IAAyB;EACnF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOC,SAAS;EACpB;EAEAD,MAAM,GAAGE,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,GAAGA,MAAM,CAACI,GAAG,CAACC,kBAAkB,CAAC,GAAGA,kBAAkB,CAACL,MAAM,CAAC;EAE5F,IAAI;IACA,OAAOM,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,SAAS,CAACT,MAAM,CAAC,CAAC,CAACU,QAAQ,CAAC,QAAQ,CAAC;EACjE,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOb,SAAS;AACpB,CAAC;AACD;AACA;AACA;AACA;AAHA;AAIO,MAAMc,YAAY,GAAIf,MAAsB,IAAmC;EAClF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOC,SAAS;EACpB;EACA,IAAI;IACA,MAAMe,KAAK,GAAGR,IAAI,CAACS,KAAK,CAACX,MAAM,CAACC,IAAI,CAACP,MAAM,EAAE,QAAQ,CAAC,CAACU,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzE,IAAIR,KAAK,CAACC,OAAO,CAACa,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACZ,GAAG,CAACc,kBAAkB,CAAC;IACxC;IACA,MAAMC,OAAO,GAAGD,kBAAkB,CAACF,KAAK,CAAC;IACzC,OAAOG,OAAO,GAAG,CAACA,OAAO,CAAC,GAAGlB,SAAS;EAC1C,CAAC,CAAC,OAAOU,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOb,SAAS;AACpB,CAAC;AAAC"}
|
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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
|
});
|
|
@@ -15,13 +14,9 @@ Object.defineProperty(exports, "createGzipCompression", {
|
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
16
|
exports.default = void 0;
|
|
18
|
-
|
|
19
17
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
20
|
-
|
|
21
18
|
var _api = require("@webiny/api");
|
|
22
|
-
|
|
23
19
|
var _client = require("./client");
|
|
24
|
-
|
|
25
20
|
Object.keys(_client).forEach(function (key) {
|
|
26
21
|
if (key === "default" || key === "__esModule") return;
|
|
27
22
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -33,9 +28,7 @@ Object.keys(_client).forEach(function (key) {
|
|
|
33
28
|
}
|
|
34
29
|
});
|
|
35
30
|
});
|
|
36
|
-
|
|
37
31
|
var _operators = require("./operators");
|
|
38
|
-
|
|
39
32
|
Object.keys(_operators).forEach(function (key) {
|
|
40
33
|
if (key === "default" || key === "__esModule") return;
|
|
41
34
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -47,11 +40,8 @@ Object.keys(_operators).forEach(function (key) {
|
|
|
47
40
|
}
|
|
48
41
|
});
|
|
49
42
|
});
|
|
50
|
-
|
|
51
43
|
var _elasticsearch = require("@elastic/elasticsearch");
|
|
52
|
-
|
|
53
44
|
var _indexConfiguration = require("./indexConfiguration");
|
|
54
|
-
|
|
55
45
|
Object.keys(_indexConfiguration).forEach(function (key) {
|
|
56
46
|
if (key === "default" || key === "__esModule") return;
|
|
57
47
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -63,9 +53,7 @@ Object.keys(_indexConfiguration).forEach(function (key) {
|
|
|
63
53
|
}
|
|
64
54
|
});
|
|
65
55
|
});
|
|
66
|
-
|
|
67
56
|
var _plugins = require("./plugins");
|
|
68
|
-
|
|
69
57
|
Object.keys(_plugins).forEach(function (key) {
|
|
70
58
|
if (key === "default" || key === "__esModule") return;
|
|
71
59
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -77,9 +65,7 @@ Object.keys(_plugins).forEach(function (key) {
|
|
|
77
65
|
}
|
|
78
66
|
});
|
|
79
67
|
});
|
|
80
|
-
|
|
81
68
|
var _sort = require("./sort");
|
|
82
|
-
|
|
83
69
|
Object.keys(_sort).forEach(function (key) {
|
|
84
70
|
if (key === "default" || key === "__esModule") return;
|
|
85
71
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -91,9 +77,7 @@ Object.keys(_sort).forEach(function (key) {
|
|
|
91
77
|
}
|
|
92
78
|
});
|
|
93
79
|
});
|
|
94
|
-
|
|
95
80
|
var _indices = require("./indices");
|
|
96
|
-
|
|
97
81
|
Object.keys(_indices).forEach(function (key) {
|
|
98
82
|
if (key === "default" || key === "__esModule") return;
|
|
99
83
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -105,9 +89,7 @@ Object.keys(_indices).forEach(function (key) {
|
|
|
105
89
|
}
|
|
106
90
|
});
|
|
107
91
|
});
|
|
108
|
-
|
|
109
92
|
var _where = require("./where");
|
|
110
|
-
|
|
111
93
|
Object.keys(_where).forEach(function (key) {
|
|
112
94
|
if (key === "default" || key === "__esModule") return;
|
|
113
95
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -119,9 +101,7 @@ Object.keys(_where).forEach(function (key) {
|
|
|
119
101
|
}
|
|
120
102
|
});
|
|
121
103
|
});
|
|
122
|
-
|
|
123
104
|
var _limit = require("./limit");
|
|
124
|
-
|
|
125
105
|
Object.keys(_limit).forEach(function (key) {
|
|
126
106
|
if (key === "default" || key === "__esModule") return;
|
|
127
107
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -133,9 +113,7 @@ Object.keys(_limit).forEach(function (key) {
|
|
|
133
113
|
}
|
|
134
114
|
});
|
|
135
115
|
});
|
|
136
|
-
|
|
137
116
|
var _normalize = require("./normalize");
|
|
138
|
-
|
|
139
117
|
Object.keys(_normalize).forEach(function (key) {
|
|
140
118
|
if (key === "default" || key === "__esModule") return;
|
|
141
119
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -147,9 +125,7 @@ Object.keys(_normalize).forEach(function (key) {
|
|
|
147
125
|
}
|
|
148
126
|
});
|
|
149
127
|
});
|
|
150
|
-
|
|
151
128
|
var _compression = require("./compression");
|
|
152
|
-
|
|
153
129
|
Object.keys(_compression).forEach(function (key) {
|
|
154
130
|
if (key === "default" || key === "__esModule") return;
|
|
155
131
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -161,9 +137,7 @@ Object.keys(_compression).forEach(function (key) {
|
|
|
161
137
|
}
|
|
162
138
|
});
|
|
163
139
|
});
|
|
164
|
-
|
|
165
140
|
var _cursors = require("./cursors");
|
|
166
|
-
|
|
167
141
|
Object.keys(_cursors).forEach(function (key) {
|
|
168
142
|
if (key === "default" || key === "__esModule") return;
|
|
169
143
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -175,13 +149,10 @@ Object.keys(_cursors).forEach(function (key) {
|
|
|
175
149
|
}
|
|
176
150
|
});
|
|
177
151
|
});
|
|
178
|
-
|
|
179
152
|
var _GzipCompression = require("./plugins/GzipCompression");
|
|
180
|
-
|
|
181
153
|
/**
|
|
182
154
|
* TODO File should contain only exports from other files.
|
|
183
155
|
*/
|
|
184
|
-
|
|
185
156
|
/**
|
|
186
157
|
* We must accept either Elasticsearch client or options that create the client.
|
|
187
158
|
*/
|
|
@@ -193,11 +164,8 @@ var _default = params => {
|
|
|
193
164
|
/**
|
|
194
165
|
* Initialize the Elasticsearch client.
|
|
195
166
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
167
|
context.elasticsearch = params instanceof _elasticsearch.Client ? params : (0, _client.createElasticsearchClient)(params);
|
|
199
168
|
context.plugins.register((0, _operators.getElasticsearchOperators)());
|
|
200
169
|
});
|
|
201
170
|
};
|
|
202
|
-
|
|
203
171
|
exports.default = _default;
|
package/index.js.map
CHANGED
|
@@ -1 +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":"
|
|
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;AAFA,eAIIA,MAA2C,IACL;EACtC,OAAO,IAAIC,kBAAa,CAAuBC,OAAO,IAAI;IACtD,IAAIA,OAAO,CAACC,aAAa,EAAE;MACvB,MAAM,IAAIC,cAAW,CACjB,yHAAyH,EACzH,mCAAmC,CACtC;IACL;IACA;AACR;AACA;IACQF,OAAO,CAACC,aAAa,GACjBH,MAAM,YAAYK,qBAAM,GAAGL,MAAM,GAAG,IAAAM,iCAAyB,EAACN,MAAM,CAAC;IAEzEE,OAAO,CAACK,OAAO,CAACC,QAAQ,CAAC,IAAAC,oCAAyB,GAAE,CAAC;EACzD,CAAC,CAAC;AACN,CAAC;AAAA"}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getBaseConfiguration = void 0;
|
|
7
|
-
|
|
8
7
|
var _common = require("./common");
|
|
9
|
-
|
|
10
8
|
const config = {
|
|
11
9
|
mappings: {
|
|
12
10
|
dynamic_templates: (0, _common.getCommonMappings)(mappings => {
|
|
@@ -33,13 +31,10 @@ const config = {
|
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
};
|
|
36
|
-
|
|
37
34
|
const getBaseConfiguration = modifier => {
|
|
38
35
|
if (!modifier) {
|
|
39
36
|
return config;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
return modifier(config);
|
|
43
39
|
};
|
|
44
|
-
|
|
45
40
|
exports.getBaseConfiguration = getBaseConfiguration;
|
|
@@ -1 +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":"
|
|
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,yBAAiB,EAACF,QAAQ,IAAI;MAC7C,OAAOA,QAAQ,CAACG,MAAM,CAAC,CACnB;QACIC,OAAO,EAAE;UACLC,kBAAkB,EAAE,QAAQ;UAC5BC,OAAO,EAAE;YACLC,IAAI,EAAE,MAAM;YACZC,MAAM,EAAE;cACJC,OAAO,EAAE;gBACLF,IAAI,EAAE,SAAS;gBACfG,YAAY,EAAE;cAClB;YACJ;UACJ;QACJ;MACJ,CAAC,CACJ,CAAC;IACN,CAAC,CAAC;IACFC,UAAU,EAAE;MACRC,SAAS,EAAE;QACPL,IAAI,EAAE,QAAQ;QACdM,OAAO,EAAE;MACb;IACJ;EACJ;AACJ,CAAC;AAKM,MAAMC,oBAAoB,GAAIC,QAAmB,IAAK;EACzD,IAAI,CAACA,QAAQ,EAAE;IACX,OAAOhB,MAAM;EACjB;EACA,OAAOgB,QAAQ,CAAChB,MAAM,CAAC;AAC3B,CAAC;AAAC"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getCommonMappings = void 0;
|
|
7
|
-
|
|
8
7
|
const getDefaultMappings = () => {
|
|
9
8
|
return [{
|
|
10
9
|
dates: {
|
|
@@ -30,7 +29,6 @@ const getDefaultMappings = () => {
|
|
|
30
29
|
}
|
|
31
30
|
}];
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
/**
|
|
35
33
|
* @internal
|
|
36
34
|
*/
|
|
@@ -38,8 +36,6 @@ const getCommonMappings = cb => {
|
|
|
38
36
|
if (!cb) {
|
|
39
37
|
return getDefaultMappings();
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
return cb(getDefaultMappings());
|
|
43
40
|
};
|
|
44
|
-
|
|
45
41
|
exports.getCommonMappings = getCommonMappings;
|
|
@@ -1 +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":"
|
|
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,iCAAiC;MACxCC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,EACD;IACIC,OAAO,EAAE;MACLH,KAAK,EAAE,UAAU;MACjBC,OAAO,EAAE;QACLC,IAAI,EAAE,cAAc;QACpBE,cAAc,EAAE;MACpB;IACJ;EACJ,CAAC,EACD;IACIC,QAAQ,EAAE;MACNL,KAAK,EAAE,WAAW;MAClBC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CACJ;AACL,CAAC;AAOD;AACA;AACA;AACO,MAAMI,iBAAiB,GAC1BC,EAAa,IAC4C;EACzD,IAAI,CAACA,EAAE,EAAE;IACL,OAAOT,kBAAkB,EAAE;EAC/B;EAEA,OAAOS,EAAE,CAACT,kBAAkB,EAAE,CAAC;AACnC,CAAC;AAAC"}
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _base = require("./base");
|
|
8
|
-
|
|
9
7
|
Object.keys(_base).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _base[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_base).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _common = require("./common");
|
|
21
|
-
|
|
22
18
|
Object.keys(_common).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _common[key]) return;
|
|
@@ -29,9 +25,7 @@ Object.keys(_common).forEach(function (key) {
|
|
|
29
25
|
}
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
var _japanese = require("./japanese");
|
|
34
|
-
|
|
35
29
|
Object.keys(_japanese).forEach(function (key) {
|
|
36
30
|
if (key === "default" || key === "__esModule") return;
|
|
37
31
|
if (key in exports && exports[key] === _japanese[key]) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./base\";\nexport * from \"./common\";\nexport * from \"./japanese\";\n"],"mappings":"
|
|
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"}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getJapaneseConfiguration = void 0;
|
|
7
|
-
|
|
8
7
|
var _common = require("./common");
|
|
9
|
-
|
|
10
8
|
const config = {
|
|
11
9
|
settings: {
|
|
12
10
|
index: {
|
|
@@ -112,13 +110,10 @@ const config = {
|
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
};
|
|
115
|
-
|
|
116
113
|
const getJapaneseConfiguration = modifier => {
|
|
117
114
|
if (!modifier) {
|
|
118
115
|
return config;
|
|
119
116
|
}
|
|
120
|
-
|
|
121
117
|
return modifier(config);
|
|
122
118
|
};
|
|
123
|
-
|
|
124
119
|
exports.getJapaneseConfiguration = getJapaneseConfiguration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["config","settings","index","analysis","char_filter","normalize","type","name","mode","tokenizer","ja_kuromoji_tokenizer","discard_compound_token","user_dictionary_rules","ja_ngram_tokenizer","min_gram","max_gram","token_chars","filter","ja_index_synonym","lenient","synonyms","ja_search_synonym","analyzer","ja_kuromoji_index_analyzer","ja_kuromoji_search_analyzer","ja_ngram_index_analyzer","ja_ngram_search_analyzer","default","default_search","mappings","numeric_detection","dynamic_templates","getCommonMappings","concat","strings","match_mapping_type","mapping","search_analyzer","fields","ngram","keyword","ignore_above","properties","rawValues","enabled","getJapaneseConfiguration","modifier"],"sources":["japanese.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBody } from \"~/types\";\nimport { getCommonMappings } from \"./common\";\n\nconst config: ElasticsearchIndexRequestBody = {\n settings: {\n index: {\n analysis: {\n char_filter: {\n normalize: {\n type: \"icu_normalizer\",\n name: \"nfkc\",\n mode: \"compose\"\n }\n },\n tokenizer: {\n ja_kuromoji_tokenizer: {\n mode: \"search\",\n type: \"kuromoji_tokenizer\",\n discard_compound_token: \"true\",\n user_dictionary_rules: [\n \"東京スカイツリー,東京 スカイツリー,トウキョウ スカイツリー,カスタム名詞\"\n ]\n },\n ja_ngram_tokenizer: {\n type: \"ngram\",\n min_gram: \"2\",\n max_gram: \"2\",\n token_chars: [\"letter\", \"digit\"]\n }\n },\n filter: {\n ja_index_synonym: {\n type: \"synonym\",\n lenient: \"false\",\n synonyms: []\n },\n ja_search_synonym: {\n type: \"synonym_graph\",\n lenient: \"false\",\n synonyms: [\"米国, アメリカ\", \"東京大学, 東大\"]\n }\n },\n analyzer: {\n ja_kuromoji_index_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_kuromoji_tokenizer\",\n filter: [\n \"kuromoji_baseform\",\n \"kuromoji_part_of_speech\",\n \"ja_index_synonym\",\n \"cjk_width\",\n \"ja_stop\",\n \"kuromoji_stemmer\",\n \"lowercase\"\n ]\n },\n ja_kuromoji_search_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_kuromoji_tokenizer\",\n filter: [\n \"kuromoji_baseform\",\n \"kuromoji_part_of_speech\",\n \"ja_search_synonym\",\n \"cjk_width\",\n \"ja_stop\",\n \"kuromoji_stemmer\",\n \"lowercase\"\n ]\n },\n ja_ngram_index_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_ngram_tokenizer\",\n filter: [\"lowercase\"]\n },\n ja_ngram_search_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_ngram_tokenizer\",\n filter: [\"ja_search_synonym\", \"lowercase\"]\n }\n },\n default: {\n type: \"ja_kuromoji_index_analyzer\"\n },\n default_search: {\n type: \"ja_kuromoji_search_analyzer\"\n }\n }\n }\n },\n mappings: {\n numeric_detection: true,\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n search_analyzer: \"ja_kuromoji_search_analyzer\",\n analyzer: \"ja_kuromoji_index_analyzer\",\n fields: {\n ngram: {\n type: \"text\",\n search_analyzer: \"ja_ngram_search_analyzer\",\n analyzer: \"ja_ngram_index_analyzer\"\n },\n keyword: {\n ignore_above: 256,\n type: \"keyword\"\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 getJapaneseConfiguration = (modifier?: Modifier) => {\n if (!modifier) {\n return config;\n }\n return modifier(config);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["config","settings","index","analysis","char_filter","normalize","type","name","mode","tokenizer","ja_kuromoji_tokenizer","discard_compound_token","user_dictionary_rules","ja_ngram_tokenizer","min_gram","max_gram","token_chars","filter","ja_index_synonym","lenient","synonyms","ja_search_synonym","analyzer","ja_kuromoji_index_analyzer","ja_kuromoji_search_analyzer","ja_ngram_index_analyzer","ja_ngram_search_analyzer","default","default_search","mappings","numeric_detection","dynamic_templates","getCommonMappings","concat","strings","match_mapping_type","mapping","search_analyzer","fields","ngram","keyword","ignore_above","properties","rawValues","enabled","getJapaneseConfiguration","modifier"],"sources":["japanese.ts"],"sourcesContent":["import { ElasticsearchIndexRequestBody } from \"~/types\";\nimport { getCommonMappings } from \"./common\";\n\nconst config: ElasticsearchIndexRequestBody = {\n settings: {\n index: {\n analysis: {\n char_filter: {\n normalize: {\n type: \"icu_normalizer\",\n name: \"nfkc\",\n mode: \"compose\"\n }\n },\n tokenizer: {\n ja_kuromoji_tokenizer: {\n mode: \"search\",\n type: \"kuromoji_tokenizer\",\n discard_compound_token: \"true\",\n user_dictionary_rules: [\n \"東京スカイツリー,東京 スカイツリー,トウキョウ スカイツリー,カスタム名詞\"\n ]\n },\n ja_ngram_tokenizer: {\n type: \"ngram\",\n min_gram: \"2\",\n max_gram: \"2\",\n token_chars: [\"letter\", \"digit\"]\n }\n },\n filter: {\n ja_index_synonym: {\n type: \"synonym\",\n lenient: \"false\",\n synonyms: []\n },\n ja_search_synonym: {\n type: \"synonym_graph\",\n lenient: \"false\",\n synonyms: [\"米国, アメリカ\", \"東京大学, 東大\"]\n }\n },\n analyzer: {\n ja_kuromoji_index_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_kuromoji_tokenizer\",\n filter: [\n \"kuromoji_baseform\",\n \"kuromoji_part_of_speech\",\n \"ja_index_synonym\",\n \"cjk_width\",\n \"ja_stop\",\n \"kuromoji_stemmer\",\n \"lowercase\"\n ]\n },\n ja_kuromoji_search_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_kuromoji_tokenizer\",\n filter: [\n \"kuromoji_baseform\",\n \"kuromoji_part_of_speech\",\n \"ja_search_synonym\",\n \"cjk_width\",\n \"ja_stop\",\n \"kuromoji_stemmer\",\n \"lowercase\"\n ]\n },\n ja_ngram_index_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_ngram_tokenizer\",\n filter: [\"lowercase\"]\n },\n ja_ngram_search_analyzer: {\n type: \"custom\",\n char_filter: [\"normalize\"],\n tokenizer: \"ja_ngram_tokenizer\",\n filter: [\"ja_search_synonym\", \"lowercase\"]\n }\n },\n default: {\n type: \"ja_kuromoji_index_analyzer\"\n },\n default_search: {\n type: \"ja_kuromoji_search_analyzer\"\n }\n }\n }\n },\n mappings: {\n numeric_detection: true,\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n search_analyzer: \"ja_kuromoji_search_analyzer\",\n analyzer: \"ja_kuromoji_index_analyzer\",\n fields: {\n ngram: {\n type: \"text\",\n search_analyzer: \"ja_ngram_search_analyzer\",\n analyzer: \"ja_ngram_index_analyzer\"\n },\n keyword: {\n ignore_above: 256,\n type: \"keyword\"\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 getJapaneseConfiguration = (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,KAAK,EAAE;MACHC,QAAQ,EAAE;QACNC,WAAW,EAAE;UACTC,SAAS,EAAE;YACPC,IAAI,EAAE,gBAAgB;YACtBC,IAAI,EAAE,MAAM;YACZC,IAAI,EAAE;UACV;QACJ,CAAC;QACDC,SAAS,EAAE;UACPC,qBAAqB,EAAE;YACnBF,IAAI,EAAE,QAAQ;YACdF,IAAI,EAAE,oBAAoB;YAC1BK,sBAAsB,EAAE,MAAM;YAC9BC,qBAAqB,EAAE,CACnB,wCAAwC;UAEhD,CAAC;UACDC,kBAAkB,EAAE;YAChBP,IAAI,EAAE,OAAO;YACbQ,QAAQ,EAAE,GAAG;YACbC,QAAQ,EAAE,GAAG;YACbC,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO;UACnC;QACJ,CAAC;QACDC,MAAM,EAAE;UACJC,gBAAgB,EAAE;YACdZ,IAAI,EAAE,SAAS;YACfa,OAAO,EAAE,OAAO;YAChBC,QAAQ,EAAE;UACd,CAAC;UACDC,iBAAiB,EAAE;YACff,IAAI,EAAE,eAAe;YACrBa,OAAO,EAAE,OAAO;YAChBC,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU;UACrC;QACJ,CAAC;QACDE,QAAQ,EAAE;UACNC,0BAA0B,EAAE;YACxBjB,IAAI,EAAE,QAAQ;YACdF,WAAW,EAAE,CAAC,WAAW,CAAC;YAC1BK,SAAS,EAAE,uBAAuB;YAClCQ,MAAM,EAAE,CACJ,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,WAAW;UAEnB,CAAC;UACDO,2BAA2B,EAAE;YACzBlB,IAAI,EAAE,QAAQ;YACdF,WAAW,EAAE,CAAC,WAAW,CAAC;YAC1BK,SAAS,EAAE,uBAAuB;YAClCQ,MAAM,EAAE,CACJ,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,WAAW;UAEnB,CAAC;UACDQ,uBAAuB,EAAE;YACrBnB,IAAI,EAAE,QAAQ;YACdF,WAAW,EAAE,CAAC,WAAW,CAAC;YAC1BK,SAAS,EAAE,oBAAoB;YAC/BQ,MAAM,EAAE,CAAC,WAAW;UACxB,CAAC;UACDS,wBAAwB,EAAE;YACtBpB,IAAI,EAAE,QAAQ;YACdF,WAAW,EAAE,CAAC,WAAW,CAAC;YAC1BK,SAAS,EAAE,oBAAoB;YAC/BQ,MAAM,EAAE,CAAC,mBAAmB,EAAE,WAAW;UAC7C;QACJ,CAAC;QACDU,OAAO,EAAE;UACLrB,IAAI,EAAE;QACV,CAAC;QACDsB,cAAc,EAAE;UACZtB,IAAI,EAAE;QACV;MACJ;IACJ;EACJ,CAAC;EACDuB,QAAQ,EAAE;IACNC,iBAAiB,EAAE,IAAI;IACvBC,iBAAiB,EAAE,IAAAC,yBAAiB,EAACH,QAAQ,IAAI;MAC7C,OAAOA,QAAQ,CAACI,MAAM,CAAC,CACnB;QACIC,OAAO,EAAE;UACLC,kBAAkB,EAAE,QAAQ;UAC5BC,OAAO,EAAE;YACL9B,IAAI,EAAE,MAAM;YACZ+B,eAAe,EAAE,6BAA6B;YAC9Cf,QAAQ,EAAE,4BAA4B;YACtCgB,MAAM,EAAE;cACJC,KAAK,EAAE;gBACHjC,IAAI,EAAE,MAAM;gBACZ+B,eAAe,EAAE,0BAA0B;gBAC3Cf,QAAQ,EAAE;cACd,CAAC;cACDkB,OAAO,EAAE;gBACLC,YAAY,EAAE,GAAG;gBACjBnC,IAAI,EAAE;cACV;YACJ;UACJ;QACJ;MACJ,CAAC,CACJ,CAAC;IACN,CAAC,CAAC;IACFoC,UAAU,EAAE;MACRC,SAAS,EAAE;QACPrC,IAAI,EAAE,QAAQ;QACdsC,OAAO,EAAE;MACb;IACJ;EACJ;AACJ,CAAC;AAKM,MAAMC,wBAAwB,GAAIC,QAAmB,IAAK;EAC7D,IAAI,CAACA,QAAQ,EAAE;IACX,OAAO9C,MAAM;EACjB;EACA,OAAO8C,QAAQ,CAAC9C,MAAM,CAAC;AAC3B,CAAC;AAAC"}
|
package/indices.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
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.getLastAddedIndexPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
const listIndicesPlugins = ({
|
|
13
10
|
container,
|
|
14
11
|
type,
|
|
@@ -18,18 +15,14 @@ const listIndicesPlugins = ({
|
|
|
18
15
|
return plugin.canUse(locale);
|
|
19
16
|
});
|
|
20
17
|
};
|
|
21
|
-
|
|
22
18
|
const getLastAddedIndexPlugin = params => {
|
|
23
19
|
const plugins = listIndicesPlugins(params);
|
|
24
|
-
|
|
25
20
|
if (plugins.length === 0) {
|
|
26
21
|
throw new _error.default(`Could not find a single ElasticsearchIndexPlugin of type "${params.type}".`, "ELASTICSEARCH_INDEX_TEMPLATE_ERROR", {
|
|
27
22
|
type: params.type,
|
|
28
23
|
locale: params.locale
|
|
29
24
|
});
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
return plugins.pop();
|
|
33
27
|
};
|
|
34
|
-
|
|
35
28
|
exports.getLastAddedIndexPlugin = getLastAddedIndexPlugin;
|
package/indices.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["listIndicesPlugins","container","type","locale","byType","filter","plugin","canUse","getLastAddedIndexPlugin","params","plugins","length","WebinyError","pop"],"sources":["indices.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"~/plugins/definition/ElasticsearchIndexPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n locale: string;\n}\nconst listIndicesPlugins = <T extends ElasticsearchIndexPlugin>({\n container,\n type,\n locale\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse(locale);\n });\n};\n\nexport const getLastAddedIndexPlugin = <T extends ElasticsearchIndexPlugin>(\n params: IndicesPluginsParams\n): T => {\n const plugins = listIndicesPlugins<T>(params);\n if (plugins.length === 0) {\n throw new WebinyError(\n `Could not find a single ElasticsearchIndexPlugin of type \"${params.type}\".`,\n \"ELASTICSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type,\n locale: params.locale\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["listIndicesPlugins","container","type","locale","byType","filter","plugin","canUse","getLastAddedIndexPlugin","params","plugins","length","WebinyError","pop"],"sources":["indices.ts"],"sourcesContent":["import { ElasticsearchIndexPlugin } from \"~/plugins/definition/ElasticsearchIndexPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n locale: string;\n}\nconst listIndicesPlugins = <T extends ElasticsearchIndexPlugin>({\n container,\n type,\n locale\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse(locale);\n });\n};\n\nexport const getLastAddedIndexPlugin = <T extends ElasticsearchIndexPlugin>(\n params: IndicesPluginsParams\n): T => {\n const plugins = listIndicesPlugins<T>(params);\n if (plugins.length === 0) {\n throw new WebinyError(\n `Could not find a single ElasticsearchIndexPlugin of type \"${params.type}\".`,\n \"ELASTICSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type,\n locale: params.locale\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"mappings":";;;;;;;AAEA;AAOA,MAAMA,kBAAkB,GAAG,CAAqC;EAC5DC,SAAS;EACTC,IAAI;EACJC;AACkB,CAAC,KAAU;EAC7B,OAAOF,SAAS,CAACG,MAAM,CAAIF,IAAI,CAAC,CAACG,MAAM,CAACC,MAAM,IAAI;IAC9C,OAAOA,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EAChC,CAAC,CAAC;AACN,CAAC;AAEM,MAAMK,uBAAuB,GAChCC,MAA4B,IACxB;EACJ,MAAMC,OAAO,GAAGV,kBAAkB,CAAIS,MAAM,CAAC;EAC7C,IAAIC,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIC,cAAW,CAChB,6DAA4DH,MAAM,CAACP,IAAK,IAAG,EAC5E,oCAAoC,EACpC;MACIA,IAAI,EAAEO,MAAM,CAACP,IAAI;MACjBC,MAAM,EAAEM,MAAM,CAACN;IACnB,CAAC,CACJ;EACL;EAEA,OAAOO,OAAO,CAACG,GAAG,EAAE;AACxB,CAAC;AAAC"}
|