import type { Result, Tx } from '../database-layer/db.js'; import type { Resolvable } from '../sbvr-api/common-types.js'; import { TypedError } from 'typed-error'; export { migrator as migratorEnv } from '../config-loader/env.js'; import * as sbvrUtils from '../sbvr-api/sbvr-utils.js'; export declare enum MigrationCategories { 'sync' = "sync", 'async' = "async" } export declare const defaultMigrationCategory = MigrationCategories['sync']; export type CategorizedMigrations = { [key in MigrationCategories]: RunnableMigrations; }; type SbvrUtils = typeof sbvrUtils; export type MigrationTuple = [string, Migration]; export type MigrationFn = (tx: Tx, sbvrUtils: SbvrUtils) => Resolvable; export type RunnableMigrations = { [key: string]: Migration; }; export type RunnableAsyncMigrations = { [key: string]: AsyncMigration; }; export type Migrations = CategorizedMigrations | RunnableMigrations; export type AsyncMigrationFn = (tx: Tx, options: { batchSize: number; }, sbvrUtils: SbvrUtils) => Resolvable; type AddFn = T & { [key in `${x}Fn`]: key extends 'syncFn' ? MigrationFn : AsyncMigrationFn; } & { [key in `${x}Sql`]?: undefined; }; type AddSql = T & { [key in `${x}Fn`]?: undefined; } & { [key in `${x}Sql`]: string; }; export type BaseAsyncMigration = { type?: MigrationCategories.async; delayMS?: number | undefined; backoffDelayMS?: number | undefined; errorThreshold?: number | undefined; asyncBatchSize?: number | undefined; finalize?: boolean | undefined; }; export type AsyncMigration = AddFn | AddSql | AddFn, 'sync'> | AddFn, 'async'>; export declare function isAsyncMigration(migration: string | MigrationFn | AsyncMigration | RunnableMigrations): migration is AsyncMigration; export declare function isSyncMigration(migration: string | MigrationFn | RunnableMigrations | AsyncMigration): migration is MigrationFn; export declare function areCategorizedMigrations($migrations: Migrations): $migrations is CategorizedMigrations; export type Migration = string | MigrationFn | AsyncMigration; export declare class MigrationError extends TypedError { } export type MigrationStatus = { migration_key: string; start_time: string | undefined | null; last_run_time: string | undefined | null; run_count: number; migrated_row_count: number; error_count: number; converged_time: string | undefined | null; is_backing_off: boolean | undefined | null; }; export type MigrationExecutionResult = undefined | { pendingUnsetMigrations: string[]; }; export declare const getRunnableAsyncMigrations: ($migrations: Migrations) => RunnableAsyncMigrations | undefined; export declare const getRunnableSyncMigrations: ($migrations: Migrations) => RunnableMigrations; export declare const filterAndSortPendingMigrations: ($migrations: NonNullable, executedMigrations: string[]) => MigrationTuple[]; export declare const binds: (strings: TemplateStringsArray, ...bindNums: number[]) => string; export declare const lockMigrations: (options: { tx: Tx; modelName: string; blocking: boolean; }, fn: () => Promise) => Promise; export declare const setExecutedMigrations: (tx: Tx, modelName: string, executedMigrations: string[]) => Promise; export declare const getExecutedMigrations: (tx: Tx, modelName: string) => Promise; export declare const migrationTablesExist: (tx: Tx) => Promise; export declare const initMigrationStatus: (tx: Tx, migrationStatus: MigrationStatus) => Promise; export declare const updateMigrationStatus: (tx: Tx, migrationStatus: MigrationStatus) => Promise; export declare const readMigrationStatus: (tx: Tx, migrationKey: string) => Promise;