import type { Kysely } from "kysely"; import type { MetaRoot } from "@metaobjectsdev/metadata"; import type { ColumnNamingStrategy } from "@metaobjectsdev/metadata"; import { type ObjectScopePredicate } from "../scope.js"; import type { AllowOptions, Dialect, DiffResult, SchemaSnapshot } from "../types.js"; export interface ComputeDriftOptions { /** * Destructive-change permissions. Mirrors `diff`'s `allow` — a drift that is * "allowed" still appears in `changes` (it's still drift), so the gate fails * on it. `allow` only affects `blocked`. Defaults to `{}`. */ allow?: AllowOptions; /** * Column-naming strategy for fields with no `@column` override. Must match * the runtime's strategy or the expected schema's columns won't line up with * what introspection sees. Defaults to `buildExpectedSchema`'s default. */ columnNamingStrategy?: ColumnNamingStrategy; /** * Table-name patterns to ignore on both sides (passed through to `diff`). * Omit to keep `diff`'s default (migration-tracking sidecar tables). */ ignoreTables?: string[]; /** * Expected views (projection → CREATE VIEW body), computed by the caller via * codegen-ts's `buildProjectionViews`. migrate-ts no longer generates view DDL * itself; pass these so view drift is detected. Defaults to none. */ views?: readonly import("../expected-schema.js").ExpectedViewInput[]; /** * Per-command scope (`migrate.scope`): objects whose declaring FQN this predicate * rejects are governed by somebody else. They leave the expected side AND are * suppressed on the actual side, so their divergence is neither drift nor a * proposed drop — `verify` reports them as out-of-scope instead (see * `DriftResult.outOfScope`). Omit to govern everything loaded (unchanged behavior). * * `verify --db` and `migrate` deliberately share ONE declaration: a drift gate * failing on tables migrate does not own is incoherent. */ inScope?: ObjectScopePredicate; } export interface DriftResult extends DiffResult { /** * Qualified physical names excluded by `inScope` — empty when no scope was * given. The caller REPORTS these: an object silently dropped from the * comparison is indistinguishable from one that was checked and found clean. */ outOfScope: readonly string[]; /** * The schemas this comparison governed (`ScopedExpectedSchema.declaredSchemas`), * `undefined` when no scope was given and `diff` derived its own. * * Reported so a SECOND comparison over the same run — `verify`'s committed-snapshot * gate — can govern exactly the same schemas instead of re-deriving them from a * different expected side. Together with `outOfScope` this pair is a * `GovernedScope`, which is what `excludeFromSnapshot` takes. */ declaredSchemas: readonly string[] | undefined; } /** * Compute the drift between an ALREADY-INTROSPECTED schema snapshot and the * metadata-declared schema. The post-introspection half of `computeDrift`, * factored out so a caller that can't use `introspect()`'s Kysely-driver path * (there is none for Cloudflare D1 — it has no client wire protocol) can still * run the same expected-schema + diff pipeline against a snapshot it obtained * some other way (e.g. `introspectD1` over a wrangler-shelled-out runner). * * Returns a `DiffResult` whose `changes` is empty iff `actual` matches the * metadata. The caller decides exit behavior (the schema-drift gate fails when * `changes` is non-empty). */ export declare function computeDriftFromActual(actual: SchemaSnapshot, dialect: Dialect, metadata: MetaRoot, opts?: ComputeDriftOptions): Promise; /** * Compute the drift between a live DB and the metadata-declared schema. * * Thin wrapper: introspects `db` via the Kysely-driver path, then delegates to * `computeDriftFromActual`. Signature and behavior are unchanged by the #225 * refactor above — existing callers are unaffected. */ export declare function computeDrift(db: Kysely>, dialect: Dialect, metadata: MetaRoot, opts?: ComputeDriftOptions): Promise; //# sourceMappingURL=drift.d.ts.map