UNPKG

107 kBTypeScriptView Raw
1/**
2 * Cloud Firestore
3 *
4 * @packageDocumentation
5 */
6import { FirebaseApp } from '@firebase/app';
7import { LogLevelString as LogLevel } from '@firebase/logger';
8import { EmulatorMockTokenOptions } from '@firebase/util';
9import { FirebaseError } from '@firebase/util';
10
11/**
12 * Add a new document to specified `CollectionReference` with the given data,
13 * assigning it a document ID automatically.
14 *
15 * @param reference - A reference to the collection to add this document to.
16 * @param data - An Object containing the data for the new document.
17 * @returns A `Promise` resolved with a `DocumentReference` pointing to the
18 * newly created document after it has been written to the backend (Note that it
19 * won't resolve while you're offline).
20 */
21export declare function addDoc<T>(reference: CollectionReference<T>, data: WithFieldValue<T>): Promise<DocumentReference<T>>;
22/**
23 * Returns a new map where every key is prefixed with the outer key appended
24 * to a dot.
25 */
26export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
27 [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
28};
29/**
30 * Represents an aggregation that can be performed by Firestore.
31 */
32export declare class AggregateField<T> {
33 /** A type string to uniquely identify instances of this class. */
34 readonly type = "AggregateField";
35}
36/* Excluded from this release type: aggregateFieldEqual */
37/**
38 * The union of all `AggregateField` types that are supported by Firestore.
39 */
40export declare type AggregateFieldType = AggregateField<number | null>;
41/**
42 * The results of executing an aggregation query.
43 */
44export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
45 /** A type string to uniquely identify instances of this class. */
46 readonly type = "AggregateQuerySnapshot";
47 /**
48 * The underlying query over which the aggregations recorded in this
49 * `AggregateQuerySnapshot` were performed.
50 */
51 readonly query: Query<unknown>;
52 private constructor();
53 /**
54 * Returns the results of the aggregations performed over the underlying
55 * query.
56 *
57 * The keys of the returned object will be the same as those of the
58 * `AggregateSpec` object specified to the aggregation method, and the values
59 * will be the corresponding aggregation result.
60 *
61 * @returns The results of the aggregations performed over the underlying
62 * query.
63 */
64 data(): AggregateSpecData<T>;
65}
66/**
67 * Compares two `AggregateQuerySnapshot` instances for equality.
68 *
69 * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
70 * underlying queries that compare equal, and the same data.
71 *
72 * @param left - The first `AggregateQuerySnapshot` to compare.
73 * @param right - The second `AggregateQuerySnapshot` to compare.
74 *
75 * @returns `true` if the objects are "equal", as defined above, or `false`
76 * otherwise.
77 */
78export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
79/**
80 * Specifies a set of aggregations and their aliases.
81 */
82export declare interface AggregateSpec {
83 [field: string]: AggregateFieldType;
84}
85/**
86 * A type whose keys are taken from an `AggregateSpec`, and whose values are the
87 * result of the aggregation performed by the corresponding `AggregateField`
88 * from the input `AggregateSpec`.
89 */
90export declare type AggregateSpecData<T extends AggregateSpec> = {
91 [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
92};
93/* Excluded from this release type: AggregateType */
94/**
95 * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of
96 * the given filter constraints. A conjunction filter includes a document if it
97 * satisfies all of the given filters.
98 *
99 * @param queryConstraints - Optional. The list of
100 * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
101 * created with calls to {@link where}, {@link or}, or {@link and}.
102 * @returns The newly created {@link QueryCompositeFilterConstraint}.
103 */
104export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
105/**
106 * Returns a special value that can be used with {@link (setDoc:1)} or {@link
107 * updateDoc:1} that tells the server to remove the given elements from any
108 * array value that already exists on the server. All instances of each element
109 * specified will be removed from the array. If the field being modified is not
110 * already an array it will be overwritten with an empty array.
111 *
112 * @param elements - The elements to remove from the array.
113 * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
114 * `updateDoc()`
115 */
116export declare function arrayRemove(...elements: unknown[]): FieldValue;
117/**
118 * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
119 * @firebase/firestore/lite#(updateDoc:1)} that tells the server to union the given elements with any array
120 * value that already exists on the server. Each specified element that doesn't
121 * already exist in the array will be added to the end. If the field being
122 * modified is not already an array it will be overwritten with an array
123 * containing exactly the specified elements.
124 *
125 * @param elements - The elements to union into the array.
126 * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
127 * `updateDoc()`.
128 */
129export declare function arrayUnion(...elements: unknown[]): FieldValue;
130/**
131 * An immutable object representing an array of bytes.
132 */
133export declare class Bytes {
134 private constructor();
135 /**
136 * Creates a new `Bytes` object from the given Base64 string, converting it to
137 * bytes.
138 *
139 * @param base64 - The Base64 string used to create the `Bytes` object.
140 */
141 static fromBase64String(base64: string): Bytes;
142 /**
143 * Creates a new `Bytes` object from the given Uint8Array.
144 *
145 * @param array - The Uint8Array used to create the `Bytes` object.
146 */
147 static fromUint8Array(array: Uint8Array): Bytes;
148 /**
149 * Returns the underlying bytes as a Base64-encoded string.
150 *
151 * @returns The Base64-encoded string created from the `Bytes` object.
152 */
153 toBase64(): string;
154 /**
155 * Returns the underlying bytes in a new `Uint8Array`.
156 *
157 * @returns The Uint8Array created from the `Bytes` object.
158 */
159 toUint8Array(): Uint8Array;
160 /**
161 * Returns a string representation of the `Bytes` object.
162 *
163 * @returns A string representation of the `Bytes` object.
164 */
165 toString(): string;
166 /**
167 * Returns true if this `Bytes` object is equal to the provided one.
168 *
169 * @param other - The `Bytes` object to compare against.
170 * @returns true if this `Bytes` object is equal to the provided one.
171 */
172 isEqual(other: Bytes): boolean;
173}
174/* Excluded from this release type: _ByteString */
175/**
176 * Constant used to indicate the LRU garbage collection should be disabled.
177 * Set this value as the `cacheSizeBytes` on the settings passed to the
178 * {@link Firestore} instance.
179 */
180export declare const CACHE_SIZE_UNLIMITED = -1;
181/**
182 * Helper for calculating the nested fields for a given type T1. This is needed
183 * to distribute union types such as `undefined | {...}` (happens for optional
184 * props) or `{a: A} | {b: B}`.
185 *
186 * In this use case, `V` is used to distribute the union types of `T[K]` on
187 * `Record`, since `T[K]` is evaluated as an expression and not distributed.
188 *
189 * See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
190 */
191export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;
192/**
193 * Clears the persistent storage. This includes pending writes and cached
194 * documents.
195 *
196 * Must be called while the {@link Firestore} instance is not started (after the app is
197 * terminated or when the app is first initialized). On startup, this function
198 * must be called before other functions (other than {@link
199 * initializeFirestore} or {@link (getFirestore:1)})). If the {@link Firestore}
200 * instance is still running, the promise will be rejected with the error code
201 * of `failed-precondition`.
202 *
203 * Note: `clearIndexedDbPersistence()` is primarily intended to help write
204 * reliable tests that use Cloud Firestore. It uses an efficient mechanism for
205 * dropping existing data but does not attempt to securely overwrite or
206 * otherwise make cached data unrecoverable. For applications that are sensitive
207 * to the disclosure of cached data in between user sessions, we strongly
208 * recommend not enabling persistence at all.
209 *
210 * @param firestore - The {@link Firestore} instance to clear persistence for.
211 * @returns A `Promise` that is resolved when the persistent storage is
212 * cleared. Otherwise, the promise is rejected with an error.
213 */
214export declare function clearIndexedDbPersistence(firestore: Firestore): Promise<void>;
215/**
216 * Gets a `CollectionReference` instance that refers to the collection at
217 * the specified absolute path.
218 *
219 * @param firestore - A reference to the root `Firestore` instance.
220 * @param path - A slash-separated path to a collection.
221 * @param pathSegments - Additional path segments to apply relative to the first
222 * argument.
223 * @throws If the final path has an even number of segments and does not point
224 * to a collection.
225 * @returns The `CollectionReference` instance.
226 */
227export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
228/**
229 * Gets a `CollectionReference` instance that refers to a subcollection of
230 * `reference` at the the specified relative path.
231 *
232 * @param reference - A reference to a collection.
233 * @param path - A slash-separated path to a collection.
234 * @param pathSegments - Additional path segments to apply relative to the first
235 * argument.
236 * @throws If the final path has an even number of segments and does not point
237 * to a collection.
238 * @returns The `CollectionReference` instance.
239 */
240export declare function collection(reference: CollectionReference<unknown>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
241/**
242 * Gets a `CollectionReference` instance that refers to a subcollection of
243 * `reference` at the the specified relative path.
244 *
245 * @param reference - A reference to a Firestore document.
246 * @param path - A slash-separated path to a collection.
247 * @param pathSegments - Additional path segments that will be applied relative
248 * to the first argument.
249 * @throws If the final path has an even number of segments and does not point
250 * to a collection.
251 * @returns The `CollectionReference` instance.
252 */
253export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
254/**
255 * Creates and returns a new `Query` instance that includes all documents in the
256 * database that are contained in a collection or subcollection with the
257 * given `collectionId`.
258 *
259 * @param firestore - A reference to the root `Firestore` instance.
260 * @param collectionId - Identifies the collections to query over. Every
261 * collection or subcollection with this ID as the last segment of its path
262 * will be included. Cannot contain a slash.
263 * @returns The created `Query`.
264 */
265export declare function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData>;
266/**
267 * A `CollectionReference` object can be used for adding documents, getting
268 * document references, and querying for documents (using {@link (query:1)}).
269 */
270export declare class CollectionReference<T = DocumentData> extends Query<T> {
271 /** The type of this Firestore reference. */
272 readonly type = "collection";
273 private constructor();
274 /** The collection's identifier. */
275 get id(): string;
276 /**
277 * A string representing the path of the referenced collection (relative
278 * to the root of the database).
279 */
280 get path(): string;
281 /**
282 * A reference to the containing `DocumentReference` if this is a
283 * subcollection. If this isn't a subcollection, the reference is null.
284 */
285 get parent(): DocumentReference<DocumentData> | null;
286 /**
287 * Applies a custom data converter to this `CollectionReference`, allowing you
288 * to use your own custom model objects with Firestore. When you call {@link
289 * addDoc} with the returned `CollectionReference` instance, the provided
290 * converter will convert between Firestore data and your custom type `U`.
291 *
292 * @param converter - Converts objects to and from Firestore.
293 * @returns A `CollectionReference<U>` that uses the provided converter.
294 */
295 withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
296 /**
297 * Removes the current converter.
298 *
299 * @param converter - `null` removes the current converter.
300 * @returns A `CollectionReference<DocumentData>` that does not use a
301 * converter.
302 */
303 withConverter(converter: null): CollectionReference<DocumentData>;
304}
305/**
306 * Modify this instance to communicate with the Cloud Firestore emulator.
307 *
308 * Note: This must be called before this instance has been used to do any
309 * operations.
310 *
311 * @param firestore - The `Firestore` instance to configure to connect to the
312 * emulator.
313 * @param host - the emulator host (ex: localhost).
314 * @param port - the emulator port (ex: 9000).
315 * @param options.mockUserToken - the mock auth token to use for unit testing
316 * Security Rules.
317 */
318export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
319 mockUserToken?: EmulatorMockTokenOptions | string;
320}): void;
321/**
322 * Deletes the document referred to by the specified `DocumentReference`.
323 *
324 * @param reference - A reference to the document to delete.
325 * @returns A Promise resolved once the document has been successfully
326 * deleted from the backend (note that it won't resolve while you're offline).
327 */
328export declare function deleteDoc(reference: DocumentReference<unknown>): Promise<void>;
329/**
330 * Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
331 * {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
332 */
333export declare function deleteField(): FieldValue;
334/**
335 * Disables network usage for this instance. It can be re-enabled via {@link
336 * enableNetwork}. While the network is disabled, any snapshot listeners,
337 * `getDoc()` or `getDocs()` calls will return results from cache, and any write
338 * operations will be queued until the network is restored.
339 *
340 * @returns A `Promise` that is resolved once the network has been disabled.
341 */
342export declare function disableNetwork(firestore: Firestore): Promise<void>;
343/**
344 * Gets a `DocumentReference` instance that refers to the document at the
345 * specified absolute path.
346 *
347 * @param firestore - A reference to the root `Firestore` instance.
348 * @param path - A slash-separated path to a document.
349 * @param pathSegments - Additional path segments that will be applied relative
350 * to the first argument.
351 * @throws If the final path has an odd number of segments and does not point to
352 * a document.
353 * @returns The `DocumentReference` instance.
354 */
355export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
356/**
357 * Gets a `DocumentReference` instance that refers to a document within
358 * `reference` at the specified relative path. If no path is specified, an
359 * automatically-generated unique ID will be used for the returned
360 * `DocumentReference`.
361 *
362 * @param reference - A reference to a collection.
363 * @param path - A slash-separated path to a document. Has to be omitted to use
364 * auto-genrated IDs.
365 * @param pathSegments - Additional path segments that will be applied relative
366 * to the first argument.
367 * @throws If the final path has an odd number of segments and does not point to
368 * a document.
369 * @returns The `DocumentReference` instance.
370 */
371export declare function doc<T>(reference: CollectionReference<T>, path?: string, ...pathSegments: string[]): DocumentReference<T>;
372/**
373 * Gets a `DocumentReference` instance that refers to a document within
374 * `reference` at the specified relative path.
375 *
376 * @param reference - A reference to a Firestore document.
377 * @param path - A slash-separated path to a document.
378 * @param pathSegments - Additional path segments that will be applied relative
379 * to the first argument.
380 * @throws If the final path has an odd number of segments and does not point to
381 * a document.
382 * @returns The `DocumentReference` instance.
383 */
384export declare function doc(reference: DocumentReference<unknown>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
385/**
386 * A `DocumentChange` represents a change to the documents matching a query.
387 * It contains the document affected and the type of change that occurred.
388 */
389export declare interface DocumentChange<T = DocumentData> {
390 /** The type of change ('added', 'modified', or 'removed'). */
391 readonly type: DocumentChangeType;
392 /** The document affected by this change. */
393 readonly doc: QueryDocumentSnapshot<T>;
394 /**
395 * The index of the changed document in the result set immediately prior to
396 * this `DocumentChange` (i.e. supposing that all prior `DocumentChange` objects
397 * have been applied). Is `-1` for 'added' events.
398 */
399 readonly oldIndex: number;
400 /**
401 * The index of the changed document in the result set immediately after
402 * this `DocumentChange` (i.e. supposing that all prior `DocumentChange`
403 * objects and the current `DocumentChange` object have been applied).
404 * Is -1 for 'removed' events.
405 */
406 readonly newIndex: number;
407}
408/**
409 * The type of a `DocumentChange` may be 'added', 'removed', or 'modified'.
410 */
411export declare type DocumentChangeType = 'added' | 'removed' | 'modified';
412/**
413 * Document data (for use with {@link @firebase/firestore/lite#(setDoc:1)}) consists of fields mapped to
414 * values.
415 */
416export declare interface DocumentData {
417 /** A mapping between a field and its value. */
418 [field: string]: any;
419}
420/**
421 * Returns a special sentinel `FieldPath` to refer to the ID of a document.
422 * It can be used in queries to sort or filter by the document ID.
423 */
424export declare function documentId(): FieldPath;
425/**
426 * A `DocumentReference` refers to a document location in a Firestore database
427 * and can be used to write, read, or listen to the location. The document at
428 * the referenced location may or may not exist.
429 */
430export declare class DocumentReference<T = DocumentData> {
431 /**
432 * If provided, the `FirestoreDataConverter` associated with this instance.
433 */
434 readonly converter: FirestoreDataConverter<T> | null;
435 /** The type of this Firestore reference. */
436 readonly type = "document";
437 /**
438 * The {@link Firestore} instance the document is in.
439 * This is useful for performing transactions, for example.
440 */
441 readonly firestore: Firestore;
442 private constructor();
443 /**
444 * The document's identifier within its collection.
445 */
446 get id(): string;
447 /**
448 * A string representing the path of the referenced document (relative
449 * to the root of the database).
450 */
451 get path(): string;
452 /**
453 * The collection this `DocumentReference` belongs to.
454 */
455 get parent(): CollectionReference<T>;
456 /**
457 * Applies a custom data converter to this `DocumentReference`, allowing you
458 * to use your own custom model objects with Firestore. When you call {@link
459 * @firebase/firestore/lite#(setDoc:1)}, {@link @firebase/firestore/lite#getDoc}, etc. with the returned `DocumentReference`
460 * instance, the provided converter will convert between Firestore data and
461 * your custom type `U`.
462 *
463 * @param converter - Converts objects to and from Firestore.
464 * @returns A `DocumentReference<U>` that uses the provided converter.
465 */
466 withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
467 /**
468 * Removes the current converter.
469 *
470 * @param converter - `null` removes the current converter.
471 * @returns A `DocumentReference<DocumentData>` that does not use a converter.
472 */
473 withConverter(converter: null): DocumentReference<DocumentData>;
474}
475/**
476 * A `DocumentSnapshot` contains data read from a document in your Firestore
477 * database. The data can be extracted with `.data()` or `.get(<field>)` to
478 * get a specific field.
479 *
480 * For a `DocumentSnapshot` that points to a non-existing document, any data
481 * access will return 'undefined'. You can use the `exists()` method to
482 * explicitly verify a document's existence.
483 */
484export declare class DocumentSnapshot<T = DocumentData> {
485 /**
486 * Metadata about the `DocumentSnapshot`, including information about its
487 * source and local modifications.
488 */
489 readonly metadata: SnapshotMetadata;
490 protected constructor();
491 /**
492 * Returns whether or not the data exists. True if the document exists.
493 */
494 exists(): this is QueryDocumentSnapshot<T>;
495 /**
496 * Retrieves all fields in the document as an `Object`. Returns `undefined` if
497 * the document doesn't exist.
498 *
499 * By default, `serverTimestamp()` values that have not yet been
500 * set to their final value will be returned as `null`. You can override
501 * this by passing an options object.
502 *
503 * @param options - An options object to configure how data is retrieved from
504 * the snapshot (for example the desired behavior for server timestamps that
505 * have not yet been set to their final value).
506 * @returns An `Object` containing all fields in the document or `undefined` if
507 * the document doesn't exist.
508 */
509 data(options?: SnapshotOptions): T | undefined;
510 /**
511 * Retrieves the field specified by `fieldPath`. Returns `undefined` if the
512 * document or field doesn't exist.
513 *
514 * By default, a `serverTimestamp()` that has not yet been set to
515 * its final value will be returned as `null`. You can override this by
516 * passing an options object.
517 *
518 * @param fieldPath - The path (for example 'foo' or 'foo.bar') to a specific
519 * field.
520 * @param options - An options object to configure how the field is retrieved
521 * from the snapshot (for example the desired behavior for server timestamps
522 * that have not yet been set to their final value).
523 * @returns The data at the specified field location or undefined if no such
524 * field exists in the document.
525 */
526 get(fieldPath: string | FieldPath, options?: SnapshotOptions): any;
527 /**
528 * Property of the `DocumentSnapshot` that provides the document's ID.
529 */
530 get id(): string;
531 /**
532 * The `DocumentReference` for the document included in the `DocumentSnapshot`.
533 */
534 get ref(): DocumentReference<T>;
535}
536/* Excluded from this release type: _EmptyAppCheckTokenProvider */
537/* Excluded from this release type: _EmptyAuthCredentialsProvider */
538export { EmulatorMockTokenOptions };
539/**
540 * Attempts to enable persistent storage, if possible.
541 *
542 * Must be called before any other functions (other than
543 * {@link initializeFirestore}, {@link (getFirestore:1)} or
544 * {@link clearIndexedDbPersistence}.
545 *
546 * If this fails, `enableIndexedDbPersistence()` will reject the promise it
547 * returns. Note that even after this failure, the {@link Firestore} instance will
548 * remain usable, however offline persistence will be disabled.
549 *
550 * There are several reasons why this can fail, which can be identified by
551 * the `code` on the error.
552 *
553 * * failed-precondition: The app is already open in another browser tab.
554 * * unimplemented: The browser is incompatible with the offline
555 * persistence implementation.
556 *
557 * @param firestore - The {@link Firestore} instance to enable persistence for.
558 * @param persistenceSettings - Optional settings object to configure
559 * persistence.
560 * @returns A `Promise` that represents successfully enabling persistent storage.
561 */
562export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;
563/**
564 * Attempts to enable multi-tab persistent storage, if possible. If enabled
565 * across all tabs, all operations share access to local persistence, including
566 * shared execution of queries and latency-compensated local document updates
567 * across all connected instances.
568 *
569 * If this fails, `enableMultiTabIndexedDbPersistence()` will reject the promise
570 * it returns. Note that even after this failure, the {@link Firestore} instance will
571 * remain usable, however offline persistence will be disabled.
572 *
573 * There are several reasons why this can fail, which can be identified by
574 * the `code` on the error.
575 *
576 * * failed-precondition: The app is already open in another browser tab and
577 * multi-tab is not enabled.
578 * * unimplemented: The browser is incompatible with the offline
579 * persistence implementation.
580 *
581 * @param firestore - The {@link Firestore} instance to enable persistence for.
582 * @returns A `Promise` that represents successfully enabling persistent
583 * storage.
584 */
585export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;
586/**
587 * Re-enables use of the network for this {@link Firestore} instance after a prior
588 * call to {@link disableNetwork}.
589 *
590 * @returns A `Promise` that is resolved once the network has been enabled.
591 */
592export declare function enableNetwork(firestore: Firestore): Promise<void>;
593/**
594 * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
595 * the provided document (inclusive). The end position is relative to the order
596 * of the query. The document must contain all of the fields provided in the
597 * orderBy of the query.
598 *
599 * @param snapshot - The snapshot of the document to end at.
600 * @returns A {@link QueryEndAtConstraint} to pass to `query()`
601 */
602export declare function endAt(snapshot: DocumentSnapshot<unknown>): QueryEndAtConstraint;
603/**
604 * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
605 * the provided fields relative to the order of the query. The order of the field
606 * values must match the order of the order by clauses of the query.
607 *
608 * @param fieldValues - The field values to end this query at, in order
609 * of the query's order by.
610 * @returns A {@link QueryEndAtConstraint} to pass to `query()`
611 */
612export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint;
613/**
614 * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
615 * before the provided document (exclusive). The end position is relative to the
616 * order of the query. The document must contain all of the fields provided in
617 * the orderBy of the query.
618 *
619 * @param snapshot - The snapshot of the document to end before.
620 * @returns A {@link QueryEndAtConstraint} to pass to `query()`
621 */
622export declare function endBefore(snapshot: DocumentSnapshot<unknown>): QueryEndAtConstraint;
623/**
624 * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
625 * before the provided fields relative to the order of the query. The order of
626 * the field values must match the order of the order by clauses of the query.
627 *
628 * @param fieldValues - The field values to end this query before, in order
629 * of the query's order by.
630 * @returns A {@link QueryEndAtConstraint} to pass to `query()`
631 */
632export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint;
633/**
634 * A `FieldPath` refers to a field in a document. The path may consist of a
635 * single field name (referring to a top-level field in the document), or a
636 * list of field names (referring to a nested field in the document).
637 *
638 * Create a `FieldPath` by providing field names. If more than one field
639 * name is provided, the path will point to a nested field in a document.
640 */
641export declare class FieldPath {
642 /**
643 * Creates a `FieldPath` from the provided field names. If more than one field
644 * name is provided, the path will point to a nested field in a document.
645 *
646 * @param fieldNames - A list of field names.
647 */
648 constructor(...fieldNames: string[]);
649 /**
650 * Returns true if this `FieldPath` is equal to the provided one.
651 *
652 * @param other - The `FieldPath` to compare against.
653 * @returns true if this `FieldPath` is equal to the provided one.
654 */
655 isEqual(other: FieldPath): boolean;
656}
657/**
658 * Sentinel values that can be used when writing document fields with `set()`
659 * or `update()`.
660 */
661export declare abstract class FieldValue {
662 private constructor();
663 /** Compares `FieldValue`s for equality. */
664 abstract isEqual(other: FieldValue): boolean;
665}
666/* Excluded from this release type: _FirebaseService */
667/**
668 * The Cloud Firestore service interface.
669 *
670 * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
671 */
672export declare class Firestore {
673 /**
674 * Whether it's a {@link Firestore} or Firestore Lite instance.
675 */
676 type: 'firestore-lite' | 'firestore';
677 private constructor();
678 /**
679 * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
680 * instance.
681 */
682 get app(): FirebaseApp;
683 /**
684 * Returns a JSON-serializable representation of this `Firestore` instance.
685 */
686 toJSON(): object;
687}
688/**
689 * Converter used by `withConverter()` to transform user objects of type `T`
690 * into Firestore data.
691 *
692 * Using the converter allows you to specify generic type arguments when
693 * storing and retrieving objects from Firestore.
694 *
695 * @example
696 * ```typescript
697 * class Post {
698 * constructor(readonly title: string, readonly author: string) {}
699 *
700 * toString(): string {
701 * return this.title + ', by ' + this.author;
702 * }
703 * }
704 *
705 * const postConverter = {
706 * toFirestore(post: WithFieldValue<Post>): DocumentData {
707 * return {title: post.title, author: post.author};
708 * },
709 * fromFirestore(
710 * snapshot: QueryDocumentSnapshot,
711 * options: SnapshotOptions
712 * ): Post {
713 * const data = snapshot.data(options)!;
714 * return new Post(data.title, data.author);
715 * }
716 * };
717 *
718 * const postSnap = await firebase.firestore()
719 * .collection('posts')
720 * .withConverter(postConverter)
721 * .doc().get();
722 * const post = postSnap.data();
723 * if (post !== undefined) {
724 * post.title; // string
725 * post.toString(); // Should be defined
726 * post.someNonExistentProperty; // TS error
727 * }
728 * ```
729 */
730export declare interface FirestoreDataConverter<T> {
731 /**
732 * Called by the Firestore SDK to convert a custom model object of type `T`
733 * into a plain JavaScript object (suitable for writing directly to the
734 * Firestore database). To use `set()` with `merge` and `mergeFields`,
735 * `toFirestore()` must be defined with `PartialWithFieldValue<T>`.
736 *
737 * The `WithFieldValue<T>` type extends `T` to also allow FieldValues such as
738 * {@link (deleteField:1)} to be used as property values.
739 */
740 toFirestore(modelObject: WithFieldValue<T>): DocumentData;
741 /**
742 * Called by the Firestore SDK to convert a custom model object of type `T`
743 * into a plain JavaScript object (suitable for writing directly to the
744 * Firestore database). Used with {@link (setDoc:1)}, {@link (WriteBatch.set:1)}
745 * and {@link (Transaction.set:1)} with `merge:true` or `mergeFields`.
746 *
747 * The `PartialWithFieldValue<T>` type extends `Partial<T>` to allow
748 * FieldValues such as {@link (arrayUnion:1)} to be used as property values.
749 * It also supports nested `Partial` by allowing nested fields to be
750 * omitted.
751 */
752 toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions): DocumentData;
753 /**
754 * Called by the Firestore SDK to convert Firestore data into an object of
755 * type T. You can access your data by calling: `snapshot.data(options)`.
756 *
757 * @param snapshot - A `QueryDocumentSnapshot` containing your data and metadata.
758 * @param options - The `SnapshotOptions` from the initial call to `data()`.
759 */
760 fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>, options?: SnapshotOptions): T;
761}
762/** An error returned by a Firestore operation. */
763export declare class FirestoreError extends FirebaseError {
764 /**
765 * The backend error code associated with this error.
766 */
767 readonly code: FirestoreErrorCode;
768 /**
769 * A custom error description.
770 */
771 readonly message: string;
772 /** The stack of the error. */
773 readonly stack?: string;
774 private constructor();
775}
776/**
777 * The set of Firestore status codes. The codes are the same at the ones
778 * exposed by gRPC here:
779 * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
780 *
781 * Possible values:
782 * - 'cancelled': The operation was cancelled (typically by the caller).
783 * - 'unknown': Unknown error or an error from a different error domain.
784 * - 'invalid-argument': Client specified an invalid argument. Note that this
785 * differs from 'failed-precondition'. 'invalid-argument' indicates
786 * arguments that are problematic regardless of the state of the system
787 * (e.g. an invalid field name).
788 * - 'deadline-exceeded': Deadline expired before operation could complete.
789 * For operations that change the state of the system, this error may be
790 * returned even if the operation has completed successfully. For example,
791 * a successful response from a server could have been delayed long enough
792 * for the deadline to expire.
793 * - 'not-found': Some requested document was not found.
794 * - 'already-exists': Some document that we attempted to create already
795 * exists.
796 * - 'permission-denied': The caller does not have permission to execute the
797 * specified operation.
798 * - 'resource-exhausted': Some resource has been exhausted, perhaps a
799 * per-user quota, or perhaps the entire file system is out of space.
800 * - 'failed-precondition': Operation was rejected because the system is not
801 * in a state required for the operation's execution.
802 * - 'aborted': The operation was aborted, typically due to a concurrency
803 * issue like transaction aborts, etc.
804 * - 'out-of-range': Operation was attempted past the valid range.
805 * - 'unimplemented': Operation is not implemented or not supported/enabled.
806 * - 'internal': Internal errors. Means some invariants expected by
807 * underlying system has been broken. If you see one of these errors,
808 * something is very broken.
809 * - 'unavailable': The service is currently unavailable. This is most likely
810 * a transient condition and may be corrected by retrying with a backoff.
811 * - 'data-loss': Unrecoverable data loss or corruption.
812 * - 'unauthenticated': The request does not have valid authentication
813 * credentials for the operation.
814 */
815export declare type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';
816/**
817 * Specifies custom configurations for your Cloud Firestore instance.
818 * You must set these before invoking any other methods.
819 */
820export declare interface FirestoreSettings {
821 /**
822 * An approximate cache size threshold for the on-disk data. If the cache
823 * grows beyond this size, Firestore will start removing data that hasn't been
824 * recently used. The size is not a guarantee that the cache will stay below
825 * that size, only that if the cache exceeds the given size, cleanup will be
826 * attempted.
827 *
828 * The default value is 40 MB. The threshold must be set to at least 1 MB, and
829 * can be set to `CACHE_SIZE_UNLIMITED` to disable garbage collection.
830 */
831 cacheSizeBytes?: number;
832 /**
833 * Forces the SDK’s underlying network transport (WebChannel) to use
834 * long-polling. Each response from the backend will be closed immediately
835 * after the backend sends data (by default responses are kept open in
836 * case the backend has more data to send). This avoids incompatibility
837 * issues with certain proxies, antivirus software, etc. that incorrectly
838 * buffer traffic indefinitely. Use of this option will cause some
839 * performance degradation though.
840 *
841 * This setting cannot be used with `experimentalAutoDetectLongPolling` and
842 * may be removed in a future release. If you find yourself using it to
843 * work around a specific network reliability issue, please tell us about
844 * it in https://github.com/firebase/firebase-js-sdk/issues/1674.
845 */
846 experimentalForceLongPolling?: boolean;
847 /**
848 * Configures the SDK's underlying transport (WebChannel) to automatically
849 * detect if long-polling should be used. This is very similar to
850 * `experimentalForceLongPolling`, but only uses long-polling if required.
851 *
852 * This setting will likely be enabled by default in future releases and
853 * cannot be combined with `experimentalForceLongPolling`.
854 */
855 experimentalAutoDetectLongPolling?: boolean;
856 /**
857 * The hostname to connect to.
858 */
859 host?: string;
860 /**
861 * Whether to use SSL when connecting.
862 */
863 ssl?: boolean;
864 /**
865 * Whether to skip nested properties that are set to `undefined` during
866 * object serialization. If set to `true`, these properties are skipped
867 * and not written to Firestore. If set to `false` or omitted, the SDK
868 * throws an exception when it encounters properties of type `undefined`.
869 */
870 ignoreUndefinedProperties?: boolean;
871}
872/**
873 * @license
874 * Copyright 2017 Google LLC
875 *
876 * Licensed under the Apache License, Version 2.0 (the "License");
877 * you may not use this file except in compliance with the License.
878 * You may obtain a copy of the License at
879 *
880 * http://www.apache.org/licenses/LICENSE-2.0
881 *
882 * Unless required by applicable law or agreed to in writing, software
883 * distributed under the License is distributed on an "AS IS" BASIS,
884 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
885 * See the License for the specific language governing permissions and
886 * limitations under the License.
887 */
888/**
889 * An immutable object representing a geographic location in Firestore. The
890 * location is represented as latitude/longitude pair.
891 *
892 * Latitude values are in the range of [-90, 90].
893 * Longitude values are in the range of [-180, 180].
894 */
895export declare class GeoPoint {
896 /**
897 * Creates a new immutable `GeoPoint` object with the provided latitude and
898 * longitude values.
899 * @param latitude - The latitude as number between -90 and 90.
900 * @param longitude - The longitude as number between -180 and 180.
901 */
902 constructor(latitude: number, longitude: number);
903 /**
904 * The latitude of this `GeoPoint` instance.
905 */
906 get latitude(): number;
907 /**
908 * The longitude of this `GeoPoint` instance.
909 */
910 get longitude(): number;
911 /**
912 * Returns true if this `GeoPoint` is equal to the provided one.
913 *
914 * @param other - The `GeoPoint` to compare against.
915 * @returns true if this `GeoPoint` is equal to the provided one.
916 */
917 isEqual(other: GeoPoint): boolean;
918 /** Returns a JSON-serializable representation of this GeoPoint. */
919 toJSON(): {
920 latitude: number;
921 longitude: number;
922 };
923}
924/* Excluded from this release type: getAggregateFromServer */
925/**
926 * Calculates the number of documents in the result set of the given query,
927 * without actually downloading the documents.
928 *
929 * Using this function to count the documents is efficient because only the
930 * final count, not the documents' data, is downloaded. This function can even
931 * count the documents if the result set would be prohibitively large to
932 * download entirely (e.g. thousands of documents).
933 *
934 * The result received from the server is presented, unaltered, without
935 * considering any local state. That is, documents in the local cache are not
936 * taken into consideration, neither are local modifications not yet
937 * synchronized with the server. Previously-downloaded results, if any, are not
938 * used: every request using this source necessarily involves a round trip to
939 * the server.
940 *
941 * @param query - The query whose result set size to calculate.
942 * @returns A Promise that will be resolved with the count; the count can be
943 * retrieved from `snapshot.data().count`, where `snapshot` is the
944 * `AggregateQuerySnapshot` to which the returned Promise resolves.
945 */
946export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
947 count: AggregateField<number>;
948}>>;
949/**
950 * Reads the document referred to by this `DocumentReference`.
951 *
952 * Note: `getDoc()` attempts to provide up-to-date data when possible by waiting
953 * for data from the server, but it may return cached data or fail if you are
954 * offline and the server cannot be reached. To specify this behavior, invoke
955 * {@link getDocFromCache} or {@link getDocFromServer}.
956 *
957 * @param reference - The reference of the document to fetch.
958 * @returns A Promise resolved with a `DocumentSnapshot` containing the
959 * current document contents.
960 */
961export declare function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
962/**
963 * Reads the document referred to by this `DocumentReference` from cache.
964 * Returns an error if the document is not currently cached.
965 *
966 * @returns A `Promise` resolved with a `DocumentSnapshot` containing the
967 * current document contents.
968 */
969export declare function getDocFromCache<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
970/**
971 * Reads the document referred to by this `DocumentReference` from the server.
972 * Returns an error if the network is not available.
973 *
974 * @returns A `Promise` resolved with a `DocumentSnapshot` containing the
975 * current document contents.
976 */
977export declare function getDocFromServer<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
978/**
979 * Executes the query and returns the results as a `QuerySnapshot`.
980 *
981 * Note: `getDocs()` attempts to provide up-to-date data when possible by
982 * waiting for data from the server, but it may return cached data or fail if
983 * you are offline and the server cannot be reached. To specify this behavior,
984 * invoke {@link getDocsFromCache} or {@link getDocsFromServer}.
985 *
986 * @returns A `Promise` that will be resolved with the results of the query.
987 */
988export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
989/**
990 * Executes the query and returns the results as a `QuerySnapshot` from cache.
991 * Returns an empty result set if no documents matching the query are currently
992 * cached.
993 *
994 * @returns A `Promise` that will be resolved with the results of the query.
995 */
996export declare function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
997/**
998 * Executes the query and returns the results as a `QuerySnapshot` from the
999 * server. Returns an error if the network is not available.
1000 *
1001 * @returns A `Promise` that will be resolved with the results of the query.
1002 */
1003export declare function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
1004/**
1005 * Returns the existing default {@link Firestore} instance that is associated with the
1006 * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
1007 * instance with default settings.
1008 *
1009 * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
1010 * instance is associated with.
1011 * @returns The {@link Firestore} instance of the provided app.
1012 */
1013export declare function getFirestore(app: FirebaseApp): Firestore;
1014/* Excluded declaration from this release type: getFirestore */
1015/**
1016 * Returns the existing default {@link Firestore} instance that is associated with the
1017 * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
1018 * instance with default settings.
1019 *
1020 * @returns The {@link Firestore} instance of the provided app.
1021 */
1022export declare function getFirestore(): Firestore;
1023/* Excluded declaration from this release type: getFirestore */
1024/**
1025 * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
1026 * @firebase/firestore/lite#(updateDoc:1)} that tells the server to increment the field's current value by
1027 * the given value.
1028 *
1029 * If either the operand or the current field value uses floating point
1030 * precision, all arithmetic follows IEEE 754 semantics. If both values are
1031 * integers, values outside of JavaScript's safe number range
1032 * (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to
1033 * precision loss. Furthermore, once processed by the Firestore backend, all
1034 * integer operations are capped between -2^63 and 2^63-1.
1035 *
1036 * If the current field value is not of type `number`, or if the field does not
1037 * yet exist, the transformation sets the field to the given value.
1038 *
1039 * @param n - The value to increment by.
1040 * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
1041 * `updateDoc()`
1042 */
1043export declare function increment(n: number): FieldValue;
1044/**
1045 * The SDK definition of a Firestore index.
1046 * @beta
1047 */
1048export declare interface Index {
1049 /** The ID of the collection to index. */
1050 readonly collectionGroup: string;
1051 /** A list of fields to index. */
1052 readonly fields?: IndexField[];
1053 [key: string]: unknown;
1054}
1055/**
1056 * A list of Firestore indexes to speed up local query execution.
1057 *
1058 * See {@link https://firebase.google.com/docs/reference/firestore/indexes/#json_format | JSON Format}
1059 * for a description of the format of the index definition.
1060 * @beta
1061 */
1062export declare interface IndexConfiguration {
1063 /** A list of all Firestore indexes. */
1064 readonly indexes?: Index[];
1065 [key: string]: unknown;
1066}
1067/**
1068 * A single field element in an index configuration.
1069 * @beta
1070 */
1071export declare interface IndexField {
1072 /** The field path to index. */
1073 readonly fieldPath: string;
1074 /**
1075 * What type of array index to create. Set to `CONTAINS` for `array-contains`
1076 * and `array-contains-any` indexes.
1077 *
1078 * Only one of `arrayConfig` or `order` should be set;
1079 */
1080 readonly arrayConfig?: 'CONTAINS';
1081 /**
1082 * What type of array index to create. Set to `ASCENDING` or 'DESCENDING` for
1083 * `==`, `!=`, `<=`, `<=`, `in` and `not-in` filters.
1084 *
1085 * Only one of `arrayConfig` or `order` should be set.
1086 */
1087 readonly order?: 'ASCENDING' | 'DESCENDING';
1088 [key: string]: unknown;
1089}
1090/**
1091 * Initializes a new instance of {@link Firestore} with the provided settings.
1092 * Can only be called before any other function, including
1093 * {@link (getFirestore:1)}. If the custom settings are empty, this function is
1094 * equivalent to calling {@link (getFirestore:1)}.
1095 *
1096 * @param app - The {@link @firebase/app#FirebaseApp} with which the {@link Firestore} instance will
1097 * be associated.
1098 * @param settings - A settings object to configure the {@link Firestore} instance.
1099 * @param databaseId - The name of database.
1100 * @returns A newly initialized {@link Firestore} instance.
1101 */
1102export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;
1103/* Excluded from this release type: _isBase64Available */
1104/**
1105 * Creates a {@link QueryLimitConstraint} that only returns the first matching
1106 * documents.
1107 *
1108 * @param limit - The maximum number of items to return.
1109 * @returns The created {@link QueryLimitConstraint}.
1110 */
1111export declare function limit(limit: number): QueryLimitConstraint;
1112/**
1113 * Creates a {@link QueryLimitConstraint} that only returns the last matching
1114 * documents.
1115 *
1116 * You must specify at least one `orderBy` clause for `limitToLast` queries,
1117 * otherwise an exception will be thrown during execution.
1118 *
1119 * @param limit - The maximum number of items to return.
1120 * @returns The created {@link QueryLimitConstraint}.
1121 */
1122export declare function limitToLast(limit: number): QueryLimitConstraint;
1123/**
1124 * Loads a Firestore bundle into the local cache.
1125 *
1126 * @param firestore - The {@link Firestore} instance to load bundles for.
1127 * @param bundleData - An object representing the bundle to be loaded. Valid
1128 * objects are `ArrayBuffer`, `ReadableStream<Uint8Array>` or `string`.
1129 *
1130 * @returns A `LoadBundleTask` object, which notifies callers with progress
1131 * updates, and completion or error events. It can be used as a
1132 * `Promise<LoadBundleTaskProgress>`.
1133 */
1134export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;
1135/**
1136 * Represents the task of loading a Firestore bundle. It provides progress of bundle
1137 * loading, as well as task completion and error events.
1138 *
1139 * The API is compatible with `Promise<LoadBundleTaskProgress>`.
1140 */
1141export declare class LoadBundleTask implements PromiseLike<LoadBundleTaskProgress> {
1142 /**
1143 * Registers functions to listen to bundle loading progress events.
1144 * @param next - Called when there is a progress update from bundle loading. Typically `next` calls occur
1145 * each time a Firestore document is loaded from the bundle.
1146 * @param error - Called when an error occurs during bundle loading. The task aborts after reporting the
1147 * error, and there should be no more updates after this.
1148 * @param complete - Called when the loading task is complete.
1149 */
1150 onProgress(next?: (progress: LoadBundleTaskProgress) => unknown, error?: (err: Error) => unknown, complete?: () => void): void;
1151 /**
1152 * Implements the `Promise<LoadBundleTaskProgress>.catch` interface.
1153 *
1154 * @param onRejected - Called when an error occurs during bundle loading.
1155 */
1156 catch<R>(onRejected: (a: Error) => R | PromiseLike<R>): Promise<R | LoadBundleTaskProgress>;
1157 /**
1158 * Implements the `Promise<LoadBundleTaskProgress>.then` interface.
1159 *
1160 * @param onFulfilled - Called on the completion of the loading task with a final `LoadBundleTaskProgress` update.
1161 * The update will always have its `taskState` set to `"Success"`.
1162 * @param onRejected - Called when an error occurs during bundle loading.
1163 */
1164 then<T, R>(onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>, onRejected?: (a: Error) => R | PromiseLike<R>): Promise<T | R>;
1165}
1166/**
1167 * Represents a progress update or a final state from loading bundles.
1168 */
1169export declare interface LoadBundleTaskProgress {
1170 /** How many documents have been loaded. */
1171 documentsLoaded: number;
1172 /** How many documents are in the bundle being loaded. */
1173 totalDocuments: number;
1174 /** How many bytes have been loaded. */
1175 bytesLoaded: number;
1176 /** How many bytes are in the bundle being loaded. */
1177 totalBytes: number;
1178 /** Current task state. */
1179 taskState: TaskState;
1180}
1181export { LogLevel };
1182/**
1183 * Reads a Firestore {@link Query} from local cache, identified by the given
1184 * name.
1185 *
1186 * The named queries are packaged into bundles on the server side (along
1187 * with resulting documents), and loaded to local cache using `loadBundle`. Once
1188 * in local cache, use this method to extract a {@link Query} by name.
1189 *
1190 * @param firestore - The {@link Firestore} instance to read the query from.
1191 * @param name - The name of the query.
1192 * @returns A `Promise` that is resolved with the Query or `null`.
1193 */
1194export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
1195/**
1196 * For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1,
1197 * 'bar.qux': T2}). Intersect them together to make a single map containing
1198 * all possible keys that are all marked as optional
1199 */
1200export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{
1201 [K in keyof T & string]: ChildUpdateFields<K, T[K]>;
1202}[keyof T & string]>;
1203/**
1204 * Attaches a listener for `DocumentSnapshot` events. You may either pass
1205 * individual `onNext` and `onError` callbacks or pass a single observer
1206 * object with `next` and `error` callbacks.
1207 *
1208 * NOTE: Although an `onCompletion` callback can be provided, it will
1209 * never be called because the snapshot stream is never-ending.
1210 *
1211 * @param reference - A reference to the document to listen to.
1212 * @param observer - A single object containing `next` and `error` callbacks.
1213 * @returns An unsubscribe function that can be called to cancel
1214 * the snapshot listener.
1215 */
1216export declare function onSnapshot<T>(reference: DocumentReference<T>, observer: {
1217 next?: (snapshot: DocumentSnapshot<T>) => void;
1218 error?: (error: FirestoreError) => void;
1219 complete?: () => void;
1220}): Unsubscribe;
1221/**
1222 * Attaches a listener for `DocumentSnapshot` events. You may either pass
1223 * individual `onNext` and `onError` callbacks or pass a single observer
1224 * object with `next` and `error` callbacks.
1225 *
1226 * NOTE: Although an `onCompletion` callback can be provided, it will
1227 * never be called because the snapshot stream is never-ending.
1228 *
1229 * @param reference - A reference to the document to listen to.
1230 * @param options - Options controlling the listen behavior.
1231 * @param observer - A single object containing `next` and `error` callbacks.
1232 * @returns An unsubscribe function that can be called to cancel
1233 * the snapshot listener.
1234 */
1235export declare function onSnapshot<T>(reference: DocumentReference<T>, options: SnapshotListenOptions, observer: {
1236 next?: (snapshot: DocumentSnapshot<T>) => void;
1237 error?: (error: FirestoreError) => void;
1238 complete?: () => void;
1239}): Unsubscribe;
1240/**
1241 * Attaches a listener for `DocumentSnapshot` events. You may either pass
1242 * individual `onNext` and `onError` callbacks or pass a single observer
1243 * object with `next` and `error` callbacks.
1244 *
1245 * NOTE: Although an `onCompletion` callback can be provided, it will
1246 * never be called because the snapshot stream is never-ending.
1247 *
1248 * @param reference - A reference to the document to listen to.
1249 * @param onNext - A callback to be called every time a new `DocumentSnapshot`
1250 * is available.
1251 * @param onError - A callback to be called if the listen fails or is
1252 * cancelled. No further callbacks will occur.
1253 * @param onCompletion - Can be provided, but will not be called since streams are
1254 * never ending.
1255 * @returns An unsubscribe function that can be called to cancel
1256 * the snapshot listener.
1257 */
1258export declare function onSnapshot<T>(reference: DocumentReference<T>, onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
1259/**
1260 * Attaches a listener for `DocumentSnapshot` events. You may either pass
1261 * individual `onNext` and `onError` callbacks or pass a single observer
1262 * object with `next` and `error` callbacks.
1263 *
1264 * NOTE: Although an `onCompletion` callback can be provided, it will
1265 * never be called because the snapshot stream is never-ending.
1266 *
1267 * @param reference - A reference to the document to listen to.
1268 * @param options - Options controlling the listen behavior.
1269 * @param onNext - A callback to be called every time a new `DocumentSnapshot`
1270 * is available.
1271 * @param onError - A callback to be called if the listen fails or is
1272 * cancelled. No further callbacks will occur.
1273 * @param onCompletion - Can be provided, but will not be called since streams are
1274 * never ending.
1275 * @returns An unsubscribe function that can be called to cancel
1276 * the snapshot listener.
1277 */
1278export declare function onSnapshot<T>(reference: DocumentReference<T>, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
1279/**
1280 * Attaches a listener for `QuerySnapshot` events. You may either pass
1281 * individual `onNext` and `onError` callbacks or pass a single observer
1282 * object with `next` and `error` callbacks. The listener can be cancelled by
1283 * calling the function that is returned when `onSnapshot` is called.
1284 *
1285 * NOTE: Although an `onCompletion` callback can be provided, it will
1286 * never be called because the snapshot stream is never-ending.
1287 *
1288 * @param query - The query to listen to.
1289 * @param observer - A single object containing `next` and `error` callbacks.
1290 * @returns An unsubscribe function that can be called to cancel
1291 * the snapshot listener.
1292 */
1293export declare function onSnapshot<T>(query: Query<T>, observer: {
1294 next?: (snapshot: QuerySnapshot<T>) => void;
1295 error?: (error: FirestoreError) => void;
1296 complete?: () => void;
1297}): Unsubscribe;
1298/**
1299 * Attaches a listener for `QuerySnapshot` events. You may either pass
1300 * individual `onNext` and `onError` callbacks or pass a single observer
1301 * object with `next` and `error` callbacks. The listener can be cancelled by
1302 * calling the function that is returned when `onSnapshot` is called.
1303 *
1304 * NOTE: Although an `onCompletion` callback can be provided, it will
1305 * never be called because the snapshot stream is never-ending.
1306 *
1307 * @param query - The query to listen to.
1308 * @param options - Options controlling the listen behavior.
1309 * @param observer - A single object containing `next` and `error` callbacks.
1310 * @returns An unsubscribe function that can be called to cancel
1311 * the snapshot listener.
1312 */
1313export declare function onSnapshot<T>(query: Query<T>, options: SnapshotListenOptions, observer: {
1314 next?: (snapshot: QuerySnapshot<T>) => void;
1315 error?: (error: FirestoreError) => void;
1316 complete?: () => void;
1317}): Unsubscribe;
1318/**
1319 * Attaches a listener for `QuerySnapshot` events. You may either pass
1320 * individual `onNext` and `onError` callbacks or pass a single observer
1321 * object with `next` and `error` callbacks. The listener can be cancelled by
1322 * calling the function that is returned when `onSnapshot` is called.
1323 *
1324 * NOTE: Although an `onCompletion` callback can be provided, it will
1325 * never be called because the snapshot stream is never-ending.
1326 *
1327 * @param query - The query to listen to.
1328 * @param onNext - A callback to be called every time a new `QuerySnapshot`
1329 * is available.
1330 * @param onCompletion - Can be provided, but will not be called since streams are
1331 * never ending.
1332 * @param onError - A callback to be called if the listen fails or is
1333 * cancelled. No further callbacks will occur.
1334 * @returns An unsubscribe function that can be called to cancel
1335 * the snapshot listener.
1336 */
1337export declare function onSnapshot<T>(query: Query<T>, onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
1338/**
1339 * Attaches a listener for `QuerySnapshot` events. You may either pass
1340 * individual `onNext` and `onError` callbacks or pass a single observer
1341 * object with `next` and `error` callbacks. The listener can be cancelled by
1342 * calling the function that is returned when `onSnapshot` is called.
1343 *
1344 * NOTE: Although an `onCompletion` callback can be provided, it will
1345 * never be called because the snapshot stream is never-ending.
1346 *
1347 * @param query - The query to listen to.
1348 * @param options - Options controlling the listen behavior.
1349 * @param onNext - A callback to be called every time a new `QuerySnapshot`
1350 * is available.
1351 * @param onCompletion - Can be provided, but will not be called since streams are
1352 * never ending.
1353 * @param onError - A callback to be called if the listen fails or is
1354 * cancelled. No further callbacks will occur.
1355 * @returns An unsubscribe function that can be called to cancel
1356 * the snapshot listener.
1357