@dbcube/schema-builder 1.0.15 → 1.0.16
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 +54 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/lib/Schema.ts
|
|
39
|
-
var
|
|
39
|
+
var import_fs2 = __toESM(require("fs"));
|
|
40
40
|
var import_core = require("@dbcube/core");
|
|
41
41
|
var import_path = __toESM(require("path"));
|
|
42
42
|
|
|
@@ -162,9 +162,13 @@ var FileUtils = class {
|
|
|
162
162
|
};
|
|
163
163
|
var FileUtils_default = FileUtils;
|
|
164
164
|
|
|
165
|
+
// src/lib/Schema.ts
|
|
166
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
167
|
+
|
|
165
168
|
// src/lib/UIUtils.ts
|
|
166
169
|
var import_chalk = __toESM(require("chalk"));
|
|
167
|
-
var
|
|
170
|
+
var import_fs = __toESM(require("fs"));
|
|
171
|
+
var UIUtils = class _UIUtils {
|
|
168
172
|
/**
|
|
169
173
|
* Shows animated progress for processing items
|
|
170
174
|
*/
|
|
@@ -243,18 +247,40 @@ ${import_chalk.default.cyan("\u{1F4CA}")} ${import_chalk.default.bold.green(`SUM
|
|
|
243
247
|
${import_chalk.default.red("\u{1F6AB}")} ${import_chalk.default.bold.red("ERRORS FOUND")}`);
|
|
244
248
|
console.log(import_chalk.default.red("\u2500".repeat(60)));
|
|
245
249
|
summary.errors.forEach((error, index) => {
|
|
246
|
-
console.log(`${import_chalk.default.red("
|
|
247
|
-
console.log(
|
|
250
|
+
console.log(`${import_chalk.default.red("[error]")} ${import_chalk.default.red(error.error)}`);
|
|
251
|
+
console.log("");
|
|
248
252
|
if (error.filePath) {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
253
|
+
const location = error.lineNumber ? `${error.filePath}:${error.lineNumber}:7` : error.filePath;
|
|
254
|
+
console.log(`${import_chalk.default.cyan("[code]")} ${import_chalk.default.yellow(location)}`);
|
|
255
|
+
_UIUtils.showCodeContext(error.filePath, error.lineNumber || 1);
|
|
252
256
|
}
|
|
253
257
|
if (index < summary.errors.length - 1) {
|
|
254
|
-
console.log(
|
|
258
|
+
console.log("");
|
|
255
259
|
}
|
|
256
260
|
});
|
|
257
|
-
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Shows code context around an error location
|
|
265
|
+
*/
|
|
266
|
+
static showCodeContext(filePath, lineNumber, contextLines = 2) {
|
|
267
|
+
try {
|
|
268
|
+
const content = import_fs.default.readFileSync(filePath, "utf8");
|
|
269
|
+
const lines = content.split("\n");
|
|
270
|
+
const startLine = Math.max(0, lineNumber - contextLines - 1);
|
|
271
|
+
const endLine = Math.min(lines.length, lineNumber + contextLines);
|
|
272
|
+
for (let i = startLine; i < endLine; i++) {
|
|
273
|
+
const currentLineNum = i + 1;
|
|
274
|
+
const line = lines[i];
|
|
275
|
+
const lineNumStr = currentLineNum.toString().padStart(4, " ");
|
|
276
|
+
if (currentLineNum === lineNumber) {
|
|
277
|
+
console.log(`${import_chalk.default.gray(lineNumStr)} ${import_chalk.default.red("<-")} ${import_chalk.default.white(line)}`);
|
|
278
|
+
} else {
|
|
279
|
+
console.log(`${import_chalk.default.gray(lineNumStr)} ${import_chalk.default.white(line)}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} catch (error) {
|
|
283
|
+
console.log(import_chalk.default.gray(" (unable to show code context)"));
|
|
258
284
|
}
|
|
259
285
|
}
|
|
260
286
|
};
|
|
@@ -340,7 +366,7 @@ var Schema = class {
|
|
|
340
366
|
*/
|
|
341
367
|
findDatabaseLineNumber(filePath) {
|
|
342
368
|
try {
|
|
343
|
-
const content =
|
|
369
|
+
const content = import_fs2.default.readFileSync(filePath, "utf8");
|
|
344
370
|
const lines = content.split("\n");
|
|
345
371
|
for (let i = 0; i < lines.length; i++) {
|
|
346
372
|
if (lines[i].includes("@database")) {
|
|
@@ -399,7 +425,7 @@ var Schema = class {
|
|
|
399
425
|
async refreshTables() {
|
|
400
426
|
const startTime = Date.now();
|
|
401
427
|
const cubesDir = import_path.default.join(process.cwd(), "dbcube", "cubes");
|
|
402
|
-
if (!
|
|
428
|
+
if (!import_fs2.default.existsSync(cubesDir)) {
|
|
403
429
|
throw new Error("\u274C The cubes folder does not exist");
|
|
404
430
|
}
|
|
405
431
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "table.cube");
|
|
@@ -415,7 +441,7 @@ var Schema = class {
|
|
|
415
441
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
416
442
|
const file = cubeFiles[index];
|
|
417
443
|
const filePath = import_path.default.isAbsolute(file) ? file : import_path.default.join(cubesDir, file);
|
|
418
|
-
const stats =
|
|
444
|
+
const stats = import_fs2.default.statSync(filePath);
|
|
419
445
|
if (stats.isFile()) {
|
|
420
446
|
const getTableName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
421
447
|
const tableName = getTableName.status === 200 ? getTableName.message : import_path.default.basename(file, ".table.cube");
|
|
@@ -501,7 +527,7 @@ var Schema = class {
|
|
|
501
527
|
async freshTables() {
|
|
502
528
|
const startTime = Date.now();
|
|
503
529
|
const cubesDir = import_path.default.join(process.cwd(), "dbcube", "cubes");
|
|
504
|
-
if (!
|
|
530
|
+
if (!import_fs2.default.existsSync(cubesDir)) {
|
|
505
531
|
throw new Error("\u274C The cubes folder does not exist");
|
|
506
532
|
}
|
|
507
533
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "table.cube");
|
|
@@ -517,7 +543,7 @@ var Schema = class {
|
|
|
517
543
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
518
544
|
const file = cubeFiles[index];
|
|
519
545
|
const filePath = import_path.default.isAbsolute(file) ? file : import_path.default.join(cubesDir, file);
|
|
520
|
-
const stats =
|
|
546
|
+
const stats = import_fs2.default.statSync(filePath);
|
|
521
547
|
if (stats.isFile()) {
|
|
522
548
|
const getTableName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
523
549
|
const tableName = getTableName.status === 200 ? getTableName.message : import_path.default.basename(file, ".table.cube");
|
|
@@ -601,7 +627,7 @@ var Schema = class {
|
|
|
601
627
|
async executeSeeders() {
|
|
602
628
|
const startTime = Date.now();
|
|
603
629
|
const cubesDir = import_path.default.join(process.cwd(), "dbcube", "cubes");
|
|
604
|
-
if (!
|
|
630
|
+
if (!import_fs2.default.existsSync(cubesDir)) {
|
|
605
631
|
throw new Error("\u274C The cubes folder does not exist");
|
|
606
632
|
}
|
|
607
633
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "seeder.cube");
|
|
@@ -617,7 +643,7 @@ var Schema = class {
|
|
|
617
643
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
618
644
|
const file = cubeFiles[index];
|
|
619
645
|
const filePath = import_path.default.isAbsolute(file) ? file : import_path.default.join(cubesDir, file);
|
|
620
|
-
const stats =
|
|
646
|
+
const stats = import_fs2.default.statSync(filePath);
|
|
621
647
|
if (stats.isFile()) {
|
|
622
648
|
const getSeederName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
623
649
|
const seederName = getSeederName.status === 200 ? getSeederName.message : import_path.default.basename(file, ".seeder.cube");
|
|
@@ -673,7 +699,7 @@ var Schema = class {
|
|
|
673
699
|
const startTime = Date.now();
|
|
674
700
|
const cubesDir = import_path.default.join(process.cwd(), "dbcube", "cubes");
|
|
675
701
|
const triggersDirExit = import_path.default.join(process.cwd(), "dbcube", "triggers");
|
|
676
|
-
if (!
|
|
702
|
+
if (!import_fs2.default.existsSync(cubesDir)) {
|
|
677
703
|
throw new Error("\u274C The cubes folder does not exist");
|
|
678
704
|
}
|
|
679
705
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "trigger.cube");
|
|
@@ -689,7 +715,7 @@ var Schema = class {
|
|
|
689
715
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
690
716
|
const file = cubeFiles[index];
|
|
691
717
|
const filePath = import_path.default.isAbsolute(file) ? file : import_path.default.join(cubesDir, file);
|
|
692
|
-
const stats =
|
|
718
|
+
const stats = import_fs2.default.statSync(filePath);
|
|
693
719
|
if (stats.isFile()) {
|
|
694
720
|
const getTriggerName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
695
721
|
const triggerName = getTriggerName.status === 200 ? getTriggerName.message : import_path.default.basename(file, ".trigger.cube");
|
|
@@ -745,29 +771,11 @@ var Schema = class {
|
|
|
745
771
|
}
|
|
746
772
|
};
|
|
747
773
|
function returnFormattedError(status, message) {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
const GRAY = "\x1B[90m";
|
|
754
|
-
const UNDERLINE = "\x1B[4m";
|
|
755
|
-
const MAGENTA = "\x1B[35m";
|
|
756
|
-
let output = "";
|
|
757
|
-
let help = "";
|
|
758
|
-
const color = status === 600 ? YELLOW : RED;
|
|
759
|
-
if (message.includes("[help]")) {
|
|
760
|
-
const parts = message.split("[help]");
|
|
761
|
-
output += `
|
|
762
|
-
${RED}${BOLD}${parts[0]}${RESET}`;
|
|
763
|
-
help += `
|
|
764
|
-
${MAGENTA}${BOLD}[help]${RESET} ${GRAY}${parts[1]}${RESET}
|
|
765
|
-
`;
|
|
766
|
-
} else {
|
|
767
|
-
output += `
|
|
768
|
-
${color}${BOLD}${message}${RESET}
|
|
769
|
-
`;
|
|
770
|
-
}
|
|
774
|
+
console.log(`
|
|
775
|
+
${import_chalk2.default.red("\u{1F6AB}")} ${import_chalk2.default.bold.red("ERRORS FOUND")}`);
|
|
776
|
+
console.log(import_chalk2.default.red("\u2500".repeat(60)));
|
|
777
|
+
console.log(`${import_chalk2.default.red("[error]")} ${import_chalk2.default.red(message)}`);
|
|
778
|
+
console.log("");
|
|
771
779
|
const err = new Error();
|
|
772
780
|
const stackLines = err.stack?.split("\n") || [];
|
|
773
781
|
const relevantStackLine = stackLines.find(
|
|
@@ -779,32 +787,22 @@ ${color}${BOLD}${message}${RESET}
|
|
|
779
787
|
const [, filePath, lineStr, columnStr] = match;
|
|
780
788
|
const lineNum = parseInt(lineStr, 10);
|
|
781
789
|
const errorLocation = `${filePath}:${lineStr}:${columnStr}`;
|
|
790
|
+
console.log(`${import_chalk2.default.cyan("[code]")} ${import_chalk2.default.yellow(errorLocation)}`);
|
|
782
791
|
try {
|
|
783
|
-
const codeLines =
|
|
792
|
+
const codeLines = import_fs2.default.readFileSync(filePath, "utf-8").split("\n");
|
|
784
793
|
const start = Math.max(0, lineNum - 3);
|
|
785
794
|
const end = Math.min(codeLines.length, lineNum + 2);
|
|
786
|
-
output += `
|
|
787
|
-
${CYAN}${BOLD}[code] ${RESET}${YELLOW} ${UNDERLINE}${errorLocation}${RESET}
|
|
788
|
-
`;
|
|
789
795
|
for (let i = start; i < end; i++) {
|
|
790
796
|
const line = codeLines[i];
|
|
791
797
|
const lineLabel = `${i + 1}`.padStart(4, " ");
|
|
792
|
-
const pointer = i + 1 === lineNum ? `${
|
|
793
|
-
|
|
794
|
-
`;
|
|
798
|
+
const pointer = i + 1 === lineNum ? `${import_chalk2.default.red("<-")}` : " ";
|
|
799
|
+
console.log(`${import_chalk2.default.gray(lineLabel)} ${pointer} ${import_chalk2.default.white(line)}`);
|
|
795
800
|
}
|
|
796
801
|
} catch (err2) {
|
|
797
|
-
|
|
798
|
-
`;
|
|
799
|
-
output += `
|
|
800
|
-
${CYAN}${BOLD}Stack Trace:${RESET}
|
|
801
|
-
${stackLines.slice(2).join("\n")}
|
|
802
|
-
`;
|
|
802
|
+
console.log(import_chalk2.default.gray(" (unable to show code context)"));
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
|
-
output += help;
|
|
807
|
-
console.error(output);
|
|
808
806
|
process.exit(1);
|
|
809
807
|
}
|
|
810
808
|
|
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 const RESET = '\\x1b[0m';\r\n const RED = '\\x1b[31m';\r\n const YELLOW = '\\x1b[33m';\r\n const BOLD = '\\x1b[1m';\r\n const CYAN = '\\x1b[36m';\r\n const GRAY = '\\x1b[90m';\r\n const UNDERLINE = '\\x1b[4m';\r\n const MAGENTA = '\\x1b[35m';\r\n\r\n let output = '';\r\n let help = '';\r\n const color = status === 600 ? YELLOW : RED;\r\n\r\n\r\n if (message.includes(\"[help]\")) {\r\n const parts = message.split(\"[help]\");\r\n output += `\\n${RED}${BOLD}${parts[0]}${RESET}`;\r\n help += `\\n${MAGENTA}${BOLD}[help]${RESET} ${GRAY}${parts[1]}${RESET}\\n`;\r\n } else {\r\n output += `\\n${color}${BOLD}${message}${RESET}\\n`;\r\n }\r\n\r\n const err = new Error();\r\n const stackLines = err.stack?.split('\\n') || [];\r\n\r\n // Buscamos la primera línea del stack fuera de 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 // Leemos el archivo y sacamos las líneas relevantes\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 output += `\\n${CYAN}${BOLD}[code] ${RESET}${YELLOW} ${UNDERLINE}${errorLocation}${RESET}\\n`;\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 ? `${RED}<-${RESET}` : ' ';\r\n output += `${GRAY}${lineLabel}${RESET} ${pointer} ${line}\\n`;\r\n }\r\n } catch (err) {\r\n output += `${YELLOW}⚠️ No se pudo leer el archivo de origen: ${filePath}${RESET}\\n`;\r\n output += `\\n${CYAN}${BOLD}Stack Trace:${RESET}\\n${stackLines.slice(2).join('\\n')}\\n`;\r\n }\r\n }\r\n }\r\n output += help;\r\n console.error(output);\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\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 console.log(`${chalk.red('├─')} ${chalk.bold(error.itemName)}`);\r\n console.log(`${chalk.red('│ ')} ${chalk.gray('Error:')} ${chalk.red(error.error)}`);\r\n if (error.filePath) {\r\n const relativePath = error.filePath.replace(process.cwd().replace(/\\\\\\\\/g, '/'), '.');\r\n const location = error.lineNumber ? `${relativePath}:${error.lineNumber}` : relativePath;\r\n console.log(`${chalk.red('│ ')} ${chalk.gray('Location:')} ${chalk.cyan(location)}`);\r\n }\r\n if (index < summary.errors.length - 1) {\r\n console.log(`${chalk.red('│')}`);\r\n }\r\n });\r\n console.log('');\r\n }\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA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A,EACJ;AACA,YAAU;AACV,UAAQ,MAAM,MAAM;AACpB,UAAQ,KAAK,CAAC;AAClB;;;ADrpBA,IAAO,gBAAQ;","names":["resolve","resolve","chalk","path","ConfigClass","fs","err"]}
|
|
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;AAElE,iBAAW,SAAS,SAAS;AAC3B,cAAM,WAAgB,UAAK,YAAY,MAAM,IAAI;AAEjD,YAAI,MAAM,YAAY,GAAG;AACvB,kBAAQ,QAAQ;AAAA,QAClB,WAAW,MAAM,OAAO,KAAK,MAAM,KAAK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AAQ,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"]}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
// src/lib/Schema.ts
|
|
9
|
-
import
|
|
9
|
+
import fs3 from "fs";
|
|
10
10
|
import { Engine, TableProcessor, Config as ConfigClass } from "@dbcube/core";
|
|
11
11
|
import path2 from "path";
|
|
12
12
|
|
|
@@ -132,9 +132,13 @@ var FileUtils = class {
|
|
|
132
132
|
};
|
|
133
133
|
var FileUtils_default = FileUtils;
|
|
134
134
|
|
|
135
|
+
// src/lib/Schema.ts
|
|
136
|
+
import chalk2 from "chalk";
|
|
137
|
+
|
|
135
138
|
// src/lib/UIUtils.ts
|
|
136
139
|
import chalk from "chalk";
|
|
137
|
-
|
|
140
|
+
import fs2 from "fs";
|
|
141
|
+
var UIUtils = class _UIUtils {
|
|
138
142
|
/**
|
|
139
143
|
* Shows animated progress for processing items
|
|
140
144
|
*/
|
|
@@ -213,18 +217,40 @@ ${chalk.cyan("\u{1F4CA}")} ${chalk.bold.green(`SUMMARY OF ${operationName.toUppe
|
|
|
213
217
|
${chalk.red("\u{1F6AB}")} ${chalk.bold.red("ERRORS FOUND")}`);
|
|
214
218
|
console.log(chalk.red("\u2500".repeat(60)));
|
|
215
219
|
summary.errors.forEach((error, index) => {
|
|
216
|
-
console.log(`${chalk.red("
|
|
217
|
-
console.log(
|
|
220
|
+
console.log(`${chalk.red("[error]")} ${chalk.red(error.error)}`);
|
|
221
|
+
console.log("");
|
|
218
222
|
if (error.filePath) {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
223
|
+
const location = error.lineNumber ? `${error.filePath}:${error.lineNumber}:7` : error.filePath;
|
|
224
|
+
console.log(`${chalk.cyan("[code]")} ${chalk.yellow(location)}`);
|
|
225
|
+
_UIUtils.showCodeContext(error.filePath, error.lineNumber || 1);
|
|
222
226
|
}
|
|
223
227
|
if (index < summary.errors.length - 1) {
|
|
224
|
-
console.log(
|
|
228
|
+
console.log("");
|
|
225
229
|
}
|
|
226
230
|
});
|
|
227
|
-
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Shows code context around an error location
|
|
235
|
+
*/
|
|
236
|
+
static showCodeContext(filePath, lineNumber, contextLines = 2) {
|
|
237
|
+
try {
|
|
238
|
+
const content = fs2.readFileSync(filePath, "utf8");
|
|
239
|
+
const lines = content.split("\n");
|
|
240
|
+
const startLine = Math.max(0, lineNumber - contextLines - 1);
|
|
241
|
+
const endLine = Math.min(lines.length, lineNumber + contextLines);
|
|
242
|
+
for (let i = startLine; i < endLine; i++) {
|
|
243
|
+
const currentLineNum = i + 1;
|
|
244
|
+
const line = lines[i];
|
|
245
|
+
const lineNumStr = currentLineNum.toString().padStart(4, " ");
|
|
246
|
+
if (currentLineNum === lineNumber) {
|
|
247
|
+
console.log(`${chalk.gray(lineNumStr)} ${chalk.red("<-")} ${chalk.white(line)}`);
|
|
248
|
+
} else {
|
|
249
|
+
console.log(`${chalk.gray(lineNumStr)} ${chalk.white(line)}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.log(chalk.gray(" (unable to show code context)"));
|
|
228
254
|
}
|
|
229
255
|
}
|
|
230
256
|
};
|
|
@@ -310,7 +336,7 @@ var Schema = class {
|
|
|
310
336
|
*/
|
|
311
337
|
findDatabaseLineNumber(filePath) {
|
|
312
338
|
try {
|
|
313
|
-
const content =
|
|
339
|
+
const content = fs3.readFileSync(filePath, "utf8");
|
|
314
340
|
const lines = content.split("\n");
|
|
315
341
|
for (let i = 0; i < lines.length; i++) {
|
|
316
342
|
if (lines[i].includes("@database")) {
|
|
@@ -369,7 +395,7 @@ var Schema = class {
|
|
|
369
395
|
async refreshTables() {
|
|
370
396
|
const startTime = Date.now();
|
|
371
397
|
const cubesDir = path2.join(process.cwd(), "dbcube", "cubes");
|
|
372
|
-
if (!
|
|
398
|
+
if (!fs3.existsSync(cubesDir)) {
|
|
373
399
|
throw new Error("\u274C The cubes folder does not exist");
|
|
374
400
|
}
|
|
375
401
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "table.cube");
|
|
@@ -385,7 +411,7 @@ var Schema = class {
|
|
|
385
411
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
386
412
|
const file = cubeFiles[index];
|
|
387
413
|
const filePath = path2.isAbsolute(file) ? file : path2.join(cubesDir, file);
|
|
388
|
-
const stats =
|
|
414
|
+
const stats = fs3.statSync(filePath);
|
|
389
415
|
if (stats.isFile()) {
|
|
390
416
|
const getTableName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
391
417
|
const tableName = getTableName.status === 200 ? getTableName.message : path2.basename(file, ".table.cube");
|
|
@@ -471,7 +497,7 @@ var Schema = class {
|
|
|
471
497
|
async freshTables() {
|
|
472
498
|
const startTime = Date.now();
|
|
473
499
|
const cubesDir = path2.join(process.cwd(), "dbcube", "cubes");
|
|
474
|
-
if (!
|
|
500
|
+
if (!fs3.existsSync(cubesDir)) {
|
|
475
501
|
throw new Error("\u274C The cubes folder does not exist");
|
|
476
502
|
}
|
|
477
503
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "table.cube");
|
|
@@ -487,7 +513,7 @@ var Schema = class {
|
|
|
487
513
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
488
514
|
const file = cubeFiles[index];
|
|
489
515
|
const filePath = path2.isAbsolute(file) ? file : path2.join(cubesDir, file);
|
|
490
|
-
const stats =
|
|
516
|
+
const stats = fs3.statSync(filePath);
|
|
491
517
|
if (stats.isFile()) {
|
|
492
518
|
const getTableName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
493
519
|
const tableName = getTableName.status === 200 ? getTableName.message : path2.basename(file, ".table.cube");
|
|
@@ -571,7 +597,7 @@ var Schema = class {
|
|
|
571
597
|
async executeSeeders() {
|
|
572
598
|
const startTime = Date.now();
|
|
573
599
|
const cubesDir = path2.join(process.cwd(), "dbcube", "cubes");
|
|
574
|
-
if (!
|
|
600
|
+
if (!fs3.existsSync(cubesDir)) {
|
|
575
601
|
throw new Error("\u274C The cubes folder does not exist");
|
|
576
602
|
}
|
|
577
603
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "seeder.cube");
|
|
@@ -587,7 +613,7 @@ var Schema = class {
|
|
|
587
613
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
588
614
|
const file = cubeFiles[index];
|
|
589
615
|
const filePath = path2.isAbsolute(file) ? file : path2.join(cubesDir, file);
|
|
590
|
-
const stats =
|
|
616
|
+
const stats = fs3.statSync(filePath);
|
|
591
617
|
if (stats.isFile()) {
|
|
592
618
|
const getSeederName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
593
619
|
const seederName = getSeederName.status === 200 ? getSeederName.message : path2.basename(file, ".seeder.cube");
|
|
@@ -643,7 +669,7 @@ var Schema = class {
|
|
|
643
669
|
const startTime = Date.now();
|
|
644
670
|
const cubesDir = path2.join(process.cwd(), "dbcube", "cubes");
|
|
645
671
|
const triggersDirExit = path2.join(process.cwd(), "dbcube", "triggers");
|
|
646
|
-
if (!
|
|
672
|
+
if (!fs3.existsSync(cubesDir)) {
|
|
647
673
|
throw new Error("\u274C The cubes folder does not exist");
|
|
648
674
|
}
|
|
649
675
|
const cubeFiles = FileUtils_default.getCubeFilesRecursively("dbcube", "trigger.cube");
|
|
@@ -659,7 +685,7 @@ var Schema = class {
|
|
|
659
685
|
for (let index = 0; index < cubeFiles.length; index++) {
|
|
660
686
|
const file = cubeFiles[index];
|
|
661
687
|
const filePath = path2.isAbsolute(file) ? file : path2.join(cubesDir, file);
|
|
662
|
-
const stats =
|
|
688
|
+
const stats = fs3.statSync(filePath);
|
|
663
689
|
if (stats.isFile()) {
|
|
664
690
|
const getTriggerName = FileUtils_default.extracTableNameFromCube(filePath);
|
|
665
691
|
const triggerName = getTriggerName.status === 200 ? getTriggerName.message : path2.basename(file, ".trigger.cube");
|
|
@@ -715,29 +741,11 @@ var Schema = class {
|
|
|
715
741
|
}
|
|
716
742
|
};
|
|
717
743
|
function returnFormattedError(status, message) {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
const GRAY = "\x1B[90m";
|
|
724
|
-
const UNDERLINE = "\x1B[4m";
|
|
725
|
-
const MAGENTA = "\x1B[35m";
|
|
726
|
-
let output = "";
|
|
727
|
-
let help = "";
|
|
728
|
-
const color = status === 600 ? YELLOW : RED;
|
|
729
|
-
if (message.includes("[help]")) {
|
|
730
|
-
const parts = message.split("[help]");
|
|
731
|
-
output += `
|
|
732
|
-
${RED}${BOLD}${parts[0]}${RESET}`;
|
|
733
|
-
help += `
|
|
734
|
-
${MAGENTA}${BOLD}[help]${RESET} ${GRAY}${parts[1]}${RESET}
|
|
735
|
-
`;
|
|
736
|
-
} else {
|
|
737
|
-
output += `
|
|
738
|
-
${color}${BOLD}${message}${RESET}
|
|
739
|
-
`;
|
|
740
|
-
}
|
|
744
|
+
console.log(`
|
|
745
|
+
${chalk2.red("\u{1F6AB}")} ${chalk2.bold.red("ERRORS FOUND")}`);
|
|
746
|
+
console.log(chalk2.red("\u2500".repeat(60)));
|
|
747
|
+
console.log(`${chalk2.red("[error]")} ${chalk2.red(message)}`);
|
|
748
|
+
console.log("");
|
|
741
749
|
const err = new Error();
|
|
742
750
|
const stackLines = err.stack?.split("\n") || [];
|
|
743
751
|
const relevantStackLine = stackLines.find(
|
|
@@ -749,32 +757,22 @@ ${color}${BOLD}${message}${RESET}
|
|
|
749
757
|
const [, filePath, lineStr, columnStr] = match;
|
|
750
758
|
const lineNum = parseInt(lineStr, 10);
|
|
751
759
|
const errorLocation = `${filePath}:${lineStr}:${columnStr}`;
|
|
760
|
+
console.log(`${chalk2.cyan("[code]")} ${chalk2.yellow(errorLocation)}`);
|
|
752
761
|
try {
|
|
753
|
-
const codeLines =
|
|
762
|
+
const codeLines = fs3.readFileSync(filePath, "utf-8").split("\n");
|
|
754
763
|
const start = Math.max(0, lineNum - 3);
|
|
755
764
|
const end = Math.min(codeLines.length, lineNum + 2);
|
|
756
|
-
output += `
|
|
757
|
-
${CYAN}${BOLD}[code] ${RESET}${YELLOW} ${UNDERLINE}${errorLocation}${RESET}
|
|
758
|
-
`;
|
|
759
765
|
for (let i = start; i < end; i++) {
|
|
760
766
|
const line = codeLines[i];
|
|
761
767
|
const lineLabel = `${i + 1}`.padStart(4, " ");
|
|
762
|
-
const pointer = i + 1 === lineNum ? `${
|
|
763
|
-
|
|
764
|
-
`;
|
|
768
|
+
const pointer = i + 1 === lineNum ? `${chalk2.red("<-")}` : " ";
|
|
769
|
+
console.log(`${chalk2.gray(lineLabel)} ${pointer} ${chalk2.white(line)}`);
|
|
765
770
|
}
|
|
766
771
|
} catch (err2) {
|
|
767
|
-
|
|
768
|
-
`;
|
|
769
|
-
output += `
|
|
770
|
-
${CYAN}${BOLD}Stack Trace:${RESET}
|
|
771
|
-
${stackLines.slice(2).join("\n")}
|
|
772
|
-
`;
|
|
772
|
+
console.log(chalk2.gray(" (unable to show code context)"));
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
|
-
output += help;
|
|
777
|
-
console.error(output);
|
|
778
776
|
process.exit(1);
|
|
779
777
|
}
|
|
780
778
|
|
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/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\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 const RESET = '\\x1b[0m';\r\n const RED = '\\x1b[31m';\r\n const YELLOW = '\\x1b[33m';\r\n const BOLD = '\\x1b[1m';\r\n const CYAN = '\\x1b[36m';\r\n const GRAY = '\\x1b[90m';\r\n const UNDERLINE = '\\x1b[4m';\r\n const MAGENTA = '\\x1b[35m';\r\n\r\n let output = '';\r\n let help = '';\r\n const color = status === 600 ? YELLOW : RED;\r\n\r\n\r\n if (message.includes(\"[help]\")) {\r\n const parts = message.split(\"[help]\");\r\n output += `\\n${RED}${BOLD}${parts[0]}${RESET}`;\r\n help += `\\n${MAGENTA}${BOLD}[help]${RESET} ${GRAY}${parts[1]}${RESET}\\n`;\r\n } else {\r\n output += `\\n${color}${BOLD}${message}${RESET}\\n`;\r\n }\r\n\r\n const err = new Error();\r\n const stackLines = err.stack?.split('\\n') || [];\r\n\r\n // Buscamos la primera línea del stack fuera de 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 // Leemos el archivo y sacamos las líneas relevantes\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 output += `\\n${CYAN}${BOLD}[code] ${RESET}${YELLOW} ${UNDERLINE}${errorLocation}${RESET}\\n`;\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 ? `${RED}<-${RESET}` : ' ';\r\n output += `${GRAY}${lineLabel}${RESET} ${pointer} ${line}\\n`;\r\n }\r\n } catch (err) {\r\n output += `${YELLOW}⚠️ No se pudo leer el archivo de origen: ${filePath}${RESET}\\n`;\r\n output += `\\n${CYAN}${BOLD}Stack Trace:${RESET}\\n${stackLines.slice(2).join('\\n')}\\n`;\r\n }\r\n }\r\n }\r\n output += help;\r\n console.error(output);\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\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 console.log(`${chalk.red('├─')} ${chalk.bold(error.itemName)}`);\r\n console.log(`${chalk.red('│ ')} ${chalk.gray('Error:')} ${chalk.red(error.error)}`);\r\n if (error.filePath) {\r\n const relativePath = error.filePath.replace(process.cwd().replace(/\\\\\\\\/g, '/'), '.');\r\n const location = error.lineNumber ? `${relativePath}:${error.lineNumber}` : relativePath;\r\n console.log(`${chalk.red('│ ')} ${chalk.gray('Location:')} ${chalk.cyan(location)}`);\r\n }\r\n if (index < summary.errors.length - 1) {\r\n console.log(`${chalk.red('│')}`);\r\n }\r\n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AACA,cAAM,YAAYC,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,kBAAU;AAAA,EAAK,IAAI,GAAG,IAAI,UAAU,KAAK,GAAG,MAAM,IAAI,SAAS,GAAG,aAAa,GAAG,KAAK;AAAA;AAEvF,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,GAAG,KAAK,KAAK,KAAK;AACzD,oBAAU,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,OAAO,IAAI,IAAI;AAAA;AAAA,QAC5D;AAAA,MACJ,SAASC,MAAK;AACV,kBAAU,GAAG,MAAM,sDAA4C,QAAQ,GAAG,KAAK;AAAA;AAC/E,kBAAU;AAAA,EAAK,IAAI,GAAG,IAAI,eAAe,KAAK;AAAA,EAAK,WAAW,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;AAAA;AAAA,MACrF;AAAA,IACJ;AAAA,EACJ;AACA,YAAU;AACV,UAAQ,MAAM,MAAM;AACpB,UAAQ,KAAK,CAAC;AAClB;;;AGrpBA,IAAO,gBAAQ;","names":["fs","path","resolve","resolve","path","fs","err"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/Schema.ts","../src/lib/FileUtils.ts","../src/lib/UIUtils.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\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}","import { Schema } from './lib/Schema';\r\n\r\nexport default Schema;\r\nexport { Schema };"],"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;A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AC,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,KAAK,CAAC;AAClB;;;AGroBA,IAAO,gBAAQ;","names":["fs","path","resolve","chalk","fs","resolve","path","fs","chalk","err"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbcube/schema-builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
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",
|