UNPKG

2.85 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2017 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { FirebaseApp } from '@firebase/app-types';
18import { FirebaseService } from '@firebase/app-types/private';
19import { Compat, EmulatorMockTokenOptions } from '@firebase/util';
20import { Reference } from './Reference';
21/**
22 * This is a workaround for an issue in the no-modular '@firebase/database' where its typings
23 * reference types from `@firebase/app-exp`.
24 */
25declare type ExpDatabase = any;
26/**
27 * Class representing a firebase database.
28 */
29export declare class Database implements FirebaseService, Compat<ExpDatabase> {
30 readonly _delegate: ExpDatabase;
31 readonly app: FirebaseApp;
32 static readonly ServerValue: {
33 TIMESTAMP: object;
34 increment: (delta: number) => object;
35 };
36 /**
37 * The constructor should not be called by users of our public API.
38 */
39 constructor(_delegate: ExpDatabase, app: FirebaseApp);
40 INTERNAL: {
41 delete: () => any;
42 };
43 /**
44 * Modify this instance to communicate with the Realtime Database emulator.
45 *
46 * <p>Note: This method must be called before performing any other operation.
47 *
48 * @param host - the emulator host (ex: localhost)
49 * @param port - the emulator port (ex: 8080)
50 * @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
51 */
52 useEmulator(host: string, port: number, options?: {
53 mockUserToken?: EmulatorMockTokenOptions;
54 }): void;
55 /**
56 * Returns a reference to the root or to the path specified in the provided
57 * argument.
58 *
59 * @param path - The relative string path or an existing Reference to a database
60 * location.
61 * @throws If a Reference is provided, throws if it does not belong to the
62 * same project.
63 * @returns Firebase reference.
64 */
65 ref(path?: string): Reference;
66 ref(path?: Reference): Reference;
67 /**
68 * Returns a reference to the root or the path specified in url.
69 * We throw a exception if the url is not in the same domain as the
70 * current repo.
71 * @returns Firebase reference.
72 */
73 refFromURL(url: string): Reference;
74 goOffline(): void;
75 goOnline(): void;
76}
77export {};