UNPKG

3.42 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 { LogCallback, LogLevelString, LogOptions } from '@firebase/logger';
18
19export type FirebaseOptions = {
20 apiKey?: string;
21 authDomain?: string;
22 databaseURL?: string;
23 projectId?: string;
24 storageBucket?: string;
25 messagingSenderId?: string;
26 appId?: string;
27 measurementId?: string;
28};
29
30export interface FirebaseAppConfig {
31 name?: string;
32 automaticDataCollectionEnabled?: boolean;
33}
34
35export class FirebaseApp {
36 /**
37 * The (read-only) name (identifier) for this App. '[DEFAULT]' is the default
38 * App.
39 */
40 name: string;
41
42 /**
43 * The (read-only) configuration options from the app initialization.
44 */
45 options: FirebaseOptions;
46
47 /**
48 * The settable config flag for GDPR opt-in/opt-out
49 */
50 automaticDataCollectionEnabled: boolean;
51
52 /**
53 * Make the given App unusable and free resources.
54 */
55 delete(): Promise<void>;
56}
57
58export interface FirebaseNamespace {
59 /**
60 * Create (and initialize) a FirebaseApp.
61 *
62 * @param options Options to configure the services used in the App.
63 * @param config The optional config for your firebase app
64 */
65 initializeApp(
66 options: FirebaseOptions,
67 config?: FirebaseAppConfig
68 ): FirebaseApp;
69 /**
70 * Create (and initialize) a FirebaseApp.
71 *
72 * @param options Options to configure the services used in the App.
73 * @param name The optional name of the app to initialize ('[DEFAULT]' if
74 * omitted)
75 */
76 initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
77
78 app: {
79 /**
80 * Retrieve an instance of a FirebaseApp.
81 *
82 * Usage: firebase.app()
83 *
84 * @param name The optional name of the app to return ('[DEFAULT]' if omitted)
85 */
86 (name?: string): FirebaseApp;
87
88 /**
89 * For testing FirebaseApp instances:
90 * app() instanceof firebase.app.App
91 *
92 * DO NOT call this constuctor directly (use firebase.app() instead).
93 */
94 App: typeof FirebaseApp;
95 };
96
97 /**
98 * A (read-only) array of all the initialized Apps.
99 */
100 apps: FirebaseApp[];
101
102 /**
103 * Registers a library's name and version for platform logging purposes.
104 * @param library Name of 1p or 3p library (e.g. firestore, angularfire)
105 * @param version Current version of that library.
106 */
107 registerVersion(library: string, version: string, variant?: string): void;
108
109 // Sets log level for all Firebase components.
110 setLogLevel(logLevel: LogLevelString): void;
111
112 // Sets log handler for all Firebase components.
113 onLog(logCallback: LogCallback, options?: LogOptions): void;
114
115 // The current SDK version.
116 SDK_VERSION: string;
117}
118
119export interface VersionService {
120 library: string;
121 version: string;
122}
123
124declare module '@firebase/component' {
125 interface NameServiceMapping {
126 'app-version': VersionService;
127 'platform-identifier': VersionService;
128 }
129}