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 | type: string;
|
35 | }
|
36 |
|
37 |
|
38 |
|
39 | export declare type AggregateFieldType = AggregateField<number>;
|
40 |
|
41 |
|
42 |
|
43 | export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
|
44 |
|
45 | readonly type = "AggregateQuerySnapshot";
|
46 | |
47 |
|
48 |
|
49 |
|
50 | readonly query: Query<unknown>;
|
51 | private constructor();
|
52 | /**
|
53 | * Returns the results of the aggregations performed over the underlying
|
54 | * query.
|
55 | *
|
56 | * The keys of the returned object will be the same as those of the
|
57 | * `AggregateSpec` object specified to the aggregation method, and the values
|
58 | * will be the corresponding aggregation result.
|
59 | *
|
60 | * @returns The results of the aggregations performed over the underlying
|
61 | * query.
|
62 | */
|
63 | data(): AggregateSpecData<T>;
|
64 | }
|
65 | /**
|
66 | * Compares two `AggregateQuerySnapshot` instances for equality.
|
67 | *
|
68 | * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
|
69 | * underlying queries that compare equal, and the same data.
|
70 | *
|
71 | * @param left - The first `AggregateQuerySnapshot` to compare.
|
72 | * @param right - The second `AggregateQuerySnapshot` to compare.
|
73 | *
|
74 | * @returns `true` if the objects are "equal", as defined above, or `false`
|
75 | * otherwise.
|
76 | */
|
77 | export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
|
78 | /**
|
79 | * A type whose property values are all `AggregateField` objects.
|
80 | */
|
81 | export declare interface AggregateSpec {
|
82 | [field: string]: AggregateFieldType;
|
83 | }
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | export declare type AggregateSpecData<T extends AggregateSpec> = {
|
90 | [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
|
91 | };
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | export declare function arrayRemove(...elements: unknown[]): FieldValue;
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | export declare function arrayUnion(...elements: unknown[]): FieldValue;
|
117 |
|
118 |
|
119 |
|
120 | export declare class Bytes {
|
121 | private constructor();
|
122 | /**
|
123 | * Creates a new `Bytes` object from the given Base64 string, converting it to
|
124 | * bytes.
|
125 | *
|
126 | * @param base64 - The Base64 string used to create the `Bytes` object.
|
127 | */
|
128 | static fromBase64String(base64: string): Bytes;
|
129 | /**
|
130 | * Creates a new `Bytes` object from the given Uint8Array.
|
131 | *
|
132 | * @param array - The Uint8Array used to create the `Bytes` object.
|
133 | */
|
134 | static fromUint8Array(array: Uint8Array): Bytes;
|
135 | /**
|
136 | * Returns the underlying bytes as a Base64-encoded string.
|
137 | *
|
138 | * @returns The Base64-encoded string created from the `Bytes` object.
|
139 | */
|
140 | toBase64(): string;
|
141 | /**
|
142 | * Returns the underlying bytes in a new `Uint8Array`.
|
143 | *
|
144 | * @returns The Uint8Array created from the `Bytes` object.
|
145 | */
|
146 | toUint8Array(): Uint8Array;
|
147 | /**
|
148 | * Returns a string representation of the `Bytes` object.
|
149 | *
|
150 | * @returns A string representation of the `Bytes` object.
|
151 | */
|
152 | toString(): string;
|
153 | /**
|
154 | * Returns true if this `Bytes` object is equal to the provided one.
|
155 | *
|
156 | * @param other - The `Bytes` object to compare against.
|
157 | * @returns true if this `Bytes` object is equal to the provided one.
|
158 | */
|
159 | isEqual(other: Bytes): boolean;
|
160 | }
|
161 | /* Excluded from this release type: _ByteString */
|
162 | /**
|
163 | * Constant used to indicate the LRU garbage collection should be disabled.
|
164 | * Set this value as the `cacheSizeBytes` on the settings passed to the
|
165 | * {@link Firestore} instance.
|
166 | */
|
167 | export declare const CACHE_SIZE_UNLIMITED = -1;
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 | export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 | export declare function clearIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 | export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | export declare function collection(reference: CollectionReference<unknown>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 | export declare function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData>;
|
253 |
|
254 |
|
255 |
|
256 |
|
257 | export declare class CollectionReference<T = DocumentData> extends Query<T> {
|
258 |
|
259 | readonly type = "collection";
|
260 | private constructor();
|
261 | /** The collection's identifier. */
|
262 | get id(): string;
|
263 | /**
|
264 | * A string representing the path of the referenced collection (relative
|
265 | * to the root of the database).
|
266 | */
|
267 | get path(): string;
|
268 | /**
|
269 | * A reference to the containing `DocumentReference` if this is a
|
270 | * subcollection. If this isn't a subcollection, the reference is null.
|
271 | */
|
272 | get parent(): DocumentReference<DocumentData> | null;
|
273 | /**
|
274 | * Applies a custom data converter to this `CollectionReference`, allowing you
|
275 | * to use your own custom model objects with Firestore. When you call {@link
|
276 | * addDoc} with the returned `CollectionReference` instance, the provided
|
277 | * converter will convert between Firestore data and your custom type `U`.
|
278 | *
|
279 | * @param converter - Converts objects to and from Firestore.
|
280 | * @returns A `CollectionReference<U>` that uses the provided converter.
|
281 | */
|
282 | withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | withConverter(converter: null): CollectionReference<DocumentData>;
|
291 | }
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 | export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
|
306 | mockUserToken?: EmulatorMockTokenOptions | string;
|
307 | }): void;
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 | export declare function deleteDoc(reference: DocumentReference<unknown>): Promise<void>;
|
316 |
|
317 |
|
318 |
|
319 |
|
320 | export declare function deleteField(): FieldValue;
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 | export declare function disableNetwork(firestore: Firestore): Promise<void>;
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 | export declare function doc<T>(reference: CollectionReference<T>, path?: string, ...pathSegments: string[]): DocumentReference<T>;
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 | export declare function doc(reference: DocumentReference<unknown>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
|
372 |
|
373 |
|
374 |
|
375 |
|
376 | export declare interface DocumentChange<T = DocumentData> {
|
377 |
|
378 | readonly type: DocumentChangeType;
|
379 |
|
380 | readonly doc: QueryDocumentSnapshot<T>;
|
381 | |
382 |
|
383 |
|
384 |
|
385 |
|
386 | readonly oldIndex: number;
|
387 | |
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 | readonly newIndex: number;
|
394 | }
|
395 |
|
396 |
|
397 |
|
398 | export declare type DocumentChangeType = 'added' | 'removed' | 'modified';
|
399 |
|
400 |
|
401 |
|
402 |
|
403 | export declare interface DocumentData {
|
404 |
|
405 | [field: string]: any;
|
406 | }
|
407 |
|
408 |
|
409 |
|
410 |
|
411 | export declare function documentId(): FieldPath;
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 | export declare class DocumentReference<T = DocumentData> {
|
418 | |
419 |
|
420 |
|
421 | readonly converter: FirestoreDataConverter<T> | null;
|
422 |
|
423 | readonly type = "document";
|
424 | |
425 |
|
426 |
|
427 |
|
428 | readonly firestore: Firestore;
|
429 | private constructor();
|
430 | /**
|
431 | * The document's identifier within its collection.
|
432 | */
|
433 | get id(): string;
|
434 | /**
|
435 | * A string representing the path of the referenced document (relative
|
436 | * to the root of the database).
|
437 | */
|
438 | get path(): string;
|
439 | /**
|
440 | * The collection this `DocumentReference` belongs to.
|
441 | */
|
442 | get parent(): CollectionReference<T>;
|
443 | /**
|
444 | * Applies a custom data converter to this `DocumentReference`, allowing you
|
445 | * to use your own custom model objects with Firestore. When you call {@link
|
446 | * @firebase/firestore/lite#(setDoc:1)}, {@link @firebase/firestore/lite#getDoc}, etc. with the returned `DocumentReference`
|
447 | * instance, the provided converter will convert between Firestore data and
|
448 | * your custom type `U`.
|
449 | *
|
450 | * @param converter - Converts objects to and from Firestore.
|
451 | * @returns A `DocumentReference<U>` that uses the provided converter.
|
452 | */
|
453 | withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
|
454 | |
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | withConverter(converter: null): DocumentReference<DocumentData>;
|
461 | }
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 | export declare class DocumentSnapshot<T = DocumentData> {
|
472 | |
473 |
|
474 |
|
475 |
|
476 | readonly metadata: SnapshotMetadata;
|
477 | protected constructor();
|
478 | /**
|
479 | * Returns whether or not the data exists. True if the document exists.
|
480 | */
|
481 | exists(): this is QueryDocumentSnapshot<T>;
|
482 | /**
|
483 | * Retrieves all fields in the document as an `Object`. Returns `undefined` if
|
484 | * the document doesn't exist.
|
485 | *
|
486 | * By default, `serverTimestamp()` values that have not yet been
|
487 | * set to their final value will be returned as `null`. You can override
|
488 | * this by passing an options object.
|
489 | *
|
490 | * @param options - An options object to configure how data is retrieved from
|
491 | * the snapshot (for example the desired behavior for server timestamps that
|
492 | * have not yet been set to their final value).
|
493 | * @returns An `Object` containing all fields in the document or `undefined` if
|
494 | * the document doesn't exist.
|
495 | */
|
496 | data(options?: SnapshotOptions): T | undefined;
|
497 | /**
|
498 | * Retrieves the field specified by `fieldPath`. Returns `undefined` if the
|
499 | * document or field doesn't exist.
|
500 | *
|
501 | * By default, a `serverTimestamp()` that has not yet been set to
|
502 | * its final value will be returned as `null`. You can override this by
|
503 | * passing an options object.
|
504 | *
|
505 | * @param fieldPath - The path (for example 'foo' or 'foo.bar') to a specific
|
506 | * field.
|
507 | * @param options - An options object to configure how the field is retrieved
|
508 | * from the snapshot (for example the desired behavior for server timestamps
|
509 | * that have not yet been set to their final value).
|
510 | * @returns The data at the specified field location or undefined if no such
|
511 | * field exists in the document.
|
512 | */
|
513 | get(fieldPath: string | FieldPath, options?: SnapshotOptions): any;
|
514 | /**
|
515 | * Property of the `DocumentSnapshot` that provides the document's ID.
|
516 | */
|
517 | get id(): string;
|
518 | /**
|
519 | * The `DocumentReference` for the document included in the `DocumentSnapshot`.
|
520 | */
|
521 | get ref(): DocumentReference<T>;
|
522 | }
|
523 | /* Excluded from this release type: _EmptyAppCheckTokenProvider */
|
524 | /* Excluded from this release type: _EmptyAuthCredentialsProvider */
|
525 | export { EmulatorMockTokenOptions };
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 | export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 | export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 | export declare function enableNetwork(firestore: Firestore): Promise<void>;
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 | export declare function endAt(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 | export declare function endAt(...fieldValues: unknown[]): QueryConstraint;
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 | export declare function endBefore(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 | export declare function endBefore(...fieldValues: unknown[]): QueryConstraint;
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 | export declare class FieldPath {
|
629 | |
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 | constructor(...fieldNames: string[]);
|
636 | /**
|
637 | * Returns true if this `FieldPath` is equal to the provided one.
|
638 | *
|
639 | * @param other - The `FieldPath` to compare against.
|
640 | * @returns true if this `FieldPath` is equal to the provided one.
|
641 | */
|
642 | isEqual(other: FieldPath): boolean;
|
643 | }
|
644 | /**
|
645 | * Sentinel values that can be used when writing document fields with `set()`
|
646 | * or `update()`.
|
647 | */
|
648 | export declare abstract class FieldValue {
|
649 | private constructor();
|
650 | /** Compares `FieldValue`s for equality. */
|
651 | abstract isEqual(other: FieldValue): boolean;
|
652 | }
|
653 | /* Excluded from this release type: _FirebaseService */
|
654 | /**
|
655 | * The Cloud Firestore service interface.
|
656 | *
|
657 | * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
|
658 | */
|
659 | export declare class Firestore {
|
660 | |
661 |
|
662 |
|
663 | type: 'firestore-lite' | 'firestore';
|
664 | private constructor();
|
665 | /**
|
666 | * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
|
667 | * instance.
|
668 | */
|
669 | get app(): FirebaseApp;
|
670 | |
671 |
|
672 |
|
673 | toJSON(): object;
|
674 | }
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
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 | export declare interface FirestoreDataConverter<T> {
|
718 | |
719 |
|
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 | toFirestore(modelObject: WithFieldValue<T>): DocumentData;
|
728 | |
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 | toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions): DocumentData;
|
740 | |
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 | fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>, options?: SnapshotOptions): T;
|
748 | }
|
749 |
|
750 | export declare class FirestoreError extends FirebaseError {
|
751 | |
752 |
|
753 |
|
754 | readonly code: FirestoreErrorCode;
|
755 | |
756 |
|
757 |
|
758 | readonly message: string;
|
759 |
|
760 | readonly stack?: string;
|
761 | private constructor();
|
762 | }
|
763 | /**
|
764 | * The set of Firestore status codes. The codes are the same at the ones
|
765 | * exposed by gRPC here:
|
766 | * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
767 | *
|
768 | * Possible values:
|
769 | * - 'cancelled': The operation was cancelled (typically by the caller).
|
770 | * - 'unknown': Unknown error or an error from a different error domain.
|
771 | * - 'invalid-argument': Client specified an invalid argument. Note that this
|
772 | * differs from 'failed-precondition'. 'invalid-argument' indicates
|
773 | * arguments that are problematic regardless of the state of the system
|
774 | * (e.g. an invalid field name).
|
775 | * - 'deadline-exceeded': Deadline expired before operation could complete.
|
776 | * For operations that change the state of the system, this error may be
|
777 | * returned even if the operation has completed successfully. For example,
|
778 | * a successful response from a server could have been delayed long enough
|
779 | * for the deadline to expire.
|
780 | * - 'not-found': Some requested document was not found.
|
781 | * - 'already-exists': Some document that we attempted to create already
|
782 | * exists.
|
783 | * - 'permission-denied': The caller does not have permission to execute the
|
784 | * specified operation.
|
785 | * - 'resource-exhausted': Some resource has been exhausted, perhaps a
|
786 | * per-user quota, or perhaps the entire file system is out of space.
|
787 | * - 'failed-precondition': Operation was rejected because the system is not
|
788 | * in a state required for the operation's execution.
|
789 | * - 'aborted': The operation was aborted, typically due to a concurrency
|
790 | * issue like transaction aborts, etc.
|
791 | * - 'out-of-range': Operation was attempted past the valid range.
|
792 | * - 'unimplemented': Operation is not implemented or not supported/enabled.
|
793 | * - 'internal': Internal errors. Means some invariants expected by
|
794 | * underlying system has been broken. If you see one of these errors,
|
795 | * something is very broken.
|
796 | * - 'unavailable': The service is currently unavailable. This is most likely
|
797 | * a transient condition and may be corrected by retrying with a backoff.
|
798 | * - 'data-loss': Unrecoverable data loss or corruption.
|
799 | * - 'unauthenticated': The request does not have valid authentication
|
800 | * credentials for the operation.
|
801 | */
|
802 | 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';
|
803 | /**
|
804 | * Specifies custom configurations for your Cloud Firestore instance.
|
805 | * You must set these before invoking any other methods.
|
806 | */
|
807 | export declare interface FirestoreSettings {
|
808 | |
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 | cacheSizeBytes?: number;
|
819 | |
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 | experimentalForceLongPolling?: boolean;
|
834 | |
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 | experimentalAutoDetectLongPolling?: boolean;
|
843 | |
844 |
|
845 |
|
846 | host?: string;
|
847 | |
848 |
|
849 |
|
850 | ssl?: boolean;
|
851 | |
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 | ignoreUndefinedProperties?: boolean;
|
858 | }
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 | export declare class GeoPoint {
|
883 | |
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 | constructor(latitude: number, longitude: number);
|
890 | /**
|
891 | * The latitude of this `GeoPoint` instance.
|
892 | */
|
893 | get latitude(): number;
|
894 | /**
|
895 | * The longitude of this `GeoPoint` instance.
|
896 | */
|
897 | get longitude(): number;
|
898 | /**
|
899 | * Returns true if this `GeoPoint` is equal to the provided one.
|
900 | *
|
901 | * @param other - The `GeoPoint` to compare against.
|
902 | * @returns true if this `GeoPoint` is equal to the provided one.
|
903 | */
|
904 | isEqual(other: GeoPoint): boolean;
|
905 | /** Returns a JSON-serializable representation of this GeoPoint. */
|
906 | toJSON(): {
|
907 | latitude: number;
|
908 | longitude: number;
|
909 | };
|
910 | }
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 | export declare function getCountFromServer(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
|
933 | count: AggregateField<number>;
|
934 | }>>;
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 | export declare function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 | export declare function getDocFromCache<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 | export declare function getDocFromServer<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 | export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
975 |
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 | export declare function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 | export declare function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 | export declare function getFirestore(app: FirebaseApp): Firestore;
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 | export declare function getFirestore(): Firestore;
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 | export declare function increment(n: number): FieldValue;
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 | export declare interface Index {
|
1034 |
|
1035 | readonly collectionGroup: string;
|
1036 |
|
1037 | readonly fields?: IndexField[];
|
1038 | [key: string]: unknown;
|
1039 | }
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 | export declare interface IndexConfiguration {
|
1048 |
|
1049 | readonly indexes?: Index[];
|
1050 | [key: string]: unknown;
|
1051 | }
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 | export declare interface IndexField {
|
1057 |
|
1058 | readonly fieldPath: string;
|
1059 | |
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 | readonly arrayConfig?: 'CONTAINS';
|
1066 | |
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 | readonly order?: 'ASCENDING' | 'DESCENDING';
|
1073 | [key: string]: unknown;
|
1074 | }
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 | export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 | export declare function limit(limit: number): QueryConstraint;
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 | export declare function limitToLast(limit: number): QueryConstraint;
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 | export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 | export declare class LoadBundleTask implements PromiseLike<LoadBundleTaskProgress> {
|
1125 | |
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 | onProgress(next?: (progress: LoadBundleTaskProgress) => unknown, error?: (err: Error) => unknown, complete?: () => void): void;
|
1134 | |
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 | catch<R>(onRejected: (a: Error) => R | PromiseLike<R>): Promise<R | LoadBundleTaskProgress>;
|
1140 | /**
|
1141 | * Implements the `Promise<LoadBundleTaskProgress>.then` interface.
|
1142 | *
|
1143 | * @param onFulfilled - Called on the completion of the loading task with a final `LoadBundleTaskProgress` update.
|
1144 | * The update will always have its `taskState` set to `"Success"`.
|
1145 | * @param onRejected - Called when an error occurs during bundle loading.
|
1146 | */
|
1147 | then<T, R>(onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>, onRejected?: (a: Error) => R | PromiseLike<R>): Promise<T | R>;
|
1148 | }
|
1149 | /**
|
1150 | * Represents a progress update or a final state from loading bundles.
|
1151 | */
|
1152 | export declare interface LoadBundleTaskProgress {
|
1153 | /** How many documents have been loaded. */
|
1154 | documentsLoaded: number;
|
1155 | /** How many documents are in the bundle being loaded. */
|
1156 | totalDocuments: number;
|
1157 | /** How many bytes have been loaded. */
|
1158 | bytesLoaded: number;
|
1159 | /** How many bytes are in the bundle being loaded. */
|
1160 | totalBytes: number;
|
1161 | /** Current task state. */
|
1162 | taskState: TaskState;
|
1163 | }
|
1164 | export { LogLevel };
|
1165 | /**
|
1166 | * Reads a Firestore {@link Query} from local cache, identified by the given
|
1167 | * name.
|
1168 | *
|
1169 | * The named queries are packaged into bundles on the server side (along
|
1170 | * with resulting documents), and loaded to local cache using `loadBundle`. Once
|
1171 | * in local cache, use this method to extract a {@link Query} by name.
|
1172 | *
|
1173 | * @param firestore - The {@link Firestore} instance to read the query from.
|
1174 | * @param name - The name of the query.
|
1175 | * @returns A `Promise` that is resolved with the Query or `null`.
|
1176 | */
|
1177 | export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;
|
1178 | /**
|
1179 | * For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1,
|
1180 | * 'bar.qux': T2}). Intersect them together to make a single map containing
|
1181 | * all possible keys that are all marked as optional
|
1182 | */
|
1183 | export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{
|
1184 | [K in keyof T & string]: ChildUpdateFields<K, T[K]>;
|
1185 | }[keyof T & string]>;
|
1186 | /**
|
1187 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1188 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1189 | * object with `next` and `error` callbacks.
|
1190 | *
|
1191 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1192 | * never be called because the snapshot stream is never-ending.
|
1193 | *
|
1194 | * @param reference - A reference to the document to listen to.
|
1195 | * @param observer - A single object containing `next` and `error` callbacks.
|
1196 | * @returns An unsubscribe function that can be called to cancel
|
1197 | * the snapshot listener.
|
1198 | */
|
1199 | export declare function onSnapshot<T>(reference: DocumentReference<T>, observer: {
|
1200 | next?: (snapshot: DocumentSnapshot<T>) => void;
|
1201 | error?: (error: FirestoreError) => void;
|
1202 | complete?: () => void;
|
1203 | }): Unsubscribe;
|
1204 | /**
|
1205 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1206 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1207 | * object with `next` and `error` callbacks.
|
1208 | *
|
1209 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1210 | * never be called because the snapshot stream is never-ending.
|
1211 | *
|
1212 | * @param reference - A reference to the document to listen to.
|
1213 | * @param options - Options controlling the listen behavior.
|
1214 | * @param observer - A single object containing `next` and `error` callbacks.
|
1215 | * @returns An unsubscribe function that can be called to cancel
|
1216 | * the snapshot listener.
|
1217 | */
|
1218 | export declare function onSnapshot<T>(reference: DocumentReference<T>, options: SnapshotListenOptions, observer: {
|
1219 | next?: (snapshot: DocumentSnapshot<T>) => void;
|
1220 | error?: (error: FirestoreError) => void;
|
1221 | complete?: () => void;
|
1222 | }): Unsubscribe;
|
1223 | /**
|
1224 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1225 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1226 | * object with `next` and `error` callbacks.
|
1227 | *
|
1228 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1229 | * never be called because the snapshot stream is never-ending.
|
1230 | *
|
1231 | * @param reference - A reference to the document to listen to.
|
1232 | * @param onNext - A callback to be called every time a new `DocumentSnapshot`
|
1233 | * is available.
|
1234 | * @param onError - A callback to be called if the listen fails or is
|
1235 | * cancelled. No further callbacks will occur.
|
1236 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1237 | * never ending.
|
1238 | * @returns An unsubscribe function that can be called to cancel
|
1239 | * the snapshot listener.
|
1240 | */
|
1241 | export declare function onSnapshot<T>(reference: DocumentReference<T>, onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1242 | /**
|
1243 | * Attaches a listener for `DocumentSnapshot` events. You may either pass
|
1244 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1245 | * object with `next` and `error` callbacks.
|
1246 | *
|
1247 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1248 | * never be called because the snapshot stream is never-ending.
|
1249 | *
|
1250 | * @param reference - A reference to the document to listen to.
|
1251 | * @param options - Options controlling the listen behavior.
|
1252 | * @param onNext - A callback to be called every time a new `DocumentSnapshot`
|
1253 | * is available.
|
1254 | * @param onError - A callback to be called if the listen fails or is
|
1255 | * cancelled. No further callbacks will occur.
|
1256 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1257 | * never ending.
|
1258 | * @returns An unsubscribe function that can be called to cancel
|
1259 | * the snapshot listener.
|
1260 | */
|
1261 | export declare function onSnapshot<T>(reference: DocumentReference<T>, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1262 | /**
|
1263 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1264 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1265 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1266 | * calling the function that is returned when `onSnapshot` is called.
|
1267 | *
|
1268 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1269 | * never be called because the snapshot stream is never-ending.
|
1270 | *
|
1271 | * @param query - The query to listen to.
|
1272 | * @param observer - A single object containing `next` and `error` callbacks.
|
1273 | * @returns An unsubscribe function that can be called to cancel
|
1274 | * the snapshot listener.
|
1275 | */
|
1276 | export declare function onSnapshot<T>(query: Query<T>, observer: {
|
1277 | next?: (snapshot: QuerySnapshot<T>) => void;
|
1278 | error?: (error: FirestoreError) => void;
|
1279 | complete?: () => void;
|
1280 | }): Unsubscribe;
|
1281 | /**
|
1282 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1283 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1284 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1285 | * calling the function that is returned when `onSnapshot` is called.
|
1286 | *
|
1287 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1288 | * never be called because the snapshot stream is never-ending.
|
1289 | *
|
1290 | * @param query - The query to listen to.
|
1291 | * @param options - Options controlling the listen behavior.
|
1292 | * @param observer - A single object containing `next` and `error` callbacks.
|
1293 | * @returns An unsubscribe function that can be called to cancel
|
1294 | * the snapshot listener.
|
1295 | */
|
1296 | export declare function onSnapshot<T>(query: Query<T>, options: SnapshotListenOptions, observer: {
|
1297 | next?: (snapshot: QuerySnapshot<T>) => void;
|
1298 | error?: (error: FirestoreError) => void;
|
1299 | complete?: () => void;
|
1300 | }): Unsubscribe;
|
1301 | /**
|
1302 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1303 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1304 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1305 | * calling the function that is returned when `onSnapshot` is called.
|
1306 | *
|
1307 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1308 | * never be called because the snapshot stream is never-ending.
|
1309 | *
|
1310 | * @param query - The query to listen to.
|
1311 | * @param onNext - A callback to be called every time a new `QuerySnapshot`
|
1312 | * is available.
|
1313 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1314 | * never ending.
|
1315 | * @param onError - A callback to be called if the listen fails or is
|
1316 | * cancelled. No further callbacks will occur.
|
1317 | * @returns An unsubscribe function that can be called to cancel
|
1318 | * the snapshot listener.
|
1319 | */
|
1320 | export declare function onSnapshot<T>(query: Query<T>, onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1321 | /**
|
1322 | * Attaches a listener for `QuerySnapshot` events. You may either pass
|
1323 | * individual `onNext` and `onError` callbacks or pass a single observer
|
1324 | * object with `next` and `error` callbacks. The listener can be cancelled by
|
1325 | * calling the function that is returned when `onSnapshot` is called.
|
1326 | *
|
1327 | * NOTE: Although an `onCompletion` callback can be provided, it will
|
1328 | * never be called because the snapshot stream is never-ending.
|
1329 | *
|
1330 | * @param query - The query to listen to.
|
1331 | * @param options - Options controlling the listen behavior.
|
1332 | * @param onNext - A callback to be called every time a new `QuerySnapshot`
|
1333 | * is available.
|
1334 | * @param onCompletion - Can be provided, but will not be called since streams are
|
1335 | * never ending.
|
1336 | * @param onError - A callback to be called if the listen fails or is
|
1337 | * cancelled. No further callbacks will occur.
|
1338 | * @returns An unsubscribe function that can be called to cancel
|
1339 | * the snapshot listener.
|
1340 | */
|
1341 | export declare function onSnapshot<T>(query: Query<T>, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;
|
1342 | /**
|
1343 | * Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
|
1344 | * event indicates that all listeners affected by a given change have fired,
|
1345 | * even if a single server-generated change affects multiple listeners.
|
1346 | *
|
1347 | * NOTE: The snapshots-in-sync event only indicates that listeners are in sync
|
1348 | * with each other, but does not relate to whether those snapshots are in sync
|
1349 | * with the server. Use SnapshotMetadata in the individual listeners to
|
1350 | * determine if a snapshot is from the cache or the server.
|
1351 | *
|
1352 | * @param firestore - The instance of Firestore for synchronizing snapshots.
|
1353 | * @param observer - A single object containing `next` and `error` callbacks.
|
1354 | * @returns An unsubscribe function that can be called to cancel the snapshot
|
1355 | * listener.
|
1356 | */
|
1357 | export declare function onSnapshotsInSync(firestore: Firestore, observer: {
|
1358 | next?: (value: void) => void;
|
1359 | error?: (error: FirestoreError) => void;
|
1360 | complete?: () => void;
|
1361 | }): Unsubscribe;
|
1362 | /**
|
1363 | * Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
|
1364 | * event indicates that all listeners affected by a given change have fired,
|
1365 | * even if a single server-generated change affects multiple listeners.
|
1366 | *
|
1367 | * NOTE: The snapshots-in-sync event only indicates that listeners are in sync
|
1368 | * with each other, but does not relate to whether those snapshots are in sync
|
1369 | * with the server. Use `SnapshotMetadata` in the individual listeners to
|
1370 | * determine if a snapshot is from the cache or the server.
|
1371 | *
|
1372 | * @param firestore - The `Firestore` instance for synchronizing snapshots.
|
1373 | * @param onSync - A callback to be called every time all snapshot listeners are
|
1374 | * in sync with each other.
|
1375 | * @returns An unsubscribe function that can be called to cancel the snapshot
|
1376 | * listener.
|
1377 | */
|
1378 | export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe;
|
1379 | /**
|
1380 | * Creates a {@link QueryConstraint} that sorts the query result by the
|
1381 | * specified field, optionally in descending order instead of ascending.
|
1382 | *
|
1383 | * @param fieldPath - The field to sort by.
|
1384 | * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
|
1385 | * not specified, order will be ascending.
|
1386 | * @returns The created {@link Query}.
|
1387 | */
|
1388 | export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryConstraint;
|
1389 | /**
|
1390 | * The direction of a {@link orderBy} clause is specified as 'desc' or 'asc'
|
1391 | * (descending or ascending).
|
1392 | */
|
1393 | export declare type OrderByDirection = 'desc' | 'asc';
|
1394 | /**
|
1395 | * Similar to Typescript's `Partial<T>`, but allows nested fields to be
|
1396 | * omitted and FieldValues to be passed in as property values.
|
1397 | */
|
1398 | export declare type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T extends {} ? {
|
1399 | [K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue;
|
1400 | } : never);
|
1401 | /**
|
1402 | * Settings that can be passed to `enableIndexedDbPersistence()` to configure
|
1403 | * Firestore persistence.
|
1404 | */
|
1405 | export declare interface PersistenceSettings {
|
1406 | /**
|
1407 | * Whether to force enable persistence for the client. This cannot be used
|
1408 | * with multi-tab synchronization and is primarily intended for use with Web
|
1409 | * Workers. Setting this to `true` will enable persistence, but cause other
|
1410 | * tabs using persistence to fail.
|
1411 | */
|
1412 | forceOwnership?: boolean;
|
1413 | }
|
1414 | /**
|
1415 | * These types primarily exist to support the `UpdateData`,
|
1416 | * `WithFieldValue`, and `PartialWithFieldValue` types and are not consumed
|
1417 | * directly by the end developer.
|
1418 | */
|
1419 | /** Primitive types. */
|
1420 | export declare type Primitive = string | number | boolean | undefined | null;
|
1421 | /**
|
1422 | * A `Query` refers to a query which you can read or listen to. You can also
|
1423 | * construct refined `Query` objects by adding filters and ordering.
|
1424 | */
|
1425 | export declare class Query<T = DocumentData> {
|
1426 | /**
|
1427 | * If provided, the `FirestoreDataConverter` associated with this instance.
|
1428 | */
|
1429 | readonly converter: FirestoreDataConverter<T> | null;
|
1430 | /** The type of this Firestore reference. */
|
1431 | readonly type: 'query' | 'collection';
|
1432 | /**
|
1433 | * The `Firestore` instance for the Firestore database (useful for performing
|
1434 | * transactions, etc.).
|
1435 | */
|
1436 | readonly firestore: Firestore;
|
1437 | protected constructor();
|
1438 | /**
|
1439 | * Removes the current converter.
|
1440 | *
|
1441 | * @param converter - `null` removes the current converter.
|
1442 | * @returns A `Query<DocumentData>` that does not use a converter.
|
1443 | */
|
1444 | withConverter(converter: null): Query<DocumentData>;
|
1445 | /**
|
1446 | * Applies a custom data converter to this query, allowing you to use your own
|
1447 | * custom model objects with Firestore. When you call {@link getDocs} with
|
1448 | * the returned query, the provided converter will convert between Firestore
|
1449 | * data and your custom type `U`.
|
1450 | *
|
1451 | * @param converter - Converts objects to and from Firestore.
|
1452 | * @returns A `Query<U>` that uses the provided converter.
|
1453 | */
|
1454 | withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
|
1455 | }
|
1456 | /**
|
1457 | * Creates a new immutable instance of {@link Query} that is extended to also include
|
1458 | * additional query constraints.
|
1459 | *
|
1460 | * @param query - The {@link Query} instance to use as a base for the new constraints.
|
1461 | * @param queryConstraints - The list of {@link QueryConstraint}s to apply.
|
1462 | * @throws if any of the provided query constraints cannot be combined with the
|
1463 | * existing or new constraints.
|
1464 | */
|
1465 | export declare function query<T>(query: Query<T>, ...queryConstraints: QueryConstraint[]): Query<T>;
|
1466 | /**
|
1467 | * A `QueryConstraint` is used to narrow the set of documents returned by a
|
1468 | * Firestore query. `QueryConstraint`s are created by invoking {@link where},
|
1469 | * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link
|
1470 | * endBefore:1}, {@link (endAt:1)}, {@link limit} or {@link limitToLast} and
|
1471 | * can then be passed to {@link query} to create a new query instance that
|
1472 | * also contains this `QueryConstraint`.
|
1473 | */
|
1474 | export declare abstract class QueryConstraint {
|
1475 | /** The type of this query constraints */
|
1476 | abstract readonly type: QueryConstraintType;
|
1477 | }
|
1478 | /** Describes the different query constraints available in this SDK. */
|
1479 | export declare type QueryConstraintType = 'where' | 'orderBy' | 'limit' | 'limitToLast' | 'startAt' | 'startAfter' | 'endAt' | 'endBefore';
|
1480 | /**
|
1481 | * A `QueryDocumentSnapshot` contains data read from a document in your
|
1482 | * Firestore database as part of a query. The document is guaranteed to exist
|
1483 | * and its data can be extracted with `.data()` or `.get(<field>)` to get a
|
1484 | * specific field.
|
1485 | *
|
1486 | * A `QueryDocumentSnapshot` offers the same API surface as a
|
1487 | * `DocumentSnapshot`. Since query results contain only existing documents, the
|
1488 | * `exists` property will always be true and `data()` will never return
|
1489 | * 'undefined'.
|
1490 | */
|
1491 | export declare class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
|
1492 | /**
|
1493 | * Retrieves all fields in the document as an `Object`.
|
1494 | *
|
1495 | * By default, `serverTimestamp()` values that have not yet been
|
1496 | * set to their final value will be returned as `null`. You can override
|
1497 | * this by passing an options object.
|
1498 | *
|
1499 | * @override
|
1500 | * @param options - An options object to configure how data is retrieved from
|
1501 | * the snapshot (for example the desired behavior for server timestamps that
|
1502 | * have not yet been set to their final value).
|
1503 | * @returns An `Object` containing all fields in the document.
|
1504 | */
|
1505 | data(options?: SnapshotOptions): T;
|
1506 | }
|
1507 | /**
|
1508 | * Returns true if the provided queries point to the same collection and apply
|
1509 | * the same constraints.
|
1510 | *
|
1511 | * @param left - A `Query` to compare.
|
1512 | * @param right - A `Query` to compare.
|
1513 | * @returns true if the references point to the same location in the same
|
1514 | * Firestore database.
|
1515 | */
|
1516 | export declare function queryEqual<T>(left: Query<T>, right: Query<T>): boolean;
|
1517 | /**
|
1518 | * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects
|
1519 | * representing the results of a query. The documents can be accessed as an
|
1520 | * array via the `docs` property or enumerated using the `forEach` method. The
|
1521 | * number of documents can be determined via the `empty` and `size`
|
1522 | * properties.
|
1523 | */
|
1524 | export declare class QuerySnapshot<T = DocumentData> {
|
1525 | /**
|
1526 | * Metadata about this snapshot, concerning its source and if it has local
|
1527 | * modifications.
|
1528 | */
|
1529 | readonly metadata: SnapshotMetadata;
|
1530 | /**
|
1531 | * The query on which you called `get` or `onSnapshot` in order to get this
|
1532 | * `QuerySnapshot`.
|
1533 | */
|
1534 | readonly query: Query<T>;
|
1535 | private constructor();
|
1536 | /** An array of all the documents in the `QuerySnapshot`. */
|
1537 | get docs(): Array<QueryDocumentSnapshot<T>>;
|
1538 | /** The number of documents in the `QuerySnapshot`. */
|
1539 | get size(): number;
|
1540 | /** True if there are no documents in the `QuerySnapshot`. */
|
1541 | get empty(): boolean;
|
1542 | /**
|
1543 | * Enumerates all of the documents in the `QuerySnapshot`.
|
1544 | *
|
1545 | * @param callback - A callback to be called with a `QueryDocumentSnapshot` for
|
1546 | * each document in the snapshot.
|
1547 | * @param thisArg - The `this` binding for the callback.
|
1548 | */
|
1549 | forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: unknown): void;
|
1550 | /**
|
1551 | * Returns an array of the documents changes since the last snapshot. If this
|
1552 | * is the first snapshot, all documents will be in the list as 'added'
|
1553 | * changes.
|
1554 | *
|
1555 | * @param options - `SnapshotListenOptions` that control whether metadata-only
|
1556 | * changes (i.e. only `DocumentSnapshot.metadata` changed) should trigger
|
1557 | * snapshot events.
|
1558 | */
|
1559 | docChanges(options?: SnapshotListenOptions): Array<DocumentChange<T>>;
|
1560 | }
|
1561 | /**
|
1562 | * Returns true if the provided references are equal.
|
1563 | *
|
1564 | * @param left - A reference to compare.
|
1565 | * @param right - A reference to compare.
|
1566 | * @returns true if the references point to the same location in the same
|
1567 | * Firestore database.
|
1568 | */
|
1569 | export declare function refEqual<T>(left: DocumentReference<T> | CollectionReference<T>, right: DocumentReference<T> | CollectionReference<T>): boolean;
|
1570 | /* Excluded from this release type: _ResourcePath */
|
1571 | /**
|
1572 | * Executes the given `updateFunction` and then attempts to commit the changes
|
1573 | * applied within the transaction. If any document read within the transaction
|
1574 | * has changed, Cloud Firestore retries the `updateFunction`. If it fails to
|
1575 | * commit after 5 attempts, the transaction fails.
|
1576 | *
|
1577 | * The maximum number of writes allowed in a single transaction is 500.
|
1578 | *
|
1579 | * @param firestore - A reference to the Firestore database to run this
|
1580 | * transaction against.
|
1581 | * @param updateFunction - The function to execute within the transaction
|
1582 | * context.
|
1583 | * @param options - An options object to configure maximum number of attempts to
|
1584 | * commit.
|
1585 | * @returns If the transaction completed successfully or was explicitly aborted
|
1586 | * (the `updateFunction` returned a failed promise), the promise returned by the
|
1587 | * `updateFunction `is returned here. Otherwise, if the transaction failed, a
|
1588 | * rejected promise with the corresponding failure error is returned.
|
1589 | */
|
1590 | export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
1591 | /**
|
1592 | * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
|
1593 | * include a server-generated timestamp in the written data.
|
1594 | */
|
1595 | export declare function serverTimestamp(): FieldValue;
|
1596 | /**
|
1597 | * Writes to the document referred to by this `DocumentReference`. If the
|
1598 | * document does not yet exist, it will be created.
|
1599 | *
|
1600 | * @param reference - A reference to the document to write.
|
1601 | * @param data - A map of the fields and values for the document.
|
1602 | * @returns A `Promise` resolved once the data has been successfully written
|
1603 | * to the backend (note that it won't resolve while you're offline).
|
1604 | */
|
1605 | export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFieldValue<T>): Promise<void>;
|
1606 | /**
|
1607 | * Writes to the document referred to by the specified `DocumentReference`. If
|
1608 | * the document does not yet exist, it will be created. If you provide `merge`
|
1609 | * or `mergeFields`, the provided data can be merged into an existing document.
|
1610 | *
|
1611 | * @param reference - A reference to the document to write.
|
1612 | * @param data - A map of the fields and values for the document.
|
1613 | * @param options - An object to configure the set behavior.
|
1614 | * @returns A Promise resolved once the data has been successfully written
|
1615 | * to the backend (note that it won't resolve while you're offline).
|
1616 | */
|
1617 | export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
|
1618 | /**
|
1619 | * Configures indexing for local query execution. Any previous index
|
1620 | * configuration is overridden. The `Promise` resolves once the index
|
1621 | * configuration has been persisted.
|
1622 | *
|
1623 | * The index entries themselves are created asynchronously. You can continue to
|
1624 | * use queries that require indexing even if the indices are not yet available.
|
1625 | * Query execution will automatically start using the index once the index
|
1626 | * entries have been written.
|
1627 | *
|
1628 | * Indexes are only supported with IndexedDb persistence. Invoke either
|
1629 | * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
1630 | * before setting an index configuration. If IndexedDb is not enabled, any
|
1631 | * index configuration is ignored.
|
1632 | *
|
1633 | * @param firestore - The {@link Firestore} instance to configure indexes for.
|
1634 | * @param configuration -The index definition.
|
1635 | * @throws FirestoreError if the JSON format is invalid.
|
1636 | * @returns A `Promise` that resolves once all indices are successfully
|
1637 | * configured.
|
1638 | * @beta
|
1639 | */
|
1640 | export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;
|
1641 | /**
|
1642 | * Configures indexing for local query execution. Any previous index
|
1643 | * configuration is overridden. The `Promise` resolves once the index
|
1644 | * configuration has been persisted.
|
1645 | *
|
1646 | * The index entries themselves are created asynchronously. You can continue to
|
1647 | * use queries that require indexing even if the indices are not yet available.
|
1648 | * Query execution will automatically start using the index once the index
|
1649 | * entries have been written.
|
1650 | *
|
1651 | * Indexes are only supported with IndexedDb persistence. Invoke either
|
1652 | * `enableIndexedDbPersistence()` or `enableMultiTabIndexedDbPersistence()`
|
1653 | * before setting an index configuration. If IndexedDb is not enabled, any
|
1654 | * index configuration is ignored.
|
1655 | *
|
1656 | * The method accepts the JSON format exported by the Firebase CLI (`firebase
|
1657 | * firestore:indexes`). If the JSON format is invalid, this method throws an
|
1658 | * error.
|
1659 | *
|
1660 | * @param firestore - The {@link Firestore} instance to configure indexes for.
|
1661 | * @param json -The JSON format exported by the Firebase CLI.
|
1662 | * @throws FirestoreError if the JSON format is invalid.
|
1663 | * @returns A `Promise` that resolves once all indices are successfully
|
1664 | * configured.
|
1665 | * @beta
|
1666 | */
|
1667 | export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;
|
1668 | /**
|
1669 | * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
|
1670 | *
|
1671 | * @param logLevel - The verbosity you set for activity and error logging. Can
|
1672 | * be any of the following values:
|
1673 | *
|
1674 | * <ul>
|
1675 | * <li>`debug` for the most verbose logging level, primarily for
|
1676 | * debugging.</li>
|
1677 | * <li>`error` to log errors only.</li>
|
1678 | * <li><code>`silent` to turn off logging.</li>
|
1679 | * </ul>
|
1680 | */
|
1681 | export declare function setLogLevel(logLevel: LogLevel): void;
|
1682 | /**
|
1683 | * An options object that configures the behavior of {@link @firebase/firestore/lite#(setDoc:1)}, {@link
|
1684 | * @firebase/firestore/lite#(WriteBatch.set:1)} and {@link @firebase/firestore/lite#(Transaction.set:1)} calls. These calls can be
|
1685 | * configured to perform granular merges instead of overwriting the target
|
1686 | * documents in their entirety by providing a `SetOptions` with `merge: true`.
|
1687 | *
|
1688 | * @param merge - Changes the behavior of a `setDoc()` call to only replace the
|
1689 | * values specified in its data argument. Fields omitted from the `setDoc()`
|
1690 | * call remain untouched. If your input sets any field to an empty map, all
|
1691 | * nested fields are overwritten.
|
1692 | * @param mergeFields - Changes the behavior of `setDoc()` calls to only replace
|
1693 | * the specified field paths. Any field path that is not specified is ignored
|
1694 | * and remains untouched. If your input sets any field to an empty map, all
|
1695 | * nested fields are overwritten.
|
1696 | */
|
1697 | export declare type SetOptions = {
|
1698 | readonly merge?: boolean;
|
1699 | } | {
|
1700 | readonly mergeFields?: Array<string | FieldPath>;
|
1701 | };
|
1702 | /**
|
1703 | * Returns true if the provided snapshots are equal.
|
1704 | *
|
1705 | * @param left - A snapshot to compare.
|
1706 | * @param right - A snapshot to compare.
|
1707 | * @returns true if the snapshots are equal.
|
1708 | */
|
1709 | export declare function snapshotEqual<T>(left: DocumentSnapshot<T> | QuerySnapshot<T>, right: DocumentSnapshot<T> | QuerySnapshot<T>): boolean;
|
1710 | /**
|
1711 | * An options object that can be passed to {@link (onSnapshot:1)} and {@link
|
1712 | * QuerySnapshot.docChanges} to control which types of changes to include in the
|
1713 | * result set.
|
1714 | */
|
1715 | export declare interface SnapshotListenOptions {
|
1716 | /**
|
1717 | * Include a change even if only the metadata of the query or of a document
|
1718 | * changed. Default is false.
|
1719 | */
|
1720 | readonly includeMetadataChanges?: boolean;
|
1721 | }
|
1722 | /**
|
1723 | * Metadata about a snapshot, describing the state of the snapshot.
|
1724 | */
|
1725 | export declare class SnapshotMetadata {
|
1726 | /**
|
1727 | * True if the snapshot contains the result of local writes (for example
|
1728 | * `set()` or `update()` calls) that have not yet been committed to the
|
1729 | * backend. If your listener has opted into metadata updates (via
|
1730 | * `SnapshotListenOptions`) you will receive another snapshot with
|
1731 | * `hasPendingWrites` equal to false once the writes have been committed to
|
1732 | * the backend.
|
1733 | */
|
1734 | readonly hasPendingWrites: boolean;
|
1735 | /**
|
1736 | * True if the snapshot was created from cached data rather than guaranteed
|
1737 | * up-to-date server data. If your listener has opted into metadata updates
|
1738 | * (via `SnapshotListenOptions`) you will receive another snapshot with
|
1739 | * `fromCache` set to false once the client has received up-to-date data from
|
1740 | * the backend.
|
1741 | */
|
1742 | readonly fromCache: boolean;
|
1743 | private constructor();
|
1744 | /**
|
1745 | * Returns true if this `SnapshotMetadata` is equal to the provided one.
|
1746 | *
|
1747 | * @param other - The `SnapshotMetadata` to compare against.
|
1748 | * @returns true if this `SnapshotMetadata` is equal to the provided one.
|
1749 | */
|
1750 | isEqual(other: SnapshotMetadata): boolean;
|
1751 | }
|
1752 | /**
|
1753 | * Options that configure how data is retrieved from a `DocumentSnapshot` (for
|
1754 | * example the desired behavior for server timestamps that have not yet been set
|
1755 | * to their final value).
|
1756 | */
|
1757 | export declare interface SnapshotOptions {
|
1758 | /**
|
1759 | * If set, controls the return value for server timestamps that have not yet
|
1760 | * been set to their final value.
|
1761 | *
|
1762 | * By specifying 'estimate', pending server timestamps return an estimate
|
1763 | * based on the local clock. This estimate will differ from the final value
|
1764 | * and cause these values to change once the server result becomes available.
|
1765 | *
|
1766 | * By specifying 'previous', pending timestamps will be ignored and return
|
1767 | * their previous value instead.
|
1768 | *
|
1769 | * If omitted or set to 'none', `null` will be returned by default until the
|
1770 | * server value becomes available.
|
1771 | */
|
1772 | readonly serverTimestamps?: 'estimate' | 'previous' | 'none';
|
1773 | }
|
1774 | /**
|
1775 | * Creates a {@link QueryConstraint} that modifies the result set to start after the
|
1776 | * provided document (exclusive). The starting position is relative to the order
|
1777 | * of the query. The document must contain all of the fields provided in the
|
1778 | * orderBy of the query.
|
1779 | *
|
1780 | * @param snapshot - The snapshot of the document to start after.
|
1781 | * @returns A {@link QueryConstraint} to pass to `query()`
|
1782 | */
|
1783 | export declare function startAfter(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
1784 | /**
|
1785 | * Creates a {@link QueryConstraint} that modifies the result set to start after the
|
1786 | * provided fields relative to the order of the query. The order of the field
|
1787 | * values must match the order of the order by clauses of the query.
|
1788 | *
|
1789 | * @param fieldValues - The field values to start this query after, in order
|
1790 | * of the query's order by.
|
1791 | * @returns A {@link QueryConstraint} to pass to `query()`
|
1792 | */
|
1793 | export declare function startAfter(...fieldValues: unknown[]): QueryConstraint;
|
1794 | /**
|
1795 | * Creates a {@link QueryConstraint} that modifies the result set to start at the
|
1796 | * provided document (inclusive). The starting position is relative to the order
|
1797 | * of the query. The document must contain all of the fields provided in the
|
1798 | * `orderBy` of this query.
|
1799 | *
|
1800 | * @param snapshot - The snapshot of the document to start at.
|
1801 | * @returns A {@link QueryConstraint} to pass to `query()`.
|
1802 | */
|
1803 | export declare function startAt(snapshot: DocumentSnapshot<unknown>): QueryConstraint;
|
1804 | /**
|
1805 | * Creates a {@link QueryConstraint} that modifies the result set to start at the
|
1806 | * provided fields relative to the order of the query. The order of the field
|
1807 | * values must match the order of the order by clauses of the query.
|
1808 | *
|
1809 | * @param fieldValues - The field values to start this query at, in order
|
1810 | * of the query's order by.
|
1811 | * @returns A {@link QueryConstraint} to pass to `query()`.
|
1812 | */
|
1813 | export declare function startAt(...fieldValues: unknown[]): QueryConstraint;
|
1814 | /**
|
1815 | * Represents the state of bundle loading tasks.
|
1816 | *
|
1817 | * Both 'Error' and 'Success' are sinking state: task will abort or complete and there will
|
1818 | * be no more updates after they are reported.
|
1819 | */
|
1820 | export declare type TaskState = 'Error' | 'Running' | 'Success';
|
1821 | /**
|
1822 | * Terminates the provided {@link Firestore} instance.
|
1823 | *
|
1824 | * After calling `terminate()` only the `clearIndexedDbPersistence()` function
|
1825 | * may be used. Any other function will throw a `FirestoreError`.
|
1826 | *
|
1827 | * To restart after termination, create a new instance of FirebaseFirestore with
|
1828 | * {@link (getFirestore:1)}.
|
1829 | *
|
1830 | * Termination does not cancel any pending writes, and any promises that are
|
1831 | * awaiting a response from the server will not be resolved. If you have
|
1832 | * persistence enabled, the next time you start this instance, it will resume
|
1833 | * sending these writes to the server.
|
1834 | *
|
1835 | * Note: Under normal circumstances, calling `terminate()` is not required. This
|
1836 | * function is useful only when you want to force this instance to release all
|
1837 | * of its resources or in combination with `clearIndexedDbPersistence()` to
|
1838 | * ensure that all local state is destroyed between test runs.
|
1839 | *
|
1840 | * @returns A `Promise` that is resolved when the instance has been successfully
|
1841 | * terminated.
|
1842 | */
|
1843 | export declare function terminate(firestore: Firestore): Promise<void>;
|
1844 | /**
|
1845 | * @license
|
1846 | * Copyright 2017 Google LLC
|
1847 | *
|
1848 | * Licensed under the Apache License, Version 2.0 (the "License");
|
1849 | * you may not use this file except in compliance with the License.
|
1850 | * You may obtain a copy of the License at
|
1851 | *
|
1852 | * http://www.apache.org/licenses/LICENSE-2.0
|
1853 | *
|
1854 | * Unless required by applicable law or agreed to in writing, software
|
1855 | * distributed under the License is distributed on an "AS IS" BASIS,
|
1856 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
1857 | * See the License for the specific language governing permissions and
|
1858 | * limitations under the License.
|
1859 | */
|
1860 | /**
|
1861 | * A `Timestamp` represents a point in time independent of any time zone or
|
1862 | * calendar, represented as seconds and fractions of seconds at nanosecond
|
1863 | * resolution in UTC Epoch time.
|
1864 | *
|
1865 | * It is encoded using the Proleptic Gregorian Calendar which extends the
|
1866 | * Gregorian calendar backwards to year one. It is encoded assuming all minutes
|
1867 | * are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second
|
1868 | * table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
|
1869 | * 9999-12-31T23:59:59.999999999Z.
|
1870 | *
|
1871 | * For examples and further specifications, refer to the
|
1872 | * {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
|
1873 | */
|
1874 | export declare class Timestamp {
|
1875 | /**
|
1876 | * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
|
1877 | */
|
1878 | readonly seconds: number;
|
1879 | /**
|
1880 | * The fractions of a second at nanosecond resolution.*
|
1881 | */
|
1882 | readonly nanoseconds: number;
|
1883 | /**
|
1884 | * Creates a new timestamp with the current date, with millisecond precision.
|
1885 | *
|
1886 | * @returns a new timestamp representing the current date.
|
1887 | */
|
1888 | static now(): Timestamp;
|
1889 | /**
|
1890 | * Creates a new timestamp from the given date.
|
1891 | *
|
1892 | * @param date - The date to initialize the `Timestamp` from.
|
1893 | * @returns A new `Timestamp` representing the same point in time as the given
|
1894 | * date.
|
1895 | */
|
1896 | static fromDate(date: Date): Timestamp;
|
1897 | /**
|
1898 | * Creates a new timestamp from the given number of milliseconds.
|
1899 | *
|
1900 | * @param milliseconds - Number of milliseconds since Unix epoch
|
1901 | * 1970-01-01T00:00:00Z.
|
1902 | * @returns A new `Timestamp` representing the same point in time as the given
|
1903 | * number of milliseconds.
|
1904 | */
|
1905 | static fromMillis(milliseconds: number): Timestamp;
|
1906 | /**
|
1907 | * Creates a new timestamp.
|
1908 | *
|
1909 | * @param seconds - The number of seconds of UTC time since Unix epoch
|
1910 | * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
1911 | * 9999-12-31T23:59:59Z inclusive.
|
1912 | * @param nanoseconds - The non-negative fractions of a second at nanosecond
|
1913 | * resolution. Negative second values with fractions must still have
|
1914 | * non-negative nanoseconds values that count forward in time. Must be
|
1915 | * from 0 to 999,999,999 inclusive.
|
1916 | */
|
1917 | constructor(
|
1918 | |
1919 |
|
1920 |
|
1921 | seconds: number,
|
1922 | |
1923 |
|
1924 |
|
1925 | nanoseconds: number);
|
1926 | /**
|
1927 | * Converts a `Timestamp` to a JavaScript `Date` object. This conversion
|
1928 | * causes a loss of precision since `Date` objects only support millisecond
|
1929 | * precision.
|
1930 | *
|
1931 | * @returns JavaScript `Date` object representing the same point in time as
|
1932 | * this `Timestamp`, with millisecond precision.
|
1933 | */
|
1934 | toDate(): Date;
|
1935 | /**
|
1936 | * Converts a `Timestamp` to a numeric timestamp (in milliseconds since
|
1937 | * epoch). This operation causes a loss of precision.
|
1938 | *
|
1939 | * @returns The point in time corresponding to this timestamp, represented as
|
1940 | * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
|
1941 | */
|
1942 | toMillis(): number;
|
1943 | /**
|
1944 | * Returns true if this `Timestamp` is equal to the provided one.
|
1945 | *
|
1946 | * @param other - The `Timestamp` to compare against.
|
1947 | * @returns true if this `Timestamp` is equal to the provided one.
|
1948 | */
|
1949 | isEqual(other: Timestamp): boolean;
|
1950 | /** Returns a textual representation of this `Timestamp`. */
|
1951 | toString(): string;
|
1952 | /** Returns a JSON-serializable representation of this `Timestamp`. */
|
1953 | toJSON(): {
|
1954 | seconds: number;
|
1955 | nanoseconds: number;
|
1956 | };
|
1957 | /**
|
1958 | * Converts this object to a primitive string, which allows `Timestamp` objects
|
1959 | * to be compared using the `>`, `<=`, `>=` and `>` operators.
|
1960 | */
|
1961 | valueOf(): string;
|
1962 | }
|
1963 | /**
|
1964 | * A reference to a transaction.
|
1965 | *
|
1966 | * The `Transaction` object passed to a transaction's `updateFunction` provides
|
1967 | * the methods to read and write data within the transaction context. See
|
1968 | * {@link runTransaction}.
|
1969 | */
|
1970 | export declare class Transaction {
|
1971 | private constructor();
|
1972 | /**
|
1973 | * Reads the document referenced by the provided {@link DocumentReference}.
|
1974 | *
|
1975 | * @param documentRef - A reference to the document to be read.
|
1976 | * @returns A `DocumentSnapshot` with the read data.
|
1977 | */
|
1978 | get<T>(documentRef: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
|
1979 | /**
|
1980 | * Writes to the document referred to by the provided {@link
|
1981 | * DocumentReference}. If the document does not exist yet, it will be created.
|
1982 | *
|
1983 | * @param documentRef - A reference to the document to be set.
|
1984 | * @param data - An object of the fields and values for the document.
|
1985 | * @throws Error - If the provided input is not a valid Firestore document.
|
1986 | * @returns This `Transaction` instance. Used for chaining method calls.
|
1987 | */
|
1988 | set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): this;
|
1989 | /**
|
1990 | * Writes to the document referred to by the provided {@link
|
1991 | * DocumentReference}. If the document does not exist yet, it will be created.
|
1992 | * If you provide `merge` or `mergeFields`, the provided data can be merged
|
1993 | * into an existing document.
|
1994 | *
|
1995 | * @param documentRef - A reference to the document to be set.
|
1996 | * @param data - An object of the fields and values for the document.
|
1997 | * @param options - An object to configure the set behavior.
|
1998 | * @throws Error - If the provided input is not a valid Firestore document.
|
1999 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2000 | */
|
2001 | set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): this;
|
2002 | /**
|
2003 | * Updates fields in the document referred to by the provided {@link
|
2004 | * DocumentReference}. The update will fail if applied to a document that does
|
2005 | * not exist.
|
2006 | *
|
2007 | * @param documentRef - A reference to the document to be updated.
|
2008 | * @param data - An object containing the fields and values with which to
|
2009 | update the document. Fields can contain dots to reference nested fields
|
2010 | within the document.
|
2011 | * @throws Error - If the provided input is not valid Firestore data.
|
2012 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2013 | */
|
2014 | update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): this;
|
2015 | /**
|
2016 | * Updates fields in the document referred to by the provided {@link
|
2017 | * DocumentReference}. The update will fail if applied to a document that does
|
2018 | * not exist.
|
2019 | *
|
2020 | * Nested fields can be updated by providing dot-separated field path
|
2021 | * strings or by providing `FieldPath` objects.
|
2022 | *
|
2023 | * @param documentRef - A reference to the document to be updated.
|
2024 | * @param field - The first field to update.
|
2025 | * @param value - The first value.
|
2026 | * @param moreFieldsAndValues - Additional key/value pairs.
|
2027 | * @throws Error - If the provided input is not valid Firestore data.
|
2028 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2029 | */
|
2030 | update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this;
|
2031 | /**
|
2032 | * Deletes the document referred to by the provided {@link DocumentReference}.
|
2033 | *
|
2034 | * @param documentRef - A reference to the document to be deleted.
|
2035 | * @returns This `Transaction` instance. Used for chaining method calls.
|
2036 | */
|
2037 | delete(documentRef: DocumentReference<unknown>): this;
|
2038 | }
|
2039 | /**
|
2040 | * @license
|
2041 | * Copyright 2022 Google LLC
|
2042 | *
|
2043 | * Licensed under the Apache License, Version 2.0 (the "License");
|
2044 | * you may not use this file except in compliance with the License.
|
2045 | * You may obtain a copy of the License at
|
2046 | *
|
2047 | * http://www.apache.org/licenses/LICENSE-2.0
|
2048 | *
|
2049 | * Unless required by applicable law or agreed to in writing, software
|
2050 | * distributed under the License is distributed on an "AS IS" BASIS,
|
2051 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2052 | * See the License for the specific language governing permissions and
|
2053 | * limitations under the License.
|
2054 | */
|
2055 | /**
|
2056 | * Options to customize transaction behavior.
|
2057 | */
|
2058 | export declare interface TransactionOptions {
|
2059 | /** Maximum number of attempts to commit, after which transaction fails. Default is 5. */
|
2060 | readonly maxAttempts?: number;
|
2061 | }
|
2062 | /**
|
2063 | * Given a union type `U = T1 | T2 | ...`, returns an intersected type
|
2064 | * `(T1 & T2 & ...)`.
|
2065 | *
|
2066 | * Uses distributive conditional types and inference from conditional types.
|
2067 | * This works because multiple candidates for the same type variable in
|
2068 | * contra-variant positions causes an intersection type to be inferred.
|
2069 | * https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types
|
2070 | * https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
|
2071 | */
|
2072 | export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
2073 |
|
2074 |
|
2075 |
|
2076 | export declare interface Unsubscribe {
|
2077 |
|
2078 | (): void;
|
2079 | }
|
2080 |
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 | export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
|
2087 | [K in keyof T]?: UpdateData<T[K]> | FieldValue;
|
2088 | } & NestedUpdateFields<T> : Partial<T>;
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 | export declare function updateDoc<T>(reference: DocumentReference<T>, data: UpdateData<T>): Promise<void>;
|
2102 |
|
2103 |
|
2104 |
|
2105 |
|
2106 |
|
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 |
|
2117 | export declare function updateDoc(reference: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise<void>;
|
2118 |
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 | export declare function waitForPendingWrites(firestore: Firestore): Promise<void>;
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 |
|
2145 |
|
2146 | export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryConstraint;
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 |
|
2152 | export declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';
|
2153 |
|
2154 |
|
2155 |
|
2156 |
|
2157 | export declare type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? {
|
2158 | [K in keyof T]: WithFieldValue<T[K]> | FieldValue;
|
2159 | } : never);
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 |
|
2166 |
|
2167 |
|
2168 | export declare class WriteBatch {
|
2169 | private constructor();
|
2170 | /**
|
2171 | * Writes to the document referred to by the provided {@link
|
2172 | * DocumentReference}. If the document does not exist yet, it will be created.
|
2173 | *
|
2174 | * @param documentRef - A reference to the document to be set.
|
2175 | * @param data - An object of the fields and values for the document.
|
2176 | * @returns This `WriteBatch` instance. Used for chaining method calls.
|
2177 | */
|
2178 | set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): WriteBatch;
|
2179 | |
2180 |
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 | set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): WriteBatch;
|
2192 | |
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 |
|
2202 |
|
2203 |
|
2204 | update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): WriteBatch;
|
2205 | |
2206 |
|
2207 |
|
2208 |
|
2209 |
|
2210 |
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 | update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;
|
2221 | |
2222 |
|
2223 |
|
2224 |
|
2225 |
|
2226 |
|
2227 | delete(documentRef: DocumentReference<unknown>): WriteBatch;
|
2228 | |
2229 |
|
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 | commit(): Promise<void>;
|
2241 | }
|
2242 |
|
2243 |
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 |
|
2249 |
|
2250 |
|
2251 |
|
2252 |
|
2253 | export declare function writeBatch(firestore: Firestore): WriteBatch;
|
2254 | export {};
|