import { Config } from 'arangojs/connection';
import { Database } from 'arangojs';
import { CollectionType, CreateCollectionOptions, DocumentCollection, EdgeCollection } from 'arangojs/collection';
import { TransactionOptions } from 'arangojs/database';
declare type Collection = DocumentCollection<any> & EdgeCollection<any>;
export interface CollectionOptions {
    collectionName: string;
    options?: CreateCollectionOptions & {
        type?: CollectionType;
    };
}
export declare type Collections = Array<string | CollectionOptions>;
export declare type StepFunction = (callback: any) => Promise<any>;
export interface Migration {
    /**
     * Optional function that will be called after the migration's `down` function is executed.
     * @param {Database} db - Database instance.
     * @param {*} data - Optional value received from the `beforeDown` function.
     * @returns {Promise<*>} - Value returned will be passed to the `afterDown` function.
     */
    afterDown?: (db: Database, data?: any) => Promise<any>;
    /**
     * Optional function that will be called after the migration's `up` function is executed.
     * @param {Database} db - Database instance.
     * @param {*} data - Value returned from the `up` function.
     * @returns {Promise<*>} - Value returned will be passed to the `afterUp` function.
     */
    afterUp?: (db: Database, data?: any) => Promise<void>;
    /**
     * Optional function that will be called before the migration's `down` function is executed.
     * @param {Database} db - Database instance.
     * @returns {Promise<*>} - Value returned will be passed to the `down` function.
     */
    beforeDown?: (db: Database) => Promise<any>;
    /**
     * Optional function that will be called before the migration's `up` function is executed.
     * @param {Database} db -  Database instance.
     * @returns {Promise<*>} - Value returned will be passed to the `up` function.
     */
    beforeUp?: (db: Database) => Promise<any>;
    /**
     * Defines all the collections that will be used as part of this migration.
     * @returns {Promise<Collections>} An array of collection names or an array of collection options.
     */
    collections(): Promise<Collections>;
    /**
     * Optional description of what the migration does. This value will be stored in the migration log.
     */
    description?: string;
    /**
     * Function that will be called to perform the `down` migration.
     * @param {Database} db - Database instance.
     * @param {StepFunction} - step The `step` function is used to add valid ArangoDB operations to the transaction.
     * @param {*} data - Optional value received from the `beforeDown` function.
     */
    down?: (db: Database, step: StepFunction, data?: any) => Promise<any>;
    /**
     * Optional function that configures how the transaction will be executed. See ArangoDB documentation for more information.
     * @returns {Promise<TransactionOptions>} - The transaction options.
     */
    transactionOptions?: () => Promise<TransactionOptions>;
    /**
     * Function that will be called to perform the `up` migration.
     * @param {Database} - db Database instance.
     * @param {StepFunction} - step The `step` function is used to add valid ArangoDB operations to the transaction.
     * @param {*} data Optional value received from the `beforeUp` function.
     */
    up: (db: Database, step: StepFunction, data?: any) => Promise<any>;
}
export interface MigrationHistory {
    _id: string;
    _key: string;
    counter: number;
    createdAt: string;
    description?: string;
    direction: 'up' | 'down';
    name: string;
    version: number;
}
export interface ArangoMigrateOptions {
    /**
     * Automatically create referenced collections if they do not exist. Defaults to `true`.
     */
    autoCreateNewCollections?: boolean;
    /**
     * ArangoDB connection options.
     */
    dbConfig: Config;
    /**
     * The collection in which the migration history will be stored. Defaults to `migration_history`.
     */
    migrationHistoryCollection?: string;
    /**
     * Path to the directory containing the migration files.
     */
    migrationsPath: string;
}
export declare const DEFAULT_CONFIG_PATH = "./config.migrate.js";
export declare const DEFAULT_MIGRATIONS_PATH = "./migrations";
export declare const DEFAULT_MIGRATION_HISTORY_COLLECTION = "migration_history";
export declare class ArangoMigrate {
    private readonly options;
    private readonly migrationHistoryCollection;
    private db;
    private readonly migrationPaths;
    private readonly migrationsPath;
    constructor(options: ArangoMigrateOptions);
    static loadConfig(configPath?: string): Promise<ArangoMigrateOptions>;
    loadMigrationPaths(migrationsPath: string): any[];
    getMigrationPaths(): string[];
    initialize(): Promise<void>;
    migrationExists(version: number): boolean;
    getMigrationPathFromVersion(version: number): string;
    getMigrationFromVersion(version: number): Promise<Migration>;
    getMigrationHistoryCollection(): Promise<DocumentCollection<any>>;
    getMigrationHistory(direction?: 'ASC' | 'DESC'): Promise<MigrationHistory[]>;
    getLatestMigration(): Promise<MigrationHistory | null>;
    writeMigrationHistory(direction: 'up' | 'down', name: string, description: string, version: number): Promise<void>;
    initializeTransactionCollections(collections: Collections): Promise<{
        transactionCollections: any[];
        newCollections: Set<Collection>;
        allCollectionNames: Set<string>;
        createdCollectionCount: number;
    }>;
    runUpMigrations(to?: number, dryRun?: boolean, noHistory?: boolean): Promise<{
        appliedMigrations: number;
        createdCollections: number;
    }>;
    runDownMigrations(to?: number, dryRun?: boolean, noHistory?: boolean, disallowMissingVersions?: boolean): Promise<{
        appliedMigrations: number;
        createdCollections: number;
    }>;
    getVersionsFromMigrationPaths(): number[];
    validateMigrationFolderNotEmpty(): void;
    validateMigrationVersions(): void;
    validateMigrationVersion(version: number): Promise<void>;
    writeNewMigration(name: string, typescript: boolean): string;
    hasNewMigrations(): Promise<boolean>;
}
export {};
