UNPKG

2.21 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 full name (hostname + port).
37 */
38 get host(): string | undefined;
39 /**
40 * Safe read-accessor to the first host's name.
41 */
42 get hostname(): string | undefined;
43 /**
44 * Safe read-accessor to the first host's port.
45 */
46 get port(): number | undefined;
47 /**
48 * Safe read-accessor to the first host's type.
49 */
50 get type(): HostType | undefined;
51 /**
52 * Constructor.
53 *
54 * @param cs - connection string (can be empty).
55 *
56 * @param defaults - optional defaults, which can also be set
57 * explicitly, via method setDefaults.
58 */
59 constructor(cs?: string | null, defaults?: IConnectionDefaults);
60 /**
61 * Parses a host name into an object, which then can be passed into `setDefaults`.
62 *
63 * It returns `null` only when no valid host recognized.
64 */
65 static parseHost(host: string): IParsedHost | null;
66 /**
67 * Converts this object into a valid connection string.
68 */
69 toString(options?: IEncodingOptions): string;
70 /**
71 * Applies default parameters, and returns itself.
72 */
73 setDefaults(defaults: IConnectionDefaults): this;
74}