Skip to content

Commit bd62fe3

Browse files
authored
reverting "making range aggregation untagged union (#2725)" (#4243)
1 parent e9322d6 commit bd62fe3

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

compiler/src/steps/validate-model.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,7 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
597597

598598
validateValueOf(valueOf, openGenerics)
599599
} else if (variants.kind === 'untagged') {
600-
if (fqn(parentName) !== '_types.aggregations:AggregationRange' &&
601-
fqn(parentName) !== '_types.query_dsl:DecayFunction' &&
600+
if (fqn(parentName) !== '_types.query_dsl:DecayFunction' &&
602601
fqn(parentName) !== '_types.query_dsl:DistanceFeatureQuery' &&
603602
fqn(parentName) !== '_types.query_dsl:RangeQuery') {
604603
throw new Error(`Please contact the devtools team before adding new untagged variant ${fqn(parentName)}`)

specification/_types/aggregations/bucket.ts

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export class DateRangeAggregation extends BucketAggregationBase {
295295
/**
296296
* Array of date ranges.
297297
*/
298-
ranges?: DateAggregationRange[]
298+
ranges?: DateRangeExpression[]
299299
/**
300300
* Time zone used to convert dates from another time zone to UTC.
301301
*/
@@ -306,6 +306,33 @@ export class DateRangeAggregation extends BucketAggregationBase {
306306
keyed?: boolean
307307
}
308308

309+
/**
310+
* A date range limit, represented either as a DateMath expression or a number expressed
311+
* according to the target field's precision.
312+
*
313+
* @codegen_names expr, value
314+
*/
315+
// ES: DateRangeAggregationBuilder.innerBuild()
316+
export type FieldDateMath = DateMath | double
317+
318+
export class DateRangeExpression {
319+
/**
320+
* Start of the range (inclusive).
321+
*/
322+
from?: FieldDateMath
323+
/**
324+
* Custom key to return the range with.
325+
*/
326+
key?: string
327+
/**
328+
* End of the range (exclusive).
329+
*/
330+
to?: FieldDateMath
331+
}
332+
333+
/**
334+
* @ext_doc_id search-aggregations-bucket-diversified-sampler-aggregation
335+
*/
309336
export class DiversifiedSamplerAggregation extends BucketAggregationBase {
310337
/**
311338
* The type of value used for de-duplication.
@@ -661,48 +688,24 @@ export class RangeAggregation extends BucketAggregationBase {
661688
format?: string
662689
}
663690

664-
/**
665-
* @codegen_names untyped, date, number, term
666-
* @variants untagged untyped=_types.aggregations.UntypedAggregationRange
667-
*/
668-
export type AggregationRange =
669-
| UntypedAggregationRange
670-
| DateAggregationRange
671-
| NumberAggregationRange
672-
| TermAggregationRange
673-
674-
export class AggregationRangeBase<T> {
691+
export class AggregationRange {
675692
/**
676693
* Start of the range (inclusive).
677694
*/
678-
from?: T
695+
from?: double | null
679696
/**
680697
* Custom key to return the range with.
681698
*/
682699
key?: string
683700
/**
684701
* End of the range (exclusive).
685702
*/
686-
to?: T
703+
to?: double | null
687704
}
688705

689-
export class NumberAggregationRange extends AggregationRangeBase<double> {}
690-
691-
export class TermAggregationRange extends AggregationRangeBase<string> {}
692-
693-
export class UntypedAggregationRange extends AggregationRangeBase<UserDefinedValue> {}
694-
695-
export class DateAggregationRange extends AggregationRangeBase<FieldDateMath> {}
696-
697706
/**
698-
* A date range limit, represented either as a DateMath expression or a number expressed
699-
* according to the target field's precision.
700-
*
701-
* @codegen_names expr, value
707+
* @ext_doc_id search-aggregations-bucket-rare-terms-aggregation
702708
*/
703-
// ES: DateRangeAggregationBuilder.innerBuild()
704-
export type FieldDateMath = DateMath | double
705-
706709
export class RareTermsAggregation extends BucketAggregationBase {
707710
/**
708711
* Terms that should be excluded from the aggregation.

0 commit comments

Comments
 (0)