@dbcube/schema-builder 4.1.12 → 4.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bun.lockb CHANGED
Binary file
package/dist/index.cjs CHANGED
@@ -725,13 +725,19 @@ var DependencyResolver = class {
725
725
  const inDegree = /* @__PURE__ */ new Map();
726
726
  const tableMap = /* @__PURE__ */ new Map();
727
727
  for (const dep of dependencies) {
728
- graph.set(dep.tableName, dep.dependencies);
728
+ if (!graph.has(dep.tableName)) {
729
+ graph.set(dep.tableName, []);
730
+ }
729
731
  inDegree.set(dep.tableName, 0);
730
732
  tableMap.set(dep.tableName, dep);
731
733
  }
732
734
  for (const dep of dependencies) {
733
735
  for (const dependency of dep.dependencies) {
734
736
  if (inDegree.has(dependency)) {
737
+ if (!graph.has(dependency)) {
738
+ graph.set(dependency, []);
739
+ }
740
+ graph.get(dependency).push(dep.tableName);
735
741
  inDegree.set(dep.tableName, (inDegree.get(dep.tableName) || 0) + 1);
736
742
  }
737
743
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/lib/Schema.ts","../src/lib/FileUtils.ts","../src/lib/UIUtils.ts","../src/lib/CubeValidator.ts","../src/lib/DependencyResolver.ts"],"sourcesContent":["import { Schema } from './lib/Schema';\r\nimport { CubeValidator } from './lib/CubeValidator';\r\nimport { UIUtils } from './lib/UIUtils';\r\nimport { DependencyResolver } from './lib/DependencyResolver';\r\n\r\nexport default Schema;\r\nexport { Schema, CubeValidator, UIUtils, DependencyResolver };","import fs from 'fs';\r\nimport { Engine, TableProcessor, Config as ConfigClass } from \"@dbcube/core\";\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\nimport chalk from 'chalk';\r\nimport { UIUtils, ProcessSummary, ProcessError } from './UIUtils';\r\nimport { CubeValidator } from './CubeValidator';\r\nimport { DependencyResolver } from './DependencyResolver';\r\nimport { createRequire } from 'module';\r\n\r\n/**\r\n * Main class to handle MySQL database connections and queries.\r\n * Implements the Singleton pattern to ensure a single instance of the connection pool.\r\n */\r\nclass Schema {\r\n private name: string;\r\n private engine: any;\r\n\r\n constructor(name: string) {\r\n this.name = name;\r\n this.engine = new Engine(name);\r\n }\r\n\r\n /**\r\n * Validates cube file comprehensively including syntax, database configuration, and structure\r\n * @param filePath - Path to the cube file\r\n * @returns validation result with any errors found\r\n */\r\n private validateDatabaseConfiguration(filePath: string): { isValid: boolean; error?: ProcessError } {\r\n try {\r\n // First, perform comprehensive cube file validation\r\n const cubeValidator = new CubeValidator();\r\n const cubeValidation = cubeValidator.validateCubeFile(filePath);\r\n\r\n // If cube file has syntax errors, return the first one\r\n if (!cubeValidation.isValid && cubeValidation.errors.length > 0) {\r\n return {\r\n isValid: false,\r\n error: cubeValidation.errors[0] // Return the first error found\r\n };\r\n }\r\n\r\n // Extract database name from cube file\r\n const dbResult = FileUtils.extractDatabaseNameFromCube(filePath);\r\n if (dbResult.status !== 200) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Error reading database directive: ${dbResult.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n const cubeDbName = dbResult.message;\r\n\r\n // Get available configurations\r\n const configInstance = new ConfigClass();\r\n const configFilePath = path.resolve(process.cwd(), 'dbcube.config.js');\r\n\r\n // Use __filename for CJS, process.cwd() for ESM\r\n const requireUrl = typeof __filename !== 'undefined' ? __filename : process.cwd();\r\n const require = createRequire(requireUrl);\r\n // Clear require cache to ensure fresh load\r\n delete require.cache[require.resolve(configFilePath)];\r\n const configModule = require(configFilePath);\r\n const configFn = configModule.default || configModule;\r\n\r\n if (typeof configFn === 'function') {\r\n configFn(configInstance);\r\n } else {\r\n throw new Error('❌ The dbcube.config.js file does not export a function.');\r\n }\r\n\r\n // Check if the database configuration exists\r\n const dbConfig = configInstance.getDatabase(cubeDbName);\r\n if (!dbConfig) {\r\n // Try to get available databases by attempting to access common ones\r\n let availableDbs: string[] = [];\r\n try {\r\n // Try some common database names to see what exists\r\n const testNames = ['test', 'development', 'production', 'local', 'main'];\r\n for (const testName of testNames) {\r\n try {\r\n const testConfig = configInstance.getDatabase(testName);\r\n if (testConfig) {\r\n availableDbs.push(testName);\r\n }\r\n } catch (e) {\r\n // Skip non-existent configs\r\n }\r\n }\r\n } catch (e) {\r\n // Fallback if we can't determine available databases\r\n }\r\n\r\n const availableText = availableDbs.length > 0 ? availableDbs.join(', ') : 'none found';\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration '${cubeDbName}' not found in dbcube.config.js. Available: ${availableText}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n return { isValid: true };\r\n\r\n } catch (error: any) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration validation failed: ${error.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Finds the line number where @database directive is located\r\n */\r\n private findDatabaseLineNumber(filePath: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@database')) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n /**\r\n * Extracts foreign key dependencies from a cube file\r\n */\r\n private extractForeignKeyDependencies(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n\r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n\r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n\r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n\r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n\r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n\r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading dependencies from ${filePath}:`, error);\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Finds the line number where a foreign key table reference is located\r\n */\r\n private findForeignKeyLineNumber(filePath: string, tableName: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes(`table: \"${tableName}\"`) || lines[i].includes(`table: '${tableName}'`)) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n async createDatabase(): Promise<any> {\r\n const startTime = Date.now();\r\n const rootPath = path.resolve(process.cwd());\r\n\r\n // Show header\r\n UIUtils.showOperationHeader(' CREATING DATABASE', this.name, '🗄️');\r\n\r\n // Show progress for database creation\r\n await UIUtils.showItemProgress('Preparando e instalando base de datos', 1, 1);\r\n\r\n try {\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'create_database',\r\n '--path', rootPath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n }\r\n\r\n UIUtils.showItemSuccess('Database');\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 1,\r\n successCount: 1,\r\n errorCount: 0,\r\n processedItems: [this.name],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return response.data;\r\n\r\n } catch (error: any) {\r\n UIUtils.showItemError('Database', error.message);\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 0,\r\n successCount: 0,\r\n errorCount: 1,\r\n processedItems: [],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n throw error;\r\n }\r\n }\r\n\r\n async refreshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING REFRESH TABLES', this.name, '🔄');\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot refresh table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--mode', 'refresh',\r\n '--schema-path', filePath,\r\n ]);\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--mode', 'refresh',\r\n '--dml', parseJson,\r\n ]);\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n delete queries.data.database_type;\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'refresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'refresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async freshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING FRESH TABLES', this.name);\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot create table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--schema-path', filePath,\r\n '--mode', 'fresh',\r\n ]);\r\n\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--dml', parseJson,\r\n ]);\r\n\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n\r\n delete queries.data._type;\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n // For fresh mode, use the generated queries directly without alterations\r\n // generateAlterQueries is used for refresh mode, not fresh mode\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'fresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'fresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n\r\n async executeSeeders(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.seeder.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Use existing table dependency order for seeders\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'seeder');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING SEEDERS', this.name, '🌱');\r\n\r\n let totalSeedersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedSeeders: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getSeederName = FileUtils.extracTableNameFromCube(filePath);\r\n const seederName = getSeederName.status === 200 ? getSeederName.message : path.basename(file, '.seeder.cube');\r\n\r\n // Show visual progress for each seeder\r\n await UIUtils.showItemProgress(seederName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(seederName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'seeder',\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(seederName);\r\n successCount++;\r\n processedSeeders.push(seederName);\r\n totalSeedersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: seederName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(seederName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalSeedersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedSeeders,\r\n operationName: 'seeders',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalSeedersProcessed > 0 ? { processed: totalSeedersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async executeTriggers(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n const triggersDirExit = path.join(process.cwd(), 'dbcube', 'triggers');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.trigger.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING TRIGGERS', this.name, '⚡');\r\n\r\n let totalTriggersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTriggers: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < cubeFiles.length; index++) {\r\n const file = cubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTriggerName = FileUtils.extracTableNameFromCube(filePath);\r\n const triggerName = getTriggerName.status === 200 ? getTriggerName.message : path.basename(file, '.trigger.cube');\r\n\r\n // Show visual progress for each trigger\r\n await UIUtils.showItemProgress(triggerName, index + 1, cubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(triggerName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'trigger',\r\n '--path-exit', triggersDirExit,\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(triggerName);\r\n successCount++;\r\n processedTriggers.push(triggerName);\r\n totalTriggersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: triggerName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(triggerName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTriggersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTriggers,\r\n operationName: 'triggers',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTriggersProcessed > 0 ? { processed: totalTriggersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n}\r\n\r\n\r\nfunction returnFormattedError(status: number, message: string) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(message)}`);\r\n console.log('');\r\n\r\n const err = new Error();\r\n const stackLines = err.stack?.split('\\n') || [];\r\n\r\n // Find the first stack line outside of node_modules\r\n const relevantStackLine = stackLines.find(line =>\r\n line.includes('.js:') && !line.includes('node_modules')\r\n );\r\n\r\n if (relevantStackLine) {\r\n const match = relevantStackLine.match(/\\((.*):(\\d+):(\\d+)\\)/) ||\r\n relevantStackLine.match(/at (.*):(\\d+):(\\d+)/);\r\n\r\n if (match) {\r\n const [, filePath, lineStr, columnStr] = match;\r\n const lineNum = parseInt(lineStr, 10);\r\n const errorLocation = `${filePath}:${lineStr}:${columnStr}`;\r\n\r\n // Show code location with [code] tag format\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(errorLocation)}`);\r\n\r\n // Show code context\r\n try {\r\n const codeLines = fs.readFileSync(filePath, 'utf-8').split('\\n');\r\n const start = Math.max(0, lineNum - 3);\r\n const end = Math.min(codeLines.length, lineNum + 2);\r\n\r\n for (let i = start; i < end; i++) {\r\n const line = codeLines[i];\r\n const lineLabel = `${i + 1}`.padStart(4, ' ');\r\n const pointer = i + 1 === lineNum ? `${chalk.red('<-')}` : ' ';\r\n console.log(`${chalk.gray(lineLabel)} ${pointer} ${chalk.white(line)}`);\r\n }\r\n } catch (err) {\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n }\r\n\r\n console.log('');\r\n}\r\n\r\nexport default Schema;\r\nexport { Schema };","import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nclass FileUtils {\r\n /**\r\n * Verifica si un archivo existe (asincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static async fileExists(filePath: string): Promise<boolean> {\r\n return new Promise((resolve) => {\r\n fs.access(path.resolve(filePath), fs.constants.F_OK, (err) => {\r\n resolve(!err);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Verifica si un archivo existe (sincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static fileExistsSync(filePath: string): boolean {\r\n try {\r\n fs.accessSync(path.resolve(filePath), fs.constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n static extractDatabaseName(input: string): string | null {\r\n const match = input.match(/@database\\([\"']?([\\w-]+)[\"']?\\)/);\r\n return match ? match[1] : null;\r\n }\r\n\r\n /**\r\n * Lee recursivamente archivos que terminan en un sufijo dado y los ordena numéricamente.\r\n * @param dir - Directorio base (relativo o absoluto).\r\n * @param suffix - Sufijo de archivo (como 'table.cube').\r\n * @returns Rutas absolutas de los archivos encontrados y ordenados.\r\n */\r\n static getCubeFilesRecursively(dir: string, suffix: string): string[] {\r\n const baseDir = path.resolve(dir); // ✅ Asegura que sea absoluto\r\n const cubeFiles: string[] = [];\r\n\r\n function recurse(currentDir: string): void {\r\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\r\n\r\n for (const entry of entries) {\r\n const fullPath = path.join(currentDir, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n recurse(fullPath);\r\n } else if (entry.isFile() && entry.name.endsWith(suffix)) {\r\n cubeFiles.push(fullPath); // Ya es absoluta\r\n }\r\n }\r\n }\r\n\r\n recurse(baseDir);\r\n\r\n // Ordenar por número si los archivos comienzan con un número\r\n cubeFiles.sort((a, b) => {\r\n const aNum = parseInt(path.basename(a));\r\n const bNum = parseInt(path.basename(b));\r\n return (isNaN(aNum) ? 0 : aNum) - (isNaN(bNum) ? 0 : bNum);\r\n });\r\n\r\n return cubeFiles;\r\n }\r\n\r\n /**\r\n * Extracts database name from cube files\r\n * @param filePath - Path to the .cube file\r\n * @returns Object containing status and database name\r\n */\r\n static extractDatabaseNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n \r\n // Pattern: @database(\"database_name\") or @database('database_name')\r\n const databaseMatch = content.match(/@database\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)\\s*;?/);\r\n if (databaseMatch) {\r\n return {\r\n status: 200,\r\n message: databaseMatch[1]\r\n };\r\n }\r\n \r\n throw new Error(`No @database directive found in file ${filePath}`);\r\n \r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Extrae nombres de tablas reales de archivos .cube\r\n * @param {string} filePath - String ruta del archivo .cube\r\n * @returns {object} - Objeto que contiene el estado y el mensaje con el nombre de la tabla\r\n */\r\n static extracTableNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n\r\n // Patrón principal: @meta({ name: \"nombre_tabla\"; }) o @meta({ name: 'nombre_tabla'; })\r\n const metaMatch = content.match(/@meta\\s*\\(\\s*\\{\\s*name\\s*:\\s*[\"']([^\"']+)[\"']\\s*;\\s*[^}]*\\}\\s*\\)/s);\r\n if (metaMatch) {\r\n return {\r\n status: 200,\r\n message: metaMatch[1]\r\n };\r\n }\r\n\r\n throw new Error(`Error to execute this file ${filePath} because no exist a name of table.`);\r\n\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n}\r\n\r\nexport default FileUtils;","import chalk from 'chalk';\r\nimport fs from 'fs';\r\n\r\nexport interface ProcessError {\r\n itemName: string;\r\n error: string;\r\n filePath?: string;\r\n lineNumber?: number;\r\n}\r\n\r\nexport interface ProcessSummary {\r\n startTime: number;\r\n totalProcessed: number;\r\n successCount: number;\r\n errorCount: number;\r\n processedItems: string[];\r\n operationName: string;\r\n databaseName: string;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class UIUtils {\r\n /**\r\n * Shows animated progress for processing items\r\n */\r\n static async showItemProgress(\r\n itemName: string,\r\n current: number,\r\n total: number\r\n ): Promise<void> {\r\n // Get console width, default to 80 if not available\r\n const consoleWidth = process.stdout.columns || 80;\r\n\r\n // Calculate available space for dots\r\n // Format: \"├─ itemName \" + dots + \" ✓ OK\"\r\n const prefix = `├─ ${itemName} `;\r\n const suffix = ` ✓ OK`;\r\n const availableSpace = consoleWidth - prefix.length - suffix.length;\r\n const maxDots = Math.max(10, availableSpace); // Minimum 10 dots\r\n\r\n return new Promise((resolve) => {\r\n process.stdout.write(`${chalk.blue('├─')} ${chalk.cyan(itemName)} `);\r\n\r\n let dotCount = 0;\r\n const interval = setInterval(() => {\r\n if (dotCount < maxDots) {\r\n process.stdout.write(chalk.gray('.'));\r\n dotCount++;\r\n } else {\r\n clearInterval(interval);\r\n resolve();\r\n }\r\n }, 10); // Faster animation\r\n });\r\n }\r\n\r\n /**\r\n * Shows success for a processed item\r\n */\r\n static showItemSuccess(itemName: string): void {\r\n process.stdout.write(` ${chalk.green('✓')} ${chalk.gray('OK')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows error for an item (simplified - only shows X)\r\n */\r\n static showItemError(itemName: string, error: string): void {\r\n process.stdout.write(` ${chalk.red('✗')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows operation header\r\n */\r\n static showOperationHeader(operationName: string, databaseName: string, icon: string = '🗑️'): void {\r\n console.log(`\\n${chalk.cyan(icon)} ${chalk.bold.green(operationName.toUpperCase())}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n console.log(`${chalk.blue('┌─')} ${chalk.bold(`Database: ${databaseName}`)}`);\r\n }\r\n\r\n /**\r\n * Shows comprehensive operation summary\r\n */\r\n static showOperationSummary(summary: ProcessSummary): void {\r\n const { startTime, totalProcessed, successCount, errorCount, processedItems, operationName, databaseName } = summary;\r\n const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);\r\n\r\n console.log(`\\n${chalk.cyan('📊')} ${chalk.bold.green(`SUMMARY OF ${operationName.toUpperCase()}`)}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n\r\n if (successCount > 0) {\r\n console.log(`${chalk.green('┌─')} ${chalk.bold('Successful processing:')}`);\r\n console.log(`${chalk.green('├─')} ${chalk.cyan(`Items processed: ${successCount}`)}`);\r\n console.log(`${chalk.green('├─')} ${chalk.gray(`Database: ${databaseName}`)}`);\r\n\r\n if (processedItems.length > 0) {\r\n console.log(`${chalk.green('├─')} ${chalk.yellow('Items updated:')}`);\r\n processedItems.forEach((item, index) => {\r\n const isLast = index === processedItems.length - 1;\r\n const connector = isLast ? '└─' : '├─';\r\n console.log(`${chalk.green('│ ')} ${chalk.gray(connector)} ${chalk.cyan(item)}`);\r\n });\r\n }\r\n }\r\n\r\n if (errorCount > 0) {\r\n console.log(`${chalk.red('├─')} ${chalk.bold.red(`Errors: ${errorCount}`)}`);\r\n }\r\n\r\n console.log(`${chalk.blue('├─')} ${chalk.gray(`Total time: ${totalTime}s`)}`);\r\n console.log(`${chalk.blue('└─')} ${chalk.bold(totalProcessed > 0 ? chalk.green('✅ Completed') : chalk.yellow('⚠️ No changes'))}`);\r\n\r\n // Show detailed errors section if there are errors\r\n if (summary.errors && summary.errors.length > 0) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n \r\n summary.errors.forEach((error, index) => {\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(error.error)}`);\r\n console.log('');\r\n \r\n if (error.filePath) {\r\n // Show code location with [code] tag format\r\n const location = error.lineNumber ? `${error.filePath}:${error.lineNumber}:7` : error.filePath;\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(location)}`);\r\n \r\n // Try to show code context if file exists\r\n UIUtils.showCodeContext(error.filePath, error.lineNumber || 1);\r\n }\r\n \r\n if (index < summary.errors.length - 1) {\r\n console.log('');\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shows code context around an error location\r\n */\r\n static showCodeContext(filePath: string, lineNumber: number, contextLines: number = 2): void {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n const startLine = Math.max(0, lineNumber - contextLines - 1);\r\n const endLine = Math.min(lines.length, lineNumber + contextLines);\r\n \r\n for (let i = startLine; i < endLine; i++) {\r\n const currentLineNum = i + 1;\r\n const line = lines[i];\r\n const lineNumStr = currentLineNum.toString().padStart(4, ' ');\r\n \r\n if (currentLineNum === lineNumber) {\r\n // Highlight the error line with arrow\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.red('<-')} ${chalk.white(line)}`);\r\n } else {\r\n // Normal context lines\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.white(line)}`);\r\n }\r\n }\r\n } catch (error) {\r\n // If we can't read the file, just skip showing context\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport { ProcessError } from './UIUtils';\r\n\r\nexport interface ValidationResult {\r\n isValid: boolean;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class CubeValidator {\r\n private validTypes = ['varchar', 'int', 'string', 'text', 'boolean', 'date', 'datetime', 'timestamp', 'decimal', 'float', 'double', 'enum', 'json'];\r\n private validOptions = ['not null', 'primary', 'autoincrement', 'unique', 'zerofill', 'index', 'required', 'unsigned'];\r\n private validProperties = ['type', 'length', 'options', 'value', 'defaultValue', 'foreign', 'enumValues', 'description'];\r\n private knownAnnotations = ['database', 'table', 'meta', 'columns', 'fields', 'dataset', 'beforeAdd', 'afterAdd', 'beforeUpdate', 'afterUpdate', 'beforeDelete', 'afterDelete', 'compute', 'column'];\r\n\r\n /**\r\n * Validates a cube file comprehensively\r\n */\r\n validateCubeFile(filePath: string): ValidationResult {\r\n const errors: ProcessError[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n const fileName = path.basename(filePath, path.extname(filePath));\r\n\r\n // Validate each line\r\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\r\n const line = lines[lineIndex];\r\n \r\n // Skip empty lines and comments\r\n if (line.trim() === '' || line.trim().startsWith('//')) {\r\n continue;\r\n }\r\n\r\n // Validate annotations\r\n this.validateAnnotations(line, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate data types\r\n this.validateDataTypes(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate column options\r\n this.validateColumnOptions(line, lineIndex + 1, filePath, fileName, errors, lines);\r\n \r\n // Validate column properties\r\n this.validateColumnProperties(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate required column properties\r\n this.validateRequiredColumnProperties(lines, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate general syntax\r\n this.validateGeneralSyntax(line, lineIndex + 1, filePath, fileName, errors);\r\n }\r\n\r\n // Validate overall structure\r\n this.validateOverallStructure(content, filePath, fileName, errors);\r\n\r\n } catch (error: any) {\r\n errors.push({\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Failed to read cube file: ${error.message}`,\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n return {\r\n isValid: errors.length === 0,\r\n errors\r\n };\r\n }\r\n\r\n private validateAnnotations(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Remove content inside strings to avoid false positives\r\n const lineWithoutStrings = line.replace(/\"[^\"]*\"/g, '\"\"').replace(/'[^']*'/g, \"''\");\r\n \r\n const annotationRegex = /@(\\w+)/g;\r\n let match;\r\n \r\n while ((match = annotationRegex.exec(lineWithoutStrings)) !== null) {\r\n const annotation = match[1];\r\n \r\n if (!this.knownAnnotations.includes(annotation)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Unknown annotation '@${annotation}'. Valid annotations: ${this.knownAnnotations.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateDataTypes(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const typeRegex = /type:\\s*[\"'](\\w+)[\"']/g;\r\n let match;\r\n \r\n while ((match = typeRegex.exec(line)) !== null) {\r\n const type = match[1];\r\n \r\n if (!this.validTypes.includes(type)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid data type '${type}'. Valid types: ${this.validTypes.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for varchar without length\r\n if (line.includes('type: \"varchar\"')) {\r\n const lines = content.split('\\n');\r\n const hasLengthNearby = lines.slice(Math.max(0, lineNumber - 1), Math.min(lineNumber + 4, lines.length))\r\n .some(nextLine => nextLine.includes('length:'));\r\n \r\n if (!hasLengthNearby) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'VARCHAR type requires a length specification',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateColumnOptions(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], lines: string[]): void {\r\n const optionsMatch = line.match(/^\\s*options\\s*:\\s*\\[(.*)\\]\\s*;?\\s*$/);\r\n if (!optionsMatch) return;\r\n\r\n const optionsContent = optionsMatch[1].trim();\r\n \r\n // Check for invalid syntax (values without quotes)\r\n const invalidSyntaxMatch = optionsContent.match(/[^\",\\s]+(?![^\"]*\")/);\r\n if (invalidSyntaxMatch) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid syntax '${invalidSyntaxMatch[0]}' in options array. All values must be quoted strings`,\r\n filePath,\r\n lineNumber\r\n });\r\n return;\r\n }\r\n\r\n // Extract individual options\r\n const optionMatches = optionsContent.match(/\"([^\"]*)\"/g);\r\n if (optionMatches) {\r\n // Get column type for compatibility checking\r\n const columnType = this.getColumnTypeForOptions(lines, lineNumber - 1);\r\n \r\n optionMatches.forEach(optionMatch => {\r\n const option = optionMatch.replace(/\"/g, '');\r\n \r\n if (option.trim() === '') {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Empty option found in options array. All options must have a value',\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (!this.validOptions.includes(option)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid option '${option}'. Valid options: ${this.validOptions.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (columnType !== 'unknown' && !this.isOptionCompatibleWithType(option, columnType)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Option '${option}' is not compatible with type '${columnType}'`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n });\r\n }\r\n }\r\n\r\n private validateColumnProperties(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const propertyKeyRegex = /^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:/;\r\n const propMatch = propertyKeyRegex.exec(line);\r\n \r\n if (!propMatch) return;\r\n\r\n const propertyName = propMatch[1];\r\n \r\n // Skip column definitions (they end with opening brace)\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n return;\r\n }\r\n\r\n // Check if we're inside a foreign key object\r\n if (this.isInsideForeignKeyObject(content, lineNumber - 1)) {\r\n // Inside foreign key object, validate foreign key properties\r\n const validForeignKeyProperties = ['table', 'column'];\r\n if (!validForeignKeyProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid foreign key property '${propertyName}'. Valid foreign key properties: ${validForeignKeyProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n return; // Skip other validation for foreign key properties\r\n }\r\n\r\n // Check if we're inside a columns block and validate property\r\n if (this.isInsideColumnsBlock(content, lineNumber - 1)) {\r\n if (!this.validProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid property '${propertyName}'. Valid properties: ${this.validProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for incomplete property declarations\r\n if (/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*$/.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Property '${propertyName}' is missing a value`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n private validateRequiredColumnProperties(lines: string[], lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const line = lines[lineNumber - 1];\r\n \r\n // Check if current line is the closing of a column definition\r\n if (!/^\\s*\\}\\s*;?\\s*$/.test(line)) {\r\n return;\r\n }\r\n\r\n // Find the start of this column definition\r\n let columnStartLine = -1;\r\n let columnName = '';\r\n \r\n for (let i = lineNumber - 2; i >= 0; i--) {\r\n const currentLine = lines[i];\r\n const columnDefMatch = currentLine.match(/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*\\{/);\r\n \r\n if (columnDefMatch) {\r\n // Verify this is the matching opening brace\r\n let openBraces = 0;\r\n let closeBraces = 0;\r\n \r\n for (let j = i; j < lineNumber; j++) {\r\n openBraces += (lines[j].match(/\\{/g) || []).length;\r\n closeBraces += (lines[j].match(/\\}/g) || []).length;\r\n }\r\n \r\n if (openBraces === closeBraces) {\r\n columnStartLine = i;\r\n columnName = columnDefMatch[1];\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (columnStartLine === -1 || !columnName) return;\r\n\r\n // Check for missing 'type' property\r\n let hasType = false;\r\n \r\n for (let i = columnStartLine + 1; i < lineNumber - 1; i++) {\r\n if (lines[i].match(/^\\s*type\\s*:/)) {\r\n hasType = true;\r\n break;\r\n }\r\n }\r\n \r\n if (!hasType && columnName !== 'foreign' && columnName !== 'defaultValue') {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Column '${columnName}' is missing required 'type' property`,\r\n filePath,\r\n lineNumber: columnStartLine + 1\r\n });\r\n }\r\n }\r\n\r\n private validateGeneralSyntax(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Check for mismatched quotes\r\n const quotes = line.match(/[\"']/g);\r\n if (quotes && quotes.length % 2 !== 0) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Mismatched quotes detected',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n\r\n // Check for invalid annotation syntax\r\n if (line.includes('@database') || line.includes('@table')) {\r\n const stringAnnotationRegex = /@(database|table)\\s*\\(\\s*\"([^\"]*)\"\\s*\\)/;\r\n if (!stringAnnotationRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid annotation syntax. Expected format: @annotation(\"value\")',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for @meta annotation syntax\r\n if (line.includes('@meta')) {\r\n const metaObjectRegex = /@meta\\s*\\(\\s*\\{/;\r\n if (!metaObjectRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid @meta syntax. Expected format: @meta({ ... })',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateOverallStructure(content: string, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const lines = content.split('\\n');\r\n \r\n // Check for required @database annotation\r\n const hasDatabase = lines.some(line => line.includes('@database'));\r\n if (!hasDatabase) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Missing required @database annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n // For table.cube files, check for @columns\r\n if (filePath.includes('.table.cube')) {\r\n const hasColumns = lines.some(line => line.includes('@columns'));\r\n if (!hasColumns) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Table cube files require @columns annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n }\r\n }\r\n\r\n private getColumnTypeForOptions(lines: string[], optionsLineIndex: number): string {\r\n // Look backwards from options line to find the type\r\n for (let i = optionsLineIndex - 1; i >= 0; i--) {\r\n const line = lines[i];\r\n const typeMatch = line.match(/^\\s*type\\s*:\\s*\"([^\"]+)\"/);\r\n if (typeMatch) {\r\n return typeMatch[1];\r\n }\r\n // Stop if we hit another column definition\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n break;\r\n }\r\n }\r\n return 'unknown';\r\n }\r\n\r\n private isOptionCompatibleWithType(option: string, type: string): boolean {\r\n const compatibilityRules: { [key: string]: string[] } = {\r\n \"zerofill\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"unsigned\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"autoincrement\": [\"int\"],\r\n \"primary\": [\"int\", \"varchar\", \"string\"],\r\n \"not null\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"],\r\n \"unique\": [\"int\", \"varchar\", \"string\", \"text\"],\r\n \"index\": [\"int\", \"varchar\", \"string\", \"text\", \"date\", \"datetime\", \"timestamp\"],\r\n \"required\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"]\r\n };\r\n \r\n const compatibleTypes = compatibilityRules[option];\r\n if (!compatibleTypes) {\r\n return true; // If not in rules, allow it\r\n }\r\n \r\n return compatibleTypes.includes(type);\r\n }\r\n\r\n private isInsideColumnsBlock(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Find @columns block boundaries\r\n let columnsStartLine = -1;\r\n let columnsEndLine = -1;\r\n \r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@columns')) {\r\n columnsStartLine = i;\r\n // Find the end of the @columns block\r\n let braceCount = 0;\r\n for (let j = i; j < lines.length; j++) {\r\n const currentLine = lines[j];\r\n braceCount += (currentLine.match(/\\{/g) || []).length;\r\n braceCount -= (currentLine.match(/\\}/g) || []).length;\r\n if (braceCount === 0 && j > i) {\r\n columnsEndLine = j;\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n \r\n return columnsStartLine !== -1 && columnsEndLine !== -1 && \r\n lineIndex > columnsStartLine && lineIndex < columnsEndLine;\r\n }\r\n\r\n private isInsideForeignKeyObject(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Look backwards from current line to find if we're inside a foreign object\r\n for (let i = lineIndex; i >= 0; i--) {\r\n const line = lines[i];\r\n \r\n // If we find a foreign: { on this line or above\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n // Count braces from the foreign line to current line to see if we're inside\r\n let braceCount = 0;\r\n \r\n // Start from the foreign line\r\n for (let j = i; j <= lineIndex; j++) {\r\n const currentLine = lines[j];\r\n \r\n // Count opening braces\r\n const openBraces = (currentLine.match(/\\{/g) || []).length;\r\n // Count closing braces\r\n const closeBraces = (currentLine.match(/\\}/g) || []).length;\r\n \r\n braceCount += openBraces - closeBraces;\r\n \r\n // If we've closed all braces, we're outside the foreign object\r\n if (braceCount === 0 && j > i) {\r\n return false;\r\n }\r\n }\r\n \r\n // If we still have open braces, we're inside the foreign object\r\n return braceCount > 0;\r\n }\r\n \r\n // If we find a closing brace before finding a foreign declaration,\r\n // we're not inside a foreign object\r\n if (line.trim() === '}' || line.includes('};')) {\r\n break;\r\n }\r\n }\r\n \r\n return false;\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\n\r\nexport interface TableDependency {\r\n tableName: string;\r\n filePath: string;\r\n dependencies: string[];\r\n}\r\n\r\nexport interface ExecutionOrder {\r\n tables: string[];\r\n seeders: string[];\r\n timestamp: string;\r\n}\r\n\r\nexport class DependencyResolver {\r\n \r\n /**\r\n * Resolves table dependencies and creates execution order\r\n */\r\n static resolveDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder' = 'table'): ExecutionOrder {\r\n const tableDependencies = this.extractDependencies(cubeFiles, cubeType);\r\n const orderedTables = this.topologicalSort(tableDependencies);\r\n \r\n const executionOrder: ExecutionOrder = {\r\n tables: cubeType === 'table' ? orderedTables : [],\r\n seeders: cubeType === 'seeder' ? orderedTables : [],\r\n timestamp: new Date().toISOString()\r\n };\r\n\r\n // Save the execution order file\r\n this.saveExecutionOrder(executionOrder);\r\n \r\n return executionOrder;\r\n }\r\n\r\n /**\r\n * Extracts dependencies from cube files\r\n */\r\n private static extractDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder'): TableDependency[] {\r\n const dependencies: TableDependency[] = [];\r\n\r\n for (const file of cubeFiles) {\r\n // Handle absolute paths and relative paths correctly\r\n let filePath: string;\r\n if (path.isAbsolute(file)) {\r\n filePath = file;\r\n } else if (fs.existsSync(file)) {\r\n // File exists in current directory\r\n filePath = path.resolve(file);\r\n } else {\r\n // Try the standard dbcube directory (files are now directly in dbcube folder)\r\n filePath = path.join(process.cwd(), 'dbcube', file);\r\n }\r\n \r\n try {\r\n // Extract table name\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n \r\n // Extract foreign key dependencies\r\n const deps = this.extractForeignKeyReferences(filePath);\r\n \r\n dependencies.push({\r\n tableName,\r\n filePath,\r\n dependencies: deps\r\n });\r\n } catch (error) {\r\n console.error(`Error processing ${filePath}:`, error);\r\n }\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Extracts foreign key references from a cube file\r\n */\r\n private static extractForeignKeyReferences(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n \r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n \r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n \r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n \r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n \r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading file ${filePath}:`, error);\r\n }\r\n \r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Performs topological sort to determine execution order\r\n */\r\n private static topologicalSort(dependencies: TableDependency[]): string[] {\r\n const graph = new Map<string, string[]>();\r\n const inDegree = new Map<string, number>();\r\n const tableMap = new Map<string, TableDependency>();\r\n \r\n // Build graph and initialize in-degree\r\n for (const dep of dependencies) {\r\n graph.set(dep.tableName, dep.dependencies);\r\n inDegree.set(dep.tableName, 0);\r\n tableMap.set(dep.tableName, dep);\r\n }\r\n \r\n // Calculate in-degrees\r\n for (const dep of dependencies) {\r\n for (const dependency of dep.dependencies) {\r\n if (inDegree.has(dependency)) {\r\n inDegree.set(dep.tableName, (inDegree.get(dep.tableName) || 0) + 1);\r\n }\r\n }\r\n }\r\n \r\n // Kahn's algorithm for topological sorting\r\n const queue: string[] = [];\r\n const result: string[] = [];\r\n \r\n // Find all nodes with no incoming edges\r\n for (const [table, degree] of inDegree) {\r\n if (degree === 0) {\r\n queue.push(table);\r\n }\r\n }\r\n \r\n while (queue.length > 0) {\r\n const current = queue.shift()!;\r\n result.push(current);\r\n \r\n const currentDeps = graph.get(current) || [];\r\n \r\n // For each neighbor, reduce in-degree\r\n for (const neighbor of currentDeps) {\r\n if (inDegree.has(neighbor)) {\r\n const newDegree = (inDegree.get(neighbor) || 0) - 1;\r\n inDegree.set(neighbor, newDegree);\r\n \r\n if (newDegree === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n }\r\n \r\n // Check for circular dependencies\r\n if (result.length !== dependencies.length) {\r\n // Add remaining tables that weren't processed due to circular dependencies\r\n for (const dep of dependencies) {\r\n if (!result.includes(dep.tableName)) {\r\n result.push(dep.tableName);\r\n }\r\n }\r\n }\r\n \r\n return result;\r\n }\r\n\r\n /**\r\n * Saves the execution order to .dbcube/orderexecute.json\r\n */\r\n private static saveExecutionOrder(order: ExecutionOrder): void {\r\n try {\r\n const projectRoot = process.cwd();\r\n const dbcubeDir = path.join(projectRoot, '.dbcube');\r\n const orderFile = path.join(dbcubeDir, 'orderexecute.json');\r\n \r\n // Create .dbcube directory if it doesn't exist\r\n if (!fs.existsSync(dbcubeDir)) {\r\n fs.mkdirSync(dbcubeDir, { recursive: true });\r\n }\r\n \r\n // Save the order file\r\n fs.writeFileSync(orderFile, JSON.stringify(order, null, 2), 'utf8');\r\n \r\n // Execution order saved silently\r\n } catch (error) {\r\n console.error('❌ Failed to save execution order:', error);\r\n }\r\n }\r\n\r\n /**\r\n * Loads the execution order from .dbcube/orderexecute.json\r\n */\r\n static loadExecutionOrder(): ExecutionOrder | null {\r\n try {\r\n const projectRoot = process.cwd();\r\n const orderFile = path.join(projectRoot, '.dbcube', 'orderexecute.json');\r\n \r\n if (!fs.existsSync(orderFile)) {\r\n return null;\r\n }\r\n \r\n const content = fs.readFileSync(orderFile, 'utf8');\r\n return JSON.parse(content);\r\n } catch (error) {\r\n console.error('❌ Failed to load execution order:', error);\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Orders cube files based on saved execution order\r\n */\r\n static orderCubeFiles(cubeFiles: string[], cubeType: 'table' | 'seeder'): string[] {\r\n const executionOrder = this.loadExecutionOrder();\r\n\r\n if (!executionOrder) {\r\n return cubeFiles;\r\n }\r\n\r\n // IMPORTANTE: Los seeders SIEMPRE usan el orden de las tablas\r\n // porque deben insertar datos respetando las foreign keys\r\n const orderList = executionOrder.tables;\r\n const orderedFiles: string[] = [];\r\n const fileMap = new Map<string, string>();\r\n\r\n // Create a map of table names to file paths\r\n for (const file of cubeFiles) {\r\n const filePath = path.isAbsolute(file) ? file : path.join(process.cwd(), 'dbcube', file);\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n fileMap.set(tableName, file);\r\n }\r\n\r\n // Order files according to execution order (using table order)\r\n for (const tableName of orderList) {\r\n if (fileMap.has(tableName)) {\r\n orderedFiles.push(fileMap.get(tableName)!);\r\n fileMap.delete(tableName);\r\n }\r\n }\r\n\r\n // Add any remaining files that weren't in the order\r\n for (const [, file] of fileMap) {\r\n orderedFiles.push(file);\r\n }\r\n\r\n // Using dependency order silently\r\n\r\n return orderedFiles;\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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D,cAAM,QAAQ,KAAK,IAAI,GAAG,UAAU,CAAC;AACrC,cAAM,MAAM,KAAK,IAAI,UAAU,QAAQ,UAAU,CAAC;AAElD,iBAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAC9B,gBAAM,OAAO,UAAU,CAAC;AACxB,gBAAM,YAAY,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,GAAG;AAC5C,gBAAM,UAAU,IAAI,MAAM,UAAU,GAAG,cAAAC,QAAM,IAAI,IAAI,CAAC,KAAK;AAC3D,kBAAQ,IAAI,GAAG,cAAAA,QAAM,KAAK,SAAS,CAAC,IAAI,OAAO,UAAU,cAAAA,QAAM,MAAM,IAAI,CAAC,EAAE;AAAA,QAChF;AAAA,MACJ,SAASC,MAAK;AACV,gBAAQ,IAAI,cAAAD,QAAM,KAAK,kCAAkC,CAAC;AAAA,MAC9D;AAAA,IACJ;AAAA,EACJ;AAEA,UAAQ,IAAI,EAAE;AAClB;;;ADxxBA,IAAO,gBAAQ;","names":["import_fs","import_path","resolve","import_chalk","resolve","chalk","fs","import_fs","fs","path","import_fs","import_path","path","fs","path","ConfigClass","require","fs","chalk","err"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/lib/Schema.ts","../src/lib/FileUtils.ts","../src/lib/UIUtils.ts","../src/lib/CubeValidator.ts","../src/lib/DependencyResolver.ts"],"sourcesContent":["import { Schema } from './lib/Schema';\r\nimport { CubeValidator } from './lib/CubeValidator';\r\nimport { UIUtils } from './lib/UIUtils';\r\nimport { DependencyResolver } from './lib/DependencyResolver';\r\n\r\nexport default Schema;\r\nexport { Schema, CubeValidator, UIUtils, DependencyResolver };","import fs from 'fs';\r\nimport { Engine, TableProcessor, Config as ConfigClass } from \"@dbcube/core\";\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\nimport chalk from 'chalk';\r\nimport { UIUtils, ProcessSummary, ProcessError } from './UIUtils';\r\nimport { CubeValidator } from './CubeValidator';\r\nimport { DependencyResolver } from './DependencyResolver';\r\nimport { createRequire } from 'module';\r\n\r\n/**\r\n * Main class to handle MySQL database connections and queries.\r\n * Implements the Singleton pattern to ensure a single instance of the connection pool.\r\n */\r\nclass Schema {\r\n private name: string;\r\n private engine: any;\r\n\r\n constructor(name: string) {\r\n this.name = name;\r\n this.engine = new Engine(name);\r\n }\r\n\r\n /**\r\n * Validates cube file comprehensively including syntax, database configuration, and structure\r\n * @param filePath - Path to the cube file\r\n * @returns validation result with any errors found\r\n */\r\n private validateDatabaseConfiguration(filePath: string): { isValid: boolean; error?: ProcessError } {\r\n try {\r\n // First, perform comprehensive cube file validation\r\n const cubeValidator = new CubeValidator();\r\n const cubeValidation = cubeValidator.validateCubeFile(filePath);\r\n\r\n // If cube file has syntax errors, return the first one\r\n if (!cubeValidation.isValid && cubeValidation.errors.length > 0) {\r\n return {\r\n isValid: false,\r\n error: cubeValidation.errors[0] // Return the first error found\r\n };\r\n }\r\n\r\n // Extract database name from cube file\r\n const dbResult = FileUtils.extractDatabaseNameFromCube(filePath);\r\n if (dbResult.status !== 200) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Error reading database directive: ${dbResult.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n const cubeDbName = dbResult.message;\r\n\r\n // Get available configurations\r\n const configInstance = new ConfigClass();\r\n const configFilePath = path.resolve(process.cwd(), 'dbcube.config.js');\r\n\r\n // Use __filename for CJS, process.cwd() for ESM\r\n const requireUrl = typeof __filename !== 'undefined' ? __filename : process.cwd();\r\n const require = createRequire(requireUrl);\r\n // Clear require cache to ensure fresh load\r\n delete require.cache[require.resolve(configFilePath)];\r\n const configModule = require(configFilePath);\r\n const configFn = configModule.default || configModule;\r\n\r\n if (typeof configFn === 'function') {\r\n configFn(configInstance);\r\n } else {\r\n throw new Error('❌ The dbcube.config.js file does not export a function.');\r\n }\r\n\r\n // Check if the database configuration exists\r\n const dbConfig = configInstance.getDatabase(cubeDbName);\r\n if (!dbConfig) {\r\n // Try to get available databases by attempting to access common ones\r\n let availableDbs: string[] = [];\r\n try {\r\n // Try some common database names to see what exists\r\n const testNames = ['test', 'development', 'production', 'local', 'main'];\r\n for (const testName of testNames) {\r\n try {\r\n const testConfig = configInstance.getDatabase(testName);\r\n if (testConfig) {\r\n availableDbs.push(testName);\r\n }\r\n } catch (e) {\r\n // Skip non-existent configs\r\n }\r\n }\r\n } catch (e) {\r\n // Fallback if we can't determine available databases\r\n }\r\n\r\n const availableText = availableDbs.length > 0 ? availableDbs.join(', ') : 'none found';\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration '${cubeDbName}' not found in dbcube.config.js. Available: ${availableText}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n return { isValid: true };\r\n\r\n } catch (error: any) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration validation failed: ${error.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Finds the line number where @database directive is located\r\n */\r\n private findDatabaseLineNumber(filePath: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@database')) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n /**\r\n * Extracts foreign key dependencies from a cube file\r\n */\r\n private extractForeignKeyDependencies(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n\r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n\r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n\r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n\r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n\r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n\r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading dependencies from ${filePath}:`, error);\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Finds the line number where a foreign key table reference is located\r\n */\r\n private findForeignKeyLineNumber(filePath: string, tableName: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes(`table: \"${tableName}\"`) || lines[i].includes(`table: '${tableName}'`)) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n async createDatabase(): Promise<any> {\r\n const startTime = Date.now();\r\n const rootPath = path.resolve(process.cwd());\r\n\r\n // Show header\r\n UIUtils.showOperationHeader(' CREATING DATABASE', this.name, '🗄️');\r\n\r\n // Show progress for database creation\r\n await UIUtils.showItemProgress('Preparando e instalando base de datos', 1, 1);\r\n\r\n try {\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'create_database',\r\n '--path', rootPath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n }\r\n\r\n UIUtils.showItemSuccess('Database');\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 1,\r\n successCount: 1,\r\n errorCount: 0,\r\n processedItems: [this.name],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return response.data;\r\n\r\n } catch (error: any) {\r\n UIUtils.showItemError('Database', error.message);\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 0,\r\n successCount: 0,\r\n errorCount: 1,\r\n processedItems: [],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n throw error;\r\n }\r\n }\r\n\r\n async refreshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING REFRESH TABLES', this.name, '🔄');\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot refresh table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--mode', 'refresh',\r\n '--schema-path', filePath,\r\n ]);\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--mode', 'refresh',\r\n '--dml', parseJson,\r\n ]);\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n delete queries.data.database_type;\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'refresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'refresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async freshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING FRESH TABLES', this.name);\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot create table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--schema-path', filePath,\r\n '--mode', 'fresh',\r\n ]);\r\n\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--dml', parseJson,\r\n ]);\r\n\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n\r\n delete queries.data._type;\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n // For fresh mode, use the generated queries directly without alterations\r\n // generateAlterQueries is used for refresh mode, not fresh mode\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'fresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'fresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n\r\n async executeSeeders(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.seeder.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Use existing table dependency order for seeders\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'seeder');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING SEEDERS', this.name, '🌱');\r\n\r\n let totalSeedersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedSeeders: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getSeederName = FileUtils.extracTableNameFromCube(filePath);\r\n const seederName = getSeederName.status === 200 ? getSeederName.message : path.basename(file, '.seeder.cube');\r\n\r\n // Show visual progress for each seeder\r\n await UIUtils.showItemProgress(seederName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(seederName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'seeder',\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(seederName);\r\n successCount++;\r\n processedSeeders.push(seederName);\r\n totalSeedersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: seederName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(seederName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalSeedersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedSeeders,\r\n operationName: 'seeders',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalSeedersProcessed > 0 ? { processed: totalSeedersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async executeTriggers(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n const triggersDirExit = path.join(process.cwd(), 'dbcube', 'triggers');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.trigger.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING TRIGGERS', this.name, '⚡');\r\n\r\n let totalTriggersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTriggers: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < cubeFiles.length; index++) {\r\n const file = cubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTriggerName = FileUtils.extracTableNameFromCube(filePath);\r\n const triggerName = getTriggerName.status === 200 ? getTriggerName.message : path.basename(file, '.trigger.cube');\r\n\r\n // Show visual progress for each trigger\r\n await UIUtils.showItemProgress(triggerName, index + 1, cubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(triggerName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'trigger',\r\n '--path-exit', triggersDirExit,\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(triggerName);\r\n successCount++;\r\n processedTriggers.push(triggerName);\r\n totalTriggersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: triggerName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(triggerName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTriggersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTriggers,\r\n operationName: 'triggers',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTriggersProcessed > 0 ? { processed: totalTriggersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n}\r\n\r\n\r\nfunction returnFormattedError(status: number, message: string) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(message)}`);\r\n console.log('');\r\n\r\n const err = new Error();\r\n const stackLines = err.stack?.split('\\n') || [];\r\n\r\n // Find the first stack line outside of node_modules\r\n const relevantStackLine = stackLines.find(line =>\r\n line.includes('.js:') && !line.includes('node_modules')\r\n );\r\n\r\n if (relevantStackLine) {\r\n const match = relevantStackLine.match(/\\((.*):(\\d+):(\\d+)\\)/) ||\r\n relevantStackLine.match(/at (.*):(\\d+):(\\d+)/);\r\n\r\n if (match) {\r\n const [, filePath, lineStr, columnStr] = match;\r\n const lineNum = parseInt(lineStr, 10);\r\n const errorLocation = `${filePath}:${lineStr}:${columnStr}`;\r\n\r\n // Show code location with [code] tag format\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(errorLocation)}`);\r\n\r\n // Show code context\r\n try {\r\n const codeLines = fs.readFileSync(filePath, 'utf-8').split('\\n');\r\n const start = Math.max(0, lineNum - 3);\r\n const end = Math.min(codeLines.length, lineNum + 2);\r\n\r\n for (let i = start; i < end; i++) {\r\n const line = codeLines[i];\r\n const lineLabel = `${i + 1}`.padStart(4, ' ');\r\n const pointer = i + 1 === lineNum ? `${chalk.red('<-')}` : ' ';\r\n console.log(`${chalk.gray(lineLabel)} ${pointer} ${chalk.white(line)}`);\r\n }\r\n } catch (err) {\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n }\r\n\r\n console.log('');\r\n}\r\n\r\nexport default Schema;\r\nexport { Schema };","import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nclass FileUtils {\r\n /**\r\n * Verifica si un archivo existe (asincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static async fileExists(filePath: string): Promise<boolean> {\r\n return new Promise((resolve) => {\r\n fs.access(path.resolve(filePath), fs.constants.F_OK, (err) => {\r\n resolve(!err);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Verifica si un archivo existe (sincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static fileExistsSync(filePath: string): boolean {\r\n try {\r\n fs.accessSync(path.resolve(filePath), fs.constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n static extractDatabaseName(input: string): string | null {\r\n const match = input.match(/@database\\([\"']?([\\w-]+)[\"']?\\)/);\r\n return match ? match[1] : null;\r\n }\r\n\r\n /**\r\n * Lee recursivamente archivos que terminan en un sufijo dado y los ordena numéricamente.\r\n * @param dir - Directorio base (relativo o absoluto).\r\n * @param suffix - Sufijo de archivo (como 'table.cube').\r\n * @returns Rutas absolutas de los archivos encontrados y ordenados.\r\n */\r\n static getCubeFilesRecursively(dir: string, suffix: string): string[] {\r\n const baseDir = path.resolve(dir); // ✅ Asegura que sea absoluto\r\n const cubeFiles: string[] = [];\r\n\r\n function recurse(currentDir: string): void {\r\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\r\n\r\n for (const entry of entries) {\r\n const fullPath = path.join(currentDir, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n recurse(fullPath);\r\n } else if (entry.isFile() && entry.name.endsWith(suffix)) {\r\n cubeFiles.push(fullPath); // Ya es absoluta\r\n }\r\n }\r\n }\r\n\r\n recurse(baseDir);\r\n\r\n // Ordenar por número si los archivos comienzan con un número\r\n cubeFiles.sort((a, b) => {\r\n const aNum = parseInt(path.basename(a));\r\n const bNum = parseInt(path.basename(b));\r\n return (isNaN(aNum) ? 0 : aNum) - (isNaN(bNum) ? 0 : bNum);\r\n });\r\n\r\n return cubeFiles;\r\n }\r\n\r\n /**\r\n * Extracts database name from cube files\r\n * @param filePath - Path to the .cube file\r\n * @returns Object containing status and database name\r\n */\r\n static extractDatabaseNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n \r\n // Pattern: @database(\"database_name\") or @database('database_name')\r\n const databaseMatch = content.match(/@database\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)\\s*;?/);\r\n if (databaseMatch) {\r\n return {\r\n status: 200,\r\n message: databaseMatch[1]\r\n };\r\n }\r\n \r\n throw new Error(`No @database directive found in file ${filePath}`);\r\n \r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Extrae nombres de tablas reales de archivos .cube\r\n * @param {string} filePath - String ruta del archivo .cube\r\n * @returns {object} - Objeto que contiene el estado y el mensaje con el nombre de la tabla\r\n */\r\n static extracTableNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n\r\n // Patrón principal: @meta({ name: \"nombre_tabla\"; }) o @meta({ name: 'nombre_tabla'; })\r\n const metaMatch = content.match(/@meta\\s*\\(\\s*\\{\\s*name\\s*:\\s*[\"']([^\"']+)[\"']\\s*;\\s*[^}]*\\}\\s*\\)/s);\r\n if (metaMatch) {\r\n return {\r\n status: 200,\r\n message: metaMatch[1]\r\n };\r\n }\r\n\r\n throw new Error(`Error to execute this file ${filePath} because no exist a name of table.`);\r\n\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n}\r\n\r\nexport default FileUtils;","import chalk from 'chalk';\r\nimport fs from 'fs';\r\n\r\nexport interface ProcessError {\r\n itemName: string;\r\n error: string;\r\n filePath?: string;\r\n lineNumber?: number;\r\n}\r\n\r\nexport interface ProcessSummary {\r\n startTime: number;\r\n totalProcessed: number;\r\n successCount: number;\r\n errorCount: number;\r\n processedItems: string[];\r\n operationName: string;\r\n databaseName: string;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class UIUtils {\r\n /**\r\n * Shows animated progress for processing items\r\n */\r\n static async showItemProgress(\r\n itemName: string,\r\n current: number,\r\n total: number\r\n ): Promise<void> {\r\n // Get console width, default to 80 if not available\r\n const consoleWidth = process.stdout.columns || 80;\r\n\r\n // Calculate available space for dots\r\n // Format: \"├─ itemName \" + dots + \" ✓ OK\"\r\n const prefix = `├─ ${itemName} `;\r\n const suffix = ` ✓ OK`;\r\n const availableSpace = consoleWidth - prefix.length - suffix.length;\r\n const maxDots = Math.max(10, availableSpace); // Minimum 10 dots\r\n\r\n return new Promise((resolve) => {\r\n process.stdout.write(`${chalk.blue('├─')} ${chalk.cyan(itemName)} `);\r\n\r\n let dotCount = 0;\r\n const interval = setInterval(() => {\r\n if (dotCount < maxDots) {\r\n process.stdout.write(chalk.gray('.'));\r\n dotCount++;\r\n } else {\r\n clearInterval(interval);\r\n resolve();\r\n }\r\n }, 10); // Faster animation\r\n });\r\n }\r\n\r\n /**\r\n * Shows success for a processed item\r\n */\r\n static showItemSuccess(itemName: string): void {\r\n process.stdout.write(` ${chalk.green('✓')} ${chalk.gray('OK')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows error for an item (simplified - only shows X)\r\n */\r\n static showItemError(itemName: string, error: string): void {\r\n process.stdout.write(` ${chalk.red('✗')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows operation header\r\n */\r\n static showOperationHeader(operationName: string, databaseName: string, icon: string = '🗑️'): void {\r\n console.log(`\\n${chalk.cyan(icon)} ${chalk.bold.green(operationName.toUpperCase())}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n console.log(`${chalk.blue('┌─')} ${chalk.bold(`Database: ${databaseName}`)}`);\r\n }\r\n\r\n /**\r\n * Shows comprehensive operation summary\r\n */\r\n static showOperationSummary(summary: ProcessSummary): void {\r\n const { startTime, totalProcessed, successCount, errorCount, processedItems, operationName, databaseName } = summary;\r\n const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);\r\n\r\n console.log(`\\n${chalk.cyan('📊')} ${chalk.bold.green(`SUMMARY OF ${operationName.toUpperCase()}`)}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n\r\n if (successCount > 0) {\r\n console.log(`${chalk.green('┌─')} ${chalk.bold('Successful processing:')}`);\r\n console.log(`${chalk.green('├─')} ${chalk.cyan(`Items processed: ${successCount}`)}`);\r\n console.log(`${chalk.green('├─')} ${chalk.gray(`Database: ${databaseName}`)}`);\r\n\r\n if (processedItems.length > 0) {\r\n console.log(`${chalk.green('├─')} ${chalk.yellow('Items updated:')}`);\r\n processedItems.forEach((item, index) => {\r\n const isLast = index === processedItems.length - 1;\r\n const connector = isLast ? '└─' : '├─';\r\n console.log(`${chalk.green('│ ')} ${chalk.gray(connector)} ${chalk.cyan(item)}`);\r\n });\r\n }\r\n }\r\n\r\n if (errorCount > 0) {\r\n console.log(`${chalk.red('├─')} ${chalk.bold.red(`Errors: ${errorCount}`)}`);\r\n }\r\n\r\n console.log(`${chalk.blue('├─')} ${chalk.gray(`Total time: ${totalTime}s`)}`);\r\n console.log(`${chalk.blue('└─')} ${chalk.bold(totalProcessed > 0 ? chalk.green('✅ Completed') : chalk.yellow('⚠️ No changes'))}`);\r\n\r\n // Show detailed errors section if there are errors\r\n if (summary.errors && summary.errors.length > 0) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n \r\n summary.errors.forEach((error, index) => {\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(error.error)}`);\r\n console.log('');\r\n \r\n if (error.filePath) {\r\n // Show code location with [code] tag format\r\n const location = error.lineNumber ? `${error.filePath}:${error.lineNumber}:7` : error.filePath;\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(location)}`);\r\n \r\n // Try to show code context if file exists\r\n UIUtils.showCodeContext(error.filePath, error.lineNumber || 1);\r\n }\r\n \r\n if (index < summary.errors.length - 1) {\r\n console.log('');\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shows code context around an error location\r\n */\r\n static showCodeContext(filePath: string, lineNumber: number, contextLines: number = 2): void {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n const startLine = Math.max(0, lineNumber - contextLines - 1);\r\n const endLine = Math.min(lines.length, lineNumber + contextLines);\r\n \r\n for (let i = startLine; i < endLine; i++) {\r\n const currentLineNum = i + 1;\r\n const line = lines[i];\r\n const lineNumStr = currentLineNum.toString().padStart(4, ' ');\r\n \r\n if (currentLineNum === lineNumber) {\r\n // Highlight the error line with arrow\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.red('<-')} ${chalk.white(line)}`);\r\n } else {\r\n // Normal context lines\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.white(line)}`);\r\n }\r\n }\r\n } catch (error) {\r\n // If we can't read the file, just skip showing context\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport { ProcessError } from './UIUtils';\r\n\r\nexport interface ValidationResult {\r\n isValid: boolean;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class CubeValidator {\r\n private validTypes = ['varchar', 'int', 'string', 'text', 'boolean', 'date', 'datetime', 'timestamp', 'decimal', 'float', 'double', 'enum', 'json'];\r\n private validOptions = ['not null', 'primary', 'autoincrement', 'unique', 'zerofill', 'index', 'required', 'unsigned'];\r\n private validProperties = ['type', 'length', 'options', 'value', 'defaultValue', 'foreign', 'enumValues', 'description'];\r\n private knownAnnotations = ['database', 'table', 'meta', 'columns', 'fields', 'dataset', 'beforeAdd', 'afterAdd', 'beforeUpdate', 'afterUpdate', 'beforeDelete', 'afterDelete', 'compute', 'column'];\r\n\r\n /**\r\n * Validates a cube file comprehensively\r\n */\r\n validateCubeFile(filePath: string): ValidationResult {\r\n const errors: ProcessError[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n const fileName = path.basename(filePath, path.extname(filePath));\r\n\r\n // Validate each line\r\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\r\n const line = lines[lineIndex];\r\n \r\n // Skip empty lines and comments\r\n if (line.trim() === '' || line.trim().startsWith('//')) {\r\n continue;\r\n }\r\n\r\n // Validate annotations\r\n this.validateAnnotations(line, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate data types\r\n this.validateDataTypes(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate column options\r\n this.validateColumnOptions(line, lineIndex + 1, filePath, fileName, errors, lines);\r\n \r\n // Validate column properties\r\n this.validateColumnProperties(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate required column properties\r\n this.validateRequiredColumnProperties(lines, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate general syntax\r\n this.validateGeneralSyntax(line, lineIndex + 1, filePath, fileName, errors);\r\n }\r\n\r\n // Validate overall structure\r\n this.validateOverallStructure(content, filePath, fileName, errors);\r\n\r\n } catch (error: any) {\r\n errors.push({\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Failed to read cube file: ${error.message}`,\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n return {\r\n isValid: errors.length === 0,\r\n errors\r\n };\r\n }\r\n\r\n private validateAnnotations(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Remove content inside strings to avoid false positives\r\n const lineWithoutStrings = line.replace(/\"[^\"]*\"/g, '\"\"').replace(/'[^']*'/g, \"''\");\r\n \r\n const annotationRegex = /@(\\w+)/g;\r\n let match;\r\n \r\n while ((match = annotationRegex.exec(lineWithoutStrings)) !== null) {\r\n const annotation = match[1];\r\n \r\n if (!this.knownAnnotations.includes(annotation)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Unknown annotation '@${annotation}'. Valid annotations: ${this.knownAnnotations.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateDataTypes(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const typeRegex = /type:\\s*[\"'](\\w+)[\"']/g;\r\n let match;\r\n \r\n while ((match = typeRegex.exec(line)) !== null) {\r\n const type = match[1];\r\n \r\n if (!this.validTypes.includes(type)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid data type '${type}'. Valid types: ${this.validTypes.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for varchar without length\r\n if (line.includes('type: \"varchar\"')) {\r\n const lines = content.split('\\n');\r\n const hasLengthNearby = lines.slice(Math.max(0, lineNumber - 1), Math.min(lineNumber + 4, lines.length))\r\n .some(nextLine => nextLine.includes('length:'));\r\n \r\n if (!hasLengthNearby) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'VARCHAR type requires a length specification',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateColumnOptions(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], lines: string[]): void {\r\n const optionsMatch = line.match(/^\\s*options\\s*:\\s*\\[(.*)\\]\\s*;?\\s*$/);\r\n if (!optionsMatch) return;\r\n\r\n const optionsContent = optionsMatch[1].trim();\r\n \r\n // Check for invalid syntax (values without quotes)\r\n const invalidSyntaxMatch = optionsContent.match(/[^\",\\s]+(?![^\"]*\")/);\r\n if (invalidSyntaxMatch) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid syntax '${invalidSyntaxMatch[0]}' in options array. All values must be quoted strings`,\r\n filePath,\r\n lineNumber\r\n });\r\n return;\r\n }\r\n\r\n // Extract individual options\r\n const optionMatches = optionsContent.match(/\"([^\"]*)\"/g);\r\n if (optionMatches) {\r\n // Get column type for compatibility checking\r\n const columnType = this.getColumnTypeForOptions(lines, lineNumber - 1);\r\n \r\n optionMatches.forEach(optionMatch => {\r\n const option = optionMatch.replace(/\"/g, '');\r\n \r\n if (option.trim() === '') {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Empty option found in options array. All options must have a value',\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (!this.validOptions.includes(option)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid option '${option}'. Valid options: ${this.validOptions.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (columnType !== 'unknown' && !this.isOptionCompatibleWithType(option, columnType)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Option '${option}' is not compatible with type '${columnType}'`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n });\r\n }\r\n }\r\n\r\n private validateColumnProperties(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const propertyKeyRegex = /^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:/;\r\n const propMatch = propertyKeyRegex.exec(line);\r\n \r\n if (!propMatch) return;\r\n\r\n const propertyName = propMatch[1];\r\n \r\n // Skip column definitions (they end with opening brace)\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n return;\r\n }\r\n\r\n // Check if we're inside a foreign key object\r\n if (this.isInsideForeignKeyObject(content, lineNumber - 1)) {\r\n // Inside foreign key object, validate foreign key properties\r\n const validForeignKeyProperties = ['table', 'column'];\r\n if (!validForeignKeyProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid foreign key property '${propertyName}'. Valid foreign key properties: ${validForeignKeyProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n return; // Skip other validation for foreign key properties\r\n }\r\n\r\n // Check if we're inside a columns block and validate property\r\n if (this.isInsideColumnsBlock(content, lineNumber - 1)) {\r\n if (!this.validProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid property '${propertyName}'. Valid properties: ${this.validProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for incomplete property declarations\r\n if (/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*$/.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Property '${propertyName}' is missing a value`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n private validateRequiredColumnProperties(lines: string[], lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const line = lines[lineNumber - 1];\r\n \r\n // Check if current line is the closing of a column definition\r\n if (!/^\\s*\\}\\s*;?\\s*$/.test(line)) {\r\n return;\r\n }\r\n\r\n // Find the start of this column definition\r\n let columnStartLine = -1;\r\n let columnName = '';\r\n \r\n for (let i = lineNumber - 2; i >= 0; i--) {\r\n const currentLine = lines[i];\r\n const columnDefMatch = currentLine.match(/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*\\{/);\r\n \r\n if (columnDefMatch) {\r\n // Verify this is the matching opening brace\r\n let openBraces = 0;\r\n let closeBraces = 0;\r\n \r\n for (let j = i; j < lineNumber; j++) {\r\n openBraces += (lines[j].match(/\\{/g) || []).length;\r\n closeBraces += (lines[j].match(/\\}/g) || []).length;\r\n }\r\n \r\n if (openBraces === closeBraces) {\r\n columnStartLine = i;\r\n columnName = columnDefMatch[1];\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (columnStartLine === -1 || !columnName) return;\r\n\r\n // Check for missing 'type' property\r\n let hasType = false;\r\n \r\n for (let i = columnStartLine + 1; i < lineNumber - 1; i++) {\r\n if (lines[i].match(/^\\s*type\\s*:/)) {\r\n hasType = true;\r\n break;\r\n }\r\n }\r\n \r\n if (!hasType && columnName !== 'foreign' && columnName !== 'defaultValue') {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Column '${columnName}' is missing required 'type' property`,\r\n filePath,\r\n lineNumber: columnStartLine + 1\r\n });\r\n }\r\n }\r\n\r\n private validateGeneralSyntax(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Check for mismatched quotes\r\n const quotes = line.match(/[\"']/g);\r\n if (quotes && quotes.length % 2 !== 0) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Mismatched quotes detected',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n\r\n // Check for invalid annotation syntax\r\n if (line.includes('@database') || line.includes('@table')) {\r\n const stringAnnotationRegex = /@(database|table)\\s*\\(\\s*\"([^\"]*)\"\\s*\\)/;\r\n if (!stringAnnotationRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid annotation syntax. Expected format: @annotation(\"value\")',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for @meta annotation syntax\r\n if (line.includes('@meta')) {\r\n const metaObjectRegex = /@meta\\s*\\(\\s*\\{/;\r\n if (!metaObjectRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid @meta syntax. Expected format: @meta({ ... })',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateOverallStructure(content: string, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const lines = content.split('\\n');\r\n \r\n // Check for required @database annotation\r\n const hasDatabase = lines.some(line => line.includes('@database'));\r\n if (!hasDatabase) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Missing required @database annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n // For table.cube files, check for @columns\r\n if (filePath.includes('.table.cube')) {\r\n const hasColumns = lines.some(line => line.includes('@columns'));\r\n if (!hasColumns) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Table cube files require @columns annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n }\r\n }\r\n\r\n private getColumnTypeForOptions(lines: string[], optionsLineIndex: number): string {\r\n // Look backwards from options line to find the type\r\n for (let i = optionsLineIndex - 1; i >= 0; i--) {\r\n const line = lines[i];\r\n const typeMatch = line.match(/^\\s*type\\s*:\\s*\"([^\"]+)\"/);\r\n if (typeMatch) {\r\n return typeMatch[1];\r\n }\r\n // Stop if we hit another column definition\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n break;\r\n }\r\n }\r\n return 'unknown';\r\n }\r\n\r\n private isOptionCompatibleWithType(option: string, type: string): boolean {\r\n const compatibilityRules: { [key: string]: string[] } = {\r\n \"zerofill\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"unsigned\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"autoincrement\": [\"int\"],\r\n \"primary\": [\"int\", \"varchar\", \"string\"],\r\n \"not null\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"],\r\n \"unique\": [\"int\", \"varchar\", \"string\", \"text\"],\r\n \"index\": [\"int\", \"varchar\", \"string\", \"text\", \"date\", \"datetime\", \"timestamp\"],\r\n \"required\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"]\r\n };\r\n \r\n const compatibleTypes = compatibilityRules[option];\r\n if (!compatibleTypes) {\r\n return true; // If not in rules, allow it\r\n }\r\n \r\n return compatibleTypes.includes(type);\r\n }\r\n\r\n private isInsideColumnsBlock(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Find @columns block boundaries\r\n let columnsStartLine = -1;\r\n let columnsEndLine = -1;\r\n \r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@columns')) {\r\n columnsStartLine = i;\r\n // Find the end of the @columns block\r\n let braceCount = 0;\r\n for (let j = i; j < lines.length; j++) {\r\n const currentLine = lines[j];\r\n braceCount += (currentLine.match(/\\{/g) || []).length;\r\n braceCount -= (currentLine.match(/\\}/g) || []).length;\r\n if (braceCount === 0 && j > i) {\r\n columnsEndLine = j;\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n \r\n return columnsStartLine !== -1 && columnsEndLine !== -1 && \r\n lineIndex > columnsStartLine && lineIndex < columnsEndLine;\r\n }\r\n\r\n private isInsideForeignKeyObject(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Look backwards from current line to find if we're inside a foreign object\r\n for (let i = lineIndex; i >= 0; i--) {\r\n const line = lines[i];\r\n \r\n // If we find a foreign: { on this line or above\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n // Count braces from the foreign line to current line to see if we're inside\r\n let braceCount = 0;\r\n \r\n // Start from the foreign line\r\n for (let j = i; j <= lineIndex; j++) {\r\n const currentLine = lines[j];\r\n \r\n // Count opening braces\r\n const openBraces = (currentLine.match(/\\{/g) || []).length;\r\n // Count closing braces\r\n const closeBraces = (currentLine.match(/\\}/g) || []).length;\r\n \r\n braceCount += openBraces - closeBraces;\r\n \r\n // If we've closed all braces, we're outside the foreign object\r\n if (braceCount === 0 && j > i) {\r\n return false;\r\n }\r\n }\r\n \r\n // If we still have open braces, we're inside the foreign object\r\n return braceCount > 0;\r\n }\r\n \r\n // If we find a closing brace before finding a foreign declaration,\r\n // we're not inside a foreign object\r\n if (line.trim() === '}' || line.includes('};')) {\r\n break;\r\n }\r\n }\r\n \r\n return false;\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\n\r\nexport interface TableDependency {\r\n tableName: string;\r\n filePath: string;\r\n dependencies: string[];\r\n}\r\n\r\nexport interface ExecutionOrder {\r\n tables: string[];\r\n seeders: string[];\r\n timestamp: string;\r\n}\r\n\r\nexport class DependencyResolver {\r\n \r\n /**\r\n * Resolves table dependencies and creates execution order\r\n */\r\n static resolveDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder' = 'table'): ExecutionOrder {\r\n const tableDependencies = this.extractDependencies(cubeFiles, cubeType);\r\n const orderedTables = this.topologicalSort(tableDependencies);\r\n \r\n const executionOrder: ExecutionOrder = {\r\n tables: cubeType === 'table' ? orderedTables : [],\r\n seeders: cubeType === 'seeder' ? orderedTables : [],\r\n timestamp: new Date().toISOString()\r\n };\r\n\r\n // Save the execution order file\r\n this.saveExecutionOrder(executionOrder);\r\n \r\n return executionOrder;\r\n }\r\n\r\n /**\r\n * Extracts dependencies from cube files\r\n */\r\n private static extractDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder'): TableDependency[] {\r\n const dependencies: TableDependency[] = [];\r\n\r\n for (const file of cubeFiles) {\r\n // Handle absolute paths and relative paths correctly\r\n let filePath: string;\r\n if (path.isAbsolute(file)) {\r\n filePath = file;\r\n } else if (fs.existsSync(file)) {\r\n // File exists in current directory\r\n filePath = path.resolve(file);\r\n } else {\r\n // Try the standard dbcube directory (files are now directly in dbcube folder)\r\n filePath = path.join(process.cwd(), 'dbcube', file);\r\n }\r\n \r\n try {\r\n // Extract table name\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n \r\n // Extract foreign key dependencies\r\n const deps = this.extractForeignKeyReferences(filePath);\r\n \r\n dependencies.push({\r\n tableName,\r\n filePath,\r\n dependencies: deps\r\n });\r\n } catch (error) {\r\n console.error(`Error processing ${filePath}:`, error);\r\n }\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Extracts foreign key references from a cube file\r\n */\r\n private static extractForeignKeyReferences(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n \r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n \r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n \r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n \r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n \r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading file ${filePath}:`, error);\r\n }\r\n \r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Performs topological sort to determine execution order\r\n */\r\n private static topologicalSort(dependencies: TableDependency[]): string[] {\r\n const graph = new Map<string, string[]>();\r\n const inDegree = new Map<string, number>();\r\n const tableMap = new Map<string, TableDependency>();\r\n\r\n // Initialize graph and in-degree for all tables\r\n for (const dep of dependencies) {\r\n if (!graph.has(dep.tableName)) {\r\n graph.set(dep.tableName, []);\r\n }\r\n inDegree.set(dep.tableName, 0);\r\n tableMap.set(dep.tableName, dep);\r\n }\r\n\r\n // Build reverse graph: for each table that A depends on, add A as a dependent of that table\r\n // This allows Kahn's algorithm to work: when we process a table, we can reduce\r\n // the in-degree of all tables that depend on it\r\n for (const dep of dependencies) {\r\n for (const dependency of dep.dependencies) {\r\n // If dependency exists in our table list, add edge: dependency -> dep.tableName\r\n if (inDegree.has(dependency)) {\r\n if (!graph.has(dependency)) {\r\n graph.set(dependency, []);\r\n }\r\n graph.get(dependency)!.push(dep.tableName);\r\n // Increase in-degree of the table that has the dependency\r\n inDegree.set(dep.tableName, (inDegree.get(dep.tableName) || 0) + 1);\r\n }\r\n }\r\n }\r\n \r\n // Kahn's algorithm for topological sorting\r\n const queue: string[] = [];\r\n const result: string[] = [];\r\n \r\n // Find all nodes with no incoming edges\r\n for (const [table, degree] of inDegree) {\r\n if (degree === 0) {\r\n queue.push(table);\r\n }\r\n }\r\n \r\n while (queue.length > 0) {\r\n const current = queue.shift()!;\r\n result.push(current);\r\n \r\n const currentDeps = graph.get(current) || [];\r\n \r\n // For each neighbor, reduce in-degree\r\n for (const neighbor of currentDeps) {\r\n if (inDegree.has(neighbor)) {\r\n const newDegree = (inDegree.get(neighbor) || 0) - 1;\r\n inDegree.set(neighbor, newDegree);\r\n \r\n if (newDegree === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n }\r\n \r\n // Check for circular dependencies\r\n if (result.length !== dependencies.length) {\r\n // Add remaining tables that weren't processed due to circular dependencies\r\n for (const dep of dependencies) {\r\n if (!result.includes(dep.tableName)) {\r\n result.push(dep.tableName);\r\n }\r\n }\r\n }\r\n \r\n return result;\r\n }\r\n\r\n /**\r\n * Saves the execution order to .dbcube/orderexecute.json\r\n */\r\n private static saveExecutionOrder(order: ExecutionOrder): void {\r\n try {\r\n const projectRoot = process.cwd();\r\n const dbcubeDir = path.join(projectRoot, '.dbcube');\r\n const orderFile = path.join(dbcubeDir, 'orderexecute.json');\r\n \r\n // Create .dbcube directory if it doesn't exist\r\n if (!fs.existsSync(dbcubeDir)) {\r\n fs.mkdirSync(dbcubeDir, { recursive: true });\r\n }\r\n \r\n // Save the order file\r\n fs.writeFileSync(orderFile, JSON.stringify(order, null, 2), 'utf8');\r\n \r\n // Execution order saved silently\r\n } catch (error) {\r\n console.error('❌ Failed to save execution order:', error);\r\n }\r\n }\r\n\r\n /**\r\n * Loads the execution order from .dbcube/orderexecute.json\r\n */\r\n static loadExecutionOrder(): ExecutionOrder | null {\r\n try {\r\n const projectRoot = process.cwd();\r\n const orderFile = path.join(projectRoot, '.dbcube', 'orderexecute.json');\r\n \r\n if (!fs.existsSync(orderFile)) {\r\n return null;\r\n }\r\n \r\n const content = fs.readFileSync(orderFile, 'utf8');\r\n return JSON.parse(content);\r\n } catch (error) {\r\n console.error('❌ Failed to load execution order:', error);\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Orders cube files based on saved execution order\r\n */\r\n static orderCubeFiles(cubeFiles: string[], cubeType: 'table' | 'seeder'): string[] {\r\n const executionOrder = this.loadExecutionOrder();\r\n\r\n if (!executionOrder) {\r\n return cubeFiles;\r\n }\r\n\r\n // IMPORTANTE: Los seeders SIEMPRE usan el orden de las tablas\r\n // porque deben insertar datos respetando las foreign keys\r\n const orderList = executionOrder.tables;\r\n const orderedFiles: string[] = [];\r\n const fileMap = new Map<string, string>();\r\n\r\n // Create a map of table names to file paths\r\n for (const file of cubeFiles) {\r\n const filePath = path.isAbsolute(file) ? file : path.join(process.cwd(), 'dbcube', file);\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n fileMap.set(tableName, file);\r\n }\r\n\r\n // Order files according to execution order (using table order)\r\n for (const tableName of orderList) {\r\n if (fileMap.has(tableName)) {\r\n orderedFiles.push(fileMap.get(tableName)!);\r\n fileMap.delete(tableName);\r\n }\r\n }\r\n\r\n // Add any remaining files that weren't in the order\r\n for (const [, file] of fileMap) {\r\n orderedFiles.push(file);\r\n }\r\n\r\n // Using dependency order silently\r\n\r\n return orderedFiles;\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,aAAe;AACf,kBAA8D;AAC9D,IAAAC,eAAiB;;;ACFjB,SAAoB;AACpB,WAAsB;AAEtB,IAAM,YAAN,MAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMd,aAAa,WAAW,UAAoC;AAC1D,WAAO,IAAI,QAAQ,CAACC,aAAY;AAC9B,MAAG,UAAY,aAAQ,QAAQ,GAAM,aAAU,MAAM,CAAC,QAAQ;AAC5D,QAAAA,SAAQ,CAAC,GAAG;AAAA,MACd,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,eAAe,UAA2B;AAC/C,QAAI;AACF,MAAG,cAAgB,aAAQ,QAAQ,GAAM,aAAU,IAAI;AACvD,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO,oBAAoB,OAA8B;AACvD,UAAM,QAAQ,MAAM,MAAM,iCAAiC;AAC3D,WAAO,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,wBAAwB,KAAa,QAA0B;AACpE,UAAM,UAAe,aAAQ,GAAG;AAChC,UAAM,YAAsB,CAAC;AAE7B,aAAS,QAAQ,YAA0B;AACzC,YAAM,UAAa,eAAY,YAAY,EAAE,eAAe,KAAK,CAAC;AAElE,iBAAW,SAAS,SAAS;AAC3B,cA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AK,UACtC,KAAK,SAAS,MAAM,KAAK,CAAC,KAAK,SAAS,cAAc;AAAA,EAC1D;AAEA,MAAI,mBAAmB;AACnB,UAAM,QAAQ,kBAAkB,MAAM,sBAAsB,KACxD,kBAAkB,MAAM,qBAAqB;AAEjD,QAAI,OAAO;AACP,YAAM,CAAC,EAAE,UAAU,SAAS,SAAS,IAAI;AACzC,YAAM,UAAU,SAAS,SAAS,EAAE;AACpC,YAAM,gBAAgB,GAAG,QAAQ,IAAI,OAAO,IAAI,SAAS;AAGzD,cAAQ,IAAI,GAAG,cAAAA,QAAM,KAAK,QAAQ,CAAC,IAAI,cAAAA,QAAM,OAAO,aAAa,CAAC,EAAE;AAGpE,UAAI;AACA,cAAM,YAAY,WAAAD,QAAG,aAAa,UAAU,OAAO,EAAE,MAAM,IAAI;AAC/D,cAAM,QAAQ,KAAK,IAAI,GAAG,UAAU,CAAC;AACrC,cAAM,MAAM,KAAK,IAAI,UAAU,QAAQ,UAAU,CAAC;AAElD,iBAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAC9B,gBAAM,OAAO,UAAU,CAAC;AACxB,gBAAM,YAAY,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,GAAG;AAC5C,gBAAM,UAAU,IAAI,MAAM,UAAU,GAAG,cAAAC,QAAM,IAAI,IAAI,CAAC,KAAK;AAC3D,kBAAQ,IAAI,GAAG,cAAAA,QAAM,KAAK,SAAS,CAAC,IAAI,OAAO,UAAU,cAAAA,QAAM,MAAM,IAAI,CAAC,EAAE;AAAA,QAChF;AAAA,MACJ,SAASC,MAAK;AACV,gBAAQ,IAAI,cAAAD,QAAM,KAAK,kCAAkC,CAAC;AAAA,MAC9D;AAAA,IACJ;AAAA,EACJ;AAEA,UAAQ,IAAI,EAAE;AAClB;;;ADxxBA,IAAO,gBAAQ;","names":["import_fs","import_path","resolve","import_chalk","resolve","chalk","fs","import_fs","fs","path","import_fs","import_path","path","fs","path","ConfigClass","require","fs","chalk","err"]}
package/dist/index.js CHANGED
@@ -685,13 +685,19 @@ var DependencyResolver = class {
685
685
  const inDegree = /* @__PURE__ */ new Map();
686
686
  const tableMap = /* @__PURE__ */ new Map();
687
687
  for (const dep of dependencies) {
688
- graph.set(dep.tableName, dep.dependencies);
688
+ if (!graph.has(dep.tableName)) {
689
+ graph.set(dep.tableName, []);
690
+ }
689
691
  inDegree.set(dep.tableName, 0);
690
692
  tableMap.set(dep.tableName, dep);
691
693
  }
692
694
  for (const dep of dependencies) {
693
695
  for (const dependency of dep.dependencies) {
694
696
  if (inDegree.has(dependency)) {
697
+ if (!graph.has(dependency)) {
698
+ graph.set(dependency, []);
699
+ }
700
+ graph.get(dependency).push(dep.tableName);
695
701
  inDegree.set(dep.tableName, (inDegree.get(dep.tableName) || 0) + 1);
696
702
  }
697
703
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/Schema.ts","../src/lib/FileUtils.ts","../src/lib/UIUtils.ts","../src/lib/CubeValidator.ts","../src/lib/DependencyResolver.ts","../src/index.ts"],"sourcesContent":["import fs from 'fs';\r\nimport { Engine, TableProcessor, Config as ConfigClass } from \"@dbcube/core\";\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\nimport chalk from 'chalk';\r\nimport { UIUtils, ProcessSummary, ProcessError } from './UIUtils';\r\nimport { CubeValidator } from './CubeValidator';\r\nimport { DependencyResolver } from './DependencyResolver';\r\nimport { createRequire } from 'module';\r\n\r\n/**\r\n * Main class to handle MySQL database connections and queries.\r\n * Implements the Singleton pattern to ensure a single instance of the connection pool.\r\n */\r\nclass Schema {\r\n private name: string;\r\n private engine: any;\r\n\r\n constructor(name: string) {\r\n this.name = name;\r\n this.engine = new Engine(name);\r\n }\r\n\r\n /**\r\n * Validates cube file comprehensively including syntax, database configuration, and structure\r\n * @param filePath - Path to the cube file\r\n * @returns validation result with any errors found\r\n */\r\n private validateDatabaseConfiguration(filePath: string): { isValid: boolean; error?: ProcessError } {\r\n try {\r\n // First, perform comprehensive cube file validation\r\n const cubeValidator = new CubeValidator();\r\n const cubeValidation = cubeValidator.validateCubeFile(filePath);\r\n\r\n // If cube file has syntax errors, return the first one\r\n if (!cubeValidation.isValid && cubeValidation.errors.length > 0) {\r\n return {\r\n isValid: false,\r\n error: cubeValidation.errors[0] // Return the first error found\r\n };\r\n }\r\n\r\n // Extract database name from cube file\r\n const dbResult = FileUtils.extractDatabaseNameFromCube(filePath);\r\n if (dbResult.status !== 200) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Error reading database directive: ${dbResult.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n const cubeDbName = dbResult.message;\r\n\r\n // Get available configurations\r\n const configInstance = new ConfigClass();\r\n const configFilePath = path.resolve(process.cwd(), 'dbcube.config.js');\r\n\r\n // Use __filename for CJS, process.cwd() for ESM\r\n const requireUrl = typeof __filename !== 'undefined' ? __filename : process.cwd();\r\n const require = createRequire(requireUrl);\r\n // Clear require cache to ensure fresh load\r\n delete require.cache[require.resolve(configFilePath)];\r\n const configModule = require(configFilePath);\r\n const configFn = configModule.default || configModule;\r\n\r\n if (typeof configFn === 'function') {\r\n configFn(configInstance);\r\n } else {\r\n throw new Error('❌ The dbcube.config.js file does not export a function.');\r\n }\r\n\r\n // Check if the database configuration exists\r\n const dbConfig = configInstance.getDatabase(cubeDbName);\r\n if (!dbConfig) {\r\n // Try to get available databases by attempting to access common ones\r\n let availableDbs: string[] = [];\r\n try {\r\n // Try some common database names to see what exists\r\n const testNames = ['test', 'development', 'production', 'local', 'main'];\r\n for (const testName of testNames) {\r\n try {\r\n const testConfig = configInstance.getDatabase(testName);\r\n if (testConfig) {\r\n availableDbs.push(testName);\r\n }\r\n } catch (e) {\r\n // Skip non-existent configs\r\n }\r\n }\r\n } catch (e) {\r\n // Fallback if we can't determine available databases\r\n }\r\n\r\n const availableText = availableDbs.length > 0 ? availableDbs.join(', ') : 'none found';\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration '${cubeDbName}' not found in dbcube.config.js. Available: ${availableText}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n return { isValid: true };\r\n\r\n } catch (error: any) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration validation failed: ${error.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Finds the line number where @database directive is located\r\n */\r\n private findDatabaseLineNumber(filePath: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@database')) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n /**\r\n * Extracts foreign key dependencies from a cube file\r\n */\r\n private extractForeignKeyDependencies(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n\r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n\r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n\r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n\r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n\r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n\r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading dependencies from ${filePath}:`, error);\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Finds the line number where a foreign key table reference is located\r\n */\r\n private findForeignKeyLineNumber(filePath: string, tableName: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes(`table: \"${tableName}\"`) || lines[i].includes(`table: '${tableName}'`)) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n async createDatabase(): Promise<any> {\r\n const startTime = Date.now();\r\n const rootPath = path.resolve(process.cwd());\r\n\r\n // Show header\r\n UIUtils.showOperationHeader(' CREATING DATABASE', this.name, '🗄️');\r\n\r\n // Show progress for database creation\r\n await UIUtils.showItemProgress('Preparando e instalando base de datos', 1, 1);\r\n\r\n try {\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'create_database',\r\n '--path', rootPath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n }\r\n\r\n UIUtils.showItemSuccess('Database');\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 1,\r\n successCount: 1,\r\n errorCount: 0,\r\n processedItems: [this.name],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return response.data;\r\n\r\n } catch (error: any) {\r\n UIUtils.showItemError('Database', error.message);\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 0,\r\n successCount: 0,\r\n errorCount: 1,\r\n processedItems: [],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n throw error;\r\n }\r\n }\r\n\r\n async refreshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING REFRESH TABLES', this.name, '🔄');\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot refresh table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--mode', 'refresh',\r\n '--schema-path', filePath,\r\n ]);\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--mode', 'refresh',\r\n '--dml', parseJson,\r\n ]);\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n delete queries.data.database_type;\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'refresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'refresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async freshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING FRESH TABLES', this.name);\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot create table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--schema-path', filePath,\r\n '--mode', 'fresh',\r\n ]);\r\n\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--dml', parseJson,\r\n ]);\r\n\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n\r\n delete queries.data._type;\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n // For fresh mode, use the generated queries directly without alterations\r\n // generateAlterQueries is used for refresh mode, not fresh mode\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'fresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'fresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n\r\n async executeSeeders(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.seeder.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Use existing table dependency order for seeders\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'seeder');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING SEEDERS', this.name, '🌱');\r\n\r\n let totalSeedersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedSeeders: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getSeederName = FileUtils.extracTableNameFromCube(filePath);\r\n const seederName = getSeederName.status === 200 ? getSeederName.message : path.basename(file, '.seeder.cube');\r\n\r\n // Show visual progress for each seeder\r\n await UIUtils.showItemProgress(seederName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(seederName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'seeder',\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(seederName);\r\n successCount++;\r\n processedSeeders.push(seederName);\r\n totalSeedersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: seederName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(seederName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalSeedersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedSeeders,\r\n operationName: 'seeders',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalSeedersProcessed > 0 ? { processed: totalSeedersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async executeTriggers(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n const triggersDirExit = path.join(process.cwd(), 'dbcube', 'triggers');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.trigger.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING TRIGGERS', this.name, '⚡');\r\n\r\n let totalTriggersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTriggers: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < cubeFiles.length; index++) {\r\n const file = cubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTriggerName = FileUtils.extracTableNameFromCube(filePath);\r\n const triggerName = getTriggerName.status === 200 ? getTriggerName.message : path.basename(file, '.trigger.cube');\r\n\r\n // Show visual progress for each trigger\r\n await UIUtils.showItemProgress(triggerName, index + 1, cubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(triggerName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'trigger',\r\n '--path-exit', triggersDirExit,\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(triggerName);\r\n successCount++;\r\n processedTriggers.push(triggerName);\r\n totalTriggersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: triggerName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(triggerName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTriggersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTriggers,\r\n operationName: 'triggers',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTriggersProcessed > 0 ? { processed: totalTriggersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n}\r\n\r\n\r\nfunction returnFormattedError(status: number, message: string) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(message)}`);\r\n console.log('');\r\n\r\n const err = new Error();\r\n const stackLines = err.stack?.split('\\n') || [];\r\n\r\n // Find the first stack line outside of node_modules\r\n const relevantStackLine = stackLines.find(line =>\r\n line.includes('.js:') && !line.includes('node_modules')\r\n );\r\n\r\n if (relevantStackLine) {\r\n const match = relevantStackLine.match(/\\((.*):(\\d+):(\\d+)\\)/) ||\r\n relevantStackLine.match(/at (.*):(\\d+):(\\d+)/);\r\n\r\n if (match) {\r\n const [, filePath, lineStr, columnStr] = match;\r\n const lineNum = parseInt(lineStr, 10);\r\n const errorLocation = `${filePath}:${lineStr}:${columnStr}`;\r\n\r\n // Show code location with [code] tag format\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(errorLocation)}`);\r\n\r\n // Show code context\r\n try {\r\n const codeLines = fs.readFileSync(filePath, 'utf-8').split('\\n');\r\n const start = Math.max(0, lineNum - 3);\r\n const end = Math.min(codeLines.length, lineNum + 2);\r\n\r\n for (let i = start; i < end; i++) {\r\n const line = codeLines[i];\r\n const lineLabel = `${i + 1}`.padStart(4, ' ');\r\n const pointer = i + 1 === lineNum ? `${chalk.red('<-')}` : ' ';\r\n console.log(`${chalk.gray(lineLabel)} ${pointer} ${chalk.white(line)}`);\r\n }\r\n } catch (err) {\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n }\r\n\r\n console.log('');\r\n}\r\n\r\nexport default Schema;\r\nexport { Schema };","import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nclass FileUtils {\r\n /**\r\n * Verifica si un archivo existe (asincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static async fileExists(filePath: string): Promise<boolean> {\r\n return new Promise((resolve) => {\r\n fs.access(path.resolve(filePath), fs.constants.F_OK, (err) => {\r\n resolve(!err);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Verifica si un archivo existe (sincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static fileExistsSync(filePath: string): boolean {\r\n try {\r\n fs.accessSync(path.resolve(filePath), fs.constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n static extractDatabaseName(input: string): string | null {\r\n const match = input.match(/@database\\([\"']?([\\w-]+)[\"']?\\)/);\r\n return match ? match[1] : null;\r\n }\r\n\r\n /**\r\n * Lee recursivamente archivos que terminan en un sufijo dado y los ordena numéricamente.\r\n * @param dir - Directorio base (relativo o absoluto).\r\n * @param suffix - Sufijo de archivo (como 'table.cube').\r\n * @returns Rutas absolutas de los archivos encontrados y ordenados.\r\n */\r\n static getCubeFilesRecursively(dir: string, suffix: string): string[] {\r\n const baseDir = path.resolve(dir); // ✅ Asegura que sea absoluto\r\n const cubeFiles: string[] = [];\r\n\r\n function recurse(currentDir: string): void {\r\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\r\n\r\n for (const entry of entries) {\r\n const fullPath = path.join(currentDir, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n recurse(fullPath);\r\n } else if (entry.isFile() && entry.name.endsWith(suffix)) {\r\n cubeFiles.push(fullPath); // Ya es absoluta\r\n }\r\n }\r\n }\r\n\r\n recurse(baseDir);\r\n\r\n // Ordenar por número si los archivos comienzan con un número\r\n cubeFiles.sort((a, b) => {\r\n const aNum = parseInt(path.basename(a));\r\n const bNum = parseInt(path.basename(b));\r\n return (isNaN(aNum) ? 0 : aNum) - (isNaN(bNum) ? 0 : bNum);\r\n });\r\n\r\n return cubeFiles;\r\n }\r\n\r\n /**\r\n * Extracts database name from cube files\r\n * @param filePath - Path to the .cube file\r\n * @returns Object containing status and database name\r\n */\r\n static extractDatabaseNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n \r\n // Pattern: @database(\"database_name\") or @database('database_name')\r\n const databaseMatch = content.match(/@database\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)\\s*;?/);\r\n if (databaseMatch) {\r\n return {\r\n status: 200,\r\n message: databaseMatch[1]\r\n };\r\n }\r\n \r\n throw new Error(`No @database directive found in file ${filePath}`);\r\n \r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Extrae nombres de tablas reales de archivos .cube\r\n * @param {string} filePath - String ruta del archivo .cube\r\n * @returns {object} - Objeto que contiene el estado y el mensaje con el nombre de la tabla\r\n */\r\n static extracTableNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n\r\n // Patrón principal: @meta({ name: \"nombre_tabla\"; }) o @meta({ name: 'nombre_tabla'; })\r\n const metaMatch = content.match(/@meta\\s*\\(\\s*\\{\\s*name\\s*:\\s*[\"']([^\"']+)[\"']\\s*;\\s*[^}]*\\}\\s*\\)/s);\r\n if (metaMatch) {\r\n return {\r\n status: 200,\r\n message: metaMatch[1]\r\n };\r\n }\r\n\r\n throw new Error(`Error to execute this file ${filePath} because no exist a name of table.`);\r\n\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n}\r\n\r\nexport default FileUtils;","import chalk from 'chalk';\r\nimport fs from 'fs';\r\n\r\nexport interface ProcessError {\r\n itemName: string;\r\n error: string;\r\n filePath?: string;\r\n lineNumber?: number;\r\n}\r\n\r\nexport interface ProcessSummary {\r\n startTime: number;\r\n totalProcessed: number;\r\n successCount: number;\r\n errorCount: number;\r\n processedItems: string[];\r\n operationName: string;\r\n databaseName: string;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class UIUtils {\r\n /**\r\n * Shows animated progress for processing items\r\n */\r\n static async showItemProgress(\r\n itemName: string,\r\n current: number,\r\n total: number\r\n ): Promise<void> {\r\n // Get console width, default to 80 if not available\r\n const consoleWidth = process.stdout.columns || 80;\r\n\r\n // Calculate available space for dots\r\n // Format: \"├─ itemName \" + dots + \" ✓ OK\"\r\n const prefix = `├─ ${itemName} `;\r\n const suffix = ` ✓ OK`;\r\n const availableSpace = consoleWidth - prefix.length - suffix.length;\r\n const maxDots = Math.max(10, availableSpace); // Minimum 10 dots\r\n\r\n return new Promise((resolve) => {\r\n process.stdout.write(`${chalk.blue('├─')} ${chalk.cyan(itemName)} `);\r\n\r\n let dotCount = 0;\r\n const interval = setInterval(() => {\r\n if (dotCount < maxDots) {\r\n process.stdout.write(chalk.gray('.'));\r\n dotCount++;\r\n } else {\r\n clearInterval(interval);\r\n resolve();\r\n }\r\n }, 10); // Faster animation\r\n });\r\n }\r\n\r\n /**\r\n * Shows success for a processed item\r\n */\r\n static showItemSuccess(itemName: string): void {\r\n process.stdout.write(` ${chalk.green('✓')} ${chalk.gray('OK')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows error for an item (simplified - only shows X)\r\n */\r\n static showItemError(itemName: string, error: string): void {\r\n process.stdout.write(` ${chalk.red('✗')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows operation header\r\n */\r\n static showOperationHeader(operationName: string, databaseName: string, icon: string = '🗑️'): void {\r\n console.log(`\\n${chalk.cyan(icon)} ${chalk.bold.green(operationName.toUpperCase())}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n console.log(`${chalk.blue('┌─')} ${chalk.bold(`Database: ${databaseName}`)}`);\r\n }\r\n\r\n /**\r\n * Shows comprehensive operation summary\r\n */\r\n static showOperationSummary(summary: ProcessSummary): void {\r\n const { startTime, totalProcessed, successCount, errorCount, processedItems, operationName, databaseName } = summary;\r\n const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);\r\n\r\n console.log(`\\n${chalk.cyan('📊')} ${chalk.bold.green(`SUMMARY OF ${operationName.toUpperCase()}`)}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n\r\n if (successCount > 0) {\r\n console.log(`${chalk.green('┌─')} ${chalk.bold('Successful processing:')}`);\r\n console.log(`${chalk.green('├─')} ${chalk.cyan(`Items processed: ${successCount}`)}`);\r\n console.log(`${chalk.green('├─')} ${chalk.gray(`Database: ${databaseName}`)}`);\r\n\r\n if (processedItems.length > 0) {\r\n console.log(`${chalk.green('├─')} ${chalk.yellow('Items updated:')}`);\r\n processedItems.forEach((item, index) => {\r\n const isLast = index === processedItems.length - 1;\r\n const connector = isLast ? '└─' : '├─';\r\n console.log(`${chalk.green('│ ')} ${chalk.gray(connector)} ${chalk.cyan(item)}`);\r\n });\r\n }\r\n }\r\n\r\n if (errorCount > 0) {\r\n console.log(`${chalk.red('├─')} ${chalk.bold.red(`Errors: ${errorCount}`)}`);\r\n }\r\n\r\n console.log(`${chalk.blue('├─')} ${chalk.gray(`Total time: ${totalTime}s`)}`);\r\n console.log(`${chalk.blue('└─')} ${chalk.bold(totalProcessed > 0 ? chalk.green('✅ Completed') : chalk.yellow('⚠️ No changes'))}`);\r\n\r\n // Show detailed errors section if there are errors\r\n if (summary.errors && summary.errors.length > 0) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n \r\n summary.errors.forEach((error, index) => {\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(error.error)}`);\r\n console.log('');\r\n \r\n if (error.filePath) {\r\n // Show code location with [code] tag format\r\n const location = error.lineNumber ? `${error.filePath}:${error.lineNumber}:7` : error.filePath;\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(location)}`);\r\n \r\n // Try to show code context if file exists\r\n UIUtils.showCodeContext(error.filePath, error.lineNumber || 1);\r\n }\r\n \r\n if (index < summary.errors.length - 1) {\r\n console.log('');\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shows code context around an error location\r\n */\r\n static showCodeContext(filePath: string, lineNumber: number, contextLines: number = 2): void {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n const startLine = Math.max(0, lineNumber - contextLines - 1);\r\n const endLine = Math.min(lines.length, lineNumber + contextLines);\r\n \r\n for (let i = startLine; i < endLine; i++) {\r\n const currentLineNum = i + 1;\r\n const line = lines[i];\r\n const lineNumStr = currentLineNum.toString().padStart(4, ' ');\r\n \r\n if (currentLineNum === lineNumber) {\r\n // Highlight the error line with arrow\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.red('<-')} ${chalk.white(line)}`);\r\n } else {\r\n // Normal context lines\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.white(line)}`);\r\n }\r\n }\r\n } catch (error) {\r\n // If we can't read the file, just skip showing context\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport { ProcessError } from './UIUtils';\r\n\r\nexport interface ValidationResult {\r\n isValid: boolean;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class CubeValidator {\r\n private validTypes = ['varchar', 'int', 'string', 'text', 'boolean', 'date', 'datetime', 'timestamp', 'decimal', 'float', 'double', 'enum', 'json'];\r\n private validOptions = ['not null', 'primary', 'autoincrement', 'unique', 'zerofill', 'index', 'required', 'unsigned'];\r\n private validProperties = ['type', 'length', 'options', 'value', 'defaultValue', 'foreign', 'enumValues', 'description'];\r\n private knownAnnotations = ['database', 'table', 'meta', 'columns', 'fields', 'dataset', 'beforeAdd', 'afterAdd', 'beforeUpdate', 'afterUpdate', 'beforeDelete', 'afterDelete', 'compute', 'column'];\r\n\r\n /**\r\n * Validates a cube file comprehensively\r\n */\r\n validateCubeFile(filePath: string): ValidationResult {\r\n const errors: ProcessError[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n const fileName = path.basename(filePath, path.extname(filePath));\r\n\r\n // Validate each line\r\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\r\n const line = lines[lineIndex];\r\n \r\n // Skip empty lines and comments\r\n if (line.trim() === '' || line.trim().startsWith('//')) {\r\n continue;\r\n }\r\n\r\n // Validate annotations\r\n this.validateAnnotations(line, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate data types\r\n this.validateDataTypes(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate column options\r\n this.validateColumnOptions(line, lineIndex + 1, filePath, fileName, errors, lines);\r\n \r\n // Validate column properties\r\n this.validateColumnProperties(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate required column properties\r\n this.validateRequiredColumnProperties(lines, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate general syntax\r\n this.validateGeneralSyntax(line, lineIndex + 1, filePath, fileName, errors);\r\n }\r\n\r\n // Validate overall structure\r\n this.validateOverallStructure(content, filePath, fileName, errors);\r\n\r\n } catch (error: any) {\r\n errors.push({\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Failed to read cube file: ${error.message}`,\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n return {\r\n isValid: errors.length === 0,\r\n errors\r\n };\r\n }\r\n\r\n private validateAnnotations(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Remove content inside strings to avoid false positives\r\n const lineWithoutStrings = line.replace(/\"[^\"]*\"/g, '\"\"').replace(/'[^']*'/g, \"''\");\r\n \r\n const annotationRegex = /@(\\w+)/g;\r\n let match;\r\n \r\n while ((match = annotationRegex.exec(lineWithoutStrings)) !== null) {\r\n const annotation = match[1];\r\n \r\n if (!this.knownAnnotations.includes(annotation)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Unknown annotation '@${annotation}'. Valid annotations: ${this.knownAnnotations.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateDataTypes(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const typeRegex = /type:\\s*[\"'](\\w+)[\"']/g;\r\n let match;\r\n \r\n while ((match = typeRegex.exec(line)) !== null) {\r\n const type = match[1];\r\n \r\n if (!this.validTypes.includes(type)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid data type '${type}'. Valid types: ${this.validTypes.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for varchar without length\r\n if (line.includes('type: \"varchar\"')) {\r\n const lines = content.split('\\n');\r\n const hasLengthNearby = lines.slice(Math.max(0, lineNumber - 1), Math.min(lineNumber + 4, lines.length))\r\n .some(nextLine => nextLine.includes('length:'));\r\n \r\n if (!hasLengthNearby) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'VARCHAR type requires a length specification',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateColumnOptions(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], lines: string[]): void {\r\n const optionsMatch = line.match(/^\\s*options\\s*:\\s*\\[(.*)\\]\\s*;?\\s*$/);\r\n if (!optionsMatch) return;\r\n\r\n const optionsContent = optionsMatch[1].trim();\r\n \r\n // Check for invalid syntax (values without quotes)\r\n const invalidSyntaxMatch = optionsContent.match(/[^\",\\s]+(?![^\"]*\")/);\r\n if (invalidSyntaxMatch) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid syntax '${invalidSyntaxMatch[0]}' in options array. All values must be quoted strings`,\r\n filePath,\r\n lineNumber\r\n });\r\n return;\r\n }\r\n\r\n // Extract individual options\r\n const optionMatches = optionsContent.match(/\"([^\"]*)\"/g);\r\n if (optionMatches) {\r\n // Get column type for compatibility checking\r\n const columnType = this.getColumnTypeForOptions(lines, lineNumber - 1);\r\n \r\n optionMatches.forEach(optionMatch => {\r\n const option = optionMatch.replace(/\"/g, '');\r\n \r\n if (option.trim() === '') {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Empty option found in options array. All options must have a value',\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (!this.validOptions.includes(option)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid option '${option}'. Valid options: ${this.validOptions.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (columnType !== 'unknown' && !this.isOptionCompatibleWithType(option, columnType)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Option '${option}' is not compatible with type '${columnType}'`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n });\r\n }\r\n }\r\n\r\n private validateColumnProperties(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const propertyKeyRegex = /^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:/;\r\n const propMatch = propertyKeyRegex.exec(line);\r\n \r\n if (!propMatch) return;\r\n\r\n const propertyName = propMatch[1];\r\n \r\n // Skip column definitions (they end with opening brace)\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n return;\r\n }\r\n\r\n // Check if we're inside a foreign key object\r\n if (this.isInsideForeignKeyObject(content, lineNumber - 1)) {\r\n // Inside foreign key object, validate foreign key properties\r\n const validForeignKeyProperties = ['table', 'column'];\r\n if (!validForeignKeyProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid foreign key property '${propertyName}'. Valid foreign key properties: ${validForeignKeyProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n return; // Skip other validation for foreign key properties\r\n }\r\n\r\n // Check if we're inside a columns block and validate property\r\n if (this.isInsideColumnsBlock(content, lineNumber - 1)) {\r\n if (!this.validProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid property '${propertyName}'. Valid properties: ${this.validProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for incomplete property declarations\r\n if (/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*$/.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Property '${propertyName}' is missing a value`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n private validateRequiredColumnProperties(lines: string[], lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const line = lines[lineNumber - 1];\r\n \r\n // Check if current line is the closing of a column definition\r\n if (!/^\\s*\\}\\s*;?\\s*$/.test(line)) {\r\n return;\r\n }\r\n\r\n // Find the start of this column definition\r\n let columnStartLine = -1;\r\n let columnName = '';\r\n \r\n for (let i = lineNumber - 2; i >= 0; i--) {\r\n const currentLine = lines[i];\r\n const columnDefMatch = currentLine.match(/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*\\{/);\r\n \r\n if (columnDefMatch) {\r\n // Verify this is the matching opening brace\r\n let openBraces = 0;\r\n let closeBraces = 0;\r\n \r\n for (let j = i; j < lineNumber; j++) {\r\n openBraces += (lines[j].match(/\\{/g) || []).length;\r\n closeBraces += (lines[j].match(/\\}/g) || []).length;\r\n }\r\n \r\n if (openBraces === closeBraces) {\r\n columnStartLine = i;\r\n columnName = columnDefMatch[1];\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (columnStartLine === -1 || !columnName) return;\r\n\r\n // Check for missing 'type' property\r\n let hasType = false;\r\n \r\n for (let i = columnStartLine + 1; i < lineNumber - 1; i++) {\r\n if (lines[i].match(/^\\s*type\\s*:/)) {\r\n hasType = true;\r\n break;\r\n }\r\n }\r\n \r\n if (!hasType && columnName !== 'foreign' && columnName !== 'defaultValue') {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Column '${columnName}' is missing required 'type' property`,\r\n filePath,\r\n lineNumber: columnStartLine + 1\r\n });\r\n }\r\n }\r\n\r\n private validateGeneralSyntax(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Check for mismatched quotes\r\n const quotes = line.match(/[\"']/g);\r\n if (quotes && quotes.length % 2 !== 0) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Mismatched quotes detected',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n\r\n // Check for invalid annotation syntax\r\n if (line.includes('@database') || line.includes('@table')) {\r\n const stringAnnotationRegex = /@(database|table)\\s*\\(\\s*\"([^\"]*)\"\\s*\\)/;\r\n if (!stringAnnotationRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid annotation syntax. Expected format: @annotation(\"value\")',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for @meta annotation syntax\r\n if (line.includes('@meta')) {\r\n const metaObjectRegex = /@meta\\s*\\(\\s*\\{/;\r\n if (!metaObjectRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid @meta syntax. Expected format: @meta({ ... })',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateOverallStructure(content: string, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const lines = content.split('\\n');\r\n \r\n // Check for required @database annotation\r\n const hasDatabase = lines.some(line => line.includes('@database'));\r\n if (!hasDatabase) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Missing required @database annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n // For table.cube files, check for @columns\r\n if (filePath.includes('.table.cube')) {\r\n const hasColumns = lines.some(line => line.includes('@columns'));\r\n if (!hasColumns) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Table cube files require @columns annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n }\r\n }\r\n\r\n private getColumnTypeForOptions(lines: string[], optionsLineIndex: number): string {\r\n // Look backwards from options line to find the type\r\n for (let i = optionsLineIndex - 1; i >= 0; i--) {\r\n const line = lines[i];\r\n const typeMatch = line.match(/^\\s*type\\s*:\\s*\"([^\"]+)\"/);\r\n if (typeMatch) {\r\n return typeMatch[1];\r\n }\r\n // Stop if we hit another column definition\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n break;\r\n }\r\n }\r\n return 'unknown';\r\n }\r\n\r\n private isOptionCompatibleWithType(option: string, type: string): boolean {\r\n const compatibilityRules: { [key: string]: string[] } = {\r\n \"zerofill\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"unsigned\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"autoincrement\": [\"int\"],\r\n \"primary\": [\"int\", \"varchar\", \"string\"],\r\n \"not null\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"],\r\n \"unique\": [\"int\", \"varchar\", \"string\", \"text\"],\r\n \"index\": [\"int\", \"varchar\", \"string\", \"text\", \"date\", \"datetime\", \"timestamp\"],\r\n \"required\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"]\r\n };\r\n \r\n const compatibleTypes = compatibilityRules[option];\r\n if (!compatibleTypes) {\r\n return true; // If not in rules, allow it\r\n }\r\n \r\n return compatibleTypes.includes(type);\r\n }\r\n\r\n private isInsideColumnsBlock(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Find @columns block boundaries\r\n let columnsStartLine = -1;\r\n let columnsEndLine = -1;\r\n \r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@columns')) {\r\n columnsStartLine = i;\r\n // Find the end of the @columns block\r\n let braceCount = 0;\r\n for (let j = i; j < lines.length; j++) {\r\n const currentLine = lines[j];\r\n braceCount += (currentLine.match(/\\{/g) || []).length;\r\n braceCount -= (currentLine.match(/\\}/g) || []).length;\r\n if (braceCount === 0 && j > i) {\r\n columnsEndLine = j;\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n \r\n return columnsStartLine !== -1 && columnsEndLine !== -1 && \r\n lineIndex > columnsStartLine && lineIndex < columnsEndLine;\r\n }\r\n\r\n private isInsideForeignKeyObject(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Look backwards from current line to find if we're inside a foreign object\r\n for (let i = lineIndex; i >= 0; i--) {\r\n const line = lines[i];\r\n \r\n // If we find a foreign: { on this line or above\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n // Count braces from the foreign line to current line to see if we're inside\r\n let braceCount = 0;\r\n \r\n // Start from the foreign line\r\n for (let j = i; j <= lineIndex; j++) {\r\n const currentLine = lines[j];\r\n \r\n // Count opening braces\r\n const openBraces = (currentLine.match(/\\{/g) || []).length;\r\n // Count closing braces\r\n const closeBraces = (currentLine.match(/\\}/g) || []).length;\r\n \r\n braceCount += openBraces - closeBraces;\r\n \r\n // If we've closed all braces, we're outside the foreign object\r\n if (braceCount === 0 && j > i) {\r\n return false;\r\n }\r\n }\r\n \r\n // If we still have open braces, we're inside the foreign object\r\n return braceCount > 0;\r\n }\r\n \r\n // If we find a closing brace before finding a foreign declaration,\r\n // we're not inside a foreign object\r\n if (line.trim() === '}' || line.includes('};')) {\r\n break;\r\n }\r\n }\r\n \r\n return false;\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\n\r\nexport interface TableDependency {\r\n tableName: string;\r\n filePath: string;\r\n dependencies: string[];\r\n}\r\n\r\nexport interface ExecutionOrder {\r\n tables: string[];\r\n seeders: string[];\r\n timestamp: string;\r\n}\r\n\r\nexport class DependencyResolver {\r\n \r\n /**\r\n * Resolves table dependencies and creates execution order\r\n */\r\n static resolveDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder' = 'table'): ExecutionOrder {\r\n const tableDependencies = this.extractDependencies(cubeFiles, cubeType);\r\n const orderedTables = this.topologicalSort(tableDependencies);\r\n \r\n const executionOrder: ExecutionOrder = {\r\n tables: cubeType === 'table' ? orderedTables : [],\r\n seeders: cubeType === 'seeder' ? orderedTables : [],\r\n timestamp: new Date().toISOString()\r\n };\r\n\r\n // Save the execution order file\r\n this.saveExecutionOrder(executionOrder);\r\n \r\n return executionOrder;\r\n }\r\n\r\n /**\r\n * Extracts dependencies from cube files\r\n */\r\n private static extractDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder'): TableDependency[] {\r\n const dependencies: TableDependency[] = [];\r\n\r\n for (const file of cubeFiles) {\r\n // Handle absolute paths and relative paths correctly\r\n let filePath: string;\r\n if (path.isAbsolute(file)) {\r\n filePath = file;\r\n } else if (fs.existsSync(file)) {\r\n // File exists in current directory\r\n filePath = path.resolve(file);\r\n } else {\r\n // Try the standard dbcube directory (files are now directly in dbcube folder)\r\n filePath = path.join(process.cwd(), 'dbcube', file);\r\n }\r\n \r\n try {\r\n // Extract table name\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n \r\n // Extract foreign key dependencies\r\n const deps = this.extractForeignKeyReferences(filePath);\r\n \r\n dependencies.push({\r\n tableName,\r\n filePath,\r\n dependencies: deps\r\n });\r\n } catch (error) {\r\n console.error(`Error processing ${filePath}:`, error);\r\n }\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Extracts foreign key references from a cube file\r\n */\r\n private static extractForeignKeyReferences(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n \r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n \r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n \r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n \r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n \r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading file ${filePath}:`, error);\r\n }\r\n \r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Performs topological sort to determine execution order\r\n */\r\n private static topologicalSort(dependencies: TableDependency[]): string[] {\r\n const graph = new Map<string, string[]>();\r\n const inDegree = new Map<string, number>();\r\n const tableMap = new Map<string, TableDependency>();\r\n \r\n // Build graph and initialize in-degree\r\n for (const dep of dependencies) {\r\n graph.set(dep.tableName, dep.dependencies);\r\n inDegree.set(dep.tableName, 0);\r\n tableMap.set(dep.tableName, dep);\r\n }\r\n \r\n // Calculate in-degrees\r\n for (const dep of dependencies) {\r\n for (const dependency of dep.dependencies) {\r\n if (inDegree.has(dependency)) {\r\n inDegree.set(dep.tableName, (inDegree.get(dep.tableName) || 0) + 1);\r\n }\r\n }\r\n }\r\n \r\n // Kahn's algorithm for topological sorting\r\n const queue: string[] = [];\r\n const result: string[] = [];\r\n \r\n // Find all nodes with no incoming edges\r\n for (const [table, degree] of inDegree) {\r\n if (degree === 0) {\r\n queue.push(table);\r\n }\r\n }\r\n \r\n while (queue.length > 0) {\r\n const current = queue.shift()!;\r\n result.push(current);\r\n \r\n const currentDeps = graph.get(current) || [];\r\n \r\n // For each neighbor, reduce in-degree\r\n for (const neighbor of currentDeps) {\r\n if (inDegree.has(neighbor)) {\r\n const newDegree = (inDegree.get(neighbor) || 0) - 1;\r\n inDegree.set(neighbor, newDegree);\r\n \r\n if (newDegree === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n }\r\n \r\n // Check for circular dependencies\r\n if (result.length !== dependencies.length) {\r\n // Add remaining tables that weren't processed due to circular dependencies\r\n for (const dep of dependencies) {\r\n if (!result.includes(dep.tableName)) {\r\n result.push(dep.tableName);\r\n }\r\n }\r\n }\r\n \r\n return result;\r\n }\r\n\r\n /**\r\n * Saves the execution order to .dbcube/orderexecute.json\r\n */\r\n private static saveExecutionOrder(order: ExecutionOrder): void {\r\n try {\r\n const projectRoot = process.cwd();\r\n const dbcubeDir = path.join(projectRoot, '.dbcube');\r\n const orderFile = path.join(dbcubeDir, 'orderexecute.json');\r\n \r\n // Create .dbcube directory if it doesn't exist\r\n if (!fs.existsSync(dbcubeDir)) {\r\n fs.mkdirSync(dbcubeDir, { recursive: true });\r\n }\r\n \r\n // Save the order file\r\n fs.writeFileSync(orderFile, JSON.stringify(order, null, 2), 'utf8');\r\n \r\n // Execution order saved silently\r\n } catch (error) {\r\n console.error('❌ Failed to save execution order:', error);\r\n }\r\n }\r\n\r\n /**\r\n * Loads the execution order from .dbcube/orderexecute.json\r\n */\r\n static loadExecutionOrder(): ExecutionOrder | null {\r\n try {\r\n const projectRoot = process.cwd();\r\n const orderFile = path.join(projectRoot, '.dbcube', 'orderexecute.json');\r\n \r\n if (!fs.existsSync(orderFile)) {\r\n return null;\r\n }\r\n \r\n const content = fs.readFileSync(orderFile, 'utf8');\r\n return JSON.parse(content);\r\n } catch (error) {\r\n console.error('❌ Failed to load execution order:', error);\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Orders cube files based on saved execution order\r\n */\r\n static orderCubeFiles(cubeFiles: string[], cubeType: 'table' | 'seeder'): string[] {\r\n const executionOrder = this.loadExecutionOrder();\r\n\r\n if (!executionOrder) {\r\n return cubeFiles;\r\n }\r\n\r\n // IMPORTANTE: Los seeders SIEMPRE usan el orden de las tablas\r\n // porque deben insertar datos respetando las foreign keys\r\n const orderList = executionOrder.tables;\r\n const orderedFiles: string[] = [];\r\n const fileMap = new Map<string, string>();\r\n\r\n // Create a map of table names to file paths\r\n for (const file of cubeFiles) {\r\n const filePath = path.isAbsolute(file) ? file : path.join(process.cwd(), 'dbcube', file);\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n fileMap.set(tableName, file);\r\n }\r\n\r\n // Order files according to execution order (using table order)\r\n for (const tableName of orderList) {\r\n if (fileMap.has(tableName)) {\r\n orderedFiles.push(fileMap.get(tableName)!);\r\n fileMap.delete(tableName);\r\n }\r\n }\r\n\r\n // Add any remaining files that weren't in the order\r\n for (const [, file] of fileMap) {\r\n orderedFiles.push(file);\r\n }\r\n\r\n // Using dependency order silently\r\n\r\n return orderedFiles;\r\n }\r\n}","import { Schema } from './lib/Schema';\r\nimport { CubeValidator } from './lib/CubeValidator';\r\nimport { UIUtils } from './lib/UIUtils';\r\nimport { DependencyResolver } from './lib/DependencyResolver';\r\n\r\nexport default Schema;\r\nexport { Schema, CubeValidator, UIUtils, DependencyResolver };"],"mappings":";AAAA,OAAOA,SAAQ;AACf,SAAS,QAAQ,gBAAgB,UAAU,mBAAmB;AAC9D,OAAOC,WAAU;;;ACFjB,YAAY,QAAQ;AACpB,YAAY,UAAU;AAEtB,IAAM,YAAN,MAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMd,aAAa,WAAW,UAA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,QAAI,OAAO;AACP,YAAM,CAAC,EAAE,UAAU,SAAS,SAAS,IAAI;AACzC,YAAM,UAAU,SAAS,SAAS,EAAE;AACpC,YAAM,gBAAgB,GAAG,QAAQ,IAAI,OAAO,IAAI,SAAS;AAGzD,cAAQ,IAAI,GAAGA,OAAM,KAAK,QAAQ,CAAC,IAAIA,OAAM,OAAO,aAAa,CAAC,EAAE;AAGpE,UAAI;AACA,cAAM,YAAYD,IAAG,aAAa,UAAU,OAAO,EAAE,MAAM,IAAI;AAC/D,cAAM,QAAQ,KAAK,IAAI,GAAG,UAAU,CAAC;AACrC,cAAM,MAAM,KAAK,IAAI,UAAU,QAAQ,UAAU,CAAC;AAElD,iBAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAC9B,gBAAM,OAAO,UAAU,CAAC;AACxB,gBAAM,YAAY,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,GAAG;AAC5C,gBAAM,UAAU,IAAI,MAAM,UAAU,GAAGC,OAAM,IAAI,IAAI,CAAC,KAAK;AAC3D,kBAAQ,IAAI,GAAGA,OAAM,KAAK,SAAS,CAAC,IAAI,OAAO,UAAUA,OAAM,MAAM,IAAI,CAAC,EAAE;AAAA,QAChF;AAAA,MACJ,SAASC,MAAK;AACV,gBAAQ,IAAID,OAAM,KAAK,kCAAkC,CAAC;AAAA,MAC9D;AAAA,IACJ;AAAA,EACJ;AAEA,UAAQ,IAAI,EAAE;AAClB;;;AKxxBA,IAAO,gBAAQ;","names":["fs","path","resolve","chalk","fs","resolve","fs","path","fs","path","path","fs","path","require","fs","chalk","err"]}
1
+ {"version":3,"sources":["../src/lib/Schema.ts","../src/lib/FileUtils.ts","../src/lib/UIUtils.ts","../src/lib/CubeValidator.ts","../src/lib/DependencyResolver.ts","../src/index.ts"],"sourcesContent":["import fs from 'fs';\r\nimport { Engine, TableProcessor, Config as ConfigClass } from \"@dbcube/core\";\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\nimport chalk from 'chalk';\r\nimport { UIUtils, ProcessSummary, ProcessError } from './UIUtils';\r\nimport { CubeValidator } from './CubeValidator';\r\nimport { DependencyResolver } from './DependencyResolver';\r\nimport { createRequire } from 'module';\r\n\r\n/**\r\n * Main class to handle MySQL database connections and queries.\r\n * Implements the Singleton pattern to ensure a single instance of the connection pool.\r\n */\r\nclass Schema {\r\n private name: string;\r\n private engine: any;\r\n\r\n constructor(name: string) {\r\n this.name = name;\r\n this.engine = new Engine(name);\r\n }\r\n\r\n /**\r\n * Validates cube file comprehensively including syntax, database configuration, and structure\r\n * @param filePath - Path to the cube file\r\n * @returns validation result with any errors found\r\n */\r\n private validateDatabaseConfiguration(filePath: string): { isValid: boolean; error?: ProcessError } {\r\n try {\r\n // First, perform comprehensive cube file validation\r\n const cubeValidator = new CubeValidator();\r\n const cubeValidation = cubeValidator.validateCubeFile(filePath);\r\n\r\n // If cube file has syntax errors, return the first one\r\n if (!cubeValidation.isValid && cubeValidation.errors.length > 0) {\r\n return {\r\n isValid: false,\r\n error: cubeValidation.errors[0] // Return the first error found\r\n };\r\n }\r\n\r\n // Extract database name from cube file\r\n const dbResult = FileUtils.extractDatabaseNameFromCube(filePath);\r\n if (dbResult.status !== 200) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Error reading database directive: ${dbResult.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n const cubeDbName = dbResult.message;\r\n\r\n // Get available configurations\r\n const configInstance = new ConfigClass();\r\n const configFilePath = path.resolve(process.cwd(), 'dbcube.config.js');\r\n\r\n // Use __filename for CJS, process.cwd() for ESM\r\n const requireUrl = typeof __filename !== 'undefined' ? __filename : process.cwd();\r\n const require = createRequire(requireUrl);\r\n // Clear require cache to ensure fresh load\r\n delete require.cache[require.resolve(configFilePath)];\r\n const configModule = require(configFilePath);\r\n const configFn = configModule.default || configModule;\r\n\r\n if (typeof configFn === 'function') {\r\n configFn(configInstance);\r\n } else {\r\n throw new Error('❌ The dbcube.config.js file does not export a function.');\r\n }\r\n\r\n // Check if the database configuration exists\r\n const dbConfig = configInstance.getDatabase(cubeDbName);\r\n if (!dbConfig) {\r\n // Try to get available databases by attempting to access common ones\r\n let availableDbs: string[] = [];\r\n try {\r\n // Try some common database names to see what exists\r\n const testNames = ['test', 'development', 'production', 'local', 'main'];\r\n for (const testName of testNames) {\r\n try {\r\n const testConfig = configInstance.getDatabase(testName);\r\n if (testConfig) {\r\n availableDbs.push(testName);\r\n }\r\n } catch (e) {\r\n // Skip non-existent configs\r\n }\r\n }\r\n } catch (e) {\r\n // Fallback if we can't determine available databases\r\n }\r\n\r\n const availableText = availableDbs.length > 0 ? availableDbs.join(', ') : 'none found';\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration '${cubeDbName}' not found in dbcube.config.js. Available: ${availableText}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n\r\n return { isValid: true };\r\n\r\n } catch (error: any) {\r\n return {\r\n isValid: false,\r\n error: {\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Database configuration validation failed: ${error.message}`,\r\n filePath,\r\n lineNumber: this.findDatabaseLineNumber(filePath)\r\n }\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Finds the line number where @database directive is located\r\n */\r\n private findDatabaseLineNumber(filePath: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@database')) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n /**\r\n * Extracts foreign key dependencies from a cube file\r\n */\r\n private extractForeignKeyDependencies(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n\r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n\r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n\r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n\r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n\r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n\r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading dependencies from ${filePath}:`, error);\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Finds the line number where a foreign key table reference is located\r\n */\r\n private findForeignKeyLineNumber(filePath: string, tableName: string): number {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes(`table: \"${tableName}\"`) || lines[i].includes(`table: '${tableName}'`)) {\r\n return i + 1; // Line numbers start at 1\r\n }\r\n }\r\n return 1;\r\n } catch {\r\n return 1;\r\n }\r\n }\r\n\r\n async createDatabase(): Promise<any> {\r\n const startTime = Date.now();\r\n const rootPath = path.resolve(process.cwd());\r\n\r\n // Show header\r\n UIUtils.showOperationHeader(' CREATING DATABASE', this.name, '🗄️');\r\n\r\n // Show progress for database creation\r\n await UIUtils.showItemProgress('Preparando e instalando base de datos', 1, 1);\r\n\r\n try {\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'create_database',\r\n '--path', rootPath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n }\r\n\r\n UIUtils.showItemSuccess('Database');\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 1,\r\n successCount: 1,\r\n errorCount: 0,\r\n processedItems: [this.name],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return response.data;\r\n\r\n } catch (error: any) {\r\n UIUtils.showItemError('Database', error.message);\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: 0,\r\n successCount: 0,\r\n errorCount: 1,\r\n processedItems: [],\r\n operationName: 'create database',\r\n databaseName: this.name,\r\n errors: []\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n throw error;\r\n }\r\n }\r\n\r\n async refreshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING REFRESH TABLES', this.name, '🔄');\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot refresh table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--mode', 'refresh',\r\n '--schema-path', filePath,\r\n ]);\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--mode', 'refresh',\r\n '--dml', parseJson,\r\n ]);\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n delete queries.data.database_type;\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'refresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'refresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async freshTables(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.table.cube');\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Resolve dependencies and create execution order\r\n DependencyResolver.resolveDependencies(cubeFiles, 'table');\r\n\r\n // Order files based on dependencies\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'table');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING FRESH TABLES', this.name);\r\n\r\n let totalTablesProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTables: string[] = [];\r\n const errors: ProcessError[] = [];\r\n const failedTables = new Set<string>(); // Track failed table names\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTableName = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = getTableName.status === 200 ? getTableName.message : path.basename(file, '.table.cube');\r\n\r\n // Show visual progress for each table\r\n await UIUtils.showItemProgress(tableName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(tableName, validation.error.error);\r\n errors.push(validation.error);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n // Check if any dependent tables failed\r\n const dependencies = this.extractForeignKeyDependencies(filePath);\r\n const missingDependencies = dependencies.filter(dep => failedTables.has(dep));\r\n\r\n if (missingDependencies.length > 0) {\r\n const dependencyError: ProcessError = {\r\n itemName: tableName,\r\n error: `Cannot create table '${tableName}' because it depends on failed table(s): ${missingDependencies.join(', ')}`,\r\n filePath,\r\n lineNumber: this.findForeignKeyLineNumber(filePath, missingDependencies[0])\r\n };\r\n UIUtils.showItemError(tableName, dependencyError.error);\r\n errors.push(dependencyError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const dml = await this.engine.run('schema_engine', [\r\n '--action', 'parse_table',\r\n '--schema-path', filePath,\r\n '--mode', 'fresh',\r\n ]);\r\n\r\n if (dml.status != 200) {\r\n returnFormattedError(dml.status, dml.message);\r\n break;\r\n }\r\n\r\n const parseJson = JSON.stringify(dml.data.actions).replace(/[\\r\\n\\t]/g, '').replace(/\\\\[rnt]/g, '').replace(/\\s{2,}/g, ' ');\r\n\r\n const queries = await this.engine.run('schema_engine', [\r\n '--action', 'generate',\r\n '--dml', parseJson,\r\n ]);\r\n\r\n if (queries.status != 200) {\r\n returnFormattedError(queries.status, queries.message);\r\n break;\r\n }\r\n\r\n delete queries.data._type;\r\n const createQuery = queries.data.regular_queries.filter((q: string) => q.includes(\"CREATE\"))[0];\r\n\r\n // For fresh mode, use the generated queries directly without alterations\r\n // generateAlterQueries is used for refresh mode, not fresh mode\r\n\r\n const parseJsonQueries = JSON.stringify(queries.data);\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'execute',\r\n '--mode', 'fresh',\r\n '--dml', parseJsonQueries,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n await TableProcessor.saveQuery(dml.data.table, dml.data.database, createQuery);\r\n\r\n UIUtils.showItemSuccess(tableName);\r\n successCount++;\r\n processedTables.push(tableName);\r\n totalTablesProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: tableName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(tableName, error.message);\r\n errors.push(processError);\r\n failedTables.add(tableName);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTablesProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTables,\r\n operationName: 'fresh tables',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTablesProcessed > 0 ? { processed: totalTablesProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n\r\n async executeSeeders(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.seeder.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Use existing table dependency order for seeders\r\n const orderedCubeFiles = DependencyResolver.orderCubeFiles(cubeFiles, 'seeder');\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING SEEDERS', this.name, '🌱');\r\n\r\n let totalSeedersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedSeeders: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < orderedCubeFiles.length; index++) {\r\n const file = orderedCubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getSeederName = FileUtils.extracTableNameFromCube(filePath);\r\n const seederName = getSeederName.status === 200 ? getSeederName.message : path.basename(file, '.seeder.cube');\r\n\r\n // Show visual progress for each seeder\r\n await UIUtils.showItemProgress(seederName, index + 1, orderedCubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(seederName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'seeder',\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(seederName);\r\n successCount++;\r\n processedSeeders.push(seederName);\r\n totalSeedersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: seederName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(seederName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalSeedersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedSeeders,\r\n operationName: 'seeders',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalSeedersProcessed > 0 ? { processed: totalSeedersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n\r\n async executeTriggers(): Promise<any> {\r\n const startTime = Date.now();\r\n const cubesDir = path.join(process.cwd(), 'dbcube');\r\n const triggersDirExit = path.join(process.cwd(), 'dbcube', 'triggers');\r\n\r\n // Verificar si la carpeta existe\r\n if (!fs.existsSync(cubesDir)) {\r\n throw new Error('❌ The cubes folder does not exist');\r\n }\r\n\r\n const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', '.trigger.cube');\r\n\r\n if (cubeFiles.length === 0) {\r\n throw new Error('❌ There are no cubes to execute');\r\n }\r\n\r\n // Show header\r\n UIUtils.showOperationHeader('EXECUTING TRIGGERS', this.name, '⚡');\r\n\r\n let totalTriggersProcessed = 0;\r\n let successCount = 0;\r\n let errorCount = 0;\r\n const processedTriggers: string[] = [];\r\n const errors: ProcessError[] = [];\r\n\r\n for (let index = 0; index < cubeFiles.length; index++) {\r\n const file = cubeFiles[index];\r\n const filePath = path.isAbsolute(file) ? file : path.join(cubesDir, file);\r\n const stats = fs.statSync(filePath);\r\n\r\n if (stats.isFile()) {\r\n const getTriggerName = FileUtils.extracTableNameFromCube(filePath);\r\n const triggerName = getTriggerName.status === 200 ? getTriggerName.message : path.basename(file, '.trigger.cube');\r\n\r\n // Show visual progress for each trigger\r\n await UIUtils.showItemProgress(triggerName, index + 1, cubeFiles.length);\r\n\r\n try {\r\n // Validate database configuration before processing\r\n const validation = this.validateDatabaseConfiguration(filePath);\r\n if (!validation.isValid && validation.error) {\r\n UIUtils.showItemError(triggerName, validation.error.error);\r\n errors.push(validation.error);\r\n errorCount++;\r\n continue;\r\n }\r\n\r\n const response = await this.engine.run('schema_engine', [\r\n '--action', 'trigger',\r\n '--path-exit', triggersDirExit,\r\n '--schema-path', filePath,\r\n ]);\r\n\r\n if (response.status != 200) {\r\n returnFormattedError(response.status, response.message);\r\n break;\r\n }\r\n\r\n UIUtils.showItemSuccess(triggerName);\r\n successCount++;\r\n processedTriggers.push(triggerName);\r\n totalTriggersProcessed++;\r\n\r\n } catch (error: any) {\r\n const processError: ProcessError = {\r\n itemName: triggerName,\r\n error: error.message,\r\n filePath\r\n };\r\n UIUtils.showItemError(triggerName, error.message);\r\n errors.push(processError);\r\n errorCount++;\r\n }\r\n }\r\n }\r\n\r\n // Show final summary\r\n const summary: ProcessSummary = {\r\n startTime,\r\n totalProcessed: totalTriggersProcessed,\r\n successCount,\r\n errorCount,\r\n processedItems: processedTriggers,\r\n operationName: 'triggers',\r\n databaseName: this.name,\r\n errors\r\n };\r\n UIUtils.showOperationSummary(summary);\r\n\r\n return totalTriggersProcessed > 0 ? { processed: totalTriggersProcessed, success: successCount, errors: errorCount } : null;\r\n }\r\n}\r\n\r\n\r\nfunction returnFormattedError(status: number, message: string) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(message)}`);\r\n console.log('');\r\n\r\n const err = new Error();\r\n const stackLines = err.stack?.split('\\n') || [];\r\n\r\n // Find the first stack line outside of node_modules\r\n const relevantStackLine = stackLines.find(line =>\r\n line.includes('.js:') && !line.includes('node_modules')\r\n );\r\n\r\n if (relevantStackLine) {\r\n const match = relevantStackLine.match(/\\((.*):(\\d+):(\\d+)\\)/) ||\r\n relevantStackLine.match(/at (.*):(\\d+):(\\d+)/);\r\n\r\n if (match) {\r\n const [, filePath, lineStr, columnStr] = match;\r\n const lineNum = parseInt(lineStr, 10);\r\n const errorLocation = `${filePath}:${lineStr}:${columnStr}`;\r\n\r\n // Show code location with [code] tag format\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(errorLocation)}`);\r\n\r\n // Show code context\r\n try {\r\n const codeLines = fs.readFileSync(filePath, 'utf-8').split('\\n');\r\n const start = Math.max(0, lineNum - 3);\r\n const end = Math.min(codeLines.length, lineNum + 2);\r\n\r\n for (let i = start; i < end; i++) {\r\n const line = codeLines[i];\r\n const lineLabel = `${i + 1}`.padStart(4, ' ');\r\n const pointer = i + 1 === lineNum ? `${chalk.red('<-')}` : ' ';\r\n console.log(`${chalk.gray(lineLabel)} ${pointer} ${chalk.white(line)}`);\r\n }\r\n } catch (err) {\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n }\r\n\r\n console.log('');\r\n}\r\n\r\nexport default Schema;\r\nexport { Schema };","import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nclass FileUtils {\r\n /**\r\n * Verifica si un archivo existe (asincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static async fileExists(filePath: string): Promise<boolean> {\r\n return new Promise((resolve) => {\r\n fs.access(path.resolve(filePath), fs.constants.F_OK, (err) => {\r\n resolve(!err);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Verifica si un archivo existe (sincrónico).\r\n * @param filePath - Ruta del archivo.\r\n * @returns True si el archivo existe, false si no.\r\n */\r\n static fileExistsSync(filePath: string): boolean {\r\n try {\r\n fs.accessSync(path.resolve(filePath), fs.constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }\r\n\r\n static extractDatabaseName(input: string): string | null {\r\n const match = input.match(/@database\\([\"']?([\\w-]+)[\"']?\\)/);\r\n return match ? match[1] : null;\r\n }\r\n\r\n /**\r\n * Lee recursivamente archivos que terminan en un sufijo dado y los ordena numéricamente.\r\n * @param dir - Directorio base (relativo o absoluto).\r\n * @param suffix - Sufijo de archivo (como 'table.cube').\r\n * @returns Rutas absolutas de los archivos encontrados y ordenados.\r\n */\r\n static getCubeFilesRecursively(dir: string, suffix: string): string[] {\r\n const baseDir = path.resolve(dir); // ✅ Asegura que sea absoluto\r\n const cubeFiles: string[] = [];\r\n\r\n function recurse(currentDir: string): void {\r\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\r\n\r\n for (const entry of entries) {\r\n const fullPath = path.join(currentDir, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n recurse(fullPath);\r\n } else if (entry.isFile() && entry.name.endsWith(suffix)) {\r\n cubeFiles.push(fullPath); // Ya es absoluta\r\n }\r\n }\r\n }\r\n\r\n recurse(baseDir);\r\n\r\n // Ordenar por número si los archivos comienzan con un número\r\n cubeFiles.sort((a, b) => {\r\n const aNum = parseInt(path.basename(a));\r\n const bNum = parseInt(path.basename(b));\r\n return (isNaN(aNum) ? 0 : aNum) - (isNaN(bNum) ? 0 : bNum);\r\n });\r\n\r\n return cubeFiles;\r\n }\r\n\r\n /**\r\n * Extracts database name from cube files\r\n * @param filePath - Path to the .cube file\r\n * @returns Object containing status and database name\r\n */\r\n static extractDatabaseNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n \r\n // Pattern: @database(\"database_name\") or @database('database_name')\r\n const databaseMatch = content.match(/@database\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)\\s*;?/);\r\n if (databaseMatch) {\r\n return {\r\n status: 200,\r\n message: databaseMatch[1]\r\n };\r\n }\r\n \r\n throw new Error(`No @database directive found in file ${filePath}`);\r\n \r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Extrae nombres de tablas reales de archivos .cube\r\n * @param {string} filePath - String ruta del archivo .cube\r\n * @returns {object} - Objeto que contiene el estado y el mensaje con el nombre de la tabla\r\n */\r\n static extracTableNameFromCube(filePath: string) {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n\r\n // Patrón principal: @meta({ name: \"nombre_tabla\"; }) o @meta({ name: 'nombre_tabla'; })\r\n const metaMatch = content.match(/@meta\\s*\\(\\s*\\{\\s*name\\s*:\\s*[\"']([^\"']+)[\"']\\s*;\\s*[^}]*\\}\\s*\\)/s);\r\n if (metaMatch) {\r\n return {\r\n status: 200,\r\n message: metaMatch[1]\r\n };\r\n }\r\n\r\n throw new Error(`Error to execute this file ${filePath} because no exist a name of table.`);\r\n\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n return {\r\n status: 500,\r\n message: error.message\r\n };\r\n }\r\n return {\r\n status: 500,\r\n message: String(error)\r\n };\r\n }\r\n }\r\n}\r\n\r\nexport default FileUtils;","import chalk from 'chalk';\r\nimport fs from 'fs';\r\n\r\nexport interface ProcessError {\r\n itemName: string;\r\n error: string;\r\n filePath?: string;\r\n lineNumber?: number;\r\n}\r\n\r\nexport interface ProcessSummary {\r\n startTime: number;\r\n totalProcessed: number;\r\n successCount: number;\r\n errorCount: number;\r\n processedItems: string[];\r\n operationName: string;\r\n databaseName: string;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class UIUtils {\r\n /**\r\n * Shows animated progress for processing items\r\n */\r\n static async showItemProgress(\r\n itemName: string,\r\n current: number,\r\n total: number\r\n ): Promise<void> {\r\n // Get console width, default to 80 if not available\r\n const consoleWidth = process.stdout.columns || 80;\r\n\r\n // Calculate available space for dots\r\n // Format: \"├─ itemName \" + dots + \" ✓ OK\"\r\n const prefix = `├─ ${itemName} `;\r\n const suffix = ` ✓ OK`;\r\n const availableSpace = consoleWidth - prefix.length - suffix.length;\r\n const maxDots = Math.max(10, availableSpace); // Minimum 10 dots\r\n\r\n return new Promise((resolve) => {\r\n process.stdout.write(`${chalk.blue('├─')} ${chalk.cyan(itemName)} `);\r\n\r\n let dotCount = 0;\r\n const interval = setInterval(() => {\r\n if (dotCount < maxDots) {\r\n process.stdout.write(chalk.gray('.'));\r\n dotCount++;\r\n } else {\r\n clearInterval(interval);\r\n resolve();\r\n }\r\n }, 10); // Faster animation\r\n });\r\n }\r\n\r\n /**\r\n * Shows success for a processed item\r\n */\r\n static showItemSuccess(itemName: string): void {\r\n process.stdout.write(` ${chalk.green('✓')} ${chalk.gray('OK')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows error for an item (simplified - only shows X)\r\n */\r\n static showItemError(itemName: string, error: string): void {\r\n process.stdout.write(` ${chalk.red('✗')}\\n`);\r\n }\r\n\r\n /**\r\n * Shows operation header\r\n */\r\n static showOperationHeader(operationName: string, databaseName: string, icon: string = '🗑️'): void {\r\n console.log(`\\n${chalk.cyan(icon)} ${chalk.bold.green(operationName.toUpperCase())}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n console.log(`${chalk.blue('┌─')} ${chalk.bold(`Database: ${databaseName}`)}`);\r\n }\r\n\r\n /**\r\n * Shows comprehensive operation summary\r\n */\r\n static showOperationSummary(summary: ProcessSummary): void {\r\n const { startTime, totalProcessed, successCount, errorCount, processedItems, operationName, databaseName } = summary;\r\n const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);\r\n\r\n console.log(`\\n${chalk.cyan('📊')} ${chalk.bold.green(`SUMMARY OF ${operationName.toUpperCase()}`)}`);\r\n console.log(chalk.gray('─'.repeat(60)));\r\n\r\n if (successCount > 0) {\r\n console.log(`${chalk.green('┌─')} ${chalk.bold('Successful processing:')}`);\r\n console.log(`${chalk.green('├─')} ${chalk.cyan(`Items processed: ${successCount}`)}`);\r\n console.log(`${chalk.green('├─')} ${chalk.gray(`Database: ${databaseName}`)}`);\r\n\r\n if (processedItems.length > 0) {\r\n console.log(`${chalk.green('├─')} ${chalk.yellow('Items updated:')}`);\r\n processedItems.forEach((item, index) => {\r\n const isLast = index === processedItems.length - 1;\r\n const connector = isLast ? '└─' : '├─';\r\n console.log(`${chalk.green('│ ')} ${chalk.gray(connector)} ${chalk.cyan(item)}`);\r\n });\r\n }\r\n }\r\n\r\n if (errorCount > 0) {\r\n console.log(`${chalk.red('├─')} ${chalk.bold.red(`Errors: ${errorCount}`)}`);\r\n }\r\n\r\n console.log(`${chalk.blue('├─')} ${chalk.gray(`Total time: ${totalTime}s`)}`);\r\n console.log(`${chalk.blue('└─')} ${chalk.bold(totalProcessed > 0 ? chalk.green('✅ Completed') : chalk.yellow('⚠️ No changes'))}`);\r\n\r\n // Show detailed errors section if there are errors\r\n if (summary.errors && summary.errors.length > 0) {\r\n console.log(`\\n${chalk.red('🚫')} ${chalk.bold.red('ERRORS FOUND')}`);\r\n console.log(chalk.red('─'.repeat(60)));\r\n \r\n summary.errors.forEach((error, index) => {\r\n // Show error with [error] tag format\r\n console.log(`${chalk.red('[error]')} ${chalk.red(error.error)}`);\r\n console.log('');\r\n \r\n if (error.filePath) {\r\n // Show code location with [code] tag format\r\n const location = error.lineNumber ? `${error.filePath}:${error.lineNumber}:7` : error.filePath;\r\n console.log(`${chalk.cyan('[code]')} ${chalk.yellow(location)}`);\r\n \r\n // Try to show code context if file exists\r\n UIUtils.showCodeContext(error.filePath, error.lineNumber || 1);\r\n }\r\n \r\n if (index < summary.errors.length - 1) {\r\n console.log('');\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Shows code context around an error location\r\n */\r\n static showCodeContext(filePath: string, lineNumber: number, contextLines: number = 2): void {\r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n const startLine = Math.max(0, lineNumber - contextLines - 1);\r\n const endLine = Math.min(lines.length, lineNumber + contextLines);\r\n \r\n for (let i = startLine; i < endLine; i++) {\r\n const currentLineNum = i + 1;\r\n const line = lines[i];\r\n const lineNumStr = currentLineNum.toString().padStart(4, ' ');\r\n \r\n if (currentLineNum === lineNumber) {\r\n // Highlight the error line with arrow\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.red('<-')} ${chalk.white(line)}`);\r\n } else {\r\n // Normal context lines\r\n console.log(`${chalk.gray(lineNumStr)} ${chalk.white(line)}`);\r\n }\r\n }\r\n } catch (error) {\r\n // If we can't read the file, just skip showing context\r\n console.log(chalk.gray(' (unable to show code context)'));\r\n }\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport { ProcessError } from './UIUtils';\r\n\r\nexport interface ValidationResult {\r\n isValid: boolean;\r\n errors: ProcessError[];\r\n}\r\n\r\nexport class CubeValidator {\r\n private validTypes = ['varchar', 'int', 'string', 'text', 'boolean', 'date', 'datetime', 'timestamp', 'decimal', 'float', 'double', 'enum', 'json'];\r\n private validOptions = ['not null', 'primary', 'autoincrement', 'unique', 'zerofill', 'index', 'required', 'unsigned'];\r\n private validProperties = ['type', 'length', 'options', 'value', 'defaultValue', 'foreign', 'enumValues', 'description'];\r\n private knownAnnotations = ['database', 'table', 'meta', 'columns', 'fields', 'dataset', 'beforeAdd', 'afterAdd', 'beforeUpdate', 'afterUpdate', 'beforeDelete', 'afterDelete', 'compute', 'column'];\r\n\r\n /**\r\n * Validates a cube file comprehensively\r\n */\r\n validateCubeFile(filePath: string): ValidationResult {\r\n const errors: ProcessError[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n const fileName = path.basename(filePath, path.extname(filePath));\r\n\r\n // Validate each line\r\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\r\n const line = lines[lineIndex];\r\n \r\n // Skip empty lines and comments\r\n if (line.trim() === '' || line.trim().startsWith('//')) {\r\n continue;\r\n }\r\n\r\n // Validate annotations\r\n this.validateAnnotations(line, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate data types\r\n this.validateDataTypes(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate column options\r\n this.validateColumnOptions(line, lineIndex + 1, filePath, fileName, errors, lines);\r\n \r\n // Validate column properties\r\n this.validateColumnProperties(line, lineIndex + 1, filePath, fileName, errors, content);\r\n \r\n // Validate required column properties\r\n this.validateRequiredColumnProperties(lines, lineIndex + 1, filePath, fileName, errors);\r\n \r\n // Validate general syntax\r\n this.validateGeneralSyntax(line, lineIndex + 1, filePath, fileName, errors);\r\n }\r\n\r\n // Validate overall structure\r\n this.validateOverallStructure(content, filePath, fileName, errors);\r\n\r\n } catch (error: any) {\r\n errors.push({\r\n itemName: path.basename(filePath, path.extname(filePath)),\r\n error: `Failed to read cube file: ${error.message}`,\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n return {\r\n isValid: errors.length === 0,\r\n errors\r\n };\r\n }\r\n\r\n private validateAnnotations(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Remove content inside strings to avoid false positives\r\n const lineWithoutStrings = line.replace(/\"[^\"]*\"/g, '\"\"').replace(/'[^']*'/g, \"''\");\r\n \r\n const annotationRegex = /@(\\w+)/g;\r\n let match;\r\n \r\n while ((match = annotationRegex.exec(lineWithoutStrings)) !== null) {\r\n const annotation = match[1];\r\n \r\n if (!this.knownAnnotations.includes(annotation)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Unknown annotation '@${annotation}'. Valid annotations: ${this.knownAnnotations.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateDataTypes(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const typeRegex = /type:\\s*[\"'](\\w+)[\"']/g;\r\n let match;\r\n \r\n while ((match = typeRegex.exec(line)) !== null) {\r\n const type = match[1];\r\n \r\n if (!this.validTypes.includes(type)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid data type '${type}'. Valid types: ${this.validTypes.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for varchar without length\r\n if (line.includes('type: \"varchar\"')) {\r\n const lines = content.split('\\n');\r\n const hasLengthNearby = lines.slice(Math.max(0, lineNumber - 1), Math.min(lineNumber + 4, lines.length))\r\n .some(nextLine => nextLine.includes('length:'));\r\n \r\n if (!hasLengthNearby) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'VARCHAR type requires a length specification',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateColumnOptions(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], lines: string[]): void {\r\n const optionsMatch = line.match(/^\\s*options\\s*:\\s*\\[(.*)\\]\\s*;?\\s*$/);\r\n if (!optionsMatch) return;\r\n\r\n const optionsContent = optionsMatch[1].trim();\r\n \r\n // Check for invalid syntax (values without quotes)\r\n const invalidSyntaxMatch = optionsContent.match(/[^\",\\s]+(?![^\"]*\")/);\r\n if (invalidSyntaxMatch) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid syntax '${invalidSyntaxMatch[0]}' in options array. All values must be quoted strings`,\r\n filePath,\r\n lineNumber\r\n });\r\n return;\r\n }\r\n\r\n // Extract individual options\r\n const optionMatches = optionsContent.match(/\"([^\"]*)\"/g);\r\n if (optionMatches) {\r\n // Get column type for compatibility checking\r\n const columnType = this.getColumnTypeForOptions(lines, lineNumber - 1);\r\n \r\n optionMatches.forEach(optionMatch => {\r\n const option = optionMatch.replace(/\"/g, '');\r\n \r\n if (option.trim() === '') {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Empty option found in options array. All options must have a value',\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (!this.validOptions.includes(option)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid option '${option}'. Valid options: ${this.validOptions.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n } else if (columnType !== 'unknown' && !this.isOptionCompatibleWithType(option, columnType)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Option '${option}' is not compatible with type '${columnType}'`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n });\r\n }\r\n }\r\n\r\n private validateColumnProperties(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[], content: string): void {\r\n const propertyKeyRegex = /^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:/;\r\n const propMatch = propertyKeyRegex.exec(line);\r\n \r\n if (!propMatch) return;\r\n\r\n const propertyName = propMatch[1];\r\n \r\n // Skip column definitions (they end with opening brace)\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n return;\r\n }\r\n\r\n // Check if we're inside a foreign key object\r\n if (this.isInsideForeignKeyObject(content, lineNumber - 1)) {\r\n // Inside foreign key object, validate foreign key properties\r\n const validForeignKeyProperties = ['table', 'column'];\r\n if (!validForeignKeyProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid foreign key property '${propertyName}'. Valid foreign key properties: ${validForeignKeyProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n return; // Skip other validation for foreign key properties\r\n }\r\n\r\n // Check if we're inside a columns block and validate property\r\n if (this.isInsideColumnsBlock(content, lineNumber - 1)) {\r\n if (!this.validProperties.includes(propertyName)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Invalid property '${propertyName}'. Valid properties: ${this.validProperties.join(', ')}`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for incomplete property declarations\r\n if (/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*$/.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Property '${propertyName}' is missing a value`,\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n private validateRequiredColumnProperties(lines: string[], lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const line = lines[lineNumber - 1];\r\n \r\n // Check if current line is the closing of a column definition\r\n if (!/^\\s*\\}\\s*;?\\s*$/.test(line)) {\r\n return;\r\n }\r\n\r\n // Find the start of this column definition\r\n let columnStartLine = -1;\r\n let columnName = '';\r\n \r\n for (let i = lineNumber - 2; i >= 0; i--) {\r\n const currentLine = lines[i];\r\n const columnDefMatch = currentLine.match(/^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*:\\s*\\{/);\r\n \r\n if (columnDefMatch) {\r\n // Verify this is the matching opening brace\r\n let openBraces = 0;\r\n let closeBraces = 0;\r\n \r\n for (let j = i; j < lineNumber; j++) {\r\n openBraces += (lines[j].match(/\\{/g) || []).length;\r\n closeBraces += (lines[j].match(/\\}/g) || []).length;\r\n }\r\n \r\n if (openBraces === closeBraces) {\r\n columnStartLine = i;\r\n columnName = columnDefMatch[1];\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (columnStartLine === -1 || !columnName) return;\r\n\r\n // Check for missing 'type' property\r\n let hasType = false;\r\n \r\n for (let i = columnStartLine + 1; i < lineNumber - 1; i++) {\r\n if (lines[i].match(/^\\s*type\\s*:/)) {\r\n hasType = true;\r\n break;\r\n }\r\n }\r\n \r\n if (!hasType && columnName !== 'foreign' && columnName !== 'defaultValue') {\r\n errors.push({\r\n itemName: fileName,\r\n error: `Column '${columnName}' is missing required 'type' property`,\r\n filePath,\r\n lineNumber: columnStartLine + 1\r\n });\r\n }\r\n }\r\n\r\n private validateGeneralSyntax(line: string, lineNumber: number, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n // Check for mismatched quotes\r\n const quotes = line.match(/[\"']/g);\r\n if (quotes && quotes.length % 2 !== 0) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Mismatched quotes detected',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n\r\n // Check for invalid annotation syntax\r\n if (line.includes('@database') || line.includes('@table')) {\r\n const stringAnnotationRegex = /@(database|table)\\s*\\(\\s*\"([^\"]*)\"\\s*\\)/;\r\n if (!stringAnnotationRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid annotation syntax. Expected format: @annotation(\"value\")',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n\r\n // Check for @meta annotation syntax\r\n if (line.includes('@meta')) {\r\n const metaObjectRegex = /@meta\\s*\\(\\s*\\{/;\r\n if (!metaObjectRegex.test(line)) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Invalid @meta syntax. Expected format: @meta({ ... })',\r\n filePath,\r\n lineNumber\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateOverallStructure(content: string, filePath: string, fileName: string, errors: ProcessError[]): void {\r\n const lines = content.split('\\n');\r\n \r\n // Check for required @database annotation\r\n const hasDatabase = lines.some(line => line.includes('@database'));\r\n if (!hasDatabase) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Missing required @database annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n\r\n // For table.cube files, check for @columns\r\n if (filePath.includes('.table.cube')) {\r\n const hasColumns = lines.some(line => line.includes('@columns'));\r\n if (!hasColumns) {\r\n errors.push({\r\n itemName: fileName,\r\n error: 'Table cube files require @columns annotation',\r\n filePath,\r\n lineNumber: 1\r\n });\r\n }\r\n }\r\n }\r\n\r\n private getColumnTypeForOptions(lines: string[], optionsLineIndex: number): string {\r\n // Look backwards from options line to find the type\r\n for (let i = optionsLineIndex - 1; i >= 0; i--) {\r\n const line = lines[i];\r\n const typeMatch = line.match(/^\\s*type\\s*:\\s*\"([^\"]+)\"/);\r\n if (typeMatch) {\r\n return typeMatch[1];\r\n }\r\n // Stop if we hit another column definition\r\n if (/^\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*:\\s*\\{/.test(line)) {\r\n break;\r\n }\r\n }\r\n return 'unknown';\r\n }\r\n\r\n private isOptionCompatibleWithType(option: string, type: string): boolean {\r\n const compatibilityRules: { [key: string]: string[] } = {\r\n \"zerofill\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"unsigned\": [\"int\", \"decimal\", \"float\", \"double\"],\r\n \"autoincrement\": [\"int\"],\r\n \"primary\": [\"int\", \"varchar\", \"string\"],\r\n \"not null\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"],\r\n \"unique\": [\"int\", \"varchar\", \"string\", \"text\"],\r\n \"index\": [\"int\", \"varchar\", \"string\", \"text\", \"date\", \"datetime\", \"timestamp\"],\r\n \"required\": [\"int\", \"varchar\", \"string\", \"text\", \"boolean\", \"date\", \"datetime\", \"timestamp\", \"decimal\", \"float\", \"double\"]\r\n };\r\n \r\n const compatibleTypes = compatibilityRules[option];\r\n if (!compatibleTypes) {\r\n return true; // If not in rules, allow it\r\n }\r\n \r\n return compatibleTypes.includes(type);\r\n }\r\n\r\n private isInsideColumnsBlock(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Find @columns block boundaries\r\n let columnsStartLine = -1;\r\n let columnsEndLine = -1;\r\n \r\n for (let i = 0; i < lines.length; i++) {\r\n if (lines[i].includes('@columns')) {\r\n columnsStartLine = i;\r\n // Find the end of the @columns block\r\n let braceCount = 0;\r\n for (let j = i; j < lines.length; j++) {\r\n const currentLine = lines[j];\r\n braceCount += (currentLine.match(/\\{/g) || []).length;\r\n braceCount -= (currentLine.match(/\\}/g) || []).length;\r\n if (braceCount === 0 && j > i) {\r\n columnsEndLine = j;\r\n break;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n \r\n return columnsStartLine !== -1 && columnsEndLine !== -1 && \r\n lineIndex > columnsStartLine && lineIndex < columnsEndLine;\r\n }\r\n\r\n private isInsideForeignKeyObject(content: string, lineIndex: number): boolean {\r\n const lines = content.split('\\n');\r\n \r\n // Look backwards from current line to find if we're inside a foreign object\r\n for (let i = lineIndex; i >= 0; i--) {\r\n const line = lines[i];\r\n \r\n // If we find a foreign: { on this line or above\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n // Count braces from the foreign line to current line to see if we're inside\r\n let braceCount = 0;\r\n \r\n // Start from the foreign line\r\n for (let j = i; j <= lineIndex; j++) {\r\n const currentLine = lines[j];\r\n \r\n // Count opening braces\r\n const openBraces = (currentLine.match(/\\{/g) || []).length;\r\n // Count closing braces\r\n const closeBraces = (currentLine.match(/\\}/g) || []).length;\r\n \r\n braceCount += openBraces - closeBraces;\r\n \r\n // If we've closed all braces, we're outside the foreign object\r\n if (braceCount === 0 && j > i) {\r\n return false;\r\n }\r\n }\r\n \r\n // If we still have open braces, we're inside the foreign object\r\n return braceCount > 0;\r\n }\r\n \r\n // If we find a closing brace before finding a foreign declaration,\r\n // we're not inside a foreign object\r\n if (line.trim() === '}' || line.includes('};')) {\r\n break;\r\n }\r\n }\r\n \r\n return false;\r\n }\r\n}","import fs from 'fs';\r\nimport path from 'path';\r\nimport FileUtils from './FileUtils';\r\n\r\nexport interface TableDependency {\r\n tableName: string;\r\n filePath: string;\r\n dependencies: string[];\r\n}\r\n\r\nexport interface ExecutionOrder {\r\n tables: string[];\r\n seeders: string[];\r\n timestamp: string;\r\n}\r\n\r\nexport class DependencyResolver {\r\n \r\n /**\r\n * Resolves table dependencies and creates execution order\r\n */\r\n static resolveDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder' = 'table'): ExecutionOrder {\r\n const tableDependencies = this.extractDependencies(cubeFiles, cubeType);\r\n const orderedTables = this.topologicalSort(tableDependencies);\r\n \r\n const executionOrder: ExecutionOrder = {\r\n tables: cubeType === 'table' ? orderedTables : [],\r\n seeders: cubeType === 'seeder' ? orderedTables : [],\r\n timestamp: new Date().toISOString()\r\n };\r\n\r\n // Save the execution order file\r\n this.saveExecutionOrder(executionOrder);\r\n \r\n return executionOrder;\r\n }\r\n\r\n /**\r\n * Extracts dependencies from cube files\r\n */\r\n private static extractDependencies(cubeFiles: string[], cubeType: 'table' | 'seeder'): TableDependency[] {\r\n const dependencies: TableDependency[] = [];\r\n\r\n for (const file of cubeFiles) {\r\n // Handle absolute paths and relative paths correctly\r\n let filePath: string;\r\n if (path.isAbsolute(file)) {\r\n filePath = file;\r\n } else if (fs.existsSync(file)) {\r\n // File exists in current directory\r\n filePath = path.resolve(file);\r\n } else {\r\n // Try the standard dbcube directory (files are now directly in dbcube folder)\r\n filePath = path.join(process.cwd(), 'dbcube', file);\r\n }\r\n \r\n try {\r\n // Extract table name\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n \r\n // Extract foreign key dependencies\r\n const deps = this.extractForeignKeyReferences(filePath);\r\n \r\n dependencies.push({\r\n tableName,\r\n filePath,\r\n dependencies: deps\r\n });\r\n } catch (error) {\r\n console.error(`Error processing ${filePath}:`, error);\r\n }\r\n }\r\n\r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Extracts foreign key references from a cube file\r\n */\r\n private static extractForeignKeyReferences(filePath: string): string[] {\r\n const dependencies: string[] = [];\r\n \r\n try {\r\n const content = fs.readFileSync(filePath, 'utf8');\r\n const lines = content.split('\\n');\r\n \r\n let insideForeignKey = false;\r\n let braceCount = 0;\r\n \r\n for (const line of lines) {\r\n // Check for foreign key start\r\n if (/foreign\\s*:\\s*\\{/.test(line)) {\r\n insideForeignKey = true;\r\n braceCount = 1;\r\n \r\n // Check if table is on the same line\r\n const sameLineMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (sameLineMatch) {\r\n dependencies.push(sameLineMatch[1]);\r\n insideForeignKey = false;\r\n braceCount = 0;\r\n }\r\n continue;\r\n }\r\n \r\n if (insideForeignKey) {\r\n // Count braces to track if we're still inside the foreign object\r\n braceCount += (line.match(/\\{/g) || []).length;\r\n braceCount -= (line.match(/\\}/g) || []).length;\r\n \r\n // Look for table reference\r\n const tableMatch = line.match(/table\\s*:\\s*[\"']([^\"']+)[\"']/);\r\n if (tableMatch) {\r\n dependencies.push(tableMatch[1]);\r\n }\r\n \r\n // If braces are balanced, we're out of the foreign object\r\n if (braceCount === 0) {\r\n insideForeignKey = false;\r\n }\r\n }\r\n }\r\n } catch (error) {\r\n console.error(`Error reading file ${filePath}:`, error);\r\n }\r\n \r\n return dependencies;\r\n }\r\n\r\n /**\r\n * Performs topological sort to determine execution order\r\n */\r\n private static topologicalSort(dependencies: TableDependency[]): string[] {\r\n const graph = new Map<string, string[]>();\r\n const inDegree = new Map<string, number>();\r\n const tableMap = new Map<string, TableDependency>();\r\n\r\n // Initialize graph and in-degree for all tables\r\n for (const dep of dependencies) {\r\n if (!graph.has(dep.tableName)) {\r\n graph.set(dep.tableName, []);\r\n }\r\n inDegree.set(dep.tableName, 0);\r\n tableMap.set(dep.tableName, dep);\r\n }\r\n\r\n // Build reverse graph: for each table that A depends on, add A as a dependent of that table\r\n // This allows Kahn's algorithm to work: when we process a table, we can reduce\r\n // the in-degree of all tables that depend on it\r\n for (const dep of dependencies) {\r\n for (const dependency of dep.dependencies) {\r\n // If dependency exists in our table list, add edge: dependency -> dep.tableName\r\n if (inDegree.has(dependency)) {\r\n if (!graph.has(dependency)) {\r\n graph.set(dependency, []);\r\n }\r\n graph.get(dependency)!.push(dep.tableName);\r\n // Increase in-degree of the table that has the dependency\r\n inDegree.set(dep.tableName, (inDegree.get(dep.tableName) || 0) + 1);\r\n }\r\n }\r\n }\r\n \r\n // Kahn's algorithm for topological sorting\r\n const queue: string[] = [];\r\n const result: string[] = [];\r\n \r\n // Find all nodes with no incoming edges\r\n for (const [table, degree] of inDegree) {\r\n if (degree === 0) {\r\n queue.push(table);\r\n }\r\n }\r\n \r\n while (queue.length > 0) {\r\n const current = queue.shift()!;\r\n result.push(current);\r\n \r\n const currentDeps = graph.get(current) || [];\r\n \r\n // For each neighbor, reduce in-degree\r\n for (const neighbor of currentDeps) {\r\n if (inDegree.has(neighbor)) {\r\n const newDegree = (inDegree.get(neighbor) || 0) - 1;\r\n inDegree.set(neighbor, newDegree);\r\n \r\n if (newDegree === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n }\r\n \r\n // Check for circular dependencies\r\n if (result.length !== dependencies.length) {\r\n // Add remaining tables that weren't processed due to circular dependencies\r\n for (const dep of dependencies) {\r\n if (!result.includes(dep.tableName)) {\r\n result.push(dep.tableName);\r\n }\r\n }\r\n }\r\n \r\n return result;\r\n }\r\n\r\n /**\r\n * Saves the execution order to .dbcube/orderexecute.json\r\n */\r\n private static saveExecutionOrder(order: ExecutionOrder): void {\r\n try {\r\n const projectRoot = process.cwd();\r\n const dbcubeDir = path.join(projectRoot, '.dbcube');\r\n const orderFile = path.join(dbcubeDir, 'orderexecute.json');\r\n \r\n // Create .dbcube directory if it doesn't exist\r\n if (!fs.existsSync(dbcubeDir)) {\r\n fs.mkdirSync(dbcubeDir, { recursive: true });\r\n }\r\n \r\n // Save the order file\r\n fs.writeFileSync(orderFile, JSON.stringify(order, null, 2), 'utf8');\r\n \r\n // Execution order saved silently\r\n } catch (error) {\r\n console.error('❌ Failed to save execution order:', error);\r\n }\r\n }\r\n\r\n /**\r\n * Loads the execution order from .dbcube/orderexecute.json\r\n */\r\n static loadExecutionOrder(): ExecutionOrder | null {\r\n try {\r\n const projectRoot = process.cwd();\r\n const orderFile = path.join(projectRoot, '.dbcube', 'orderexecute.json');\r\n \r\n if (!fs.existsSync(orderFile)) {\r\n return null;\r\n }\r\n \r\n const content = fs.readFileSync(orderFile, 'utf8');\r\n return JSON.parse(content);\r\n } catch (error) {\r\n console.error('❌ Failed to load execution order:', error);\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Orders cube files based on saved execution order\r\n */\r\n static orderCubeFiles(cubeFiles: string[], cubeType: 'table' | 'seeder'): string[] {\r\n const executionOrder = this.loadExecutionOrder();\r\n\r\n if (!executionOrder) {\r\n return cubeFiles;\r\n }\r\n\r\n // IMPORTANTE: Los seeders SIEMPRE usan el orden de las tablas\r\n // porque deben insertar datos respetando las foreign keys\r\n const orderList = executionOrder.tables;\r\n const orderedFiles: string[] = [];\r\n const fileMap = new Map<string, string>();\r\n\r\n // Create a map of table names to file paths\r\n for (const file of cubeFiles) {\r\n const filePath = path.isAbsolute(file) ? file : path.join(process.cwd(), 'dbcube', file);\r\n const tableNameResult = FileUtils.extracTableNameFromCube(filePath);\r\n const tableName = tableNameResult.status === 200 ? tableNameResult.message : path.basename(file, `.${cubeType}.cube`);\r\n fileMap.set(tableName, file);\r\n }\r\n\r\n // Order files according to execution order (using table order)\r\n for (const tableName of orderList) {\r\n if (fileMap.has(tableName)) {\r\n orderedFiles.push(fileMap.get(tableName)!);\r\n fileMap.delete(tableName);\r\n }\r\n }\r\n\r\n // Add any remaining files that weren't in the order\r\n for (const [, file] of fileMap) {\r\n orderedFiles.push(file);\r\n }\r\n\r\n // Using dependency order silently\r\n\r\n return orderedFiles;\r\n }\r\n}","import { Schema } from './lib/Schema';\r\nimport { CubeValidator } from './lib/CubeValidator';\r\nimport { UIUtils } from './lib/UIUtils';\r\nimport { DependencyResolver } from './lib/DependencyResolver';\r\n\r\nexport default Schema;\r\nexport { Schema, CubeValidator, UIUtils, DependencyResolver };"],"mappings":";AAAA,OAAOA,SAAQ;AACf,SAAS,QAAQ,gBAAgB,UAAU,mBAAmB;AAC9D,OAAOC,WAAU;;;ACFjB,YAAY,QAAQ;AACpB,YAAY,UAAU;AAEtB,IAAM,YAAN,MAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMd,aAAa,WAAW,UAAoC;AAC1D,WAAO,IAAI,QAAQ,CAACC,aAAY;AAC9B,MAAG,UAAY,aAAQ,QAAQ,GAAM,aAAU,MAAM,CAAC,QAAQ;AAC5D,QAAAA,SAAQ,CAAC,GAAG;AAAA,MACd,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,eAAe,UAA2B;AAC/C,QAAI;AACF,MAAG,cAAgB,aAAQ,QAAQ,GAAM,aAAU,IAAI;AACvD,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,OAAO,oBAAoB,OAA8B;AACvD,UAAM,QAAQ,MAAM,MAAM,iCAAiC;AAC3D,WAAO,QAAQ,MAAM,CAAC,IAAI;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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M,QAAQ,KAAK,IAAI,GAAG,UAAU,CAAC;AACrC,cAAM,MAAM,KAAK,IAAI,UAAU,QAAQ,UAAU,CAAC;AAElD,iBAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAC9B,gBAAM,OAAO,UAAU,CAAC;AACxB,gBAAM,YAAY,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,GAAG;AAC5C,gBAAM,UAAU,IAAI,MAAM,UAAU,GAAGC,OAAM,IAAI,IAAI,CAAC,KAAK;AAC3D,kBAAQ,IAAI,GAAGA,OAAM,KAAK,SAAS,CAAC,IAAI,OAAO,UAAUA,OAAM,MAAM,IAAI,CAAC,EAAE;AAAA,QAChF;AAAA,MACJ,SAASC,MAAK;AACV,gBAAQ,IAAID,OAAM,KAAK,kCAAkC,CAAC;AAAA,MAC9D;AAAA,IACJ;AAAA,EACJ;AAEA,UAAQ,IAAI,EAAE;AAClB;;;AKxxBA,IAAO,gBAAQ;","names":["fs","path","resolve","chalk","fs","resolve","fs","path","fs","path","path","fs","path","require","fs","chalk","err"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbcube/schema-builder",
3
- "version": "4.1.12",
3
+ "version": "4.1.13",
4
4
  "description": "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. \nIts agnostic design allows you to generate data manipulation (DML) and data definition (DDL) operations with a clean, chainable syntax—without sacrificing power or expressiveness.\nIt’s designed to work seamlessly in both SQL and NoSQL environments, providing a consistent abstraction layer across different storage technologies while still leveraging the native capabilities of each engine.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -54,7 +54,7 @@
54
54
  "access": "public"
55
55
  },
56
56
  "dependencies": {
57
- "@dbcube/core": "^4.1.15",
57
+ "@dbcube/core": "^4.1.16",
58
58
  "chalk": "^5.6.2",
59
59
  "ora": "^9.0.0"
60
60
  },
@@ -63,7 +63,7 @@
63
63
  "url": "https://github.com/Dbcube/query-builder"
64
64
  },
65
65
  "devDependencies": {
66
- "@types/node": "^25.0.6",
66
+ "@types/node": "^25.0.7",
67
67
  "rollup": "^4.55.1",
68
68
  "tsup": "^8.5.1",
69
69
  "typescript": "^5.9.3"