import { MDXLDDocument } from './types.js'; /** * MDXLD Type Generation * * Generate TypeScript type definitions from MDXLD documents. * Scans frontmatter to infer types and creates .d.ts files. * * @packageDocumentation */ /** * TypeScript type representation */ type TSType = 'string' | 'number' | 'boolean' | 'null' | 'undefined' | 'unknown' | 'string[]' | 'number[]' | 'boolean[]' | 'unknown[]' | { kind: 'object'; properties: Record; } | { kind: 'union'; types: TSType[]; } | { kind: 'array'; items: TSType; }; /** * Inferred field with type and metadata */ interface InferredField { name: string; type: TSType; optional: boolean; description?: string; } /** * Inferred schema for a document type */ interface InferredSchema { name: string; fields: InferredField[]; description?: string; } /** * Options for type generation */ interface TypegenOptions { /** Include JSDoc comments */ jsdoc?: boolean; /** Export format: 'interface' | 'type' */ format?: 'interface' | 'type'; /** Base interface to extend */ extends?: string; /** Add index signature for additional properties */ indexSignature?: boolean; } /** * Infer TypeScript type from a JavaScript value */ declare function inferType(value: unknown): TSType; /** * Merge two types into a union or combined type */ declare function mergeTypes(a: TSType, b: TSType): TSType; /** * Convert TSType to TypeScript string */ declare function typeToString(type: TSType): string; /** * Infer schema from a single document */ declare function inferSchemaFromDocument(doc: MDXLDDocument): InferredSchema; /** * Merge multiple schemas of the same type */ declare function mergeSchemas(schemas: InferredSchema[]): InferredSchema; /** * Generate TypeScript interface from schema */ declare function generateInterface(schema: InferredSchema, options?: TypegenOptions): string; /** * Generate TypeScript types from multiple documents */ declare function generateTypes(docs: MDXLDDocument[], options?: TypegenOptions): string; export { type InferredField, type InferredSchema, type TSType, type TypegenOptions, generateInterface, generateTypes, inferSchemaFromDocument, inferType, mergeSchemas, mergeTypes, typeToString };