import type * as TypeScript from 'typescript'; import { type ManagedColumnRequirement, type NamingConvention, type SchemaDialect } from './managed-columns.js'; export type TypeScriptApi = Omit; export type SchemaTableStyle = 'q-feature' | 'q-table' | 'raw-drizzle'; export type StaticDeleteMode = 'hard' | 'soft' | 'default' | 'dynamic'; export interface SchemaTableContext { /** Stable within one source file, even when SQL table names repeat. */ id: string; fileName: string; tableName: string; variableName?: string; style: SchemaTableStyle; dialect: SchemaDialect; namingConvention: NamingConvention; hasResourceConfig: boolean; deleteMode: StaticDeleteMode; /** * `crud.batchDelete.mode`, inheriting `deleteMode` when unset — the same * resolution the compiler applies in `resolveDeleteModes`. Soft-delete * columns are required unless BOTH paths are hard, so a resolver that reads * only `deleteMode` under-reports the requirement for * `delete: { mode: 'hard' }, batchDelete: { mode: 'soft' }`. */ batchDeleteMode: StaticDeleteMode; sourceStart: number; sourceEnd: number; } export type ManagedRequirementResolver = (table: SchemaTableContext) => ReadonlyArray; export interface SchemaSourceEdit { start: number; end: number; text: string; tableId?: string; reason: string; } export type SchemaSyncDiagnosticCode = 'DIVERGENT_MANAGED_COLUMN' | 'DUPLICATE_MANAGED_REPRESENTATION' | 'DUPLICATE_TABLE_COLUMN' | 'MISSING_VALUE_IMPORT' | 'SOURCE_PARSE_ERROR' | 'UNSUPPORTED_DYNAMIC_DELETE_MODE' | 'REQUIREMENT_RESOLUTION_FAILED' | 'INVALID_REQUIREMENT' | 'OVERLAPPING_SOURCE_EDITS'; export interface SchemaSyncDiagnostic { code: SchemaSyncDiagnosticCode; message: string; fileName: string; tableId?: string; tableName?: string; start?: number; end?: number; expected?: string; actual?: string; } export interface PlanSchemaSourceOptions { fileName: string; source: string; typescript: TypeScriptApi; dialect: SchemaDialect; namingConvention?: NamingConvention; resolveRequirements: ManagedRequirementResolver; } export interface SchemaSourcePlan { fileName: string; source: string; tables: ReadonlyArray; edits: ReadonlyArray; diagnostics: ReadonlyArray; updatedSource: string; changed: boolean; canApply: boolean; } /** * Inspect every table in one source file and calculate formatting-preserving, * additive-only source edits. No edit is applied here. */ export declare function planSchemaSource(options: PlanSchemaSourceOptions): SchemaSourcePlan; export declare function applySchemaSourceEdits(source: string, edits: ReadonlyArray): string; //# sourceMappingURL=source-sync.d.ts.map