/** * Parsing and resolution for drizzle-kit's create-or-rename prompt. * * Ported from `apps/compiler/src/runner/drizzle-prompts.ts`. Only the parsing * and resolution half moves: `extractDrizzleRenameHints` stays compiler-side * because it derives hints from `quickback.config.ts`, and the CLI receives * the derived result on `ClientMigrationTarget.renameHints`. * * ── Why any of this exists ─────────────────────────────────────────────── * * A renamed column and a dropped-plus-added column produce the IDENTICAL * schema diff: `old` is gone, `new` is present. drizzle-kit cannot tell them * apart, so it stops and asks. The answer decides the generated SQL: * * "create" → DROP COLUMN old + ADD COLUMN new (every value is lost) * "rename" → ALTER TABLE ... RENAME COLUMN (data preserved) * * So answering it wrongly on a deployed table is silent data loss, and NOT * answering it means drizzle aborts on its non-TTY resolver, exits 0, and * writes no migration at all — a compile that looks successful and ships a * Worker referencing tables that do not exist. * * Resolution order (mirrors the compiler): * 1. An explicit hint from `compiler.migrations.renames` → select that * specific rename option. * 2. `autoCreateRenames` → select "create" (option index 0). This is the * D1 default: an added column is the common case, and guessing "rename" * wrongly is worse than guessing "create" wrongly on a genuinely new one. * 3. Neither → refuse, naming the ambiguous entity and the hint key that * would resolve it. */ export declare const DRIZZLE_INTERACTIVE_ERROR = "drizzle-kit requested interactive rename input, but Quickback compile is running headless."; export declare const DRIZZLE_RENAME_HINTS_EXAMPLE = "Example: compiler: { migrations: { renames: { tables: { new_table: 'old_table' }, columns: { target_table: { new_column: 'old_column' } } } } }"; export interface DrizzleRenameHints { tables?: Record; columns?: Record>; } export interface DrizzlePrompt { entity: 'table' | 'column'; toName: string; contextTable?: string; options: Array<{ fromName: string; toName: string; }>; } /** * drizzle-kit 0.31's create-or-rename resolver hard-aborts on a non-TTY stdin * for add+drop diffs. This is the signal to retry through the fake-TTY wrapper * so the prompt actually renders and keystrokes can answer it. * * CRITICAL: drizzle prints this and still EXITS 0. Never gate the retry on a * non-zero exit — that bug shipped once compiler-side and silently skipped * generation for every add+drop diff. */ export declare function isDrizzleTtyAbort(stdout: string, stderr: string): boolean; export declare function stripAnsi(text: string): string; export declare function normalizeIdentifier(value: string): string; /** * Parse the most recent create-or-rename prompt out of accumulated output. * * "Most recent" matters: output accumulates across the whole run, so an * earlier answered prompt is still in the buffer. Taking the last match is * what keeps the runner answering the question currently on screen. */ export declare function extractLatestDrizzlePrompt(output: string): DrizzlePrompt | null; /** * Resolve a prompt against explicit hints, returning how many arrow-down * presses reach the matching rename option. * * The `+1` is load-bearing: index 0 of drizzle's list is always "create", so * option N in `prompt.options` sits at list position N+1. Returning N instead * would select the option ABOVE the intended one — on a multi-candidate * prompt that renames from the wrong source column. * * Returns null when no hint covers this prompt, or when the hinted source * name isn't among the offered options (a stale hint), so the caller falls * through to auto-create or refuses rather than picking arbitrarily. * * Hint keys are normalized on lookup. In practice they arrive already * normalized — `extractDrizzleRenameHints` lowercases and unquotes every key * and value when it reads `quickback.config.ts`, so a user writing * `Projects` or `createdAt` in their config is already handled upstream. * `normalizeIdentifier` is idempotent, so re-normalizing here changes nothing * for that path; it exists so this function is correct for ANY caller rather * than carrying an unstated precondition that a future one could miss. */ export declare function resolvePromptWithHints(prompt: DrizzlePrompt, hints: DrizzleRenameHints): number | null; /** Stable identity for a prompt, so the runner answers each one exactly once. */ export declare function drizzlePromptKey(prompt: DrizzlePrompt): string; /** Error naming the ambiguity and the exact config key that would resolve it. */ export declare function formatDrizzlePromptError(prompt: DrizzlePrompt): string; /** Keystrokes that select option `movesDown` positions below "create". */ export declare function keystrokesForOption(movesDown: number): string; /** Keystroke that accepts the default option, "create". */ export declare const KEYSTROKE_ACCEPT_CREATE = "\r"; //# sourceMappingURL=drizzle-prompts.d.ts.map