From 54a8b37781eb5bf5e13dcb7a9c00806ac571a597 Mon Sep 17 00:00:00 2001 From: Laura Trotta <153528055+l-trotta@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:18:29 +0200 Subject: [PATCH] simplifying generics (#2665) --- output/openapi/elasticsearch-openapi.json | 16 ++--- .../elasticsearch-serverless-openapi.json | 16 ++--- output/schema/schema-serverless.json | 60 +++++-------------- output/schema/schema.json | 60 +++++-------------- output/typescript/types.ts | 10 ++-- specification/_types/query_dsl/compound.ts | 12 +--- 6 files changed, 52 insertions(+), 122 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index d057b75dbb..ff06b8ab3a 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -57817,14 +57817,14 @@ "_types.query_dsl:UntypedDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseField" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBase" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseField": { + "_types.query_dsl:DecayFunctionBase": { "type": "object", "properties": { "multi_value_mode": { @@ -57844,14 +57844,14 @@ "_types.query_dsl:DateDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseFieldDecayPlacementDateMathDuration" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseDecayPlacementDateMathDuration" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseFieldDecayPlacementDateMathDuration": { + "_types.query_dsl:DecayFunctionBaseDecayPlacementDateMathDuration": { "type": "object", "properties": { "multi_value_mode": { @@ -57862,14 +57862,14 @@ "_types.query_dsl:NumericDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseFieldDecayPlacementdoubledouble" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseDecayPlacementdoubledouble" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseFieldDecayPlacementdoubledouble": { + "_types.query_dsl:DecayFunctionBaseDecayPlacementdoubledouble": { "type": "object", "properties": { "multi_value_mode": { @@ -57880,14 +57880,14 @@ "_types.query_dsl:GeoDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseFieldDecayPlacementGeoLocationDistance" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseDecayPlacementGeoLocationDistance" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseFieldDecayPlacementGeoLocationDistance": { + "_types.query_dsl:DecayFunctionBaseDecayPlacementGeoLocationDistance": { "type": "object", "properties": { "multi_value_mode": { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 1349753c91..dd54f997e5 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -35138,14 +35138,14 @@ "_types.query_dsl:UntypedDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseField" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBase" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseField": { + "_types.query_dsl:DecayFunctionBase": { "type": "object", "properties": { "multi_value_mode": { @@ -35165,14 +35165,14 @@ "_types.query_dsl:DateDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseFieldDecayPlacementDateMathDuration" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseDecayPlacementDateMathDuration" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseFieldDecayPlacementDateMathDuration": { + "_types.query_dsl:DecayFunctionBaseDecayPlacementDateMathDuration": { "type": "object", "properties": { "multi_value_mode": { @@ -35183,14 +35183,14 @@ "_types.query_dsl:NumericDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseFieldDecayPlacementdoubledouble" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseDecayPlacementdoubledouble" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseFieldDecayPlacementdoubledouble": { + "_types.query_dsl:DecayFunctionBaseDecayPlacementdoubledouble": { "type": "object", "properties": { "multi_value_mode": { @@ -35201,14 +35201,14 @@ "_types.query_dsl:GeoDecayFunction": { "allOf": [ { - "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseFieldDecayPlacementGeoLocationDistance" + "$ref": "#/components/schemas/_types.query_dsl:DecayFunctionBaseDecayPlacementGeoLocationDistance" }, { "type": "object" } ] }, - "_types.query_dsl:DecayFunctionBaseFieldDecayPlacementGeoLocationDistance": { + "_types.query_dsl:DecayFunctionBaseDecayPlacementGeoLocationDistance": { "type": "object", "properties": { "multi_value_mode": { diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 2a0f76da78..21590b326b 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -49902,7 +49902,7 @@ "name": "FunctionBoostMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L285-L311" + "specLocation": "_types/query_dsl/compound.ts#L279-L305" }, { "esQuirk": "this container is valid without a variant. Despite being documented as a function, 'weight'\nis actually a container property that can be combined with a function. Comment in the ES code\n(SearchModule#registerScoreFunctions) says: Weight doesn't have its own parser, so every function\nsupports it out of the box. Can be a single function too when not associated to any other function,\nwhich is why it needs to be registered manually here.", @@ -50009,7 +50009,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L216-L256", + "specLocation": "_types/query_dsl/compound.ts#L210-L250", "variants": { "kind": "container" } @@ -50026,7 +50026,7 @@ "name": "DecayFunction", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L205-L214", + "specLocation": "_types/query_dsl/compound.ts#L199-L208", "type": { "items": [ { @@ -50074,13 +50074,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "kind": "user_defined_value" } @@ -50096,7 +50089,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L188-L191" + "specLocation": "_types/query_dsl/compound.ts#L188-L188" }, { "attachedBehaviors": [ @@ -50108,14 +50101,14 @@ { "kind": "instance_of", "type": { - "name": "TOrigin", - "namespace": "_types.query_dsl.DecayFunctionBase" + "name": "Field", + "namespace": "_types" } }, { "kind": "instance_of", "type": { - "name": "TScale", + "name": "TPlacement", "namespace": "_types.query_dsl.DecayFunctionBase" } } @@ -50132,11 +50125,7 @@ ], "generics": [ { - "name": "TOrigin", - "namespace": "_types.query_dsl.DecayFunctionBase" - }, - { - "name": "TScale", + "name": "TPlacement", "namespace": "_types.query_dsl.DecayFunctionBase" } ], @@ -50206,7 +50195,7 @@ "name": "MultiValueMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L358-L375" + "specLocation": "_types/query_dsl/compound.ts#L352-L369" }, { "attachedBehaviors": [ @@ -50214,13 +50203,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "generics": [ { @@ -50256,7 +50238,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L196-L199" + "specLocation": "_types/query_dsl/compound.ts#L192-L194" }, { "attachedBehaviors": [ @@ -50264,13 +50246,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "generics": [ { @@ -50306,7 +50281,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L192-L195" + "specLocation": "_types/query_dsl/compound.ts#L189-L191" }, { "attachedBehaviors": [ @@ -50314,13 +50289,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "generics": [ { @@ -50356,7 +50324,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L200-L203" + "specLocation": "_types/query_dsl/compound.ts#L195-L197" }, { "kind": "interface", @@ -50465,7 +50433,7 @@ "name": "FieldValueFactorModifier", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L313-L356" + "specLocation": "_types/query_dsl/compound.ts#L307-L350" }, { "kind": "interface", @@ -50744,7 +50712,7 @@ "name": "FunctionScoreMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L258-L283" + "specLocation": "_types/query_dsl/compound.ts#L252-L277" }, { "inherits": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 22ccf47cbb..a1c459571d 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -75442,13 +75442,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "generics": [ { @@ -75484,7 +75477,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L196-L199" + "specLocation": "_types/query_dsl/compound.ts#L192-L194" }, { "inherits": { @@ -75578,7 +75571,7 @@ "name": "DecayFunction", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L205-L214", + "specLocation": "_types/query_dsl/compound.ts#L199-L208", "type": { "items": [ { @@ -75630,14 +75623,14 @@ { "kind": "instance_of", "type": { - "name": "TOrigin", - "namespace": "_types.query_dsl.DecayFunctionBase" + "name": "Field", + "namespace": "_types" } }, { "kind": "instance_of", "type": { - "name": "TScale", + "name": "TPlacement", "namespace": "_types.query_dsl.DecayFunctionBase" } } @@ -75654,11 +75647,7 @@ ], "generics": [ { - "name": "TOrigin", - "namespace": "_types.query_dsl.DecayFunctionBase" - }, - { - "name": "TScale", + "name": "TPlacement", "namespace": "_types.query_dsl.DecayFunctionBase" } ], @@ -76087,7 +76076,7 @@ "name": "FieldValueFactorModifier", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L313-L356" + "specLocation": "_types/query_dsl/compound.ts#L307-L350" }, { "kind": "interface", @@ -76180,7 +76169,7 @@ "name": "FunctionBoostMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L285-L311" + "specLocation": "_types/query_dsl/compound.ts#L279-L305" }, { "esQuirk": "this container is valid without a variant. Despite being documented as a function, 'weight'\nis actually a container property that can be combined with a function. Comment in the ES code\n(SearchModule#registerScoreFunctions) says: Weight doesn't have its own parser, so every function\nsupports it out of the box. Can be a single function too when not associated to any other function,\nwhich is why it needs to be registered manually here.", @@ -76287,7 +76276,7 @@ } } ], - "specLocation": "_types/query_dsl/compound.ts#L216-L256", + "specLocation": "_types/query_dsl/compound.ts#L210-L250", "variants": { "kind": "container" } @@ -76324,7 +76313,7 @@ "name": "FunctionScoreMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L258-L283" + "specLocation": "_types/query_dsl/compound.ts#L252-L277" }, { "inherits": { @@ -76629,13 +76618,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "generics": [ { @@ -76671,7 +76653,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L200-L203" + "specLocation": "_types/query_dsl/compound.ts#L195-L197" }, { "inherits": { @@ -79138,7 +79120,7 @@ "name": "MultiValueMode", "namespace": "_types.query_dsl" }, - "specLocation": "_types/query_dsl/compound.ts#L358-L375" + "specLocation": "_types/query_dsl/compound.ts#L352-L369" }, { "inherits": { @@ -79250,13 +79232,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "generics": [ { @@ -79292,7 +79267,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L192-L195" + "specLocation": "_types/query_dsl/compound.ts#L189-L191" }, { "kind": "enum", @@ -83319,13 +83294,6 @@ ], "inherits": { "generics": [ - { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - }, { "kind": "user_defined_value" } @@ -83341,7 +83309,7 @@ "namespace": "_types.query_dsl" }, "properties": [], - "specLocation": "_types/query_dsl/compound.ts#L188-L191" + "specLocation": "_types/query_dsl/compound.ts#L188-L188" }, { "inherits": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index ca39c3478d..6d11470683 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -5492,7 +5492,7 @@ export interface QueryDslConstantScoreQuery extends QueryDslQueryBase { filter: QueryDslQueryContainer } -export interface QueryDslDateDecayFunctionKeys extends QueryDslDecayFunctionBase> { +export interface QueryDslDateDecayFunctionKeys extends QueryDslDecayFunctionBase> { } export type QueryDslDateDecayFunction = QueryDslDateDecayFunctionKeys & { [property: string]: QueryDslDecayPlacement | QueryDslMultiValueMode } @@ -5507,7 +5507,7 @@ export interface QueryDslDateRangeQuery extends QueryDslRangeQueryBase export type QueryDslDecayFunction = QueryDslUntypedDecayFunction | QueryDslDateDecayFunction | QueryDslNumericDecayFunction | QueryDslGeoDecayFunction -export interface QueryDslDecayFunctionBase { +export interface QueryDslDecayFunctionBase { multi_value_mode?: QueryDslMultiValueMode } @@ -5598,7 +5598,7 @@ export interface QueryDslGeoBoundingBoxQueryKeys extends QueryDslQueryBase { export type QueryDslGeoBoundingBoxQuery = QueryDslGeoBoundingBoxQueryKeys & { [property: string]: GeoBounds | QueryDslGeoExecution | QueryDslGeoValidationMethod | boolean | float | string } -export interface QueryDslGeoDecayFunctionKeys extends QueryDslDecayFunctionBase> { +export interface QueryDslGeoDecayFunctionKeys extends QueryDslDecayFunctionBase> { } export type QueryDslGeoDecayFunction = QueryDslGeoDecayFunctionKeys & { [property: string]: QueryDslDecayPlacement | QueryDslMultiValueMode } @@ -5852,7 +5852,7 @@ export interface QueryDslNestedQuery extends QueryDslQueryBase { export interface QueryDslNumberRangeQuery extends QueryDslRangeQueryBase { } -export interface QueryDslNumericDecayFunctionKeys extends QueryDslDecayFunctionBase> { +export interface QueryDslNumericDecayFunctionKeys extends QueryDslDecayFunctionBase> { } export type QueryDslNumericDecayFunction = QueryDslNumericDecayFunctionKeys & { [property: string]: QueryDslDecayPlacement | QueryDslMultiValueMode } @@ -6219,7 +6219,7 @@ export interface QueryDslTypeQuery extends QueryDslQueryBase { value: string } -export interface QueryDslUntypedDecayFunctionKeys extends QueryDslDecayFunctionBase { +export interface QueryDslUntypedDecayFunctionKeys extends QueryDslDecayFunctionBase { } export type QueryDslUntypedDecayFunction = QueryDslUntypedDecayFunctionKeys & { [property: string]: any } diff --git a/specification/_types/query_dsl/compound.ts b/specification/_types/query_dsl/compound.ts index 662eb434d9..f420e1b608 100644 --- a/specification/_types/query_dsl/compound.ts +++ b/specification/_types/query_dsl/compound.ts @@ -175,8 +175,8 @@ export class DecayPlacement { /** * @behavior_meta AdditionalProperty key=field value=placement */ -export class DecayFunctionBase - implements AdditionalProperty +export class DecayFunctionBase + implements AdditionalProperty { /** * Determines how the distance is calculated when a field used for computing the decay contains multiple values. @@ -185,20 +185,14 @@ export class DecayFunctionBase multi_value_mode?: MultiValueMode } -export class UntypedDecayFunction extends DecayFunctionBase< - Field, - UserDefinedValue -> {} +export class UntypedDecayFunction extends DecayFunctionBase {} export class NumericDecayFunction extends DecayFunctionBase< - Field, DecayPlacement > {} export class DateDecayFunction extends DecayFunctionBase< - Field, DecayPlacement > {} export class GeoDecayFunction extends DecayFunctionBase< - Field, DecayPlacement > {}