/** * Migration Runner * * Core migration logic: validate migration registries, run migrations, * and preview migrations via dry-run. */ import { Effect, type Ref } from "effect"; import { MigrationError } from "../errors/migration-errors.js"; import type { SerializationError, StorageError, UnsupportedFormatError } from "../errors/storage-errors.js"; import { SerializerRegistry } from "../serializers/serializer-service.js"; import { StorageAdapter } from "../storage/storage-service.js"; import { type DatabaseConfig } from "../types/database-config-types.js"; import type { DryRunResult, Migration } from "./migration-types.js"; /** * Run migrations to transform data from one version to another. * * Filters migrations to only those applicable for the version transition, * then runs each transform in order, piping the output of one to the input * of the next. * * @param data - The raw entity map to migrate * @param fileVersion - The version of the data (from file's _version, or 0 if absent) * @param targetVersion - The target schema version from collection config * @param migrations - The full migration registry for this collection * @param collectionName - Name of the collection (for error messages) * @returns Effect, MigrationError> - the migrated data */ export declare const runMigrations: (data: Record, fileVersion: number, targetVersion: number, migrations: ReadonlyArray, collectionName: string) => Effect.Effect, MigrationError>; /** * Validate that a migration registry forms a valid, contiguous chain. * * Validation rules: * - Migrations must form a contiguous chain (no gaps in `from`/`to`) * - Each migration's `to` must equal `from + 1` * - No duplicate `from` values * - The last migration's `to` must equal the collection's `version` * - Version 0 with no migrations is valid * - Version > 0 with empty migrations is invalid * * @param collectionName - Name of the collection (for error messages) * @param version - Target schema version from collection config * @param migrations - Array of migrations to validate * @returns Effect - succeeds if valid, fails with MigrationError if invalid */ export declare const validateMigrationRegistry: (collectionName: string, version: number, migrations: ReadonlyArray) => Effect.Effect; /** * Internal Ref map type for cross-collection access. */ type HasId = { readonly id: string; }; type StateRefs = Record>>; /** * Preview which files need migration and what transforms would apply. * * For each versioned collection with a file path: * - Read the file and extract `_version` * - Compare to config `version` * - List which migrations would apply (without running transforms) * - Report status * * No transforms are executed. No files are written. * * @param config - The database configuration * @param _stateRefs - State refs (unused, but kept for API consistency) * @returns Effect */ export declare const dryRunMigrations: (config: DatabaseConfig, _stateRefs: StateRefs) => Effect.Effect; export {}; //# sourceMappingURL=migration-runner.d.ts.map