Skip to content

[Exp] Export public types from App, RC, FCM, Perf, and Installations #4350

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 8 commits into from
Jan 27, 2021
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
12 changes: 9 additions & 3 deletions common/api-review/app-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
```ts

import { Component } from '@firebase/component';
import { FirebaseApp } from '@firebase/app-types-exp';
import { FirebaseAppConfig } from '@firebase/app-types-exp';
import { FirebaseOptions } from '@firebase/app-types-exp';
import { FirebaseApp } from '@firebase/app-types';
import { FirebaseAppConfig } from '@firebase/app-types';
import { FirebaseOptions } from '@firebase/app-types';
import { LogCallback } from '@firebase/logger';
import { LogLevelString } from '@firebase/logger';
import { LogOptions } from '@firebase/logger';
Expand Down Expand Up @@ -35,6 +35,12 @@ export const _DEFAULT_ENTRY_NAME = "[DEFAULT]";
// @public
export function deleteApp(app: FirebaseApp): Promise<void>;

export { FirebaseApp }

export { FirebaseAppConfig }

export { FirebaseOptions }

// @public
export function getApp(name?: string): FirebaseApp;

Expand Down
8 changes: 4 additions & 4 deletions common/api-review/app-types-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export interface _FirebaseService {
_delete(): Promise<void>;
}

// @public (undocumented)
export interface PlatformLoggerService {
// @internal (undocumented)
export interface _PlatformLoggerService {
// (undocumented)
getPlatformInfoString(): string;
}

// @public (undocumented)
export interface VersionService {
// @internal (undocumented)
export interface _VersionService {
// (undocumented)
library: string;
// (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions packages-exp/app-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"predoc": "node ../../scripts/exp/remove-exp.js temp",
"doc": "api-documenter markdown --input temp --output docs",
"build:doc": "yarn build && yarn doc",
"typings:public": "node ./use_typings.js --public",
"typings:internal": "node ./use_typings.js"
"typings:public": "node ../../scripts/exp/use_typings.js ./dist/app-exp-public.d.ts",
"typings:internal": "node ../../scripts/exp/use_typings.js ./dist/app-exp.d.ts"
},
"dependencies": {
"@firebase/app-types-exp": "0.0.900",
Expand Down
2 changes: 2 additions & 0 deletions packages-exp/app-exp/rollup.config.release.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const es5BuildPlugins = [
typescriptPlugin({
typescript,
clean: true,
abortOnError: false,
transformers: [importPathTransformer]
}),
json()
Expand All @@ -53,6 +54,7 @@ const es2017BuildPlugins = [
}
},
clean: true,
abortOnError: false,
transformers: [importPathTransformer]
}),
json({
Expand Down
2 changes: 2 additions & 0 deletions packages-exp/app-exp/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,5 @@ export function onLog(
export function setLogLevel(logLevel: LogLevelString): void {
setLogLevelImpl(logLevel);
}

export { FirebaseApp, FirebaseAppConfig, FirebaseOptions };
7 changes: 6 additions & 1 deletion packages-exp/app-types-exp/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"extends": "../../config/api-extractor.json",
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/index.d.ts"
"mainEntryPointFilePath": "<projectFolder>/index.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts"
}
}
13 changes: 8 additions & 5 deletions packages-exp/app-types-exp/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ export interface FirebaseAppConfig {
}

/**
* @public
* @internal
*/
export interface PlatformLoggerService {
export interface _PlatformLoggerService {
getPlatformInfoString(): string;
}

Expand All @@ -116,15 +116,18 @@ export interface _FirebaseService {
_delete(): Promise<void>;
}

export interface VersionService {
/**
* @internal
*/
export interface _VersionService {
library: string;
version: string;
}

declare module '@firebase/component' {
interface NameServiceMapping {
'app-exp': FirebaseApp;
'app-version': VersionService;
'platform-logger': PlatformLoggerService;
'app-version': _VersionService;
'platform-logger': _PlatformLoggerService;
}
}
5 changes: 4 additions & 1 deletion packages-exp/app-types-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"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"
"build:doc": "yarn api-report && yarn doc",
"build:release": "yarn api-report && yarn typings:public",
"typings:public": "node ../../scripts/exp/use_typings.js ./dist/app-types-exp-public.d.ts",
"typings:internal": "node ../../scripts/exp/use_typings.js ./index.d.ts"
},
"files": [
"index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ export async function deleteInstallations(
}
}
}

export { FirebaseInstallations };
2 changes: 2 additions & 0 deletions packages-exp/messaging-exp/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ export function onBackgroundMessage(
): Unsubscribe {
return _onBackgroundMessage(messaging as MessagingService, nextOrObserver);
}

export { FirebaseMessaging, MessagePayload };
24 changes: 19 additions & 5 deletions packages-exp/messaging-types-exp/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,29 @@
* limitations under the License.
*/

// Currently supported fcm notification display parameters. Note that
// {@link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/notifications/NotificationOptions}
// defines a full list of display notification parameters. This interface we only include what the
// SEND API support for clarity.
/**
* Currently supported fcm notification display parameters. Note that
* {@link https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/notifications/NotificationOptions}
* defines a full list of display notification parameters. This interface we only include what the
* SEND API support for clarity.
*/
export interface NotificationPayload {
title?: string;
body?: string;
image?: string;
}

/**
* @public
*/
export interface FcmOptions {
link?: string;
analyticsLabel?: string;
}

/**
* @public
*/
export interface MessagePayload {
notification?: NotificationPayload;
data?: { [key: string]: string };
Expand All @@ -38,9 +46,15 @@ export interface MessagePayload {
collapseKey: string;
}

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

export type FirebaseMessagingName = 'messaging';
/**
* @internal
*/
export type _FirebaseMessagingName = 'messaging';

declare module '@firebase/component' {
interface NameServiceMapping {
Expand Down
2 changes: 2 additions & 0 deletions packages-exp/performance-exp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ function registerPerformance(): void {

registerPerformance();
registerVersion(name, version);

export { FirebasePerformance, PerformanceSettings, PerformanceTrace };
6 changes: 6 additions & 0 deletions packages-exp/performance-types-exp/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export interface PerformanceSettings {
instrumentationEnabled?: boolean;
}

/**
* @public
*/
export interface FirebasePerformance {
/**
* Controls the logging of automatic traces and HTTP/S network monitoring.
Expand All @@ -38,6 +41,9 @@ export interface FirebasePerformance {
dataCollectionEnabled: boolean;
}

/**
* @public
*/
export interface PerformanceTrace {
/**
* Starts the timing for the trace instance.
Expand Down
2 changes: 2 additions & 0 deletions packages-exp/remote-config-exp/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,5 @@ export function setLogLevel(
function getAllKeys(obj1: {} = {}, obj2: {} = {}): string[] {
return Object.keys({ ...obj1, ...obj2 });
}

export { RemoteConfig, ValueType, RemoteConfigLogLevel };
23 changes: 13 additions & 10 deletions packages-exp/app-exp/use_typings.js → scripts/exp/use_typings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,27 @@
* limitations under the License.
*/

// NOTE: the script assumes it runs at the root of the package you want to update

const { writeFileSync } = require('fs');
const { argv } = require('yargs');

const path = require('path');
const packageJsonPath = path.resolve(__dirname, './package.json');
const packageJsonPath = path.resolve(process.cwd(), './package.json');

// point typings field to the public d.ts file in package.json
const TYPINGS_PATH = argv.public
? './dist/app-exp-public.d.ts'
: './dist/app-exp.d.ts';
console.log(
`Updating the packages-exp/app-exp typings field to the ${
argv.public ? 'public' : 'internal'
} d.ts file ${TYPINGS_PATH}`
);
// point typings field to supplied path in package.json
const TYPINGS_PATH = argv._[0];

if (!TYPINGS_PATH) {
throw Error('Please supply a file path');
}
const packageJson = require(packageJsonPath);
packageJson.typings = TYPINGS_PATH;

console.log(
`Pointing the typings field in ${packageJson.name} to ${TYPINGS_PATH}`
);

writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, {
encoding: 'utf-8'
});