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