@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.
- package/README.md +31 -0
- package/changes.json +10 -0
- package/dist/esm/index.esm.js +2199 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/src/abt/experiment.d.ts +13 -0
- package/dist/esm/src/api.d.ts +144 -0
- package/dist/esm/src/api2.d.ts +40 -0
- package/dist/esm/src/client/caching_client.d.ts +46 -0
- package/dist/esm/src/client/eventEmitter.d.ts +39 -0
- package/dist/esm/src/client/realtime_handler.d.ts +141 -0
- package/dist/esm/src/client/remote_config_fetch_client.d.ts +104 -0
- package/dist/esm/src/client/rest_client.d.ts +41 -0
- package/dist/esm/src/client/retrying_client.d.ts +50 -0
- package/dist/esm/src/client/visibility_monitor.d.ts +23 -0
- package/dist/esm/src/constants.d.ts +20 -0
- package/dist/esm/src/errors.d.ts +87 -0
- package/dist/esm/src/index.d.ts +14 -0
- package/dist/esm/src/language.d.ts +26 -0
- package/dist/esm/src/public_types.d.ts +274 -0
- package/dist/esm/src/register.d.ts +2 -0
- package/dist/esm/src/remote_config.d.ts +98 -0
- package/dist/esm/src/storage/storage.d.ts +118 -0
- package/dist/esm/src/storage/storage_cache.d.ts +51 -0
- package/dist/esm/src/value.d.ts +26 -0
- package/dist/esm/test/setup.d.ts +17 -0
- package/dist/index.cjs.js +2216 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/remote-config-public.d.ts +441 -0
- package/dist/remote-config.d.ts +441 -0
- package/dist/src/abt/experiment.d.ts +13 -0
- package/dist/src/api.d.ts +144 -0
- package/dist/src/api2.d.ts +40 -0
- package/dist/src/client/caching_client.d.ts +46 -0
- package/dist/src/client/eventEmitter.d.ts +39 -0
- package/dist/src/client/realtime_handler.d.ts +141 -0
- package/dist/src/client/remote_config_fetch_client.d.ts +104 -0
- package/dist/src/client/rest_client.d.ts +41 -0
- package/dist/src/client/retrying_client.d.ts +50 -0
- package/dist/src/client/visibility_monitor.d.ts +23 -0
- package/dist/src/constants.d.ts +20 -0
- package/dist/src/errors.d.ts +87 -0
- package/dist/src/global_index.d.ts +674 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/language.d.ts +26 -0
- package/dist/src/public_types.d.ts +274 -0
- package/dist/src/register.d.ts +2 -0
- package/dist/src/remote_config.d.ts +98 -0
- package/dist/src/storage/storage.d.ts +118 -0
- package/dist/src/storage/storage_cache.d.ts +51 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/value.d.ts +26 -0
- package/dist/test/setup.d.ts +17 -0
- 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 { }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FirebaseExperimentDescription } from '../public_types';
|
|
2
|
+
import { RemoteConfig } from '../remote_config';
|
|
3
|
+
export declare class Experiment {
|
|
4
|
+
private storage;
|
|
5
|
+
private logger;
|
|
6
|
+
private analyticsProvider;
|
|
7
|
+
constructor(rc: RemoteConfig);
|
|
8
|
+
updateActiveExperiments(latestExperiments: FirebaseExperimentDescription[]): Promise<void>;
|
|
9
|
+
private createExperimentInfoMap;
|
|
10
|
+
private addActiveExperiments;
|
|
11
|
+
private removeInactiveExperiments;
|
|
12
|
+
private addExperimentToAnalytics;
|
|
13
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { CustomSignals, LogLevel as RemoteConfigLogLevel, RemoteConfig, Value, RemoteConfigOptions, ConfigUpdateObserver, Unsubscribe } from './public_types';
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param app - The {@link @firebase/app#FirebaseApp} instance.
|
|
22
|
+
* @param options - Optional. The {@link RemoteConfigOptions} with which to instantiate the
|
|
23
|
+
* Remote Config instance.
|
|
24
|
+
* @returns A {@link RemoteConfig} instance.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRemoteConfig(app?: FirebaseApp, options?: RemoteConfigOptions): RemoteConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Makes the last fetched config available to the getters.
|
|
31
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
32
|
+
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
|
33
|
+
* If the fetched configs were already activated, the `Promise` will resolve to false.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Ensures the last activated config are available to the getters.
|
|
40
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
41
|
+
*
|
|
42
|
+
* @returns A `Promise` that resolves when the last activated config is available to the getters.
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Fetches and caches configuration from the Remote Config service.
|
|
48
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Gets all config.
|
|
54
|
+
*
|
|
55
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
56
|
+
* @returns All config.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the value for the given key as a boolean.
|
|
63
|
+
*
|
|
64
|
+
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
|
|
65
|
+
*
|
|
66
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
67
|
+
* @param key - The name of the parameter.
|
|
68
|
+
*
|
|
69
|
+
* @returns The value for the given key as a boolean.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the value for the given key as a number.
|
|
75
|
+
*
|
|
76
|
+
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
|
|
77
|
+
*
|
|
78
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
79
|
+
* @param key - The name of the parameter.
|
|
80
|
+
*
|
|
81
|
+
* @returns The value for the given key as a number.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the value for the given key as a string.
|
|
88
|
+
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
|
|
89
|
+
*
|
|
90
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
91
|
+
* @param key - The name of the parameter.
|
|
92
|
+
*
|
|
93
|
+
* @returns The value for the given key as a string.
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the {@link Value} for the given key.
|
|
100
|
+
*
|
|
101
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
102
|
+
* @param key - The name of the parameter.
|
|
103
|
+
*
|
|
104
|
+
* @returns The value for the given key.
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
|
|
109
|
+
/**
|
|
110
|
+
* Defines the log level to use.
|
|
111
|
+
*
|
|
112
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
113
|
+
* @param logLevel - The log level to set.
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;
|
|
118
|
+
/**
|
|
119
|
+
* Sets the custom signals for the app instance.
|
|
120
|
+
*
|
|
121
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
122
|
+
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If
|
|
123
|
+
* a key already exists, the value is overwritten. Setting the value of a custom signal to null
|
|
124
|
+
* unsets the signal. The signals will be persisted locally on the client.
|
|
125
|
+
*
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Starts listening for real-time config updates from the Remote Config backend and automatically
|
|
131
|
+
* fetches updates from the Remote Config backend when they are available.
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* If a connection to the Remote Config backend is not already open, calling this method will
|
|
135
|
+
* open it. Multiple listeners can be added by calling this method again, but subsequent calls
|
|
136
|
+
* re-use the same connection to the backend.
|
|
137
|
+
*
|
|
138
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
139
|
+
* @param observer - The {@link ConfigUpdateObserver} to be notified of config updates.
|
|
140
|
+
* @returns An {@link Unsubscribe} function to remove the listener.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare function onConfigUpdate(remoteConfig: RemoteConfig, observer: ConfigUpdateObserver): Unsubscribe;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { RemoteConfig } from './public_types';
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* Performs fetch and activate operations, as a convenience.
|
|
21
|
+
*
|
|
22
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
23
|
+
*
|
|
24
|
+
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
|
25
|
+
* If the fetched configs were already activated, the `Promise` will resolve to false.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* This method provides two different checks:
|
|
32
|
+
*
|
|
33
|
+
* 1. Check if IndexedDB exists in the browser environment.
|
|
34
|
+
* 2. Check if the current browser context allows IndexedDB `open()` calls.
|
|
35
|
+
*
|
|
36
|
+
* @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
|
|
37
|
+
* can be initialized in this environment, or false if it cannot.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function isSupported(): Promise<boolean>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { StorageCache } from '../storage/storage_cache';
|
|
18
|
+
import { FetchResponse } from '../public_types';
|
|
19
|
+
import { RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
|
|
20
|
+
import { Storage } from '../storage/storage';
|
|
21
|
+
import { Logger } from '@firebase/logger';
|
|
22
|
+
/**
|
|
23
|
+
* Implements the {@link RemoteConfigClient} abstraction with success response caching.
|
|
24
|
+
*
|
|
25
|
+
* <p>Comparable to the browser's Cache API for responses, but the Cache API requires a Service
|
|
26
|
+
* Worker, which requires HTTPS, which would significantly complicate SDK installation. Also, the
|
|
27
|
+
* Cache API doesn't support matching entries by time.
|
|
28
|
+
*/
|
|
29
|
+
export declare class CachingClient implements RemoteConfigFetchClient {
|
|
30
|
+
private readonly client;
|
|
31
|
+
private readonly storage;
|
|
32
|
+
private readonly storageCache;
|
|
33
|
+
private readonly logger;
|
|
34
|
+
constructor(client: RemoteConfigFetchClient, storage: Storage, storageCache: StorageCache, logger: Logger);
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if the age of the cached fetched configs is less than or equal to
|
|
37
|
+
* {@link Settings#minimumFetchIntervalInSeconds}.
|
|
38
|
+
*
|
|
39
|
+
* <p>This is comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the
|
|
40
|
+
* native Fetch API.
|
|
41
|
+
*
|
|
42
|
+
* <p>Visible for testing.
|
|
43
|
+
*/
|
|
44
|
+
isCachedDataFresh(cacheMaxAgeMillis: number, lastSuccessfulFetchTimestampMillis: number | undefined): boolean;
|
|
45
|
+
fetch(request: FetchRequest): Promise<FetchResponse>;
|
|
46
|
+
}
|