import type { EntityManagerType, IDatabaseDriver } from './drivers/IDatabaseDriver.js';
import { type EntitySchema } from './metadata/EntitySchema.js';
import { MetadataStorage } from './metadata/MetadataStorage.js';
import { Configuration, type Options } from './utils/Configuration.js';
import type { EntityManager } from './EntityManager.js';
import type {
  AnyEntity,
  Constructor,
  EntityClass,
  EntityMetadata,
  EntityName,
  IEntityGenerator,
  IMigrator,
  ISeedManager,
} from './typings.js';
/** @internal */
export declare function loadOptionalDependencies(options: Partial<Options>): Promise<void>;
/**
 * The main class used to configure and bootstrap the ORM.
 *
 * @example
 * ```ts
 * // import from driver package
 * import { MikroORM, defineEntity, p } from '@mikro-orm/sqlite';
 *
 * const User = defineEntity({
 *   name: 'User',
 *   properties: {
 *     id: p.integer().primary(),
 *     name: p.string(),
 *   },
 * });
 *
 * const orm = new MikroORM({
 *   entities: [User],
 *   dbName: 'my.db',
 * });
 * await orm.schema.update();
 *
 * const em = orm.em.fork();
 * const u1 = em.create(User, { name: 'John' });
 * const u2 = em.create(User, { name: 'Ben' });
 * await em.flush();
 * ```
 */
export declare class MikroORM<
  Driver extends IDatabaseDriver = IDatabaseDriver,
  EM extends Driver[typeof EntityManagerType] & EntityManager<Driver> = Driver[typeof EntityManagerType] &
    EntityManager<Driver>,
  Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
    | string
    | EntityClass<AnyEntity>
    | EntitySchema
  )[],
> {
  #private;
  /** The global EntityManager instance. If you are using `RequestContext` helper, it will automatically pick the request specific context under the hood */
  em: EM & {
    '~entities'?: Entities;
  };
  /** The database driver instance used by this ORM. */
  readonly driver: Driver;
  /** The ORM configuration instance. */
  readonly config: Configuration<Driver>;
  /**
   * Initialize the ORM, load entity metadata, create EntityManager and connect to the database.
   * If you omit the `options` parameter, your CLI config will be used.
   */
  static init<
    D extends IDatabaseDriver = IDatabaseDriver,
    EM extends D[typeof EntityManagerType] & EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>,
    Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
      | string
      | EntityClass<AnyEntity>
      | EntitySchema
    )[],
  >(options: Partial<Options<D, EM, Entities>>): Promise<MikroORM<D, EM, Entities>>;
  /**
   * Synchronous variant of the `init` method with some limitations:
   * - folder-based discovery not supported
   * - ORM extensions are not autoloaded
   * - when metadata cache is enabled, `FileCacheAdapter` needs to be explicitly set in the config
   */
  constructor(options: Partial<Options<Driver, EM, Entities>>);
  /**
   * Connects to the database.
   */
  connect(): Promise<Driver>;
  /**
   * Reconnects, possibly to a different database.
   */
  reconnect(options?: Partial<Options<Driver, EM, Entities>>): Promise<void>;
  /**
   * Checks whether the database connection is active.
   */
  isConnected(): Promise<boolean>;
  /**
   * Checks whether the database connection is active, returns the reason if not.
   */
  checkConnection(): Promise<
    | {
        ok: true;
      }
    | {
        ok: false;
        reason: string;
        error?: Error;
      }
  >;
  /**
   * Closes the database connection.
   */
  close(force?: boolean): Promise<void>;
  /**
   * Gets the `MetadataStorage`.
   */
  getMetadata(): MetadataStorage;
  /**
   * Gets the `EntityMetadata` instance when provided with the `entityName` parameter.
   */
  getMetadata<Entity extends object>(entityName: EntityName<Entity>): EntityMetadata<Entity>;
  private createEntityManager;
  /**
   * Allows dynamically discovering new entity by reference, handy for testing schema diffing.
   */
  discoverEntity<T extends Constructor | EntitySchema>(entities: T | T[], reset?: EntityName | EntityName[]): void;
  /**
   * Gets the SchemaGenerator.
   */
  get schema(): ReturnType<ReturnType<Driver['getPlatform']>['getSchemaGenerator']>;
  /**
   * Gets the SeedManager
   */
  get seeder(): ISeedManager;
  /**
   * Gets the Migrator.
   */
  get migrator(): IMigrator;
  /**
   * Gets the EntityGenerator.
   */
  get entityGenerator(): IEntityGenerator;
}
