import type { ResponseFormat } from '../types'; export interface JsonSchemaProperty { type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null'; description?: string; enum?: any[]; items?: JsonSchemaProperty; properties?: Record; required?: string[]; additionalProperties?: boolean; minLength?: number; maxLength?: number; minimum?: number; maximum?: number; pattern?: string; default?: any; } export interface JsonSchemaConfig { name: string; description?: string; properties: Record; required: string[]; strict?: boolean; additionalProperties?: boolean; } /** * Utility class for building JSON Schema response formats for structured outputs. * Provides a fluent API to create schemas with less boilerplate. * * @example * ```typescript * import { SchemaBuilder } from 'openrouter-kit'; * * const schema = SchemaBuilder.createJsonSchema({ * name: 'user_profile', * properties: { * name: SchemaBuilder.string({ description: 'Full name' }), * age: SchemaBuilder.integer({ minimum: 0, maximum: 150 }) * }, * required: ['name'] * }); * * const result = await client.chat({ * model: 'openai/gpt-4o', * prompt: 'Extract user info', * responseFormat: schema * }); * ``` */ export declare class SchemaBuilder { /** * Creates a ResponseFormat for structured outputs with JSON Schema. * Uses strict mode by default to ensure exact schema adherence. * * @param config - Schema configuration object * @returns ResponseFormat object ready to use in chat requests * * @example * ```typescript * const format = SchemaBuilder.createJsonSchema({ * name: 'weather_data', * description: 'Weather information', * properties: { * location: { type: 'string', description: 'City name' }, * temperature: { type: 'number', description: 'Temperature in Celsius' } * }, * required: ['location', 'temperature'] * }); * ``` */ static createJsonSchema(config: JsonSchemaConfig): ResponseFormat; /** * Creates a simple JSON Object format without strict schema validation. * The model will return valid JSON, but structure is not enforced. * * @returns ResponseFormat object for json_object mode * * @example * ```typescript * const format = SchemaBuilder.createJsonObject(); * ``` */ static createJsonObject(): ResponseFormat; /** * Helper for creating an array property with item schema. * * @param items - Schema for array items * @param description - Optional description of the array * @returns JsonSchemaProperty for an array type * * @example * ```typescript * const tags = SchemaBuilder.array( * SchemaBuilder.string({ description: 'Tag name' }), * 'List of tags' * ); * ``` */ static array(items: JsonSchemaProperty, description?: string): JsonSchemaProperty; /** * Helper for creating an enum property with allowed values. * Automatically infers type from first value. * * @param values - Array of allowed values * @param description - Optional description * @returns JsonSchemaProperty with enum constraint * * @example * ```typescript * const status = SchemaBuilder.enum(['active', 'inactive', 'pending'], 'User status'); * ``` */ static enum(values: any[], description?: string): JsonSchemaProperty; /** * Helper for creating a nested object property. * * @param properties - Object properties schema * @param required - Array of required property names * @param description - Optional description * @returns JsonSchemaProperty for an object type * * @example * ```typescript * const address = SchemaBuilder.object({ * street: SchemaBuilder.string(), * city: SchemaBuilder.string(), * zipCode: SchemaBuilder.string({ pattern: '^\\d{5}$' }) * }, ['city'], 'User address'); * ``` */ static object(properties: Record, required?: string[], description?: string): JsonSchemaProperty; /** * Helper for creating a string property with optional constraints. * * @param options - String constraints (length, pattern, enum) * @returns JsonSchemaProperty for a string type * * @example * ```typescript * const email = SchemaBuilder.string({ * description: 'Email address', * pattern: '^[^@]+@[^@]+\\.[^@]+$' * }); * ``` */ static string(options?: { description?: string; minLength?: number; maxLength?: number; pattern?: string; enum?: string[]; }): JsonSchemaProperty; /** * Helper for creating a number property with optional constraints. * * @param options - Number constraints (min, max) * @returns JsonSchemaProperty for a number type * * @example * ```typescript * const temperature = SchemaBuilder.number({ * description: 'Temperature in Celsius', * minimum: -273.15 * }); * ``` */ static number(options?: { description?: string; minimum?: number; maximum?: number; }): JsonSchemaProperty; /** * Helper for creating an integer property with optional constraints. * * @param options - Integer constraints (min, max) * @returns JsonSchemaProperty for an integer type * * @example * ```typescript * const age = SchemaBuilder.integer({ * description: 'Age in years', * minimum: 0, * maximum: 150 * }); * ``` */ static integer(options?: { description?: string; minimum?: number; maximum?: number; }): JsonSchemaProperty; /** * Helper for creating a boolean property. * * @param description - Optional description * @returns JsonSchemaProperty for a boolean type * * @example * ```typescript * const active = SchemaBuilder.boolean('Is user active'); * ``` */ static boolean(description?: string): JsonSchemaProperty; }