import { DbConnectionInfo } from ".." ; import { IDbAdapter , IDbAdapterConstructor , IDbAdapterExtension } from "./db-adapter" ; /**
 * Factory for registering and creating database adapters.
 */ export class DbAdapterFactory { private static readonly ADAPTERS = { } ; private constructor ( ) { } param name param adapterType static registerAdapter ( name , adapterType ) { DbAdapterFactory . ADAPTERS [ name ] = adapterType ; } internal param connectionInfo static create ( connectionInfo ) { const adapterName = connectionInfo . adapter ; const adapterType = DbAdapterFactory . ADAPTERS [ adapterName ] ; if ( adapterType !== undefined ) { return new adapterType ( connectionInfo ) ; } throw new TypeError ( `Cannot create DB adapter '${ adapterName }': adapter is not registered.` ) ; } }