connection-string
Version:
Advanced URL Connection String parser + generator.
75 lines (74 loc) • 2.15 kB
TypeScript
import { HostType, IConnectionDefaults, IEncodingOptions, IParsedHost } from './types';
export declare class ConnectionString {
/**
* Connection protocol, if specified,
* or else the property does not exist.
*/
protocol?: string;
/**
* Username, if specified,
* or else the property does not exist.
*/
user?: string;
/**
* User password, if specified,
* or else the property does not exist.
*/
password?: string;
/**
* List of parsed hosts, if at least one is specified,
* or else the property does not exist.
*/
hosts?: IParsedHost[];
/**
* Url path segments, if at least one is specified,
* or else the property does not exist.
*/
path?: string[];
/**
* Url parameters, if at least one is specified,
* or else the property does not exist.
*/
params?: {
[]: any;
};
/**
* Safe read-accessor to the first host's full name (hostname + port).
*/
get host(): string | undefined;
/**
* Safe read-accessor to the first host's name (without port).
*/
get hostname(): string | undefined;
/**
* Safe read-accessor to the first host's port.
*/
get port(): number | undefined;
/**
* Safe read-accessor to the first host's type.
*/
get type(): HostType | undefined;
/**
* Constructor.
*
* @param cs - connection string (can be empty).
*
* @param defaults - optional defaults, which can also be set
* explicitly, via method setDefaults.
*/
constructor(cs?: string | null, defaults?: IConnectionDefaults);
/**
* Parses a host name into an object, which then can be passed into `setDefaults`.
*
* It returns `null` only when no valid host recognized.
*/
static parseHost(host: string): IParsedHost | null;
/**
* Converts this object into a valid connection string.
*/
toString(options?: IEncodingOptions): string;
/**
* Applies default parameters, and returns itself.
*/
setDefaults(defaults: IConnectionDefaults): this;
}