import { Config, Engine } from '@dbcube/core'; /** * Main class to handle MySQL database connections and queries. * Implements the Singleton pattern to ensure a single instance of the connection pool. */ export declare class Schema { private name; private engine; constructor(name: string); /** * Validates cube file comprehensively including syntax, database configuration, and structure * @param filePath - Path to the cube file * @returns validation result with any errors found */ private validateDatabaseConfiguration; /** * Finds the line number where @database directive is located */ private findDatabaseLineNumber; /** * Extracts foreign key dependencies from a cube file */ private extractForeignKeyDependencies; /** * Finds the line number where a foreign key table reference is located */ private findForeignKeyLineNumber; createDatabase(): Promise; refreshTables(): Promise; freshTables(): Promise; executeSeeders(filterName?: string): Promise; executeAlters(filterFiles?: string[] | null, options?: { dryRun?: boolean; }): Promise; executeTriggers(): Promise; } export interface ProcessError { itemName: string; error: string; filePath?: string; lineNumber?: number; } export interface ProcessSummary { startTime: number; totalProcessed: number; successCount: number; errorCount: number; processedItems: string[]; operationName: string; databaseName: string; errors: ProcessError[]; } /** * Reporter que recibe los eventos de una operación de schema. * Todos los métodos son opcionales: quien renderiza decide qué le interesa. */ export interface SchemaReporter { operationStart?(op: { operation: string; database: string; }): void; itemStart?(item: { name: string; index: number; total: number; }): void; itemSuccess?(item: { name: string; }): void; itemError?(item: { name: string; error: string; }): void; operationEnd?(summary: ProcessSummary): void; /** Error fatal fuera del ciclo de items (p. ej. fallo al crear la base). */ fatal?(err: { message: string; filePath?: string; lineNumber?: number; }): void; /** Salida cruda opcional (dry-run: sentencias SQL). */ raw?(line: string): void; } /** * UIUtils ya NO imprime: es un bus de eventos. * * Una librería no debe escribir en la consola del programa que la usa, y tener * dos renderers (este + el del CLI) era la causa de las salidas duplicadas y * las letras sobrepuestas. Ahora el CLI instala su renderer con * `UIUtils.setReporter(...)` y es el ÚNICO que dibuja. Sin reporter, silencio. * * Además, `showItemProgress` ya no anima puntos con un setInterval que se * esperaba ANTES de hacer el trabajo real (por eso "la UI cargaba y luego * recién se ejecutaba"): ahora sólo notifica el inicio del item y retorna. */ export declare class UIUtils { private static reporter; /** Instala el renderer (el CLI). Pasar null vuelve al modo silencioso. */ static setReporter(reporter: SchemaReporter | null): void; static getReporter(): SchemaReporter | null; /** Notifica que empieza a procesarse un item. No bloquea ni anima. */ static showItemProgress(itemName: string, current: number, total: number): Promise; static showItemSuccess(itemName: string): void; static showItemError(itemName: string, error: string): void; /** `icon` se mantiene por compatibilidad de firma; ya no se usa. */ static showOperationHeader(operationName: string, databaseName: string, _icon?: string): void; static showOperationSummary(summary: ProcessSummary): void; /** Error fatal (fuera del ciclo de items). */ static showFatal(message: string, filePath?: string, lineNumber?: number): void; /** Línea cruda (dry-run). */ static showRaw(line: string): void; /** * Lee el contexto de código alrededor de una línea. Devuelve las líneas en * vez de imprimirlas: quien renderiza decide cómo mostrarlas. */ static readCodeContext(filePath: string, lineNumber: number, contextLines?: number): Array<{ line: number; text: string; isError: boolean; }>; } export interface ValidationResult { isValid: boolean; errors: ProcessError[]; } export declare class CubeValidator { private validTypes; private validOptions; private validProperties; private knownAnnotations; /** * Validates a cube file comprehensively */ validateCubeFile(filePath: string): ValidationResult; private validateAnnotations; private validateDataTypes; private validateColumnOptions; private validateColumnProperties; private isInsideIndexesBlock; private validateRequiredColumnProperties; private validateGeneralSyntax; private validateOverallStructure; private getColumnTypeForOptions; private isOptionCompatibleWithType; private isInsideColumnsBlock; private isInsideForeignKeyObject; } export interface ExecutionOrder { tables: string[]; seeders: string[]; timestamp: string; } export declare class DependencyResolver { /** * Resolves table dependencies and creates execution order */ static resolveDependencies(cubeFiles: string[], cubeType?: "table" | "seeder"): ExecutionOrder; /** * Extracts dependencies from cube files */ private static extractDependencies; /** * Extracts foreign key references from a cube file */ private static extractForeignKeyReferences; /** * Performs topological sort to determine execution order */ private static topologicalSort; /** * Saves the execution order to .dbcube/orderexecute.json */ private static saveExecutionOrder; /** * Loads the execution order from .dbcube/orderexecute.json */ static loadExecutionOrder(): ExecutionOrder | null; /** * Orders cube files based on saved execution order */ static orderCubeFiles(cubeFiles: string[], cubeType: "table" | "seeder"): string[]; } export { Config, Engine, Schema as default, }; export {};