Skip to content

Commit fff6b1b

Browse files
committed
Merge branch 'master' into wuandy/Bundles
2 parents 2e73801 + af0c430 commit fff6b1b

Some content is hidden

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

54 files changed

+2098
-703
lines changed

.changeset/breezy-queens-give.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.changeset/cuddly-rivers-add.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@firebase/messaging": patch
3+
"firebase": patch
4+
---
5+
6+
Fixed an issue where we try to update token for every getToken() call because we don't save the updated token in the IndexedDB.

.changeset/cyan-books-melt.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
---
3+

.changeset/firebsae-messaging.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
Update testing policy. Since this is neither a major nor minor update use an empty changeset.

.changeset/kind-melons-obey.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
---
4+
5+
update codeowner to allow approving changeset changes

.changeset/many-gifts-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
---
4+
5+
Update dependency chalk to v4

.changeset/popular-beds-yell.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
---
3+
---

.changeset/popular-beds-yell2.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
---
3+
---

.changeset/quiet-coats-type.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'firebase': minor
3+
'@firebase/firestore': minor
4+
'@firebase/firestore-types': minor
5+
---
6+
7+
Added support for `set()` with merge options when using `FirestoreDataConverter`.

.changeset/small-ghosts-visit.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"firebase": patch
3+
"@firebase/firestore": patch
4+
---
5+
6+
Removed internal wrapper around our public API that was meant to prevent incorrect SDK usage for JavaScript users, but caused our SDK to stop working in IE11.

.changeset/tall-pots-brush.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.changeset/tame-countries-marry.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
---
3+

.changeset/ten-plants-sort.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.changeset/tricky-rocks-dream.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/CODEOWNERS

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ packages/messaging-types @zwu52 @firebase/jssdk-global-approvers
5555
integration/messaging @zwu52 @firebase/jssdk-global-approvers
5656

5757
# Auth Code
58-
packages/auth @bojeil-google @wti806 @firebase/jssdk-global-approvers
59-
packages/auth-types @bojeil-google @wti806 @firebase/jssdk-global-approvers
58+
packages/auth @bojeil-google @avolkovi @samhorlbeck @scottcrossen @firebase/jssdk-global-approvers
59+
packages/auth-types @bojeil-google @avolkovi @samhorlbeck @scottcrossen @firebase/jssdk-global-approvers
6060

6161
# Testing Code
6262
packages/testing @avolkovi @samhorlbeck @scottcrossen @yuchenshi @firebase/jssdk-global-approvers
@@ -83,3 +83,6 @@ packages/remote-config-types @erikeldridge @firebase/jssdk-global-approvers
8383
# Documentation Changes
8484
packages/firebase/index.d.ts @egilmorez @firebase/jssdk-global-approvers
8585
scripts/docgen/content-sources/ @egilmorez @firebase/jssdk-global-approvers
86+
87+
# Changeset
88+
.changeset @egilmorez @erikeldridge @alikn @zijianjoy @andirayo @avolkovi @samhorlbeck @scottcrossen @yuchenshi @zwu52 @firebase/firestore-js-team @firebase/jssdk-global-approvers

.github/workflows/test-all.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ 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}}
3028
- name: Generate coverage file
3129
run: yarn ci:coverage
3230
- name: Run coverage

.github/workflows/test-changed.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ jobs:
2727
- name: yarn build
2828
run: yarn build
2929
- name: Run tests on changed packages
30-
run: xvfb-run yarn test:changed
31-
env:
32-
FCM_TEST_PROJECT_SERVER_KEY: $${{secrets.FCM_TEST_PROJECT_SERVER_KEY}}
30+
run: xvfb-run yarn test:changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"babel-loader": "8.1.0",
8484
"chai": "4.2.0",
8585
"chai-as-promised": "7.1.1",
86-
"chalk": "3.0.0",
86+
"chalk": "4.1.0",
8787
"child-process-promise": "2.2.1",
8888
"clone": "2.1.2",
8989
"coveralls": "3.1.0",

packages/firebase/index.d.ts

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7859,9 +7859,11 @@ declare namespace firebase.firestore {
78597859
/**
78607860
* Called by the Firestore SDK to convert a custom model object of type T
78617861
* into a plain Javascript object (suitable for writing directly to the
7862-
* Firestore database).
7862+
* Firestore database). To use `set()` with `merge` and `mergeFields`,
7863+
* `toFirestore()` must be defined with `Partial<T>`.
78637864
*/
78647865
toFirestore(modelObject: T): DocumentData;
7866+
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
78657867

78667868
/**
78677869
* Called by the Firestore SDK to convert Firestore data into an object of
@@ -8310,10 +8312,21 @@ declare namespace firebase.firestore {
83108312
*/
83118313
set<T>(
83128314
documentRef: DocumentReference<T>,
8313-
data: T,
8314-
options?: SetOptions
8315+
data: Partial<T>,
8316+
options: SetOptions
83158317
): Transaction;
83168318

8319+
/**
8320+
* Writes to the document referred to by the provided `DocumentReference`.
8321+
* If the document does not exist yet, it will be created. If you pass
8322+
* `SetOptions`, the provided data can be merged into the existing document.
8323+
*
8324+
* @param documentRef A reference to the document to be set.
8325+
* @param data An object of the fields and values for the document.
8326+
* @return This `Transaction` instance. Used for chaining method calls.
8327+
*/
8328+
set<T>(documentRef: DocumentReference<T>, data: T): Transaction;
8329+
83178330
/**
83188331
* Updates fields in the document referred to by the provided
83198332
* `DocumentReference`. The update will fail if applied to a document that
@@ -8384,10 +8397,21 @@ declare namespace firebase.firestore {
83848397
*/
83858398
set<T>(
83868399
documentRef: DocumentReference<T>,
8387-
data: T,
8388-
options?: SetOptions
8400+
data: Partial<T>,
8401+
options: SetOptions
83898402
): WriteBatch;
83908403

8404+
/**
8405+
* Writes to the document referred to by the provided `DocumentReference`.
8406+
* If the document does not exist yet, it will be created. If you pass
8407+
* `SetOptions`, the provided data can be merged into the existing document.
8408+
*
8409+
* @param documentRef A reference to the document to be set.
8410+
* @param data An object of the fields and values for the document.
8411+
* @return This `WriteBatch` instance. Used for chaining method calls.
8412+
*/
8413+
set<T>(documentRef: DocumentReference<T>, data: T): WriteBatch;
8414+
83918415
/**
83928416
* Updates fields in the document referred to by the provided
83938417
* `DocumentReference`. The update will fail if applied to a document that
@@ -8566,7 +8590,18 @@ declare namespace firebase.firestore {
85668590
* @return A Promise resolved once the data has been successfully written
85678591
* to the backend (Note that it won't resolve while you're offline).
85688592
*/
8569-
set(data: T, options?: SetOptions): Promise<void>;
8593+
set(data: Partial<T>, options: SetOptions): Promise<void>;
8594+
8595+
/**
8596+
* Writes to the document referred to by this `DocumentReference`. If the
8597+
* document does not yet exist, it will be created. If you pass
8598+
* `SetOptions`, the provided data can be merged into an existing document.
8599+
*
8600+
* @param data A map of the fields and values for the document.
8601+
* @return A Promise resolved once the data has been successfully written
8602+
* to the backend (Note that it won't resolve while you're offline).
8603+
*/
8604+
set(data: T): Promise<void>;
85708605

85718606
/**
85728607
* Updates fields in the document referred to by this `DocumentReference`.

packages/firestore-types/index.d.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function setLogLevel(logLevel: LogLevel): void;
5050

5151
export interface FirestoreDataConverter<T> {
5252
toFirestore(modelObject: T): DocumentData;
53+
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
5354

5455
fromFirestore(snapshot: QueryDocumentSnapshot, options: SnapshotOptions): T;
5556
}
@@ -146,9 +147,10 @@ export class Transaction {
146147

147148
set<T>(
148149
documentRef: DocumentReference<T>,
149-
data: T,
150-
options?: SetOptions
150+
data: Partial<T>,
151+
options: SetOptions
151152
): Transaction;
153+
set<T>(documentRef: DocumentReference<T>, data: T): Transaction;
152154

153155
update(documentRef: DocumentReference<any>, data: UpdateData): Transaction;
154156
update(
@@ -166,9 +168,10 @@ export class WriteBatch {
166168

167169
set<T>(
168170
documentRef: DocumentReference<T>,
169-
data: T,
170-
options?: SetOptions
171+
data: Partial<T>,
172+
options: SetOptions
171173
): WriteBatch;
174+
set<T>(documentRef: DocumentReference<T>, data: T): WriteBatch;
172175

173176
update(documentRef: DocumentReference<any>, data: UpdateData): WriteBatch;
174177
update(
@@ -208,7 +211,8 @@ export class DocumentReference<T = DocumentData> {
208211

209212
isEqual(other: DocumentReference<T>): boolean;
210213

211-
set(data: T, options?: SetOptions): Promise<void>;
214+
set(data: Partial<T>, options: SetOptions): Promise<void>;
215+
set(data: T): Promise<void>;
212216

213217
update(data: UpdateData): Promise<void>;
214218
update(

packages/firestore/.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ module.exports = {
5959
rules: {
6060
'import/no-extraneous-dependencies': 'off'
6161
}
62+
},
63+
// TODO(firestoreexp): Remove this exception when app-exp is published
64+
{
65+
files: ['exp/**/*.ts'],
66+
rules: {
67+
'import/no-extraneous-dependencies': 'off'
68+
}
6269
}
6370
]
6471
};

packages/firestore/exp/index.d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export function setLogLevel(logLevel: LogLevel): void;
6464

6565
export interface FirestoreDataConverter<T> {
6666
toFirestore(modelObject: T): DocumentData;
67-
fromFirestore(snapshot: QueryDocumentSnapshot): T;
67+
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
68+
fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>): T;
6869
}
6970

7071
export class FirebaseFirestore {
@@ -217,9 +218,10 @@ export class WriteBatch {
217218
commit(): Promise<void>;
218219
}
219220

220-
export type SetOptions =
221-
| { merge: true }
222-
| { mergeFields: Array<string | FieldPath> };
221+
export interface SetOptions {
222+
readonly merge?: boolean;
223+
readonly mergeFields?: Array<string | FieldPath>;
224+
}
223225

224226
export class DocumentReference<T = DocumentData> {
225227
private constructor();
@@ -488,6 +490,6 @@ export interface FirestoreError {
488490

489491
declare module '@firebase/component' {
490492
interface NameServiceMapping {
491-
'firestore/lite': FirebaseFirestore;
493+
'firestore-exp': FirebaseFirestore;
492494
}
493495
}

packages/firestore/exp/index.node.ts

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

18+
import { version } from '../package.json';
19+
import { _registerComponent, registerVersion } from '@firebase/app-exp';
20+
import { Component, ComponentType } from '@firebase/component';
21+
import { Firestore } from './src/api/database';
22+
1823
export { FieldPath, documentId } from '../lite/src/api/field_path';
1924

25+
export {
26+
Firestore,
27+
initializeFirestore,
28+
getFirestore
29+
} from './src/api/database';
30+
31+
export { DocumentSnapshot, QueryDocumentSnapshot } from './src/api/snapshot';
32+
33+
export { SnapshotMetadata } from '../src/api/database';
34+
35+
export {
36+
DocumentReference,
37+
CollectionReference,
38+
Query,
39+
doc,
40+
collection,
41+
collectionGroup,
42+
parent
43+
} from '../lite/src/api/reference';
44+
45+
export { runTransaction, Transaction } from '../lite/src/api/transaction';
46+
47+
export { getDoc, getDocFromCache, getDocFromServer } from './src/api/reference';
48+
2049
export {
2150
FieldValue,
2251
deleteField,
@@ -33,3 +62,24 @@ export { Blob } from '../src/api/blob';
3362
export { GeoPoint } from '../src/api/geo_point';
3463

3564
export { Timestamp } from '../src/api/timestamp';
65+
66+
export { refEqual, queryEqual } from '../lite/src/api/reference';
67+
68+
export function registerFirestore(): void {
69+
_registerComponent(
70+
new Component(
71+
'firestore-exp',
72+
container => {
73+
const app = container.getProvider('app-exp').getImmediate()!;
74+
return ((app, auth) => new Firestore(app, auth))(
75+
app,
76+
container.getProvider('auth-internal')
77+
);
78+
},
79+
ComponentType.PUBLIC
80+
)
81+
);
82+
registerVersion('firestore-exp', version, 'node');
83+
}
84+
85+
registerFirestore();

0 commit comments

Comments
 (0)