@firebase/firestore 3.4.3 → 3.4.4-canary.aaeab08ac
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/firestore/src/api/database.d.ts +14 -9
- package/dist/firestore/src/api/index_configuration.d.ts +117 -0
- package/dist/firestore/src/api.d.ts +1 -0
- package/dist/firestore/src/core/firestore_client.d.ts +2 -0
- package/dist/firestore/src/local/local_serializer.d.ts +1 -1
- package/dist/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/firestore/src/model/document.d.ts +7 -0
- package/dist/firestore/src/model/document_key.d.ts +1 -0
- package/dist/firestore/src/model/field_index.d.ts +152 -0
- package/dist/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
- package/dist/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
- package/dist/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/firestore/test/util/helpers.d.ts +6 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.esm2017.js +1204 -1052
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +1862 -1720
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +308 -75
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +308 -76
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.rn.js +1204 -1052
- package/dist/index.rn.js.map +1 -1
- package/dist/internal.d.ts +131 -21
- package/dist/lite/firestore/src/api/database.d.ts +14 -9
- package/dist/lite/firestore/src/api/index_configuration.d.ts +117 -0
- package/dist/lite/firestore/src/api.d.ts +1 -0
- package/dist/lite/firestore/src/core/firestore_client.d.ts +2 -0
- package/dist/lite/firestore/src/local/local_serializer.d.ts +1 -1
- package/dist/lite/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/lite/firestore/src/model/document.d.ts +7 -0
- package/dist/lite/firestore/src/model/document_key.d.ts +1 -0
- package/dist/lite/firestore/src/model/field_index.d.ts +152 -0
- package/dist/lite/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
- package/dist/lite/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
- package/dist/lite/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/lite/firestore/test/util/helpers.d.ts +6 -0
- package/dist/lite/index.browser.esm2017.js +76 -69
- package/dist/lite/index.browser.esm2017.js.map +1 -1
- package/dist/lite/index.browser.esm5.js +52 -47
- package/dist/lite/index.browser.esm5.js.map +1 -1
- package/dist/lite/index.node.cjs.js +16 -8
- package/dist/lite/index.node.cjs.js.map +1 -1
- package/dist/lite/index.node.mjs +16 -8
- package/dist/lite/index.node.mjs.map +1 -1
- package/dist/lite/index.rn.esm2017.js +95 -88
- package/dist/lite/index.rn.esm2017.js.map +1 -1
- package/dist/lite/internal.d.ts +8 -0
- package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +19 -19
- package/dist/lite/packages/firestore/src/api/database.d.ts +14 -9
- package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +117 -0
- package/dist/lite/packages/firestore/src/api.d.ts +1 -0
- package/dist/lite/packages/firestore/src/core/firestore_client.d.ts +2 -0
- package/dist/lite/packages/firestore/src/local/local_serializer.d.ts +1 -1
- package/dist/lite/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/lite/packages/firestore/src/model/document.d.ts +7 -0
- package/dist/lite/packages/firestore/src/model/document_key.d.ts +1 -0
- package/dist/lite/packages/firestore/src/model/field_index.d.ts +152 -0
- package/dist/lite/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
- package/dist/lite/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/lite/packages/firestore/test/util/helpers.d.ts +6 -0
- package/dist/lite/private.d.ts +7 -0
- package/dist/packages/firestore/dist/index.esm2017.d.ts +34 -12
- package/dist/packages/firestore/src/api/database.d.ts +14 -9
- package/dist/packages/firestore/src/api/index_configuration.d.ts +117 -0
- package/dist/packages/firestore/src/api.d.ts +1 -0
- package/dist/packages/firestore/src/core/firestore_client.d.ts +2 -0
- package/dist/packages/firestore/src/local/local_serializer.d.ts +1 -1
- package/dist/packages/firestore/src/local/remote_document_change_buffer.d.ts +3 -12
- package/dist/packages/firestore/src/model/document.d.ts +7 -0
- package/dist/packages/firestore/src/model/document_key.d.ts +1 -0
- package/dist/packages/firestore/src/model/field_index.d.ts +152 -0
- package/dist/packages/firestore/test/integration/api/index_configuration.test.d.ts +17 -0
- package/dist/packages/firestore/test/unit/local/test_remote_document_cache.d.ts +1 -1
- package/dist/packages/firestore/test/unit/model/field_index.test.d.ts +17 -0
- package/dist/packages/firestore/test/util/helpers.d.ts +6 -0
- package/dist/private.d.ts +34 -21
- package/package.json +10 -10
package/dist/internal.d.ts
CHANGED
|
@@ -841,6 +841,11 @@ declare interface Document_2 {
|
|
|
841
841
|
* document was guaranteed to not exist.
|
|
842
842
|
*/
|
|
843
843
|
readonly version: SnapshotVersion;
|
|
844
|
+
/**
|
|
845
|
+
* The timestamp at which this document was read from the remote server. Uses
|
|
846
|
+
* `SnapshotVersion.min()` for documents created by the user.
|
|
847
|
+
*/
|
|
848
|
+
readonly readTime: SnapshotVersion;
|
|
844
849
|
/** The underlying data of this document or an empty value if no data exists. */
|
|
845
850
|
readonly data: ObjectValue;
|
|
846
851
|
/** Returns whether local mutations were applied via the mutation queue. */
|
|
@@ -931,6 +936,7 @@ export declare class _DocumentKey {
|
|
|
931
936
|
constructor(path: _ResourcePath);
|
|
932
937
|
static fromPath(path: string): _DocumentKey;
|
|
933
938
|
static fromName(name: string): _DocumentKey;
|
|
939
|
+
static empty(): _DocumentKey;
|
|
934
940
|
/** Returns true if the document is in the specified collectionId. */
|
|
935
941
|
hasCollectionId(collectionId: string): boolean;
|
|
936
942
|
isEqual(other: _DocumentKey | null): boolean;
|
|
@@ -1513,6 +1519,7 @@ declare class FirestoreClient {
|
|
|
1513
1519
|
private user;
|
|
1514
1520
|
private readonly clientId;
|
|
1515
1521
|
private authCredentialListener;
|
|
1522
|
+
private appCheckCredentialListener;
|
|
1516
1523
|
offlineComponents?: OfflineComponentProvider;
|
|
1517
1524
|
onlineComponents?: OnlineComponentProvider;
|
|
1518
1525
|
constructor(authCredentials: CredentialsProvider<User>, appCheckCredentials: CredentialsProvider<string>,
|
|
@@ -1527,6 +1534,7 @@ declare class FirestoreClient {
|
|
|
1527
1534
|
asyncQueue: AsyncQueue, databaseInfo: DatabaseInfo);
|
|
1528
1535
|
getConfiguration(): Promise<ComponentConfiguration>;
|
|
1529
1536
|
setCredentialChangeListener(listener: (user: User) => Promise<void>): void;
|
|
1537
|
+
setAppCheckTokenChangeListener(listener: (appCheckToken: string, user: User) => Promise<void>): void;
|
|
1530
1538
|
/**
|
|
1531
1539
|
* Checks that the client has not been terminated. Ensures that other methods on
|
|
1532
1540
|
* this class cannot be called after the client is terminated.
|
|
@@ -2300,6 +2308,58 @@ export declare function getFirestore(app?: FirebaseApp): Firestore;
|
|
|
2300
2308
|
*/
|
|
2301
2309
|
export declare function increment(n: number): FieldValue;
|
|
2302
2310
|
|
|
2311
|
+
/**
|
|
2312
|
+
* The SDK definition of a Firestore index.
|
|
2313
|
+
*
|
|
2314
|
+
* @internal
|
|
2315
|
+
*/
|
|
2316
|
+
declare interface Index {
|
|
2317
|
+
/** The ID of the collection to index. */
|
|
2318
|
+
readonly collectionGroup: string;
|
|
2319
|
+
/** A list of fields to index. */
|
|
2320
|
+
readonly fields?: IndexField[];
|
|
2321
|
+
[key: string]: unknown;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
/**
|
|
2325
|
+
* A list of Firestore indexes to speed up local query execution.
|
|
2326
|
+
*
|
|
2327
|
+
* See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
|
|
2328
|
+
* for a description of the format of the index definition.
|
|
2329
|
+
*
|
|
2330
|
+
* @internal
|
|
2331
|
+
*/
|
|
2332
|
+
declare interface IndexConfiguration {
|
|
2333
|
+
/** A list of all Firestore indexes. */
|
|
2334
|
+
readonly indexes?: Index[];
|
|
2335
|
+
[key: string]: unknown;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
/**
|
|
2339
|
+
* A single field element in an index configuration.
|
|
2340
|
+
*
|
|
2341
|
+
* @internal
|
|
2342
|
+
*/
|
|
2343
|
+
declare interface IndexField {
|
|
2344
|
+
/** The field path to index. */
|
|
2345
|
+
readonly fieldPath: string;
|
|
2346
|
+
/**
|
|
2347
|
+
* What type of array index to create. Set to `CONTAINS` for `array-contains`
|
|
2348
|
+
* and `array-contains-any` indexes.
|
|
2349
|
+
*
|
|
2350
|
+
* Only one of `arrayConfig` or `order` should be set;
|
|
2351
|
+
*/
|
|
2352
|
+
readonly arrayConfig?: 'CONTAINS';
|
|
2353
|
+
/**
|
|
2354
|
+
* What type of array index to create. Set to `ASCENDING` or 'DESCENDING` for
|
|
2355
|
+
* `==`, `!=`, `<=`, `<=`, `in` and `not-in` filters.
|
|
2356
|
+
*
|
|
2357
|
+
* Only one of `arrayConfig` or `order` should be set.
|
|
2358
|
+
*/
|
|
2359
|
+
readonly order?: 'ASCENDING' | 'DESCENDING';
|
|
2360
|
+
[key: string]: unknown;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2303
2363
|
declare type IndexFieldMode = 'MODE_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING';
|
|
2304
2364
|
|
|
2305
2365
|
/**
|
|
@@ -2432,13 +2492,13 @@ declare class LLRBNode<K, V> {
|
|
|
2432
2492
|
/**
|
|
2433
2493
|
* Loads a Firestore bundle into the local cache.
|
|
2434
2494
|
*
|
|
2435
|
-
* @param firestore - The {@link Firestore} instance to load bundles for
|
|
2436
|
-
* @param bundleData - An object representing the bundle to be loaded. Valid
|
|
2437
|
-
*
|
|
2495
|
+
* @param firestore - The {@link Firestore} instance to load bundles for.
|
|
2496
|
+
* @param bundleData - An object representing the bundle to be loaded. Valid
|
|
2497
|
+
* objects are `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
|
|
2438
2498
|
*
|
|
2439
|
-
* @returns
|
|
2440
|
-
*
|
|
2441
|
-
*
|
|
2499
|
+
* @returns A `LoadBundleTask` object, which notifies callers with progress
|
|
2500
|
+
* updates, and completion or error events. It can be used as a
|
|
2501
|
+
* `Promise<LoadBundleTaskProgress>`.
|
|
2442
2502
|
*/
|
|
2443
2503
|
export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;
|
|
2444
2504
|
|
|
@@ -2585,6 +2645,7 @@ declare class MutableDocument implements Document_2 {
|
|
|
2585
2645
|
readonly key: _DocumentKey;
|
|
2586
2646
|
private documentType;
|
|
2587
2647
|
version: SnapshotVersion;
|
|
2648
|
+
readTime: SnapshotVersion;
|
|
2588
2649
|
data: ObjectValue;
|
|
2589
2650
|
private documentState;
|
|
2590
2651
|
private constructor();
|
|
@@ -2624,6 +2685,7 @@ declare class MutableDocument implements Document_2 {
|
|
|
2624
2685
|
convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
|
|
2625
2686
|
setHasCommittedMutations(): MutableDocument;
|
|
2626
2687
|
setHasLocalMutations(): MutableDocument;
|
|
2688
|
+
setReadTime(readTime: SnapshotVersion): MutableDocument;
|
|
2627
2689
|
get hasLocalMutations(): boolean;
|
|
2628
2690
|
get hasCommittedMutations(): boolean;
|
|
2629
2691
|
get hasPendingWrites(): boolean;
|
|
@@ -2916,11 +2978,16 @@ declare interface NamedQuery {
|
|
|
2916
2978
|
}
|
|
2917
2979
|
|
|
2918
2980
|
/**
|
|
2919
|
-
* Reads a Firestore {@link Query} from local cache, identified by the given
|
|
2981
|
+
* Reads a Firestore {@link Query} from local cache, identified by the given
|
|
2982
|
+
* name.
|
|
2920
2983
|
*
|
|
2921
2984
|
* The named queries are packaged into bundles on the server side (along
|
|
2922
|
-
* with resulting documents), and loaded to local cache using `loadBundle`. Once
|
|
2923
|
-
* cache, use this method to extract a {@link Query} by name.
|
|
2985
|
+
* with resulting documents), and loaded to local cache using `loadBundle`. Once
|
|
2986
|
+
* in local cache, use this method to extract a {@link Query} by name.
|
|
2987
|
+
*
|
|
2988
|
+
* @param firestore - The {@link Firestore} instance to read the query from.
|
|
2989
|
+
* @param name - The name of the query.
|
|
2990
|
+
* @returns A `Promise` that is resolved with the Query or `null`.
|
|
2924
2991
|
*/
|
|
2925
2992
|
export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
|
|
2926
2993
|
|
|
@@ -3935,14 +4002,6 @@ declare interface RemoteDocumentCache {
|
|
|
3935
4002
|
getSize(transaction: PersistenceTransaction): PersistencePromise<number>;
|
|
3936
4003
|
}
|
|
3937
4004
|
|
|
3938
|
-
/**
|
|
3939
|
-
* Represents a document change to be applied to remote document cache.
|
|
3940
|
-
*/
|
|
3941
|
-
declare interface RemoteDocumentChange {
|
|
3942
|
-
readonly document: MutableDocument;
|
|
3943
|
-
readonly readTime: SnapshotVersion | null;
|
|
3944
|
-
}
|
|
3945
|
-
|
|
3946
4005
|
/**
|
|
3947
4006
|
* An in-memory buffer of entries to be written to a RemoteDocumentCache.
|
|
3948
4007
|
* It can be used to batch up a set of changes to be written to the cache, but
|
|
@@ -3958,26 +4017,25 @@ declare interface RemoteDocumentChange {
|
|
|
3958
4017
|
* porting this class as part of that implementation work.
|
|
3959
4018
|
*/
|
|
3960
4019
|
declare abstract class RemoteDocumentChangeBuffer {
|
|
3961
|
-
protected changes: ObjectMap<_DocumentKey,
|
|
4020
|
+
protected changes: ObjectMap<_DocumentKey, MutableDocument>;
|
|
3962
4021
|
private changesApplied;
|
|
3963
4022
|
protected abstract getFromCache(transaction: PersistenceTransaction, documentKey: _DocumentKey): PersistencePromise<MutableDocument>;
|
|
3964
4023
|
protected abstract getAllFromCache(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
|
|
3965
4024
|
protected abstract applyChanges(transaction: PersistenceTransaction): PersistencePromise<void>;
|
|
3966
|
-
protected getReadTime(key: _DocumentKey): SnapshotVersion;
|
|
3967
4025
|
/**
|
|
3968
4026
|
* Buffers a `RemoteDocumentCache.addEntry()` call.
|
|
3969
4027
|
*
|
|
3970
4028
|
* You can only modify documents that have already been retrieved via
|
|
3971
4029
|
* `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
|
|
3972
4030
|
*/
|
|
3973
|
-
addEntry(document: MutableDocument
|
|
4031
|
+
addEntry(document: MutableDocument): void;
|
|
3974
4032
|
/**
|
|
3975
4033
|
* Buffers a `RemoteDocumentCache.removeEntry()` call.
|
|
3976
4034
|
*
|
|
3977
4035
|
* You can only remove documents that have already been retrieved via
|
|
3978
4036
|
* `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
|
|
3979
4037
|
*/
|
|
3980
|
-
removeEntry(key: _DocumentKey, readTime
|
|
4038
|
+
removeEntry(key: _DocumentKey, readTime: SnapshotVersion): void;
|
|
3981
4039
|
/**
|
|
3982
4040
|
* Looks up an entry in the cache. The buffered changes will first be checked,
|
|
3983
4041
|
* and if no buffered change applies, this will forward to
|
|
@@ -4216,6 +4274,58 @@ export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFie
|
|
|
4216
4274
|
*/
|
|
4217
4275
|
export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
|
|
4218
4276
|
|
|
4277
|
+
/**
|
|
4278
|
+
* Configures indexing for local query execution. Any previous index
|
|
4279
|
+
* configuration is overridden. The `Promise` resolves once the index
|
|
4280
|
+
* configuration has been persisted.
|
|
4281
|
+
*
|
|
4282
|
+
* The index entries themselves are created asynchronously. You can continue to
|
|
4283
|
+
* use queries that require indexing even if the indices are not yet available.
|
|
4284
|
+
* Query execution will automatically start using the index once the index
|
|
4285
|
+
* entries have been written.
|
|
4286
|
+
*
|
|
4287
|
+
* Indexes are only supported with IndexedDb persistence. Invoke either
|
|
4288
|
+
* `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
|
4289
|
+
* before setting an index configuration. If IndexedDb is not enabled, any
|
|
4290
|
+
* index configuration is ignored.
|
|
4291
|
+
*
|
|
4292
|
+
* @internal
|
|
4293
|
+
* @param firestore - The {@link Firestore} instance to configure indexes for.
|
|
4294
|
+
* @param configuration -The index definition.
|
|
4295
|
+
* @throws FirestoreError if the JSON format is invalid.
|
|
4296
|
+
* @returns A `Promise` that resolves once all indices are successfully
|
|
4297
|
+
* configured.
|
|
4298
|
+
*/
|
|
4299
|
+
export declare function _setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
|
|
4300
|
+
|
|
4301
|
+
/**
|
|
4302
|
+
* Configures indexing for local query execution. Any previous index
|
|
4303
|
+
* configuration is overridden. The `Promise` resolves once the index
|
|
4304
|
+
* configuration has been persisted.
|
|
4305
|
+
*
|
|
4306
|
+
* The index entries themselves are created asynchronously. You can continue to
|
|
4307
|
+
* use queries that require indexing even if the indices are not yet available.
|
|
4308
|
+
* Query execution will automatically start using the index once the index
|
|
4309
|
+
* entries have been written.
|
|
4310
|
+
*
|
|
4311
|
+
* Indexes are only supported with IndexedDb persistence. Invoke either
|
|
4312
|
+
* `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
|
4313
|
+
* before setting an index configuration. If IndexedDb is not enabled, any
|
|
4314
|
+
* index configuration is ignored.
|
|
4315
|
+
*
|
|
4316
|
+
* The method accepts the JSON format exported by the Firebase CLI (`firebase
|
|
4317
|
+
* firestore:indexes`). If the JSON format is invalid, this method throws an
|
|
4318
|
+
* error.
|
|
4319
|
+
*
|
|
4320
|
+
* @internal
|
|
4321
|
+
* @param firestore - The {@link Firestore} instance to configure indexes for.
|
|
4322
|
+
* @param json -The JSON format exported by the Firebase CLI.
|
|
4323
|
+
* @throws FirestoreError if the JSON format is invalid.
|
|
4324
|
+
* @returns A `Promise` that resolves once all indices are successfully
|
|
4325
|
+
* configured.
|
|
4326
|
+
*/
|
|
4327
|
+
export declare function _setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
|
|
4328
|
+
|
|
4219
4329
|
/**
|
|
4220
4330
|
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
|
4221
4331
|
*
|
|
@@ -209,20 +209,25 @@ export declare function terminate(firestore: Firestore): Promise<void>;
|
|
|
209
209
|
/**
|
|
210
210
|
* Loads a Firestore bundle into the local cache.
|
|
211
211
|
*
|
|
212
|
-
* @param firestore - The {@link Firestore} instance to load bundles for
|
|
213
|
-
* @param bundleData - An object representing the bundle to be loaded. Valid
|
|
214
|
-
*
|
|
212
|
+
* @param firestore - The {@link Firestore} instance to load bundles for.
|
|
213
|
+
* @param bundleData - An object representing the bundle to be loaded. Valid
|
|
214
|
+
* objects are `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
|
|
215
215
|
*
|
|
216
|
-
* @returns
|
|
217
|
-
*
|
|
218
|
-
*
|
|
216
|
+
* @returns A `LoadBundleTask` object, which notifies callers with progress
|
|
217
|
+
* updates, and completion or error events. It can be used as a
|
|
218
|
+
* `Promise<LoadBundleTaskProgress>`.
|
|
219
219
|
*/
|
|
220
220
|
export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;
|
|
221
221
|
/**
|
|
222
|
-
* Reads a Firestore {@link Query} from local cache, identified by the given
|
|
222
|
+
* Reads a Firestore {@link Query} from local cache, identified by the given
|
|
223
|
+
* name.
|
|
223
224
|
*
|
|
224
225
|
* The named queries are packaged into bundles on the server side (along
|
|
225
|
-
* with resulting documents), and loaded to local cache using `loadBundle`. Once
|
|
226
|
-
* cache, use this method to extract a {@link Query} by name.
|
|
226
|
+
* with resulting documents), and loaded to local cache using `loadBundle`. Once
|
|
227
|
+
* in local cache, use this method to extract a {@link Query} by name.
|
|
228
|
+
*
|
|
229
|
+
* @param firestore - The {@link Firestore} instance to read the query from.
|
|
230
|
+
* @param name - The name of the query.
|
|
231
|
+
* @returns A `Promise` that is resolved with the Query or `null`.
|
|
227
232
|
*/
|
|
228
233
|
export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { Firestore } from './database';
|
|
18
|
+
export { connectFirestoreEmulator, EmulatorMockTokenOptions } from '../lite-api/database';
|
|
19
|
+
/**
|
|
20
|
+
* A single field element in an index configuration.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export interface IndexField {
|
|
25
|
+
/** The field path to index. */
|
|
26
|
+
readonly fieldPath: string;
|
|
27
|
+
/**
|
|
28
|
+
* What type of array index to create. Set to `CONTAINS` for `array-contains`
|
|
29
|
+
* and `array-contains-any` indexes.
|
|
30
|
+
*
|
|
31
|
+
* Only one of `arrayConfig` or `order` should be set;
|
|
32
|
+
*/
|
|
33
|
+
readonly arrayConfig?: 'CONTAINS';
|
|
34
|
+
/**
|
|
35
|
+
* What type of array index to create. Set to `ASCENDING` or 'DESCENDING` for
|
|
36
|
+
* `==`, `!=`, `<=`, `<=`, `in` and `not-in` filters.
|
|
37
|
+
*
|
|
38
|
+
* Only one of `arrayConfig` or `order` should be set.
|
|
39
|
+
*/
|
|
40
|
+
readonly order?: 'ASCENDING' | 'DESCENDING';
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The SDK definition of a Firestore index.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export interface Index {
|
|
49
|
+
/** The ID of the collection to index. */
|
|
50
|
+
readonly collectionGroup: string;
|
|
51
|
+
/** A list of fields to index. */
|
|
52
|
+
readonly fields?: IndexField[];
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A list of Firestore indexes to speed up local query execution.
|
|
57
|
+
*
|
|
58
|
+
* See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
|
|
59
|
+
* for a description of the format of the index definition.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export interface IndexConfiguration {
|
|
64
|
+
/** A list of all Firestore indexes. */
|
|
65
|
+
readonly indexes?: Index[];
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Configures indexing for local query execution. Any previous index
|
|
70
|
+
* configuration is overridden. The `Promise` resolves once the index
|
|
71
|
+
* configuration has been persisted.
|
|
72
|
+
*
|
|
73
|
+
* The index entries themselves are created asynchronously. You can continue to
|
|
74
|
+
* use queries that require indexing even if the indices are not yet available.
|
|
75
|
+
* Query execution will automatically start using the index once the index
|
|
76
|
+
* entries have been written.
|
|
77
|
+
*
|
|
78
|
+
* Indexes are only supported with IndexedDb persistence. Invoke either
|
|
79
|
+
* `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
|
80
|
+
* before setting an index configuration. If IndexedDb is not enabled, any
|
|
81
|
+
* index configuration is ignored.
|
|
82
|
+
*
|
|
83
|
+
* @internal
|
|
84
|
+
* @param firestore - The {@link Firestore} instance to configure indexes for.
|
|
85
|
+
* @param configuration -The index definition.
|
|
86
|
+
* @throws FirestoreError if the JSON format is invalid.
|
|
87
|
+
* @returns A `Promise` that resolves once all indices are successfully
|
|
88
|
+
* configured.
|
|
89
|
+
*/
|
|
90
|
+
export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Configures indexing for local query execution. Any previous index
|
|
93
|
+
* configuration is overridden. The `Promise` resolves once the index
|
|
94
|
+
* configuration has been persisted.
|
|
95
|
+
*
|
|
96
|
+
* The index entries themselves are created asynchronously. You can continue to
|
|
97
|
+
* use queries that require indexing even if the indices are not yet available.
|
|
98
|
+
* Query execution will automatically start using the index once the index
|
|
99
|
+
* entries have been written.
|
|
100
|
+
*
|
|
101
|
+
* Indexes are only supported with IndexedDb persistence. Invoke either
|
|
102
|
+
* `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
|
103
|
+
* before setting an index configuration. If IndexedDb is not enabled, any
|
|
104
|
+
* index configuration is ignored.
|
|
105
|
+
*
|
|
106
|
+
* The method accepts the JSON format exported by the Firebase CLI (`firebase
|
|
107
|
+
* firestore:indexes`). If the JSON format is invalid, this method throws an
|
|
108
|
+
* error.
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
* @param firestore - The {@link Firestore} instance to configure indexes for.
|
|
112
|
+
* @param json -The JSON format exported by the Firebase CLI.
|
|
113
|
+
* @throws FirestoreError if the JSON format is invalid.
|
|
114
|
+
* @returns A `Promise` that resolves once all indices are successfully
|
|
115
|
+
* configured.
|
|
116
|
+
*/
|
|
117
|
+
export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
|
|
@@ -49,3 +49,4 @@ export type { ByteString as _ByteString } from './util/byte_string';
|
|
|
49
49
|
export { logWarn as _logWarn } from './util/log';
|
|
50
50
|
export { EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider } from './api/credentials';
|
|
51
51
|
export { EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider } from './api/credentials';
|
|
52
|
+
export { setIndexConfiguration as _setIndexConfiguration } from './api/index_configuration';
|
|
@@ -53,6 +53,7 @@ export declare class FirestoreClient {
|
|
|
53
53
|
private user;
|
|
54
54
|
private readonly clientId;
|
|
55
55
|
private authCredentialListener;
|
|
56
|
+
private appCheckCredentialListener;
|
|
56
57
|
offlineComponents?: OfflineComponentProvider;
|
|
57
58
|
onlineComponents?: OnlineComponentProvider;
|
|
58
59
|
constructor(authCredentials: CredentialsProvider<User>, appCheckCredentials: CredentialsProvider<string>,
|
|
@@ -67,6 +68,7 @@ export declare class FirestoreClient {
|
|
|
67
68
|
asyncQueue: AsyncQueue, databaseInfo: DatabaseInfo);
|
|
68
69
|
getConfiguration(): Promise<ComponentConfiguration>;
|
|
69
70
|
setCredentialChangeListener(listener: (user: User) => Promise<void>): void;
|
|
71
|
+
setAppCheckTokenChangeListener(listener: (appCheckToken: string, user: User) => Promise<void>): void;
|
|
70
72
|
/**
|
|
71
73
|
* Checks that the client has not been terminated. Ensures that other methods on
|
|
72
74
|
* this class cannot be called after the client is terminated.
|
|
@@ -31,7 +31,7 @@ export declare class LocalSerializer {
|
|
|
31
31
|
/** Decodes a remote document from storage locally to a Document. */
|
|
32
32
|
export declare function fromDbRemoteDocument(localSerializer: LocalSerializer, remoteDoc: DbRemoteDocument): MutableDocument;
|
|
33
33
|
/** Encodes a document for storage locally. */
|
|
34
|
-
export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument
|
|
34
|
+
export declare function toDbRemoteDocument(localSerializer: LocalSerializer, document: MutableDocument): DbRemoteDocument;
|
|
35
35
|
export declare function toDbTimestampKey(snapshotVersion: SnapshotVersion): DbTimestampKey;
|
|
36
36
|
export declare function fromDbTimestampKey(dbTimestampKey: DbTimestampKey): SnapshotVersion;
|
|
37
37
|
/** Encodes a batch of mutations into a DbMutationBatch for local storage. */
|
|
@@ -21,13 +21,6 @@ import { DocumentKey } from '../model/document_key';
|
|
|
21
21
|
import { ObjectMap } from '../util/obj_map';
|
|
22
22
|
import { PersistencePromise } from './persistence_promise';
|
|
23
23
|
import { PersistenceTransaction } from './persistence_transaction';
|
|
24
|
-
/**
|
|
25
|
-
* Represents a document change to be applied to remote document cache.
|
|
26
|
-
*/
|
|
27
|
-
interface RemoteDocumentChange {
|
|
28
|
-
readonly document: MutableDocument;
|
|
29
|
-
readonly readTime: SnapshotVersion | null;
|
|
30
|
-
}
|
|
31
24
|
/**
|
|
32
25
|
* An in-memory buffer of entries to be written to a RemoteDocumentCache.
|
|
33
26
|
* It can be used to batch up a set of changes to be written to the cache, but
|
|
@@ -43,26 +36,25 @@ interface RemoteDocumentChange {
|
|
|
43
36
|
* porting this class as part of that implementation work.
|
|
44
37
|
*/
|
|
45
38
|
export declare abstract class RemoteDocumentChangeBuffer {
|
|
46
|
-
protected changes: ObjectMap<DocumentKey,
|
|
39
|
+
protected changes: ObjectMap<DocumentKey, MutableDocument>;
|
|
47
40
|
private changesApplied;
|
|
48
41
|
protected abstract getFromCache(transaction: PersistenceTransaction, documentKey: DocumentKey): PersistencePromise<MutableDocument>;
|
|
49
42
|
protected abstract getAllFromCache(transaction: PersistenceTransaction, documentKeys: DocumentKeySet): PersistencePromise<MutableDocumentMap>;
|
|
50
43
|
protected abstract applyChanges(transaction: PersistenceTransaction): PersistencePromise<void>;
|
|
51
|
-
protected getReadTime(key: DocumentKey): SnapshotVersion;
|
|
52
44
|
/**
|
|
53
45
|
* Buffers a `RemoteDocumentCache.addEntry()` call.
|
|
54
46
|
*
|
|
55
47
|
* You can only modify documents that have already been retrieved via
|
|
56
48
|
* `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
|
|
57
49
|
*/
|
|
58
|
-
addEntry(document: MutableDocument
|
|
50
|
+
addEntry(document: MutableDocument): void;
|
|
59
51
|
/**
|
|
60
52
|
* Buffers a `RemoteDocumentCache.removeEntry()` call.
|
|
61
53
|
*
|
|
62
54
|
* You can only remove documents that have already been retrieved via
|
|
63
55
|
* `getEntry()/getEntries()` (enforced via IndexedDbs `apply()`).
|
|
64
56
|
*/
|
|
65
|
-
removeEntry(key: DocumentKey, readTime
|
|
57
|
+
removeEntry(key: DocumentKey, readTime: SnapshotVersion): void;
|
|
66
58
|
/**
|
|
67
59
|
* Looks up an entry in the cache. The buffered changes will first be checked,
|
|
68
60
|
* and if no buffered change applies, this will forward to
|
|
@@ -94,4 +86,3 @@ export declare abstract class RemoteDocumentChangeBuffer {
|
|
|
94
86
|
/** Helper to assert this.changes is not null */
|
|
95
87
|
protected assertNotApplied(): void;
|
|
96
88
|
}
|
|
97
|
-
export {};
|
|
@@ -30,6 +30,11 @@ export interface Document {
|
|
|
30
30
|
* document was guaranteed to not exist.
|
|
31
31
|
*/
|
|
32
32
|
readonly version: SnapshotVersion;
|
|
33
|
+
/**
|
|
34
|
+
* The timestamp at which this document was read from the remote server. Uses
|
|
35
|
+
* `SnapshotVersion.min()` for documents created by the user.
|
|
36
|
+
*/
|
|
37
|
+
readonly readTime: SnapshotVersion;
|
|
33
38
|
/** The underlying data of this document or an empty value if no data exists. */
|
|
34
39
|
readonly data: ObjectValue;
|
|
35
40
|
/** Returns whether local mutations were applied via the mutation queue. */
|
|
@@ -79,6 +84,7 @@ export declare class MutableDocument implements Document {
|
|
|
79
84
|
readonly key: DocumentKey;
|
|
80
85
|
private documentType;
|
|
81
86
|
version: SnapshotVersion;
|
|
87
|
+
readTime: SnapshotVersion;
|
|
82
88
|
data: ObjectValue;
|
|
83
89
|
private documentState;
|
|
84
90
|
private constructor();
|
|
@@ -118,6 +124,7 @@ export declare class MutableDocument implements Document {
|
|
|
118
124
|
convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
|
|
119
125
|
setHasCommittedMutations(): MutableDocument;
|
|
120
126
|
setHasLocalMutations(): MutableDocument;
|
|
127
|
+
setReadTime(readTime: SnapshotVersion): MutableDocument;
|
|
121
128
|
get hasLocalMutations(): boolean;
|
|
122
129
|
get hasCommittedMutations(): boolean;
|
|
123
130
|
get hasPendingWrites(): boolean;
|
|
@@ -23,6 +23,7 @@ export declare class DocumentKey {
|
|
|
23
23
|
constructor(path: ResourcePath);
|
|
24
24
|
static fromPath(path: string): DocumentKey;
|
|
25
25
|
static fromName(name: string): DocumentKey;
|
|
26
|
+
static empty(): DocumentKey;
|
|
26
27
|
/** Returns true if the document is in the specified collectionId. */
|
|
27
28
|
hasCollectionId(collectionId: string): boolean;
|
|
28
29
|
isEqual(other: DocumentKey | null): boolean;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { SnapshotVersion } from '../core/snapshot_version';
|
|
18
|
+
import { Document } from './document';
|
|
19
|
+
import { DocumentKey } from './document_key';
|
|
20
|
+
import { FieldPath } from './path';
|
|
21
|
+
/**
|
|
22
|
+
* The initial sequence number for each index. Gets updated during index
|
|
23
|
+
* backfill.
|
|
24
|
+
*/
|
|
25
|
+
export declare const INITIAL_SEQUENCE_NUMBER = 0;
|
|
26
|
+
/**
|
|
27
|
+
* An index definition for field indexes in Firestore.
|
|
28
|
+
*
|
|
29
|
+
* Every index is associated with a collection. The definition contains a list
|
|
30
|
+
* of fields and their index kind (which can be `ASCENDING`, `DESCENDING` or
|
|
31
|
+
* `CONTAINS` for ArrayContains/ArrayContainsAny queries).
|
|
32
|
+
*
|
|
33
|
+
* Unlike the backend, the SDK does not differentiate between collection or
|
|
34
|
+
* collection group-scoped indices. Every index can be used for both single
|
|
35
|
+
* collection and collection group queries.
|
|
36
|
+
*/
|
|
37
|
+
export declare class FieldIndex {
|
|
38
|
+
/**
|
|
39
|
+
* The index ID. Returns -1 if the index ID is not available (e.g. the index
|
|
40
|
+
* has not yet been persisted).
|
|
41
|
+
*/
|
|
42
|
+
readonly indexId: number;
|
|
43
|
+
/** The collection ID this index applies to. */
|
|
44
|
+
readonly collectionGroup: string;
|
|
45
|
+
/** The field segments for this index. */
|
|
46
|
+
readonly segments: IndexSegment[];
|
|
47
|
+
/** Shows how up-to-date the index is for the current user. */
|
|
48
|
+
readonly indexState: IndexState;
|
|
49
|
+
/** An ID for an index that has not yet been added to persistence. */
|
|
50
|
+
static UNKNOWN_ID: number;
|
|
51
|
+
constructor(
|
|
52
|
+
/**
|
|
53
|
+
* The index ID. Returns -1 if the index ID is not available (e.g. the index
|
|
54
|
+
* has not yet been persisted).
|
|
55
|
+
*/
|
|
56
|
+
indexId: number,
|
|
57
|
+
/** The collection ID this index applies to. */
|
|
58
|
+
collectionGroup: string,
|
|
59
|
+
/** The field segments for this index. */
|
|
60
|
+
segments: IndexSegment[],
|
|
61
|
+
/** Shows how up-to-date the index is for the current user. */
|
|
62
|
+
indexState: IndexState);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Compares indexes by collection group and segments. Ignores update time and
|
|
66
|
+
* index ID.
|
|
67
|
+
*/
|
|
68
|
+
export declare function fieldIndexSemanticComparator(left: FieldIndex, right: FieldIndex): number;
|
|
69
|
+
/** The type of the index, e.g. for which type of query it can be used. */
|
|
70
|
+
export declare const enum IndexKind {
|
|
71
|
+
/**
|
|
72
|
+
* Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
|
|
73
|
+
*/
|
|
74
|
+
ASCENDING = 0,
|
|
75
|
+
/**
|
|
76
|
+
* Ordered index. Can be used for <, <=, ==, >=, >, !=, IN and NOT IN queries.
|
|
77
|
+
*/
|
|
78
|
+
DESCENDING = 1,
|
|
79
|
+
/** Contains index. Can be used for ArrayContains and ArrayContainsAny. */
|
|
80
|
+
CONTAINS = 2
|
|
81
|
+
}
|
|
82
|
+
/** An index component consisting of field path and index type. */
|
|
83
|
+
export declare class IndexSegment {
|
|
84
|
+
/** The field path of the component. */
|
|
85
|
+
readonly fieldPath: FieldPath;
|
|
86
|
+
/** The fields sorting order. */
|
|
87
|
+
readonly kind: IndexKind;
|
|
88
|
+
constructor(
|
|
89
|
+
/** The field path of the component. */
|
|
90
|
+
fieldPath: FieldPath,
|
|
91
|
+
/** The fields sorting order. */
|
|
92
|
+
kind: IndexKind);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Stores the "high water mark" that indicates how updated the Index is for the
|
|
96
|
+
* current user.
|
|
97
|
+
*/
|
|
98
|
+
export declare class IndexState {
|
|
99
|
+
/**
|
|
100
|
+
* Indicates when the index was last updated (relative to other indexes).
|
|
101
|
+
*/
|
|
102
|
+
readonly sequenceNumber: number;
|
|
103
|
+
/** The the latest indexed read time, document and batch id. */
|
|
104
|
+
readonly offset: IndexOffset;
|
|
105
|
+
constructor(
|
|
106
|
+
/**
|
|
107
|
+
* Indicates when the index was last updated (relative to other indexes).
|
|
108
|
+
*/
|
|
109
|
+
sequenceNumber: number,
|
|
110
|
+
/** The the latest indexed read time, document and batch id. */
|
|
111
|
+
offset: IndexOffset);
|
|
112
|
+
/** The state of an index that has not yet been backfilled. */
|
|
113
|
+
static empty(): IndexState;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates an offset that matches all documents with a read time higher than
|
|
117
|
+
* `readTime`.
|
|
118
|
+
*/
|
|
119
|
+
export declare function newIndexOffsetSuccessorFromReadTime(readTime: SnapshotVersion, largestBatchId: number): IndexOffset;
|
|
120
|
+
/** Creates a new offset based on the provided document. */
|
|
121
|
+
export declare function newIndexOffsetFromDocument(document: Document): IndexOffset;
|
|
122
|
+
/**
|
|
123
|
+
* Stores the latest read time, document and batch ID that were processed for an
|
|
124
|
+
* index.
|
|
125
|
+
*/
|
|
126
|
+
export declare class IndexOffset {
|
|
127
|
+
/**
|
|
128
|
+
* The latest read time version that has been indexed by Firestore for this
|
|
129
|
+
* field index.
|
|
130
|
+
*/
|
|
131
|
+
readonly readTime: SnapshotVersion;
|
|
132
|
+
/**
|
|
133
|
+
* The key of the last document that was indexed for this query. Use
|
|
134
|
+
* `DocumentKey.empty()` if no document has been indexed.
|
|
135
|
+
*/
|
|
136
|
+
readonly documentKey: DocumentKey;
|
|
137
|
+
readonly largestBatchId: number;
|
|
138
|
+
constructor(
|
|
139
|
+
/**
|
|
140
|
+
* The latest read time version that has been indexed by Firestore for this
|
|
141
|
+
* field index.
|
|
142
|
+
*/
|
|
143
|
+
readTime: SnapshotVersion,
|
|
144
|
+
/**
|
|
145
|
+
* The key of the last document that was indexed for this query. Use
|
|
146
|
+
* `DocumentKey.empty()` if no document has been indexed.
|
|
147
|
+
*/
|
|
148
|
+
documentKey: DocumentKey, largestBatchId: number);
|
|
149
|
+
/** The state of an index that has not yet been backfilled. */
|
|
150
|
+
static min(): IndexOffset;
|
|
151
|
+
}
|
|
152
|
+
export declare function indexOffsetComparator(left: IndexOffset, right: IndexOffset): number;
|