UNPKG

lakutata

Version:

An IoC-based universal application framework.

108 lines (103 loc) 3.56 kB
import { BaseDataSourceOptions, DataSource, DataSourceOptions } from './TypeDef.internal.33.js'; import './TypeDef.internal.30.js'; /** * BaseConnectionOptions is set of connection options shared by all database types. * * @deprecated */ type BaseConnectionOptions = BaseDataSourceOptions; /** * ConnectionManager is used to store and manage multiple orm connections. * It also provides useful factory methods to simplify connection creation. * * @deprecated */ declare class ConnectionManager { /** * List of connections registered in this connection manager. */ get connections(): DataSource[]; /** * Internal lookup to quickly get from a connection name to the Connection object. */ private readonly connectionMap; /** * Checks if connection with the given name exist in the manager. */ has(name: string): boolean; /** * Gets registered connection with the given name. * If connection name is not given then it will get a default connection. * Throws error if connection with the given name was not found. */ get(name?: string): DataSource; /** * Creates a new connection based on the given connection options and registers it in the manager. * Connection won't be established, you'll need to manually call connect method to establish connection. */ create(options: DataSourceOptions): DataSource; } /** * Reads connection options from the ormconfig. */ declare class ConnectionOptionsReader { protected options?: { /** * Directory where ormconfig should be read from. * By default its your application root (where your app package.json is located). */ root?: string; /** * Filename of the ormconfig configuration. By default its equal to "ormconfig". */ configName?: string; } | undefined; constructor(options?: { /** * Directory where ormconfig should be read from. * By default its your application root (where your app package.json is located). */ root?: string; /** * Filename of the ormconfig configuration. By default its equal to "ormconfig". */ configName?: string; } | undefined); /** * Returns all connection options read from the ormconfig. */ all(): Promise<DataSourceOptions[]>; /** * Gets a connection with a given name read from ormconfig. * If connection with such name would not be found then it throw error. */ get(name: string): Promise<DataSourceOptions>; /** * Checks if there is a TypeORM configuration file. */ has(name: string): Promise<boolean>; /** * Loads all connection options from a configuration file. * * todo: get in count NODE_ENV somehow */ protected load(): Promise<DataSourceOptions[] | undefined>; /** * Normalize connection options. */ protected normalizeConnectionOptions(connectionOptions: DataSourceOptions | DataSourceOptions[]): DataSourceOptions[]; /** * Gets directory where configuration file should be located and configuration file name. */ protected get baseFilePath(): string; /** * Gets directory where configuration file should be located. */ protected get baseDirectory(): string; /** * Gets configuration file name. */ protected get baseConfigName(): string; } export { ConnectionManager, ConnectionOptionsReader }; export type { BaseConnectionOptions };