1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import { FirebaseApp } from '@firebase/app';
|
7 | import { LogLevelString as LogLevel } from '@firebase/logger';
|
8 | import { EmulatorMockTokenOptions } from '@firebase/util';
|
9 | import { FirebaseError } from '@firebase/util';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export declare function addDoc<T>(reference: CollectionReference<T>, data: WithFieldValue<T>): Promise<DocumentReference<T>>;
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export 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 |
|
31 |
|
32 | export declare class AggregateField<T> {
|
33 |
|
34 | readonly type = "AggregateField";
|
35 | }
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | export declare type AggregateFieldType = AggregateField<number | null>;
|
41 |
|
42 |
|
43 |
|
44 | export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
|
45 |
|
46 | readonly type = "AggregateQuerySnapshot";
|
47 | |
48 |
|
49 |
|
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 | */
|
78 | export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
|
79 | /**
|
80 | * Specifies a set of aggregations and their aliases.
|
81 | */
|
82 | export declare interface AggregateSpec {
|
83 | [field: string]: AggregateFieldType;
|
84 | }
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | export declare type AggregateSpecData<T extends AggregateSpec> = {
|
91 | [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
|
92 | };
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | export declare function arrayRemove(...elements: unknown[]): FieldValue;
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | export declare function arrayUnion(...elements: unknown[]): FieldValue;
|
130 |
|
131 |
|
132 |
|
133 | export 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 | */
|
180 | export declare const CACHE_SIZE_UNLIMITED = -1;
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 | export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 | export declare function clearIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | export declare function collection(reference: CollectionReference<unknown>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 | export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | export declare function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData>;
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | export declare class CollectionReference<T = DocumentData> extends Query<T> {
|
271 |
|
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 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 | withConverter(converter: null): CollectionReference<DocumentData>;
|
304 | }
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 | export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
|
319 | mockUserToken?: EmulatorMockTokenOptions | string;
|
320 | }): void;
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 | export declare function deleteDoc(reference: DocumentReference<unknown>): Promise<void>;
|
329 |
|
330 |
|
331 |
|
332 |
|
333 | export declare function deleteField(): FieldValue;
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | export declare function disableNetwork(firestore: Firestore): Promise<void>;
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 | export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 | export declare function doc<T>(reference: CollectionReference<T>, path?: string, ...pathSegments: string[]): DocumentReference<T>;
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 | export declare function doc(reference: DocumentReference<unknown>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
|
385 |
|
386 |
|
387 |
|
388 |
|
389 | export declare interface DocumentChange<T = DocumentData> {
|
390 |
|
391 | readonly type: DocumentChangeType;
|
392 |
|
393 | readonly doc: QueryDocumentSnapshot<T>;
|
394 | |
395 |
|
396 |
|
397 |
|
398 |
|
399 | readonly oldIndex: number;
|
400 | |
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 | readonly newIndex: number;
|
407 | }
|
408 |
|
409 |
|
410 |
|
411 | export declare type DocumentChangeType = 'added' | 'removed' | 'modified';
|
412 |
|
413 |
|
414 |
|
415 |
|
416 | export declare interface DocumentData {
|
417 |
|
418 | [field: string]: any;
|
419 | }
|
420 |
|
421 |
|
422 |
|
423 |
|
424 | export declare function documentId(): FieldPath;
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 | export declare class DocumentReference<T = DocumentData> {
|
431 | |
432 |
|
433 |
|
434 | readonly converter: FirestoreDataConverter<T> | null;
|
435 |
|
436 | readonly type = "document";
|
437 | |
438 |
|
439 |
|
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 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 | withConverter(converter: null): DocumentReference<DocumentData>;
|
474 | }
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 | export declare class DocumentSnapshot<T = DocumentData> {
|
485 | |
486 |
|
487 |
|
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 */
|
538 | export { EmulatorMockTokenOptions };
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 | export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 | export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 | export declare function enableNetwork(firestore: Firestore): Promise<void>;
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 | export declare function endAt(snapshot: DocumentSnapshot<unknown>): QueryEndAtConstraint;
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 | export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint;
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 | export declare function endBefore(snapshot: DocumentSnapshot<unknown>): QueryEndAtConstraint;
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 | export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint;
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 | export declare class FieldPath {
|
642 | |
643 |
|
644 |
|
645 |
|
646 |
|
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 | */
|
661 | export 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 | */
|
672 | export declare class Firestore {
|
673 | |
674 |
|
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 |
|
685 |
|
686 | toJSON(): object;
|
687 | }
|
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 | export declare interface FirestoreDataConverter<T> {
|
731 | |
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 | toFirestore(modelObject: WithFieldValue<T>): DocumentData;
|
741 | |
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 | toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions): DocumentData;
|
753 | |
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 | fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>, options?: SnapshotOptions): T;
|
761 | }
|
762 |
|
763 | export declare class FirestoreError extends FirebaseError {
|
764 | |
765 |
|
766 |
|
767 | readonly code: FirestoreErrorCode;
|
768 | |
769 |
|
770 |
|
771 | readonly message: string;
|
772 |
|
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 | */
|
815 | export 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 | */
|
820 | export declare interface FirestoreSettings {
|
821 | |
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 | cacheSizeBytes?: number;
|
832 | |
833 |
|
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 | experimentalForceLongPolling?: boolean;
|
847 | |
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 | experimentalAutoDetectLongPolling?: boolean;
|
856 | |
857 |
|
858 |
|
859 | host?: string;
|
860 | |
861 |
|
862 |
|
863 | ssl?: boolean;
|
864 | |
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 | ignoreUndefinedProperties?: boolean;
|
871 | }
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 | export declare class GeoPoint {
|
896 | |
897 |
|
898 |
|
899 |
|
900 |
|
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 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 | export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
947 | count: AggregateField<number>;
|
948 | }>>;
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 | export declare function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 | export declare function getDocFromCache<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 | export declare function getDocFromServer<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 | export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 | export declare function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 | export declare function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 | export declare function getFirestore(app: FirebaseApp): Firestore;
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 | export declare function getFirestore(): Firestore;
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 | export declare function increment(n: number): FieldValue;
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 | export declare interface Index {
|
1049 |
|
1050 | readonly collectionGroup: string;
|
1051 |
|
1052 | readonly fields?: IndexField[];
|
1053 | [key: string]: unknown;
|
1054 | }
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 | export declare interface IndexConfiguration {
|
1063 |
|
1064 | readonly indexes?: Index[];
|
1065 | [key: string]: unknown;
|
1066 | }
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 | export declare interface IndexField {
|
1072 |
|
1073 | readonly fieldPath: string;
|
1074 | |
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 | readonly arrayConfig?: 'CONTAINS';
|
1081 | |
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 | readonly order?: 'ASCENDING' | 'DESCENDING';
|
1088 | [key: string]: unknown;
|
1089 | }
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 | export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 | export declare function limit(limit: number): QueryLimitConstraint;
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 | export declare function limitToLast(limit: number): QueryLimitConstraint;
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 | export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 | export declare class LoadBundleTask implements PromiseLike<LoadBundleTaskProgress> {
|
1142 | |
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 | onProgress(next?: (progress: LoadBundleTaskProgress) => unknown, error?: (err: Error) => unknown, complete?: () => void): void;
|
1151 | |
1152 |
|
1153 |
|
1154 |
|
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 | */
|
1169 | export 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 | }
|
1181 | export { 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 | */
|
1194 | export 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 | */
|
1200 | export 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 | */
|
1216 | export 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 | */
|
1235 | export 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 | */
|
1258 | export 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 | */
|
1278 | export 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 | */
|
1293 | export 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 | */
|
1313 | export 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 | */
|
1337 | export 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 | */
|
1358 | export declare function onSnapshot<T>(query: Query<T>, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1359 | /**
|
1360 | * Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
|
1361 | * event indicates that all listeners affected by a given change have fired,
|
1362 | * even if a single server-generated change affects multiple listeners.
|
1363 | *
|
1364 | * NOTE: The snapshots-in-sync event only indicates that listeners are in sync
|
1365 | * with each other, but does not relate to whether those snapshots are in sync
|
1366 | * with the server. Use SnapshotMetadata in the individual listeners to
|
1367 | * determine if a snapshot is from the cache or the server.
|
1368 | *
|
1369 | * @param firestore - The instance of Firestore for synchronizing snapshots.
|
1370 | * @param observer - A single object containing `next` and `error` callbacks.
|
1371 | * @returns An unsubscribe function that can be called to cancel the snapshot
|
1372 | * listener.
|
1373 | */
|
1374 | export declare function onSnapshotsInSync(firestore: Firestore, observer: {
|
1375 | next?: (value: void) => void;
|
1376 | error?: (error: FirestoreError) => void;
|
1377 | complete?: () => void;
|
1378 | }): Unsubscribe;
|
1379 | /**
|
1380 | * Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
|
1381 | * event indicates that all listeners affected by a given change have fired,
|
1382 | * even if a single server-generated change affects multiple listeners.
|
1383 | *
|
1384 | * NOTE: The snapshots-in-sync event only indicates that listeners are in sync
|
1385 | * with each other, but does not relate to whether those snapshots are in sync
|
1386 | * with the server. Use `SnapshotMetadata` in the individual listeners to
|
1387 | * determine if a snapshot is from the cache or the server.
|
1388 | *
|
1389 | * @param firestore - The `Firestore` instance for synchronizing snapshots.
|
1390 | * @param onSync - A callback to be called every time all snapshot listeners are
|
1391 | * in sync with each other.
|
1392 | * @returns An unsubscribe function that can be called to cancel the snapshot
|
1393 | * listener.
|
1394 | */
|
1395 | export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe;
|
1396 | /**
|
1397 | * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of
|
1398 | * the given filter constraints. A disjunction filter includes a document if it
|
1399 | * satisfies any of the given filters.
|
1400 | *
|
1401 | * @param queryConstraints - Optional. The list of
|
1402 | * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
|
1403 | * created with calls to {@link where}, {@link or}, or {@link and}.
|
1404 | * @returns The newly created {@link QueryCompositeFilterConstraint}.
|
1405 | */
|
1406 | export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;
|
1407 | /**
|
1408 | * Creates a {@link QueryOrderByConstraint} that sorts the query result by the
|
1409 | * specified field, optionally in descending order instead of ascending.
|
1410 | *
|
1411 | * Note: Documents that do not contain the specified field will not be present
|
1412 | * in the query result.
|
1413 | *
|
1414 | * @param fieldPath - The field to sort by.
|
1415 | * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
1416 | * not specified, order will be ascending.
|
1417 | * @returns The created {@link QueryOrderByConstraint}.
|
1418 | */
|
1419 | export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint;
|
1420 | /**
|
1421 | * The direction of a {@link orderBy} clause is specified as 'desc' or 'asc'
|
1422 | * (descending or ascending).
|
1423 | */
|
1424 | export declare type OrderByDirection = 'desc' | 'asc';
|
1425 | /**
|
1426 | * Similar to Typescript's `Partial<T>`, but allows nested fields to be
|
1427 | * omitted and FieldValues to be passed in as property values.
|
1428 | */
|
1429 | export declare type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T extends {} ? {
|
1430 | [K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue;
|
1431 | } : never);
|
1432 | /**
|
1433 | * Settings that can be passed to `enableIndexedDbPersistence()` to configure
|
1434 | * Firestore persistence.
|
1435 | */
|
1436 | export declare interface PersistenceSettings {
|
1437 | /**
|
1438 | * Whether to force enable persistence for the client. This cannot be used
|
1439 | * with multi-tab synchronization and is primarily intended for use with Web
|
1440 | * Workers. Setting this to `true` will enable persistence, but cause other
|
1441 | * tabs using persistence to fail.
|
1442 | */
|
1443 | forceOwnership?: boolean;
|
1444 | }
|
1445 | /**
|
1446 | * These types primarily exist to support the `UpdateData`,
|
1447 | * `WithFieldValue`, and `PartialWithFieldValue` types and are not consumed
|
1448 | * directly by the end developer.
|
1449 | */
|
1450 | /** Primitive types. */
|
1451 | export declare type Primitive = string | number | boolean | undefined | null;
|
1452 | /**
|
1453 | * A `Query` refers to a query which you can read or listen to. You can also
|
1454 | * construct refined `Query` objects by adding filters and ordering.
|
1455 | */
|
1456 | export declare class Query<T = DocumentData> {
|
1457 | /**
|
1458 | * If provided, the `FirestoreDataConverter` associated with this instance.
|
1459 | */
|
1460 | readonly converter: FirestoreDataConverter<T> | null;
|
1461 | /** The type of this Firestore reference. */
|
1462 | readonly type: 'query' | 'collection';
|
1463 | /**
|
1464 | * The `Firestore` instance for the Firestore database (useful for performing
|
1465 | * transactions, etc.).
|
1466 | */
|
1467 | readonly firestore: Firestore;
|
1468 | protected constructor();
|
1469 | /**
|
1470 | * Removes the current converter.
|
1471 | *
|
1472 | * @param converter - `null` removes the current converter.
|
1473 | * @returns A `Query<DocumentData>` that does not use a converter.
|
1474 | */
|
1475 | withConverter(converter: null): Query<DocumentData>;
|
1476 | /**
|
1477 | * Applies a custom data converter to this query, allowing you to use your own
|
1478 | * custom model objects with Firestore. When you call {@link getDocs} with
|
1479 | * the returned query, the provided converter will convert between Firestore
|
1480 | * data and your custom type `U`.
|
1481 | *
|
1482 | * @param converter - Converts objects to and from Firestore.
|
1483 | * @returns A `Query<U>` that uses the provided converter.
|
1484 | */
|
1485 | withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
|
1486 | }
|
1487 | /**
|
1488 | * Creates a new immutable instance of {@link Query} that is extended to also
|
1489 | * include additional query constraints.
|
1490 | *
|
1491 | * @param query - The {@link Query} instance to use as a base for the new
|
1492 | * constraints.
|
1493 | * @param compositeFilter - The {@link QueryCompositeFilterConstraint} to
|
1494 | * apply. Create {@link QueryCompositeFilterConstraint} using {@link and} or
|
1495 | * {@link or}.
|
1496 | * @param queryConstraints - Additional {@link QueryNonFilterConstraint}s to
|
1497 | * apply (e.g. {@link orderBy}, {@link limit}).
|
1498 | * @throws if any of the provided query constraints cannot be combined with the
|
1499 | * existing or new constraints.
|
1500 | */
|
1501 | export declare function query<T>(query: Query<T>, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query<T>;
|
1502 | /**
|
1503 | * Creates a new immutable instance of {@link Query} that is extended to also
|
1504 | * include additional query constraints.
|
1505 | *
|
1506 | * @param query - The {@link Query} instance to use as a base for the new
|
1507 | * constraints.
|
1508 | * @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
1509 | * @throws if any of the provided query constraints cannot be combined with the
|
1510 | * existing or new constraints.
|
1511 | */
|
1512 | export declare function query<T>(query: Query<T>, ...queryConstraints: QueryConstraint[]): Query<T>;
|
1513 | /**
|
1514 | * A `QueryCompositeFilterConstraint` is used to narrow the set of documents
|
1515 | * returned by a Firestore query by performing the logical OR or AND of multiple
|
1516 | * {@link QueryFieldFilterConstraint}s or {@link QueryCompositeFilterConstraint}s.
|
1517 | * `QueryCompositeFilterConstraint`s are created by invoking {@link or} or
|
1518 | * {@link and} and can then be passed to {@link (query:1)} to create a new query
|
1519 | * instance that also contains the `QueryCompositeFilterConstraint`.
|
1520 | */
|
1521 | export declare class QueryCompositeFilterConstraint {
|
1522 | /** The type of this query constraint */
|
1523 | readonly type: 'or' | 'and';
|
1524 | }
|
1525 | /**
|
1526 | * A `QueryConstraint` is used to narrow the set of documents returned by a
|
1527 | * Firestore query. `QueryConstraint`s are created by invoking {@link where},
|
1528 | * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link
|
1529 | * (endBefore:1)}, {@link (endAt:1)}, {@link limit}, {@link limitToLast} and
|
1530 | * can then be passed to {@link (query:1)} to create a new query instance that
|
1531 | * also contains this `QueryConstraint`.
|
1532 | */
|
1533 | export declare abstract class QueryConstraint {
|
1534 | /** The type of this query constraint */
|
1535 | abstract readonly type: QueryConstraintType;
|
1536 | }
|
1537 | /** Describes the different query constraints available in this SDK. */
|
1538 | export declare type QueryConstraintType = 'where' | 'orderBy' | 'limit' | 'limitToLast' | 'startAt' | 'startAfter' | 'endAt' | 'endBefore';
|
1539 | /**
|
1540 | * A `QueryDocumentSnapshot` contains data read from a document in your
|
1541 | * Firestore database as part of a query. The document is guaranteed to exist
|
1542 | * and its data can be extracted with `.data()` or `.get(<field>)` to get a
|
1543 | * specific field.
|
1544 | *
|
1545 | * A `QueryDocumentSnapshot` offers the same API surface as a
|
1546 | * `DocumentSnapshot`. Since query results contain only existing documents, the
|
1547 | * `exists` property will always be true and `data()` will never return
|
1548 | * 'undefined'.
|
1549 | */
|
1550 | export declare class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
|
1551 | /**
|
1552 | * Retrieves all fields in the document as an `Object`.
|
1553 | *
|
1554 | * By default, `serverTimestamp()` values that have not yet been
|
1555 | * set to their final value will be returned as `null`. You can override
|
1556 | * this by passing an options object.
|
1557 | *
|
1558 | * @override
|
1559 | * @param options - An options object to configure how data is retrieved from
|
1560 | * the snapshot (for example the desired behavior for server timestamps that
|
1561 | * have not yet been set to their final value).
|
1562 | * @returns An `Object` containing all fields in the document.
|
1563 | */
|
1564 | data(options?: SnapshotOptions): T;
|
1565 | }
|
1566 | /**
|
1567 | * A `QueryEndAtConstraint` is used to exclude documents from the end of a
|
1568 | * result set returned by a Firestore query.
|
1569 | * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
|
1570 | * {@link (endBefore:1)} and can then be passed to {@link (query:1)} to create a new
|
1571 | * query instance that also contains this `QueryEndAtConstraint`.
|
1572 | */
|
1573 | export declare class QueryEndAtConstraint extends QueryConstraint {
|
1574 | /** The type of this query constraint */
|
1575 | readonly type: 'endBefore' | 'endAt';
|
1576 | }
|
1577 | /**
|
1578 | * Returns true if the provided queries point to the same collection and apply
|
1579 | * the same constraints.
|
1580 | *
|
1581 | * @param left - A `Query` to compare.
|
1582 | * @param right - A `Query` to compare.
|
1583 | * @returns true if the references point to the same location in the same
|
1584 | * Firestore database.
|
1585 | */
|
1586 | export declare function queryEqual<T>(left: Query<T>, right: Query<T>): boolean;
|
1587 | /**
|
1588 | * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by
|
1589 | * a Firestore query by filtering on one or more document fields.
|
1590 | * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then
|
1591 | * be passed to {@link (query:1)} to create a new query instance that also contains
|
1592 | * this `QueryFieldFilterConstraint`.
|
1593 | */
|
1594 | export declare class QueryFieldFilterConstraint extends QueryConstraint {
|
1595 | /** The type of this query constraint */
|
1596 | readonly type = "where";
|
1597 | }
|
1598 | /**
|
1599 | * `QueryFilterConstraint` is a helper union type that represents
|
1600 | * {@link QueryFieldFilterConstraint} and {@link QueryCompositeFilterConstraint}.
|
1601 | */
|
1602 | export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCompositeFilterConstraint;
|
1603 | /**
|
1604 | * A `QueryLimitConstraint` is used to limit the number of documents returned by
|
1605 | * a Firestore query.
|
1606 | * `QueryLimitConstraint`s are created by invoking {@link limit} or
|
1607 | * {@link limitToLast} and can then be passed to {@link (query:1)} to create a new
|
1608 | * query instance that also contains this `QueryLimitConstraint`.
|
1609 | */
|
1610 | export declare class QueryLimitConstraint extends QueryConstraint {
|
1611 | /** The type of this query constraint */
|
1612 | readonly type: 'limit' | 'limitToLast';
|
1613 | }
|
1614 | /**
|
1615 | * `QueryNonFilterConstraint` is a helper union type that represents
|
1616 | * QueryConstraints which are used to narrow or order the set of documents,
|
1617 | * but that do not explicitly filter on a document field.
|
1618 | * `QueryNonFilterConstraint`s are created by invoking {@link orderBy},
|
1619 | * {@link (startAt:1)}, {@link (startAfter:1)}, {@link (endBefore:1)}, {@link (endAt:1)},
|
1620 | * {@link limit} or {@link limitToLast} and can then be passed to {@link (query:1)}
|
1621 | * to create a new query instance that also contains the `QueryConstraint`.
|
1622 | */
|
1623 | export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint;
|
1624 | /**
|
1625 | * A `QueryOrderByConstraint` is used to sort the set of documents returned by a
|
1626 | * Firestore query. `QueryOrderByConstraint`s are created by invoking
|
1627 | * {@link orderBy} and can then be passed to {@link (query:1)} to create a new query
|
1628 | * instance that also contains this `QueryOrderByConstraint`.
|
1629 | *
|
1630 | * Note: Documents that do not contain the orderBy field will not be present in
|
1631 | * the query result.
|
1632 | */
|
1633 | export declare class QueryOrderByConstraint extends QueryConstraint {
|
1634 | /** The type of this query constraint */
|
1635 | readonly type = "orderBy";
|
1636 | }
|
1637 | /**
|
1638 | * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects
|
1639 | * representing the results of a query. The documents can be accessed as an
|
1640 | * array via the `docs` property or enumerated using the `forEach` method. The
|
1641 | * number of documents can be determined via the `empty` and `size`
|
1642 | * properties.
|
1643 | */
|
1644 | export declare class QuerySnapshot<T = DocumentData> {
|
1645 | /**
|
1646 | * Metadata about this snapshot, concerning its source and if it has local
|
1647 | * modifications.
|
1648 | */
|
1649 | readonly metadata: SnapshotMetadata;
|
1650 | /**
|
1651 | * The query on which you called `get` or `onSnapshot` in order to get this
|
1652 | * `QuerySnapshot`.
|
1653 | */
|
1654 | readonly query: Query<T>;
|
1655 | private constructor();
|
1656 | /** An array of all the documents in the `QuerySnapshot`. */
|
1657 | get docs(): Array<QueryDocumentSnapshot<T>>;
|
1658 | /** The number of documents in the `QuerySnapshot`. */
|
1659 | get size(): number;
|
1660 | /** True if there are no documents in the `QuerySnapshot`. */
|
1661 | get empty(): boolean;
|
1662 | /**
|
1663 | * Enumerates all of the documents in the `QuerySnapshot`.
|
1664 | *
|
1665 | * @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
1666 | * each document in the snapshot.
|
1667 | * @param thisArg - The `this` binding for the callback.
|
1668 | */
|
1669 | forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: unknown): void;
|
1670 | /**
|
1671 | * Returns an array of the documents changes since the last snapshot. If this
|
1672 | * is the first snapshot, all documents will be in the list as 'added'
|
1673 | * changes.
|
1674 | *
|
1675 | * @param options - `SnapshotListenOptions` that control whether metadata-only
|
1676 | * changes (i.e. only `DocumentSnapshot.metadata` changed) should trigger
|
1677 | * snapshot events.
|
1678 | */
|
1679 | docChanges(options?: SnapshotListenOptions): Array<DocumentChange<T>>;
|
1680 | }
|
1681 | /**
|
1682 | * A `QueryStartAtConstraint` is used to exclude documents from the start of a
|
1683 | * result set returned by a Firestore query.
|
1684 | * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
|
1685 | * {@link (startAfter:1)} and can then be passed to {@link (query:1)} to create a
|
1686 | * new query instance that also contains this `QueryStartAtConstraint`.
|
1687 | */
|
1688 | export declare class QueryStartAtConstraint extends QueryConstraint {
|
1689 | /** The type of this query constraint */
|
1690 | readonly type: 'startAt' | 'startAfter';
|
1691 | }
|
1692 | /**
|
1693 | * Returns true if the provided references are equal.
|
1694 | *
|
1695 | * @param left - A reference to compare.
|
1696 | * @param right - A reference to compare.
|
1697 | * @returns true if the references point to the same location in the same
|
1698 | * Firestore database.
|
1699 | */
|
1700 | export declare function refEqual<T>(left: DocumentReference<T> | CollectionReference<T>, right: DocumentReference<T> | CollectionReference<T>): boolean;
|
1701 | /* Excluded from this release type: _ResourcePath */
|
1702 | /**
|
1703 | * Executes the given `updateFunction` and then attempts to commit the changes
|
1704 | * applied within the transaction. If any document read within the transaction
|
1705 | * has changed, Cloud Firestore retries the `updateFunction`. If it fails to
|
1706 | * commit after 5 attempts, the transaction fails.
|
1707 | *
|
1708 | * The maximum number of writes allowed in a single transaction is 500.
|
1709 | *
|
1710 | * @param firestore - A reference to the Firestore database to run this
|
1711 | * transaction against.
|
1712 | * @param updateFunction - The function to execute within the transaction
|
1713 | * context.
|
1714 | * @param options - An options object to configure maximum number of attempts to
|
1715 | * commit.
|
1716 | * @returns If the transaction completed successfully or was explicitly aborted
|
1717 | * (the `updateFunction` returned a failed promise), the promise returned by the
|
1718 | * `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
1719 | * rejected promise with the corresponding failure error is returned.
|
1720 | */
|
1721 | export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
1722 | /**
|
1723 | * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
1724 | * include a server-generated timestamp in the written data.
|
1725 | */
|
1726 | export declare function serverTimestamp(): FieldValue;
|
1727 | /**
|
1728 | * Writes to the document referred to by this `DocumentReference`. If the
|
1729 | * document does not yet exist, it will be created.
|
1730 | *
|
1731 | * @param reference - A reference to the document to write.
|
1732 | * @param data - A map of the fields and values for the document.
|
1733 | * @returns A `Promise` resolved once the data has been successfully written
|
1734 | * to the backend (note that it won't resolve while you're offline).
|
1735 | */
|
1736 | export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFieldValue<T>): Promise<void>;
|
1737 | /**
|
1738 | * Writes to the document referred to by the specified `DocumentReference`. If
|
1739 | * the document does not yet exist, it will be created. If you provide `merge`
|
1740 | * or `mergeFields`, the provided data can be merged into an existing document.
|
1741 | *
|
1742 | * @param reference - A reference to the document to write.
|
1743 | * @param data - A map of the fields and values for the document.
|
1744 | * @param options - An object to configure the set behavior.
|
1745 | * @returns A Promise resolved once the data has been successfully written
|
1746 | * to the backend (note that it won't resolve while you're offline).
|
1747 | */
|
1748 | export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
|
1749 | /**
|
1750 | * Configures indexing for local query execution. Any previous index
|
1751 | * configuration is overridden. The `Promise` resolves once the index
|
1752 | * configuration has been persisted.
|
1753 | *
|
1754 | * The index entries themselves are created asynchronously. You can continue to
|
1755 | * use queries that require indexing even if the indices are not yet available.
|
1756 | * Query execution will automatically start using the index once the index
|
1757 | * entries have been written.
|
1758 | *
|
1759 | * Indexes are only supported with IndexedDb persistence. Invoke either
|
1760 | * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
1761 | * before setting an index configuration. If IndexedDb is not enabled, any
|
1762 | * index configuration is ignored.
|
1763 | *
|
1764 | * @param firestore - The {@link Firestore} instance to configure indexes for.
|
1765 | * @param configuration -The index definition.
|
1766 | * @throws FirestoreError if the JSON format is invalid.
|
1767 | * @returns A `Promise` that resolves once all indices are successfully
|
1768 | * configured.
|
1769 | * @beta
|
1770 | */
|
1771 | export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
|
1772 | /**
|
1773 | * Configures indexing for local query execution. Any previous index
|
1774 | * configuration is overridden. The `Promise` resolves once the index
|
1775 | * configuration has been persisted.
|
1776 | *
|
1777 | * The index entries themselves are created asynchronously. You can continue to
|
1778 | * use queries that require indexing even if the indices are not yet available.
|
1779 | * Query execution will automatically start using the index once the index
|
1780 | * entries have been written.
|
1781 | *
|
1782 | * Indexes are only supported with IndexedDb persistence. Invoke either
|
1783 | * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
1784 | * before setting an index configuration. If IndexedDb is not enabled, any
|
1785 | * index configuration is ignored.
|
1786 | *
|
1787 | * The method accepts the JSON format exported by the Firebase CLI (`firebase
|
1788 | * firestore:indexes`). If the JSON format is invalid, this method throws an
|
1789 | * error.
|
1790 | *
|
1791 | * @param firestore - The {@link Firestore} instance to configure indexes for.
|
1792 | * @param json -The JSON format exported by the Firebase CLI.
|
1793 | * @throws FirestoreError if the JSON format is invalid.
|
1794 | * @returns A `Promise` that resolves once all indices are successfully
|
1795 | * configured.
|
1796 | * @beta
|
1797 | */
|
1798 | export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
|
1799 | /**
|
1800 | * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
1801 | *
|
1802 | * @param logLevel - The verbosity you set for activity and error logging. Can
|
1803 | * be any of the following values:
|
1804 | *
|
1805 | * <ul>
|
1806 | * <li>`debug` for the most verbose logging level, primarily for
|
1807 | * debugging.</li>
|
1808 | * <li>`error` to log errors only.</li>
|
1809 | * <li><code>`silent` to turn off logging.</li>
|
1810 | * </ul>
|
1811 | */
|
1812 | export declare function setLogLevel(logLevel: LogLevel): void;
|
1813 | /**
|
1814 | * An options object that configures the behavior of {@link @firebase/firestore/lite#(setDoc:1)}, {@link
|
1815 | * @firebase/firestore/lite#(WriteBatch.set:1)} and {@link @firebase/firestore/lite#(Transaction.set:1)} calls. These calls can be
|
1816 | * configured to perform granular merges instead of overwriting the target
|
1817 | * documents in their entirety by providing a `SetOptions` with `merge: true`.
|
1818 | *
|
1819 | * @param merge - Changes the behavior of a `setDoc()` call to only replace the
|
1820 | * values specified in its data argument. Fields omitted from the `setDoc()`
|
1821 | * call remain untouched. If your input sets any field to an empty map, all
|
1822 | * nested fields are overwritten.
|
1823 | * @param mergeFields - Changes the behavior of `setDoc()` calls to only replace
|
1824 | * the specified field paths. Any field path that is not specified is ignored
|
1825 | * and remains untouched. If your input sets any field to an empty map, all
|
1826 | * nested fields are overwritten.
|
1827 | */
|
1828 | export declare type SetOptions = {
|
1829 | readonly merge?: boolean;
|
1830 | } | {
|
1831 | readonly mergeFields?: Array<string | FieldPath>;
|
1832 | };
|
1833 | /**
|
1834 | * Returns true if the provided snapshots are equal.
|
1835 | *
|
1836 | * @param left - A snapshot to compare.
|
1837 | * @param right - A snapshot to compare.
|
1838 | * @returns true if the snapshots are equal.
|
1839 | */
|
1840 | export declare function snapshotEqual<T>(left: DocumentSnapshot<T> | QuerySnapshot<T>, right: DocumentSnapshot<T> | QuerySnapshot<T>): boolean;
|
1841 | /**
|
1842 | * An options object that can be passed to {@link (onSnapshot:1)} and {@link
|
1843 | * QuerySnapshot.docChanges} to control which types of changes to include in the
|
1844 | * result set.
|
1845 | */
|
1846 | export declare interface SnapshotListenOptions {
|
1847 | /**
|
1848 | * Include a change even if only the metadata of the query or of a document
|
1849 | * changed. Default is false.
|
1850 | */
|
1851 | readonly includeMetadataChanges?: boolean;
|
1852 | }
|
1853 | /**
|
1854 | * Metadata about a snapshot, describing the state of the snapshot.
|
1855 | */
|
1856 | export declare class SnapshotMetadata {
|
1857 | /**
|
1858 | * True if the snapshot contains the result of local writes (for example
|
1859 | * `set()` or `update()` calls) that have not yet been committed to the
|
1860 | * backend. If your listener has opted into metadata updates (via
|
1861 | * `SnapshotListenOptions`) you will receive another snapshot with
|
1862 | * `hasPendingWrites` equal to false once the writes have been committed to
|
1863 | * the backend.
|
1864 | */
|
1865 | readonly hasPendingWrites: boolean;
|
1866 | /**
|
1867 | * True if the snapshot was created from cached data rather than guaranteed
|
1868 | * up-to-date server data. If your listener has opted into metadata updates
|
1869 | * (via `SnapshotListenOptions`) you will receive another snapshot with
|
1870 | * `fromCache` set to false once the client has received up-to-date data from
|
1871 | * the backend.
|
1872 | */
|
1873 | readonly fromCache: boolean;
|
1874 | private constructor();
|
1875 | /**
|
1876 | * Returns true if this `SnapshotMetadata` is equal to the provided one.
|
1877 | *
|
1878 | * @param other - The `SnapshotMetadata` to compare against.
|
1879 | * @returns true if this `SnapshotMetadata` is equal to the provided one.
|
1880 | */
|
1881 | isEqual(other: SnapshotMetadata): boolean;
|
1882 | }
|
1883 | /**
|
1884 | * Options that configure how data is retrieved from a `DocumentSnapshot` (for
|
1885 | * example the desired behavior for server timestamps that have not yet been set
|
1886 | * to their final value).
|
1887 | */
|
1888 | export declare interface SnapshotOptions {
|
1889 | /**
|
1890 | * If set, controls the return value for server timestamps that have not yet
|
1891 | * been set to their final value.
|
1892 | *
|
1893 | * By specifying 'estimate', pending server timestamps return an estimate
|
1894 | * based on the local clock. This estimate will differ from the final value
|
1895 | * and cause these values to change once the server result becomes available.
|
1896 | *
|
1897 | * By specifying 'previous', pending timestamps will be ignored and return
|
1898 | * their previous value instead.
|
1899 | *
|
1900 | * If omitted or set to 'none', `null` will be returned by default until the
|
1901 | * server value becomes available.
|
1902 | */
|
1903 | readonly serverTimestamps?: 'estimate' | 'previous' | 'none';
|
1904 | }
|
1905 | /**
|
1906 | * Creates a {@link QueryStartAtConstraint} that modifies the result set to
|
1907 | * start after the provided document (exclusive). The starting position is
|
1908 | * relative to the order of the query. The document must contain all of the
|
1909 | * fields provided in the orderBy of the query.
|
1910 | *
|
1911 | * @param snapshot - The snapshot of the document to start after.
|
1912 | * @returns A {@link QueryStartAtConstraint} to pass to `query()`
|
1913 | */
|
1914 | export declare function startAfter(snapshot: DocumentSnapshot<unknown>): QueryStartAtConstraint;
|
1915 | /**
|
1916 | * Creates a {@link QueryStartAtConstraint} that modifies the result set to
|
1917 | * start after the provided fields relative to the order of the query. The order
|
1918 | * of the field values must match the order of the order by clauses of the query.
|
1919 | *
|
1920 | * @param fieldValues - The field values to start this query after, in order
|
1921 | * of the query's order by.
|
1922 | * @returns A {@link QueryStartAtConstraint} to pass to `query()`
|
1923 | */
|
1924 | export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint;
|
1925 | /**
|
1926 | * Creates a {@link QueryStartAtConstraint} that modifies the result set to
|
1927 | * start at the provided document (inclusive). The starting position is relative
|
1928 | * to the order of the query. The document must contain all of the fields
|
1929 | * provided in the `orderBy` of this query.
|
1930 | *
|
1931 | * @param snapshot - The snapshot of the document to start at.
|
1932 | * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
|
1933 | */
|
1934 | export declare function startAt(snapshot: DocumentSnapshot<unknown>): QueryStartAtConstraint;
|
1935 | /**
|
1936 | * Creates a {@link QueryStartAtConstraint} that modifies the result set to
|
1937 | * start at the provided fields relative to the order of the query. The order of
|
1938 | * the field values must match the order of the order by clauses of the query.
|
1939 | *
|
1940 | * @param fieldValues - The field values to start this query at, in order
|
1941 | * of the query's order by.
|
1942 | * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
|
1943 | */
|
1944 | export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;
|
1945 | /**
|
1946 | * Represents the state of bundle loading tasks.
|
1947 | *
|
1948 | * Both 'Error' and 'Success' are sinking state: task will abort or complete and there will
|
1949 | * be no more updates after they are reported.
|
1950 | */
|
1951 | export declare type TaskState = 'Error' | 'Running' | 'Success';
|
1952 | /**
|
1953 | * Terminates the provided {@link Firestore} instance.
|
1954 | *
|
1955 | * After calling `terminate()` only the `clearIndexedDbPersistence()` function
|
1956 | * may be used. Any other function will throw a `FirestoreError`.
|
1957 | *
|
1958 | * To restart after termination, create a new instance of FirebaseFirestore with
|
1959 | * {@link (getFirestore:1)}.
|
1960 | *
|
1961 | * Termination does not cancel any pending writes, and any promises that are
|
1962 | * awaiting a response from the server will not be resolved. If you have
|
1963 | * persistence enabled, the next time you start this instance, it will resume
|
1964 | * sending these writes to the server.
|
1965 | *
|
1966 | * Note: Under normal circumstances, calling `terminate()` is not required. This
|
1967 | * function is useful only when you want to force this instance to release all
|
1968 | * of its resources or in combination with `clearIndexedDbPersistence()` to
|
1969 | * ensure that all local state is destroyed between test runs.
|
1970 | *
|
1971 | * @returns A `Promise` that is resolved when the instance has been successfully
|
1972 | * terminated.
|
1973 | */
|
1974 | export declare function terminate(firestore: Firestore): Promise<void>;
|
1975 | /**
|
1976 | * @license
|
1977 | * Copyright 2017 Google LLC
|
1978 | *
|
1979 | * Licensed under the Apache License, Version 2.0 (the "License");
|
1980 | * you may not use this file except in compliance with the License.
|
1981 | * You may obtain a copy of the License at
|
1982 | *
|
1983 | * http://www.apache.org/licenses/LICENSE-2.0
|
1984 | *
|
1985 | * Unless required by applicable law or agreed to in writing, software
|
1986 | * distributed under the License is distributed on an "AS IS" BASIS,
|
1987 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
1988 | * See the License for the specific language governing permissions and
|
1989 | * limitations under the License.
|
1990 | */
|
1991 | /**
|
1992 | * A `Timestamp` represents a point in time independent of any time zone or
|
1993 | * calendar, represented as seconds and fractions of seconds at nanosecond
|
1994 | * resolution in UTC Epoch time.
|
1995 | *
|
1996 | * It is encoded using the Proleptic Gregorian Calendar which extends the
|
1997 | * Gregorian calendar backwards to year one. It is encoded assuming all minutes
|
1998 | * are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second
|
1999 | * table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
|
2000 | * 9999-12-31T23:59:59.999999999Z.
|
2001 | *
|
2002 | * For examples and further specifications, refer to the
|
2003 | * {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
2004 | */
|
2005 | export declare class Timestamp {
|
2006 | /**
|
2007 | * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
|
2008 | */
|
2009 | readonly seconds: number;
|
2010 | /**
|
2011 | * The fractions of a second at nanosecond resolution.*
|
2012 | */
|
2013 | readonly nanoseconds: number;
|
2014 | /**
|
2015 | * Creates a new timestamp with the current date, with millisecond precision.
|
2016 | *
|
2017 | * @returns a new timestamp representing the current date.
|
2018 | */
|
2019 | static now(): Timestamp;
|
2020 | /**
|
2021 | * Creates a new timestamp from the given date.
|
2022 | *
|
2023 | * @param date - The date to initialize the `Timestamp` from.
|
2024 | * @returns A new `Timestamp` representing the same point in time as the given
|
2025 | * date.
|
2026 | */
|
2027 | static fromDate(date: Date): Timestamp;
|
2028 | /**
|
2029 | * Creates a new timestamp from the given number of milliseconds.
|
2030 | *
|
2031 | * @param milliseconds - Number of milliseconds since Unix epoch
|
2032 | * 1970-01-01T00:00:00Z.
|
2033 | * @returns A new `Timestamp` representing the same point in time as the given
|
2034 | * number of milliseconds.
|
2035 | */
|
2036 | static fromMillis(milliseconds: number): Timestamp;
|
2037 | /**
|
2038 | * Creates a new timestamp.
|
2039 | *
|
2040 | * @param seconds - The number of seconds of UTC time since Unix epoch
|
2041 | * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
2042 | * 9999-12-31T23:59:59Z inclusive.
|
2043 | * @param nanoseconds - The non-negative fractions of a second at nanosecond
|
2044 | * resolution. Negative second values with fractions must still have
|
2045 | * non-negative nanoseconds values that count forward in time. Must be
|
2046 | * from 0 to 999,999,999 inclusive.
|
2047 | */
|
2048 | constructor(
|
2049 | |
2050 |
|
2051 |
|
2052 | seconds: number,
|
2053 | |
2054 |
|
2055 |
|
2056 | nanoseconds: number);
|
2057 | /**
|
2058 | * Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
2059 | * causes a loss of precision since `Date` objects only support millisecond
|
2060 | * precision.
|
2061 | *
|
2062 | * @returns JavaScript `Date` object representing the same point in time as
|
2063 | * this `Timestamp`, with millisecond precision.
|
2064 | */
|
2065 | toDate(): Date;
|
2066 | /**
|
2067 | * Converts a `Timestamp` to a numeric timestamp (in milliseconds since
|
2068 | * epoch). This operation causes a loss of precision.
|
2069 | *
|
2070 | * @returns The point in time corresponding to this timestamp, represented as
|
2071 | * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
|
2072 | */
|
2073 | toMillis(): number;
|
2074 | /**
|
2075 | * Returns true if this `Timestamp` is equal to the provided one.
|
2076 | *
|
2077 | * @param other - The `Timestamp` to compare against.
|
2078 | * @returns true if this `Timestamp` is equal to the provided one.
|
2079 | */
|
2080 | isEqual(other: Timestamp): boolean;
|
2081 | /** Returns a textual representation of this `Timestamp`. */
|
2082 | toString(): string;
|
2083 | /** Returns a JSON-serializable representation of this `Timestamp`. */
|
2084 | toJSON(): {
|
2085 | seconds: number;
|
2086 | nanoseconds: number;
|
2087 | };
|
2088 | /**
|
2089 | * Converts this object to a primitive string, which allows `Timestamp` objects
|
2090 | * to be compared using the `>`, `<=`, `>=` and `>` operators.
|
2091 | */
|
2092 | valueOf(): string;
|
2093 | }
|
2094 | /**
|
2095 | * A reference to a transaction.
|
2096 | *
|
2097 | * The `Transaction` object passed to a transaction's `updateFunction` provides
|
2098 | * the methods to read and write data within the transaction context. See
|
2099 | * {@link runTransaction}.
|
2100 | */
|
2101 | export declare class Transaction {
|
2102 | private constructor();
|
2103 | /**
|
2104 | * Reads the document referenced by the provided {@link DocumentReference}.
|
2105 | *
|
2106 | * @param documentRef - A reference to the document to be read.
|
2107 | * @returns A `DocumentSnapshot` with the read data.
|
2108 | */
|
2109 | get<T>(documentRef: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
2110 | /**
|
2111 | * Writes to the document referred to by the provided {@link
|
2112 | * DocumentReference}. If the document does not exist yet, it will be created.
|
2113 | *
|
2114 | * @param documentRef - A reference to the document to be set.
|
2115 | * @param data - An object of the fields and values for the document.
|
2116 | * @throws Error - If the provided input is not a valid Firestore document.
|
2117 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2118 | */
|
2119 | set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): this;
|
2120 | /**
|
2121 | * Writes to the document referred to by the provided {@link
|
2122 | * DocumentReference}. If the document does not exist yet, it will be created.
|
2123 | * If you provide `merge` or `mergeFields`, the provided data can be merged
|
2124 | * into an existing document.
|
2125 | *
|
2126 | * @param documentRef - A reference to the document to be set.
|
2127 | * @param data - An object of the fields and values for the document.
|
2128 | * @param options - An object to configure the set behavior.
|
2129 | * @throws Error - If the provided input is not a valid Firestore document.
|
2130 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2131 | */
|
2132 | set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): this;
|
2133 | /**
|
2134 | * Updates fields in the document referred to by the provided {@link
|
2135 | * DocumentReference}. The update will fail if applied to a document that does
|
2136 | * not exist.
|
2137 | *
|
2138 | * @param documentRef - A reference to the document to be updated.
|
2139 | * @param data - An object containing the fields and values with which to
|
2140 | update the document. Fields can contain dots to reference nested fields
|
2141 | within the document.
|
2142 | * @throws Error - If the provided input is not valid Firestore data.
|
2143 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2144 | */
|
2145 | update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): this;
|
2146 | /**
|
2147 | * Updates fields in the document referred to by the provided {@link
|
2148 | * DocumentReference}. The update will fail if applied to a document that does
|
2149 | * not exist.
|
2150 | *
|
2151 | * Nested fields can be updated by providing dot-separated field path
|
2152 | * strings or by providing `FieldPath` objects.
|
2153 | *
|
2154 | * @param documentRef - A reference to the document to be updated.
|
2155 | * @param field - The first field to update.
|
2156 | * @param value - The first value.
|
2157 | * @param moreFieldsAndValues - Additional key/value pairs.
|
2158 | * @throws Error - If the provided input is not valid Firestore data.
|
2159 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2160 | */
|
2161 | update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this;
|
2162 | /**
|
2163 | * Deletes the document referred to by the provided {@link DocumentReference}.
|
2164 | *
|
2165 | * @param documentRef - A reference to the document to be deleted.
|
2166 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2167 | */
|
2168 | delete(documentRef: DocumentReference<unknown>): this;
|
2169 | }
|
2170 | /**
|
2171 | * @license
|
2172 | * Copyright 2022 Google LLC
|
2173 | *
|
2174 | * Licensed under the Apache License, Version 2.0 (the "License");
|
2175 | * you may not use this file except in compliance with the License.
|
2176 | * You may obtain a copy of the License at
|
2177 | *
|
2178 | * http://www.apache.org/licenses/LICENSE-2.0
|
2179 | *
|
2180 | * Unless required by applicable law or agreed to in writing, software
|
2181 | * distributed under the License is distributed on an "AS IS" BASIS,
|
2182 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2183 | * See the License for the specific language governing permissions and
|
2184 | * limitations under the License.
|
2185 | */
|
2186 | /**
|
2187 | * Options to customize transaction behavior.
|
2188 | */
|
2189 | export declare interface TransactionOptions {
|
2190 | /** Maximum number of attempts to commit, after which transaction fails. Default is 5. */
|
2191 | readonly maxAttempts?: number;
|
2192 | }
|
2193 | /**
|
2194 | * Given a union type `U = T1 | T2 | ...`, returns an intersected type
|
2195 | * `(T1 & T2 & ...)`.
|
2196 | *
|
2197 | * Uses distributive conditional types and inference from conditional types.
|
2198 | * This works because multiple candidates for the same type variable in
|
2199 | * contra-variant positions causes an intersection type to be inferred.
|
2200 | * https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types
|
2201 | * https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
|
2202 | */
|
2203 | export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
2204 |
|
2205 |
|
2206 |
|
2207 | export declare interface Unsubscribe {
|
2208 |
|
2209 | (): void;
|
2210 | }
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 |
|
2217 | export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
|
2218 | [K in keyof T]?: UpdateData<T[K]> | FieldValue;
|
2219 | } & NestedUpdateFields<T> : Partial<T>;
|
2220 |
|
2221 |
|
2222 |
|
2223 |
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 |
|
2229 |
|
2230 |
|
2231 |
|
2232 | export declare function updateDoc<T>(reference: DocumentReference<T>, data: UpdateData<T>): Promise<void>;
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 |
|
2242 |
|
2243 |
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 | export declare function updateDoc(reference: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise<void>;
|
2249 |
|
2250 |
|
2251 |
|
2252 |
|
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 |
|
2264 |
|
2265 | export declare function waitForPendingWrites(firestore: Firestore): Promise<void>;
|
2266 |
|
2267 |
|
2268 |
|
2269 |
|
2270 |
|
2271 |
|
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 | export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint;
|
2278 |
|
2279 |
|
2280 |
|
2281 |
|
2282 |
|
2283 | export declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';
|
2284 |
|
2285 |
|
2286 |
|
2287 |
|
2288 | export declare type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? {
|
2289 | [K in keyof T]: WithFieldValue<T[K]> | FieldValue;
|
2290 | } : never);
|
2291 |
|
2292 |
|
2293 |
|
2294 |
|
2295 |
|
2296 |
|
2297 |
|
2298 |
|
2299 | export declare class WriteBatch {
|
2300 | private constructor();
|
2301 | /**
|
2302 | * Writes to the document referred to by the provided {@link
|
2303 | * DocumentReference}. If the document does not exist yet, it will be created.
|
2304 | *
|
2305 | * @param documentRef - A reference to the document to be set.
|
2306 | * @param data - An object of the fields and values for the document.
|
2307 | * @returns This `WriteBatch` instance. Used for chaining method calls.
|
2308 | */
|
2309 | set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): WriteBatch;
|
2310 | |
2311 |
|
2312 |
|
2313 |
|
2314 |
|
2315 |
|
2316 |
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 | set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): WriteBatch;
|
2323 | |
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 |
|
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 | update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): WriteBatch;
|
2336 | |
2337 |
|
2338 |
|
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 | update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;
|
2352 | |
2353 |
|
2354 |
|
2355 |
|
2356 |
|
2357 |
|
2358 | delete(documentRef: DocumentReference<unknown>): WriteBatch;
|
2359 | |
2360 |
|
2361 |
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 |
|
2371 | commit(): Promise<void>;
|
2372 | }
|
2373 |
|
2374 |
|
2375 |
|
2376 |
|
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 | export declare function writeBatch(firestore: Firestore): WriteBatch;
|
2385 | export {};
|