Skip to content

Commit 1ff2e66

Browse files
authored
Add AppMetadata interface, declared unimplemented methods to ProjectManagement (#541)
* Added AppMetadata type * Declare setDisplayName and listAppMetadata (unimplemented) * Declare listAppMetadata and setDisplayName methods in Project Management class (#12) * Added AppMetadata type * Declare setDisplayName and listAppMetadata (unimplemented) * Update AndroidAppMetadata and IosAppMetadata * Change AppMetadata to interface and displayName to be optional * Rename file to app-metadata.ts and small fixes * Move projectId and resourceName to AppMetadata * Update index.d.ts
1 parent 9e86633 commit 1ff2e66

File tree

8 files changed

+100
-30
lines changed

8 files changed

+100
-30
lines changed

src/index.d.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ declare namespace admin.auth {
243243
callbackURL?: string;
244244
enableRequestSigning?: boolean;
245245
}
246-
246+
247247
interface OIDCAuthProviderConfig extends admin.auth.AuthProviderConfig {
248248
clientId: string;
249249
issuer: string;
@@ -761,14 +761,30 @@ declare namespace admin.projectManagement {
761761
resourceName?: string;
762762
}
763763

764-
interface AndroidAppMetadata {
765-
resourceName: string;
764+
interface AppMetadata {
766765
appId: string;
767-
displayName: string | null;
766+
displayName?: string;
767+
platform: AppPlatform;
768768
projectId: string;
769+
resourceName: string;
770+
}
771+
772+
enum AppPlatform {
773+
PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN',
774+
IOS = 'IOS',
775+
ANDROID = 'ANDROID',
776+
}
777+
778+
interface AndroidAppMetadata extends AppMetadata {
779+
platform: AppPlatform.ANDROID;
769780
packageName: string;
770781
}
771782

783+
interface IosAppMetadata extends AppMetadata {
784+
platform: AppPlatform.IOS;
785+
bundleId: string;
786+
}
787+
772788
interface AndroidApp {
773789
appId: string;
774790

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

783-
interface IosAppMetadata {
784-
resourceName: string;
785-
appId: string;
786-
displayName: string;
787-
projectId: string;
788-
bundleId: string;
789-
}
790-
791799
interface IosApp {
792800
appId: string;
793801

src/project-management/android-app.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { FirebaseProjectManagementError } from '../utils/error';
1818
import * as validator from '../utils/validator';
1919
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
20+
import { AndroidAppMetadata, AppPlatform } from './app-metadata';
2021

2122
export class AndroidApp {
2223
private readonly resourceName: string;
@@ -49,6 +50,7 @@ export class AndroidApp {
4950
});
5051

5152
const metadata: AndroidAppMetadata = {
53+
platform: AppPlatform.ANDROID,
5254
resourceName: responseData.name,
5355
appId: responseData.appId,
5456
displayName: responseData.displayName || null,
@@ -127,14 +129,6 @@ export class AndroidApp {
127129
}
128130
}
129131

130-
export interface AndroidAppMetadata {
131-
readonly resourceName: string;
132-
readonly appId: string;
133-
readonly displayName: string | null;
134-
readonly projectId: string;
135-
readonly packageName: string;
136-
}
137-
138132
export class ShaCertificate {
139133
public readonly certType: ('sha1' | 'sha256');
140134

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*!
2+
* Copyright 2019 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export enum AppPlatform {
18+
PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN',
19+
IOS = 'IOS',
20+
ANDROID = 'ANDROID',
21+
}
22+
23+
export interface AppMetadata {
24+
readonly appId: string;
25+
readonly displayName?: string;
26+
readonly platform: AppPlatform;
27+
readonly projectId: string;
28+
readonly resourceName: string;
29+
}
30+
31+
export interface AndroidAppMetadata extends AppMetadata {
32+
readonly platform: AppPlatform.ANDROID;
33+
readonly packageName: string;
34+
}
35+
36+
export interface IosAppMetadata extends AppMetadata {
37+
readonly platform: AppPlatform.IOS;
38+
readonly bundleId: string;
39+
}

src/project-management/ios-app.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { FirebaseProjectManagementError } from '../utils/error';
1818
import * as validator from '../utils/validator';
1919
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
20+
import { IosAppMetadata, AppPlatform } from './app-metadata';
2021

2122
export class IosApp {
2223
private readonly resourceName: string;
@@ -49,6 +50,7 @@ export class IosApp {
4950
});
5051

5152
const metadata: IosAppMetadata = {
53+
platform: AppPlatform.IOS,
5254
resourceName: responseData.name,
5355
appId: responseData.appId,
5456
displayName: responseData.displayName || null,
@@ -85,11 +87,3 @@ export class IosApp {
8587
});
8688
}
8789
}
88-
89-
export interface IosAppMetadata {
90-
readonly resourceName: string;
91-
readonly appId: string;
92-
readonly displayName: string;
93-
readonly projectId: string;
94-
readonly bundleId: string;
95-
}

src/project-management/project-management.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import * as validator from '../utils/validator';
2222
import { AndroidApp, ShaCertificate } from './android-app';
2323
import { IosApp } from './ios-app';
2424
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
25+
import { AppMetadata } from './app-metadata';
2526

2627
/**
2728
* Internals of a Project Management instance.
@@ -147,6 +148,22 @@ export class ProjectManagement implements FirebaseServiceInterface {
147148
});
148149
}
149150

151+
/**
152+
* Lists summary of all apps in the project
153+
*/
154+
public listAppMetadata(): Promise<AppMetadata[]> {
155+
throw new FirebaseProjectManagementError(
156+
'service-unavailable', 'This service is not available');
157+
}
158+
159+
/**
160+
* Update display name of the project
161+
*/
162+
public setDisplayName(displayName: string): Promise<void> {
163+
throw new FirebaseProjectManagementError(
164+
'service-unavailable', 'This service is not available');
165+
}
166+
150167
/**
151168
* Lists up to 100 Firebase apps for a specified platform, associated with this Firebase project.
152169
*/

test/unit/project-management/android-app.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ import * as chai from 'chai';
2020
import * as _ from 'lodash';
2121
import * as sinon from 'sinon';
2222
import { FirebaseApp } from '../../../src/firebase-app';
23-
import { AndroidApp, AndroidAppMetadata, ShaCertificate } from '../../../src/project-management/android-app';
23+
import { AndroidApp, ShaCertificate } from '../../../src/project-management/android-app';
2424
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request';
2525
import { deepCopy } from '../../../src/utils/deep-copy';
2626
import { FirebaseProjectManagementError } from '../../../src/utils/error';
2727
import * as mocks from '../../resources/mocks';
28+
import { AndroidAppMetadata, AppPlatform } from '../../../src/project-management/app-metadata';
2829

2930
const expect = chai.expect;
3031

@@ -89,6 +90,7 @@ describe('AndroidApp', () => {
8990
};
9091

9192
const VALID_ANDROID_APP_METADATA: AndroidAppMetadata = {
93+
platform: AppPlatform.ANDROID,
9294
resourceName: VALID_ANDROID_APP_METADATA_API_RESPONSE.name,
9395
appId: APP_ID,
9496
displayName: VALID_ANDROID_APP_METADATA_API_RESPONSE.displayName,

test/unit/project-management/ios-app.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ import * as chai from 'chai';
2020
import * as _ from 'lodash';
2121
import * as sinon from 'sinon';
2222
import { FirebaseApp } from '../../../src/firebase-app';
23-
import { IosApp, IosAppMetadata } from '../../../src/project-management/ios-app';
23+
import { IosApp } from '../../../src/project-management/ios-app';
2424
import { ProjectManagementRequestHandler } from '../../../src/project-management/project-management-api-request';
2525
import { deepCopy } from '../../../src/utils/deep-copy';
2626
import { FirebaseProjectManagementError } from '../../../src/utils/error';
2727
import * as mocks from '../../resources/mocks';
28+
import { IosAppMetadata, AppPlatform } from '../../../src/project-management/app-metadata';
2829

2930
const expect = chai.expect;
3031

@@ -88,6 +89,7 @@ describe('IosApp', () => {
8889
};
8990

9091
const VALID_IOS_APP_METADATA: IosAppMetadata = {
92+
platform: AppPlatform.IOS,
9193
resourceName: VALID_IOS_APP_METADATA_API_RESPONSE.name,
9294
appId: APP_ID,
9395
displayName: VALID_IOS_APP_METADATA_API_RESPONSE.displayName,

test/unit/project-management/project-management.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,5 +380,19 @@ describe('ProjectManagement', () => {
380380
return projectManagement.createIosApp(BUNDLE_ID)
381381
.should.eventually.deep.equal(createdIosApp);
382382
});
383+
384+
describe('listAppMetadata', () => {
385+
it('should throw service-unavailable error', () => {
386+
expect(() => projectManagement.listAppMetadata())
387+
.to.throw('This service is not available');
388+
});
389+
});
390+
391+
describe('setDisplayName', () => {
392+
it('should throw service-unavailable error', () => {
393+
expect(() => projectManagement.setDisplayName('new project name'))
394+
.to.throw('This service is not available');
395+
});
396+
});
383397
});
384398
});

0 commit comments

Comments
 (0)