@webiny/api-opensearch 6.3.0 → 6.4.0-beta.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.
Files changed (139) hide show
  1. package/client.js +52 -62
  2. package/client.js.map +1 -1
  3. package/cursors.js +20 -32
  4. package/cursors.js.map +1 -1
  5. package/db/entity.js +14 -16
  6. package/db/entity.js.map +1 -1
  7. package/db/index.js +0 -2
  8. package/db/table.js +10 -14
  9. package/db/table.js.map +1 -1
  10. package/db/types.js +0 -3
  11. package/exports/api/opensearch.js +0 -2
  12. package/features/OpenSearchClient/OpenSearchClient.js +13 -10
  13. package/features/OpenSearchClient/OpenSearchClient.js.map +1 -1
  14. package/features/OpenSearchClient/abstraction.js +2 -1
  15. package/features/OpenSearchClient/abstraction.js.map +1 -1
  16. package/features/OpenSearchClient/feature.js +6 -5
  17. package/features/OpenSearchClient/feature.js.map +1 -1
  18. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +8 -9
  19. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -1
  20. package/features/OpenSearchClientFactory/abstraction.js +2 -1
  21. package/features/OpenSearchClientFactory/abstraction.js.map +1 -1
  22. package/features/OpenSearchClientFactory/feature.js +6 -5
  23. package/features/OpenSearchClientFactory/feature.js.map +1 -1
  24. package/features/OpenSearchContext/OpenSearchContext.js +11 -10
  25. package/features/OpenSearchContext/OpenSearchContext.js.map +1 -1
  26. package/features/OpenSearchContext/abstraction.js +2 -1
  27. package/features/OpenSearchContext/abstraction.js.map +1 -1
  28. package/features/OpenSearchContext/feature.js +7 -8
  29. package/features/OpenSearchContext/feature.js.map +1 -1
  30. package/index.js +14 -16
  31. package/index.js.map +1 -1
  32. package/indexConfiguration/base.js +25 -26
  33. package/indexConfiguration/base.js.map +1 -1
  34. package/indexConfiguration/common.js +39 -41
  35. package/indexConfiguration/common.js.map +1 -1
  36. package/indexConfiguration/index.js +0 -2
  37. package/indexPrefix.js +2 -3
  38. package/indexPrefix.js.map +1 -1
  39. package/indices.js +8 -16
  40. package/indices.js.map +1 -1
  41. package/limit.js +5 -27
  42. package/limit.js.map +1 -1
  43. package/normalize.js +50 -49
  44. package/normalize.js.map +1 -1
  45. package/operations/OpenSearchCatHealth.js +24 -25
  46. package/operations/OpenSearchCatHealth.js.map +1 -1
  47. package/operations/OpenSearchCatNodes.js +22 -23
  48. package/operations/OpenSearchCatNodes.js.map +1 -1
  49. package/operations/index.js +0 -2
  50. package/operations/stripConnectionFromException.js +11 -14
  51. package/operations/stripConnectionFromException.js.map +1 -1
  52. package/operations/types.js +6 -5
  53. package/operations/types.js.map +1 -1
  54. package/operators.js +20 -7
  55. package/operators.js.map +1 -1
  56. package/package.json +11 -11
  57. package/plugins/definition/OpenSearchBodyModifierPlugin.js +12 -13
  58. package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +1 -1
  59. package/plugins/definition/OpenSearchFieldPlugin.js +43 -60
  60. package/plugins/definition/OpenSearchFieldPlugin.js.map +1 -1
  61. package/plugins/definition/OpenSearchIndexPlugin.js +12 -13
  62. package/plugins/definition/OpenSearchIndexPlugin.js.map +1 -1
  63. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +5 -5
  64. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +1 -1
  65. package/plugins/definition/OpenSearchQueryModifierPlugin.js +12 -13
  66. package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +1 -1
  67. package/plugins/definition/OpenSearchSortModifierPlugin.js +12 -13
  68. package/plugins/definition/OpenSearchSortModifierPlugin.js.map +1 -1
  69. package/plugins/definition/index.js +0 -2
  70. package/plugins/index.js +0 -2
  71. package/plugins/operator/andIn.js +20 -28
  72. package/plugins/operator/andIn.js.map +1 -1
  73. package/plugins/operator/between.js +21 -27
  74. package/plugins/operator/between.js.map +1 -1
  75. package/plugins/operator/contains.js +21 -19
  76. package/plugins/operator/contains.js.map +1 -1
  77. package/plugins/operator/equal.js +27 -44
  78. package/plugins/operator/equal.js.map +1 -1
  79. package/plugins/operator/gt.js +18 -18
  80. package/plugins/operator/gt.js.map +1 -1
  81. package/plugins/operator/gte.js +18 -18
  82. package/plugins/operator/gte.js.map +1 -1
  83. package/plugins/operator/in.js +18 -24
  84. package/plugins/operator/in.js.map +1 -1
  85. package/plugins/operator/index.js +0 -2
  86. package/plugins/operator/lt.js +18 -18
  87. package/plugins/operator/lt.js.map +1 -1
  88. package/plugins/operator/lte.js +18 -18
  89. package/plugins/operator/lte.js.map +1 -1
  90. package/plugins/operator/not.js +29 -36
  91. package/plugins/operator/not.js.map +1 -1
  92. package/plugins/operator/notBetween.js +21 -27
  93. package/plugins/operator/notBetween.js.map +1 -1
  94. package/plugins/operator/notContains.js +21 -19
  95. package/plugins/operator/notContains.js.map +1 -1
  96. package/plugins/operator/notIn.js +18 -22
  97. package/plugins/operator/notIn.js.map +1 -1
  98. package/plugins/operator/notStartsWith.js +16 -18
  99. package/plugins/operator/notStartsWith.js.map +1 -1
  100. package/plugins/operator/startsWith.js +16 -18
  101. package/plugins/operator/startsWith.js.map +1 -1
  102. package/sharedIndex.js +2 -3
  103. package/sharedIndex.js.map +1 -1
  104. package/sort.js +29 -58
  105. package/sort.js.map +1 -1
  106. package/types.js +5 -65
  107. package/types.js.map +1 -1
  108. package/utils/createIndex.js +56 -78
  109. package/utils/createIndex.js.map +1 -1
  110. package/utils/index.js +0 -2
  111. package/utils/waitUntilHealthy/UnhealthyClusterError.js +8 -7
  112. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
  113. package/utils/waitUntilHealthy/WaitUntilHealthy.js +111 -141
  114. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
  115. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +8 -7
  116. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
  117. package/utils/waitUntilHealthy/index.js +0 -2
  118. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +9 -10
  119. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
  120. package/utils/waitUntilHealthy/reason/IReason.js +0 -3
  121. package/utils/waitUntilHealthy/reason/MemoryReason.js +9 -10
  122. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
  123. package/utils/waitUntilHealthy/reason/ProcessorReason.js +9 -10
  124. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
  125. package/utils/waitUntilHealthy/reason/index.js +0 -2
  126. package/where.js +41 -74
  127. package/where.js.map +1 -1
  128. package/db/index.js.map +0 -1
  129. package/db/types.js.map +0 -1
  130. package/exports/api/opensearch.js.map +0 -1
  131. package/indexConfiguration/index.js.map +0 -1
  132. package/operations/index.js.map +0 -1
  133. package/plugins/definition/index.js.map +0 -1
  134. package/plugins/index.js.map +0 -1
  135. package/plugins/operator/index.js.map +0 -1
  136. package/utils/index.js.map +0 -1
  137. package/utils/waitUntilHealthy/index.js.map +0 -1
  138. package/utils/waitUntilHealthy/reason/IReason.js.map +0 -1
  139. package/utils/waitUntilHealthy/reason/index.js.map +0 -1
@@ -1,88 +1,66 @@
1
1
  import { getLastAddedIndexPlugin } from "../indices.js";
2
- import WebinyError from "@webiny/error";
3
- const indexExists = async params => {
4
- const {
5
- client,
6
- index,
7
- onExists
8
- } = params;
9
- try {
10
- const response = await client.indices.exists({
11
- index,
12
- ignore_unavailable: false,
13
- allow_no_indices: true,
14
- include_defaults: true,
15
- flat_settings: false,
16
- local: false
17
- });
18
- if (!response.body) {
19
- return false;
2
+ import _webiny_error from "@webiny/error";
3
+ const indexExists = async (params)=>{
4
+ const { client, index, onExists } = params;
5
+ try {
6
+ const response = await client.indices.exists({
7
+ index,
8
+ ignore_unavailable: false,
9
+ allow_no_indices: true,
10
+ include_defaults: true,
11
+ flat_settings: false,
12
+ local: false
13
+ });
14
+ if (!response.body) return false;
15
+ if (onExists) onExists();
16
+ return true;
17
+ } catch {
18
+ console.error(`Could not determine if the index "${index}" exists.`);
20
19
  }
21
- if (onExists) {
22
- onExists();
20
+ return false;
21
+ };
22
+ const indexCreate = async (params)=>{
23
+ const { client, index, plugin, tenant, type, onError } = params;
24
+ try {
25
+ await client.indices.create({
26
+ index,
27
+ body: {
28
+ ...plugin.body
29
+ }
30
+ });
31
+ } catch (ex) {
32
+ let error = ex;
33
+ if (onError) error = onError(ex);
34
+ throw new _webiny_error(error.message || `Could not create OpenSearch index for the ${type}.`, error.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
35
+ error: {
36
+ ...error,
37
+ message: error.message,
38
+ code: error.code,
39
+ data: error.data
40
+ },
41
+ type,
42
+ tenant,
43
+ index,
44
+ body: plugin.body
45
+ });
23
46
  }
24
- return true;
25
- } catch {
26
- console.error(`Could not determine if the index "${index}" exists.`);
27
- }
28
- return false;
29
47
  };
30
- const indexCreate = async params => {
31
- const {
32
- client,
33
- index,
34
- plugin,
35
- tenant,
36
- type,
37
- onError
38
- } = params;
39
- try {
40
- await client.indices.create({
41
- index,
42
- body: {
43
- ...plugin.body
44
- }
48
+ const createIndex = async (params)=>{
49
+ const { plugins, type, onExists } = params;
50
+ const plugin = getLastAddedIndexPlugin({
51
+ container: plugins,
52
+ type
45
53
  });
46
- } catch (ex) {
47
- let error = ex;
48
- if (onError) {
49
- error = onError(ex);
54
+ const exists = await indexExists(params);
55
+ if (exists) {
56
+ if (onExists) onExists();
57
+ return;
50
58
  }
51
- throw new WebinyError(error.message || `Could not create OpenSearch index for the ${type}.`, error.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
52
- error: {
53
- ...error,
54
- message: error.message,
55
- code: error.code,
56
- data: error.data
57
- },
58
- type,
59
- tenant,
60
- index,
61
- body: plugin.body
59
+ await indexCreate({
60
+ ...params,
61
+ plugin
62
62
  });
63
- }
64
- };
65
- export const createIndex = async params => {
66
- const {
67
- plugins,
68
- type,
69
- onExists
70
- } = params;
71
- const plugin = getLastAddedIndexPlugin({
72
- container: plugins,
73
- type
74
- });
75
- const exists = await indexExists(params);
76
- if (exists) {
77
- if (onExists) {
78
- onExists();
79
- }
80
- return;
81
- }
82
- await indexCreate({
83
- ...params,
84
- plugin
85
- });
86
63
  };
64
+ export { createIndex };
87
65
 
88
66
  //# sourceMappingURL=createIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getLastAddedIndexPlugin","WebinyError","indexExists","params","client","index","onExists","response","indices","exists","ignore_unavailable","allow_no_indices","include_defaults","flat_settings","local","body","console","error","indexCreate","plugin","tenant","type","onError","create","ex","message","code","data","createIndex","plugins","container"],"sources":["createIndex.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { getLastAddedIndexPlugin } from \"~/indices.js\";\nimport type { OpenSearchIndexPlugin } from \"~/plugins/index.js\";\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 {\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 plugin: OpenSearchIndexPlugin;\n onError?: OnError;\n}\n\nconst indexCreate = async (params: IndexCreateParams): Promise<void> => {\n const { client, index, plugin, tenant, 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 OpenSearch index for the ${type}.`,\n error.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data\n },\n type,\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 index: string;\n onExists?: OnExists;\n onError?: OnError;\n}\n\nexport const createIndex = async (params: CreateIndexParams): Promise<void> => {\n const { plugins, type, onExists } = params;\n const plugin = getLastAddedIndexPlugin<OpenSearchIndexPlugin>({\n container: plugins,\n type\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,SAASA,uBAAuB;AAEhC,OAAOC,WAAW,MAAM,eAAe;AAgBvC,MAAMC,WAAW,GAAG,MAAOC,MAAyB,IAAuB;EACvE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAE1C,IAAI;IACA,MAAMI,QAAQ,GAAG,MAAMH,MAAM,CAACI,OAAO,CAACC,MAAM,CAAC;MACzCJ,KAAK;MACLK,kBAAkB,EAAE,KAAK;MACzBC,gBAAgB,EAAE,IAAI;MACtBC,gBAAgB,EAAE,IAAI;MACtBC,aAAa,EAAE,KAAK;MACpBC,KAAK,EAAE;IACX,CAAC,CAAC;IACF,IAAI,CAACP,QAAQ,CAACQ,IAAI,EAAE;MAChB,OAAO,KAAK;IAChB;IACA,IAAIT,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA,OAAO,IAAI;EACf,CAAC,CAAC,MAAM;IACJU,OAAO,CAACC,KAAK,CAAC,qCAAqCZ,KAAK,WAAW,CAAC;EACxE;EACA,OAAO,KAAK;AAChB,CAAC;AAWD,MAAMa,WAAW,GAAG,MAAOf,MAAyB,IAAoB;EACpE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEc,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAQ,CAAC,GAAGnB,MAAM;EAE/D,IAAI;IACA,MAAMC,MAAM,CAACI,OAAO,CAACe,MAAM,CAAC;MACxBlB,KAAK;MACLU,IAAI,EAAE;QACF,GAAGI,MAAM,CAACJ;MACd;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOS,EAAE,EAAE;IACT,IAAIP,KAAK,GAAGO,EAAE;IACd,IAAIF,OAAO,EAAE;MACTL,KAAK,GAAGK,OAAO,CAACE,EAAE,CAAC;IACvB;IACA,MAAM,IAAIvB,WAAW,CACjBgB,KAAK,CAACQ,OAAO,IAAI,6CAA6CJ,IAAI,GAAG,EACrEJ,KAAK,CAACS,IAAI,IAAI,+BAA+B,EAC7C;MACIT,KAAK,EAAE;QACH,GAAGA,KAAK;QACRQ,OAAO,EAAER,KAAK,CAACQ,OAAO;QACtBC,IAAI,EAAET,KAAK,CAACS,IAAI;QAChBC,IAAI,EAAEV,KAAK,CAACU;MAChB,CAAC;MACDN,IAAI;MACJD,MAAM;MACNf,KAAK;MACLU,IAAI,EAAEI,MAAM,CAACJ;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAYD,OAAO,MAAMa,WAAW,GAAG,MAAOzB,MAAyB,IAAoB;EAC3E,MAAM;IAAE0B,OAAO;IAAER,IAAI;IAAEf;EAAS,CAAC,GAAGH,MAAM;EAC1C,MAAMgB,MAAM,GAAGnB,uBAAuB,CAAwB;IAC1D8B,SAAS,EAAED,OAAO;IAClBR;EACJ,CAAC,CAAC;EAEF,MAAMZ,MAAM,GAAG,MAAMP,WAAW,CAACC,MAAM,CAAC;EACxC,IAAIM,MAAM,EAAE;IACR,IAAIH,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA;EACJ;EAEA,MAAMY,WAAW,CAAC;IACd,GAAGf,MAAM;IACTgB;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/createIndex.js","sources":["../../src/utils/createIndex.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { getLastAddedIndexPlugin } from \"~/indices.js\";\nimport type { OpenSearchIndexPlugin } from \"~/plugins/index.js\";\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 {\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 plugin: OpenSearchIndexPlugin;\n onError?: OnError;\n}\n\nconst indexCreate = async (params: IndexCreateParams): Promise<void> => {\n const { client, index, plugin, tenant, 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 OpenSearch index for the ${type}.`,\n error.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data\n },\n type,\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 index: string;\n onExists?: OnExists;\n onError?: OnError;\n}\n\nexport const createIndex = async (params: CreateIndexParams): Promise<void> => {\n const { plugins, type, onExists } = params;\n const plugin = getLastAddedIndexPlugin<OpenSearchIndexPlugin>({\n container: plugins,\n type\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"],"names":["indexExists","params","client","index","onExists","response","console","indexCreate","plugin","tenant","type","onError","ex","error","WebinyError","createIndex","plugins","getLastAddedIndexPlugin","exists"],"mappings":";;AAoBA,MAAMA,cAAc,OAAOC;IACvB,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGH;IAEpC,IAAI;QACA,MAAMI,WAAW,MAAMH,OAAO,OAAO,CAAC,MAAM,CAAC;YACzCC;YACA,oBAAoB;YACpB,kBAAkB;YAClB,kBAAkB;YAClB,eAAe;YACf,OAAO;QACX;QACA,IAAI,CAACE,SAAS,IAAI,EACd,OAAO;QAEX,IAAID,UACAA;QAEJ,OAAO;IACX,EAAE,OAAM;QACJE,QAAQ,KAAK,CAAC,CAAC,kCAAkC,EAAEH,MAAM,SAAS,CAAC;IACvE;IACA,OAAO;AACX;AAWA,MAAMI,cAAc,OAAON;IACvB,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEK,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGV;IAEzD,IAAI;QACA,MAAMC,OAAO,OAAO,CAAC,MAAM,CAAC;YACxBC;YACA,MAAM;gBACF,GAAGK,OAAO,IAAI;YAClB;QACJ;IACJ,EAAE,OAAOI,IAAI;QACT,IAAIC,QAAQD;QACZ,IAAID,SACAE,QAAQF,QAAQC;QAEpB,MAAM,IAAIE,cACND,MAAM,OAAO,IAAI,CAAC,0CAA0C,EAAEH,KAAK,CAAC,CAAC,EACrEG,MAAM,IAAI,IAAI,iCACd;YACI,OAAO;gBACH,GAAGA,KAAK;gBACR,SAASA,MAAM,OAAO;gBACtB,MAAMA,MAAM,IAAI;gBAChB,MAAMA,MAAM,IAAI;YACpB;YACAH;YACAD;YACAN;YACA,MAAMK,OAAO,IAAI;QACrB;IAER;AACJ;AAYO,MAAMO,cAAc,OAAOd;IAC9B,MAAM,EAAEe,OAAO,EAAEN,IAAI,EAAEN,QAAQ,EAAE,GAAGH;IACpC,MAAMO,SAASS,wBAA+C;QAC1D,WAAWD;QACXN;IACJ;IAEA,MAAMQ,SAAS,MAAMlB,YAAYC;IACjC,IAAIiB,QAAQ;QACR,IAAId,UACAA;QAEJ;IACJ;IAEA,MAAMG,YAAY;QACd,GAAGN,MAAM;QACTO;IACJ;AACJ"}
package/utils/index.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from "./waitUntilHealthy/index.js";
2
2
  export * from "./createIndex.js";
3
-
4
- //# sourceMappingURL=index.js.map
@@ -1,11 +1,12 @@
1
1
  import { WebinyError } from "@webiny/error";
2
- export class UnhealthyClusterError extends WebinyError {
3
- constructor(maxWaitingTime) {
4
- super({
5
- message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,
6
- code: "UNHEALTHY_CLUSTER"
7
- });
8
- }
2
+ class UnhealthyClusterError extends WebinyError {
3
+ constructor(maxWaitingTime){
4
+ super({
5
+ message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,
6
+ code: "UNHEALTHY_CLUSTER"
7
+ });
8
+ }
9
9
  }
10
+ export { UnhealthyClusterError };
10
11
 
11
12
  //# sourceMappingURL=UnhealthyClusterError.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","UnhealthyClusterError","constructor","maxWaitingTime","message","code"],"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,SAASA,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAAC;EAC5CE,WAAWA,CAACC,cAAsB,EAAE;IACvC,KAAK,CAAC;MACFC,OAAO,EAAE,qCAAqCD,cAAc,WAAW;MACvEE,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"utils/waitUntilHealthy/UnhealthyClusterError.js","sources":["../../../src/utils/waitUntilHealthy/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"],"names":["UnhealthyClusterError","WebinyError","maxWaitingTime"],"mappings":";AAEO,MAAMA,8BAA8BC;IACvC,YAAmBC,cAAsB,CAAE;QACvC,KAAK,CAAC;YACF,SAAS,CAAC,kCAAkC,EAAEA,eAAe,SAAS,CAAC;YACvE,MAAM;QACV;IACJ;AACJ"}
@@ -6,156 +6,126 @@ import { createClusterHealthStatusReason, createMemoryReason, createProcessorRea
6
6
  import { WaitingHealthyClusterAbortedError } from "./WaitingHealthyClusterAbortedError.js";
7
7
  const WAITING_TIME_STEP = 10;
8
8
  class WaitUntilHealthy {
9
- aborted = false;
10
- constructor(client, options) {
11
- this.client = client;
12
- this.options = options;
13
- this.catHealth = new OpenSearchCatHealth(this.client);
14
- this.catNodes = new OpenSearchCatNodes(this.client);
15
- }
16
- abort() {
17
- this.aborted = true;
18
- }
19
- /**
20
- * @throws UnhealthyClusterError
21
- * @throws WaitingHealthyClusterAbortedError
22
- */
23
- async wait(options) {
24
- if (this.aborted) {
25
- throw new WaitingHealthyClusterAbortedError(`Waiting for the cluster to become healthy was aborted even before it started.`);
9
+ constructor(client, options){
10
+ this.aborted = false;
11
+ this.client = client;
12
+ this.options = options;
13
+ this.catHealth = new OpenSearchCatHealth(this.client);
14
+ this.catNodes = new OpenSearchCatNodes(this.client);
26
15
  }
27
- const startedAt = new Date();
28
- const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);
29
- const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;
30
- let runs = 1;
31
- let waitingReason;
32
- while (waitingReason = await this.shouldWait()) {
33
- if (new Date() >= mustEndAt) {
34
- if (options?.onTimeout) {
35
- await options.onTimeout({
36
- startedAt,
37
- mustEndAt,
38
- waitingTimeStep,
39
- waitingReason,
16
+ abort() {
17
+ this.aborted = true;
18
+ }
19
+ async wait(options) {
20
+ if (this.aborted) throw new WaitingHealthyClusterAbortedError("Waiting for the cluster to become healthy was aborted even before it started.");
21
+ const startedAt = new Date();
22
+ const mustEndAt = new Date(startedAt.getTime() + 1000 * this.options.maxWaitingTime);
23
+ const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;
24
+ let runs = 1;
25
+ let waitingReason;
26
+ while(waitingReason = await this.shouldWait()){
27
+ if (new Date() >= mustEndAt) {
28
+ if (options?.onTimeout) await options.onTimeout({
29
+ startedAt,
30
+ mustEndAt,
31
+ waitingTimeStep,
32
+ waitingReason,
33
+ runs
34
+ });
35
+ throw new UnhealthyClusterError(this.options.maxWaitingTime);
36
+ }
37
+ if (options?.onUnhealthy) await options.onUnhealthy({
38
+ startedAt,
39
+ mustEndAt,
40
+ waitingTimeStep,
41
+ waitingReason,
42
+ runs
43
+ });
44
+ if (this.aborted) throw new WaitingHealthyClusterAbortedError();
45
+ runs++;
46
+ await new Promise((resolve)=>{
47
+ setTimeout(resolve, 1000 * waitingTimeStep);
48
+ });
49
+ }
50
+ const runningTime = new Date().getTime() - startedAt.getTime();
51
+ return {
52
+ runningTime,
40
53
  runs
41
- });
54
+ };
55
+ }
56
+ async shouldWait() {
57
+ let health;
58
+ let nodes;
59
+ try {
60
+ health = await this.catHealth.getHealth();
61
+ } catch (ex) {
62
+ return createClusterHealthStatusReason({
63
+ description: ex.message,
64
+ minimum: this.options.minClusterHealthStatus,
65
+ current: OpenSearchCatClusterHealthStatus.Red
66
+ });
42
67
  }
43
- throw new UnhealthyClusterError(this.options.maxWaitingTime);
44
- } else if (options?.onUnhealthy) {
45
- await options.onUnhealthy({
46
- startedAt,
47
- mustEndAt,
48
- waitingTimeStep,
49
- waitingReason,
50
- runs
68
+ try {
69
+ nodes = await this.catNodes.getNodes();
70
+ } catch (ex) {
71
+ return createClusterHealthStatusReason({
72
+ description: ex.message,
73
+ minimum: this.options.minClusterHealthStatus,
74
+ current: OpenSearchCatClusterHealthStatus.Red
75
+ });
76
+ }
77
+ const currentStatus = this.toClusterHealthStatus(health.status);
78
+ const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);
79
+ const minClusterHealthStatus = this.transformClusterHealthStatus(this.options.minClusterHealthStatus);
80
+ if (clusterHealthStatus > minClusterHealthStatus) return createClusterHealthStatusReason({
81
+ minimum: this.options.minClusterHealthStatus,
82
+ current: currentStatus
51
83
  });
52
- }
53
- /**
54
- * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.
55
- */
56
- if (this.aborted) {
57
- throw new WaitingHealthyClusterAbortedError();
58
- }
59
- runs++;
60
- await new Promise(resolve => {
61
- setTimeout(resolve, waitingTimeStep * 1000);
62
- });
63
- }
64
- const runningTime = new Date().getTime() - startedAt.getTime();
65
- return {
66
- runningTime,
67
- runs
68
- };
69
- }
70
- async shouldWait() {
71
- let health;
72
- let nodes;
73
- try {
74
- health = await this.catHealth.getHealth();
75
- } catch (ex) {
76
- return createClusterHealthStatusReason({
77
- description: ex.message,
78
- minimum: this.options.minClusterHealthStatus,
79
- current: OpenSearchCatClusterHealthStatus.Red
80
- });
81
- }
82
- try {
83
- nodes = await this.catNodes.getNodes();
84
- } catch (ex) {
85
- return createClusterHealthStatusReason({
86
- description: ex.message,
87
- minimum: this.options.minClusterHealthStatus,
88
- current: OpenSearchCatClusterHealthStatus.Red
89
- });
90
- }
91
- const currentStatus = this.toClusterHealthStatus(health.status);
92
- const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);
93
- const minClusterHealthStatus = this.transformClusterHealthStatus(this.options.minClusterHealthStatus);
94
- if (clusterHealthStatus > minClusterHealthStatus) {
95
- return createClusterHealthStatusReason({
96
- minimum: this.options.minClusterHealthStatus,
97
- current: currentStatus
98
- });
99
- }
100
- const processorPercent = this.getProcessorPercent(nodes);
101
- if (processorPercent > this.options.maxProcessorPercent) {
102
- return createProcessorReason({
103
- maximum: this.options.maxProcessorPercent,
104
- current: processorPercent
105
- });
84
+ const processorPercent = this.getProcessorPercent(nodes);
85
+ if (processorPercent > this.options.maxProcessorPercent) return createProcessorReason({
86
+ maximum: this.options.maxProcessorPercent,
87
+ current: processorPercent
88
+ });
89
+ if (void 0 === this.options.maxRamPercent) return false;
90
+ const ramPercent = this.getRamPercent(nodes);
91
+ if (ramPercent > this.options.maxRamPercent) return createMemoryReason({
92
+ maximum: this.options.maxRamPercent,
93
+ current: ramPercent
94
+ });
95
+ return false;
106
96
  }
107
- /**
108
- * Possibly no max ram definition?
109
- */
110
- if (this.options.maxRamPercent === undefined) {
111
- return false;
97
+ getProcessorPercent(nodes) {
98
+ const total = nodes.reduce((total, node)=>total + parseFloat(node.cpu || "0"), 0);
99
+ return total / nodes.length;
112
100
  }
113
- const ramPercent = this.getRamPercent(nodes);
114
- if (ramPercent > this.options.maxRamPercent) {
115
- return createMemoryReason({
116
- maximum: this.options.maxRamPercent,
117
- current: ramPercent
118
- });
101
+ getRamPercent(nodes) {
102
+ const total = nodes.reduce((total, node)=>total + parseFloat(node["ram.percent"] || "0"), 0);
103
+ return total / nodes.length;
119
104
  }
120
- return false;
121
- }
122
- getProcessorPercent(nodes) {
123
- const total = nodes.reduce((total, node) => {
124
- return total + parseFloat(node.cpu || "0");
125
- }, 0);
126
- return total / nodes.length;
127
- }
128
- getRamPercent(nodes) {
129
- const total = nodes.reduce((total, node) => {
130
- return total + parseFloat(node["ram.percent"] || "0");
131
- }, 0);
132
- return total / nodes.length;
133
- }
134
- toClusterHealthStatus(status) {
135
- switch (status) {
136
- case "green":
137
- return OpenSearchCatClusterHealthStatus.Green;
138
- case "yellow":
139
- return OpenSearchCatClusterHealthStatus.Yellow;
140
- default:
141
- return OpenSearchCatClusterHealthStatus.Red;
105
+ toClusterHealthStatus(status) {
106
+ switch(status){
107
+ case "green":
108
+ return OpenSearchCatClusterHealthStatus.Green;
109
+ case "yellow":
110
+ return OpenSearchCatClusterHealthStatus.Yellow;
111
+ default:
112
+ return OpenSearchCatClusterHealthStatus.Red;
113
+ }
142
114
  }
143
- }
144
- transformClusterHealthStatus(status) {
145
- switch (status) {
146
- case OpenSearchCatClusterHealthStatus.Green:
147
- return 1;
148
- case OpenSearchCatClusterHealthStatus.Yellow:
149
- return 2;
150
- case OpenSearchCatClusterHealthStatus.Red:
151
- return 3;
152
- default:
153
- return 99;
115
+ transformClusterHealthStatus(status) {
116
+ switch(status){
117
+ case OpenSearchCatClusterHealthStatus.Green:
118
+ return 1;
119
+ case OpenSearchCatClusterHealthStatus.Yellow:
120
+ return 2;
121
+ case OpenSearchCatClusterHealthStatus.Red:
122
+ return 3;
123
+ default:
124
+ return 99;
125
+ }
154
126
  }
155
- }
156
127
  }
157
- export const createWaitUntilHealthy = (client, params) => {
158
- return new WaitUntilHealthy(client, params);
159
- };
128
+ const createWaitUntilHealthy = (client, params)=>new WaitUntilHealthy(client, params);
129
+ export { createWaitUntilHealthy };
160
130
 
161
131
  //# sourceMappingURL=WaitUntilHealthy.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchCatHealth","OpenSearchCatNodes","OpenSearchCatClusterHealthStatus","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","currentStatus","toClusterHealthStatus","status","clusterHealthStatus","transformClusterHealthStatus","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 { OpenSearchCatHealth } from \"~/operations/OpenSearchCatHealth.js\";\nimport { OpenSearchCatNodes } from \"~/operations/OpenSearchCatNodes.js\";\nimport type {\n IOpenSearchCatHealthResponse,\n IOpenSearchCatNodesResponse\n} from \"~/operations/types.js\";\nimport { OpenSearchCatClusterHealthStatus } 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 | OpenSearchCatClusterHealthStatus.Green\n | OpenSearchCatClusterHealthStatus.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: OpenSearchCatHealth;\n private readonly catNodes: OpenSearchCatNodes;\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 OpenSearchCatHealth(this.client);\n this.catNodes = new OpenSearchCatNodes(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: IOpenSearchCatHealthResponse;\n let nodes: IOpenSearchCatNodesResponse;\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: OpenSearchCatClusterHealthStatus.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: OpenSearchCatClusterHealthStatus.Red\n });\n }\n\n const currentStatus = this.toClusterHealthStatus(health.status);\n const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: currentStatus\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: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"] || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private toClusterHealthStatus(status?: string): OpenSearchCatClusterHealthStatus {\n switch (status) {\n case \"green\":\n return OpenSearchCatClusterHealthStatus.Green;\n case \"yellow\":\n return OpenSearchCatClusterHealthStatus.Yellow;\n default:\n return OpenSearchCatClusterHealthStatus.Red;\n }\n }\n\n private transformClusterHealthStatus(status: OpenSearchCatClusterHealthStatus): number {\n switch (status) {\n case OpenSearchCatClusterHealthStatus.Green:\n return 1;\n case OpenSearchCatClusterHealthStatus.Yellow:\n return 2;\n case OpenSearchCatClusterHealthStatus.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,mBAAmB;AAC5B,SAASC,kBAAkB;AAK3B,SAASC,gCAAgC;AACzC,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,mBAAmB,CAAC,IAAI,CAACY,MAAM,CAAC;IACrD,IAAI,CAACG,QAAQ,GAAG,IAAId,kBAAkB,CAAC,IAAI,CAACW,MAAM,CAAC;EACvD;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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IACnF,QAAQA,MAAM;MACV,KAAK5C,gCAAgC,CAAC6D,KAAK;QACvC,OAAO,CAAC;MACZ,KAAK7D,gCAAgC,CAAC8D,MAAM;QACxC,OAAO,CAAC;MACZ,KAAK9D,gCAAgC,CAACwC,GAAG;QACrC,OAAO,CAAC;MACZ;QACI,OAAO,EAAE;IACjB;EACJ;AACJ;AAIA,OAAO,MAAMuB,sBAAsB,GAAGA,CAClCrD,MAAc,EACdsD,MAA+B,KACZ;EACnB,OAAO,IAAIzD,gBAAgB,CAACG,MAAM,EAAEsD,MAAM,CAAC;AAC/C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/waitUntilHealthy/WaitUntilHealthy.js","sources":["../../../src/utils/waitUntilHealthy/WaitUntilHealthy.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport { OpenSearchCatHealth } from \"~/operations/OpenSearchCatHealth.js\";\nimport { OpenSearchCatNodes } from \"~/operations/OpenSearchCatNodes.js\";\nimport type {\n IOpenSearchCatHealthResponse,\n IOpenSearchCatNodesResponse\n} from \"~/operations/types.js\";\nimport { OpenSearchCatClusterHealthStatus } 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 | OpenSearchCatClusterHealthStatus.Green\n | OpenSearchCatClusterHealthStatus.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: OpenSearchCatHealth;\n private readonly catNodes: OpenSearchCatNodes;\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 OpenSearchCatHealth(this.client);\n this.catNodes = new OpenSearchCatNodes(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: IOpenSearchCatHealthResponse;\n let nodes: IOpenSearchCatNodesResponse;\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: OpenSearchCatClusterHealthStatus.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: OpenSearchCatClusterHealthStatus.Red\n });\n }\n\n const currentStatus = this.toClusterHealthStatus(health.status);\n const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: currentStatus\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: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"] || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private toClusterHealthStatus(status?: string): OpenSearchCatClusterHealthStatus {\n switch (status) {\n case \"green\":\n return OpenSearchCatClusterHealthStatus.Green;\n case \"yellow\":\n return OpenSearchCatClusterHealthStatus.Yellow;\n default:\n return OpenSearchCatClusterHealthStatus.Red;\n }\n }\n\n private transformClusterHealthStatus(status: OpenSearchCatClusterHealthStatus): number {\n switch (status) {\n case OpenSearchCatClusterHealthStatus.Green:\n return 1;\n case OpenSearchCatClusterHealthStatus.Yellow:\n return 2;\n case OpenSearchCatClusterHealthStatus.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"],"names":["WAITING_TIME_STEP","WaitUntilHealthy","client","options","OpenSearchCatHealth","OpenSearchCatNodes","WaitingHealthyClusterAbortedError","startedAt","Date","mustEndAt","waitingTimeStep","runs","waitingReason","UnhealthyClusterError","Promise","resolve","setTimeout","runningTime","health","nodes","ex","createClusterHealthStatusReason","OpenSearchCatClusterHealthStatus","currentStatus","clusterHealthStatus","minClusterHealthStatus","processorPercent","createProcessorReason","undefined","ramPercent","createMemoryReason","total","node","parseFloat","status","createWaitUntilHealthy","params"],"mappings":";;;;;;AAiBA,MAAMA,oBAAoB;AA0D1B,MAAMC;IASF,YAAmBC,MAAc,EAAEC,OAAg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ACY,OAAOC,OAChCD,QAAQE,WAAWD,KAAK,GAAG,IAAI,MACvC;QACH,OAAOD,QAAQZ,MAAM,MAAM;IAC/B;IAEQ,cAAcA,KAAkC,EAAU;QAC9D,MAAMY,QAAQZ,MAAM,MAAM,CAAS,CAACY,OAAOC,OAChCD,QAAQE,WAAWD,IAAI,CAAC,cAAc,IAAI,MAClD;QACH,OAAOD,QAAQZ,MAAM,MAAM;IAC/B;IAEQ,sBAAsBe,MAAe,EAAoC;QAC7E,OAAQA;YACJ,KAAK;gBACD,OAAOZ,iCAAiC,KAAK;YACjD,KAAK;gBACD,OAAOA,iCAAiC,MAAM;YAClD;gBACI,OAAOA,iCAAiC,GAAG;QACnD;IACJ;IAEQ,6BAA6BY,MAAwC,EAAU;QACnF,OAAQA;YACJ,KAAKZ,iCAAiC,KAAK;gBACvC,OAAO;YACX,KAAKA,iCAAiC,MAAM;gBACxC,OAAO;YACX,KAAKA,iCAAiC,GAAG;gBACrC,OAAO;YACX;gBACI,OAAO;QACf;IACJ;AACJ;AAIO,MAAMa,yBAAyB,CAClCjC,QACAkC,SAEO,IAAInC,iBAAiBC,QAAQkC"}
@@ -1,11 +1,12 @@
1
1
  import { WebinyError } from "@webiny/error";
2
- export class WaitingHealthyClusterAbortedError extends WebinyError {
3
- constructor(message) {
4
- super({
5
- message: message || `Waiting for the cluster to become healthy was aborted.`,
6
- code: "WAITING_HEALTHY_CLUSTER_ABORTED"
7
- });
8
- }
2
+ class WaitingHealthyClusterAbortedError extends WebinyError {
3
+ constructor(message){
4
+ super({
5
+ message: message || "Waiting for the cluster to become healthy was aborted.",
6
+ code: "WAITING_HEALTHY_CLUSTER_ABORTED"
7
+ });
8
+ }
9
9
  }
10
+ export { WaitingHealthyClusterAbortedError };
10
11
 
11
12
  //# sourceMappingURL=WaitingHealthyClusterAbortedError.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js","sources":["../../../src/utils/waitUntilHealthy/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"],"names":["WaitingHealthyClusterAbortedError","WebinyError","message"],"mappings":";AAEO,MAAMA,0CAA0CC;IACnD,YAAmBC,OAAgB,CAAE;QACjC,KAAK,CAAC;YACF,SAASA,WAAW;YACpB,MAAM;QACV;IACJ;AACJ"}
@@ -2,5 +2,3 @@ export * from "./WaitingHealthyClusterAbortedError.js";
2
2
  export * from "./UnhealthyClusterError.js";
3
3
  export * from "./WaitUntilHealthy.js";
4
4
  export * from "./reason/index.js";
5
-
6
- //# sourceMappingURL=index.js.map
@@ -1,13 +1,12 @@
1
- export class ClusterHealthReason {
2
- name = "clusterHealth";
3
- constructor(params) {
4
- this.minimum = params.minimum;
5
- this.current = params.current;
6
- this.description = params.description;
7
- }
1
+ class ClusterHealthReason {
2
+ constructor(params){
3
+ this.name = "clusterHealth";
4
+ this.minimum = params.minimum;
5
+ this.current = params.current;
6
+ this.description = params.description;
7
+ }
8
8
  }
9
- export const createClusterHealthStatusReason = params => {
10
- return new ClusterHealthReason(params);
11
- };
9
+ const createClusterHealthStatusReason = (params)=>new ClusterHealthReason(params);
10
+ export { ClusterHealthReason, createClusterHealthStatusReason };
12
11
 
13
12
  //# sourceMappingURL=ClusterHealthReason.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ClusterHealthReason","name","constructor","params","minimum","current","description","createClusterHealthStatusReason"],"sources":["ClusterHealthReason.ts"],"sourcesContent":["import type { OpenSearchCatClusterHealthStatus } from \"~/operations/index.js\";\nimport type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IClusterHealthReasonParams {\n minimum: OpenSearchCatClusterHealthStatus;\n current: OpenSearchCatClusterHealthStatus;\n description?: string;\n}\n\nexport class ClusterHealthReason implements IReason {\n public readonly name = \"clusterHealth\";\n public readonly minimum: OpenSearchCatClusterHealthStatus;\n public readonly current: OpenSearchCatClusterHealthStatus;\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
+ {"version":3,"file":"utils/waitUntilHealthy/reason/ClusterHealthReason.js","sources":["../../../../src/utils/waitUntilHealthy/reason/ClusterHealthReason.ts"],"sourcesContent":["import type { OpenSearchCatClusterHealthStatus } from \"~/operations/index.js\";\nimport type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IClusterHealthReasonParams {\n minimum: OpenSearchCatClusterHealthStatus;\n current: OpenSearchCatClusterHealthStatus;\n description?: string;\n}\n\nexport class ClusterHealthReason implements IReason {\n public readonly name = \"clusterHealth\";\n public readonly minimum: OpenSearchCatClusterHealthStatus;\n public readonly current: OpenSearchCatClusterHealthStatus;\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"],"names":["ClusterHealthReason","params","createClusterHealthStatusReason"],"mappings":"AASO,MAAMA;IAMT,YAAmBC,MAAkC,CAAE;aALvC,IAAI,GAAG;QAMnB,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;IACzC;AACJ;AAEO,MAAMC,kCAAkC,CAC3CD,SAEO,IAAID,oBAAoBC"}
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=IReason.js.map