From b094491cf58b26e772ba8e34f7122f107125c50a Mon Sep 17 00:00:00 2001 From: vignesh07 Date: Thu, 12 Feb 2026 00:44:10 -0800 Subject: [PATCH] fix(config): restore schema.ts schema helper types after hints refactor --- src/config/schema.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/config/schema.ts b/src/config/schema.ts index 6d2429bfa3d..1300673b270 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -10,6 +10,58 @@ export type ConfigSchema = ReturnType; type JsonSchemaNode = Record; +type JsonSchemaObject = JsonSchemaNode & { + type?: string | string[]; + properties?: Record; + required?: string[]; + additionalProperties?: JsonSchemaObject | boolean; +}; + +function cloneSchema(value: T): T { + if (typeof structuredClone === "function") { + return structuredClone(value); + } + return JSON.parse(JSON.stringify(value)) as T; +} + +function asSchemaObject(value: unknown): JsonSchemaObject | null { + if (!value || typeof value !== "object" || Array.isArray(value)) { + return null; + } + return value as JsonSchemaObject; +} + +function isObjectSchema(schema: JsonSchemaObject): boolean { + const type = schema.type; + if (type === "object") { + return true; + } + if (Array.isArray(type) && type.includes("object")) { + return true; + } + return Boolean(schema.properties || schema.additionalProperties); +} + +function mergeObjectSchema(base: JsonSchemaObject, extension: JsonSchemaObject): JsonSchemaObject { + const mergedRequired = new Set([...(base.required ?? []), ...(extension.required ?? [])]); + const merged: JsonSchemaObject = { + ...base, + ...extension, + properties: { + ...base.properties, + ...extension.properties, + }, + }; + if (mergedRequired.size > 0) { + merged.required = Array.from(mergedRequired); + } + const additional = extension.additionalProperties ?? base.additionalProperties; + if (additional !== undefined) { + merged.additionalProperties = additional; + } + return merged; +} + export type ConfigSchemaResponse = { schema: ConfigSchema; uiHints: ConfigUiHints;