UNPKG

@dbcube/schema-builder

Version:

The Dbcube Query Builder is a lightweight, flexible, and fluent library for building queries across multiple database engines, including MySQL, PostgreSQL, SQLite, and MongoDB, using JavaScript/Node.js. Its agnostic design allows you to generate data man

140 lines (135 loc) 4.18 kB
/** * Main class to handle MySQL database connections and queries. * Implements the Singleton pattern to ensure a single instance of the connection pool. */ 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<any>; refreshTables(): Promise<any>; freshTables(): Promise<any>; executeSeeders(): Promise<any>; executeTriggers(): Promise<any>; } interface ProcessError { itemName: string; error: string; filePath?: string; lineNumber?: number; } interface ProcessSummary { startTime: number; totalProcessed: number; successCount: number; errorCount: number; processedItems: string[]; operationName: string; databaseName: string; errors: ProcessError[]; } declare class UIUtils { /** * Shows animated progress for processing items */ static showItemProgress(itemName: string, current: number, total: number): Promise<void>; /** * Shows success for a processed item */ static showItemSuccess(itemName: string): void; /** * Shows error for an item (simplified - only shows X) */ static showItemError(itemName: string, error: string): void; /** * Shows operation header */ static showOperationHeader(operationName: string, databaseName: string, icon?: string): void; /** * Shows comprehensive operation summary */ static showOperationSummary(summary: ProcessSummary): void; /** * Shows code context around an error location */ static showCodeContext(filePath: string, lineNumber: number, contextLines?: number): void; } interface ValidationResult { isValid: boolean; errors: ProcessError[]; } 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 validateRequiredColumnProperties; private validateGeneralSyntax; private validateOverallStructure; private getColumnTypeForOptions; private isOptionCompatibleWithType; private isInsideColumnsBlock; private isInsideForeignKeyObject; } interface ExecutionOrder { tables: string[]; seeders: string[]; timestamp: string; } 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 { CubeValidator, DependencyResolver, Schema, UIUtils, Schema as default };