@depup/firebase__remote-config 0.8.1-depup.0

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 (54) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/esm/index.esm.js +2199 -0
  4. package/dist/esm/index.esm.js.map +1 -0
  5. package/dist/esm/package.json +1 -0
  6. package/dist/esm/src/abt/experiment.d.ts +13 -0
  7. package/dist/esm/src/api.d.ts +144 -0
  8. package/dist/esm/src/api2.d.ts +40 -0
  9. package/dist/esm/src/client/caching_client.d.ts +46 -0
  10. package/dist/esm/src/client/eventEmitter.d.ts +39 -0
  11. package/dist/esm/src/client/realtime_handler.d.ts +141 -0
  12. package/dist/esm/src/client/remote_config_fetch_client.d.ts +104 -0
  13. package/dist/esm/src/client/rest_client.d.ts +41 -0
  14. package/dist/esm/src/client/retrying_client.d.ts +50 -0
  15. package/dist/esm/src/client/visibility_monitor.d.ts +23 -0
  16. package/dist/esm/src/constants.d.ts +20 -0
  17. package/dist/esm/src/errors.d.ts +87 -0
  18. package/dist/esm/src/index.d.ts +14 -0
  19. package/dist/esm/src/language.d.ts +26 -0
  20. package/dist/esm/src/public_types.d.ts +274 -0
  21. package/dist/esm/src/register.d.ts +2 -0
  22. package/dist/esm/src/remote_config.d.ts +98 -0
  23. package/dist/esm/src/storage/storage.d.ts +118 -0
  24. package/dist/esm/src/storage/storage_cache.d.ts +51 -0
  25. package/dist/esm/src/value.d.ts +26 -0
  26. package/dist/esm/test/setup.d.ts +17 -0
  27. package/dist/index.cjs.js +2216 -0
  28. package/dist/index.cjs.js.map +1 -0
  29. package/dist/remote-config-public.d.ts +441 -0
  30. package/dist/remote-config.d.ts +441 -0
  31. package/dist/src/abt/experiment.d.ts +13 -0
  32. package/dist/src/api.d.ts +144 -0
  33. package/dist/src/api2.d.ts +40 -0
  34. package/dist/src/client/caching_client.d.ts +46 -0
  35. package/dist/src/client/eventEmitter.d.ts +39 -0
  36. package/dist/src/client/realtime_handler.d.ts +141 -0
  37. package/dist/src/client/remote_config_fetch_client.d.ts +104 -0
  38. package/dist/src/client/rest_client.d.ts +41 -0
  39. package/dist/src/client/retrying_client.d.ts +50 -0
  40. package/dist/src/client/visibility_monitor.d.ts +23 -0
  41. package/dist/src/constants.d.ts +20 -0
  42. package/dist/src/errors.d.ts +87 -0
  43. package/dist/src/global_index.d.ts +674 -0
  44. package/dist/src/index.d.ts +14 -0
  45. package/dist/src/language.d.ts +26 -0
  46. package/dist/src/public_types.d.ts +274 -0
  47. package/dist/src/register.d.ts +2 -0
  48. package/dist/src/remote_config.d.ts +98 -0
  49. package/dist/src/storage/storage.d.ts +118 -0
  50. package/dist/src/storage/storage_cache.d.ts +51 -0
  51. package/dist/src/tsdoc-metadata.json +11 -0
  52. package/dist/src/value.d.ts +26 -0
  53. package/dist/test/setup.d.ts +17 -0
  54. package/package.json +93 -0
@@ -0,0 +1,441 @@
1
+ /**
2
+ * The Firebase Remote Config Web SDK.
3
+ * This SDK does not work in a Node.js environment.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ import { FirebaseApp } from '@firebase/app';
9
+ import { FirebaseError } from '@firebase/app';
10
+
11
+ /**
12
+ * Makes the last fetched config available to the getters.
13
+ * @param remoteConfig - The {@link RemoteConfig} instance.
14
+ * @returns A `Promise` which resolves to true if the current call activated the fetched configs.
15
+ * If the fetched configs were already activated, the `Promise` will resolve to false.
16
+ *
17
+ * @public
18
+ */
19
+ export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
20
+
21
+ /**
22
+ * Contains information about which keys have been updated.
23
+ *
24
+ * @public
25
+ */
26
+ export declare interface ConfigUpdate {
27
+ /**
28
+ * Parameter keys whose values have been updated from the currently activated values.
29
+ * Includes keys that are added, deleted, or whose value, value source, or metadata has changed.
30
+ */
31
+ getUpdatedKeys(): Set<string>;
32
+ }
33
+
34
+ /**
35
+ * Observer interface for receiving real-time Remote Config update notifications.
36
+ *
37
+ * NOTE: Although an `complete` callback can be provided, it will
38
+ * never be called because the ConfigUpdate stream is never-ending.
39
+ *
40
+ * @public
41
+ */
42
+ export declare interface ConfigUpdateObserver {
43
+ /**
44
+ * Called when a new ConfigUpdate is available.
45
+ */
46
+ next: (configUpdate: ConfigUpdate) => void;
47
+ /**
48
+ * Called if an error occurs during the stream.
49
+ */
50
+ error: (error: FirebaseError) => void;
51
+ /**
52
+ * Called when the stream is gracefully terminated.
53
+ */
54
+ complete: () => void;
55
+ }
56
+
57
+ /**
58
+ * Defines the type for representing custom signals and their values.
59
+ *
60
+ * <p>The values in CustomSignals must be one of the following types:
61
+ *
62
+ * <ul>
63
+ * <li><code>string</code>
64
+ * <li><code>number</code>
65
+ * <li><code>null</code>
66
+ * </ul>
67
+ *
68
+ * @public
69
+ */
70
+ export declare interface CustomSignals {
71
+ [key: string]: string | number | null;
72
+ }
73
+
74
+ /**
75
+ * Ensures the last activated config are available to the getters.
76
+ * @param remoteConfig - The {@link RemoteConfig} instance.
77
+ *
78
+ * @returns A `Promise` that resolves when the last activated config is available to the getters.
79
+ * @public
80
+ */
81
+ export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
82
+
83
+ /**
84
+ *
85
+ * Performs fetch and activate operations, as a convenience.
86
+ *
87
+ * @param remoteConfig - The {@link RemoteConfig} instance.
88
+ *
89
+ * @returns A `Promise` which resolves to true if the current call activated the fetched configs.
90
+ * If the fetched configs were already activated, the `Promise` will resolve to false.
91
+ *
92
+ * @public
93
+ */
94
+ export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
95
+
96
+ /**
97
+ * Fetches and caches configuration from the Remote Config service.
98
+ * @param remoteConfig - The {@link RemoteConfig} instance.
99
+ * @public
100
+ */
101
+ export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
102
+
103
+ /**
104
+ * Defines a successful response (200 or 304).
105
+ *
106
+ * <p>Modeled after the native `Response` interface, but simplified for Remote Config's
107
+ * use case.
108
+ *
109
+ * @public
110
+ */
111
+ export declare interface FetchResponse {
112
+ /**
113
+ * The HTTP status, which is useful for differentiating success responses with data from
114
+ * those without.
115
+ *
116
+ * <p>The Remote Config client is modeled after the native `Fetch` interface, so
117
+ * HTTP status is first-class.
118
+ *
119
+ * <p>Disambiguation: the fetch response returns a legacy "state" value that is redundant with the
120
+ * HTTP status code. The former is normalized into the latter.
121
+ */
122
+ status: number;
123
+ /**
124
+ * Defines the ETag response header value.
125
+ *
126
+ * <p>Only defined for 200 and 304 responses.
127
+ */
128
+ eTag?: string;
129
+ /**
130
+ * Defines the map of parameters returned as "entries" in the fetch response body.
131
+ *
132
+ * <p>Only defined for 200 responses.
133
+ */
134
+ config?: FirebaseRemoteConfigObject;
135
+ /**
136
+ * The version number of the config template fetched from the server.
137
+ */
138
+ templateVersion?: number;
139
+ /**
140
+ * Metadata for A/B testing and Remote Config Rollout experiments.
141
+ *
142
+ * @remarks Only defined for 200 responses.
143
+ */
144
+ experiments?: FirebaseExperimentDescription[];
145
+ }
146
+
147
+ /**
148
+ * Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
149
+ *
150
+ * <ul>
151
+ * <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
152
+ * to fetch config, or that SDK initialization is incomplete.</li>
153
+ * <li>"success" indicates the last attempt succeeded.</li>
154
+ * <li>"failure" indicates the last attempt failed.</li>
155
+ * <li>"throttle" indicates the last attempt was rate-limited.</li>
156
+ * </ul>
157
+ *
158
+ * @public
159
+ */
160
+ export declare type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
161
+
162
+ /**
163
+ * Indicates the type of fetch request.
164
+ *
165
+ * <ul>
166
+ * <li>"BASE" indicates a standard fetch request.</li>
167
+ * <li>"REALTIME" indicates a fetch request triggered by a real-time update.</li>
168
+ * </ul>
169
+ *
170
+ * @public
171
+ */
172
+ export declare type FetchType = 'BASE' | 'REALTIME';
173
+
174
+ /**
175
+ * Defines experiment and variant attached to a config parameter.
176
+ *
177
+ * @public
178
+ */
179
+ export declare interface FirebaseExperimentDescription {
180
+ experimentId: string;
181
+ variantId: string;
182
+ experimentStartTime: string;
183
+ triggerTimeoutMillis: string;
184
+ timeToLiveMillis: string;
185
+ affectedParameterKeys?: string[];
186
+ }
187
+
188
+ /**
189
+ * Defines a self-descriptive reference for config key-value pairs.
190
+ *
191
+ * @public
192
+ */
193
+ export declare interface FirebaseRemoteConfigObject {
194
+ [key: string]: string;
195
+ }
196
+
197
+ /**
198
+ * Gets all config.
199
+ *
200
+ * @param remoteConfig - The {@link RemoteConfig} instance.
201
+ * @returns All config.
202
+ *
203
+ * @public
204
+ */
205
+ export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
206
+
207
+ /**
208
+ * Gets the value for the given key as a boolean.
209
+ *
210
+ * Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
211
+ *
212
+ * @param remoteConfig - The {@link RemoteConfig} instance.
213
+ * @param key - The name of the parameter.
214
+ *
215
+ * @returns The value for the given key as a boolean.
216
+ * @public
217
+ */
218
+ export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
219
+
220
+ /**
221
+ * Gets the value for the given key as a number.
222
+ *
223
+ * Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
224
+ *
225
+ * @param remoteConfig - The {@link RemoteConfig} instance.
226
+ * @param key - The name of the parameter.
227
+ *
228
+ * @returns The value for the given key as a number.
229
+ *
230
+ * @public
231
+ */
232
+ export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
233
+
234
+ /**
235
+ *
236
+ * @param app - The {@link @firebase/app#FirebaseApp} instance.
237
+ * @param options - Optional. The {@link RemoteConfigOptions} with which to instantiate the
238
+ * Remote Config instance.
239
+ * @returns A {@link RemoteConfig} instance.
240
+ *
241
+ * @public
242
+ */
243
+ export declare function getRemoteConfig(app?: FirebaseApp, options?: RemoteConfigOptions): RemoteConfig;
244
+
245
+ /**
246
+ * Gets the value for the given key as a string.
247
+ * Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
248
+ *
249
+ * @param remoteConfig - The {@link RemoteConfig} instance.
250
+ * @param key - The name of the parameter.
251
+ *
252
+ * @returns The value for the given key as a string.
253
+ *
254
+ * @public
255
+ */
256
+ export declare function getString(remoteConfig: RemoteConfig, key: string): string;
257
+
258
+ /**
259
+ * Gets the {@link Value} for the given key.
260
+ *
261
+ * @param remoteConfig - The {@link RemoteConfig} instance.
262
+ * @param key - The name of the parameter.
263
+ *
264
+ * @returns The value for the given key.
265
+ *
266
+ * @public
267
+ */
268
+ export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
269
+
270
+ /**
271
+ * This method provides two different checks:
272
+ *
273
+ * 1. Check if IndexedDB exists in the browser environment.
274
+ * 2. Check if the current browser context allows IndexedDB `open()` calls.
275
+ *
276
+ * @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
277
+ * can be initialized in this environment, or false if it cannot.
278
+ * @public
279
+ */
280
+ export declare function isSupported(): Promise<boolean>;
281
+
282
+ /**
283
+ * Defines levels of Remote Config logging.
284
+ *
285
+ * @public
286
+ */
287
+ export declare type LogLevel = 'debug' | 'error' | 'silent';
288
+
289
+ /**
290
+ * Starts listening for real-time config updates from the Remote Config backend and automatically
291
+ * fetches updates from the Remote Config backend when they are available.
292
+ *
293
+ * @remarks
294
+ * If a connection to the Remote Config backend is not already open, calling this method will
295
+ * open it. Multiple listeners can be added by calling this method again, but subsequent calls
296
+ * re-use the same connection to the backend.
297
+ *
298
+ * @param remoteConfig - The {@link RemoteConfig} instance.
299
+ * @param observer - The {@link ConfigUpdateObserver} to be notified of config updates.
300
+ * @returns An {@link Unsubscribe} function to remove the listener.
301
+ *
302
+ * @public
303
+ */
304
+ export declare function onConfigUpdate(remoteConfig: RemoteConfig, observer: ConfigUpdateObserver): Unsubscribe;
305
+
306
+ /**
307
+ * The Firebase Remote Config service interface.
308
+ *
309
+ * @public
310
+ */
311
+ export declare interface RemoteConfig {
312
+ /**
313
+ * The {@link @firebase/app#FirebaseApp} this `RemoteConfig` instance is associated with.
314
+ */
315
+ app: FirebaseApp;
316
+ /**
317
+ * Defines configuration for the Remote Config SDK.
318
+ */
319
+ settings: RemoteConfigSettings;
320
+ /**
321
+ * Object containing default values for configs.
322
+ */
323
+ defaultConfig: {
324
+ [key: string]: string | number | boolean;
325
+ };
326
+ /**
327
+ * The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
328
+ * the {@link RemoteConfig} instance either hasn't fetched or initialization
329
+ * is incomplete.
330
+ */
331
+ fetchTimeMillis: number;
332
+ /**
333
+ * The status of the last fetch <i>attempt</i>.
334
+ */
335
+ lastFetchStatus: FetchStatus;
336
+ }
337
+
338
+ /**
339
+ * Options for Remote Config initialization.
340
+ *
341
+ * @public
342
+ */
343
+ export declare interface RemoteConfigOptions {
344
+ /**
345
+ * The ID of the template to use. If not provided, defaults to "firebase".
346
+ */
347
+ templateId?: string;
348
+ /**
349
+ * Hydrates the state with an initial fetch response.
350
+ */
351
+ initialFetchResponse?: FetchResponse;
352
+ }
353
+
354
+ /**
355
+ * Defines configuration options for the Remote Config SDK.
356
+ *
357
+ * @public
358
+ */
359
+ export declare interface RemoteConfigSettings {
360
+ /**
361
+ * Defines the maximum age in milliseconds of an entry in the config cache before
362
+ * it is considered stale. Defaults to 43200000 (Twelve hours).
363
+ */
364
+ minimumFetchIntervalMillis: number;
365
+ /**
366
+ * Defines the maximum amount of milliseconds to wait for a response when fetching
367
+ * configuration from the Remote Config server. Defaults to 60000 (One minute).
368
+ */
369
+ fetchTimeoutMillis: number;
370
+ }
371
+
372
+ /**
373
+ * Sets the custom signals for the app instance.
374
+ *
375
+ * @param remoteConfig - The {@link RemoteConfig} instance.
376
+ * @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If
377
+ * a key already exists, the value is overwritten. Setting the value of a custom signal to null
378
+ * unsets the signal. The signals will be persisted locally on the client.
379
+ *
380
+ * @public
381
+ */
382
+ export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>;
383
+
384
+ /**
385
+ * Defines the log level to use.
386
+ *
387
+ * @param remoteConfig - The {@link RemoteConfig} instance.
388
+ * @param logLevel - The log level to set.
389
+ *
390
+ * @public
391
+ */
392
+ export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: LogLevel): void;
393
+
394
+ /**
395
+ * A function that unsubscribes from a real-time event stream.
396
+ *
397
+ * @public
398
+ */
399
+ export declare type Unsubscribe = () => void;
400
+
401
+ /**
402
+ * Wraps a value with metadata and type-safe getters.
403
+ *
404
+ * @public
405
+ */
406
+ export declare interface Value {
407
+ /**
408
+ * Gets the value as a boolean.
409
+ *
410
+ * The following values (case-insensitive) are interpreted as true:
411
+ * "1", "true", "t", "yes", "y", "on". Other values are interpreted as false.
412
+ */
413
+ asBoolean(): boolean;
414
+ /**
415
+ * Gets the value as a number. Comparable to calling <code>Number(value) || 0</code>.
416
+ */
417
+ asNumber(): number;
418
+ /**
419
+ * Gets the value as a string.
420
+ */
421
+ asString(): string;
422
+ /**
423
+ * Gets the {@link ValueSource} for the given key.
424
+ */
425
+ getSource(): ValueSource;
426
+ }
427
+
428
+ /**
429
+ * Indicates the source of a value.
430
+ *
431
+ * <ul>
432
+ * <li>"static" indicates the value was defined by a static constant.</li>
433
+ * <li>"default" indicates the value was defined by default config.</li>
434
+ * <li>"remote" indicates the value was defined by fetched config.</li>
435
+ * </ul>
436
+ *
437
+ * @public
438
+ */
439
+ export declare type ValueSource = 'static' | 'default' | 'remote';
440
+
441
+ export { }