UNPKG

object-migrations

Version:

Linear, in-memory migrations for versioned objects

66 lines (65 loc) 1.81 kB
import { type Version } from './migrator.js'; /** * Base class for all errors thrown by the migrator. */ export declare abstract class MigratorError extends Error { constructor(name: string, message: string); } /** * Wraps an error thrown within the migration function, while migrating an object between successive * versions. */ export declare class MigrationError extends MigratorError { /** * Version from which migration was attempted (version of the object being migrated). */ readonly from: Version; /** * Version to which migration was attempted. */ readonly to: Version; /** * The underlying (wrapped) error. */ readonly cause: unknown; constructor( /** * Version from which migration was attempted (version of the object being migrated). */ from: Version, /** * Version to which migration was attempted. */ to: Version, /** * The underlying (wrapped) error. */ cause: unknown); } /** * Indicates that the sequence of steps to migrate an object between two versions couldn't be * determined. * * Occurs when migrations between the versions (or a chain of migrations between successive versions * starting & ending at the them) haven't been registered beforehand. */ export declare class NoMigrationStepsError extends MigratorError { /** * Version from which migration was attempted. */ readonly from: Version; /** * Version to which migration was attempted. */ readonly to: Version; constructor( /** * Version from which migration was attempted. */ from: Version, /** * Version to which migration was attempted. */ to: Version); } export declare function describeVersion(v: Version): string;