@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
@@ -2,11 +2,11 @@ import { _getProvider, getApp, _removeServiceInstance, _registerComponent, regis
2
2
  import { Component } from '@firebase/component';
3
3
  import { Logger, LogLevel } from '@firebase/logger';
4
4
  import { inspect } from 'util';
5
- import { FirebaseError, createMockUserToken, getModularInstance } from '@firebase/util';
5
+ import { FirebaseError, getDefaultEmulatorHost, createMockUserToken, getModularInstance, deepEqual } from '@firebase/util';
6
6
  import nodeFetch from 'node-fetch';
7
7
  import { randomBytes as randomBytes$1 } from 'crypto';
8
8
 
9
- const version$1 = "3.5.0";
9
+ const version$1 = "3.6.0";
10
10
 
11
11
  /**
12
12
  * @license
@@ -59,7 +59,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
59
59
  User.FIRST_PARTY = new User('first-party-uid');
60
60
  User.MOCK_USER = new User('mock-user');
61
61
 
62
- const version = "9.10.0";
62
+ const version = "9.11.0";
63
63
 
64
64
  /**
65
65
  * @license
@@ -1203,6 +1203,7 @@ const RPC_NAME_URL_MAPPING = {};
1203
1203
  RPC_NAME_URL_MAPPING['BatchGetDocuments'] = 'batchGet';
1204
1204
  RPC_NAME_URL_MAPPING['Commit'] = 'commit';
1205
1205
  RPC_NAME_URL_MAPPING['RunQuery'] = 'runQuery';
1206
+ RPC_NAME_URL_MAPPING['RunAggregationQuery'] = 'runAggregationQuery';
1206
1207
  const RPC_URL_VERSION = 'v1';
1207
1208
  // SDK_VERSION is updated to different value at runtime depending on the entry point,
1208
1209
  // so we need to get its value when we need it in a function.
@@ -1226,6 +1227,11 @@ class RestConnection {
1226
1227
  this.databaseId.database +
1227
1228
  '/documents';
1228
1229
  }
1230
+ get shouldResourcePathBeIncludedInRequest() {
1231
+ // Both `invokeRPC()` and `invokeStreamingRPC()` use their `path` arguments to determine
1232
+ // where to run the query, and expect the `request` to NOT specify the "path".
1233
+ return false;
1234
+ }
1229
1235
  invokeRPC(rpcName, path, req, authToken, appCheckToken) {
1230
1236
  const url = this.makeUrl(rpcName, path);
1231
1237
  logDebug(LOG_TAG$3, 'Sending: ', url, req);
@@ -4561,6 +4567,21 @@ function toQueryTarget(serializer, target) {
4561
4567
  }
4562
4568
  return result;
4563
4569
  }
4570
+ function toRunAggregationQueryRequest(serializer, target) {
4571
+ const queryTarget = toQueryTarget(serializer, target);
4572
+ return {
4573
+ structuredAggregationQuery: {
4574
+ aggregations: [
4575
+ {
4576
+ count: {},
4577
+ alias: 'count_alias'
4578
+ }
4579
+ ],
4580
+ structuredQuery: queryTarget.structuredQuery
4581
+ },
4582
+ parent: queryTarget.parent
4583
+ };
4584
+ }
4564
4585
  function toFilter(filters) {
4565
4586
  if (filters.length === 0) {
4566
4587
  return;
@@ -4963,6 +4984,19 @@ async function invokeRunQueryRpc(datastore, query) {
4963
4984
  // Omit RunQueryResponses that only contain readTimes.
4964
4985
  .filter(proto => !!proto.document)
4965
4986
  .map(proto => fromDocument(datastoreImpl.serializer, proto.document, undefined)));
4987
+ }
4988
+ async function invokeRunAggregationQueryRpc(datastore, query) {
4989
+ const datastoreImpl = debugCast(datastore);
4990
+ const request = toRunAggregationQueryRequest(datastoreImpl.serializer, queryToTarget(query));
4991
+ const parent = request.parent;
4992
+ if (!datastoreImpl.connection.shouldResourcePathBeIncludedInRequest) {
4993
+ delete request.parent;
4994
+ }
4995
+ const response = await datastoreImpl.invokeStreamingRPC('RunAggregationQuery', parent, request, /*expectedResponseCount=*/ 1);
4996
+ return (response
4997
+ // Omit RunAggregationQueryResponse that only contain readTimes.
4998
+ .filter(proto => !!proto.result)
4999
+ .map(proto => proto.result.aggregateFields));
4966
5000
  }
4967
5001
 
4968
5002
  /**
@@ -5173,7 +5207,7 @@ class FirestoreSettingsImpl {
5173
5207
  /**
5174
5208
  * The Cloud Firestore service interface.
5175
5209
  *
5176
- * Do not call this constructor directly. Instead, use {@link getFirestore}.
5210
+ * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
5177
5211
  */
5178
5212
  class Firestore {
5179
5213
  /** @hideconstructor */
@@ -5269,9 +5303,17 @@ function getFirestore(appOrDatabaseId, optionalDatabaseId) {
5269
5303
  const databaseId = typeof appOrDatabaseId === 'string'
5270
5304
  ? appOrDatabaseId
5271
5305
  : optionalDatabaseId || '(default)';
5272
- return _getProvider(app, 'firestore/lite').getImmediate({
5306
+ const db = _getProvider(app, 'firestore/lite').getImmediate({
5273
5307
  identifier: databaseId
5274
5308
  });
5309
+ if (!db._initialized) {
5310
+ const firestoreEmulatorHost = getDefaultEmulatorHost('firestore');
5311
+ if (firestoreEmulatorHost) {
5312
+ const [host, port] = firestoreEmulatorHost.split(':');
5313
+ connectFirestoreEmulator(db, host, parseInt(port, 10));
5314
+ }
5315
+ }
5316
+ return db;
5275
5317
  }
5276
5318
  /**
5277
5319
  * Modify this instance to communicate with the Cloud Firestore emulator.
@@ -5324,7 +5366,7 @@ function connectFirestoreEmulator(firestore, host, port, options = {}) {
5324
5366
  * response from the server will not be resolved.
5325
5367
  *
5326
5368
  * To restart after termination, create a new instance of `Firestore` with
5327
- * {@link getFirestore}.
5369
+ * {@link (getFirestore:1)}.
5328
5370
  *
5329
5371
  * Note: Under normal circumstances, calling `terminate()` is not required. This
5330
5372
  * function is useful only when you want to force this instance to release all of
@@ -5372,6 +5414,100 @@ function registerFirestore() {
5372
5414
  registerVersion('firestore-lite', version$1, 'esm2017');
5373
5415
  }
5374
5416
 
5417
+ /**
5418
+ * @license
5419
+ * Copyright 2022 Google LLC
5420
+ *
5421
+ * Licensed under the Apache License, Version 2.0 (the "License");
5422
+ * you may not use this file except in compliance with the License.
5423
+ * You may obtain a copy of the License at
5424
+ *
5425
+ * http://www.apache.org/licenses/LICENSE-2.0
5426
+ *
5427
+ * Unless required by applicable law or agreed to in writing, software
5428
+ * distributed under the License is distributed on an "AS IS" BASIS,
5429
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5430
+ * See the License for the specific language governing permissions and
5431
+ * limitations under the License.
5432
+ */
5433
+ /**
5434
+ * Represents an aggregation that can be performed by Firestore.
5435
+ */
5436
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5437
+ class AggregateField {
5438
+ constructor() {
5439
+ /** A type string to uniquely identify instances of this class. */
5440
+ this.type = 'AggregateField';
5441
+ }
5442
+ }
5443
+ /**
5444
+ * The results of executing an aggregation query.
5445
+ */
5446
+ class AggregateQuerySnapshot {
5447
+ /** @hideconstructor */
5448
+ constructor(query, _data) {
5449
+ this._data = _data;
5450
+ /** A type string to uniquely identify instances of this class. */
5451
+ this.type = 'AggregateQuerySnapshot';
5452
+ this.query = query;
5453
+ }
5454
+ /**
5455
+ * Returns the results of the aggregations performed over the underlying
5456
+ * query.
5457
+ *
5458
+ * The keys of the returned object will be the same as those of the
5459
+ * `AggregateSpec` object specified to the aggregation method, and the values
5460
+ * will be the corresponding aggregation result.
5461
+ *
5462
+ * @returns The results of the aggregations performed over the underlying
5463
+ * query.
5464
+ */
5465
+ data() {
5466
+ return this._data;
5467
+ }
5468
+ }
5469
+
5470
+ /**
5471
+ * @license
5472
+ * Copyright 2022 Google LLC
5473
+ *
5474
+ * Licensed under the Apache License, Version 2.0 (the "License");
5475
+ * you may not use this file except in compliance with the License.
5476
+ * You may obtain a copy of the License at
5477
+ *
5478
+ * http://www.apache.org/licenses/LICENSE-2.0
5479
+ *
5480
+ * Unless required by applicable law or agreed to in writing, software
5481
+ * distributed under the License is distributed on an "AS IS" BASIS,
5482
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5483
+ * See the License for the specific language governing permissions and
5484
+ * limitations under the License.
5485
+ */
5486
+ /**
5487
+ * CountQueryRunner encapsulates the logic needed to run the count aggregation
5488
+ * queries.
5489
+ */
5490
+ class CountQueryRunner {
5491
+ constructor(query, datastore, userDataWriter) {
5492
+ this.query = query;
5493
+ this.datastore = datastore;
5494
+ this.userDataWriter = userDataWriter;
5495
+ }
5496
+ run() {
5497
+ return invokeRunAggregationQueryRpc(this.datastore, this.query._query).then(result => {
5498
+ hardAssert(result[0] !== undefined);
5499
+ const counts = Object.entries(result[0])
5500
+ .filter(([key, value]) => key === 'count_alias')
5501
+ .map(([key, value]) => this.userDataWriter.convertValue(value));
5502
+ const countValue = counts[0];
5503
+ hardAssert(typeof countValue === 'number');
5504
+ return Promise.resolve(new AggregateQuerySnapshot(this.query, {
5505
+ count: countValue
5506
+ }));
5507
+ });
5508
+ }
5509
+ }
5510
+
5375
5511
  /**
5376
5512
  * @license
5377
5513
  * Copyright 2020 Google LLC
@@ -5603,64 +5739,6 @@ function queryEqual(left, right) {
5603
5739
  return false;
5604
5740
  }
5605
5741
 
5606
- /**
5607
- * @license
5608
- * Copyright 2020 Google LLC
5609
- *
5610
- * Licensed under the Apache License, Version 2.0 (the "License");
5611
- * you may not use this file except in compliance with the License.
5612
- * You may obtain a copy of the License at
5613
- *
5614
- * http://www.apache.org/licenses/LICENSE-2.0
5615
- *
5616
- * Unless required by applicable law or agreed to in writing, software
5617
- * distributed under the License is distributed on an "AS IS" BASIS,
5618
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5619
- * See the License for the specific language governing permissions and
5620
- * limitations under the License.
5621
- */
5622
- /**
5623
- * A `FieldPath` refers to a field in a document. The path may consist of a
5624
- * single field name (referring to a top-level field in the document), or a
5625
- * list of field names (referring to a nested field in the document).
5626
- *
5627
- * Create a `FieldPath` by providing field names. If more than one field
5628
- * name is provided, the path will point to a nested field in a document.
5629
- */
5630
- class FieldPath {
5631
- /**
5632
- * Creates a `FieldPath` from the provided field names. If more than one field
5633
- * name is provided, the path will point to a nested field in a document.
5634
- *
5635
- * @param fieldNames - A list of field names.
5636
- */
5637
- constructor(...fieldNames) {
5638
- for (let i = 0; i < fieldNames.length; ++i) {
5639
- if (fieldNames[i].length === 0) {
5640
- throw new FirestoreError(Code.INVALID_ARGUMENT, `Invalid field name at argument $(i + 1). ` +
5641
- 'Field names must not be empty.');
5642
- }
5643
- }
5644
- this._internalPath = new FieldPath$1(fieldNames);
5645
- }
5646
- /**
5647
- * Returns true if this `FieldPath` is equal to the provided one.
5648
- *
5649
- * @param other - The `FieldPath` to compare against.
5650
- * @returns true if this `FieldPath` is equal to the provided one.
5651
- */
5652
- isEqual(other) {
5653
- return this._internalPath.isEqual(other._internalPath);
5654
- }
5655
- }
5656
- /**
5657
- * Returns a special sentinel `FieldPath` to refer to the ID of a document.
5658
- * It can be used in queries to sort or filter by the document ID.
5659
- */
5660
- function documentId() {
5661
- return new FieldPath(DOCUMENT_KEY_NAME);
5662
- }
5663
-
5664
5742
  /**
5665
5743
  * @license
5666
5744
  * Copyright 2020 Google LLC
@@ -5742,6 +5820,64 @@ class Bytes {
5742
5820
  }
5743
5821
  }
5744
5822
 
5823
+ /**
5824
+ * @license
5825
+ * Copyright 2020 Google LLC
5826
+ *
5827
+ * Licensed under the Apache License, Version 2.0 (the "License");
5828
+ * you may not use this file except in compliance with the License.
5829
+ * You may obtain a copy of the License at
5830
+ *
5831
+ * http://www.apache.org/licenses/LICENSE-2.0
5832
+ *
5833
+ * Unless required by applicable law or agreed to in writing, software
5834
+ * distributed under the License is distributed on an "AS IS" BASIS,
5835
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5836
+ * See the License for the specific language governing permissions and
5837
+ * limitations under the License.
5838
+ */
5839
+ /**
5840
+ * A `FieldPath` refers to a field in a document. The path may consist of a
5841
+ * single field name (referring to a top-level field in the document), or a
5842
+ * list of field names (referring to a nested field in the document).
5843
+ *
5844
+ * Create a `FieldPath` by providing field names. If more than one field
5845
+ * name is provided, the path will point to a nested field in a document.
5846
+ */
5847
+ class FieldPath {
5848
+ /**
5849
+ * Creates a `FieldPath` from the provided field names. If more than one field
5850
+ * name is provided, the path will point to a nested field in a document.
5851
+ *
5852
+ * @param fieldNames - A list of field names.
5853
+ */
5854
+ constructor(...fieldNames) {
5855
+ for (let i = 0; i < fieldNames.length; ++i) {
5856
+ if (fieldNames[i].length === 0) {
5857
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `Invalid field name at argument $(i + 1). ` +
5858
+ 'Field names must not be empty.');
5859
+ }
5860
+ }
5861
+ this._internalPath = new FieldPath$1(fieldNames);
5862
+ }
5863
+ /**
5864
+ * Returns true if this `FieldPath` is equal to the provided one.
5865
+ *
5866
+ * @param other - The `FieldPath` to compare against.
5867
+ * @returns true if this `FieldPath` is equal to the provided one.
5868
+ */
5869
+ isEqual(other) {
5870
+ return this._internalPath.isEqual(other._internalPath);
5871
+ }
5872
+ }
5873
+ /**
5874
+ * Returns a special sentinel `FieldPath` to refer to the ID of a document.
5875
+ * It can be used in queries to sort or filter by the document ID.
5876
+ */
5877
+ function documentId() {
5878
+ return new FieldPath(DOCUMENT_KEY_NAME);
5879
+ }
5880
+
5745
5881
  /**
5746
5882
  * @license
5747
5883
  * Copyright 2020 Google LLC
@@ -7450,6 +7586,58 @@ function addDoc(reference, data) {
7450
7586
  ]).then(() => docRef);
7451
7587
  }
7452
7588
 
7589
+ /**
7590
+ * @license
7591
+ * Copyright 2022 Google LLC
7592
+ *
7593
+ * Licensed under the Apache License, Version 2.0 (the "License");
7594
+ * you may not use this file except in compliance with the License.
7595
+ * You may obtain a copy of the License at
7596
+ *
7597
+ * http://www.apache.org/licenses/LICENSE-2.0
7598
+ *
7599
+ * Unless required by applicable law or agreed to in writing, software
7600
+ * distributed under the License is distributed on an "AS IS" BASIS,
7601
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7602
+ * See the License for the specific language governing permissions and
7603
+ * limitations under the License.
7604
+ */
7605
+ /**
7606
+ * Calculates the number of documents in the result set of the given query,
7607
+ * without actually downloading the documents.
7608
+ *
7609
+ * Using this function to count the documents is efficient because only the
7610
+ * final count, not the documents' data, is downloaded. This function can even
7611
+ * count the documents if the result set would be prohibitively large to
7612
+ * download entirely (e.g. thousands of documents).
7613
+ *
7614
+ * @param query - The query whose result set size to calculate.
7615
+ * @returns A Promise that will be resolved with the count; the count can be
7616
+ * retrieved from `snapshot.data().count`, where `snapshot` is the
7617
+ * `AggregateQuerySnapshot` to which the returned Promise resolves.
7618
+ */
7619
+ function getCount(query) {
7620
+ const firestore = cast(query.firestore, Firestore);
7621
+ const datastore = getDatastore(firestore);
7622
+ const userDataWriter = new LiteUserDataWriter(firestore);
7623
+ return new CountQueryRunner(query, datastore, userDataWriter).run();
7624
+ }
7625
+ /**
7626
+ * Compares two `AggregateQuerySnapshot` instances for equality.
7627
+ *
7628
+ * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
7629
+ * underlying queries that compare equal, and the same data.
7630
+ *
7631
+ * @param left - The first `AggregateQuerySnapshot` to compare.
7632
+ * @param right - The second `AggregateQuerySnapshot` to compare.
7633
+ *
7634
+ * @returns `true` if the objects are "equal", as defined above, or `false`
7635
+ * otherwise.
7636
+ */
7637
+ function aggregateQuerySnapshotEqual(left, right) {
7638
+ return (queryEqual(left.query, right.query) && deepEqual(left.data(), right.data()));
7639
+ }
7640
+
7453
7641
  /**
7454
7642
  * @license
7455
7643
  * Copyright 2020 Google LLC
@@ -8442,5 +8630,5 @@ function runTransaction(firestore, updateFunction, options) {
8442
8630
  */
8443
8631
  registerFirestore();
8444
8632
 
8445
- export { Bytes, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, Query, QueryConstraint, QueryDocumentSnapshot, QuerySnapshot, Timestamp, Transaction, WriteBatch, addDoc, arrayRemove, arrayUnion, collection, collectionGroup, connectFirestoreEmulator, deleteDoc, deleteField, doc, documentId, endAt, endBefore, getDoc, getDocs, getFirestore, increment, initializeFirestore, limit, limitToLast, orderBy, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setLogLevel, snapshotEqual, startAfter, startAt, terminate, updateDoc, where, writeBatch };
8633
+ export { AggregateField, AggregateQuerySnapshot, Bytes, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, Query, QueryConstraint, QueryDocumentSnapshot, QuerySnapshot, Timestamp, Transaction, WriteBatch, addDoc, aggregateQuerySnapshotEqual, arrayRemove, arrayUnion, collection, collectionGroup, connectFirestoreEmulator, deleteDoc, deleteField, doc, documentId, endAt, endBefore, getCount, getDoc, getDocs, getFirestore, increment, initializeFirestore, limit, limitToLast, orderBy, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setLogLevel, snapshotEqual, startAfter, startAt, terminate, updateDoc, where, writeBatch };
8446
8634
  //# sourceMappingURL=index.node.mjs.map