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]& |