@firebase/firestore 3.4.4-canary.aaeab08ac → 3.4.4-canary.d04b608f2
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/{query.d.ts → filter.d.ts} +0 -0
- package/dist/firestore/src/api.d.ts +1 -1
- package/dist/firestore/src/core/database_info.d.ts +1 -0
- package/dist/firestore/src/core/target.d.ts +26 -1
- package/dist/firestore/src/model/field_index.d.ts +4 -0
- package/dist/firestore/src/model/values.d.ts +7 -0
- package/dist/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/firestore/test/util/helpers.d.ts +2 -2
- package/dist/index.esm2017.js +3253 -3249
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +3363 -3383
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +196 -192
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +196 -192
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +3253 -3249
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/lite/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/firestore/src/api.d.ts +1 -1
- package/dist/lite/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/firestore/src/core/target.d.ts +26 -1
- package/dist/lite/firestore/src/model/field_index.d.ts +4 -0
- package/dist/lite/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/firestore/test/util/helpers.d.ts +2 -2
- package/dist/lite/index.browser.esm2017.js +6 -2
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +45 -43
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +6 -2
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +6 -2
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +6 -2
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +1 -0
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +1 -0
- package/dist/lite/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -1
- package/dist/lite/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/target.d.ts +26 -1
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +4 -0
- package/dist/lite/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/lite/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +2 -2
- package/dist/packages/firestore/dist/index.esm2017.d.ts +182 -181
- package/dist/packages/firestore/src/api/{query.d.ts → filter.d.ts} +0 -0
- package/dist/packages/firestore/src/api.d.ts +1 -1
- package/dist/packages/firestore/src/core/database_info.d.ts +1 -0
- package/dist/packages/firestore/src/core/target.d.ts +26 -1
- package/dist/packages/firestore/src/model/field_index.d.ts +4 -0
- package/dist/packages/firestore/src/model/values.d.ts +7 -0
- package/dist/packages/firestore/test/unit/model/target.test.d.ts +17 -0
- package/dist/packages/firestore/test/util/helpers.d.ts +2 -2
- package/package.json +9 -9
package/dist/index.node.cjs.js
CHANGED
|
@@ -12,7 +12,7 @@ var grpcJs = require('@grpc/grpc-js');
|
|
|
12
12
|
var protoLoader = require('@grpc/proto-loader');
|
|
13
13
|
|
|
14
14
|
const name = "@firebase/firestore";
|
|
15
|
-
const version$1 = "3.4.4-canary.
|
|
15
|
+
const version$1 = "3.4.4-canary.d04b608f2";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @license
|
|
@@ -65,7 +65,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
|
|
|
65
65
|
User.FIRST_PARTY = new User('first-party-uid');
|
|
66
66
|
User.MOCK_USER = new User('mock-user');
|
|
67
67
|
|
|
68
|
-
const version = "9.6.5-canary.
|
|
68
|
+
const version = "9.6.5-canary.d04b608f2";
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* @license
|
|
@@ -3378,6 +3378,75 @@ function getLocalWriteTime(value) {
|
|
|
3378
3378
|
return new Timestamp(localWriteTime.seconds, localWriteTime.nanos);
|
|
3379
3379
|
}
|
|
3380
3380
|
|
|
3381
|
+
/**
|
|
3382
|
+
* @license
|
|
3383
|
+
* Copyright 2017 Google LLC
|
|
3384
|
+
*
|
|
3385
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3386
|
+
* you may not use this file except in compliance with the License.
|
|
3387
|
+
* You may obtain a copy of the License at
|
|
3388
|
+
*
|
|
3389
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3390
|
+
*
|
|
3391
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3392
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3393
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3394
|
+
* See the License for the specific language governing permissions and
|
|
3395
|
+
* limitations under the License.
|
|
3396
|
+
*/
|
|
3397
|
+
class DatabaseInfo {
|
|
3398
|
+
/**
|
|
3399
|
+
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
3400
|
+
* persistenceKey.
|
|
3401
|
+
*
|
|
3402
|
+
* @param databaseId - The database to use.
|
|
3403
|
+
* @param appId - The Firebase App Id.
|
|
3404
|
+
* @param persistenceKey - A unique identifier for this Firestore's local
|
|
3405
|
+
* storage (used in conjunction with the databaseId).
|
|
3406
|
+
* @param host - The Firestore backend host to connect to.
|
|
3407
|
+
* @param ssl - Whether to use SSL when connecting.
|
|
3408
|
+
* @param forceLongPolling - Whether to use the forceLongPolling option
|
|
3409
|
+
* when using WebChannel as the network transport.
|
|
3410
|
+
* @param autoDetectLongPolling - Whether to use the detectBufferingProxy
|
|
3411
|
+
* option when using WebChannel as the network transport.
|
|
3412
|
+
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
3413
|
+
* XMLHTTPRequest
|
|
3414
|
+
*/
|
|
3415
|
+
constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
|
|
3416
|
+
this.databaseId = databaseId;
|
|
3417
|
+
this.appId = appId;
|
|
3418
|
+
this.persistenceKey = persistenceKey;
|
|
3419
|
+
this.host = host;
|
|
3420
|
+
this.ssl = ssl;
|
|
3421
|
+
this.forceLongPolling = forceLongPolling;
|
|
3422
|
+
this.autoDetectLongPolling = autoDetectLongPolling;
|
|
3423
|
+
this.useFetchStreams = useFetchStreams;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
/** The default database name for a project. */
|
|
3427
|
+
const DEFAULT_DATABASE_NAME = '(default)';
|
|
3428
|
+
/**
|
|
3429
|
+
* Represents the database ID a Firestore client is associated with.
|
|
3430
|
+
* @internal
|
|
3431
|
+
*/
|
|
3432
|
+
class DatabaseId {
|
|
3433
|
+
constructor(projectId, database) {
|
|
3434
|
+
this.projectId = projectId;
|
|
3435
|
+
this.database = database ? database : DEFAULT_DATABASE_NAME;
|
|
3436
|
+
}
|
|
3437
|
+
static empty() {
|
|
3438
|
+
return new DatabaseId('', '');
|
|
3439
|
+
}
|
|
3440
|
+
get isDefaultDatabase() {
|
|
3441
|
+
return this.database === DEFAULT_DATABASE_NAME;
|
|
3442
|
+
}
|
|
3443
|
+
isEqual(other) {
|
|
3444
|
+
return (other instanceof DatabaseId &&
|
|
3445
|
+
other.projectId === this.projectId &&
|
|
3446
|
+
other.database === this.database);
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3381
3450
|
/**
|
|
3382
3451
|
* @license
|
|
3383
3452
|
* Copyright 2017 Google LLC
|
|
@@ -4233,6 +4302,125 @@ function compareDocumentsByField(field, d1, d2) {
|
|
|
4233
4302
|
}
|
|
4234
4303
|
}
|
|
4235
4304
|
|
|
4305
|
+
/**
|
|
4306
|
+
* @license
|
|
4307
|
+
* Copyright 2021 Google LLC
|
|
4308
|
+
*
|
|
4309
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4310
|
+
* you may not use this file except in compliance with the License.
|
|
4311
|
+
* You may obtain a copy of the License at
|
|
4312
|
+
*
|
|
4313
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4314
|
+
*
|
|
4315
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4316
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4317
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4318
|
+
* See the License for the specific language governing permissions and
|
|
4319
|
+
* limitations under the License.
|
|
4320
|
+
*/
|
|
4321
|
+
/**
|
|
4322
|
+
* The initial mutation batch id for each index. Gets updated during index
|
|
4323
|
+
* backfill.
|
|
4324
|
+
*/
|
|
4325
|
+
const INITIAL_LARGEST_BATCH_ID = -1;
|
|
4326
|
+
/**
|
|
4327
|
+
* The initial sequence number for each index. Gets updated during index
|
|
4328
|
+
* backfill.
|
|
4329
|
+
*/
|
|
4330
|
+
const INITIAL_SEQUENCE_NUMBER = 0;
|
|
4331
|
+
/**
|
|
4332
|
+
* An index definition for field indexes in Firestore.
|
|
4333
|
+
*
|
|
4334
|
+
* Every index is associated with a collection. The definition contains a list
|
|
4335
|
+
* of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
|
|
4336
|
+
* `CONTAINS` for ArrayContains/ArrayContainsAny queries).
|
|
4337
|
+
*
|
|
4338
|
+
* Unlike the backend, the SDK does not differentiate between collection or
|
|
4339
|
+
* collection group-scoped indices. Every index can be used for both single
|
|
4340
|
+
* collection and collection group queries.
|
|
4341
|
+
*/
|
|
4342
|
+
class FieldIndex {
|
|
4343
|
+
constructor(
|
|
4344
|
+
/**
|
|
4345
|
+
* The index ID. Returns -1 if the index ID is not available (e.g. the index
|
|
4346
|
+
* has not yet been persisted).
|
|
4347
|
+
*/
|
|
4348
|
+
indexId,
|
|
4349
|
+
/** The collection ID this index applies to. */
|
|
4350
|
+
collectionGroup,
|
|
4351
|
+
/** The field segments for this index. */
|
|
4352
|
+
segments,
|
|
4353
|
+
/** Shows how up-to-date the index is for the current user. */
|
|
4354
|
+
indexState) {
|
|
4355
|
+
this.indexId = indexId;
|
|
4356
|
+
this.collectionGroup = collectionGroup;
|
|
4357
|
+
this.segments = segments;
|
|
4358
|
+
this.indexState = indexState;
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
/** An ID for an index that has not yet been added to persistence. */
|
|
4362
|
+
FieldIndex.UNKNOWN_ID = -1;
|
|
4363
|
+
/** An index component consisting of field path and index type. */
|
|
4364
|
+
class IndexSegment {
|
|
4365
|
+
constructor(
|
|
4366
|
+
/** The field path of the component. */
|
|
4367
|
+
fieldPath,
|
|
4368
|
+
/** The fields sorting order. */
|
|
4369
|
+
kind) {
|
|
4370
|
+
this.fieldPath = fieldPath;
|
|
4371
|
+
this.kind = kind;
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
/**
|
|
4375
|
+
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
4376
|
+
* current user.
|
|
4377
|
+
*/
|
|
4378
|
+
class IndexState {
|
|
4379
|
+
constructor(
|
|
4380
|
+
/**
|
|
4381
|
+
* Indicates when the index was last updated (relative to other indexes).
|
|
4382
|
+
*/
|
|
4383
|
+
sequenceNumber,
|
|
4384
|
+
/** The the latest indexed read time, document and batch id. */
|
|
4385
|
+
offset) {
|
|
4386
|
+
this.sequenceNumber = sequenceNumber;
|
|
4387
|
+
this.offset = offset;
|
|
4388
|
+
}
|
|
4389
|
+
/** The state of an index that has not yet been backfilled. */
|
|
4390
|
+
static empty() {
|
|
4391
|
+
return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
/**
|
|
4395
|
+
* Stores the latest read time, document and batch ID that were processed for an
|
|
4396
|
+
* index.
|
|
4397
|
+
*/
|
|
4398
|
+
class IndexOffset {
|
|
4399
|
+
constructor(
|
|
4400
|
+
/**
|
|
4401
|
+
* The latest read time version that has been indexed by Firestore for this
|
|
4402
|
+
* field index.
|
|
4403
|
+
*/
|
|
4404
|
+
readTime,
|
|
4405
|
+
/**
|
|
4406
|
+
* The key of the last document that was indexed for this query. Use
|
|
4407
|
+
* `DocumentKey.empty()` if no document has been indexed.
|
|
4408
|
+
*/
|
|
4409
|
+
documentKey,
|
|
4410
|
+
/*
|
|
4411
|
+
* The largest mutation batch id that's been processed by Firestore.
|
|
4412
|
+
*/
|
|
4413
|
+
largestBatchId) {
|
|
4414
|
+
this.readTime = readTime;
|
|
4415
|
+
this.documentKey = documentKey;
|
|
4416
|
+
this.largestBatchId = largestBatchId;
|
|
4417
|
+
}
|
|
4418
|
+
/** The state of an index that has not yet been backfilled. */
|
|
4419
|
+
static min() {
|
|
4420
|
+
return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
|
|
4236
4424
|
/**
|
|
4237
4425
|
* @license
|
|
4238
4426
|
* Copyright 2019 Google LLC
|
|
@@ -4357,7 +4545,7 @@ function targetEquals(left, right) {
|
|
|
4357
4545
|
}
|
|
4358
4546
|
return boundEquals(left.endAt, right.endAt);
|
|
4359
4547
|
}
|
|
4360
|
-
function
|
|
4548
|
+
function targetIsDocumentTarget(target) {
|
|
4361
4549
|
return (DocumentKey.isDocumentKey(target.path) &&
|
|
4362
4550
|
target.collectionGroup === null &&
|
|
4363
4551
|
target.filters.length === 0);
|
|
@@ -4545,6 +4733,7 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4545
4733
|
return other.arrayValue.values.some(val => arrayValueContains(this.value.arrayValue, val));
|
|
4546
4734
|
}
|
|
4547
4735
|
}
|
|
4736
|
+
// TODO(indexing): Change Bound.before to "inclusive"
|
|
4548
4737
|
/**
|
|
4549
4738
|
* Represents a bound of a query.
|
|
4550
4739
|
*
|
|
@@ -7002,7 +7191,7 @@ class WatchChangeAggregator {
|
|
|
7002
7191
|
const targetData = this.targetDataForActiveTarget(targetId);
|
|
7003
7192
|
if (targetData) {
|
|
7004
7193
|
const target = targetData.target;
|
|
7005
|
-
if (
|
|
7194
|
+
if (targetIsDocumentTarget(target)) {
|
|
7006
7195
|
if (expectedCount === 0) {
|
|
7007
7196
|
// The existence filter told us the document does not exist. We deduce
|
|
7008
7197
|
// that this document does not exist and apply a deleted document to
|
|
@@ -7037,7 +7226,7 @@ class WatchChangeAggregator {
|
|
|
7037
7226
|
this.targetStates.forEach((targetState, targetId) => {
|
|
7038
7227
|
const targetData = this.targetDataForActiveTarget(targetId);
|
|
7039
7228
|
if (targetData) {
|
|
7040
|
-
if (targetState.current &&
|
|
7229
|
+
if (targetState.current && targetIsDocumentTarget(targetData.target)) {
|
|
7041
7230
|
// Document queries for document that don't exist can produce an empty
|
|
7042
7231
|
// result set. To update our local cache, we synthesize a document
|
|
7043
7232
|
// delete if we have not previously received the document. This
|
|
@@ -7873,7 +8062,7 @@ function toLabel(serializer, purpose) {
|
|
|
7873
8062
|
function toTarget(serializer, targetData) {
|
|
7874
8063
|
let result;
|
|
7875
8064
|
const target = targetData.target;
|
|
7876
|
-
if (
|
|
8065
|
+
if (targetIsDocumentTarget(target)) {
|
|
7877
8066
|
result = { documents: toDocumentsTarget(serializer, target) };
|
|
7878
8067
|
}
|
|
7879
8068
|
else {
|
|
@@ -8323,7 +8512,7 @@ function toDbTarget(localSerializer, targetData) {
|
|
|
8323
8512
|
const dbTimestamp = toDbTimestamp(targetData.snapshotVersion);
|
|
8324
8513
|
const dbLastLimboFreeTimestamp = toDbTimestamp(targetData.lastLimboFreeSnapshotVersion);
|
|
8325
8514
|
let queryProto;
|
|
8326
|
-
if (
|
|
8515
|
+
if (targetIsDocumentTarget(targetData.target)) {
|
|
8327
8516
|
queryProto = toDocumentsTarget(localSerializer.remoteSerializer, targetData.target);
|
|
8328
8517
|
}
|
|
8329
8518
|
else {
|
|
@@ -22295,72 +22484,6 @@ function createBundleReader(data, serializer) {
|
|
|
22295
22484
|
return newBundleReader(toByteStreamReader(content), serializer);
|
|
22296
22485
|
}
|
|
22297
22486
|
|
|
22298
|
-
/**
|
|
22299
|
-
* @license
|
|
22300
|
-
* Copyright 2017 Google LLC
|
|
22301
|
-
*
|
|
22302
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22303
|
-
* you may not use this file except in compliance with the License.
|
|
22304
|
-
* You may obtain a copy of the License at
|
|
22305
|
-
*
|
|
22306
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22307
|
-
*
|
|
22308
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
22309
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22310
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22311
|
-
* See the License for the specific language governing permissions and
|
|
22312
|
-
* limitations under the License.
|
|
22313
|
-
*/
|
|
22314
|
-
class DatabaseInfo {
|
|
22315
|
-
/**
|
|
22316
|
-
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
22317
|
-
* persistenceKey.
|
|
22318
|
-
*
|
|
22319
|
-
* @param databaseId - The database to use.
|
|
22320
|
-
* @param appId - The Firebase App Id.
|
|
22321
|
-
* @param persistenceKey - A unique identifier for this Firestore's local
|
|
22322
|
-
* storage (used in conjunction with the databaseId).
|
|
22323
|
-
* @param host - The Firestore backend host to connect to.
|
|
22324
|
-
* @param ssl - Whether to use SSL when connecting.
|
|
22325
|
-
* @param forceLongPolling - Whether to use the forceLongPolling option
|
|
22326
|
-
* when using WebChannel as the network transport.
|
|
22327
|
-
* @param autoDetectLongPolling - Whether to use the detectBufferingProxy
|
|
22328
|
-
* option when using WebChannel as the network transport.
|
|
22329
|
-
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
22330
|
-
* XMLHTTPRequest
|
|
22331
|
-
*/
|
|
22332
|
-
constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
|
|
22333
|
-
this.databaseId = databaseId;
|
|
22334
|
-
this.appId = appId;
|
|
22335
|
-
this.persistenceKey = persistenceKey;
|
|
22336
|
-
this.host = host;
|
|
22337
|
-
this.ssl = ssl;
|
|
22338
|
-
this.forceLongPolling = forceLongPolling;
|
|
22339
|
-
this.autoDetectLongPolling = autoDetectLongPolling;
|
|
22340
|
-
this.useFetchStreams = useFetchStreams;
|
|
22341
|
-
}
|
|
22342
|
-
}
|
|
22343
|
-
/** The default database name for a project. */
|
|
22344
|
-
const DEFAULT_DATABASE_NAME = '(default)';
|
|
22345
|
-
/**
|
|
22346
|
-
* Represents the database ID a Firestore client is associated with.
|
|
22347
|
-
* @internal
|
|
22348
|
-
*/
|
|
22349
|
-
class DatabaseId {
|
|
22350
|
-
constructor(projectId, database) {
|
|
22351
|
-
this.projectId = projectId;
|
|
22352
|
-
this.database = database ? database : DEFAULT_DATABASE_NAME;
|
|
22353
|
-
}
|
|
22354
|
-
get isDefaultDatabase() {
|
|
22355
|
-
return this.database === DEFAULT_DATABASE_NAME;
|
|
22356
|
-
}
|
|
22357
|
-
isEqual(other) {
|
|
22358
|
-
return (other instanceof DatabaseId &&
|
|
22359
|
-
other.projectId === this.projectId &&
|
|
22360
|
-
other.database === this.database);
|
|
22361
|
-
}
|
|
22362
|
-
}
|
|
22363
|
-
|
|
22364
22487
|
/**
|
|
22365
22488
|
* @license
|
|
22366
22489
|
* Copyright 2020 Google LLC
|
|
@@ -26275,125 +26398,6 @@ function writeBatch(firestore) {
|
|
|
26275
26398
|
return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations));
|
|
26276
26399
|
}
|
|
26277
26400
|
|
|
26278
|
-
/**
|
|
26279
|
-
* @license
|
|
26280
|
-
* Copyright 2021 Google LLC
|
|
26281
|
-
*
|
|
26282
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26283
|
-
* you may not use this file except in compliance with the License.
|
|
26284
|
-
* You may obtain a copy of the License at
|
|
26285
|
-
*
|
|
26286
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26287
|
-
*
|
|
26288
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
26289
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26290
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26291
|
-
* See the License for the specific language governing permissions and
|
|
26292
|
-
* limitations under the License.
|
|
26293
|
-
*/
|
|
26294
|
-
/**
|
|
26295
|
-
* The initial mutation batch id for each index. Gets updated during index
|
|
26296
|
-
* backfill.
|
|
26297
|
-
*/
|
|
26298
|
-
const INITIAL_LARGEST_BATCH_ID = -1;
|
|
26299
|
-
/**
|
|
26300
|
-
* The initial sequence number for each index. Gets updated during index
|
|
26301
|
-
* backfill.
|
|
26302
|
-
*/
|
|
26303
|
-
const INITIAL_SEQUENCE_NUMBER = 0;
|
|
26304
|
-
/**
|
|
26305
|
-
* An index definition for field indexes in Firestore.
|
|
26306
|
-
*
|
|
26307
|
-
* Every index is associated with a collection. The definition contains a list
|
|
26308
|
-
* of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
|
|
26309
|
-
* `CONTAINS` for ArrayContains/ArrayContainsAny queries).
|
|
26310
|
-
*
|
|
26311
|
-
* Unlike the backend, the SDK does not differentiate between collection or
|
|
26312
|
-
* collection group-scoped indices. Every index can be used for both single
|
|
26313
|
-
* collection and collection group queries.
|
|
26314
|
-
*/
|
|
26315
|
-
class FieldIndex {
|
|
26316
|
-
constructor(
|
|
26317
|
-
/**
|
|
26318
|
-
* The index ID. Returns -1 if the index ID is not available (e.g. the index
|
|
26319
|
-
* has not yet been persisted).
|
|
26320
|
-
*/
|
|
26321
|
-
indexId,
|
|
26322
|
-
/** The collection ID this index applies to. */
|
|
26323
|
-
collectionGroup,
|
|
26324
|
-
/** The field segments for this index. */
|
|
26325
|
-
segments,
|
|
26326
|
-
/** Shows how up-to-date the index is for the current user. */
|
|
26327
|
-
indexState) {
|
|
26328
|
-
this.indexId = indexId;
|
|
26329
|
-
this.collectionGroup = collectionGroup;
|
|
26330
|
-
this.segments = segments;
|
|
26331
|
-
this.indexState = indexState;
|
|
26332
|
-
}
|
|
26333
|
-
}
|
|
26334
|
-
/** An ID for an index that has not yet been added to persistence. */
|
|
26335
|
-
FieldIndex.UNKNOWN_ID = -1;
|
|
26336
|
-
/** An index component consisting of field path and index type. */
|
|
26337
|
-
class IndexSegment {
|
|
26338
|
-
constructor(
|
|
26339
|
-
/** The field path of the component. */
|
|
26340
|
-
fieldPath,
|
|
26341
|
-
/** The fields sorting order. */
|
|
26342
|
-
kind) {
|
|
26343
|
-
this.fieldPath = fieldPath;
|
|
26344
|
-
this.kind = kind;
|
|
26345
|
-
}
|
|
26346
|
-
}
|
|
26347
|
-
/**
|
|
26348
|
-
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
26349
|
-
* current user.
|
|
26350
|
-
*/
|
|
26351
|
-
class IndexState {
|
|
26352
|
-
constructor(
|
|
26353
|
-
/**
|
|
26354
|
-
* Indicates when the index was last updated (relative to other indexes).
|
|
26355
|
-
*/
|
|
26356
|
-
sequenceNumber,
|
|
26357
|
-
/** The the latest indexed read time, document and batch id. */
|
|
26358
|
-
offset) {
|
|
26359
|
-
this.sequenceNumber = sequenceNumber;
|
|
26360
|
-
this.offset = offset;
|
|
26361
|
-
}
|
|
26362
|
-
/** The state of an index that has not yet been backfilled. */
|
|
26363
|
-
static empty() {
|
|
26364
|
-
return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
|
|
26365
|
-
}
|
|
26366
|
-
}
|
|
26367
|
-
/**
|
|
26368
|
-
* Stores the latest read time, document and batch ID that were processed for an
|
|
26369
|
-
* index.
|
|
26370
|
-
*/
|
|
26371
|
-
class IndexOffset {
|
|
26372
|
-
constructor(
|
|
26373
|
-
/**
|
|
26374
|
-
* The latest read time version that has been indexed by Firestore for this
|
|
26375
|
-
* field index.
|
|
26376
|
-
*/
|
|
26377
|
-
readTime,
|
|
26378
|
-
/**
|
|
26379
|
-
* The key of the last document that was indexed for this query. Use
|
|
26380
|
-
* `DocumentKey.empty()` if no document has been indexed.
|
|
26381
|
-
*/
|
|
26382
|
-
documentKey,
|
|
26383
|
-
/*
|
|
26384
|
-
* The largest mutation batch id that's been processed by Firestore.
|
|
26385
|
-
*/
|
|
26386
|
-
largestBatchId) {
|
|
26387
|
-
this.readTime = readTime;
|
|
26388
|
-
this.documentKey = documentKey;
|
|
26389
|
-
this.largestBatchId = largestBatchId;
|
|
26390
|
-
}
|
|
26391
|
-
/** The state of an index that has not yet been backfilled. */
|
|
26392
|
-
static min() {
|
|
26393
|
-
return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
|
|
26394
|
-
}
|
|
26395
|
-
}
|
|
26396
|
-
|
|
26397
26401
|
/**
|
|
26398
26402
|
* @license
|
|
26399
26403
|
* Copyright 2021 Google LLC
|