Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

remote-config.d.ts 7.1KB

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