plugin-elastic-report 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/ai/skills/elastic-report/SKILLS.md +32 -0
  2. package/client-v2.d.ts +2 -0
  3. package/client-v2.js +1 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/index.js +10 -0
  7. package/dist/client-v2/851.488fdbf5bc5b6a36.js +10 -0
  8. package/dist/client-v2/index.js +10 -0
  9. package/dist/externalVersion.js +20 -0
  10. package/dist/index.js +48 -0
  11. package/dist/locale/en-US.json +99 -0
  12. package/dist/locale/vi-VN.json +99 -0
  13. package/dist/locale/zh-CN.json +99 -0
  14. package/dist/node_modules/@elastic/elasticsearch/.dockerignore +11 -0
  15. package/dist/node_modules/@elastic/elasticsearch/LICENSE +202 -0
  16. package/dist/node_modules/@elastic/elasticsearch/NOTICE.txt +2 -0
  17. package/dist/node_modules/@elastic/elasticsearch/catalog-info.yaml +50 -0
  18. package/dist/node_modules/@elastic/elasticsearch/codecov.yml +14 -0
  19. package/dist/node_modules/@elastic/elasticsearch/index.d.ts +28 -0
  20. package/dist/node_modules/@elastic/elasticsearch/index.js +85525 -0
  21. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/async_search.d.ts +39 -0
  22. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/async_search.js +155 -0
  23. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/autoscaling.d.ts +39 -0
  24. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/autoscaling.js +130 -0
  25. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/bulk.d.ts +14 -0
  26. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/bulk.js +60 -0
  27. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/capabilities.d.ts +14 -0
  28. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/capabilities.js +43 -0
  29. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cat.d.ts +193 -0
  30. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cat.js +766 -0
  31. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ccr.d.ts +102 -0
  32. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ccr.js +395 -0
  33. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/clear_scroll.d.ts +14 -0
  34. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/clear_scroll.js +60 -0
  35. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/close_point_in_time.d.ts +14 -0
  36. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/close_point_in_time.js +56 -0
  37. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cluster.d.ts +123 -0
  38. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/cluster.js +482 -0
  39. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/connector.d.ts +245 -0
  40. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/connector.js +1121 -0
  41. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/count.d.ts +14 -0
  42. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/count.js +68 -0
  43. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/create.d.ts +14 -0
  44. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/create.js +53 -0
  45. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/dangling_indices.d.ts +32 -0
  46. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/dangling_indices.js +100 -0
  47. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete.d.ts +14 -0
  48. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete.js +46 -0
  49. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query.d.ts +14 -0
  50. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query.js +59 -0
  51. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query_rethrottle.d.ts +14 -0
  52. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_by_query_rethrottle.js +45 -0
  53. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_script.d.ts +14 -0
  54. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/delete_script.js +45 -0
  55. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/enrich.d.ts +46 -0
  56. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/enrich.js +169 -0
  57. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/eql.d.ts +39 -0
  58. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/eql.js +139 -0
  59. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/esql.d.ts +46 -0
  60. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/esql.js +170 -0
  61. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists.d.ts +14 -0
  62. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists.js +46 -0
  63. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists_source.d.ts +14 -0
  64. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/exists_source.js +46 -0
  65. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/explain.d.ts +14 -0
  66. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/explain.js +60 -0
  67. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/features.d.ts +25 -0
  68. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/features.js +75 -0
  69. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/field_caps.d.ts +14 -0
  70. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/field_caps.js +68 -0
  71. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/fleet.d.ts +50 -0
  72. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/fleet.js +211 -0
  73. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get.d.ts +14 -0
  74. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get.js +46 -0
  75. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script.d.ts +14 -0
  76. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script.js +45 -0
  77. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_context.d.ts +14 -0
  78. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_context.js +43 -0
  79. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_languages.d.ts +14 -0
  80. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_script_languages.js +43 -0
  81. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_source.d.ts +14 -0
  82. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/get_source.js +46 -0
  83. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/graph.d.ts +18 -0
  84. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/graph.js +70 -0
  85. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/health_report.d.ts +14 -0
  86. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/health_report.js +54 -0
  87. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ilm.d.ts +88 -0
  88. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ilm.js +329 -0
  89. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/index.d.ts +14 -0
  90. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/index.js +61 -0
  91. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/indices.d.ts +494 -0
  92. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/indices.js +2133 -0
  93. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/inference.d.ts +221 -0
  94. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/inference.js +1167 -0
  95. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/info.d.ts +14 -0
  96. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/info.js +43 -0
  97. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ingest.d.ts +95 -0
  98. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ingest.js +389 -0
  99. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/knn_search.d.ts +14 -0
  100. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/knn_search.js +59 -0
  101. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/license.d.ts +60 -0
  102. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/license.js +194 -0
  103. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/logstash.d.ts +32 -0
  104. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/logstash.js +118 -0
  105. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mget.d.ts +14 -0
  106. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mget.js +68 -0
  107. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/migration.d.ts +32 -0
  108. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/migration.js +107 -0
  109. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ml.d.ts +522 -0
  110. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ml.js +2468 -0
  111. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/monitoring.d.ts +18 -0
  112. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/monitoring.js +60 -0
  113. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch.d.ts +14 -0
  114. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch.js +60 -0
  115. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch_template.d.ts +14 -0
  116. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/msearch_template.js +60 -0
  117. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mtermvectors.d.ts +14 -0
  118. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/mtermvectors.js +68 -0
  119. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/nodes.d.ts +60 -0
  120. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/nodes.js +290 -0
  121. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/open_point_in_time.d.ts +14 -0
  122. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/open_point_in_time.js +59 -0
  123. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ping.d.ts +14 -0
  124. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ping.js +43 -0
  125. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/profiling.d.ts +39 -0
  126. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/profiling.js +135 -0
  127. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/put_script.d.ts +14 -0
  128. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/put_script.js +68 -0
  129. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/query_rules.d.ts +67 -0
  130. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/query_rules.js +260 -0
  131. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rank_eval.d.ts +14 -0
  132. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rank_eval.js +67 -0
  133. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex.d.ts +14 -0
  134. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex.js +56 -0
  135. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex_rethrottle.d.ts +14 -0
  136. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/reindex_rethrottle.js +45 -0
  137. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/render_search_template.d.ts +14 -0
  138. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/render_search_template.js +68 -0
  139. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rollup.d.ts +67 -0
  140. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/rollup.js +263 -0
  141. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scripts_painless_execute.d.ts +14 -0
  142. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scripts_painless_execute.js +57 -0
  143. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scroll.d.ts +14 -0
  144. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/scroll.js +59 -0
  145. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search.d.ts +14 -0
  146. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search.js +75 -0
  147. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_application.d.ts +81 -0
  148. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_application.js +313 -0
  149. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_mvt.d.ts +14 -0
  150. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_mvt.js +63 -0
  151. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_shards.d.ts +14 -0
  152. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_shards.js +54 -0
  153. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_template.d.ts +14 -0
  154. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/search_template.js +68 -0
  155. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/searchable_snapshots.d.ts +39 -0
  156. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/searchable_snapshots.js +167 -0
  157. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/security.d.ts +459 -0
  158. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/security.js +1982 -0
  159. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/shutdown.d.ts +32 -0
  160. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/shutdown.js +125 -0
  161. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/simulate.d.ts +18 -0
  162. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/simulate.js +78 -0
  163. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/slm.d.ts +74 -0
  164. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/slm.js +253 -0
  165. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/snapshot.d.ts +102 -0
  166. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/snapshot.js +410 -0
  167. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/sql.d.ts +53 -0
  168. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/sql.js +205 -0
  169. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ssl.d.ts +18 -0
  170. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/ssl.js +54 -0
  171. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/streams.d.ts +32 -0
  172. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/streams.js +96 -0
  173. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/synonyms.d.ts +60 -0
  174. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/synonyms.js +223 -0
  175. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/tasks.d.ts +32 -0
  176. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/tasks.js +109 -0
  177. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/terms_enum.d.ts +14 -0
  178. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/terms_enum.js +59 -0
  179. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/termvectors.d.ts +14 -0
  180. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/termvectors.js +68 -0
  181. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/text_structure.d.ts +39 -0
  182. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/text_structure.js +148 -0
  183. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/transform.d.ts +101 -0
  184. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/transform.js +386 -0
  185. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update.d.ts +14 -0
  186. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update.js +60 -0
  187. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query.d.ts +14 -0
  188. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query.js +59 -0
  189. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query_rethrottle.d.ts +14 -0
  190. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/update_by_query_rethrottle.js +45 -0
  191. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/watcher.d.ts +102 -0
  192. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/watcher.js +405 -0
  193. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/xpack.d.ts +25 -0
  194. package/dist/node_modules/@elastic/elasticsearch/lib/api/api/xpack.js +75 -0
  195. package/dist/node_modules/@elastic/elasticsearch/lib/api/index.d.ts +265 -0
  196. package/dist/node_modules/@elastic/elasticsearch/lib/api/index.js +632 -0
  197. package/dist/node_modules/@elastic/elasticsearch/lib/api/types.d.ts +19933 -0
  198. package/dist/node_modules/@elastic/elasticsearch/lib/api/types.js +21 -0
  199. package/dist/node_modules/@elastic/elasticsearch/lib/api/typesWithBodyKey.d.ts +20606 -0
  200. package/dist/node_modules/@elastic/elasticsearch/lib/api/typesWithBodyKey.js +21 -0
  201. package/dist/node_modules/@elastic/elasticsearch/lib/client.d.ts +152 -0
  202. package/dist/node_modules/@elastic/elasticsearch/lib/client.js +369 -0
  203. package/dist/node_modules/@elastic/elasticsearch/lib/helpers.d.ts +184 -0
  204. package/dist/node_modules/@elastic/elasticsearch/lib/helpers.js +889 -0
  205. package/dist/node_modules/@elastic/elasticsearch/lib/sniffingTransport.d.ts +4 -0
  206. package/dist/node_modules/@elastic/elasticsearch/lib/sniffingTransport.js +56 -0
  207. package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv +15 -0
  208. package/dist/node_modules/@elastic/elasticsearch/node_modules/.bin/arrow2csv.cmd +7 -0
  209. package/dist/node_modules/@elastic/elasticsearch/package.json +1 -0
  210. package/dist/node_modules/@elastic/elasticsearch/tsconfig.json +38 -0
  211. package/dist/server/acl-guard.js +107 -0
  212. package/dist/server/collections/es-report-data-views.js +79 -0
  213. package/dist/server/collections/es-reports.js +95 -0
  214. package/dist/server/index.js +58 -0
  215. package/dist/server/mcp/ElasticReportMcpServer.js +344 -0
  216. package/dist/server/mcp/ElasticReportToolCatalog.js +417 -0
  217. package/dist/server/plugin.js +395 -0
  218. package/dist/server/services/ElasticReportService.js +263 -0
  219. package/dist/server/services/ElasticsearchConnectionService.js +332 -0
  220. package/dist/server/services/ReportQueryCompiler.js +858 -0
  221. package/dist/shared/constants.js +81 -0
  222. package/dist/shared/types.js +24 -0
  223. package/package.json +61 -4
  224. package/server.d.ts +2 -0
  225. package/server.js +1 -0
  226. package/src/client/index.tsx +19 -0
  227. package/src/client-v2/__tests__/elastic-report.test.tsx +311 -0
  228. package/src/client-v2/api.ts +224 -0
  229. package/src/client-v2/components/ElasticBasicCharts.tsx +399 -0
  230. package/src/client-v2/components/ElasticReportBlock.tsx +160 -0
  231. package/src/client-v2/components/ElasticReportRenderer.tsx +707 -0
  232. package/src/client-v2/components/HighlightText.tsx +50 -0
  233. package/src/client-v2/components/ReportSelect.tsx +72 -0
  234. package/src/client-v2/index.tsx +14 -0
  235. package/src/client-v2/locale.ts +23 -0
  236. package/src/client-v2/models/ElasticReportBlockModel.tsx +85 -0
  237. package/src/client-v2/pages/ElasticReportManager.tsx +1047 -0
  238. package/src/client-v2/plugin.tsx +52 -0
  239. package/src/index.ts +11 -0
  240. package/src/locale/en-US.json +99 -0
  241. package/src/locale/vi-VN.json +99 -0
  242. package/src/locale/zh-CN.json +99 -0
  243. package/src/server/__tests__/query-compiler.test.ts +231 -0
  244. package/src/server/__tests__/report-mcp-acl.integration.test.ts +377 -0
  245. package/src/server/acl-guard.ts +103 -0
  246. package/src/server/collections/es-report-data-views.ts +58 -0
  247. package/src/server/collections/es-reports.ts +74 -0
  248. package/src/server/index.ts +15 -0
  249. package/src/server/mcp/ElasticReportMcpServer.ts +391 -0
  250. package/src/server/mcp/ElasticReportToolCatalog.ts +417 -0
  251. package/src/server/plugin.ts +431 -0
  252. package/src/server/services/ElasticReportService.ts +326 -0
  253. package/src/server/services/ElasticsearchConnectionService.ts +401 -0
  254. package/src/server/services/ReportQueryCompiler.ts +1017 -0
  255. package/src/shared/constants.ts +29 -0
  256. package/src/shared/types.ts +175 -0
  257. package/README.md +0 -3
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed to Elasticsearch B.V. under one or more contributor
4
+ * license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright
6
+ * ownership. Elasticsearch B.V. licenses this file to you under
7
+ * the Apache License, Version 2.0 (the "License"); you may
8
+ * not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ //# sourceMappingURL=typesWithBodyKey.js.map
@@ -0,0 +1,152 @@
1
+ import { ConnectionOptions as TlsConnectionOptions } from 'node:tls';
2
+ import { URL } from 'node:url';
3
+ import { Transport, Serializer, Diagnostic, BaseConnectionPool } from '@elastic/transport';
4
+ import { HttpAgentOptions, UndiciAgentOptions, agentFn, nodeFilterFn, nodeSelectorFn, generateRequestIdFn, BasicAuth, ApiKeyAuth, BearerAuth, Context } from '@elastic/transport/lib/types';
5
+ import { RedactionOptions } from '@elastic/transport/lib/Transport';
6
+ import BaseConnection from '@elastic/transport/lib/connection/BaseConnection';
7
+ import SniffingTransport from './sniffingTransport';
8
+ import Helpers from './helpers';
9
+ import API from './api';
10
+ export interface NodeOptions {
11
+ /** @property url Elasticsearch node's location */
12
+ url: URL;
13
+ id?: string;
14
+ /** @property agent Custom HTTP agent options */
15
+ agent?: HttpAgentOptions | UndiciAgentOptions;
16
+ /** @property ssl Overrides default TLS connection settings */
17
+ ssl?: TlsConnectionOptions;
18
+ /** @property headers Custom HTTP headers that should be sent with each request */
19
+ headers?: Record<string, any>;
20
+ /** @property roles Common Elasticsearch roles that can be assigned to this node. Can be helpful when writing custom nodeFilter or nodeSelector functions. */
21
+ roles?: {
22
+ master: boolean;
23
+ data: boolean;
24
+ ingest: boolean;
25
+ ml: boolean;
26
+ };
27
+ }
28
+ export interface ClientOptions {
29
+ /** @property node Elasticsearch node settings, if there is only one node. Required if `nodes` or `cloud` is not set. */
30
+ node?: string | string[] | NodeOptions | NodeOptions[];
31
+ /** @property nodes Elasticsearch node settings, if there are multiple nodes. Required if `node` or `cloud` is not set. */
32
+ nodes?: string | string[] | NodeOptions | NodeOptions[];
33
+ /** @property Connection HTTP connection class to use
34
+ * @defaultValue `UndiciConnection` */
35
+ Connection?: typeof BaseConnection;
36
+ /** @property ConnectionPool HTTP connection pool class to use
37
+ * @defaultValue `CloudConnectionPool`, if connecting to Elastic Cloud, otherwise `WeightedConnectionPool` */
38
+ ConnectionPool?: typeof BaseConnectionPool;
39
+ /** @property Transport Elastic transport class to use
40
+ * @defaultValue `Transport` */
41
+ Transport?: typeof Transport;
42
+ /** @property Serializer Serialization class to use
43
+ * @defaultValue `Serializer` */
44
+ Serializer?: typeof Serializer;
45
+ /** @property maxRetries Max number of retries for each request
46
+ * @defaultValue 3 */
47
+ maxRetries?: number;
48
+ /** @property requestTimeout Max request timeout in milliseconds for each request
49
+ * @defaultValue 600000 */
50
+ requestTimeout?: number;
51
+ /** @property pingTimeout Max number of milliseconds a `ClusterConnectionPool` will wait when pinging nodes before marking them dead
52
+ * @defaultValue 3000 */
53
+ pingTimeout?: number;
54
+ /** @property sniffInterval Perform a sniff operation every `n` milliseconds
55
+ * @remarks Sniffing might not be the best solution for you. Read https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how to learn more.
56
+ * @defaultValue */
57
+ sniffInterval?: number | boolean;
58
+ /** @property sniffOnStart Perform a sniff once the client is started
59
+ * @remarks Sniffing might not be the best solution for you. Read https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how to learn more.
60
+ * @defaultValue false */
61
+ sniffOnStart?: boolean;
62
+ /** @property sniffEndpoint Endpoint to ping during a sniff
63
+ * @remarks Sniffing might not be the best solution for you. Read https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how to learn more.
64
+ * @defaultValue "_nodes/_all/http" */
65
+ sniffEndpoint?: string;
66
+ /** @property sniffOnConnectionFault Perform a sniff on connection fault
67
+ * @remarks Sniffing might not be the best solution for you. Read https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how to learn more.
68
+ * @defaultValue false */
69
+ sniffOnConnectionFault?: boolean;
70
+ /** @property resurrectStrategy Strategy for resurrecting dead nodes when using `ClusterConnectionPool`. 'ping' will issue a test request to a node and resurrect it if it responds. 'optimistic' marks a node as alive without testing it. 'none` will never attempt to revive a dead connection.
71
+ * @defaultValue 'ping' */
72
+ resurrectStrategy?: 'ping' | 'optimistic' | 'none';
73
+ /** @property compression Enables gzip request body compression
74
+ * @defaultValue `true` if connecting to Elastic Cloud, otherwise `false`. */
75
+ compression?: boolean;
76
+ /** @property tls [TLS configuraton](https://nodejs.org/api/tls.html)
77
+ * @defaultValue null */
78
+ tls?: TlsConnectionOptions;
79
+ /** @property agent Custom HTTP agent options
80
+ * @defaultValue null */
81
+ agent?: HttpAgentOptions | UndiciAgentOptions | agentFn | false;
82
+ /** @property nodeFilter A custom function used by the connection pool to determine which nodes are qualified to receive a request
83
+ * @defaultValue A function that uses the Connection `roles` property to avoid master-only nodes */
84
+ nodeFilter?: nodeFilterFn;
85
+ /** @property nodeSelector A custom function used by the connection pool to determine which node should receive the next request
86
+ * @defaultValue A "round robin" function that loops sequentially through each node in the pool. */
87
+ nodeSelector?: nodeSelectorFn;
88
+ /** @property headers Custom HTTP headers that should be sent with each request
89
+ * @defaultValue An object with a custom `user-agent` header */
90
+ headers?: Record<string, any>;
91
+ /** @property opaqueIdPrefix A string prefix to apply to every generated X-Opaque-Id header
92
+ * @defaultValue null */
93
+ opaqueIdPrefix?: string;
94
+ /** @property generateRequestId A custom function for generating unique IDs for each request, to make it easier to associate each API request to a single response
95
+ * @defaultValue A function that increments a number counter starting from 1 */
96
+ generateRequestId?: generateRequestIdFn;
97
+ /** @property name A name for this client
98
+ * @defaultValue 'elasticsearch-js' */
99
+ name?: string | symbol;
100
+ /** @property auth Authentication options for this Elasticsearch cluster
101
+ * @defaultValue null */
102
+ auth?: BasicAuth | ApiKeyAuth | BearerAuth;
103
+ /** @property context A custom object attached to each request that can be used to pass data to client events
104
+ * @defaultValue null */
105
+ context?: Context;
106
+ /** @property proxy A proxy URL that, when provided, the client will automatically send all requests through
107
+ * @defaultValue null */
108
+ proxy?: string | URL;
109
+ /** @property enableMetaHeader If true, adds an header named `x-elastic-client-meta`, containing a small amount of high-level telemetry data, such as the client and platform version
110
+ * @defaultValue true */
111
+ enableMetaHeader?: boolean;
112
+ /** @property cloud Custom configuration for connecting to Elastic Cloud, in lieu of a `node` or `nodes` configuration
113
+ * @remarks Read https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-connecting.html#client-usage for more details
114
+ * @defaultValue null */
115
+ cloud?: {
116
+ id: string;
117
+ };
118
+ /** @property disablePrototypePoisoningProtection Disables safe JSON parsing that protects execution of prototype poisoning attacks; disabled by default, as it can introduce a performance penalty
119
+ * @defaultValue true */
120
+ disablePrototypePoisoningProtection?: boolean | 'proto' | 'constructor';
121
+ /** @property caFingerprint If configured, verifies that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint; only accepts SHA256 digest fingerprints
122
+ * @defaultValue null */
123
+ caFingerprint?: string;
124
+ /** @property maxResponseSize When configured, verifies that the uncompressed response size is lower than the configured number. If it's higher, it will abort the request. It cannot be higher than `buffer.constants.MAX_STRING_LENGTH`
125
+ * @defaultValue null */
126
+ maxResponseSize?: number;
127
+ /** @property maxCompressedResponseSize When configured, verifies that the compressed response size is lower than the configured number. If it's higher, it will abort the request. It cannot be higher than `buffer.constants.MAX_LENGTH`
128
+ * @defaultValue null */
129
+ maxCompressedResponseSize?: number;
130
+ /** @property redaction Options for how to redact potentially sensitive data from metadata attached to `Error` objects
131
+ * @remarks Read https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/advanced-config.html#redaction for more details
132
+ * @defaultValue Configuration that will replace known sources of sensitive data */
133
+ redaction?: RedactionOptions;
134
+ }
135
+ export default class Client extends API {
136
+ diagnostic: Diagnostic;
137
+ name: string | symbol;
138
+ connectionPool: BaseConnectionPool;
139
+ transport: SniffingTransport;
140
+ serializer: Serializer;
141
+ helpers: Helpers;
142
+ constructor(opts: ClientOptions);
143
+ /**
144
+ * Creates a child client instance that shared its connection pool with the parent client
145
+ * @see {@link https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/child.html}
146
+ */
147
+ child(opts: ClientOptions): Client;
148
+ /**
149
+ * Closes all connections in the connection pool. Connections shared with any parent or child instances will also be closed.
150
+ */
151
+ close(): Promise<void>;
152
+ }
@@ -0,0 +1,369 @@
1
+ "use strict";
2
+ /*
3
+ * Licensed to Elasticsearch B.V. under one or more contributor
4
+ * license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright
6
+ * ownership. Elasticsearch B.V. licenses this file to you under
7
+ * the Apache License, Version 2.0 (the "License") you may
8
+ * not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const tslib_1 = require("tslib");
22
+ const node_process_1 = tslib_1.__importDefault(require("node:process"));
23
+ const node_url_1 = require("node:url");
24
+ const node_buffer_1 = tslib_1.__importDefault(require("node:buffer"));
25
+ const node_os_1 = tslib_1.__importDefault(require("node:os"));
26
+ const transport_1 = require("@elastic/transport");
27
+ const BaseConnection_1 = require("@elastic/transport/lib/connection/BaseConnection");
28
+ const sniffingTransport_1 = tslib_1.__importDefault(require("./sniffingTransport"));
29
+ const helpers_1 = tslib_1.__importDefault(require("./helpers"));
30
+ const api_1 = tslib_1.__importDefault(require("./api"));
31
+ const package_json_1 = tslib_1.__importDefault(require("../package.json"));
32
+ const package_json_2 = tslib_1.__importDefault(require("@elastic/transport/package.json"));
33
+ const kChild = Symbol('elasticsearchjs-child');
34
+ const kInitialOptions = Symbol('elasticsearchjs-initial-options');
35
+ let clientVersion = package_json_1.default.version;
36
+ /* istanbul ignore next */
37
+ if (clientVersion.includes('-')) {
38
+ // clean prerelease
39
+ clientVersion = clientVersion.slice(0, clientVersion.indexOf('-')) + 'p';
40
+ }
41
+ let transportVersion = package_json_2.default.version; // eslint-disable-line
42
+ /* istanbul ignore next */
43
+ if (transportVersion.includes('-')) {
44
+ // clean prerelease
45
+ transportVersion = transportVersion.slice(0, transportVersion.indexOf('-')) + 'p';
46
+ }
47
+ const nodeVersion = node_process_1.default.versions.node;
48
+ class Client extends api_1.default {
49
+ constructor(opts) {
50
+ var _a, _b, _c, _d, _e, _f;
51
+ super();
52
+ Object.defineProperty(this, "diagnostic", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ Object.defineProperty(this, "name", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+ Object.defineProperty(this, "connectionPool", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: void 0
69
+ });
70
+ Object.defineProperty(this, "transport", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: void 0
75
+ });
76
+ Object.defineProperty(this, "serializer", {
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true,
80
+ value: void 0
81
+ });
82
+ Object.defineProperty(this, "helpers", {
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true,
86
+ value: void 0
87
+ });
88
+ // @ts-expect-error kChild symbol is for internal use only
89
+ if ((opts.cloud != null) && opts[kChild] === undefined) {
90
+ const { id } = opts.cloud;
91
+ if (typeof id !== 'string') {
92
+ throw new transport_1.errors.ConfigurationError('Cloud ID must be a string.');
93
+ }
94
+ const parts = id.split(':');
95
+ if (parts.length !== 2 || parts[1] === '') {
96
+ throw new transport_1.errors.ConfigurationError('Cloud ID must be in the format "name:base64string".');
97
+ }
98
+ // the cloud id is `cluster-name:base64encodedurl`
99
+ // the url is a string divided by two '$', the first is the cloud url
100
+ // the second the elasticsearch instance, the third the kibana instance
101
+ let cloudUrls;
102
+ try {
103
+ cloudUrls = Buffer.from(parts[1], 'base64').toString().split('$');
104
+ }
105
+ catch (err) {
106
+ throw new transport_1.errors.ConfigurationError('Cloud ID base64 decoding failed.');
107
+ }
108
+ if (cloudUrls.length < 2 || cloudUrls[0] === '' || cloudUrls[1] === '') {
109
+ throw new transport_1.errors.ConfigurationError('Cloud ID base64 must contain at least two "$" separated parts: "<cloudUrl>$<esId>[$<kibanaId>]".');
110
+ }
111
+ opts.node = `https://${cloudUrls[1]}.${cloudUrls[0]}`;
112
+ // Cloud has better performance with compression enabled
113
+ // see https://github.com/elastic/elasticsearch-py/pull/704.
114
+ // So unless the user specifies otherwise, we enable compression.
115
+ if (opts.compression == null)
116
+ opts.compression = true;
117
+ if (opts.tls == null ||
118
+ (opts.tls != null && opts.tls.secureProtocol == null)) {
119
+ opts.tls = (_a = opts.tls) !== null && _a !== void 0 ? _a : {};
120
+ opts.tls.secureProtocol = 'TLSv1_2_method';
121
+ }
122
+ }
123
+ if (opts.node == null && opts.nodes == null) {
124
+ throw new transport_1.errors.ConfigurationError('Missing node(s) option');
125
+ }
126
+ // @ts-expect-error kChild symbol is for internal use only
127
+ if (opts[kChild] === undefined) {
128
+ const checkAuth = getAuth((_b = opts.node) !== null && _b !== void 0 ? _b : opts.nodes);
129
+ if ((checkAuth != null) && checkAuth.username !== '' && checkAuth.password !== '') {
130
+ opts.auth = Object.assign({}, opts.auth, { username: checkAuth.username, password: checkAuth.password });
131
+ }
132
+ }
133
+ const headers = Object.assign({}, {
134
+ 'user-agent': `elasticsearch-js/${clientVersion} (${node_os_1.default.platform()} ${node_os_1.default.release()}-${node_os_1.default.arch()}; Node.js ${nodeVersion}; Transport ${transportVersion})`
135
+ }, (_c = opts.headers) !== null && _c !== void 0 ? _c : {});
136
+ const redaction = Object.assign({}, { type: 'replace', additionalKeys: [] }, (_d = opts.redaction) !== null && _d !== void 0 ? _d : {});
137
+ const options = Object.assign({}, {
138
+ Connection: transport_1.UndiciConnection,
139
+ Transport: sniffingTransport_1.default,
140
+ Serializer: transport_1.Serializer,
141
+ ConnectionPool: (opts.cloud != null) ? transport_1.CloudConnectionPool : transport_1.WeightedConnectionPool,
142
+ maxRetries: 3,
143
+ requestTimeout: 600000,
144
+ pingTimeout: 3000,
145
+ sniffInterval: false,
146
+ sniffOnStart: false,
147
+ sniffEndpoint: '_nodes/_all/http',
148
+ sniffOnConnectionFault: false,
149
+ resurrectStrategy: 'ping',
150
+ compression: false,
151
+ tls: null,
152
+ caFingerprint: null,
153
+ agent: null,
154
+ nodeFilter: null,
155
+ generateRequestId: null,
156
+ name: 'elasticsearch-js',
157
+ auth: null,
158
+ opaqueIdPrefix: null,
159
+ context: null,
160
+ proxy: null,
161
+ enableMetaHeader: true,
162
+ maxResponseSize: null,
163
+ maxCompressedResponseSize: null
164
+ }, opts, { headers, redaction });
165
+ if (options.caFingerprint != null && isHttpConnection((_e = opts.node) !== null && _e !== void 0 ? _e : opts.nodes)) {
166
+ throw new transport_1.errors.ConfigurationError('You can\'t configure the caFingerprint with a http connection');
167
+ }
168
+ if (options.maxResponseSize != null && options.maxResponseSize > node_buffer_1.default.constants.MAX_STRING_LENGTH) {
169
+ throw new transport_1.errors.ConfigurationError(`The maxResponseSize cannot be bigger than ${node_buffer_1.default.constants.MAX_STRING_LENGTH}`);
170
+ }
171
+ if (options.maxCompressedResponseSize != null && options.maxCompressedResponseSize > node_buffer_1.default.constants.MAX_LENGTH) {
172
+ throw new transport_1.errors.ConfigurationError(`The maxCompressedResponseSize cannot be bigger than ${node_buffer_1.default.constants.MAX_LENGTH}`);
173
+ }
174
+ if (options.enableMetaHeader) {
175
+ let clientMeta = `es=${clientVersion},js=${nodeVersion},t=${transportVersion}`;
176
+ if (options.Connection === transport_1.UndiciConnection) {
177
+ clientMeta += `,un=${nodeVersion}`;
178
+ }
179
+ else {
180
+ // assumes HttpConnection
181
+ clientMeta += `,hc=${nodeVersion}`;
182
+ }
183
+ // detect alternative runtimes
184
+ if (node_process_1.default.versions.bun != null)
185
+ clientMeta += `,bn=${node_process_1.default.versions.bun}`;
186
+ if (node_process_1.default.versions.deno != null)
187
+ clientMeta += `,dn=${node_process_1.default.versions.deno}`;
188
+ options.headers['x-elastic-client-meta'] = clientMeta;
189
+ }
190
+ this.name = options.name;
191
+ // @ts-expect-error kInitialOptions symbol is for internal use only
192
+ this[kInitialOptions] = options;
193
+ // @ts-expect-error kChild symbol is for internal use only
194
+ if (opts[kChild] !== undefined) {
195
+ // @ts-expect-error kChild symbol is for internal use only
196
+ this.serializer = opts[kChild].serializer;
197
+ // @ts-expect-error kChild symbol is for internal use only
198
+ this.connectionPool = opts[kChild].connectionPool;
199
+ // @ts-expect-error kChild symbol is for internal use only
200
+ this.diagnostic = opts[kChild].diagnostic;
201
+ }
202
+ else {
203
+ this.diagnostic = new transport_1.Diagnostic();
204
+ let serializerOptions;
205
+ if (opts.disablePrototypePoisoningProtection != null) {
206
+ if (typeof opts.disablePrototypePoisoningProtection === 'boolean') {
207
+ serializerOptions = {
208
+ enablePrototypePoisoningProtection: !opts.disablePrototypePoisoningProtection
209
+ };
210
+ }
211
+ else {
212
+ serializerOptions = {
213
+ enablePrototypePoisoningProtection: opts.disablePrototypePoisoningProtection
214
+ };
215
+ }
216
+ }
217
+ this.serializer = new options.Serializer(serializerOptions);
218
+ this.connectionPool = new options.ConnectionPool({
219
+ pingTimeout: options.pingTimeout,
220
+ resurrectStrategy: options.resurrectStrategy,
221
+ tls: options.tls,
222
+ agent: options.agent,
223
+ proxy: options.proxy,
224
+ Connection: options.Connection,
225
+ auth: options.auth,
226
+ diagnostic: this.diagnostic,
227
+ caFingerprint: options.caFingerprint
228
+ });
229
+ // ensure default connection values are inherited when creating new connections
230
+ // see https://github.com/elastic/elasticsearch-js/issues/1791
231
+ const nodes = (_f = options.node) !== null && _f !== void 0 ? _f : options.nodes;
232
+ let nodeOptions = Array.isArray(nodes) ? nodes : [nodes];
233
+ nodeOptions = nodeOptions.map(opt => {
234
+ const { tls, headers, auth, requestTimeout: timeout, agent, proxy, caFingerprint } = options;
235
+ let defaults = { tls, headers, auth, timeout, agent, proxy, caFingerprint };
236
+ // strip undefined values from defaults
237
+ defaults = Object.keys(defaults).reduce((acc, key) => {
238
+ const val = defaults[key];
239
+ if (val !== undefined)
240
+ acc[key] = val;
241
+ return acc;
242
+ }, {});
243
+ let newOpts;
244
+ if (typeof opt === 'string') {
245
+ newOpts = {
246
+ url: new node_url_1.URL(opt)
247
+ };
248
+ }
249
+ else {
250
+ newOpts = opt;
251
+ }
252
+ return { ...defaults, ...newOpts };
253
+ });
254
+ this.connectionPool.addConnection(nodeOptions);
255
+ }
256
+ this.transport = new options.Transport({
257
+ diagnostic: this.diagnostic,
258
+ connectionPool: this.connectionPool,
259
+ serializer: this.serializer,
260
+ maxRetries: options.maxRetries,
261
+ requestTimeout: options.requestTimeout,
262
+ sniffInterval: options.sniffInterval,
263
+ sniffOnStart: options.sniffOnStart,
264
+ sniffOnConnectionFault: options.sniffOnConnectionFault,
265
+ sniffEndpoint: options.sniffEndpoint,
266
+ compression: options.compression,
267
+ headers: options.headers,
268
+ nodeFilter: options.nodeFilter,
269
+ nodeSelector: options.nodeSelector,
270
+ generateRequestId: options.generateRequestId,
271
+ name: options.name,
272
+ opaqueIdPrefix: options.opaqueIdPrefix,
273
+ context: options.context,
274
+ productCheck: 'Elasticsearch',
275
+ maxResponseSize: options.maxResponseSize,
276
+ maxCompressedResponseSize: options.maxCompressedResponseSize,
277
+ vendoredHeaders: {
278
+ jsonContentType: 'application/vnd.elasticsearch+json; compatible-with=8',
279
+ ndjsonContentType: 'application/vnd.elasticsearch+x-ndjson; compatible-with=8',
280
+ accept: 'application/vnd.elasticsearch+json; compatible-with=8,text/plain'
281
+ },
282
+ redaction: options.redaction
283
+ });
284
+ this.helpers = new helpers_1.default({
285
+ client: this,
286
+ metaHeader: options.enableMetaHeader
287
+ ? `es=${clientVersion},js=${nodeVersion},t=${transportVersion},hc=${nodeVersion}`
288
+ : null,
289
+ maxRetries: options.maxRetries
290
+ });
291
+ }
292
+ /**
293
+ * Creates a child client instance that shared its connection pool with the parent client
294
+ * @see {@link https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/child.html}
295
+ */
296
+ child(opts) {
297
+ // Merge the new options with the initial ones
298
+ // @ts-expect-error kChild symbol is for internal use only
299
+ const options = Object.assign({}, this[kInitialOptions], opts);
300
+ // Pass to the child client the parent instances that cannot be overridden
301
+ // @ts-expect-error kInitialOptions symbol is for internal use only
302
+ options[kChild] = {
303
+ connectionPool: this.connectionPool,
304
+ serializer: this.serializer,
305
+ diagnostic: this.diagnostic,
306
+ initialOptions: options
307
+ };
308
+ /* istanbul ignore else */
309
+ if (options.auth !== undefined) {
310
+ options.headers = (0, BaseConnection_1.prepareHeaders)(options.headers, options.auth);
311
+ }
312
+ return new Client(options);
313
+ }
314
+ /**
315
+ * Closes all connections in the connection pool. Connections shared with any parent or child instances will also be closed.
316
+ */
317
+ async close() {
318
+ return await this.connectionPool.empty();
319
+ }
320
+ }
321
+ exports.default = Client;
322
+ function isHttpConnection(node) {
323
+ if (Array.isArray(node)) {
324
+ return node.some((n) => (typeof n === 'string' ? new node_url_1.URL(n).protocol : n.url.protocol) === 'http:');
325
+ }
326
+ else {
327
+ if (node == null)
328
+ return false;
329
+ return (typeof node === 'string' ? new node_url_1.URL(node).protocol : node.url.protocol) === 'http:';
330
+ }
331
+ }
332
+ function getAuth(node) {
333
+ if (Array.isArray(node)) {
334
+ for (const url of node) {
335
+ const auth = getUsernameAndPassword(url);
336
+ if (auth != null && auth.username !== '' && auth.password !== '') {
337
+ return auth;
338
+ }
339
+ }
340
+ return null;
341
+ }
342
+ else {
343
+ const auth = getUsernameAndPassword(node);
344
+ if (auth != null && auth.username !== '' && auth.password !== '') {
345
+ return auth;
346
+ }
347
+ return null;
348
+ }
349
+ function getUsernameAndPassword(node) {
350
+ /* istanbul ignore else */
351
+ if (typeof node === 'string') {
352
+ const { username, password } = new node_url_1.URL(node);
353
+ return {
354
+ username: decodeURIComponent(username),
355
+ password: decodeURIComponent(password)
356
+ };
357
+ }
358
+ else if (node != null && node.url instanceof node_url_1.URL) {
359
+ return {
360
+ username: decodeURIComponent(node.url.username),
361
+ password: decodeURIComponent(node.url.password)
362
+ };
363
+ }
364
+ else {
365
+ return null;
366
+ }
367
+ }
368
+ }
369
+ //# sourceMappingURL=client.js.map