From 0ce3f1c85549d5b18c7a59e5b1324548e2d755c1 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 5 Jul 2024 11:57:04 +0400 Subject: [PATCH 1/5] Add missing priority field --- specification/query_rules/_types/QueryRuleset.ts | 2 ++ specification/query_rules/put_rule/QueryRulePutRequest.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/specification/query_rules/_types/QueryRuleset.ts b/specification/query_rules/_types/QueryRuleset.ts index de33443501..91b3d6162d 100644 --- a/specification/query_rules/_types/QueryRuleset.ts +++ b/specification/query_rules/_types/QueryRuleset.ts @@ -18,6 +18,7 @@ */ import { Id, IndexName, Name } from '@_types/common' +import { integer } from '@_types/Numeric' import { EpochTime, UnitMillis } from '@_types/Time' import { InlineScript } from '@_types/Scripting' import { UserDefinedValue } from '@spec_utils/UserDefinedValue' @@ -39,6 +40,7 @@ export class QueryRule { type: QueryRuleType criteria: QueryRuleCriteria[] actions: QueryRuleActions + priority?: integer } export enum QueryRuleType { diff --git a/specification/query_rules/put_rule/QueryRulePutRequest.ts b/specification/query_rules/put_rule/QueryRulePutRequest.ts index 9094b4f5a6..df75e1592e 100644 --- a/specification/query_rules/put_rule/QueryRulePutRequest.ts +++ b/specification/query_rules/put_rule/QueryRulePutRequest.ts @@ -18,6 +18,7 @@ */ import { RequestBase } from '@_types/Base' import { Id } from '@_types/common' +import { integer } from '@_types/Numeric' import { QueryRuleType, QueryRuleCriteria, @@ -50,5 +51,6 @@ export interface Request extends RequestBase { type: QueryRuleType criteria: QueryRuleCriteria[] actions: QueryRuleActions + priority?: integer } } From 0053366a872781f70d88c529bdf75f2819211df4 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 5 Jul 2024 11:57:35 +0400 Subject: [PATCH 2/5] Add fuzzy criteria type --- specification/query_rules/_types/QueryRuleset.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/specification/query_rules/_types/QueryRuleset.ts b/specification/query_rules/_types/QueryRuleset.ts index 91b3d6162d..2f8198fec0 100644 --- a/specification/query_rules/_types/QueryRuleset.ts +++ b/specification/query_rules/_types/QueryRuleset.ts @@ -57,6 +57,7 @@ export enum QueryRuleCriteriaType { global, exact, exact_fuzzy, + fuzzy, prefix, suffix, contains, From c7d91cbb1539040a189f13ef9f39b21e0b73afc6 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 5 Jul 2024 11:58:37 +0400 Subject: [PATCH 3/5] Allow criteria and rules to be single objects --- specification/query_rules/_types/QueryRuleset.ts | 2 +- specification/query_rules/put_rule/QueryRulePutRequest.ts | 2 +- specification/query_rules/put_ruleset/QueryRulesetPutRequest.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/query_rules/_types/QueryRuleset.ts b/specification/query_rules/_types/QueryRuleset.ts index 2f8198fec0..f8d31dc132 100644 --- a/specification/query_rules/_types/QueryRuleset.ts +++ b/specification/query_rules/_types/QueryRuleset.ts @@ -38,7 +38,7 @@ export class QueryRuleset { export class QueryRule { rule_id: Id type: QueryRuleType - criteria: QueryRuleCriteria[] + criteria: QueryRuleCriteria | QueryRuleCriteria[] actions: QueryRuleActions priority?: integer } diff --git a/specification/query_rules/put_rule/QueryRulePutRequest.ts b/specification/query_rules/put_rule/QueryRulePutRequest.ts index df75e1592e..bafdd311ff 100644 --- a/specification/query_rules/put_rule/QueryRulePutRequest.ts +++ b/specification/query_rules/put_rule/QueryRulePutRequest.ts @@ -49,7 +49,7 @@ export interface Request extends RequestBase { /** @codegen_name query_rule */ body: { type: QueryRuleType - criteria: QueryRuleCriteria[] + criteria: QueryRuleCriteria | QueryRuleCriteria[] actions: QueryRuleActions priority?: integer } diff --git a/specification/query_rules/put_ruleset/QueryRulesetPutRequest.ts b/specification/query_rules/put_ruleset/QueryRulesetPutRequest.ts index 9bfe726fe9..1b9f22f27e 100644 --- a/specification/query_rules/put_ruleset/QueryRulesetPutRequest.ts +++ b/specification/query_rules/put_ruleset/QueryRulesetPutRequest.ts @@ -38,6 +38,6 @@ export interface Request extends RequestBase { */ /** @codegen_name query_ruleset */ body: { - rules: QueryRule[] + rules: QueryRule | QueryRule[] } } From 8a544682cfb3343a1cc33726d81640901b8e6739 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 5 Jul 2024 11:59:09 +0400 Subject: [PATCH 4/5] Fix type of rule_criteria_types_counts --- specification/query_rules/list_rulesets/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/query_rules/list_rulesets/types.ts b/specification/query_rules/list_rulesets/types.ts index 918bd1d0f9..6aa550bc75 100644 --- a/specification/query_rules/list_rulesets/types.ts +++ b/specification/query_rules/list_rulesets/types.ts @@ -33,5 +33,5 @@ export class QueryRulesetListItem { /** * A map of criteria type to the number of rules of that type */ - rule_criteria_types_counts: Dictionary + rule_criteria_types_counts: Dictionary } From e9f50f4959761af90bd883f71008e8653a3d8653 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 5 Jul 2024 12:00:50 +0400 Subject: [PATCH 5/5] Run make contrib --- output/openapi/elasticsearch-openapi.json | 54 ++++++-- .../elasticsearch-serverless-openapi.json | 54 ++++++-- output/schema/schema-serverless.json | 121 +++++++++++++----- output/schema/schema.json | 121 +++++++++++++----- output/typescript/types.ts | 12 +- 5 files changed, 271 insertions(+), 91 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 828dd408ef..aad833fad0 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -24625,13 +24625,23 @@ "$ref": "#/components/schemas/query_rules._types:QueryRuleType" }, "criteria": { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" - } + "oneOf": [ + { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + } + } + ] }, "actions": { "$ref": "#/components/schemas/query_rules._types:QueryRuleActions" + }, + "priority": { + "type": "number" } }, "required": [ @@ -24777,10 +24787,17 @@ "type": "object", "properties": { "rules": { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRule" - } + "oneOf": [ + { + "$ref": "#/components/schemas/query_rules._types:QueryRule" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules._types:QueryRule" + } + } + ] } }, "required": [ @@ -93163,13 +93180,23 @@ "$ref": "#/components/schemas/query_rules._types:QueryRuleType" }, "criteria": { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" - } + "oneOf": [ + { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + } + } + ] }, "actions": { "$ref": "#/components/schemas/query_rules._types:QueryRuleActions" + }, + "priority": { + "type": "number" } }, "required": [ @@ -93211,6 +93238,7 @@ "global", "exact", "exact_fuzzy", + "fuzzy", "prefix", "suffix", "contains", @@ -93271,7 +93299,7 @@ "description": "A map of criteria type to the number of rules of that type", "type": "object", "additionalProperties": { - "type": "string" + "type": "number" } } }, diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index fd03a9aa9e..e9a4ef9557 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -15307,13 +15307,23 @@ "$ref": "#/components/schemas/query_rules._types:QueryRuleType" }, "criteria": { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" - } + "oneOf": [ + { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + } + } + ] }, "actions": { "$ref": "#/components/schemas/query_rules._types:QueryRuleActions" + }, + "priority": { + "type": "number" } }, "required": [ @@ -15459,10 +15469,17 @@ "type": "object", "properties": { "rules": { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRule" - } + "oneOf": [ + { + "$ref": "#/components/schemas/query_rules._types:QueryRule" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules._types:QueryRule" + } + } + ] } }, "required": [ @@ -59938,13 +59955,23 @@ "$ref": "#/components/schemas/query_rules._types:QueryRuleType" }, "criteria": { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" - } + "oneOf": [ + { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules._types:QueryRuleCriteria" + } + } + ] }, "actions": { "$ref": "#/components/schemas/query_rules._types:QueryRuleActions" + }, + "priority": { + "type": "number" } }, "required": [ @@ -59986,6 +60013,7 @@ "global", "exact", "exact_fuzzy", + "fuzzy", "prefix", "suffix", "contains", @@ -60046,7 +60074,7 @@ "description": "A map of criteria type to the number of rules of that type", "type": "object", "additionalProperties": { - "type": "string" + "type": "number" } } }, diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 157e5ce10b..0ad3e734f0 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -35825,14 +35825,26 @@ "name": "criteria", "required": true, "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRuleCriteria", - "namespace": "query_rules._types" + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + } } - } + ], + "kind": "union_of" } }, { @@ -35845,6 +35857,17 @@ "namespace": "query_rules._types" } } + }, + { + "name": "priority", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } } ] }, @@ -35887,7 +35910,7 @@ } ], "query": [], - "specLocation": "query_rules/put_rule/QueryRulePutRequest.ts#L27-L54" + "specLocation": "query_rules/put_rule/QueryRulePutRequest.ts#L28-L56" }, { "body": { @@ -35924,14 +35947,26 @@ "name": "rules", "required": true, "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRule", - "namespace": "query_rules._types" + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryRule", + "namespace": "query_rules._types" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRule", + "namespace": "query_rules._types" + } + } } - } + ], + "kind": "union_of" } } ] @@ -99339,6 +99374,9 @@ { "name": "exact_fuzzy" }, + { + "name": "fuzzy" + }, { "name": "prefix" }, @@ -99368,7 +99406,7 @@ "name": "QueryRuleCriteriaType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L54-L66" + "specLocation": "query_rules/_types/QueryRuleset.ts#L56-L69" }, { "kind": "enum", @@ -99381,7 +99419,7 @@ "name": "QueryRuleType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L44-L46" + "specLocation": "query_rules/_types/QueryRuleset.ts#L46-L48" }, { "kind": "enum", @@ -132762,14 +132800,26 @@ "name": "criteria", "required": true, "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRuleCriteria", - "namespace": "query_rules._types" + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + } } - } + ], + "kind": "union_of" } }, { @@ -132782,9 +132832,20 @@ "namespace": "query_rules._types" } } + }, + { + "name": "priority", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L37-L42" + "specLocation": "query_rules/_types/QueryRuleset.ts#L38-L44" }, { "kind": "interface", @@ -132826,7 +132887,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L48-L52" + "specLocation": "query_rules/_types/QueryRuleset.ts#L50-L54" }, { "kind": "interface", @@ -132864,7 +132925,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L68-L71" + "specLocation": "query_rules/_types/QueryRuleset.ts#L71-L74" }, { "kind": "interface", @@ -132901,7 +132962,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L26-L35" + "specLocation": "query_rules/_types/QueryRuleset.ts#L27-L36" }, { "kind": "interface", @@ -132951,8 +133012,8 @@ "value": { "kind": "instance_of", "type": { - "name": "string", - "namespace": "_builtins" + "name": "integer", + "namespace": "_types" } } } diff --git a/output/schema/schema.json b/output/schema/schema.json index 0366010f6d..30253b9b57 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -176026,14 +176026,26 @@ "name": "criteria", "required": true, "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRuleCriteria", - "namespace": "query_rules._types" + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + } } - } + ], + "kind": "union_of" } }, { @@ -176046,9 +176058,20 @@ "namespace": "query_rules._types" } } + }, + { + "name": "priority", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L37-L42" + "specLocation": "query_rules/_types/QueryRuleset.ts#L38-L44" }, { "kind": "interface", @@ -176086,7 +176109,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L68-L71" + "specLocation": "query_rules/_types/QueryRuleset.ts#L71-L74" }, { "kind": "interface", @@ -176128,7 +176151,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L48-L52" + "specLocation": "query_rules/_types/QueryRuleset.ts#L50-L54" }, { "kind": "enum", @@ -176142,6 +176165,9 @@ { "name": "exact_fuzzy" }, + { + "name": "fuzzy" + }, { "name": "prefix" }, @@ -176171,7 +176197,7 @@ "name": "QueryRuleCriteriaType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L54-L66" + "specLocation": "query_rules/_types/QueryRuleset.ts#L56-L69" }, { "kind": "enum", @@ -176184,7 +176210,7 @@ "name": "QueryRuleType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L44-L46" + "specLocation": "query_rules/_types/QueryRuleset.ts#L46-L48" }, { "kind": "interface", @@ -176221,7 +176247,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L26-L35" + "specLocation": "query_rules/_types/QueryRuleset.ts#L27-L36" }, { "attachedBehaviors": [ @@ -176511,8 +176537,8 @@ "value": { "kind": "instance_of", "type": { - "name": "string", - "namespace": "_builtins" + "name": "integer", + "namespace": "_types" } } } @@ -176628,14 +176654,26 @@ "name": "criteria", "required": true, "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRuleCriteria", - "namespace": "query_rules._types" + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRuleCriteria", + "namespace": "query_rules._types" + } + } } - } + ], + "kind": "union_of" } }, { @@ -176648,6 +176686,17 @@ "namespace": "query_rules._types" } } + }, + { + "name": "priority", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } } ] }, @@ -176690,7 +176739,7 @@ } ], "query": [], - "specLocation": "query_rules/put_rule/QueryRulePutRequest.ts#L27-L54" + "specLocation": "query_rules/put_rule/QueryRulePutRequest.ts#L28-L56" }, { "body": { @@ -176727,14 +176776,26 @@ "name": "rules", "required": true, "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRule", - "namespace": "query_rules._types" + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryRule", + "namespace": "query_rules._types" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRule", + "namespace": "query_rules._types" + } + } } - } + ], + "kind": "union_of" } } ] diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 50cfb46222..83268925fc 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -16366,8 +16366,9 @@ export interface NodesUsageResponseBase extends NodesNodesResponseBase { export interface QueryRulesQueryRule { rule_id: Id type: QueryRulesQueryRuleType - criteria: QueryRulesQueryRuleCriteria[] + criteria: QueryRulesQueryRuleCriteria | QueryRulesQueryRuleCriteria[] actions: QueryRulesQueryRuleActions + priority?: integer } export interface QueryRulesQueryRuleActions { @@ -16381,7 +16382,7 @@ export interface QueryRulesQueryRuleCriteria { values?: any[] } -export type QueryRulesQueryRuleCriteriaType = 'global' | 'exact' | 'exact_fuzzy' | 'prefix' | 'suffix' | 'contains' | 'lt' | 'lte' | 'gt' | 'gte' | 'always' +export type QueryRulesQueryRuleCriteriaType = 'global' | 'exact' | 'exact_fuzzy' | 'fuzzy' | 'prefix' | 'suffix' | 'contains' | 'lt' | 'lte' | 'gt' | 'gte' | 'always' export type QueryRulesQueryRuleType = 'pinned' @@ -16419,7 +16420,7 @@ export type QueryRulesGetRulesetResponse = QueryRulesQueryRuleset export interface QueryRulesListRulesetsQueryRulesetListItem { ruleset_id: Id rule_total_count: integer - rule_criteria_types_counts: Record + rule_criteria_types_counts: Record } export interface QueryRulesListRulesetsRequest extends RequestBase { @@ -16437,8 +16438,9 @@ export interface QueryRulesPutRuleRequest extends RequestBase { rule_id: Id body?: { type: QueryRulesQueryRuleType - criteria: QueryRulesQueryRuleCriteria[] + criteria: QueryRulesQueryRuleCriteria | QueryRulesQueryRuleCriteria[] actions: QueryRulesQueryRuleActions + priority?: integer } } @@ -16449,7 +16451,7 @@ export interface QueryRulesPutRuleResponse { export interface QueryRulesPutRulesetRequest extends RequestBase { ruleset_id: Id body?: { - rules: QueryRulesQueryRule[] + rules: QueryRulesQueryRule | QueryRulesQueryRule[] } }