@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
@@ -58,6 +58,77 @@ export declare type AddPrefixToKeys<Prefix extends string, T extends Record<stri
58
58
  [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
59
59
  };
60
60
 
61
+ /**
62
+ * Represents an aggregation that can be performed by Firestore.
63
+ */
64
+ export declare class AggregateField<T> {
65
+ /** A type string to uniquely identify instances of this class. */
66
+ type: string;
67
+ }
68
+
69
+ /**
70
+ * The union of all `AggregateField` types that are supported by Firestore.
71
+ */
72
+ export declare type AggregateFieldType = AggregateField<number>;
73
+
74
+ /**
75
+ * The results of executing an aggregation query.
76
+ */
77
+ export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
78
+ private readonly _data;
79
+ /** A type string to uniquely identify instances of this class. */
80
+ readonly type = "AggregateQuerySnapshot";
81
+ /**
82
+ * The underlying query over which the aggregations recorded in this
83
+ * `AggregateQuerySnapshot` were performed.
84
+ */
85
+ readonly query: Query<unknown>;
86
+ /** @hideconstructor */
87
+ constructor(query: Query<unknown>, _data: AggregateSpecData<T>);
88
+ /**
89
+ * Returns the results of the aggregations performed over the underlying
90
+ * query.
91
+ *
92
+ * The keys of the returned object will be the same as those of the
93
+ * `AggregateSpec` object specified to the aggregation method, and the values
94
+ * will be the corresponding aggregation result.
95
+ *
96
+ * @returns The results of the aggregations performed over the underlying
97
+ * query.
98
+ */
99
+ data(): AggregateSpecData<T>;
100
+ }
101
+
102
+ /**
103
+ * Compares two `AggregateQuerySnapshot` instances for equality.
104
+ *
105
+ * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
106
+ * underlying queries that compare equal, and the same data.
107
+ *
108
+ * @param left - The first `AggregateQuerySnapshot` to compare.
109
+ * @param right - The second `AggregateQuerySnapshot` to compare.
110
+ *
111
+ * @returns `true` if the objects are "equal", as defined above, or `false`
112
+ * otherwise.
113
+ */
114
+ export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
115
+
116
+ /**
117
+ * A type whose property values are all `AggregateField` objects.
118
+ */
119
+ export declare interface AggregateSpec {
120
+ [field: string]: AggregateFieldType;
121
+ }
122
+
123
+ /**
124
+ * A type whose keys are taken from an `AggregateSpec`, and whose values are the
125
+ * result of the aggregation performed by the corresponding `AggregateField`
126
+ * from the input `AggregateSpec`.
127
+ */
128
+ export declare type AggregateSpecData<T extends AggregateSpec> = {
129
+ [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
130
+ };
131
+
61
132
  declare interface ApiClientObjectMap<T> {
62
133
  [k: string]: T;
63
134
  }
@@ -974,7 +1045,7 @@ declare abstract class Filter {
974
1045
  /**
975
1046
  * The Cloud Firestore service interface.
976
1047
  *
977
- * Do not call this constructor directly. Instead, use {@link getFirestore}.
1048
+ * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
978
1049
  */
979
1050
  export declare class Firestore implements FirestoreService {
980
1051
  _authCredentials: CredentialsProvider<User>;
@@ -1377,6 +1448,32 @@ declare namespace firestoreV1ApiClientInterfaces {
1377
1448
  readTime?: string;
1378
1449
  skippedResults?: number;
1379
1450
  }
1451
+ interface RunAggregationQueryRequest {
1452
+ parent?: string;
1453
+ structuredAggregationQuery?: StructuredAggregationQuery;
1454
+ transaction?: string;
1455
+ newTransaction?: TransactionOptions;
1456
+ readTime?: string;
1457
+ }
1458
+ interface RunAggregationQueryResponse {
1459
+ result?: AggregationResult;
1460
+ transaction?: string;
1461
+ readTime?: string;
1462
+ }
1463
+ interface AggregationResult {
1464
+ aggregateFields?: ApiClientObjectMap<Value>;
1465
+ }
1466
+ interface StructuredAggregationQuery {
1467
+ structuredQuery?: StructuredQuery;
1468
+ aggregations?: Aggregation[];
1469
+ }
1470
+ interface Aggregation {
1471
+ count?: Count;
1472
+ alias?: string;
1473
+ }
1474
+ interface Count {
1475
+ upTo?: number;
1476
+ }
1380
1477
  interface Status {
1381
1478
  code?: number;
1382
1479
  message?: string;
@@ -1525,6 +1622,24 @@ export declare class GeoPoint {
1525
1622
  _compareTo(other: GeoPoint): number;
1526
1623
  }
1527
1624
 
1625
+ /**
1626
+ * Calculates the number of documents in the result set of the given query,
1627
+ * without actually downloading the documents.
1628
+ *
1629
+ * Using this function to count the documents is efficient because only the
1630
+ * final count, not the documents' data, is downloaded. This function can even
1631
+ * count the documents if the result set would be prohibitively large to
1632
+ * download entirely (e.g. thousands of documents).
1633
+ *
1634
+ * @param query - The query whose result set size to calculate.
1635
+ * @returns A Promise that will be resolved with the count; the count can be
1636
+ * retrieved from `snapshot.data().count`, where `snapshot` is the
1637
+ * `AggregateQuerySnapshot` to which the returned Promise resolves.
1638
+ */
1639
+ export declare function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
1640
+ count: AggregateField<number>;
1641
+ }>>;
1642
+
1528
1643
  /**
1529
1644
  * Reads the document referred to by the specified document reference.
1530
1645
  *
@@ -1626,8 +1741,8 @@ declare type IndexState = 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'ERROR';
1626
1741
  /**
1627
1742
  * Initializes a new instance of Cloud Firestore with the provided settings.
1628
1743
  * Can only be called before any other functions, including
1629
- * {@link getFirestore}. If the custom settings are empty, this function is
1630
- * equivalent to calling {@link getFirestore}.
1744
+ * {@link (getFirestore:1)}. If the custom settings are empty, this function is
1745
+ * equivalent to calling {@link (getFirestore:1)}.
1631
1746
  *
1632
1747
  * @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
1633
1748
  * be associated.
@@ -1639,8 +1754,8 @@ export declare function initializeFirestore(app: FirebaseApp, settings: Settings
1639
1754
  /**
1640
1755
  * Initializes a new instance of Cloud Firestore with the provided settings.
1641
1756
  * Can only be called before any other functions, including
1642
- * {@link getFirestore}. If the custom settings are empty, this function is
1643
- * equivalent to calling {@link getFirestore}.
1757
+ * {@link (getFirestore:1)}. If the custom settings are empty, this function is
1758
+ * equivalent to calling {@link (getFirestore:1)}.
1644
1759
  *
1645
1760
  * @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
1646
1761
  * be associated.
@@ -2357,7 +2472,7 @@ declare type TargetChangeTargetChangeType = 'NO_CHANGE' | 'ADD' | 'REMOVE' | 'CU
2357
2472
  * response from the server will not be resolved.
2358
2473
  *
2359
2474
  * To restart after termination, create a new instance of `Firestore` with
2360
- * {@link getFirestore}.
2475
+ * {@link (getFirestore:1)}.
2361
2476
  *
2362
2477
  * Note: Under normal circumstances, calling `terminate()` is not required. This
2363
2478
  * function is useful only when you want to force this instance to release all of