UNPKG

8.87 kBTypeScriptView Raw
1/**
2 * Firebase App
3 *
4 * @remarks This package coordinates the communication between the different Firebase components
5 * @packageDocumentation
6 */
7
8import { Component } from '@firebase/component';
9import { ComponentContainer } from '@firebase/component';
10import { FirebaseError } from '@firebase/util';
11import { LogCallback } from '@firebase/logger';
12import { LogLevelString } from '@firebase/logger';
13import { LogOptions } from '@firebase/logger';
14import { Name } from '@firebase/component';
15import { Provider } from '@firebase/component';
16
17/* Excluded from this release type: _addComponent */
18
19/* Excluded from this release type: _addOrOverwriteComponent */
20
21/* Excluded from this release type: _apps */
22
23/* Excluded from this release type: _clearComponents */
24
25/* Excluded from this release type: _components */
26
27/* Excluded from this release type: _DEFAULT_ENTRY_NAME */
28
29/**
30 * Renders this app unusable and frees the resources of all associated
31 * services.
32 *
33 * @example
34 * ```javascript
35 * deleteApp(app)
36 * .then(function() {
37 * console.log("App deleted successfully");
38 * })
39 * .catch(function(error) {
40 * console.log("Error deleting app:", error);
41 * });
42 * ```
43 *
44 * @public
45 */
46export declare function deleteApp(app: FirebaseApp): Promise<void>;
47
48/**
49 * A {@link @firebase/app#FirebaseApp} holds the initialization information for a collection of
50 * services.
51 *
52 * Do not call this constructor directly. Instead, use
53 * {@link (initializeApp:1) | initializeApp()} to create an app.
54 *
55 * @public
56 */
57export declare interface FirebaseApp {
58 /**
59 * The (read-only) name for this app.
60 *
61 * The default app's name is `"[DEFAULT]"`.
62 *
63 * @example
64 * ```javascript
65 * // The default app's name is "[DEFAULT]"
66 * const app = initializeApp(defaultAppConfig);
67 * console.log(app.name); // "[DEFAULT]"
68 * ```
69 *
70 * @example
71 * ```javascript
72 * // A named app's name is what you provide to initializeApp()
73 * const otherApp = initializeApp(otherAppConfig, "other");
74 * console.log(otherApp.name); // "other"
75 * ```
76 */
77 readonly name: string;
78 /**
79 * The (read-only) configuration options for this app. These are the original
80 * parameters given in {@link (initializeApp:1) | initializeApp()}.
81 *
82 * @example
83 * ```javascript
84 * const app = initializeApp(config);
85 * console.log(app.options.databaseURL === config.databaseURL); // true
86 * ```
87 */
88 readonly options: FirebaseOptions;
89 /**
90 * The settable config flag for GDPR opt-in/opt-out
91 */
92 automaticDataCollectionEnabled: boolean;
93}
94
95/* Excluded from this release type: _FirebaseAppInternal */
96
97/**
98 * @public
99 *
100 * Configuration options given to {@link (initializeApp:1) | initializeApp()}
101 */
102export declare interface FirebaseAppSettings {
103 /**
104 * custom name for the Firebase App.
105 * The default value is `"[DEFAULT]"`.
106 */
107 name?: string;
108 /**
109 * The settable config flag for GDPR opt-in/opt-out
110 */
111 automaticDataCollectionEnabled?: boolean;
112}
113export { FirebaseError }
114
115/**
116 * @public
117 *
118 * Firebase configuration object. Contains a set of parameters required by
119 * services in order to successfully communicate with Firebase server APIs
120 * and to associate client data with your Firebase project and
121 * Firebase application. Typically this object is populated by the Firebase
122 * console at project setup. See also:
123 * {@link https://firebase.google.com/docs/web/setup#config-object | Learn about the Firebase config object}.
124 */
125export declare interface FirebaseOptions {
126 /**
127 * An encrypted string used when calling certain APIs that don't need to
128 * access private user data
129 * (example value: `AIzaSyDOCAbC123dEf456GhI789jKl012-MnO`).
130 */
131 apiKey?: string;
132 /**
133 * Auth domain for the project ID.
134 */
135 authDomain?: string;
136 /**
137 * Default Realtime Database URL.
138 */
139 databaseURL?: string;
140 /**
141 * The unique identifier for the project across all of Firebase and
142 * Google Cloud.
143 */
144 projectId?: string;
145 /**
146 * The default Cloud Storage bucket name.
147 */
148 storageBucket?: string;
149 /**
150 * Unique numerical value used to identify each sender that can send
151 * Firebase Cloud Messaging messages to client apps.
152 */
153 messagingSenderId?: string;
154 /**
155 * Unique identifier for the app.
156 */
157 appId?: string;
158 /**
159 * An ID automatically created when you enable Analytics in your
160 * Firebase project and register a web app. In versions 7.20.0
161 * and higher, this parameter is optional.
162 */
163 measurementId?: string;
164}
165
166/* Excluded from this release type: _FirebaseService */
167
168/**
169 * Retrieves a {@link @firebase/app#FirebaseApp} instance.
170 *
171 * When called with no arguments, the default app is returned. When an app name
172 * is provided, the app corresponding to that name is returned.
173 *
174 * An exception is thrown if the app being retrieved has not yet been
175 * initialized.
176 *
177 * @example
178 * ```javascript
179 * // Return the default app
180 * const app = getApp();
181 * ```
182 *
183 * @example
184 * ```javascript
185 * // Return a named app
186 * const otherApp = getApp("otherApp");
187 * ```
188 *
189 * @param name - Optional name of the app to return. If no name is
190 * provided, the default is `"[DEFAULT]"`.
191 *
192 * @returns The app corresponding to the provided app name.
193 * If no app name is provided, the default app is returned.
194 *
195 * @public
196 */
197export declare function getApp(name?: string): FirebaseApp;
198
199/**
200 * A (read-only) array of all initialized apps.
201 * @public
202 */
203export declare function getApps(): FirebaseApp[];
204
205/* Excluded from this release type: _getProvider */
206
207/**
208 * Creates and initializes a {@link @firebase/app#FirebaseApp} instance.
209 *
210 * See
211 * {@link
212 * https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
213 * | Add Firebase to your app} and
214 * {@link
215 * https://firebase.google.com/docs/web/setup#multiple-projects
216 * | Initialize multiple projects} for detailed documentation.
217 *
218 * @example
219 * ```javascript
220 *
221 * // Initialize default app
222 * // Retrieve your own options values by adding a web app on
223 * // https://console.firebase.google.com
224 * initializeApp({
225 * apiKey: "AIza....", // Auth / General Use
226 * authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
227 * databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
228 * storageBucket: "YOUR_APP.appspot.com", // Storage
229 * messagingSenderId: "123456789" // Cloud Messaging
230 * });
231 * ```
232 *
233 * @example
234 * ```javascript
235 *
236 * // Initialize another app
237 * const otherApp = initializeApp({
238 * databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
239 * storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
240 * }, "otherApp");
241 * ```
242 *
243 * @param options - Options to configure the app's services.
244 * @param name - Optional name of the app to initialize. If no name
245 * is provided, the default is `"[DEFAULT]"`.
246 *
247 * @returns The initialized app.
248 *
249 * @public
250 */
251export declare function initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
252
253/**
254 * Creates and initializes a FirebaseApp instance.
255 *
256 * @param options - Options to configure the app's services.
257 * @param config - FirebaseApp Configuration
258 *
259 * @public
260 */
261export declare function initializeApp(options: FirebaseOptions, config?: FirebaseAppSettings): FirebaseApp;
262
263/**
264 * Creates and initializes a FirebaseApp instance.
265 *
266 * @public
267 */
268export declare function initializeApp(): FirebaseApp;
269
270/**
271 * Sets log handler for all Firebase SDKs.
272 * @param logCallback - An optional custom log handler that executes user code whenever
273 * the Firebase SDK makes a logging call.
274 *
275 * @public
276 */
277export declare function onLog(logCallback: LogCallback | null, options?: LogOptions): void;
278
279/* Excluded from this release type: _registerComponent */
280
281/**
282 * Registers a library's name and version for platform logging purposes.
283 * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
284 * @param version - Current version of that library.
285 * @param variant - Bundle variant, e.g., node, rn, etc.
286 *
287 * @public
288 */
289export declare function registerVersion(libraryKeyOrName: string, version: string, variant?: string): void;
290
291/* Excluded from this release type: _removeServiceInstance */
292
293/**
294 * The current SDK version.
295 *
296 * @public
297 */
298export declare const SDK_VERSION: string;
299
300/**
301 * Sets log level for all Firebase SDKs.
302 *
303 * All of the log types above the current log level are captured (i.e. if
304 * you set the log level to `info`, errors are logged, but `debug` and
305 * `verbose` logs are not).
306 *
307 * @public
308 */
309export declare function setLogLevel(logLevel: LogLevelString): void;
310
311export { }