From 03079d44edb98ec94e812e8e3bfb04a546745700 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Oct 2021 15:52:53 +0200 Subject: [PATCH 001/172] bump to a pre-8.0 version --- package.json | 2 +- yarn.lock | 44 ++++++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 37a5239cf068a..e55ac2a7a1fdb 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "34.2.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.21", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.22", "@elastic/ems-client": "7.15.0", "@elastic/eui": "38.0.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 9f6ccfffb8113..65ba1cf7a8b95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2310,15 +2310,13 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.21": - version "8.0.0-canary.21" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.21.tgz#6572a547071a17cf511a42fd93738780266a9f89" - integrity sha512-J/qRGYkTj+YeEJh5xci9eLlVPrfwSEURK/P+ZZ6ZKymFLz7VQvK1vvha2YJJBjpM3ERnLNDL0y/HTEjYkR3VtQ== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.22": + version "8.0.0-canary.22" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.22.tgz#f25ffb3bc4946f4d6b8621d5d48764c2ca63b03e" + integrity sha512-lDaBPpooXkPw+A/1UZH9mJci6mcRg1CWuVndwK6I9VoF1Es3BV2aWOCjXWKRTdYzpojywXFUNJadCOeWGa+M6Q== dependencies: - debug "^4.3.1" - hpagent "^0.1.1" - ms "^2.1.3" - secure-json-parse "^2.4.0" + "@elastic/transport" "^0.0.6" + tslib "^2.3.0" "@elastic/ems-client@7.15.0": version "7.15.0" @@ -2504,6 +2502,18 @@ ts-node "^10.2.1" typescript "^4.3.5" +"@elastic/transport@^0.0.6": + version "0.0.6" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.6.tgz#78da508529dfe789b26f85d4cb1db6a47aee0078" + integrity sha512-MvXT0xYuKs9+hCI1TiymvrvvhX+inKlaPcP1rO61X2N2jbViDrF1LqKWqIxfJWOImF+BsQBhh6elyiYwdCZYmw== + dependencies: + debug "^4.3.2" + hpagent "^0.1.2" + ms "^2.1.3" + secure-json-parse "^2.4.0" + tslib "^2.3.0" + undici "^4.7.0" + "@emotion/babel-plugin-jsx-pragmatic@^0.1.5": version "0.1.5" resolved "https://registry.yarnpkg.com/@emotion/babel-plugin-jsx-pragmatic/-/babel-plugin-jsx-pragmatic-0.1.5.tgz#27debfe9c27c4d83574d509787ae553bf8a34d7e" @@ -16295,10 +16305,10 @@ hpack.js@^2.1.6: readable-stream "^2.0.1" wbuf "^1.1.0" -hpagent@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/hpagent/-/hpagent-0.1.1.tgz#66f67f16e5c7a8b59a068e40c2658c2c749ad5e2" - integrity sha512-IxJWQiY0vmEjetHdoE9HZjD4Cx+mYTr25tR7JCxXaiI3QxW0YqYyM11KyZbHufoa/piWhMb2+D3FGpMgmA2cFQ== +hpagent@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/hpagent/-/hpagent-0.1.2.tgz#cab39c66d4df2d4377dbd212295d878deb9bdaa9" + integrity sha512-ePqFXHtSQWAFXYmj+JtOTHr84iNrII4/QRlAAPPE+zqnKy4xJo7Ie1Y4kC7AdB+LxLxSTTzBMASsEcy0q8YyvQ== hsl-regex@^1.0.0: version "1.0.0" @@ -28224,6 +28234,11 @@ tslib@^2.0.0, tslib@^2.0.1, tslib@^2.2.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w== +tslib@^2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" + integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== + tslib@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a" @@ -28504,6 +28519,11 @@ undertaker@^1.2.1: object.reduce "^1.0.0" undertaker-registry "^1.0.0" +undici@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/undici/-/undici-4.7.0.tgz#3bda286d67bf45d0ab1b94ca6c84e546dcb3b0d4" + integrity sha512-O1q+/EIs4g0HnVMH8colei3qODGiYBLpavWYv3kI+JazBBsBIndnZfUqZ2MEfPJ12H9d56yVdwZG1/nV/xcoSQ== + unfetch@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.1.0.tgz#6ec2dd0de887e58a4dee83a050ded80ffc4137db" From 453157aa577f1550fc99f9bc37a9a807de91a52b Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Oct 2021 16:12:53 +0200 Subject: [PATCH 002/172] export KibanaClient from /lib sub-folder --- packages/kbn-es-archiver/src/actions/empty_kibana_index.ts | 2 +- packages/kbn-es-archiver/src/actions/load.ts | 2 +- packages/kbn-es-archiver/src/actions/save.ts | 2 +- packages/kbn-es-archiver/src/actions/unload.ts | 2 +- packages/kbn-es-archiver/src/es_archiver.ts | 2 +- .../src/lib/docs/generate_doc_records_stream.ts | 2 +- .../kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts | 2 +- packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts | 2 +- .../kbn-es-archiver/src/lib/indices/create_index_stream.ts | 2 +- packages/kbn-es-archiver/src/lib/indices/delete_index.ts | 2 +- .../kbn-es-archiver/src/lib/indices/delete_index_stream.ts | 2 +- .../src/lib/indices/generate_index_records_stream.ts | 2 +- packages/kbn-es-archiver/src/lib/indices/kibana_index.ts | 2 +- .../kbn-securitysolution-es-utils/src/delete_policy/index.ts | 5 +---- .../src/elasticsearch_client/index.ts | 2 +- packages/kbn-test/src/es/test_es_cluster.ts | 2 +- src/core/server/elasticsearch/client/types.ts | 2 +- src/core/server/ui_settings/integration_tests/lib/servers.ts | 2 +- test/common/services/elasticsearch.ts | 2 +- .../server/lib/detection_engine/signals/utils.ts | 2 +- x-pack/test/api_integration/apis/security_solution/utils.ts | 2 +- .../api_integration/apis/uptime/rest/helper/make_checks.ts | 2 +- .../api_integration/apis/uptime/rest/helper/make_ping.ts | 2 +- x-pack/test/case_api_integration/common/lib/utils.ts | 2 +- x-pack/test/detection_engine_api_integration/utils.ts | 2 +- x-pack/test/lists_api_integration/utils.ts | 2 +- .../common/lib/create_users_and_roles.ts | 2 +- .../common/lib/saved_object_test_utils.ts | 2 +- .../saved_object_api_integration/common/suites/import.ts | 2 +- .../common/suites/resolve_import_errors.ts | 2 +- .../common/lib/create_users_and_roles.ts | 2 +- .../spaces_api_integration/common/suites/copy_to_space.ts | 2 +- x-pack/test/spaces_api_integration/common/suites/delete.ts | 2 +- .../common/suites/disable_legacy_url_aliases.ts | 2 +- 34 files changed, 34 insertions(+), 37 deletions(-) diff --git a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts b/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts index 24a1de10b2b1d..90a1d1b3aabc1 100644 --- a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts +++ b/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; diff --git a/packages/kbn-es-archiver/src/actions/load.ts b/packages/kbn-es-archiver/src/actions/load.ts index 673fa7e7d96c8..f8d7878846cd7 100644 --- a/packages/kbn-es-archiver/src/actions/load.ts +++ b/packages/kbn-es-archiver/src/actions/load.ts @@ -11,7 +11,7 @@ import { createReadStream } from 'fs'; import { Readable } from 'stream'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { createPromiseFromStreams, concatStreamProviders } from '@kbn/utils'; import { ES_CLIENT_HEADERS } from '../client_headers'; diff --git a/packages/kbn-es-archiver/src/actions/save.ts b/packages/kbn-es-archiver/src/actions/save.ts index da0966920de24..32308ff96fc14 100644 --- a/packages/kbn-es-archiver/src/actions/save.ts +++ b/packages/kbn-es-archiver/src/actions/save.ts @@ -9,7 +9,7 @@ import { resolve, relative } from 'path'; import { createWriteStream, mkdirSync } from 'fs'; import { Readable, Writable } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { createListStream, createPromiseFromStreams } from '@kbn/utils'; diff --git a/packages/kbn-es-archiver/src/actions/unload.ts b/packages/kbn-es-archiver/src/actions/unload.ts index 98bae36095b88..a70f2991b4809 100644 --- a/packages/kbn-es-archiver/src/actions/unload.ts +++ b/packages/kbn-es-archiver/src/actions/unload.ts @@ -9,7 +9,7 @@ import { resolve, relative } from 'path'; import { createReadStream } from 'fs'; import { Readable, Writable } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { createPromiseFromStreams } from '@kbn/utils'; diff --git a/packages/kbn-es-archiver/src/es_archiver.ts b/packages/kbn-es-archiver/src/es_archiver.ts index 06a56b79e3012..e29160c279447 100644 --- a/packages/kbn-es-archiver/src/es_archiver.ts +++ b/packages/kbn-es-archiver/src/es_archiver.ts @@ -9,7 +9,7 @@ import Fs from 'fs'; import Path from 'path'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; diff --git a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts index 88e167b3705cb..8cd970e55699b 100644 --- a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts @@ -7,7 +7,7 @@ */ import { Transform } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { Stats } from '../stats'; import { Progress } from '../progress'; import { ES_CLIENT_HEADERS } from '../../client_headers'; diff --git a/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts b/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts index 028ff16c9afb2..2f6b0db62cc3d 100644 --- a/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import AggregateError from 'aggregate-error'; import { Writable } from 'stream'; import { Stats } from '../stats'; diff --git a/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts b/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts index 7dde4075dc3f2..d67b7b24a5eae 100644 --- a/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts +++ b/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import sinon from 'sinon'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../../stats'; diff --git a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts index fba3df24e896f..15e277dabfd03 100644 --- a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts @@ -10,7 +10,7 @@ import { Transform, Readable } from 'stream'; import { inspect } from 'util'; import { estypes } from '@elastic/elasticsearch'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../stats'; diff --git a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts b/packages/kbn-es-archiver/src/lib/indices/delete_index.ts index d3d6f85d7a360..ed63e7c7ff137 100644 --- a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts +++ b/packages/kbn-es-archiver/src/lib/indices/delete_index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../stats'; import { ES_CLIENT_HEADERS } from '../../client_headers'; diff --git a/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts b/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts index 7765419bb9d15..ded7ed7e22fb7 100644 --- a/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts @@ -7,7 +7,7 @@ */ import { Transform } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../stats'; diff --git a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts b/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts index 6619f1b3a601e..d3a25b2cb4daf 100644 --- a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts @@ -7,7 +7,7 @@ */ import { Transform } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { Stats } from '../stats'; import { ES_CLIENT_HEADERS } from '../../client_headers'; diff --git a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts index 635e432468846..5f383ca214dea 100644 --- a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts +++ b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts @@ -8,7 +8,7 @@ import { inspect } from 'util'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { Stats } from '../stats'; diff --git a/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts b/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts index 60a15f6d4625d..62592c9176d48 100644 --- a/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts @@ -12,8 +12,5 @@ export const deletePolicy = async ( esClient: ElasticsearchClient, policy: string ): Promise => { - return ( - // @ts-expect-error policy_id is required by mistake. fixed in the v8.0 - (await esClient.ilm.deleteLifecycle({ policy })).body - ); + return (await esClient.ilm.deleteLifecycle({ policy })).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts b/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts index a1fb3ff3ecf31..9cb834c97bfbe 100644 --- a/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts @@ -9,7 +9,7 @@ // Copied from src/core/server/elasticsearch/client/types.ts // as these types aren't part of any package yet. Once they are, remove this completely -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; /** * Client used to query the elasticsearch cluster. diff --git a/packages/kbn-test/src/es/test_es_cluster.ts b/packages/kbn-test/src/es/test_es_cluster.ts index 0d31ffdb99cc2..b3b40449879dc 100644 --- a/packages/kbn-test/src/es/test_es_cluster.ts +++ b/packages/kbn-test/src/es/test_es_cluster.ts @@ -12,7 +12,7 @@ import del from 'del'; // @ts-expect-error in js import { Cluster } from '@kbn/es'; import { Client } from '@elastic/elasticsearch'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { ToolingLog } from '@kbn/dev-utils'; import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix'; import { esTestConfig } from './es_test_config'; diff --git a/src/core/server/elasticsearch/client/types.ts b/src/core/server/elasticsearch/client/types.ts index f5a6fa1f0b1fd..d6691e5793539 100644 --- a/src/core/server/elasticsearch/client/types.ts +++ b/src/core/server/elasticsearch/client/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { ApiResponse, TransportRequestOptions, diff --git a/src/core/server/ui_settings/integration_tests/lib/servers.ts b/src/core/server/ui_settings/integration_tests/lib/servers.ts index 96ba08a0728ab..216513e4244e8 100644 --- a/src/core/server/ui_settings/integration_tests/lib/servers.ts +++ b/src/core/server/ui_settings/integration_tests/lib/servers.ts @@ -8,7 +8,7 @@ import type supertest from 'supertest'; import type { SavedObjectsClientContract, IUiSettingsClient } from 'src/core/server'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { createTestServers, diff --git a/test/common/services/elasticsearch.ts b/test/common/services/elasticsearch.ts index 7b8ff6bd6c8f4..b2dc2b028a4ed 100644 --- a/test/common/services/elasticsearch.ts +++ b/test/common/services/elasticsearch.ts @@ -10,7 +10,7 @@ import { format as formatUrl } from 'url'; import fs from 'fs'; import { Client } from '@elastic/elasticsearch'; import { CA_CERT_PATH } from '@kbn/dev-utils'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { FtrProviderContext } from '../ftr_provider_context'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index 5993dd626729f..3ac533649a242 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -149,7 +149,7 @@ export const hasTimestampFields = async (args: { timestampField: string; ruleName: string; // any is derived from here - // node_modules/@elastic/elasticsearch/api/kibana.d.ts + // node_modules/@elastic/elasticsearch/lib/api/kibana.d.ts // eslint-disable-next-line @typescript-eslint/no-explicit-any timestampFieldCapsResponse: ApiResponse, Context>; inputIndices: string[]; diff --git a/x-pack/test/api_integration/apis/security_solution/utils.ts b/x-pack/test/api_integration/apis/security_solution/utils.ts index 79d5ef499deb2..5eaca9d679a0d 100644 --- a/x-pack/test/api_integration/apis/security_solution/utils.ts +++ b/x-pack/test/api_integration/apis/security_solution/utils.ts @@ -6,7 +6,7 @@ */ import { ApiResponse, estypes } from '@elastic/elasticsearch'; -import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { JsonObject, JsonArray } from '@kbn/utility-types'; export async function getSavedObjectFromES( diff --git a/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts b/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts index 51338d2bb6e03..3f5addd6243e3 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts @@ -7,7 +7,7 @@ import uuid from 'uuid'; import { merge, flattenDeep } from 'lodash'; -import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { makePing } from './make_ping'; import { TlsProps } from './make_tls'; diff --git a/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts b/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts index 8532b3079f3c2..c50d078275cfe 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts @@ -7,7 +7,7 @@ import uuid from 'uuid'; import { merge } from 'lodash'; -import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { makeTls, TlsProps } from './make_tls'; const DEFAULT_INDEX_NAME = 'heartbeat-8-generated-test'; diff --git a/x-pack/test/case_api_integration/common/lib/utils.ts b/x-pack/test/case_api_integration/common/lib/utils.ts index 7367641d71585..188fe50f2fb06 100644 --- a/x-pack/test/case_api_integration/common/lib/utils.ts +++ b/x-pack/test/case_api_integration/common/lib/utils.ts @@ -8,7 +8,7 @@ import { omit } from 'lodash'; import expect from '@kbn/expect'; import type { ApiResponse, estypes } from '@elastic/elasticsearch'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type SuperTest from 'supertest'; import { ObjectRemover as ActionsRemover } from '../../../alerting_api_integration/common/lib'; diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index ac27f06a149d9..ec776c6f3ccd2 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -9,7 +9,7 @@ import { KbnClient } from '@kbn/test'; import type { ApiResponse } from '@elastic/elasticsearch'; import { Context } from '@elastic/elasticsearch/lib/Transport'; import type { estypes } from '@elastic/elasticsearch'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type SuperTest from 'supertest'; import type { ListArray, diff --git a/x-pack/test/lists_api_integration/utils.ts b/x-pack/test/lists_api_integration/utils.ts index b3816ad7563b8..4c0dd4420090f 100644 --- a/x-pack/test/lists_api_integration/utils.ts +++ b/x-pack/test/lists_api_integration/utils.ts @@ -6,7 +6,7 @@ */ import type SuperTest from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { Type, diff --git a/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts b/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts index 2ba5ce3f7d5b1..e1c3d54320c03 100644 --- a/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts +++ b/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts @@ -6,7 +6,7 @@ */ import type { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { AUTHENTICATION } from './authentication'; export const createUsersAndRoles = async (es: KibanaClient, supertest: SuperTest) => { diff --git a/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts b/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts index ce2079ab8234a..e5932a97c08ff 100644 --- a/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts +++ b/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { SavedObjectsErrorHelpers } from '../../../../../src/core/server'; import { SPACES, ALL_SPACES_ID } from './spaces'; import { AUTHENTICATION } from './authentication'; diff --git a/x-pack/test/saved_object_api_integration/common/suites/import.ts b/x-pack/test/saved_object_api_integration/common/suites/import.ts index 4e1b783d69841..3c10226149bb6 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/import.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/import.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; diff --git a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts index dd1f04529db7b..518813d83b974 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; diff --git a/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts b/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts index ecc680c32f303..d28b83d59fa24 100644 --- a/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts +++ b/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts @@ -6,7 +6,7 @@ */ import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { AUTHENTICATION } from './authentication'; export const createUsersAndRoles = async (es: KibanaClient, supertest: SuperTest) => { diff --git a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts index 27f1e55c3a90a..c17eb61bab4e6 100644 --- a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts +++ b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts @@ -8,7 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; import { EsArchiver } from '@kbn/es-archiver'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants'; import { CopyResponse } from '../../../../plugins/spaces/server/lib/copy_to_spaces'; import { getUrlPrefix } from '../lib/space_test_utils'; diff --git a/x-pack/test/spaces_api_integration/common/suites/delete.ts b/x-pack/test/spaces_api_integration/common/suites/delete.ts index 57fa6d8533890..b544732870849 100644 --- a/x-pack/test/spaces_api_integration/common/suites/delete.ts +++ b/x-pack/test/spaces_api_integration/common/suites/delete.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { getTestScenariosForSpace } from '../lib/space_test_utils'; import { MULTI_NAMESPACE_SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { DescribeFn, TestDefinitionAuthentication } from '../lib/types'; diff --git a/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts b/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts index 2d4b8b237e3c7..f4f37fcf6286b 100644 --- a/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts +++ b/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { LegacyUrlAlias } from 'src/core/server/saved_objects/object_types'; import { SPACES } from '../lib/spaces'; import { getUrlPrefix } from '../../../saved_object_api_integration/common/lib/saved_object_test_utils'; From adf623ca26d38d44fe724ea1aaf1544057b69552 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Oct 2021 16:44:53 +0200 Subject: [PATCH 003/172] workaround the problem of the absence of estypes --- .../kbn-es-archiver/src/lib/indices/create_index_stream.ts | 2 +- packages/kbn-es-query/src/es_query/decorate_query.ts | 2 +- packages/kbn-es-query/src/es_query/from_filters.ts | 2 +- packages/kbn-es-query/src/es_query/lucene_string_to_dsl.ts | 2 +- packages/kbn-es-query/src/es_query/types.ts | 2 +- .../kbn-es-query/src/filters/build_filters/custom_filter.ts | 2 +- .../src/filters/build_filters/match_all_filter.ts | 2 +- .../src/filters/build_filters/phrase_filter.test.ts | 2 +- .../kbn-es-query/src/filters/build_filters/phrase_filter.ts | 2 +- .../kbn-es-query/src/filters/build_filters/phrases_filter.ts | 2 +- .../kbn-es-query/src/filters/build_filters/range_filter.ts | 2 +- packages/kbn-es-query/src/kuery/ast/ast.ts | 2 +- packages/kbn-es-query/src/kuery/functions/exists.ts | 2 +- packages/kbn-es-query/src/kuery/functions/geo_bounding_box.ts | 3 +-- packages/kbn-es-query/src/kuery/functions/geo_polygon.ts | 3 +-- packages/kbn-es-query/src/kuery/functions/is.test.ts | 2 +- packages/kbn-es-query/src/kuery/functions/is.ts | 2 +- packages/kbn-es-query/src/kuery/functions/nested.ts | 2 +- packages/kbn-es-query/src/kuery/functions/not.ts | 2 +- packages/kbn-es-query/src/kuery/functions/or.ts | 2 +- packages/kbn-es-query/src/kuery/functions/range.test.ts | 2 +- packages/kbn-es-query/src/kuery/functions/range.ts | 2 +- packages/kbn-es-query/src/kuery/index.ts | 2 +- packages/kbn-es-query/src/kuery/types.ts | 2 +- packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts | 2 +- packages/kbn-test/src/es/test_es_cluster.ts | 4 +++- .../src/failed_tests_reporter/report_failures_to_es.ts | 2 +- 27 files changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts index 15e277dabfd03..b4ca91248844c 100644 --- a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts @@ -9,7 +9,7 @@ import { Transform, Readable } from 'stream'; import { inspect } from 'util'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { ToolingLog } from '@kbn/dev-utils'; diff --git a/packages/kbn-es-query/src/es_query/decorate_query.ts b/packages/kbn-es-query/src/es_query/decorate_query.ts index e5bcf01a45915..a58eca575f4bf 100644 --- a/packages/kbn-es-query/src/es_query/decorate_query.ts +++ b/packages/kbn-es-query/src/es_query/decorate_query.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SerializableRecord } from '@kbn/utility-types'; import { extend, defaults } from 'lodash'; import { getTimeZoneFromSettings } from '../utils'; diff --git a/packages/kbn-es-query/src/es_query/from_filters.ts b/packages/kbn-es-query/src/es_query/from_filters.ts index 9c93fba6fad92..45da659521daa 100644 --- a/packages/kbn-es-query/src/es_query/from_filters.ts +++ b/packages/kbn-es-query/src/es_query/from_filters.ts @@ -7,7 +7,7 @@ */ import { isUndefined } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { migrateFilter } from './migrate_filter'; import { filterMatchesIndex } from './filter_matches_index'; import { Filter, cleanFilter, isFilterDisabled } from '../filters'; diff --git a/packages/kbn-es-query/src/es_query/lucene_string_to_dsl.ts b/packages/kbn-es-query/src/es_query/lucene_string_to_dsl.ts index 91a912a5da0e3..07b56f281e80e 100644 --- a/packages/kbn-es-query/src/es_query/lucene_string_to_dsl.ts +++ b/packages/kbn-es-query/src/es_query/lucene_string_to_dsl.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isString } from 'lodash'; /** diff --git a/packages/kbn-es-query/src/es_query/types.ts b/packages/kbn-es-query/src/es_query/types.ts index 0d443366626a0..1ce34cd24ace2 100644 --- a/packages/kbn-es-query/src/es_query/types.ts +++ b/packages/kbn-es-query/src/es_query/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; /** * A field's sub type diff --git a/packages/kbn-es-query/src/filters/build_filters/custom_filter.ts b/packages/kbn-es-query/src/filters/build_filters/custom_filter.ts index 72b775bc688cc..77356006d98ef 100644 --- a/packages/kbn-es-query/src/filters/build_filters/custom_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/custom_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Filter, FilterMeta, FILTERS, FilterStateStore } from './types'; /** @public */ diff --git a/packages/kbn-es-query/src/filters/build_filters/match_all_filter.ts b/packages/kbn-es-query/src/filters/build_filters/match_all_filter.ts index aadf949b6624a..49d7c3d55cad0 100644 --- a/packages/kbn-es-query/src/filters/build_filters/match_all_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/match_all_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { has } from 'lodash'; import type { Filter, FilterMeta } from './types'; diff --git a/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts index 58e639afda3b6..6b418d0df509f 100644 --- a/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts @@ -14,7 +14,7 @@ import { } from './phrase_filter'; import { fields, getField } from '../stubs'; import { IndexPatternBase } from '../../es_query'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; describe('Phrase filter builder', () => { let indexPattern: IndexPatternBase; diff --git a/packages/kbn-es-query/src/filters/build_filters/phrase_filter.ts b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.ts index 1e8f95921e700..af2f77e5113ad 100644 --- a/packages/kbn-es-query/src/filters/build_filters/phrase_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { get, has, isPlainObject } from 'lodash'; import type { Filter, FilterMeta } from './types'; import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query'; diff --git a/packages/kbn-es-query/src/filters/build_filters/phrases_filter.ts b/packages/kbn-es-query/src/filters/build_filters/phrases_filter.ts index 0e09a191fd549..fe895bbd60a74 100644 --- a/packages/kbn-es-query/src/filters/build_filters/phrases_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrases_filter.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Filter, FilterMeta, FILTERS } from './types'; import { getPhraseScript, PhraseFilterValue } from './phrase_filter'; import type { IndexPatternFieldBase, IndexPatternBase } from '../../es_query'; diff --git a/packages/kbn-es-query/src/filters/build_filters/range_filter.ts b/packages/kbn-es-query/src/filters/build_filters/range_filter.ts index a7ebff7c3500e..c3c003e2454dc 100644 --- a/packages/kbn-es-query/src/filters/build_filters/range_filter.ts +++ b/packages/kbn-es-query/src/filters/build_filters/range_filter.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { map, reduce, mapValues, has, get, keys, pickBy } from 'lodash'; import type { Filter, FilterMeta } from './types'; import type { IndexPatternBase, IndexPatternFieldBase } from '../../es_query'; diff --git a/packages/kbn-es-query/src/kuery/ast/ast.ts b/packages/kbn-es-query/src/kuery/ast/ast.ts index c1b4380ecbfe3..683de9f193901 100644 --- a/packages/kbn-es-query/src/kuery/ast/ast.ts +++ b/packages/kbn-es-query/src/kuery/ast/ast.ts @@ -7,7 +7,7 @@ */ import { JsonObject } from '@kbn/utility-types'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { nodeTypes } from '../node_types/index'; import { KQLSyntaxError } from '../kuery_syntax_error'; import { KueryNode, KueryParseOptions, KueryQueryOptions } from '../types'; diff --git a/packages/kbn-es-query/src/kuery/functions/exists.ts b/packages/kbn-es-query/src/kuery/functions/exists.ts index d1d0cb7835bca..a0d779c4c7d49 100644 --- a/packages/kbn-es-query/src/kuery/functions/exists.ts +++ b/packages/kbn-es-query/src/kuery/functions/exists.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IndexPatternFieldBase, IndexPatternBase, KueryNode, KueryQueryOptions } from '../..'; import * as literal from '../node_types/literal'; diff --git a/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.ts b/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.ts index 1dae0b40ff08e..1808b7a2c0106 100644 --- a/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.ts +++ b/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.ts @@ -7,7 +7,7 @@ */ import _ from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { nodeTypes } from '../node_types'; import * as ast from '../ast'; import { IndexPatternBase, KueryNode, KueryQueryOptions, LatLon } from '../..'; @@ -53,7 +53,6 @@ export function toElasticsearchQuery( } return { - // @ts-expect-error @elastic/elasticsearch doesn't support ignore_unmapped in QueryDslGeoBoundingBoxQuery geo_bounding_box: { [fieldName]: queryParams, ignore_unmapped: true, diff --git a/packages/kbn-es-query/src/kuery/functions/geo_polygon.ts b/packages/kbn-es-query/src/kuery/functions/geo_polygon.ts index cf0bcdafa04c7..0cc95f8012a42 100644 --- a/packages/kbn-es-query/src/kuery/functions/geo_polygon.ts +++ b/packages/kbn-es-query/src/kuery/functions/geo_polygon.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { nodeTypes } from '../node_types'; import * as ast from '../ast'; import { IndexPatternBase, KueryNode, KueryQueryOptions, LatLon } from '../..'; @@ -49,7 +49,6 @@ export function toElasticsearchQuery( } return { - // @ts-expect-error @elastic/elasticsearch doesn't support ignore_unmapped in QueryDslGeoPolygonQuery geo_polygon: { [fieldName]: queryParams, ignore_unmapped: true, diff --git a/packages/kbn-es-query/src/kuery/functions/is.test.ts b/packages/kbn-es-query/src/kuery/functions/is.test.ts index bc1bbb2508438..56e2a1a10d8f8 100644 --- a/packages/kbn-es-query/src/kuery/functions/is.test.ts +++ b/packages/kbn-es-query/src/kuery/functions/is.test.ts @@ -11,7 +11,7 @@ import { fields } from '../../filters/stubs'; import * as is from './is'; import { IndexPatternBase } from '../..'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; jest.mock('../grammar'); diff --git a/packages/kbn-es-query/src/kuery/functions/is.ts b/packages/kbn-es-query/src/kuery/functions/is.ts index 596dd91df22b3..eafa02a20a0d0 100644 --- a/packages/kbn-es-query/src/kuery/functions/is.ts +++ b/packages/kbn-es-query/src/kuery/functions/is.ts @@ -7,7 +7,7 @@ */ import { get, isUndefined } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getPhraseScript } from '../../filters'; import { getFields } from './utils/get_fields'; import { getTimeZoneFromSettings } from '../../utils'; diff --git a/packages/kbn-es-query/src/kuery/functions/nested.ts b/packages/kbn-es-query/src/kuery/functions/nested.ts index e59f7a6acc07d..3a466e9ddca02 100644 --- a/packages/kbn-es-query/src/kuery/functions/nested.ts +++ b/packages/kbn-es-query/src/kuery/functions/nested.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as ast from '../ast'; import * as literal from '../node_types/literal'; import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..'; diff --git a/packages/kbn-es-query/src/kuery/functions/not.ts b/packages/kbn-es-query/src/kuery/functions/not.ts index 01ec89e9b499d..91954c6a09fc4 100644 --- a/packages/kbn-es-query/src/kuery/functions/not.ts +++ b/packages/kbn-es-query/src/kuery/functions/not.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as ast from '../ast'; import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..'; diff --git a/packages/kbn-es-query/src/kuery/functions/or.ts b/packages/kbn-es-query/src/kuery/functions/or.ts index d48ddb4c32d73..d06f51d2918bd 100644 --- a/packages/kbn-es-query/src/kuery/functions/or.ts +++ b/packages/kbn-es-query/src/kuery/functions/or.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as ast from '../ast'; import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..'; diff --git a/packages/kbn-es-query/src/kuery/functions/range.test.ts b/packages/kbn-es-query/src/kuery/functions/range.test.ts index 42005a3fe702d..062aa6c221b5b 100644 --- a/packages/kbn-es-query/src/kuery/functions/range.test.ts +++ b/packages/kbn-es-query/src/kuery/functions/range.test.ts @@ -13,7 +13,7 @@ import { IndexPatternBase } from '../..'; import { RangeFilterParams } from '../../filters'; import * as range from './range'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; jest.mock('../grammar'); describe('kuery functions', () => { diff --git a/packages/kbn-es-query/src/kuery/functions/range.ts b/packages/kbn-es-query/src/kuery/functions/range.ts index 51f686925518d..4e165994aaa38 100644 --- a/packages/kbn-es-query/src/kuery/functions/range.ts +++ b/packages/kbn-es-query/src/kuery/functions/range.ts @@ -7,7 +7,7 @@ */ import _ from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { nodeTypes } from '../node_types'; import * as ast from '../ast'; import { getRangeScript, RangeFilterParams } from '../../filters'; diff --git a/packages/kbn-es-query/src/kuery/index.ts b/packages/kbn-es-query/src/kuery/index.ts index 15f3a768ebbd3..6e03b3cb18f4c 100644 --- a/packages/kbn-es-query/src/kuery/index.ts +++ b/packages/kbn-es-query/src/kuery/index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { toElasticsearchQuery as astToElasticsearchQuery } from './ast'; /** diff --git a/packages/kbn-es-query/src/kuery/types.ts b/packages/kbn-es-query/src/kuery/types.ts index 1ab2d07a60a11..c074fa6d90845 100644 --- a/packages/kbn-es-query/src/kuery/types.ts +++ b/packages/kbn-es-query/src/kuery/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SerializableRecord } from '@kbn/utility-types'; import { NodeTypes } from './node_types'; diff --git a/packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts b/packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts index d167b17b83f23..d68f6df5cc4d2 100644 --- a/packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts +++ b/packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { EsQueryConfig } from '@kbn/es-query'; /** diff --git a/packages/kbn-test/src/es/test_es_cluster.ts b/packages/kbn-test/src/es/test_es_cluster.ts index b3b40449879dc..1143fa381b710 100644 --- a/packages/kbn-test/src/es/test_es_cluster.ts +++ b/packages/kbn-test/src/es/test_es_cluster.ts @@ -283,7 +283,9 @@ export function createTestEsCluster< getClient(): KibanaClient { return new Client({ node: this.getHostUrls()[0], - }); + // TODO investigate the mismatch: + // Property 'dataFrameTransformDeprecated' is missing in type 'Client' but required in type 'KibanaClient'. + }) as unknown as KibanaClient; } getUrl() { diff --git a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts index 754ce2567cb80..abec5b718a845 100644 --- a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts +++ b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts @@ -59,7 +59,7 @@ export async function reportFailuresToEs(log: ToolingLog, failures: TestFailure[ }, ]); - const resp = await client.bulk({ body }); + const resp = await client.bulk({ body }, { meta: true }); if (resp?.body?.errors) { log.error(JSON.stringify(resp.body.items, null, 2)); } From ff63c52c8c76817b7a51b750a4140f130a5b81b7 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Oct 2021 17:03:33 +0200 Subject: [PATCH 004/172] update es client usage in pacakges --- packages/kbn-es-archiver/src/cli.ts | 6 ++++-- .../src/lib/docs/generate_doc_records_stream.ts | 4 +--- packages/kbn-es-archiver/src/lib/indices/kibana_index.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/kbn-es-archiver/src/cli.ts b/packages/kbn-es-archiver/src/cli.ts index 8e4a879282765..355d9065b6d08 100644 --- a/packages/kbn-es-archiver/src/cli.ts +++ b/packages/kbn-es-archiver/src/cli.ts @@ -20,6 +20,7 @@ import Fs from 'fs'; import { RunWithCommands, createFlagError, CA_CERT_PATH } from '@kbn/dev-utils'; import { readConfigFile, KbnClient } from '@kbn/test'; import { Client } from '@elastic/elasticsearch'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { EsArchiver } from './es_archiver'; @@ -106,7 +107,7 @@ export function runCli() { const client = new Client({ node: esUrl, - ssl: esCa ? { ca: esCa } : undefined, + tls: esCa ? { ca: esCa } : undefined, }); addCleanupTask(() => client.close()); @@ -118,7 +119,8 @@ export function runCli() { const esArchiver = new EsArchiver({ log, - client, + // TODO fix the discrepancy + client: client as unknown as KibanaClient, baseDir: process.cwd(), kbnClient, }); diff --git a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts index 8cd970e55699b..178f34d50d03d 100644 --- a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts @@ -37,9 +37,7 @@ export function createGenerateDocRecordsStream({ scroll: SCROLL_TIMEOUT, size: SCROLL_SIZE, _source: 'true', - body: { - query, - }, + query, rest_total_hits_as_int: true, }, { diff --git a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts index 5f383ca214dea..2fc7e555084b4 100644 --- a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts +++ b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts @@ -35,7 +35,7 @@ export async function deleteKibanaIndices({ await client.indices.putSettings( { index: indexNames, - body: { settings: { blocks: { read_only: false } } }, + body: { blocks: { read_only: false } }, }, { headers: ES_CLIENT_HEADERS, From b0850898d5993edff7d4356e8c2127ce2a53de2f Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Oct 2021 17:08:44 +0200 Subject: [PATCH 005/172] export estypes from another path --- src/core/server/elasticsearch/client/types.ts | 7 +++---- src/core/server/elasticsearch/is_scripting_enabled.test.ts | 2 +- src/core/server/http/router/router.ts | 2 +- .../deprecations/unknown_object_types.test.ts | 2 +- .../saved_objects/deprecations/unknown_object_types.ts | 2 +- src/core/server/saved_objects/mappings/types.ts | 2 +- .../server/saved_objects/migrations/core/call_cluster.ts | 2 +- .../saved_objects/migrations/core/elastic_index.test.ts | 2 +- .../server/saved_objects/migrations/core/elastic_index.ts | 2 +- .../saved_objects/migrations/core/index_migrator.test.ts | 2 +- .../migrationsv2/actions/calculate_exclude_filters.ts | 2 +- .../migrationsv2/actions/check_for_unknown_docs.ts | 2 +- .../saved_objects/migrationsv2/actions/create_index.ts | 2 +- .../saved_objects/migrationsv2/actions/read_with_pit.ts | 2 +- .../server/saved_objects/migrationsv2/actions/reindex.ts | 2 +- .../migrationsv2/actions/search_for_outdated_documents.ts | 2 +- .../integration_tests/7_13_0_unknown_types.test.ts | 2 +- src/core/server/saved_objects/migrationsv2/model/model.ts | 2 +- src/core/server/saved_objects/migrationsv2/types.ts | 2 +- .../service/lib/aggregations/validation.test.ts | 2 +- .../saved_objects/service/lib/aggregations/validation.ts | 2 +- .../saved_objects/service/lib/point_in_time_finder.ts | 2 +- src/core/server/saved_objects/service/lib/repository.ts | 2 +- .../saved_objects/service/lib/search_dsl/search_dsl.ts | 2 +- .../saved_objects/service/lib/search_dsl/sorting_params.ts | 2 +- .../saved_objects/service/lib/update_objects_spaces.ts | 2 +- src/core/server/saved_objects/types.ts | 2 +- src/core/types/elasticsearch/index.ts | 2 +- src/core/types/elasticsearch/search.ts | 2 +- 29 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/core/server/elasticsearch/client/types.ts b/src/core/server/elasticsearch/client/types.ts index d6691e5793539..c3f6ad23560c1 100644 --- a/src/core/server/elasticsearch/client/types.ts +++ b/src/core/server/elasticsearch/client/types.ts @@ -8,11 +8,10 @@ import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { - ApiResponse, + TransportResult, TransportRequestOptions, TransportRequestParams, - TransportRequestPromise, -} from '@elastic/elasticsearch/lib/Transport'; +} from '@elastic/transport'; /** * Client used to query the elasticsearch cluster. @@ -27,7 +26,7 @@ export type ElasticsearchClient = Omit< request( params: TransportRequestParams, options?: TransportRequestOptions - ): TransportRequestPromise; + ): Promise; }; }; diff --git a/src/core/server/elasticsearch/is_scripting_enabled.test.ts b/src/core/server/elasticsearch/is_scripting_enabled.test.ts index 6dfb4b13edb9f..dd84c29818556 100644 --- a/src/core/server/elasticsearch/is_scripting_enabled.test.ts +++ b/src/core/server/elasticsearch/is_scripting_enabled.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { elasticsearchServiceMock } from './elasticsearch_service.mock'; import { isInlineScriptingEnabled } from './is_scripting_enabled'; diff --git a/src/core/server/http/router/router.ts b/src/core/server/http/router/router.ts index d2d8dfa2cc72f..c9679c1871581 100644 --- a/src/core/server/http/router/router.ts +++ b/src/core/server/http/router/router.ts @@ -292,7 +292,7 @@ const convertEsUnauthorized = (e: EsNotAuthorizedError): ErrorHttpResponseOption const header = Object.entries(e.headers).find( ([key]) => key.toLowerCase() === 'www-authenticate' ); - return header ? header[1] : 'Basic realm="Authorization Required"'; + return header ? (header[1] as string) : 'Basic realm="Authorization Required"'; }; return { body: e.message, diff --git a/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts b/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts index d7ea73456e236..af77360e0dd7e 100644 --- a/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts +++ b/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts @@ -8,7 +8,7 @@ import { getIndexForTypeMock } from './unknown_object_types.test.mocks'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { deleteUnknownTypeObjects, getUnknownTypesDeprecations } from './unknown_object_types'; import { typeRegistryMock } from '../saved_objects_type_registry.mock'; import { elasticsearchClientMock } from '../../elasticsearch/client/mocks'; diff --git a/src/core/server/saved_objects/deprecations/unknown_object_types.ts b/src/core/server/saved_objects/deprecations/unknown_object_types.ts index c966e621ca605..af2410bc427c2 100644 --- a/src/core/server/saved_objects/deprecations/unknown_object_types.ts +++ b/src/core/server/saved_objects/deprecations/unknown_object_types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import type { DeprecationsDetails } from '../../deprecations'; import { IScopedClusterClient } from '../../elasticsearch'; diff --git a/src/core/server/saved_objects/mappings/types.ts b/src/core/server/saved_objects/mappings/types.ts index e2ad2a91fd000..e225d0ff31022 100644 --- a/src/core/server/saved_objects/mappings/types.ts +++ b/src/core/server/saved_objects/mappings/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; /** * Describe a saved object type mapping. * diff --git a/src/core/server/saved_objects/migrations/core/call_cluster.ts b/src/core/server/saved_objects/migrations/core/call_cluster.ts index f37bbdd14a899..7b34e0488256b 100644 --- a/src/core/server/saved_objects/migrations/core/call_cluster.ts +++ b/src/core/server/saved_objects/migrations/core/call_cluster.ts @@ -12,7 +12,7 @@ * funcationality contained here. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IndexMapping } from '../../mappings'; export interface CallCluster { diff --git a/src/core/server/saved_objects/migrations/core/elastic_index.test.ts b/src/core/server/saved_objects/migrations/core/elastic_index.test.ts index 15bd1d46b092b..3de913f77c47e 100644 --- a/src/core/server/saved_objects/migrations/core/elastic_index.test.ts +++ b/src/core/server/saved_objects/migrations/core/elastic_index.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import _ from 'lodash'; import { elasticsearchClientMock } from '../../../elasticsearch/client/mocks'; import * as Index from './elastic_index'; diff --git a/src/core/server/saved_objects/migrations/core/elastic_index.ts b/src/core/server/saved_objects/migrations/core/elastic_index.ts index 5068c24df3414..f9572151084dc 100644 --- a/src/core/server/saved_objects/migrations/core/elastic_index.ts +++ b/src/core/server/saved_objects/migrations/core/elastic_index.ts @@ -12,7 +12,7 @@ */ import _ from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { MigrationEsClient } from './migration_es_client'; import { IndexMapping } from '../../mappings'; import { SavedObjectsMigrationVersion } from '../../types'; diff --git a/src/core/server/saved_objects/migrations/core/index_migrator.test.ts b/src/core/server/saved_objects/migrations/core/index_migrator.test.ts index 64d4fa3609e90..6ffa6950e9b1f 100644 --- a/src/core/server/saved_objects/migrations/core/index_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/core/index_migrator.test.ts @@ -7,7 +7,7 @@ */ import _ from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { elasticsearchClientMock } from '../../../elasticsearch/client/mocks'; import { SavedObjectUnsanitizedDoc, SavedObjectsSerializer } from '../../serialization'; import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry'; diff --git a/src/core/server/saved_objects/migrationsv2/actions/calculate_exclude_filters.ts b/src/core/server/saved_objects/migrationsv2/actions/calculate_exclude_filters.ts index 9ba098d01870f..2b35e3b59e988 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/calculate_exclude_filters.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/calculate_exclude_filters.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { withTimeout } from '@kbn/std'; import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; diff --git a/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.ts b/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.ts index 1db47f0083467..cfeda0548b16a 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.ts @@ -8,7 +8,7 @@ import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SavedObjectsRawDocSource } from '../../serialization'; import { ElasticsearchClient } from '../../../elasticsearch'; import { diff --git a/src/core/server/saved_objects/migrationsv2/actions/create_index.ts b/src/core/server/saved_objects/migrationsv2/actions/create_index.ts index d5269233344c3..9cb8880e7c664 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/create_index.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/create_index.ts @@ -9,7 +9,7 @@ import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; import { pipe } from 'fp-ts/lib/pipeable'; -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AcknowledgeResponse } from './index'; import { ElasticsearchClient } from '../../../elasticsearch'; import { IndexMapping } from '../../mappings'; diff --git a/src/core/server/saved_objects/migrationsv2/actions/read_with_pit.ts b/src/core/server/saved_objects/migrationsv2/actions/read_with_pit.ts index c8e7d61dce811..0902e206147d3 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/read_with_pit.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/read_with_pit.ts @@ -8,7 +8,7 @@ import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from '../../../elasticsearch'; import type { SavedObjectsRawDoc } from '../../serialization'; import { diff --git a/src/core/server/saved_objects/migrationsv2/actions/reindex.ts b/src/core/server/saved_objects/migrationsv2/actions/reindex.ts index 92134d2755ac3..e8e054c7a1780 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/reindex.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/reindex.ts @@ -9,7 +9,7 @@ import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; import * as Option from 'fp-ts/lib/Option'; -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from '../../../elasticsearch'; import { catchRetryableEsClientErrors, diff --git a/src/core/server/saved_objects/migrationsv2/actions/search_for_outdated_documents.ts b/src/core/server/saved_objects/migrationsv2/actions/search_for_outdated_documents.ts index 5a6cb3a3d048d..5a92a7c6cc286 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/search_for_outdated_documents.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/search_for_outdated_documents.ts @@ -8,7 +8,7 @@ import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from '../../../elasticsearch'; import type { SavedObjectsRawDoc, SavedObjectsRawDocSource } from '../../serialization'; import { diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts index 0be8b1187af71..4bf0c2dcf979d 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts @@ -8,7 +8,7 @@ import Path from 'path'; import fs from 'fs/promises'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as kbnTestServer from '../../../../test_helpers/kbn_server'; import { Root } from '../../../root'; import JSON5 from 'json5'; diff --git a/src/core/server/saved_objects/migrationsv2/model/model.ts b/src/core/server/saved_objects/migrationsv2/model/model.ts index 5d8862e48df1a..6d9a6fee25d56 100644 --- a/src/core/server/saved_objects/migrationsv2/model/model.ts +++ b/src/core/server/saved_objects/migrationsv2/model/model.ts @@ -9,7 +9,7 @@ import * as Either from 'fp-ts/lib/Either'; import * as Option from 'fp-ts/lib/Option'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AliasAction, isLeftTypeof } from '../actions'; import { AllActionStates, MigrationLog, State } from '../types'; import type { ResponseType } from '../next'; diff --git a/src/core/server/saved_objects/migrationsv2/types.ts b/src/core/server/saved_objects/migrationsv2/types.ts index 4f6419930c6cc..e68e04e5267cc 100644 --- a/src/core/server/saved_objects/migrationsv2/types.ts +++ b/src/core/server/saved_objects/migrationsv2/types.ts @@ -8,7 +8,7 @@ import * as TaskEither from 'fp-ts/lib/TaskEither'; import * as Option from 'fp-ts/lib/Option'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ControlState } from './state_action_machine'; import { AliasAction } from './actions'; import { IndexMapping } from '../mappings'; diff --git a/src/core/server/saved_objects/service/lib/aggregations/validation.test.ts b/src/core/server/saved_objects/service/lib/aggregations/validation.test.ts index 53f1b5c9d78c5..0296dd25b56ee 100644 --- a/src/core/server/saved_objects/service/lib/aggregations/validation.test.ts +++ b/src/core/server/saved_objects/service/lib/aggregations/validation.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { validateAndConvertAggregations } from './validation'; type AggsMap = Record; diff --git a/src/core/server/saved_objects/service/lib/aggregations/validation.ts b/src/core/server/saved_objects/service/lib/aggregations/validation.ts index 5ef89f297a796..445d6b6a7ce22 100644 --- a/src/core/server/saved_objects/service/lib/aggregations/validation.ts +++ b/src/core/server/saved_objects/service/lib/aggregations/validation.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ObjectType } from '@kbn/config-schema'; import { isPlainObject } from 'lodash'; diff --git a/src/core/server/saved_objects/service/lib/point_in_time_finder.ts b/src/core/server/saved_objects/service/lib/point_in_time_finder.ts index 9faf5e85085ed..e7f3e9c378e90 100644 --- a/src/core/server/saved_objects/service/lib/point_in_time_finder.ts +++ b/src/core/server/saved_objects/service/lib/point_in_time_finder.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { Logger } from '../../../logging'; import type { SavedObjectsFindOptions, SavedObjectsClientContract } from '../../types'; import type { SavedObjectsFindResponse } from '../'; diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index 9cdc58f02f5d1..d48aeb35d9ced 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -7,7 +7,7 @@ */ import { omit, isObject } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from '../../../elasticsearch/'; import { isSupportedEsServer, isNotFoundFromUnsupportedServer } from '../../../elasticsearch'; import type { Logger } from '../../../logging'; diff --git a/src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts b/src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts index 3196a59ca39ee..f2cf0013dfe08 100644 --- a/src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts +++ b/src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts @@ -8,7 +8,7 @@ import Boom from '@hapi/boom'; -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IndexMapping } from '../../../mappings'; import { SavedObjectsPitParams } from '../../../types'; import { getQueryParams, HasReferenceQueryParams, SearchOperator } from './query_params'; diff --git a/src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts b/src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts index 592110a5413ec..2a3dca2629098 100644 --- a/src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts +++ b/src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import Boom from '@hapi/boom'; import { getProperty, IndexMapping } from '../../../mappings'; diff --git a/src/core/server/saved_objects/service/lib/update_objects_spaces.ts b/src/core/server/saved_objects/service/lib/update_objects_spaces.ts index 6d7c272c26eec..baa6525b1f33f 100644 --- a/src/core/server/saved_objects/service/lib/update_objects_spaces.ts +++ b/src/core/server/saved_objects/service/lib/update_objects_spaces.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import intersection from 'lodash/intersection'; import type { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry'; diff --git a/src/core/server/saved_objects/types.ts b/src/core/server/saved_objects/types.ts index 7e38a52bee0ca..5376af9c6c3ad 100644 --- a/src/core/server/saved_objects/types.ts +++ b/src/core/server/saved_objects/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SavedObjectsClient } from './service/saved_objects_client'; import { SavedObjectsTypeMappingDefinition } from './mappings'; import { SavedObjectMigrationMap } from './migrations'; diff --git a/src/core/types/elasticsearch/index.ts b/src/core/types/elasticsearch/index.ts index bec611778e6f5..09eff555fc857 100644 --- a/src/core/types/elasticsearch/index.ts +++ b/src/core/types/elasticsearch/index.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { InferSearchResponseOf, AggregateOf as AggregationResultOf, SearchHit } from './search'; export type ESFilter = estypes.QueryDslQueryContainer; diff --git a/src/core/types/elasticsearch/search.ts b/src/core/types/elasticsearch/search.ts index a54f5f3758ce3..2e79bf6fea57c 100644 --- a/src/core/types/elasticsearch/search.ts +++ b/src/core/types/elasticsearch/search.ts @@ -7,7 +7,7 @@ */ import { ValuesType } from 'utility-types'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; type InvalidAggregationRequest = unknown; From 1faf379bae9949c36b5c09b8f34576db5675c573 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Oct 2021 17:09:15 +0200 Subject: [PATCH 006/172] import errors from root --- src/core/server/elasticsearch/client/errors.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/server/elasticsearch/client/errors.ts b/src/core/server/elasticsearch/client/errors.ts index 356c2e370c471..21452af770ff4 100644 --- a/src/core/server/elasticsearch/client/errors.ts +++ b/src/core/server/elasticsearch/client/errors.ts @@ -6,14 +6,14 @@ * Side Public License, v 1. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; -export type UnauthorizedError = ResponseError & { +export type UnauthorizedError = errors.ResponseError & { statusCode: 401; }; -export function isResponseError(error: unknown): error is ResponseError { - return error instanceof ResponseError; +export function isResponseError(error: unknown): error is errors.ResponseError { + return error instanceof errors.ResponseError; } export function isUnauthorizedError(error: unknown): error is UnauthorizedError { From ceb4886a8e6702f7c26fbbc6a70bbb4403296f98 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 5 Oct 2021 17:11:38 +0200 Subject: [PATCH 007/172] import errors from root 2 --- .../actions/integration_tests/actions.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts index 21e99d83443f6..70f5943c11a44 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts @@ -38,7 +38,7 @@ import { } from '../../actions'; import * as Either from 'fp-ts/lib/Either'; import * as Option from 'fp-ts/lib/Option'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { DocumentsTransformFailed, DocumentsTransformSuccess } from '../../../migrations/core'; import { TaskEither } from 'fp-ts/lib/TaskEither'; import Path from 'path'; @@ -412,7 +412,7 @@ describe('migration actions', () => { await expect(cloneIndexPromise).resolves.toMatchObject({ _tag: 'Left', left: { - error: expect.any(ResponseError), + error: expect.any(errors.ResponseError), message: expect.stringMatching(/\"timed_out\":true/), type: 'retryable_es_client_error', }, @@ -810,7 +810,7 @@ describe('migration actions', () => { await expect(task()).resolves.toMatchObject({ _tag: 'Left', left: { - error: expect.any(ResponseError), + error: expect.any(errors.ResponseError), message: expect.stringMatching( /\[timeout_exception\] Timed out waiting for completion of \[org.elasticsearch.index.reindex.BulkByScrollTask/ ), @@ -1169,7 +1169,7 @@ describe('migration actions', () => { await expect(task()).resolves.toMatchObject({ _tag: 'Left', left: { - error: expect.any(ResponseError), + error: expect.any(errors.ResponseError), message: expect.stringMatching( /\[timeout_exception\] Timed out waiting for completion of \[org.elasticsearch.index.reindex.BulkByScrollTask/ ), From f93b8dc8f67864f1881cba09bc6a8912eeb6f6da Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 09:52:57 +0200 Subject: [PATCH 008/172] update transport import --- src/core/server/elasticsearch/client/client_config.ts | 6 +++--- .../server/elasticsearch/client/configure_client.test.ts | 2 +- src/core/server/elasticsearch/client/configure_client.ts | 2 +- src/core/server/elasticsearch/client/mocks.ts | 2 +- .../saved_objects/migrations/core/migration_es_client.ts | 2 +- .../saved_objects/service/lib/repository_es_client.ts | 2 +- .../data/common/search/strategies/eql_search/types.ts | 2 +- .../server/search/strategies/es_search/request_utils.ts | 2 +- .../helpers/create_es_client/cancel_es_request_on_abort.ts | 2 +- .../create_es_client/create_internal_es_client/index.ts | 2 +- x-pack/plugins/canvas/types/strategy.ts | 2 +- .../fleet/server/services/artifacts/artifacts.test.ts | 2 +- .../services/epm/elasticsearch/ingest_pipeline/install.ts | 2 +- .../lib/adapters/framework/kibana_framework_adapter.ts | 2 +- x-pack/plugins/infra/server/utils/get_all_composite_data.ts | 2 +- .../detection_engine/signals/signal_rule_alert_type.test.ts | 2 +- .../server/lib/detection_engine/signals/utils.test.ts | 4 ++-- .../server/lib/detection_engine/signals/utils.ts | 4 ++-- .../server/lib/es_deprecations_status.test.ts | 2 +- .../server/lib/reindexing/reindex_actions.test.ts | 2 +- .../server/lib/reindexing/reindex_service.test.ts | 2 +- x-pack/test/detection_engine_api_integration/utils.ts | 3 +-- 22 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/core/server/elasticsearch/client/client_config.ts b/src/core/server/elasticsearch/client/client_config.ts index a6b0891fc12dd..fac4efeb8c19c 100644 --- a/src/core/server/elasticsearch/client/client_config.ts +++ b/src/core/server/elasticsearch/client/client_config.ts @@ -9,7 +9,7 @@ import { ConnectionOptions as TlsConnectionOptions } from 'tls'; import { URL } from 'url'; import { Duration } from 'moment'; -import { ClientOptions, NodeOptions } from '@elastic/elasticsearch'; +import type { ClientOptions } from '@elastic/elasticsearch/lib/client'; import { ElasticsearchConfig } from '../elasticsearch_config'; import { DEFAULT_HEADERS } from '../default_headers'; @@ -94,7 +94,7 @@ export function parseClientOptions( clientOptions.nodes = config.hosts.map((host) => convertHost(host)); if (config.ssl) { - clientOptions.ssl = generateSslConfig( + clientOptions.tls = generateSslConfig( config.ssl, scoped && !config.ssl.alwaysPresentCertificate ); @@ -142,7 +142,7 @@ const generateSslConfig = ( return ssl; }; -const convertHost = (host: string): NodeOptions => { +const convertHost = (host: string): { url: URL } => { const url = new URL(host); const isHTTPS = url.protocol === 'https:'; url.port = url.port || (isHTTPS ? '443' : '80'); diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index 35fcb5819d015..b2d8ca1d55ed6 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -15,7 +15,7 @@ import type { TransportRequestOptions, TransportRequestParams, RequestBody, -} from '@elastic/elasticsearch/lib/Transport'; +} from '@elastic/transport'; import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks'; import { loggingSystemMock } from '../../logging/logging_system.mock'; diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index 93c404593af3f..a20c8d96db7f1 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -13,7 +13,7 @@ import type { RequestBody, TransportRequestParams, TransportRequestOptions, -} from '@elastic/elasticsearch/lib/Transport'; +} from '@elastic/transport'; import { Logger } from '../../logging'; import { parseClientOptions, ElasticsearchClientConfig } from './client_config'; diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index 7c4cde1ae424d..2626dee6aeac2 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -7,7 +7,7 @@ */ import type { Client, ApiResponse } from '@elastic/elasticsearch'; -import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; +import { TransportRequestPromise } from '@elastic/transport'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import { ElasticsearchClient } from './types'; import { ICustomClusterClient } from './cluster_client'; diff --git a/src/core/server/saved_objects/migrations/core/migration_es_client.ts b/src/core/server/saved_objects/migrations/core/migration_es_client.ts index e8dc9c94b7861..4d14373e7961b 100644 --- a/src/core/server/saved_objects/migrations/core/migration_es_client.ts +++ b/src/core/server/saved_objects/migrations/core/migration_es_client.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; +import type { TransportRequestOptions } from '@elastic/transport'; import { get } from 'lodash'; import { set } from '@elastic/safer-lodash-set'; diff --git a/src/core/server/saved_objects/service/lib/repository_es_client.ts b/src/core/server/saved_objects/service/lib/repository_es_client.ts index 4e8592fa94cca..170fd2d058e58 100644 --- a/src/core/server/saved_objects/service/lib/repository_es_client.ts +++ b/src/core/server/saved_objects/service/lib/repository_es_client.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; +import type { TransportRequestOptions } from '@elastic/transport'; import { ElasticsearchClient } from '../../../elasticsearch/'; import { retryCallCluster } from '../../../elasticsearch/client/retry_call_cluster'; diff --git a/src/plugins/data/common/search/strategies/eql_search/types.ts b/src/plugins/data/common/search/strategies/eql_search/types.ts index a30adbaf47c60..a4013773e9538 100644 --- a/src/plugins/data/common/search/strategies/eql_search/types.ts +++ b/src/plugins/data/common/search/strategies/eql_search/types.ts @@ -7,7 +7,7 @@ */ import { EqlSearch } from '@elastic/elasticsearch/api/requestParams'; -import { ApiResponse, TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; +import { ApiResponse, TransportRequestOptions } from '@elastic/transport'; import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../types'; diff --git a/src/plugins/data/server/search/strategies/es_search/request_utils.ts b/src/plugins/data/server/search/strategies/es_search/request_utils.ts index 829497929c20f..5c089f974d54f 100644 --- a/src/plugins/data/server/search/strategies/es_search/request_utils.ts +++ b/src/plugins/data/server/search/strategies/es_search/request_utils.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; +import type { TransportRequestPromise } from '@elastic/transport'; import type { Search } from '@elastic/elasticsearch/api/requestParams'; import type { IUiSettingsClient, SharedGlobalConfig } from 'kibana/server'; import { UI_SETTINGS } from '../../../../common'; diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts index a14564fc8e268..3cacabe61b7bb 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; +import { TransportRequestPromise } from '@elastic/transport'; import { KibanaRequest } from 'src/core/server'; export function cancelEsRequestOnAbort>( diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts index 34801cdf94750..3bcdaed145ac2 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; +import { TransportRequestPromise } from '@elastic/transport'; import type { estypes } from '@elastic/elasticsearch'; import { unwrapEsResponse } from '../../../../../../observability/server'; import { APMRouteHandlerResources } from '../../../../routes/typings'; diff --git a/x-pack/plugins/canvas/types/strategy.ts b/x-pack/plugins/canvas/types/strategy.ts index d7115a3e4372f..055fb4c57cc66 100644 --- a/x-pack/plugins/canvas/types/strategy.ts +++ b/x-pack/plugins/canvas/types/strategy.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; +import { ApiResponse } from '@elastic/transport'; import { estypes } from '@elastic/elasticsearch'; import { IKibanaSearchRequest } from 'src/plugins/data/common'; import { ExpressionValueFilter } from '.'; diff --git a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts index b046b41d73722..c09ba881a81c0 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts @@ -9,7 +9,7 @@ import { elasticsearchServiceMock } from 'src/core/server/mocks'; import { ResponseError } from '@elastic/elasticsearch/lib/errors'; -import type { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; +import type { ApiResponse } from '@elastic/transport'; import { FLEET_SERVER_ARTIFACTS_INDEX } from '../../../common'; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts index 46750105900d5..8cdaccc105eaf 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; +import type { TransportRequestOptions } from '@elastic/transport'; import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; import { ElasticsearchAssetType } from '../../../../types'; diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index 4576a2e8452ac..5af341e2d77c5 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -10,7 +10,7 @@ import { IndicesGet, MlGetBuckets, } from '@elastic/elasticsearch/api/requestParams'; -import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport'; +import { TransportRequestParams } from '@elastic/transport'; import { estypes } from '@elastic/elasticsearch'; import { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; import { diff --git a/x-pack/plugins/infra/server/utils/get_all_composite_data.ts b/x-pack/plugins/infra/server/utils/get_all_composite_data.ts index 1ab290796e36d..2faac324c3858 100644 --- a/x-pack/plugins/infra/server/utils/get_all_composite_data.ts +++ b/x-pack/plugins/infra/server/utils/get_all_composite_data.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; +import { ApiResponse } from '@elastic/transport'; import { InfraDatabaseSearchResponse } from '../lib/adapters/framework'; export const getAllCompositeData = async < diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts index 2696d6981083e..caba810b116e8 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts @@ -24,7 +24,7 @@ import { listMock } from '../../../../../lists/server/mocks'; import { getListClientMock } from '../../../../../lists/server/services/lists/list_client.mock'; import { getExceptionListClientMock } from '../../../../../lists/server/services/exception_lists/exception_list_client.mock'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; -import { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; +import { ApiResponse } from '@elastic/transport'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; import { queryExecutor } from './executors/query'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts index c3e95d6d196ca..4b9c51da2bd41 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts @@ -7,7 +7,7 @@ import moment from 'moment'; import sinon from 'sinon'; -import { ApiResponse, Context } from '@elastic/elasticsearch/lib/Transport'; +import { ApiResponse } from '@elastic/transport'; import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; import { listMock } from '../../../../../lists/server/mocks'; @@ -758,7 +758,7 @@ describe('utils', () => { test('returns true when missing timestamp override field', async () => { const timestampField = 'event.ingested'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, Context>> = { + const timestampFieldCapsResponse: Partial, unknown>> = { body: { indices: ['myfakeindex-1', 'myfakeindex-2', 'myfakeindex-3', 'myfakeindex-4'], fields: { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index 3ac533649a242..8ef5384fbf1c9 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -11,7 +11,7 @@ import uuidv5 from 'uuid/v5'; import dateMath from '@elastic/datemath'; import type { estypes } from '@elastic/elasticsearch'; -import { ApiResponse, Context } from '@elastic/elasticsearch/lib/Transport'; +import { ApiResponse } from '@elastic/transport'; import { ALERT_INSTANCE_ID, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; import type { ListArray, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { MAX_EXCEPTION_LIST_SIZE } from '@kbn/securitysolution-list-constants'; @@ -151,7 +151,7 @@ export const hasTimestampFields = async (args: { // any is derived from here // node_modules/@elastic/elasticsearch/lib/api/kibana.d.ts // eslint-disable-next-line @typescript-eslint/no-explicit-any - timestampFieldCapsResponse: ApiResponse, Context>; + timestampFieldCapsResponse: ApiResponse, unknown>; inputIndices: string[]; ruleStatusClient: IRuleExecutionLogClient; ruleId: string; diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts index e1a348f8ed8ee..d9245990ae6a0 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts @@ -6,7 +6,7 @@ */ import _ from 'lodash'; -import { RequestEvent } from '@elastic/elasticsearch/lib/Transport'; +import { RequestEvent } from '@elastic/transport'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; import { MigrationDeprecationInfoResponse } from '@elastic/elasticsearch/api/types'; diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts index 3cfdb1fdd3167..3477020daf4f4 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { RequestEvent } from '@elastic/elasticsearch/lib/Transport'; +import { RequestEvent } from '@elastic/transport'; import { SavedObjectsErrorHelpers } from 'src/core/server'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts index 7a5bf1c187698..b73c4b2df413b 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts @@ -7,7 +7,7 @@ jest.mock('../es_indices_state_check', () => ({ esIndicesStateCheck: jest.fn() })); import { BehaviorSubject } from 'rxjs'; -import { RequestEvent } from '@elastic/elasticsearch/lib/Transport'; +import { RequestEvent } from '@elastic/transport'; import { Logger } from 'src/core/server'; import { elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index ec776c6f3ccd2..80ddb5e1cfe76 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -7,7 +7,6 @@ import { KbnClient } from '@kbn/test'; import type { ApiResponse } from '@elastic/elasticsearch'; -import { Context } from '@elastic/elasticsearch/lib/Transport'; import type { estypes } from '@elastic/elasticsearch'; import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type SuperTest from 'supertest'; @@ -795,7 +794,7 @@ export const waitFor = async ( * @param timeoutWait Time to wait before trying again (has default) */ export const countDownES = async ( - esFunction: () => Promise, Context>>, + esFunction: () => Promise, unknown>>, esFunctionName: string, retryCount: number = 20, timeoutWait = 250 From 279533d88f3ca7323684b4ded2e3034e6db770f5 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 09:56:15 +0200 Subject: [PATCH 009/172] update import path for /api/types --- src/core/server/core_usage_data/core_usage_data_service.ts | 2 +- .../saved_objects/service/lib/internal_bulk_resolve.ts | 2 +- src/plugins/data/public/search/errors/utils.ts | 2 +- src/plugins/data/server/autocomplete/terms_enum.test.ts | 2 +- x-pack/plugins/apm/common/utils/environment_query.ts | 2 +- .../apm/public/components/shared/kuery_bar/index.tsx | 2 +- x-pack/plugins/apm/public/components/shared/search_bar.tsx | 2 +- .../apm/scripts/create-functional-tests-archive/index.ts | 2 +- .../lib/alerts/chart_preview/get_transaction_duration.ts | 2 +- .../lib/alerts/register_transaction_duration_alert_type.ts | 2 +- .../register_transaction_duration_anomaly_alert_type.ts | 2 +- .../server/lib/connections/exclude_rum_exit_spans_query.ts | 2 +- .../connections/get_connection_stats/get_destination_map.ts | 2 +- .../lib/connections/get_connection_stats/get_stats.ts | 2 +- .../server/lib/connections/get_connection_stats/index.ts | 2 +- .../apm/server/lib/event_metadata/get_event_metadata.ts | 2 +- .../create_es_client/create_apm_event_client/index.ts | 2 +- .../server/lib/settings/custom_link/list_custom_links.ts | 2 +- x-pack/plugins/apm/server/lib/traces/get_trace_items.ts | 2 +- x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts | 2 +- .../apm/server/lib/transactions/get_anomaly_data/fetcher.ts | 2 +- .../transactions/trace_samples/get_trace_samples/index.ts | 2 +- x-pack/plugins/apm/server/projections/metrics.ts | 2 +- x-pack/plugins/event_log/server/es/init.ts | 5 ++++- .../ml/server/lib/alerts/jobs_health_service.test.ts | 2 +- x-pack/plugins/ml/server/lib/alerts/jobs_health_service.ts | 2 +- .../server/lib/alerts/register_jobs_monitoring_rule_type.ts | 6 +++++- .../server/models/job_audit_messages/job_audit_messages.ts | 2 +- .../server/lib/elasticsearch_settings/cluster.test.ts | 2 +- .../monitoring/server/lib/elasticsearch_settings/cluster.ts | 2 +- .../series_editor/columns/filter_expanded.tsx | 2 +- x-pack/plugins/osquery/server/usage/fetchers.ts | 2 +- .../server/lib/store/ilm_policy_manager/constants.ts | 2 +- x-pack/plugins/snapshot_restore/server/routes/api/policy.ts | 2 +- .../snapshot_restore/server/routes/api/repositories.ts | 2 +- x-pack/plugins/upgrade_assistant/common/types.ts | 2 +- .../server/lib/es_deprecations_status.test.ts | 2 +- .../upgrade_assistant/server/lib/es_deprecations_status.ts | 2 +- .../uptime/server/lib/requests/get_journey_details.ts | 2 +- .../uptime/server/lib/requests/get_journey_failed_steps.ts | 2 +- .../uptime/server/lib/requests/get_journey_screenshot.ts | 2 +- .../plugins/uptime/server/lib/requests/get_journey_steps.ts | 2 +- .../uptime/server/lib/requests/get_latest_monitor.ts | 2 +- .../uptime/server/lib/requests/get_monitor_duration.ts | 2 +- .../uptime/server/lib/requests/get_monitor_status.ts | 2 +- .../uptime/server/lib/requests/get_network_events.ts | 2 +- x-pack/plugins/uptime/server/lib/requests/get_pings.ts | 2 +- x-pack/plugins/uptime/server/lib/requests/helper.ts | 5 ++++- 48 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/core/server/core_usage_data/core_usage_data_service.ts b/src/core/server/core_usage_data/core_usage_data_service.ts index 72b70824d305d..7630e26026c5b 100644 --- a/src/core/server/core_usage_data/core_usage_data_service.ts +++ b/src/core/server/core_usage_data/core_usage_data_service.ts @@ -17,7 +17,7 @@ import { AggregationsFiltersAggregate, AggregationsFiltersBucketItem, SearchTotalHits, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CoreContext } from '../core_context'; import { ElasticsearchConfigType } from '../elasticsearch/elasticsearch_config'; import { HttpConfigType, InternalHttpServiceSetup } from '../http'; diff --git a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts index f53a85a9a03ef..558faad125af9 100644 --- a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts +++ b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { MgetHit } from '@elastic/elasticsearch/api/types'; +import type { MgetHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CORE_USAGE_STATS_ID, diff --git a/src/plugins/data/public/search/errors/utils.ts b/src/plugins/data/public/search/errors/utils.ts index cb3e83dc8001c..4373939878d68 100644 --- a/src/plugins/data/public/search/errors/utils.ts +++ b/src/plugins/data/public/search/errors/utils.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { ErrorCause } from '@elastic/elasticsearch/api/types'; +import type { ErrorCause } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { FailedShard, Reason } from './types'; import { KibanaServerError } from '../../../../kibana_utils/common'; diff --git a/src/plugins/data/server/autocomplete/terms_enum.test.ts b/src/plugins/data/server/autocomplete/terms_enum.test.ts index 444ba4e89c58b..2340b6bcec7ca 100644 --- a/src/plugins/data/server/autocomplete/terms_enum.test.ts +++ b/src/plugins/data/server/autocomplete/terms_enum.test.ts @@ -12,7 +12,7 @@ import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; import { ConfigSchema } from '../../config'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import type { ApiResponse } from '@elastic/elasticsearch'; -import { TermsEnumResponse } from '@elastic/elasticsearch/api/types'; +import { TermsEnumResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; let savedObjectsClientMock: jest.Mocked; let esClientMock: DeeplyMockedKeys; diff --git a/x-pack/plugins/apm/common/utils/environment_query.ts b/x-pack/plugins/apm/common/utils/environment_query.ts index 7b35f90d87691..e2f9a722e3de2 100644 --- a/x-pack/plugins/apm/common/utils/environment_query.ts +++ b/x-pack/plugins/apm/common/utils/environment_query.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SERVICE_ENVIRONMENT } from '../elasticsearch_fieldnames'; import { ENVIRONMENT_ALL, diff --git a/x-pack/plugins/apm/public/components/shared/kuery_bar/index.tsx b/x-pack/plugins/apm/public/components/shared/kuery_bar/index.tsx index c0417f4a8bbda..1b1c4e1f80a2d 100644 --- a/x-pack/plugins/apm/public/components/shared/kuery_bar/index.tsx +++ b/x-pack/plugins/apm/public/components/shared/kuery_bar/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import { uniqueId } from 'lodash'; import React, { useState } from 'react'; diff --git a/x-pack/plugins/apm/public/components/shared/search_bar.tsx b/x-pack/plugins/apm/public/components/shared/search_bar.tsx index 035635908e56c..4b8c8f3eadd6b 100644 --- a/x-pack/plugins/apm/public/components/shared/search_bar.tsx +++ b/x-pack/plugins/apm/public/components/shared/search_bar.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiFlexGroup, EuiFlexGroupProps, diff --git a/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts b/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts index b9102efee50dc..9ef2c5a52bff1 100644 --- a/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts +++ b/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts @@ -10,7 +10,7 @@ import { execSync } from 'child_process'; import moment from 'moment'; import path from 'path'; import fs from 'fs'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getEsClient } from '../shared/get_es_client'; import { parseIndexUrl } from '../shared/parse_index_url'; diff --git a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts index 1f8b88b3db3e7..14f342115dda9 100644 --- a/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts +++ b/x-pack/plugins/apm/server/lib/alerts/chart_preview/get_transaction_duration.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { rangeQuery } from '../../../../../observability/server'; import { SERVICE_NAME, diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts index b383b4777eca4..45ae7d1eeb016 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_alert_type.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import type { ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, diff --git a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts index 08203646d9004..2809d7feadb37 100644 --- a/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts +++ b/x-pack/plugins/apm/server/lib/alerts/register_transaction_duration_anomaly_alert_type.ts @@ -8,7 +8,7 @@ import { schema } from '@kbn/config-schema'; import { compact } from 'lodash'; import { ESSearchResponse } from 'src/core/types/elasticsearch'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED, ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED, diff --git a/x-pack/plugins/apm/server/lib/connections/exclude_rum_exit_spans_query.ts b/x-pack/plugins/apm/server/lib/connections/exclude_rum_exit_spans_query.ts index 89a510fe508c6..4e15500a59466 100644 --- a/x-pack/plugins/apm/server/lib/connections/exclude_rum_exit_spans_query.ts +++ b/x-pack/plugins/apm/server/lib/connections/exclude_rum_exit_spans_query.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AGENT_NAME } from '../../../common/elasticsearch_fieldnames'; import { RUM_AGENT_NAMES } from '../../../common/agent_name'; diff --git a/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_destination_map.ts b/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_destination_map.ts index be6518708eddb..2eb0ed3db02bd 100644 --- a/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_destination_map.ts +++ b/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_destination_map.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import objectHash from 'object-hash'; import { getOffsetInMs } from '../../../../common/utils/get_offset_in_ms'; import { ENVIRONMENT_NOT_DEFINED } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_stats.ts b/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_stats.ts index 4f48f3388c017..ff46db949d122 100644 --- a/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_stats.ts +++ b/x-pack/plugins/apm/server/lib/connections/get_connection_stats/get_stats.ts @@ -7,7 +7,7 @@ import { sum } from 'lodash'; import objectHash from 'object-hash'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent'; import { getOffsetInMs } from '../../../../common/utils/get_offset_in_ms'; import { ENVIRONMENT_NOT_DEFINED } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/connections/get_connection_stats/index.ts b/x-pack/plugins/apm/server/lib/connections/get_connection_stats/index.ts index 03b94defda6dd..5c1c628762edb 100644 --- a/x-pack/plugins/apm/server/lib/connections/get_connection_stats/index.ts +++ b/x-pack/plugins/apm/server/lib/connections/get_connection_stats/index.ts @@ -7,7 +7,7 @@ import { ValuesType } from 'utility-types'; import { merge } from 'lodash'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { joinByKey } from '../../../../common/utils/join_by_key'; import { Setup } from '../../helpers/setup_request'; import { getStats } from './get_stats'; diff --git a/x-pack/plugins/apm/server/lib/event_metadata/get_event_metadata.ts b/x-pack/plugins/apm/server/lib/event_metadata/get_event_metadata.ts index 97e2e1356363f..b9e0dee52a42e 100644 --- a/x-pack/plugins/apm/server/lib/event_metadata/get_event_metadata.ts +++ b/x-pack/plugins/apm/server/lib/event_metadata/get_event_metadata.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ERROR_ID, SPAN_ID, diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts index b2b2a0b869c80..78587e1303a08 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts @@ -8,7 +8,7 @@ import type { TermsEnumRequest, TermsEnumResponse, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ValuesType } from 'utility-types'; import { withApmSpan } from '../../../../utils/with_apm_span'; import { Profile } from '../../../../../typings/es_schemas/ui/profile'; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts index d477da85e0d9b..633545e16acfd 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/list_custom_links.ts @@ -6,7 +6,7 @@ */ import * as t from 'io-ts'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CustomLink, CustomLinkES, diff --git a/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts b/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts index e940100edcf52..49b6372d9466c 100644 --- a/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts +++ b/x-pack/plugins/apm/server/lib/traces/get_trace_items.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ProcessorEvent } from '../../../common/processor_event'; import { TRACE_ID, diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts index dc7cc0f804469..6a12ab50a4e2e 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/fetcher.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { sortBy } from 'lodash'; import moment from 'moment'; import { Unionize } from 'utility-types'; diff --git a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts b/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts index a7357bbc1dd34..73a175a2e9a74 100644 --- a/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts +++ b/x-pack/plugins/apm/server/lib/transactions/get_anomaly_data/fetcher.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESSearchResponse } from '../../../../../../../src/core/types/elasticsearch'; import { PromiseReturnType } from '../../../../../observability/typings/common'; import { rangeQuery } from '../../../../../observability/server'; diff --git a/x-pack/plugins/apm/server/lib/transactions/trace_samples/get_trace_samples/index.ts b/x-pack/plugins/apm/server/lib/transactions/trace_samples/get_trace_samples/index.ts index 79eebf0813e36..b085c0fc4a839 100644 --- a/x-pack/plugins/apm/server/lib/transactions/trace_samples/get_trace_samples/index.ts +++ b/x-pack/plugins/apm/server/lib/transactions/trace_samples/get_trace_samples/index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { withApmSpan } from '../../../../utils/with_apm_span'; import { SERVICE_NAME, diff --git a/x-pack/plugins/apm/server/projections/metrics.ts b/x-pack/plugins/apm/server/projections/metrics.ts index ce5a506752b65..417281f2de487 100644 --- a/x-pack/plugins/apm/server/projections/metrics.ts +++ b/x-pack/plugins/apm/server/projections/metrics.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SERVICE_NAME, SERVICE_NODE_NAME, diff --git a/x-pack/plugins/event_log/server/es/init.ts b/x-pack/plugins/event_log/server/es/init.ts index f15b9f89887c5..da603deb476d4 100644 --- a/x-pack/plugins/event_log/server/es/init.ts +++ b/x-pack/plugins/event_log/server/es/init.ts @@ -5,7 +5,10 @@ * 2.0. */ -import { IndicesAlias, IndicesIndexStatePrefixedSettings } from '@elastic/elasticsearch/api/types'; +import { + IndicesAlias, + IndicesIndexStatePrefixedSettings, +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { estypes } from '@elastic/elasticsearch'; import { asyncForEach } from '@kbn/std'; import { getIlmPolicy, getIndexTemplate } from './documents'; diff --git a/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.test.ts b/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.test.ts index 2790ce423c1e7..e824e34a1779b 100644 --- a/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.test.ts +++ b/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.test.ts @@ -9,7 +9,7 @@ import { JobsHealthService, jobsHealthServiceProvider } from './jobs_health_serv import type { DatafeedsService } from '../../models/job_service/datafeeds'; import type { Logger } from 'kibana/server'; import { MlClient } from '../ml_client'; -import { MlJob, MlJobStats } from '@elastic/elasticsearch/api/types'; +import { MlJob, MlJobStats } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AnnotationService } from '../../models/annotation_service/annotation'; import { JobsHealthExecutorOptions } from './register_jobs_monitoring_rule_type'; import { JobAuditMessagesService } from '../../models/job_audit_messages/job_audit_messages'; diff --git a/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.ts b/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.ts index 70a8e4a777b69..2fbda6a4b37f6 100644 --- a/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.ts +++ b/x-pack/plugins/ml/server/lib/alerts/jobs_health_service.ts @@ -8,7 +8,7 @@ import { groupBy, keyBy, memoize } from 'lodash'; import { KibanaRequest, Logger, SavedObjectsClientContract } from 'kibana/server'; import { i18n } from '@kbn/i18n'; -import { MlJob } from '@elastic/elasticsearch/api/types'; +import { MlJob } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { MlClient } from '../ml_client'; import { JobSelection } from '../../routes/schemas/alerting_schema'; import { datafeedsProvider, DatafeedsService } from '../../models/job_service/datafeeds'; diff --git a/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts b/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts index dcf545fa4060b..5fd21d5372d23 100644 --- a/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts +++ b/x-pack/plugins/ml/server/lib/alerts/register_jobs_monitoring_rule_type.ts @@ -7,7 +7,11 @@ import { i18n } from '@kbn/i18n'; import { KibanaRequest } from 'kibana/server'; -import { MlDatafeedState, MlJobState, MlJobStats } from '@elastic/elasticsearch/api/types'; +import { + MlDatafeedState, + MlJobState, + MlJobStats, +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ML_ALERT_TYPES } from '../../../common/constants/alerts'; import { PLUGIN_ID } from '../../../common/constants/app'; import { MINIMUM_FULL_LICENSE } from '../../../common/license'; diff --git a/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts b/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts index 69f5c8b36f10c..530a1342ad340 100644 --- a/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts +++ b/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts @@ -7,7 +7,7 @@ import moment from 'moment'; import type { IScopedClusterClient } from 'kibana/server'; -import type { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { estypes } from '@elastic/elasticsearch'; import { ML_NOTIFICATION_INDEX_PATTERN } from '../../../common/constants/index_patterns'; import { MESSAGE_LEVEL } from '../../../common/constants/message_levels'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.test.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.test.ts index 8b2ea8459e26c..985ad2357648a 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.test.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ClusterGetSettingsResponse } from '@elastic/elasticsearch/api/types'; +import { ClusterGetSettingsResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { checkClusterSettings } from '.'; import { LegacyRequest } from '../../types'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.ts index 4f46f65591d62..b474cca59519e 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch_settings/cluster.ts @@ -6,7 +6,7 @@ */ import { get } from 'lodash'; -import { ClusterGetSettingsResponse } from '@elastic/elasticsearch/api/types'; +import { ClusterGetSettingsResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { findReason } from './find_reason'; import { ClusterSettingsReasonResponse, LegacyRequest } from '../../types'; diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/filter_expanded.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/filter_expanded.tsx index 693b79c6dc831..cae1cfee3c0ab 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/filter_expanded.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/filter_expanded.tsx @@ -17,7 +17,7 @@ import { import styled from 'styled-components'; import { rgba } from 'polished'; import { i18n } from '@kbn/i18n'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { map } from 'lodash'; import { ExistsFilter, isExistsFilter } from '@kbn/es-query'; import { useAppIndexPatternContext } from '../../hooks/use_app_index_pattern'; diff --git a/x-pack/plugins/osquery/server/usage/fetchers.ts b/x-pack/plugins/osquery/server/usage/fetchers.ts index 3ac7d56acac4d..cbf72f9144b4b 100644 --- a/x-pack/plugins/osquery/server/usage/fetchers.ts +++ b/x-pack/plugins/osquery/server/usage/fetchers.ts @@ -10,7 +10,7 @@ import { AggregationsTopHitsAggregate, AggregationsValueAggregate, SearchResponse, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { PackagePolicyServiceInterface } from '../../../fleet/server'; import { getRouteMetric } from '../routes/usage'; import { ElasticsearchClient, SavedObjectsClientContract } from '../../../../../src/core/server'; diff --git a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts index bea2ba21c0846..cbbf21094d61f 100644 --- a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts +++ b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { IlmPutLifecycleRequest } from '@elastic/elasticsearch/api/types'; +import type { IlmPutLifecycleRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export const reportingIlmPolicy: IlmPutLifecycleRequest['body'] = { policy: { diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts b/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts index a93540c1ba90d..36c56feba444a 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts @@ -38,7 +38,7 @@ export function registerPolicyRoutes({ body: { policies: Object.entries(policiesByName).map(([name, policy]) => { // TODO: Figure out why our {@link SlmPolicyEs} is not compatible with: - // import type { SnapshotLifecyclePolicyMetadata } from '@elastic/elasticsearch/api/types'; + // import type { SnapshotLifecyclePolicyMetadata } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; return deserializePolicy(name, policy as SlmPolicyEs, managedPolicies); }), }, diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts b/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts index 6048ec3b52656..c2f59e6433b73 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts @@ -9,7 +9,7 @@ import { TypeOf } from '@kbn/config-schema'; import type { SnapshotGetRepositoryResponse, SnapshotRepositorySettings, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DEFAULT_REPOSITORY_TYPES, REPOSITORY_PLUGINS_MAP } from '../../../common/constants'; import { Repository, RepositoryType } from '../../../common/types'; diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts index a390dd26a0747..f07569c3bbbad 100644 --- a/x-pack/plugins/upgrade_assistant/common/types.ts +++ b/x-pack/plugins/upgrade_assistant/common/types.ts @@ -8,7 +8,7 @@ import { MigrationDeprecationInfoDeprecation, MigrationDeprecationInfoResponse, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SavedObject, SavedObjectAttributes } from 'src/core/public'; export enum ReindexStep { diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts index d9245990ae6a0..76e6550e62ec9 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts @@ -8,7 +8,7 @@ import _ from 'lodash'; import { RequestEvent } from '@elastic/transport'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; -import { MigrationDeprecationInfoResponse } from '@elastic/elasticsearch/api/types'; +import { MigrationDeprecationInfoResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getESUpgradeStatus } from './es_deprecations_status'; import fakeDeprecations from './__fixtures__/fake_deprecations.json'; diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts index cd719cc0f32b5..df16b4150d579 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts @@ -8,7 +8,7 @@ import { MigrationDeprecationInfoDeprecation, MigrationDeprecationInfoResponse, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient } from 'src/core/server'; import { indexSettingDeprecations } from '../../common/constants'; import { EnrichedDeprecationInfo, ESUpgradeStatus } from '../../common/types'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_journey_details.ts b/x-pack/plugins/uptime/server/lib/requests/get_journey_details.ts index b389699e2074a..24e33b9248da6 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_journey_details.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_journey_details.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMElasticsearchQueryFn } from '../adapters/framework'; import { JourneyStep, diff --git a/x-pack/plugins/uptime/server/lib/requests/get_journey_failed_steps.ts b/x-pack/plugins/uptime/server/lib/requests/get_journey_failed_steps.ts index 52a7b67000fec..c53f1b589ef7a 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_journey_failed_steps.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_journey_failed_steps.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { asMutableArray } from '../../../common/utils/as_mutable_array'; import { UMElasticsearchQueryFn } from '../adapters/framework'; import { JourneyStep } from '../../../common/runtime_types/ping/synthetics'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_journey_screenshot.ts b/x-pack/plugins/uptime/server/lib/requests/get_journey_screenshot.ts index 3d95d35aa90d0..be9f21d4cea02 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_journey_screenshot.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_journey_screenshot.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMElasticsearchQueryFn } from '../adapters'; import { RefResult, FullScreenshot } from '../../../common/runtime_types/ping/synthetics'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_journey_steps.ts b/x-pack/plugins/uptime/server/lib/requests/get_journey_steps.ts index f843859575e31..3e48ae7cccfbc 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_journey_steps.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_journey_steps.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { asMutableArray } from '../../../common/utils/as_mutable_array'; import { UMElasticsearchQueryFn } from '../adapters/framework'; import { JourneyStep } from '../../../common/runtime_types/ping/synthetics'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts b/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts index 36968fa97fda4..f6f1d7ff938be 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMElasticsearchQueryFn } from '../adapters'; import { Ping } from '../../../common/runtime_types'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts b/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts index be134a311af66..35e02da34148e 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_monitor_duration.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMElasticsearchQueryFn } from '../adapters'; import { LocationDurationLine, MonitorDurationResult } from '../../../common/types'; import { QUERY, UNNAMED_LOCATION } from '../../../common/constants'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_monitor_status.ts b/x-pack/plugins/uptime/server/lib/requests/get_monitor_status.ts index 5227b8ca7dcc2..ab21a12aa735e 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_monitor_status.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_monitor_status.ts @@ -6,7 +6,7 @@ */ import { JsonObject } from '@kbn/utility-types'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { asMutableArray } from '../../../common/utils/as_mutable_array'; import { UMElasticsearchQueryFn } from '../adapters'; import { Ping } from '../../../common/runtime_types/ping'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_network_events.ts b/x-pack/plugins/uptime/server/lib/requests/get_network_events.ts index 20e5c3a2a1185..1b6f02f90d34c 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_network_events.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_network_events.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMElasticsearchQueryFn } from '../adapters/framework'; import { NetworkEvent } from '../../../common/runtime_types'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_pings.ts b/x-pack/plugins/uptime/server/lib/requests/get_pings.ts index 86c96c5f589bc..c084c6e6afe82 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_pings.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_pings.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMElasticsearchQueryFn } from '../adapters/framework'; import { GetPingsParams, diff --git a/x-pack/plugins/uptime/server/lib/requests/helper.ts b/x-pack/plugins/uptime/server/lib/requests/helper.ts index 03cc3e1ea3713..b12b979d786e6 100644 --- a/x-pack/plugins/uptime/server/lib/requests/helper.ts +++ b/x-pack/plugins/uptime/server/lib/requests/helper.ts @@ -5,7 +5,10 @@ * 2.0. */ -import { AggregationsAggregate, SearchResponse } from '@elastic/elasticsearch/api/types'; +import { + AggregationsAggregate, + SearchResponse, +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ElasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; import { From 13b152fd590fa5a2972de81837fd99dc45abd768 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 09:57:37 +0200 Subject: [PATCH 010/172] update import path for /api/types --- .../server/lib/deprecations/check_ilm_migration_status.ts | 2 +- x-pack/plugins/reporting/server/lib/store/store.ts | 2 +- x-pack/plugins/reporting/server/lib/tasks/execute_report.ts | 2 +- x-pack/plugins/reporting/server/routes/deprecations.ts | 2 +- x-pack/plugins/reporting/server/routes/lib/jobs_query.ts | 6 +++++- .../rule_registry/server/alert_data_client/alerts_client.ts | 5 ++++- .../plugins/rule_registry/server/rule_data_client/types.ts | 2 +- .../plugins/rule_registry/server/utils/persistence_types.ts | 2 +- .../common/endpoint/data_loaders/index_endpoint_actions.ts | 2 +- .../common/endpoint/data_loaders/index_endpoint_hosts.ts | 2 +- .../common/endpoint/data_loaders/index_fleet_actions.ts | 2 +- .../common/endpoint/data_loaders/index_fleet_agent.ts | 2 +- .../lib/artifacts/migrate_artifacts_to_fleet.test.ts | 2 +- .../lib/metadata/check_metadata_transforms_task.test.ts | 2 +- .../endpoint/lib/metadata/check_metadata_transforms_task.ts | 2 +- .../server/endpoint/routes/metadata/handlers.ts | 2 +- .../endpoint/routes/metadata/support/query_strategies.ts | 2 +- .../rule_registry_adapter/rule_registry_log_client/utils.ts | 2 +- .../server/lib/detection_engine/rule_types/types.ts | 2 +- .../lib/detection_engine/signals/executors/threshold.ts | 2 +- .../signals/threshold/build_signal_history.ts | 2 +- .../security_solution/server/lib/telemetry/receiver.ts | 2 +- .../api_integration/apis/ml/job_audit_messages/index.ts | 2 +- .../tests/service_overview/dependencies/es_utils.ts | 2 +- 24 files changed, 31 insertions(+), 24 deletions(-) diff --git a/x-pack/plugins/reporting/server/lib/deprecations/check_ilm_migration_status.ts b/x-pack/plugins/reporting/server/lib/deprecations/check_ilm_migration_status.ts index dc20f92f38c94..629a44ecbcc9e 100644 --- a/x-pack/plugins/reporting/server/lib/deprecations/check_ilm_migration_status.ts +++ b/x-pack/plugins/reporting/server/lib/deprecations/check_ilm_migration_status.ts @@ -7,7 +7,7 @@ import type { IndicesIndexStatePrefixedSettings, IndicesIndexSettings, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ILM_POLICY_NAME } from '../../../common/constants'; import { IlmPolicyMigrationStatus } from '../../../common/types'; import { IlmPolicyManager } from '../../lib/store/ilm_policy_manager'; diff --git a/x-pack/plugins/reporting/server/lib/store/store.ts b/x-pack/plugins/reporting/server/lib/store/store.ts index d49337391ca40..c42e3c2da7d20 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IndexResponse, UpdateResponse } from '@elastic/elasticsearch/api/types'; +import { IndexResponse, UpdateResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from 'src/core/server'; import { LevelLogger, statuses } from '../'; import { ReportingCore } from '../../'; diff --git a/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts b/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts index 84566eb9c250c..5f885ad127b43 100644 --- a/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts +++ b/x-pack/plugins/reporting/server/lib/tasks/execute_report.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { UpdateResponse } from '@elastic/elasticsearch/api/types'; +import { UpdateResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import moment from 'moment'; import * as Rx from 'rxjs'; import { timeout } from 'rxjs/operators'; diff --git a/x-pack/plugins/reporting/server/routes/deprecations.ts b/x-pack/plugins/reporting/server/routes/deprecations.ts index 4a519b7c199f8..521be51d6ccee 100644 --- a/x-pack/plugins/reporting/server/routes/deprecations.ts +++ b/x-pack/plugins/reporting/server/routes/deprecations.ts @@ -5,7 +5,7 @@ * 2.0. */ import { errors } from '@elastic/elasticsearch'; -import { SecurityHasPrivilegesIndexPrivilegesCheck } from '@elastic/elasticsearch/api/types'; +import { SecurityHasPrivilegesIndexPrivilegesCheck } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RequestHandler } from 'src/core/server'; import { API_MIGRATE_ILM_POLICY_URL, diff --git a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts index afa83ed331672..3c687aa17fa3e 100644 --- a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts @@ -6,7 +6,11 @@ */ import { ApiResponse } from '@elastic/elasticsearch'; -import { DeleteResponse, SearchHit, SearchResponse } from '@elastic/elasticsearch/api/types'; +import { + DeleteResponse, + SearchHit, + SearchResponse, +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ResponseError } from '@elastic/elasticsearch/lib/errors'; import { i18n } from '@kbn/i18n'; import { UnwrapPromise } from '@kbn/utility-types'; diff --git a/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts b/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts index 5f65cda456a16..4a66550f432cb 100644 --- a/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts +++ b/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts @@ -23,7 +23,10 @@ import { // @ts-expect-error } from '@kbn/rule-data-utils/target_node/alerts_as_data_rbac'; -import { InlineScript, QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { + InlineScript, + QueryDslQueryContainer, +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AlertTypeParams, AlertingAuthorizationFilterType } from '../../../alerting/server'; import { ReadOperations, diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts index 0595dbeea6dc6..e621d28c41a75 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts @@ -6,7 +6,7 @@ */ import { ApiResponse } from '@elastic/elasticsearch'; -import { BulkRequest, BulkResponse } from '@elastic/elasticsearch/api/types'; +import { BulkRequest, BulkResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESSearchRequest, ESSearchResponse } from 'src/core/types/elasticsearch'; import { FieldDescriptor } from 'src/plugins/data/server'; diff --git a/x-pack/plugins/rule_registry/server/utils/persistence_types.ts b/x-pack/plugins/rule_registry/server/utils/persistence_types.ts index 11607909a2e0f..37c4a0799e1b8 100644 --- a/x-pack/plugins/rule_registry/server/utils/persistence_types.ts +++ b/x-pack/plugins/rule_registry/server/utils/persistence_types.ts @@ -6,7 +6,7 @@ */ import { ApiResponse } from '@elastic/elasticsearch'; -import { BulkResponse } from '@elastic/elasticsearch/api/types'; +import { BulkResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger } from '@kbn/logging'; import { ESSearchRequest } from 'src/core/types/elasticsearch'; import { diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts index bf46214b20f31..e463128a399cf 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts @@ -6,7 +6,7 @@ */ import { Client } from '@elastic/elasticsearch'; -import { DeleteByQueryResponse } from '@elastic/elasticsearch/api/types'; +import { DeleteByQueryResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HostMetadata } from '../types'; import { EndpointActionGenerator, diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts index d7ab014c3b445..5ccdaf1597c73 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts @@ -10,7 +10,7 @@ import { cloneDeep, merge } from 'lodash'; import { AxiosResponse } from 'axios'; // eslint-disable-next-line import/no-extraneous-dependencies import { KbnClient } from '@kbn/test'; -import { DeleteByQueryResponse } from '@elastic/elasticsearch/api/types'; +import { DeleteByQueryResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Agent, CreatePackagePolicyResponse, GetPackagesResponse } from '../../../../fleet/common'; import { EndpointDocGenerator } from '../generate_data'; import { HostMetadata, HostPolicyResponse } from '../types'; diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts index 246cf059f4cbd..cca95f71c8091 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts @@ -6,7 +6,7 @@ */ import { Client } from '@elastic/elasticsearch'; -import { DeleteByQueryResponse } from '@elastic/elasticsearch/api/types'; +import { DeleteByQueryResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EndpointAction, EndpointActionResponse, HostMetadata } from '../types'; import { AGENT_ACTIONS_INDEX, AGENT_ACTIONS_RESULTS_INDEX } from '../../../../fleet/common'; import { FleetActionGenerator } from '../data_generators/fleet_action_generator'; diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts index b792b34dd510f..d6ef02d4f01e2 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts @@ -7,7 +7,7 @@ import { Client } from '@elastic/elasticsearch'; import { AxiosResponse } from 'axios'; -import { DeleteByQueryResponse } from '@elastic/elasticsearch/api/types'; +import { DeleteByQueryResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // eslint-disable-next-line import/no-extraneous-dependencies import { KbnClient } from '@kbn/test'; import { HostMetadata } from '../types'; diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts index d6599f2686670..277ccf030f808 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/migrate_artifacts_to_fleet.test.ts @@ -21,7 +21,7 @@ import { createEndpointArtifactClientMock } from '../../services/artifacts/mocks import { InternalArtifactCompleteSchema } from '../../schemas'; import { generateArtifactEsGetSingleHitMock } from '../../../../../fleet/server/services/artifacts/mocks'; import { NewArtifact } from '../../../../../fleet/server/services'; -import { CreateRequest } from '@elastic/elasticsearch/api/types'; +import { CreateRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; describe('When migrating artifacts to fleet', () => { let soClient: jest.Mocked; diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts index 0510743fdf05b..6894e237581e8 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts @@ -5,7 +5,7 @@ * 2.0. */ import { ApiResponse } from '@elastic/elasticsearch'; -import { TransformGetTransformStatsResponse } from '@elastic/elasticsearch/api/types'; +import { TransformGetTransformStatsResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CheckMetadataTransformsTask, TYPE, diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts index 68f149bcc64c4..41ce6845ab30b 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts @@ -8,7 +8,7 @@ import { ApiResponse } from '@elastic/elasticsearch'; import { TransformGetTransformStatsResponse, TransformGetTransformStatsTransformStats, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CoreSetup, ElasticsearchClient, Logger } from 'src/core/server'; import { ConcreteTaskInstance, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts index 5c06dbd3db14c..8189074833de1 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts @@ -7,7 +7,7 @@ import Boom from '@hapi/boom'; import { ApiResponse } from '@elastic/elasticsearch'; -import { SearchResponse, SearchTotalHits } from '@elastic/elasticsearch/api/types'; +import { SearchResponse, SearchTotalHits } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TypeOf } from '@kbn/config-schema'; import { diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/query_strategies.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/query_strategies.ts index ae9d0780de337..3770a6c36fb01 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/query_strategies.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/query_strategies.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchResponse } from '@elastic/elasticsearch/api/types'; +import { SearchResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HostMetadata } from '../../../../../common/endpoint/types'; import { HostListQueryResult, HostQueryResult } from '../../../types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/utils.ts index 713cf73890e7f..69f8a0afa6b3d 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchSort } from '@elastic/elasticsearch/api/types'; +import { SearchSort } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EVENT_ACTION, TIMESTAMP } from '@kbn/rule-data-utils'; import { RuleExecutionStatus } from '../../../../../../common/detection_engine/schemas/common/schemas'; import { ExecutionMetric } from '../../types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/types.ts index 6280a50d4981c..f6b3ec9baebdc 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_types/types.ts @@ -7,7 +7,7 @@ import { Moment } from 'moment'; -import { SearchHit } from '@elastic/elasticsearch/api/types'; +import { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger } from '@kbn/logging'; import { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts index 02cad1e8e508c..c7548bec6c0ff 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchHit } from '@elastic/elasticsearch/api/types'; +import { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { Logger } from 'src/core/server'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/build_signal_history.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/build_signal_history.ts index 81b12d2d4f229..e5c21edbc9350 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/build_signal_history.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threshold/build_signal_history.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchHit } from '@elastic/elasticsearch/api/types'; +import { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ALERT_ORIGINAL_TIME, ALERT_RULE_THRESHOLD_FIELD, diff --git a/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts b/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts index 038b7687784f4..77ad318efd6d9 100644 --- a/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts +++ b/x-pack/plugins/security_solution/server/lib/telemetry/receiver.ts @@ -11,7 +11,7 @@ import { ElasticsearchClient, SavedObjectsClientContract, } from 'src/core/server'; -import { SearchRequest } from '@elastic/elasticsearch/api/types'; +import { SearchRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getTrustedAppsList } from '../../endpoint/routes/trusted_apps/service'; import { AgentService, AgentPolicyServiceInterface } from '../../../../fleet/server'; import { ExceptionListClient } from '../../../../lists/server'; diff --git a/x-pack/test/api_integration/apis/ml/job_audit_messages/index.ts b/x-pack/test/api_integration/apis/ml/job_audit_messages/index.ts index a87855cef964e..d66728613a1cd 100644 --- a/x-pack/test/api_integration/apis/ml/job_audit_messages/index.ts +++ b/x-pack/test/api_integration/apis/ml/job_audit_messages/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { MlJob } from '@elastic/elasticsearch/api/types'; +import { MlJob } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { diff --git a/x-pack/test/apm_api_integration/tests/service_overview/dependencies/es_utils.ts b/x-pack/test/apm_api_integration/tests/service_overview/dependencies/es_utils.ts index b1663ea714056..e0913ba09e448 100644 --- a/x-pack/test/apm_api_integration/tests/service_overview/dependencies/es_utils.ts +++ b/x-pack/test/apm_api_integration/tests/service_overview/dependencies/es_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { MappingTypeMapping } from '@elastic/elasticsearch/api/types'; +import { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import uuid from 'uuid'; export function createServiceDependencyDocs({ From baa07a534bb9dbe9dd4393ad165753a44a514703 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 10:18:03 +0200 Subject: [PATCH 011/172] import errors from top export --- .../elasticsearch/client/errors.test.ts | 28 +++++++++---------- .../integration_tests/core_services.test.ts | 8 +++--- .../migrationsv2/actions/set_write_block.ts | 2 +- .../migrations_state_action_machine.test.ts | 4 +-- .../es_search/es_search_strategy.test.ts | 6 ++-- .../ese_search/ese_search_strategy.test.ts | 8 +++--- .../errors/handle_es_error.ts | 6 ++-- .../server/report_server_error.ts | 6 ++-- .../server/lib/errors/es_error_parser.ts | 1 - .../annotations/get_stored_annotations.ts | 4 +-- .../server/routes/register_routes/index.ts | 2 +- x-pack/plugins/fleet/server/errors/utils.ts | 6 ++-- .../services/api_keys/enrollment_api_key.ts | 4 +-- .../services/artifacts/artifacts.test.ts | 6 ++-- .../fleet/server/services/artifacts/mocks.ts | 4 +-- .../epm/elasticsearch/transform/install.ts | 4 +-- .../elasticsearch/transform/transform.test.ts | 4 +-- .../log_entries_search_strategy.test.ts | 6 ++-- .../log_entry_search_strategy.test.ts | 6 ++-- .../server/lib/errors/auth_errors.test.ts | 6 ++-- .../server/lib/errors/esclient_errors.ts | 2 +- .../server/lib/errors/handle_error.ts | 4 +-- x-pack/plugins/monitoring/server/types.ts | 4 +-- .../server/routes/register_routes.ts | 2 +- .../server/utils/unwrap_es_response.ts | 2 +- .../reporting/server/routes/lib/jobs_query.ts | 4 +-- .../rule_data_client/rule_data_client.ts | 6 ++-- .../endpoint/resolver_generator_script.ts | 4 +-- .../signals/search_after_bulk_create.test.ts | 4 +-- .../signals/signal_rule_alert_type.test.ts | 4 +-- .../server/routes/ml_snapshots.ts | 4 +-- .../services/endpoint.ts | 4 +-- 32 files changed, 82 insertions(+), 83 deletions(-) diff --git a/src/core/server/elasticsearch/client/errors.test.ts b/src/core/server/elasticsearch/client/errors.test.ts index a27a1fa794a97..52d74ddfdab24 100644 --- a/src/core/server/elasticsearch/client/errors.test.ts +++ b/src/core/server/elasticsearch/client/errors.test.ts @@ -6,11 +6,7 @@ * Side Public License, v 1. */ -import { - ResponseError, - ConnectionError, - ConfigurationError, -} from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { ApiResponse } from '@elastic/elasticsearch'; import { isResponseError, isUnauthorizedError } from './errors'; @@ -34,38 +30,42 @@ const createApiResponseError = ({ describe('isResponseError', () => { it('returns `true` when the input is a `ResponseError`', () => { - expect(isResponseError(new ResponseError(createApiResponseError()))).toBe(true); + expect(isResponseError(new errors.ResponseError(createApiResponseError()))).toBe(true); }); it('returns `false` when the input is not a `ResponseError`', () => { expect(isResponseError(new Error('foo'))).toBe(false); - expect(isResponseError(new ConnectionError('error', createApiResponseError()))).toBe(false); - expect(isResponseError(new ConfigurationError('foo'))).toBe(false); + expect(isResponseError(new errors.ConnectionError('error', createApiResponseError()))).toBe( + false + ); + expect(isResponseError(new errors.ConfigurationError('foo'))).toBe(false); }); }); describe('isUnauthorizedError', () => { it('returns true when the input is a `ResponseError` and statusCode === 401', () => { expect( - isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 401 }))) + isUnauthorizedError(new errors.ResponseError(createApiResponseError({ statusCode: 401 }))) ).toBe(true); }); it('returns false when the input is a `ResponseError` and statusCode !== 401', () => { expect( - isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 200 }))) + isUnauthorizedError(new errors.ResponseError(createApiResponseError({ statusCode: 200 }))) ).toBe(false); expect( - isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 403 }))) + isUnauthorizedError(new errors.ResponseError(createApiResponseError({ statusCode: 403 }))) ).toBe(false); expect( - isUnauthorizedError(new ResponseError(createApiResponseError({ statusCode: 500 }))) + isUnauthorizedError(new errors.ResponseError(createApiResponseError({ statusCode: 500 }))) ).toBe(false); }); it('returns `false` when the input is not a `ResponseError`', () => { expect(isUnauthorizedError(new Error('foo'))).toBe(false); - expect(isUnauthorizedError(new ConnectionError('error', createApiResponseError()))).toBe(false); - expect(isUnauthorizedError(new ConfigurationError('foo'))).toBe(false); + expect(isUnauthorizedError(new errors.ConnectionError('error', createApiResponseError()))).toBe( + false + ); + expect(isUnauthorizedError(new errors.ConfigurationError('foo'))).toBe(false); }); }); diff --git a/src/core/server/http/integration_tests/core_services.test.ts b/src/core/server/http/integration_tests/core_services.test.ts index 84eed0511cb23..4bf64a96cf773 100644 --- a/src/core/server/http/integration_tests/core_services.test.ts +++ b/src/core/server/http/integration_tests/core_services.test.ts @@ -8,7 +8,7 @@ import { MockElasticsearchClient } from './core_service.test.mocks'; import { elasticsearchClientMock } from '../../elasticsearch/client/mocks'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import * as kbnTestServer from '../../../test_helpers/kbn_server'; import { InternalElasticsearchServiceStart } from '../../elasticsearch'; @@ -205,7 +205,7 @@ describe('http service', () => { esClient.ping.mockImplementation(() => elasticsearchClientMock.createErrorTransportRequestPromise( - new ResponseError({ + new errors.ResponseError({ statusCode: 401, body: { error: { @@ -243,7 +243,7 @@ describe('http service', () => { esClient.ping.mockImplementation(() => elasticsearchClientMock.createErrorTransportRequestPromise( - new ResponseError({ + new errors.ResponseError({ statusCode: 401, body: { error: { @@ -279,7 +279,7 @@ describe('http service', () => { esClient.ping.mockImplementation(() => elasticsearchClientMock.createErrorTransportRequestPromise( - new ResponseError({ + new errors.ResponseError({ statusCode: 404, body: { error: { diff --git a/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts b/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts index db519d0246511..cb5621bb2bf1a 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { ElasticsearchClientError } from '@elastic/elasticsearch/lib/errors'; +import type { ElasticsearchClientError } from '@elastic/elasticsearch'; import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; import { errors as EsErrors } from '@elastic/elasticsearch'; diff --git a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts index 21468d7552320..075b56b0e7271 100644 --- a/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts +++ b/src/core/server/saved_objects/migrationsv2/migrations_state_action_machine.test.ts @@ -12,7 +12,7 @@ import { loggingSystemMock, elasticsearchServiceMock } from '../../mocks'; import { typeRegistryMock } from '../saved_objects_type_registry.mock'; import * as Either from 'fp-ts/lib/Either'; import * as Option from 'fp-ts/lib/Option'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { elasticsearchClientMock } from '../../elasticsearch/client/mocks'; import { LoggerAdapter } from '../../logging/logger_adapter'; import { AllControlStates, State } from './types'; @@ -194,7 +194,7 @@ describe('migrationsStateActionMachine', () => { logger: mockLogger.get(), model: transitionModel(['LEGACY_REINDEX', 'LEGACY_DELETE', 'FATAL']), next: () => { - throw new ResponseError( + throw new errors.ResponseError( elasticsearchClientMock.createApiResponse({ meta: { request: { options: {}, id: '', params: { method: 'POST', path: '/mock' } }, diff --git a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts index bbbc99d157fe0..973662809bb52 100644 --- a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts +++ b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts @@ -16,7 +16,7 @@ import { esSearchStrategyProvider } from './es_search_strategy'; import { SearchStrategyDependencies } from '../../types'; import * as indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json'; -import { ElasticsearchClientError, ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { KbnServerError } from '../../../../../kibana_utils/server'; describe('ES search strategy', () => { @@ -132,7 +132,7 @@ describe('ES search strategy', () => { it('throws normalized error if ResponseError is thrown', async (done) => { const params = { index: 'logstash-*', ignore_unavailable: false, timeout: '1000ms' }; - const errResponse = new ResponseError({ + const errResponse = new errors.ResponseError({ body: indexNotFoundException, statusCode: 404, headers: {}, @@ -156,7 +156,7 @@ describe('ES search strategy', () => { it('throws normalized error if ElasticsearchClientError is thrown', async (done) => { const params = { index: 'logstash-*', ignore_unavailable: false, timeout: '1000ms' }; - const errResponse = new ElasticsearchClientError('This is a general ESClient error'); + const errResponse = new errors.ElasticsearchClientError('This is a general ESClient error'); try { await esSearchStrategyProvider(mockConfig$, mockLogger) diff --git a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.test.ts b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.test.ts index 8d5fbf98db2d3..d4fe74486ee85 100644 --- a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.test.ts +++ b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.test.ts @@ -8,7 +8,7 @@ import { BehaviorSubject } from 'rxjs'; import { KbnServerError } from '../../../../../kibana_utils/server'; -import { ElasticsearchClientError, ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import * as indexNotFoundException from '../../../../common/search/test_data/index_not_found_exception.json'; import * as xContentParseException from '../../../../common/search/test_data/x_content_parse_exception.json'; import { SearchStrategyDependencies } from '../../types'; @@ -191,7 +191,7 @@ describe('ES search strategy', () => { }); it('throws normalized error if ResponseError is thrown', async () => { - const errResponse = new ResponseError({ + const errResponse = new errors.ResponseError({ body: indexNotFoundException, statusCode: 404, headers: {}, @@ -254,7 +254,7 @@ describe('ES search strategy', () => { }); it('throws normalized error on ResponseError', async () => { - const errResponse = new ResponseError({ + const errResponse = new errors.ResponseError({ body: xContentParseException, statusCode: 400, headers: {}, @@ -297,7 +297,7 @@ describe('ES search strategy', () => { }); it('throws normalized error on ElasticsearchClientError', async () => { - const errResponse = new ElasticsearchClientError('something is wrong with EsClient'); + const errResponse = new errors.ElasticsearchClientError('something is wrong with EsClient'); mockGetCaller.mockRejectedValue(errResponse); const id = 'some_other_id'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts index 678c46f69d51f..cce8cf52e7979 100644 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts @@ -7,7 +7,7 @@ */ import { ApiError } from '@elastic/elasticsearch'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { IKibanaResponse, KibanaResponseFactory } from 'kibana/server'; import { getEsCause } from './es_error_parser'; @@ -34,9 +34,9 @@ export const handleEsError = ({ return handleCustomError(); } - const { statusCode, body } = error as ResponseError; + const { statusCode, body } = error as errors.ResponseError; return response.customError({ - statusCode, + statusCode: statusCode!, body: { message: // We use || instead of ?? as the switch here because reason could be an empty string diff --git a/src/plugins/kibana_utils/server/report_server_error.ts b/src/plugins/kibana_utils/server/report_server_error.ts index 9f0bf34eaebb6..57b8c4e207f72 100644 --- a/src/plugins/kibana_utils/server/report_server_error.ts +++ b/src/plugins/kibana_utils/server/report_server_error.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { KibanaResponseFactory } from 'kibana/server'; import { KbnError } from '../common'; @@ -27,8 +27,8 @@ export function getKbnServerError(e: Error) { if (e instanceof KbnServerError) return e; return new KbnServerError( e.message ?? 'Unknown error', - e instanceof ResponseError ? e.statusCode : 500, - e instanceof ResponseError ? e.body : undefined + e instanceof errors.ResponseError ? e.statusCode! : 500, + e instanceof errors.ResponseError ? e.body : undefined ); } diff --git a/x-pack/plugins/alerting/server/lib/errors/es_error_parser.ts b/x-pack/plugins/alerting/server/lib/errors/es_error_parser.ts index 3573da3a52eea..f26fa22f8d730 100644 --- a/x-pack/plugins/alerting/server/lib/errors/es_error_parser.ts +++ b/x-pack/plugins/alerting/server/lib/errors/es_error_parser.ts @@ -5,7 +5,6 @@ * 2.0. */ -// import { ResponseError } from '@elastic/elasticsearch/lib/errors'; import { ElasticsearchError, ElasticsearchErrorCausedByObject } from './types'; const getEsCause = ( diff --git a/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts b/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts index d44468bb0bb60..ac1c2653bf148 100644 --- a/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts +++ b/x-pack/plugins/apm/server/lib/services/annotations/get_stored_annotations.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { ElasticsearchClient, Logger } from 'kibana/server'; import { rangeQuery } from '../../../../../observability/server'; import { environmentQuery } from '../../../../common/utils/environment_query'; @@ -75,7 +75,7 @@ export function getStoredAnnotations({ // so we should handle this error gracefully if ( error instanceof WrappedElasticsearchClientError && - error.originalError instanceof ResponseError + error.originalError instanceof errors.ResponseError ) { const type = error.originalError.body.error.type; diff --git a/x-pack/plugins/apm/server/routes/register_routes/index.ts b/x-pack/plugins/apm/server/routes/register_routes/index.ts index fb1d67ad30c2b..38db62e7cf240 100644 --- a/x-pack/plugins/apm/server/routes/register_routes/index.ts +++ b/x-pack/plugins/apm/server/routes/register_routes/index.ts @@ -8,7 +8,7 @@ import Boom from '@hapi/boom'; import * as t from 'io-ts'; import { KibanaRequest, RouteRegistrar } from 'src/core/server'; -import { RequestAbortedError } from '@elastic/elasticsearch/lib/errors'; +import { RequestAbortedError } from '@elastic/elasticsearch'; import agent from 'elastic-apm-node'; import { ServerRouteRepository } from '@kbn/server-route-repository'; import { merge } from 'lodash'; diff --git a/x-pack/plugins/fleet/server/errors/utils.ts b/x-pack/plugins/fleet/server/errors/utils.ts index d58f82b94fcd7..23e92cdcd9f51 100644 --- a/x-pack/plugins/fleet/server/errors/utils.ts +++ b/x-pack/plugins/fleet/server/errors/utils.ts @@ -5,10 +5,10 @@ * 2.0. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; -export function isESClientError(error: unknown): error is ResponseError { - return error instanceof ResponseError; +export function isESClientError(error: unknown): error is errors.ResponseError { + return error instanceof errors.ResponseError; } export function isElasticsearchVersionConflictError(error: Error): boolean { diff --git a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts index cc2357351f6df..58ca19c06a742 100644 --- a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts +++ b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts @@ -8,7 +8,7 @@ import uuid from 'uuid'; import Boom from '@hapi/boom'; import { i18n } from '@kbn/i18n'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import type { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; import { toElasticsearchQuery, fromKueryExpression } from '@kbn/es-query'; @@ -84,7 +84,7 @@ export async function getEnrollmentAPIKey( // @ts-expect-error esDocToEnrollmentApiKey doesn't accept optional _source return esDocToEnrollmentApiKey(res.body); } catch (e) { - if (e instanceof ResponseError && e.statusCode === 404) { + if (e instanceof errors.ResponseError && e.statusCode === 404) { throw Boom.notFound(`Enrollment api key ${id} not found`); } diff --git a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts index c09ba881a81c0..c7f224dcf0b22 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts @@ -7,7 +7,7 @@ import { elasticsearchServiceMock } from 'src/core/server/mocks'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import type { ApiResponse } from '@elastic/transport'; @@ -64,7 +64,7 @@ describe('When using the artifacts services', () => { it('should throw an ArtifactElasticsearchError if one is encountered', async () => { esClientMock.get.mockImplementation(() => { return elasticsearchServiceMock.createErrorTransportRequestPromise( - new ResponseError(generateEsRequestErrorApiResponseMock()) + new errors.ResponseError(generateEsRequestErrorApiResponseMock()) ); }); @@ -103,7 +103,7 @@ describe('When using the artifacts services', () => { }); it('should ignore 409 errors from elasticsearch', async () => { - const error = new ResponseError({ statusCode: 409 } as ApiResponse); + const error = new errors.ResponseError({ statusCode: 409 } as ApiResponse); // Unclear why `mockRejectedValue()` has the params value type set to `never` // @ts-expect-error esClientMock.create.mockRejectedValue(error); diff --git a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts index 2799e1807123d..754df46a30b11 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts @@ -7,7 +7,7 @@ import { URL } from 'url'; import type { ApiResponse } from '@elastic/elasticsearch'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { elasticsearchServiceMock } from '../../../../../../src/core/server/mocks'; import type { SearchHit, ESSearchResponse } from '../../../../../../src/core/types/elasticsearch'; @@ -182,7 +182,7 @@ export const setEsClientMethodResponseToError = ( ) => { esClientMock[method].mockImplementation(() => { return elasticsearchServiceMock.createErrorTransportRequestPromise( - new ResponseError(generateEsRequestErrorApiResponseMock(options)) + new errors.ResponseError(generateEsRequestErrorApiResponseMock(options)) ); }); }; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts index 7d62c0ef41c8d..93181d4f26d02 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/install.ts @@ -6,7 +6,7 @@ */ import type { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { saveInstalledEsRefs } from '../../packages/install'; import { getPathParts } from '../../archive'; @@ -129,7 +129,7 @@ async function handleTransformInstall({ } catch (err) { // swallow the error if the transform already exists. const isAlreadyExistError = - err instanceof ResponseError && + err instanceof errors.ResponseError && err?.body?.error?.type === 'resource_already_exists_exception'; if (!isAlreadyExistError) { throw err; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts index 34dcd5427d655..5f6f64576ad64 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts @@ -18,7 +18,7 @@ jest.mock('./common', () => { }; }); -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import type { ElasticsearchClient, SavedObject, SavedObjectsClientContract } from 'kibana/server'; @@ -518,7 +518,7 @@ describe('test transform install', () => { esClient.transport.request.mockImplementationOnce(() => elasticsearchClientMock.createErrorTransportRequestPromise( - new ResponseError( + new errors.ResponseError( elasticsearchClientMock.createApiResponse({ statusCode: 400, body: { error: { type: 'resource_already_exists_exception' } }, diff --git a/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts b/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts index 876aad4ef8d02..e39e5ad57ea53 100644 --- a/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts +++ b/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { of, throwError } from 'rxjs'; import { elasticsearchServiceMock, @@ -230,7 +230,7 @@ describe('LogEntries search strategy', () => { mockDependencies ); - await expect(response.toPromise()).rejects.toThrowError(ResponseError); + await expect(response.toPromise()).rejects.toThrowError(errors.ResponseError); }); it('forwards cancellation to the underlying search strategy', async () => { @@ -307,7 +307,7 @@ const createEsSearchStrategyMock = (esSearchResponse: IEsSearchResponse) => ({ return of(esSearchResponse); } else { return throwError( - new ResponseError({ + new errors.ResponseError({ body: {}, headers: {}, meta: {} as any, diff --git a/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts b/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts index 88c9d956dbe0a..b42d2667bda3c 100644 --- a/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts +++ b/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { of, throwError } from 'rxjs'; import { elasticsearchServiceMock, @@ -196,7 +196,7 @@ describe('LogEntry search strategy', () => { mockDependencies ); - await expect(response.toPromise()).rejects.toThrowError(ResponseError); + await expect(response.toPromise()).rejects.toThrowError(errors.ResponseError); }); it('forwards cancellation to the underlying search strategy', async () => { @@ -262,7 +262,7 @@ const createEsSearchStrategyMock = (esSearchResponse: IEsSearchResponse) => ({ return of(esSearchResponse); } else { return throwError( - new ResponseError({ + new errors.ResponseError({ body: {}, headers: {}, meta: {} as any, diff --git a/x-pack/plugins/monitoring/server/lib/errors/auth_errors.test.ts b/x-pack/plugins/monitoring/server/lib/errors/auth_errors.test.ts index e9f3eb8efc4d7..06883a47f2ca3 100644 --- a/x-pack/plugins/monitoring/server/lib/errors/auth_errors.test.ts +++ b/x-pack/plugins/monitoring/server/lib/errors/auth_errors.test.ts @@ -6,7 +6,7 @@ */ import { forbidden, unauthorized } from '@hapi/boom'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { isAuthError, handleAuthError } from './auth_errors'; describe('Error handling for 401/403 errors', () => { @@ -59,7 +59,7 @@ describe('Error handling for 401/403 errors', () => { describe('Elasticsearch errors', () => { it('handles Forbidden error defined by ElasticsearchJS', () => { - const err = new ResponseError({ + const err = new errors.ResponseError({ statusCode: 401, body: { error: { @@ -91,7 +91,7 @@ describe('Error handling for 401/403 errors', () => { }); it('handles Unauthorized error defined by ElasticsearchJS', () => { - const err = new ResponseError({ + const err = new errors.ResponseError({ statusCode: 403, body: { error: { diff --git a/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts b/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts index 5994c3048dae8..6df1dbf725cdf 100644 --- a/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts +++ b/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ElasticsearchClientError } from '@elastic/elasticsearch/lib/errors'; +import { ElasticsearchClientError } from '@elastic/elasticsearch'; import { boomify } from '@hapi/boom'; import { i18n } from '@kbn/i18n'; import { ErrorTypes } from '../../types'; diff --git a/x-pack/plugins/monitoring/server/lib/errors/handle_error.ts b/x-pack/plugins/monitoring/server/lib/errors/handle_error.ts index 3fe3b28034b2c..cc5fde228120e 100644 --- a/x-pack/plugins/monitoring/server/lib/errors/handle_error.ts +++ b/x-pack/plugins/monitoring/server/lib/errors/handle_error.ts @@ -6,7 +6,7 @@ */ import { boomify, isBoom } from '@hapi/boom'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { isCustomError, handleCustomError } from './custom_errors'; import { isAuthError, handleAuthError } from './auth_errors'; import { ErrorTypes, LegacyRequest } from '../../types'; @@ -15,7 +15,7 @@ import { handleESClientError, isESClientError } from './esclient_errors'; export const getStatusCode = (err: ErrorTypes) => { return isBoom(err) ? err.output.statusCode - : err instanceof ResponseError + : err instanceof errors.ResponseError ? err.statusCode : undefined; }; diff --git a/x-pack/plugins/monitoring/server/types.ts b/x-pack/plugins/monitoring/server/types.ts index 416d1ac7c3d86..14071aafaea12 100644 --- a/x-pack/plugins/monitoring/server/types.ts +++ b/x-pack/plugins/monitoring/server/types.ts @@ -14,7 +14,7 @@ import type { ElasticsearchClient, } from 'kibana/server'; import type Boom from '@hapi/boom'; -import { ElasticsearchClientError, ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { LicenseFeature, ILicense } from '../../licensing/server'; import type { @@ -180,7 +180,7 @@ export interface ClusterSettingsReasonResponse { }; } -export type ErrorTypes = Error | Boom.Boom | ResponseError | ElasticsearchClientError; +export type ErrorTypes = Error | Boom.Boom | errors.ResponseError | errors.ElasticsearchClientError; export type Pipeline = { id: string; diff --git a/x-pack/plugins/observability/server/routes/register_routes.ts b/x-pack/plugins/observability/server/routes/register_routes.ts index 660c38edb8e9d..abf009302baee 100644 --- a/x-pack/plugins/observability/server/routes/register_routes.ts +++ b/x-pack/plugins/observability/server/routes/register_routes.ts @@ -12,7 +12,7 @@ import { } from '@kbn/server-route-repository'; import { CoreSetup, CoreStart, Logger, RouteRegistrar } from 'kibana/server'; import Boom from '@hapi/boom'; -import { RequestAbortedError } from '@elastic/elasticsearch/lib/errors'; +import { RequestAbortedError } from '@elastic/elasticsearch'; import { RuleDataPluginService } from '../../../rule_registry/server'; import { ObservabilityRequestHandlerContext } from '../types'; import { AbstractObservabilityServerRouteRepository } from './types'; diff --git a/x-pack/plugins/observability/server/utils/unwrap_es_response.ts b/x-pack/plugins/observability/server/utils/unwrap_es_response.ts index 81f8be4e0f696..d2051f4d24d8a 100644 --- a/x-pack/plugins/observability/server/utils/unwrap_es_response.ts +++ b/x-pack/plugins/observability/server/utils/unwrap_es_response.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { ElasticsearchClientError, ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { ElasticsearchClientError, ResponseError } from '@elastic/elasticsearch'; import type { UnwrapPromise } from '@kbn/utility-types'; import { inspect } from 'util'; diff --git a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts index 3c687aa17fa3e..c7806ab43db91 100644 --- a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts @@ -11,7 +11,7 @@ import { SearchHit, SearchResponse, } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { i18n } from '@kbn/i18n'; import { UnwrapPromise } from '@kbn/utility-types'; import { ElasticsearchClient } from 'src/core/server'; @@ -71,7 +71,7 @@ export function jobsQueryFactory(reportingCore: ReportingCore): JobsQueryFactory return await callback(client); } catch (error) { - if (error instanceof ResponseError && [401, 403, 404].includes(error.statusCode)) { + if (error instanceof errors.ResponseError && [401, 403, 404].includes(error.statusCode)) { return; } diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts index 89ae479132de5..4cf93460b39fc 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { Either, isLeft } from 'fp-ts/lib/Either'; import { ElasticsearchClient } from 'kibana/server'; @@ -140,13 +140,13 @@ export class RuleDataClient implements IRuleDataClient { .then(() => { return clusterClient.bulk(requestWithDefaultParameters).then((retryResponse) => { if (retryResponse.body.errors) { - throw new ResponseError(retryResponse); + throw new errors.ResponseError(retryResponse); } return retryResponse; }); }); } - const error = new ResponseError(response); + const error = new errors.ResponseError(response); throw error; } return response; diff --git a/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts b/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts index 3c267117964ce..cca2c27a9ff72 100644 --- a/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts +++ b/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts @@ -9,7 +9,7 @@ import yargs from 'yargs'; import fs from 'fs'; import { Client, ClientOptions } from '@elastic/elasticsearch'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { ToolingLog, CA_CERT_PATH } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { indexHostsAndAlerts } from '../../common/endpoint/index_data'; @@ -19,7 +19,7 @@ main(); async function deleteIndices(indices: string[], client: Client) { const handleErr = (err: unknown) => { - if (err instanceof ResponseError && err.statusCode !== 404) { + if (err instanceof errors.ResponseError && err.statusCode !== 404) { console.log(JSON.stringify(err, null, 2)); // eslint-disable-next-line no-process-exit process.exit(1); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts index 1f46654e855b2..a405833f985f4 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts @@ -31,7 +31,7 @@ import { getQueryRuleParams } from '../schemas/rule_schemas.mock'; import { bulkCreateFactory } from './bulk_create_factory'; import { wrapHitsFactory } from './wrap_hits_factory'; import { mockBuildRuleMessage } from './__mocks__/build_rule_message.mock'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { BuildReasonMessage } from './reason_formatters'; const buildRuleMessage = mockBuildRuleMessage; @@ -754,7 +754,7 @@ describe('searchAfterAndBulkCreate', () => { ); mockService.scopedClusterClient.asCurrentUser.bulk.mockReturnValue( elasticsearchClientMock.createErrorTransportRequestPromise( - new ResponseError( + new errors.ResponseError( elasticsearchClientMock.createApiResponse({ statusCode: 400, body: { error: { type: 'bulk_error_type' } }, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts index caba810b116e8..8c3f97f36aab5 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts @@ -30,7 +30,7 @@ import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mo import { queryExecutor } from './executors/query'; import { mlExecutor } from './executors/ml'; import { getMlRuleParams, getQueryRuleParams } from '../schemas/rule_schemas.mock'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { allowedExperimentalValues } from '../../../../common/experimental_features'; import { ruleRegistryMocks } from '../../../../../rule_registry/server/mocks'; import { scheduleNotificationActions } from '../notifications/schedule_notification_actions'; @@ -496,7 +496,7 @@ describe('signal_rule_alert_type', () => { it('and log failure with the default message', async () => { (queryExecutor as jest.Mock).mockReturnValue( elasticsearchClientMock.createErrorTransportRequestPromise( - new ResponseError( + new errors.ResponseError( elasticsearchClientMock.createApiResponse({ statusCode: 400, body: { error: { type: 'some_error_type' } }, diff --git a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts index f23de49d97dc8..49d64ce97ae06 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { schema } from '@kbn/config-schema'; import { IScopedClusterClient, SavedObjectsClientContract } from 'kibana/server'; import { API_BASE_PATH } from '../../common/constants'; @@ -56,7 +56,7 @@ const verifySnapshotUpgrade = async ( snapshot: { snapshotId: string; jobId: string } ): Promise<{ isSuccessful: boolean; - error?: ResponseError; + error?: errors.ResponseError; }> => { const { snapshotId, jobId } = snapshot; diff --git a/x-pack/test/security_solution_endpoint/services/endpoint.ts b/x-pack/test/security_solution_endpoint/services/endpoint.ts index 2e774dcd84782..2c78bb81a1d38 100644 --- a/x-pack/test/security_solution_endpoint/services/endpoint.ts +++ b/x-pack/test/security_solution_endpoint/services/endpoint.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { Client } from '@elastic/elasticsearch'; import { FtrService } from '../../functional/ftr_provider_context'; import { @@ -180,7 +180,7 @@ export class EndpointTestResources extends FtrService { return searchResponse.body.hits.total === size; } catch (error) { // We ignore 404's (index might not exist) - if (error instanceof ResponseError && error.statusCode === 404) { + if (error instanceof errors.ResponseError && error.statusCode === 404) { return false; } From 14d6fb554cf99cc2d51b5520a1bc955ffe2c7a5e Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 10:41:51 +0200 Subject: [PATCH 012/172] use TransportResult instead if ApiResponse --- .../elasticsearch/client/errors.test.ts | 4 +-- src/core/server/elasticsearch/client/mocks.ts | 30 +++++++------------ .../search/strategies/eql_search/types.ts | 6 ++-- .../server/autocomplete/terms_agg.test.ts | 4 +-- .../server/autocomplete/terms_enum.test.ts | 4 +-- .../eql_search/eql_search_strategy.ts | 4 +-- .../strategies/eql_search/response_utils.ts | 4 +-- .../server/elasticsearch_service.ts | 4 +-- src/plugins/interactive_setup/server/mocks.ts | 8 ++--- .../cleanup_tasks.test.ts | 7 +++-- .../lib/bulk_delete.ts | 5 ++-- .../extract_bulk_response_delete_failures.ts | 5 ++-- x-pack/plugins/canvas/types/strategy.ts | 4 +-- .../search/session/get_search_status.ts | 4 +-- .../services/artifacts/artifacts.test.ts | 4 +-- .../fleet/server/services/artifacts/mocks.ts | 8 ++--- .../api/policies/register_fetch_route.ts | 4 +-- .../server/utils/get_all_composite_data.ts | 4 +-- .../plugins/ml/server/lib/ml_client/search.ts | 5 ++-- .../reporting/server/routes/lib/jobs_query.ts | 6 ++-- .../server/rule_data_client/types.ts | 4 +-- .../server/utils/persistence_types.ts | 4 +-- x-pack/plugins/security/server/mocks.ts | 8 ++--- .../eql/validation/helpers.mock.ts | 6 ++-- .../check_metadata_transforms_task.test.ts | 6 ++-- .../check_metadata_transforms_task.ts | 4 +-- .../server/endpoint/routes/actions/mocks.ts | 4 +-- .../endpoint/routes/metadata/handlers.ts | 4 +-- .../resolver/tree/queries/descendants.ts | 5 ++-- .../detection_engine/signals/executors/eql.ts | 4 +-- .../signals/signal_rule_alert_type.test.ts | 6 ++-- .../detection_engine/signals/utils.test.ts | 26 ++++++++++------ .../lib/detection_engine/signals/utils.ts | 4 +-- .../geo_containment/es_query_builder.ts | 5 ++-- .../eql/validation/helpers.mock.ts | 6 ++-- .../tests/alerting/alerts.ts | 5 ++-- .../tests/alerting/create.ts | 5 ++-- .../tests/alerting/enable.ts | 5 ++-- .../preconfigured_alert_history_connector.ts | 7 +++-- .../spaces_only/tests/alerting/alerts_base.ts | 5 ++-- .../spaces_only/tests/alerting/create.ts | 5 ++-- .../spaces_only/tests/alerting/enable.ts | 5 ++-- .../spaces_only/tests/alerting/migrations.ts | 7 +++-- .../apis/security_solution/utils.ts | 5 ++-- .../case_api_integration/common/lib/utils.ts | 11 +++---- .../tests/common/cases/find_cases.ts | 5 ++-- .../tests/common/sub_cases/find_sub_cases.ts | 23 +++++++------- .../detection_engine_api_integration/utils.ts | 4 +-- .../test_suites/task_manager/migrations.ts | 5 ++-- 49 files changed, 169 insertions(+), 148 deletions(-) diff --git a/src/core/server/elasticsearch/client/errors.test.ts b/src/core/server/elasticsearch/client/errors.test.ts index 52d74ddfdab24..36d026af6081e 100644 --- a/src/core/server/elasticsearch/client/errors.test.ts +++ b/src/core/server/elasticsearch/client/errors.test.ts @@ -7,7 +7,7 @@ */ import { errors } from '@elastic/elasticsearch'; -import { ApiResponse } from '@elastic/elasticsearch'; +import { TransportResult } from '@elastic/transport'; import { isResponseError, isUnauthorizedError } from './errors'; const createApiResponseError = ({ @@ -18,7 +18,7 @@ const createApiResponseError = ({ statusCode?: number; headers?: Record; body?: Record; -} = {}): ApiResponse => { +} = {}): TransportResult => { return { body, statusCode, diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index 2626dee6aeac2..a37cccce17f57 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ -import type { Client, ApiResponse } from '@elastic/elasticsearch'; -import { TransportRequestPromise } from '@elastic/transport'; +import type { Client } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import { ElasticsearchClient } from './types'; import { ICustomClusterClient } from './cluster_client'; @@ -16,9 +16,7 @@ import { PRODUCT_RESPONSE_HEADER } from '../supported_server_response_check'; // use jest.requireActual() to prevent weird errors when people mock @elastic/elasticsearch const { Client: UnmockedClient } = jest.requireActual('@elastic/elasticsearch'); -const createInternalClientMock = ( - res?: MockedTransportRequestPromise -): DeeplyMockedKeys => { +const createInternalClientMock = (res?: Promise): DeeplyMockedKeys => { // we mimic 'reflection' on a concrete instance of the client to generate the mocked functions. const client = new UnmockedClient({ node: 'http://localhost', @@ -91,7 +89,7 @@ const createInternalClientMock = ( export type ElasticsearchClientMock = DeeplyMockedKeys; -const createClientMock = (res?: MockedTransportRequestPromise): ElasticsearchClientMock => +const createClientMock = (res?: Promise): ElasticsearchClientMock => createInternalClientMock(res) as unknown as ElasticsearchClientMock; export interface ScopedClusterClientMock { @@ -139,31 +137,25 @@ const createCustomClusterClientMock = () => { return mock; }; -export type MockedTransportRequestPromise = TransportRequestPromise & { - abort: jest.MockedFunction<() => undefined>; -}; - const createSuccessTransportRequestPromise = ( body: T, { statusCode = 200 }: { statusCode?: number } = {}, headers: Record = { [PRODUCT_RESPONSE_HEADER]: 'Elasticsearch' } -): MockedTransportRequestPromise> => { +): Promise> => { const response = createApiResponse({ body, statusCode, headers }); - const promise = Promise.resolve(response); - (promise as MockedTransportRequestPromise>).abort = jest.fn(); + const promise = Promise.resolve(response) as Promise>; - return promise as MockedTransportRequestPromise>; + return promise; }; -const createErrorTransportRequestPromise = (err: any): MockedTransportRequestPromise => { +const createErrorTransportRequestPromise = (err: any): Promise => { const promise = Promise.reject(err); - (promise as MockedTransportRequestPromise).abort = jest.fn(); - return promise as MockedTransportRequestPromise; + return promise; }; function createApiResponse>( - opts: Partial> = {} -): ApiResponse { + opts: Partial> = {} +): TransportResult { return { body: {} as any, statusCode: 200, diff --git a/src/plugins/data/common/search/strategies/eql_search/types.ts b/src/plugins/data/common/search/strategies/eql_search/types.ts index a4013773e9538..cd4da96526f6f 100644 --- a/src/plugins/data/common/search/strategies/eql_search/types.ts +++ b/src/plugins/data/common/search/strategies/eql_search/types.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ -import { EqlSearch } from '@elastic/elasticsearch/api/requestParams'; -import { ApiResponse, TransportRequestOptions } from '@elastic/transport'; +import { EqlSearch } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { TransportResult, TransportRequestOptions } from '@elastic/transport'; import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../types'; @@ -19,4 +19,4 @@ export interface EqlSearchStrategyRequest extends IKibanaSearchRequest = IKibanaSearchResponse>; +export type EqlSearchStrategyResponse = IKibanaSearchResponse>; diff --git a/src/plugins/data/server/autocomplete/terms_agg.test.ts b/src/plugins/data/server/autocomplete/terms_agg.test.ts index dcaa5390f3fe6..9176f345d4a05 100644 --- a/src/plugins/data/server/autocomplete/terms_agg.test.ts +++ b/src/plugins/data/server/autocomplete/terms_agg.test.ts @@ -10,7 +10,7 @@ import { coreMock } from '../../../../core/server/mocks'; import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; import { ConfigSchema } from '../../config'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; -import type { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { termsAggSuggestions } from './terms_agg'; import type { estypes } from '@elastic/elasticsearch'; import { duration } from 'moment'; @@ -32,7 +32,7 @@ const mockResponse = { }, }, }, -} as ApiResponse>; +} as TransportResult>; jest.mock('../data_views'); diff --git a/src/plugins/data/server/autocomplete/terms_enum.test.ts b/src/plugins/data/server/autocomplete/terms_enum.test.ts index 2340b6bcec7ca..f9cad79919e02 100644 --- a/src/plugins/data/server/autocomplete/terms_enum.test.ts +++ b/src/plugins/data/server/autocomplete/terms_enum.test.ts @@ -11,7 +11,7 @@ import { coreMock } from '../../../../core/server/mocks'; import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; import { ConfigSchema } from '../../config'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; -import type { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { TermsEnumResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; let savedObjectsClientMock: jest.Mocked; @@ -31,7 +31,7 @@ describe('_terms_enum suggestions', () => { savedObjectsClientMock = requestHandlerContext.savedObjects.client; esClientMock = requestHandlerContext.elasticsearch.client.asCurrentUser; esClientMock.termsEnum.mockResolvedValue( - mockResponse as unknown as ApiResponse + mockResponse as unknown as TransportResult ); }); diff --git a/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts b/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts index 4c75d62f12190..88a555dd7ab3e 100644 --- a/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { tap } from 'rxjs/operators'; import type { IScopedClusterClient, Logger } from 'kibana/server'; import { @@ -57,7 +57,7 @@ export const eqlSearchStrategyProvider = ( : // @ts-expect-error EqlRequestParams | undefined is not assignable to EqlRequestParams client.search(params as EqlSearchStrategyRequest['params'], request.options); const response = await shimAbortSignal(promise, options.abortSignal); - return toEqlKibanaSearchResponse(response as ApiResponse); + return toEqlKibanaSearchResponse(response as TransportResult); }; const cancel = async () => { diff --git a/src/plugins/data/server/search/strategies/eql_search/response_utils.ts b/src/plugins/data/server/search/strategies/eql_search/response_utils.ts index 11b5a286e709d..342e8453c10db 100644 --- a/src/plugins/data/server/search/strategies/eql_search/response_utils.ts +++ b/src/plugins/data/server/search/strategies/eql_search/response_utils.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { EqlSearchResponse } from './types'; import { EqlSearchStrategyResponse } from '../../../../common'; @@ -15,7 +15,7 @@ import { EqlSearchStrategyResponse } from '../../../../common'; * (EQL does not provide _shard info, so total/loaded cannot be calculated.) */ export function toEqlKibanaSearchResponse( - response: ApiResponse + response: TransportResult ): EqlSearchStrategyResponse { return { id: response.body.id, diff --git a/src/plugins/interactive_setup/server/elasticsearch_service.ts b/src/plugins/interactive_setup/server/elasticsearch_service.ts index 99cf0950eec72..c76fe315f73d2 100644 --- a/src/plugins/interactive_setup/server/elasticsearch_service.ts +++ b/src/plugins/interactive_setup/server/elasticsearch_service.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ -import type { ApiResponse } from '@elastic/elasticsearch'; import { errors } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import type { Duration } from 'moment'; import type { Observable } from 'rxjs'; import { from, of, timer } from 'rxjs'; @@ -193,7 +193,7 @@ export class ElasticsearchService { .asCurrentUser.transport.request({ method: 'GET', path: '/_security/enroll/kibana', - })) as ApiResponse<{ token: { name: string; value: string }; http_ca: string }>; + })) as TransportResult<{ token: { name: string; value: string }; http_ca: string }>; } catch (err) { // We expect that all hosts belong to exactly same node and any non-connection error for one host would mean // that enrollment will fail for any other host and we should bail out. diff --git a/src/plugins/interactive_setup/server/mocks.ts b/src/plugins/interactive_setup/server/mocks.ts index 75b28a502b6d4..bfe65edc21c3b 100644 --- a/src/plugins/interactive_setup/server/mocks.ts +++ b/src/plugins/interactive_setup/server/mocks.ts @@ -6,12 +6,12 @@ * Side Public License, v 1. */ -import type { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; function createApiResponseMock( - apiResponse: Pick, 'body'> & - Partial, 'body'>> -): ApiResponse { + apiResponse: Pick, 'body'> & + Partial, 'body'>> +): TransportResult { return { statusCode: null, headers: null, diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts index 451e12b9cf29a..b5e3297dda8f6 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts @@ -10,7 +10,8 @@ import { loggingSystemMock, elasticsearchServiceMock } from '../../../../../src/ import { spacesMock } from '../../../spaces/server/mocks'; import { CleanupTasksOpts, cleanupTasks } from './cleanup_tasks'; import { TaskInstance } from '../../../task_manager/server'; -import { ApiResponse, estypes } from '@elastic/elasticsearch'; +import { estypes } from '@elastic/elasticsearch'; +import { TransportResult } from '@elastic/transport'; describe('cleanupTasks', () => { const logger = loggingSystemMock.create().get(); @@ -71,7 +72,7 @@ describe('cleanupTasks', () => { it('should delete action_task_params and task objects', async () => { esClient.bulk.mockResolvedValue({ body: { items: [], errors: false, took: 1 }, - } as unknown as ApiResponse); + } as unknown as TransportResult); const result = await cleanupTasks({ ...cleanupTasksOpts, tasks: [taskSO], @@ -106,7 +107,7 @@ describe('cleanupTasks', () => { errors: true, took: 1, }, - } as unknown as ApiResponse); + } as unknown as TransportResult); const result = await cleanupTasks({ ...cleanupTasksOpts, tasks: [taskSO], diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts index 2e0037d01943d..9b49c6be1f426 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts @@ -6,13 +6,14 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { ApiResponse, estypes } from '@elastic/elasticsearch'; +import { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; export async function bulkDelete( esClient: ElasticsearchClient, index: string, ids: string[] -): Promise | undefined> { +): Promise | undefined> { if (ids.length === 0) { return; } diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts index 90418c9763a4d..29025004e67e1 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts @@ -5,12 +5,13 @@ * 2.0. */ -import { ApiResponse, estypes } from '@elastic/elasticsearch'; +import { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; type ResponseFailures = Array>; export function extractBulkResponseDeleteFailures( - response: ApiResponse + response: TransportResult ): ResponseFailures { const result: ResponseFailures = []; for (const item of response.body.items) { diff --git a/x-pack/plugins/canvas/types/strategy.ts b/x-pack/plugins/canvas/types/strategy.ts index 055fb4c57cc66..1fa68ab151cfc 100644 --- a/x-pack/plugins/canvas/types/strategy.ts +++ b/x-pack/plugins/canvas/types/strategy.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; import { estypes } from '@elastic/elasticsearch'; import { IKibanaSearchRequest } from 'src/plugins/data/common'; import { ExpressionValueFilter } from '.'; @@ -27,5 +27,5 @@ export interface EssqlSearchStrategyResponse { }>; rows: any[]; - rawResponse: ApiResponse; + rawResponse: TransportResult; } diff --git a/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts b/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts index 461c41b46491c..0cc7d4b3f2c76 100644 --- a/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts +++ b/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { ElasticsearchClient } from 'src/core/server'; import { SearchStatus } from './types'; import { SearchSessionRequestInfo } from '../../../../../../src/plugins/data/common'; @@ -19,7 +19,7 @@ export async function getSearchStatus( // TODO: Handle strategies other than the default one try { // @ts-expect-error start_time_in_millis: EpochMillis is string | number - const apiResponse: ApiResponse = await client.asyncSearch.status({ + const apiResponse: TransportResult = await client.asyncSearch.status({ id: asyncId, }); const response = apiResponse.body; diff --git a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts index c7f224dcf0b22..b5f8356332b72 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts @@ -9,7 +9,7 @@ import { elasticsearchServiceMock } from 'src/core/server/mocks'; import { errors } from '@elastic/elasticsearch'; -import type { ApiResponse } from '@elastic/transport'; +import type { TransportResult } from '@elastic/transport'; import { FLEET_SERVER_ARTIFACTS_INDEX } from '../../../common'; @@ -103,7 +103,7 @@ describe('When using the artifacts services', () => { }); it('should ignore 409 errors from elasticsearch', async () => { - const error = new errors.ResponseError({ statusCode: 409 } as ApiResponse); + const error = new errors.ResponseError({ statusCode: 409 } as TransportResult); // Unclear why `mockRejectedValue()` has the params value type set to `never` // @ts-expect-error esClientMock.create.mockRejectedValue(error); diff --git a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts index 754df46a30b11..053021063fdf9 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts @@ -6,7 +6,7 @@ */ import { URL } from 'url'; -import type { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { errors } from '@elastic/elasticsearch'; import { elasticsearchServiceMock } from '../../../../../../src/core/server/mocks'; @@ -69,7 +69,7 @@ export interface GenerateEsRequestErrorApiResponseMockProps { export const generateEsRequestErrorApiResponseMock = ( { statusCode = 500 }: GenerateEsRequestErrorApiResponseMockProps = { statusCode: 500 } -): ApiResponse => { +): TransportResult => { return generateEsApiResponseMock( { _index: '.fleet-artifacts_1', @@ -127,8 +127,8 @@ export const generateArtifactEsSearchResultHitsMock = (): ESSearchResponse< export const generateEsApiResponseMock = >( body: TBody, - otherProps: Partial> = {} -): ApiResponse => { + otherProps: Partial> = {} +): TransportResult => { return elasticsearchServiceMock.createApiResponse({ body, headers: { diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts index 5c65ff9f6a14b..a23cca4f765fa 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { PolicyFromES, SerializedPolicy } from '../../../../common/types'; import { RouteDependencies } from '../../../types'; @@ -46,7 +46,7 @@ function formatPolicies(policiesMap: PoliciesMap): PolicyFromES[] { }, []); } -async function fetchPolicies(client: ElasticsearchClient): Promise> { +async function fetchPolicies(client: ElasticsearchClient): Promise> { const options = { // we allow 404 since they may have no policies ignore: [404], diff --git a/x-pack/plugins/infra/server/utils/get_all_composite_data.ts b/x-pack/plugins/infra/server/utils/get_all_composite_data.ts index 2faac324c3858..a8f36ebbad783 100644 --- a/x-pack/plugins/infra/server/utils/get_all_composite_data.ts +++ b/x-pack/plugins/infra/server/utils/get_all_composite_data.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; import { InfraDatabaseSearchResponse } from '../lib/adapters/framework'; export const getAllCompositeData = async < @@ -15,7 +15,7 @@ export const getAllCompositeData = async < >( esClientSearch: ( options: Options - ) => Promise>>, + ) => Promise>>, options: Options, bucketSelector: (response: InfraDatabaseSearchResponse<{}, Aggregation>) => Bucket[], onAfterKey: (options: Options, response: InfraDatabaseSearchResponse<{}, Aggregation>) => Options, diff --git a/x-pack/plugins/ml/server/lib/ml_client/search.ts b/x-pack/plugins/ml/server/lib/ml_client/search.ts index 3062a70d9a975..68e503ac56246 100644 --- a/x-pack/plugins/ml/server/lib/ml_client/search.ts +++ b/x-pack/plugins/ml/server/lib/ml_client/search.ts @@ -7,7 +7,8 @@ import Boom from '@hapi/boom'; import { IScopedClusterClient } from 'kibana/server'; -import { estypes, ApiResponse } from '@elastic/elasticsearch'; +import { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { JobSavedObjectService } from '../../saved_objects'; import { ML_RESULTS_INDEX_PATTERN } from '../../../common/constants/index_patterns'; @@ -30,7 +31,7 @@ export function searchProvider( async function anomalySearch( searchParams: estypes.SearchRequest, jobIds: string[] - ): Promise>> { + ): Promise>> { await jobIdsCheck('anomaly-detector', jobIds); const { asInternalUser } = client; const resp = await asInternalUser.search({ diff --git a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts index c7806ab43db91..92cef6ee4ded8 100644 --- a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { DeleteResponse, SearchHit, @@ -53,7 +53,7 @@ interface JobsQueryFactory { count(jobTypes: string[], user: ReportingUser): Promise; get(user: ReportingUser, id: string): Promise; getError(id: string): Promise; - delete(deleteIndex: string, id: string): Promise>; + delete(deleteIndex: string, id: string): Promise>; } export function jobsQueryFactory(reportingCore: ReportingCore): JobsQueryFactory { @@ -102,7 +102,7 @@ export function jobsQueryFactory(reportingCore: ReportingCore): JobsQueryFactory const response = (await execQuery((elasticsearchClient) => elasticsearchClient.search({ body, index: getIndex() }) - )) as ApiResponse>; + )) as TransportResult>; return ( response?.body.hits?.hits.map((report: SearchHit) => { diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts index e621d28c41a75..70e6e645d1829 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { BulkRequest, BulkResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESSearchRequest, ESSearchResponse } from 'src/core/types/elasticsearch'; @@ -35,5 +35,5 @@ export interface IRuleDataReader { } export interface IRuleDataWriter { - bulk(request: BulkRequest): Promise>; + bulk(request: BulkRequest): Promise>; } diff --git a/x-pack/plugins/rule_registry/server/utils/persistence_types.ts b/x-pack/plugins/rule_registry/server/utils/persistence_types.ts index 37c4a0799e1b8..f94ae019ecf5a 100644 --- a/x-pack/plugins/rule_registry/server/utils/persistence_types.ts +++ b/x-pack/plugins/rule_registry/server/utils/persistence_types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { BulkResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger } from '@kbn/logging'; import { ESSearchRequest } from 'src/core/types/elasticsearch'; @@ -28,7 +28,7 @@ export type PersistenceAlertService< fields: Record; }>, refresh: boolean | 'wait_for' -) => Promise>; +) => Promise>; export type PersistenceAlertQueryService = ( query: ESSearchRequest diff --git a/x-pack/plugins/security/server/mocks.ts b/x-pack/plugins/security/server/mocks.ts index f1f858a40a465..9abbb60d2b93f 100644 --- a/x-pack/plugins/security/server/mocks.ts +++ b/x-pack/plugins/security/server/mocks.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { licenseMock } from '../common/licensing/index.mock'; import type { MockAuthenticatedUserProps } from '../common/model/authenticated_user.mock'; @@ -50,9 +50,9 @@ function createStartMock() { } function createApiResponseMock( - apiResponse: Pick, 'body'> & - Partial, 'body'>> -): ApiResponse { + apiResponse: Pick, 'body'> & + Partial, 'body'>> +): TransportResult { return { statusCode: null, headers: null, diff --git a/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts b/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts index b3a2c9c9a3f62..0a3f3921ba346 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts @@ -5,10 +5,10 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { ErrorResponse } from './helpers'; -export const getValidEqlResponse = (): ApiResponse['body'] => ({ +export const getValidEqlResponse = (): TransportResult['body'] => ({ is_partial: false, is_running: false, took: 162, @@ -56,7 +56,7 @@ export const getEqlResponseWithValidationErrors = (): ErrorResponse => ({ }, }); -export const getEqlResponseWithNonValidationError = (): ApiResponse['body'] => ({ +export const getEqlResponseWithNonValidationError = (): TransportResult['body'] => ({ error: { root_cause: [ { diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts index 6894e237581e8..e623c47b356cb 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { TransformGetTransformStatsResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CheckMetadataTransformsTask, @@ -102,7 +102,7 @@ describe('check metadata transforms task', () => { }, ], }, - } as unknown as ApiResponse); + } as unknown as TransportResult); it('should stop task if transform stats response fails', async () => { esClient.transform.getTransformStats.mockRejectedValue({}); @@ -237,7 +237,7 @@ describe('check metadata transforms task', () => { }, ], }, - } as unknown as ApiResponse; + } as unknown as TransportResult; esClient.transform.getTransformStats.mockResolvedValue(transformStatsResponseMock); taskResponse = (await runTask({ ...MOCK_TASK_INSTANCE, diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts index 41ce6845ab30b..ebf284d4fa457 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { TransformGetTransformStatsResponse, TransformGetTransformStatsTransformStats, @@ -104,7 +104,7 @@ export class CheckMetadataTransformsTask { const [{ elasticsearch }] = await core.getStartServices(); const esClient = elasticsearch.client.asInternalUser; - let transformStatsResponse: ApiResponse; + let transformStatsResponse: TransportResult; try { transformStatsResponse = await esClient?.transform.getTransformStats({ transform_id: METADATA_TRANSFORMS_PATTERN, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts b/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts index 34f7d140a78de..ec4db41b4d6c9 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts @@ -9,7 +9,7 @@ /* eslint-disable max-classes-per-file */ /* eslint-disable @typescript-eslint/no-useless-constructor */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import moment from 'moment'; import uuid from 'uuid'; import { @@ -18,7 +18,7 @@ import { ISOLATION_ACTIONS, } from '../../../../common/endpoint/types'; -export const mockSearchResult = (results: any = []): ApiResponse => { +export const mockSearchResult = (results: any = []): TransportResult => { return { body: { hits: { diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts index 8189074833de1..3b37cd2ca15ab 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts @@ -6,7 +6,7 @@ */ import Boom from '@hapi/boom'; -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { SearchResponse, SearchTotalHits } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TypeOf } from '@kbn/config-schema'; @@ -458,7 +458,7 @@ async function queryUnitedIndex( endpointPolicyIds ); - let unitedMetadataQueryResponse: ApiResponse>; + let unitedMetadataQueryResponse: TransportResult>; try { unitedMetadataQueryResponse = await context.core.elasticsearch.client.asCurrentUser.search( diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts b/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts index ba9ac98cbffe4..3dcfee65314eb 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts @@ -5,7 +5,8 @@ * 2.0. */ -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { IScopedClusterClient } from 'src/core/server'; import { JsonObject, JsonValue } from '@kbn/utility-types'; import { FieldsObject, ResolverSchema } from '../../../../../../common/endpoint/types'; @@ -197,7 +198,7 @@ export class DescendantsQuery { return []; } - let response: ApiResponse>; + let response: TransportResult>; if (this.schema.ancestry) { response = await client.asCurrentUser.search({ body: this.queryWithAncestryArray(validNodes, this.schema.ancestry, limit), diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts index 047495031a6df..ebc9b76a7850a 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { performance } from 'perf_hooks'; import { SavedObject } from 'src/core/types'; import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; @@ -120,7 +120,7 @@ export const eqlExecutor = async ({ // TODO: fix this later const { body: response } = (await services.scopedClusterClient.asCurrentUser.transport.request( request - )) as ApiResponse; + )) as TransportResult; const eqlSignalSearchEnd = performance.now(); const eqlSearchDuration = makeFloatString(eqlSignalSearchEnd - eqlSignalSearchStart); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts index 8c3f97f36aab5..e5bb015d663e2 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts @@ -24,7 +24,7 @@ import { listMock } from '../../../../../lists/server/mocks'; import { getListClientMock } from '../../../../../lists/server/services/lists/list_client.mock'; import { getExceptionListClientMock } from '../../../../../lists/server/services/exception_lists/exception_list_client.mock'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; -import { ApiResponse } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; import { queryExecutor } from './executors/query'; @@ -158,7 +158,7 @@ describe('signal_rule_alert_type', () => { (mlExecutor as jest.Mock).mockClear(); (mlExecutor as jest.Mock).mockResolvedValue(executorReturnValue); (parseScheduleDates as jest.Mock).mockReturnValue(moment(100)); - const value: Partial> = { + const value: Partial> = { statusCode: 200, body: { indices: ['index1', 'index2', 'index3', 'index4'], @@ -175,7 +175,7 @@ describe('signal_rule_alert_type', () => { }, }; alertServices.scopedClusterClient.asCurrentUser.fieldCaps.mockResolvedValue( - value as ApiResponse + value as TransportResult ); const ruleAlert = getAlertMock(false, getQueryRuleParams()); alertServices.savedObjectsClient.get.mockResolvedValue({ diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts index 4b9c51da2bd41..97ccd5b5f6b23 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts @@ -7,7 +7,7 @@ import moment from 'moment'; import sinon from 'sinon'; -import { ApiResponse } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; import { listMock } from '../../../../../lists/server/mocks'; @@ -758,7 +758,7 @@ describe('utils', () => { test('returns true when missing timestamp override field', async () => { const timestampField = 'event.ingested'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, unknown>> = { + const timestampFieldCapsResponse: Partial, unknown>> = { body: { indices: ['myfakeindex-1', 'myfakeindex-2', 'myfakeindex-3', 'myfakeindex-4'], fields: { @@ -785,7 +785,9 @@ describe('utils', () => { timestampField, ruleName: 'myfakerulename', // eslint-disable-next-line @typescript-eslint/no-explicit-any - timestampFieldCapsResponse: timestampFieldCapsResponse as ApiResponse>, + timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + Record + >, inputIndices: ['myfa*'], ruleStatusClient, ruleId: 'ruleId', @@ -801,7 +803,7 @@ describe('utils', () => { test('returns true when missing timestamp field', async () => { const timestampField = '@timestamp'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, Context>> = { + const timestampFieldCapsResponse: Partial, Context>> = { body: { indices: ['myfakeindex-1', 'myfakeindex-2', 'myfakeindex-3', 'myfakeindex-4'], fields: { @@ -828,7 +830,9 @@ describe('utils', () => { timestampField, ruleName: 'myfakerulename', // eslint-disable-next-line @typescript-eslint/no-explicit-any - timestampFieldCapsResponse: timestampFieldCapsResponse as ApiResponse>, + timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + Record + >, inputIndices: ['myfa*'], ruleStatusClient, ruleId: 'ruleId', @@ -845,7 +849,7 @@ describe('utils', () => { test('returns true when missing logs-endpoint.alerts-* index and rule name is Endpoint Security', async () => { const timestampField = '@timestamp'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, Context>> = { + const timestampFieldCapsResponse: Partial, Context>> = { body: { indices: [], fields: {}, @@ -857,7 +861,9 @@ describe('utils', () => { timestampField, ruleName: 'Endpoint Security', // eslint-disable-next-line @typescript-eslint/no-explicit-any - timestampFieldCapsResponse: timestampFieldCapsResponse as ApiResponse>, + timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + Record + >, inputIndices: ['logs-endpoint.alerts-*'], ruleStatusClient, ruleId: 'ruleId', @@ -874,7 +880,7 @@ describe('utils', () => { test('returns true when missing logs-endpoint.alerts-* index and rule name is NOT Endpoint Security', async () => { const timestampField = '@timestamp'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, Context>> = { + const timestampFieldCapsResponse: Partial, Context>> = { body: { indices: [], fields: {}, @@ -886,7 +892,9 @@ describe('utils', () => { timestampField, ruleName: 'NOT Endpoint Security', // eslint-disable-next-line @typescript-eslint/no-explicit-any - timestampFieldCapsResponse: timestampFieldCapsResponse as ApiResponse>, + timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + Record + >, inputIndices: ['logs-endpoint.alerts-*'], ruleStatusClient, ruleId: 'ruleId', diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index 8ef5384fbf1c9..7538aedf3aacb 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -11,7 +11,7 @@ import uuidv5 from 'uuid/v5'; import dateMath from '@elastic/datemath'; import type { estypes } from '@elastic/elasticsearch'; -import { ApiResponse } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; import { ALERT_INSTANCE_ID, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; import type { ListArray, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { MAX_EXCEPTION_LIST_SIZE } from '@kbn/securitysolution-list-constants'; @@ -151,7 +151,7 @@ export const hasTimestampFields = async (args: { // any is derived from here // node_modules/@elastic/elasticsearch/lib/api/kibana.d.ts // eslint-disable-next-line @typescript-eslint/no-explicit-any - timestampFieldCapsResponse: ApiResponse, unknown>; + timestampFieldCapsResponse: TransportResult, unknown>; inputIndices: string[]; ruleStatusClient: IRuleExecutionLogClient; ruleId: string; diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts index 9a95517986bee..f09f1b051d881 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts @@ -7,7 +7,8 @@ import { ElasticsearchClient } from 'kibana/server'; import { Logger } from 'src/core/server'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { fromKueryExpression, toElasticsearchQuery, @@ -49,7 +50,7 @@ export async function getShapesFilters( const shapesIdsNamesMap: Record = {}; // Get all shapes in index // eslint-disable-next-line @typescript-eslint/no-explicit-any - const { body: boundaryData }: ApiResponse> = await esClient.search({ + const { body: boundaryData }: TransportResult> = await esClient.search({ index: boundaryIndexTitle, body: { size: MAX_SHAPES_QUERY_SIZE, diff --git a/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts b/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts index b3a2c9c9a3f62..0a3f3921ba346 100644 --- a/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts +++ b/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts @@ -5,10 +5,10 @@ * 2.0. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { ErrorResponse } from './helpers'; -export const getValidEqlResponse = (): ApiResponse['body'] => ({ +export const getValidEqlResponse = (): TransportResult['body'] => ({ is_partial: false, is_running: false, took: 162, @@ -56,7 +56,7 @@ export const getEqlResponseWithValidationErrors = (): ErrorResponse => ({ }, }); -export const getEqlResponseWithNonValidationError = (): ApiResponse['body'] => ({ +export const getEqlResponseWithNonValidationError = (): TransportResult['body'] => ({ error: { root_cause: [ { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts index 3131649e7c742..1baf86bb7f528 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts @@ -7,7 +7,8 @@ import expect from '@kbn/expect'; import { omit } from 'lodash'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios, Superuser } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { @@ -534,7 +535,7 @@ instanceStateValue: true const scheduledActionTask: estypes.SearchHit< TaskRunning > = await retry.try(async () => { - const searchResult: ApiResponse< + const searchResult: TransportResult< estypes.SearchResponse> > = await es.search({ index: '.kibana_task_manager', diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts index 1e85cb3011979..54b3c14dad1e2 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios } from '../../scenarios'; import { checkAAD, @@ -31,7 +32,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: ApiResponse> = await es.get({ + const scheduledTask: TransportResult> = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts index d836f615e5349..7f5f1b37bf9a8 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { @@ -33,7 +34,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: ApiResponse> = await es.get({ + const scheduledTask: TransportResult> = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts index fe0f5d3ecbade..272dbc4d59145 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { getTestAlertData, ObjectRemover } from '../../../../common/lib'; import { AlertHistoryDefaultIndexName } from '../../../../../../plugins/actions/common'; @@ -66,7 +67,7 @@ export default function preconfiguredAlertHistoryConnectorTests({ await waitForStatus(response.body.id, new Set(['active'])); await retry.try(async () => { - const result: ApiResponse> = await es.search({ + const result: TransportResult> = await es.search({ index: AlertHistoryDefaultIndexName, }); const indexedItems = result.body.hits.hits; @@ -104,7 +105,7 @@ export default function preconfiguredAlertHistoryConnectorTests({ await waitForStatus(response.body.id, new Set(['active'])); await retry.try(async () => { - const result: ApiResponse> = await es.search({ + const result: TransportResult> = await es.search({ index: ALERT_HISTORY_OVERRIDE_INDEX, }); const indexedItems = result.body.hits.hits; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts index 999135993d069..5129bd196be60 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts @@ -7,7 +7,8 @@ import expect from '@kbn/expect'; import { omit } from 'lodash'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/elasticsearch'; import { Response as SupertestResponse } from 'supertest'; import { RecoveredActionGroup } from '../../../../../plugins/alerting/common'; import { Space } from '../../../common/types'; @@ -379,7 +380,7 @@ instanceStateValue: true const scheduledActionTask: estypes.SearchHit< TaskRunning > = await retry.try(async () => { - const searchResult: ApiResponse< + const searchResult: TransportResult< estypes.SearchResponse> > = await es.search({ index: '.kibana_task_manager', diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts index f45ad28e2cdc5..d998c86eefe66 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { SavedObject } from 'kibana/server'; import { Spaces } from '../../scenarios'; import { @@ -31,7 +32,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: ApiResponse> = await es.get({ + const scheduledTask: TransportResult> = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts index 881931252ed5f..a0196ff3fcb28 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { Spaces } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { @@ -30,7 +31,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: ApiResponse> = await es.get({ + const scheduledTask: TransportResult> = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts index e3a062a08ffb9..94c9904a29fd6 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { getUrlPrefix } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import type { RawAlert, RawAlertAction } from '../../../../../plugins/alerting/server/types'; @@ -201,7 +202,7 @@ export default function createGetTests({ getService }: FtrProviderContext) { }); it('7.16.0 migrates existing alerts to contain legacyId field', async () => { - const searchResult: ApiResponse> = await es.search({ + const searchResult: TransportResult> = await es.search({ index: '.kibana', body: { query: { @@ -220,7 +221,7 @@ export default function createGetTests({ getService }: FtrProviderContext) { }); it('7.16.0 migrates existing rules so predefined connectors are not stored in references', async () => { - const searchResult: ApiResponse> = await es.search({ + const searchResult: TransportResult> = await es.search({ index: '.kibana', body: { query: { diff --git a/x-pack/test/api_integration/apis/security_solution/utils.ts b/x-pack/test/api_integration/apis/security_solution/utils.ts index 5eaca9d679a0d..86e02989f12de 100644 --- a/x-pack/test/api_integration/apis/security_solution/utils.ts +++ b/x-pack/test/api_integration/apis/security_solution/utils.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { ApiResponse, estypes } from '@elastic/elasticsearch'; +import { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { JsonObject, JsonArray } from '@kbn/utility-types'; @@ -13,7 +14,7 @@ export async function getSavedObjectFromES( es: KibanaClient, savedObjectType: string, query?: object -): Promise, unknown>> { +): Promise, unknown>> { return await es.search({ index: '.kibana', body: { diff --git a/x-pack/test/case_api_integration/common/lib/utils.ts b/x-pack/test/case_api_integration/common/lib/utils.ts index 188fe50f2fb06..812cc777dd0df 100644 --- a/x-pack/test/case_api_integration/common/lib/utils.ts +++ b/x-pack/test/case_api_integration/common/lib/utils.ts @@ -7,7 +7,8 @@ import { omit } from 'lodash'; import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type SuperTest from 'supertest'; @@ -78,7 +79,7 @@ export const getSignalsWithES = async ({ indices: string | string[]; ids: string | string[]; }): Promise>>> => { - const signals: ApiResponse> = await es.search({ + const signals: TransportResult> = await es.search({ index: indices, body: { size: 10000, @@ -590,7 +591,7 @@ interface ConnectorMappingsSavedObject { * Returns connector mappings saved objects from Elasticsearch directly. */ export const getConnectorMappingsFromES = async ({ es }: { es: KibanaClient }) => { - const mappings: ApiResponse> = + const mappings: TransportResult> = await es.search({ index: '.kibana', body: { @@ -615,7 +616,7 @@ interface ConfigureSavedObject { * Returns configure saved objects from Elasticsearch directly. */ export const getConfigureSavedObjectsFromES = async ({ es }: { es: KibanaClient }) => { - const configure: ApiResponse> = await es.search({ + const configure: TransportResult> = await es.search({ index: '.kibana', body: { query: { @@ -632,7 +633,7 @@ export const getConfigureSavedObjectsFromES = async ({ es }: { es: KibanaClient }; export const getCaseSavedObjectsFromES = async ({ es }: { es: KibanaClient }) => { - const configure: ApiResponse> = + const configure: TransportResult> = await es.search({ index: '.kibana', body: { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts index b7838dd9299bc..23d3028515205 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { @@ -423,7 +424,7 @@ export default ({ getService }: FtrProviderContext): void => { * around 30 seconds which seemed too slow */ const getAllCasesSortedByCreatedAtAsc = async () => { - const cases: ApiResponse> = await es.search({ + const cases: TransportResult> = await es.search({ index: '.kibana', body: { size: 10000, diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts index d54523bec0c4d..4815e656414d6 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/elasticsearch'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { findSubCasesResp, postCollectionReq } from '../../../../common/lib/mock'; @@ -313,16 +314,18 @@ export default ({ getService }: FtrProviderContext): void => { }; const getAllCasesSortedByCreatedAtAsc = async () => { - const cases: ApiResponse> = await es.search({ - index: '.kibana', - body: { - size: 10000, - sort: [{ 'cases-sub-case.created_at': { unmapped_type: 'date', order: 'asc' } }], - query: { - term: { type: 'cases-sub-case' }, + const cases: TransportResult> = await es.search( + { + index: '.kibana', + body: { + size: 10000, + sort: [{ 'cases-sub-case.created_at': { unmapped_type: 'date', order: 'asc' } }], + query: { + term: { type: 'cases-sub-case' }, + }, }, - }, - }); + } + ); return cases.body.hits.hits.map((hit) => hit._source); }; diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index 80ddb5e1cfe76..d0972432170e2 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -6,7 +6,7 @@ */ import { KbnClient } from '@kbn/test'; -import type { ApiResponse } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import type { estypes } from '@elastic/elasticsearch'; import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type SuperTest from 'supertest'; @@ -794,7 +794,7 @@ export const waitFor = async ( * @param timeoutWait Time to wait before trying again (has default) */ export const countDownES = async ( - esFunction: () => Promise, unknown>>, + esFunction: () => Promise, unknown>>, esFunctionName: string, retryCount: number = 20, timeoutWait = 250 diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts index caf62a1d364c0..8124c0d95fb99 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts @@ -6,7 +6,8 @@ */ import expect from '@kbn/expect'; -import type { ApiResponse, estypes } from '@elastic/elasticsearch'; +import type { estypes } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; import { TaskInstanceWithDeprecatedFields } from '../../../../plugins/task_manager/server/task'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { SavedObjectsUtils } from '../../../../../src/core/server/saved_objects'; @@ -43,7 +44,7 @@ export default function createGetTests({ getService }: FtrProviderContext) { }); it('8.0.0 migrates actions tasks from legacy id to saved object ids', async () => { - const searchResult: ApiResponse< + const searchResult: TransportResult< estypes.SearchResponse<{ task: TaskInstanceWithDeprecatedFields }> > = await es.search({ index: '.kibana_task_manager', From cf0bdf6100a3bee1117b212193b8d5523ac3b38a Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 10:59:41 +0200 Subject: [PATCH 013/172] fix errors in client_config --- .../client/client_config.test.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/core/server/elasticsearch/client/client_config.test.ts b/src/core/server/elasticsearch/client/client_config.test.ts index 7956bcc64ea2f..4baa49a4b47ce 100644 --- a/src/core/server/elasticsearch/client/client_config.test.ts +++ b/src/core/server/elasticsearch/client/client_config.test.ts @@ -305,10 +305,10 @@ describe('parseClientOptions', () => { }); }); - describe('ssl config', () => { - it('does not generate ssl option is ssl config is not set', () => { - expect(parseClientOptions(createConfig({}), false).ssl).toBeUndefined(); - expect(parseClientOptions(createConfig({}), true).ssl).toBeUndefined(); + describe('tls config', () => { + it('does not generate tls option is ssl config is not set', () => { + expect(parseClientOptions(createConfig({}), false).tls).toBeUndefined(); + expect(parseClientOptions(createConfig({}), true).tls).toBeUndefined(); }); it('handles the `certificateAuthorities` option', () => { @@ -318,7 +318,7 @@ describe('parseClientOptions', () => { ssl: { verificationMode: 'full', certificateAuthorities: ['content-of-ca-path'] }, }), false - ).ssl!.ca + ).tls!.ca ).toEqual(['content-of-ca-path']); expect( parseClientOptions( @@ -326,7 +326,7 @@ describe('parseClientOptions', () => { ssl: { verificationMode: 'full', certificateAuthorities: ['content-of-ca-path'] }, }), true - ).ssl!.ca + ).tls!.ca ).toEqual(['content-of-ca-path']); }); @@ -340,7 +340,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, @@ -357,7 +357,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, @@ -375,7 +375,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, @@ -393,7 +393,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toThrowErrorMatchingInlineSnapshot(`"Unknown ssl verificationMode: unknown"`); }); it('throws for undefined values', () => { @@ -406,7 +406,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toThrowErrorMatchingInlineSnapshot(`"Unknown ssl verificationMode: undefined"`); }); }); @@ -423,7 +423,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, @@ -443,7 +443,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, @@ -464,7 +464,7 @@ describe('parseClientOptions', () => { }, }), false - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, @@ -488,7 +488,7 @@ describe('parseClientOptions', () => { }, }), true - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, @@ -508,7 +508,7 @@ describe('parseClientOptions', () => { }, }), true - ).ssl + ).tls ).toMatchInlineSnapshot(` Object { "ca": undefined, From ede95bb36e463fa1f660f95604f7071b8e5643c5 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 11:01:14 +0200 Subject: [PATCH 014/172] fix src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts --- .../migrationsv2/actions/integration_tests/actions.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts index 70f5943c11a44..41e3826875000 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts @@ -280,7 +280,7 @@ describe('migration actions', () => { index: 'red_then_yellow_index', body: { // Enable all shard allocation so that the index status turns yellow - settings: { routing: { allocation: { enable: 'all' } } }, + routing: { allocation: { enable: 'all' } }, }, }); @@ -350,7 +350,7 @@ describe('migration actions', () => { index: 'clone_red_then_yellow_index', body: { // Enable all shard allocation so that the index status goes yellow - settings: { routing: { allocation: { enable: 'all' } } }, + routing: { allocation: { enable: 'all' } }, }, }); indexYellow = true; @@ -1444,7 +1444,7 @@ describe('migration actions', () => { index: 'red_then_yellow_index', body: { // Disable all shard allocation so that the index status is red - settings: { routing: { allocation: { enable: 'all' } } }, + routing: { allocation: { enable: 'all' } }, }, }); indexYellow = true; From 525bdbd434892c174be6d38988d26aca8f933d67 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 11:05:10 +0200 Subject: [PATCH 015/172] use KibanaClient in mock. we dont export the original Client --- src/core/server/elasticsearch/client/mocks.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index a37cccce17f57..f2a0caa91c26d 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { Client } from '@elastic/elasticsearch'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { TransportResult } from '@elastic/transport'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import { ElasticsearchClient } from './types'; @@ -16,7 +16,7 @@ import { PRODUCT_RESPONSE_HEADER } from '../supported_server_response_check'; // use jest.requireActual() to prevent weird errors when people mock @elastic/elasticsearch const { Client: UnmockedClient } = jest.requireActual('@elastic/elasticsearch'); -const createInternalClientMock = (res?: Promise): DeeplyMockedKeys => { +const createInternalClientMock = (res?: Promise): DeeplyMockedKeys => { // we mimic 'reflection' on a concrete instance of the client to generate the mocked functions. const client = new UnmockedClient({ node: 'http://localhost', @@ -84,7 +84,7 @@ const createInternalClientMock = (res?: Promise): DeeplyMockedKeys; + return client as DeeplyMockedKeys; }; export type ElasticsearchClientMock = DeeplyMockedKeys; From d3607c5c013d6b16e661e3e03f094e4d62c8cd25 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 11:43:10 +0200 Subject: [PATCH 016/172] fix client mocks --- .../client/configure_client.test.ts | 41 ++++++++++--------- .../elasticsearch/client/configure_client.ts | 27 +++++++----- .../server/elasticsearch/client/mocks.test.ts | 6 +-- src/core/server/elasticsearch/client/mocks.ts | 7 ++-- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index b2d8ca1d55ed6..1d258012d6450 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -9,13 +9,14 @@ import { Buffer } from 'buffer'; import { Readable } from 'stream'; -import { RequestEvent, errors } from '@elastic/elasticsearch'; +import { errors } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch'; import type { TransportRequestOptions, TransportRequestParams, - RequestBody, + DiagnosticResult, } from '@elastic/transport'; +import type { RequestBody } from '@elastic/transport/lib/types'; import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks'; import { loggingSystemMock } from '../../logging/logging_system.mock'; @@ -36,7 +37,7 @@ const createFakeClient = () => { const client = new actualEs.Client({ nodes: ['http://localhost'], // Enforcing `nodes` because it's mandatory }); - jest.spyOn(client, 'on'); + jest.spyOn(client.diagnostic, 'on'); return client; }; @@ -54,7 +55,7 @@ const createApiResponse = ({ warnings?: string[]; params?: TransportRequestParams; requestOptions?: TransportRequestOptions; -}): RequestEvent => { +}): DiagnosticResult => { return { body, statusCode, @@ -124,8 +125,8 @@ describe('configureClient', () => { it('listens to client on `response` events', () => { const client = configureClient(config, { logger, type: 'test', scoped: false }); - expect(client.on).toHaveBeenCalledTimes(1); - expect(client.on).toHaveBeenCalledWith('response', expect.any(Function)); + expect(client.diagnostic.on).toHaveBeenCalledTimes(1); + expect(client.diagnostic.on).toHaveBeenCalledWith('response', expect.any(Function)); }); describe('Product check', () => { @@ -176,7 +177,7 @@ describe('configureClient', () => { }, }); - client.emit('response', null, response); + client.diagnostic.emit('response', null, response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ Array [ @@ -201,7 +202,7 @@ describe('configureClient', () => { }) ); - client.emit('response', null, response); + client.diagnostic.emit('response', null, response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ Array [ @@ -228,7 +229,7 @@ describe('configureClient', () => { ) ); - client.emit('response', null, response); + client.diagnostic.emit('response', null, response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ Array [ @@ -255,7 +256,7 @@ describe('configureClient', () => { ) ); - client.emit('response', null, response); + client.diagnostic.emit('response', null, response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ Array [ @@ -273,7 +274,7 @@ describe('configureClient', () => { const response = createResponseWithBody(); - client.emit('response', null, response); + client.diagnostic.emit('response', null, response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ Array [ @@ -298,7 +299,7 @@ describe('configureClient', () => { }, }); - client.emit('response', null, response); + client.diagnostic.emit('response', null, response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ @@ -333,7 +334,7 @@ describe('configureClient', () => { }, }, }); - client.emit('response', new errors.ResponseError(response), response); + client.diagnostic.emit('response', new errors.ResponseError(response), response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ @@ -351,7 +352,7 @@ describe('configureClient', () => { const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false }); const response = createApiResponse({ body: {} }); - client.emit('response', new errors.TimeoutError('message', response), response); + client.diagnostic.emit('response', new errors.TimeoutError('message', response), response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ @@ -381,7 +382,7 @@ describe('configureClient', () => { }, }, }); - client.emit('response', new errors.ResponseError(response), response); + client.diagnostic.emit('response', new errors.ResponseError(response), response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ @@ -397,7 +398,7 @@ describe('configureClient', () => { it('logs default error info when the error response body is empty', () => { const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false }); - let response: RequestEvent = createApiResponse({ + let response: DiagnosticResult = createApiResponse({ statusCode: 400, headers: {}, params: { @@ -408,7 +409,7 @@ describe('configureClient', () => { error: {}, }, }); - client.emit('response', new errors.ResponseError(response), response); + client.diagnostic.emit('response', new errors.ResponseError(response), response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ @@ -431,7 +432,7 @@ describe('configureClient', () => { }, body: undefined, }); - client.emit('response', new errors.ResponseError(response), response); + client.diagnostic.emit('response', new errors.ResponseError(response), response); expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` Array [ @@ -461,7 +462,7 @@ describe('configureClient', () => { error: {}, }, }); - client.emit('response', null, response); + client.diagnostic.emit('response', null, response); expect(loggingSystemMock.collect(logger).debug[0][1]).toMatchInlineSnapshot(` Object { @@ -487,7 +488,7 @@ describe('configureClient', () => { }, body: {} as any, }); - client.emit('response', new errors.ResponseError(response), response); + client.diagnostic.emit('response', new errors.ResponseError(response), response); expect(loggingSystemMock.collect(logger).debug[0][1]).toMatchInlineSnapshot(` Object { diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index a20c8d96db7f1..ad44e46612949 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -8,12 +8,15 @@ import { Buffer } from 'buffer'; import { stringify } from 'querystring'; -import { ApiError, Client, RequestEvent, errors, Transport } from '@elastic/elasticsearch'; +import { Client, errors } from '@elastic/elasticsearch'; +import { Transport, events } from '@elastic/transport'; import type { - RequestBody, TransportRequestParams, TransportRequestOptions, + TransportResult, + DiagnosticResult, } from '@elastic/transport'; +import type { RequestBody } from '@elastic/transport/lib/types'; import { Logger } from '../../logging'; import { parseClientOptions, ElasticsearchClientConfig } from './client_config'; @@ -36,13 +39,16 @@ export const configureClient = ( const clientOptions = parseClientOptions(config, scoped); class KibanaTransport extends Transport { request(params: TransportRequestParams, options?: TransportRequestOptions) { - const opts = options || {}; + const opts: TransportRequestOptions = options || {}; const opaqueId = getExecutionContext(); if (opaqueId && !opts.opaqueId) { // rewrites headers['x-opaque-id'] if it presents opts.opaqueId = opaqueId; } - return super.request(params, opts); + // Enforce the client to return TransportResult. + // It's required for bwc with responses in 7.x version. + opts.meta = true; + return super.request(params, opts) as Promise>; } } @@ -76,9 +82,10 @@ function ensureString(body: RequestBody): string { * Returns a debug message from an Elasticsearch error in the following format: * [error type] error reason */ -export function getErrorMessage(error: ApiError): string { +export function getErrorMessage(error: errors.ElasticsearchClientError): string { if (error instanceof errors.ResponseError) { - return `[${error.meta.body?.error?.type}]: ${error.meta.body?.error?.reason ?? error.message}`; + const errorBody = error.meta.body as { error?: { type: string; reason?: string } }; + return `[${errorBody?.error?.type}]: ${errorBody?.error?.reason ?? error.message}`; } return `[${error.name}]: ${error.message}`; } @@ -92,7 +99,7 @@ export function getErrorMessage(error: ApiError): string { * * so it could be copy-pasted into the Dev console */ -function getResponseMessage(event: RequestEvent): string { +function getResponseMessage(event: DiagnosticResult): string { const errorMeta = getRequestDebugMeta(event); const body = errorMeta.body ? `\n${errorMeta.body}` : ''; return `${errorMeta.statusCode}\n${errorMeta.method} ${errorMeta.url}${body}`; @@ -102,7 +109,7 @@ function getResponseMessage(event: RequestEvent): string { * Returns stringified debug information from an Elasticsearch request event * useful for logging in case of an unexpected failure. */ -export function getRequestDebugMeta(event: RequestEvent): { +export function getRequestDebugMeta(event: DiagnosticResult): { url: string; body: string; statusCode: number | null; @@ -115,12 +122,12 @@ export function getRequestDebugMeta(event: RequestEvent): { url: `${params.path}${querystring ? `?${querystring}` : ''}`, body: params.body ? `${ensureString(params.body)}` : '', method: params.method, - statusCode: event.statusCode, + statusCode: event.statusCode!, }; } const addLogging = (client: Client, logger: Logger) => { - client.on('response', (error, event) => { + client.diagnostic.on(events.RESPONSE, (error, event) => { if (event) { const opaqueId = event.meta.request.options.opaqueId; const meta = opaqueId diff --git a/src/core/server/elasticsearch/client/mocks.test.ts b/src/core/server/elasticsearch/client/mocks.test.ts index e3619e094c8cb..30b50e19f6c7e 100644 --- a/src/core/server/elasticsearch/client/mocks.test.ts +++ b/src/core/server/elasticsearch/client/mocks.test.ts @@ -39,9 +39,9 @@ describe('Mocked client', () => { }); it('used EventEmitter functions should be mocked', () => { - expectMocked(client.on); - expectMocked(client.off); - expectMocked(client.once); + expectMocked(client.diagnostic.on); + expectMocked(client.diagnostic.off); + expectMocked(client.diagnostic.once); }); it('`child` should be mocked and return a mocked Client', () => { diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index f2a0caa91c26d..f08725d51dfd7 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -15,7 +15,6 @@ import { PRODUCT_RESPONSE_HEADER } from '../supported_server_response_check'; // use jest.requireActual() to prevent weird errors when people mock @elastic/elasticsearch const { Client: UnmockedClient } = jest.requireActual('@elastic/elasticsearch'); - const createInternalClientMock = (res?: Promise): DeeplyMockedKeys => { // we mimic 'reflection' on a concrete instance of the client to generate the mocked functions. const client = new UnmockedClient({ @@ -77,9 +76,9 @@ const createInternalClientMock = (res?: Promise): DeeplyMockedKeys which has only a getter - mockGetter(client, 'on'); - mockGetter(client, 'off'); - mockGetter(client, 'once'); + mockGetter(client.diagnostic, 'on'); + mockGetter(client.diagnostic, 'off'); + mockGetter(client.diagnostic, 'once'); client.transport = { request: jest.fn(), }; From 9f5446c25c00f9e3dbd902035e891eb10e354e74 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 11:46:10 +0200 Subject: [PATCH 017/172] fix errors on SO --- .../saved_objects/migrations/core/elastic_index.test.ts | 4 ++-- .../saved_objects/migrations/core/index_migrator.test.ts | 2 +- .../saved_objects/migrations/kibana/kibana_migrator.test.ts | 5 +++-- .../migrationsv2/actions/check_for_unknown_docs.test.ts | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/server/saved_objects/migrations/core/elastic_index.test.ts b/src/core/server/saved_objects/migrations/core/elastic_index.test.ts index 3de913f77c47e..2cdeb479f50f9 100644 --- a/src/core/server/saved_objects/migrations/core/elastic_index.test.ts +++ b/src/core/server/saved_objects/migrations/core/elastic_index.test.ts @@ -164,7 +164,7 @@ describe('ElasticIndex', () => { client.tasks.get.mockResolvedValue( elasticsearchClientMock.createSuccessTransportRequestPromise({ completed: true, - } as estypes.TaskGetResponse) + } as estypes.TasksGetResponse) ); const info = { @@ -248,7 +248,7 @@ describe('ElasticIndex', () => { reason: 'all shards failed', failed_shards: [], }, - } as estypes.TaskGetResponse) + } as estypes.TasksGetResponse) ); const info = { diff --git a/src/core/server/saved_objects/migrations/core/index_migrator.test.ts b/src/core/server/saved_objects/migrations/core/index_migrator.test.ts index 6ffa6950e9b1f..beb0c1d3651c6 100644 --- a/src/core/server/saved_objects/migrations/core/index_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/core/index_migrator.test.ts @@ -450,7 +450,7 @@ function withIndex( client.tasks.get.mockReturnValue( elasticsearchClientMock.createSuccessTransportRequestPromise({ completed: true, - } as estypes.TaskGetResponse) + } as estypes.TasksGetResponse) ); client.search.mockReturnValue( elasticsearchClientMock.createSuccessTransportRequestPromise(searchResult(0) as any) diff --git a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts index 6e10349f4b57c..e6fbf2fe089be 100644 --- a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts @@ -7,7 +7,8 @@ */ import { take } from 'rxjs/operators'; -import { estypes, errors as esErrors } from '@elastic/elasticsearch'; +import { errors as esErrors } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { elasticsearchClientMock } from '../../../elasticsearch/client/mocks'; import { KibanaMigratorOptions, KibanaMigrator } from './kibana_migrator'; @@ -338,7 +339,7 @@ const mockV2MigrationOptions = () => { error: undefined, failures: [], task: { description: 'task description' } as any, - } as estypes.TaskGetResponse) + } as estypes.TasksGetResponse) ); options.client.search = jest diff --git a/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.test.ts b/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.test.ts index a52cb2a922968..8a99d28b40de1 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.test.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/check_for_unknown_docs.test.ts @@ -8,7 +8,8 @@ import * as Either from 'fp-ts/lib/Either'; import { catchRetryableEsClientErrors } from './catch_retryable_es_client_errors'; -import { errors as EsErrors, estypes } from '@elastic/elasticsearch'; +import { errors as EsErrors } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { elasticsearchClientMock } from '../../../elasticsearch/client/mocks'; import { checkForUnknownDocs } from './check_for_unknown_docs'; From 2f67f71f3fa291f17e08ec6f9aa48ee797cfdb3f Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 12:20:44 +0200 Subject: [PATCH 018/172] fix remaining core errors --- packages/kbn-test/src/es/test_es_cluster.ts | 5 ++--- .../elasticsearch/client/cluster_client.ts | 2 ++ .../elasticsearch/client/configure_client.ts | 3 ++- src/core/server/elasticsearch/client/index.ts | 1 + src/core/server/elasticsearch/client/types.ts | 7 ++++++ .../elasticsearch/elasticsearch_service.ts | 5 +++++ src/core/server/elasticsearch/index.ts | 1 + .../integration_tests/client.test.ts | 2 +- .../supported_server_response_check.ts | 6 +++-- .../version_check/ensure_es_version.test.ts | 1 + .../server/http/router/response_adapter.ts | 5 ++++- src/core/server/http/router/router.ts | 2 +- .../deprecations/unknown_object_types.test.ts | 2 +- .../migrations/core/elastic_index.ts | 1 + .../bulk_overwrite_transformed_documents.ts | 3 ++- .../catch_retryable_es_client_errors.ts | 2 +- .../actions/remove_write_block.ts | 6 ++--- .../migrationsv2/actions/set_write_block.ts | 3 +-- .../migrationsv2/actions/update_aliases.ts | 1 + .../service/lib/decorate_es_error.ts | 22 +++++++++---------- .../saved_objects/service/lib/repository.ts | 1 + .../service/lib/update_objects_spaces.ts | 1 - 22 files changed, 52 insertions(+), 30 deletions(-) diff --git a/packages/kbn-test/src/es/test_es_cluster.ts b/packages/kbn-test/src/es/test_es_cluster.ts index 1143fa381b710..3df1fdb308564 100644 --- a/packages/kbn-test/src/es/test_es_cluster.ts +++ b/packages/kbn-test/src/es/test_es_cluster.ts @@ -281,11 +281,10 @@ export function createTestEsCluster< * Returns an ES Client to the configured cluster */ getClient(): KibanaClient { + // @ts-expect-error TODO make sure Client is assignable to KibanaClient return new Client({ node: this.getHostUrls()[0], - // TODO investigate the mismatch: - // Property 'dataFrameTransformDeprecated' is missing in type 'Client' but required in type 'KibanaClient'. - }) as unknown as KibanaClient; + }); } getUrl() { diff --git a/src/core/server/elasticsearch/client/cluster_client.ts b/src/core/server/elasticsearch/client/cluster_client.ts index f81b651843013..56eb06c92558e 100644 --- a/src/core/server/elasticsearch/client/cluster_client.ts +++ b/src/core/server/elasticsearch/client/cluster_client.ts @@ -52,6 +52,7 @@ export interface ICustomClusterClient extends IClusterClient { /** @internal **/ export class ClusterClient implements ICustomClusterClient { + // @ts-expect-error TODO make sure Client is assignable to KibanaClient public readonly asInternalUser: Client; private readonly rootScopedClient: Client; private readonly allowListHeaders: string[]; @@ -81,6 +82,7 @@ export class ClusterClient implements ICustomClusterClient { const scopedClient = this.rootScopedClient.child({ headers: scopedHeaders, }); + // @ts-expect-error TODO make sure Client is assignable to KibanaClient return new ScopedClusterClient(this.asInternalUser, scopedClient); } diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index ad44e46612949..acf7a14a79945 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -19,6 +19,7 @@ import type { import type { RequestBody } from '@elastic/transport/lib/types'; import { Logger } from '../../logging'; import { parseClientOptions, ElasticsearchClientConfig } from './client_config'; +import type { ElasticsearchErrorDetails } from './types'; const noop = () => undefined; @@ -84,7 +85,7 @@ function ensureString(body: RequestBody): string { */ export function getErrorMessage(error: errors.ElasticsearchClientError): string { if (error instanceof errors.ResponseError) { - const errorBody = error.meta.body as { error?: { type: string; reason?: string } }; + const errorBody = error.meta.body as ElasticsearchErrorDetails; return `[${errorBody?.error?.type}]: ${errorBody?.error?.reason ?? error.message}`; } return `[${error.name}]: ${error.message}`; diff --git a/src/core/server/elasticsearch/client/index.ts b/src/core/server/elasticsearch/client/index.ts index 29f8b85695190..2cf5a0229a489 100644 --- a/src/core/server/elasticsearch/client/index.ts +++ b/src/core/server/elasticsearch/client/index.ts @@ -14,6 +14,7 @@ export type { SearchResponse, GetResponse, DeleteDocumentResponse, + ElasticsearchErrorDetails, } from './types'; export { ScopedClusterClient } from './scoped_cluster_client'; export type { IScopedClusterClient } from './scoped_cluster_client'; diff --git a/src/core/server/elasticsearch/client/types.ts b/src/core/server/elasticsearch/client/types.ts index c3f6ad23560c1..d88a4c53e84d8 100644 --- a/src/core/server/elasticsearch/client/types.ts +++ b/src/core/server/elasticsearch/client/types.ts @@ -132,3 +132,10 @@ export interface DeleteDocumentResponse { type: string; }; } + +/** + * @public + */ +export interface ElasticsearchErrorDetails { + error?: { type: string; reason?: string }; +} diff --git a/src/core/server/elasticsearch/elasticsearch_service.ts b/src/core/server/elasticsearch/elasticsearch_service.ts index 014fa38646275..2f9152c1c33b5 100644 --- a/src/core/server/elasticsearch/elasticsearch_service.ts +++ b/src/core/server/elasticsearch/elasticsearch_service.ts @@ -67,6 +67,7 @@ export class ElasticsearchService config.password !== undefined || config.serviceAccountToken !== undefined, }, + // @ts-expect-error TODO make sure Client is assignable to KibanaClient createClient: (type, clientConfig) => this.createClusterClient(type, config, clientConfig), }; } @@ -81,6 +82,7 @@ export class ElasticsearchService this.client = this.createClusterClient('data', config); const esNodesCompatibility$ = pollEsNodesVersion({ + // @ts-expect-error TODO make sure Client is assignable to KibanaClient internalClient: this.client.asInternalUser, log: this.log, ignoreVersionMismatch: config.ignoreVersionMismatch, @@ -119,6 +121,7 @@ export class ElasticsearchService // Ensure inline scripting is enabled on the ES cluster const scriptingEnabled = await isInlineScriptingEnabled({ + // @ts-expect-error TODO make sure Client is assignable to KibanaClient client: this.client.asInternalUser, }); if (!scriptingEnabled) { @@ -131,7 +134,9 @@ export class ElasticsearchService } return { + // @ts-expect-error TODO make sure Client is assignable to KibanaClient client: this.client!, + // @ts-expect-error TODO make sure Client is assignable to KibanaClient createClient: (type, clientConfig) => this.createClusterClient(type, config, clientConfig), legacy: { config$: this.config$, diff --git a/src/core/server/elasticsearch/index.ts b/src/core/server/elasticsearch/index.ts index 7f0620a03e5f4..72636879b22c3 100644 --- a/src/core/server/elasticsearch/index.ts +++ b/src/core/server/elasticsearch/index.ts @@ -35,6 +35,7 @@ export type { ShardsResponse, GetResponse, DeleteDocumentResponse, + ElasticsearchErrorDetails, } from './client'; export { getRequestDebugMeta, getErrorMessage } from './client'; export { diff --git a/src/core/server/elasticsearch/integration_tests/client.test.ts b/src/core/server/elasticsearch/integration_tests/client.test.ts index f3c9cf27d3b29..1ff9afdda9635 100644 --- a/src/core/server/elasticsearch/integration_tests/client.test.ts +++ b/src/core/server/elasticsearch/integration_tests/client.test.ts @@ -57,7 +57,7 @@ describe('elasticsearch clients', () => { const resp = await kibanaServer.coreStart.elasticsearch.client.asInternalUser.indices.getSettings( { index: '.kibana' }, - { headers: { 'x-elastic-product-origin': null } } + { headers: { 'x-elastic-product-origin': undefined } } ); expect(resp.headers).toHaveProperty('warning'); diff --git a/src/core/server/elasticsearch/supported_server_response_check.ts b/src/core/server/elasticsearch/supported_server_response_check.ts index 85235d04caf5c..91aa06e132de8 100644 --- a/src/core/server/elasticsearch/supported_server_response_check.ts +++ b/src/core/server/elasticsearch/supported_server_response_check.ts @@ -12,7 +12,9 @@ export const PRODUCT_RESPONSE_HEADER = 'x-elastic-product'; * @returns boolean */ // This check belongs to the elasticsearch service as a dedicated helper method. -export const isSupportedEsServer = (headers: Record | null) => { +export const isSupportedEsServer = ( + headers: Record | null | undefined +) => { return !!headers && headers[PRODUCT_RESPONSE_HEADER] === 'Elasticsearch'; }; @@ -27,7 +29,7 @@ export const isSupportedEsServer = (headers: Record | */ export const isNotFoundFromUnsupportedServer = (args: { statusCode: number | null; - headers: Record | null; + headers: Record | null; }): boolean => { return args.statusCode === 404 && !isSupportedEsServer(args.headers); }; diff --git a/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts b/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts index 70166704679fe..c9bb82d5da65c 100644 --- a/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts +++ b/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts @@ -139,6 +139,7 @@ describe('pollEsNodesVersion', () => { }); const nodeInfosSuccessOnce = (infos: NodesInfo) => { + // @ts-expect-error not full interface internalClient.nodes.info.mockImplementationOnce(() => createEsSuccess(infos)); }; const nodeInfosErrorOnce = (error: any) => { diff --git a/src/core/server/http/router/response_adapter.ts b/src/core/server/http/router/response_adapter.ts index b03449b2ae194..753c11d5f45ae 100644 --- a/src/core/server/http/router/response_adapter.ts +++ b/src/core/server/http/router/response_adapter.ts @@ -15,6 +15,7 @@ import Boom from '@hapi/boom'; import * as stream from 'stream'; import { isResponseError as isElasticsearchResponseError } from '../../elasticsearch/client/errors'; +import { ElasticsearchErrorDetails } from '../../elasticsearch'; import { HttpResponsePayload, @@ -154,7 +155,9 @@ function getErrorMessage(payload?: ResponseError): string { if (typeof payload === 'string') return payload; // for ES response errors include nested error reason message. it doesn't contain sensitive data. if (isElasticsearchResponseError(payload)) { - return `[${payload.message}]: ${payload.meta.body?.error?.reason}`; + return `[${payload.message}]: ${ + (payload.meta.body as ElasticsearchErrorDetails)?.error?.reason + }`; } return getErrorMessage(payload.message); diff --git a/src/core/server/http/router/router.ts b/src/core/server/http/router/router.ts index c9679c1871581..be3b24d5d19a7 100644 --- a/src/core/server/http/router/router.ts +++ b/src/core/server/http/router/router.ts @@ -289,7 +289,7 @@ export class Router { const getAuthenticateHeaderValue = () => { - const header = Object.entries(e.headers).find( + const header = Object.entries(e.headers || {}).find( ([key]) => key.toLowerCase() === 'www-authenticate' ); return header ? (header[1] as string) : 'Basic realm="Authorization Required"'; diff --git a/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts b/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts index af77360e0dd7e..82db336a257af 100644 --- a/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts +++ b/src/core/server/saved_objects/deprecations/unknown_object_types.test.ts @@ -8,7 +8,7 @@ import { getIndexForTypeMock } from './unknown_object_types.test.mocks'; -import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { deleteUnknownTypeObjects, getUnknownTypesDeprecations } from './unknown_object_types'; import { typeRegistryMock } from '../saved_objects_type_registry.mock'; import { elasticsearchClientMock } from '../../elasticsearch/client/mocks'; diff --git a/src/core/server/saved_objects/migrations/core/elastic_index.ts b/src/core/server/saved_objects/migrations/core/elastic_index.ts index f9572151084dc..632a86b76967f 100644 --- a/src/core/server/saved_objects/migrations/core/elastic_index.ts +++ b/src/core/server/saved_objects/migrations/core/elastic_index.ts @@ -323,6 +323,7 @@ export async function claimAlias( await client.indices.updateAliases({ body: { + // @ts-expect-error @elastic/elasticsearch IndicesUpdateAliasesRequest cannot be used actions: aliasActions.concat(removeActions).concat({ add: { index, alias } }), }, }); diff --git a/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts b/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts index 9353ede9be6ac..c809b406a39ee 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts @@ -8,7 +8,8 @@ import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; -import { errors as esErrors, estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { errors as esErrors } from '@elastic/elasticsearch'; import { ElasticsearchClient } from '../../../elasticsearch'; import type { SavedObjectsRawDoc } from '../../serialization'; import { diff --git a/src/core/server/saved_objects/migrationsv2/actions/catch_retryable_es_client_errors.ts b/src/core/server/saved_objects/migrationsv2/actions/catch_retryable_es_client_errors.ts index 3d9a51e3b1eba..168e3170d30bf 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/catch_retryable_es_client_errors.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/catch_retryable_es_client_errors.ts @@ -31,7 +31,7 @@ export const catchRetryableEsClientErrors = ( e instanceof EsErrors.ConnectionError || e instanceof EsErrors.TimeoutError || (e instanceof EsErrors.ResponseError && - (retryResponseStatuses.includes(e?.statusCode) || + (retryResponseStatuses.includes(e?.statusCode!) || // ES returns a 400 Bad Request when trying to close or delete an // index while snapshots are in progress. This should have been a 503 // so once https://github.com/elastic/elasticsearch/issues/65883 is diff --git a/src/core/server/saved_objects/migrationsv2/actions/remove_write_block.ts b/src/core/server/saved_objects/migrationsv2/actions/remove_write_block.ts index 77445654d3cc3..cca9ea5e7598e 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/remove_write_block.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/remove_write_block.ts @@ -41,10 +41,8 @@ export const removeWriteBlock = // Don't change any existing settings preserve_existing: true, body: { - settings: { - blocks: { - write: false, - }, + blocks: { + write: false, }, }, }, diff --git a/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts b/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts index cb5621bb2bf1a..9c40e1b64fae0 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/set_write_block.ts @@ -6,7 +6,6 @@ * Side Public License, v 1. */ -import type { ElasticsearchClientError } from '@elastic/elasticsearch'; import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; import { errors as EsErrors } from '@elastic/elasticsearch'; @@ -61,7 +60,7 @@ export const setWriteBlock = message: 'set_write_block_failed', }); }) - .catch((e: ElasticsearchClientError) => { + .catch((e: EsErrors.ElasticsearchClientError) => { if (e instanceof EsErrors.ResponseError) { if (e.body?.error?.type === 'index_not_found_exception') { return Either.left({ type: 'index_not_found_exception' as const, index }); diff --git a/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts b/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts index 5f1903f010a41..77ea71e9e6c19 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts @@ -52,6 +52,7 @@ export const updateAliases = .updateAliases( { body: { + // @ts-expect-error @elastic/elasticsearch IndicesUpdateAliasesRequest cannot be used actions: aliasActions, }, }, diff --git a/src/core/server/saved_objects/service/lib/decorate_es_error.ts b/src/core/server/saved_objects/service/lib/decorate_es_error.ts index 016268ccdf9f4..b7062c935815d 100644 --- a/src/core/server/saved_objects/service/lib/decorate_es_error.ts +++ b/src/core/server/saved_objects/service/lib/decorate_es_error.ts @@ -8,17 +8,17 @@ import { errors as esErrors } from '@elastic/elasticsearch'; import { get } from 'lodash'; -import { isSupportedEsServer } from '../../../elasticsearch'; +import { isSupportedEsServer, ElasticsearchErrorDetails } from '../../../elasticsearch'; const responseErrors = { - isServiceUnavailable: (statusCode: number) => statusCode === 503, - isConflict: (statusCode: number) => statusCode === 409, - isNotAuthorized: (statusCode: number) => statusCode === 401, - isForbidden: (statusCode: number) => statusCode === 403, - isRequestEntityTooLarge: (statusCode: number) => statusCode === 413, - isNotFound: (statusCode: number) => statusCode === 404, - isBadRequest: (statusCode: number) => statusCode === 400, - isTooManyRequests: (statusCode: number) => statusCode === 429, + isServiceUnavailable: (statusCode?: number) => statusCode === 503, + isConflict: (statusCode?: number) => statusCode === 409, + isNotAuthorized: (statusCode?: number) => statusCode === 401, + isForbidden: (statusCode?: number) => statusCode === 403, + isRequestEntityTooLarge: (statusCode?: number) => statusCode === 413, + isNotFound: (statusCode?: number) => statusCode === 404, + isBadRequest: (statusCode?: number) => statusCode === 400, + isTooManyRequests: (statusCode?: number) => statusCode === 429, }; const { ConnectionError, NoLivingConnectionsError, TimeoutError } = esErrors; const SCRIPT_CONTEXT_DISABLED_REGEX = /(?:cannot execute scripts using \[)([a-z]*)(?:\] context)/; @@ -64,10 +64,10 @@ export function decorateEsError(error: EsErrors) { } if (responseErrors.isNotFound(error.statusCode)) { - const match = error?.meta?.body?.error?.reason?.match( + const match = (error?.meta?.body as ElasticsearchErrorDetails)?.error?.reason?.match( /no such index \[(.+)\] and \[require_alias\] request flag is \[true\] and \[.+\] is not an alias/ ); - if (match?.length > 0) { + if (match && match.length > 0) { return SavedObjectsErrorHelpers.decorateIndexAliasNotFoundError(error, match[1]); } // Throw EsUnavailable error if the 404 is not from elasticsearch diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index d48aeb35d9ced..1eb5d16aec86f 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -1882,6 +1882,7 @@ export class SavedObjectsRepository { const { body, statusCode, headers } = await this.client.openPointInTime(esOptions, { ignore: [404], }); + if (statusCode === 404) { if (!isSupportedEsServer(headers)) { throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); diff --git a/src/core/server/saved_objects/service/lib/update_objects_spaces.ts b/src/core/server/saved_objects/service/lib/update_objects_spaces.ts index baa6525b1f33f..b54f72d4c23f0 100644 --- a/src/core/server/saved_objects/service/lib/update_objects_spaces.ts +++ b/src/core/server/saved_objects/service/lib/update_objects_spaces.ts @@ -259,7 +259,6 @@ export async function updateObjectsSpaces({ // @ts-expect-error BulkOperation.retry_on_conflict, BulkOperation.routing. BulkOperation.version, and BulkOperation.version_type are optional bulkOperationParams.push({ update: documentMetadata }, { doc: documentToSave }); } else { - // @ts-expect-error BulkOperation.retry_on_conflict, BulkOperation.routing. BulkOperation.version, and BulkOperation.version_type are optional bulkOperationParams.push({ delete: documentMetadata }); } } From 6ee98bd9ca37c791a5e6dcd77f01666d0589527b Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 12:26:01 +0200 Subject: [PATCH 019/172] update estype import path --- src/plugins/data/common/search/aggs/agg_configs.ts | 2 +- src/plugins/data/common/search/aggs/agg_type.ts | 2 +- .../common/search/aggs/buckets/_terms_other_bucket_helper.ts | 2 +- src/plugins/data/common/search/aggs/utils/time_splits.ts | 2 +- src/plugins/data/common/search/expressions/es_raw_response.ts | 2 +- .../data/common/search/search_source/inspect/inspector_stats.ts | 2 +- src/plugins/data/common/search/search_source/search_source.ts | 2 +- src/plugins/data/common/search/search_source/types.ts | 2 +- src/plugins/data/common/search/strategies/es_search/types.ts | 2 +- src/plugins/data/common/search/tabify/tabify_docs.test.ts | 2 +- src/plugins/data/common/search/tabify/tabify_docs.ts | 2 +- src/plugins/data/public/search/errors/types.ts | 2 +- .../ui/shard_failure_modal/__mocks__/shard_failure_response.ts | 2 +- .../data/public/ui/shard_failure_modal/shard_failure_modal.tsx | 2 +- .../ui/shard_failure_modal/shard_failure_open_modal_button.tsx | 2 +- .../data/public/ui/shard_failure_modal/shard_failure_types.ts | 2 +- src/plugins/data/server/autocomplete/terms_agg.test.ts | 2 +- src/plugins/data/server/autocomplete/terms_agg.ts | 2 +- src/plugins/data/server/autocomplete/terms_enum.ts | 2 +- src/plugins/data/server/search/strategies/eql_search/types.ts | 2 +- .../server/search/strategies/es_search/response_utils.test.ts | 2 +- .../data/server/search/strategies/es_search/response_utils.ts | 2 +- .../server/search/strategies/ese_search/ese_search_strategy.ts | 2 +- src/plugins/data/server/search/strategies/ese_search/types.ts | 2 +- src/plugins/data_views/common/data_views/data_view.ts | 2 +- src/plugins/data_views/common/types.ts | 2 +- .../fetcher/lib/field_capabilities/field_caps_response.ts | 2 +- .../public/application/apps/main/utils/fetch_chart.test.ts | 2 +- .../discover/public/application/doc_views/doc_views_types.ts | 2 +- .../discover/public/application/services/use_es_doc_search.ts | 2 +- src/plugins/discover/public/application/types.ts | 2 +- .../edit_index_pattern/scripted_fields_table/types.ts | 2 +- .../public/components/field_editor/field_editor.tsx | 2 +- .../public/scripting_languages/index.ts | 2 +- .../server/telemetry_collection/get_local_stats.test.ts | 2 +- .../telemetry/server/telemetry_collection/get_local_stats.ts | 2 +- .../telemetry/server/telemetry_collection/get_nodes_usage.ts | 2 +- src/plugins/vis_types/vega/public/data_model/es_query_parser.ts | 2 +- src/plugins/vis_types/vega/public/data_model/types.ts | 2 +- x-pack/plugins/actions/server/actions_client.ts | 2 +- .../server/cleanup_failed_executions/cleanup_tasks.test.ts | 2 +- .../actions/server/cleanup_failed_executions/lib/bulk_delete.ts | 2 +- .../lib/extract_bulk_response_delete_failures.ts | 2 +- .../server/authorization/alerting_authorization_kuery.ts | 2 +- x-pack/plugins/alerting/server/rules_client/rules_client.ts | 2 +- .../server/lib/apm_telemetry/collect_data_telemetry/tasks.ts | 2 +- .../helpers/create_es_client/create_internal_es_client/index.ts | 2 +- .../lib/search_strategies/queries/get_query_with_params.ts | 2 +- .../lib/search_strategies/queries/query_correlation.test.ts | 2 +- .../server/lib/search_strategies/queries/query_correlation.ts | 2 +- .../lib/search_strategies/queries/query_failure_correlation.ts | 2 +- .../search_strategies/queries/query_field_candidates.test.ts | 2 +- .../lib/search_strategies/queries/query_field_candidates.ts | 2 +- .../search_strategies/queries/query_field_value_pairs.test.ts | 2 +- .../lib/search_strategies/queries/query_field_value_pairs.ts | 2 +- .../lib/search_strategies/queries/query_fractions.test.ts | 2 +- .../apm/server/lib/search_strategies/queries/query_fractions.ts | 2 +- .../lib/search_strategies/queries/query_histogram.test.ts | 2 +- .../apm/server/lib/search_strategies/queries/query_histogram.ts | 2 +- .../queries/query_histogram_range_steps.test.ts | 2 +- .../search_strategies/queries/query_histogram_range_steps.ts | 2 +- .../queries/query_histograms_generator.test.ts | 2 +- .../lib/search_strategies/queries/query_histograms_generator.ts | 2 +- .../lib/search_strategies/queries/query_percentiles.test.ts | 2 +- .../server/lib/search_strategies/queries/query_percentiles.ts | 2 +- .../server/lib/search_strategies/queries/query_ranges.test.ts | 2 +- .../apm/server/lib/search_strategies/queries/query_ranges.ts | 2 +- .../lib/search_strategies/search_strategy_provider.test.ts | 2 +- .../search_strategies/utils/compute_expectations_and_ranges.ts | 2 +- .../plugins/apm/server/lib/service_map/get_service_anomalies.ts | 2 +- .../server/lib/settings/custom_link/create_custom_link_index.ts | 2 +- .../lib/transaction_groups/get_transaction_group_stats.ts | 2 +- x-pack/plugins/apm/server/projections/typings.ts | 2 +- x-pack/plugins/canvas/types/strategy.ts | 2 +- x-pack/plugins/cases/server/services/cases/index.ts | 2 +- x-pack/plugins/data_enhanced/server/collectors/fetch.ts | 2 +- x-pack/plugins/data_visualizer/common/types/indices.ts | 2 +- x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts | 2 +- x-pack/plugins/data_visualizer/common/utils/query_utils.ts | 2 +- .../plugins/data_visualizer/common/utils/runtime_field_utils.ts | 2 +- .../full_time_range_selector_service.ts | 2 +- .../index_data_visualizer/data_loader/data_loader.ts | 2 +- .../index_data_visualizer/services/time_field_range.ts | 2 +- .../index_data_visualizer/services/visualizer_stats.ts | 2 +- .../server/models/data_visualizer/check_fields_exist.ts | 2 +- .../server/models/data_visualizer/data_visualizer.ts | 2 +- .../server/models/data_visualizer/get_field_examples.ts | 2 +- .../server/models/data_visualizer/get_fields_stats.ts | 2 +- .../server/models/data_visualizer/get_histogram_for_fields.ts | 2 +- x-pack/plugins/data_visualizer/server/routes/routes.ts | 2 +- x-pack/plugins/event_log/server/es/cluster_client_adapter.ts | 2 +- x-pack/plugins/event_log/server/es/init.ts | 2 +- x-pack/plugins/file_upload/common/types.ts | 2 +- x-pack/plugins/file_upload/server/get_time_field_range.ts | 2 +- x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts | 2 +- x-pack/plugins/fleet/common/types/models/epm.ts | 2 +- x-pack/plugins/fleet/server/routes/data_streams/handlers.ts | 2 +- x-pack/plugins/fleet/server/services/agents/crud.ts | 2 +- x-pack/plugins/fleet/server/services/agents/helpers.ts | 2 +- .../routes/api/component_templates/register_update_route.ts | 2 +- .../server/routes/api/stats/register_stats_route.ts | 2 +- .../common/log_sources/resolved_log_source_configuration.ts | 2 +- .../infra/common/search_strategies/log_entries/log_entries.ts | 2 +- .../containers/logs/log_analysis/api/validate_datasets.ts | 2 +- .../public/containers/logs/log_analysis/api/validate_indices.ts | 2 +- .../containers/logs/log_analysis/log_analysis_module_types.ts | 2 +- .../modules/log_entry_categories/module_descriptor.ts | 2 +- .../log_entry_categories/use_log_entry_categories_module.tsx | 2 +- .../log_analysis/modules/log_entry_rate/module_descriptor.ts | 2 +- .../modules/log_entry_rate/use_log_entry_rate_module.tsx | 2 +- x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts | 2 +- .../infra/server/lib/adapters/framework/adapter_types.ts | 2 +- .../server/lib/adapters/framework/kibana_framework_adapter.ts | 2 +- .../lib/alerting/log_threshold/log_threshold_executor.test.ts | 2 +- .../server/lib/alerting/log_threshold/log_threshold_executor.ts | 2 +- .../server/lib/domains/log_entries_domain/log_entries_domain.ts | 2 +- .../domains/log_entries_domain/queries/log_entry_datasets.ts | 2 +- .../infra/server/lib/log_analysis/log_entry_anomalies.ts | 2 +- .../server/lib/log_analysis/log_entry_categories_analysis.ts | 2 +- .../lib/log_analysis/queries/log_entry_category_examples.ts | 2 +- .../infra/server/lib/log_analysis/queries/log_entry_examples.ts | 2 +- .../infra/server/routes/log_analysis/validation/datasets.ts | 2 +- .../infra/server/services/log_entries/queries/log_entries.ts | 2 +- .../infra/server/services/log_entries/queries/log_entry.ts | 2 +- .../ingest_pipelines/common/lib/pipeline_serialization.ts | 2 +- x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts | 2 +- x-pack/plugins/licensing/server/plugin.test.ts | 2 +- x-pack/plugins/licensing/server/plugin.ts | 2 +- x-pack/plugins/lists/server/schemas/common/get_shard.mock.ts | 2 +- .../schemas/elastic_response/search_es_list_item_schema.mock.ts | 2 +- .../schemas/elastic_response/search_es_list_schema.mock.ts | 2 +- .../plugins/lists/server/services/items/find_list_item.mock.ts | 2 +- .../lists/server/services/items/write_list_items_to_stream.ts | 2 +- .../server/services/utils/get_query_filter_from_type_value.ts | 2 +- .../server/services/utils/get_search_after_with_tie_breaker.ts | 2 +- .../lists/server/services/utils/get_sort_with_tie_breaker.ts | 2 +- .../utils/transform_elastic_named_search_to_list_item.ts | 2 +- .../lists/server/services/utils/transform_elastic_to_list.ts | 2 +- .../server/services/utils/transform_elastic_to_list_item.ts | 2 +- x-pack/plugins/logstash/server/models/cluster/cluster.test.ts | 2 +- x-pack/plugins/logstash/server/models/cluster/cluster.ts | 2 +- .../classes/sources/es_geo_grid_source/es_geo_grid_source.tsx | 2 +- .../plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts | 2 +- .../ml/common/types/anomaly_detection_jobs/datafeed_stats.ts | 2 +- x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts | 2 +- .../plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts | 2 +- .../ml/common/types/anomaly_detection_jobs/model_snapshot.ts | 2 +- x-pack/plugins/ml/common/types/data_frame_analytics.ts | 2 +- x-pack/plugins/ml/common/types/es_client.ts | 2 +- x-pack/plugins/ml/common/types/fields.ts | 2 +- x-pack/plugins/ml/common/types/results.ts | 2 +- x-pack/plugins/ml/common/util/job_utils.ts | 2 +- x-pack/plugins/ml/common/util/runtime_field_utils.ts | 2 +- .../ml/public/application/components/data_grid/common.ts | 2 +- .../plugins/ml/public/application/components/data_grid/types.ts | 2 +- .../new_job_awaiting_node_shared.tsx | 2 +- .../components/scatterplot_matrix/scatterplot_matrix.tsx | 2 +- .../application/data_frame_analytics/common/get_index_data.ts | 2 +- .../components/configuration_step/form_options_validation.ts | 2 +- .../components/configuration_step/use_saved_search.ts | 2 +- .../pages/analytics_creation/hooks/use_index_data.ts | 2 +- .../components/exploration_query_bar/exploration_query_bar.tsx | 2 +- .../jobs/new_job/common/job_creator/advanced_job_creator.ts | 2 +- .../advanced_detector_modal/advanced_detector_modal.tsx | 2 +- x-pack/plugins/ml/public/application/services/job_service.d.ts | 2 +- .../ml/public/application/services/ml_api_service/index.ts | 2 +- x-pack/plugins/ml/public/embeddables/common/process_filters.ts | 2 +- x-pack/plugins/ml/server/lib/ml_client/search.ts | 2 +- x-pack/plugins/ml/server/lib/query_utils.ts | 2 +- .../plugins/ml/server/models/annotation_service/annotation.ts | 2 +- .../calculate_model_memory_limit.ts | 2 +- x-pack/plugins/ml/server/models/calendar/calendar_manager.ts | 2 +- x-pack/plugins/ml/server/models/calendar/event_manager.ts | 2 +- .../plugins/ml/server/models/data_frame_analytics/validation.ts | 2 +- x-pack/plugins/ml/server/models/filter/filter_manager.ts | 2 +- .../ml/server/models/job_audit_messages/job_audit_messages.ts | 2 +- x-pack/plugins/ml/server/models/job_service/datafeeds.ts | 2 +- .../models/job_service/new_job/categorization/examples.ts | 2 +- .../models/job_service/new_job/categorization/top_categories.ts | 2 +- .../ml/server/models/job_service/new_job_caps/field_service.ts | 2 +- .../plugins/ml/server/models/job_service/new_job_caps/rollup.ts | 2 +- x-pack/plugins/ml/server/routes/anomaly_detectors.ts | 2 +- x-pack/plugins/ml/server/routes/datafeeds.ts | 2 +- x-pack/plugins/ml/server/routes/job_service.ts | 2 +- x-pack/plugins/ml/server/shared_services/providers/system.ts | 2 +- .../server/kibana_monitoring/collectors/lib/fetch_es_usage.ts | 2 +- .../kibana_monitoring/collectors/lib/fetch_license_type.ts | 2 +- .../collectors/lib/fetch_stack_product_usage.ts | 2 +- .../monitoring/server/lib/alerts/fetch_available_ccs.test.ts | 2 +- .../monitoring/server/lib/alerts/fetch_cluster_health.test.ts | 2 +- .../plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts | 2 +- .../server/lib/alerts/fetch_cpu_usage_node_stats.test.ts | 2 +- .../server/lib/alerts/fetch_elasticsearch_versions.test.ts | 2 +- .../plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts | 2 +- .../api/v1/elasticsearch_settings/check/internal_monitoring.ts | 2 +- x-pack/plugins/monitoring/server/static_globals.ts | 2 +- .../monitoring/server/telemetry_collection/get_beats_stats.ts | 2 +- .../monitoring/server/telemetry_collection/get_cluster_uuids.ts | 2 +- .../monitoring/server/telemetry_collection/get_es_stats.ts | 2 +- .../server/telemetry_collection/get_high_level_stats.ts | 2 +- .../server/telemetry_collection/get_kibana_stats.test.ts | 2 +- .../monitoring/server/telemetry_collection/get_kibana_stats.ts | 2 +- .../monitoring/server/telemetry_collection/get_licenses.ts | 2 +- .../server/telemetry_collection/get_logstash_stats.ts | 2 +- x-pack/plugins/observability/public/hooks/use_es_search.ts | 2 +- .../observability/server/utils/create_or_update_index.ts | 2 +- x-pack/plugins/observability/server/utils/queries.ts | 2 +- .../osquery/common/search_strategy/osquery/actions/index.ts | 2 +- x-pack/plugins/osquery/common/search_strategy/osquery/index.ts | 2 +- .../osquery/common/search_strategy/osquery/results/index.ts | 2 +- x-pack/plugins/osquery/public/agents/helpers.ts | 2 +- x-pack/plugins/osquery/public/agents/types.ts | 2 +- .../osquery/factory/actions/all/query.all_actions.dsl.ts | 2 +- .../export_types/csv_searchsource/generate_csv/generate_csv.ts | 2 +- x-pack/plugins/reporting/server/usage/get_reporting_usage.ts | 2 +- x-pack/plugins/rule_registry/common/mapping_from_field_map.ts | 2 +- x-pack/plugins/rule_registry/common/types.ts | 2 +- .../rule_registry/server/alert_data_client/alerts_client.ts | 2 +- .../server/rule_data_plugin_service/index_options.ts | 2 +- .../server/rule_data_plugin_service/resource_installer.ts | 2 +- .../common/endpoint/data_generators/fleet_agent_generator.ts | 2 +- .../search_strategy/security_solution/hosts/details/index.ts | 2 +- .../common/search_strategy/security_solution/index.ts | 2 +- .../common/components/exceptions/use_add_exception.test.tsx | 2 +- .../public/common/components/exceptions/use_add_exception.tsx | 2 +- .../public/detections/containers/detection_engine/alerts/api.ts | 2 +- .../detection_engine/alerts/use_fetch_ecs_alerts_data.ts | 2 +- .../public/hosts/components/authentications_table/mock.ts | 2 +- .../server/endpoint/routes/metadata/query_builders.ts | 2 +- .../server/endpoint/routes/metadata/support/test_support.ts | 2 +- .../server/endpoint/routes/policy/handlers.test.ts | 2 +- .../server/endpoint/routes/resolver/tree/queries/descendants.ts | 2 +- .../server/endpoint/services/metadata/metadata.ts | 2 +- .../lib/detection_engine/routes/index/create_index_route.ts | 2 +- .../rule_registry_log_client/rule_registry_log_client.ts | 2 +- .../server/lib/detection_engine/signals/build_events_query.ts | 2 +- .../lib/detection_engine/signals/bulk_create_ml_signals.ts | 2 +- .../lib/detection_engine/signals/filters/filter_events.ts | 2 +- .../signals/filters/filter_events_against_list.ts | 2 +- .../server/lib/detection_engine/signals/filters/types.ts | 2 +- .../lib/detection_engine/signals/search_after_bulk_create.ts | 2 +- .../lib/detection_engine/signals/signal_rule_alert_type.test.ts | 2 +- .../lib/detection_engine/signals/single_search_after.test.ts | 2 +- .../server/lib/detection_engine/signals/single_search_after.ts | 2 +- .../signals/threat_mapping/build_threat_mapping_filter.mock.ts | 2 +- .../detection_engine/signals/threat_mapping/get_threat_list.ts | 2 +- .../server/lib/detection_engine/signals/threat_mapping/types.ts | 2 +- .../server/lib/detection_engine/signals/types.ts | 2 +- .../server/lib/detection_engine/signals/utils.ts | 2 +- .../security_solution/server/lib/machine_learning/index.ts | 2 +- x-pack/plugins/security_solution/server/plugin.ts | 2 +- .../security_solution/factory/cti/event_enrichment/helpers.ts | 2 +- .../factory/hosts/authentications/dsl/query.dsl.ts | 2 +- .../factory/hosts/authentications/dsl/query_entities.dsl.ts | 2 +- .../factory/hosts/uncommon_processes/dsl/query.dsl.ts | 2 +- x-pack/plugins/snapshot_restore/server/routes/api/policy.ts | 2 +- x-pack/plugins/snapshot_restore/server/routes/api/restore.ts | 2 +- x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts | 2 +- .../stack_alerts/public/alert_types/es_query/expression.tsx | 2 +- .../stack_alerts/server/alert_types/es_query/action_context.ts | 2 +- .../stack_alerts/server/alert_types/es_query/alert_type.ts | 2 +- .../server/alert_types/geo_containment/es_query_builder.ts | 2 +- .../server/alert_types/geo_containment/geo_containment.ts | 2 +- .../task_manager/server/monitoring/workload_statistics.test.ts | 2 +- .../task_manager/server/monitoring/workload_statistics.ts | 2 +- .../server/queries/mark_available_tasks_as_claimed.ts | 2 +- x-pack/plugins/task_manager/server/queries/query_clauses.ts | 2 +- x-pack/plugins/task_manager/server/saved_objects/index.ts | 2 +- x-pack/plugins/task_manager/server/task_store.test.ts | 2 +- x-pack/plugins/task_manager/server/task_store.ts | 2 +- .../server/telemetry_collection/get_license.ts | 2 +- .../server/telemetry_collection/get_stats_with_xpack.test.ts | 2 +- x-pack/plugins/timelines/common/search_strategy/common/index.ts | 2 +- x-pack/plugins/timelines/public/container/use_update_alerts.ts | 2 +- x-pack/plugins/transform/common/api_schemas/type_guards.ts | 2 +- x-pack/plugins/transform/public/app/common/request.ts | 2 +- x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts | 2 +- x-pack/plugins/transform/public/app/hooks/use_api.ts | 2 +- x-pack/plugins/transform/public/app/hooks/use_index_data.ts | 2 +- .../common/filter_agg/components/filter_term_form.tsx | 2 +- x-pack/plugins/transform/server/routes/api/transforms.ts | 2 +- .../server/data/lib/time_series_query.test.ts | 2 +- .../triggers_actions_ui/server/data/lib/time_series_query.ts | 2 +- x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts | 2 +- x-pack/plugins/uptime/common/requests/get_certs_request_body.ts | 2 +- x-pack/plugins/uptime/common/utils/es_search.ts | 2 +- x-pack/plugins/uptime/server/lib/lib.ts | 2 +- .../uptime/server/lib/requests/get_last_successful_step.ts | 2 +- .../server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts | 2 +- .../watcher/server/routes/api/indices/register_get_route.ts | 2 +- .../watcher/server/routes/api/watches/register_delete_route.ts | 2 +- .../security_and_spaces/tests/alerting/alerts.ts | 2 +- .../security_and_spaces/tests/alerting/create.ts | 2 +- .../security_and_spaces/tests/alerting/enable.ts | 2 +- .../preconfigured_alert_history_connector.ts | 2 +- .../spaces_only/tests/actions/enqueue.ts | 2 +- .../spaces_only/tests/alerting/alerts_base.ts | 2 +- .../spaces_only/tests/alerting/create.ts | 2 +- .../spaces_only/tests/alerting/enable.ts | 2 +- .../spaces_only/tests/alerting/migrations.ts | 2 +- x-pack/test/api_integration/apis/ml/calendars/helpers.ts | 2 +- x-pack/test/api_integration/apis/security_solution/utils.ts | 2 +- x-pack/test/case_api_integration/common/lib/utils.ts | 2 +- .../security_and_spaces/tests/common/cases/find_cases.ts | 2 +- .../tests/common/sub_cases/find_sub_cases.ts | 2 +- .../basic/tests/open_close_signals.ts | 2 +- .../basic/tests/update_rac_alerts.ts | 2 +- .../security_and_spaces/tests/alerts/alerts_compatibility.ts | 2 +- .../security_and_spaces/tests/open_close_signals.ts | 2 +- x-pack/test/detection_engine_api_integration/utils.ts | 2 +- x-pack/test/functional/services/ml/api.ts | 2 +- x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts | 2 +- .../test_suites/task_manager/migrations.ts | 2 +- .../test_suites/task_manager/task_management.ts | 2 +- .../test/spaces_api_integration/common/suites/copy_to_space.ts | 2 +- 315 files changed, 315 insertions(+), 315 deletions(-) diff --git a/src/plugins/data/common/search/aggs/agg_configs.ts b/src/plugins/data/common/search/aggs/agg_configs.ts index cb9ac56b99cd9..d85614125bf31 100644 --- a/src/plugins/data/common/search/aggs/agg_configs.ts +++ b/src/plugins/data/common/search/aggs/agg_configs.ts @@ -11,7 +11,7 @@ import _, { cloneDeep } from 'lodash'; import { i18n } from '@kbn/i18n'; import { Assign } from '@kbn/utility-types'; import { isRangeFilter } from '@kbn/es-query'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IEsSearchResponse, diff --git a/src/plugins/data/common/search/aggs/agg_type.ts b/src/plugins/data/common/search/aggs/agg_type.ts index 48ce54bbd61bd..bbeb03d0dc191 100644 --- a/src/plugins/data/common/search/aggs/agg_type.ts +++ b/src/plugins/data/common/search/aggs/agg_type.ts @@ -13,7 +13,7 @@ import { ISearchSource } from 'src/plugins/data/public'; import { DatatableColumnType, SerializedFieldFormat } from 'src/plugins/expressions/common'; import type { RequestAdapter } from 'src/plugins/inspector/common'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { initParams } from './agg_params'; import { AggConfig } from './agg_config'; import { IAggConfigs } from './agg_configs'; diff --git a/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts b/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts index 436cc5614ac80..ef5066e84f985 100644 --- a/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts +++ b/src/plugins/data/common/search/aggs/buckets/_terms_other_bucket_helper.ts @@ -7,7 +7,7 @@ */ import { isNumber, keys, values, find, each, cloneDeep, flatten } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { buildExistsFilter, buildPhrasesFilter, buildQueryFromFilters } from '@kbn/es-query'; import { AggGroupNames } from '../agg_groups'; import { IAggConfigs } from '../agg_configs'; diff --git a/src/plugins/data/common/search/aggs/utils/time_splits.ts b/src/plugins/data/common/search/aggs/utils/time_splits.ts index 99ea9fcefc179..8a8fd12ce1996 100644 --- a/src/plugins/data/common/search/aggs/utils/time_splits.ts +++ b/src/plugins/data/common/search/aggs/utils/time_splits.ts @@ -8,7 +8,7 @@ import moment from 'moment'; import _, { isArray } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RangeFilter } from '@kbn/es-query'; import { AggGroupNames } from '../agg_groups'; diff --git a/src/plugins/data/common/search/expressions/es_raw_response.ts b/src/plugins/data/common/search/expressions/es_raw_response.ts index 2d12af017d88c..61d79939e8635 100644 --- a/src/plugins/data/common/search/expressions/es_raw_response.ts +++ b/src/plugins/data/common/search/expressions/es_raw_response.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ExpressionTypeDefinition } from '../../../../expressions/common'; const name = 'es_raw_response'; diff --git a/src/plugins/data/common/search/search_source/inspect/inspector_stats.ts b/src/plugins/data/common/search/search_source/inspect/inspector_stats.ts index e5a3acc23eee8..2eb116c59f3c9 100644 --- a/src/plugins/data/common/search/search_source/inspect/inspector_stats.ts +++ b/src/plugins/data/common/search/search_source/inspect/inspector_stats.ts @@ -14,7 +14,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ISearchSource } from 'src/plugins/data/public'; import type { RequestStatistics } from 'src/plugins/inspector/common'; diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index 7b4537043c31c..50752523403cf 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -71,7 +71,7 @@ import { tap, } from 'rxjs/operators'; import { defer, EMPTY, from, Observable } from 'rxjs'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { buildEsQuery, Filter } from '@kbn/es-query'; import { normalizeSortRequest } from './normalize_sort_request'; import { fieldWildcardFilter } from '../../../../kibana_utils/common'; diff --git a/src/plugins/data/common/search/search_source/types.ts b/src/plugins/data/common/search/search_source/types.ts index a19316c1c8418..c411e53abfcd2 100644 --- a/src/plugins/data/common/search/search_source/types.ts +++ b/src/plugins/data/common/search/search_source/types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IAggConfigs } from 'src/plugins/data/public'; import { Query } from '../..'; import { Filter } from '../../es_query'; diff --git a/src/plugins/data/common/search/strategies/es_search/types.ts b/src/plugins/data/common/search/strategies/es_search/types.ts index 05df661d466c8..73bf7961fea9b 100644 --- a/src/plugins/data/common/search/strategies/es_search/types.ts +++ b/src/plugins/data/common/search/strategies/es_search/types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../types'; diff --git a/src/plugins/data/common/search/tabify/tabify_docs.test.ts b/src/plugins/data/common/search/tabify/tabify_docs.test.ts index 1a3f7195b722e..53fc40ae112ea 100644 --- a/src/plugins/data/common/search/tabify/tabify_docs.test.ts +++ b/src/plugins/data/common/search/tabify/tabify_docs.test.ts @@ -8,7 +8,7 @@ import { tabifyDocs } from './tabify_docs'; import { IndexPattern } from '../..'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; describe('tabifyDocs', () => { const fieldFormats = { diff --git a/src/plugins/data/common/search/tabify/tabify_docs.ts b/src/plugins/data/common/search/tabify/tabify_docs.ts index 8e628e7741df5..3cfc4a54611bb 100644 --- a/src/plugins/data/common/search/tabify/tabify_docs.ts +++ b/src/plugins/data/common/search/tabify/tabify_docs.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isPlainObject } from 'lodash'; import { IndexPattern } from '../..'; import { Datatable, DatatableColumn, DatatableColumnType } from '../../../../expressions/common'; diff --git a/src/plugins/data/public/search/errors/types.ts b/src/plugins/data/public/search/errors/types.ts index 13c5d0c242ed0..d541e53be78f9 100644 --- a/src/plugins/data/public/search/errors/types.ts +++ b/src/plugins/data/public/search/errors/types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { KibanaServerError } from '../../../../kibana_utils/common'; export interface FailedShard { diff --git a/src/plugins/data/public/ui/shard_failure_modal/__mocks__/shard_failure_response.ts b/src/plugins/data/public/ui/shard_failure_modal/__mocks__/shard_failure_response.ts index e4a31995e47b6..50355a933ec5d 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/__mocks__/shard_failure_response.ts +++ b/src/plugins/data/public/ui/shard_failure_modal/__mocks__/shard_failure_response.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export const shardFailureResponse: estypes.SearchResponse = { _shards: { diff --git a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.tsx b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.tsx index 8e6ad4bc92c8f..e009af4250e6c 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.tsx +++ b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_modal.tsx @@ -21,7 +21,7 @@ import { EuiButtonEmpty, EuiCallOut, } from '@elastic/eui'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ShardFailureTable } from './shard_failure_table'; import { ShardFailureRequest } from './shard_failure_types'; diff --git a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.tsx b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.tsx index a230378d6c3d3..4ebdd64fede13 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.tsx +++ b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_open_modal_button.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, EuiTextAlign } from '@elastic/eui'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getOverlays } from '../../services'; import { toMountPoint } from '../../../../kibana_react/public'; diff --git a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_types.ts b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_types.ts index 83e4abf55d525..c6533f9f0a850 100644 --- a/src/plugins/data/public/ui/shard_failure_modal/shard_failure_types.ts +++ b/src/plugins/data/public/ui/shard_failure_modal/shard_failure_types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export interface ShardFailureRequest { docvalue_fields: string[]; _source: unknown; diff --git a/src/plugins/data/server/autocomplete/terms_agg.test.ts b/src/plugins/data/server/autocomplete/terms_agg.test.ts index 9176f345d4a05..025e7f5a015f0 100644 --- a/src/plugins/data/server/autocomplete/terms_agg.test.ts +++ b/src/plugins/data/server/autocomplete/terms_agg.test.ts @@ -12,7 +12,7 @@ import { ConfigSchema } from '../../config'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import type { TransportResult } from '@elastic/transport'; import { termsAggSuggestions } from './terms_agg'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { duration } from 'moment'; let savedObjectsClientMock: jest.Mocked; diff --git a/src/plugins/data/server/autocomplete/terms_agg.ts b/src/plugins/data/server/autocomplete/terms_agg.ts index 9b1f5d92889bc..0e396b1c51e8e 100644 --- a/src/plugins/data/server/autocomplete/terms_agg.ts +++ b/src/plugins/data/server/autocomplete/terms_agg.ts @@ -8,7 +8,7 @@ import { get, map } from 'lodash'; import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ConfigSchema } from '../../config'; import { IFieldType } from '../../common'; import { findIndexPatternById, getFieldByName } from '../data_views'; diff --git a/src/plugins/data/server/autocomplete/terms_enum.ts b/src/plugins/data/server/autocomplete/terms_enum.ts index 3d7f369233720..2fd3b78d804a4 100644 --- a/src/plugins/data/server/autocomplete/terms_enum.ts +++ b/src/plugins/data/server/autocomplete/terms_enum.ts @@ -7,7 +7,7 @@ */ import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IFieldType } from '../../common'; import { findIndexPatternById, getFieldByName } from '../data_views'; import { shimAbortSignal } from '../search'; diff --git a/src/plugins/data/server/search/strategies/eql_search/types.ts b/src/plugins/data/server/search/strategies/eql_search/types.ts index 4b3c19fda78ea..695490b668e38 100644 --- a/src/plugins/data/server/search/strategies/eql_search/types.ts +++ b/src/plugins/data/server/search/strategies/eql_search/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export interface EqlSearchResponse extends estypes.SearchResponse { id?: string; diff --git a/src/plugins/data/server/search/strategies/es_search/response_utils.test.ts b/src/plugins/data/server/search/strategies/es_search/response_utils.test.ts index fc35187429a98..043bfd2e518ff 100644 --- a/src/plugins/data/server/search/strategies/es_search/response_utils.test.ts +++ b/src/plugins/data/server/search/strategies/es_search/response_utils.test.ts @@ -7,7 +7,7 @@ */ import { getTotalLoaded, toKibanaSearchResponse, shimHitsTotal } from './response_utils'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; describe('response utils', () => { describe('getTotalLoaded', () => { diff --git a/src/plugins/data/server/search/strategies/es_search/response_utils.ts b/src/plugins/data/server/search/strategies/es_search/response_utils.ts index 0553c015fb2da..4773b6df3bbaf 100644 --- a/src/plugins/data/server/search/strategies/es_search/response_utils.ts +++ b/src/plugins/data/server/search/strategies/es_search/response_utils.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ISearchOptions } from '../../../../common'; /** diff --git a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts index 75a4ddf051418..0b7ed38378c61 100644 --- a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts @@ -9,7 +9,7 @@ import type { Observable } from 'rxjs'; import type { IScopedClusterClient, Logger, SharedGlobalConfig } from 'kibana/server'; import { catchError, first, tap } from 'rxjs/operators'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { from } from 'rxjs'; import type { ISearchStrategy, SearchStrategyDependencies } from '../../types'; import type { diff --git a/src/plugins/data/server/search/strategies/ese_search/types.ts b/src/plugins/data/server/search/strategies/ese_search/types.ts index 7f21aa3616e4e..4116aa4380339 100644 --- a/src/plugins/data/server/search/strategies/ese_search/types.ts +++ b/src/plugins/data/server/search/strategies/ese_search/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export interface AsyncSearchResponse { id?: string; diff --git a/src/plugins/data_views/common/data_views/data_view.ts b/src/plugins/data_views/common/data_views/data_view.ts index 00b96cda32ad7..9dc00eae0b122 100644 --- a/src/plugins/data_views/common/data_views/data_view.ts +++ b/src/plugins/data_views/common/data_views/data_view.ts @@ -10,7 +10,7 @@ import _, { each, reject } from 'lodash'; import { castEsToKbnFieldTypeName, ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FieldAttrs, FieldAttrSet, DataViewAttributes } from '..'; import type { RuntimeField } from '../types'; import { DuplicateField } from '../../../kibana_utils/common'; diff --git a/src/plugins/data_views/common/types.ts b/src/plugins/data_views/common/types.ts index 2b184bc1ef2a4..44369bcb3f845 100644 --- a/src/plugins/data_views/common/types.ts +++ b/src/plugins/data_views/common/types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { DataViewFieldBase, IFieldSubType, DataViewBase } from '@kbn/es-query'; import { ToastInputFields, ErrorToastOptions } from 'src/core/public/notifications'; // eslint-disable-next-line diff --git a/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts index 6dff343f9e00e..892c447e45389 100644 --- a/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts +++ b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts @@ -7,7 +7,7 @@ */ import { uniq } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { castEsToKbnFieldTypeName } from '@kbn/field-types'; import { shouldReadFieldFromDocValues } from './should_read_field_from_doc_values'; import { FieldDescriptor } from '../../../fetcher'; diff --git a/src/plugins/discover/public/application/apps/main/utils/fetch_chart.test.ts b/src/plugins/discover/public/application/apps/main/utils/fetch_chart.test.ts index 2c050a9391a86..2c9350b457779 100644 --- a/src/plugins/discover/public/application/apps/main/utils/fetch_chart.test.ts +++ b/src/plugins/discover/public/application/apps/main/utils/fetch_chart.test.ts @@ -14,7 +14,7 @@ import { ReduxLikeStateContainer } from '../../../../../../kibana_utils/common'; import { AppState } from '../services/discover_state'; import { discoverServiceMock } from '../../../../__mocks__/services'; import { calculateBounds, IKibanaSearchResponse } from '../../../../../../data/common'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; function getDataSubjects() { return { diff --git a/src/plugins/discover/public/application/doc_views/doc_views_types.ts b/src/plugins/discover/public/application/doc_views/doc_views_types.ts index 48bebec22b9b5..094f7b6d1ce9f 100644 --- a/src/plugins/discover/public/application/doc_views/doc_views_types.ts +++ b/src/plugins/discover/public/application/doc_views/doc_views_types.ts @@ -8,7 +8,7 @@ import { ComponentType } from 'react'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IndexPattern } from '../../../../data/public'; export type ElasticSearchHit = estypes.SearchHit; diff --git a/src/plugins/discover/public/application/services/use_es_doc_search.ts b/src/plugins/discover/public/application/services/use_es_doc_search.ts index a2f0cd6f8442b..5beff7616c4d0 100644 --- a/src/plugins/discover/public/application/services/use_es_doc_search.ts +++ b/src/plugins/discover/public/application/services/use_es_doc_search.ts @@ -7,7 +7,7 @@ */ import { useCallback, useEffect, useMemo, useState } from 'react'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IndexPattern } from '../../../../data/common'; import { DocProps } from '../apps/doc/components/doc'; import { ElasticRequestState } from '../apps/doc/types'; diff --git a/src/plugins/discover/public/application/types.ts b/src/plugins/discover/public/application/types.ts index a28c5bbc89aed..f04f3bf77c2f9 100644 --- a/src/plugins/discover/public/application/types.ts +++ b/src/plugins/discover/public/application/types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export enum FetchStatus { UNINITIALIZED = 'uninitialized', diff --git a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/types.ts b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/types.ts index 5c6adc824d225..a25c683c7aa1f 100644 --- a/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/types.ts +++ b/src/plugins/index_pattern_management/public/components/edit_index_pattern/scripted_fields_table/types.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; /** @internal **/ export interface ScriptedFieldItem { name: string; diff --git a/src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx b/src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx index bdc18938f9d6c..6a157a26a5657 100644 --- a/src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx +++ b/src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import React, { PureComponent, Fragment } from 'react'; import { intersection, union, get } from 'lodash'; diff --git a/src/plugins/index_pattern_management/public/scripting_languages/index.ts b/src/plugins/index_pattern_management/public/scripting_languages/index.ts index aeb38c8172be0..46bb0a359ae89 100644 --- a/src/plugins/index_pattern_management/public/scripting_languages/index.ts +++ b/src/plugins/index_pattern_management/public/scripting_languages/index.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import { HttpStart, NotificationsStart } from 'src/core/public'; diff --git a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts index 1a00d0e428016..191e857c777d2 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.test.ts @@ -7,7 +7,7 @@ */ import { merge, omit } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getLocalStats, handleLocalStats } from './get_local_stats'; import { diff --git a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts index 7860949e098aa..ae2a849ccfa19 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_local_stats.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { StatsGetter, StatsCollectionContext, diff --git a/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts b/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts index 0d58d80ed5965..a5d4f32b3a62f 100644 --- a/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts +++ b/src/plugins/telemetry/server/telemetry_collection/get_nodes_usage.ts @@ -7,7 +7,7 @@ */ import type { ElasticsearchClient } from 'src/core/server'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TIMEOUT } from './constants'; /** diff --git a/src/plugins/vis_types/vega/public/data_model/es_query_parser.ts b/src/plugins/vis_types/vega/public/data_model/es_query_parser.ts index 134e82d676763..cc769c3b5c12c 100644 --- a/src/plugins/vis_types/vega/public/data_model/es_query_parser.ts +++ b/src/plugins/vis_types/vega/public/data_model/es_query_parser.ts @@ -9,7 +9,7 @@ import moment from 'moment'; import { i18n } from '@kbn/i18n'; import { cloneDeep, isPlainObject } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Assign } from 'utility-types'; import { TimeCache } from './time_cache'; import { SearchAPI } from './search_api'; diff --git a/src/plugins/vis_types/vega/public/data_model/types.ts b/src/plugins/vis_types/vega/public/data_model/types.ts index d1568bba6c98c..19efe5a9a4b7d 100644 --- a/src/plugins/vis_types/vega/public/data_model/types.ts +++ b/src/plugins/vis_types/vega/public/data_model/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Assign } from '@kbn/utility-types'; import { Spec } from 'vega'; import { EsQueryParser } from './es_query_parser'; diff --git a/x-pack/plugins/actions/server/actions_client.ts b/x-pack/plugins/actions/server/actions_client.ts index b391e50283ad1..5a5c5b302fad1 100644 --- a/x-pack/plugins/actions/server/actions_client.ts +++ b/x-pack/plugins/actions/server/actions_client.ts @@ -6,7 +6,7 @@ */ import Boom from '@hapi/boom'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UsageCounter } from 'src/plugins/usage_collection/server'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts index b5e3297dda8f6..452f1829c9c36 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts @@ -10,7 +10,7 @@ import { loggingSystemMock, elasticsearchServiceMock } from '../../../../../src/ import { spacesMock } from '../../../spaces/server/mocks'; import { CleanupTasksOpts, cleanupTasks } from './cleanup_tasks'; import { TaskInstance } from '../../../task_manager/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TransportResult } from '@elastic/transport'; describe('cleanupTasks', () => { diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts index 9b49c6be1f426..67f0002a93600 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; export async function bulkDelete( diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts index 29025004e67e1..5ba75eecdd30b 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; type ResponseFailures = Array>; diff --git a/x-pack/plugins/alerting/server/authorization/alerting_authorization_kuery.ts b/x-pack/plugins/alerting/server/authorization/alerting_authorization_kuery.ts index 300634af84585..d718373446b60 100644 --- a/x-pack/plugins/alerting/server/authorization/alerting_authorization_kuery.ts +++ b/x-pack/plugins/alerting/server/authorization/alerting_authorization_kuery.ts @@ -8,7 +8,7 @@ import { remove } from 'lodash'; import { EsQueryConfig, nodeBuilder, toElasticsearchQuery, KueryNode } from '@kbn/es-query'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RegistryAlertTypeWithAuth } from './alerting_authorization'; export enum AlertingAuthorizationFilterType { diff --git a/x-pack/plugins/alerting/server/rules_client/rules_client.ts b/x-pack/plugins/alerting/server/rules_client/rules_client.ts index 231d19ce9a6f8..323102cdd0adf 100644 --- a/x-pack/plugins/alerting/server/rules_client/rules_client.ts +++ b/x-pack/plugins/alerting/server/rules_client/rules_client.ts @@ -9,7 +9,7 @@ import Semver from 'semver'; import Boom from '@hapi/boom'; import { omit, isEqual, map, uniq, pick, truncate, trim } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger, SavedObjectsClientContract, diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts index d624c8527df86..82b786cbd8fcf 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts @@ -5,7 +5,7 @@ * 2.0. */ import { flatten, merge, sortBy, sum, pickBy } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { asMutableArray } from '../../../../common/utils/as_mutable_array'; import { ProcessorEvent } from '../../../../common/processor_event'; import { TelemetryTask } from '.'; diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts index 3bcdaed145ac2..98c1731349d10 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts @@ -6,7 +6,7 @@ */ import { TransportRequestPromise } from '@elastic/transport'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { unwrapEsResponse } from '../../../../../../observability/server'; import { APMRouteHandlerResources } from '../../../../routes/typings'; import { diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/get_query_with_params.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/get_query_with_params.ts index f00c89503f103..bf18e86ff77e5 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/get_query_with_params.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/get_query_with_params.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getOrElse } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import * as t from 'io-ts'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.test.ts index fc2dacce61a73..bf1e388c746fc 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.ts index 24db25f8afd89..a150d23b27113 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_correlation.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_failure_correlation.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_failure_correlation.ts index 4e6d37932ed88..5bc697c9c299a 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_failure_correlation.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_failure_correlation.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from 'kibana/server'; import { SearchStrategyParams } from '../../../../common/search_strategies/types'; import { EVENT_OUTCOME } from '../../../../common/elasticsearch_fieldnames'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.test.ts index 6e0521ac1a008..145128f7dccff 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.ts index 390243295c4f0..292be1b5817aa 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_candidates.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.test.ts index 9ffbf6b2ce18d..fec55debdc1a5 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.ts index 296abfd2d8653..39d6aea2f38bd 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_field_value_pairs.ts @@ -7,7 +7,7 @@ import type { ElasticsearchClient } from 'src/core/server'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { FieldValuePair, diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.test.ts index daf6b368c78b1..639a21db1b91d 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.ts index ccea480052c9b..555465466498a 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_fractions.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SearchStrategyParams } from '../../../../common/search_strategies/types'; import { TRANSACTION_DURATION } from '../../../../common/elasticsearch_fieldnames'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.test.ts index 7ecb1d2d8a333..3fb46232cfc1e 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.ts index 5fb7ef76fc728..4e40834acccd1 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.test.ts index 25ce39cbcf17b..6bf5461f260bc 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.ts index 973787833577c..b07495c54d04b 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histogram_range_steps.ts @@ -7,7 +7,7 @@ import { scaleLog } from 'd3-scale'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.test.ts index 375e32b1472c6..e1dc0b0988dbe 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.ts index d526c63c7de34..500714ffdf0d5 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_histograms_generator.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.test.ts index ce86ffd9654e6..a832aca0fa577 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.ts index 70b5b70ce8912..4e1a7b2015614 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_percentiles.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.test.ts index e210eb7d41e78..b80c52fbd8fdd 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.ts index a530c997876c4..8b359c3665eaf 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/query_ranges.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/search_strategy_provider.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/search_strategy_provider.test.ts index 6e03c879f9b97..e4917e0c23f42 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/search_strategy_provider.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/search_strategy_provider.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SearchStrategyDependencies } from 'src/plugins/data/server'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/utils/compute_expectations_and_ranges.ts b/x-pack/plugins/apm/server/lib/search_strategies/utils/compute_expectations_and_ranges.ts index 9ab9689fd6d30..1754a35280f86 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/utils/compute_expectations_and_ranges.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/utils/compute_expectations_and_ranges.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { PERCENTILES_STEP } from '../constants'; export const computeExpectationsAndRanges = ( diff --git a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts b/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts index 97c95e4e40045..ef80395ae4bcd 100644 --- a/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts +++ b/x-pack/plugins/apm/server/lib/service_map/get_service_anomalies.ts @@ -7,7 +7,7 @@ import Boom from '@hapi/boom'; import { sortBy, uniqBy } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESSearchResponse } from '../../../../../../src/core/types/elasticsearch'; import { MlPluginSetup } from '../../../../ml/server'; import { PromiseReturnType } from '../../../../observability/typings/common'; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/create_custom_link_index.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/create_custom_link_index.ts index 085bb2b4be40d..752a7769caea0 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/create_custom_link_index.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/create_custom_link_index.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient, Logger } from 'src/core/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { createOrUpdateIndex, Mappings, diff --git a/x-pack/plugins/apm/server/lib/transaction_groups/get_transaction_group_stats.ts b/x-pack/plugins/apm/server/lib/transaction_groups/get_transaction_group_stats.ts index 980d8f10610c8..770c782414ca1 100644 --- a/x-pack/plugins/apm/server/lib/transaction_groups/get_transaction_group_stats.ts +++ b/x-pack/plugins/apm/server/lib/transaction_groups/get_transaction_group_stats.ts @@ -6,7 +6,7 @@ */ import { merge } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TRANSACTION_TYPE } from '../../../common/elasticsearch_fieldnames'; import { arrayUnionToCallable } from '../../../common/utils/array_union_to_callable'; import { TransactionGroupRequestBase, TransactionGroupSetup } from './fetcher'; diff --git a/x-pack/plugins/apm/server/projections/typings.ts b/x-pack/plugins/apm/server/projections/typings.ts index 0843fa4c9dd64..d252fd311b4fe 100644 --- a/x-pack/plugins/apm/server/projections/typings.ts +++ b/x-pack/plugins/apm/server/projections/typings.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AggregationOptionsByType } from '../../../../../src/core/types/elasticsearch'; import { APMEventESSearchRequest } from '../lib/helpers/create_es_client/create_apm_event_client'; diff --git a/x-pack/plugins/canvas/types/strategy.ts b/x-pack/plugins/canvas/types/strategy.ts index 1fa68ab151cfc..9f6488e275777 100644 --- a/x-pack/plugins/canvas/types/strategy.ts +++ b/x-pack/plugins/canvas/types/strategy.ts @@ -6,7 +6,7 @@ */ import { TransportResult } from '@elastic/transport'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IKibanaSearchRequest } from 'src/plugins/data/common'; import { ExpressionValueFilter } from '.'; export interface EssqlSearchStrategyRequest extends IKibanaSearchRequest { diff --git a/x-pack/plugins/cases/server/services/cases/index.ts b/x-pack/plugins/cases/server/services/cases/index.ts index 3c76be6d6dd93..4a22793f78af5 100644 --- a/x-pack/plugins/cases/server/services/cases/index.ts +++ b/x-pack/plugins/cases/server/services/cases/index.ts @@ -19,7 +19,7 @@ import { SavedObjectsResolveResponse, } from 'kibana/server'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { nodeBuilder, KueryNode } from '../../../../../../src/plugins/data/common'; import { SecurityPluginSetup } from '../../../../security/server'; diff --git a/x-pack/plugins/data_enhanced/server/collectors/fetch.ts b/x-pack/plugins/data_enhanced/server/collectors/fetch.ts index 27f72986dd537..c08a5d5ebb51d 100644 --- a/x-pack/plugins/data_enhanced/server/collectors/fetch.ts +++ b/x-pack/plugins/data_enhanced/server/collectors/fetch.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Observable } from 'rxjs'; import { first } from 'rxjs/operators'; import { SharedGlobalConfig, Logger } from 'kibana/server'; diff --git a/x-pack/plugins/data_visualizer/common/types/indices.ts b/x-pack/plugins/data_visualizer/common/types/indices.ts index c80b89b4e84c7..dd4bea8602720 100644 --- a/x-pack/plugins/data_visualizer/common/types/indices.ts +++ b/x-pack/plugins/data_visualizer/common/types/indices.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export interface IndicesOptions { allow_no_indices?: boolean; diff --git a/x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts b/x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts index bccd40ed43b0c..5a87d7b01db46 100644 --- a/x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts +++ b/x-pack/plugins/data_visualizer/common/utils/datafeed_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export type Datafeed = estypes.MlDatafeed; export type Aggregation = Record; diff --git a/x-pack/plugins/data_visualizer/common/utils/query_utils.ts b/x-pack/plugins/data_visualizer/common/utils/query_utils.ts index d2785072f419d..2aa4cd063d1b1 100644 --- a/x-pack/plugins/data_visualizer/common/utils/query_utils.ts +++ b/x-pack/plugins/data_visualizer/common/utils/query_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; /* * Contains utility functions for building and processing queries. */ diff --git a/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts index fbe4ae5c6faf1..a088685f03f54 100644 --- a/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts +++ b/x-pack/plugins/data_visualizer/common/utils/runtime_field_utils.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isPopulatedObject } from './object_utils'; import { RUNTIME_FIELD_TYPES } from '../../../../../src/plugins/data/common'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts index 198079c6ec9de..f2d14de9812ca 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/full_time_range_selector/full_time_range_selector_service.ts @@ -6,7 +6,7 @@ */ import moment from 'moment'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Query, TimefilterContract } from 'src/plugins/data/public'; import dateMath from '@elastic/datemath'; import { IndexPattern } from '../../../../../../../../src/plugins/data/public'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/data_loader/data_loader.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/data_loader/data_loader.ts index c4db51dcd81bc..e0a2852a57b29 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/data_loader/data_loader.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/data_loader/data_loader.ts @@ -7,7 +7,7 @@ // Maximum number of examples to obtain for text type fields. import { CoreSetup } from 'kibana/public'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import { IndexPattern } from '../../../../../../../src/plugins/data/common'; import { NON_AGGREGATABLE_FIELD_TYPES, OMIT_FIELDS } from '../../../../common/constants'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts index 87d4a3b7fb711..58a4bd4520829 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/time_field_range.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { lazyLoadModules } from '../../../lazy_load_bundle'; import { GetTimeFieldRangeResponse } from '../../../../common/types/time_field_request'; import { Query } from '../../../../../../../src/plugins/data/common/query'; diff --git a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts index 8db267a1dc837..3653936f3d12e 100644 --- a/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts +++ b/x-pack/plugins/data_visualizer/public/application/index_data_visualizer/services/visualizer_stats.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { lazyLoadModules } from '../../../lazy_load_bundle'; import type { DocumentCounts, FieldRequestConfig, FieldVisStats } from '../../../../common/types'; import { OverallStats } from '../types/overall_stats'; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts index ca7287394b8e3..83aa6235ba95f 100644 --- a/x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/check_fields_exist.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { get } from 'lodash'; import { IScopedClusterClient } from 'kibana/server'; import { AggCardinality, Aggs, FieldData } from '../../types'; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts index 155cf09ebb8db..dcd51a27dbb34 100644 --- a/x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/data_visualizer.ts @@ -7,7 +7,7 @@ import { IScopedClusterClient } from 'kibana/server'; import { each, last } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { JOB_FIELD_TYPES } from '../../../common'; import type { BatchStats, diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts index 69476e254068f..78adfb9e81b95 100644 --- a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_field_examples.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { get } from 'lodash'; import { IScopedClusterClient } from 'kibana/server'; import { buildBaseFilterCriteria } from '../../../common/utils/query_utils'; diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts index 6968aa97ab938..da93719e9ed93 100644 --- a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_fields_stats.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { each, find, get } from 'lodash'; import { IScopedClusterClient } from 'kibana/server'; import { diff --git a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts index 6621c793c0017..1cbf40a22b056 100644 --- a/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts +++ b/x-pack/plugins/data_visualizer/server/models/data_visualizer/get_histogram_for_fields.ts @@ -6,7 +6,7 @@ */ import { IScopedClusterClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { get } from 'lodash'; import { ChartData, ChartRequestAgg, HistogramField, NumericColumnStatsMap } from '../../types'; import { KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/common'; diff --git a/x-pack/plugins/data_visualizer/server/routes/routes.ts b/x-pack/plugins/data_visualizer/server/routes/routes.ts index 13a0031a25dfd..347ff08f72e33 100644 --- a/x-pack/plugins/data_visualizer/server/routes/routes.ts +++ b/x-pack/plugins/data_visualizer/server/routes/routes.ts @@ -6,7 +6,7 @@ */ import type { CoreSetup, IScopedClusterClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { dataVisualizerFieldHistogramsSchema, dataVisualizerFieldStatsSchema, diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts index 7eb3328dddb6b..8d7c1e637bb1e 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts @@ -11,7 +11,7 @@ import { reject, isUndefined, isNumber, pick } from 'lodash'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { Logger, ElasticsearchClient } from 'src/core/server'; import util from 'util'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query'; import { IEvent, IValidatedEvent, SAVED_OBJECT_REL_PRIMARY } from '../types'; import { FindOptionsType } from '../event_log_client'; diff --git a/x-pack/plugins/event_log/server/es/init.ts b/x-pack/plugins/event_log/server/es/init.ts index da603deb476d4..7641404c484ce 100644 --- a/x-pack/plugins/event_log/server/es/init.ts +++ b/x-pack/plugins/event_log/server/es/init.ts @@ -9,7 +9,7 @@ import { IndicesAlias, IndicesIndexStatePrefixedSettings, } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { asyncForEach } from '@kbn/std'; import { getIlmPolicy, getIndexTemplate } from './documents'; import { EsContext } from './context'; diff --git a/x-pack/plugins/file_upload/common/types.ts b/x-pack/plugins/file_upload/common/types.ts index 8462f8983a67d..6e72b749bdb61 100644 --- a/x-pack/plugins/file_upload/common/types.ts +++ b/x-pack/plugins/file_upload/common/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ES_FIELD_TYPES } from 'src/plugins/data/common'; export interface InputOverrides { diff --git a/x-pack/plugins/file_upload/server/get_time_field_range.ts b/x-pack/plugins/file_upload/server/get_time_field_range.ts index 0e8358f1671d0..1c8e94d5fc301 100644 --- a/x-pack/plugins/file_upload/server/get_time_field_range.ts +++ b/x-pack/plugins/file_upload/server/get_time_field_range.ts @@ -5,7 +5,7 @@ * 2.0. */ import { IScopedClusterClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isPopulatedObject } from './utils/runtime_field_utils'; export async function getTimeFieldRange( diff --git a/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts index aba6effe175c0..09a473b611ac9 100644 --- a/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts +++ b/x-pack/plugins/file_upload/server/utils/runtime_field_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RUNTIME_FIELD_TYPES } from '../../../../../src/plugins/data/common'; type RuntimeType = typeof RUNTIME_FIELD_TYPES[number]; diff --git a/x-pack/plugins/fleet/common/types/models/epm.ts b/x-pack/plugins/fleet/common/types/models/epm.ts index 06e3d13c2394b..2fafcc1d1185e 100644 --- a/x-pack/plugins/fleet/common/types/models/epm.ts +++ b/x-pack/plugins/fleet/common/types/models/epm.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // Follow pattern from https://github.com/elastic/kibana/pull/52447 // TODO: Update when https://github.com/elastic/kibana/issues/53021 is closed import type { SavedObject, SavedObjectAttributes, SavedObjectReference } from 'src/core/public'; diff --git a/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts b/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts index 073ff7806d9fe..e92ca3db97211 100644 --- a/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { keyBy, keys, merge } from 'lodash'; import type { RequestHandler, SavedObjectsBulkGetObject } from 'src/core/server'; diff --git a/x-pack/plugins/fleet/server/services/agents/crud.ts b/x-pack/plugins/fleet/server/services/agents/crud.ts index 03647c52e05f0..f89517d83a0f1 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud.ts @@ -6,7 +6,7 @@ */ import Boom from '@hapi/boom'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; import type { KueryNode } from '@kbn/es-query'; diff --git a/x-pack/plugins/fleet/server/services/agents/helpers.ts b/x-pack/plugins/fleet/server/services/agents/helpers.ts index 195b2567c24ae..609d5ba6c83a0 100644 --- a/x-pack/plugins/fleet/server/services/agents/helpers.ts +++ b/x-pack/plugins/fleet/server/services/agents/helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SearchHit } from '../../../../../../src/core/types/elasticsearch'; import type { Agent, AgentSOAttributes, FleetServerAgent } from '../../types'; diff --git a/x-pack/plugins/index_management/server/routes/api/component_templates/register_update_route.ts b/x-pack/plugins/index_management/server/routes/api/component_templates/register_update_route.ts index 464d73790af2a..c2235b9eb85ab 100644 --- a/x-pack/plugins/index_management/server/routes/api/component_templates/register_update_route.ts +++ b/x-pack/plugins/index_management/server/routes/api/component_templates/register_update_route.ts @@ -6,7 +6,7 @@ */ import { schema } from '@kbn/config-schema'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RouteDependencies } from '../../../types'; import { addBasePath } from '../index'; diff --git a/x-pack/plugins/index_management/server/routes/api/stats/register_stats_route.ts b/x-pack/plugins/index_management/server/routes/api/stats/register_stats_route.ts index 7458b98f5092f..3335913b81071 100644 --- a/x-pack/plugins/index_management/server/routes/api/stats/register_stats_route.ts +++ b/x-pack/plugins/index_management/server/routes/api/stats/register_stats_route.ts @@ -6,7 +6,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RouteDependencies } from '../../../types'; import { addBasePath } from '../index'; diff --git a/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts b/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts index 9c41a216c7f92..e996e2092d7c2 100644 --- a/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts +++ b/x-pack/plugins/infra/common/log_sources/resolved_log_source_configuration.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IndexPattern, IndexPatternsContract } from '../../../../../src/plugins/data/common'; import { ObjectEntries } from '../utility_types'; import { ResolveLogSourceConfigurationError } from './errors'; diff --git a/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts b/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts index cc6d3fbe585e0..4e115cda6a8e6 100644 --- a/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts +++ b/x-pack/plugins/infra/common/search_strategies/log_entries/log_entries.ts @@ -6,7 +6,7 @@ */ import * as rt from 'io-ts'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { logSourceColumnConfigurationRT } from '../../log_sources/log_source_configuration'; import { logEntryAfterCursorRT, diff --git a/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_datasets.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_datasets.ts index 9de6e574ecb5b..94bb3d8e66cbf 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_datasets.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_datasets.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { HttpHandler } from 'src/core/public'; import { LOG_ANALYSIS_VALIDATE_DATASETS_PATH, diff --git a/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts index a211fecc807fa..8a9f960b54afa 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/api/validate_indices.ts @@ -6,7 +6,7 @@ */ import type { HttpHandler } from 'src/core/public'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { LOG_ANALYSIS_VALIDATE_INDICES_PATH, diff --git a/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts index 4ae99b95cfff8..4ff8c0c3c08e0 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/log_analysis_module_types.ts @@ -6,7 +6,7 @@ */ import type { HttpHandler } from 'src/core/public'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ValidateLogEntryDatasetsResponsePayload, ValidationIndicesResponsePayload, diff --git a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/module_descriptor.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/module_descriptor.ts index 6823ed173a740..9ef41042302a1 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/module_descriptor.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/module_descriptor.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import type { HttpHandler } from 'src/core/public'; import { diff --git a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/use_log_entry_categories_module.tsx b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/use_log_entry_categories_module.tsx index 99d4ab4becee5..433a24cffd937 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/use_log_entry_categories_module.tsx +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_categories/use_log_entry_categories_module.tsx @@ -6,7 +6,7 @@ */ import createContainer from 'constate'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { useMemo } from 'react'; import { useLogAnalysisModule } from '../../log_analysis_module'; import { useLogAnalysisModuleConfiguration } from '../../log_analysis_module_configuration'; diff --git a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/module_descriptor.ts b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/module_descriptor.ts index c4c939d0ebb9d..214faaf9a3012 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/module_descriptor.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/module_descriptor.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { HttpHandler } from 'src/core/public'; import { bucketSpan, diff --git a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/use_log_entry_rate_module.tsx b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/use_log_entry_rate_module.tsx index f3e8f7e777597..46587969ca2ab 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/use_log_entry_rate_module.tsx +++ b/x-pack/plugins/infra/public/containers/logs/log_analysis/modules/log_entry_rate/use_log_entry_rate_module.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import createContainer from 'constate'; import { useMemo } from 'react'; import { ModuleSourceConfiguration } from '../../log_analysis_module_types'; diff --git a/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts b/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts index 67db6a4721941..cc9b71aed5a32 100644 --- a/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts +++ b/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts @@ -6,7 +6,7 @@ */ import { encode } from 'rison-node'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FetchData, FetchDataParams, LogsFetchDataResponse } from '../../../observability/public'; import { DEFAULT_SOURCE_ID } from '../../common/constants'; import { callFetchLogSourceConfigurationAPI } from '../containers/logs/log_source/api/fetch_log_source_configuration'; diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts index 4d4a0ff6320bd..00c52dae7ed3c 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Lifecycle } from '@hapi/hapi'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { JsonArray, JsonValue } from '@kbn/utility-types'; diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index 5af341e2d77c5..44f95976d8ad0 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -11,7 +11,7 @@ import { MlGetBuckets, } from '@elastic/elasticsearch/api/requestParams'; import { TransportRequestParams } from '@elastic/transport'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; import { InfraRouteConfig, diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.test.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.test.ts index 1f0521070a1e5..e5d8bab948581 100644 --- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.test.ts +++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.test.ts @@ -24,7 +24,7 @@ import { GroupedSearchQueryResponse, } from '../../../../common/alerting/logs/log_threshold/types'; import { alertsMock } from '../../../../../alerting/server/mocks'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // Mocks // const numericField = { diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts index f99f7a96158c3..6d2b074c45bb0 100644 --- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts +++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_executor.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import { ALERT_EVALUATION_THRESHOLD, diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts index 16209e5e4b684..e7b1624206515 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { JsonObject } from '@kbn/utility-types'; import type { InfraPluginRequestHandlerContext } from '../../../types'; diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts index 3431f3bfb0c8c..27ce2f3dd647e 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts @@ -6,7 +6,7 @@ */ import * as rt from 'io-ts'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { commonSearchSuccessResponseFieldsRT } from '../../../../utils/elasticsearch_runtime_types'; diff --git a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts index 3210f01116f76..aca0483037912 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { InfraPluginRequestHandlerContext, InfraRequestHandlerContext } from '../../types'; import { TracingSpan, startTracingSpan } from '../../../common/performance_tracing'; import { fetchMlJob, getLogEntryDatasets } from './common'; diff --git a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts index 7023f7007763c..d1d136c741876 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'src/core/server'; import { compareDatasetsByMaximumAnomalyScore, diff --git a/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_category_examples.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_category_examples.ts index 8b05d7c44e3f5..dd68de4e49d34 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_category_examples.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_category_examples.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as rt from 'io-ts'; import { commonSearchSuccessResponseFieldsRT } from '../../../utils/elasticsearch_runtime_types'; import { defaultRequestParameters } from './common'; diff --git a/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_examples.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_examples.ts index d903225facd57..d6099404daa80 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_examples.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/queries/log_entry_examples.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as rt from 'io-ts'; import { partitionField } from '../../../../common/log_analysis'; import { commonSearchSuccessResponseFieldsRT } from '../../../utils/elasticsearch_runtime_types'; diff --git a/x-pack/plugins/infra/server/routes/log_analysis/validation/datasets.ts b/x-pack/plugins/infra/server/routes/log_analysis/validation/datasets.ts index ef789c1b41349..4237ee2ae9abc 100644 --- a/x-pack/plugins/infra/server/routes/log_analysis/validation/datasets.ts +++ b/x-pack/plugins/infra/server/routes/log_analysis/validation/datasets.ts @@ -6,7 +6,7 @@ */ import Boom from '@hapi/boom'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { InfraBackendLibs } from '../../../lib/infra_types'; import { diff --git a/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts b/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts index 9022195dce85d..762efda1c6c1d 100644 --- a/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts +++ b/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as rt from 'io-ts'; import { LogEntryAfterCursor, diff --git a/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts b/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts index 8da2f1d685db3..8895a6e03f0c5 100644 --- a/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts +++ b/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as rt from 'io-ts'; import { jsonArrayRT } from '../../../../common/typed_json'; import { diff --git a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts index d2669e7c0012b..248797c652c6a 100644 --- a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts +++ b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Pipeline, Processor } from '../types'; export function deserializePipelines(pipelinesByName: { diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts index c133b9237102a..52fcd398758cb 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import { API_BASE_PATH } from '../../../common/constants'; diff --git a/x-pack/plugins/licensing/server/plugin.test.ts b/x-pack/plugins/licensing/server/plugin.test.ts index 1fe4bbf238e19..5857596e13c14 100644 --- a/x-pack/plugins/licensing/server/plugin.test.ts +++ b/x-pack/plugins/licensing/server/plugin.test.ts @@ -6,7 +6,7 @@ */ import { take, toArray } from 'rxjs/operators'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import moment from 'moment'; import { LicenseType } from '../common/types'; import { ElasticsearchError } from './types'; diff --git a/x-pack/plugins/licensing/server/plugin.ts b/x-pack/plugins/licensing/server/plugin.ts index 00d2ae602fcae..83379fe48ac9e 100644 --- a/x-pack/plugins/licensing/server/plugin.ts +++ b/x-pack/plugins/licensing/server/plugin.ts @@ -10,7 +10,7 @@ import moment from 'moment'; import { createHash } from 'crypto'; import stringify from 'json-stable-stringify'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { MaybePromise } from '@kbn/utility-types'; import { isPromise } from '@kbn/std'; import { diff --git a/x-pack/plugins/lists/server/schemas/common/get_shard.mock.ts b/x-pack/plugins/lists/server/schemas/common/get_shard.mock.ts index 43511a748ba1a..e7a887d6ca354 100644 --- a/x-pack/plugins/lists/server/schemas/common/get_shard.mock.ts +++ b/x-pack/plugins/lists/server/schemas/common/get_shard.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export const getShardMock = (): estypes.ShardStatistics => ({ failed: 0, diff --git a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.mock.ts b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.mock.ts index 2f213ccfbad06..682c77cf5c83b 100644 --- a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DATE_NOW, diff --git a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.mock.ts b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.mock.ts index 2cfbaf26f9d6a..5dde9cc14d4a1 100644 --- a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.mock.ts +++ b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DATE_NOW, diff --git a/x-pack/plugins/lists/server/services/items/find_list_item.mock.ts b/x-pack/plugins/lists/server/services/items/find_list_item.mock.ts index 1c1ce872a402d..99c2f18877032 100644 --- a/x-pack/plugins/lists/server/services/items/find_list_item.mock.ts +++ b/x-pack/plugins/lists/server/services/items/find_list_item.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; diff --git a/x-pack/plugins/lists/server/services/items/write_list_items_to_stream.ts b/x-pack/plugins/lists/server/services/items/write_list_items_to_stream.ts index 1bf337dbd7532..565e8a3e196c5 100644 --- a/x-pack/plugins/lists/server/services/items/write_list_items_to_stream.ts +++ b/x-pack/plugins/lists/server/services/items/write_list_items_to_stream.ts @@ -7,7 +7,7 @@ import { PassThrough } from 'stream'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from 'kibana/server'; import { ErrorWithStatusCode } from '../../error_with_status_code'; diff --git a/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts b/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts index db667951381b0..8d0d2501475e6 100644 --- a/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts +++ b/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isEmpty, isObject } from 'lodash/fp'; import type { Type } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts b/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts index 7db46ce1a464c..37794228bd693 100644 --- a/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts +++ b/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SortFieldOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; export type TieBreaker = T & { diff --git a/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts b/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts index 8a513483f5b5e..e8fae957a5615 100644 --- a/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts +++ b/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SortFieldOrUndefined, SortOrderOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; export const getSortWithTieBreaker = ({ diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts index b669b983fe46d..0a3632efe9195 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SearchListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; import { SearchEsListItemSchema } from '../../schemas/elastic_response'; diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts index 5b0949d7b79b7..3242742c1cfd6 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ListArraySchema } from '@kbn/securitysolution-io-ts-list-types'; import { encodeHitVersion } from '@kbn/securitysolution-es-utils'; diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts index 65392f8c379d9..3edbab94a0cfd 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; import { encodeHitVersion } from '@kbn/securitysolution-es-utils'; diff --git a/x-pack/plugins/logstash/server/models/cluster/cluster.test.ts b/x-pack/plugins/logstash/server/models/cluster/cluster.test.ts index 10c1d1ba24ae0..9fe03cd411b81 100755 --- a/x-pack/plugins/logstash/server/models/cluster/cluster.test.ts +++ b/x-pack/plugins/logstash/server/models/cluster/cluster.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Cluster } from './cluster'; describe('cluster', () => { diff --git a/x-pack/plugins/logstash/server/models/cluster/cluster.ts b/x-pack/plugins/logstash/server/models/cluster/cluster.ts index 2982284879c47..6c1712eb4797e 100755 --- a/x-pack/plugins/logstash/server/models/cluster/cluster.ts +++ b/x-pack/plugins/logstash/server/models/cluster/cluster.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; /** * This model deals with a cluster object from ES and converts it to Kibana downstream diff --git a/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/es_geo_grid_source.tsx b/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/es_geo_grid_source.tsx index 8a02066343914..10aabc9a0602c 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/es_geo_grid_source.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/es_geo_grid_source.tsx @@ -10,7 +10,7 @@ import React, { ReactElement } from 'react'; import { i18n } from '@kbn/i18n'; import rison from 'rison-node'; import { Feature } from 'geojson'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { convertCompositeRespToGeoJson, convertRegularRespToGeoJson, diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts index e1a3f6044587b..ef38504c869fb 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export type DatafeedId = string; diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts index 4e23d97c0d145..3c7f8c51785d1 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/datafeed_stats.ts @@ -5,6 +5,6 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export type DatafeedStats = estypes.MlDatafeedStats; diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts index dcf18b98e00a0..0e32f4e7a065b 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export type JobId = string; export type BucketSpan = string; diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts index 5fc8b423a5ac2..995bd1e6a14fc 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/job_stats.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export type JobStats = estypes.MlJobStats; diff --git a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/model_snapshot.ts b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/model_snapshot.ts index 0bb2162994c37..806aca3eb43ad 100644 --- a/x-pack/plugins/ml/common/types/anomaly_detection_jobs/model_snapshot.ts +++ b/x-pack/plugins/ml/common/types/anomaly_detection_jobs/model_snapshot.ts @@ -5,6 +5,6 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export type ModelSnapshot = estypes.MlModelSnapshot; diff --git a/x-pack/plugins/ml/common/types/data_frame_analytics.ts b/x-pack/plugins/ml/common/types/data_frame_analytics.ts index 1d2a75069dfe6..92c0c1d06ef93 100644 --- a/x-pack/plugins/ml/common/types/data_frame_analytics.ts +++ b/x-pack/plugins/ml/common/types/data_frame_analytics.ts @@ -6,7 +6,7 @@ */ import Boom from '@hapi/boom'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { RuntimeMappings } from './fields'; import { EsErrorBody } from '../util/errors'; diff --git a/x-pack/plugins/ml/common/types/es_client.ts b/x-pack/plugins/ml/common/types/es_client.ts index 466075284515e..2a6a1d4c1ffab 100644 --- a/x-pack/plugins/ml/common/types/es_client.ts +++ b/x-pack/plugins/ml/common/types/es_client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isPopulatedObject } from '../util/object_utils'; export function isMultiBucketAggregate( diff --git a/x-pack/plugins/ml/common/types/fields.ts b/x-pack/plugins/ml/common/types/fields.ts index 33a4a94e539b8..bf7876570f485 100644 --- a/x-pack/plugins/ml/common/types/fields.ts +++ b/x-pack/plugins/ml/common/types/fields.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ES_FIELD_TYPES } from '../../../../../src/plugins/data/common'; import { ML_JOB_AGGREGATION, diff --git a/x-pack/plugins/ml/common/types/results.ts b/x-pack/plugins/ml/common/types/results.ts index 74d3286438588..f840f9ad58c01 100644 --- a/x-pack/plugins/ml/common/types/results.ts +++ b/x-pack/plugins/ml/common/types/results.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { LineAnnotationDatum, RectAnnotationDatum } from '@elastic/charts'; export interface GetStoppedPartitionResult { diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index 6d069cd4383ea..e66d8de5bd15e 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -8,7 +8,7 @@ import { each, isEmpty, isEqual, pick } from 'lodash'; import semverGte from 'semver/functions/gte'; import moment, { Duration } from 'moment'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // @ts-ignore import numeral from '@elastic/numeral'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/plugins/ml/common/util/runtime_field_utils.ts b/x-pack/plugins/ml/common/util/runtime_field_utils.ts index 1fcf8e2e72b15..edda547d363e4 100644 --- a/x-pack/plugins/ml/common/util/runtime_field_utils.ts +++ b/x-pack/plugins/ml/common/util/runtime_field_utils.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isPopulatedObject } from './object_utils'; import { RUNTIME_FIELD_TYPES } from '../../../../../src/plugins/data/common'; import type { RuntimeMappings } from '../types/fields'; diff --git a/x-pack/plugins/ml/public/application/components/data_grid/common.ts b/x-pack/plugins/ml/public/application/components/data_grid/common.ts index a64594e86a757..c1b2cfa6b3de0 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/common.ts +++ b/x-pack/plugins/ml/public/application/components/data_grid/common.ts @@ -6,7 +6,7 @@ */ import moment from 'moment-timezone'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { useEffect, useMemo } from 'react'; import { diff --git a/x-pack/plugins/ml/public/application/components/data_grid/types.ts b/x-pack/plugins/ml/public/application/components/data_grid/types.ts index 47684ee307e99..01c135000fb0e 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/types.ts +++ b/x-pack/plugins/ml/public/application/components/data_grid/types.ts @@ -7,7 +7,7 @@ import { Dispatch, SetStateAction } from 'react'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiDataGridCellValueElementProps, EuiDataGridPaginationProps, diff --git a/x-pack/plugins/ml/public/application/components/jobs_awaiting_node_warning/new_job_awaiting_node_shared/new_job_awaiting_node_shared.tsx b/x-pack/plugins/ml/public/application/components/jobs_awaiting_node_warning/new_job_awaiting_node_shared/new_job_awaiting_node_shared.tsx index 5850349ff5fd6..d4ce935cc085f 100644 --- a/x-pack/plugins/ml/public/application/components/jobs_awaiting_node_warning/new_job_awaiting_node_shared/new_job_awaiting_node_shared.tsx +++ b/x-pack/plugins/ml/public/application/components/jobs_awaiting_node_warning/new_job_awaiting_node_shared/new_job_awaiting_node_shared.tsx @@ -6,7 +6,7 @@ */ import React, { FC, useState, useEffect, useCallback, useMemo } from 'react'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiCallOut, EuiSpacer, EuiLink } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; diff --git a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx index b83965b52befc..7c50d344f4049 100644 --- a/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx +++ b/x-pack/plugins/ml/public/application/components/scatterplot_matrix/scatterplot_matrix.tsx @@ -7,7 +7,7 @@ import React, { useMemo, useEffect, useState, FC } from 'react'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiCallOut, diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/common/get_index_data.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/common/get_index_data.ts index 920f56b376747..eda63ec4285ea 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/common/get_index_data.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/common/get_index_data.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { extractErrorMessage } from '../../../../common/util/errors'; import { EsSorting, UseDataGridReturnType, getProcessedFields } from '../../components/data_grid'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/form_options_validation.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/form_options_validation.ts index 72853ec23fd36..1fe649ee9519a 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/form_options_validation.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/form_options_validation.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; import { EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields'; import { ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/use_saved_search.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/use_saved_search.ts index 324db0d6b2ad4..0c3121f5aff58 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/use_saved_search.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/use_saved_search.ts @@ -12,7 +12,7 @@ import { luceneStringToDsl, toElasticsearchQuery, } from '@kbn/es-query'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { useMlContext } from '../../../../../contexts/ml'; import { SEARCH_QUERY_LANGUAGE } from '../../../../../../../common/constants/search'; import { getQueryFromSavedSearch } from '../../../../../util/index_utils'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/hooks/use_index_data.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/hooks/use_index_data.ts index 60a5a548c8621..a6a66d0ff4799 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/hooks/use_index_data.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/hooks/use_index_data.ts @@ -7,7 +7,7 @@ import { useEffect, useMemo, useState } from 'react'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiDataGridColumn } from '@elastic/eui'; import { CoreSetup } from 'src/core/public'; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx index 1a5f1bad997e2..cb48583eb2c7e 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx @@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; import { debounce } from 'lodash'; import { fromKueryExpression, luceneStringToDsl, toElasticsearchQuery } from '@kbn/es-query'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Dictionary } from '../../../../../../../common/types/common'; import { IIndexPattern } from '../../../../../../../../../../src/plugins/data/common'; import { Query, QueryStringInput } from '../../../../../../../../../../src/plugins/data/public'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts index 35847839b02a0..9a1d7da26cab5 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/advanced_job_creator.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SavedSearchSavedObject } from '../../../../../../common/types/kibana'; import { JobCreator } from './job_creator'; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx index f156233dfde85..f6317bcc41e54 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx +++ b/x-pack/plugins/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/advanced_detector_modal/advanced_detector_modal.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import React, { FC, Fragment, useState, useContext, useEffect } from 'react'; import { EuiComboBox, diff --git a/x-pack/plugins/ml/public/application/services/job_service.d.ts b/x-pack/plugins/ml/public/application/services/job_service.d.ts index 667f23da34aa0..b6575c48b21f2 100644 --- a/x-pack/plugins/ml/public/application/services/job_service.d.ts +++ b/x-pack/plugins/ml/public/application/services/job_service.d.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TimeRange } from 'src/plugins/data/common/query/timefilter/types'; import { CombinedJob, Datafeed, Job } from '../../../common/types/anomaly_detection_jobs'; diff --git a/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts b/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts index 883e5d499c3d4..db28a34f3f274 100644 --- a/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts +++ b/x-pack/plugins/ml/public/application/services/ml_api_service/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Observable } from 'rxjs'; import type { HttpStart } from 'kibana/public'; import { HttpService } from '../http_service'; diff --git a/x-pack/plugins/ml/public/embeddables/common/process_filters.ts b/x-pack/plugins/ml/public/embeddables/common/process_filters.ts index 4ce445eb4c488..1ff8259250019 100644 --- a/x-pack/plugins/ml/public/embeddables/common/process_filters.ts +++ b/x-pack/plugins/ml/public/embeddables/common/process_filters.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Filter, fromKueryExpression, diff --git a/x-pack/plugins/ml/server/lib/ml_client/search.ts b/x-pack/plugins/ml/server/lib/ml_client/search.ts index 68e503ac56246..b9de1fa0d2bfc 100644 --- a/x-pack/plugins/ml/server/lib/ml_client/search.ts +++ b/x-pack/plugins/ml/server/lib/ml_client/search.ts @@ -7,7 +7,7 @@ import Boom from '@hapi/boom'; import { IScopedClusterClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { JobSavedObjectService } from '../../saved_objects'; diff --git a/x-pack/plugins/ml/server/lib/query_utils.ts b/x-pack/plugins/ml/server/lib/query_utils.ts index e801130643345..cfaa5abaf7f23 100644 --- a/x-pack/plugins/ml/server/lib/query_utils.ts +++ b/x-pack/plugins/ml/server/lib/query_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; /* * Contains utility functions for building and processing queries. */ diff --git a/x-pack/plugins/ml/server/models/annotation_service/annotation.ts b/x-pack/plugins/ml/server/models/annotation_service/annotation.ts index c6ed72de18d05..9e4242408b077 100644 --- a/x-pack/plugins/ml/server/models/annotation_service/annotation.ts +++ b/x-pack/plugins/ml/server/models/annotation_service/annotation.ts @@ -9,7 +9,7 @@ import Boom from '@hapi/boom'; import { each, get } from 'lodash'; import { IScopedClusterClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ANNOTATION_EVENT_USER, ANNOTATION_TYPE } from '../../../common/constants/annotations'; import { PARTITION_FIELDS } from '../../../common/constants/anomalies'; import { diff --git a/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts b/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts index 760faa8d530fc..bb4bcb0781e27 100644 --- a/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts +++ b/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import numeral from '@elastic/numeral'; import { IScopedClusterClient } from 'kibana/server'; import { MLCATEGORY } from '../../../common/constants/field_types'; diff --git a/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts b/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts index 791ba6d79ab5a..508abcffd0776 100644 --- a/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts +++ b/x-pack/plugins/ml/server/models/calendar/calendar_manager.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { difference } from 'lodash'; import { EventManager } from './event_manager'; import type { MlClient } from '../../lib/ml_client'; diff --git a/x-pack/plugins/ml/server/models/calendar/event_manager.ts b/x-pack/plugins/ml/server/models/calendar/event_manager.ts index d30297eab5c15..46ad415167387 100644 --- a/x-pack/plugins/ml/server/models/calendar/event_manager.ts +++ b/x-pack/plugins/ml/server/models/calendar/event_manager.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { GLOBAL_CALENDAR } from '../../../common/constants/calendars'; import type { MlClient } from '../../lib/ml_client'; diff --git a/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts b/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts index b39debbe664d3..436ca86b5a603 100644 --- a/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts +++ b/x-pack/plugins/ml/server/models/data_frame_analytics/validation.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient } from 'kibana/server'; import { getAnalysisType } from '../../../common/util/analytics_utils'; import { ANALYSIS_CONFIG_TYPE } from '../../../common/constants/data_frame_analytics'; diff --git a/x-pack/plugins/ml/server/models/filter/filter_manager.ts b/x-pack/plugins/ml/server/models/filter/filter_manager.ts index a2b71ae572170..3a0d7a706e69c 100644 --- a/x-pack/plugins/ml/server/models/filter/filter_manager.ts +++ b/x-pack/plugins/ml/server/models/filter/filter_manager.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import Boom from '@hapi/boom'; import type { MlClient } from '../../lib/ml_client'; diff --git a/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts b/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts index 530a1342ad340..313b60a35aa6d 100644 --- a/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts +++ b/x-pack/plugins/ml/server/models/job_audit_messages/job_audit_messages.ts @@ -8,7 +8,7 @@ import moment from 'moment'; import type { IScopedClusterClient } from 'kibana/server'; import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ML_NOTIFICATION_INDEX_PATTERN } from '../../../common/constants/index_patterns'; import { MESSAGE_LEVEL } from '../../../common/constants/message_levels'; import type { JobSavedObjectService } from '../../saved_objects'; diff --git a/x-pack/plugins/ml/server/models/job_service/datafeeds.ts b/x-pack/plugins/ml/server/models/job_service/datafeeds.ts index 8b3f7f4b0b0ee..a699402f9b47a 100644 --- a/x-pack/plugins/ml/server/models/job_service/datafeeds.ts +++ b/x-pack/plugins/ml/server/models/job_service/datafeeds.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import { IScopedClusterClient } from 'kibana/server'; import { JOB_STATE, DATAFEED_STATE } from '../../../common/constants/states'; diff --git a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts index 4f87e4698c032..a5510977d2ade 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/examples.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient } from 'kibana/server'; import { chunk } from 'lodash'; diff --git a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts index 87715d9d85dbf..03477b896d7c7 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job/categorization/top_categories.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CategoryId, Category } from '../../../../../common/types/categories'; import type { MlClient } from '../../../../lib/ml_client'; diff --git a/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts b/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts index b838165826da1..cd0f81d46563a 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient } from 'kibana/server'; import { cloneDeep } from 'lodash'; import { SavedObjectsClientContract } from 'kibana/server'; diff --git a/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts b/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts index 72408b7f9c534..80376688227ab 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient } from 'kibana/server'; import { SavedObject } from 'kibana/server'; import { IndexPatternAttributes } from 'src/plugins/data/server'; diff --git a/x-pack/plugins/ml/server/routes/anomaly_detectors.ts b/x-pack/plugins/ml/server/routes/anomaly_detectors.ts index 30aae3c0fb550..c6942b1cc40d6 100644 --- a/x-pack/plugins/ml/server/routes/anomaly_detectors.ts +++ b/x-pack/plugins/ml/server/routes/anomaly_detectors.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import { wrapError } from '../client/error_wrapper'; import { RouteInitialization } from '../types'; diff --git a/x-pack/plugins/ml/server/routes/datafeeds.ts b/x-pack/plugins/ml/server/routes/datafeeds.ts index 9f908bf61a35d..c3414b2fbc55c 100644 --- a/x-pack/plugins/ml/server/routes/datafeeds.ts +++ b/x-pack/plugins/ml/server/routes/datafeeds.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { wrapError } from '../client/error_wrapper'; import { RouteInitialization } from '../types'; import { diff --git a/x-pack/plugins/ml/server/routes/job_service.ts b/x-pack/plugins/ml/server/routes/job_service.ts index da115a224d19e..9998e11c8f0f8 100644 --- a/x-pack/plugins/ml/server/routes/job_service.ts +++ b/x-pack/plugins/ml/server/routes/job_service.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import { wrapError } from '../client/error_wrapper'; import { RouteInitialization } from '../types'; diff --git a/x-pack/plugins/ml/server/shared_services/providers/system.ts b/x-pack/plugins/ml/server/shared_services/providers/system.ts index 85cd73ba010af..b198e5d8345f0 100644 --- a/x-pack/plugins/ml/server/shared_services/providers/system.ts +++ b/x-pack/plugins/ml/server/shared_services/providers/system.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { KibanaRequest, SavedObjectsClientContract } from 'kibana/server'; import { MlLicense } from '../../../common/license'; diff --git a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_es_usage.ts b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_es_usage.ts index 1fb2ba70f2ab1..884b4e6466e60 100644 --- a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_es_usage.ts +++ b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_es_usage.ts @@ -7,7 +7,7 @@ import { ElasticsearchClient } from 'src/core/server'; import { get } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { StackProductUsage } from '../types'; interface ESIndicesBucket { diff --git a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_license_type.ts b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_license_type.ts index f42623ff851ce..0f0d75546d28d 100644 --- a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_license_type.ts +++ b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_license_type.ts @@ -7,7 +7,7 @@ import { get } from 'lodash'; import { ElasticsearchClient } from 'src/core/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { INDEX_PATTERN_ELASTICSEARCH } from '../../../../common/constants'; import { getCcsIndexPattern } from '../../../lib/alerts/get_ccs_index_pattern'; diff --git a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_stack_product_usage.ts b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_stack_product_usage.ts index 0d3aab8283688..bcb872912394c 100644 --- a/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_stack_product_usage.ts +++ b/x-pack/plugins/monitoring/server/kibana_monitoring/collectors/lib/fetch_stack_product_usage.ts @@ -7,7 +7,7 @@ import { get } from 'lodash'; import { ElasticsearchClient } from 'src/core/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { MonitoringConfig } from '../../../config'; // @ts-ignore import { prefixIndexPattern } from '../../../../common/ccs_utils'; diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_available_ccs.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_available_ccs.test.ts index ca8270590da54..19d6168dbb5d0 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_available_ccs.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_available_ccs.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts index 08ecaef33085b..2739e23245bde 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cluster_health.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from '../../../../../../src/core/server/elasticsearch/client/mocks'; import { fetchClusterHealth } from './fetch_cluster_health'; diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts index 75991e892d419..c46ec424b2cd3 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_clusters.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts index 8f0083f1f533f..a67a5e679cc33 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_cpu_usage_node_stats.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from '../../../../../../src/core/server/elasticsearch/client/mocks'; import { fetchCpuUsageNodeStats } from './fetch_cpu_usage_node_stats'; diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts index d105174853636..515fa3b2442d3 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_elasticsearch_versions.test.ts @@ -9,7 +9,7 @@ import { elasticsearchClientMock } from '../../../../../../src/core/server/elasticsearch/client/mocks'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; import { fetchElasticsearchVersions } from './fetch_elasticsearch_versions'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; describe('fetchElasticsearchVersions', () => { const esClient = elasticsearchServiceMock.createScopedClusterClient().asCurrentUser; diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts index 3c12c70bf1713..538e24a764276 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_licenses.test.ts @@ -8,7 +8,7 @@ import { fetchLicenses } from './fetch_licenses'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from '../../../../../../src/core/server/elasticsearch/client/mocks'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; describe('fetchLicenses', () => { const clusterName = 'MyCluster'; diff --git a/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch_settings/check/internal_monitoring.ts b/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch_settings/check/internal_monitoring.ts index 3cd2b8b73b315..eee6ba98e62c7 100644 --- a/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch_settings/check/internal_monitoring.ts +++ b/x-pack/plugins/monitoring/server/routes/api/v1/elasticsearch_settings/check/internal_monitoring.ts @@ -7,7 +7,7 @@ import { schema } from '@kbn/config-schema'; import { RequestHandlerContext } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { INDEX_PATTERN_ELASTICSEARCH, INDEX_PATTERN_KIBANA, diff --git a/x-pack/plugins/monitoring/server/static_globals.ts b/x-pack/plugins/monitoring/server/static_globals.ts index fc4ece3231486..ac0cab7a68388 100644 --- a/x-pack/plugins/monitoring/server/static_globals.ts +++ b/x-pack/plugins/monitoring/server/static_globals.ts @@ -13,7 +13,7 @@ import { PluginInitializerContext, } from 'kibana/server'; import url from 'url'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { MonitoringConfig } from './config'; import { PluginsSetup } from './types'; import { mbSafeQuery } from './lib/mb_safe_query'; diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_beats_stats.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_beats_stats.ts index 00dba8b727883..8da551a923f04 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_beats_stats.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_beats_stats.ts @@ -7,7 +7,7 @@ import { get } from 'lodash'; import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { createQuery } from './create_query'; import { INDEX_PATTERN_BEATS } from '../../common/constants'; diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts index 7cf4ca2b94ce0..eda038ac19395 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_cluster_uuids.ts @@ -8,7 +8,7 @@ import { get } from 'lodash'; import moment from 'moment'; import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { createQuery } from './create_query'; import { INDEX_PATTERN_ELASTICSEARCH, diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_es_stats.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_es_stats.ts index 92aa48cbe90ef..8155c0080e44e 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_es_stats.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_es_stats.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { INDEX_PATTERN_ELASTICSEARCH } from '../../common/constants'; /** diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_high_level_stats.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_high_level_stats.ts index 5f14ebb815bab..79c38c4d15a87 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_high_level_stats.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_high_level_stats.ts @@ -7,7 +7,7 @@ import { get } from 'lodash'; import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { createQuery } from './create_query'; import { INDEX_PATTERN_KIBANA, diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.test.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.test.ts index cd037fa062ed8..5474880986238 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.test.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getUsageStats, combineStats, diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.ts index 8313bcc9f5464..df8354716a0c8 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_kibana_stats.ts @@ -7,7 +7,7 @@ import moment from 'moment'; import { isEmpty } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from 'kibana/server'; import { KIBANA_SYSTEM_ID, TELEMETRY_COLLECTION_INTERVAL } from '../../common/constants'; import { diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_licenses.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_licenses.ts index 514b04bf1a0e7..d70bfdfd70ad6 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_licenses.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_licenses.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESLicense } from '../../../telemetry_collection_xpack/server'; import { INDEX_PATTERN_ELASTICSEARCH } from '../../common/constants'; diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_logstash_stats.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_logstash_stats.ts index 306c9b6201557..736c61130bc67 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_logstash_stats.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_logstash_stats.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { createQuery } from './create_query'; import { mapToList } from './get_high_level_stats'; import { incrementByKey } from './get_high_level_stats'; diff --git a/x-pack/plugins/observability/public/hooks/use_es_search.ts b/x-pack/plugins/observability/public/hooks/use_es_search.ts index 70ffdbba22c58..7902adf77ad1a 100644 --- a/x-pack/plugins/observability/public/hooks/use_es_search.ts +++ b/x-pack/plugins/observability/public/hooks/use_es_search.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DataPublicPluginStart } from '../../../../../src/plugins/data/public'; import { ESSearchResponse } from '../../../../../src/core/types/elasticsearch'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/observability/server/utils/create_or_update_index.ts b/x-pack/plugins/observability/server/utils/create_or_update_index.ts index 7451314ad248c..9cd4cf9c9334f 100644 --- a/x-pack/plugins/observability/server/utils/create_or_update_index.ts +++ b/x-pack/plugins/observability/server/utils/create_or_update_index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import pRetry from 'p-retry'; import { Logger, ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/observability/server/utils/queries.ts b/x-pack/plugins/observability/server/utils/queries.ts index 2e05aa6cb3758..953c0021636d4 100644 --- a/x-pack/plugins/observability/server/utils/queries.ts +++ b/x-pack/plugins/observability/server/utils/queries.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query'; export function rangeQuery( diff --git a/x-pack/plugins/osquery/common/search_strategy/osquery/actions/index.ts b/x-pack/plugins/osquery/common/search_strategy/osquery/actions/index.ts index b24e4f28d89f1..22edbf25cc412 100644 --- a/x-pack/plugins/osquery/common/search_strategy/osquery/actions/index.ts +++ b/x-pack/plugins/osquery/common/search_strategy/osquery/actions/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IEsSearchResponse } from '../../../../../../../src/plugins/data/common'; import { Inspect, Maybe, PageInfoPaginated } from '../../common'; diff --git a/x-pack/plugins/osquery/common/search_strategy/osquery/index.ts b/x-pack/plugins/osquery/common/search_strategy/osquery/index.ts index fb3bd92abb4c9..d0d67c8546b61 100644 --- a/x-pack/plugins/osquery/common/search_strategy/osquery/index.ts +++ b/x-pack/plugins/osquery/common/search_strategy/osquery/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; import { ESQuery } from '../../typed_json'; import { diff --git a/x-pack/plugins/osquery/common/search_strategy/osquery/results/index.ts b/x-pack/plugins/osquery/common/search_strategy/osquery/results/index.ts index ca85f4342c9c1..f08d9f88e705d 100644 --- a/x-pack/plugins/osquery/common/search_strategy/osquery/results/index.ts +++ b/x-pack/plugins/osquery/common/search_strategy/osquery/results/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IEsSearchResponse } from '../../../../../../../src/plugins/data/common'; import { Inspect, Maybe, PageInfoPaginated, SortField } from '../../common'; diff --git a/x-pack/plugins/osquery/public/agents/helpers.ts b/x-pack/plugins/osquery/public/agents/helpers.ts index df966a01f1de1..6a60607d9a301 100644 --- a/x-pack/plugins/osquery/public/agents/helpers.ts +++ b/x-pack/plugins/osquery/public/agents/helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { euiPaletteColorBlindBehindText } from '@elastic/eui'; import { PaginationInputPaginated, diff --git a/x-pack/plugins/osquery/public/agents/types.ts b/x-pack/plugins/osquery/public/agents/types.ts index bfe59c91d007d..9a4d4c7ff18cc 100644 --- a/x-pack/plugins/osquery/public/agents/types.ts +++ b/x-pack/plugins/osquery/public/agents/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiComboBoxOptionOption } from '@elastic/eui'; import { Agent } from '../../common/shared_imports'; diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts index 55bec687d3e2c..84241356579c8 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ISearchRequestParams } from '../../../../../../../../../src/plugins/data/common'; import { AgentsRequestOptions } from '../../../../../../common/search_strategy'; diff --git a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts index c269677ae930d..300b64113b4a7 100644 --- a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts @@ -7,7 +7,7 @@ import { Writable } from 'stream'; import { i18n } from '@kbn/i18n'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient, IUiSettingsClient } from 'src/core/server'; import { IScopedSearchClient } from 'src/plugins/data/server'; import { Datatable } from 'src/plugins/expressions/server'; diff --git a/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts index 9a452943ff699..c1243be554dfb 100644 --- a/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts +++ b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ElasticsearchClient } from 'kibana/server'; import { get } from 'lodash'; import type { ReportingConfig } from '../'; diff --git a/x-pack/plugins/rule_registry/common/mapping_from_field_map.ts b/x-pack/plugins/rule_registry/common/mapping_from_field_map.ts index f929917bd8f75..4833631f09adb 100644 --- a/x-pack/plugins/rule_registry/common/mapping_from_field_map.ts +++ b/x-pack/plugins/rule_registry/common/mapping_from_field_map.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { set } from '@elastic/safer-lodash-set'; import { FieldMap } from './field_map/types'; diff --git a/x-pack/plugins/rule_registry/common/types.ts b/x-pack/plugins/rule_registry/common/types.ts index 7b2fde48057a6..8ffbebbc631a1 100644 --- a/x-pack/plugins/rule_registry/common/types.ts +++ b/x-pack/plugins/rule_registry/common/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as t from 'io-ts'; diff --git a/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts b/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts index 4a66550f432cb..9a84fc7b7e2bb 100644 --- a/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts +++ b/x-pack/plugins/rule_registry/server/alert_data_client/alerts_client.ts @@ -5,7 +5,7 @@ * 2.0. */ import Boom from '@hapi/boom'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { PublicMethodsOf } from '@kbn/utility-types'; import { Filter, buildEsQuery, EsQueryConfig } from '@kbn/es-query'; import { decodeVersion, encodeHitVersion } from '@kbn/securitysolution-es-utils'; diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index_options.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index_options.ts index e85331fb02a63..ba0961c7926a1 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index_options.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/index_options.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ValidFeatureId } from '@kbn/rule-data-utils'; /** diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts index e10bb6382ab24..9018b10afdb5b 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts @@ -6,7 +6,7 @@ */ import { get, isEmpty } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient, Logger } from 'kibana/server'; diff --git a/x-pack/plugins/security_solution/common/endpoint/data_generators/fleet_agent_generator.ts b/x-pack/plugins/security_solution/common/endpoint/data_generators/fleet_agent_generator.ts index 61f71e2ee253b..8f69df325fe42 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_generators/fleet_agent_generator.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_generators/fleet_agent_generator.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DeepPartial } from 'utility-types'; import { merge } from 'lodash'; import { BaseDataGenerator } from './base_data_generator'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts index e8578b4c07063..315f6eeb69f34 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/hosts/details/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IEsSearchResponse } from '../../../../../../../../src/plugins/data/common'; import { Inspect, Maybe, TimerangeInput } from '../../../common'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts b/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts index 47a96d8a5fe69..f12dbf0370e65 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/security_solution/index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IEsSearchRequest } from '../../../../../../src/plugins/data/common'; import { ESQuery } from '../../typed_json'; import { diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx index 662a3ee770547..82c3fb4c40248 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx @@ -6,7 +6,7 @@ */ import { act, renderHook, RenderHookResult } from '@testing-library/react-hooks'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { KibanaServices } from '../../../common/lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx index 18fce44646909..7cb8b643aa0e8 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx @@ -6,7 +6,7 @@ */ import { useEffect, useRef, useState, useCallback } from 'react'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ExceptionListItemSchema, CreateExceptionListItemSchema, diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts index 88882131fed03..d400379e7d154 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/api.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getCasesFromAlertsUrl } from '../../../../../../cases/common'; import { HostIsolationResponse, HostInfo } from '../../../../../common/endpoint/types'; import { diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/use_fetch_ecs_alerts_data.ts b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/use_fetch_ecs_alerts_data.ts index 749addcc94930..64b5d6ea9431a 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/use_fetch_ecs_alerts_data.ts +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/alerts/use_fetch_ecs_alerts_data.ts @@ -5,7 +5,7 @@ * 2.0. */ import { useEffect, useState } from 'react'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isEmpty } from 'lodash'; import { diff --git a/x-pack/plugins/security_solution/public/hosts/components/authentications_table/mock.ts b/x-pack/plugins/security_solution/public/hosts/components/authentications_table/mock.ts index f2b004f856cc4..caf441b34ca90 100644 --- a/x-pack/plugins/security_solution/public/hosts/components/authentications_table/mock.ts +++ b/x-pack/plugins/security_solution/public/hosts/components/authentications_table/mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HostAuthenticationsStrategyResponse } from '../../../../common/search_strategy/security_solution/hosts/authentications'; export const mockData: { Authentications: HostAuthenticationsStrategyResponse } = { diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.ts index 448496671b4f9..742770db65b11 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/query_builders.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query'; import { metadataCurrentIndexPattern, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/test_support.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/test_support.ts index 0207d59137eb3..2ffcc06915e73 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/test_support.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/support/test_support.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { METADATA_UNITED_INDEX } from '../../../../../common/endpoint/constants'; import { HostMetadata, UnitedAgentMetadata } from '../../../../../common/endpoint/types'; diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts index 90cda7ceb05d4..254b01c0e3ad0 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/policy/handlers.test.ts @@ -22,7 +22,7 @@ import { loggingSystemMock, savedObjectsClientMock, } from '../../../../../../../src/core/server/mocks'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { GetHostPolicyResponse, HostPolicyResponse } from '../../../../common/endpoint/types'; import { EndpointDocGenerator } from '../../../../common/endpoint/generate_data'; import { parseExperimentalConfigValue } from '../../../../common/experimental_features'; diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts b/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts index 3dcfee65314eb..fde8181c6bd1f 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { IScopedClusterClient } from 'src/core/server'; import { JsonObject, JsonValue } from '@kbn/utility-types'; diff --git a/x-pack/plugins/security_solution/server/endpoint/services/metadata/metadata.ts b/x-pack/plugins/security_solution/server/endpoint/services/metadata/metadata.ts index 6bf062c02732e..f82ce73491e57 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/metadata/metadata.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/metadata/metadata.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HostMetadata } from '../../../../common/endpoint/types'; import { SecuritySolutionRequestHandlerContext } from '../../../types'; import { getESQueryHostMetadataByIDs } from '../../routes/metadata/query_builders'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/create_index_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/create_index_route.ts index 61635fdcef9f0..5a16805cd22f6 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/create_index_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/index/create_index_route.ts @@ -6,7 +6,7 @@ */ import { get } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from 'src/core/server'; import { transformError, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts index 3cd6171b5bbeb..d3e39cf696e22 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ALERT_RULE_CONSUMER, ALERT_RULE_TYPE_ID, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_events_query.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_events_query.ts index 065707252c601..c09a60ba165fd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_events_query.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_events_query.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { isEmpty } from 'lodash'; import { TimestampOverrideOrUndefined } from '../../../../common/detection_engine/schemas/common/schemas'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/bulk_create_ml_signals.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/bulk_create_ml_signals.ts index c2ac2a031ca9b..3a1fe273c79d4 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/bulk_create_ml_signals.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/bulk_create_ml_signals.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { flow, omit } from 'lodash/fp'; import set from 'set-value'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events.ts index da664f65c2d50..d267153a4813a 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FilterEventsOptions } from './types'; /** diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts index fffe971753f87..49a8ab0781eb0 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { entriesList, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { hasLargeValueList } from '@kbn/securitysolution-list-utils'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts index 160506b965bf0..5feb8e8b92c5b 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger } from 'src/core/server'; import type { Type, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.ts index 52b0799f5fe33..c47cbb4177855 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.ts @@ -6,7 +6,7 @@ */ import { identity } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { singleSearchAfter } from './single_search_after'; import { filterEventsAgainstList } from './filters/filter_events_against_list'; import { sendAlertTelemetryEvents } from './send_telemetry_events'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts index e5bb015d663e2..ff4ffdaaab923 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts @@ -6,7 +6,7 @@ */ import moment from 'moment'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { loggingSystemMock } from 'src/core/server/mocks'; import { getAlertMock } from '../routes/__mocks__/request_responses'; import { signalRulesAlertType } from './signal_rule_alert_type'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.test.ts index a67016491aaef..d00925af74316 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { sampleDocSearchResultsNoSortId, mockLogger, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts index 2b1d27fc2fcd0..2596068848ef0 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { performance } from 'perf_hooks'; import { AlertInstanceContext, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts index f49e3dec93600..592ab137ee289 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/build_threat_mapping_filter.mock.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ThreatMapping } from '@kbn/securitysolution-io-ts-alerting-types'; import { Filter } from 'src/plugins/data/common'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/get_threat_list.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/get_threat_list.ts index 2e10f467b9fc8..94d6be3ea24dd 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/get_threat_list.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/get_threat_list.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getQueryFilter } from '../../../../../common/detection_engine/get_query_filter'; import { GetSortWithTieBreakerOptions, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts index 38d9d42a4602c..63a198ae372e7 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ThreatQuery, ThreatMapping, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts index fc6b42c38549e..d719be0ee3c95 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { BoolQuery } from '@kbn/es-query'; import moment from 'moment'; import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index 7538aedf3aacb..7c236d63e684c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -10,7 +10,7 @@ import moment from 'moment'; import uuidv5 from 'uuid/v5'; import dateMath from '@elastic/datemath'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TransportResult } from '@elastic/transport'; import { ALERT_INSTANCE_ID, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; import type { ListArray, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts b/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts index 86e1c6dee6180..f8d767a371d9a 100644 --- a/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts +++ b/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { buildExceptionFilter } from '@kbn/securitysolution-list-utils'; diff --git a/x-pack/plugins/security_solution/server/plugin.ts b/x-pack/plugins/security_solution/server/plugin.ts index f69565cacceb5..b055c33eebad6 100644 --- a/x-pack/plugins/security_solution/server/plugin.ts +++ b/x-pack/plugins/security_solution/server/plugin.ts @@ -7,7 +7,7 @@ import { Observable } from 'rxjs'; import LRU from 'lru-cache'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CoreSetup, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/helpers.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/helpers.ts index 22dba31701e17..4d39a7e12f679 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/helpers.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/helpers.ts @@ -6,7 +6,7 @@ */ import { get, isEmpty } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ENRICHMENT_TYPES, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts index 325d45e04b2b0..57646c48ce55b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts @@ -6,7 +6,7 @@ */ import { isEmpty } from 'lodash/fp'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HostAuthenticationsRequestOptions } from '../../../../../../../common/search_strategy/security_solution/hosts/authentications'; import { sourceFieldsMap, hostFieldsMap } from '../../../../../../../common/ecs/ecs_fields'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts index d320130115588..d77bbb5d429ac 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts @@ -6,7 +6,7 @@ */ import { isEmpty } from 'lodash/fp'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HostAuthenticationsRequestOptions } from '../../../../../../../common/search_strategy/security_solution/hosts/authentications'; diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts index 5d4f45c68160a..0623507f885b1 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { createQueryFilterClauses } from '../../../../../../utils/build_query'; import { reduceFields } from '../../../../../../utils/build_query/reduce_fields'; import { diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts b/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts index 36c56feba444a..0458d78263270 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/policy.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema, TypeOf } from '@kbn/config-schema'; import { SlmPolicyEs, PolicyIndicesResponse } from '../../../common/types'; diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/restore.ts b/x-pack/plugins/snapshot_restore/server/routes/api/restore.ts index eb77c5e2d833f..f62256090eaaa 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/restore.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/restore.ts @@ -6,7 +6,7 @@ */ import { schema, TypeOf } from '@kbn/config-schema'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SnapshotRestore, SnapshotRestoreShardEs } from '../../../common/types'; import { serializeRestoreSettings } from '../../../common/lib'; diff --git a/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts b/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts index 83421056229cf..c3b59dbd1c557 100644 --- a/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts +++ b/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { ESSearchRequest } from '../../../../src/core/types/elasticsearch'; interface BuildSortedEventsQueryOpts { diff --git a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx index 5111f427cd0d8..4cba80a9a541a 100644 --- a/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx +++ b/x-pack/plugins/stack_alerts/public/alert_types/es_query/expression.tsx @@ -23,7 +23,7 @@ import { EuiLink, } from '@elastic/eui'; import { DocLinksStart, HttpSetup } from 'kibana/public'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { XJson } from '../../../../../../src/plugins/es_ui_shared/public'; import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/stack_alerts/server/alert_types/es_query/action_context.ts b/x-pack/plugins/stack_alerts/server/alert_types/es_query/action_context.ts index 84a4569d9b860..f4886e3c055a2 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/es_query/action_context.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/es_query/action_context.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AlertExecutorOptions, AlertInstanceContext } from '../../../../alerting/server'; import { EsQueryAlertParams } from './alert_type_params'; diff --git a/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts b/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts index 26efdc0c056a5..42f3508f1a2c9 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger } from 'src/core/server'; import { AlertType, AlertExecutorOptions } from '../../types'; import { ActionContext, EsQueryAlertActionContext, addMessages } from './action_context'; diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts index f09f1b051d881..8f0026839fda6 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts @@ -7,7 +7,7 @@ import { ElasticsearchClient } from 'kibana/server'; import { Logger } from 'src/core/server'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { fromKueryExpression, diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/geo_containment.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/geo_containment.ts index 21a536dd474ba..dac0162322a9f 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/geo_containment.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/geo_containment.ts @@ -7,7 +7,7 @@ import _ from 'lodash'; import { Logger } from 'src/core/server'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { executeEsQueryFactory, getShapesFilters, OTHER_CATEGORY } from './es_query_builder'; import { AlertServices } from '../../../../alerting/server'; import { diff --git a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts index 9628e2807627a..9a63ece0dda46 100644 --- a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts +++ b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.test.ts @@ -21,7 +21,7 @@ import { times } from 'lodash'; import { taskStoreMock } from '../task_store.mock'; import { of, Subject } from 'rxjs'; import { sleep } from '../test_utils'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; type ResponseWithAggs = Omit, 'aggregations'> & { aggregations: WorkloadAggregationResponse; diff --git a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts index 9ac528cfd1ced..1ea3e5c6242e2 100644 --- a/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts +++ b/x-pack/plugins/task_manager/server/monitoring/workload_statistics.ts @@ -10,7 +10,7 @@ import { mergeMap, map, filter, switchMap, catchError } from 'rxjs/operators'; import { Logger } from 'src/core/server'; import { JsonObject } from '@kbn/utility-types'; import { keyBy, mapValues } from 'lodash'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { AggregatedStatProvider } from './runtime_statistics_aggregator'; import { parseIntervalAsSecond, asInterval, parseIntervalAsMillisecond } from '../lib/intervals'; import { AggregationResultOf } from '../../../../../src/core/types/elasticsearch'; diff --git a/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.ts b/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.ts index 3183f364001d9..47f4722562973 100644 --- a/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.ts +++ b/x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ScriptBasedSortClause, ScriptClause, diff --git a/x-pack/plugins/task_manager/server/queries/query_clauses.ts b/x-pack/plugins/task_manager/server/queries/query_clauses.ts index 5f7cc8ed2bdb3..6fc5677594f3d 100644 --- a/x-pack/plugins/task_manager/server/queries/query_clauses.ts +++ b/x-pack/plugins/task_manager/server/queries/query_clauses.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export interface MustCondition { bool: Pick; diff --git a/x-pack/plugins/task_manager/server/saved_objects/index.ts b/x-pack/plugins/task_manager/server/saved_objects/index.ts index abbd1af73b55a..56390b280fced 100644 --- a/x-pack/plugins/task_manager/server/saved_objects/index.ts +++ b/x-pack/plugins/task_manager/server/saved_objects/index.ts @@ -6,7 +6,7 @@ */ import type { SavedObjectsServiceSetup, SavedObjectsTypeMappingDefinition } from 'kibana/server'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import mappings from './mappings.json'; import { getMigrations } from './migrations'; import { TaskManagerConfig } from '../config.js'; diff --git a/x-pack/plugins/task_manager/server/task_store.test.ts b/x-pack/plugins/task_manager/server/task_store.test.ts index f3b4014c9c919..4a5637d75b65f 100644 --- a/x-pack/plugins/task_manager/server/task_store.test.ts +++ b/x-pack/plugins/task_manager/server/task_store.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import _ from 'lodash'; import { first } from 'rxjs/operators'; diff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts index bcd4b3b1885f9..4f13f95497a42 100644 --- a/x-pack/plugins/task_manager/server/task_store.ts +++ b/x-pack/plugins/task_manager/server/task_store.ts @@ -11,7 +11,7 @@ import { Subject } from 'rxjs'; import { omit, defaults } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SavedObject, diff --git a/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_license.ts b/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_license.ts index ad7d5439f8765..ff16d272b17b2 100644 --- a/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_license.ts +++ b/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_license.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from 'src/core/server'; export type ESLicense = estypes.LicenseGetLicenseInformation; diff --git a/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts b/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts index 75b9c736de901..2d1fea23c5ef3 100644 --- a/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts +++ b/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { coreMock, elasticsearchServiceMock } from '../../../../../src/core/server/mocks'; import { getStatsWithXpack } from './get_stats_with_xpack'; import { SavedObjectsClient } from '../../../../../src/core/server'; diff --git a/x-pack/plugins/timelines/common/search_strategy/common/index.ts b/x-pack/plugins/timelines/common/search_strategy/common/index.ts index 62c2187e267fa..976b0bfc373d1 100644 --- a/x-pack/plugins/timelines/common/search_strategy/common/index.ts +++ b/x-pack/plugins/timelines/common/search_strategy/common/index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export type Maybe = T | null; diff --git a/x-pack/plugins/timelines/public/container/use_update_alerts.ts b/x-pack/plugins/timelines/public/container/use_update_alerts.ts index 7f42ddc6e8211..78182cb347b9d 100644 --- a/x-pack/plugins/timelines/public/container/use_update_alerts.ts +++ b/x-pack/plugins/timelines/public/container/use_update_alerts.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CoreStart } from '../../../../../src/core/public'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/transform/common/api_schemas/type_guards.ts b/x-pack/plugins/transform/common/api_schemas/type_guards.ts index 1f27f1798c8e7..9fcf01f80cf66 100644 --- a/x-pack/plugins/transform/common/api_schemas/type_guards.ts +++ b/x-pack/plugins/transform/common/api_schemas/type_guards.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { EsIndex } from '../types/es_index'; import { isPopulatedObject } from '../shared_imports'; diff --git a/x-pack/plugins/transform/public/app/common/request.ts b/x-pack/plugins/transform/public/app/common/request.ts index a7a3a91f9429b..8f8341260bd7e 100644 --- a/x-pack/plugins/transform/public/app/common/request.ts +++ b/x-pack/plugins/transform/public/app/common/request.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HttpFetchError } from '../../../../../../src/core/public'; import type { IndexPattern } from '../../../../../../src/plugins/data/public'; diff --git a/x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts b/x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts index 3d5e1783f8c62..979a98ececabb 100644 --- a/x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts +++ b/x-pack/plugins/transform/public/app/hooks/__mocks__/use_api.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HttpFetchError } from 'kibana/public'; diff --git a/x-pack/plugins/transform/public/app/hooks/use_api.ts b/x-pack/plugins/transform/public/app/hooks/use_api.ts index 1abe2ed09444e..21e37ca16c4de 100644 --- a/x-pack/plugins/transform/public/app/hooks/use_api.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_api.ts @@ -7,7 +7,7 @@ import { useMemo } from 'react'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HttpFetchError } from 'kibana/public'; diff --git a/x-pack/plugins/transform/public/app/hooks/use_index_data.ts b/x-pack/plugins/transform/public/app/hooks/use_index_data.ts index 55a304207a1c7..3b26f0cffb28e 100644 --- a/x-pack/plugins/transform/public/app/hooks/use_index_data.ts +++ b/x-pack/plugins/transform/public/app/hooks/use_index_data.ts @@ -7,7 +7,7 @@ import { useEffect, useMemo, useState } from 'react'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { EuiDataGridColumn } from '@elastic/eui'; import { diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx index da7100a31167a..2456c61b6c2ed 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_define/common/filter_agg/components/filter_term_form.tsx @@ -6,7 +6,7 @@ */ import React, { useCallback, useContext, useEffect, useState } from 'react'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { debounce } from 'lodash'; diff --git a/x-pack/plugins/transform/server/routes/api/transforms.ts b/x-pack/plugins/transform/server/routes/api/transforms.ts index 76aac9686c37e..2d46ec51efe25 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms.ts @@ -6,7 +6,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient, diff --git a/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.test.ts b/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.test.ts index 46fd82f4bd70e..5afe37df536a6 100644 --- a/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.test.ts +++ b/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.test.ts @@ -7,7 +7,7 @@ // test error conditions of calling timeSeriesQuery - postive results tested in FT -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { loggingSystemMock } from '../../../../../../src/core/server/mocks'; import { Logger } from '../../../../../../src/core/server'; import { TimeSeriesQuery, timeSeriesQuery, getResultFromEs } from './time_series_query'; diff --git a/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.ts b/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.ts index a90d903d71db5..0be981661f565 100644 --- a/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.ts +++ b/x-pack/plugins/triggers_actions_ui/server/data/lib/time_series_query.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger, ElasticsearchClient } from 'kibana/server'; import { getEsErrorMessage } from '../../../../alerting/server'; import { DEFAULT_GROUPS } from '../index'; diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts index ddff137772ae8..094a7cbb3844f 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; interface Mapping { type?: string; diff --git a/x-pack/plugins/uptime/common/requests/get_certs_request_body.ts b/x-pack/plugins/uptime/common/requests/get_certs_request_body.ts index 5a729c7e3b96d..ca72717ff4113 100644 --- a/x-pack/plugins/uptime/common/requests/get_certs_request_body.ts +++ b/x-pack/plugins/uptime/common/requests/get_certs_request_body.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CertResult, GetCertsParams, Ping } from '../runtime_types'; import { createEsQuery } from '../utils/es_search'; diff --git a/x-pack/plugins/uptime/common/utils/es_search.ts b/x-pack/plugins/uptime/common/utils/es_search.ts index ba72d09a4e8ef..6a41b83d19ee0 100644 --- a/x-pack/plugins/uptime/common/utils/es_search.ts +++ b/x-pack/plugins/uptime/common/utils/es_search.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; export function createEsQuery(params: T): T { return params; diff --git a/x-pack/plugins/uptime/server/lib/lib.ts b/x-pack/plugins/uptime/server/lib/lib.ts index 9b8ea6b98c8be..0810d761bbe78 100644 --- a/x-pack/plugins/uptime/server/lib/lib.ts +++ b/x-pack/plugins/uptime/server/lib/lib.ts @@ -12,7 +12,7 @@ import { ISavedObjectsRepository, } from 'kibana/server'; import chalk from 'chalk'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMBackendFrameworkAdapter } from './adapters'; import { UMLicenseCheck } from './domains'; import { UptimeRequests } from './requests'; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_last_successful_step.ts b/x-pack/plugins/uptime/server/lib/requests/get_last_successful_step.ts index 6d0f72052e586..e096cdaa65b86 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_last_successful_step.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_last_successful_step.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { UMElasticsearchQueryFn } from '../adapters/framework'; import { JourneyStep } from '../../../common/runtime_types/ping'; diff --git a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts index 621fdf0d15861..cc33a3dab1ef3 100644 --- a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts +++ b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient } from 'kibana/server'; import { get } from 'lodash'; import { ES_SCROLL_SETTINGS } from '../../../common/constants'; diff --git a/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts index f69ee60f9cd73..247c90bd40b4d 100644 --- a/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import { IScopedClusterClient } from 'kibana/server'; import { reduce, size } from 'lodash'; diff --git a/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts index b7c09361774ab..adefe8a29be97 100644 --- a/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts +++ b/x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import { IScopedClusterClient } from 'kibana/server'; import { RouteDependencies } from '../../../types'; diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts index 1baf86bb7f528..53a0fe4ac9e63 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { omit } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios, Superuser } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts index 54b3c14dad1e2..cce3650ecb4cc 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios } from '../../scenarios'; import { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts index 7f5f1b37bf9a8..9fa329e985ed9 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts index 272dbc4d59145..9c86075427dae 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { getTestAlertData, ObjectRemover } from '../../../../common/lib'; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts index 93f6a73b7ce21..683f9f9a79c49 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Spaces } from '../../scenarios'; import { ESTestIndexTool, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts index 5129bd196be60..ea91ce7234a4b 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { omit } from 'lodash'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/elasticsearch'; import { Response as SupertestResponse } from 'supertest'; import { RecoveredActionGroup } from '../../../../../plugins/alerting/common'; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts index d998c86eefe66..c5774f9076132 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { SavedObject } from 'kibana/server'; import { Spaces } from '../../scenarios'; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts index a0196ff3fcb28..d1c534d1aa446 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { Spaces } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts index 94c9904a29fd6..8567578cea7a1 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { getUrlPrefix } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; diff --git a/x-pack/test/api_integration/apis/ml/calendars/helpers.ts b/x-pack/test/api_integration/apis/ml/calendars/helpers.ts index 4667eb25437b1..3d60285bb5d23 100644 --- a/x-pack/test/api_integration/apis/ml/calendars/helpers.ts +++ b/x-pack/test/api_integration/apis/ml/calendars/helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Calendar } from '../../../../../plugins/ml/server/models/calendar'; type ScheduledEvent = estypes.MlCalendarEvent; diff --git a/x-pack/test/api_integration/apis/security_solution/utils.ts b/x-pack/test/api_integration/apis/security_solution/utils.ts index 86e02989f12de..67e55e5ae708e 100644 --- a/x-pack/test/api_integration/apis/security_solution/utils.ts +++ b/x-pack/test/api_integration/apis/security_solution/utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { JsonObject, JsonArray } from '@kbn/utility-types'; diff --git a/x-pack/test/case_api_integration/common/lib/utils.ts b/x-pack/test/case_api_integration/common/lib/utils.ts index 812cc777dd0df..de9f13e768495 100644 --- a/x-pack/test/case_api_integration/common/lib/utils.ts +++ b/x-pack/test/case_api_integration/common/lib/utils.ts @@ -7,7 +7,7 @@ import { omit } from 'lodash'; import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts index 23d3028515205..ac18cf9542fc2 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts index 4815e656414d6..33843f45b5260 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/elasticsearch'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts b/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts index 071be0e7add92..e46391e5cc2dd 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/open_close_signals.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Signal } from '../../../../plugins/security_solution/server/lib/detection_engine/signals/types'; import { DETECTION_ENGINE_SIGNALS_STATUS_URL, diff --git a/x-pack/test/detection_engine_api_integration/basic/tests/update_rac_alerts.ts b/x-pack/test/detection_engine_api_integration/basic/tests/update_rac_alerts.ts index 2b339159d5900..cdad74720b9e2 100644 --- a/x-pack/test/detection_engine_api_integration/basic/tests/update_rac_alerts.ts +++ b/x-pack/test/detection_engine_api_integration/basic/tests/update_rac_alerts.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Signal } from '../../../../plugins/security_solution/server/lib/detection_engine/signals/types'; import { DETECTION_ENGINE_QUERY_SIGNALS_URL } from '../../../../plugins/security_solution/common/constants'; import { RAC_ALERTS_BULK_UPDATE_URL } from '../../../../plugins/timelines/common/constants'; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/alerts/alerts_compatibility.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/alerts/alerts_compatibility.ts index 8d12f9192e13b..ee4dadd1ffcb5 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/alerts/alerts_compatibility.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/alerts/alerts_compatibility.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import expect from '@kbn/expect'; import { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts index 7b6192ddc07e9..6654852988613 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Signal } from '../../../../plugins/security_solution/server/lib/detection_engine/signals/types'; import { diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index d0972432170e2..b62212179c5dc 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -7,7 +7,7 @@ import { KbnClient } from '@kbn/test'; import type { TransportResult } from '@elastic/transport'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type SuperTest from 'supertest'; import type { diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index 7add4a024b469..1d6585d30d8b5 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import expect from '@kbn/expect'; import { ProvidedType } from '@kbn/test'; import fs from 'fs'; diff --git a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts index b97562fe07bfc..cfcfbb021b52a 100644 --- a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FtrProviderContext } from '../../ftr_provider_context'; import { DATAFEED_STATE } from '../../../../plugins/ml/common/constants/states'; diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts index 8124c0d95fb99..4a651f9729e94 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; import { TaskInstanceWithDeprecatedFields } from '../../../../plugins/task_manager/server/task'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts index eb2b4cb1f6f49..3052320440ce7 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts @@ -7,7 +7,7 @@ import { random, times } from 'lodash'; import expect from '@kbn/expect'; -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FtrProviderContext } from '../../ftr_provider_context'; import TaskManagerMapping from '../../../../plugins/task_manager/server/saved_objects/mappings.json'; import { diff --git a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts index c17eb61bab4e6..6252bad684e9e 100644 --- a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts +++ b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; import { EsArchiver } from '@kbn/es-archiver'; From 1e7846d782a2d54a8ac3a6a9b9ee9e9f93410c31 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 14:55:25 +0200 Subject: [PATCH 020/172] fix errors in data plugin --- src/core/server/elasticsearch/client/mocks.ts | 8 +-- .../search/strategies/eql_search/types.ts | 4 +- .../data/server/autocomplete/terms_agg.ts | 9 ++- .../data/server/autocomplete/terms_enum.ts | 37 ++++++------ .../eql_search/eql_search_strategy.ts | 18 ++++-- .../es_search/es_search_strategy.test.ts | 20 +++---- .../es_search/es_search_strategy.ts | 7 ++- .../es_search/request_utils.test.ts | 57 +------------------ .../strategies/es_search/request_utils.ts | 37 +++--------- .../ese_search/ese_search_strategy.ts | 31 ++++++---- .../strategies/ese_search/request_utils.ts | 13 ++--- 11 files changed, 86 insertions(+), 155 deletions(-) diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index f08725d51dfd7..f27bfa9fad38b 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -142,14 +142,12 @@ const createSuccessTransportRequestPromise = ( headers: Record = { [PRODUCT_RESPONSE_HEADER]: 'Elasticsearch' } ): Promise> => { const response = createApiResponse({ body, statusCode, headers }); - const promise = Promise.resolve(response) as Promise>; - return promise; + return Promise.resolve(response) as Promise>; }; -const createErrorTransportRequestPromise = (err: any): Promise => { - const promise = Promise.reject(err); - return promise; +const createErrorTransportRequestPromise = (err: any): Promise> => { + return Promise.reject(err); }; function createApiResponse>( diff --git a/src/plugins/data/common/search/strategies/eql_search/types.ts b/src/plugins/data/common/search/strategies/eql_search/types.ts index cd4da96526f6f..eb87c242d5241 100644 --- a/src/plugins/data/common/search/strategies/eql_search/types.ts +++ b/src/plugins/data/common/search/strategies/eql_search/types.ts @@ -6,14 +6,14 @@ * Side Public License, v 1. */ -import { EqlSearch } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { EqlSearchRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult, TransportRequestOptions } from '@elastic/transport'; import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../types'; export const EQL_SEARCH_STRATEGY = 'eql'; -export type EqlRequestParams = EqlSearch>; +export type EqlRequestParams = EqlSearchRequest; export interface EqlSearchStrategyRequest extends IKibanaSearchRequest { options?: TransportRequestOptions; diff --git a/src/plugins/data/server/autocomplete/terms_agg.ts b/src/plugins/data/server/autocomplete/terms_agg.ts index 0e396b1c51e8e..c5e06a8dcd551 100644 --- a/src/plugins/data/server/autocomplete/terms_agg.ts +++ b/src/plugins/data/server/autocomplete/terms_agg.ts @@ -12,7 +12,6 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ConfigSchema } from '../../config'; import { IFieldType } from '../../common'; import { findIndexPatternById, getFieldByName } from '../data_views'; -import { shimAbortSignal } from '../search'; export async function termsAggSuggestions( config: ConfigSchema, @@ -38,8 +37,12 @@ export async function termsAggSuggestions( const body = await getBody(autocompleteSearchOptions, field ?? fieldName, query, filters); - const promise = esClient.search({ index, body }); - const result = await shimAbortSignal(promise, abortSignal); + const result = await esClient.search( + { index, body }, + { + abortController: { signal: abortSignal }, + } + ); const buckets = get(result.body, 'aggregations.suggestions.buckets') || diff --git a/src/plugins/data/server/autocomplete/terms_enum.ts b/src/plugins/data/server/autocomplete/terms_enum.ts index 2fd3b78d804a4..4acfb6550f5b0 100644 --- a/src/plugins/data/server/autocomplete/terms_enum.ts +++ b/src/plugins/data/server/autocomplete/terms_enum.ts @@ -10,7 +10,6 @@ import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IFieldType } from '../../common'; import { findIndexPatternById, getFieldByName } from '../data_views'; -import { shimAbortSignal } from '../search'; import { ConfigSchema } from '../../config'; export async function termsEnumSuggestions( @@ -30,26 +29,30 @@ export async function termsEnumSuggestions( field = indexPattern && getFieldByName(fieldName, indexPattern); } - const promise = esClient.termsEnum({ - index, - body: { - field: field?.name ?? fieldName, - string: query, - index_filter: { - bool: { - must: [ - ...(filters ?? []), - { - terms: { - _tier: tiers, + const result = await esClient.termsEnum( + { + index, + body: { + field: field?.name ?? fieldName, + string: query, + index_filter: { + bool: { + must: [ + ...(filters ?? []), + { + terms: { + _tier: tiers, + }, }, - }, - ], + ], + }, }, }, }, - }); + { + abortController: { signal: abortSignal }, + } + ); - const result = await shimAbortSignal(promise, abortSignal); return result.body.terms; } diff --git a/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts b/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts index 88a555dd7ab3e..89e36cab10286 100644 --- a/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts @@ -18,7 +18,7 @@ import { import { toEqlKibanaSearchResponse } from './response_utils'; import { EqlSearchResponse } from './types'; import { ISearchStrategy } from '../../types'; -import { getDefaultSearchParams, shimAbortSignal } from '../es_search'; +import { getDefaultSearchParams } from '../es_search'; import { getDefaultAsyncGetParams, getIgnoreThrottled } from '../ese_search/request_utils'; export const eqlSearchStrategyProvider = ( @@ -52,11 +52,17 @@ export const eqlSearchStrategyProvider = ( ...getDefaultAsyncGetParams(null, options), ...request.params, }; - const promise = id - ? client.get({ ...params, id }, request.options) - : // @ts-expect-error EqlRequestParams | undefined is not assignable to EqlRequestParams - client.search(params as EqlSearchStrategyRequest['params'], request.options); - const response = await shimAbortSignal(promise, options.abortSignal); + const response = id + ? await client.get( + { ...params, id }, + { ...request.options, abortController: { signal: options.abortSignal } } + ) + : // @ts-expect-error optional key cannot be used since search doesn't expect undefined + await client.search(params as EqlSearchStrategyRequest['params'], { + ...request.options, + abortController: { signal: options.abortSignal }, + }); + return toEqlKibanaSearchResponse(response as TransportResult); }; diff --git a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts index 973662809bb52..05b35c60c2070 100644 --- a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts +++ b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts @@ -5,12 +5,8 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - -import { - elasticsearchClientMock, - MockedTransportRequestPromise, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../core/server/elasticsearch/client/mocks'; +import type { TransportResult } from '@elastic/transport'; +import { elasticsearchServiceMock } from '../../../../../../core/server/mocks'; import { pluginInitializerContextConfigMock } from '../../../../../../core/server/mocks'; import { esSearchStrategyProvider } from './es_search_strategy'; import { SearchStrategyDependencies } from '../../types'; @@ -27,9 +23,9 @@ describe('ES search strategy', () => { skipped: 2, successful: 7, }, - }; - let mockedApiCaller: MockedTransportRequestPromise; - let mockApiCaller: jest.Mock<() => MockedTransportRequestPromise>; + } as const; + let mockedApiCaller: Promise>; + let mockApiCaller: jest.Mock<() => TransportResult>; const mockLogger: any = { debug: () => {}, }; @@ -37,9 +33,9 @@ describe('ES search strategy', () => { function getMockedDeps(err?: Record) { mockApiCaller = jest.fn().mockImplementation(() => { if (err) { - mockedApiCaller = elasticsearchClientMock.createErrorTransportRequestPromise(err); + mockedApiCaller = elasticsearchServiceMock.createErrorTransportRequestPromise(err); } else { - mockedApiCaller = elasticsearchClientMock.createSuccessTransportRequestPromise( + mockedApiCaller = elasticsearchServiceMock.createSuccessTransportRequestPromise( successBody, { statusCode: 200 } ); @@ -108,7 +104,6 @@ describe('ES search strategy', () => { expect(data.isPartial).toBe(false); expect(data).toHaveProperty('loaded'); expect(data).toHaveProperty('rawResponse'); - expect(mockedApiCaller.abort).not.toBeCalled(); done(); })); @@ -127,7 +122,6 @@ describe('ES search strategy', () => { ...params, track_total_hits: true, }); - expect(mockedApiCaller.abort).toBeCalled(); }); it('throws normalized error if ResponseError is thrown', async (done) => { diff --git a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts index c24aa37082bd8..2a83220710fba 100644 --- a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts @@ -11,7 +11,7 @@ import { first, tap } from 'rxjs/operators'; import type { Logger, SharedGlobalConfig } from 'kibana/server'; import type { ISearchStrategy } from '../../types'; import type { SearchUsage } from '../../collectors'; -import { getDefaultSearchParams, getShardTimeout, shimAbortSignal } from './request_utils'; +import { getDefaultSearchParams, getShardTimeout } from './request_utils'; import { shimHitsTotal, toKibanaSearchResponse } from './response_utils'; import { searchUsageObserver } from '../../collectors/usage'; import { getKbnServerError, KbnServerError } from '../../../../../kibana_utils/server'; @@ -43,8 +43,9 @@ export const esSearchStrategyProvider = ( ...getShardTimeout(config), ...request.params, }; - const promise = esClient.asCurrentUser.search(params); - const { body } = await shimAbortSignal(promise, abortSignal); + const { body } = await esClient.asCurrentUser.search(params, { + abortController: { signal: abortSignal }, + }); const response = shimHitsTotal(body, options); return toKibanaSearchResponse(response); } catch (e) { diff --git a/src/plugins/data/server/search/strategies/es_search/request_utils.test.ts b/src/plugins/data/server/search/strategies/es_search/request_utils.test.ts index 5d1826d92f182..d6e078c71a87d 100644 --- a/src/plugins/data/server/search/strategies/es_search/request_utils.test.ts +++ b/src/plugins/data/server/search/strategies/es_search/request_utils.test.ts @@ -6,19 +6,9 @@ * Side Public License, v 1. */ -import { getShardTimeout, getDefaultSearchParams, shimAbortSignal } from './request_utils'; +import { getShardTimeout, getDefaultSearchParams } from './request_utils'; import { IUiSettingsClient, SharedGlobalConfig } from 'kibana/server'; -const createSuccessTransportRequestPromise = ( - body: any, - { statusCode = 200 }: { statusCode?: number } = {} -) => { - const promise = Promise.resolve({ body, statusCode }) as any; - promise.abort = jest.fn(); - - return promise; -}; - describe('request utils', () => { describe('getShardTimeout', () => { test('returns an empty object if the config does not contain a value', () => { @@ -89,49 +79,4 @@ describe('request utils', () => { }); }); }); - - describe('shimAbortSignal', () => { - test('aborts the promise if the signal is already aborted', async () => { - const promise = createSuccessTransportRequestPromise({ - success: true, - }); - const controller = new AbortController(); - controller.abort(); - shimAbortSignal(promise, controller.signal); - - expect(promise.abort).toHaveBeenCalled(); - }); - - test('aborts the promise if the signal is aborted', () => { - const promise = createSuccessTransportRequestPromise({ - success: true, - }); - const controller = new AbortController(); - shimAbortSignal(promise, controller.signal); - controller.abort(); - - expect(promise.abort).toHaveBeenCalled(); - }); - - test('returns the original promise', async () => { - const promise = createSuccessTransportRequestPromise({ - success: true, - }); - const controller = new AbortController(); - const response = await shimAbortSignal(promise, controller.signal); - - expect(response).toEqual(expect.objectContaining({ body: { success: true } })); - }); - - test('allows the promise to be aborted manually', () => { - const promise = createSuccessTransportRequestPromise({ - success: true, - }); - const controller = new AbortController(); - const enhancedPromise = shimAbortSignal(promise, controller.signal); - - enhancedPromise.abort(); - expect(promise.abort).toHaveBeenCalled(); - }); - }); }); diff --git a/src/plugins/data/server/search/strategies/es_search/request_utils.ts b/src/plugins/data/server/search/strategies/es_search/request_utils.ts index 5c089f974d54f..6b2a13139200c 100644 --- a/src/plugins/data/server/search/strategies/es_search/request_utils.ts +++ b/src/plugins/data/server/search/strategies/es_search/request_utils.ts @@ -6,21 +6,20 @@ * Side Public License, v 1. */ -import type { TransportRequestPromise } from '@elastic/transport'; -import type { Search } from '@elastic/elasticsearch/api/requestParams'; +import { SearchRequest } from '@elastic/elasticsearch/lib/api/types'; import type { IUiSettingsClient, SharedGlobalConfig } from 'kibana/server'; import { UI_SETTINGS } from '../../../../common'; -export function getShardTimeout(config: SharedGlobalConfig): Pick { +export function getShardTimeout(config: SharedGlobalConfig): Pick { const timeout = config.elasticsearch.shardTimeout.asMilliseconds(); return timeout ? { timeout: `${timeout}ms` } : {}; } -export async function getDefaultSearchParams( - uiSettingsClient: IUiSettingsClient -): Promise< - Pick -> { +export async function getDefaultSearchParams(uiSettingsClient: IUiSettingsClient): Promise<{ + max_concurrent_shard_requests?: number; + ignore_unavailable: boolean; + track_total_hits: boolean; +}> { const maxConcurrentShardRequests = await uiSettingsClient.get( UI_SETTINGS.COURIER_MAX_CONCURRENT_SHARD_REQUESTS ); @@ -31,25 +30,3 @@ export async function getDefaultSearchParams( track_total_hits: true, }; } - -/** - * Temporary workaround until https://github.com/elastic/elasticsearch-js/issues/1297 is resolved. - * Shims the `AbortSignal` behavior so that, if the given `signal` aborts, the `abort` method on the - * `TransportRequestPromise` is called, actually performing the cancellation. - * @internal - */ -export const shimAbortSignal = (promise: TransportRequestPromise, signal?: AbortSignal) => { - if (!signal) return promise; - const abortHandler = () => { - promise.abort(); - cleanup(); - }; - const cleanup = () => signal.removeEventListener('abort', abortHandler); - if (signal.aborted) { - promise.abort(); - } else { - signal.addEventListener('abort', abortHandler); - promise.then(cleanup, cleanup); - } - return promise; -}; diff --git a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts index 0b7ed38378c61..1983ff2d8066f 100644 --- a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts @@ -31,7 +31,6 @@ import { getDefaultSearchParams, getShardTimeout, getTotalLoaded, - shimAbortSignal, shimHitsTotal, } from '../es_search'; @@ -68,10 +67,14 @@ export const enhancedEsSearchStrategyProvider = ( )), ...request.params, }; - const promise = id - ? client.asyncSearch.get({ ...params, id }) - : client.asyncSearch.submit(params); - const { body, headers } = await shimAbortSignal(promise, options.abortSignal); + const { body, headers } = id + ? await client.asyncSearch.get( + { ...params, id }, + { abortController: { signal: options.abortSignal } } + ) + : await client.asyncSearch.submit(params, { + abortController: { signal: options.abortSignal }, + }); const response = shimHitsTotal(body.response, options); @@ -115,14 +118,18 @@ export const enhancedEsSearchStrategyProvider = ( }; try { - const promise = client.transport.request({ - method, - path, - body, - querystring, - }); + const esResponse = await client.transport.request( + { + method, + path, + body, + querystring, + }, + { + abortController: { signal: options?.abortSignal }, + } + ); - const esResponse = await shimAbortSignal(promise, options?.abortSignal); const response = esResponse.body as estypes.SearchResponse; return { rawResponse: shimHitsTotal(response, options), diff --git a/src/plugins/data/server/search/strategies/ese_search/request_utils.ts b/src/plugins/data/server/search/strategies/ese_search/request_utils.ts index e224215571ca9..40131af1c44c9 100644 --- a/src/plugins/data/server/search/strategies/ese_search/request_utils.ts +++ b/src/plugins/data/server/search/strategies/ese_search/request_utils.ts @@ -7,11 +7,8 @@ */ import { IUiSettingsClient } from 'kibana/server'; -import { - AsyncSearchGet, - AsyncSearchSubmit, - Search, -} from '@elastic/elasticsearch/api/requestParams'; +import { AsyncSearchGetRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { AsyncSearchSubmitRequest, SearchRequest } from '@elastic/elasticsearch/lib/api/types'; import { ISearchOptions, UI_SETTINGS } from '../../../../common'; import { getDefaultSearchParams } from '../es_search'; import { SearchSessionsConfigSchema } from '../../../../config'; @@ -21,7 +18,7 @@ import { SearchSessionsConfigSchema } from '../../../../config'; */ export async function getIgnoreThrottled( uiSettingsClient: IUiSettingsClient -): Promise> { +): Promise> { const includeFrozen = await uiSettingsClient.get(UI_SETTINGS.SEARCH_INCLUDE_FROZEN); return includeFrozen ? { ignore_throttled: false } : {}; } @@ -35,7 +32,7 @@ export async function getDefaultAsyncSubmitParams( options: ISearchOptions ): Promise< Pick< - AsyncSearchSubmit, + AsyncSearchSubmitRequest, | 'batched_reduce_size' | 'keep_alive' | 'wait_for_completion_timeout' @@ -75,7 +72,7 @@ export async function getDefaultAsyncSubmitParams( export function getDefaultAsyncGetParams( searchSessionsConfig: SearchSessionsConfigSchema | null, options: ISearchOptions -): Pick { +): Pick { const useSearchSessions = searchSessionsConfig?.enabled && !!options.sessionId; return { From 4d76b091c8e36d56a5d3c12fdecc0a298eb3f8b2 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 14:57:28 +0200 Subject: [PATCH 021/172] fix data_views --- .../fetcher/lib/field_capabilities/field_caps_response.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts index 892c447e45389..75bede61e10d8 100644 --- a/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts +++ b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts @@ -116,7 +116,6 @@ export function readFieldCapsResponse( }), {} ), - // @ts-expect-error metadata_field: capsByType[types[0]].metadata_field, }; // This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes @@ -133,7 +132,6 @@ export function readFieldCapsResponse( searchable: isSearchable, aggregatable: isAggregatable, readFromDocValues: shouldReadFieldFromDocValues(isAggregatable, esType), - // @ts-expect-error metadata_field: capsByType[types[0]].metadata_field, }; // This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes From 23d56e5858c215d70091c2b1aefb3b90b9d9581e Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 14:58:34 +0200 Subject: [PATCH 022/172] fix es_ui_shared --- .../__packages_do_not_import__/errors/handle_es_error.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts index cce8cf52e7979..07a681f002f33 100644 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts @@ -6,13 +6,12 @@ * Side Public License, v 1. */ -import { ApiError } from '@elastic/elasticsearch'; import { errors } from '@elastic/elasticsearch'; import { IKibanaResponse, KibanaResponseFactory } from 'kibana/server'; import { getEsCause } from './es_error_parser'; interface EsErrorHandlerParams { - error: ApiError; + error: errors.ElasticsearchClientError; response: KibanaResponseFactory; handleCustomError?: () => IKibanaResponse; } From 54b34face812e5a31f0f520495577ac8dec3ec56 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 14:59:04 +0200 Subject: [PATCH 023/172] fix errors in interactive_setup --- .../interactive_setup/server/elasticsearch_service.test.ts | 6 ++++-- src/plugins/interactive_setup/server/errors.ts | 2 +- src/plugins/interactive_setup/server/mocks.ts | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/interactive_setup/server/elasticsearch_service.test.ts b/src/plugins/interactive_setup/server/elasticsearch_service.test.ts index 9baed65db299d..e0d96e68ce42b 100644 --- a/src/plugins/interactive_setup/server/elasticsearch_service.test.ts +++ b/src/plugins/interactive_setup/server/elasticsearch_service.test.ts @@ -289,7 +289,8 @@ describe('ElasticsearchService', () => { it('treats product check error the same as successful response', async () => { mockConnectionStatusClient.asInternalUser.ping.mockRejectedValue( - new errors.ProductNotSupportedError(interactiveSetupMock.createApiResponse({ body: {} })) + // @ts-expect-error not full interface + new errors.ProductNotSupportedError('product-name', { body: {} }) ); const mockHandler = jest.fn(); @@ -538,7 +539,8 @@ some weird+ca/with it('fails if host is not supported', async () => { mockPingClient.asInternalUser.ping.mockRejectedValue( - new errors.ProductNotSupportedError(interactiveSetupMock.createApiResponse({ body: {} })) + // @ts-expect-error not full interface + new errors.ProductNotSupportedError('product-name', { body: {} }) ); await expect(setupContract.ping('http://localhost:9200')).rejects.toMatchInlineSnapshot( diff --git a/src/plugins/interactive_setup/server/errors.ts b/src/plugins/interactive_setup/server/errors.ts index 5f1d2388b3938..89962e06e0e61 100644 --- a/src/plugins/interactive_setup/server/errors.ts +++ b/src/plugins/interactive_setup/server/errors.ts @@ -14,7 +14,7 @@ import { errors } from '@elastic/elasticsearch'; */ export function getErrorStatusCode(error: any): number { if (error instanceof errors.ResponseError) { - return error.statusCode; + return error.statusCode!; } return error.statusCode || error.status; diff --git a/src/plugins/interactive_setup/server/mocks.ts b/src/plugins/interactive_setup/server/mocks.ts index bfe65edc21c3b..8800572d91669 100644 --- a/src/plugins/interactive_setup/server/mocks.ts +++ b/src/plugins/interactive_setup/server/mocks.ts @@ -13,8 +13,10 @@ function createApiResponseMock( Partial, 'body'>> ): TransportResult { return { + // @ts-expect-error null is not supported statusCode: null, - headers: null, + // @ts-expect-error null is not supported + headers: undefined, warnings: null, meta: {} as any, ...apiResponse, From 57e797ed4290c9307da59322bed2ff30e3bf3698 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 6 Oct 2021 14:59:48 +0200 Subject: [PATCH 024/172] fix errors in ./test folder --- test/common/services/elasticsearch.ts | 4 +++- test/common/services/saved_object_info/saved_object_info.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/common/services/elasticsearch.ts b/test/common/services/elasticsearch.ts index b2dc2b028a4ed..7898a7375d1be 100644 --- a/test/common/services/elasticsearch.ts +++ b/test/common/services/elasticsearch.ts @@ -21,13 +21,15 @@ export function ElasticsearchProvider({ getService }: FtrProviderContext): Kiban const config = getService('config'); if (process.env.TEST_CLOUD) { + // @ts-expect-error TODO make sure Client is assignable to KibanaClient return new Client({ nodes: [formatUrl(config.get('servers.elasticsearch'))], requestTimeout: config.get('timeouts.esRequestTimeout'), }); } else { + // @ts-expect-error TODO make sure Client is assignable to KibanaClient return new Client({ - ssl: { + tls: { ca: fs.readFileSync(CA_CERT_PATH, 'utf-8'), }, nodes: [formatUrl(config.get('servers.elasticsearch'))], diff --git a/test/common/services/saved_object_info/saved_object_info.ts b/test/common/services/saved_object_info/saved_object_info.ts index 61472ea98d879..fc46933fb5d4d 100644 --- a/test/common/services/saved_object_info/saved_object_info.ts +++ b/test/common/services/saved_object_info/saved_object_info.ts @@ -37,7 +37,7 @@ export const types = await pipe( TE.tryCatch( async () => { - const { body } = await new Client({ node }).search({ + const body = await new Client({ node }).search({ index, size: 0, body: query, From 47afcf8e3b89be352c8597a263b0d660b0f06988 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:07:59 +0200 Subject: [PATCH 025/172] add @elastic/transport to the runtime deps --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e55ac2a7a1fdb..a629faa9c83ed 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "@elastic/request-crypto": "1.1.4", "@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set", "@elastic/search-ui-app-search-connector": "^1.6.0", + "@elastic/transport": "^0.0.6", "@emotion/react": "^11.4.0", "@hapi/accept": "^5.0.2", "@hapi/boom": "^9.1.4", From c8a71b0dec5658990e87fbd4be2374d72de226fd Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:09:17 +0200 Subject: [PATCH 026/172] fix errors in packages --- .../src/actions/empty_kibana_index.ts | 4 +- packages/kbn-es-archiver/src/actions/load.ts | 4 +- packages/kbn-es-archiver/src/actions/save.ts | 4 +- .../kbn-es-archiver/src/actions/unload.ts | 4 +- packages/kbn-es-archiver/src/cli.ts | 4 +- packages/kbn-es-archiver/src/es_archiver.ts | 6 +- .../lib/docs/generate_doc_records_stream.ts | 4 +- .../src/lib/docs/index_doc_records_stream.ts | 4 +- .../src/lib/indices/__mocks__/stubs.ts | 4 +- .../src/lib/indices/create_index_stream.ts | 4 +- .../src/lib/indices/delete_index.ts | 15 ++-- .../src/lib/indices/delete_index_stream.ts | 4 +- .../indices/generate_index_records_stream.ts | 52 ++++++------- .../src/lib/indices/kibana_index.ts | 28 +++---- .../kuery/functions/geo_bounding_box.test.ts | 1 - packages/kbn-es/src/utils/native_realm.js | 10 +-- .../kbn-es/src/utils/native_realm.test.js | 74 +++++++++---------- packages/kbn-test/BUILD.bazel | 2 + .../src/es/client_to_kibana_client.ts | 34 +++++++++ packages/kbn-test/src/es/index.ts | 1 + packages/kbn-test/src/es/test_es_cluster.ts | 6 +- packages/kbn-test/src/index.ts | 1 + 22 files changed, 140 insertions(+), 130 deletions(-) create mode 100644 packages/kbn-test/src/es/client_to_kibana_client.ts diff --git a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts b/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts index 90a1d1b3aabc1..96b5b5f8e98e5 100644 --- a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts +++ b/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; @@ -17,7 +17,7 @@ export async function emptyKibanaIndexAction({ log, kbnClient, }: { - client: KibanaClient; + client: Client; log: ToolingLog; kbnClient: KbnClient; }) { diff --git a/packages/kbn-es-archiver/src/actions/load.ts b/packages/kbn-es-archiver/src/actions/load.ts index f8d7878846cd7..619c946f0c988 100644 --- a/packages/kbn-es-archiver/src/actions/load.ts +++ b/packages/kbn-es-archiver/src/actions/load.ts @@ -11,7 +11,7 @@ import { createReadStream } from 'fs'; import { Readable } from 'stream'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { createPromiseFromStreams, concatStreamProviders } from '@kbn/utils'; import { ES_CLIENT_HEADERS } from '../client_headers'; @@ -47,7 +47,7 @@ export async function loadAction({ inputDir: string; skipExisting: boolean; useCreate: boolean; - client: KibanaClient; + client: Client; log: ToolingLog; kbnClient: KbnClient; }) { diff --git a/packages/kbn-es-archiver/src/actions/save.ts b/packages/kbn-es-archiver/src/actions/save.ts index 32308ff96fc14..07ed2b206c1dd 100644 --- a/packages/kbn-es-archiver/src/actions/save.ts +++ b/packages/kbn-es-archiver/src/actions/save.ts @@ -9,7 +9,7 @@ import { resolve, relative } from 'path'; import { createWriteStream, mkdirSync } from 'fs'; import { Readable, Writable } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { createListStream, createPromiseFromStreams } from '@kbn/utils'; @@ -31,7 +31,7 @@ export async function saveAction({ }: { outputDir: string; indices: string | string[]; - client: KibanaClient; + client: Client; log: ToolingLog; raw: boolean; query?: Record; diff --git a/packages/kbn-es-archiver/src/actions/unload.ts b/packages/kbn-es-archiver/src/actions/unload.ts index a70f2991b4809..1c5f4cd5d7d03 100644 --- a/packages/kbn-es-archiver/src/actions/unload.ts +++ b/packages/kbn-es-archiver/src/actions/unload.ts @@ -9,7 +9,7 @@ import { resolve, relative } from 'path'; import { createReadStream } from 'fs'; import { Readable, Writable } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { createPromiseFromStreams } from '@kbn/utils'; @@ -31,7 +31,7 @@ export async function unloadAction({ kbnClient, }: { inputDir: string; - client: KibanaClient; + client: Client; log: ToolingLog; kbnClient: KbnClient; }) { diff --git a/packages/kbn-es-archiver/src/cli.ts b/packages/kbn-es-archiver/src/cli.ts index 355d9065b6d08..dd3e047e908a7 100644 --- a/packages/kbn-es-archiver/src/cli.ts +++ b/packages/kbn-es-archiver/src/cli.ts @@ -20,7 +20,6 @@ import Fs from 'fs'; import { RunWithCommands, createFlagError, CA_CERT_PATH } from '@kbn/dev-utils'; import { readConfigFile, KbnClient } from '@kbn/test'; import { Client } from '@elastic/elasticsearch'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { EsArchiver } from './es_archiver'; @@ -119,8 +118,7 @@ export function runCli() { const esArchiver = new EsArchiver({ log, - // TODO fix the discrepancy - client: client as unknown as KibanaClient, + client, baseDir: process.cwd(), kbnClient, }); diff --git a/packages/kbn-es-archiver/src/es_archiver.ts b/packages/kbn-es-archiver/src/es_archiver.ts index e29160c279447..ed27bc0afcf34 100644 --- a/packages/kbn-es-archiver/src/es_archiver.ts +++ b/packages/kbn-es-archiver/src/es_archiver.ts @@ -9,7 +9,7 @@ import Fs from 'fs'; import Path from 'path'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; @@ -23,14 +23,14 @@ import { } from './actions'; interface Options { - client: KibanaClient; + client: Client; baseDir?: string; log: ToolingLog; kbnClient: KbnClient; } export class EsArchiver { - private readonly client: KibanaClient; + private readonly client: Client; private readonly baseDir: string; private readonly log: ToolingLog; private readonly kbnClient: KbnClient; diff --git a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts index 178f34d50d03d..a0636d6a3f76a 100644 --- a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts @@ -7,7 +7,7 @@ */ import { Transform } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { Stats } from '../stats'; import { Progress } from '../progress'; import { ES_CLIENT_HEADERS } from '../../client_headers'; @@ -21,7 +21,7 @@ export function createGenerateDocRecordsStream({ progress, query, }: { - client: KibanaClient; + client: Client; stats: Stats; progress: Progress; query?: Record; diff --git a/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts b/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts index 2f6b0db62cc3d..749bfd0872353 100644 --- a/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import AggregateError from 'aggregate-error'; import { Writable } from 'stream'; import { Stats } from '../stats'; @@ -14,7 +14,7 @@ import { Progress } from '../progress'; import { ES_CLIENT_HEADERS } from '../../client_headers'; export function createIndexDocRecordsStream( - client: KibanaClient, + client: Client, stats: Stats, progress: Progress, useCreate: boolean = false diff --git a/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts b/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts index d67b7b24a5eae..ded56ddfdf0de 100644 --- a/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts +++ b/packages/kbn-es-archiver/src/lib/indices/__mocks__/stubs.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import sinon from 'sinon'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../../stats'; @@ -67,7 +67,7 @@ const createEsClientError = (errorType: string) => { const indexAlias = (aliases: Record, index: string) => Object.keys(aliases).find((k) => aliases[k] === index); -type StubClient = KibanaClient; +type StubClient = Client; export const createStubClient = ( existingIndices: string[] = [], diff --git a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts index b4ca91248844c..50d13fc728c79 100644 --- a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts @@ -10,7 +10,7 @@ import { Transform, Readable } from 'stream'; import { inspect } from 'util'; import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../stats'; @@ -31,7 +31,7 @@ export function createCreateIndexStream({ skipExisting = false, log, }: { - client: KibanaClient; + client: Client; stats: Stats; skipExisting?: boolean; log: ToolingLog; diff --git a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts b/packages/kbn-es-archiver/src/lib/indices/delete_index.ts index ed63e7c7ff137..a0aee1d60af47 100644 --- a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts +++ b/packages/kbn-es-archiver/src/lib/indices/delete_index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../stats'; import { ES_CLIENT_HEADERS } from '../../client_headers'; @@ -15,7 +15,7 @@ import { ES_CLIENT_HEADERS } from '../../client_headers'; const PENDING_SNAPSHOT_STATUSES = ['INIT', 'STARTED', 'WAITING']; export async function deleteIndex(options: { - client: KibanaClient; + client: Client; stats: Stats; index: string | string[]; log: ToolingLog; @@ -32,6 +32,7 @@ export async function deleteIndex(options: { { ignore: [404], headers: ES_CLIENT_HEADERS, + meta: true, } ); @@ -84,15 +85,13 @@ export function isDeleteWhileSnapshotInProgressError(error: any) { * snapshotting this index to complete. */ export async function waitForSnapshotCompletion( - client: KibanaClient, + client: Client, index: string | string[], log: ToolingLog ) { const isSnapshotPending = async (repository: string, snapshot: string) => { const { - body: { - snapshots: [status], - }, + snapshots: [status], } = await client.snapshot.status( { repository, @@ -108,9 +107,7 @@ export async function waitForSnapshotCompletion( }; const getInProgressSnapshots = async (repository: string) => { - const { - body: { snapshots: inProgressSnapshots }, - } = await client.snapshot.get( + const { snapshots: inProgressSnapshots } = await client.snapshot.get( { repository, snapshot: '_current', diff --git a/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts b/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts index ded7ed7e22fb7..e7763ca251e6f 100644 --- a/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts @@ -7,14 +7,14 @@ */ import { Transform } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog } from '@kbn/dev-utils'; import { Stats } from '../stats'; import { deleteIndex } from './delete_index'; import { cleanKibanaIndices } from './kibana_index'; -export function createDeleteIndexStream(client: KibanaClient, stats: Stats, log: ToolingLog) { +export function createDeleteIndexStream(client: Client, stats: Stats, log: ToolingLog) { return new Transform({ readableObjectMode: true, writableObjectMode: true, diff --git a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts b/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts index d3a25b2cb4daf..6dc5b04e7f31a 100644 --- a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts @@ -6,46 +6,42 @@ * Side Public License, v 1. */ +import type { Client } from '@elastic/elasticsearch'; import { Transform } from 'stream'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { Stats } from '../stats'; import { ES_CLIENT_HEADERS } from '../../client_headers'; -export function createGenerateIndexRecordsStream(client: KibanaClient, stats: Stats) { +export function createGenerateIndexRecordsStream(client: Client, stats: Stats) { return new Transform({ writableObjectMode: true, readableObjectMode: true, async transform(indexOrAlias, enc, callback) { try { - const resp = ( - await client.indices.get( - { - index: indexOrAlias, - filter_path: [ - '*.settings', - '*.mappings', - // remove settings that aren't really settings - '-*.settings.index.creation_date', - '-*.settings.index.uuid', - '-*.settings.index.version', - '-*.settings.index.provided_name', - '-*.settings.index.frozen', - '-*.settings.index.search.throttled', - '-*.settings.index.query', - '-*.settings.index.routing', - ], - }, - { - headers: ES_CLIENT_HEADERS, - } - ) - ).body as Record; + const resp = await client.indices.get( + { + index: indexOrAlias, + filter_path: [ + '*.settings', + '*.mappings', + // remove settings that aren't really settings + '-*.settings.index.creation_date', + '-*.settings.index.uuid', + '-*.settings.index.version', + '-*.settings.index.provided_name', + '-*.settings.index.frozen', + '-*.settings.index.search.throttled', + '-*.settings.index.query', + '-*.settings.index.routing', + ], + }, + { + headers: ES_CLIENT_HEADERS, + } + ); for (const [index, { settings, mappings }] of Object.entries(resp)) { const { - body: { - [index]: { aliases }, - }, + [index]: { aliases }, } = await client.indices.getAlias( { index }, { diff --git a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts index 2fc7e555084b4..069db636c596b 100644 --- a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts +++ b/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts @@ -8,7 +8,7 @@ import { inspect } from 'util'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { ToolingLog } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { Stats } from '../stats'; @@ -23,7 +23,7 @@ export async function deleteKibanaIndices({ stats, log, }: { - client: KibanaClient; + client: Client; stats: Stats; log: ToolingLog; }) { @@ -75,7 +75,7 @@ function isKibanaIndex(index?: string): index is string { ); } -async function fetchKibanaIndices(client: KibanaClient) { +async function fetchKibanaIndices(client: Client) { const resp = await client.cat.indices( { index: '.kibana*', format: 'json' }, { @@ -83,11 +83,11 @@ async function fetchKibanaIndices(client: KibanaClient) { } ); - if (!Array.isArray(resp.body)) { - throw new Error(`expected response to be an array ${inspect(resp.body)}`); + if (!Array.isArray(resp)) { + throw new Error(`expected response to be an array ${inspect(resp)}`); } - return resp.body.map((x: { index?: string }) => x.index).filter(isKibanaIndex); + return resp.map((x: { index?: string }) => x.index).filter(isKibanaIndex); } const delay = (delayInMs: number) => new Promise((resolve) => setTimeout(resolve, delayInMs)); @@ -97,7 +97,7 @@ export async function cleanKibanaIndices({ stats, log, }: { - client: KibanaClient; + client: Client; stats: Stats; log: ToolingLog; }) { @@ -123,11 +123,11 @@ export async function cleanKibanaIndices({ } ); - if (resp.body.total !== resp.body.deleted) { + if (resp.total !== resp.deleted) { log.warning( 'delete by query deleted %d of %d total documents, trying again', - resp.body.deleted, - resp.body.total + resp.deleted, + resp.total ); await delay(200); continue; @@ -144,13 +144,7 @@ export async function cleanKibanaIndices({ stats.deletedIndex('.kibana'); } -export async function createDefaultSpace({ - index, - client, -}: { - index: string; - client: KibanaClient; -}) { +export async function createDefaultSpace({ index, client }: { index: string; client: Client }) { await client.create( { index, diff --git a/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.test.ts b/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.test.ts index 45e6474b22986..cfa496fb5a2a0 100644 --- a/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.test.ts +++ b/packages/kbn-es-query/src/kuery/functions/geo_bounding_box.test.ts @@ -108,7 +108,6 @@ describe('kuery functions', () => { const node = nodeTypes.function.buildNode('geoBoundingBox', 'geo', params); const result = geoBoundingBox.toElasticsearchQuery(node, indexPattern); - // @ts-expect-error @elastic/elasticsearch doesn't support ignore_unmapped in QueryDslGeoBoundingBoxQuery expect(result.geo_bounding_box!.ignore_unmapped).toBe(true); }); diff --git a/packages/kbn-es/src/utils/native_realm.js b/packages/kbn-es/src/utils/native_realm.js index a5051cdb0d89a..8f25b0f3a6972 100644 --- a/packages/kbn-es/src/utils/native_realm.js +++ b/packages/kbn-es/src/utils/native_realm.js @@ -15,7 +15,7 @@ exports.NativeRealm = class NativeRealm { constructor({ elasticPassword, port, log = defaultLog, ssl = false, caCert }) { this._client = new Client({ node: `${ssl ? 'https' : 'http'}://elastic:${elasticPassword}@localhost:${port}`, - ssl: ssl + tls: ssl ? { ca: caCert, rejectUnauthorized: true, @@ -70,9 +70,7 @@ exports.NativeRealm = class NativeRealm { async getReservedUsers(retryOpts = {}) { return await this._autoRetry(retryOpts, async () => { const resp = await this._client.security.getUser(); - const usernames = Object.keys(resp.body).filter( - (user) => resp.body[user].metadata._reserved === true - ); + const usernames = Object.keys(resp).filter((user) => resp[user].metadata._reserved === true); if (!usernames?.length) { throw new Error('no reserved users found, unable to set native realm passwords'); @@ -85,9 +83,7 @@ exports.NativeRealm = class NativeRealm { async isSecurityEnabled(retryOpts = {}) { try { return await this._autoRetry(retryOpts, async () => { - const { - body: { features }, - } = await this._client.xpack.info({ categories: 'features' }); + const { features } = await this._client.xpack.info({ categories: 'features' }); return features.security && features.security.enabled && features.security.available; }); } catch (error) { diff --git a/packages/kbn-es/src/utils/native_realm.test.js b/packages/kbn-es/src/utils/native_realm.test.js index 6d07b1e73b547..e3cb6aee84198 100644 --- a/packages/kbn-es/src/utils/native_realm.test.js +++ b/packages/kbn-es/src/utils/native_realm.test.js @@ -38,12 +38,10 @@ afterAll(() => { function mockXPackInfo(available, enabled) { mockClient.xpack.info.mockImplementation(() => ({ - body: { - features: { - security: { - available, - enabled, - }, + features: { + security: { + available, + enabled, }, }, })); @@ -97,31 +95,29 @@ describe('setPasswords', () => { mockXPackInfo(true, true); mockClient.security.getUser.mockImplementation(() => ({ - body: { - kibana_system: { - metadata: { - _reserved: true, - }, + kibana_system: { + metadata: { + _reserved: true, }, - non_native: { - metadata: { - _reserved: false, - }, + }, + non_native: { + metadata: { + _reserved: false, }, - logstash_system: { - metadata: { - _reserved: true, - }, + }, + logstash_system: { + metadata: { + _reserved: true, }, - elastic: { - metadata: { - _reserved: true, - }, + }, + elastic: { + metadata: { + _reserved: true, }, - beats_system: { - metadata: { - _reserved: true, - }, + }, + beats_system: { + metadata: { + _reserved: true, }, }, })); @@ -176,21 +172,19 @@ Array [ describe('getReservedUsers', () => { it('returns array of reserved usernames', async () => { mockClient.security.getUser.mockImplementation(() => ({ - body: { - kibana_system: { - metadata: { - _reserved: true, - }, + kibana_system: { + metadata: { + _reserved: true, }, - non_native: { - metadata: { - _reserved: false, - }, + }, + non_native: { + metadata: { + _reserved: false, }, - logstash_system: { - metadata: { - _reserved: true, - }, + }, + logstash_system: { + metadata: { + _reserved: true, }, }, })); diff --git a/packages/kbn-test/BUILD.bazel b/packages/kbn-test/BUILD.bazel index efaf01f7137d9..bb86299d3d306 100644 --- a/packages/kbn-test/BUILD.bazel +++ b/packages/kbn-test/BUILD.bazel @@ -41,6 +41,7 @@ RUNTIME_DEPS = [ "//packages/kbn-std", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", + "@npm//@elastic/transport", "@npm//axios", "@npm//@babel/traverse", "@npm//chance", @@ -76,6 +77,7 @@ TYPES_DEPS = [ "//packages/kbn-i18n", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", + "@npm//@elastic/transport", "@npm//del", "@npm//form-data", "@npm//jest", diff --git a/packages/kbn-test/src/es/client_to_kibana_client.ts b/packages/kbn-test/src/es/client_to_kibana_client.ts new file mode 100644 index 0000000000000..6c7301d5a0273 --- /dev/null +++ b/packages/kbn-test/src/es/client_to_kibana_client.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import type { Client } from '@elastic/elasticsearch'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import { Transport } from '@elastic/transport'; +import type { + TransportRequestParams, + TransportRequestOptions, + TransportResult, +} from '@elastic/transport'; + +class KibanaTransport extends Transport { + request(params: TransportRequestParams, options?: TransportRequestOptions) { + const opts: TransportRequestOptions = options || {}; + // Enforce the client to return TransportResult. + // It's required for bwc with responses in 7.x version. + if (opts?.meta === undefined) { + opts.meta = true; + } + return super.request(params, opts) as Promise>; + } +} + +export function convertToKibanaClient(esClient: Client): KibanaClient { + // @ts-expect-error @elastic/elasticsearch fix discrepancy between clients + return esClient.child({ + Transport: KibanaTransport, + }); +} diff --git a/packages/kbn-test/src/es/index.ts b/packages/kbn-test/src/es/index.ts index ccfec67dae848..0c19a6b903742 100644 --- a/packages/kbn-test/src/es/index.ts +++ b/packages/kbn-test/src/es/index.ts @@ -9,3 +9,4 @@ export { createTestEsCluster } from './test_es_cluster'; export type { CreateTestEsClusterOptions, EsTestCluster, ICluster } from './test_es_cluster'; export { esTestConfig } from './es_test_config'; +export { convertToKibanaClient } from './client_to_kibana_client'; diff --git a/packages/kbn-test/src/es/test_es_cluster.ts b/packages/kbn-test/src/es/test_es_cluster.ts index 3df1fdb308564..353823a53645b 100644 --- a/packages/kbn-test/src/es/test_es_cluster.ts +++ b/packages/kbn-test/src/es/test_es_cluster.ts @@ -12,7 +12,6 @@ import del from 'del'; // @ts-expect-error in js import { Cluster } from '@kbn/es'; import { Client } from '@elastic/elasticsearch'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { ToolingLog } from '@kbn/dev-utils'; import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix'; import { esTestConfig } from './es_test_config'; @@ -51,7 +50,7 @@ export interface ICluster { start: () => Promise; stop: () => Promise; cleanup: () => Promise; - getClient: () => KibanaClient; + getClient: () => Client; getHostUrls: () => string[]; } @@ -280,8 +279,7 @@ export function createTestEsCluster< /** * Returns an ES Client to the configured cluster */ - getClient(): KibanaClient { - // @ts-expect-error TODO make sure Client is assignable to KibanaClient + getClient(): Client { return new Client({ node: this.getHostUrls()[0], }); diff --git a/packages/kbn-test/src/index.ts b/packages/kbn-test/src/index.ts index dea2ec9d1035e..0ef9fbfed07a0 100644 --- a/packages/kbn-test/src/index.ts +++ b/packages/kbn-test/src/index.ts @@ -31,6 +31,7 @@ export { CreateTestEsClusterOptions, EsTestCluster, ICluster, + convertToKibanaClient, } from './es'; export { kbnTestConfig, kibanaServerTestUser, kibanaTestUser, adminTestUser } from './kbn'; From 6e0a34f655696dfe32a33421045d06f2a5e523fe Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:11:10 +0200 Subject: [PATCH 027/172] fix erros in src/core --- src/core/server/elasticsearch/client/configure_client.ts | 6 ++++-- src/core/server/elasticsearch/client/types.ts | 4 ++-- src/core/server/index.ts | 1 + .../saved_objects/migrations/core/migration_es_client.ts | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index acf7a14a79945..81a92e6896843 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -48,7 +48,9 @@ export const configureClient = ( } // Enforce the client to return TransportResult. // It's required for bwc with responses in 7.x version. - opts.meta = true; + if (opts.meta === undefined) { + opts.meta = true; + } return super.request(params, opts) as Promise>; } } @@ -162,7 +164,7 @@ const addLogging = (client: Client, logger: Logger) => { function skipProductCheck(client: Client) { const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter( (symbol) => symbol.description === 'product check' - )[0]; + )[1]; // @ts-expect-error `tSymbol` is missing in the index signature of Transport (client.transport || client)[tSymbol] = 2; } diff --git a/src/core/server/elasticsearch/client/types.ts b/src/core/server/elasticsearch/client/types.ts index d88a4c53e84d8..e2db3c9e26cbd 100644 --- a/src/core/server/elasticsearch/client/types.ts +++ b/src/core/server/elasticsearch/client/types.ts @@ -23,10 +23,10 @@ export type ElasticsearchClient = Omit< 'connectionPool' | 'transport' | 'serializer' | 'extend' | 'child' | 'close' > & { transport: { - request( + request( params: TransportRequestParams, options?: TransportRequestOptions - ): Promise; + ): Promise>; }; }; diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 110ac4d5bd973..3207683f21254 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -135,6 +135,7 @@ export type { GetResponse, DeleteDocumentResponse, ElasticsearchConfigPreboot, + ElasticsearchErrorDetails, } from './elasticsearch'; export type { IExternalUrlConfig, IExternalUrlPolicy } from './external_url'; diff --git a/src/core/server/saved_objects/migrations/core/migration_es_client.ts b/src/core/server/saved_objects/migrations/core/migration_es_client.ts index 4d14373e7961b..947f648286221 100644 --- a/src/core/server/saved_objects/migrations/core/migration_es_client.ts +++ b/src/core/server/saved_objects/migrations/core/migration_es_client.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - +import type { Client } from '@elastic/elasticsearch'; import type { TransportRequestOptions } from '@elastic/transport'; import { get } from 'lodash'; import { set } from '@elastic/safer-lodash-set'; @@ -58,7 +58,7 @@ export interface MigrationEsClient { } export function createMigrationEsClient( - client: ElasticsearchClient, + client: ElasticsearchClient | Client, log: Logger, delay?: number ): MigrationEsClient { @@ -69,7 +69,7 @@ export function createMigrationEsClient( throw new Error(`unknown ElasticsearchClient client method [${key}]`); } return await migrationRetryCallCluster( - () => fn.call(client, params, { maxRetries: 0, ...options }), + () => fn.call(client, params, { maxRetries: 0, meta: true, ...options }), log, delay ); From 1647724df3b93f2a276fd90ae943cdb437eb28c9 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:11:51 +0200 Subject: [PATCH 028/172] fix errors in test/ --- test/api_integration/apis/home/sample_data.ts | 6 +++--- .../has_user_index_pattern.ts | 4 ++-- .../apis/kql_telemetry/kql_telemetry.ts | 4 ++-- .../apis/saved_objects/delete_unknown_types.ts | 2 +- .../apis/saved_objects/migrations.ts | 13 +++++++------ .../apis/telemetry/telemetry_optin_notice_seen.ts | 4 +--- test/api_integration/apis/ui_metric/ui_metric.ts | 8 +++----- test/common/services/elasticsearch.ts | 5 +---- test/common/services/es_delete_all_indices.ts | 1 + test/functional/apps/management/_field_formatter.ts | 4 ++-- 10 files changed, 23 insertions(+), 28 deletions(-) diff --git a/test/api_integration/apis/home/sample_data.ts b/test/api_integration/apis/home/sample_data.ts index 1e029bc1e04d7..2525cbe330044 100644 --- a/test/api_integration/apis/home/sample_data.ts +++ b/test/api_integration/apis/home/sample_data.ts @@ -48,7 +48,7 @@ export default function ({ getService }: FtrProviderContext) { }); it('should load elasticsearch index containing sample data with dates relative to current time', async () => { - const { body: resp } = await es.search<{ timestamp: string }>({ + const resp = await es.search<{ timestamp: string }>({ index: 'kibana_sample_data_flights', }); @@ -66,7 +66,7 @@ export default function ({ getService }: FtrProviderContext) { .post(`/api/sample_data/flights?now=${nowString}`) .set('kbn-xsrf', 'kibana'); - const { body: resp } = await es.search<{ timestamp: string }>({ + const resp = await es.search<{ timestamp: string }>({ index: 'kibana_sample_data_flights', }); @@ -85,7 +85,7 @@ export default function ({ getService }: FtrProviderContext) { }); it('should remove elasticsearch index containing sample data', async () => { - const { body: resp } = await es.indices.exists({ + const resp = await es.indices.exists({ index: 'kibana_sample_data_flights', }); expect(resp).to.be(false); diff --git a/test/api_integration/apis/index_patterns/has_user_index_pattern/has_user_index_pattern.ts b/test/api_integration/apis/index_patterns/has_user_index_pattern/has_user_index_pattern.ts index 8dfb892acfd90..8fc4e860e5d9c 100644 --- a/test/api_integration/apis/index_patterns/has_user_index_pattern/has_user_index_pattern.ts +++ b/test/api_integration/apis/index_patterns/has_user_index_pattern/has_user_index_pattern.ts @@ -17,11 +17,11 @@ export default function ({ getService }: FtrProviderContext) { describe('has user index pattern API', () => { beforeEach(async () => { await esArchiver.emptyKibanaIndex(); - if ((await es.indices.exists({ index: 'metrics-test' })).body) { + if (await es.indices.exists({ index: 'metrics-test' })) { await es.indices.delete({ index: 'metrics-test' }); } - if ((await es.indices.exists({ index: 'logs-test' })).body) { + if (await es.indices.exists({ index: 'logs-test' })) { await es.indices.delete({ index: 'logs-test' }); } }); diff --git a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts index 5770ed0866a90..4825b454bc42f 100644 --- a/test/api_integration/apis/kql_telemetry/kql_telemetry.ts +++ b/test/api_integration/apis/kql_telemetry/kql_telemetry.ts @@ -40,7 +40,7 @@ export default function ({ getService }: FtrProviderContext) { index: '.kibana', q: 'type:kql-telemetry', }) - .then(({ body: response }) => { + .then((response) => { const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry'); expect(kqlTelemetryDoc.optInCount).to.be(1); }); @@ -58,7 +58,7 @@ export default function ({ getService }: FtrProviderContext) { index: '.kibana', q: 'type:kql-telemetry', }) - .then(({ body: response }) => { + .then((response) => { const kqlTelemetryDoc = get(response, 'hits.hits[0]._source.kql-telemetry'); expect(kqlTelemetryDoc.optOutCount).to.be(1); }); diff --git a/test/api_integration/apis/saved_objects/delete_unknown_types.ts b/test/api_integration/apis/saved_objects/delete_unknown_types.ts index 42caa753683e1..af9e413de0279 100644 --- a/test/api_integration/apis/saved_objects/delete_unknown_types.ts +++ b/test/api_integration/apis/saved_objects/delete_unknown_types.ts @@ -31,7 +31,7 @@ export default function ({ getService }: FtrProviderContext) { }); const fetchIndexContent = async () => { - const { body } = await es.search<{ type: string }>({ + const body = await es.search<{ type: string }>({ index: '.kibana', body: { size: 100, diff --git a/test/api_integration/apis/saved_objects/migrations.ts b/test/api_integration/apis/saved_objects/migrations.ts index 0877998ca6c1f..cba62ee51763d 100644 --- a/test/api_integration/apis/saved_objects/migrations.ts +++ b/test/api_integration/apis/saved_objects/migrations.ts @@ -14,7 +14,8 @@ import uuidv5 from 'uuid/v5'; import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import expect from '@kbn/expect'; -import { ElasticsearchClient, SavedObjectsType } from 'src/core/server'; +import { SavedObjectsType } from 'src/core/server'; +import { Client as ElasticsearchClient } from '@elastic/elasticsearch'; import { DocumentMigrator, @@ -136,7 +137,7 @@ export default ({ getService }: FtrProviderContext) => { const migrationATemplate = await esClient.indices.existsTemplate({ name: 'migration_a_template', }); - expect(migrationATemplate.body).to.be.ok(); + expect(migrationATemplate).to.be.ok(); const result = await migrateIndex({ esClient, @@ -150,12 +151,12 @@ export default ({ getService }: FtrProviderContext) => { name: 'migration_a_template', }); - expect(migrationATemplateAfter.body).not.to.be.ok(); + expect(migrationATemplateAfter).not.to.be.ok(); const migrationTestATemplateAfter = await esClient.indices.existsTemplate({ name: 'migration_test_a_template', }); - expect(migrationTestATemplateAfter.body).to.be.ok(); + expect(migrationTestATemplateAfter).to.be.ok(); expect(_.omit(result, 'elapsedMs')).to.eql({ destIndex: '.migration-a_2', sourceIndex: '.migration-a_1', @@ -451,7 +452,7 @@ export default ({ getService }: FtrProviderContext) => { { status: 'skipped', destIndex: undefined }, ]); - const { body } = await esClient.cat.indices({ index: '.migration-c*', format: 'json' }); + const body = await esClient.cat.indices({ index: '.migration-c*', format: 'json' }); // It only created the original and the dest expect(_.map(body, 'index').sort()).to.eql(['.migration-c_1', '.migration-c_2']); @@ -747,7 +748,7 @@ async function migrateIndex({ } async function fetchDocs(esClient: ElasticsearchClient, index: string) { - const { body } = await esClient.search({ index }); + const body = await esClient.search({ index }); return body.hits.hits .map((h) => ({ diff --git a/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts b/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts index a76d09481eca1..a2c48996069b2 100644 --- a/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts +++ b/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts @@ -25,9 +25,7 @@ export default function optInTest({ getService }: FtrProviderContext) { await supertest.put('/api/telemetry/v2/userHasSeenNotice').set('kbn-xsrf', 'xxx').expect(200); - const { - body: { _source }, - } = await client.get<{ telemetry: { userHasSeenNotice: boolean } }>({ + const { _source } = await client.get<{ telemetry: { userHasSeenNotice: boolean } }>({ index: '.kibana', id: 'telemetry:telemetry', }); diff --git a/test/api_integration/apis/ui_metric/ui_metric.ts b/test/api_integration/apis/ui_metric/ui_metric.ts index 3f0a4c0778911..83f84af4eb9bd 100644 --- a/test/api_integration/apis/ui_metric/ui_metric.ts +++ b/test/api_integration/apis/ui_metric/ui_metric.ts @@ -50,7 +50,7 @@ export default function ({ getService }: FtrProviderContext) { .send({ report }) .expect(200); - const { body: response } = await es.search({ index: '.kibana', q: 'type:ui-metric' }); + const response = await es.search({ index: '.kibana', q: 'type:ui-metric' }); const ids = response.hits.hits.map(({ _id }: { _id: string }) => _id); expect(ids.includes('ui-metric:myApp:myEvent')).to.eql(true); }); @@ -75,7 +75,7 @@ export default function ({ getService }: FtrProviderContext) { .send({ report }) .expect(200); - const { body: response } = await es.search({ index: '.kibana', q: 'type:ui-metric' }); + const response = await es.search({ index: '.kibana', q: 'type:ui-metric' }); const ids = response.hits.hits.map(({ _id }: { _id: string }) => _id); expect(ids.includes('ui-metric:myApp:myEvent')).to.eql(true); expect(ids.includes(`ui-metric:myApp:${uniqueEventName}`)).to.eql(true); @@ -99,9 +99,7 @@ export default function ({ getService }: FtrProviderContext) { .expect(200); const { - body: { - hits: { hits }, - }, + hits: { hits }, } = await es.search({ index: '.kibana', q: 'type:ui-metric' }); const countTypeEvent = hits.find( diff --git a/test/common/services/elasticsearch.ts b/test/common/services/elasticsearch.ts index 7898a7375d1be..2b093bac814b7 100644 --- a/test/common/services/elasticsearch.ts +++ b/test/common/services/elasticsearch.ts @@ -10,24 +10,21 @@ import { format as formatUrl } from 'url'; import fs from 'fs'; import { Client } from '@elastic/elasticsearch'; import { CA_CERT_PATH } from '@kbn/dev-utils'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { FtrProviderContext } from '../ftr_provider_context'; /* registers Kibana-specific @elastic/elasticsearch client instance. */ -export function ElasticsearchProvider({ getService }: FtrProviderContext): KibanaClient { +export function ElasticsearchProvider({ getService }: FtrProviderContext): Client { const config = getService('config'); if (process.env.TEST_CLOUD) { - // @ts-expect-error TODO make sure Client is assignable to KibanaClient return new Client({ nodes: [formatUrl(config.get('servers.elasticsearch'))], requestTimeout: config.get('timeouts.esRequestTimeout'), }); } else { - // @ts-expect-error TODO make sure Client is assignable to KibanaClient return new Client({ tls: { ca: fs.readFileSync(CA_CERT_PATH, 'utf-8'), diff --git a/test/common/services/es_delete_all_indices.ts b/test/common/services/es_delete_all_indices.ts index 3443ef23c8ed0..c0ffa44c2e2c3 100644 --- a/test/common/services/es_delete_all_indices.ts +++ b/test/common/services/es_delete_all_indices.ts @@ -37,6 +37,7 @@ export function EsDeleteAllIndicesProvider({ getService }: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); const indices = Object.keys(resp.body) as string[]; diff --git a/test/functional/apps/management/_field_formatter.ts b/test/functional/apps/management/_field_formatter.ts index 2377e714418ee..838d20ccdfb50 100644 --- a/test/functional/apps/management/_field_formatter.ts +++ b/test/functional/apps/management/_field_formatter.ts @@ -423,7 +423,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { let testDocumentId: string; before(async () => { - if ((await es.indices.exists({ index: indexTitle })).body) { + if (await es.indices.exists({ index: indexTitle })) { await es.indices.delete({ index: indexTitle }); } @@ -447,7 +447,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }, {} as Record), refresh: 'wait_for', }); - testDocumentId = docResult.body._id; + testDocumentId = docResult._id; const indexPatternResult = await indexPatterns.create( { title: indexTitle }, From 4ed2d115ef7ecdabfdf369c34563a2b195622d29 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:12:34 +0200 Subject: [PATCH 029/172] fix an error in actions plugin --- .../server/builtin_action_types/es_index.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/actions/server/builtin_action_types/es_index.test.ts b/x-pack/plugins/actions/server/builtin_action_types/es_index.test.ts index 738fa236f89c0..50a1deba5af20 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/es_index.test.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/es_index.test.ts @@ -8,7 +8,7 @@ jest.mock('./lib/send_email', () => ({ sendEmail: jest.fn(), })); - +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { validateConfig, validateParams } from '../lib'; import { createActionTypeRegistry } from './index.test'; import { actionsMock } from '../mocks'; @@ -216,10 +216,12 @@ describe('execute()', () => { }); const calls = scopedClusterClient.bulk.mock.calls; - const timeValue = ((calls[0][0]?.body as unknown[])[1] as Record) - .field_to_use_for_time; + const timeValue = ( + ((calls[0][0] as estypes.BulkRequest)?.body as unknown[])[1] as Record + ).field_to_use_for_time; expect(timeValue).toBeInstanceOf(Date); - delete ((calls[0][0]?.body as unknown[])[1] as Record).field_to_use_for_time; + delete (((calls[0][0] as estypes.BulkRequest)?.body as unknown[])[1] as Record) + .field_to_use_for_time; expect(calls).toMatchInlineSnapshot(` Array [ Array [ From abe4e73da01116517792656ef546b088ba7d5f6f Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:14:22 +0200 Subject: [PATCH 030/172] woraround and fix errors in APM plugin --- .../apm/scripts/aggregate-latency-metrics/index.ts | 8 +++----- .../create-functional-tests-archive/index.ts | 1 + .../apm/scripts/shared/create-or-update-index.ts | 8 +++----- x-pack/plugins/apm/scripts/shared/get_es_client.ts | 14 ++++++-------- .../apm/scripts/upload-telemetry-data/index.ts | 14 ++++---------- .../apm_telemetry/collect_data_telemetry/index.ts | 4 ++-- .../create_es_client/cancel_es_request_on_abort.ts | 5 +++-- .../create_internal_es_client/index.ts | 3 +-- .../java/gc/fetch_and_transform_gc_metrics.ts | 10 +++++++--- .../create_agent_config_index.ts | 1 - .../apm/server/routes/register_routes/index.ts | 4 ++-- 11 files changed, 32 insertions(+), 40 deletions(-) diff --git a/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts b/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts index c2d989c1dbf21..cc465e43a3eb0 100644 --- a/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts +++ b/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts @@ -135,11 +135,9 @@ export async function aggregateLatencyMetrics() { destOptions = parseIndexUrl(dest); destClient = getEsClient({ node: destOptions.node }); - const mappings = ( - await sourceClient.indices.getMapping({ - index: sourceOptions.index, - }) - ).body; + const mappings = await sourceClient.indices.getMapping({ + index: sourceOptions.index, + }); const lastMapping = mappings[Object.keys(mappings)[0]]; diff --git a/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts b/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts index 9ef2c5a52bff1..559f746ab50f2 100644 --- a/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts +++ b/x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts @@ -144,6 +144,7 @@ async function run() { // profile const indicesWithDocs = response.body.aggregations?.index.buckets.map( + // @ts-expect-error bucket has any type (bucket) => bucket.key as string ) ?? []; diff --git a/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts b/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts index 8bab4df9006f5..39f398354422f 100644 --- a/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts +++ b/x-pack/plugins/apm/scripts/shared/create-or-update-index.ts @@ -36,11 +36,9 @@ export async function createOrUpdateIndex({ delete settings?.index?.number_of_shards; delete settings?.index?.sort; - const indexExists = ( - await client.indices.exists({ - index: indexName, - }) - ).body as unknown; + const indexExists = await client.indices.exists({ + index: indexName, + }); if (!indexExists) { await client.indices.create({ diff --git a/x-pack/plugins/apm/scripts/shared/get_es_client.ts b/x-pack/plugins/apm/scripts/shared/get_es_client.ts index 42833d28adcb2..1533efa82ba63 100644 --- a/x-pack/plugins/apm/scripts/shared/get_es_client.ts +++ b/x-pack/plugins/apm/scripts/shared/get_es_client.ts @@ -6,7 +6,7 @@ */ import { Client } from '@elastic/elasticsearch'; -import { ApiKeyAuth, BasicAuth } from '@elastic/elasticsearch/lib/pool'; +import { ApiKeyAuth, BasicAuth } from '@elastic/transport/lib/types'; import { ESSearchResponse, ESSearchRequest, @@ -20,10 +20,11 @@ export function getEsClient({ }: { node: string; auth?: BasicAuth | ApiKeyAuth; -}) { + // TODO ask owners to fix +}): any { const client = new Client({ node, - ssl: { + tls: { rejectUnauthorized: false, }, requestTimeout: 120000, @@ -36,14 +37,11 @@ export function getEsClient({ TDocument = unknown, TSearchRequest extends ESSearchRequest = ESSearchRequest >(request: TSearchRequest) { - const response = await originalSearch(request); + const response = await originalSearch(request); return { ...response, - body: response.body as unknown as ESSearchResponse< - TDocument, - TSearchRequest - >, + body: response as unknown as ESSearchResponse, }; } diff --git a/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts index 0dab75cfba9c7..998a39d650e86 100644 --- a/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts +++ b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts @@ -17,8 +17,6 @@ import { argv } from 'yargs'; import { Logger } from 'kibana/server'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { CollectTelemetryParams } from '../../server/lib/apm_telemetry/collect_data_telemetry'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { unwrapEsResponse } from '../../../observability/server/utils/unwrap_es_response'; import { downloadTelemetryTemplate } from '../shared/download-telemetry-template'; import { mergeApmTelemetryMapping } from '../../common/apm_telemetry'; import { generateSampleDocuments } from './generate-sample-documents'; @@ -82,19 +80,15 @@ async function uploadData() { apmCustomLinkIndex: '.apm-custom-links', apmAgentConfigurationIndex: '.apm-agent-configuration', }, + // TODO ask owners to fix search: (body) => { - return unwrapEsResponse(client.search(body)) as Promise; + return client.search(body); }, indicesStats: (body) => { - return unwrapEsResponse(client.indices.stats(body)); + return client.indices.stats(body); }, transportRequest: ((params) => { - return unwrapEsResponse( - client.transport.request({ - method: params.method, - path: params.path, - }) - ); + return; }) as CollectTelemetryParams['transportRequest'], }, }); diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts index 22a2090dbb6cd..9b5820767690f 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts @@ -7,7 +7,7 @@ import { merge } from 'lodash'; import { Logger } from 'kibana/server'; -import { IndicesStats } from '@elastic/elasticsearch/api/requestParams'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESSearchRequest, ESSearchResponse, @@ -22,7 +22,7 @@ type TelemetryTaskExecutor = (params: { params: TSearchRequest ): Promise>; indicesStats( - params: IndicesStats + params: estypes.IndicesStatsRequest // promise returned by client has an abort property // so we cannot use its ReturnType ): Promise<{ diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts index 3cacabe61b7bb..a5e32f8a942bc 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts @@ -5,20 +5,21 @@ * 2.0. */ -import { TransportRequestPromise } from '@elastic/transport'; import { KibanaRequest } from 'src/core/server'; -export function cancelEsRequestOnAbort>( +export function cancelEsRequestOnAbort( promise: T, request: KibanaRequest ) { const subscription = request.events.aborted$.subscribe(() => { + // @ts-expect-error fix abort promise.abort(); }); // using .catch() here means unsubscribe will be called // after it has thrown an error, so we use .then(onSuccess, onFailure) // syntax + // @ts-expect-error fix abort promise.then( () => subscription.unsubscribe(), () => subscription.unsubscribe() diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts index 98c1731349d10..aff54d4bbc650 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { TransportRequestPromise } from '@elastic/transport'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { unwrapEsResponse } from '../../../../../../observability/server'; import { APMRouteHandlerResources } from '../../../../routes/typings'; @@ -39,7 +38,7 @@ export function createInternalESClient({ params, }: { requestType: string; - cb: () => TransportRequestPromise; + cb: () => Promise; params: Record; } ) { diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts index 8231e4d3c6faa..bad30750fb6b2 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts @@ -97,6 +97,7 @@ export async function fetchAndTransformGcMetrics({ // get the derivative, which is the delta y derivative: { derivative: { + // @ts-expect-error AggregationsBucketsPath is not valid buckets_path: 'max', }, }, @@ -104,6 +105,7 @@ export async function fetchAndTransformGcMetrics({ // needs to be excluded value: { bucket_script: { + // @ts-expect-error AggregationsBucketsPath is not valid buckets_path: { value: 'derivative' }, script: 'params.value > 0.0 ? params.value : 0.0', }, @@ -115,7 +117,7 @@ export async function fetchAndTransformGcMetrics({ }, }, }); - + // @ts-expect-error AggregationsBucketsPath is not valid const response = await apmEventClient.search(operationName, params); const { aggregations } = response; @@ -127,11 +129,11 @@ export async function fetchAndTransformGcMetrics({ series: [], }; } - + // @ts-expect-error aggregations is unknown const series = aggregations.per_pool.buckets.map((poolBucket, i) => { const label = poolBucket.key as string; const timeseriesData = poolBucket.timeseries; - + // @ts-expect-error bucket has any type const data = timeseriesData.buckets.map((bucket) => { // derivative/value will be undefined for the first hit and if the `max` value is null const bucketValue = bucket.value?.value; @@ -146,7 +148,9 @@ export async function fetchAndTransformGcMetrics({ }); const values = data + // @ts-expect-error coordinate has any type .map((coordinate) => coordinate.y) + // @ts-expect-error y has any type .filter((y) => y !== null); const overallValue = sum(values) / values.length; diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index.ts b/x-pack/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index.ts index f43938891f1f0..a14019f4dbdec 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index.ts +++ b/x-pack/plugins/apm/server/lib/settings/agent_configuration/create_agent_config_index.ts @@ -36,7 +36,6 @@ const mappings: Mappings = { dynamic_templates: [ { // force string to keyword (instead of default of text + keyword) - // @ts-expect-error @elastic/elasticsearch expects here mapping: MappingPropertyBase strings: { match_mapping_type: 'string', mapping: { diff --git a/x-pack/plugins/apm/server/routes/register_routes/index.ts b/x-pack/plugins/apm/server/routes/register_routes/index.ts index 38db62e7cf240..dc902a9d61382 100644 --- a/x-pack/plugins/apm/server/routes/register_routes/index.ts +++ b/x-pack/plugins/apm/server/routes/register_routes/index.ts @@ -8,7 +8,7 @@ import Boom from '@hapi/boom'; import * as t from 'io-ts'; import { KibanaRequest, RouteRegistrar } from 'src/core/server'; -import { RequestAbortedError } from '@elastic/elasticsearch'; +import { errors } from '@elastic/elasticsearch'; import agent from 'elastic-apm-node'; import { ServerRouteRepository } from '@kbn/server-route-repository'; import { merge } from 'lodash'; @@ -170,7 +170,7 @@ export function registerRoutes({ }, }; - if (error instanceof RequestAbortedError) { + if (error instanceof errors.RequestAbortedError) { return response.custom(merge(opts, CLIENT_CLOSED_REQUEST)); } From 79348ad8ee1cfdd775078bcaa8d846a6b4ed64c9 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:14:59 +0200 Subject: [PATCH 031/172] fix errors in canvas --- x-pack/plugins/canvas/types/strategy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/canvas/types/strategy.ts b/x-pack/plugins/canvas/types/strategy.ts index 9f6488e275777..c7a83655049d6 100644 --- a/x-pack/plugins/canvas/types/strategy.ts +++ b/x-pack/plugins/canvas/types/strategy.ts @@ -27,5 +27,5 @@ export interface EssqlSearchStrategyResponse { }>; rows: any[]; - rawResponse: TransportResult; + rawResponse: TransportResult; } From f4a7dfdd7490e5a7a5fe4056d28c9f05304be0e4 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:15:37 +0200 Subject: [PATCH 032/172] fix errors in event_log --- .../event_log/server/es/cluster_client_adapter.test.ts | 7 ++++--- .../plugins/event_log/server/es/cluster_client_adapter.ts | 5 ++--- x-pack/plugins/event_log/server/es/context.test.ts | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts index f4140298928b6..efafb0b465855 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts @@ -16,7 +16,8 @@ import { findOptionsSchema } from '../event_log_client'; import { delay } from '../lib/delay'; import { times } from 'lodash'; import { DeeplyMockedKeys } from '@kbn/utility-types/jest'; -import { estypes, RequestEvent } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/types'; +import type { TransportResult } from '@elastic/transport'; type MockedLogger = ReturnType; @@ -1270,10 +1271,10 @@ type RetryableFunction = () => boolean; const RETRY_UNTIL_DEFAULT_COUNT = 20; const RETRY_UNTIL_DEFAULT_WAIT = 1000; // milliseconds -function asApiResponse(body: T): RequestEvent { +function asApiResponse(body: T): TransportResult { return { body, - } as RequestEvent; + } as TransportResult; } async function retryUntil( diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts index 8d7c1e637bb1e..55bdb5a16f8c0 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts @@ -255,9 +255,7 @@ export class ClusterClientAdapter { const existingAliasOptions = pick(currentAliases.aliases[aliasName], [ 'is_write_index', diff --git a/x-pack/plugins/event_log/server/es/context.test.ts b/x-pack/plugins/event_log/server/es/context.test.ts index 0fe63ffb6217a..aac6496571720 100644 --- a/x-pack/plugins/event_log/server/es/context.test.ts +++ b/x-pack/plugins/event_log/server/es/context.test.ts @@ -9,7 +9,7 @@ import { createEsContext } from './context'; import { ElasticsearchClient, Logger } from '../../../../../src/core/server'; import { elasticsearchServiceMock, loggingSystemMock } from '../../../../../src/core/server/mocks'; import { DeeplyMockedKeys } from '@kbn/utility-types/jest'; -import { RequestEvent } from '@elastic/elasticsearch'; +import type { TransportResult } from '@elastic/transport'; jest.mock('../lib/../../../../package.json', () => ({ version: '1.2.3' })); jest.mock('./init'); @@ -63,6 +63,7 @@ describe('createEsContext', () => { kibanaVersion: '1.2.3', elasticsearchClientPromise: Promise.resolve(elasticsearchClient), }); + elasticsearchClient.indices.existsTemplate.mockResolvedValue(asApiResponse(false)); elasticsearchClient.indices.existsIndexTemplate.mockResolvedValue(asApiResponse(false)); elasticsearchClient.indices.existsAlias.mockResolvedValue(asApiResponse(false)); @@ -113,8 +114,8 @@ describe('createEsContext', () => { }); }); -function asApiResponse(body: T): RequestEvent { +function asApiResponse(body: T): TransportResult { return { body, - } as RequestEvent; + } as TransportResult; } From 6c105fc25528811a3aebb4311db9a6188eb45167 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:16:59 +0200 Subject: [PATCH 033/172] fix errors in fleet --- x-pack/plugins/fleet/server/errors/index.ts | 6 ++- .../plugins/fleet/server/routes/app/index.ts | 5 ++- .../services/agents/authenticate.test.ts | 11 ++--- .../server/services/agents/reassign.test.ts | 8 +++- .../server/services/agents/unenroll.test.ts | 42 ++++++++++++------- .../services/artifacts/artifacts.test.ts | 3 +- .../server/services/artifacts/client.test.ts | 2 + .../fleet/server/services/artifacts/mocks.ts | 4 +- .../fleet/server/services/artifacts/utils.ts | 6 ++- .../elasticsearch/template/install.test.ts | 7 +++- .../epm/elasticsearch/template/install.ts | 1 - .../epm/elasticsearch/template/template.ts | 2 +- .../elasticsearch/transform/transform.test.ts | 2 + 13 files changed, 66 insertions(+), 33 deletions(-) diff --git a/x-pack/plugins/fleet/server/errors/index.ts b/x-pack/plugins/fleet/server/errors/index.ts index f31719d6c4364..dfe2b9084eab6 100644 --- a/x-pack/plugins/fleet/server/errors/index.ts +++ b/x-pack/plugins/fleet/server/errors/index.ts @@ -6,6 +6,8 @@ */ /* eslint-disable max-classes-per-file */ +import type { ElasticsearchErrorDetails } from 'src/core/server'; + import { isESClientError } from './utils'; export { defaultIngestErrorHandler, ingestErrorToResponseOptions } from './handlers'; @@ -63,8 +65,8 @@ export class ArtifactsElasticsearchError extends IngestManagerError { constructor(public readonly meta: Error) { super( `${ - isESClientError(meta) && meta.meta.body?.error?.reason - ? meta.meta.body?.error?.reason + isESClientError(meta) && (meta.meta.body as ElasticsearchErrorDetails)?.error?.reason + ? (meta.meta.body as ElasticsearchErrorDetails)?.error?.reason : `Elasticsearch error while working with artifacts: ${meta.message}` }` ); diff --git a/x-pack/plugins/fleet/server/routes/app/index.ts b/x-pack/plugins/fleet/server/routes/app/index.ts index f2fc6302c8ce5..5314597f3af47 100644 --- a/x-pack/plugins/fleet/server/routes/app/index.ts +++ b/x-pack/plugins/fleet/server/routes/app/index.ts @@ -39,7 +39,10 @@ export const getCheckPermissionsHandler: RequestHandler = async (context, reques export const generateServiceTokenHandler: RequestHandler = async (context, request, response) => { const esClient = context.core.elasticsearch.client.asCurrentUser; try { - const { body: tokenResponse } = await esClient.transport.request({ + const { body: tokenResponse } = await esClient.transport.request<{ + created?: boolean; + token?: GenerateServiceTokenResponse; + }>({ method: 'POST', path: `_security/service/elastic/fleet-server/credential/token/token-${Date.now()}`, }); diff --git a/x-pack/plugins/fleet/server/services/agents/authenticate.test.ts b/x-pack/plugins/fleet/server/services/agents/authenticate.test.ts index eaa240165e853..9837fa17503be 100644 --- a/x-pack/plugins/fleet/server/services/agents/authenticate.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/authenticate.test.ts @@ -18,13 +18,11 @@ describe('test agent autenticate services', () => { body: { hits: { hits: [ + // @ts-expect-error not full interface { - // @ts-expect-error _id: 'agent1', _source: { - // @ts-expect-error active: true, - // @ts-expect-error access_api_key_id: 'pedTuHIBTEDt93wW0Fhr', }, }, @@ -47,13 +45,11 @@ describe('test agent autenticate services', () => { body: { hits: { hits: [ + // @ts-expect-error not full interface { - // @ts-expect-error _id: 'agent1', _source: { - // @ts-expect-error active: true, - // @ts-expect-error access_api_key_id: 'pedTuHIBTEDt93wW0Fhr', }, }, @@ -137,10 +133,11 @@ describe('test agent autenticate services', () => { const mockEsClient = elasticsearchServiceMock.createInternalClient(); mockEsClient.search.mockResolvedValue({ + // @ts-expect-error not full interface body: { hits: { - // @ts-expect-error hits: [], + total: 0, }, }, }); diff --git a/x-pack/plugins/fleet/server/services/agents/reassign.test.ts b/x-pack/plugins/fleet/server/services/agents/reassign.test.ts index a87432c639249..71935ffa5f90c 100644 --- a/x-pack/plugins/fleet/server/services/agents/reassign.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/reassign.test.ts @@ -6,6 +6,7 @@ */ import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { SavedObject } from 'kibana/server'; import type { AgentPolicy } from '../../types'; @@ -47,7 +48,10 @@ describe('reassignAgent (singular)', () => { expect(esClient.update).toBeCalledTimes(1); const calledWith = esClient.update.mock.calls[0]; expect(calledWith[0]?.id).toBe(agentInRegularDoc._id); - expect(calledWith[0]?.body?.doc).toHaveProperty('policy_id', regularAgentPolicySO.id); + expect((calledWith[0] as estypes.UpdateRequest)?.body?.doc).toHaveProperty( + 'policy_id', + regularAgentPolicySO.id + ); }); it('cannot reassign from regular agent policy to hosted', async () => { @@ -85,7 +89,7 @@ describe('reassignAgents (plural)', () => { // calls ES update with correct values const calledWith = esClient.bulk.mock.calls[0][0]; // only 1 are regular and bulk write two line per update - expect(calledWith.body?.length).toBe(2); + expect((calledWith as estypes.BulkRequest).body?.length).toBe(2); // @ts-expect-error expect(calledWith.body[0].update._id).toEqual(agentInRegularDoc._id); }); diff --git a/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts b/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts index 3621bc5025ab3..7f744ba6a59f4 100644 --- a/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts +++ b/x-pack/plugins/fleet/server/services/agents/unenroll.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { elasticsearchServiceMock, savedObjectsClientMock } from 'src/core/server/mocks'; import type { SavedObject } from 'kibana/server'; @@ -43,7 +43,9 @@ describe('unenrollAgent (singular)', () => { expect(esClient.update).toBeCalledTimes(1); const calledWith = esClient.update.mock.calls[0]; expect(calledWith[0]?.id).toBe(agentInRegularDoc._id); - expect(calledWith[0]?.body).toHaveProperty('doc.unenrollment_started_at'); + expect((calledWith[0] as estypes.UpdateRequest)?.body).toHaveProperty( + 'doc.unenrollment_started_at' + ); }); it('cannot unenroll from hosted agent policy by default', async () => { @@ -71,7 +73,9 @@ describe('unenrollAgent (singular)', () => { expect(esClient.update).toBeCalledTimes(1); const calledWith = esClient.update.mock.calls[0]; expect(calledWith[0]?.id).toBe(agentInHostedDoc._id); - expect(calledWith[0]?.body).toHaveProperty('doc.unenrollment_started_at'); + expect((calledWith[0] as estypes.UpdateRequest)?.body).toHaveProperty( + 'doc.unenrollment_started_at' + ); }); it('can unenroll from hosted agent policy with force=true and revoke=true', async () => { @@ -81,7 +85,7 @@ describe('unenrollAgent (singular)', () => { expect(esClient.update).toBeCalledTimes(1); const calledWith = esClient.update.mock.calls[0]; expect(calledWith[0]?.id).toBe(agentInHostedDoc._id); - expect(calledWith[0]?.body).toHaveProperty('doc.unenrolled_at'); + expect((calledWith[0] as estypes.UpdateRequest)?.body).toHaveProperty('doc.unenrolled_at'); }); }); @@ -93,10 +97,12 @@ describe('unenrollAgents (plural)', () => { // calls ES update with correct values const calledWith = esClient.bulk.mock.calls[1][0]; - const ids = calledWith?.body + const ids = (calledWith as estypes.BulkRequest)?.body ?.filter((i: any) => i.update !== undefined) .map((i: any) => i.update._id); - const docs = calledWith?.body?.filter((i: any) => i.doc).map((i: any) => i.doc); + const docs = (calledWith as estypes.BulkRequest)?.body + ?.filter((i: any) => i.doc) + .map((i: any) => i.doc); expect(ids).toEqual(idsToUnenroll); for (const doc of docs!) { expect(doc).toHaveProperty('unenrollment_started_at'); @@ -111,10 +117,12 @@ describe('unenrollAgents (plural)', () => { // calls ES update with correct values const onlyRegular = [agentInRegularDoc._id, agentInRegularDoc2._id]; const calledWith = esClient.bulk.mock.calls[1][0]; - const ids = calledWith?.body + const ids = (calledWith as estypes.BulkRequest)?.body ?.filter((i: any) => i.update !== undefined) .map((i: any) => i.update._id); - const docs = calledWith?.body?.filter((i: any) => i.doc).map((i: any) => i.doc); + const docs = (calledWith as estypes.BulkRequest)?.body + ?.filter((i: any) => i.doc) + .map((i: any) => i.doc); expect(ids).toEqual(onlyRegular); for (const doc of docs!) { expect(doc).toHaveProperty('unenrollment_started_at'); @@ -149,10 +157,12 @@ describe('unenrollAgents (plural)', () => { // calls ES update with correct values const onlyRegular = [agentInRegularDoc._id, agentInRegularDoc2._id]; const calledWith = esClient.bulk.mock.calls[0][0]; - const ids = calledWith?.body + const ids = (calledWith as estypes.BulkRequest)?.body ?.filter((i: any) => i.update !== undefined) .map((i: any) => i.update._id); - const docs = calledWith?.body?.filter((i: any) => i.doc).map((i: any) => i.doc); + const docs = (calledWith as estypes.BulkRequest)?.body + ?.filter((i: any) => i.doc) + .map((i: any) => i.doc); expect(ids).toEqual(onlyRegular); for (const doc of docs!) { expect(doc).toHaveProperty('unenrolled_at'); @@ -166,10 +176,12 @@ describe('unenrollAgents (plural)', () => { // calls ES update with correct values const calledWith = esClient.bulk.mock.calls[1][0]; - const ids = calledWith?.body + const ids = (calledWith as estypes.BulkRequest)?.body ?.filter((i: any) => i.update !== undefined) .map((i: any) => i.update._id); - const docs = calledWith?.body?.filter((i: any) => i.doc).map((i: any) => i.doc); + const docs = (calledWith as estypes.BulkRequest)?.body + ?.filter((i: any) => i.doc) + .map((i: any) => i.doc); expect(ids).toEqual(idsToUnenroll); for (const doc of docs!) { expect(doc).toHaveProperty('unenrollment_started_at'); @@ -204,10 +216,12 @@ describe('unenrollAgents (plural)', () => { // calls ES update with correct values const calledWith = esClient.bulk.mock.calls[0][0]; - const ids = calledWith?.body + const ids = (calledWith as estypes.BulkRequest)?.body ?.filter((i: any) => i.update !== undefined) .map((i: any) => i.update._id); - const docs = calledWith?.body?.filter((i: any) => i.doc).map((i: any) => i.doc); + const docs = (calledWith as estypes.BulkRequest)?.body + ?.filter((i: any) => i.doc) + .map((i: any) => i.doc); expect(ids).toEqual(idsToUnenroll); for (const doc of docs!) { expect(doc).toHaveProperty('unenrolled_at'); diff --git a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts index b5f8356332b72..5ed1ad902eed3 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts @@ -43,6 +43,7 @@ describe('When using the artifacts services', () => { describe('and calling `getArtifact()`', () => { it('should get artifact using id', async () => { + // @ts-expect-error not full interface esClientMock.get.mockImplementation(() => { return elasticsearchServiceMock.createSuccessTransportRequestPromise( generateArtifactEsGetSingleHitMock() @@ -105,7 +106,6 @@ describe('When using the artifacts services', () => { it('should ignore 409 errors from elasticsearch', async () => { const error = new errors.ResponseError({ statusCode: 409 } as TransportResult); // Unclear why `mockRejectedValue()` has the params value type set to `never` - // @ts-expect-error esClientMock.create.mockRejectedValue(error); await expect(() => createArtifact(esClientMock, newArtifact)).not.toThrow(); }); @@ -140,6 +140,7 @@ describe('When using the artifacts services', () => { describe('and calling `listArtifacts()`', () => { beforeEach(() => { + // @ts-expect-error not full interface esClientMock.search.mockImplementation(() => { return elasticsearchServiceMock.createSuccessTransportRequestPromise( generateArtifactEsSearchResultHitsMock() diff --git a/x-pack/plugins/fleet/server/services/artifacts/client.test.ts b/x-pack/plugins/fleet/server/services/artifacts/client.test.ts index 470f1d4ce0a84..ae875df26371c 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/client.test.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/client.test.ts @@ -28,6 +28,7 @@ describe('When using the Fleet Artifacts Client', () => { singleHit._source.package_name = 'not endpoint'; } + // @ts-expect-error not full interface esClientMock.get.mockImplementation(() => { return elasticsearchServiceMock.createSuccessTransportRequestPromise(singleHit); }); @@ -104,6 +105,7 @@ describe('When using the Fleet Artifacts Client', () => { describe('and calling `listArtifacts()`', () => { beforeEach(() => { + // @ts-expect-error not full interface esClientMock.search.mockImplementation(() => { return elasticsearchServiceMock.createSuccessTransportRequestPromise( generateArtifactEsSearchResultHitsMock() diff --git a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts index 053021063fdf9..b739246c758b9 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts @@ -148,8 +148,6 @@ export const generateEsApiResponseMock = >( id: 7160, }, name: 'elasticsearch-js', - // There are some properties missing below which is not important for this mock - // @ts-ignore connection: { url: new URL('http://localhost:9200/'), id: 'http://localhost:9200/', @@ -158,6 +156,8 @@ export const generateEsApiResponseMock = >( resurrectTimeout: 0, _openRequests: 0, status: 'alive', + // There are some properties missing below which is not important for this mock + // @ts-expect-error roles: { master: true, data: true, diff --git a/x-pack/plugins/fleet/server/services/artifacts/utils.ts b/x-pack/plugins/fleet/server/services/artifacts/utils.ts index bce6b1a1e815b..e3b1be26165e8 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/utils.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/utils.ts @@ -8,5 +8,9 @@ import { isESClientError } from '../../errors'; export const isElasticsearchItemNotFoundError = (error: Error): boolean => { - return isESClientError(error) && error.meta.statusCode === 404 && error.meta.body.found === false; + return ( + isESClientError(error) && + error.meta.statusCode === 404 && + (error.meta.body as any).found === false + ); }; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts index 552e486552a78..109d76be2826f 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts @@ -49,7 +49,8 @@ describe('EPM install', () => { packageName: pkg.name, }); - const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[0][0]!.body as Record< + // @ts-expect-error + const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[0][0].body as Record< string, any >; @@ -90,6 +91,7 @@ describe('EPM install', () => { packageName: pkg.name, }); + // @ts-expect-error const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[0][0]!.body as Record< string, any @@ -130,6 +132,7 @@ describe('EPM install', () => { packageVersion: pkg.version, packageName: pkg.name, }); + // @ts-expect-error const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[0][0]!.body as Record< string, any @@ -181,12 +184,14 @@ describe('EPM install', () => { packageName: pkg.name, }); + // @ts-expect-error const removeAliases = esClient.indices.putIndexTemplate.mock.calls[0][0]!.body as Record< string, any >; expect(removeAliases.template.aliases).not.toBeDefined(); + // @ts-expect-error const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[1][0]!.body as Record< string, any diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts index 9dae415838890..67b57dea6e310 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts @@ -192,7 +192,6 @@ function putComponentTemplate( const { name, body, create = false } = params; return { clusterPromise: esClient.cluster.putComponentTemplate( - // @ts-expect-error body is missing required key `settings`. TemplateMapEntry has settings *or* mappings { name, body, create }, { ignore: [404] } ), diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts index 44d633d5f6e53..16cb4a29bcc7e 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts @@ -505,7 +505,7 @@ const updateExistingDataStream = async ({ try { await esClient.indices.putSettings({ index: dataStreamName, - body: { settings: { default_pipeline: settings.index.default_pipeline } }, + body: { default_pipeline: settings.index.default_pipeline }, }); } catch (err) { throw new Error(`could not update index template settings for ${dataStreamName}`); diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts index 5f6f64576ad64..23f32ca772fb8 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts @@ -102,6 +102,7 @@ describe('test transform install', () => { ); esClient.transform.getTransform.mockReturnValueOnce( + // @ts-expect-error Transform is not valid elasticsearchClientMock.createSuccessTransportRequestPromise({ count: 1, transforms: [ @@ -386,6 +387,7 @@ describe('test transform install', () => { ); esClient.transform.getTransform.mockReturnValueOnce( + // @ts-expect-error Transform is not valid elasticsearchClientMock.createSuccessTransportRequestPromise({ count: 1, transforms: [ From 53e11057e83aff908477a9b5dc55e2280b4f02ea Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:17:30 +0200 Subject: [PATCH 034/172] fix errors in ILM --- x-pack/plugins/index_lifecycle_management/server/plugin.ts | 3 +-- .../server/routes/api/policies/register_delete_route.ts | 1 - x-pack/plugins/index_management/server/lib/fetch_indices.ts | 1 - .../index_management/server/routes/api/templates/lib.ts | 1 - .../server/routes/api/templates/register_simulate_route.ts | 4 ++-- 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/server/plugin.ts b/x-pack/plugins/index_lifecycle_management/server/plugin.ts index f511f837b8074..08b1033371ad5 100644 --- a/x-pack/plugins/index_lifecycle_management/server/plugin.ts +++ b/x-pack/plugins/index_lifecycle_management/server/plugin.ts @@ -31,11 +31,10 @@ const indexLifecycleDataEnricher = async ( } = await client.asCurrentUser.ilm.explainLifecycle({ index: '*', }); - + // @ts-expect-error IndexLifecyclePolicy is not compatible with IlmExplainLifecycleResponse return indicesList.map((index: IndexWithoutIlm) => { return { ...index, - // @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/531 ilm: { ...(ilmIndicesData[index.name] || {}) }, }; }); diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts index 069adc139a86d..72768a1540adc 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts @@ -17,7 +17,6 @@ async function deletePolicies(client: ElasticsearchClient, policyName: string): ignore: [404], }; - // @ts-expect-error @elastic/elasticsearch DeleteSnapshotLifecycleRequest.policy_id is required return client.ilm.deleteLifecycle({ policy: policyName }, options); } diff --git a/x-pack/plugins/index_management/server/lib/fetch_indices.ts b/x-pack/plugins/index_management/server/lib/fetch_indices.ts index f78e666ddfc5f..1dd27dff98c16 100644 --- a/x-pack/plugins/index_management/server/lib/fetch_indices.ts +++ b/x-pack/plugins/index_management/server/lib/fetch_indices.ts @@ -54,7 +54,6 @@ async function fetchIndicesCall( aliases: aliases.length ? aliases : 'none', // @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/532 hidden: index.settings.index.hidden === 'true', - // @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/532 data_stream: index.data_stream!, }); } diff --git a/x-pack/plugins/index_management/server/routes/api/templates/lib.ts b/x-pack/plugins/index_management/server/routes/api/templates/lib.ts index ec8916b0b8d07..413e73ff93d5f 100644 --- a/x-pack/plugins/index_management/server/routes/api/templates/lib.ts +++ b/x-pack/plugins/index_management/server/routes/api/templates/lib.ts @@ -51,7 +51,6 @@ export const saveTemplate = async ({ return await client.asCurrentUser.indices.putTemplate({ name: template.name, - // @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/533 order, body: { index_patterns, diff --git a/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts b/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts index cd363cbd7d003..e45d86f3e2b27 100644 --- a/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts +++ b/x-pack/plugins/index_management/server/routes/api/templates/register_simulate_route.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema, TypeOf } from '@kbn/config-schema'; import { RouteDependencies } from '../../../types'; @@ -31,7 +31,7 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD // Issue: https://github.com/elastic/elasticsearch/issues/59152 index_patterns: ['a_fake_index_pattern_that_wont_match_any_indices'], }, - }); + } as estypes.IndicesSimulateTemplateRequest); return response.ok({ body: templatePreview }); } catch (error) { From 3beef6a49204f39a16fb04ce794a0d7eb7378cf2 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:18:21 +0200 Subject: [PATCH 035/172] fix errors in infra --- .../components/expression_chart.test.tsx | 1 + x-pack/plugins/infra/public/lib/lib.ts | 2 +- .../adapters/framework/kibana_framework_adapter.ts | 13 ++++--------- .../log_entries/kibana_log_entries_adapter.ts | 4 ++-- .../alerting/metric_threshold/lib/evaluate_alert.ts | 3 ++- .../server/routes/log_sources/configuration.ts | 2 ++ .../infra/server/routes/metrics_sources/index.ts | 2 ++ .../services/log_entries/queries/log_entries.ts | 4 ++-- .../services/log_entries/queries/log_entry.ts | 2 +- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx index caf8e32814fe5..dcc485c2d2d55 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx @@ -54,6 +54,7 @@ describe('ExpressionChart', () => { metricAlias: 'metricbeat-*', inventoryDefaultView: 'host', metricsExplorerDefaultView: 'host', + // @ts-expect-error message is missing fields: { timestamp: '@timestamp', container: 'container.id', diff --git a/x-pack/plugins/infra/public/lib/lib.ts b/x-pack/plugins/infra/public/lib/lib.ts index 4541eb6518788..97a3f8eabbe4e 100644 --- a/x-pack/plugins/infra/public/lib/lib.ts +++ b/x-pack/plugins/infra/public/lib/lib.ts @@ -124,7 +124,7 @@ export enum InfraWaffleMapRuleOperator { } export interface InfraWaffleMapOptions { - fields?: MetricsSourceConfigurationProperties['fields'] | null; + fields?: Omit | null; formatter: InfraFormatterType; formatTemplate: string; metric: SnapshotMetricInput; diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index 44f95976d8ad0..9e79e75100be8 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -5,13 +5,8 @@ * 2.0. */ -import { - IndicesExistsAlias, - IndicesGet, - MlGetBuckets, -} from '@elastic/elasticsearch/api/requestParams'; -import { TransportRequestParams } from '@elastic/transport'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { TransportRequestParams } from '@elastic/transport'; import { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; import { InfraRouteConfig, @@ -173,7 +168,7 @@ export class KibanaFramework { apiResult = elasticsearch.client.asCurrentUser.indices.existsAlias({ ...params, ...frozenIndicesParams, - } as IndicesExistsAlias); + } as estypes.IndicesExistsAliasRequest); break; case 'indices.getAlias': apiResult = elasticsearch.client.asCurrentUser.indices.getAlias({ @@ -185,7 +180,7 @@ export class KibanaFramework { apiResult = elasticsearch.client.asCurrentUser.indices.get({ ...params, ...frozenIndicesParams, - } as IndicesGet); + } as estypes.IndicesGetRequest); break; case 'transport.request': apiResult = elasticsearch.client.asCurrentUser.transport.request({ @@ -197,7 +192,7 @@ export class KibanaFramework { apiResult = elasticsearch.client.asCurrentUser.ml.getBuckets({ ...params, ...frozenIndicesParams, - } as MlGetBuckets); + } as estypes.MlGetBucketsRequest); break; } return apiResult ? (await apiResult).body : undefined; diff --git a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts index ab98de7901a3d..f8691accebe01 100644 --- a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts @@ -10,8 +10,8 @@ import { fold, map } from 'fp-ts/lib/Either'; import { constant, identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; import * as runtimeTypes from 'io-ts'; -import { compact } from 'lodash'; import { JsonArray } from '@kbn/utility-types'; +import { compact } from 'lodash'; import type { InfraPluginRequestHandlerContext } from '../../../types'; import { LogEntriesAdapter, @@ -46,7 +46,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter { const highlightClause = highlightQuery ? { highlight: { - boundary_scanner: 'word', + boundary_scanner: 'word' as const, fields: fields.reduce( (highlightFieldConfigs, fieldName) => ({ ...highlightFieldConfigs, diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts index 5bd7a4947b439..71c18d9f7cf04 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { mapValues, first, last, isNaN, isNumber, isObject, has } from 'lodash'; import moment from 'moment'; import { ElasticsearchClient } from 'kibana/server'; +import { mapValues, first, last, isNaN, isNumber, isObject, has } from 'lodash'; import { isTooManyBucketsPreviewException, TOO_MANY_BUCKETS_PREVIEW_EXCEPTION, @@ -222,6 +222,7 @@ const getMetric: ( return groupedResults; } const { body: result } = await esClient.search({ + // @ts-expect-error buckets_path is not compatible body: searchBody, index, }); diff --git a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts index f0d7b18d91a5d..d15da50954990 100644 --- a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts +++ b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts @@ -85,11 +85,13 @@ export const initLogSourceConfigurationRoutes = ({ framework, sources }: InfraBa ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties )); diff --git a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts index 0123e4678697c..e794a0e5a7b45 100644 --- a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts +++ b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts @@ -88,11 +88,13 @@ export const initMetricsSourceConfigurationRoutes = (libs: InfraBackendLibs) => ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties )); diff --git a/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts b/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts index 762efda1c6c1d..534aac61c5220 100644 --- a/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts +++ b/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts @@ -38,6 +38,7 @@ export const createGetLogEntriesQuery = ( return { index: logEntriesIndex, + // @ts-expect-error AsyncSearchSubmitRequest expects allow_no_indices in body allow_no_indices: true, track_scores: false, track_total_hits: false, @@ -53,7 +54,6 @@ export const createGetLogEntriesQuery = ( }, }, fields, - // @ts-expect-error @elastic/elasticsearch doesn't declare "runtime_mappings" property runtime_mappings: runtimeMappings, _source: false, ...createSortClause(sortDirection, timestampField, tiebreakerField), @@ -87,7 +87,7 @@ const createHighlightClause = (highlightQuery: JsonObject | undefined, fields: s highlightQuery ? { highlight: { - boundary_scanner: 'word', + boundary_scanner: 'word' as const, fields: fields.reduce( (highlightFieldConfigs, fieldName) => ({ ...highlightFieldConfigs, diff --git a/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts b/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts index 8895a6e03f0c5..972305af37502 100644 --- a/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts +++ b/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts @@ -21,6 +21,7 @@ export const createGetLogEntryQuery = ( runtimeMappings?: estypes.MappingRuntimeFields ): estypes.AsyncSearchSubmitRequest => ({ index: logEntryIndex, + // @ts-expect-error AsyncSearchSubmitRequest expects terminate_after in body terminate_after: 1, track_scores: false, track_total_hits: false, @@ -32,7 +33,6 @@ export const createGetLogEntryQuery = ( }, }, fields: ['*'], - // @ts-expect-error @elastic/elasticsearch doesn't declare "runtime_mappings" property runtime_mappings: runtimeMappings, sort: [{ [timestampField]: 'desc' }, { [tiebreakerField]: 'desc' }], _source: false, From e41e5667126c2d0519f0524ec5b9bbe9890680f0 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:18:45 +0200 Subject: [PATCH 036/172] fix errors in ingest_pipeline --- x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts | 1 + x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts index 5368b59b35a41..a2882fd7855d6 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/privileges.ts @@ -41,6 +41,7 @@ export const registerPrivilegesRoute = ({ router, config }: RouteDependencies) = const { body: { has_all_requested: hasAllPrivileges, cluster }, } = await clusterClient.asCurrentUser.security.hasPrivileges({ + // @ts-expect-error @elastic/elasticsearch SecurityClusterPrivilege doesn’t contain all the priviledges body: { cluster: APP_CLUSTER_REQUIRED_PRIVILEGES }, }); diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts index 52fcd398758cb..c6d628294a734 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/simulate.ts @@ -38,7 +38,7 @@ export const registerSimulateRoute = ({ verbose, body: { pipeline, - docs: documents as estypes.IngestSimulatePipelineDocument[], + docs: documents as estypes.IngestSimulateDocument[], }, }); From e686e868e54073dc9e670765a03e461e65012b43 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:19:02 +0200 Subject: [PATCH 037/172] fix errors in lens --- x-pack/plugins/lens/server/routes/existing_fields.ts | 3 ++- x-pack/plugins/lens/server/routes/field_stats.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/lens/server/routes/existing_fields.ts b/x-pack/plugins/lens/server/routes/existing_fields.ts index f35b0a7f23179..704b248faeadb 100644 --- a/x-pack/plugins/lens/server/routes/existing_fields.ts +++ b/x-pack/plugins/lens/server/routes/existing_fields.ts @@ -6,7 +6,8 @@ */ import Boom from '@hapi/boom'; -import { errors, estypes } from '@elastic/elasticsearch'; +import { errors } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import { RequestHandlerContext, ElasticsearchClient } from 'src/core/server'; import { CoreSetup, Logger } from 'src/core/server'; diff --git a/x-pack/plugins/lens/server/routes/field_stats.ts b/x-pack/plugins/lens/server/routes/field_stats.ts index 88e8e600aa906..9e48c00b9d8cb 100644 --- a/x-pack/plugins/lens/server/routes/field_stats.ts +++ b/x-pack/plugins/lens/server/routes/field_stats.ts @@ -4,7 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { errors, estypes } from '@elastic/elasticsearch'; +import { errors } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import DateMath from '@elastic/datemath'; import { schema } from '@kbn/config-schema'; import { CoreSetup } from 'src/core/server'; From 3b82324c326ca6c18e422d3312a536d9ff6f04d4 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:19:24 +0200 Subject: [PATCH 038/172] fix errors in license_management --- .../license_management/server/lib/permissions.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/license_management/server/lib/permissions.ts b/x-pack/plugins/license_management/server/lib/permissions.ts index 517854fad8e83..06395fb6302b6 100644 --- a/x-pack/plugins/license_management/server/lib/permissions.ts +++ b/x-pack/plugins/license_management/server/lib/permissions.ts @@ -20,14 +20,12 @@ export async function getPermissions({ isSecurityEnabled, client }: GetPermissio }; } - const options = { - body: { - cluster: ['manage'], // License management requires "manage" cluster privileges - }, - }; - try { - const { body: response } = await client.asCurrentUser.security.hasPrivileges(options); + const { body: response } = await client.asCurrentUser.security.hasPrivileges({ + body: { + cluster: ['manage'], // License management requires "manage" cluster privileges + }, + }); return { hasPermission: response.cluster.manage, }; From a2d00ead81e9b9bd2b40e4846227b7ef1768479a Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:21:08 +0200 Subject: [PATCH 039/172] fix errors in licensing --- x-pack/plugins/licensing/server/plugin.test.ts | 3 --- x-pack/plugins/licensing/server/plugin.ts | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/x-pack/plugins/licensing/server/plugin.test.ts b/x-pack/plugins/licensing/server/plugin.test.ts index 5857596e13c14..71a98098bb0f5 100644 --- a/x-pack/plugins/licensing/server/plugin.test.ts +++ b/x-pack/plugins/licensing/server/plugin.test.ts @@ -102,9 +102,6 @@ describe('licensing plugin', () => { await license$.pipe(take(1)).toPromise(); expect(esClient.asInternalUser.xpack.info).toHaveBeenCalledTimes(1); - expect(esClient.asInternalUser.xpack.info).toHaveBeenCalledWith({ - accept_enterprise: true, - }); }); it('observable receives updated licenses', async () => { diff --git a/x-pack/plugins/licensing/server/plugin.ts b/x-pack/plugins/licensing/server/plugin.ts index 83379fe48ac9e..43c8135127871 100644 --- a/x-pack/plugins/licensing/server/plugin.ts +++ b/x-pack/plugins/licensing/server/plugin.ts @@ -177,10 +177,7 @@ export class LicensingPlugin implements Plugin): Promise => { const client = isPromise(clusterClient) ? await clusterClient : clusterClient; try { - const { body: response } = await client.asInternalUser.xpack.info({ - // @ts-expect-error `accept_enterprise` is not present in the client definition - accept_enterprise: true, - }); + const { body: response } = await client.asInternalUser.xpack.info(); const normalizedLicense = response.license && response.license.type !== 'missing' ? normalizeServerLicense(response.license) From b9e09d6589367ff5bdbde8880f4ab563840b0b74 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:21:20 +0200 Subject: [PATCH 040/172] fix errors in logstash --- x-pack/plugins/logstash/server/routes/pipeline/save.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/logstash/server/routes/pipeline/save.ts b/x-pack/plugins/logstash/server/routes/pipeline/save.ts index 48a62f83c91ca..83f6ee9b00ba9 100644 --- a/x-pack/plugins/logstash/server/routes/pipeline/save.ts +++ b/x-pack/plugins/logstash/server/routes/pipeline/save.ts @@ -47,6 +47,7 @@ export function registerPipelineSaveRoute( await client.asCurrentUser.logstash.putPipeline({ id: pipeline.id, + // @ts-expect-error description is required body: pipeline.upstreamJSON, }); From cf0ee2575630bfafd97e1d3841c575e27f6c0bc0 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:21:59 +0200 Subject: [PATCH 041/172] fix errors in ml --- .../plugins/ml/public/alerting/ml_anomaly_alert_trigger.tsx | 2 +- .../jobs/new_job/common/job_creator/job_creator.ts | 4 ++-- .../public/application/services/anomaly_detector_service.ts | 2 +- x-pack/plugins/ml/server/lib/ml_client/search.ts | 2 +- .../calculate_model_memory_limit.ts | 1 + .../server/models/job_service/new_job_caps/field_service.ts | 4 ++-- .../ml/server/models/job_service/new_job_caps/rollup.ts | 2 +- .../ml/server/models/job_validation/validate_influencers.ts | 5 ++++- x-pack/plugins/ml/server/routes/anomaly_detectors.ts | 1 + 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ml/public/alerting/ml_anomaly_alert_trigger.tsx b/x-pack/plugins/ml/public/alerting/ml_anomaly_alert_trigger.tsx index 794f4b3b164e9..2be57ddf95431 100644 --- a/x-pack/plugins/ml/public/alerting/ml_anomaly_alert_trigger.tsx +++ b/x-pack/plugins/ml/public/alerting/ml_anomaly_alert_trigger.tsx @@ -88,7 +88,7 @@ const MlAnomalyAlertTrigger: FC = ({ const availableResultTypes = useMemo(() => { if (jobConfigs.length === 0) return Object.values(ANOMALY_RESULT_TYPE); - return (jobConfigs ?? []).some((v) => v.analysis_config.influencers.length > 0) + return (jobConfigs ?? []).some((v) => Boolean(v.analysis_config?.influencers?.length)) ? Object.values(ANOMALY_RESULT_TYPE) : [ANOMALY_RESULT_TYPE.BUCKET, ANOMALY_RESULT_TYPE.RECORD]; }, [jobConfigs]); diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts index e6cfe52933617..74ff15df88b16 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts @@ -87,7 +87,7 @@ export class JobCreator { this._calendars = []; this._datafeed_config = createEmptyDatafeed(this._indexPatternTitle); this._detectors = this._job_config.analysis_config.detectors; - this._influencers = this._job_config.analysis_config.influencers; + this._influencers = this._job_config.analysis_config.influencers!; if (typeof indexPattern.timeFieldName === 'string') { this._job_config.data_description.time_field = indexPattern.timeFieldName; @@ -766,7 +766,7 @@ export class JobCreator { this._datafeed_config = datafeed; this._detectors = this._job_config.analysis_config.detectors; - this._influencers = this._job_config.analysis_config.influencers; + this._influencers = this._job_config.analysis_config.influencers!; if (this._job_config.groups === undefined) { this._job_config.groups = []; } diff --git a/x-pack/plugins/ml/public/application/services/anomaly_detector_service.ts b/x-pack/plugins/ml/public/application/services/anomaly_detector_service.ts index eacfd826868ac..1601a5d6cceea 100644 --- a/x-pack/plugins/ml/public/application/services/anomaly_detector_service.ts +++ b/x-pack/plugins/ml/public/application/services/anomaly_detector_service.ts @@ -50,7 +50,7 @@ export class AnomalyDetectorService { } const influencers = new Set(); for (const job of jobs) { - for (const influencer of job.analysis_config.influencers) { + for (const influencer of job.analysis_config.influencers || []) { influencers.add(influencer); } } diff --git a/x-pack/plugins/ml/server/lib/ml_client/search.ts b/x-pack/plugins/ml/server/lib/ml_client/search.ts index b9de1fa0d2bfc..ad3e37079c585 100644 --- a/x-pack/plugins/ml/server/lib/ml_client/search.ts +++ b/x-pack/plugins/ml/server/lib/ml_client/search.ts @@ -31,7 +31,7 @@ export function searchProvider( async function anomalySearch( searchParams: estypes.SearchRequest, jobIds: string[] - ): Promise>> { + ): Promise, unknown>> { await jobIdsCheck('anomaly-detector', jobIds); const { asInternalUser } = client; const resp = await asInternalUser.search({ diff --git a/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts b/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts index bb4bcb0781e27..4eb2c2421debf 100644 --- a/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts +++ b/x-pack/plugins/ml/server/models/calculate_model_memory_limit/calculate_model_memory_limit.ts @@ -89,6 +89,7 @@ const cardinalityCheckProvider = (client: IScopedClusterClient) => { new Set() ); + // @ts-expect-error influencers is optional const normalizedInfluencers: estypes.Field[] = Array.isArray(influencers) ? influencers : [influencers]; diff --git a/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts b/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts index cd0f81d46563a..1bf62f7eab41b 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job_caps/field_service.ts @@ -113,7 +113,7 @@ class FieldsService { this._mlClusterClient, this._savedObjectsClient ); - const rollupConfigs: estypes.RollupGetRollupCapabilitiesRollupCapabilitySummary[] | null = + const rollupConfigs: estypes.RollupGetRollupCapsRollupCapabilitySummary[] | null = await rollupService.getRollupJobs(); // if a rollup index has been specified, yet there are no @@ -137,7 +137,7 @@ class FieldsService { } function combineAllRollupFields( - rollupConfigs: estypes.RollupGetRollupCapabilitiesRollupCapabilitySummary[] + rollupConfigs: estypes.RollupGetRollupCapsRollupCapabilitySummary[] ): RollupFields { const rollupFields: RollupFields = {}; rollupConfigs.forEach((conf) => { diff --git a/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts b/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts index 80376688227ab..4f75678f6360a 100644 --- a/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts +++ b/x-pack/plugins/ml/server/models/job_service/new_job_caps/rollup.ts @@ -28,7 +28,7 @@ export async function rollupServiceProvider( let jobIndexPatterns: string[] = [indexPattern]; async function getRollupJobs(): Promise< - estypes.RollupGetRollupCapabilitiesRollupCapabilitySummary[] | null + estypes.RollupGetRollupCapsRollupCapabilitySummary[] | null > { if (rollupIndexPatternObject !== null) { const parsedTypeMetaData = JSON.parse(rollupIndexPatternObject.attributes.typeMeta!); diff --git a/x-pack/plugins/ml/server/models/job_validation/validate_influencers.ts b/x-pack/plugins/ml/server/models/job_validation/validate_influencers.ts index ad67cfb49ca6d..212beb1ebbd4a 100644 --- a/x-pack/plugins/ml/server/models/job_validation/validate_influencers.ts +++ b/x-pack/plugins/ml/server/models/job_validation/validate_influencers.ts @@ -38,7 +38,7 @@ export async function validateInfluencers(job: CombinedJob) { // detector using 'count' and no influencers and there shouldn't // be a warning about that. if ( - influencers.length === 0 && + influencers?.length === 0 && job.analysis_config.detectors.length === 1 && detectorFieldNames.length === 0 ) { @@ -46,6 +46,7 @@ export async function validateInfluencers(job: CombinedJob) { } if ( + // @ts-expect-error influencers is optional influencers.length <= INFLUENCER_LOW_THRESHOLD && detectorFieldNames.length >= DETECTOR_FIELD_NAMES_THRESHOLD ) { @@ -59,8 +60,10 @@ export async function validateInfluencers(job: CombinedJob) { } messages.push({ id, influencerSuggestion }); + // @ts-expect-error influencers is optional } else if (influencers.length <= INFLUENCER_LOW_THRESHOLD) { messages.push({ id: 'influencer_low' }); + // @ts-expect-error influencers is optional } else if (influencers.length >= INFLUENCER_HIGH_THRESHOLD) { messages.push({ id: 'influencer_high' }); } diff --git a/x-pack/plugins/ml/server/routes/anomaly_detectors.ts b/x-pack/plugins/ml/server/routes/anomaly_detectors.ts index c6942b1cc40d6..4e222e05c1b19 100644 --- a/x-pack/plugins/ml/server/routes/anomaly_detectors.ts +++ b/x-pack/plugins/ml/server/routes/anomaly_detectors.ts @@ -221,6 +221,7 @@ export function jobRoutes({ router, routeGuard }: RouteInitialization) { const { jobId } = request.params; const { body } = await mlClient.updateJob({ job_id: jobId, + // @ts-expect-error MlDetector is not compatible body: request.body, }); return response.ok({ From 1575bcb92bbad216b551c3cf2eb278e5b1fdc789 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:22:16 +0200 Subject: [PATCH 042/172] fix errors in monitoring --- .../plugins/monitoring/server/lib/errors/esclient_errors.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts b/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts index 6df1dbf725cdf..1b83b8e4e7eb6 100644 --- a/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts +++ b/x-pack/plugins/monitoring/server/lib/errors/esclient_errors.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ElasticsearchClientError } from '@elastic/elasticsearch'; +import { errors } from '@elastic/elasticsearch'; import { boomify } from '@hapi/boom'; import { i18n } from '@kbn/i18n'; import { ErrorTypes } from '../../types'; @@ -38,12 +38,12 @@ const mapTypeMessage: { [key: string]: string } = { }; export function isESClientError(err: ErrorTypes) { - if (err instanceof ElasticsearchClientError === false) return false; + if (err instanceof errors.ElasticsearchClientError === false) return false; const knownTypes = Object.keys(mapTypeMessage); return knownTypes.includes(err.constructor.name); } -export function handleESClientError(err: ElasticsearchClientError) { +export function handleESClientError(err: errors.ElasticsearchClientError) { err.message = mapTypeMessage[err.constructor.name]; return boomify(err, { statusCode: 503 }); } From cbf44d499ce5696a439cf2bf158a2ef6977d1fc4 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:22:34 +0200 Subject: [PATCH 043/172] fix errors in observability --- .../observability/server/routes/register_routes.ts | 4 ++-- .../observability/server/utils/unwrap_es_response.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/observability/server/routes/register_routes.ts b/x-pack/plugins/observability/server/routes/register_routes.ts index abf009302baee..66d8940b615b3 100644 --- a/x-pack/plugins/observability/server/routes/register_routes.ts +++ b/x-pack/plugins/observability/server/routes/register_routes.ts @@ -12,7 +12,7 @@ import { } from '@kbn/server-route-repository'; import { CoreSetup, CoreStart, Logger, RouteRegistrar } from 'kibana/server'; import Boom from '@hapi/boom'; -import { RequestAbortedError } from '@elastic/elasticsearch'; +import { errors } from '@elastic/elasticsearch'; import { RuleDataPluginService } from '../../../rule_registry/server'; import { ObservabilityRequestHandlerContext } from '../types'; import { AbstractObservabilityServerRouteRepository } from './types'; @@ -79,7 +79,7 @@ export function registerRoutes({ opts.statusCode = error.output.statusCode; } - if (error instanceof RequestAbortedError) { + if (error instanceof errors.RequestAbortedError) { opts.statusCode = 499; opts.body.message = 'Client closed request'; } diff --git a/x-pack/plugins/observability/server/utils/unwrap_es_response.ts b/x-pack/plugins/observability/server/utils/unwrap_es_response.ts index d2051f4d24d8a..d2c97eb0ba25a 100644 --- a/x-pack/plugins/observability/server/utils/unwrap_es_response.ts +++ b/x-pack/plugins/observability/server/utils/unwrap_es_response.ts @@ -4,20 +4,20 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { ElasticsearchClientError, ResponseError } from '@elastic/elasticsearch'; +import { errors } from '@elastic/elasticsearch'; import type { UnwrapPromise } from '@kbn/utility-types'; import { inspect } from 'util'; export class WrappedElasticsearchClientError extends Error { - originalError: ElasticsearchClientError; - constructor(originalError: ElasticsearchClientError) { + originalError: errors.ElasticsearchClientError; + constructor(originalError: errors.ElasticsearchClientError) { super(originalError.message); const stack = this.stack; this.originalError = originalError; - if (originalError instanceof ResponseError) { + if (originalError instanceof errors.ResponseError) { // make sure ES response body is visible when logged to the console // @ts-expect-error this.stack = { From 1786edc9a6645f1e5d6302f9bc7e7d5b94cbcf47 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:22:46 +0200 Subject: [PATCH 044/172] fix errors in rule_registry --- .../remote_clusters/server/routes/api/update_route.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/remote_clusters/server/routes/api/update_route.test.ts b/x-pack/plugins/remote_clusters/server/routes/api/update_route.test.ts index 129326dea95ec..856b8062e320e 100644 --- a/x-pack/plugins/remote_clusters/server/routes/api/update_route.test.ts +++ b/x-pack/plugins/remote_clusters/server/routes/api/update_route.test.ts @@ -164,6 +164,7 @@ describe('UPDATE remote clusters', () => { test('updates v1 proxy cluster', async () => { remoteInfoMockFn.mockResolvedValueOnce( + // @ts-expect-error not full interface createApiResponse({ body: { test: { From b30724dce065f88387a3c8442acc58ca4e401a38 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:23:21 +0200 Subject: [PATCH 045/172] fix errors in reporting --- .../csv/generate_csv/hit_iterator.ts | 16 ++++++++-------- .../reporting/server/lib/content_stream.ts | 4 ++-- .../reporting/server/lib/store/store.test.ts | 13 +++++++------ .../reporting/server/routes/lib/jobs_query.ts | 5 ++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts index 9014e4f85b3b2..18572bba59d0f 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts @@ -4,18 +4,15 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - -import { UnwrapPromise } from '@kbn/utility-types'; +import type { TransportResult } from '@elastic/transport'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import { ElasticsearchClient } from 'src/core/server'; import { CancellationToken } from '../../../../common'; import { LevelLogger } from '../../../lib'; import { ScrollConfig } from '../../../types'; -type SearchResponse = UnwrapPromise>; -type SearchRequest = Required>[0]; - -function parseResponse(response: SearchResponse) { +function parseResponse(response: TransportResult) { if (!response?.body._scroll_id) { throw new Error( i18n.translate('xpack.reporting.exportTypes.csv.hitIterator.expectedScrollIdErrorMessage', { @@ -44,11 +41,14 @@ export function createHitIterator(logger: LevelLogger) { return async function* hitIterator( scrollSettings: ScrollConfig, elasticsearchClient: ElasticsearchClient, - searchRequest: SearchRequest, + searchRequest: estypes.SearchRequest, cancellationToken: CancellationToken ) { logger.debug('executing search request'); - async function search(index: SearchRequest['index'], body: SearchRequest['body']) { + async function search( + index: estypes.SearchRequest['index'], + body: estypes.SearchRequest['body'] + ) { return parseResponse( await elasticsearchClient.search({ index, diff --git a/x-pack/plugins/reporting/server/lib/content_stream.ts b/x-pack/plugins/reporting/server/lib/content_stream.ts index 3c0fdaa91f32e..9719ac57b119c 100644 --- a/x-pack/plugins/reporting/server/lib/content_stream.ts +++ b/x-pack/plugins/reporting/server/lib/content_stream.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Duplex } from 'stream'; import { defaults, get } from 'lodash'; import Puid from 'puid'; @@ -22,7 +22,7 @@ import { LevelLogger } from './level_logger'; const REQUEST_SPAN_SIZE_IN_BYTES = 1024; type Callback = (error?: Error) => void; -type SearchRequest = Required>[0]; +type SearchRequest = estypes.SearchRequest; interface ContentStreamDocument { id: string; diff --git a/x-pack/plugins/reporting/server/lib/store/store.test.ts b/x-pack/plugins/reporting/server/lib/store/store.test.ts index 8c6cb4dcdd7d6..87a72eeb910c3 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.test.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import { ElasticsearchClient } from 'src/core/server'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; @@ -262,7 +262,8 @@ describe('ReportingStore', () => { await store.setReportClaimed(report, { testDoc: 'test' } as any); const [[updateCall]] = mockEsClient.update.mock.calls; - const response = updateCall.body?.doc as Report; + + const response = (updateCall as estypes.UpdateRequest).body?.doc as Report; expect(response.migration_version).toBe(`7.14.0`); expect(response.status).toBe(`processing`); expect(updateCall.if_seq_no).toBe(42); @@ -293,7 +294,7 @@ describe('ReportingStore', () => { await store.setReportFailed(report, { errors: 'yes' } as any); const [[updateCall]] = mockEsClient.update.mock.calls; - const response = updateCall.body?.doc as Report; + const response = (updateCall as estypes.UpdateRequest).body?.doc as Report; expect(response.migration_version).toBe(`7.14.0`); expect(response.status).toBe(`failed`); expect(updateCall.if_seq_no).toBe(43); @@ -324,7 +325,7 @@ describe('ReportingStore', () => { await store.setReportCompleted(report, { certainly_completed: 'yes' } as any); const [[updateCall]] = mockEsClient.update.mock.calls; - const response = updateCall.body?.doc as Report; + const response = (updateCall as estypes.UpdateRequest).body?.doc as Report; expect(response.migration_version).toBe(`7.14.0`); expect(response.status).toBe(`completed`); expect(updateCall.if_seq_no).toBe(44); @@ -360,7 +361,7 @@ describe('ReportingStore', () => { } as any); const [[updateCall]] = mockEsClient.update.mock.calls; - const response = updateCall.body?.doc as Report; + const response = (updateCall as estypes.UpdateRequest).body?.doc as Report; expect(response.migration_version).toBe(`7.14.0`); expect(response.status).toBe(`completed_with_warnings`); @@ -401,7 +402,7 @@ describe('ReportingStore', () => { await store.prepareReportForRetry(report); const [[updateCall]] = mockEsClient.update.mock.calls; - const response = updateCall.body?.doc as Report; + const response = (updateCall as estypes.UpdateRequest).body?.doc as Report; expect(response.migration_version).toBe(`7.14.0`); expect(response.status).toBe(`pending`); diff --git a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts index 92cef6ee4ded8..3a64207c0d49e 100644 --- a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts @@ -10,6 +10,7 @@ import { DeleteResponse, SearchHit, SearchResponse, + SearchRequest, } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { errors } from '@elastic/elasticsearch'; import { i18n } from '@kbn/i18n'; @@ -22,8 +23,6 @@ import { statuses } from '../../lib/statuses'; import { Report } from '../../lib/store'; import { ReportingUser } from '../../types'; -type SearchRequest = Required>[0]; - const defaultSize = 10; const getUsername = (user: ReportingUser) => (user ? user.username : false); @@ -71,7 +70,7 @@ export function jobsQueryFactory(reportingCore: ReportingCore): JobsQueryFactory return await callback(client); } catch (error) { - if (error instanceof errors.ResponseError && [401, 403, 404].includes(error.statusCode)) { + if (error instanceof errors.ResponseError && [401, 403, 404].includes(error.statusCode!)) { return; } From 053e4b87eba27275dfb2818430b5e75c974ed8c3 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:23:41 +0200 Subject: [PATCH 046/172] fix errors in rule_registry --- .../rule_registry/server/rule_data_client/rule_data_client.ts | 2 ++ x-pack/plugins/rule_registry/server/rule_data_client/types.ts | 2 +- .../server/rule_data_plugin_service/resource_installer.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts index 4cf93460b39fc..297fdbdc67642 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts @@ -140,12 +140,14 @@ export class RuleDataClient implements IRuleDataClient { .then(() => { return clusterClient.bulk(requestWithDefaultParameters).then((retryResponse) => { if (retryResponse.body.errors) { + // @ts-expect-error @elatic/elasticsearch TransportResult is not assignable to DiagnosticResult throw new errors.ResponseError(retryResponse); } return retryResponse; }); }); } + // @ts-expect-error @elatic/elasticsearch TransportResult is not assignable to DiagnosticResult const error = new errors.ResponseError(response); throw error; } diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts index 70e6e645d1829..ebcc83f0fa8b1 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts @@ -35,5 +35,5 @@ export interface IRuleDataReader { } export interface IRuleDataWriter { - bulk(request: BulkRequest): Promise>; + bulk(request: BulkRequest): Promise>; } diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts index 9018b10afdb5b..19c6a0d41872a 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts @@ -88,6 +88,7 @@ export class ResourceInstaller { await Promise.all([ this.createOrUpdateLifecyclePolicy({ policy: getResourceName(DEFAULT_ILM_POLICY_ID), + // @ts-expect-error @elastic/elasticsearch IlmAction is not valid body: defaultLifecyclePolicy, }), From c5150db6359aedd9a490255fa32acf55304a0b43 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:24:27 +0200 Subject: [PATCH 047/172] fix errors in security --- .../security/server/authorization/check_privileges.ts | 5 +++-- x-pack/plugins/security/server/errors.ts | 2 +- x-pack/plugins/security/server/mocks.ts | 2 ++ x-pack/plugins/security/server/routes/indices/get_fields.ts | 6 +----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/security/server/authorization/check_privileges.ts b/x-pack/plugins/security/server/authorization/check_privileges.ts index 3a35cf164ad85..0daee28599e0d 100644 --- a/x-pack/plugins/security/server/authorization/check_privileges.ts +++ b/x-pack/plugins/security/server/authorization/check_privileges.ts @@ -5,6 +5,7 @@ * 2.0. */ +import type * as estypes from '@elastic/elasticsearch/lib/api/types'; import { pick, transform, uniq } from 'lodash'; import type { IClusterClient, KibanaRequest } from 'src/core/server'; @@ -53,11 +54,11 @@ export function checkPrivilegesWithRequestFactory( const clusterClient = await getClusterClient(); const { body } = await clusterClient.asScoped(request).asCurrentUser.security.hasPrivileges({ body: { - cluster: privileges.elasticsearch?.cluster, + cluster: privileges.elasticsearch?.cluster as estypes.SecurityClusterPrivilege[], index: Object.entries(privileges.elasticsearch?.index ?? {}).map( ([name, indexPrivileges]) => ({ names: [name], - privileges: indexPrivileges, + privileges: indexPrivileges as estypes.SecurityIndexPrivilege[], }) ), application: [ diff --git a/x-pack/plugins/security/server/errors.ts b/x-pack/plugins/security/server/errors.ts index 25d2aa44f3dc8..2f2573b171ae2 100644 --- a/x-pack/plugins/security/server/errors.ts +++ b/x-pack/plugins/security/server/errors.ts @@ -33,7 +33,7 @@ export function wrapIntoCustomErrorResponse(error: any) { */ export function getErrorStatusCode(error: any): number { if (error instanceof errors.ResponseError) { - return error.statusCode; + return error.statusCode!; } return Boom.isBoom(error) ? error.output.statusCode : error.statusCode || error.status; diff --git a/x-pack/plugins/security/server/mocks.ts b/x-pack/plugins/security/server/mocks.ts index 9abbb60d2b93f..69082527ddf70 100644 --- a/x-pack/plugins/security/server/mocks.ts +++ b/x-pack/plugins/security/server/mocks.ts @@ -54,7 +54,9 @@ function createApiResponseMock( Partial, 'body'>> ): TransportResult { return { + // @ts-expect-error null is not supported statusCode: null, + // @ts-expect-error null is not supported headers: null, warnings: null, meta: {} as any, diff --git a/x-pack/plugins/security/server/routes/indices/get_fields.ts b/x-pack/plugins/security/server/routes/indices/get_fields.ts index ebfb2b9b3fb95..c3d13bc1f11e7 100644 --- a/x-pack/plugins/security/server/routes/indices/get_fields.ts +++ b/x-pack/plugins/security/server/routes/indices/get_fields.ts @@ -39,11 +39,7 @@ export function defineGetFieldsRoutes({ router }: RouteDefinitionParams) { const mappingValues = Object.values( // `FieldMapping` type from `TypeFieldMappings` --> `GetFieldMappingResponse` is not correct and // doesn't have any properties. - ( - indexMapping.mappings[fieldName] as { - mapping: Record; - } - ).mapping + indexMapping.mappings[fieldName].mapping as Record ); const hasMapping = mappingValues.length > 0; From 51ca4d4fab268be7da8c0eb78441331cefdcdbc0 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:25:21 +0200 Subject: [PATCH 048/172] fix errors in security_solution --- .../data_loaders/index_endpoint_actions.ts | 76 +++++++++---------- .../data_loaders/index_endpoint_hosts.ts | 54 ++++++------- .../data_loaders/index_fleet_actions.ts | 62 +++++++-------- .../data_loaders/index_fleet_agent.ts | 40 +++++----- .../data_loaders/index_fleet_server.ts | 4 +- .../hooks/eql/eql_search_response.mock.ts | 2 +- .../public/timelines/containers/index.tsx | 1 + .../endpoint/resolver_generator_script.ts | 6 +- .../endpoint/routes/metadata/handlers.ts | 2 +- .../migrations/migration_cleanup.ts | 7 +- .../migrations/replace_signals_index_alias.ts | 2 + .../detection_engine/signals/utils.test.ts | 14 ++-- 12 files changed, 129 insertions(+), 141 deletions(-) diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts index e463128a399cf..0b79a5ee4ec87 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts @@ -162,55 +162,51 @@ export const deleteIndexedEndpointActions = async ( }; if (indexedData.endpointActions.length) { - response.endpointActionRequests = ( - await esClient - .deleteByQuery({ - index: `${indexedData.endpointActionsIndex}-*`, - wait_for_completion: true, - body: { - query: { - bool: { - filter: [ - { - terms: { - action_id: indexedData.endpointActions.map( - (action) => action.EndpointAction.action_id - ), - }, + response.endpointActionRequests = await esClient + .deleteByQuery({ + index: `${indexedData.endpointActionsIndex}-*`, + wait_for_completion: true, + body: { + query: { + bool: { + filter: [ + { + terms: { + action_id: indexedData.endpointActions.map( + (action) => action.EndpointAction.action_id + ), }, - ], - }, + }, + ], }, }, - }) - .catch(wrapErrorAndRejectPromise) - ).body; + }, + }) + .catch(wrapErrorAndRejectPromise); } if (indexedData.endpointActionResponses) { - response.endpointActionResponses = ( - await esClient - .deleteByQuery({ - index: `${indexedData.endpointActionResponsesIndex}-*`, - wait_for_completion: true, - body: { - query: { - bool: { - filter: [ - { - terms: { - action_id: indexedData.endpointActionResponses.map( - (action) => action.EndpointAction.action_id - ), - }, + response.endpointActionResponses = await esClient + .deleteByQuery({ + index: `${indexedData.endpointActionResponsesIndex}-*`, + wait_for_completion: true, + body: { + query: { + bool: { + filter: [ + { + terms: { + action_id: indexedData.endpointActionResponses.map( + (action) => action.EndpointAction.action_id + ), }, - ], - }, + }, + ], }, }, - }) - .catch(wrapErrorAndRejectPromise) - ).body; + }, + }) + .catch(wrapErrorAndRejectPromise); } return response; diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts index 5ccdaf1597c73..71bc66ea1bc0e 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_hosts.ts @@ -290,15 +290,13 @@ export const deleteIndexedEndpointHosts = async ( }, }; - response.hosts = ( - await esClient - .deleteByQuery({ - index: indexedData.metadataIndex, - wait_for_completion: true, - body, - }) - .catch(wrapErrorAndRejectPromise) - ).body; + response.hosts = await esClient + .deleteByQuery({ + index: indexedData.metadataIndex, + wait_for_completion: true, + body, + }) + .catch(wrapErrorAndRejectPromise); // Delete from the transform destination index await esClient @@ -311,29 +309,27 @@ export const deleteIndexedEndpointHosts = async ( } if (indexedData.policyResponses.length) { - response.policyResponses = ( - await esClient - .deleteByQuery({ - index: indexedData.policyResponseIndex, - wait_for_completion: true, - body: { - query: { - bool: { - filter: [ - { - terms: { - 'agent.id': indexedData.policyResponses.map( - (policyResponse) => policyResponse.agent.id - ), - }, + response.policyResponses = await esClient + .deleteByQuery({ + index: indexedData.policyResponseIndex, + wait_for_completion: true, + body: { + query: { + bool: { + filter: [ + { + terms: { + 'agent.id': indexedData.policyResponses.map( + (policyResponse) => policyResponse.agent.id + ), }, - ], - }, + }, + ], }, }, - }) - .catch(wrapErrorAndRejectPromise) - ).body; + }, + }) + .catch(wrapErrorAndRejectPromise); } merge(response, await deleteIndexedFleetAgents(esClient, indexedData)); diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts index cca95f71c8091..98d2bd4f7bf2e 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_actions.ts @@ -171,47 +171,43 @@ export const deleteIndexedFleetActions = async ( }; if (indexedData.actions.length) { - response.actions = ( - await esClient - .deleteByQuery({ - index: `${indexedData.actionsIndex}-*`, - wait_for_completion: true, - body: { - query: { - bool: { - filter: [ - { terms: { action_id: indexedData.actions.map((action) => action.action_id) } }, - ], - }, + response.actions = await esClient + .deleteByQuery({ + index: `${indexedData.actionsIndex}-*`, + wait_for_completion: true, + body: { + query: { + bool: { + filter: [ + { terms: { action_id: indexedData.actions.map((action) => action.action_id) } }, + ], }, }, - }) - .catch(wrapErrorAndRejectPromise) - ).body; + }, + }) + .catch(wrapErrorAndRejectPromise); } if (indexedData.actionResponses) { - response.responses = ( - await esClient - .deleteByQuery({ - index: `${indexedData.responsesIndex}-*`, - wait_for_completion: true, - body: { - query: { - bool: { - filter: [ - { - terms: { - action_id: indexedData.actionResponses.map((action) => action.action_id), - }, + response.responses = await esClient + .deleteByQuery({ + index: `${indexedData.responsesIndex}-*`, + wait_for_completion: true, + body: { + query: { + bool: { + filter: [ + { + terms: { + action_id: indexedData.actionResponses.map((action) => action.action_id), }, - ], - }, + }, + ], }, }, - }) - .catch(wrapErrorAndRejectPromise) - ).body; + }, + }) + .catch(wrapErrorAndRejectPromise); } return response; diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts index d6ef02d4f01e2..87374338eee3e 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_agent.ts @@ -81,7 +81,7 @@ export const indexFleetAgentForHost = async ( return { fleetAgentsIndex: agentDoc._index, agents: [ - await fetchFleetAgent(kbnClient, createdFleetAgent.body._id).catch(wrapErrorAndRejectPromise), + await fetchFleetAgent(kbnClient, createdFleetAgent._id).catch(wrapErrorAndRejectPromise), ], }; }; @@ -110,29 +110,27 @@ export const deleteIndexedFleetAgents = async ( }; if (indexedData.agents.length) { - response.agents = ( - await esClient - .deleteByQuery({ - index: `${indexedData.fleetAgentsIndex}-*`, - wait_for_completion: true, - body: { - query: { - bool: { - filter: [ - { - terms: { - 'local_metadata.elastic.agent.id': indexedData.agents.map( - (agent) => agent.local_metadata.elastic.agent.id - ), - }, + response.agents = await esClient + .deleteByQuery({ + index: `${indexedData.fleetAgentsIndex}-*`, + wait_for_completion: true, + body: { + query: { + bool: { + filter: [ + { + terms: { + 'local_metadata.elastic.agent.id': indexedData.agents.map( + (agent) => agent.local_metadata.elastic.agent.id + ), }, - ], - }, + }, + ], }, }, - }) - .catch(wrapErrorAndRejectPromise) - ).body; + }, + }) + .catch(wrapErrorAndRejectPromise); } return response; diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_server.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_server.ts index 7ef827b8ea1f1..ed3e1812b8a63 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_server.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_fleet_server.ts @@ -17,13 +17,13 @@ import { wrapErrorAndRejectPromise } from './utils'; * @param version */ export const enableFleetServerIfNecessary = async (esClient: Client, version: string = '8.0.0') => { - const res = await esClient.search<{}, {}>({ + const res = await esClient.search({ index: FLEET_SERVER_SERVERS_INDEX, ignore_unavailable: true, rest_total_hits_as_int: true, }); - if (res.body.hits.total > 0) { + if (res.hits.total > 0) { return; } diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts index 513bfc654027d..380e4da6601e2 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts @@ -8,7 +8,7 @@ import { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; import { Source } from './types'; import { EqlSearchResponse } from '../../../../common/detection_engine/types'; -import { Connection } from '@elastic/elasticsearch'; +import { Connection } from '@elastic/transport/lib/connection'; export const getMockEqlResponse = (): EqlSearchStrategyResponse> => ({ id: 'some-id', diff --git a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx index 368a5a02d7167..4ccb90b0ee5ae 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx @@ -245,6 +245,7 @@ export const useTimelineEvents = ({ activeTimeline.setEqlRequest(request as TimelineEqlRequestOptions); activeTimeline.setEqlResponse(newTimelineResponse); } else { + // @ts-expect-error EqlSearchRequest.query is not compatible with QueryDslQueryContainer activeTimeline.setRequest(request); activeTimeline.setResponse(newTimelineResponse); } diff --git a/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts b/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts index cca2c27a9ff72..da0810bead47e 100644 --- a/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts +++ b/x-pack/plugins/security_solution/scripts/endpoint/resolver_generator_script.ts @@ -8,8 +8,8 @@ /* eslint-disable no-console */ import yargs from 'yargs'; import fs from 'fs'; -import { Client, ClientOptions } from '@elastic/elasticsearch'; -import { errors } from '@elastic/elasticsearch'; +import { Client, errors } from '@elastic/elasticsearch'; +import type { ClientOptions } from '@elastic/elasticsearch/lib/client'; import { ToolingLog, CA_CERT_PATH } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { indexHostsAndAlerts } from '../../common/endpoint/index_data'; @@ -196,7 +196,7 @@ async function main() { url, certificateAuthorities: [ca], }); - clientOptions = { node, ssl: { ca: [ca] } }; + clientOptions = { node, tls: { ca: [ca] } }; } else { kbnClient = new KbnClient({ log: new ToolingLog({ diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts index 3b37cd2ca15ab..5fd859444b935 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts @@ -458,7 +458,7 @@ async function queryUnitedIndex( endpointPolicyIds ); - let unitedMetadataQueryResponse: TransportResult>; + let unitedMetadataQueryResponse: TransportResult, unknown>; try { unitedMetadataQueryResponse = await context.core.elasticsearch.client.asCurrentUser.search( diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts index 00446a204ca89..5241b2b8e9738 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts @@ -57,6 +57,7 @@ export const ensureMigrationCleanupPolicy = async ({ if (!policyExists) { await esClient.ilm.putLifecycle({ policy, + // @ts-expect-error IlmAction is not valid body: migrationCleanupPolicy, }); } @@ -86,10 +87,8 @@ export const applyMigrationCleanupPolicy = async ({ await esClient.indices.putSettings({ index, body: { - settings: { - lifecycle: { - name: getMigrationCleanupPolicyName(alias), - }, + lifecycle: { + name: getMigrationCleanupPolicyName(alias), }, }, }); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts index 911160da01030..38d8c6f5ded81 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts @@ -35,7 +35,9 @@ export const replaceSignalsIndexAlias = async ({ await esClient.indices.updateAliases({ body: { actions: [ + // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { remove: { index: oldIndex, alias } }, + // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { add: { index: newIndex, alias, is_write_index: false } }, ], }, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts index 97ccd5b5f6b23..e08a3885800e9 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts @@ -784,8 +784,8 @@ describe('utils', () => { wroteStatus: false, timestampField, ruleName: 'myfakerulename', - // eslint-disable-next-line @typescript-eslint/no-explicit-any timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + // eslint-disable-next-line @typescript-eslint/no-explicit-any Record >, inputIndices: ['myfa*'], @@ -803,7 +803,7 @@ describe('utils', () => { test('returns true when missing timestamp field', async () => { const timestampField = '@timestamp'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, Context>> = { + const timestampFieldCapsResponse: Partial, unknown>> = { body: { indices: ['myfakeindex-1', 'myfakeindex-2', 'myfakeindex-3', 'myfakeindex-4'], fields: { @@ -829,8 +829,8 @@ describe('utils', () => { wroteStatus: false, timestampField, ruleName: 'myfakerulename', - // eslint-disable-next-line @typescript-eslint/no-explicit-any timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + // eslint-disable-next-line @typescript-eslint/no-explicit-any Record >, inputIndices: ['myfa*'], @@ -849,7 +849,7 @@ describe('utils', () => { test('returns true when missing logs-endpoint.alerts-* index and rule name is Endpoint Security', async () => { const timestampField = '@timestamp'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, Context>> = { + const timestampFieldCapsResponse: Partial, unknown>> = { body: { indices: [], fields: {}, @@ -860,8 +860,8 @@ describe('utils', () => { wroteStatus: false, timestampField, ruleName: 'Endpoint Security', - // eslint-disable-next-line @typescript-eslint/no-explicit-any timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + // eslint-disable-next-line @typescript-eslint/no-explicit-any Record >, inputIndices: ['logs-endpoint.alerts-*'], @@ -880,7 +880,7 @@ describe('utils', () => { test('returns true when missing logs-endpoint.alerts-* index and rule name is NOT Endpoint Security', async () => { const timestampField = '@timestamp'; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const timestampFieldCapsResponse: Partial, Context>> = { + const timestampFieldCapsResponse: Partial, unknown>> = { body: { indices: [], fields: {}, @@ -891,8 +891,8 @@ describe('utils', () => { wroteStatus: false, timestampField, ruleName: 'NOT Endpoint Security', - // eslint-disable-next-line @typescript-eslint/no-explicit-any timestampFieldCapsResponse: timestampFieldCapsResponse as TransportResult< + // eslint-disable-next-line @typescript-eslint/no-explicit-any Record >, inputIndices: ['logs-endpoint.alerts-*'], From d3552e102d98eb2a5426f6d6197d555e34e23e4a Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:25:44 +0200 Subject: [PATCH 049/172] fix errors in snapshot_restore --- x-pack/plugins/snapshot_restore/server/routes/api/app.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts index 217bce9721f63..ec2e66235d295 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts @@ -53,6 +53,7 @@ export function registerAppRoutes({ body: { has_all_requested: hasAllPrivileges, cluster }, } = await clusterClient.asCurrentUser.security.hasPrivileges({ body: { + // @ts-expect-error @elastic/elasticsearch doesn't declare all possible values in SecurityClusterPrivilege cluster: [...APP_REQUIRED_CLUSTER_PRIVILEGES, ...APP_SLM_CLUSTER_PRIVILEGES], }, }); From dfe35f4976939c380262f5281bd2cb817f052ba1 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:26:06 +0200 Subject: [PATCH 050/172] fix errors in transform --- .../transform/server/routes/api/privileges.ts | 1 + .../transform/server/routes/api/transforms.ts | 31 +++++++++---------- .../server/routes/api/transforms_nodes.ts | 1 + 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/transform/server/routes/api/privileges.ts b/x-pack/plugins/transform/server/routes/api/privileges.ts index f1900079ec9c4..6029260e13914 100644 --- a/x-pack/plugins/transform/server/routes/api/privileges.ts +++ b/x-pack/plugins/transform/server/routes/api/privileges.ts @@ -33,6 +33,7 @@ export function registerPrivilegesRoute({ router, license }: RouteDependencies) body: { has_all_requested: hasAllPrivileges, cluster }, } = await ctx.core.elasticsearch.client.asCurrentUser.security.hasPrivileges({ body: { + // @ts-expect-error SecurityClusterPrivilege doesn’t contain all the priviledges cluster: APP_CLUSTER_PRIVILEGES, }, }); diff --git a/x-pack/plugins/transform/server/routes/api/transforms.ts b/x-pack/plugins/transform/server/routes/api/transforms.ts index 2d46ec51efe25..4b6c2a57e052d 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms.ts @@ -16,10 +16,6 @@ import { SavedObjectsClientContract, } from 'kibana/server'; -import { - TransformGetTransform, - TransformGetTransformStats, -} from '@elastic/elasticsearch/api/requestParams'; import { TRANSFORM_STATE } from '../../../common/constants'; import { transformIdParamSchema, @@ -84,17 +80,21 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) { */ router.get( { path: addBasePath('transforms'), validate: false }, - license.guardApiRoute(async (ctx, req, res) => { - try { - const { body } = await ctx.core.elasticsearch.client.asCurrentUser.transform.getTransform({ - size: 1000, - ...req.params, - }); - return res.ok({ body }); - } catch (e) { - return res.customError(wrapError(wrapEsError(e))); + license.guardApiRoute( + async (ctx, req, res) => { + try { + const { body } = await ctx.core.elasticsearch.client.asCurrentUser.transform.getTransform( + { + size: 1000, + ...req.params, + } + ); + return res.ok({ body }); + } catch (e) { + return res.customError(wrapError(wrapEsError(e))); + } } - }) + ) ); /** @@ -133,7 +133,7 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) { */ router.get( { path: addBasePath('transforms/_stats'), validate: false }, - license.guardApiRoute( + license.guardApiRoute( async (ctx, req, res) => { try { const { body } = @@ -543,7 +543,6 @@ const previewTransformHandler: RequestHandler< try { const reqBody = req.body; const { body } = await ctx.core.elasticsearch.client.asCurrentUser.transform.previewTransform({ - // @ts-expect-error max_page_search_size is required in TransformPivot body: reqBody, }); if (isLatestTransform(reqBody)) { diff --git a/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts b/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts index 29a3c50b2eea9..5a260b63d5501 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms_nodes.ts @@ -54,6 +54,7 @@ export function registerTransformNodesRoutes({ router, license }: RouteDependenc body: { has_all_requested: hasAllPrivileges }, } = await ctx.core.elasticsearch.client.asCurrentUser.security.hasPrivileges({ body: { + // @ts-expect-error SecurityClusterPrivilege doesn’t contain all the priviledges cluster: NODES_INFO_PRIVILEGES, }, }); From 724ec0b757088c18018eb789df095e109ce5655b Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:26:41 +0200 Subject: [PATCH 051/172] fix errors in UA --- x-pack/plugins/upgrade_assistant/common/types.ts | 9 +++------ .../server/lib/es_deprecations_status.test.ts | 10 +++++----- .../server/lib/es_deprecations_status.ts | 13 +++++-------- .../server/lib/reindexing/index_settings.ts | 2 +- .../server/lib/reindexing/reindex_actions.test.ts | 6 +++--- .../server/lib/reindexing/reindex_service.test.ts | 6 +++--- .../server/lib/reindexing/reindex_service.ts | 7 +++++-- .../server/lib/reindexing/types.ts | 2 +- .../upgrade_assistant/server/routes/ml_snapshots.ts | 4 ++-- .../server/routes/update_index_settings.ts | 4 +--- 10 files changed, 29 insertions(+), 34 deletions(-) diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts index f07569c3bbbad..a296e158481fa 100644 --- a/x-pack/plugins/upgrade_assistant/common/types.ts +++ b/x-pack/plugins/upgrade_assistant/common/types.ts @@ -5,10 +5,7 @@ * 2.0. */ -import { - MigrationDeprecationInfoDeprecation, - MigrationDeprecationInfoResponse, -} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SavedObject, SavedObjectAttributes } from 'src/core/public'; export enum ReindexStep { @@ -210,8 +207,8 @@ export interface IndexSettingAction { deprecatedSettings: string[]; } export interface EnrichedDeprecationInfo - extends Omit { - type: keyof MigrationDeprecationInfoResponse; + extends Omit { + type: keyof estypes.MigrationDeprecationsResponse; isCritical: boolean; index?: string; correctiveAction?: ReindexAction | MlAction | IndexSettingAction; diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts index 76e6550e62ec9..ad7761f91e4fb 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts @@ -6,19 +6,19 @@ */ import _ from 'lodash'; -import { RequestEvent } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; -import { MigrationDeprecationInfoResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { getESUpgradeStatus } from './es_deprecations_status'; import fakeDeprecations from './__fixtures__/fake_deprecations.json'; const fakeIndexNames = Object.keys(fakeDeprecations.index_settings); -const asApiResponse = (body: T): RequestEvent => +const asApiResponse = (body: T): TransportResult => ({ body, - } as RequestEvent); + } as TransportResult); describe('getESUpgradeStatus', () => { const resolvedIndices = { @@ -32,7 +32,7 @@ describe('getESUpgradeStatus', () => { }; // @ts-expect-error mock data is too loosely typed - const deprecationsResponse: MigrationDeprecationInfoResponse = _.cloneDeep(fakeDeprecations); + const deprecationsResponse: estypes.MigrationDeprecationsResponse = _.cloneDeep(fakeDeprecations); const esClient = elasticsearchServiceMock.createScopedClusterClient(); diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts index df16b4150d579..aa08ecef78d32 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.ts @@ -5,10 +5,7 @@ * 2.0. */ -import { - MigrationDeprecationInfoDeprecation, - MigrationDeprecationInfoResponse, -} from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IScopedClusterClient } from 'src/core/server'; import { indexSettingDeprecations } from '../../common/constants'; import { EnrichedDeprecationInfo, ESUpgradeStatus } from '../../common/types'; @@ -28,8 +25,8 @@ export async function getESUpgradeStatus( combinedDeprecations = combinedDeprecations.concat(indices); } else { const deprecationsByType = deprecations[ - deprecationType as keyof MigrationDeprecationInfoResponse - ] as MigrationDeprecationInfoDeprecation[]; + deprecationType as keyof estypes.MigrationDeprecationsResponse + ] as estypes.MigrationDeprecationsDeprecation[]; const enrichedDeprecationInfo = deprecationsByType.map( ({ @@ -46,7 +43,7 @@ export async function getESUpgradeStatus( details, message, url, - type: deprecationType as keyof MigrationDeprecationInfoResponse, + type: deprecationType as keyof estypes.MigrationDeprecationsResponse, isCritical: level === 'critical', resolveDuringUpgrade, correctiveAction: getCorrectiveAction(message, metadata), @@ -72,7 +69,7 @@ export async function getESUpgradeStatus( // Reformats the index deprecations to an array of deprecation warnings extended with an index field. const getCombinedIndexInfos = async ( - deprecations: MigrationDeprecationInfoResponse, + deprecations: estypes.MigrationDeprecationsResponse, dataClient: IScopedClusterClient ) => { const indices = Object.keys(deprecations.index_settings).reduce( diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts index 0fb531b286854..b65984af5deb3 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/index_settings.ts @@ -99,7 +99,7 @@ export const getDeprecatedSettingWarning = ( ): ReindexWarning | undefined => { const { settings } = flatSettings; - const deprecatedSettingsInUse = Object.keys(settings).filter((setting) => { + const deprecatedSettingsInUse = Object.keys(settings || {}).filter((setting) => { return deprecatedSettings.indexOf(setting) > -1; }); diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts index 3477020daf4f4..ad5ca990b5ffe 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { RequestEvent } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; import { SavedObjectsErrorHelpers } from 'src/core/server'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths @@ -257,10 +257,10 @@ describe('ReindexActions', () => { }); describe('getFlatSettings', () => { - const asApiResponse = (body: T): RequestEvent => + const asApiResponse = (body: T): TransportResult => ({ body, - } as RequestEvent); + } as TransportResult); it('returns flat settings', async () => { clusterClient.asCurrentUser.indices.get.mockResolvedValueOnce( diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts index b73c4b2df413b..1a95bfc71bcd0 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts @@ -7,7 +7,7 @@ jest.mock('../es_indices_state_check', () => ({ esIndicesStateCheck: jest.fn() })); import { BehaviorSubject } from 'rxjs'; -import { RequestEvent } from '@elastic/transport'; +import { TransportResult } from '@elastic/transport'; import { Logger } from 'src/core/server'; import { elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths @@ -35,10 +35,10 @@ import { reindexServiceFactory, } from './reindex_service'; -const asApiResponse = (body: T): RequestEvent => +const asApiResponse = (body: T): TransportResult => ({ body, - } as RequestEvent); + } as TransportResult); const { currentMajor, prevMajor } = getMockVersionInfo(); diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts index 1bf45e3a4a038..106961e1b6b30 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts @@ -226,7 +226,7 @@ export const reindexServiceFactory = ( if (reindexOp.attributes.lastCompletedStep >= ReindexStep.readonly) { await esClient.indices.putSettings({ index: reindexOp.attributes.indexName, - body: { settings: { blocks: { write: false } } }, + body: { blocks: { write: false } }, }); } @@ -290,7 +290,7 @@ export const reindexServiceFactory = ( const { indexName } = reindexOp.attributes; const { body: putReadonly } = await esClient.indices.putSettings({ index: indexName, - body: { settings: { blocks: { write: true } } }, + body: { blocks: { write: true } }, }); if (!putReadonly.acknowledged) { @@ -456,8 +456,11 @@ export const reindexServiceFactory = ( const { body: aliasResponse } = await esClient.indices.updateAliases({ body: { actions: [ + // @ts-expect-error @elastic/elasticseach IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { add: { index: newIndexName, alias: indexName } }, + // @ts-expect-error @elastic/elasticseach IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { remove_index: { index: indexName } }, + // @ts-expect-error @elastic/elasticseach IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid ...extraAliases, ], }, diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts index 094a7cbb3844f..8d600849987db 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts @@ -20,7 +20,7 @@ interface MetaProperties { } export interface FlatSettings { - settings: estypes.IndicesIndexState['settings']; + settings?: estypes.IndicesIndexState['settings']; mappings?: { properties?: MappingProperties; _meta?: MetaProperties; diff --git a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts index 49d64ce97ae06..65e707339d67c 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts @@ -257,7 +257,7 @@ export function registerMlSnapshotRoutes({ router }: RouteDependencies) { } return response.customError({ - statusCode: upgradeSnapshotError ? upgradeSnapshotError.statusCode : 500, + statusCode: upgradeSnapshotError ? upgradeSnapshotError.statusCode! : 500, body: { message: upgradeSnapshotError?.body?.error?.reason || @@ -286,7 +286,7 @@ export function registerMlSnapshotRoutes({ router }: RouteDependencies) { } return response.customError({ - statusCode: upgradeSnapshotError ? upgradeSnapshotError.statusCode : 500, + statusCode: upgradeSnapshotError ? upgradeSnapshotError.statusCode! : 500, body: { message: upgradeSnapshotError?.body?.error?.reason || diff --git a/x-pack/plugins/upgrade_assistant/server/routes/update_index_settings.ts b/x-pack/plugins/upgrade_assistant/server/routes/update_index_settings.ts index b90ff4281644b..751e685002a99 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/update_index_settings.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/update_index_settings.ts @@ -44,9 +44,7 @@ export function registerUpdateSettingsRoute({ router }: RouteDependencies) { const { body: settingsResponse } = await client.asCurrentUser.indices.putSettings({ index: indexName, - body: { - settings: settingsToDelete, - }, + body: settingsToDelete, }); return response.ok({ From fc9c4a45bde2f76d915579c37dd3030a30d343de Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:26:56 +0200 Subject: [PATCH 052/172] fix errors in uptime --- .../uptime/server/lib/requests/get_monitor_availability.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts b/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts index bf6c176a233c4..33db37329f77a 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts @@ -147,10 +147,11 @@ export const getMonitorAvailability: UMElasticsearchQueryFn< }, }; + // @ts-expect-error AggregationsBucketsPath is not valid const { body: result } = await uptimeEsClient.search({ body: esParams }); - + // @ts-expect-error aggregation is not valid afterKey = result?.aggregations?.monitors?.after_key as AfterKey; - + // @ts-expect-error aggregation is not valid queryResults.push(formatBuckets(result?.aggregations?.monitors?.buckets || [])); } while (afterKey !== undefined); From c1958a6404d1079d8e2e3235d97bd001c12bae4e Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 15:27:17 +0200 Subject: [PATCH 053/172] fix errors in x-pack/test --- .../apps/index_lifecycle_management.ts | 1 - .../tests/alerting/alerts.ts | 11 +- .../tests/alerting/create.ts | 6 +- .../tests/alerting/enable.ts | 6 +- .../tests/action_task_params/migrations.ts | 22 ++- .../preconfigured_alert_history_connector.ts | 10 +- .../spaces_only/tests/actions/enqueue.ts | 6 +- .../spaces_only/tests/alerting/alerts_base.ts | 11 +- .../spaces_only/tests/alerting/create.ts | 17 ++- .../spaces_only/tests/alerting/enable.ts | 6 +- .../spaces_only/tests/alerting/migrations.ts | 57 +++++--- .../api_integration/apis/lens/telemetry.ts | 12 +- .../apis/logstash/cluster/load.ts | 2 +- .../ingest_pipelines/lib/elasticsearch.ts | 9 +- .../snapshot_restore/lib/elasticsearch.ts | 47 +++--- .../apis/metrics_ui/metric_threshold_alert.ts | 16 +- .../apis/metrics_ui/metrics_alerting.ts | 12 +- .../apis/security/index_fields.ts | 2 +- .../api_integration/apis/security/roles.ts | 2 +- .../api_integration/apis/security/users.ts | 4 +- .../apis/security_solution/utils.ts | 35 +++-- .../telemetry/telemetry_optin_notice_seen.ts | 4 +- .../apis/uptime/rest/helper/make_checks.ts | 8 +- .../apis/uptime/rest/helper/make_ping.ts | 4 +- .../tests/alerts/rule_registry.ts | 11 +- .../tests/metadata/event_metadata.ts | 2 +- .../service_overview/dependencies/index.ts | 2 +- .../tests/services/annotations.ts | 10 +- .../tests/services/derived_annotations.ts | 2 +- .../case_api_integration/common/lib/utils.ts | 97 +++++++----- .../tests/common/cases/find_cases.ts | 6 +- .../tests/common/sub_cases/find_sub_cases.ts | 24 ++- .../tests/create_signals_migrations.ts | 2 +- .../detection_engine_api_integration/utils.ts | 64 ++++---- .../tests/encrypted_saved_objects_api.ts | 4 +- .../search_examples/search_session_example.ts | 2 +- .../apis/agents/unenroll.ts | 16 +- .../apis/data_streams/list.ts | 25 ++-- .../apis/enrollment_api_keys/crud.ts | 29 ++-- .../apis/epm/data_stream.ts | 138 +++++++++++------- .../apis/epm/final_pipeline.ts | 28 ++-- .../fleet_api_integration/apis/epm/ilm.ts | 13 +- .../apis/epm/install_overrides.ts | 11 +- .../apis/epm/install_remove_assets.ts | 10 ++ .../apis/epm/template.ts | 24 +-- .../apis/epm/update_assets.ts | 114 +++++++++------ .../apis/service_tokens.ts | 11 +- .../apis/settings/update.ts | 2 +- .../index_lifecycle_management/home_page.ts | 1 - x-pack/test/functional/services/ml/api.ts | 24 +-- .../functional/services/ml/test_resources.ts | 2 + .../test/functional/services/transform/api.ts | 18 +-- x-pack/test/lists_api_integration/utils.ts | 20 +-- .../trial/tests/annotations.ts | 18 +-- .../event_log/service_api_integration.ts | 2 +- .../test_suites/task_manager/migrations.ts | 33 +++-- .../task_manager/task_management.ts | 4 +- .../ilm_migration_apis.ts | 5 +- .../common/lib/create_users_and_roles.ts | 4 +- .../common/lib/saved_object_test_utils.ts | 6 +- .../common/suites/import.ts | 8 +- .../common/suites/resolve_import_errors.ts | 4 +- .../test/saved_objects_field_count/runner.ts | 4 +- .../dashboard/async_search/async_search.ts | 2 +- .../async_search/save_search_session.ts | 2 +- .../async_search/search_sessions_tour.ts | 2 +- .../tests/kerberos/kerberos_login.ts | 2 +- .../oidc/authorization_code_flow/oidc_auth.ts | 2 +- .../tests/saml/saml_login.ts | 4 +- .../tests/token/header.ts | 4 +- .../tests/token/session.ts | 2 +- .../services/endpoint.ts | 2 +- .../apis/package.ts | 27 ++-- .../services/resolver.ts | 2 +- .../common/lib/create_users_and_roles.ts | 4 +- .../common/suites/copy_to_space.ts | 6 +- .../common/suites/delete.ts | 12 +- .../suites/disable_legacy_url_aliases.ts | 6 +- 78 files changed, 642 insertions(+), 547 deletions(-) diff --git a/x-pack/test/accessibility/apps/index_lifecycle_management.ts b/x-pack/test/accessibility/apps/index_lifecycle_management.ts index da56cfd702abf..83124bc517ef6 100644 --- a/x-pack/test/accessibility/apps/index_lifecycle_management.ts +++ b/x-pack/test/accessibility/apps/index_lifecycle_management.ts @@ -76,7 +76,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - // @ts-expect-error @elastic/elasticsearch DeleteSnapshotLifecycleRequest.policy_id is required await esClient.ilm.deleteLifecycle({ policy: POLICY_NAME }); await esClient.indices.deleteIndexTemplate({ name: indexTemplateName }); }); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts index 53a0fe4ac9e63..5a12b6882ac23 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts @@ -8,7 +8,6 @@ import expect from '@kbn/expect'; import { omit } from 'lodash'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios, Superuser } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { @@ -535,9 +534,9 @@ instanceStateValue: true const scheduledActionTask: estypes.SearchHit< TaskRunning > = await retry.try(async () => { - const searchResult: TransportResult< - estypes.SearchResponse> - > = await es.search({ + const searchResult = await es.search< + TaskRunning + >({ index: '.kibana_task_manager', body: { query: { @@ -570,8 +569,8 @@ instanceStateValue: true }, }, }); - expect((searchResult.body.hits.total as estypes.SearchTotalHits).value).to.eql(1); - return searchResult.body.hits.hits[0]; + expect((searchResult.hits.total as estypes.SearchTotalHits).value).to.eql(1); + return searchResult.hits.hits[0]; }); // Ensure the next runAt is set to the retryDate by custom logic diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts index cce3650ecb4cc..eaa73facb3734 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts @@ -6,8 +6,6 @@ */ import expect from '@kbn/expect'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios } from '../../scenarios'; import { checkAAD, @@ -32,11 +30,11 @@ export default function createAlertTests({ getService }: FtrProviderContext) { after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: TransportResult> = await es.get({ + const scheduledTask = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); - return scheduledTask.body._source!; + return scheduledTask._source!; } for (const scenario of UserAtSpaceScenarios) { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts index 9fa329e985ed9..1589a63cb7108 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts @@ -6,8 +6,6 @@ */ import expect from '@kbn/expect'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { UserAtSpaceScenarios } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { @@ -34,11 +32,11 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: TransportResult> = await es.get({ + const scheduledTask = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); - return scheduledTask.body._source!; + return scheduledTask._source!; } for (const scenario of UserAtSpaceScenarios) { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/action_task_params/migrations.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/action_task_params/migrations.ts index 0c0b62b6cb529..27b523fa24298 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/action_task_params/migrations.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/action_task_params/migrations.ts @@ -26,10 +26,13 @@ export default function createGetTests({ getService }: FtrProviderContext) { it('7.16.0 migrates action_task_params to use references array', async () => { // Inspect migration of non-preconfigured connector ID - const response = await es.get>({ - index: '.kibana', - id: 'action_task_params:b9af6280-0052-11ec-917b-f7aa317691ed', - }); + const response = await es.get>( + { + index: '.kibana', + id: 'action_task_params:b9af6280-0052-11ec-917b-f7aa317691ed', + }, + { meta: true } + ); expect(response.statusCode).to.eql(200); const { actionId, relatedSavedObjects, references } = getActionIdAndRelatedSavedObjects( response.body._source @@ -49,10 +52,13 @@ export default function createGetTests({ getService }: FtrProviderContext) { }); // Inspect migration of preconfigured connector ID - const preconfiguredConnectorResponse = await es.get>({ - index: '.kibana', - id: 'action_task_params:0205a520-0054-11ec-917b-f7aa317691ed', - }); + const preconfiguredConnectorResponse = await es.get>( + { + index: '.kibana', + id: 'action_task_params:0205a520-0054-11ec-917b-f7aa317691ed', + }, + { meta: true } + ); expect(preconfiguredConnectorResponse.statusCode).to.eql(200); const { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts index 9c86075427dae..dea873073f61f 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts @@ -6,8 +6,6 @@ */ import expect from '@kbn/expect'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { getTestAlertData, ObjectRemover } from '../../../../common/lib'; import { AlertHistoryDefaultIndexName } from '../../../../../../plugins/actions/common'; @@ -67,10 +65,10 @@ export default function preconfiguredAlertHistoryConnectorTests({ await waitForStatus(response.body.id, new Set(['active'])); await retry.try(async () => { - const result: TransportResult> = await es.search({ + const result = await es.search({ index: AlertHistoryDefaultIndexName, }); - const indexedItems = result.body.hits.hits; + const indexedItems = result.hits.hits; expect(indexedItems.length).to.eql(1); const indexedDoc = indexedItems[0]._source; @@ -105,10 +103,10 @@ export default function preconfiguredAlertHistoryConnectorTests({ await waitForStatus(response.body.id, new Set(['active'])); await retry.try(async () => { - const result: TransportResult> = await es.search({ + const result = await es.search({ index: ALERT_HISTORY_OVERRIDE_INDEX, }); - const indexedItems = result.body.hits.hits; + const indexedItems = result.hits.hits; expect(indexedItems.length).to.eql(1); const indexedDoc = indexedItems[0]._source; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts index 683f9f9a79c49..084c105aa723a 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/enqueue.ts @@ -123,7 +123,7 @@ export default function ({ getService }: FtrProviderContext) { }, }, }); - expect((searchResult.body.hits.total as estypes.SearchTotalHits).value).to.eql(0); + expect((searchResult.hits.total as estypes.SearchTotalHits).value).to.eql(0); }); }); @@ -174,7 +174,7 @@ export default function ({ getService }: FtrProviderContext) { }, }, }); - const total = (runningSearchResult.body.hits.total as estypes.SearchTotalHits).value; + const total = (runningSearchResult.hits.total as estypes.SearchTotalHits).value; expect(total).to.eql(1); }); @@ -195,7 +195,7 @@ export default function ({ getService }: FtrProviderContext) { }, }, }); - const total = (runningSearchResult.body.hits.total as estypes.SearchTotalHits).value; + const total = (runningSearchResult.hits.total as estypes.SearchTotalHits).value; expect(total).to.eql(0); }); }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts index ea91ce7234a4b..db2ef523841b2 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts @@ -8,7 +8,6 @@ import expect from '@kbn/expect'; import { omit } from 'lodash'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/elasticsearch'; import { Response as SupertestResponse } from 'supertest'; import { RecoveredActionGroup } from '../../../../../plugins/alerting/common'; import { Space } from '../../../common/types'; @@ -380,9 +379,9 @@ instanceStateValue: true const scheduledActionTask: estypes.SearchHit< TaskRunning > = await retry.try(async () => { - const searchResult: TransportResult< - estypes.SearchResponse> - > = await es.search({ + const searchResult = await es.search< + TaskRunning + >({ index: '.kibana_task_manager', body: { query: { @@ -415,8 +414,8 @@ instanceStateValue: true }, }, }); - expect((searchResult.body.hits.total as estypes.SearchTotalHits).value).to.eql(1); - return searchResult.body.hits.hits[0]; + expect((searchResult.hits.total as estypes.SearchTotalHits).value).to.eql(1); + return searchResult.hits.hits[0]; }); expect(scheduledActionTask._source!.task.runAt).to.eql(retryDate.toISOString()); }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts index c5774f9076132..dce5de4188220 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts @@ -6,8 +6,6 @@ */ import expect from '@kbn/expect'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { SavedObject } from 'kibana/server'; import { Spaces } from '../../scenarios'; import { @@ -32,11 +30,11 @@ export default function createAlertTests({ getService }: FtrProviderContext) { after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: TransportResult> = await es.get({ + const scheduledTask = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); - return scheduledTask.body._source!; + return scheduledTask._source!; } it('should handle create alert request appropriately', async () => { @@ -192,10 +190,13 @@ export default function createAlertTests({ getService }: FtrProviderContext) { execution_status: response.body.execution_status, }); - const esResponse = await es.get>({ - index: '.kibana', - id: `alert:${response.body.id}`, - }); + const esResponse = await es.get>( + { + index: '.kibana', + id: `alert:${response.body.id}`, + }, + { meta: true } + ); expect(esResponse.statusCode).to.eql(200); const rawActions = (esResponse.body._source as any)?.alert.actions ?? []; expect(rawActions).to.eql([ diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts index d1c534d1aa446..611c2498dd9d3 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts @@ -6,8 +6,6 @@ */ import expect from '@kbn/expect'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { Spaces } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { @@ -31,11 +29,11 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex after(() => objectRemover.removeAll()); async function getScheduledTask(id: string): Promise { - const scheduledTask: TransportResult> = await es.get({ + const scheduledTask = await es.get({ id: `task:${id}`, index: '.kibana_task_manager', }); - return scheduledTask.body._source!; + return scheduledTask._source!; } it('should handle enable alert request appropriately', async () => { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts index 8567578cea7a1..250f78c6b2800 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations.ts @@ -7,7 +7,6 @@ import expect from '@kbn/expect'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { getUrlPrefix } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import type { RawAlert, RawAlertAction } from '../../../../../plugins/alerting/server/types'; @@ -182,10 +181,13 @@ export default function createGetTests({ getService }: FtrProviderContext) { it('7.15.0 migrates security_solution alerts with exceptionLists to be saved object references', async () => { // NOTE: We hae to use elastic search directly against the ".kibana" index because alerts do not expose the references which we want to test exists - const response = await es.get<{ references: [{}] }>({ - index: '.kibana', - id: 'alert:38482620-ef1b-11eb-ad71-7de7959be71c', - }); + const response = await es.get<{ references: [{}] }>( + { + index: '.kibana', + id: 'alert:38482620-ef1b-11eb-ad71-7de7959be71c', + }, + { meta: true } + ); expect(response.statusCode).to.eql(200); expect(response.body._source?.references).to.eql([ { @@ -202,16 +204,19 @@ export default function createGetTests({ getService }: FtrProviderContext) { }); it('7.16.0 migrates existing alerts to contain legacyId field', async () => { - const searchResult: TransportResult> = await es.search({ - index: '.kibana', - body: { - query: { - term: { - _id: 'alert:74f3e6d7-b7bb-477d-ac28-92ee22728e6e', + const searchResult = await es.search( + { + index: '.kibana', + body: { + query: { + term: { + _id: 'alert:74f3e6d7-b7bb-477d-ac28-92ee22728e6e', + }, }, }, }, - }); + { meta: true } + ); expect(searchResult.statusCode).to.equal(200); expect((searchResult.body.hits.total as estypes.SearchTotalHits).value).to.equal(1); const hit = searchResult.body.hits.hits[0]; @@ -221,16 +226,19 @@ export default function createGetTests({ getService }: FtrProviderContext) { }); it('7.16.0 migrates existing rules so predefined connectors are not stored in references', async () => { - const searchResult: TransportResult> = await es.search({ - index: '.kibana', - body: { - query: { - term: { - _id: 'alert:9c003b00-00ee-11ec-b067-2524946ba327', + const searchResult = await es.search( + { + index: '.kibana', + body: { + query: { + term: { + _id: 'alert:9c003b00-00ee-11ec-b067-2524946ba327', + }, }, }, }, - }); + { meta: true } + ); expect(searchResult.statusCode).to.equal(200); expect((searchResult.body.hits.total as estypes.SearchTotalHits).value).to.equal(1); const hit = searchResult.body.hits.hits[0]; @@ -261,10 +269,13 @@ export default function createGetTests({ getService }: FtrProviderContext) { it('7.16.0 migrates security_solution (Legacy) siem.notifications with "ruleAlertId" to be saved object references', async () => { // NOTE: We hae to use elastic search directly against the ".kibana" index because alerts do not expose the references which we want to test exists - const response = await es.get<{ references: [{}] }>({ - index: '.kibana', - id: 'alert:d7a8c6a1-9394-48df-a634-d5457c35d747', - }); + const response = await es.get<{ references: [{}] }>( + { + index: '.kibana', + id: 'alert:d7a8c6a1-9394-48df-a634-d5457c35d747', + }, + { meta: true } + ); expect(response.statusCode).to.eql(200); expect(response.body._source?.references).to.eql([ { diff --git a/x-pack/test/api_integration/apis/lens/telemetry.ts b/x-pack/test/api_integration/apis/lens/telemetry.ts index 9f691115232ae..8d73a733a2266 100644 --- a/x-pack/test/api_integration/apis/lens/telemetry.ts +++ b/x-pack/test/api_integration/apis/lens/telemetry.ts @@ -7,6 +7,7 @@ import moment from 'moment'; import expect from '@kbn/expect'; +import { convertToKibanaClient } from '@kbn/test'; import { FtrProviderContext } from '../../ftr_provider_context'; @@ -20,6 +21,7 @@ const COMMON_HEADERS = { export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); const es = getService('es'); + const kibanaClient = convertToKibanaClient(es); async function assertExpectedSavedObjects(num: number) { // Make sure that new/deleted docs are available to search @@ -27,9 +29,7 @@ export default ({ getService }: FtrProviderContext) => { index: '.kibana', }); - const { - body: { count }, - } = await es.count({ + const { count } = await es.count({ index: '.kibana', q: 'type:lens-ui-telemetry', }); @@ -107,7 +107,7 @@ export default ({ getService }: FtrProviderContext) => { refresh: 'wait_for', }); - const result = await getDailyEvents('.kibana', () => Promise.resolve(es)); + const result = await getDailyEvents('.kibana', () => Promise.resolve(kibanaClient)); expect(result).to.eql({ byDate: {}, @@ -150,7 +150,7 @@ export default ({ getService }: FtrProviderContext) => { ], }); - const result = await getDailyEvents('.kibana', () => Promise.resolve(es)); + const result = await getDailyEvents('.kibana', () => Promise.resolve(kibanaClient)); expect(result).to.eql({ byDate: { @@ -177,7 +177,7 @@ export default ({ getService }: FtrProviderContext) => { await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); - const results = await getVisualizationCounts(() => Promise.resolve(es), '.kibana'); + const results = await getVisualizationCounts(() => Promise.resolve(kibanaClient), '.kibana'); expect(results).to.have.keys([ 'saved_overall', diff --git a/x-pack/test/api_integration/apis/logstash/cluster/load.ts b/x-pack/test/api_integration/apis/logstash/cluster/load.ts index 1997b65c5a871..951acd3bb3aae 100644 --- a/x-pack/test/api_integration/apis/logstash/cluster/load.ts +++ b/x-pack/test/api_integration/apis/logstash/cluster/load.ts @@ -16,7 +16,7 @@ export default function ({ getService }: FtrProviderContext) { it('should return the ES cluster info', async () => { const { body } = await supertest.get('/api/logstash/cluster').expect(200); - const { body: responseFromES } = await es.info(); + const responseFromES = await es.info(); expect(body.cluster.uuid).to.eql(responseFromES.cluster_uuid); }); }); diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts index 5a4459fced624..c2a42356f5f51 100644 --- a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts @@ -37,11 +37,10 @@ export const registerEsHelpers = (getService: FtrProviderContext['getService']) pipelinesCreated.push(pipeline.id); } - return es.ingest.putPipeline(pipeline).then(({ body }) => body); + return es.ingest.putPipeline(pipeline); }; - const deletePipeline = (pipelineId: string) => - es.ingest.deletePipeline({ id: pipelineId }).then(({ body }) => body); + const deletePipeline = (pipelineId: string) => es.ingest.deletePipeline({ id: pipelineId }); const cleanupPipelines = () => Promise.all(pipelinesCreated.map(deletePipeline)) @@ -54,11 +53,11 @@ export const registerEsHelpers = (getService: FtrProviderContext['getService']) }); const createIndex = (index: { index: string; id: string; body: object }) => { - return es.index(index).then(({ body }) => body); + return es.index(index); }; const deleteIndex = (indexName: string) => { - return es.indices.delete({ index: indexName }).then(({ body }) => body); + return es.indices.delete({ index: indexName }); }; return { diff --git a/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts b/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts index 9b4d39a3b10b3..2b7f5cdc30091 100644 --- a/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts +++ b/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts @@ -39,18 +39,16 @@ export const registerEsHelpers = (getService: FtrProviderContext['getService']) const es = getService('es'); const createRepository = (repoName: string) => { - return es.snapshot - .createRepository({ - repository: repoName, - body: { - type: 'fs', - settings: { - location: '/tmp/', - }, + return es.snapshot.createRepository({ + repository: repoName, + body: { + type: 'fs', + settings: { + location: '/tmp/', }, - verify: false, - }) - .then(({ body }) => body); + }, + verify: false, + }); }; const createPolicy = (policy: SlmPolicy, cachePolicy?: boolean) => { @@ -58,27 +56,22 @@ export const registerEsHelpers = (getService: FtrProviderContext['getService']) policiesCreated.push(policy.name); } - return es.slm - .putLifecycle({ - policy_id: policy.name, - // TODO: bring {@link SlmPolicy} in line with {@link PutSnapshotLifecycleRequest['body']} - // @ts-expect-error - body: policy, - }) - .then(({ body }) => body); + return es.slm.putLifecycle({ + policy_id: policy.name, + // TODO: bring {@link SlmPolicy} in line with {@link PutSnapshotLifecycleRequest['body']} + // @ts-expect-error + body: policy, + }); }; const getPolicy = (policyName: string) => { - return es.slm - .getLifecycle({ - policy_id: policyName, - human: true, - }) - .then(({ body }) => body); + return es.slm.getLifecycle({ + policy_id: policyName, + human: true, + }); }; - const deletePolicy = (policyName: string) => - es.slm.deleteLifecycle({ policy_id: policyName }).then(({ body }) => body); + const deletePolicy = (policyName: string) => es.slm.deleteLifecycle({ policy_id: policyName }); const cleanupPolicies = () => Promise.all(policiesCreated.map(deletePolicy)) diff --git a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts index 66c40e2e6e92d..8857928463742 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts @@ -6,6 +6,7 @@ */ import expect from '@kbn/expect'; +import { convertToKibanaClient } from '@kbn/test'; import { InfraSource } from '../../../../plugins/infra/common/source_configuration/source_configuration'; import { FtrProviderContext } from '../../ftr_provider_context'; import { @@ -25,6 +26,7 @@ const { gauge, rate } = DATES['alert-test-data']; export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const esClient = getService('es'); + const kbnClient = convertToKibanaClient(esClient); const baseParams: EvaluatedAlertParams = { groupBy: void 0, @@ -100,7 +102,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: gauge.max }; - const results = await evaluateAlert(esClient, params, configuration, [], timeFrame); + const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { '*': { @@ -123,7 +125,7 @@ export default function ({ getService }: FtrProviderContext) { it('should alert on the last value when the end date is the same as the last event', async () => { const params = { ...baseParams }; const timeFrame = { end: gauge.max }; - const results = await evaluateAlert(esClient, params, configuration, [], timeFrame); + const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { '*': { @@ -160,7 +162,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: gauge.max }; - const results = await evaluateAlert(esClient, params, configuration, [], timeFrame); + const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { dev: { @@ -200,7 +202,7 @@ export default function ({ getService }: FtrProviderContext) { groupBy: ['env'], }; const timeFrame = { end: gauge.max }; - const results = await evaluateAlert(esClient, params, configuration, [], timeFrame); + const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { dev: { @@ -242,7 +244,7 @@ export default function ({ getService }: FtrProviderContext) { }; const timeFrame = { end: gauge.midpoint }; const results = await evaluateAlert( - esClient, + kbnClient, params, configuration, ['dev', 'prod'], @@ -301,7 +303,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: rate.max }; - const results = await evaluateAlert(esClient, params, configuration, [], timeFrame); + const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { '*': { @@ -341,7 +343,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: rate.max }; - const results = await evaluateAlert(esClient, params, configuration, [], timeFrame); + const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { dev: { diff --git a/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts b/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts index 90b815d4d0530..f2c9d48ad4652 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metrics_alerting.ts @@ -42,8 +42,9 @@ export default function ({ getService }: FtrProviderContext) { '@timestamp', timeframe ); - const { body: result } = await client.search({ + const result = await client.search({ index, + // @ts-expect-error @elastic/elasticsearch AggregationsBucketsPath is not valid body: searchBody, }); @@ -65,8 +66,9 @@ export default function ({ getService }: FtrProviderContext) { undefined, '{"bool":{"should":[{"match_phrase":{"agent.hostname":"foo"}}],"minimum_should_match":1}}' ); - const { body: result } = await client.search({ + const result = await client.search({ index, + // @ts-expect-error @elastic/elasticsearch AggregationsBucketsPath is not valid body: searchBody, }); @@ -87,8 +89,9 @@ export default function ({ getService }: FtrProviderContext) { timeframe, 'agent.id' ); - const { body: result } = await client.search({ + const result = await client.search({ index, + // @ts-expect-error @elastic/elasticsearch AggregationsBucketsPath is not valid body: searchBody, }); @@ -108,8 +111,9 @@ export default function ({ getService }: FtrProviderContext) { 'agent.id', '{"bool":{"should":[{"match_phrase":{"agent.hostname":"foo"}}],"minimum_should_match":1}}' ); - const { body: result } = await client.search({ + const result = await client.search({ index, + // @ts-expect-error @elastic/elasticsearch AggregationsBucketsPath is not valid body: searchBody, }); diff --git a/x-pack/test/api_integration/apis/security/index_fields.ts b/x-pack/test/api_integration/apis/security/index_fields.ts index c21f65eb488ba..621a183182348 100644 --- a/x-pack/test/api_integration/apis/security/index_fields.ts +++ b/x-pack/test/api_integration/apis/security/index_fields.ts @@ -43,7 +43,7 @@ export default function ({ getService }: FtrProviderContext) { it('should not include runtime fields', async () => { // First, make sure the mapping actually includes a runtime field - const { body: mapping } = await es.indices.getMapping({ + const mapping = await es.indices.getMapping({ index: 'flstest', }); diff --git a/x-pack/test/api_integration/apis/security/roles.ts b/x-pack/test/api_integration/apis/security/roles.ts index 440bb4ca32f18..dafe1f33954e5 100644 --- a/x-pack/test/api_integration/apis/security/roles.ts +++ b/x-pack/test/api_integration/apis/security/roles.ts @@ -263,7 +263,7 @@ export default function ({ getService }: FtrProviderContext) { }) .expect(basic ? 403 : 204); - const { body: role } = await es.security.getRole({ name: 'role_to_update_with_dls_fls' }); + const role = await es.security.getRole({ name: 'role_to_update_with_dls_fls' }); expect(role.role_to_update_with_dls_fls.cluster).to.eql(basic ? ['monitor'] : ['manage']); expect(role.role_to_update_with_dls_fls.run_as).to.eql( diff --git a/x-pack/test/api_integration/apis/security/users.ts b/x-pack/test/api_integration/apis/security/users.ts index 60554d2cf7c04..20f591205be39 100644 --- a/x-pack/test/api_integration/apis/security/users.ts +++ b/x-pack/test/api_integration/apis/security/users.ts @@ -31,7 +31,7 @@ export default function ({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .expect(204); - const { body } = await es.security.getUser({ username: mockUserName }); + const body = await es.security.getUser({ username: mockUserName }); expect(body[mockUserName].enabled).to.be(false); }); @@ -41,7 +41,7 @@ export default function ({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .expect(204); - const { body } = await es.security.getUser({ username: mockUserName }); + const body = await es.security.getUser({ username: mockUserName }); expect(body[mockUserName].enabled).to.be(true); }); }); diff --git a/x-pack/test/api_integration/apis/security_solution/utils.ts b/x-pack/test/api_integration/apis/security_solution/utils.ts index 67e55e5ae708e..e44536701d5b3 100644 --- a/x-pack/test/api_integration/apis/security_solution/utils.ts +++ b/x-pack/test/api_integration/apis/security_solution/utils.ts @@ -7,33 +7,36 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; -import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { JsonObject, JsonArray } from '@kbn/utility-types'; export async function getSavedObjectFromES( - es: KibanaClient, + es: Client, savedObjectType: string, query?: object ): Promise, unknown>> { - return await es.search({ - index: '.kibana', - body: { - query: { - bool: { - filter: [ - { ...query }, - { - term: { - type: { - value: savedObjectType, + return await es.search( + { + index: '.kibana', + body: { + query: { + bool: { + filter: [ + { ...query }, + { + term: { + type: { + value: savedObjectType, + }, }, }, - }, - ], + ], + }, }, }, }, - }); + { meta: true } + ); } export const getFilterValue = (hostName: string, from: string, to: string): JsonObject => ({ diff --git a/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts b/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts index 9e9211c4b5893..2a4725739e73f 100644 --- a/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts +++ b/x-pack/test/api_integration/apis/telemetry/telemetry_optin_notice_seen.ts @@ -24,9 +24,7 @@ export default function optInTest({ getService }: FtrProviderContext) { await supertest.put('/api/telemetry/v2/userHasSeenNotice').set('kbn-xsrf', 'xxx').expect(200); - const { - body: { _source }, - } = await client.get<{ telemetry: { userHasSeenNotice: boolean } }>({ + const { _source } = await client.get<{ telemetry: { userHasSeenNotice: boolean } }>({ index: '.kibana', id: 'telemetry:telemetry', }); diff --git a/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts b/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts index 3f5addd6243e3..b9e913524cb1f 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts @@ -7,12 +7,12 @@ import uuid from 'uuid'; import { merge, flattenDeep } from 'lodash'; -import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { makePing } from './make_ping'; import { TlsProps } from './make_tls'; interface CheckProps { - es: KibanaClient; + es: Client; monitorId?: string; numIps?: number; fields?: { [key: string]: any }; @@ -77,7 +77,7 @@ export const makeCheck = async ({ }; export const makeChecks = async ( - es: KibanaClient, + es: Client, monitorId: string, numChecks: number = 1, numIps: number = 1, @@ -122,7 +122,7 @@ export const makeChecks = async ( }; export const makeChecksWithStatus = async ( - es: KibanaClient, + es: Client, monitorId: string, numChecks: number, numIps: number, diff --git a/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts b/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts index c50d078275cfe..29421345393a8 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts @@ -7,14 +7,14 @@ import uuid from 'uuid'; import { merge } from 'lodash'; -import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { makeTls, TlsProps } from './make_tls'; const DEFAULT_INDEX_NAME = 'heartbeat-8-generated-test'; const DATA_STREAM_INDEX_NAME = 'synthetics-http-default'; export const makePing = async ( - es: KibanaClient, + es: Client, monitorId: string, fields: { [key: string]: any }, mogrify: (doc: any) => any, diff --git a/x-pack/test/apm_api_integration/tests/alerts/rule_registry.ts b/x-pack/test/apm_api_integration/tests/alerts/rule_registry.ts index 7f107f127594d..06abeb02404c8 100644 --- a/x-pack/test/apm_api_integration/tests/alerts/rule_registry.ts +++ b/x-pack/test/apm_api_integration/tests/alerts/rule_registry.ts @@ -370,12 +370,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); - expect(afterViolatingDataResponse.body.hits.hits.length).to.be(1); + expect(afterViolatingDataResponse.hits.hits.length).to.be(1); - const alertEvent = afterViolatingDataResponse.body.hits.hits[0].fields as Record< - string, - any - >; + const alertEvent = afterViolatingDataResponse.hits.hits[0].fields as Record; const exclude = ['@timestamp', ALERT_START, ALERT_UUID, ALERT_RULE_UUID, VERSION]; @@ -482,9 +479,9 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); - expect(afterRecoveryResponse.body.hits.hits.length).to.be(1); + expect(afterRecoveryResponse.hits.hits.length).to.be(1); - const recoveredAlertEvent = afterRecoveryResponse.body.hits.hits[0].fields as Record< + const recoveredAlertEvent = afterRecoveryResponse.hits.hits[0].fields as Record< string, any >; diff --git a/x-pack/test/apm_api_integration/tests/metadata/event_metadata.ts b/x-pack/test/apm_api_integration/tests/metadata/event_metadata.ts index d979f0bad1ec6..61cea852258a6 100644 --- a/x-pack/test/apm_api_integration/tests/metadata/event_metadata.ts +++ b/x-pack/test/apm_api_integration/tests/metadata/event_metadata.ts @@ -32,7 +32,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { }, }); - return response.body.hits.hits[0]._source![processorEvent].id; + return response.hits.hits[0]._source![processorEvent].id; } registry.when('Event metadata', { config: 'basic', archives: ['apm_8.0.0'] }, () => { diff --git a/x-pack/test/apm_api_integration/tests/service_overview/dependencies/index.ts b/x-pack/test/apm_api_integration/tests/service_overview/dependencies/index.ts index 4bd9785b31427..02d2eabc0b645 100644 --- a/x-pack/test/apm_api_integration/tests/service_overview/dependencies/index.ts +++ b/x-pack/test/apm_api_integration/tests/service_overview/dependencies/index.ts @@ -75,7 +75,7 @@ export default function ApiTest({ getService }: FtrProviderContext) { after(async () => { const allIndices = Object.values(indices).join(','); - const indexExists = (await es.indices.exists({ index: allIndices })).body; + const indexExists = await es.indices.exists({ index: allIndices }); if (indexExists) { await es.indices.delete({ index: allIndices, diff --git a/x-pack/test/apm_api_integration/tests/services/annotations.ts b/x-pack/test/apm_api_integration/tests/services/annotations.ts index 32ade1036e629..25737ce8cce9a 100644 --- a/x-pack/test/apm_api_integration/tests/services/annotations.ts +++ b/x-pack/test/apm_api_integration/tests/services/annotations.ts @@ -70,7 +70,7 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { registry.when('Annotations with a trial license', { config: 'trial', archives: [] }, () => { describe('when creating an annotation', () => { afterEach(async () => { - const indexExists = (await es.indices.exists({ index: DEFAULT_INDEX_NAME })).body; + const indexExists = await es.indices.exists({ index: DEFAULT_INDEX_NAME }); if (indexExists) { await es.indices.delete({ index: DEFAULT_INDEX_NAME, @@ -259,11 +259,9 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { index: transactionIndexName, }); - const annotationIndexExists = ( - await es.indices.exists({ - index: DEFAULT_INDEX_NAME, - }) - ).body; + const annotationIndexExists = await es.indices.exists({ + index: DEFAULT_INDEX_NAME, + }); if (annotationIndexExists) { await es.indices.delete({ diff --git a/x-pack/test/apm_api_integration/tests/services/derived_annotations.ts b/x-pack/test/apm_api_integration/tests/services/derived_annotations.ts index f401d69b1b002..c9ee61557deb6 100644 --- a/x-pack/test/apm_api_integration/tests/services/derived_annotations.ts +++ b/x-pack/test/apm_api_integration/tests/services/derived_annotations.ts @@ -32,7 +32,7 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { let response: APIReturnType<'GET /api/apm/services/{serviceName}/annotation/search'>; before(async () => { - const { body: indexExists } = await es.indices.exists({ index: indexName }); + const indexExists = await es.indices.exists({ index: indexName }); if (indexExists) { await es.indices.delete({ index: indexName, diff --git a/x-pack/test/case_api_integration/common/lib/utils.ts b/x-pack/test/case_api_integration/common/lib/utils.ts index de9f13e768495..8f77c424cad63 100644 --- a/x-pack/test/case_api_integration/common/lib/utils.ts +++ b/x-pack/test/case_api_integration/common/lib/utils.ts @@ -9,7 +9,7 @@ import { omit } from 'lodash'; import expect from '@kbn/expect'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/transport'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import type SuperTest from 'supertest'; import { ObjectRemover as ActionsRemover } from '../../../alerting_api_integration/common/lib'; @@ -75,27 +75,30 @@ export const getSignalsWithES = async ({ indices, ids, }: { - es: KibanaClient; + es: Client; indices: string | string[]; ids: string | string[]; }): Promise>>> => { - const signals: TransportResult> = await es.search({ - index: indices, - body: { - size: 10000, - query: { - bool: { - filter: [ - { - ids: { - values: toArray(ids), + const signals: TransportResult, unknown> = await es.search( + { + index: indices, + body: { + size: 10000, + query: { + bool: { + filter: [ + { + ids: { + values: toArray(ids), + }, }, - }, - ], + ], + }, }, }, }, - }); + { meta: true } + ); return signals.body.hits.hits.reduce((acc, hit) => { let indexMap = acc.get(hit._index); @@ -465,7 +468,7 @@ export const removeServerGeneratedPropertiesFromComments = ( }); }; -export const deleteAllCaseItems = async (es: KibanaClient) => { +export const deleteAllCaseItems = async (es: Client) => { await Promise.all([ deleteCasesByESQuery(es), deleteSubCases(es), @@ -476,7 +479,7 @@ export const deleteAllCaseItems = async (es: KibanaClient) => { ]); }; -export const deleteCasesUserActions = async (es: KibanaClient): Promise => { +export const deleteCasesUserActions = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:cases-user-actions', @@ -487,7 +490,7 @@ export const deleteCasesUserActions = async (es: KibanaClient): Promise => }); }; -export const deleteCasesByESQuery = async (es: KibanaClient): Promise => { +export const deleteCasesByESQuery = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:cases', @@ -502,7 +505,7 @@ export const deleteCasesByESQuery = async (es: KibanaClient): Promise => { * Deletes all sub cases in the .kibana index. This uses ES to perform the delete and does * not go through the case API. */ -export const deleteSubCases = async (es: KibanaClient): Promise => { +export const deleteSubCases = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:cases-sub-case', @@ -513,7 +516,7 @@ export const deleteSubCases = async (es: KibanaClient): Promise => { }); }; -export const deleteComments = async (es: KibanaClient): Promise => { +export const deleteComments = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:cases-comments', @@ -524,7 +527,7 @@ export const deleteComments = async (es: KibanaClient): Promise => { }); }; -export const deleteConfiguration = async (es: KibanaClient): Promise => { +export const deleteConfiguration = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:cases-configure', @@ -535,7 +538,7 @@ export const deleteConfiguration = async (es: KibanaClient): Promise => { }); }; -export const deleteMappings = async (es: KibanaClient): Promise => { +export const deleteMappings = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:cases-connector-mappings', @@ -590,9 +593,12 @@ interface ConnectorMappingsSavedObject { /** * Returns connector mappings saved objects from Elasticsearch directly. */ -export const getConnectorMappingsFromES = async ({ es }: { es: KibanaClient }) => { - const mappings: TransportResult> = - await es.search({ +export const getConnectorMappingsFromES = async ({ es }: { es: Client }) => { + const mappings: TransportResult< + estypes.SearchResponse, + unknown + > = await es.search( + { index: '.kibana', body: { query: { @@ -603,7 +609,9 @@ export const getConnectorMappingsFromES = async ({ es }: { es: KibanaClient }) = }, }, }, - }); + }, + { meta: true } + ); return mappings; }; @@ -615,26 +623,35 @@ interface ConfigureSavedObject { /** * Returns configure saved objects from Elasticsearch directly. */ -export const getConfigureSavedObjectsFromES = async ({ es }: { es: KibanaClient }) => { - const configure: TransportResult> = await es.search({ - index: '.kibana', - body: { - query: { - term: { - type: { - value: 'cases-configure', +export const getConfigureSavedObjectsFromES = async ({ es }: { es: Client }) => { + const configure: TransportResult< + estypes.SearchResponse, + unknown + > = await es.search( + { + index: '.kibana', + body: { + query: { + term: { + type: { + value: 'cases-configure', + }, }, }, }, }, - }); + { meta: true } + ); return configure; }; -export const getCaseSavedObjectsFromES = async ({ es }: { es: KibanaClient }) => { - const configure: TransportResult> = - await es.search({ +export const getCaseSavedObjectsFromES = async ({ es }: { es: Client }) => { + const configure: TransportResult< + estypes.SearchResponse<{ cases: ESCaseAttributes }>, + unknown + > = await es.search( + { index: '.kibana', body: { query: { @@ -645,7 +662,9 @@ export const getCaseSavedObjectsFromES = async ({ es }: { es: KibanaClient }) => }, }, }, - }); + }, + { meta: true } + ); return configure; }; diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts index ac18cf9542fc2..d0d4cea91146d 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/cases/find_cases.ts @@ -6,8 +6,6 @@ */ import expect from '@kbn/expect'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { @@ -424,7 +422,7 @@ export default ({ getService }: FtrProviderContext): void => { * around 30 seconds which seemed too slow */ const getAllCasesSortedByCreatedAtAsc = async () => { - const cases: TransportResult> = await es.search({ + const cases = await es.search({ index: '.kibana', body: { size: 10000, @@ -434,7 +432,7 @@ export default ({ getService }: FtrProviderContext): void => { }, }, }); - return cases.body.hits.hits.map((hit) => hit._source); + return cases.hits.hits.map((hit) => hit._source); }; it('returns the correct total when perPage is less than the total', async () => { diff --git a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts index 33843f45b5260..91a6ebc098b8e 100644 --- a/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts +++ b/x-pack/test/case_api_integration/security_and_spaces/tests/common/sub_cases/find_sub_cases.ts @@ -6,8 +6,6 @@ */ import expect from '@kbn/expect'; -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/elasticsearch'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; import { findSubCasesResp, postCollectionReq } from '../../../../common/lib/mock'; @@ -314,19 +312,17 @@ export default ({ getService }: FtrProviderContext): void => { }; const getAllCasesSortedByCreatedAtAsc = async () => { - const cases: TransportResult> = await es.search( - { - index: '.kibana', - body: { - size: 10000, - sort: [{ 'cases-sub-case.created_at': { unmapped_type: 'date', order: 'asc' } }], - query: { - term: { type: 'cases-sub-case' }, - }, + const cases = await es.search({ + index: '.kibana', + body: { + size: 10000, + sort: [{ 'cases-sub-case.created_at': { unmapped_type: 'date', order: 'asc' } }], + query: { + term: { type: 'cases-sub-case' }, }, - } - ); - return cases.body.hits.hits.map((hit) => hit._source); + }, + }); + return cases.hits.hits.map((hit) => hit._source); }; it('returns the correct total when perPage is less than the total', async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts index 8d18b98e40c59..d0c610319ba88 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_signals_migrations.ts @@ -97,7 +97,7 @@ export default ({ getService }: FtrProviderContext): void => { const [{ migration_index: newIndex }] = createResponses; await waitForIndexToPopulate(es, newIndex); - const { body: migrationResults } = await es.search<{ signal: Signal }>({ index: newIndex }); + const migrationResults = await es.search<{ signal: Signal }>({ index: newIndex }); expect(migrationResults.hits.hits).length(1); const migratedSignal = migrationResults.hits.hits[0]._source?.signal; diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index b62212179c5dc..5a2eb9ae451dd 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -8,7 +8,7 @@ import { KbnClient } from '@kbn/test'; import type { TransportResult } from '@elastic/transport'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import type SuperTest from 'supertest'; import type { ListArray, @@ -428,24 +428,27 @@ export const deleteAllAlerts = async ( ); }; -export const downgradeImmutableRule = async (es: KibanaClient, ruleId: string): Promise => { +export const downgradeImmutableRule = async (es: Client, ruleId: string): Promise => { return countDownES(async () => { - return es.updateByQuery({ - index: '.kibana', - refresh: true, - wait_for_completion: true, - body: { - script: { - lang: 'painless', - source: 'ctx._source.alert.params.version--', - }, - query: { - term: { - 'alert.tags': `${INTERNAL_RULE_ID_KEY}:${ruleId}`, + return es.updateByQuery( + { + index: '.kibana', + refresh: true, + wait_for_completion: true, + body: { + script: { + lang: 'painless', + source: 'ctx._source.alert.params.version--', + }, + query: { + term: { + 'alert.tags': `${INTERNAL_RULE_ID_KEY}:${ruleId}`, + }, }, }, }, - }); + { meta: true } + ); }, 'downgradeImmutableRule'); }; @@ -453,7 +456,7 @@ export const downgradeImmutableRule = async (es: KibanaClient, ruleId: string): * Remove all timelines from the .kibana index * @param es The ElasticSearch handle */ -export const deleteAllTimelines = async (es: KibanaClient): Promise => { +export const deleteAllTimelines = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:siem-ui-timeline', @@ -468,15 +471,18 @@ export const deleteAllTimelines = async (es: KibanaClient): Promise => { * This will retry 20 times before giving up and hopefully still not interfere with other tests * @param es The ElasticSearch handle */ -export const deleteAllRulesStatuses = async (es: KibanaClient): Promise => { +export const deleteAllRulesStatuses = async (es: Client): Promise => { return countDownES(async () => { - return es.deleteByQuery({ - index: '.kibana', - q: 'type:siem-detection-engine-rule-status', - wait_for_completion: true, - refresh: true, - body: {}, - }); + return es.deleteByQuery( + { + index: '.kibana', + q: 'type:siem-detection-engine-rule-status', + wait_for_completion: true, + refresh: true, + body: {}, + }, + { meta: true } + ); }, 'deleteAllRulesStatuses'); }; @@ -821,7 +827,7 @@ export const countDownES = async ( * Useful for tests where we want to ensure that a rule does NOT create alerts, e.g. testing exceptions. * @param es The ElasticSearch handle */ -export const refreshIndex = async (es: KibanaClient, index?: string) => { +export const refreshIndex = async (es: Client, index?: string) => { await es.indices.refresh({ index, }); @@ -1324,10 +1330,10 @@ export const getIndexNameFromLoad = (loadResponse: Record): str * @param esClient elasticsearch {@link Client} * @param index name of the index to query */ -export const waitForIndexToPopulate = async (es: KibanaClient, index: string): Promise => { +export const waitForIndexToPopulate = async (es: Client, index: string): Promise => { await waitFor(async () => { - const response = await es.count<{ count: number }>({ index }); - return response.body.count > 0; + const response = await es.count({ index }); + return response.count > 0; }, `waitForIndexToPopulate: ${index}`); }; @@ -1398,7 +1404,7 @@ export const finalizeSignalsMigration = async ({ export const getOpenSignals = async ( supertest: SuperTest.SuperTest, - es: KibanaClient, + es: Client, rule: FullResponseSchema ) => { await waitForRuleSuccessOrStatus(supertest, rule.id); diff --git a/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts b/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts index 311228424afe3..79880e1f21cb0 100644 --- a/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts +++ b/x-pack/test/encrypted_saved_objects_api_integration/tests/encrypted_saved_objects_api.ts @@ -28,9 +28,7 @@ export default function ({ getService }: FtrProviderContext) { generateRawID: (id: string, type: string) => string ) { async function getRawSavedObjectAttributes({ id, type }: SavedObject) { - const { - body: { _source }, - } = await es.get>({ + const { _source } = await es.get>({ id: generateRawID(id, type), index: '.kibana', }); diff --git a/x-pack/test/examples/search_examples/search_session_example.ts b/x-pack/test/examples/search_examples/search_session_example.ts index 4834fbddea899..ab96a7767baff 100644 --- a/x-pack/test/examples/search_examples/search_session_example.ts +++ b/x-pack/test/examples/search_examples/search_session_example.ts @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const appId = 'searchExamples'; before(async function () { - const { body } = await es.info(); + const body = await es.info(); if (!body.version.number.includes('SNAPSHOT')) { log.debug('Skipping because this build does not have the required shard_delay agg'); this.skip(); diff --git a/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts b/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts index 05ada4cc6a388..14dd5871a0317 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/unenroll.ts @@ -30,21 +30,19 @@ export default function (providerContext: FtrProviderContext) { await esArchiver.unload('x-pack/test/functional/es_archives/fleet/empty_fleet_server'); await esArchiver.load('x-pack/test/functional/es_archives/fleet/agents'); await getService('supertest').post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send(); - const { body: accessAPIKeyBody } = await esClient.security.createApiKey({ + const accessAPIKeyBody = await esClient.security.createApiKey({ body: { name: `test access api key: ${uuid.v4()}`, }, }); accessAPIKeyId = accessAPIKeyBody.id; - const { body: outputAPIKeyBody } = await esClient.security.createApiKey({ + const outputAPIKeyBody = await esClient.security.createApiKey({ body: { name: `test output api key: ${uuid.v4()}`, }, }); outputAPIKeyId = outputAPIKeyBody.id; - const { - body: { _source: agentDoc }, - } = await esClient.get({ + const { _source: agentDoc } = await esClient.get({ index: '.fleet-agents', id: 'agent1', }); @@ -104,15 +102,11 @@ export default function (providerContext: FtrProviderContext) { }) .expect(200); - const { - body: { api_keys: accessAPIKeys }, - } = await esClient.security.getApiKey({ id: accessAPIKeyId }); + const { api_keys: accessAPIKeys } = await esClient.security.getApiKey({ id: accessAPIKeyId }); expect(accessAPIKeys).length(1); expect(accessAPIKeys[0].invalidated).eql(true); - const { - body: { api_keys: outputAPIKeys }, - } = await esClient.security.getApiKey({ id: outputAPIKeyId }); + const { api_keys: outputAPIKeys } = await esClient.security.getApiKey({ id: outputAPIKeyId }); expect(outputAPIKeys).length(1); expect(outputAPIKeys[0].invalidated).eql(true); }); diff --git a/x-pack/test/fleet_api_integration/apis/data_streams/list.ts b/x-pack/test/fleet_api_integration/apis/data_streams/list.ts index 7755acc2468b1..365eb716592d1 100644 --- a/x-pack/test/fleet_api_integration/apis/data_streams/list.ts +++ b/x-pack/test/fleet_api_integration/apis/data_streams/list.ts @@ -146,21 +146,24 @@ export default function (providerContext: FtrProviderContext) { // Wait until backing indices are created await retry.tryForTime(10000, async () => { - const { body } = await es.transport.request({ - method: 'GET', - path: `/${logsTemplateName}-default,${metricsTemplateName}-default/_search`, - body: { - size: 0, - aggs: { - index: { - terms: { - field: '_index', - size: 100000, + const { body } = await es.transport.request( + { + method: 'GET', + path: `/${logsTemplateName}-default,${metricsTemplateName}-default/_search`, + body: { + size: 0, + aggs: { + index: { + terms: { + field: '_index', + size: 100000, + }, }, }, }, }, - }); + { meta: true } + ); expect(body.aggregations.index.buckets.length).to.eql(4); }); diff --git a/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts b/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts index 429bc3b80a54f..d1d9ce70dcd25 100644 --- a/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts +++ b/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts @@ -73,9 +73,7 @@ export default function (providerContext: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .expect(200); - const { - body: { api_keys: apiKeys }, - } = await es.security.getApiKey({ id: esApiKeyId }); + const { api_keys: apiKeys } = await es.security.getApiKey({ id: esApiKeyId }); expect(apiKeys).length(1); expect(apiKeys[0].invalidated).eql(true); @@ -173,7 +171,7 @@ export default function (providerContext: FtrProviderContext) { }) .expect(200); - const { body: apiKeyRes } = await es.security.getApiKey({ + const apiKeyRes = await es.security.getApiKey({ id: apiResponse.item.api_key_id, }); @@ -197,17 +195,20 @@ export default function (providerContext: FtrProviderContext) { const { body: privileges } = await getEsClientForAPIKey( providerContext, apiResponse.item.api_key - ).security.hasPrivileges({ - body: { - cluster: ['all', 'monitor', 'manage_api_key'], - index: [ - { - names: ['log-*', 'metrics-*', 'events-*', '*'], - privileges: ['write', 'create_index'], - }, - ], + ).security.hasPrivileges( + { + body: { + cluster: ['all', 'monitor', 'manage_api_key'], + index: [ + { + names: ['log-*', 'metrics-*', 'events-*', '*'], + privileges: ['write', 'create_index'], + }, + ], + }, }, - }); + { meta: true } + ); expect(privileges.cluster).to.eql({ all: false, monitor: false, diff --git a/x-pack/test/fleet_api_integration/apis/epm/data_stream.ts b/x-pack/test/fleet_api_integration/apis/epm/data_stream.ts index e258d1c4a2d07..9cdc21943a312 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/data_stream.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/data_stream.ts @@ -43,32 +43,38 @@ export default function (providerContext: FtrProviderContext) { await installPackage(pkgKey); await Promise.all( namespaces.map(async (namespace) => { - const createLogsRequest = es.transport.request({ - method: 'POST', - path: `/${logsTemplateName}-${namespace}/_doc`, - body: { - '@timestamp': '2015-01-01', - logs_test_name: 'test', - data_stream: { - dataset: `${pkgName}.test_logs`, - namespace, - type: 'logs', + const createLogsRequest = es.transport.request( + { + method: 'POST', + path: `/${logsTemplateName}-${namespace}/_doc`, + body: { + '@timestamp': '2015-01-01', + logs_test_name: 'test', + data_stream: { + dataset: `${pkgName}.test_logs`, + namespace, + type: 'logs', + }, }, }, - }); - const createMetricsRequest = es.transport.request({ - method: 'POST', - path: `/${metricsTemplateName}-${namespace}/_doc`, - body: { - '@timestamp': '2015-01-01', - logs_test_name: 'test', - data_stream: { - dataset: `${pkgName}.test_metrics`, - namespace, - type: 'metrics', + { meta: true } + ); + const createMetricsRequest = es.transport.request( + { + method: 'POST', + path: `/${metricsTemplateName}-${namespace}/_doc`, + body: { + '@timestamp': '2015-01-01', + logs_test_name: 'test', + data_stream: { + dataset: `${pkgName}.test_metrics`, + namespace, + type: 'metrics', + }, }, }, - }); + { meta: true } + ); return Promise.all([createLogsRequest, createMetricsRequest]); }) ); @@ -77,14 +83,20 @@ export default function (providerContext: FtrProviderContext) { afterEach(async () => { await Promise.all( namespaces.map(async (namespace) => { - const deleteLogsRequest = es.transport.request({ - method: 'DELETE', - path: `/_data_stream/${logsTemplateName}-${namespace}`, - }); - const deleteMetricsRequest = es.transport.request({ - method: 'DELETE', - path: `/_data_stream/${metricsTemplateName}-${namespace}`, - }); + const deleteLogsRequest = es.transport.request( + { + method: 'DELETE', + path: `/_data_stream/${logsTemplateName}-${namespace}`, + }, + { meta: true } + ); + const deleteMetricsRequest = es.transport.request( + { + method: 'DELETE', + path: `/_data_stream/${metricsTemplateName}-${namespace}`, + }, + { meta: true } + ); return Promise.all([deleteLogsRequest, deleteMetricsRequest]); }) ); @@ -94,14 +106,20 @@ export default function (providerContext: FtrProviderContext) { it('should list the logs and metrics datastream', async function () { await asyncForEach(namespaces, async (namespace) => { - const resLogsDatastream = await es.transport.request({ - method: 'GET', - path: `/_data_stream/${logsTemplateName}-${namespace}`, - }); - const resMetricsDatastream = await es.transport.request({ - method: 'GET', - path: `/_data_stream/${metricsTemplateName}-${namespace}`, - }); + const resLogsDatastream = await es.transport.request( + { + method: 'GET', + path: `/_data_stream/${logsTemplateName}-${namespace}`, + }, + { meta: true } + ); + const resMetricsDatastream = await es.transport.request( + { + method: 'GET', + path: `/_data_stream/${metricsTemplateName}-${namespace}`, + }, + { meta: true } + ); expect(resLogsDatastream.body.data_streams.length).equal(1); expect(resLogsDatastream.body.data_streams[0].indices.length).equal(1); expect(resMetricsDatastream.body.data_streams.length).equal(1); @@ -112,14 +130,20 @@ export default function (providerContext: FtrProviderContext) { it('after update, it should have rolled over logs datastream because mappings are not compatible and not metrics', async function () { await installPackage(pkgUpdateKey); await asyncForEach(namespaces, async (namespace) => { - const resLogsDatastream = await es.transport.request({ - method: 'GET', - path: `/_data_stream/${logsTemplateName}-${namespace}`, - }); - const resMetricsDatastream = await es.transport.request({ - method: 'GET', - path: `/_data_stream/${metricsTemplateName}-${namespace}`, - }); + const resLogsDatastream = await es.transport.request( + { + method: 'GET', + path: `/_data_stream/${logsTemplateName}-${namespace}`, + }, + { meta: true } + ); + const resMetricsDatastream = await es.transport.request( + { + method: 'GET', + path: `/_data_stream/${metricsTemplateName}-${namespace}`, + }, + { meta: true } + ); expect(resLogsDatastream.body.data_streams[0].indices.length).equal(2); expect(resMetricsDatastream.body.data_streams[0].indices.length).equal(1); }); @@ -127,14 +151,20 @@ export default function (providerContext: FtrProviderContext) { it('should be able to upgrade a package after a rollover', async function () { await asyncForEach(namespaces, async (namespace) => { - await es.transport.request({ - method: 'POST', - path: `/${logsTemplateName}-${namespace}/_rollover`, - }); - const resLogsDatastream = await es.transport.request({ - method: 'GET', - path: `/_data_stream/${logsTemplateName}-${namespace}`, - }); + await es.transport.request( + { + method: 'POST', + path: `/${logsTemplateName}-${namespace}/_rollover`, + }, + { meta: true } + ); + const resLogsDatastream = await es.transport.request( + { + method: 'GET', + path: `/_data_stream/${logsTemplateName}-${namespace}`, + }, + { meta: true } + ); expect(resLogsDatastream.body.data_streams[0].indices.length).equal(2); }); await installPackage(pkgUpdateKey); diff --git a/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts b/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts index 8c6603a3e38b0..85ebf346aa202 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/final_pipeline.ts @@ -75,7 +75,7 @@ export default function (providerContext: FtrProviderContext) { index: TEST_INDEX, }); - for (const hit of res.body.hits.hits) { + for (const hit of res.hits.hits) { await es.delete({ id: hit._id, index: hit._index, @@ -100,16 +100,16 @@ export default function (providerContext: FtrProviderContext) { }); await supertest.post(`/api/fleet/setup`).set('kbn-xsrf', 'xxxx'); const pipelineRes = await es.ingest.getPipeline({ id: FINAL_PIPELINE_ID }); - expect(pipelineRes.body).to.have.property(FINAL_PIPELINE_ID); - expect(pipelineRes.body[FINAL_PIPELINE_ID].version).to.be(1); + expect(pipelineRes).to.have.property(FINAL_PIPELINE_ID); + expect(pipelineRes[FINAL_PIPELINE_ID].version).to.be(1); }); it('should correctly setup the final pipeline and apply to fleet managed index template', async () => { const pipelineRes = await es.ingest.getPipeline({ id: FINAL_PIPELINE_ID }); - expect(pipelineRes.body).to.have.property(FINAL_PIPELINE_ID); + expect(pipelineRes).to.have.property(FINAL_PIPELINE_ID); const res = await es.indices.getIndexTemplate({ name: 'logs-log.log' }); - expect(res.body.index_templates.length).to.be(FINAL_PIPELINE_VERSION); - expect(res.body.index_templates[0]?.index_template?.composed_of).to.contain( + expect(res.index_templates.length).to.be(FINAL_PIPELINE_VERSION); + expect(res.index_templates[0]?.index_template?.composed_of).to.contain( '.fleet_component_template-1' ); }); @@ -123,9 +123,9 @@ export default function (providerContext: FtrProviderContext) { }, }); - const { body: doc } = await es.get({ - id: res.body._id, - index: res.body._index, + const doc = await es.get({ + id: res._id, + index: res._index, }); // @ts-expect-error const ingestTimestamp = doc._source.event.ingested; @@ -146,9 +146,9 @@ export default function (providerContext: FtrProviderContext) { }, }); - const { body: doc } = await es.get({ - id: res.body._id, - index: res.body._index, + const doc = await es.get({ + id: res._id, + index: res._index, }); // @ts-expect-error const event = doc._source.event; @@ -197,7 +197,7 @@ export default function (providerContext: FtrProviderContext) { for (const scenario of scenarios) { it(`Should write the correct event.agent_id_status for ${scenario.name}`, async () => { // Create an API key - const { body: apiKeyRes } = await es.security.createApiKey({ + const apiKeyRes = await es.security.createApiKey({ body: { name: `test api key`, ...(scenario.apiKey || {}), @@ -213,7 +213,7 @@ export default function (providerContext: FtrProviderContext) { Buffer.from(`${apiKeyRes.id}:${apiKeyRes.api_key}`).toString('base64') ); - const { body: doc } = await es.get({ + const doc = await es.get({ id: res.body._id as string, index: res.body._index as string, }); diff --git a/x-pack/test/fleet_api_integration/apis/epm/ilm.ts b/x-pack/test/fleet_api_integration/apis/epm/ilm.ts index 28a8bb11e6e1e..26d93598dd35a 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/ilm.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/ilm.ts @@ -28,11 +28,14 @@ export default function ({ getService }: FtrProviderContext) { }, }; - const data = await es.transport.request({ - method: 'PUT', - path: '/_ilm/policy/' + policyName, - body: policy, - }); + const data = await es.transport.request( + { + method: 'PUT', + path: '/_ilm/policy/' + policyName, + body: policy, + }, + { meta: true } + ); expect(data.body.acknowledged).to.eql(true); expect(data.statusCode).to.eql(200); diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts index 856122ff2ce22..177fad37aa882 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts @@ -40,10 +40,13 @@ export default function (providerContext: FtrProviderContext) { const templateName = body.response[0].id; - const { body: indexTemplateResponse } = await es.transport.request({ - method: 'GET', - path: `/_index_template/${templateName}`, - }); + const { body: indexTemplateResponse } = await es.transport.request( + { + method: 'GET', + path: `/_index_template/${templateName}`, + }, + { meta: true } + ); // the index template composed_of has the correct component templates in the correct order const indexTemplate = indexTemplateResponse.index_templates[0].index_template; diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts index 348b4bef59b30..13b283807fa15 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts @@ -74,6 +74,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(resLogsTemplate.statusCode).equal(404); @@ -85,6 +86,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(resMetricsTemplate.statusCode).equal(404); @@ -97,6 +99,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(resMappings.statusCode).equal(404); @@ -108,6 +111,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(resSettings.statusCode).equal(404); @@ -119,6 +123,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(resUserSettings.statusCode).equal(404); @@ -131,6 +136,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(res.statusCode).equal(404); @@ -141,6 +147,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(resPipeline1.statusCode).equal(404); @@ -151,6 +158,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(resPipeline2.statusCode).equal(404); @@ -163,6 +171,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(res.statusCode).equal(404); @@ -176,6 +185,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(res.statusCode).equal(404); diff --git a/x-pack/test/fleet_api_integration/apis/epm/template.ts b/x-pack/test/fleet_api_integration/apis/epm/template.ts index 517d2c77d430d..6f29eb794e7d0 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/template.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/template.ts @@ -55,19 +55,25 @@ export default function ({ getService }: FtrProviderContext) { // This test is not an API integration test with Kibana // We want to test here if the template is valid and for this we need a running ES instance. // If the ES instance takes the template, we assume it is a valid template. - const { body: response1 } = await es.transport.request({ - method: 'PUT', - path: `/_index_template/${templateName}`, - body: template, - }); + const { body: response1 } = await es.transport.request( + { + method: 'PUT', + path: `/_index_template/${templateName}`, + body: template, + }, + { meta: true } + ); // Checks if template loading worked as expected expect(response1).to.eql({ acknowledged: true }); - const { body: response2 } = await es.transport.request({ - method: 'GET', - path: `/_index_template/${templateName}`, - }); + const { body: response2 } = await es.transport.request( + { + method: 'GET', + path: `/_index_template/${templateName}`, + }, + { meta: true } + ); // Checks if the content of the template that was loaded is as expected // We already know based on the above test that the template was valid diff --git a/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts index 390be9bf6ea19..7bda96a0251c0 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts @@ -46,10 +46,12 @@ export default function (providerContext: FtrProviderContext) { await uninstallPackage(pkgUpdateKey); }); it('should have updated the ILM policy', async function () { - const resPolicy = await es.transport.request({ - method: 'GET', - path: `/_ilm/policy/all_assets`, - }); + const resPolicy = await es.ilm.getLifecycle( + { + policy: 'all_assets', + }, + { meta: true } + ); expect(resPolicy.body.all_assets.policy).eql({ phases: { hot: { @@ -65,10 +67,13 @@ export default function (providerContext: FtrProviderContext) { }); }); it('should have updated the index templates', async function () { - const resLogsTemplate = await es.transport.request({ - method: 'GET', - path: `/_index_template/${logsTemplateName}`, - }); + const resLogsTemplate = await es.transport.request( + { + method: 'GET', + path: `/_index_template/${logsTemplateName}`, + }, + { meta: true } + ); expect(resLogsTemplate.statusCode).equal(200); expect( resLogsTemplate.body.index_templates[0].index_template.template.mappings.properties @@ -97,10 +102,13 @@ export default function (providerContext: FtrProviderContext) { }, }, }); - const resMetricsTemplate = await es.transport.request({ - method: 'GET', - path: `/_index_template/${metricsTemplateName}`, - }); + const resMetricsTemplate = await es.transport.request( + { + method: 'GET', + path: `/_index_template/${metricsTemplateName}`, + }, + { meta: true } + ); expect(resMetricsTemplate.statusCode).equal(200); expect( resMetricsTemplate.body.index_templates[0].index_template.template.mappings.properties @@ -128,10 +136,13 @@ export default function (providerContext: FtrProviderContext) { }); }); it('should have installed the new index template', async function () { - const resLogsTemplate = await es.transport.request({ - method: 'GET', - path: `/_index_template/${logsTemplateName2}`, - }); + const resLogsTemplate = await es.transport.request( + { + method: 'GET', + path: `/_index_template/${logsTemplateName2}`, + }, + { meta: true } + ); expect(resLogsTemplate.statusCode).equal(200); expect( resLogsTemplate.body.index_templates[0].index_template.template.mappings.properties @@ -159,62 +170,72 @@ export default function (providerContext: FtrProviderContext) { }); }); it('should have installed the new versionized pipelines', async function () { - const res = await es.transport.request({ - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgUpdateVersion}`, - }); + const res = await es.ingest.getPipeline( + { + id: `${logsTemplateName}-${pkgUpdateVersion}`, + }, + { meta: true } + ); expect(res.statusCode).equal(200); - const resPipeline1 = await es.transport.request({ - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgUpdateVersion}-pipeline1`, - }); + const resPipeline1 = await es.ingest.getPipeline( + { + id: `${logsTemplateName}-${pkgUpdateVersion}-pipeline1`, + }, + { meta: true } + ); expect(resPipeline1.statusCode).equal(200); }); it('should have removed the old versionized pipelines', async function () { - const res = await es.transport.request( + const res = await es.ingest.getPipeline( { - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}`, + id: `${logsTemplateName}-${pkgVersion}`, }, { ignore: [404], + meta: true, } ); expect(res.statusCode).equal(404); - const resPipeline1 = await es.transport.request( + const resPipeline1 = await es.ingest.getPipeline( { - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}-pipeline1`, + id: `${logsTemplateName}-${pkgVersion}-pipeline1`, }, { ignore: [404], + meta: true, } ); expect(resPipeline1.statusCode).equal(404); - const resPipeline2 = await es.transport.request( + const resPipeline2 = await es.ingest.getPipeline( { - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}-pipeline2`, + id: `${logsTemplateName}-${pkgVersion}-pipeline2`, }, { ignore: [404], + meta: true, } ); expect(resPipeline2.statusCode).equal(404); }); it('should have updated the component templates', async function () { - const resMappings = await es.transport.request({ - method: 'GET', - path: `/_component_template/${logsTemplateName}@mappings`, - }); + const resMappings = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${logsTemplateName}@mappings`, + }, + { meta: true } + ); expect(resMappings.statusCode).equal(200); expect(resMappings.body.component_templates[0].component_template.template.mappings).eql({ dynamic: true, }); - const resSettings = await es.transport.request({ - method: 'GET', - path: `/_component_template/${logsTemplateName}@settings`, - }); + const resSettings = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${logsTemplateName}@settings`, + }, + { meta: true } + ); expect(resSettings.statusCode).equal(200); expect(resSettings.body.component_templates[0].component_template.template.settings).eql({ index: { @@ -233,10 +254,13 @@ export default function (providerContext: FtrProviderContext) { refresh_interval: '5s', }, }); - const resUserSettings = await es.transport.request({ - method: 'GET', - path: `/_component_template/${logsTemplateName}@custom`, - }); + const resUserSettings = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${logsTemplateName}@custom`, + }, + { meta: true } + ); expect(resUserSettings.statusCode).equal(200); expect(resUserSettings.body).eql({ component_templates: [ diff --git a/x-pack/test/fleet_api_integration/apis/service_tokens.ts b/x-pack/test/fleet_api_integration/apis/service_tokens.ts index 0399778b2e13c..4d5487841782c 100644 --- a/x-pack/test/fleet_api_integration/apis/service_tokens.ts +++ b/x-pack/test/fleet_api_integration/apis/service_tokens.ts @@ -33,10 +33,13 @@ export default function (providerContext: FtrProviderContext) { expect(apiResponse).have.property('name'); expect(apiResponse).have.property('value'); - const { body: tokensResponse } = await esClient.transport.request({ - method: 'GET', - path: `_security/service/elastic/fleet-server/credential`, - }); + const { body: tokensResponse } = await esClient.transport.request( + { + method: 'GET', + path: `_security/service/elastic/fleet-server/credential`, + }, + { meta: true } + ); expect(tokensResponse.tokens).have.property(apiResponse.name); }); diff --git a/x-pack/test/fleet_api_integration/apis/settings/update.ts b/x-pack/test/fleet_api_integration/apis/settings/update.ts index 1db0fc7e39441..566eeb156d243 100644 --- a/x-pack/test/fleet_api_integration/apis/settings/update.ts +++ b/x-pack/test/fleet_api_integration/apis/settings/update.ts @@ -130,7 +130,7 @@ export default function (providerContext: FtrProviderContext) { }, }); - expect(res.body.hits.hits.length).equal(beforeRes.body.hits.hits.length + 1); + expect(res.hits.hits.length).equal(beforeRes.hits.hits.length + 1); }); }); } diff --git a/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts b/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts index c51e2968baee0..3a151e3681339 100644 --- a/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts +++ b/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts @@ -21,7 +21,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await pageObjects.common.navigateToApp('indexLifecycleManagement'); }); after(async () => { - // @ts-expect-error @elastic/elasticsearch DeleteSnapshotLifecycleRequest.policy_id is required await esClient.ilm.deleteLifecycle({ policy: policyName }); }); diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index 1d6585d30d8b5..148e1e525a96a 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -39,7 +39,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { return { async hasJobResults(jobId: string): Promise { - const { body } = await es.search({ + const body = await es.search({ index: '.ml-anomalies-*', body: { size: 1, @@ -79,7 +79,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { }, async hasDetectorResults(jobId: string, detectorIndex: number): Promise { - const { body } = await es.search({ + const body = await es.search({ index: '.ml-anomalies-*', body: { size: 1, @@ -128,12 +128,12 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async createIndices(indices: string) { log.debug(`Creating indices: '${indices}'...`); - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === true) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === true) { log.debug(`Indices '${indices}' already exist. Nothing to create.`); return; } - const { body } = await es.indices.create({ index: indices }); + const body = await es.indices.create({ index: indices }); expect(body) .to.have.property('acknowledged') .eql(true, 'Response for create request indices should be acknowledged.'); @@ -144,12 +144,12 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async deleteIndices(indices: string) { log.debug(`Deleting indices: '${indices}'...`); - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === false) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === false) { log.debug(`Indices '${indices}' don't exist. Nothing to delete.`); return; } - const { body } = await es.indices.delete({ + const body = await es.indices.delete({ index: indices, }); expect(body) @@ -315,7 +315,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async assertIndicesExist(indices: string) { await retry.tryForTime(30 * 1000, async () => { - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === true) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === true) { return true; } else { throw new Error(`indices '${indices}' should exist`); @@ -325,7 +325,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async assertIndicesNotToExist(indices: string) { await retry.tryForTime(30 * 1000, async () => { - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === false) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === false) { return true; } else { throw new Error(`indices '${indices}' should not exist`); @@ -335,7 +335,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async assertIndicesNotEmpty(indices: string) { await retry.tryForTime(30 * 1000, async () => { - const { body } = await es.search({ + const body = await es.search({ index: indices, body: { size: 1, @@ -842,7 +842,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async getAnnotations(jobId: string) { log.debug(`Fetching annotations for job '${jobId}'...`); - const { body } = await es.search({ + const body = await es.search({ index: ML_ANNOTATIONS_INDEX_ALIAS_READ, body: { query: { @@ -861,7 +861,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { async getAnnotationById(annotationId: string): Promise { log.debug(`Fetching annotation '${annotationId}'...`); - const { body } = await es.search({ + const body = await es.search({ index: ML_ANNOTATIONS_INDEX_ALIAS_READ, body: { size: 1, @@ -890,7 +890,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { body: annotationRequestBody, refresh: 'wait_for', } as const; - const { body } = await es.index(params); + const body = await es.index(params); await this.waitForAnnotationToExist(body._id); log.debug(`> Annotation ${body._id} indexed.`); return body; diff --git a/x-pack/test/functional/services/ml/test_resources.ts b/x-pack/test/functional/services/ml/test_resources.ts index f1b2ef97e4e0d..feabc0f4ed899 100644 --- a/x-pack/test/functional/services/ml/test_resources.ts +++ b/x-pack/test/functional/services/ml/test_resources.ts @@ -225,6 +225,7 @@ export function MachineLearningTestResourcesProvider({ getService }: FtrProvider // Points the read/write aliases for annotations to the broken annotations index // so we can run tests against a state where annotation endpoints return errors. + // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid await es.indices.updateAliases({ body: { actions: [ @@ -252,6 +253,7 @@ export function MachineLearningTestResourcesProvider({ getService }: FtrProvider async restoreAnnotationsIndexState() { // restore the original working state of pointing read/write aliases // to the right annotations index. + // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid await es.indices.updateAliases({ body: { actions: [ diff --git a/x-pack/test/functional/services/transform/api.ts b/x-pack/test/functional/services/transform/api.ts index 484d794aac879..d10003279690c 100644 --- a/x-pack/test/functional/services/transform/api.ts +++ b/x-pack/test/functional/services/transform/api.ts @@ -32,12 +32,12 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) { return { async createIndices(indices: string) { log.debug(`Creating indices: '${indices}'...`); - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === true) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === true) { log.debug(`Indices '${indices}' already exist. Nothing to create.`); return; } - const createResponse = (await es.indices.create({ index: indices })).body; + const createResponse = await es.indices.create({ index: indices }); expect(createResponse) .to.have.property('acknowledged') .eql(true, 'Response for create request indices should be acknowledged.'); @@ -47,16 +47,14 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) { async deleteIndices(indices: string, skipWaitForIndicesNotToExist?: boolean) { log.debug(`Deleting indices: '${indices}'...`); - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === false) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === false) { log.debug(`Indices '${indices}' don't exist. Nothing to delete.`); return; } - const deleteResponse = ( - await es.indices.delete({ - index: indices, - }) - ).body; + const deleteResponse = await es.indices.delete({ + index: indices, + }); expect(deleteResponse) .to.have.property('acknowledged') .eql(true, 'Response for delete request should be acknowledged'); @@ -72,7 +70,7 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) { async waitForIndicesToExist(indices: string, errorMsg?: string) { await retry.tryForTime(30 * 1000, async () => { - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === true) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === true) { return true; } else { throw new Error(errorMsg || `indices '${indices}' should exist`); @@ -82,7 +80,7 @@ export function TransformAPIProvider({ getService }: FtrProviderContext) { async waitForIndicesNotToExist(indices: string, errorMsg?: string) { await retry.tryForTime(30 * 1000, async () => { - if ((await es.indices.exists({ index: indices, allow_no_indices: false })).body === false) { + if ((await es.indices.exists({ index: indices, allow_no_indices: false })) === false) { return true; } else { throw new Error(errorMsg || `indices '${indices}' should not exist`); diff --git a/x-pack/test/lists_api_integration/utils.ts b/x-pack/test/lists_api_integration/utils.ts index 4c0dd4420090f..55943cf33055d 100644 --- a/x-pack/test/lists_api_integration/utils.ts +++ b/x-pack/test/lists_api_integration/utils.ts @@ -6,7 +6,7 @@ */ import type SuperTest from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import type { Type, @@ -164,15 +164,17 @@ export const binaryToString = (res: any, callback: any): void => { * This will retry 20 times before giving up and hopefully still not interfere with other tests * @param es The ElasticSearch handle */ -export const deleteAllExceptions = async (es: KibanaClient): Promise => { +export const deleteAllExceptions = async (es: Client): Promise => { return countDownES(async () => { - return es.deleteByQuery({ - index: '.kibana', - q: 'type:exception-list or type:exception-list-agnostic', - wait_for_completion: true, - refresh: true, - body: {}, - }); + return es.deleteByQuery( + { + index: '.kibana', + q: 'type:exception-list or type:exception-list-agnostic', + wait_for_completion: true, + refresh: true, + }, + { meta: true } + ); }, 'deleteAllExceptions'); }; diff --git a/x-pack/test/observability_api_integration/trial/tests/annotations.ts b/x-pack/test/observability_api_integration/trial/tests/annotations.ts index 48b16b712bf3a..be4e98f9937d0 100644 --- a/x-pack/test/observability_api_integration/trial/tests/annotations.ts +++ b/x-pack/test/observability_api_integration/trial/tests/annotations.ts @@ -36,7 +36,7 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { describe('Observability annotations', () => { describe('when creating an annotation', () => { afterEach(async () => { - const indexExists = (await es.indices.exists({ index: DEFAULT_INDEX_NAME })).body; + const indexExists = await es.indices.exists({ index: DEFAULT_INDEX_NAME }); if (indexExists) { await es.indices.delete({ index: DEFAULT_INDEX_NAME, @@ -153,10 +153,10 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { }); // @ts-expect-error doesn't handle number - expect(search.body.hits.total.value).to.be(1); + expect(search.hits.total.value).to.be(1); - expect(search.body.hits.hits[0]._source).to.eql(response.body._source); - expect(search.body.hits.hits[0]._id).to.eql(response.body._id); + expect(search.hits.hits[0]._source).to.eql(response.body._source); + expect(search.hits.hits[0]._id).to.eql(response.body._id); }); it('returns the annotation', async () => { @@ -242,9 +242,9 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { }); // @ts-expect-error doesn't handler number - expect(initialSearch.body.hits.total.value).to.be(2); + expect(initialSearch.hits.total.value).to.be(2); - const [id1, id2] = initialSearch.body.hits.hits.map((hit) => hit._id); + const [id1, id2] = initialSearch.hits.hits.map((hit) => hit._id); expect( ( @@ -261,9 +261,9 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { }); // @ts-expect-error doesn't handler number - expect(searchAfterFirstDelete.body.hits.total.value).to.be(1); + expect(searchAfterFirstDelete.hits.total.value).to.be(1); - expect(searchAfterFirstDelete.body.hits.hits[0]._id).to.be(id2); + expect(searchAfterFirstDelete.hits.hits[0]._id).to.be(id2); expect( ( @@ -280,7 +280,7 @@ export default function annotationApiTests({ getService }: FtrProviderContext) { }); // @ts-expect-error doesn't handle number - expect(searchAfterSecondDelete.body.hits.total.value).to.be(0); + expect(searchAfterSecondDelete.hits.total.value).to.be(0); }); }); }); diff --git a/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts b/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts index 4c624cdbdda63..a8493e31cd82c 100644 --- a/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts +++ b/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts @@ -41,7 +41,7 @@ export default function ({ getService }: FtrProviderContext) { .find((val: string) => val === '--xpack.eventLog.indexEntries=true'); const result = await isIndexingEntries(); const exists = await es.indices.exists({ index: '.kibana-event-log-*' }); - expect(exists.body).to.be.eql(true); + expect(exists).to.be.eql(true); expect(configValue).to.be.eql( `--xpack.eventLog.indexEntries=${result.body.isIndexingEntries}` ); diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts index 4a651f9729e94..184cbe611ae55 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts @@ -29,10 +29,15 @@ export default function createGetTests({ getService }: FtrProviderContext) { it('8.0.0 migrates actions tasks with legacy id to saved object ids', async () => { // NOTE: We hae to use elastic search directly against the ".kibana" index because alerts do not expose the references which we want to test exists - const response = await es.get<{ task: TaskInstanceWithDeprecatedFields }>({ - index: '.kibana_task_manager', - id: 'task:be7e1250-3322-11eb-94c1-db6995e84f6a', - }); + const response = await es.get<{ task: TaskInstanceWithDeprecatedFields }>( + { + index: '.kibana_task_manager', + id: 'task:be7e1250-3322-11eb-94c1-db6995e84f6a', + }, + { + meta: true, + } + ); expect(response.statusCode).to.eql(200); expect(response.body._source?.task.params).to.eql( `{"spaceId":"user1","alertId":"${SavedObjectsUtils.getConvertedObjectId( @@ -45,17 +50,21 @@ export default function createGetTests({ getService }: FtrProviderContext) { it('8.0.0 migrates actions tasks from legacy id to saved object ids', async () => { const searchResult: TransportResult< - estypes.SearchResponse<{ task: TaskInstanceWithDeprecatedFields }> - > = await es.search({ - index: '.kibana_task_manager', - body: { - query: { - term: { - _id: 'task:be7e1250-3322-11eb-94c1-db6995e8389f', + estypes.SearchResponse<{ task: TaskInstanceWithDeprecatedFields }>, + unknown + > = await es.search( + { + index: '.kibana_task_manager', + body: { + query: { + term: { + _id: 'task:be7e1250-3322-11eb-94c1-db6995e8389f', + }, }, }, }, - }); + { meta: true } + ); expect(searchResult.statusCode).to.equal(200); expect((searchResult.body.hits.total as estypes.SearchTotalHits).value).to.equal(1); const hit = searchResult.body.hits.hits[0]; diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts index 3052320440ce7..cc7b3ceb542d6 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts @@ -64,7 +64,7 @@ export default function ({ getService }: FtrProviderContext) { beforeEach(async () => { const exists = await es.indices.exists({ index: testHistoryIndex }); - if (exists.body) { + if (exists) { await es.deleteByQuery({ index: testHistoryIndex, refresh: true, @@ -151,7 +151,7 @@ export default function ({ getService }: FtrProviderContext) { }, }) .then((result) => - (result.body as unknown as SearchResults).hits.hits.filter((task) => + (result as unknown as SearchResults).hits.hits.filter((task) => taskId ? task._source?.taskId === taskId : true ) ); diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts b/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts index fd49e2b237217..d8bad4a013fea 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts @@ -100,15 +100,14 @@ export default function ({ getService }: FtrProviderContext) { // customize the lifecycle policy await es.ilm.putLifecycle({ policy: ILM_POLICY_NAME, + // @ts-expect-error @elastic/elasticsearch IlmAction is not valid body: customLifecycle, }); await reportingAPI.migrateReportingIndices(); const { - body: { - [ILM_POLICY_NAME]: { policy }, - }, + [ILM_POLICY_NAME]: { policy }, } = await es.ilm.getLifecycle({ policy: ILM_POLICY_NAME }); expect(policy).to.eql(customLifecycle.policy); diff --git a/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts b/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts index e1c3d54320c03..e0fed03efb94d 100644 --- a/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts +++ b/x-pack/test/saved_object_api_integration/common/lib/create_users_and_roles.ts @@ -6,10 +6,10 @@ */ import type { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { AUTHENTICATION } from './authentication'; -export const createUsersAndRoles = async (es: KibanaClient, supertest: SuperTest) => { +export const createUsersAndRoles = async (es: Client, supertest: SuperTest) => { await supertest .put('/api/security/role/kibana_legacy_user') .send({ diff --git a/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts b/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts index e5932a97c08ff..a4c69ec5a2ab1 100644 --- a/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts +++ b/x-pack/test/saved_object_api_integration/common/lib/saved_object_test_utils.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { SavedObjectsErrorHelpers } from '../../../../../src/core/server'; import { SPACES, ALL_SPACES_ID } from './spaces'; import { AUTHENTICATION } from './authentication'; @@ -182,11 +182,11 @@ export const expectResponses = { * Additional assertions that we use in `import` and `resolve_import_errors` to ensure that * newly-created (or overwritten) objects don't have unexpected properties */ - successCreated: async (es: KibanaClient, spaceId: string, type: string, id: string) => { + successCreated: async (es: Client, spaceId: string, type: string, id: string) => { const isNamespaceUndefined = spaceId === SPACES.DEFAULT.spaceId || isNamespaceAgnostic(type) || isMultiNamespace(type); const expectedSpacePrefix = isNamespaceUndefined ? '' : `${spaceId}:`; - const { body: savedObject } = await es.get>({ + const savedObject = await es.get>({ id: `${expectedSpacePrefix}${type}:${id}`, index: '.kibana', }); diff --git a/x-pack/test/saved_object_api_integration/common/suites/import.ts b/x-pack/test/saved_object_api_integration/common/suites/import.ts index 3c10226149bb6..28af483ddc5c3 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/import.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/import.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; @@ -72,11 +72,7 @@ const getConflictDest = (id: string) => ({ updatedAt: '2017-09-21T18:59:16.270Z', }); -export function importTestSuiteFactory( - es: KibanaClient, - esArchiver: any, - supertest: SuperTest -) { +export function importTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTest) { const expectSavedObjectForbidden = expectResponses.forbiddenTypes('bulk_create'); const expectResponseBody = ( diff --git a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts index 518813d83b974..6de4e6dfbdcfa 100644 --- a/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts +++ b/x-pack/test/saved_object_api_integration/common/suites/resolve_import_errors.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { SPACES } from '../lib/spaces'; import { expectResponses, getUrlPrefix, getTestTitle } from '../lib/saved_object_test_utils'; @@ -92,7 +92,7 @@ const createRequest = ( }); export function resolveImportErrorsTestSuiteFactory( - es: KibanaClient, + es: Client, esArchiver: any, supertest: SuperTest ) { diff --git a/x-pack/test/saved_objects_field_count/runner.ts b/x-pack/test/saved_objects_field_count/runner.ts index e590a0667296f..22c6fd5d4612f 100644 --- a/x-pack/test/saved_objects_field_count/runner.ts +++ b/x-pack/test/saved_objects_field_count/runner.ts @@ -37,9 +37,7 @@ export async function testRunner({ getService }: FtrProviderContext) { log.debug('Saved Objects field count metrics starting'); - const { - body: { fields }, - } = await es.fieldCaps({ + const { fields } = await es.fieldCaps({ index: '.kibana', fields: '*', }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts index 3428071684900..eca329bd47439 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/async_search.ts @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('dashboard with async search', () => { before(async function () { - const { body } = await es.info(); + const body = await es.info(); if (!body.version.number.includes('SNAPSHOT')) { log.debug('Skipping because this build does not have the required shard_delay agg'); this.skip(); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts index bab93ad0483d3..0fe3cb428880b 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts @@ -26,7 +26,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('save a search sessions', () => { before(async function () { - const { body } = await es.info(); + const body = await es.info(); if (!body.version.number.includes('SNAPSHOT')) { log.debug('Skipping because this build does not have the required shard_delay agg'); this.skip(); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts index e12bd377288ba..86b7f41abf4eb 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/search_sessions_tour.ts @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('search sessions tour', () => { before(async function () { - const { body } = await es.info(); + const body = await es.info(); if (!body.version.number.includes('SNAPSHOT')) { log.debug('Skipping because this build does not have the required shard_delay agg'); this.skip(); diff --git a/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts b/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts index 5b21d63c8d888..ed1a1f3c16fcc 100644 --- a/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts +++ b/x-pack/test/security_api_integration/tests/kerberos/kerberos_login.ts @@ -399,7 +399,7 @@ export default function ({ getService }: FtrProviderContext) { body: { query: { match: { doc_type: 'token' } } }, refresh: true, }); - expect(esResponse.body).to.have.property('deleted').greaterThan(0); + expect(esResponse).to.have.property('deleted').greaterThan(0); }); it('AJAX call should initiate SPNEGO and clear existing cookie', async function () { diff --git a/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts b/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts index 330133049f549..a7a8702894482 100644 --- a/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts +++ b/x-pack/test/security_api_integration/tests/oidc/authorization_code_flow/oidc_auth.ts @@ -581,7 +581,7 @@ export default function ({ getService }: FtrProviderContext) { body: { query: { match: { doc_type: 'token' } } }, refresh: true, }); - expect(esResponse.body).to.have.property('deleted').greaterThan(0); + expect(esResponse).to.have.property('deleted').greaterThan(0); const handshakeResponse = await supertest .get( diff --git a/x-pack/test/security_api_integration/tests/saml/saml_login.ts b/x-pack/test/security_api_integration/tests/saml/saml_login.ts index d78a7b1040455..97fdcb77f4d66 100644 --- a/x-pack/test/security_api_integration/tests/saml/saml_login.ts +++ b/x-pack/test/security_api_integration/tests/saml/saml_login.ts @@ -568,7 +568,7 @@ export default function ({ getService }: FtrProviderContext) { body: { query: { match: { doc_type: 'token' } } }, refresh: true, }); - expect(esResponse.body).to.have.property('deleted').greaterThan(0); + expect(esResponse).to.have.property('deleted').greaterThan(0); }); it('should redirect user to a page that would capture URL fragment', async () => { @@ -650,7 +650,7 @@ export default function ({ getService }: FtrProviderContext) { body: { query: { match: { doc_type: 'token' } } }, refresh: true, }); - expect(esResponse.body).to.have.property('deleted').greaterThan(0); + expect(esResponse).to.have.property('deleted').greaterThan(0); }, ], ]; diff --git a/x-pack/test/security_api_integration/tests/token/header.ts b/x-pack/test/security_api_integration/tests/token/header.ts index 63e24e94565a0..74707aee68931 100644 --- a/x-pack/test/security_api_integration/tests/token/header.ts +++ b/x-pack/test/security_api_integration/tests/token/header.ts @@ -12,9 +12,7 @@ export default function ({ getService }: FtrProviderContext) { const es = getService('es'); async function createToken() { - const { - body: { access_token: accessToken }, - } = await es.security.getToken({ + const { access_token: accessToken } = await es.security.getToken({ body: { grant_type: 'password', username: 'elastic', diff --git a/x-pack/test/security_api_integration/tests/token/session.ts b/x-pack/test/security_api_integration/tests/token/session.ts index b8319ec8f7af1..b668108b9ee8b 100644 --- a/x-pack/test/security_api_integration/tests/token/session.ts +++ b/x-pack/test/security_api_integration/tests/token/session.ts @@ -146,7 +146,7 @@ export default function ({ getService }: FtrProviderContext) { body: { query: { match: { doc_type: 'token' } } }, refresh: true, }); - expect(esResponse.body).to.have.property('deleted').greaterThan(0); + expect(esResponse).to.have.property('deleted').greaterThan(0); const response = await supertest .get('/abc/xyz/') diff --git a/x-pack/test/security_solution_endpoint/services/endpoint.ts b/x-pack/test/security_solution_endpoint/services/endpoint.ts index 2c78bb81a1d38..db18418fd23d6 100644 --- a/x-pack/test/security_solution_endpoint/services/endpoint.ts +++ b/x-pack/test/security_solution_endpoint/services/endpoint.ts @@ -177,7 +177,7 @@ export class EndpointTestResources extends FtrService { rest_total_hits_as_int: true, }); - return searchResponse.body.hits.total === size; + return searchResponse.hits.total === size; } catch (error) { // We ignore 404's (index might not exist) if (error instanceof errors.ResponseError && error.statusCode === 404) { diff --git a/x-pack/test/security_solution_endpoint_api_int/apis/package.ts b/x-pack/test/security_solution_endpoint_api_int/apis/package.ts index a8fd5a612b306..bc3b9b54e38a2 100644 --- a/x-pack/test/security_solution_endpoint_api_int/apis/package.ts +++ b/x-pack/test/security_solution_endpoint_api_int/apis/package.ts @@ -48,22 +48,25 @@ export default function ({ getService }: FtrProviderContext) { const generator = new EndpointDocGenerator('data'); const searchForID = async (id: string) => { - return es.search({ - index: eventsIndexPattern, - body: { - query: { - bool: { - filter: [ - { - ids: { - values: [id], + return es.search( + { + index: eventsIndexPattern, + body: { + query: { + bool: { + filter: [ + { + ids: { + values: [id], + }, }, - }, - ], + ], + }, }, }, }, - }); + { meta: true } + ); }; describe('Endpoint package', () => { diff --git a/x-pack/test/security_solution_endpoint_api_int/services/resolver.ts b/x-pack/test/security_solution_endpoint_api_int/services/resolver.ts index 156043bd3c918..586de1f1276ee 100644 --- a/x-pack/test/security_solution_endpoint_api_int/services/resolver.ts +++ b/x-pack/test/security_solution_endpoint_api_int/services/resolver.ts @@ -64,7 +64,7 @@ export function ResolverGeneratorProvider({ getService }: FtrProviderContext) { const bulkResp = await client.bulk({ body, refresh: true }); const eventsInfo = events.map((event: Event, i: number) => { - return { event, _id: bulkResp.body.items[i].create?._id }; + return { event, _id: bulkResp.items[i].create?._id }; }); // @ts-expect-error @elastic/elasticsearch expected BulkResponseItemBase._id: string diff --git a/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts b/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts index d28b83d59fa24..15ee9785aa690 100644 --- a/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts +++ b/x-pack/test/spaces_api_integration/common/lib/create_users_and_roles.ts @@ -6,10 +6,10 @@ */ import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { AUTHENTICATION } from './authentication'; -export const createUsersAndRoles = async (es: KibanaClient, supertest: SuperTest) => { +export const createUsersAndRoles = async (es: Client, supertest: SuperTest) => { await supertest .put('/api/security/role/kibana_legacy_user') .send({ diff --git a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts index 6252bad684e9e..0c91caa5d5d71 100644 --- a/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts +++ b/x-pack/test/spaces_api_integration/common/suites/copy_to_space.ts @@ -8,7 +8,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; import { EsArchiver } from '@kbn/es-archiver'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants'; import { CopyResponse } from '../../../../plugins/spaces/server/lib/copy_to_spaces'; import { getUrlPrefix } from '../lib/space_test_utils'; @@ -74,12 +74,12 @@ const getDestinationWithConflicts = (originSpaceId?: string) => !originSpaceId || originSpaceId === DEFAULT_SPACE_ID ? 'space_1' : DEFAULT_SPACE_ID; export function copyToSpaceTestSuiteFactory( - es: KibanaClient, + es: Client, esArchiver: EsArchiver, supertest: SuperTest ) { const collectSpaceContents = async () => { - const { body: response } = await es.search({ + const response = await es.search({ index: '.kibana', body: { size: 0, diff --git a/x-pack/test/spaces_api_integration/common/suites/delete.ts b/x-pack/test/spaces_api_integration/common/suites/delete.ts index b544732870849..4eab59ca603fc 100644 --- a/x-pack/test/spaces_api_integration/common/suites/delete.ts +++ b/x-pack/test/spaces_api_integration/common/suites/delete.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { getTestScenariosForSpace } from '../lib/space_test_utils'; import { MULTI_NAMESPACE_SAVED_OBJECT_TEST_CASES as CASES } from '../lib/saved_object_test_cases'; import { DescribeFn, TestDefinitionAuthentication } from '../lib/types'; @@ -29,11 +29,7 @@ interface DeleteTestDefinition { tests: DeleteTests; } -export function deleteTestSuiteFactory( - es: KibanaClient, - esArchiver: any, - supertest: SuperTest -) { +export function deleteTestSuiteFactory(es: Client, esArchiver: any, supertest: SuperTest) { const createExpectResult = (expectedResult: any) => (resp: { [key: string]: any }) => { expect(resp.body).to.eql(expectedResult); }; @@ -43,7 +39,7 @@ export function deleteTestSuiteFactory( // Query ES to ensure that we deleted everything we expected, and nothing we didn't // Grouping first by namespace, then by saved object type - const { body: response } = await es.search({ + const response = await es.search({ index: '.kibana', body: { size: 0, @@ -136,7 +132,7 @@ export function deleteTestSuiteFactory( // There were 15 multi-namespace objects. // Since Space 2 was deleted, any multi-namespace objects that existed in that space // are updated to remove it, and of those, any that don't exist in any space are deleted. - const { body: multiNamespaceResponse } = await es.search>({ + const multiNamespaceResponse = await es.search>({ index: '.kibana', size: 20, body: { query: { terms: { type: ['sharedtype'] } } }, diff --git a/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts b/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts index f4f37fcf6286b..3374bfe647d10 100644 --- a/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts +++ b/x-pack/test/spaces_api_integration/common/suites/disable_legacy_url_aliases.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { SuperTest } from 'supertest'; -import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { LegacyUrlAlias } from 'src/core/server/saved_objects/object_types'; import { SPACES } from '../lib/spaces'; import { getUrlPrefix } from '../../../saved_object_api_integration/common/lib/saved_object_test_utils'; @@ -44,7 +44,7 @@ const getTestTitle = ({ targetSpace, targetType, sourceId }: DisableLegacyUrlAli }; export function disableLegacyUrlAliasesTestSuiteFactory( - es: KibanaClient, + es: Client, esArchiver: any, supertest: SuperTest ) { @@ -63,7 +63,7 @@ export function disableLegacyUrlAliasesTestSuiteFactory( index: '.kibana', id: `${LEGACY_URL_ALIAS_TYPE}:${targetSpace}:${targetType}:${sourceId}`, }); - const doc = esResponse.body._source!; + const doc = esResponse._source!; expect(doc).not.to.be(undefined); expect(doc[LEGACY_URL_ALIAS_TYPE].disabled).to.be(statusCode === 204 ? true : undefined); }; From a7f0bf87ff33a62217a326e9683b73254edbffe8 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 7 Oct 2021 17:11:36 +0200 Subject: [PATCH 054/172] fix eslint errors --- .../server/search/session/get_search_status.ts | 8 +++++--- .../signals/search_after_bulk_create.test.ts | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts b/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts index 0cc7d4b3f2c76..99f7b52c17577 100644 --- a/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts +++ b/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts @@ -19,9 +19,11 @@ export async function getSearchStatus( // TODO: Handle strategies other than the default one try { // @ts-expect-error start_time_in_millis: EpochMillis is string | number - const apiResponse: TransportResult = await client.asyncSearch.status({ - id: asyncId, - }); + const apiResponse: TransportResult = await client.asyncSearch.status( + { + id: asyncId, + } + ); const response = apiResponse.body; if ((response.is_partial && !response.is_running) || response.completion_status >= 400) { return { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts index a405833f985f4..e793de0e143cc 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts @@ -31,7 +31,7 @@ import { getQueryRuleParams } from '../schemas/rule_schemas.mock'; import { bulkCreateFactory } from './bulk_create_factory'; import { wrapHitsFactory } from './wrap_hits_factory'; import { mockBuildRuleMessage } from './__mocks__/build_rule_message.mock'; -import { errors } from '@elastic/elasticsearch'; +import { errors as esErrors } from '@elastic/elasticsearch'; import { BuildReasonMessage } from './reason_formatters'; const buildRuleMessage = mockBuildRuleMessage; @@ -754,7 +754,7 @@ describe('searchAfterAndBulkCreate', () => { ); mockService.scopedClusterClient.asCurrentUser.bulk.mockReturnValue( elasticsearchClientMock.createErrorTransportRequestPromise( - new errors.ResponseError( + new esErrors.ResponseError( elasticsearchClientMock.createApiResponse({ statusCode: 400, body: { error: { type: 'bulk_error_type' } }, From e37fff4dbd8dfd47669c8a3fd31138da7909237f Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 13 Oct 2021 16:32:21 +0200 Subject: [PATCH 055/172] fix new errors --- .../elastic-apm-generator/src/scripts/es.ts | 2 +- .../src/build_exception_filter/index.ts | 6 +- .../components/expression_chart.test.tsx | 1 - .../routes/log_sources/configuration.ts | 2 - .../server/routes/metrics_sources/index.ts | 2 - .../series_editor/use_filter_values.ts | 4 +- .../data_loaders/index_endpoint_actions.ts | 6 +- .../rule_registry_log_client.ts | 270 ------------------ .../snapshot_restore/server/routes/api/app.ts | 1 + .../transform_health_service.ts | 5 +- .../monitor_list/use_monitor_histogram.ts | 2 +- .../apm_api_integration/common/trace_data.ts | 2 +- .../security_and_spaces/tests/migrations.ts | 13 +- .../tests/http_bearer/header.ts | 4 +- 14 files changed, 24 insertions(+), 296 deletions(-) delete mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts diff --git a/packages/elastic-apm-generator/src/scripts/es.ts b/packages/elastic-apm-generator/src/scripts/es.ts index d023ef7172892..b399d73863a25 100644 --- a/packages/elastic-apm-generator/src/scripts/es.ts +++ b/packages/elastic-apm-generator/src/scripts/es.ts @@ -92,7 +92,7 @@ yargs(process.argv.slice(2)) ) .then((results) => { const errors = results - .flatMap((result) => result.body.items) + .flatMap((result) => result.items) .filter((item) => !!item.index?.error) .map((item) => item.index?.error); diff --git a/packages/kbn-securitysolution-list-utils/src/build_exception_filter/index.ts b/packages/kbn-securitysolution-list-utils/src/build_exception_filter/index.ts index 2aa4cf64073ab..dc00314ece266 100644 --- a/packages/kbn-securitysolution-list-utils/src/build_exception_filter/index.ts +++ b/packages/kbn-securitysolution-list-utils/src/build_exception_filter/index.ts @@ -23,7 +23,7 @@ import { } from '@kbn/securitysolution-io-ts-list-types'; import { Filter } from '@kbn/es-query'; -import { QueryDslBoolQuery, QueryDslNestedQuery } from '@elastic/elasticsearch/api/types'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { hasLargeValueList } from '../has_large_value_list'; type NonListEntry = EntryMatch | EntryMatchAny | EntryNested | EntryExists; @@ -40,11 +40,11 @@ export type ExceptionItemSansLargeValueLists = | CreateExceptionListItemNonLargeList; export interface BooleanFilter { - bool: QueryDslBoolQuery; + bool: estypes.QueryDslBoolQuery; } export interface NestedFilter { - nested: QueryDslNestedQuery; + nested: estypes.QueryDslNestedQuery; } export const chunkExceptions = ( diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx index fd723c9b161a5..5aafd9b613d99 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx @@ -54,7 +54,6 @@ describe('ExpressionChart', () => { metricAlias: 'metricbeat-*', inventoryDefaultView: 'host', metricsExplorerDefaultView: 'host', - // @ts-expect-error message is missing fields: { timestamp: '@timestamp', container: 'container.id', diff --git a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts index d15da50954990..f0d7b18d91a5d 100644 --- a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts +++ b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts @@ -85,13 +85,11 @@ export const initLogSourceConfigurationRoutes = ({ framework, sources }: InfraBa ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties )); diff --git a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts index e794a0e5a7b45..0123e4678697c 100644 --- a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts +++ b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts @@ -88,13 +88,11 @@ export const initMetricsSourceConfigurationRoutes = (libs: InfraBackendLibs) => ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error fields.container is not compatible patchedSourceConfigurationProperties )); diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/use_filter_values.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/use_filter_values.ts index 90cdbd61ef923..43bf417382b9f 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/use_filter_values.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/use_filter_values.ts @@ -5,7 +5,7 @@ * 2.0. */ import { ExistsFilter, isExistsFilter } from '@kbn/es-query'; -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { useValuesList } from '../../../../hooks/use_values_list'; import { FilterProps } from './columns/filter_expanded'; import { useAppIndexPatternContext } from '../hooks/use_app_index_pattern'; @@ -22,7 +22,7 @@ export function useFilterValues({ field, series, baseFilters }: FilterProps, que queryFilters.push(qFilter.query); } if (isExistsFilter(qFilter)) { - queryFilters.push({ exists: qFilter.query.exists } as QueryDslQueryContainer); + queryFilters.push({ exists: qFilter.query.exists } as estypes.QueryDslQueryContainer); } }); diff --git a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts index e2a577f593af1..3c8d23e375159 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_loaders/index_endpoint_actions.ts @@ -6,7 +6,7 @@ */ import { Client } from '@elastic/elasticsearch'; -import { DeleteByQueryResponse } from '@elastic/elasticsearch/api/types'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { HostMetadata, LogsEndpointAction, LogsEndpointActionResponse } from '../types'; import { EndpointActionGenerator } from '../data_generators/endpoint_action_generator'; import { wrapErrorAndRejectPromise } from './utils'; @@ -144,8 +144,8 @@ export const indexEndpointActionsForHost = async ( }; export interface DeleteIndexedEndpointActionsResponse { - endpointActionRequests: DeleteByQueryResponse | undefined; - endpointActionResponses: DeleteByQueryResponse | undefined; + endpointActionRequests: estypes.DeleteByQueryResponse | undefined; + endpointActionResponses: estypes.DeleteByQueryResponse | undefined; } export const deleteIndexedEndpointActions = async ( diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts deleted file mode 100644 index d3e39cf696e22..0000000000000 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_execution_log/rule_registry_adapter/rule_registry_log_client/rule_registry_log_client.ts +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { - ALERT_RULE_CONSUMER, - ALERT_RULE_TYPE_ID, - EVENT_ACTION, - EVENT_KIND, - SPACE_IDS, - TIMESTAMP, - ALERT_RULE_UUID, -} from '@kbn/rule-data-utils'; -import moment from 'moment'; - -import { mappingFromFieldMap } from '../../../../../../../rule_registry/common/mapping_from_field_map'; -import { Dataset, IRuleDataClient } from '../../../../../../../rule_registry/server'; -import { SERVER_APP_ID } from '../../../../../../common/constants'; -import { RuleExecutionStatus } from '../../../../../../common/detection_engine/schemas/common/schemas'; -import { invariant } from '../../../../../../common/utils/invariant'; -import { IRuleStatusSOAttributes } from '../../../rules/types'; -import { makeFloatString } from '../../../signals/utils'; -import { - ExecutionMetric, - ExecutionMetricArgs, - IRuleDataPluginService, - LogStatusChangeArgs, -} from '../../types'; -import { EVENT_SEQUENCE, MESSAGE, RULE_STATUS, RULE_STATUS_SEVERITY } from './constants'; -import { parseRuleExecutionLog, RuleExecutionEvent } from './parse_rule_execution_log'; -import { ruleExecutionFieldMap } from './rule_execution_field_map'; -import { - getLastEntryAggregation, - getMetricAggregation, - getMetricField, - sortByTimeDesc, -} from './utils'; - -const statusSeverityDict: Record = { - [RuleExecutionStatus.succeeded]: 0, - [RuleExecutionStatus['going to run']]: 10, - [RuleExecutionStatus.warning]: 20, - [RuleExecutionStatus['partial failure']]: 20, - [RuleExecutionStatus.failed]: 30, -}; - -interface FindExecutionLogArgs { - ruleIds: string[]; - spaceId: string; - logsCount?: number; - statuses?: RuleExecutionStatus[]; -} - -interface IRuleRegistryLogClient { - find: (args: FindExecutionLogArgs) => Promise<{ - [ruleId: string]: IRuleStatusSOAttributes[] | undefined; - }>; - create: (event: RuleExecutionEvent) => Promise; - logStatusChange: (args: LogStatusChangeArgs) => Promise; - logExecutionMetric: (args: ExecutionMetricArgs) => Promise; -} - -/** - * @deprecated RuleRegistryLogClient is kept here only as a reference. It will be superseded with EventLog implementation - */ -export class RuleRegistryLogClient implements IRuleRegistryLogClient { - private sequence = 0; - private ruleDataClient: IRuleDataClient; - - constructor(ruleDataService: IRuleDataPluginService) { - this.ruleDataClient = ruleDataService.initializeIndex({ - feature: SERVER_APP_ID, - registrationContext: 'security', - dataset: Dataset.events, - componentTemplateRefs: [], - componentTemplates: [ - { - name: 'mappings', - mappings: mappingFromFieldMap(ruleExecutionFieldMap, 'strict'), - }, - ], - }); - } - - public async find({ ruleIds, spaceId, statuses, logsCount = 1 }: FindExecutionLogArgs) { - if (ruleIds.length === 0) { - return {}; - } - - const filter: estypes.QueryDslQueryContainer[] = [ - { terms: { [ALERT_RULE_UUID]: ruleIds } }, - { terms: { [SPACE_IDS]: [spaceId] } }, - ]; - - if (statuses) { - filter.push({ terms: { [RULE_STATUS]: statuses } }); - } - - const result = await this.ruleDataClient.getReader().search({ - size: 0, - body: { - query: { - bool: { - filter, - }, - }, - aggs: { - rules: { - terms: { - field: ALERT_RULE_UUID, - size: ruleIds.length, - }, - aggs: { - most_recent_logs: { - top_hits: { - sort: sortByTimeDesc, - size: logsCount, - }, - }, - last_failure: getLastEntryAggregation(RuleExecutionStatus.failed), - last_success: getLastEntryAggregation(RuleExecutionStatus.succeeded), - execution_gap: getMetricAggregation(ExecutionMetric.executionGap), - search_duration_max: getMetricAggregation(ExecutionMetric.searchDurationMax), - indexing_duration_max: getMetricAggregation(ExecutionMetric.indexingDurationMax), - indexing_lookback: getMetricAggregation(ExecutionMetric.indexingLookback), - }, - }, - }, - }, - }); - - if (result.hits.total.value === 0) { - return {}; - } - - invariant(result.aggregations, 'Search response should contain aggregations'); - - return Object.fromEntries( - result.aggregations.rules.buckets.map<[ruleId: string, logs: IRuleStatusSOAttributes[]]>( - (bucket) => [ - bucket.key as string, - bucket.most_recent_logs.hits.hits.map((event) => { - const logEntry = parseRuleExecutionLog(event._source); - invariant( - logEntry[ALERT_RULE_UUID] ?? '', - 'Malformed execution log entry: rule.id field not found' - ); - - const lastFailure = bucket.last_failure.event.hits.hits[0] - ? parseRuleExecutionLog(bucket.last_failure.event.hits.hits[0]._source) - : undefined; - - const lastSuccess = bucket.last_success.event.hits.hits[0] - ? parseRuleExecutionLog(bucket.last_success.event.hits.hits[0]._source) - : undefined; - - const lookBack = bucket.indexing_lookback.event.hits.hits[0] - ? parseRuleExecutionLog(bucket.indexing_lookback.event.hits.hits[0]._source) - : undefined; - - const executionGap = bucket.execution_gap.event.hits.hits[0] - ? parseRuleExecutionLog(bucket.execution_gap.event.hits.hits[0]._source)[ - getMetricField(ExecutionMetric.executionGap) - ] - : undefined; - - const searchDuration = bucket.search_duration_max.event.hits.hits[0] - ? parseRuleExecutionLog(bucket.search_duration_max.event.hits.hits[0]._source)[ - getMetricField(ExecutionMetric.searchDurationMax) - ] - : undefined; - - const indexingDuration = bucket.indexing_duration_max.event.hits.hits[0] - ? parseRuleExecutionLog(bucket.indexing_duration_max.event.hits.hits[0]._source)[ - getMetricField(ExecutionMetric.indexingDurationMax) - ] - : undefined; - - const alertId = logEntry[ALERT_RULE_UUID] ?? ''; - const statusDate = logEntry[TIMESTAMP]; - const lastFailureAt = lastFailure?.[TIMESTAMP]; - const lastFailureMessage = lastFailure?.[MESSAGE]; - const lastSuccessAt = lastSuccess?.[TIMESTAMP]; - const lastSuccessMessage = lastSuccess?.[MESSAGE]; - const status = (logEntry[RULE_STATUS] as RuleExecutionStatus) || null; - const lastLookBackDate = lookBack?.[getMetricField(ExecutionMetric.indexingLookback)]; - const gap = executionGap ? moment.duration(executionGap).humanize() : null; - const bulkCreateTimeDurations = indexingDuration - ? [makeFloatString(indexingDuration)] - : null; - const searchAfterTimeDurations = searchDuration - ? [makeFloatString(searchDuration)] - : null; - - return { - alertId, - statusDate, - lastFailureAt, - lastFailureMessage, - lastSuccessAt, - lastSuccessMessage, - status, - lastLookBackDate, - gap, - bulkCreateTimeDurations, - searchAfterTimeDurations, - }; - }), - ] - ) - ); - } - - public async logExecutionMetric({ - ruleId, - namespace, - metric, - value, - spaceId, - }: ExecutionMetricArgs) { - await this.create( - { - [SPACE_IDS]: [spaceId], - [EVENT_ACTION]: metric, - [EVENT_KIND]: 'metric', - [getMetricField(metric)]: value, - [ALERT_RULE_UUID]: ruleId ?? '', - [TIMESTAMP]: new Date().toISOString(), - [ALERT_RULE_CONSUMER]: SERVER_APP_ID, - [ALERT_RULE_TYPE_ID]: SERVER_APP_ID, - }, - namespace - ); - } - - public async logStatusChange({ - ruleId, - newStatus, - namespace, - message, - spaceId, - }: LogStatusChangeArgs) { - await this.create( - { - [SPACE_IDS]: [spaceId], - [EVENT_ACTION]: 'status-change', - [EVENT_KIND]: 'event', - [EVENT_SEQUENCE]: this.sequence++, - [MESSAGE]: message, - [ALERT_RULE_UUID]: ruleId ?? '', - [RULE_STATUS_SEVERITY]: statusSeverityDict[newStatus], - [RULE_STATUS]: newStatus, - [TIMESTAMP]: new Date().toISOString(), - [ALERT_RULE_CONSUMER]: SERVER_APP_ID, - [ALERT_RULE_TYPE_ID]: SERVER_APP_ID, - }, - namespace - ); - } - - public async create(event: RuleExecutionEvent, namespace?: string) { - await this.ruleDataClient.getWriter({ namespace }).bulk({ - body: [{ index: {} }, event], - }); - } -} diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts index ec2e66235d295..5e6c937088848 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts @@ -74,6 +74,7 @@ export function registerAppRoutes({ } const indexHasAllPrivileges = APP_RESTORE_INDEX_PRIVILEGES.every((privilege) => + // @ts-expect-error SecurityClusterPrivilege doesn’t list all the possible privileges. privileges.includes(privilege) ); diff --git a/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/transform_health_service.ts b/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/transform_health_service.ts index 88b5396c7b110..1b0bc30beeac1 100644 --- a/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/transform_health_service.ts +++ b/x-pack/plugins/transform/server/lib/alerting/transform_health_rule_type/transform_health_service.ts @@ -7,7 +7,7 @@ import { ElasticsearchClient } from 'kibana/server'; import { i18n } from '@kbn/i18n'; -import type { Transform as EsTransform } from '@elastic/elasticsearch/api/types'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TransformHealthRuleParams } from './schema'; import { ALL_TRANSFORMS_SELECTION, @@ -24,8 +24,7 @@ interface TestResult { context: TransformHealthAlertContext; } -// @ts-ignore FIXME update types in the elasticsearch client -type Transform = EsTransform & { id: string; description?: string; sync: object }; +type Transform = estypes.Transform & { id: string; description?: string; sync: object }; export function transformHealthServiceProvider(esClient: ElasticsearchClient) { const transformsDict = new Map(); diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/use_monitor_histogram.ts b/x-pack/plugins/uptime/public/components/overview/monitor_list/use_monitor_histogram.ts index e1ef3d9efee89..4fe3c2bb72f8b 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/use_monitor_histogram.ts +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/use_monitor_histogram.ts @@ -7,7 +7,7 @@ import { useContext } from 'react'; import { useSelector } from 'react-redux'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Histogram, HistogramPoint, diff --git a/x-pack/test/apm_api_integration/common/trace_data.ts b/x-pack/test/apm_api_integration/common/trace_data.ts index 9c96d3fa1e0b0..b84fce2bbcf23 100644 --- a/x-pack/test/apm_api_integration/common/trace_data.ts +++ b/x-pack/test/apm_api_integration/common/trace_data.ts @@ -39,7 +39,7 @@ export async function traceData(context: InheritedFtrProviderContext) { ) ).then((results) => { const errors = results - .flatMap((result) => result.body.items) + .flatMap((result) => result.items) .filter((item) => !!item.index?.error) .map((item) => item.index?.error); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts index d25fb5bfa5899..c592ae7bb778a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts @@ -30,10 +30,15 @@ export default ({ getService }: FtrProviderContext): void => { actions: [{ id: string; actionRef: string }]; }; references: [{}]; - }>({ - index: '.kibana', - id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3', - }); + }>( + { + index: '.kibana', + id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3', + }, + { + meta: true, + } + ); expect(response.statusCode).to.eql(200); // references exist and are expected values diff --git a/x-pack/test/security_api_integration/tests/http_bearer/header.ts b/x-pack/test/security_api_integration/tests/http_bearer/header.ts index f7ebef4f16d09..7de7d83e154e2 100644 --- a/x-pack/test/security_api_integration/tests/http_bearer/header.ts +++ b/x-pack/test/security_api_integration/tests/http_bearer/header.ts @@ -14,9 +14,7 @@ export default function ({ getService }: FtrProviderContext) { const es = getService('es'); async function createToken() { - const { - body: { access_token: accessToken, authentication }, - } = await es.security.getToken({ + const { access_token: accessToken, authentication } = await es.security.getToken({ body: { grant_type: 'password', ...adminTestUser, From 12bb7a7f1bfafe9af92b97f1f38572f94d7e1ec0 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 13 Oct 2021 18:29:13 +0200 Subject: [PATCH 056/172] use default HTTP Connection. Undici does not support agent config options keepAlive and maxSockets --- src/core/server/elasticsearch/client/configure_client.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index 81a92e6896843..966cf0b4ab0e4 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -10,6 +10,7 @@ import { Buffer } from 'buffer'; import { stringify } from 'querystring'; import { Client, errors } from '@elastic/elasticsearch'; import { Transport, events } from '@elastic/transport'; +import { HttpConnection } from '@elastic/transport'; import type { TransportRequestParams, TransportRequestOptions, @@ -55,7 +56,11 @@ export const configureClient = ( } } - const client = new Client({ ...clientOptions, Transport: KibanaTransport }); + const client = new Client({ + ...clientOptions, + Transport: KibanaTransport, + Connection: HttpConnection, + }); addLogging(client, logger.get('query', type)); // --------------------------------------------------------------------------------- // From ff799634d7f6301dddf3ab0b7d58e5428ded9d78 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 13 Oct 2021 18:29:48 +0200 Subject: [PATCH 057/172] create does not accept require_alias option --- src/core/server/saved_objects/service/lib/repository.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index 3af307626fbae..0b57c031a49c6 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -328,12 +328,11 @@ export class SavedObjectsRepository { refresh, body: raw._source, ...(overwrite && version ? decodeRequestVersion(version) : {}), - require_alias: true, }; const { body, statusCode, headers } = id && overwrite - ? await this.client.index(requestParams) + ? await this.client.index({ ...requestParams, require_alias: true }) : await this.client.create(requestParams); // throw if we can't verify a 404 response is from Elasticsearch From 67785b119fcd208f19e7fa6fce17e7951a0a5a19 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 15:25:19 +0200 Subject: [PATCH 058/172] update deps --- package.json | 3 +-- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index e07eaff4c5603..4b6dff35a1977 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "37.0.0", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.22", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.23", "@elastic/ems-client": "7.15.0", "@elastic/eui": "39.0.0", "@elastic/filesaver": "1.1.2", @@ -111,7 +111,6 @@ "@elastic/request-crypto": "1.1.4", "@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set", "@elastic/search-ui-app-search-connector": "^1.6.0", - "@elastic/transport": "^0.0.6", "@emotion/react": "^11.4.0", "@hapi/accept": "^5.0.2", "@hapi/boom": "^9.1.4", diff --git a/yarn.lock b/yarn.lock index 6517facea2dfa..da20bfb6d7e60 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.22": - version "8.0.0-canary.22" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.22.tgz#f25ffb3bc4946f4d6b8621d5d48764c2ca63b03e" - integrity sha512-lDaBPpooXkPw+A/1UZH9mJci6mcRg1CWuVndwK6I9VoF1Es3BV2aWOCjXWKRTdYzpojywXFUNJadCOeWGa+M6Q== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.23": + version "8.0.0-canary.23" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.23.tgz#25ae3e08e102dfd6f7cbf08238e8feac68d56f62" + integrity sha512-45CB7L7pGU2UvSck9YoGoiaXPnF9sUyXSO1dpwwWSUAXSW5v4zcAhvLLjxL/mAzQIvHtY3w+P2JuYwxJf3OqMw== dependencies: - "@elastic/transport" "^0.0.6" + "@elastic/transport" "^0.0.7" tslib "^2.3.0" "@elastic/ems-client@7.15.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.6": - version "0.0.6" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.6.tgz#78da508529dfe789b26f85d4cb1db6a47aee0078" - integrity sha512-MvXT0xYuKs9+hCI1TiymvrvvhX+inKlaPcP1rO61X2N2jbViDrF1LqKWqIxfJWOImF+BsQBhh6elyiYwdCZYmw== +"@elastic/transport@^0.0.7": + version "0.0.7" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.7.tgz#abc636b18c231dba457f188f62a4df432c543cdc" + integrity sha512-apSD9aY6jVBC5lLc3GWmgrcjXl2StAR/AQYW8bnZ0mGTqkkLGpx4Ojnd3yYDvD1JxMosbs6lpTA60dLF2vtSHQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From 5ebf8e66cac6f807b450f7f86c8ff24376d4c373 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 15:36:41 +0200 Subject: [PATCH 059/172] use transport types exported from ES client package --- packages/kbn-test/BUILD.bazel | 2 -- packages/kbn-test/src/es/client_to_kibana_client.ts | 6 +++--- .../server/elasticsearch/client/configure_client.test.ts | 6 +++--- src/core/server/elasticsearch/client/configure_client.ts | 6 ++---- src/core/server/elasticsearch/client/errors.test.ts | 2 +- src/core/server/elasticsearch/client/types.ts | 2 +- .../saved_objects/migrations/core/migration_es_client.ts | 3 +-- .../saved_objects/service/lib/repository_es_client.ts | 2 +- .../data/common/search/strategies/eql_search/types.ts | 2 +- src/plugins/data/server/autocomplete/terms_agg.test.ts | 2 +- src/plugins/data/server/autocomplete/terms_enum.test.ts | 2 +- .../search/strategies/eql_search/eql_search_strategy.ts | 7 ++----- .../server/search/strategies/eql_search/response_utils.ts | 2 +- .../search/strategies/es_search/es_search_strategy.test.ts | 2 +- .../interactive_setup/server/elasticsearch_service.ts | 2 +- .../server/cleanup_failed_executions/cleanup_tasks.test.ts | 2 +- .../server/cleanup_failed_executions/lib/bulk_delete.ts | 2 +- .../lib/extract_bulk_response_delete_failures.ts | 2 +- x-pack/plugins/apm/scripts/shared/get_es_client.ts | 2 +- x-pack/plugins/canvas/types/strategy.ts | 2 +- .../server/search/session/get_search_status.ts | 2 +- .../event_log/server/es/cluster_client_adapter.test.ts | 2 +- x-pack/plugins/event_log/server/es/context.test.ts | 2 +- .../fleet/server/services/artifacts/artifacts.test.ts | 2 +- .../services/epm/elasticsearch/ingest_pipeline/install.ts | 2 +- .../server/routes/api/policies/register_fetch_route.ts | 2 +- .../lib/adapters/framework/kibana_framework_adapter.ts | 2 +- .../plugins/infra/server/utils/get_all_composite_data.ts | 2 +- x-pack/plugins/ml/server/lib/ml_client/search.ts | 2 +- .../server/export_types/csv/generate_csv/hit_iterator.ts | 2 +- x-pack/plugins/reporting/server/routes/lib/jobs_query.ts | 2 +- .../plugins/rule_registry/server/rule_data_client/types.ts | 2 +- .../rule_registry/server/utils/persistence_types.ts | 2 +- .../lib/metadata/check_metadata_transforms_task.test.ts | 2 +- .../lib/metadata/check_metadata_transforms_task.ts | 2 +- .../server/endpoint/routes/metadata/handlers.ts | 2 +- .../endpoint/routes/resolver/tree/queries/descendants.ts | 2 +- .../server/lib/detection_engine/signals/executors/eql.ts | 2 +- .../signals/signal_rule_alert_type.test.ts | 2 +- .../server/lib/detection_engine/signals/utils.test.ts | 2 +- .../server/lib/detection_engine/signals/utils.ts | 2 +- .../server/lib/es_deprecations_status.test.ts | 2 +- .../server/lib/reindexing/reindex_actions.test.ts | 2 +- .../server/lib/reindexing/reindex_service.test.ts | 2 +- .../test/api_integration/apis/security_solution/utils.ts | 2 +- x-pack/test/case_api_integration/common/lib/utils.ts | 2 +- x-pack/test/detection_engine_api_integration/utils.ts | 2 +- .../test_suites/task_manager/migrations.ts | 2 +- 48 files changed, 53 insertions(+), 61 deletions(-) diff --git a/packages/kbn-test/BUILD.bazel b/packages/kbn-test/BUILD.bazel index bb86299d3d306..efaf01f7137d9 100644 --- a/packages/kbn-test/BUILD.bazel +++ b/packages/kbn-test/BUILD.bazel @@ -41,7 +41,6 @@ RUNTIME_DEPS = [ "//packages/kbn-std", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", - "@npm//@elastic/transport", "@npm//axios", "@npm//@babel/traverse", "@npm//chance", @@ -77,7 +76,6 @@ TYPES_DEPS = [ "//packages/kbn-i18n", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", - "@npm//@elastic/transport", "@npm//del", "@npm//form-data", "@npm//jest", diff --git a/packages/kbn-test/src/es/client_to_kibana_client.ts b/packages/kbn-test/src/es/client_to_kibana_client.ts index 6c7301d5a0273..57c492f09c20f 100644 --- a/packages/kbn-test/src/es/client_to_kibana_client.ts +++ b/packages/kbn-test/src/es/client_to_kibana_client.ts @@ -5,14 +5,14 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { Client } from '@elastic/elasticsearch'; import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; -import { Transport } from '@elastic/transport'; import type { + Client, TransportRequestParams, TransportRequestOptions, TransportResult, -} from '@elastic/transport'; +} from '@elastic/elasticsearch'; +import { Transport } from '@elastic/elasticsearch'; class KibanaTransport extends Transport { request(params: TransportRequestParams, options?: TransportRequestOptions) { diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index 1d258012d6450..4a02f2feb6268 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -10,13 +10,13 @@ import { Buffer } from 'buffer'; import { Readable } from 'stream'; import { errors } from '@elastic/elasticsearch'; -import type { Client } from '@elastic/elasticsearch'; import type { + Client, TransportRequestOptions, TransportRequestParams, DiagnosticResult, -} from '@elastic/transport'; -import type { RequestBody } from '@elastic/transport/lib/types'; +} from '@elastic/elasticsearch'; +import type { RequestBody } from '@elastic/elasticsearch/lib/types'; import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks'; import { loggingSystemMock } from '../../logging/logging_system.mock'; diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index 966cf0b4ab0e4..ec704bc07799b 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -8,15 +8,13 @@ import { Buffer } from 'buffer'; import { stringify } from 'querystring'; -import { Client, errors } from '@elastic/elasticsearch'; -import { Transport, events } from '@elastic/transport'; -import { HttpConnection } from '@elastic/transport'; +import { Client, errors, Transport, events, HttpConnection } from '@elastic/elasticsearch'; import type { TransportRequestParams, TransportRequestOptions, TransportResult, DiagnosticResult, -} from '@elastic/transport'; +} from '@elastic/elasticsearch'; import type { RequestBody } from '@elastic/transport/lib/types'; import { Logger } from '../../logging'; import { parseClientOptions, ElasticsearchClientConfig } from './client_config'; diff --git a/src/core/server/elasticsearch/client/errors.test.ts b/src/core/server/elasticsearch/client/errors.test.ts index 36d026af6081e..59c4296d2bbb2 100644 --- a/src/core/server/elasticsearch/client/errors.test.ts +++ b/src/core/server/elasticsearch/client/errors.test.ts @@ -7,7 +7,7 @@ */ import { errors } from '@elastic/elasticsearch'; -import { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { isResponseError, isUnauthorizedError } from './errors'; const createApiResponseError = ({ diff --git a/src/core/server/elasticsearch/client/types.ts b/src/core/server/elasticsearch/client/types.ts index e2db3c9e26cbd..e70844df96a88 100644 --- a/src/core/server/elasticsearch/client/types.ts +++ b/src/core/server/elasticsearch/client/types.ts @@ -11,7 +11,7 @@ import type { TransportResult, TransportRequestOptions, TransportRequestParams, -} from '@elastic/transport'; +} from '@elastic/elasticsearch'; /** * Client used to query the elasticsearch cluster. diff --git a/src/core/server/saved_objects/migrations/core/migration_es_client.ts b/src/core/server/saved_objects/migrations/core/migration_es_client.ts index 947f648286221..243b724eb2a67 100644 --- a/src/core/server/saved_objects/migrations/core/migration_es_client.ts +++ b/src/core/server/saved_objects/migrations/core/migration_es_client.ts @@ -5,8 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { Client } from '@elastic/elasticsearch'; -import type { TransportRequestOptions } from '@elastic/transport'; +import type { Client, TransportRequestOptions } from '@elastic/elasticsearch'; import { get } from 'lodash'; import { set } from '@elastic/safer-lodash-set'; diff --git a/src/core/server/saved_objects/service/lib/repository_es_client.ts b/src/core/server/saved_objects/service/lib/repository_es_client.ts index 170fd2d058e58..4c1ae294cc7db 100644 --- a/src/core/server/saved_objects/service/lib/repository_es_client.ts +++ b/src/core/server/saved_objects/service/lib/repository_es_client.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { TransportRequestOptions } from '@elastic/transport'; +import type { TransportRequestOptions } from '@elastic/elasticsearch'; import { ElasticsearchClient } from '../../../elasticsearch/'; import { retryCallCluster } from '../../../elasticsearch/client/retry_call_cluster'; diff --git a/src/plugins/data/common/search/strategies/eql_search/types.ts b/src/plugins/data/common/search/strategies/eql_search/types.ts index eb87c242d5241..7f6ec4809b2c5 100644 --- a/src/plugins/data/common/search/strategies/eql_search/types.ts +++ b/src/plugins/data/common/search/strategies/eql_search/types.ts @@ -7,7 +7,7 @@ */ import type { EqlSearchRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult, TransportRequestOptions } from '@elastic/transport'; +import type { TransportResult, TransportRequestOptions } from '@elastic/elasticsearch'; import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../types'; diff --git a/src/plugins/data/server/autocomplete/terms_agg.test.ts b/src/plugins/data/server/autocomplete/terms_agg.test.ts index 025e7f5a015f0..eb24b71cae274 100644 --- a/src/plugins/data/server/autocomplete/terms_agg.test.ts +++ b/src/plugins/data/server/autocomplete/terms_agg.test.ts @@ -10,7 +10,7 @@ import { coreMock } from '../../../../core/server/mocks'; import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; import { ConfigSchema } from '../../config'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { termsAggSuggestions } from './terms_agg'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { duration } from 'moment'; diff --git a/src/plugins/data/server/autocomplete/terms_enum.test.ts b/src/plugins/data/server/autocomplete/terms_enum.test.ts index f9cad79919e02..c0750ead5cc0a 100644 --- a/src/plugins/data/server/autocomplete/terms_enum.test.ts +++ b/src/plugins/data/server/autocomplete/terms_enum.test.ts @@ -11,7 +11,7 @@ import { coreMock } from '../../../../core/server/mocks'; import { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; import { ConfigSchema } from '../../config'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { TermsEnumResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; let savedObjectsClientMock: jest.Mocked; diff --git a/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts b/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts index 89e36cab10286..3d9294765cc15 100644 --- a/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/eql_search/eql_search_strategy.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { tap } from 'rxjs/operators'; import type { IScopedClusterClient, Logger } from 'kibana/server'; import { @@ -53,10 +53,7 @@ export const eqlSearchStrategyProvider = ( ...request.params, }; const response = id - ? await client.get( - { ...params, id }, - { ...request.options, abortController: { signal: options.abortSignal } } - ) + ? await client.get({ ...params, id }, { ...request.options, signal: options.abortSignal }) : // @ts-expect-error optional key cannot be used since search doesn't expect undefined await client.search(params as EqlSearchStrategyRequest['params'], { ...request.options, diff --git a/src/plugins/data/server/search/strategies/eql_search/response_utils.ts b/src/plugins/data/server/search/strategies/eql_search/response_utils.ts index 342e8453c10db..f9bdf5bc7de30 100644 --- a/src/plugins/data/server/search/strategies/eql_search/response_utils.ts +++ b/src/plugins/data/server/search/strategies/eql_search/response_utils.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { EqlSearchResponse } from './types'; import { EqlSearchStrategyResponse } from '../../../../common'; diff --git a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts index 05b35c60c2070..c06a75f3148a8 100644 --- a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts +++ b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.test.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { elasticsearchServiceMock } from '../../../../../../core/server/mocks'; import { pluginInitializerContextConfigMock } from '../../../../../../core/server/mocks'; import { esSearchStrategyProvider } from './es_search_strategy'; diff --git a/src/plugins/interactive_setup/server/elasticsearch_service.ts b/src/plugins/interactive_setup/server/elasticsearch_service.ts index c76fe315f73d2..5e6eb4e007ee9 100644 --- a/src/plugins/interactive_setup/server/elasticsearch_service.ts +++ b/src/plugins/interactive_setup/server/elasticsearch_service.ts @@ -7,7 +7,7 @@ */ import { errors } from '@elastic/elasticsearch'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import type { Duration } from 'moment'; import type { Observable } from 'rxjs'; import { from, of, timer } from 'rxjs'; diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts index 452f1829c9c36..b80a8d092118a 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/cleanup_tasks.test.ts @@ -11,7 +11,7 @@ import { spacesMock } from '../../../spaces/server/mocks'; import { CleanupTasksOpts, cleanupTasks } from './cleanup_tasks'; import { TaskInstance } from '../../../task_manager/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; describe('cleanupTasks', () => { const logger = loggingSystemMock.create().get(); diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts index 67f0002a93600..5bbb48a3d520d 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/bulk_delete.ts @@ -7,7 +7,7 @@ import { ElasticsearchClient } from 'kibana/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; export async function bulkDelete( esClient: ElasticsearchClient, diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts index 5ba75eecdd30b..bf2d8a453e772 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; type ResponseFailures = Array>; diff --git a/x-pack/plugins/apm/scripts/shared/get_es_client.ts b/x-pack/plugins/apm/scripts/shared/get_es_client.ts index 1533efa82ba63..eb8a897146b11 100644 --- a/x-pack/plugins/apm/scripts/shared/get_es_client.ts +++ b/x-pack/plugins/apm/scripts/shared/get_es_client.ts @@ -6,7 +6,7 @@ */ import { Client } from '@elastic/elasticsearch'; -import { ApiKeyAuth, BasicAuth } from '@elastic/transport/lib/types'; +import { ApiKeyAuth, BasicAuth } from '@elastic/elasticsearch/lib/types'; import { ESSearchResponse, ESSearchRequest, diff --git a/x-pack/plugins/canvas/types/strategy.ts b/x-pack/plugins/canvas/types/strategy.ts index c7a83655049d6..2cc4c72116cdb 100644 --- a/x-pack/plugins/canvas/types/strategy.ts +++ b/x-pack/plugins/canvas/types/strategy.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IKibanaSearchRequest } from 'src/plugins/data/common'; import { ExpressionValueFilter } from '.'; diff --git a/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts b/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts index 99f7b52c17577..a49dc30b84fb5 100644 --- a/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts +++ b/x-pack/plugins/data_enhanced/server/search/session/get_search_status.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { ElasticsearchClient } from 'src/core/server'; import { SearchStatus } from './types'; import { SearchSessionRequestInfo } from '../../../../../../src/plugins/data/common'; diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts index efafb0b465855..c01e5196df8a0 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts @@ -17,7 +17,7 @@ import { delay } from '../lib/delay'; import { times } from 'lodash'; import { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import type * as estypes from '@elastic/elasticsearch/lib/api/types'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; type MockedLogger = ReturnType; diff --git a/x-pack/plugins/event_log/server/es/context.test.ts b/x-pack/plugins/event_log/server/es/context.test.ts index aac6496571720..97d68b64d1f39 100644 --- a/x-pack/plugins/event_log/server/es/context.test.ts +++ b/x-pack/plugins/event_log/server/es/context.test.ts @@ -9,7 +9,7 @@ import { createEsContext } from './context'; import { ElasticsearchClient, Logger } from '../../../../../src/core/server'; import { elasticsearchServiceMock, loggingSystemMock } from '../../../../../src/core/server/mocks'; import { DeeplyMockedKeys } from '@kbn/utility-types/jest'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; jest.mock('../lib/../../../../package.json', () => ({ version: '1.2.3' })); jest.mock('./init'); diff --git a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts index 5ed1ad902eed3..09ceb5e40a556 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts @@ -9,7 +9,7 @@ import { elasticsearchServiceMock } from 'src/core/server/mocks'; import { errors } from '@elastic/elasticsearch'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { FLEET_SERVER_ARTIFACTS_INDEX } from '../../../common'; diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts index 8cdaccc105eaf..ab0cf39fcc833 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportRequestOptions } from '@elastic/transport'; +import type { TransportRequestOptions } from '@elastic/elasticsearch'; import type { ElasticsearchClient, SavedObjectsClientContract } from 'src/core/server'; import { ElasticsearchAssetType } from '../../../../types'; diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts index a23cca4f765fa..8cb96e4af0bf3 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts @@ -6,7 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { PolicyFromES, SerializedPolicy } from '../../../../common/types'; import { RouteDependencies } from '../../../types'; diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts index 9e79e75100be8..cc9815955d28d 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { TransportRequestParams } from '@elastic/transport'; +import { TransportRequestParams } from '@elastic/elasticsearch'; import { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server'; import { InfraRouteConfig, diff --git a/x-pack/plugins/infra/server/utils/get_all_composite_data.ts b/x-pack/plugins/infra/server/utils/get_all_composite_data.ts index a8f36ebbad783..b5b4b731472c4 100644 --- a/x-pack/plugins/infra/server/utils/get_all_composite_data.ts +++ b/x-pack/plugins/infra/server/utils/get_all_composite_data.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; import { InfraDatabaseSearchResponse } from '../lib/adapters/framework'; export const getAllCompositeData = async < diff --git a/x-pack/plugins/ml/server/lib/ml_client/search.ts b/x-pack/plugins/ml/server/lib/ml_client/search.ts index ad3e37079c585..bdcee216cf669 100644 --- a/x-pack/plugins/ml/server/lib/ml_client/search.ts +++ b/x-pack/plugins/ml/server/lib/ml_client/search.ts @@ -8,7 +8,7 @@ import Boom from '@hapi/boom'; import { IScopedClusterClient } from 'kibana/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { JobSavedObjectService } from '../../saved_objects'; import { ML_RESULTS_INDEX_PATTERN } from '../../../common/constants/index_patterns'; diff --git a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts index 18572bba59d0f..a1bf7fbb0d264 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { i18n } from '@kbn/i18n'; import { ElasticsearchClient } from 'src/core/server'; diff --git a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts index bb0df00ddd0da..ce8b5cf14ac9b 100644 --- a/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts +++ b/x-pack/plugins/reporting/server/routes/lib/jobs_query.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { DeleteResponse, SearchHit, diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts index ebcc83f0fa8b1..90067ab4e2f0e 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { BulkRequest, BulkResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESSearchRequest, ESSearchResponse } from 'src/core/types/elasticsearch'; diff --git a/x-pack/plugins/rule_registry/server/utils/persistence_types.ts b/x-pack/plugins/rule_registry/server/utils/persistence_types.ts index 1eb0fbab1fa29..326a8bef49abd 100644 --- a/x-pack/plugins/rule_registry/server/utils/persistence_types.ts +++ b/x-pack/plugins/rule_registry/server/utils/persistence_types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { BulkResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { Logger } from '@kbn/logging'; import { diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts index e623c47b356cb..91bb5c775b74e 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { TransformGetTransformStatsResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { CheckMetadataTransformsTask, diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts index ebf284d4fa457..91daaa9bf6151 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/metadata/check_metadata_transforms_task.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { TransformGetTransformStatsResponse, TransformGetTransformStatsTransformStats, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts index 5fd859444b935..a6af104a346a9 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/metadata/handlers.ts @@ -6,7 +6,7 @@ */ import Boom from '@hapi/boom'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { SearchResponse, SearchTotalHits } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { TypeOf } from '@kbn/config-schema'; diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts b/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts index fde8181c6bd1f..989d695de4d62 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/resolver/tree/queries/descendants.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { IScopedClusterClient } from 'src/core/server'; import { JsonObject, JsonValue } from '@kbn/utility-types'; import { FieldsObject, ResolverSchema } from '../../../../../../common/endpoint/types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts index ebc9b76a7850a..449949eff4323 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { performance } from 'perf_hooks'; import { SavedObject } from 'src/core/types'; import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts index 74b2c547c7e29..cd4d912fa68c3 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts @@ -24,7 +24,7 @@ import { listMock } from '../../../../../lists/server/mocks'; import { getListClientMock } from '../../../../../lists/server/services/lists/list_client.mock'; import { getExceptionListClientMock } from '../../../../../lists/server/services/exception_lists/exception_list_client.mock'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; -import { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; import { queryExecutor } from './executors/query'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts index f7c032f98d600..ad984553d1a5d 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts @@ -7,7 +7,7 @@ import moment from 'moment'; import sinon from 'sinon'; -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; import { listMock } from '../../../../../lists/server/mocks'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index 46aa3dedf8d63..da58af579a2c0 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -11,7 +11,7 @@ import uuidv5 from 'uuid/v5'; import dateMath from '@elastic/datemath'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; import { ALERT_INSTANCE_ID, ALERT_RULE_UUID } from '@kbn/rule-data-utils'; import type { ListArray, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { MAX_EXCEPTION_LIST_SIZE } from '@kbn/securitysolution-list-constants'; diff --git a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts index ad7761f91e4fb..99c101e04e36b 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/es_deprecations_status.test.ts @@ -6,7 +6,7 @@ */ import _ from 'lodash'; -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts index ad5ca990b5ffe..e26a42ac6cff1 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_actions.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; import { SavedObjectsErrorHelpers } from 'src/core/server'; import { elasticsearchServiceMock } from 'src/core/server/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts index 1a95bfc71bcd0..f42449340fd6e 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts @@ -7,7 +7,7 @@ jest.mock('../es_indices_state_check', () => ({ esIndicesStateCheck: jest.fn() })); import { BehaviorSubject } from 'rxjs'; -import { TransportResult } from '@elastic/transport'; +import { TransportResult } from '@elastic/elasticsearch'; import { Logger } from 'src/core/server'; import { elasticsearchServiceMock, loggingSystemMock } from 'src/core/server/mocks'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/test/api_integration/apis/security_solution/utils.ts b/x-pack/test/api_integration/apis/security_solution/utils.ts index e44536701d5b3..4bc152ebcf5db 100644 --- a/x-pack/test/api_integration/apis/security_solution/utils.ts +++ b/x-pack/test/api_integration/apis/security_solution/utils.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch'; import { JsonObject, JsonArray } from '@kbn/utility-types'; diff --git a/x-pack/test/case_api_integration/common/lib/utils.ts b/x-pack/test/case_api_integration/common/lib/utils.ts index 58d8ede9cd8ef..6a44507033427 100644 --- a/x-pack/test/case_api_integration/common/lib/utils.ts +++ b/x-pack/test/case_api_integration/common/lib/utils.ts @@ -11,7 +11,7 @@ import http from 'http'; import expect from '@kbn/expect'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import type { Client } from '@elastic/elasticsearch'; import type SuperTest from 'supertest'; diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index a49318c09cf40..893c52acc5cec 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -6,7 +6,7 @@ */ import { KbnClient } from '@kbn/test'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { Client } from '@elastic/elasticsearch'; import type SuperTest from 'supertest'; diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts index 184cbe611ae55..329aee7e74b98 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/migrations.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { TaskInstanceWithDeprecatedFields } from '../../../../plugins/task_manager/server/task'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { SavedObjectsUtils } from '../../../../../src/core/server/saved_objects'; From 211ff87b43da6f598836aefb95838acdbbb802d2 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 15:59:13 +0200 Subject: [PATCH 060/172] fix ErrorCause | string errors --- .../elasticsearch/client/configure_client.test.ts | 2 +- .../saved_objects/migrations/core/elastic_index.ts | 4 ++-- .../actions/bulk_overwrite_transformed_documents.ts | 4 ++-- .../migrationsv2/actions/create_index.ts | 2 +- .../saved_objects/migrationsv2/actions/es_errors.ts | 12 ++++-------- .../actions/integration_tests/es_errors.test.ts | 6 +++--- .../migrationsv2/actions/wait_for_task.ts | 5 +++-- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index 4a02f2feb6268..648557cfffeae 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -16,7 +16,7 @@ import type { TransportRequestParams, DiagnosticResult, } from '@elastic/elasticsearch'; -import type { RequestBody } from '@elastic/elasticsearch/lib/types'; +import type { RequestBody } from '@elastic/transport/lib/types'; import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks'; import { loggingSystemMock } from '../../logging/logging_system.mock'; diff --git a/src/core/server/saved_objects/migrations/core/elastic_index.ts b/src/core/server/saved_objects/migrations/core/elastic_index.ts index 632a86b76967f..7897adefaf100 100644 --- a/src/core/server/saved_objects/migrations/core/elastic_index.ts +++ b/src/core/server/saved_objects/migrations/core/elastic_index.ts @@ -179,7 +179,7 @@ export async function write(client: MigrationEsClient, index: string, docs: RawD return; } - const exception: any = new Error(err.index!.error!.reason); + const exception: any = new Error((err.index!.error as estypes.ErrorCause)!.reason); exception.detail = err; throw exception; } @@ -416,7 +416,7 @@ async function reindex( task_id: String(task), }); - const e = body.error; + const e = body.error as estypes.ErrorCause; if (e) { throw new Error(`Re-index failed [${e.type}] ${e.reason} :: ${JSON.stringify(e)}`); } diff --git a/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts b/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts index c809b406a39ee..9c6d89cfcf18c 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts @@ -93,9 +93,9 @@ export const bulkOverwriteTransformedDocuments = .then((res) => { // Filter out version_conflict_engine_exception since these just mean // that another instance already updated these documents - const errors = (res.body.items ?? []) + const errors: estypes.ErrorCause[] = (res.body.items ?? []) .filter((item) => item.index?.error) - .map((item) => item.index!.error!) + .map((item) => item.index!.error! as estypes.ErrorCause) .filter(({ type }) => type !== 'version_conflict_engine_exception'); if (errors.length === 0) { diff --git a/src/core/server/saved_objects/migrationsv2/actions/create_index.ts b/src/core/server/saved_objects/migrationsv2/actions/create_index.ts index 9cb8880e7c664..9fa8aebcd7dc1 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/create_index.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/create_index.ts @@ -100,7 +100,7 @@ export const createIndex = ({ * - acknowledged=true, shards_acknowledged=true, index creation complete */ return Either.right({ - acknowledged: res.body.acknowledged, + acknowledged: Boolean(res.body.acknowledged), shardsAcknowledged: res.body.shards_acknowledged, }); }) diff --git a/src/core/server/saved_objects/migrationsv2/actions/es_errors.ts b/src/core/server/saved_objects/migrationsv2/actions/es_errors.ts index 49b996bb118d8..4f560468bcb0c 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/es_errors.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/es_errors.ts @@ -5,23 +5,19 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -export interface EsErrorCause { - type: string; - reason: string; -} - -export const isWriteBlockException = ({ type, reason }: EsErrorCause): boolean => { +export const isWriteBlockException = ({ type, reason }: estypes.ErrorCause): boolean => { return ( type === 'cluster_block_exception' && reason.match(/index \[.+] blocked by: \[FORBIDDEN\/8\/.+ \(api\)\]/) !== null ); }; -export const isIncompatibleMappingException = ({ type }: EsErrorCause): boolean => { +export const isIncompatibleMappingException = ({ type }: estypes.ErrorCause): boolean => { return type === 'strict_dynamic_mapping_exception' || type === 'mapper_parsing_exception'; }; -export const isIndexNotFoundException = ({ type }: EsErrorCause): boolean => { +export const isIndexNotFoundException = ({ type }: estypes.ErrorCause): boolean => { return type === 'index_not_found_exception'; }; diff --git a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/es_errors.test.ts b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/es_errors.test.ts index e259b375736d5..2473d8d3ae410 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/es_errors.test.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/es_errors.test.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from '../../../../'; import { InternalCoreStart } from '../../../../internal_types'; import * as kbnTestServer from '../../../../../test_helpers/kbn_server'; @@ -100,7 +100,7 @@ describe('Elasticsearch Errors', () => { ], }); - const cause = res.body.items[0].index!.error!; + const cause = res.body.items[0].index!.error! as estypes.ErrorCause; expect(isWriteBlockException(cause)).toEqual(true); }); @@ -122,7 +122,7 @@ describe('Elasticsearch Errors', () => { ], }); - const cause = res.body.items[0].create!.error!; + const cause = res.body.items[0].create!.error! as estypes.ErrorCause; expect(isWriteBlockException(cause)).toEqual(true); }); diff --git a/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts b/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts index 212e1ad9c8c81..da3e8e8e05663 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts @@ -5,6 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as Either from 'fp-ts/lib/Either'; import * as TaskEither from 'fp-ts/lib/TaskEither'; import * as Option from 'fp-ts/lib/Option'; @@ -16,7 +17,7 @@ import { } from './catch_retryable_es_client_errors'; /** @internal */ export interface WaitForTaskResponse { - error: Option.Option<{ type: string; reason: string; index?: string }>; + error: Option.Option<{ type?: string; reason: string; index?: string }>; completed: boolean; failures: Option.Option; description?: string; @@ -86,7 +87,7 @@ export const waitForTask = const failures = body.response?.failures ?? []; return Either.right({ completed: body.completed, - error: Option.fromNullable(body.error), + error: Option.fromNullable(body.error as estypes.ErrorCauseKeys), failures: failures.length > 0 ? Option.some(failures) : Option.none, description: body.task.description, }); From 5871840ad6c5d7c5266e1a2cb1a3833bf256f755 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 16:44:32 +0200 Subject: [PATCH 061/172] do not use enum --- src/core/server/elasticsearch/client/configure_client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index ec704bc07799b..9fa374dfae719 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -8,7 +8,7 @@ import { Buffer } from 'buffer'; import { stringify } from 'querystring'; -import { Client, errors, Transport, events, HttpConnection } from '@elastic/elasticsearch'; +import { Client, errors, Transport, HttpConnection } from '@elastic/elasticsearch'; import type { TransportRequestParams, TransportRequestOptions, @@ -133,7 +133,7 @@ export function getRequestDebugMeta(event: DiagnosticResult): { } const addLogging = (client: Client, logger: Logger) => { - client.diagnostic.on(events.RESPONSE, (error, event) => { + client.diagnostic.on('response', (error, event) => { if (event) { const opaqueId = event.meta.request.options.opaqueId; const meta = opaqueId From dc81ea86a89ba7e2f3fba6a1c3747cd5ea0c769c Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 16:44:54 +0200 Subject: [PATCH 062/172] fix errors in data plugin --- src/plugins/data/server/autocomplete/terms_agg.ts | 2 +- src/plugins/data/server/autocomplete/terms_enum.ts | 2 +- .../search/strategies/es_search/es_search_strategy.ts | 2 +- .../search/strategies/ese_search/ese_search_strategy.ts | 9 +++------ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/plugins/data/server/autocomplete/terms_agg.ts b/src/plugins/data/server/autocomplete/terms_agg.ts index c34a1ac4abe9b..20a8a5c212f26 100644 --- a/src/plugins/data/server/autocomplete/terms_agg.ts +++ b/src/plugins/data/server/autocomplete/terms_agg.ts @@ -40,7 +40,7 @@ export async function termsAggSuggestions( const result = await esClient.search( { index, body }, { - abortController: { signal: abortSignal }, + signal: abortSignal, } ); diff --git a/src/plugins/data/server/autocomplete/terms_enum.ts b/src/plugins/data/server/autocomplete/terms_enum.ts index 4acfb6550f5b0..201ff32c056ce 100644 --- a/src/plugins/data/server/autocomplete/terms_enum.ts +++ b/src/plugins/data/server/autocomplete/terms_enum.ts @@ -50,7 +50,7 @@ export async function termsEnumSuggestions( }, }, { - abortController: { signal: abortSignal }, + signal: abortSignal, } ); diff --git a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts index 2a83220710fba..1c2d333f5bfc6 100644 --- a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts @@ -44,7 +44,7 @@ export const esSearchStrategyProvider = ( ...request.params, }; const { body } = await esClient.asCurrentUser.search(params, { - abortController: { signal: abortSignal }, + signal: abortSignal, }); const response = shimHitsTotal(body, options); return toKibanaSearchResponse(response); diff --git a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts index 1983ff2d8066f..e94f1aa44d351 100644 --- a/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts @@ -68,12 +68,9 @@ export const enhancedEsSearchStrategyProvider = ( ...request.params, }; const { body, headers } = id - ? await client.asyncSearch.get( - { ...params, id }, - { abortController: { signal: options.abortSignal } } - ) + ? await client.asyncSearch.get({ ...params, id }, { signal: options.abortSignal }) : await client.asyncSearch.submit(params, { - abortController: { signal: options.abortSignal }, + signal: options.abortSignal, }); const response = shimHitsTotal(body.response, options); @@ -126,7 +123,7 @@ export const enhancedEsSearchStrategyProvider = ( querystring, }, { - abortController: { signal: options?.abortSignal }, + signal: options?.abortSignal, } ); From 2c485c1ef725eead56b1a9c7063754b8e709f9b2 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 16:50:14 +0200 Subject: [PATCH 063/172] update x-pack code --- package.json | 1 + .../actions/server/builtin_action_types/es_index.ts | 2 ++ x-pack/plugins/apm/scripts/shared/get_es_client.ts | 2 +- .../by_agent/java/gc/fetch_and_transform_gc_metrics.ts | 10 +++------- x-pack/plugins/fleet/server/services/agents/crud.ts | 1 - .../server/rule_data_client/rule_data_client.ts | 2 ++ .../server/authentication/api_keys/api_keys.ts | 2 ++ .../detection_engine/signals/single_search_after.ts | 1 + .../server/lib/detection_engine/signals/utils.ts | 6 ++++++ .../server/lib/requests/get_monitor_availability.ts | 3 --- 10 files changed, 18 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 4b6dff35a1977..40ef33d98f9cc 100644 --- a/package.json +++ b/package.json @@ -440,6 +440,7 @@ "@elastic/github-checks-reporter": "0.0.20b3", "@elastic/makelogs": "^6.0.0", "@elastic/synthetics": "^1.0.0-beta.12", + "@elastic/transport": "^0.0.7", "@emotion/babel-preset-css-prop": "^11.2.0", "@emotion/jest": "^11.3.0", "@istanbuljs/schema": "^0.1.2", diff --git a/x-pack/plugins/actions/server/builtin_action_types/es_index.ts b/x-pack/plugins/actions/server/builtin_action_types/es_index.ts index 3662fea00e31d..cd71becb7eddd 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/es_index.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/es_index.ts @@ -105,7 +105,9 @@ async function executor( const err = find(result.items, 'index.error.reason'); if (err) { return wrapErr( + // @ts-expect-error error_details is not comptible with error: ErrorCause | string `${err.index?.error?.reason}${ + // @ts-expect-error error_details is not comptible with error: ErrorCause | string err.index?.error?.caused_by ? ` (${err.index?.error?.caused_by?.reason})` : '' }`, actionId, diff --git a/x-pack/plugins/apm/scripts/shared/get_es_client.ts b/x-pack/plugins/apm/scripts/shared/get_es_client.ts index eb8a897146b11..671997c632452 100644 --- a/x-pack/plugins/apm/scripts/shared/get_es_client.ts +++ b/x-pack/plugins/apm/scripts/shared/get_es_client.ts @@ -6,7 +6,7 @@ */ import { Client } from '@elastic/elasticsearch'; -import { ApiKeyAuth, BasicAuth } from '@elastic/elasticsearch/lib/types'; +import type { ApiKeyAuth, BasicAuth } from '@elastic/transport/lib/types'; import { ESSearchResponse, ESSearchRequest, diff --git a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts index 0177d318ce96b..06138931c004e 100644 --- a/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts +++ b/x-pack/plugins/apm/server/lib/metrics/by_agent/java/gc/fetch_and_transform_gc_metrics.ts @@ -97,7 +97,6 @@ export async function fetchAndTransformGcMetrics({ // get the derivative, which is the delta y derivative: { derivative: { - // @ts-expect-error AggregationsBucketsPath is not valid buckets_path: 'max', }, }, @@ -105,7 +104,6 @@ export async function fetchAndTransformGcMetrics({ // needs to be excluded value: { bucket_script: { - // @ts-expect-error AggregationsBucketsPath is not valid buckets_path: { value: 'derivative' }, script: 'params.value > 0.0 ? params.value : 0.0', }, @@ -117,7 +115,7 @@ export async function fetchAndTransformGcMetrics({ }, }, }); - // @ts-expect-error AggregationsBucketsPath is not valid + const response = await apmEventClient.search(operationName, params); const { aggregations } = response; @@ -129,11 +127,11 @@ export async function fetchAndTransformGcMetrics({ series: [], }; } - // @ts-expect-error aggregations is unknown + const series = aggregations.per_pool.buckets.map((poolBucket, i) => { const label = poolBucket.key as string; const timeseriesData = poolBucket.timeseries; - // @ts-expect-error bucket has any type + const data = timeseriesData.buckets.map((bucket) => { // derivative/value will be undefined for the first hit and if the `max` value is null const bucketValue = bucket.value?.value; @@ -155,9 +153,7 @@ export async function fetchAndTransformGcMetrics({ }); const values = data - // @ts-expect-error coordinate has any type .map((coordinate) => coordinate.y) - // @ts-expect-error y has any type .filter((y) => y !== null); const overallValue = sum(values) / values.length; diff --git a/x-pack/plugins/fleet/server/services/agents/crud.ts b/x-pack/plugins/fleet/server/services/agents/crud.ts index f89517d83a0f1..39d4833fbc341 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud.ts @@ -318,7 +318,6 @@ export async function bulkUpdateAgents( items: res.body.items.map((item: estypes.BulkResponseItemContainer) => ({ id: item.update!._id as string, success: !item.update!.error, - // @ts-expect-error ErrorCause is not assignable to Error error: item.update!.error as Error, })), }; diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts index 297fdbdc67642..b20f682fafa39 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts @@ -129,9 +129,11 @@ export class RuleDataClient implements IRuleDataClient { if ( response.body.items.length > 0 && (response.body.items.every( + // @ts-expect-error error_details is not comptible with error: ErrorCause | string (item) => item.index?.error?.type === 'index_not_found_exception' ) || response.body.items.every( + // @ts-expect-error error_details is not comptible with error: ErrorCause | string (item) => item.index?.error?.type === 'illegal_argument_exception' )) ) { diff --git a/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts b/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts index 1707ca710aaf8..bb9d15c13fa77 100644 --- a/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts +++ b/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts @@ -252,6 +252,7 @@ export class APIKeys { let result: InvalidateAPIKeyResult; try { // User needs `manage_api_key` privilege to use this API + // @ts-expect-error error_details is not comptible with error: ErrorCause | string result = ( await this.clusterClient.asScoped(request).asCurrentUser.security.invalidateApiKey({ body: { @@ -288,6 +289,7 @@ export class APIKeys { let result: InvalidateAPIKeyResult; try { // Internal user needs `cluster:admin/xpack/security/api_key/invalidate` privilege to use this API + // @ts-expect-error error_details is not comptible with error: ErrorCause | string result = ( await this.clusterClient.asInternalUser.security.invalidateApiKey({ body: { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts index 2596068848ef0..9b4bfe5b8aed1 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts @@ -76,6 +76,7 @@ export const singleSearchAfter = async ({ const end = performance.now(); const searchErrors = createErrorsFromShard({ + // @ts-expect-error is not compatile with ErrorCause | string; errors: nextSearchAfterResult._shards.failures ?? [], }); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index da58af579a2c0..38cf66d26baf7 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -505,13 +505,17 @@ export const errorAggregator = ( ): BulkResponseErrorAggregation => { return response.items.reduce((accum, item) => { if (item.create?.error != null && !ignoreStatusCodes.includes(item.create.status)) { + // @ts-expect-error error is not comptible with error: ErrorCause | string if (accum[item.create.error.reason] == null) { + // @ts-expect-error error is not comptible with error: ErrorCause | string accum[item.create.error.reason] = { count: 1, statusCode: item.create.status, }; } else { + // @ts-expect-error error is not comptible with error: ErrorCause | string accum[item.create.error.reason] = { + // @ts-expect-error error is not comptible with error: ErrorCause | string count: accum[item.create.error.reason].count + 1, statusCode: item.create.status, }; @@ -728,9 +732,11 @@ export const createSearchAfterReturnTypeFromResponse = ({ searchResult._shards.failed === 0 || searchResult._shards.failures?.every((failure) => { return ( + // @ts-expect-error reason is not comptible with error: ErrorCause | string failure.reason?.reason?.includes( 'No mapping found for [@timestamp] in order to sort on' ) || + // @ts-expect-error reason is not comptible with error: ErrorCause | string failure.reason?.reason?.includes( `No mapping found for [${timestampOverride}] in order to sort on` ) diff --git a/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts b/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts index 33db37329f77a..4d51a4857ecaa 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_monitor_availability.ts @@ -147,11 +147,8 @@ export const getMonitorAvailability: UMElasticsearchQueryFn< }, }; - // @ts-expect-error AggregationsBucketsPath is not valid const { body: result } = await uptimeEsClient.search({ body: esParams }); - // @ts-expect-error aggregation is not valid afterKey = result?.aggregations?.monitors?.after_key as AfterKey; - // @ts-expect-error aggregation is not valid queryResults.push(formatBuckets(result?.aggregations?.monitors?.buckets || [])); } while (afterKey !== undefined); From 0a35a426a2a6f27d273132a47eeb72cc6dd8c31f Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 17:45:52 +0200 Subject: [PATCH 064/172] fix transport --- package.json | 2 +- src/core/server/elasticsearch/client/configure_client.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 40ef33d98f9cc..9296aef2fe693 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "@elastic/request-crypto": "1.1.4", "@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set", "@elastic/search-ui-app-search-connector": "^1.6.0", + "@elastic/transport": "^0.0.7", "@emotion/react": "^11.4.0", "@hapi/accept": "^5.0.2", "@hapi/boom": "^9.1.4", @@ -440,7 +441,6 @@ "@elastic/github-checks-reporter": "0.0.20b3", "@elastic/makelogs": "^6.0.0", "@elastic/synthetics": "^1.0.0-beta.12", - "@elastic/transport": "^0.0.7", "@emotion/babel-preset-css-prop": "^11.2.0", "@emotion/jest": "^11.3.0", "@istanbuljs/schema": "^0.1.2", diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index 9fa374dfae719..4a4128d220b9a 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -8,7 +8,7 @@ import { Buffer } from 'buffer'; import { stringify } from 'querystring'; -import { Client, errors, Transport, HttpConnection } from '@elastic/elasticsearch'; +import { Client, errors } from '@elastic/elasticsearch'; import type { TransportRequestParams, TransportRequestOptions, @@ -16,6 +16,7 @@ import type { DiagnosticResult, } from '@elastic/elasticsearch'; import type { RequestBody } from '@elastic/transport/lib/types'; +import { Transport, HttpConnection } from '@elastic/transport'; import { Logger } from '../../logging'; import { parseClientOptions, ElasticsearchClientConfig } from './client_config'; import type { ElasticsearchErrorDetails } from './types'; From 3c13ec5f3feb66688353bc729f1c54bfc23b7e16 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 17:46:23 +0200 Subject: [PATCH 065/172] fix apm search request --- .../server/lib/apm_telemetry/collect_data_telemetry/tasks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts index 7f07821977607..f06226c864a98 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts @@ -599,7 +599,7 @@ export const tasks: TelemetryTask[] = [ executor: async ({ search, indices }) => { const response = await search({ index: [indices.transaction, indices.span, indices.error], - terminateAfter: 1, + terminate_after: 1, body: { query: { exists: { From 497ea54be034308e042744911b94cf7403981480 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 17:47:01 +0200 Subject: [PATCH 066/172] do not crash on reporting --- .../reporting/server/lib/store/ilm_policy_manager/constants.ts | 2 ++ .../server/lib/store/ilm_policy_manager/ilm_policy_manager.ts | 1 - x-pack/plugins/reporting/server/lib/store/store.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts index cbbf21094d61f..0c12903def052 100644 --- a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts +++ b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts @@ -6,6 +6,7 @@ */ import type { IlmPutLifecycleRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { ILM_POLICY_NAME } from '../../../../common/constants'; export const reportingIlmPolicy: IlmPutLifecycleRequest['body'] = { policy: { @@ -14,5 +15,6 @@ export const reportingIlmPolicy: IlmPutLifecycleRequest['body'] = { actions: {}, }, }, + name: ILM_POLICY_NAME, }, }; diff --git a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts index ca0a74cae8726..9f5e2c2a83915 100644 --- a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts +++ b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts @@ -39,7 +39,6 @@ export class IlmPolicyManager { */ public async createIlmPolicy(): Promise { await this.client.ilm.putLifecycle({ - policy: ILM_POLICY_NAME, body: reportingIlmPolicy, }); } diff --git a/x-pack/plugins/reporting/server/lib/store/store.ts b/x-pack/plugins/reporting/server/lib/store/store.ts index 6c9d31c5af359..43f57da8c21f7 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.ts @@ -196,7 +196,7 @@ export class ReportingStore { await ilmPolicyManager.createIlmPolicy(); } catch (e) { this.logger.error('Error in start phase'); - this.logger.error(e.body.error); + this.logger.error(e.body?.error); throw e; } } From e467a5ecd0844e515a2013647b622c27f92f5f94 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 17:53:53 +0200 Subject: [PATCH 067/172] fix kbn-test build --- packages/kbn-test/BUILD.bazel | 2 ++ packages/kbn-test/src/es/client_to_kibana_client.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/kbn-test/BUILD.bazel b/packages/kbn-test/BUILD.bazel index efaf01f7137d9..bb86299d3d306 100644 --- a/packages/kbn-test/BUILD.bazel +++ b/packages/kbn-test/BUILD.bazel @@ -41,6 +41,7 @@ RUNTIME_DEPS = [ "//packages/kbn-std", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", + "@npm//@elastic/transport", "@npm//axios", "@npm//@babel/traverse", "@npm//chance", @@ -76,6 +77,7 @@ TYPES_DEPS = [ "//packages/kbn-i18n", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", + "@npm//@elastic/transport", "@npm//del", "@npm//form-data", "@npm//jest", diff --git a/packages/kbn-test/src/es/client_to_kibana_client.ts b/packages/kbn-test/src/es/client_to_kibana_client.ts index 57c492f09c20f..e01c524c6294d 100644 --- a/packages/kbn-test/src/es/client_to_kibana_client.ts +++ b/packages/kbn-test/src/es/client_to_kibana_client.ts @@ -12,7 +12,7 @@ import type { TransportRequestOptions, TransportResult, } from '@elastic/elasticsearch'; -import { Transport } from '@elastic/elasticsearch'; +import { Transport } from '@elastic/transport'; class KibanaTransport extends Transport { request(params: TransportRequestParams, options?: TransportRequestOptions) { From 407dd5d98610a2dceac503fbde489657db7e325c Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 17:56:31 +0200 Subject: [PATCH 068/172] mute reporting error to start --- .../server/lib/store/ilm_policy_manager/ilm_policy_manager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts index 9f5e2c2a83915..31f1571cfbc94 100644 --- a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts +++ b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts @@ -38,6 +38,7 @@ export class IlmPolicyManager { * Create the Reporting ILM policy */ public async createIlmPolicy(): Promise { + // @ts-expect-error expects policy to be present await this.client.ilm.putLifecycle({ body: reportingIlmPolicy, }); From d04b2f5f3771207d2d519259e7bf08a7e07d1b20 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 18:29:40 +0200 Subject: [PATCH 069/172] fix ftr build --- x-pack/test/api_integration/apis/lens/telemetry.ts | 2 +- .../api_integration/apis/metrics_ui/metric_threshold_alert.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/api_integration/apis/lens/telemetry.ts b/x-pack/test/api_integration/apis/lens/telemetry.ts index 8d73a733a2266..a421d9c7708ad 100644 --- a/x-pack/test/api_integration/apis/lens/telemetry.ts +++ b/x-pack/test/api_integration/apis/lens/telemetry.ts @@ -21,7 +21,6 @@ const COMMON_HEADERS = { export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); const es = getService('es'); - const kibanaClient = convertToKibanaClient(es); async function assertExpectedSavedObjects(num: number) { // Make sure that new/deleted docs are available to search @@ -38,6 +37,7 @@ export default ({ getService }: FtrProviderContext) => { } describe('lens telemetry', () => { + const kibanaClient = convertToKibanaClient(es); beforeEach(async () => { await es.deleteByQuery({ index: '.kibana', diff --git a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts index 8857928463742..f2bcafd6a9a4e 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts @@ -26,7 +26,6 @@ const { gauge, rate } = DATES['alert-test-data']; export default function ({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const esClient = getService('es'); - const kbnClient = convertToKibanaClient(esClient); const baseParams: EvaluatedAlertParams = { groupBy: void 0, @@ -83,6 +82,7 @@ export default function ({ getService }: FtrProviderContext) { }; describe('Metric Threshold Alerts Executor', () => { + const kbnClient = convertToKibanaClient(esClient); before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/alerts_test_data')); after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/alerts_test_data')); From a0421288ee7589e20373be98fb9b56d65c5f71ea Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 14 Oct 2021 18:49:35 +0200 Subject: [PATCH 070/172] another attempt --- x-pack/test/api_integration/apis/lens/telemetry.ts | 7 +++---- .../apis/metrics_ui/metric_threshold_alert.ts | 8 +++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/x-pack/test/api_integration/apis/lens/telemetry.ts b/x-pack/test/api_integration/apis/lens/telemetry.ts index a421d9c7708ad..1c0c67a5203d6 100644 --- a/x-pack/test/api_integration/apis/lens/telemetry.ts +++ b/x-pack/test/api_integration/apis/lens/telemetry.ts @@ -37,7 +37,6 @@ export default ({ getService }: FtrProviderContext) => { } describe('lens telemetry', () => { - const kibanaClient = convertToKibanaClient(es); beforeEach(async () => { await es.deleteByQuery({ index: '.kibana', @@ -106,7 +105,7 @@ export default ({ getService }: FtrProviderContext) => { }, refresh: 'wait_for', }); - + const kibanaClient = convertToKibanaClient(es); const result = await getDailyEvents('.kibana', () => Promise.resolve(kibanaClient)); expect(result).to.eql({ @@ -149,7 +148,7 @@ export default ({ getService }: FtrProviderContext) => { getEvent('revert', date1, 'suggestion'), ], }); - + const kibanaClient = convertToKibanaClient(es); const result = await getDailyEvents('.kibana', () => Promise.resolve(kibanaClient)); expect(result).to.eql({ @@ -176,7 +175,7 @@ export default ({ getService }: FtrProviderContext) => { const esArchiver = getService('esArchiver'); await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/lens/basic'); - + const kibanaClient = convertToKibanaClient(es); const results = await getVisualizationCounts(() => Promise.resolve(kibanaClient), '.kibana'); expect(results).to.have.keys([ diff --git a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts index f2bcafd6a9a4e..4291e347624f6 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts @@ -82,7 +82,6 @@ export default function ({ getService }: FtrProviderContext) { }; describe('Metric Threshold Alerts Executor', () => { - const kbnClient = convertToKibanaClient(esClient); before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/alerts_test_data')); after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/alerts_test_data')); @@ -102,6 +101,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: gauge.max }; + const kbnClient = convertToKibanaClient(esClient); const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { @@ -125,6 +125,7 @@ export default function ({ getService }: FtrProviderContext) { it('should alert on the last value when the end date is the same as the last event', async () => { const params = { ...baseParams }; const timeFrame = { end: gauge.max }; + const kbnClient = convertToKibanaClient(esClient); const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { @@ -162,6 +163,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: gauge.max }; + const kbnClient = convertToKibanaClient(esClient); const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { @@ -202,6 +204,7 @@ export default function ({ getService }: FtrProviderContext) { groupBy: ['env'], }; const timeFrame = { end: gauge.max }; + const kbnClient = convertToKibanaClient(esClient); const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { @@ -243,6 +246,7 @@ export default function ({ getService }: FtrProviderContext) { groupBy: ['env'], }; const timeFrame = { end: gauge.midpoint }; + const kbnClient = convertToKibanaClient(esClient); const results = await evaluateAlert( kbnClient, params, @@ -303,6 +307,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: rate.max }; + const kbnClient = convertToKibanaClient(esClient); const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { @@ -343,6 +348,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; const timeFrame = { end: rate.max }; + const kbnClient = convertToKibanaClient(esClient); const results = await evaluateAlert(kbnClient, params, configuration, [], timeFrame); expect(results).to.eql([ { From 07b0bc269b17b1e38e21740daf9c9d21aa195cfe Mon Sep 17 00:00:00 2001 From: restrry Date: Sun, 17 Oct 2021 12:16:45 +0200 Subject: [PATCH 071/172] update import path --- .../index_pattern_field_editor/server/routes/field_preview.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts b/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts index 847dd41e0082b..9ffa5c88df8e8 100644 --- a/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts +++ b/src/plugins/index_pattern_field_editor/server/routes/field_preview.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { schema } from '@kbn/config-schema'; import { API_BASE_PATH } from '../../common/constants'; From 4ce204e7ba309d7de802cb64793447a2e06d9f97 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 18 Oct 2021 09:38:29 +0200 Subject: [PATCH 072/172] address or mute new errors --- .../public/__mocks__/index_pattern.ts | 2 +- .../__mocks__/index_pattern_with_timefield.ts | 3 +- .../tests/enrollment_flow.ts | 4 +- .../epm/elasticsearch/ml_model/install.ts | 5 ++- .../components/expression_chart.test.tsx | 1 + .../routes/log_sources/configuration.ts | 2 + .../server/routes/metrics_sources/index.ts | 2 + .../rule_data_client/rule_data_client.ts | 1 + .../server/rule_data_client/types.ts | 2 +- .../notifications/utils.test.ts | 38 +++++++++---------- .../security_and_spaces/tests/migrations.ts | 13 +++++-- .../apis/epm/install_endpoint.ts | 27 +++++++------ .../apis/epm/install_remove_assets.ts | 1 + 13 files changed, 58 insertions(+), 43 deletions(-) diff --git a/src/plugins/discover/public/__mocks__/index_pattern.ts b/src/plugins/discover/public/__mocks__/index_pattern.ts index 2acb512617a6b..605d5a4d5c68e 100644 --- a/src/plugins/discover/public/__mocks__/index_pattern.ts +++ b/src/plugins/discover/public/__mocks__/index_pattern.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { flattenHit, IIndexPatternFieldList } from '../../../data/common'; import { IndexPattern } from '../../../data/common'; diff --git a/src/plugins/discover/public/__mocks__/index_pattern_with_timefield.ts b/src/plugins/discover/public/__mocks__/index_pattern_with_timefield.ts index 6cf8e8b3485ff..dbbb021e733d4 100644 --- a/src/plugins/discover/public/__mocks__/index_pattern_with_timefield.ts +++ b/src/plugins/discover/public/__mocks__/index_pattern_with_timefield.ts @@ -5,10 +5,9 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { flattenHit, IIndexPatternFieldList } from '../../../data/common'; import { IndexPattern } from '../../../data/common'; -import type { estypes } from '@elastic/elasticsearch'; const fields = [ { diff --git a/test/interactive_setup_api_integration/tests/enrollment_flow.ts b/test/interactive_setup_api_integration/tests/enrollment_flow.ts index 9f61529cc3439..53454207b73ed 100644 --- a/test/interactive_setup_api_integration/tests/enrollment_flow.ts +++ b/test/interactive_setup_api_integration/tests/enrollment_flow.ts @@ -38,9 +38,7 @@ export default function (context: FtrProviderContext) { let enrollmentAPIKey: string; beforeEach(async () => { const apiResponse = await es.security.createApiKey({ body: { name: 'enrollment_api_key' } }); - enrollmentAPIKey = Buffer.from(`${apiResponse.body.id}:${apiResponse.body.api_key}`).toString( - 'base64' - ); + enrollmentAPIKey = Buffer.from(`${apiResponse.id}:${apiResponse.api_key}`).toString('base64'); }); afterEach(async () => { diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ml_model/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ml_model/install.ts index d6de59507fbf7..d97081f15aca3 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ml_model/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ml_model/install.ts @@ -6,7 +6,7 @@ */ import type { ElasticsearchClient, SavedObjectsClientContract } from 'kibana/server'; -import { ResponseError } from '@elastic/elasticsearch/lib/errors'; +import { errors } from '@elastic/elasticsearch'; import { saveInstalledEsRefs } from '../../packages/install'; import { getPathParts } from '../../archive'; @@ -71,12 +71,13 @@ async function handleMlModelInstall({ model_id: mlModel.installationName, defer_definition_decompression: true, timeout: '45s', + // @ts-expect-error expects an object not a string body: mlModel.content, }); } catch (err) { // swallow the error if the ml model already exists. const isAlreadyExistError = - err instanceof ResponseError && + err instanceof errors.ResponseError && err?.body?.error?.type === 'resource_already_exists_exception'; if (!isAlreadyExistError) { throw err; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx index 5aafd9b613d99..1eacae1feee46 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx @@ -54,6 +54,7 @@ describe('ExpressionChart', () => { metricAlias: 'metricbeat-*', inventoryDefaultView: 'host', metricsExplorerDefaultView: 'host', + // @ts-expect-error not full interface fields: { timestamp: '@timestamp', container: 'container.id', diff --git a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts index f0d7b18d91a5d..f954ce7d78939 100644 --- a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts +++ b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts @@ -85,11 +85,13 @@ export const initLogSourceConfigurationRoutes = ({ framework, sources }: InfraBa ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error incompat interface patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error incompat interface patchedSourceConfigurationProperties )); diff --git a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts index 0123e4678697c..c21520d5d89f3 100644 --- a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts +++ b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts @@ -88,11 +88,13 @@ export const initMetricsSourceConfigurationRoutes = (libs: InfraBackendLibs) => ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error incompat interface patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, + // @ts-expect-error incompat interface patchedSourceConfigurationProperties )); diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts index ba92e9aac3d27..35f0379203496 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts @@ -179,6 +179,7 @@ export class RuleDataClient implements IRuleDataClient { return clusterClient.bulk(requestWithDefaultParameters).then((response) => { if (response.body.errors) { + // @ts-expect-error @elastic/elasticsearch Context falls back to Record mistakenly const error = new errors.ResponseError(response); throw error; } diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts index 90067ab4e2f0e..5ddbd0035526d 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/types.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/types.ts @@ -35,5 +35,5 @@ export interface IRuleDataReader { } export interface IRuleDataWriter { - bulk(request: BulkRequest): Promise>; + bulk(request: BulkRequest): Promise | undefined>; } diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/notifications/utils.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/notifications/utils.test.ts index 2da7a0398bd3f..36e0b6a6c02ab 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/notifications/utils.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/notifications/utils.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SearchHit } from '@elastic/elasticsearch/api/types'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { loggingSystemMock } from 'src/core/server/mocks'; import { SignalSource } from '../signals/types'; import { deconflictSignalsAndResults, getNotificationResultsLink } from './utils'; @@ -41,7 +41,7 @@ describe('utils', () => { }); test('given an empty signal and a single query result it returns the query result in the array', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', _index: 'index-123', @@ -56,7 +56,7 @@ describe('utils', () => { }); test('given a single signal and an empty query result it returns the query result in the array', () => { - const signals: Array> = [ + const signals: Array> = [ { _id: 'id-123', _index: 'index-123', @@ -71,7 +71,7 @@ describe('utils', () => { }); test('given a signal and a different query result it returns both combined together', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', _index: 'index-123', @@ -80,7 +80,7 @@ describe('utils', () => { }, }, ]; - const signals: Array> = [ + const signals: Array> = [ { _id: 'id-789', _index: 'index-456', @@ -96,7 +96,7 @@ describe('utils', () => { }); test('given a duplicate in querySignals it returns both combined together without the duplicate', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', _index: 'index-123', // This should only show up once and not be duplicated twice @@ -112,7 +112,7 @@ describe('utils', () => { }, }, ]; - const signals: Array> = [ + const signals: Array> = [ { _id: 'id-123', // This should only show up once and not be duplicated twice _index: 'index-123', @@ -154,7 +154,7 @@ describe('utils', () => { }); test('given a duplicate in signals it returns both combined together without the duplicate', () => { - const signals: Array> = [ + const signals: Array> = [ { _id: 'id-123', _index: 'index-123', // This should only show up once and not be duplicated twice @@ -170,7 +170,7 @@ describe('utils', () => { }, }, ]; - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', // This should only show up once and not be duplicated twice _index: 'index-123', @@ -206,7 +206,7 @@ describe('utils', () => { }); test('does not give a duplicate in signals if they are only different by their index', () => { - const signals: Array> = [ + const signals: Array> = [ { _id: 'id-123', _index: 'index-123-a', // This is only different by index @@ -222,7 +222,7 @@ describe('utils', () => { }, }, ]; - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', // This is only different by index _index: 'index-123-b', @@ -245,7 +245,7 @@ describe('utils', () => { }); test('it logs a debug statement when it sees a duplicate and returns nothing if both are identical', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', _index: 'index-123', @@ -254,7 +254,7 @@ describe('utils', () => { }, }, ]; - const signals: Array> = [ + const signals: Array> = [ { _id: 'id-123', _index: 'index-123', @@ -278,7 +278,7 @@ describe('utils', () => { }); test('it logs an error statement if it sees a signal missing an "_id" for an uncommon reason and returns both documents', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', _index: 'index-123', @@ -305,7 +305,7 @@ describe('utils', () => { }); test('it logs an error statement if it sees a signal missing a "_index" for an uncommon reason and returns both documents', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', _index: 'index-123', @@ -332,14 +332,14 @@ describe('utils', () => { }); test('it logs an error statement if it sees a querySignals missing an "_id" for an uncommon reason and returns both documents', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _index: 'index-123', _source: { test: '123', }, }, - ] as unknown[] as Array>; + ] as unknown[] as Array>; const signals: unknown[] = [ { _id: 'id-123', @@ -359,14 +359,14 @@ describe('utils', () => { }); test('it logs an error statement if it sees a querySignals missing a "_index" for an uncommon reason and returns both documents', () => { - const querySignals: Array> = [ + const querySignals: Array> = [ { _id: 'id-123', _source: { test: '123', }, }, - ] as unknown[] as Array>; + ] as unknown[] as Array>; const signals: unknown[] = [ { _id: 'id-123', diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts index aa0344b6af672..04586999aa163 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts @@ -77,10 +77,15 @@ export default ({ getService }: FtrProviderContext): void => { ruleThrottle: string; alertThrottle: string; }; - }>({ - index: '.kibana', - id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3', - }); + }>( + { + index: '.kibana', + id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3', + }, + { + meta: true, + } + ); expect(response.statusCode).to.eql(200); // "alertThrottle" and "ruleThrottle" should still exist diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_endpoint.ts b/x-pack/test/fleet_api_integration/apis/epm/install_endpoint.ts index ba9264e1d1999..e3e0fda58e230 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_endpoint.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_endpoint.ts @@ -49,18 +49,24 @@ export default function (providerContext: FtrProviderContext) { describe('install', () => { transforms.forEach((transform) => { it(`should have installed the [${transform.id}] transform`, async function () { - const res = await es.transport.request({ - method: 'GET', - path: `/_transform/${transform.id}-${pkgVersion}`, - }); + const res = await es.transport.request( + { + method: 'GET', + path: `/_transform/${transform.id}-${pkgVersion}`, + }, + { meta: true } + ); expect(res.statusCode).equal(200); }); it(`should have created the destination index for the [${transform.id}] transform`, async function () { // the index is defined in the transform file - const res = await es.transport.request({ - method: 'GET', - path: `/${transform.dest}`, - }); + const res = await es.transport.request( + { + method: 'GET', + path: `/${transform.dest}`, + }, + { meta: true } + ); expect(res.statusCode).equal(200); }); }); @@ -82,9 +88,7 @@ export default function (providerContext: FtrProviderContext) { method: 'GET', path: `/_transform/${transform.id}`, }, - { - ignore: [404], - } + { meta: true, ignore: [404] } ); expect(res.statusCode).equal(404); }); @@ -97,6 +101,7 @@ export default function (providerContext: FtrProviderContext) { path: `/${transform.dest}`, }, { + meta: true, ignore: [404], } ); diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts index eeb6f7e5670b2..2d097a327b52e 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts @@ -171,6 +171,7 @@ export default function (providerContext: FtrProviderContext) { }, { ignore: [404], + meta: true, } ); expect(res.statusCode).equal(404); From dcb0acc7bc6801424d05d5d0505ccace4bff67bf Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Mon, 18 Oct 2021 14:20:23 +0200 Subject: [PATCH 073/172] REMOVE me. pin transport version temporarily. --- package.json | 3 ++- yarn.lock | 20 ++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index e1d40e5173e9c..e494331fdc2ed 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ }, "resolutions": { "**/@types/node": "16.10.2", + "**/@elastic/transport": "^0.0.9", "**/chokidar": "^3.4.3", "**/deepmerge": "^4.2.2", "**/fast-deep-equal": "^3.1.1", @@ -111,7 +112,7 @@ "@elastic/request-crypto": "1.1.4", "@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set", "@elastic/search-ui-app-search-connector": "^1.6.0", - "@elastic/transport": "^0.0.7", + "@elastic/transport": "^0.0.9", "@emotion/react": "^11.4.0", "@hapi/accept": "^5.0.2", "@hapi/boom": "^9.1.4", diff --git a/yarn.lock b/yarn.lock index 39089d70a6be7..76f89fde24f2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2571,22 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.7": - version "0.0.7" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.7.tgz#abc636b18c231dba457f188f62a4df432c543cdc" - integrity sha512-apSD9aY6jVBC5lLc3GWmgrcjXl2StAR/AQYW8bnZ0mGTqkkLGpx4Ojnd3yYDvD1JxMosbs6lpTA60dLF2vtSHQ== - dependencies: - debug "^4.3.2" - hpagent "^0.1.2" - ms "^2.1.3" - secure-json-parse "^2.4.0" - tslib "^2.3.0" - undici "^4.7.0" - -"@elastic/transport@^0.0.7": - version "0.0.7" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.7.tgz#abc636b18c231dba457f188f62a4df432c543cdc" - integrity sha512-apSD9aY6jVBC5lLc3GWmgrcjXl2StAR/AQYW8bnZ0mGTqkkLGpx4Ojnd3yYDvD1JxMosbs6lpTA60dLF2vtSHQ== +"@elastic/transport@^0.0.7", "@elastic/transport@^0.0.9": + version "0.0.9" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.9.tgz#608e13fad75eb9d92d80171aeb92aea0351f70c1" + integrity sha512-HgW/nBtwpXpj5RIjhxg03Yd2S5fPYOtjcsXUYW1Yo85Z5pgNDq+lujU6m6CAJBGgrUghtFvkoGzP0vBSpU1weQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From 5226feb7b2b28ed08151a9aae579c4032695e954 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Mon, 18 Oct 2021 14:21:25 +0200 Subject: [PATCH 074/172] remove deep imports from transport package --- src/core/server/elasticsearch/client/configure_client.ts | 2 +- x-pack/plugins/apm/scripts/shared/get_es_client.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index 4a4128d220b9a..4fb9f532d9077 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -15,7 +15,7 @@ import type { TransportResult, DiagnosticResult, } from '@elastic/elasticsearch'; -import type { RequestBody } from '@elastic/transport/lib/types'; +import type { RequestBody } from '@elastic/transport'; import { Transport, HttpConnection } from '@elastic/transport'; import { Logger } from '../../logging'; import { parseClientOptions, ElasticsearchClientConfig } from './client_config'; diff --git a/x-pack/plugins/apm/scripts/shared/get_es_client.ts b/x-pack/plugins/apm/scripts/shared/get_es_client.ts index 671997c632452..c260ba0650d2a 100644 --- a/x-pack/plugins/apm/scripts/shared/get_es_client.ts +++ b/x-pack/plugins/apm/scripts/shared/get_es_client.ts @@ -6,7 +6,7 @@ */ import { Client } from '@elastic/elasticsearch'; -import type { ApiKeyAuth, BasicAuth } from '@elastic/transport/lib/types'; +import type { ClientOptions } from '@elastic/elasticsearch/lib/client'; import { ESSearchResponse, ESSearchRequest, @@ -19,7 +19,7 @@ export function getEsClient({ auth, }: { node: string; - auth?: BasicAuth | ApiKeyAuth; + auth?: ClientOptions['auth']; // TODO ask owners to fix }): any { const client = new Client({ From a4edd38d47e53f2891ccaec50bea7a9117a1b6cb Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Mon, 18 Oct 2021 14:41:27 +0200 Subject: [PATCH 075/172] fix jest crash --- src/core/server/elasticsearch/client/mocks.ts | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index f27bfa9fad38b..072c7c7a82fc9 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -9,30 +9,28 @@ import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { TransportResult } from '@elastic/transport'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; +import type { PublicKeys } from '@kbn/utility-types'; import { ElasticsearchClient } from './types'; import { ICustomClusterClient } from './cluster_client'; import { PRODUCT_RESPONSE_HEADER } from '../supported_server_response_check'; +const omittedProps = [ + 'diagnostic', + 'name', + 'connectionPool', + 'transport', + 'serializer', + 'helpers', +] as Array>; + // use jest.requireActual() to prevent weird errors when people mock @elastic/elasticsearch const { Client: UnmockedClient } = jest.requireActual('@elastic/elasticsearch'); const createInternalClientMock = (res?: Promise): DeeplyMockedKeys => { // we mimic 'reflection' on a concrete instance of the client to generate the mocked functions. const client = new UnmockedClient({ - node: 'http://localhost', + node: 'http://127.0.0.1', }); - const omittedProps = [ - '_events', - '_eventsCount', - '_maxListeners', - 'constructor', - 'name', - 'serializer', - 'connectionPool', - 'transport', - 'helpers', - ]; - const getAllPropertyDescriptors = (obj: Record) => { const descriptors = Object.entries(Object.getOwnPropertyDescriptors(obj)); let prototype = Object.getPrototypeOf(obj); From 957a56bdb125b2c23157f37594f94e1bb6b21bd6 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Mon, 18 Oct 2021 14:42:31 +0200 Subject: [PATCH 076/172] fix product check tests --- .../server/elasticsearch/client/configure_client.test.ts | 6 +++--- .../interactive_setup/server/elasticsearch_service.test.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index 648557cfffeae..f75db77776316 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -74,7 +74,7 @@ const createApiResponse = ({ function getProductCheckValue(client: Client) { const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter( (symbol) => symbol.description === 'product check' - )[0]; + )[1]; // @ts-expect-error `tSymbol` is missing in the index signature of Transport return (client.transport || client)[tSymbol]; } @@ -130,9 +130,9 @@ describe('configureClient', () => { }); describe('Product check', () => { - it('should not skip the product check for the unscoped client', () => { + it('performs the product check for the unscoped client', () => { const client = configureClient(config, { logger, type: 'test', scoped: false }); - expect(getProductCheckValue(client)).toBe(0); + expect(getProductCheckValue(client)).toBeFalsy(); }); it('should skip the product check for the scoped client', () => { diff --git a/src/plugins/interactive_setup/server/elasticsearch_service.test.ts b/src/plugins/interactive_setup/server/elasticsearch_service.test.ts index e0d96e68ce42b..93870578d8cc4 100644 --- a/src/plugins/interactive_setup/server/elasticsearch_service.test.ts +++ b/src/plugins/interactive_setup/server/elasticsearch_service.test.ts @@ -540,7 +540,7 @@ some weird+ca/with it('fails if host is not supported', async () => { mockPingClient.asInternalUser.ping.mockRejectedValue( // @ts-expect-error not full interface - new errors.ProductNotSupportedError('product-name', { body: {} }) + new errors.ProductNotSupportedError('Elasticsearch', { body: {} }) ); await expect(setupContract.ping('http://localhost:9200')).rejects.toMatchInlineSnapshot( From 189af1a375d1672a4a123466ea1d774af83bb1b9 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Mon, 18 Oct 2021 14:46:50 +0200 Subject: [PATCH 077/172] remove unnecessary ts-expect-error --- .../rule_registry/server/rule_data_client/rule_data_client.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts index 35f0379203496..ba92e9aac3d27 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_client/rule_data_client.ts @@ -179,7 +179,6 @@ export class RuleDataClient implements IRuleDataClient { return clusterClient.bulk(requestWithDefaultParameters).then((response) => { if (response.body.errors) { - // @ts-expect-error @elastic/elasticsearch Context falls back to Record mistakenly const error = new errors.ResponseError(response); throw error; } From 7c4a3135becbbc4de7d6144bf1863e044498d8df Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Mon, 18 Oct 2021 14:47:21 +0200 Subject: [PATCH 078/172] fix a few failed unit tests --- .../event_log/server/es/cluster_client_adapter.test.ts | 4 +--- .../server/lib/reindexing/reindex_service.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts index c01e5196df8a0..314a6b9a31ef8 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts @@ -400,9 +400,7 @@ describe('setIndexToHidden', () => { expect(clusterClient.indices.putSettings).toHaveBeenCalledWith({ index: 'foo-bar-000001', body: { - settings: { - 'index.hidden': true, - }, + 'index.hidden': true, }, }); }); diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts index f42449340fd6e..e50c9ed0f9ae9 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts @@ -793,7 +793,7 @@ describe('reindexService', () => { expect(updatedOp.attributes.lastCompletedStep).toEqual(ReindexStep.readonly); expect(clusterClient.asCurrentUser.indices.putSettings).toHaveBeenCalledWith({ index: 'myIndex', - body: { settings: { blocks: { write: true } } }, + body: { blocks: { write: true } }, }); }); @@ -885,7 +885,7 @@ describe('reindexService', () => { // Original index should have been set back to allow reads. expect(clusterClient.asCurrentUser.indices.putSettings).toHaveBeenCalledWith({ index: 'myIndex', - body: { settings: { blocks: { write: false } } }, + body: { blocks: { write: false } }, }); }); }); From b356775a00c3381cbf541cb93a879a2ee0d121ad Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Mon, 18 Oct 2021 17:39:33 +0200 Subject: [PATCH 079/172] bump to canary 24 --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e494331fdc2ed..114c854cf4f62 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "37.0.0", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.23", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.24", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.0.0", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 76f89fde24f2a..d409ab4290bbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.23": - version "8.0.0-canary.23" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.23.tgz#25ae3e08e102dfd6f7cbf08238e8feac68d56f62" - integrity sha512-45CB7L7pGU2UvSck9YoGoiaXPnF9sUyXSO1dpwwWSUAXSW5v4zcAhvLLjxL/mAzQIvHtY3w+P2JuYwxJf3OqMw== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.24": + version "8.0.0-canary.24" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.24.tgz#a87c79b8e08d63882c9711220bc99cdec69115bc" + integrity sha512-SsTooVXwuLIvMuj3QU8JxbXkHT8c30pilIwzpRBMVpeO0WeYS5BZb9DPgXBt3h91oqDToOstZjGoJXQPRWGpKw== dependencies: - "@elastic/transport" "^0.0.7" + "@elastic/transport" "^0.0.9" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,7 +2571,7 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.7", "@elastic/transport@^0.0.9": +"@elastic/transport@^0.0.9": version "0.0.9" resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.9.tgz#608e13fad75eb9d92d80171aeb92aea0351f70c1" integrity sha512-HgW/nBtwpXpj5RIjhxg03Yd2S5fPYOtjcsXUYW1Yo85Z5pgNDq+lujU6m6CAJBGgrUghtFvkoGzP0vBSpU1weQ== From 7571003b552b727de0e965e64c45673a5c287de6 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 18 Oct 2021 17:39:55 +0200 Subject: [PATCH 080/172] remove unnecessary ts-expect-error --- src/core/server/saved_objects/migrations/core/elastic_index.ts | 1 - .../saved_objects/migrationsv2/actions/update_aliases.ts | 1 - .../lib/extract_bulk_response_delete_failures.ts | 2 +- x-pack/plugins/event_log/server/es/cluster_client_adapter.ts | 1 - x-pack/plugins/fleet/server/services/agents/crud.ts | 2 +- .../server/services/log_entries/log_entries_search_strategy.ts | 1 - .../server/services/log_entries/log_entry_search_strategy.ts | 1 - .../infra/server/services/log_entries/queries/log_entries.ts | 1 - .../infra/server/services/log_entries/queries/log_entry.ts | 1 - x-pack/plugins/security/server/routes/indices/get_fields.ts | 2 +- .../detection_engine/migrations/replace_signals_index_alias.ts | 2 -- .../security_solution/factory/network/http/index.ts | 1 - .../upgrade_assistant/server/lib/reindexing/reindex_service.ts | 3 --- x-pack/test/functional/services/ml/test_resources.ts | 2 -- 14 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/core/server/saved_objects/migrations/core/elastic_index.ts b/src/core/server/saved_objects/migrations/core/elastic_index.ts index 7897adefaf100..6b70d7ccdb2f2 100644 --- a/src/core/server/saved_objects/migrations/core/elastic_index.ts +++ b/src/core/server/saved_objects/migrations/core/elastic_index.ts @@ -323,7 +323,6 @@ export async function claimAlias( await client.indices.updateAliases({ body: { - // @ts-expect-error @elastic/elasticsearch IndicesUpdateAliasesRequest cannot be used actions: aliasActions.concat(removeActions).concat({ add: { index, alias } }), }, }); diff --git a/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts b/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts index a157ae2cab87a..f76d30ae023db 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/update_aliases.ts @@ -52,7 +52,6 @@ export const updateAliases = .updateAliases( { body: { - // @ts-expect-error @elastic/elasticsearch IndicesUpdateAliasesRequest cannot be used actions: aliasActions, }, }, diff --git a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts index bf2d8a453e772..c3b4866f199d3 100644 --- a/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts +++ b/x-pack/plugins/actions/server/cleanup_failed_executions/lib/extract_bulk_response_delete_failures.ts @@ -8,7 +8,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { TransportResult } from '@elastic/elasticsearch'; -type ResponseFailures = Array>; +type ResponseFailures = Array>; export function extractBulkResponseDeleteFailures( response: TransportResult diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts index 55bdb5a16f8c0..7246e1ed972ec 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts @@ -288,7 +288,6 @@ export class ClusterClientAdapter { const existingAliasOptions = pick(currentAliases.aliases[aliasName], [ 'is_write_index', diff --git a/x-pack/plugins/fleet/server/services/agents/crud.ts b/x-pack/plugins/fleet/server/services/agents/crud.ts index 39d4833fbc341..d0ec4bd9cb540 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud.ts @@ -315,7 +315,7 @@ export async function bulkUpdateAgents( }); return { - items: res.body.items.map((item: estypes.BulkResponseItemContainer) => ({ + items: res.body.items.map((item) => ({ id: item.update!._id as string, success: !item.update!.error, error: item.update!.error as Error, diff --git a/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.ts b/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.ts index 651758d9cd976..b401b68d0e3d3 100644 --- a/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.ts +++ b/x-pack/plugins/infra/server/services/log_entries/log_entries_search_strategy.ts @@ -113,7 +113,6 @@ export const logEntriesSearchStrategyProvider = ({ messageFormattingRules, ]): IEsSearchRequest => { return { - // @ts-expect-error @elastic/elasticsearch declares indices_boost as Record params: createGetLogEntriesQuery( indices, params.startTimestamp, diff --git a/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.ts b/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.ts index 1f0f13eeb6ca9..565318578f990 100644 --- a/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.ts +++ b/x-pack/plugins/infra/server/services/log_entries/log_entry_search_strategy.ts @@ -84,7 +84,6 @@ export const logEntrySearchStrategyProvider = ({ tiebreakerField, runtimeMappings, }): IEsSearchRequest => ({ - // @ts-expect-error `Field` is not assignable to `SearchRequest.docvalue_fields` params: createGetLogEntryQuery( indices, params.logEntryId, diff --git a/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts b/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts index 534aac61c5220..6ca6d5ecd0191 100644 --- a/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts +++ b/x-pack/plugins/infra/server/services/log_entries/queries/log_entries.ts @@ -38,7 +38,6 @@ export const createGetLogEntriesQuery = ( return { index: logEntriesIndex, - // @ts-expect-error AsyncSearchSubmitRequest expects allow_no_indices in body allow_no_indices: true, track_scores: false, track_total_hits: false, diff --git a/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts b/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts index 972305af37502..856f8b1af9770 100644 --- a/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts +++ b/x-pack/plugins/infra/server/services/log_entries/queries/log_entry.ts @@ -21,7 +21,6 @@ export const createGetLogEntryQuery = ( runtimeMappings?: estypes.MappingRuntimeFields ): estypes.AsyncSearchSubmitRequest => ({ index: logEntryIndex, - // @ts-expect-error AsyncSearchSubmitRequest expects terminate_after in body terminate_after: 1, track_scores: false, track_total_hits: false, diff --git a/x-pack/plugins/security/server/routes/indices/get_fields.ts b/x-pack/plugins/security/server/routes/indices/get_fields.ts index c3d13bc1f11e7..d6c7778d9ccbf 100644 --- a/x-pack/plugins/security/server/routes/indices/get_fields.ts +++ b/x-pack/plugins/security/server/routes/indices/get_fields.ts @@ -39,7 +39,7 @@ export function defineGetFieldsRoutes({ router }: RouteDefinitionParams) { const mappingValues = Object.values( // `FieldMapping` type from `TypeFieldMappings` --> `GetFieldMappingResponse` is not correct and // doesn't have any properties. - indexMapping.mappings[fieldName].mapping as Record + indexMapping.mappings[fieldName]?.mapping as Record ); const hasMapping = mappingValues.length > 0; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts index 38d8c6f5ded81..911160da01030 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/replace_signals_index_alias.ts @@ -35,9 +35,7 @@ export const replaceSignalsIndexAlias = async ({ await esClient.indices.updateAliases({ body: { actions: [ - // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { remove: { index: oldIndex, alias } }, - // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { add: { index: newIndex, alias, is_write_index: false } }, ], }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts index 6a36e113b62a7..259b45f436124 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/index.ts @@ -24,7 +24,6 @@ import { getHttpEdges } from './helpers'; import { buildHttpQuery } from './query.http_network.dsl'; export const networkHttp: SecuritySolutionFactory = { - // @ts-expect-error dns_name_query_count is not conpatible with @elastic/elasticsearch buildDsl: (options: NetworkHttpRequestOptions) => { if (options.pagination && options.pagination.querySize >= DEFAULT_MAX_TABLE_QUERY_SIZE) { throw new Error(`No query size above ${DEFAULT_MAX_TABLE_QUERY_SIZE}`); diff --git a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts index 106961e1b6b30..77b5495bd4563 100644 --- a/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts +++ b/x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts @@ -456,11 +456,8 @@ export const reindexServiceFactory = ( const { body: aliasResponse } = await esClient.indices.updateAliases({ body: { actions: [ - // @ts-expect-error @elastic/elasticseach IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { add: { index: newIndexName, alias: indexName } }, - // @ts-expect-error @elastic/elasticseach IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid { remove_index: { index: indexName } }, - // @ts-expect-error @elastic/elasticseach IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid ...extraAliases, ], }, diff --git a/x-pack/test/functional/services/ml/test_resources.ts b/x-pack/test/functional/services/ml/test_resources.ts index feabc0f4ed899..f1b2ef97e4e0d 100644 --- a/x-pack/test/functional/services/ml/test_resources.ts +++ b/x-pack/test/functional/services/ml/test_resources.ts @@ -225,7 +225,6 @@ export function MachineLearningTestResourcesProvider({ getService }: FtrProvider // Points the read/write aliases for annotations to the broken annotations index // so we can run tests against a state where annotation endpoints return errors. - // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid await es.indices.updateAliases({ body: { actions: [ @@ -253,7 +252,6 @@ export function MachineLearningTestResourcesProvider({ getService }: FtrProvider async restoreAnnotationsIndexState() { // restore the original working state of pointing read/write aliases // to the right annotations index. - // @ts-expect-error IndicesUpdateAliasesIndicesUpdateAliasBulk is not valid await es.indices.updateAliases({ body: { actions: [ From f46d7587fe2f718bf7a0fa0d4b35a8ebbf694830 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 18 Oct 2021 18:35:53 +0200 Subject: [PATCH 081/172] remove dependency on transport --- package.json | 2 -- packages/kbn-test/BUILD.bazel | 2 -- packages/kbn-test/src/es/client_to_kibana_client.ts | 2 +- .../server/elasticsearch/client/configure_client.test.ts | 2 +- src/core/server/elasticsearch/client/configure_client.ts | 6 +++--- src/core/server/elasticsearch/client/mocks.ts | 2 +- src/plugins/interactive_setup/server/mocks.ts | 2 +- x-pack/plugins/fleet/server/services/artifacts/mocks.ts | 2 +- x-pack/plugins/security/server/mocks.ts | 2 +- .../common/search_strategy/eql/validation/helpers.mock.ts | 2 +- .../public/common/hooks/eql/eql_search_response.mock.ts | 2 +- .../server/endpoint/routes/actions/mocks.ts | 2 +- .../server/alert_types/geo_containment/es_query_builder.ts | 2 +- .../common/search_strategy/eql/validation/helpers.mock.ts | 2 +- 14 files changed, 14 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 114c854cf4f62..4d0112d202079 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,6 @@ }, "resolutions": { "**/@types/node": "16.10.2", - "**/@elastic/transport": "^0.0.9", "**/chokidar": "^3.4.3", "**/deepmerge": "^4.2.2", "**/fast-deep-equal": "^3.1.1", @@ -112,7 +111,6 @@ "@elastic/request-crypto": "1.1.4", "@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set", "@elastic/search-ui-app-search-connector": "^1.6.0", - "@elastic/transport": "^0.0.9", "@emotion/react": "^11.4.0", "@hapi/accept": "^5.0.2", "@hapi/boom": "^9.1.4", diff --git a/packages/kbn-test/BUILD.bazel b/packages/kbn-test/BUILD.bazel index bb86299d3d306..efaf01f7137d9 100644 --- a/packages/kbn-test/BUILD.bazel +++ b/packages/kbn-test/BUILD.bazel @@ -41,7 +41,6 @@ RUNTIME_DEPS = [ "//packages/kbn-std", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", - "@npm//@elastic/transport", "@npm//axios", "@npm//@babel/traverse", "@npm//chance", @@ -77,7 +76,6 @@ TYPES_DEPS = [ "//packages/kbn-i18n", "//packages/kbn-utils", "@npm//@elastic/elasticsearch", - "@npm//@elastic/transport", "@npm//del", "@npm//form-data", "@npm//jest", diff --git a/packages/kbn-test/src/es/client_to_kibana_client.ts b/packages/kbn-test/src/es/client_to_kibana_client.ts index e01c524c6294d..57c492f09c20f 100644 --- a/packages/kbn-test/src/es/client_to_kibana_client.ts +++ b/packages/kbn-test/src/es/client_to_kibana_client.ts @@ -12,7 +12,7 @@ import type { TransportRequestOptions, TransportResult, } from '@elastic/elasticsearch'; -import { Transport } from '@elastic/transport'; +import { Transport } from '@elastic/elasticsearch'; class KibanaTransport extends Transport { request(params: TransportRequestParams, options?: TransportRequestOptions) { diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index f75db77776316..0f13eeb31e8ca 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -15,8 +15,8 @@ import type { TransportRequestOptions, TransportRequestParams, DiagnosticResult, + RequestBody, } from '@elastic/elasticsearch'; -import type { RequestBody } from '@elastic/transport/lib/types'; import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks'; import { loggingSystemMock } from '../../logging/logging_system.mock'; diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index 4fb9f532d9077..261baf1bc77ef 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -8,15 +8,15 @@ import { Buffer } from 'buffer'; import { stringify } from 'querystring'; -import { Client, errors } from '@elastic/elasticsearch'; +import { Client, errors, Transport, HttpConnection } from '@elastic/elasticsearch'; import type { TransportRequestParams, TransportRequestOptions, TransportResult, DiagnosticResult, + RequestBody, } from '@elastic/elasticsearch'; -import type { RequestBody } from '@elastic/transport'; -import { Transport, HttpConnection } from '@elastic/transport'; + import { Logger } from '../../logging'; import { parseClientOptions, ElasticsearchClientConfig } from './client_config'; import type { ElasticsearchErrorDetails } from './types'; diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index 072c7c7a82fc9..18ef6a712f9c0 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -7,7 +7,7 @@ */ import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import type { PublicKeys } from '@kbn/utility-types'; import { ElasticsearchClient } from './types'; diff --git a/src/plugins/interactive_setup/server/mocks.ts b/src/plugins/interactive_setup/server/mocks.ts index 8800572d91669..eb531e35f8dff 100644 --- a/src/plugins/interactive_setup/server/mocks.ts +++ b/src/plugins/interactive_setup/server/mocks.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; function createApiResponseMock( apiResponse: Pick, 'body'> & diff --git a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts index b739246c758b9..bc22bff0b29d0 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/mocks.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/mocks.ts @@ -6,7 +6,7 @@ */ import { URL } from 'url'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { errors } from '@elastic/elasticsearch'; import { elasticsearchServiceMock } from '../../../../../../src/core/server/mocks'; diff --git a/x-pack/plugins/security/server/mocks.ts b/x-pack/plugins/security/server/mocks.ts index 6496817d8284d..491d6cdafa44d 100644 --- a/x-pack/plugins/security/server/mocks.ts +++ b/x-pack/plugins/security/server/mocks.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { licenseMock } from '../common/licensing/index.mock'; import type { MockAuthenticatedUserProps } from '../common/model/authenticated_user.mock'; diff --git a/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts b/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts index 0a3f3921ba346..0c620fbdd348d 100644 --- a/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts +++ b/x-pack/plugins/security_solution/common/search_strategy/eql/validation/helpers.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { ErrorResponse } from './helpers'; export const getValidEqlResponse = (): TransportResult['body'] => ({ diff --git a/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts b/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts index 380e4da6601e2..107a691b6dbeb 100644 --- a/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts +++ b/x-pack/plugins/security_solution/public/common/hooks/eql/eql_search_response.mock.ts @@ -8,7 +8,7 @@ import { EqlSearchStrategyResponse } from '../../../../../../../src/plugins/data/common'; import { Source } from './types'; import { EqlSearchResponse } from '../../../../common/detection_engine/types'; -import { Connection } from '@elastic/transport/lib/connection'; +import type { Connection } from '@elastic/elasticsearch'; export const getMockEqlResponse = (): EqlSearchStrategyResponse> => ({ id: 'some-id', diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts b/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts index ec4db41b4d6c9..5f9c55275477e 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/actions/mocks.ts @@ -9,7 +9,7 @@ /* eslint-disable max-classes-per-file */ /* eslint-disable @typescript-eslint/no-useless-constructor */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import moment from 'moment'; import uuid from 'uuid'; import { diff --git a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts index 8f0026839fda6..7efce1153c915 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/geo_containment/es_query_builder.ts @@ -8,7 +8,7 @@ import { ElasticsearchClient } from 'kibana/server'; import { Logger } from 'src/core/server'; import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { fromKueryExpression, toElasticsearchQuery, diff --git a/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts b/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts index 0a3f3921ba346..0c620fbdd348d 100644 --- a/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts +++ b/x-pack/plugins/timelines/common/search_strategy/eql/validation/helpers.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { TransportResult } from '@elastic/transport'; +import type { TransportResult } from '@elastic/elasticsearch'; import { ErrorResponse } from './helpers'; export const getValidEqlResponse = (): TransportResult['body'] => ({ From 692f8d4968e72cf82e3dcae819923f599a09119b Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 18 Oct 2021 19:59:46 +0200 Subject: [PATCH 082/172] fix types in tests --- x-pack/test/accessibility/apps/helpers.ts | 39 +++--- .../apps/ingest_node_pipelines.ts | 4 +- .../common/lib/es_test_index_tool.ts | 89 +++++++------- .../common/lib/task_manager_utils.ts | 32 ++--- .../actions/builtin_action_types/es_index.ts | 10 +- .../es_index_preconfigured.ts | 10 +- .../actions/builtin_action_types/es_index.ts | 8 +- .../spaces_only/tests/actions/execute.ts | 9 +- .../es_query/create_test_data.ts | 8 +- .../index_threshold/create_test_data.ts | 13 +- .../apis/epm/install_remove_assets.ts | 116 +++++++++++------- 11 files changed, 195 insertions(+), 143 deletions(-) diff --git a/x-pack/test/accessibility/apps/helpers.ts b/x-pack/test/accessibility/apps/helpers.ts index 18e3a51a2d268..790a3a089624d 100644 --- a/x-pack/test/accessibility/apps/helpers.ts +++ b/x-pack/test/accessibility/apps/helpers.ts @@ -4,35 +4,38 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import { asyncForEach } from '@kbn/std'; // This function clears all pipelines to ensure that there in an empty state before starting each test. -export async function deleteAllPipelines(client: any, logger: any) { +export async function deleteAllPipelines(client: Client, logger: any) { const pipelines = await client.ingest.getPipeline(); - const pipeLineIds = Object.keys(pipelines.body); + const pipeLineIds = Object.keys(pipelines); await logger.debug(pipelines); if (pipeLineIds.length > 0) { - await asyncForEach(pipeLineIds, async (newId: any) => { + await asyncForEach(pipeLineIds, async (newId) => { await client.ingest.deletePipeline({ id: newId }); }); } } -export async function putSamplePipeline(client: any) { - return await client.ingest.putPipeline({ - id: 'testPipeline', - body: { - description: 'describe pipeline', - version: 123, - processors: [ - { - set: { - field: 'foo', - value: 'bar', +export async function putSamplePipeline(client: Client) { + return await client.ingest.putPipeline( + { + id: 'testPipeline', + body: { + description: 'describe pipeline', + version: 123, + processors: [ + { + set: { + field: 'foo', + value: 'bar', + }, }, - }, - ], + ], + }, }, - }); + { meta: true } + ); } diff --git a/x-pack/test/accessibility/apps/ingest_node_pipelines.ts b/x-pack/test/accessibility/apps/ingest_node_pipelines.ts index dab9c86bf018e..9e92446fe4b5e 100644 --- a/x-pack/test/accessibility/apps/ingest_node_pipelines.ts +++ b/x-pack/test/accessibility/apps/ingest_node_pipelines.ts @@ -4,13 +4,13 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import { deleteAllPipelines, putSamplePipeline } from './helpers'; export default function ({ getService, getPageObjects }: any) { const { common } = getPageObjects(['common']); const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const esClient = getService('es'); + const esClient: Client = getService('es'); const log = getService('log'); const a11y = getService('a11y'); /* this is the wrapping service around axe */ diff --git a/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts b/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts index 47fae2a249efe..c880ce945042f 100644 --- a/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts +++ b/x-pack/test/alerting_api_integration/common/lib/es_test_index_tool.ts @@ -4,64 +4,67 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; export const ES_TEST_INDEX_NAME = '.kibana-alerting-test-data'; export class ESTestIndexTool { constructor( - private readonly es: any, + private readonly es: Client, private readonly retry: any, private readonly index: string = ES_TEST_INDEX_NAME ) {} async setup() { - return await this.es.indices.create({ - index: this.index, - body: { - mappings: { - properties: { - source: { - type: 'keyword', - }, - reference: { - type: 'keyword', - }, - params: { - enabled: false, - type: 'object', - }, - config: { - enabled: false, - type: 'object', - }, - state: { - enabled: false, - type: 'object', - }, - date: { - type: 'date', - format: 'strict_date_time', - }, - date_epoch_millis: { - type: 'date', - format: 'epoch_millis', - }, - testedValue: { - type: 'long', - }, - group: { - type: 'keyword', + return await this.es.indices.create( + { + index: this.index, + body: { + mappings: { + properties: { + source: { + type: 'keyword', + }, + reference: { + type: 'keyword', + }, + params: { + enabled: false, + type: 'object', + }, + config: { + enabled: false, + type: 'object', + }, + state: { + enabled: false, + type: 'object', + }, + date: { + type: 'date', + format: 'strict_date_time', + }, + date_epoch_millis: { + type: 'date', + format: 'epoch_millis', + }, + testedValue: { + type: 'long', + }, + group: { + type: 'keyword', + }, }, }, }, }, - }); + { meta: true } + ); } async destroy() { - const indexExists = (await this.es.indices.exists({ index: this.index })).body; + const indexExists = await this.es.indices.exists({ index: this.index }); if (indexExists) { - return await this.es.indices.delete({ index: this.index }); + return await this.es.indices.delete({ index: this.index }, { meta: true }); } } @@ -97,13 +100,15 @@ export class ESTestIndexTool { size: 1000, body, }; - return await this.es.search(params); + return await this.es.search(params, { meta: true }); } async waitForDocs(source: string, reference: string, numDocs: number = 1) { return await this.retry.try(async () => { const searchResult = await this.search(source, reference); + // @ts-expect-error doesn't handle total: number if (searchResult.body.hits.total.value < numDocs) { + // @ts-expect-error doesn't handle total: number throw new Error(`Expected ${numDocs} but received ${searchResult.body.hits.total.value}.`); } return searchResult.body.hits.hits; diff --git a/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts b/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts index 57af1b1bcb035..275f29acf2e04 100644 --- a/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts +++ b/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import { SerializedConcreteTaskInstance } from '../../../../plugins/task_manager/server/task'; export interface TaskManagerDoc { @@ -12,10 +12,10 @@ export interface TaskManagerDoc { task: SerializedConcreteTaskInstance; } export class TaskManagerUtils { - private readonly es: any; + private readonly es: Client; private readonly retry: any; - constructor(es: any, retry: any) { + constructor(es: Client, retry: any) { this.es = es; this.retry = retry; } @@ -36,7 +36,7 @@ export class TaskManagerUtils { { range: { 'task.scheduledAt': { - gte: taskRunAtFilter, + gte: taskRunAtFilter.toString(), }, }, }, @@ -45,8 +45,10 @@ export class TaskManagerUtils { }, }, }); - if (searchResult.body.hits.total.value) { - throw new Error(`Expected 0 tasks but received ${searchResult.body.hits.total.value}`); + // @ts-expect-error + if (searchResult.hits.total.value) { + // @ts-expect-error + throw new Error(`Expected 0 tasks but received ${searchResult.hits.total.value}`); } }); } @@ -67,7 +69,7 @@ export class TaskManagerUtils { { range: { 'task.scheduledAt': { - gte: taskRunAtFilter, + gte: taskRunAtFilter.toString(), }, }, }, @@ -83,10 +85,10 @@ export class TaskManagerUtils { }, }, }); - if (searchResult.body.hits.total.value) { - throw new Error( - `Expected 0 non-idle tasks but received ${searchResult.body.hits.total.value}` - ); + // @ts-expect-error + if (searchResult.hits.total.value) { + // @ts-expect-error + throw new Error(`Expected 0 non-idle tasks but received ${searchResult.hits.total.value}`); } }); } @@ -107,7 +109,7 @@ export class TaskManagerUtils { { range: { updated_at: { - gte: createdAtFilter, + gte: createdAtFilter.toString(), }, }, }, @@ -116,9 +118,11 @@ export class TaskManagerUtils { }, }, }); - if (searchResult.body.hits.total.value) { + // @ts-expect-error + if (searchResult.hits.total.value) { throw new Error( - `Expected 0 action_task_params objects but received ${searchResult.body.hits.total.value}` + // @ts-expect-error + `Expected 0 action_task_params objects but received ${searchResult.hits.total.value}` ); } }); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index.ts index 3db58cb2adc3d..fc40d036f925a 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; @@ -13,7 +13,7 @@ const ES_TEST_INDEX_NAME = 'functional-test-actions-index'; // eslint-disable-next-line import/no-default-export export default function indexTest({ getService }: FtrProviderContext) { - const es = getService('es'); + const es: Client = getService('es'); const supertest = getService('supertest'); const esDeleteAllIndices = getService('esDeleteAllIndices'); @@ -189,7 +189,7 @@ export default function indexTest({ getService }: FtrProviderContext) { .expect(200); expect(result.status).to.eql('ok'); - const items = await getTestIndexItems(es); + const items: any[] = await getTestIndexItems(es); expect(items.length).to.eql(2); let passed1 = false; let passed2 = false; @@ -268,10 +268,10 @@ export default function indexTest({ getService }: FtrProviderContext) { }); } -async function getTestIndexItems(es: any) { +async function getTestIndexItems(es: Client) { const result = await es.search({ index: ES_TEST_INDEX_NAME, }); - return result.body.hits.hits; + return result.hits.hits; } diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index_preconfigured.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index_preconfigured.ts index 92a5d7d840276..caa7d57688037 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index_preconfigured.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/es_index_preconfigured.ts @@ -5,8 +5,8 @@ * 2.0. */ +import type { Client } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; - import { FtrProviderContext } from '../../../../common/ftr_provider_context'; // from: x-pack/test/alerting_api_integration/common/config.ts @@ -15,7 +15,7 @@ const ES_TEST_INDEX_NAME = 'functional-test-actions-index-preconfigured'; // eslint-disable-next-line import/no-default-export export default function indexTest({ getService }: FtrProviderContext) { - const es = getService('es'); + const es: Client = getService('es'); const esDeleteAllIndices = getService('esDeleteAllIndices'); const supertest = getService('supertest'); @@ -38,7 +38,7 @@ export default function indexTest({ getService }: FtrProviderContext) { expect(items.length).to.eql(1); // check document sans timestamp - const document = items[0]._source; + const document: any = items[0]._source; const timestamp = document.timestamp; delete document.timestamp; expect(document).to.eql({ testing: [4, 5, 6] }); @@ -52,10 +52,10 @@ export default function indexTest({ getService }: FtrProviderContext) { }); } -async function getTestIndexItems(es: any) { +async function getTestIndexItems(es: Client) { const result = await es.search({ index: ES_TEST_INDEX_NAME, }); - return result.body.hits.hits; + return result.hits.hits; } diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/es_index.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/es_index.ts index 3f4cef25ff65e..3bc8cec9bf163 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/es_index.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/es_index.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; @@ -13,7 +13,7 @@ const ES_TEST_INDEX_NAME = 'functional-test-actions-index'; // eslint-disable-next-line import/no-default-export export default function indexTest({ getService }: FtrProviderContext) { - const es = getService('es'); + const es: Client = getService('es'); const supertest = getService('supertest'); const esDeleteAllIndices = getService('esDeleteAllIndices'); @@ -144,10 +144,10 @@ export default function indexTest({ getService }: FtrProviderContext) { }); } -async function getTestIndexItems(es: any) { +async function getTestIndexItems(es: Client) { const result = await es.search({ index: ES_TEST_INDEX_NAME, }); - return result.body.hits.hits; + return result.hits.hits; } diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/execute.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/execute.ts index 10da2d852e806..389a4beeb8737 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/execute.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/execute.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; import { @@ -22,7 +22,7 @@ const NANOS_IN_MILLIS = 1000 * 1000; // eslint-disable-next-line import/no-default-export export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - const es = getService('es'); + const es: Client = getService('es'); const retry = getService('retry'); const esTestIndexTool = new ESTestIndexTool(es, retry); @@ -76,6 +76,7 @@ export default function ({ getService }: FtrProviderContext) { expect(response.status).to.eql(200); expect(response.body).to.be.an('object'); const searchResult = await esTestIndexTool.search('action:test.index-record', reference); + // @ts-expect-error doesn't handle total: number expect(searchResult.body.hits.total.value).to.eql(1); const indexedRecord = searchResult.body.hits.hits[0]; expect(indexedRecord._source).to.eql({ @@ -211,15 +212,19 @@ export default function ({ getService }: FtrProviderContext) { expect(response.status).to.eql(200); const searchResult = await esTestIndexTool.search('action:test.authorization', reference); + // @ts-expect-error doesn't handle total: number expect(searchResult.body.hits.total.value).to.eql(1); const indexedRecord = searchResult.body.hits.hits[0]; + // @ts-expect-error _source is not typed expect(indexedRecord._source.state).to.eql({ callClusterSuccess: true, callScopedClusterSuccess: true, savedObjectsClientSuccess: false, savedObjectsClientError: { + // @ts-expect-error _source is not typed ...indexedRecord._source.state.savedObjectsClientError, output: { + // @ts-expect-error _source is not typed ...indexedRecord._source.state.savedObjectsClientError.output, statusCode: 404, }, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/es_query/create_test_data.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/es_query/create_test_data.ts index f3c707c58af1c..73a81904d0cc0 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/es_query/create_test_data.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/es_query/create_test_data.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import { times } from 'lodash'; import { v4 as uuid } from 'uuid'; import { ESTestIndexTool, ES_TEST_INDEX_NAME } from '../../../../../common/lib'; @@ -16,7 +16,7 @@ export const DOCUMENT_SOURCE = 'queryDataEndpointTests'; export const DOCUMENT_REFERENCE = '-na-'; export async function createEsDocuments( - es: any, + es: Client, esTestIndexTool: ESTestIndexTool, endDate: string = END_DATE, intervals: number = 1, @@ -39,7 +39,7 @@ export async function createEsDocuments( await esTestIndexTool.waitForDocs(DOCUMENT_SOURCE, DOCUMENT_REFERENCE, totalDocuments); } -async function createEsDocument(es: any, epochMillis: number, testedValue: number) { +async function createEsDocument(es: Client, epochMillis: number, testedValue: number) { const document = { source: DOCUMENT_SOURCE, reference: DOCUMENT_REFERENCE, @@ -54,7 +54,7 @@ async function createEsDocument(es: any, epochMillis: number, testedValue: numbe body: document, }); - if (response.body.result !== 'created') { + if (response.result !== 'created') { throw new Error(`document not created: ${JSON.stringify(response)}`); } } diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts index b9faadcd3d4b7..ba063044d9233 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/builtin_alert_types/index_threshold/create_test_data.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import { times } from 'lodash'; import { v4 as uuid } from 'uuid'; import { ESTestIndexTool, ES_TEST_INDEX_NAME } from '../../../../../common/lib'; @@ -24,7 +24,7 @@ export const DOCUMENT_REFERENCE = '-na-'; // 2^0 as the value of the last documents, the values increasing for older // documents. export async function createEsDocuments( - es: any, + es: Client, esTestIndexTool: ESTestIndexTool, endDate: string = END_DATE, intervals: number = 1, @@ -49,7 +49,12 @@ export async function createEsDocuments( await esTestIndexTool.waitForDocs(DOCUMENT_SOURCE, DOCUMENT_REFERENCE, totalDocuments); } -async function createEsDocument(es: any, epochMillis: number, testedValue: number, group: string) { +async function createEsDocument( + es: Client, + epochMillis: number, + testedValue: number, + group: string +) { const document = { source: DOCUMENT_SOURCE, reference: DOCUMENT_REFERENCE, @@ -66,7 +71,7 @@ async function createEsDocument(es: any, epochMillis: number, testedValue: numbe }); // console.log(`writing document to ${ES_TEST_INDEX_NAME}:`, JSON.stringify(document, null, 4)); - if (response.body.result !== 'created') { + if (response.result !== 'created') { throw new Error(`document not created: ${JSON.stringify(response)}`); } } diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts index 2d097a327b52e..699b60a14b911 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_remove_assets.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import type { Client } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import { sortBy } from 'lodash'; import { AssetReference } from '../../../../plugins/fleet/common'; @@ -18,7 +18,7 @@ export default function (providerContext: FtrProviderContext) { const supertest = getService('supertest'); const dockerServers = getService('dockerServers'); const server = dockerServers.get('registry'); - const es = getService('es'); + const es: Client = getService('es'); const pkgName = 'all_assets'; const pkgVersion = '0.1.0'; const pkgKey = `${pkgName}-${pkgVersion}`; @@ -346,68 +346,98 @@ const expectAssetsInstalled = ({ metricsTemplateName: string; pkgVersion: string; pkgName: string; - es: any; + es: Client; kibanaServer: any; }) => { it('should have installed the ILM policy', async function () { - const resPolicy = await es.transport.request({ - method: 'GET', - path: `/_ilm/policy/all_assets`, - }); + const resPolicy = await es.transport.request( + { + method: 'GET', + path: `/_ilm/policy/all_assets`, + }, + { meta: true } + ); expect(resPolicy.statusCode).equal(200); }); it('should have installed the index templates', async function () { - const resLogsTemplate = await es.transport.request({ - method: 'GET', - path: `/_index_template/${logsTemplateName}`, - }); + const resLogsTemplate = await es.transport.request( + { + method: 'GET', + path: `/_index_template/${logsTemplateName}`, + }, + { meta: true } + ); expect(resLogsTemplate.statusCode).equal(200); - const resMetricsTemplate = await es.transport.request({ - method: 'GET', - path: `/_index_template/${metricsTemplateName}`, - }); + const resMetricsTemplate = await es.transport.request( + { + method: 'GET', + path: `/_index_template/${metricsTemplateName}`, + }, + { meta: true } + ); expect(resMetricsTemplate.statusCode).equal(200); }); it('should have installed the pipelines', async function () { - const res = await es.transport.request({ - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}`, - }); + const res = await es.transport.request( + { + method: 'GET', + path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}`, + }, + { meta: true } + ); expect(res.statusCode).equal(200); - const resPipeline1 = await es.transport.request({ - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}-pipeline1`, - }); + const resPipeline1 = await es.transport.request( + { + method: 'GET', + path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}-pipeline1`, + }, + { meta: true } + ); expect(resPipeline1.statusCode).equal(200); - const resPipeline2 = await es.transport.request({ - method: 'GET', - path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}-pipeline2`, - }); + const resPipeline2 = await es.transport.request( + { + method: 'GET', + path: `/_ingest/pipeline/${logsTemplateName}-${pkgVersion}-pipeline2`, + }, + { meta: true } + ); expect(resPipeline2.statusCode).equal(200); }); it('should have installed the ml model', async function () { - const res = await es.transport.request({ - method: 'GET', - path: `_ml/trained_models/default`, - }); + const res = await es.transport.request( + { + method: 'GET', + path: `_ml/trained_models/default`, + }, + { meta: true } + ); expect(res.statusCode).equal(200); }); it('should have installed the component templates', async function () { - const resMappings = await es.transport.request({ - method: 'GET', - path: `/_component_template/${logsTemplateName}@mappings`, - }); + const resMappings = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${logsTemplateName}@mappings`, + }, + { meta: true } + ); expect(resMappings.statusCode).equal(200); - const resSettings = await es.transport.request({ - method: 'GET', - path: `/_component_template/${logsTemplateName}@settings`, - }); + const resSettings = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${logsTemplateName}@settings`, + }, + { meta: true } + ); expect(resSettings.statusCode).equal(200); - const resUserSettings = await es.transport.request({ - method: 'GET', - path: `/_component_template/${logsTemplateName}@custom`, - }); + const resUserSettings = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${logsTemplateName}@custom`, + }, + { meta: true } + ); expect(resUserSettings.statusCode).equal(200); }); it('should have installed the kibana assets', async function () { From 55477469369ed6ce4eea6abc5a1f5e22a2992c33 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 09:41:17 +0200 Subject: [PATCH 083/172] mute errors in xpack tests --- .../components/expression_chart.test.tsx | 2 +- .../routes/log_sources/configuration.ts | 4 +-- .../server/routes/metrics_sources/index.ts | 4 +-- .../tests/actions/execute.ts | 2 ++ .../tests/alerting/alerts.ts | 26 +++++++++++++++++-- .../tests/alerting/rbac_legacy.ts | 20 +++++++++----- .../spaces_only/tests/alerting/alerts_base.ts | 1 + .../spaces_only/tests/alerting/ephemeral.ts | 1 + 8 files changed, 47 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx index 1eacae1feee46..ec97d01a1cd6f 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.test.tsx @@ -54,7 +54,7 @@ describe('ExpressionChart', () => { metricAlias: 'metricbeat-*', inventoryDefaultView: 'host', metricsExplorerDefaultView: 'host', - // @ts-expect-error not full interface + // @ts-ignore fields: { timestamp: '@timestamp', container: 'container.id', diff --git a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts index f954ce7d78939..9a92012c21fe4 100644 --- a/x-pack/plugins/infra/server/routes/log_sources/configuration.ts +++ b/x-pack/plugins/infra/server/routes/log_sources/configuration.ts @@ -85,13 +85,13 @@ export const initLogSourceConfigurationRoutes = ({ framework, sources }: InfraBa ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error incompat interface + // @ts-ignore patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error incompat interface + // @ts-ignore patchedSourceConfigurationProperties )); diff --git a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts index c21520d5d89f3..24ea04e3e14f9 100644 --- a/x-pack/plugins/infra/server/routes/metrics_sources/index.ts +++ b/x-pack/plugins/infra/server/routes/metrics_sources/index.ts @@ -88,13 +88,13 @@ export const initMetricsSourceConfigurationRoutes = (libs: InfraBackendLibs) => ? sources.updateSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error incompat interface + // @ts-ignore patchedSourceConfigurationProperties ) : sources.createSourceConfiguration( requestContext.core.savedObjects.client, sourceId, - // @ts-expect-error incompat interface + // @ts-ignore patchedSourceConfigurationProperties )); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/execute.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/execute.ts index 9091b96ff335a..913baa2517fbb 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/execute.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/execute.ts @@ -97,6 +97,7 @@ export default function ({ getService }: FtrProviderContext) { 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).to.eql(1); const indexedRecord = searchResult.body.hits.hits[0]; expect(indexedRecord._source).to.eql({ @@ -250,6 +251,7 @@ export default function ({ getService }: FtrProviderContext) { 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).to.eql(1); const indexedRecord = searchResult.body.hits.hits[0]; expect(indexedRecord._source).to.eql({ diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts index 5a12b6882ac23..0de487a064a17 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts @@ -134,9 +134,10 @@ export default function alertTests({ getService }: FtrProviderContext) { 'alert:test.always-firing', reference ); + // @ts-expect-error doesnt handle total: number expect(alertSearchResult.body.hits.total.value).to.eql(1); const alertSearchResultWithoutDates = omit( - alertSearchResult.body.hits.hits[0]._source, + alertSearchResult.body.hits.hits[0]._source as object, ['alertInfo.createdAt', 'alertInfo.updatedAt'] ); expect(alertSearchResultWithoutDates).to.eql({ @@ -177,9 +178,12 @@ export default function alertTests({ getService }: FtrProviderContext) { ruleTypeName: 'Test: Always Firing', }, }); + // @ts-expect-error _source: unknown expect(alertSearchResult.body.hits.hits[0]._source.alertInfo.createdAt).to.match( /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/ ); + + // @ts-expect-error _source: unknown expect(alertSearchResult.body.hits.hits[0]._source.alertInfo.updatedAt).to.match( /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/ ); @@ -189,6 +193,7 @@ export default function alertTests({ getService }: FtrProviderContext) { 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(actionSearchResult.body.hits.total.value).to.eql(1); expect(actionSearchResult.body.hits.hits[0]._source).to.eql({ config: { @@ -281,9 +286,10 @@ instanceStateValue: true 'alert:test.always-firing', reference ); + // @ts-expect-error doesnt handle total: number expect(alertSearchResult.body.hits.total.value).to.eql(1); const alertSearchResultWithoutDates = omit( - alertSearchResult.body.hits.hits[0]._source, + alertSearchResult.body.hits.hits[0]._source as object, ['alertInfo.createdAt', 'alertInfo.updatedAt'] ); expect(alertSearchResultWithoutDates).to.eql({ @@ -325,9 +331,11 @@ instanceStateValue: true }, }); + // @ts-expect-error _source: unknown expect(alertSearchResult.body.hits.hits[0]._source.alertInfo.createdAt).to.match( /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/ ); + // @ts-expect-error _source: unknown expect(alertSearchResult.body.hits.hits[0]._source.alertInfo.updatedAt).to.match( /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/ ); @@ -336,6 +344,7 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(actionSearchResult.body.hits.total.value).to.eql(1); expect(actionSearchResult.body.hits.hits[0]._source).to.eql({ config: { @@ -416,8 +425,10 @@ instanceStateValue: true reference2 ); + // @ts-expect-error doesnt handle total: number expect(alertSearchResult.body.hits.total.value).to.be.greaterThan(0); const alertSearchResultInfoWithoutDates = omit( + // @ts-expect-error _source: unknown alertSearchResult.body.hits.hits[0]._source.alertInfo, ['createdAt', 'updatedAt'] ); @@ -451,9 +462,11 @@ instanceStateValue: true ruleTypeName: 'Test: Always Firing', }); + // @ts-expect-error _source: unknown expect(alertSearchResult.body.hits.hits[0]._source.alertInfo.createdAt).to.match( /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/ ); + // @ts-expect-error _source: unknown expect(alertSearchResult.body.hits.hits[0]._source.alertInfo.updatedAt).to.match( /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/ ); @@ -852,6 +865,7 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).to.eql(1); break; default: @@ -931,8 +945,10 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).to.eql(2); const messages: string[] = searchResult.body.hits.hits.map( + // @ts-expect-error _search: unknown (hit: { _source: { params: { message: string } } }) => hit._source.params.message ); expect(messages.sort()).to.eql(['from:default', 'from:other']); @@ -1005,8 +1021,10 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).to.eql(2); const messages: string[] = searchResult.body.hits.hits.map( + // @ts-expect-error _source: unknown (hit: { _source: { params: { message: string } } }) => hit._source.params.message ); expect(messages.sort()).to.eql(['from:default:next', 'from:default:prev']); @@ -1068,6 +1086,7 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).to.eql(2); break; default: @@ -1126,6 +1145,7 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(executedActionsResult.body.hits.total.value).to.eql(0); break; default: @@ -1184,6 +1204,7 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(executedActionsResult.body.hits.total.value).to.eql(0); break; default: @@ -1243,6 +1264,7 @@ instanceStateValue: true 'action:test.index-record', reference ); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).to.eql(1); break; default: diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts index 17e34973041c0..4aa8447823dca 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy.ts @@ -226,13 +226,19 @@ export default function alertTests({ getService }: FtrProviderContext) { async function ensureAlertIsRunning() { // ensure the alert still runs and that it can schedule actions - const numberOfAlertExecutions = ( - await esTestIndexTool.search('alert:test.always-firing', reference) - ).body.hits.total.value; + const alwaysFiringResponse = await esTestIndexTool.search( + 'alert:test.always-firing', + reference + ); + // @ts-expect-error doesnt handle total: number + const numberOfAlertExecutions = alwaysFiringResponse.body.hits.total.value; - const numberOfActionExecutions = ( - await esTestIndexTool.search('action:test.index-record', reference) - ).body.hits.total.value; + const indexRecordResponse = await esTestIndexTool.search( + 'action:test.index-record', + reference + ); + // @ts-expect-error doesnt handle total: number + const numberOfActionExecutions = indexRecordResponse.body.hits.total.value; // wait for alert to execute and for its action to be scheduled and run await retry.try(async () => { @@ -246,9 +252,11 @@ export default function alertTests({ getService }: FtrProviderContext) { reference ); + // @ts-expect-error doesnt handle total: number expect(alertSearchResult.body.hits.total.value).to.be.greaterThan( numberOfAlertExecutions ); + // @ts-expect-error doesnt handle total: number expect(actionSearchResult.body.hits.total.value).to.be.greaterThan( numberOfActionExecutions ); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts index db2ef523841b2..ea818a6e64b0d 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts @@ -298,6 +298,7 @@ instanceStateValue: true await taskManagerUtils.waitForActionTaskParamsToBeCleanedUp(testStart); const actionTestRecord = await esTestIndexTool.search('action:test.index-record', reference); + // @ts-expect-error doesnt handle total: number expect(actionTestRecord.body.hits.total.value).to.eql(0); objectRemover.add(space.id, alertId, 'rule', 'alerting'); }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts index 99801cf838836..a3b8c75f79e62 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts @@ -117,6 +117,7 @@ export default function createNotifyWhenTests({ getService }: FtrProviderContext ); const searchResult = await esTestIndexTool.search('action:test.index-record'); + // @ts-expect-error doesnt handle total: number expect(searchResult.body.hits.total.value).equal( nonEphemeralTasks + DEFAULT_MAX_EPHEMERAL_ACTIONS_PER_ALERT ); From 5cd6b01a3f4caf209ffe239458471418563d7caf Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Tue, 19 Oct 2021 10:09:57 +0200 Subject: [PATCH 084/172] product check doesn;t spam in logs anymore --- .../client/configure_client.test.ts | 27 ------------------- .../elasticsearch/client/configure_client.ts | 24 ----------------- 2 files changed, 51 deletions(-) diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index 0f13eeb31e8ca..7988e81045d17 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -11,7 +11,6 @@ import { Readable } from 'stream'; import { errors } from '@elastic/elasticsearch'; import type { - Client, TransportRequestOptions, TransportRequestParams, DiagnosticResult, @@ -71,14 +70,6 @@ const createApiResponse = ({ }; }; -function getProductCheckValue(client: Client) { - const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter( - (symbol) => symbol.description === 'product check' - )[1]; - // @ts-expect-error `tSymbol` is missing in the index signature of Transport - return (client.transport || client)[tSymbol]; -} - describe('configureClient', () => { let logger: ReturnType; let config: ElasticsearchClientConfig; @@ -129,24 +120,6 @@ describe('configureClient', () => { expect(client.diagnostic.on).toHaveBeenCalledWith('response', expect.any(Function)); }); - describe('Product check', () => { - it('performs the product check for the unscoped client', () => { - const client = configureClient(config, { logger, type: 'test', scoped: false }); - expect(getProductCheckValue(client)).toBeFalsy(); - }); - - it('should skip the product check for the scoped client', () => { - const client = configureClient(config, { logger, type: 'test', scoped: true }); - expect(getProductCheckValue(client)).toBe(2); - }); - - it('should skip the product check for the children of the scoped client', () => { - const client = configureClient(config, { logger, type: 'test', scoped: true }); - const asScoped = client.child({ headers: { 'x-custom-header': 'Custom value' } }); - expect(getProductCheckValue(asScoped)).toBe(2); - }); - }); - describe('Client logging', () => { function createResponseWithBody(body?: RequestBody) { return createApiResponse({ diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index 261baf1bc77ef..a946a29fde498 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -62,12 +62,6 @@ export const configureClient = ( }); addLogging(client, logger.get('query', type)); - // --------------------------------------------------------------------------------- // - // Hack to disable the "Product check" only in the scoped clients while we // - // come up with a better approach in https://github.com/elastic/kibana/issues/110675 // - if (scoped) skipProductCheck(client); - // --------------------------------------------------------------------------------- // - return client; }; @@ -154,21 +148,3 @@ const addLogging = (client: Client, logger: Logger) => { } }); }; - -/** - * Hack to skip the Product Check performed by the Elasticsearch-js client. - * We noticed that the scoped clients are always performing this check because - * of the way we initialize the clients. We'll discuss changing this in the issue - * https://github.com/elastic/kibana/issues/110675. In the meanwhile, let's skip - * it for the scoped clients. - * - * The hack is copied from the test/utils in the elasticsearch-js repo - * (https://github.com/elastic/elasticsearch-js/blob/master/test/utils/index.js#L45-L56) - */ -function skipProductCheck(client: Client) { - const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter( - (symbol) => symbol.description === 'product check' - )[1]; - // @ts-expect-error `tSymbol` is missing in the index signature of Transport - (client.transport || client)[tSymbol] = 2; -} From c14dc37badf0ba918f42b07ea8ceda6c43c0793f Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 10:10:27 +0200 Subject: [PATCH 085/172] filterPath --> filter_path --- .../saved_objects_counts/get_saved_object_counts.test.ts | 6 +++--- .../saved_objects_counts/get_saved_object_counts.ts | 2 +- .../canvas/server/collectors/custom_element_collector.ts | 2 +- .../plugins/canvas/server/collectors/workpad_collector.ts | 2 +- .../source_status/elasticsearch_source_status_adapter.ts | 4 ++-- .../plugins/reporting/server/usage/get_reporting_usage.ts | 2 +- x-pack/plugins/rollup/server/collectors/helpers.ts | 2 +- .../server/usage/detections/detection_rule_helpers.ts | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts index 94c618354fc37..bd5c90887707b 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts @@ -27,7 +27,7 @@ describe('getSavedObjectsCounts', () => { expect(esClient.search).toHaveBeenCalledWith({ index: '.kibana', ignoreUnavailable: true, - filterPath: 'aggregations.types.buckets', + filter_path: 'aggregations.types.buckets', body: { size: 0, query: { match_all: {} }, @@ -42,7 +42,7 @@ describe('getSavedObjectsCounts', () => { expect(esClient.search).toHaveBeenCalledWith({ index: '.kibana', ignoreUnavailable: true, - filterPath: 'aggregations.types.buckets', + filter_path: 'aggregations.types.buckets', body: { size: 0, query: { match_all: {} }, @@ -57,7 +57,7 @@ describe('getSavedObjectsCounts', () => { expect(esClient.search).toHaveBeenCalledWith({ index: '.kibana', ignoreUnavailable: true, - filterPath: 'aggregations.types.buckets', + filter_path: 'aggregations.types.buckets', body: { size: 0, query: { terms: { type: ['type_one', 'type_two'] } }, diff --git a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts index eeaeed67e753f..57d776a2a26bf 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts @@ -18,7 +18,7 @@ export async function getSavedObjectsCounts( const savedObjectCountSearchParams = { index: kibanaIndex, ignoreUnavailable: true, - filterPath: 'aggregations.types.buckets', + filter_path: 'aggregations.types.buckets', body: { size: 0, query, diff --git a/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts b/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts index 18cfe1a3df56c..e93c6714aaa32 100644 --- a/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts +++ b/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts @@ -148,7 +148,7 @@ const customElementCollector: TelemetryCollector = async function customElementC size: 10000, index: kibanaIndex, ignoreUnavailable: true, - filterPath: [`hits.hits._source.${CUSTOM_ELEMENT_TYPE}.content`], + filter_path: [`hits.hits._source.${CUSTOM_ELEMENT_TYPE}.content`], body: { query: { bool: { filter: { term: { type: CUSTOM_ELEMENT_TYPE } } } } }, }; diff --git a/x-pack/plugins/canvas/server/collectors/workpad_collector.ts b/x-pack/plugins/canvas/server/collectors/workpad_collector.ts index d42b8480ed7c7..f8509abf85b2b 100644 --- a/x-pack/plugins/canvas/server/collectors/workpad_collector.ts +++ b/x-pack/plugins/canvas/server/collectors/workpad_collector.ts @@ -382,7 +382,7 @@ const workpadCollector: TelemetryCollector = async function (kibanaIndex, esClie size: 10000, // elasticsearch index.max_result_window default value index: kibanaIndex, ignoreUnavailable: true, - filterPath: ['hits.hits._source.canvas-workpad', '-hits.hits._source.canvas-workpad.assets'], + filter_path: ['hits.hits._source.canvas-workpad', '-hits.hits._source.canvas-workpad.assets'], body: { query: { bool: { filter: { term: { type: CANVAS_TYPE } } } } }, }; diff --git a/x-pack/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts index 0aa305a580ffa..9c15d4746cdc5 100644 --- a/x-pack/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/source_status/elasticsearch_source_status_adapter.ts @@ -18,13 +18,13 @@ export class InfraElasticsearchSourceStatusAdapter implements InfraSourceStatusA this.framework .callWithRequest(requestContext, 'indices.getAlias', { name: aliasName, - filterPath: '*.settings.index.uuid', // to keep the response size as small as possible + filter_path: '*.settings.index.uuid', // to keep the response size as small as possible }) .catch(withDefaultIfNotFound({})), this.framework .callWithRequest(requestContext, 'indices.get', { index: aliasName, - filterPath: '*.settings.index.uuid', // to keep the response size as small as possible + filter_path: '*.settings.index.uuid', // to keep the response size as small as possible }) .catch(withDefaultIfNotFound({})), ]); diff --git a/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts index 51a1405f5180e..73a4920b350e3 100644 --- a/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts +++ b/x-pack/plugins/reporting/server/usage/get_reporting_usage.ts @@ -148,7 +148,7 @@ export async function getReportingUsage( const reportingIndex = REPORTING_SYSTEM_INDEX; const params = { index: `${reportingIndex}-*`, - filterPath: 'aggregations.*.buckets', + filter_path: 'aggregations.*.buckets', body: { size: 0, aggs: { diff --git a/x-pack/plugins/rollup/server/collectors/helpers.ts b/x-pack/plugins/rollup/server/collectors/helpers.ts index b6e5bc190d972..7b29894caf306 100644 --- a/x-pack/plugins/rollup/server/collectors/helpers.ts +++ b/x-pack/plugins/rollup/server/collectors/helpers.ts @@ -33,7 +33,7 @@ export async function fetchRollupIndexPatterns(kibanaIndex: string, esClient: El size: ES_MAX_RESULT_WINDOW_DEFAULT_VALUE, index: kibanaIndex, ignoreUnavailable: true, - filterPath: ['hits.hits._id'], + filter_path: ['hits.hits._id'], body: { query: { bool: { diff --git a/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts b/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts index 8d5a2efc7fae1..923f758425479 100644 --- a/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts +++ b/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts @@ -188,7 +188,7 @@ export const getDetectionRuleMetrics = async ( let rulesUsage: DetectionRulesTypeUsage = initialDetectionRulesUsage; const ruleSearchOptions: RuleSearchParams = { body: { query: { bool: { filter: { term: { 'alert.alertTypeId': SIGNALS_ID } } } } }, - filterPath: [], + filter_path: [], ignoreUnavailable: true, index: kibanaIndex, size: MAX_RESULTS_WINDOW, From 5f22e83636b1fe21c2f058da8b8c60774834beaf Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 10:18:49 +0200 Subject: [PATCH 086/172] ignoreUnavailable --> ignore_unavailable --- .../get_saved_object_counts.test.ts | 6 +++--- .../get_saved_object_counts.ts | 2 +- .../collectors/custom_element_collector.ts | 2 +- .../server/collectors/workpad_collector.ts | 2 +- .../log_entries/kibana_log_entries_adapter.ts | 4 ++-- .../lib/adapters/metrics/lib/check_valid_node.ts | 2 +- .../queries/log_entry_datasets.ts | 2 +- .../infra/server/lib/infra_ml/queries/common.ts | 2 +- .../queries/metrics_host_anomalies.test.ts | 2 +- .../queries/metrics_k8s_anomalies.test.ts | 2 +- .../server/lib/log_analysis/queries/common.ts | 2 +- x-pack/plugins/infra/server/lib/metrics/index.ts | 2 +- .../plugins/infra/server/lib/sources/has_data.ts | 2 +- .../inventory_metadata/lib/get_cloud_metadata.ts | 2 +- .../metadata/lib/get_cloud_metric_metadata.ts | 2 +- .../routes/metadata/lib/get_metric_metadata.ts | 2 +- .../server/routes/metadata/lib/get_node_info.ts | 2 +- .../routes/metadata/lib/get_pod_node_name.ts | 2 +- .../lib/get_dataset_for_field.ts | 2 +- .../lib/query_total_groupings.ts | 2 +- .../server/utils/calculate_metric_interval.ts | 2 +- .../lib/elasticsearch/get_last_recovery.ts | 2 +- .../factory/actions/all/query.all_actions.dsl.ts | 2 +- .../actions/details/query.action_details.dsl.ts | 2 +- .../actions/results/query.action_results.dsl.ts | 2 +- .../factory/agents/query.all_agents.dsl.ts | 2 +- .../factory/results/query.all_results.dsl.ts | 2 +- .../plugins/rollup/server/collectors/helpers.ts | 2 +- .../factory/cti/event_enrichment/query.ts | 2 +- .../cti/event_enrichment/response.test.ts | 2 +- .../factory/hosts/all/__mocks__/index.ts | 4 ++-- .../factory/hosts/all/query.all_hosts.dsl.ts | 2 +- .../hosts/all/query.all_hosts_entities.dsl.ts | 2 +- .../hosts/authentications/__mocks__/index.ts | 4 ++-- .../hosts/authentications/dsl/query.dsl.ts | 2 +- .../authentications/dsl/query_entities.dsl.ts | 2 +- .../factory/hosts/details/__mocks__/index.ts | 4 ++-- .../hosts/details/query.host_details.dsl.ts | 2 +- .../query.hosts_kpi_authentications.dsl.ts | 2 +- ...ery.hosts_kpi_authentications_entities.dsl.ts | 2 +- .../hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts | 2 +- .../hosts/query.hosts_kpi_hosts_entities.dsl.ts | 2 +- .../unique_ips/query.hosts_kpi_unique_ips.dsl.ts | 2 +- .../query.hosts_kpi_unique_ips_entities.dsl.ts | 2 +- .../hosts/last_first_seen/__mocks__/index.ts | 6 +++--- .../query.first_or_last_seen_host.dsl.ts | 2 +- .../factory/hosts/overview/__mocks__/index.ts | 4 ++-- .../hosts/overview/query.overview_host.dsl.ts | 2 +- .../hosts/risk_score/query.hosts_risk.dsl.ts | 2 +- .../hosts/uncommon_processes/__mocks__/index.ts | 4 ++-- .../hosts/uncommon_processes/dsl/query.dsl.ts | 2 +- .../factory/matrix_histogram/__mocks__/index.ts | 12 ++++++------ .../matrix_histogram/alerts/__mocks__/index.ts | 2 +- .../alerts/query.alerts_histogram.dsl.ts | 2 +- .../anomalies/__mocks__/index.ts | 2 +- .../anomalies/query.anomalies_histogram.dsl.ts | 2 +- .../authentications/__mocks__/index.ts | 2 +- .../query.authentications_histogram.dsl.ts | 2 +- ...ery.authentications_histogram_entities.dsl.ts | 2 +- .../matrix_histogram/dns/__mocks__/index.ts | 2 +- .../dns/query.dns_histogram.dsl.ts | 2 +- .../matrix_histogram/events/__mocks__/index.ts | 16 ++++++++-------- .../events/query.events_histogram.dsl.ts | 2 +- .../factory/network/details/__mocks__/index.ts | 4 ++-- .../network/details/query.details_network.dsl.ts | 2 +- .../factory/network/dns/__mocks__/index.ts | 4 ++-- .../factory/network/dns/query.dns_network.dsl.ts | 2 +- .../factory/network/http/__mocks__/index.ts | 4 ++-- .../network/http/query.http_network.dsl.ts | 2 +- .../dns/query.network_kip_dns_entities.dsl.ts | 2 +- .../network/kpi/dns/query.network_kpi_dns.dsl.ts | 2 +- .../query.network_kpi_network_events.dsl.ts | 2 +- ...ry.network_kpi_network_events_entities.dsl.ts | 2 +- .../query.network_kpi_tls_handshakes.dsl.ts | 2 +- ...ry.network_kpi_tls_handshakes_entities.dsl.ts | 2 +- .../query.network_kpi_unique_flows.dsl.ts | 2 +- .../query.network_kpi_unique_private_ips.dsl.ts | 2 +- ...etwork_kpi_unique_private_ips_entities.dsl.ts | 2 +- .../factory/network/overview/__mocks__/index.ts | 4 ++-- .../overview/query.overview_network.dsl.ts | 2 +- .../factory/network/tls/__mocks__/index.ts | 4 ++-- .../factory/network/tls/query.tls_network.dsl.ts | 2 +- .../network/top_countries/__mocks__/index.ts | 4 ++-- .../query.top_countries_network.dsl.ts | 2 +- .../query.top_countries_network_entities.dsl.ts | 2 +- .../network/top_n_flow/__mocks__/index.ts | 4 ++-- .../top_n_flow/query.top_n_flow_network.dsl.ts | 2 +- .../query.top_n_flow_network_entities.dsl.ts | 2 +- .../factory/network/users/__mocks__/index.ts | 4 ++-- .../network/users/query.users_network.dsl.ts | 2 +- .../ueba/host_rules/query.host_rules.dsl.ts | 2 +- .../ueba/host_tactics/query.host_tactics.dsl.ts | 2 +- .../ueba/risk_score/query.risk_score.dsl.ts | 2 +- .../ueba/user_rules/query.user_rules.dsl.ts | 2 +- .../usage/detections/detection_rule_helpers.ts | 2 +- .../server/usage/detections/types.ts | 4 ++-- .../client_integration/policy_edit.test.ts | 2 +- .../server/routes/api/validate_schemas.ts | 4 ++-- .../factory/events/all/query.events_all.dsl.ts | 2 +- .../events/details/query.events_details.dsl.ts | 2 +- .../timeline/factory/events/kpi/query.kpi.dsl.ts | 2 +- .../query.events_last_event_time.dsl.ts | 6 +++--- .../snapshot_restore/snapshot_restore.ts | 4 ++-- 103 files changed, 138 insertions(+), 138 deletions(-) diff --git a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts index bd5c90887707b..4b3421efed96e 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.test.ts @@ -26,7 +26,7 @@ describe('getSavedObjectsCounts', () => { expect(results).toStrictEqual([]); expect(esClient.search).toHaveBeenCalledWith({ index: '.kibana', - ignoreUnavailable: true, + ignore_unavailable: true, filter_path: 'aggregations.types.buckets', body: { size: 0, @@ -41,7 +41,7 @@ describe('getSavedObjectsCounts', () => { await getSavedObjectsCounts(esClient, '.kibana'); expect(esClient.search).toHaveBeenCalledWith({ index: '.kibana', - ignoreUnavailable: true, + ignore_unavailable: true, filter_path: 'aggregations.types.buckets', body: { size: 0, @@ -56,7 +56,7 @@ describe('getSavedObjectsCounts', () => { await getSavedObjectsCounts(esClient, '.kibana', ['type_one', 'type_two']); expect(esClient.search).toHaveBeenCalledWith({ index: '.kibana', - ignoreUnavailable: true, + ignore_unavailable: true, filter_path: 'aggregations.types.buckets', body: { size: 0, diff --git a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts index 57d776a2a26bf..f82a803b763c5 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/saved_objects_counts/get_saved_object_counts.ts @@ -17,7 +17,7 @@ export async function getSavedObjectsCounts( const savedObjectCountSearchParams = { index: kibanaIndex, - ignoreUnavailable: true, + ignore_unavailable: true, filter_path: 'aggregations.types.buckets', body: { size: 0, diff --git a/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts b/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts index e93c6714aaa32..b0e219a4d886d 100644 --- a/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts +++ b/x-pack/plugins/canvas/server/collectors/custom_element_collector.ts @@ -147,7 +147,7 @@ const customElementCollector: TelemetryCollector = async function customElementC const customElementParams = { size: 10000, index: kibanaIndex, - ignoreUnavailable: true, + ignore_unavailable: true, filter_path: [`hits.hits._source.${CUSTOM_ELEMENT_TYPE}.content`], body: { query: { bool: { filter: { term: { type: CUSTOM_ELEMENT_TYPE } } } } }, }; diff --git a/x-pack/plugins/canvas/server/collectors/workpad_collector.ts b/x-pack/plugins/canvas/server/collectors/workpad_collector.ts index f8509abf85b2b..62b0ce200e320 100644 --- a/x-pack/plugins/canvas/server/collectors/workpad_collector.ts +++ b/x-pack/plugins/canvas/server/collectors/workpad_collector.ts @@ -381,7 +381,7 @@ const workpadCollector: TelemetryCollector = async function (kibanaIndex, esClie const searchParams = { size: 10000, // elasticsearch index.max_result_window default value index: kibanaIndex, - ignoreUnavailable: true, + ignore_unavailable: true, filter_path: ['hits.hits._source.canvas-workpad', '-hits.hits._source.canvas-workpad.assets'], body: { query: { bool: { filter: { term: { type: CANVAS_TYPE } } } } }, }; diff --git a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts index f8691accebe01..3d4c428b14f11 100644 --- a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts @@ -71,7 +71,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter { const esQuery = { allowNoIndices: true, index: resolvedLogSourceConfiguration.indices, - ignoreUnavailable: true, + ignore_unavailable: true, body: { size: size + 1, // Extra one to test if it has more before or after track_total_hits: false, @@ -141,7 +141,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter { const query = { allowNoIndices: true, index: resolvedLogSourceConfiguration.indices, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { count_by_date: { diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts index f53016561dc5b..1d5a84b93d22a 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts @@ -15,7 +15,7 @@ export const checkValidNode = async ( ): Promise => { const params = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, index: indexPattern, terminateAfter: 1, body: { diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts index 27ce2f3dd647e..025e243a242a2 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts @@ -66,7 +66,7 @@ export const createLogEntryDatasetsQuery = ( const defaultRequestParameters = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, trackScores: false, trackTotalHits: false, }; diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts index f4088c56303e2..2c978e74229ec 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts @@ -7,7 +7,7 @@ export const defaultRequestParameters = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, trackScores: false, trackTotalHits: false, }; diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts index 7c281963e5717..3274169a783ff 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts @@ -28,7 +28,7 @@ describe('createMetricsHostAnomaliesQuery', () => { }) ).toMatchObject({ allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, trackScores: false, trackTotalHits: false, body: { diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts index 61efb896a6c89..80762a012a934 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts @@ -28,7 +28,7 @@ describe('createMetricsK8sAnomaliesQuery', () => { }) ).toMatchObject({ allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, trackScores: false, trackTotalHits: false, body: { diff --git a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts index 4c3ba5612c443..8bd76249a232d 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts @@ -7,7 +7,7 @@ export const defaultRequestParameters = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, trackScores: false, trackTotalHits: false, }; diff --git a/x-pack/plugins/infra/server/lib/metrics/index.ts b/x-pack/plugins/infra/server/lib/metrics/index.ts index 131f6944b0484..517197591d606 100644 --- a/x-pack/plugins/infra/server/lib/metrics/index.ts +++ b/x-pack/plugins/infra/server/lib/metrics/index.ts @@ -48,7 +48,7 @@ export const query = async ( const params = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, index: options.indexPattern, body: { size: 0, diff --git a/x-pack/plugins/infra/server/lib/sources/has_data.ts b/x-pack/plugins/infra/server/lib/sources/has_data.ts index b036124344ea9..71f32bcecd80b 100644 --- a/x-pack/plugins/infra/server/lib/sources/has_data.ts +++ b/x-pack/plugins/infra/server/lib/sources/has_data.ts @@ -12,7 +12,7 @@ export const hasData = async (index: string, client: ESSearchClient) => { index, allowNoIndices: true, terminate_after: 1, - ignoreUnavailable: true, + ignore_unavailable: true, body: { size: 0, }, diff --git a/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts b/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts index 57f99aee6d187..c9c0b174b07ed 100644 --- a/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts +++ b/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts @@ -41,7 +41,7 @@ export const getCloudMetadata = async ( const metricQuery = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, index: sourceConfiguration.metricAlias, body: { query: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts index be2a39b84ef1c..54f0fb7b5adc8 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts @@ -27,7 +27,7 @@ export const getCloudMetricsMetadata = async ( ): Promise => { const metricQuery = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, index: sourceConfiguration.metricAlias, body: { query: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts index 26bcf267ad6cc..054dc558e9866 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts @@ -33,7 +33,7 @@ export const getMetricMetadata = async ( const fields = findInventoryFields(nodeType, sourceConfiguration.fields); const metricQuery = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, index: sourceConfiguration.metricAlias, body: { query: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts index fccbead2832c9..9a57bdc8e6c64 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts @@ -54,7 +54,7 @@ export const getNodeInfo = async ( const timestampField = sourceConfiguration.fields.timestamp; const params = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, terminateAfter: 1, index: sourceConfiguration.metricAlias, body: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts index 8e4c707d9b467..169c00adc5031 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts @@ -23,7 +23,7 @@ export const getPodNodeName = async ( const timestampField = sourceConfiguration.fields.timestamp; const params = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, terminateAfter: 1, index: sourceConfiguration.metricAlias, body: { diff --git a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts index b88472fbb4b14..da50e64b9bc8b 100644 --- a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts @@ -23,7 +23,7 @@ export const getDatasetForField = async ( ) => { const params = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, terminateAfter: 1, index: indexPattern, body: { diff --git a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts index b871fa21c111d..a3e88bd6b9b2e 100644 --- a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts @@ -42,7 +42,7 @@ export const queryTotalGroupings = async ( const params = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, index: options.indexPattern, body: { size: 0, diff --git a/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts b/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts index 13a108b76b6a4..1495fe95e084a 100644 --- a/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts +++ b/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts @@ -37,7 +37,7 @@ export const calculateMetricInterval = async ( const query = { allowNoIndices: true, index: options.indexPattern, - ignoreUnavailable: true, + ignore_unavailable: true, body: { query: { bool: { diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts index 43527f875cf72..974ffad7745d9 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/get_last_recovery.ts @@ -107,7 +107,7 @@ export async function getLastRecovery(req: LegacyRequest, esIndexPattern: string const mbParams = { index: esIndexPattern, size, - ignoreUnavailable: true, + ignore_unavailable: true, body: { _source: ['elasticsearch.index.recovery', '@timestamp'], sort: { timestamp: { order: 'desc', unmapped_type: 'long' } }, diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts index 84241356579c8..8c47a928373a5 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts @@ -22,7 +22,7 @@ export const buildActionsQuery = ({ const dslQuery = { allowNoIndices: true, index: '.fleet-actions', - ignoreUnavailable: true, + ignore_unavailable: true, body: { // query: { bool: { filter } }, query: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts index bc9d63e619338..bc87a877f9785 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts @@ -25,7 +25,7 @@ export const buildActionDetailsQuery = ({ const dslQuery = { allowNoIndices: true, index: '.fleet-actions', - ignoreUnavailable: true, + ignore_unavailable: true, body: { query: { bool: { filter } }, size: 1, diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts index d74067bff0251..9941780008693 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts @@ -27,7 +27,7 @@ export const buildActionResultsQuery = ({ const dslQuery = { allowNoIndices: true, index: '.fleet-actions-results*', - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggs: { aggs: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts index 52101462270c7..ec07b73993fae 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts @@ -23,7 +23,7 @@ export const buildAgentsQuery = ({ const dslQuery = { allowNoIndices: true, index: '.fleet-agents', - ignoreUnavailable: true, + ignore_unavailable: true, body: { query: { bool: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts index 406ff26991f0e..172f85dba6efd 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts @@ -38,7 +38,7 @@ export const buildResultsQuery = ({ const dslQuery = { allowNoIndices: true, index: `logs-${OSQUERY_INTEGRATION_NAME}.result*`, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggs: { count_by_agent_id: { diff --git a/x-pack/plugins/rollup/server/collectors/helpers.ts b/x-pack/plugins/rollup/server/collectors/helpers.ts index 7b29894caf306..b007bbbff7e4a 100644 --- a/x-pack/plugins/rollup/server/collectors/helpers.ts +++ b/x-pack/plugins/rollup/server/collectors/helpers.ts @@ -32,7 +32,7 @@ export async function fetchRollupIndexPatterns(kibanaIndex: string, esClient: El const searchParams = { size: ES_MAX_RESULT_WINDOW_DEFAULT_VALUE, index: kibanaIndex, - ignoreUnavailable: true, + ignore_unavailable: true, filter_path: ['hits.hits._id'], body: { query: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts index 786f9a20f77e5..e517c11668d6f 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts @@ -29,7 +29,7 @@ export const buildEventEnrichmentQuery: SecuritySolutionFactory { }, }, }, - ignoreUnavailable: true, + ignore_unavailable: true, index: ['filebeat-*'], }); const parsedInspect = JSON.parse(parsedResponse.inspect.dsl[0]); diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts index 0369f182a4c75..426b2859dff01 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts @@ -622,7 +622,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { docvalue_fields: mockOptions.docValueFields, @@ -821,7 +821,7 @@ export const expectedDsl = { docvalue_fields: mockOptions.docValueFields, size: 0, }, - ignoreUnavailable: true, + ignore_unavailable: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts index 5d8540f886077..4dd8cb022efed 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts @@ -42,7 +42,7 @@ export const buildHostsQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts index 1c338998e3b65..6e17f17f69ae8 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts @@ -42,7 +42,7 @@ export const buildHostsQueryEntities = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts index 1dd3dc8ee4cff..29654a5abff67 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts @@ -2160,7 +2160,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { docvalue_fields: mockOptions.docValueFields, aggregations: { @@ -2382,7 +2382,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { docvalue_fields: mockOptions.docValueFields, aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts index 57646c48ce55b..b884538179bdf 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts @@ -63,7 +63,7 @@ export const buildQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts index d77bbb5d429ac..958c8809d659e 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts @@ -43,7 +43,7 @@ export const buildQueryEntities = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts index e0473c9501b0c..7d9b403eb2759 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts @@ -1312,7 +1312,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { @@ -1426,7 +1426,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts index 45afed2526aa3..8eb29a44bf0f6 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts @@ -37,7 +37,7 @@ export const buildHostDetailsQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts index 01473a4368dbc..377ca60020324 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts @@ -40,7 +40,7 @@ export const buildHostsKpiAuthenticationsQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts index cff09f2354d31..e0b8612ec2d88 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts @@ -29,7 +29,7 @@ export const buildHostsKpiAuthenticationsQueryEntities = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts index 5ea2d1aa40780..97b2fd46c6313 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts @@ -29,7 +29,7 @@ export const buildHostsKpiHostsQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts index 972ead9a6538e..a5a9774eed023 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts @@ -29,7 +29,7 @@ export const buildHostsKpiHostsQueryEntities = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts index 0471644d11bbe..2b2c90dfefa7b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts @@ -29,7 +29,7 @@ export const buildHostsKpiUniqueIpsQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts index 2a55c34238d70..bb1e6d57f8410 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts @@ -29,7 +29,7 @@ export const buildHostsKpiUniqueIpsQueryEntities = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts index 443e7e96a3c7f..643cc6771ad89 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts @@ -135,7 +135,7 @@ export const formattedSearchStrategyFirstResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { query: { bool: { filter: [{ term: { 'host.name': 'siem-kibana' } }] } }, @@ -201,7 +201,7 @@ export const formattedSearchStrategyLastResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { query: { bool: { filter: [{ term: { 'host.name': 'siem-kibana' } }] } }, @@ -236,7 +236,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { _source: ['@timestamp'], diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts index 21876b9aad11b..72c7b686ecc7c 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts @@ -19,7 +19,7 @@ export const buildFirstOrLastSeenHostQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts index 2b4e4b8291401..8e879803cb9c7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts @@ -128,7 +128,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { @@ -341,7 +341,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts index a0ae368ac0fe2..e0b5750d9e848 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts @@ -30,7 +30,7 @@ export const buildOverviewHostQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts index 43930ab3de2ef..4a8916a086fa9 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts @@ -33,7 +33,7 @@ export const buildHostsRiskScoreQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: false, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { query: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts index 0ad976a0f498c..ecae54e163525 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts @@ -4311,7 +4311,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { process_count: { cardinality: { field: 'process.name' } }, @@ -4446,7 +4446,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { process_count: { cardinality: { field: 'process.name' } }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts index 0623507f885b1..c669ad5c03cdc 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts @@ -50,7 +50,7 @@ export const buildQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { ...agg, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts index 7f36e3551e5be..b392369d9a62b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts @@ -42,7 +42,7 @@ export const formattedAlertsSearchStrategyResponse: MatrixHistogramStrategyRespo 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -164,7 +164,7 @@ export const expectedDsl = { }, size: 0, }, - ignoreUnavailable: true, + ignore_unavailable: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -210,7 +210,7 @@ export const formattedAnomaliesSearchStrategyResponse: MatrixHistogramStrategyRe 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggs: { @@ -393,7 +393,7 @@ export const formattedAuthenticationsSearchStrategyResponse: MatrixHistogramStra 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -960,7 +960,7 @@ export const formattedEventsSearchStrategyResponse: MatrixHistogramStrategyRespo 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -1938,7 +1938,7 @@ export const formattedDnsSearchStrategyResponse: MatrixHistogramStrategyResponse 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { dns_count: { cardinality: { field: 'dns.question.registered_domain' } }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts index 82531f35b09ab..055bc320ab61a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts @@ -37,7 +37,7 @@ export const expectedDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts index 54ee066b64119..e6d78038c5049 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts @@ -84,7 +84,7 @@ export const buildAlertsHistogramQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: getHistogramAggregation(), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts index ab76d54dee11f..929e55f1fe199 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts @@ -37,7 +37,7 @@ export const expectedDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts index 78fc0a30d0477..2bb9de8b08423 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts @@ -65,7 +65,7 @@ export const buildAnomaliesHistogramQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggs: getHistogramAggregation(), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts index 1fd7b85242df6..1a9582285ba50 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts @@ -36,7 +36,7 @@ export const expectedDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts index 8661fff574b4a..79b8ec63a901a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts @@ -77,7 +77,7 @@ export const buildAuthenticationsHistogramQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: getHistogramAggregation(), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts index c66a0d6c11b94..7286657897d71 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts @@ -60,7 +60,7 @@ export const buildAuthenticationsHistogramQueryEntities = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: getHistogramAggregation(), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts index 4d97fba3cb80c..31c437e89dfee 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts @@ -37,7 +37,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { dns_count: { cardinality: { field: 'dns.question.registered_domain' } }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts index d9dfc57a264a8..0296b0a6f9e4b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts @@ -79,7 +79,7 @@ export const buildDnsHistogramQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts index 5dab2bcd5cf9d..f81f775b0f94b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts @@ -41,7 +41,7 @@ export const expectedDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -96,7 +96,7 @@ export const expectedThresholdDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -153,7 +153,7 @@ export const expectedThresholdMissingFieldDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -244,7 +244,7 @@ export const expectedThresholdWithCardinalityDsl = { }, size: 0, }, - ignoreUnavailable: true, + ignore_unavailable: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -270,7 +270,7 @@ export const expectedThresholdWithGroupFieldsAndCardinalityDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -365,7 +365,7 @@ export const expectedThresholdGroupWithCardinalityDsl = { }, size: 0, }, - ignoreUnavailable: true, + ignore_unavailable: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -391,7 +391,7 @@ export const expectedIpIncludingMissingDataDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { @@ -454,7 +454,7 @@ export const expectedIpNotIncludingMissingDataDsl = { 'winlogbeat-*', ], allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts index 16bcb3cdbfcb1..c8819dcd830e5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts @@ -153,7 +153,7 @@ export const buildEventsHistogramQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { aggregations: getHistogramAggregation(), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts index 7f71906bcaa97..bf5c3b814f4cc 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts @@ -315,7 +315,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { docvalue_fields: mockOptions.docValueFields, @@ -457,7 +457,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts index e5a508663a2e0..94c7a155adc67 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts @@ -105,7 +105,7 @@ export const buildNetworkDetailsQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts index cc01450e5bec5..eb097562666e1 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts @@ -142,7 +142,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { dns_count: { cardinality: { field: 'dns.question.registered_domain' } }, @@ -214,7 +214,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { dns_count: { cardinality: { field: 'dns.question.registered_domain' } }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts index 90e8ee02ee684..3597330602cf6 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts @@ -90,7 +90,7 @@ export const buildDnsQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts index 9d52eb638eac6..c5cfeedb6dc05 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts @@ -624,7 +624,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { http_count: { cardinality: { field: 'url.path' } }, @@ -682,7 +682,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { http_count: { cardinality: { field: 'url.path' } }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts index 85db56cd72167..d576c24768872 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts @@ -38,7 +38,7 @@ export const buildHttpQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { ...getCountAgg(), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts index 75b32af4b01f5..368b2ca83ed3d 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts @@ -29,7 +29,7 @@ export const buildDnsQueryEntities = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts index 1d1aa50cc3ee2..aa0746944c845 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts @@ -57,7 +57,7 @@ export const buildDnsQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { query: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts index 3d5607c8b443a..a2545ab8b57fa 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts @@ -31,7 +31,7 @@ export const buildNetworkEventsQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { query: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts index 6311bb6ea2039..839bda22ce669 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts @@ -29,7 +29,7 @@ export const buildNetworkEventsQueryEntities = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts index 0a826938e95b8..45593bdecfdc1 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts @@ -57,7 +57,7 @@ export const buildTlsHandshakeQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { query: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts index 5b0ac92b35049..d952657f43e7b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts @@ -29,7 +29,7 @@ export const buildTlsHandshakeQueryEntities = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts index ec8de30cfff85..6f5a85f5832c6 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts @@ -31,7 +31,7 @@ export const buildUniqueFlowsQuery = ({ const dslQuery = { index: defaultIndex, allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts index 590e7117826d7..bf3236095ffab 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts @@ -86,7 +86,7 @@ export const buildUniquePrivateIpsQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts index a56cf4c3d1ced..fb55260115322 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts @@ -86,7 +86,7 @@ export const buildUniquePrivateIpsQueryEntities = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts index 74b201e9a2294..77e4d71fded8a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts @@ -112,7 +112,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { @@ -207,7 +207,7 @@ export const formattedSearchStrategyResponse = { export const expectedDsl = { allowNoIndices: true, - ignoreUnavailable: true, + ignore_unavailable: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts index 7e35ae2fd4308..b56ec4ed8ab9d 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts @@ -30,7 +30,7 @@ export const buildOverviewNetworkQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts index e46c2c20aa1a8..d3c30abe75c40 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts @@ -70,7 +70,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { @@ -125,7 +125,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts index 4f724cf9b15f9..a4ff905305018 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts @@ -77,7 +77,7 @@ export const buildNetworkTlsQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts index ba5db90df8245..08cffcce1ef1a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts @@ -69,7 +69,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { top_countries_count: { cardinality: { field: 'destination.geo.country_iso_code' } }, @@ -129,7 +129,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { top_countries_count: { cardinality: { field: 'destination.geo.country_iso_code' } }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts index 880cd4002086a..56105bf9c5aec 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts @@ -44,7 +44,7 @@ export const buildTopCountriesQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { ...getCountAgg(flowTarget), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts index d661bfa0d6707..59659629a144b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts @@ -49,7 +49,7 @@ export const buildTopCountriesQueryEntities = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { ...getCountAgg(flowTarget), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts index e881a9ef93949..e6a4da56dc9ba 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts @@ -821,7 +821,7 @@ export const formattedSearchStrategyResponse: NetworkTopNFlowStrategyResponse = 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { top_n_flow_count: { cardinality: { field: 'source.ip' } }, @@ -889,7 +889,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { top_n_flow_count: { cardinality: { field: 'source.ip' } }, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts index f1ac87e59d392..6be0160cd1d6c 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts @@ -44,7 +44,7 @@ export const buildTopNFlowQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { ...getCountAgg(flowTarget), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts index 3ea3c6f363de0..5a4a685bedc23 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts @@ -49,7 +49,7 @@ export const buildTopNFlowQueryEntities = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggregations: { ...getCountAgg(flowTarget), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts index 686730dbe7927..56a54ab39b2f4 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts @@ -130,7 +130,7 @@ export const formattedSearchStrategyResponse = { 'packetbeat-*', 'winlogbeat-*', ], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { @@ -209,7 +209,7 @@ export const expectedDsl = { }, size: 0, }, - ignoreUnavailable: true, + ignore_unavailable: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts index 2b02b25292a32..f93ce5a4d8047 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts @@ -36,7 +36,7 @@ export const buildUsersQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts index 4c116104b3e14..988ea5752c8f3 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts @@ -32,7 +32,7 @@ export const buildHostRulesQuery = ({ return { allowNoIndices: true, index: defaultIndex, // can stop getting this from sourcerer and assume default detections index if we want - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts index ec1afe247011b..bdc73d01bd283 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts @@ -32,7 +32,7 @@ export const buildHostTacticsQuery = ({ return { allowNoIndices: true, index: defaultIndex, // can stop getting this from sourcerer and assume default detections index if we want - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts index 79c50d84e3c92..d48535b622248 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts @@ -33,7 +33,7 @@ export const buildRiskScoreQuery = ({ return { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts index c2242ff00a6c1..7e042931b2606 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts @@ -32,7 +32,7 @@ export const buildUserRulesQuery = ({ return { allowNoIndices: true, index: defaultIndex, // can stop getting this from sourcerer and assume default detections index if we want - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts b/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts index 923f758425479..eaeceb8ab57ee 100644 --- a/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts +++ b/x-pack/plugins/security_solution/server/usage/detections/detection_rule_helpers.ts @@ -189,7 +189,7 @@ export const getDetectionRuleMetrics = async ( const ruleSearchOptions: RuleSearchParams = { body: { query: { bool: { filter: { term: { 'alert.alertTypeId': SIGNALS_ID } } } } }, filter_path: [], - ignoreUnavailable: true, + ignore_unavailable: true, index: kibanaIndex, size: MAX_RESULTS_WINDOW, }; diff --git a/x-pack/plugins/security_solution/server/usage/detections/types.ts b/x-pack/plugins/security_solution/server/usage/detections/types.ts index 0e3ba97ca0f7c..430a524f3f03a 100644 --- a/x-pack/plugins/security_solution/server/usage/detections/types.ts +++ b/x-pack/plugins/security_solution/server/usage/detections/types.ts @@ -17,8 +17,8 @@ interface RuleSearchBody { export interface RuleSearchParams { body: RuleSearchBody; - filterPath: string[]; - ignoreUnavailable: boolean; + filter_path: string[]; + ignore_unavailable: boolean; index: string; size: number; } diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts index 7d5d605b216bc..d1386ca34be8b 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts @@ -153,7 +153,7 @@ describe('', () => { schedule, repository, config: { - ignoreUnavailable: true, + ignore_unavailable: true, }, retention: { ...retention, diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts b/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts index af31466c2cefe..9decff4b120c2 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts @@ -13,7 +13,7 @@ export const nameParameterSchema = schema.object({ const snapshotConfigSchema = schema.object({ indices: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), - ignoreUnavailable: schema.maybe(schema.boolean()), + ignore_unavailable: schema.maybe(schema.boolean()), includeGlobalState: schema.maybe(schema.boolean()), partial: schema.maybe(schema.boolean()), metadata: schema.maybe(schema.recordOf(schema.string(), schema.string())), @@ -175,6 +175,6 @@ export const restoreSettingsSchema = schema.object({ partial: schema.maybe(schema.boolean()), indexSettings: schema.maybe(schema.string()), ignoreIndexSettings: schema.maybe(schema.arrayOf(schema.string())), - ignoreUnavailable: schema.maybe(schema.boolean()), + ignore_unavailable: schema.maybe(schema.boolean()), includeAliases: schema.maybe(schema.boolean()), }); diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts index 72a7d6e2692e8..53932d5ca7ec5 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts @@ -65,7 +65,7 @@ export const buildTimelineEventsAllQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), aggregations: { diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts index 4297cd595e261..9a070070dd80e 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts @@ -35,7 +35,7 @@ export const buildTimelineDetailsQuery = ( return { allowNoIndices: true, index: indexName, - ignoreUnavailable: true, + ignore_unavailable: true, body: { docvalue_fields: docValueFields, query, diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts index 41eed7cbb4fa3..6110ebbd622dd 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts @@ -46,7 +46,7 @@ export const buildTimelineKpiQuery = ({ const dslQuery = { allowNoIndices: true, index: defaultIndex, - ignoreUnavailable: true, + ignore_unavailable: true, body: { aggs: { userCount: { diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts index 354c682377bac..b31c4b4662c46 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts @@ -40,7 +40,7 @@ export const buildLastEventTimeQuery = ({ return { allowNoIndices: true, index: indicesToQuery.network, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), @@ -63,7 +63,7 @@ export const buildLastEventTimeQuery = ({ return { allowNoIndices: true, index: indicesToQuery.hosts, - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), @@ -87,7 +87,7 @@ export const buildLastEventTimeQuery = ({ return { allowNoIndices: true, index: indicesToQuery[indexKey], - ignoreUnavailable: true, + ignore_unavailable: true, track_total_hits: false, body: { ...(!isEmpty(docValueFields) ? { docvalue_fields: docValueFields } : {}), diff --git a/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts b/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts index a6ac2d057c84e..c0d93185c5fc1 100644 --- a/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts +++ b/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts @@ -62,7 +62,7 @@ export default function ({ getService }: FtrProviderContext) { repository: REPO_NAME, config: { indices: ['my_index'], - ignoreUnavailable: true, + ignore_unavailable: true, partial: false, metadata: { meta: 'my_meta', @@ -141,7 +141,7 @@ export default function ({ getService }: FtrProviderContext) { repository: REPO_NAME, config: { indices: ['my_index'], - ignoreUnavailable: true, + ignore_unavailable: true, partial: false, metadata: { meta: 'my_meta', From 77b7d20434b10391d6938c088d5d56a4e168bdab Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 10:33:19 +0200 Subject: [PATCH 087/172] ignoreUnavailable --> ignore_unavailable --- .../data_views/server/fetcher/lib/es_api.test.js | 4 ++-- .../log_entries/kibana_log_entries_adapter.ts | 4 ++-- .../lib/adapters/metrics/lib/check_valid_node.ts | 2 +- .../queries/log_entry_datasets.ts | 2 +- .../infra/server/lib/infra_ml/queries/common.ts | 2 +- .../queries/metrics_host_anomalies.test.ts | 2 +- .../queries/metrics_k8s_anomalies.test.ts | 2 +- .../server/lib/log_analysis/queries/common.ts | 2 +- x-pack/plugins/infra/server/lib/metrics/index.ts | 2 +- .../plugins/infra/server/lib/sources/has_data.ts | 2 +- .../inventory_metadata/lib/get_cloud_metadata.ts | 2 +- .../metadata/lib/get_cloud_metric_metadata.ts | 2 +- .../routes/metadata/lib/get_metric_metadata.ts | 2 +- .../server/routes/metadata/lib/get_node_info.ts | 2 +- .../routes/metadata/lib/get_pod_node_name.ts | 2 +- .../lib/get_dataset_for_field.ts | 2 +- .../lib/query_total_groupings.ts | 2 +- .../server/utils/calculate_metric_interval.ts | 2 +- .../factory/actions/all/query.all_actions.dsl.ts | 2 +- .../actions/details/query.action_details.dsl.ts | 2 +- .../actions/results/query.action_results.dsl.ts | 2 +- .../factory/agents/query.all_agents.dsl.ts | 2 +- .../factory/results/query.all_results.dsl.ts | 2 +- .../factory/cti/event_enrichment/query.ts | 2 +- .../cti/event_enrichment/response.test.ts | 2 +- .../factory/hosts/all/__mocks__/index.ts | 4 ++-- .../factory/hosts/all/query.all_hosts.dsl.ts | 2 +- .../hosts/all/query.all_hosts_entities.dsl.ts | 2 +- .../hosts/authentications/__mocks__/index.ts | 4 ++-- .../hosts/authentications/dsl/query.dsl.ts | 2 +- .../authentications/dsl/query_entities.dsl.ts | 2 +- .../factory/hosts/details/__mocks__/index.ts | 4 ++-- .../hosts/details/query.host_details.dsl.ts | 2 +- .../query.hosts_kpi_authentications.dsl.ts | 2 +- ...ery.hosts_kpi_authentications_entities.dsl.ts | 2 +- .../hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts | 2 +- .../hosts/query.hosts_kpi_hosts_entities.dsl.ts | 2 +- .../unique_ips/query.hosts_kpi_unique_ips.dsl.ts | 2 +- .../query.hosts_kpi_unique_ips_entities.dsl.ts | 2 +- .../hosts/last_first_seen/__mocks__/index.ts | 6 +++--- .../query.first_or_last_seen_host.dsl.ts | 2 +- .../factory/hosts/overview/__mocks__/index.ts | 4 ++-- .../hosts/overview/query.overview_host.dsl.ts | 2 +- .../hosts/risk_score/query.hosts_risk.dsl.ts | 2 +- .../hosts/uncommon_processes/__mocks__/index.ts | 4 ++-- .../hosts/uncommon_processes/dsl/query.dsl.ts | 2 +- .../factory/matrix_histogram/__mocks__/index.ts | 12 ++++++------ .../matrix_histogram/alerts/__mocks__/index.ts | 2 +- .../alerts/query.alerts_histogram.dsl.ts | 2 +- .../anomalies/__mocks__/index.ts | 2 +- .../anomalies/query.anomalies_histogram.dsl.ts | 2 +- .../authentications/__mocks__/index.ts | 2 +- .../query.authentications_histogram.dsl.ts | 2 +- ...ery.authentications_histogram_entities.dsl.ts | 2 +- .../matrix_histogram/dns/__mocks__/index.ts | 2 +- .../dns/query.dns_histogram.dsl.ts | 2 +- .../matrix_histogram/events/__mocks__/index.ts | 16 ++++++++-------- .../events/query.events_histogram.dsl.ts | 2 +- .../factory/network/details/__mocks__/index.ts | 4 ++-- .../network/details/query.details_network.dsl.ts | 2 +- .../factory/network/dns/__mocks__/index.ts | 4 ++-- .../factory/network/dns/query.dns_network.dsl.ts | 2 +- .../factory/network/http/__mocks__/index.ts | 4 ++-- .../network/http/query.http_network.dsl.ts | 2 +- .../dns/query.network_kip_dns_entities.dsl.ts | 2 +- .../network/kpi/dns/query.network_kpi_dns.dsl.ts | 2 +- .../query.network_kpi_network_events.dsl.ts | 2 +- ...ry.network_kpi_network_events_entities.dsl.ts | 2 +- .../query.network_kpi_tls_handshakes.dsl.ts | 2 +- ...ry.network_kpi_tls_handshakes_entities.dsl.ts | 2 +- .../query.network_kpi_unique_flows.dsl.ts | 2 +- .../query.network_kpi_unique_private_ips.dsl.ts | 2 +- ...etwork_kpi_unique_private_ips_entities.dsl.ts | 2 +- .../factory/network/overview/__mocks__/index.ts | 4 ++-- .../overview/query.overview_network.dsl.ts | 2 +- .../factory/network/tls/__mocks__/index.ts | 4 ++-- .../factory/network/tls/query.tls_network.dsl.ts | 2 +- .../network/top_countries/__mocks__/index.ts | 4 ++-- .../query.top_countries_network.dsl.ts | 2 +- .../query.top_countries_network_entities.dsl.ts | 2 +- .../network/top_n_flow/__mocks__/index.ts | 4 ++-- .../top_n_flow/query.top_n_flow_network.dsl.ts | 2 +- .../query.top_n_flow_network_entities.dsl.ts | 2 +- .../factory/network/users/__mocks__/index.ts | 4 ++-- .../network/users/query.users_network.dsl.ts | 2 +- .../ueba/host_rules/query.host_rules.dsl.ts | 2 +- .../ueba/host_tactics/query.host_tactics.dsl.ts | 2 +- .../ueba/risk_score/query.risk_score.dsl.ts | 2 +- .../ueba/user_rules/query.user_rules.dsl.ts | 2 +- .../factory/events/all/query.events_all.dsl.ts | 2 +- .../details/query.events_details.dsl.test.ts | 4 ++-- .../events/details/query.events_details.dsl.ts | 2 +- .../timeline/factory/events/kpi/query.kpi.dsl.ts | 2 +- .../query.events_last_event_time.dsl.ts | 6 +++--- 94 files changed, 126 insertions(+), 126 deletions(-) diff --git a/src/plugins/data_views/server/fetcher/lib/es_api.test.js b/src/plugins/data_views/server/fetcher/lib/es_api.test.js index 2893fde671bb2..085add965b921 100644 --- a/src/plugins/data_views/server/fetcher/lib/es_api.test.js +++ b/src/plugins/data_views/server/fetcher/lib/es_api.test.js @@ -61,7 +61,7 @@ describe('server/index_patterns/service/lib/es_api', () => { expect(resp).toBe(football); }); - it('sets ignoreUnavailable and allowNoIndices params', async () => { + it('sets ignore_unavailable and allow_no_indices params', async () => { const getAlias = sinon.stub(); const callCluster = { indices: { @@ -149,7 +149,7 @@ describe('server/index_patterns/service/lib/es_api', () => { expect(resp).toBe(football); }); - it('sets ignoreUnavailable, allowNoIndices, and fields params', async () => { + it('sets ignore_unavailable, allow_no_indices, and fields params', async () => { const fieldCaps = sinon.stub(); const callCluster = { indices: { diff --git a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts index 3d4c428b14f11..75a86ae654d6c 100644 --- a/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts @@ -69,7 +69,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter { }; const esQuery = { - allowNoIndices: true, + allow_no_indices: true, index: resolvedLogSourceConfiguration.indices, ignore_unavailable: true, body: { @@ -139,7 +139,7 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter { ); const query = { - allowNoIndices: true, + allow_no_indices: true, index: resolvedLogSourceConfiguration.indices, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts index 1d5a84b93d22a..f2b7691646e48 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts @@ -14,7 +14,7 @@ export const checkValidNode = async ( id: string ): Promise => { const params = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, index: indexPattern, terminateAfter: 1, diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts index 025e243a242a2..e6f84e3a408dc 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts @@ -65,7 +65,7 @@ export const createLogEntryDatasetsQuery = ( }); const defaultRequestParameters = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, trackScores: false, trackTotalHits: false, diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts index 2c978e74229ec..48f889c529fa4 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts @@ -6,7 +6,7 @@ */ export const defaultRequestParameters = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, trackScores: false, trackTotalHits: false, diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts index 3274169a783ff..3f8d099cc463a 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts @@ -27,7 +27,7 @@ describe('createMetricsHostAnomaliesQuery', () => { pagination, }) ).toMatchObject({ - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, trackScores: false, trackTotalHits: false, diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts index 80762a012a934..573473f32c5a6 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts @@ -27,7 +27,7 @@ describe('createMetricsK8sAnomaliesQuery', () => { pagination, }) ).toMatchObject({ - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, trackScores: false, trackTotalHits: false, diff --git a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts index 8bd76249a232d..6edac66785d66 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts @@ -6,7 +6,7 @@ */ export const defaultRequestParameters = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, trackScores: false, trackTotalHits: false, diff --git a/x-pack/plugins/infra/server/lib/metrics/index.ts b/x-pack/plugins/infra/server/lib/metrics/index.ts index 517197591d606..d291dbf88b49a 100644 --- a/x-pack/plugins/infra/server/lib/metrics/index.ts +++ b/x-pack/plugins/infra/server/lib/metrics/index.ts @@ -47,7 +47,7 @@ export const query = async ( ]; const params = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, index: options.indexPattern, body: { diff --git a/x-pack/plugins/infra/server/lib/sources/has_data.ts b/x-pack/plugins/infra/server/lib/sources/has_data.ts index 71f32bcecd80b..d56512918f11a 100644 --- a/x-pack/plugins/infra/server/lib/sources/has_data.ts +++ b/x-pack/plugins/infra/server/lib/sources/has_data.ts @@ -10,7 +10,7 @@ import { ESSearchClient } from '../metrics/types'; export const hasData = async (index: string, client: ESSearchClient) => { const params = { index, - allowNoIndices: true, + allow_no_indices: true, terminate_after: 1, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts b/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts index c9c0b174b07ed..c721ca75ea978 100644 --- a/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts +++ b/x-pack/plugins/infra/server/routes/inventory_metadata/lib/get_cloud_metadata.ts @@ -40,7 +40,7 @@ export const getCloudMetadata = async ( } const metricQuery = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, index: sourceConfiguration.metricAlias, body: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts index 54f0fb7b5adc8..d9da7bce2246f 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_cloud_metric_metadata.ts @@ -26,7 +26,7 @@ export const getCloudMetricsMetadata = async ( timeRange: { from: number; to: number } ): Promise => { const metricQuery = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, index: sourceConfiguration.metricAlias, body: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts index 054dc558e9866..bfa0884bfe199 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_metric_metadata.ts @@ -32,7 +32,7 @@ export const getMetricMetadata = async ( ): Promise => { const fields = findInventoryFields(nodeType, sourceConfiguration.fields); const metricQuery = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, index: sourceConfiguration.metricAlias, body: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts index 9a57bdc8e6c64..06035ed40adf1 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts @@ -53,7 +53,7 @@ export const getNodeInfo = async ( const fields = findInventoryFields(nodeType, sourceConfiguration.fields); const timestampField = sourceConfiguration.fields.timestamp; const params = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, terminateAfter: 1, index: sourceConfiguration.metricAlias, diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts index 169c00adc5031..9bf809ba3b3f4 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts @@ -22,7 +22,7 @@ export const getPodNodeName = async ( const fields = findInventoryFields(nodeType, sourceConfiguration.fields); const timestampField = sourceConfiguration.fields.timestamp; const params = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, terminateAfter: 1, index: sourceConfiguration.metricAlias, diff --git a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts index da50e64b9bc8b..be25bbbf022ee 100644 --- a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts @@ -22,7 +22,7 @@ export const getDatasetForField = async ( timerange: { field: string; to: number; from: number } ) => { const params = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, terminateAfter: 1, index: indexPattern, diff --git a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts index a3e88bd6b9b2e..a2bf778d5016d 100644 --- a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/query_total_groupings.ts @@ -41,7 +41,7 @@ export const queryTotalGroupings = async ( } const params = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, index: options.indexPattern, body: { diff --git a/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts b/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts index 1495fe95e084a..3357b1a842183 100644 --- a/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts +++ b/x-pack/plugins/infra/server/utils/calculate_metric_interval.ts @@ -35,7 +35,7 @@ export const calculateMetricInterval = async ( from = options.timerange.to - inventoryModel.metrics.defaultTimeRangeInSeconds * 1000; } const query = { - allowNoIndices: true, + allow_no_indices: true, index: options.indexPattern, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts index 8c47a928373a5..5162475529792 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/all/query.all_actions.dsl.ts @@ -20,7 +20,7 @@ export const buildActionsQuery = ({ // const filter = [...createQueryFilterClauses(filterQuery)]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: '.fleet-actions', ignore_unavailable: true, body: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts index bc87a877f9785..41f2875b1d4c8 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/details/query.action_details.dsl.ts @@ -23,7 +23,7 @@ export const buildActionDetailsQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: '.fleet-actions', ignore_unavailable: true, body: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts index 9941780008693..109e260911933 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/actions/results/query.action_results.dsl.ts @@ -25,7 +25,7 @@ export const buildActionResultsQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: '.fleet-actions-results*', ignore_unavailable: true, body: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts index ec07b73993fae..314de574f0a70 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/agents/query.all_agents.dsl.ts @@ -21,7 +21,7 @@ export const buildAgentsQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: '.fleet-agents', ignore_unavailable: true, body: { diff --git a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts index 172f85dba6efd..59326d6c50155 100644 --- a/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts +++ b/x-pack/plugins/osquery/server/search_strategy/osquery/factory/results/query.all_results.dsl.ts @@ -36,7 +36,7 @@ export const buildResultsQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: `logs-${OSQUERY_INTEGRATION_NAME}.result*`, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts index e517c11668d6f..ea015ea145b3f 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/cti/event_enrichment/query.ts @@ -28,7 +28,7 @@ export const buildEventEnrichmentQuery: SecuritySolutionFactory { const parsedResponse = await parseEventEnrichmentResponse(options, response); const expectedInspect = expect.objectContaining({ - allowNoIndices: true, + allow_no_indices: true, body: { _source: false, fields: ['*'], diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts index 426b2859dff01..d6e456e706673 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/__mocks__/index.ts @@ -611,7 +611,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -783,7 +783,7 @@ export const mockBuckets: HostAggEsItem = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, track_total_hits: false, body: { aggregations: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts index 4dd8cb022efed..bc405e89bf7a6 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts.dsl.ts @@ -40,7 +40,7 @@ export const buildHostsQuery = ({ const agg = { host_count: { cardinality: { field: 'host.name' } } }; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts index 6e17f17f69ae8..94124bc9567b7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/all/query.all_hosts_entities.dsl.ts @@ -40,7 +40,7 @@ export const buildHostsQueryEntities = ({ const agg = { host_count: { cardinality: { field: 'host.name' } } }; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts index 29654a5abff67..bdc4755c6a02b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/__mocks__/index.ts @@ -2149,7 +2149,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -2371,7 +2371,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts index b884538179bdf..c88104745ba06 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query.dsl.ts @@ -61,7 +61,7 @@ export const buildQuery = ({ }; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts index 958c8809d659e..ab726b41ae01b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/authentications/dsl/query_entities.dsl.ts @@ -41,7 +41,7 @@ export const buildQueryEntities = ({ }; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts index 7d9b403eb2759..ec8c7d7ca6866 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/__mocks__/index.ts @@ -1301,7 +1301,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -1415,7 +1415,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts index 8eb29a44bf0f6..003149a9501bb 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/details/query.host_details.dsl.ts @@ -35,7 +35,7 @@ export const buildHostDetailsQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts index 377ca60020324..738a9db683728 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications.dsl.ts @@ -39,7 +39,7 @@ export const buildHostsKpiAuthenticationsQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts index e0b8612ec2d88..fd1104345babc 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/authentications/query.hosts_kpi_authentications_entities.dsl.ts @@ -28,7 +28,7 @@ export const buildHostsKpiAuthenticationsQueryEntities = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts index 97b2fd46c6313..ed1d0e8edb107 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts.dsl.ts @@ -28,7 +28,7 @@ export const buildHostsKpiHostsQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts index a5a9774eed023..785f6aa5b6980 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/hosts/query.hosts_kpi_hosts_entities.dsl.ts @@ -28,7 +28,7 @@ export const buildHostsKpiHostsQueryEntities = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts index 2b2c90dfefa7b..c875e23b523e5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips.dsl.ts @@ -28,7 +28,7 @@ export const buildHostsKpiUniqueIpsQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts index bb1e6d57f8410..e323de78a0459 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/kpi/unique_ips/query.hosts_kpi_unique_ips_entities.dsl.ts @@ -28,7 +28,7 @@ export const buildHostsKpiUniqueIpsQueryEntities = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts index 643cc6771ad89..54403f9c392e7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/__mocks__/index.ts @@ -124,7 +124,7 @@ export const formattedSearchStrategyFirstResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -190,7 +190,7 @@ export const formattedSearchStrategyLastResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -225,7 +225,7 @@ export const formattedSearchStrategyLastResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts index 72c7b686ecc7c..8f9f7462b9dcb 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/last_first_seen/query.first_or_last_seen_host.dsl.ts @@ -17,7 +17,7 @@ export const buildFirstOrLastSeenHostQuery = ({ const filter = [{ term: { 'host.name': hostName } }]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts index 8e879803cb9c7..85bce797f52ae 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/__mocks__/index.ts @@ -117,7 +117,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -330,7 +330,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts index e0b5750d9e848..92d194e78284b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/overview/query.overview_host.dsl.ts @@ -28,7 +28,7 @@ export const buildOverviewHostQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts index 4a8916a086fa9..5bbc9b7726002 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/risk_score/query.hosts_risk.dsl.ts @@ -32,7 +32,7 @@ export const buildHostsRiskScoreQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: false, + allow_no_indices: false, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts index ecae54e163525..2730465323c19 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/__mocks__/index.ts @@ -4300,7 +4300,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -4435,7 +4435,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts index c669ad5c03cdc..e87e344e22eca 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/hosts/uncommon_processes/dsl/query.dsl.ts @@ -48,7 +48,7 @@ export const buildQuery = ({ }; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts index b392369d9a62b..d5478dad15d50 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/__mocks__/index.ts @@ -41,7 +41,7 @@ export const formattedAlertsSearchStrategyResponse: MatrixHistogramStrategyRespo 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -127,7 +127,7 @@ export const formattedAlertsSearchStrategyResponse: MatrixHistogramStrategyRespo }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, track_total_hits: false, body: { aggregations: { @@ -209,7 +209,7 @@ export const formattedAnomaliesSearchStrategyResponse: MatrixHistogramStrategyRe 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -392,7 +392,7 @@ export const formattedAuthenticationsSearchStrategyResponse: MatrixHistogramStra 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -959,7 +959,7 @@ export const formattedEventsSearchStrategyResponse: MatrixHistogramStrategyRespo 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -1927,7 +1927,7 @@ export const formattedDnsSearchStrategyResponse: MatrixHistogramStrategyResponse dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts index 055bc320ab61a..4f6b910fbccf7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/__mocks__/index.ts @@ -36,7 +36,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts index e6d78038c5049..60df6023a13d0 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/alerts/query.alerts_histogram.dsl.ts @@ -83,7 +83,7 @@ export const buildAlertsHistogramQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts index 929e55f1fe199..700580655f1b0 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/__mocks__/index.ts @@ -36,7 +36,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts index 2bb9de8b08423..b82e7823fd847 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/anomalies/query.anomalies_histogram.dsl.ts @@ -64,7 +64,7 @@ export const buildAnomaliesHistogramQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts index 1a9582285ba50..b917da12c9ad7 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/__mocks__/index.ts @@ -35,7 +35,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts index 79b8ec63a901a..b16efcd8301e0 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram.dsl.ts @@ -76,7 +76,7 @@ export const buildAuthenticationsHistogramQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts index 7286657897d71..886dcf11123bd 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/authentications/query.authentications_histogram_entities.dsl.ts @@ -59,7 +59,7 @@ export const buildAuthenticationsHistogramQueryEntities = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts index 31c437e89dfee..d4e721a5ebe80 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/__mocks__/index.ts @@ -26,7 +26,7 @@ export const mockOptions = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts index 0296b0a6f9e4b..7a7b4b49d17c1 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/dns/query.dns_histogram.dsl.ts @@ -77,7 +77,7 @@ export const buildDnsHistogramQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts index f81f775b0f94b..d2ee38ddd66a8 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/__mocks__/index.ts @@ -40,7 +40,7 @@ export const expectedDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -95,7 +95,7 @@ export const expectedThresholdDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -152,7 +152,7 @@ export const expectedThresholdMissingFieldDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -197,7 +197,7 @@ export const expectedThresholdMissingFieldDsl = { }; export const expectedThresholdWithCardinalityDsl = { - allowNoIndices: true, + allow_no_indices: true, body: { aggregations: { eventActionGroup: { @@ -269,7 +269,7 @@ export const expectedThresholdWithGroupFieldsAndCardinalityDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -316,7 +316,7 @@ export const expectedThresholdWithGroupFieldsAndCardinalityDsl = { }; export const expectedThresholdGroupWithCardinalityDsl = { - allowNoIndices: true, + allow_no_indices: true, body: { aggregations: { eventActionGroup: { @@ -390,7 +390,7 @@ export const expectedIpIncludingMissingDataDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { @@ -453,7 +453,7 @@ export const expectedIpNotIncludingMissingDataDsl = { 'packetbeat-*', 'winlogbeat-*', ], - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts index c8819dcd830e5..91aeb50448d4e 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/matrix_histogram/events/query.events_histogram.dsl.ts @@ -152,7 +152,7 @@ export const buildEventsHistogramQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts index bf5c3b814f4cc..158b63e6e8455 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/__mocks__/index.ts @@ -304,7 +304,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -446,7 +446,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts index 94c7a155adc67..5684c7685231e 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/details/query.details_network.dsl.ts @@ -103,7 +103,7 @@ export const buildNetworkDetailsQuery = ({ ip, }: NetworkDetailsRequestOptions) => { const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts index eb097562666e1..f1bae35f53ebb 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/__mocks__/index.ts @@ -131,7 +131,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -203,7 +203,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts index 3597330602cf6..612d83e81660d 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/dns/query.dns_network.dsl.ts @@ -88,7 +88,7 @@ export const buildDnsQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts index c5cfeedb6dc05..f831b9f20e8ca 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/__mocks__/index.ts @@ -613,7 +613,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -671,7 +671,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts index d576c24768872..8882d17804261 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/http/query.http_network.dsl.ts @@ -36,7 +36,7 @@ export const buildHttpQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts index 368b2ca83ed3d..c0317772e5fa9 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kip_dns_entities.dsl.ts @@ -28,7 +28,7 @@ export const buildDnsQueryEntities = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts index aa0746944c845..8d27f7d289d03 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/dns/query.network_kpi_dns.dsl.ts @@ -56,7 +56,7 @@ export const buildDnsQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts index a2545ab8b57fa..4d5ca88fe383a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events.dsl.ts @@ -30,7 +30,7 @@ export const buildNetworkEventsQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts index 839bda22ce669..bb40da0a064fb 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/network_events/query.network_kpi_network_events_entities.dsl.ts @@ -28,7 +28,7 @@ export const buildNetworkEventsQueryEntities = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts index 45593bdecfdc1..eae7f7a29ce72 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes.dsl.ts @@ -56,7 +56,7 @@ export const buildTlsHandshakeQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts index d952657f43e7b..bd7a464e1a090 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/tls_handshakes/query.network_kpi_tls_handshakes_entities.dsl.ts @@ -28,7 +28,7 @@ export const buildTlsHandshakeQueryEntities = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts index 6f5a85f5832c6..3cb04caf5afe5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_flows/query.network_kpi_unique_flows.dsl.ts @@ -30,7 +30,7 @@ export const buildUniqueFlowsQuery = ({ const dslQuery = { index: defaultIndex, - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, track_total_hits: false, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts index bf3236095ffab..c915cd4fb58d6 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips.dsl.ts @@ -84,7 +84,7 @@ export const buildUniquePrivateIpsQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts index fb55260115322..922a082439807 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/kpi/unique_private_ips/query.network_kpi_unique_private_ips_entities.dsl.ts @@ -84,7 +84,7 @@ export const buildUniquePrivateIpsQueryEntities = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts index 77e4d71fded8a..0b5019d6fec9a 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/__mocks__/index.ts @@ -101,7 +101,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -206,7 +206,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, ignore_unavailable: true, index: [ 'apm-*-transaction*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts index b56ec4ed8ab9d..f911850c8cd94 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/overview/query.overview_network.dsl.ts @@ -28,7 +28,7 @@ export const buildOverviewNetworkQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts index d3c30abe75c40..c34ec2225ed95 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/__mocks__/index.ts @@ -59,7 +59,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -114,7 +114,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts index a4ff905305018..297643fe56952 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/tls/query.tls_network.dsl.ts @@ -75,7 +75,7 @@ export const buildNetworkTlsQuery = ({ const filter = ip ? [...defaultFilter, { term: { [`${flowTarget}.ip`]: ip } }] : defaultFilter; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts index 08cffcce1ef1a..490ade26ad2a5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/__mocks__/index.ts @@ -58,7 +58,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -118,7 +118,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts index 56105bf9c5aec..463d3c9b11bd2 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network.dsl.ts @@ -42,7 +42,7 @@ export const buildTopCountriesQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts index 59659629a144b..7f1d27db45d2d 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_countries/query.top_countries_network_entities.dsl.ts @@ -47,7 +47,7 @@ export const buildTopCountriesQueryEntities = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts index e6a4da56dc9ba..fa759661772d5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/__mocks__/index.ts @@ -810,7 +810,7 @@ export const formattedSearchStrategyResponse: NetworkTopNFlowStrategyResponse = dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -878,7 +878,7 @@ export const formattedSearchStrategyResponse: NetworkTopNFlowStrategyResponse = }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts index 6be0160cd1d6c..52efb50f00b4b 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network.dsl.ts @@ -42,7 +42,7 @@ export const buildTopNFlowQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts index 5a4a685bedc23..d11a2debf3cff 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/top_n_flow/query.top_n_flow_network_entities.dsl.ts @@ -47,7 +47,7 @@ export const buildTopNFlowQueryEntities = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts index 56a54ab39b2f4..acb98b7e347bc 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/__mocks__/index.ts @@ -119,7 +119,7 @@ export const formattedSearchStrategyResponse = { dsl: [ JSON.stringify( { - allowNoIndices: true, + allow_no_indices: true, index: [ 'apm-*-transaction*', 'traces-apm*', @@ -175,7 +175,7 @@ export const formattedSearchStrategyResponse = { }; export const expectedDsl = { - allowNoIndices: true, + allow_no_indices: true, track_total_hits: false, body: { aggs: { diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts index f93ce5a4d8047..0c35c967c2ac5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/network/users/query.users_network.dsl.ts @@ -34,7 +34,7 @@ export const buildUsersQuery = ({ ]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: false, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts index 988ea5752c8f3..d2aeb63b743f5 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_rules/query.host_rules.dsl.ts @@ -30,7 +30,7 @@ export const buildHostRulesQuery = ({ ]; return { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, // can stop getting this from sourcerer and assume default detections index if we want ignore_unavailable: true, track_total_hits: true, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts index bdc73d01bd283..f9bbcc8077278 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/host_tactics/query.host_tactics.dsl.ts @@ -30,7 +30,7 @@ export const buildHostTacticsQuery = ({ ]; return { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, // can stop getting this from sourcerer and assume default detections index if we want ignore_unavailable: true, track_total_hits: true, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts index d48535b622248..90d2e51c8ff9e 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/risk_score/query.risk_score.dsl.ts @@ -31,7 +31,7 @@ export const buildRiskScoreQuery = ({ ]; return { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, track_total_hits: true, diff --git a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts index 7e042931b2606..d3111eed4aef8 100644 --- a/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts +++ b/x-pack/plugins/security_solution/server/search_strategy/security_solution/factory/ueba/user_rules/query.user_rules.dsl.ts @@ -30,7 +30,7 @@ export const buildUserRulesQuery = ({ ]; return { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, // can stop getting this from sourcerer and assume default detections index if we want ignore_unavailable: true, track_total_hits: true, diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts index 53932d5ca7ec5..3653cb60d3653 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/all/query.events_all.dsl.ts @@ -63,7 +63,7 @@ export const buildTimelineEventsAllQuery = ({ }); const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.test.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.test.ts index 3572a2b9c497e..9066861cdb818 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.test.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.test.ts @@ -22,7 +22,7 @@ describe('buildTimelineDetailsQuery', () => { expect(query).toMatchInlineSnapshot(` Object { - "allowNoIndices": true, + "allow_no_indices": true, "body": Object { "_source": true, "docvalue_fields": Array [ @@ -53,7 +53,7 @@ describe('buildTimelineDetailsQuery', () => { }, }, }, - "ignoreUnavailable": true, + "ignore_unavailable": true, "index": ".siem-signals-default", "size": 1, } diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts index 9a070070dd80e..70b592440468e 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/details/query.events_details.dsl.ts @@ -33,7 +33,7 @@ export const buildTimelineDetailsQuery = ( }; return { - allowNoIndices: true, + allow_no_indices: true, index: indexName, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts index 6110ebbd622dd..dd87ef177bfe6 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/kpi/query.kpi.dsl.ts @@ -44,7 +44,7 @@ export const buildTimelineKpiQuery = ({ const filter = [...filterClause, ...getTimerangeFilter(timerange), { match_all: {} }]; const dslQuery = { - allowNoIndices: true, + allow_no_indices: true, index: defaultIndex, ignore_unavailable: true, body: { diff --git a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts index b31c4b4662c46..4ff86c9a9f290 100644 --- a/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts +++ b/x-pack/plugins/timelines/server/search_strategy/timeline/factory/events/last_event_time/query.events_last_event_time.dsl.ts @@ -38,7 +38,7 @@ export const buildLastEventTimeQuery = ({ case LastEventIndexKey.ipDetails: if (details.ip) { return { - allowNoIndices: true, + allow_no_indices: true, index: indicesToQuery.network, ignore_unavailable: true, track_total_hits: false, @@ -61,7 +61,7 @@ export const buildLastEventTimeQuery = ({ case LastEventIndexKey.hostDetails: if (details.hostName) { return { - allowNoIndices: true, + allow_no_indices: true, index: indicesToQuery.hosts, ignore_unavailable: true, track_total_hits: false, @@ -85,7 +85,7 @@ export const buildLastEventTimeQuery = ({ case LastEventIndexKey.network: case LastEventIndexKey.ueba: return { - allowNoIndices: true, + allow_no_indices: true, index: indicesToQuery[indexKey], ignore_unavailable: true, track_total_hits: false, From eb1d72c1db49bad6857a280b869a095703e605bc Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 10:41:41 +0200 Subject: [PATCH 088/172] trackScores --> track_scores --- .../domains/log_entries_domain/queries/log_entry_datasets.ts | 2 +- x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts | 2 +- .../server/lib/infra_ml/queries/metrics_host_anomalies.test.ts | 2 +- .../server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts | 2 +- x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts index e6f84e3a408dc..b3a841e14080e 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts @@ -67,7 +67,7 @@ export const createLogEntryDatasetsQuery = ( const defaultRequestParameters = { allow_no_indices: true, ignore_unavailable: true, - trackScores: false, + track_scores: false, trackTotalHits: false, }; diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts index 48f889c529fa4..5df4b48be5be9 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts @@ -8,7 +8,7 @@ export const defaultRequestParameters = { allow_no_indices: true, ignore_unavailable: true, - trackScores: false, + track_scores: false, trackTotalHits: false, }; diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts index 3f8d099cc463a..ff14a8ef4bb2c 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts @@ -29,7 +29,7 @@ describe('createMetricsHostAnomaliesQuery', () => { ).toMatchObject({ allow_no_indices: true, ignore_unavailable: true, - trackScores: false, + track_scores: false, trackTotalHits: false, body: { query: { diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts index 573473f32c5a6..60d72983b8b87 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts @@ -29,7 +29,7 @@ describe('createMetricsK8sAnomaliesQuery', () => { ).toMatchObject({ allow_no_indices: true, ignore_unavailable: true, - trackScores: false, + track_scores: false, trackTotalHits: false, body: { query: { diff --git a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts index 6edac66785d66..ea53bfe6ceea1 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts @@ -8,7 +8,7 @@ export const defaultRequestParameters = { allow_no_indices: true, ignore_unavailable: true, - trackScores: false, + track_scores: false, trackTotalHits: false, }; From e0582a6c23e007634017e5ad935669014d949784 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 10:44:50 +0200 Subject: [PATCH 089/172] trackTotalHits --> track_total_hits --- .../domains/log_entries_domain/queries/log_entry_datasets.ts | 2 +- x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts | 2 +- .../server/lib/infra_ml/queries/metrics_host_anomalies.test.ts | 2 +- .../server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts | 2 +- x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts index b3a841e14080e..4386b6ccef9c1 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/queries/log_entry_datasets.ts @@ -68,7 +68,7 @@ const defaultRequestParameters = { allow_no_indices: true, ignore_unavailable: true, track_scores: false, - trackTotalHits: false, + track_total_hits: false, }; const compositeDatasetKeyRT = rt.type({ diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts index 5df4b48be5be9..594dc3371f3a2 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/common.ts @@ -9,7 +9,7 @@ export const defaultRequestParameters = { allow_no_indices: true, ignore_unavailable: true, track_scores: false, - trackTotalHits: false, + track_total_hits: false, }; export const createJobIdFilters = (jobId: string) => [ diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts index ff14a8ef4bb2c..5e7cb78790de0 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_host_anomalies.test.ts @@ -30,7 +30,7 @@ describe('createMetricsHostAnomaliesQuery', () => { allow_no_indices: true, ignore_unavailable: true, track_scores: false, - trackTotalHits: false, + track_total_hits: false, body: { query: { bool: { diff --git a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts index 60d72983b8b87..959b20a482544 100644 --- a/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts +++ b/x-pack/plugins/infra/server/lib/infra_ml/queries/metrics_k8s_anomalies.test.ts @@ -30,7 +30,7 @@ describe('createMetricsK8sAnomaliesQuery', () => { allow_no_indices: true, ignore_unavailable: true, track_scores: false, - trackTotalHits: false, + track_total_hits: false, body: { query: { bool: { diff --git a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts index ea53bfe6ceea1..b05e4ce00fe9c 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/queries/common.ts @@ -9,7 +9,7 @@ export const defaultRequestParameters = { allow_no_indices: true, ignore_unavailable: true, track_scores: false, - trackTotalHits: false, + track_total_hits: false, }; export const createJobIdFilters = (jobId: string) => [ From 15d913f7bf58a5e050d9e790ded80355adeeec4c Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 11:25:27 +0200 Subject: [PATCH 090/172] fix es-arcives --- .../docs/generate_doc_records_stream.test.ts | 8 +-- .../lib/indices/create_index_stream.test.ts | 1 + .../indices/generate_index_records_stream.ts | 50 +++++++++++-------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts index da7ed4c81b666..2902812f51493 100644 --- a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts +++ b/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.test.ts @@ -99,10 +99,8 @@ it('transforms each input index to a stream of docs using scrollSearch helper', Array [ Object { "_source": "true", - "body": Object { - "query": undefined, - }, "index": "bar", + "query": undefined, "rest_total_hits_as_int": true, "scroll": "1m", "size": 1000, @@ -116,10 +114,8 @@ it('transforms each input index to a stream of docs using scrollSearch helper', Array [ Object { "_source": "true", - "body": Object { - "query": undefined, - }, "index": "foo", + "query": undefined, "rest_total_hits_as_int": true, "scroll": "1m", "size": 1000, diff --git a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.test.ts b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.test.ts index 28c8ccd1c28a8..3a8180b724e07 100644 --- a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.test.ts +++ b/packages/kbn-es-archiver/src/lib/indices/create_index_stream.test.ts @@ -71,6 +71,7 @@ describe('esArchiver: createCreateIndexStream()', () => { "ignore": Array [ 404, ], + "meta": true, }, ], ] diff --git a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts b/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts index 6dc5b04e7f31a..d647a4fe5f501 100644 --- a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts +++ b/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts @@ -17,35 +17,41 @@ export function createGenerateIndexRecordsStream(client: Client, stats: Stats) { readableObjectMode: true, async transform(indexOrAlias, enc, callback) { try { - const resp = await client.indices.get( - { - index: indexOrAlias, - filter_path: [ - '*.settings', - '*.mappings', - // remove settings that aren't really settings - '-*.settings.index.creation_date', - '-*.settings.index.uuid', - '-*.settings.index.version', - '-*.settings.index.provided_name', - '-*.settings.index.frozen', - '-*.settings.index.search.throttled', - '-*.settings.index.query', - '-*.settings.index.routing', - ], - }, - { - headers: ES_CLIENT_HEADERS, - } - ); + const resp = ( + await client.indices.get( + { + index: indexOrAlias, + filter_path: [ + '*.settings', + '*.mappings', + // remove settings that aren't really settings + '-*.settings.index.creation_date', + '-*.settings.index.uuid', + '-*.settings.index.version', + '-*.settings.index.provided_name', + '-*.settings.index.frozen', + '-*.settings.index.search.throttled', + '-*.settings.index.query', + '-*.settings.index.routing', + ], + }, + { + headers: ES_CLIENT_HEADERS, + meta: true, + } + ) + ).body; for (const [index, { settings, mappings }] of Object.entries(resp)) { const { - [index]: { aliases }, + body: { + [index]: { aliases }, + }, } = await client.indices.getAlias( { index }, { headers: ES_CLIENT_HEADERS, + meta: true, } ); From f4cf33496f2adb29775ebf02e6e7b3b2bf82f9f5 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 12:09:22 +0200 Subject: [PATCH 091/172] fix data plugin crashes --- .../server/search/strategies/es_search/es_search_strategy.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts index 1c2d333f5bfc6..097e099bf2997 100644 --- a/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts +++ b/src/plugins/data/server/search/strategies/es_search/es_search_strategy.ts @@ -38,10 +38,13 @@ export const esSearchStrategyProvider = ( const search = async () => { try { const config = await config$.pipe(first()).toPromise(); + // @ts-expect-error params fall back to any, but should be valid SearchRequest params + const { terminateAfter, ...requestParams } = request.params ?? {}; const params = { ...(await getDefaultSearchParams(uiSettingsClient)), ...getShardTimeout(config), - ...request.params, + ...(terminateAfter ? { terminate_after: terminateAfter } : {}), + ...requestParams, }; const { body } = await esClient.asCurrentUser.search(params, { signal: abortSignal, From 68d6ea391a040999bef576e3c91d4a8ed95349be Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 12:10:46 +0200 Subject: [PATCH 092/172] fix watcher test utils --- .../stack_functional_integration/apps/reporting/util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/test/stack_functional_integration/apps/reporting/util.js b/x-pack/test/stack_functional_integration/apps/reporting/util.js index 8f5356dd741ed..d3dc7967d1f54 100644 --- a/x-pack/test/stack_functional_integration/apps/reporting/util.js +++ b/x-pack/test/stack_functional_integration/apps/reporting/util.js @@ -11,7 +11,7 @@ export const pretty = (x) => JSON.stringify(x, null, 2); export const buildUrl = ({ protocol, auth, hostname, port }) => new URL(`${protocol}://${auth}@${hostname}:${port}`); export const putWatcher = async (watch, id, body, client, log) => { - const putWatchResponse = await client.watcher.putWatch({ ...watch, body }); + const putWatchResponse = await client.watcher.putWatch({ ...watch, body }, { meta: true }); log.debug(`# putWatchResponse \n${pretty(putWatchResponse)}`); expect(putWatchResponse.body._id).to.eql(id); expect(putWatchResponse.statusCode).to.eql('201'); @@ -26,7 +26,7 @@ export const getWatcher = async (watch, id, client, log, common, tryForTime) => await watcherHistory(id, client, log); - const getWatchResponse = await client.watcher.getWatch(watch); + const getWatchResponse = await client.watcher.getWatch(watch, { meta: true }); log.debug(`\n getWatchResponse: ${JSON.stringify(getWatchResponse)}`); expect(getWatchResponse.body._id).to.eql(id); expect(getWatchResponse.body._version).to.be.above(1); @@ -44,14 +44,14 @@ export const getWatcher = async (watch, id, client, log, common, tryForTime) => ); }; export const deleteWatcher = async (watch, id, client, log) => { - const deleteResponse = await client.watcher.deleteWatch(watch); + const deleteResponse = await client.watcher.deleteWatch(watch, { meta: true }); log.debug('\nDelete Response=' + pretty(deleteResponse) + '\n'); expect(deleteResponse.body._id).to.eql(id); expect(deleteResponse.body.found).to.eql(true); expect(deleteResponse.statusCode).to.eql('200'); }; async function watcherHistory(watchId, client, log) { - const { body } = await client.search({ + const body = await client.search({ index: '.watcher-history*', body: { query: { From 3fbdad6061bd290405cc70b154cab463bc46bb59 Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Tue, 19 Oct 2021 13:54:04 +0200 Subject: [PATCH 093/172] rollback unnecessary changes --- .../__jest__/client_integration/policy_edit.test.ts | 2 +- .../snapshot_restore/server/routes/api/validate_schemas.ts | 4 ++-- .../apis/management/snapshot_restore/snapshot_restore.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts b/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts index d1386ca34be8b..7d5d605b216bc 100644 --- a/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts +++ b/x-pack/plugins/snapshot_restore/__jest__/client_integration/policy_edit.test.ts @@ -153,7 +153,7 @@ describe('', () => { schedule, repository, config: { - ignore_unavailable: true, + ignoreUnavailable: true, }, retention: { ...retention, diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts b/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts index 9decff4b120c2..af31466c2cefe 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts @@ -13,7 +13,7 @@ export const nameParameterSchema = schema.object({ const snapshotConfigSchema = schema.object({ indices: schema.maybe(schema.oneOf([schema.string(), schema.arrayOf(schema.string())])), - ignore_unavailable: schema.maybe(schema.boolean()), + ignoreUnavailable: schema.maybe(schema.boolean()), includeGlobalState: schema.maybe(schema.boolean()), partial: schema.maybe(schema.boolean()), metadata: schema.maybe(schema.recordOf(schema.string(), schema.string())), @@ -175,6 +175,6 @@ export const restoreSettingsSchema = schema.object({ partial: schema.maybe(schema.boolean()), indexSettings: schema.maybe(schema.string()), ignoreIndexSettings: schema.maybe(schema.arrayOf(schema.string())), - ignore_unavailable: schema.maybe(schema.boolean()), + ignoreUnavailable: schema.maybe(schema.boolean()), includeAliases: schema.maybe(schema.boolean()), }); diff --git a/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts b/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts index c0d93185c5fc1..a6ac2d057c84e 100644 --- a/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts +++ b/x-pack/test/api_integration/apis/management/snapshot_restore/snapshot_restore.ts @@ -62,7 +62,7 @@ export default function ({ getService }: FtrProviderContext) { repository: REPO_NAME, config: { indices: ['my_index'], - ignore_unavailable: true, + ignoreUnavailable: true, partial: false, metadata: { meta: 'my_meta', @@ -141,7 +141,7 @@ export default function ({ getService }: FtrProviderContext) { repository: REPO_NAME, config: { indices: ['my_index'], - ignore_unavailable: true, + ignoreUnavailable: true, partial: false, metadata: { meta: 'my_meta', From e466e2fc714b8e5be3f11d3874d36c734e99be2f Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 15:28:14 +0200 Subject: [PATCH 094/172] fix another problem in es-archiver --- packages/kbn-es-archiver/src/lib/indices/delete_index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts b/packages/kbn-es-archiver/src/lib/indices/delete_index.ts index a0aee1d60af47..3bba96d32ba95 100644 --- a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts +++ b/packages/kbn-es-archiver/src/lib/indices/delete_index.ts @@ -120,7 +120,7 @@ export async function waitForSnapshotCompletion( return inProgressSnapshots; }; - const { body: repositoryMap } = await client.snapshot.getRepository({} as any); + const repositoryMap = await client.snapshot.getRepository({}); for (const repository of Object.keys(repositoryMap)) { const allInProgress = await getInProgressSnapshots(repository); const found = allInProgress?.find((s: any) => s.indices.includes(index)); From 2cf1577a68d19e934464fcd6a3d31e4cf060f2d3 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 15:41:02 +0200 Subject: [PATCH 095/172] fix scroll. for whatever reason scroll fails when request scroll_id in body --- .../server/export_types/csv/generate_csv/hit_iterator.ts | 6 ++---- .../csv_searchsource/generate_csv/generate_csv.ts | 6 ++---- .../lib/fetch_all_from_scroll/fetch_all_from_scroll.ts | 6 ++---- x-pack/test/functional/apps/watcher/index.js | 1 - 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts index a1bf7fbb0d264..028dbb65764a6 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts @@ -64,10 +64,8 @@ export function createHitIterator(logger: LevelLogger) { logger.debug('executing scroll request'); return parseResponse( await elasticsearchClient.scroll({ - body: { - scroll_id: scrollId, - scroll: scrollSettings.duration, - }, + scroll_id: scrollId, + scroll: scrollSettings.duration, }) ); } diff --git a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts index 5664d83f1ead8..8830b874fd18a 100644 --- a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts @@ -109,10 +109,8 @@ export class CsvGenerator { this.logger.debug(`executing scroll request`); const results = ( await this.clients.es.asCurrentUser.scroll({ - body: { - scroll: scrollSettings.duration, - scroll_id: scrollId, - }, + scroll: scrollSettings.duration, + scroll_id: scrollId, }) ).body; return results; diff --git a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts index cc33a3dab1ef3..7f6bc5d0af22a 100644 --- a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts +++ b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.ts @@ -23,10 +23,8 @@ export function fetchAllFromScroll( return dataClient.asCurrentUser .scroll({ - body: { - scroll: ES_SCROLL_SETTINGS.KEEPALIVE, - scroll_id: scrollId!, - }, + scroll: ES_SCROLL_SETTINGS.KEEPALIVE, + scroll_id: scrollId!, }) .then(({ body: innerResponse }) => { return fetchAllFromScroll(innerResponse, dataClient, hits); diff --git a/x-pack/test/functional/apps/watcher/index.js b/x-pack/test/functional/apps/watcher/index.js index 49fcdf65fcdcd..db5f52d2121e8 100644 --- a/x-pack/test/functional/apps/watcher/index.js +++ b/x-pack/test/functional/apps/watcher/index.js @@ -9,7 +9,6 @@ export default function ({ loadTestFile }) { describe('watcher app', function () { this.tags(['ciGroup1', 'includeFirefox']); - //loadTestFile(require.resolve('./management')); loadTestFile(require.resolve('./watcher_test')); }); } From 4ba25f3d52efd2fa27944aa546fe5d552646b356 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 19 Oct 2021 17:11:09 +0200 Subject: [PATCH 096/172] add meta: true in kbn-securitysolution-es-utils --- .../src/create_boostrap_index/index.ts | 17 +-- .../src/delete_all_index/index.ts | 2 +- .../src/delete_policy/index.ts | 2 +- .../src/delete_template/index.ts | 9 +- .../src/get_index_aliases/index.ts | 9 +- .../src/get_index_count/index.ts | 9 +- .../src/get_index_exists/index.ts | 17 +-- .../src/get_template_exists/index.ts | 9 +- .../src/read_index/index.ts | 9 +- .../src/read_privileges/index.ts | 111 +++++++++--------- .../src/set_policy/index.ts | 11 +- .../src/set_template/index.ts | 11 +- 12 files changed, 123 insertions(+), 93 deletions(-) diff --git a/packages/kbn-securitysolution-es-utils/src/create_boostrap_index/index.ts b/packages/kbn-securitysolution-es-utils/src/create_boostrap_index/index.ts index 6a177f5caac21..973fe27ad7537 100644 --- a/packages/kbn-securitysolution-es-utils/src/create_boostrap_index/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/create_boostrap_index/index.ts @@ -16,15 +16,18 @@ export const createBootstrapIndex = async ( index: string ): Promise => { return ( - await esClient.indices.create({ - index: `${index}-000001`, - body: { - aliases: { - [index]: { - is_write_index: true, + await esClient.indices.create( + { + index: `${index}-000001`, + body: { + aliases: { + [index]: { + is_write_index: true, + }, }, }, }, - }) + { meta: true } + ) ).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/delete_all_index/index.ts b/packages/kbn-securitysolution-es-utils/src/delete_all_index/index.ts index 580c104752aea..2ff93f668ea27 100644 --- a/packages/kbn-securitysolution-es-utils/src/delete_all_index/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/delete_all_index/index.ts @@ -25,7 +25,7 @@ export const deleteAllIndex = async ( { index: pattern, }, - { ignore: [404] } + { ignore: [404], meta: true } ); // @ts-expect-error status doesn't exist on response diff --git a/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts b/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts index 62592c9176d48..5d6989fd9e57f 100644 --- a/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts @@ -12,5 +12,5 @@ export const deletePolicy = async ( esClient: ElasticsearchClient, policy: string ): Promise => { - return (await esClient.ilm.deleteLifecycle({ policy })).body; + return (await esClient.ilm.deleteLifecycle({ policy }, { meta: true })).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/delete_template/index.ts b/packages/kbn-securitysolution-es-utils/src/delete_template/index.ts index 86565a0c43b3a..92eeadfff860a 100644 --- a/packages/kbn-securitysolution-es-utils/src/delete_template/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/delete_template/index.ts @@ -13,8 +13,11 @@ export const deleteTemplate = async ( name: string ): Promise => { return ( - await esClient.indices.deleteTemplate({ - name, - }) + await esClient.indices.deleteTemplate( + { + name, + }, + { meta: true } + ) ).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/get_index_aliases/index.ts b/packages/kbn-securitysolution-es-utils/src/get_index_aliases/index.ts index ba00c1144edfc..9a0d0fed1b63e 100644 --- a/packages/kbn-securitysolution-es-utils/src/get_index_aliases/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/get_index_aliases/index.ts @@ -39,9 +39,12 @@ export const getIndexAliases = async ({ esClient: ElasticsearchClient; alias: string; }): Promise => { - const response = await esClient.indices.getAlias({ - name: alias, - }); + const response = await esClient.indices.getAlias( + { + name: alias, + }, + { meta: true } + ); return Object.keys(response.body).map((index) => ({ alias, diff --git a/packages/kbn-securitysolution-es-utils/src/get_index_count/index.ts b/packages/kbn-securitysolution-es-utils/src/get_index_count/index.ts index b1dcd4fd0ad9b..59cae505bfded 100644 --- a/packages/kbn-securitysolution-es-utils/src/get_index_count/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/get_index_count/index.ts @@ -23,9 +23,12 @@ export const getIndexCount = async ({ esClient: ElasticsearchClient; index: string; }): Promise => { - const response = await esClient.count<{ count: number }>({ - index, - }); + const response = await esClient.count<{ count: number }>( + { + index, + }, + { meta: true } + ); return response.body.count; }; diff --git a/packages/kbn-securitysolution-es-utils/src/get_index_exists/index.ts b/packages/kbn-securitysolution-es-utils/src/get_index_exists/index.ts index 9208773048474..50ba298d10259 100644 --- a/packages/kbn-securitysolution-es-utils/src/get_index_exists/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/get_index_exists/index.ts @@ -13,14 +13,17 @@ export const getIndexExists = async ( index: string ): Promise => { try { - const { body: response } = await esClient.search({ - index, - size: 0, - allow_no_indices: true, - body: { - terminate_after: 1, + const { body: response } = await esClient.search( + { + index, + size: 0, + allow_no_indices: true, + body: { + terminate_after: 1, + }, }, - }); + { meta: true } + ); return response._shards.total > 0; } catch (err) { if (err.body != null && err.body.status === 404) { diff --git a/packages/kbn-securitysolution-es-utils/src/get_template_exists/index.ts b/packages/kbn-securitysolution-es-utils/src/get_template_exists/index.ts index 72a3a93654482..a310d1d6e9e0e 100644 --- a/packages/kbn-securitysolution-es-utils/src/get_template_exists/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/get_template_exists/index.ts @@ -13,8 +13,11 @@ export const getTemplateExists = async ( template: string ): Promise => { return ( - await esClient.indices.existsTemplate({ - name: template, - }) + await esClient.indices.existsTemplate( + { + name: template, + }, + { meta: true } + ) ).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/read_index/index.ts b/packages/kbn-securitysolution-es-utils/src/read_index/index.ts index 206a4208b2ecc..a1112f8fceb64 100644 --- a/packages/kbn-securitysolution-es-utils/src/read_index/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/read_index/index.ts @@ -9,7 +9,10 @@ import type { ElasticsearchClient } from '../elasticsearch_client'; export const readIndex = async (esClient: ElasticsearchClient, index: string): Promise => { - return esClient.indices.get({ - index, - }); + return esClient.indices.get( + { + index, + }, + { meta: true } + ); }; diff --git a/packages/kbn-securitysolution-es-utils/src/read_privileges/index.ts b/packages/kbn-securitysolution-es-utils/src/read_privileges/index.ts index 772a6afa18c95..614eb55297980 100644 --- a/packages/kbn-securitysolution-es-utils/src/read_privileges/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/read_privileges/index.ts @@ -13,60 +13,63 @@ export const readPrivileges = async ( index: string ): Promise => { return ( - await esClient.security.hasPrivileges({ - body: { - cluster: [ - 'all', - 'create_snapshot', - 'manage', - 'manage_api_key', - 'manage_ccr', - 'manage_transform', - 'manage_ilm', - 'manage_index_templates', - 'manage_ingest_pipelines', - 'manage_ml', - 'manage_own_api_key', - 'manage_pipeline', - 'manage_rollup', - 'manage_saml', - 'manage_security', - 'manage_token', - 'manage_watcher', - 'monitor', - 'monitor_transform', - 'monitor_ml', - 'monitor_rollup', - 'monitor_watcher', - 'read_ccr', - 'read_ilm', - 'transport_client', - ], - index: [ - { - names: [index], - privileges: [ - 'all', - 'create', - 'create_doc', - 'create_index', - 'delete', - 'delete_index', - 'index', - 'manage', - 'maintenance', - 'manage_follow_index', - 'manage_ilm', - 'manage_leader_index', - 'monitor', - 'read', - 'read_cross_cluster', - 'view_index_metadata', - 'write', - ], - }, - ], + await esClient.security.hasPrivileges( + { + body: { + cluster: [ + 'all', + 'create_snapshot', + 'manage', + 'manage_api_key', + 'manage_ccr', + 'manage_transform', + 'manage_ilm', + 'manage_index_templates', + 'manage_ingest_pipelines', + 'manage_ml', + 'manage_own_api_key', + 'manage_pipeline', + 'manage_rollup', + 'manage_saml', + 'manage_security', + 'manage_token', + 'manage_watcher', + 'monitor', + 'monitor_transform', + 'monitor_ml', + 'monitor_rollup', + 'monitor_watcher', + 'read_ccr', + 'read_ilm', + 'transport_client', + ], + index: [ + { + names: [index], + privileges: [ + 'all', + 'create', + 'create_doc', + 'create_index', + 'delete', + 'delete_index', + 'index', + 'manage', + 'maintenance', + 'manage_follow_index', + 'manage_ilm', + 'manage_leader_index', + 'monitor', + 'read', + 'read_cross_cluster', + 'view_index_metadata', + 'write', + ], + }, + ], + }, }, - }) + { meta: true } + ) ).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts b/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts index f6c2dcf7c3c3a..06176bf07d1d7 100644 --- a/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts @@ -13,9 +13,12 @@ export const setPolicy = async ( body: Record ): Promise => { return ( - await esClient.ilm.putLifecycle({ - policy, - body, - }) + await esClient.ilm.putLifecycle( + { + policy, + body, + }, + { meta: true } + ) ).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/set_template/index.ts b/packages/kbn-securitysolution-es-utils/src/set_template/index.ts index 20f6fd5719d51..7e1d6a4fb0a1e 100644 --- a/packages/kbn-securitysolution-es-utils/src/set_template/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/set_template/index.ts @@ -14,9 +14,12 @@ export const setTemplate = async ( body: Record ): Promise => { return ( - await esClient.indices.putTemplate({ - name, - body, - }) + await esClient.indices.putTemplate( + { + name, + body, + }, + { meta: true } + ) ).body; }; From fb3a12d655ae11d6277c530b584f47d310b1ecd3 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 09:40:49 +0200 Subject: [PATCH 097/172] bump client to canary 25 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4d0112d202079..40b924b9ca0a7 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "37.0.0", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.24", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.25", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.0.0", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index d409ab4290bbc..79b5cc11b7c51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,10 +2379,10 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.24": - version "8.0.0-canary.24" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.24.tgz#a87c79b8e08d63882c9711220bc99cdec69115bc" - integrity sha512-SsTooVXwuLIvMuj3QU8JxbXkHT8c30pilIwzpRBMVpeO0WeYS5BZb9DPgXBt3h91oqDToOstZjGoJXQPRWGpKw== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.25": + version "8.0.0-canary.25" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.25.tgz#a8edb0509dba1b1fd19b7b89dd3d31cf847cd6ca" + integrity sha512-iOBKwbwnh/bV8U2X84z7oZUnAROkrxKI33aZPgrlIQujDMYkAn7e0ABAJNP5KGANIvEJ31T2UQmUE4PUAijpEA== dependencies: "@elastic/transport" "^0.0.9" tslib "^2.3.0" From a7a03f6cca046909931facb22b2623318ce8d9db Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 10:27:50 +0200 Subject: [PATCH 098/172] fix errors in accordance with the es client spec --- .../elasticsearch/transform/transform.test.ts | 2 -- .../api/policies/register_create_route.ts | 2 +- .../api/policies/register_delete_route.ts | 2 +- .../register_fetch_route.ts | 2 +- .../lib/store/ilm_policy_manager/constants.ts | 2 -- .../ilm_policy_manager/ilm_policy_manager.ts | 4 ++-- .../reporting/server/lib/store/store.test.ts | 4 ++-- .../resource_installer.ts | 7 +++--- .../migrations/migration_cleanup.ts | 5 ++-- .../server/routes/api/repositories.ts | 24 +++++++------------ .../server/routes/api/snapshots.ts | 2 +- .../apps/index_lifecycle_management.ts | 4 ++-- .../snapshot_restore/lib/elasticsearch.ts | 2 +- .../apis/epm/update_assets.ts | 2 +- .../index_lifecycle_management/home_page.ts | 2 +- .../apps/snapshot_restore/home_page.ts | 4 ++-- .../ilm_migration_apis.ts | 5 ++-- 17 files changed, 31 insertions(+), 44 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts index 23f32ca772fb8..5f6f64576ad64 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/transform/transform.test.ts @@ -102,7 +102,6 @@ describe('test transform install', () => { ); esClient.transform.getTransform.mockReturnValueOnce( - // @ts-expect-error Transform is not valid elasticsearchClientMock.createSuccessTransportRequestPromise({ count: 1, transforms: [ @@ -387,7 +386,6 @@ describe('test transform install', () => { ); esClient.transform.getTransform.mockReturnValueOnce( - // @ts-expect-error Transform is not valid elasticsearchClientMock.createSuccessTransportRequestPromise({ count: 1, transforms: [ diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts index bc27a3b909c85..5ac37f4eeb215 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts @@ -21,7 +21,7 @@ async function createPolicy( ignore: [404], }; - return client.ilm.putLifecycle({ policy: name, body }, options); + return client.ilm.putLifecycle({ name, body }, options); } /** diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts index 72768a1540adc..eed36962a78e5 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts @@ -17,7 +17,7 @@ async function deletePolicies(client: ElasticsearchClient, policyName: string): ignore: [404], }; - return client.ilm.deleteLifecycle({ policy: policyName }, options); + return client.ilm.deleteLifecycle({ name: policyName }, options); } const paramsSchema = schema.object({ diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/snapshot_repositories/register_fetch_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/snapshot_repositories/register_fetch_route.ts index f1fb987c41911..8787be8e936ba 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/snapshot_repositories/register_fetch_route.ts +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/snapshot_repositories/register_fetch_route.ts @@ -29,7 +29,7 @@ export const registerFetchRoute = ({ router, license }: RouteDependencies) => { try { const esResult = await ctx.core.elasticsearch.client.asCurrentUser.snapshot.getRepository({ - repository: '*', + name: '*', }); const repos: ListSnapshotReposResponse = { repositories: Object.keys(esResult.body), diff --git a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts index 0c12903def052..cbbf21094d61f 100644 --- a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts +++ b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/constants.ts @@ -6,7 +6,6 @@ */ import type { IlmPutLifecycleRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import { ILM_POLICY_NAME } from '../../../../common/constants'; export const reportingIlmPolicy: IlmPutLifecycleRequest['body'] = { policy: { @@ -15,6 +14,5 @@ export const reportingIlmPolicy: IlmPutLifecycleRequest['body'] = { actions: {}, }, }, - name: ILM_POLICY_NAME, }, }; diff --git a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts index 31f1571cfbc94..e0569883fbbe2 100644 --- a/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts +++ b/x-pack/plugins/reporting/server/lib/store/ilm_policy_manager/ilm_policy_manager.ts @@ -24,7 +24,7 @@ export class IlmPolicyManager { public async doesIlmPolicyExist(): Promise { try { - await this.client.ilm.getLifecycle({ policy: ILM_POLICY_NAME }); + await this.client.ilm.getLifecycle({ name: ILM_POLICY_NAME }); return true; } catch (e) { if (e.statusCode === 404) { @@ -38,8 +38,8 @@ export class IlmPolicyManager { * Create the Reporting ILM policy */ public async createIlmPolicy(): Promise { - // @ts-expect-error expects policy to be present await this.client.ilm.putLifecycle({ + name: ILM_POLICY_NAME, body: reportingIlmPolicy, }); } diff --git a/x-pack/plugins/reporting/server/lib/store/store.test.ts b/x-pack/plugins/reporting/server/lib/store/store.test.ts index 87a72eeb910c3..f326350abdb92 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.test.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.test.ts @@ -418,7 +418,7 @@ describe('ReportingStore', () => { const store = new ReportingStore(mockCore, mockLogger); await store.start(); - expect(mockEsClient.ilm.getLifecycle).toHaveBeenCalledWith({ policy: 'kibana-reporting' }); + expect(mockEsClient.ilm.getLifecycle).toHaveBeenCalledWith({ name: 'kibana-reporting' }); expect(mockEsClient.ilm.putLifecycle.mock.calls[0][0]).toMatchInlineSnapshot(` Object { "body": Object { @@ -441,7 +441,7 @@ describe('ReportingStore', () => { const store = new ReportingStore(mockCore, mockLogger); await store.start(); - expect(mockEsClient.ilm.getLifecycle).toHaveBeenCalledWith({ policy: 'kibana-reporting' }); + expect(mockEsClient.ilm.getLifecycle).toHaveBeenCalledWith({ name: 'kibana-reporting' }); expect(mockEsClient.ilm.putLifecycle).not.toHaveBeenCalled(); }); }); diff --git a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts index 39354a2c26282..041dfdeed42e0 100644 --- a/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts +++ b/x-pack/plugins/rule_registry/server/rule_data_plugin_service/resource_installer.ts @@ -85,8 +85,7 @@ export class ResourceInstaller { // We can install them in parallel await Promise.all([ this.createOrUpdateLifecyclePolicy({ - policy: getResourceName(DEFAULT_ILM_POLICY_ID), - // @ts-expect-error @elastic/elasticsearch IlmAction is not valid + name: getResourceName(DEFAULT_ILM_POLICY_ID), body: defaultLifecyclePolicy, }), @@ -117,7 +116,7 @@ export class ResourceInstaller { if (ilmPolicy != null) { await this.createOrUpdateLifecyclePolicy({ - policy: indexInfo.getIlmPolicyName(), + name: indexInfo.getIlmPolicyName(), body: { policy: ilmPolicy }, }); } @@ -386,7 +385,7 @@ export class ResourceInstaller { const { logger, getClusterClient } = this.options; const clusterClient = await getClusterClient(); - logger.debug(`Installing lifecycle policy ${policy.policy}`); + logger.debug(`Installing lifecycle policy ${policy.name}`); return clusterClient.ilm.putLifecycle(policy); } diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts index 5241b2b8e9738..e8b9b000a47d3 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/migration_cleanup.ts @@ -20,7 +20,7 @@ const getPolicyExists = async ({ }): Promise => { try { await esClient.ilm.getLifecycle({ - policy, + name: policy, }); return true; } catch (err) { @@ -56,8 +56,7 @@ export const ensureMigrationCleanupPolicy = async ({ const policyExists = await getPolicyExists({ esClient, policy }); if (!policyExists) { await esClient.ilm.putLifecycle({ - policy, - // @ts-expect-error IlmAction is not valid + name: policy, body: migrationCleanupPolicy, }); } diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts b/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts index c2f59e6433b73..c220d92280822 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/repositories.ts @@ -48,7 +48,7 @@ export function registerRepositoriesRoutes({ try { const { body: repositoriesByName } = await clusterClient.asCurrentUser.snapshot.getRepository({ - repository: '_all', + name: '_all', }); repositoryNames = Object.keys(repositoriesByName); repositories = repositoryNames.map((name) => { @@ -107,7 +107,7 @@ export function registerRepositoriesRoutes({ try { ({ body: repositoryByName } = await clusterClient.asCurrentUser.snapshot.getRepository({ - repository: name, + name, })); } catch (e) { return handleEsError({ error: e, response: res }); @@ -196,9 +196,7 @@ export function registerRepositoriesRoutes({ try { const { body: verificationResults } = await clusterClient.asCurrentUser.snapshot - .verifyRepository({ - repository: name, - }) + .verifyRepository({ name }) .catch((e) => ({ body: { valid: false, @@ -234,9 +232,7 @@ export function registerRepositoriesRoutes({ try { const { body: cleanupResults } = await clusterClient.asCurrentUser.snapshot - .cleanupRepository({ - repository: name, - }) + .cleanupRepository({ name }) .catch((e) => ({ body: { cleaned: false, @@ -270,9 +266,7 @@ export function registerRepositoriesRoutes({ // Check that repository with the same name doesn't already exist try { const { body: repositoryByName } = await clusterClient.asCurrentUser.snapshot.getRepository( - { - repository: name, - } + { name } ); if (repositoryByName[name]) { return res.conflict({ body: 'There is already a repository with that name.' }); @@ -284,7 +278,7 @@ export function registerRepositoriesRoutes({ // Otherwise create new repository try { const response = await clusterClient.asCurrentUser.snapshot.createRepository({ - repository: name, + name, body: { type, // TODO: Bring {@link RepositorySettings} in line with {@link SnapshotRepositorySettings} @@ -314,11 +308,11 @@ export function registerRepositoriesRoutes({ try { // Check that repository with the given name exists // If it doesn't exist, 404 will be thrown by ES and will be returned - await clusterClient.asCurrentUser.snapshot.getRepository({ repository: name }); + await clusterClient.asCurrentUser.snapshot.getRepository({ name }); // Otherwise update repository const response = await clusterClient.asCurrentUser.snapshot.createRepository({ - repository: name, + name, body: { type, settings: serializeRepositorySettings(settings) as SnapshotRepositorySettings, @@ -352,7 +346,7 @@ export function registerRepositoriesRoutes({ await Promise.all( repositoryNames.map((repoName) => { return clusterClient.asCurrentUser.snapshot - .deleteRepository({ repository: repoName }) + .deleteRepository({ name: repoName }) .then(() => response.itemsDeleted.push(repoName)) .catch((e) => response.errors.push({ diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts b/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts index 6838ae2700f3a..9d1867642421c 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts @@ -42,7 +42,7 @@ export function registerSnapshotsRoutes({ try { const { body: repositoriesByName } = await clusterClient.asCurrentUser.snapshot.getRepository({ - repository: '_all', + name: '_all', }); repositories = Object.keys(repositoriesByName); diff --git a/x-pack/test/accessibility/apps/index_lifecycle_management.ts b/x-pack/test/accessibility/apps/index_lifecycle_management.ts index c106569dbadf9..35f4a8e1adea5 100644 --- a/x-pack/test/accessibility/apps/index_lifecycle_management.ts +++ b/x-pack/test/accessibility/apps/index_lifecycle_management.ts @@ -62,7 +62,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // https://github.com/elastic/kibana/issues/114542 describe.skip('Index Lifecycle Management', async () => { before(async () => { - await esClient.ilm.putLifecycle({ policy: POLICY_NAME, body: POLICY_ALL_PHASES }); + await esClient.ilm.putLifecycle({ name: POLICY_NAME, body: POLICY_ALL_PHASES }); await esClient.indices.putIndexTemplate({ name: indexTemplateName, body: { @@ -79,7 +79,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after(async () => { - await esClient.ilm.deleteLifecycle({ policy: POLICY_NAME }); + await esClient.ilm.deleteLifecycle({ name: POLICY_NAME }); await esClient.indices.deleteIndexTemplate({ name: indexTemplateName }); }); diff --git a/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts b/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts index 2b7f5cdc30091..4a9925e7b1563 100644 --- a/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts +++ b/x-pack/test/api_integration/apis/management/snapshot_restore/lib/elasticsearch.ts @@ -40,7 +40,7 @@ export const registerEsHelpers = (getService: FtrProviderContext['getService']) const createRepository = (repoName: string) => { return es.snapshot.createRepository({ - repository: repoName, + name: repoName, body: { type: 'fs', settings: { diff --git a/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts b/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts index 5b630c33106cb..4ae42ce179219 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/update_assets.ts @@ -48,7 +48,7 @@ export default function (providerContext: FtrProviderContext) { it('should have updated the ILM policy', async function () { const resPolicy = await es.ilm.getLifecycle( { - policy: 'all_assets', + name: 'all_assets', }, { meta: true } ); diff --git a/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts b/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts index 6996829f5ecfa..f7510c3c30318 100644 --- a/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts +++ b/x-pack/test/functional/apps/index_lifecycle_management/home_page.ts @@ -22,7 +22,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await pageObjects.common.navigateToApp('indexLifecycleManagement'); }); after(async () => { - await esClient.ilm.deleteLifecycle({ policy: policyName }); + await esClient.ilm.deleteLifecycle({ name: policyName }); }); it('Loads the app', async () => { diff --git a/x-pack/test/functional/apps/snapshot_restore/home_page.ts b/x-pack/test/functional/apps/snapshot_restore/home_page.ts index b72656a96980f..b2893ace7b20a 100644 --- a/x-pack/test/functional/apps/snapshot_restore/home_page.ts +++ b/x-pack/test/functional/apps/snapshot_restore/home_page.ts @@ -31,7 +31,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { describe('Repositories Tab', async () => { before(async () => { await es.snapshot.createRepository({ - repository: 'my-repository', + name: 'my-repository', body: { type: 'fs', settings: { @@ -55,7 +55,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); after(async () => { await es.snapshot.deleteRepository({ - repository: 'my-repository', + name: 'my-repository', }); }); }); diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts b/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts index d8bad4a013fea..e8b3a300ed38c 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts @@ -99,8 +99,7 @@ export default function ({ getService }: FtrProviderContext) { // customize the lifecycle policy await es.ilm.putLifecycle({ - policy: ILM_POLICY_NAME, - // @ts-expect-error @elastic/elasticsearch IlmAction is not valid + name: ILM_POLICY_NAME, body: customLifecycle, }); @@ -108,7 +107,7 @@ export default function ({ getService }: FtrProviderContext) { const { [ILM_POLICY_NAME]: { policy }, - } = await es.ilm.getLifecycle({ policy: ILM_POLICY_NAME }); + } = await es.ilm.getLifecycle({ name: ILM_POLICY_NAME }); expect(policy).to.eql(customLifecycle.policy); }); From cc66f07b494e7b86b79b4ea87977a12278f17594 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 11:13:56 +0200 Subject: [PATCH 099/172] update securityscolution-es-utils --- .../kbn-securitysolution-es-utils/src/delete_policy/index.ts | 4 ++-- .../src/get_policy_exists/index.ts | 4 ++-- .../kbn-securitysolution-es-utils/src/set_policy/index.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts b/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts index 5d6989fd9e57f..af6dca4619004 100644 --- a/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/delete_policy/index.ts @@ -10,7 +10,7 @@ import type { ElasticsearchClient } from '../elasticsearch_client'; export const deletePolicy = async ( esClient: ElasticsearchClient, - policy: string + name: string ): Promise => { - return (await esClient.ilm.deleteLifecycle({ policy }, { meta: true })).body; + return (await esClient.ilm.deleteLifecycle({ name }, { meta: true })).body; }; diff --git a/packages/kbn-securitysolution-es-utils/src/get_policy_exists/index.ts b/packages/kbn-securitysolution-es-utils/src/get_policy_exists/index.ts index 8172cfb2abaa0..a62ea6e224e7d 100644 --- a/packages/kbn-securitysolution-es-utils/src/get_policy_exists/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/get_policy_exists/index.ts @@ -9,11 +9,11 @@ import type { ElasticsearchClient } from '../elasticsearch_client'; export const getPolicyExists = async ( esClient: ElasticsearchClient, - policy: string + name: string ): Promise => { try { await esClient.ilm.getLifecycle({ - policy, + name, }); // Return true that there exists a policy which is not 404 or some error // Since there is not a policy exists API, this is how we create one by calling diff --git a/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts b/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts index 06176bf07d1d7..091155e491e05 100644 --- a/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/set_policy/index.ts @@ -9,13 +9,13 @@ import type { ElasticsearchClient } from '../elasticsearch_client'; export const setPolicy = async ( esClient: ElasticsearchClient, - policy: string, + name: string, body: Record ): Promise => { return ( await esClient.ilm.putLifecycle( { - policy, + name, body, }, { meta: true } From b2bebabb484dfa37c1829fa1670dbac89a47b220 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 11:47:35 +0200 Subject: [PATCH 100/172] unify scroll api in reporting and fix tests --- .../server/export_types/csv/execute_job.test.ts | 12 +++++------- .../export_types/csv/generate_csv/hit_iterator.ts | 2 +- .../generate_csv/generate_csv.test.ts | 5 +++-- .../csv_searchsource/generate_csv/generate_csv.ts | 2 +- .../plugins/reporting/server/lib/store/store.test.ts | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts b/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts index cb103812c7f2a..e432950c9c7fc 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/execute_job.test.ts @@ -182,7 +182,7 @@ describe('CSV Execute Job', function () { ); expect(mockEsClient.scroll).toHaveBeenCalledWith( - expect.objectContaining({ body: { scroll_id: scrollId } }) + expect.objectContaining({ scroll_id: scrollId }) ); }); @@ -271,7 +271,7 @@ describe('CSV Execute Job', function () { ); expect(mockEsClient.clearScroll).toHaveBeenCalledWith( - expect.objectContaining({ body: { scroll_id: lastScrollId } }) + expect.objectContaining({ scroll_id: lastScrollId }) ); }); @@ -307,7 +307,7 @@ describe('CSV Execute Job', function () { ); expect(mockEsClient.clearScroll).toHaveBeenCalledWith( - expect.objectContaining({ body: { scroll_id: lastScrollId } }) + expect.objectContaining({ scroll_id: lastScrollId }) ); }); }); @@ -780,9 +780,7 @@ describe('CSV Execute Job', function () { await delay(100); expect(mockEsClient.clearScroll).toHaveBeenCalledWith( - expect.objectContaining({ - body: { scroll_id: scrollId }, - }) + expect.objectContaining({ scroll_id: scrollId }) ); }); }); @@ -1178,7 +1176,7 @@ describe('CSV Execute Job', function () { await runTask('job123', jobParams, cancellationToken, stream); expect(mockEsClient.scroll).toHaveBeenCalledWith( - expect.objectContaining({ body: { scroll: scrollDuration, scroll_id: 'scrollId' } }) + expect.objectContaining({ scroll: scrollDuration, scroll_id: 'scrollId' }) ); }); }); diff --git a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts index 028dbb65764a6..f2da8564bebbc 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/hit_iterator.ts @@ -74,7 +74,7 @@ export function createHitIterator(logger: LevelLogger) { logger.debug('executing clearScroll request'); try { await elasticsearchClient.clearScroll({ - body: { scroll_id: scrollId }, + scroll_id: scrollId, }); } catch (err) { // Do not throw the error, as the job can still be completed successfully diff --git a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.test.ts b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.test.ts index 1902c4ed0272e..4d883eb9aefb9 100644 --- a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.test.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.test.ts @@ -345,12 +345,13 @@ it('uses the scrollId to page all the data', async () => { // `scroll` and `clearScroll` must be called with scroll ID in the post body! expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledTimes(9); expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledWith({ - body: { scroll: '30s', scroll_id: 'awesome-scroll-hero' }, + scroll: '30s', + scroll_id: 'awesome-scroll-hero', }); expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledTimes(1); expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledWith({ - body: { scroll_id: ['awesome-scroll-hero'] }, + scroll_id: ['awesome-scroll-hero'], }); }); diff --git a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts index 8830b874fd18a..3205b5bf3ab4b 100644 --- a/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts +++ b/x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts @@ -401,7 +401,7 @@ export class CsvGenerator { if (scrollId) { this.logger.debug(`executing clearScroll request`); try { - await this.clients.es.asCurrentUser.clearScroll({ body: { scroll_id: [scrollId] } }); + await this.clients.es.asCurrentUser.clearScroll({ scroll_id: [scrollId] }); } catch (err) { this.logger.error(err); } diff --git a/x-pack/plugins/reporting/server/lib/store/store.test.ts b/x-pack/plugins/reporting/server/lib/store/store.test.ts index f326350abdb92..a28197d261ba2 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.test.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.test.ts @@ -430,7 +430,7 @@ describe('ReportingStore', () => { }, }, }, - "policy": "kibana-reporting", + "name": "kibana-reporting", } `); }); From 6d0e46ef13f51e40a0194be72f2cf1f53133522c Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 11:48:03 +0200 Subject: [PATCH 101/172] fix unit tests in watcher --- .../lib/fetch_all_from_scroll/fetch_all_from_scroll.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.test.js b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.test.js index a561aabbf4107..28f3eaabb283d 100644 --- a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.test.js +++ b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/fetch_all_from_scroll.test.js @@ -76,10 +76,12 @@ describe('fetch_all_from_scroll', () => { expect(mockScopedClusterClient.asCurrentUser.scroll).toHaveBeenCalledTimes(2); expect(mockScopedClusterClient.asCurrentUser.scroll).toHaveBeenNthCalledWith(1, { - body: { scroll: '30s', scroll_id: 'originalScrollId' }, + scroll: '30s', + scroll_id: 'originalScrollId', }); expect(mockScopedClusterClient.asCurrentUser.scroll).toHaveBeenNthCalledWith(2, { - body: { scroll: '30s', scroll_id: 'newScrollId' }, + scroll: '30s', + scroll_id: 'newScrollId', }); }); }); From b127d461e51d846eadf3b86767d35dee3a8b2175 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 12:17:58 +0200 Subject: [PATCH 102/172] refactor APM to abort request with AbortController API --- .../cancel_es_request_on_abort.ts | 6 +-- .../create_apm_event_client/index.ts | 34 ++++++++----- .../create_internal_es_client/index.ts | 17 ++++--- .../server/lib/helpers/setup_request.test.ts | 48 +++++++++++-------- 4 files changed, 65 insertions(+), 40 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts index a5e32f8a942bc..3361aa01ff2fe 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts @@ -9,11 +9,11 @@ import { KibanaRequest } from 'src/core/server'; export function cancelEsRequestOnAbort( promise: T, - request: KibanaRequest + request: KibanaRequest, + controller: AbortController ) { const subscription = request.events.aborted$.subscribe(() => { - // @ts-expect-error fix abort - promise.abort(); + controller.abort(); }); // using .catch() here means unsubscribe will be called diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts index 78587e1303a08..26b00b075a5c8 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts @@ -110,9 +110,14 @@ export function createApmEventClient({ return callAsyncWithDebug({ cb: () => { - const searchPromise = withApmSpan(operationName, () => - cancelEsRequestOnAbort(esClient.search(searchParams), request) - ); + const searchPromise = withApmSpan(operationName, () => { + const controller = new AbortController(); + return cancelEsRequestOnAbort( + esClient.search(searchParams, { signal: controller.signal }), + request, + controller + ); + }); return unwrapEsResponse(searchPromise); }, @@ -143,15 +148,20 @@ export function createApmEventClient({ return callAsyncWithDebug({ cb: () => { const { apm, ...rest } = params; - const termsEnumPromise = withApmSpan(operationName, () => - cancelEsRequestOnAbort( - esClient.termsEnum({ - index: Array.isArray(index) ? index.join(',') : index, - ...rest, - }), - request - ) - ); + const termsEnumPromise = withApmSpan(operationName, () => { + const controller = new AbortController(); + return cancelEsRequestOnAbort( + esClient.termsEnum( + { + index: Array.isArray(index) ? index.join(',') : index, + ...rest, + }, + { signal: controller.signal } + ), + request, + controller + ); + }); return unwrapEsResponse(termsEnumPromise); }, diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts index aff54d4bbc650..621f65f74d9f4 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_internal_es_client/index.ts @@ -38,12 +38,17 @@ export function createInternalESClient({ params, }: { requestType: string; - cb: () => Promise; + cb: (signal: AbortSignal) => Promise; params: Record; } ) { return callAsyncWithDebug({ - cb: () => unwrapEsResponse(cancelEsRequestOnAbort(cb(), request)), + cb: () => { + const controller = new AbortController(); + return unwrapEsResponse( + cancelEsRequestOnAbort(cb(controller.signal), request, controller) + ); + }, getDebugMessage: () => ({ title: getDebugTitle(request), body: getDebugBody({ params, requestType, operationName }), @@ -67,14 +72,14 @@ export function createInternalESClient({ ): Promise> => { return callEs(operationName, { requestType: 'search', - cb: () => asInternalUser.search(params), + cb: (signal) => asInternalUser.search(params, { signal }), params, }); }, index: (operationName: string, params: APMIndexDocumentParams) => { return callEs(operationName, { requestType: 'index', - cb: () => asInternalUser.index(params), + cb: (signal) => asInternalUser.index(params, { signal }), params, }); }, @@ -84,7 +89,7 @@ export function createInternalESClient({ ): Promise<{ result: string }> => { return callEs(operationName, { requestType: 'delete', - cb: () => asInternalUser.delete(params), + cb: (signal) => asInternalUser.delete(params, { signal }), params, }); }, @@ -94,7 +99,7 @@ export function createInternalESClient({ ) => { return callEs(operationName, { requestType: 'indices.create', - cb: () => asInternalUser.indices.create(params), + cb: (signal) => asInternalUser.indices.create(params, { signal }), params, }); }, diff --git a/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts b/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts index d5ff97c050d9d..bfaa1188067e5 100644 --- a/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts +++ b/x-pack/plugins/apm/server/lib/helpers/setup_request.test.ts @@ -117,23 +117,28 @@ describe('setupRequest', () => { expect( mockResources.context.core.elasticsearch.client.asCurrentUser.search - ).toHaveBeenCalledWith({ - index: ['apm-*'], - body: { - foo: 'bar', - query: { - bool: { - filter: [ - { terms: { 'processor.event': ['transaction'] } }, - { range: { 'observer.version_major': { gte: 7 } } }, - ], + ).toHaveBeenCalledWith( + { + index: ['apm-*'], + body: { + foo: 'bar', + query: { + bool: { + filter: [ + { terms: { 'processor.event': ['transaction'] } }, + { range: { 'observer.version_major': { gte: 7 } } }, + ], + }, }, }, + ignore_unavailable: true, + ignore_throttled: true, + preference: 'any', }, - ignore_unavailable: true, - ignore_throttled: true, - preference: 'any', - }); + { + signal: expect.any(Object), + } + ); }); it('calls callWithInternalUser', async () => { @@ -145,12 +150,17 @@ describe('setupRequest', () => { } as any); expect( mockResources.context.core.elasticsearch.client.asInternalUser.search - ).toHaveBeenCalledWith({ - index: ['apm-*'], - body: { - foo: 'bar', + ).toHaveBeenCalledWith( + { + index: ['apm-*'], + body: { + foo: 'bar', + }, }, - }); + { + signal: expect.any(Object), + } + ); }); }); From ddc5f8056d0a8ad59e89cd393055cb84c0848898 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 12:28:17 +0200 Subject: [PATCH 103/172] fix missing es client calls in tests --- .../management/_handle_version_conflict.js | 30 +++++++++++-------- .../lib/elasticsearch.js | 18 +++++------ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/test/functional/apps/management/_handle_version_conflict.js b/test/functional/apps/management/_handle_version_conflict.js index 89426805bd503..a04c5d34b2d35 100644 --- a/test/functional/apps/management/_handle_version_conflict.js +++ b/test/functional/apps/management/_handle_version_conflict.js @@ -45,13 +45,16 @@ export default function ({ getService, getPageObjects }) { await PageObjects.settings.clickAddScriptedField(); await PageObjects.settings.setScriptedFieldName(scriptedFiledName); await PageObjects.settings.setScriptedFieldScript(`doc['bytes'].value`); - const response = await es.update({ - index: '.kibana', - id: 'index-pattern:logstash-*', - body: { - doc: { 'index-pattern': { fieldFormatMap: '{"geo.src":{"id":"number"}}' } }, + const response = await es.update( + { + index: '.kibana', + id: 'index-pattern:logstash-*', + body: { + doc: { 'index-pattern': { fieldFormatMap: '{"geo.src":{"id":"number"}}' } }, + }, }, - }); + { meta: true } + ); log.debug(JSON.stringify(response)); expect(response.body.result).to.be('updated'); await PageObjects.settings.setFieldFormat('url'); @@ -76,13 +79,16 @@ export default function ({ getService, getPageObjects }) { ).findAllByCssSelector('[data-test-subj="toggle"]') )[0].click(); await PageObjects.settings.setFieldFormat('url'); - const response = await es.update({ - index: '.kibana', - id: 'index-pattern:logstash-*', - body: { - doc: { 'index-pattern': { fieldFormatMap: '{"geo.dest":{"id":"number"}}' } }, + const response = await es.update( + { + index: '.kibana', + id: 'index-pattern:logstash-*', + body: { + doc: { 'index-pattern': { fieldFormatMap: '{"geo.dest":{"id":"number"}}' } }, + }, }, - }); + { meta: true } + ); log.debug(JSON.stringify(response)); expect(response.body.result).to.be('updated'); await PageObjects.settings.controlChangeSave(); diff --git a/x-pack/test/api_integration/apis/management/index_lifecycle_management/lib/elasticsearch.js b/x-pack/test/api_integration/apis/management/index_lifecycle_management/lib/elasticsearch.js index 9e09ae57e167e..8c5481a6e2c85 100644 --- a/x-pack/test/api_integration/apis/management/index_lifecycle_management/lib/elasticsearch.js +++ b/x-pack/test/api_integration/apis/management/index_lifecycle_management/lib/elasticsearch.js @@ -22,7 +22,7 @@ export const initElasticsearchHelpers = (getService) => { let dataStreamsCreated = []; // Indices - const getIndex = (index) => es.indices.get({ index }).then(({ body }) => body); + const getIndex = (index) => es.indices.get({ index }); const createIndex = (index = getRandomString()) => { indicesCreated.push(index); @@ -37,34 +37,34 @@ export const initElasticsearchHelpers = (getService) => { // Data streams const createDataStream = (dataStream = getRandomString(), document) => { dataStreamsCreated.push(dataStream); - return es.index({ index: dataStream, body: document }); + return es.index({ index: dataStream, body: document }, { meta: true }); }; const deleteDataStream = (dataStream) => { dataStreamsCreated = dataStreamsCreated.filter((i) => i !== dataStream); - return es.indices.deleteDataStream({ name: dataStream }); + return es.indices.deleteDataStream({ name: dataStream }, { meta: true }); }; const deleteAllDataStreams = () => Promise.all(dataStreamsCreated.map(deleteDataStream)).then(() => (dataStreamsCreated = [])); // Index templates - const getIndexTemplates = () => es.indices.getTemplate(); + const getIndexTemplates = () => es.indices.getTemplate(undefined, { meta: true }); // Create index template if it does not already exist const createIndexTemplate = (name, template) => { templatesCreated.push(name); - return es.indices.putTemplate({ name, body: template }, { create: true }); + return es.indices.putTemplate({ name, body: template }, { create: true, meta: true }); }; const createComposableIndexTemplate = (name, template) => { composableTemplatesCreated.push(name); - return es.indices.putIndexTemplate({ name, body: template }, { create: true }); + return es.indices.putIndexTemplate({ name, body: template }, { create: true, meta: true }); }; const deleteIndexTemplate = (name) => { templatesCreated = templatesCreated.filter((i) => i !== name); - return es.indices.deleteTemplate({ name }).catch((err) => { + return es.indices.deleteTemplate({ name }, { meta: true }).catch((err) => { // Silently fail templates not found if (err.statusCode !== 404) { throw err; @@ -74,7 +74,7 @@ export const initElasticsearchHelpers = (getService) => { const deleteComposableIndexTemplate = (name) => { composableTemplatesCreated = composableTemplatesCreated.filter((i) => i !== name); - return es.indices.deleteIndexTemplate({ name }).catch((err) => { + return es.indices.deleteIndexTemplate({ name }, { meta: true }).catch((err) => { // Silently fail if templates not found if (err.statusCode !== 404) { throw err; @@ -98,7 +98,7 @@ export const initElasticsearchHelpers = (getService) => { deleteAllDataStreams(), ]); - const getNodesStats = () => es.nodes.stats().then(({ body }) => body); + const getNodesStats = () => es.nodes.stats(); return { getIndex, From 0d0765c14989b08557fda15901ebc8caa7a04158 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 20 Oct 2021 13:56:34 +0200 Subject: [PATCH 104/172] fix missing meta in detection engine FTR tests --- .../security_and_spaces/tests/delete_signals_migrations.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts index 5f373ceedcf7d..b6424361a0cff 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts @@ -35,7 +35,7 @@ export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); const supertestWithoutAuth = getService('supertestWithoutAuth'); - describe('deleting signals migrations', () => { + describe('FOO deleting signals migrations', () => { let outdatedSignalsIndexName: string; let createdMigration: CreateResponse; let finalizedMigration: FinalizeResponse; @@ -95,7 +95,10 @@ export default ({ getService }: FtrProviderContext): void => { .send({ migration_ids: [createdMigration.migration_id] }) .expect(200); - const { body } = await es.indices.getSettings({ index: createdMigration.index }); + const { body } = await es.indices.getSettings( + { index: createdMigration.index }, + { meta: true } + ); // @ts-expect-error @elastic/elasticsearch supports flatten 'index.*' keys only const indexSettings = body[createdMigration.index].settings.index; expect(indexSettings.lifecycle.name).to.eql( From 0d9cf9702ae0c1fbb77167a165a6a84278ffc3c3 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 14:02:11 +0200 Subject: [PATCH 105/172] fix another bunch of errors in js tests --- .../apis/monitoring/common/mappings_exist.js | 2 +- .../apps/rollup_job/hybrid_index_pattern.js | 2 +- .../upgrade_assistant/reindexing.js | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js b/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js index f193e0dbe091a..a34473501c2e2 100644 --- a/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js +++ b/x-pack/test/api_integration/apis/monitoring/common/mappings_exist.js @@ -49,7 +49,7 @@ export default function ({ getService }) { let mappings; before('load mappings', async () => { - const { body: template } = await es.indices.getTemplate({ name: indexTemplate }); + const template = await es.indices.getTemplate({ name: indexTemplate }); mappings = get(template, [indexTemplate, 'mappings', 'properties']); }); diff --git a/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js b/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js index 4fe957dac7b6d..336a575454e72 100644 --- a/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js +++ b/x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js @@ -57,7 +57,7 @@ export default function ({ getService, getPageObjects }) { 'waiting for 3 records to be loaded into elasticsearch.', 10000, async () => { - const { body: response } = await es.indices.get({ + const response = await es.indices.get({ index: `${rollupSourceIndexPrefix}*`, allow_no_indices: false, }); diff --git a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js index 2fe7254def272..7b43bb1f4dd38 100644 --- a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js +++ b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js @@ -66,7 +66,7 @@ export default function ({ getService }) { expect(lastState.status).to.equal(ReindexStatus.completed); const { newIndexName } = lastState; - const { body: indexSummary } = await es.indices.get({ index: 'dummydata' }); + const indexSummary = await es.indices.get({ index: 'dummydata' }); // The new index was created expect(indexSummary[newIndexName]).to.be.an('object'); @@ -75,7 +75,7 @@ export default function ({ getService }) { // Verify mappings exist on new index expect(indexSummary[newIndexName].mappings.properties).to.be.an('object'); // The number of documents in the new index matches what we expect - expect((await es.count({ index: lastState.newIndexName })).body.count).to.be(3); + expect((await es.count({ index: lastState.newIndexName })).count).to.be(3); // Cleanup newly created index await es.indices.delete({ @@ -98,9 +98,9 @@ export default function ({ getService }) { ], }, }); - expect((await es.count({ index: 'myAlias' })).body.count).to.be(3); - expect((await es.count({ index: 'wildcardAlias' })).body.count).to.be(3); - expect((await es.count({ index: 'myHttpsAlias' })).body.count).to.be(2); + expect((await es.count({ index: 'myAlias' })).count).to.be(3); + expect((await es.count({ index: 'wildcardAlias' })).count).to.be(3); + expect((await es.count({ index: 'myHttpsAlias' })).count).to.be(2); // Reindex await supertest @@ -110,10 +110,10 @@ export default function ({ getService }) { const lastState = await waitForReindexToComplete('dummydata'); // The regular aliases should still return 3 docs - expect((await es.count({ index: 'myAlias' })).body.count).to.be(3); - expect((await es.count({ index: 'wildcardAlias' })).body.count).to.be(3); + expect((await es.count({ index: 'myAlias' })).count).to.be(3); + expect((await es.count({ index: 'wildcardAlias' })).count).to.be(3); // The filtered alias should still return 2 docs - expect((await es.count({ index: 'myHttpsAlias' })).body.count).to.be(2); + expect((await es.count({ index: 'myHttpsAlias' })).count).to.be(2); // Cleanup newly created index await es.indices.delete({ From 7749d909b6045e2e1cbbaef24f006e0a553b19c3 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 14:21:13 +0200 Subject: [PATCH 106/172] fix wrong coercion --- .../common/lib/task_manager_utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts b/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts index 275f29acf2e04..42064369e0221 100644 --- a/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts +++ b/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts @@ -36,7 +36,7 @@ export class TaskManagerUtils { { range: { 'task.scheduledAt': { - gte: taskRunAtFilter.toString(), + gte: taskRunAtFilter.getTime().toString(), }, }, }, @@ -69,7 +69,7 @@ export class TaskManagerUtils { { range: { 'task.scheduledAt': { - gte: taskRunAtFilter.toString(), + gte: taskRunAtFilter.getTime().toString(), }, }, }, @@ -109,7 +109,7 @@ export class TaskManagerUtils { { range: { updated_at: { - gte: createdAtFilter.toString(), + gte: taskRunAtFilter.getTime().toString(), }, }, }, From 25a350629df23217669f347cba7270108eb0a9ff Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 20 Oct 2021 14:11:21 +0200 Subject: [PATCH 107/172] remove test-grep pattern --- .../security_and_spaces/tests/delete_signals_migrations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts index b6424361a0cff..73bd8abf0a304 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_signals_migrations.ts @@ -35,7 +35,7 @@ export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); const supertestWithoutAuth = getService('supertestWithoutAuth'); - describe('FOO deleting signals migrations', () => { + describe('deleting signals migrations', () => { let outdatedSignalsIndexName: string; let createdMigration: CreateResponse; let finalizedMigration: FinalizeResponse; From cf8fa3d46e6eebf98a9a552cf40e2fb30979c4f5 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 14:29:37 +0200 Subject: [PATCH 108/172] fix apm unit test --- .../create_apm_event_client/index.test.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts index 8f03aceef3348..e9280ba3e5976 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import { setTimeout as setTimeoutPromise } from 'timers/promises'; import { contextServiceMock, executionContextServiceMock, @@ -34,17 +34,19 @@ describe('createApmEventClient', () => { }); const router = createRouter('/'); - const abort = jest.fn(); + let abortSignal: AbortSignal | undefined; router.get( { path: '/', validate: false }, async (context, request, res) => { const eventClient = createApmEventClient({ esClient: { - search: () => { - return Object.assign( - new Promise((resolve) => setTimeout(resolve, 3000)), - { abort } - ); + search: async ( + params: any, + { signal }: { signal: AbortSignal } + ) => { + abortSignal = signal; + await setTimeoutPromise(3_000); + return {}; }, } as any, debug: false, @@ -67,6 +69,8 @@ describe('createApmEventClient', () => { await server.start(); + expect(abortSignal?.aborted).toBeFalsy(); + const incomingRequest = supertest(innerServer.listener) .get('/') // end required to send request @@ -83,6 +87,6 @@ describe('createApmEventClient', () => { }, 100); }); - expect(abort).toHaveBeenCalled(); + expect(abortSignal?.aborted).toBe(true); }); }); From 99009a72f37207d72799e672e0297471d3dc943c Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 20 Oct 2021 14:57:30 +0200 Subject: [PATCH 109/172] rename terminateAfter to terminate_after in infra plugin --- .../infra/server/lib/adapters/metrics/lib/check_valid_node.ts | 2 +- .../plugins/infra/server/routes/metadata/lib/get_node_info.ts | 2 +- .../infra/server/routes/metadata/lib/get_pod_node_name.ts | 2 +- .../server/routes/metrics_explorer/lib/get_dataset_for_field.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts index f2b7691646e48..a1bff361a8067 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/lib/check_valid_node.ts @@ -17,7 +17,7 @@ export const checkValidNode = async ( allow_no_indices: true, ignore_unavailable: true, index: indexPattern, - terminateAfter: 1, + terminate_after: 1, body: { size: 0, query: { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts index 06035ed40adf1..94becdf6d2811 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts @@ -55,7 +55,7 @@ export const getNodeInfo = async ( const params = { allow_no_indices: true, ignore_unavailable: true, - terminateAfter: 1, + terminate_after: 1, index: sourceConfiguration.metricAlias, body: { size: 1, diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts index 9bf809ba3b3f4..164d94d9f692f 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_pod_node_name.ts @@ -24,7 +24,7 @@ export const getPodNodeName = async ( const params = { allow_no_indices: true, ignore_unavailable: true, - terminateAfter: 1, + terminate_after: 1, index: sourceConfiguration.metricAlias, body: { size: 1, diff --git a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts index be25bbbf022ee..640d62c366726 100644 --- a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_dataset_for_field.ts @@ -24,7 +24,7 @@ export const getDatasetForField = async ( const params = { allow_no_indices: true, ignore_unavailable: true, - terminateAfter: 1, + terminate_after: 1, index: indexPattern, body: { query: { From 16bb7c58ef6f11b97dc8bd7d6533388785466fe4 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 20 Oct 2021 15:42:52 +0200 Subject: [PATCH 110/172] rename terminateAfter to terminate_after in uptime plugin --- x-pack/plugins/uptime/server/lib/requests/get_index_status.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/get_index_status.ts b/x-pack/plugins/uptime/server/lib/requests/get_index_status.ts index dcd61d5331aa4..f9215b5af31e4 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_index_status.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_index_status.ts @@ -19,7 +19,7 @@ export const getIndexStatus: UMElasticsearchQueryFn<{}, StatesIndexStatus> = asy count, }, }, - } = await uptimeEsClient.count({ terminateAfter: 1 }); + } = await uptimeEsClient.count({ terminate_after: 1 }); return { indices, indexExists: total > 0, From 55ad139bbacb4fef482f8c05d22ccffac8746f07 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 20 Oct 2021 15:48:49 +0200 Subject: [PATCH 111/172] rename terminateAfter to terminate_after in apm plugin --- .../get_is_using_transaction_events.test.ts.snap | 8 ++++---- .../get_is_using_transaction_events.ts | 2 +- .../server/lib/helpers/aggregated_transactions/index.ts | 2 +- .../apm/server/lib/observability_overview/has_data.ts | 2 +- .../lib/services/__snapshots__/queries.test.ts.snap | 6 +++--- .../plugins/apm/server/lib/services/get_service_agent.ts | 2 +- .../lib/services/get_services/get_legacy_data_status.ts | 2 +- .../agent_configuration/get_agent_name_by_service.ts | 2 +- .../__snapshots__/get_transaction.test.ts.snap | 4 ++-- .../server/lib/settings/custom_link/get_transaction.ts | 2 +- .../routes/historical_data/has_historical_agent_data.ts | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/__snapshots__/get_is_using_transaction_events.test.ts.snap b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/__snapshots__/get_is_using_transaction_events.test.ts.snap index 2b629e9849d0d..56d735b5df115 100644 --- a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/__snapshots__/get_is_using_transaction_events.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/__snapshots__/get_is_using_transaction_events.test.ts.snap @@ -32,7 +32,7 @@ Object { }, }, }, - "terminateAfter": 1, + "terminate_after": 1, } `; @@ -56,7 +56,7 @@ Object { }, }, }, - "terminateAfter": 1, + "terminate_after": 1, } `; @@ -83,7 +83,7 @@ Array [ }, }, }, - "terminateAfter": 1, + "terminate_after": 1, }, ], Array [ @@ -101,7 +101,7 @@ Array [ }, }, }, - "terminateAfter": 1, + "terminate_after": 1, }, ], ] diff --git a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/get_is_using_transaction_events.ts b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/get_is_using_transaction_events.ts index 66e9697ab7c91..75be545a7e427 100644 --- a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/get_is_using_transaction_events.ts +++ b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/get_is_using_transaction_events.ts @@ -83,7 +83,7 @@ async function getHasTransactions({ }, }, }, - terminateAfter: 1, + terminate_after: 1, }); return response.hits.total.value > 0; diff --git a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts index a58a95dd43fcc..98002e15d0bac 100644 --- a/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts +++ b/x-pack/plugins/apm/server/lib/helpers/aggregated_transactions/index.ts @@ -43,7 +43,7 @@ export async function getHasAggregatedTransactions({ }, }, }, - terminateAfter: 1, + terminate_after: 1, } ); diff --git a/x-pack/plugins/apm/server/lib/observability_overview/has_data.ts b/x-pack/plugins/apm/server/lib/observability_overview/has_data.ts index 3b6993695f3de..f09b67ec98dfb 100644 --- a/x-pack/plugins/apm/server/lib/observability_overview/has_data.ts +++ b/x-pack/plugins/apm/server/lib/observability_overview/has_data.ts @@ -19,7 +19,7 @@ export async function getHasData({ setup }: { setup: Setup }) { ProcessorEvent.metric, ], }, - terminateAfter: 1, + terminate_after: 1, body: { size: 0, }, diff --git a/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap index 99891807e689b..d6d6219440dad 100644 --- a/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/services/__snapshots__/queries.test.ts.snap @@ -12,7 +12,7 @@ Object { "body": Object { "size": 0, }, - "terminateAfter": 1, + "terminate_after": 1, } `; @@ -49,7 +49,7 @@ Object { }, "size": 0, }, - "terminateAfter": 1, + "terminate_after": 1, } `; @@ -99,7 +99,7 @@ Object { }, "size": 1, }, - "terminateAfter": 1, + "terminate_after": 1, } `; diff --git a/x-pack/plugins/apm/server/lib/services/get_service_agent.ts b/x-pack/plugins/apm/server/lib/services/get_service_agent.ts index a9bb3c8f3103f..b8ec36e2c91e1 100644 --- a/x-pack/plugins/apm/server/lib/services/get_service_agent.ts +++ b/x-pack/plugins/apm/server/lib/services/get_service_agent.ts @@ -42,7 +42,7 @@ export async function getServiceAgent({ const { apmEventClient } = setup; const params = { - terminateAfter: 1, + terminate_after: 1, apm: { events: [ ProcessorEvent.error, diff --git a/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts b/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts index cf80222dc8303..5b94bb2314258 100644 --- a/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts +++ b/x-pack/plugins/apm/server/lib/services/get_services/get_legacy_data_status.ts @@ -19,7 +19,7 @@ export async function getLegacyDataStatus( const { apmEventClient } = setup; const params = { - terminateAfter: 1, + terminate_after: 1, apm: { events: [ProcessorEvent.transaction], includeLegacyData: true, diff --git a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_agent_name_by_service.ts b/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_agent_name_by_service.ts index 0b6dd10b42e25..6ea3e2a578050 100644 --- a/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_agent_name_by_service.ts +++ b/x-pack/plugins/apm/server/lib/settings/agent_configuration/get_agent_name_by_service.ts @@ -20,7 +20,7 @@ export async function getAgentNameByService({ const { apmEventClient } = setup; const params = { - terminateAfter: 1, + terminate_after: 1, apm: { events: [ ProcessorEvent.transaction, diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap b/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap index 0649c8c38d29a..921129cf2c1da 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/__snapshots__/get_transaction.test.ts.snap @@ -44,7 +44,7 @@ Object { }, }, "size": 1, - "terminateAfter": 1, + "terminate_after": 1, } `; @@ -63,6 +63,6 @@ Object { }, }, "size": 1, - "terminateAfter": 1, + "terminate_after": 1, } `; diff --git a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts b/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts index 91bc8c85bc014..1c3d1465527ba 100644 --- a/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts +++ b/x-pack/plugins/apm/server/lib/settings/custom_link/get_transaction.ts @@ -32,7 +32,7 @@ export async function getTransaction({ ); const params = { - terminateAfter: 1, + terminate_after: 1, apm: { events: [ProcessorEvent.transaction as const], }, diff --git a/x-pack/plugins/apm/server/routes/historical_data/has_historical_agent_data.ts b/x-pack/plugins/apm/server/routes/historical_data/has_historical_agent_data.ts index 13591b47a8584..54960c3e48b60 100644 --- a/x-pack/plugins/apm/server/routes/historical_data/has_historical_agent_data.ts +++ b/x-pack/plugins/apm/server/routes/historical_data/has_historical_agent_data.ts @@ -13,7 +13,7 @@ export async function hasHistoricalAgentData(setup: Setup) { const { apmEventClient } = setup; const params = { - terminateAfter: 1, + terminate_after: 1, apm: { events: [ ProcessorEvent.error, From 527d2966aa68ecd6904782be8030a5f7a4358b93 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 20 Oct 2021 16:32:27 +0200 Subject: [PATCH 112/172] fix security roles FTR tests --- .../test/api_integration/apis/security/roles.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/x-pack/test/api_integration/apis/security/roles.ts b/x-pack/test/api_integration/apis/security/roles.ts index dafe1f33954e5..b07a5ca859a5c 100644 --- a/x-pack/test/api_integration/apis/security/roles.ts +++ b/x-pack/test/api_integration/apis/security/roles.ts @@ -58,7 +58,7 @@ export default function ({ getService }: FtrProviderContext) { }) .expect(204); - const { body: role } = await es.security.getRole({ name: 'role_with_privileges' }); + const role = await es.security.getRole({ name: 'role_with_privileges' }); expect(role).to.eql({ role_with_privileges: { cluster: ['manage'], @@ -186,7 +186,7 @@ export default function ({ getService }: FtrProviderContext) { }) .expect(204); - const { body: role } = await es.security.getRole({ name: 'role_to_update' }); + const role = await es.security.getRole({ name: 'role_to_update' }); expect(role).to.eql({ role_to_update: { cluster: ['manage'], @@ -380,27 +380,24 @@ export default function ({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'xxx') .expect(204); - const { body: emptyRole } = await es.security.getRole( - { name: 'empty_role' }, - { ignore: [404] } - ); + const emptyRole = await es.security.getRole({ name: 'empty_role' }, { ignore: [404] }); expect(emptyRole).to.eql({}); - const { body: roleWithPrivileges } = await es.security.getRole( + const roleWithPrivileges = await es.security.getRole( { name: 'role_with_privileges' }, { ignore: [404] } ); expect(roleWithPrivileges).to.eql({}); - const { body: roleWithPrivilegesDlsFls } = await es.security.getRole( + const roleWithPrivilegesDlsFls = await es.security.getRole( { name: 'role_with_privileges_dls_fls' }, { ignore: [404] } ); expect(roleWithPrivilegesDlsFls).to.eql({}); - const { body: roleToUpdate } = await es.security.getRole( + const roleToUpdate = await es.security.getRole( { name: 'role_to_update' }, { ignore: [404] } ); expect(roleToUpdate).to.eql({}); - const { body: roleToUpdateWithDlsFls } = await es.security.getRole( + const roleToUpdateWithDlsFls = await es.security.getRole( { name: 'role_to_update_with_dls_fls' }, { ignore: [404] } ); From 7c52a8ee204a15ce5848c4cdfbecd278ba87d9bf Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Wed, 20 Oct 2021 17:21:16 +0200 Subject: [PATCH 113/172] fix reference --- .../alerting_api_integration/common/lib/task_manager_utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts b/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts index 42064369e0221..11e0b047ffd85 100644 --- a/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts +++ b/x-pack/test/alerting_api_integration/common/lib/task_manager_utils.ts @@ -109,7 +109,7 @@ export class TaskManagerUtils { { range: { updated_at: { - gte: taskRunAtFilter.getTime().toString(), + gte: createdAtFilter.getTime().toString(), }, }, }, From 0c8438d6b4345a29b8ee048cb6831c618ae94c30 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 17:25:25 +0200 Subject: [PATCH 114/172] fix post_privilidges test --- x-pack/test/api_integration/apis/es/post_privileges.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/es/post_privileges.ts b/x-pack/test/api_integration/apis/es/post_privileges.ts index 37399fe31a2ca..b8298c3bef8c9 100644 --- a/x-pack/test/api_integration/apis/es/post_privileges.ts +++ b/x-pack/test/api_integration/apis/es/post_privileges.ts @@ -70,7 +70,7 @@ export default function ({ getService }: FtrProviderContext) { }); const retrievedPrivilege = await es.security.getPrivileges({ application }); - expect(retrievedPrivilege.body).to.eql({ + expect(retrievedPrivilege).to.eql({ foo: { // "all" is maintained even though the subsequent update did not specify this privilege all: { From 747788f64e8986f30d6d466c3c7b1f38e01d6a57 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 17:33:48 +0200 Subject: [PATCH 115/172] fix post_privilidges --- x-pack/test/api_integration/apis/es/post_privileges.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/api_integration/apis/es/post_privileges.ts b/x-pack/test/api_integration/apis/es/post_privileges.ts index b8298c3bef8c9..76cc21a861d8c 100644 --- a/x-pack/test/api_integration/apis/es/post_privileges.ts +++ b/x-pack/test/api_integration/apis/es/post_privileges.ts @@ -32,7 +32,7 @@ export default function ({ getService }: FtrProviderContext) { }, }); - expect(response.body).to.eql({ + expect(response).to.eql({ foo: { all: { created: true }, read: { created: true }, @@ -62,7 +62,7 @@ export default function ({ getService }: FtrProviderContext) { }, }); - expect(updateResponse.body).to.eql({ + expect(updateResponse).to.eql({ foo: { other: { created: true }, read: { created: false }, From a19ff0afbcc9c72eef2c834604aaced14c71004a Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 17:37:50 +0200 Subject: [PATCH 116/172] bump client to 26 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 40b924b9ca0a7..529460160ed56 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "37.0.0", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.25", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.26", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.0.0", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 79b5cc11b7c51..0a3f9b0bb68a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,10 +2379,10 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.25": - version "8.0.0-canary.25" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.25.tgz#a8edb0509dba1b1fd19b7b89dd3d31cf847cd6ca" - integrity sha512-iOBKwbwnh/bV8U2X84z7oZUnAROkrxKI33aZPgrlIQujDMYkAn7e0ABAJNP5KGANIvEJ31T2UQmUE4PUAijpEA== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.26": + version "8.0.0-canary.26" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.26.tgz#586c64b4bace79e6acbe6856a8758ef5d9f4b5ef" + integrity sha512-LPCE44ReyxdpsxrhC89UqpA5UktFGFeEWHRlCHTizcWP/sADbl1Xe8lr/PxdpYK9BzRW/eIn2sK+M9nuCb8WUA== dependencies: "@elastic/transport" "^0.0.9" tslib "^2.3.0" From caa8be5ebdf37b9f8eb2c394f39918d380b04487 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 18:38:19 +0200 Subject: [PATCH 117/172] add meta for index_management test helpers --- .../management/index_management/lib/elasticsearch.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/test/api_integration/apis/management/index_management/lib/elasticsearch.js b/x-pack/test/api_integration/apis/management/index_management/lib/elasticsearch.js index 22824227f1275..9c67f493a7ca3 100644 --- a/x-pack/test/api_integration/apis/management/index_management/lib/elasticsearch.js +++ b/x-pack/test/api_integration/apis/management/index_management/lib/elasticsearch.js @@ -29,24 +29,24 @@ export const initElasticsearchHelpers = (getService) => { indicesCreated = []; }; - const catIndex = (index, h) => es.cat.indices({ index, format: 'json', h }); + const catIndex = (index, h) => es.cat.indices({ index, format: 'json', h }, { meta: true }); - const indexStats = (index, metric) => es.indices.stats({ index, metric }); + const indexStats = (index, metric) => es.indices.stats({ index, metric }, { meta: true }); const cleanUp = () => deleteAllIndices(); - const catTemplate = (name) => es.cat.templates({ name, format: 'json' }); + const catTemplate = (name) => es.cat.templates({ name, format: 'json' }, { meta: true }); const createComponentTemplate = (componentTemplate, shouldCacheTemplate) => { if (shouldCacheTemplate) { componentTemplatesCreated.push(componentTemplate.name); } - return es.cluster.putComponentTemplate(componentTemplate); + return es.cluster.putComponentTemplate(componentTemplate, { meta: true }); }; const deleteComponentTemplate = (componentTemplateName) => { - return es.cluster.deleteComponentTemplate({ name: componentTemplateName }); + return es.cluster.deleteComponentTemplate({ name: componentTemplateName }, { meta: true }); }; const cleanUpComponentTemplates = () => From caa789f7d94d8191f0d55b49fc6466f0ae026880 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 18:39:46 +0200 Subject: [PATCH 118/172] remove ts-expect-error caused by bad type in reason --- .../actions/server/builtin_action_types/es_index.ts | 2 -- .../server/authentication/api_keys/api_keys.ts | 10 ++++------ .../detection_engine/signals/single_search_after.ts | 1 - .../server/lib/detection_engine/signals/utils.ts | 6 ------ 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/actions/server/builtin_action_types/es_index.ts b/x-pack/plugins/actions/server/builtin_action_types/es_index.ts index cd71becb7eddd..3662fea00e31d 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/es_index.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/es_index.ts @@ -105,9 +105,7 @@ async function executor( const err = find(result.items, 'index.error.reason'); if (err) { return wrapErr( - // @ts-expect-error error_details is not comptible with error: ErrorCause | string `${err.index?.error?.reason}${ - // @ts-expect-error error_details is not comptible with error: ErrorCause | string err.index?.error?.caused_by ? ` (${err.index?.error?.caused_by?.reason})` : '' }`, actionId, diff --git a/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts b/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts index bb9d15c13fa77..65a7972084cb8 100644 --- a/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts +++ b/x-pack/plugins/security/server/authentication/api_keys/api_keys.ts @@ -113,11 +113,11 @@ export interface InvalidateAPIKeyResult { * Details about these errors. This field is not present in the response when error_count is 0. */ error_details?: Array<{ - type: string; - reason: string; + type?: string; + reason?: string; caused_by?: { - type: string; - reason: string; + type?: string; + reason?: string; }; }>; } @@ -252,7 +252,6 @@ export class APIKeys { let result: InvalidateAPIKeyResult; try { // User needs `manage_api_key` privilege to use this API - // @ts-expect-error error_details is not comptible with error: ErrorCause | string result = ( await this.clusterClient.asScoped(request).asCurrentUser.security.invalidateApiKey({ body: { @@ -289,7 +288,6 @@ export class APIKeys { let result: InvalidateAPIKeyResult; try { // Internal user needs `cluster:admin/xpack/security/api_key/invalidate` privilege to use this API - // @ts-expect-error error_details is not comptible with error: ErrorCause | string result = ( await this.clusterClient.asInternalUser.security.invalidateApiKey({ body: { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts index 9b4bfe5b8aed1..2596068848ef0 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.ts @@ -76,7 +76,6 @@ export const singleSearchAfter = async ({ const end = performance.now(); const searchErrors = createErrorsFromShard({ - // @ts-expect-error is not compatile with ErrorCause | string; errors: nextSearchAfterResult._shards.failures ?? [], }); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index 5557266bb519d..7144dbc4f8a5d 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -505,17 +505,13 @@ export const errorAggregator = ( ): BulkResponseErrorAggregation => { return response.items.reduce((accum, item) => { if (item.create?.error != null && !ignoreStatusCodes.includes(item.create.status)) { - // @ts-expect-error error is not comptible with error: ErrorCause | string if (accum[item.create.error.reason] == null) { - // @ts-expect-error error is not comptible with error: ErrorCause | string accum[item.create.error.reason] = { count: 1, statusCode: item.create.status, }; } else { - // @ts-expect-error error is not comptible with error: ErrorCause | string accum[item.create.error.reason] = { - // @ts-expect-error error is not comptible with error: ErrorCause | string count: accum[item.create.error.reason].count + 1, statusCode: item.create.status, }; @@ -732,11 +728,9 @@ export const createSearchAfterReturnTypeFromResponse = ({ searchResult._shards.failed === 0 || searchResult._shards.failures?.every((failure) => { return ( - // @ts-expect-error reason is not comptible with error: ErrorCause | string failure.reason?.reason?.includes( 'No mapping found for [@timestamp] in order to sort on' ) || - // @ts-expect-error reason is not comptible with error: ErrorCause | string failure.reason?.reason?.includes( `No mapping found for [${timestampOverride}] in order to sort on` ) From a33d8fc0b1c38fd0b7ace16c6ed9f036b0c90c5d Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 20 Oct 2021 22:20:28 +0200 Subject: [PATCH 119/172] bump client to 27 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 529460160ed56..61f01dc5f8907 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "37.0.0", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.26", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.27", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.0.0", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 0a3f9b0bb68a4..abd77e3c86fb3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,10 +2379,10 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.26": - version "8.0.0-canary.26" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.26.tgz#586c64b4bace79e6acbe6856a8758ef5d9f4b5ef" - integrity sha512-LPCE44ReyxdpsxrhC89UqpA5UktFGFeEWHRlCHTizcWP/sADbl1Xe8lr/PxdpYK9BzRW/eIn2sK+M9nuCb8WUA== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.27": + version "8.0.0-canary.27" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.27.tgz#ae7a68147809c62dc2858593a8b44bbe365fad15" + integrity sha512-ObEXgSMqNFCBe0l+FaClDidAGBAZfZ7Gwnb7CCHHFPnhi2PLhYi+xQ94TSRTzmKHsurfQyF4kskn5WlYDobjqg== dependencies: "@elastic/transport" "^0.0.9" tslib "^2.3.0" From c038850c09c378977a50c0e3d176810f4b69b5d6 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 07:46:36 +0200 Subject: [PATCH 120/172] REMOVE me. workaround until fixed in the es client --- .../services/epm/elasticsearch/ingest_pipeline/install.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts index 42e1bff6ab370..1e5d3b8887702 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts @@ -218,7 +218,7 @@ async function installPipeline({ if (pipeline.extension === 'yml') { esClientRequestOptions.headers = { // pipeline is YAML - 'Content-Type': 'application/yaml', + 'Content-Type': 'application/yaml; compatible-with=8', // but we want JSON responses (to extract error messages, status code, or other metadata) Accept: 'application/json', }; From 42c34935fa8d650842202d43ec0c38ed23bc0e16 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 07:52:13 +0200 Subject: [PATCH 121/172] fix incorrect type casting --- .../reporting_and_security/ilm_migration_apis.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts b/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts index e8b3a300ed38c..d1dc091992dd6 100644 --- a/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts +++ b/x-pack/test/reporting_api_integration/reporting_and_security/ilm_migration_apis.ts @@ -50,8 +50,7 @@ export default function ({ getService }: FtrProviderContext) { it('detects when reporting indices should be migrated due to missing ILM policy', async () => { await reportingAPI.makeAllReportingIndicesUnmanaged(); - // TODO: Remove "any" when no longer through type issue "policy_id" missing - await es.ilm.deleteLifecycle({ policy: ILM_POLICY_NAME } as any); + await es.ilm.deleteLifecycle({ name: ILM_POLICY_NAME }); await supertest .post(`/api/reporting/generate/csv`) From b2a28616b24b12ab4407ac40253d394d0443c482 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 08:11:32 +0200 Subject: [PATCH 122/172] swtich from camelCase params --- .../kbn-securitysolution-es-utils/src/decode_version/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kbn-securitysolution-es-utils/src/decode_version/index.ts b/packages/kbn-securitysolution-es-utils/src/decode_version/index.ts index d58c7add67a27..8b3fb6f63d59a 100644 --- a/packages/kbn-securitysolution-es-utils/src/decode_version/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/decode_version/index.ts @@ -23,8 +23,8 @@ export const decodeVersion = ( const parsed = JSON.parse(decoded); if (Array.isArray(parsed) && Number.isInteger(parsed[0]) && Number.isInteger(parsed[1])) { return { - ifPrimaryTerm: parsed[1], - ifSeqNo: parsed[0], + if_primary_term: parsed[1], + if_seq_no: parsed[0], }; } else { return {}; From 761875b402bc22bb86d600abab17de8372bf8b7e Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 09:14:40 +0200 Subject: [PATCH 123/172] use `HttpConnection` for FTR-related clients --- packages/kbn-es-archiver/src/cli.ts | 3 ++- packages/kbn-test/src/es/test_es_cluster.ts | 3 ++- .../src/failed_tests_reporter/report_failures_to_es.ts | 3 ++- test/common/services/elasticsearch.ts | 4 +++- test/common/services/saved_object_info/saved_object_info.ts | 4 ++-- x-pack/test/fleet_api_integration/apis/agents/services.ts | 3 ++- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/kbn-es-archiver/src/cli.ts b/packages/kbn-es-archiver/src/cli.ts index dd3e047e908a7..db54a3bade74b 100644 --- a/packages/kbn-es-archiver/src/cli.ts +++ b/packages/kbn-es-archiver/src/cli.ts @@ -19,7 +19,7 @@ import Fs from 'fs'; import { RunWithCommands, createFlagError, CA_CERT_PATH } from '@kbn/dev-utils'; import { readConfigFile, KbnClient } from '@kbn/test'; -import { Client } from '@elastic/elasticsearch'; +import { Client, HttpConnection } from '@elastic/elasticsearch'; import { EsArchiver } from './es_archiver'; @@ -107,6 +107,7 @@ export function runCli() { const client = new Client({ node: esUrl, tls: esCa ? { ca: esCa } : undefined, + Connection: HttpConnection, }); addCleanupTask(() => client.close()); diff --git a/packages/kbn-test/src/es/test_es_cluster.ts b/packages/kbn-test/src/es/test_es_cluster.ts index 353823a53645b..388d578c9af57 100644 --- a/packages/kbn-test/src/es/test_es_cluster.ts +++ b/packages/kbn-test/src/es/test_es_cluster.ts @@ -11,7 +11,7 @@ import { format } from 'url'; import del from 'del'; // @ts-expect-error in js import { Cluster } from '@kbn/es'; -import { Client } from '@elastic/elasticsearch'; +import { Client, HttpConnection } from '@elastic/elasticsearch'; import type { ToolingLog } from '@kbn/dev-utils'; import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix'; import { esTestConfig } from './es_test_config'; @@ -282,6 +282,7 @@ export function createTestEsCluster< getClient(): Client { return new Client({ node: this.getHostUrls()[0], + Connection: HttpConnection, }); } diff --git a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts index abec5b718a845..a96ca5822775d 100644 --- a/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts +++ b/packages/kbn-test/src/failed_tests_reporter/report_failures_to_es.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Client } from '@elastic/elasticsearch'; +import { Client, HttpConnection } from '@elastic/elasticsearch'; import { createFailError, ToolingLog } from '@kbn/dev-utils'; import { TestFailure } from './get_failures'; @@ -34,6 +34,7 @@ export async function reportFailuresToEs(log: ToolingLog, failures: TestFailure[ username: process.env.TEST_FAILURES_ES_USERNAME, password: process.env.TEST_FAILURES_ES_PASSWORD, }, + Connection: HttpConnection, }); const body = failures.flatMap((failure) => [ diff --git a/test/common/services/elasticsearch.ts b/test/common/services/elasticsearch.ts index 2b093bac814b7..384f98e31bf3c 100644 --- a/test/common/services/elasticsearch.ts +++ b/test/common/services/elasticsearch.ts @@ -8,7 +8,7 @@ import { format as formatUrl } from 'url'; import fs from 'fs'; -import { Client } from '@elastic/elasticsearch'; +import { Client, HttpConnection } from '@elastic/elasticsearch'; import { CA_CERT_PATH } from '@kbn/dev-utils'; import { FtrProviderContext } from '../ftr_provider_context'; @@ -23,6 +23,7 @@ export function ElasticsearchProvider({ getService }: FtrProviderContext): Clien return new Client({ nodes: [formatUrl(config.get('servers.elasticsearch'))], requestTimeout: config.get('timeouts.esRequestTimeout'), + Connection: HttpConnection, }); } else { return new Client({ @@ -31,6 +32,7 @@ export function ElasticsearchProvider({ getService }: FtrProviderContext): Clien }, nodes: [formatUrl(config.get('servers.elasticsearch'))], requestTimeout: config.get('timeouts.esRequestTimeout'), + Connection: HttpConnection, }); } } diff --git a/test/common/services/saved_object_info/saved_object_info.ts b/test/common/services/saved_object_info/saved_object_info.ts index fc46933fb5d4d..3442efcc98438 100644 --- a/test/common/services/saved_object_info/saved_object_info.ts +++ b/test/common/services/saved_object_info/saved_object_info.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Client } from '@elastic/elasticsearch'; +import { Client, HttpConnection } from '@elastic/elasticsearch'; import url from 'url'; import { Either, fromNullable, chain, getOrElse, toError } from 'fp-ts/Either'; import { flow, pipe } from 'fp-ts/function'; @@ -37,7 +37,7 @@ export const types = await pipe( TE.tryCatch( async () => { - const body = await new Client({ node }).search({ + const body = await new Client({ node, Connection: HttpConnection }).search({ index, size: 0, body: query, diff --git a/x-pack/test/fleet_api_integration/apis/agents/services.ts b/x-pack/test/fleet_api_integration/apis/agents/services.ts index be5d2d438f76f..bfaf1ae66252c 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/services.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/services.ts @@ -6,7 +6,7 @@ */ import supertest from 'supertest'; -import { Client } from '@elastic/elasticsearch'; +import { Client, HttpConnection } from '@elastic/elasticsearch'; import { format as formatUrl } from 'url'; import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; @@ -29,6 +29,7 @@ export function getEsClientForAPIKey({ getService }: FtrProviderContext, esApiKe apiKey: esApiKey, }, requestTimeout: config.get('timeouts.esRequestTimeout'), + Connection: HttpConnection, }); } From 4a3f621c6cc0ab62cabbecf89afaec294946c7aa Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 09:59:23 +0200 Subject: [PATCH 124/172] bump client to 29 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 61f01dc5f8907..245665d6b08d5 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "37.0.0", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.27", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.28", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.0.0", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index abd77e3c86fb3..0d0af12328dfb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.27": - version "8.0.0-canary.27" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.27.tgz#ae7a68147809c62dc2858593a8b44bbe365fad15" - integrity sha512-ObEXgSMqNFCBe0l+FaClDidAGBAZfZ7Gwnb7CCHHFPnhi2PLhYi+xQ94TSRTzmKHsurfQyF4kskn5WlYDobjqg== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.28": + version "8.0.0-canary.28" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.28.tgz#6888ad7d7b78bda8f37f37e50a43d44df6ca22d7" + integrity sha512-6t9Dsoj2OxOyzdsZUzcg6cnc4IJUBgX23D5pQymOtldABPg1J86PD65KFIrTiHFvJm/BK2TmTJ8vp/sPpwhbBw== dependencies: - "@elastic/transport" "^0.0.9" + "@elastic/transport" "^0.0.10" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.9": - version "0.0.9" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.9.tgz#608e13fad75eb9d92d80171aeb92aea0351f70c1" - integrity sha512-HgW/nBtwpXpj5RIjhxg03Yd2S5fPYOtjcsXUYW1Yo85Z5pgNDq+lujU6m6CAJBGgrUghtFvkoGzP0vBSpU1weQ== +"@elastic/transport@^0.0.10": + version "0.0.10" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.10.tgz#a2612fd0f26fa1d9721672471af3520ad1d773f6" + integrity sha512-B/8NqBqdB3eRCt1DVXXUfnuiMzB/dFgvu93c1YsC8DZqopgIENE1h9gIVKLH6QiTDm7YVUTDiIUulwbnOjtaaQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From 7e0159d1b06c21523fc4fa5f182a5d3fa0adc3d9 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 09:59:45 +0200 Subject: [PATCH 125/172] Revert "REMOVE me. workaround until fixed in the es client" This reverts commit c038850c09c378977a50c0e3d176810f4b69b5d6. --- .../services/epm/elasticsearch/ingest_pipeline/install.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts index 1e5d3b8887702..42e1bff6ab370 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts @@ -218,7 +218,7 @@ async function installPipeline({ if (pipeline.extension === 'yml') { esClientRequestOptions.headers = { // pipeline is YAML - 'Content-Type': 'application/yaml; compatible-with=8', + 'Content-Type': 'application/yaml', // but we want JSON responses (to extract error messages, status code, or other metadata) Accept: 'application/json', }; From 64997e838a23f39fd6150586c86ecaa1f5941859 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 12:34:53 +0200 Subject: [PATCH 126/172] fix new util --- .../spaces_api_integration/common/lib/space_test_utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts b/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts index c047a741e35da..a4ce22c6c010c 100644 --- a/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts +++ b/x-pack/test/spaces_api_integration/common/lib/space_test_utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import type { Client } from '@elastic/elasticsearch'; import { DEFAULT_SPACE_ID } from '../../../../plugins/spaces/common/constants'; export function getUrlPrefix(spaceId?: string) { @@ -37,7 +37,7 @@ export function getTestScenariosForSpace(spaceId: string) { return [explicitScenario]; } -export function getAggregatedSpaceData(es: KibanaClient, objectTypes: string[]) { +export function getAggregatedSpaceData(es: Client, objectTypes: string[]) { return es.search({ index: '.kibana', body: { From 14737efa9dc586a213204ecd55e1c472d5e45942 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 12:49:15 +0200 Subject: [PATCH 127/172] revert repository changes --- src/core/server/saved_objects/service/lib/repository.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index 506eb3cade897..79be29f0e3450 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -361,11 +361,12 @@ export class SavedObjectsRepository { refresh, body: raw._source, ...(overwrite && version ? decodeRequestVersion(version) : {}), + require_alias: true, }; const { body, statusCode, headers } = id && overwrite - ? await this.client.index({ ...requestParams, require_alias: true }) + ? await this.client.index(requestParams) : await this.client.create(requestParams); // throw if we can't verify a 404 response is from Elasticsearch From 6a9dc91f3ab0dda46af43277051f50a6191eb442 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 12:50:00 +0200 Subject: [PATCH 128/172] do not crash if cannot store event_loop data --- .../server/collectors/event_loop_delays/track_delays.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts index facdb549d0df7..33266cdbd9792 100644 --- a/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts +++ b/src/plugins/kibana_usage_collection/server/collectors/event_loop_delays/track_delays.ts @@ -52,6 +52,10 @@ export function startTrackingEventLoopDelaysUsage( if (shouldReset) { eventLoopDelaysMonitor.reset(); } - await storeHistogram(histogram, internalRepository, instanceUuid); + try { + await storeHistogram(histogram, internalRepository, instanceUuid); + } catch (e) { + // do not crash if cannot store a histogram. + } }); } From 54361122bbb16466c243fbb573c4d998a3bd1bda Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 13:06:59 +0200 Subject: [PATCH 129/172] fix new estypes imports --- .../apps/main/components/doc_table/lib/row_formatter.tsx | 2 +- .../discover/public/application/helpers/format_hit.test.ts | 2 +- src/plugins/discover/public/application/helpers/format_hit.ts | 2 +- src/plugins/discover/public/application/helpers/format_value.ts | 2 +- .../discover/public/application/helpers/get_ignored_reason.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.tsx b/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.tsx index 2702a232f21ef..a73bc3f175be1 100644 --- a/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.tsx +++ b/src/plugins/discover/public/application/apps/main/components/doc_table/lib/row_formatter.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import React, { Fragment } from 'react'; import type { IndexPattern } from 'src/plugins/data/common'; import { MAX_DOC_FIELDS_DISPLAYED } from '../../../../../../../common'; diff --git a/src/plugins/discover/public/application/helpers/format_hit.test.ts b/src/plugins/discover/public/application/helpers/format_hit.test.ts index 2cb46f28dd397..ebf5078238ccf 100644 --- a/src/plugins/discover/public/application/helpers/format_hit.test.ts +++ b/src/plugins/discover/public/application/helpers/format_hit.test.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { indexPatternMock as dataViewMock } from '../../__mocks__/index_pattern'; import { formatHit } from './format_hit'; import { discoverServiceMock } from '../../__mocks__/services'; diff --git a/src/plugins/discover/public/application/helpers/format_hit.ts b/src/plugins/discover/public/application/helpers/format_hit.ts index 3890973a3f3e4..1101439515523 100644 --- a/src/plugins/discover/public/application/helpers/format_hit.ts +++ b/src/plugins/discover/public/application/helpers/format_hit.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DataView, flattenHit } from '../../../../data/common'; import { MAX_DOC_FIELDS_DISPLAYED } from '../../../common'; import { getServices } from '../../kibana_services'; diff --git a/src/plugins/discover/public/application/helpers/format_value.ts b/src/plugins/discover/public/application/helpers/format_value.ts index cc33276790372..933309d6dcf8e 100644 --- a/src/plugins/discover/public/application/helpers/format_value.ts +++ b/src/plugins/discover/public/application/helpers/format_value.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DataView, DataViewField, KBN_FIELD_TYPES } from '../../../../data/common'; import { getServices } from '../../kibana_services'; diff --git a/src/plugins/discover/public/application/helpers/get_ignored_reason.ts b/src/plugins/discover/public/application/helpers/get_ignored_reason.ts index 4d2fb85bdb2c4..bf8df6e000d4c 100644 --- a/src/plugins/discover/public/application/helpers/get_ignored_reason.ts +++ b/src/plugins/discover/public/application/helpers/get_ignored_reason.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { DataViewField, KBN_FIELD_TYPES } from '../../../../data/common'; export enum IgnoredReason { From 6324647456556d91444cb4db80473f03ec5231f2 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 13:36:28 +0200 Subject: [PATCH 130/172] fix more types --- x-pack/plugins/actions/server/usage/actions_telemetry.ts | 2 +- x-pack/plugins/reporting/server/deprecations/reporting_role.ts | 2 +- x-pack/plugins/reporting/server/lib/deprecations/index.ts | 2 +- x-pack/plugins/security/server/deprecations/kibana_user_role.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/actions/server/usage/actions_telemetry.ts b/x-pack/plugins/actions/server/usage/actions_telemetry.ts index 1cb6bf8bfc74c..a4026e3b009d4 100644 --- a/x-pack/plugins/actions/server/usage/actions_telemetry.ts +++ b/x-pack/plugins/actions/server/usage/actions_telemetry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types'; +import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; import { ElasticsearchClient } from 'kibana/server'; import { AlertHistoryEsIndexConnectorId } from '../../common'; import { ActionResult, PreConfiguredAction } from '../types'; diff --git a/x-pack/plugins/reporting/server/deprecations/reporting_role.ts b/x-pack/plugins/reporting/server/deprecations/reporting_role.ts index a2a7e9c78726d..e4575f9875315 100644 --- a/x-pack/plugins/reporting/server/deprecations/reporting_role.ts +++ b/x-pack/plugins/reporting/server/deprecations/reporting_role.ts @@ -8,7 +8,7 @@ import { SecurityGetRoleMappingResponse, SecurityGetUserResponse, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/types'; import { i18n } from '@kbn/i18n'; import type { DeprecationsDetails, diff --git a/x-pack/plugins/reporting/server/lib/deprecations/index.ts b/x-pack/plugins/reporting/server/lib/deprecations/index.ts index 2d55c3b4c22d8..5d8a95695a129 100644 --- a/x-pack/plugins/reporting/server/lib/deprecations/index.ts +++ b/x-pack/plugins/reporting/server/lib/deprecations/index.ts @@ -58,7 +58,7 @@ function deprecationError(title: string, error: Error): DeprecationsDetails[] { ]; } -function getErrorStatusCode(error: any): number { +function getErrorStatusCode(error: any): number | undefined { if (error instanceof errors.ResponseError) { return error.statusCode; } diff --git a/x-pack/plugins/security/server/deprecations/kibana_user_role.ts b/x-pack/plugins/security/server/deprecations/kibana_user_role.ts index d659ea273f05f..ba32446611a62 100644 --- a/x-pack/plugins/security/server/deprecations/kibana_user_role.ts +++ b/x-pack/plugins/security/server/deprecations/kibana_user_role.ts @@ -8,7 +8,7 @@ import type { SecurityGetRoleMappingResponse, SecurityGetUserResponse, -} from '@elastic/elasticsearch/api/types'; +} from '@elastic/elasticsearch/lib/api/types'; import { i18n } from '@kbn/i18n'; import type { From e089067584bbb0d389db236ae5d662a32b0ff63b Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 14:09:39 +0200 Subject: [PATCH 131/172] fix security test types and add ts-ignore for custom ES client --- src/cli_setup/utils.ts | 1 + .../security/server/deprecations/kibana_user_role.test.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli_setup/utils.ts b/src/cli_setup/utils.ts index 65a46b8f5b278..123bf50adcca0 100644 --- a/src/cli_setup/utils.ts +++ b/src/cli_setup/utils.ts @@ -34,6 +34,7 @@ export const kibanaConfigWriter = new KibanaConfigWriter(getConfigPath(), logger export const elasticsearch = new ElasticsearchService(logger).setup({ connectionCheckInterval: duration(Infinity), elasticsearch: { + // @ts-expect-error TODO make sure Client is assignable to KibanaClient, see src/core/server/elasticsearch/client/cluster_client.ts createClient: (type, config) => { const defaults = configSchema.validate({}); return new ClusterClient( diff --git a/x-pack/plugins/security/server/deprecations/kibana_user_role.test.ts b/x-pack/plugins/security/server/deprecations/kibana_user_role.test.ts index da728b12fca91..d971769160df5 100644 --- a/x-pack/plugins/security/server/deprecations/kibana_user_role.test.ts +++ b/x-pack/plugins/security/server/deprecations/kibana_user_role.test.ts @@ -6,7 +6,7 @@ */ import { errors } from '@elastic/elasticsearch'; -import type { SecurityRoleMapping, SecurityUser } from '@elastic/elasticsearch/api/types'; +import type { SecurityRoleMapping, SecurityUser } from '@elastic/elasticsearch/lib/api/types'; import type { PackageInfo, RegisterDeprecationsConfig } from 'src/core/server'; import { From a156a6bb6a184d22e585095f20ee66b0d1fb9c97 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 14:44:23 +0200 Subject: [PATCH 132/172] fix more estypes imports --- .../apm/common/search_strategies/field_stats_types.ts | 2 +- .../server/lib/latency/get_overall_latency_distribution.ts | 2 +- .../server/lib/latency/get_percentile_threshold_value.ts | 2 +- .../queries/field_stats/get_boolean_field_stats.ts | 6 +++--- .../queries/field_stats/get_field_stats.test.ts | 2 +- .../queries/field_stats/get_keyword_field_stats.ts | 5 ++--- .../queries/field_stats/get_numeric_field_stats.ts | 5 ++--- .../server/lib/search_strategies/utils/field_stats_utils.ts | 3 ++- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/apm/common/search_strategies/field_stats_types.ts b/x-pack/plugins/apm/common/search_strategies/field_stats_types.ts index d96bb4408f0e8..d63dd7f8d58a1 100644 --- a/x-pack/plugins/apm/common/search_strategies/field_stats_types.ts +++ b/x-pack/plugins/apm/common/search_strategies/field_stats_types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SearchStrategyParams } from './types'; export interface FieldStatsCommonRequestParams extends SearchStrategyParams { diff --git a/x-pack/plugins/apm/server/lib/latency/get_overall_latency_distribution.ts b/x-pack/plugins/apm/server/lib/latency/get_overall_latency_distribution.ts index 787304c3f8dcd..ad1914d921211 100644 --- a/x-pack/plugins/apm/server/lib/latency/get_overall_latency_distribution.ts +++ b/x-pack/plugins/apm/server/lib/latency/get_overall_latency_distribution.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ProcessorEvent } from '../../../common/processor_event'; diff --git a/x-pack/plugins/apm/server/lib/latency/get_percentile_threshold_value.ts b/x-pack/plugins/apm/server/lib/latency/get_percentile_threshold_value.ts index 0d417a370e0b6..996e039841b88 100644 --- a/x-pack/plugins/apm/server/lib/latency/get_percentile_threshold_value.ts +++ b/x-pack/plugins/apm/server/lib/latency/get_percentile_threshold_value.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ProcessorEvent } from '../../../common/processor_event'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_boolean_field_stats.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_boolean_field_stats.ts index 551ecfe3cd4ea..da5493376426c 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_boolean_field_stats.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_boolean_field_stats.ts @@ -6,8 +6,8 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { SearchRequest } from '@elastic/elasticsearch/api/types'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; + import { buildSamplerAggregation } from '../../utils/field_stats_utils'; import { FieldValuePair } from '../../../../../common/search_strategies/types'; import { @@ -22,7 +22,7 @@ export const getBooleanFieldStatsRequest = ( params: FieldStatsCommonRequestParams, fieldName: string, termFilters?: FieldValuePair[] -): SearchRequest => { +): estypes.SearchRequest => { const query = getQueryWithParams({ params, termFilters }); const { index, samplerShardSize } = params; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_field_stats.test.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_field_stats.test.ts index d3cee1c4ca596..2775d755c9907 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_field_stats.test.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_field_stats.test.ts @@ -9,7 +9,7 @@ import { ENVIRONMENT_ALL } from '../../../../../common/environment_filter_values import { getNumericFieldStatsRequest } from './get_numeric_field_stats'; import { getKeywordFieldStatsRequest } from './get_keyword_field_stats'; import { getBooleanFieldStatsRequest } from './get_boolean_field_stats'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ElasticsearchClient } from 'kibana/server'; import { fetchFieldsStats } from './get_fields_stats'; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_keyword_field_stats.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_keyword_field_stats.ts index b15449657cba5..a9c727457d0ae 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_keyword_field_stats.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_keyword_field_stats.ts @@ -6,8 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { SearchRequest } from '@elastic/elasticsearch/api/types'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FieldValuePair } from '../../../../../common/search_strategies/types'; import { getQueryWithParams } from '../get_query_with_params'; import { buildSamplerAggregation } from '../../utils/field_stats_utils'; @@ -22,7 +21,7 @@ export const getKeywordFieldStatsRequest = ( params: FieldStatsCommonRequestParams, fieldName: string, termFilters?: FieldValuePair[] -): SearchRequest => { +): estypes.SearchRequest => { const query = getQueryWithParams({ params, termFilters }); const { index, samplerShardSize } = params; diff --git a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_numeric_field_stats.ts b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_numeric_field_stats.ts index bab4a1af29b65..c45d4356cfe23 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_numeric_field_stats.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/queries/field_stats/get_numeric_field_stats.ts @@ -6,9 +6,8 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { SearchRequest } from '@elastic/elasticsearch/api/types'; import { find, get } from 'lodash'; -import { estypes } from '@elastic/elasticsearch/index'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { NumericFieldStats, FieldStatsCommonRequestParams, @@ -80,7 +79,7 @@ export const fetchNumericFieldStats = async ( field: FieldValuePair, termFilters?: FieldValuePair[] ): Promise => { - const request: SearchRequest = getNumericFieldStatsRequest( + const request: estypes.SearchRequest = getNumericFieldStatsRequest( params, field.fieldName, termFilters diff --git a/x-pack/plugins/apm/server/lib/search_strategies/utils/field_stats_utils.ts b/x-pack/plugins/apm/server/lib/search_strategies/utils/field_stats_utils.ts index 2eb67ec501bab..7f98f771c50e2 100644 --- a/x-pack/plugins/apm/server/lib/search_strategies/utils/field_stats_utils.ts +++ b/x-pack/plugins/apm/server/lib/search_strategies/utils/field_stats_utils.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; + /* * Contains utility functions for building and processing queries. */ From 144e7b1f0b012115d35dfe875a97a4b74f44cc22 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 14:54:49 +0200 Subject: [PATCH 133/172] yet more ts violations --- .../server/endpoint/services/actions.ts | 12 ++++++------ .../server/endpoint/utils/audit_log_helpers.ts | 16 ++++++++-------- .../routes/__mocks__/request_responses.ts | 2 +- .../server/routes/api/snapshots.ts | 1 - .../transform/server/routes/api/transforms.ts | 3 +-- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/security_solution/server/endpoint/services/actions.ts b/x-pack/plugins/security_solution/server/endpoint/services/actions.ts index b25b599517300..87455e6c578bc 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/actions.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/actions.ts @@ -6,8 +6,8 @@ */ import { ElasticsearchClient, Logger } from 'kibana/server'; -import { SearchHit, SearchResponse } from '@elastic/elasticsearch/api/types'; -import { ApiResponse } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { TransportResult } from '@elastic/elasticsearch'; import { AGENT_ACTIONS_INDEX, AGENT_ACTIONS_RESULTS_INDEX } from '../../../../fleet/common'; import { ENDPOINT_ACTION_RESPONSES_INDEX } from '../../../common/endpoint/constants'; import { SecuritySolutionRequestHandlerContext } from '../../types'; @@ -89,8 +89,8 @@ const getActivityLog = async ({ endDate: string; logger: Logger; }): Promise => { - let actionsResult: ApiResponse, unknown>; - let responsesResult: ApiResponse, unknown>; + let actionsResult: TransportResult, unknown>; + let responsesResult: TransportResult, unknown>; try { // fetch actions with matching agent_id @@ -126,14 +126,14 @@ const getActivityLog = async ({ // label record as `action`, `fleetAction` const responses = categorizeResponseResults({ results: responsesResult?.body?.hits?.hits as Array< - SearchHit + estypes.SearchHit >, }); // label record as `response`, `fleetResponse` const actions = categorizeActionResults({ results: actionsResult?.body?.hits?.hits as Array< - SearchHit + estypes.SearchHit >, }); diff --git a/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts b/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts index f75b265bf24d7..c50a460a377c7 100644 --- a/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts +++ b/x-pack/plugins/security_solution/server/endpoint/utils/audit_log_helpers.ts @@ -7,8 +7,8 @@ import { Logger } from 'kibana/server'; import { SearchRequest } from 'src/plugins/data/public'; -import { SearchHit, SearchResponse } from '@elastic/elasticsearch/api/types'; -import { ApiResponse } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import { TransportResult } from '@elastic/elasticsearch'; import { AGENT_ACTIONS_INDEX, AGENT_ACTIONS_RESULTS_INDEX } from '../../../../fleet/common'; import { ENDPOINT_ACTIONS_INDEX, @@ -84,7 +84,7 @@ export const getUniqueLogData = (activityLogEntries: ActivityLogEntry[]): Activi export const categorizeResponseResults = ({ results, }: { - results: Array>; + results: Array>; }): Array => { return results?.length ? results?.map((e) => { @@ -108,7 +108,7 @@ export const categorizeResponseResults = ({ export const categorizeActionResults = ({ results, }: { - results: Array>; + results: Array>; }): Array => { return results?.length ? results?.map((e) => { @@ -153,7 +153,7 @@ export const getActionRequestsResult = async ({ from: number; }): Promise<{ actionIds: string[]; - actionRequests: ApiResponse, unknown>; + actionRequests: TransportResult, unknown>; }> => { const dateFilters = getDateFilters({ startDate, endDate }); const baseActionFilters = [ @@ -189,7 +189,7 @@ export const getActionRequestsResult = async ({ }, }; - let actionRequests: ApiResponse, unknown>; + let actionRequests: TransportResult, unknown>; try { const esClient = context.core.elasticsearch.client.asCurrentUser; actionRequests = await esClient.search(actionsSearchQuery, queryOptions); @@ -220,7 +220,7 @@ export const getActionResponsesResult = async ({ actionIds: string[]; startDate: string; endDate: string; -}): Promise, unknown>> => { +}): Promise, unknown>> => { const dateFilters = getDateFilters({ startDate, endDate }); const baseResponsesFilter = [ { term: { agent_id: elasticAgentId } }, @@ -246,7 +246,7 @@ export const getActionResponsesResult = async ({ }, }; - let actionResponses: ApiResponse, unknown>; + let actionResponses: TransportResult, unknown>; try { const esClient = context.core.elasticsearch.client.asCurrentUser; actionResponses = await esClient.search(responsesSearchQuery, queryOptions); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts index 1520b4da82d8d..d91d9b29c5b59 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { SavedObjectsFindResponse, SavedObjectsFindResult } from 'src/core/server'; import { ActionResult } from '../../../../../../actions/server'; diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts b/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts index d514458082ed4..7ff68f7958bfc 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/snapshots.ts @@ -157,7 +157,6 @@ export function registerSnapshotsRoutes({ repositories, // @ts-expect-error @elastic/elasticsearch https://github.com/elastic/elasticsearch-specification/issues/845 errors: fetchedSnapshots?.failures, - // @ts-expect-error @elastic/elasticsearch "total" is a new field in the response total: fetchedSnapshots?.total, }, }); diff --git a/x-pack/plugins/transform/server/routes/api/transforms.ts b/x-pack/plugins/transform/server/routes/api/transforms.ts index 2d428c630b0a4..e19ac2c39c129 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms.ts @@ -145,7 +145,7 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) { */ router.get( { path: addBasePath('transforms/_stats'), validate: false }, - license.guardApiRoute( + license.guardApiRoute( async (ctx, req, res) => { try { const { body } = @@ -555,7 +555,6 @@ const previewTransformHandler: RequestHandler< try { const reqBody = req.body; const { body } = await ctx.core.elasticsearch.client.asCurrentUser.transform.previewTransform({ - // @ts-expect-error max_page_search_size is required in TransformPivot body: reqBody, }); if (isLatestTransform(reqBody)) { From 1bb50f9bd25743b3a13d99574fbf605cd269a71c Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 15:00:25 +0200 Subject: [PATCH 134/172] line by line fixing is hard --- .../server/routes/deprecations/kibana_user_role.test.ts | 6 +++--- .../server/routes/deprecations/kibana_user_role.ts | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.test.ts b/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.test.ts index b2ae2543bd652..3c9a775d7a054 100644 --- a/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.test.ts +++ b/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.test.ts @@ -6,7 +6,7 @@ */ import { errors } from '@elastic/elasticsearch'; -import type { SecurityRoleMapping, SecurityUser } from '@elastic/elasticsearch/api/types'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import type { RequestHandler, RouteConfig } from 'src/core/server'; @@ -18,11 +18,11 @@ import type { SecurityRequestHandlerContext, SecurityRouter } from '../../types' import { routeDefinitionParamsMock } from '../index.mock'; import { defineKibanaUserRoleDeprecationRoutes } from './kibana_user_role'; -function createMockUser(user: Partial = {}) { +function createMockUser(user: Partial = {}) { return { enabled: true, username: 'userA', roles: ['roleA'], metadata: {}, ...user }; } -function createMockRoleMapping(mapping: Partial = {}) { +function createMockRoleMapping(mapping: Partial = {}) { return { enabled: true, roles: ['roleA'], rules: {}, metadata: {}, ...mapping }; } diff --git a/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.ts b/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.ts index 21bb9db7329b6..5d5e2a12f86a6 100644 --- a/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.ts +++ b/x-pack/plugins/security/server/routes/deprecations/kibana_user_role.ts @@ -5,10 +5,7 @@ * 2.0. */ -import type { - SecurityGetRoleMappingResponse, - SecurityGetUserResponse, -} from '@elastic/elasticsearch/api/types'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { RouteDefinitionParams } from '..'; import { KIBANA_ADMIN_ROLE_NAME, KIBANA_USER_ROLE_NAME } from '../../deprecations'; @@ -29,7 +26,7 @@ export function defineKibanaUserRoleDeprecationRoutes({ router, logger }: RouteD validate: false, }, createLicensedRouteHandler(async (context, request, response) => { - let users: SecurityGetUserResponse; + let users: estypes.SecurityGetUserResponse; try { users = (await context.core.elasticsearch.client.asCurrentUser.security.getUser()).body; } catch (err) { @@ -92,7 +89,7 @@ export function defineKibanaUserRoleDeprecationRoutes({ router, logger }: RouteD validate: false, }, createLicensedRouteHandler(async (context, request, response) => { - let roleMappings: SecurityGetRoleMappingResponse; + let roleMappings: estypes.SecurityGetRoleMappingResponse; try { roleMappings = ( await context.core.elasticsearch.client.asCurrentUser.security.getRoleMapping() From 63cc7baa84a18e43aa5d4abe54491ab3c50cdc70 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 15:29:26 +0200 Subject: [PATCH 135/172] adapt `evaluateAlert` from infra as it's also used from FTR tests --- .../metric_threshold/lib/evaluate_alert.ts | 17 +++++++++++------ .../apis/metrics_ui/metric_threshold_alert.ts | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts index 71c18d9f7cf04..0a27d4d7e0cd9 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts @@ -198,8 +198,9 @@ const getMetric: ( (response) => response.aggregations?.groupings?.after_key ); const compositeBuckets = (await getAllCompositeData( + // must provide meta: true as this function is also consumed with a plain client from FTR // @ts-expect-error @elastic/elasticsearch SearchResponse.body.timeout is not required - (body) => esClient.search({ body, index }), + (body) => esClient.search({ body, index }, { meta: true }), searchBody, bucketSelector, afterKeyHandler @@ -221,11 +222,15 @@ const getMetric: ( ); return groupedResults; } - const { body: result } = await esClient.search({ - // @ts-expect-error buckets_path is not compatible - body: searchBody, - index, - }); + const { body: result } = await esClient.search( + { + // @ts-expect-error buckets_path is not compatible + body: searchBody, + index, + }, + // must provide meta: true as this function is also consumed with a plain client from FTR + { meta: true } + ); return { [UNGROUPED_FACTORY_KEY]: getValuesFromAggregations( diff --git a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts index 69f760c52c5d6..128d0cc44398e 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts @@ -104,6 +104,7 @@ export default function ({ getService }: FtrProviderContext) { metricAlias: 'filebeat-*', }; const timeFrame = { end: DATES.ten_thousand_plus.max }; + // @ts-expect-error es FTR service is a Client, not a KibanaClient const results = await evaluateAlert(esClient, params, config, [], timeFrame); expect(results).to.eql([ { @@ -145,6 +146,7 @@ export default function ({ getService }: FtrProviderContext) { metricAlias: 'filebeat-*', }; const timeFrame = { end: DATES.ten_thousand_plus.max }; + // @ts-expect-error es FTR service is a Client, not a KibanaClient const results = await evaluateAlert(esClient, params, config, [], timeFrame); expect(results).to.eql([ { From 5e2a6f5605b14ab6bdae73cf0b215788d928aa15 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 15:42:08 +0200 Subject: [PATCH 136/172] use convertToKibanaClient in FTR test instead of meta:true in plugin code --- .../metric_threshold/lib/evaluate_alert.ts | 17 ++++++----------- .../apis/metrics_ui/metric_threshold_alert.ts | 10 +++++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts index 0a27d4d7e0cd9..71c18d9f7cf04 100644 --- a/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts +++ b/x-pack/plugins/infra/server/lib/alerting/metric_threshold/lib/evaluate_alert.ts @@ -198,9 +198,8 @@ const getMetric: ( (response) => response.aggregations?.groupings?.after_key ); const compositeBuckets = (await getAllCompositeData( - // must provide meta: true as this function is also consumed with a plain client from FTR // @ts-expect-error @elastic/elasticsearch SearchResponse.body.timeout is not required - (body) => esClient.search({ body, index }, { meta: true }), + (body) => esClient.search({ body, index }), searchBody, bucketSelector, afterKeyHandler @@ -222,15 +221,11 @@ const getMetric: ( ); return groupedResults; } - const { body: result } = await esClient.search( - { - // @ts-expect-error buckets_path is not compatible - body: searchBody, - index, - }, - // must provide meta: true as this function is also consumed with a plain client from FTR - { meta: true } - ); + const { body: result } = await esClient.search({ + // @ts-expect-error buckets_path is not compatible + body: searchBody, + index, + }); return { [UNGROUPED_FACTORY_KEY]: getValuesFromAggregations( diff --git a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts index 128d0cc44398e..5e8dcd683375e 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts @@ -81,7 +81,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; - describe('Metric Threshold Alerts Executor', () => { + describe('FOO Metric Threshold Alerts Executor', () => { describe('with 10K plus docs', () => { before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/ten_thousand_plus')); after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/ten_thousand_plus')); @@ -104,8 +104,8 @@ export default function ({ getService }: FtrProviderContext) { metricAlias: 'filebeat-*', }; const timeFrame = { end: DATES.ten_thousand_plus.max }; - // @ts-expect-error es FTR service is a Client, not a KibanaClient - const results = await evaluateAlert(esClient, params, config, [], timeFrame); + const kbnClient = convertToKibanaClient(esClient); + const results = await evaluateAlert(kbnClient, params, config, [], timeFrame); expect(results).to.eql([ { '*': { @@ -146,8 +146,8 @@ export default function ({ getService }: FtrProviderContext) { metricAlias: 'filebeat-*', }; const timeFrame = { end: DATES.ten_thousand_plus.max }; - // @ts-expect-error es FTR service is a Client, not a KibanaClient - const results = await evaluateAlert(esClient, params, config, [], timeFrame); + const kbnClient = convertToKibanaClient(esClient); + const results = await evaluateAlert(kbnClient, params, config, [], timeFrame); expect(results).to.eql([ { web: { From ab1e13f253823188ad52037655cfe6e9498183e1 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 18:06:50 +0200 Subject: [PATCH 137/172] migrate from deprecated API in fleet --- x-pack/plugins/fleet/server/services/agents/crud.ts | 7 +++++-- .../fleet/server/services/api_keys/enrollment_api_key.ts | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/agents/crud.ts b/x-pack/plugins/fleet/server/services/agents/crud.ts index d0ec4bd9cb540..b8d7c284309df 100644 --- a/x-pack/plugins/fleet/server/services/agents/crud.ts +++ b/x-pack/plugins/fleet/server/services/agents/crud.ts @@ -126,10 +126,12 @@ export async function getAgentsByKuery( index: AGENTS_INDEX, from: (page - 1) * perPage, size: perPage, - sort: `${sortField}:${sortOrder}`, track_total_hits: true, ignore_unavailable: true, - body, + body: { + ...body, + sort: [{ [sortField]: { order: sortOrder } }], + }, }); let agents = res.body.hits.hits.map(searchHitToAgent); @@ -219,6 +221,7 @@ export function isAgentDocument( } export type ESAgentDocumentResult = estypes.MgetHit; + export async function getAgentDocuments( esClient: ElasticsearchClient, agentIds: string[] diff --git a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts index 58ca19c06a742..166bd26e0d706 100644 --- a/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts +++ b/x-pack/plugins/fleet/server/services/api_keys/enrollment_api_key.ts @@ -42,10 +42,12 @@ export async function listEnrollmentApiKeys( index: ENROLLMENT_API_KEYS_INDEX, from: (page - 1) * perPage, size: perPage, - sort: 'created_at:desc', track_total_hits: true, ignore_unavailable: true, - body: query ? { query } : undefined, + body: { + sort: [{ created_at: { order: 'desc' } }], + ...(query ? { query } : {}), + }, }); // @ts-expect-error @elastic/elasticsearch _source is optional From 67569312533dd9b2ac25177739fc3b8b1ef53073 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 19:20:36 +0200 Subject: [PATCH 138/172] fix intergration tests --- .../datafeed_preview_validation.ts | 2 +- .../upgrade_assistant/upgrade_assistant.ts | 2 +- .../security_and_spaces/tests/migrations.ts | 22 ++++++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/x-pack/test/api_integration/apis/ml/job_validation/datafeed_preview_validation.ts b/x-pack/test/api_integration/apis/ml/job_validation/datafeed_preview_validation.ts index c16050e08c886..b449fb903958f 100644 --- a/x-pack/test/api_integration/apis/ml/job_validation/datafeed_preview_validation.ts +++ b/x-pack/test/api_integration/apis/ml/job_validation/datafeed_preview_validation.ts @@ -12,7 +12,7 @@ */ import expect from '@kbn/expect'; -import { estypes } from '@elastic/elasticsearch'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { FtrProviderContext } from '../../../ftr_provider_context'; import { USER } from '../../../../functional/services/ml/security_common'; import { COMMON_REQUEST_HEADERS } from '../../../../functional/services/ml/common_api'; diff --git a/x-pack/test/api_integration/apis/upgrade_assistant/upgrade_assistant.ts b/x-pack/test/api_integration/apis/upgrade_assistant/upgrade_assistant.ts index 7dd7a1584d0ef..92e96f41659bc 100644 --- a/x-pack/test/api_integration/apis/upgrade_assistant/upgrade_assistant.ts +++ b/x-pack/test/api_integration/apis/upgrade_assistant/upgrade_assistant.ts @@ -89,7 +89,7 @@ export default function ({ getService }: FtrProviderContext) { // Refetch the index and verify settings were updated correctly try { - const { body: indexSettingsResponse } = await es.indices.getSettings({ + const indexSettingsResponse = await es.indices.getSettings({ index: indexName, }); diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts index 03b29d394072a..d4eaf0d3dbf80 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/migrations.ts @@ -104,10 +104,13 @@ export default ({ getService }: FtrProviderContext): void => { alertId: string; }; references: [{}]; - }>({ - index: '.kibana', - id: 'siem-detection-engine-rule-status:d62d2980-27c4-11ec-92b0-f7b47106bb35', - }); + }>( + { + index: '.kibana', + id: 'siem-detection-engine-rule-status:d62d2980-27c4-11ec-92b0-f7b47106bb35', + }, + { meta: true } + ); expect(response.statusCode).to.eql(200); // references exist and are expected values @@ -128,10 +131,13 @@ export default ({ getService }: FtrProviderContext): void => { it('migrates legacy siem-detection-engine-rule-status and retains other attributes as the same attributes as before', async () => { const response = await es.get<{ 'siem-detection-engine-rule-status': IRuleStatusSOAttributes; - }>({ - index: '.kibana', - id: 'siem-detection-engine-rule-status:d62d2980-27c4-11ec-92b0-f7b47106bb35', - }); + }>( + { + index: '.kibana', + id: 'siem-detection-engine-rule-status:d62d2980-27c4-11ec-92b0-f7b47106bb35', + }, + { meta: true } + ); expect(response.statusCode).to.eql(200); expect(response.body._source?.['siem-detection-engine-rule-status']).to.eql({ From 8240a8443014fb05728903d3c92125859ea6fa3f Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 20:05:18 +0200 Subject: [PATCH 139/172] fix fleet tests --- x-pack/test/fleet_api_integration/apis/agents/services.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x-pack/test/fleet_api_integration/apis/agents/services.ts b/x-pack/test/fleet_api_integration/apis/agents/services.ts index 27fcb49e0fcf6..f9f779271934e 100644 --- a/x-pack/test/fleet_api_integration/apis/agents/services.ts +++ b/x-pack/test/fleet_api_integration/apis/agents/services.ts @@ -37,10 +37,8 @@ export function setupFleetAndAgents(providerContext: FtrProviderContext) { before(async () => { // Use elastic/fleet-server service account to execute setup to verify privilege configuration const es = providerContext.getService('es'); - const { - body: { token }, - // @ts-expect-error SecurityCreateServiceTokenRequest should not require `name` - } = await es.security.createServiceToken({ + // @ts-expect-error SecurityCreateServiceTokenRequest should not require `name` + const { token } = await es.security.createServiceToken({ namespace: 'elastic', service: 'fleet-server', }); From 31aa7ad8f43f111ef1c6204e4da661f10f76bac8 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 21 Oct 2021 21:22:53 +0200 Subject: [PATCH 140/172] fix another fleet test --- x-pack/test/fleet_api_integration/apis/epm/setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/fleet_api_integration/apis/epm/setup.ts b/x-pack/test/fleet_api_integration/apis/epm/setup.ts index 051636ad11f5a..ce967160f33e1 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/setup.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/setup.ts @@ -52,7 +52,7 @@ export default function (providerContext: FtrProviderContext) { it('allows elastic/fleet-server user to call required APIs', async () => { const { - body: { token }, + token, // @ts-expect-error SecurityCreateServiceTokenRequest should not require `name` } = await es.security.createServiceToken({ namespace: 'elastic', From f08a6e6a81b8c35c6602aad5ff092a30d3010c7b Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Thu, 21 Oct 2021 22:38:01 +0200 Subject: [PATCH 141/172] fix more tests --- .../apis/epm/install_overrides.ts | 60 +++++++++++-------- .../tests/session_idle/cleanup.ts | 2 +- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts index f61e19f8709c5..9e8bab3854b54 100644 --- a/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts +++ b/x-pack/test/fleet_api_integration/apis/epm/install_overrides.ts @@ -57,28 +57,37 @@ export default function (providerContext: FtrProviderContext) { '.fleet_component_template-1', ]); - ({ body } = await es.transport.request({ - method: 'GET', - path: `/_component_template/${templateName}@mappings`, - })); + ({ body } = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${templateName}@mappings`, + }, + { meta: true } + )); // The mappings override provided in the package is set in the mappings component template expect(body.component_templates[0].component_template.template.mappings.dynamic).to.be(false); - ({ body } = await es.transport.request({ - method: 'GET', - path: `/_component_template/${templateName}@settings`, - })); + ({ body } = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${templateName}@settings`, + }, + { meta: true } + )); // The settings override provided in the package is set in the settings component template expect( body.component_templates[0].component_template.template.settings.index.lifecycle.name ).to.be('reference'); - ({ body } = await es.transport.request({ - method: 'GET', - path: `/_component_template/${templateName}@custom`, - })); + ({ body } = await es.transport.request( + { + method: 'GET', + path: `/_component_template/${templateName}@custom`, + }, + { meta: true } + )); // The user_settings component template is an empty/stub template at first const storedTemplate = body.component_templates[0].component_template.template.settings; @@ -102,19 +111,22 @@ export default function (providerContext: FtrProviderContext) { })); // simulate the result - ({ body } = await es.transport.request({ - method: 'POST', - path: `/_index_template/_simulate/${templateName}`, - // body: indexTemplate, // I *think* this should work, but it doesn't - body: { - index_patterns: [`${templateName}-*`], - composed_of: [ - `${templateName}@mappings`, - `${templateName}@settings`, - `${templateName}@custom`, - ], + ({ body } = await es.transport.request( + { + method: 'POST', + path: `/_index_template/_simulate/${templateName}`, + // body: indexTemplate, // I *think* this should work, but it doesn't + body: { + index_patterns: [`${templateName}-*`], + composed_of: [ + `${templateName}@mappings`, + `${templateName}@settings`, + `${templateName}@custom`, + ], + }, }, - })); + { meta: true } + )); expect(body).to.eql({ template: { diff --git a/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts b/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts index 86b1cff3568f3..beb7bdfbdfccc 100644 --- a/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts +++ b/x-pack/test/security_api_integration/tests/session_idle/cleanup.ts @@ -45,7 +45,7 @@ export default function ({ getService }: FtrProviderContext) { async function getNumberOfSessionDocuments() { return ( // @ts-expect-error doesn't handle total as number - (await es.search({ index: '.kibana_security_session*' })).body.hits.total.value as number + (await es.search({ index: '.kibana_security_session*' })).hits.total.value as number ); } From f5b9335e4a1b49cb80dde5667f1b16192e182318 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 22 Oct 2021 00:17:22 +0200 Subject: [PATCH 142/172] let's call it a day --- .../apis/agent_policy/agent_policy_with_agents_setup.ts | 2 +- .../security_api_integration/tests/session_lifespan/cleanup.ts | 2 +- .../upgrade_assistant/reindexing.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts index a4f67cd58d935..87bb8b7d1c913 100644 --- a/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts +++ b/x-pack/test/fleet_api_integration/apis/agent_policy/agent_policy_with_agents_setup.ts @@ -50,7 +50,7 @@ export default function (providerContext: FtrProviderContext) { }); // @ts-expect-error TotalHit - return res.body.hits.total.value !== 0; + return res.hits.total.value !== 0; } // Test all the side effect that should occurs when we create|update an agent policy diff --git a/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts b/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts index 69bbe9ea00341..6b5308f623805 100644 --- a/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts +++ b/x-pack/test/security_api_integration/tests/session_lifespan/cleanup.ts @@ -40,7 +40,7 @@ export default function ({ getService }: FtrProviderContext) { async function getNumberOfSessionDocuments() { return ( // @ts-expect-error doesn't handle total as number - (await es.search({ index: '.kibana_security_session*' })).body.hits.total.value as number + (await es.search({ index: '.kibana_security_session*' })).hits.total.value as number ); } diff --git a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js index 7b43bb1f4dd38..d52f407e8483f 100644 --- a/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js +++ b/x-pack/test/upgrade_assistant_integration/upgrade_assistant/reindexing.js @@ -207,7 +207,7 @@ export default function ({ getService }) { await assertQueueState(undefined, 0); // Check that the closed index is still closed after reindexing - const { body: resolvedIndices } = await es.indices.resolveIndex({ + const resolvedIndices = await es.indices.resolveIndex({ name: nameOfIndexThatShouldBeClosed, }); From ed2d516f68de0a98e41a6b792d9ad19cfc048334 Mon Sep 17 00:00:00 2001 From: "Christiane (Tina) Heiligers" Date: Thu, 21 Oct 2021 22:58:05 -0700 Subject: [PATCH 143/172] Removes custom header check on 404 responses, includes es client ProductNotSupportedError in EsUnavailableError conditional (#116029) * Removes custom header check on 404 responses, includes es client ProductNotSupportedError in EsUnavailableError conditional * Updates proxy response integration test --- src/core/server/elasticsearch/client/mocks.ts | 4 +- src/core/server/elasticsearch/index.ts | 5 - .../supported_server_response_check.test.ts | 41 ---- .../supported_server_response_check.ts | 35 --- ...collect_multi_namespace_references.test.ts | 17 -- .../lib/collect_multi_namespace_references.ts | 11 - .../service/lib/decorate_es_error.test.ts | 22 +- .../service/lib/decorate_es_error.ts | 12 +- .../saved_objects/service/lib/errors.test.ts | 41 ---- .../saved_objects/service/lib/errors.ts | 12 - .../repository_with_proxy.test.ts | 36 ++- .../lib/internal_bulk_resolve.test.mock.ts | 12 - .../service/lib/internal_bulk_resolve.test.ts | 21 -- .../service/lib/internal_bulk_resolve.ts | 11 - .../service/lib/repository.test.js | 221 ------------------ .../saved_objects/service/lib/repository.ts | 105 ++------- .../service/lib/update_objects_spaces.test.ts | 38 --- .../service/lib/update_objects_spaces.ts | 11 - 18 files changed, 50 insertions(+), 605 deletions(-) delete mode 100644 src/core/server/elasticsearch/supported_server_response_check.test.ts delete mode 100644 src/core/server/elasticsearch/supported_server_response_check.ts diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index 18ef6a712f9c0..19a6872a80cf1 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -12,7 +12,6 @@ import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; import type { PublicKeys } from '@kbn/utility-types'; import { ElasticsearchClient } from './types'; import { ICustomClusterClient } from './cluster_client'; -import { PRODUCT_RESPONSE_HEADER } from '../supported_server_response_check'; const omittedProps = [ 'diagnostic', @@ -23,6 +22,9 @@ const omittedProps = [ 'helpers', ] as Array>; +// the product header expected in every response from es +const PRODUCT_RESPONSE_HEADER = 'x-elastic-product'; + // use jest.requireActual() to prevent weird errors when people mock @elastic/elasticsearch const { Client: UnmockedClient } = jest.requireActual('@elastic/elasticsearch'); const createInternalClientMock = (res?: Promise): DeeplyMockedKeys => { diff --git a/src/core/server/elasticsearch/index.ts b/src/core/server/elasticsearch/index.ts index 72636879b22c3..cf7d8a0ce0de2 100644 --- a/src/core/server/elasticsearch/index.ts +++ b/src/core/server/elasticsearch/index.ts @@ -38,8 +38,3 @@ export type { ElasticsearchErrorDetails, } from './client'; export { getRequestDebugMeta, getErrorMessage } from './client'; -export { - isSupportedEsServer, - isNotFoundFromUnsupportedServer, - PRODUCT_RESPONSE_HEADER, -} from './supported_server_response_check'; diff --git a/src/core/server/elasticsearch/supported_server_response_check.test.ts b/src/core/server/elasticsearch/supported_server_response_check.test.ts deleted file mode 100644 index 589e947142fc3..0000000000000 --- a/src/core/server/elasticsearch/supported_server_response_check.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { isNotFoundFromUnsupportedServer } from './supported_server_response_check'; - -describe('#isNotFoundFromUnsupportedServer', () => { - it('returns true with not found response from unsupported server', () => { - const rawResponse = { - statusCode: 404, - headers: {}, - }; - - const result = isNotFoundFromUnsupportedServer(rawResponse); - expect(result).toBe(true); - }); - - it('returns false with not found response from supported server', async () => { - const rawResponse = { - statusCode: 404, - headers: { 'x-elastic-product': 'Elasticsearch' }, - }; - - const result = isNotFoundFromUnsupportedServer(rawResponse); - expect(result).toBe(false); - }); - - it('returns false when not a 404', async () => { - const rawResponse = { - statusCode: 200, - headers: { 'x-elastic-product': 'Elasticsearch' }, - }; - - const result = isNotFoundFromUnsupportedServer(rawResponse); - expect(result).toBe(false); - }); -}); diff --git a/src/core/server/elasticsearch/supported_server_response_check.ts b/src/core/server/elasticsearch/supported_server_response_check.ts deleted file mode 100644 index 91aa06e132de8..0000000000000 --- a/src/core/server/elasticsearch/supported_server_response_check.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -export const PRODUCT_RESPONSE_HEADER = 'x-elastic-product'; -/** - * Response headers check to determine if the response is from Elasticsearch - * @param headers Response headers - * @returns boolean - */ -// This check belongs to the elasticsearch service as a dedicated helper method. -export const isSupportedEsServer = ( - headers: Record | null | undefined -) => { - return !!headers && headers[PRODUCT_RESPONSE_HEADER] === 'Elasticsearch'; -}; - -/** - * Check to ensure that a 404 response does not come from Elasticsearch - * - * WARNING: This is a hack to work around for 404 responses returned from a proxy. - * We're aiming to minimise the risk of data loss when consumers act on Not Found errors - * - * @param response response from elasticsearch client call - * @returns boolean 'true' if the status code is 404 and the Elasticsearch product header is missing/unexpected value - */ -export const isNotFoundFromUnsupportedServer = (args: { - statusCode: number | null; - headers: Record | null; -}): boolean => { - return args.statusCode === 404 && !isSupportedEsServer(args.headers); -}; diff --git a/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts b/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts index fe97208a6168d..201077cf4d733 100644 --- a/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts +++ b/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts @@ -319,23 +319,6 @@ describe('collectMultiNamespaceReferences', () => { // obj3 is excluded from the results ]); }); - it(`handles 404 responses that don't come from Elasticsearch`, async () => { - const createEsUnavailableNotFoundError = () => { - return SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - }; - const obj1 = { type: MULTI_NAMESPACE_OBJ_TYPE_1, id: 'id-1' }; - const params = setup([obj1]); - client.mget.mockReturnValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { docs: [] }, - { statusCode: 404 }, - {} - ) - ); - await expect(() => collectMultiNamespaceReferences(params)).rejects.toThrowError( - createEsUnavailableNotFoundError() - ); - }); describe('legacy URL aliases', () => { it('uses the PointInTimeFinder to search for legacy URL aliases', async () => { diff --git a/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.ts b/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.ts index 7acbaaea1f5d7..278964c934ba0 100644 --- a/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.ts +++ b/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.ts @@ -7,12 +7,10 @@ */ import * as esKuery from '@kbn/es-query'; -import { isNotFoundFromUnsupportedServer } from '../../../elasticsearch'; import { LegacyUrlAlias, LEGACY_URL_ALIAS_TYPE } from '../../object_types'; import type { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry'; import type { SavedObjectsSerializer } from '../../serialization'; import type { SavedObject, SavedObjectsBaseOptions } from '../../types'; -import { SavedObjectsErrorHelpers } from './errors'; import { getRootFields } from './included_fields'; import { getSavedObjectFromSource, rawDocExistsInNamespace } from './internal_utils'; import type { @@ -199,15 +197,6 @@ async function getObjectsAndReferences({ { body: { docs: makeBulkGetDocs(bulkGetObjects) } }, { ignore: [404] } ); - // exit early if we can't verify a 404 response is from Elasticsearch - if ( - isNotFoundFromUnsupportedServer({ - statusCode: bulkGetResponse.statusCode, - headers: bulkGetResponse.headers, - }) - ) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } const newObjectsToGet = new Set(); for (let i = 0; i < bulkGetObjects.length; i++) { // For every element in bulkGetObjects, there should be a matching element in bulkGetResponse.body.docs diff --git a/src/core/server/saved_objects/service/lib/decorate_es_error.test.ts b/src/core/server/saved_objects/service/lib/decorate_es_error.test.ts index 4e187e85f81a7..e7dd355910362 100644 --- a/src/core/server/saved_objects/service/lib/decorate_es_error.test.ts +++ b/src/core/server/saved_objects/service/lib/decorate_es_error.test.ts @@ -53,6 +53,16 @@ describe('savedObjectsClient/decorateEsError', () => { expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true); }); + it('makes ProductNotSupportedError a SavedObjectsClient/EsUnavailable error', () => { + const error = new esErrors.ProductNotSupportedError( + 'reason', + elasticsearchClientMock.createApiResponse() + ); + expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(false); + expect(decorateEsError(error)).toBe(error); + expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true); + }); + it('makes Conflict a SavedObjectsClient/Conflict error', () => { const error = new esErrors.ResponseError( elasticsearchClientMock.createApiResponse({ statusCode: 409 }) @@ -109,18 +119,6 @@ describe('savedObjectsClient/decorateEsError', () => { expect(SavedObjectsErrorHelpers.isNotFoundError(genericError)).toBe(true); }); - it('makes NotFound errors generic NotFoundEsUnavailableError errors when response is from unsupported server', () => { - const error = new esErrors.ResponseError( - // explicitly override the headers - elasticsearchClientMock.createApiResponse({ statusCode: 404, headers: {} }) - ); - expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(false); - const genericError = decorateEsError(error); - expect(genericError).not.toBe(error); - expect(SavedObjectsErrorHelpers.isNotFoundError(genericError)).toBe(false); - expect(SavedObjectsErrorHelpers.isEsUnavailableError(genericError)).toBe(true); - }); - it('if saved objects index does not exist makes NotFound a SavedObjectsClient/generalError', () => { const error = new esErrors.ResponseError( elasticsearchClientMock.createApiResponse({ diff --git a/src/core/server/saved_objects/service/lib/decorate_es_error.ts b/src/core/server/saved_objects/service/lib/decorate_es_error.ts index b7062c935815d..d8734b141bd9b 100644 --- a/src/core/server/saved_objects/service/lib/decorate_es_error.ts +++ b/src/core/server/saved_objects/service/lib/decorate_es_error.ts @@ -8,7 +8,7 @@ import { errors as esErrors } from '@elastic/elasticsearch'; import { get } from 'lodash'; -import { isSupportedEsServer, ElasticsearchErrorDetails } from '../../../elasticsearch'; +import { ElasticsearchErrorDetails } from '../../../elasticsearch'; const responseErrors = { isServiceUnavailable: (statusCode?: number) => statusCode === 503, @@ -20,7 +20,8 @@ const responseErrors = { isBadRequest: (statusCode?: number) => statusCode === 400, isTooManyRequests: (statusCode?: number) => statusCode === 429, }; -const { ConnectionError, NoLivingConnectionsError, TimeoutError } = esErrors; +const { ConnectionError, NoLivingConnectionsError, TimeoutError, ProductNotSupportedError } = + esErrors; const SCRIPT_CONTEXT_DISABLED_REGEX = /(?:cannot execute scripts using \[)([a-z]*)(?:\] context)/; const INLINE_SCRIPTS_DISABLED_MESSAGE = 'cannot execute [inline] scripts'; @@ -30,6 +31,7 @@ type EsErrors = | esErrors.ConnectionError | esErrors.NoLivingConnectionsError | esErrors.TimeoutError + | esErrors.ProductNotSupportedError | esErrors.ResponseError; export function decorateEsError(error: EsErrors) { @@ -42,6 +44,7 @@ export function decorateEsError(error: EsErrors) { error instanceof ConnectionError || error instanceof NoLivingConnectionsError || error instanceof TimeoutError || + error instanceof ProductNotSupportedError || responseErrors.isServiceUnavailable(error.statusCode) ) { return SavedObjectsErrorHelpers.decorateEsUnavailableError(error, reason); @@ -70,11 +73,6 @@ export function decorateEsError(error: EsErrors) { if (match && match.length > 0) { return SavedObjectsErrorHelpers.decorateIndexAliasNotFoundError(error, match[1]); } - // Throw EsUnavailable error if the 404 is not from elasticsearch - // Needed here to verify Product support for any non-ignored 404 responses from calls to ES - if (!isSupportedEsServer(error?.meta?.headers)) { - return SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } return SavedObjectsErrorHelpers.createGenericNotFoundError(); } diff --git a/src/core/server/saved_objects/service/lib/errors.test.ts b/src/core/server/saved_objects/service/lib/errors.test.ts index 3bea693429254..a366dce626ec2 100644 --- a/src/core/server/saved_objects/service/lib/errors.test.ts +++ b/src/core/server/saved_objects/service/lib/errors.test.ts @@ -439,45 +439,4 @@ describe('savedObjectsClient/errorTypes', () => { }); }); }); - - describe('NotFoundEsUnavailableError', () => { - it('makes an error identifiable as an EsUnavailable error', () => { - const error = SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError('foo', 'bar'); - expect(SavedObjectsErrorHelpers.isEsUnavailableError(error)).toBe(true); - }); - - it('returns a boom error', () => { - const error = SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError('foo', 'bar'); - expect(error).toHaveProperty('isBoom', true); - }); - - it('decorates the error message with the saved object that was not found', () => { - const error = SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError('foo', 'bar'); - expect(error.output.payload).toHaveProperty( - 'message', - 'x-elastic-product not present or not recognized: Saved object [foo/bar] not found' - ); - }); - - describe('error.output', () => { - it('specifies the saved object that was not found', () => { - const error = SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError( - 'foo', - 'bar' - ); - expect(error.output.payload).toHaveProperty( - 'message', - 'x-elastic-product not present or not recognized: Saved object [foo/bar] not found' - ); - }); - - it('sets statusCode to 503', () => { - const error = SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError( - 'foo', - 'bar' - ); - expect(error.output).toHaveProperty('statusCode', 503); - }); - }); - }); }); diff --git a/src/core/server/saved_objects/service/lib/errors.ts b/src/core/server/saved_objects/service/lib/errors.ts index 7412e744f19e7..581145c7c09d1 100644 --- a/src/core/server/saved_objects/service/lib/errors.ts +++ b/src/core/server/saved_objects/service/lib/errors.ts @@ -202,16 +202,4 @@ export class SavedObjectsErrorHelpers { public static isGeneralError(error: Error | DecoratedError) { return isSavedObjectsClientError(error) && error[code] === CODE_GENERAL_ERROR; } - - public static createGenericNotFoundEsUnavailableError( - // type and id not available in all operations (e.g. mget) - type: string | null = null, - id: string | null = null - ) { - const notFoundError = this.createGenericNotFoundError(type, id); - return this.decorateEsUnavailableError( - new Error(`${notFoundError.message}`), - `x-elastic-product not present or not recognized` - ); - } } diff --git a/src/core/server/saved_objects/service/lib/integration_tests/repository_with_proxy.test.ts b/src/core/server/saved_objects/service/lib/integration_tests/repository_with_proxy.test.ts index 925b23a64f03e..b767b28c90608 100644 --- a/src/core/server/saved_objects/service/lib/integration_tests/repository_with_proxy.test.ts +++ b/src/core/server/saved_objects/service/lib/integration_tests/repository_with_proxy.test.ts @@ -289,17 +289,11 @@ describe('404s from proxies', () => { let repository: ISavedObjectsRepository; const myTypeDocs: SavedObject[] = []; - const genericNotFoundEsUnavailableError = (err: any, type?: string, id?: string) => { + const SavedObjectsClientEsUnavailable = (err: any) => { expect(err?.output?.statusCode).toBe(503); - if (type && id) { - expect(err?.output?.payload?.message).toBe( - `x-elastic-product not present or not recognized: Saved object [${type}/${id}] not found` - ); - } else { - expect(err?.output?.payload?.message).toBe( - `x-elastic-product not present or not recognized: Not Found` - ); - } + expect(err?.output?.payload?.message).toBe( + `The client noticed that the server is not Elasticsearch and we do not support this unknown product.` + ); }; beforeAll(async () => { @@ -341,7 +335,7 @@ describe('404s from proxies', () => { } catch (err) { myError = err; } - expect(genericNotFoundEsUnavailableError(myError, 'my_type', 'myTypeId1')); + expect(SavedObjectsClientEsUnavailable(myError)); }); it('returns an EsUnavailable error on `update` requests that are interrupted', async () => { @@ -354,7 +348,7 @@ describe('404s from proxies', () => { } catch (err) { updateError = err; } - expect(genericNotFoundEsUnavailableError(updateError)); + expect(SavedObjectsClientEsUnavailable(updateError)); }); it('returns an EsUnavailable error on `bulkCreate` requests with a 404 proxy response and wrong product header', async () => { @@ -383,7 +377,7 @@ describe('404s from proxies', () => { } catch (err) { bulkCreateError = err; } - expect(genericNotFoundEsUnavailableError(bulkCreateError)); + expect(SavedObjectsClientEsUnavailable(bulkCreateError)); }); it('returns an EsUnavailable error on `find` requests with a 404 proxy response and wrong product header', async () => { @@ -394,7 +388,7 @@ describe('404s from proxies', () => { } catch (err) { findErr = err; } - expect(genericNotFoundEsUnavailableError(findErr)); + expect(SavedObjectsClientEsUnavailable(findErr)); expect(findErr?.output?.payload?.error).toBe('Service Unavailable'); }); @@ -405,7 +399,7 @@ describe('404s from proxies', () => { } catch (err) { deleteErr = err; } - expect(genericNotFoundEsUnavailableError(deleteErr, 'my_type', 'myTypeId1')); + expect(SavedObjectsClientEsUnavailable(deleteErr)); }); it('returns an EsUnavailable error on `bulkResolve` requests with a 404 proxy response and wrong product header for an exact match', async () => { @@ -417,7 +411,7 @@ describe('404s from proxies', () => { } catch (err) { testBulkResolveErr = err; } - expect(genericNotFoundEsUnavailableError(testBulkResolveErr)); + expect(SavedObjectsClientEsUnavailable(testBulkResolveErr)); }); it('returns an EsUnavailable error on `resolve` requests with a 404 proxy response and wrong product header for an exact match', async () => { @@ -428,7 +422,7 @@ describe('404s from proxies', () => { } catch (err) { testResolveErr = err; } - expect(genericNotFoundEsUnavailableError(testResolveErr)); + expect(SavedObjectsClientEsUnavailable(testResolveErr)); }); it('returns an EsUnavailable error on `bulkGet` requests with a 404 proxy response and wrong product header', async () => { @@ -440,7 +434,7 @@ describe('404s from proxies', () => { } catch (err) { bulkGetError = err; } - expect(genericNotFoundEsUnavailableError(bulkGetError)); + expect(SavedObjectsClientEsUnavailable(bulkGetError)); }); it('returns an EsUnavailable error on `openPointInTimeForType` requests with a 404 proxy response and wrong product header', async () => { @@ -451,7 +445,7 @@ describe('404s from proxies', () => { } catch (err) { openPitErr = err; } - expect(genericNotFoundEsUnavailableError(openPitErr)); + expect(SavedObjectsClientEsUnavailable(openPitErr)); }); it('returns an EsUnavailable error on `checkConflicts` requests with a 404 proxy response and wrong product header', async () => { @@ -468,7 +462,7 @@ describe('404s from proxies', () => { } catch (err) { checkConflictsErr = err; } - expect(genericNotFoundEsUnavailableError(checkConflictsErr)); + expect(SavedObjectsClientEsUnavailable(checkConflictsErr)); }); it('returns an EsUnavailable error on `deleteByNamespace` requests with a 404 proxy response and wrong product header', async () => { @@ -479,7 +473,7 @@ describe('404s from proxies', () => { } catch (err) { deleteByNamespaceErr = err; } - expect(genericNotFoundEsUnavailableError(deleteByNamespaceErr)); + expect(SavedObjectsClientEsUnavailable(deleteByNamespaceErr)); }); }); }); diff --git a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.mock.ts b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.mock.ts index fbd774f1c10d5..513add01cdd83 100644 --- a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.mock.ts +++ b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.mock.ts @@ -7,7 +7,6 @@ */ import type * as InternalUtils from './internal_utils'; -import type { isNotFoundFromUnsupportedServer } from '../../../elasticsearch'; export const mockGetSavedObjectFromSource = jest.fn() as jest.MockedFunction< typeof InternalUtils['getSavedObjectFromSource'] @@ -24,14 +23,3 @@ jest.mock('./internal_utils', () => { rawDocExistsInNamespace: mockRawDocExistsInNamespace, }; }); - -export const mockIsNotFoundFromUnsupportedServer = jest.fn() as jest.MockedFunction< - typeof isNotFoundFromUnsupportedServer ->; -jest.mock('../../../elasticsearch', () => { - const actual = jest.requireActual('../../../elasticsearch'); - return { - ...actual, - isNotFoundFromUnsupportedServer: mockIsNotFoundFromUnsupportedServer, - }; -}); diff --git a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.ts b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.ts index 5403e146509ae..4120b077a8981 100644 --- a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.ts +++ b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.test.ts @@ -9,7 +9,6 @@ import { mockGetSavedObjectFromSource, mockRawDocExistsInNamespace, - mockIsNotFoundFromUnsupportedServer, } from './internal_bulk_resolve.test.mock'; import type { DeeplyMockedKeys } from '@kbn/utility-types/jest'; @@ -35,8 +34,6 @@ beforeEach(() => { ); mockRawDocExistsInNamespace.mockReset(); mockRawDocExistsInNamespace.mockReturnValue(true); // return true by default - mockIsNotFoundFromUnsupportedServer.mockReset(); - mockIsNotFoundFromUnsupportedServer.mockReturnValue(false); }); describe('internalBulkResolve', () => { @@ -173,24 +170,6 @@ describe('internalBulkResolve', () => { return { saved_object: `mock-obj-for-${id}`, outcome: 'conflict', alias_target_id }; } - it('throws if mget call results in non-ES-originated 404 error', async () => { - const objects = [{ type: OBJ_TYPE, id: '1' }]; - const params = setup(objects, { namespace: 'space-x' }); - mockBulkResults( - { found: false } // fetch alias for obj 1 - ); - mockMgetResults( - { found: false } // fetch obj 1 (actual result body doesn't matter, just needs statusCode and headers) - ); - mockIsNotFoundFromUnsupportedServer.mockReturnValue(true); - - await expect(() => internalBulkResolve(params)).rejects.toThrow( - SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError() - ); - expect(client.bulk).toHaveBeenCalledTimes(1); - expect(client.mget).toHaveBeenCalledTimes(1); - }); - it('returns an empty array if no object args are passed in', async () => { const params = setup([], { namespace: 'space-x' }); diff --git a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts index 558faad125af9..19f774fb068b6 100644 --- a/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts +++ b/src/core/server/saved_objects/service/lib/internal_bulk_resolve.ts @@ -13,7 +13,6 @@ import { CORE_USAGE_STATS_TYPE, REPOSITORY_RESOLVE_OUTCOME_STATS, } from '../../../core_usage_data'; -import { isNotFoundFromUnsupportedServer } from '../../../elasticsearch'; import { LegacyUrlAlias, LEGACY_URL_ALIAS_TYPE } from '../../object_types'; import type { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry'; import type { SavedObjectsRawDocSource, SavedObjectsSerializer } from '../../serialization'; @@ -141,16 +140,6 @@ export async function internalBulkResolve( { ignore: [404] } ) : undefined; - // exit early if a 404 isn't from elasticsearch - if ( - bulkGetResponse && - isNotFoundFromUnsupportedServer({ - statusCode: bulkGetResponse.statusCode, - headers: bulkGetResponse.headers, - }) - ) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } let getResponseIndex = 0; let aliasTargetIndex = 0; diff --git a/src/core/server/saved_objects/service/lib/repository.test.js b/src/core/server/saved_objects/service/lib/repository.test.js index 985d609f2da59..32b13ba160d5e 100644 --- a/src/core/server/saved_objects/service/lib/repository.test.js +++ b/src/core/server/saved_objects/service/lib/repository.test.js @@ -46,8 +46,6 @@ const createGenericNotFoundError = (...args) => SavedObjectsErrorHelpers.createGenericNotFoundError(...args).output.payload; const createUnsupportedTypeError = (...args) => SavedObjectsErrorHelpers.createUnsupportedTypeError(...args).output.payload; -const createGenericNotFoundEsUnavailableError = (...args) => - SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(...args).output.payload; describe('SavedObjectsRepository', () => { let client; @@ -690,29 +688,6 @@ describe('SavedObjectsRepository', () => { }); }; - const unsupportedProductBulkCreateMgetError = async (objects, options) => { - const multiNamespaceObjects = objects.filter( - ({ type, id }) => registry.isMultiNamespace(type) && id - ); - if (multiNamespaceObjects?.length) { - const response = getMockMgetResponse(multiNamespaceObjects, options?.namespace); - client.mget.mockResolvedValue( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { ...response }, - { statusCode: 404 }, - {} - ) - ); - } - const response = getMockBulkCreateResponse(objects, options?.namespace); - client.bulk.mockResolvedValue( - elasticsearchClientMock.createSuccessTransportRequestPromise(response) - ); - await expect(savedObjectsRepository.bulkCreate(objects, options)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError() - ); - }; - it(`throws when options.namespace is '*'`, async () => { await expect( savedObjectsRepository.bulkCreate([obj3], { namespace: ALL_NAMESPACES_STRING }) @@ -868,13 +843,6 @@ describe('SavedObjectsRepository', () => { const expectedErrorResult = { type: obj3.type, id: obj3.id, error: 'Oh no, a bulk error!' }; await bulkCreateError(obj3, true, expectedErrorResult); }); - - it(`throws when ES mget action returns 404 with missing Elasticsearch header`, async () => { - const objects = [obj1, { ...obj2, type: MULTI_NAMESPACE_ISOLATED_TYPE }]; - await unsupportedProductBulkCreateMgetError(objects); - expect(client.mget).toHaveBeenCalledTimes(1); - expect(client.bulk).toHaveBeenCalledTimes(0); - }); }); describe('migration', () => { @@ -1136,21 +1104,6 @@ describe('SavedObjectsRepository', () => { }); }; - const unsupportedProductBulkGetMgetError = async (objects, options) => { - const response = getMockMgetResponse(objects, options?.namespace); - client.mget.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { ...response }, - { statusCode: 404 }, - {} - ) - ); - await expect(bulkGet(objects, options)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError() - ); - expect(client.mget).toHaveBeenCalledTimes(1); - }; - it(`throws when options.namespace is '*'`, async () => { const obj = { type: 'dashboard', id: 'three' }; await expect( @@ -1218,12 +1171,6 @@ describe('SavedObjectsRepository', () => { }; await bulkGetError(obj, true, expectErrorNotFound(obj)); }); - - it(`throws when ES mget action responds with a 404 and a missing Elasticsearch product header`, async () => { - const getId = (type, id) => `${type}:${id}`; - await unsupportedProductBulkGetMgetError([obj1, obj2]); // returns 404 without required product header - _expectClientCallArgs([obj1, obj2], { getId }); - }); }); describe('returns', () => { @@ -1681,34 +1628,6 @@ describe('SavedObjectsRepository', () => { saved_objects: [expectSuccess(obj1), expectErrorNotFound(_obj), expectSuccess(obj2)], }); }; - const unsupportedProductBulkUpdateMgetError = async (objects, options, includeOriginId) => { - const multiNamespaceObjects = objects.filter(({ type }) => registry.isMultiNamespace(type)); - if (multiNamespaceObjects?.length) { - const response = getMockMgetResponse(multiNamespaceObjects, options?.namespace); - client.mget.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { ...response }, - { statusCode: 404 }, - {} - ) - ); - } - const response = getMockBulkUpdateResponse(objects, options?.namespace, includeOriginId); - client.bulk.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise(response) - ); - - await expect(savedObjectsRepository.bulkUpdate(objects, options)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError() - ); - expect(client.mget).toHaveBeenCalledTimes(multiNamespaceObjects?.length ? 1 : 0); - }; - - it(`throws when ES mget action responds with a 404 and a missing Elasticsearch product header`, async () => { - const objects = [obj1, { ...obj2, type: MULTI_NAMESPACE_ISOLATED_TYPE }]; - await unsupportedProductBulkUpdateMgetError(objects); - expect(client.mget).toHaveBeenCalledTimes(1); - }); it(`throws when options.namespace is '*'`, async () => { await expect( @@ -1910,24 +1829,6 @@ describe('SavedObjectsRepository', () => { savedObjectsRepository.checkConflicts([obj1], { namespace: ALL_NAMESPACES_STRING }) ).rejects.toThrowError(createBadRequestError('"options.namespace" cannot be "*"')); }); - - it(`throws when not found responses aren't from Elasticsearch`, async () => { - const checkConflictsMgetError = async (objects, options) => { - const response = getMockMgetResponse(objects, options?.namespace); - client.mget.mockResolvedValue( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { ...response }, - { statusCode: 404 }, - {} - ) - ); - await expect(checkConflicts(objects, options)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError() - ); - expect(client.mget).toHaveBeenCalledTimes(1); - }; - await checkConflictsMgetError([obj1, obj2], { namespace: 'default' }); - }); }); describe('returns', () => { @@ -2515,11 +2416,6 @@ describe('SavedObjectsRepository', () => { createGenericNotFoundError(type, id) ); }; - const expectNotFoundEsUnavailableError = async (type, id) => { - await expect(savedObjectsRepository.delete(type, id)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError(type, id) - ); - }; it(`throws when options.namespace is '*'`, async () => { await expect( @@ -2553,24 +2449,6 @@ describe('SavedObjectsRepository', () => { expect(client.get).toHaveBeenCalledTimes(1); }); - it(`throws when ES is unable to find the document during get with missing Elasticsearch header`, async () => { - client.get.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { found: false }, - { statusCode: 404 }, - {} - ) - ); - await expectNotFoundEsUnavailableError(MULTI_NAMESPACE_ISOLATED_TYPE, id); - }); - - it(`throws when ES is unable to find the index during get with missing Elasticsearch header`, async () => { - client.get.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise({}, { statusCode: 404 }, {}) - ); - await expectNotFoundEsUnavailableError(MULTI_NAMESPACE_ISOLATED_TYPE, id); - }); - it(`throws when the type is multi-namespace and the document exists, but not in this namespace`, async () => { const response = getMockGetResponse({ type: MULTI_NAMESPACE_ISOLATED_TYPE, id }, namespace); client.get.mockResolvedValueOnce( @@ -2885,22 +2763,6 @@ describe('SavedObjectsRepository', () => { savedObjectsRepository.removeReferencesTo(type, id, defaultOptions) ).rejects.toThrowError(createConflictError(type, id)); }); - - it(`throws on 404 with missing Elasticsearch header`, async () => { - client.updateByQuery.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { - updated: updatedCount, - }, - { statusCode: 404 }, - {} - ) - ); - await expect( - savedObjectsRepository.removeReferencesTo(type, id, defaultOptions) - ).rejects.toThrowError(createGenericNotFoundEsUnavailableError(type, id)); - expect(client.updateByQuery).toHaveBeenCalledTimes(1); - }); }); }); @@ -3077,21 +2939,6 @@ describe('SavedObjectsRepository', () => { }); describe('errors', () => { - const findNotSupportedServerError = async (options, namespace) => { - const expectedSearchResults = generateSearchResults(namespace); - client.search.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { ...expectedSearchResults }, - { statusCode: 404 }, - {} - ) - ); - await expect(savedObjectsRepository.find(options)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError() - ); - expect(getSearchDslNS.getSearchDsl).toHaveBeenCalledTimes(1); - expect(client.search).toHaveBeenCalledTimes(1); - }; it(`throws when type is not defined`, async () => { await expect(savedObjectsRepository.find({})).rejects.toThrowError( 'options.type must be a string or an array of strings' @@ -3172,11 +3019,6 @@ describe('SavedObjectsRepository', () => { expect(getSearchDslNS.getSearchDsl).not.toHaveBeenCalled(); expect(client.search).not.toHaveBeenCalled(); }); - - it(`throws when ES is unable to find with missing Elasticsearch`, async () => { - await findNotSupportedServerError({ type }); - expect(client.search).toHaveBeenCalledTimes(1); - }); }); describe('returns', () => { @@ -3548,11 +3390,6 @@ describe('SavedObjectsRepository', () => { createGenericNotFoundError(type, id) ); }; - const expectNotFoundEsUnavailableError = async (type, id) => { - await expect(savedObjectsRepository.get(type, id)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError(type, id) - ); - }; it(`throws when options.namespace is '*'`, async () => { await expect( @@ -3596,19 +3433,6 @@ describe('SavedObjectsRepository', () => { }); expect(client.get).toHaveBeenCalledTimes(1); }); - - it(`throws when ES does not return the correct header when finding the document during get`, async () => { - client.get.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { found: false }, - { statusCode: 404 }, - {} - ) - ); - await expectNotFoundEsUnavailableError(type, id); - - expect(client.get).toHaveBeenCalledTimes(1); - }); }); describe('returns', () => { @@ -4279,11 +4103,6 @@ describe('SavedObjectsRepository', () => { createGenericNotFoundError(type, id) ); }; - const expectNotFoundEsUnavailableError = async (type, id) => { - await expect(savedObjectsRepository.update(type, id)).rejects.toThrowError( - createGenericNotFoundEsUnavailableError(type, id) - ); - }; it(`throws when options.namespace is '*'`, async () => { await expect( @@ -4317,26 +4136,6 @@ describe('SavedObjectsRepository', () => { expect(client.get).toHaveBeenCalledTimes(1); }); - it(`throws when ES is unable to find the document during get with missing Elasticsearch header`, async () => { - client.get.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { found: false }, - { statusCode: 404 }, - {} - ) - ); - await expectNotFoundEsUnavailableError(MULTI_NAMESPACE_ISOLATED_TYPE, id); - expect(client.get).toHaveBeenCalledTimes(1); - }); - - it(`throws when ES is unable to find the index during get with missing Elasticsearch header`, async () => { - client.get.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise({}, { statusCode: 404 }, {}) - ); - await expectNotFoundEsUnavailableError(MULTI_NAMESPACE_ISOLATED_TYPE, id); - expect(client.get).toHaveBeenCalledTimes(1); - }); - it(`throws when type is multi-namespace and the document exists, but not in this namespace`, async () => { const response = getMockGetResponse({ type: MULTI_NAMESPACE_ISOLATED_TYPE, id }, namespace); client.get.mockResolvedValueOnce( @@ -4458,21 +4257,6 @@ describe('SavedObjectsRepository', () => { ); }; - const unsupportedProductExpectNotFoundError = async (type, options) => { - const results = generateResults(); - client.openPointInTime.mockResolvedValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { ...results }, - { statusCode: 404 }, - {} - ) - ); - await expect( - savedObjectsRepository.openPointInTimeForType(type, options) - ).rejects.toThrowError(createGenericNotFoundEsUnavailableError()); - expect(client.openPointInTime).toHaveBeenCalledTimes(1); - }; - it(`throws when ES is unable to find the index`, async () => { client.openPointInTime.mockResolvedValueOnce( elasticsearchClientMock.createSuccessTransportRequestPromise({}, { statusCode: 404 }) @@ -4491,11 +4275,6 @@ describe('SavedObjectsRepository', () => { await test(HIDDEN_TYPE); await test(['unknownType', HIDDEN_TYPE]); }); - - it(`throws on 404 with missing Elasticsearch product header`, async () => { - await unsupportedProductExpectNotFoundError(type); - expect(client.openPointInTime).toHaveBeenCalledTimes(1); - }); }); describe('returns', () => { diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index 79c91ad98a430..9f69396fac838 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -10,7 +10,6 @@ import { omit, isObject } from 'lodash'; import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import * as esKuery from '@kbn/es-query'; import type { ElasticsearchClient } from '../../../elasticsearch/'; -import { isSupportedEsServer, isNotFoundFromUnsupportedServer } from '../../../elasticsearch'; import type { Logger } from '../../../logging'; import { getRootPropertiesObjects, IndexMapping } from '../../mappings'; import { @@ -366,15 +365,11 @@ export class SavedObjectsRepository { require_alias: true, }; - const { body, statusCode, headers } = + const { body } = id && overwrite ? await this.client.index(requestParams) : await this.client.create(requestParams); - // throw if we can't verify a 404 response is from Elasticsearch - if (isNotFoundFromUnsupportedServer({ statusCode, headers })) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(id, type); - } return this._rawToSavedObject({ ...raw, ...body, @@ -462,16 +457,7 @@ export class SavedObjectsRepository { { ignore: [404] } ) : undefined; - // throw if we can't verify a 404 response is from Elasticsearch - if ( - bulkGetResponse && - isNotFoundFromUnsupportedServer({ - statusCode: bulkGetResponse.statusCode, - headers: bulkGetResponse.headers, - }) - ) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } + let bulkRequestIndexCounter = 0; const bulkCreateParams: object[] = []; const expectedBulkResults: Array, Record>> = @@ -650,16 +636,7 @@ export class SavedObjectsRepository { { ignore: [404] } ) : undefined; - // throw if we can't verify a 404 response is from Elasticsearch - if ( - bulkGetResponse && - isNotFoundFromUnsupportedServer({ - statusCode: bulkGetResponse.statusCode, - headers: bulkGetResponse.headers, - }) - ) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } + const errors: SavedObjectsCheckConflictsResponse['errors'] = []; expectedBulkGetResults.forEach((expectedResult) => { if (isLeft(expectedResult)) { @@ -731,7 +708,7 @@ export class SavedObjectsRepository { } } - const { body, statusCode, headers } = await this.client.delete( + const { body, statusCode } = await this.client.delete( { id: rawId, index: this.getIndexForType(type), @@ -741,10 +718,6 @@ export class SavedObjectsRepository { { ignore: [404] } ); - if (isNotFoundFromUnsupportedServer({ statusCode, headers })) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(type, id); - } - const deleted = body.result === 'deleted'; if (deleted) { return {}; @@ -793,7 +766,7 @@ export class SavedObjectsRepository { const match2 = buildNode('not', buildNode('is', 'type', LEGACY_URL_ALIAS_TYPE)); const kueryNode = buildNode('or', [match1, match2]); - const { body, statusCode, headers } = await this.client.updateByQuery( + const { body } = await this.client.updateByQuery( { index: this.getIndicesForTypes(typesToUpdate), refresh: options.refresh, @@ -822,10 +795,6 @@ export class SavedObjectsRepository { }, { ignore: [404] } ); - // throw if we can't verify a 404 response is from Elasticsearch - if (isNotFoundFromUnsupportedServer({ statusCode, headers })) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } return body; } @@ -970,16 +939,10 @@ export class SavedObjectsRepository { }, }; - const { body, statusCode, headers } = await this.client.search( - esOptions, - { - ignore: [404], - } - ); + const { body, statusCode } = await this.client.search(esOptions, { + ignore: [404], + }); if (statusCode === 404) { - if (!isSupportedEsServer(headers)) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } // 404 is only possible here if the index is missing, which // we don't want to leak, see "404s from missing index" above return { @@ -1086,16 +1049,7 @@ export class SavedObjectsRepository { { ignore: [404] } ) : undefined; - // fail fast if we can't verify a 404 is from Elasticsearch - if ( - bulkGetResponse && - isNotFoundFromUnsupportedServer({ - statusCode: bulkGetResponse.statusCode, - headers: bulkGetResponse.headers, - }) - ) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } + return { saved_objects: expectedBulkGetResults.map((expectedResult) => { if (isLeft(expectedResult)) { @@ -1186,7 +1140,7 @@ export class SavedObjectsRepository { throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id); } const namespace = normalizeNamespace(options.namespace); - const { body, statusCode, headers } = await this.client.get( + const { body, statusCode } = await this.client.get( { id: this._serializer.generateRawId(namespace, type, id), index: this.getIndexForType(type), @@ -1194,10 +1148,7 @@ export class SavedObjectsRepository { { ignore: [404] } ); const indexNotFound = statusCode === 404; - // check if we have the elasticsearch header when index is not found and if we do, ensure it is Elasticsearch - if (indexNotFound && !isSupportedEsServer(headers)) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(type, id); - } + if ( !isFoundGetResponse(body) || indexNotFound || @@ -1326,9 +1277,6 @@ export class SavedObjectsRepository { require_alias: true, }) .catch((err) => { - if (SavedObjectsErrorHelpers.isEsUnavailableError(err)) { - throw err; - } if (SavedObjectsErrorHelpers.isNotFoundError(err)) { // see "404s from missing index" above throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id); @@ -1501,16 +1449,7 @@ export class SavedObjectsRepository { } ) : undefined; - // fail fast if we can't verify a 404 response is from Elasticsearch - if ( - bulkGetResponse && - isNotFoundFromUnsupportedServer({ - statusCode: bulkGetResponse.statusCode, - headers: bulkGetResponse.headers, - }) - ) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } + let bulkUpdateRequestIndexCounter = 0; const bulkUpdateParams: object[] = []; const expectedBulkUpdateResults: Array, Record>> = @@ -1644,7 +1583,7 @@ export class SavedObjectsRepository { // we need to target all SO indices as all types of objects may have references to the given SO. const targetIndices = this.getIndicesForTypes(allTypes); - const { body, statusCode, headers } = await this.client.updateByQuery( + const { body } = await this.client.updateByQuery( { index: targetIndices, refresh, @@ -1677,10 +1616,7 @@ export class SavedObjectsRepository { }, { ignore: [404] } ); - // fail fast if we can't verify a 404 is from Elasticsearch - if (isNotFoundFromUnsupportedServer({ statusCode, headers })) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(type, id); - } + if (body.failures?.length) { throw SavedObjectsErrorHelpers.createConflictError( type, @@ -1954,16 +1890,12 @@ export class SavedObjectsRepository { ...(preference ? { preference } : {}), }; - const { body, statusCode, headers } = await this.client.openPointInTime(esOptions, { + const { body, statusCode } = await this.client.openPointInTime(esOptions, { ignore: [404], }); if (statusCode === 404) { - if (!isSupportedEsServer(headers)) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } else { - throw SavedObjectsErrorHelpers.createGenericNotFoundError(); - } + throw SavedObjectsErrorHelpers.createGenericNotFoundError(); } return { @@ -2134,7 +2066,7 @@ export class SavedObjectsRepository { throw new Error(`Cannot make preflight get request for non-multi-namespace type '${type}'.`); } - const { body, statusCode, headers } = await this.client.get( + const { body, statusCode } = await this.client.get( { id: this._serializer.generateRawId(undefined, type, id), index: this.getIndexForType(type), @@ -2156,9 +2088,6 @@ export class SavedObjectsRepository { savedObjectNamespaces: initialNamespaces ?? getSavedObjectNamespaces(namespace, body), rawDocSource: body, }; - } else if (isNotFoundFromUnsupportedServer({ statusCode, headers })) { - // checking if the 404 is from Elasticsearch - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(type, id); } return { checkResult: 'not_found', diff --git a/src/core/server/saved_objects/service/lib/update_objects_spaces.test.ts b/src/core/server/saved_objects/service/lib/update_objects_spaces.test.ts index ba15fbabfba6b..11dbe6149878c 100644 --- a/src/core/server/saved_objects/service/lib/update_objects_spaces.test.ts +++ b/src/core/server/saved_objects/service/lib/update_objects_spaces.test.ts @@ -23,7 +23,6 @@ import type { UpdateObjectsSpacesParams, } from './update_objects_spaces'; import { updateObjectsSpaces } from './update_objects_spaces'; -import { SavedObjectsErrorHelpers } from './errors'; type SetupParams = Partial< Pick @@ -106,32 +105,6 @@ describe('#updateObjectsSpaces', () => { }) ); } - /** Mocks the saved objects client so as to test unsupported server responding with 404 */ - function mockMgetResultsNotFound(...results: Array<{ found: boolean }>) { - client.mget.mockReturnValueOnce( - elasticsearchClientMock.createSuccessTransportRequestPromise( - { - docs: results.map((x) => - x.found - ? { - _id: 'doesnt-matter', - _index: 'doesnt-matter', - _source: { namespaces: [EXISTING_SPACE] }, - ...VERSION_PROPS, - found: true, - } - : { - _id: 'doesnt-matter', - _index: 'doesnt-matter', - found: false, - } - ), - }, - { statusCode: 404 }, - {} - ) - ); - } /** Asserts that mget is called for the given objects */ function expectMgetArgs(...objects: SavedObjectsUpdateObjectsSpacesObject[]) { @@ -267,17 +240,6 @@ describe('#updateObjectsSpaces', () => { { ...obj7, spaces: [EXISTING_SPACE, 'foo-space'] }, ]); }); - - it('throws when mget not found response is missing the Elasticsearch header', async () => { - const objects = [{ type: SHAREABLE_OBJ_TYPE, id: 'id-1' }]; - const spacesToAdd = ['foo-space']; - const params = setup({ objects, spacesToAdd }); - mockMgetResultsNotFound({ found: true }); - - await expect(() => updateObjectsSpaces(params)).rejects.toThrowError( - SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError() - ); - }); }); // Note: these test cases do not include requested objects that will result in errors (those are covered above) diff --git a/src/core/server/saved_objects/service/lib/update_objects_spaces.ts b/src/core/server/saved_objects/service/lib/update_objects_spaces.ts index b54f72d4c23f0..d88bf700a900e 100644 --- a/src/core/server/saved_objects/service/lib/update_objects_spaces.ts +++ b/src/core/server/saved_objects/service/lib/update_objects_spaces.ts @@ -28,7 +28,6 @@ import { } from './internal_utils'; import { DEFAULT_REFRESH_SETTING } from './repository'; import type { RepositoryEsClient } from './repository_es_client'; -import { isNotFoundFromUnsupportedServer } from '../../../elasticsearch'; /** * An object that should have its spaces updated. @@ -188,16 +187,6 @@ export async function updateObjectsSpaces({ ) : undefined; - // fail fast if we can't verify a 404 response is from Elasticsearch - if ( - bulkGetResponse && - isNotFoundFromUnsupportedServer({ - statusCode: bulkGetResponse.statusCode, - headers: bulkGetResponse.headers, - }) - ) { - throw SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError(); - } const time = new Date().toISOString(); let bulkOperationRequestIndexCounter = 0; const bulkOperationParams: estypes.BulkOperationContainer[] = []; From 93f2f7c6a6dcd5ac14879660ba4d323926be8f58 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 22 Oct 2021 08:10:38 +0200 Subject: [PATCH 144/172] disable APM until compatible with client v8 --- packages/kbn-apm-config-loader/src/init_apm.test.ts | 3 ++- packages/kbn-apm-config-loader/src/init_apm.ts | 3 +++ x-pack/test/performance/tests/reporting_dashboard.ts | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/kbn-apm-config-loader/src/init_apm.test.ts b/packages/kbn-apm-config-loader/src/init_apm.test.ts index 95f0a15a448c8..5227528c5e8d6 100644 --- a/packages/kbn-apm-config-loader/src/init_apm.test.ts +++ b/packages/kbn-apm-config-loader/src/init_apm.test.ts @@ -11,7 +11,8 @@ import { mockLoadConfiguration } from './init_apm.test.mocks'; import { initApm } from './init_apm'; import apm from 'elastic-apm-node'; -describe('initApm', () => { +// TODO: https://github.com/elastic/apm-agent-nodejs/issues/2355 is fixed +describe.skip('initApm', () => { let apmAddFilterSpy: jest.SpyInstance; let apmStartSpy: jest.SpyInstance; let getConfig: jest.Mock; diff --git a/packages/kbn-apm-config-loader/src/init_apm.ts b/packages/kbn-apm-config-loader/src/init_apm.ts index 21c40c8b39419..0d318d16223c4 100644 --- a/packages/kbn-apm-config-loader/src/init_apm.ts +++ b/packages/kbn-apm-config-loader/src/init_apm.ts @@ -14,6 +14,9 @@ export const initApm = ( isDistributable: boolean, serviceName: string ) => { + // TODO: re-enabled when https://github.com/elastic/apm-agent-nodejs/issues/2355 is fixed + return; + const apmConfigLoader = loadConfiguration(argv, rootDir, isDistributable); const apmConfig = apmConfigLoader.getConfig(serviceName); diff --git a/x-pack/test/performance/tests/reporting_dashboard.ts b/x-pack/test/performance/tests/reporting_dashboard.ts index f363f8449df96..2ca77ff736a87 100644 --- a/x-pack/test/performance/tests/reporting_dashboard.ts +++ b/x-pack/test/performance/tests/reporting_dashboard.ts @@ -16,7 +16,8 @@ export default function ({ getService, getPageObject }: FtrProviderContext) { const dashboard = getPageObject('dashboard'); const reporting = getPageObject('reporting'); - describe('reporting dashbaord', () => { + // TODO: unskip when https://github.com/elastic/apm-agent-nodejs/issues/2355 is fixed + describe.skip('reporting dashbaord', () => { before(async () => { await kibanaServer.importExport.load( 'x-pack/test/performance/kbn_archives/reporting_dashboard' From 0a615cbffb7bb85f937bf37128fcc357c6327523 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 22 Oct 2021 08:44:37 +0200 Subject: [PATCH 145/172] skip async_search FTR test --- .../tests/apps/discover/async_search.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts index cd13f71cf1bb7..68e614d1d26a8 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts @@ -102,7 +102,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await searchSessions.missingOrFail(); }); - it('relative timerange works', async () => { + // SKIPPED - see https://github.com/elastic/kibana/pull/113950 + // `expect(await toasts.getToastCount()).to.be(0)` fails because of a `Your search session is still running` toast + // rest of the test does pass + it.skip('relative timerange works', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.header.waitUntilLoadingHasFinished(); await searchSessions.save(); From b8caf6117a85a0808b6f914cace4f3cb9cd02f54 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 09:21:52 +0200 Subject: [PATCH 146/172] use kbnClient in integration tests --- packages/kbn-test/src/es/test_es_cluster.ts | 10 ++++++++++ .../actions/integration_tests/actions.test.ts | 2 +- .../7_13_0_failed_action_tasks.test.ts | 2 +- .../integration_tests/7_13_0_unknown_types.test.ts | 4 ++-- .../integration_tests/batch_size_bytes.test.ts | 2 +- .../migrationsv2/integration_tests/cleanup.test.ts | 2 +- .../integration_tests/multiple_es_nodes.test.ts | 2 +- .../integration_tests/multiple_kibana_nodes.test.ts | 8 ++++---- .../lib/collect_multi_namespace_references.test.ts | 1 - .../ui_settings/integration_tests/lib/servers.ts | 2 +- 10 files changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/kbn-test/src/es/test_es_cluster.ts b/packages/kbn-test/src/es/test_es_cluster.ts index 388d578c9af57..575fc965962eb 100644 --- a/packages/kbn-test/src/es/test_es_cluster.ts +++ b/packages/kbn-test/src/es/test_es_cluster.ts @@ -12,9 +12,11 @@ import del from 'del'; // @ts-expect-error in js import { Cluster } from '@kbn/es'; import { Client, HttpConnection } from '@elastic/elasticsearch'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { ToolingLog } from '@kbn/dev-utils'; import { CI_PARALLEL_PROCESS_PREFIX } from '../ci_parallel_process_prefix'; import { esTestConfig } from './es_test_config'; +import { convertToKibanaClient } from './client_to_kibana_client'; import { KIBANA_ROOT } from '../'; @@ -51,6 +53,7 @@ export interface ICluster { stop: () => Promise; cleanup: () => Promise; getClient: () => Client; + getKibanaEsClient: () => KibanaClient; getHostUrls: () => string[]; } @@ -286,6 +289,13 @@ export function createTestEsCluster< }); } + /** + * Returns an ES Client to the configured cluster + */ + getKibanaEsClient(): KibanaClient { + return convertToKibanaClient(this.getClient()); + } + getUrl() { if (this.nodes.length > 1) { throw new Error( diff --git a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts index 5ee8d1749135e..3ca3a8505338b 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/integration_tests/actions.test.ts @@ -61,7 +61,7 @@ describe.skip('migration actions', () => { beforeAll(async () => { esServer = await startES(); - client = esServer.es.getClient(); + client = esServer.es.getKibanaEsClient(); // Create test fixture data: await createIndex({ diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_failed_action_tasks.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_failed_action_tasks.test.ts index a4ce95a9e0584..479b1e78e1b72 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_failed_action_tasks.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_failed_action_tasks.test.ts @@ -55,7 +55,7 @@ describe('migration from 7.13 to 7.14+ with many failed action_tasks', () => { kibanaIndexName = '.kibana', taskManagerIndexName = '.kibana_task_manager' ): Promise<{ tasksCount: number; actionTaskParamsCount: number }> => { - const esClient: ElasticsearchClient = esServer.es.getClient(); + const esClient: ElasticsearchClient = esServer.es.getKibanaEsClient(); const actionTaskParamsResponse = await esClient.count({ index: kibanaIndexName, diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts index 9cc6b20b1c337..aea84cea22862 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/7_13_0_unknown_types.test.ts @@ -114,7 +114,7 @@ describe('migration v2', () => { ); }); - const client: ElasticsearchClient = esServer.es.getClient(); + const client: ElasticsearchClient = esServer.es.getKibanaEsClient(); const { body: response } = await client.indices.getSettings({ index: targetIndex, }); @@ -178,7 +178,7 @@ describe('migration v2', () => { }); await root.start(); - const client: ElasticsearchClient = esServer.es.getClient(); + const client: ElasticsearchClient = esServer.es.getKibanaEsClient(); const spacesDocsMigrated = await fetchDocs(client, targetIndex, 'space'); expect(spacesDocsMigrated.map((s) => s.id)).toEqual( expect.arrayContaining([ diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts index de25c7b1c6412..e444a3b1a8bdb 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts @@ -95,7 +95,7 @@ describe('migration v2', () => { // wait a bit for the count to settle. await new Promise((resolve) => setTimeout(resolve, 5000)); - const esClient: ElasticsearchClient = esServer.es.getClient(); + const esClient: ElasticsearchClient = esServer.es.getKibanaEsClient(); // assert that the docs from the original index have been migrated rather than comparing a doc count after startup const originalDocs = await fetchDocuments(esClient, '.kibana_7.14.0_001'); diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts index c84f72b184261..4f3026c619d3c 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/cleanup.test.ts @@ -133,7 +133,7 @@ describe('migration v2', () => { const pitId = logRecordWithPit.right.pitId; expect(pitId).toBeTruthy(); - const client = esServer.es.getClient(); + const client = esServer.es.getKibanaEsClient(); await expect( client.search({ body: { diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_es_nodes.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_es_nodes.test.ts index 6956e53ebc7fa..fabc9222b6858 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_es_nodes.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_es_nodes.test.ts @@ -179,7 +179,7 @@ describe('migration v2', () => { }); await root.start(); - const esClient = esServer.es.getClient(); + const esClient = esServer.es.getKibanaEsClient(); const migratedFooDocs = await fetchDocs(esClient, migratedIndex, 'foo'); expect(migratedFooDocs.length).toBe(2500); diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_kibana_nodes.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_kibana_nodes.test.ts index ef92c823182d8..5d0d662a5360b 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_kibana_nodes.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/multiple_kibana_nodes.test.ts @@ -182,7 +182,7 @@ describe('migration v2', () => { await startWithDelay([rootA, rootB, rootC], 0); - const esClient = esServer.es.getClient(); + const esClient = esServer.es.getKibanaEsClient(); const migratedDocs = await fetchDocs(esClient, migratedIndex); expect(migratedDocs.length).toBe(5000); @@ -201,7 +201,7 @@ describe('migration v2', () => { await startWithDelay([rootA, rootB, rootC], 1); - const esClient = esServer.es.getClient(); + const esClient = esServer.es.getKibanaEsClient(); const migratedDocs = await fetchDocs(esClient, migratedIndex); expect(migratedDocs.length).toBe(5000); @@ -220,7 +220,7 @@ describe('migration v2', () => { await startWithDelay([rootA, rootB, rootC], 5); - const esClient = esServer.es.getClient(); + const esClient = esServer.es.getKibanaEsClient(); const migratedDocs = await fetchDocs(esClient, migratedIndex); expect(migratedDocs.length).toBe(5000); @@ -239,7 +239,7 @@ describe('migration v2', () => { await startWithDelay([rootA, rootB, rootC], 20); - const esClient = esServer.es.getClient(); + const esClient = esServer.es.getKibanaEsClient(); const migratedDocs = await fetchDocs(esClient, migratedIndex); expect(migratedDocs.length).toBe(5000); diff --git a/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts b/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts index 201077cf4d733..45794e25d00a6 100644 --- a/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts +++ b/src/core/server/saved_objects/service/lib/collect_multi_namespace_references.test.ts @@ -25,7 +25,6 @@ import { savedObjectsPointInTimeFinderMock } from './point_in_time_finder.mock'; import { savedObjectsRepositoryMock } from './repository.mock'; import { PointInTimeFinder } from './point_in_time_finder'; import { ISavedObjectsRepository } from './repository'; -import { SavedObjectsErrorHelpers } from './errors'; const SPACES = ['default', 'another-space']; const VERSION_PROPS = { _seq_no: 1, _primary_term: 1 }; diff --git a/src/core/server/ui_settings/integration_tests/lib/servers.ts b/src/core/server/ui_settings/integration_tests/lib/servers.ts index 216513e4244e8..d94ab98060a27 100644 --- a/src/core/server/ui_settings/integration_tests/lib/servers.ts +++ b/src/core/server/ui_settings/integration_tests/lib/servers.ts @@ -55,7 +55,7 @@ export function getServices() { return services; } - const esClient = esServer.es.getClient(); + const esClient = esServer.es.getKibanaEsClient(); const savedObjectsClient = kbn.coreStart.savedObjects.getScopedClient( httpServerMock.createKibanaRequest() From b0e635bc18a0b7ffc9f4e180acf86856c0b83427 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 11:08:34 +0200 Subject: [PATCH 147/172] bump version to 29 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 8aa381e296aad..d415df7b0fab8 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.28", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.29", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index e7819d74c1e8f..d87d8c7daf31e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.28": - version "8.0.0-canary.28" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.28.tgz#6888ad7d7b78bda8f37f37e50a43d44df6ca22d7" - integrity sha512-6t9Dsoj2OxOyzdsZUzcg6cnc4IJUBgX23D5pQymOtldABPg1J86PD65KFIrTiHFvJm/BK2TmTJ8vp/sPpwhbBw== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.29": + version "8.0.0-canary.29" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.29.tgz#4dd249418c899935f58411683820bff0f53fcd58" + integrity sha512-51stxLdblxhEiVSFjhQE5iQ2LAKbHkJqS42byW7niDXdsjbEfNHG3XLaaX6tq8fUGT+z5AqO8h7Kr3HcRo9Dfw== dependencies: - "@elastic/transport" "^0.0.10" + "@elastic/transport" "^0.0.11" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.10": - version "0.0.10" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.10.tgz#a2612fd0f26fa1d9721672471af3520ad1d773f6" - integrity sha512-B/8NqBqdB3eRCt1DVXXUfnuiMzB/dFgvu93c1YsC8DZqopgIENE1h9gIVKLH6QiTDm7YVUTDiIUulwbnOjtaaQ== +"@elastic/transport@^0.0.11": + version "0.0.11" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.11.tgz#192f36fe11a83a09d107a589add9046d81fc9bb9" + integrity sha512-5Rla02jyeMQ556XCfeds/gwNwZ84U8afLAqP7pMliQnTRu0EBUVCGH6j1cMdXk2kkpM51usNIxYFmB6IoBWMEw== dependencies: debug "^4.3.2" hpagent "^0.1.2" From 8baed5d75315b5f6b36d4e650c01ce9f8712cbc5 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 13:30:43 +0200 Subject: [PATCH 148/172] bump to 30 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index d415df7b0fab8..a4bd1f4ae609f 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.29", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.30", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index d87d8c7daf31e..449f5cc51fb56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.29": - version "8.0.0-canary.29" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.29.tgz#4dd249418c899935f58411683820bff0f53fcd58" - integrity sha512-51stxLdblxhEiVSFjhQE5iQ2LAKbHkJqS42byW7niDXdsjbEfNHG3XLaaX6tq8fUGT+z5AqO8h7Kr3HcRo9Dfw== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.30": + version "8.0.0-canary.30" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.30.tgz#9c7c915516e05e56d4275e057e0960eab186318e" + integrity sha512-cFXDiycUNjmGms5f5cEBTxPuu4GtzV9W/hkJ6wmUn8Yf7P7TfbCK9VuQKjst+G05Nu0Wm4s5602Z4DaUjl+XjA== dependencies: - "@elastic/transport" "^0.0.11" + "@elastic/transport" "^0.0.12" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.11": - version "0.0.11" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.11.tgz#192f36fe11a83a09d107a589add9046d81fc9bb9" - integrity sha512-5Rla02jyeMQ556XCfeds/gwNwZ84U8afLAqP7pMliQnTRu0EBUVCGH6j1cMdXk2kkpM51usNIxYFmB6IoBWMEw== +"@elastic/transport@^0.0.12": + version "0.0.12" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.12.tgz#406580c22ee1f414af08e41fd05bffd04f9afbf6" + integrity sha512-YX1X9CLcrW1yUgXsuwtdrgalQcTxzATbjlsYLqj+mW4FgCrtyK2F1+crUcPza/wp5qOSv1lREz0PgMapHzKOCQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From e5c70daf3b27790333eda3b1dc4fbe0831f074ee Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 22 Oct 2021 14:15:05 +0200 Subject: [PATCH 149/172] have configureClient return a KibanaClient instead of Client, remove resolved violations. --- .../src/elasticsearch_client/index.ts | 2 +- src/cli_setup/utils.ts | 1 - src/core/server/elasticsearch/client/cluster_client.ts | 8 +++----- src/core/server/elasticsearch/client/configure_client.ts | 5 +++-- src/core/server/elasticsearch/client/types.ts | 2 +- src/core/server/elasticsearch/elasticsearch_service.ts | 5 ----- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts b/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts index 9cb834c97bfbe..95fa040142c15 100644 --- a/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts +++ b/packages/kbn-securitysolution-es-utils/src/elasticsearch_client/index.ts @@ -18,5 +18,5 @@ import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; */ export type ElasticsearchClient = Omit< KibanaClient, - 'connectionPool' | 'transport' | 'serializer' | 'extend' | 'child' | 'close' + 'connectionPool' | 'transport' | 'serializer' | 'extend' | 'child' | 'close' | 'diagnostic' >; diff --git a/src/cli_setup/utils.ts b/src/cli_setup/utils.ts index 123bf50adcca0..65a46b8f5b278 100644 --- a/src/cli_setup/utils.ts +++ b/src/cli_setup/utils.ts @@ -34,7 +34,6 @@ export const kibanaConfigWriter = new KibanaConfigWriter(getConfigPath(), logger export const elasticsearch = new ElasticsearchService(logger).setup({ connectionCheckInterval: duration(Infinity), elasticsearch: { - // @ts-expect-error TODO make sure Client is assignable to KibanaClient, see src/core/server/elasticsearch/client/cluster_client.ts createClient: (type, config) => { const defaults = configSchema.validate({}); return new ClusterClient( diff --git a/src/core/server/elasticsearch/client/cluster_client.ts b/src/core/server/elasticsearch/client/cluster_client.ts index 56eb06c92558e..1f3118c77aa0f 100644 --- a/src/core/server/elasticsearch/client/cluster_client.ts +++ b/src/core/server/elasticsearch/client/cluster_client.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { Client } from '@elastic/elasticsearch'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { Logger } from '../../logging'; import { GetAuthHeaders, Headers, isKibanaRequest, isRealRequest } from '../../http'; import { ensureRawRequest, filterHeaders } from '../../http/router'; @@ -52,9 +52,8 @@ export interface ICustomClusterClient extends IClusterClient { /** @internal **/ export class ClusterClient implements ICustomClusterClient { - // @ts-expect-error TODO make sure Client is assignable to KibanaClient - public readonly asInternalUser: Client; - private readonly rootScopedClient: Client; + public readonly asInternalUser: KibanaClient; + private readonly rootScopedClient: KibanaClient; private readonly allowListHeaders: string[]; private isClosed = false; @@ -82,7 +81,6 @@ export class ClusterClient implements ICustomClusterClient { const scopedClient = this.rootScopedClient.child({ headers: scopedHeaders, }); - // @ts-expect-error TODO make sure Client is assignable to KibanaClient return new ScopedClusterClient(this.asInternalUser, scopedClient); } diff --git a/src/core/server/elasticsearch/client/configure_client.ts b/src/core/server/elasticsearch/client/configure_client.ts index a946a29fde498..fc8a06660cc5e 100644 --- a/src/core/server/elasticsearch/client/configure_client.ts +++ b/src/core/server/elasticsearch/client/configure_client.ts @@ -9,6 +9,7 @@ import { Buffer } from 'buffer'; import { stringify } from 'querystring'; import { Client, errors, Transport, HttpConnection } from '@elastic/elasticsearch'; +import type { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import type { TransportRequestParams, TransportRequestOptions, @@ -36,7 +37,7 @@ export const configureClient = ( scoped?: boolean; getExecutionContext?: () => string | undefined; } -): Client => { +): KibanaClient => { const clientOptions = parseClientOptions(config, scoped); class KibanaTransport extends Transport { request(params: TransportRequestParams, options?: TransportRequestOptions) { @@ -62,7 +63,7 @@ export const configureClient = ( }); addLogging(client, logger.get('query', type)); - return client; + return client as KibanaClient; }; const convertQueryString = (qs: string | Record | undefined): string => { diff --git a/src/core/server/elasticsearch/client/types.ts b/src/core/server/elasticsearch/client/types.ts index e70844df96a88..e168a4a4a9c21 100644 --- a/src/core/server/elasticsearch/client/types.ts +++ b/src/core/server/elasticsearch/client/types.ts @@ -20,7 +20,7 @@ import type { */ export type ElasticsearchClient = Omit< KibanaClient, - 'connectionPool' | 'transport' | 'serializer' | 'extend' | 'child' | 'close' + 'connectionPool' | 'transport' | 'serializer' | 'extend' | 'child' | 'close' | 'diagnostic' > & { transport: { request( diff --git a/src/core/server/elasticsearch/elasticsearch_service.ts b/src/core/server/elasticsearch/elasticsearch_service.ts index 2f9152c1c33b5..014fa38646275 100644 --- a/src/core/server/elasticsearch/elasticsearch_service.ts +++ b/src/core/server/elasticsearch/elasticsearch_service.ts @@ -67,7 +67,6 @@ export class ElasticsearchService config.password !== undefined || config.serviceAccountToken !== undefined, }, - // @ts-expect-error TODO make sure Client is assignable to KibanaClient createClient: (type, clientConfig) => this.createClusterClient(type, config, clientConfig), }; } @@ -82,7 +81,6 @@ export class ElasticsearchService this.client = this.createClusterClient('data', config); const esNodesCompatibility$ = pollEsNodesVersion({ - // @ts-expect-error TODO make sure Client is assignable to KibanaClient internalClient: this.client.asInternalUser, log: this.log, ignoreVersionMismatch: config.ignoreVersionMismatch, @@ -121,7 +119,6 @@ export class ElasticsearchService // Ensure inline scripting is enabled on the ES cluster const scriptingEnabled = await isInlineScriptingEnabled({ - // @ts-expect-error TODO make sure Client is assignable to KibanaClient client: this.client.asInternalUser, }); if (!scriptingEnabled) { @@ -134,9 +131,7 @@ export class ElasticsearchService } return { - // @ts-expect-error TODO make sure Client is assignable to KibanaClient client: this.client!, - // @ts-expect-error TODO make sure Client is assignable to KibanaClient createClient: (type, clientConfig) => this.createClusterClient(type, config, clientConfig), legacy: { config$: this.config$, From 9c7b2afd5ed00cadfbe4722d8a353e001a5465cb Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 22 Oct 2021 15:19:17 +0200 Subject: [PATCH 150/172] bump to 31 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index a4bd1f4ae609f..03571a1cdd819 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.30", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.31", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 449f5cc51fb56..64d62d22f4be9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.30": - version "8.0.0-canary.30" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.30.tgz#9c7c915516e05e56d4275e057e0960eab186318e" - integrity sha512-cFXDiycUNjmGms5f5cEBTxPuu4GtzV9W/hkJ6wmUn8Yf7P7TfbCK9VuQKjst+G05Nu0Wm4s5602Z4DaUjl+XjA== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.31": + version "8.0.0-canary.31" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.31.tgz#79aa97ee9c056a43060e6659d0cbd4f82c8735b6" + integrity sha512-DKYYAXwvNKjZzEZt74hywRH9wCjsXqUS8kRXr7AXHuccg3jAolViN+3/Asohn7qFcUqUYy+OvDb9TpDJA4CykQ== dependencies: - "@elastic/transport" "^0.0.12" + "@elastic/transport" "^0.0.13" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.12": - version "0.0.12" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.12.tgz#406580c22ee1f414af08e41fd05bffd04f9afbf6" - integrity sha512-YX1X9CLcrW1yUgXsuwtdrgalQcTxzATbjlsYLqj+mW4FgCrtyK2F1+crUcPza/wp5qOSv1lREz0PgMapHzKOCQ== +"@elastic/transport@^0.0.13": + version "0.0.13" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.13.tgz#7debe13146084e6421b222c8863a264393f87709" + integrity sha512-hiCeEVOlCOsUBiYmWho0Nebr5E4K6pA/zGj72tMX5oJ5mWEZ4wuvw7liiUazWXMrA2UmUAy82/Qnb5mdau7BwQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From 5ac713e640bf60ae4b6914e00e3149ffe0b8ae8c Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 15:21:02 +0200 Subject: [PATCH 151/172] bump to 31 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index a4bd1f4ae609f..03571a1cdd819 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.30", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.31", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 449f5cc51fb56..64d62d22f4be9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.30": - version "8.0.0-canary.30" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.30.tgz#9c7c915516e05e56d4275e057e0960eab186318e" - integrity sha512-cFXDiycUNjmGms5f5cEBTxPuu4GtzV9W/hkJ6wmUn8Yf7P7TfbCK9VuQKjst+G05Nu0Wm4s5602Z4DaUjl+XjA== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.31": + version "8.0.0-canary.31" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.31.tgz#79aa97ee9c056a43060e6659d0cbd4f82c8735b6" + integrity sha512-DKYYAXwvNKjZzEZt74hywRH9wCjsXqUS8kRXr7AXHuccg3jAolViN+3/Asohn7qFcUqUYy+OvDb9TpDJA4CykQ== dependencies: - "@elastic/transport" "^0.0.12" + "@elastic/transport" "^0.0.13" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.12": - version "0.0.12" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.12.tgz#406580c22ee1f414af08e41fd05bffd04f9afbf6" - integrity sha512-YX1X9CLcrW1yUgXsuwtdrgalQcTxzATbjlsYLqj+mW4FgCrtyK2F1+crUcPza/wp5qOSv1lREz0PgMapHzKOCQ== +"@elastic/transport@^0.0.13": + version "0.0.13" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.13.tgz#7debe13146084e6421b222c8863a264393f87709" + integrity sha512-hiCeEVOlCOsUBiYmWho0Nebr5E4K6pA/zGj72tMX5oJ5mWEZ4wuvw7liiUazWXMrA2UmUAy82/Qnb5mdau7BwQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From ef8345d3a523d20c375c77687a86b86c8b23e5b3 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 15:21:49 +0200 Subject: [PATCH 152/172] Revert "bump to 31" This reverts commit 5ac713e640bf60ae4b6914e00e3149ffe0b8ae8c. --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 03571a1cdd819..a4bd1f4ae609f 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.31", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.30", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 64d62d22f4be9..449f5cc51fb56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.31": - version "8.0.0-canary.31" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.31.tgz#79aa97ee9c056a43060e6659d0cbd4f82c8735b6" - integrity sha512-DKYYAXwvNKjZzEZt74hywRH9wCjsXqUS8kRXr7AXHuccg3jAolViN+3/Asohn7qFcUqUYy+OvDb9TpDJA4CykQ== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.30": + version "8.0.0-canary.30" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.30.tgz#9c7c915516e05e56d4275e057e0960eab186318e" + integrity sha512-cFXDiycUNjmGms5f5cEBTxPuu4GtzV9W/hkJ6wmUn8Yf7P7TfbCK9VuQKjst+G05Nu0Wm4s5602Z4DaUjl+XjA== dependencies: - "@elastic/transport" "^0.0.13" + "@elastic/transport" "^0.0.12" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.13": - version "0.0.13" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.13.tgz#7debe13146084e6421b222c8863a264393f87709" - integrity sha512-hiCeEVOlCOsUBiYmWho0Nebr5E4K6pA/zGj72tMX5oJ5mWEZ4wuvw7liiUazWXMrA2UmUAy82/Qnb5mdau7BwQ== +"@elastic/transport@^0.0.12": + version "0.0.12" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.12.tgz#406580c22ee1f414af08e41fd05bffd04f9afbf6" + integrity sha512-YX1X9CLcrW1yUgXsuwtdrgalQcTxzATbjlsYLqj+mW4FgCrtyK2F1+crUcPza/wp5qOSv1lREz0PgMapHzKOCQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From d34c1bafde5d980efe1292ae254cb9ac21d4a721 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 15:22:37 +0200 Subject: [PATCH 153/172] trigger stop to unusubscribe --- src/plugins/kibana_usage_collection/server/plugin.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/kibana_usage_collection/server/plugin.ts b/src/plugins/kibana_usage_collection/server/plugin.ts index 07a70dfd56fb4..29e0f5b3547f6 100644 --- a/src/plugins/kibana_usage_collection/server/plugin.ts +++ b/src/plugins/kibana_usage_collection/server/plugin.ts @@ -111,6 +111,8 @@ export class KibanaUsageCollectionPlugin implements Plugin { public stop() { this.metric$.complete(); + + this.pluginStop$.next(); this.pluginStop$.complete(); } From e2bec101422f579af0be8f5ffd4405397b712f6d Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 22 Oct 2021 16:10:01 +0200 Subject: [PATCH 154/172] update generated docs --- ...kibana-plugin-core-public.doclinksstart.md | 2 +- ...-plugin-core-server.elasticsearchclient.md | 4 +-- ...-server.elasticsearcherrordetails.error.md | 14 +++++++++ ...n-core-server.elasticsearcherrordetails.md | 19 ++++++++++++ .../core/server/kibana-plugin-core-server.md | 1 + ...creategenericnotfoundesunavailableerror.md | 23 -------------- ...in-core-server.savedobjectserrorhelpers.md | 1 - src/core/public/public.api.md | 11 ++++--- src/core/server/server.api.md | 30 +++++++++++-------- 9 files changed, 60 insertions(+), 45 deletions(-) create mode 100644 docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.error.md create mode 100644 docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfoundesunavailableerror.md diff --git a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md index fdf469f443f28..dd0f081b269a5 100644 --- a/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md +++ b/docs/development/core/public/kibana-plugin-core-public.doclinksstart.md @@ -17,5 +17,5 @@ export interface DocLinksStart | --- | --- | --- | | [DOC\_LINK\_VERSION](./kibana-plugin-core-public.doclinksstart.doc_link_version.md) | string | | | [ELASTIC\_WEBSITE\_URL](./kibana-plugin-core-public.doclinksstart.elastic_website_url.md) | string | | -| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly settings: string;
readonly elasticStackGetStarted: string;
readonly apm: {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly customLinks: string;
readonly droppedTransactionSpans: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
};
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly discover: Record<string, string>;
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly elasticsearchModule: string;
readonly startup: string;
readonly exportedFields: string;
readonly suricataModule: string;
readonly zeekModule: string;
};
readonly auditbeat: {
readonly base: string;
readonly auditdModule: string;
readonly systemModule: string;
};
readonly metricbeat: {
readonly base: string;
readonly configure: string;
readonly httpEndpoint: string;
readonly install: string;
readonly start: string;
};
readonly enterpriseSearch: {
readonly base: string;
readonly appSearchBase: string;
readonly workplaceSearchBase: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly libbeat: {
readonly getStarted: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly composite: string;
readonly composite_missing_bucket: string;
readonly date_histogram: string;
readonly date_range: string;
readonly date_format_pattern: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessLangSpec: string;
readonly painlessSyntax: string;
readonly painlessWalkthrough: string;
readonly luceneExpressions: string;
};
readonly search: {
readonly sessions: string;
readonly sessionLimits: string;
};
readonly indexPatterns: {
readonly introduction: string;
readonly fieldFormattersNumber: string;
readonly fieldFormattersString: string;
readonly runtimeFields: string;
};
readonly addData: string;
readonly kibana: string;
readonly upgradeAssistant: string;
readonly rollupJobs: string;
readonly elasticsearch: Record<string, string>;
readonly siem: {
readonly privileges: string;
readonly guide: string;
readonly gettingStarted: string;
readonly ml: string;
readonly ruleChangeLog: string;
readonly detectionsReq: string;
readonly networkMap: string;
readonly troubleshootGaps: string;
};
readonly securitySolution: {
readonly trustedApps: string;
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly autocompleteChanges: string;
};
readonly date: {
readonly dateMath: string;
readonly dateMathIndexNames: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
byteSizeUnits: string;
createAutoFollowPattern: string;
createFollower: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;
cronExpressions: string;
executeWatchActionModes: string;
indexExists: string;
openIndex: string;
putComponentTemplate: string;
painlessExecute: string;
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
timeUnits: string;
updateTransform: string;
}>;
readonly observability: Readonly<{
guide: string;
infrastructureThreshold: string;
logsThreshold: string;
metricsThreshold: string;
monitorStatus: string;
monitorUptime: string;
tlsCertificate: string;
uptimeDurationAnomaly: string;
}>;
readonly alerting: Record<string, string>;
readonly maps: Record<string, string>;
readonly monitoring: Record<string, string>;
readonly security: Readonly<{
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
elasticsearchEnableSecurity: string;
indicesPrivileges: string;
kibanaTLS: string;
kibanaPrivileges: string;
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
}>;
readonly spaces: Readonly<{
kibanaLegacyUrlAliases: string;
kibanaDisableLegacyUrlAliasesApi: string;
}>;
readonly watcher: Record<string, string>;
readonly ccs: Record<string, string>;
readonly plugins: Record<string, string>;
readonly snapshotRestore: Record<string, string>;
readonly ingest: Record<string, string>;
readonly fleet: Readonly<{
guide: string;
fleetServer: string;
fleetServerAddFleetServer: string;
settings: string;
settingsFleetServerHostSettings: string;
troubleshooting: string;
elasticAgent: string;
datastreams: string;
datastreamsNamingScheme: string;
installElasticAgent: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
apiKeysLearnMore: string;
}>;
readonly ecs: {
readonly guide: string;
};
readonly clients: {
readonly guide: string;
readonly goOverview: string;
readonly javaIndex: string;
readonly jsIntro: string;
readonly netGuide: string;
readonly perlGuide: string;
readonly phpGuide: string;
readonly pythonGuide: string;
readonly rubyOverview: string;
readonly rustGuide: string;
};
} | | +| [links](./kibana-plugin-core-public.doclinksstart.links.md) | {
readonly settings: string;
readonly elasticStackGetStarted: string;
readonly apm: {
readonly kibanaSettings: string;
readonly supportedServiceMaps: string;
readonly customLinks: string;
readonly droppedTransactionSpans: string;
readonly upgrading: string;
readonly metaData: string;
};
readonly canvas: {
readonly guide: string;
};
readonly dashboard: {
readonly guide: string;
readonly drilldowns: string;
readonly drilldownsTriggerPicker: string;
readonly urlDrilldownTemplateSyntax: string;
readonly urlDrilldownVariables: string;
};
readonly discover: Record<string, string>;
readonly filebeat: {
readonly base: string;
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly elasticsearchModule: string;
readonly startup: string;
readonly exportedFields: string;
readonly suricataModule: string;
readonly zeekModule: string;
};
readonly auditbeat: {
readonly base: string;
readonly auditdModule: string;
readonly systemModule: string;
};
readonly metricbeat: {
readonly base: string;
readonly configure: string;
readonly httpEndpoint: string;
readonly install: string;
readonly start: string;
};
readonly enterpriseSearch: {
readonly base: string;
readonly appSearchBase: string;
readonly workplaceSearchBase: string;
};
readonly heartbeat: {
readonly base: string;
};
readonly libbeat: {
readonly getStarted: string;
};
readonly logstash: {
readonly base: string;
};
readonly functionbeat: {
readonly base: string;
};
readonly winlogbeat: {
readonly base: string;
};
readonly aggs: {
readonly composite: string;
readonly composite_missing_bucket: string;
readonly date_histogram: string;
readonly date_range: string;
readonly date_format_pattern: string;
readonly filter: string;
readonly filters: string;
readonly geohash_grid: string;
readonly histogram: string;
readonly ip_range: string;
readonly range: string;
readonly significant_terms: string;
readonly terms: string;
readonly avg: string;
readonly avg_bucket: string;
readonly max_bucket: string;
readonly min_bucket: string;
readonly sum_bucket: string;
readonly cardinality: string;
readonly count: string;
readonly cumulative_sum: string;
readonly derivative: string;
readonly geo_bounds: string;
readonly geo_centroid: string;
readonly max: string;
readonly median: string;
readonly min: string;
readonly moving_avg: string;
readonly percentile_ranks: string;
readonly serial_diff: string;
readonly std_dev: string;
readonly sum: string;
readonly top_hits: string;
};
readonly runtimeFields: {
readonly overview: string;
readonly mapping: string;
};
readonly scriptedFields: {
readonly scriptFields: string;
readonly scriptAggs: string;
readonly painless: string;
readonly painlessApi: string;
readonly painlessLangSpec: string;
readonly painlessSyntax: string;
readonly painlessWalkthrough: string;
readonly luceneExpressions: string;
};
readonly search: {
readonly sessions: string;
readonly sessionLimits: string;
};
readonly indexPatterns: {
readonly introduction: string;
readonly fieldFormattersNumber: string;
readonly fieldFormattersString: string;
readonly runtimeFields: string;
};
readonly addData: string;
readonly kibana: string;
readonly upgradeAssistant: string;
readonly rollupJobs: string;
readonly elasticsearch: Record<string, string>;
readonly siem: {
readonly privileges: string;
readonly guide: string;
readonly gettingStarted: string;
readonly ml: string;
readonly ruleChangeLog: string;
readonly detectionsReq: string;
readonly networkMap: string;
readonly troubleshootGaps: string;
};
readonly securitySolution: {
readonly trustedApps: string;
};
readonly query: {
readonly eql: string;
readonly kueryQuerySyntax: string;
readonly luceneQuerySyntax: string;
readonly percolate: string;
readonly queryDsl: string;
readonly autocompleteChanges: string;
};
readonly date: {
readonly dateMath: string;
readonly dateMathIndexNames: string;
};
readonly management: Record<string, string>;
readonly ml: Record<string, string>;
readonly transforms: Record<string, string>;
readonly visualize: Record<string, string>;
readonly apis: Readonly<{
bulkIndexAlias: string;
byteSizeUnits: string;
createAutoFollowPattern: string;
createFollower: string;
createIndex: string;
createSnapshotLifecyclePolicy: string;
createRoleMapping: string;
createRoleMappingTemplates: string;
createRollupJobsRequest: string;
createApiKey: string;
createPipeline: string;
createTransformRequest: string;
cronExpressions: string;
executeWatchActionModes: string;
indexExists: string;
openIndex: string;
putComponentTemplate: string;
painlessExecute: string;
painlessExecuteAPIContexts: string;
putComponentTemplateMetadata: string;
putSnapshotLifecyclePolicy: string;
putIndexTemplateV1: string;
putWatch: string;
simulatePipeline: string;
timeUnits: string;
updateTransform: string;
}>;
readonly observability: Readonly<{
guide: string;
infrastructureThreshold: string;
logsThreshold: string;
metricsThreshold: string;
monitorStatus: string;
monitorUptime: string;
tlsCertificate: string;
uptimeDurationAnomaly: string;
}>;
readonly alerting: Record<string, string>;
readonly maps: Record<string, string>;
readonly monitoring: Record<string, string>;
readonly security: Readonly<{
apiKeyServiceSettings: string;
clusterPrivileges: string;
elasticsearchSettings: string;
elasticsearchEnableSecurity: string;
elasticsearchEnableApiKeys: string;
indicesPrivileges: string;
kibanaTLS: string;
kibanaPrivileges: string;
mappingRoles: string;
mappingRolesFieldRules: string;
runAsPrivilege: string;
}>;
readonly spaces: Readonly<{
kibanaLegacyUrlAliases: string;
kibanaDisableLegacyUrlAliasesApi: string;
}>;
readonly watcher: Record<string, string>;
readonly ccs: Record<string, string>;
readonly plugins: Record<string, string>;
readonly snapshotRestore: Record<string, string>;
readonly ingest: Record<string, string>;
readonly fleet: Readonly<{
guide: string;
fleetServer: string;
fleetServerAddFleetServer: string;
settings: string;
settingsFleetServerHostSettings: string;
troubleshooting: string;
elasticAgent: string;
datastreams: string;
datastreamsNamingScheme: string;
installElasticAgent: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
apiKeysLearnMore: string;
}>;
readonly ecs: {
readonly guide: string;
};
readonly clients: {
readonly guide: string;
readonly goOverview: string;
readonly javaIndex: string;
readonly jsIntro: string;
readonly netGuide: string;
readonly perlGuide: string;
readonly phpGuide: string;
readonly pythonGuide: string;
readonly rubyOverview: string;
readonly rustGuide: string;
};
} | | diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearchclient.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearchclient.md index 279262aa6a5ec..f6190fb3bc055 100644 --- a/docs/development/core/server/kibana-plugin-core-server.elasticsearchclient.md +++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearchclient.md @@ -9,9 +9,9 @@ Client used to query the elasticsearch cluster. Signature: ```typescript -export declare type ElasticsearchClient = Omit & { +export declare type ElasticsearchClient = Omit & { transport: { - request(params: TransportRequestParams, options?: TransportRequestOptions): TransportRequestPromise; + request(params: TransportRequestParams, options?: TransportRequestOptions): Promise>; }; }; ``` diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.error.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.error.md new file mode 100644 index 0000000000000..7191caea54929 --- /dev/null +++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.error.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ElasticsearchErrorDetails](./kibana-plugin-core-server.elasticsearcherrordetails.md) > [error](./kibana-plugin-core-server.elasticsearcherrordetails.error.md) + +## ElasticsearchErrorDetails.error property + +Signature: + +```typescript +error?: { + type: string; + reason?: string; + }; +``` diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.md new file mode 100644 index 0000000000000..7dbf9e89f9b7c --- /dev/null +++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearcherrordetails.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ElasticsearchErrorDetails](./kibana-plugin-core-server.elasticsearcherrordetails.md) + +## ElasticsearchErrorDetails interface + + +Signature: + +```typescript +export interface ElasticsearchErrorDetails +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [error](./kibana-plugin-core-server.elasticsearcherrordetails.error.md) | {
type: string;
reason?: string;
} | | + diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md index 3970cf005abe4..f22a0fb8283d7 100644 --- a/docs/development/core/server/kibana-plugin-core-server.md +++ b/docs/development/core/server/kibana-plugin-core-server.md @@ -71,6 +71,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [DeprecationsServiceSetup](./kibana-plugin-core-server.deprecationsservicesetup.md) | The deprecations service provides a way for the Kibana platform to communicate deprecated features and configs with its users. These deprecations are only communicated if the deployment is using these features. Allowing for a user tailored experience for upgrading the stack version.The Deprecation service is consumed by the upgrade assistant to assist with the upgrade experience.If a deprecated feature can be resolved without manual user intervention. Using correctiveActions.api allows the Upgrade Assistant to use this api to correct the deprecation upon a user trigger. | | [DiscoveredPlugin](./kibana-plugin-core-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. | | [ElasticsearchConfigPreboot](./kibana-plugin-core-server.elasticsearchconfigpreboot.md) | A limited set of Elasticsearch configuration entries exposed to the preboot plugins at setup. | +| [ElasticsearchErrorDetails](./kibana-plugin-core-server.elasticsearcherrordetails.md) | | | [ElasticsearchServicePreboot](./kibana-plugin-core-server.elasticsearchservicepreboot.md) | | | [ElasticsearchServiceSetup](./kibana-plugin-core-server.elasticsearchservicesetup.md) | | | [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) | | diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfoundesunavailableerror.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfoundesunavailableerror.md deleted file mode 100644 index e17877a537d00..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfoundesunavailableerror.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsErrorHelpers](./kibana-plugin-core-server.savedobjectserrorhelpers.md) > [createGenericNotFoundEsUnavailableError](./kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfoundesunavailableerror.md) - -## SavedObjectsErrorHelpers.createGenericNotFoundEsUnavailableError() method - -Signature: - -```typescript -static createGenericNotFoundEsUnavailableError(type?: string | null, id?: string | null): DecoratedError; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| type | string | null | | -| id | string | null | | - -Returns: - -`DecoratedError` - diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.md index 67056c8a3cb50..2dc78f2df3a83 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectserrorhelpers.md @@ -18,7 +18,6 @@ export declare class SavedObjectsErrorHelpers | [createBadRequestError(reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.createbadrequesterror.md) | static | | | [createConflictError(type, id, reason)](./kibana-plugin-core-server.savedobjectserrorhelpers.createconflicterror.md) | static | | | [createGenericNotFoundError(type, id)](./kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfounderror.md) | static | | -| [createGenericNotFoundEsUnavailableError(type, id)](./kibana-plugin-core-server.savedobjectserrorhelpers.creategenericnotfoundesunavailableerror.md) | static | | | [createIndexAliasNotFoundError(alias)](./kibana-plugin-core-server.savedobjectserrorhelpers.createindexaliasnotfounderror.md) | static | | | [createInvalidVersionError(versionInput)](./kibana-plugin-core-server.savedobjectserrorhelpers.createinvalidversionerror.md) | static | | | [createTooManyRequestsError(type, id)](./kibana-plugin-core-server.savedobjectserrorhelpers.createtoomanyrequestserror.md) | static | | diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 353e5aa4607e4..7bbf4406eb6d4 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -5,13 +5,12 @@ ```ts import { Action } from 'history'; -import { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; import Boom from '@hapi/boom'; import { ConfigDeprecationProvider } from '@kbn/config'; import { ConfigPath } from '@kbn/config'; import { DetailedPeerCertificate } from 'tls'; import { EnvironmentMode } from '@kbn/config'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { EuiBreadcrumb } from '@elastic/eui'; import { EuiButtonEmptyProps } from '@elastic/eui'; import { EuiConfirmModalProps } from '@elastic/eui'; @@ -21,7 +20,7 @@ import { History } from 'history'; import { Href } from 'history'; import { IconType } from '@elastic/eui'; import { IncomingHttpHeaders } from 'http'; -import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { Location } from 'history'; import { LocationDescriptorObject } from 'history'; import { Logger } from '@kbn/logging'; @@ -39,9 +38,9 @@ import { RecursiveReadonly } from '@kbn/utility-types'; import { Request } from '@hapi/hapi'; import * as Rx from 'rxjs'; import { SchemaTypeError } from '@kbn/config-schema'; -import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; -import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport'; -import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; +import { TransportRequestOptions } from '@elastic/elasticsearch'; +import { TransportRequestParams } from '@elastic/elasticsearch'; +import { TransportResult } from '@elastic/elasticsearch'; import { Type } from '@kbn/config-schema'; import { TypeOf } from '@kbn/config-schema'; import { UiCounterMetricType } from '@kbn/analytics'; diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 9e50a3008293b..d65dcb9a1d09b 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -5,11 +5,10 @@ ```ts import { AddConfigDeprecation } from '@kbn/config'; -import { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; import Boom from '@hapi/boom'; import { ByteSizeValue } from '@kbn/config-schema'; import { CliArgs } from '@kbn/config'; -import { ClientOptions } from '@elastic/elasticsearch'; +import { ClientOptions } from '@elastic/elasticsearch/lib/client'; import { ConfigDeprecation } from '@kbn/config'; import { ConfigDeprecationContext } from '@kbn/config'; import { ConfigDeprecationFactory } from '@kbn/config'; @@ -25,9 +24,9 @@ import { EcsEventKind } from '@kbn/logging'; import { EcsEventOutcome } from '@kbn/logging'; import { EcsEventType } from '@kbn/logging'; import { EnvironmentMode } from '@kbn/config'; -import { estypes } from '@elastic/elasticsearch'; +import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { IncomingHttpHeaders } from 'http'; -import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; +import { KibanaClient } from '@elastic/elasticsearch/lib/api/kibana'; import { Logger } from '@kbn/logging'; import { LoggerFactory } from '@kbn/logging'; import { LogLevel } from '@kbn/logging'; @@ -49,9 +48,9 @@ import { ResponseToolkit } from '@hapi/hapi'; import { SchemaTypeError } from '@kbn/config-schema'; import { ShallowPromise } from '@kbn/utility-types'; import { Stream } from 'stream'; -import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; -import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport'; -import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; +import { TransportRequestOptions } from '@elastic/elasticsearch'; +import { TransportRequestParams } from '@elastic/elasticsearch'; +import { TransportResult } from '@elastic/elasticsearch'; import { Type } from '@kbn/config-schema'; import { TypeOf } from '@kbn/config-schema'; import { UiCounterMetricType } from '@kbn/analytics'; @@ -870,9 +869,9 @@ export { EcsEventOutcome } export { EcsEventType } // @public -export type ElasticsearchClient = Omit & { +export type ElasticsearchClient = Omit & { transport: { - request(params: TransportRequestParams, options?: TransportRequestOptions): TransportRequestPromise; + request(params: TransportRequestParams, options?: TransportRequestOptions): Promise>; }; }; @@ -918,6 +917,15 @@ export interface ElasticsearchConfigPreboot { readonly hosts: string[]; } +// @public (undocumented) +export interface ElasticsearchErrorDetails { + // (undocumented) + error?: { + type: string; + reason?: string; + }; +} + // @public (undocumented) export interface ElasticsearchServicePreboot { readonly config: Readonly; @@ -2171,8 +2179,6 @@ export class SavedObjectsErrorHelpers { // (undocumented) static createGenericNotFoundError(type?: string | null, id?: string | null): DecoratedError; // (undocumented) - static createGenericNotFoundEsUnavailableError(type?: string | null, id?: string | null): DecoratedError; - // (undocumented) static createIndexAliasNotFoundError(alias: string): DecoratedError; // (undocumented) static createInvalidVersionError(versionInput?: string): DecoratedError; @@ -3050,7 +3056,7 @@ export const validBodyOutput: readonly ["data", "stream"]; // Warnings were encountered during analysis: // -// src/core/server/elasticsearch/client/types.ts:94:7 - (ae-forgotten-export) The symbol "Explanation" needs to be exported by the entry point index.d.ts +// src/core/server/elasticsearch/client/types.ts:93:7 - (ae-forgotten-export) The symbol "Explanation" needs to be exported by the entry point index.d.ts // src/core/server/http/router/response.ts:302:3 - (ae-forgotten-export) The symbol "KibanaResponse" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:377:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:377:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts From 66fb5b9dee1ea112e0b4f2a2745d291144659394 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 22 Oct 2021 16:10:18 +0200 Subject: [PATCH 155/172] remove obsolete test --- .../elasticsearch/integration_tests/client.test.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/core/server/elasticsearch/integration_tests/client.test.ts b/src/core/server/elasticsearch/integration_tests/client.test.ts index 1ff9afdda9635..05100564dac03 100644 --- a/src/core/server/elasticsearch/integration_tests/client.test.ts +++ b/src/core/server/elasticsearch/integration_tests/client.test.ts @@ -52,17 +52,6 @@ describe('elasticsearch clients', () => { ); expect(resp2.headers).not.toHaveProperty('warning'); }); - - it('returns deprecation warning when x-elastic-product-orign header is not set', async () => { - const resp = - await kibanaServer.coreStart.elasticsearch.client.asInternalUser.indices.getSettings( - { index: '.kibana' }, - { headers: { 'x-elastic-product-origin': undefined } } - ); - - expect(resp.headers).toHaveProperty('warning'); - expect(resp.headers!.warning).toMatch('system indices'); - }); }); function createFakeElasticsearchServer() { From 8159269bb64374319cd48e63192ffd2bb5028f62 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 16:48:15 +0200 Subject: [PATCH 156/172] put "as" back --- x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts index cadd78c23f275..990376ca3e6ba 100644 --- a/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts +++ b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts @@ -85,9 +85,8 @@ async function uploadData() { apmCustomLinkIndex: '.apm-custom-links', apmAgentConfigurationIndex: '.apm-agent-configuration', }, - // TODO ask owners to fix search: (body) => { - return client.search(body); + return client.search(body) as Promise; }, indicesStats: (body) => { return client.indices.stats(body); From 7dffa45ac7701370cf554e9df6e9b887c929c7a7 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 22 Oct 2021 16:48:56 +0200 Subject: [PATCH 157/172] cleanup --- x-pack/plugins/apm/scripts/shared/get_es_client.ts | 3 ++- x-pack/plugins/licensing/server/plugin.ts | 5 ++++- .../apis/metrics_ui/metric_threshold_alert.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/apm/scripts/shared/get_es_client.ts b/x-pack/plugins/apm/scripts/shared/get_es_client.ts index c260ba0650d2a..3ee5642852c06 100644 --- a/x-pack/plugins/apm/scripts/shared/get_es_client.ts +++ b/x-pack/plugins/apm/scripts/shared/get_es_client.ts @@ -20,7 +20,8 @@ export function getEsClient({ }: { node: string; auth?: ClientOptions['auth']; - // TODO ask owners to fix + // Should be refactored + // The inferred type of 'getEsClient' references an inaccessible 'unique symbol' type. A type annotation is necessary. }): any { const client = new Client({ node, diff --git a/x-pack/plugins/licensing/server/plugin.ts b/x-pack/plugins/licensing/server/plugin.ts index 43c8135127871..83379fe48ac9e 100644 --- a/x-pack/plugins/licensing/server/plugin.ts +++ b/x-pack/plugins/licensing/server/plugin.ts @@ -177,7 +177,10 @@ export class LicensingPlugin implements Plugin): Promise => { const client = isPromise(clusterClient) ? await clusterClient : clusterClient; try { - const { body: response } = await client.asInternalUser.xpack.info(); + const { body: response } = await client.asInternalUser.xpack.info({ + // @ts-expect-error `accept_enterprise` is not present in the client definition + accept_enterprise: true, + }); const normalizedLicense = response.license && response.license.type !== 'missing' ? normalizeServerLicense(response.license) diff --git a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts index 5e8dcd683375e..bf5e9532edf25 100644 --- a/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts +++ b/x-pack/test/api_integration/apis/metrics_ui/metric_threshold_alert.ts @@ -81,7 +81,7 @@ export default function ({ getService }: FtrProviderContext) { ], }; - describe('FOO Metric Threshold Alerts Executor', () => { + describe('Metric Threshold Alerts Executor', () => { describe('with 10K plus docs', () => { before(() => esArchiver.load('x-pack/test/functional/es_archives/infra/ten_thousand_plus')); after(() => esArchiver.unload('x-pack/test/functional/es_archives/infra/ten_thousand_plus')); From b88c94cfe5ff51381668b619f5c5154f97891036 Mon Sep 17 00:00:00 2001 From: restrry Date: Sat, 23 Oct 2021 12:55:45 +0200 Subject: [PATCH 158/172] skip test --- .../batch_size_bytes_exceeds_es_content_length.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts index b47156e3a1e9e..72c3be0360e53 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts @@ -20,7 +20,8 @@ async function removeLogFile() { await fs.unlink(logFilePath).catch(() => void 0); } -describe('migration v2', () => { +// skipped until https://github.com/elastic/elasticsearch/issues/79684 is fixed in Elasticsearch +describe.skip('migration v2', () => { let esServer: kbnTestServer.TestElasticsearchUtils; let root: Root; let startES: () => Promise; From c175bee42974fdf80dcbcbb4c0a160e6aefe5669 Mon Sep 17 00:00:00 2001 From: restrry Date: Sun, 24 Oct 2021 12:58:24 +0200 Subject: [PATCH 159/172] remove new type errors in apm package --- .../src/scripts/utils/clean_write_targets.ts | 10 +++++----- .../src/scripts/utils/get_write_targets.ts | 7 +++---- .../src/scripts/utils/upload_events.ts | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/elastic-apm-generator/src/scripts/utils/clean_write_targets.ts b/packages/elastic-apm-generator/src/scripts/utils/clean_write_targets.ts index efa24f164d51e..3c514e1097b31 100644 --- a/packages/elastic-apm-generator/src/scripts/utils/clean_write_targets.ts +++ b/packages/elastic-apm-generator/src/scripts/utils/clean_write_targets.ts @@ -35,7 +35,7 @@ export async function cleanWriteTargets({ wait_for_completion: false, }); - const task = response.body.task; + const task = response.task; if (task) { await new Promise((resolve, reject) => { @@ -45,13 +45,13 @@ export async function cleanWriteTargets({ }); logger.debug( - `Polled for task:\n${JSON.stringify(taskResponse.body, ['completed', 'error'], 2)}` + `Polled for task:\n${JSON.stringify(taskResponse, ['completed', 'error'], 2)}` ); - if (taskResponse.body.completed) { + if (taskResponse.completed) { resolve(); - } else if (taskResponse.body.error) { - reject(taskResponse.body.error); + } else if (taskResponse.error) { + reject(taskResponse.error); } else { setTimeout(pollForTaskCompletion, 2500); } diff --git a/packages/elastic-apm-generator/src/scripts/utils/get_write_targets.ts b/packages/elastic-apm-generator/src/scripts/utils/get_write_targets.ts index 3640e4efaf796..3ad11a8fb049a 100644 --- a/packages/elastic-apm-generator/src/scripts/utils/get_write_targets.ts +++ b/packages/elastic-apm-generator/src/scripts/utils/get_write_targets.ts @@ -24,16 +24,15 @@ export async function getWriteTargets({ ]); function getDataStreamName(filter: string) { - return datastreamsResponse.body.data_streams.find((stream) => stream.name.includes(filter)) - ?.name; + return datastreamsResponse.data_streams.find((stream) => stream.name.includes(filter))?.name; } function getAlias(filter: string) { - return Object.keys(indicesResponse.body) + return Object.keys(indicesResponse) .map((key) => { return { key, - writeIndexAlias: Object.entries(indicesResponse.body[key].aliases).find( + writeIndexAlias: Object.entries(indicesResponse[key].aliases).find( ([_, alias]) => alias.is_write_index )?.[0], }; diff --git a/packages/elastic-apm-generator/src/scripts/utils/upload_events.ts b/packages/elastic-apm-generator/src/scripts/utils/upload_events.ts index 89cf4d4602177..63d0e451a3af6 100644 --- a/packages/elastic-apm-generator/src/scripts/utils/upload_events.ts +++ b/packages/elastic-apm-generator/src/scripts/utils/upload_events.ts @@ -52,7 +52,7 @@ export function uploadEvents({ ) .then((results) => { const errors = results - .flatMap((result) => result.body.items) + .flatMap((result) => result.items) .filter((item) => !!item.index?.error) .map((item) => item.index?.error); From 168d66027359df34f13aa5a0cbbf2455fc898572 Mon Sep 17 00:00:00 2001 From: restrry Date: Sun, 24 Oct 2021 12:59:08 +0200 Subject: [PATCH 160/172] remove ErrorCause casting --- .../server/saved_objects/migrations/core/elastic_index.ts | 4 ++-- .../actions/bulk_overwrite_transformed_documents.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/server/saved_objects/migrations/core/elastic_index.ts b/src/core/server/saved_objects/migrations/core/elastic_index.ts index d3e55e1f56f08..64df079897722 100644 --- a/src/core/server/saved_objects/migrations/core/elastic_index.ts +++ b/src/core/server/saved_objects/migrations/core/elastic_index.ts @@ -179,7 +179,7 @@ export async function write(client: MigrationEsClient, index: string, docs: RawD return; } - const exception: any = new Error((err.index!.error as estypes.ErrorCause)!.reason); + const exception: any = new Error(err.index!.error!.reason); exception.detail = err; throw exception; } @@ -415,7 +415,7 @@ async function reindex( task_id: String(task), }); - const e = body.error as estypes.ErrorCause; + const e = body.error; if (e) { throw new Error(`Re-index failed [${e.type}] ${e.reason} :: ${JSON.stringify(e)}`); } diff --git a/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts b/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts index 9c6d89cfcf18c..f3ddc0c308970 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/bulk_overwrite_transformed_documents.ts @@ -95,7 +95,7 @@ export const bulkOverwriteTransformedDocuments = // that another instance already updated these documents const errors: estypes.ErrorCause[] = (res.body.items ?? []) .filter((item) => item.index?.error) - .map((item) => item.index!.error! as estypes.ErrorCause) + .map((item) => item.index!.error!) .filter(({ type }) => type !== 'version_conflict_engine_exception'); if (errors.length === 0) { From bccf20235eec50fdfd0af5e16a31766b29ac46d6 Mon Sep 17 00:00:00 2001 From: restrry Date: Sun, 24 Oct 2021 13:00:44 +0200 Subject: [PATCH 161/172] update a comment --- src/core/server/elasticsearch/client/mocks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index 19a6872a80cf1..16eaf6c49a735 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -74,7 +74,7 @@ const createInternalClientMock = (res?: Promise): DeeplyMockedKeys which has only a getter mockGetter(client.diagnostic, 'on'); mockGetter(client.diagnostic, 'off'); From 887badec3496a8412a09d983bf5d0d54683d3b0b Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 09:48:34 +0200 Subject: [PATCH 162/172] bump version to 32 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 93d1ddd2bd55d..b87d27af16f2d 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.31", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.32", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 38017b44147f7..2a81104c94491 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.31": - version "8.0.0-canary.31" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.31.tgz#79aa97ee9c056a43060e6659d0cbd4f82c8735b6" - integrity sha512-DKYYAXwvNKjZzEZt74hywRH9wCjsXqUS8kRXr7AXHuccg3jAolViN+3/Asohn7qFcUqUYy+OvDb9TpDJA4CykQ== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.32": + version "8.0.0-canary.32" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.32.tgz#024923b0d5f181c3c0c82f0d8f5bcf8bea08a5a7" + integrity sha512-1AD7Gbvj8gMqFVU+ZmK3NFKnUy/HzvUddtvtX1sWOrcAduwrjW/HwuGzz4C5EjRuvTLD/SGMjRq4exYdKyKuyQ== dependencies: - "@elastic/transport" "^0.0.13" + "@elastic/transport" "^0.0.14" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.13": - version "0.0.13" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.13.tgz#7debe13146084e6421b222c8863a264393f87709" - integrity sha512-hiCeEVOlCOsUBiYmWho0Nebr5E4K6pA/zGj72tMX5oJ5mWEZ4wuvw7liiUazWXMrA2UmUAy82/Qnb5mdau7BwQ== +"@elastic/transport@^0.0.14": + version "0.0.14" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.14.tgz#facbdab0d3661c8128a423bf648d9a0852019bf7" + integrity sha512-Cz8zNuctfkZIFoxEU3q0ZbfidgZLXL8t7SBZfSU7jfqx56PC759LN6jx7DwRQYRS3EpJnQKC1QIL0jEzCD2P/g== dependencies: debug "^4.3.2" hpagent "^0.1.2" From b3281ba33e91d8feb9dfacb01b0b3b0ae246a25b Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 13:28:23 +0200 Subject: [PATCH 163/172] remove unnecessary ts-expect-error in apm code --- .../create_es_client/cancel_es_request_on_abort.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts index 3361aa01ff2fe..41dc33dfa193f 100644 --- a/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts +++ b/x-pack/plugins/apm/server/lib/helpers/create_es_client/cancel_es_request_on_abort.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { KibanaRequest } from 'src/core/server'; +import type { KibanaRequest } from 'src/core/server'; -export function cancelEsRequestOnAbort( +export function cancelEsRequestOnAbort>( promise: T, request: KibanaRequest, controller: AbortController @@ -16,14 +16,7 @@ export function cancelEsRequestOnAbort( controller.abort(); }); - // using .catch() here means unsubscribe will be called - // after it has thrown an error, so we use .then(onSuccess, onFailure) - // syntax - // @ts-expect-error fix abort - promise.then( - () => subscription.unsubscribe(), - () => subscription.unsubscribe() - ); + promise.finally(() => subscription.unsubscribe()); return promise; } From 96da44b8ed11e9d0c9658402e8e3b8f8ec171288 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 13:28:46 +0200 Subject: [PATCH 164/172] update comments --- packages/kbn-apm-config-loader/src/init_apm.test.ts | 2 +- packages/kbn-apm-config-loader/src/init_apm.ts | 2 +- packages/kbn-test/src/es/client_to_kibana_client.ts | 1 + .../batch_size_bytes_exceeds_es_content_length.test.ts | 2 +- x-pack/test/performance/tests/reporting_dashboard.ts | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/kbn-apm-config-loader/src/init_apm.test.ts b/packages/kbn-apm-config-loader/src/init_apm.test.ts index 5227528c5e8d6..6781b1b8b807e 100644 --- a/packages/kbn-apm-config-loader/src/init_apm.test.ts +++ b/packages/kbn-apm-config-loader/src/init_apm.test.ts @@ -11,7 +11,7 @@ import { mockLoadConfiguration } from './init_apm.test.mocks'; import { initApm } from './init_apm'; import apm from 'elastic-apm-node'; -// TODO: https://github.com/elastic/apm-agent-nodejs/issues/2355 is fixed +// TODO: unskip when https://github.com/elastic/kibana/issues/116109 is fixed describe.skip('initApm', () => { let apmAddFilterSpy: jest.SpyInstance; let apmStartSpy: jest.SpyInstance; diff --git a/packages/kbn-apm-config-loader/src/init_apm.ts b/packages/kbn-apm-config-loader/src/init_apm.ts index 0d318d16223c4..33609c2493396 100644 --- a/packages/kbn-apm-config-loader/src/init_apm.ts +++ b/packages/kbn-apm-config-loader/src/init_apm.ts @@ -14,7 +14,7 @@ export const initApm = ( isDistributable: boolean, serviceName: string ) => { - // TODO: re-enabled when https://github.com/elastic/apm-agent-nodejs/issues/2355 is fixed + // TODO: re-enabled when https://github.com/elastic/kibana/issues/116109 is fixed return; const apmConfigLoader = loadConfiguration(argv, rootDir, isDistributable); diff --git a/packages/kbn-test/src/es/client_to_kibana_client.ts b/packages/kbn-test/src/es/client_to_kibana_client.ts index 57c492f09c20f..778ee0a7705b3 100644 --- a/packages/kbn-test/src/es/client_to_kibana_client.ts +++ b/packages/kbn-test/src/es/client_to_kibana_client.ts @@ -14,6 +14,7 @@ import type { } from '@elastic/elasticsearch'; import { Transport } from '@elastic/elasticsearch'; +// remove once https://github.com/elastic/kibana/issues/116095 is addressed class KibanaTransport extends Transport { request(params: TransportRequestParams, options?: TransportRequestOptions) { const opts: TransportRequestOptions = options || {}; diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts index 72c3be0360e53..d992193730a34 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes_exceeds_es_content_length.test.ts @@ -20,7 +20,7 @@ async function removeLogFile() { await fs.unlink(logFilePath).catch(() => void 0); } -// skipped until https://github.com/elastic/elasticsearch/issues/79684 is fixed in Elasticsearch +// un-skip after https://github.com/elastic/kibana/issues/116111 describe.skip('migration v2', () => { let esServer: kbnTestServer.TestElasticsearchUtils; let root: Root; diff --git a/x-pack/test/performance/tests/reporting_dashboard.ts b/x-pack/test/performance/tests/reporting_dashboard.ts index 2ca77ff736a87..9d285b1cf7f44 100644 --- a/x-pack/test/performance/tests/reporting_dashboard.ts +++ b/x-pack/test/performance/tests/reporting_dashboard.ts @@ -16,7 +16,7 @@ export default function ({ getService, getPageObject }: FtrProviderContext) { const dashboard = getPageObject('dashboard'); const reporting = getPageObject('reporting'); - // TODO: unskip when https://github.com/elastic/apm-agent-nodejs/issues/2355 is fixed + // TODO: unskip when https://github.com/elastic/kibana/issues/116109 is fixed describe.skip('reporting dashbaord', () => { before(async () => { await kibanaServer.importExport.load( From 35e16faab2ae1de9740286105fdf1bbed40d3e49 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 16:01:12 +0200 Subject: [PATCH 165/172] update to client v33 --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index b87d27af16f2d..a665772667304 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.32", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.33", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index 2a81104c94491..c6717907f450a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,12 +2379,12 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.32": - version "8.0.0-canary.32" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.32.tgz#024923b0d5f181c3c0c82f0d8f5bcf8bea08a5a7" - integrity sha512-1AD7Gbvj8gMqFVU+ZmK3NFKnUy/HzvUddtvtX1sWOrcAduwrjW/HwuGzz4C5EjRuvTLD/SGMjRq4exYdKyKuyQ== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.33": + version "8.0.0-canary.33" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.33.tgz#0acc7aa8237a97f29e9b0114e71319359d6e59b1" + integrity sha512-ta1xLULZxWl43mXFYxK7XoMuDBVAqKPqvnbSs1dcz4A68d9mj7ckeUPrZHA3aSMihr2fdb9nBOfrvJvvq9+5EA== dependencies: - "@elastic/transport" "^0.0.14" + "@elastic/transport" "^0.0.15" tslib "^2.3.0" "@elastic/ems-client@7.16.0": @@ -2571,10 +2571,10 @@ ts-node "^10.2.1" typescript "^4.3.5" -"@elastic/transport@^0.0.14": - version "0.0.14" - resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.14.tgz#facbdab0d3661c8128a423bf648d9a0852019bf7" - integrity sha512-Cz8zNuctfkZIFoxEU3q0ZbfidgZLXL8t7SBZfSU7jfqx56PC759LN6jx7DwRQYRS3EpJnQKC1QIL0jEzCD2P/g== +"@elastic/transport@^0.0.15": + version "0.0.15" + resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-0.0.15.tgz#4f09806035d4959c1e2ab5e395f80927cb0ad821" + integrity sha512-V3ROTwKEWLT8X+rntJbZ4wV8sdt7HHSj81yi2Wv0DojQlvYo91Cit8YvdEwZcZHF4z8muIoWJv4G9gyD0MkfHQ== dependencies: debug "^4.3.2" hpagent "^0.1.2" From 89c284f5602bd9b80cd1fa69287438d07581dbdf Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 17:01:24 +0200 Subject: [PATCH 166/172] remove outdated type definition --- .../server/saved_objects/migrationsv2/actions/wait_for_task.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts b/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts index da3e8e8e05663..1a319d17dbce9 100644 --- a/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts +++ b/src/core/server/saved_objects/migrationsv2/actions/wait_for_task.ts @@ -17,7 +17,7 @@ import { } from './catch_retryable_es_client_errors'; /** @internal */ export interface WaitForTaskResponse { - error: Option.Option<{ type?: string; reason: string; index?: string }>; + error: Option.Option<{ type: string; reason: string; index?: string }>; completed: boolean; failures: Option.Option; description?: string; From 97d56575d624e6c59829c4a30eeb9c2e8497fa5c Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 17:03:25 +0200 Subject: [PATCH 167/172] bump to 34 without params mutation --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a665772667304..356c9c18cf060 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.33", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.34", "@elastic/ems-client": "7.16.0", "@elastic/eui": "39.1.1", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index c6717907f450a..819d17a5a7786 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,10 +2379,10 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.33": - version "8.0.0-canary.33" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.33.tgz#0acc7aa8237a97f29e9b0114e71319359d6e59b1" - integrity sha512-ta1xLULZxWl43mXFYxK7XoMuDBVAqKPqvnbSs1dcz4A68d9mj7ckeUPrZHA3aSMihr2fdb9nBOfrvJvvq9+5EA== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.34": + version "8.0.0-canary.34" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.34.tgz#05ba5b561b07e78e9b00a15bfdce4b31a06407c9" + integrity sha512-WWEBk3tHKX1C6vBzC1ovyAZIDhDn467H1Plxo6I1VxGdXHNtgqqzuXQc5oXj3bE8lfT3jsqWy0ull21ENCg8ww== dependencies: "@elastic/transport" "^0.0.15" tslib "^2.3.0" From f7aa7ce6773f71b0be3fb0aff480fcdde086cc30 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 17:04:16 +0200 Subject: [PATCH 168/172] unskip the test that should not fail anymore --- .../tests/apps/discover/async_search.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts index 68e614d1d26a8..cd13f71cf1bb7 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts @@ -102,10 +102,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await searchSessions.missingOrFail(); }); - // SKIPPED - see https://github.com/elastic/kibana/pull/113950 - // `expect(await toasts.getToastCount()).to.be(0)` fails because of a `Your search session is still running` toast - // rest of the test does pass - it.skip('relative timerange works', async () => { + it('relative timerange works', async () => { await PageObjects.common.navigateToApp('discover'); await PageObjects.header.waitUntilLoadingHasFinished(); await searchSessions.save(); From 5ad28bd01ccb9b5b9ca450d48294a48f2532c664 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 17:29:26 +0200 Subject: [PATCH 169/172] remove unnecessary ts-expect-error comments --- .../elasticsearch/template/install.test.ts | 62 ++++++++----------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts index 109d76be2826f..2e6365a9913e4 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.test.ts @@ -5,6 +5,7 @@ * 2.0. */ import { elasticsearchServiceMock } from 'src/core/server/mocks'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { createAppContextStartContractMock } from '../../../../mocks'; import { appContextService } from '../../../../services'; @@ -49,15 +50,13 @@ describe('EPM install', () => { packageName: pkg.name, }); - // @ts-expect-error - const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[0][0].body as Record< - string, - any - >; + const sentTemplate = ( + esClient.indices.putIndexTemplate.mock.calls[0][0] as estypes.IndicesPutIndexTemplateRequest + ).body; expect(sentTemplate).toBeDefined(); - expect(sentTemplate.priority).toBe(templatePriorityDatasetIsPrefixUnset); - expect(sentTemplate.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixUnset]); + expect(sentTemplate?.priority).toBe(templatePriorityDatasetIsPrefixUnset); + expect(sentTemplate?.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixUnset]); }); it('tests installPackage to use correct priority and index_patterns for data stream with dataset_is_prefix set to false', async () => { @@ -91,15 +90,13 @@ describe('EPM install', () => { packageName: pkg.name, }); - // @ts-expect-error - const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[0][0]!.body as Record< - string, - any - >; + const sentTemplate = ( + esClient.indices.putIndexTemplate.mock.calls[0][0] as estypes.IndicesPutIndexTemplateRequest + ).body; expect(sentTemplate).toBeDefined(); - expect(sentTemplate.priority).toBe(templatePriorityDatasetIsPrefixFalse); - expect(sentTemplate.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixFalse]); + expect(sentTemplate?.priority).toBe(templatePriorityDatasetIsPrefixFalse); + expect(sentTemplate?.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixFalse]); }); it('tests installPackage to use correct priority and index_patterns for data stream with dataset_is_prefix set to true', async () => { @@ -132,15 +129,14 @@ describe('EPM install', () => { packageVersion: pkg.version, packageName: pkg.name, }); - // @ts-expect-error - const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[0][0]!.body as Record< - string, - any - >; + + const sentTemplate = ( + esClient.indices.putIndexTemplate.mock.calls[0][0] as estypes.IndicesPutIndexTemplateRequest + ).body; expect(sentTemplate).toBeDefined(); - expect(sentTemplate.priority).toBe(templatePriorityDatasetIsPrefixTrue); - expect(sentTemplate.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixTrue]); + expect(sentTemplate?.priority).toBe(templatePriorityDatasetIsPrefixTrue); + expect(sentTemplate?.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixTrue]); }); it('tests installPackage remove the aliases property if the property existed', async () => { @@ -184,20 +180,16 @@ describe('EPM install', () => { packageName: pkg.name, }); - // @ts-expect-error - const removeAliases = esClient.indices.putIndexTemplate.mock.calls[0][0]!.body as Record< - string, - any - >; - expect(removeAliases.template.aliases).not.toBeDefined(); - - // @ts-expect-error - const sentTemplate = esClient.indices.putIndexTemplate.mock.calls[1][0]!.body as Record< - string, - any - >; + const removeAliases = ( + esClient.indices.putIndexTemplate.mock.calls[0][0] as estypes.IndicesPutIndexTemplateRequest + ).body; + expect(removeAliases?.template?.aliases).not.toBeDefined(); + + const sentTemplate = ( + esClient.indices.putIndexTemplate.mock.calls[1][0] as estypes.IndicesPutIndexTemplateRequest + ).body; expect(sentTemplate).toBeDefined(); - expect(sentTemplate.priority).toBe(templatePriorityDatasetIsPrefixUnset); - expect(sentTemplate.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixUnset]); + expect(sentTemplate?.priority).toBe(templatePriorityDatasetIsPrefixUnset); + expect(sentTemplate?.index_patterns).toEqual([templateIndexPatternDatasetIsPrefixUnset]); }); }); From 9ef6e220b1faa96ec8668a27c317eaddcb2532c2 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 25 Oct 2021 19:09:37 +0200 Subject: [PATCH 170/172] update to v35. body can be string --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cdf45431b1a33..72bd4e837081e 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "@elastic/apm-rum-react": "^1.3.1", "@elastic/charts": "38.0.1", "@elastic/datemath": "link:bazel-bin/packages/elastic-datemath", - "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.34", + "@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.35", "@elastic/ems-client": "7.16.0", "@elastic/eui": "40.0.0", "@elastic/filesaver": "1.1.2", diff --git a/yarn.lock b/yarn.lock index a73e91ff52e4b..c8d8a71f122d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2379,10 +2379,10 @@ dependencies: "@elastic/ecs-helpers" "^1.1.0" -"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.34": - version "8.0.0-canary.34" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.34.tgz#05ba5b561b07e78e9b00a15bfdce4b31a06407c9" - integrity sha512-WWEBk3tHKX1C6vBzC1ovyAZIDhDn467H1Plxo6I1VxGdXHNtgqqzuXQc5oXj3bE8lfT3jsqWy0ull21ENCg8ww== +"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.35": + version "8.0.0-canary.35" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.35.tgz#a6023cb83c063cb0a82eac5d0ef1b025d4025c74" + integrity sha512-mrMnIDrhZECjIy8sdARsuaRip9xm4xOmi+WtDWpIhmvRNZ3lpw5d9BmEr7+AnduG4HsccCGWY05HrA+iUtRV8w== dependencies: "@elastic/transport" "^0.0.15" tslib "^2.3.0" From 356a89b4b777407312f4f2b3a23afe11affe7c03 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Mon, 25 Oct 2021 21:32:48 +0200 Subject: [PATCH 171/172] move `sort` to body and use body friendly syntax --- .../fleet/server/services/artifacts/artifacts.test.ts | 8 ++++++-- .../plugins/fleet/server/services/artifacts/artifacts.ts | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts index 09ceb5e40a556..a0e186aafb79a 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/artifacts.test.ts @@ -153,11 +153,13 @@ describe('When using the artifacts services', () => { expect(esClientMock.search).toHaveBeenCalledWith({ index: FLEET_SERVER_ARTIFACTS_INDEX, - sort: 'created:asc', ignore_unavailable: true, q: '', from: 0, size: 20, + body: { + sort: [{ created: { order: 'asc' } }], + }, }); expect(results).toEqual({ @@ -185,11 +187,13 @@ describe('When using the artifacts services', () => { expect(esClientMock.search).toHaveBeenCalledWith({ index: FLEET_SERVER_ARTIFACTS_INDEX, - sort: 'identifier:desc', q: 'packageName:endpoint', ignore_unavailable: true, from: 450, size: 50, + body: { + sort: [{ identifier: { order: 'desc' } }], + }, }); expect(listMeta).toEqual({ diff --git a/x-pack/plugins/fleet/server/services/artifacts/artifacts.ts b/x-pack/plugins/fleet/server/services/artifacts/artifacts.ts index 6ac23cb1f9ef8..3a6db6fd0d04f 100644 --- a/x-pack/plugins/fleet/server/services/artifacts/artifacts.ts +++ b/x-pack/plugins/fleet/server/services/artifacts/artifacts.ts @@ -103,11 +103,13 @@ export const listArtifacts = async ( try { const searchResult = await esClient.search({ index: FLEET_SERVER_ARTIFACTS_INDEX, - sort: `${sortField}:${sortOrder}`, q: kuery, from: (page - 1) * perPage, ignore_unavailable: true, size: perPage, + body: { + sort: [{ [sortField]: { order: sortOrder } }], + }, }); return { From 61b7f90c9e0d768d6cc85f652406ab177c0fab79 Mon Sep 17 00:00:00 2001 From: restrry Date: Tue, 26 Oct 2021 11:51:18 +0200 Subject: [PATCH 172/172] fix a failing test. maps register the same SO that has been already registered by home --- x-pack/plugins/maps/server/plugin.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/maps/server/plugin.ts b/x-pack/plugins/maps/server/plugin.ts index 8768580089f31..5d84ee2ef26d2 100644 --- a/x-pack/plugins/maps/server/plugin.ts +++ b/x-pack/plugins/maps/server/plugin.ts @@ -73,7 +73,9 @@ export class MapsPlugin implements Plugin { defaultMessage: 'Map', }); - home.sampleData.addSavedObjectsToSampleDataset('ecommerce', getEcommerceSavedObjects()); + // commented out since it registers an SO already registered by home plugin + // https://github.com/elastic/kibana/blob/2ddaddc2e958f60c6685ab9f9840cdd86da9d398/src/plugins/home/server/services/sample_data/data_sets/ecommerce/saved_objects.ts#L151 + // home.sampleData.addSavedObjectsToSampleDataset('ecommerce', getEcommerceSavedObjects()); home.sampleData.addAppLinksToSampleDataset('ecommerce', [ {