Skip to content

Commit 5ee7d4f

Browse files
committed
Address PR comments
1 parent 1b4d1ff commit 5ee7d4f

File tree

10 files changed

+93
-21
lines changed

10 files changed

+93
-21
lines changed

packages-exp/functions-exp/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
},
3838
"devDependencies": {
3939
"@firebase/app-exp": "0.0.800",
40-
"@firebase/messaging": "0.6.16",
41-
"@firebase/util": "0.2.47",
4240
"rollup": "2.7.6",
4341
"rollup-plugin-typescript2": "0.27.0",
4442
"typescript": "3.8.3"
@@ -53,9 +51,11 @@
5351
},
5452
"typings": "dist/index.d.ts",
5553
"dependencies": {
56-
"@firebase/component": "0.1.12",
54+
"@firebase/component": "0.1.13",
5755
"@firebase/functions-types-exp": "0.0.800",
56+
"@firebase/messaging": "0.6.17",
5857
"@firebase/messaging-types": "0.4.5",
58+
"@firebase/util": "0.2.48",
5959
"isomorphic-fetch": "2.2.1",
6060
"tslib": "1.11.1"
6161
},
@@ -65,4 +65,4 @@
6565
],
6666
"reportDir": "./coverage/node"
6767
}
68-
}
68+
}

packages-exp/functions-exp/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { _getProvider } from '@firebase/app-exp';
1919
import { FirebaseApp } from '@firebase/app-types-exp';
20-
import { FUNCTIONS_TYPE } from './config';
20+
import { FUNCTIONS_TYPE } from './constants';
2121

2222
import { Provider } from '@firebase/component';
2323
import {

packages-exp/functions-exp/src/callable.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from '@firebase/auth-interop-types';
3535
import { makeFakeApp, createTestService } from '../test/utils';
3636
import { httpsCallable } from './service';
37+
import { FUNCTIONS_TYPE } from './constants';
3738

3839
// eslint-disable-next-line @typescript-eslint/no-require-imports
3940
export const TEST_PROJECT = require('../../../config/project.json');
@@ -51,7 +52,7 @@ async function expectError(
5152
await promise;
5253
} catch (e) {
5354
failed = true;
54-
expect(e.code).to.equal(code);
55+
expect(e.code).to.equal(`${FUNCTIONS_TYPE}/${code}`);
5556
expect(e.message).to.equal(message);
5657
expect(e.details).to.deep.equal(details);
5758
}

packages-exp/functions-exp/src/config.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ import {
2323
ComponentContainer,
2424
InstanceFactory
2525
} from '@firebase/component';
26-
27-
/**
28-
* Type constant for Firebase Functions.
29-
*/
30-
export const FUNCTIONS_TYPE = 'functions';
26+
import { FUNCTIONS_TYPE } from './constants';
3127

3228
export const DEFAULT_REGION = 'us-central1';
3329

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
* Type constant for Firebase Functions.
20+
*/
21+
export const FUNCTIONS_TYPE = 'functions';

packages-exp/functions-exp/src/error.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { FunctionsErrorCode } from '@firebase/functions-types-exp';
1919
import { decode } from './serializer';
2020
import { HttpResponseBody } from './service';
2121
import { FirebaseError } from '@firebase/util';
22+
import { FUNCTIONS_TYPE } from './constants';
2223

2324
/**
2425
* Standard error codes for different ways a request can fail, as defined by:
@@ -57,14 +58,14 @@ export class FunctionsError extends FirebaseError {
5758
* A standard error code that will be returned to the client. This also
5859
* determines the HTTP status code of the response, as defined in code.proto.
5960
*/
60-
readonly code: FunctionsErrorCode,
61+
code: FunctionsErrorCode,
6162
message?: string,
6263
/**
6364
* Extra data to be converted to JSON and included in the error response.
6465
*/
6566
readonly details?: unknown
6667
) {
67-
super(code, message || '');
68+
super(`${FUNCTIONS_TYPE}/${code}`, message || '');
6869
}
6970
}
7071

packages-exp/functions-exp/src/service.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { FirebaseApp } from '@firebase/app-types-exp';
18+
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
1919
import {
2020
HttpsCallable,
2121
HttpsCallableResult,
@@ -70,7 +70,7 @@ function failAfter(millis: number): Promise<never> {
7070
* The main class for the Firebase Functions SDK.
7171
* @internal
7272
*/
73-
export class FunctionsService {
73+
export class FunctionsService implements _FirebaseService {
7474
readonly contextProvider: ContextProvider;
7575
emulatorOrigin: string | null = null;
7676
cancelAllRequests: Promise<void>;
@@ -95,11 +95,9 @@ export class FunctionsService {
9595
});
9696
}
9797

98-
INTERNAL = {
99-
delete: (): Promise<void> => {
100-
return this.deleteService();
101-
}
102-
};
98+
delete(): Promise<void> {
99+
return this.deleteService();
100+
}
103101

104102
/**
105103
* Returns the URL for a callable with the given name.

packages/util/src/errors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export interface StringLike {
6666
}
6767

6868
export interface ErrorData {
69-
[key: string]: StringLike | undefined;
69+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
70+
[key: string]: any;
7071
}
7172

7273
export interface FirebaseError extends Error, ErrorData {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const { projectRoot } = require('../utils');
19+
const { mapPkgNameToPkgJson } = require('../release/utils/workspace');
20+
const { argv } = require('yargs');
21+
const fs = require('mz/fs');
22+
23+
async function updateField(pkg, fieldName) {
24+
const field = pkg[fieldName];
25+
for (const depName in field) {
26+
if (!depName.includes('@firebase')) continue;
27+
const depJson = await mapPkgNameToPkgJson(depName);
28+
if (!depJson.version) continue;
29+
field[depName] = depJson.version;
30+
}
31+
return { ...pkg, [fieldName]: field };
32+
}
33+
34+
async function updateInternalDepVersions() {
35+
const fileName = argv.file;
36+
if (!fileName) return;
37+
const pkg = require(`${projectRoot}/${fileName}`);
38+
let newPkg = await updateField(pkg, 'devDependencies');
39+
newPkg = await updateField(newPkg, 'dependencies');
40+
await fs.writeFile(
41+
`${projectRoot}/${fileName}`,
42+
JSON.stringify(newPkg, null, 2),
43+
{ encoding: 'utf-8' }
44+
);
45+
}
46+
47+
updateInternalDepVersions();

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,13 @@
897897
dependencies:
898898
semver "^6.2.0"
899899

900+
"@grpc/grpc-js@^1.0.0":
901+
version "1.0.5"
902+
resolved "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.0.5.tgz#09948c0810e62828fdd61455b2eb13d7879888b0"
903+
integrity sha512-Hm+xOiqAhcpT9RYM8lc15dbQD7aQurM7ZU8ulmulepiPlN7iwBXXwP3vSBUimoFoApRqz7pSIisXU8pZaCB4og==
904+
dependencies:
905+
semver "^6.2.0"
906+
900907
"@grpc/proto-loader@^0.5.0", "@grpc/proto-loader@^0.5.1":
901908
version "0.5.4"
902909
resolved "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.4.tgz#038a3820540f621eeb1b05d81fbedfb045e14de0"

0 commit comments

Comments
 (0)