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