Skip to content

Commit

Permalink
Fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Sep 1, 2020
1 parent 49770ed commit 45a839b
Showing 1 changed file with 57 additions and 56 deletions.
113 changes: 57 additions & 56 deletions x-pack/plugins/apm/typings/elasticsearch/aggregations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ export type SortOptions = SortOrder | SortInstruction | SortInstruction[];
type Script =
| string
| {
lang?: string;
id?: string;
source?: string;
params?: Record<string, string | number>;
};
lang?: string;
id?: string;
source?: string;
params?: Record<string, string | number>;
};

type BucketsPath = string | Record<string, string>;

type SourceOptions = string | string[];

type MetricsAggregationOptions =
| {
field: string;
missing?: number;
}
field: string;
missing?: number;
}
| {
script?: Script;
};
script?: Script;
};

interface MetricsAggregationResponsePart {
value: number | null;
Expand All @@ -43,9 +43,9 @@ interface DateHistogramBucket {

type GetCompositeKeys<
TAggregationOptionsMap extends AggregationOptionsMap
> = TAggregationOptionsMap extends {
composite: { sources: Array<infer Source> };
}
> = TAggregationOptionsMap extends {
composite: { sources: Array<infer Source> };
}
? keyof Source
: never;

Expand All @@ -68,7 +68,8 @@ export interface AggregationOptionsByType {
min: number;
max: number;
};
} & ({ calendar_interval: string } | { fixed_interval: string }) & MetricsAggregationOptions;
} & ({ calendar_interval: string } | { fixed_interval: string }) &
MetricsAggregationOptions;
histogram: {
interval: number;
min_doc_count?: number;
Expand Down Expand Up @@ -171,14 +172,14 @@ export interface AggregationInputMap {
type BucketSubAggregationResponse<
TAggregationInputMap extends AggregationInputMap | undefined,
TDocument
> = TAggregationInputMap extends AggregationInputMap
> = TAggregationInputMap extends AggregationInputMap
? AggregationResponseMap<TAggregationInputMap, TDocument>
: {};

interface AggregationResponsePart<
TAggregationOptionsMap extends AggregationOptionsMap,
TDocument
> {
> {
terms: {
buckets: Array<
{
Expand All @@ -204,7 +205,7 @@ interface AggregationResponsePart<
date_histogram: {
buckets: Array<
DateHistogramBucket &
BucketSubAggregationResponse<TAggregationOptionsMap['aggs'], TDocument>
BucketSubAggregationResponse<TAggregationOptionsMap['aggs'], TDocument>
>;
};
avg: MetricsAggregationResponsePart;
Expand Down Expand Up @@ -248,38 +249,38 @@ interface AggregationResponsePart<
doc_count: number;
} & AggregationResponseMap<TAggregationOptionsMap['aggs'], TDocument>;
filters: TAggregationOptionsMap extends { filters: { filters: any[] } }
? Array<
{ doc_count: number } & AggregationResponseMap<
TAggregationOptionsMap['aggs'],
TDocument
>
>
: TAggregationOptionsMap extends {
filters: {
filters: Record<string, any>;
};
}
? {
buckets: {
[key in keyof TAggregationOptionsMap['filters']['filters']]: {
doc_count: number;
} & AggregationResponseMap<TAggregationOptionsMap['aggs'], TDocument>;
};
}
: never;
? Array<
{ doc_count: number } & AggregationResponseMap<
TAggregationOptionsMap['aggs'],
TDocument
>
>
: TAggregationOptionsMap extends {
filters: {
filters: Record<string, any>;
};
}
? {
buckets: {
[key in keyof TAggregationOptionsMap['filters']['filters']]: {
doc_count: number;
} & AggregationResponseMap<TAggregationOptionsMap['aggs'], TDocument>;
};
}
: never;
sampler: {
doc_count: number;
} & AggregationResponseMap<TAggregationOptionsMap['aggs'], TDocument>;
derivative:
| {
value: number;
}
| undefined;
| {
value: number;
}
| undefined;
bucket_script:
| {
value: number | null;
}
| undefined;
| {
value: number | null;
}
| undefined;
composite: {
after_key: Record<
GetCompositeKeys<TAggregationOptionsMap>,
Expand All @@ -303,13 +304,13 @@ interface AggregationResponsePart<
};
date_range: {
buckets: TAggregationOptionsMap extends { date_range: { keyed: true } }
? Record<string, DateRangeBucket>
: { buckets: DateRangeBucket[] };
? Record<string, DateRangeBucket>
: { buckets: DateRangeBucket[] };
};
auto_date_histogram: {
buckets: Array<
DateHistogramBucket &
AggregationResponseMap<TAggregationOptionsMap['aggs'], TDocument>
AggregationResponseMap<TAggregationOptionsMap['aggs'], TDocument>
>;
interval: string;
};
Expand All @@ -318,8 +319,8 @@ interface AggregationResponsePart<
values: TAggregationOptionsMap extends {
percentile_ranks: { keyed: false };
}
? Array<{ key: number; value: number }>
: Record<string, number>;
? Array<{ key: number; value: number }>
: Record<string, number>;
};
}

Expand All @@ -340,16 +341,16 @@ interface AggregationResponsePart<
// types, e.g. { foo: string; bar?: undefined } | { foo?: undefined; bar: string };
export type ValidAggregationKeysOf<
T extends Record<string, any>
> = keyof (UnionToIntersection<T> extends never ? T : UnionToIntersection<T>);
> = keyof (UnionToIntersection<T> extends never ? T : UnionToIntersection<T>);

export type AggregationResponseMap<
TAggregationInputMap extends AggregationInputMap | undefined,
TDocument
> = TAggregationInputMap extends AggregationInputMap
> = TAggregationInputMap extends AggregationInputMap
? {
[TName in keyof TAggregationInputMap]: AggregationResponsePart<
TAggregationInputMap[TName],
TDocument
>[AggregationType & ValidAggregationKeysOf<TAggregationInputMap[TName]>];
}
[TName in keyof TAggregationInputMap]: AggregationResponsePart<
TAggregationInputMap[TName],
TDocument
>[AggregationType & ValidAggregationKeysOf<TAggregationInputMap[TName]>];
}
: undefined;

0 comments on commit 45a839b

Please sign in to comment.