@firebase/firestore 3.4.4-canary.2dd99ae2d → 3.4.4-canary.7f959622d
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/core/target.d.ts +8 -4
- package/dist/firestore/src/lite-api/query.d.ts +2 -2
- package/dist/firestore/src/local/indexeddb_schema.d.ts +121 -7
- package/dist/firestore/test/util/helpers.d.ts +1 -1
- package/dist/index.esm2017.js +2233 -2144
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2964 -2912
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +199 -90
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +199 -90
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +2183 -2090
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +2 -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/indexeddb_schema.d.ts +121 -7
- 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 +301 -298
- 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/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/indexeddb_schema.d.ts +121 -7
- 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 +61 -61
- 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/indexeddb_schema.d.ts +121 -7
- package/dist/packages/firestore/test/util/helpers.d.ts +1 -1
- package/dist/private.d.ts +2 -2
- 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.7f959622d";
|
|
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.5-canary.
|
|
64
|
+
const version = "9.6.5-canary.7f959622d";
|
|
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
|
|
@@ -4460,27 +4532,29 @@ function newTarget(path, collectionGroup = null, orderBy = [], filters = [], lim
|
|
|
4460
4532
|
function canonifyTarget(target) {
|
|
4461
4533
|
const targetImpl = debugCast(target);
|
|
4462
4534
|
if (targetImpl.memoizedCanonicalId === null) {
|
|
4463
|
-
let
|
|
4535
|
+
let str = targetImpl.path.canonicalString();
|
|
4464
4536
|
if (targetImpl.collectionGroup !== null) {
|
|
4465
|
-
|
|
4537
|
+
str += '|cg:' + targetImpl.collectionGroup;
|
|
4466
4538
|
}
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4539
|
+
str += '|f:';
|
|
4540
|
+
str += targetImpl.filters.map(f => canonifyFilter(f)).join(',');
|
|
4541
|
+
str += '|ob:';
|
|
4542
|
+
str += targetImpl.orderBy.map(o => canonifyOrderBy(o)).join(',');
|
|
4471
4543
|
if (!isNullOrUndefined(targetImpl.limit)) {
|
|
4472
|
-
|
|
4473
|
-
|
|
4544
|
+
str += '|l:';
|
|
4545
|
+
str += targetImpl.limit;
|
|
4474
4546
|
}
|
|
4475
4547
|
if (targetImpl.startAt) {
|
|
4476
|
-
|
|
4477
|
-
|
|
4548
|
+
str += '|lb:';
|
|
4549
|
+
str += targetImpl.startAt.inclusive ? 'b:' : 'a:';
|
|
4550
|
+
str += targetImpl.startAt.position.map(p => canonicalId(p)).join(',');
|
|
4478
4551
|
}
|
|
4479
4552
|
if (targetImpl.endAt) {
|
|
4480
|
-
|
|
4481
|
-
|
|
4553
|
+
str += '|ub:';
|
|
4554
|
+
str += targetImpl.endAt.inclusive ? 'a:' : 'b:';
|
|
4555
|
+
str += targetImpl.endAt.position.map(p => canonicalId(p)).join(',');
|
|
4482
4556
|
}
|
|
4483
|
-
targetImpl.memoizedCanonicalId =
|
|
4557
|
+
targetImpl.memoizedCanonicalId = str;
|
|
4484
4558
|
}
|
|
4485
4559
|
return targetImpl.memoizedCanonicalId;
|
|
4486
4560
|
}
|
|
@@ -4503,10 +4577,14 @@ function stringifyTarget(target) {
|
|
|
4503
4577
|
.join(', ')}]`;
|
|
4504
4578
|
}
|
|
4505
4579
|
if (target.startAt) {
|
|
4506
|
-
str += ', startAt: '
|
|
4580
|
+
str += ', startAt: ';
|
|
4581
|
+
str += target.startAt.inclusive ? 'b:' : 'a:';
|
|
4582
|
+
str += target.startAt.position.map(p => canonicalId(p)).join(',');
|
|
4507
4583
|
}
|
|
4508
4584
|
if (target.endAt) {
|
|
4509
|
-
str += ', endAt: '
|
|
4585
|
+
str += ', endAt: ';
|
|
4586
|
+
str += target.endAt.inclusive ? 'a:' : 'b:';
|
|
4587
|
+
str += target.endAt.position.map(p => canonicalId(p)).join(',');
|
|
4510
4588
|
}
|
|
4511
4589
|
return `Target(${str})`;
|
|
4512
4590
|
}
|
|
@@ -4729,7 +4807,6 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4729
4807
|
return other.arrayValue.values.some(val => arrayValueContains(this.value.arrayValue, val));
|
|
4730
4808
|
}
|
|
4731
4809
|
}
|
|
4732
|
-
// TODO(indexing): Change Bound.before to "inclusive"
|
|
4733
4810
|
/**
|
|
4734
4811
|
* Represents a bound of a query.
|
|
4735
4812
|
*
|
|
@@ -4745,17 +4822,11 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4745
4822
|
* just after the provided values.
|
|
4746
4823
|
*/
|
|
4747
4824
|
class Bound {
|
|
4748
|
-
constructor(position,
|
|
4825
|
+
constructor(position, inclusive) {
|
|
4749
4826
|
this.position = position;
|
|
4750
|
-
this.
|
|
4827
|
+
this.inclusive = inclusive;
|
|
4751
4828
|
}
|
|
4752
4829
|
}
|
|
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
4830
|
/**
|
|
4760
4831
|
* An ordering on a field, in some Direction. Direction defaults to ASCENDING.
|
|
4761
4832
|
*/
|
|
@@ -4775,11 +4846,7 @@ function stringifyOrderBy(orderBy) {
|
|
|
4775
4846
|
function orderByEquals(left, right) {
|
|
4776
4847
|
return left.dir === right.dir && left.field.isEqual(right.field);
|
|
4777
4848
|
}
|
|
4778
|
-
|
|
4779
|
-
* Returns true if a document sorts before a bound using the provided sort
|
|
4780
|
-
* order.
|
|
4781
|
-
*/
|
|
4782
|
-
function sortsBeforeDocument(bound, orderBy, doc) {
|
|
4849
|
+
function boundCompareToDocument(bound, orderBy, doc) {
|
|
4783
4850
|
let comparison = 0;
|
|
4784
4851
|
for (let i = 0; i < bound.position.length; i++) {
|
|
4785
4852
|
const orderByComponent = orderBy[i];
|
|
@@ -4798,7 +4865,23 @@ function sortsBeforeDocument(bound, orderBy, doc) {
|
|
|
4798
4865
|
break;
|
|
4799
4866
|
}
|
|
4800
4867
|
}
|
|
4801
|
-
return
|
|
4868
|
+
return comparison;
|
|
4869
|
+
}
|
|
4870
|
+
/**
|
|
4871
|
+
* Returns true if a document sorts after a bound using the provided sort
|
|
4872
|
+
* order.
|
|
4873
|
+
*/
|
|
4874
|
+
function boundSortsAfterDocument(bound, orderBy, doc) {
|
|
4875
|
+
const comparison = boundCompareToDocument(bound, orderBy, doc);
|
|
4876
|
+
return bound.inclusive ? comparison >= 0 : comparison > 0;
|
|
4877
|
+
}
|
|
4878
|
+
/**
|
|
4879
|
+
* Returns true if a document sorts before a bound using the provided sort
|
|
4880
|
+
* order.
|
|
4881
|
+
*/
|
|
4882
|
+
function boundSortsBeforeDocument(bound, orderBy, doc) {
|
|
4883
|
+
const comparison = boundCompareToDocument(bound, orderBy, doc);
|
|
4884
|
+
return bound.inclusive ? comparison <= 0 : comparison < 0;
|
|
4802
4885
|
}
|
|
4803
4886
|
function boundEquals(left, right) {
|
|
4804
4887
|
if (left === null) {
|
|
@@ -4807,7 +4890,7 @@ function boundEquals(left, right) {
|
|
|
4807
4890
|
else if (right === null) {
|
|
4808
4891
|
return false;
|
|
4809
4892
|
}
|
|
4810
|
-
if (left.
|
|
4893
|
+
if (left.inclusive !== right.inclusive ||
|
|
4811
4894
|
left.position.length !== right.position.length) {
|
|
4812
4895
|
return false;
|
|
4813
4896
|
}
|
|
@@ -5011,10 +5094,10 @@ function queryToTarget(query) {
|
|
|
5011
5094
|
}
|
|
5012
5095
|
// We need to swap the cursors to match the now-flipped query ordering.
|
|
5013
5096
|
const startAt = queryImpl.endAt
|
|
5014
|
-
? new Bound(queryImpl.endAt.position, !queryImpl.endAt.
|
|
5097
|
+
? new Bound(queryImpl.endAt.position, !queryImpl.endAt.inclusive)
|
|
5015
5098
|
: null;
|
|
5016
5099
|
const endAt = queryImpl.startAt
|
|
5017
|
-
? new Bound(queryImpl.startAt.position, !queryImpl.startAt.
|
|
5100
|
+
? new Bound(queryImpl.startAt.position, !queryImpl.startAt.inclusive)
|
|
5018
5101
|
: null;
|
|
5019
5102
|
// Now return as a LimitType.First query.
|
|
5020
5103
|
queryImpl.memoizedTarget = newTarget(queryImpl.path, queryImpl.collectionGroup, orderBys, queryImpl.filters, queryImpl.limit, startAt, endAt);
|
|
@@ -5102,11 +5185,11 @@ function queryMatchesFilters(query, doc) {
|
|
|
5102
5185
|
/** Makes sure a document is within the bounds, if provided. */
|
|
5103
5186
|
function queryMatchesBounds(query, doc) {
|
|
5104
5187
|
if (query.startAt &&
|
|
5105
|
-
!
|
|
5188
|
+
!boundSortsBeforeDocument(query.startAt, queryOrderBy(query), doc)) {
|
|
5106
5189
|
return false;
|
|
5107
5190
|
}
|
|
5108
5191
|
if (query.endAt &&
|
|
5109
|
-
|
|
5192
|
+
!boundSortsAfterDocument(query.endAt, queryOrderBy(query), doc)) {
|
|
5110
5193
|
return false;
|
|
5111
5194
|
}
|
|
5112
5195
|
return true;
|
|
@@ -7985,10 +8068,10 @@ function toQueryTarget(serializer, target) {
|
|
|
7985
8068
|
result.structuredQuery.limit = limit;
|
|
7986
8069
|
}
|
|
7987
8070
|
if (target.startAt) {
|
|
7988
|
-
result.structuredQuery.startAt =
|
|
8071
|
+
result.structuredQuery.startAt = toStartAtCursor(target.startAt);
|
|
7989
8072
|
}
|
|
7990
8073
|
if (target.endAt) {
|
|
7991
|
-
result.structuredQuery.endAt =
|
|
8074
|
+
result.structuredQuery.endAt = toEndAtCursor(target.endAt);
|
|
7992
8075
|
}
|
|
7993
8076
|
return result;
|
|
7994
8077
|
}
|
|
@@ -8021,11 +8104,11 @@ function convertQueryTargetToQuery(target) {
|
|
|
8021
8104
|
}
|
|
8022
8105
|
let startAt = null;
|
|
8023
8106
|
if (query.startAt) {
|
|
8024
|
-
startAt =
|
|
8107
|
+
startAt = fromStartAtCursor(query.startAt);
|
|
8025
8108
|
}
|
|
8026
8109
|
let endAt = null;
|
|
8027
8110
|
if (query.endAt) {
|
|
8028
|
-
endAt =
|
|
8111
|
+
endAt = fromEndAtCursor(query.endAt);
|
|
8029
8112
|
}
|
|
8030
8113
|
return newQuery(path, collectionGroup, orderBy, filterBy, limit, "F" /* First */, startAt, endAt);
|
|
8031
8114
|
}
|
|
@@ -8116,16 +8199,27 @@ function toOrder(orderBys) {
|
|
|
8116
8199
|
function fromOrder(orderBys) {
|
|
8117
8200
|
return orderBys.map(order => fromPropertyOrder(order));
|
|
8118
8201
|
}
|
|
8119
|
-
function
|
|
8202
|
+
function toStartAtCursor(cursor) {
|
|
8120
8203
|
return {
|
|
8121
|
-
before: cursor.
|
|
8204
|
+
before: cursor.inclusive,
|
|
8122
8205
|
values: cursor.position
|
|
8123
8206
|
};
|
|
8124
8207
|
}
|
|
8125
|
-
function
|
|
8126
|
-
|
|
8208
|
+
function toEndAtCursor(cursor) {
|
|
8209
|
+
return {
|
|
8210
|
+
before: !cursor.inclusive,
|
|
8211
|
+
values: cursor.position
|
|
8212
|
+
};
|
|
8213
|
+
}
|
|
8214
|
+
function fromStartAtCursor(cursor) {
|
|
8215
|
+
const inclusive = !!cursor.before;
|
|
8216
|
+
const position = cursor.values || [];
|
|
8217
|
+
return new Bound(position, inclusive);
|
|
8218
|
+
}
|
|
8219
|
+
function fromEndAtCursor(cursor) {
|
|
8220
|
+
const inclusive = !cursor.before;
|
|
8127
8221
|
const position = cursor.values || [];
|
|
8128
|
-
return new Bound(position,
|
|
8222
|
+
return new Bound(position, inclusive);
|
|
8129
8223
|
}
|
|
8130
8224
|
// visible for testing
|
|
8131
8225
|
function toDirection(dir) {
|
|
@@ -10637,9 +10731,6 @@ class SchemaConverter {
|
|
|
10637
10731
|
* and local feature development.
|
|
10638
10732
|
*/
|
|
10639
10733
|
createOrUpgrade(db, txn, fromVersion, toVersion) {
|
|
10640
|
-
hardAssert(fromVersion < toVersion &&
|
|
10641
|
-
fromVersion >= 0 &&
|
|
10642
|
-
toVersion <= SCHEMA_VERSION);
|
|
10643
10734
|
const simpleDbTransaction = new SimpleDbTransaction('createOrUpgrade', txn);
|
|
10644
10735
|
if (fromVersion < 1 && toVersion >= 1) {
|
|
10645
10736
|
createPrimaryClientStore(db);
|
|
@@ -10706,6 +10797,11 @@ class SchemaConverter {
|
|
|
10706
10797
|
createNamedQueriesStore(db);
|
|
10707
10798
|
});
|
|
10708
10799
|
}
|
|
10800
|
+
if (fromVersion < 12 && toVersion >= 12) {
|
|
10801
|
+
p = p.next(() => {
|
|
10802
|
+
createFieldIndex(db);
|
|
10803
|
+
});
|
|
10804
|
+
}
|
|
10709
10805
|
return p;
|
|
10710
10806
|
}
|
|
10711
10807
|
addDocumentGlobal(txn) {
|
|
@@ -10912,6 +11008,17 @@ function createNamedQueriesStore(db) {
|
|
|
10912
11008
|
db.createObjectStore(DbNamedQuery.store, {
|
|
10913
11009
|
keyPath: DbNamedQuery.keyPath
|
|
10914
11010
|
});
|
|
11011
|
+
}
|
|
11012
|
+
function createFieldIndex(db) {
|
|
11013
|
+
db.createObjectStore(DbIndexConfiguration.store, {
|
|
11014
|
+
keyPath: DbIndexConfiguration.keyPath
|
|
11015
|
+
});
|
|
11016
|
+
db.createObjectStore(DbIndexState.store, {
|
|
11017
|
+
keyPath: DbIndexState.keyPath
|
|
11018
|
+
});
|
|
11019
|
+
db.createObjectStore(DbIndexEntries.store, {
|
|
11020
|
+
keyPath: DbIndexEntries.keyPath
|
|
11021
|
+
});
|
|
10915
11022
|
}
|
|
10916
11023
|
|
|
10917
11024
|
/**
|
|
@@ -25228,51 +25335,53 @@ function limitToLast(limit) {
|
|
|
25228
25335
|
return new QueryLimitConstraint('limitToLast', limit, "L" /* Last */);
|
|
25229
25336
|
}
|
|
25230
25337
|
class QueryStartAtConstraint extends QueryConstraint {
|
|
25231
|
-
constructor(type, _docOrFields,
|
|
25338
|
+
constructor(type, _docOrFields, _inclusive) {
|
|
25232
25339
|
super();
|
|
25233
25340
|
this.type = type;
|
|
25234
25341
|
this._docOrFields = _docOrFields;
|
|
25235
|
-
this.
|
|
25342
|
+
this._inclusive = _inclusive;
|
|
25236
25343
|
}
|
|
25237
25344
|
_apply(query) {
|
|
25238
|
-
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this.
|
|
25345
|
+
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
|
|
25239
25346
|
return new Query(query.firestore, query.converter, queryWithStartAt(query._query, bound));
|
|
25240
25347
|
}
|
|
25241
25348
|
}
|
|
25242
25349
|
function startAt(...docOrFields) {
|
|
25243
|
-
return new QueryStartAtConstraint('startAt', docOrFields,
|
|
25350
|
+
return new QueryStartAtConstraint('startAt', docOrFields,
|
|
25351
|
+
/*inclusive=*/ true);
|
|
25244
25352
|
}
|
|
25245
25353
|
function startAfter(...docOrFields) {
|
|
25246
25354
|
return new QueryStartAtConstraint('startAfter', docOrFields,
|
|
25247
|
-
/*
|
|
25355
|
+
/*inclusive=*/ false);
|
|
25248
25356
|
}
|
|
25249
25357
|
class QueryEndAtConstraint extends QueryConstraint {
|
|
25250
|
-
constructor(type, _docOrFields,
|
|
25358
|
+
constructor(type, _docOrFields, _inclusive) {
|
|
25251
25359
|
super();
|
|
25252
25360
|
this.type = type;
|
|
25253
25361
|
this._docOrFields = _docOrFields;
|
|
25254
|
-
this.
|
|
25362
|
+
this._inclusive = _inclusive;
|
|
25255
25363
|
}
|
|
25256
25364
|
_apply(query) {
|
|
25257
|
-
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this.
|
|
25365
|
+
const bound = newQueryBoundFromDocOrFields(query, this.type, this._docOrFields, this._inclusive);
|
|
25258
25366
|
return new Query(query.firestore, query.converter, queryWithEndAt(query._query, bound));
|
|
25259
25367
|
}
|
|
25260
25368
|
}
|
|
25261
25369
|
function endBefore(...docOrFields) {
|
|
25262
|
-
return new QueryEndAtConstraint('endBefore', docOrFields,
|
|
25370
|
+
return new QueryEndAtConstraint('endBefore', docOrFields,
|
|
25371
|
+
/*inclusive=*/ false);
|
|
25263
25372
|
}
|
|
25264
25373
|
function endAt(...docOrFields) {
|
|
25265
|
-
return new QueryEndAtConstraint('endAt', docOrFields, /*
|
|
25374
|
+
return new QueryEndAtConstraint('endAt', docOrFields, /*inclusive=*/ true);
|
|
25266
25375
|
}
|
|
25267
25376
|
/** Helper function to create a bound from a document or fields */
|
|
25268
|
-
function newQueryBoundFromDocOrFields(query, methodName, docOrFields,
|
|
25377
|
+
function newQueryBoundFromDocOrFields(query, methodName, docOrFields, inclusive) {
|
|
25269
25378
|
docOrFields[0] = getModularInstance(docOrFields[0]);
|
|
25270
25379
|
if (docOrFields[0] instanceof DocumentSnapshot$1) {
|
|
25271
|
-
return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document,
|
|
25380
|
+
return newQueryBoundFromDocument(query._query, query.firestore._databaseId, methodName, docOrFields[0]._document, inclusive);
|
|
25272
25381
|
}
|
|
25273
25382
|
else {
|
|
25274
25383
|
const reader = newUserDataReader(query.firestore);
|
|
25275
|
-
return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields,
|
|
25384
|
+
return newQueryBoundFromFields(query._query, query.firestore._databaseId, reader, methodName, docOrFields, inclusive);
|
|
25276
25385
|
}
|
|
25277
25386
|
}
|
|
25278
25387
|
function newQueryFilter(query, methodName, dataReader, databaseId, fieldPath, op, value) {
|
|
@@ -25330,7 +25439,7 @@ function newQueryOrderBy(query, fieldPath, direction) {
|
|
|
25330
25439
|
* of the query or if any of the fields in the order by are an uncommitted
|
|
25331
25440
|
* server timestamp.
|
|
25332
25441
|
*/
|
|
25333
|
-
function newQueryBoundFromDocument(query, databaseId, methodName, doc,
|
|
25442
|
+
function newQueryBoundFromDocument(query, databaseId, methodName, doc, inclusive) {
|
|
25334
25443
|
if (!doc) {
|
|
25335
25444
|
throw new FirestoreError(Code.NOT_FOUND, `Can't use a DocumentSnapshot that doesn't exist for ` +
|
|
25336
25445
|
`${methodName}().`);
|
|
@@ -25367,12 +25476,12 @@ function newQueryBoundFromDocument(query, databaseId, methodName, doc, before) {
|
|
|
25367
25476
|
}
|
|
25368
25477
|
}
|
|
25369
25478
|
}
|
|
25370
|
-
return new Bound(components,
|
|
25479
|
+
return new Bound(components, inclusive);
|
|
25371
25480
|
}
|
|
25372
25481
|
/**
|
|
25373
25482
|
* Converts a list of field values to a `Bound` for the given query.
|
|
25374
25483
|
*/
|
|
25375
|
-
function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values,
|
|
25484
|
+
function newQueryBoundFromFields(query, databaseId, dataReader, methodName, values, inclusive) {
|
|
25376
25485
|
// Use explicit order by's because it has to match the query the user made
|
|
25377
25486
|
const orderBy = query.explicitOrderBy;
|
|
25378
25487
|
if (values.length > orderBy.length) {
|
|
@@ -25409,7 +25518,7 @@ function newQueryBoundFromFields(query, databaseId, dataReader, methodName, valu
|
|
|
25409
25518
|
components.push(wrapped);
|
|
25410
25519
|
}
|
|
25411
25520
|
}
|
|
25412
|
-
return new Bound(components,
|
|
25521
|
+
return new Bound(components, inclusive);
|
|
25413
25522
|
}
|
|
25414
25523
|
/**
|
|
25415
25524
|
* Parses the given `documentIdValue` into a `ReferenceValue`, throwing
|