/** * Schema Sync * * Orchestrates schema synchronization between entities and database * with configurable direction modes. */ import type { SchemaDiffResult, SyncDirection, SyncOptions } from '../../schema/types.js'; import type { SchemaIntrospector, Type } from '../../type/index.js'; /** * Result of a schema sync operation. */ export interface SchemaSyncResult { /** Direction of the sync */ direction: SyncDirection; /** Whether the sync was successful */ success: boolean; /** Changes applied to database */ dbChanges: SchemaDiffResult | undefined; /** Changes applied to entities */ entityChanges: SchemaDiffResult | undefined; /** Conflicts that need manual resolution */ conflicts: SyncConflict[]; /** Human-readable summary */ summary: string; /** Structured summary of changes */ details: { db: { created: number; dropped: number; altered: number; }; entity: { created: number; dropped: number; altered: number; }; }; } /** * A conflict between entity and database schemas. */ export interface SyncConflict { /** Type of conflict */ type: 'type_mismatch' | 'constraint_mismatch' | 'column_mismatch' | 'relation_mismatch'; /** Table name */ table: string; /** Column name (if applicable) */ column?: string; /** What entity expects */ entityValue: unknown; /** What database has */ dbValue: unknown; /** Suggested resolution */ suggestion: string; } /** * Options for schema sync operation. */ export interface SchemaSyncOptions extends SyncOptions { /** Entities to sync */ entities: Type[]; /** Schema introspector for database */ introspector: SchemaIntrospector; /** Output directory for generated entities (db-to-entity mode) */ entityOutputDir?: string; /** Dry run - don't apply changes */ dryRun?: boolean; } /** * Service for synchronizing schemas between entities and database. */ export declare class SchemaSync { private readonly options; constructor(options: SchemaSyncOptions); /** * Execute schema synchronization. */ sync(): Promise; /** * Sync from entities to database (push). */ private syncEntityToDb; /** * Sync from database to entities (pull). */ private syncDbToEntity; /** * Bidirectional sync with conflict detection. */ private syncBidirectional; /** * Build SchemaAST from entities. */ private buildEntityAST; /** * Build SchemaAST from database. */ private buildDatabaseAST; /** * Filter destructive changes for safe mode. */ private filterDestructiveChanges; /** * Detect conflicts between bidirectional changes. */ private detectConflicts; /** * Filter out conflicting changes. */ private filterConflictingChanges; /** * Get counts of changes from a diff. */ private getDiffCounts; /** * Format summary for single-direction sync. */ private formatSummary; /** * Format summary for bidirectional sync. */ private formatBidirectionalSummary; /** * Format type for display. */ private formatType; } /** * Create a SchemaSync instance. */ export declare function createSchemaSync(options: SchemaSyncOptions): SchemaSync; //# sourceMappingURL=schemaSync.d.ts.map