@launchdarkly/js-client-sdk-common 1.9.1-beta.1 → 1.9.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/{index.cjs → cjs/index.cjs} +1 -1
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/package.json +1 -0
  4. package/dist/esm/DataManager.d.ts +65 -0
  5. package/dist/esm/DataManager.d.ts.map +1 -0
  6. package/dist/esm/HookRunner.d.ts +12 -0
  7. package/dist/esm/HookRunner.d.ts.map +1 -0
  8. package/dist/esm/LDClientImpl.d.ts +84 -0
  9. package/dist/esm/LDClientImpl.d.ts.map +1 -0
  10. package/dist/esm/LDEmitter.d.ts +32 -0
  11. package/dist/esm/LDEmitter.d.ts.map +1 -0
  12. package/dist/esm/api/ConnectionMode.d.ts +16 -0
  13. package/dist/esm/api/ConnectionMode.d.ts.map +1 -0
  14. package/dist/esm/api/LDClient.d.ts +315 -0
  15. package/dist/esm/api/LDClient.d.ts.map +1 -0
  16. package/dist/esm/api/LDEvaluationDetail.d.ts +26 -0
  17. package/dist/esm/api/LDEvaluationDetail.d.ts.map +1 -0
  18. package/dist/esm/api/LDIdentifyOptions.d.ts +23 -0
  19. package/dist/esm/api/LDIdentifyOptions.d.ts.map +1 -0
  20. package/dist/esm/api/LDInspection.d.ts +105 -0
  21. package/dist/esm/api/LDInspection.d.ts.map +1 -0
  22. package/dist/esm/api/LDOptions.d.ts +246 -0
  23. package/dist/esm/api/LDOptions.d.ts.map +1 -0
  24. package/dist/esm/api/index.d.ts +8 -0
  25. package/dist/esm/api/index.d.ts.map +1 -0
  26. package/dist/esm/api/integrations/Hooks.d.ts +133 -0
  27. package/dist/esm/api/integrations/Hooks.d.ts.map +1 -0
  28. package/dist/esm/api/integrations/index.d.ts +2 -0
  29. package/dist/esm/api/integrations/index.d.ts.map +1 -0
  30. package/dist/esm/configuration/Configuration.d.ts +86 -0
  31. package/dist/esm/configuration/Configuration.d.ts.map +1 -0
  32. package/dist/esm/configuration/index.d.ts +3 -0
  33. package/dist/esm/configuration/index.d.ts.map +1 -0
  34. package/dist/esm/configuration/validators.d.ts +5 -0
  35. package/dist/esm/configuration/validators.d.ts.map +1 -0
  36. package/dist/esm/context/addAutoEnv.d.ts +31 -0
  37. package/dist/esm/context/addAutoEnv.d.ts.map +1 -0
  38. package/dist/esm/context/ensureKey.d.ts +10 -0
  39. package/dist/esm/context/ensureKey.d.ts.map +1 -0
  40. package/dist/esm/crypto/digest.d.ts +3 -0
  41. package/dist/esm/crypto/digest.d.ts.map +1 -0
  42. package/dist/esm/datasource/DataSourceConfig.d.ts +25 -0
  43. package/dist/esm/datasource/DataSourceConfig.d.ts.map +1 -0
  44. package/dist/esm/datasource/DataSourceEventHandler.d.ts +16 -0
  45. package/dist/esm/datasource/DataSourceEventHandler.d.ts.map +1 -0
  46. package/dist/esm/datasource/DataSourceStatus.d.ts +39 -0
  47. package/dist/esm/datasource/DataSourceStatus.d.ts.map +1 -0
  48. package/dist/esm/datasource/DataSourceStatusErrorInfo.d.ts +8 -0
  49. package/dist/esm/datasource/DataSourceStatusErrorInfo.d.ts.map +1 -0
  50. package/dist/esm/datasource/DataSourceStatusManager.d.ts +40 -0
  51. package/dist/esm/datasource/DataSourceStatusManager.d.ts.map +1 -0
  52. package/dist/esm/datasource/Requestor.d.ts +26 -0
  53. package/dist/esm/datasource/Requestor.d.ts.map +1 -0
  54. package/dist/esm/diagnostics/createDiagnosticsInitConfig.d.ts +16 -0
  55. package/dist/esm/diagnostics/createDiagnosticsInitConfig.d.ts.map +1 -0
  56. package/dist/esm/diagnostics/createDiagnosticsManager.d.ts +5 -0
  57. package/dist/esm/diagnostics/createDiagnosticsManager.d.ts.map +1 -0
  58. package/dist/esm/evaluation/evaluationDetail.d.ts +5 -0
  59. package/dist/esm/evaluation/evaluationDetail.d.ts.map +1 -0
  60. package/dist/esm/events/EventFactory.d.ts +2 -0
  61. package/dist/esm/events/EventFactory.d.ts.map +1 -0
  62. package/dist/esm/events/createEventProcessor.d.ts +5 -0
  63. package/dist/esm/events/createEventProcessor.d.ts.map +1 -0
  64. package/dist/esm/flag-manager/ContextIndex.d.ts +39 -0
  65. package/dist/esm/flag-manager/ContextIndex.d.ts.map +1 -0
  66. package/dist/esm/flag-manager/FlagManager.d.ts +81 -0
  67. package/dist/esm/flag-manager/FlagManager.d.ts.map +1 -0
  68. package/dist/esm/flag-manager/FlagPersistence.d.ts +43 -0
  69. package/dist/esm/flag-manager/FlagPersistence.d.ts.map +1 -0
  70. package/dist/esm/flag-manager/FlagStore.d.ts +29 -0
  71. package/dist/esm/flag-manager/FlagStore.d.ts.map +1 -0
  72. package/dist/esm/flag-manager/FlagUpdater.d.ts +40 -0
  73. package/dist/esm/flag-manager/FlagUpdater.d.ts.map +1 -0
  74. package/dist/esm/flag-manager/ItemDescriptor.d.ts +10 -0
  75. package/dist/esm/flag-manager/ItemDescriptor.d.ts.map +1 -0
  76. package/dist/esm/flag-manager/calculateChangedKeys.d.ts +6 -0
  77. package/dist/esm/flag-manager/calculateChangedKeys.d.ts.map +1 -0
  78. package/dist/esm/index.d.ts +20 -0
  79. package/dist/esm/index.d.ts.map +1 -0
  80. package/dist/{index.mjs → esm/index.mjs} +1 -1
  81. package/dist/esm/index.mjs.map +1 -0
  82. package/dist/esm/inspection/InspectorManager.d.ts +41 -0
  83. package/dist/esm/inspection/InspectorManager.d.ts.map +1 -0
  84. package/dist/esm/inspection/createSafeInspector.d.ts +8 -0
  85. package/dist/esm/inspection/createSafeInspector.d.ts.map +1 -0
  86. package/dist/esm/inspection/getInspectorHook.d.ts +4 -0
  87. package/dist/esm/inspection/getInspectorHook.d.ts.map +1 -0
  88. package/dist/esm/inspection/messages.d.ts +3 -0
  89. package/dist/esm/inspection/messages.d.ts.map +1 -0
  90. package/dist/esm/package.json +1 -0
  91. package/dist/esm/polling/PollingProcessor.d.ts +3 -0
  92. package/dist/esm/polling/PollingProcessor.d.ts.map +1 -0
  93. package/dist/esm/storage/getOrGenerateKey.d.ts +11 -0
  94. package/dist/esm/storage/getOrGenerateKey.d.ts.map +1 -0
  95. package/dist/esm/storage/namespaceUtils.d.ts +20 -0
  96. package/dist/esm/storage/namespaceUtils.d.ts.map +1 -0
  97. package/dist/esm/streaming/StreamingProcessor.d.ts +35 -0
  98. package/dist/esm/streaming/StreamingProcessor.d.ts.map +1 -0
  99. package/dist/esm/streaming/index.d.ts +4 -0
  100. package/dist/esm/streaming/index.d.ts.map +1 -0
  101. package/dist/esm/types/index.d.ts +21 -0
  102. package/dist/esm/types/index.d.ts.map +1 -0
  103. package/package.json +15 -7
  104. package/dist/index.cjs.map +0 -1
  105. package/dist/index.mjs.map +0 -1
  106. /package/dist/{DataManager.d.ts → cjs/DataManager.d.ts} +0 -0
  107. /package/dist/{DataManager.d.ts.map → cjs/DataManager.d.ts.map} +0 -0
  108. /package/dist/{HookRunner.d.ts → cjs/HookRunner.d.ts} +0 -0
  109. /package/dist/{HookRunner.d.ts.map → cjs/HookRunner.d.ts.map} +0 -0
  110. /package/dist/{LDClientImpl.d.ts → cjs/LDClientImpl.d.ts} +0 -0
  111. /package/dist/{LDClientImpl.d.ts.map → cjs/LDClientImpl.d.ts.map} +0 -0
  112. /package/dist/{LDEmitter.d.ts → cjs/LDEmitter.d.ts} +0 -0
  113. /package/dist/{LDEmitter.d.ts.map → cjs/LDEmitter.d.ts.map} +0 -0
  114. /package/dist/{api → cjs/api}/ConnectionMode.d.ts +0 -0
  115. /package/dist/{api → cjs/api}/ConnectionMode.d.ts.map +0 -0
  116. /package/dist/{api → cjs/api}/LDClient.d.ts +0 -0
  117. /package/dist/{api → cjs/api}/LDClient.d.ts.map +0 -0
  118. /package/dist/{api → cjs/api}/LDEvaluationDetail.d.ts +0 -0
  119. /package/dist/{api → cjs/api}/LDEvaluationDetail.d.ts.map +0 -0
  120. /package/dist/{api → cjs/api}/LDIdentifyOptions.d.ts +0 -0
  121. /package/dist/{api → cjs/api}/LDIdentifyOptions.d.ts.map +0 -0
  122. /package/dist/{api → cjs/api}/LDInspection.d.ts +0 -0
  123. /package/dist/{api → cjs/api}/LDInspection.d.ts.map +0 -0
  124. /package/dist/{api → cjs/api}/LDOptions.d.ts +0 -0
  125. /package/dist/{api → cjs/api}/LDOptions.d.ts.map +0 -0
  126. /package/dist/{api → cjs/api}/index.d.ts +0 -0
  127. /package/dist/{api → cjs/api}/index.d.ts.map +0 -0
  128. /package/dist/{api → cjs/api}/integrations/Hooks.d.ts +0 -0
  129. /package/dist/{api → cjs/api}/integrations/Hooks.d.ts.map +0 -0
  130. /package/dist/{api → cjs/api}/integrations/index.d.ts +0 -0
  131. /package/dist/{api → cjs/api}/integrations/index.d.ts.map +0 -0
  132. /package/dist/{configuration → cjs/configuration}/Configuration.d.ts +0 -0
  133. /package/dist/{configuration → cjs/configuration}/Configuration.d.ts.map +0 -0
  134. /package/dist/{configuration → cjs/configuration}/index.d.ts +0 -0
  135. /package/dist/{configuration → cjs/configuration}/index.d.ts.map +0 -0
  136. /package/dist/{configuration → cjs/configuration}/validators.d.ts +0 -0
  137. /package/dist/{configuration → cjs/configuration}/validators.d.ts.map +0 -0
  138. /package/dist/{context → cjs/context}/addAutoEnv.d.ts +0 -0
  139. /package/dist/{context → cjs/context}/addAutoEnv.d.ts.map +0 -0
  140. /package/dist/{context → cjs/context}/ensureKey.d.ts +0 -0
  141. /package/dist/{context → cjs/context}/ensureKey.d.ts.map +0 -0
  142. /package/dist/{crypto → cjs/crypto}/digest.d.ts +0 -0
  143. /package/dist/{crypto → cjs/crypto}/digest.d.ts.map +0 -0
  144. /package/dist/{datasource → cjs/datasource}/DataSourceConfig.d.ts +0 -0
  145. /package/dist/{datasource → cjs/datasource}/DataSourceConfig.d.ts.map +0 -0
  146. /package/dist/{datasource → cjs/datasource}/DataSourceEventHandler.d.ts +0 -0
  147. /package/dist/{datasource → cjs/datasource}/DataSourceEventHandler.d.ts.map +0 -0
  148. /package/dist/{datasource → cjs/datasource}/DataSourceStatus.d.ts +0 -0
  149. /package/dist/{datasource → cjs/datasource}/DataSourceStatus.d.ts.map +0 -0
  150. /package/dist/{datasource → cjs/datasource}/DataSourceStatusErrorInfo.d.ts +0 -0
  151. /package/dist/{datasource → cjs/datasource}/DataSourceStatusErrorInfo.d.ts.map +0 -0
  152. /package/dist/{datasource → cjs/datasource}/DataSourceStatusManager.d.ts +0 -0
  153. /package/dist/{datasource → cjs/datasource}/DataSourceStatusManager.d.ts.map +0 -0
  154. /package/dist/{datasource → cjs/datasource}/Requestor.d.ts +0 -0
  155. /package/dist/{datasource → cjs/datasource}/Requestor.d.ts.map +0 -0
  156. /package/dist/{diagnostics → cjs/diagnostics}/createDiagnosticsInitConfig.d.ts +0 -0
  157. /package/dist/{diagnostics → cjs/diagnostics}/createDiagnosticsInitConfig.d.ts.map +0 -0
  158. /package/dist/{diagnostics → cjs/diagnostics}/createDiagnosticsManager.d.ts +0 -0
  159. /package/dist/{diagnostics → cjs/diagnostics}/createDiagnosticsManager.d.ts.map +0 -0
  160. /package/dist/{evaluation → cjs/evaluation}/evaluationDetail.d.ts +0 -0
  161. /package/dist/{evaluation → cjs/evaluation}/evaluationDetail.d.ts.map +0 -0
  162. /package/dist/{events → cjs/events}/EventFactory.d.ts +0 -0
  163. /package/dist/{events → cjs/events}/EventFactory.d.ts.map +0 -0
  164. /package/dist/{events → cjs/events}/createEventProcessor.d.ts +0 -0
  165. /package/dist/{events → cjs/events}/createEventProcessor.d.ts.map +0 -0
  166. /package/dist/{flag-manager → cjs/flag-manager}/ContextIndex.d.ts +0 -0
  167. /package/dist/{flag-manager → cjs/flag-manager}/ContextIndex.d.ts.map +0 -0
  168. /package/dist/{flag-manager → cjs/flag-manager}/FlagManager.d.ts +0 -0
  169. /package/dist/{flag-manager → cjs/flag-manager}/FlagManager.d.ts.map +0 -0
  170. /package/dist/{flag-manager → cjs/flag-manager}/FlagPersistence.d.ts +0 -0
  171. /package/dist/{flag-manager → cjs/flag-manager}/FlagPersistence.d.ts.map +0 -0
  172. /package/dist/{flag-manager → cjs/flag-manager}/FlagStore.d.ts +0 -0
  173. /package/dist/{flag-manager → cjs/flag-manager}/FlagStore.d.ts.map +0 -0
  174. /package/dist/{flag-manager → cjs/flag-manager}/FlagUpdater.d.ts +0 -0
  175. /package/dist/{flag-manager → cjs/flag-manager}/FlagUpdater.d.ts.map +0 -0
  176. /package/dist/{flag-manager → cjs/flag-manager}/ItemDescriptor.d.ts +0 -0
  177. /package/dist/{flag-manager → cjs/flag-manager}/ItemDescriptor.d.ts.map +0 -0
  178. /package/dist/{flag-manager → cjs/flag-manager}/calculateChangedKeys.d.ts +0 -0
  179. /package/dist/{flag-manager → cjs/flag-manager}/calculateChangedKeys.d.ts.map +0 -0
  180. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  181. /package/dist/{index.d.ts.map → cjs/index.d.ts.map} +0 -0
  182. /package/dist/{inspection → cjs/inspection}/InspectorManager.d.ts +0 -0
  183. /package/dist/{inspection → cjs/inspection}/InspectorManager.d.ts.map +0 -0
  184. /package/dist/{inspection → cjs/inspection}/createSafeInspector.d.ts +0 -0
  185. /package/dist/{inspection → cjs/inspection}/createSafeInspector.d.ts.map +0 -0
  186. /package/dist/{inspection → cjs/inspection}/getInspectorHook.d.ts +0 -0
  187. /package/dist/{inspection → cjs/inspection}/getInspectorHook.d.ts.map +0 -0
  188. /package/dist/{inspection → cjs/inspection}/messages.d.ts +0 -0
  189. /package/dist/{inspection → cjs/inspection}/messages.d.ts.map +0 -0
  190. /package/dist/{polling → cjs/polling}/PollingProcessor.d.ts +0 -0
  191. /package/dist/{polling → cjs/polling}/PollingProcessor.d.ts.map +0 -0
  192. /package/dist/{storage → cjs/storage}/getOrGenerateKey.d.ts +0 -0
  193. /package/dist/{storage → cjs/storage}/getOrGenerateKey.d.ts.map +0 -0
  194. /package/dist/{storage → cjs/storage}/namespaceUtils.d.ts +0 -0
  195. /package/dist/{storage → cjs/storage}/namespaceUtils.d.ts.map +0 -0
  196. /package/dist/{streaming → cjs/streaming}/StreamingProcessor.d.ts +0 -0
  197. /package/dist/{streaming → cjs/streaming}/StreamingProcessor.d.ts.map +0 -0
  198. /package/dist/{streaming → cjs/streaming}/index.d.ts +0 -0
  199. /package/dist/{streaming → cjs/streaming}/index.d.ts.map +0 -0
  200. /package/dist/{types → cjs/types}/index.d.ts +0 -0
  201. /package/dist/{types → cjs/types}/index.d.ts.map +0 -0
@@ -0,0 +1,315 @@
1
+ import { LDContext, LDFlagSet, LDFlagValue, LDLogger } from '@launchdarkly/js-sdk-common';
2
+ import { Hook } from './integrations/Hooks';
3
+ import { LDEvaluationDetail, LDEvaluationDetailTyped } from './LDEvaluationDetail';
4
+ import { LDIdentifyOptions } from './LDIdentifyOptions';
5
+ /**
6
+ * The basic interface for the LaunchDarkly client. Platform-specific SDKs may add some methods of their own.
7
+ *
8
+ * @see https://docs.launchdarkly.com/sdk/client-side/javascript
9
+ *
10
+ * @ignore (don't need to show this separately in TypeDoc output; all methods will be shown in LDClient)
11
+ */
12
+ export interface LDClient {
13
+ /**
14
+ * Returns a map of all available flags to the current context's values.
15
+ *
16
+ * @returns
17
+ * An object in which each key is a feature flag key and each value is the flag value.
18
+ * Note that there is no way to specify a default value for each flag as there is with
19
+ * {@link variation}, so any flag that cannot be evaluated will be undefined.
20
+ */
21
+ allFlags(): LDFlagSet;
22
+ /**
23
+ * Determines the boolean variation of a feature flag.
24
+ *
25
+ * If the flag variation does not have a boolean value, defaultValue is returned.
26
+ *
27
+ * @param key The unique key of the feature flag.
28
+ * @param defaultValue The default value of the flag, to be used if the value is not available
29
+ * from LaunchDarkly.
30
+ * @returns
31
+ * The boolean value.
32
+ */
33
+ boolVariation(key: string, defaultValue: boolean): boolean;
34
+ /**
35
+ * Determines the boolean variation of a feature flag, along with information about
36
+ * how it was calculated.
37
+ *
38
+ * The `reason` property of the result will also be included in analytics events, if you are
39
+ * capturing detailed event data for this flag.
40
+ *
41
+ * If the flag variation does not have a boolean value, defaultValue is returned. The reason will
42
+ * indicate an error of the type `WRONG_KIND` in this case.
43
+ *
44
+ * For more information, see the [SDK reference
45
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
46
+ *
47
+ * @param key The unique key of the feature flag.
48
+ * @param defaultValue The default value of the flag, to be used if the value is not available
49
+ * from LaunchDarkly.
50
+ * @returns
51
+ * The result (as an {@link LDEvaluationDetailTyped<boolean>}).
52
+ */
53
+ boolVariationDetail(key: string, defaultValue: boolean): LDEvaluationDetailTyped<boolean>;
54
+ /**
55
+ * Shuts down the client and releases its resources, after delivering any pending analytics
56
+ * events. After the client is closed, all calls to {@link variation} will return default values,
57
+ * and it will not make any requests to LaunchDarkly.
58
+ */
59
+ close(): Promise<void>;
60
+ /**
61
+ * Flushes all pending analytics events.
62
+ *
63
+ * Normally, batches of events are delivered in the background at intervals determined by the
64
+ * `flushInterval` property of {@link LDOptions}. Calling `flush()` triggers an immediate delivery.
65
+ *
66
+ * @returns
67
+ * A Promise which resolves once
68
+ * flushing is finished. You can inspect the result of the flush for errors.
69
+ */
70
+ flush(): Promise<{
71
+ error?: Error;
72
+ result: boolean;
73
+ }>;
74
+ /**
75
+ * Returns the client's current context.
76
+ *
77
+ * This is the context that was most recently passed to {@link identify}, or, if {@link identify} has never
78
+ * been called, this will be undefined.
79
+ */
80
+ getContext(): LDContext | undefined;
81
+ /**
82
+ * Identifies a context to LaunchDarkly.
83
+ *
84
+ * Unlike the server-side SDKs, the client-side JavaScript SDKs maintain a current context state,
85
+ * which is set when you call `identify()`.
86
+ *
87
+ * Changing the current context also causes all feature flag values to be reloaded. Until that has
88
+ * finished, calls to {@link variation} will still return flag values for the previous context. You can
89
+ * await the Promise to determine when the new flag values are available.
90
+ *
91
+ * @param context
92
+ * The LDContext object.
93
+ * @param identifyOptions
94
+ * Optional configuration. Please see {@link LDIdentifyOptions}.
95
+ * @returns
96
+ * A Promise which resolves when the flag values for the specified
97
+ * context are available. It rejects when:
98
+ *
99
+ * 1. The context is unspecified or has no key.
100
+ *
101
+ * 2. The identify timeout is exceeded. In client SDKs this defaults to 5s.
102
+ * You can customize this timeout with {@link LDIdentifyOptions | identifyOptions}.
103
+ *
104
+ * 3. A network error is encountered during initialization.
105
+ */
106
+ identify(context: LDContext, identifyOptions?: LDIdentifyOptions): Promise<void>;
107
+ /**
108
+ * Determines the json variation of a feature flag.
109
+ *
110
+ * This version may be favored in TypeScript versus `variation` because it returns
111
+ * an `unknown` type instead of `any`. `unknown` will require a cast before usage.
112
+ *
113
+ * @param key The unique key of the feature flag.
114
+ * @param defaultValue The default value of the flag, to be used if the value is not available
115
+ * from LaunchDarkly.
116
+ * @returns
117
+ * The json value.
118
+ */
119
+ jsonVariation(key: string, defaultValue: unknown): unknown;
120
+ /**
121
+ * Determines the json variation of a feature flag, along with information about how it
122
+ * was calculated.
123
+ *
124
+ * The `reason` property of the result will also be included in analytics events, if you are
125
+ * capturing detailed event data for this flag.
126
+ *
127
+ * This version may be favored in TypeScript versus `variation` because it returns
128
+ * an `unknown` type instead of `any`. `unknown` will require a cast before usage.
129
+ *
130
+ * For more information, see the [SDK reference
131
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
132
+ *
133
+ * @param key The unique key of the feature flag.
134
+ * @param defaultValue The default value of the flag, to be used if the value is not available
135
+ * from LaunchDarkly.
136
+ * @returns
137
+ * The result (as an {@link LDEvaluationDetailTyped<unknown>}).
138
+ */
139
+ jsonVariationDetail(key: string, defaultValue: unknown): LDEvaluationDetailTyped<unknown>;
140
+ /**
141
+ * The logger configured as part of LDOptions during construction.
142
+ *
143
+ * @remarks
144
+ * For more information, read {@link LDOptions.logger} and {@link LDLogger}.
145
+ *
146
+ * @returns The configured {@link LDLogger}.
147
+ */
148
+ readonly logger: LDLogger;
149
+ /**
150
+ * Determines the numeric variation of a feature flag.
151
+ *
152
+ * If the flag variation does not have a numeric value, defaultValue is returned.
153
+ *
154
+ * @param key The unique key of the feature flag.
155
+ * @param defaultValue The default value of the flag, to be used if the value is not available
156
+ * from LaunchDarkly.
157
+ * @returns
158
+ * The numeric value.
159
+ */
160
+ numberVariation(key: string, defaultValue: number): number;
161
+ /**
162
+ * Determines the numeric variation of a feature flag for a context, along with information about
163
+ * how it was calculated.
164
+ *
165
+ * @remarks
166
+ * The `reason` property of the result will also be included in analytics events, if you are
167
+ * capturing detailed event data for this flag.
168
+ *
169
+ * If the flag variation does not have a numeric value, defaultValue is returned. The reason will
170
+ * indicate an error of the type `WRONG_KIND` in this case.
171
+ *
172
+ * For more information, see the [SDK reference
173
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
174
+ *
175
+ * @param key The unique key of the feature flag.
176
+ * @param defaultValue The default value of the flag, to be used if the value is not available
177
+ * from LaunchDarkly.
178
+ * @returns
179
+ * The result (as an {@link LDEvaluationDetailTyped<number>}).
180
+ */
181
+ numberVariationDetail(key: string, defaultValue: number): LDEvaluationDetailTyped<number>;
182
+ /**
183
+ * Removes an event listener. See {@link on} for the available event types.
184
+ *
185
+ * @param key
186
+ * The name of the event for which to stop listening.
187
+ * @param callback
188
+ * The function to deregister.
189
+ */
190
+ off(key: string, callback: (...args: any[]) => void): void;
191
+ /**
192
+ * Registers an event listener.
193
+ *
194
+ * @remarks
195
+ * You can subscribe to one of the supported {@link EventName}:
196
+ *
197
+ * - `"change"`: The client has received new feature flag data. This can happen either
198
+ * because you have switched contexts with {@link identify}, or because the client has a
199
+ * stream connection and has received a live change to a flag value (see below).
200
+ * The callback parameters are the context and an array of flag keys that have changed.
201
+ *
202
+ * - `"error"`: General event for any kind of error condition during client operation.
203
+ * The callback parameters are the context and an Error object. Errors are also output by
204
+ * the {@link logger} at the error level.
205
+ *
206
+ * - `"dataSourceStatus"`: Event indicating that there has been a change in the status of the
207
+ * data source. This will include the state of the data source as well any error information.
208
+ *
209
+ * @param key
210
+ * The name of the event for which to listen.
211
+ * @param callback
212
+ * The function to execute when the event fires. The callback may or may not
213
+ * receive parameters, depending on the type of event.
214
+ */
215
+ on(key: string, callback: (...args: any[]) => void): void;
216
+ /**
217
+ * Determines the string variation of a feature flag.
218
+ *
219
+ * If the flag variation does not have a string value, defaultValue is returned.
220
+ *
221
+ * @param key The unique key of the feature flag.
222
+ * @param defaultValue The default value of the flag, to be used if the value is not available
223
+ * from LaunchDarkly.
224
+ * @returns
225
+ * The string value.
226
+ */
227
+ stringVariation(key: string, defaultValue: string): string;
228
+ /**
229
+ * Determines the string variation of a feature flag for a context, along with information about
230
+ * how it was calculated.
231
+ *
232
+ * @remarks
233
+ * The `reason` property of the result will also be included in analytics events, if you are
234
+ * capturing detailed event data for this flag.
235
+ *
236
+ * If the flag variation does not have a string value, defaultValue is returned. The reason will
237
+ * indicate an error of the type `WRONG_KIND` in this case.
238
+ *
239
+ * For more information, see the [SDK reference
240
+ * guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#react-native).
241
+ *
242
+ * @param key The unique key of the feature flag.
243
+ * @param defaultValue The default value of the flag, to be used if the value is not available
244
+ * from LaunchDarkly.
245
+ * @returns
246
+ * The result (as an {@link LDEvaluationDetailTyped<string>}).
247
+ */
248
+ stringVariationDetail(key: string, defaultValue: string): LDEvaluationDetailTyped<string>;
249
+ /**
250
+ * Track events for experiments.
251
+ *
252
+ * @param key
253
+ * The name of the event, which may correspond to a goal in an experiment.
254
+ * @param data
255
+ * Additional information to associate with the event.
256
+ * @param metricValue
257
+ * An optional numeric value that can be used by the LaunchDarkly experimentation
258
+ * feature in numeric custom metrics. Can be omitted if this event is used by only
259
+ * non-numeric metrics. This field will also be returned as part of the custom event
260
+ * for Data Export.
261
+ */
262
+ track(key: string, data?: any, metricValue?: number): void;
263
+ /**
264
+ * We recommend using strongly typed variation methods which perform
265
+ * type checks and handle type errors.
266
+ *
267
+ * @remarks
268
+ * Determines the variation of a feature flag.
269
+ *
270
+ * In the client-side JavaScript SDKs, this is always a fast synchronous operation because all of
271
+ * the feature flag values for the current context have already been loaded into memory.
272
+ *
273
+ * @param key
274
+ * The unique key of the feature flag.
275
+ * @param defaultValue
276
+ * The default value of the flag, to be used if the value is not available from LaunchDarkly.
277
+ * @returns
278
+ * The flag's value.
279
+ */
280
+ variation(key: string, defaultValue?: LDFlagValue): LDFlagValue;
281
+ /**
282
+ * We recommend using strongly typed variation detail methods which perform
283
+ * type checks and handle type errors.
284
+ *
285
+ * @remarks
286
+ * Determines the variation of a feature flag for a context, along with information about how it was
287
+ * calculated.
288
+ *
289
+ * Note that this will only work if you have set `withReasons` to true in {@link LDOptions}.
290
+ *
291
+ * The `reason` property of the result will also be included in analytics events, if you are
292
+ * capturing detailed event data for this flag.
293
+ *
294
+ * For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/features/evaluation-reasons#javascript).
295
+ *
296
+ * @param key
297
+ * The unique key of the feature flag.
298
+ * @param defaultValue
299
+ * The default value of the flag, to be used if the value is not available from LaunchDarkly.
300
+ *
301
+ * @returns
302
+ * An {@link LDEvaluationDetail} object containing the value and explanation.
303
+ */
304
+ variationDetail(key: string, defaultValue?: LDFlagValue): LDEvaluationDetail;
305
+ /**
306
+ * Add a hook to the client. In order to register a hook before the client
307
+ * starts, please use the `hooks` property of {@link LDOptions}.
308
+ *
309
+ * Hooks provide entrypoints which allow for observation of SDK functions.
310
+ *
311
+ * @param Hook The hook to add.
312
+ */
313
+ addHook(hook: Hook): void;
314
+ }
315
+ //# sourceMappingURL=LDClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDClient.d.ts","sourceRoot":"","sources":["../../src/api/LDClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE1F,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;;OAOG;IACH,QAAQ,IAAI,SAAS,CAAC;IAEtB;;;;;;;;;;OAUG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC;IAE3D;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAE1F;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;;;;;;OASG;IACH,KAAK,IAAI,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAErD;;;;;OAKG;IACH,UAAU,IAAI,SAAS,GAAG,SAAS,CAAC;IAEpC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,EAAE,eAAe,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjF;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC;IAE3D;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAE1F;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAE1B;;;;;;;;;;OAUG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3D;;;;;;;;;;;;;;;;;;;OAmBG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAE1F;;;;;;;OAOG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAE3D;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAE1D;;;;;;;;;;OAUG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3D;;;;;;;;;;;;;;;;;;;OAmBG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAE1F;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3D;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IAEhE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,WAAW,GAAG,kBAAkB,CAAC;IAE7E;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAC3B"}
@@ -0,0 +1,26 @@
1
+ import { LDEvaluationDetail as CommonDetail, LDEvaluationDetailTyped as CommonDetailTyped, LDEvaluationReason } from '@launchdarkly/js-sdk-common';
2
+ /**
3
+ * An object that combines the result of a feature flag evaluation with information about
4
+ * how it was calculated.
5
+ *
6
+ * This is the result of calling `LDClient.variationDetail`.
7
+ */
8
+ export type LDEvaluationDetail = Omit<CommonDetail, 'reason'> & {
9
+ /**
10
+ * An optional object describing the main factor that influenced the flag evaluation value.
11
+ */
12
+ reason: LDEvaluationReason | null;
13
+ };
14
+ /**
15
+ * An object that combines the result of a feature flag evaluation with information about
16
+ * how it was calculated.
17
+ *
18
+ * This is the result of calling detailed variation methods.
19
+ */
20
+ export type LDEvaluationDetailTyped<TFlag> = Omit<CommonDetailTyped<TFlag>, 'reason'> & {
21
+ /**
22
+ * An optional object describing the main factor that influenced the flag evaluation value.
23
+ */
24
+ reason: LDEvaluationReason | null;
25
+ };
26
+ //# sourceMappingURL=LDEvaluationDetail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDEvaluationDetail.d.ts","sourceRoot":"","sources":["../../src/api/LDEvaluationDetail.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,IAAI,YAAY,EAClC,uBAAuB,IAAI,iBAAiB,EAC5C,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AAQrC;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG;IAC9D;;OAEG;IACH,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,CAAC,KAAK,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG;IACtF;;OAEG;IACH,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACnC,CAAC"}
@@ -0,0 +1,23 @@
1
+ export interface LDIdentifyOptions {
2
+ /**
3
+ * In seconds. Determines when the identify promise resolves if no flags have been
4
+ * returned from the network. If you use a large timeout and await it, then
5
+ * any network delays will cause your application to wait a long time before
6
+ * continuing execution.
7
+ *
8
+ * Defaults to 5 seconds.
9
+ */
10
+ timeout?: number;
11
+ /**
12
+ * When true indicates that the SDK will attempt to wait for values from
13
+ * LaunchDarkly instead of depending on cached values. The cached values will
14
+ * still be loaded, but the promise returned by the identify function will not
15
+ * resolve as a result of those cached values being loaded. Generally this
16
+ * option should NOT be used and instead flag changes should be listened to.
17
+ * If the client is set to offline mode, then this option is ignored.
18
+ *
19
+ * Defaults to false.
20
+ */
21
+ waitForNetworkResults?: boolean;
22
+ }
23
+ //# sourceMappingURL=LDIdentifyOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDIdentifyOptions.d.ts","sourceRoot":"","sources":["../../src/api/LDIdentifyOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;OASG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC"}
@@ -0,0 +1,105 @@
1
+ import { LDContext } from '@launchdarkly/js-sdk-common';
2
+ import { LDEvaluationDetail } from './LDEvaluationDetail';
3
+ /**
4
+ * Callback interface for collecting information about the SDK at runtime.
5
+ *
6
+ * This interface is used to collect information about flag usage.
7
+ *
8
+ * This interface should not be used by the application to access flags for the purpose of controlling application
9
+ * flow. It is intended for monitoring, analytics, or debugging purposes.
10
+ */
11
+ export interface LDInspectionFlagUsedHandler {
12
+ type: 'flag-used';
13
+ /**
14
+ * Name of the inspector. Will be used for logging issues with the inspector.
15
+ */
16
+ name: string;
17
+ /**
18
+ * @deprecated All inspectors run synchronously. This field will be removed in a future major version.
19
+ */
20
+ synchronous?: boolean;
21
+ /**
22
+ * This method is called when a flag is accessed via a variation method, or it can be called based on actions in
23
+ * wrapper SDKs which have different methods of tracking when a flag was accessed. It is not called when a call is made
24
+ * to allFlags.
25
+ */
26
+ method: (flagKey: string, flagDetail: LDEvaluationDetail, context?: LDContext) => void;
27
+ }
28
+ /**
29
+ * Callback interface for collecting information about the SDK at runtime.
30
+ *
31
+ * This interface is used to collect information about flag data. In order to understand the
32
+ * current flag state it should be combined with {@link LDInspectionFlagValueChangedHandler}.
33
+ * This interface will get the initial flag information, and
34
+ * {@link LDInspectionFlagValueChangedHandler} will provide changes to individual flags.
35
+ *
36
+ * This interface should not be used by the application to access flags for the purpose of controlling application
37
+ * flow. It is intended for monitoring, analytics, or debugging purposes.
38
+ */
39
+ export interface LDInspectionFlagDetailsChangedHandler {
40
+ type: 'flag-details-changed';
41
+ /**
42
+ * Name of the inspector. Will be used for logging issues with the inspector.
43
+ */
44
+ name: string;
45
+ /**
46
+ * @deprecated All inspectors run synchronously. This field will be removed in a future major version.
47
+ */
48
+ synchronous?: boolean;
49
+ /**
50
+ * This method is called when the flags in the store are replaced with new flags. It will contain all flags
51
+ * regardless of if they have been evaluated.
52
+ */
53
+ method: (details: Record<string, LDEvaluationDetail>) => void;
54
+ }
55
+ /**
56
+ * Callback interface for collecting information about the SDK at runtime.
57
+ *
58
+ * This interface is used to collect changes to flag data, but does not provide the initial
59
+ * data. It can be combined with {@link LDInspectionFlagValuesChangedHandler} to track the
60
+ * entire flag state.
61
+ *
62
+ * This interface should not be used by the application to access flags for the purpose of controlling application
63
+ * flow. It is intended for monitoring, analytics, or debugging purposes.
64
+ */
65
+ export interface LDInspectionFlagDetailChangedHandler {
66
+ type: 'flag-detail-changed';
67
+ /**
68
+ * Name of the inspector. Will be used for logging issues with the inspector.
69
+ */
70
+ name: string;
71
+ /**
72
+ * @deprecated All inspectors run synchronously. This field will be removed in a future major version.
73
+ */
74
+ synchronous?: boolean;
75
+ /**
76
+ * This method is called when a flag is updated. It will not be called
77
+ * when all flags are updated.
78
+ */
79
+ method: (flagKey: string, detail: LDEvaluationDetail) => void;
80
+ }
81
+ /**
82
+ * Callback interface for collecting information about the SDK at runtime.
83
+ *
84
+ * This interface is used to track current identity state of the SDK.
85
+ *
86
+ * This interface should not be used by the application to access flags for the purpose of controlling application
87
+ * flow. It is intended for monitoring, analytics, or debugging purposes.
88
+ */
89
+ export interface LDInspectionIdentifyHandler {
90
+ type: 'client-identity-changed';
91
+ /**
92
+ * Name of the inspector. Will be used for logging issues with the inspector.
93
+ */
94
+ name: string;
95
+ /**
96
+ * @deprecated All inspectors run synchronously. This field will be removed in a future major version.
97
+ */
98
+ synchronous?: boolean;
99
+ /**
100
+ * This method will be called when an identify operation completes.
101
+ */
102
+ method: (context: LDContext) => void;
103
+ }
104
+ export type LDInspection = LDInspectionFlagUsedHandler | LDInspectionFlagDetailsChangedHandler | LDInspectionFlagDetailChangedHandler | LDInspectionIdentifyHandler;
105
+ //# sourceMappingURL=LDInspection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDInspection.d.ts","sourceRoot":"","sources":["../../src/api/LDInspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;CACxF;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qCAAqC;IACpD,IAAI,EAAE,sBAAsB,CAAC;IAE7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,IAAI,CAAC;CAC/D;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,oCAAoC;IACnD,IAAI,EAAE,qBAAqB,CAAC;IAE5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC/D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,yBAAyB,CAAC;IAEhC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,MAAM,YAAY,GACpB,2BAA2B,GAC3B,qCAAqC,GACrC,oCAAoC,GACpC,2BAA2B,CAAC"}