-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtypings.d.ts
135 lines (126 loc) · 4.9 KB
/
typings.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* This is the API reference for the LaunchDarkly Client-Side Node SDK.
*
*
* In typical usage, you will call {@link initialize} once at startup time to obtain an instance of
* {@link LDClient}, which provides access to all of the SDK's functionality.
*
* For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
*
* @packageDocumentation
*/
declare module 'launchdarkly-node-client-sdk' {
export * from 'launchdarkly-js-sdk-common';
import {
BasicLoggerOptions,
LDEvaluationDetail,
LDEvaluationReason,
LDFlagSet,
LDFlagValue,
LDClientBase,
LDLogger,
LDOptionsBase,
LDContext
} from 'launchdarkly-js-sdk-common';
/**
* The current version string of the SDK.
*/
export const version: string;
/**
* Creates an instance of the LaunchDarkly client.
*
* Applications should instantiate a single instance for the lifetime of the application.
* The client will begin attempting to connect to LaunchDarkly as soon as it is created. To
* determine when it is ready to use, call {@link LDClient.waitForInitialization}, or register an
* event listener for the `"ready"` event using {@link LDClient.on}.
*
* @param envKey
* The LaunchDarkly environment ID.
* @param context
* The initial context properties. These can be changed later with {@link LDClient.identify}.
* The context must have a `key` property, except that if you omit `context.key` and set `context.anonymous` to
* true, the SDK will create a randomized unique key (which will be cached in local storage for the
* current OS user account, so the next initialization will reuse the same key).
* @param options
* Optional configuration settings.
*/
export function initialize(envKey: string, context: LDContext, options?: LDOptions): LDClient;
/**
* Initialization options for the LaunchDarkly client.
*/
export interface LDOptions extends LDOptionsBase {
/**
* Determines where flag values and anonymous context keys are cached in the filesystem. By
* default, this is the current directory.
*/
localStoragePath?: string;
/**
* Additional parameters to pass to the Node HTTPS API for secure requests. These can include any
* of the TLS-related parameters supported by `https.request()`, such as `ca`, `cert`, and `key`.
*/
tlsParams?: LDTLSOptions;
}
/**
* Additional parameters to pass to the Node HTTPS API for secure requests. These can include any
* of the TLS-related parameters supported by `https.request()`, such as `ca`, `cert`, and `key`.
* This object should be stored in the `tlsParams` property of {@link LDOptions}.
*
* For more information, see the Node documentation for `https.request()` and `tls.connect()`.
*/
export interface LDTLSOptions {
ca?: string | string[] | Buffer | Buffer[];
cert?: string | string[] | Buffer | Buffer[];
checkServerIdentity?: (servername: string, cert: any) => Error | undefined;
ciphers?: string;
pfx?: string | string[] | Buffer | Buffer[] | object[];
key?: string | string[] | Buffer | Buffer[] | object[];
passphrase?: string;
rejectUnauthorized?: boolean;
secureProtocol?: string;
servername?: string;
}
/**
* The LaunchDarkly SDK client object.
*
* Applications should configure the client at startup time with {@link initialize}, and reuse the same instance.
*
* For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
*/
export interface LDClient extends LDClientBase {
}
/**
* Provides a simple {@link LDLogger} implementation.
*
* This logging implementation uses a simple format that includes only the log level
* and the message text. Output is written to the standard error stream (`console.error`).
* You can filter by log level as described in {@link BasicLoggerOptions.level}.
*
* To use the logger created by this function, put it into {@link LDOptions.logger}. If
* you do not set {@link LDOptions.logger} to anything, the SDK uses a default logger
* that is equivalent to `ld.basicLogger({ level: 'info' })`.
*
* @param options Configuration for the logger. If no options are specified, the
* logger uses `{ level: 'info' }`.
*
* @example
* This example shows how to use `basicLogger` in your SDK options to enable console
* logging only at `warn` and `error` levels.
* ```javascript
* const ldOptions = {
* logger: ld.basicLogger({ level: 'warn' }),
* };
* ```
*
* @example
* This example shows how to use `basicLogger` in your SDK options to cause log
* output to go to `console.log` instead of `console.error`.
* ```javascript
* const ldOptions = {
* logger: ld.basicLogger({ destination: console.log }),
* };
* ```
*/
export function basicLogger(
options?: BasicLoggerOptions
): LDLogger;
}