@firebase/firestore 3.4.4-canary.d04b608f2 → 3.4.4-canary.f5ac47fb1
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/dist/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/firestore/src/core/target.d.ts +8 -4
- package/dist/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/firestore/src/local/simple_db.d.ts +1 -0
- package/dist/firestore/test/util/helpers.d.ts +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.esm2017.js +2514 -2352
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3147 -3040
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +280 -95
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +280 -95
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2561 -2395
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +171 -4
- package/dist/lite/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/lite/firestore/src/core/target.d.ts +8 -4
- package/dist/lite/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/lite/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/lite/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/lite/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/lite/firestore/src/local/simple_db.d.ts +1 -0
- package/dist/lite/firestore/test/util/helpers.d.ts +1 -1
- package/dist/lite/index.browser.esm2017.js +301 -298
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +327 -326
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +36 -29
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +36 -29
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +357 -354
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +2 -2
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +90 -90
- package/dist/lite/packages/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/lite/packages/firestore/src/core/target.d.ts +8 -4
- package/dist/lite/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/lite/packages/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/lite/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/lite/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/lite/packages/firestore/src/local/simple_db.d.ts +1 -0
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +1 -1
- package/dist/lite/private.d.ts +2 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +78 -78
- package/dist/packages/firestore/src/api/snapshot.d.ts +1 -2
- package/dist/packages/firestore/src/core/target.d.ts +8 -4
- package/dist/packages/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/packages/firestore/src/local/index_manager.d.ts +52 -0
- package/dist/packages/firestore/src/local/indexeddb_index_manager.d.ts +11 -0
- package/dist/packages/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/packages/firestore/src/local/memory_index_manager.d.ts +11 -0
- package/dist/packages/firestore/src/local/simple_db.d.ts +1 -0
- package/dist/packages/firestore/test/util/helpers.d.ts +1 -1
- package/dist/private.d.ts +171 -4
- package/package.json +9 -9
package/dist/index.node.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { credentials, loadPackageDefinition, Metadata } from '@grpc/grpc-js';
|
|
|
8
8
|
import { fromJSON } from '@grpc/proto-loader';
|
|
9
9
|
|
|
10
10
|
const name = "@firebase/firestore";
|
|
11
|
-
const version$1 = "3.4.4-canary.
|
|
11
|
+
const version$1 = "3.4.4-canary.f5ac47fb1";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
61
61
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
62
62
|
User.MOCK_USER = new User('mock-user');
|
|
63
63
|
|
|
64
|
-
const version = "9.6.
|
|
64
|
+
const version = "9.6.6-canary.f5ac47fb1";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @license
|
|
@@ -1192,23 +1192,6 @@ function decodeResourcePath(path) {
|
|
|
1192
1192
|
}
|
|
1193
1193
|
return new ResourcePath(segments);
|
|
1194
1194
|
}
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
* @license
|
|
1198
|
-
* Copyright 2017 Google LLC
|
|
1199
|
-
*
|
|
1200
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1201
|
-
* you may not use this file except in compliance with the License.
|
|
1202
|
-
* You may obtain a copy of the License at
|
|
1203
|
-
*
|
|
1204
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1205
|
-
*
|
|
1206
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1207
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1208
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1209
|
-
* See the License for the specific language governing permissions and
|
|
1210
|
-
* limitations under the License.
|
|
1211
|
-
*/
|
|
1212
1195
|
/**
|
|
1213
1196
|
* Schema Version for the Web client:
|
|
1214
1197
|
* 1. Initial version including Mutation Queue, Query Cache, and Remote
|
|
@@ -1227,6 +1210,7 @@ function decodeResourcePath(path) {
|
|
|
1227
1210
|
* an auto-incrementing ID. This is required for Index-Free queries.
|
|
1228
1211
|
* 10. Rewrite the canonical IDs to the explicit Protobuf-based format.
|
|
1229
1212
|
* 11. Add bundles and named_queries for bundle support.
|
|
1213
|
+
* 12. Add indexing support.
|
|
1230
1214
|
*/
|
|
1231
1215
|
const SCHEMA_VERSION = 11;
|
|
1232
1216
|
/**
|
|
@@ -1753,9 +1737,7 @@ class DbClientMetadata {
|
|
|
1753
1737
|
DbClientMetadata.store = 'clientMetadata';
|
|
1754
1738
|
/** Keys are automatically assigned via the clientId properties. */
|
|
1755
1739
|
DbClientMetadata.keyPath = 'clientId';
|
|
1756
|
-
/**
|
|
1757
|
-
* A object representing a bundle loaded by the SDK.
|
|
1758
|
-
*/
|
|
1740
|
+
/** An object representing a bundle loaded by the SDK. */
|
|
1759
1741
|
class DbBundle {
|
|
1760
1742
|
constructor(
|
|
1761
1743
|
/** The ID of the loaded bundle. */
|
|
@@ -1772,9 +1754,7 @@ class DbBundle {
|
|
|
1772
1754
|
/** Name of the IndexedDb object store. */
|
|
1773
1755
|
DbBundle.store = 'bundles';
|
|
1774
1756
|
DbBundle.keyPath = 'bundleId';
|
|
1775
|
-
/**
|
|
1776
|
-
* A object representing a named query loaded by the SDK via a bundle.
|
|
1777
|
-
*/
|
|
1757
|
+
/** An object representing a named query loaded by the SDK via a bundle. */
|
|
1778
1758
|
class DbNamedQuery {
|
|
1779
1759
|
constructor(
|
|
1780
1760
|
/** The name of the query. */
|
|
@@ -1791,6 +1771,93 @@ class DbNamedQuery {
|
|
|
1791
1771
|
/** Name of the IndexedDb object store. */
|
|
1792
1772
|
DbNamedQuery.store = 'namedQueries';
|
|
1793
1773
|
DbNamedQuery.keyPath = 'name';
|
|
1774
|
+
/** An object representing the global configuration for a field index. */
|
|
1775
|
+
class DbIndexConfiguration {
|
|
1776
|
+
constructor(
|
|
1777
|
+
/** The index id for this entry. */
|
|
1778
|
+
indexId,
|
|
1779
|
+
/** The collection group this index belongs to. */
|
|
1780
|
+
collectionGroup,
|
|
1781
|
+
/** The fields to index for this index. */
|
|
1782
|
+
fields) {
|
|
1783
|
+
this.indexId = indexId;
|
|
1784
|
+
this.collectionGroup = collectionGroup;
|
|
1785
|
+
this.fields = fields;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
/** Name of the IndexedDb object store. */
|
|
1789
|
+
DbIndexConfiguration.store = 'indexConfiguration';
|
|
1790
|
+
DbIndexConfiguration.keyPath = 'indexId';
|
|
1791
|
+
/**
|
|
1792
|
+
* An object describing how up-to-date the index backfill is for each user and
|
|
1793
|
+
* index.
|
|
1794
|
+
*/
|
|
1795
|
+
class DbIndexState {
|
|
1796
|
+
constructor(
|
|
1797
|
+
/** The index id for this entry. */
|
|
1798
|
+
indexId,
|
|
1799
|
+
/** The user id for this entry. */
|
|
1800
|
+
uid,
|
|
1801
|
+
/**
|
|
1802
|
+
* A number that indicates when the index was last updated (relative to
|
|
1803
|
+
* other indexes).
|
|
1804
|
+
*/
|
|
1805
|
+
sequenceNumber,
|
|
1806
|
+
/**
|
|
1807
|
+
* The latest read time that has been indexed by Firestore for this field
|
|
1808
|
+
* index. Set to `{seconds: 0, nanos: 0}` if no documents have been indexed.
|
|
1809
|
+
*/
|
|
1810
|
+
readTime,
|
|
1811
|
+
/**
|
|
1812
|
+
* The last document that has been indexed for this field index. Empty if
|
|
1813
|
+
* no documents have been indexed.
|
|
1814
|
+
*/
|
|
1815
|
+
documentKey,
|
|
1816
|
+
/**
|
|
1817
|
+
* The largest mutation batch id that has been processed for this index. -1
|
|
1818
|
+
* if no mutations have been indexed.
|
|
1819
|
+
*/
|
|
1820
|
+
largestBatchId) {
|
|
1821
|
+
this.indexId = indexId;
|
|
1822
|
+
this.uid = uid;
|
|
1823
|
+
this.sequenceNumber = sequenceNumber;
|
|
1824
|
+
this.readTime = readTime;
|
|
1825
|
+
this.documentKey = documentKey;
|
|
1826
|
+
this.largestBatchId = largestBatchId;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
/** Name of the IndexedDb object store. */
|
|
1830
|
+
DbIndexState.store = 'indexState';
|
|
1831
|
+
DbIndexState.keyPath = ['indexId', 'uid'];
|
|
1832
|
+
/** An object that stores the encoded entries for all documents and fields. */
|
|
1833
|
+
class DbIndexEntries {
|
|
1834
|
+
constructor(
|
|
1835
|
+
/** The index id for this entry. */
|
|
1836
|
+
indexId,
|
|
1837
|
+
/** The user id for this entry. */
|
|
1838
|
+
uid,
|
|
1839
|
+
/** The encoded array index value for this entry. */
|
|
1840
|
+
arrayValue,
|
|
1841
|
+
/** The encoded directional value for equality and inequality filters. */
|
|
1842
|
+
directionalValue,
|
|
1843
|
+
/** The document key this entry points to. */
|
|
1844
|
+
documentKey) {
|
|
1845
|
+
this.indexId = indexId;
|
|
1846
|
+
this.uid = uid;
|
|
1847
|
+
this.arrayValue = arrayValue;
|
|
1848
|
+
this.directionalValue = directionalValue;
|
|
1849
|
+
this.documentKey = documentKey;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
/** Name of the IndexedDb object store. */
|
|
1853
|
+
DbIndexEntries.store = 'indexEntries';
|
|
1854
|
+
DbIndexEntries.keyPath = [
|
|
1855
|
+
'indexId',
|
|
1856
|
+
'uid',
|
|
1857
|
+
'arrayValue',
|
|
1858
|
+
'directionalValue',
|
|
1859
|
+
'documentKey'
|
|
1860
|
+
];
|
|
1794
1861
|
// Visible for testing
|
|
1795
1862
|
const V1_STORES = [
|
|
1796
1863
|
DbMutationQueue.store,
|
|
@@ -1805,7 +1872,6 @@ const V1_STORES = [
|
|
|
1805
1872
|
// V2 is no longer usable (see comment at top of file)
|
|
1806
1873
|
// Visible for testing
|
|
1807
1874
|
const V3_STORES = V1_STORES;
|
|
1808
|
-
// Visible for testing
|
|
1809
1875
|
// Note: DbRemoteDocumentChanges is no longer used and dropped with v9.
|
|
1810
1876
|
const V4_STORES = [...V3_STORES, DbClientMetadata.store];
|
|
1811
1877
|
// V5 does not change the set of stores.
|
|
@@ -1815,6 +1881,12 @@ const V8_STORES = [...V6_STORES, DbCollectionParent.store];
|
|
|
1815
1881
|
// V9 does not change the set of stores.
|
|
1816
1882
|
// V10 does not change the set of stores.
|
|
1817
1883
|
const V11_STORES = [...V8_STORES, DbBundle.store, DbNamedQuery.store];
|
|
1884
|
+
[
|
|
1885
|
+
...V11_STORES,
|
|
1886
|
+
DbIndexConfiguration.store,
|
|
1887
|
+
DbIndexState.store,
|
|
1888
|
+
DbIndexEntries.store
|
|
1889
|
+
];
|
|
1818
1890
|
/**
|
|
1819
1891
|
* The list of all default IndexedDB stores used throughout the SDK. This is
|
|
1820
1892
|
* used when creating transactions so that access across all stores is done
|
|
@@ -2117,6 +2189,15 @@ class SimpleDbTransaction {
|
|
|
2117
2189
|
this.transaction.abort();
|
|
2118
2190
|
}
|
|
2119
2191
|
}
|
|
2192
|
+
maybeCommit() {
|
|
2193
|
+
// If the browser supports V3 IndexedDB, we invoke commit() explicitly to
|
|
2194
|
+
// speed up index DB processing if the event loop remains blocks.
|
|
2195
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2196
|
+
const maybeV3IndexedDb = this.transaction;
|
|
2197
|
+
if (!this.aborted && typeof maybeV3IndexedDb.commit === 'function') {
|
|
2198
|
+
maybeV3IndexedDb.commit();
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2120
2201
|
/**
|
|
2121
2202
|
* Returns a SimpleDbStore<KeyType, ValueType> for the specified store. All
|
|
2122
2203
|
* operations performed on the SimpleDbStore happen within the context of this
|
|
@@ -2313,6 +2394,10 @@ class SimpleDb {
|
|
|
2313
2394
|
this.db = await this.ensureDb(action);
|
|
2314
2395
|
const transaction = SimpleDbTransaction.open(this.db, action, readonly ? 'readonly' : 'readwrite', objectStores);
|
|
2315
2396
|
const transactionFnResult = transactionFn(transaction)
|
|
2397
|
+
.next(result => {
|
|
2398
|
+
transaction.maybeCommit();
|
|
2399
|
+
return result;
|
|
2400
|
+
})
|
|
2316
2401
|
.catch(error => {
|
|
2317
2402
|
// Abort the transaction if there was an error.
|
|
2318
2403
|
transaction.abort(error);
|
|
@@ -4460,27 +4545,29 @@ function newTarget(path, collectionGroup = null, orderBy = [], filters = [], lim
|
|
|
4460
4545
|
function canonifyTarget(target) {
|
|
4461
4546
|
const targetImpl = debugCast(target);
|
|
4462
4547
|
if (targetImpl.memoizedCanonicalId === null) {
|
|
4463
|
-
let
|
|
4548
|
+
let str = targetImpl.path.canonicalString();
|
|
4464
4549
|
if (targetImpl.collectionGroup !== null) {
|
|
4465
|
-
|
|
4550
|
+
str += '|cg:' + targetImpl.collectionGroup;
|
|
4466
4551
|
}
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4552
|
+
str += '|f:';
|
|
4553
|
+
str += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
|
|
4554
|
+
str += '|ob:';
|
|
4555
|
+
str += targetImpl.orderBy.map(o => canonifyOrderBy(o)).join(',');
|
|
4471
4556
|
if (!isNullOrUndefined(targetImpl.limit)) {
|
|
4472
|
-
|
|
4473
|
-
|
|
4557
|
+
str += '|l:';
|
|
4558
|
+
str += targetImpl.limit;
|
|
4474
4559
|
}
|
|
4475
4560
|
if (targetImpl.startAt) {
|
|
4476
|
-
|
|
4477
|
-
|
|
4561
|
+
str += '|lb:';
|
|
4562
|
+
str += targetImpl.startAt.inclusive ? 'b:' : 'a:';
|
|
4563
|
+
str += targetImpl.startAt.position.map(p => canonicalId(p)).join(',');
|
|
4478
4564
|
}
|
|
4479
4565
|
if (targetImpl.endAt) {
|
|
4480
|
-
|
|
4481
|
-
|
|
4566
|
+
str += '|ub:';
|
|
4567
|
+
str += targetImpl.endAt.inclusive ? 'a:' : 'b:';
|
|
4568
|
+
str += targetImpl.endAt.position.map(p => canonicalId(p)).join(',');
|
|
4482
4569
|
}
|
|
4483
|
-
targetImpl.memoizedCanonicalId =
|
|
4570
|
+
targetImpl.memoizedCanonicalId = str;
|
|
4484
4571
|
}
|
|
4485
4572
|
return targetImpl.memoizedCanonicalId;
|
|
4486
4573
|
}
|
|
@@ -4503,10 +4590,14 @@ function stringifyTarget(target) {
|
|
|
4503
4590
|
.join(', ')}]`;
|
|
4504
4591
|
}
|
|
4505
4592
|
if (target.startAt) {
|
|
4506
|
-
str += ', startAt: '
|
|
4593
|
+
str += ', startAt: ';
|
|
4594
|
+
str += target.startAt.inclusive ? 'b:' : 'a:';
|
|
4595
|
+
str += target.startAt.position.map(p => canonicalId(p)).join(',');
|
|
4507
4596
|
}
|
|
4508
4597
|
if (target.endAt) {
|
|
4509
|
-
str += ', endAt: '
|
|
4598
|
+
str += ', endAt: ';
|
|
4599
|
+
str += target.endAt.inclusive ? 'a:' : 'b:';
|
|
4600
|
+
str += target.endAt.position.map(p => canonicalId(p)).join(',');
|
|
4510
4601
|
}
|
|
4511
4602
|
return `Target(${str})`;
|
|
4512
4603
|
}
|
|
@@ -4729,7 +4820,6 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4729
4820
|
return other.arrayValue.values.some(val => arrayValueContains(this.value.arrayValue, val));
|
|
4730
4821
|
}
|
|
4731
4822
|
}
|
|
4732
|
-
// TODO(indexing): Change Bound.before to "inclusive"
|
|
4733
4823
|
/**
|
|
4734
4824
|
* Represents a bound of a query.
|
|
4735
4825
|
*
|
|
@@ -4745,17 +4835,11 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4745
4835
|
* just after the provided values.
|
|
4746
4836
|
*/
|
|
4747
4837
|
class Bound {
|
|
4748
|
-
constructor(position,
|
|
4838
|
+
constructor(position, inclusive) {
|
|
4749
4839
|
this.position = position;
|
|
4750
|
-
this.
|
|
4840
|
+
this.inclusive = inclusive;
|
|
4751
4841
|
}
|
|
4752
4842
|
}
|
|
4753
|
-
function canonifyBound(bound) {
|
|
4754
|
-
// TODO(b/29183165): Make this collision robust.
|
|
4755
|
-
return `${bound.before ? 'b' : 'a'}:${bound.position
|
|
4756
|
-
.map(p => canonicalId(p))
|
|
4757
|
-
.join(',')}`;
|
|
4758
|
-
}
|
|
4759
4843
|
/**
|
|
4760
4844
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
4761
4845
|
*/
|
|
@@ -4775,11 +4859,7 @@ function stringifyOrderBy(orderBy) {
|
|
|
4775
4859
|
function orderByEquals(left, right) {
|
|
4776
4860
|
return left.dir === right.dir && left.field.isEqual(right.field);
|
|
4777
4861
|
}
|
|
4778
|
-
|
|
4779
|
-
* Returns true if a document sorts before a bound using the provided sort
|
|
4780
|
-
* order.
|
|
4781
|
-
*/
|
|
4782
|
-
function sortsBeforeDocument(bound, orderBy, doc) {
|
|
4862
|
+
function boundCompareToDocument(bound, orderBy, doc) {
|
|
4783
4863
|
let comparison = 0;
|
|
4784
4864
|
for (let i = 0; i < bound.position.length; i++) {
|
|
4785
4865
|
const orderByComponent = orderBy[i];
|
|
@@ -4798,7 +4878,23 @@ function sortsBeforeDocument(bound, orderBy, doc) {
|
|
|
4798
4878
|
break;
|
|
4799
4879
|
}
|
|
4800
4880
|
}
|
|
4801
|
-
return
|
|
4881
|
+
return comparison;
|
|
4882
|
+
}
|
|
4883
|
+
/**
|
|
4884
|
+
* Returns true if a document sorts after a bound using the provided sort
|
|
4885
|
+
* order.
|
|
4886
|
+
*/
|
|
4887
|
+
function boundSortsAfterDocument(bound, orderBy, doc) {
|
|
4888
|
+
const comparison = boundCompareToDocument(bound, orderBy, doc);
|
|
4889
|
+
return bound.inclusive ? comparison >= 0 : comparison > 0;
|
|
4890
|
+
}
|
|
4891
|
+
/**
|
|
4892
|
+
* Returns true if a document sorts before a bound using the provided sort
|
|
4893
|
+
* order.
|
|
4894
|
+
*/
|
|
4895
|
+
function boundSortsBeforeDocument(bound, orderBy, doc) {
|
|
4896
|
+
const comparison = boundCompareToDocument(bound, orderBy, doc);
|
|
4897
|
+
return bound.inclusive ? comparison <= 0 : comparison < 0;
|
|
4802
4898
|
}
|
|
4803
4899
|
function boundEquals(left, right) {
|
|
4804
4900
|
if (left === null) {
|
|
@@ -4807,7 +4903,7 @@ function boundEquals(left, right) {
|
|
|
4807
4903
|
else if (right === null) {
|
|
4808
4904
|
return false;
|
|
4809
4905
|
}
|
|
4810
|
-
if (left.
|
|
4906
|
+
if (left.inclusive !== right.inclusive ||
|
|
4811
4907
|
left.position.length !== right.position.length) {
|
|
4812
4908
|
return false;
|
|
4813
4909
|
}
|
|
@@ -5011,10 +5107,10 @@ function queryToTarget(query) {
|
|
|
5011
5107
|
}
|
|
5012
5108
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
5013
5109
|
const startAt = queryImpl.endAt
|
|
5014
|
-
? new Bound(queryImpl.endAt.position, !queryImpl.endAt.
|
|
5110
|
+
? new Bound(queryImpl.endAt.position, !queryImpl.endAt.inclusive)
|
|
5015
5111
|
: null;
|
|
5016
5112
|
const endAt = queryImpl.startAt
|
|
5017
|
-
? new Bound(queryImpl.startAt.position, !queryImpl.startAt.
|
|
5113
|
+
? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
|
|
5018
5114
|
: null;
|
|
5019
5115
|
// Now return as a LimitType.First query.
|
|
5020
5116
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -5102,11 +5198,11 @@ function queryMatchesFilters(query, doc) {
|
|
|
5102
5198
|
/** Makes sure a document is within the bounds, if provided. */
|
|
5103
5199
|
function queryMatchesBounds(query, doc) {
|
|
5104
5200
|
if (query.startAt &&
|
|
5105
|
-
!
|
|
5201
|
+
!boundSortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
|
|
5106
5202
|
return false;
|
|
5107
5203
|
}
|
|
5108
5204
|
if (query.endAt &&
|
|
5109
|
-
|
|
5205
|
+
!boundSortsAfterDocument(query.endAt, queryOrderBy(query), doc)) {
|
|
5110
5206
|
return false;
|
|
5111
5207
|
}
|
|
5112
5208
|
return true;
|
|
@@ -7985,10 +8081,10 @@ function toQueryTarget(serializer, target) {
|
|
|
7985
8081
|
result.structuredQuery.limit = limit;
|
|
7986
8082
|
}
|
|
7987
8083
|
if (target.startAt) {
|
|
7988
|
-
result.structuredQuery.startAt =
|
|
8084
|
+
result.structuredQuery.startAt = toStartAtCursor(target.startAt);
|
|
7989
8085
|
}
|
|
7990
8086
|
if (target.endAt) {
|
|
7991
|
-
result.structuredQuery.endAt =
|
|
8087
|
+
result.structuredQuery.endAt = toEndAtCursor(target.endAt);
|
|
7992
8088
|
}
|
|
7993
8089
|
return result;
|
|
7994
8090
|
}
|
|
@@ -8021,11 +8117,11 @@ function convertQueryTargetToQuery(target) {
|
|
|
8021
8117
|
}
|
|
8022
8118
|
let startAt = null;
|
|
8023
8119
|
if (query.startAt) {
|
|
8024
|
-
startAt =
|
|
8120
|
+
startAt = fromStartAtCursor(query.startAt);
|
|
8025
8121
|
}
|
|
8026
8122
|
let endAt = null;
|
|
8027
8123
|
if (query.endAt) {
|
|
8028
|
-
endAt =
|
|
8124
|
+
endAt = fromEndAtCursor(query.endAt);
|
|
8029
8125
|
}
|
|
8030
8126
|
return newQuery(path, collectionGroup, orderBy, filterBy, limit, "F" /* First */, startAt, endAt);
|
|
8031
8127
|
}
|
|
@@ -8116,16 +8212,27 @@ function toOrder(orderBys) {
|
|
|
8116
8212
|
function fromOrder(orderBys) {
|
|
8117
8213
|
return orderBys.map(order => fromPropertyOrder(order));
|
|
8118
8214
|
}
|
|
8119
|
-
function
|
|
8215
|
+
function toStartAtCursor(cursor) {
|
|
8216
|
+
return {
|
|
8217
|
+
before: cursor.inclusive,
|
|
8218
|
+
values: cursor.position
|
|
8219
|
+
};
|
|
8220
|
+
}
|
|
8221
|
+
function toEndAtCursor(cursor) {
|
|
8120
8222
|
return {
|
|
8121
|
-
before: cursor.
|
|
8223
|
+
before: !cursor.inclusive,
|
|
8122
8224
|
values: cursor.position
|
|
8123
8225
|
};
|
|
8124
8226
|
}
|
|
8125
|
-
function
|
|
8126
|
-
const
|
|
8227
|
+
function fromStartAtCursor(cursor) {
|
|
8228
|
+
const inclusive = !!cursor.before;
|
|
8229
|
+
const position = cursor.values || [];
|
|
8230
|
+
return new Bound(position, inclusive);
|
|
8231
|
+
}
|
|
8232
|
+
function fromEndAtCursor(cursor) {
|
|
8233
|
+
const inclusive = !cursor.before;
|
|
8127
8234
|
const position = cursor.values || [];
|
|
8128
|
-
return new Bound(position,
|
|
8235
|
+
return new Bound(position, inclusive);
|
|
8129
8236
|
}
|
|
8130
8237
|
// visible for testing
|
|
8131
8238
|
function toDirection(dir) {
|
|
@@ -8678,6 +8785,38 @@ class MemoryIndexManager {
|
|
|
8678
8785
|
getCollectionParents(transaction, collectionId) {
|
|
8679
8786
|
return PersistencePromise.resolve(this.collectionParentIndex.getEntries(collectionId));
|
|
8680
8787
|
}
|
|
8788
|
+
addFieldIndex(transaction, index) {
|
|
8789
|
+
// Field indices are not supported with memory persistence.
|
|
8790
|
+
return PersistencePromise.resolve();
|
|
8791
|
+
}
|
|
8792
|
+
deleteFieldIndex(transaction, index) {
|
|
8793
|
+
// Field indices are not supported with memory persistence.
|
|
8794
|
+
return PersistencePromise.resolve();
|
|
8795
|
+
}
|
|
8796
|
+
getDocumentsMatchingTarget(transaction, fieldIndex, target) {
|
|
8797
|
+
// Field indices are not supported with memory persistence.
|
|
8798
|
+
return PersistencePromise.resolve(documentKeySet());
|
|
8799
|
+
}
|
|
8800
|
+
getFieldIndex(transaction, target) {
|
|
8801
|
+
// Field indices are not supported with memory persistence.
|
|
8802
|
+
return PersistencePromise.resolve(null);
|
|
8803
|
+
}
|
|
8804
|
+
getFieldIndexes(transaction, collectionGroup) {
|
|
8805
|
+
// Field indices are not supported with memory persistence.
|
|
8806
|
+
return PersistencePromise.resolve([]);
|
|
8807
|
+
}
|
|
8808
|
+
getNextCollectionGroupToUpdate(transaction) {
|
|
8809
|
+
// Field indices are not supported with memory persistence.
|
|
8810
|
+
return PersistencePromise.resolve(null);
|
|
8811
|
+
}
|
|
8812
|
+
updateCollectionGroup(transaction, collectionGroup, offset) {
|
|
8813
|
+
// Field indices are not supported with memory persistence.
|
|
8814
|
+
return PersistencePromise.resolve();
|
|
8815
|
+
}
|
|
8816
|
+
updateIndexEntries(transaction, documents) {
|
|
8817
|
+
// Field indices are not supported with memory persistence.
|
|
8818
|
+
return PersistencePromise.resolve();
|
|
8819
|
+
}
|
|
8681
8820
|
}
|
|
8682
8821
|
/**
|
|
8683
8822
|
* Internal implementation of the collection-parent index exposed by MemoryIndexManager.
|
|
@@ -8786,6 +8925,38 @@ class IndexedDbIndexManager {
|
|
|
8786
8925
|
return parentPaths;
|
|
8787
8926
|
});
|
|
8788
8927
|
}
|
|
8928
|
+
addFieldIndex(transaction, index) {
|
|
8929
|
+
// TODO(indexing): Implement
|
|
8930
|
+
return PersistencePromise.resolve();
|
|
8931
|
+
}
|
|
8932
|
+
deleteFieldIndex(transaction, index) {
|
|
8933
|
+
// TODO(indexing): Implement
|
|
8934
|
+
return PersistencePromise.resolve();
|
|
8935
|
+
}
|
|
8936
|
+
getDocumentsMatchingTarget(transaction, fieldIndex, target) {
|
|
8937
|
+
// TODO(indexing): Implement
|
|
8938
|
+
return PersistencePromise.resolve(documentKeySet());
|
|
8939
|
+
}
|
|
8940
|
+
getFieldIndex(transaction, target) {
|
|
8941
|
+
// TODO(indexing): Implement
|
|
8942
|
+
return PersistencePromise.resolve(null);
|
|
8943
|
+
}
|
|
8944
|
+
getFieldIndexes(transaction, collectionGroup) {
|
|
8945
|
+
// TODO(indexing): Implement
|
|
8946
|
+
return PersistencePromise.resolve([]);
|
|
8947
|
+
}
|
|
8948
|
+
getNextCollectionGroupToUpdate(transaction) {
|
|
8949
|
+
// TODO(indexing): Implement
|
|
8950
|
+
return PersistencePromise.resolve(null);
|
|
8951
|
+
}
|
|
8952
|
+
updateCollectionGroup(transaction, collectionGroup, offset) {
|
|
8953
|
+
// TODO(indexing): Implement
|
|
8954
|
+
return PersistencePromise.resolve();
|
|
8955
|
+
}
|
|
8956
|
+
updateIndexEntries(transaction, documents) {
|
|
8957
|
+
// TODO(indexing): Implement
|
|
8958
|
+
return PersistencePromise.resolve();
|
|
8959
|
+
}
|
|
8789
8960
|
}
|
|
8790
8961
|
/**
|
|
8791
8962
|
* Helper to get a typed SimpleDbStore for the collectionParents
|
|
@@ -10637,9 +10808,6 @@ class SchemaConverter {
|
|
|
10637
10808
|
* and local feature development.
|
|
10638
10809
|
*/
|
|
10639
10810
|
createOrUpgrade(db, txn, fromVersion, toVersion) {
|
|
10640
|
-
hardAssert(fromVersion < toVersion &&
|
|
10641
|
-
fromVersion >= 0 &&
|
|
10642
|
-
toVersion <= SCHEMA_VERSION);
|
|
10643
10811
|
const simpleDbTransaction = new SimpleDbTransaction('createOrUpgrade', txn);
|
|
10644
10812
|
if (fromVersion < 1 && toVersion >= 1) {
|
|
10645
10813
|
createPrimaryClientStore(db);
|
|
@@ -10706,6 +10874,11 @@ class SchemaConverter {
|
|
|
10706
10874
|
createNamedQueriesStore(db);
|
|
10707
10875
|
});
|
|
10708
10876
|
}
|
|
10877
|
+
if (fromVersion < 12 && toVersion >= 12) {
|
|
10878
|
+
p = p.next(() => {
|
|
10879
|
+
createFieldIndex(db);
|
|
10880
|
+
});
|
|
10881
|
+
}
|
|
10709
10882
|
return p;
|
|
10710
10883
|
}
|
|
10711
10884
|
addDocumentGlobal(txn) {
|
|
@@ -10912,6 +11085,17 @@ function createNamedQueriesStore(db) {
|
|
|
10912
11085
|
db.createObjectStore(DbNamedQuery.store, {
|
|
10913
11086
|
keyPath: DbNamedQuery.keyPath
|
|
10914
11087
|
});
|
|
11088
|
+
}
|
|
11089
|
+
function createFieldIndex(db) {
|
|
11090
|
+
db.createObjectStore(DbIndexConfiguration.store, {
|
|
11091
|
+
keyPath: DbIndexConfiguration.keyPath
|
|
11092
|
+
});
|
|
11093
|
+
db.createObjectStore(DbIndexState.store, {
|
|
11094
|
+
keyPath: DbIndexState.keyPath
|
|
11095
|
+
});
|
|
11096
|
+
db.createObjectStore(DbIndexEntries.store, {
|
|
11097
|
+
keyPath: DbIndexEntries.keyPath
|
|
11098
|
+
});
|
|
10915
11099
|
}
|
|
10916
11100
|
|
|
10917
11101
|
/**
|
|
@@ -20340,12 +20524,12 @@ async function syncEngineListen(syncEngine, query) {
|
|
|
20340
20524
|
}
|
|
20341
20525
|
else {
|
|
20342
20526
|
const targetData = await localStoreAllocateTarget(syncEngineImpl.localStore, queryToTarget(query));
|
|
20343
|
-
const status = syncEngineImpl.sharedClientState.addLocalQueryTarget(targetData.targetId);
|
|
20344
|
-
targetId = targetData.targetId;
|
|
20345
|
-
viewSnapshot = await initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId, status === 'current');
|
|
20346
20527
|
if (syncEngineImpl.isPrimaryClient) {
|
|
20347
20528
|
remoteStoreListen(syncEngineImpl.remoteStore, targetData);
|
|
20348
20529
|
}
|
|
20530
|
+
const status = syncEngineImpl.sharedClientState.addLocalQueryTarget(targetData.targetId);
|
|
20531
|
+
targetId = targetData.targetId;
|
|
20532
|
+
viewSnapshot = await initializeViewAndComputeSnapshot(syncEngineImpl, query, targetId, status === 'current');
|
|
20349
20533
|
}
|
|
20350
20534
|
return viewSnapshot;
|
|
20351
20535
|
}
|
|
@@ -24853,8 +25037,7 @@ class DocumentSnapshot extends DocumentSnapshot$1 {
|
|
|
24853
25037
|
this.metadata = metadata;
|
|
24854
25038
|
}
|
|
24855
25039
|
/**
|
|
24856
|
-
*
|
|
24857
|
-
* exists. True if the document exists.
|
|
25040
|
+
* Returns whether or not the data exists. True if the document exists.
|
|
24858
25041
|
*/
|
|
24859
25042
|
exists() {
|
|
24860
25043
|
return super.exists();
|
|
@@ -25228,51 +25411,53 @@ function limitToLast(limit) {
|
|
|
25228
25411
|
return new QueryLimitConstraint('limitToLast', limit, "L" /* Last */);
|
|
25229
25412
|
}
|
|
25230
25413
|
class QueryStartAtConstraint extends QueryConstraint {
|
|
25231
|
-
constructor(type, _docOrFields,
|
|
25414
|
+
constructor(type, _docOrFields, _inclusive) {
|
|
25232
25415
|
super();
|
|
25233
25416
|
this.type = type;
|
|
25234
25417
|
this._docOrFields = _docOrFields;
|
|
25235
|
-
this.
|
|
25418
|
+
this._inclusive = _inclusive;
|
|
25236
25419
|
}
|
|
25237
25420
|
_apply(query) {
|
|
25238
|
-
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this.
|
|
25421
|
+
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
|
|
25239
25422
|
return new Query(query.firestore, query.converter, queryWithStartAt(query._query, bound));
|
|
25240
25423
|
}
|
|
25241
25424
|
}
|
|
25242
25425
|
function startAt(...docOrFields) {
|
|
25243
|
-
return new QueryStartAtConstraint('startAt', docOrFields,
|
|
25426
|
+
return new QueryStartAtConstraint('startAt', docOrFields,
|
|
25427
|
+
/*inclusive=*/ true);
|
|
25244
25428
|
}
|
|
25245
25429
|
function startAfter(...docOrFields) {
|
|
25246
25430
|
return new QueryStartAtConstraint('startAfter', docOrFields,
|
|
25247
|
-
/*
|
|
25431
|
+
/*inclusive=*/ false);
|
|
25248
25432
|
}
|
|
25249
25433
|
class QueryEndAtConstraint extends QueryConstraint {
|
|
25250
|
-
constructor(type, _docOrFields,
|
|
25434
|
+
constructor(type, _docOrFields, _inclusive) {
|
|
25251
25435
|
super();
|
|
25252
25436
|
this.type = type;
|
|
25253
25437
|
this._docOrFields = _docOrFields;
|
|
25254
|
-
this.
|
|
25438
|
+
this._inclusive = _inclusive;
|
|
25255
25439
|
}
|
|
25256
25440
|
_apply(query) {
|
|
25257
|
-
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this.
|
|
25441
|
+
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
|
|
25258
25442
|
return new Query(query.firestore, query.converter, queryWithEndAt(query._query, bound));
|
|
25259
25443
|
}
|
|
25260
25444
|
}
|
|
25261
25445
|
function endBefore(...docOrFields) {
|
|
25262
|
-
return new QueryEndAtConstraint('endBefore', docOrFields,
|
|
25446
|
+
return new QueryEndAtConstraint('endBefore', docOrFields,
|
|
25447
|
+
/*inclusive=*/ false);
|
|
25263
25448
|
}
|
|
25264
25449
|
function endAt(...docOrFields) {
|
|
25265
|
-
return new QueryEndAtConstraint('endAt', docOrFields, /*
|
|
25450
|
+
return new QueryEndAtConstraint('endAt', docOrFields, /*inclusive=*/ true);
|
|
25266
25451
|
}
|
|
25267
25452
|
/** Helper function to create a bound from a document or fields */
|
|
25268
|
-
function newQueryBoundFromDocOrFields(query, methodName, docOrFields,
|
|
25453
|
+
function newQueryBoundFromDocOrFields(query, methodName, docOrFields, inclusive) {
|
|
25269
25454
|
docOrFields[0] = getModularInstance(docOrFields[0]);
|
|
25270
25455
|
if (docOrFields[0] instanceof DocumentSnapshot$1) {
|
|
25271
|
-
return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document,
|
|
25456
|
+
return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, inclusive);
|
|
25272
25457
|
}
|
|
25273
25458
|
else {
|
|
25274
25459
|
const reader = newUserDataReader(query.firestore);
|
|
25275
|
-
return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields,
|
|
25460
|
+
return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, inclusive);
|
|
25276
25461
|
}
|
|
25277
25462
|
}
|
|
25278
25463
|
function newQueryFilter(query, methodName, dataReader, databaseId, fieldPath, op, value) {
|
|
@@ -25330,7 +25515,7 @@ function newQueryOrderBy(query, fieldPath, direction) {
|
|
|
25330
25515
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
25331
25516
|
* server timestamp.
|
|
25332
25517
|
*/
|
|
25333
|
-
function newQueryBoundFromDocument(query, databaseId, methodName, doc,
|
|
25518
|
+
function newQueryBoundFromDocument(query, databaseId, methodName, doc, inclusive) {
|
|
25334
25519
|
if (!doc) {
|
|
25335
25520
|
throw new FirestoreError(Code.NOT_FOUND, `Can't use a DocumentSnapshot that doesn't exist for ` +
|
|
25336
25521
|
`${methodName}().`);
|
|
@@ -25367,12 +25552,12 @@ function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
|
|
|
25367
25552
|
}
|
|
25368
25553
|
}
|
|
25369
25554
|
}
|
|
25370
|
-
return new Bound(components,
|
|
25555
|
+
return new Bound(components, inclusive);
|
|
25371
25556
|
}
|
|
25372
25557
|
/**
|
|
25373
25558
|
* Converts a list of field values to a `Bound` for the given query.
|
|
25374
25559
|
*/
|
|
25375
|
-
function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values,
|
|
25560
|
+
function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, inclusive) {
|
|
25376
25561
|
// Use explicit order by's because it has to match the query the user made
|
|
25377
25562
|
const orderBy = query.explicitOrderBy;
|
|
25378
25563
|
if (values.length > orderBy.length) {
|
|
@@ -25409,7 +25594,7 @@ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, valu
|
|
|
25409
25594
|
components.push(wrapped);
|
|
25410
25595
|
}
|
|
25411
25596
|
}
|
|
25412
|
-
return new Bound(components,
|
|
25597
|
+
return new Bound(components, inclusive);
|
|
25413
25598
|
}
|
|
25414
25599
|
/**
|
|
25415
25600
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|