@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
@@ -8,7 +8,7 @@ import { credentials, loadPackageDefinition, Metadata } from '@grpc/grpc-js';
8
8
  import { fromJSON } from '@grpc/proto-loader';
9
9
 
10
10
  const name = "@firebase/firestore";
11
- const version$1 = "3.4.4-canary.dd86989b3";
11
+ const version$1 = "3.4.4-canary.e8972ef49";
12
12
 
13
13
  /**
14
14
  * @license
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
61
61
  User.FIRST_PARTY = new User('first-party-uid');
62
62
  User.MOCK_USER = new User('mock-user');
63
63
 
64
- const version = "9.6.5-canary.dd86989b3";
64
+ const version = "9.6.5-canary.e8972ef49";
65
65
 
66
66
  /**
67
67
  * @license
@@ -1192,23 +1192,6 @@ function decodeResourcePath(path) {
1192
1192
  }
1193
1193
  return new ResourcePath(segments);
1194
1194
  }
1195
-
1196
- /**
1197
- * @license
1198
- * Copyright 2017 Google LLC
1199
- *
1200
- * Licensed under the Apache License, Version 2.0 (the "License");
1201
- * you may not use this file except in compliance with the License.
1202
- * You may obtain a copy of the License at
1203
- *
1204
- * http://www.apache.org/licenses/LICENSE-2.0
1205
- *
1206
- * Unless required by applicable law or agreed to in writing, software
1207
- * distributed under the License is distributed on an "AS IS" BASIS,
1208
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1209
- * See the License for the specific language governing permissions and
1210
- * limitations under the License.
1211
- */
1212
1195
  /**
1213
1196
  * Schema Version for the Web client:
1214
1197
  * 1. Initial version including Mutation Queue, Query Cache, and Remote
@@ -1227,6 +1210,7 @@ function decodeResourcePath(path) {
1227
1210
  * an auto-incrementing ID. This is required for Index-Free queries.
1228
1211
  * 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
1229
1212
  * 11. Add bundles and named_queries for bundle support.
1213
+ * 12. Add indexing support.
1230
1214
  */
1231
1215
  const SCHEMA_VERSION = 11;
1232
1216
  /**
@@ -1753,9 +1737,7 @@ class DbClientMetadata {
1753
1737
  DbClientMetadata.store = 'clientMetadata';
1754
1738
  /** Keys are automatically assigned via the clientId properties. */
1755
1739
  DbClientMetadata.keyPath = 'clientId';
1756
- /**
1757
- * A object representing a bundle loaded by the SDK.
1758
- */
1740
+ /** An object representing a bundle loaded by the SDK. */
1759
1741
  class DbBundle {
1760
1742
  constructor(
1761
1743
  /** The ID of the loaded bundle. */
@@ -1772,9 +1754,7 @@ class DbBundle {
1772
1754
  /** Name of the IndexedDb object store. */
1773
1755
  DbBundle.store = 'bundles';
1774
1756
  DbBundle.keyPath = 'bundleId';
1775
- /**
1776
- * A object representing a named query loaded by the SDK via a bundle.
1777
- */
1757
+ /** An object representing a named query loaded by the SDK via a bundle. */
1778
1758
  class DbNamedQuery {
1779
1759
  constructor(
1780
1760
  /** The name of the query. */
@@ -1791,6 +1771,93 @@ class DbNamedQuery {
1791
1771
  /** Name of the IndexedDb object store. */
1792
1772
  DbNamedQuery.store = 'namedQueries';
1793
1773
  DbNamedQuery.keyPath = 'name';
1774
+ /** An object representing the global configuration for a field index. */
1775
+ class DbIndexConfiguration {
1776
+ constructor(
1777
+ /** The index id for this entry. */
1778
+ indexId,
1779
+ /** The collection group this index belongs to. */
1780
+ collectionGroup,
1781
+ /** The fields to index for this index. */
1782
+ fields) {
1783
+ this.indexId = indexId;
1784
+ this.collectionGroup = collectionGroup;
1785
+ this.fields = fields;
1786
+ }
1787
+ }
1788
+ /** Name of the IndexedDb object store. */
1789
+ DbIndexConfiguration.store = 'indexConfiguration';
1790
+ DbIndexConfiguration.keyPath = 'indexId';
1791
+ /**
1792
+ * An object describing how up-to-date the index backfill is for each user and
1793
+ * index.
1794
+ */
1795
+ class DbIndexState {
1796
+ constructor(
1797
+ /** The index id for this entry. */
1798
+ indexId,
1799
+ /** The user id for this entry. */
1800
+ uid,
1801
+ /**
1802
+ * A number that indicates when the index was last updated (relative to
1803
+ * other indexes).
1804
+ */
1805
+ sequenceNumber,
1806
+ /**
1807
+ * The latest read time that has been indexed by Firestore for this field
1808
+ * index. Set to `{seconds: 0, nanos: 0}` if no documents have been indexed.
1809
+ */
1810
+ readTime,
1811
+ /**
1812
+ * The last document that has been indexed for this field index. Empty if
1813
+ * no documents have been indexed.
1814
+ */
1815
+ documentKey,
1816
+ /**
1817
+ * The largest mutation batch id that has been processed for this index. -1
1818
+ * if no mutations have been indexed.
1819
+ */
1820
+ largestBatchId) {
1821
+ this.indexId = indexId;
1822
+ this.uid = uid;
1823
+ this.sequenceNumber = sequenceNumber;
1824
+ this.readTime = readTime;
1825
+ this.documentKey = documentKey;
1826
+ this.largestBatchId = largestBatchId;
1827
+ }
1828
+ }
1829
+ /** Name of the IndexedDb object store. */
1830
+ DbIndexState.store = 'indexState';
1831
+ DbIndexState.keyPath = ['indexId', 'uid'];
1832
+ /** An object that stores the encoded entries for all documents and fields. */
1833
+ class DbIndexEntries {
1834
+ constructor(
1835
+ /** The index id for this entry. */
1836
+ indexId,
1837
+ /** The user id for this entry. */
1838
+ uid,
1839
+ /** The encoded array index value for this entry. */
1840
+ arrayValue,
1841
+ /** The encoded directional value for equality and inequality filters. */
1842
+ directionalValue,
1843
+ /** The document key this entry points to. */
1844
+ documentKey) {
1845
+ this.indexId = indexId;
1846
+ this.uid = uid;
1847
+ this.arrayValue = arrayValue;
1848
+ this.directionalValue = directionalValue;
1849
+ this.documentKey = documentKey;
1850
+ }
1851
+ }
1852
+ /** Name of the IndexedDb object store. */
1853
+ DbIndexEntries.store = 'indexEntries';
1854
+ DbIndexEntries.keyPath = [
1855
+ 'indexId',
1856
+ 'uid',
1857
+ 'arrayValue',
1858
+ 'directionalValue',
1859
+ 'documentKey'
1860
+ ];
1794
1861
  // Visible for testing
1795
1862
  const V1_STORES = [
1796
1863
  DbMutationQueue.store,
@@ -1805,7 +1872,6 @@ const V1_STORES = [
1805
1872
  // V2 is no longer usable (see comment at top of file)
1806
1873
  // Visible for testing
1807
1874
  const V3_STORES = V1_STORES;
1808
- // Visible for testing
1809
1875
  // Note: DbRemoteDocumentChanges is no longer used and dropped with v9.
1810
1876
  const V4_STORES = [...V3_STORES, DbClientMetadata.store];
1811
1877
  // V5 does not change the set of stores.
@@ -1815,6 +1881,12 @@ const V8_STORES = [...V6_STORES, DbCollectionParent.store];
1815
1881
  // V9 does not change the set of stores.
1816
1882
  // V10 does not change the set of stores.
1817
1883
  const V11_STORES = [...V8_STORES, DbBundle.store, DbNamedQuery.store];
1884
+ [
1885
+ ...V11_STORES,
1886
+ DbIndexConfiguration.store,
1887
+ DbIndexState.store,
1888
+ DbIndexEntries.store
1889
+ ];
1818
1890
  /**
1819
1891
  * The list of all default IndexedDB stores used throughout the SDK. This is
1820
1892
  * used when creating transactions so that access across all stores is done
@@ -3374,6 +3446,75 @@ function getLocalWriteTime(value) {
3374
3446
  return new Timestamp(localWriteTime.seconds, localWriteTime.nanos);
3375
3447
  }
3376
3448
 
3449
+ /**
3450
+ * @license
3451
+ * Copyright 2017 Google LLC
3452
+ *
3453
+ * Licensed under the Apache License, Version 2.0 (the "License");
3454
+ * you may not use this file except in compliance with the License.
3455
+ * You may obtain a copy of the License at
3456
+ *
3457
+ * http://www.apache.org/licenses/LICENSE-2.0
3458
+ *
3459
+ * Unless required by applicable law or agreed to in writing, software
3460
+ * distributed under the License is distributed on an "AS IS" BASIS,
3461
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3462
+ * See the License for the specific language governing permissions and
3463
+ * limitations under the License.
3464
+ */
3465
+ class DatabaseInfo {
3466
+ /**
3467
+ * Constructs a DatabaseInfo using the provided host, databaseId and
3468
+ * persistenceKey.
3469
+ *
3470
+ * @param databaseId - The database to use.
3471
+ * @param appId - The Firebase App Id.
3472
+ * @param persistenceKey - A unique identifier for this Firestore's local
3473
+ * storage (used in conjunction with the databaseId).
3474
+ * @param host - The Firestore backend host to connect to.
3475
+ * @param ssl - Whether to use SSL when connecting.
3476
+ * @param forceLongPolling - Whether to use the forceLongPolling option
3477
+ * when using WebChannel as the network transport.
3478
+ * @param autoDetectLongPolling - Whether to use the detectBufferingProxy
3479
+ * option when using WebChannel as the network transport.
3480
+ * @param useFetchStreams Whether to use the Fetch API instead of
3481
+ * XMLHTTPRequest
3482
+ */
3483
+ constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
3484
+ this.databaseId = databaseId;
3485
+ this.appId = appId;
3486
+ this.persistenceKey = persistenceKey;
3487
+ this.host = host;
3488
+ this.ssl = ssl;
3489
+ this.forceLongPolling = forceLongPolling;
3490
+ this.autoDetectLongPolling = autoDetectLongPolling;
3491
+ this.useFetchStreams = useFetchStreams;
3492
+ }
3493
+ }
3494
+ /** The default database name for a project. */
3495
+ const DEFAULT_DATABASE_NAME = '(default)';
3496
+ /**
3497
+ * Represents the database ID a Firestore client is associated with.
3498
+ * @internal
3499
+ */
3500
+ class DatabaseId {
3501
+ constructor(projectId, database) {
3502
+ this.projectId = projectId;
3503
+ this.database = database ? database : DEFAULT_DATABASE_NAME;
3504
+ }
3505
+ static empty() {
3506
+ return new DatabaseId('', '');
3507
+ }
3508
+ get isDefaultDatabase() {
3509
+ return this.database === DEFAULT_DATABASE_NAME;
3510
+ }
3511
+ isEqual(other) {
3512
+ return (other instanceof DatabaseId &&
3513
+ other.projectId === this.projectId &&
3514
+ other.database === this.database);
3515
+ }
3516
+ }
3517
+
3377
3518
  /**
3378
3519
  * @license
3379
3520
  * Copyright 2017 Google LLC
@@ -4229,6 +4370,125 @@ function compareDocumentsByField(field, d1, d2) {
4229
4370
  }
4230
4371
  }
4231
4372
 
4373
+ /**
4374
+ * @license
4375
+ * Copyright 2021 Google LLC
4376
+ *
4377
+ * Licensed under the Apache License, Version 2.0 (the "License");
4378
+ * you may not use this file except in compliance with the License.
4379
+ * You may obtain a copy of the License at
4380
+ *
4381
+ * http://www.apache.org/licenses/LICENSE-2.0
4382
+ *
4383
+ * Unless required by applicable law or agreed to in writing, software
4384
+ * distributed under the License is distributed on an "AS IS" BASIS,
4385
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4386
+ * See the License for the specific language governing permissions and
4387
+ * limitations under the License.
4388
+ */
4389
+ /**
4390
+ * The initial mutation batch id for each index. Gets updated during index
4391
+ * backfill.
4392
+ */
4393
+ const INITIAL_LARGEST_BATCH_ID = -1;
4394
+ /**
4395
+ * The initial sequence number for each index. Gets updated during index
4396
+ * backfill.
4397
+ */
4398
+ const INITIAL_SEQUENCE_NUMBER = 0;
4399
+ /**
4400
+ * An index definition for field indexes in Firestore.
4401
+ *
4402
+ * Every index is associated with a collection. The definition contains a list
4403
+ * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
4404
+ * `CONTAINS` for ArrayContains/ArrayContainsAny queries).
4405
+ *
4406
+ * Unlike the backend, the SDK does not differentiate between collection or
4407
+ * collection group-scoped indices. Every index can be used for both single
4408
+ * collection and collection group queries.
4409
+ */
4410
+ class FieldIndex {
4411
+ constructor(
4412
+ /**
4413
+ * The index ID. Returns -1 if the index ID is not available (e.g. the index
4414
+ * has not yet been persisted).
4415
+ */
4416
+ indexId,
4417
+ /** The collection ID this index applies to. */
4418
+ collectionGroup,
4419
+ /** The field segments for this index. */
4420
+ segments,
4421
+ /** Shows how up-to-date the index is for the current user. */
4422
+ indexState) {
4423
+ this.indexId = indexId;
4424
+ this.collectionGroup = collectionGroup;
4425
+ this.segments = segments;
4426
+ this.indexState = indexState;
4427
+ }
4428
+ }
4429
+ /** An ID for an index that has not yet been added to persistence. */
4430
+ FieldIndex.UNKNOWN_ID = -1;
4431
+ /** An index component consisting of field path and index type. */
4432
+ class IndexSegment {
4433
+ constructor(
4434
+ /** The field path of the component. */
4435
+ fieldPath,
4436
+ /** The fields sorting order. */
4437
+ kind) {
4438
+ this.fieldPath = fieldPath;
4439
+ this.kind = kind;
4440
+ }
4441
+ }
4442
+ /**
4443
+ * Stores the "high water mark" that indicates how updated the Index is for the
4444
+ * current user.
4445
+ */
4446
+ class IndexState {
4447
+ constructor(
4448
+ /**
4449
+ * Indicates when the index was last updated (relative to other indexes).
4450
+ */
4451
+ sequenceNumber,
4452
+ /** The the latest indexed read time, document and batch id. */
4453
+ offset) {
4454
+ this.sequenceNumber = sequenceNumber;
4455
+ this.offset = offset;
4456
+ }
4457
+ /** The state of an index that has not yet been backfilled. */
4458
+ static empty() {
4459
+ return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
4460
+ }
4461
+ }
4462
+ /**
4463
+ * Stores the latest read time, document and batch ID that were processed for an
4464
+ * index.
4465
+ */
4466
+ class IndexOffset {
4467
+ constructor(
4468
+ /**
4469
+ * The latest read time version that has been indexed by Firestore for this
4470
+ * field index.
4471
+ */
4472
+ readTime,
4473
+ /**
4474
+ * The key of the last document that was indexed for this query. Use
4475
+ * `DocumentKey.empty()` if no document has been indexed.
4476
+ */
4477
+ documentKey,
4478
+ /*
4479
+ * The largest mutation batch id that's been processed by Firestore.
4480
+ */
4481
+ largestBatchId) {
4482
+ this.readTime = readTime;
4483
+ this.documentKey = documentKey;
4484
+ this.largestBatchId = largestBatchId;
4485
+ }
4486
+ /** The state of an index that has not yet been backfilled. */
4487
+ static min() {
4488
+ return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
4489
+ }
4490
+ }
4491
+
4232
4492
  /**
4233
4493
  * @license
4234
4494
  * Copyright 2019 Google LLC
@@ -4272,27 +4532,29 @@ function newTarget(path, collectionGroup = null, orderBy = [], filters = [], lim
4272
4532
  function canonifyTarget(target) {
4273
4533
  const targetImpl = debugCast(target);
4274
4534
  if (targetImpl.memoizedCanonicalId === null) {
4275
- let canonicalId = targetImpl.path.canonicalString();
4535
+ let str = targetImpl.path.canonicalString();
4276
4536
  if (targetImpl.collectionGroup !== null) {
4277
- canonicalId += '|cg:' + targetImpl.collectionGroup;
4537
+ str += '|cg:' + targetImpl.collectionGroup;
4278
4538
  }
4279
- canonicalId += '|f:';
4280
- canonicalId += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
4281
- canonicalId += '|ob:';
4282
- canonicalId += targetImpl.orderBy.map(o => canonifyOrderBy(o)).join(',');
4539
+ str += '|f:';
4540
+ str += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
4541
+ str += '|ob:';
4542
+ str += targetImpl.orderBy.map(o => canonifyOrderBy(o)).join(',');
4283
4543
  if (!isNullOrUndefined(targetImpl.limit)) {
4284
- canonicalId += '|l:';
4285
- canonicalId += targetImpl.limit;
4544
+ str += '|l:';
4545
+ str += targetImpl.limit;
4286
4546
  }
4287
4547
  if (targetImpl.startAt) {
4288
- canonicalId += '|lb:';
4289
- canonicalId += canonifyBound(targetImpl.startAt);
4548
+ str += '|lb:';
4549
+ str += targetImpl.startAt.inclusive ? 'b:' : 'a:';
4550
+ str += targetImpl.startAt.position.map(p => canonicalId(p)).join(',');
4290
4551
  }
4291
4552
  if (targetImpl.endAt) {
4292
- canonicalId += '|ub:';
4293
- canonicalId += canonifyBound(targetImpl.endAt);
4553
+ str += '|ub:';
4554
+ str += targetImpl.endAt.inclusive ? 'a:' : 'b:';
4555
+ str += targetImpl.endAt.position.map(p => canonicalId(p)).join(',');
4294
4556
  }
4295
- targetImpl.memoizedCanonicalId = canonicalId;
4557
+ targetImpl.memoizedCanonicalId = str;
4296
4558
  }
4297
4559
  return targetImpl.memoizedCanonicalId;
4298
4560
  }
@@ -4315,10 +4577,14 @@ function stringifyTarget(target) {
4315
4577
  .join(', ')}]`;
4316
4578
  }
4317
4579
  if (target.startAt) {
4318
- str += ', startAt: ' + canonifyBound(target.startAt);
4580
+ str += ', startAt: ';
4581
+ str += target.startAt.inclusive ? 'b:' : 'a:';
4582
+ str += target.startAt.position.map(p => canonicalId(p)).join(',');
4319
4583
  }
4320
4584
  if (target.endAt) {
4321
- str += ', endAt: ' + canonifyBound(target.endAt);
4585
+ str += ', endAt: ';
4586
+ str += target.endAt.inclusive ? 'a:' : 'b:';
4587
+ str += target.endAt.position.map(p => canonicalId(p)).join(',');
4322
4588
  }
4323
4589
  return `Target(${str})`;
4324
4590
  }
@@ -4353,7 +4619,7 @@ function targetEquals(left, right) {
4353
4619
  }
4354
4620
  return boundEquals(left.endAt, right.endAt);
4355
4621
  }
4356
- function isDocumentTarget(target) {
4622
+ function targetIsDocumentTarget(target) {
4357
4623
  return (DocumentKey.isDocumentKey(target.path) &&
4358
4624
  target.collectionGroup === null &&
4359
4625
  target.filters.length === 0);
@@ -4556,17 +4822,11 @@ class ArrayContainsAnyFilter extends FieldFilter {
4556
4822
  * just after the provided values.
4557
4823
  */
4558
4824
  class Bound {
4559
- constructor(position, before) {
4825
+ constructor(position, inclusive) {
4560
4826
  this.position = position;
4561
- this.before = before;
4827
+ this.inclusive = inclusive;
4562
4828
  }
4563
4829
  }
4564
- function canonifyBound(bound) {
4565
- // TODO(b/29183165): Make this collision robust.
4566
- return `${bound.before ? 'b' : 'a'}:${bound.position
4567
- .map(p => canonicalId(p))
4568
- .join(',')}`;
4569
- }
4570
4830
  /**
4571
4831
  * An ordering on a field, in some Direction. Direction defaults to ASCENDING.
4572
4832
  */
@@ -4586,11 +4846,7 @@ function stringifyOrderBy(orderBy) {
4586
4846
  function orderByEquals(left, right) {
4587
4847
  return left.dir === right.dir && left.field.isEqual(right.field);
4588
4848
  }
4589
- /**
4590
- * Returns true if a document sorts before a bound using the provided sort
4591
- * order.
4592
- */
4593
- function sortsBeforeDocument(bound, orderBy, doc) {
4849
+ function boundCompareToDocument(bound, orderBy, doc) {
4594
4850
  let comparison = 0;
4595
4851
  for (let i = 0; i < bound.position.length; i++) {
4596
4852
  const orderByComponent = orderBy[i];
@@ -4609,7 +4865,23 @@ function sortsBeforeDocument(bound, orderBy, doc) {
4609
4865
  break;
4610
4866
  }
4611
4867
  }
4612
- return bound.before ? comparison <= 0 : comparison < 0;
4868
+ return comparison;
4869
+ }
4870
+ /**
4871
+ * Returns true if a document sorts after a bound using the provided sort
4872
+ * order.
4873
+ */
4874
+ function boundSortsAfterDocument(bound, orderBy, doc) {
4875
+ const comparison = boundCompareToDocument(bound, orderBy, doc);
4876
+ return bound.inclusive ? comparison >= 0 : comparison > 0;
4877
+ }
4878
+ /**
4879
+ * Returns true if a document sorts before a bound using the provided sort
4880
+ * order.
4881
+ */
4882
+ function boundSortsBeforeDocument(bound, orderBy, doc) {
4883
+ const comparison = boundCompareToDocument(bound, orderBy, doc);
4884
+ return bound.inclusive ? comparison <= 0 : comparison < 0;
4613
4885
  }
4614
4886
  function boundEquals(left, right) {
4615
4887
  if (left === null) {
@@ -4618,7 +4890,7 @@ function boundEquals(left, right) {
4618
4890
  else if (right === null) {
4619
4891
  return false;
4620
4892
  }
4621
- if (left.before !== right.before ||
4893
+ if (left.inclusive !== right.inclusive ||
4622
4894
  left.position.length !== right.position.length) {
4623
4895
  return false;
4624
4896
  }
@@ -4822,10 +5094,10 @@ function queryToTarget(query) {
4822
5094
  }
4823
5095
  // We need to swap the cursors to match the now-flipped query ordering.
4824
5096
  const startAt = queryImpl.endAt
4825
- ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.before)
5097
+ ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.inclusive)
4826
5098
  : null;
4827
5099
  const endAt = queryImpl.startAt
4828
- ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.before)
5100
+ ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
4829
5101
  : null;
4830
5102
  // Now return as a LimitType.First query.
4831
5103
  queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
@@ -4913,11 +5185,11 @@ function queryMatchesFilters(query, doc) {
4913
5185
  /** Makes sure a document is within the bounds, if provided. */
4914
5186
  function queryMatchesBounds(query, doc) {
4915
5187
  if (query.startAt &&
4916
- !sortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
5188
+ !boundSortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
4917
5189
  return false;
4918
5190
  }
4919
5191
  if (query.endAt &&
4920
- sortsBeforeDocument(query.endAt, queryOrderBy(query), doc)) {
5192
+ !boundSortsAfterDocument(query.endAt, queryOrderBy(query), doc)) {
4921
5193
  return false;
4922
5194
  }
4923
5195
  return true;
@@ -6998,7 +7270,7 @@ class WatchChangeAggregator {
6998
7270
  const targetData = this.targetDataForActiveTarget(targetId);
6999
7271
  if (targetData) {
7000
7272
  const target = targetData.target;
7001
- if (isDocumentTarget(target)) {
7273
+ if (targetIsDocumentTarget(target)) {
7002
7274
  if (expectedCount === 0) {
7003
7275
  // The existence filter told us the document does not exist. We deduce
7004
7276
  // that this document does not exist and apply a deleted document to
@@ -7033,7 +7305,7 @@ class WatchChangeAggregator {
7033
7305
  this.targetStates.forEach((targetState, targetId) => {
7034
7306
  const targetData = this.targetDataForActiveTarget(targetId);
7035
7307
  if (targetData) {
7036
- if (targetState.current && isDocumentTarget(targetData.target)) {
7308
+ if (targetState.current && targetIsDocumentTarget(targetData.target)) {
7037
7309
  // Document queries for document that don't exist can produce an empty
7038
7310
  // result set. To update our local cache, we synthesize a document
7039
7311
  // delete if we have not previously received the document. This
@@ -7796,10 +8068,10 @@ function toQueryTarget(serializer, target) {
7796
8068
  result.structuredQuery.limit = limit;
7797
8069
  }
7798
8070
  if (target.startAt) {
7799
- result.structuredQuery.startAt = toCursor(target.startAt);
8071
+ result.structuredQuery.startAt = toStartAtCursor(target.startAt);
7800
8072
  }
7801
8073
  if (target.endAt) {
7802
- result.structuredQuery.endAt = toCursor(target.endAt);
8074
+ result.structuredQuery.endAt = toEndAtCursor(target.endAt);
7803
8075
  }
7804
8076
  return result;
7805
8077
  }
@@ -7832,11 +8104,11 @@ function convertQueryTargetToQuery(target) {
7832
8104
  }
7833
8105
  let startAt = null;
7834
8106
  if (query.startAt) {
7835
- startAt = fromCursor(query.startAt);
8107
+ startAt = fromStartAtCursor(query.startAt);
7836
8108
  }
7837
8109
  let endAt = null;
7838
8110
  if (query.endAt) {
7839
- endAt = fromCursor(query.endAt);
8111
+ endAt = fromEndAtCursor(query.endAt);
7840
8112
  }
7841
8113
  return newQuery(path, collectionGroup, orderBy, filterBy, limit, "F" /* First */, startAt, endAt);
7842
8114
  }
@@ -7869,7 +8141,7 @@ function toLabel(serializer, purpose) {
7869
8141
  function toTarget(serializer, targetData) {
7870
8142
  let result;
7871
8143
  const target = targetData.target;
7872
- if (isDocumentTarget(target)) {
8144
+ if (targetIsDocumentTarget(target)) {
7873
8145
  result = { documents: toDocumentsTarget(serializer, target) };
7874
8146
  }
7875
8147
  else {
@@ -7927,16 +8199,27 @@ function toOrder(orderBys) {
7927
8199
  function fromOrder(orderBys) {
7928
8200
  return orderBys.map(order => fromPropertyOrder(order));
7929
8201
  }
7930
- function toCursor(cursor) {
8202
+ function toStartAtCursor(cursor) {
7931
8203
  return {
7932
- before: cursor.before,
8204
+ before: cursor.inclusive,
7933
8205
  values: cursor.position
7934
8206
  };
7935
8207
  }
7936
- function fromCursor(cursor) {
7937
- const before = !!cursor.before;
8208
+ function toEndAtCursor(cursor) {
8209
+ return {
8210
+ before: !cursor.inclusive,
8211
+ values: cursor.position
8212
+ };
8213
+ }
8214
+ function fromStartAtCursor(cursor) {
8215
+ const inclusive = !!cursor.before;
7938
8216
  const position = cursor.values || [];
7939
- return new Bound(position, before);
8217
+ return new Bound(position, inclusive);
8218
+ }
8219
+ function fromEndAtCursor(cursor) {
8220
+ const inclusive = !cursor.before;
8221
+ const position = cursor.values || [];
8222
+ return new Bound(position, inclusive);
7940
8223
  }
7941
8224
  // visible for testing
7942
8225
  function toDirection(dir) {
@@ -8319,7 +8602,7 @@ function toDbTarget(localSerializer, targetData) {
8319
8602
  const dbTimestamp = toDbTimestamp(targetData.snapshotVersion);
8320
8603
  const dbLastLimboFreeTimestamp = toDbTimestamp(targetData.lastLimboFreeSnapshotVersion);
8321
8604
  let queryProto;
8322
- if (isDocumentTarget(targetData.target)) {
8605
+ if (targetIsDocumentTarget(targetData.target)) {
8323
8606
  queryProto = toDocumentsTarget(localSerializer.remoteSerializer, targetData.target);
8324
8607
  }
8325
8608
  else {
@@ -8489,6 +8772,38 @@ class MemoryIndexManager {
8489
8772
  getCollectionParents(transaction, collectionId) {
8490
8773
  return PersistencePromise.resolve(this.collectionParentIndex.getEntries(collectionId));
8491
8774
  }
8775
+ addFieldIndex(transaction, index) {
8776
+ // Field indices are not supported with memory persistence.
8777
+ return PersistencePromise.resolve();
8778
+ }
8779
+ deleteFieldIndex(transaction, index) {
8780
+ // Field indices are not supported with memory persistence.
8781
+ return PersistencePromise.resolve();
8782
+ }
8783
+ getDocumentsMatchingTarget(transaction, fieldIndex, target) {
8784
+ // Field indices are not supported with memory persistence.
8785
+ return PersistencePromise.resolve(documentKeySet());
8786
+ }
8787
+ getFieldIndex(transaction, target) {
8788
+ // Field indices are not supported with memory persistence.
8789
+ return PersistencePromise.resolve(null);
8790
+ }
8791
+ getFieldIndexes(transaction, collectionGroup) {
8792
+ // Field indices are not supported with memory persistence.
8793
+ return PersistencePromise.resolve([]);
8794
+ }
8795
+ getNextCollectionGroupToUpdate(transaction) {
8796
+ // Field indices are not supported with memory persistence.
8797
+ return PersistencePromise.resolve(null);
8798
+ }
8799
+ updateCollectionGroup(transaction, collectionGroup, offset) {
8800
+ // Field indices are not supported with memory persistence.
8801
+ return PersistencePromise.resolve();
8802
+ }
8803
+ updateIndexEntries(transaction, documents) {
8804
+ // Field indices are not supported with memory persistence.
8805
+ return PersistencePromise.resolve();
8806
+ }
8492
8807
  }
8493
8808
  /**
8494
8809
  * Internal implementation of the collection-parent index exposed by MemoryIndexManager.
@@ -8597,6 +8912,38 @@ class IndexedDbIndexManager {
8597
8912
  return parentPaths;
8598
8913
  });
8599
8914
  }
8915
+ addFieldIndex(transaction, index) {
8916
+ // TODO(indexing): Implement
8917
+ return PersistencePromise.resolve();
8918
+ }
8919
+ deleteFieldIndex(transaction, index) {
8920
+ // TODO(indexing): Implement
8921
+ return PersistencePromise.resolve();
8922
+ }
8923
+ getDocumentsMatchingTarget(transaction, fieldIndex, target) {
8924
+ // TODO(indexing): Implement
8925
+ return PersistencePromise.resolve(documentKeySet());
8926
+ }
8927
+ getFieldIndex(transaction, target) {
8928
+ // TODO(indexing): Implement
8929
+ return PersistencePromise.resolve(null);
8930
+ }
8931
+ getFieldIndexes(transaction, collectionGroup) {
8932
+ // TODO(indexing): Implement
8933
+ return PersistencePromise.resolve([]);
8934
+ }
8935
+ getNextCollectionGroupToUpdate(transaction) {
8936
+ // TODO(indexing): Implement
8937
+ return PersistencePromise.resolve(null);
8938
+ }
8939
+ updateCollectionGroup(transaction, collectionGroup, offset) {
8940
+ // TODO(indexing): Implement
8941
+ return PersistencePromise.resolve();
8942
+ }
8943
+ updateIndexEntries(transaction, documents) {
8944
+ // TODO(indexing): Implement
8945
+ return PersistencePromise.resolve();
8946
+ }
8600
8947
  }
8601
8948
  /**
8602
8949
  * Helper to get a typed SimpleDbStore for the collectionParents
@@ -10448,9 +10795,6 @@ class SchemaConverter {
10448
10795
  * and local feature development.
10449
10796
  */
10450
10797
  createOrUpgrade(db, txn, fromVersion, toVersion) {
10451
- hardAssert(fromVersion < toVersion &&
10452
- fromVersion >= 0 &&
10453
- toVersion <= SCHEMA_VERSION);
10454
10798
  const simpleDbTransaction = new SimpleDbTransaction('createOrUpgrade', txn);
10455
10799
  if (fromVersion < 1 && toVersion >= 1) {
10456
10800
  createPrimaryClientStore(db);
@@ -10517,6 +10861,11 @@ class SchemaConverter {
10517
10861
  createNamedQueriesStore(db);
10518
10862
  });
10519
10863
  }
10864
+ if (fromVersion < 12 && toVersion >= 12) {
10865
+ p = p.next(() => {
10866
+ createFieldIndex(db);
10867
+ });
10868
+ }
10520
10869
  return p;
10521
10870
  }
10522
10871
  addDocumentGlobal(txn) {
@@ -10723,6 +11072,17 @@ function createNamedQueriesStore(db) {
10723
11072
  db.createObjectStore(DbNamedQuery.store, {
10724
11073
  keyPath: DbNamedQuery.keyPath
10725
11074
  });
11075
+ }
11076
+ function createFieldIndex(db) {
11077
+ db.createObjectStore(DbIndexConfiguration.store, {
11078
+ keyPath: DbIndexConfiguration.keyPath
11079
+ });
11080
+ db.createObjectStore(DbIndexState.store, {
11081
+ keyPath: DbIndexState.keyPath
11082
+ });
11083
+ db.createObjectStore(DbIndexEntries.store, {
11084
+ keyPath: DbIndexEntries.keyPath
11085
+ });
10726
11086
  }
10727
11087
 
10728
11088
  /**
@@ -22291,72 +22651,6 @@ function createBundleReader(data, serializer) {
22291
22651
  return newBundleReader(toByteStreamReader(content), serializer);
22292
22652
  }
22293
22653
 
22294
- /**
22295
- * @license
22296
- * Copyright 2017 Google LLC
22297
- *
22298
- * Licensed under the Apache License, Version 2.0 (the "License");
22299
- * you may not use this file except in compliance with the License.
22300
- * You may obtain a copy of the License at
22301
- *
22302
- * http://www.apache.org/licenses/LICENSE-2.0
22303
- *
22304
- * Unless required by applicable law or agreed to in writing, software
22305
- * distributed under the License is distributed on an "AS IS" BASIS,
22306
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22307
- * See the License for the specific language governing permissions and
22308
- * limitations under the License.
22309
- */
22310
- class DatabaseInfo {
22311
- /**
22312
- * Constructs a DatabaseInfo using the provided host, databaseId and
22313
- * persistenceKey.
22314
- *
22315
- * @param databaseId - The database to use.
22316
- * @param appId - The Firebase App Id.
22317
- * @param persistenceKey - A unique identifier for this Firestore's local
22318
- * storage (used in conjunction with the databaseId).
22319
- * @param host - The Firestore backend host to connect to.
22320
- * @param ssl - Whether to use SSL when connecting.
22321
- * @param forceLongPolling - Whether to use the forceLongPolling option
22322
- * when using WebChannel as the network transport.
22323
- * @param autoDetectLongPolling - Whether to use the detectBufferingProxy
22324
- * option when using WebChannel as the network transport.
22325
- * @param useFetchStreams Whether to use the Fetch API instead of
22326
- * XMLHTTPRequest
22327
- */
22328
- constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
22329
- this.databaseId = databaseId;
22330
- this.appId = appId;
22331
- this.persistenceKey = persistenceKey;
22332
- this.host = host;
22333
- this.ssl = ssl;
22334
- this.forceLongPolling = forceLongPolling;
22335
- this.autoDetectLongPolling = autoDetectLongPolling;
22336
- this.useFetchStreams = useFetchStreams;
22337
- }
22338
- }
22339
- /** The default database name for a project. */
22340
- const DEFAULT_DATABASE_NAME = '(default)';
22341
- /**
22342
- * Represents the database ID a Firestore client is associated with.
22343
- * @internal
22344
- */
22345
- class DatabaseId {
22346
- constructor(projectId, database) {
22347
- this.projectId = projectId;
22348
- this.database = database ? database : DEFAULT_DATABASE_NAME;
22349
- }
22350
- get isDefaultDatabase() {
22351
- return this.database === DEFAULT_DATABASE_NAME;
22352
- }
22353
- isEqual(other) {
22354
- return (other instanceof DatabaseId &&
22355
- other.projectId === this.projectId &&
22356
- other.database === this.database);
22357
- }
22358
- }
22359
-
22360
22654
  /**
22361
22655
  * @license
22362
22656
  * Copyright 2020 Google LLC
@@ -25105,51 +25399,53 @@ function limitToLast(limit) {
25105
25399
  return new QueryLimitConstraint('limitToLast', limit, "L" /* Last */);
25106
25400
  }
25107
25401
  class QueryStartAtConstraint extends QueryConstraint {
25108
- constructor(type, _docOrFields, _before) {
25402
+ constructor(type, _docOrFields, _inclusive) {
25109
25403
  super();
25110
25404
  this.type = type;
25111
25405
  this._docOrFields = _docOrFields;
25112
- this._before = _before;
25406
+ this._inclusive = _inclusive;
25113
25407
  }
25114
25408
  _apply(query) {
25115
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
25409
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
25116
25410
  return new Query(query.firestore, query.converter, queryWithStartAt(query._query, bound));
25117
25411
  }
25118
25412
  }
25119
25413
  function startAt(...docOrFields) {
25120
- return new QueryStartAtConstraint('startAt', docOrFields, /*before=*/ true);
25414
+ return new QueryStartAtConstraint('startAt', docOrFields,
25415
+ /*inclusive=*/ true);
25121
25416
  }
25122
25417
  function startAfter(...docOrFields) {
25123
25418
  return new QueryStartAtConstraint('startAfter', docOrFields,
25124
- /*before=*/ false);
25419
+ /*inclusive=*/ false);
25125
25420
  }
25126
25421
  class QueryEndAtConstraint extends QueryConstraint {
25127
- constructor(type, _docOrFields, _before) {
25422
+ constructor(type, _docOrFields, _inclusive) {
25128
25423
  super();
25129
25424
  this.type = type;
25130
25425
  this._docOrFields = _docOrFields;
25131
- this._before = _before;
25426
+ this._inclusive = _inclusive;
25132
25427
  }
25133
25428
  _apply(query) {
25134
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
25429
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
25135
25430
  return new Query(query.firestore, query.converter, queryWithEndAt(query._query, bound));
25136
25431
  }
25137
25432
  }
25138
25433
  function endBefore(...docOrFields) {
25139
- return new QueryEndAtConstraint('endBefore', docOrFields, /*before=*/ true);
25434
+ return new QueryEndAtConstraint('endBefore', docOrFields,
25435
+ /*inclusive=*/ false);
25140
25436
  }
25141
25437
  function endAt(...docOrFields) {
25142
- return new QueryEndAtConstraint('endAt', docOrFields, /*before=*/ false);
25438
+ return new QueryEndAtConstraint('endAt', docOrFields, /*inclusive=*/ true);
25143
25439
  }
25144
25440
  /** Helper function to create a bound from a document or fields */
25145
- function newQueryBoundFromDocOrFields(query, methodName, docOrFields, before) {
25441
+ function newQueryBoundFromDocOrFields(query, methodName, docOrFields, inclusive) {
25146
25442
  docOrFields[0] = getModularInstance(docOrFields[0]);
25147
25443
  if (docOrFields[0] instanceof DocumentSnapshot$1) {
25148
- return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, before);
25444
+ return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, inclusive);
25149
25445
  }
25150
25446
  else {
25151
25447
  const reader = newUserDataReader(query.firestore);
25152
- return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, before);
25448
+ return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, inclusive);
25153
25449
  }
25154
25450
  }
25155
25451
  function newQueryFilter(query, methodName, dataReader, databaseId, fieldPath, op, value) {
@@ -25207,7 +25503,7 @@ function newQueryOrderBy(query, fieldPath, direction) {
25207
25503
  * of the query or if any of the fields in the order by are an uncommitted
25208
25504
  * server timestamp.
25209
25505
  */
25210
- function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
25506
+ function newQueryBoundFromDocument(query, databaseId, methodName, doc, inclusive) {
25211
25507
  if (!doc) {
25212
25508
  throw new FirestoreError(Code.NOT_FOUND, `Can't use a DocumentSnapshot that doesn't exist for ` +
25213
25509
  `${methodName}().`);
@@ -25244,12 +25540,12 @@ function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
25244
25540
  }
25245
25541
  }
25246
25542
  }
25247
- return new Bound(components, before);
25543
+ return new Bound(components, inclusive);
25248
25544
  }
25249
25545
  /**
25250
25546
  * Converts a list of field values to a `Bound` for the given query.
25251
25547
  */
25252
- function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, before) {
25548
+ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, inclusive) {
25253
25549
  // Use explicit order by's because it has to match the query the user made
25254
25550
  const orderBy = query.explicitOrderBy;
25255
25551
  if (values.length > orderBy.length) {
@@ -25286,7 +25582,7 @@ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, valu
25286
25582
  components.push(wrapped);
25287
25583
  }
25288
25584
  }
25289
- return new Bound(components, before);
25585
+ return new Bound(components, inclusive);
25290
25586
  }
25291
25587
  /**
25292
25588
  * Parses the given `documentIdValue` into a `ReferenceValue`, throwing
@@ -26271,125 +26567,6 @@ function writeBatch(firestore) {
26271
26567
  return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations));
26272
26568
  }
26273
26569
 
26274
- /**
26275
- * @license
26276
- * Copyright 2021 Google LLC
26277
- *
26278
- * Licensed under the Apache License, Version 2.0 (the "License");
26279
- * you may not use this file except in compliance with the License.
26280
- * You may obtain a copy of the License at
26281
- *
26282
- * http://www.apache.org/licenses/LICENSE-2.0
26283
- *
26284
- * Unless required by applicable law or agreed to in writing, software
26285
- * distributed under the License is distributed on an "AS IS" BASIS,
26286
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26287
- * See the License for the specific language governing permissions and
26288
- * limitations under the License.
26289
- */
26290
- /**
26291
- * The initial mutation batch id for each index. Gets updated during index
26292
- * backfill.
26293
- */
26294
- const INITIAL_LARGEST_BATCH_ID = -1;
26295
- /**
26296
- * The initial sequence number for each index. Gets updated during index
26297
- * backfill.
26298
- */
26299
- const INITIAL_SEQUENCE_NUMBER = 0;
26300
- /**
26301
- * An index definition for field indexes in Firestore.
26302
- *
26303
- * Every index is associated with a collection. The definition contains a list
26304
- * of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
26305
- * `CONTAINS` for ArrayContains/ArrayContainsAny queries).
26306
- *
26307
- * Unlike the backend, the SDK does not differentiate between collection or
26308
- * collection group-scoped indices. Every index can be used for both single
26309
- * collection and collection group queries.
26310
- */
26311
- class FieldIndex {
26312
- constructor(
26313
- /**
26314
- * The index ID. Returns -1 if the index ID is not available (e.g. the index
26315
- * has not yet been persisted).
26316
- */
26317
- indexId,
26318
- /** The collection ID this index applies to. */
26319
- collectionGroup,
26320
- /** The field segments for this index. */
26321
- segments,
26322
- /** Shows how up-to-date the index is for the current user. */
26323
- indexState) {
26324
- this.indexId = indexId;
26325
- this.collectionGroup = collectionGroup;
26326
- this.segments = segments;
26327
- this.indexState = indexState;
26328
- }
26329
- }
26330
- /** An ID for an index that has not yet been added to persistence. */
26331
- FieldIndex.UNKNOWN_ID = -1;
26332
- /** An index component consisting of field path and index type. */
26333
- class IndexSegment {
26334
- constructor(
26335
- /** The field path of the component. */
26336
- fieldPath,
26337
- /** The fields sorting order. */
26338
- kind) {
26339
- this.fieldPath = fieldPath;
26340
- this.kind = kind;
26341
- }
26342
- }
26343
- /**
26344
- * Stores the "high water mark" that indicates how updated the Index is for the
26345
- * current user.
26346
- */
26347
- class IndexState {
26348
- constructor(
26349
- /**
26350
- * Indicates when the index was last updated (relative to other indexes).
26351
- */
26352
- sequenceNumber,
26353
- /** The the latest indexed read time, document and batch id. */
26354
- offset) {
26355
- this.sequenceNumber = sequenceNumber;
26356
- this.offset = offset;
26357
- }
26358
- /** The state of an index that has not yet been backfilled. */
26359
- static empty() {
26360
- return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
26361
- }
26362
- }
26363
- /**
26364
- * Stores the latest read time, document and batch ID that were processed for an
26365
- * index.
26366
- */
26367
- class IndexOffset {
26368
- constructor(
26369
- /**
26370
- * The latest read time version that has been indexed by Firestore for this
26371
- * field index.
26372
- */
26373
- readTime,
26374
- /**
26375
- * The key of the last document that was indexed for this query. Use
26376
- * `DocumentKey.empty()` if no document has been indexed.
26377
- */
26378
- documentKey,
26379
- /*
26380
- * The largest mutation batch id that's been processed by Firestore.
26381
- */
26382
- largestBatchId) {
26383
- this.readTime = readTime;
26384
- this.documentKey = documentKey;
26385
- this.largestBatchId = largestBatchId;
26386
- }
26387
- /** The state of an index that has not yet been backfilled. */
26388
- static min() {
26389
- return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
26390
- }
26391
- }
26392
-
26393
26570
  /**
26394
26571
  * @license
26395
26572
  * Copyright 2021 Google LLC