Skip to content

Commit 7fe4f9f

Browse files
committed
fix remote-config-compat
1 parent af5894d commit 7fe4f9f

File tree

9 files changed

+46
-19
lines changed

9 files changed

+46
-19
lines changed

common/api-review/remote-config-exp.api.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
```ts
66

77
import { FirebaseApp } from '@firebase/app-exp';
8-
import { RemoteConfig } from '@firebase/remote-config-types-exp';
9-
import { LogLevel as RemoteConfigLogLevel } from '@firebase/remote-config-types-exp';
10-
import { Value as ValueType } from '@firebase/remote-config-types-exp';
118

129
// @public
1310
export function activate(remoteConfig: RemoteConfig): Promise<boolean>;
@@ -22,7 +19,10 @@ export function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
2219
export function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
2320

2421
// @public
25-
export function getAll(remoteConfig: RemoteConfig): Record<string, ValueType>;
22+
export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
23+
24+
// @public
25+
export function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
2626

2727
// @public
2828
export function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
@@ -37,16 +37,40 @@ export function getRemoteConfig(app: FirebaseApp): RemoteConfig;
3737
export function getString(remoteConfig: RemoteConfig, key: string): string;
3838

3939
// @public
40-
export function getValue(remoteConfig: RemoteConfig, key: string): ValueType;
40+
export function getValue(remoteConfig: RemoteConfig, key: string): Value;
4141

42-
export { RemoteConfig }
42+
// @public
43+
export type LogLevel = 'debug' | 'error' | 'silent';
4344

44-
export { RemoteConfigLogLevel }
45+
// @public
46+
export interface RemoteConfig {
47+
defaultConfig: {
48+
[key: string]: string | number | boolean;
49+
};
50+
fetchTimeMillis: number;
51+
lastFetchStatus: FetchStatus;
52+
settings: Settings;
53+
}
4554

4655
// @public
47-
export function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;
56+
export function setLogLevel(remoteConfig: RemoteConfig, logLevel: LogLevel): void;
4857

49-
export { ValueType }
58+
// @public
59+
export interface Settings {
60+
fetchTimeoutMillis: number;
61+
minimumFetchIntervalMillis: number;
62+
}
63+
64+
// @public
65+
export interface Value {
66+
asBoolean(): boolean;
67+
asNumber(): number;
68+
asString(): string;
69+
getSource(): ValueSource;
70+
}
71+
72+
// @public
73+
export type ValueSource = 'static' | 'default' | 'remote';
5074

5175

5276
// (No @packageDocumentation comment for this package)

packages-exp/remote-config-compat/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
},
2929
"dependencies": {
3030
"@firebase/remote-config-exp": "0.0.900",
31-
"@firebase/remote-config-types-exp": "0.0.900",
3231
"@firebase/util": "0.3.4",
3332
"@firebase/logger": "0.2.6",
3433
"@firebase/component": "0.1.21",

packages-exp/remote-config-compat/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { RemoteConfigCompatImpl } from './remoteConfig';
2525
import { name as packageName, version } from '../package.json';
2626
import { RemoteConfig as RemoteConfigCompat } from '@firebase/remote-config-types';
2727

28-
// TODO: move it to the future remote-config-compat-types package
28+
// TODO: move it to remote-config-types package
2929
declare module '@firebase/component' {
3030
interface NameServiceMapping {
3131
'remote-config-compat': RemoteConfigCompat;

packages-exp/remote-config-compat/src/remoteConfig.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { stub } from 'sinon';
2121
import { RemoteConfigCompatImpl } from './remoteConfig';
2222
import { getFakeApp, getFakeModularRemoteConfig } from '../test/util';
2323
import * as modularApi from '@firebase/remote-config-exp';
24-
import { Value } from '@firebase/remote-config-types-exp';
2524

2625
describe('Remote Config Compat', () => {
2726
let remoteConfig!: RemoteConfigCompatImpl;
@@ -134,7 +133,7 @@ describe('Remote Config Compat', () => {
134133
});
135134

136135
it('getValue() calls modular getValue()', () => {
137-
const fakeValue = {} as Value;
136+
const fakeValue = {} as modularApi.Value;
138137
const modularGetValue = stub(modularApi, 'getValue').callsFake(
139138
() => fakeValue
140139
);

packages-exp/remote-config-compat/src/remoteConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
import { FirebaseApp, _FirebaseService } from '@firebase/app-compat';
19-
import { RemoteConfig } from '@firebase/remote-config-types-exp';
2019
import {
2120
Value as ValueCompat,
2221
FetchStatus as FetchSTatusCompat,
@@ -25,6 +24,7 @@ import {
2524
RemoteConfig as RemoteConfigCompat
2625
} from '@firebase/remote-config-types';
2726
import {
27+
RemoteConfig,
2828
setLogLevel,
2929
activate,
3030
ensureInitialized,

packages-exp/remote-config-compat/test/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { FirebaseApp } from '@firebase/app-compat';
19-
import { RemoteConfig } from '@firebase/remote-config-types-exp';
19+
import { RemoteConfig } from '@firebase/remote-config-exp';
2020

2121
export function getFakeApp(): FirebaseApp {
2222
return {

packages-exp/remote-config-exp/api-extractor.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Point it to your entry point d.ts file.
44
"mainEntryPointFilePath": "<projectFolder>/dist/src/index.d.ts",
55
"dtsRollup": {
6-
"enabled": true
6+
"enabled": true,
7+
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
8+
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts"
79
}
810
}

packages-exp/remote-config-exp/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1515
"build": "rollup -c && yarn api-report",
1616
"build:deps": "lerna run --scope @firebase/remote-config-exp --include-dependencies build",
17-
"build:release": "rollup -c rollup.config.release.js && yarn api-report",
17+
"build:release": "rollup -c rollup.config.release.js && yarn api-report && yarn typings:public",
1818
"dev": "rollup -c -w",
1919
"test": "run-p lint test:browser",
2020
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:browser",
@@ -24,7 +24,9 @@
2424
"api-report": "api-extractor run --local --verbose",
2525
"predoc": "node ../../scripts/exp/remove-exp.js temp",
2626
"doc": "api-documenter markdown --input temp --output docs",
27-
"build:doc": "yarn build && yarn doc"
27+
"build:doc": "yarn build && yarn doc",
28+
"typings:public": "node ../../scripts/exp/use_typings.js ./dist/app-exp-public.d.ts",
29+
"typings:internal": "node ../../scripts/exp/use_typings.js ./dist/src/index.d.ts"
2830
},
2931
"peerDependencies": {
3032
"@firebase/app-exp": "0.x"
@@ -51,7 +53,7 @@
5153
"bugs": {
5254
"url": "https://github.com/firebase/firebase-js-sdk/issues"
5355
},
54-
"typings": "dist/remote-config-exp.d.ts",
56+
"typings": "dist/src/index.d.ts",
5557
"nyc": {
5658
"extension": [
5759
".ts"

packages-exp/remote-config-exp/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ declare global {
2929

3030
export * from './api';
3131
export * from './api2';
32+
export * from './public_types';
3233

3334
/** register component and version */
3435
registerRemoteConfig();

0 commit comments

Comments
 (0)