@dbcube/schema-builder 1.0.16 β 1.0.17
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/dist/index.cjs +354 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +71 -3
- package/dist/index.d.ts +71 -3
- package/dist/index.js +351 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/lib/Schema.ts","../src/lib/FileUtils.ts","../src/lib/UIUtils.ts"],"sourcesContent":["import { Schema } from './lib/Schema';\r\n\r\nexport default Schema;\r\nexport { Schema };","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\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 that the database specified in cube file exists in configuration\r\n * @param filePath - Path to the cube file\r\n * @returns true if valid, throws error if invalid\r\n */\r\n private validateDatabaseConfiguration(filePath: string): { isValid: boolean; error?: ProcessError } {\r\n try {\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 const configFn = require(configFilePath);\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 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', 'cubes');\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 // 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\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 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, 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(tableName, validation.error.error);\r\n errors.push(validation.error);\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 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', 'cubes');\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 // 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\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 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, 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(tableName, validation.error.error);\r\n errors.push(validation.error);\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 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', 'cubes');\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 // 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 < 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 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, 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(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', 'cubes');\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 process.exit(1);\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}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,aAAe;AACf,kBAA8D;AAC9D,kBAAiB;;;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;A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;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,KAAK,CAAC;AAClB;;;ADroBA,IAAO,gBAAQ;","names":["import_fs","resolve","import_chalk","resolve","chalk","fs","path","ConfigClass","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"],"sourcesContent":["import { Schema } from './lib/Schema';\r\nimport { CubeValidator } from './lib/CubeValidator';\r\nimport { UIUtils } from './lib/UIUtils';\r\n\r\nexport default Schema;\r\nexport { Schema, CubeValidator, UIUtils };","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\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 const configFn = require(configFilePath);\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 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', 'cubes');\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 // 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\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 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, 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(tableName, validation.error.error);\r\n errors.push(validation.error);\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 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', 'cubes');\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 // 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\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 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, 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(tableName, validation.error.error);\r\n errors.push(validation.error);\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 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', 'cubes');\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 // 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 < 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 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, 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(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', 'cubes');\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 process.exit(1);\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 const annotationRegex = /@(\\w+)/g;\r\n let match;\r\n \r\n while ((match = annotationRegex.exec(line)) !== 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 (!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 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 column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AAAD,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;AAEd,UAAQ,KAAK,CAAC;AAClB;;;ADlpBA,IAAO,gBAAQ;","names":["import_fs","import_path","resolve","import_chalk","resolve","chalk","fs","import_fs","fs","path","path","ConfigClass","fs","chalk","err"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -7,9 +7,9 @@ declare class Schema {
|
|
|
7
7
|
private engine;
|
|
8
8
|
constructor(name: string);
|
|
9
9
|
/**
|
|
10
|
-
* Validates
|
|
10
|
+
* Validates cube file comprehensively including syntax, database configuration, and structure
|
|
11
11
|
* @param filePath - Path to the cube file
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns validation result with any errors found
|
|
13
13
|
*/
|
|
14
14
|
private validateDatabaseConfiguration;
|
|
15
15
|
/**
|
|
@@ -23,4 +23,72 @@ declare class Schema {
|
|
|
23
23
|
executeTriggers(): Promise<any>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
interface ProcessError {
|
|
27
|
+
itemName: string;
|
|
28
|
+
error: string;
|
|
29
|
+
filePath?: string;
|
|
30
|
+
lineNumber?: number;
|
|
31
|
+
}
|
|
32
|
+
interface ProcessSummary {
|
|
33
|
+
startTime: number;
|
|
34
|
+
totalProcessed: number;
|
|
35
|
+
successCount: number;
|
|
36
|
+
errorCount: number;
|
|
37
|
+
processedItems: string[];
|
|
38
|
+
operationName: string;
|
|
39
|
+
databaseName: string;
|
|
40
|
+
errors: ProcessError[];
|
|
41
|
+
}
|
|
42
|
+
declare class UIUtils {
|
|
43
|
+
/**
|
|
44
|
+
* Shows animated progress for processing items
|
|
45
|
+
*/
|
|
46
|
+
static showItemProgress(itemName: string, current: number, total: number): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Shows success for a processed item
|
|
49
|
+
*/
|
|
50
|
+
static showItemSuccess(itemName: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Shows error for an item (simplified - only shows X)
|
|
53
|
+
*/
|
|
54
|
+
static showItemError(itemName: string, error: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Shows operation header
|
|
57
|
+
*/
|
|
58
|
+
static showOperationHeader(operationName: string, databaseName: string, icon?: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Shows comprehensive operation summary
|
|
61
|
+
*/
|
|
62
|
+
static showOperationSummary(summary: ProcessSummary): void;
|
|
63
|
+
/**
|
|
64
|
+
* Shows code context around an error location
|
|
65
|
+
*/
|
|
66
|
+
static showCodeContext(filePath: string, lineNumber: number, contextLines?: number): void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface ValidationResult {
|
|
70
|
+
isValid: boolean;
|
|
71
|
+
errors: ProcessError[];
|
|
72
|
+
}
|
|
73
|
+
declare class CubeValidator {
|
|
74
|
+
private validTypes;
|
|
75
|
+
private validOptions;
|
|
76
|
+
private validProperties;
|
|
77
|
+
private knownAnnotations;
|
|
78
|
+
/**
|
|
79
|
+
* Validates a cube file comprehensively
|
|
80
|
+
*/
|
|
81
|
+
validateCubeFile(filePath: string): ValidationResult;
|
|
82
|
+
private validateAnnotations;
|
|
83
|
+
private validateDataTypes;
|
|
84
|
+
private validateColumnOptions;
|
|
85
|
+
private validateColumnProperties;
|
|
86
|
+
private validateRequiredColumnProperties;
|
|
87
|
+
private validateGeneralSyntax;
|
|
88
|
+
private validateOverallStructure;
|
|
89
|
+
private getColumnTypeForOptions;
|
|
90
|
+
private isOptionCompatibleWithType;
|
|
91
|
+
private isInsideColumnsBlock;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { CubeValidator, Schema, UIUtils, Schema as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ declare class Schema {
|
|
|
7
7
|
private engine;
|
|
8
8
|
constructor(name: string);
|
|
9
9
|
/**
|
|
10
|
-
* Validates
|
|
10
|
+
* Validates cube file comprehensively including syntax, database configuration, and structure
|
|
11
11
|
* @param filePath - Path to the cube file
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns validation result with any errors found
|
|
13
13
|
*/
|
|
14
14
|
private validateDatabaseConfiguration;
|
|
15
15
|
/**
|
|
@@ -23,4 +23,72 @@ declare class Schema {
|
|
|
23
23
|
executeTriggers(): Promise<any>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
interface ProcessError {
|
|
27
|
+
itemName: string;
|
|
28
|
+
error: string;
|
|
29
|
+
filePath?: string;
|
|
30
|
+
lineNumber?: number;
|
|
31
|
+
}
|
|
32
|
+
interface ProcessSummary {
|
|
33
|
+
startTime: number;
|
|
34
|
+
totalProcessed: number;
|
|
35
|
+
successCount: number;
|
|
36
|
+
errorCount: number;
|
|
37
|
+
processedItems: string[];
|
|
38
|
+
operationName: string;
|
|
39
|
+
databaseName: string;
|
|
40
|
+
errors: ProcessError[];
|
|
41
|
+
}
|
|
42
|
+
declare class UIUtils {
|
|
43
|
+
/**
|
|
44
|
+
* Shows animated progress for processing items
|
|
45
|
+
*/
|
|
46
|
+
static showItemProgress(itemName: string, current: number, total: number): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Shows success for a processed item
|
|
49
|
+
*/
|
|
50
|
+
static showItemSuccess(itemName: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Shows error for an item (simplified - only shows X)
|
|
53
|
+
*/
|
|
54
|
+
static showItemError(itemName: string, error: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Shows operation header
|
|
57
|
+
*/
|
|
58
|
+
static showOperationHeader(operationName: string, databaseName: string, icon?: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Shows comprehensive operation summary
|
|
61
|
+
*/
|
|
62
|
+
static showOperationSummary(summary: ProcessSummary): void;
|
|
63
|
+
/**
|
|
64
|
+
* Shows code context around an error location
|
|
65
|
+
*/
|
|
66
|
+
static showCodeContext(filePath: string, lineNumber: number, contextLines?: number): void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface ValidationResult {
|
|
70
|
+
isValid: boolean;
|
|
71
|
+
errors: ProcessError[];
|
|
72
|
+
}
|
|
73
|
+
declare class CubeValidator {
|
|
74
|
+
private validTypes;
|
|
75
|
+
private validOptions;
|
|
76
|
+
private validProperties;
|
|
77
|
+
private knownAnnotations;
|
|
78
|
+
/**
|
|
79
|
+
* Validates a cube file comprehensively
|
|
80
|
+
*/
|
|
81
|
+
validateCubeFile(filePath: string): ValidationResult;
|
|
82
|
+
private validateAnnotations;
|
|
83
|
+
private validateDataTypes;
|
|
84
|
+
private validateColumnOptions;
|
|
85
|
+
private validateColumnProperties;
|
|
86
|
+
private validateRequiredColumnProperties;
|
|
87
|
+
private validateGeneralSyntax;
|
|
88
|
+
private validateOverallStructure;
|
|
89
|
+
private getColumnTypeForOptions;
|
|
90
|
+
private isOptionCompatibleWithType;
|
|
91
|
+
private isInsideColumnsBlock;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { CubeValidator, Schema, UIUtils, Schema as default };
|