@firebase/firestore 3.4.1 → 3.4.2-202205224240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
  3. package/dist/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
  4. package/dist/firestore/src/index/index_byte_encoder.d.ts +14 -0
  5. package/dist/firestore/src/index/ordered_code_writer.d.ts +60 -0
  6. package/dist/firestore/src/lite-api/reference.d.ts +4 -2
  7. package/dist/firestore/src/lite-api/reference_impl.d.ts +5 -0
  8. package/dist/firestore/src/lite-api/transaction.d.ts +4 -0
  9. package/dist/firestore/src/lite-api/write_batch.d.ts +3 -0
  10. package/dist/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
  11. package/dist/firestore/src/model/collections.d.ts +0 -4
  12. package/dist/firestore/src/model/document.d.ts +3 -1
  13. package/dist/firestore/src/model/values.d.ts +3 -0
  14. package/dist/firestore/src/util/byte_string.d.ts +1 -0
  15. package/dist/firestore/src/util/error.d.ts +2 -3
  16. package/dist/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
  17. package/dist/firestore/test/util/helpers.d.ts +1 -0
  18. package/dist/index.d.ts +13 -21
  19. package/dist/index.esm2017.js +2649 -2640
  20. package/dist/index.esm2017.js.map +1 -1
  21. package/dist/index.esm5.js +2640 -2630
  22. package/dist/index.esm5.js.map +1 -1
  23. package/dist/index.node.cjs.js +42 -24
  24. package/dist/index.node.cjs.js.map +1 -1
  25. package/dist/index.node.mjs +43 -25
  26. package/dist/index.node.mjs.map +1 -1
  27. package/dist/index.rn.js +2839 -2830
  28. package/dist/index.rn.js.map +1 -1
  29. package/dist/internal.d.ts +18 -22
  30. package/dist/lite/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
  31. package/dist/lite/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
  32. package/dist/lite/firestore/src/index/index_byte_encoder.d.ts +14 -0
  33. package/dist/lite/firestore/src/index/ordered_code_writer.d.ts +60 -0
  34. package/dist/lite/firestore/src/lite-api/reference.d.ts +4 -2
  35. package/dist/lite/firestore/src/lite-api/reference_impl.d.ts +5 -0
  36. package/dist/lite/firestore/src/lite-api/transaction.d.ts +4 -0
  37. package/dist/lite/firestore/src/lite-api/write_batch.d.ts +3 -0
  38. package/dist/lite/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
  39. package/dist/lite/firestore/src/model/collections.d.ts +0 -4
  40. package/dist/lite/firestore/src/model/document.d.ts +3 -1
  41. package/dist/lite/firestore/src/model/values.d.ts +3 -0
  42. package/dist/lite/firestore/src/util/byte_string.d.ts +1 -0
  43. package/dist/lite/firestore/src/util/error.d.ts +2 -3
  44. package/dist/lite/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
  45. package/dist/lite/firestore/test/util/helpers.d.ts +1 -0
  46. package/dist/lite/index.browser.esm2017.js +1378 -1365
  47. package/dist/lite/index.browser.esm2017.js.map +1 -1
  48. package/dist/lite/index.browser.esm5.js +842 -828
  49. package/dist/lite/index.browser.esm5.js.map +1 -1
  50. package/dist/lite/index.d.ts +18 -21
  51. package/dist/lite/index.node.cjs.js +25 -7
  52. package/dist/lite/index.node.cjs.js.map +1 -1
  53. package/dist/lite/index.node.mjs +26 -8
  54. package/dist/lite/index.node.mjs.map +1 -1
  55. package/dist/lite/index.rn.esm2017.js +849 -836
  56. package/dist/lite/index.rn.esm2017.js.map +1 -1
  57. package/dist/lite/internal.d.ts +86 -21
  58. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +142 -141
  59. package/dist/lite/packages/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
  60. package/dist/lite/packages/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
  61. package/dist/lite/packages/firestore/src/index/index_byte_encoder.d.ts +14 -0
  62. package/dist/lite/packages/firestore/src/index/ordered_code_writer.d.ts +60 -0
  63. package/dist/lite/packages/firestore/src/lite-api/reference.d.ts +4 -2
  64. package/dist/lite/packages/firestore/src/lite-api/reference_impl.d.ts +5 -0
  65. package/dist/lite/packages/firestore/src/lite-api/transaction.d.ts +4 -0
  66. package/dist/lite/packages/firestore/src/lite-api/write_batch.d.ts +3 -0
  67. package/dist/lite/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
  68. package/dist/lite/packages/firestore/src/model/collections.d.ts +0 -4
  69. package/dist/lite/packages/firestore/src/model/document.d.ts +3 -1
  70. package/dist/lite/packages/firestore/src/model/values.d.ts +3 -0
  71. package/dist/lite/packages/firestore/src/util/byte_string.d.ts +1 -0
  72. package/dist/lite/packages/firestore/src/util/error.d.ts +2 -3
  73. package/dist/lite/packages/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
  74. package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -0
  75. package/dist/lite/private.d.ts +85 -21
  76. package/dist/packages/firestore/dist/index.esm2017.d.ts +152 -152
  77. package/dist/packages/firestore/src/index/directional_index_byte_encoder.d.ts +24 -0
  78. package/dist/packages/firestore/src/index/firestore_index_value_writer.d.ts +33 -0
  79. package/dist/packages/firestore/src/index/index_byte_encoder.d.ts +14 -0
  80. package/dist/packages/firestore/src/index/ordered_code_writer.d.ts +60 -0
  81. package/dist/packages/firestore/src/lite-api/reference.d.ts +4 -2
  82. package/dist/packages/firestore/src/lite-api/reference_impl.d.ts +5 -0
  83. package/dist/packages/firestore/src/lite-api/transaction.d.ts +4 -0
  84. package/dist/packages/firestore/src/lite-api/write_batch.d.ts +3 -0
  85. package/dist/packages/firestore/src/local/indexeddb_remote_document_cache.d.ts +5 -0
  86. package/dist/packages/firestore/src/model/collections.d.ts +0 -4
  87. package/dist/packages/firestore/src/model/document.d.ts +3 -1
  88. package/dist/packages/firestore/src/model/values.d.ts +3 -0
  89. package/dist/packages/firestore/src/util/byte_string.d.ts +1 -0
  90. package/dist/packages/firestore/src/util/error.d.ts +2 -3
  91. package/dist/packages/firestore/test/unit/index/ordered_code_writer.test.d.ts +1 -0
  92. package/dist/packages/firestore/test/util/helpers.d.ts +1 -0
  93. package/dist/private.d.ts +17 -22
  94. package/package.json +7 -7
@@ -0,0 +1,24 @@
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
+ import { ByteString } from '../util/byte_string';
18
+ /** An index value encoder. */
19
+ export interface DirectionalIndexByteEncoder {
20
+ writeBytes(value: ByteString): void;
21
+ writeString(value: string): void;
22
+ writeNumber(value: number): void;
23
+ writeInfinity(): void;
24
+ }
@@ -0,0 +1,33 @@
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
+ import { Value } from '../protos/firestore_proto_api';
18
+ import { DirectionalIndexByteEncoder } from './directional_index_byte_encoder';
19
+ /** Firestore index value writer. */
20
+ export declare class FirestoreIndexValueWriter {
21
+ static INSTANCE: FirestoreIndexValueWriter;
22
+ private constructor();
23
+ /** Writes an index value. */
24
+ writeIndexValue(value: Value, encoder: DirectionalIndexByteEncoder): void;
25
+ private writeIndexValueAux;
26
+ private writeIndexString;
27
+ private writeUnlabeledIndexString;
28
+ private writeIndexMap;
29
+ private writeIndexArray;
30
+ private writeIndexEntityRef;
31
+ private writeValueTypeLabel;
32
+ private writeTruncationMarker;
33
+ }
@@ -0,0 +1,14 @@
1
+ import { DirectionalIndexByteEncoder } from './directional_index_byte_encoder';
2
+ /**
3
+ * Implements `DirectionalIndexByteEncoder` using `OrderedCodeWriter` for the
4
+ * actual encoding.
5
+ */
6
+ export declare class IndexByteEncoder {
7
+ private orderedCode;
8
+ private ascending;
9
+ private descending;
10
+ seed(encodedBytes: Uint8Array): void;
11
+ forKind(kind: 'asc' | 'desc'): DirectionalIndexByteEncoder;
12
+ encodedBytes(): Uint8Array;
13
+ reset(): void;
14
+ }
@@ -0,0 +1,60 @@
1
+ import { ByteString } from '../util/byte_string';
2
+ /**
3
+ * Counts the number of zeros in a byte.
4
+ *
5
+ * Visible for testing.
6
+ */
7
+ export declare function numberOfLeadingZerosInByte(x: number): number;
8
+ /**
9
+ * OrderedCodeWriter is a minimal-allocation implementation of the writing
10
+ * behavior defined by the backend.
11
+ *
12
+ * The code is ported from its Java counterpart.
13
+ */
14
+ export declare class OrderedCodeWriter {
15
+ buffer: Uint8Array;
16
+ position: number;
17
+ writeBytesAscending(value: ByteString): void;
18
+ writeBytesDescending(value: ByteString): void;
19
+ /** Writes utf8 bytes into this byte sequence, ascending. */
20
+ writeUtf8Ascending(sequence: string): void;
21
+ /** Writes utf8 bytes into this byte sequence, descending */
22
+ writeUtf8Descending(sequence: string): void;
23
+ writeNumberAscending(val: number): void;
24
+ writeNumberDescending(val: number): void;
25
+ /**
26
+ * Writes the "infinity" byte sequence that sorts after all other byte
27
+ * sequences written in ascending order.
28
+ */
29
+ writeInfinityAscending(): void;
30
+ /**
31
+ * Writes the "infinity" byte sequence that sorts before all other byte
32
+ * sequences written in descending order.
33
+ */
34
+ writeInfinityDescending(): void;
35
+ /**
36
+ * Resets the buffer such that it is the same as when it was newly
37
+ * constructed.
38
+ */
39
+ reset(): void;
40
+ seed(encodedBytes: Uint8Array): void;
41
+ /** Makes a copy of the encoded bytes in this buffer. */
42
+ encodedBytes(): Uint8Array;
43
+ /**
44
+ * Encodes `val` into an encoding so that the order matches the IEEE 754
45
+ * floating-point comparison results with the following exceptions:
46
+ * -0.0 < 0.0
47
+ * all non-NaN < NaN
48
+ * NaN = NaN
49
+ */
50
+ private toOrderedBits;
51
+ /** Writes a single byte ascending to the buffer. */
52
+ private writeByteAscending;
53
+ /** Writes a single byte descending to the buffer. */
54
+ private writeByteDescending;
55
+ private writeSeparatorAscending;
56
+ private writeSeparatorDescending;
57
+ private writeEscapedByteAscending;
58
+ private writeEscapedByteDescending;
59
+ private ensureAvailable;
60
+ }
@@ -61,10 +61,12 @@ export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
61
61
  *
62
62
  * @param merge - Changes the behavior of a `setDoc()` call to only replace the
63
63
  * values specified in its data argument. Fields omitted from the `setDoc()`
64
- * call remain untouched.
64
+ * call remain untouched. If your input sets any field to an empty map, all
65
+ * nested fields are overwritten.
65
66
  * @param mergeFields - Changes the behavior of `setDoc()` calls to only replace
66
67
  * the specified field paths. Any field path that is not specified is ignored
67
- * and remains untouched.
68
+ * and remains untouched. If your input sets any field to an empty map, all
69
+ * nested fields are overwritten.
68
70
  */
69
71
  export declare type SetOptions = {
70
72
  readonly merge?: boolean;
@@ -77,6 +77,7 @@ export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
77
77
  *
78
78
  * @param reference - A reference to the document to write.
79
79
  * @param data - A map of the fields and values for the document.
80
+ * @throws Error - If the provided input is not a valid Firestore document.
80
81
  * @returns A `Promise` resolved once the data has been successfully written
81
82
  * to the backend.
82
83
  */
@@ -94,6 +95,7 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFie
94
95
  * @param reference - A reference to the document to write.
95
96
  * @param data - A map of the fields and values for the document.
96
97
  * @param options - An object to configure the set behavior.
98
+ * @throws Error - If the provided input is not a valid Firestore document.
97
99
  * @returns A `Promise` resolved once the data has been successfully written
98
100
  * to the backend.
99
101
  */
@@ -112,6 +114,7 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: Partial
112
114
  * @param data - An object containing the fields and values with which to
113
115
  * update the document. Fields can contain dots to reference nested fields
114
116
  * within the document.
117
+ * @throws Error - If the provided input is not valid Firestore data.
115
118
  * @returns A `Promise` resolved once the data has been successfully written
116
119
  * to the backend.
117
120
  */
@@ -133,6 +136,7 @@ export declare function updateDoc<T>(reference: DocumentReference<T>, data: Upda
133
136
  * @param field - The first field to update.
134
137
  * @param value - The first value.
135
138
  * @param moreFieldsAndValues - Additional key value pairs.
139
+ * @throws Error - If the provided input is not valid Firestore data.
136
140
  * @returns A `Promise` resolved once the data has been successfully written
137
141
  * to the backend.
138
142
  */
@@ -161,6 +165,7 @@ export declare function deleteDoc(reference: DocumentReference<unknown>): Promis
161
165
  *
162
166
  * @param reference - A reference to the collection to add this document to.
163
167
  * @param data - An Object containing the data for the new document.
168
+ * @throws Error - If the provided input is not a valid Firestore document.
164
169
  * @returns A `Promise` resolved with a `DocumentReference` pointing to the
165
170
  * newly created document after it has been written to the backend.
166
171
  */
@@ -45,6 +45,7 @@ export declare class Transaction {
45
45
  *
46
46
  * @param documentRef - A reference to the document to be set.
47
47
  * @param data - An object of the fields and values for the document.
48
+ * @throws Error - If the provided input is not a valid Firestore document.
48
49
  * @returns This `Transaction` instance. Used for chaining method calls.
49
50
  */
50
51
  set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): this;
@@ -57,6 +58,7 @@ export declare class Transaction {
57
58
  * @param documentRef - A reference to the document to be set.
58
59
  * @param data - An object of the fields and values for the document.
59
60
  * @param options - An object to configure the set behavior.
61
+ * @throws Error - If the provided input is not a valid Firestore document.
60
62
  * @returns This `Transaction` instance. Used for chaining method calls.
61
63
  */
62
64
  set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): this;
@@ -69,6 +71,7 @@ export declare class Transaction {
69
71
  * @param data - An object containing the fields and values with which to
70
72
  * update the document. Fields can contain dots to reference nested fields
71
73
  * within the document.
74
+ * @throws Error - If the provided input is not valid Firestore data.
72
75
  * @returns This `Transaction` instance. Used for chaining method calls.
73
76
  */
74
77
  update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): this;
@@ -84,6 +87,7 @@ export declare class Transaction {
84
87
  * @param field - The first field to update.
85
88
  * @param value - The first value.
86
89
  * @param moreFieldsAndValues - Additional key/value pairs.
90
+ * @throws Error - If the provided input is not valid Firestore data.
87
91
  * @returns This `Transaction` instance. Used for chaining method calls.
88
92
  */
89
93
  update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this;
@@ -53,6 +53,7 @@ export declare class WriteBatch {
53
53
  * @param documentRef - A reference to the document to be set.
54
54
  * @param data - An object of the fields and values for the document.
55
55
  * @param options - An object to configure the set behavior.
56
+ * @throws Error - If the provided input is not a valid Firestore document.
56
57
  * @returns This `WriteBatch` instance. Used for chaining method calls.
57
58
  */
58
59
  set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): WriteBatch;
@@ -65,6 +66,7 @@ export declare class WriteBatch {
65
66
  * @param data - An object containing the fields and values with which to
66
67
  * update the document. Fields can contain dots to reference nested fields
67
68
  * within the document.
69
+ * @throws Error - If the provided input is not valid Firestore data.
68
70
  * @returns This `WriteBatch` instance. Used for chaining method calls.
69
71
  */
70
72
  update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): WriteBatch;
@@ -80,6 +82,7 @@ export declare class WriteBatch {
80
82
  * @param field - The first field to update.
81
83
  * @param value - The first value.
82
84
  * @param moreFieldsAndValues - Additional key value pairs.
85
+ * @throws Error - If the provided input is not valid Firestore data.
83
86
  * @returns This `WriteBatch` instance. Used for chaining method calls.
84
87
  */
85
88
  update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;
@@ -16,11 +16,16 @@
16
16
  */
17
17
  import { SnapshotVersion } from '../core/snapshot_version';
18
18
  import { MutableDocumentMap } from '../model/collections';
19
+ import { MutableDocument } from '../model/document';
19
20
  import { IndexManager } from './index_manager';
20
21
  import { LocalSerializer } from './local_serializer';
21
22
  import { PersistencePromise } from './persistence_promise';
22
23
  import { PersistenceTransaction } from './persistence_transaction';
23
24
  import { RemoteDocumentCache } from './remote_document_cache';
25
+ export interface DocumentSizeEntry {
26
+ document: MutableDocument;
27
+ size: number;
28
+ }
24
29
  export interface IndexedDbRemoteDocumentCache extends RemoteDocumentCache {
25
30
  }
26
31
  /**
@@ -21,10 +21,6 @@ import { SortedSet } from '../util/sorted_set';
21
21
  import { Document, MutableDocument } from './document';
22
22
  import { DocumentKey } from './document_key';
23
23
  /** Miscellaneous collection types / constants. */
24
- export interface DocumentSizeEntry {
25
- document: MutableDocument;
26
- size: number;
27
- }
28
24
  export declare type MutableDocumentMap = SortedMap<DocumentKey, MutableDocument>;
29
25
  export declare function mutableDocumentMap(): MutableDocumentMap;
30
26
  export interface DocumentSizeEntries {
@@ -61,6 +61,8 @@ export interface Document {
61
61
  */
62
62
  isUnknownDocument(): boolean;
63
63
  isEqual(other: Document | null | undefined): boolean;
64
+ /** Creates a mutable copy of this document. */
65
+ mutableCopy(): MutableDocument;
64
66
  toString(): string;
65
67
  }
66
68
  /**
@@ -124,7 +126,7 @@ export declare class MutableDocument implements Document {
124
126
  isNoDocument(): boolean;
125
127
  isUnknownDocument(): boolean;
126
128
  isEqual(other: Document | null | undefined): boolean;
127
- clone(): MutableDocument;
129
+ mutableCopy(): MutableDocument;
128
130
  toString(): string;
129
131
  }
130
132
  /**
@@ -18,6 +18,7 @@ import { DatabaseId } from '../core/database_info';
18
18
  import { ArrayValue, MapValue, Value } from '../protos/firestore_proto_api';
19
19
  import { DocumentKey } from './document_key';
20
20
  import { TypeOrder } from './type_order';
21
+ export declare const MAX_VALUE: Value;
21
22
  /** Extracts the backend's type order for the provided value. */
22
23
  export declare function typeOrder(value: Value): TypeOrder;
23
24
  /** Tests `left` and `right` for equality based on the backend semantics. */
@@ -73,3 +74,5 @@ export declare function isMapValue(value?: Value | null): value is {
73
74
  };
74
75
  /** Creates a deep copy of `source`. */
75
76
  export declare function deepClone(source: Value): Value;
77
+ /** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
78
+ export declare function isMaxValue(value: Value): boolean;
@@ -29,6 +29,7 @@ export declare class ByteString {
29
29
  private constructor();
30
30
  static fromBase64String(base64: string): ByteString;
31
31
  static fromUint8Array(array: Uint8Array): ByteString;
32
+ [Symbol.iterator](): Iterator<number>;
32
33
  toBase64(): string;
33
34
  toUint8Array(): Uint8Array;
34
35
  approximateByteSize(): number;
@@ -14,6 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { FirebaseError } from '@firebase/util';
17
18
  /**
18
19
  * The set of Firestore status codes. The codes are the same at the ones
19
20
  * exposed by gRPC here:
@@ -170,7 +171,7 @@ export declare const Code: {
170
171
  DATA_LOSS: FirestoreErrorCode;
171
172
  };
172
173
  /** An error returned by a Firestore operation. */
173
- export declare class FirestoreError extends Error {
174
+ export declare class FirestoreError extends FirebaseError {
174
175
  /**
175
176
  * The backend error code associated with this error.
176
177
  */
@@ -179,8 +180,6 @@ export declare class FirestoreError extends Error {
179
180
  * A custom error description.
180
181
  */
181
182
  readonly message: string;
182
- /** The custom name for all FirestoreErrors. */
183
- readonly name: string;
184
183
  /** The stack of the error. */
185
184
  readonly stack?: string;
186
185
  /** @hideconstructor */
@@ -71,6 +71,7 @@ export declare function bound(values: Array<[string, {}, firestore.OrderByDirect
71
71
  export declare function query(resourcePath: string, ...constraints: Array<OrderBy | Filter>): Query;
72
72
  export declare function targetData(targetId: TargetId, queryPurpose: TargetPurpose, path: string): TargetData;
73
73
  export declare function noChangeEvent(targetId: number, snapshotVersion: number, resumeToken?: ByteString): RemoteEvent;
74
+ export declare function existenceFilterEvent(targetId: number, count: number, snapshotVersion: number): RemoteEvent;
74
75
  export declare function docAddedRemoteEvent(docOrDocs: MutableDocument | MutableDocument[], updatedInTargets?: TargetId[], removedFromTargets?: TargetId[], activeTargets?: TargetId[]): RemoteEvent;
75
76
  export declare function docUpdateRemoteEvent(doc: MutableDocument, updatedInTargets?: TargetId[], removedFromTargets?: TargetId[], limboTargets?: TargetId[]): RemoteEvent;
76
77
  export declare class TestBundledDocuments {
@@ -10,6 +10,7 @@
10
10
  import { DocumentData as DocumentData_2 } from '@firebase/firestore-types';
11
11
  import { EmulatorMockTokenOptions } from '@firebase/util';
12
12
  import { FirebaseApp } from '@firebase/app';
13
+ import { FirebaseError } from '@firebase/util';
13
14
  import { LogLevelString as LogLevel } from '@firebase/logger';
14
15
  import { SetOptions as SetOptions_2 } from '@firebase/firestore-types';
15
16
 
@@ -26,6 +27,7 @@ import { SetOptions as SetOptions_2 } from '@firebase/firestore-types';
26
27
  *
27
28
  * @param reference - A reference to the collection to add this document to.
28
29
  * @param data - An Object containing the data for the new document.
30
+ * @throws Error - If the provided input is not a valid Firestore document.
29
31
  * @returns A `Promise` resolved with a `DocumentReference` pointing to the
30
32
  * newly created document after it has been written to the backend.
31
33
  */
@@ -574,6 +576,8 @@ declare interface Document_2 {
574
576
  */
575
577
  isUnknownDocument(): boolean;
576
578
  isEqual(other: Document_2 | null | undefined): boolean;
579
+ /** Creates a mutable copy of this document. */
580
+ mutableCopy(): MutableDocument;
577
581
  toString(): string;
578
582
  }
579
583
 
@@ -947,7 +951,7 @@ export declare interface FirestoreDataConverter<T> {
947
951
  }
948
952
 
949
953
  /** An error returned by a Firestore operation. */
950
- export declare class FirestoreError extends Error {
954
+ export declare class FirestoreError extends FirebaseError {
951
955
  /**
952
956
  * The backend error code associated with this error.
953
957
  */
@@ -956,8 +960,6 @@ export declare class FirestoreError extends Error {
956
960
  * A custom error description.
957
961
  */
958
962
  readonly message: string;
959
- /** The custom name for all FirestoreErrors. */
960
- readonly name: string;
961
963
  /** The stack of the error. */
962
964
  readonly stack?: string;
963
965
  /** @hideconstructor */
@@ -972,22 +974,6 @@ export declare class FirestoreError extends Error {
972
974
  message: string);
973
975
  }
974
976
 
975
- /**
976
- * @license
977
- * Copyright 2017 Google LLC
978
- *
979
- * Licensed under the Apache License, Version 2.0 (the "License");
980
- * you may not use this file except in compliance with the License.
981
- * You may obtain a copy of the License at
982
- *
983
- * http://www.apache.org/licenses/LICENSE-2.0
984
- *
985
- * Unless required by applicable law or agreed to in writing, software
986
- * distributed under the License is distributed on an "AS IS" BASIS,
987
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
988
- * See the License for the specific language governing permissions and
989
- * limitations under the License.
990
- */
991
977
  /**
992
978
  * The set of Firestore status codes. The codes are the same at the ones
993
979
  * exposed by gRPC here:
@@ -1507,6 +1493,71 @@ export { LogLevel }
1507
1493
 
1508
1494
  declare type MapValue = firestoreV1ApiClientInterfaces.MapValue;
1509
1495
 
1496
+ /**
1497
+ * Represents a document in Firestore with a key, version, data and whether it
1498
+ * has local mutations applied to it.
1499
+ *
1500
+ * Documents can transition between states via `convertToFoundDocument()`,
1501
+ * `convertToNoDocument()` and `convertToUnknownDocument()`. If a document does
1502
+ * not transition to one of these states even after all mutations have been
1503
+ * applied, `isValidDocument()` returns false and the document should be removed
1504
+ * from all views.
1505
+ */
1506
+ declare class MutableDocument implements Document_2 {
1507
+ readonly key: DocumentKey;
1508
+ private documentType;
1509
+ version: SnapshotVersion;
1510
+ data: ObjectValue;
1511
+ private documentState;
1512
+ private constructor();
1513
+ /**
1514
+ * Creates a document with no known version or data, but which can serve as
1515
+ * base document for mutations.
1516
+ */
1517
+ static newInvalidDocument(documentKey: DocumentKey): MutableDocument;
1518
+ /**
1519
+ * Creates a new document that is known to exist with the given data at the
1520
+ * given version.
1521
+ */
1522
+ static newFoundDocument(documentKey: DocumentKey, version: SnapshotVersion, value: ObjectValue): MutableDocument;
1523
+ /** Creates a new document that is known to not exist at the given version. */
1524
+ static newNoDocument(documentKey: DocumentKey, version: SnapshotVersion): MutableDocument;
1525
+ /**
1526
+ * Creates a new document that is known to exist at the given version but
1527
+ * whose data is not known (e.g. a document that was updated without a known
1528
+ * base document).
1529
+ */
1530
+ static newUnknownDocument(documentKey: DocumentKey, version: SnapshotVersion): MutableDocument;
1531
+ /**
1532
+ * Changes the document type to indicate that it exists and that its version
1533
+ * and data are known.
1534
+ */
1535
+ convertToFoundDocument(version: SnapshotVersion, value: ObjectValue): MutableDocument;
1536
+ /**
1537
+ * Changes the document type to indicate that it doesn't exist at the given
1538
+ * version.
1539
+ */
1540
+ convertToNoDocument(version: SnapshotVersion): MutableDocument;
1541
+ /**
1542
+ * Changes the document type to indicate that it exists at a given version but
1543
+ * that its data is not known (e.g. a document that was updated without a known
1544
+ * base document).
1545
+ */
1546
+ convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
1547
+ setHasCommittedMutations(): MutableDocument;
1548
+ setHasLocalMutations(): MutableDocument;
1549
+ get hasLocalMutations(): boolean;
1550
+ get hasCommittedMutations(): boolean;
1551
+ get hasPendingWrites(): boolean;
1552
+ isValidDocument(): boolean;
1553
+ isFoundDocument(): boolean;
1554
+ isNoDocument(): boolean;
1555
+ isUnknownDocument(): boolean;
1556
+ isEqual(other: Document_2 | null | undefined): boolean;
1557
+ mutableCopy(): MutableDocument;
1558
+ toString(): string;
1559
+ }
1560
+
1510
1561
  /**
1511
1562
  * A mutation describes a self-contained change to a document. Mutations can
1512
1563
  * create, replace, delete, and update subsets of documents.
@@ -1933,6 +1984,7 @@ declare type ServerTimestampBehavior = 'estimate' | 'previous' | 'none';
1933
1984
  *
1934
1985
  * @param reference - A reference to the document to write.
1935
1986
  * @param data - A map of the fields and values for the document.
1987
+ * @throws Error - If the provided input is not a valid Firestore document.
1936
1988
  * @returns A `Promise` resolved once the data has been successfully written
1937
1989
  * to the backend.
1938
1990
  */
@@ -1951,6 +2003,7 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFie
1951
2003
  * @param reference - A reference to the document to write.
1952
2004
  * @param data - A map of the fields and values for the document.
1953
2005
  * @param options - An object to configure the set behavior.
2006
+ * @throws Error - If the provided input is not a valid Firestore document.
1954
2007
  * @returns A `Promise` resolved once the data has been successfully written
1955
2008
  * to the backend.
1956
2009
  */
@@ -1979,10 +2032,12 @@ export declare function setLogLevel(logLevel: LogLevel): void;
1979
2032
  *
1980
2033
  * @param merge - Changes the behavior of a `setDoc()` call to only replace the
1981
2034
  * values specified in its data argument. Fields omitted from the `setDoc()`
1982
- * call remain untouched.
2035
+ * call remain untouched. If your input sets any field to an empty map, all
2036
+ * nested fields are overwritten.
1983
2037
  * @param mergeFields - Changes the behavior of `setDoc()` calls to only replace
1984
2038
  * the specified field paths. Any field path that is not specified is ignored
1985
- * and remains untouched.
2039
+ * and remains untouched. If your input sets any field to an empty map, all
2040
+ * nested fields are overwritten.
1986
2041
  */
1987
2042
  export declare type SetOptions = {
1988
2043
  readonly merge?: boolean;
@@ -2316,6 +2371,7 @@ export declare class Transaction {
2316
2371
  *
2317
2372
  * @param documentRef - A reference to the document to be set.
2318
2373
  * @param data - An object of the fields and values for the document.
2374
+ * @throws Error - If the provided input is not a valid Firestore document.
2319
2375
  * @returns This `Transaction` instance. Used for chaining method calls.
2320
2376
  */
2321
2377
  set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): this;
@@ -2328,6 +2384,7 @@ export declare class Transaction {
2328
2384
  * @param documentRef - A reference to the document to be set.
2329
2385
  * @param data - An object of the fields and values for the document.
2330
2386
  * @param options - An object to configure the set behavior.
2387
+ * @throws Error - If the provided input is not a valid Firestore document.
2331
2388
  * @returns This `Transaction` instance. Used for chaining method calls.
2332
2389
  */
2333
2390
  set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): this;
@@ -2340,6 +2397,7 @@ export declare class Transaction {
2340
2397
  * @param data - An object containing the fields and values with which to
2341
2398
  * update the document. Fields can contain dots to reference nested fields
2342
2399
  * within the document.
2400
+ * @throws Error - If the provided input is not valid Firestore data.
2343
2401
  * @returns This `Transaction` instance. Used for chaining method calls.
2344
2402
  */
2345
2403
  update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): this;
@@ -2355,6 +2413,7 @@ export declare class Transaction {
2355
2413
  * @param field - The first field to update.
2356
2414
  * @param value - The first value.
2357
2415
  * @param moreFieldsAndValues - Additional key/value pairs.
2416
+ * @throws Error - If the provided input is not valid Firestore data.
2358
2417
  * @returns This `Transaction` instance. Used for chaining method calls.
2359
2418
  */
2360
2419
  update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this;
@@ -2461,6 +2520,7 @@ export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
2461
2520
  * @param data - An object containing the fields and values with which to
2462
2521
  * update the document. Fields can contain dots to reference nested fields
2463
2522
  * within the document.
2523
+ * @throws Error - If the provided input is not valid Firestore data.
2464
2524
  * @returns A `Promise` resolved once the data has been successfully written
2465
2525
  * to the backend.
2466
2526
  */
@@ -2483,6 +2543,7 @@ export declare function updateDoc<T>(reference: DocumentReference<T>, data: Upda
2483
2543
  * @param field - The first field to update.
2484
2544
  * @param value - The first value.
2485
2545
  * @param moreFieldsAndValues - Additional key value pairs.
2546
+ * @throws Error - If the provided input is not valid Firestore data.
2486
2547
  * @returns A `Promise` resolved once the data has been successfully written
2487
2548
  * to the backend.
2488
2549
  */
@@ -2591,6 +2652,7 @@ export declare class WriteBatch {
2591
2652
  * @param documentRef - A reference to the document to be set.
2592
2653
  * @param data - An object of the fields and values for the document.
2593
2654
  * @param options - An object to configure the set behavior.
2655
+ * @throws Error - If the provided input is not a valid Firestore document.
2594
2656
  * @returns This `WriteBatch` instance. Used for chaining method calls.
2595
2657
  */
2596
2658
  set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): WriteBatch;
@@ -2603,6 +2665,7 @@ export declare class WriteBatch {
2603
2665
  * @param data - An object containing the fields and values with which to
2604
2666
  * update the document. Fields can contain dots to reference nested fields
2605
2667
  * within the document.
2668
+ * @throws Error - If the provided input is not valid Firestore data.
2606
2669
  * @returns This `WriteBatch` instance. Used for chaining method calls.
2607
2670
  */
2608
2671
  update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): WriteBatch;
@@ -2618,6 +2681,7 @@ export declare class WriteBatch {
2618
2681
  * @param field - The first field to update.
2619
2682
  * @param value - The first value.
2620
2683
  * @param moreFieldsAndValues - Additional key value pairs.
2684
+ * @throws Error - If the provided input is not valid Firestore data.
2621
2685
  * @returns This `WriteBatch` instance. Used for chaining method calls.
2622
2686
  */
2623
2687
  update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;