forked from launchdarkly/react-client-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
110 lines (98 loc) · 3.46 KB
/
types.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
import { LDClient, LDFlagSet, LDOptions, LDUser } from 'launchdarkly-js-client-sdk';
import * as React from 'react';
/**
* Initialization options for the LaunchDarkly React SDK. These are in addition to the options exposed
* by [[LDOptions]] which are common to both the JavaScript and React SDKs.
*/
export interface LDReactOptions {
/**
* Whether the React SDK should transform flag keys into camel-cased format.
* Using camel-cased flag keys allow for easier use as prop values, however,
* these keys won't directly match the flag keys as known to LaunchDarkly.
* Consequently, flag key collisions may be possible and the Code References feature
* will not function properly.
*
* This is true by default, meaning that keys will automatically be converted to camel-case.
*
* For more information, see the React SDK Reference Guide on
* [flag keys](https://docs.launchdarkly.com/docs/react-sdk-reference#section-flag-keys).
*
* @see https://docs.launchdarkly.com/docs/react-sdk-reference#section-flag-keys
*/
useCamelCaseFlagKeys?: boolean;
}
/**
* Contains default values for the `reactOptions` object.
*/
export const defaultReactOptions = { useCamelCaseFlagKeys: true };
/**
* Configuration object used to initialise LaunchDarkly's JS client.
*/
export interface ProviderConfig {
/**
* Your project and environment specific client side ID. You can find
* this in your LaunchDarkly portal under Account settings. This is
* the only mandatory property required to use the React SDK.
*/
clientSideID: string;
/**
* A LaunchDarkly user object. If unspecified, a new user with a
* random key will be created and used. This user's key will remain constant across browser sessions.
*
* @see http://docs.launchdarkly.com/docs/js-sdk-reference#section-users
*/
user?: LDUser;
/**
* If set to true, the ldClient will not be initialized until the user prop has been defined.
*/
deferInitialization?: boolean;
/**
* LaunchDarkly initialization options. These options are common between LaunchDarkly's JavaScript and React SDKs.
*
* @see https://docs.launchdarkly.com/docs/js-sdk-reference#section-customizing-your-client
*/
options?: LDOptions;
/**
* Additional initialization options specific to the React SDK.
*
* @see options
*/
reactOptions?: LDReactOptions;
/**
* If specified, `launchdarkly-react-client-sdk` will only request and listen to these flags.
* Otherwise, all flags will be requested and listened to.
*/
flags?: LDFlagSet;
/**
* Optionally, the LDClient can be initialised outside of the provider
* and passed in, instead of being initialised by the provider.
*/
ldClient?: LDClient | Promise<LDClient | undefined>;
}
/**
* The return type of withLDProvider HOC. Exported for testing purposes only.
*
* @ignore
*/
export interface EnhancedComponent extends React.Component {
subscribeToChanges(ldClient: LDClient): void;
// tslint:disable-next-line:invalid-void
componentDidMount(): Promise<void>;
// tslint:disable-next-line:invalid-void
componentDidUpdate(prevProps: ProviderConfig): Promise<void>;
}
/**
* Return type of `initLDClient`.
*/
export interface AllFlagsLDClient {
/**
* Contains all flags from LaunchDarkly.
*/
flags: LDFlagSet;
/**
* An instance of `LDClient` from the LaunchDarkly JS SDK (`launchdarkly-js-client-sdk`).
*
* @see http://docs.launchdarkly.com/docs/js-sdk-reference
*/
ldClient: LDClient;
}