@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.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.d04b608f2";
|
|
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.d04b608f2";
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @license
|
|
@@ -3374,6 +3374,75 @@ function getLocalWriteTime(value) {
|
|
|
3374
3374
|
return new Timestamp(localWriteTime.seconds, localWriteTime.nanos);
|
|
3375
3375
|
}
|
|
3376
3376
|
|
|
3377
|
+
/**
|
|
3378
|
+
* @license
|
|
3379
|
+
* Copyright 2017 Google LLC
|
|
3380
|
+
*
|
|
3381
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3382
|
+
* you may not use this file except in compliance with the License.
|
|
3383
|
+
* You may obtain a copy of the License at
|
|
3384
|
+
*
|
|
3385
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3386
|
+
*
|
|
3387
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3388
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3389
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3390
|
+
* See the License for the specific language governing permissions and
|
|
3391
|
+
* limitations under the License.
|
|
3392
|
+
*/
|
|
3393
|
+
class DatabaseInfo {
|
|
3394
|
+
/**
|
|
3395
|
+
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
3396
|
+
* persistenceKey.
|
|
3397
|
+
*
|
|
3398
|
+
* @param databaseId - The database to use.
|
|
3399
|
+
* @param appId - The Firebase App Id.
|
|
3400
|
+
* @param persistenceKey - A unique identifier for this Firestore's local
|
|
3401
|
+
* storage (used in conjunction with the databaseId).
|
|
3402
|
+
* @param host - The Firestore backend host to connect to.
|
|
3403
|
+
* @param ssl - Whether to use SSL when connecting.
|
|
3404
|
+
* @param forceLongPolling - Whether to use the forceLongPolling option
|
|
3405
|
+
* when using WebChannel as the network transport.
|
|
3406
|
+
* @param autoDetectLongPolling - Whether to use the detectBufferingProxy
|
|
3407
|
+
* option when using WebChannel as the network transport.
|
|
3408
|
+
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
3409
|
+
* XMLHTTPRequest
|
|
3410
|
+
*/
|
|
3411
|
+
constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
|
|
3412
|
+
this.databaseId = databaseId;
|
|
3413
|
+
this.appId = appId;
|
|
3414
|
+
this.persistenceKey = persistenceKey;
|
|
3415
|
+
this.host = host;
|
|
3416
|
+
this.ssl = ssl;
|
|
3417
|
+
this.forceLongPolling = forceLongPolling;
|
|
3418
|
+
this.autoDetectLongPolling = autoDetectLongPolling;
|
|
3419
|
+
this.useFetchStreams = useFetchStreams;
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
/** The default database name for a project. */
|
|
3423
|
+
const DEFAULT_DATABASE_NAME = '(default)';
|
|
3424
|
+
/**
|
|
3425
|
+
* Represents the database ID a Firestore client is associated with.
|
|
3426
|
+
* @internal
|
|
3427
|
+
*/
|
|
3428
|
+
class DatabaseId {
|
|
3429
|
+
constructor(projectId, database) {
|
|
3430
|
+
this.projectId = projectId;
|
|
3431
|
+
this.database = database ? database : DEFAULT_DATABASE_NAME;
|
|
3432
|
+
}
|
|
3433
|
+
static empty() {
|
|
3434
|
+
return new DatabaseId('', '');
|
|
3435
|
+
}
|
|
3436
|
+
get isDefaultDatabase() {
|
|
3437
|
+
return this.database === DEFAULT_DATABASE_NAME;
|
|
3438
|
+
}
|
|
3439
|
+
isEqual(other) {
|
|
3440
|
+
return (other instanceof DatabaseId &&
|
|
3441
|
+
other.projectId === this.projectId &&
|
|
3442
|
+
other.database === this.database);
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3377
3446
|
/**
|
|
3378
3447
|
* @license
|
|
3379
3448
|
* Copyright 2017 Google LLC
|
|
@@ -4229,6 +4298,125 @@ function compareDocumentsByField(field, d1, d2) {
|
|
|
4229
4298
|
}
|
|
4230
4299
|
}
|
|
4231
4300
|
|
|
4301
|
+
/**
|
|
4302
|
+
* @license
|
|
4303
|
+
* Copyright 2021 Google LLC
|
|
4304
|
+
*
|
|
4305
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4306
|
+
* you may not use this file except in compliance with the License.
|
|
4307
|
+
* You may obtain a copy of the License at
|
|
4308
|
+
*
|
|
4309
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4310
|
+
*
|
|
4311
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4312
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4313
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4314
|
+
* See the License for the specific language governing permissions and
|
|
4315
|
+
* limitations under the License.
|
|
4316
|
+
*/
|
|
4317
|
+
/**
|
|
4318
|
+
* The initial mutation batch id for each index. Gets updated during index
|
|
4319
|
+
* backfill.
|
|
4320
|
+
*/
|
|
4321
|
+
const INITIAL_LARGEST_BATCH_ID = -1;
|
|
4322
|
+
/**
|
|
4323
|
+
* The initial sequence number for each index. Gets updated during index
|
|
4324
|
+
* backfill.
|
|
4325
|
+
*/
|
|
4326
|
+
const INITIAL_SEQUENCE_NUMBER = 0;
|
|
4327
|
+
/**
|
|
4328
|
+
* An index definition for field indexes in Firestore.
|
|
4329
|
+
*
|
|
4330
|
+
* Every index is associated with a collection. The definition contains a list
|
|
4331
|
+
* of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
|
|
4332
|
+
* `CONTAINS` for ArrayContains/ArrayContainsAny queries).
|
|
4333
|
+
*
|
|
4334
|
+
* Unlike the backend, the SDK does not differentiate between collection or
|
|
4335
|
+
* collection group-scoped indices. Every index can be used for both single
|
|
4336
|
+
* collection and collection group queries.
|
|
4337
|
+
*/
|
|
4338
|
+
class FieldIndex {
|
|
4339
|
+
constructor(
|
|
4340
|
+
/**
|
|
4341
|
+
* The index ID. Returns -1 if the index ID is not available (e.g. the index
|
|
4342
|
+
* has not yet been persisted).
|
|
4343
|
+
*/
|
|
4344
|
+
indexId,
|
|
4345
|
+
/** The collection ID this index applies to. */
|
|
4346
|
+
collectionGroup,
|
|
4347
|
+
/** The field segments for this index. */
|
|
4348
|
+
segments,
|
|
4349
|
+
/** Shows how up-to-date the index is for the current user. */
|
|
4350
|
+
indexState) {
|
|
4351
|
+
this.indexId = indexId;
|
|
4352
|
+
this.collectionGroup = collectionGroup;
|
|
4353
|
+
this.segments = segments;
|
|
4354
|
+
this.indexState = indexState;
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
/** An ID for an index that has not yet been added to persistence. */
|
|
4358
|
+
FieldIndex.UNKNOWN_ID = -1;
|
|
4359
|
+
/** An index component consisting of field path and index type. */
|
|
4360
|
+
class IndexSegment {
|
|
4361
|
+
constructor(
|
|
4362
|
+
/** The field path of the component. */
|
|
4363
|
+
fieldPath,
|
|
4364
|
+
/** The fields sorting order. */
|
|
4365
|
+
kind) {
|
|
4366
|
+
this.fieldPath = fieldPath;
|
|
4367
|
+
this.kind = kind;
|
|
4368
|
+
}
|
|
4369
|
+
}
|
|
4370
|
+
/**
|
|
4371
|
+
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
4372
|
+
* current user.
|
|
4373
|
+
*/
|
|
4374
|
+
class IndexState {
|
|
4375
|
+
constructor(
|
|
4376
|
+
/**
|
|
4377
|
+
* Indicates when the index was last updated (relative to other indexes).
|
|
4378
|
+
*/
|
|
4379
|
+
sequenceNumber,
|
|
4380
|
+
/** The the latest indexed read time, document and batch id. */
|
|
4381
|
+
offset) {
|
|
4382
|
+
this.sequenceNumber = sequenceNumber;
|
|
4383
|
+
this.offset = offset;
|
|
4384
|
+
}
|
|
4385
|
+
/** The state of an index that has not yet been backfilled. */
|
|
4386
|
+
static empty() {
|
|
4387
|
+
return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
/**
|
|
4391
|
+
* Stores the latest read time, document and batch ID that were processed for an
|
|
4392
|
+
* index.
|
|
4393
|
+
*/
|
|
4394
|
+
class IndexOffset {
|
|
4395
|
+
constructor(
|
|
4396
|
+
/**
|
|
4397
|
+
* The latest read time version that has been indexed by Firestore for this
|
|
4398
|
+
* field index.
|
|
4399
|
+
*/
|
|
4400
|
+
readTime,
|
|
4401
|
+
/**
|
|
4402
|
+
* The key of the last document that was indexed for this query. Use
|
|
4403
|
+
* `DocumentKey.empty()` if no document has been indexed.
|
|
4404
|
+
*/
|
|
4405
|
+
documentKey,
|
|
4406
|
+
/*
|
|
4407
|
+
* The largest mutation batch id that's been processed by Firestore.
|
|
4408
|
+
*/
|
|
4409
|
+
largestBatchId) {
|
|
4410
|
+
this.readTime = readTime;
|
|
4411
|
+
this.documentKey = documentKey;
|
|
4412
|
+
this.largestBatchId = largestBatchId;
|
|
4413
|
+
}
|
|
4414
|
+
/** The state of an index that has not yet been backfilled. */
|
|
4415
|
+
static min() {
|
|
4416
|
+
return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
|
|
4417
|
+
}
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4232
4420
|
/**
|
|
4233
4421
|
* @license
|
|
4234
4422
|
* Copyright 2019 Google LLC
|
|
@@ -4353,7 +4541,7 @@ function targetEquals(left, right) {
|
|
|
4353
4541
|
}
|
|
4354
4542
|
return boundEquals(left.endAt, right.endAt);
|
|
4355
4543
|
}
|
|
4356
|
-
function
|
|
4544
|
+
function targetIsDocumentTarget(target) {
|
|
4357
4545
|
return (DocumentKey.isDocumentKey(target.path) &&
|
|
4358
4546
|
target.collectionGroup === null &&
|
|
4359
4547
|
target.filters.length === 0);
|
|
@@ -4541,6 +4729,7 @@ class ArrayContainsAnyFilter extends FieldFilter {
|
|
|
4541
4729
|
return other.arrayValue.values.some(val => arrayValueContains(this.value.arrayValue, val));
|
|
4542
4730
|
}
|
|
4543
4731
|
}
|
|
4732
|
+
// TODO(indexing): Change Bound.before to "inclusive"
|
|
4544
4733
|
/**
|
|
4545
4734
|
* Represents a bound of a query.
|
|
4546
4735
|
*
|
|
@@ -6998,7 +7187,7 @@ class WatchChangeAggregator {
|
|
|
6998
7187
|
const targetData = this.targetDataForActiveTarget(targetId);
|
|
6999
7188
|
if (targetData) {
|
|
7000
7189
|
const target = targetData.target;
|
|
7001
|
-
if (
|
|
7190
|
+
if (targetIsDocumentTarget(target)) {
|
|
7002
7191
|
if (expectedCount === 0) {
|
|
7003
7192
|
// The existence filter told us the document does not exist. We deduce
|
|
7004
7193
|
// that this document does not exist and apply a deleted document to
|
|
@@ -7033,7 +7222,7 @@ class WatchChangeAggregator {
|
|
|
7033
7222
|
this.targetStates.forEach((targetState, targetId) => {
|
|
7034
7223
|
const targetData = this.targetDataForActiveTarget(targetId);
|
|
7035
7224
|
if (targetData) {
|
|
7036
|
-
if (targetState.current &&
|
|
7225
|
+
if (targetState.current && targetIsDocumentTarget(targetData.target)) {
|
|
7037
7226
|
// Document queries for document that don't exist can produce an empty
|
|
7038
7227
|
// result set. To update our local cache, we synthesize a document
|
|
7039
7228
|
// delete if we have not previously received the document. This
|
|
@@ -7869,7 +8058,7 @@ function toLabel(serializer, purpose) {
|
|
|
7869
8058
|
function toTarget(serializer, targetData) {
|
|
7870
8059
|
let result;
|
|
7871
8060
|
const target = targetData.target;
|
|
7872
|
-
if (
|
|
8061
|
+
if (targetIsDocumentTarget(target)) {
|
|
7873
8062
|
result = { documents: toDocumentsTarget(serializer, target) };
|
|
7874
8063
|
}
|
|
7875
8064
|
else {
|
|
@@ -8319,7 +8508,7 @@ function toDbTarget(localSerializer, targetData) {
|
|
|
8319
8508
|
const dbTimestamp = toDbTimestamp(targetData.snapshotVersion);
|
|
8320
8509
|
const dbLastLimboFreeTimestamp = toDbTimestamp(targetData.lastLimboFreeSnapshotVersion);
|
|
8321
8510
|
let queryProto;
|
|
8322
|
-
if (
|
|
8511
|
+
if (targetIsDocumentTarget(targetData.target)) {
|
|
8323
8512
|
queryProto = toDocumentsTarget(localSerializer.remoteSerializer, targetData.target);
|
|
8324
8513
|
}
|
|
8325
8514
|
else {
|
|
@@ -22291,72 +22480,6 @@ function createBundleReader(data, serializer) {
|
|
|
22291
22480
|
return newBundleReader(toByteStreamReader(content), serializer);
|
|
22292
22481
|
}
|
|
22293
22482
|
|
|
22294
|
-
/**
|
|
22295
|
-
* @license
|
|
22296
|
-
* Copyright 2017 Google LLC
|
|
22297
|
-
*
|
|
22298
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22299
|
-
* you may not use this file except in compliance with the License.
|
|
22300
|
-
* You may obtain a copy of the License at
|
|
22301
|
-
*
|
|
22302
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22303
|
-
*
|
|
22304
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
22305
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22306
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22307
|
-
* See the License for the specific language governing permissions and
|
|
22308
|
-
* limitations under the License.
|
|
22309
|
-
*/
|
|
22310
|
-
class DatabaseInfo {
|
|
22311
|
-
/**
|
|
22312
|
-
* Constructs a DatabaseInfo using the provided host, databaseId and
|
|
22313
|
-
* persistenceKey.
|
|
22314
|
-
*
|
|
22315
|
-
* @param databaseId - The database to use.
|
|
22316
|
-
* @param appId - The Firebase App Id.
|
|
22317
|
-
* @param persistenceKey - A unique identifier for this Firestore's local
|
|
22318
|
-
* storage (used in conjunction with the databaseId).
|
|
22319
|
-
* @param host - The Firestore backend host to connect to.
|
|
22320
|
-
* @param ssl - Whether to use SSL when connecting.
|
|
22321
|
-
* @param forceLongPolling - Whether to use the forceLongPolling option
|
|
22322
|
-
* when using WebChannel as the network transport.
|
|
22323
|
-
* @param autoDetectLongPolling - Whether to use the detectBufferingProxy
|
|
22324
|
-
* option when using WebChannel as the network transport.
|
|
22325
|
-
* @param useFetchStreams Whether to use the Fetch API instead of
|
|
22326
|
-
* XMLHTTPRequest
|
|
22327
|
-
*/
|
|
22328
|
-
constructor(databaseId, appId, persistenceKey, host, ssl, forceLongPolling, autoDetectLongPolling, useFetchStreams) {
|
|
22329
|
-
this.databaseId = databaseId;
|
|
22330
|
-
this.appId = appId;
|
|
22331
|
-
this.persistenceKey = persistenceKey;
|
|
22332
|
-
this.host = host;
|
|
22333
|
-
this.ssl = ssl;
|
|
22334
|
-
this.forceLongPolling = forceLongPolling;
|
|
22335
|
-
this.autoDetectLongPolling = autoDetectLongPolling;
|
|
22336
|
-
this.useFetchStreams = useFetchStreams;
|
|
22337
|
-
}
|
|
22338
|
-
}
|
|
22339
|
-
/** The default database name for a project. */
|
|
22340
|
-
const DEFAULT_DATABASE_NAME = '(default)';
|
|
22341
|
-
/**
|
|
22342
|
-
* Represents the database ID a Firestore client is associated with.
|
|
22343
|
-
* @internal
|
|
22344
|
-
*/
|
|
22345
|
-
class DatabaseId {
|
|
22346
|
-
constructor(projectId, database) {
|
|
22347
|
-
this.projectId = projectId;
|
|
22348
|
-
this.database = database ? database : DEFAULT_DATABASE_NAME;
|
|
22349
|
-
}
|
|
22350
|
-
get isDefaultDatabase() {
|
|
22351
|
-
return this.database === DEFAULT_DATABASE_NAME;
|
|
22352
|
-
}
|
|
22353
|
-
isEqual(other) {
|
|
22354
|
-
return (other instanceof DatabaseId &&
|
|
22355
|
-
other.projectId === this.projectId &&
|
|
22356
|
-
other.database === this.database);
|
|
22357
|
-
}
|
|
22358
|
-
}
|
|
22359
|
-
|
|
22360
22483
|
/**
|
|
22361
22484
|
* @license
|
|
22362
22485
|
* Copyright 2020 Google LLC
|
|
@@ -26271,125 +26394,6 @@ function writeBatch(firestore) {
|
|
|
26271
26394
|
return new WriteBatch(firestore, mutations => executeWrite(firestore, mutations));
|
|
26272
26395
|
}
|
|
26273
26396
|
|
|
26274
|
-
/**
|
|
26275
|
-
* @license
|
|
26276
|
-
* Copyright 2021 Google LLC
|
|
26277
|
-
*
|
|
26278
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26279
|
-
* you may not use this file except in compliance with the License.
|
|
26280
|
-
* You may obtain a copy of the License at
|
|
26281
|
-
*
|
|
26282
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26283
|
-
*
|
|
26284
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
26285
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26286
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26287
|
-
* See the License for the specific language governing permissions and
|
|
26288
|
-
* limitations under the License.
|
|
26289
|
-
*/
|
|
26290
|
-
/**
|
|
26291
|
-
* The initial mutation batch id for each index. Gets updated during index
|
|
26292
|
-
* backfill.
|
|
26293
|
-
*/
|
|
26294
|
-
const INITIAL_LARGEST_BATCH_ID = -1;
|
|
26295
|
-
/**
|
|
26296
|
-
* The initial sequence number for each index. Gets updated during index
|
|
26297
|
-
* backfill.
|
|
26298
|
-
*/
|
|
26299
|
-
const INITIAL_SEQUENCE_NUMBER = 0;
|
|
26300
|
-
/**
|
|
26301
|
-
* An index definition for field indexes in Firestore.
|
|
26302
|
-
*
|
|
26303
|
-
* Every index is associated with a collection. The definition contains a list
|
|
26304
|
-
* of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
|
|
26305
|
-
* `CONTAINS` for ArrayContains/ArrayContainsAny queries).
|
|
26306
|
-
*
|
|
26307
|
-
* Unlike the backend, the SDK does not differentiate between collection or
|
|
26308
|
-
* collection group-scoped indices. Every index can be used for both single
|
|
26309
|
-
* collection and collection group queries.
|
|
26310
|
-
*/
|
|
26311
|
-
class FieldIndex {
|
|
26312
|
-
constructor(
|
|
26313
|
-
/**
|
|
26314
|
-
* The index ID. Returns -1 if the index ID is not available (e.g. the index
|
|
26315
|
-
* has not yet been persisted).
|
|
26316
|
-
*/
|
|
26317
|
-
indexId,
|
|
26318
|
-
/** The collection ID this index applies to. */
|
|
26319
|
-
collectionGroup,
|
|
26320
|
-
/** The field segments for this index. */
|
|
26321
|
-
segments,
|
|
26322
|
-
/** Shows how up-to-date the index is for the current user. */
|
|
26323
|
-
indexState) {
|
|
26324
|
-
this.indexId = indexId;
|
|
26325
|
-
this.collectionGroup = collectionGroup;
|
|
26326
|
-
this.segments = segments;
|
|
26327
|
-
this.indexState = indexState;
|
|
26328
|
-
}
|
|
26329
|
-
}
|
|
26330
|
-
/** An ID for an index that has not yet been added to persistence. */
|
|
26331
|
-
FieldIndex.UNKNOWN_ID = -1;
|
|
26332
|
-
/** An index component consisting of field path and index type. */
|
|
26333
|
-
class IndexSegment {
|
|
26334
|
-
constructor(
|
|
26335
|
-
/** The field path of the component. */
|
|
26336
|
-
fieldPath,
|
|
26337
|
-
/** The fields sorting order. */
|
|
26338
|
-
kind) {
|
|
26339
|
-
this.fieldPath = fieldPath;
|
|
26340
|
-
this.kind = kind;
|
|
26341
|
-
}
|
|
26342
|
-
}
|
|
26343
|
-
/**
|
|
26344
|
-
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
26345
|
-
* current user.
|
|
26346
|
-
*/
|
|
26347
|
-
class IndexState {
|
|
26348
|
-
constructor(
|
|
26349
|
-
/**
|
|
26350
|
-
* Indicates when the index was last updated (relative to other indexes).
|
|
26351
|
-
*/
|
|
26352
|
-
sequenceNumber,
|
|
26353
|
-
/** The the latest indexed read time, document and batch id. */
|
|
26354
|
-
offset) {
|
|
26355
|
-
this.sequenceNumber = sequenceNumber;
|
|
26356
|
-
this.offset = offset;
|
|
26357
|
-
}
|
|
26358
|
-
/** The state of an index that has not yet been backfilled. */
|
|
26359
|
-
static empty() {
|
|
26360
|
-
return new IndexState(INITIAL_SEQUENCE_NUMBER, IndexOffset.min());
|
|
26361
|
-
}
|
|
26362
|
-
}
|
|
26363
|
-
/**
|
|
26364
|
-
* Stores the latest read time, document and batch ID that were processed for an
|
|
26365
|
-
* index.
|
|
26366
|
-
*/
|
|
26367
|
-
class IndexOffset {
|
|
26368
|
-
constructor(
|
|
26369
|
-
/**
|
|
26370
|
-
* The latest read time version that has been indexed by Firestore for this
|
|
26371
|
-
* field index.
|
|
26372
|
-
*/
|
|
26373
|
-
readTime,
|
|
26374
|
-
/**
|
|
26375
|
-
* The key of the last document that was indexed for this query. Use
|
|
26376
|
-
* `DocumentKey.empty()` if no document has been indexed.
|
|
26377
|
-
*/
|
|
26378
|
-
documentKey,
|
|
26379
|
-
/*
|
|
26380
|
-
* The largest mutation batch id that's been processed by Firestore.
|
|
26381
|
-
*/
|
|
26382
|
-
largestBatchId) {
|
|
26383
|
-
this.readTime = readTime;
|
|
26384
|
-
this.documentKey = documentKey;
|
|
26385
|
-
this.largestBatchId = largestBatchId;
|
|
26386
|
-
}
|
|
26387
|
-
/** The state of an index that has not yet been backfilled. */
|
|
26388
|
-
static min() {
|
|
26389
|
-
return new IndexOffset(SnapshotVersion.min(), DocumentKey.empty(), INITIAL_LARGEST_BATCH_ID);
|
|
26390
|
-
}
|
|
26391
|
-
}
|
|
26392
|
-
|
|
26393
26397
|
/**
|
|
26394
26398
|
* @license
|
|
26395
26399
|
* Copyright 2021 Google LLC
|