@webiny/api-elasticsearch 0.0.0-unstable.9e825fd5fb → 0.0.0-unstable.a9593f74dd
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.d.ts +1 -0
- package/client.js +79 -43
- package/client.js.map +1 -1
- package/compression.js +2 -18
- package/compression.js.map +1 -1
- package/cursors.js +2 -12
- package/cursors.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +14 -32
- package/index.js.map +1 -1
- package/indexConfiguration/base.js +2 -5
- package/indexConfiguration/base.js.map +1 -1
- package/indexConfiguration/common.js +2 -4
- package/indexConfiguration/common.js.map +1 -1
- package/indexConfiguration/index.js +3 -7
- package/indexConfiguration/index.js.map +1 -1
- package/indexConfiguration/japanese.js +2 -5
- package/indexConfiguration/japanese.js.map +1 -1
- package/indices.js +2 -7
- package/indices.js.map +1 -1
- package/limit.js +2 -8
- package/limit.js.map +1 -1
- package/normalize.d.ts +1 -0
- package/normalize.js +41 -9
- package/normalize.js.map +1 -1
- package/operators.js +2 -11
- package/operators.js.map +1 -1
- package/package.json +12 -20
- package/plugins/GzipCompression.d.ts +1 -1
- package/plugins/GzipCompression.js +2 -18
- package/plugins/GzipCompression.js.map +1 -1
- package/plugins/definition/CompressionPlugin.js +18 -7
- package/plugins/definition/CompressionPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js +2 -11
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/definition/ElasticsearchFieldPlugin.js +7 -36
- package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchIndexPlugin.js +5 -15
- package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +4 -9
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js +2 -11
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchSortModifierPlugin.js +2 -11
- package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/definition/index.js +3 -15
- package/plugins/definition/index.js.map +1 -1
- package/plugins/index.js +3 -5
- package/plugins/index.js.map +1 -1
- package/plugins/operator/andIn.js +5 -19
- package/plugins/operator/andIn.js.map +1 -1
- package/plugins/operator/between.js +5 -18
- package/plugins/operator/between.js.map +1 -1
- package/plugins/operator/contains.js +4 -16
- package/plugins/operator/contains.js.map +1 -1
- package/plugins/operator/equal.js +3 -20
- package/plugins/operator/equal.js.map +1 -1
- package/plugins/operator/gt.js +3 -14
- package/plugins/operator/gt.js.map +1 -1
- package/plugins/operator/gte.js +3 -14
- package/plugins/operator/gte.js.map +1 -1
- package/plugins/operator/in.js +5 -17
- package/plugins/operator/in.js.map +1 -1
- package/plugins/operator/index.js +3 -33
- package/plugins/operator/index.js.map +1 -1
- package/plugins/operator/japanese/contains.js +6 -20
- package/plugins/operator/japanese/contains.js.map +1 -1
- package/plugins/operator/lt.js +3 -14
- package/plugins/operator/lt.js.map +1 -1
- package/plugins/operator/lte.js +3 -14
- package/plugins/operator/lte.js.map +1 -1
- package/plugins/operator/not.js +3 -18
- package/plugins/operator/not.js.map +1 -1
- package/plugins/operator/notBetween.js +5 -18
- package/plugins/operator/notBetween.js.map +1 -1
- package/plugins/operator/notContains.js +4 -16
- package/plugins/operator/notContains.js.map +1 -1
- package/plugins/operator/notIn.js +3 -16
- package/plugins/operator/notIn.js.map +1 -1
- package/plugins/operator/notStartsWith.js +6 -14
- package/plugins/operator/notStartsWith.js.map +1 -1
- package/plugins/operator/startsWith.js +6 -14
- package/plugins/operator/startsWith.js.map +1 -1
- package/sort.js +2 -16
- package/sort.js.map +1 -1
- package/types.d.ts +1 -0
- package/types.js +3 -4
- package/types.js.map +1 -1
- package/utils/createIndex.d.ts +20 -0
- package/utils/createIndex.js +100 -0
- package/utils/createIndex.js.map +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +18 -0
- package/utils/index.js.map +1 -0
- package/where.js +8 -24
- package/where.js.map +1 -1
package/client.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { Client, ClientOptions } from "@elastic/elasticsearch";
|
|
|
2
2
|
export interface ElasticsearchClientOptions extends ClientOptions {
|
|
3
3
|
endpoint?: string;
|
|
4
4
|
}
|
|
5
|
+
export { Client, ClientOptions };
|
|
5
6
|
export declare const createElasticsearchClient: (options: ElasticsearchClientOptions) => Client;
|
package/client.js
CHANGED
|
@@ -1,55 +1,91 @@
|
|
|
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
|
});
|
|
7
|
+
Object.defineProperty(exports, "Client", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _elasticsearch.Client;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "ClientOptions", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _elasticsearch.ClientOptions;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
8
19
|
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
20
|
var _awsElasticsearchConnector = _interopRequireDefault(require("aws-elasticsearch-connector"));
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
22
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
23
|
+
var _elasticsearch = require("@elastic/elasticsearch");
|
|
24
|
+
const clients = new Map();
|
|
25
|
+
const createClientKey = options => {
|
|
26
|
+
const key = JSON.stringify(options);
|
|
27
|
+
const hash = _crypto.default.createHash("sha1");
|
|
28
|
+
hash.update(key);
|
|
29
|
+
return hash.digest("hex");
|
|
30
|
+
};
|
|
24
31
|
const createElasticsearchClient = options => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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);
|
|
32
|
+
const key = createClientKey(options);
|
|
33
|
+
const existing = clients.get(key);
|
|
34
|
+
if (existing) {
|
|
35
|
+
return existing;
|
|
52
36
|
}
|
|
37
|
+
const cached = () => {
|
|
38
|
+
const {
|
|
39
|
+
endpoint,
|
|
40
|
+
node,
|
|
41
|
+
...rest
|
|
42
|
+
} = options;
|
|
43
|
+
let clientOptions = {
|
|
44
|
+
node: endpoint || node,
|
|
45
|
+
...rest
|
|
46
|
+
};
|
|
47
|
+
if (!clientOptions.auth) {
|
|
48
|
+
const region = String(process.env.AWS_REGION);
|
|
49
|
+
const credentials = {
|
|
50
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
51
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
52
|
+
sessionToken: process.env.AWS_SESSION_TOKEN
|
|
53
|
+
};
|
|
54
|
+
const errors = Object.keys(credentials).filter(key => {
|
|
55
|
+
const value = credentials[key];
|
|
56
|
+
return !value;
|
|
57
|
+
});
|
|
58
|
+
if (errors.length > 0) {
|
|
59
|
+
throw new _error.default(`Missing keys values: ${errors.join(", ")}`, "MISSING_AWS_CREDENTIALS");
|
|
60
|
+
}
|
|
61
|
+
clientOptions = {
|
|
62
|
+
...clientOptions,
|
|
63
|
+
...(0, _awsElasticsearchConnector.default)({
|
|
64
|
+
region,
|
|
65
|
+
// @ts-expect-error
|
|
66
|
+
credentials
|
|
67
|
+
})
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
return new _elasticsearch.Client(clientOptions);
|
|
72
|
+
} catch (ex) {
|
|
73
|
+
const data = {
|
|
74
|
+
error: ex,
|
|
75
|
+
node: endpoint || node,
|
|
76
|
+
...rest,
|
|
77
|
+
auth: undefined
|
|
78
|
+
};
|
|
79
|
+
console.log({
|
|
80
|
+
...data
|
|
81
|
+
});
|
|
82
|
+
throw new _error.default("Could not connect to Elasticsearch.", "ELASTICSEARCH_CLIENT_ERROR", data);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const client = cached();
|
|
86
|
+
clients.set(key, client);
|
|
87
|
+
return client;
|
|
53
88
|
};
|
|
89
|
+
exports.createElasticsearchClient = createElasticsearchClient;
|
|
54
90
|
|
|
55
|
-
|
|
91
|
+
//# sourceMappingURL=client.js.map
|
package/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_awsElasticsearchConnector","_interopRequireDefault","require","_crypto","_error","_elasticsearch","clients","Map","createClientKey","options","key","JSON","stringify","hash","crypto","createHash","update","digest","createElasticsearchClient","existing","get","cached","endpoint","node","rest","clientOptions","auth","region","String","process","env","AWS_REGION","credentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","errors","Object","keys","filter","value","length","WebinyError","join","createAwsElasticsearchConnector","Client","ex","data","error","undefined","console","log","client","set","exports"],"sources":["client.ts"],"sourcesContent":["import createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\nimport crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client, ClientOptions } from \"@elastic/elasticsearch\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: ElasticsearchClientOptions) => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport { Client, ClientOptions };\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const cached = (): Client => {\n const { endpoint, node, ...rest } = options;\n\n let clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n const region = String(process.env.AWS_REGION);\n\n const credentials = {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n sessionToken: process.env.AWS_SESSION_TOKEN\n };\n\n const errors = Object.keys(credentials).filter(key => {\n const value = credentials[key as keyof typeof credentials];\n return !value;\n });\n if (errors.length > 0) {\n throw new WebinyError(\n `Missing keys values: ${errors.join(\", \")}`,\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n clientOptions = {\n ...clientOptions,\n ...createAwsElasticsearchConnector({\n region,\n // @ts-expect-error\n credentials\n })\n };\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\n const client = cached();\n\n clients.set(key, client);\n return client;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAMA,MAAMI,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEzC,MAAMC,eAAe,GAAIC,OAAmC,IAAK;EAC7D,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC;EACnC,MAAMI,IAAI,GAAGC,eAAM,CAACC,UAAU,CAAC,MAAM,CAAC;EACtCF,IAAI,CAACG,MAAM,CAACN,GAAG,CAAC;EAChB,OAAOG,IAAI,CAACI,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAIM,MAAMC,yBAAyB,GAAIT,OAAmC,IAAa;EACtF,MAAMC,GAAG,GAAGF,eAAe,CAACC,OAAO,CAAC;EACpC,MAAMU,QAAQ,GAAGb,OAAO,CAACc,GAAG,CAACV,GAAG,CAAC;EACjC,IAAIS,QAAQ,EAAE;IACV,OAAOA,QAAQ;EACnB;EAEA,MAAME,MAAM,GAAGA,CAAA,KAAc;IACz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MACP,CAAC,CAAC;MACF,MAAM,IAAIL,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BK,IACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMK,MAAM,GAAGlC,MAAM,CAAC,CAAC;EAEvBf,OAAO,CAACkD,GAAG,CAAC9C,GAAG,EAAE6C,MAAM,CAAC;EACxB,OAAOA,MAAM;AACjB,CAAC;AAACE,OAAA,CAAAvC,yBAAA,GAAAA,yBAAA"}
|
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,39 @@ 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
|
-
console.log("No compression plugins");
|
|
26
20
|
return data;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
for (const plugin of plugins) {
|
|
30
23
|
if (plugin.canCompress(data) === false) {
|
|
31
24
|
continue;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
return await plugin.compress(data);
|
|
35
27
|
}
|
|
36
28
|
/**
|
|
37
29
|
* Possibly no plugins that can compress, just return the data.
|
|
38
30
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
31
|
return data;
|
|
42
32
|
};
|
|
43
|
-
|
|
44
33
|
exports.compress = compress;
|
|
45
|
-
|
|
46
34
|
const decompress = async (pluginsContainer, data) => {
|
|
47
35
|
const plugins = getCompressionPlugins(pluginsContainer);
|
|
48
|
-
|
|
49
36
|
if (plugins.length === 0) {
|
|
50
37
|
return data;
|
|
51
38
|
}
|
|
52
|
-
|
|
53
39
|
for (const plugin of plugins) {
|
|
54
40
|
if (plugin.canDecompress(data) === false) {
|
|
55
41
|
continue;
|
|
56
42
|
}
|
|
57
|
-
|
|
58
43
|
return await plugin.decompress(data);
|
|
59
44
|
}
|
|
60
45
|
/**
|
|
61
46
|
* Possibly no plugins that can decompress, just return the data.
|
|
62
47
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
48
|
return data;
|
|
66
49
|
};
|
|
50
|
+
exports.decompress = decompress;
|
|
67
51
|
|
|
68
|
-
|
|
52
|
+
//# sourceMappingURL=compression.js.map
|
package/compression.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getCompressionPlugins","plugins","byType","CompressionPlugin","type","reverse","compress","pluginsContainer","data","length","
|
|
1
|
+
{"version":3,"names":["_CompressionPlugin","require","getCompressionPlugins","plugins","byType","CompressionPlugin","type","reverse","compress","pluginsContainer","data","length","plugin","canCompress","exports","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 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,IAAAA,kBAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAIC,OAAyB,IAA0B;EAC9E,OAAOA,OAAO,CAACC,MAAM,CAAoBC,oCAAiB,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;AAC9E,CAAC;AACD;AACA;AACA;AACO,MAAMC,QAAQ,GAAG,MAAAA,CACpBC,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,MAAME,MAAM,IAAIT,OAAO,EAAE;IAC1B,IAAIS,MAAM,CAACC,WAAW,CAACH,IAAI,CAAC,KAAK,KAAK,EAAE;MACpC;IACJ;IACA,OAAO,MAAME,MAAM,CAACJ,QAAQ,CAACE,IAAI,CAAC;EACtC;EACA;AACJ;AACA;EACI,OAAOA,IAAI;AACf,CAAC;AAACI,OAAA,CAAAN,QAAA,GAAAA,QAAA;AAEK,MAAMO,UAAU,GAAG,MAAAA,CACtBN,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,MAAME,MAAM,IAAIT,OAAO,EAAE;IAC1B,IAAIS,MAAM,CAACI,aAAa,CAACN,IAAI,CAAC,KAAK,KAAK,EAAE;MACtC;IACJ;IACA,OAAO,MAAME,MAAM,CAACG,UAAU,CAACL,IAAI,CAAC;EACxC;EACA;AACJ;AACA;EACI,OAAOA,IAAI;AACf,CAAC;AAACI,OAAA,CAAAC,UAAA,GAAAA,UAAA"}
|
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,35 @@ 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
|
};
|
|
43
|
+
exports.decodeCursor = decodeCursor;
|
|
54
44
|
|
|
55
|
-
|
|
45
|
+
//# sourceMappingURL=cursors.js.map
|
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","exports","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;AAHAc,OAAA,CAAAhB,YAAA,GAAAA,YAAA;AAIO,MAAMiB,YAAY,GAAIhB,MAAsB,IAAmC;EAClF,IAAI,CAACA,MAAM,EAAE;IACT,OAAOC,SAAS;EACpB;EACA,IAAI;IACA,MAAMgB,KAAK,GAAGT,IAAI,CAACU,KAAK,CAACZ,MAAM,CAACC,IAAI,CAACP,MAAM,EAAE,QAAQ,CAAC,CAACU,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzE,IAAIR,KAAK,CAACC,OAAO,CAACc,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACb,GAAG,CAACe,kBAAkB,CAAC;IACxC;IACA,MAAMC,OAAO,GAAGD,kBAAkB,CAACF,KAAK,CAAC;IACzC,OAAOG,OAAO,GAAG,CAACA,OAAO,CAAC,GAAGnB,SAAS;EAC1C,CAAC,CAAC,OAAOU,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;EAC7B;EACA,OAAOb,SAAS;AACpB,CAAC;AAACc,OAAA,CAAAC,YAAA,GAAAA,YAAA"}
|
package/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./compression";
|
|
|
13
13
|
export * from "./operators";
|
|
14
14
|
export * from "./cursors";
|
|
15
15
|
export * from "./client";
|
|
16
|
+
export * from "./utils";
|
|
16
17
|
export { createGzipCompression } from "./plugins/GzipCompression";
|
|
17
18
|
/**
|
|
18
19
|
* We must accept either Elasticsearch client or options that create the client.
|
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,22 @@ Object.keys(_cursors).forEach(function (key) {
|
|
|
175
149
|
}
|
|
176
150
|
});
|
|
177
151
|
});
|
|
178
|
-
|
|
152
|
+
var _utils = require("./utils");
|
|
153
|
+
Object.keys(_utils).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] === _utils[key]) return;
|
|
157
|
+
Object.defineProperty(exports, key, {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function () {
|
|
160
|
+
return _utils[key];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
179
164
|
var _GzipCompression = require("./plugins/GzipCompression");
|
|
180
|
-
|
|
181
165
|
/**
|
|
182
166
|
* TODO File should contain only exports from other files.
|
|
183
167
|
*/
|
|
184
|
-
|
|
185
168
|
/**
|
|
186
169
|
* We must accept either Elasticsearch client or options that create the client.
|
|
187
170
|
*/
|
|
@@ -193,11 +176,10 @@ var _default = params => {
|
|
|
193
176
|
/**
|
|
194
177
|
* Initialize the Elasticsearch client.
|
|
195
178
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
179
|
context.elasticsearch = params instanceof _elasticsearch.Client ? params : (0, _client.createElasticsearchClient)(params);
|
|
199
180
|
context.plugins.register((0, _operators.getElasticsearchOperators)());
|
|
200
181
|
});
|
|
201
182
|
};
|
|
183
|
+
exports.default = _default;
|
|
202
184
|
|
|
203
|
-
|
|
185
|
+
//# sourceMappingURL=index.js.map
|
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":["_error","_interopRequireDefault","require","_api","_client","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_operators","_elasticsearch","_indexConfiguration","_plugins","_sort","_indices","_where","_limit","_normalize","_compression","_cursors","_utils","_GzipCompression","_default","params","ContextPlugin","context","elasticsearch","WebinyError","Client","createElasticsearchClient","plugins","register","getElasticsearchOperators","default"],"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 * from \"./utils\";\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAcAG,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,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AsB,MAAA,EAAArB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAoB,MAAA,CAAApB,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAY,MAAA,CAAApB,GAAA;IAAA;EAAA;AAAA;AACA,IAAAqB,gBAAA,GAAA3B,OAAA;AAtBA;AACA;AACA;AAsBA;AACA;AACA;AAFA,IAAA4B,QAAA,GAIIC,MAA2C,IACL;EACtC,OAAO,IAAIC,kBAAa,CAAuBC,OAAO,IAAI;IACtD,IAAIA,OAAO,CAACC,aAAa,EAAE;MACvB,MAAM,IAAIC,cAAW,CACjB,yHAAyH,EACzH,mCACJ,CAAC;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,EAAC,CAAC,CAAC;EACzD,CAAC,CAAC;AACN,CAAC;AAAA3B,OAAA,CAAA4B,OAAA,GAAAX,QAAA"}
|
|
@@ -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,12 @@ 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
|
};
|
|
40
|
+
exports.getBaseConfiguration = getBaseConfiguration;
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -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":["_common","require","config","mappings","dynamic_templates","getCommonMappings","concat","strings","match_mapping_type","mapping","type","fields","keyword","ignore_above","properties","rawValues","enabled","getBaseConfiguration","modifier","exports"],"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,IAAAA,OAAA,GAAAC,OAAA;AAEA,MAAMC,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;AAACiB,OAAA,CAAAF,oBAAA,GAAAA,oBAAA"}
|
|
@@ -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,8 @@ const getCommonMappings = cb => {
|
|
|
38
36
|
if (!cb) {
|
|
39
37
|
return getDefaultMappings();
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
return cb(getDefaultMappings());
|
|
43
40
|
};
|
|
41
|
+
exports.getCommonMappings = getCommonMappings;
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -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","exports"],"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,GAAGA,CAAA,KAA8D;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,CAAC,CAAC;EAC/B;EAEA,OAAOS,EAAE,CAACT,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC;AAACU,OAAA,CAAAF,iBAAA,GAAAA,iBAAA"}
|
|
@@ -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;
|
|
@@ -41,4 +35,6 @@ Object.keys(_japanese).forEach(function (key) {
|
|
|
41
35
|
return _japanese[key];
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
|
-
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.js.map
|