Skip to content

Commit 726f2f5

Browse files
authored
Merge 38d8bc5 into 880110b
2 parents 880110b + 38d8bc5 commit 726f2f5

Some content is hidden

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

49 files changed

+4188
-139
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ export function average(field: string | FieldPath): AggregateField<number | null
6868
// @public
6969
export class Bytes {
7070
static fromBase64String(base64: string): Bytes;
71+
static fromJSON(json: object): Bytes;
7172
static fromUint8Array(array: Uint8Array): Bytes;
7273
isEqual(other: Bytes): boolean;
7374
toBase64(): string;
75+
toJSON(): object;
7476
toString(): string;
7577
toUint8Array(): Uint8Array;
7678
}
@@ -135,9 +137,12 @@ export function documentId(): FieldPath;
135137
export class DocumentReference<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> {
136138
readonly converter: FirestoreDataConverter<AppModelType, DbModelType> | null;
137139
readonly firestore: Firestore;
140+
static fromJSON(firestore: Firestore, json: object): DocumentReference;
141+
static fromJSON<NewAppModelType = DocumentData, NewDbModelType extends DocumentData = DocumentData>(firestore: Firestore, json: object, converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
138142
get id(): string;
139143
get parent(): CollectionReference<AppModelType, DbModelType>;
140144
get path(): string;
145+
toJSON(): object;
141146
readonly type = "document";
142147
withConverter<NewAppModelType, NewDbModelType extends DocumentData = DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
143148
withConverter(converter: null): DocumentReference<DocumentData, DocumentData>;
@@ -205,12 +210,14 @@ export type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' |
205210
// @public
206211
export class GeoPoint {
207212
constructor(latitude: number, longitude: number);
213+
static fromJSON(json: object): GeoPoint;
208214
isEqual(other: GeoPoint): boolean;
209215
get latitude(): number;
210216
get longitude(): number;
211217
toJSON(): {
212218
latitude: number;
213219
longitude: number;
220+
type: string;
214221
};
215222
}
216223

@@ -416,6 +423,7 @@ export class Timestamp {
416423
seconds: number,
417424
nanoseconds: number);
418425
static fromDate(date: Date): Timestamp;
426+
static fromJSON(json: object): Timestamp;
419427
static fromMillis(milliseconds: number): Timestamp;
420428
isEqual(other: Timestamp): boolean;
421429
readonly nanoseconds: number;
@@ -425,6 +433,7 @@ export class Timestamp {
425433
toJSON(): {
426434
seconds: number;
427435
nanoseconds: number;
436+
type: string;
428437
};
429438
toMillis(): number;
430439
toString(): string;
@@ -466,8 +475,10 @@ export function vector(values?: number[]): VectorValue;
466475
// @public
467476
export class VectorValue {
468477
/* Excluded from this release type: __constructor */
478+
static fromJSON(json: object): VectorValue;
469479
isEqual(other: VectorValue): boolean;
470480
toArray(): number[];
481+
toJSON(): object;
471482
}
472483

473484
// @public

common/api-review/firestore.api.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ export function average(field: string | FieldPath): AggregateField<number | null
6868
// @public
6969
export class Bytes {
7070
static fromBase64String(base64: string): Bytes;
71+
static fromJSON(json: object): Bytes;
7172
static fromUint8Array(array: Uint8Array): Bytes;
7273
isEqual(other: Bytes): boolean;
7374
toBase64(): string;
75+
toJSON(): object;
7476
toString(): string;
7577
toUint8Array(): Uint8Array;
7678
}
@@ -161,9 +163,12 @@ export function documentId(): FieldPath;
161163
export class DocumentReference<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> {
162164
readonly converter: FirestoreDataConverter<AppModelType, DbModelType> | null;
163165
readonly firestore: Firestore;
166+
static fromJSON(firestore: Firestore, json: object): DocumentReference;
167+
static fromJSON<NewAppModelType = DocumentData, NewDbModelType extends DocumentData = DocumentData>(firestore: Firestore, json: object, converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
164168
get id(): string;
165169
get parent(): CollectionReference<AppModelType, DbModelType>;
166170
get path(): string;
171+
toJSON(): object;
167172
readonly type = "document";
168173
withConverter<NewAppModelType, NewDbModelType extends DocumentData = DocumentData>(converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
169174
withConverter(converter: null): DocumentReference<DocumentData, DocumentData>;
@@ -178,8 +183,15 @@ export class DocumentSnapshot<AppModelType = DocumentData, DbModelType extends D
178183
get id(): string;
179184
readonly metadata: SnapshotMetadata;
180185
get ref(): DocumentReference<AppModelType, DbModelType>;
186+
toJSON(): object;
181187
}
182188

189+
// @public
190+
export function documentSnapshotFromJSON(db: Firestore, json: object): DocumentSnapshot;
191+
192+
// @public
193+
export function documentSnapshotFromJSON<AppModelType, DbModelType extends DocumentData = DocumentData>(db: Firestore, json: object, converter: FirestoreDataConverter<AppModelType, DbModelType>): DocumentSnapshot<AppModelType, DbModelType>;
194+
183195
export { EmulatorMockTokenOptions }
184196

185197
// @public @deprecated
@@ -264,12 +276,14 @@ export interface FirestoreSettings {
264276
// @public
265277
export class GeoPoint {
266278
constructor(latitude: number, longitude: number);
279+
static fromJSON(json: object): GeoPoint;
267280
isEqual(other: GeoPoint): boolean;
268281
get latitude(): number;
269282
get longitude(): number;
270283
toJSON(): {
271284
latitude: number;
272285
longitude: number;
286+
type: string;
273287
};
274288
}
275289

@@ -459,6 +473,46 @@ export function onSnapshot<AppModelType, DbModelType extends DocumentData>(query
459473
// @public
460474
export function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
461475

476+
// @public
477+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
478+
479+
// @public
480+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
481+
482+
// @public
483+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
484+
485+
// @public
486+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
487+
488+
// @public
489+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, observer: {
490+
next: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
491+
error?: (error: FirestoreError) => void;
492+
complete?: () => void;
493+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
494+
495+
// @public
496+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, observer: {
497+
next: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
498+
error?: (error: FirestoreError) => void;
499+
complete?: () => void;
500+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
501+
502+
// @public
503+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: {
504+
next: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
505+
error?: (error: FirestoreError) => void;
506+
complete?: () => void;
507+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
508+
509+
// @public
510+
export function onSnapshotResume<AppModelType, DbModelType extends DocumentData>(firestore: Firestore, snapshotJson: object, options: SnapshotListenOptions, observer: {
511+
next: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
512+
error?: (error: FirestoreError) => void;
513+
complete?: () => void;
514+
}, converter?: FirestoreDataConverter<DbModelType>): Unsubscribe;
515+
462516
// @public
463517
export function onSnapshotsInSync(firestore: Firestore, observer: {
464518
next?: (value: void) => void;
@@ -610,8 +664,15 @@ export class QuerySnapshot<AppModelType = DocumentData, DbModelType extends Docu
610664
readonly metadata: SnapshotMetadata;
611665
readonly query: Query<AppModelType, DbModelType>;
612666
get size(): number;
667+
toJSON(): object;
613668
}
614669

670+
// @public
671+
export function querySnapshotFromJSON(db: Firestore, json: object): QuerySnapshot;
672+
673+
// @public
674+
export function querySnapshotFromJSON<AppModelType, DbModelType extends DocumentData = DocumentData>(db: Firestore, json: object, converter: FirestoreDataConverter<AppModelType, DbModelType>): QuerySnapshot<AppModelType, DbModelType>;
675+
615676
// @public
616677
export class QueryStartAtConstraint extends QueryConstraint {
617678
readonly type: 'startAt' | 'startAfter';
@@ -696,6 +757,7 @@ export class Timestamp {
696757
seconds: number,
697758
nanoseconds: number);
698759
static fromDate(date: Date): Timestamp;
760+
static fromJSON(json: object): Timestamp;
699761
static fromMillis(milliseconds: number): Timestamp;
700762
isEqual(other: Timestamp): boolean;
701763
readonly nanoseconds: number;
@@ -705,6 +767,7 @@ export class Timestamp {
705767
toJSON(): {
706768
seconds: number;
707769
nanoseconds: number;
770+
type: string;
708771
};
709772
toMillis(): number;
710773
toString(): string;
@@ -751,8 +814,10 @@ export function vector(values?: number[]): VectorValue;
751814
// @public
752815
export class VectorValue {
753816
/* Excluded from this release type: __constructor */
817+
static fromJSON(json: object): VectorValue;
754818
isEqual(other: VectorValue): boolean;
755819
toArray(): number[];
820+
toJSON(): object;
756821
}
757822

758823
// @public

docs-devsite/firestore_.bytes.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ export declare class Bytes
2323
| Method | Modifiers | Description |
2424
| --- | --- | --- |
2525
| [fromBase64String(base64)](./firestore_.bytes.md#bytesfrombase64string) | <code>static</code> | Creates a new <code>Bytes</code> object from the given Base64 string, converting it to bytes. |
26+
| [fromJSON(json)](./firestore_.bytes.md#bytesfromjson) | <code>static</code> | Builds a <code>Byes</code> instance from a JSON object created by [Bytes.toJSON()](./firestore_.bytes.md#bytestojson)<!-- -->. |
2627
| [fromUint8Array(array)](./firestore_.bytes.md#bytesfromuint8array) | <code>static</code> | Creates a new <code>Bytes</code> object from the given Uint8Array. |
2728
| [isEqual(other)](./firestore_.bytes.md#bytesisequal) | | Returns true if this <code>Bytes</code> object is equal to the provided one. |
2829
| [toBase64()](./firestore_.bytes.md#bytestobase64) | | Returns the underlying bytes as a Base64-encoded string. |
30+
| [toJSON()](./firestore_.bytes.md#bytestojson) | | Returns a JSON-serializable representation of this <code>Bytes</code> instance. |
2931
| [toString()](./firestore_.bytes.md#bytestostring) | | Returns a string representation of the <code>Bytes</code> object. |
3032
| [toUint8Array()](./firestore_.bytes.md#bytestouint8array) | | Returns the underlying bytes in a new <code>Uint8Array</code>. |
3133

@@ -49,6 +51,28 @@ static fromBase64String(base64: string): Bytes;
4951

5052
[Bytes](./firestore_.bytes.md#bytes_class)
5153

54+
## Bytes.fromJSON()
55+
56+
Builds a `Byes` instance from a JSON object created by [Bytes.toJSON()](./firestore_.bytes.md#bytestojson)<!-- -->.
57+
58+
<b>Signature:</b>
59+
60+
```typescript
61+
static fromJSON(json: object): Bytes;
62+
```
63+
64+
#### Parameters
65+
66+
| Parameter | Type | Description |
67+
| --- | --- | --- |
68+
| json | object | a JSON object represention of a <code>Bytes</code> instance |
69+
70+
<b>Returns:</b>
71+
72+
[Bytes](./firestore_.bytes.md#bytes_class)
73+
74+
an instance of [Bytes](./firestore_.bytes.md#bytes_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs.
75+
5276
## Bytes.fromUint8Array()
5377

5478
Creates a new `Bytes` object from the given Uint8Array.
@@ -106,6 +130,21 @@ string
106130

107131
The Base64-encoded string created from the `Bytes` object.
108132

133+
## Bytes.toJSON()
134+
135+
Returns a JSON-serializable representation of this `Bytes` instance.
136+
137+
<b>Signature:</b>
138+
139+
```typescript
140+
toJSON(): object;
141+
```
142+
<b>Returns:</b>
143+
144+
object
145+
146+
a JSON representation of this object.
147+
109148
## Bytes.toString()
110149

111150
Returns a string representation of the `Bytes` object.

docs-devsite/firestore_.documentreference.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export declare class DocumentReference<AppModelType = DocumentData, DbModelType
3333

3434
| Method | Modifiers | Description |
3535
| --- | --- | --- |
36+
| [fromJSON(firestore, json)](./firestore_.documentreference.md#documentreferencefromjson) | <code>static</code> | Builds a <code>DocumentReference</code> instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson)<!-- -->. |
37+
| [fromJSON(firestore, json, converter)](./firestore_.documentreference.md#documentreferencefromjson) | <code>static</code> | Builds a <code>DocumentReference</code> instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson)<!-- -->. |
38+
| [toJSON()](./firestore_.documentreference.md#documentreferencetojson) | | Returns a JSON-serializable representation of this <code>DocumentReference</code> instance. |
3639
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Applies a custom data converter to this <code>DocumentReference</code>, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc_ee215ad)<!-- -->, [getDoc()](./firestore_lite.md#getdoc_4569087)<!-- -->, etc. with the returned <code>DocumentReference</code> instance, the provided converter will convert between Firestore data of type <code>NewDbModelType</code> and your custom type <code>NewAppModelType</code>. |
3740
| [withConverter(converter)](./firestore_.documentreference.md#documentreferencewithconverter) | | Removes the current converter. |
3841

@@ -96,6 +99,68 @@ The type of this Firestore reference.
9699
readonly type = "document";
97100
```
98101

102+
## DocumentReference.fromJSON()
103+
104+
Builds a `DocumentReference` instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson)<!-- -->.
105+
106+
<b>Signature:</b>
107+
108+
```typescript
109+
static fromJSON(firestore: Firestore, json: object): DocumentReference;
110+
```
111+
112+
#### Parameters
113+
114+
| Parameter | Type | Description |
115+
| --- | --- | --- |
116+
| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance the snapshot should be loaded for. |
117+
| json | object | a JSON object represention of a <code>DocumentReference</code> instance |
118+
119+
<b>Returns:</b>
120+
121+
[DocumentReference](./firestore_.documentreference.md#documentreference_class)
122+
123+
an instance of [DocumentReference](./firestore_.documentreference.md#documentreference_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs.
124+
125+
## DocumentReference.fromJSON()
126+
127+
Builds a `DocumentReference` instance from a JSON object created by [DocumentReference.toJSON()](./firestore_.documentreference.md#documentreferencetojson)<!-- -->.
128+
129+
<b>Signature:</b>
130+
131+
```typescript
132+
static fromJSON<NewAppModelType = DocumentData, NewDbModelType extends DocumentData = DocumentData>(firestore: Firestore, json: object, converter: FirestoreDataConverter<NewAppModelType, NewDbModelType>): DocumentReference<NewAppModelType, NewDbModelType>;
133+
```
134+
135+
#### Parameters
136+
137+
| Parameter | Type | Description |
138+
| --- | --- | --- |
139+
| firestore | [Firestore](./firestore_.firestore.md#firestore_class) | The [Firestore](./firestore_.firestore.md#firestore_class) instance the snapshot should be loaded for. |
140+
| json | object | a JSON object represention of a <code>DocumentReference</code> instance |
141+
| converter | [FirestoreDataConverter](./firestore_.firestoredataconverter.md#firestoredataconverter_interface)<!-- -->&lt;NewAppModelType, NewDbModelType&gt; | Converts objects to and from Firestore. |
142+
143+
<b>Returns:</b>
144+
145+
[DocumentReference](./firestore_.documentreference.md#documentreference_class)<!-- -->&lt;NewAppModelType, NewDbModelType&gt;
146+
147+
an instance of [DocumentReference](./firestore_.documentreference.md#documentreference_class) if the JSON object could be parsed. Throws a [FirestoreError](./firestore_.firestoreerror.md#firestoreerror_class) if an error occurs.
148+
149+
## DocumentReference.toJSON()
150+
151+
Returns a JSON-serializable representation of this `DocumentReference` instance.
152+
153+
<b>Signature:</b>
154+
155+
```typescript
156+
toJSON(): object;
157+
```
158+
<b>Returns:</b>
159+
160+
object
161+
162+
a JSON representation of this object.
163+
99164
## DocumentReference.withConverter()
100165

101166
Applies a custom data converter to this `DocumentReference`<!-- -->, allowing you to use your own custom model objects with Firestore. When you call [setDoc()](./firestore_lite.md#setdoc_ee215ad)<!-- -->, [getDoc()](./firestore_lite.md#getdoc_4569087)<!-- -->, etc. with the returned `DocumentReference` instance, the provided converter will convert between Firestore data of type `NewDbModelType` and your custom type `NewAppModelType`<!-- -->.

docs-devsite/firestore_.documentsnapshot.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export declare class DocumentSnapshot<AppModelType = DocumentData, DbModelType e
4141
| [data(options)](./firestore_.documentsnapshot.md#documentsnapshotdata) | | Retrieves all fields in the document as an <code>Object</code>. Returns <code>undefined</code> if the document doesn't exist.<!-- -->By default, <code>serverTimestamp()</code> values that have not yet been set to their final value will be returned as <code>null</code>. You can override this by passing an options object. |
4242
| [exists()](./firestore_.documentsnapshot.md#documentsnapshotexists) | | Returns whether or not the data exists. True if the document exists. |
4343
| [get(fieldPath, options)](./firestore_.documentsnapshot.md#documentsnapshotget) | | Retrieves the field specified by <code>fieldPath</code>. Returns <code>undefined</code> if the document or field doesn't exist.<!-- -->By default, a <code>serverTimestamp()</code> that has not yet been set to its final value will be returned as <code>null</code>. You can override this by passing an options object. |
44+
| [toJSON()](./firestore_.documentsnapshot.md#documentsnapshottojson) | | Returns a JSON-serializable representation of this <code>DocumentSnapshot</code> instance. |
4445

4546
## DocumentSnapshot.(constructor)
4647

@@ -144,3 +145,18 @@ any
144145

145146
The data at the specified field location or undefined if no such field exists in the document.
146147

148+
## DocumentSnapshot.toJSON()
149+
150+
Returns a JSON-serializable representation of this `DocumentSnapshot` instance.
151+
152+
<b>Signature:</b>
153+
154+
```typescript
155+
toJSON(): object;
156+
```
157+
<b>Returns:</b>
158+
159+
object
160+
161+
a JSON representation of this object.
162+

0 commit comments

Comments
 (0)