From fbda1fc2d1fddadd5cbf1b8ba4e2be52dab3fda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 22 Aug 2024 17:45:40 +0200 Subject: [PATCH] Fix more types --- .../components/search_index/index_error.tsx | 1 - x-pack/plugins/ml/common/types/common.ts | 6 ++++++ .../legacy_uptime/lib/requests/get_ping_histogram.ts | 2 -- .../server/lib/delete_inference_endpoint.ts | 2 +- .../security_solution/common/detection_engine/types.ts | 7 +++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_error.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_error.tsx index 38d50c9a731fd..49a3ca412a547 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_error.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/index_error.tsx @@ -50,7 +50,6 @@ const getSemanticTextFields = ( return Object.entries(fields).flatMap(([key, value]) => { const currentPath: string = path ? `${path}.${key}` : key; const currentField: Array<{ path: string; source: SemanticTextProperty }> = - // @ts-expect-error because semantic_text type isn't incorporated in API type yet value.type === 'semantic_text' ? [{ path: currentPath, source: value }] : []; if (hasProperties(value)) { const childSemanticTextFields: Array<{ path: string; source: SemanticTextProperty }> = diff --git a/x-pack/plugins/ml/common/types/common.ts b/x-pack/plugins/ml/common/types/common.ts index ce6f61789a94b..ec75a2b8d525f 100644 --- a/x-pack/plugins/ml/common/types/common.ts +++ b/x-pack/plugins/ml/common/types/common.ts @@ -17,6 +17,12 @@ export function dictionaryToArray(dict: Dictionary): TValue[] { return Object.keys(dict).map((key) => dict[key]); } +// A recursive partial type to allow passing nested partial attributes. +// Used for example for the optional `jobConfig.dest.results_field` property. +export type DeepPartial = { + [P in keyof T]?: DeepPartial; +}; + export type DeepReadonly = T extends Array ? ReadonlyArray> : T extends Function diff --git a/x-pack/plugins/observability_solution/uptime/server/legacy_uptime/lib/requests/get_ping_histogram.ts b/x-pack/plugins/observability_solution/uptime/server/legacy_uptime/lib/requests/get_ping_histogram.ts index d7e4372b0a100..192c77bbb0c32 100644 --- a/x-pack/plugins/observability_solution/uptime/server/legacy_uptime/lib/requests/get_ping_histogram.ts +++ b/x-pack/plugins/observability_solution/uptime/server/legacy_uptime/lib/requests/get_ping_histogram.ts @@ -50,7 +50,6 @@ export const getPingHistogram: UMElasticsearchQueryFn< body: { query: { bool: { - // @ts-expect-error upgrade typescript v5.1.6 filter: [...filter, SUMMARY_FILTER, EXCLUDE_RUN_ONCE_FILTER], }, }, @@ -81,7 +80,6 @@ export const getPingHistogram: UMElasticsearchQueryFn< }); const { body: result } = await uptimeEsClient.search(params, 'getPingsOverTime'); - // @ts-expect-error upgrade typescript v5.1.6 const buckets = result?.aggregations?.timeseries?.buckets ?? []; const histogram = buckets.map((bucket: Pick<(typeof buckets)[0], 'key' | 'down' | 'up'>) => { diff --git a/x-pack/plugins/search_inference_endpoints/server/lib/delete_inference_endpoint.ts b/x-pack/plugins/search_inference_endpoints/server/lib/delete_inference_endpoint.ts index 1bd6592488151..561a1f4f157ab 100644 --- a/x-pack/plugins/search_inference_endpoints/server/lib/delete_inference_endpoint.ts +++ b/x-pack/plugins/search_inference_endpoints/server/lib/delete_inference_endpoint.ts @@ -19,6 +19,6 @@ export const deleteInferenceEndpoint = async ( id: string ) => { if (isTaskType(type)) { - return await client.inference.deleteModel({ inference_id: id, task_type: type }); + return await client.inference.delete({ inference_id: id, task_type: type }); } }; diff --git a/x-pack/plugins/security_solution/common/detection_engine/types.ts b/x-pack/plugins/security_solution/common/detection_engine/types.ts index 0d87a7e0f8755..4ec806b7e81c1 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/types.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/types.ts @@ -5,6 +5,8 @@ * 2.0. */ +import type { EqlHitsSequence } from '@elastic/elasticsearch/lib/api/types'; + /** * Defines the search types you can have from Elasticsearch within a * doc._source. It uses recursive types of "| SearchTypes[]" to designate @@ -32,10 +34,7 @@ export interface BaseHit { fields?: Record; } -export interface EqlSequence { - join_keys: SearchTypes[]; - events: Array>; -} +export type EqlSequence = EqlHitsSequence; export interface EqlSearchResponse { is_partial: boolean;