UNPKG

selvedge

Version:

A type-safe, declarative DSL for building robust, composable LLM prompts and programs in TypeScript. Selvedge simplifies prompt engineering, structured output, and multi-model orchestration.

43 lines 1.32 kB
/** * Schema inference utilities for TypeScript types * * This module provides functions to infer Zod schemas from TypeScript types. * Since TypeScript types are erased at runtime, this uses a best-effort approach * based on property names and patterns. */ import * as z from 'zod'; /** * Infer a Zod schema from a TypeScript type * * @param typeHint - Optional type hint to help with inference * @returns A Zod schema that approximates the TypeScript type */ export declare function inferSchema<T>(typeHint?: string): z.ZodType<T>; /** * Infer a schema from an object structure * * @param obj - The object to infer a schema from * @returns A Zod schema that matches the object structure */ export declare function inferSchemaFromObject(obj: Record<string, any>): z.ZodType<any>; /** * Create a schema from a TypeScript interface * * This is a helper function for creating schemas from interfaces. * It's used when we can't infer the schema automatically. * * @example * ```ts * interface User { * name: string; * age: number; * } * * const UserSchema = createSchema<User>({ * name: z.string(), * age: z.number() * }); * ``` */ export declare function createSchema<T>(shape: Record<string, z.ZodType<any>>): z.ZodObject<any, any, any, T>; //# sourceMappingURL=inference.d.ts.map