/** * Zod schema introspection utilities. * * Generic helpers for walking, unwrapping, and extracting metadata from Zod schemas. * Used by CLI argument parsing, adversarial input testing, and surface generation. * * @module */ import type { z } from 'zod'; /** * Unwrap nested schema types (optional, default, nullable, etc). * * @returns inner schema if wrapped, undefined otherwise */ export declare const zod_to_subschema: (def: z.core.$ZodTypeDef) => z.ZodType | undefined; /** Zod wrapper type names that `zod_unwrap_def` traverses through. */ export declare const ZOD_WRAPPER_TYPES: Set; /** * Unwrap Zod wrappers (optional, default, nullable, pipe, transform) * to get the base type definition. * * @returns the innermost non-wrapper type definition */ export declare const zod_unwrap_def: (schema: z.ZodType) => z.core.$ZodTypeDef; /** * Get the base type name for a Zod schema, unwrapping all wrappers. * * @returns base type name (e.g. `'string'`, `'object'`, `'uuid'`) */ export declare const zod_get_base_type: (schema: z.ZodType) => string; /** * Check if a schema is optional at the outermost level. */ export declare const zod_is_optional: (schema: z.ZodType) => boolean; /** * Check if a schema accepts null at any wrapping level. */ export declare const zod_is_nullable: (schema: z.ZodType) => boolean; /** * Check if a schema has a default value at any wrapping level. * * Unlike `zod_to_schema_default` (which returns the value), this returns a boolean. * Distinguishes "no default" from "default is undefined". */ export declare const zod_has_default: (schema: z.ZodType) => boolean; /** * Unwrap a schema through every wrapper type (optional, nullable, default, * transform, pipe, prefault) to reach the innermost schema. Like `zod_unwrap_def` * but returns the schema (so callers can `.shape`, `instanceof`-check, etc.) * instead of the def. * * @returns the innermost non-wrapper schema */ export declare const zod_get_innermost_type: (schema: z.ZodType) => z.ZodType; /** * Get all property keys from an object schema, unwrapping wrappers. * Returns an empty array if the innermost type is not an object. * * @param schema - Zod schema (typically a `ZodObject` with possible wrappers) */ export declare const zod_get_schema_keys: (schema: T) => Array & string>; /** * Get the field schema for a key in an object schema, returning `undefined` if * the schema is not an object or the key is missing. * * @param schema - Zod schema (typically a `ZodObject` with possible wrappers) * @param key - the property name * @returns the field's schema, or `undefined` */ export declare const zod_maybe_get_field_schema: (schema: z.ZodType, key: string) => z.ZodType | undefined; /** * Get the field schema for a key in an object schema. * * @param schema - Zod schema (typically a `ZodObject` with possible wrappers) * @throws Error if the schema is not an object or the key is missing */ export declare const zod_get_field_schema: (schema: z.ZodType, key: string) => z.ZodType; /** * Unwrap a schema to find the inner `ZodObject`, or `null` if not an object schema. * Handles wrappers like `z.strictObject({...}).default({...})`. */ export declare const zod_unwrap_to_object: (schema: z.ZodType) => z.ZodObject | null; /** Metadata extracted from a single field of a Zod object schema. */ export interface ZodFieldInfo { name: string; base_type: string; required: boolean; has_default: boolean; nullable: boolean; } /** * Extract field metadata from a Zod object schema. */ export declare const zod_extract_fields: (schema: z.ZodObject) => Array; /** * Get the description from a schema's metadata, unwrapping if needed. * * @returns description string or null if not found */ export declare const zod_to_schema_description: (schema: z.ZodType) => string | null; /** * Get the default value from a schema, unwrapping if needed. * * @returns default value or undefined */ export declare const zod_to_schema_default: (schema: z.ZodType) => unknown; /** * Get aliases from a schema's metadata, unwrapping if needed. */ export declare const zod_to_schema_aliases: (schema: z.ZodType) => Array; /** * Get the type string for a schema, suitable for display. * * @returns human-readable type string */ export declare const zod_to_schema_type_string: (schema: z.ZodType) => string; /** * Format a value for display in help text. */ export declare const zod_format_value: (value: unknown) => string; /** * Property extracted from an object schema. */ export interface ZodSchemaProperty { name: string; type: string; description: string; default: unknown; aliases: Array; } /** * Extract properties from a Zod object schema. */ export declare const zod_to_schema_properties: (schema: z.ZodType) => Array; /** * Get all property names and their aliases from an object schema. */ export declare const zod_to_schema_names_with_aliases: (schema: z.ZodType) => Set; //# sourceMappingURL=zod.d.ts.map