UNPKG

@mastra/schema-compat

Version:

Tool schema compatibility layer for Mastra.ai

30 lines 1.61 kB
import type { JSONSchema7 } from './_types/@types_json-schema/index.d.ts'; import type { Targets } from 'zod-to-json-schema'; /** * Recursively patch Zod v4 record schemas that are missing valueType. * This fixes a bug in Zod v4 where z.record(valueSchema) doesn't set def.valueType. * The single-arg form should set valueType but instead only sets keyType. * * Idempotent — marks patched schemas with a Symbol so repeat calls no-op. * * @internal Exported so the Zod v4 standard-schema adapter can apply the * same patch before its native `toJSONSchema` call (the legacy `zodToJsonSchema` * entry already calls it; the `applyCompatLayer` path otherwise wouldn't). * Not part of the public API. */ export declare function patchRecordSchemas(schema: any): any; /** * Recursively ensures all properties in an object schema are included in the `required` array. * OpenAI's strict structured output mode requires every key in `properties` to also appear in `required`. * * @param schema - The JSON Schema to process * @returns A new schema with all properties marked as required */ export declare function ensureAllPropertiesRequired(schema: JSONSchema7): JSONSchema7; /** * Prepare a JSON Schema for OpenAI strict mode by ensuring all object properties * are required and all objects have additionalProperties: false. */ export declare function prepareJsonSchemaForOpenAIStrictMode(schema: JSONSchema7): JSONSchema7; export declare function zodToJsonSchema(zodSchema: any, target?: Targets, strategy?: 'none' | 'seen' | 'root' | 'relative'): JSONSchema7; //# sourceMappingURL=zod-to-json.d.ts.map