@firebase/firestore 3.5.0 → 3.6.0

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 (106) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/firestore/lite/index.d.ts +2 -0
  3. package/dist/firestore/src/api/aggregate.d.ts +43 -0
  4. package/dist/firestore/src/api/database.d.ts +15 -15
  5. package/dist/firestore/src/api.d.ts +2 -0
  6. package/dist/firestore/src/core/count_query_runner.d.ts +32 -0
  7. package/dist/firestore/src/core/firestore_client.d.ts +5 -0
  8. package/dist/firestore/src/lite-api/aggregate.d.ts +48 -0
  9. package/dist/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  10. package/dist/firestore/src/lite-api/database.d.ts +7 -7
  11. package/dist/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  12. package/dist/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  13. package/dist/firestore/src/remote/connection.d.ts +7 -0
  14. package/dist/firestore/src/remote/datastore.d.ts +2 -0
  15. package/dist/firestore/src/remote/rest_connection.d.ts +1 -0
  16. package/dist/firestore/src/remote/serializer.d.ts +2 -1
  17. package/dist/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  18. package/dist/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  19. package/dist/firestore/test/integration/util/helpers.d.ts +1 -0
  20. package/dist/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  21. package/dist/index.d.ts +196 -14
  22. package/dist/index.esm2017.js +4616 -4413
  23. package/dist/index.esm2017.js.map +1 -1
  24. package/dist/index.esm5.js +4608 -4402
  25. package/dist/index.esm5.js.map +1 -1
  26. package/dist/index.node.cjs.js +994 -613
  27. package/dist/index.node.cjs.js.map +1 -1
  28. package/dist/index.node.mjs +992 -615
  29. package/dist/index.node.mjs.map +1 -1
  30. package/dist/index.rn.js +4622 -4419
  31. package/dist/index.rn.js.map +1 -1
  32. package/dist/internal.d.ts +139 -17
  33. package/dist/lite/firestore/lite/index.d.ts +2 -0
  34. package/dist/lite/firestore/src/api/aggregate.d.ts +43 -0
  35. package/dist/lite/firestore/src/api/database.d.ts +15 -15
  36. package/dist/lite/firestore/src/api.d.ts +2 -0
  37. package/dist/lite/firestore/src/core/count_query_runner.d.ts +32 -0
  38. package/dist/lite/firestore/src/core/firestore_client.d.ts +5 -0
  39. package/dist/lite/firestore/src/lite-api/aggregate.d.ts +48 -0
  40. package/dist/lite/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  41. package/dist/lite/firestore/src/lite-api/database.d.ts +7 -7
  42. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  43. package/dist/lite/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  44. package/dist/lite/firestore/src/remote/connection.d.ts +7 -0
  45. package/dist/lite/firestore/src/remote/datastore.d.ts +2 -0
  46. package/dist/lite/firestore/src/remote/rest_connection.d.ts +1 -0
  47. package/dist/lite/firestore/src/remote/serializer.d.ts +2 -1
  48. package/dist/lite/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  49. package/dist/lite/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  50. package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -0
  51. package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  52. package/dist/lite/index.browser.esm2017.js +1250 -1086
  53. package/dist/lite/index.browser.esm2017.js.map +1 -1
  54. package/dist/lite/index.browser.esm5.js +1394 -1232
  55. package/dist/lite/index.browser.esm5.js.map +1 -1
  56. package/dist/lite/index.d.ts +84 -4
  57. package/dist/lite/index.node.cjs.js +255 -63
  58. package/dist/lite/index.node.cjs.js.map +1 -1
  59. package/dist/lite/index.node.mjs +253 -65
  60. package/dist/lite/index.node.mjs.map +1 -1
  61. package/dist/lite/index.rn.esm2017.js +1257 -1093
  62. package/dist/lite/index.rn.esm2017.js.map +1 -1
  63. package/dist/lite/internal.d.ts +121 -6
  64. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +227 -142
  65. package/dist/lite/packages/firestore/lite/index.d.ts +2 -0
  66. package/dist/lite/packages/firestore/src/api/aggregate.d.ts +43 -0
  67. package/dist/lite/packages/firestore/src/api/database.d.ts +15 -15
  68. package/dist/lite/packages/firestore/src/api.d.ts +2 -0
  69. package/dist/lite/packages/firestore/src/core/count_query_runner.d.ts +32 -0
  70. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +5 -0
  71. package/dist/lite/packages/firestore/src/lite-api/aggregate.d.ts +48 -0
  72. package/dist/lite/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  73. package/dist/lite/packages/firestore/src/lite-api/database.d.ts +7 -7
  74. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  75. package/dist/lite/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  76. package/dist/lite/packages/firestore/src/remote/connection.d.ts +7 -0
  77. package/dist/lite/packages/firestore/src/remote/datastore.d.ts +2 -0
  78. package/dist/lite/packages/firestore/src/remote/rest_connection.d.ts +1 -0
  79. package/dist/lite/packages/firestore/src/remote/serializer.d.ts +2 -1
  80. package/dist/lite/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  81. package/dist/lite/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  82. package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  83. package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  84. package/dist/lite/private.d.ts +119 -4
  85. package/dist/packages/firestore/dist/index.esm2017.d.ts +336 -254
  86. package/dist/packages/firestore/lite/index.d.ts +2 -0
  87. package/dist/packages/firestore/src/api/aggregate.d.ts +43 -0
  88. package/dist/packages/firestore/src/api/database.d.ts +15 -15
  89. package/dist/packages/firestore/src/api.d.ts +2 -0
  90. package/dist/packages/firestore/src/core/count_query_runner.d.ts +32 -0
  91. package/dist/packages/firestore/src/core/firestore_client.d.ts +5 -0
  92. package/dist/packages/firestore/src/lite-api/aggregate.d.ts +48 -0
  93. package/dist/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  94. package/dist/packages/firestore/src/lite-api/database.d.ts +7 -7
  95. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  96. package/dist/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  97. package/dist/packages/firestore/src/remote/connection.d.ts +7 -0
  98. package/dist/packages/firestore/src/remote/datastore.d.ts +2 -0
  99. package/dist/packages/firestore/src/remote/rest_connection.d.ts +1 -0
  100. package/dist/packages/firestore/src/remote/serializer.d.ts +2 -1
  101. package/dist/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  102. package/dist/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  103. package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  104. package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  105. package/dist/private.d.ts +234 -19
  106. package/package.json +6 -6
package/dist/index.d.ts CHANGED
@@ -26,6 +26,69 @@ export declare function addDoc<T>(reference: CollectionReference<T>, data: WithF
26
26
  export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
27
27
  [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
28
28
  };
29
+ /**
30
+ * Represents an aggregation that can be performed by Firestore.
31
+ */
32
+ export declare class AggregateField<T> {
33
+ /** A type string to uniquely identify instances of this class. */
34
+ type: string;
35
+ }
36
+ /**
37
+ * The union of all `AggregateField` types that are supported by Firestore.
38
+ */
39
+ export declare type AggregateFieldType = AggregateField<number>;
40
+ /**
41
+ * The results of executing an aggregation query.
42
+ */
43
+ export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
44
+ /** A type string to uniquely identify instances of this class. */
45
+ readonly type = "AggregateQuerySnapshot";
46
+ /**
47
+ * The underlying query over which the aggregations recorded in this
48
+ * `AggregateQuerySnapshot` were performed.
49
+ */
50
+ readonly query: Query<unknown>;
51
+ private constructor();
52
+ /**
53
+ * Returns the results of the aggregations performed over the underlying
54
+ * query.
55
+ *
56
+ * The keys of the returned object will be the same as those of the
57
+ * `AggregateSpec` object specified to the aggregation method, and the values
58
+ * will be the corresponding aggregation result.
59
+ *
60
+ * @returns The results of the aggregations performed over the underlying
61
+ * query.
62
+ */
63
+ data(): AggregateSpecData<T>;
64
+ }
65
+ /**
66
+ * Compares two `AggregateQuerySnapshot` instances for equality.
67
+ *
68
+ * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
69
+ * underlying queries that compare equal, and the same data.
70
+ *
71
+ * @param left - The first `AggregateQuerySnapshot` to compare.
72
+ * @param right - The second `AggregateQuerySnapshot` to compare.
73
+ *
74
+ * @returns `true` if the objects are "equal", as defined above, or `false`
75
+ * otherwise.
76
+ */
77
+ export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
78
+ /**
79
+ * A type whose property values are all `AggregateField` objects.
80
+ */
81
+ export declare interface AggregateSpec {
82
+ [field: string]: AggregateFieldType;
83
+ }
84
+ /**
85
+ * A type whose keys are taken from an `AggregateSpec`, and whose values are the
86
+ * result of the aggregation performed by the corresponding `AggregateField`
87
+ * from the input `AggregateSpec`.
88
+ */
89
+ export declare type AggregateSpecData<T extends AggregateSpec> = {
90
+ [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
91
+ };
29
92
  /**
30
93
  * Returns a special value that can be used with {@link (setDoc:1)} or {@link
31
94
  * updateDoc:1} that tells the server to remove the given elements from any
@@ -120,7 +183,7 @@ export declare type ChildUpdateFields<K extends string, V> = V extends Record<st
120
183
  * Must be called while the {@link Firestore} instance is not started (after the app is
121
184
  * terminated or when the app is first initialized). On startup, this function
122
185
  * must be called before other functions (other than {@link
123
- * initializeFirestore} or {@link getFirestore})). If the {@link Firestore}
186
+ * initializeFirestore} or {@link (getFirestore:1)})). If the {@link Firestore}
124
187
  * instance is still running, the promise will be rejected with the error code
125
188
  * of `failed-precondition`.
126
189
  *
@@ -464,7 +527,7 @@ export { EmulatorMockTokenOptions };
464
527
  * Attempts to enable persistent storage, if possible.
465
528
  *
466
529
  * Must be called before any other functions (other than
467
- * {@link initializeFirestore}, {@link getFirestore} or
530
+ * {@link initializeFirestore}, {@link (getFirestore:1)} or
468
531
  * {@link clearIndexedDbPersistence}.
469
532
  *
470
533
  * If this fails, `enableIndexedDbPersistence()` will reject the promise it
@@ -591,7 +654,7 @@ export declare abstract class FieldValue {
591
654
  /**
592
655
  * The Cloud Firestore service interface.
593
656
  *
594
- * Do not call this constructor directly. Instead, use {@link getFirestore}.
657
+ * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
595
658
  */
596
659
  export declare class Firestore {
597
660
  /**
@@ -845,6 +908,30 @@ export declare class GeoPoint {
845
908
  longitude: number;
846
909
  };
847
910
  }
911
+ /**
912
+ * Calculates the number of documents in the result set of the given query,
913
+ * without actually downloading the documents.
914
+ *
915
+ * Using this function to count the documents is efficient because only the
916
+ * final count, not the documents' data, is downloaded. This function can even
917
+ * count the documents if the result set would be prohibitively large to
918
+ * download entirely (e.g. thousands of documents).
919
+ *
920
+ * The result received from the server is presented, unaltered, without
921
+ * considering any local state. That is, documents in the local cache are not
922
+ * taken into consideration, neither are local modifications not yet
923
+ * synchronized with the server. Previously-downloaded results, if any, are not
924
+ * used: every request using this source necessarily involves a round trip to
925
+ * the server.
926
+ *
927
+ * @param query - The query whose result set size to calculate.
928
+ * @returns A Promise that will be resolved with the count; the count can be
929
+ * retrieved from `snapshot.data().count`, where `snapshot` is the
930
+ * `AggregateQuerySnapshot` to which the returned Promise resolves.
931
+ */
932
+ export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
933
+ count: AggregateField<number>;
934
+ }>>;
848
935
  /**
849
936
  * Reads the document referred to by this `DocumentReference`.
850
937
  *
@@ -901,23 +988,23 @@ export declare function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnaps
901
988
  export declare function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
902
989
  /**
903
990
  * Returns the existing default {@link Firestore} instance that is associated with the
904
- * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
991
+ * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
905
992
  * instance with default settings.
906
993
  *
994
+ * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
995
+ * instance is associated with.
907
996
  * @returns The {@link Firestore} instance of the provided app.
908
997
  */
909
- export declare function getFirestore(): Firestore;
998
+ export declare function getFirestore(app: FirebaseApp): Firestore;
999
+ /* Excluded declaration from this release type: getFirestore */
910
1000
  /**
911
1001
  * Returns the existing default {@link Firestore} instance that is associated with the
912
- * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
1002
+ * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
913
1003
  * instance with default settings.
914
1004
  *
915
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
916
- * instance is associated with.
917
1005
  * @returns The {@link Firestore} instance of the provided app.
918
1006
  */
919
- export declare function getFirestore(app: FirebaseApp): Firestore;
920
- /* Excluded declaration from this release type: getFirestore */
1007
+ export declare function getFirestore(): Firestore;
921
1008
  /* Excluded declaration from this release type: getFirestore */
922
1009
  /**
923
1010
  * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
@@ -939,11 +1026,57 @@ export declare function getFirestore(app: FirebaseApp): Firestore;
939
1026
  * `updateDoc()`
940
1027
  */
941
1028
  export declare function increment(n: number): FieldValue;
1029
+ /**
1030
+ * The SDK definition of a Firestore index.
1031
+ * @beta
1032
+ */
1033
+ export declare interface Index {
1034
+ /** The ID of the collection to index. */
1035
+ readonly collectionGroup: string;
1036
+ /** A list of fields to index. */
1037
+ readonly fields?: IndexField[];
1038
+ [key: string]: unknown;
1039
+ }
1040
+ /**
1041
+ * A list of Firestore indexes to speed up local query execution.
1042
+ *
1043
+ * See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
1044
+ * for a description of the format of the index definition.
1045
+ * @beta
1046
+ */
1047
+ export declare interface IndexConfiguration {
1048
+ /** A list of all Firestore indexes. */
1049
+ readonly indexes?: Index[];
1050
+ [key: string]: unknown;
1051
+ }
1052
+ /**
1053
+ * A single field element in an index configuration.
1054
+ * @beta
1055
+ */
1056
+ export declare interface IndexField {
1057
+ /** The field path to index. */
1058
+ readonly fieldPath: string;
1059
+ /**
1060
+ * What type of array index to create. Set to `CONTAINS` for `array-contains`
1061
+ * and `array-contains-any` indexes.
1062
+ *
1063
+ * Only one of `arrayConfig` or `order` should be set;
1064
+ */
1065
+ readonly arrayConfig?: 'CONTAINS';
1066
+ /**
1067
+ * What type of array index to create. Set to `ASCENDING` or 'DESCENDING` for
1068
+ * `==`, `!=`, `<=`, `<=`, `in` and `not-in` filters.
1069
+ *
1070
+ * Only one of `arrayConfig` or `order` should be set.
1071
+ */
1072
+ readonly order?: 'ASCENDING' | 'DESCENDING';
1073
+ [key: string]: unknown;
1074
+ }
942
1075
  /**
943
1076
  * Initializes a new instance of {@link Firestore} with the provided settings.
944
1077
  * Can only be called before any other function, including
945
- * {@link getFirestore}. If the custom settings are empty, this function is
946
- * equivalent to calling {@link getFirestore}.
1078
+ * {@link (getFirestore:1)}. If the custom settings are empty, this function is
1079
+ * equivalent to calling {@link (getFirestore:1)}.
947
1080
  *
948
1081
  * @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
949
1082
  * be associated.
@@ -1482,7 +1615,56 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFie
1482
1615
  * to the backend (note that it won't resolve while you're offline).
1483
1616
  */
1484
1617
  export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
1485
- /* Excluded from this release type: setIndexConfiguration */
1618
+ /**
1619
+ * Configures indexing for local query execution. Any previous index
1620
+ * configuration is overridden. The `Promise` resolves once the index
1621
+ * configuration has been persisted.
1622
+ *
1623
+ * The index entries themselves are created asynchronously. You can continue to
1624
+ * use queries that require indexing even if the indices are not yet available.
1625
+ * Query execution will automatically start using the index once the index
1626
+ * entries have been written.
1627
+ *
1628
+ * Indexes are only supported with IndexedDb persistence. Invoke either
1629
+ * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
1630
+ * before setting an index configuration. If IndexedDb is not enabled, any
1631
+ * index configuration is ignored.
1632
+ *
1633
+ * @param firestore - The {@link Firestore} instance to configure indexes for.
1634
+ * @param configuration -The index definition.
1635
+ * @throws FirestoreError if the JSON format is invalid.
1636
+ * @returns A `Promise` that resolves once all indices are successfully
1637
+ * configured.
1638
+ * @beta
1639
+ */
1640
+ export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
1641
+ /**
1642
+ * Configures indexing for local query execution. Any previous index
1643
+ * configuration is overridden. The `Promise` resolves once the index
1644
+ * configuration has been persisted.
1645
+ *
1646
+ * The index entries themselves are created asynchronously. You can continue to
1647
+ * use queries that require indexing even if the indices are not yet available.
1648
+ * Query execution will automatically start using the index once the index
1649
+ * entries have been written.
1650
+ *
1651
+ * Indexes are only supported with IndexedDb persistence. Invoke either
1652
+ * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
1653
+ * before setting an index configuration. If IndexedDb is not enabled, any
1654
+ * index configuration is ignored.
1655
+ *
1656
+ * The method accepts the JSON format exported by the Firebase CLI (`firebase
1657
+ * firestore:indexes`). If the JSON format is invalid, this method throws an
1658
+ * error.
1659
+ *
1660
+ * @param firestore - The {@link Firestore} instance to configure indexes for.
1661
+ * @param json -The JSON format exported by the Firebase CLI.
1662
+ * @throws FirestoreError if the JSON format is invalid.
1663
+ * @returns A `Promise` that resolves once all indices are successfully
1664
+ * configured.
1665
+ * @beta
1666
+ */
1667
+ export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
1486
1668
  /**
1487
1669
  * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
1488
1670
  *
@@ -1643,7 +1825,7 @@ export declare type TaskState = 'Error' | 'Running' | 'Success';
1643
1825
  * may be used. Any other function will throw a `FirestoreError`.
1644
1826
  *
1645
1827
  * To restart after termination, create a new instance of FirebaseFirestore with
1646
- * {@link getFirestore}.
1828
+ * {@link (getFirestore:1)}.
1647
1829
  *
1648
1830
  * Termination does not cancel any pending writes, and any promises that are
1649
1831
  * awaiting a response from the server will not be resolved. If you have