Skip to content

Commit 1aa9bf8

Browse files
Fei v9 main firestore (#5319)
* compile firestore * update typings path * compile firestore compat * lint compat * make test work * get most tests work * build * remove special paths * update firestore-compat pkg json * fix merge issues * Simplify bundles * Prettier * Fix Bundle compile * Fix build * address comments * console build * Fix all tests * Prettier * fix merge issues * fix typo * update paths * app-exp * fix lint * correct path * fix * fix compat lint * fix firestore integration * fix workflow * update dep * Always block on Auth (#5340) * Always block on Auth * Don't block on token if already recevied * fix lint * build firestore * remove memory only tests * fix firebase integration tests * enable more build and tests * add firestore-compat to firebase dep * fix auth compat class * enable auth test * auth package doc * Update API reports Co-authored-by: Sebastian Schmidt <[email protected]> Co-authored-by: Feiyang1 <[email protected]>
1 parent 521ccbf commit 1aa9bf8

File tree

157 files changed

+3772
-4378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+3772
-4378
lines changed

common/api-review/auth.api.md

+824-826
Large diffs are not rendered by default.

common/api-review/firestore-lite.api.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```ts
66

77
import { EmulatorMockTokenOptions } from '@firebase/util';
8-
import { FirebaseApp } from '@firebase/app-exp';
8+
import { FirebaseApp } from '@firebase/app';
99
import { LogLevelString as LogLevel } from '@firebase/logger';
1010

1111
// @public
@@ -104,6 +104,8 @@ export class DocumentSnapshot<T = DocumentData> {
104104
get ref(): DocumentReference<T>;
105105
}
106106

107+
export { EmulatorMockTokenOptions }
108+
107109
// @public
108110
export function endAt(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
109111

common/api-review/firestore.api.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```ts
66

77
import { EmulatorMockTokenOptions } from '@firebase/util';
8-
import { FirebaseApp } from '@firebase/app-exp';
8+
import { FirebaseApp } from '@firebase/app';
99
import { LogLevelString as LogLevel } from '@firebase/logger';
1010

1111
// @public
@@ -125,6 +125,8 @@ export class DocumentSnapshot<T = DocumentData> {
125125
get ref(): DocumentReference<T>;
126126
}
127127

128+
export { EmulatorMockTokenOptions }
129+
128130
// @public
129131
export function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;
130132

integration/firebase/test/namespaceDefinition.json

+1-10
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@
5555
"removeApp": {
5656
"__type": "function"
5757
},
58-
"components": {
59-
"__type": "Map"
60-
},
6158
"ErrorFactory": {
6259
"__type": "function"
6360
},
@@ -223,16 +220,10 @@
223220
"onMessage": {
224221
"__type": "function"
225222
},
226-
"onTokenRefresh": {
227-
"__type": "function"
228-
},
229-
"requestPermission": {
230-
"__type": "function"
231-
},
232223
"deleteToken": {
233224
"__type": "function"
234225
},
235-
"setBackgroundMessageHandler": {
226+
"onBackgroundMessage": {
236227
"__type": "function"
237228
}
238229
}

integration/firestore/firebase_export.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
import firebase from '@firebase/app';
19-
import '@firebase/firestore';
20-
import '@firebase/firestore/bundle';
18+
import firebase from '@firebase/app-compat';
19+
import '@firebase/firestore-compat';
2120
import { FirebaseApp } from '@firebase/app-types';
2221
import { Settings, FirebaseFirestore } from '@firebase/firestore-types';
2322

integration/firestore/firebase_export_memory.ts

-71
This file was deleted.

integration/firestore/gulpfile.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ function copyTests() {
6363
*/
6464
/import\s+\* as firebaseExport\s+from\s+('|")[^\1]+firebase_export\1;?/,
6565
`import * as firebaseExport from '${resolve(
66-
__dirname,
67-
isPersistenceEnabled()
68-
? './firebase_export'
69-
: './firebase_export_memory'
66+
__dirname, './firebase_export'
7067
)}';
7168
7269
if (typeof process === 'undefined') {

integration/firestore/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@firebase/app": "0.6.30",
18-
"@firebase/firestore": "2.4.0",
18+
"@firebase/firestore-compat": "0.0.900",
1919
"@types/mocha": "8.2.3",
2020
"gulp": "4.0.2",
2121
"gulp-filter": "7.0.0",

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
],
2323
"scripts": {
2424
"dev": "lerna run --parallel --scope @firebase/* --scope firebase dev",
25-
"build": "lerna run --scope @firebase/* --scope firebase --ignore @firebase/rules-unit-testing --ignore @firebase/firestore build",
25+
"build": "lerna run --scope @firebase/* --scope firebase --ignore @firebase/rules-unit-testing build",
2626
"build:changed": "ts-node-script scripts/ci-test/build_changed.ts",
2727
"release:prepare": "lerna run --scope @firebase/* add-compat-overloads && lerna run --scope @firebase/* typings:public",
2828
"link:packages": "lerna exec --scope @firebase/* --scope firebase -- yarn link",
2929
"stage:packages": "./scripts/prepublish.sh",
3030
"repl": "node tools/repl.js",
3131
"release": "ts-node-script scripts/release/cli.ts",
3232
"pretest": "node tools/pretest.js",
33-
"test": "lerna run --ignore firebase-repo-scripts-prune-dts --ignore @firebase/rules-unit-testing --ignore @firebase/auth --ignore @firebase/firestore --ignore @firebase/database-compat --ignore firebase-firestore-integration-test --ignore firebase-messaging-integration-test --ignore firebase-namespace-integration-test --concurrency 4 --stream test",
33+
"test": "lerna run --ignore firebase-repo-scripts-prune-dts --ignore @firebase/rules-unit-testing --ignore @firebase/database-compat --ignore firebase-messaging-integration-test --concurrency 4 --stream test",
3434
"test:ci": "lerna run --concurrency 4 test:ci",
3535
"pretest:coverage": "mkdirp coverage",
3636
"ci:coverage": "lcov-result-merger 'packages/**/lcov.info' 'lcov-all.info'",

packages/auth-compat/index.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import {
2424
ComponentType,
2525
InstantiationMode
2626
} from '@firebase/component';
27+
import { FirebaseError } from '@firebase/util';
2728

2829
import * as types from '@firebase/auth-types';
2930
import { name, version } from './package.json';
3031
import { Auth } from './src/auth';
31-
import { Persistence } from './src/persistence';
3232
import { PhoneAuthProvider as CompatAuthProvider } from './src/phone_auth_provider';
3333
import { RecaptchaVerifier as CompatRecaptchaVerifier } from './src/recaptcha_verifier';
3434

@@ -106,11 +106,9 @@ function registerAuthCompat(instance: _FirebaseNamespace): void {
106106
PhoneMultiFactorGenerator: impl.PhoneMultiFactorGenerator,
107107
RecaptchaVerifier: CompatRecaptchaVerifier,
108108
TwitterAuthProvider: impl.TwitterAuthProvider,
109-
Auth: {
110-
Persistence
111-
},
112-
AuthCredential: impl.AuthCredential
113-
// 'Error': fireauth.AuthError
109+
Auth,
110+
AuthCredential: impl.AuthCredential,
111+
Error: FirebaseError
114112
})
115113
.setInstantiationMode(InstantiationMode.LAZY)
116114
.setMultipleInstances(false)

packages/auth-compat/src/auth.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const _assert: typeof exp._assert = exp._assert;
4141
export class Auth
4242
implements compat.FirebaseAuth, Wrapper<exp.Auth>, _FirebaseService
4343
{
44+
static Persistence = Persistence;
4445
readonly _delegate: exp.AuthImpl;
4546

4647
constructor(readonly app: FirebaseApp, provider: Provider<'auth'>) {

packages/auth/index.doc.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Firebase Authentication
3+
*
4+
* @packageDocumentation
5+
*/
6+
17
/**
28
* @license
39
* Copyright 2021 Google LLC

packages/firebase/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
"@firebase/database": "0.11.0",
227227
"@firebase/database-compat": "0.0.900",
228228
"@firebase/firestore": "2.4.0",
229+
"@firebase/firestore-compat": "0.0.900",
229230
"@firebase/functions": "0.6.15",
230231
"@firebase/functions-compat": "0.0.900",
231232
"@firebase/installations": "0.4.32",
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
module.exports = {
19+
extends: '../../config/.eslintrc.js',
20+
parserOptions: {
21+
project: 'tsconfig.json',
22+
// to make vscode-eslint work with monorepo
23+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
24+
tsconfigRootDir: __dirname
25+
},
26+
plugins: ['import'],
27+
rules: {
28+
'no-console': ['error', { allow: ['warn', 'error'] }],
29+
'@typescript-eslint/no-unused-vars': [
30+
'error',
31+
{
32+
varsIgnorePattern: '^_',
33+
args: 'none'
34+
}
35+
],
36+
'import/order': [
37+
'error',
38+
{
39+
'groups': [
40+
'builtin',
41+
'external',
42+
'internal',
43+
'parent',
44+
'sibling',
45+
'index'
46+
],
47+
'newlines-between': 'always',
48+
'alphabetize': { 'order': 'asc', 'caseInsensitive': true }
49+
}
50+
]
51+
},
52+
overrides: [
53+
{
54+
files: ['**/*.d.ts'],
55+
rules: {
56+
'camelcase': 'off',
57+
'import/no-duplicates': 'off',
58+
'@typescript-eslint/no-explicit-any': 'off',
59+
'@typescript-eslint/no-unused-vars': 'off'
60+
}
61+
},
62+
{
63+
files: ['**/*.test.ts', '**/test/**/*.ts'],
64+
rules: {
65+
'@typescript-eslint/no-explicit-any': 'error'
66+
}
67+
},
68+
{
69+
files: ['scripts/*.ts'],
70+
rules: {
71+
'import/no-extraneous-dependencies': 'off',
72+
'@typescript-eslint/no-require-imports': 'off'
73+
}
74+
}
75+
]
76+
};

packages/firestore-compat/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# @firebase/firestore-compat
2+
3+
This is the [Cloud Firestore](https://firebase.google.com/docs/firestore/) component of the
4+
[Firebase JS SDK](https://www.npmjs.com/package/firebase).
5+
6+
**This package is not intended for direct usage, and should only be used via the officially
7+
supported [firebase](https://www.npmjs.com/package/firebase) package.**
8+
9+
If you are developing a Node.js application that requires administrative access to Cloud Firestore,
10+
use the [`@google-cloud/firestore`](https://www.npmjs.com/package/@google-cloud/firestore) Server
11+
SDK with your developer credentials.
12+
13+
## Documentation
14+
15+
For comprehensive documentation please see the [Firebase Reference
16+
Docs][reference-docs].
17+
18+
[reference-docs]: https://firebase.google.com/docs/reference/js/
19+
20+
## Contributing
21+
See [Contributing to the Firebase SDK](../../CONTRIBUTING.md) for general
22+
information about contributing to the firebase-js-sdk repo and
23+
[Contributing to the Cloud Firestore Component](./CONTRIBUTING.md) for
24+
details specific to the Cloud Firestore code and tests.

0 commit comments

Comments
 (0)