@webiny/api-elasticsearch 6.0.0-beta.0 → 6.0.0-rc.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/README.md +10 -0
- package/client.d.ts +2 -2
- package/client.js +11 -31
- package/client.js.map +1 -1
- package/compression.d.ts +1 -1
- package/compression.js +13 -40
- package/compression.js.map +1 -1
- package/cursors.d.ts +2 -2
- package/cursors.js +5 -13
- package/cursors.js.map +1 -1
- package/db/entity.d.ts +7 -0
- package/db/entity.js +20 -0
- package/db/entity.js.map +1 -0
- package/db/index.d.ts +3 -0
- package/db/index.js +5 -0
- package/db/index.js.map +1 -0
- package/db/table.d.ts +7 -0
- package/db/table.js +17 -0
- package/db/table.js.map +1 -0
- package/db/types.d.ts +6 -0
- package/db/types.js +3 -0
- package/db/types.js.map +1 -0
- package/index.d.ts +18 -16
- package/index.js +27 -182
- package/index.js.map +1 -1
- package/indexConfiguration/base.d.ts +1 -1
- package/indexConfiguration/base.js +3 -10
- package/indexConfiguration/base.js.map +1 -1
- package/indexConfiguration/common.d.ts +1 -1
- package/indexConfiguration/common.js +12 -8
- package/indexConfiguration/common.js.map +1 -1
- package/indexConfiguration/index.d.ts +2 -3
- package/indexConfiguration/index.js +2 -38
- package/indexConfiguration/index.js.map +1 -1
- package/indexPrefix.d.ts +1 -0
- package/indexPrefix.js +5 -0
- package/indexPrefix.js.map +1 -0
- package/indices.d.ts +2 -3
- package/indices.js +6 -16
- package/indices.js.map +1 -1
- package/limit.js +1 -8
- package/limit.js.map +1 -1
- package/normalize.js +3 -11
- package/normalize.js.map +1 -1
- package/operations/ElasticsearchCatHealth.d.ts +2 -2
- package/operations/ElasticsearchCatHealth.js +6 -13
- package/operations/ElasticsearchCatHealth.js.map +1 -1
- package/operations/ElasticsearchCatNodes.d.ts +2 -2
- package/operations/ElasticsearchCatNodes.js +6 -13
- package/operations/ElasticsearchCatNodes.js.map +1 -1
- package/operations/index.d.ts +3 -3
- package/operations/index.js +3 -38
- package/operations/index.js.map +1 -1
- package/operations/stripConnectionFromException.js +1 -8
- package/operations/stripConnectionFromException.js.map +1 -1
- package/operations/types.d.ts +1 -1
- package/operations/types.js +1 -7
- package/operations/types.js.map +1 -1
- package/operators.d.ts +2 -5
- package/operators.js +3 -41
- package/operators.js.map +1 -1
- package/package.json +14 -18
- package/plugins/definition/ElasticsearchBodyModifierPlugin.d.ts +1 -1
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js +4 -12
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchFieldPlugin.d.ts +2 -2
- package/plugins/definition/ElasticsearchFieldPlugin.js +2 -9
- package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchIndexPlugin.d.ts +2 -10
- package/plugins/definition/ElasticsearchIndexPlugin.js +4 -23
- package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +1 -5
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +2 -17
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js +4 -12
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/definition/ElasticsearchSortModifierPlugin.js +4 -12
- package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/definition/index.d.ts +6 -7
- package/plugins/definition/index.js +6 -82
- package/plugins/definition/index.js.map +1 -1
- package/plugins/index.d.ts +2 -2
- package/plugins/index.js +2 -27
- package/plugins/index.js.map +1 -1
- package/plugins/operator/andIn.d.ts +2 -2
- package/plugins/operator/andIn.js +2 -9
- package/plugins/operator/andIn.js.map +1 -1
- package/plugins/operator/between.d.ts +2 -2
- package/plugins/operator/between.js +2 -9
- package/plugins/operator/between.js.map +1 -1
- package/plugins/operator/contains.d.ts +2 -2
- package/plugins/operator/contains.js +4 -11
- package/plugins/operator/contains.js.map +1 -1
- package/plugins/operator/equal.d.ts +2 -2
- package/plugins/operator/equal.js +3 -10
- package/plugins/operator/equal.js.map +1 -1
- package/plugins/operator/gt.d.ts +2 -2
- package/plugins/operator/gt.js +2 -9
- package/plugins/operator/gt.js.map +1 -1
- package/plugins/operator/gte.d.ts +2 -2
- package/plugins/operator/gte.js +2 -9
- package/plugins/operator/gte.js.map +1 -1
- package/plugins/operator/in.d.ts +2 -2
- package/plugins/operator/in.js +2 -9
- package/plugins/operator/in.js.map +1 -1
- package/plugins/operator/index.d.ts +15 -16
- package/plugins/operator/index.js +15 -181
- package/plugins/operator/index.js.map +1 -1
- package/plugins/operator/lt.d.ts +2 -2
- package/plugins/operator/lt.js +2 -9
- package/plugins/operator/lt.js.map +1 -1
- package/plugins/operator/lte.d.ts +2 -2
- package/plugins/operator/lte.js +2 -9
- package/plugins/operator/lte.js.map +1 -1
- package/plugins/operator/not.d.ts +2 -2
- package/plugins/operator/not.js +3 -10
- package/plugins/operator/not.js.map +1 -1
- package/plugins/operator/notBetween.d.ts +2 -2
- package/plugins/operator/notBetween.js +2 -9
- package/plugins/operator/notBetween.js.map +1 -1
- package/plugins/operator/notContains.d.ts +2 -2
- package/plugins/operator/notContains.js +4 -11
- package/plugins/operator/notContains.js.map +1 -1
- package/plugins/operator/notIn.d.ts +2 -2
- package/plugins/operator/notIn.js +2 -9
- package/plugins/operator/notIn.js.map +1 -1
- package/plugins/operator/notStartsWith.d.ts +2 -2
- package/plugins/operator/notStartsWith.js +2 -9
- package/plugins/operator/notStartsWith.js.map +1 -1
- package/plugins/operator/startsWith.d.ts +2 -2
- package/plugins/operator/startsWith.js +2 -9
- package/plugins/operator/startsWith.js.map +1 -1
- package/sharedIndex.d.ts +1 -0
- package/sharedIndex.js +5 -0
- package/sharedIndex.js.map +1 -0
- package/sort.d.ts +2 -2
- package/sort.js +18 -17
- package/sort.js.map +1 -1
- package/types.d.ts +32 -20
- package/types.js +28 -26
- package/types.js.map +1 -1
- package/utils/createIndex.d.ts +2 -3
- package/utils/createIndex.js +7 -19
- package/utils/createIndex.js.map +1 -1
- package/utils/index.d.ts +3 -3
- package/utils/index.js +3 -27
- package/utils/index.js.map +1 -1
- package/utils/waitUntilHealthy/UnhealthyClusterError.js +2 -9
- package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
- package/utils/waitUntilHealthy/WaitUntilHealthy.d.ts +4 -4
- package/utils/waitUntilHealthy/WaitUntilHealthy.js +22 -29
- package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +2 -9
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
- package/utils/waitUntilHealthy/index.d.ts +6 -6
- package/utils/waitUntilHealthy/index.js +6 -49
- package/utils/waitUntilHealthy/index.js.map +1 -1
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.d.ts +2 -2
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +2 -10
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/IReason.js +1 -5
- package/utils/waitUntilHealthy/reason/MemoryReason.d.ts +1 -1
- package/utils/waitUntilHealthy/reason/MemoryReason.js +2 -10
- package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/ProcessorReason.d.ts +1 -1
- package/utils/waitUntilHealthy/reason/ProcessorReason.js +2 -10
- package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/index.d.ts +3 -3
- package/utils/waitUntilHealthy/reason/index.js +3 -38
- package/utils/waitUntilHealthy/reason/index.js.map +1 -1
- package/where.d.ts +4 -4
- package/where.js +7 -16
- package/where.js.map +1 -1
- package/indexConfiguration/japanese.d.ts +0 -6
- package/indexConfiguration/japanese.js +0 -121
- package/indexConfiguration/japanese.js.map +0 -1
- package/plugins/GzipCompression.d.ts +0 -24
- package/plugins/GzipCompression.js +0 -70
- package/plugins/GzipCompression.js.map +0 -1
- package/plugins/definition/CompressionPlugin.d.ts +0 -20
- package/plugins/definition/CompressionPlugin.js +0 -28
- package/plugins/definition/CompressionPlugin.js.map +0 -1
- package/plugins/operator/japanese/contains.d.ts +0 -8
- package/plugins/operator/japanese/contains.js +0 -44
- package/plugins/operator/japanese/contains.js.map +0 -1
package/index.js
CHANGED
|
@@ -1,197 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
createGzipCompression: true
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "createGzipCompression", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _GzipCompression.createGzipCompression;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
exports.default = void 0;
|
|
17
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
18
|
-
var _api = require("@webiny/api");
|
|
19
|
-
var _client = require("./client");
|
|
20
|
-
Object.keys(_client).forEach(function (key) {
|
|
21
|
-
if (key === "default" || key === "__esModule") return;
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
-
if (key in exports && exports[key] === _client[key]) return;
|
|
24
|
-
Object.defineProperty(exports, key, {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _client[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
var _operators = require("./operators");
|
|
32
|
-
Object.keys(_operators).forEach(function (key) {
|
|
33
|
-
if (key === "default" || key === "__esModule") return;
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
-
if (key in exports && exports[key] === _operators[key]) return;
|
|
36
|
-
Object.defineProperty(exports, key, {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _operators[key];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
var _elasticsearch = require("@elastic/elasticsearch");
|
|
44
|
-
var _indexConfiguration = require("./indexConfiguration");
|
|
45
|
-
Object.keys(_indexConfiguration).forEach(function (key) {
|
|
46
|
-
if (key === "default" || key === "__esModule") return;
|
|
47
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
48
|
-
if (key in exports && exports[key] === _indexConfiguration[key]) return;
|
|
49
|
-
Object.defineProperty(exports, key, {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return _indexConfiguration[key];
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
var _plugins = require("./plugins");
|
|
57
|
-
Object.keys(_plugins).forEach(function (key) {
|
|
58
|
-
if (key === "default" || key === "__esModule") return;
|
|
59
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
60
|
-
if (key in exports && exports[key] === _plugins[key]) return;
|
|
61
|
-
Object.defineProperty(exports, key, {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: function () {
|
|
64
|
-
return _plugins[key];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
var _sort = require("./sort");
|
|
69
|
-
Object.keys(_sort).forEach(function (key) {
|
|
70
|
-
if (key === "default" || key === "__esModule") return;
|
|
71
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
72
|
-
if (key in exports && exports[key] === _sort[key]) return;
|
|
73
|
-
Object.defineProperty(exports, key, {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
get: function () {
|
|
76
|
-
return _sort[key];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
var _indices = require("./indices");
|
|
81
|
-
Object.keys(_indices).forEach(function (key) {
|
|
82
|
-
if (key === "default" || key === "__esModule") return;
|
|
83
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
84
|
-
if (key in exports && exports[key] === _indices[key]) return;
|
|
85
|
-
Object.defineProperty(exports, key, {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
get: function () {
|
|
88
|
-
return _indices[key];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
var _where = require("./where");
|
|
93
|
-
Object.keys(_where).forEach(function (key) {
|
|
94
|
-
if (key === "default" || key === "__esModule") return;
|
|
95
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
96
|
-
if (key in exports && exports[key] === _where[key]) return;
|
|
97
|
-
Object.defineProperty(exports, key, {
|
|
98
|
-
enumerable: true,
|
|
99
|
-
get: function () {
|
|
100
|
-
return _where[key];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
var _limit = require("./limit");
|
|
105
|
-
Object.keys(_limit).forEach(function (key) {
|
|
106
|
-
if (key === "default" || key === "__esModule") return;
|
|
107
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
108
|
-
if (key in exports && exports[key] === _limit[key]) return;
|
|
109
|
-
Object.defineProperty(exports, key, {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
get: function () {
|
|
112
|
-
return _limit[key];
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
var _normalize = require("./normalize");
|
|
117
|
-
Object.keys(_normalize).forEach(function (key) {
|
|
118
|
-
if (key === "default" || key === "__esModule") return;
|
|
119
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
120
|
-
if (key in exports && exports[key] === _normalize[key]) return;
|
|
121
|
-
Object.defineProperty(exports, key, {
|
|
122
|
-
enumerable: true,
|
|
123
|
-
get: function () {
|
|
124
|
-
return _normalize[key];
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
var _compression = require("./compression");
|
|
129
|
-
Object.keys(_compression).forEach(function (key) {
|
|
130
|
-
if (key === "default" || key === "__esModule") return;
|
|
131
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
132
|
-
if (key in exports && exports[key] === _compression[key]) return;
|
|
133
|
-
Object.defineProperty(exports, key, {
|
|
134
|
-
enumerable: true,
|
|
135
|
-
get: function () {
|
|
136
|
-
return _compression[key];
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
var _cursors = require("./cursors");
|
|
141
|
-
Object.keys(_cursors).forEach(function (key) {
|
|
142
|
-
if (key === "default" || key === "__esModule") return;
|
|
143
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
144
|
-
if (key in exports && exports[key] === _cursors[key]) return;
|
|
145
|
-
Object.defineProperty(exports, key, {
|
|
146
|
-
enumerable: true,
|
|
147
|
-
get: function () {
|
|
148
|
-
return _cursors[key];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
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
|
-
});
|
|
164
|
-
var _operations = require("./operations");
|
|
165
|
-
Object.keys(_operations).forEach(function (key) {
|
|
166
|
-
if (key === "default" || key === "__esModule") return;
|
|
167
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
168
|
-
if (key in exports && exports[key] === _operations[key]) return;
|
|
169
|
-
Object.defineProperty(exports, key, {
|
|
170
|
-
enumerable: true,
|
|
171
|
-
get: function () {
|
|
172
|
-
return _operations[key];
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
var _GzipCompression = require("./plugins/GzipCompression");
|
|
177
1
|
/**
|
|
178
2
|
* TODO File should contain only exports from other files.
|
|
179
3
|
*/
|
|
4
|
+
import WebinyError from "@webiny/error";
|
|
5
|
+
import { ContextPlugin } from "@webiny/api";
|
|
6
|
+
import { createElasticsearchClient } from "./client.js";
|
|
7
|
+
import { getElasticsearchOperators } from "./operators.js";
|
|
8
|
+
import { Client } from "@elastic/elasticsearch";
|
|
9
|
+
export * from "./indexConfiguration/index.js";
|
|
10
|
+
export * from "./plugins/index.js";
|
|
11
|
+
export * from "./sort.js";
|
|
12
|
+
export * from "./indices.js";
|
|
13
|
+
export * from "./where.js";
|
|
14
|
+
export * from "./limit.js";
|
|
15
|
+
export * from "./normalize.js";
|
|
16
|
+
export * from "./compression.js";
|
|
17
|
+
export * from "./operators.js";
|
|
18
|
+
export * from "./cursors.js";
|
|
19
|
+
export * from "./client.js";
|
|
20
|
+
export * from "./utils/index.js";
|
|
21
|
+
export * from "./operations/index.js";
|
|
22
|
+
export * from "./sharedIndex.js";
|
|
23
|
+
export * from "./indexPrefix.js";
|
|
24
|
+
export * from "./db/index.js";
|
|
25
|
+
|
|
180
26
|
/**
|
|
181
27
|
* We must accept either Elasticsearch client or options that create the client.
|
|
182
28
|
*/
|
|
183
|
-
|
|
184
|
-
return new
|
|
29
|
+
export default params => {
|
|
30
|
+
return new ContextPlugin(context => {
|
|
185
31
|
if (context.elasticsearch) {
|
|
186
|
-
throw new
|
|
32
|
+
throw new WebinyError("Elasticsearch client is already initialized, no need to define it again. Check your code for duplicate initializations.", "OPENSEARCH_ALREADY_INITIALIZED");
|
|
187
33
|
}
|
|
188
34
|
/**
|
|
189
35
|
* Initialize the Elasticsearch client.
|
|
190
36
|
*/
|
|
191
|
-
context.elasticsearch = params instanceof
|
|
192
|
-
context.plugins.register(
|
|
37
|
+
context.elasticsearch = params instanceof Client ? params : createElasticsearchClient(params);
|
|
38
|
+
context.plugins.register(getElasticsearchOperators());
|
|
193
39
|
});
|
|
194
40
|
};
|
|
195
|
-
exports.default = _default;
|
|
196
41
|
|
|
197
42
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","ContextPlugin","createElasticsearchClient","getElasticsearchOperators","Client","params","context","elasticsearch","plugins","register"],"sources":["index.ts"],"sourcesContent":["/**\n * TODO File should contain only exports from other files.\n */\nimport WebinyError from \"@webiny/error\";\nimport type { ElasticsearchContext } from \"~/types.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport type { ElasticsearchClientOptions } from \"~/client.js\";\nimport { createElasticsearchClient } from \"~/client.js\";\nimport { getElasticsearchOperators } from \"~/operators.js\";\nimport { Client } from \"@elastic/elasticsearch\";\n\nexport * from \"./indexConfiguration/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./sort.js\";\nexport * from \"./indices.js\";\nexport * from \"./where.js\";\nexport * from \"./limit.js\";\nexport * from \"./normalize.js\";\nexport * from \"./compression.js\";\nexport * from \"./operators.js\";\nexport * from \"./cursors.js\";\nexport * from \"./client.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./operations/index.js\";\nexport * from \"./sharedIndex.js\";\nexport * from \"./indexPrefix.js\";\nexport * from \"./db/index.js\";\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 \"OPENSEARCH_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":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,aAAa,QAAQ,aAAa;AAE3C,SAASC,yBAAyB;AAClC,SAASC,yBAAyB;AAClC,SAASC,MAAM,QAAQ,wBAAwB;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eACIC,MAA2C,IACL;EACtC,OAAO,IAAIJ,aAAa,CAAuBK,OAAO,IAAI;IACtD,IAAIA,OAAO,CAACC,aAAa,EAAE;MACvB,MAAM,IAAIP,WAAW,CACjB,yHAAyH,EACzH,gCACJ,CAAC;IACL;IACA;AACR;AACA;IACQM,OAAO,CAACC,aAAa,GACjBF,MAAM,YAAYD,MAAM,GAAGC,MAAM,GAAGH,yBAAyB,CAACG,MAAM,CAAC;IAEzEC,OAAO,CAACE,OAAO,CAACC,QAAQ,CAACN,yBAAyB,CAAC,CAAC,CAAC;EACzD,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBaseConfiguration = void 0;
|
|
7
|
-
var _common = require("./common");
|
|
1
|
+
import { getCommonMappings } from "./common.js";
|
|
8
2
|
const config = {
|
|
9
3
|
mappings: {
|
|
10
|
-
dynamic_templates:
|
|
4
|
+
dynamic_templates: getCommonMappings(mappings => {
|
|
11
5
|
return mappings.concat([{
|
|
12
6
|
strings: {
|
|
13
7
|
match_mapping_type: "string",
|
|
@@ -31,12 +25,11 @@ const config = {
|
|
|
31
25
|
}
|
|
32
26
|
}
|
|
33
27
|
};
|
|
34
|
-
const getBaseConfiguration = modifier => {
|
|
28
|
+
export const getBaseConfiguration = modifier => {
|
|
35
29
|
if (!modifier) {
|
|
36
30
|
return config;
|
|
37
31
|
}
|
|
38
32
|
return modifier(config);
|
|
39
33
|
};
|
|
40
|
-
exports.getBaseConfiguration = getBaseConfiguration;
|
|
41
34
|
|
|
42
35
|
//# sourceMappingURL=base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getCommonMappings","config","mappings","dynamic_templates","concat","strings","match_mapping_type","mapping","type","fields","keyword","ignore_above","properties","rawValues","enabled","getBaseConfiguration","modifier"],"sources":["base.ts"],"sourcesContent":["import type { ElasticsearchIndexRequestBody } from \"~/types.js\";\nimport { getCommonMappings } from \"./common.js\";\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,SAASA,iBAAiB;AAE1B,MAAMC,MAAqC,GAAG;EAC1CC,QAAQ,EAAE;IACNC,iBAAiB,EAAEH,iBAAiB,CAACE,QAAQ,IAAI;MAC7C,OAAOA,QAAQ,CAACE,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;AAKD,OAAO,MAAMC,oBAAoB,GAAIC,QAAmB,IAAK;EACzD,IAAI,CAACA,QAAQ,EAAE;IACX,OAAOf,MAAM;EACjB;EACA,OAAOe,QAAQ,CAACf,MAAM,CAAC;AAC3B,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from "../types";
|
|
1
|
+
import type { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from "../types.js";
|
|
2
2
|
interface Modifier {
|
|
3
3
|
(mappings: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[]): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];
|
|
4
4
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCommonMappings = void 0;
|
|
7
1
|
const getDefaultMappings = () => {
|
|
8
2
|
return [{
|
|
3
|
+
ids: {
|
|
4
|
+
match: "^id|entryId$",
|
|
5
|
+
mapping: {
|
|
6
|
+
type: "string",
|
|
7
|
+
keyword: true
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}, {
|
|
11
|
+
/**
|
|
12
|
+
* Update with the correct date fields.
|
|
13
|
+
*/
|
|
9
14
|
dates: {
|
|
10
15
|
match: "^createdOn|savedOn|publishedOn$",
|
|
11
16
|
mapping: {
|
|
@@ -32,12 +37,11 @@ const getDefaultMappings = () => {
|
|
|
32
37
|
/**
|
|
33
38
|
* @internal
|
|
34
39
|
*/
|
|
35
|
-
const getCommonMappings = cb => {
|
|
40
|
+
export const getCommonMappings = cb => {
|
|
36
41
|
if (!cb) {
|
|
37
42
|
return getDefaultMappings();
|
|
38
43
|
}
|
|
39
44
|
return cb(getDefaultMappings());
|
|
40
45
|
};
|
|
41
|
-
exports.getCommonMappings = getCommonMappings;
|
|
42
46
|
|
|
43
47
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getDefaultMappings","
|
|
1
|
+
{"version":3,"names":["getDefaultMappings","ids","match","mapping","type","keyword","dates","numbers","scaling_factor","booleans","getCommonMappings","cb"],"sources":["common.ts"],"sourcesContent":["import type { ElasticsearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types.js\";\n\nconst getDefaultMappings = (): ElasticsearchIndexRequestBodyMappingsDynamicTemplate[] => {\n return [\n {\n ids: {\n match: \"^id|entryId$\",\n mapping: {\n type: \"string\",\n keyword: true\n }\n }\n },\n {\n /**\n * Update with the correct date fields.\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,GAAG,EAAE;MACDC,KAAK,EAAE,cAAc;MACrBC,OAAO,EAAE;QACLC,IAAI,EAAE,QAAQ;QACdC,OAAO,EAAE;MACb;IACJ;EACJ,CAAC,EACD;IACI;AACZ;AACA;IACYC,KAAK,EAAE;MACHJ,KAAK,EAAE,iCAAiC;MACxCC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,EACD;IACIG,OAAO,EAAE;MACLL,KAAK,EAAE,UAAU;MACjBC,OAAO,EAAE;QACLC,IAAI,EAAE,cAAc;QACpBI,cAAc,EAAE;MACpB;IACJ;EACJ,CAAC,EACD;IACIC,QAAQ,EAAE;MACNP,KAAK,EAAE,WAAW;MAClBC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CACJ;AACL,CAAC;AAOD;AACA;AACA;AACA,OAAO,MAAMM,iBAAiB,GAC1BC,EAAa,IAC4C;EACzD,IAAI,CAACA,EAAE,EAAE;IACL,OAAOX,kBAAkB,CAAC,CAAC;EAC/B;EAEA,OAAOW,EAAE,CAACX,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from "./base";
|
|
2
|
-
export * from "./common";
|
|
3
|
-
export * from "./japanese";
|
|
1
|
+
export * from "./base.js";
|
|
2
|
+
export * from "./common.js";
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _base = require("./base");
|
|
7
|
-
Object.keys(_base).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _base[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _base[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _common = require("./common");
|
|
18
|
-
Object.keys(_common).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _common[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _common[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _japanese = require("./japanese");
|
|
29
|
-
Object.keys(_japanese).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _japanese[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _japanese[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
1
|
+
export * from "./base.js";
|
|
2
|
+
export * from "./common.js";
|
|
39
3
|
|
|
40
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./base.js\";\nexport * from \"./common.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
package/indexPrefix.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getElasticsearchIndexPrefix: () => string;
|
package/indexPrefix.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getElasticsearchIndexPrefix","process","env","OPENSEARCH_INDEX_PREFIX","WEBINY_OPENSEARCH_INDEX_PREFIX"],"sources":["indexPrefix.ts"],"sourcesContent":["export const getElasticsearchIndexPrefix = (): string => {\n return process.env.OPENSEARCH_INDEX_PREFIX || process.env.WEBINY_OPENSEARCH_INDEX_PREFIX || \"\";\n};\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAGA,CAAA,KAAc;EACrD,OAAOC,OAAO,CAACC,GAAG,CAACC,uBAAuB,IAAIF,OAAO,CAACC,GAAG,CAACE,8BAA8B,IAAI,EAAE;AAClG,CAAC","ignoreList":[]}
|
package/indices.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ElasticsearchIndexPlugin } from "./plugins/definition/ElasticsearchIndexPlugin";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
1
|
+
import type { ElasticsearchIndexPlugin } from "./plugins/definition/ElasticsearchIndexPlugin.js";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
3
|
interface IndicesPluginsParams {
|
|
4
4
|
container: PluginsContainer;
|
|
5
5
|
type: string;
|
|
6
|
-
locale: string;
|
|
7
6
|
}
|
|
8
7
|
export declare const getLastAddedIndexPlugin: <T extends ElasticsearchIndexPlugin>(params: IndicesPluginsParams) => T;
|
|
9
8
|
export {};
|
package/indices.js
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getLastAddedIndexPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
9
2
|
const listIndicesPlugins = ({
|
|
10
3
|
container,
|
|
11
|
-
type
|
|
12
|
-
locale
|
|
4
|
+
type
|
|
13
5
|
}) => {
|
|
14
6
|
return container.byType(type).filter(plugin => {
|
|
15
|
-
return plugin.canUse(
|
|
7
|
+
return plugin.canUse();
|
|
16
8
|
});
|
|
17
9
|
};
|
|
18
|
-
const getLastAddedIndexPlugin = params => {
|
|
10
|
+
export const getLastAddedIndexPlugin = params => {
|
|
19
11
|
const plugins = listIndicesPlugins(params);
|
|
20
12
|
if (plugins.length === 0) {
|
|
21
|
-
throw new
|
|
22
|
-
type: params.type
|
|
23
|
-
locale: params.locale
|
|
13
|
+
throw new WebinyError(`Could not find a single ElasticsearchIndexPlugin of type "${params.type}".`, "OPENSEARCH_INDEX_TEMPLATE_ERROR", {
|
|
14
|
+
type: params.type
|
|
24
15
|
});
|
|
25
16
|
}
|
|
26
17
|
return plugins.pop();
|
|
27
18
|
};
|
|
28
|
-
exports.getLastAddedIndexPlugin = getLastAddedIndexPlugin;
|
|
29
19
|
|
|
30
20
|
//# sourceMappingURL=indices.js.map
|
package/indices.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","listIndicesPlugins","container","type","byType","filter","plugin","canUse","getLastAddedIndexPlugin","params","plugins","length","pop"],"sources":["indices.ts"],"sourcesContent":["import type { ElasticsearchIndexPlugin } from \"~/plugins/definition/ElasticsearchIndexPlugin.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n}\nconst listIndicesPlugins = <T extends ElasticsearchIndexPlugin>({\n container,\n type\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse();\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 \"OPENSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"mappings":"AAEA,OAAOA,WAAW,MAAM,eAAe;AAMvC,MAAMC,kBAAkB,GAAGA,CAAqC;EAC5DC,SAAS;EACTC;AACkB,CAAC,KAAU;EAC7B,OAAOD,SAAS,CAACE,MAAM,CAAID,IAAI,CAAC,CAACE,MAAM,CAACC,MAAM,IAAI;IAC9C,OAAOA,MAAM,CAACC,MAAM,CAAC,CAAC;EAC1B,CAAC,CAAC;AACN,CAAC;AAED,OAAO,MAAMC,uBAAuB,GAChCC,MAA4B,IACxB;EACJ,MAAMC,OAAO,GAAGT,kBAAkB,CAAIQ,MAAM,CAAC;EAC7C,IAAIC,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIX,WAAW,CACjB,6DAA6DS,MAAM,CAACN,IAAI,IAAI,EAC5E,iCAAiC,EACjC;MACIA,IAAI,EAAEM,MAAM,CAACN;IACjB,CACJ,CAAC;EACL;EAEA,OAAOO,OAAO,CAACE,GAAG,CAAC,CAAC;AACxB,CAAC","ignoreList":[]}
|
package/limit.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createLimit = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* This is the max limit of the Elasticsearch.
|
|
9
3
|
* Change here if it changes (and if it is necessary).
|
|
@@ -13,7 +7,7 @@ const ES_LIMIT_MAX = 10000;
|
|
|
13
7
|
* Our system default limit.
|
|
14
8
|
*/
|
|
15
9
|
const ES_LIMIT_DEFAULT = 50;
|
|
16
|
-
const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
|
|
10
|
+
export const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
|
|
17
11
|
/**
|
|
18
12
|
* Limit can possibly be null/undefined or less than 1.
|
|
19
13
|
* In that case return the defaults.
|
|
@@ -34,6 +28,5 @@ const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
|
|
|
34
28
|
*/
|
|
35
29
|
return ES_LIMIT_MAX - 1;
|
|
36
30
|
};
|
|
37
|
-
exports.createLimit = createLimit;
|
|
38
31
|
|
|
39
32
|
//# sourceMappingURL=limit.js.map
|
package/limit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"
|
|
1
|
+
{"version":3,"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"sources":["limit.ts"],"sourcesContent":["/**\n * This is the max limit of the Elasticsearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the Elasticsearch one.\n * Elasticsearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,KAAK;AAC1B;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,EAAE;AAE3B,OAAO,MAAMC,WAAW,GAAGA,CAACC,KAAc,EAAEC,YAAY,GAAGH,gBAAgB,KAAa;EACpF;AACJ;AACA;AACA;EACI,IAAI,CAACE,KAAK,IAAIA,KAAK,GAAG,CAAC,EAAE;IACrB,OAAOC,YAAY;EACvB;EACA;AACJ;AACA;AACA;EACI,IAAID,KAAK,GAAGH,YAAY,EAAE;IACtB,OAAOG,KAAK;EAChB;EACA;AACJ;AACA;AACA;EACI,OAAOH,YAAY,GAAG,CAAC;AAC3B,CAAC","ignoreList":[]}
|
package/normalize.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.normalizeValueWithAsterisk = exports.normalizeValue = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* Before performing the query, we need to escape all special characters.
|
|
9
3
|
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
|
|
10
4
|
*/
|
|
11
5
|
|
|
12
6
|
const specialCharactersToRemove = [`\\?`];
|
|
13
|
-
const specialCharacterToSpace = ["-"];
|
|
7
|
+
const specialCharacterToSpace = ["-", "\\\\"];
|
|
14
8
|
const specialCharacters = ["\\\\", "\\+",
|
|
15
9
|
// "\\-",
|
|
16
10
|
"\\=", `\&`, `\\|`, ">", "<", `\!`, "\\(", "\\)", "\\{", "\\}", "\\[", "\\]", "\\^", '\\"', "\\~", "\\*", `\:`, `\/`, "\\#"];
|
|
17
|
-
const normalizeValue = value => {
|
|
11
|
+
export const normalizeValue = value => {
|
|
18
12
|
let result = value || "";
|
|
19
13
|
if (!result) {
|
|
20
14
|
return result;
|
|
@@ -30,14 +24,13 @@ const normalizeValue = value => {
|
|
|
30
24
|
}
|
|
31
25
|
return result || "";
|
|
32
26
|
};
|
|
33
|
-
exports.normalizeValue = normalizeValue;
|
|
34
27
|
const hasSpecialChar = value => {
|
|
35
28
|
if (!value) {
|
|
36
29
|
return null;
|
|
37
30
|
}
|
|
38
31
|
return value.match(/^([0-9a-zA-Z]+)$/i) === null;
|
|
39
32
|
};
|
|
40
|
-
const normalizeValueWithAsterisk = initial => {
|
|
33
|
+
export const normalizeValueWithAsterisk = initial => {
|
|
41
34
|
const value = normalizeValue(initial);
|
|
42
35
|
const results = value.split(" ");
|
|
43
36
|
let result = value;
|
|
@@ -57,6 +50,5 @@ const normalizeValueWithAsterisk = initial => {
|
|
|
57
50
|
}
|
|
58
51
|
return result;
|
|
59
52
|
};
|
|
60
|
-
exports.normalizeValueWithAsterisk = normalizeValueWithAsterisk;
|
|
61
53
|
|
|
62
54
|
//# sourceMappingURL=normalize.js.map
|
package/normalize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp","
|
|
1
|
+
{"version":3,"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp","hasSpecialChar","match","normalizeValueWithAsterisk","initial","results","split","firstWord","lastWord","length"],"sources":["normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\", \"\\\\\\\\\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `\\&`,\n `\\\\|`,\n \">\",\n \"<\",\n `\\!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `\\:`,\n `\\/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,MAAMA,yBAAyB,GAAG,CAAC,KAAK,CAAC;AAEzC,MAAMC,uBAAuB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;AAE7C,MAAMC,iBAAiB,GAAG,CACtB,MAAM,EACN,KAAK;AACL;AACA,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,CACR;AAED,OAAO,MAAMC,cAAc,GAAIC,KAAa,IAAK;EAC7C,IAAIC,MAAM,GAAGD,KAAK,IAAI,EAAE;EACxB,IAAI,CAACC,MAAM,EAAE;IACT,OAAOA,MAAM;EACjB;EACA,KAAK,MAAMC,SAAS,IAAIN,yBAAyB,EAAE;IAC/CK,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;EAC3D;EACA,KAAK,MAAMA,SAAS,IAAIL,uBAAuB,EAAE;IAC7CI,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC;EAC5D;EAEA,KAAK,MAAMA,SAAS,IAAIJ,iBAAiB,EAAE;IACvCG,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,KAAKA,SAAS,EAAE,CAAC;EACzE;EAEA,OAAOD,MAAM,IAAI,EAAE;AACvB,CAAC;AAED,MAAMI,cAAc,GAAIL,KAAa,IAAqB;EACtD,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,OAAOA,KAAK,CAACM,KAAK,CAAC,mBAAmB,CAAC,KAAK,IAAI;AACpD,CAAC;AAED,OAAO,MAAMC,0BAA0B,GAAIC,OAAe,IAAK;EAC3D,MAAMR,KAAK,GAAGD,cAAc,CAACS,OAAO,CAAC;EACrC,MAAMC,OAAO,GAAGT,KAAK,CAACU,KAAK,CAAC,GAAG,CAAC;EAEhC,IAAIT,MAAM,GAAGD,KAAK;EAClB;AACJ;AACA;EACI,MAAMW,SAAS,GAAGF,OAAO,CAAC,CAAC,CAAC;EAC5B,IAAIJ,cAAc,CAACM,SAAS,CAAC,KAAK,KAAK,EAAE;IACrCV,MAAM,GAAG,IAAIA,MAAM,EAAE;EACzB;EACA;AACJ;AACA;EACI,MAAMW,QAAQ,GAAGH,OAAO,CAACA,OAAO,CAACI,MAAM,GAAG,CAAC,CAAC;EAC5C,IAAIR,cAAc,CAACO,QAAQ,CAAC,KAAK,KAAK,EAAE;IACpCX,MAAM,GAAG,GAAGA,MAAM,GAAG;EACzB;EAEA,OAAOA,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Client } from "../client";
|
|
2
|
-
import { IElasticsearchCatHealthResponse } from "./types";
|
|
1
|
+
import type { Client } from "../client.js";
|
|
2
|
+
import type { IElasticsearchCatHealthResponse } from "./types.js";
|
|
3
3
|
export declare class ElasticsearchCatHealth {
|
|
4
4
|
private readonly client;
|
|
5
5
|
constructor(client: Client);
|