@firebase/firestore 3.4.13 → 3.4.14-canary.04dcdbb0f
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/database.d.ts +34 -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/core/database_info.d.ts +4 -0
- package/dist/firestore/src/lite-api/database.d.ts +51 -7
- 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/integration/api/provider.test.d.ts +17 -0
- package/dist/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/firestore/test/integration/util/helpers.d.ts +1 -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 +15 -4
- package/dist/index.esm2017.js +3793 -3646
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3762 -3648
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +295 -93
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +295 -93
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3732 -3586
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +53 -19
- package/dist/lite/firestore/src/api/credentials.d.ts +13 -3
- package/dist/lite/firestore/src/api/database.d.ts +34 -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/core/database_info.d.ts +4 -0
- package/dist/lite/firestore/src/lite-api/database.d.ts +51 -7
- 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/integration/api/provider.test.d.ts +17 -0
- package/dist/lite/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/lite/firestore/test/integration/util/helpers.d.ts +1 -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 +273 -277
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +506 -493
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.d.ts +15 -4
- package/dist/lite/index.node.cjs.js +71 -61
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +71 -61
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +273 -277
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +58 -7
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +29 -66
- package/dist/lite/packages/firestore/src/api/credentials.d.ts +13 -3
- package/dist/lite/packages/firestore/src/api/database.d.ts +34 -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/core/database_info.d.ts +4 -0
- package/dist/lite/packages/firestore/src/lite-api/database.d.ts +51 -7
- 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/integration/api/provider.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/lite/packages/firestore/test/integration/util/helpers.d.ts +1 -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 +25 -7
- package/dist/packages/firestore/dist/index.esm2017.d.ts +208 -203
- package/dist/packages/firestore/src/api/credentials.d.ts +13 -3
- package/dist/packages/firestore/src/api/database.d.ts +34 -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/core/database_info.d.ts +4 -0
- package/dist/packages/firestore/src/lite-api/database.d.ts +51 -7
- 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/integration/api/provider.test.d.ts +17 -0
- package/dist/packages/firestore/test/integration/util/firebase_export.d.ts +2 -1
- package/dist/packages/firestore/test/integration/util/helpers.d.ts +1 -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 +25 -8
- package/package.json +11 -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.04dcdbb0f";
|
|
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.04dcdbb0f";
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* @license
|
|
@@ -641,19 +641,41 @@ 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();
|
|
652
657
|
}
|
|
653
|
-
|
|
654
|
-
this.
|
|
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']([]);
|
|
655
665
|
}
|
|
656
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);
|
|
673
|
+
}
|
|
674
|
+
if (this.iamToken) {
|
|
675
|
+
this._headers.set('X-Goog-Iam-Authorization-Token', this.iamToken);
|
|
676
|
+
}
|
|
677
|
+
return this._headers;
|
|
678
|
+
}
|
|
657
679
|
}
|
|
658
680
|
/*
|
|
659
681
|
* Provides user credentials required for the Firestore JavaScript SDK
|
|
@@ -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) {
|
|
@@ -4348,6 +4368,12 @@ class DatabaseId {
|
|
|
4348
4368
|
other.projectId === this.projectId &&
|
|
4349
4369
|
other.database === this.database);
|
|
4350
4370
|
}
|
|
4371
|
+
}
|
|
4372
|
+
function databaseIdFromApp(app, database) {
|
|
4373
|
+
if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
|
|
4374
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
4375
|
+
}
|
|
4376
|
+
return new DatabaseId(app.options.projectId, database);
|
|
4351
4377
|
}
|
|
4352
4378
|
|
|
4353
4379
|
/**
|
|
@@ -12735,6 +12761,48 @@ function dbKeyComparator(l, r) {
|
|
|
12735
12761
|
return primitiveComparator(left[left.length - 1], right[right.length - 1]);
|
|
12736
12762
|
}
|
|
12737
12763
|
|
|
12764
|
+
/**
|
|
12765
|
+
* @license
|
|
12766
|
+
* Copyright 2017 Google LLC
|
|
12767
|
+
*
|
|
12768
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12769
|
+
* you may not use this file except in compliance with the License.
|
|
12770
|
+
* You may obtain a copy of the License at
|
|
12771
|
+
*
|
|
12772
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12773
|
+
*
|
|
12774
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12775
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12776
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12777
|
+
* See the License for the specific language governing permissions and
|
|
12778
|
+
* limitations under the License.
|
|
12779
|
+
*/
|
|
12780
|
+
/**
|
|
12781
|
+
* Schema Version for the Web client:
|
|
12782
|
+
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
12783
|
+
* Document Cache
|
|
12784
|
+
* 2. Used to ensure a targetGlobal object exists and add targetCount to it. No
|
|
12785
|
+
* longer required because migration 3 unconditionally clears it.
|
|
12786
|
+
* 3. Dropped and re-created Query Cache to deal with cache corruption related
|
|
12787
|
+
* to limbo resolution. Addresses
|
|
12788
|
+
* https://github.com/firebase/firebase-ios-sdk/issues/1548
|
|
12789
|
+
* 4. Multi-Tab Support.
|
|
12790
|
+
* 5. Removal of held write acks.
|
|
12791
|
+
* 6. Create document global for tracking document cache size.
|
|
12792
|
+
* 7. Ensure every cached document has a sentinel row with a sequence number.
|
|
12793
|
+
* 8. Add collection-parent index for Collection Group queries.
|
|
12794
|
+
* 9. Change RemoteDocumentChanges store to be keyed by readTime rather than
|
|
12795
|
+
* an auto-incrementing ID. This is required for Index-Free queries.
|
|
12796
|
+
* 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
|
|
12797
|
+
* 11. Add bundles and named_queries for bundle support.
|
|
12798
|
+
* 12. Add document overlays.
|
|
12799
|
+
* 13. Rewrite the keys of the remote document cache to allow for efficient
|
|
12800
|
+
* document lookup via `getAll()`.
|
|
12801
|
+
* 14. Add overlays.
|
|
12802
|
+
* 15. Add indexing support.
|
|
12803
|
+
*/
|
|
12804
|
+
const SCHEMA_VERSION = 15;
|
|
12805
|
+
|
|
12738
12806
|
/**
|
|
12739
12807
|
* @license
|
|
12740
12808
|
* Copyright 2022 Google LLC
|
|
@@ -15273,6 +15341,73 @@ async function indexedDbClearPersistence(persistenceKey) {
|
|
|
15273
15341
|
await SimpleDb.delete(dbName);
|
|
15274
15342
|
}
|
|
15275
15343
|
|
|
15344
|
+
/**
|
|
15345
|
+
* @license
|
|
15346
|
+
* Copyright 2017 Google LLC
|
|
15347
|
+
*
|
|
15348
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15349
|
+
* you may not use this file except in compliance with the License.
|
|
15350
|
+
* You may obtain a copy of the License at
|
|
15351
|
+
*
|
|
15352
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15353
|
+
*
|
|
15354
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15355
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15356
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15357
|
+
* See the License for the specific language governing permissions and
|
|
15358
|
+
* limitations under the License.
|
|
15359
|
+
*/
|
|
15360
|
+
/**
|
|
15361
|
+
* Compares two array for equality using comparator. The method computes the
|
|
15362
|
+
* intersection and invokes `onAdd` for every element that is in `after` but not
|
|
15363
|
+
* `before`. `onRemove` is invoked for every element in `before` but missing
|
|
15364
|
+
* from `after`.
|
|
15365
|
+
*
|
|
15366
|
+
* The method creates a copy of both `before` and `after` and runs in O(n log
|
|
15367
|
+
* n), where n is the size of the two lists.
|
|
15368
|
+
*
|
|
15369
|
+
* @param before - The elements that exist in the original array.
|
|
15370
|
+
* @param after - The elements to diff against the original array.
|
|
15371
|
+
* @param comparator - The comparator for the elements in before and after.
|
|
15372
|
+
* @param onAdd - A function to invoke for every element that is part of `
|
|
15373
|
+
* after` but not `before`.
|
|
15374
|
+
* @param onRemove - A function to invoke for every element that is part of
|
|
15375
|
+
* `before` but not `after`.
|
|
15376
|
+
*/
|
|
15377
|
+
function diffArrays(before, after, comparator, onAdd, onRemove) {
|
|
15378
|
+
before = [...before];
|
|
15379
|
+
after = [...after];
|
|
15380
|
+
before.sort(comparator);
|
|
15381
|
+
after.sort(comparator);
|
|
15382
|
+
const bLen = before.length;
|
|
15383
|
+
const aLen = after.length;
|
|
15384
|
+
let a = 0;
|
|
15385
|
+
let b = 0;
|
|
15386
|
+
while (a < aLen && b < bLen) {
|
|
15387
|
+
const cmp = comparator(before[b], after[a]);
|
|
15388
|
+
if (cmp < 0) {
|
|
15389
|
+
// The element was removed if the next element in our ordered
|
|
15390
|
+
// walkthrough is only in `before`.
|
|
15391
|
+
onRemove(before[b++]);
|
|
15392
|
+
}
|
|
15393
|
+
else if (cmp > 0) {
|
|
15394
|
+
// The element was added if the next element in our ordered walkthrough
|
|
15395
|
+
// is only in `after`.
|
|
15396
|
+
onAdd(after[a++]);
|
|
15397
|
+
}
|
|
15398
|
+
else {
|
|
15399
|
+
a++;
|
|
15400
|
+
b++;
|
|
15401
|
+
}
|
|
15402
|
+
}
|
|
15403
|
+
while (a < aLen) {
|
|
15404
|
+
onAdd(after[a++]);
|
|
15405
|
+
}
|
|
15406
|
+
while (b < bLen) {
|
|
15407
|
+
onRemove(before[b++]);
|
|
15408
|
+
}
|
|
15409
|
+
}
|
|
15410
|
+
|
|
15276
15411
|
/**
|
|
15277
15412
|
* @license
|
|
15278
15413
|
* Copyright 2020 Google LLC
|
|
@@ -16122,6 +16257,19 @@ async function localStoreSaveNamedQuery(localStore, query, documents = documentK
|
|
|
16122
16257
|
.next(() => localStoreImpl.targetCache.addMatchingKeys(transaction, documents, allocated.targetId))
|
|
16123
16258
|
.next(() => localStoreImpl.bundleCache.saveNamedQuery(transaction, query));
|
|
16124
16259
|
});
|
|
16260
|
+
}
|
|
16261
|
+
async function localStoreConfigureFieldIndexes(localStore, newFieldIndexes) {
|
|
16262
|
+
const localStoreImpl = debugCast(localStore);
|
|
16263
|
+
const indexManager = localStoreImpl.indexManager;
|
|
16264
|
+
const promises = [];
|
|
16265
|
+
return localStoreImpl.persistence.runTransaction('Configure indexes', 'readwrite', transaction => indexManager
|
|
16266
|
+
.getFieldIndexes(transaction)
|
|
16267
|
+
.next(oldFieldIndexes => diffArrays(oldFieldIndexes, newFieldIndexes, fieldIndexSemanticComparator, fieldIndex => {
|
|
16268
|
+
promises.push(indexManager.addFieldIndex(transaction, fieldIndex));
|
|
16269
|
+
}, fieldIndex => {
|
|
16270
|
+
promises.push(indexManager.deleteFieldIndex(transaction, fieldIndex));
|
|
16271
|
+
}))
|
|
16272
|
+
.next(() => PersistencePromise.waitFor(promises)));
|
|
16125
16273
|
}
|
|
16126
16274
|
|
|
16127
16275
|
/**
|
|
@@ -16201,9 +16349,56 @@ class QueryEngine {
|
|
|
16201
16349
|
* persisted index values. Returns `null` if an index is not available.
|
|
16202
16350
|
*/
|
|
16203
16351
|
performQueryUsingIndex(transaction, query) {
|
|
16204
|
-
{
|
|
16352
|
+
if (queryMatchesAllDocuments(query)) {
|
|
16353
|
+
// Queries that match all documents don't benefit from using
|
|
16354
|
+
// key-based lookups. It is more efficient to scan all documents in a
|
|
16355
|
+
// collection, rather than to perform individual lookups.
|
|
16205
16356
|
return PersistencePromise.resolve(null);
|
|
16206
16357
|
}
|
|
16358
|
+
let target = queryToTarget(query);
|
|
16359
|
+
return this.indexManager
|
|
16360
|
+
.getIndexType(transaction, target)
|
|
16361
|
+
.next(indexType => {
|
|
16362
|
+
if (indexType === 0 /* NONE */) {
|
|
16363
|
+
// The target cannot be served from any index.
|
|
16364
|
+
return null;
|
|
16365
|
+
}
|
|
16366
|
+
if (query.limit !== null && indexType === 1 /* PARTIAL */) {
|
|
16367
|
+
// We cannot apply a limit for targets that are served using a partial
|
|
16368
|
+
// index. If a partial index will be used to serve the target, the
|
|
16369
|
+
// query may return a superset of documents that match the target
|
|
16370
|
+
// (e.g. if the index doesn't include all the target's filters), or
|
|
16371
|
+
// may return the correct set of documents in the wrong order (e.g. if
|
|
16372
|
+
// the index doesn't include a segment for one of the orderBys).
|
|
16373
|
+
// Therefore, a limit should not be applied in such cases.
|
|
16374
|
+
query = queryWithLimit(query, null, "F" /* First */);
|
|
16375
|
+
target = queryToTarget(query);
|
|
16376
|
+
}
|
|
16377
|
+
return this.indexManager
|
|
16378
|
+
.getDocumentsMatchingTarget(transaction, target)
|
|
16379
|
+
.next(keys => {
|
|
16380
|
+
const sortedKeys = documentKeySet(...keys);
|
|
16381
|
+
return this.localDocumentsView
|
|
16382
|
+
.getDocuments(transaction, sortedKeys)
|
|
16383
|
+
.next(indexedDocuments => {
|
|
16384
|
+
return this.indexManager
|
|
16385
|
+
.getMinOffset(transaction, target)
|
|
16386
|
+
.next(offset => {
|
|
16387
|
+
const previousResults = this.applyQuery(query, indexedDocuments);
|
|
16388
|
+
if (this.needsRefill(query, previousResults, sortedKeys, offset.readTime)) {
|
|
16389
|
+
// A limit query whose boundaries change due to local
|
|
16390
|
+
// edits can be re-run against the cache by excluding the
|
|
16391
|
+
// limit. This ensures that all documents that match the
|
|
16392
|
+
// query's filters are included in the result set. The SDK
|
|
16393
|
+
// can then apply the limit once all local edits are
|
|
16394
|
+
// incorporated.
|
|
16395
|
+
return this.performQueryUsingIndex(transaction, queryWithLimit(query, null, "F" /* First */));
|
|
16396
|
+
}
|
|
16397
|
+
return this.appendRemainingResults(transaction, previousResults, query, offset);
|
|
16398
|
+
});
|
|
16399
|
+
});
|
|
16400
|
+
});
|
|
16401
|
+
});
|
|
16207
16402
|
}
|
|
16208
16403
|
/**
|
|
16209
16404
|
* Performs a query based on the target's persisted query mapping. Returns
|
|
@@ -24298,7 +24493,7 @@ class AsyncObserver {
|
|
|
24298
24493
|
this.scheduleEvent(this.observer.error, error);
|
|
24299
24494
|
}
|
|
24300
24495
|
else {
|
|
24301
|
-
|
|
24496
|
+
logError('Uncaught Error in snapshot listener:', error);
|
|
24302
24497
|
}
|
|
24303
24498
|
}
|
|
24304
24499
|
mute() {
|
|
@@ -24594,7 +24789,7 @@ class Transaction$2 {
|
|
|
24594
24789
|
docVersion = doc.version;
|
|
24595
24790
|
}
|
|
24596
24791
|
else if (doc.isNoDocument()) {
|
|
24597
|
-
//
|
|
24792
|
+
// Represent a deleted doc using SnapshotVersion.min().
|
|
24598
24793
|
docVersion = SnapshotVersion.min();
|
|
24599
24794
|
}
|
|
24600
24795
|
else {
|
|
@@ -24618,7 +24813,12 @@ class Transaction$2 {
|
|
|
24618
24813
|
precondition(key) {
|
|
24619
24814
|
const version = this.readVersions.get(key.toString());
|
|
24620
24815
|
if (!this.writtenDocs.has(key.toString()) && version) {
|
|
24621
|
-
|
|
24816
|
+
if (version.isEqual(SnapshotVersion.min())) {
|
|
24817
|
+
return Precondition.exists(false);
|
|
24818
|
+
}
|
|
24819
|
+
else {
|
|
24820
|
+
return Precondition.updateTime(version);
|
|
24821
|
+
}
|
|
24622
24822
|
}
|
|
24623
24823
|
else {
|
|
24624
24824
|
return Precondition.none();
|
|
@@ -25313,9 +25513,11 @@ class FirestoreSettingsImpl {
|
|
|
25313
25513
|
*/
|
|
25314
25514
|
class Firestore$1 {
|
|
25315
25515
|
/** @hideconstructor */
|
|
25316
|
-
constructor(
|
|
25516
|
+
constructor(_authCredentials, _appCheckCredentials, _databaseId, _app) {
|
|
25317
25517
|
this._authCredentials = _authCredentials;
|
|
25318
25518
|
this._appCheckCredentials = _appCheckCredentials;
|
|
25519
|
+
this._databaseId = _databaseId;
|
|
25520
|
+
this._app = _app;
|
|
25319
25521
|
/**
|
|
25320
25522
|
* Whether it's a Firestore or Firestore Lite instance.
|
|
25321
25523
|
*/
|
|
@@ -25323,13 +25525,6 @@ class Firestore$1 {
|
|
|
25323
25525
|
this._persistenceKey = '(lite)';
|
|
25324
25526
|
this._settings = new FirestoreSettingsImpl({});
|
|
25325
25527
|
this._settingsFrozen = false;
|
|
25326
|
-
if (databaseIdOrApp instanceof DatabaseId) {
|
|
25327
|
-
this._databaseId = databaseIdOrApp;
|
|
25328
|
-
}
|
|
25329
|
-
else {
|
|
25330
|
-
this._app = databaseIdOrApp;
|
|
25331
|
-
this._databaseId = databaseIdFromApp(databaseIdOrApp);
|
|
25332
|
-
}
|
|
25333
25528
|
}
|
|
25334
25529
|
/**
|
|
25335
25530
|
* The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
|
@@ -25392,12 +25587,6 @@ class Firestore$1 {
|
|
|
25392
25587
|
return Promise.resolve();
|
|
25393
25588
|
}
|
|
25394
25589
|
}
|
|
25395
|
-
function databaseIdFromApp(app) {
|
|
25396
|
-
if (!Object.prototype.hasOwnProperty.apply(app.options, ['projectId'])) {
|
|
25397
|
-
throw new FirestoreError(Code.INVALID_ARGUMENT, '"projectId" not provided in firebase.initializeApp.');
|
|
25398
|
-
}
|
|
25399
|
-
return new DatabaseId(app.options.projectId);
|
|
25400
|
-
}
|
|
25401
25590
|
/**
|
|
25402
25591
|
* Modify this instance to communicate with the Cloud Firestore emulator.
|
|
25403
25592
|
*
|
|
@@ -26066,15 +26255,14 @@ const CACHE_SIZE_UNLIMITED = LRU_COLLECTION_DISABLED;
|
|
|
26066
26255
|
*/
|
|
26067
26256
|
class Firestore extends Firestore$1 {
|
|
26068
26257
|
/** @hideconstructor */
|
|
26069
|
-
constructor(
|
|
26070
|
-
super(
|
|
26258
|
+
constructor(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app) {
|
|
26259
|
+
super(authCredentialsProvider, appCheckCredentialsProvider, databaseId, app);
|
|
26071
26260
|
/**
|
|
26072
26261
|
* Whether it's a {@link Firestore} or Firestore Lite instance.
|
|
26073
26262
|
*/
|
|
26074
26263
|
this.type = 'firestore';
|
|
26075
26264
|
this._queue = newAsyncQueue();
|
|
26076
|
-
this._persistenceKey =
|
|
26077
|
-
'name' in databaseIdOrApp ? databaseIdOrApp.name : '[DEFAULT]';
|
|
26265
|
+
this._persistenceKey = (app === null || app === void 0 ? void 0 : app.name) || '[DEFAULT]';
|
|
26078
26266
|
}
|
|
26079
26267
|
_terminate() {
|
|
26080
26268
|
if (!this._firestoreClient) {
|
|
@@ -26094,13 +26282,19 @@ class Firestore extends Firestore$1 {
|
|
|
26094
26282
|
* @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
|
|
26095
26283
|
* be associated.
|
|
26096
26284
|
* @param settings - A settings object to configure the {@link Firestore} instance.
|
|
26285
|
+
* @param databaseId - The name of database.
|
|
26097
26286
|
* @returns A newly initialized {@link Firestore} instance.
|
|
26098
26287
|
*/
|
|
26099
|
-
function initializeFirestore(app$1, settings) {
|
|
26288
|
+
function initializeFirestore(app$1, settings, databaseId) {
|
|
26289
|
+
if (!databaseId) {
|
|
26290
|
+
databaseId = DEFAULT_DATABASE_NAME;
|
|
26291
|
+
}
|
|
26100
26292
|
const provider = app._getProvider(app$1, 'firestore');
|
|
26101
|
-
if (provider.isInitialized()) {
|
|
26102
|
-
const existingInstance = provider.getImmediate(
|
|
26103
|
-
|
|
26293
|
+
if (provider.isInitialized(databaseId)) {
|
|
26294
|
+
const existingInstance = provider.getImmediate({
|
|
26295
|
+
identifier: databaseId
|
|
26296
|
+
});
|
|
26297
|
+
const initialSettings = provider.getOptions(databaseId);
|
|
26104
26298
|
if (util$1.deepEqual(initialSettings, settings)) {
|
|
26105
26299
|
return existingInstance;
|
|
26106
26300
|
}
|
|
@@ -26116,19 +26310,19 @@ function initializeFirestore(app$1, settings) {
|
|
|
26116
26310
|
settings.cacheSizeBytes < LRU_MINIMUM_CACHE_SIZE_BYTES) {
|
|
26117
26311
|
throw new FirestoreError(Code.INVALID_ARGUMENT, `cacheSizeBytes must be at least ${LRU_MINIMUM_CACHE_SIZE_BYTES}`);
|
|
26118
26312
|
}
|
|
26119
|
-
return provider.initialize({
|
|
26313
|
+
return provider.initialize({
|
|
26314
|
+
options: settings,
|
|
26315
|
+
instanceIdentifier: databaseId
|
|
26316
|
+
});
|
|
26120
26317
|
}
|
|
26121
|
-
|
|
26122
|
-
|
|
26123
|
-
|
|
26124
|
-
|
|
26125
|
-
|
|
26126
|
-
|
|
26127
|
-
|
|
26128
|
-
|
|
26129
|
-
*/
|
|
26130
|
-
function getFirestore(app$1 = app.getApp()) {
|
|
26131
|
-
return app._getProvider(app$1, 'firestore').getImmediate();
|
|
26318
|
+
function getFirestore(appOrDatabaseId, optionalDatabaseId) {
|
|
26319
|
+
const app$1 = typeof appOrDatabaseId === 'object' ? appOrDatabaseId : app.getApp();
|
|
26320
|
+
const databaseId = typeof appOrDatabaseId === 'string'
|
|
26321
|
+
? appOrDatabaseId
|
|
26322
|
+
: optionalDatabaseId || DEFAULT_DATABASE_NAME;
|
|
26323
|
+
return app._getProvider(app$1, 'firestore').getImmediate({
|
|
26324
|
+
identifier: databaseId
|
|
26325
|
+
});
|
|
26132
26326
|
}
|
|
26133
26327
|
/**
|
|
26134
26328
|
* @internal
|
|
@@ -26229,7 +26423,7 @@ function setPersistenceProviders(client, onlineComponentProvider, offlineCompone
|
|
|
26229
26423
|
if (!canFallbackFromIndexedDbError(error)) {
|
|
26230
26424
|
throw error;
|
|
26231
26425
|
}
|
|
26232
|
-
|
|
26426
|
+
logWarn('Error enabling offline persistence. Falling back to ' +
|
|
26233
26427
|
'persistence disabled: ' +
|
|
26234
26428
|
error);
|
|
26235
26429
|
persistenceResult.reject(error);
|
|
@@ -26374,7 +26568,7 @@ function disableNetwork(firestore) {
|
|
|
26374
26568
|
* terminated.
|
|
26375
26569
|
*/
|
|
26376
26570
|
function terminate(firestore) {
|
|
26377
|
-
app._removeServiceInstance(firestore.app, 'firestore');
|
|
26571
|
+
app._removeServiceInstance(firestore.app, 'firestore', firestore._databaseId.database);
|
|
26378
26572
|
return firestore._delete();
|
|
26379
26573
|
}
|
|
26380
26574
|
/**
|
|
@@ -26443,13 +26637,13 @@ function verifyNotInitialized(firestore) {
|
|
|
26443
26637
|
*/
|
|
26444
26638
|
function registerFirestore(variant, useFetchStreams = true) {
|
|
26445
26639
|
setSDKVersion(app.SDK_VERSION);
|
|
26446
|
-
app._registerComponent(new component.Component('firestore', (container, { options: settings }) => {
|
|
26640
|
+
app._registerComponent(new component.Component('firestore', (container, { instanceIdentifier: databaseId, options: settings }) => {
|
|
26447
26641
|
const app = container.getProvider('app').getImmediate();
|
|
26448
|
-
const firestoreInstance = new Firestore(
|
|
26642
|
+
const firestoreInstance = new Firestore(new FirebaseAuthCredentialsProvider(container.getProvider('auth-internal')), new FirebaseAppCheckTokenProvider(container.getProvider('app-check-internal')), databaseIdFromApp(app, databaseId), app);
|
|
26449
26643
|
settings = Object.assign({ useFetchStreams }, settings);
|
|
26450
26644
|
firestoreInstance._setSettings(settings);
|
|
26451
26645
|
return firestoreInstance;
|
|
26452
|
-
}, 'PUBLIC'));
|
|
26646
|
+
}, 'PUBLIC').setMultipleInstances(true));
|
|
26453
26647
|
app.registerVersion(name, version$1, variant);
|
|
26454
26648
|
// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
|
|
26455
26649
|
app.registerVersion(name, version$1, 'cjs2017');
|
|
@@ -29143,14 +29337,23 @@ function writeBatch(firestore) {
|
|
|
29143
29337
|
* limitations under the License.
|
|
29144
29338
|
*/
|
|
29145
29339
|
function setIndexConfiguration(firestore, jsonOrConfiguration) {
|
|
29340
|
+
var _a;
|
|
29146
29341
|
firestore = cast(firestore, Firestore);
|
|
29147
|
-
ensureFirestoreConfigured(firestore);
|
|
29342
|
+
const client = ensureFirestoreConfigured(firestore);
|
|
29343
|
+
// PORTING NOTE: We don't return an error if the user has not enabled
|
|
29344
|
+
// persistence since `enableIndexeddbPersistence()` can fail on the Web.
|
|
29345
|
+
if (!((_a = client.offlineComponents) === null || _a === void 0 ? void 0 : _a.indexBackfillerScheduler)) {
|
|
29346
|
+
logWarn('Cannot enable indexes when persistence is disabled');
|
|
29347
|
+
return Promise.resolve();
|
|
29348
|
+
}
|
|
29349
|
+
const parsedIndexes = parseIndexes(jsonOrConfiguration);
|
|
29350
|
+
return getLocalStore(client).then(localStore => localStoreConfigureFieldIndexes(localStore, parsedIndexes));
|
|
29351
|
+
}
|
|
29352
|
+
function parseIndexes(jsonOrConfiguration) {
|
|
29148
29353
|
const indexConfiguration = typeof jsonOrConfiguration === 'string'
|
|
29149
29354
|
? tryParseJson(jsonOrConfiguration)
|
|
29150
29355
|
: jsonOrConfiguration;
|
|
29151
29356
|
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
29357
|
if (Array.isArray(indexConfiguration.indexes)) {
|
|
29155
29358
|
for (const index of indexConfiguration.indexes) {
|
|
29156
29359
|
const collectionGroup = tryGetString(index, 'collectionGroup');
|
|
@@ -29173,8 +29376,7 @@ function setIndexConfiguration(firestore, jsonOrConfiguration) {
|
|
|
29173
29376
|
parsedIndexes.push(new FieldIndex(FieldIndex.UNKNOWN_ID, collectionGroup, segments, IndexState.empty()));
|
|
29174
29377
|
}
|
|
29175
29378
|
}
|
|
29176
|
-
|
|
29177
|
-
return Promise.resolve();
|
|
29379
|
+
return parsedIndexes;
|
|
29178
29380
|
}
|
|
29179
29381
|
function tryParseJson(json) {
|
|
29180
29382
|
var _a;
|
|
@@ -29182,7 +29384,7 @@ function tryParseJson(json) {
|
|
|
29182
29384
|
return JSON.parse(json);
|
|
29183
29385
|
}
|
|
29184
29386
|
catch (e) {
|
|
29185
|
-
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON:' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
|
|
29387
|
+
throw new FirestoreError(Code.INVALID_ARGUMENT, 'Failed to parse JSON: ' + ((_a = e) === null || _a === void 0 ? void 0 : _a.message));
|
|
29186
29388
|
}
|
|
29187
29389
|
}
|
|
29188
29390
|
function tryGetString(data, property) {
|
|
@@ -29239,7 +29441,6 @@ exports._cast = cast;
|
|
|
29239
29441
|
exports._debugAssert = debugAssert;
|
|
29240
29442
|
exports._isBase64Available = isBase64Available;
|
|
29241
29443
|
exports._logWarn = logWarn;
|
|
29242
|
-
exports._setIndexConfiguration = setIndexConfiguration;
|
|
29243
29444
|
exports._validateIsNotUsedTogether = validateIsNotUsedTogether;
|
|
29244
29445
|
exports.addDoc = addDoc;
|
|
29245
29446
|
exports.arrayRemove = arrayRemove;
|
|
@@ -29282,6 +29483,7 @@ exports.refEqual = refEqual;
|
|
|
29282
29483
|
exports.runTransaction = runTransaction;
|
|
29283
29484
|
exports.serverTimestamp = serverTimestamp;
|
|
29284
29485
|
exports.setDoc = setDoc;
|
|
29486
|
+
exports.setIndexConfiguration = setIndexConfiguration;
|
|
29285
29487
|
exports.setLogLevel = setLogLevel;
|
|
29286
29488
|
exports.snapshotEqual = snapshotEqual;
|
|
29287
29489
|
exports.startAfter = startAfter;
|