Skip to content

Commit 51ad82c

Browse files
Merge
2 parents 871d955 + 9b32270 commit 51ad82c

File tree

35 files changed

+424
-72
lines changed

35 files changed

+424
-72
lines changed

.github/workflows/test-all.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
run: yarn build
2626
- name: Run unit tests
2727
run: xvfb-run yarn test:ci
28+
env:
29+
FCM_TEST_PROJECT_SERVER_KEY: $${{secrets.FCM_TEST_PROJECT_SERVER_KEY}}
2830
- name: Generate coverage file
2931
run: yarn ci:coverage
3032
- name: Run coverage

.github/workflows/test-changed.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
run: yarn build
2929
- name: Run tests on changed packages
3030
run: xvfb-run yarn test:changed
31+
env:
32+
FCM_TEST_PROJECT_SERVER_KEY: $${{secrets.FCM_TEST_PROJECT_SERVER_KEY}}

common/api-review/app-types-exp.api.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export interface FirebaseOptions {
5353
storageBucket?: string;
5454
}
5555

56+
// @internal (undocumented)
57+
export interface _FirebaseService {
58+
// (undocumented)
59+
app: FirebaseApp;
60+
delete(): Promise<void>;
61+
}
62+
5663
// @public (undocumented)
5764
export interface PlatformLoggerService {
5865
// (undocumented)

config/karma.saucelabs.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ const packageConfigs = {
4949
messaging: {
5050
// Messaging currently only supports these browsers.
5151
browsers: ['Chrome_Windows', 'Firefox_Windows', 'Edge_Windows']
52+
},
53+
firestore: {
54+
browsers: [
55+
'Chrome_Windows',
56+
'Firefox_Windows',
57+
'Edge_Windows',
58+
'Safari_macOS'
59+
]
5260
}
5361
};
5462

@@ -170,7 +178,8 @@ module.exports = function(config) {
170178
'packages/polyfill/index.ts': ['webpack', 'sourcemap'],
171179
'**/test/**/*.ts': ['webpack', 'sourcemap'],
172180
'**/*.test.ts': ['webpack', 'sourcemap'],
173-
'packages/firestore/test/**/bootstrap.ts': ['webpack', 'babel'],
181+
// Restore when ready to run Firestore unit tests in IE.
182+
// 'packages/firestore/test/**/bootstrap.ts': ['webpack', 'babel'],
174183
'integration/**/namespace.*': ['webpack', 'babel', 'sourcemap']
175184
},
176185

integration/browserify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:ci": "node ../../scripts/run_tests_in_ci.js"
99
},
1010
"dependencies": {
11-
"firebase": "7.14.5"
11+
"firebase": "7.14.6"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "7.9.6",

integration/firebase-typings/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test:ci": "node ../../scripts/run_tests_in_ci.js"
88
},
99
"dependencies": {
10-
"firebase": "7.14.5"
10+
"firebase": "7.14.6"
1111
},
1212
"devDependencies": {
1313
"typescript": "3.8.3"

integration/messaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:manual": "mocha --exit"
99
},
1010
"dependencies": {
11-
"firebase": "7.14.5"
11+
"firebase": "7.14.6"
1212
},
1313
"devDependencies": {
1414
"chai": "4.2.0",

integration/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test:ci": "node ../../scripts/run_tests_in_ci.js"
88
},
99
"dependencies": {
10-
"firebase": "7.14.5"
10+
"firebase": "7.14.6"
1111
},
1212
"devDependencies": {
1313
"@babel/core": "7.9.6",

integration/webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:ci": "node ../../scripts/run_tests_in_ci.js"
99
},
1010
"dependencies": {
11-
"firebase": "7.14.5"
11+
"firebase": "7.14.6"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "7.9.6",

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"test:changed": "node scripts/run_changed.js",
4141
"test:setup": "node tools/config.js",
4242
"test:saucelabs": "node scripts/run_saucelabs.js",
43-
"test:saucelabs:single": "karma start config/karma.saucelabs.js --single-run",
4443
"docgen:js": "node scripts/docgen/generate-docs.js --api js",
4544
"docgen:node": "node scripts/docgen/generate-docs.js --api node",
4645
"docgen": "yarn docgen:js; yarn docgen:node",

packages-exp/app-types-exp/index.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ export interface PlatformLoggerService {
104104
getPlatformInfoString(): string;
105105
}
106106

107+
/**
108+
* @internal
109+
*/
110+
export interface _FirebaseService {
111+
app: FirebaseApp;
112+
/**
113+
* Delete the service and free it's resources - called from
114+
* {@link @firebase/app-exp#deleteApp | deleteApp()}
115+
*/
116+
delete(): Promise<void>;
117+
}
118+
107119
declare module '@firebase/component' {
108120
interface NameServiceMapping {
109121
'app-exp': FirebaseApp;

packages/firebase/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firebase",
3-
"version": "7.14.5",
3+
"version": "7.14.6",
44
"description": "Firebase JavaScript library for web and Node.js",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"license": "Apache-2.0",
@@ -49,13 +49,13 @@
4949
"@firebase/app-types": "0.6.1",
5050
"@firebase/auth": "0.14.6",
5151
"@firebase/database": "0.6.3",
52-
"@firebase/firestore": "1.14.5",
52+
"@firebase/firestore": "1.14.6",
5353
"@firebase/functions": "0.4.44",
5454
"@firebase/installations": "0.4.10",
5555
"@firebase/messaging": "0.6.16",
5656
"@firebase/polyfill": "0.3.36",
5757
"@firebase/storage": "0.3.34",
58-
"@firebase/performance": "0.3.4",
58+
"@firebase/performance": "0.3.5",
5959
"@firebase/remote-config": "0.1.21",
6060
"@firebase/analytics": "0.3.5",
6161
"@firebase/util": "0.2.47"

packages/firestore-types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/firestore-types",
3-
"version": "1.10.2",
3+
"version": "1.10.3",
44
"description": "@firebase/firestore Types",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"license": "Apache-2.0",

packages/firestore/.eslintrc.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
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+
118
module.exports = {
219
extends: '../../config/.eslintrc.js',
320
parserOptions: {
@@ -35,6 +52,13 @@ module.exports = {
3552
rules: {
3653
'@typescript-eslint/no-explicit-any': 'error'
3754
}
55+
},
56+
// TODO(firestorelite): Remove this exception when app-exp is published
57+
{
58+
files: ['lite/**/*.ts'],
59+
rules: {
60+
'import/no-extraneous-dependencies': 'off'
61+
}
3862
}
3963
]
4064
};

packages/firestore/exp/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export function getQueryFromServer<T>(
327327
export function addDoc<T>(
328328
reference: CollectionReference<T>,
329329
data: T
330-
): Promise<DocumentSnapshot<T>>;
330+
): Promise<DocumentReference<T>>;
331331
export function setDoc<T>(
332332
reference: DocumentReference<T>,
333333
data: T

packages/firestore/karma.conf.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
const karma = require('karma');
19-
const path = require('path');
2018
const karmaBase = require('../../config/karma.base');
2119
const { argv } = require('yargs');
2220

packages/firestore/lite/index.d.ts

Lines changed: 1 addition & 1 deletion
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';
18+
import { FirebaseApp } from '@firebase/app-types-exp';
1919

2020
/* eslint-disable @typescript-eslint/no-explicit-any */
2121

packages/firestore/lite/index.node.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
import { registerVersion, _registerComponent } from '@firebase/app-exp';
19+
import { Firestore } from './src/api/database';
20+
import { version } from '../package.json';
21+
import { Component, ComponentType } from '@firebase/component';
22+
23+
export {
24+
Firestore,
25+
initializeFirestore,
26+
getFirestore
27+
} from './src/api/database';
28+
29+
export function registerFirestore(): void {
30+
_registerComponent(
31+
new Component(
32+
'firestore/lite',
33+
container => {
34+
const app = container.getProvider('app-exp').getImmediate()!;
35+
return ((app, auth) => new Firestore(app, auth))(
36+
app,
37+
container.getProvider('auth-internal')
38+
);
39+
},
40+
ComponentType.PUBLIC
41+
)
42+
);
43+
registerVersion('firestore-lite', version, 'node');
44+
}
45+
46+
registerFirestore();

packages/firestore/lite/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "@firebase/firestore/lite",
3+
"description": "A lite version of the Firestore SDK",
4+
"main": "../dist/lite/index.node.cjs.js",
5+
"private": true
6+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
import * as firestore from '../../';
19+
20+
import { _getProvider } from '@firebase/app-exp';
21+
import { FirebaseApp } from '@firebase/app-types-exp';
22+
import { Provider } from '@firebase/component';
23+
24+
import { Code, FirestoreError } from '../../../src/util/error';
25+
import { DatabaseId } from '../../../src/core/database_info';
26+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
27+
import {
28+
CredentialsProvider,
29+
FirebaseCredentialsProvider
30+
} from '../../../src/api/credentials';
31+
32+
// TODO(firestorelite): Depend on FirebaseService once #3112 is merged
33+
34+
/**
35+
* The root reference to the Firestore Lite database.
36+
*/
37+
export class Firestore implements firestore.FirebaseFirestore {
38+
readonly _databaseId: DatabaseId;
39+
private readonly _firebaseApp: FirebaseApp;
40+
private readonly _credentials: CredentialsProvider;
41+
private _settings?: firestore.Settings;
42+
43+
constructor(
44+
app: FirebaseApp,
45+
authProvider: Provider<FirebaseAuthInternalName>
46+
) {
47+
this._firebaseApp = app;
48+
this._databaseId = Firestore.databaseIdFromApp(app);
49+
this._credentials = new FirebaseCredentialsProvider(authProvider);
50+
}
51+
52+
get app(): FirebaseApp {
53+
return this._firebaseApp;
54+
}
55+
56+
_configureClient(settings: firestore.Settings): void {
57+
if (this._settings) {
58+
throw new FirestoreError(
59+
Code.FAILED_PRECONDITION,
60+
'Firestore has already been started and its settings can no longer ' +
61+
'be changed. initializeFirestore() cannot be called after calling ' +
62+
'getFirestore().'
63+
);
64+
}
65+
this._settings = settings;
66+
}
67+
68+
_ensureClientConfigured(): void {
69+
if (!this._settings) {
70+
this._settings = {};
71+
}
72+
}
73+
74+
private static databaseIdFromApp(app: FirebaseApp): DatabaseId {
75+
if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
76+
throw new FirestoreError(
77+
Code.INVALID_ARGUMENT,
78+
'"projectId" not provided in firebase.initializeApp.'
79+
);
80+
}
81+
82+
return new DatabaseId(app.options.projectId!);
83+
}
84+
}
85+
86+
export function initializeFirestore(
87+
app: FirebaseApp,
88+
settings: firestore.Settings
89+
): Firestore {
90+
const firestore = _getProvider(
91+
app,
92+
'firestore/lite'
93+
).getImmediate() as Firestore;
94+
firestore._configureClient(settings);
95+
return firestore;
96+
}
97+
98+
export function getFirestore(app: FirebaseApp): Firestore {
99+
return _getProvider(app, 'firestore/lite').getImmediate() as Firestore;
100+
}

0 commit comments

Comments
 (0)