Skip to content
Merged
32 changes: 20 additions & 12 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ declare namespace admin.auth {
callbackURL?: string;
enableRequestSigning?: boolean;
}

interface OIDCAuthProviderConfig extends admin.auth.AuthProviderConfig {
clientId: string;
issuer: string;
Expand Down Expand Up @@ -761,14 +761,30 @@ declare namespace admin.projectManagement {
resourceName?: string;
}

interface AndroidAppMetadata {
resourceName: string;
interface AppMetadata {
appId: string;
displayName: string | null;
displayName?: string;
platform: AppPlatform;
projectId: string;
resourceName: string;
}

enum AppPlatform {
PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN',
IOS = 'IOS',
ANDROID = 'ANDROID',
}

interface AndroidAppMetadata extends AppMetadata {
platform: AppPlatform.ANDROID;
packageName: string;
}

interface IosAppMetadata extends AppMetadata {
platform: AppPlatform.IOS;
bundleId: string;
}

interface AndroidApp {
appId: string;

Expand All @@ -780,14 +796,6 @@ declare namespace admin.projectManagement {
getConfig(): Promise<string>;
}

interface IosAppMetadata {
resourceName: string;
appId: string;
displayName: string;
projectId: string;
bundleId: string;
}

interface IosApp {
appId: string;

Expand Down
10 changes: 2 additions & 8 deletions src/project-management/android-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { FirebaseProjectManagementError } from '../utils/error';
import * as validator from '../utils/validator';
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
import { AndroidAppMetadata, AppPlatform } from './app-metadata';

export class AndroidApp {
private readonly resourceName: string;
Expand Down Expand Up @@ -49,6 +50,7 @@ export class AndroidApp {
});

const metadata: AndroidAppMetadata = {
platform: AppPlatform.ANDROID,
resourceName: responseData.name,
appId: responseData.appId,
displayName: responseData.displayName || null,
Expand Down Expand Up @@ -127,14 +129,6 @@ export class AndroidApp {
}
}

export interface AndroidAppMetadata {
readonly resourceName: string;
readonly appId: string;
readonly displayName: string | null;
readonly projectId: string;
readonly packageName: string;
}

export class ShaCertificate {
public readonly certType: ('sha1' | 'sha256');

Expand Down
39 changes: 39 additions & 0 deletions src/project-management/app-metadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
* Copyright 2019 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export enum AppPlatform {
PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN',
IOS = 'IOS',
ANDROID = 'ANDROID',
}

export interface AppMetadata {
readonly appId: string;
readonly displayName?: string;
readonly platform: AppPlatform;
readonly projectId: string;
readonly resourceName: string;
}

export interface AndroidAppMetadata extends AppMetadata {
readonly platform: AppPlatform.ANDROID;
readonly packageName: string;
}

export interface IosAppMetadata extends AppMetadata {
readonly platform: AppPlatform.IOS;
readonly bundleId: string;
}
10 changes: 2 additions & 8 deletions src/project-management/ios-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { FirebaseProjectManagementError } from '../utils/error';
import * as validator from '../utils/validator';
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
import { IosAppMetadata, AppPlatform } from './app-metadata';

export class IosApp {
private readonly resourceName: string;
Expand Down Expand Up @@ -49,6 +50,7 @@ export class IosApp {
});

const metadata: IosAppMetadata = {
platform: AppPlatform.IOS,
resourceName: responseData.name,
appId: responseData.appId,
displayName: responseData.displayName || null,
Expand Down Expand Up @@ -85,11 +87,3 @@ export class IosApp {
});
}
}

export interface IosAppMetadata {
readonly resourceName: string;
readonly appId: string;
readonly displayName: string;
readonly projectId: string;
readonly bundleId: string;
}
17 changes: 17 additions & 0 deletions src/project-management/project-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as validator from '../utils/validator';
import { AndroidApp, ShaCertificate } from './android-app';
import { IosApp } from './ios-app';
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
import { AppMetadata } from './app-metadata';

/**
* Internals of a Project Management instance.
Expand Down Expand Up @@ -147,6 +148,22 @@ export class ProjectManagement implements FirebaseServiceInterface {
});
}

/**
* Lists summary of all apps in the project
*/
public listAppMetadata(): Promise<AppMetadata[]> {
throw new FirebaseProjectManagementError(
'service-unavailable', 'This service is not available');
}

/**
* Update display name of the project
*/
public setDisplayName(displayName: string): Promise<void> {
throw new FirebaseProjectManagementError(
'service-unavailable', 'This service is not available');
}

/**
* Lists up to 100 Firebase apps for a specified platform, associated with this Firebase project.
*/
Expand Down
4 changes: 3 additions & 1 deletion test/unit/project-management/android-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import * as chai from 'chai';
import * as _ from 'lodash';
import * as sinon from 'sinon';
import { FirebaseApp } from '../../../src/firebase-app';
import { AndroidApp, AndroidAppMetadata, ShaCertificate } from '../../../src/project-management/android-app';
import { AndroidApp, ShaCertificate } from '../../../src/project-management/android-app';
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request';
import { deepCopy } from '../../../src/utils/deep-copy';
import { FirebaseProjectManagementError } from '../../../src/utils/error';
import * as mocks from '../../resources/mocks';
import { AndroidAppMetadata, AppPlatform } from '../../../src/project-management/app-metadata';

const expect = chai.expect;

Expand Down Expand Up @@ -89,6 +90,7 @@ describe('AndroidApp', () => {
};

const VALID_ANDROID_APP_METADATA: AndroidAppMetadata = {
platform: AppPlatform.ANDROID,
resourceName: VALID_ANDROID_APP_METADATA_API_RESPONSE.name,
appId: APP_ID,
displayName: VALID_ANDROID_APP_METADATA_API_RESPONSE.displayName,
Expand Down
4 changes: 3 additions & 1 deletion test/unit/project-management/ios-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import * as chai from 'chai';
import * as _ from 'lodash';
import * as sinon from 'sinon';
import { FirebaseApp } from '../../../src/firebase-app';
import { IosApp, IosAppMetadata } from '../../../src/project-management/ios-app';
import { IosApp } from '../../../src/project-management/ios-app';
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request';
import { deepCopy } from '../../../src/utils/deep-copy';
import { FirebaseProjectManagementError } from '../../../src/utils/error';
import * as mocks from '../../resources/mocks';
import { IosAppMetadata, AppPlatform } from '../../../src/project-management/app-metadata';

const expect = chai.expect;

Expand Down Expand Up @@ -88,6 +89,7 @@ describe('IosApp', () => {
};

const VALID_IOS_APP_METADATA: IosAppMetadata = {
platform: AppPlatform.IOS,
resourceName: VALID_IOS_APP_METADATA_API_RESPONSE.name,
appId: APP_ID,
displayName: VALID_IOS_APP_METADATA_API_RESPONSE.displayName,
Expand Down
14 changes: 14 additions & 0 deletions test/unit/project-management/project-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,5 +380,19 @@ describe('ProjectManagement', () => {
return projectManagement.createIosApp(BUNDLE_ID)
.should.eventually.deep.equal(createdIosApp);
});

describe('listAppMetadata', () => {
it('should throw service-unavailable error', () => {
expect(() => projectManagement.listAppMetadata())
.to.throw('This service is not available');
});
});

describe('setDisplayName', () => {
it('should throw service-unavailable error', () => {
expect(() => projectManagement.setDisplayName('new project name'))
.to.throw('This service is not available');
});
});
});
});