forked from firebase/firebase-bower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase-app-externs.js
286 lines (261 loc) · 7.95 KB
/
firebase-app-externs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/**
* @license Copyright 2017 Google Inc.
*
* 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.
*/
/**
* @fileoverview Firebase namespace and Firebase App API.
* @externs
*/
/**
* <code>firebase</code> is a global namespace from which all the Firebase
* services are accessed.
*
* @namespace
*/
var firebase = {};
/**
* Creates and initializes a Firebase {@link firebase.app.App app} instance.
*
* See
* {@link
* https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
* Add Firebase to your app} and
* {@link
* https://firebase.google.com/docs/web/setup#initialize_multiple_apps
* Initialize multiple apps} for detailed documentation.
*
* @example
* // Initialize default app
* // Retrieve your own options values by adding a web app on
* // https://console.firebase.google.com
* firebase.initializeApp({
* apiKey: "AIza....", // Auth / General Use
* authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
* databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
* storageBucket: "YOUR_APP.appspot.com", // Storage
* messagingSenderId: "123456789" // Cloud Messaging
* });
*
* @example
* // Initialize another app
* var otherApp = firebase.initializeApp({
* databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
* storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
* }, "otherApp");
*
* @param {!Object} options Options to configure the app's services.
* @param {string=} name Optional name of the app to initialize. If no name
* is provided, the default is `"[DEFAULT]"`.
*
* @return {!firebase.app.App} The initialized app.
*/
firebase.initializeApp = function(options, name) {};
/**
* Retrieves a Firebase {@link firebase.app.App app} instance.
*
* When called with no arguments, the default app is returned. When an app name
* is provided, the app corresponding to that name is returned.
*
* An exception is thrown if the app being retrieved has not yet been
* initialized.
*
* @example
* // Return the default app
* var app = firebase.app();
*
* @example
* // Return a named app
* var otherApp = firebase.app("otherApp");
*
* @namespace
* @param {string=} name Optional name of the app to return. If no name is
* provided, the default is `"[DEFAULT]"`.
*
* @return {!firebase.app.App} The app corresponding to the provided app name.
* If no app name is provided, the default app is returned.
*/
firebase.app = function(name) {};
/**
* A (read-only) array of all initialized apps.
* @type {!Array<firebase.app.App>}
*/
firebase.apps;
/**
* The current SDK version.
* @type {string}
*/
firebase.SDK_VERSION;
/**
* A Firebase App holds the initialization information for a collection of
* services.
*
* Do not call this constructor directly. Instead, use
* {@link firebase#.initializeApp `firebase.initializeApp()`} to create an app.
*
* @interface
*/
firebase.app.App = function() {};
/**
* The (read-only) name for this app.
*
* The default app's name is `"[DEFAULT]"`.
*
* @example
* // The default app's name is "[DEFAULT]"
* firebase.initializeApp(defaultAppConfig);
* console.log(firebase.app().name); // "[DEFAULT]"
*
* @example
* // A named app's name is what you provide to initializeApp()
* var otherApp = firebase.initializeApp(otherAppConfig, "other");
* console.log(otherApp.name); // "other"
*
* @type {string}
*/
firebase.app.App.prototype.name;
/**
* The (read-only) configuration options for this app. These are the original
* parameters given in
* {@link firebase#.initializeApp `firebase.initializeApp()`}.
*
* @example
* var app = firebase.initializeApp(config);
* console.log(app.options.databaseURL === config.databaseURL); // true
*
* @type {!Object}
*/
firebase.app.App.prototype.options;
/**
* Renders this app unusable and frees the resources of all associated
* services.
*
* @example
* app.delete()
* .then(function() {
* console.log("App deleted successfully");
* })
* .catch(function(error) {
* console.log("Error deleting app:", error);
* });
*
* @return {!firebase.Promise<void>} An empty promise fulfilled when the app has
* been deleted.
*/
firebase.app.App.prototype.delete = function() {};
/**
* A Thenable is the standard interface returned by a Promise.
*
* @template T
* @interface
*/
firebase.Thenable = function() {};
/**
* Assign callback functions called when the Thenable value either
* resolves, or is rejected.
*
* @param {(function(T): *)=} onResolve Called when the Thenable resolves.
* @param {(function(!Error): *)=} onReject Called when the Thenable is rejected
* (with an error).
* @return {!firebase.Thenable<*>}
*/
firebase.Thenable.prototype.then = function(onResolve, onReject) {};
/**
* Assign a callback when the Thenable rejects.
*
* @param {(function(!Error): *)=} onReject Called when the Thenable is rejected
* (with an error).
* @return {!firebase.Thenable<*>}
*/
firebase.Thenable.prototype.catch = function(onReject) {};
/**
* A Promise represents an eventual (asynchronous) value. A Promise should
* (eventually) either resolve or reject. When it does, it will call all the
* callback functions that have been assigned via the <code>.then()</code> or
* <code>.catch()</code> methods.
*
* <code>firebase.Promise</code> is the same as the native Promise
* implementation when available in the current environment, otherwise it is a
* compatible implementation of the Promise/A+ spec.
*
* @template T
* @constructor
* @implements {firebase.Thenable}
* @param {function((function(T): void),
* (function(!Error): void))} resolver
*/
firebase.Promise = function(resolver) {};
/**
* Assign callback functions called when the Promise either resolves, or is
* rejected.
*
* @param {(function(T): *)=} onResolve Called when the Promise resolves.
* @param {(function(!Error): *)=} onReject Called when the Promise is rejected
* (with an error).
* @return {!firebase.Promise<*>}
* @override
*/
firebase.Promise.prototype.then = function(onResolve, onReject) {};
/**
* Assign a callback when the Promise rejects.
*
* @param {(function(!Error): *)=} onReject Called when the Promise is rejected
* (with an error).
* @override
*/
firebase.Promise.prototype.catch = function(onReject) {};
/**
* Return a resolved Promise.
*
* @template T
* @param {T=} value The value to be returned by the Promise.
* @return {!firebase.Promise<T>}
*/
firebase.Promise.resolve = function(value) {};
/**
* Return (an immediately) rejected Promise.
*
* @param {!Error} error The reason for the Promise being rejected.
* @return {!firebase.Promise<*>}
*/
firebase.Promise.reject = function(error) {};
/**
* Convert an array of Promises, to a single array of values.
* <code>Promise.all()</code> resolves only after all the Promises in the array
* have resolved.
*
* <code>Promise.all()</code> rejects when any of the promises in the Array have
* rejected.
*
* @param {!Array<!firebase.Promise<*>>} values
* @return {!firebase.Promise<!Array<*>>}
*/
firebase.Promise.all = function(values) {};
/**
* @template V, E
* @interface
**/
firebase.Observer = function() {};
/**
* @param {?V} value
*/
firebase.Observer.prototype.next = function(value) {};
/**
* @param {!E} error
*/
firebase.Observer.prototype.error = function(error) {};
firebase.Observer.prototype.complete = function() {};
/** @typedef {function(): void} */
firebase.CompleteFn;
/** @typedef {function(): void} */
firebase.Unsubscribe;