UNPKG

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