UNPKG

nestjs-reverse-engineering

Version:

A powerful TypeScript/NestJS library for database reverse engineering, entity generation, and CRUD operations

158 lines 4.62 kB
import { DataSource } from 'typeorm'; import { EntityGenerationOptions, DatabaseSchema } from './types/database.types'; export declare class ReverseEngineeringService { private readonly dataSource; constructor(dataSource: DataSource); /** * Generate TypeScript entities from database schema */ generateEntities(options?: Partial<EntityGenerationOptions>): Promise<void>; /** * Analyze database schema and return metadata */ analyzeSchema(): Promise<DatabaseSchema>; /** * Get basic table information */ getTableList(): Promise<Array<{ tableName: string; tableSchema: string; columnCount: number; }>>; /** * Generate SQL scripts for schema recreation */ generateSQLScripts(options?: { dialect?: 'postgres' | 'mysql'; schemaName?: string; includeDropIfExists?: boolean; includeCreateIfNotExists?: boolean; outputPath?: string; entitiesPath?: string; }): Promise<{ sql: string; tableCount: number; outputPath?: string; }>; /** * Generate React/UI components */ generateUIComponents(): Promise<void>; /** * Test database connection and compatibility */ testConnection(): Promise<{ connected: boolean; dialect: string; version?: string; error?: string; }>; /** * Generate index.ts file for all entities */ generateEntityIndex(entitiesPath?: string): Promise<void>; /** * Scan entity files and return information */ scanEntityFiles(entitiesPath?: string): Promise<Array<{ className: string; fileName: string; filePath: string; }>>; /** * Export table data as INSERT statements */ exportTableData(options?: { tables?: string[]; excludeTables?: string[]; batchSize?: number; outputPath?: string; prettyPrint?: boolean; alignValues?: boolean; nullHandling?: 'NULL' | 'DEFAULT' | 'SKIP'; dataMasking?: { enabled: boolean; sensitiveFields?: string[]; maskEmail?: boolean; maskPasswords?: boolean; maskPhones?: boolean; }; whereConditions?: Record<string, string>; }): Promise<{ success: boolean; tableCount: number; totalRows: number; fileCount: number; outputPaths: string[]; statistics: Record<string, { rows: number; batches: number; }>; }>; /** * Generate CRUD operations for all tables */ generateCrudOperations(options?: { outputPath?: string; framework?: 'nestjs' | 'express' | 'fastify'; includeValidation?: boolean; includeSwagger?: boolean; includePagination?: boolean; includeFiltering?: boolean; includeSorting?: boolean; includeRelations?: boolean; generateTests?: boolean; authGuards?: boolean; useTypeORM?: boolean; useDTO?: boolean; tables?: string[]; excludeTables?: string[]; }): Promise<{ success: boolean; tablesProcessed: number; filesGenerated: number; outputPaths: string[]; modules: Array<{ tableName: string; entityName: string; moduleName: string; files: { entity: string; dto: string[]; controller: string; service: string; repository: string; module: string; tests?: string[]; }; }>; }>; /** * Generate CRUD operations for specific tables */ generateCrudForTables(tableNames: string[], options?: { outputPath?: string; framework?: 'nestjs' | 'express' | 'fastify'; includeValidation?: boolean; includeSwagger?: boolean; includePagination?: boolean; includeFiltering?: boolean; includeSorting?: boolean; includeRelations?: boolean; generateTests?: boolean; authGuards?: boolean; useTypeORM?: boolean; useDTO?: boolean; }): Promise<{ success: boolean; tablesProcessed: number; filesGenerated: number; outputPaths: string[]; modules: Array<{ tableName: string; entityName: string; moduleName: string; }>; }>; } //# sourceMappingURL=reverse-engineering.service.d.ts.map