UNPKG

nestjs-reverse-engineering

Version:

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

116 lines 2.89 kB
import { DataSource } from 'typeorm'; import { DatabaseDialect } from '../types/database.types'; export interface DataExportOptions { dialect: DatabaseDialect; batchSize: number; outputPath: string; prettyPrint: boolean; alignValues: boolean; nullHandling: 'NULL' | 'DEFAULT' | 'SKIP'; includeHeaders: boolean; includeTableComments: boolean; dataMasking: DataMaskingOptions; tables?: string[]; excludeTables?: string[]; whereConditions?: Record<string, string>; orderBy?: Record<string, string>; } export interface DataMaskingOptions { enabled: boolean; sensitiveFields: string[]; maskingPatterns: Record<string, MaskingRule>; } export interface MaskingRule { type: 'email' | 'phone' | 'name' | 'address' | 'custom'; pattern?: string; replacement?: string; preserveLength?: boolean; preserveFormat?: boolean; } export interface InsertScriptResult { sql: string; tableCount: number; totalRows: number; fileCount: number; outputPaths: string[]; statistics: Record<string, { rows: number; batches: number; }>; } export interface TableData { tableName: string; columns: string[]; rows: any[][]; totalRows: number; } export declare class DataExporter { private readonly dataSource; private readonly options; constructor(dataSource: DataSource, options?: Partial<DataExportOptions>); /** * Export all table data as INSERT scripts */ exportAllTables(): Promise<InsertScriptResult>; /** * Export specific tables */ exportTables(tableNames: string[]): Promise<InsertScriptResult>; /** * Discover all tables in the database */ private discoverTables; /** * Filter tables based on options */ private filterTables; /** * Extract data from a specific table */ private extractTableData; /** * Get column names for a table */ private getTableColumns; /** * Generate INSERT scripts for table data */ private generateInsertScripts; /** * Generate a single batch INSERT script */ private generateBatchInsert; /** * Calculate column widths for alignment */ private calculateColumnWidths; /** * Format a single value for SQL */ private formatValue; /** * Apply data masking to sensitive fields */ private applyDataMasking; /** * Apply a specific masking rule */ private applyMaskingRule; /** * Write INSERT scripts to files */ private writeInsertScripts; /** * Build file header */ private buildFileHeader; /** * Generate summary file */ private generateSummaryFile; /** * Escape SQL identifiers */ private escapeIdentifier; } //# sourceMappingURL=data-exporter.d.ts.map