@firebase/firestore 3.5.0 → 3.6.0-canary.03d1fabcb

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 (122) 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/core/view.d.ts +1 -0
  9. package/dist/firestore/src/core/view_snapshot.d.ts +3 -2
  10. package/dist/firestore/src/lite-api/aggregate.d.ts +48 -0
  11. package/dist/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  12. package/dist/firestore/src/lite-api/database.d.ts +7 -7
  13. package/dist/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  14. package/dist/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  15. package/dist/firestore/src/remote/connection.d.ts +7 -0
  16. package/dist/firestore/src/remote/datastore.d.ts +2 -0
  17. package/dist/firestore/src/remote/remote_event.d.ts +2 -2
  18. package/dist/firestore/src/remote/rest_connection.d.ts +1 -0
  19. package/dist/firestore/src/remote/serializer.d.ts +2 -1
  20. package/dist/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  21. package/dist/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  22. package/dist/firestore/test/integration/util/helpers.d.ts +1 -0
  23. package/dist/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  24. package/dist/firestore/test/util/api_helpers.d.ts +1 -1
  25. package/dist/index.d.ts +196 -14
  26. package/dist/index.esm2017.js +4630 -4428
  27. package/dist/index.esm2017.js.map +1 -1
  28. package/dist/index.esm5.js +4705 -4500
  29. package/dist/index.esm5.js.map +1 -1
  30. package/dist/index.node.cjs.js +1020 -632
  31. package/dist/index.node.cjs.js.map +1 -1
  32. package/dist/index.node.mjs +1018 -634
  33. package/dist/index.node.mjs.map +1 -1
  34. package/dist/index.rn.js +4634 -4432
  35. package/dist/index.rn.js.map +1 -1
  36. package/dist/internal.d.ts +144 -21
  37. package/dist/lite/firestore/lite/index.d.ts +2 -0
  38. package/dist/lite/firestore/src/api/aggregate.d.ts +43 -0
  39. package/dist/lite/firestore/src/api/database.d.ts +15 -15
  40. package/dist/lite/firestore/src/api.d.ts +2 -0
  41. package/dist/lite/firestore/src/core/count_query_runner.d.ts +32 -0
  42. package/dist/lite/firestore/src/core/firestore_client.d.ts +5 -0
  43. package/dist/lite/firestore/src/core/view.d.ts +1 -0
  44. package/dist/lite/firestore/src/core/view_snapshot.d.ts +3 -2
  45. package/dist/lite/firestore/src/lite-api/aggregate.d.ts +48 -0
  46. package/dist/lite/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  47. package/dist/lite/firestore/src/lite-api/database.d.ts +7 -7
  48. package/dist/lite/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  49. package/dist/lite/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  50. package/dist/lite/firestore/src/remote/connection.d.ts +7 -0
  51. package/dist/lite/firestore/src/remote/datastore.d.ts +2 -0
  52. package/dist/lite/firestore/src/remote/remote_event.d.ts +2 -2
  53. package/dist/lite/firestore/src/remote/rest_connection.d.ts +1 -0
  54. package/dist/lite/firestore/src/remote/serializer.d.ts +2 -1
  55. package/dist/lite/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  56. package/dist/lite/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  57. package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -0
  58. package/dist/lite/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  59. package/dist/lite/firestore/test/util/api_helpers.d.ts +1 -1
  60. package/dist/lite/index.browser.esm2017.js +1247 -1086
  61. package/dist/lite/index.browser.esm2017.js.map +1 -1
  62. package/dist/lite/index.browser.esm5.js +1392 -1233
  63. package/dist/lite/index.browser.esm5.js.map +1 -1
  64. package/dist/lite/index.d.ts +84 -4
  65. package/dist/lite/index.node.cjs.js +254 -63
  66. package/dist/lite/index.node.cjs.js.map +1 -1
  67. package/dist/lite/index.node.mjs +252 -65
  68. package/dist/lite/index.node.mjs.map +1 -1
  69. package/dist/lite/index.rn.esm2017.js +1254 -1093
  70. package/dist/lite/index.rn.esm2017.js.map +1 -1
  71. package/dist/lite/internal.d.ts +121 -6
  72. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +227 -142
  73. package/dist/lite/packages/firestore/lite/index.d.ts +2 -0
  74. package/dist/lite/packages/firestore/src/api/aggregate.d.ts +43 -0
  75. package/dist/lite/packages/firestore/src/api/database.d.ts +15 -15
  76. package/dist/lite/packages/firestore/src/api.d.ts +2 -0
  77. package/dist/lite/packages/firestore/src/core/count_query_runner.d.ts +32 -0
  78. package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +5 -0
  79. package/dist/lite/packages/firestore/src/core/view.d.ts +1 -0
  80. package/dist/lite/packages/firestore/src/core/view_snapshot.d.ts +3 -2
  81. package/dist/lite/packages/firestore/src/lite-api/aggregate.d.ts +48 -0
  82. package/dist/lite/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  83. package/dist/lite/packages/firestore/src/lite-api/database.d.ts +7 -7
  84. package/dist/lite/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  85. package/dist/lite/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  86. package/dist/lite/packages/firestore/src/remote/connection.d.ts +7 -0
  87. package/dist/lite/packages/firestore/src/remote/datastore.d.ts +2 -0
  88. package/dist/lite/packages/firestore/src/remote/remote_event.d.ts +2 -2
  89. package/dist/lite/packages/firestore/src/remote/rest_connection.d.ts +1 -0
  90. package/dist/lite/packages/firestore/src/remote/serializer.d.ts +2 -1
  91. package/dist/lite/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  92. package/dist/lite/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  93. package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  94. package/dist/lite/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  95. package/dist/lite/packages/firestore/test/util/api_helpers.d.ts +1 -1
  96. package/dist/lite/private.d.ts +119 -4
  97. package/dist/packages/firestore/dist/index.esm2017.d.ts +336 -254
  98. package/dist/packages/firestore/lite/index.d.ts +2 -0
  99. package/dist/packages/firestore/src/api/aggregate.d.ts +43 -0
  100. package/dist/packages/firestore/src/api/database.d.ts +15 -15
  101. package/dist/packages/firestore/src/api.d.ts +2 -0
  102. package/dist/packages/firestore/src/core/count_query_runner.d.ts +32 -0
  103. package/dist/packages/firestore/src/core/firestore_client.d.ts +5 -0
  104. package/dist/packages/firestore/src/core/view.d.ts +1 -0
  105. package/dist/packages/firestore/src/core/view_snapshot.d.ts +3 -2
  106. package/dist/packages/firestore/src/lite-api/aggregate.d.ts +48 -0
  107. package/dist/packages/firestore/src/lite-api/aggregate_types.d.ts +69 -0
  108. package/dist/packages/firestore/src/lite-api/database.d.ts +7 -7
  109. package/dist/packages/firestore/src/platform/node/grpc_connection.d.ts +1 -0
  110. package/dist/packages/firestore/src/protos/firestore_proto_api.d.ts +28 -0
  111. package/dist/packages/firestore/src/remote/connection.d.ts +7 -0
  112. package/dist/packages/firestore/src/remote/datastore.d.ts +2 -0
  113. package/dist/packages/firestore/src/remote/remote_event.d.ts +2 -2
  114. package/dist/packages/firestore/src/remote/rest_connection.d.ts +1 -0
  115. package/dist/packages/firestore/src/remote/serializer.d.ts +2 -1
  116. package/dist/packages/firestore/test/integration/api/aggregation.test.d.ts +17 -0
  117. package/dist/packages/firestore/test/integration/api_internal/aggregation.test.d.ts +17 -0
  118. package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -0
  119. package/dist/packages/firestore/test/unit/specs/spec_test_components.d.ts +1 -0
  120. package/dist/packages/firestore/test/util/api_helpers.d.ts +1 -1
  121. package/dist/private.d.ts +239 -23
  122. package/package.json +9 -9
@@ -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, getDefaultEmulatorHostnameAndPort, 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-canary.03d1fabcb";
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-canary.03d1fabcb";
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,16 @@ 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 emulator = getDefaultEmulatorHostnameAndPort('firestore');
5311
+ if (emulator) {
5312
+ connectFirestoreEmulator(db, ...emulator);
5313
+ }
5314
+ }
5315
+ return db;
5275
5316
  }
5276
5317
  /**
5277
5318
  * Modify this instance to communicate with the Cloud Firestore emulator.
@@ -5324,7 +5365,7 @@ function connectFirestoreEmulator(firestore, host, port, options = {}) {
5324
5365
  * response from the server will not be resolved.
5325
5366
  *
5326
5367
  * To restart after termination, create a new instance of `Firestore` with
5327
- * {@link getFirestore}.
5368
+ * {@link (getFirestore:1)}.
5328
5369
  *
5329
5370
  * Note: Under normal circumstances, calling `terminate()` is not required. This
5330
5371
  * function is useful only when you want to force this instance to release all of
@@ -5372,6 +5413,100 @@ function registerFirestore() {
5372
5413
  registerVersion('firestore-lite', version$1, 'esm2017');
5373
5414
  }
5374
5415
 
5416
+ /**
5417
+ * @license
5418
+ * Copyright 2022 Google LLC
5419
+ *
5420
+ * Licensed under the Apache License, Version 2.0 (the "License");
5421
+ * you may not use this file except in compliance with the License.
5422
+ * You may obtain a copy of the License at
5423
+ *
5424
+ * http://www.apache.org/licenses/LICENSE-2.0
5425
+ *
5426
+ * Unless required by applicable law or agreed to in writing, software
5427
+ * distributed under the License is distributed on an "AS IS" BASIS,
5428
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5429
+ * See the License for the specific language governing permissions and
5430
+ * limitations under the License.
5431
+ */
5432
+ /**
5433
+ * Represents an aggregation that can be performed by Firestore.
5434
+ */
5435
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5436
+ class AggregateField {
5437
+ constructor() {
5438
+ /** A type string to uniquely identify instances of this class. */
5439
+ this.type = 'AggregateField';
5440
+ }
5441
+ }
5442
+ /**
5443
+ * The results of executing an aggregation query.
5444
+ */
5445
+ class AggregateQuerySnapshot {
5446
+ /** @hideconstructor */
5447
+ constructor(query, _data) {
5448
+ this._data = _data;
5449
+ /** A type string to uniquely identify instances of this class. */
5450
+ this.type = 'AggregateQuerySnapshot';
5451
+ this.query = query;
5452
+ }
5453
+ /**
5454
+ * Returns the results of the aggregations performed over the underlying
5455
+ * query.
5456
+ *
5457
+ * The keys of the returned object will be the same as those of the
5458
+ * `AggregateSpec` object specified to the aggregation method, and the values
5459
+ * will be the corresponding aggregation result.
5460
+ *
5461
+ * @returns The results of the aggregations performed over the underlying
5462
+ * query.
5463
+ */
5464
+ data() {
5465
+ return this._data;
5466
+ }
5467
+ }
5468
+
5469
+ /**
5470
+ * @license
5471
+ * Copyright 2022 Google LLC
5472
+ *
5473
+ * Licensed under the Apache License, Version 2.0 (the "License");
5474
+ * you may not use this file except in compliance with the License.
5475
+ * You may obtain a copy of the License at
5476
+ *
5477
+ * http://www.apache.org/licenses/LICENSE-2.0
5478
+ *
5479
+ * Unless required by applicable law or agreed to in writing, software
5480
+ * distributed under the License is distributed on an "AS IS" BASIS,
5481
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5482
+ * See the License for the specific language governing permissions and
5483
+ * limitations under the License.
5484
+ */
5485
+ /**
5486
+ * CountQueryRunner encapsulates the logic needed to run the count aggregation
5487
+ * queries.
5488
+ */
5489
+ class CountQueryRunner {
5490
+ constructor(query, datastore, userDataWriter) {
5491
+ this.query = query;
5492
+ this.datastore = datastore;
5493
+ this.userDataWriter = userDataWriter;
5494
+ }
5495
+ run() {
5496
+ return invokeRunAggregationQueryRpc(this.datastore, this.query._query).then(result => {
5497
+ hardAssert(result[0] !== undefined);
5498
+ const counts = Object.entries(result[0])
5499
+ .filter(([key, value]) => key === 'count_alias')
5500
+ .map(([key, value]) => this.userDataWriter.convertValue(value));
5501
+ const countValue = counts[0];
5502
+ hardAssert(typeof countValue === 'number');
5503
+ return Promise.resolve(new AggregateQuerySnapshot(this.query, {
5504
+ count: countValue
5505
+ }));
5506
+ });
5507
+ }
5508
+ }
5509
+
5375
5510
  /**
5376
5511
  * @license
5377
5512
  * Copyright 2020 Google LLC
@@ -5603,64 +5738,6 @@ function queryEqual(left, right) {
5603
5738
  return false;
5604
5739
  }
5605
5740
 
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
5741
  /**
5665
5742
  * @license
5666
5743
  * Copyright 2020 Google LLC
@@ -5742,6 +5819,64 @@ class Bytes {
5742
5819
  }
5743
5820
  }
5744
5821
 
5822
+ /**
5823
+ * @license
5824
+ * Copyright 2020 Google LLC
5825
+ *
5826
+ * Licensed under the Apache License, Version 2.0 (the "License");
5827
+ * you may not use this file except in compliance with the License.
5828
+ * You may obtain a copy of the License at
5829
+ *
5830
+ * http://www.apache.org/licenses/LICENSE-2.0
5831
+ *
5832
+ * Unless required by applicable law or agreed to in writing, software
5833
+ * distributed under the License is distributed on an "AS IS" BASIS,
5834
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5835
+ * See the License for the specific language governing permissions and
5836
+ * limitations under the License.
5837
+ */
5838
+ /**
5839
+ * A `FieldPath` refers to a field in a document. The path may consist of a
5840
+ * single field name (referring to a top-level field in the document), or a
5841
+ * list of field names (referring to a nested field in the document).
5842
+ *
5843
+ * Create a `FieldPath` by providing field names. If more than one field
5844
+ * name is provided, the path will point to a nested field in a document.
5845
+ */
5846
+ class FieldPath {
5847
+ /**
5848
+ * Creates a `FieldPath` from the provided field names. If more than one field
5849
+ * name is provided, the path will point to a nested field in a document.
5850
+ *
5851
+ * @param fieldNames - A list of field names.
5852
+ */
5853
+ constructor(...fieldNames) {
5854
+ for (let i = 0; i < fieldNames.length; ++i) {
5855
+ if (fieldNames[i].length === 0) {
5856
+ throw new FirestoreError(Code.INVALID_ARGUMENT, `Invalid field name at argument $(i + 1). ` +
5857
+ 'Field names must not be empty.');
5858
+ }
5859
+ }
5860
+ this._internalPath = new FieldPath$1(fieldNames);
5861
+ }
5862
+ /**
5863
+ * Returns true if this `FieldPath` is equal to the provided one.
5864
+ *
5865
+ * @param other - The `FieldPath` to compare against.
5866
+ * @returns true if this `FieldPath` is equal to the provided one.
5867
+ */
5868
+ isEqual(other) {
5869
+ return this._internalPath.isEqual(other._internalPath);
5870
+ }
5871
+ }
5872
+ /**
5873
+ * Returns a special sentinel `FieldPath` to refer to the ID of a document.
5874
+ * It can be used in queries to sort or filter by the document ID.
5875
+ */
5876
+ function documentId() {
5877
+ return new FieldPath(DOCUMENT_KEY_NAME);
5878
+ }
5879
+
5745
5880
  /**
5746
5881
  * @license
5747
5882
  * Copyright 2020 Google LLC
@@ -7450,6 +7585,58 @@ function addDoc(reference, data) {
7450
7585
  ]).then(() => docRef);
7451
7586
  }
7452
7587
 
7588
+ /**
7589
+ * @license
7590
+ * Copyright 2022 Google LLC
7591
+ *
7592
+ * Licensed under the Apache License, Version 2.0 (the "License");
7593
+ * you may not use this file except in compliance with the License.
7594
+ * You may obtain a copy of the License at
7595
+ *
7596
+ * http://www.apache.org/licenses/LICENSE-2.0
7597
+ *
7598
+ * Unless required by applicable law or agreed to in writing, software
7599
+ * distributed under the License is distributed on an "AS IS" BASIS,
7600
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7601
+ * See the License for the specific language governing permissions and
7602
+ * limitations under the License.
7603
+ */
7604
+ /**
7605
+ * Calculates the number of documents in the result set of the given query,
7606
+ * without actually downloading the documents.
7607
+ *
7608
+ * Using this function to count the documents is efficient because only the
7609
+ * final count, not the documents' data, is downloaded. This function can even
7610
+ * count the documents if the result set would be prohibitively large to
7611
+ * download entirely (e.g. thousands of documents).
7612
+ *
7613
+ * @param query - The query whose result set size to calculate.
7614
+ * @returns A Promise that will be resolved with the count; the count can be
7615
+ * retrieved from `snapshot.data().count`, where `snapshot` is the
7616
+ * `AggregateQuerySnapshot` to which the returned Promise resolves.
7617
+ */
7618
+ function getCount(query) {
7619
+ const firestore = cast(query.firestore, Firestore);
7620
+ const datastore = getDatastore(firestore);
7621
+ const userDataWriter = new LiteUserDataWriter(firestore);
7622
+ return new CountQueryRunner(query, datastore, userDataWriter).run();
7623
+ }
7624
+ /**
7625
+ * Compares two `AggregateQuerySnapshot` instances for equality.
7626
+ *
7627
+ * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
7628
+ * underlying queries that compare equal, and the same data.
7629
+ *
7630
+ * @param left - The first `AggregateQuerySnapshot` to compare.
7631
+ * @param right - The second `AggregateQuerySnapshot` to compare.
7632
+ *
7633
+ * @returns `true` if the objects are "equal", as defined above, or `false`
7634
+ * otherwise.
7635
+ */
7636
+ function aggregateQuerySnapshotEqual(left, right) {
7637
+ return (queryEqual(left.query, right.query) && deepEqual(left.data(), right.data()));
7638
+ }
7639
+
7453
7640
  /**
7454
7641
  * @license
7455
7642
  * Copyright 2020 Google LLC
@@ -8442,5 +8629,5 @@ function runTransaction(firestore, updateFunction, options) {
8442
8629
  */
8443
8630
  registerFirestore();
8444
8631
 
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 };
8632
+ 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
8633
  //# sourceMappingURL=index.node.mjs.map