@webiny/api-elasticsearch 6.0.0-beta.0 → 6.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
var _ElasticsearchCatHealth = require("../../operations/ElasticsearchCatHealth");
|
|
8
|
-
var _ElasticsearchCatNodes = require("../../operations/ElasticsearchCatNodes");
|
|
9
|
-
var _types = require("../../operations/types");
|
|
10
|
-
var _UnhealthyClusterError = require("./UnhealthyClusterError");
|
|
11
|
-
var _reason = require("./reason");
|
|
12
|
-
var _WaitingHealthyClusterAbortedError = require("./WaitingHealthyClusterAbortedError");
|
|
1
|
+
import { ElasticsearchCatHealth } from "../../operations/ElasticsearchCatHealth.js";
|
|
2
|
+
import { ElasticsearchCatNodes } from "../../operations/ElasticsearchCatNodes.js";
|
|
3
|
+
import { ElasticsearchCatClusterHealthStatus } from "../../operations/types.js";
|
|
4
|
+
import { UnhealthyClusterError } from "./UnhealthyClusterError.js";
|
|
5
|
+
import { createClusterHealthStatusReason, createMemoryReason, createProcessorReason } from "./reason/index.js";
|
|
6
|
+
import { WaitingHealthyClusterAbortedError } from "./WaitingHealthyClusterAbortedError.js";
|
|
13
7
|
const WAITING_TIME_STEP = 10;
|
|
14
8
|
class WaitUntilHealthy {
|
|
15
9
|
aborted = false;
|
|
16
10
|
constructor(client, options) {
|
|
17
11
|
this.client = client;
|
|
18
12
|
this.options = options;
|
|
19
|
-
this.catHealth = new
|
|
20
|
-
this.catNodes = new
|
|
13
|
+
this.catHealth = new ElasticsearchCatHealth(this.client);
|
|
14
|
+
this.catNodes = new ElasticsearchCatNodes(this.client);
|
|
21
15
|
}
|
|
22
16
|
abort() {
|
|
23
17
|
this.aborted = true;
|
|
@@ -28,7 +22,7 @@ class WaitUntilHealthy {
|
|
|
28
22
|
*/
|
|
29
23
|
async wait(options) {
|
|
30
24
|
if (this.aborted) {
|
|
31
|
-
throw new
|
|
25
|
+
throw new WaitingHealthyClusterAbortedError(`Waiting for the cluster to become healthy was aborted even before it started.`);
|
|
32
26
|
}
|
|
33
27
|
const startedAt = new Date();
|
|
34
28
|
const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);
|
|
@@ -46,7 +40,7 @@ class WaitUntilHealthy {
|
|
|
46
40
|
runs
|
|
47
41
|
});
|
|
48
42
|
}
|
|
49
|
-
throw new
|
|
43
|
+
throw new UnhealthyClusterError(this.options.maxWaitingTime);
|
|
50
44
|
} else if (options?.onUnhealthy) {
|
|
51
45
|
await options.onUnhealthy({
|
|
52
46
|
startedAt,
|
|
@@ -60,7 +54,7 @@ class WaitUntilHealthy {
|
|
|
60
54
|
* Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.
|
|
61
55
|
*/
|
|
62
56
|
if (this.aborted) {
|
|
63
|
-
throw new
|
|
57
|
+
throw new WaitingHealthyClusterAbortedError();
|
|
64
58
|
}
|
|
65
59
|
runs++;
|
|
66
60
|
await new Promise(resolve => {
|
|
@@ -79,32 +73,32 @@ class WaitUntilHealthy {
|
|
|
79
73
|
try {
|
|
80
74
|
health = await this.catHealth.getHealth();
|
|
81
75
|
} catch (ex) {
|
|
82
|
-
return
|
|
76
|
+
return createClusterHealthStatusReason({
|
|
83
77
|
description: ex.message,
|
|
84
78
|
minimum: this.options.minClusterHealthStatus,
|
|
85
|
-
current:
|
|
79
|
+
current: ElasticsearchCatClusterHealthStatus.Red
|
|
86
80
|
});
|
|
87
81
|
}
|
|
88
82
|
try {
|
|
89
83
|
nodes = await this.catNodes.getNodes();
|
|
90
84
|
} catch (ex) {
|
|
91
|
-
return
|
|
85
|
+
return createClusterHealthStatusReason({
|
|
92
86
|
description: ex.message,
|
|
93
87
|
minimum: this.options.minClusterHealthStatus,
|
|
94
|
-
current:
|
|
88
|
+
current: ElasticsearchCatClusterHealthStatus.Red
|
|
95
89
|
});
|
|
96
90
|
}
|
|
97
91
|
const clusterHealthStatus = this.transformClusterHealthStatus(health.status);
|
|
98
92
|
const minClusterHealthStatus = this.transformClusterHealthStatus(this.options.minClusterHealthStatus);
|
|
99
93
|
if (clusterHealthStatus > minClusterHealthStatus) {
|
|
100
|
-
return
|
|
94
|
+
return createClusterHealthStatusReason({
|
|
101
95
|
minimum: this.options.minClusterHealthStatus,
|
|
102
96
|
current: health.status
|
|
103
97
|
});
|
|
104
98
|
}
|
|
105
99
|
const processorPercent = this.getProcessorPercent(nodes);
|
|
106
100
|
if (processorPercent > this.options.maxProcessorPercent) {
|
|
107
|
-
return
|
|
101
|
+
return createProcessorReason({
|
|
108
102
|
maximum: this.options.maxProcessorPercent,
|
|
109
103
|
current: processorPercent
|
|
110
104
|
});
|
|
@@ -117,7 +111,7 @@ class WaitUntilHealthy {
|
|
|
117
111
|
}
|
|
118
112
|
const ramPercent = this.getRamPercent(nodes);
|
|
119
113
|
if (ramPercent > this.options.maxRamPercent) {
|
|
120
|
-
return
|
|
114
|
+
return createMemoryReason({
|
|
121
115
|
maximum: this.options.maxRamPercent,
|
|
122
116
|
current: ramPercent
|
|
123
117
|
});
|
|
@@ -138,20 +132,19 @@ class WaitUntilHealthy {
|
|
|
138
132
|
}
|
|
139
133
|
transformClusterHealthStatus(status) {
|
|
140
134
|
switch (status) {
|
|
141
|
-
case
|
|
135
|
+
case ElasticsearchCatClusterHealthStatus.Green:
|
|
142
136
|
return 1;
|
|
143
|
-
case
|
|
137
|
+
case ElasticsearchCatClusterHealthStatus.Yellow:
|
|
144
138
|
return 2;
|
|
145
|
-
case
|
|
139
|
+
case ElasticsearchCatClusterHealthStatus.Red:
|
|
146
140
|
return 3;
|
|
147
141
|
default:
|
|
148
142
|
return 99;
|
|
149
143
|
}
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
|
-
const createWaitUntilHealthy = (client, params) => {
|
|
146
|
+
export const createWaitUntilHealthy = (client, params) => {
|
|
153
147
|
return new WaitUntilHealthy(client, params);
|
|
154
148
|
};
|
|
155
|
-
exports.createWaitUntilHealthy = createWaitUntilHealthy;
|
|
156
149
|
|
|
157
150
|
//# sourceMappingURL=WaitUntilHealthy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ElasticsearchCatHealth","require","_ElasticsearchCatNodes","_types","_UnhealthyClusterError","_reason","_WaitingHealthyClusterAbortedError","WAITING_TIME_STEP","WaitUntilHealthy","aborted","constructor","client","options","catHealth","ElasticsearchCatHealth","catNodes","ElasticsearchCatNodes","abort","wait","WaitingHealthyClusterAbortedError","startedAt","Date","mustEndAt","getTime","maxWaitingTime","waitingTimeStep","runs","waitingReason","shouldWait","onTimeout","UnhealthyClusterError","onUnhealthy","Promise","resolve","setTimeout","runningTime","health","nodes","getHealth","ex","createClusterHealthStatusReason","description","message","minimum","minClusterHealthStatus","current","ElasticsearchCatClusterHealthStatus","Red","getNodes","clusterHealthStatus","transformClusterHealthStatus","status","processorPercent","getProcessorPercent","maxProcessorPercent","createProcessorReason","maximum","maxRamPercent","undefined","ramPercent","getRamPercent","createMemoryReason","total","reduce","node","parseFloat","cpu","length","Green","Yellow","createWaitUntilHealthy","params","exports"],"sources":["WaitUntilHealthy.ts"],"sourcesContent":["import { Client } from \"~/client\";\nimport { ElasticsearchCatHealth } from \"~/operations/ElasticsearchCatHealth\";\nimport { ElasticsearchCatNodes } from \"~/operations/ElasticsearchCatNodes\";\nimport {\n ElasticsearchCatClusterHealthStatus,\n IElasticsearchCatHealthResponse,\n IElasticsearchCatNodesResponse\n} from \"~/operations/types\";\nimport { UnhealthyClusterError } from \"~/utils/waitUntilHealthy/UnhealthyClusterError\";\nimport {\n ClusterHealthReason,\n createClusterHealthStatusReason,\n createMemoryReason,\n createProcessorReason,\n MemoryReason,\n ProcessorReason\n} from \"./reason\";\nimport { WaitingHealthyClusterAbortedError } from \"./WaitingHealthyClusterAbortedError\";\n\nconst WAITING_TIME_STEP = 10;\n\nexport type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;\n\nexport interface IWaitUntilHealthyParams {\n /**\n * Minimum status allowed, otherwise the cluster is considered unhealthy.\n */\n minClusterHealthStatus:\n | ElasticsearchCatClusterHealthStatus.Green\n | ElasticsearchCatClusterHealthStatus.Yellow;\n /**\n * Maximum processor percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxProcessorPercent: number;\n /**\n * Maximum RAM percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxRamPercent?: number;\n /**\n * Maximum time to wait in seconds.\n * This is to prevent infinite waiting in case the cluster never becomes healthy.\n */\n maxWaitingTime: number;\n /**\n * Time in seconds to wait between each check.\n * This is to prevent spamming the cluster with requests.\n * Default is WAITING_TIME_STEP seconds.\n */\n waitingTimeStep?: number;\n}\n\nexport interface IWaitOptionsOnUnhealthyParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptionsOnTimeoutParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptions {\n onUnhealthy?(params: IWaitOptionsOnUnhealthyParams): Promise<void>;\n onTimeout?(params: IWaitOptionsOnTimeoutParams): Promise<void>;\n}\n\nexport interface IWaitUntilHealthyWaitResponse {\n runningTime: number;\n runs: number;\n}\n\nclass WaitUntilHealthy {\n private readonly client: Client;\n private readonly options: IWaitUntilHealthyParams;\n\n private readonly catHealth: ElasticsearchCatHealth;\n private readonly catNodes: ElasticsearchCatNodes;\n\n private aborted = false;\n\n public constructor(client: Client, options: IWaitUntilHealthyParams) {\n this.client = client;\n this.options = options;\n\n this.catHealth = new ElasticsearchCatHealth(this.client);\n this.catNodes = new ElasticsearchCatNodes(this.client);\n }\n\n public abort(): void {\n this.aborted = true;\n }\n /**\n * @throws UnhealthyClusterError\n * @throws WaitingHealthyClusterAbortedError\n */\n public async wait(options?: IWaitOptions): Promise<IWaitUntilHealthyWaitResponse> {\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError(\n `Waiting for the cluster to become healthy was aborted even before it started.`\n );\n }\n const startedAt = new Date();\n const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);\n const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;\n let runs = 1;\n let waitingReason: WaitingReason | false;\n while ((waitingReason = await this.shouldWait())) {\n if (new Date() >= mustEndAt) {\n if (options?.onTimeout) {\n await options.onTimeout({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n throw new UnhealthyClusterError(this.options.maxWaitingTime);\n } else if (options?.onUnhealthy) {\n await options.onUnhealthy({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n /**\n * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.\n */\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError();\n }\n runs++;\n await new Promise(resolve => {\n setTimeout(resolve, waitingTimeStep * 1000);\n });\n }\n\n const runningTime = new Date().getTime() - startedAt.getTime();\n\n return {\n runningTime,\n runs\n };\n }\n\n private async shouldWait(): Promise<WaitingReason | false> {\n let health: IElasticsearchCatHealthResponse;\n let nodes: IElasticsearchCatNodesResponse;\n try {\n health = await this.catHealth.getHealth();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n try {\n nodes = await this.catNodes.getNodes();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n\n const clusterHealthStatus = this.transformClusterHealthStatus(health.status);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: health.status\n });\n }\n\n const processorPercent = this.getProcessorPercent(nodes);\n if (processorPercent > this.options.maxProcessorPercent) {\n return createProcessorReason({\n maximum: this.options.maxProcessorPercent,\n current: processorPercent\n });\n }\n /**\n * Possibly no max ram definition?\n */\n if (this.options.maxRamPercent === undefined) {\n return false;\n }\n\n const ramPercent = this.getRamPercent(nodes);\n if (ramPercent > this.options.maxRamPercent) {\n return createMemoryReason({\n maximum: this.options.maxRamPercent,\n current: ramPercent\n });\n }\n return false;\n }\n\n private getProcessorPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu);\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"]);\n }, 0);\n return total / nodes.length;\n }\n\n private transformClusterHealthStatus(status: ElasticsearchCatClusterHealthStatus): number {\n switch (status) {\n case ElasticsearchCatClusterHealthStatus.Green:\n return 1;\n case ElasticsearchCatClusterHealthStatus.Yellow:\n return 2;\n case ElasticsearchCatClusterHealthStatus.Red:\n return 3;\n default:\n return 99;\n }\n }\n}\n\nexport type { WaitUntilHealthy };\n\nexport const createWaitUntilHealthy = (\n client: Client,\n params: IWaitUntilHealthyParams\n): WaitUntilHealthy => {\n return new WaitUntilHealthy(client, params);\n};\n"],"mappings":";;;;;;AACA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OA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C0B,MAAM,CAAS,CAACD,KAAK,EAAEE,IAAI,KAAK;MAChD,OAAOF,KAAK,GAAGG,UAAU,CAACD,IAAI,CAACE,GAAG,CAAC;IACvC,CAAC,EAAE,CAAC,CAAC;IACL,OAAOJ,KAAK,GAAGzB,KAAK,CAAC8B,MAAM;EAC/B;EAEQP,aAAaA,CAACvB,KAAqC,EAAU;IACjE,MAAMyB,KAAK,GAAGzB,KAAK,CAAC0B,MAAM,CAAS,CAACD,KAAK,EAAEE,IAAI,KAAK;MAChD,OAAOF,KAAK,GAAGG,UAAU,CAACD,IAAI,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,CAAC;IACL,OAAOF,KAAK,GAAGzB,KAAK,CAAC8B,MAAM;EAC/B;EAEQjB,4BAA4BA,CAACC,MAA2C,EAAU;IACtF,QAAQA,MAAM;MACV,KAAKL,0CAAmC,CAACsB,KAAK;QAC1C,OAAO,CAAC;MACZ,KAAKtB,0CAAmC,CAACuB,MAAM;QAC3C,OAAO,CAAC;MACZ,KAAKvB,0CAAmC,CAACC,GAAG;QACxC,OAAO,CAAC;MACZ;QACI,OAAO,EAAE;IACjB;EACJ;AACJ;AAIO,MAAMuB,sBAAsB,GAAGA,CAClC3D,MAAc,EACd4D,MAA+B,KACZ;EACnB,OAAO,IAAI/D,gBAAgB,CAACG,MAAM,EAAE4D,MAAM,CAAC;AAC/C,CAAC;AAACC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ElasticsearchCatHealth","ElasticsearchCatNodes","ElasticsearchCatClusterHealthStatus","UnhealthyClusterError","createClusterHealthStatusReason","createMemoryReason","createProcessorReason","WaitingHealthyClusterAbortedError","WAITING_TIME_STEP","WaitUntilHealthy","aborted","constructor","client","options","catHealth","catNodes","abort","wait","startedAt","Date","mustEndAt","getTime","maxWaitingTime","waitingTimeStep","runs","waitingReason","shouldWait","onTimeout","onUnhealthy","Promise","resolve","setTimeout","runningTime","health","nodes","getHealth","ex","description","message","minimum","minClusterHealthStatus","current","Red","getNodes","clusterHealthStatus","transformClusterHealthStatus","status","processorPercent","getProcessorPercent","maxProcessorPercent","maximum","maxRamPercent","undefined","ramPercent","getRamPercent","total","reduce","node","parseFloat","cpu","length","Green","Yellow","createWaitUntilHealthy","params"],"sources":["WaitUntilHealthy.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport { ElasticsearchCatHealth } from \"~/operations/ElasticsearchCatHealth.js\";\nimport { ElasticsearchCatNodes } from \"~/operations/ElasticsearchCatNodes.js\";\nimport type {\n IElasticsearchCatHealthResponse,\n IElasticsearchCatNodesResponse\n} from \"~/operations/types.js\";\nimport { ElasticsearchCatClusterHealthStatus } from \"~/operations/types.js\";\nimport { UnhealthyClusterError } from \"~/utils/waitUntilHealthy/UnhealthyClusterError.js\";\nimport type { ClusterHealthReason, MemoryReason, ProcessorReason } from \"./reason/index.js\";\nimport {\n createClusterHealthStatusReason,\n createMemoryReason,\n createProcessorReason\n} from \"./reason/index.js\";\nimport { WaitingHealthyClusterAbortedError } from \"./WaitingHealthyClusterAbortedError.js\";\n\nconst WAITING_TIME_STEP = 10;\n\nexport type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;\n\nexport interface IWaitUntilHealthyParams {\n /**\n * Minimum status allowed, otherwise the cluster is considered unhealthy.\n */\n minClusterHealthStatus:\n | ElasticsearchCatClusterHealthStatus.Green\n | ElasticsearchCatClusterHealthStatus.Yellow;\n /**\n * Maximum processor percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxProcessorPercent: number;\n /**\n * Maximum RAM percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxRamPercent?: number;\n /**\n * Maximum time to wait in seconds.\n * This is to prevent infinite waiting in case the cluster never becomes healthy.\n */\n maxWaitingTime: number;\n /**\n * Time in seconds to wait between each check.\n * This is to prevent spamming the cluster with requests.\n * Default is WAITING_TIME_STEP seconds.\n */\n waitingTimeStep?: number;\n}\n\nexport interface IWaitOptionsOnUnhealthyParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptionsOnTimeoutParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptions {\n onUnhealthy?(params: IWaitOptionsOnUnhealthyParams): Promise<void>;\n onTimeout?(params: IWaitOptionsOnTimeoutParams): Promise<void>;\n}\n\nexport interface IWaitUntilHealthyWaitResponse {\n runningTime: number;\n runs: number;\n}\n\nclass WaitUntilHealthy {\n private readonly client: Client;\n private readonly options: IWaitUntilHealthyParams;\n\n private readonly catHealth: ElasticsearchCatHealth;\n private readonly catNodes: ElasticsearchCatNodes;\n\n private aborted = false;\n\n public constructor(client: Client, options: IWaitUntilHealthyParams) {\n this.client = client;\n this.options = options;\n\n this.catHealth = new ElasticsearchCatHealth(this.client);\n this.catNodes = new ElasticsearchCatNodes(this.client);\n }\n\n public abort(): void {\n this.aborted = true;\n }\n /**\n * @throws UnhealthyClusterError\n * @throws WaitingHealthyClusterAbortedError\n */\n public async wait(options?: IWaitOptions): Promise<IWaitUntilHealthyWaitResponse> {\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError(\n `Waiting for the cluster to become healthy was aborted even before it started.`\n );\n }\n const startedAt = new Date();\n const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);\n const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;\n let runs = 1;\n let waitingReason: WaitingReason | false;\n while ((waitingReason = await this.shouldWait())) {\n if (new Date() >= mustEndAt) {\n if (options?.onTimeout) {\n await options.onTimeout({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n throw new UnhealthyClusterError(this.options.maxWaitingTime);\n } else if (options?.onUnhealthy) {\n await options.onUnhealthy({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n /**\n * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.\n */\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError();\n }\n runs++;\n await new Promise(resolve => {\n setTimeout(resolve, waitingTimeStep * 1000);\n });\n }\n\n const runningTime = new Date().getTime() - startedAt.getTime();\n\n return {\n runningTime,\n runs\n };\n }\n\n private async shouldWait(): Promise<WaitingReason | false> {\n let health: IElasticsearchCatHealthResponse;\n let nodes: IElasticsearchCatNodesResponse;\n try {\n health = await this.catHealth.getHealth();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n try {\n nodes = await this.catNodes.getNodes();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n\n const clusterHealthStatus = this.transformClusterHealthStatus(health.status);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: health.status\n });\n }\n\n const processorPercent = this.getProcessorPercent(nodes);\n if (processorPercent > this.options.maxProcessorPercent) {\n return createProcessorReason({\n maximum: this.options.maxProcessorPercent,\n current: processorPercent\n });\n }\n /**\n * Possibly no max ram definition?\n */\n if (this.options.maxRamPercent === undefined) {\n return false;\n }\n\n const ramPercent = this.getRamPercent(nodes);\n if (ramPercent > this.options.maxRamPercent) {\n return createMemoryReason({\n maximum: this.options.maxRamPercent,\n current: ramPercent\n });\n }\n return false;\n }\n\n private getProcessorPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu);\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"]);\n }, 0);\n return total / nodes.length;\n }\n\n private transformClusterHealthStatus(status: ElasticsearchCatClusterHealthStatus): number {\n switch (status) {\n case ElasticsearchCatClusterHealthStatus.Green:\n return 1;\n case ElasticsearchCatClusterHealthStatus.Yellow:\n return 2;\n case ElasticsearchCatClusterHealthStatus.Red:\n return 3;\n default:\n return 99;\n }\n }\n}\n\nexport type { WaitUntilHealthy };\n\nexport const createWaitUntilHealthy = (\n client: Client,\n params: IWaitUntilHealthyParams\n): WaitUntilHealthy => {\n return new WaitUntilHealthy(client, params);\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,qBAAqB;AAK9B,SAASC,mCAAmC;AAC5C,SAASC,qBAAqB;AAE9B,SACIC,+BAA+B,EAC/BC,kBAAkB,EAClBC,qBAAqB;AAEzB,SAASC,iCAAiC;AAE1C,MAAMC,iBAAiB,GAAG,EAAE;AA0D5B,MAAMC,gBAAgB,CAAC;EAOXC,OAAO,GAAG,KAAK;EAEhBC,WAAWA,CAACC,MAAc,EAAEC,OAAgC,EAAE;IACjE,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACC,SAAS,GAAG,IAAId,sBAAsB,CAAC,IAAI,CAACY,MAAM,CAAC;IACxD,IAAI,CAACG,QAAQ,GAAG,IAAId,qBAAqB,CAAC,IAAI,CAACW,MAAM,CAAC;EAC1D;EAEOI,KAAKA,CAAA,EAAS;IACjB,IAAI,CAACN,OAAO,GAAG,IAAI;EACvB;EACA;AACJ;AACA;AACA;EACI,MAAaO,IAAIA,CAACJ,OAAsB,EAA0C;IAC9E,IAAI,IAAI,CAACH,OAAO,EAAE;MACd,MAAM,IAAIH,iCAAiC,CACvC,+EACJ,CAAC;IACL;IACA,MAAMW,SAAS,GAAG,IAAIC,IAAI,CAAC,CAAC;IAC5B,MAAMC,SAAS,GAAG,IAAID,IAAI,CAACD,SAAS,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gBAAgB,CAACG,MAAM,EAAEoD,MAAM,CAAC;AAC/C,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WaitingHealthyClusterAbortedError = void 0;
|
|
7
|
-
var _error = require("@webiny/error");
|
|
8
|
-
class WaitingHealthyClusterAbortedError extends _error.WebinyError {
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
export class WaitingHealthyClusterAbortedError extends WebinyError {
|
|
9
3
|
constructor(message) {
|
|
10
4
|
super({
|
|
11
5
|
message: message || `Waiting for the cluster to become healthy was aborted.`,
|
|
@@ -13,6 +7,5 @@ class WaitingHealthyClusterAbortedError extends _error.WebinyError {
|
|
|
13
7
|
});
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
|
-
exports.WaitingHealthyClusterAbortedError = WaitingHealthyClusterAbortedError;
|
|
17
10
|
|
|
18
11
|
//# sourceMappingURL=WaitingHealthyClusterAbortedError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","WaitingHealthyClusterAbortedError","constructor","message","code"],"sources":["WaitingHealthyClusterAbortedError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class WaitingHealthyClusterAbortedError extends WebinyError {\n public constructor(message?: string) {\n super({\n message: message || `Waiting for the cluster to become healthy was aborted.`,\n code: \"WAITING_HEALTHY_CLUSTER_ABORTED\"\n });\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,iCAAiC,SAASD,WAAW,CAAC;EACxDE,WAAWA,CAACC,OAAgB,EAAE;IACjC,KAAK,CAAC;MACFA,OAAO,EAAEA,OAAO,IAAI,wDAAwD;MAC5EC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./WaitingHealthyClusterAbortedError";
|
|
2
|
-
export * from "./UnhealthyClusterError";
|
|
3
|
-
export * from "./WaitUntilHealthy";
|
|
4
|
-
export * from "./UnhealthyClusterError";
|
|
5
|
-
export * from "./WaitUntilHealthy";
|
|
6
|
-
export * from "./reason";
|
|
1
|
+
export * from "./WaitingHealthyClusterAbortedError.js";
|
|
2
|
+
export * from "./UnhealthyClusterError.js";
|
|
3
|
+
export * from "./WaitUntilHealthy.js";
|
|
4
|
+
export * from "./UnhealthyClusterError.js";
|
|
5
|
+
export * from "./WaitUntilHealthy.js";
|
|
6
|
+
export * from "./reason/index.js";
|
|
@@ -1,51 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(_WaitingHealthyClusterAbortedError).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _WaitingHealthyClusterAbortedError[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _WaitingHealthyClusterAbortedError[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _UnhealthyClusterError = require("./UnhealthyClusterError");
|
|
18
|
-
Object.keys(_UnhealthyClusterError).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _UnhealthyClusterError[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _UnhealthyClusterError[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _WaitUntilHealthy = require("./WaitUntilHealthy");
|
|
29
|
-
Object.keys(_WaitUntilHealthy).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _WaitUntilHealthy[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _WaitUntilHealthy[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _reason = require("./reason");
|
|
40
|
-
Object.keys(_reason).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _reason[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _reason[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
1
|
+
export * from "./WaitingHealthyClusterAbortedError.js";
|
|
2
|
+
export * from "./UnhealthyClusterError.js";
|
|
3
|
+
export * from "./WaitUntilHealthy.js";
|
|
4
|
+
export * from "./UnhealthyClusterError.js";
|
|
5
|
+
export * from "./WaitUntilHealthy.js";
|
|
6
|
+
export * from "./reason/index.js";
|
|
50
7
|
|
|
51
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./WaitingHealthyClusterAbortedError.js\";\nexport * from \"./UnhealthyClusterError.js\";\nexport * from \"./WaitUntilHealthy.js\";\nexport * from \"./UnhealthyClusterError.js\";\nexport * from \"./WaitUntilHealthy.js\";\nexport * from \"./reason/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElasticsearchCatClusterHealthStatus } from "../../../operations";
|
|
2
|
-
import { IReason } from "
|
|
1
|
+
import type { ElasticsearchCatClusterHealthStatus } from "../../../operations/index.js";
|
|
2
|
+
import type { IReason } from "../../../utils/waitUntilHealthy/reason/IReason.js";
|
|
3
3
|
export interface IClusterHealthReasonParams {
|
|
4
4
|
minimum: ElasticsearchCatClusterHealthStatus;
|
|
5
5
|
current: ElasticsearchCatClusterHealthStatus;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createClusterHealthStatusReason = exports.ClusterHealthReason = void 0;
|
|
7
|
-
class ClusterHealthReason {
|
|
1
|
+
export class ClusterHealthReason {
|
|
8
2
|
name = "clusterHealth";
|
|
9
3
|
constructor(params) {
|
|
10
4
|
this.minimum = params.minimum;
|
|
@@ -12,10 +6,8 @@ class ClusterHealthReason {
|
|
|
12
6
|
this.description = params.description;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createClusterHealthStatusReason = params => {
|
|
9
|
+
export const createClusterHealthStatusReason = params => {
|
|
17
10
|
return new ClusterHealthReason(params);
|
|
18
11
|
};
|
|
19
|
-
exports.createClusterHealthStatusReason = createClusterHealthStatusReason;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=ClusterHealthReason.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ClusterHealthReason","name","constructor","params","minimum","current","description","
|
|
1
|
+
{"version":3,"names":["ClusterHealthReason","name","constructor","params","minimum","current","description","createClusterHealthStatusReason"],"sources":["ClusterHealthReason.ts"],"sourcesContent":["import type { ElasticsearchCatClusterHealthStatus } from \"~/operations/index.js\";\nimport type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IClusterHealthReasonParams {\n minimum: ElasticsearchCatClusterHealthStatus;\n current: ElasticsearchCatClusterHealthStatus;\n description?: string;\n}\n\nexport class ClusterHealthReason implements IReason {\n public readonly name = \"clusterHealth\";\n public readonly minimum: ElasticsearchCatClusterHealthStatus;\n public readonly current: ElasticsearchCatClusterHealthStatus;\n public readonly description?: string;\n\n public constructor(params: IClusterHealthReasonParams) {\n this.minimum = params.minimum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createClusterHealthStatusReason = (\n params: IClusterHealthReasonParams\n): ClusterHealthReason => {\n return new ClusterHealthReason(params);\n};\n"],"mappings":"AASA,OAAO,MAAMA,mBAAmB,CAAoB;EAChCC,IAAI,GAAG,eAAe;EAK/BC,WAAWA,CAACC,MAAkC,EAAE;IACnD,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;AACJ;AAEA,OAAO,MAAMC,+BAA+B,GACxCJ,MAAkC,IACZ;EACtB,OAAO,IAAIH,mBAAmB,CAACG,MAAM,CAAC;AAC1C,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createMemoryReason = exports.MemoryReason = void 0;
|
|
7
|
-
class MemoryReason {
|
|
1
|
+
export class MemoryReason {
|
|
8
2
|
name = "memory";
|
|
9
3
|
constructor(params) {
|
|
10
4
|
this.maximum = params.maximum;
|
|
@@ -12,10 +6,8 @@ class MemoryReason {
|
|
|
12
6
|
this.description = params.description;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createMemoryReason = params => {
|
|
9
|
+
export const createMemoryReason = params => {
|
|
17
10
|
return new MemoryReason(params);
|
|
18
11
|
};
|
|
19
|
-
exports.createMemoryReason = createMemoryReason;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=MemoryReason.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MemoryReason","name","constructor","params","maximum","current","description","
|
|
1
|
+
{"version":3,"names":["MemoryReason","name","constructor","params","maximum","current","description","createMemoryReason"],"sources":["MemoryReason.ts"],"sourcesContent":["import type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IMemoryReasonParams {\n maximum: number;\n current: number;\n description?: string;\n}\n\nexport class MemoryReason implements IReason {\n public readonly name = \"memory\";\n public readonly maximum: number;\n public readonly current: number;\n public readonly description?: string;\n\n public constructor(params: IMemoryReasonParams) {\n this.maximum = params.maximum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createMemoryReason = (params: IMemoryReasonParams): MemoryReason => {\n return new MemoryReason(params);\n};\n"],"mappings":"AAQA,OAAO,MAAMA,YAAY,CAAoB;EACzBC,IAAI,GAAG,QAAQ;EAKxBC,WAAWA,CAACC,MAA2B,EAAE;IAC5C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAAIJ,MAA2B,IAAmB;EAC7E,OAAO,IAAIH,YAAY,CAACG,MAAM,CAAC;AACnC,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createProcessorReason = exports.ProcessorReason = void 0;
|
|
7
|
-
class ProcessorReason {
|
|
1
|
+
export class ProcessorReason {
|
|
8
2
|
name = "processor";
|
|
9
3
|
constructor(params) {
|
|
10
4
|
this.maximum = params.maximum;
|
|
@@ -12,10 +6,8 @@ class ProcessorReason {
|
|
|
12
6
|
this.description = params.description;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createProcessorReason = params => {
|
|
9
|
+
export const createProcessorReason = params => {
|
|
17
10
|
return new ProcessorReason(params);
|
|
18
11
|
};
|
|
19
|
-
exports.createProcessorReason = createProcessorReason;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=ProcessorReason.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProcessorReason","name","constructor","params","maximum","current","description","
|
|
1
|
+
{"version":3,"names":["ProcessorReason","name","constructor","params","maximum","current","description","createProcessorReason"],"sources":["ProcessorReason.ts"],"sourcesContent":["import type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IProcessorReasonParams {\n maximum: number;\n current: number;\n description?: string;\n}\n\nexport class ProcessorReason implements IReason {\n public readonly name = \"processor\";\n public readonly maximum: number;\n public readonly current: number;\n public readonly description?: string;\n\n public constructor(params: IProcessorReasonParams) {\n this.maximum = params.maximum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createProcessorReason = (params: IProcessorReasonParams): ProcessorReason => {\n return new ProcessorReason(params);\n};\n"],"mappings":"AAQA,OAAO,MAAMA,eAAe,CAAoB;EAC5BC,IAAI,GAAG,WAAW;EAK3BC,WAAWA,CAACC,MAA8B,EAAE;IAC/C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;AACJ;AAEA,OAAO,MAAMC,qBAAqB,GAAIJ,MAA8B,IAAsB;EACtF,OAAO,IAAIH,eAAe,CAACG,MAAM,CAAC;AACtC,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./ClusterHealthReason";
|
|
2
|
-
export * from "./MemoryReason";
|
|
3
|
-
export * from "./ProcessorReason";
|
|
1
|
+
export * from "./ClusterHealthReason.js";
|
|
2
|
+
export * from "./MemoryReason.js";
|
|
3
|
+
export * from "./ProcessorReason.js";
|
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _ClusterHealthReason = require("./ClusterHealthReason");
|
|
7
|
-
Object.keys(_ClusterHealthReason).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _ClusterHealthReason[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _ClusterHealthReason[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _MemoryReason = require("./MemoryReason");
|
|
18
|
-
Object.keys(_MemoryReason).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _MemoryReason[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _MemoryReason[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _ProcessorReason = require("./ProcessorReason");
|
|
29
|
-
Object.keys(_ProcessorReason).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _ProcessorReason[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _ProcessorReason[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
1
|
+
export * from "./ClusterHealthReason.js";
|
|
2
|
+
export * from "./MemoryReason.js";
|
|
3
|
+
export * from "./ProcessorReason.js";
|
|
39
4
|
|
|
40
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ClusterHealthReason.js\";\nexport * from \"./MemoryReason.js\";\nexport * from \"./ProcessorReason.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
package/where.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ElasticsearchBoolQueryConfig } from "./types";
|
|
2
|
-
import { ElasticsearchFieldPlugin } from "./plugins/definition/ElasticsearchFieldPlugin";
|
|
3
|
-
import { ElasticsearchQueryBuilderOperatorPlugin } from "./plugins/definition/ElasticsearchQueryBuilderOperatorPlugin";
|
|
4
|
-
|
|
1
|
+
import type { ElasticsearchBoolQueryConfig } from "./types.js";
|
|
2
|
+
import { ElasticsearchFieldPlugin } from "./plugins/definition/ElasticsearchFieldPlugin.js";
|
|
3
|
+
import type { ElasticsearchQueryBuilderOperatorPlugin } from "./plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js";
|
|
4
|
+
type Records<T> = Record<string, T>;
|
|
5
5
|
export interface ApplyWhereParams {
|
|
6
6
|
query: ElasticsearchBoolQueryConfig;
|
|
7
7
|
where: Records<any>;
|
package/where.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.parseWhereKey = exports.applyWhere = void 0;
|
|
8
|
-
var _ElasticsearchFieldPlugin = require("./plugins/definition/ElasticsearchFieldPlugin");
|
|
9
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
1
|
+
import { ElasticsearchFieldPlugin } from "./plugins/definition/ElasticsearchFieldPlugin.js";
|
|
2
|
+
import WebinyError from "@webiny/error";
|
|
10
3
|
/**
|
|
11
4
|
* TODO remove the wbyAco prefix when we move the user fields to the values property.
|
|
12
5
|
*/
|
|
13
6
|
const parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);
|
|
14
|
-
const parseWhereKey = key => {
|
|
7
|
+
export const parseWhereKey = key => {
|
|
15
8
|
const match = key.match(parseWhereKeyRegExp);
|
|
16
9
|
if (!match) {
|
|
17
10
|
throw new Error(`It is not possible to search by key "${key}"`);
|
|
@@ -26,9 +19,8 @@ const parseWhereKey = key => {
|
|
|
26
19
|
operator
|
|
27
20
|
};
|
|
28
21
|
};
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const applyWhere = params => {
|
|
22
|
+
const ALL = ElasticsearchFieldPlugin.ALL;
|
|
23
|
+
export const applyWhere = params => {
|
|
32
24
|
const {
|
|
33
25
|
query,
|
|
34
26
|
where,
|
|
@@ -52,13 +44,13 @@ const applyWhere = params => {
|
|
|
52
44
|
} = parseWhereKey(key);
|
|
53
45
|
const fieldPlugin = fields[field] || fields[ALL];
|
|
54
46
|
if (!fieldPlugin) {
|
|
55
|
-
throw new
|
|
47
|
+
throw new WebinyError(`Missing plugin for the field "${field}".`, "PLUGIN_WHERE_ERROR", {
|
|
56
48
|
field
|
|
57
49
|
});
|
|
58
50
|
}
|
|
59
51
|
const operatorPlugin = operators[operator];
|
|
60
52
|
if (!operatorPlugin) {
|
|
61
|
-
throw new
|
|
53
|
+
throw new WebinyError(`Missing plugin for the operator "${operator}"`, "PLUGIN_WHERE_ERROR", {
|
|
62
54
|
operator
|
|
63
55
|
});
|
|
64
56
|
}
|
|
@@ -86,6 +78,5 @@ const applyWhere = params => {
|
|
|
86
78
|
});
|
|
87
79
|
}
|
|
88
80
|
};
|
|
89
|
-
exports.applyWhere = applyWhere;
|
|
90
81
|
|
|
91
82
|
//# sourceMappingURL=where.js.map
|
package/where.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ElasticsearchFieldPlugin","WebinyError","parseWhereKeyRegExp","RegExp","parseWhereKey","key","match","Error","field","operation","operator","slice","ALL","applyWhere","params","query","where","fields","operators","hasOwnProperty","initialValue","undefined","fieldPlugin","operatorPlugin","path","getPath","basePath","getBasePath","value","toSearchValue","apply","name","keyword"],"sources":["where.ts"],"sourcesContent":["import type { ElasticsearchBoolQueryConfig } from \"~/types.js\";\nimport { ElasticsearchFieldPlugin } from \"~/plugins/definition/ElasticsearchFieldPlugin.js\";\nimport type { ElasticsearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js\";\nimport WebinyError from \"@webiny/error\";\n\ntype Records<T> = Record<string, T>;\n\nexport interface ApplyWhereParams {\n query: ElasticsearchBoolQueryConfig;\n where: Records<any>;\n fields: Records<ElasticsearchFieldPlugin>;\n operators: Records<ElasticsearchQueryBuilderOperatorPlugin>;\n}\n\nexport interface ParseWhereKeyResult {\n field: string;\n operator: string;\n}\n\n/**\n * TODO remove the wbyAco prefix when we move the user fields to the values property.\n */\nconst parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);\n\nexport const parseWhereKey = (key: string): ParseWhereKeyResult => {\n const match = key.match(parseWhereKeyRegExp);\n\n if (!match) {\n throw new Error(`It is not possible to search by key \"${key}\"`);\n }\n\n const [, field, operation = \"eq\"] = match;\n\n if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) {\n throw new Error(`Cannot filter by \"${field}\".`);\n }\n\n const operator = operation.match(/^_/) ? operation.slice(1) : operation;\n\n return { field, operator };\n};\n\nconst ALL = ElasticsearchFieldPlugin.ALL;\n\nexport const applyWhere = (params: ApplyWhereParams): void => {\n const { query, where, fields, operators } = params;\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n const initialValue = where[key];\n /**\n * There is a possibility that undefined is sent as a value, so just skip it.\n */\n if (initialValue === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n const fieldPlugin: ElasticsearchFieldPlugin = fields[field] || fields[ALL];\n if (!fieldPlugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\".`,\n \"PLUGIN_WHERE_ERROR\",\n {\n field\n }\n );\n }\n const operatorPlugin = operators[operator];\n if (!operatorPlugin) {\n throw new WebinyError(\n `Missing plugin for the operator \"${operator}\"`,\n \"PLUGIN_WHERE_ERROR\",\n {\n operator\n }\n );\n }\n\n /**\n * Get the path but in the case of * (all fields, replace * with the field.\n * Custom path would return its own value anyways.\n */\n const path = fieldPlugin.getPath(field);\n const basePath = fieldPlugin.getBasePath(field);\n /**\n * Transform the value for the search.\n */\n const value = fieldPlugin.toSearchValue({\n value: initialValue,\n path,\n basePath\n });\n\n operatorPlugin.apply(query, {\n name: field,\n value,\n path,\n basePath,\n keyword: fieldPlugin.keyword\n });\n }\n};\n"],"mappings":"AACA,SAASA,wBAAwB;AAEjC,OAAOC,WAAW,MAAM,eAAe;AAgBvC;AACA;AACA;AACA,MAAMC,mBAAmB,GAAG,IAAIC,MAAM,CAAC,+CAA+C,CAAC;AAEvF,OAAO,MAAMC,aAAa,GAAIC,GAAW,IAA0B;EAC/D,MAAMC,KAAK,GAAGD,GAAG,CAACC,KAAK,CAACJ,mBAAmB,CAAC;EAE5C,IAAI,CAACI,KAAK,EAAE;IACR,MAAM,IAAIC,KAAK,CAAC,wCAAwCF,GAAG,GAAG,CAAC;EACnE;EAEA,MAAM,GAAGG,KAAK,EAAEC,SAAS,GAAG,IAAI,CAAC,GAAGH,KAAK;EAEzC,IAAI,CAACE,KAAK,CAACF,KAAK,CAAC,8BAA8B,CAAC,EAAE;IAC9C,MAAM,IAAIC,KAAK,CAAC,qBAAqBC,KAAK,IAAI,CAAC;EACnD;EAEA,MAAME,QAAQ,GAAGD,SAAS,CAACH,KAAK,CAAC,IAAI,CAAC,GAAGG,SAAS,CAACE,KAAK,CAAC,CAAC,CAAC,GAAGF,SAAS;EAEvE,OAAO;IAAED,KAAK;IAAEE;EAAS,CAAC;AAC9B,CAA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MACxBgB,IAAI,EAAEvB,KAAK;MACXoB,KAAK;MACLJ,IAAI;MACJE,QAAQ;MACRM,OAAO,EAAEV,WAAW,CAACU;IACzB,CAAC,CAAC;EACN;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ElasticsearchIndexRequestBody } from "../types";
|
|
2
|
-
interface Modifier {
|
|
3
|
-
(config: ElasticsearchIndexRequestBody): ElasticsearchIndexRequestBody;
|
|
4
|
-
}
|
|
5
|
-
export declare const getJapaneseConfiguration: (modifier?: Modifier) => ElasticsearchIndexRequestBody;
|
|
6
|
-
export {};
|