UNPKG

@mastra/schema-compat

Version:

Tool schema compatibility layer for Mastra.ai

29 lines 1.26 kB
import type { StandardSchemaV1 } from '../../_types/@standard-schema_spec/dist/index.d.ts'; import type { StandardSchemaWithJSON } from '../standard-schema.types.js'; /** * Options for the Zod v4 adapter's JSON Schema conversion. */ export interface ZodV4AdapterOptions { unrepresentable?: 'any' | 'error'; override?: (ctx: { zodSchema: unknown; jsonSchema: Record<string, unknown>; }) => undefined; } /** * Wraps a Zod v4 schema to implement the full @standard-schema/spec interface. * * Zod v4 schemas (and Zod 3.25's v4 compat layer) implement `StandardSchemaV1` * (validation) but may not implement `StandardJSONSchemaV1` (JSON Schema conversion) * on the `~standard` property. This adapter adds the `jsonSchema` property using * `z.toJSONSchema()` to provide JSON Schema conversion capabilities. * * @param zodSchema - A Zod v4 schema (has `_zod` property) * @param adapterOptions - Options passed to z.toJSONSchema() * @returns The schema wrapped with StandardSchemaWithJSON support */ export declare function toStandardSchema<T>(zodSchema: T & { _zod: unknown; '~standard': StandardSchemaV1.Props; }, adapterOptions?: ZodV4AdapterOptions): T & StandardSchemaWithJSON; //# sourceMappingURL=zod-v4.d.ts.map