Skip to content

Fixes and api extractor integration for @firebase/installations-exp #3733

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 4 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions common/api-review/installations-exp.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## API Report File for "@firebase/installations-exp"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { FirebaseApp } from '@firebase/app-types-exp';
import { FirebaseInstallations } from '@firebase/installations-types-exp';

// @public (undocumented)
Copy link
Member Author

Choose a reason for hiding this comment

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

@ChaoqunCHEN When you have a chance, can you add documentation for all APIs? It doesn't have to be part of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure.

export function deleteInstallations(installations: FirebaseInstallations): Promise<void>;

// @public (undocumented)
export function getId(installations: FirebaseInstallations): Promise<string>;

// @public (undocumented)
export function getInstallations(app: FirebaseApp): FirebaseInstallations;

// @public (undocumented)
export function getToken(installations: FirebaseInstallations, forceRefresh?: boolean): Promise<string>;

// @public (undocumented)
export type IdChangeCallbackFn = (installationId: string) => void;

// @public (undocumented)
export type IdChangeUnsubscribeFn = () => void;

// @public
export function onIdChange(installations: FirebaseInstallations, callback: IdChangeCallbackFn): IdChangeUnsubscribeFn;


// (No @packageDocumentation comment for this package)

```
20 changes: 20 additions & 0 deletions common/api-review/installations-types-exp.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## API Report File for "@firebase/installations-types-exp"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public (undocumented)
export interface FirebaseInstallations {}

// @internal
export interface _FirebaseInstallationsInternal {
getId(): Promise<string>;

getToken(forceRefresh?: boolean): Promise<string>;
}


// (No @packageDocumentation comment for this package)

```
8 changes: 8 additions & 0 deletions packages-exp/installations-exp/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../config/api-extractor.json",
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/dist/src/index.d.ts",
"dtsRollup": {
"enabled": true
}
}
15 changes: 10 additions & 5 deletions packages-exp/installations-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"browser": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"types": "dist/src/index.d.ts",
"typings": "dist/installations-exp.d.ts",
"license": "Apache-2.0",
"files": [
"dist"
],
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c",
"build": "rollup -c && yarn api-report",
"build:deps": "lerna run --scope @firebase/installations-exp --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && yarn test:karma && yarn lint",
Expand All @@ -25,7 +26,11 @@
"serve": "yarn serve:build && yarn serve:host",
"serve:build": "rollup -c test-app/rollup.config.js",
"serve:host": "http-server -c-1 test-app",
"prepare": "yarn build"
"prepare": "yarn build",
"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"
},
"repository": {
"directory": "packages-exp/installations-exp",
Expand All @@ -37,11 +42,11 @@
},
"devDependencies": {
"@firebase/app-exp": "0.0.800",
"rollup": "2.26.5",
"rollup": "2.26.7",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-typescript2": "0.27.1",
"rollup-plugin-typescript2": "0.27.2",
"rollup-plugin-uglify": "6.0.4",
"typescript": "4.0.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import { ERROR_FACTORY, ErrorCode } from '../util/errors';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { FirebaseInstallations } from '@firebase/installations-types-exp';

/**
* @public
*/
export async function deleteInstallations(
installations: FirebaseInstallations
): Promise<void> {
Expand Down
3 changes: 3 additions & 0 deletions packages-exp/installations-exp/src/api/get-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import { refreshAuthToken } from '../helpers/refresh-auth-token';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { FirebaseInstallations } from '@firebase/installations-types-exp';

/**
* @public
*/
export async function getId(
installations: FirebaseInstallations
): Promise<string> {
Expand Down
3 changes: 3 additions & 0 deletions packages-exp/installations-exp/src/api/get-installations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { FirebaseApp } from '@firebase/app-types-exp';
import { FirebaseInstallations } from '@firebase/installations-types-exp';
import { _getProvider } from '@firebase/app-exp';

/**
* @public
*/
export function getInstallations(app: FirebaseApp): FirebaseInstallations {
const installationsImpl = _getProvider(
app,
Expand Down
3 changes: 3 additions & 0 deletions packages-exp/installations-exp/src/api/get-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
} from '../interfaces/installation-impl';
import { FirebaseInstallations } from '@firebase/installations-types-exp';

/**
* @public
*/
export async function getToken(
installations: FirebaseInstallations,
forceRefresh = false
Expand Down
8 changes: 8 additions & 0 deletions packages-exp/installations-exp/src/api/on-id-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ import { addCallback, removeCallback } from '../helpers/fid-changed';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { FirebaseInstallations } from '@firebase/installations-types-exp';

/**
* @public
*/
export type IdChangeCallbackFn = (installationId: string) => void;
/**
* @public
*/
export type IdChangeUnsubscribeFn = () => void;

/**
* Sets a new callback that will get called when Installation ID changes.
* Returns an unsubscribe function that will remove the callback when called.
*
* @public
*/
export function onIdChange(
installations: FirebaseInstallations,
Expand Down
4 changes: 2 additions & 2 deletions packages-exp/installations-exp/src/functions/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
ComponentContainer
} from '@firebase/component';
import { getId, getToken } from '../api/index';
import { FirebaseInstallationsInternal } from '@firebase/installations-types-exp';
import { _FirebaseInstallationsInternal } from '@firebase/installations-types-exp';
import { FirebaseInstallationsImpl } from '../interfaces/installation-impl';
import { extractAppConfig } from '../helpers/extract-app-config';

Expand Down Expand Up @@ -55,7 +55,7 @@ const internalFactory: InstanceFactory<'installations-exp-internal'> = (
// Internal FIS instance relies on public FIS instance.
const installations = _getProvider(app, INSTALLATIONS_NAME).getImmediate();

const installationsInternal: FirebaseInstallationsInternal = {
const installationsInternal: _FirebaseInstallationsInternal = {
getId: () => getId(installations),
getToken: (forceRefresh?: boolean) => getToken(installations, forceRefresh)
};
Expand Down
11 changes: 7 additions & 4 deletions packages-exp/installations-types-exp/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
* limitations under the License.
*/

import { FirebaseInstallationsImpl } from '../installations-exp/src/interfaces/installation-impl';

/**
* @public
*/
export interface FirebaseInstallations {}

/**
* An interface for Firebase internal SDKs use only.
*
* @internal
*/
export interface FirebaseInstallationsInternal {
export interface _FirebaseInstallationsInternal {
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
Expand All @@ -38,6 +41,6 @@ export interface FirebaseInstallationsInternal {
declare module '@firebase/component' {
interface NameServiceMapping {
'installations-exp': FirebaseInstallations;
'installations-exp-internal': FirebaseInstallationsInternal;
'installations-exp-internal': _FirebaseInstallationsInternal;
}
}
6 changes: 5 additions & 1 deletion packages-exp/installations-types-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"license": "Apache-2.0",
"scripts": {
"test": "tsc",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"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 api-report && yarn doc"
},
"files": [
"index.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion scripts/exp/remove-exp.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (argv._[0]) {
if (statSync(dirOrFile).isFile()) {
removeExpSuffixFromFile(dirOrFile);
} else {
removeExpSuffix(dir);
removeExpSuffix(dirOrFile);
}
}

Expand Down