@firebase/firestore 3.4.4-canary.b02927e2e → 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 (55) hide show
  1. package/dist/firestore/src/core/target.d.ts +8 -4
  2. package/dist/firestore/src/lite-api/query.d.ts +2 -2
  3. package/dist/firestore/src/local/index_manager.d.ts +52 -0
  4. package/dist/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  5. package/dist/firestore/src/local/indexeddb_schema.d.ts +121 -7
  6. package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
  7. package/dist/firestore/test/util/helpers.d.ts +1 -1
  8. package/dist/index.esm2017.js +2501 -2348
  9. package/dist/index.esm2017.js.map +1 -1
  10. package/dist/index.esm5.js +3212 -3112
  11. package/dist/index.esm5.js.map +1 -1
  12. package/dist/index.node.cjs.js +263 -90
  13. package/dist/index.node.cjs.js.map +1 -1
  14. package/dist/index.node.mjs +263 -90
  15. package/dist/index.node.mjs.map +1 -1
  16. package/dist/index.rn.js +2548 -2391
  17. package/dist/index.rn.js.map +1 -1
  18. package/dist/internal.d.ts +170 -2
  19. package/dist/lite/firestore/src/core/target.d.ts +8 -4
  20. package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
  21. package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
  22. package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  23. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +121 -7
  24. package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
  25. package/dist/lite/firestore/test/util/helpers.d.ts +1 -1
  26. package/dist/lite/index.browser.esm2017.js +346 -343
  27. package/dist/lite/index.browser.esm2017.js.map +1 -1
  28. package/dist/lite/index.browser.esm5.js +331 -330
  29. package/dist/lite/index.browser.esm5.js.map +1 -1
  30. package/dist/lite/index.node.cjs.js +36 -29
  31. package/dist/lite/index.node.cjs.js.map +1 -1
  32. package/dist/lite/index.node.mjs +36 -29
  33. package/dist/lite/index.node.mjs.map +1 -1
  34. package/dist/lite/index.rn.esm2017.js +357 -354
  35. package/dist/lite/index.rn.esm2017.js.map +1 -1
  36. package/dist/lite/internal.d.ts +2 -2
  37. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +97 -97
  38. package/dist/lite/packages/firestore/src/core/target.d.ts +8 -4
  39. package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
  40. package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
  41. package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  42. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
  43. package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  44. package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -1
  45. package/dist/lite/private.d.ts +2 -2
  46. package/dist/packages/firestore/dist/index.esm2017.d.ts +79 -79
  47. package/dist/packages/firestore/src/core/target.d.ts +8 -4
  48. package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
  49. package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
  50. package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
  51. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
  52. package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
  53. package/dist/packages/firestore/test/util/helpers.d.ts +1 -1
  54. package/dist/private.d.ts +170 -2
  55. 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.b02927e2e";
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.b02927e2e";
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
@@ -4460,27 +4532,29 @@ function newTarget(path, collectionGroup = null, orderBy = [], filters = [], lim
4460
4532
  function canonifyTarget(target) {
4461
4533
  const targetImpl = debugCast(target);
4462
4534
  if (targetImpl.memoizedCanonicalId === null) {
4463
- let canonicalId = targetImpl.path.canonicalString();
4535
+ let str = targetImpl.path.canonicalString();
4464
4536
  if (targetImpl.collectionGroup !== null) {
4465
- canonicalId += '|cg:' + targetImpl.collectionGroup;
4537
+ str += '|cg:' + targetImpl.collectionGroup;
4466
4538
  }
4467
- canonicalId += '|f:';
4468
- canonicalId += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
4469
- canonicalId += '|ob:';
4470
- 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(',');
4471
4543
  if (!isNullOrUndefined(targetImpl.limit)) {
4472
- canonicalId += '|l:';
4473
- canonicalId += targetImpl.limit;
4544
+ str += '|l:';
4545
+ str += targetImpl.limit;
4474
4546
  }
4475
4547
  if (targetImpl.startAt) {
4476
- canonicalId += '|lb:';
4477
- canonicalId += canonifyBound(targetImpl.startAt);
4548
+ str += '|lb:';
4549
+ str += targetImpl.startAt.inclusive ? 'b:' : 'a:';
4550
+ str += targetImpl.startAt.position.map(p => canonicalId(p)).join(',');
4478
4551
  }
4479
4552
  if (targetImpl.endAt) {
4480
- canonicalId += '|ub:';
4481
- canonicalId += canonifyBound(targetImpl.endAt);
4553
+ str += '|ub:';
4554
+ str += targetImpl.endAt.inclusive ? 'a:' : 'b:';
4555
+ str += targetImpl.endAt.position.map(p => canonicalId(p)).join(',');
4482
4556
  }
4483
- targetImpl.memoizedCanonicalId = canonicalId;
4557
+ targetImpl.memoizedCanonicalId = str;
4484
4558
  }
4485
4559
  return targetImpl.memoizedCanonicalId;
4486
4560
  }
@@ -4503,10 +4577,14 @@ function stringifyTarget(target) {
4503
4577
  .join(', ')}]`;
4504
4578
  }
4505
4579
  if (target.startAt) {
4506
- 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(',');
4507
4583
  }
4508
4584
  if (target.endAt) {
4509
- 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(',');
4510
4588
  }
4511
4589
  return `Target(${str})`;
4512
4590
  }
@@ -4729,7 +4807,6 @@ class ArrayContainsAnyFilter extends FieldFilter {
4729
4807
  return other.arrayValue.values.some(val => arrayValueContains(this.value.arrayValue, val));
4730
4808
  }
4731
4809
  }
4732
- // TODO(indexing): Change Bound.before to "inclusive"
4733
4810
  /**
4734
4811
  * Represents a bound of a query.
4735
4812
  *
@@ -4745,17 +4822,11 @@ class ArrayContainsAnyFilter extends FieldFilter {
4745
4822
  * just after the provided values.
4746
4823
  */
4747
4824
  class Bound {
4748
- constructor(position, before) {
4825
+ constructor(position, inclusive) {
4749
4826
  this.position = position;
4750
- this.before = before;
4827
+ this.inclusive = inclusive;
4751
4828
  }
4752
4829
  }
4753
- function canonifyBound(bound) {
4754
- // TODO(b/29183165): Make this collision robust.
4755
- return `${bound.before ? 'b' : 'a'}:${bound.position
4756
- .map(p => canonicalId(p))
4757
- .join(',')}`;
4758
- }
4759
4830
  /**
4760
4831
  * An ordering on a field, in some Direction. Direction defaults to ASCENDING.
4761
4832
  */
@@ -4775,11 +4846,7 @@ function stringifyOrderBy(orderBy) {
4775
4846
  function orderByEquals(left, right) {
4776
4847
  return left.dir === right.dir && left.field.isEqual(right.field);
4777
4848
  }
4778
- /**
4779
- * Returns true if a document sorts before a bound using the provided sort
4780
- * order.
4781
- */
4782
- function sortsBeforeDocument(bound, orderBy, doc) {
4849
+ function boundCompareToDocument(bound, orderBy, doc) {
4783
4850
  let comparison = 0;
4784
4851
  for (let i = 0; i < bound.position.length; i++) {
4785
4852
  const orderByComponent = orderBy[i];
@@ -4798,7 +4865,23 @@ function sortsBeforeDocument(bound, orderBy, doc) {
4798
4865
  break;
4799
4866
  }
4800
4867
  }
4801
- 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;
4802
4885
  }
4803
4886
  function boundEquals(left, right) {
4804
4887
  if (left === null) {
@@ -4807,7 +4890,7 @@ function boundEquals(left, right) {
4807
4890
  else if (right === null) {
4808
4891
  return false;
4809
4892
  }
4810
- if (left.before !== right.before ||
4893
+ if (left.inclusive !== right.inclusive ||
4811
4894
  left.position.length !== right.position.length) {
4812
4895
  return false;
4813
4896
  }
@@ -5011,10 +5094,10 @@ function queryToTarget(query) {
5011
5094
  }
5012
5095
  // We need to swap the cursors to match the now-flipped query ordering.
5013
5096
  const startAt = queryImpl.endAt
5014
- ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.before)
5097
+ ? new Bound(queryImpl.endAt.position, !queryImpl.endAt.inclusive)
5015
5098
  : null;
5016
5099
  const endAt = queryImpl.startAt
5017
- ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.before)
5100
+ ? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
5018
5101
  : null;
5019
5102
  // Now return as a LimitType.First query.
5020
5103
  queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
@@ -5102,11 +5185,11 @@ function queryMatchesFilters(query, doc) {
5102
5185
  /** Makes sure a document is within the bounds, if provided. */
5103
5186
  function queryMatchesBounds(query, doc) {
5104
5187
  if (query.startAt &&
5105
- !sortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
5188
+ !boundSortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
5106
5189
  return false;
5107
5190
  }
5108
5191
  if (query.endAt &&
5109
- sortsBeforeDocument(query.endAt, queryOrderBy(query), doc)) {
5192
+ !boundSortsAfterDocument(query.endAt, queryOrderBy(query), doc)) {
5110
5193
  return false;
5111
5194
  }
5112
5195
  return true;
@@ -7985,10 +8068,10 @@ function toQueryTarget(serializer, target) {
7985
8068
  result.structuredQuery.limit = limit;
7986
8069
  }
7987
8070
  if (target.startAt) {
7988
- result.structuredQuery.startAt = toCursor(target.startAt);
8071
+ result.structuredQuery.startAt = toStartAtCursor(target.startAt);
7989
8072
  }
7990
8073
  if (target.endAt) {
7991
- result.structuredQuery.endAt = toCursor(target.endAt);
8074
+ result.structuredQuery.endAt = toEndAtCursor(target.endAt);
7992
8075
  }
7993
8076
  return result;
7994
8077
  }
@@ -8021,11 +8104,11 @@ function convertQueryTargetToQuery(target) {
8021
8104
  }
8022
8105
  let startAt = null;
8023
8106
  if (query.startAt) {
8024
- startAt = fromCursor(query.startAt);
8107
+ startAt = fromStartAtCursor(query.startAt);
8025
8108
  }
8026
8109
  let endAt = null;
8027
8110
  if (query.endAt) {
8028
- endAt = fromCursor(query.endAt);
8111
+ endAt = fromEndAtCursor(query.endAt);
8029
8112
  }
8030
8113
  return newQuery(path, collectionGroup, orderBy, filterBy, limit, "F" /* First */, startAt, endAt);
8031
8114
  }
@@ -8116,16 +8199,27 @@ function toOrder(orderBys) {
8116
8199
  function fromOrder(orderBys) {
8117
8200
  return orderBys.map(order => fromPropertyOrder(order));
8118
8201
  }
8119
- function toCursor(cursor) {
8202
+ function toStartAtCursor(cursor) {
8120
8203
  return {
8121
- before: cursor.before,
8204
+ before: cursor.inclusive,
8122
8205
  values: cursor.position
8123
8206
  };
8124
8207
  }
8125
- function fromCursor(cursor) {
8126
- 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;
8127
8216
  const position = cursor.values || [];
8128
- 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);
8129
8223
  }
8130
8224
  // visible for testing
8131
8225
  function toDirection(dir) {
@@ -8678,6 +8772,38 @@ class MemoryIndexManager {
8678
8772
  getCollectionParents(transaction, collectionId) {
8679
8773
  return PersistencePromise.resolve(this.collectionParentIndex.getEntries(collectionId));
8680
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
+ }
8681
8807
  }
8682
8808
  /**
8683
8809
  * Internal implementation of the collection-parent index exposed by MemoryIndexManager.
@@ -8786,6 +8912,38 @@ class IndexedDbIndexManager {
8786
8912
  return parentPaths;
8787
8913
  });
8788
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
+ }
8789
8947
  }
8790
8948
  /**
8791
8949
  * Helper to get a typed SimpleDbStore for the collectionParents
@@ -10637,9 +10795,6 @@ class SchemaConverter {
10637
10795
  * and local feature development.
10638
10796
  */
10639
10797
  createOrUpgrade(db, txn, fromVersion, toVersion) {
10640
- hardAssert(fromVersion < toVersion &&
10641
- fromVersion >= 0 &&
10642
- toVersion <= SCHEMA_VERSION);
10643
10798
  const simpleDbTransaction = new SimpleDbTransaction('createOrUpgrade', txn);
10644
10799
  if (fromVersion < 1 && toVersion >= 1) {
10645
10800
  createPrimaryClientStore(db);
@@ -10706,6 +10861,11 @@ class SchemaConverter {
10706
10861
  createNamedQueriesStore(db);
10707
10862
  });
10708
10863
  }
10864
+ if (fromVersion < 12 && toVersion >= 12) {
10865
+ p = p.next(() => {
10866
+ createFieldIndex(db);
10867
+ });
10868
+ }
10709
10869
  return p;
10710
10870
  }
10711
10871
  addDocumentGlobal(txn) {
@@ -10912,6 +11072,17 @@ function createNamedQueriesStore(db) {
10912
11072
  db.createObjectStore(DbNamedQuery.store, {
10913
11073
  keyPath: DbNamedQuery.keyPath
10914
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
+ });
10915
11086
  }
10916
11087
 
10917
11088
  /**
@@ -25228,51 +25399,53 @@ function limitToLast(limit) {
25228
25399
  return new QueryLimitConstraint('limitToLast', limit, "L" /* Last */);
25229
25400
  }
25230
25401
  class QueryStartAtConstraint extends QueryConstraint {
25231
- constructor(type, _docOrFields, _before) {
25402
+ constructor(type, _docOrFields, _inclusive) {
25232
25403
  super();
25233
25404
  this.type = type;
25234
25405
  this._docOrFields = _docOrFields;
25235
- this._before = _before;
25406
+ this._inclusive = _inclusive;
25236
25407
  }
25237
25408
  _apply(query) {
25238
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
25409
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
25239
25410
  return new Query(query.firestore, query.converter, queryWithStartAt(query._query, bound));
25240
25411
  }
25241
25412
  }
25242
25413
  function startAt(...docOrFields) {
25243
- return new QueryStartAtConstraint('startAt', docOrFields, /*before=*/ true);
25414
+ return new QueryStartAtConstraint('startAt', docOrFields,
25415
+ /*inclusive=*/ true);
25244
25416
  }
25245
25417
  function startAfter(...docOrFields) {
25246
25418
  return new QueryStartAtConstraint('startAfter', docOrFields,
25247
- /*before=*/ false);
25419
+ /*inclusive=*/ false);
25248
25420
  }
25249
25421
  class QueryEndAtConstraint extends QueryConstraint {
25250
- constructor(type, _docOrFields, _before) {
25422
+ constructor(type, _docOrFields, _inclusive) {
25251
25423
  super();
25252
25424
  this.type = type;
25253
25425
  this._docOrFields = _docOrFields;
25254
- this._before = _before;
25426
+ this._inclusive = _inclusive;
25255
25427
  }
25256
25428
  _apply(query) {
25257
- const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._before);
25429
+ const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
25258
25430
  return new Query(query.firestore, query.converter, queryWithEndAt(query._query, bound));
25259
25431
  }
25260
25432
  }
25261
25433
  function endBefore(...docOrFields) {
25262
- return new QueryEndAtConstraint('endBefore', docOrFields, /*before=*/ true);
25434
+ return new QueryEndAtConstraint('endBefore', docOrFields,
25435
+ /*inclusive=*/ false);
25263
25436
  }
25264
25437
  function endAt(...docOrFields) {
25265
- return new QueryEndAtConstraint('endAt', docOrFields, /*before=*/ false);
25438
+ return new QueryEndAtConstraint('endAt', docOrFields, /*inclusive=*/ true);
25266
25439
  }
25267
25440
  /** Helper function to create a bound from a document or fields */
25268
- function newQueryBoundFromDocOrFields(query, methodName, docOrFields, before) {
25441
+ function newQueryBoundFromDocOrFields(query, methodName, docOrFields, inclusive) {
25269
25442
  docOrFields[0] = getModularInstance(docOrFields[0]);
25270
25443
  if (docOrFields[0] instanceof DocumentSnapshot$1) {
25271
- 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);
25272
25445
  }
25273
25446
  else {
25274
25447
  const reader = newUserDataReader(query.firestore);
25275
- return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, before);
25448
+ return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, inclusive);
25276
25449
  }
25277
25450
  }
25278
25451
  function newQueryFilter(query, methodName, dataReader, databaseId, fieldPath, op, value) {
@@ -25330,7 +25503,7 @@ function newQueryOrderBy(query, fieldPath, direction) {
25330
25503
  * of the query or if any of the fields in the order by are an uncommitted
25331
25504
  * server timestamp.
25332
25505
  */
25333
- function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
25506
+ function newQueryBoundFromDocument(query, databaseId, methodName, doc, inclusive) {
25334
25507
  if (!doc) {
25335
25508
  throw new FirestoreError(Code.NOT_FOUND, `Can't use a DocumentSnapshot that doesn't exist for ` +
25336
25509
  `${methodName}().`);
@@ -25367,12 +25540,12 @@ function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
25367
25540
  }
25368
25541
  }
25369
25542
  }
25370
- return new Bound(components, before);
25543
+ return new Bound(components, inclusive);
25371
25544
  }
25372
25545
  /**
25373
25546
  * Converts a list of field values to a `Bound` for the given query.
25374
25547
  */
25375
- function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, before) {
25548
+ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, inclusive) {
25376
25549
  // Use explicit order by's because it has to match the query the user made
25377
25550
  const orderBy = query.explicitOrderBy;
25378
25551
  if (values.length > orderBy.length) {
@@ -25409,7 +25582,7 @@ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, valu
25409
25582
  components.push(wrapped);
25410
25583
  }
25411
25584
  }
25412
- return new Bound(components, before);
25585
+ return new Bound(components, inclusive);
25413
25586
  }
25414
25587
  /**
25415
25588
  * Parses the given `documentIdValue` into a `ReferenceValue`, throwing