Skip to content

Commit

Permalink
fix errors in transform plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Jun 4, 2021
1 parent 4e5e3d4 commit 4d562e5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/transform/common/api_schemas/type_guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const isEsSearchResponseWithAggregations = (

export const isMultiBucketAggregate = <TBucket = unknown>(
arg: unknown
): arg is estypes.MultiBucketAggregate<TBucket> => {
): arg is estypes.AggregationsMultiBucketAggregate<TBucket> => {
return isPopulatedObject(arg, ['buckets']);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export const FilterTermForm: FilterAggConfigTerm['aggTypeConfig']['FilterAggForm
if (
!(
isEsSearchResponseWithAggregations(response) &&
isMultiBucketAggregate<estypes.KeyedBucketKeys>(response.aggregations.field_values)
isMultiBucketAggregate<estypes.AggregationsKeyedBucketKeys>(
response.aggregations.field_values
)
)
) {
toastNotifications.addWarning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/transform/server/routes/api/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { schema } from '@kbn/config-schema';
import type { estypes } from '@elastic/elasticsearch';

import {
ElasticsearchClient,
Expand Down Expand Up @@ -570,7 +571,10 @@ const previewTransformHandler: RequestHandler<
return acc;
}, {} as Record<string, { type: string }>);

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) {
Expand Down

0 comments on commit 4d562e5

Please sign in to comment.