From e5ff3ae694a0f3dd46a23ede09daf4ed998b13a6 Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Wed, 22 May 2019 08:44:26 -0400 Subject: [PATCH 1/8] Added AppMetadata type --- src/project-management/AppMetadata.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/project-management/AppMetadata.ts diff --git a/src/project-management/AppMetadata.ts b/src/project-management/AppMetadata.ts new file mode 100644 index 0000000000..2769aa0be0 --- /dev/null +++ b/src/project-management/AppMetadata.ts @@ -0,0 +1,27 @@ +/*! + * 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 class AppMetadata { + public readonly appId: string; + public readonly displayName: string; + public readonly platform: AppPlatform; +} + +export enum AppPlatform { + PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN', + IOS = 'IOS', + ANDROID = 'ANDROID', +} From 6821a150b82e118bd6cefc7e600a5944b300b876 Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Wed, 22 May 2019 09:06:30 -0400 Subject: [PATCH 2/8] Declare setDisplayName and listAppMetadata (unimplemented) --- src/project-management/project-management.ts | 17 +++++++++++++++++ .../project-management.spec.ts | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/project-management/project-management.ts b/src/project-management/project-management.ts index 02123b88a2..0a251c726c 100644 --- a/src/project-management/project-management.ts +++ b/src/project-management/project-management.ts @@ -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 './AppMetadata'; /** * Internals of a Project Management instance. @@ -147,6 +148,22 @@ export class ProjectManagement implements FirebaseServiceInterface { }); } + /** + * Lists summary of all apps in the project + */ + public listAppMetadata(): Promise { + throw new FirebaseProjectManagementError( + 'service-unavailable', 'This service is not available'); + } + + /** + * Update display name of the project + */ + public setDisplayName(displayName: string): Promise { + 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. */ diff --git a/test/unit/project-management/project-management.spec.ts b/test/unit/project-management/project-management.spec.ts index 08ef23d867..3898d06cde 100644 --- a/test/unit/project-management/project-management.spec.ts +++ b/test/unit/project-management/project-management.spec.ts @@ -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'); + }); + }); }); }); From 6feb2c1e7e09202f6fd59b5611f86414b45eeb38 Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Wed, 22 May 2019 11:46:18 -0400 Subject: [PATCH 3/8] Declare listAppMetadata and setDisplayName methods in Project Management class (#12) * Added AppMetadata type * Declare setDisplayName and listAppMetadata (unimplemented) --- src/project-management/AppMetadata.ts | 27 +++++++++++++++++++ src/project-management/project-management.ts | 17 ++++++++++++ .../project-management.spec.ts | 14 ++++++++++ 3 files changed, 58 insertions(+) create mode 100644 src/project-management/AppMetadata.ts diff --git a/src/project-management/AppMetadata.ts b/src/project-management/AppMetadata.ts new file mode 100644 index 0000000000..2769aa0be0 --- /dev/null +++ b/src/project-management/AppMetadata.ts @@ -0,0 +1,27 @@ +/*! + * 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 class AppMetadata { + public readonly appId: string; + public readonly displayName: string; + public readonly platform: AppPlatform; +} + +export enum AppPlatform { + PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN', + IOS = 'IOS', + ANDROID = 'ANDROID', +} diff --git a/src/project-management/project-management.ts b/src/project-management/project-management.ts index 02123b88a2..0a251c726c 100644 --- a/src/project-management/project-management.ts +++ b/src/project-management/project-management.ts @@ -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 './AppMetadata'; /** * Internals of a Project Management instance. @@ -147,6 +148,22 @@ export class ProjectManagement implements FirebaseServiceInterface { }); } + /** + * Lists summary of all apps in the project + */ + public listAppMetadata(): Promise { + throw new FirebaseProjectManagementError( + 'service-unavailable', 'This service is not available'); + } + + /** + * Update display name of the project + */ + public setDisplayName(displayName: string): Promise { + 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. */ diff --git a/test/unit/project-management/project-management.spec.ts b/test/unit/project-management/project-management.spec.ts index 08ef23d867..3898d06cde 100644 --- a/test/unit/project-management/project-management.spec.ts +++ b/test/unit/project-management/project-management.spec.ts @@ -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'); + }); + }); }); }); From 8c103fbf594f01782080d2cca06aa66fcebf7283 Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Wed, 22 May 2019 15:43:40 -0400 Subject: [PATCH 4/8] Update AndroidAppMetadata and IosAppMetadata --- src/index.d.ts | 24 +++++++++++++------ src/project-management/AppMetadata.ts | 14 +++++++++++ src/project-management/android-app.ts | 10 ++------ src/project-management/ios-app.ts | 10 ++------ .../project-management/android-app.spec.ts | 4 +++- test/unit/project-management/ios-app.spec.ts | 4 +++- 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index f02bc45c03..f997298815 100755 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -243,7 +243,7 @@ declare namespace admin.auth { callbackURL?: string; enableRequestSigning?: boolean; } - + interface OIDCAuthProviderConfig extends admin.auth.AuthProviderConfig { clientId: string; issuer: string; @@ -761,10 +761,21 @@ declare namespace admin.projectManagement { resourceName?: string; } - interface AndroidAppMetadata { + class AppMetadata { + public appId: string; + public displayName: string; + public platform: AppPlatform; + } + + enum AppPlatform { + PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN', + IOS = 'IOS', + ANDROID = 'ANDROID', + } + + interface AndroidAppMetadata extends AppMetadata { + platform: AppPlatform.ANDROID; resourceName: string; - appId: string; - displayName: string | null; projectId: string; packageName: string; } @@ -780,10 +791,9 @@ declare namespace admin.projectManagement { getConfig(): Promise; } - interface IosAppMetadata { + interface IosAppMetadata extends AppMetadata { + platform: AppPlatform.IOS; resourceName: string; - appId: string; - displayName: string; projectId: string; bundleId: string; } diff --git a/src/project-management/AppMetadata.ts b/src/project-management/AppMetadata.ts index 2769aa0be0..9ace2dc8fd 100644 --- a/src/project-management/AppMetadata.ts +++ b/src/project-management/AppMetadata.ts @@ -25,3 +25,17 @@ export enum AppPlatform { IOS = 'IOS', ANDROID = 'ANDROID', } + +export interface AndroidAppMetadata extends AppMetadata { + readonly platform: AppPlatform.ANDROID; + readonly resourceName: string; + readonly projectId: string; + readonly packageName: string; +} + +export interface IosAppMetadata extends AppMetadata { + readonly platform: AppPlatform.IOS; + readonly resourceName: string; + readonly projectId: string; + readonly bundleId: string; +} diff --git a/src/project-management/android-app.ts b/src/project-management/android-app.ts index 0a9eeb0771..521b3e9037 100644 --- a/src/project-management/android-app.ts +++ b/src/project-management/android-app.ts @@ -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 './AppMetadata'; export class AndroidApp { private readonly resourceName: string; @@ -49,6 +50,7 @@ export class AndroidApp { }); const metadata: AndroidAppMetadata = { + platform: AppPlatform.ANDROID, resourceName: responseData.name, appId: responseData.appId, displayName: responseData.displayName || null, @@ -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'); diff --git a/src/project-management/ios-app.ts b/src/project-management/ios-app.ts index 35af3a3a17..95c50e065d 100644 --- a/src/project-management/ios-app.ts +++ b/src/project-management/ios-app.ts @@ -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 './AppMetadata'; export class IosApp { private readonly resourceName: string; @@ -49,6 +50,7 @@ export class IosApp { }); const metadata: IosAppMetadata = { + platform: AppPlatform.IOS, resourceName: responseData.name, appId: responseData.appId, displayName: responseData.displayName || null, @@ -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; -} diff --git a/test/unit/project-management/android-app.spec.ts b/test/unit/project-management/android-app.spec.ts index b6022ffcbc..794f996fb7 100644 --- a/test/unit/project-management/android-app.spec.ts +++ b/test/unit/project-management/android-app.spec.ts @@ -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/AppMetadata'; const expect = chai.expect; @@ -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, diff --git a/test/unit/project-management/ios-app.spec.ts b/test/unit/project-management/ios-app.spec.ts index 2aaa343dd9..48a7de09dc 100644 --- a/test/unit/project-management/ios-app.spec.ts +++ b/test/unit/project-management/ios-app.spec.ts @@ -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/AppMetadata'; const expect = chai.expect; @@ -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, From 78944dc2a63562ce53a60f40e254ce19cc652b4c Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Thu, 23 May 2019 08:40:08 -0400 Subject: [PATCH 5/8] Change AppMetadata to interface and displayName to be optional --- src/index.d.ts | 8 ++++---- src/project-management/AppMetadata.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index f997298815..68f37980ce 100755 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -761,10 +761,10 @@ declare namespace admin.projectManagement { resourceName?: string; } - class AppMetadata { - public appId: string; - public displayName: string; - public platform: AppPlatform; + interface AppMetadata { + appId: string; + displayName?: string; + platform: AppPlatform; } enum AppPlatform { diff --git a/src/project-management/AppMetadata.ts b/src/project-management/AppMetadata.ts index 9ace2dc8fd..611833c876 100644 --- a/src/project-management/AppMetadata.ts +++ b/src/project-management/AppMetadata.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -export class AppMetadata { - public readonly appId: string; - public readonly displayName: string; - public readonly platform: AppPlatform; +export interface AppMetadata { + readonly appId: string; + readonly displayName: string; + readonly platform: AppPlatform; } export enum AppPlatform { From 3f886aabaf7bcea45df79f6cbd4382831b0fb4cc Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Wed, 29 May 2019 09:07:22 -0400 Subject: [PATCH 6/8] Rename file to app-metadata.ts and small fixes --- src/project-management/android-app.ts | 2 +- .../{AppMetadata.ts => app-metadata.ts} | 12 ++++++------ src/project-management/ios-app.ts | 2 +- src/project-management/project-management.ts | 2 +- test/unit/project-management/android-app.spec.ts | 2 +- test/unit/project-management/ios-app.spec.ts | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename src/project-management/{AppMetadata.ts => app-metadata.ts} (100%) diff --git a/src/project-management/android-app.ts b/src/project-management/android-app.ts index 521b3e9037..f05f7e851c 100644 --- a/src/project-management/android-app.ts +++ b/src/project-management/android-app.ts @@ -17,7 +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 './AppMetadata'; +import { AndroidAppMetadata, AppPlatform } from './app-metadata'; export class AndroidApp { private readonly resourceName: string; diff --git a/src/project-management/AppMetadata.ts b/src/project-management/app-metadata.ts similarity index 100% rename from src/project-management/AppMetadata.ts rename to src/project-management/app-metadata.ts index 611833c876..ad4e39f9f4 100644 --- a/src/project-management/AppMetadata.ts +++ b/src/project-management/app-metadata.ts @@ -14,18 +14,18 @@ * limitations under the License. */ -export interface AppMetadata { - readonly appId: string; - readonly displayName: string; - readonly platform: AppPlatform; -} - export enum AppPlatform { PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN', IOS = 'IOS', ANDROID = 'ANDROID', } +export interface AppMetadata { + readonly appId: string; + readonly displayName: string; + readonly platform: AppPlatform; +} + export interface AndroidAppMetadata extends AppMetadata { readonly platform: AppPlatform.ANDROID; readonly resourceName: string; diff --git a/src/project-management/ios-app.ts b/src/project-management/ios-app.ts index 95c50e065d..f9b553d6df 100644 --- a/src/project-management/ios-app.ts +++ b/src/project-management/ios-app.ts @@ -17,7 +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 './AppMetadata'; +import { IosAppMetadata, AppPlatform } from './app-metadata'; export class IosApp { private readonly resourceName: string; diff --git a/src/project-management/project-management.ts b/src/project-management/project-management.ts index 0a251c726c..808d404d01 100644 --- a/src/project-management/project-management.ts +++ b/src/project-management/project-management.ts @@ -22,7 +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 './AppMetadata'; +import { AppMetadata } from './app-metadata'; /** * Internals of a Project Management instance. diff --git a/test/unit/project-management/android-app.spec.ts b/test/unit/project-management/android-app.spec.ts index 794f996fb7..ac429fa6d5 100644 --- a/test/unit/project-management/android-app.spec.ts +++ b/test/unit/project-management/android-app.spec.ts @@ -25,7 +25,7 @@ import { ProjectManagementRequestHandler } from '../../../src/project-management 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/AppMetadata'; +import { AndroidAppMetadata, AppPlatform } from '../../../src/project-management/app-metadata'; const expect = chai.expect; diff --git a/test/unit/project-management/ios-app.spec.ts b/test/unit/project-management/ios-app.spec.ts index 48a7de09dc..ab0be5b033 100644 --- a/test/unit/project-management/ios-app.spec.ts +++ b/test/unit/project-management/ios-app.spec.ts @@ -25,7 +25,7 @@ import { ProjectManagementRequestHandler } from '../../../src/project-management 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/AppMetadata'; +import { IosAppMetadata, AppPlatform } from '../../../src/project-management/app-metadata'; const expect = chai.expect; From cb8e90ba92645b6ced1e7554377e6d88d8caa586 Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Thu, 30 May 2019 14:54:55 -0400 Subject: [PATCH 7/8] Move projectId and resourceName to AppMetadata --- src/project-management/app-metadata.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/project-management/app-metadata.ts b/src/project-management/app-metadata.ts index ad4e39f9f4..4e7ff71bce 100644 --- a/src/project-management/app-metadata.ts +++ b/src/project-management/app-metadata.ts @@ -22,20 +22,18 @@ export enum AppPlatform { export interface AppMetadata { readonly appId: string; - readonly displayName: string; + readonly displayName?: string; readonly platform: AppPlatform; + readonly projectId: string; + readonly resourceName: string; } export interface AndroidAppMetadata extends AppMetadata { readonly platform: AppPlatform.ANDROID; - readonly resourceName: string; - readonly projectId: string; readonly packageName: string; } export interface IosAppMetadata extends AppMetadata { readonly platform: AppPlatform.IOS; - readonly resourceName: string; - readonly projectId: string; readonly bundleId: string; } From b9bf6311cbeab618755d8111546223c215e878ef Mon Sep 17 00:00:00 2001 From: Tri Cao Date: Thu, 30 May 2019 14:56:23 -0400 Subject: [PATCH 8/8] Update index.d.ts --- src/index.d.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 68f37980ce..7eb23f6d8e 100755 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -765,6 +765,8 @@ declare namespace admin.projectManagement { appId: string; displayName?: string; platform: AppPlatform; + projectId: string; + resourceName: string; } enum AppPlatform { @@ -775,11 +777,14 @@ declare namespace admin.projectManagement { interface AndroidAppMetadata extends AppMetadata { platform: AppPlatform.ANDROID; - resourceName: string; - projectId: string; packageName: string; } + interface IosAppMetadata extends AppMetadata { + platform: AppPlatform.IOS; + bundleId: string; + } + interface AndroidApp { appId: string; @@ -791,13 +796,6 @@ declare namespace admin.projectManagement { getConfig(): Promise; } - interface IosAppMetadata extends AppMetadata { - platform: AppPlatform.IOS; - resourceName: string; - projectId: string; - bundleId: string; - } - interface IosApp { appId: string;