@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
@@ -41,6 +41,77 @@ export declare type AddPrefixToKeys<Prefix extends string, T extends Record<stri
41
41
  [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
42
42
  };
43
43
 
44
+ /**
45
+ * Represents an aggregation that can be performed by Firestore.
46
+ */
47
+ export declare class AggregateField<T> {
48
+ /** A type string to uniquely identify instances of this class. */
49
+ type: string;
50
+ }
51
+
52
+ /**
53
+ * The union of all `AggregateField` types that are supported by Firestore.
54
+ */
55
+ export declare type AggregateFieldType = AggregateField<number>;
56
+
57
+ /**
58
+ * The results of executing an aggregation query.
59
+ */
60
+ export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
61
+ private readonly _data;
62
+ /** A type string to uniquely identify instances of this class. */
63
+ readonly type = "AggregateQuerySnapshot";
64
+ /**
65
+ * The underlying query over which the aggregations recorded in this
66
+ * `AggregateQuerySnapshot` were performed.
67
+ */
68
+ readonly query: Query<unknown>;
69
+ /** @hideconstructor */
70
+ constructor(query: Query<unknown>, _data: AggregateSpecData<T>);
71
+ /**
72
+ * Returns the results of the aggregations performed over the underlying
73
+ * query.
74
+ *
75
+ * The keys of the returned object will be the same as those of the
76
+ * `AggregateSpec` object specified to the aggregation method, and the values
77
+ * will be the corresponding aggregation result.
78
+ *
79
+ * @returns The results of the aggregations performed over the underlying
80
+ * query.
81
+ */
82
+ data(): AggregateSpecData<T>;
83
+ }
84
+
85
+ /**
86
+ * Compares two `AggregateQuerySnapshot` instances for equality.
87
+ *
88
+ * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
89
+ * underlying queries that compare equal, and the same data.
90
+ *
91
+ * @param left - The first `AggregateQuerySnapshot` to compare.
92
+ * @param right - The second `AggregateQuerySnapshot` to compare.
93
+ *
94
+ * @returns `true` if the objects are "equal", as defined above, or `false`
95
+ * otherwise.
96
+ */
97
+ export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
98
+
99
+ /**
100
+ * A type whose property values are all `AggregateField` objects.
101
+ */
102
+ export declare interface AggregateSpec {
103
+ [field: string]: AggregateFieldType;
104
+ }
105
+
106
+ /**
107
+ * A type whose keys are taken from an `AggregateSpec`, and whose values are the
108
+ * result of the aggregation performed by the corresponding `AggregateField`
109
+ * from the input `AggregateSpec`.
110
+ */
111
+ export declare type AggregateSpecData<T extends AggregateSpec> = {
112
+ [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
113
+ };
114
+
44
115
  declare interface ApiClientObjectMap<T> {
45
116
  [k: string]: T;
46
117
  }
@@ -851,7 +922,7 @@ declare abstract class Filter {
851
922
  /**
852
923
  * The Cloud Firestore service interface.
853
924
  *
854
- * Do not call this constructor directly. Instead, use {@link getFirestore}.
925
+ * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
855
926
  */
856
927
  export declare class Firestore implements FirestoreService {
857
928
  _authCredentials: CredentialsProvider<User>;
@@ -1254,6 +1325,32 @@ declare namespace firestoreV1ApiClientInterfaces {
1254
1325
  readTime?: string;
1255
1326
  skippedResults?: number;
1256
1327
  }
1328
+ interface RunAggregationQueryRequest {
1329
+ parent?: string;
1330
+ structuredAggregationQuery?: StructuredAggregationQuery;
1331
+ transaction?: string;
1332
+ newTransaction?: TransactionOptions;
1333
+ readTime?: string;
1334
+ }
1335
+ interface RunAggregationQueryResponse {
1336
+ result?: AggregationResult;
1337
+ transaction?: string;
1338
+ readTime?: string;
1339
+ }
1340
+ interface AggregationResult {
1341
+ aggregateFields?: ApiClientObjectMap<Value>;
1342
+ }
1343
+ interface StructuredAggregationQuery {
1344
+ structuredQuery?: StructuredQuery;
1345
+ aggregations?: Aggregation[];
1346
+ }
1347
+ interface Aggregation {
1348
+ count?: Count;
1349
+ alias?: string;
1350
+ }
1351
+ interface Count {
1352
+ upTo?: number;
1353
+ }
1257
1354
  interface Status {
1258
1355
  code?: number;
1259
1356
  message?: string;
@@ -1402,6 +1499,24 @@ export declare class GeoPoint {
1402
1499
  _compareTo(other: GeoPoint): number;
1403
1500
  }
1404
1501
 
1502
+ /**
1503
+ * Calculates the number of documents in the result set of the given query,
1504
+ * without actually downloading the documents.
1505
+ *
1506
+ * Using this function to count the documents is efficient because only the
1507
+ * final count, not the documents' data, is downloaded. This function can even
1508
+ * count the documents if the result set would be prohibitively large to
1509
+ * download entirely (e.g. thousands of documents).
1510
+ *
1511
+ * @param query - The query whose result set size to calculate.
1512
+ * @returns A Promise that will be resolved with the count; the count can be
1513
+ * retrieved from `snapshot.data().count`, where `snapshot` is the
1514
+ * `AggregateQuerySnapshot` to which the returned Promise resolves.
1515
+ */
1516
+ export declare function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
1517
+ count: AggregateField<number>;
1518
+ }>>;
1519
+
1405
1520
  /**
1406
1521
  * Reads the document referred to by the specified document reference.
1407
1522
  *
@@ -1483,8 +1598,8 @@ declare type IndexState = 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'ERROR';
1483
1598
  /**
1484
1599
  * Initializes a new instance of Cloud Firestore with the provided settings.
1485
1600
  * Can only be called before any other functions, including
1486
- * {@link getFirestore}. If the custom settings are empty, this function is
1487
- * equivalent to calling {@link getFirestore}.
1601
+ * {@link (getFirestore:1)}. If the custom settings are empty, this function is
1602
+ * equivalent to calling {@link (getFirestore:1)}.
1488
1603
  *
1489
1604
  * @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
1490
1605
  * be associated.
@@ -2184,7 +2299,7 @@ declare type TargetChangeTargetChangeType = 'NO_CHANGE' | 'ADD' | 'REMOVE' | 'CU
2184
2299
  * response from the server will not be resolved.
2185
2300
  *
2186
2301
  * To restart after termination, create a new instance of `Firestore` with
2187
- * {@link getFirestore}.
2302
+ * {@link (getFirestore:1)}.
2188
2303
  *
2189
2304
  * Note: Under normal circumstances, calling `terminate()` is not required. This
2190
2305
  * function is useful only when you want to force this instance to release all of