12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083 |
- /**
- * Firestore Lite
- *
- * @remarks Firestore Lite is a small online-only SDK that allows read
- * and write access to your Firestore database. All operations connect
- * directly to the backend, and `onSnapshot()` APIs are not supported.
- * @packageDocumentation
- */
-
- import { DocumentData as DocumentData_2 } from '@firebase/firestore-types';
- import { EmulatorMockTokenOptions } from '@firebase/util';
- import { FirebaseApp } from '@firebase/app';
- import { FirebaseError } from '@firebase/util';
- import { LogLevelString as LogLevel } from '@firebase/logger';
- import { SetOptions as SetOptions_2 } from '@firebase/firestore-types';
-
- /* Excluded from this release type: AbstractUserDataWriter */
-
- /**
- * Add a new document to specified `CollectionReference` with the given data,
- * assigning it a document ID automatically.
- *
- * The result of this write will only be reflected in document reads that occur
- * after the returned promise resolves. If the client is offline, the
- * write fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @param reference - A reference to the collection to add this document to.
- * @param data - An Object containing the data for the new document.
- * @throws Error - If the provided input is not a valid Firestore document.
- * @returns A `Promise` resolved with a `DocumentReference` pointing to the
- * newly created document after it has been written to the backend.
- */
- export declare function addDoc<T>(reference: CollectionReference<T>, data: WithFieldValue<T>): Promise<DocumentReference<T>>;
-
- /**
- * Returns a new map where every key is prefixed with the outer key appended
- * to a dot.
- */
- export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
- [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
- };
-
- /**
- * Represents an aggregation that can be performed by Firestore.
- */
- export declare class AggregateField<T> {
- /** A type string to uniquely identify instances of this class. */
- type: string;
- }
-
- /**
- * The union of all `AggregateField` types that are supported by Firestore.
- */
- export declare type AggregateFieldType = AggregateField<number>;
-
- /**
- * The results of executing an aggregation query.
- */
- export declare class AggregateQuerySnapshot<T extends AggregateSpec> {
- private readonly _data;
- /** A type string to uniquely identify instances of this class. */
- readonly type = "AggregateQuerySnapshot";
- /**
- * The underlying query over which the aggregations recorded in this
- * `AggregateQuerySnapshot` were performed.
- */
- readonly query: Query<unknown>;
- /** @hideconstructor */
- constructor(query: Query<unknown>, _data: AggregateSpecData<T>);
- /**
- * Returns the results of the aggregations performed over the underlying
- * query.
- *
- * The keys of the returned object will be the same as those of the
- * `AggregateSpec` object specified to the aggregation method, and the values
- * will be the corresponding aggregation result.
- *
- * @returns The results of the aggregations performed over the underlying
- * query.
- */
- data(): AggregateSpecData<T>;
- }
-
- /**
- * Compares two `AggregateQuerySnapshot` instances for equality.
- *
- * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
- * underlying queries that compare equal, and the same data.
- *
- * @param left - The first `AggregateQuerySnapshot` to compare.
- * @param right - The second `AggregateQuerySnapshot` to compare.
- *
- * @returns `true` if the objects are "equal", as defined above, or `false`
- * otherwise.
- */
- export declare function aggregateQuerySnapshotEqual<T extends AggregateSpec>(left: AggregateQuerySnapshot<T>, right: AggregateQuerySnapshot<T>): boolean;
-
- /**
- * A type whose property values are all `AggregateField` objects.
- */
- export declare interface AggregateSpec {
- [field: string]: AggregateFieldType;
- }
-
- /**
- * A type whose keys are taken from an `AggregateSpec`, and whose values are the
- * result of the aggregation performed by the corresponding `AggregateField`
- * from the input `AggregateSpec`.
- */
- export declare type AggregateSpecData<T extends AggregateSpec> = {
- [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
- };
-
- /* Excluded from this release type: and */
-
- declare interface ApiClientObjectMap<T> {
- [k: string]: T;
- }
-
- /**
- * An `AppliableConstraint` is an abstraction of a constraint that can be applied
- * to a Firestore query.
- */
- declare abstract class AppliableConstraint {
- /**
- * Takes the provided {@link Query} and returns a copy of the {@link Query} with this
- * {@link AppliableConstraint} applied.
- */
- abstract _apply<T>(query: Query<T>): Query<T>;
- }
-
- /**
- * Returns a special value that can be used with {@link (setDoc:1)} or {@link
- * updateDoc:1} that tells the server to remove the given elements from any
- * array value that already exists on the server. All instances of each element
- * specified will be removed from the array. If the field being modified is not
- * already an array it will be overwritten with an empty array.
- *
- * @param elements - The elements to remove from the array.
- * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
- * `updateDoc()`
- */
- export declare function arrayRemove(...elements: unknown[]): FieldValue;
-
- /**
- * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
- * @firebase/firestore/lite#(updateDoc:1)} that tells the server to union the given elements with any array
- * value that already exists on the server. Each specified element that doesn't
- * already exist in the array will be added to the end. If the field being
- * modified is not already an array it will be overwritten with an array
- * containing exactly the specified elements.
- *
- * @param elements - The elements to union into the array.
- * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
- * `updateDoc()`.
- */
- export declare function arrayUnion(...elements: unknown[]): FieldValue;
-
- declare interface AsyncQueue {
- readonly isShuttingDown: boolean;
- /**
- * Adds a new operation to the queue without waiting for it to complete (i.e.
- * we ignore the Promise result).
- */
- enqueueAndForget<T extends unknown>(op: () => Promise<T>): void;
- /**
- * Regardless if the queue has initialized shutdown, adds a new operation to the
- * queue without waiting for it to complete (i.e. we ignore the Promise result).
- */
- enqueueAndForgetEvenWhileRestricted<T extends unknown>(op: () => Promise<T>): void;
- /**
- * Initialize the shutdown of this queue. Once this method is called, the
- * only possible way to request running an operation is through
- * `enqueueEvenWhileRestricted()`.
- *
- * @param purgeExistingTasks Whether already enqueued tasked should be
- * rejected (unless enqueued wih `enqueueEvenWhileRestricted()`). Defaults
- * to false.
- */
- enterRestrictedMode(purgeExistingTasks?: boolean): void;
- /**
- * Adds a new operation to the queue. Returns a promise that will be resolved
- * when the promise returned by the new operation is (with its value).
- */
- enqueue<T extends unknown>(op: () => Promise<T>): Promise<T>;
- /**
- * Enqueue a retryable operation.
- *
- * A retryable operation is rescheduled with backoff if it fails with a
- * IndexedDbTransactionError (the error type used by SimpleDb). All
- * retryable operations are executed in order and only run if all prior
- * operations were retried successfully.
- */
- enqueueRetryable(op: () => Promise<void>): void;
- /**
- * Schedules an operation to be queued on the AsyncQueue once the specified
- * `delayMs` has elapsed. The returned DelayedOperation can be used to cancel
- * or fast-forward the operation prior to its running.
- */
- enqueueAfterDelay<T extends unknown>(timerId: TimerId, delayMs: number, op: () => Promise<T>): DelayedOperation<T>;
- /**
- * Verifies there's an operation currently in-progress on the AsyncQueue.
- * Unfortunately we can't verify that the running code is in the promise chain
- * of that operation, so this isn't a foolproof check, but it should be enough
- * to catch some bugs.
- */
- verifyOperationInProgress(): void;
- }
-
- declare type AuthTokenFactory = () => string;
-
- /**
- * Path represents an ordered sequence of string segments.
- */
- declare abstract class BasePath<B extends BasePath<B>> {
- private segments;
- private offset;
- private len;
- constructor(segments: string[], offset?: number, length?: number);
- /**
- * Abstract constructor method to construct an instance of B with the given
- * parameters.
- */
- protected abstract construct(segments: string[], offset?: number, length?: number): B;
- /**
- * Returns a String representation.
- *
- * Implementing classes are required to provide deterministic implementations as
- * the String representation is used to obtain canonical Query IDs.
- */
- abstract toString(): string;
- get length(): number;
- isEqual(other: B): boolean;
- child(nameOrPath: string | B): B;
- /** The index of one past the last segment of the path. */
- private limit;
- popFirst(size?: number): B;
- popLast(): B;
- firstSegment(): string;
- lastSegment(): string;
- get(index: number): string;
- isEmpty(): boolean;
- isPrefixOf(other: this): boolean;
- isImmediateParentOf(potentialChild: this): boolean;
- forEach(fn: (segment: string) => void): void;
- toArray(): string[];
- static comparator<T extends BasePath<T>>(p1: BasePath<T>, p2: BasePath<T>): number;
- }
-
- /**
- * Represents a bound of a query.
- *
- * The bound is specified with the given components representing a position and
- * whether it's just before or just after the position (relative to whatever the
- * query order is).
- *
- * The position represents a logical index position for a query. It's a prefix
- * of values for the (potentially implicit) order by clauses of a query.
- *
- * Bound provides a function to determine whether a document comes before or
- * after a bound. This is influenced by whether the position is just before or
- * just after the provided values.
- */
- declare class Bound {
- readonly position: Value[];
- readonly inclusive: boolean;
- constructor(position: Value[], inclusive: boolean);
- }
-
- /**
- * An immutable object representing an array of bytes.
- */
- export declare class Bytes {
- _byteString: ByteString;
- /** @hideconstructor */
- constructor(byteString: ByteString);
- /**
- * Creates a new `Bytes` object from the given Base64 string, converting it to
- * bytes.
- *
- * @param base64 - The Base64 string used to create the `Bytes` object.
- */
- static fromBase64String(base64: string): Bytes;
- /**
- * Creates a new `Bytes` object from the given Uint8Array.
- *
- * @param array - The Uint8Array used to create the `Bytes` object.
- */
- static fromUint8Array(array: Uint8Array): Bytes;
- /**
- * Returns the underlying bytes as a Base64-encoded string.
- *
- * @returns The Base64-encoded string created from the `Bytes` object.
- */
- toBase64(): string;
- /**
- * Returns the underlying bytes in a new `Uint8Array`.
- *
- * @returns The Uint8Array created from the `Bytes` object.
- */
- toUint8Array(): Uint8Array;
- /**
- * Returns a string representation of the `Bytes` object.
- *
- * @returns A string representation of the `Bytes` object.
- */
- toString(): string;
- /**
- * Returns true if this `Bytes` object is equal to the provided one.
- *
- * @param other - The `Bytes` object to compare against.
- * @returns true if this `Bytes` object is equal to the provided one.
- */
- isEqual(other: Bytes): boolean;
- }
-
- /* Excluded from this release type: ByteString */
-
- /**
- * Helper for calculating the nested fields for a given type T1. This is needed
- * to distribute union types such as `undefined | {...}` (happens for optional
- * props) or `{a: A} | {b: B}`.
- *
- * In this use case, `V` is used to distribute the union types of `T[K]` on
- * `Record`, since `T[K]` is evaluated as an expression and not distributed.
- *
- * See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types
- */
- export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;
-
- /**
- * Gets a `CollectionReference` instance that refers to the collection at
- * the specified absolute path.
- *
- * @param firestore - A reference to the root `Firestore` instance.
- * @param path - A slash-separated path to a collection.
- * @param pathSegments - Additional path segments to apply relative to the first
- * argument.
- * @throws If the final path has an even number of segments and does not point
- * to a collection.
- * @returns The `CollectionReference` instance.
- */
- export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
-
- /**
- * Gets a `CollectionReference` instance that refers to a subcollection of
- * `reference` at the the specified relative path.
- *
- * @param reference - A reference to a collection.
- * @param path - A slash-separated path to a collection.
- * @param pathSegments - Additional path segments to apply relative to the first
- * argument.
- * @throws If the final path has an even number of segments and does not point
- * to a collection.
- * @returns The `CollectionReference` instance.
- */
- export declare function collection(reference: CollectionReference<unknown>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
-
- /**
- * Gets a `CollectionReference` instance that refers to a subcollection of
- * `reference` at the the specified relative path.
- *
- * @param reference - A reference to a Firestore document.
- * @param path - A slash-separated path to a collection.
- * @param pathSegments - Additional path segments that will be applied relative
- * to the first argument.
- * @throws If the final path has an even number of segments and does not point
- * to a collection.
- * @returns The `CollectionReference` instance.
- */
- export declare function collection(reference: DocumentReference, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;
-
- /**
- * Creates and returns a new `Query` instance that includes all documents in the
- * database that are contained in a collection or subcollection with the
- * given `collectionId`.
- *
- * @param firestore - A reference to the root `Firestore` instance.
- * @param collectionId - Identifies the collections to query over. Every
- * collection or subcollection with this ID as the last segment of its path
- * will be included. Cannot contain a slash.
- * @returns The created `Query`.
- */
- export declare function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData>;
-
- /**
- * A `CollectionReference` object can be used for adding documents, getting
- * document references, and querying for documents (using {@link query}).
- */
- export declare class CollectionReference<T = DocumentData> extends Query<T> {
- readonly _path: ResourcePath;
- /** The type of this Firestore reference. */
- readonly type = "collection";
- /** @hideconstructor */
- constructor(firestore: Firestore, converter: FirestoreDataConverter<T> | null, _path: ResourcePath);
- /** The collection's identifier. */
- get id(): string;
- /**
- * A string representing the path of the referenced collection (relative
- * to the root of the database).
- */
- get path(): string;
- /**
- * A reference to the containing `DocumentReference` if this is a
- * subcollection. If this isn't a subcollection, the reference is null.
- */
- get parent(): DocumentReference<DocumentData> | null;
- /**
- * Applies a custom data converter to this `CollectionReference`, allowing you
- * to use your own custom model objects with Firestore. When you call {@link
- * addDoc} with the returned `CollectionReference` instance, the provided
- * converter will convert between Firestore data and your custom type `U`.
- *
- * @param converter - Converts objects to and from Firestore.
- * @returns A `CollectionReference<U>` that uses the provided converter.
- */
- withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
- /**
- * Removes the current converter.
- *
- * @param converter - `null` removes the current converter.
- * @returns A `CollectionReference<DocumentData>` that does not use a
- * converter.
- */
- withConverter(converter: null): CollectionReference<DocumentData>;
- }
-
- declare type CompositeFilterOp = 'OPERATOR_UNSPECIFIED' | 'AND' | 'OR';
-
- declare const enum CompositeOperator {
- OR = "or",
- AND = "and"
- }
-
- /**
- * Modify this instance to communicate with the Cloud Firestore emulator.
- *
- * Note: This must be called before this instance has been used to do any
- * operations.
- *
- * @param firestore - The `Firestore` instance to configure to connect to the
- * emulator.
- * @param host - the emulator host (ex: localhost).
- * @param port - the emulator port (ex: 9000).
- * @param options.mockUserToken - the mock auth token to use for unit testing
- * Security Rules.
- */
- export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
- mockUserToken?: EmulatorMockTokenOptions | string;
- }): void;
-
- /**
- * A Listener for credential change events. The listener should fetch a new
- * token and may need to invalidate other state if the current user has also
- * changed.
- */
- declare type CredentialChangeListener<T> = (credential: T) => Promise<void>;
-
- /**
- * Provides methods for getting the uid and token for the current user and
- * listening for changes.
- */
- declare interface CredentialsProvider<T> {
- /**
- * Starts the credentials provider and specifies a listener to be notified of
- * credential changes (sign-in / sign-out, token changes). It is immediately
- * called once with the initial user.
- *
- * The change listener is invoked on the provided AsyncQueue.
- */
- start(asyncQueue: AsyncQueue, changeListener: CredentialChangeListener<T>): void;
- /** Requests a token for the current user. */
- getToken(): Promise<Token | null>;
- /**
- * Marks the last retrieved token as invalid, making the next GetToken request
- * force-refresh the token.
- */
- invalidateToken(): void;
- shutdown(): void;
- }
-
- /** Settings for private credentials */
- declare type CredentialsSettings = FirstPartyCredentialsSettings | ProviderCredentialsSettings;
-
- /* Excluded from this release type: DatabaseId */
-
- /**
- * Datastore and its related methods are a wrapper around the external Google
- * Cloud Datastore grpc API, which provides an interface that is more convenient
- * for the rest of the client SDK architecture to consume.
- */
- declare abstract class Datastore {
- abstract terminate(): void;
- }
-
- /**
- * Represents an operation scheduled to be run in the future on an AsyncQueue.
- *
- * It is created via DelayedOperation.createAndSchedule().
- *
- * Supports cancellation (via cancel()) and early execution (via skipDelay()).
- *
- * Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
- * in newer versions of TypeScript defines `finally`, which is not available in
- * IE.
- */
- declare class DelayedOperation<T extends unknown> implements PromiseLike<T> {
- private readonly asyncQueue;
- readonly timerId: TimerId;
- readonly targetTimeMs: number;
- private readonly op;
- private readonly removalCallback;
- private timerHandle;
- private readonly deferred;
- private constructor();
- /**
- * Creates and returns a DelayedOperation that has been scheduled to be
- * executed on the provided asyncQueue after the provided delayMs.
- *
- * @param asyncQueue - The queue to schedule the operation on.
- * @param id - A Timer ID identifying the type of operation this is.
- * @param delayMs - The delay (ms) before the operation should be scheduled.
- * @param op - The operation to run.
- * @param removalCallback - A callback to be called synchronously once the
- * operation is executed or canceled, notifying the AsyncQueue to remove it
- * from its delayedOperations list.
- * PORTING NOTE: This exists to prevent making removeDelayedOperation() and
- * the DelayedOperation class public.
- */
- static createAndSchedule<R extends unknown>(asyncQueue: AsyncQueue, timerId: TimerId, delayMs: number, op: () => Promise<R>, removalCallback: (op: DelayedOperation<R>) => void): DelayedOperation<R>;
- /**
- * Starts the timer. This is called immediately after construction by
- * createAndSchedule().
- */
- private start;
- /**
- * Queues the operation to run immediately (if it hasn't already been run or
- * canceled).
- */
- skipDelay(): void;
- /**
- * Cancels the operation if it hasn't already been executed or canceled. The
- * promise will be rejected.
- *
- * As long as the operation has not yet been run, calling cancel() provides a
- * guarantee that the operation will not be run.
- */
- cancel(reason?: string): void;
- then: <TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
- private handleDelayElapsed;
- private clearTimeout;
- }
-
- /**
- * Deletes the document referred to by the specified `DocumentReference`.
- *
- * The deletion will only be reflected in document reads that occur after the
- * returned promise resolves. If the client is offline, the
- * delete fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @param reference - A reference to the document to delete.
- * @returns A `Promise` resolved once the document has been successfully
- * deleted from the backend.
- */
- export declare function deleteDoc(reference: DocumentReference<unknown>): Promise<void>;
-
- /**
- * Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
- * {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
- */
- export declare function deleteField(): FieldValue;
-
- /**
- * The direction of sorting in an order by.
- */
- declare const enum Direction {
- ASCENDING = "asc",
- DESCENDING = "desc"
- }
-
- /**
- * Gets a `DocumentReference` instance that refers to the document at the
- * specified absolute path.
- *
- * @param firestore - A reference to the root `Firestore` instance.
- * @param path - A slash-separated path to a document.
- * @param pathSegments - Additional path segments that will be applied relative
- * to the first argument.
- * @throws If the final path has an odd number of segments and does not point to
- * a document.
- * @returns The `DocumentReference` instance.
- */
- export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
-
- /**
- * Gets a `DocumentReference` instance that refers to a document within
- * `reference` at the specified relative path. If no path is specified, an
- * automatically-generated unique ID will be used for the returned
- * `DocumentReference`.
- *
- * @param reference - A reference to a collection.
- * @param path - A slash-separated path to a document. Has to be omitted to use
- * auto-genrated IDs.
- * @param pathSegments - Additional path segments that will be applied relative
- * to the first argument.
- * @throws If the final path has an odd number of segments and does not point to
- * a document.
- * @returns The `DocumentReference` instance.
- */
- export declare function doc<T>(reference: CollectionReference<T>, path?: string, ...pathSegments: string[]): DocumentReference<T>;
-
- /**
- * Gets a `DocumentReference` instance that refers to a document within
- * `reference` at the specified relative path.
- *
- * @param reference - A reference to a Firestore document.
- * @param path - A slash-separated path to a document.
- * @param pathSegments - Additional path segments that will be applied relative
- * to the first argument.
- * @throws If the final path has an odd number of segments and does not point to
- * a document.
- * @returns The `DocumentReference` instance.
- */
- export declare function doc(reference: DocumentReference<unknown>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData>;
-
- /**
- * Represents a document in Firestore with a key, version, data and whether the
- * data has local mutations applied to it.
- */
- declare interface Document_2 {
- /** The key for this document */
- readonly key: DocumentKey;
- /**
- * The version of this document if it exists or a version at which this
- * document was guaranteed to not exist.
- */
- readonly version: SnapshotVersion;
- /**
- * The timestamp at which this document was read from the remote server. Uses
- * `SnapshotVersion.min()` for documents created by the user.
- */
- readonly readTime: SnapshotVersion;
- /**
- * The timestamp at which the document was created. This value increases
- * monotonically when a document is deleted then recreated. It can also be
- * compared to `createTime` of other documents and the `readTime` of a query.
- */
- readonly createTime: SnapshotVersion;
- /** The underlying data of this document or an empty value if no data exists. */
- readonly data: ObjectValue;
- /** Returns whether local mutations were applied via the mutation queue. */
- readonly hasLocalMutations: boolean;
- /** Returns whether mutations were applied based on a write acknowledgment. */
- readonly hasCommittedMutations: boolean;
- /**
- * Whether this document had a local mutation applied that has not yet been
- * acknowledged by Watch.
- */
- readonly hasPendingWrites: boolean;
- /**
- * Returns whether this document is valid (i.e. it is an entry in the
- * RemoteDocumentCache, was created by a mutation or read from the backend).
- */
- isValidDocument(): boolean;
- /**
- * Returns whether the document exists and its data is known at the current
- * version.
- */
- isFoundDocument(): boolean;
- /**
- * Returns whether the document is known to not exist at the current version.
- */
- isNoDocument(): boolean;
- /**
- * Returns whether the document exists and its data is unknown at the current
- * version.
- */
- isUnknownDocument(): boolean;
- isEqual(other: Document_2 | null | undefined): boolean;
- /** Creates a mutable copy of this document. */
- mutableCopy(): MutableDocument;
- toString(): string;
- }
-
- /**
- * Document data (for use with {@link @firebase/firestore/lite#(setDoc:1)}) consists of fields mapped to
- * values.
- */
- export declare interface DocumentData {
- /** A mapping between a field and its value. */
- [field: string]: any;
- }
-
- /**
- * Returns a special sentinel `FieldPath` to refer to the ID of a document.
- * It can be used in queries to sort or filter by the document ID.
- */
- export declare function documentId(): FieldPath;
-
- /* Excluded from this release type: DocumentKey */
-
- /**
- * A `DocumentReference` refers to a document location in a Firestore database
- * and can be used to write, read, or listen to the location. The document at
- * the referenced location may or may not exist.
- */
- export declare class DocumentReference<T = DocumentData> {
- /**
- * If provided, the `FirestoreDataConverter` associated with this instance.
- */
- readonly converter: FirestoreDataConverter<T> | null;
- readonly _key: DocumentKey;
- /** The type of this Firestore reference. */
- readonly type = "document";
- /**
- * The {@link Firestore} instance the document is in.
- * This is useful for performing transactions, for example.
- */
- readonly firestore: Firestore;
- /** @hideconstructor */
- constructor(firestore: Firestore,
- /**
- * If provided, the `FirestoreDataConverter` associated with this instance.
- */
- converter: FirestoreDataConverter<T> | null, _key: DocumentKey);
- get _path(): ResourcePath;
- /**
- * The document's identifier within its collection.
- */
- get id(): string;
- /**
- * A string representing the path of the referenced document (relative
- * to the root of the database).
- */
- get path(): string;
- /**
- * The collection this `DocumentReference` belongs to.
- */
- get parent(): CollectionReference<T>;
- /**
- * Applies a custom data converter to this `DocumentReference`, allowing you
- * to use your own custom model objects with Firestore. When you call {@link
- * @firebase/firestore/lite#(setDoc:1)}, {@link @firebase/firestore/lite#getDoc}, etc. with the returned `DocumentReference`
- * instance, the provided converter will convert between Firestore data and
- * your custom type `U`.
- *
- * @param converter - Converts objects to and from Firestore.
- * @returns A `DocumentReference<U>` that uses the provided converter.
- */
- withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
- /**
- * Removes the current converter.
- *
- * @param converter - `null` removes the current converter.
- * @returns A `DocumentReference<DocumentData>` that does not use a converter.
- */
- withConverter(converter: null): DocumentReference<DocumentData>;
- }
-
- /**
- * A `DocumentSnapshot` contains data read from a document in your Firestore
- * database. The data can be extracted with `.data()` or `.get(<field>)` to
- * get a specific field.
- *
- * For a `DocumentSnapshot` that points to a non-existing document, any data
- * access will return 'undefined'. You can use the `exists()` method to
- * explicitly verify a document's existence.
- */
- export declare class DocumentSnapshot<T = DocumentData> {
- _firestore: Firestore;
- _userDataWriter: AbstractUserDataWriter;
- _key: DocumentKey;
- _document: Document_2 | null;
- _converter: UntypedFirestoreDataConverter<T> | null;
- /** @hideconstructor protected */
- constructor(_firestore: Firestore, _userDataWriter: AbstractUserDataWriter, _key: DocumentKey, _document: Document_2 | null, _converter: UntypedFirestoreDataConverter<T> | null);
- /** Property of the `DocumentSnapshot` that provides the document's ID. */
- get id(): string;
- /**
- * The `DocumentReference` for the document included in the `DocumentSnapshot`.
- */
- get ref(): DocumentReference<T>;
- /**
- * Signals whether or not the document at the snapshot's location exists.
- *
- * @returns true if the document exists.
- */
- exists(): this is QueryDocumentSnapshot<T>;
- /**
- * Retrieves all fields in the document as an `Object`. Returns `undefined` if
- * the document doesn't exist.
- *
- * @returns An `Object` containing all fields in the document or `undefined`
- * if the document doesn't exist.
- */
- data(): T | undefined;
- /**
- * Retrieves the field specified by `fieldPath`. Returns `undefined` if the
- * document or field doesn't exist.
- *
- * @param fieldPath - The path (for example 'foo' or 'foo.bar') to a specific
- * field.
- * @returns The data at the specified field location or undefined if no such
- * field exists in the document.
- */
- get(fieldPath: string | FieldPath): any;
- }
- export { EmulatorMockTokenOptions }
-
- /**
- * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
- * the provided document (inclusive). The end position is relative to the order
- * of the query. The document must contain all of the fields provided in the
- * orderBy of the query.
- *
- * @param snapshot - The snapshot of the document to end at.
- * @returns A {@link QueryEndAtConstraint} to pass to `query()`
- */
- export declare function endAt(snapshot: DocumentSnapshot<unknown>): QueryEndAtConstraint;
-
- /**
- * Creates a {@link QueryEndAtConstraint} that modifies the result set to end at
- * the provided fields relative to the order of the query. The order of the field
- * values must match the order of the order by clauses of the query.
- *
- * @param fieldValues - The field values to end this query at, in order
- * of the query's order by.
- * @returns A {@link QueryEndAtConstraint} to pass to `query()`
- */
- export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint;
-
- /**
- * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
- * before the provided document (exclusive). The end position is relative to the
- * order of the query. The document must contain all of the fields provided in
- * the orderBy of the query.
- *
- * @param snapshot - The snapshot of the document to end before.
- * @returns A {@link QueryEndAtConstraint} to pass to `query()`
- */
- export declare function endBefore(snapshot: DocumentSnapshot<unknown>): QueryEndAtConstraint;
-
- /**
- * Creates a {@link QueryEndAtConstraint} that modifies the result set to end
- * before the provided fields relative to the order of the query. The order of
- * the field values must match the order of the order by clauses of the query.
- *
- * @param fieldValues - The field values to end this query before, in order
- * of the query's order by.
- * @returns A {@link QueryEndAtConstraint} to pass to `query()`
- */
- export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint;
-
- declare class FieldFilter extends Filter {
- readonly field: FieldPath_2;
- readonly op: Operator;
- readonly value: Value;
- protected constructor(field: FieldPath_2, op: Operator, value: Value);
- /**
- * Creates a filter based on the provided arguments.
- */
- static create(field: FieldPath_2, op: Operator, value: Value): FieldFilter;
- private static createKeyFieldInFilter;
- matches(doc: Document_2): boolean;
- protected matchesComparison(comparison: number): boolean;
- isInequality(): boolean;
- getFlattenedFilters(): readonly FieldFilter[];
- getFilters(): Filter[];
- getFirstInequalityField(): FieldPath_2 | null;
- }
-
- declare type FieldFilterOp = 'OPERATOR_UNSPECIFIED' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'EQUAL' | 'NOT_EQUAL' | 'ARRAY_CONTAINS' | 'IN' | 'ARRAY_CONTAINS_ANY' | 'NOT_IN';
-
- /**
- * Provides a set of fields that can be used to partially patch a document.
- * FieldMask is used in conjunction with ObjectValue.
- * Examples:
- * foo - Overwrites foo entirely with the provided value. If foo is not
- * present in the companion ObjectValue, the field is deleted.
- * foo.bar - Overwrites only the field bar of the object foo.
- * If foo is not an object, foo is replaced with an object
- * containing foo
- */
- declare class FieldMask {
- readonly fields: FieldPath_2[];
- constructor(fields: FieldPath_2[]);
- static empty(): FieldMask;
- /**
- * Returns a new FieldMask object that is the result of adding all the given
- * fields paths to this field mask.
- */
- unionWith(extraFields: FieldPath_2[]): FieldMask;
- /**
- * Verifies that `fieldPath` is included by at least one field in this field
- * mask.
- *
- * This is an O(n) operation, where `n` is the size of the field mask.
- */
- covers(fieldPath: FieldPath_2): boolean;
- isEqual(other: FieldMask): boolean;
- }
-
- /**
- * A `FieldPath` refers to a field in a document. The path may consist of a
- * single field name (referring to a top-level field in the document), or a
- * list of field names (referring to a nested field in the document).
- *
- * Create a `FieldPath` by providing field names. If more than one field
- * name is provided, the path will point to a nested field in a document.
- */
- export declare class FieldPath {
- /** Internal representation of a Firestore field path. */
- readonly _internalPath: FieldPath_2;
- /**
- * Creates a `FieldPath` from the provided field names. If more than one field
- * name is provided, the path will point to a nested field in a document.
- *
- * @param fieldNames - A list of field names.
- */
- constructor(...fieldNames: string[]);
- /**
- * Returns true if this `FieldPath` is equal to the provided one.
- *
- * @param other - The `FieldPath` to compare against.
- * @returns true if this `FieldPath` is equal to the provided one.
- */
- isEqual(other: FieldPath): boolean;
- }
-
- /* Excluded from this release type: FieldPath_2 */
-
- /** A field path and the TransformOperation to perform upon it. */
- declare class FieldTransform {
- readonly field: FieldPath_2;
- readonly transform: TransformOperation;
- constructor(field: FieldPath_2, transform: TransformOperation);
- }
-
- declare type FieldTransformSetToServerValue = 'SERVER_VALUE_UNSPECIFIED' | 'REQUEST_TIME';
-
- /**
- * Sentinel values that can be used when writing document fields with `set()`
- * or `update()`.
- */
- export declare abstract class FieldValue {
- _methodName: string;
- /**
- * @param _methodName - The public API endpoint that returns this class.
- * @hideconstructor
- */
- constructor(_methodName: string);
- /** Compares `FieldValue`s for equality. */
- abstract isEqual(other: FieldValue): boolean;
- abstract _toFieldTransform(context: ParseContext): FieldTransform | null;
- }
-
- declare abstract class Filter {
- abstract matches(doc: Document_2): boolean;
- abstract getFlattenedFilters(): readonly FieldFilter[];
- abstract getFilters(): Filter[];
- abstract getFirstInequalityField(): FieldPath_2 | null;
- }
-
- /* Excluded from this release type: _FirebaseService */
-
- /**
- * The Cloud Firestore service interface.
- *
- * Do not call this constructor directly. Instead, use {@link (getFirestore:1)}.
- */
- export declare class Firestore implements FirestoreService {
- _authCredentials: CredentialsProvider<User>;
- _appCheckCredentials: CredentialsProvider<string>;
- readonly _databaseId: DatabaseId;
- readonly _app?: FirebaseApp | undefined;
- /**
- * Whether it's a Firestore or Firestore Lite instance.
- */
- type: 'firestore-lite' | 'firestore';
- readonly _persistenceKey: string;
- private _settings;
- private _settingsFrozen;
- private _terminateTask?;
- /** @hideconstructor */
- constructor(_authCredentials: CredentialsProvider<User>, _appCheckCredentials: CredentialsProvider<string>, _databaseId: DatabaseId, _app?: FirebaseApp | undefined);
- /**
- * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
- * instance.
- */
- get app(): FirebaseApp;
- get _initialized(): boolean;
- get _terminated(): boolean;
- _setSettings(settings: PrivateSettings): void;
- _getSettings(): FirestoreSettingsImpl;
- _freezeSettings(): FirestoreSettingsImpl;
- _delete(): Promise<void>;
- /** Returns a JSON-serializable representation of this `Firestore` instance. */
- toJSON(): object;
- /**
- * Terminates all components used by this client. Subclasses can override
- * this method to clean up their own dependencies, but must also call this
- * method.
- *
- * Only ever called once.
- */
- protected _terminate(): Promise<void>;
- }
-
- /**
- * Converter used by `withConverter()` to transform user objects of type `T`
- * into Firestore data.
- *
- * Using the converter allows you to specify generic type arguments when
- * storing and retrieving objects from Firestore.
- *
- * @example
- * ```typescript
- * class Post {
- * constructor(readonly title: string, readonly author: string) {}
- *
- * toString(): string {
- * return this.title + ', by ' + this.author;
- * }
- * }
- *
- * const postConverter = {
- * toFirestore(post: WithFieldValue<Post>): DocumentData {
- * return {title: post.title, author: post.author};
- * },
- * fromFirestore(snapshot: QueryDocumentSnapshot): Post {
- * const data = snapshot.data(options)!;
- * return new Post(data.title, data.author);
- * }
- * };
- *
- * const postSnap = await firebase.firestore()
- * .collection('posts')
- * .withConverter(postConverter)
- * .doc().get();
- * const post = postSnap.data();
- * if (post !== undefined) {
- * post.title; // string
- * post.toString(); // Should be defined
- * post.someNonExistentProperty; // TS error
- * }
- * ```
- */
- export declare interface FirestoreDataConverter<T> {
- /**
- * Called by the Firestore SDK to convert a custom model object of type `T`
- * into a plain Javascript object (suitable for writing directly to the
- * Firestore database). Used with {@link @firebase/firestore/lite#(setDoc:1)}, {@link @firebase/firestore/lite#(WriteBatch.set:1)}
- * and {@link @firebase/firestore/lite#(Transaction.set:1)}.
- *
- * The `WithFieldValue<T>` type extends `T` to also allow FieldValues such as
- * {@link (deleteField:1)} to be used as property values.
- */
- toFirestore(modelObject: WithFieldValue<T>): DocumentData;
- /**
- * Called by the Firestore SDK to convert a custom model object of type `T`
- * into a plain Javascript object (suitable for writing directly to the
- * Firestore database). Used with {@link @firebase/firestore/lite#(setDoc:1)}, {@link @firebase/firestore/lite#(WriteBatch.set:1)}
- * and {@link @firebase/firestore/lite#(Transaction.set:1)} with `merge:true` or `mergeFields`.
- *
- * The `PartialWithFieldValue<T>` type extends `Partial<T>` to allow
- * FieldValues such as {@link (arrayUnion:1)} to be used as property values.
- * It also supports nested `Partial` by allowing nested fields to be
- * omitted.
- */
- toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions): DocumentData;
- /**
- * Called by the Firestore SDK to convert Firestore data into an object of
- * type T. You can access your data by calling: `snapshot.data()`.
- *
- * @param snapshot - A `QueryDocumentSnapshot` containing your data and
- * metadata.
- */
- fromFirestore(snapshot: QueryDocumentSnapshot<DocumentData>): T;
- }
-
- /** An error returned by a Firestore operation. */
- export declare class FirestoreError extends FirebaseError {
- /**
- * The backend error code associated with this error.
- */
- readonly code: FirestoreErrorCode;
- /**
- * A custom error description.
- */
- readonly message: string;
- /** The stack of the error. */
- readonly stack?: string;
- /** @hideconstructor */
- constructor(
- /**
- * The backend error code associated with this error.
- */
- code: FirestoreErrorCode,
- /**
- * A custom error description.
- */
- message: string);
- }
-
- /**
- * The set of Firestore status codes. The codes are the same at the ones
- * exposed by gRPC here:
- * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
- *
- * Possible values:
- * - 'cancelled': The operation was cancelled (typically by the caller).
- * - 'unknown': Unknown error or an error from a different error domain.
- * - 'invalid-argument': Client specified an invalid argument. Note that this
- * differs from 'failed-precondition'. 'invalid-argument' indicates
- * arguments that are problematic regardless of the state of the system
- * (e.g. an invalid field name).
- * - 'deadline-exceeded': Deadline expired before operation could complete.
- * For operations that change the state of the system, this error may be
- * returned even if the operation has completed successfully. For example,
- * a successful response from a server could have been delayed long enough
- * for the deadline to expire.
- * - 'not-found': Some requested document was not found.
- * - 'already-exists': Some document that we attempted to create already
- * exists.
- * - 'permission-denied': The caller does not have permission to execute the
- * specified operation.
- * - 'resource-exhausted': Some resource has been exhausted, perhaps a
- * per-user quota, or perhaps the entire file system is out of space.
- * - 'failed-precondition': Operation was rejected because the system is not
- * in a state required for the operation's execution.
- * - 'aborted': The operation was aborted, typically due to a concurrency
- * issue like transaction aborts, etc.
- * - 'out-of-range': Operation was attempted past the valid range.
- * - 'unimplemented': Operation is not implemented or not supported/enabled.
- * - 'internal': Internal errors. Means some invariants expected by
- * underlying system has been broken. If you see one of these errors,
- * something is very broken.
- * - 'unavailable': The service is currently unavailable. This is most likely
- * a transient condition and may be corrected by retrying with a backoff.
- * - 'data-loss': Unrecoverable data loss or corruption.
- * - 'unauthenticated': The request does not have valid authentication
- * credentials for the operation.
- */
- 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';
-
- /**
- * An interface implemented by FirebaseFirestore that provides compatibility
- * with the usage in this file.
- *
- * This interface mainly exists to remove a cyclic dependency.
- */
- declare interface FirestoreService extends _FirebaseService {
- _authCredentials: CredentialsProvider<User>;
- _appCheckCredentials: CredentialsProvider<string>;
- _persistenceKey: string;
- _databaseId: DatabaseId;
- _terminated: boolean;
- _freezeSettings(): FirestoreSettingsImpl;
- }
-
- /**
- * A concrete type describing all the values that can be applied via a
- * user-supplied `FirestoreSettings` object. This is a separate type so that
- * defaults can be supplied and the value can be checked for equality.
- */
- declare class FirestoreSettingsImpl {
- /** The hostname to connect to. */
- readonly host: string;
- /** Whether to use SSL when connecting. */
- readonly ssl: boolean;
- readonly cacheSizeBytes: number;
- readonly experimentalForceLongPolling: boolean;
- readonly experimentalAutoDetectLongPolling: boolean;
- readonly ignoreUndefinedProperties: boolean;
- readonly useFetchStreams: boolean;
- credentials?: any;
- constructor(settings: PrivateSettings);
- isEqual(other: FirestoreSettingsImpl): boolean;
- }
-
- declare namespace firestoreV1ApiClientInterfaces {
- interface ArrayValue {
- values?: Value[];
- }
- interface BatchGetDocumentsRequest {
- database?: string;
- documents?: string[];
- mask?: DocumentMask;
- transaction?: string;
- newTransaction?: TransactionOptions;
- readTime?: string;
- }
- interface BatchGetDocumentsResponse {
- found?: Document;
- missing?: string;
- transaction?: string;
- readTime?: string;
- }
- interface BeginTransactionRequest {
- options?: TransactionOptions;
- }
- interface BeginTransactionResponse {
- transaction?: string;
- }
- interface CollectionSelector {
- collectionId?: string;
- allDescendants?: boolean;
- }
- interface CommitRequest {
- database?: string;
- writes?: Write[];
- transaction?: string;
- }
- interface CommitResponse {
- writeResults?: WriteResult[];
- commitTime?: string;
- }
- interface CompositeFilter {
- op?: CompositeFilterOp;
- filters?: Filter[];
- }
- interface Cursor {
- values?: Value[];
- before?: boolean;
- }
- interface Document {
- name?: string;
- fields?: ApiClientObjectMap<Value>;
- createTime?: Timestamp_2;
- updateTime?: Timestamp_2;
- }
- interface DocumentChange {
- document?: Document;
- targetIds?: number[];
- removedTargetIds?: number[];
- }
- interface DocumentDelete {
- document?: string;
- removedTargetIds?: number[];
- readTime?: Timestamp_2;
- }
- interface DocumentMask {
- fieldPaths?: string[];
- }
- interface DocumentRemove {
- document?: string;
- removedTargetIds?: number[];
- readTime?: string;
- }
- interface DocumentTransform {
- document?: string;
- fieldTransforms?: FieldTransform[];
- }
- interface DocumentsTarget {
- documents?: string[];
- }
- interface Empty {
- }
- interface ExistenceFilter {
- targetId?: number;
- count?: number;
- }
- interface FieldFilter {
- field?: FieldReference;
- op?: FieldFilterOp;
- value?: Value;
- }
- interface FieldReference {
- fieldPath?: string;
- }
- interface FieldTransform {
- fieldPath?: string;
- setToServerValue?: FieldTransformSetToServerValue;
- appendMissingElements?: ArrayValue;
- removeAllFromArray?: ArrayValue;
- increment?: Value;
- }
- interface Filter {
- compositeFilter?: CompositeFilter;
- fieldFilter?: FieldFilter;
- unaryFilter?: UnaryFilter;
- }
- interface Index {
- name?: string;
- collectionId?: string;
- fields?: IndexField[];
- state?: IndexState;
- }
- interface IndexField {
- fieldPath?: string;
- mode?: IndexFieldMode;
- }
- interface LatLng {
- latitude?: number;
- longitude?: number;
- }
- interface ListCollectionIdsRequest {
- pageSize?: number;
- pageToken?: string;
- }
- interface ListCollectionIdsResponse {
- collectionIds?: string[];
- nextPageToken?: string;
- }
- interface ListDocumentsResponse {
- documents?: Document[];
- nextPageToken?: string;
- }
- interface ListIndexesResponse {
- indexes?: Index[];
- nextPageToken?: string;
- }
- interface ListenRequest {
- addTarget?: Target;
- removeTarget?: number;
- labels?: ApiClientObjectMap<string>;
- }
- interface ListenResponse {
- targetChange?: TargetChange;
- documentChange?: DocumentChange;
- documentDelete?: DocumentDelete;
- documentRemove?: DocumentRemove;
- filter?: ExistenceFilter;
- }
- interface MapValue {
- fields?: ApiClientObjectMap<Value>;
- }
- interface Operation {
- name?: string;
- metadata?: ApiClientObjectMap<any>;
- done?: boolean;
- error?: Status;
- response?: ApiClientObjectMap<any>;
- }
- interface Order {
- field?: FieldReference;
- direction?: OrderDirection;
- }
- interface Precondition {
- exists?: boolean;
- updateTime?: Timestamp_2;
- }
- interface Projection {
- fields?: FieldReference[];
- }
- interface QueryTarget {
- parent?: string;
- structuredQuery?: StructuredQuery;
- }
- interface ReadOnly {
- readTime?: string;
- }
- interface ReadWrite {
- retryTransaction?: string;
- }
- interface RollbackRequest {
- transaction?: string;
- }
- interface RunQueryRequest {
- parent?: string;
- structuredQuery?: StructuredQuery;
- transaction?: string;
- newTransaction?: TransactionOptions;
- readTime?: string;
- }
- interface RunQueryResponse {
- transaction?: string;
- document?: Document;
- readTime?: string;
- skippedResults?: number;
- }
- interface RunAggregationQueryRequest {
- parent?: string;
- structuredAggregationQuery?: StructuredAggregationQuery;
- transaction?: string;
- newTransaction?: TransactionOptions;
- readTime?: string;
- }
- interface RunAggregationQueryResponse {
- result?: AggregationResult;
- transaction?: string;
- readTime?: string;
- }
- interface AggregationResult {
- aggregateFields?: ApiClientObjectMap<Value>;
- }
- interface StructuredAggregationQuery {
- structuredQuery?: StructuredQuery;
- aggregations?: Aggregation[];
- }
- interface Aggregation {
- count?: Count;
- alias?: string;
- }
- interface Count {
- upTo?: number;
- }
- interface Status {
- code?: number;
- message?: string;
- details?: Array<ApiClientObjectMap<any>>;
- }
- interface StructuredQuery {
- select?: Projection;
- from?: CollectionSelector[];
- where?: Filter;
- orderBy?: Order[];
- startAt?: Cursor;
- endAt?: Cursor;
- offset?: number;
- limit?: number | {
- value: number;
- };
- }
- interface Target {
- query?: QueryTarget;
- documents?: DocumentsTarget;
- resumeToken?: string | Uint8Array;
- readTime?: Timestamp_2;
- targetId?: number;
- once?: boolean;
- }
- interface TargetChange {
- targetChangeType?: TargetChangeTargetChangeType;
- targetIds?: number[];
- cause?: Status;
- resumeToken?: string | Uint8Array;
- readTime?: Timestamp_2;
- }
- interface TransactionOptions {
- readOnly?: ReadOnly;
- readWrite?: ReadWrite;
- }
- interface UnaryFilter {
- op?: UnaryFilterOp;
- field?: FieldReference;
- }
- interface Value {
- nullValue?: ValueNullValue;
- booleanValue?: boolean;
- integerValue?: string | number;
- doubleValue?: string | number;
- timestampValue?: Timestamp_2;
- stringValue?: string;
- bytesValue?: string | Uint8Array;
- referenceValue?: string;
- geoPointValue?: LatLng;
- arrayValue?: ArrayValue;
- mapValue?: MapValue;
- }
- interface Write {
- update?: Document;
- delete?: string;
- verify?: string;
- transform?: DocumentTransform;
- updateMask?: DocumentMask;
- updateTransforms?: FieldTransform[];
- currentDocument?: Precondition;
- }
- interface WriteRequest {
- streamId?: string;
- writes?: Write[];
- streamToken?: string | Uint8Array;
- labels?: ApiClientObjectMap<string>;
- }
- interface WriteResponse {
- streamId?: string;
- streamToken?: string | Uint8Array;
- writeResults?: WriteResult[];
- commitTime?: Timestamp_2;
- }
- interface WriteResult {
- updateTime?: Timestamp_2;
- transformResults?: Value[];
- }
- }
-
- declare interface FirstPartyCredentialsSettings {
- ['type']: 'gapi';
- ['client']: unknown;
- ['sessionIndex']: string;
- ['iamToken']: string | null;
- ['authTokenFactory']: AuthTokenFactory | null;
- }
-
- /**
- * @license
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * An immutable object representing a geographic location in Firestore. The
- * location is represented as latitude/longitude pair.
- *
- * Latitude values are in the range of [-90, 90].
- * Longitude values are in the range of [-180, 180].
- */
- export declare class GeoPoint {
- private _lat;
- private _long;
- /**
- * Creates a new immutable `GeoPoint` object with the provided latitude and
- * longitude values.
- * @param latitude - The latitude as number between -90 and 90.
- * @param longitude - The longitude as number between -180 and 180.
- */
- constructor(latitude: number, longitude: number);
- /**
- * The latitude of this `GeoPoint` instance.
- */
- get latitude(): number;
- /**
- * The longitude of this `GeoPoint` instance.
- */
- get longitude(): number;
- /**
- * Returns true if this `GeoPoint` is equal to the provided one.
- *
- * @param other - The `GeoPoint` to compare against.
- * @returns true if this `GeoPoint` is equal to the provided one.
- */
- isEqual(other: GeoPoint): boolean;
- /** Returns a JSON-serializable representation of this GeoPoint. */
- toJSON(): {
- latitude: number;
- longitude: number;
- };
- /**
- * Actually private to JS consumers of our API, so this function is prefixed
- * with an underscore.
- */
- _compareTo(other: GeoPoint): number;
- }
-
- /**
- * Calculates the number of documents in the result set of the given query,
- * without actually downloading the documents.
- *
- * Using this function to count the documents is efficient because only the
- * final count, not the documents' data, is downloaded. This function can even
- * count the documents if the result set would be prohibitively large to
- * download entirely (e.g. thousands of documents).
- *
- * @param query - The query whose result set size to calculate.
- * @returns A Promise that will be resolved with the count; the count can be
- * retrieved from `snapshot.data().count`, where `snapshot` is the
- * `AggregateQuerySnapshot` to which the returned Promise resolves.
- */
- export declare function getCount(query: Query<unknown>): Promise<AggregateQuerySnapshot<{
- count: AggregateField<number>;
- }>>;
-
- /**
- * Reads the document referred to by the specified document reference.
- *
- * All documents are directly fetched from the server, even if the document was
- * previously read or modified. Recent modifications are only reflected in the
- * retrieved `DocumentSnapshot` if they have already been applied by the
- * backend. If the client is offline, the read fails. If you like to use
- * caching or see local modifications, please use the full Firestore SDK.
- *
- * @param reference - The reference of the document to fetch.
- * @returns A Promise resolved with a `DocumentSnapshot` containing the current
- * document contents.
- */
- export declare function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
-
- /**
- * Executes the query and returns the results as a {@link QuerySnapshot}.
- *
- * All queries are executed directly by the server, even if the the query was
- * previously executed. Recent modifications are only reflected in the retrieved
- * results if they have already been applied by the backend. If the client is
- * offline, the operation fails. To see previously cached result and local
- * modifications, use the full Firestore SDK.
- *
- * @param query - The `Query` to execute.
- * @returns A Promise that will be resolved with the results of the query.
- */
- export declare function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>;
-
- /**
- * Returns the existing default {@link Firestore} instance that is associated with the
- * default {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
- * instance with default settings.
- *
- * @returns The {@link Firestore} instance of the provided app.
- */
- export declare function getFirestore(): Firestore;
-
- /**
- * Returns the existing default {@link Firestore} instance that is associated with the
- * provided {@link @firebase/app#FirebaseApp}. If no instance exists, initializes a new
- * instance with default settings.
- *
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned {@link Firestore}
- * instance is associated with.
- * @returns The {@link Firestore} instance of the provided app.
- */
- export declare function getFirestore(app: FirebaseApp): Firestore;
-
- /* Excluded declaration from this release type: getFirestore */
-
- /* Excluded declaration from this release type: getFirestore */
-
- /**
- * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
- * @firebase/firestore/lite#(updateDoc:1)} that tells the server to increment the field's current value by
- * the given value.
- *
- * If either the operand or the current field value uses floating point
- * precision, all arithmetic follows IEEE 754 semantics. If both values are
- * integers, values outside of JavaScript's safe number range
- * (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to
- * precision loss. Furthermore, once processed by the Firestore backend, all
- * integer operations are capped between -2^63 and 2^63-1.
- *
- * If the current field value is not of type `number`, or if the field does not
- * yet exist, the transformation sets the field to the given value.
- *
- * @param n - The value to increment by.
- * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
- * `updateDoc()`
- */
- export declare function increment(n: number): FieldValue;
-
- declare type IndexFieldMode = 'MODE_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING';
-
- declare type IndexState = 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'ERROR';
-
- /**
- * Initializes a new instance of Cloud Firestore with the provided settings.
- * Can only be called before any other functions, including
- * {@link (getFirestore:1)}. If the custom settings are empty, this function is
- * equivalent to calling {@link (getFirestore:1)}.
- *
- * @param app - The {@link @firebase/app#FirebaseApp} with which the `Firestore` instance will
- * be associated.
- * @param settings - A settings object to configure the `Firestore` instance.
- * @returns A newly initialized `Firestore` instance.
- */
- export declare function initializeFirestore(app: FirebaseApp, settings: Settings): Firestore;
-
- /* Excluded declaration from this release type: initializeFirestore */
-
- /**
- * Creates a {@link QueryLimitConstraint} that only returns the first matching
- * documents.
- *
- * @param limit - The maximum number of items to return.
- * @returns The created {@link QueryLimitConstraint}.
- */
- export declare function limit(limit: number): QueryLimitConstraint;
-
- /**
- * Creates a {@link QueryLimitConstraint} that only returns the last matching
- * documents.
- *
- * You must specify at least one `orderBy` clause for `limitToLast` queries,
- * otherwise an exception will be thrown during execution.
- *
- * @param limit - The maximum number of items to return.
- * @returns The created {@link QueryLimitConstraint}.
- */
- export declare function limitToLast(limit: number): QueryLimitConstraint;
-
- declare const enum LimitType {
- First = "F",
- Last = "L"
- }
- export { LogLevel }
-
- declare type MapValue = firestoreV1ApiClientInterfaces.MapValue;
-
- /**
- * Represents a document in Firestore with a key, version, data and whether it
- * has local mutations applied to it.
- *
- * Documents can transition between states via `convertToFoundDocument()`,
- * `convertToNoDocument()` and `convertToUnknownDocument()`. If a document does
- * not transition to one of these states even after all mutations have been
- * applied, `isValidDocument()` returns false and the document should be removed
- * from all views.
- */
- declare class MutableDocument implements Document_2 {
- readonly key: DocumentKey;
- private documentType;
- version: SnapshotVersion;
- readTime: SnapshotVersion;
- createTime: SnapshotVersion;
- data: ObjectValue;
- private documentState;
- private constructor();
- /**
- * Creates a document with no known version or data, but which can serve as
- * base document for mutations.
- */
- static newInvalidDocument(documentKey: DocumentKey): MutableDocument;
- /**
- * Creates a new document that is known to exist with the given data at the
- * given version.
- */
- static newFoundDocument(documentKey: DocumentKey, version: SnapshotVersion, createTime: SnapshotVersion, value: ObjectValue): MutableDocument;
- /** Creates a new document that is known to not exist at the given version. */
- static newNoDocument(documentKey: DocumentKey, version: SnapshotVersion): MutableDocument;
- /**
- * Creates a new document that is known to exist at the given version but
- * whose data is not known (e.g. a document that was updated without a known
- * base document).
- */
- static newUnknownDocument(documentKey: DocumentKey, version: SnapshotVersion): MutableDocument;
- /**
- * Changes the document type to indicate that it exists and that its version
- * and data are known.
- */
- convertToFoundDocument(version: SnapshotVersion, value: ObjectValue): MutableDocument;
- /**
- * Changes the document type to indicate that it doesn't exist at the given
- * version.
- */
- convertToNoDocument(version: SnapshotVersion): MutableDocument;
- /**
- * Changes the document type to indicate that it exists at a given version but
- * that its data is not known (e.g. a document that was updated without a known
- * base document).
- */
- convertToUnknownDocument(version: SnapshotVersion): MutableDocument;
- setHasCommittedMutations(): MutableDocument;
- setHasLocalMutations(): MutableDocument;
- setReadTime(readTime: SnapshotVersion): MutableDocument;
- get hasLocalMutations(): boolean;
- get hasCommittedMutations(): boolean;
- get hasPendingWrites(): boolean;
- isValidDocument(): boolean;
- isFoundDocument(): boolean;
- isNoDocument(): boolean;
- isUnknownDocument(): boolean;
- isEqual(other: Document_2 | null | undefined): boolean;
- mutableCopy(): MutableDocument;
- toString(): string;
- }
-
- /**
- * A mutation describes a self-contained change to a document. Mutations can
- * create, replace, delete, and update subsets of documents.
- *
- * Mutations not only act on the value of the document but also its version.
- *
- * For local mutations (mutations that haven't been committed yet), we preserve
- * the existing version for Set and Patch mutations. For Delete mutations, we
- * reset the version to 0.
- *
- * Here's the expected transition table.
- *
- * MUTATION APPLIED TO RESULTS IN
- *
- * SetMutation Document(v3) Document(v3)
- * SetMutation NoDocument(v3) Document(v0)
- * SetMutation InvalidDocument(v0) Document(v0)
- * PatchMutation Document(v3) Document(v3)
- * PatchMutation NoDocument(v3) NoDocument(v3)
- * PatchMutation InvalidDocument(v0) UnknownDocument(v3)
- * DeleteMutation Document(v3) NoDocument(v0)
- * DeleteMutation NoDocument(v3) NoDocument(v0)
- * DeleteMutation InvalidDocument(v0) NoDocument(v0)
- *
- * For acknowledged mutations, we use the updateTime of the WriteResponse as
- * the resulting version for Set and Patch mutations. As deletes have no
- * explicit update time, we use the commitTime of the WriteResponse for
- * Delete mutations.
- *
- * If a mutation is acknowledged by the backend but fails the precondition check
- * locally, we transition to an `UnknownDocument` and rely on Watch to send us
- * the updated version.
- *
- * Field transforms are used only with Patch and Set Mutations. We use the
- * `updateTransforms` message to store transforms, rather than the `transforms`s
- * messages.
- *
- * ## Subclassing Notes
- *
- * Every type of mutation needs to implement its own applyToRemoteDocument() and
- * applyToLocalView() to implement the actual behavior of applying the mutation
- * to some source document (see `setMutationApplyToRemoteDocument()` for an
- * example).
- */
- declare abstract class Mutation {
- abstract readonly type: MutationType;
- abstract readonly key: DocumentKey;
- abstract readonly precondition: Precondition;
- abstract readonly fieldTransforms: FieldTransform[];
- /**
- * Returns a `FieldMask` representing the fields that will be changed by
- * applying this mutation. Returns `null` if the mutation will overwrite the
- * entire document.
- */
- abstract getFieldMask(): FieldMask | null;
- }
-
- declare const enum MutationType {
- Set = 0,
- Patch = 1,
- Delete = 2,
- Verify = 3
- }
-
- /**
- * For each field (e.g. 'bar'), find all nested keys (e.g. {'bar.baz': T1,
- * 'bar.qux': T2}). Intersect them together to make a single map containing
- * all possible keys that are all marked as optional
- */
- export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{
- [K in keyof T & string]: ChildUpdateFields<K, T[K]>;
- }[keyof T & string]>;
-
- /**
- * An ObjectValue represents a MapValue in the Firestore Proto and offers the
- * ability to add and remove fields (via the ObjectValueBuilder).
- */
- declare class ObjectValue {
- readonly value: {
- mapValue: MapValue;
- };
- constructor(value: {
- mapValue: MapValue;
- });
- static empty(): ObjectValue;
- /**
- * Returns the value at the given path or null.
- *
- * @param path - the path to search
- * @returns The value at the path or null if the path is not set.
- */
- field(path: FieldPath_2): Value | null;
- /**
- * Sets the field to the provided value.
- *
- * @param path - The field path to set.
- * @param value - The value to set.
- */
- set(path: FieldPath_2, value: Value): void;
- /**
- * Sets the provided fields to the provided values.
- *
- * @param data - A map of fields to values (or null for deletes).
- */
- setAll(data: Map<FieldPath_2, Value | null>): void;
- /**
- * Removes the field at the specified path. If there is no field at the
- * specified path, nothing is changed.
- *
- * @param path - The field path to remove.
- */
- delete(path: FieldPath_2): void;
- isEqual(other: ObjectValue): boolean;
- /**
- * Returns the map that contains the leaf element of `path`. If the parent
- * entry does not yet exist, or if it is not a map, a new map will be created.
- */
- private getFieldsMap;
- /**
- * Modifies `fieldsMap` by adding, replacing or deleting the specified
- * entries.
- */
- private applyChanges;
- clone(): ObjectValue;
- }
-
- declare const enum Operator {
- LESS_THAN = "<",
- LESS_THAN_OR_EQUAL = "<=",
- EQUAL = "==",
- NOT_EQUAL = "!=",
- GREATER_THAN = ">",
- GREATER_THAN_OR_EQUAL = ">=",
- ARRAY_CONTAINS = "array-contains",
- IN = "in",
- NOT_IN = "not-in",
- ARRAY_CONTAINS_ANY = "array-contains-any"
- }
-
- /* Excluded from this release type: or */
-
- /**
- * An ordering on a field, in some Direction. Direction defaults to ASCENDING.
- */
- declare class OrderBy {
- readonly field: FieldPath_2;
- readonly dir: Direction;
- constructor(field: FieldPath_2, dir?: Direction);
- }
-
- /**
- * Creates a {@link QueryOrderByConstraint} that sorts the query result by the
- * specified field, optionally in descending order instead of ascending.
- *
- * Note: Documents that do not contain the specified field will not be present
- * in the query result.
- *
- * @param fieldPath - The field to sort by.
- * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
- * not specified, order will be ascending.
- * @returns The created {@link QueryOrderByConstraint}.
- */
- export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint;
-
- /**
- * The direction of a {@link orderBy} clause is specified as 'desc' or 'asc'
- * (descending or ascending).
- */
- export declare type OrderByDirection = 'desc' | 'asc';
-
- declare type OrderDirection = 'DIRECTION_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING';
-
- declare interface ParseContext {
- readonly databaseId: DatabaseId;
- readonly ignoreUndefinedProperties: boolean;
- }
-
- /** The result of parsing document data (e.g. for a setData call). */
- declare class ParsedSetData {
- readonly data: ObjectValue;
- readonly fieldMask: FieldMask | null;
- readonly fieldTransforms: FieldTransform[];
- constructor(data: ObjectValue, fieldMask: FieldMask | null, fieldTransforms: FieldTransform[]);
- toMutation(key: DocumentKey, precondition: Precondition): Mutation;
- }
-
- /** The result of parsing "update" data (i.e. for an updateData call). */
- declare class ParsedUpdateData {
- readonly data: ObjectValue;
- readonly fieldMask: FieldMask;
- readonly fieldTransforms: FieldTransform[];
- constructor(data: ObjectValue, fieldMask: FieldMask, fieldTransforms: FieldTransform[]);
- toMutation(key: DocumentKey, precondition: Precondition): Mutation;
- }
-
- /**
- * Similar to Typescript's `Partial<T>`, but allows nested fields to be
- * omitted and FieldValues to be passed in as property values.
- */
- export declare type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T extends {} ? {
- [K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue;
- } : never);
-
- /**
- * Encodes a precondition for a mutation. This follows the model that the
- * backend accepts with the special case of an explicit "empty" precondition
- * (meaning no precondition).
- */
- declare class Precondition {
- readonly updateTime?: SnapshotVersion | undefined;
- readonly exists?: boolean | undefined;
- private constructor();
- /** Creates a new empty Precondition. */
- static none(): Precondition;
- /** Creates a new Precondition with an exists flag. */
- static exists(exists: boolean): Precondition;
- /** Creates a new Precondition based on a version a document exists at. */
- static updateTime(version: SnapshotVersion): Precondition;
- /** Returns whether this Precondition is empty. */
- get isNone(): boolean;
- isEqual(other: Precondition): boolean;
- }
-
- /**
- * These types primarily exist to support the `UpdateData`,
- * `WithFieldValue`, and `PartialWithFieldValue` types and are not consumed
- * directly by the end developer.
- */
- /** Primitive types. */
- export declare type Primitive = string | number | boolean | undefined | null;
-
- /** Undocumented, private additional settings not exposed in our public API. */
- declare interface PrivateSettings extends Settings {
- credentials?: CredentialsSettings;
- cacheSizeBytes?: number;
- experimentalForceLongPolling?: boolean;
- experimentalAutoDetectLongPolling?: boolean;
- useFetchStreams?: boolean;
- }
-
- declare interface ProviderCredentialsSettings {
- ['type']: 'provider';
- ['client']: CredentialsProvider<User>;
- }
-
- /**
- * A `Query` refers to a query which you can read or listen to. You can also
- * construct refined `Query` objects by adding filters and ordering.
- */
- export declare class Query<T = DocumentData> {
- /**
- * If provided, the `FirestoreDataConverter` associated with this instance.
- */
- readonly converter: FirestoreDataConverter<T> | null;
- readonly _query: Query_2;
- /** The type of this Firestore reference. */
- readonly type: 'query' | 'collection';
- /**
- * The `Firestore` instance for the Firestore database (useful for performing
- * transactions, etc.).
- */
- readonly firestore: Firestore;
- /** @hideconstructor protected */
- constructor(firestore: Firestore,
- /**
- * If provided, the `FirestoreDataConverter` associated with this instance.
- */
- converter: FirestoreDataConverter<T> | null, _query: Query_2);
- /**
- * Removes the current converter.
- *
- * @param converter - `null` removes the current converter.
- * @returns A `Query<DocumentData>` that does not use a converter.
- */
- withConverter(converter: null): Query<DocumentData>;
- /**
- * Applies a custom data converter to this query, allowing you to use your own
- * custom model objects with Firestore. When you call {@link getDocs} with
- * the returned query, the provided converter will convert between Firestore
- * data and your custom type `U`.
- *
- * @param converter - Converts objects to and from Firestore.
- * @returns A `Query<U>` that uses the provided converter.
- */
- withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
- }
-
- /* Excluded declaration from this release type: query */
-
- /**
- * Creates a new immutable instance of {@link Query} that is extended to also
- * include additional query constraints.
- *
- * @param query - The {@link Query} instance to use as a base for the new
- * constraints.
- * @param queryConstraints - The list of {@link QueryConstraint}s to apply.
- * @throws if any of the provided query constraints cannot be combined with the
- * existing or new constraints.
- */
- export declare function query<T>(query: Query<T>, ...queryConstraints: QueryConstraint[]): Query<T>;
-
- /**
- * The Query interface defines all external properties of a query.
- *
- * QueryImpl implements this interface to provide memoization for `queryOrderBy`
- * and `queryToTarget`.
- */
- declare interface Query_2 {
- readonly path: ResourcePath;
- readonly collectionGroup: string | null;
- readonly explicitOrderBy: OrderBy[];
- readonly filters: Filter[];
- readonly limit: number | null;
- readonly limitType: LimitType;
- readonly startAt: Bound | null;
- readonly endAt: Bound | null;
- }
-
- /* Excluded from this release type: QueryCompositeFilterConstraint */
-
- /**
- * A `QueryConstraint` is used to narrow the set of documents returned by a
- * Firestore query. `QueryConstraint`s are created by invoking {@link where},
- * {@link orderBy}, {@link startAt}, {@link startAfter}, {@link
- * endBefore}, {@link endAt}, {@link limit}, {@link limitToLast} and
- * can then be passed to {@link query} to create a new query instance that
- * also contains this `QueryConstraint`.
- */
- export declare abstract class QueryConstraint extends AppliableConstraint {
- /** The type of this query constraint */
- abstract readonly type: QueryConstraintType;
- /**
- * Takes the provided {@link Query} and returns a copy of the {@link Query} with this
- * {@link AppliableConstraint} applied.
- */
- abstract _apply<T>(query: Query<T>): Query<T>;
- }
-
- /** Describes the different query constraints available in this SDK. */
- export declare type QueryConstraintType = 'where' | 'orderBy' | 'limit' | 'limitToLast' | 'startAt' | 'startAfter' | 'endAt' | 'endBefore';
-
- /**
- * A `QueryDocumentSnapshot` contains data read from a document in your
- * Firestore database as part of a query. The document is guaranteed to exist
- * and its data can be extracted with `.data()` or `.get(<field>)` to get a
- * specific field.
- *
- * A `QueryDocumentSnapshot` offers the same API surface as a
- * `DocumentSnapshot`. Since query results contain only existing documents, the
- * `exists` property will always be true and `data()` will never return
- * 'undefined'.
- */
- export declare class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
- /**
- * Retrieves all fields in the document as an `Object`.
- *
- * @override
- * @returns An `Object` containing all fields in the document.
- */
- data(): T;
- }
-
- /**
- * A `QueryEndAtConstraint` is used to exclude documents from the end of a
- * result set returned by a Firestore query.
- * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
- * {@link (endBefore:1)} and can then be passed to {@link query} to create a new
- * query instance that also contains this `QueryEndAtConstraint`.
- */
- export declare class QueryEndAtConstraint extends QueryConstraint {
- /** The type of this query constraint */
- readonly type: 'endBefore' | 'endAt';
- private readonly _docOrFields;
- private readonly _inclusive;
- /* Excluded from this release type: __constructor */
- static _create(type: 'endBefore' | 'endAt', _docOrFields: Array<unknown | DocumentSnapshot<unknown>>, _inclusive: boolean): QueryEndAtConstraint;
- _apply<T>(query: Query<T>): Query<T>;
- }
-
- /**
- * Returns true if the provided queries point to the same collection and apply
- * the same constraints.
- *
- * @param left - A `Query` to compare.
- * @param right - A `Query` to compare.
- * @returns true if the references point to the same location in the same
- * Firestore database.
- */
- export declare function queryEqual<T>(left: Query<T>, right: Query<T>): boolean;
-
- /**
- * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by
- * a Firestore query by filtering on one or more document fields.
- * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then
- * be passed to {@link query} to create a new query instance that also contains
- * this `QueryFieldFilterConstraint`.
- */
- export declare class QueryFieldFilterConstraint extends QueryConstraint {
- private readonly _field;
- private _op;
- private _value;
- /** The type of this query constraint */
- readonly type = "where";
- /* Excluded from this release type: __constructor */
- static _create(_field: FieldPath_2, _op: Operator, _value: unknown): QueryFieldFilterConstraint;
- _apply<T>(query: Query<T>): Query<T>;
- _parse<T>(query: Query<T>): FieldFilter;
- }
-
- /* Excluded from this release type: QueryFilterConstraint */
-
- /**
- * A `QueryLimitConstraint` is used to limit the number of documents returned by
- * a Firestore query.
- * `QueryLimitConstraint`s are created by invoking {@link limit} or
- * {@link limitToLast} and can then be passed to {@link query} to create a new
- * query instance that also contains this `QueryLimitConstraint`.
- */
- export declare class QueryLimitConstraint extends QueryConstraint {
- /** The type of this query constraint */
- readonly type: 'limit' | 'limitToLast';
- private readonly _limit;
- private readonly _limitType;
- /* Excluded from this release type: __constructor */
- static _create(type: 'limit' | 'limitToLast', _limit: number, _limitType: LimitType): QueryLimitConstraint;
- _apply<T>(query: Query<T>): Query<T>;
- }
-
- /**
- * `QueryNonFilterConstraint` is a helper union type that represents
- * QueryConstraints which are used to narrow or order the set of documents,
- * but that do not explicitly filter on a document field.
- * `QueryNonFilterConstraint`s are created by invoking {@link orderBy},
- * {@link startAt}, {@link startAfter}, {@link endBefore}, {@link endAt},
- * {@link limit} or {@link limitToLast} and can then be passed to {@link query}
- * to create a new query instance that also contains the `QueryConstraint`.
- */
- export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint;
-
- /**
- * A `QueryOrderByConstraint` is used to sort the set of documents returned by a
- * Firestore query. `QueryOrderByConstraint`s are created by invoking
- * {@link orderBy} and can then be passed to {@link query} to create a new query
- * instance that also contains this `QueryOrderByConstraint`.
- *
- * Note: Documents that do not contain the orderBy field will not be present in
- * the query result.
- */
- export declare class QueryOrderByConstraint extends QueryConstraint {
- private readonly _field;
- private _direction;
- /** The type of this query constraint */
- readonly type = "orderBy";
- /* Excluded from this release type: __constructor */
- static _create(_field: FieldPath_2, _direction: Direction): QueryOrderByConstraint;
- _apply<T>(query: Query<T>): Query<T>;
- }
-
- /**
- * A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects
- * representing the results of a query. The documents can be accessed as an
- * array via the `docs` property or enumerated using the `forEach` method. The
- * number of documents can be determined via the `empty` and `size`
- * properties.
- */
- export declare class QuerySnapshot<T = DocumentData> {
- readonly _docs: Array<QueryDocumentSnapshot<T>>;
- /**
- * The query on which you called {@link getDocs} in order to get this
- * `QuerySnapshot`.
- */
- readonly query: Query<T>;
- /** @hideconstructor */
- constructor(_query: Query<T>, _docs: Array<QueryDocumentSnapshot<T>>);
- /** An array of all the documents in the `QuerySnapshot`. */
- get docs(): Array<QueryDocumentSnapshot<T>>;
- /** The number of documents in the `QuerySnapshot`. */
- get size(): number;
- /** True if there are no documents in the `QuerySnapshot`. */
- get empty(): boolean;
- /**
- * Enumerates all of the documents in the `QuerySnapshot`.
- *
- * @param callback - A callback to be called with a `QueryDocumentSnapshot` for
- * each document in the snapshot.
- * @param thisArg - The `this` binding for the callback.
- */
- forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: unknown): void;
- }
-
- /**
- * A `QueryStartAtConstraint` is used to exclude documents from the start of a
- * result set returned by a Firestore query.
- * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
- * {@link (startAfter:1)} and can then be passed to {@link query} to create a
- * new query instance that also contains this `QueryStartAtConstraint`.
- */
- export declare class QueryStartAtConstraint extends QueryConstraint {
- /** The type of this query constraint */
- readonly type: 'startAt' | 'startAfter';
- private readonly _docOrFields;
- private readonly _inclusive;
- /* Excluded from this release type: __constructor */
- static _create(type: 'startAt' | 'startAfter', _docOrFields: Array<unknown | DocumentSnapshot<unknown>>, _inclusive: boolean): QueryStartAtConstraint;
- _apply<T>(query: Query<T>): Query<T>;
- }
-
- /**
- * Returns true if the provided references are equal.
- *
- * @param left - A reference to compare.
- * @param right - A reference to compare.
- * @returns true if the references point to the same location in the same
- * Firestore database.
- */
- export declare function refEqual<T>(left: DocumentReference<T> | CollectionReference<T>, right: DocumentReference<T> | CollectionReference<T>): boolean;
-
- /* Excluded from this release type: ResourcePath */
-
- /**
- * Executes the given `updateFunction` and then attempts to commit the changes
- * applied within the transaction. If any document read within the transaction
- * has changed, Cloud Firestore retries the `updateFunction`. If it fails to
- * commit after 5 attempts, the transaction fails.
- *
- * The maximum number of writes allowed in a single transaction is 500.
- *
- * @param firestore - A reference to the Firestore database to run this
- * transaction against.
- * @param updateFunction - The function to execute within the transaction
- * context.
- * @param options - An options object to configure maximum number of attempts to
- * commit.
- * @returns If the transaction completed successfully or was explicitly aborted
- * (the `updateFunction` returned a failed promise), the promise returned by the
- * `updateFunction `is returned here. Otherwise, if the transaction failed, a
- * rejected promise with the corresponding failure error is returned.
- */
- export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
-
- /**
- * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
- * include a server-generated timestamp in the written data.
- */
- export declare function serverTimestamp(): FieldValue;
-
- declare type ServerTimestampBehavior = 'estimate' | 'previous' | 'none';
-
- /**
- * Writes to the document referred to by the specified `DocumentReference`. If
- * the document does not yet exist, it will be created.
- *
- * The result of this write will only be reflected in document reads that occur
- * after the returned promise resolves. If the client is offline, the
- * write fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @param reference - A reference to the document to write.
- * @param data - A map of the fields and values for the document.
- * @throws Error - If the provided input is not a valid Firestore document.
- * @returns A `Promise` resolved once the data has been successfully written
- * to the backend.
- */
- export declare function setDoc<T>(reference: DocumentReference<T>, data: WithFieldValue<T>): Promise<void>;
-
- /**
- * Writes to the document referred to by the specified `DocumentReference`. If
- * the document does not yet exist, it will be created. If you provide `merge`
- * or `mergeFields`, the provided data can be merged into an existing document.
- *
- * The result of this write will only be reflected in document reads that occur
- * after the returned promise resolves. If the client is offline, the
- * write fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @param reference - A reference to the document to write.
- * @param data - A map of the fields and values for the document.
- * @param options - An object to configure the set behavior.
- * @throws Error - If the provided input is not a valid Firestore document.
- * @returns A `Promise` resolved once the data has been successfully written
- * to the backend.
- */
- export declare function setDoc<T>(reference: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): Promise<void>;
-
- /**
- * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
- *
- * @param logLevel - The verbosity you set for activity and error logging. Can
- * be any of the following values:
- *
- * <ul>
- * <li>`debug` for the most verbose logging level, primarily for
- * debugging.</li>
- * <li>`error` to log errors only.</li>
- * <li><code>`silent` to turn off logging.</li>
- * </ul>
- */
- export declare function setLogLevel(logLevel: LogLevel): void;
-
- /**
- * An options object that configures the behavior of {@link @firebase/firestore/lite#(setDoc:1)}, {@link
- * @firebase/firestore/lite#(WriteBatch.set:1)} and {@link @firebase/firestore/lite#(Transaction.set:1)} calls. These calls can be
- * configured to perform granular merges instead of overwriting the target
- * documents in their entirety by providing a `SetOptions` with `merge: true`.
- *
- * @param merge - Changes the behavior of a `setDoc()` call to only replace the
- * values specified in its data argument. Fields omitted from the `setDoc()`
- * call remain untouched. If your input sets any field to an empty map, all
- * nested fields are overwritten.
- * @param mergeFields - Changes the behavior of `setDoc()` calls to only replace
- * the specified field paths. Any field path that is not specified is ignored
- * and remains untouched. If your input sets any field to an empty map, all
- * nested fields are overwritten.
- */
- export declare type SetOptions = {
- readonly merge?: boolean;
- } | {
- readonly mergeFields?: Array<string | FieldPath>;
- };
-
- /**
- * Specifies custom configurations for your Cloud Firestore instance.
- * You must set these before invoking any other methods.
- */
- export declare interface Settings {
- /** The hostname to connect to. */
- host?: string;
- /** Whether to use SSL when connecting. */
- ssl?: boolean;
- /**
- * Whether to skip nested properties that are set to `undefined` during
- * object serialization. If set to `true`, these properties are skipped
- * and not written to Firestore. If set to `false` or omitted, the SDK
- * throws an exception when it encounters properties of type `undefined`.
- */
- ignoreUndefinedProperties?: boolean;
- }
-
- /**
- * Returns true if the provided snapshots are equal.
- *
- * @param left - A snapshot to compare.
- * @param right - A snapshot to compare.
- * @returns true if the snapshots are equal.
- */
- export declare function snapshotEqual<T>(left: DocumentSnapshot<T> | QuerySnapshot<T>, right: DocumentSnapshot<T> | QuerySnapshot<T>): boolean;
-
- /**
- * A version of a document in Firestore. This corresponds to the version
- * timestamp, such as update_time or read_time.
- */
- declare class SnapshotVersion {
- private timestamp;
- static fromTimestamp(value: Timestamp): SnapshotVersion;
- static min(): SnapshotVersion;
- static max(): SnapshotVersion;
- private constructor();
- compareTo(other: SnapshotVersion): number;
- isEqual(other: SnapshotVersion): boolean;
- /** Returns a number representation of the version for use in spec tests. */
- toMicroseconds(): number;
- toString(): string;
- toTimestamp(): Timestamp;
- }
-
- /**
- * Creates a {@link QueryStartAtConstraint} that modifies the result set to
- * start after the provided document (exclusive). The starting position is
- * relative to the order of the query. The document must contain all of the
- * fields provided in the orderBy of the query.
- *
- * @param snapshot - The snapshot of the document to start after.
- * @returns A {@link QueryStartAtConstraint} to pass to `query()`
- */
- export declare function startAfter(snapshot: DocumentSnapshot<unknown>): QueryStartAtConstraint;
-
- /**
- * Creates a {@link QueryStartAtConstraint} that modifies the result set to
- * start after the provided fields relative to the order of the query. The order
- * of the field values must match the order of the order by clauses of the query.
- *
- * @param fieldValues - The field values to start this query after, in order
- * of the query's order by.
- * @returns A {@link QueryStartAtConstraint} to pass to `query()`
- */
- export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint;
-
- /**
- * Creates a {@link QueryStartAtConstraint} that modifies the result set to
- * start at the provided document (inclusive). The starting position is relative
- * to the order of the query. The document must contain all of the fields
- * provided in the `orderBy` of this query.
- *
- * @param snapshot - The snapshot of the document to start at.
- * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
- */
- export declare function startAt(snapshot: DocumentSnapshot<unknown>): QueryStartAtConstraint;
-
- /**
- * Creates a {@link QueryStartAtConstraint} that modifies the result set to
- * start at the provided fields relative to the order of the query. The order of
- * the field values must match the order of the order by clauses of the query.
- *
- * @param fieldValues - The field values to start this query at, in order
- * of the query's order by.
- * @returns A {@link QueryStartAtConstraint} to pass to `query()`.
- */
- export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;
-
- declare type TargetChangeTargetChangeType = 'NO_CHANGE' | 'ADD' | 'REMOVE' | 'CURRENT' | 'RESET';
-
- /**
- * Terminates the provided `Firestore` instance.
- *
- * After calling `terminate()` only the `clearIndexedDbPersistence()` functions
- * may be used. Any other function will throw a `FirestoreError`. Termination
- * does not cancel any pending writes, and any promises that are awaiting a
- * response from the server will not be resolved.
- *
- * To restart after termination, create a new instance of `Firestore` with
- * {@link (getFirestore:1)}.
- *
- * Note: Under normal circumstances, calling `terminate()` is not required. This
- * function is useful only when you want to force this instance to release all of
- * its resources or in combination with {@link clearIndexedDbPersistence} to
- * ensure that all local state is destroyed between test runs.
- *
- * @param firestore - The `Firestore` instance to terminate.
- * @returns A `Promise` that is resolved when the instance has been successfully
- * terminated.
- */
- export declare function terminate(firestore: Firestore): Promise<void>;
-
- /**
- * Wellknown "timer" IDs used when scheduling delayed operations on the
- * AsyncQueue. These IDs can then be used from tests to check for the presence
- * of operations or to run them early.
- *
- * The string values are used when encoding these timer IDs in JSON spec tests.
- */
- declare const enum TimerId {
- /** All can be used with runDelayedOperationsEarly() to run all timers. */
- All = "all",
- /**
- * The following 5 timers are used in persistent_stream.ts for the listen and
- * write streams. The "Idle" timer is used to close the stream due to
- * inactivity. The "ConnectionBackoff" timer is used to restart a stream once
- * the appropriate backoff delay has elapsed. The health check is used to mark
- * a stream healthy if it has not received an error during its initial setup.
- */
- ListenStreamIdle = "listen_stream_idle",
- ListenStreamConnectionBackoff = "listen_stream_connection_backoff",
- WriteStreamIdle = "write_stream_idle",
- WriteStreamConnectionBackoff = "write_stream_connection_backoff",
- HealthCheckTimeout = "health_check_timeout",
- /**
- * A timer used in online_state_tracker.ts to transition from
- * OnlineState.Unknown to Offline after a set timeout, rather than waiting
- * indefinitely for success or failure.
- */
- OnlineStateTimeout = "online_state_timeout",
- /**
- * A timer used to update the client metadata in IndexedDb, which is used
- * to determine the primary leaseholder.
- */
- ClientMetadataRefresh = "client_metadata_refresh",
- /** A timer used to periodically attempt LRU Garbage collection */
- LruGarbageCollection = "lru_garbage_collection",
- /**
- * A timer used to retry transactions. Since there can be multiple concurrent
- * transactions, multiple of these may be in the queue at a given time.
- */
- TransactionRetry = "transaction_retry",
- /**
- * A timer used to retry operations scheduled via retryable AsyncQueue
- * operations.
- */
- AsyncQueueRetry = "async_queue_retry",
- /**
- * A timer used to periodically attempt index backfill.
- */
- IndexBackfill = "index_backfill"
- }
-
- /**
- * @license
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * A `Timestamp` represents a point in time independent of any time zone or
- * calendar, represented as seconds and fractions of seconds at nanosecond
- * resolution in UTC Epoch time.
- *
- * It is encoded using the Proleptic Gregorian Calendar which extends the
- * Gregorian calendar backwards to year one. It is encoded assuming all minutes
- * are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second
- * table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
- * 9999-12-31T23:59:59.999999999Z.
- *
- * For examples and further specifications, refer to the
- * {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
- */
- export declare class Timestamp {
- /**
- * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
- */
- readonly seconds: number;
- /**
- * The fractions of a second at nanosecond resolution.*
- */
- readonly nanoseconds: number;
- /**
- * Creates a new timestamp with the current date, with millisecond precision.
- *
- * @returns a new timestamp representing the current date.
- */
- static now(): Timestamp;
- /**
- * Creates a new timestamp from the given date.
- *
- * @param date - The date to initialize the `Timestamp` from.
- * @returns A new `Timestamp` representing the same point in time as the given
- * date.
- */
- static fromDate(date: Date): Timestamp;
- /**
- * Creates a new timestamp from the given number of milliseconds.
- *
- * @param milliseconds - Number of milliseconds since Unix epoch
- * 1970-01-01T00:00:00Z.
- * @returns A new `Timestamp` representing the same point in time as the given
- * number of milliseconds.
- */
- static fromMillis(milliseconds: number): Timestamp;
- /**
- * Creates a new timestamp.
- *
- * @param seconds - The number of seconds of UTC time since Unix epoch
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
- * 9999-12-31T23:59:59Z inclusive.
- * @param nanoseconds - The non-negative fractions of a second at nanosecond
- * resolution. Negative second values with fractions must still have
- * non-negative nanoseconds values that count forward in time. Must be
- * from 0 to 999,999,999 inclusive.
- */
- constructor(
- /**
- * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
- */
- seconds: number,
- /**
- * The fractions of a second at nanosecond resolution.*
- */
- nanoseconds: number);
- /**
- * Converts a `Timestamp` to a JavaScript `Date` object. This conversion
- * causes a loss of precision since `Date` objects only support millisecond
- * precision.
- *
- * @returns JavaScript `Date` object representing the same point in time as
- * this `Timestamp`, with millisecond precision.
- */
- toDate(): Date;
- /**
- * Converts a `Timestamp` to a numeric timestamp (in milliseconds since
- * epoch). This operation causes a loss of precision.
- *
- * @returns The point in time corresponding to this timestamp, represented as
- * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
- */
- toMillis(): number;
- _compareTo(other: Timestamp): number;
- /**
- * Returns true if this `Timestamp` is equal to the provided one.
- *
- * @param other - The `Timestamp` to compare against.
- * @returns true if this `Timestamp` is equal to the provided one.
- */
- isEqual(other: Timestamp): boolean;
- /** Returns a textual representation of this `Timestamp`. */
- toString(): string;
- /** Returns a JSON-serializable representation of this `Timestamp`. */
- toJSON(): {
- seconds: number;
- nanoseconds: number;
- };
- /**
- * Converts this object to a primitive string, which allows `Timestamp` objects
- * to be compared using the `>`, `<=`, `>=` and `>` operators.
- */
- valueOf(): string;
- }
-
- declare type Timestamp_2 = string | {
- seconds?: string | number;
- nanos?: number;
- };
-
- declare interface Token {
- /** Type of token. */
- type: TokenType;
- /**
- * The user with which the token is associated (used for persisting user
- * state on disk, etc.).
- * This will be null for Tokens of the type 'AppCheck'.
- */
- user?: User;
- /** Header values to set for this token */
- headers: Map<string, string>;
- }
-
- declare type TokenType = 'OAuth' | 'FirstParty' | 'AppCheck';
-
- /**
- * A reference to a transaction.
- *
- * The `Transaction` object passed to a transaction's `updateFunction` provides
- * the methods to read and write data within the transaction context. See
- * {@link runTransaction}.
- */
- export declare class Transaction {
- protected readonly _firestore: Firestore;
- private readonly _transaction;
- private readonly _dataReader;
- /** @hideconstructor */
- constructor(_firestore: Firestore, _transaction: Transaction_2);
- /**
- * Reads the document referenced by the provided {@link DocumentReference}.
- *
- * @param documentRef - A reference to the document to be read.
- * @returns A `DocumentSnapshot` with the read data.
- */
- get<T>(documentRef: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
- /**
- * Writes to the document referred to by the provided {@link
- * DocumentReference}. If the document does not exist yet, it will be created.
- *
- * @param documentRef - A reference to the document to be set.
- * @param data - An object of the fields and values for the document.
- * @throws Error - If the provided input is not a valid Firestore document.
- * @returns This `Transaction` instance. Used for chaining method calls.
- */
- set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): this;
- /**
- * Writes to the document referred to by the provided {@link
- * DocumentReference}. If the document does not exist yet, it will be created.
- * If you provide `merge` or `mergeFields`, the provided data can be merged
- * into an existing document.
- *
- * @param documentRef - A reference to the document to be set.
- * @param data - An object of the fields and values for the document.
- * @param options - An object to configure the set behavior.
- * @throws Error - If the provided input is not a valid Firestore document.
- * @returns This `Transaction` instance. Used for chaining method calls.
- */
- set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): this;
- /**
- * Updates fields in the document referred to by the provided {@link
- * DocumentReference}. The update will fail if applied to a document that does
- * not exist.
- *
- * @param documentRef - A reference to the document to be updated.
- * @param data - An object containing the fields and values with which to
- * update the document. Fields can contain dots to reference nested fields
- * within the document.
- * @throws Error - If the provided input is not valid Firestore data.
- * @returns This `Transaction` instance. Used for chaining method calls.
- */
- update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): this;
- /**
- * Updates fields in the document referred to by the provided {@link
- * DocumentReference}. The update will fail if applied to a document that does
- * not exist.
- *
- * Nested fields can be updated by providing dot-separated field path
- * strings or by providing `FieldPath` objects.
- *
- * @param documentRef - A reference to the document to be updated.
- * @param field - The first field to update.
- * @param value - The first value.
- * @param moreFieldsAndValues - Additional key/value pairs.
- * @throws Error - If the provided input is not valid Firestore data.
- * @returns This `Transaction` instance. Used for chaining method calls.
- */
- update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): this;
- /**
- * Deletes the document referred to by the provided {@link DocumentReference}.
- *
- * @param documentRef - A reference to the document to be deleted.
- * @returns This `Transaction` instance. Used for chaining method calls.
- */
- delete(documentRef: DocumentReference<unknown>): this;
- }
-
- /**
- * Internal transaction object responsible for accumulating the mutations to
- * perform and the base versions for any documents read.
- */
- declare class Transaction_2 {
- private datastore;
- private readVersions;
- private mutations;
- private committed;
- /**
- * A deferred usage error that occurred previously in this transaction that
- * will cause the transaction to fail once it actually commits.
- */
- private lastWriteError;
- /**
- * Set of documents that have been written in the transaction.
- *
- * When there's more than one write to the same key in a transaction, any
- * writes after the first are handled differently.
- */
- private writtenDocs;
- constructor(datastore: Datastore);
- lookup(keys: DocumentKey[]): Promise<Document_2[]>;
- set(key: DocumentKey, data: ParsedSetData): void;
- update(key: DocumentKey, data: ParsedUpdateData): void;
- delete(key: DocumentKey): void;
- commit(): Promise<void>;
- private recordVersion;
- /**
- * Returns the version of this document when it was read in this transaction,
- * as a precondition, or no precondition if it was not read.
- */
- private precondition;
- /**
- * Returns the precondition for a document if the operation is an update.
- */
- private preconditionForUpdate;
- private write;
- private ensureCommitNotCalled;
- }
-
- /**
- * @license
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * Options to customize transaction behavior.
- */
- export declare interface TransactionOptions {
- /** Maximum number of attempts to commit, after which transaction fails. Default is 5. */
- readonly maxAttempts?: number;
- }
-
- /** Used to represent a field transform on a mutation. */
- declare class TransformOperation {
- private _;
- }
-
- declare type UnaryFilterOp = 'OPERATOR_UNSPECIFIED' | 'IS_NAN' | 'IS_NULL' | 'IS_NOT_NAN' | 'IS_NOT_NULL';
-
- /**
- * Given a union type `U = T1 | T2 | ...`, returns an intersected type
- * `(T1 & T2 & ...)`.
- *
- * Uses distributive conditional types and inference from conditional types.
- * This works because multiple candidates for the same type variable in
- * contra-variant positions causes an intersection type to be inferred.
- * https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types
- * https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
- */
- export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
-
- /**
- * An untyped Firestore Data Converter interface that is shared between the
- * lite, firestore-exp and classic SDK.
- */
- declare interface UntypedFirestoreDataConverter<T> {
- toFirestore(modelObject: WithFieldValue<T>): DocumentData_2;
- toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions_2): DocumentData_2;
- fromFirestore(snapshot: unknown, options?: unknown): T;
- }
-
- /**
- * Update data (for use with {@link (updateDoc:1)}) that consists of field paths
- * (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots
- * reference nested fields within the document. FieldValues can be passed in
- * as property values.
- */
- export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
- [K in keyof T]?: UpdateData<T[K]> | FieldValue;
- } & NestedUpdateFields<T> : Partial<T>;
-
- /**
- * Updates fields in the document referred to by the specified
- * `DocumentReference`. The update will fail if applied to a document that does
- * not exist.
- *
- * The result of this update will only be reflected in document reads that occur
- * after the returned promise resolves. If the client is offline, the
- * update fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @param reference - A reference to the document to update.
- * @param data - An object containing the fields and values with which to
- * update the document. Fields can contain dots to reference nested fields
- * within the document.
- * @throws Error - If the provided input is not valid Firestore data.
- * @returns A `Promise` resolved once the data has been successfully written
- * to the backend.
- */
- export declare function updateDoc<T>(reference: DocumentReference<T>, data: UpdateData<T>): Promise<void>;
-
- /**
- * Updates fields in the document referred to by the specified
- * `DocumentReference` The update will fail if applied to a document that does
- * not exist.
- *
- * Nested fields can be updated by providing dot-separated field path
- * strings or by providing `FieldPath` objects.
- *
- * The result of this update will only be reflected in document reads that occur
- * after the returned promise resolves. If the client is offline, the
- * update fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @param reference - A reference to the document to update.
- * @param field - The first field to update.
- * @param value - The first value.
- * @param moreFieldsAndValues - Additional key value pairs.
- * @throws Error - If the provided input is not valid Firestore data.
- * @returns A `Promise` resolved once the data has been successfully written
- * to the backend.
- */
- export declare function updateDoc(reference: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise<void>;
-
- /**
- * @license
- * Copyright 2017 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * Simple wrapper around a nullable UID. Mostly exists to make code more
- * readable.
- */
- declare class User {
- readonly uid: string | null;
- /** A user with a null UID. */
- static readonly UNAUTHENTICATED: User;
- static readonly GOOGLE_CREDENTIALS: User;
- static readonly FIRST_PARTY: User;
- static readonly MOCK_USER: User;
- constructor(uid: string | null);
- isAuthenticated(): boolean;
- /**
- * Returns a key representing this user, suitable for inclusion in a
- * dictionary.
- */
- toKey(): string;
- isEqual(otherUser: User): boolean;
- }
-
- declare type Value = firestoreV1ApiClientInterfaces.Value;
-
- declare type ValueNullValue = 'NULL_VALUE';
-
- /**
- * Creates a {@link QueryFieldFilterConstraint} that enforces that documents
- * must contain the specified field and that the value should satisfy the
- * relation constraint provided.
- *
- * @param fieldPath - The path to compare
- * @param opStr - The operation string (e.g "<", "<=", "==", "<",
- * "<=", "!=").
- * @param value - The value for comparison
- * @returns The created {@link QueryFieldFilterConstraint}.
- */
- export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint;
-
- /**
- * Filter conditions in a {@link where} clause are specified using the
- * strings '<', '<=', '==', '!=', '>=', '>', 'array-contains', 'in',
- * 'array-contains-any', and 'not-in'.
- */
- export declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';
-
- /**
- * Allows FieldValues to be passed in as a property value while maintaining
- * type safety.
- */
- export declare type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? {
- [K in keyof T]: WithFieldValue<T[K]> | FieldValue;
- } : never);
-
- /**
- * A write batch, used to perform multiple writes as a single atomic unit.
- *
- * A `WriteBatch` object can be acquired by calling {@link writeBatch}. It
- * provides methods for adding writes to the write batch. None of the writes
- * will be committed (or visible locally) until {@link WriteBatch.commit} is
- * called.
- */
- export declare class WriteBatch {
- private readonly _firestore;
- private readonly _commitHandler;
- private readonly _dataReader;
- private _mutations;
- private _committed;
- /** @hideconstructor */
- constructor(_firestore: Firestore, _commitHandler: (m: Mutation[]) => Promise<void>);
- /**
- * Writes to the document referred to by the provided {@link
- * DocumentReference}. If the document does not exist yet, it will be created.
- *
- * @param documentRef - A reference to the document to be set.
- * @param data - An object of the fields and values for the document.
- * @returns This `WriteBatch` instance. Used for chaining method calls.
- */
- set<T>(documentRef: DocumentReference<T>, data: WithFieldValue<T>): WriteBatch;
- /**
- * Writes to the document referred to by the provided {@link
- * DocumentReference}. If the document does not exist yet, it will be created.
- * If you provide `merge` or `mergeFields`, the provided data can be merged
- * into an existing document.
- *
- * @param documentRef - A reference to the document to be set.
- * @param data - An object of the fields and values for the document.
- * @param options - An object to configure the set behavior.
- * @throws Error - If the provided input is not a valid Firestore document.
- * @returns This `WriteBatch` instance. Used for chaining method calls.
- */
- set<T>(documentRef: DocumentReference<T>, data: PartialWithFieldValue<T>, options: SetOptions): WriteBatch;
- /**
- * Updates fields in the document referred to by the provided {@link
- * DocumentReference}. The update will fail if applied to a document that does
- * not exist.
- *
- * @param documentRef - A reference to the document to be updated.
- * @param data - An object containing the fields and values with which to
- * update the document. Fields can contain dots to reference nested fields
- * within the document.
- * @throws Error - If the provided input is not valid Firestore data.
- * @returns This `WriteBatch` instance. Used for chaining method calls.
- */
- update<T>(documentRef: DocumentReference<T>, data: UpdateData<T>): WriteBatch;
- /**
- * Updates fields in the document referred to by this {@link
- * DocumentReference}. The update will fail if applied to a document that does
- * not exist.
- *
- * Nested fields can be update by providing dot-separated field path strings
- * or by providing `FieldPath` objects.
- *
- * @param documentRef - A reference to the document to be updated.
- * @param field - The first field to update.
- * @param value - The first value.
- * @param moreFieldsAndValues - Additional key value pairs.
- * @throws Error - If the provided input is not valid Firestore data.
- * @returns This `WriteBatch` instance. Used for chaining method calls.
- */
- update(documentRef: DocumentReference<unknown>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): WriteBatch;
- /**
- * Deletes the document referred to by the provided {@link DocumentReference}.
- *
- * @param documentRef - A reference to the document to be deleted.
- * @returns This `WriteBatch` instance. Used for chaining method calls.
- */
- delete(documentRef: DocumentReference<unknown>): WriteBatch;
- /**
- * Commits all of the writes in this write batch as a single atomic unit.
- *
- * The result of these writes will only be reflected in document reads that
- * occur after the returned promise resolves. If the client is offline, the
- * write fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @returns A `Promise` resolved once all of the writes in the batch have been
- * successfully written to the backend as an atomic unit (note that it won't
- * resolve while you're offline).
- */
- commit(): Promise<void>;
- private _verifyNotCommitted;
- }
-
- /**
- * Creates a write batch, used for performing multiple writes as a single
- * atomic operation. The maximum number of writes allowed in a single WriteBatch
- * is 500.
- *
- * The result of these writes will only be reflected in document reads that
- * occur after the returned promise resolves. If the client is offline, the
- * write fails. If you would like to see local modifications or buffer writes
- * until the client is online, use the full Firestore SDK.
- *
- * @returns A `WriteBatch` that can be used to atomically execute multiple
- * writes.
- */
- export declare function writeBatch(firestore: Firestore): WriteBatch;
-
- export { }
|