import { TSchema } from '@sinclair/typebox'; /** * Unified Document Schema Generator - SHARED UTILITY * * This is the SHARED implementation for generating document schemas. * It's used by MULTIPLE CONSUMERS with different requirements: * * 1. BUILD-TIME: generate-schemas.mjs uses this to create static .schema.json files * - Only standard components (no custom components available at build time) * - Outputs to filesystem for IDE autocomplete * * 2. RUNTIME PLUGIN: plugin/schema.ts uses this for plugin-enhanced schemas * - Includes custom components registered at runtime * - Cannot be generated at build time (components must be instantiated) * * 3. WEB APP: Monaco editor may use this for in-browser validation * - Optimized for browser environment * - No filesystem access * * This separation is ARCHITECTURAL, not accidental: * - Build-time vs runtime constraints are incompatible * - Custom components require runtime instantiation * - Different consumers need different output formats * * IMPORTANT: Standard components are defined in component-registry.ts (SINGLE SOURCE OF TRUTH). * This generator consumes that registry to ensure consistency across all schema generation. */ /** * Per-version props schema entry */ interface VersionedPropsEntry { version: string; propsSchema: TSchema; hasChildren?: boolean; description?: string; } /** * Custom component interface for plugins */ interface CustomComponentInfo { name: string; propsSchema: TSchema; /** When true, the component includes an optional `children` array */ hasChildren?: boolean; /** Human-readable description shown in autocomplete */ description?: string; /** * Per-version props schemas for version-discriminated validation. * When provided, separate schema variants are generated per version, * each pairing its version literal with its specific props schema. * A "no version" fallback variant uses the latest version's props. */ versionedProps?: VersionedPropsEntry[]; } /** * Options for generating document schema */ interface GenerateDocumentSchemaOptions { includeStandardComponents?: boolean; includeTheme?: boolean; customComponents?: CustomComponentInfo[]; title?: string; description?: string; } /** * Generate a complete document schema with all components * * This is the SHARED IMPLEMENTATION used by: * - Build-time schema generation (standard components only) * - Runtime plugin schema generation (with custom components) * - Web app schema generation (optimized for browser) * * @param options Configuration for what to include in the schema * @returns TypeBox schema that can be converted to JSON Schema */ declare function generateUnifiedDocumentSchema(options?: GenerateDocumentSchemaOptions): TSchema; export { type CustomComponentInfo, type GenerateDocumentSchemaOptions, type VersionedPropsEntry, generateUnifiedDocumentSchema };