From 90fe7e26253312b8efb4cad3fcb5c49e02bb325d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Saint-F=C3=A9lix?= Date: Fri, 12 Jul 2024 13:19:43 +0200 Subject: [PATCH] [Proposal] Transform script into a container (#2708) * transform script union to a container variant * Remove unused imports * refresh outputs * remove wrongly added empty files * merge script into a standard class * add output * remove duplicated fields * add newly generated output * simplify RoleTemplateScript to reflect Script changes * add newly generated output * make source option in RoleTemplateScript --- output/openapi/elasticsearch-openapi.json | 140 +++---- .../elasticsearch-serverless-openapi.json | 140 +++---- output/schema/schema-serverless.json | 237 +++++------- output/schema/schema.json | 347 +++++++----------- output/typescript/types.ts | 118 +++--- .../ExecutePainlessScriptRequest.ts | 4 +- specification/_types/Scripting.ts | 32 +- .../query_rules/_types/QueryRuleset.ts | 4 +- .../_types/SearchApplication.ts | 4 +- specification/security/_types/Privileges.ts | 25 +- 10 files changed, 413 insertions(+), 638 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 06c4e013b2..e9f5f10b91 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -51720,7 +51720,7 @@ "$ref": "#/components/schemas/_global.scripts_painless_execute:PainlessContextSetup" }, "script": { - "$ref": "#/components/schemas/_types:InlineScript" + "$ref": "#/components/schemas/_types:Script" } } } @@ -58928,42 +58928,32 @@ ] }, "_types:Script": { - "oneOf": [ - { - "$ref": "#/components/schemas/_types:InlineScript" + "type": "object", + "properties": { + "source": { + "description": "The script source.", + "type": "string" }, - { - "$ref": "#/components/schemas/_types:StoredScriptId" - } - ] - }, - "_types:InlineScript": { - "allOf": [ - { - "$ref": "#/components/schemas/_types:ScriptBase" + "id": { + "$ref": "#/components/schemas/_types:Id" }, - { + "params": { + "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", "type": "object", - "properties": { - "lang": { - "$ref": "#/components/schemas/_types:ScriptLanguage" - }, - "options": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "source": { - "description": "The script source.", - "type": "string" - } - }, - "required": [ - "source" - ] + "additionalProperties": { + "type": "object" + } + }, + "lang": { + "$ref": "#/components/schemas/_types:ScriptLanguage" + }, + "options": { + "type": "object", + "additionalProperties": { + "type": "string" + } } - ] + } }, "_types:ScriptLanguage": { "anyOf": [ @@ -58981,36 +58971,6 @@ } ] }, - "_types:ScriptBase": { - "type": "object", - "properties": { - "params": { - "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", - "type": "object", - "additionalProperties": { - "type": "object" - } - } - } - }, - "_types:StoredScriptId": { - "allOf": [ - { - "$ref": "#/components/schemas/_types:ScriptBase" - }, - { - "type": "object", - "properties": { - "id": { - "$ref": "#/components/schemas/_types:Id" - } - }, - "required": [ - "id" - ] - } - ] - }, "_types.query_dsl:FunctionScoreMode": { "type": "string", "enum": [ @@ -95472,7 +95432,7 @@ "type": "object", "properties": { "script": { - "$ref": "#/components/schemas/_types:InlineScript" + "$ref": "#/components/schemas/_types:Script" } }, "required": [ @@ -96150,41 +96110,31 @@ } }, "security._types:RoleTemplateScript": { - "oneOf": [ - { - "$ref": "#/components/schemas/security._types:RoleTemplateInlineScript" + "type": "object", + "properties": { + "source": { + "$ref": "#/components/schemas/security._types:RoleTemplateInlineQuery" }, - { - "$ref": "#/components/schemas/_types:StoredScriptId" - } - ] - }, - "security._types:RoleTemplateInlineScript": { - "allOf": [ - { - "$ref": "#/components/schemas/_types:ScriptBase" + "id": { + "$ref": "#/components/schemas/_types:Id" }, - { + "params": { + "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", "type": "object", - "properties": { - "lang": { - "$ref": "#/components/schemas/_types:ScriptLanguage" - }, - "options": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "source": { - "$ref": "#/components/schemas/security._types:RoleTemplateInlineQuery" - } - }, - "required": [ - "source" - ] + "additionalProperties": { + "type": "object" + } + }, + "lang": { + "$ref": "#/components/schemas/_types:ScriptLanguage" + }, + "options": { + "type": "object", + "additionalProperties": { + "type": "string" + } } - ] + } }, "security._types:RoleTemplateInlineQuery": { "oneOf": [ diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 591c2c7de1..a652fafee3 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -28908,7 +28908,7 @@ "$ref": "#/components/schemas/_global.scripts_painless_execute:PainlessContextSetup" }, "script": { - "$ref": "#/components/schemas/_types:InlineScript" + "$ref": "#/components/schemas/_types:Script" } } } @@ -35601,42 +35601,32 @@ ] }, "_types:Script": { - "oneOf": [ - { - "$ref": "#/components/schemas/_types:InlineScript" + "type": "object", + "properties": { + "source": { + "description": "The script source.", + "type": "string" }, - { - "$ref": "#/components/schemas/_types:StoredScriptId" - } - ] - }, - "_types:InlineScript": { - "allOf": [ - { - "$ref": "#/components/schemas/_types:ScriptBase" + "id": { + "$ref": "#/components/schemas/_types:Id" }, - { + "params": { + "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", "type": "object", - "properties": { - "lang": { - "$ref": "#/components/schemas/_types:ScriptLanguage" - }, - "options": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "source": { - "description": "The script source.", - "type": "string" - } - }, - "required": [ - "source" - ] + "additionalProperties": { + "type": "object" + } + }, + "lang": { + "$ref": "#/components/schemas/_types:ScriptLanguage" + }, + "options": { + "type": "object", + "additionalProperties": { + "type": "string" + } } - ] + } }, "_types:ScriptLanguage": { "anyOf": [ @@ -35654,36 +35644,6 @@ } ] }, - "_types:ScriptBase": { - "type": "object", - "properties": { - "params": { - "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", - "type": "object", - "additionalProperties": { - "type": "object" - } - } - } - }, - "_types:StoredScriptId": { - "allOf": [ - { - "$ref": "#/components/schemas/_types:ScriptBase" - }, - { - "type": "object", - "properties": { - "id": { - "$ref": "#/components/schemas/_types:Id" - } - }, - "required": [ - "id" - ] - } - ] - }, "_types.query_dsl:FunctionScoreMode": { "type": "string", "enum": [ @@ -60999,7 +60959,7 @@ "type": "object", "properties": { "script": { - "$ref": "#/components/schemas/_types:InlineScript" + "$ref": "#/components/schemas/_types:Script" } }, "required": [ @@ -61339,41 +61299,31 @@ } }, "security._types:RoleTemplateScript": { - "oneOf": [ - { - "$ref": "#/components/schemas/security._types:RoleTemplateInlineScript" + "type": "object", + "properties": { + "source": { + "$ref": "#/components/schemas/security._types:RoleTemplateInlineQuery" }, - { - "$ref": "#/components/schemas/_types:StoredScriptId" - } - ] - }, - "security._types:RoleTemplateInlineScript": { - "allOf": [ - { - "$ref": "#/components/schemas/_types:ScriptBase" + "id": { + "$ref": "#/components/schemas/_types:Id" }, - { + "params": { + "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", "type": "object", - "properties": { - "lang": { - "$ref": "#/components/schemas/_types:ScriptLanguage" - }, - "options": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "source": { - "$ref": "#/components/schemas/security._types:RoleTemplateInlineQuery" - } - }, - "required": [ - "source" - ] + "additionalProperties": { + "type": "object" + } + }, + "lang": { + "$ref": "#/components/schemas/_types:ScriptLanguage" + }, + "options": { + "type": "object", + "additionalProperties": { + "type": "string" + } } - ] + } }, "security._types:RoleTemplateInlineQuery": { "oneOf": [ diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index d5cfc28ed8..f3d08935b2 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -36016,7 +36016,7 @@ "type": { "kind": "instance_of", "type": { - "name": "InlineScript", + "name": "Script", "namespace": "_types" } } @@ -49816,64 +49816,39 @@ "specLocation": "_types/query_dsl/compound.ts#L121-L126" }, { - "codegenNames": [ - "inline", - "stored" - ], - "kind": "type_alias", + "kind": "interface", "name": { "name": "Script", "namespace": "_types" }, - "specLocation": "_types/Scripting.ts#L88-L89", - "type": { - "items": [ - { - "kind": "instance_of", - "type": { - "name": "InlineScript", - "namespace": "_types" - } - }, - { + "properties": [ + { + "description": "The script source.", + "name": "source", + "required": false, + "type": { "kind": "instance_of", "type": { - "name": "StoredScriptId", - "namespace": "_types" + "name": "string", + "namespace": "_builtins" } } - ], - "kind": "union_of" - } - }, - { - "inherits": { - "type": { - "name": "ScriptBase", - "namespace": "_types" - } - }, - "kind": "interface", - "name": { - "name": "InlineScript", - "namespace": "_types" - }, - "properties": [ + }, { - "description": "Specifies the language the script is written in.", - "name": "lang", + "description": "The `id` for a stored script.", + "name": "id", "required": false, - "serverDefault": "painless", "type": { "kind": "instance_of", "type": { - "name": "ScriptLanguage", + "name": "Id", "namespace": "_types" } } }, { - "name": "options", + "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", + "name": "params", "required": false, "type": { "key": { @@ -49886,40 +49861,25 @@ "kind": "dictionary_of", "singleKey": false, "value": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } + "kind": "user_defined_value" } } }, { - "description": "The script source.", - "name": "source", - "required": true, + "description": "Specifies the language the script is written in.", + "name": "lang", + "required": false, + "serverDefault": "painless", "type": { "kind": "instance_of", "type": { - "name": "string", - "namespace": "_builtins" + "name": "ScriptLanguage", + "namespace": "_types" } } - } - ], - "shortcutProperty": "source", - "specLocation": "_types/Scripting.ts#L67-L79" - }, - { - "kind": "interface", - "name": { - "name": "ScriptBase", - "namespace": "_types" - }, - "properties": [ + }, { - "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", - "name": "params", + "name": "options", "required": false, "type": { "key": { @@ -49932,12 +49892,17 @@ "kind": "dictionary_of", "singleKey": false, "value": { - "kind": "user_defined_value" + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } } } } ], - "specLocation": "_types/Scripting.ts#L59-L65" + "shortcutProperty": "source", + "specLocation": "_types/Scripting.ts#L73-L97" }, { "isOpen": true, @@ -49966,34 +49931,6 @@ }, "specLocation": "_types/Scripting.ts#L24-L45" }, - { - "inherits": { - "type": { - "name": "ScriptBase", - "namespace": "_types" - } - }, - "kind": "interface", - "name": { - "name": "StoredScriptId", - "namespace": "_types" - }, - "properties": [ - { - "description": "The `id` for a stored script.", - "name": "id", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Id", - "namespace": "_types" - } - } - } - ], - "specLocation": "_types/Scripting.ts#L81-L86" - }, { "kind": "enum", "members": [ @@ -53186,7 +53123,7 @@ } } ], - "specLocation": "_types/Scripting.ts#L91-L94" + "specLocation": "_types/Scripting.ts#L99-L102" }, { "kind": "type_alias", @@ -98614,7 +98551,7 @@ "name": "QueryRuleCriteriaType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L56-L69" + "specLocation": "query_rules/_types/QueryRuleset.ts#L54-L67" }, { "kind": "enum", @@ -98627,7 +98564,7 @@ "name": "QueryRuleType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L46-L48" + "specLocation": "query_rules/_types/QueryRuleset.ts#L44-L46" }, { "kind": "enum", @@ -98788,7 +98725,7 @@ "name": "ClusterPrivilege", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L41-L194" + "specLocation": "security/_types/Privileges.ts#L42-L195" }, { "kind": "enum", @@ -98865,7 +98802,7 @@ "name": "IndexPrivilege", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L281-L323" + "specLocation": "security/_types/Privileges.ts#L292-L334" }, { "codegenNames": [ @@ -98879,7 +98816,7 @@ "name": "IndicesPrivilegesQuery", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L246-L254", + "specLocation": "security/_types/Privileges.ts#L247-L255", "type": { "items": [ { @@ -98929,55 +98866,62 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L256-L266" + "specLocation": "security/_types/Privileges.ts#L257-L267" }, { - "codegenNames": [ - "inline", - "stored" - ], - "kind": "type_alias", + "kind": "interface", "name": { "name": "RoleTemplateScript", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L278-L279", - "type": { - "items": [ - { + "properties": [ + { + "name": "source", + "required": false, + "type": { "kind": "instance_of", "type": { - "name": "RoleTemplateInlineScript", + "name": "RoleTemplateInlineQuery", "namespace": "security._types" } - }, - { + } + }, + { + "description": "The `id` for a stored script.", + "name": "id", + "required": false, + "type": { "kind": "instance_of", "type": { - "name": "StoredScriptId", + "name": "Id", "namespace": "_types" } } - ], - "kind": "union_of" - } - }, - { - "inherits": { - "type": { - "name": "ScriptBase", - "namespace": "_types" - } - }, - "kind": "interface", - "name": { - "name": "RoleTemplateInlineScript", - "namespace": "security._types" - }, - "properties": [ + }, + { + "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", + "name": "params", + "required": false, + "type": { + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + }, + "kind": "dictionary_of", + "singleKey": false, + "value": { + "kind": "user_defined_value" + } + } + }, { + "description": "Specifies the language the script is written in.", "name": "lang", "required": false, + "serverDefault": "painless", "type": { "kind": "instance_of", "type": { @@ -99007,21 +98951,10 @@ } } } - }, - { - "name": "source", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "RoleTemplateInlineQuery", - "namespace": "security._types" - } - } } ], "shortcutProperty": "source", - "specLocation": "security/_types/Privileges.ts#L268-L273" + "specLocation": "security/_types/Privileges.ts#L269-L287" }, { "codegenNames": [ @@ -99033,7 +98966,7 @@ "name": "RoleTemplateInlineQuery", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L275-L276", + "specLocation": "security/_types/Privileges.ts#L289-L290", "type": { "items": [ { @@ -132015,7 +131948,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L38-L44" + "specLocation": "query_rules/_types/QueryRuleset.ts#L36-L42" }, { "kind": "interface", @@ -132057,7 +131990,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L50-L54" + "specLocation": "query_rules/_types/QueryRuleset.ts#L48-L52" }, { "kind": "interface", @@ -132095,7 +132028,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L71-L74" + "specLocation": "query_rules/_types/QueryRuleset.ts#L69-L72" }, { "kind": "interface", @@ -132132,7 +132065,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L27-L36" + "specLocation": "query_rules/_types/QueryRuleset.ts#L25-L34" }, { "kind": "interface", @@ -133599,7 +133532,7 @@ "type": { "kind": "instance_of", "type": { - "name": "InlineScript", + "name": "Script", "namespace": "_types" } } @@ -134140,7 +134073,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L196-L220" + "specLocation": "security/_types/Privileges.ts#L197-L221" }, { "kind": "interface", @@ -134224,7 +134157,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L26-L39" + "specLocation": "security/_types/Privileges.ts#L27-L40" }, { "kind": "interface", diff --git a/output/schema/schema.json b/output/schema/schema.json index 74c7f33f3f..b252e05a7a 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -31176,7 +31176,7 @@ "type": { "kind": "instance_of", "type": { - "name": "InlineScript", + "name": "Script", "namespace": "_types" } } @@ -44095,70 +44095,6 @@ ], "specLocation": "_types/common.ts#L320-L333" }, - { - "inherits": { - "type": { - "name": "ScriptBase", - "namespace": "_types" - } - }, - "kind": "interface", - "name": { - "name": "InlineScript", - "namespace": "_types" - }, - "properties": [ - { - "description": "Specifies the language the script is written in.", - "name": "lang", - "required": false, - "serverDefault": "painless", - "type": { - "kind": "instance_of", - "type": { - "name": "ScriptLanguage", - "namespace": "_types" - } - } - }, - { - "name": "options", - "required": false, - "type": { - "key": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } - }, - "kind": "dictionary_of", - "singleKey": false, - "value": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } - } - } - }, - { - "description": "The script source.", - "name": "source", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } - } - } - ], - "shortcutProperty": "source", - "specLocation": "_types/Scripting.ts#L67-L79" - }, { "kind": "type_alias", "name": { @@ -46509,43 +46445,36 @@ "specLocation": "_types/sort.ts#L55-L57" }, { - "codegenNames": [ - "inline", - "stored" - ], - "kind": "type_alias", + "kind": "interface", "name": { "name": "Script", "namespace": "_types" }, - "specLocation": "_types/Scripting.ts#L88-L89", - "type": { - "items": [ - { + "properties": [ + { + "description": "The script source.", + "name": "source", + "required": false, + "type": { "kind": "instance_of", "type": { - "name": "InlineScript", - "namespace": "_types" + "name": "string", + "namespace": "_builtins" } - }, - { + } + }, + { + "description": "The `id` for a stored script.", + "name": "id", + "required": false, + "type": { "kind": "instance_of", "type": { - "name": "StoredScriptId", + "name": "Id", "namespace": "_types" } } - ], - "kind": "union_of" - } - }, - { - "kind": "interface", - "name": { - "name": "ScriptBase", - "namespace": "_types" - }, - "properties": [ + }, { "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", "name": "params", @@ -46564,9 +46493,45 @@ "kind": "user_defined_value" } } + }, + { + "description": "Specifies the language the script is written in.", + "name": "lang", + "required": false, + "serverDefault": "painless", + "type": { + "kind": "instance_of", + "type": { + "name": "ScriptLanguage", + "namespace": "_types" + } + } + }, + { + "name": "options", + "required": false, + "type": { + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + }, + "kind": "dictionary_of", + "singleKey": false, + "value": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + } } ], - "specLocation": "_types/Scripting.ts#L59-L65" + "shortcutProperty": "source", + "specLocation": "_types/Scripting.ts#L73-L97" }, { "kind": "interface", @@ -46598,7 +46563,7 @@ } } ], - "specLocation": "_types/Scripting.ts#L91-L94" + "specLocation": "_types/Scripting.ts#L99-L102" }, { "isOpen": true, @@ -48143,34 +48108,6 @@ ], "specLocation": "_types/Scripting.ts#L47-L57" }, - { - "inherits": { - "type": { - "name": "ScriptBase", - "namespace": "_types" - } - }, - "kind": "interface", - "name": { - "name": "StoredScriptId", - "namespace": "_types" - }, - "properties": [ - { - "description": "The `id` for a stored script.", - "name": "id", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Id", - "namespace": "_types" - } - } - } - ], - "specLocation": "_types/Scripting.ts#L81-L86" - }, { "kind": "enum", "members": [ @@ -174589,7 +174526,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L38-L44" + "specLocation": "query_rules/_types/QueryRuleset.ts#L36-L42" }, { "kind": "interface", @@ -174627,7 +174564,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L71-L74" + "specLocation": "query_rules/_types/QueryRuleset.ts#L69-L72" }, { "kind": "interface", @@ -174669,7 +174606,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L50-L54" + "specLocation": "query_rules/_types/QueryRuleset.ts#L48-L52" }, { "kind": "enum", @@ -174715,7 +174652,7 @@ "name": "QueryRuleCriteriaType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L56-L69" + "specLocation": "query_rules/_types/QueryRuleset.ts#L54-L67" }, { "kind": "enum", @@ -174728,7 +174665,7 @@ "name": "QueryRuleType", "namespace": "query_rules._types" }, - "specLocation": "query_rules/_types/QueryRuleset.ts#L46-L48" + "specLocation": "query_rules/_types/QueryRuleset.ts#L44-L46" }, { "kind": "interface", @@ -174765,7 +174702,7 @@ } } ], - "specLocation": "query_rules/_types/QueryRuleset.ts#L27-L36" + "specLocation": "query_rules/_types/QueryRuleset.ts#L25-L34" }, { "attachedBehaviors": [ @@ -177215,7 +177152,7 @@ "type": { "kind": "instance_of", "type": { - "name": "InlineScript", + "name": "Script", "namespace": "_types" } } @@ -178746,7 +178683,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L329-L331" + "specLocation": "security/_types/Privileges.ts#L340-L342" }, { "kind": "interface", @@ -178798,7 +178735,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L26-L39" + "specLocation": "security/_types/Privileges.ts#L27-L40" }, { "kind": "interface", @@ -179142,7 +179079,7 @@ "name": "ClusterPrivilege", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L41-L194" + "specLocation": "security/_types/Privileges.ts#L42-L195" }, { "kind": "interface", @@ -179263,7 +179200,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L325-L327" + "specLocation": "security/_types/Privileges.ts#L336-L338" }, { "kind": "enum", @@ -179376,7 +179313,7 @@ "name": "IndexPrivilege", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L281-L323" + "specLocation": "security/_types/Privileges.ts#L292-L334" }, { "kind": "interface", @@ -179455,7 +179392,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L196-L220" + "specLocation": "security/_types/Privileges.ts#L197-L221" }, { "codegenNames": [ @@ -179469,7 +179406,7 @@ "name": "IndicesPrivilegesQuery", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L246-L254", + "specLocation": "security/_types/Privileges.ts#L247-L255", "type": { "items": [ { @@ -179519,7 +179456,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L333-L335" + "specLocation": "security/_types/Privileges.ts#L344-L346" }, { "kind": "interface", @@ -180043,7 +179980,7 @@ "name": "RoleTemplateInlineQuery", "namespace": "security._types" }, - "specLocation": "security/_types/Privileges.ts#L275-L276", + "specLocation": "security/_types/Privileges.ts#L289-L290", "type": { "items": [ { @@ -180065,31 +180002,62 @@ } }, { - "inherits": { - "type": { - "name": "ScriptBase", - "namespace": "_types" - } + "kind": "interface", + "name": { + "name": "RoleTemplateQuery", + "namespace": "security._types" }, + "properties": [ + { + "description": "When you create a role, you can specify a query that defines the document level security permissions. You can optionally\nuse Mustache templates in the role query to insert the username of the current authenticated user into the role.\nLike other places in Elasticsearch that support templating or scripting, you can specify inline, stored, or file-based\ntemplates and define custom parameters. You access the details for the current authenticated user through the _user parameter.", + "docId": "templating-role-query", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/field-and-document-access-control.html#templating-role-query", + "name": "template", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "RoleTemplateScript", + "namespace": "security._types" + } + } + } + ], + "specLocation": "security/_types/Privileges.ts#L257-L267" + }, + { "kind": "interface", "name": { - "name": "RoleTemplateInlineScript", + "name": "RoleTemplateScript", "namespace": "security._types" }, "properties": [ { - "name": "lang", + "name": "source", "required": false, "type": { "kind": "instance_of", "type": { - "name": "ScriptLanguage", + "name": "RoleTemplateInlineQuery", + "namespace": "security._types" + } + } + }, + { + "description": "The `id` for a stored script.", + "name": "id", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", "namespace": "_types" } } }, { - "name": "options", + "description": "Specifies any named parameters that are passed into the script as variables.\nUse parameters instead of hard-coded values to decrease compile time.", + "name": "params", "required": false, "type": { "key": { @@ -180102,83 +180070,48 @@ "kind": "dictionary_of", "singleKey": false, "value": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } + "kind": "user_defined_value" } } }, { - "name": "source", - "required": true, + "description": "Specifies the language the script is written in.", + "name": "lang", + "required": false, + "serverDefault": "painless", "type": { "kind": "instance_of", "type": { - "name": "RoleTemplateInlineQuery", - "namespace": "security._types" + "name": "ScriptLanguage", + "namespace": "_types" } } - } - ], - "shortcutProperty": "source", - "specLocation": "security/_types/Privileges.ts#L268-L273" - }, - { - "kind": "interface", - "name": { - "name": "RoleTemplateQuery", - "namespace": "security._types" - }, - "properties": [ + }, { - "description": "When you create a role, you can specify a query that defines the document level security permissions. You can optionally\nuse Mustache templates in the role query to insert the username of the current authenticated user into the role.\nLike other places in Elasticsearch that support templating or scripting, you can specify inline, stored, or file-based\ntemplates and define custom parameters. You access the details for the current authenticated user through the _user parameter.", - "docId": "templating-role-query", - "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/field-and-document-access-control.html#templating-role-query", - "name": "template", + "name": "options", "required": false, "type": { - "kind": "instance_of", - "type": { - "name": "RoleTemplateScript", - "namespace": "security._types" + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + }, + "kind": "dictionary_of", + "singleKey": false, + "value": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } } } } ], - "specLocation": "security/_types/Privileges.ts#L256-L266" - }, - { - "codegenNames": [ - "inline", - "stored" - ], - "kind": "type_alias", - "name": { - "name": "RoleTemplateScript", - "namespace": "security._types" - }, - "specLocation": "security/_types/Privileges.ts#L278-L279", - "type": { - "items": [ - { - "kind": "instance_of", - "type": { - "name": "RoleTemplateInlineScript", - "namespace": "security._types" - } - }, - { - "kind": "instance_of", - "type": { - "name": "StoredScriptId", - "namespace": "_types" - } - } - ], - "kind": "union_of" - } + "shortcutProperty": "source", + "specLocation": "security/_types/Privileges.ts#L269-L287" }, { "kind": "enum", @@ -180389,7 +180322,7 @@ } } ], - "specLocation": "security/_types/Privileges.ts#L222-L244" + "specLocation": "security/_types/Privileges.ts#L223-L245" }, { "kind": "interface", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 02959e3e27..7fab2f84d4 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -84,7 +84,7 @@ export interface BulkUpdateAction detect_noop?: boolean doc?: TPartialDocument doc_as_upsert?: boolean - script?: Script + script?: Script | string scripted_upsert?: boolean _source?: SearchSourceConfig upsert?: TDocument @@ -1983,7 +1983,7 @@ export interface UpdateByQueryRequest extends RequestBase { body?: { max_docs?: long query?: QueryDslQueryContainer - script?: Script + script?: Script | string slice?: SlicedScroll conflicts?: Conflicts } @@ -2353,12 +2353,6 @@ export interface InlineGetKeys { export type InlineGet = InlineGetKeys & { [property: string]: any } -export interface InlineScript extends ScriptBase { - lang?: ScriptLanguage - options?: Record - source: string -} - export type Ip = string export interface KnnQuery extends QueryDslQueryBase { @@ -2601,14 +2595,16 @@ export interface ScoreSort { order?: SortOrder } -export type Script = InlineScript | string | StoredScriptId - -export interface ScriptBase { +export interface Script { + source?: string + id?: Id params?: Record + lang?: ScriptLanguage + options?: Record } export interface ScriptField { - script: Script + script: Script | string ignore_failure?: boolean } @@ -2616,7 +2612,7 @@ export type ScriptLanguage = 'painless' | 'expression' | 'mustache' | 'java'| st export interface ScriptSort { order?: SortOrder - script: Script + script: Script | string type?: ScriptSortType mode?: SortMode nested?: NestedSortValue @@ -2767,10 +2763,6 @@ export interface StoredScript { source: string } -export interface StoredScriptId extends ScriptBase { - id: Id -} - export type SuggestMode = 'missing' | 'popular' | 'always' export type SuggestionName = string @@ -3019,7 +3011,7 @@ export interface AggregationsAutoDateHistogramAggregation extends AggregationsBu missing?: DateTime offset?: string params?: Record - script?: Script + script?: Script | string time_zone?: TimeZone } @@ -3089,11 +3081,11 @@ export interface AggregationsBucketPathAggregation { } export interface AggregationsBucketScriptAggregation extends AggregationsPipelineAggregationBase { - script?: Script + script?: Script | string } export interface AggregationsBucketSelectorAggregation extends AggregationsPipelineAggregationBase { - script?: Script + script?: Script | string } export interface AggregationsBucketSortAggregation { @@ -3166,7 +3158,7 @@ export interface AggregationsCompositeAggregationBase { field?: Field missing_bucket?: boolean missing_order?: AggregationsMissingOrder - script?: Script + script?: Script | string value_type?: AggregationsValueType order?: SortOrder } @@ -3237,7 +3229,7 @@ export interface AggregationsDateHistogramAggregation extends AggregationsBucket offset?: Duration order?: AggregationsAggregateOrder params?: Record - script?: Script + script?: Script | string time_zone?: TimeZone keyed?: boolean } @@ -3278,7 +3270,7 @@ export interface AggregationsDerivativeAggregation extends AggregationsPipelineA export interface AggregationsDiversifiedSamplerAggregation extends AggregationsBucketAggregationBase { execution_hint?: AggregationsSamplerAggregationExecutionHint max_docs_per_value?: integer - script?: Script + script?: Script | string shard_size?: integer field?: Field } @@ -3527,7 +3519,7 @@ export interface AggregationsHistogramAggregation extends AggregationsBucketAggr missing?: double offset?: double order?: AggregationsAggregateOrder - script?: Script + script?: Script | string format?: string keyed?: boolean } @@ -3715,7 +3707,7 @@ export interface AggregationsMedianAbsoluteDeviationAggregation extends Aggregat export interface AggregationsMetricAggregationBase { field?: Field missing?: AggregationsMissing - script?: Script + script?: Script | string } export interface AggregationsMinAggregate extends AggregationsSingleMetricAggregateBase { @@ -3870,7 +3862,7 @@ export interface AggregationsRangeAggregation extends AggregationsBucketAggregat field?: Field missing?: integer ranges?: AggregationsAggregationRange[] - script?: Script + script?: Script | string keyed?: boolean format?: string } @@ -3928,7 +3920,7 @@ export interface AggregationsSamplerAggregation extends AggregationsBucketAggreg export type AggregationsSamplerAggregationExecutionHint = 'map' | 'global_ordinals' | 'bytes_hash' export interface AggregationsScriptedHeuristic { - script: Script + script: Script | string } export interface AggregationsScriptedMetricAggregate extends AggregationsAggregateBase { @@ -3936,11 +3928,11 @@ export interface AggregationsScriptedMetricAggregate extends AggregationsAggrega } export interface AggregationsScriptedMetricAggregation extends AggregationsMetricAggregationBase { - combine_script?: Script - init_script?: Script - map_script?: Script + combine_script?: Script | string + init_script?: Script | string + map_script?: Script | string params?: Record - reduce_script?: Script + reduce_script?: Script | string } export interface AggregationsSerialDifferencingAggregation extends AggregationsPipelineAggregationBase { @@ -4153,7 +4145,7 @@ export interface AggregationsTermsAggregation extends AggregationsBucketAggregat missing_bucket?: boolean value_type?: string order?: AggregationsAggregateOrder - script?: Script + script?: Script | string shard_min_doc_count?: long shard_size?: integer show_term_doc_count_error?: boolean @@ -4180,7 +4172,7 @@ export interface AggregationsTermsPartition { export interface AggregationsTestPopulation { field: Field - script?: Script + script?: Script | string filter?: QueryDslQueryContainer } @@ -4253,7 +4245,7 @@ export interface AggregationsVariableWidthHistogramAggregation { buckets?: integer shard_size?: integer initial_buffer?: integer - script?: Script + script?: Script | string } export interface AggregationsVariableWidthHistogramBucketKeys extends AggregationsMultiBucketBase { @@ -4277,7 +4269,7 @@ export interface AggregationsWeightedAverageAggregation { export interface AggregationsWeightedAverageValue { field?: Field missing?: double - script?: Script + script?: Script | string } export interface AggregationsWeightedAvgAggregate extends AggregationsSingleMetricAggregateBase { @@ -4325,7 +4317,7 @@ export interface AnalysisCompoundWordTokenFilterBase extends AnalysisTokenFilter export interface AnalysisConditionTokenFilter extends AnalysisTokenFilterBase { type: 'condition' filter: string[] - script: Script + script: Script | string } export interface AnalysisCustomAnalyzer { @@ -4720,7 +4712,7 @@ export interface AnalysisPorterStemTokenFilter extends AnalysisTokenFilterBase { export interface AnalysisPredicateTokenFilter extends AnalysisTokenFilterBase { type: 'predicate_token_filter' - script: Script + script: Script | string } export interface AnalysisRemoveDuplicatesTokenFilter extends AnalysisTokenFilterBase { @@ -5038,7 +5030,7 @@ export interface MappingDynamicProperty extends MappingDocValuesPropertyBase { null_value?: FieldValue boost?: double coerce?: boolean - script?: Script + script?: Script | string on_script_error?: MappingOnScriptError ignore_malformed?: boolean time_series_metric?: MappingTimeSeriesMetricType @@ -5116,7 +5108,7 @@ export interface MappingGeoPointProperty extends MappingDocValuesPropertyBase { null_value?: GeoLocation index?: boolean on_script_error?: MappingOnScriptError - script?: Script + script?: Script | string type: 'geo_point' } @@ -5182,7 +5174,7 @@ export interface MappingIpProperty extends MappingDocValuesPropertyBase { ignore_malformed?: boolean null_value?: string on_script_error?: MappingOnScriptError - script?: Script + script?: Script | string time_series_dimension?: boolean type: 'ip' } @@ -5202,7 +5194,7 @@ export interface MappingKeywordProperty extends MappingDocValuesPropertyBase { eager_global_ordinals?: boolean index?: boolean index_options?: MappingIndexOptions - script?: Script + script?: Script | string on_script_error?: MappingOnScriptError normalizer?: string norms?: boolean @@ -5247,7 +5239,7 @@ export interface MappingNumberPropertyBase extends MappingDocValuesPropertyBase ignore_malformed?: boolean index?: boolean on_script_error?: MappingOnScriptError - script?: Script + script?: Script | string time_series_metric?: MappingTimeSeriesMetricType time_series_dimension?: boolean } @@ -5307,7 +5299,7 @@ export interface MappingRuntimeField { input_field?: Field target_field?: Field target_index?: IndexName - script?: Script + script?: Script | string type: MappingRuntimeFieldType } @@ -5697,7 +5689,7 @@ export interface QueryDslIntervalsFilter { not_containing?: QueryDslIntervalsContainer not_overlapping?: QueryDslIntervalsContainer overlapping?: QueryDslIntervalsContainer - script?: Script + script?: Script | string } export interface QueryDslIntervalsFuzzy { @@ -6056,17 +6048,17 @@ export interface QueryDslRuleQuery extends QueryDslQueryBase { } export interface QueryDslScriptQuery extends QueryDslQueryBase { - script: Script + script: Script | string } export interface QueryDslScriptScoreFunction { - script: Script + script: Script | string } export interface QueryDslScriptScoreQuery extends QueryDslQueryBase { min_score?: float query: QueryDslQueryContainer - script: Script + script: Script | string } export interface QueryDslSemanticQuery extends QueryDslQueryBase { @@ -6200,7 +6192,7 @@ export type QueryDslTermsQueryField = FieldValue[] | QueryDslTermsLookup export interface QueryDslTermsSetQuery extends QueryDslQueryBase { minimum_should_match_field?: Field - minimum_should_match_script?: Script + minimum_should_match_script?: Script | string terms: string[] } @@ -10747,8 +10739,8 @@ export interface IndicesSettingsSimilarityLmj { export interface IndicesSettingsSimilarityScripted { type: 'scripted' - script: Script - weight_script?: Script + script: Script | string + weight_script?: Script | string } export interface IndicesSlowlogSettings { @@ -16682,7 +16674,7 @@ export interface SearchApplicationSearchApplication { } export interface SearchApplicationSearchApplicationTemplate { - script: InlineScript | string + script: Script | string } export interface SearchApplicationDeleteRequest extends RequestBase { @@ -16948,22 +16940,22 @@ export interface SecurityRoleMappingRule { export interface SecurityRoleTemplate { format?: SecurityTemplateFormat - template: Script + template: Script | string } export type SecurityRoleTemplateInlineQuery = string | QueryDslQueryContainer -export interface SecurityRoleTemplateInlineScript extends ScriptBase { - lang?: ScriptLanguage - options?: Record - source: SecurityRoleTemplateInlineQuery -} - export interface SecurityRoleTemplateQuery { - template?: SecurityRoleTemplateScript + template?: SecurityRoleTemplateScript | SecurityRoleTemplateInlineQuery } -export type SecurityRoleTemplateScript = SecurityRoleTemplateInlineScript | SecurityRoleTemplateInlineQuery | StoredScriptId +export interface SecurityRoleTemplateScript { + source?: SecurityRoleTemplateInlineQuery + id?: Id + params?: Record + lang?: ScriptLanguage + options?: Record +} export type SecurityTemplateFormat = 'string' | 'json' diff --git a/specification/_global/scripts_painless_execute/ExecutePainlessScriptRequest.ts b/specification/_global/scripts_painless_execute/ExecutePainlessScriptRequest.ts index eafd1613d2..1442f08875 100644 --- a/specification/_global/scripts_painless_execute/ExecutePainlessScriptRequest.ts +++ b/specification/_global/scripts_painless_execute/ExecutePainlessScriptRequest.ts @@ -18,7 +18,7 @@ */ import { RequestBase } from '@_types/Base' -import { InlineScript } from '@_types/Scripting' +import { Script } from '@_types/Scripting' import { PainlessContextSetup } from './types' /** @@ -41,6 +41,6 @@ export interface Request extends RequestBase { /** * The Painless script to execute. */ - script?: InlineScript + script?: Script } } diff --git a/specification/_types/Scripting.ts b/specification/_types/Scripting.ts index 51d18334e2..8532f867f4 100644 --- a/specification/_types/Scripting.ts +++ b/specification/_types/Scripting.ts @@ -62,31 +62,39 @@ export class ScriptBase { * Use parameters instead of hard-coded values to decrease compile time. */ params?: Dictionary -} - -/** @shortcut_property source */ -export class InlineScript extends ScriptBase { /** * Specifies the language the script is written in. * @server_default painless */ lang?: ScriptLanguage options?: Dictionary +} + +/** + * @shortcut_property source + * */ +export class Script { /** * The script source. */ - source: string -} - -export class StoredScriptId extends ScriptBase { + source?: string /** * The `id` for a stored script. */ - id: Id -} + id?: Id -/** @codegen_names inline, stored */ -export type Script = InlineScript | StoredScriptId + /** + * Specifies any named parameters that are passed into the script as variables. + * Use parameters instead of hard-coded values to decrease compile time. + */ + params?: Dictionary + /** + * Specifies the language the script is written in. + * @server_default painless + */ + lang?: ScriptLanguage + options?: Dictionary +} export class ScriptField { script: Script diff --git a/specification/query_rules/_types/QueryRuleset.ts b/specification/query_rules/_types/QueryRuleset.ts index f8d31dc132..0f00fd1b70 100644 --- a/specification/query_rules/_types/QueryRuleset.ts +++ b/specification/query_rules/_types/QueryRuleset.ts @@ -17,10 +17,8 @@ * under the License. */ -import { Id, IndexName, Name } from '@_types/common' +import { Id } 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' import { PinnedDoc } from '../../_types/query_dsl/specialized' diff --git a/specification/search_application/_types/SearchApplication.ts b/specification/search_application/_types/SearchApplication.ts index 44dc42b0c6..d40f01f4e9 100644 --- a/specification/search_application/_types/SearchApplication.ts +++ b/specification/search_application/_types/SearchApplication.ts @@ -19,7 +19,7 @@ import { IndexName, Name } from '@_types/common' import { EpochTime, UnitMillis } from '@_types/Time' -import { InlineScript } from '@_types/Scripting' +import { Script } from '@_types/Scripting' export class SearchApplication { /** @@ -48,5 +48,5 @@ export class SearchApplicationTemplate { /** * The associated mustache template. */ - script: InlineScript + script: Script } diff --git a/specification/security/_types/Privileges.ts b/specification/security/_types/Privileges.ts index e3efe63f33..289615d6d1 100644 --- a/specification/security/_types/Privileges.ts +++ b/specification/security/_types/Privileges.ts @@ -18,10 +18,11 @@ */ import { Dictionary } from '@spec_utils/Dictionary' -import { Indices } from '@_types/common' +import { Id, Indices } from '@_types/common' import { QueryContainer } from '@_types/query_dsl/abstractions' import { FieldSecurity } from './FieldSecurity' -import { ScriptLanguage, ScriptBase, StoredScriptId } from '@_types/Scripting' +import { ScriptLanguage, ScriptBase, Script } from '@_types/Scripting' +import { UserDefinedValue } from '@spec_utils/UserDefinedValue' export class ApplicationPrivileges { /** @@ -266,18 +267,28 @@ export class RoleTemplateQuery { } /** @shortcut_property source */ -export class RoleTemplateInlineScript extends ScriptBase { +export class RoleTemplateScript { + source?: RoleTemplateInlineQuery + /** + * The `id` for a stored script. + */ + id?: Id + /** + * Specifies any named parameters that are passed into the script as variables. + * Use parameters instead of hard-coded values to decrease compile time. + */ + params?: Dictionary + /** + * Specifies the language the script is written in. + * @server_default painless + */ lang?: ScriptLanguage options?: Dictionary - source: RoleTemplateInlineQuery } /** @codegen_names query_string, query_object */ export type RoleTemplateInlineQuery = string | QueryContainer -/** @codegen_names inline, stored */ -export type RoleTemplateScript = RoleTemplateInlineScript | StoredScriptId - /** @non_exhaustive */ export enum IndexPrivilege { all,