@firebase/firestore 3.4.13 → 3.4.14-canary.47895fe5b

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 (77) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/firestore/src/api/credentials.d.ts +13 -3
  3. package/dist/firestore/src/api/index_configuration.d.ts +7 -8
  4. package/dist/firestore/src/api.d.ts +1 -1
  5. package/dist/firestore/src/local/indexeddb_schema.d.ts +1 -3
  6. package/dist/firestore/src/local/local_store_impl.d.ts +2 -0
  7. package/dist/firestore/src/util/array.d.ts +18 -0
  8. package/dist/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  9. package/dist/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  10. package/dist/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  11. package/dist/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  12. package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  13. package/dist/firestore/test/unit/util/array.test.d.ts +17 -0
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.esm2017.js +3737 -3589
  16. package/dist/index.esm2017.js.map +1 -1
  17. package/dist/index.esm5.js +3721 -3604
  18. package/dist/index.esm5.js.map +1 -1
  19. package/dist/index.node.cjs.js +250 -53
  20. package/dist/index.node.cjs.js.map +1 -1
  21. package/dist/index.node.mjs +250 -53
  22. package/dist/index.node.mjs.map +1 -1
  23. package/dist/index.rn.js +3676 -3529
  24. package/dist/index.rn.js.map +1 -1
  25. package/dist/internal.d.ts +13 -13
  26. package/dist/lite/firestore/src/api/credentials.d.ts +13 -3
  27. package/dist/lite/firestore/src/api/index_configuration.d.ts +7 -8
  28. package/dist/lite/firestore/src/api.d.ts +1 -1
  29. package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +1 -3
  30. package/dist/lite/firestore/src/local/local_store_impl.d.ts +2 -0
  31. package/dist/lite/firestore/src/util/array.d.ts +18 -0
  32. package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  33. package/dist/lite/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  34. package/dist/lite/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  35. package/dist/lite/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  36. package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  37. package/dist/lite/firestore/test/unit/util/array.test.d.ts +17 -0
  38. package/dist/lite/index.browser.esm2017.js +232 -222
  39. package/dist/lite/index.browser.esm2017.js.map +1 -1
  40. package/dist/lite/index.browser.esm5.js +485 -469
  41. package/dist/lite/index.browser.esm5.js.map +1 -1
  42. package/dist/lite/index.node.cjs.js +36 -18
  43. package/dist/lite/index.node.cjs.js.map +1 -1
  44. package/dist/lite/index.node.mjs +36 -18
  45. package/dist/lite/index.node.mjs.map +1 -1
  46. package/dist/lite/index.rn.esm2017.js +232 -222
  47. package/dist/lite/index.rn.esm2017.js.map +1 -1
  48. package/dist/lite/internal.d.ts +3 -0
  49. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +23 -23
  50. package/dist/lite/packages/firestore/src/api/credentials.d.ts +13 -3
  51. package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +7 -8
  52. package/dist/lite/packages/firestore/src/api.d.ts +1 -1
  53. package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +1 -3
  54. package/dist/lite/packages/firestore/src/local/local_store_impl.d.ts +2 -0
  55. package/dist/lite/packages/firestore/src/util/array.d.ts +18 -0
  56. package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  57. package/dist/lite/packages/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  58. package/dist/lite/packages/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  59. package/dist/lite/packages/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  60. package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  61. package/dist/lite/packages/firestore/test/unit/util/array.test.d.ts +17 -0
  62. package/dist/lite/private.d.ts +3 -0
  63. package/dist/packages/firestore/dist/index.esm2017.d.ts +193 -193
  64. package/dist/packages/firestore/src/api/credentials.d.ts +13 -3
  65. package/dist/packages/firestore/src/api/index_configuration.d.ts +7 -8
  66. package/dist/packages/firestore/src/api.d.ts +1 -1
  67. package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +1 -3
  68. package/dist/packages/firestore/src/local/local_store_impl.d.ts +2 -0
  69. package/dist/packages/firestore/src/util/array.d.ts +18 -0
  70. package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
  71. package/dist/packages/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
  72. package/dist/packages/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
  73. package/dist/packages/firestore/test/unit/specs/spec_builder.d.ts +5 -0
  74. package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
  75. package/dist/packages/firestore/test/unit/util/array.test.d.ts +17 -0
  76. package/dist/private.d.ts +4 -1
  77. package/package.json +10 -9
@@ -8,7 +8,7 @@ import * as grpc from '@grpc/grpc-js';
8
8
  import * as protoLoader from '@grpc/proto-loader';
9
9
 
10
10
  const name = "@firebase/firestore";
11
- const version$1 = "3.4.13";
11
+ const version$1 = "3.4.14-canary.47895fe5b";
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.9.1";
64
+ const version = "9.9.3-canary.47895fe5b";
65
65
 
66
66
  /**
67
67
  * @license
@@ -616,18 +616,40 @@ class FirebaseAuthCredentialsProvider {
616
616
  * safer to keep the implementation as-is.
617
617
  */
618
618
  class FirstPartyToken {
619
- constructor(gapi, sessionIndex, iamToken) {
619
+ constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
620
+ this.gapi = gapi;
621
+ this.sessionIndex = sessionIndex;
622
+ this.iamToken = iamToken;
623
+ this.authTokenFactory = authTokenFactory;
620
624
  this.type = 'FirstParty';
621
625
  this.user = User.FIRST_PARTY;
622
- this.headers = new Map();
623
- this.headers.set('X-Goog-AuthUser', sessionIndex);
624
- const authHeader = gapi['auth']['getAuthHeaderValueForFirstParty']([]);
625
- if (authHeader) {
626
- this.headers.set('Authorization', authHeader);
626
+ this._headers = new Map();
627
+ }
628
+ /** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
629
+ getAuthToken() {
630
+ if (this.authTokenFactory) {
631
+ return this.authTokenFactory();
632
+ }
633
+ else {
634
+ // Make sure this really is a Gapi client.
635
+ hardAssert(!!(typeof this.gapi === 'object' &&
636
+ this.gapi !== null &&
637
+ this.gapi['auth'] &&
638
+ this.gapi['auth']['getAuthHeaderValueForFirstParty']));
639
+ return this.gapi['auth']['getAuthHeaderValueForFirstParty']([]);
640
+ }
641
+ }
642
+ get headers() {
643
+ this._headers.set('X-Goog-AuthUser', this.sessionIndex);
644
+ // Use array notation to prevent minification
645
+ const authHeaderTokenValue = this.getAuthToken();
646
+ if (authHeaderTokenValue) {
647
+ this._headers.set('Authorization', authHeaderTokenValue);
627
648
  }
628
- if (iamToken) {
629
- this.headers.set('X-Goog-Iam-Authorization-Token', iamToken);
649
+ if (this.iamToken) {
650
+ this._headers.set('X-Goog-Iam-Authorization-Token', this.iamToken);
630
651
  }
652
+ return this._headers;
631
653
  }
632
654
  }
633
655
  /*
@@ -636,13 +658,14 @@ class FirstPartyToken {
636
658
  * to applications hosted by Google.
637
659
  */
638
660
  class FirstPartyAuthCredentialsProvider {
639
- constructor(gapi, sessionIndex, iamToken) {
661
+ constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
640
662
  this.gapi = gapi;
641
663
  this.sessionIndex = sessionIndex;
642
664
  this.iamToken = iamToken;
665
+ this.authTokenFactory = authTokenFactory;
643
666
  }
644
667
  getToken() {
645
- return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken));
668
+ return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken, this.authTokenFactory));
646
669
  }
647
670
  start(asyncQueue, changeListener) {
648
671
  // Fire with initial uid.
@@ -753,12 +776,7 @@ function makeAuthCredentialsProvider(credentials) {
753
776
  switch (credentials['type']) {
754
777
  case 'gapi':
755
778
  const client = credentials['client'];
756
- // Make sure this really is a Gapi client.
757
- hardAssert(!!(typeof client === 'object' &&
758
- client !== null &&
759
- client['auth'] &&
760
- client['auth']['getAuthHeaderValueForFirstParty']));
761
- return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null);
779
+ return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null, credentials['authTokenFactory'] || null);
762
780
  case 'provider':
763
781
  return credentials['client'];
764
782
  default:
@@ -1498,6 +1516,23 @@ function fieldIndexGetKeyOrder(fieldIndex) {
1498
1516
  ? 0 /* ASCENDING */
1499
1517
  : directionalSegments[directionalSegments.length - 1].kind;
1500
1518
  }
1519
+ /**
1520
+ * Compares indexes by collection group and segments. Ignores update time and
1521
+ * index ID.
1522
+ */
1523
+ function fieldIndexSemanticComparator(left, right) {
1524
+ let cmp = primitiveComparator(left.collectionGroup, right.collectionGroup);
1525
+ if (cmp !== 0) {
1526
+ return cmp;
1527
+ }
1528
+ for (let i = 0; i < Math.min(left.fields.length, right.fields.length); ++i) {
1529
+ cmp = indexSegmentComparator(left.fields[i], right.fields[i]);
1530
+ if (cmp !== 0) {
1531
+ return cmp;
1532
+ }
1533
+ }
1534
+ return primitiveComparator(left.fields.length, right.fields.length);
1535
+ }
1501
1536
  /** Returns a debug representation of the field index */
1502
1537
  function fieldIndexToString(fieldIndex) {
1503
1538
  return `id=${fieldIndex.indexId}|cg=${fieldIndex.collectionGroup}|f=${fieldIndex.fields.map(f => `${f.fieldPath}:${f.kind}`).join(',')}`;
@@ -1513,6 +1548,13 @@ class IndexSegment {
1513
1548
  this.kind = kind;
1514
1549
  }
1515
1550
  }
1551
+ function indexSegmentComparator(left, right) {
1552
+ const cmp = FieldPath$1.comparator(left.fieldPath, right.fieldPath);
1553
+ if (cmp !== 0) {
1554
+ return cmp;
1555
+ }
1556
+ return primitiveComparator(left.kind, right.kind);
1557
+ }
1516
1558
  /**
1517
1559
  * Stores the "high water mark" that indicates how updated the Index is for the
1518
1560
  * current user.
@@ -1599,31 +1641,6 @@ function indexOffsetComparator(left, right) {
1599
1641
  }
1600
1642
  return primitiveComparator(left.largestBatchId, right.largestBatchId);
1601
1643
  }
1602
- /**
1603
- * Schema Version for the Web client:
1604
- * 1. Initial version including Mutation Queue, Query Cache, and Remote
1605
- * Document Cache
1606
- * 2. Used to ensure a targetGlobal object exists and add targetCount to it. No
1607
- * longer required because migration 3 unconditionally clears it.
1608
- * 3. Dropped and re-created Query Cache to deal with cache corruption related
1609
- * to limbo resolution. Addresses
1610
- * https://github.com/firebase/firebase-ios-sdk/issues/1548
1611
- * 4. Multi-Tab Support.
1612
- * 5. Removal of held write acks.
1613
- * 6. Create document global for tracking document cache size.
1614
- * 7. Ensure every cached document has a sentinel row with a sequence number.
1615
- * 8. Add collection-parent index for Collection Group queries.
1616
- * 9. Change RemoteDocumentChanges store to be keyed by readTime rather than
1617
- * an auto-incrementing ID. This is required for Index-Free queries.
1618
- * 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
1619
- * 11. Add bundles and named_queries for bundle support.
1620
- * 12. Add document overlays.
1621
- * 13. Rewrite the keys of the remote document cache to allow for efficient
1622
- * document lookup via `getAll()`.
1623
- * 14. Add overlays.
1624
- * 15. Add indexing support.
1625
- */
1626
- const SCHEMA_VERSION = 14;
1627
1644
 
1628
1645
  /**
1629
1646
  * @license
@@ -2583,6 +2600,8 @@ function checkForAndReportiOSError(error) {
2583
2600
  }
2584
2601
 
2585
2602
  const LOG_TAG$h = 'IndexBackiller';
2603
+ /** How long we wait to try running index backfill after SDK initialization. */
2604
+ const INITIAL_BACKFILL_DELAY_MS = 15;
2586
2605
  /** Minimum amount of time between backfill checks, after the first one. */
2587
2606
  const REGULAR_BACKFILL_DELAY_MS = 1;
2588
2607
  /** The maximum number of documents to process each time backfill() is called. */
@@ -2595,6 +2614,7 @@ class IndexBackfillerScheduler {
2595
2614
  this.task = null;
2596
2615
  }
2597
2616
  start() {
2617
+ this.schedule(INITIAL_BACKFILL_DELAY_MS);
2598
2618
  }
2599
2619
  stop() {
2600
2620
  if (this.task) {
@@ -12710,6 +12730,48 @@ function dbKeyComparator(l, r) {
12710
12730
  return primitiveComparator(left[left.length - 1], right[right.length - 1]);
12711
12731
  }
12712
12732
 
12733
+ /**
12734
+ * @license
12735
+ * Copyright 2017 Google LLC
12736
+ *
12737
+ * Licensed under the Apache License, Version 2.0 (the "License");
12738
+ * you may not use this file except in compliance with the License.
12739
+ * You may obtain a copy of the License at
12740
+ *
12741
+ * http://www.apache.org/licenses/LICENSE-2.0
12742
+ *
12743
+ * Unless required by applicable law or agreed to in writing, software
12744
+ * distributed under the License is distributed on an "AS IS" BASIS,
12745
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12746
+ * See the License for the specific language governing permissions and
12747
+ * limitations under the License.
12748
+ */
12749
+ /**
12750
+ * Schema Version for the Web client:
12751
+ * 1. Initial version including Mutation Queue, Query Cache, and Remote
12752
+ * Document Cache
12753
+ * 2. Used to ensure a targetGlobal object exists and add targetCount to it. No
12754
+ * longer required because migration 3 unconditionally clears it.
12755
+ * 3. Dropped and re-created Query Cache to deal with cache corruption related
12756
+ * to limbo resolution. Addresses
12757
+ * https://github.com/firebase/firebase-ios-sdk/issues/1548
12758
+ * 4. Multi-Tab Support.
12759
+ * 5. Removal of held write acks.
12760
+ * 6. Create document global for tracking document cache size.
12761
+ * 7. Ensure every cached document has a sentinel row with a sequence number.
12762
+ * 8. Add collection-parent index for Collection Group queries.
12763
+ * 9. Change RemoteDocumentChanges store to be keyed by readTime rather than
12764
+ * an auto-incrementing ID. This is required for Index-Free queries.
12765
+ * 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
12766
+ * 11. Add bundles and named_queries for bundle support.
12767
+ * 12. Add document overlays.
12768
+ * 13. Rewrite the keys of the remote document cache to allow for efficient
12769
+ * document lookup via `getAll()`.
12770
+ * 14. Add overlays.
12771
+ * 15. Add indexing support.
12772
+ */
12773
+ const SCHEMA_VERSION = 15;
12774
+
12713
12775
  /**
12714
12776
  * @license
12715
12777
  * Copyright 2022 Google LLC
@@ -15248,6 +15310,73 @@ async function indexedDbClearPersistence(persistenceKey) {
15248
15310
  await SimpleDb.delete(dbName);
15249
15311
  }
15250
15312
 
15313
+ /**
15314
+ * @license
15315
+ * Copyright 2017 Google LLC
15316
+ *
15317
+ * Licensed under the Apache License, Version 2.0 (the "License");
15318
+ * you may not use this file except in compliance with the License.
15319
+ * You may obtain a copy of the License at
15320
+ *
15321
+ * http://www.apache.org/licenses/LICENSE-2.0
15322
+ *
15323
+ * Unless required by applicable law or agreed to in writing, software
15324
+ * distributed under the License is distributed on an "AS IS" BASIS,
15325
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15326
+ * See the License for the specific language governing permissions and
15327
+ * limitations under the License.
15328
+ */
15329
+ /**
15330
+ * Compares two array for equality using comparator. The method computes the
15331
+ * intersection and invokes `onAdd` for every element that is in `after` but not
15332
+ * `before`. `onRemove` is invoked for every element in `before` but missing
15333
+ * from `after`.
15334
+ *
15335
+ * The method creates a copy of both `before` and `after` and runs in O(n log
15336
+ * n), where n is the size of the two lists.
15337
+ *
15338
+ * @param before - The elements that exist in the original array.
15339
+ * @param after - The elements to diff against the original array.
15340
+ * @param comparator - The comparator for the elements in before and after.
15341
+ * @param onAdd - A function to invoke for every element that is part of `
15342
+ * after` but not `before`.
15343
+ * @param onRemove - A function to invoke for every element that is part of
15344
+ * `before` but not `after`.
15345
+ */
15346
+ function diffArrays(before, after, comparator, onAdd, onRemove) {
15347
+ before = [...before];
15348
+ after = [...after];
15349
+ before.sort(comparator);
15350
+ after.sort(comparator);
15351
+ const bLen = before.length;
15352
+ const aLen = after.length;
15353
+ let a = 0;
15354
+ let b = 0;
15355
+ while (a < aLen && b < bLen) {
15356
+ const cmp = comparator(before[b], after[a]);
15357
+ if (cmp < 0) {
15358
+ // The element was removed if the next element in our ordered
15359
+ // walkthrough is only in `before`.
15360
+ onRemove(before[b++]);
15361
+ }
15362
+ else if (cmp > 0) {
15363
+ // The element was added if the next element in our ordered walkthrough
15364
+ // is only in `after`.
15365
+ onAdd(after[a++]);
15366
+ }
15367
+ else {
15368
+ a++;
15369
+ b++;
15370
+ }
15371
+ }
15372
+ while (a < aLen) {
15373
+ onAdd(after[a++]);
15374
+ }
15375
+ while (b < bLen) {
15376
+ onRemove(before[b++]);
15377
+ }
15378
+ }
15379
+
15251
15380
  /**
15252
15381
  * @license
15253
15382
  * Copyright 2020 Google LLC
@@ -16097,6 +16226,19 @@ async function localStoreSaveNamedQuery(localStore, query, documents = documentK
16097
16226
  .next(() => localStoreImpl.targetCache.addMatchingKeys(transaction, documents, allocated.targetId))
16098
16227
  .next(() => localStoreImpl.bundleCache.saveNamedQuery(transaction, query));
16099
16228
  });
16229
+ }
16230
+ async function localStoreConfigureFieldIndexes(localStore, newFieldIndexes) {
16231
+ const localStoreImpl = debugCast(localStore);
16232
+ const indexManager = localStoreImpl.indexManager;
16233
+ const promises = [];
16234
+ return localStoreImpl.persistence.runTransaction('Configure indexes', 'readwrite', transaction => indexManager
16235
+ .getFieldIndexes(transaction)
16236
+ .next(oldFieldIndexes => diffArrays(oldFieldIndexes, newFieldIndexes, fieldIndexSemanticComparator, fieldIndex => {
16237
+ promises.push(indexManager.addFieldIndex(transaction, fieldIndex));
16238
+ }, fieldIndex => {
16239
+ promises.push(indexManager.deleteFieldIndex(transaction, fieldIndex));
16240
+ }))
16241
+ .next(() => PersistencePromise.waitFor(promises)));
16100
16242
  }
16101
16243
 
16102
16244
  /**
@@ -16176,9 +16318,56 @@ class QueryEngine {
16176
16318
  * persisted index values. Returns `null` if an index is not available.
16177
16319
  */
16178
16320
  performQueryUsingIndex(transaction, query) {
16179
- {
16321
+ if (queryMatchesAllDocuments(query)) {
16322
+ // Queries that match all documents don't benefit from using
16323
+ // key-based lookups. It is more efficient to scan all documents in a
16324
+ // collection, rather than to perform individual lookups.
16180
16325
  return PersistencePromise.resolve(null);
16181
16326
  }
16327
+ let target = queryToTarget(query);
16328
+ return this.indexManager
16329
+ .getIndexType(transaction, target)
16330
+ .next(indexType => {
16331
+ if (indexType === 0 /* NONE */) {
16332
+ // The target cannot be served from any index.
16333
+ return null;
16334
+ }
16335
+ if (query.limit !== null && indexType === 1 /* PARTIAL */) {
16336
+ // We cannot apply a limit for targets that are served using a partial
16337
+ // index. If a partial index will be used to serve the target, the
16338
+ // query may return a superset of documents that match the target
16339
+ // (e.g. if the index doesn't include all the target's filters), or
16340
+ // may return the correct set of documents in the wrong order (e.g. if
16341
+ // the index doesn't include a segment for one of the orderBys).
16342
+ // Therefore, a limit should not be applied in such cases.
16343
+ query = queryWithLimit(query, null, "F" /* First */);
16344
+ target = queryToTarget(query);
16345
+ }
16346
+ return this.indexManager
16347
+ .getDocumentsMatchingTarget(transaction, target)
16348
+ .next(keys => {
16349
+ const sortedKeys = documentKeySet(...keys);
16350
+ return this.localDocumentsView
16351
+ .getDocuments(transaction, sortedKeys)
16352
+ .next(indexedDocuments => {
16353
+ return this.indexManager
16354
+ .getMinOffset(transaction, target)
16355
+ .next(offset => {
16356
+ const previousResults = this.applyQuery(query, indexedDocuments);
16357
+ if (this.needsRefill(query, previousResults, sortedKeys, offset.readTime)) {
16358
+ // A limit query whose boundaries change due to local
16359
+ // edits can be re-run against the cache by excluding the
16360
+ // limit. This ensures that all documents that match the
16361
+ // query's filters are included in the result set. The SDK
16362
+ // can then apply the limit once all local edits are
16363
+ // incorporated.
16364
+ return this.performQueryUsingIndex(transaction, queryWithLimit(query, null, "F" /* First */));
16365
+ }
16366
+ return this.appendRemainingResults(transaction, previousResults, query, offset);
16367
+ });
16368
+ });
16369
+ });
16370
+ });
16182
16371
  }
16183
16372
  /**
16184
16373
  * Performs a query based on the target's persisted query mapping. Returns
@@ -24273,7 +24462,7 @@ class AsyncObserver {
24273
24462
  this.scheduleEvent(this.observer.error, error);
24274
24463
  }
24275
24464
  else {
24276
- console.error('Uncaught Error in snapshot listener:', error);
24465
+ logError('Uncaught Error in snapshot listener:', error);
24277
24466
  }
24278
24467
  }
24279
24468
  mute() {
@@ -26204,7 +26393,7 @@ function setPersistenceProviders(client, onlineComponentProvider, offlineCompone
26204
26393
  if (!canFallbackFromIndexedDbError(error)) {
26205
26394
  throw error;
26206
26395
  }
26207
- console.warn('Error enabling offline persistence. Falling back to ' +
26396
+ logWarn('Error enabling offline persistence. Falling back to ' +
26208
26397
  'persistence disabled: ' +
26209
26398
  error);
26210
26399
  persistenceResult.reject(error);
@@ -29118,14 +29307,23 @@ function writeBatch(firestore) {
29118
29307
  * limitations under the License.
29119
29308
  */
29120
29309
  function setIndexConfiguration(firestore, jsonOrConfiguration) {
29310
+ var _a;
29121
29311
  firestore = cast(firestore, Firestore);
29122
- ensureFirestoreConfigured(firestore);
29312
+ const client = ensureFirestoreConfigured(firestore);
29313
+ // PORTING NOTE: We don't return an error if the user has not enabled
29314
+ // persistence since `enableIndexeddbPersistence()` can fail on the Web.
29315
+ if (!((_a = client.offlineComponents) === null || _a === void 0 ? void 0 : _a.indexBackfillerScheduler)) {
29316
+ logWarn('Cannot enable indexes when persistence is disabled');
29317
+ return Promise.resolve();
29318
+ }
29319
+ const parsedIndexes = parseIndexes(jsonOrConfiguration);
29320
+ return getLocalStore(client).then(localStore => localStoreConfigureFieldIndexes(localStore, parsedIndexes));
29321
+ }
29322
+ function parseIndexes(jsonOrConfiguration) {
29123
29323
  const indexConfiguration = typeof jsonOrConfiguration === 'string'
29124
29324
  ? tryParseJson(jsonOrConfiguration)
29125
29325
  : jsonOrConfiguration;
29126
29326
  const parsedIndexes = [];
29127
- // PORTING NOTE: We don't return an error if the user has not enabled
29128
- // persistence since `enableIndexeddbPersistence()` can fail on the Web.
29129
29327
  if (Array.isArray(indexConfiguration.indexes)) {
29130
29328
  for (const index of indexConfiguration.indexes) {
29131
29329
  const collectionGroup = tryGetString(index, 'collectionGroup');
@@ -29148,8 +29346,7 @@ function setIndexConfiguration(firestore, jsonOrConfiguration) {
29148
29346
  parsedIndexes.push(new FieldIndex(FieldIndex.UNKNOWN_ID, collectionGroup, segments, IndexState.empty()));
29149
29347
  }
29150
29348
  }
29151
- // TODO(indexing): Configure indexes
29152
- return Promise.resolve();
29349
+ return parsedIndexes;
29153
29350
  }
29154
29351
  function tryParseJson(json) {
29155
29352
  var _a;
@@ -29157,7 +29354,7 @@ function tryParseJson(json) {
29157
29354
  return JSON.parse(json);
29158
29355
  }
29159
29356
  catch (e) {
29160
- throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON:' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
29357
+ throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON: ' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
29161
29358
  }
29162
29359
  }
29163
29360
  function tryGetString(data, property) {
@@ -29185,5 +29382,5 @@ function tryGetString(data, property) {
29185
29382
  */
29186
29383
  registerFirestore('node');
29187
29384
 
29188
- export { AbstractUserDataWriter, Bytes, CACHE_SIZE_UNLIMITED, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, LoadBundleTask, Query, QueryConstraint, QueryDocumentSnapshot, QuerySnapshot, SnapshotMetadata, Timestamp, Transaction, WriteBatch, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, cast as _cast, debugAssert as _debugAssert, isBase64Available as _isBase64Available, logWarn as _logWarn, setIndexConfiguration as _setIndexConfiguration, validateIsNotUsedTogether as _validateIsNotUsedTogether, addDoc, arrayRemove, arrayUnion, clearIndexedDbPersistence, collection, collectionGroup, connectFirestoreEmulator, deleteDoc, deleteField, disableNetwork, doc, documentId, enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence, enableNetwork, endAt, endBefore, ensureFirestoreConfigured, executeWrite, getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, getFirestore, increment, initializeFirestore, limit, limitToLast, loadBundle, namedQuery, onSnapshot, onSnapshotsInSync, orderBy, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setLogLevel, snapshotEqual, startAfter, startAt, terminate, updateDoc, waitForPendingWrites, where, writeBatch };
29385
+ export { AbstractUserDataWriter, Bytes, CACHE_SIZE_UNLIMITED, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, LoadBundleTask, Query, QueryConstraint, QueryDocumentSnapshot, QuerySnapshot, SnapshotMetadata, Timestamp, Transaction, WriteBatch, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, cast as _cast, debugAssert as _debugAssert, isBase64Available as _isBase64Available, logWarn as _logWarn, validateIsNotUsedTogether as _validateIsNotUsedTogether, addDoc, arrayRemove, arrayUnion, clearIndexedDbPersistence, collection, collectionGroup, connectFirestoreEmulator, deleteDoc, deleteField, disableNetwork, doc, documentId, enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence, enableNetwork, endAt, endBefore, ensureFirestoreConfigured, executeWrite, getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, getFirestore, increment, initializeFirestore, limit, limitToLast, loadBundle, namedQuery, onSnapshot, onSnapshotsInSync, orderBy, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setIndexConfiguration, setLogLevel, snapshotEqual, startAfter, startAt, terminate, updateDoc, waitForPendingWrites, where, writeBatch };
29189
29386
  //# sourceMappingURL=index.node.mjs.map