Skip to content

Commit

Permalink
Fix more types
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo committed Aug 22, 2024
1 parent 57da14b commit fbda1fc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }> =
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/ml/common/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export function dictionaryToArray<TValue>(dict: Dictionary<TValue>): 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<T> = {
[P in keyof T]?: DeepPartial<T[P]>;
};

export type DeepReadonly<T> = T extends Array<infer R>
? ReadonlyArray<DeepReadonly<T>>
: T extends Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
},
Expand Down Expand Up @@ -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'>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -32,10 +34,7 @@ export interface BaseHit<T> {
fields?: Record<string, SearchTypes[]>;
}

export interface EqlSequence<T> {
join_keys: SearchTypes[];
events: Array<BaseHit<T>>;
}
export type EqlSequence<T> = EqlHitsSequence<T>;

export interface EqlSearchResponse<T> {
is_partial: boolean;
Expand Down

0 comments on commit fbda1fc

Please sign in to comment.