@firebase/firestore 3.4.13 → 3.4.14-20220804201204
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.
- package/CHANGELOG.md +11 -0
- package/dist/firestore/src/api/index_configuration.d.ts +2 -8
- package/dist/firestore/src/api.d.ts +1 -1
- package/dist/firestore/src/local/indexeddb_schema.d.ts +1 -3
- package/dist/firestore/src/local/local_store_impl.d.ts +2 -0
- package/dist/firestore/src/util/array.d.ts +18 -0
- package/dist/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
- package/dist/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
- package/dist/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
- package/dist/firestore/test/unit/specs/spec_builder.d.ts +5 -0
- package/dist/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
- package/dist/firestore/test/unit/util/array.test.d.ts +17 -0
- package/dist/index.d.ts +91 -1
- package/dist/index.esm2017.js +2525 -2387
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2383 -2282
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +216 -37
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +216 -37
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2448 -2311
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +5 -13
- package/dist/lite/firestore/src/api/index_configuration.d.ts +2 -8
- package/dist/lite/firestore/src/api.d.ts +1 -1
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +1 -3
- package/dist/lite/firestore/src/local/local_store_impl.d.ts +2 -0
- package/dist/lite/firestore/src/util/array.d.ts +18 -0
- package/dist/lite/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
- package/dist/lite/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/specs/spec_builder.d.ts +5 -0
- package/dist/lite/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
- package/dist/lite/firestore/test/unit/util/array.test.d.ts +17 -0
- package/dist/lite/index.browser.esm2017.js +2 -2
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +2 -2
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +2 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +2 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +2 -2
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +2 -8
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +1 -3
- package/dist/lite/packages/firestore/src/local/local_store_impl.d.ts +2 -0
- package/dist/lite/packages/firestore/src/util/array.d.ts +18 -0
- package/dist/lite/packages/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
- package/dist/lite/packages/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/specs/spec_builder.d.ts +5 -0
- package/dist/lite/packages/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
- package/dist/lite/packages/firestore/test/unit/util/array.test.d.ts +17 -0
- package/dist/packages/firestore/dist/index.esm2017.d.ts +150 -150
- package/dist/packages/firestore/src/api/index_configuration.d.ts +2 -8
- package/dist/packages/firestore/src/api.d.ts +1 -1
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +1 -3
- package/dist/packages/firestore/src/local/local_store_impl.d.ts +2 -0
- package/dist/packages/firestore/src/util/array.d.ts +18 -0
- package/dist/packages/firestore/test/unit/local/counting_query_engine.d.ts +11 -0
- package/dist/packages/firestore/test/unit/local/local_store_indexeddb.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/specs/index_spec.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/specs/spec_builder.d.ts +5 -0
- package/dist/packages/firestore/test/unit/specs/spec_test_runner.d.ts +8 -0
- package/dist/packages/firestore/test/unit/util/array.test.d.ts +17 -0
- package/dist/private.d.ts +92 -4
- package/package.json +5 -4
package/dist/index.node.cjs.js
CHANGED
|
@@ -33,7 +33,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
|
|
|
33
33
|
var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
|
|
34
34
|
|
|
35
35
|
const name = "@firebase/firestore";
|
|
36
|
-
const version$1 = "3.4.
|
|
36
|
+
const version$1 = "3.4.14-20220804201204";
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @license
|
|
@@ -86,7 +86,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
86
86
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
87
87
|
User.MOCK_USER = new User('mock-user');
|
|
88
88
|
|
|
89
|
-
const version = "9.9.
|
|
89
|
+
const version = "9.9.2-20220804201204";
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* @license
|
|
@@ -1523,6 +1523,23 @@ function fieldIndexGetKeyOrder(fieldIndex) {
|
|
|
1523
1523
|
? 0 /* ASCENDING */
|
|
1524
1524
|
: directionalSegments[directionalSegments.length - 1].kind;
|
|
1525
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Compares indexes by collection group and segments. Ignores update time and
|
|
1528
|
+
* index ID.
|
|
1529
|
+
*/
|
|
1530
|
+
function fieldIndexSemanticComparator(left, right) {
|
|
1531
|
+
let cmp = primitiveComparator(left.collectionGroup, right.collectionGroup);
|
|
1532
|
+
if (cmp !== 0) {
|
|
1533
|
+
return cmp;
|
|
1534
|
+
}
|
|
1535
|
+
for (let i = 0; i < Math.min(left.fields.length, right.fields.length); ++i) {
|
|
1536
|
+
cmp = indexSegmentComparator(left.fields[i], right.fields[i]);
|
|
1537
|
+
if (cmp !== 0) {
|
|
1538
|
+
return cmp;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
return primitiveComparator(left.fields.length, right.fields.length);
|
|
1542
|
+
}
|
|
1526
1543
|
/** Returns a debug representation of the field index */
|
|
1527
1544
|
function fieldIndexToString(fieldIndex) {
|
|
1528
1545
|
return `id=${fieldIndex.indexId}|cg=${fieldIndex.collectionGroup}|f=${fieldIndex.fields.map(f => `${f.fieldPath}:${f.kind}`).join(',')}`;
|
|
@@ -1538,6 +1555,13 @@ class IndexSegment {
|
|
|
1538
1555
|
this.kind = kind;
|
|
1539
1556
|
}
|
|
1540
1557
|
}
|
|
1558
|
+
function indexSegmentComparator(left, right) {
|
|
1559
|
+
const cmp = FieldPath$1.comparator(left.fieldPath, right.fieldPath);
|
|
1560
|
+
if (cmp !== 0) {
|
|
1561
|
+
return cmp;
|
|
1562
|
+
}
|
|
1563
|
+
return primitiveComparator(left.kind, right.kind);
|
|
1564
|
+
}
|
|
1541
1565
|
/**
|
|
1542
1566
|
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
1543
1567
|
* current user.
|
|
@@ -1624,31 +1648,6 @@ function indexOffsetComparator(left, right) {
|
|
|
1624
1648
|
}
|
|
1625
1649
|
return primitiveComparator(left.largestBatchId, right.largestBatchId);
|
|
1626
1650
|
}
|
|
1627
|
-
/**
|
|
1628
|
-
* Schema Version for the Web client:
|
|
1629
|
-
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
1630
|
-
* Document Cache
|
|
1631
|
-
* 2. Used to ensure a targetGlobal object exists and add targetCount to it. No
|
|
1632
|
-
* longer required because migration 3 unconditionally clears it.
|
|
1633
|
-
* 3. Dropped and re-created Query Cache to deal with cache corruption related
|
|
1634
|
-
* to limbo resolution. Addresses
|
|
1635
|
-
* https://github.com/firebase/firebase-ios-sdk/issues/1548
|
|
1636
|
-
* 4. Multi-Tab Support.
|
|
1637
|
-
* 5. Removal of held write acks.
|
|
1638
|
-
* 6. Create document global for tracking document cache size.
|
|
1639
|
-
* 7. Ensure every cached document has a sentinel row with a sequence number.
|
|
1640
|
-
* 8. Add collection-parent index for Collection Group queries.
|
|
1641
|
-
* 9. Change RemoteDocumentChanges store to be keyed by readTime rather than
|
|
1642
|
-
* an auto-incrementing ID. This is required for Index-Free queries.
|
|
1643
|
-
* 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
|
|
1644
|
-
* 11. Add bundles and named_queries for bundle support.
|
|
1645
|
-
* 12. Add document overlays.
|
|
1646
|
-
* 13. Rewrite the keys of the remote document cache to allow for efficient
|
|
1647
|
-
* document lookup via `getAll()`.
|
|
1648
|
-
* 14. Add overlays.
|
|
1649
|
-
* 15. Add indexing support.
|
|
1650
|
-
*/
|
|
1651
|
-
const SCHEMA_VERSION = 14;
|
|
1652
1651
|
|
|
1653
1652
|
/**
|
|
1654
1653
|
* @license
|
|
@@ -2608,6 +2607,8 @@ function checkForAndReportiOSError(error) {
|
|
|
2608
2607
|
}
|
|
2609
2608
|
|
|
2610
2609
|
const LOG_TAG$h = 'IndexBackiller';
|
|
2610
|
+
/** How long we wait to try running index backfill after SDK initialization. */
|
|
2611
|
+
const INITIAL_BACKFILL_DELAY_MS = 15;
|
|
2611
2612
|
/** Minimum amount of time between backfill checks, after the first one. */
|
|
2612
2613
|
const REGULAR_BACKFILL_DELAY_MS = 1;
|
|
2613
2614
|
/** The maximum number of documents to process each time backfill() is called. */
|
|
@@ -2620,6 +2621,7 @@ class IndexBackfillerScheduler {
|
|
|
2620
2621
|
this.task = null;
|
|
2621
2622
|
}
|
|
2622
2623
|
start() {
|
|
2624
|
+
this.schedule(INITIAL_BACKFILL_DELAY_MS);
|
|
2623
2625
|
}
|
|
2624
2626
|
stop() {
|
|
2625
2627
|
if (this.task) {
|
|
@@ -12735,6 +12737,48 @@ function dbKeyComparator(l, r) {
|
|
|
12735
12737
|
return primitiveComparator(left[left.length - 1], right[right.length - 1]);
|
|
12736
12738
|
}
|
|
12737
12739
|
|
|
12740
|
+
/**
|
|
12741
|
+
* @license
|
|
12742
|
+
* Copyright 2017 Google LLC
|
|
12743
|
+
*
|
|
12744
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12745
|
+
* you may not use this file except in compliance with the License.
|
|
12746
|
+
* You may obtain a copy of the License at
|
|
12747
|
+
*
|
|
12748
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12749
|
+
*
|
|
12750
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12751
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12752
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12753
|
+
* See the License for the specific language governing permissions and
|
|
12754
|
+
* limitations under the License.
|
|
12755
|
+
*/
|
|
12756
|
+
/**
|
|
12757
|
+
* Schema Version for the Web client:
|
|
12758
|
+
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
12759
|
+
* Document Cache
|
|
12760
|
+
* 2. Used to ensure a targetGlobal object exists and add targetCount to it. No
|
|
12761
|
+
* longer required because migration 3 unconditionally clears it.
|
|
12762
|
+
* 3. Dropped and re-created Query Cache to deal with cache corruption related
|
|
12763
|
+
* to limbo resolution. Addresses
|
|
12764
|
+
* https://github.com/firebase/firebase-ios-sdk/issues/1548
|
|
12765
|
+
* 4. Multi-Tab Support.
|
|
12766
|
+
* 5. Removal of held write acks.
|
|
12767
|
+
* 6. Create document global for tracking document cache size.
|
|
12768
|
+
* 7. Ensure every cached document has a sentinel row with a sequence number.
|
|
12769
|
+
* 8. Add collection-parent index for Collection Group queries.
|
|
12770
|
+
* 9. Change RemoteDocumentChanges store to be keyed by readTime rather than
|
|
12771
|
+
* an auto-incrementing ID. This is required for Index-Free queries.
|
|
12772
|
+
* 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
|
|
12773
|
+
* 11. Add bundles and named_queries for bundle support.
|
|
12774
|
+
* 12. Add document overlays.
|
|
12775
|
+
* 13. Rewrite the keys of the remote document cache to allow for efficient
|
|
12776
|
+
* document lookup via `getAll()`.
|
|
12777
|
+
* 14. Add overlays.
|
|
12778
|
+
* 15. Add indexing support.
|
|
12779
|
+
*/
|
|
12780
|
+
const SCHEMA_VERSION = 15;
|
|
12781
|
+
|
|
12738
12782
|
/**
|
|
12739
12783
|
* @license
|
|
12740
12784
|
* Copyright 2022 Google LLC
|
|
@@ -15273,6 +15317,73 @@ async function indexedDbClearPersistence(persistenceKey) {
|
|
|
15273
15317
|
await SimpleDb.delete(dbName);
|
|
15274
15318
|
}
|
|
15275
15319
|
|
|
15320
|
+
/**
|
|
15321
|
+
* @license
|
|
15322
|
+
* Copyright 2017 Google LLC
|
|
15323
|
+
*
|
|
15324
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15325
|
+
* you may not use this file except in compliance with the License.
|
|
15326
|
+
* You may obtain a copy of the License at
|
|
15327
|
+
*
|
|
15328
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15329
|
+
*
|
|
15330
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15331
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15332
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15333
|
+
* See the License for the specific language governing permissions and
|
|
15334
|
+
* limitations under the License.
|
|
15335
|
+
*/
|
|
15336
|
+
/**
|
|
15337
|
+
* Compares two array for equality using comparator. The method computes the
|
|
15338
|
+
* intersection and invokes `onAdd` for every element that is in `after` but not
|
|
15339
|
+
* `before`. `onRemove` is invoked for every element in `before` but missing
|
|
15340
|
+
* from `after`.
|
|
15341
|
+
*
|
|
15342
|
+
* The method creates a copy of both `before` and `after` and runs in O(n log
|
|
15343
|
+
* n), where n is the size of the two lists.
|
|
15344
|
+
*
|
|
15345
|
+
* @param before - The elements that exist in the original array.
|
|
15346
|
+
* @param after - The elements to diff against the original array.
|
|
15347
|
+
* @param comparator - The comparator for the elements in before and after.
|
|
15348
|
+
* @param onAdd - A function to invoke for every element that is part of `
|
|
15349
|
+
* after` but not `before`.
|
|
15350
|
+
* @param onRemove - A function to invoke for every element that is part of
|
|
15351
|
+
* `before` but not `after`.
|
|
15352
|
+
*/
|
|
15353
|
+
function diffArrays(before, after, comparator, onAdd, onRemove) {
|
|
15354
|
+
before = [...before];
|
|
15355
|
+
after = [...after];
|
|
15356
|
+
before.sort(comparator);
|
|
15357
|
+
after.sort(comparator);
|
|
15358
|
+
const bLen = before.length;
|
|
15359
|
+
const aLen = after.length;
|
|
15360
|
+
let a = 0;
|
|
15361
|
+
let b = 0;
|
|
15362
|
+
while (a < aLen && b < bLen) {
|
|
15363
|
+
const cmp = comparator(before[b], after[a]);
|
|
15364
|
+
if (cmp < 0) {
|
|
15365
|
+
// The element was removed if the next element in our ordered
|
|
15366
|
+
// walkthrough is only in `before`.
|
|
15367
|
+
onRemove(before[b++]);
|
|
15368
|
+
}
|
|
15369
|
+
else if (cmp > 0) {
|
|
15370
|
+
// The element was added if the next element in our ordered walkthrough
|
|
15371
|
+
// is only in `after`.
|
|
15372
|
+
onAdd(after[a++]);
|
|
15373
|
+
}
|
|
15374
|
+
else {
|
|
15375
|
+
a++;
|
|
15376
|
+
b++;
|
|
15377
|
+
}
|
|
15378
|
+
}
|
|
15379
|
+
while (a < aLen) {
|
|
15380
|
+
onAdd(after[a++]);
|
|
15381
|
+
}
|
|
15382
|
+
while (b < bLen) {
|
|
15383
|
+
onRemove(before[b++]);
|
|
15384
|
+
}
|
|
15385
|
+
}
|
|
15386
|
+
|
|
15276
15387
|
/**
|
|
15277
15388
|
* @license
|
|
15278
15389
|
* Copyright 2020 Google LLC
|
|
@@ -16122,6 +16233,19 @@ async function localStoreSaveNamedQuery(localStore, query, documents = documentK
|
|
|
16122
16233
|
.next(() => localStoreImpl.targetCache.addMatchingKeys(transaction, documents, allocated.targetId))
|
|
16123
16234
|
.next(() => localStoreImpl.bundleCache.saveNamedQuery(transaction, query));
|
|
16124
16235
|
});
|
|
16236
|
+
}
|
|
16237
|
+
async function localStoreConfigureFieldIndexes(localStore, newFieldIndexes) {
|
|
16238
|
+
const localStoreImpl = debugCast(localStore);
|
|
16239
|
+
const indexManager = localStoreImpl.indexManager;
|
|
16240
|
+
const promises = [];
|
|
16241
|
+
return localStoreImpl.persistence.runTransaction('Configure indexes', 'readwrite', transaction => indexManager
|
|
16242
|
+
.getFieldIndexes(transaction)
|
|
16243
|
+
.next(oldFieldIndexes => diffArrays(oldFieldIndexes, newFieldIndexes, fieldIndexSemanticComparator, fieldIndex => {
|
|
16244
|
+
promises.push(indexManager.addFieldIndex(transaction, fieldIndex));
|
|
16245
|
+
}, fieldIndex => {
|
|
16246
|
+
promises.push(indexManager.deleteFieldIndex(transaction, fieldIndex));
|
|
16247
|
+
}))
|
|
16248
|
+
.next(() => PersistencePromise.waitFor(promises)));
|
|
16125
16249
|
}
|
|
16126
16250
|
|
|
16127
16251
|
/**
|
|
@@ -16201,9 +16325,56 @@ class QueryEngine {
|
|
|
16201
16325
|
* persisted index values. Returns `null` if an index is not available.
|
|
16202
16326
|
*/
|
|
16203
16327
|
performQueryUsingIndex(transaction, query) {
|
|
16204
|
-
{
|
|
16328
|
+
if (queryMatchesAllDocuments(query)) {
|
|
16329
|
+
// Queries that match all documents don't benefit from using
|
|
16330
|
+
// key-based lookups. It is more efficient to scan all documents in a
|
|
16331
|
+
// collection, rather than to perform individual lookups.
|
|
16205
16332
|
return PersistencePromise.resolve(null);
|
|
16206
16333
|
}
|
|
16334
|
+
let target = queryToTarget(query);
|
|
16335
|
+
return this.indexManager
|
|
16336
|
+
.getIndexType(transaction, target)
|
|
16337
|
+
.next(indexType => {
|
|
16338
|
+
if (indexType === 0 /* NONE */) {
|
|
16339
|
+
// The target cannot be served from any index.
|
|
16340
|
+
return null;
|
|
16341
|
+
}
|
|
16342
|
+
if (query.limit !== null && indexType === 1 /* PARTIAL */) {
|
|
16343
|
+
// We cannot apply a limit for targets that are served using a partial
|
|
16344
|
+
// index. If a partial index will be used to serve the target, the
|
|
16345
|
+
// query may return a superset of documents that match the target
|
|
16346
|
+
// (e.g. if the index doesn't include all the target's filters), or
|
|
16347
|
+
// may return the correct set of documents in the wrong order (e.g. if
|
|
16348
|
+
// the index doesn't include a segment for one of the orderBys).
|
|
16349
|
+
// Therefore, a limit should not be applied in such cases.
|
|
16350
|
+
query = queryWithLimit(query, null, "F" /* First */);
|
|
16351
|
+
target = queryToTarget(query);
|
|
16352
|
+
}
|
|
16353
|
+
return this.indexManager
|
|
16354
|
+
.getDocumentsMatchingTarget(transaction, target)
|
|
16355
|
+
.next(keys => {
|
|
16356
|
+
const sortedKeys = documentKeySet(...keys);
|
|
16357
|
+
return this.localDocumentsView
|
|
16358
|
+
.getDocuments(transaction, sortedKeys)
|
|
16359
|
+
.next(indexedDocuments => {
|
|
16360
|
+
return this.indexManager
|
|
16361
|
+
.getMinOffset(transaction, target)
|
|
16362
|
+
.next(offset => {
|
|
16363
|
+
const previousResults = this.applyQuery(query, indexedDocuments);
|
|
16364
|
+
if (this.needsRefill(query, previousResults, sortedKeys, offset.readTime)) {
|
|
16365
|
+
// A limit query whose boundaries change due to local
|
|
16366
|
+
// edits can be re-run against the cache by excluding the
|
|
16367
|
+
// limit. This ensures that all documents that match the
|
|
16368
|
+
// query's filters are included in the result set. The SDK
|
|
16369
|
+
// can then apply the limit once all local edits are
|
|
16370
|
+
// incorporated.
|
|
16371
|
+
return this.performQueryUsingIndex(transaction, queryWithLimit(query, null, "F" /* First */));
|
|
16372
|
+
}
|
|
16373
|
+
return this.appendRemainingResults(transaction, previousResults, query, offset);
|
|
16374
|
+
});
|
|
16375
|
+
});
|
|
16376
|
+
});
|
|
16377
|
+
});
|
|
16207
16378
|
}
|
|
16208
16379
|
/**
|
|
16209
16380
|
* Performs a query based on the target's persisted query mapping. Returns
|
|
@@ -24298,7 +24469,7 @@ class AsyncObserver {
|
|
|
24298
24469
|
this.scheduleEvent(this.observer.error, error);
|
|
24299
24470
|
}
|
|
24300
24471
|
else {
|
|
24301
|
-
|
|
24472
|
+
logError('Uncaught Error in snapshot listener:', error);
|
|
24302
24473
|
}
|
|
24303
24474
|
}
|
|
24304
24475
|
mute() {
|
|
@@ -26229,7 +26400,7 @@ function setPersistenceProviders(client, onlineComponentProvider, offlineCompone
|
|
|
26229
26400
|
if (!canFallbackFromIndexedDbError(error)) {
|
|
26230
26401
|
throw error;
|
|
26231
26402
|
}
|
|
26232
|
-
|
|
26403
|
+
logWarn('Error enabling offline persistence. Falling back to ' +
|
|
26233
26404
|
'persistence disabled: ' +
|
|
26234
26405
|
error);
|
|
26235
26406
|
persistenceResult.reject(error);
|
|
@@ -29143,14 +29314,23 @@ function writeBatch(firestore) {
|
|
|
29143
29314
|
* limitations under the License.
|
|
29144
29315
|
*/
|
|
29145
29316
|
function setIndexConfiguration(firestore, jsonOrConfiguration) {
|
|
29317
|
+
var _a;
|
|
29146
29318
|
firestore = cast(firestore, Firestore);
|
|
29147
|
-
ensureFirestoreConfigured(firestore);
|
|
29319
|
+
const client = ensureFirestoreConfigured(firestore);
|
|
29320
|
+
// PORTING NOTE: We don't return an error if the user has not enabled
|
|
29321
|
+
// persistence since `enableIndexeddbPersistence()` can fail on the Web.
|
|
29322
|
+
if (!((_a = client.offlineComponents) === null || _a === void 0 ? void 0 : _a.indexBackfillerScheduler)) {
|
|
29323
|
+
logWarn('Cannot enable indexes when persistence is disabled');
|
|
29324
|
+
return Promise.resolve();
|
|
29325
|
+
}
|
|
29326
|
+
const parsedIndexes = parseIndexes(jsonOrConfiguration);
|
|
29327
|
+
return getLocalStore(client).then(localStore => localStoreConfigureFieldIndexes(localStore, parsedIndexes));
|
|
29328
|
+
}
|
|
29329
|
+
function parseIndexes(jsonOrConfiguration) {
|
|
29148
29330
|
const indexConfiguration = typeof jsonOrConfiguration === 'string'
|
|
29149
29331
|
? tryParseJson(jsonOrConfiguration)
|
|
29150
29332
|
: jsonOrConfiguration;
|
|
29151
29333
|
const parsedIndexes = [];
|
|
29152
|
-
// PORTING NOTE: We don't return an error if the user has not enabled
|
|
29153
|
-
// persistence since `enableIndexeddbPersistence()` can fail on the Web.
|
|
29154
29334
|
if (Array.isArray(indexConfiguration.indexes)) {
|
|
29155
29335
|
for (const index of indexConfiguration.indexes) {
|
|
29156
29336
|
const collectionGroup = tryGetString(index, 'collectionGroup');
|
|
@@ -29173,8 +29353,7 @@ function setIndexConfiguration(firestore, jsonOrConfiguration) {
|
|
|
29173
29353
|
parsedIndexes.push(new FieldIndex(FieldIndex.UNKNOWN_ID, collectionGroup, segments, IndexState.empty()));
|
|
29174
29354
|
}
|
|
29175
29355
|
}
|
|
29176
|
-
|
|
29177
|
-
return Promise.resolve();
|
|
29356
|
+
return parsedIndexes;
|
|
29178
29357
|
}
|
|
29179
29358
|
function tryParseJson(json) {
|
|
29180
29359
|
var _a;
|
|
@@ -29182,7 +29361,7 @@ function tryParseJson(json) {
|
|
|
29182
29361
|
return JSON.parse(json);
|
|
29183
29362
|
}
|
|
29184
29363
|
catch (e) {
|
|
29185
|
-
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON:' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
|
|
29364
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON: ' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
|
|
29186
29365
|
}
|
|
29187
29366
|
}
|
|
29188
29367
|
function tryGetString(data, property) {
|
|
@@ -29239,7 +29418,6 @@ exports._cast = cast;
|
|
|
29239
29418
|
exports._debugAssert = debugAssert;
|
|
29240
29419
|
exports._isBase64Available = isBase64Available;
|
|
29241
29420
|
exports._logWarn = logWarn;
|
|
29242
|
-
exports._setIndexConfiguration = setIndexConfiguration;
|
|
29243
29421
|
exports._validateIsNotUsedTogether = validateIsNotUsedTogether;
|
|
29244
29422
|
exports.addDoc = addDoc;
|
|
29245
29423
|
exports.arrayRemove = arrayRemove;
|
|
@@ -29282,6 +29460,7 @@ exports.refEqual = refEqual;
|
|
|
29282
29460
|
exports.runTransaction = runTransaction;
|
|
29283
29461
|
exports.serverTimestamp = serverTimestamp;
|
|
29284
29462
|
exports.setDoc = setDoc;
|
|
29463
|
+
exports.setIndexConfiguration = setIndexConfiguration;
|
|
29285
29464
|
exports.setLogLevel = setLogLevel;
|
|
29286
29465
|
exports.snapshotEqual = snapshotEqual;
|
|
29287
29466
|
exports.startAfter = startAfter;
|