Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@dbcube/schema-builder

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbcube/schema-builder - npm Package Compare versions

Comparing version
5.1.1
to
5.1.3
+34
-1
dist/index.cjs

@@ -298,3 +298,3 @@ "use strict";

validProperties = ["type", "length", "options", "value", "defaultValue", "foreign", "enumValues", "description"];
knownAnnotations = ["database", "table", "meta", "columns", "fields", "dataset", "beforeAdd", "afterAdd", "beforeUpdate", "afterUpdate", "beforeDelete", "afterDelete", "compute", "column", "changeName", "addColumn", "deleteColumn", "renameColumn", "changeType", "changeLength", "changeDefault", "changeOptions", "changeEnumValues"];
knownAnnotations = ["database", "table", "meta", "columns", "indexes", "fields", "dataset", "beforeAdd", "afterAdd", "beforeUpdate", "afterUpdate", "beforeDelete", "afterDelete", "compute", "column", "changeName", "addColumn", "deleteColumn", "renameColumn", "changeType", "changeLength", "changeDefault", "changeOptions", "changeEnumValues"];
/**

@@ -430,2 +430,14 @@ * Validates a cube file comprehensively

}
if (this.isInsideIndexesBlock(content, lineNumber - 1)) {
const validIndexProperties = ["columns", "unique"];
if (!validIndexProperties.includes(propertyName)) {
errors.push({
itemName: fileName,
error: `Invalid index property '${propertyName}'. Valid index properties: ${validIndexProperties.join(", ")}`,
filePath,
lineNumber
});
}
return;
}
if (this.isInsideForeignKeyObject(content, lineNumber - 1)) {

@@ -462,2 +474,23 @@ const validForeignKeyProperties = ["table", "column"];

}
isInsideIndexesBlock(content, lineIndex) {
const lines = content.split("\n");
let indexesStartLine = -1;
let indexesEndLine = -1;
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes("@indexes")) {
indexesStartLine = i;
let braceCount = 0;
for (let j = i; j < lines.length; j++) {
braceCount += (lines[j].match(/\{/g) || []).length;
braceCount -= (lines[j].match(/\}/g) || []).length;
if (braceCount === 0 && j > i) {
indexesEndLine = j;
break;
}
}
break;
}
}
return indexesStartLine !== -1 && indexesEndLine !== -1 && lineIndex > indexesStartLine && lineIndex < indexesEndLine;
}
validateRequiredColumnProperties(lines, lineNumber, filePath, fileName, errors) {

@@ -464,0 +497,0 @@ const line = lines[lineNumber - 1];

+129
-127

@@ -5,137 +5,139 @@ /**

*/
declare class Schema {
private name;
private engine;
constructor(name: string);
/**
* Validates cube file comprehensively including syntax, database configuration, and structure
* @param filePath - Path to the cube file
* @returns validation result with any errors found
*/
private validateDatabaseConfiguration;
/**
* Finds the line number where @database directive is located
*/
private findDatabaseLineNumber;
/**
* Extracts foreign key dependencies from a cube file
*/
private extractForeignKeyDependencies;
/**
* Finds the line number where a foreign key table reference is located
*/
private findForeignKeyLineNumber;
createDatabase(): Promise<any>;
refreshTables(): Promise<any>;
freshTables(): Promise<any>;
executeSeeders(): Promise<any>;
executeAlters(): Promise<any>;
executeTriggers(): Promise<any>;
export declare class Schema {
private name;
private engine;
constructor(name: string);
/**
* Validates cube file comprehensively including syntax, database configuration, and structure
* @param filePath - Path to the cube file
* @returns validation result with any errors found
*/
private validateDatabaseConfiguration;
/**
* Finds the line number where @database directive is located
*/
private findDatabaseLineNumber;
/**
* Extracts foreign key dependencies from a cube file
*/
private extractForeignKeyDependencies;
/**
* Finds the line number where a foreign key table reference is located
*/
private findForeignKeyLineNumber;
createDatabase(): Promise<any>;
refreshTables(): Promise<any>;
freshTables(): Promise<any>;
executeSeeders(): Promise<any>;
executeAlters(): Promise<any>;
executeTriggers(): Promise<any>;
}
interface ProcessError {
itemName: string;
error: string;
filePath?: string;
lineNumber?: number;
export interface ProcessError {
itemName: string;
error: string;
filePath?: string;
lineNumber?: number;
}
interface ProcessSummary {
startTime: number;
totalProcessed: number;
successCount: number;
errorCount: number;
processedItems: string[];
operationName: string;
databaseName: string;
errors: ProcessError[];
export interface ProcessSummary {
startTime: number;
totalProcessed: number;
successCount: number;
errorCount: number;
processedItems: string[];
operationName: string;
databaseName: string;
errors: ProcessError[];
}
declare class UIUtils {
/**
* Shows animated progress for processing items
*/
static showItemProgress(itemName: string, current: number, total: number): Promise<void>;
/**
* Shows success for a processed item
*/
static showItemSuccess(itemName: string): void;
/**
* Shows error for an item (simplified - only shows X)
*/
static showItemError(itemName: string, error: string): void;
/**
* Shows operation header
*/
static showOperationHeader(operationName: string, databaseName: string, icon?: string): void;
/**
* Shows comprehensive operation summary
*/
static showOperationSummary(summary: ProcessSummary): void;
/**
* Shows code context around an error location
*/
static showCodeContext(filePath: string, lineNumber: number, contextLines?: number): void;
export declare class UIUtils {
/**
* Shows animated progress for processing items
*/
static showItemProgress(itemName: string, current: number, total: number): Promise<void>;
/**
* Shows success for a processed item
*/
static showItemSuccess(itemName: string): void;
/**
* Shows error for an item (simplified - only shows X)
*/
static showItemError(itemName: string, error: string): void;
/**
* Shows operation header
*/
static showOperationHeader(operationName: string, databaseName: string, icon?: string): void;
/**
* Shows comprehensive operation summary
*/
static showOperationSummary(summary: ProcessSummary): void;
/**
* Shows code context around an error location
*/
static showCodeContext(filePath: string, lineNumber: number, contextLines?: number): void;
}
interface ValidationResult {
isValid: boolean;
errors: ProcessError[];
export interface ValidationResult {
isValid: boolean;
errors: ProcessError[];
}
declare class CubeValidator {
private validTypes;
private validOptions;
private validProperties;
private knownAnnotations;
/**
* Validates a cube file comprehensively
*/
validateCubeFile(filePath: string): ValidationResult;
private validateAnnotations;
private validateDataTypes;
private validateColumnOptions;
private validateColumnProperties;
private validateRequiredColumnProperties;
private validateGeneralSyntax;
private validateOverallStructure;
private getColumnTypeForOptions;
private isOptionCompatibleWithType;
private isInsideColumnsBlock;
private isInsideForeignKeyObject;
export declare class CubeValidator {
private validTypes;
private validOptions;
private validProperties;
private knownAnnotations;
/**
* Validates a cube file comprehensively
*/
validateCubeFile(filePath: string): ValidationResult;
private validateAnnotations;
private validateDataTypes;
private validateColumnOptions;
private validateColumnProperties;
private isInsideIndexesBlock;
private validateRequiredColumnProperties;
private validateGeneralSyntax;
private validateOverallStructure;
private getColumnTypeForOptions;
private isOptionCompatibleWithType;
private isInsideColumnsBlock;
private isInsideForeignKeyObject;
}
interface ExecutionOrder {
tables: string[];
seeders: string[];
timestamp: string;
export interface ExecutionOrder {
tables: string[];
seeders: string[];
timestamp: string;
}
declare class DependencyResolver {
/**
* Resolves table dependencies and creates execution order
*/
static resolveDependencies(cubeFiles: string[], cubeType?: 'table' | 'seeder'): ExecutionOrder;
/**
* Extracts dependencies from cube files
*/
private static extractDependencies;
/**
* Extracts foreign key references from a cube file
*/
private static extractForeignKeyReferences;
/**
* Performs topological sort to determine execution order
*/
private static topologicalSort;
/**
* Saves the execution order to .dbcube/orderexecute.json
*/
private static saveExecutionOrder;
/**
* Loads the execution order from .dbcube/orderexecute.json
*/
static loadExecutionOrder(): ExecutionOrder | null;
/**
* Orders cube files based on saved execution order
*/
static orderCubeFiles(cubeFiles: string[], cubeType: 'table' | 'seeder'): string[];
export declare class DependencyResolver {
/**
* Resolves table dependencies and creates execution order
*/
static resolveDependencies(cubeFiles: string[], cubeType?: "table" | "seeder"): ExecutionOrder;
/**
* Extracts dependencies from cube files
*/
private static extractDependencies;
/**
* Extracts foreign key references from a cube file
*/
private static extractForeignKeyReferences;
/**
* Performs topological sort to determine execution order
*/
private static topologicalSort;
/**
* Saves the execution order to .dbcube/orderexecute.json
*/
private static saveExecutionOrder;
/**
* Loads the execution order from .dbcube/orderexecute.json
*/
static loadExecutionOrder(): ExecutionOrder | null;
/**
* Orders cube files based on saved execution order
*/
static orderCubeFiles(cubeFiles: string[], cubeType: "table" | "seeder"): string[];
}
export { CubeValidator, DependencyResolver, Schema, UIUtils, Schema as default };
export {
Schema as default,
};
export {};

@@ -5,137 +5,139 @@ /**

*/
declare class Schema {
private name;
private engine;
constructor(name: string);
/**
* Validates cube file comprehensively including syntax, database configuration, and structure
* @param filePath - Path to the cube file
* @returns validation result with any errors found
*/
private validateDatabaseConfiguration;
/**
* Finds the line number where @database directive is located
*/
private findDatabaseLineNumber;
/**
* Extracts foreign key dependencies from a cube file
*/
private extractForeignKeyDependencies;
/**
* Finds the line number where a foreign key table reference is located
*/
private findForeignKeyLineNumber;
createDatabase(): Promise<any>;
refreshTables(): Promise<any>;
freshTables(): Promise<any>;
executeSeeders(): Promise<any>;
executeAlters(): Promise<any>;
executeTriggers(): Promise<any>;
export declare class Schema {
private name;
private engine;
constructor(name: string);
/**
* Validates cube file comprehensively including syntax, database configuration, and structure
* @param filePath - Path to the cube file
* @returns validation result with any errors found
*/
private validateDatabaseConfiguration;
/**
* Finds the line number where @database directive is located
*/
private findDatabaseLineNumber;
/**
* Extracts foreign key dependencies from a cube file
*/
private extractForeignKeyDependencies;
/**
* Finds the line number where a foreign key table reference is located
*/
private findForeignKeyLineNumber;
createDatabase(): Promise<any>;
refreshTables(): Promise<any>;
freshTables(): Promise<any>;
executeSeeders(): Promise<any>;
executeAlters(): Promise<any>;
executeTriggers(): Promise<any>;
}
interface ProcessError {
itemName: string;
error: string;
filePath?: string;
lineNumber?: number;
export interface ProcessError {
itemName: string;
error: string;
filePath?: string;
lineNumber?: number;
}
interface ProcessSummary {
startTime: number;
totalProcessed: number;
successCount: number;
errorCount: number;
processedItems: string[];
operationName: string;
databaseName: string;
errors: ProcessError[];
export interface ProcessSummary {
startTime: number;
totalProcessed: number;
successCount: number;
errorCount: number;
processedItems: string[];
operationName: string;
databaseName: string;
errors: ProcessError[];
}
declare class UIUtils {
/**
* Shows animated progress for processing items
*/
static showItemProgress(itemName: string, current: number, total: number): Promise<void>;
/**
* Shows success for a processed item
*/
static showItemSuccess(itemName: string): void;
/**
* Shows error for an item (simplified - only shows X)
*/
static showItemError(itemName: string, error: string): void;
/**
* Shows operation header
*/
static showOperationHeader(operationName: string, databaseName: string, icon?: string): void;
/**
* Shows comprehensive operation summary
*/
static showOperationSummary(summary: ProcessSummary): void;
/**
* Shows code context around an error location
*/
static showCodeContext(filePath: string, lineNumber: number, contextLines?: number): void;
export declare class UIUtils {
/**
* Shows animated progress for processing items
*/
static showItemProgress(itemName: string, current: number, total: number): Promise<void>;
/**
* Shows success for a processed item
*/
static showItemSuccess(itemName: string): void;
/**
* Shows error for an item (simplified - only shows X)
*/
static showItemError(itemName: string, error: string): void;
/**
* Shows operation header
*/
static showOperationHeader(operationName: string, databaseName: string, icon?: string): void;
/**
* Shows comprehensive operation summary
*/
static showOperationSummary(summary: ProcessSummary): void;
/**
* Shows code context around an error location
*/
static showCodeContext(filePath: string, lineNumber: number, contextLines?: number): void;
}
interface ValidationResult {
isValid: boolean;
errors: ProcessError[];
export interface ValidationResult {
isValid: boolean;
errors: ProcessError[];
}
declare class CubeValidator {
private validTypes;
private validOptions;
private validProperties;
private knownAnnotations;
/**
* Validates a cube file comprehensively
*/
validateCubeFile(filePath: string): ValidationResult;
private validateAnnotations;
private validateDataTypes;
private validateColumnOptions;
private validateColumnProperties;
private validateRequiredColumnProperties;
private validateGeneralSyntax;
private validateOverallStructure;
private getColumnTypeForOptions;
private isOptionCompatibleWithType;
private isInsideColumnsBlock;
private isInsideForeignKeyObject;
export declare class CubeValidator {
private validTypes;
private validOptions;
private validProperties;
private knownAnnotations;
/**
* Validates a cube file comprehensively
*/
validateCubeFile(filePath: string): ValidationResult;
private validateAnnotations;
private validateDataTypes;
private validateColumnOptions;
private validateColumnProperties;
private isInsideIndexesBlock;
private validateRequiredColumnProperties;
private validateGeneralSyntax;
private validateOverallStructure;
private getColumnTypeForOptions;
private isOptionCompatibleWithType;
private isInsideColumnsBlock;
private isInsideForeignKeyObject;
}
interface ExecutionOrder {
tables: string[];
seeders: string[];
timestamp: string;
export interface ExecutionOrder {
tables: string[];
seeders: string[];
timestamp: string;
}
declare class DependencyResolver {
/**
* Resolves table dependencies and creates execution order
*/
static resolveDependencies(cubeFiles: string[], cubeType?: 'table' | 'seeder'): ExecutionOrder;
/**
* Extracts dependencies from cube files
*/
private static extractDependencies;
/**
* Extracts foreign key references from a cube file
*/
private static extractForeignKeyReferences;
/**
* Performs topological sort to determine execution order
*/
private static topologicalSort;
/**
* Saves the execution order to .dbcube/orderexecute.json
*/
private static saveExecutionOrder;
/**
* Loads the execution order from .dbcube/orderexecute.json
*/
static loadExecutionOrder(): ExecutionOrder | null;
/**
* Orders cube files based on saved execution order
*/
static orderCubeFiles(cubeFiles: string[], cubeType: 'table' | 'seeder'): string[];
export declare class DependencyResolver {
/**
* Resolves table dependencies and creates execution order
*/
static resolveDependencies(cubeFiles: string[], cubeType?: "table" | "seeder"): ExecutionOrder;
/**
* Extracts dependencies from cube files
*/
private static extractDependencies;
/**
* Extracts foreign key references from a cube file
*/
private static extractForeignKeyReferences;
/**
* Performs topological sort to determine execution order
*/
private static topologicalSort;
/**
* Saves the execution order to .dbcube/orderexecute.json
*/
private static saveExecutionOrder;
/**
* Loads the execution order from .dbcube/orderexecute.json
*/
static loadExecutionOrder(): ExecutionOrder | null;
/**
* Orders cube files based on saved execution order
*/
static orderCubeFiles(cubeFiles: string[], cubeType: "table" | "seeder"): string[];
}
export { CubeValidator, DependencyResolver, Schema, UIUtils, Schema as default };
export {
Schema as default,
};
export {};

@@ -258,3 +258,3 @@ // src/lib/Schema.ts

validProperties = ["type", "length", "options", "value", "defaultValue", "foreign", "enumValues", "description"];
knownAnnotations = ["database", "table", "meta", "columns", "fields", "dataset", "beforeAdd", "afterAdd", "beforeUpdate", "afterUpdate", "beforeDelete", "afterDelete", "compute", "column", "changeName", "addColumn", "deleteColumn", "renameColumn", "changeType", "changeLength", "changeDefault", "changeOptions", "changeEnumValues"];
knownAnnotations = ["database", "table", "meta", "columns", "indexes", "fields", "dataset", "beforeAdd", "afterAdd", "beforeUpdate", "afterUpdate", "beforeDelete", "afterDelete", "compute", "column", "changeName", "addColumn", "deleteColumn", "renameColumn", "changeType", "changeLength", "changeDefault", "changeOptions", "changeEnumValues"];
/**

@@ -390,2 +390,14 @@ * Validates a cube file comprehensively

}
if (this.isInsideIndexesBlock(content, lineNumber - 1)) {
const validIndexProperties = ["columns", "unique"];
if (!validIndexProperties.includes(propertyName)) {
errors.push({
itemName: fileName,
error: `Invalid index property '${propertyName}'. Valid index properties: ${validIndexProperties.join(", ")}`,
filePath,
lineNumber
});
}
return;
}
if (this.isInsideForeignKeyObject(content, lineNumber - 1)) {

@@ -422,2 +434,23 @@ const validForeignKeyProperties = ["table", "column"];

}
isInsideIndexesBlock(content, lineIndex) {
const lines = content.split("\n");
let indexesStartLine = -1;
let indexesEndLine = -1;
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes("@indexes")) {
indexesStartLine = i;
let braceCount = 0;
for (let j = i; j < lines.length; j++) {
braceCount += (lines[j].match(/\{/g) || []).length;
braceCount -= (lines[j].match(/\}/g) || []).length;
if (braceCount === 0 && j > i) {
indexesEndLine = j;
break;
}
}
break;
}
}
return indexesStartLine !== -1 && indexesEndLine !== -1 && lineIndex > indexesStartLine && lineIndex < indexesEndLine;
}
validateRequiredColumnProperties(lines, lineNumber, filePath, fileName, errors) {

@@ -424,0 +457,0 @@ const line = lines[lineNumber - 1];

{
"name": "@dbcube/schema-builder",
"version": "5.1.1",
"version": "5.1.3",
"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.",

@@ -13,3 +13,3 @@ "main": "dist/index.cjs",

"scripts": {
"build": "tsup"
"build": "tsup && bunx dts-bundle-generator --no-banner -o dist/index.d.ts src/index.ts && node -e \"const fs=require('fs');fs.copyFileSync('dist/index.d.ts','dist/index.d.mts')\""
},

@@ -58,5 +58,5 @@ "keywords": [

"dependencies": {
"@dbcube/core": "^5.1.4",
"@dbcube/core": "^5.1.9",
"chalk": "^5.6.2",
"ora": "^9.3.0"
"ora": "^9.4.0"
},

@@ -68,7 +68,8 @@ "repository": {

"devDependencies": {
"@types/node": "^25.5.0",
"rollup": "^4.60.0",
"@types/node": "^25.6.0",
"dts-bundle-generator": "^9.5.1",
"rollup": "^4.60.2",
"tsup": "^8.5.1",
"typescript": "^5.9.3"
"typescript": "^6.0.3"
}
}

@@ -6,3 +6,3 @@ import { defineConfig } from 'tsup';

format: ['cjs', 'esm'], // Genera CommonJS y ES Modules
dts: true, // Genera archivos de tipos
dts: false,
clean: true, // Limpia el directorio de salida

@@ -9,0 +9,0 @@ outDir: 'dist', // Directorio de salida

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display