@webiny/api-elasticsearch 0.0.0-mt-3 → 0.0.0-unstable.06b2ede40f

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.
Files changed (178) hide show
  1. package/client.d.ts +1 -0
  2. package/client.js +79 -36
  3. package/client.js.map +1 -0
  4. package/compression.d.ts +1 -1
  5. package/compression.js +13 -49
  6. package/compression.js.map +1 -0
  7. package/cursors.d.ts +3 -2
  8. package/cursors.js +10 -14
  9. package/cursors.js.map +1 -0
  10. package/index.d.ts +19 -4
  11. package/index.js +187 -13
  12. package/index.js.map +1 -0
  13. package/indexConfiguration/base.d.ts +6 -0
  14. package/indexConfiguration/base.js +42 -0
  15. package/indexConfiguration/base.js.map +1 -0
  16. package/indexConfiguration/common.d.ts +9 -0
  17. package/indexConfiguration/common.js +54 -0
  18. package/indexConfiguration/common.js.map +1 -0
  19. package/indexConfiguration/index.d.ts +3 -0
  20. package/indexConfiguration/index.js +40 -0
  21. package/indexConfiguration/index.js.map +1 -0
  22. package/indexConfiguration/japanese.d.ts +6 -0
  23. package/indexConfiguration/japanese.js +121 -0
  24. package/indexConfiguration/japanese.js.map +1 -0
  25. package/indexPrefix.d.ts +1 -0
  26. package/indexPrefix.js +12 -0
  27. package/indexPrefix.js.map +1 -0
  28. package/indices.d.ts +9 -0
  29. package/indices.js +30 -0
  30. package/indices.js.map +1 -0
  31. package/limit.js +2 -8
  32. package/limit.js.map +1 -0
  33. package/normalize.d.ts +1 -0
  34. package/normalize.js +47 -12
  35. package/normalize.js.map +1 -0
  36. package/operations/ElasticsearchCatHealth.d.ts +7 -0
  37. package/operations/ElasticsearchCatHealth.js +38 -0
  38. package/operations/ElasticsearchCatHealth.js.map +1 -0
  39. package/operations/ElasticsearchCatNodes.d.ts +7 -0
  40. package/operations/ElasticsearchCatNodes.js +36 -0
  41. package/operations/ElasticsearchCatNodes.js.map +1 -0
  42. package/operations/index.d.ts +3 -0
  43. package/operations/index.js +40 -0
  44. package/operations/index.js.map +1 -0
  45. package/operations/stripConnectionFromException.d.ts +1 -0
  46. package/operations/stripConnectionFromException.js +24 -0
  47. package/operations/stripConnectionFromException.js.map +1 -0
  48. package/operations/types.d.ts +35 -0
  49. package/operations/types.js +14 -0
  50. package/operations/types.js.map +1 -0
  51. package/operators.d.ts +5 -14
  52. package/operators.js +37 -32
  53. package/operators.js.map +1 -0
  54. package/package.json +12 -25
  55. package/plugins/definition/ElasticsearchBodyModifierPlugin.d.ts +1 -1
  56. package/plugins/definition/ElasticsearchBodyModifierPlugin.js +3 -12
  57. package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -0
  58. package/plugins/definition/ElasticsearchFieldPlugin.d.ts +11 -17
  59. package/plugins/definition/ElasticsearchFieldPlugin.js +22 -75
  60. package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -0
  61. package/plugins/definition/ElasticsearchIndexPlugin.d.ts +18 -0
  62. package/plugins/definition/ElasticsearchIndexPlugin.js +36 -0
  63. package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -0
  64. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +6 -2
  65. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +12 -8
  66. package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -0
  67. package/plugins/definition/ElasticsearchQueryModifierPlugin.d.ts +1 -1
  68. package/plugins/definition/ElasticsearchQueryModifierPlugin.js +3 -12
  69. package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -0
  70. package/plugins/definition/ElasticsearchSortModifierPlugin.d.ts +1 -1
  71. package/plugins/definition/ElasticsearchSortModifierPlugin.js +3 -12
  72. package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -0
  73. package/plugins/definition/index.d.ts +6 -0
  74. package/plugins/definition/index.js +73 -0
  75. package/plugins/definition/index.js.map +1 -0
  76. package/plugins/index.d.ts +2 -0
  77. package/plugins/index.js +29 -0
  78. package/plugins/index.js.map +1 -0
  79. package/plugins/operator/andIn.d.ts +1 -1
  80. package/plugins/operator/andIn.js +6 -20
  81. package/plugins/operator/andIn.js.map +1 -0
  82. package/plugins/operator/between.d.ts +1 -1
  83. package/plugins/operator/between.js +10 -22
  84. package/plugins/operator/between.js.map +1 -0
  85. package/plugins/operator/contains.d.ts +1 -1
  86. package/plugins/operator/contains.js +4 -16
  87. package/plugins/operator/contains.js.map +1 -0
  88. package/plugins/operator/equal.d.ts +1 -1
  89. package/plugins/operator/equal.js +31 -19
  90. package/plugins/operator/equal.js.map +1 -0
  91. package/plugins/operator/gt.d.ts +1 -1
  92. package/plugins/operator/gt.js +4 -15
  93. package/plugins/operator/gt.js.map +1 -0
  94. package/plugins/operator/gte.d.ts +1 -1
  95. package/plugins/operator/gte.js +4 -15
  96. package/plugins/operator/gte.js.map +1 -0
  97. package/plugins/operator/in.d.ts +1 -1
  98. package/plugins/operator/in.js +9 -27
  99. package/plugins/operator/in.js.map +1 -0
  100. package/plugins/operator/index.d.ts +3 -0
  101. package/plugins/operator/index.js +36 -27
  102. package/plugins/operator/index.js.map +1 -0
  103. package/plugins/operator/japanese/contains.d.ts +8 -0
  104. package/plugins/operator/japanese/contains.js +44 -0
  105. package/plugins/operator/japanese/contains.js.map +1 -0
  106. package/plugins/operator/lt.d.ts +1 -1
  107. package/plugins/operator/lt.js +4 -15
  108. package/plugins/operator/lt.js.map +1 -0
  109. package/plugins/operator/lte.d.ts +1 -1
  110. package/plugins/operator/lte.js +4 -15
  111. package/plugins/operator/lte.js.map +1 -0
  112. package/plugins/operator/not.d.ts +1 -1
  113. package/plugins/operator/not.js +27 -16
  114. package/plugins/operator/not.js.map +1 -0
  115. package/plugins/operator/notBetween.d.ts +1 -1
  116. package/plugins/operator/notBetween.js +9 -21
  117. package/plugins/operator/notBetween.js.map +1 -0
  118. package/plugins/operator/notContains.d.ts +1 -1
  119. package/plugins/operator/notContains.js +4 -16
  120. package/plugins/operator/notContains.js.map +1 -0
  121. package/plugins/operator/notIn.d.ts +1 -1
  122. package/plugins/operator/notIn.js +6 -18
  123. package/plugins/operator/notIn.js.map +1 -0
  124. package/plugins/operator/notStartsWith.d.ts +7 -0
  125. package/plugins/operator/notStartsWith.js +30 -0
  126. package/plugins/operator/notStartsWith.js.map +1 -0
  127. package/plugins/operator/startsWith.d.ts +7 -0
  128. package/plugins/operator/startsWith.js +30 -0
  129. package/plugins/operator/startsWith.js.map +1 -0
  130. package/sharedIndex.d.ts +1 -0
  131. package/sharedIndex.js +12 -0
  132. package/sharedIndex.js.map +1 -0
  133. package/sort.d.ts +5 -4
  134. package/sort.js +22 -17
  135. package/sort.js.map +1 -0
  136. package/types.d.ts +178 -6
  137. package/types.js +14 -3
  138. package/types.js.map +1 -0
  139. package/utils/createIndex.d.ts +20 -0
  140. package/utils/createIndex.js +100 -0
  141. package/utils/createIndex.js.map +1 -0
  142. package/utils/index.d.ts +3 -0
  143. package/utils/index.js +29 -0
  144. package/utils/index.js.map +1 -0
  145. package/utils/waitUntilHealthy/UnhealthyClusterError.d.ts +4 -0
  146. package/utils/waitUntilHealthy/UnhealthyClusterError.js +18 -0
  147. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -0
  148. package/utils/waitUntilHealthy/WaitUntilHealthy.d.ts +71 -0
  149. package/utils/waitUntilHealthy/WaitUntilHealthy.js +157 -0
  150. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -0
  151. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.d.ts +4 -0
  152. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +18 -0
  153. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -0
  154. package/utils/waitUntilHealthy/index.d.ts +6 -0
  155. package/utils/waitUntilHealthy/index.js +51 -0
  156. package/utils/waitUntilHealthy/index.js.map +1 -0
  157. package/utils/waitUntilHealthy/reason/ClusterHealthReason.d.ts +15 -0
  158. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +21 -0
  159. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -0
  160. package/utils/waitUntilHealthy/reason/IReason.d.ts +4 -0
  161. package/utils/waitUntilHealthy/reason/IReason.js +7 -0
  162. package/utils/waitUntilHealthy/reason/IReason.js.map +1 -0
  163. package/utils/waitUntilHealthy/reason/MemoryReason.d.ts +14 -0
  164. package/utils/waitUntilHealthy/reason/MemoryReason.js +21 -0
  165. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -0
  166. package/utils/waitUntilHealthy/reason/ProcessorReason.d.ts +14 -0
  167. package/utils/waitUntilHealthy/reason/ProcessorReason.js +21 -0
  168. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -0
  169. package/utils/waitUntilHealthy/reason/index.d.ts +3 -0
  170. package/utils/waitUntilHealthy/reason/index.js +40 -0
  171. package/utils/waitUntilHealthy/reason/index.js.map +1 -0
  172. package/where.d.ts +5 -5
  173. package/where.js +11 -26
  174. package/where.js.map +1 -0
  175. package/plugins/GzipCompression.d.ts +0 -19
  176. package/plugins/GzipCompression.js +0 -75
  177. package/plugins/definition/CompressionPlugin.d.ts +0 -20
  178. package/plugins/definition/CompressionPlugin.js +0 -17
package/types.js CHANGED
@@ -3,11 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
6
+ var _exportNames = {
7
+ ApiResponse: true
8
+ };
9
+ Object.defineProperty(exports, "ApiResponse", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _elasticsearch.ApiResponse;
13
+ }
14
+ });
15
+ var _elasticsearch = require("@elastic/elasticsearch");
7
16
  var _elasticTs = require("elastic-ts");
8
-
9
17
  Object.keys(_elasticTs).forEach(function (key) {
10
18
  if (key === "default" || key === "__esModule") return;
19
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
11
20
  if (key in exports && exports[key] === _elasticTs[key]) return;
12
21
  Object.defineProperty(exports, key, {
13
22
  enumerable: true,
@@ -15,4 +24,6 @@ Object.keys(_elasticTs).forEach(function (key) {
15
24
  return _elasticTs[key];
16
25
  }
17
26
  });
18
- });
27
+ });
28
+
29
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_elasticsearch","require","_elasticTs","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["types.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport { ApiResponse } from \"@elastic/elasticsearch\";\nimport type { BoolQueryConfig, PrimitiveValue, Query as esQuery } from \"elastic-ts\";\nimport type { Context, GenericRecord } from \"@webiny/api/types\";\n/**\n * Re-export some dep lib types.\n */\nexport * from \"elastic-ts\";\nexport { ApiResponse };\n\nexport interface ElasticsearchContext extends Context {\n elasticsearch: Client;\n}\n\n/**\n * To simplify our plugins, we say that query contains arrays of objects, not single objects.\n * And that they all are defined as empty arrays at the start.\n */\nexport interface ElasticsearchBoolQueryConfig extends BoolQueryConfig {\n must: esQuery[];\n filter: esQuery[];\n should: esQuery[];\n must_not: esQuery[];\n}\n\n/**\n * Definitions of possible Elasticsearch operators.\n *\n * @category Elasticsearch\n */\nexport type ElasticsearchQueryOperator =\n | \"eq\"\n | \"not\"\n | \"in\"\n | \"not_in\"\n | \"contains\"\n | \"not_contains\"\n | \"between\"\n | \"not_between\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | string;\n\n/**\n * Definition for arguments of the ElasticsearchQueryBuilderOperatorPlugin.apply method.\n *\n * @see ElasticsearchQueryBuilderOperatorPlugin.apply\n *\n * @category Plugin\n * @category Elasticsearch\n */\nexport interface ElasticsearchQueryBuilderArgsPlugin {\n /**\n * Name of the field.\n */\n name: string;\n /**\n * A full path to the field. Including the \".keyword\" if it is added.\n */\n path: string;\n /**\n * A path to the field, plain.\n */\n basePath: string;\n /**\n * Value to apply.\n */\n value: any;\n /**\n * Is path containing the \".keyword\"\n */\n keyword: boolean;\n}\n\n/**\n * Elasticsearch responses.\n */\nexport interface ElasticsearchSearchResponseHit<T> {\n _index: string;\n _type: string;\n _id: string;\n _score: number | null;\n _source: T;\n sort: PrimitiveValue[];\n}\nexport interface ElasticsearchSearchResponseAggregationBucket<T> {\n key: T;\n doc_count: number;\n}\n\nexport interface ElasticsearchSearchResponseBodyHits<T> {\n hits: ElasticsearchSearchResponseHit<T>[];\n total: {\n value: number;\n };\n}\n\nexport interface ElasticsearchSearchResponseBodyAggregations<T> {\n [key: string]: {\n buckets: ElasticsearchSearchResponseAggregationBucket<T>[];\n };\n}\n\nexport interface ElasticsearchSearchResponseBody<T> {\n hits: ElasticsearchSearchResponseBodyHits<T>;\n aggregations: ElasticsearchSearchResponseBodyAggregations<T>;\n}\n\nexport interface ElasticsearchSearchResponse<T = GenericRecord> {\n body: ElasticsearchSearchResponseBody<T>;\n}\n\nexport interface ElasticsearchIndexRequestBodyMappingsDynamicTemplate {\n [key: string]: {\n path_match?: string;\n path_unmatch?: string;\n match_mapping_type?: string;\n match?: string;\n unmatch?: string;\n mapping?: {\n numeric_detection?: boolean;\n date_detection?: boolean;\n type?:\n | \"string\"\n | \"date\"\n | \"binary\"\n | \"boolean\"\n | \"object\"\n | \"ip\"\n | \"geo\"\n | \"long\"\n | \"integer\"\n | \"short\"\n | \"byte\"\n | \"double\"\n | \"float\"\n | \"half_float\"\n | \"scaled_float\"\n | \"unsigned_long\"\n | string;\n search_analyzer?: string;\n analyzer?: string;\n fields?: {\n [key: string]:\n | {\n type: string;\n search_analyzer?: string;\n analyzer?: string;\n ignore_above?: number;\n [key: string]: any;\n }\n | undefined;\n };\n [key: string]: any;\n };\n [key: string]: any;\n };\n}\n\nexport interface ElasticsearchIndexRequestBodySettingsTotalFields {\n limit?: number;\n}\n\ninterface ElasticsearchIndexRequestBodySettings {\n analysis?: {\n [key: string]: any;\n };\n number_of_shards?: number;\n number_of_routing_shards?: number;\n codec?: string;\n routing_partition_size?: number;\n soft_deletes?: {\n enabled?: boolean;\n retention_lease?: {\n period?: string;\n };\n };\n load_fixed_bitset_filters_eagerly?: boolean;\n shard?: {\n check_on_startup?: boolean | \"checksum\";\n };\n number_of_replicas?: number;\n auto_expand_replicas?: string | \"all\" | false;\n search?: {\n idle?: {\n after?: string;\n };\n };\n refresh_interval?: string;\n max_result_window?: number;\n max_inner_result_window?: number;\n max_rescore_window?: number;\n max_docvalue_fields_search?: number;\n max_script_fields?: number;\n max_ngram_diff?: number;\n max_shingle_diff?: number;\n max_refresh_listeners?: number;\n analyze?: {\n max_token_count?: number;\n };\n highlight?: {\n max_analyzed_offset?: number;\n };\n max_terms_count?: number;\n max_regex_length?: number;\n query?: {\n default_field?: string;\n };\n routing?: {\n allocation?: {\n enable?: \"all\" | \"primaries\" | \"new_primaries\" | \"none\";\n };\n rebalance?: {\n enable?: \"all\" | \"primaries\" | \"new_primaries\" | \"none\";\n };\n };\n gc_deletes?: string;\n default_pipeline?: string;\n final_pipeline?: string;\n hidden?: boolean;\n total_fields?: ElasticsearchIndexRequestBodySettingsTotalFields;\n [key: string]: any;\n}\n\nexport interface ElasticsearchIndexRequestBody {\n settings?: {\n index?: Partial<ElasticsearchIndexRequestBodySettings>;\n };\n mappings: {\n numeric_detection?: boolean;\n dynamic_templates?: ElasticsearchIndexRequestBodyMappingsDynamicTemplate[];\n properties?: {\n [key: string]: {\n analyzer?: string;\n type?: string;\n normalizer?: string;\n index?: string;\n fields?: {\n [key: string]: {\n type: string;\n ignore_above?: number;\n search_analyzer?: string;\n analyzer?: string;\n [key: string]: any;\n };\n };\n [key: string]: any;\n };\n };\n [key: string]: any;\n };\n aliases?: {\n [key: string]: {\n filter?: {\n [key: string]: any;\n };\n index_routing?: string;\n is_hidden?: boolean;\n is_write_index?: boolean;\n routing?: string;\n search_routing?: string;\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,UAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,UAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,UAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ import type { Client } from "@elastic/elasticsearch";
2
+ import type { PluginsContainer } from "@webiny/plugins";
3
+ interface OnExists {
4
+ (): void;
5
+ }
6
+ interface OnError {
7
+ (ex: Error): Error;
8
+ }
9
+ interface CreateIndexParams {
10
+ client: Client;
11
+ plugins: PluginsContainer;
12
+ type: string;
13
+ tenant: string;
14
+ locale: string;
15
+ index: string;
16
+ onExists?: OnExists;
17
+ onError?: OnError;
18
+ }
19
+ export declare const createIndex: (params: CreateIndexParams) => Promise<void>;
20
+ export {};
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createIndex = void 0;
8
+ var _indices = require("../indices");
9
+ var _error = _interopRequireDefault(require("@webiny/error"));
10
+ const indexExists = async params => {
11
+ const {
12
+ client,
13
+ index,
14
+ onExists
15
+ } = params;
16
+ try {
17
+ const response = await client.indices.exists({
18
+ index,
19
+ ignore_unavailable: false,
20
+ allow_no_indices: true,
21
+ include_defaults: true,
22
+ flat_settings: false,
23
+ local: false
24
+ });
25
+ if (!response.body) {
26
+ return false;
27
+ }
28
+ if (onExists) {
29
+ onExists();
30
+ }
31
+ return true;
32
+ } catch (ex) {
33
+ console.error(`Could not determine if the index "${index}" exists.`);
34
+ }
35
+ return false;
36
+ };
37
+ const indexCreate = async params => {
38
+ const {
39
+ client,
40
+ index,
41
+ plugin,
42
+ tenant,
43
+ locale,
44
+ type,
45
+ onError
46
+ } = params;
47
+ try {
48
+ await client.indices.create({
49
+ index,
50
+ body: {
51
+ ...plugin.body
52
+ }
53
+ });
54
+ } catch (ex) {
55
+ let error = ex;
56
+ if (onError) {
57
+ error = onError(ex);
58
+ }
59
+ throw new _error.default(error.message || `Could not create Elasticsearch index for the ${type}.`, error.code || "CREATE_ELASTICSEARCH_INDEX_ERROR", {
60
+ error: {
61
+ ...error,
62
+ message: error.message,
63
+ code: error.code,
64
+ data: error.data
65
+ },
66
+ type,
67
+ locale,
68
+ tenant,
69
+ index,
70
+ body: plugin.body
71
+ });
72
+ }
73
+ };
74
+ const createIndex = async params => {
75
+ const {
76
+ plugins,
77
+ type,
78
+ locale,
79
+ onExists
80
+ } = params;
81
+ const plugin = (0, _indices.getLastAddedIndexPlugin)({
82
+ container: plugins,
83
+ type,
84
+ locale
85
+ });
86
+ const exists = await indexExists(params);
87
+ if (exists) {
88
+ if (onExists) {
89
+ onExists();
90
+ }
91
+ return;
92
+ }
93
+ await indexCreate({
94
+ ...params,
95
+ plugin
96
+ });
97
+ };
98
+ exports.createIndex = createIndex;
99
+
100
+ //# sourceMappingURL=createIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_indices","require","_error","_interopRequireDefault","indexExists","params","client","index","onExists","response","indices","exists","ignore_unavailable","allow_no_indices","include_defaults","flat_settings","local","body","ex","console","error","indexCreate","plugin","tenant","locale","type","onError","create","WebinyError","message","code","data","createIndex","plugins","getLastAddedIndexPlugin","container","exports"],"sources":["createIndex.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { getLastAddedIndexPlugin } from \"~/indices\";\nimport type { ElasticsearchIndexPlugin } from \"~/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface OnExists {\n (): void;\n}\n\ninterface OnError {\n (ex: Error): Error;\n}\n\ninterface ExistsIndexParams {\n client: Client;\n index: string;\n onExists?: OnExists;\n}\n\nconst indexExists = async (params: ExistsIndexParams): Promise<boolean> => {\n const { client, index, onExists } = params;\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (!response.body) {\n return false;\n }\n if (onExists) {\n onExists();\n }\n return true;\n } catch (ex) {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n return false;\n};\n\ninterface IndexCreateParams {\n client: Client;\n index: string;\n type: string;\n tenant: string;\n locale: string;\n plugin: ElasticsearchIndexPlugin;\n onError?: OnError;\n}\n\nconst indexCreate = async (params: IndexCreateParams): Promise<void> => {\n const { client, index, plugin, tenant, locale, type, onError } = params;\n\n try {\n await client.indices.create({\n index,\n body: {\n ...plugin.body\n }\n });\n } catch (ex) {\n let error = ex;\n if (onError) {\n error = onError(ex);\n }\n throw new WebinyError(\n error.message || `Could not create Elasticsearch index for the ${type}.`,\n error.code || \"CREATE_ELASTICSEARCH_INDEX_ERROR\",\n {\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data\n },\n type,\n locale,\n tenant,\n index,\n body: plugin.body\n }\n );\n }\n};\n\ninterface CreateIndexParams {\n client: Client;\n plugins: PluginsContainer;\n type: string;\n tenant: string;\n locale: string;\n index: string;\n onExists?: OnExists;\n onError?: OnError;\n}\n\nexport const createIndex = async (params: CreateIndexParams): Promise<void> => {\n const { plugins, type, locale, onExists } = params;\n const plugin = getLastAddedIndexPlugin<ElasticsearchIndexPlugin>({\n container: plugins,\n type,\n locale\n });\n\n const exists = await indexExists(params);\n if (exists) {\n if (onExists) {\n onExists();\n }\n return;\n }\n\n await indexCreate({\n ...params,\n plugin\n });\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IA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,kCAAkC,EAChD;MACIV,KAAK,EAAE;QACH,GAAGA,KAAK;QACRS,OAAO,EAAET,KAAK,CAACS,OAAO;QACtBC,IAAI,EAAEV,KAAK,CAACU,IAAI;QAChBC,IAAI,EAAEX,KAAK,CAACW;MAChB,CAAC;MACDN,IAAI;MACJD,MAAM;MACND,MAAM;MACNhB,KAAK;MACLU,IAAI,EAAEK,MAAM,CAACL;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAaM,MAAMe,WAAW,GAAG,MAAO3B,MAAyB,IAAoB;EAC3E,MAAM;IAAE4B,OAAO;IAAER,IAAI;IAAED,MAAM;IAAEhB;EAAS,CAAC,GAAGH,MAAM;EAClD,MAAMiB,MAAM,GAAG,IAAAY,gCAAuB,EAA2B;IAC7DC,SAAS,EAAEF,OAAO;IAClBR,IAAI;IACJD;EACJ,CAAC,CAAC;EAEF,MAAMb,MAAM,GAAG,MAAMP,WAAW,CAACC,MAAM,CAAC;EACxC,IAAIM,MAAM,EAAE;IACR,IAAIH,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA;EACJ;EAEA,MAAMa,WAAW,CAAC;IACd,GAAGhB,MAAM;IACTiB;EACJ,CAAC,CAAC;AACN,CAAC;AAACc,OAAA,CAAAJ,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export * from "./waitUntilHealthy";
2
+ export * from "./createIndex";
3
+ export * from "./waitUntilHealthy";
package/utils/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _waitUntilHealthy = require("./waitUntilHealthy");
7
+ Object.keys(_waitUntilHealthy).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _waitUntilHealthy[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _waitUntilHealthy[key];
14
+ }
15
+ });
16
+ });
17
+ var _createIndex = require("./createIndex");
18
+ Object.keys(_createIndex).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _createIndex[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _createIndex[key];
25
+ }
26
+ });
27
+ });
28
+
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_waitUntilHealthy","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_createIndex"],"sources":["index.ts"],"sourcesContent":["export * from \"./waitUntilHealthy\";\nexport * from \"./createIndex\";\nexport * from \"./waitUntilHealthy\";\n"],"mappings":";;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEAC,MAAA,CAAAC,IAAA,CAAAH,iBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,iBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,iBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AADA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ export declare class UnhealthyClusterError extends WebinyError {
3
+ constructor(maxWaitingTime: number);
4
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnhealthyClusterError = void 0;
7
+ var _error = require("@webiny/error");
8
+ class UnhealthyClusterError extends _error.WebinyError {
9
+ constructor(maxWaitingTime) {
10
+ super({
11
+ message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,
12
+ code: "UNHEALTHY_CLUSTER"
13
+ });
14
+ }
15
+ }
16
+ exports.UnhealthyClusterError = UnhealthyClusterError;
17
+
18
+ //# sourceMappingURL=UnhealthyClusterError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","require","UnhealthyClusterError","WebinyError","constructor","maxWaitingTime","message","code","exports"],"sources":["UnhealthyClusterError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class UnhealthyClusterError extends WebinyError {\n public constructor(maxWaitingTime: number) {\n super({\n message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,\n code: \"UNHEALTHY_CLUSTER\"\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,qBAAqB,SAASC,kBAAW,CAAC;EAC5CC,WAAWA,CAACC,cAAsB,EAAE;IACvC,KAAK,CAAC;MACFC,OAAO,EAAE,qCAAqCD,cAAc,WAAW;MACvEE,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAN,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,71 @@
1
+ import type { Client } from "../../client";
2
+ import { ElasticsearchCatClusterHealthStatus } from "../../operations/types";
3
+ import type { ClusterHealthReason, MemoryReason, ProcessorReason } from "./reason";
4
+ export type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;
5
+ export interface IWaitUntilHealthyParams {
6
+ /**
7
+ * Minimum status allowed, otherwise the cluster is considered unhealthy.
8
+ */
9
+ minClusterHealthStatus: ElasticsearchCatClusterHealthStatus.Green | ElasticsearchCatClusterHealthStatus.Yellow;
10
+ /**
11
+ * Maximum processor percent allowed, otherwise the cluster is considered unhealthy.
12
+ */
13
+ maxProcessorPercent: number;
14
+ /**
15
+ * Maximum RAM percent allowed, otherwise the cluster is considered unhealthy.
16
+ */
17
+ maxRamPercent?: number;
18
+ /**
19
+ * Maximum time to wait in seconds.
20
+ * This is to prevent infinite waiting in case the cluster never becomes healthy.
21
+ */
22
+ maxWaitingTime: number;
23
+ /**
24
+ * Time in seconds to wait between each check.
25
+ * This is to prevent spamming the cluster with requests.
26
+ * Default is WAITING_TIME_STEP seconds.
27
+ */
28
+ waitingTimeStep?: number;
29
+ }
30
+ export interface IWaitOptionsOnUnhealthyParams {
31
+ startedAt: Date;
32
+ mustEndAt: Date;
33
+ waitingTimeStep: number;
34
+ runs: number;
35
+ waitingReason: WaitingReason;
36
+ }
37
+ export interface IWaitOptionsOnTimeoutParams {
38
+ startedAt: Date;
39
+ mustEndAt: Date;
40
+ waitingTimeStep: number;
41
+ runs: number;
42
+ waitingReason: WaitingReason;
43
+ }
44
+ export interface IWaitOptions {
45
+ onUnhealthy?(params: IWaitOptionsOnUnhealthyParams): Promise<void>;
46
+ onTimeout?(params: IWaitOptionsOnTimeoutParams): Promise<void>;
47
+ }
48
+ export interface IWaitUntilHealthyWaitResponse {
49
+ runningTime: number;
50
+ runs: number;
51
+ }
52
+ declare class WaitUntilHealthy {
53
+ private readonly client;
54
+ private readonly options;
55
+ private readonly catHealth;
56
+ private readonly catNodes;
57
+ private aborted;
58
+ constructor(client: Client, options: IWaitUntilHealthyParams);
59
+ abort(): void;
60
+ /**
61
+ * @throws UnhealthyClusterError
62
+ * @throws WaitingHealthyClusterAbortedError
63
+ */
64
+ wait(options?: IWaitOptions): Promise<IWaitUntilHealthyWaitResponse>;
65
+ private shouldWait;
66
+ private getProcessorPercent;
67
+ private getRamPercent;
68
+ private transformClusterHealthStatus;
69
+ }
70
+ export type { WaitUntilHealthy };
71
+ export declare const createWaitUntilHealthy: (client: Client, params: IWaitUntilHealthyParams) => WaitUntilHealthy;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createWaitUntilHealthy = void 0;
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");
13
+ const WAITING_TIME_STEP = 10;
14
+ class WaitUntilHealthy {
15
+ aborted = false;
16
+ constructor(client, options) {
17
+ this.client = client;
18
+ this.options = options;
19
+ this.catHealth = new _ElasticsearchCatHealth.ElasticsearchCatHealth(this.client);
20
+ this.catNodes = new _ElasticsearchCatNodes.ElasticsearchCatNodes(this.client);
21
+ }
22
+ abort() {
23
+ this.aborted = true;
24
+ }
25
+ /**
26
+ * @throws UnhealthyClusterError
27
+ * @throws WaitingHealthyClusterAbortedError
28
+ */
29
+ async wait(options) {
30
+ if (this.aborted) {
31
+ throw new _WaitingHealthyClusterAbortedError.WaitingHealthyClusterAbortedError(`Waiting for the cluster to become healthy was aborted even before it started.`);
32
+ }
33
+ const startedAt = new Date();
34
+ const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);
35
+ const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;
36
+ let runs = 1;
37
+ let waitingReason;
38
+ while (waitingReason = await this.shouldWait()) {
39
+ if (new Date() >= mustEndAt) {
40
+ if (options?.onTimeout) {
41
+ await options.onTimeout({
42
+ startedAt,
43
+ mustEndAt,
44
+ waitingTimeStep,
45
+ waitingReason,
46
+ runs
47
+ });
48
+ }
49
+ throw new _UnhealthyClusterError.UnhealthyClusterError(this.options.maxWaitingTime);
50
+ } else if (options?.onUnhealthy) {
51
+ await options.onUnhealthy({
52
+ startedAt,
53
+ mustEndAt,
54
+ waitingTimeStep,
55
+ waitingReason,
56
+ runs
57
+ });
58
+ }
59
+ /**
60
+ * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.
61
+ */
62
+ if (this.aborted) {
63
+ throw new _WaitingHealthyClusterAbortedError.WaitingHealthyClusterAbortedError();
64
+ }
65
+ runs++;
66
+ await new Promise(resolve => {
67
+ setTimeout(resolve, waitingTimeStep * 1000);
68
+ });
69
+ }
70
+ const runningTime = new Date().getTime() - startedAt.getTime();
71
+ return {
72
+ runningTime,
73
+ runs
74
+ };
75
+ }
76
+ async shouldWait() {
77
+ let health;
78
+ let nodes;
79
+ try {
80
+ health = await this.catHealth.getHealth();
81
+ } catch (ex) {
82
+ return (0, _reason.createClusterHealthStatusReason)({
83
+ description: ex.message,
84
+ minimum: this.options.minClusterHealthStatus,
85
+ current: _types.ElasticsearchCatClusterHealthStatus.Red
86
+ });
87
+ }
88
+ try {
89
+ nodes = await this.catNodes.getNodes();
90
+ } catch (ex) {
91
+ return (0, _reason.createClusterHealthStatusReason)({
92
+ description: ex.message,
93
+ minimum: this.options.minClusterHealthStatus,
94
+ current: _types.ElasticsearchCatClusterHealthStatus.Red
95
+ });
96
+ }
97
+ const clusterHealthStatus = this.transformClusterHealthStatus(health.status);
98
+ const minClusterHealthStatus = this.transformClusterHealthStatus(this.options.minClusterHealthStatus);
99
+ if (clusterHealthStatus > minClusterHealthStatus) {
100
+ return (0, _reason.createClusterHealthStatusReason)({
101
+ minimum: this.options.minClusterHealthStatus,
102
+ current: health.status
103
+ });
104
+ }
105
+ const processorPercent = this.getProcessorPercent(nodes);
106
+ if (processorPercent > this.options.maxProcessorPercent) {
107
+ return (0, _reason.createProcessorReason)({
108
+ maximum: this.options.maxProcessorPercent,
109
+ current: processorPercent
110
+ });
111
+ }
112
+ /**
113
+ * Possibly no max ram definition?
114
+ */
115
+ if (this.options.maxRamPercent === undefined) {
116
+ return false;
117
+ }
118
+ const ramPercent = this.getRamPercent(nodes);
119
+ if (ramPercent > this.options.maxRamPercent) {
120
+ return (0, _reason.createMemoryReason)({
121
+ maximum: this.options.maxRamPercent,
122
+ current: ramPercent
123
+ });
124
+ }
125
+ return false;
126
+ }
127
+ getProcessorPercent(nodes) {
128
+ const total = nodes.reduce((total, node) => {
129
+ return total + parseFloat(node.cpu);
130
+ }, 0);
131
+ return total / nodes.length;
132
+ }
133
+ getRamPercent(nodes) {
134
+ const total = nodes.reduce((total, node) => {
135
+ return total + parseFloat(node["ram.percent"]);
136
+ }, 0);
137
+ return total / nodes.length;
138
+ }
139
+ transformClusterHealthStatus(status) {
140
+ switch (status) {
141
+ case _types.ElasticsearchCatClusterHealthStatus.Green:
142
+ return 1;
143
+ case _types.ElasticsearchCatClusterHealthStatus.Yellow:
144
+ return 2;
145
+ case _types.ElasticsearchCatClusterHealthStatus.Red:
146
+ return 3;
147
+ default:
148
+ return 99;
149
+ }
150
+ }
151
+ }
152
+ const createWaitUntilHealthy = (client, params) => {
153
+ return new WaitUntilHealthy(client, params);
154
+ };
155
+ exports.createWaitUntilHealthy = createWaitUntilHealthy;
156
+
157
+ //# sourceMappingURL=WaitUntilHealthy.js.map
@@ -0,0 +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 type { Client } from \"~/client\";\nimport { ElasticsearchCatHealth } from \"~/operations/ElasticsearchCatHealth\";\nimport { ElasticsearchCatNodes } from \"~/operations/ElasticsearchCatNodes\";\nimport type {\n IElasticsearchCatHealthResponse,\n IElasticsearchCatNodesResponse\n} from \"~/operations/types\";\nimport { ElasticsearchCatClusterHealthStatus } from \"~/operations/types\";\nimport { UnhealthyClusterError } from \"~/utils/waitUntilHealthy/UnhealthyClusterError\";\nimport type { ClusterHealthReason, MemoryReason, ProcessorReason } from \"./reason\";\nimport {\n createClusterHealthStatusReason,\n createMemoryReason,\n createProcessorReason\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;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,kCAAA,GAAAL,OAAA;AAEA,MAAMM,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,IAAIC,8CAAsB,CAAC,IAAI,CAACH,MAAM,CAAC;IACxD,IAAI,CAACI,QAAQ,GAAG,IAAIC,4CAAqB,CAAC,IAAI,CAACL,MAAM,CAAC;EAC1D;EAEOM,KAAKA,CAAA,EAAS;IACjB,IAAI,CAACR,OAAO,GAAG,IAAI;EACvB;EACA;AACJ;AACA;AACA;EACI,MAAaS,IAAIA,CAACN,OAAsB,EAA0C;IAC9E,IAAI,IAAI,CAACH,OAAO,EAAE;MACd,MAAM,IAAIU,oEAAiC,CACvC,+EACJ,CAAC;IACL;IACA,MAAMC,SAAS,GAAG,IAAIC,IAAI,CAAC,CAAC;IAC5B,MAAMC,SAAS,GAAG,IAAID,IAAI,CAACD,SAAS,CAACG,OAAO,CAAC,CAAC,GAA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gB,CAACG,MAAM,EAAE4D,MAAM,CAAC;AAC/C,CAAC;AAACC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ export declare class WaitingHealthyClusterAbortedError extends WebinyError {
3
+ constructor(message?: string);
4
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
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 {
9
+ constructor(message) {
10
+ super({
11
+ message: message || `Waiting for the cluster to become healthy was aborted.`,
12
+ code: "WAITING_HEALTHY_CLUSTER_ABORTED"
13
+ });
14
+ }
15
+ }
16
+ exports.WaitingHealthyClusterAbortedError = WaitingHealthyClusterAbortedError;
17
+
18
+ //# sourceMappingURL=WaitingHealthyClusterAbortedError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","require","WaitingHealthyClusterAbortedError","WebinyError","constructor","message","code","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,iCAAiC,SAASC,kBAAW,CAAC;EACxDC,WAAWA,CAACC,OAAgB,EAAE;IACjC,KAAK,CAAC;MACFA,OAAO,EAAEA,OAAO,IAAI,wDAAwD;MAC5EC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ;AAACC,OAAA,CAAAL,iCAAA,GAAAA,iCAAA","ignoreList":[]}
@@ -0,0 +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";
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _WaitingHealthyClusterAbortedError = require("./WaitingHealthyClusterAbortedError");
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
+ });
50
+
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_WaitingHealthyClusterAbortedError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_UnhealthyClusterError","_WaitUntilHealthy","_reason"],"sources":["index.ts"],"sourcesContent":["export * from \"./WaitingHealthyClusterAbortedError\";\nexport * from \"./UnhealthyClusterError\";\nexport * from \"./WaitUntilHealthy\";\nexport * from \"./UnhealthyClusterError\";\nexport * from \"./WaitUntilHealthy\";\nexport * from \"./reason\";\n"],"mappings":";;;;;AAAA,IAAAA,kCAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kCAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kCAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kCAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,sBAAA,GAAAT,OAAA;AAEAC,MAAA,CAAAC,IAAA,CAAAO,sBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,sBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,sBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AADA,IAAAM,iBAAA,GAAAV,OAAA;AAEAC,MAAA,CAAAC,IAAA,CAAAQ,iBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,iBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,iBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,OAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,OAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,OAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,OAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import type { ElasticsearchCatClusterHealthStatus } from "../../../operations";
2
+ import type { IReason } from "./IReason";
3
+ export interface IClusterHealthReasonParams {
4
+ minimum: ElasticsearchCatClusterHealthStatus;
5
+ current: ElasticsearchCatClusterHealthStatus;
6
+ description?: string;
7
+ }
8
+ export declare class ClusterHealthReason implements IReason {
9
+ readonly name = "clusterHealth";
10
+ readonly minimum: ElasticsearchCatClusterHealthStatus;
11
+ readonly current: ElasticsearchCatClusterHealthStatus;
12
+ readonly description?: string;
13
+ constructor(params: IClusterHealthReasonParams);
14
+ }
15
+ export declare const createClusterHealthStatusReason: (params: IClusterHealthReasonParams) => ClusterHealthReason;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createClusterHealthStatusReason = exports.ClusterHealthReason = void 0;
7
+ class ClusterHealthReason {
8
+ name = "clusterHealth";
9
+ constructor(params) {
10
+ this.minimum = params.minimum;
11
+ this.current = params.current;
12
+ this.description = params.description;
13
+ }
14
+ }
15
+ exports.ClusterHealthReason = ClusterHealthReason;
16
+ const createClusterHealthStatusReason = params => {
17
+ return new ClusterHealthReason(params);
18
+ };
19
+ exports.createClusterHealthStatusReason = createClusterHealthStatusReason;
20
+
21
+ //# sourceMappingURL=ClusterHealthReason.js.map