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 |
|
10 | /**
|
11 | * Makes the last fetched config available to the getters.
|
12 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
13 | * @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
14 | * If the fetched configs were already activated, the `Promise` will resolve to false.
|
15 | *
|
16 | * @public
|
17 | */
|
18 | export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
|
19 |
|
20 | /**
|
21 | * Defines the type for representing custom signals and their values.
|
22 | *
|
23 | * <p>The values in CustomSignals must be one of the following types:
|
24 | *
|
25 | * <ul>
|
26 | * <li><code>string</code>
|
27 | * <li><code>number</code>
|
28 | * <li><code>null</code>
|
29 | * </ul>
|
30 | *
|
31 | * @public
|
32 | */
|
33 | export declare interface CustomSignals {
|
34 | [key: string]: string | number | null;
|
35 | }
|
36 |
|
37 | /**
|
38 | * Ensures the last activated config are available to the getters.
|
39 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
40 | *
|
41 | * @returns A `Promise` that resolves when the last activated config is available to the getters.
|
42 | * @public
|
43 | */
|
44 | export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
|
45 |
|
46 | /**
|
47 | *
|
48 | * Performs fetch and activate operations, as a convenience.
|
49 | *
|
50 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
51 | *
|
52 | * @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
53 | * If the fetched configs were already activated, the `Promise` will resolve to false.
|
54 | *
|
55 | * @public
|
56 | */
|
57 | export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
|
58 |
|
59 | /**
|
60 | * Fetches and caches configuration from the Remote Config service.
|
61 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
62 | * @public
|
63 | */
|
64 | export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
|
65 |
|
66 | /**
|
67 | * Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
|
68 | *
|
69 | * <ul>
|
70 | * <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
|
71 | * to fetch config, or that SDK initialization is incomplete.</li>
|
72 | * <li>"success" indicates the last attempt succeeded.</li>
|
73 | * <li>"failure" indicates the last attempt failed.</li>
|
74 | * <li>"throttle" indicates the last attempt was rate-limited.</li>
|
75 | * </ul>
|
76 | *
|
77 | * @public
|
78 | */
|
79 | export declare type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
|
80 |
|
81 | /**
|
82 | * Gets all config.
|
83 | *
|
84 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
85 | * @returns All config.
|
86 | *
|
87 | * @public
|
88 | */
|
89 | export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
|
90 |
|
91 | /**
|
92 | * Gets the value for the given key as a boolean.
|
93 | *
|
94 | * Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
|
95 | *
|
96 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
97 | * @param key - The name of the parameter.
|
98 | *
|
99 | * @returns The value for the given key as a boolean.
|
100 | * @public
|
101 | */
|
102 | export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
|
103 |
|
104 | /**
|
105 | * Gets the value for the given key as a number.
|
106 | *
|
107 | * Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
|
108 | *
|
109 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
110 | * @param key - The name of the parameter.
|
111 | *
|
112 | * @returns The value for the given key as a number.
|
113 | *
|
114 | * @public
|
115 | */
|
116 | export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
|
117 |
|
118 | /**
|
119 | *
|
120 | * @param app - The {@link @firebase/app#FirebaseApp} instance.
|
121 | * @returns A {@link RemoteConfig} instance.
|
122 | *
|
123 | * @public
|
124 | */
|
125 | export declare function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
|
126 |
|
127 | /**
|
128 | * Gets the value for the given key as a string.
|
129 | * Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
|
130 | *
|
131 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
132 | * @param key - The name of the parameter.
|
133 | *
|
134 | * @returns The value for the given key as a string.
|
135 | *
|
136 | * @public
|
137 | */
|
138 | export declare function getString(remoteConfig: RemoteConfig, key: string): string;
|
139 |
|
140 | /**
|
141 | * Gets the {@link Value} for the given key.
|
142 | *
|
143 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
144 | * @param key - The name of the parameter.
|
145 | *
|
146 | * @returns The value for the given key.
|
147 | *
|
148 | * @public
|
149 | */
|
150 | export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
|
151 |
|
152 | /**
|
153 | * This method provides two different checks:
|
154 | *
|
155 | * 1. Check if IndexedDB exists in the browser environment.
|
156 | * 2. Check if the current browser context allows IndexedDB `open()` calls.
|
157 | *
|
158 | * @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
|
159 | * can be initialized in this environment, or false if it cannot.
|
160 | * @public
|
161 | */
|
162 | export declare function isSupported(): Promise<boolean>;
|
163 |
|
164 | /**
|
165 | * Defines levels of Remote Config logging.
|
166 | *
|
167 | * @public
|
168 | */
|
169 | export declare type LogLevel = 'debug' | 'error' | 'silent';
|
170 |
|
171 | /**
|
172 | * The Firebase Remote Config service interface.
|
173 | *
|
174 | * @public
|
175 | */
|
176 | export declare interface RemoteConfig {
|
177 | /**
|
178 | * The {@link @firebase/app#FirebaseApp} this `RemoteConfig` instance is associated with.
|
179 | */
|
180 | app: FirebaseApp;
|
181 | /**
|
182 | * Defines configuration for the Remote Config SDK.
|
183 | */
|
184 | settings: RemoteConfigSettings;
|
185 | /**
|
186 | * Object containing default values for configs.
|
187 | */
|
188 | defaultConfig: {
|
189 | [key: string]: string | number | boolean;
|
190 | };
|
191 | /**
|
192 | * The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
|
193 | * the {@link RemoteConfig} instance either hasn't fetched or initialization
|
194 | * is incomplete.
|
195 | */
|
196 | fetchTimeMillis: number;
|
197 | /**
|
198 | * The status of the last fetch <i>attempt</i>.
|
199 | */
|
200 | lastFetchStatus: FetchStatus;
|
201 | }
|
202 |
|
203 | /**
|
204 | * Defines configuration options for the Remote Config SDK.
|
205 | *
|
206 | * @public
|
207 | */
|
208 | export declare interface RemoteConfigSettings {
|
209 | /**
|
210 | * Defines the maximum age in milliseconds of an entry in the config cache before
|
211 | * it is considered stale. Defaults to 43200000 (Twelve hours).
|
212 | */
|
213 | minimumFetchIntervalMillis: number;
|
214 | /**
|
215 | * Defines the maximum amount of milliseconds to wait for a response when fetching
|
216 | * configuration from the Remote Config server. Defaults to 60000 (One minute).
|
217 | */
|
218 | fetchTimeoutMillis: number;
|
219 | }
|
220 |
|
221 | /**
|
222 | * Sets the custom signals for the app instance.
|
223 | *
|
224 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
225 | * @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If
|
226 | * a key already exists, the value is overwritten. Setting the value of a custom signal to null
|
227 | * unsets the signal. The signals will be persisted locally on the client.
|
228 | *
|
229 | * @public
|
230 | */
|
231 | export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>;
|
232 |
|
233 | /**
|
234 | * Defines the log level to use.
|
235 | *
|
236 | * @param remoteConfig - The {@link RemoteConfig} instance.
|
237 | * @param logLevel - The log level to set.
|
238 | *
|
239 | * @public
|
240 | */
|
241 | export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: LogLevel): void;
|
242 |
|
243 | /**
|
244 | * Wraps a value with metadata and type-safe getters.
|
245 | *
|
246 | * @public
|
247 | */
|
248 | export declare interface Value {
|
249 | /**
|
250 | * Gets the value as a boolean.
|
251 | *
|
252 | * The following values (case-insensitive) are interpreted as true:
|
253 | * "1", "true", "t", "yes", "y", "on". Other values are interpreted as false.
|
254 | */
|
255 | asBoolean(): boolean;
|
256 | /**
|
257 | * Gets the value as a number. Comparable to calling <code>Number(value) || 0</code>.
|
258 | */
|
259 | asNumber(): number;
|
260 | /**
|
261 | * Gets the value as a string.
|
262 | */
|
263 | asString(): string;
|
264 | /**
|
265 | * Gets the {@link ValueSource} for the given key.
|
266 | */
|
267 | getSource(): ValueSource;
|
268 | }
|
269 |
|
270 | /**
|
271 | * Indicates the source of a value.
|
272 | *
|
273 | * <ul>
|
274 | * <li>"static" indicates the value was defined by a static constant.</li>
|
275 | * <li>"default" indicates the value was defined by default config.</li>
|
276 | * <li>"remote" indicates the value was defined by fetched config.</li>
|
277 | * </ul>
|
278 | *
|
279 | * @public
|
280 | */
|
281 | export declare type ValueSource = 'static' | 'default' | 'remote';
|
282 |
|
283 | export { }
|