import { AutoBeDatabase } from "../database/AutoBeDatabase"; import { IAutoBeDatabaseValidation } from "../database/IAutoBeDatabaseValidation"; import { IAutoBePrismaCompileResult } from "./IAutoBePrismaCompileResult"; import { IAutoBePrismaCompilerProps } from "./IAutoBePrismaCompilerProps"; /** * Interface for the custom Database compiler that handles database schema * validation and generation. * * This compiler provides the foundational compilation layer that transforms * business requirements into validated database architectures through * sophisticated AST manipulation. The Database compiler operates exclusively on * {@link AutoBeDatabase.IApplication} structures, eliminating error-prone * text-based schema authoring while ensuring perfect consistency between * business logic and data storage design. * * The compiler implements a comprehensive validation system that includes * relationship graph analysis, business logic validation, performance * optimization analysis, and security constraint enforcement. The deterministic * code generation process produces comprehensive documentation, optimal * indexes, and proper constraints ready for production deployment. * * @author Samchon */ export interface IAutoBeDatabaseCompiler { /** * Compiles validated database application into complete database artifacts. * * Performs the complete compilation pipeline from validated * {@link AutoBeDatabase.IApplication} through schema generation, documentation * creation, ERD diagram generation, and dependency file creation. This * comprehensive process produces all artifacts necessary for database * deployment and integration. * * The compilation includes validation of the AST structure, generation of * production-ready Prisma schema files, creation of comprehensive * documentation with business context, automatic ERD diagram generation * through prisma-markdown integration, and preparation of all supporting * files for seamless deployment. * * @param props Compilation configuration including the validated application * and generation options * @returns Promise resolving to complete compilation results including * success status, generated artifacts, or detailed error information */ compilePrismaSchemas(props: IAutoBePrismaCompilerProps): Promise; /** * Generates Prisma schema files from validated application AST structure. * * Transforms the validated {@link AutoBeDatabase.IApplication} AST into * production-ready Prisma schema files through deterministic code generation. * The generated schemas include comprehensive documentation for each entity * and attribute, optimal index configurations, proper constraint definitions, * and business context explanations derived from the AST structure. * * The schema files are organized by business domains following domain-driven * design principles, with each file focusing on related models within the * same functional area. The generated schemas are immediately ready for * Prisma deployment and database migration processes. * * @param app Validated database application AST structure * @param dbms Target database management system * @returns Promise resolving to key-value pairs mapping schema filenames to * generated Prisma schema content */ writePrismaSchemas(app: AutoBeDatabase.IApplication, dbms?: "postgres" | "sqlite"): Promise>; /** * Validates database application AST structure for correctness and best * practices. * * Performs comprehensive validation of the {@link AutoBeDatabase.IApplication} * structure including relationship graph analysis to detect circular * dependencies, business logic validation for constraint compliance, * performance optimization analysis for query patterns, and security * constraint enforcement for data access patterns. * * The validation process ensures that the database design is semantically * correct, follows established best practices, and will function correctly in * production environments. When validation errors occur, detailed feedback is * provided to enable AI self-correction through the iterative improvement * feedback loop. * * @param app Database application AST structure to validate * @returns Promise resolving to validation results including success status * and detailed error information for correction guidance */ validate(app: AutoBeDatabase.IApplication): Promise; }