From 4d562e52d5d984aef5b963a1dd883297eeecb94b Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Fri, 4 Jun 2021 16:23:00 +0300 Subject: [PATCH] fix errors in transform plugin --- x-pack/plugins/transform/common/api_schemas/type_guards.ts | 2 +- x-pack/plugins/transform/public/app/hooks/use_index_data.ts | 2 +- .../common/filter_agg/components/filter_term_form.tsx | 4 +++- .../plugins/transform/server/routes/api/field_histograms.ts | 1 - x-pack/plugins/transform/server/routes/api/transforms.ts | 6 +++++- 5 files changed, 10 insertions(+), 5 deletions(-) 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 4b66de9be20d2..1f27f1798c8e7 100644 --- a/x-pack/plugins/transform/common/api_schemas/type_guards.ts +++ b/x-pack/plugins/transform/common/api_schemas/type_guards.ts @@ -74,7 +74,7 @@ export const isEsSearchResponseWithAggregations = ( export const isMultiBucketAggregate = ( arg: unknown -): arg is estypes.MultiBucketAggregate => { +): arg is estypes.AggregationsMultiBucketAggregate => { return isPopulatedObject(arg, ['buckets']); }; 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 bd1ecd79f4d12..55a304207a1c7 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 @@ -206,7 +206,7 @@ export const useIndexData = ( setRowCount(typeof resp.hits.total === 'number' ? resp.hits.total : resp.hits.total.value); setRowCountRelation( typeof resp.hits.total === 'number' - ? ('eq' as estypes.TotalHitsRelation) + ? ('eq' as estypes.SearchTotalHitsRelation) : resp.hits.total.relation ); setTableItems(docs); 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 358bb9dcafa96..da7100a31167a 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 @@ -69,7 +69,9 @@ export const FilterTermForm: FilterAggConfigTerm['aggTypeConfig']['FilterAggForm if ( !( isEsSearchResponseWithAggregations(response) && - isMultiBucketAggregate(response.aggregations.field_values) + isMultiBucketAggregate( + response.aggregations.field_values + ) ) ) { toastNotifications.addWarning( diff --git a/x-pack/plugins/transform/server/routes/api/field_histograms.ts b/x-pack/plugins/transform/server/routes/api/field_histograms.ts index bb2a1b278a5c2..bfe2f47078569 100644 --- a/x-pack/plugins/transform/server/routes/api/field_histograms.ts +++ b/x-pack/plugins/transform/server/routes/api/field_histograms.ts @@ -41,7 +41,6 @@ export function registerFieldHistogramsRoutes({ router, license }: RouteDependen query, fields, samplerShardSize, - // @ts-expect-error script is not compatible with StoredScript from @elastic/elasticsearch: string is not supported runtimeMappings ); diff --git a/x-pack/plugins/transform/server/routes/api/transforms.ts b/x-pack/plugins/transform/server/routes/api/transforms.ts index 34ae3f42d8622..ea2bb28776ac2 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms.ts @@ -6,6 +6,7 @@ */ import { schema } from '@kbn/config-schema'; +import type { estypes } from '@elastic/elasticsearch'; import { ElasticsearchClient, @@ -570,7 +571,10 @@ const previewTransformHandler: RequestHandler< return acc; }, {} as Record); - body.generated_dest_index.mappings.properties = fields; + body.generated_dest_index.mappings!.properties = fields as Record< + string, + estypes.MappingProperty + >; } return res.ok({ body }); } catch (e) {