@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
@@ -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 { _FirebaseService } from '@firebase/app';
14
15
  import { LogLevelString as LogLevel } from '@firebase/logger';
15
16
  import { SetOptions as SetOptions_2 } from '@firebase/firestore-types';
@@ -43,6 +44,7 @@ declare abstract class AbstractUserDataWriter {
43
44
  *
44
45
  * @param reference - A reference to the collection to add this document to.
45
46
  * @param data - An Object containing the data for the new document.
47
+ * @throws Error - If the provided input is not a valid Firestore document.
46
48
  * @returns A `Promise` resolved with a `DocumentReference` pointing to the
47
49
  * newly created document after it has been written to the backend.
48
50
  */
@@ -274,6 +276,7 @@ declare class ByteString {
274
276
  private constructor();
275
277
  static fromBase64String(base64: string): ByteString;
276
278
  static fromUint8Array(array: Uint8Array): ByteString;
279
+ [Symbol.iterator](): Iterator<number>;
277
280
  toBase64(): string;
278
281
  toUint8Array(): Uint8Array;
279
282
  approximateByteSize(): number;
@@ -637,6 +640,8 @@ declare interface Document_2 {
637
640
  */
638
641
  isUnknownDocument(): boolean;
639
642
  isEqual(other: Document_2 | null | undefined): boolean;
643
+ /** Creates a mutable copy of this document. */
644
+ mutableCopy(): MutableDocument;
640
645
  toString(): string;
641
646
  }
642
647
 
@@ -1062,7 +1067,7 @@ export declare interface FirestoreDataConverter<T> {
1062
1067
  }
1063
1068
 
1064
1069
  /** An error returned by a Firestore operation. */
1065
- export declare class FirestoreError extends Error {
1070
+ export declare class FirestoreError extends FirebaseError {
1066
1071
  /**
1067
1072
  * The backend error code associated with this error.
1068
1073
  */
@@ -1071,8 +1076,6 @@ export declare class FirestoreError extends Error {
1071
1076
  * A custom error description.
1072
1077
  */
1073
1078
  readonly message: string;
1074
- /** The custom name for all FirestoreErrors. */
1075
- readonly name: string;
1076
1079
  /** The stack of the error. */
1077
1080
  readonly stack?: string;
1078
1081
  /** @hideconstructor */
@@ -1087,22 +1090,6 @@ export declare class FirestoreError extends Error {
1087
1090
  message: string);
1088
1091
  }
1089
1092
 
1090
- /**
1091
- * @license
1092
- * Copyright 2017 Google LLC
1093
- *
1094
- * Licensed under the Apache License, Version 2.0 (the "License");
1095
- * you may not use this file except in compliance with the License.
1096
- * You may obtain a copy of the License at
1097
- *
1098
- * http://www.apache.org/licenses/LICENSE-2.0
1099
- *
1100
- * Unless required by applicable law or agreed to in writing, software
1101
- * distributed under the License is distributed on an "AS IS" BASIS,
1102
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1103
- * See the License for the specific language governing permissions and
1104
- * limitations under the License.
1105
- */
1106
1093
  /**
1107
1094
  * The set of Firestore status codes. The codes are the same at the ones
1108
1095
  * exposed by gRPC here:
@@ -1622,6 +1609,71 @@ export { LogLevel }
1622
1609
 
1623
1610
  declare type MapValue = firestoreV1ApiClientInterfaces.MapValue;
1624
1611
 
1612
+ /**
1613
+ * Represents a document in Firestore with a key, version, data and whether it
1614
+ * has local mutations applied to it.
1615
+ *
1616
+ * Documents can transition between states via `convertToFoundDocument()`,
1617
+ * `convertToNoDocument()` and `convertToUnknownDocument()`. If a document does
1618
+ * not transition to one of these states even after all mutations have been
1619
+ * applied, `isValidDocument()` returns false and the document should be removed
1620
+ * from all views.
1621
+ */
1622
+ declare class MutableDocument implements Document_2 {
1623
+ readonly key: DocumentKey;
1624
+ private documentType;
1625
+ version: SnapshotVersion;
1626
+ data: ObjectValue;
1627
+ private documentState;
1628
+ private constructor();
1629
+ /**
1630
+ * Creates a document with no known version or data, but which can serve as
1631
+ * base document for mutations.
1632
+ */
1633
+ static newInvalidDocument(documentKey: DocumentKey): MutableDocument;
1634
+ /**
1635
+ * Creates a new document that is known to exist with the given data at the
1636
+ * given version.
1637
+ */
1638
+ static newFoundDocument(documentKey: DocumentKey, version: SnapshotVersion, value: ObjectValue): MutableDocument;
1639
+ /** Creates a new document that is known to not exist at the given version. */
1640
+ static newNoDocument(documentKey: DocumentKey, version: SnapshotVersion): MutableDocument;
1641
+ /**
1642
+ * Creates a new document that is known to exist at the given version but
1643
+ * whose data is not known (e.g. a document that was updated without a known
1644
+ * base document).
1645
+ */
1646
+ static newUnknownDocument(documentKey: DocumentKey, version: SnapshotVersion): MutableDocument;
1647
+ /**
1648
+ * Changes the document type to indicate that it exists and that its version
1649
+ * and data are known.
1650
+ */
1651
+ convertToFoundDocument(version: SnapshotVersion, value: ObjectValue): MutableDocument;
1652
+ /**
1653
+ * Changes the document type to indicate that it doesn't exist at the given
1654
+ * version.
1655
+ */
1656
+ convertToNoDocument(version: SnapshotVersion): MutableDocument;
1657
+ /**
1658
+ * Changes the document type to indicate that it exists at a given version but
1659
+ * that its data is not known (e.g. a document that was updated without a known
1660
+ * base document).
1661
+ */
1662
+ convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
1663
+ setHasCommittedMutations(): MutableDocument;
1664
+ setHasLocalMutations(): MutableDocument;
1665
+ get hasLocalMutations(): boolean;
1666
+ get hasCommittedMutations(): boolean;
1667
+ get hasPendingWrites(): boolean;
1668
+ isValidDocument(): boolean;
1669
+ isFoundDocument(): boolean;
1670
+ isNoDocument(): boolean;
1671
+ isUnknownDocument(): boolean;
1672
+ isEqual(other: Document_2 | null | undefined): boolean;
1673
+ mutableCopy(): MutableDocument;
1674
+ toString(): string;
1675
+ }
1676
+
1625
1677
  /**
1626
1678
  * A mutation describes a self-contained change to a document. Mutations can
1627
1679
  * create, replace, delete, and update subsets of documents.
@@ -2065,6 +2117,7 @@ declare type ServerTimestampBehavior = 'estimate' | 'previous' | 'none';
2065
2117
  *
2066
2118
  * @param reference - A reference to the document to write.
2067
2119
  * @param data - A map of the fields and values for the document.
2120
+ * @throws Error - If the provided input is not a valid Firestore document.
2068
2121
  * @returns A `Promise` resolved once the data has been successfully written
2069
2122
  * to the backend.
2070
2123
  */
@@ -2083,6 +2136,7 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFie
2083
2136
  * @param reference - A reference to the document to write.
2084
2137
  * @param data - A map of the fields and values for the document.
2085
2138
  * @param options - An object to configure the set behavior.
2139
+ * @throws Error - If the provided input is not a valid Firestore document.
2086
2140
  * @returns A `Promise` resolved once the data has been successfully written
2087
2141
  * to the backend.
2088
2142
  */
@@ -2111,10 +2165,12 @@ export declare function setLogLevel(logLevel: LogLevel): void;
2111
2165
  *
2112
2166
  * @param merge - Changes the behavior of a `setDoc()` call to only replace the
2113
2167
  * values specified in its data argument. Fields omitted from the `setDoc()`
2114
- * call remain untouched.
2168
+ * call remain untouched. If your input sets any field to an empty map, all
2169
+ * nested fields are overwritten.
2115
2170
  * @param mergeFields - Changes the behavior of `setDoc()` calls to only replace
2116
2171
  * the specified field paths. Any field path that is not specified is ignored
2117
- * and remains untouched.
2172
+ * and remains untouched. If your input sets any field to an empty map, all
2173
+ * nested fields are overwritten.
2118
2174
  */
2119
2175
  export declare type SetOptions = {
2120
2176
  readonly merge?: boolean;
@@ -2448,6 +2504,7 @@ export declare class Transaction {
2448
2504
  *
2449
2505
  * @param documentRef - A reference to the document to be set.
2450
2506
  * @param data - An object of the fields and values for the document.
2507
+ * @throws Error - If the provided input is not a valid Firestore document.
2451
2508
  * @returns This `Transaction` instance. Used for chaining method calls.
2452
2509
  */
2453
2510
  set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): this;
@@ -2460,6 +2517,7 @@ export declare class Transaction {
2460
2517
  * @param documentRef - A reference to the document to be set.
2461
2518
  * @param data - An object of the fields and values for the document.
2462
2519
  * @param options - An object to configure the set behavior.
2520
+ * @throws Error - If the provided input is not a valid Firestore document.
2463
2521
  * @returns This `Transaction` instance. Used for chaining method calls.
2464
2522
  */
2465
2523
  set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): this;
@@ -2472,6 +2530,7 @@ export declare class Transaction {
2472
2530
  * @param data - An object containing the fields and values with which to
2473
2531
  * update the document. Fields can contain dots to reference nested fields
2474
2532
  * within the document.
2533
+ * @throws Error - If the provided input is not valid Firestore data.
2475
2534
  * @returns This `Transaction` instance. Used for chaining method calls.
2476
2535
  */
2477
2536
  update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): this;
@@ -2487,6 +2546,7 @@ export declare class Transaction {
2487
2546
  * @param field - The first field to update.
2488
2547
  * @param value - The first value.
2489
2548
  * @param moreFieldsAndValues - Additional key/value pairs.
2549
+ * @throws Error - If the provided input is not valid Firestore data.
2490
2550
  * @returns This `Transaction` instance. Used for chaining method calls.
2491
2551
  */
2492
2552
  update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this;
@@ -2593,6 +2653,7 @@ export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
2593
2653
  * @param data - An object containing the fields and values with which to
2594
2654
  * update the document. Fields can contain dots to reference nested fields
2595
2655
  * within the document.
2656
+ * @throws Error - If the provided input is not valid Firestore data.
2596
2657
  * @returns A `Promise` resolved once the data has been successfully written
2597
2658
  * to the backend.
2598
2659
  */
@@ -2615,6 +2676,7 @@ export declare function updateDoc<T>(reference: DocumentReference<T>, data: Upda
2615
2676
  * @param field - The first field to update.
2616
2677
  * @param value - The first value.
2617
2678
  * @param moreFieldsAndValues - Additional key value pairs.
2679
+ * @throws Error - If the provided input is not valid Firestore data.
2618
2680
  * @returns A `Promise` resolved once the data has been successfully written
2619
2681
  * to the backend.
2620
2682
  */
@@ -2723,6 +2785,7 @@ export declare class WriteBatch {
2723
2785
  * @param documentRef - A reference to the document to be set.
2724
2786
  * @param data - An object of the fields and values for the document.
2725
2787
  * @param options - An object to configure the set behavior.
2788
+ * @throws Error - If the provided input is not a valid Firestore document.
2726
2789
  * @returns This `WriteBatch` instance. Used for chaining method calls.
2727
2790
  */
2728
2791
  set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): WriteBatch;
@@ -2735,6 +2798,7 @@ export declare class WriteBatch {
2735
2798
  * @param data - An object containing the fields and values with which to
2736
2799
  * update the document. Fields can contain dots to reference nested fields
2737
2800
  * within the document.
2801
+ * @throws Error - If the provided input is not valid Firestore data.
2738
2802
  * @returns This `WriteBatch` instance. Used for chaining method calls.
2739
2803
  */
2740
2804
  update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): WriteBatch;
@@ -2750,6 +2814,7 @@ export declare class WriteBatch {
2750
2814
  * @param field - The first field to update.
2751
2815
  * @param value - The first value.
2752
2816
  * @param moreFieldsAndValues - Additional key value pairs.
2817
+ * @throws Error - If the provided input is not valid Firestore data.
2753
2818
  * @returns This `WriteBatch` instance. Used for chaining method calls.
2754
2819
  */
2755
2820
  update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;