Skip to content

Remove remote-config-types-exp #4496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"@firebase/performance-exp",
"@firebase/performance-types-exp",
"@firebase/remote-config-exp",
"@firebase/remote-config-types-exp",
"@firebase/remote-config-compat",
"firebase-exp",
"@firebase/app-compat",
Expand Down
42 changes: 33 additions & 9 deletions common/api-review/remote-config-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
```ts

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

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

// @public
export function getAll(remoteConfig: RemoteConfig): Record<string, ValueType>;
export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';

// @public
export function getAll(remoteConfig: RemoteConfig): Record<string, Value>;

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

// @public
export function getValue(remoteConfig: RemoteConfig, key: string): ValueType;
export function getValue(remoteConfig: RemoteConfig, key: string): Value;

export { RemoteConfig }
// @public
export type LogLevel = 'debug' | 'error' | 'silent';

export { RemoteConfigLogLevel }
// @public
export interface RemoteConfig {
defaultConfig: {
[key: string]: string | number | boolean;
};
fetchTimeMillis: number;
lastFetchStatus: FetchStatus;
settings: Settings;
}

// @public
export function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;
export function setLogLevel(remoteConfig: RemoteConfig, logLevel: LogLevel): void;

export { ValueType }
// @public
export interface Settings {
fetchTimeoutMillis: number;
minimumFetchIntervalMillis: number;
}

// @public
export interface Value {
asBoolean(): boolean;
asNumber(): number;
asString(): string;
getSource(): ValueSource;
}

// @public
export type ValueSource = 'static' | 'default' | 'remote';


// (No @packageDocumentation comment for this package)
Expand Down
48 changes: 0 additions & 48 deletions common/api-review/remote-config-types-exp.api.md

This file was deleted.

1 change: 0 additions & 1 deletion packages-exp/remote-config-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"dependencies": {
"@firebase/remote-config-exp": "0.0.900",
"@firebase/remote-config-types-exp": "0.0.900",
"@firebase/util": "0.3.4",
"@firebase/logger": "0.2.6",
"@firebase/component": "0.1.21",
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/remote-config-compat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { RemoteConfigCompatImpl } from './remoteConfig';
import { name as packageName, version } from '../package.json';
import { RemoteConfig as RemoteConfigCompat } from '@firebase/remote-config-types';

// TODO: move it to the future remote-config-compat-types package
// TODO: move it to remote-config-types package
declare module '@firebase/component' {
interface NameServiceMapping {
'remote-config-compat': RemoteConfigCompat;
Expand Down
3 changes: 1 addition & 2 deletions packages-exp/remote-config-compat/src/remoteConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { stub } from 'sinon';
import { RemoteConfigCompatImpl } from './remoteConfig';
import { getFakeApp, getFakeModularRemoteConfig } from '../test/util';
import * as modularApi from '@firebase/remote-config-exp';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't in the scope of the PR but this isn't a potential tree-shaking problem is it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a test, so no tree-shaking concerns. It's imported this way to allow stubbing.

import { Value } from '@firebase/remote-config-types-exp';

describe('Remote Config Compat', () => {
let remoteConfig!: RemoteConfigCompatImpl;
Expand Down Expand Up @@ -134,7 +133,7 @@ describe('Remote Config Compat', () => {
});

it('getValue() calls modular getValue()', () => {
const fakeValue = {} as Value;
const fakeValue = {} as modularApi.Value;
const modularGetValue = stub(modularApi, 'getValue').callsFake(
() => fakeValue
);
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/remote-config-compat/src/remoteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

import { FirebaseApp, _FirebaseService } from '@firebase/app-compat';
import { RemoteConfig } from '@firebase/remote-config-types-exp';
import {
Value as ValueCompat,
FetchStatus as FetchSTatusCompat,
Expand All @@ -25,6 +24,7 @@ import {
RemoteConfig as RemoteConfigCompat
} from '@firebase/remote-config-types';
import {
RemoteConfig,
setLogLevel,
activate,
ensureInitialized,
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/remote-config-compat/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

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

export function getFakeApp(): FirebaseApp {
return {
Expand Down
4 changes: 3 additions & 1 deletion packages-exp/remote-config-exp/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/dist/src/index.d.ts",
"dtsRollup": {
"enabled": true
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts"
}
}
9 changes: 5 additions & 4 deletions packages-exp/remote-config-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c && yarn api-report",
"build:deps": "lerna run --scope @firebase/remote-config-exp --include-dependencies build",
"build:release": "rollup -c rollup.config.release.js && yarn api-report",
"build:release": "rollup -c rollup.config.release.js && yarn api-report && yarn typings:public",
"dev": "rollup -c -w",
"test": "run-p lint test:browser",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:browser",
Expand All @@ -24,15 +24,16 @@
"api-report": "api-extractor run --local --verbose",
"predoc": "node ../../scripts/exp/remove-exp.js temp",
"doc": "api-documenter markdown --input temp --output docs",
"build:doc": "yarn build && yarn doc"
"build:doc": "yarn build && yarn doc",
"typings:public": "node ../../scripts/exp/use_typings.js ./dist/remote-config-exp-public.d.ts",
"typings:internal": "node ../../scripts/exp/use_typings.js ./dist/src/index.d.ts"
},
"peerDependencies": {
"@firebase/app-exp": "0.x"
},
"dependencies": {
"@firebase/installations-exp": "0.0.900",
"@firebase/logger": "0.2.6",
"@firebase/remote-config-types-exp": "0.0.900",
"@firebase/util": "0.3.4",
"@firebase/component": "0.1.21",
"tslib": "^1.11.1"
Expand All @@ -52,7 +53,7 @@
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"typings": "dist/remote-config-exp.d.ts",
"typings": "dist/src/index.d.ts",
"nyc": {
"extension": [
".ts"
Expand Down
20 changes: 9 additions & 11 deletions packages-exp/remote-config-exp/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import { _getProvider, FirebaseApp } from '@firebase/app-exp';
import {
LogLevel as RemoteConfigLogLevel,
RemoteConfig,
Value as ValueType
} from '@firebase/remote-config-types-exp';
Value
} from './public_types';
import { RemoteConfigAbortSignal } from './client/remote_config_fetch_client';
import { RC_COMPONENT_NAME } from './constants';
import { ErrorCode, hasErrorCode } from './errors';
import { RemoteConfig as RemoteConfigImpl } from './remote_config';
import { Value } from './value';
import { Value as ValueImpl } from './value';
import { LogLevel as FirebaseLogLevel } from '@firebase/logger';

/**
Expand Down Expand Up @@ -137,15 +137,15 @@ export async function fetchConfig(remoteConfig: RemoteConfig): Promise<void> {
*
* @public
*/
export function getAll(remoteConfig: RemoteConfig): Record<string, ValueType> {
export function getAll(remoteConfig: RemoteConfig): Record<string, Value> {
const rc = remoteConfig as RemoteConfigImpl;
return getAllKeys(
rc._storageCache.getActiveConfig(),
rc.defaultConfig
).reduce((allConfigs, key) => {
allConfigs[key] = getValue(remoteConfig, key);
return allConfigs;
}, {} as Record<string, ValueType>);
}, {} as Record<string, Value>);
}

/**
Expand Down Expand Up @@ -204,7 +204,7 @@ export function getString(remoteConfig: RemoteConfig, key: string): string {
*
* @public
*/
export function getValue(remoteConfig: RemoteConfig, key: string): ValueType {
export function getValue(remoteConfig: RemoteConfig, key: string): Value {
const rc = remoteConfig as RemoteConfigImpl;
if (!rc._isInitializationComplete) {
rc._logger.debug(
Expand All @@ -214,15 +214,15 @@ export function getValue(remoteConfig: RemoteConfig, key: string): ValueType {
}
const activeConfig = rc._storageCache.getActiveConfig();
if (activeConfig && activeConfig[key] !== undefined) {
return new Value('remote', activeConfig[key]);
return new ValueImpl('remote', activeConfig[key]);
} else if (rc.defaultConfig && rc.defaultConfig[key] !== undefined) {
return new Value('default', String(rc.defaultConfig[key]));
return new ValueImpl('default', String(rc.defaultConfig[key]));
}
rc._logger.debug(
`Returning static value for key "${key}".` +
' Define a default or remote value if this is unintentional.'
);
return new Value('static');
return new ValueImpl('static');
}

/**
Expand Down Expand Up @@ -256,5 +256,3 @@ export function setLogLevel(
function getAllKeys(obj1: {} = {}, obj2: {} = {}): string[] {
return Object.keys({ ...obj1, ...obj2 });
}

export { RemoteConfig, ValueType, RemoteConfigLogLevel };
2 changes: 1 addition & 1 deletion packages-exp/remote-config-exp/src/api2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { RemoteConfig } from '@firebase/remote-config-types-exp';
import { RemoteConfig } from './public_types';
import { activate, fetchConfig } from './api';

// This API is put in a separate file, so we can stub fetchConfig and activate in tests.
Expand Down
1 change: 1 addition & 0 deletions packages-exp/remote-config-exp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ declare global {

export * from './api';
export * from './api2';
export * from './public_types';

/** register component and version */
registerRemoteConfig();
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2019 Google LLC
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/remote-config-exp/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
ComponentContainer
} from '@firebase/component';
import { Logger, LogLevel as FirebaseLogLevel } from '@firebase/logger';
import { RemoteConfig } from '@firebase/remote-config-types-exp';
import { RemoteConfig } from './public_types';
import { name as packageName, version } from '../package.json';
import { ensureInitialized } from './api';
import { CachingClient } from './client/caching_client';
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/remote-config-exp/src/remote_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
RemoteConfig as RemoteConfigType,
FetchStatus,
Settings
} from '@firebase/remote-config-types-exp';
} from './public_types';
import { StorageCache } from './storage/storage_cache';
import { RemoteConfigFetchClient } from './client/remote_config_fetch_client';
import { Storage } from './storage/storage';
Expand Down
2 changes: 1 addition & 1 deletion packages-exp/remote-config-exp/test/remote_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { FirebaseApp } from '@firebase/app-exp';
import {
RemoteConfig as RemoteConfigType,
LogLevel as RemoteConfigLogLevel
} from '@firebase/remote-config-types-exp';
} from '../src/public_types';
import { expect } from 'chai';
import * as sinon from 'sinon';
import { StorageCache } from '../src/storage/storage_cache';
Expand Down
3 changes: 0 additions & 3 deletions packages-exp/remote-config-types-exp/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions packages-exp/remote-config-types-exp/api-extractor.json

This file was deleted.

30 changes: 0 additions & 30 deletions packages-exp/remote-config-types-exp/package.json

This file was deleted.

Loading