Skip to content

feat: Exposed firebase-admin/project-management entry point #1157

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 1 commit into from
Feb 8, 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
91 changes: 33 additions & 58 deletions etc/firebase-admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,67 +607,42 @@ export namespace messaging {
}

// @public
export function projectManagement(app?: app.App): projectManagement.ProjectManagement;
export function projectManagement(app?: App): projectManagement.ProjectManagement;

// @public (undocumented)
export namespace projectManagement {
export interface AndroidApp {
addShaCertificate(certificateToAdd: ShaCertificate): Promise<void>;
// (undocumented)
appId: string;
deleteShaCertificate(certificateToRemove: ShaCertificate): Promise<void>;
getConfig(): Promise<string>;
getMetadata(): Promise<AndroidAppMetadata>;
getShaCertificates(): Promise<ShaCertificate[]>;
setDisplayName(newDisplayName: string): Promise<void>;
}
export interface AndroidAppMetadata extends AppMetadata {
packageName: string;
// (undocumented)
platform: AppPlatform.ANDROID;
}
export interface AppMetadata {
appId: string;
displayName?: string;
platform: AppPlatform;
projectId: string;
resourceName: string;
}
export enum AppPlatform {
ANDROID = "ANDROID",
IOS = "IOS",
PLATFORM_UNKNOWN = "PLATFORM_UNKNOWN"
}
export interface IosApp {
// (undocumented)
appId: string;
getConfig(): Promise<string>;
getMetadata(): Promise<IosAppMetadata>;
setDisplayName(newDisplayName: string): Promise<void>;
}
export interface IosAppMetadata extends AppMetadata {
bundleId: string;
// (undocumented)
platform: AppPlatform.IOS;
}
export interface ProjectManagement {
androidApp(appId: string): AndroidApp;
// (undocumented)
app: app.App;
createAndroidApp(packageName: string, displayName?: string): Promise<AndroidApp>;
createIosApp(bundleId: string, displayName?: string): Promise<IosApp>;
iosApp(appId: string): IosApp;
listAndroidApps(): Promise<AndroidApp[]>;
listAppMetadata(): Promise<AppMetadata[]>;
listIosApps(): Promise<IosApp[]>;
setDisplayName(newDisplayName: string): Promise<void>;
shaCertificate(shaHash: string): ShaCertificate;
}
export interface ShaCertificate {
certType: ('sha1' | 'sha256');
resourceName?: string;
shaHash: string;
}
// Warning: (ae-forgotten-export) The symbol "AndroidApp" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type AndroidApp = AndroidApp;
// Warning: (ae-forgotten-export) The symbol "AndroidAppMetadata" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type AndroidAppMetadata = AndroidAppMetadata;
// Warning: (ae-forgotten-export) The symbol "AppMetadata" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type AppMetadata = AppMetadata;
// Warning: (ae-forgotten-export) The symbol "AppPlatform" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type AppPlatform = AppPlatform;
// Warning: (ae-forgotten-export) The symbol "IosApp" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type IosApp = IosApp;
// Warning: (ae-forgotten-export) The symbol "IosAppMetadata" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type IosAppMetadata = IosAppMetadata;
// Warning: (ae-forgotten-export) The symbol "ProjectManagement" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type ProjectManagement = ProjectManagement;
// Warning: (ae-forgotten-export) The symbol "ShaCertificate" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type ShaCertificate = ShaCertificate;
}

// @public (undocumented)
Expand Down
115 changes: 115 additions & 0 deletions etc/firebase-admin.project-management.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
## API Report File for "firebase-admin.project-management"

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

```ts

import { Agent } from 'http';

// @public (undocumented)
export class AndroidApp {
addShaCertificate(certificateToAdd: ShaCertificate): Promise<void>;
// (undocumented)
readonly appId: string;
deleteShaCertificate(certificateToDelete: ShaCertificate): Promise<void>;
getConfig(): Promise<string>;
getMetadata(): Promise<AndroidAppMetadata>;
getShaCertificates(): Promise<ShaCertificate[]>;
setDisplayName(newDisplayName: string): Promise<void>;
}

// @public
export interface AndroidAppMetadata extends AppMetadata {
packageName: string;
// (undocumented)
platform: AppPlatform.ANDROID;
}

// @public
export interface AppMetadata {
appId: string;
displayName?: string;
platform: AppPlatform;
projectId: string;
resourceName: string;
}

// @public
export enum AppPlatform {
ANDROID = "ANDROID",
IOS = "IOS",
PLATFORM_UNKNOWN = "PLATFORM_UNKNOWN"
}

// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export function getProjectManagement(app?: App): ProjectManagement;

// @public (undocumented)
export class IosApp {
// (undocumented)
readonly appId: string;
getConfig(): Promise<string>;
getMetadata(): Promise<IosAppMetadata>;
setDisplayName(newDisplayName: string): Promise<void>;
}

// @public
export interface IosAppMetadata extends AppMetadata {
bundleId: string;
// (undocumented)
platform: AppPlatform.IOS;
}

// @public
export class ProjectManagement {
androidApp(appId: string): AndroidApp;
// (undocumented)
readonly app: App;
createAndroidApp(packageName: string, displayName?: string): Promise<AndroidApp>;
createIosApp(bundleId: string, displayName?: string): Promise<IosApp>;
iosApp(appId: string): IosApp;
listAndroidApps(): Promise<AndroidApp[]>;
listAppMetadata(): Promise<AppMetadata[]>;
listIosApps(): Promise<IosApp[]>;
setDisplayName(newDisplayName: string): Promise<void>;
shaCertificate(shaHash: string): ShaCertificate;
}

// @public
export function projectManagement(app?: App): projectManagement.ProjectManagement;

// @public (undocumented)
export namespace projectManagement {
// (undocumented)
export type AndroidApp = AndroidApp;
// (undocumented)
export type AndroidAppMetadata = AndroidAppMetadata;
// (undocumented)
export type AppMetadata = AppMetadata;
// (undocumented)
export type AppPlatform = AppPlatform;
// (undocumented)
export type IosApp = IosApp;
// (undocumented)
export type IosAppMetadata = IosAppMetadata;
// (undocumented)
export type ProjectManagement = ProjectManagement;
// (undocumented)
export type ShaCertificate = ShaCertificate;
}

// @public
export class ShaCertificate {
readonly certType: ('sha1' | 'sha256');
// (undocumented)
readonly resourceName?: string | undefined;
// (undocumented)
readonly shaHash: string;
}


// (No @packageDocumentation comment for this package)

```
1 change: 1 addition & 0 deletions generate-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const entryPoints = {
'firebase-admin/firestore': './lib/firestore/index.d.ts',
'firebase-admin/instance-id': './lib/instance-id/index.d.ts',
'firebase-admin/messaging': './lib/messaging/index.d.ts',
'firebase-admin/project-management': './lib/project-management/index.d.ts',
'firebase-admin/security-rules': './lib/security-rules/index.d.ts',
'firebase-admin/remote-config': './lib/remote-config/index.d.ts',
};
Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ gulp.task('compile', function() {
'lib/firestore/*.d.ts',
'lib/instance-id/*.d.ts',
'lib/messaging/*.d.ts',
'lib/project-management/*.d.ts',
'lib/security-rules/*.d.ts',
'lib/remote-config/*.d.ts',
'!lib/utils/index.d.ts',
Expand Down
9 changes: 3 additions & 6 deletions src/app/firebase-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { Storage } from '../storage/storage';
import { Database } from '../database/index';
import { Firestore } from '../firestore/index';
import { InstanceId } from '../instance-id/index';
import { ProjectManagement } from '../project-management/project-management';
import { ProjectManagement } from '../project-management/index';
import { SecurityRules } from '../security-rules/index';
import { RemoteConfig } from '../remote-config/index';

Expand Down Expand Up @@ -343,11 +343,8 @@ export class FirebaseApp implements app.App {
* @return The ProjectManagement service instance of this app.
*/
public projectManagement(): ProjectManagement {
return this.ensureService_('project-management', () => {
const projectManagementService: typeof ProjectManagement =
require('../project-management/project-management').ProjectManagement;
return new projectManagementService(this);
});
const fn = require('../project-management/index').getProjectManagement;
return fn(this);
}

/**
Expand Down
34 changes: 27 additions & 7 deletions src/project-management/android-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,34 @@
import { FirebaseProjectManagementError } from '../utils/error';
import * as validator from '../utils/validator';
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request-internal';
import { projectManagement } from './index';
import { AppMetadata, AppPlatform } from './app-metadata';

import AndroidAppInterface = projectManagement.AndroidApp;
import AndroidAppMetadata = projectManagement.AndroidAppMetadata;
import AppPlatform = projectManagement.AppPlatform;
import ShaCertificateInterface = projectManagement.ShaCertificate;

export class AndroidApp implements AndroidAppInterface {
/**
* Metadata about a Firebase Android App.
*/
export interface AndroidAppMetadata extends AppMetadata {

platform: AppPlatform.ANDROID;

/**
* The canonical package name of the Android App, as would appear in the Google Play Developer
* Console.
*
* @example
* ```javascript
* var packageName = androidAppMetadata.packageName;
* ```
*/
packageName: string;
}

export class AndroidApp {
private readonly resourceName: string;

/**
* @internal
*/
constructor(
public readonly appId: string,
private readonly requestHandler: ProjectManagementRequestHandler) {
Expand Down Expand Up @@ -184,7 +202,7 @@ export class AndroidApp implements AndroidAppInterface {
* Do not call this constructor directly. Instead, use
* [`projectManagement.shaCertificate()`](projectManagement.ProjectManagement#shaCertificate).
*/
export class ShaCertificate implements ShaCertificateInterface {
export class ShaCertificate {
/**
* The SHA certificate type.
*
Expand All @@ -210,6 +228,8 @@ export class ShaCertificate implements ShaCertificateInterface {
* ```javascript
* var resourceName = shaCertificate.resourceName;
* ```
*
* @internal
*/
constructor(public readonly shaHash: string, public readonly resourceName?: string) {
if (/^[a-fA-F0-9]{40}$/.test(shaHash)) {
Expand Down
Loading