@featbit/js-client-sdk 3.0.13 → 3.0.14

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 (113) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +301 -301
  3. package/dist/esm/IFbClientCore.d.ts +1 -1
  4. package/dist/esm/IFbClientCore.d.ts.map +1 -1
  5. package/dist/esm/version.d.ts +1 -1
  6. package/dist/esm/version.js +1 -1
  7. package/dist/umd/{featbit-js-client-sdk-3.0.13.js → featbit-js-client-sdk-3.0.14.js} +2 -2
  8. package/dist/umd/featbit-js-client-sdk-3.0.14.js.map +1 -0
  9. package/dist/umd/featbit-js-client-sdk.js +1 -1
  10. package/dist/umd/featbit-js-client-sdk.js.map +1 -1
  11. package/package.json +46 -46
  12. package/src/Configuration.ts +232 -232
  13. package/src/Context.ts +61 -61
  14. package/src/FbClientBuilder.ts +167 -167
  15. package/src/FbClientCore.ts +405 -405
  16. package/src/IContextProperty.ts +3 -3
  17. package/src/IDataKind.ts +11 -11
  18. package/src/IFbClient.ts +29 -29
  19. package/src/IFbClientCore.ts +290 -290
  20. package/src/IVersionedData.ts +18 -18
  21. package/src/bootstrap/IBootstrapProvider.ts +4 -4
  22. package/src/bootstrap/JsonBootstrapProvider.ts +34 -34
  23. package/src/bootstrap/NullBootstrapProvider.ts +20 -20
  24. package/src/bootstrap/index.ts +2 -2
  25. package/src/constants.ts +1 -1
  26. package/src/data-sources/DataSourceUpdates.ts +116 -116
  27. package/src/data-sources/createStreamListeners.ts +67 -67
  28. package/src/data-sources/index.ts +1 -1
  29. package/src/data-sync/DataSyncMode.ts +3 -3
  30. package/src/data-sync/IDataSynchronizer.ts +15 -15
  31. package/src/data-sync/IRequestor.ts +10 -10
  32. package/src/data-sync/NullDataSynchronizer.ts +14 -14
  33. package/src/data-sync/PollingDataSynchronizer.ts +125 -125
  34. package/src/data-sync/Requestor.ts +61 -61
  35. package/src/data-sync/WebSocketDataSynchronizer.ts +77 -77
  36. package/src/data-sync/index.ts +8 -8
  37. package/src/data-sync/types.ts +19 -19
  38. package/src/data-sync/utils.ts +31 -31
  39. package/src/errors.ts +47 -47
  40. package/src/evaluation/EvalResult.ts +35 -35
  41. package/src/evaluation/Evaluator.ts +26 -26
  42. package/src/evaluation/IEvalDetail.ts +23 -23
  43. package/src/evaluation/ReasonKinds.ts +9 -9
  44. package/src/evaluation/data/IFlag.ts +29 -29
  45. package/src/evaluation/index.ts +4 -4
  46. package/src/events/DefaultEventProcessor.ts +83 -83
  47. package/src/events/DefaultEventQueue.ts +49 -49
  48. package/src/events/DefaultEventSender.ts +73 -73
  49. package/src/events/DefaultEventSerializer.ts +11 -11
  50. package/src/events/EventDispatcher.ts +127 -127
  51. package/src/events/EventSerializer.ts +4 -4
  52. package/src/events/IEventProcessor.ts +8 -8
  53. package/src/events/IEventQueue.ts +16 -16
  54. package/src/events/IEventSender.ts +13 -13
  55. package/src/events/NullEventProcessor.ts +15 -15
  56. package/src/events/event.ts +129 -129
  57. package/src/events/index.ts +11 -11
  58. package/src/index.ts +21 -21
  59. package/src/integrations/TestLogger.ts +24 -24
  60. package/src/integrations/index.ts +1 -1
  61. package/src/integrations/test_data/FlagBuilder.ts +59 -59
  62. package/src/integrations/test_data/TestData.ts +57 -57
  63. package/src/integrations/test_data/TestDataSynchronizer.ts +49 -49
  64. package/src/integrations/test_data/index.ts +4 -4
  65. package/src/logging/BasicLogger.ts +108 -108
  66. package/src/logging/IBasicLoggerOptions.ts +46 -46
  67. package/src/logging/ILogger.ts +49 -49
  68. package/src/logging/LogLevel.ts +8 -8
  69. package/src/logging/SafeLogger.ts +69 -69
  70. package/src/logging/format.ts +154 -154
  71. package/src/logging/index.ts +5 -5
  72. package/src/options/ClientContext.ts +39 -39
  73. package/src/options/IClientContext.ts +53 -53
  74. package/src/options/IOptions.ts +123 -123
  75. package/src/options/IUser.ts +6 -6
  76. package/src/options/IValidatedOptions.ts +29 -29
  77. package/src/options/OptionMessages.ts +35 -35
  78. package/src/options/UserBuilder.ts +35 -35
  79. package/src/options/Validators.ts +300 -300
  80. package/src/options/index.ts +7 -7
  81. package/src/platform/IInfo.ts +102 -102
  82. package/src/platform/IPlatform.ts +20 -20
  83. package/src/platform/IStore.ts +112 -112
  84. package/src/platform/IWebSocket.ts +22 -22
  85. package/src/platform/browser/BrowserInfo.ts +24 -24
  86. package/src/platform/browser/BrowserPlatform.ts +19 -19
  87. package/src/platform/browser/BrowserRequests.ts +6 -6
  88. package/src/platform/browser/BrowserWebSocket.ts +147 -147
  89. package/src/platform/browser/FbClient.ts +65 -65
  90. package/src/platform/browser/LocalStorageStore.ts +59 -59
  91. package/src/platform/index.ts +11 -11
  92. package/src/platform/requests.ts +76 -76
  93. package/src/store/BaseStore.ts +125 -125
  94. package/src/store/DataKinds.ts +6 -6
  95. package/src/store/IDataSourceUpdates.ts +68 -68
  96. package/src/store/InMemoryStore.ts +36 -36
  97. package/src/store/index.ts +5 -5
  98. package/src/store/serialization.ts +52 -52
  99. package/src/store/store.ts +37 -37
  100. package/src/utils/Emits.ts +75 -75
  101. package/src/utils/EventEmitter.ts +128 -128
  102. package/src/utils/IEventEmitter.ts +14 -14
  103. package/src/utils/Regex.ts +21 -21
  104. package/src/utils/ValueConverters.ts +55 -55
  105. package/src/utils/canonicalizeUri.ts +3 -3
  106. package/src/utils/debounce.ts +33 -33
  107. package/src/utils/http.ts +40 -40
  108. package/src/utils/index.ts +5 -5
  109. package/src/utils/isNullOrUndefined.ts +2 -2
  110. package/src/utils/serializeUser.ts +27 -27
  111. package/src/utils/sleep.ts +5 -5
  112. package/src/version.ts +1 -1
  113. package/dist/umd/featbit-js-client-sdk-3.0.13.js.map +0 -1
@@ -1,291 +1,291 @@
1
- import { IEvalDetail } from "./evaluation/IEvalDetail";
2
- import { IConvertResult } from "./utils/ValueConverters";
3
- import { IUser } from "./options";
4
-
5
- /**
6
- * The FeatBit SDK client object.
7
- *
8
- * Create this object with {@link FbClientBuilder}. Applications should configure the client at startup time
9
- * and continue to use it throughout the lifetime of the application, rather than creating instances
10
- * on the fly.
11
- *
12
- */
13
- export interface IFbClientCore {
14
- /**
15
- * Set the current user of the client.
16
- *
17
- * @param user
18
- * The current user. The actual type of this parameter is
19
- * {@link IUser}.
20
- */
21
- identify(user: IUser): void;
22
-
23
- /**
24
- * Indicates whether the client is ready to be used.
25
- *
26
- * @returns true if the client is ready to be used, false otherwise.
27
- */
28
- initialized(): boolean;
29
-
30
- /**
31
- * Wait until the client is initialized. The promise resolves when the client has finished initializing successfully.
32
- * If the client fails to initialize, the promise will be rejected.
33
- *
34
- * @returns A promise.
35
- */
36
- waitForInitialization(): Promise<IFbClientCore>;
37
-
38
- /**
39
- * Calculates the boolean value of a feature flag for a given user.
40
- *
41
- * If the flag variation does not have a boolean value, {@link defaultValue} is returned.
42
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
43
- * does not match any existing flag), {@link defaultValue} is returned.
44
- *
45
- * @param key
46
- * The unique key of the feature flag.
47
- * @param defaultValue
48
- * The default value to return if the flag cannot be evaluated.
49
- *
50
- * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
51
- */
52
- boolVariation(
53
- key: string,
54
- defaultValue: boolean
55
- ): boolean;
56
-
57
- /**
58
- * Calculates the boolean value of a feature flag for a given user, and returns an object that
59
- * describes the way the value was determined.
60
- *
61
- * If the flag variation does not have a boolean value, {@link defaultValue} is returned.
62
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
63
- * does not match any existing flag), {@link defaultValue} is returned.
64
- *
65
- * @param key
66
- * The unique key of the feature flag.
67
- * @param defaultValue
68
- * The default value to return if the flag cannot be evaluated.
69
- *
70
- * @returns {@link IEvalDetail} object describing the way the value was determined.
71
- */
72
- boolVariationDetail(
73
- key: string,
74
- defaultValue: boolean
75
- ): IEvalDetail<boolean>;
76
-
77
- /**
78
- * Calculates the number value of a feature flag for a given user.
79
- *
80
- * If the flag variation does not have a number value, {@link defaultValue} is returned.
81
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
82
- * does not match any existing flag), {@link defaultValue} is returned.
83
- *
84
- * @param key
85
- * The unique key of the feature flag.
86
- * @param defaultValue
87
- * The default value to return if the flag cannot be evaluated.
88
- *
89
- * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
90
- */
91
- numberVariation(
92
- key: string,
93
- defaultValue: number
94
- ): number;
95
-
96
- /**
97
- * Calculates the number value of a feature flag for a given user, and returns an object that
98
- * describes the way the value was determined.
99
- *
100
- * If the flag variation does not have a number value, {@link defaultValue} is returned.
101
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
102
- * does not match any existing flag), {@link defaultValue} is returned.
103
- *
104
- * @param key
105
- * The unique key of the feature flag.
106
- * @param defaultValue
107
- * The default value to return if the flag cannot be evaluated.
108
- *
109
- * @returns {@link IEvalDetail} object describing the way the value was determined.
110
- */
111
- numberVariationDetail(
112
- key: string,
113
- defaultValue: number
114
- ): IEvalDetail<number>;
115
-
116
- /**
117
- * Calculates the string value of a feature flag for a given user.
118
- *
119
- * If the flag variation does not have a string value, {@link defaultValue} is returned.
120
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
121
- * does not match any existing flag), {@link defaultValue} is returned.
122
- *
123
- * @param key
124
- * The unique key of the feature flag.
125
- * @param defaultValue
126
- * The default value to return if the flag cannot be evaluated.
127
- *
128
- * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
129
- */
130
- stringVariation(
131
- key: string,
132
- defaultValue: string
133
- ): string;
134
-
135
- /**
136
- * Calculates the string value of a feature flag for a given user, and returns an object that
137
- * describes the way the value was determined.
138
- *
139
- * If the flag variation does not have a string value, {@link defaultValue} is returned.
140
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
141
- * does not match any existing flag), {@link defaultValue} is returned.
142
- *
143
- * @param key
144
- * The unique key of the feature flag.
145
- * @param defaultValue
146
- * The default value to return if the flag cannot be evaluated.
147
- *
148
- * @returns {@link IEvalDetail} object describing the way the value was determined.
149
- */
150
- stringVariationDetail(
151
- key: string,
152
- defaultValue: string
153
- ): IEvalDetail<string>;
154
-
155
- /**
156
- * Calculates the JSON value of a feature flag for a given user.
157
- *
158
- * If the flag variation does not have a JSON value, {@link defaultValue} is returned.
159
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
160
- * does not match any existing flag), {@link defaultValue} is returned.
161
- *
162
- * @param key
163
- * The unique key of the feature flag.
164
- * @param defaultValue
165
- * The default value to return if the flag cannot be evaluated.
166
- *
167
- * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
168
- */
169
- jsonVariation(
170
- key: string,
171
- defaultValue: any
172
- ): any;
173
-
174
- /**
175
- * Calculates the JSON value of a feature flag for a given user, and returns an object that
176
- * describes the way the value was determined.
177
- *
178
- * If the flag variation does not have a JSON value, {@link defaultValue} is returned.
179
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
180
- * does not match any existing flag), {@link defaultValue} is returned.
181
- *
182
- * @param key
183
- * The unique key of the feature flag.
184
- * @param defaultValue
185
- * The default value to return if the flag cannot be evaluated.
186
- *
187
- * @returns {@link IEvalDetail} object describing the way the value was determined.
188
- */
189
- jsonVariationDetail(
190
- key: string,
191
- defaultValue: any
192
- ): IEvalDetail<any>;
193
-
194
- /**
195
- * Calculates the string value of a feature flag for a given user.
196
- *
197
- * If the flag variation does not have a string value, {@link defaultValue} is returned.
198
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
199
- * does not match any existing flag), {@link defaultValue} is returned.
200
- *
201
- * @param key
202
- * The unique key of the feature flag.
203
- * @param defaultValue
204
- * The default value to return if the flag cannot be evaluated.
205
- *
206
- * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
207
- */
208
- variation(
209
- key: string,
210
- defaultValue: string
211
- ): string;
212
-
213
- /**
214
- * Calculates the string value of a feature flag for a given user, and returns an object that
215
- * describes the way the value was determined.
216
- *
217
- * If the flag variation does not have a string value, {@link defaultValue} is returned.
218
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
219
- * does not match any existing flag), {@link defaultValue} is returned.
220
- *
221
- * @param key
222
- * The unique key of the feature flag.
223
- * @param defaultValue
224
- * The default value to return if the flag cannot be evaluated.
225
- *
226
- * @returns {@link IEvalDetail} object describing the way the value was determined.
227
- */
228
- variationDetail(
229
- key: string,
230
- defaultValue: string
231
- ): IEvalDetail<string>;
232
-
233
- /**
234
- * This method is exposed only for testing purpose, please DO NOT USE IT
235
- *
236
- * Calculates the value of a feature flag for a given user, and returns a {@link IEvalDetail} object that
237
- * describes the way the value was determined.
238
- *
239
- * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
240
- * does not match any existing flag), {@link defaultValue} is returned.
241
- *
242
- * @param flagKey
243
- * The unique key of the feature flag.
244
- * @param defaultValue
245
- * The default value to return if the flag cannot be evaluated.
246
- * @param typeConverter
247
- * the function to convert result.
248
- *
249
- * @returns {@link IEvalDetail} object describing the way the value was determined.
250
- */
251
- evaluateCore<TValue>(
252
- flagKey: string,
253
- defaultValue: TValue,
254
- typeConverter: (value: string) => IConvertResult<TValue>
255
- ): IEvalDetail<TValue>;
256
-
257
- /**
258
- * Returns the variation with of all feature flags for a given user, and returns an object that
259
- * describes the way the value was determined for each flag.
260
- *
261
- * @returns A list of {@link IEvalDetail} objects describing the way the values were determined.
262
- */
263
- getAllVariations(): Promise<IEvalDetail<string>[]>;
264
-
265
- /**
266
- * Shuts down the client and releases any resources it is using.
267
- *
268
- * @returns A promise that resolves when the client has been shut down.
269
- */
270
- close(): Promise<void>;
271
-
272
- /**
273
- * Tracks that an application-defined event occurred, and provides an additional numeric value for custom metrics.
274
- *
275
- * @param eventName
276
- * the name of the event.
277
- * @param metricValue
278
- * a numeric value used by the FeatBit experimentation feature in custom numeric metrics, the default value is 1 if not provided.
279
- */
280
- track(eventName: string, metricValue?: number | undefined): void
281
-
282
- /**
283
- * Tells the client that all pending events (if any) should be delivered as soon as possible.
284
- *
285
- * @param callback
286
- * Will be called when the flush operation is complete. If the flush fails, the callback will be called with false.
287
- *
288
- * @returns A promise that resolves when the client has been shut down.
289
- */
290
- flush(callback?: (res: boolean) => void): Promise<boolean>;
1
+ import { IEvalDetail } from "./evaluation/IEvalDetail";
2
+ import { IConvertResult } from "./utils/ValueConverters";
3
+ import { IUser } from "./options";
4
+
5
+ /**
6
+ * The FeatBit SDK client object.
7
+ *
8
+ * Create this object with {@link FbClientBuilder}. Applications should configure the client at startup time
9
+ * and continue to use it throughout the lifetime of the application, rather than creating instances
10
+ * on the fly.
11
+ *
12
+ */
13
+ export interface IFbClientCore {
14
+ /**
15
+ * Set the current user of the client.
16
+ *
17
+ * @param user
18
+ * The current user. The actual type of this parameter is
19
+ * {@link IUser}.
20
+ */
21
+ identify(user: IUser): Promise<void>;
22
+
23
+ /**
24
+ * Indicates whether the client is ready to be used.
25
+ *
26
+ * @returns true if the client is ready to be used, false otherwise.
27
+ */
28
+ initialized(): boolean;
29
+
30
+ /**
31
+ * Wait until the client is initialized. The promise resolves when the client has finished initializing successfully.
32
+ * If the client fails to initialize, the promise will be rejected.
33
+ *
34
+ * @returns A promise.
35
+ */
36
+ waitForInitialization(): Promise<IFbClientCore>;
37
+
38
+ /**
39
+ * Calculates the boolean value of a feature flag for a given user.
40
+ *
41
+ * If the flag variation does not have a boolean value, {@link defaultValue} is returned.
42
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
43
+ * does not match any existing flag), {@link defaultValue} is returned.
44
+ *
45
+ * @param key
46
+ * The unique key of the feature flag.
47
+ * @param defaultValue
48
+ * The default value to return if the flag cannot be evaluated.
49
+ *
50
+ * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
51
+ */
52
+ boolVariation(
53
+ key: string,
54
+ defaultValue: boolean
55
+ ): boolean;
56
+
57
+ /**
58
+ * Calculates the boolean value of a feature flag for a given user, and returns an object that
59
+ * describes the way the value was determined.
60
+ *
61
+ * If the flag variation does not have a boolean value, {@link defaultValue} is returned.
62
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
63
+ * does not match any existing flag), {@link defaultValue} is returned.
64
+ *
65
+ * @param key
66
+ * The unique key of the feature flag.
67
+ * @param defaultValue
68
+ * The default value to return if the flag cannot be evaluated.
69
+ *
70
+ * @returns {@link IEvalDetail} object describing the way the value was determined.
71
+ */
72
+ boolVariationDetail(
73
+ key: string,
74
+ defaultValue: boolean
75
+ ): IEvalDetail<boolean>;
76
+
77
+ /**
78
+ * Calculates the number value of a feature flag for a given user.
79
+ *
80
+ * If the flag variation does not have a number value, {@link defaultValue} is returned.
81
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
82
+ * does not match any existing flag), {@link defaultValue} is returned.
83
+ *
84
+ * @param key
85
+ * The unique key of the feature flag.
86
+ * @param defaultValue
87
+ * The default value to return if the flag cannot be evaluated.
88
+ *
89
+ * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
90
+ */
91
+ numberVariation(
92
+ key: string,
93
+ defaultValue: number
94
+ ): number;
95
+
96
+ /**
97
+ * Calculates the number value of a feature flag for a given user, and returns an object that
98
+ * describes the way the value was determined.
99
+ *
100
+ * If the flag variation does not have a number value, {@link defaultValue} is returned.
101
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
102
+ * does not match any existing flag), {@link defaultValue} is returned.
103
+ *
104
+ * @param key
105
+ * The unique key of the feature flag.
106
+ * @param defaultValue
107
+ * The default value to return if the flag cannot be evaluated.
108
+ *
109
+ * @returns {@link IEvalDetail} object describing the way the value was determined.
110
+ */
111
+ numberVariationDetail(
112
+ key: string,
113
+ defaultValue: number
114
+ ): IEvalDetail<number>;
115
+
116
+ /**
117
+ * Calculates the string value of a feature flag for a given user.
118
+ *
119
+ * If the flag variation does not have a string value, {@link defaultValue} is returned.
120
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
121
+ * does not match any existing flag), {@link defaultValue} is returned.
122
+ *
123
+ * @param key
124
+ * The unique key of the feature flag.
125
+ * @param defaultValue
126
+ * The default value to return if the flag cannot be evaluated.
127
+ *
128
+ * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
129
+ */
130
+ stringVariation(
131
+ key: string,
132
+ defaultValue: string
133
+ ): string;
134
+
135
+ /**
136
+ * Calculates the string value of a feature flag for a given user, and returns an object that
137
+ * describes the way the value was determined.
138
+ *
139
+ * If the flag variation does not have a string value, {@link defaultValue} is returned.
140
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
141
+ * does not match any existing flag), {@link defaultValue} is returned.
142
+ *
143
+ * @param key
144
+ * The unique key of the feature flag.
145
+ * @param defaultValue
146
+ * The default value to return if the flag cannot be evaluated.
147
+ *
148
+ * @returns {@link IEvalDetail} object describing the way the value was determined.
149
+ */
150
+ stringVariationDetail(
151
+ key: string,
152
+ defaultValue: string
153
+ ): IEvalDetail<string>;
154
+
155
+ /**
156
+ * Calculates the JSON value of a feature flag for a given user.
157
+ *
158
+ * If the flag variation does not have a JSON value, {@link defaultValue} is returned.
159
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
160
+ * does not match any existing flag), {@link defaultValue} is returned.
161
+ *
162
+ * @param key
163
+ * The unique key of the feature flag.
164
+ * @param defaultValue
165
+ * The default value to return if the flag cannot be evaluated.
166
+ *
167
+ * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
168
+ */
169
+ jsonVariation(
170
+ key: string,
171
+ defaultValue: any
172
+ ): any;
173
+
174
+ /**
175
+ * Calculates the JSON value of a feature flag for a given user, and returns an object that
176
+ * describes the way the value was determined.
177
+ *
178
+ * If the flag variation does not have a JSON value, {@link defaultValue} is returned.
179
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
180
+ * does not match any existing flag), {@link defaultValue} is returned.
181
+ *
182
+ * @param key
183
+ * The unique key of the feature flag.
184
+ * @param defaultValue
185
+ * The default value to return if the flag cannot be evaluated.
186
+ *
187
+ * @returns {@link IEvalDetail} object describing the way the value was determined.
188
+ */
189
+ jsonVariationDetail(
190
+ key: string,
191
+ defaultValue: any
192
+ ): IEvalDetail<any>;
193
+
194
+ /**
195
+ * Calculates the string value of a feature flag for a given user.
196
+ *
197
+ * If the flag variation does not have a string value, {@link defaultValue} is returned.
198
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
199
+ * does not match any existing flag), {@link defaultValue} is returned.
200
+ *
201
+ * @param key
202
+ * The unique key of the feature flag.
203
+ * @param defaultValue
204
+ * The default value to return if the flag cannot be evaluated.
205
+ *
206
+ * @returns the variation for the given user, or {@link defaultValue} if the flag cannot be evaluated
207
+ */
208
+ variation(
209
+ key: string,
210
+ defaultValue: string
211
+ ): string;
212
+
213
+ /**
214
+ * Calculates the string value of a feature flag for a given user, and returns an object that
215
+ * describes the way the value was determined.
216
+ *
217
+ * If the flag variation does not have a string value, {@link defaultValue} is returned.
218
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
219
+ * does not match any existing flag), {@link defaultValue} is returned.
220
+ *
221
+ * @param key
222
+ * The unique key of the feature flag.
223
+ * @param defaultValue
224
+ * The default value to return if the flag cannot be evaluated.
225
+ *
226
+ * @returns {@link IEvalDetail} object describing the way the value was determined.
227
+ */
228
+ variationDetail(
229
+ key: string,
230
+ defaultValue: string
231
+ ): IEvalDetail<string>;
232
+
233
+ /**
234
+ * This method is exposed only for testing purpose, please DO NOT USE IT
235
+ *
236
+ * Calculates the value of a feature flag for a given user, and returns a {@link IEvalDetail} object that
237
+ * describes the way the value was determined.
238
+ *
239
+ * If an error makes it impossible to evaluate the flag (for instance, the feature flag key
240
+ * does not match any existing flag), {@link defaultValue} is returned.
241
+ *
242
+ * @param flagKey
243
+ * The unique key of the feature flag.
244
+ * @param defaultValue
245
+ * The default value to return if the flag cannot be evaluated.
246
+ * @param typeConverter
247
+ * the function to convert result.
248
+ *
249
+ * @returns {@link IEvalDetail} object describing the way the value was determined.
250
+ */
251
+ evaluateCore<TValue>(
252
+ flagKey: string,
253
+ defaultValue: TValue,
254
+ typeConverter: (value: string) => IConvertResult<TValue>
255
+ ): IEvalDetail<TValue>;
256
+
257
+ /**
258
+ * Returns the variation with of all feature flags for a given user, and returns an object that
259
+ * describes the way the value was determined for each flag.
260
+ *
261
+ * @returns A list of {@link IEvalDetail} objects describing the way the values were determined.
262
+ */
263
+ getAllVariations(): Promise<IEvalDetail<string>[]>;
264
+
265
+ /**
266
+ * Shuts down the client and releases any resources it is using.
267
+ *
268
+ * @returns A promise that resolves when the client has been shut down.
269
+ */
270
+ close(): Promise<void>;
271
+
272
+ /**
273
+ * Tracks that an application-defined event occurred, and provides an additional numeric value for custom metrics.
274
+ *
275
+ * @param eventName
276
+ * the name of the event.
277
+ * @param metricValue
278
+ * a numeric value used by the FeatBit experimentation feature in custom numeric metrics, the default value is 1 if not provided.
279
+ */
280
+ track(eventName: string, metricValue?: number | undefined): void
281
+
282
+ /**
283
+ * Tells the client that all pending events (if any) should be delivered as soon as possible.
284
+ *
285
+ * @param callback
286
+ * Will be called when the flush operation is complete. If the flush fails, the callback will be called with false.
287
+ *
288
+ * @returns A promise that resolves when the client has been shut down.
289
+ */
290
+ flush(callback?: (res: boolean) => void): Promise<boolean>;
291
291
  }
@@ -1,18 +1,18 @@
1
- /**
2
- * Used internally to describe the basic properties of stored data such as feature flags or user
3
- * segments.
4
- *
5
- * This is the actual type of parameters and return values in `IStore` methods that refer
6
- * to a flag or segment item. Those methods still use the `object` type for backward compatibility.
7
- */
8
- export interface IVersionedData {
9
- /**
10
- * The item's unique key, such as a feature flag key.
11
- */
12
- key: string;
13
-
14
- /**
15
- * A version number that FeatBit will increment each time this item is changed.
16
- */
17
- version: number;
18
- }
1
+ /**
2
+ * Used internally to describe the basic properties of stored data such as feature flags or user
3
+ * segments.
4
+ *
5
+ * This is the actual type of parameters and return values in `IStore` methods that refer
6
+ * to a flag or segment item. Those methods still use the `object` type for backward compatibility.
7
+ */
8
+ export interface IVersionedData {
9
+ /**
10
+ * The item's unique key, such as a feature flag key.
11
+ */
12
+ key: string;
13
+
14
+ /**
15
+ * A version number that FeatBit will increment each time this item is changed.
16
+ */
17
+ version: number;
18
+ }
@@ -1,5 +1,5 @@
1
- import { IDataSourceUpdates } from "../store/IDataSourceUpdates";
2
-
3
- export interface IBootstrapProvider {
4
- populate(userKeyId: string, dataSourceUpdates: IDataSourceUpdates, callback?: () => void): Promise<void>
1
+ import { IDataSourceUpdates } from "../store/IDataSourceUpdates";
2
+
3
+ export interface IBootstrapProvider {
4
+ populate(userKeyId: string, dataSourceUpdates: IDataSourceUpdates, callback?: () => void): Promise<void>
5
5
  }