@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.
- package/CHANGELOG.md +8 -0
- package/dist/firestore/src/api/credentials.d.ts +13 -3
- package/dist/firestore/src/api/index_configuration.d.ts +7 -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 +1 -1
- package/dist/index.esm2017.js +3737 -3589
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3721 -3604
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +250 -53
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +250 -53
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3676 -3529
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +13 -13
- package/dist/lite/firestore/src/api/credentials.d.ts +13 -3
- package/dist/lite/firestore/src/api/index_configuration.d.ts +7 -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 +232 -222
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +485 -469
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +36 -18
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +36 -18
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +232 -222
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +3 -0
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +23 -23
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +13 -3
- package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +7 -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/lite/private.d.ts +3 -0
- package/dist/packages/firestore/dist/index.esm2017.d.ts +193 -193
- package/dist/packages/firestore/src/api/credentials.d.ts +13 -3
- package/dist/packages/firestore/src/api/index_configuration.d.ts +7 -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 +4 -1
- package/package.json +10 -9
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-canary.47895fe5b";
|
|
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.3-canary.47895fe5b";
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* @license
|
|
@@ -641,18 +641,40 @@ class FirebaseAuthCredentialsProvider {
|
|
|
641
641
|
* safer to keep the implementation as-is.
|
|
642
642
|
*/
|
|
643
643
|
class FirstPartyToken {
|
|
644
|
-
constructor(gapi, sessionIndex, iamToken) {
|
|
644
|
+
constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
|
|
645
|
+
this.gapi = gapi;
|
|
646
|
+
this.sessionIndex = sessionIndex;
|
|
647
|
+
this.iamToken = iamToken;
|
|
648
|
+
this.authTokenFactory = authTokenFactory;
|
|
645
649
|
this.type = 'FirstParty';
|
|
646
650
|
this.user = User.FIRST_PARTY;
|
|
647
|
-
this.
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
651
|
+
this._headers = new Map();
|
|
652
|
+
}
|
|
653
|
+
/** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
|
|
654
|
+
getAuthToken() {
|
|
655
|
+
if (this.authTokenFactory) {
|
|
656
|
+
return this.authTokenFactory();
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
// Make sure this really is a Gapi client.
|
|
660
|
+
hardAssert(!!(typeof this.gapi === 'object' &&
|
|
661
|
+
this.gapi !== null &&
|
|
662
|
+
this.gapi['auth'] &&
|
|
663
|
+
this.gapi['auth']['getAuthHeaderValueForFirstParty']));
|
|
664
|
+
return this.gapi['auth']['getAuthHeaderValueForFirstParty']([]);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
get headers() {
|
|
668
|
+
this._headers.set('X-Goog-AuthUser', this.sessionIndex);
|
|
669
|
+
// Use array notation to prevent minification
|
|
670
|
+
const authHeaderTokenValue = this.getAuthToken();
|
|
671
|
+
if (authHeaderTokenValue) {
|
|
672
|
+
this._headers.set('Authorization', authHeaderTokenValue);
|
|
652
673
|
}
|
|
653
|
-
if (iamToken) {
|
|
654
|
-
this.
|
|
674
|
+
if (this.iamToken) {
|
|
675
|
+
this._headers.set('X-Goog-Iam-Authorization-Token', this.iamToken);
|
|
655
676
|
}
|
|
677
|
+
return this._headers;
|
|
656
678
|
}
|
|
657
679
|
}
|
|
658
680
|
/*
|
|
@@ -661,13 +683,14 @@ class FirstPartyToken {
|
|
|
661
683
|
* to applications hosted by Google.
|
|
662
684
|
*/
|
|
663
685
|
class FirstPartyAuthCredentialsProvider {
|
|
664
|
-
constructor(gapi, sessionIndex, iamToken) {
|
|
686
|
+
constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
|
|
665
687
|
this.gapi = gapi;
|
|
666
688
|
this.sessionIndex = sessionIndex;
|
|
667
689
|
this.iamToken = iamToken;
|
|
690
|
+
this.authTokenFactory = authTokenFactory;
|
|
668
691
|
}
|
|
669
692
|
getToken() {
|
|
670
|
-
return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken));
|
|
693
|
+
return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken, this.authTokenFactory));
|
|
671
694
|
}
|
|
672
695
|
start(asyncQueue, changeListener) {
|
|
673
696
|
// Fire with initial uid.
|
|
@@ -778,12 +801,7 @@ function makeAuthCredentialsProvider(credentials) {
|
|
|
778
801
|
switch (credentials['type']) {
|
|
779
802
|
case 'gapi':
|
|
780
803
|
const client = credentials['client'];
|
|
781
|
-
|
|
782
|
-
hardAssert(!!(typeof client === 'object' &&
|
|
783
|
-
client !== null &&
|
|
784
|
-
client['auth'] &&
|
|
785
|
-
client['auth']['getAuthHeaderValueForFirstParty']));
|
|
786
|
-
return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null);
|
|
804
|
+
return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null, credentials['authTokenFactory'] || null);
|
|
787
805
|
case 'provider':
|
|
788
806
|
return credentials['client'];
|
|
789
807
|
default:
|
|
@@ -1523,6 +1541,23 @@ function fieldIndexGetKeyOrder(fieldIndex) {
|
|
|
1523
1541
|
? 0 /* ASCENDING */
|
|
1524
1542
|
: directionalSegments[directionalSegments.length - 1].kind;
|
|
1525
1543
|
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Compares indexes by collection group and segments. Ignores update time and
|
|
1546
|
+
* index ID.
|
|
1547
|
+
*/
|
|
1548
|
+
function fieldIndexSemanticComparator(left, right) {
|
|
1549
|
+
let cmp = primitiveComparator(left.collectionGroup, right.collectionGroup);
|
|
1550
|
+
if (cmp !== 0) {
|
|
1551
|
+
return cmp;
|
|
1552
|
+
}
|
|
1553
|
+
for (let i = 0; i < Math.min(left.fields.length, right.fields.length); ++i) {
|
|
1554
|
+
cmp = indexSegmentComparator(left.fields[i], right.fields[i]);
|
|
1555
|
+
if (cmp !== 0) {
|
|
1556
|
+
return cmp;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
return primitiveComparator(left.fields.length, right.fields.length);
|
|
1560
|
+
}
|
|
1526
1561
|
/** Returns a debug representation of the field index */
|
|
1527
1562
|
function fieldIndexToString(fieldIndex) {
|
|
1528
1563
|
return `id=${fieldIndex.indexId}|cg=${fieldIndex.collectionGroup}|f=${fieldIndex.fields.map(f => `${f.fieldPath}:${f.kind}`).join(',')}`;
|
|
@@ -1538,6 +1573,13 @@ class IndexSegment {
|
|
|
1538
1573
|
this.kind = kind;
|
|
1539
1574
|
}
|
|
1540
1575
|
}
|
|
1576
|
+
function indexSegmentComparator(left, right) {
|
|
1577
|
+
const cmp = FieldPath$1.comparator(left.fieldPath, right.fieldPath);
|
|
1578
|
+
if (cmp !== 0) {
|
|
1579
|
+
return cmp;
|
|
1580
|
+
}
|
|
1581
|
+
return primitiveComparator(left.kind, right.kind);
|
|
1582
|
+
}
|
|
1541
1583
|
/**
|
|
1542
1584
|
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
1543
1585
|
* current user.
|
|
@@ -1624,31 +1666,6 @@ function indexOffsetComparator(left, right) {
|
|
|
1624
1666
|
}
|
|
1625
1667
|
return primitiveComparator(left.largestBatchId, right.largestBatchId);
|
|
1626
1668
|
}
|
|
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
1669
|
|
|
1653
1670
|
/**
|
|
1654
1671
|
* @license
|
|
@@ -2608,6 +2625,8 @@ function checkForAndReportiOSError(error) {
|
|
|
2608
2625
|
}
|
|
2609
2626
|
|
|
2610
2627
|
const LOG_TAG$h = 'IndexBackiller';
|
|
2628
|
+
/** How long we wait to try running index backfill after SDK initialization. */
|
|
2629
|
+
const INITIAL_BACKFILL_DELAY_MS = 15;
|
|
2611
2630
|
/** Minimum amount of time between backfill checks, after the first one. */
|
|
2612
2631
|
const REGULAR_BACKFILL_DELAY_MS = 1;
|
|
2613
2632
|
/** The maximum number of documents to process each time backfill() is called. */
|
|
@@ -2620,6 +2639,7 @@ class IndexBackfillerScheduler {
|
|
|
2620
2639
|
this.task = null;
|
|
2621
2640
|
}
|
|
2622
2641
|
start() {
|
|
2642
|
+
this.schedule(INITIAL_BACKFILL_DELAY_MS);
|
|
2623
2643
|
}
|
|
2624
2644
|
stop() {
|
|
2625
2645
|
if (this.task) {
|
|
@@ -12735,6 +12755,48 @@ function dbKeyComparator(l, r) {
|
|
|
12735
12755
|
return primitiveComparator(left[left.length - 1], right[right.length - 1]);
|
|
12736
12756
|
}
|
|
12737
12757
|
|
|
12758
|
+
/**
|
|
12759
|
+
* @license
|
|
12760
|
+
* Copyright 2017 Google LLC
|
|
12761
|
+
*
|
|
12762
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12763
|
+
* you may not use this file except in compliance with the License.
|
|
12764
|
+
* You may obtain a copy of the License at
|
|
12765
|
+
*
|
|
12766
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12767
|
+
*
|
|
12768
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12769
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12770
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12771
|
+
* See the License for the specific language governing permissions and
|
|
12772
|
+
* limitations under the License.
|
|
12773
|
+
*/
|
|
12774
|
+
/**
|
|
12775
|
+
* Schema Version for the Web client:
|
|
12776
|
+
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
12777
|
+
* Document Cache
|
|
12778
|
+
* 2. Used to ensure a targetGlobal object exists and add targetCount to it. No
|
|
12779
|
+
* longer required because migration 3 unconditionally clears it.
|
|
12780
|
+
* 3. Dropped and re-created Query Cache to deal with cache corruption related
|
|
12781
|
+
* to limbo resolution. Addresses
|
|
12782
|
+
* https://github.com/firebase/firebase-ios-sdk/issues/1548
|
|
12783
|
+
* 4. Multi-Tab Support.
|
|
12784
|
+
* 5. Removal of held write acks.
|
|
12785
|
+
* 6. Create document global for tracking document cache size.
|
|
12786
|
+
* 7. Ensure every cached document has a sentinel row with a sequence number.
|
|
12787
|
+
* 8. Add collection-parent index for Collection Group queries.
|
|
12788
|
+
* 9. Change RemoteDocumentChanges store to be keyed by readTime rather than
|
|
12789
|
+
* an auto-incrementing ID. This is required for Index-Free queries.
|
|
12790
|
+
* 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
|
|
12791
|
+
* 11. Add bundles and named_queries for bundle support.
|
|
12792
|
+
* 12. Add document overlays.
|
|
12793
|
+
* 13. Rewrite the keys of the remote document cache to allow for efficient
|
|
12794
|
+
* document lookup via `getAll()`.
|
|
12795
|
+
* 14. Add overlays.
|
|
12796
|
+
* 15. Add indexing support.
|
|
12797
|
+
*/
|
|
12798
|
+
const SCHEMA_VERSION = 15;
|
|
12799
|
+
|
|
12738
12800
|
/**
|
|
12739
12801
|
* @license
|
|
12740
12802
|
* Copyright 2022 Google LLC
|
|
@@ -15273,6 +15335,73 @@ async function indexedDbClearPersistence(persistenceKey) {
|
|
|
15273
15335
|
await SimpleDb.delete(dbName);
|
|
15274
15336
|
}
|
|
15275
15337
|
|
|
15338
|
+
/**
|
|
15339
|
+
* @license
|
|
15340
|
+
* Copyright 2017 Google LLC
|
|
15341
|
+
*
|
|
15342
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15343
|
+
* you may not use this file except in compliance with the License.
|
|
15344
|
+
* You may obtain a copy of the License at
|
|
15345
|
+
*
|
|
15346
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15347
|
+
*
|
|
15348
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15349
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15350
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15351
|
+
* See the License for the specific language governing permissions and
|
|
15352
|
+
* limitations under the License.
|
|
15353
|
+
*/
|
|
15354
|
+
/**
|
|
15355
|
+
* Compares two array for equality using comparator. The method computes the
|
|
15356
|
+
* intersection and invokes `onAdd` for every element that is in `after` but not
|
|
15357
|
+
* `before`. `onRemove` is invoked for every element in `before` but missing
|
|
15358
|
+
* from `after`.
|
|
15359
|
+
*
|
|
15360
|
+
* The method creates a copy of both `before` and `after` and runs in O(n log
|
|
15361
|
+
* n), where n is the size of the two lists.
|
|
15362
|
+
*
|
|
15363
|
+
* @param before - The elements that exist in the original array.
|
|
15364
|
+
* @param after - The elements to diff against the original array.
|
|
15365
|
+
* @param comparator - The comparator for the elements in before and after.
|
|
15366
|
+
* @param onAdd - A function to invoke for every element that is part of `
|
|
15367
|
+
* after` but not `before`.
|
|
15368
|
+
* @param onRemove - A function to invoke for every element that is part of
|
|
15369
|
+
* `before` but not `after`.
|
|
15370
|
+
*/
|
|
15371
|
+
function diffArrays(before, after, comparator, onAdd, onRemove) {
|
|
15372
|
+
before = [...before];
|
|
15373
|
+
after = [...after];
|
|
15374
|
+
before.sort(comparator);
|
|
15375
|
+
after.sort(comparator);
|
|
15376
|
+
const bLen = before.length;
|
|
15377
|
+
const aLen = after.length;
|
|
15378
|
+
let a = 0;
|
|
15379
|
+
let b = 0;
|
|
15380
|
+
while (a < aLen && b < bLen) {
|
|
15381
|
+
const cmp = comparator(before[b], after[a]);
|
|
15382
|
+
if (cmp < 0) {
|
|
15383
|
+
// The element was removed if the next element in our ordered
|
|
15384
|
+
// walkthrough is only in `before`.
|
|
15385
|
+
onRemove(before[b++]);
|
|
15386
|
+
}
|
|
15387
|
+
else if (cmp > 0) {
|
|
15388
|
+
// The element was added if the next element in our ordered walkthrough
|
|
15389
|
+
// is only in `after`.
|
|
15390
|
+
onAdd(after[a++]);
|
|
15391
|
+
}
|
|
15392
|
+
else {
|
|
15393
|
+
a++;
|
|
15394
|
+
b++;
|
|
15395
|
+
}
|
|
15396
|
+
}
|
|
15397
|
+
while (a < aLen) {
|
|
15398
|
+
onAdd(after[a++]);
|
|
15399
|
+
}
|
|
15400
|
+
while (b < bLen) {
|
|
15401
|
+
onRemove(before[b++]);
|
|
15402
|
+
}
|
|
15403
|
+
}
|
|
15404
|
+
|
|
15276
15405
|
/**
|
|
15277
15406
|
* @license
|
|
15278
15407
|
* Copyright 2020 Google LLC
|
|
@@ -16122,6 +16251,19 @@ async function localStoreSaveNamedQuery(localStore, query, documents = documentK
|
|
|
16122
16251
|
.next(() => localStoreImpl.targetCache.addMatchingKeys(transaction, documents, allocated.targetId))
|
|
16123
16252
|
.next(() => localStoreImpl.bundleCache.saveNamedQuery(transaction, query));
|
|
16124
16253
|
});
|
|
16254
|
+
}
|
|
16255
|
+
async function localStoreConfigureFieldIndexes(localStore, newFieldIndexes) {
|
|
16256
|
+
const localStoreImpl = debugCast(localStore);
|
|
16257
|
+
const indexManager = localStoreImpl.indexManager;
|
|
16258
|
+
const promises = [];
|
|
16259
|
+
return localStoreImpl.persistence.runTransaction('Configure indexes', 'readwrite', transaction => indexManager
|
|
16260
|
+
.getFieldIndexes(transaction)
|
|
16261
|
+
.next(oldFieldIndexes => diffArrays(oldFieldIndexes, newFieldIndexes, fieldIndexSemanticComparator, fieldIndex => {
|
|
16262
|
+
promises.push(indexManager.addFieldIndex(transaction, fieldIndex));
|
|
16263
|
+
}, fieldIndex => {
|
|
16264
|
+
promises.push(indexManager.deleteFieldIndex(transaction, fieldIndex));
|
|
16265
|
+
}))
|
|
16266
|
+
.next(() => PersistencePromise.waitFor(promises)));
|
|
16125
16267
|
}
|
|
16126
16268
|
|
|
16127
16269
|
/**
|
|
@@ -16201,9 +16343,56 @@ class QueryEngine {
|
|
|
16201
16343
|
* persisted index values. Returns `null` if an index is not available.
|
|
16202
16344
|
*/
|
|
16203
16345
|
performQueryUsingIndex(transaction, query) {
|
|
16204
|
-
{
|
|
16346
|
+
if (queryMatchesAllDocuments(query)) {
|
|
16347
|
+
// Queries that match all documents don't benefit from using
|
|
16348
|
+
// key-based lookups. It is more efficient to scan all documents in a
|
|
16349
|
+
// collection, rather than to perform individual lookups.
|
|
16205
16350
|
return PersistencePromise.resolve(null);
|
|
16206
16351
|
}
|
|
16352
|
+
let target = queryToTarget(query);
|
|
16353
|
+
return this.indexManager
|
|
16354
|
+
.getIndexType(transaction, target)
|
|
16355
|
+
.next(indexType => {
|
|
16356
|
+
if (indexType === 0 /* NONE */) {
|
|
16357
|
+
// The target cannot be served from any index.
|
|
16358
|
+
return null;
|
|
16359
|
+
}
|
|
16360
|
+
if (query.limit !== null && indexType === 1 /* PARTIAL */) {
|
|
16361
|
+
// We cannot apply a limit for targets that are served using a partial
|
|
16362
|
+
// index. If a partial index will be used to serve the target, the
|
|
16363
|
+
// query may return a superset of documents that match the target
|
|
16364
|
+
// (e.g. if the index doesn't include all the target's filters), or
|
|
16365
|
+
// may return the correct set of documents in the wrong order (e.g. if
|
|
16366
|
+
// the index doesn't include a segment for one of the orderBys).
|
|
16367
|
+
// Therefore, a limit should not be applied in such cases.
|
|
16368
|
+
query = queryWithLimit(query, null, "F" /* First */);
|
|
16369
|
+
target = queryToTarget(query);
|
|
16370
|
+
}
|
|
16371
|
+
return this.indexManager
|
|
16372
|
+
.getDocumentsMatchingTarget(transaction, target)
|
|
16373
|
+
.next(keys => {
|
|
16374
|
+
const sortedKeys = documentKeySet(...keys);
|
|
16375
|
+
return this.localDocumentsView
|
|
16376
|
+
.getDocuments(transaction, sortedKeys)
|
|
16377
|
+
.next(indexedDocuments => {
|
|
16378
|
+
return this.indexManager
|
|
16379
|
+
.getMinOffset(transaction, target)
|
|
16380
|
+
.next(offset => {
|
|
16381
|
+
const previousResults = this.applyQuery(query, indexedDocuments);
|
|
16382
|
+
if (this.needsRefill(query, previousResults, sortedKeys, offset.readTime)) {
|
|
16383
|
+
// A limit query whose boundaries change due to local
|
|
16384
|
+
// edits can be re-run against the cache by excluding the
|
|
16385
|
+
// limit. This ensures that all documents that match the
|
|
16386
|
+
// query's filters are included in the result set. The SDK
|
|
16387
|
+
// can then apply the limit once all local edits are
|
|
16388
|
+
// incorporated.
|
|
16389
|
+
return this.performQueryUsingIndex(transaction, queryWithLimit(query, null, "F" /* First */));
|
|
16390
|
+
}
|
|
16391
|
+
return this.appendRemainingResults(transaction, previousResults, query, offset);
|
|
16392
|
+
});
|
|
16393
|
+
});
|
|
16394
|
+
});
|
|
16395
|
+
});
|
|
16207
16396
|
}
|
|
16208
16397
|
/**
|
|
16209
16398
|
* Performs a query based on the target's persisted query mapping. Returns
|
|
@@ -24298,7 +24487,7 @@ class AsyncObserver {
|
|
|
24298
24487
|
this.scheduleEvent(this.observer.error, error);
|
|
24299
24488
|
}
|
|
24300
24489
|
else {
|
|
24301
|
-
|
|
24490
|
+
logError('Uncaught Error in snapshot listener:', error);
|
|
24302
24491
|
}
|
|
24303
24492
|
}
|
|
24304
24493
|
mute() {
|
|
@@ -26229,7 +26418,7 @@ function setPersistenceProviders(client, onlineComponentProvider, offlineCompone
|
|
|
26229
26418
|
if (!canFallbackFromIndexedDbError(error)) {
|
|
26230
26419
|
throw error;
|
|
26231
26420
|
}
|
|
26232
|
-
|
|
26421
|
+
logWarn('Error enabling offline persistence. Falling back to ' +
|
|
26233
26422
|
'persistence disabled: ' +
|
|
26234
26423
|
error);
|
|
26235
26424
|
persistenceResult.reject(error);
|
|
@@ -29143,14 +29332,23 @@ function writeBatch(firestore) {
|
|
|
29143
29332
|
* limitations under the License.
|
|
29144
29333
|
*/
|
|
29145
29334
|
function setIndexConfiguration(firestore, jsonOrConfiguration) {
|
|
29335
|
+
var _a;
|
|
29146
29336
|
firestore = cast(firestore, Firestore);
|
|
29147
|
-
ensureFirestoreConfigured(firestore);
|
|
29337
|
+
const client = ensureFirestoreConfigured(firestore);
|
|
29338
|
+
// PORTING NOTE: We don't return an error if the user has not enabled
|
|
29339
|
+
// persistence since `enableIndexeddbPersistence()` can fail on the Web.
|
|
29340
|
+
if (!((_a = client.offlineComponents) === null || _a === void 0 ? void 0 : _a.indexBackfillerScheduler)) {
|
|
29341
|
+
logWarn('Cannot enable indexes when persistence is disabled');
|
|
29342
|
+
return Promise.resolve();
|
|
29343
|
+
}
|
|
29344
|
+
const parsedIndexes = parseIndexes(jsonOrConfiguration);
|
|
29345
|
+
return getLocalStore(client).then(localStore => localStoreConfigureFieldIndexes(localStore, parsedIndexes));
|
|
29346
|
+
}
|
|
29347
|
+
function parseIndexes(jsonOrConfiguration) {
|
|
29148
29348
|
const indexConfiguration = typeof jsonOrConfiguration === 'string'
|
|
29149
29349
|
? tryParseJson(jsonOrConfiguration)
|
|
29150
29350
|
: jsonOrConfiguration;
|
|
29151
29351
|
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
29352
|
if (Array.isArray(indexConfiguration.indexes)) {
|
|
29155
29353
|
for (const index of indexConfiguration.indexes) {
|
|
29156
29354
|
const collectionGroup = tryGetString(index, 'collectionGroup');
|
|
@@ -29173,8 +29371,7 @@ function setIndexConfiguration(firestore, jsonOrConfiguration) {
|
|
|
29173
29371
|
parsedIndexes.push(new FieldIndex(FieldIndex.UNKNOWN_ID, collectionGroup, segments, IndexState.empty()));
|
|
29174
29372
|
}
|
|
29175
29373
|
}
|
|
29176
|
-
|
|
29177
|
-
return Promise.resolve();
|
|
29374
|
+
return parsedIndexes;
|
|
29178
29375
|
}
|
|
29179
29376
|
function tryParseJson(json) {
|
|
29180
29377
|
var _a;
|
|
@@ -29182,7 +29379,7 @@ function tryParseJson(json) {
|
|
|
29182
29379
|
return JSON.parse(json);
|
|
29183
29380
|
}
|
|
29184
29381
|
catch (e) {
|
|
29185
|
-
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON:' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
|
|
29382
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON: ' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
|
|
29186
29383
|
}
|
|
29187
29384
|
}
|
|
29188
29385
|
function tryGetString(data, property) {
|
|
@@ -29239,7 +29436,6 @@ exports._cast = cast;
|
|
|
29239
29436
|
exports._debugAssert = debugAssert;
|
|
29240
29437
|
exports._isBase64Available = isBase64Available;
|
|
29241
29438
|
exports._logWarn = logWarn;
|
|
29242
|
-
exports._setIndexConfiguration = setIndexConfiguration;
|
|
29243
29439
|
exports._validateIsNotUsedTogether = validateIsNotUsedTogether;
|
|
29244
29440
|
exports.addDoc = addDoc;
|
|
29245
29441
|
exports.arrayRemove = arrayRemove;
|
|
@@ -29282,6 +29478,7 @@ exports.refEqual = refEqual;
|
|
|
29282
29478
|
exports.runTransaction = runTransaction;
|
|
29283
29479
|
exports.serverTimestamp = serverTimestamp;
|
|
29284
29480
|
exports.setDoc = setDoc;
|
|
29481
|
+
exports.setIndexConfiguration = setIndexConfiguration;
|
|
29285
29482
|
exports.setLogLevel = setLogLevel;
|
|
29286
29483
|
exports.snapshotEqual = snapshotEqual;
|
|
29287
29484
|
exports.startAfter = startAfter;
|