Gateway: add path-scoped config schema lookup (#37266)

Merged via squash.

Prepared head SHA: 0c4d187f6f
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
Gustavo Madeira Santana
2026-03-06 02:50:48 -05:00
committed by GitHub
parent c5828cbc08
commit ff97195500
18 changed files with 633 additions and 7 deletions

View File

@@ -66,6 +66,10 @@ import {
ConfigGetParamsSchema,
type ConfigPatchParams,
ConfigPatchParamsSchema,
type ConfigSchemaLookupParams,
ConfigSchemaLookupParamsSchema,
type ConfigSchemaLookupResult,
ConfigSchemaLookupResultSchema,
type ConfigSchemaParams,
ConfigSchemaParamsSchema,
type ConfigSchemaResponse,
@@ -318,6 +322,12 @@ export const validateConfigSetParams = ajv.compile<ConfigSetParams>(ConfigSetPar
export const validateConfigApplyParams = ajv.compile<ConfigApplyParams>(ConfigApplyParamsSchema);
export const validateConfigPatchParams = ajv.compile<ConfigPatchParams>(ConfigPatchParamsSchema);
export const validateConfigSchemaParams = ajv.compile<ConfigSchemaParams>(ConfigSchemaParamsSchema);
export const validateConfigSchemaLookupParams = ajv.compile<ConfigSchemaLookupParams>(
ConfigSchemaLookupParamsSchema,
);
export const validateConfigSchemaLookupResult = ajv.compile<ConfigSchemaLookupResult>(
ConfigSchemaLookupResultSchema,
);
export const validateWizardStartParams = ajv.compile<WizardStartParams>(WizardStartParamsSchema);
export const validateWizardNextParams = ajv.compile<WizardNextParams>(WizardNextParamsSchema);
export const validateWizardCancelParams = ajv.compile<WizardCancelParams>(WizardCancelParamsSchema);
@@ -467,7 +477,9 @@ export {
ConfigApplyParamsSchema,
ConfigPatchParamsSchema,
ConfigSchemaParamsSchema,
ConfigSchemaLookupParamsSchema,
ConfigSchemaResponseSchema,
ConfigSchemaLookupResultSchema,
WizardStartParamsSchema,
WizardNextParamsSchema,
WizardCancelParamsSchema,

View File

@@ -1,6 +1,12 @@
import { Type } from "@sinclair/typebox";
import { NonEmptyString } from "./primitives.js";
const ConfigSchemaLookupPathString = Type.String({
minLength: 1,
maxLength: 1024,
pattern: "^[A-Za-z0-9_.\\[\\]\\-*]+$",
});
export const ConfigGetParamsSchema = Type.Object({}, { additionalProperties: false });
export const ConfigSetParamsSchema = Type.Object(
@@ -27,6 +33,13 @@ export const ConfigPatchParamsSchema = ConfigApplyLikeParamsSchema;
export const ConfigSchemaParamsSchema = Type.Object({}, { additionalProperties: false });
export const ConfigSchemaLookupParamsSchema = Type.Object(
{
path: ConfigSchemaLookupPathString,
},
{ additionalProperties: false },
);
export const UpdateRunParamsSchema = Type.Object(
{
sessionKey: Type.Optional(Type.String()),
@@ -61,3 +74,27 @@ export const ConfigSchemaResponseSchema = Type.Object(
},
{ additionalProperties: false },
);
export const ConfigSchemaLookupChildSchema = Type.Object(
{
key: NonEmptyString,
path: NonEmptyString,
type: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String())])),
required: Type.Boolean(),
hasChildren: Type.Boolean(),
hint: Type.Optional(ConfigUiHintSchema),
hintPath: Type.Optional(Type.String()),
},
{ additionalProperties: false },
);
export const ConfigSchemaLookupResultSchema = Type.Object(
{
path: NonEmptyString,
schema: Type.Unknown(),
hint: Type.Optional(ConfigUiHintSchema),
hintPath: Type.Optional(Type.String()),
children: Type.Array(ConfigSchemaLookupChildSchema),
},
{ additionalProperties: false },
);

View File

@@ -54,6 +54,8 @@ import {
ConfigApplyParamsSchema,
ConfigGetParamsSchema,
ConfigPatchParamsSchema,
ConfigSchemaLookupParamsSchema,
ConfigSchemaLookupResultSchema,
ConfigSchemaParamsSchema,
ConfigSchemaResponseSchema,
ConfigSetParamsSchema,
@@ -202,7 +204,9 @@ export const ProtocolSchemas = {
ConfigApplyParams: ConfigApplyParamsSchema,
ConfigPatchParams: ConfigPatchParamsSchema,
ConfigSchemaParams: ConfigSchemaParamsSchema,
ConfigSchemaLookupParams: ConfigSchemaLookupParamsSchema,
ConfigSchemaResponse: ConfigSchemaResponseSchema,
ConfigSchemaLookupResult: ConfigSchemaLookupResultSchema,
WizardStartParams: WizardStartParamsSchema,
WizardNextParams: WizardNextParamsSchema,
WizardCancelParams: WizardCancelParamsSchema,

View File

@@ -46,7 +46,9 @@ export type ConfigSetParams = SchemaType<"ConfigSetParams">;
export type ConfigApplyParams = SchemaType<"ConfigApplyParams">;
export type ConfigPatchParams = SchemaType<"ConfigPatchParams">;
export type ConfigSchemaParams = SchemaType<"ConfigSchemaParams">;
export type ConfigSchemaLookupParams = SchemaType<"ConfigSchemaLookupParams">;
export type ConfigSchemaResponse = SchemaType<"ConfigSchemaResponse">;
export type ConfigSchemaLookupResult = SchemaType<"ConfigSchemaLookupResult">;
export type WizardStartParams = SchemaType<"WizardStartParams">;
export type WizardNextParams = SchemaType<"WizardNextParams">;
export type WizardCancelParams = SchemaType<"WizardCancelParams">;