UNPKG

2.07 kBTypeScriptView Raw
1import { HostType, IConnectionDefaults, IEncodingOptions, IParsedHost } from './types';
2export declare class ConnectionString {
3 /**
4 * Connection protocol, if specified,
5 * or else the property does not exist.
6 */
7 protocol?: string;
8 /**
9 * User name, if specified,
10 * or else the property does not exist.
11 */
12 user?: string;
13 /**
14 * User password, if specified,
15 * or else the property does not exist.
16 */
17 password?: string;
18 /**
19 * List of parsed hosts, if at least one is specified,
20 * or else the property does not exist.
21 */
22 hosts?: IParsedHost[];
23 /**
24 * Url path segments, if at least one is specified,
25 * or else the property does not exist.
26 */
27 path?: string[];
28 /**
29 * Url parameters, if at least one is specified,
30 * or else the property does not exist.
31 */
32 params?: {
33 [name: string]: any;
34 };
35 /**
36 * Safe read-accessor to the first host's name.
37 */
38 get hostname(): string | undefined;
39 /**
40 * Safe read-accessor to the first host's port.
41 */
42 get port(): number | undefined;
43 /**
44 * Safe read-accessor to the first host's type.
45 */
46 get type(): HostType | undefined;
47 /**
48 * Constructor.
49 *
50 * @param cs - connection string (can be empty).
51 *
52 * @param defaults - optional defaults, which can also be set
53 * explicitly, via method setDefaults.
54 */
55 constructor(cs: string, defaults?: IConnectionDefaults);
56 /**
57 * Parses a host name into an object, which then can be passed into `setDefaults`.
58 *
59 * It returns `null` only when no valid host recognized.
60 */
61 static parseHost(host: string): IParsedHost | null;
62 /**
63 * Converts this object into a valid connection string.
64 */
65 toString(options?: IEncodingOptions): string;
66 /**
67 * Applies default parameters, and returns itself.
68 */
69 setDefaults(defaults: IConnectionDefaults): this;
70}