@@ -1099,6 +1099,23 @@ declare namespace firebase {
1099
1099
app ?: firebase . app . App
1100
1100
) : firebase . performance . Performance ;
1101
1101
1102
+ /**
1103
+ * Gets the {@link firebase.remoteConfig.RemoteConfig `RemoteConfig`} instance.
1104
+ *
1105
+ * @webonly
1106
+ *
1107
+ * @example
1108
+ * ```javascript
1109
+ * // Get the RemoteConfig instance for the default app
1110
+ * const defaultRemoteConfig = firebase.remoteConfig();
1111
+ * ```
1112
+ *
1113
+ * @param app The app to create a Remote Config service for. If not passed, uses the default app.
1114
+ */
1115
+ function remoteConfig (
1116
+ app ?: firebase . app . App
1117
+ ) : firebase . remoteConfig . RemoteConfig ;
1118
+
1102
1119
/**
1103
1120
* Gets the {@link firebase.analytics.Analytics `Analytics`} service.
1104
1121
*
@@ -1116,7 +1133,6 @@ declare namespace firebase {
1116
1133
* @param app The app to create an analytics service for.
1117
1134
* If not passed, uses the default app.
1118
1135
*/
1119
-
1120
1136
function analytics ( app ?: firebase . app . App ) : firebase . analytics . Analytics ;
1121
1137
}
1122
1138
@@ -1270,6 +1286,19 @@ declare namespace firebase.app {
1270
1286
* ```
1271
1287
*/
1272
1288
performance ( ) : firebase . performance . Performance ;
1289
+ /**
1290
+ * Gets the {@link firebase.remoteConfig.RemoteConfig `RemoteConfig`} instance.
1291
+ *
1292
+ * @webonly
1293
+ *
1294
+ * @example
1295
+ * ```javascript
1296
+ * const rc = app.remoteConfig();
1297
+ * // The above is shorthand for:
1298
+ * // const rc = firebase.remoteConfig(app);
1299
+ * ```
1300
+ */
1301
+ remoteConfig ( ) : firebase . remoteConfig . RemoteConfig ;
1273
1302
/**
1274
1303
* Gets the {@link firebase.analytics.Analytics `Analytics`} service for the
1275
1304
* current app. If the current app is not the default one, throws an error.
@@ -1433,6 +1462,175 @@ declare namespace firebase.performance {
1433
1462
}
1434
1463
}
1435
1464
1465
+ /**
1466
+ * @webonly
1467
+ */
1468
+ declare namespace firebase . remoteConfig {
1469
+ /**
1470
+ * The Firebase Remote Config service interface.
1471
+ *
1472
+ * Do not call this constructor directly. Instead, use
1473
+ * {@link firebase.remoteConfig `firebase.remoteConfig()`}.
1474
+ */
1475
+ export interface RemoteConfig {
1476
+ /**
1477
+ * Defines configuration for the Remote Config SDK.
1478
+ */
1479
+ settings : Settings ;
1480
+
1481
+ /**
1482
+ * Object containing default values for conigs.
1483
+ */
1484
+ defaultConfig : { [ key : string ] : string | number | boolean } ;
1485
+
1486
+ /**
1487
+ * The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
1488
+ * the {@link RemoteConfig} instance either hasn't fetched or initialization
1489
+ * is incomplete.
1490
+ */
1491
+ fetchTimeMillis : number ;
1492
+
1493
+ /**
1494
+ * The status of the last fetch <i>attempt</i>.
1495
+ */
1496
+ lastFetchStatus : FetchStatus ;
1497
+
1498
+ /**
1499
+ * Makes the last fetched config available to the getters.
1500
+ * Returns a promise which resolves to true if the current call activated the fetched configs.
1501
+ * If the fetched configs were already activated, the promise will resolve to false.
1502
+ */
1503
+ activate ( ) : Promise < boolean > ;
1504
+
1505
+ /**
1506
+ * Ensures the last activated config are available to the getters.
1507
+ */
1508
+ ensureInitialized ( ) : Promise < void > ;
1509
+
1510
+ /**
1511
+ * Fetches and caches configuration from the Remote Config service.
1512
+ */
1513
+ fetch ( ) : Promise < void > ;
1514
+
1515
+ /**
1516
+ * Performs fetch and activate operations, as a convenience.
1517
+ * Returns a promise which resolves to true if the current call activated the fetched configs.
1518
+ * If the fetched configs were already activated, the promise will resolve to false.
1519
+ */
1520
+ fetchAndActivate ( ) : Promise < boolean > ;
1521
+
1522
+ /**
1523
+ * Gets all config.
1524
+ */
1525
+ getAll ( ) : { [ key : string ] : Value } ;
1526
+
1527
+ /**
1528
+ * Gets the value for the given key as a boolean.
1529
+ *
1530
+ * Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
1531
+ */
1532
+ getBoolean ( key : string ) : boolean ;
1533
+
1534
+ /**
1535
+ * Gets the value for the given key as a number.
1536
+ *
1537
+ * Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
1538
+ */
1539
+ getNumber ( key : string ) : number ;
1540
+
1541
+ /**
1542
+ * Gets the value for the given key as a String.
1543
+ *
1544
+ * Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
1545
+ */
1546
+ getString ( key : string ) : string ;
1547
+
1548
+ /**
1549
+ * Gets the {@link Value} for the given key.
1550
+ */
1551
+ getValue ( key : string ) : Value ;
1552
+
1553
+ /**
1554
+ * Defines the log level to use.
1555
+ */
1556
+ setLogLevel ( logLevel : LogLevel ) : void ;
1557
+ }
1558
+
1559
+ /**
1560
+ * Indicates the source of a value.
1561
+ *
1562
+ * <ul>
1563
+ * <li>"static" indicates the value was defined by a static constant.</li>
1564
+ * <li>"default" indicates the value was defined by default config.</li>
1565
+ * <li>"remote" indicates the value was defined by fetched config.</li>
1566
+ * </ul>
1567
+ */
1568
+ export type ValueSource = 'static' | 'default' | 'remote' ;
1569
+
1570
+ /**
1571
+ * Wraps a value with metadata and type-safe getters.
1572
+ */
1573
+ export interface Value {
1574
+ /**
1575
+ * Gets the value as a boolean.
1576
+ *
1577
+ * The following values (case insensitive) are interpreted as true:
1578
+ * "1", "true", "t", "yes", "y", "on". Other values are interpreted as false.
1579
+ */
1580
+ asBoolean ( ) : boolean ;
1581
+
1582
+ /**
1583
+ * Gets the value as a number. Comparable to calling <code>Number(value) || 0</code>.
1584
+ */
1585
+ asNumber ( ) : number ;
1586
+
1587
+ /**
1588
+ * Gets the value as a string.
1589
+ */
1590
+ asString ( ) : string ;
1591
+
1592
+ /**
1593
+ * Gets the {@link ValueSource} for the given key.
1594
+ */
1595
+ getSource ( ) : ValueSource ;
1596
+ }
1597
+
1598
+ /**
1599
+ * Defines configuration options for the Remote Config SDK.
1600
+ */
1601
+ export interface Settings {
1602
+ /**
1603
+ * Defines the maximum age in milliseconds of an entry in the config cache before
1604
+ * it is considered stale. Defaults to 43200000 (Twelve hours).
1605
+ */
1606
+ minimumFetchIntervalMillis : number ;
1607
+
1608
+ /**
1609
+ * Defines the maximum amount of milliseconds to wait for a response when fetching
1610
+ * configuration from the Remote Config server. Defaults to 60000 (One minute).
1611
+ */
1612
+ fetchTimeoutMillis : number ;
1613
+ }
1614
+
1615
+ /**
1616
+ * Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
1617
+ *
1618
+ * <ul>
1619
+ * <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
1620
+ * to fetch config, or that SDK initialization is incomplete.</li>
1621
+ * <li>"success" indicates the last attempt succeeded.</li>
1622
+ * <li>"failure" indicates the last attempt failed.</li>
1623
+ * <li>"throttle" indicates the last attempt was rate-limited.</li>
1624
+ * </ul>
1625
+ */
1626
+ export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle' ;
1627
+
1628
+ /**
1629
+ * Defines levels of Remote Config logging.
1630
+ */
1631
+ export type LogLevel = 'debug' | 'error' | 'silent' ;
1632
+ }
1633
+
1436
1634
/**
1437
1635
* @webonly
1438
1636
*/
0 commit comments