@firebase/firestore 3.4.4-canary.dd86989b3 → 3.4.4-canary.e8972ef49

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 (79) hide show
  1. package/dist/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  2. package/dist/firestore/src/api.d.ts +1 -1
  3. package/dist/firestore/src/core/database_info.d.ts +1 -0
  4. package/dist/firestore/src/core/target.d.ts +34 -5
  5. package/dist/firestore/src/lite-api/query.d.ts +2 -2
  6. package/dist/firestore/src/local/index_manager.d.ts +52 -0
  7. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  8. package/dist/firestore/src/local/indexeddb_schema.d.ts +121 -7
  9. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  10. package/dist/firestore/src/model/field_index.d.ts +4 -0
  11. package/dist/firestore/src/model/values.d.ts +7 -0
  12. package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
  13. package/dist/firestore/test/util/helpers.d.ts +2 -2
  14. package/dist/index.esm2017.js +2626 -2469
  15. package/dist/index.esm2017.js.map +1 -1
  16. package/dist/index.esm5.js +2627 -2547
  17. package/dist/index.esm5.js.map +1 -1
  18. package/dist/index.node.cjs.js +456 -279
  19. package/dist/index.node.cjs.js.map +1 -1
  20. package/dist/index.node.mjs +456 -279
  21. package/dist/index.node.mjs.map +1 -1
  22. package/dist/index.rn.js +2652 -2491
  23. package/dist/index.rn.js.map +1 -1
  24. package/dist/internal.d.ts +171 -2
  25. package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  26. package/dist/lite/firestore/src/api.d.ts +1 -1
  27. package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
  28. package/dist/lite/firestore/src/core/target.d.ts +34 -5
  29. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  30. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  31. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  32. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +121 -7
  33. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  34. package/dist/lite/firestore/src/model/field_index.d.ts +4 -0
  35. package/dist/lite/firestore/src/model/values.d.ts +7 -0
  36. package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
  37. package/dist/lite/firestore/test/util/helpers.d.ts +2 -2
  38. package/dist/lite/index.browser.esm2017.js +1159 -1152
  39. package/dist/lite/index.browser.esm2017.js.map +1 -1
  40. package/dist/lite/index.browser.esm5.js +311 -308
  41. package/dist/lite/index.browser.esm5.js.map +1 -1
  42. package/dist/lite/index.node.cjs.js +39 -28
  43. package/dist/lite/index.node.cjs.js.map +1 -1
  44. package/dist/lite/index.node.mjs +39 -28
  45. package/dist/lite/index.node.mjs.map +1 -1
  46. package/dist/lite/index.rn.esm2017.js +360 -353
  47. package/dist/lite/index.rn.esm2017.js.map +1 -1
  48. package/dist/lite/internal.d.ts +3 -2
  49. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +125 -124
  50. package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  51. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  52. package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
  53. package/dist/lite/packages/firestore/src/core/target.d.ts +34 -5
  54. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  55. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  56. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  57. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
  58. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  59. package/dist/lite/packages/firestore/src/model/field_index.d.ts +4 -0
  60. package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
  61. package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  62. package/dist/lite/packages/firestore/test/util/helpers.d.ts +2 -2
  63. package/dist/lite/private.d.ts +2 -2
  64. package/dist/packages/firestore/dist/index.esm2017.d.ts +148 -147
  65. package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
  66. package/dist/packages/firestore/src/api.d.ts +1 -1
  67. package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
  68. package/dist/packages/firestore/src/core/target.d.ts +34 -5
  69. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  70. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  71. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  72. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
  73. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  74. package/dist/packages/firestore/src/model/field_index.d.ts +4 -0
  75. package/dist/packages/firestore/src/model/values.d.ts +7 -0
  76. package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
  77. package/dist/packages/firestore/test/util/helpers.d.ts +2 -2
  78. package/dist/private.d.ts +170 -2
  79. package/package.json +9 -9
@@ -12,7 +12,7 @@ var grpcJs = require('@grpc/grpc-js');
12
12
  var protoLoader = require('@grpc/proto-loader');
13
13
 
14
14
  const name = "@firebase/firestore";
15
- const version$1 = "3.4.4-canary.dd86989b3";
15
+ const version$1 = "3.4.4-canary.e8972ef49";
16
16
 
17
17
  /**
18
18
  * @license
@@ -65,7 +65,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
65
65
  User.FIRST_PARTY = new User('first-party-uid');
66
66
  User.MOCK_USER = new User('mock-user');
67
67
 
68
- const version = "9.6.5-canary.dd86989b3";
68
+ const version = "9.6.5-canary.e8972ef49";
69
69
 
70
70
  /**
71
71
  * @license
@@ -1196,23 +1196,6 @@ function decodeResourcePath(path) {
1196
1196
  }
1197
1197
  return new ResourcePath(segments);
1198
1198
  }
1199
-
1200
- /**
1201
- * @license
1202
- * Copyright 2017 Google LLC
1203
- *
1204
- * Licensed under the Apache License, Version 2.0 (the "License");
1205
- * you may not use this file except in compliance with the License.
1206
- * You may obtain a copy of the License at
1207
- *
1208
- * http://www.apache.org/licenses/LICENSE-2.0
1209
- *
1210
- * Unless required by applicable law or agreed to in writing, software
1211
- * distributed under the License is distributed on an "AS IS" BASIS,
1212
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1213
- * See the License for the specific language governing permissions and
1214
- * limitations under the License.
1215
- */
1216
1199
  /**
1217
1200
  * Schema Version for the Web client:
1218
1201
  * 1. Initial version including Mutation Queue, Query Cache, and Remote
@@ -1231,6 +1214,7 @@ function decodeResourcePath(path) {
1231
1214
  * an auto-incrementing ID. This is required for Index-Free queries.
1232
1215
  * 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
1233
1216
  * 11. Add bundles and named_queries for bundle support.
1217
+ * 12. Add indexing support.
1234
1218
  */
1235
1219
  const SCHEMA_VERSION = 11;
1236
1220
  /**
@@ -1757,9 +1741,7 @@ class DbClientMetadata {
1757
1741
  DbClientMetadata.store = 'clientMetadata';
1758
1742
  /** Keys are automatically assigned via the clientId properties. */
1759
1743
  DbClientMetadata.keyPath = 'clientId';
1760
- /**
1761
- * A object representing a bundle loaded by the SDK.
1762
- */
1744
+ /** An object representing a bundle loaded by the SDK. */
1763
1745
  class DbBundle {
1764
1746
  constructor(
1765
1747
  /** The ID of the loaded bundle. */
@@ -1776,9 +1758,7 @@ class DbBundle {
1776
1758
  /** Name of the IndexedDb object store. */
1777
1759
  DbBundle.store = 'bundles';
1778
1760
  DbBundle.keyPath = 'bundleId';
1779
- /**
1780
- * A object representing a named query loaded by the SDK via a bundle.
1781
- */
1761
+ /** An object representing a named query loaded by the SDK via a bundle. */
1782
1762
  class DbNamedQuery {
1783
1763
  constructor(
1784
1764
  /** The name of the query. */
@@ -1795,6 +1775,93 @@ class DbNamedQuery {
1795
1775
  /** Name of the IndexedDb object store. */
1796
1776
  DbNamedQuery.store = 'namedQueries';
1797
1777
  DbNamedQuery.keyPath = 'name';
1778
+ /** An object representing the global configuration for a field index. */
1779
+ class DbIndexConfiguration {
1780
+ constructor(
1781
+ /** The index id for this entry. */
1782
+ indexId,
1783
+ /** The collection group this index belongs to. */
1784
+ collectionGroup,
1785
+ /** The fields to index for this index. */
1786
+ fields) {
1787
+ this.indexId = indexId;
1788
+ this.collectionGroup = collectionGroup;
1789
+ this.fields = fields;
1790
+ }
1791
+ }
1792
+ /** Name of the IndexedDb object store. */
1793
+ DbIndexConfiguration.store = 'indexConfiguration';
1794
+ DbIndexConfiguration.keyPath = 'indexId';
1795
+ /**
1796
+ * An object describing how up-to-date the index backfill is for each user and
1797
+ * index.
1798
+ */
1799
+ class DbIndexState {
1800
+ constructor(
1801
+ /** The index id for this entry. */
1802
+ indexId,
1803
+ /** The user id for this entry. */
1804
+ uid,
1805
+ /**
1806
+ * A number that indicates when the index was last updated (relative to
1807
+ * other indexes).
1808
+ */
1809
+ sequenceNumber,
1810
+ /**
1811
+ * The latest read time that has been indexed by Firestore for this field
1812
+ * index. Set to `{seconds: 0, nanos: 0}` if no documents have been indexed.
1813
+ */
1814
+ readTime,
1815
+ /**
1816
+ * The last document that has been indexed for this field index. Empty if
1817
+ * no documents have been indexed.
1818
+ */
1819
+ documentKey,
1820
+ /**
1821
+ * The largest mutation batch id that has been processed for this index. -1
1822
+ * if no mutations have been indexed.
1823
+ */
1824
+ largestBatchId) {
1825
+ this.indexId = indexId;
1826
+ this.uid = uid;
1827
+ this.sequenceNumber = sequenceNumber;
1828
+ this.readTime = readTime;
1829
+ this.documentKey = documentKey;
1830
+ this.largestBatchId = largestBatchId;
1831
+ }
1832
+ }
1833
+ /** Name of the IndexedDb object store. */
1834
+ DbIndexState.store = 'indexState';
1835
+ DbIndexState.keyPath = ['indexId', 'uid'];
1836
+ /** An object that stores the encoded entries for all documents and fields. */
1837
+ class DbIndexEntries {
1838
+ constructor(
1839
+ /** The index id for this entry. */
1840
+ indexId,
1841
+ /** The user id for this entry. */
1842
+ uid,
1843
+ /** The encoded array index value for this entry. */
1844
+ arrayValue,
1845
+ /** The encoded directional value for equality and inequality filters. */
1846
+ directionalValue,
1847
+ /** The document key this entry points to. */
1848
+ documentKey) {
1849
+ this.indexId = indexId;
1850
+ this.uid = uid;
1851
+ this.arrayValue = arrayValue;
1852
+ this.directionalValue = directionalValue;
1853
+ this.documentKey = documentKey;
1854
+ }
1855
+ }
1856
+ /** Name of the IndexedDb object store. */
1857
+ DbIndexEntries.store = 'indexEntries';
1858
+ DbIndexEntries.keyPath = [
1859
+ 'indexId',
1860
+ 'uid',
1861
+ 'arrayValue',
1862
+ 'directionalValue',
1863
+ 'documentKey'
1864
+ ];
1798
1865
  // Visible for testing
1799
1866
  const V1_STORES = [
1800
1867
  DbMutationQueue.store,
@@ -1809,7 +1876,6 @@ const V1_STORES = [
1809
1876
  // V2 is no longer usable (see comment at top of file)
1810
1877
  // Visible for testing
1811
1878
  const V3_STORES = V1_STORES;
1812
- // Visible for testing
1813
1879
  // Note: DbRemoteDocumentChanges is no longer used and dropped with v9.
1814
1880
  const V4_STORES = [...V3_STORES, DbClientMetadata.store];
1815
1881
  // V5 does not change the set of stores.
@@ -1819,6 +1885,12 @@ const V8_STORES = [...V6_STORES, DbCollectionParent.store];
1819
1885
  // V9 does not change the set of stores.
1820
1886
  // V10 does not change the set of stores.
1821
1887
  const V11_STORES = [...V8_STORES, DbBundle.store, DbNamedQuery.store];
1888
+ [
1889
+ ...V11_STORES,
1890
+ DbIndexConfiguration.store,
1891
+ DbIndexState.store,
1892
+ DbIndexEntries.store
1893
+ ];
1822
1894
  /**
1823
1895
  * The list of all default IndexedDB stores used throughout the SDK. This is
1824
1896
  * used when creating transactions so that access across all stores is done
@@ -3378,6 +3450,75 @@ function getLocalWriteTime(value) {
3378
3450
  return new Timestamp(localWriteTime.seconds, localWriteTime.nanos);
3379
3451
  }
3380
3452
 
3453
+ /**
3454
+ * @license
3455
+ * Copyright 2017 Google LLC
3456
+ *
3457
+ * Licensed under the Apache License, Version 2.0 (the "License");
3458
+ * you may not use this file except in compliance with the License.
3459
+ * You may obtain a copy of the License at
3460
+ *
3461
+ * http://www.apache.org/licenses/LICENSE-2.0
3462
+ *
3463
+ * Unless required by applicable law or agreed to in writing, software
3464
+ * distributed under the License is distributed on an "AS IS" BASIS,
3465
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3466
+ * See the License for the specific language governing permissions and
3467
+ * limitations under the License.
3468
+ */
3469
+ class DatabaseInfo {
3470
+ /**
3471
+ * Constructs a DatabaseInfo using the provided host, databaseId and
3472
+ * persistenceKey.
3473
+ *
3474
+ * @param databaseId - The database to use.
3475
+ * @param appId - The Firebase App Id.
3476
+ * @param persistenceKey - A unique identifier for this Firestore's local
3477
+ * storage (used in conjunction with the databaseId).
3478
+ * @param host - The Firestore backend host to connect to.
3479
+ * @param ssl - Whether to use SSL when connecting.
3480
+ * @param forceLongPolling - Whether to use the forceLongPolling option
3481
+ * when using WebChannel as the network transport.
3482
+ * @param autoDetectLongPolling - Whether to use the detectBufferingProxy
3483
+ * option when using WebChannel as the network transport.
3484
+ * @param useFetchStreams Whether to use the Fetch API instead of
3485
+ * XMLHTTPRequest
3486
+ */
3487
+ constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
3488
+ this.databaseId = databaseId;
3489
+ this.appId = appId;
3490
+ this.persistenceKey = persistenceKey;
3491
+ this.host = host;
3492
+ this.ssl = ssl;
3493
+ this.forceLongPolling = forceLongPolling;
3494
+ this.autoDetectLongPolling = autoDetectLongPolling;
3495
+ this.useFetchStreams = useFetchStreams;
3496
+ }
3497
+ }
3498
+ /** The default database name for a project. */
3499
+ const DEFAULT_DATABASE_NAME = '(default)';
3500
+ /**
3501
+ * Represents the database ID a Firestore client is associated with.
3502
+ * @internal
3503
+ */
3504
+ class DatabaseId {
3505
+ constructor(projectId, database) {
3506
+ this.projectId = projectId;
3507
+ this.database = database ? database : DEFAULT_DATABASE_NAME;
3508
+ }
3509
+ static empty() {
3510
+ return new DatabaseId('', '');
3511
+ }
3512
+ get isDefaultDatabase() {
3513
+ return this.database === DEFAULT_DATABASE_NAME;
3514
+ }
3515
+ isEqual(other) {
3516
+ return (other instanceof DatabaseId &&
3517
+ other.projectId === this.projectId &&
3518
+ other.database === this.database);
3519
+ }
3520
+ }
3521
+
3381
3522
  /**
3382
3523
  * @license
3383
3524
  * Copyright 2017 Google LLC
@@ -4233,6 +4374,125 @@ function compareDocumentsByField(field, d1, d2) {
4233
4374
  }
4234
4375
  }
4235
4376
 
4377
+ /**
4378
+ * @license
4379
+ * Copyright 2021 Google LLC
4380
+ *
4381
+ * Licensed under the Apache License, Version 2.0 (the "License");
4382
+ * you may not use this file except in compliance with the License.
4383
+ * You may obtain a copy of the License at
4384
+ *
4385
+ * http://www.apache.org/licenses/LICENSE-2.0
4386
+ *
4387
+ * Unless required by applicable law or agreed to in writing, software
4388
+ * distributed under the License is distributed on an "AS IS" BASIS,
4389
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4390
+ * See the License for the specific language governing permissions and
4391
+ * limitations under the License.
4392
+ */
4393
+ /**
4394
+ * The initial mutation batch id for each index. Gets updated during index
4395
+ * backfill.
4396
+ */
4397
+ const INITIAL_LARGEST_BATCH_ID = -1;
4398
+ /**
4399
+ * The initial sequence number for each index. Gets updated during index
4400
+ * backfill.
4401
+ */
4402
+ const INITIAL_SEQUENCE_NUMBER = 0;
4403
+ /**
4404
+ * An index definition for field indexes in Firestore.
4405
+ *
4406
+ * Every index is associated with a collection. The definition contains a list
4407
+ * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
4408
+ * `CONTAINS` for ArrayContains/ArrayContainsAny queries).
4409
+ *
4410
+ * Unlike the backend, the SDK does not differentiate between collection or
4411
+ * collection group-scoped indices. Every index can be used for both single
4412
+ * collection and collection group queries.
4413
+ */
4414
+ class FieldIndex {
4415
+ constructor(
4416
+ /**
4417
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
4418
+ * has not yet been persisted).
4419
+ */
4420
+ indexId,
4421
+ /** The collection ID this index applies to. */
4422
+ collectionGroup,
4423
+ /** The field segments for this index. */
4424
+ segments,
4425
+ /** Shows how up-to-date the index is for the current user. */
4426
+ indexState) {
4427
+ this.indexId = indexId;
4428
+ this.collectionGroup = collectionGroup;
4429
+ this.segments = segments;
4430
+ this.indexState = indexState;
4431
+ }
4432
+ }
4433
+ /** An ID for an index that has not yet been added to persistence. */
4434
+ FieldIndex.UNKNOWN_ID = -1;
4435
+ /** An index component consisting of field path and index type. */
4436
+ class IndexSegment {
4437
+ constructor(
4438
+ /** The field path of the component. */
4439
+ fieldPath,
4440
+ /** The fields sorting order. */
4441
+ kind) {
4442
+ this.fieldPath = fieldPath;
4443
+ this.kind = kind;
4444
+ }
4445
+ }
4446
+ /**
4447
+ * Stores the "high water mark" that indicates how updated the Index is for the
4448
+ * current user.
4449
+ */
4450
+ class IndexState {
4451
+ constructor(
4452
+ /**
4453
+ * Indicates when the index was last updated (relative to other indexes).
4454
+ */
4455
+ sequenceNumber,
4456
+ /** The the latest indexed read time, document and batch id. */
4457
+ offset) {
4458
+ this.sequenceNumber = sequenceNumber;
4459
+ this.offset = offset;
4460
+ }
4461
+ /** The state of an index that has not yet been backfilled. */
4462
+ static empty() {
4463
+ return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
4464
+ }
4465
+ }
4466
+ /**
4467
+ * Stores the latest read time, document and batch ID that were processed for an
4468
+ * index.
4469
+ */
4470
+ class IndexOffset {
4471
+ constructor(
4472
+ /**
4473
+ * The latest read time version that has been indexed by Firestore for this
4474
+ * field index.
4475
+ */
4476
+ readTime,
4477
+ /**
4478
+ * The key of the last document that was indexed for this query. Use
4479
+ * `DocumentKey.empty()` if no document has been indexed.
4480
+ */
4481
+ documentKey,
4482
+ /*
4483
+ * The largest mutation batch id that's been processed by Firestore.
4484
+ */
4485
+ largestBatchId) {
4486
+ this.readTime = readTime;
4487
+ this.documentKey = documentKey;
4488
+ this.largestBatchId = largestBatchId;
4489
+ }
4490
+ /** The state of an index that has not yet been backfilled. */
4491
+ static min() {
4492
+ return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
4493
+ }
4494
+ }
4495
+
4236
4496
  /**
4237
4497
  * @license
4238
4498
  * Copyright 2019 Google LLC
@@ -4276,27 +4536,29 @@ function newTarget(path, collectionGroup = null, orderBy = [], filters = [], lim
4276
4536
  function canonifyTarget(target) {
4277
4537
  const targetImpl = debugCast(target);
4278
4538
  if (targetImpl.memoizedCanonicalId === null) {
4279
- let canonicalId = targetImpl.path.canonicalString();
4539
+ let str = targetImpl.path.canonicalString();
4280
4540
  if (targetImpl.collectionGroup !== null) {
4281
- canonicalId += '|cg:' + targetImpl.collectionGroup;
4541
+ str += '|cg:' + targetImpl.collectionGroup;
4282
4542
  }
4283
- canonicalId += '|f:';
4284
- canonicalId += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
4285
- canonicalId += '|ob:';
4286
- canonicalId += targetImpl.orderBy.map(o => canonifyOrderBy(o)).join(',');
4543
+ str += '|f:';
4544
+ str += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
4545
+ str += '|ob:';
4546
+ str += targetImpl.orderBy.map(o => canonifyOrderBy(o)).join(',');
4287
4547
  if (!isNullOrUndefined(targetImpl.limit)) {
4288
- canonicalId += '|l:';
4289
- canonicalId += targetImpl.limit;
4548
+ str += '|l:';
4549
+ str += targetImpl.limit;
4290
4550
  }
4291
4551
  if (targetImpl.startAt) {
4292
- canonicalId += '|lb:';
4293
- canonicalId += canonifyBound(targetImpl.startAt);
4552
+ str += '|lb:';
4553
+ str += targetImpl.startAt.inclusive ? 'b:' : 'a:';
4554
+ str += targetImpl.startAt.position.map(p => canonicalId(p)).join(',');
4294
4555
  }
4295
4556
  if (targetImpl.endAt) {
4296
- canonicalId += '|ub:';
4297
- canonicalId += canonifyBound(targetImpl.endAt);
4557
+ str += '|ub:';
4558
+ str += targetImpl.endAt.inclusive ? 'a:' : 'b:';
4559
+ str += targetImpl.endAt.position.map(p => canonicalId(p)).join(',');
4298
4560
  }
4299
- targetImpl.memoizedCanonicalId = canonicalId;
4561
+ targetImpl.memoizedCanonicalId = str;
4300
4562
  }
4301
4563
  return targetImpl.memoizedCanonicalId;
4302
4564
  }
@@ -4319,10 +4581,14 @@ function stringifyTarget(target) {
4319
4581
  .join(', ')}]`;
4320
4582
  }
4321
4583
  if (target.startAt) {
4322
- str += ', startAt: ' + canonifyBound(target.startAt);
4584
+ str += ', startAt: ';
4585
+ str += target.startAt.inclusive ? 'b:' : 'a:';
4586
+ str += target.startAt.position.map(p => canonicalId(p)).join(',');
4323
4587
  }
4324
4588
  if (target.endAt) {
4325
- str += ', endAt: ' + canonifyBound(target.endAt);
4589
+ str += ', endAt: ';
4590
+ str += target.endAt.inclusive ? 'a:' : 'b:';
4591
+ str += target.endAt.position.map(p => canonicalId(p)).join(',');
4326
4592
  }
4327
4593
  return `Target(${str})`;
4328
4594
  }
@@ -4357,7 +4623,7 @@ function targetEquals(left, right) {
4357
4623
  }
4358
4624
  return boundEquals(left.endAt, right.endAt);
4359
4625
  }
4360
- function isDocumentTarget(target) {
4626
+ function targetIsDocumentTarget(target) {
4361
4627
  return (DocumentKey.isDocumentKey(target.path) &&
4362
4628
  target.collectionGroup === null &&
4363
4629
  target.filters.length === 0);
@@ -4560,17 +4826,11 @@ class ArrayContainsAnyFilter extends FieldFilter {
4560
4826
  * just after the provided values.
4561
4827
  */
4562
4828
  class Bound {
4563
- constructor(position, before) {
4829
+ constructor(position, inclusive) {
4564
4830
  this.position = position;
4565
- this.before = before;
4831
+ this.inclusive = inclusive;
4566
4832
  }
4567
4833
  }
4568
- function canonifyBound(bound) {
4569
- // TODO(b/29183165): Make this collision robust.
4570
- return `${bound.before ? 'b' : 'a'}:${bound.position
4571
- .map(p => canonicalId(p))
4572
- .join(',')}`;
4573
- }
4574
4834
  /**
4575
4835
  * An ordering on a field, in some Direction. Direction defaults to ASCENDING.
4576
4836
  */
@@ -4590,11 +4850,7 @@ function stringifyOrderBy(orderBy) {
4590
4850
  function orderByEquals(left, right) {
4591
4851
  return left.dir === right.dir && left.field.isEqual(right.field);
4592
4852
  }
4593
- /**
4594
- * Returns true if a document sorts before a bound using the provided sort
4595
- * order.
4596
- */
4597
- function sortsBeforeDocument(bound, orderBy, doc) {
4853
+ function boundCompareToDocument(bound, orderBy, doc) {
4598
4854
  let comparison = 0;
4599
4855
  for (let i = 0; i < bound.position.length; i++) {
4600
4856
  const orderByComponent = orderBy[i];
@@ -4613,7 +4869,23 @@ function sortsBeforeDocument(bound, orderBy, doc) {
4613
4869
  break;
4614
4870
  }
4615
4871
  }
4616
- return bound.before ? comparison <= 0 : comparison < 0;
4872
+ return comparison;
4873
+ }
4874
+ /**
4875
+ * Returns true if a document sorts after a bound using the provided sort
4876
+ * order.
4877
+ */
4878
+ function boundSortsAfterDocument(bound, orderBy, doc) {
4879
+ const comparison = boundCompareToDocument(bound, orderBy, doc);
4880
+ return bound.inclusive ? comparison >= 0 : comparison > 0;
4881
+ }
4882
+ /**
4883
+ * Returns true if a document sorts before a bound using the provided sort
4884
+ * order.
4885
+ */
4886
+ function boundSortsBeforeDocument(bound, orderBy, doc) {
4887
+ const comparison = boundCompareToDocument(bound, orderBy, doc);
4888
+ return bound.inclusive ? comparison <= 0 : comparison < 0;
4617
4889
  }
4618
4890
  function boundEquals(left, right) {
4619
4891
  if (left === null) {
@@ -4622,7 +4894,7 @@ function boundEquals(left, right) {
4622
4894
  else if (right === null) {
4623
4895
  return false;
4624
4896
  }
4625
- if (left.before !== right.before ||
4897
+ if (left.inclusive !== right.inclusive ||
4626
4898
  left.position.length !== right.position.length) {
4627
4899
  return false;
4628
4900
  }
@@ -4826,10 +5098,10 @@ function queryToTarget(query) {
4826
5098
  }
4827
5099
  // We need to swap the cursors to match the now-flipped query ordering.
4828
5100
  const startAt = queryImpl.endAt
4829
- ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.before)
5101
+ ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.inclusive)
4830
5102
  : null;
4831
5103
  const endAt = queryImpl.startAt
4832
- ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.before)
5104
+ ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
4833
5105
  : null;
4834
5106
  // Now return as a LimitType.First query.
4835
5107
  queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
@@ -4917,11 +5189,11 @@ function queryMatchesFilters(query, doc) {
4917
5189
  /** Makes sure a document is within the bounds, if provided. */
4918
5190
  function queryMatchesBounds(query, doc) {
4919
5191
  if (query.startAt &&
4920
- !sortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
5192
+ !boundSortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
4921
5193
  return false;
4922
5194
  }
4923
5195
  if (query.endAt &&
4924
- sortsBeforeDocument(query.endAt, queryOrderBy(query), doc)) {
5196
+ !boundSortsAfterDocument(query.endAt, queryOrderBy(query), doc)) {
4925
5197
  return false;
4926
5198
  }
4927
5199
  return true;
@@ -7002,7 +7274,7 @@ class WatchChangeAggregator {
7002
7274
  const targetData = this.targetDataForActiveTarget(targetId);
7003
7275
  if (targetData) {
7004
7276
  const target = targetData.target;
7005
- if (isDocumentTarget(target)) {
7277
+ if (targetIsDocumentTarget(target)) {
7006
7278
  if (expectedCount === 0) {
7007
7279
  // The existence filter told us the document does not exist. We deduce
7008
7280
  // that this document does not exist and apply a deleted document to
@@ -7037,7 +7309,7 @@ class WatchChangeAggregator {
7037
7309
  this.targetStates.forEach((targetState, targetId) => {
7038
7310
  const targetData = this.targetDataForActiveTarget(targetId);
7039
7311
  if (targetData) {
7040
- if (targetState.current && isDocumentTarget(targetData.target)) {
7312
+ if (targetState.current && targetIsDocumentTarget(targetData.target)) {
7041
7313
  // Document queries for document that don't exist can produce an empty
7042
7314
  // result set. To update our local cache, we synthesize a document
7043
7315
  // delete if we have not previously received the document. This
@@ -7800,10 +8072,10 @@ function toQueryTarget(serializer, target) {
7800
8072
  result.structuredQuery.limit = limit;
7801
8073
  }
7802
8074
  if (target.startAt) {
7803
- result.structuredQuery.startAt = toCursor(target.startAt);
8075
+ result.structuredQuery.startAt = toStartAtCursor(target.startAt);
7804
8076
  }
7805
8077
  if (target.endAt) {
7806
- result.structuredQuery.endAt = toCursor(target.endAt);
8078
+ result.structuredQuery.endAt = toEndAtCursor(target.endAt);
7807
8079
  }
7808
8080
  return result;
7809
8081
  }
@@ -7836,11 +8108,11 @@ function convertQueryTargetToQuery(target) {
7836
8108
  }
7837
8109
  let startAt = null;
7838
8110
  if (query.startAt) {
7839
- startAt = fromCursor(query.startAt);
8111
+ startAt = fromStartAtCursor(query.startAt);
7840
8112
  }
7841
8113
  let endAt = null;
7842
8114
  if (query.endAt) {
7843
- endAt = fromCursor(query.endAt);
8115
+ endAt = fromEndAtCursor(query.endAt);
7844
8116
  }
7845
8117
  return newQuery(path, collectionGroup, orderBy, filterBy, limit, "F" /* First */, startAt, endAt);
7846
8118
  }
@@ -7873,7 +8145,7 @@ function toLabel(serializer, purpose) {
7873
8145
  function toTarget(serializer, targetData) {
7874
8146
  let result;
7875
8147
  const target = targetData.target;
7876
- if (isDocumentTarget(target)) {
8148
+ if (targetIsDocumentTarget(target)) {
7877
8149
  result = { documents: toDocumentsTarget(serializer, target) };
7878
8150
  }
7879
8151
  else {
@@ -7931,16 +8203,27 @@ function toOrder(orderBys) {
7931
8203
  function fromOrder(orderBys) {
7932
8204
  return orderBys.map(order => fromPropertyOrder(order));
7933
8205
  }
7934
- function toCursor(cursor) {
8206
+ function toStartAtCursor(cursor) {
7935
8207
  return {
7936
- before: cursor.before,
8208
+ before: cursor.inclusive,
7937
8209
  values: cursor.position
7938
8210
  };
7939
8211
  }
7940
- function fromCursor(cursor) {
7941
- const before = !!cursor.before;
8212
+ function toEndAtCursor(cursor) {
8213
+ return {
8214
+ before: !cursor.inclusive,
8215
+ values: cursor.position
8216
+ };
8217
+ }
8218
+ function fromStartAtCursor(cursor) {
8219
+ const inclusive = !!cursor.before;
7942
8220
  const position = cursor.values || [];
7943
- return new Bound(position, before);
8221
+ return new Bound(position, inclusive);
8222
+ }
8223
+ function fromEndAtCursor(cursor) {
8224
+ const inclusive = !cursor.before;
8225
+ const position = cursor.values || [];
8226
+ return new Bound(position, inclusive);
7944
8227
  }
7945
8228
  // visible for testing
7946
8229
  function toDirection(dir) {
@@ -8323,7 +8606,7 @@ function toDbTarget(localSerializer, targetData) {
8323
8606
  const dbTimestamp = toDbTimestamp(targetData.snapshotVersion);
8324
8607
  const dbLastLimboFreeTimestamp = toDbTimestamp(targetData.lastLimboFreeSnapshotVersion);
8325
8608
  let queryProto;
8326
- if (isDocumentTarget(targetData.target)) {
8609
+ if (targetIsDocumentTarget(targetData.target)) {
8327
8610
  queryProto = toDocumentsTarget(localSerializer.remoteSerializer, targetData.target);
8328
8611
  }
8329
8612
  else {
@@ -8493,6 +8776,38 @@ class MemoryIndexManager {
8493
8776
  getCollectionParents(transaction, collectionId) {
8494
8777
  return PersistencePromise.resolve(this.collectionParentIndex.getEntries(collectionId));
8495
8778
  }
8779
+ addFieldIndex(transaction, index) {
8780
+ // Field indices are not supported with memory persistence.
8781
+ return PersistencePromise.resolve();
8782
+ }
8783
+ deleteFieldIndex(transaction, index) {
8784
+ // Field indices are not supported with memory persistence.
8785
+ return PersistencePromise.resolve();
8786
+ }
8787
+ getDocumentsMatchingTarget(transaction, fieldIndex, target) {
8788
+ // Field indices are not supported with memory persistence.
8789
+ return PersistencePromise.resolve(documentKeySet());
8790
+ }
8791
+ getFieldIndex(transaction, target) {
8792
+ // Field indices are not supported with memory persistence.
8793
+ return PersistencePromise.resolve(null);
8794
+ }
8795
+ getFieldIndexes(transaction, collectionGroup) {
8796
+ // Field indices are not supported with memory persistence.
8797
+ return PersistencePromise.resolve([]);
8798
+ }
8799
+ getNextCollectionGroupToUpdate(transaction) {
8800
+ // Field indices are not supported with memory persistence.
8801
+ return PersistencePromise.resolve(null);
8802
+ }
8803
+ updateCollectionGroup(transaction, collectionGroup, offset) {
8804
+ // Field indices are not supported with memory persistence.
8805
+ return PersistencePromise.resolve();
8806
+ }
8807
+ updateIndexEntries(transaction, documents) {
8808
+ // Field indices are not supported with memory persistence.
8809
+ return PersistencePromise.resolve();
8810
+ }
8496
8811
  }
8497
8812
  /**
8498
8813
  * Internal implementation of the collection-parent index exposed by MemoryIndexManager.
@@ -8601,6 +8916,38 @@ class IndexedDbIndexManager {
8601
8916
  return parentPaths;
8602
8917
  });
8603
8918
  }
8919
+ addFieldIndex(transaction, index) {
8920
+ // TODO(indexing): Implement
8921
+ return PersistencePromise.resolve();
8922
+ }
8923
+ deleteFieldIndex(transaction, index) {
8924
+ // TODO(indexing): Implement
8925
+ return PersistencePromise.resolve();
8926
+ }
8927
+ getDocumentsMatchingTarget(transaction, fieldIndex, target) {
8928
+ // TODO(indexing): Implement
8929
+ return PersistencePromise.resolve(documentKeySet());
8930
+ }
8931
+ getFieldIndex(transaction, target) {
8932
+ // TODO(indexing): Implement
8933
+ return PersistencePromise.resolve(null);
8934
+ }
8935
+ getFieldIndexes(transaction, collectionGroup) {
8936
+ // TODO(indexing): Implement
8937
+ return PersistencePromise.resolve([]);
8938
+ }
8939
+ getNextCollectionGroupToUpdate(transaction) {
8940
+ // TODO(indexing): Implement
8941
+ return PersistencePromise.resolve(null);
8942
+ }
8943
+ updateCollectionGroup(transaction, collectionGroup, offset) {
8944
+ // TODO(indexing): Implement
8945
+ return PersistencePromise.resolve();
8946
+ }
8947
+ updateIndexEntries(transaction, documents) {
8948
+ // TODO(indexing): Implement
8949
+ return PersistencePromise.resolve();
8950
+ }
8604
8951
  }
8605
8952
  /**
8606
8953
  * Helper to get a typed SimpleDbStore for the collectionParents
@@ -10452,9 +10799,6 @@ class SchemaConverter {
10452
10799
  * and local feature development.
10453
10800
  */
10454
10801
  createOrUpgrade(db, txn, fromVersion, toVersion) {
10455
- hardAssert(fromVersion < toVersion &&
10456
- fromVersion >= 0 &&
10457
- toVersion <= SCHEMA_VERSION);
10458
10802
  const simpleDbTransaction = new SimpleDbTransaction('createOrUpgrade', txn);
10459
10803
  if (fromVersion < 1 && toVersion >= 1) {
10460
10804
  createPrimaryClientStore(db);
@@ -10521,6 +10865,11 @@ class SchemaConverter {
10521
10865
  createNamedQueriesStore(db);
10522
10866
  });
10523
10867
  }
10868
+ if (fromVersion < 12 && toVersion >= 12) {
10869
+ p = p.next(() => {
10870
+ createFieldIndex(db);
10871
+ });
10872
+ }
10524
10873
  return p;
10525
10874
  }
10526
10875
  addDocumentGlobal(txn) {
@@ -10727,6 +11076,17 @@ function createNamedQueriesStore(db) {
10727
11076
  db.createObjectStore(DbNamedQuery.store, {
10728
11077
  keyPath: DbNamedQuery.keyPath
10729
11078
  });
11079
+ }
11080
+ function createFieldIndex(db) {
11081
+ db.createObjectStore(DbIndexConfiguration.store, {
11082
+ keyPath: DbIndexConfiguration.keyPath
11083
+ });
11084
+ db.createObjectStore(DbIndexState.store, {
11085
+ keyPath: DbIndexState.keyPath
11086
+ });
11087
+ db.createObjectStore(DbIndexEntries.store, {
11088
+ keyPath: DbIndexEntries.keyPath
11089
+ });
10730
11090
  }
10731
11091
 
10732
11092
  /**
@@ -22295,72 +22655,6 @@ function createBundleReader(data, serializer) {
22295
22655
  return newBundleReader(toByteStreamReader(content), serializer);
22296
22656
  }
22297
22657
 
22298
- /**
22299
- * @license
22300
- * Copyright 2017 Google LLC
22301
- *
22302
- * Licensed under the Apache License, Version 2.0 (the "License");
22303
- * you may not use this file except in compliance with the License.
22304
- * You may obtain a copy of the License at
22305
- *
22306
- * http://www.apache.org/licenses/LICENSE-2.0
22307
- *
22308
- * Unless required by applicable law or agreed to in writing, software
22309
- * distributed under the License is distributed on an "AS IS" BASIS,
22310
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22311
- * See the License for the specific language governing permissions and
22312
- * limitations under the License.
22313
- */
22314
- class DatabaseInfo {
22315
- /**
22316
- * Constructs a DatabaseInfo using the provided host, databaseId and
22317
- * persistenceKey.
22318
- *
22319
- * @param databaseId - The database to use.
22320
- * @param appId - The Firebase App Id.
22321
- * @param persistenceKey - A unique identifier for this Firestore's local
22322
- * storage (used in conjunction with the databaseId).
22323
- * @param host - The Firestore backend host to connect to.
22324
- * @param ssl - Whether to use SSL when connecting.
22325
- * @param forceLongPolling - Whether to use the forceLongPolling option
22326
- * when using WebChannel as the network transport.
22327
- * @param autoDetectLongPolling - Whether to use the detectBufferingProxy
22328
- * option when using WebChannel as the network transport.
22329
- * @param useFetchStreams Whether to use the Fetch API instead of
22330
- * XMLHTTPRequest
22331
- */
22332
- constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
22333
- this.databaseId = databaseId;
22334
- this.appId = appId;
22335
- this.persistenceKey = persistenceKey;
22336
- this.host = host;
22337
- this.ssl = ssl;
22338
- this.forceLongPolling = forceLongPolling;
22339
- this.autoDetectLongPolling = autoDetectLongPolling;
22340
- this.useFetchStreams = useFetchStreams;
22341
- }
22342
- }
22343
- /** The default database name for a project. */
22344
- const DEFAULT_DATABASE_NAME = '(default)';
22345
- /**
22346
- * Represents the database ID a Firestore client is associated with.
22347
- * @internal
22348
- */
22349
- class DatabaseId {
22350
- constructor(projectId, database) {
22351
- this.projectId = projectId;
22352
- this.database = database ? database : DEFAULT_DATABASE_NAME;
22353
- }
22354
- get isDefaultDatabase() {
22355
- return this.database === DEFAULT_DATABASE_NAME;
22356
- }
22357
- isEqual(other) {
22358
- return (other instanceof DatabaseId &&
22359
- other.projectId === this.projectId &&
22360
- other.database === this.database);
22361
- }
22362
- }
22363
-
22364
22658
  /**
22365
22659
  * @license
22366
22660
  * Copyright 2020 Google LLC
@@ -25109,51 +25403,53 @@ function limitToLast(limit) {
25109
25403
  return new QueryLimitConstraint('limitToLast', limit, "L" /* Last */);
25110
25404
  }
25111
25405
  class QueryStartAtConstraint extends QueryConstraint {
25112
- constructor(type, _docOrFields, _before) {
25406
+ constructor(type, _docOrFields, _inclusive) {
25113
25407
  super();
25114
25408
  this.type = type;
25115
25409
  this._docOrFields = _docOrFields;
25116
- this._before = _before;
25410
+ this._inclusive = _inclusive;
25117
25411
  }
25118
25412
  _apply(query) {
25119
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
25413
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
25120
25414
  return new Query(query.firestore, query.converter, queryWithStartAt(query._query, bound));
25121
25415
  }
25122
25416
  }
25123
25417
  function startAt(...docOrFields) {
25124
- return new QueryStartAtConstraint('startAt', docOrFields, /*before=*/ true);
25418
+ return new QueryStartAtConstraint('startAt', docOrFields,
25419
+ /*inclusive=*/ true);
25125
25420
  }
25126
25421
  function startAfter(...docOrFields) {
25127
25422
  return new QueryStartAtConstraint('startAfter', docOrFields,
25128
- /*before=*/ false);
25423
+ /*inclusive=*/ false);
25129
25424
  }
25130
25425
  class QueryEndAtConstraint extends QueryConstraint {
25131
- constructor(type, _docOrFields, _before) {
25426
+ constructor(type, _docOrFields, _inclusive) {
25132
25427
  super();
25133
25428
  this.type = type;
25134
25429
  this._docOrFields = _docOrFields;
25135
- this._before = _before;
25430
+ this._inclusive = _inclusive;
25136
25431
  }
25137
25432
  _apply(query) {
25138
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
25433
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
25139
25434
  return new Query(query.firestore, query.converter, queryWithEndAt(query._query, bound));
25140
25435
  }
25141
25436
  }
25142
25437
  function endBefore(...docOrFields) {
25143
- return new QueryEndAtConstraint('endBefore', docOrFields, /*before=*/ true);
25438
+ return new QueryEndAtConstraint('endBefore', docOrFields,
25439
+ /*inclusive=*/ false);
25144
25440
  }
25145
25441
  function endAt(...docOrFields) {
25146
- return new QueryEndAtConstraint('endAt', docOrFields, /*before=*/ false);
25442
+ return new QueryEndAtConstraint('endAt', docOrFields, /*inclusive=*/ true);
25147
25443
  }
25148
25444
  /** Helper function to create a bound from a document or fields */
25149
- function newQueryBoundFromDocOrFields(query, methodName, docOrFields, before) {
25445
+ function newQueryBoundFromDocOrFields(query, methodName, docOrFields, inclusive) {
25150
25446
  docOrFields[0] = util$1.getModularInstance(docOrFields[0]);
25151
25447
  if (docOrFields[0] instanceof DocumentSnapshot$1) {
25152
- return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, before);
25448
+ return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, inclusive);
25153
25449
  }
25154
25450
  else {
25155
25451
  const reader = newUserDataReader(query.firestore);
25156
- return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, before);
25452
+ return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, inclusive);
25157
25453
  }
25158
25454
  }
25159
25455
  function newQueryFilter(query, methodName, dataReader, databaseId, fieldPath, op, value) {
@@ -25211,7 +25507,7 @@ function newQueryOrderBy(query, fieldPath, direction) {
25211
25507
  * of the query or if any of the fields in the order by are an uncommitted
25212
25508
  * server timestamp.
25213
25509
  */
25214
- function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
25510
+ function newQueryBoundFromDocument(query, databaseId, methodName, doc, inclusive) {
25215
25511
  if (!doc) {
25216
25512
  throw new FirestoreError(Code.NOT_FOUND, `Can't use a DocumentSnapshot that doesn't exist for ` +
25217
25513
  `${methodName}().`);
@@ -25248,12 +25544,12 @@ function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
25248
25544
  }
25249
25545
  }
25250
25546
  }
25251
- return new Bound(components, before);
25547
+ return new Bound(components, inclusive);
25252
25548
  }
25253
25549
  /**
25254
25550
  * Converts a list of field values to a `Bound` for the given query.
25255
25551
  */
25256
- function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, before) {
25552
+ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, inclusive) {
25257
25553
  // Use explicit order by's because it has to match the query the user made
25258
25554
  const orderBy = query.explicitOrderBy;
25259
25555
  if (values.length > orderBy.length) {
@@ -25290,7 +25586,7 @@ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, valu
25290
25586
  components.push(wrapped);
25291
25587
  }
25292
25588
  }
25293
- return new Bound(components, before);
25589
+ return new Bound(components, inclusive);
25294
25590
  }
25295
25591
  /**
25296
25592
  * Parses the given `documentIdValue` into a `ReferenceValue`, throwing
@@ -26275,125 +26571,6 @@ function writeBatch(firestore) {
26275
26571
  return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations));
26276
26572
  }
26277
26573
 
26278
- /**
26279
- * @license
26280
- * Copyright 2021 Google LLC
26281
- *
26282
- * Licensed under the Apache License, Version 2.0 (the "License");
26283
- * you may not use this file except in compliance with the License.
26284
- * You may obtain a copy of the License at
26285
- *
26286
- * http://www.apache.org/licenses/LICENSE-2.0
26287
- *
26288
- * Unless required by applicable law or agreed to in writing, software
26289
- * distributed under the License is distributed on an "AS IS" BASIS,
26290
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26291
- * See the License for the specific language governing permissions and
26292
- * limitations under the License.
26293
- */
26294
- /**
26295
- * The initial mutation batch id for each index. Gets updated during index
26296
- * backfill.
26297
- */
26298
- const INITIAL_LARGEST_BATCH_ID = -1;
26299
- /**
26300
- * The initial sequence number for each index. Gets updated during index
26301
- * backfill.
26302
- */
26303
- const INITIAL_SEQUENCE_NUMBER = 0;
26304
- /**
26305
- * An index definition for field indexes in Firestore.
26306
- *
26307
- * Every index is associated with a collection. The definition contains a list
26308
- * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
26309
- * `CONTAINS` for ArrayContains/ArrayContainsAny queries).
26310
- *
26311
- * Unlike the backend, the SDK does not differentiate between collection or
26312
- * collection group-scoped indices. Every index can be used for both single
26313
- * collection and collection group queries.
26314
- */
26315
- class FieldIndex {
26316
- constructor(
26317
- /**
26318
- * The index ID. Returns -1 if the index ID is not available (e.g. the index
26319
- * has not yet been persisted).
26320
- */
26321
- indexId,
26322
- /** The collection ID this index applies to. */
26323
- collectionGroup,
26324
- /** The field segments for this index. */
26325
- segments,
26326
- /** Shows how up-to-date the index is for the current user. */
26327
- indexState) {
26328
- this.indexId = indexId;
26329
- this.collectionGroup = collectionGroup;
26330
- this.segments = segments;
26331
- this.indexState = indexState;
26332
- }
26333
- }
26334
- /** An ID for an index that has not yet been added to persistence. */
26335
- FieldIndex.UNKNOWN_ID = -1;
26336
- /** An index component consisting of field path and index type. */
26337
- class IndexSegment {
26338
- constructor(
26339
- /** The field path of the component. */
26340
- fieldPath,
26341
- /** The fields sorting order. */
26342
- kind) {
26343
- this.fieldPath = fieldPath;
26344
- this.kind = kind;
26345
- }
26346
- }
26347
- /**
26348
- * Stores the "high water mark" that indicates how updated the Index is for the
26349
- * current user.
26350
- */
26351
- class IndexState {
26352
- constructor(
26353
- /**
26354
- * Indicates when the index was last updated (relative to other indexes).
26355
- */
26356
- sequenceNumber,
26357
- /** The the latest indexed read time, document and batch id. */
26358
- offset) {
26359
- this.sequenceNumber = sequenceNumber;
26360
- this.offset = offset;
26361
- }
26362
- /** The state of an index that has not yet been backfilled. */
26363
- static empty() {
26364
- return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
26365
- }
26366
- }
26367
- /**
26368
- * Stores the latest read time, document and batch ID that were processed for an
26369
- * index.
26370
- */
26371
- class IndexOffset {
26372
- constructor(
26373
- /**
26374
- * The latest read time version that has been indexed by Firestore for this
26375
- * field index.
26376
- */
26377
- readTime,
26378
- /**
26379
- * The key of the last document that was indexed for this query. Use
26380
- * `DocumentKey.empty()` if no document has been indexed.
26381
- */
26382
- documentKey,
26383
- /*
26384
- * The largest mutation batch id that's been processed by Firestore.
26385
- */
26386
- largestBatchId) {
26387
- this.readTime = readTime;
26388
- this.documentKey = documentKey;
26389
- this.largestBatchId = largestBatchId;
26390
- }
26391
- /** The state of an index that has not yet been backfilled. */
26392
- static min() {
26393
- return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
26394
- }
26395
- }
26396
-
26397
26574
  /**
26398
26575
  * @license
26399
26576
  * Copyright 2021 Google LLC