12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397 |
- /**
- * Firebase Realtime Database
- *
- * @packageDocumentation
- */
- import { FirebaseApp } from '@firebase/app';
- import { EmulatorMockTokenOptions } from '@firebase/util';
-
- /**
- * Gets a `Reference` for the location at the specified relative path.
- *
- * The relative path can either be a simple child name (for example, "ada") or
- * a deeper slash-separated path (for example, "ada/name/first").
- *
- * @param parent - The parent location.
- * @param path - A relative path from this location to the desired child
- * location.
- * @returns The specified child location.
- */
- export declare function child(parent: DatabaseReference, path: string): DatabaseReference;
- /**
- * Modify the provided instance to communicate with the Realtime Database
- * emulator.
- *
- * <p>Note: This method must be called before performing any other operation.
- *
- * @param db - The instance to modify.
- * @param host - The emulator host (ex: localhost)
- * @param port - The emulator port (ex: 8080)
- * @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
- */
- export declare function connectDatabaseEmulator(db: Database, host: string, port: number, options?: {
- mockUserToken?: EmulatorMockTokenOptions | string;
- }): void;
- /**
- * Class representing a Firebase Realtime Database.
- */
- export declare class Database {
- /** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
- readonly app: FirebaseApp;
- /** Represents a `Database` instance. */
- readonly 'type' = "database";
- private constructor();
- }
- /**
- * A `DatabaseReference` represents a specific location in your Database and can be used
- * for reading or writing data to that Database location.
- *
- * You can reference the root or child location in your Database by calling
- * `ref()` or `ref("child/path")`.
- *
- * Writing is done with the `set()` method and reading can be done with the
- * `on*()` method. See {@link
- * https://firebase.google.com/docs/database/web/read-and-write}
- */
- export declare interface DatabaseReference extends Query {
- /**
- * The last part of the `DatabaseReference`'s path.
- *
- * For example, `"ada"` is the key for
- * `https://<DATABASE_NAME>.firebaseio.com/users/ada`.
- *
- * The key of a root `DatabaseReference` is `null`.
- */
- readonly key: string | null;
- /**
- * The parent location of a `DatabaseReference`.
- *
- * The parent of a root `DatabaseReference` is `null`.
- */
- readonly parent: DatabaseReference | null;
- /** The root `DatabaseReference` of the Database. */
- readonly root: DatabaseReference;
- }
- /**
- * A `DataSnapshot` contains data from a Database location.
- *
- * Any time you read data from the Database, you receive the data as a
- * `DataSnapshot`. A `DataSnapshot` is passed to the event callbacks you attach
- * with `on()` or `once()`. You can extract the contents of the snapshot as a
- * JavaScript object by calling the `val()` method. Alternatively, you can
- * traverse into the snapshot by calling `child()` to return child snapshots
- * (which you could then call `val()` on).
- *
- * A `DataSnapshot` is an efficiently generated, immutable copy of the data at
- * a Database location. It cannot be modified and will never change (to modify
- * data, you always call the `set()` method on a `Reference` directly).
- */
- export declare class DataSnapshot {
- /**
- * The location of this DataSnapshot.
- */
- readonly ref: DatabaseReference;
- private constructor();
- /**
- * Gets the priority value of the data in this `DataSnapshot`.
- *
- * Applications need not use priority but can order collections by
- * ordinary properties (see
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data |Sorting and filtering data}
- * ).
- */
- get priority(): string | number | null;
- /**
- * The key (last part of the path) of the location of this `DataSnapshot`.
- *
- * The last token in a Database location is considered its key. For example,
- * "ada" is the key for the /users/ada/ node. Accessing the key on any
- * `DataSnapshot` will return the key for the location that generated it.
- * However, accessing the key on the root URL of a Database will return
- * `null`.
- */
- get key(): string | null;
- /** Returns the number of child properties of this `DataSnapshot`. */
- get size(): number;
- /**
- * Gets another `DataSnapshot` for the location at the specified relative path.
- *
- * Passing a relative path to the `child()` method of a DataSnapshot returns
- * another `DataSnapshot` for the location at the specified relative path. The
- * relative path can either be a simple child name (for example, "ada") or a
- * deeper, slash-separated path (for example, "ada/name/first"). If the child
- * location has no data, an empty `DataSnapshot` (that is, a `DataSnapshot`
- * whose value is `null`) is returned.
- *
- * @param path - A relative path to the location of child data.
- */
- child(path: string): DataSnapshot;
- /**
- * Returns true if this `DataSnapshot` contains any data. It is slightly more
- * efficient than using `snapshot.val() !== null`.
- */
- exists(): boolean;
- /**
- * Exports the entire contents of the DataSnapshot as a JavaScript object.
- *
- * The `exportVal()` method is similar to `val()`, except priority information
- * is included (if available), making it suitable for backing up your data.
- *
- * @returns The DataSnapshot's contents as a JavaScript value (Object,
- * Array, string, number, boolean, or `null`).
- */
- exportVal(): any;
- /**
- * Enumerates the top-level children in the `DataSnapshot`.
- *
- * Because of the way JavaScript objects work, the ordering of data in the
- * JavaScript object returned by `val()` is not guaranteed to match the
- * ordering on the server nor the ordering of `onChildAdded()` events. That is
- * where `forEach()` comes in handy. It guarantees the children of a
- * `DataSnapshot` will be iterated in their query order.
- *
- * If no explicit `orderBy*()` method is used, results are returned
- * ordered by key (unless priorities are used, in which case, results are
- * returned by priority).
- *
- * @param action - A function that will be called for each child DataSnapshot.
- * The callback can return true to cancel further enumeration.
- * @returns true if enumeration was canceled due to your callback returning
- * true.
- */
- forEach(action: (child: DataSnapshot) => boolean | void): boolean;
- /**
- * Returns true if the specified child path has (non-null) data.
- *
- * @param path - A relative path to the location of a potential child.
- * @returns `true` if data exists at the specified child path; else
- * `false`.
- */
- hasChild(path: string): boolean;
- /**
- * Returns whether or not the `DataSnapshot` has any non-`null` child
- * properties.
- *
- * You can use `hasChildren()` to determine if a `DataSnapshot` has any
- * children. If it does, you can enumerate them using `forEach()`. If it
- * doesn't, then either this snapshot contains a primitive value (which can be
- * retrieved with `val()`) or it is empty (in which case, `val()` will return
- * `null`).
- *
- * @returns true if this snapshot has any children; else false.
- */
- hasChildren(): boolean;
- /**
- * Returns a JSON-serializable representation of this object.
- */
- toJSON(): object | null;
- /**
- * Extracts a JavaScript value from a `DataSnapshot`.
- *
- * Depending on the data in a `DataSnapshot`, the `val()` method may return a
- * scalar type (string, number, or boolean), an array, or an object. It may
- * also return null, indicating that the `DataSnapshot` is empty (contains no
- * data).
- *
- * @returns The DataSnapshot's contents as a JavaScript value (Object,
- * Array, string, number, boolean, or `null`).
- */
- val(): any;
- }
- export { EmulatorMockTokenOptions };
- /**
- * Logs debugging information to the console.
- *
- * @param enabled - Enables logging if `true`, disables logging if `false`.
- * @param persistent - Remembers the logging state between page refreshes if
- * `true`.
- */
- export declare function enableLogging(enabled: boolean, persistent?: boolean): any;
- /**
- * Logs debugging information to the console.
- *
- * @param logger - A custom logger function to control how things get logged.
- */
- export declare function enableLogging(logger: (message: string) => unknown): any;
- /**
- * Creates a `QueryConstraint` with the specified ending point.
- *
- * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
- * allows you to choose arbitrary starting and ending points for your queries.
- *
- * The ending point is inclusive, so children with exactly the specified value
- * will be included in the query. The optional key argument can be used to
- * further limit the range of the query. If it is specified, then children that
- * have exactly the specified value must also have a key name less than or equal
- * to the specified key.
- *
- * You can read more about `endAt()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
- *
- * @param value - The value to end at. The argument type depends on which
- * `orderBy*()` function was used in this query. Specify a value that matches
- * the `orderBy*()` type. When used in combination with `orderByKey()`, the
- * value must be a string.
- * @param key - The child key to end at, among the children with the previously
- * specified priority. This argument is only allowed if ordering by child,
- * value, or priority.
- */
- export declare function endAt(value: number | string | boolean | null, key?: string): QueryConstraint;
- /**
- * Creates a `QueryConstraint` with the specified ending point (exclusive).
- *
- * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
- * allows you to choose arbitrary starting and ending points for your queries.
- *
- * The ending point is exclusive. If only a value is provided, children
- * with a value less than the specified value will be included in the query.
- * If a key is specified, then children must have a value less than or equal
- * to the specified value and a key name less than the specified key.
- *
- * @param value - The value to end before. The argument type depends on which
- * `orderBy*()` function was used in this query. Specify a value that matches
- * the `orderBy*()` type. When used in combination with `orderByKey()`, the
- * value must be a string.
- * @param key - The child key to end before, among the children with the
- * previously specified priority. This argument is only allowed if ordering by
- * child, value, or priority.
- */
- export declare function endBefore(value: number | string | boolean | null, key?: string): QueryConstraint;
- /**
- * Creates a `QueryConstraint` that includes children that match the specified
- * value.
- *
- * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
- * allows you to choose arbitrary starting and ending points for your queries.
- *
- * The optional key argument can be used to further limit the range of the
- * query. If it is specified, then children that have exactly the specified
- * value must also have exactly the specified key as their key name. This can be
- * used to filter result sets with many matches for the same value.
- *
- * You can read more about `equalTo()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
- *
- * @param value - The value to match for. The argument type depends on which
- * `orderBy*()` function was used in this query. Specify a value that matches
- * the `orderBy*()` type. When used in combination with `orderByKey()`, the
- * value must be a string.
- * @param key - The child key to start at, among the children with the
- * previously specified priority. This argument is only allowed if ordering by
- * child, value, or priority.
- */
- export declare function equalTo(value: number | string | boolean | null, key?: string): QueryConstraint;
- /**
- * One of the following strings: "value", "child_added", "child_changed",
- * "child_removed", or "child_moved."
- */
- export declare type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed';
- /* Excluded from this release type: _FirebaseService */
- /**
- * Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
- */
- export declare function forceLongPolling(): void;
- /**
- * Force the use of websockets instead of longPolling.
- */
- export declare function forceWebSockets(): void;
- /**
- * Gets the most up-to-date result for this query.
- *
- * @param query - The query to run.
- * @returns A `Promise` which resolves to the resulting DataSnapshot if a value is
- * available, or rejects if the client is unable to return a value (e.g., if the
- * server is unreachable and there is nothing cached).
- */
- export declare function get(query: Query): Promise<DataSnapshot>;
- /**
- * Returns the instance of the Realtime Database SDK that is associated
- * with the provided {@link @firebase/app#FirebaseApp}. Initializes a new instance with
- * with default settings if no instance exists or if the existing instance uses
- * a custom database URL.
- *
- * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned Realtime
- * Database instance is associated with.
- * @param url - The URL of the Realtime Database instance to connect to. If not
- * provided, the SDK connects to the default instance of the Firebase App.
- * @returns The `Database` instance of the provided app.
- */
- export declare function getDatabase(app?: FirebaseApp, url?: string): Database;
- /**
- * Disconnects from the server (all Database operations will be completed
- * offline).
- *
- * The client automatically maintains a persistent connection to the Database
- * server, which will remain active indefinitely and reconnect when
- * disconnected. However, the `goOffline()` and `goOnline()` methods may be used
- * to control the client connection in cases where a persistent connection is
- * undesirable.
- *
- * While offline, the client will no longer receive data updates from the
- * Database. However, all Database operations performed locally will continue to
- * immediately fire events, allowing your application to continue behaving
- * normally. Additionally, each operation performed locally will automatically
- * be queued and retried upon reconnection to the Database server.
- *
- * To reconnect to the Database and begin receiving remote events, see
- * `goOnline()`.
- *
- * @param db - The instance to disconnect.
- */
- export declare function goOffline(db: Database): void;
- /**
- * Reconnects to the server and synchronizes the offline Database state
- * with the server state.
- *
- * This method should be used after disabling the active connection with
- * `goOffline()`. Once reconnected, the client will transmit the proper data
- * and fire the appropriate events so that your client "catches up"
- * automatically.
- *
- * @param db - The instance to reconnect.
- */
- export declare function goOnline(db: Database): void;
- /**
- * Returns a placeholder value that can be used to atomically increment the
- * current database value by the provided delta.
- *
- * @param delta - the amount to modify the current value atomically.
- * @returns A placeholder value for modifying data atomically server-side.
- */
- export declare function increment(delta: number): object;
- /**
- * Creates a new `QueryConstraint` that if limited to the first specific number
- * of children.
- *
- * The `limitToFirst()` method is used to set a maximum number of children to be
- * synced for a given callback. If we set a limit of 100, we will initially only
- * receive up to 100 `child_added` events. If we have fewer than 100 messages
- * stored in our Database, a `child_added` event will fire for each message.
- * However, if we have over 100 messages, we will only receive a `child_added`
- * event for the first 100 ordered messages. As items change, we will receive
- * `child_removed` events for each item that drops out of the active list so
- * that the total number stays at 100.
- *
- * You can read more about `limitToFirst()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
- *
- * @param limit - The maximum number of nodes to include in this query.
- */
- export declare function limitToFirst(limit: number): QueryConstraint;
- /**
- * Creates a new `QueryConstraint` that is limited to return only the last
- * specified number of children.
- *
- * The `limitToLast()` method is used to set a maximum number of children to be
- * synced for a given callback. If we set a limit of 100, we will initially only
- * receive up to 100 `child_added` events. If we have fewer than 100 messages
- * stored in our Database, a `child_added` event will fire for each message.
- * However, if we have over 100 messages, we will only receive a `child_added`
- * event for the last 100 ordered messages. As items change, we will receive
- * `child_removed` events for each item that drops out of the active list so
- * that the total number stays at 100.
- *
- * You can read more about `limitToLast()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
- *
- * @param limit - The maximum number of nodes to include in this query.
- */
- export declare function limitToLast(limit: number): QueryConstraint;
- /** An options objects that can be used to customize a listener. */
- export declare interface ListenOptions {
- /** Whether to remove the listener after its first invocation. */
- readonly onlyOnce?: boolean;
- }
- /**
- * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
- * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
- * the respective `on*` callbacks.
- *
- * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
- * will not automatically remove listeners registered on child nodes, `off()`
- * must also be called on any child listeners to remove the callback.
- *
- * If a callback is not specified, all callbacks for the specified eventType
- * will be removed. Similarly, if no eventType is specified, all callbacks
- * for the `Reference` will be removed.
- *
- * Individual listeners can also be removed by invoking their unsubscribe
- * callbacks.
- *
- * @param query - The query that the listener was registered with.
- * @param eventType - One of the following strings: "value", "child_added",
- * "child_changed", "child_removed", or "child_moved." If omitted, all callbacks
- * for the `Reference` will be removed.
- * @param callback - The callback function that was passed to `on()` or
- * `undefined` to remove all callbacks.
- */
- export declare function off(query: Query, eventType?: EventType, callback?: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown): void;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildAdded` event will be triggered once for each initial child at this
- * location, and it will be triggered again every time a new child is added. The
- * `DataSnapshot` passed into the callback will reflect the data for the
- * relevant child. For ordering purposes, it is passed a second argument which
- * is a string containing the key of the previous sibling child by sort order,
- * or `null` if it is the first child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildAdded` event will be triggered once for each initial child at this
- * location, and it will be triggered again every time a new child is added. The
- * `DataSnapshot` passed into the callback will reflect the data for the
- * relevant child. For ordering purposes, it is passed a second argument which
- * is a string containing the key of the previous sibling child by sort order,
- * or `null` if it is the first child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildAdded` event will be triggered once for each initial child at this
- * location, and it will be triggered again every time a new child is added. The
- * `DataSnapshot` passed into the callback will reflect the data for the
- * relevant child. For ordering purposes, it is passed a second argument which
- * is a string containing the key of the previous sibling child by sort order,
- * or `null` if it is the first child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildChanged` event will be triggered when the data stored in a child
- * (or any of its descendants) changes. Note that a single `child_changed` event
- * may represent multiple changes to the child. The `DataSnapshot` passed to the
- * callback will contain the new child contents. For ordering purposes, the
- * callback is also passed a second argument which is a string containing the
- * key of the previous sibling child by sort order, or `null` if it is the first
- * child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildChanged` event will be triggered when the data stored in a child
- * (or any of its descendants) changes. Note that a single `child_changed` event
- * may represent multiple changes to the child. The `DataSnapshot` passed to the
- * callback will contain the new child contents. For ordering purposes, the
- * callback is also passed a second argument which is a string containing the
- * key of the previous sibling child by sort order, or `null` if it is the first
- * child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildChanged` event will be triggered when the data stored in a child
- * (or any of its descendants) changes. Note that a single `child_changed` event
- * may represent multiple changes to the child. The `DataSnapshot` passed to the
- * callback will contain the new child contents. For ordering purposes, the
- * callback is also passed a second argument which is a string containing the
- * key of the previous sibling child by sort order, or `null` if it is the first
- * child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildMoved` event will be triggered when a child's sort order changes
- * such that its position relative to its siblings changes. The `DataSnapshot`
- * passed to the callback will be for the data of the child that has moved. It
- * is also passed a second argument which is a string containing the key of the
- * previous sibling child by sort order, or `null` if it is the first child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildMoved` event will be triggered when a child's sort order changes
- * such that its position relative to its siblings changes. The `DataSnapshot`
- * passed to the callback will be for the data of the child that has moved. It
- * is also passed a second argument which is a string containing the key of the
- * previous sibling child by sort order, or `null` if it is the first child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildMoved` event will be triggered when a child's sort order changes
- * such that its position relative to its siblings changes. The `DataSnapshot`
- * passed to the callback will be for the data of the child that has moved. It
- * is also passed a second argument which is a string containing the key of the
- * previous sibling child by sort order, or `null` if it is the first child.
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildRemoved` event will be triggered once every time a child is
- * removed. The `DataSnapshot` passed into the callback will be the old data for
- * the child that was removed. A child will get removed when either:
- *
- * - a client explicitly calls `remove()` on that child or one of its ancestors
- * - a client calls `set(null)` on that child or one of its ancestors
- * - that child has all of its children removed
- * - there is a query in effect which now filters out the child (because it's
- * sort order changed or the max limit was hit)
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildRemoved` event will be triggered once every time a child is
- * removed. The `DataSnapshot` passed into the callback will be the old data for
- * the child that was removed. A child will get removed when either:
- *
- * - a client explicitly calls `remove()` on that child or one of its ancestors
- * - a client calls `set(null)` on that child or one of its ancestors
- * - that child has all of its children removed
- * - there is a query in effect which now filters out the child (because it's
- * sort order changed or the max limit was hit)
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onChildRemoved` event will be triggered once every time a child is
- * removed. The `DataSnapshot` passed into the callback will be the old data for
- * the child that was removed. A child will get removed when either:
- *
- * - a client explicitly calls `remove()` on that child or one of its ancestors
- * - a client calls `set(null)` on that child or one of its ancestors
- * - that child has all of its children removed
- * - there is a query in effect which now filters out the child (because it's
- * sort order changed or the max limit was hit)
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs.
- * The callback will be passed a DataSnapshot and a string containing the key of
- * the previous child, by sort order, or `null` if it is the first child.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * The `onDisconnect` class allows you to write or clear data when your client
- * disconnects from the Database server. These updates occur whether your
- * client disconnects cleanly or not, so you can rely on them to clean up data
- * even if a connection is dropped or a client crashes.
- *
- * The `onDisconnect` class is most commonly used to manage presence in
- * applications where it is useful to detect how many clients are connected and
- * when other clients disconnect. See
- * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
- * for more information.
- *
- * To avoid problems when a connection is dropped before the requests can be
- * transferred to the Database server, these functions should be called before
- * writing any data.
- *
- * Note that `onDisconnect` operations are only triggered once. If you want an
- * operation to occur each time a disconnect occurs, you'll need to re-establish
- * the `onDisconnect` operations each time you reconnect.
- */
- export declare class OnDisconnect {
- private constructor();
- /**
- * Cancels all previously queued `onDisconnect()` set or update events for this
- * location and all children.
- *
- * If a write has been queued for this location via a `set()` or `update()` at a
- * parent location, the write at this location will be canceled, though writes
- * to sibling locations will still occur.
- *
- * @returns Resolves when synchronization to the server is complete.
- */
- cancel(): Promise<void>;
- /**
- * Ensures the data at this location is deleted when the client is disconnected
- * (due to closing the browser, navigating to a new page, or network issues).
- *
- * @returns Resolves when synchronization to the server is complete.
- */
- remove(): Promise<void>;
- /**
- * Ensures the data at this location is set to the specified value when the
- * client is disconnected (due to closing the browser, navigating to a new page,
- * or network issues).
- *
- * `set()` is especially useful for implementing "presence" systems, where a
- * value should be changed or cleared when a user disconnects so that they
- * appear "offline" to other users. See
- * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
- * for more information.
- *
- * Note that `onDisconnect` operations are only triggered once. If you want an
- * operation to occur each time a disconnect occurs, you'll need to re-establish
- * the `onDisconnect` operations each time.
- *
- * @param value - The value to be written to this location on disconnect (can
- * be an object, array, string, number, boolean, or null).
- * @returns Resolves when synchronization to the Database is complete.
- */
- set(value: unknown): Promise<void>;
- /**
- * Ensures the data at this location is set to the specified value and priority
- * when the client is disconnected (due to closing the browser, navigating to a
- * new page, or network issues).
- *
- * @param value - The value to be written to this location on disconnect (can
- * be an object, array, string, number, boolean, or null).
- * @param priority - The priority to be written (string, number, or null).
- * @returns Resolves when synchronization to the Database is complete.
- */
- setWithPriority(value: unknown, priority: number | string | null): Promise<void>;
- /**
- * Writes multiple values at this location when the client is disconnected (due
- * to closing the browser, navigating to a new page, or network issues).
- *
- * The `values` argument contains multiple property-value pairs that will be
- * written to the Database together. Each child property can either be a simple
- * property (for example, "name") or a relative path (for example, "name/first")
- * from the current location to the data to update.
- *
- * As opposed to the `set()` method, `update()` can be use to selectively update
- * only the referenced properties at the current location (instead of replacing
- * all the child properties at the current location).
- *
- * @param values - Object containing multiple values.
- * @returns Resolves when synchronization to the Database is complete.
- */
- update(values: object): Promise<void>;
- }
- /**
- * Returns an `OnDisconnect` object - see
- * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
- * for more information on how to use it.
- *
- * @param ref - The reference to add OnDisconnect triggers for.
- */
- export declare function onDisconnect(ref: DatabaseReference): OnDisconnect;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onValue` event will trigger once with the initial data stored at this
- * location, and then trigger again each time the data changes. The
- * `DataSnapshot` passed to the callback will be for the location at which
- * `on()` was called. It won't trigger until the entire contents has been
- * synchronized. If the location has no data, it will be triggered with an empty
- * `DataSnapshot` (`val()` will return `null`).
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs. The
- * callback will be passed a DataSnapshot.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onValue` event will trigger once with the initial data stored at this
- * location, and then trigger again each time the data changes. The
- * `DataSnapshot` passed to the callback will be for the location at which
- * `on()` was called. It won't trigger until the entire contents has been
- * synchronized. If the location has no data, it will be triggered with an empty
- * `DataSnapshot` (`val()` will return `null`).
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs. The
- * callback will be passed a DataSnapshot.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Listens for data changes at a particular location.
- *
- * This is the primary way to read data from a Database. Your callback
- * will be triggered for the initial data and again whenever the data changes.
- * Invoke the returned unsubscribe callback to stop receiving updates. See
- * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
- * for more details.
- *
- * An `onValue` event will trigger once with the initial data stored at this
- * location, and then trigger again each time the data changes. The
- * `DataSnapshot` passed to the callback will be for the location at which
- * `on()` was called. It won't trigger until the entire contents has been
- * synchronized. If the location has no data, it will be triggered with an empty
- * `DataSnapshot` (`val()` will return `null`).
- *
- * @param query - The query to run.
- * @param callback - A callback that fires when the specified event occurs. The
- * callback will be passed a DataSnapshot.
- * @param cancelCallback - An optional callback that will be notified if your
- * event subscription is ever canceled because your client does not have
- * permission to read this data (or it had permission but has now lost it).
- * This callback will be passed an `Error` object indicating why the failure
- * occurred.
- * @param options - An object that can be used to configure `onlyOnce`, which
- * then removes the listener after its first invocation.
- * @returns A function that can be invoked to remove the listener.
- */
- export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
- /**
- * Creates a new `QueryConstraint` that orders by the specified child key.
- *
- * Queries can only order by one key at a time. Calling `orderByChild()`
- * multiple times on the same query is an error.
- *
- * Firebase queries allow you to order your data by any child key on the fly.
- * However, if you know in advance what your indexes will be, you can define
- * them via the .indexOn rule in your Security Rules for better performance. See
- * the{@link https://firebase.google.com/docs/database/security/indexing-data}
- * rule for more information.
- *
- * You can read more about `orderByChild()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
- *
- * @param path - The path to order by.
- */
- export declare function orderByChild(path: string): QueryConstraint;
- /**
- * Creates a new `QueryConstraint` that orders by the key.
- *
- * Sorts the results of a query by their (ascending) key values.
- *
- * You can read more about `orderByKey()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
- */
- export declare function orderByKey(): QueryConstraint;
- /**
- * Creates a new `QueryConstraint` that orders by priority.
- *
- * Applications need not use priority but can order collections by
- * ordinary properties (see
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}
- * for alternatives to priority.
- */
- export declare function orderByPriority(): QueryConstraint;
- /**
- * Creates a new `QueryConstraint` that orders by value.
- *
- * If the children of a query are all scalar values (string, number, or
- * boolean), you can order the results by their (ascending) values.
- *
- * You can read more about `orderByValue()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
- */
- export declare function orderByValue(): QueryConstraint;
- /**
- * Generates a new child location using a unique key and returns its
- * `Reference`.
- *
- * This is the most common pattern for adding data to a collection of items.
- *
- * If you provide a value to `push()`, the value is written to the
- * generated location. If you don't pass a value, nothing is written to the
- * database and the child remains empty (but you can use the `Reference`
- * elsewhere).
- *
- * The unique keys generated by `push()` are ordered by the current time, so the
- * resulting list of items is chronologically sorted. The keys are also
- * designed to be unguessable (they contain 72 random bits of entropy).
- *
- * See {@link https://firebase.google.com/docs/database/web/lists-of-data#append_to_a_list_of_data | Append to a list of data}.
- * See {@link https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html | The 2^120 Ways to Ensure Unique Identifiers}.
- *
- * @param parent - The parent location.
- * @param value - Optional value to be written at the generated location.
- * @returns Combined `Promise` and `Reference`; resolves when write is complete,
- * but can be used immediately as the `Reference` to the child location.
- */
- export declare function push(parent: DatabaseReference, value?: unknown): ThenableReference;
- /**
- * @license
- * Copyright 2021 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 `Query` sorts and filters the data at a Database location so only a subset
- * of the child data is included. This can be used to order a collection of
- * data by some attribute (for example, height of dinosaurs) as well as to
- * restrict a large list of items (for example, chat messages) down to a number
- * suitable for synchronizing to the client. Queries are created by chaining
- * together one or more of the filter methods defined here.
- *
- * Just as with a `DatabaseReference`, you can receive data from a `Query` by using the
- * `on*()` methods. You will only receive events and `DataSnapshot`s for the
- * subset of the data that matches your query.
- *
- * See {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data}
- * for more information.
- */
- export declare interface Query {
- /** The `DatabaseReference` for the `Query`'s location. */
- readonly ref: DatabaseReference;
- /**
- * Returns whether or not the current and provided queries represent the same
- * location, have the same query parameters, and are from the same instance of
- * `FirebaseApp`.
- *
- * Two `DatabaseReference` objects are equivalent if they represent the same location
- * and are from the same instance of `FirebaseApp`.
- *
- * Two `Query` objects are equivalent if they represent the same location,
- * have the same query parameters, and are from the same instance of
- * `FirebaseApp`. Equivalent queries share the same sort order, limits, and
- * starting and ending points.
- *
- * @param other - The query to compare against.
- * @returns Whether or not the current and provided queries are equivalent.
- */
- isEqual(other: Query | null): boolean;
- /**
- * Returns a JSON-serializable representation of this object.
- *
- * @returns A JSON-serializable representation of this object.
- */
- toJSON(): string;
- /**
- * Gets the absolute URL for this location.
- *
- * The `toString()` method returns a URL that is ready to be put into a
- * browser, curl command, or a `refFromURL()` call. Since all of those expect
- * the URL to be url-encoded, `toString()` returns an encoded URL.
- *
- * Append '.json' to the returned URL when typed into a browser to download
- * JSON-formatted data. If the location is secured (that is, not publicly
- * readable), you will get a permission-denied error.
- *
- * @returns The absolute URL for this location.
- */
- toString(): string;
- }
- /**
- * Creates a new immutable instance of `Query` that is extended to also include
- * additional query constraints.
- *
- * @param query - The Query instance to use as a base for the new constraints.
- * @param queryConstraints - The list of `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(query: Query, ...queryConstraints: QueryConstraint[]): Query;
- /**
- * A `QueryConstraint` is used to narrow the set of documents returned by a
- * Database query. `QueryConstraint`s are created by invoking {@link endAt},
- * {@link endBefore}, {@link startAt}, {@link startAfter}, {@link
- * limitToFirst}, {@link limitToLast}, {@link orderByChild},
- * {@link orderByChild}, {@link orderByKey} , {@link orderByPriority} ,
- * {@link orderByValue} or {@link equalTo} and
- * can then be passed to {@link query} to create a new query instance that
- * also contains this `QueryConstraint`.
- */
- export declare abstract class QueryConstraint {
- /** The type of this query constraints */
- abstract readonly type: QueryConstraintType;
- }
- /** Describes the different query constraints available in this SDK. */
- export declare type QueryConstraintType = 'endAt' | 'endBefore' | 'startAt' | 'startAfter' | 'limitToFirst' | 'limitToLast' | 'orderByChild' | 'orderByKey' | 'orderByPriority' | 'orderByValue' | 'equalTo';
- /* Excluded from this release type: _QueryImpl */
- /* Excluded from this release type: _QueryParams */
- /**
- *
- * Returns a `Reference` representing the location in the Database
- * corresponding to the provided path. If no path is provided, the `Reference`
- * will point to the root of the Database.
- *
- * @param db - The database instance to obtain a reference for.
- * @param path - Optional path representing the location the returned
- * `Reference` will point. If not provided, the returned `Reference` will
- * point to the root of the Database.
- * @returns If a path is provided, a `Reference`
- * pointing to the provided path. Otherwise, a `Reference` pointing to the
- * root of the Database.
- */
- export declare function ref(db: Database, path?: string): DatabaseReference;
- /* Excluded from this release type: _ReferenceImpl */
- /**
- * Returns a `Reference` representing the location in the Database
- * corresponding to the provided Firebase URL.
- *
- * An exception is thrown if the URL is not a valid Firebase Database URL or it
- * has a different domain than the current `Database` instance.
- *
- * Note that all query parameters (`orderBy`, `limitToLast`, etc.) are ignored
- * and are not applied to the returned `Reference`.
- *
- * @param db - The database instance to obtain a reference for.
- * @param url - The Firebase URL at which the returned `Reference` will
- * point.
- * @returns A `Reference` pointing to the provided
- * Firebase URL.
- */
- export declare function refFromURL(db: Database, url: string): DatabaseReference;
- /**
- * Removes the data at this Database location.
- *
- * Any data at child locations will also be deleted.
- *
- * The effect of the remove will be visible immediately and the corresponding
- * event 'value' will be triggered. Synchronization of the remove to the
- * Firebase servers will also be started, and the returned Promise will resolve
- * when complete. If provided, the onComplete callback will be called
- * asynchronously after synchronization has finished.
- *
- * @param ref - The location to remove.
- * @returns Resolves when remove on server is complete.
- */
- export declare function remove(ref: DatabaseReference): Promise<void>;
- /* Excluded from this release type: _repoManagerDatabaseFromApp */
- /**
- * Atomically modifies the data at this location.
- *
- * Atomically modify the data at this location. Unlike a normal `set()`, which
- * just overwrites the data regardless of its previous value, `runTransaction()` is
- * used to modify the existing value to a new value, ensuring there are no
- * conflicts with other clients writing to the same location at the same time.
- *
- * To accomplish this, you pass `runTransaction()` an update function which is
- * used to transform the current value into a new value. If another client
- * writes to the location before your new value is successfully written, your
- * update function will be called again with the new current value, and the
- * write will be retried. This will happen repeatedly until your write succeeds
- * without conflict or you abort the transaction by not returning a value from
- * your update function.
- *
- * Note: Modifying data with `set()` will cancel any pending transactions at
- * that location, so extreme care should be taken if mixing `set()` and
- * `runTransaction()` to update the same data.
- *
- * Note: When using transactions with Security and Firebase Rules in place, be
- * aware that a client needs `.read` access in addition to `.write` access in
- * order to perform a transaction. This is because the client-side nature of
- * transactions requires the client to read the data in order to transactionally
- * update it.
- *
- * @param ref - The location to atomically modify.
- * @param transactionUpdate - A developer-supplied function which will be passed
- * the current data stored at this location (as a JavaScript object). The
- * function should return the new value it would like written (as a JavaScript
- * object). If `undefined` is returned (i.e. you return with no arguments) the
- * transaction will be aborted and the data at this location will not be
- * modified.
- * @param options - An options object to configure transactions.
- * @returns A `Promise` that can optionally be used instead of the `onComplete`
- * callback to handle success and failure.
- */
- export declare function runTransaction(ref: DatabaseReference, transactionUpdate: (currentData: any) => unknown, options?: TransactionOptions): Promise<TransactionResult>;
- /**
- * @license
- * Copyright 2020 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.
- */
- /**
- * Returns a placeholder value for auto-populating the current timestamp (time
- * since the Unix epoch, in milliseconds) as determined by the Firebase
- * servers.
- */
- export declare function serverTimestamp(): object;
- /**
- * Writes data to this Database location.
- *
- * This will overwrite any data at this location and all child locations.
- *
- * The effect of the write will be visible immediately, and the corresponding
- * events ("value", "child_added", etc.) will be triggered. Synchronization of
- * the data to the Firebase servers will also be started, and the returned
- * Promise will resolve when complete. If provided, the `onComplete` callback
- * will be called asynchronously after synchronization has finished.
- *
- * Passing `null` for the new value is equivalent to calling `remove()`; namely,
- * all data at this location and all child locations will be deleted.
- *
- * `set()` will remove any priority stored at this location, so if priority is
- * meant to be preserved, you need to use `setWithPriority()` instead.
- *
- * Note that modifying data with `set()` will cancel any pending transactions
- * at that location, so extreme care should be taken if mixing `set()` and
- * `transaction()` to modify the same data.
- *
- * A single `set()` will generate a single "value" event at the location where
- * the `set()` was performed.
- *
- * @param ref - The location to write to.
- * @param value - The value to be written (string, number, boolean, object,
- * array, or null).
- * @returns Resolves when write to server is complete.
- */
- export declare function set(ref: DatabaseReference, value: unknown): Promise<void>;
- /**
- * Sets a priority for the data at this Database location.
- *
- * Applications need not use priority but can order collections by
- * ordinary properties (see
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
- * ).
- *
- * @param ref - The location to write to.
- * @param priority - The priority to be written (string, number, or null).
- * @returns Resolves when write to server is complete.
- */
- export declare function setPriority(ref: DatabaseReference, priority: string | number | null): Promise<void>;
- /* Excluded from this release type: _setSDKVersion */
- /**
- * Writes data the Database location. Like `set()` but also specifies the
- * priority for that data.
- *
- * Applications need not use priority but can order collections by
- * ordinary properties (see
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
- * ).
- *
- * @param ref - The location to write to.
- * @param value - The value to be written (string, number, boolean, object,
- * array, or null).
- * @param priority - The priority to be written (string, number, or null).
- * @returns Resolves when write to server is complete.
- */
- export declare function setWithPriority(ref: DatabaseReference, value: unknown, priority: string | number | null): Promise<void>;
- /**
- * Creates a `QueryConstraint` with the specified starting point (exclusive).
- *
- * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
- * allows you to choose arbitrary starting and ending points for your queries.
- *
- * The starting point is exclusive. If only a value is provided, children
- * with a value greater than the specified value will be included in the query.
- * If a key is specified, then children must have a value greater than or equal
- * to the specified value and a a key name greater than the specified key.
- *
- * @param value - The value to start after. The argument type depends on which
- * `orderBy*()` function was used in this query. Specify a value that matches
- * the `orderBy*()` type. When used in combination with `orderByKey()`, the
- * value must be a string.
- * @param key - The child key to start after. This argument is only allowed if
- * ordering by child, value, or priority.
- */
- export declare function startAfter(value: number | string | boolean | null, key?: string): QueryConstraint;
- /**
- * Creates a `QueryConstraint` with the specified starting point.
- *
- * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
- * allows you to choose arbitrary starting and ending points for your queries.
- *
- * The starting point is inclusive, so children with exactly the specified value
- * will be included in the query. The optional key argument can be used to
- * further limit the range of the query. If it is specified, then children that
- * have exactly the specified value must also have a key name greater than or
- * equal to the specified key.
- *
- * You can read more about `startAt()` in
- * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
- *
- * @param value - The value to start at. The argument type depends on which
- * `orderBy*()` function was used in this query. Specify a value that matches
- * the `orderBy*()` type. When used in combination with `orderByKey()`, the
- * value must be a string.
- * @param key - The child key to start at. This argument is only allowed if
- * ordering by child, value, or priority.
- */
- export declare function startAt(value?: number | string | boolean | null, key?: string): QueryConstraint;
- /* Excluded from this release type: _TEST_ACCESS_forceRestClient */
- /* Excluded from this release type: _TEST_ACCESS_hijackHash */
- /**
- * A `Promise` that can also act as a `DatabaseReference` when returned by
- * {@link push}. The reference is available immediately and the `Promise` resolves
- * as the write to the backend completes.
- */
- export declare interface ThenableReference extends DatabaseReference, Pick<Promise<DatabaseReference>, 'then' | 'catch'> {
- }
- /** An options object to configure transactions. */
- export declare interface TransactionOptions {
- /**
- * By default, events are raised each time the transaction update function
- * runs. So if it is run multiple times, you may see intermediate states. You
- * can set this to false to suppress these intermediate states and instead
- * wait until the transaction has completed before events are raised.
- */
- readonly applyLocally?: boolean;
- }
- /**
- * A type for the resolve value of {@link runTransaction}.
- */
- export declare class TransactionResult {
- /** Whether the transaction was successfully committed. */
- readonly committed: boolean;
- /** The resulting data snapshot. */
- readonly snapshot: DataSnapshot;
- private constructor();
- /** Returns a JSON-serializable representation of this object. */
- toJSON(): object;
- }
- /** A callback that can invoked to remove a listener. */
- export declare type Unsubscribe = () => void;
- /**
- * Writes multiple values to the Database at once.
- *
- * The `values` argument contains multiple property-value pairs that will be
- * written to the Database together. Each child property can either be a simple
- * property (for example, "name") or a relative path (for example,
- * "name/first") from the current location to the data to update.
- *
- * As opposed to the `set()` method, `update()` can be use to selectively update
- * only the referenced properties at the current location (instead of replacing
- * all the child properties at the current location).
- *
- * The effect of the write will be visible immediately, and the corresponding
- * events ('value', 'child_added', etc.) will be triggered. Synchronization of
- * the data to the Firebase servers will also be started, and the returned
- * Promise will resolve when complete. If provided, the `onComplete` callback
- * will be called asynchronously after synchronization has finished.
- *
- * A single `update()` will generate a single "value" event at the location
- * where the `update()` was performed, regardless of how many children were
- * modified.
- *
- * Note that modifying data with `update()` will cancel any pending
- * transactions at that location, so extreme care should be taken if mixing
- * `update()` and `transaction()` to modify the same data.
- *
- * Passing `null` to `update()` will remove the data at this location.
- *
- * See
- * {@link https://firebase.googleblog.com/2015/09/introducing-multi-location-updates-and_86.html | Introducing multi-location updates and more}.
- *
- * @param ref - The location to write to.
- * @param values - Object containing multiple values.
- * @returns Resolves when update on server is complete.
- */
- export declare function update(ref: DatabaseReference, values: object): Promise<void>;
- export {};
|