-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebase.d.ts
419 lines (410 loc) · 14.9 KB
/
firebase.d.ts
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
/*
SOURCE: https://github.com/angular/angularfire2/blob/master/manual_typings/firebase3/firebase3.d.ts
*/
/*
1. Delete goog namespaces
2. Delete look of disaproval
3. typealias firebase.Promise to Promise
4. Union type FirebaseOAuthProvider
5. Remove _noStructuralTyping from Promise classes
6. Remove catch() and then() declarations from firebase.Thenable, and extend Promise<t>.
*/
declare interface Promise<T> {}
declare interface FirebaseService {
INTERNAL: Object;
app: firebase.app.App;
}
declare interface FirebaseServiceNamespace {
app(app?: firebase.app.App): FirebaseService;
}
declare interface Observer {
complete(): any;
error(error: Object): any;
next(value: any): any;
}
declare type FirebaseOAuthProvider = firebase.auth.GithubAuthProvider |
firebase.auth.GoogleAuthProvider |
firebase.auth.FacebookAuthProvider;
declare class Promise_Instance<TYPE> implements PromiseLike<TYPE> {
constructor(resolver: (a: (a?: TYPE | PromiseLike<TYPE> | { then: any }) => any, b: (a?: any) => any) => any);
catch<RESULT>(onRejected: (a: any) => RESULT): Promise<RESULT>;
then<VALUE, RESULT>(opt_onFulfilled?: (a: TYPE) => VALUE, opt_onRejected?: (a: any) => any): RESULT;
}
declare namespace firebase {
type AuthTokenData = { accessToken: string, expirationTime: number, refreshToken: string };
}
declare namespace firebase {
type AuthTokenListener = (a: string) => void;
}
declare namespace firebase {
type CompleteFn = () => void;
}
declare namespace firebase {
type ErrorFn = (a: Object) => void;
}
declare namespace firebase {
interface FirebaseError {
code: string;
message: string;
name: string;
stack: string;
}
}
declare namespace firebase {
type NextFn = (a: any) => void;
}
declare namespace firebase {
class Promise<T> extends Promise_Instance<T> {
static all(values: firebase.Promise<any>[]): firebase.Promise<any[]>;
static reject(error: Object): firebase.Promise<any>;
static resolve<T>(value: T): firebase.Promise<T>;
}
class Promise_Instance<T> implements firebase.Thenable<any> {
constructor(resolver: (a?: (a: T) => void, b?: (a: Object) => void) => any);
catch(onReject?: (a: Object) => any): firebase.Thenable<any>;
then(onResolve?: (a: T) => any, onReject?: (a: Object) => any): firebase.Promise<any>;
}
}
declare namespace firebase {
var SDK_VERSION: string;
}
declare namespace firebase {
type Subscribe = (a?: ((a: any) => void) | Observer, b?: (a: Object) => void, c?: () => void) => () => void;
}
declare namespace firebase {
interface Thenable<T> extends Promise<T> {
//Removed definitions of catch() and then(), and extended Promise.
}
}
declare namespace firebase {
type Unsubscribe = () => void;
}
declare namespace firebase {
interface User extends firebase.UserInfo {
delete(): firebase.Promise<void>;
emailVerified: boolean;
getToken(opt_forceRefresh?: boolean): firebase.Promise<string>;
isAnonymous: boolean;
link(credential: firebase.auth.AuthCredential): firebase.Promise<firebase.User>;
linkWithPopup(provider: firebase.auth.AuthProvider): firebase.Promise<{ credential: firebase.auth.AuthCredential, user: firebase.User }>;
linkWithRedirect(provider: firebase.auth.AuthProvider): firebase.Promise<void>;
providerData: (firebase.UserInfo)[];
reauthenticate(credential: firebase.auth.AuthCredential): firebase.Promise<void>;
refreshToken: string;
reload(): firebase.Promise<void>;
sendEmailVerification(): firebase.Promise<void>;
unlink(providerId: string): firebase.Promise<firebase.User>;
updateEmail(newEmail: string): firebase.Promise<void>;
updatePassword(newPassword: string): firebase.Promise<void>;
updateProfile(profile: { displayName: string, photoURL: string }): firebase.Promise<void>;
}
}
declare namespace firebase {
interface UserInfo {
displayName: string;
email: string;
photoURL: string;
providerId: string;
uid: string;
}
}
declare namespace firebase {
function app(name: string): firebase.app.App;
}
declare namespace firebase.app {
interface App {
INTERNAL: Object;
auth(): firebase.auth.Auth;
database(): firebase.database.Database;
delete(): firebase.Promise<any>;
name: string;
options: Object;
storage(): firebase.storage.Storage;
}
}
declare namespace firebase {
var apps: (firebase.app.App)[];
}
declare namespace firebase {
function auth(app?: firebase.app.App): firebase.auth.Auth;
}
declare namespace firebase.auth {
interface ActionCodeInfo {
}
}
declare namespace firebase.auth {
interface Auth {
app: firebase.app.App;
applyActionCode(code: string): firebase.Promise<void>;
checkActionCode(code: string): firebase.Promise<firebase.auth.ActionCodeInfo>;
confirmPasswordReset(code: string, newPassword: string): firebase.Promise<void>;
createUserWithEmailAndPassword(email: string, password: string): firebase.Promise<firebase.User>;
currentUser: firebase.User;
fetchProvidersForEmail(email: string): firebase.Promise<string[]>;
getRedirectResult(): firebase.Promise<{ credential: firebase.auth.AuthCredential, user: firebase.User }>;
onAuthStateChanged(nextOrObserver: Object, opt_error?: (a: firebase.auth.Error) => any, opt_completed?: () => any): () => any;
sendPasswordResetEmail(email: string): firebase.Promise<void>;
signInAnonymously(): firebase.Promise<firebase.User>;
signInWithCredential(credential: firebase.auth.AuthCredential): firebase.Promise<firebase.User>;
signInWithCustomToken(token: string): firebase.Promise<firebase.User>;
signInWithEmailAndPassword(email: string, password: string): firebase.Promise<firebase.User>;
signInWithPopup(provider: firebase.auth.AuthProvider): firebase.Promise<{ credential: firebase.auth.AuthCredential, user: firebase.User }>;
signInWithRedirect(provider: firebase.auth.AuthProvider): firebase.Promise<void>;
signOut(): firebase.Promise<void>;
verifyPasswordResetCode(code: string): firebase.Promise<string>;
}
}
declare namespace firebase.auth {
interface AuthCredential {
provider: string;
}
}
declare namespace firebase.auth {
interface AuthProvider {
providerId: string;
}
}
declare namespace firebase.auth {
class EmailAuthProvider extends EmailAuthProvider_Instance {
static PROVIDER_ID: string;
}
class EmailAuthProvider_Instance implements firebase.auth.AuthProvider {
private noStructuralTyping_: any;
credential(email: string, password: string): firebase.auth.AuthCredential;
providerId: string;
}
}
declare namespace firebase.auth {
interface Error {
code: string;
message: string;
}
}
declare namespace firebase.auth {
class FacebookAuthProvider extends FacebookAuthProvider_Instance {
static PROVIDER_ID: string;
}
class FacebookAuthProvider_Instance implements firebase.auth.AuthProvider {
private noStructuralTyping_: any;
addScope(scope: string): any;
credential(token: string): firebase.auth.AuthCredential;
providerId: string;
}
}
declare namespace firebase.auth {
class GithubAuthProvider extends GithubAuthProvider_Instance {
static PROVIDER_ID: string;
// TODO fix upstream
static credential(token: string): firebase.auth.AuthCredential;
}
class GithubAuthProvider_Instance implements firebase.auth.AuthProvider {
private noStructuralTyping_: any;
addScope(scope: string): any;
providerId: string;
}
}
declare namespace firebase.auth {
class GoogleAuthProvider extends GoogleAuthProvider_Instance {
static PROVIDER_ID: string;
}
class GoogleAuthProvider_Instance implements firebase.auth.AuthProvider {
private noStructuralTyping_: any;
addScope(scope: string): any;
credential(idToken?: string, accessToken?: string): firebase.auth.AuthCredential;
providerId: string;
}
}
declare namespace firebase.auth {
class TwitterAuthProvider extends TwitterAuthProvider_Instance {
static PROVIDER_ID: string;
// TODO fix this upstream
static credential(token: string, secret: string): firebase.auth.AuthCredential;
}
class TwitterAuthProvider_Instance implements firebase.auth.AuthProvider {
private noStructuralTyping_: any;
providerId: string;
}
}
declare namespace firebase.auth {
type UserCredential = { credential: firebase.auth.AuthCredential, user: firebase.User };
}
declare namespace firebase {
function database(app?: firebase.app.App): firebase.database.Database;
}
declare namespace firebase.database {
interface DataSnapshot {
child(path: string): firebase.database.DataSnapshot;
exists(): boolean;
exportVal(): any;
forEach(action: (a: firebase.database.DataSnapshot) => boolean): boolean;
getPriority(): string | number;
hasChild(path: string): boolean;
hasChildren(): boolean;
key: string;
numChildren(): number;
ref: firebase.database.Reference;
val(): any;
}
}
declare namespace firebase.database {
interface Database {
app: firebase.app.App;
goOffline(): any;
goOnline(): any;
ref(path?: string): firebase.database.Reference;
refFromURL(url: string): firebase.database.Reference;
}
}
declare namespace firebase.database {
interface OnDisconnect {
cancel(onComplete?: (a: Object) => any): firebase.Promise<void>;
remove(onComplete?: (a: Object) => any): firebase.Promise<void>;
set(value: any, onComplete?: (a: Object) => any): firebase.Promise<void>;
setWithPriority(value: any, priority: number | string, onComplete?: (a: Object) => any): firebase.Promise<void>;
update(values: Object, onComplete?: (a: Object) => any): firebase.Promise<void>;
}
}
declare namespace firebase.database {
interface Query {
endAt(value: number | string | boolean, key?: string): firebase.database.Query;
equalTo(value: number | string | boolean, key?: string): firebase.database.Query;
limitToFirst(limit: number): firebase.database.Query;
limitToLast(limit: number): firebase.database.Query;
off(eventType?: string, callback?: (a: firebase.database.DataSnapshot, b?: string) => any, context?: Object): any;
on(eventType: string, callback: (a: firebase.database.DataSnapshot, b?: string) => any, cancelCallbackOrContext?: Object, context?: Object): (a: firebase.database.DataSnapshot, b?: string) => any;
once(eventType: string, callback?: (a: firebase.database.DataSnapshot, b?: string) => any, cancelCallbackOrContext?: Object, context?: Object): firebase.Promise<any>;
orderByChild(path: string): firebase.database.Query;
orderByKey(): firebase.database.Query;
orderByPriority(): firebase.database.Query;
orderByValue(): firebase.database.Query;
ref: firebase.database.Reference;
startAt(value: number | string | boolean, key?: string): firebase.database.Query;
toString(): string;
}
}
declare namespace firebase.database {
interface Reference extends firebase.database.Query {
child(path: string): firebase.database.Reference;
key: string;
onDisconnect(): firebase.database.OnDisconnect;
parent: firebase.database.Reference;
push(value?: any, onComplete?: (a: Object) => any): firebase.database.ThenableReference;
remove(onComplete?: (a: Object) => any): firebase.Promise<void>;
root: firebase.database.Reference;
set(value: any, onComplete?: (a: Object) => any): firebase.Promise<void>;
setPriority(priority: string | number, onComplete: (a: Object) => any): firebase.Promise<void>;
setWithPriority(newVal: any, newPriority: string | number, onComplete?: (a: Object) => any): firebase.Promise<void>;
transaction(transactionUpdate: (a: any) => any, onComplete?: (a: Object, b: boolean, c: firebase.database.DataSnapshot) => any, applyLocally?: boolean): firebase.Promise<{ committed: boolean, snapshot: firebase.database.DataSnapshot }>;
update(values: Object, onComplete?: (a: Object) => any): firebase.Promise<void>;
}
}
declare namespace firebase.database.ServerValue {
}
declare namespace firebase.database {
interface ThenableReference extends firebase.database.Reference, firebase.Thenable<void> {
}
}
declare namespace firebase.database {
function enableLogging(logger?: any, persistent?: boolean): any;
}
declare namespace firebase {
function initializeApp(options: Object, name?: string): firebase.app.App;
}
declare namespace firebase {
function storage(app?: firebase.app.App): firebase.storage.Storage;
}
declare namespace firebase.storage {
interface FullMetadata extends firebase.storage.UploadMetadata {
bucket: string;
downloadURLs: string[];
fullPath: string;
generation: string;
metageneration: string;
name: string;
size: number;
timeCreated: string;
updated: string;
}
}
declare namespace firebase.storage {
interface Reference {
bucket: string;
child(path: string): firebase.storage.Reference;
delete(): Promise<void>;
fullPath: string;
getDownloadURL(): Promise<string>;
getMetadata(): Promise<firebase.storage.FullMetadata>;
name: string;
parent: firebase.storage.Reference;
put(blob: Blob, metadata?: firebase.storage.UploadMetadata): firebase.storage.UploadTask;
root: firebase.storage.Reference;
storage: firebase.storage.Storage;
toString(): string;
updateMetadata(metadata: firebase.storage.SettableMetadata): Promise<firebase.storage.FullMetadata>;
}
}
declare namespace firebase.storage {
interface SettableMetadata {
cacheControl: string;
contentDisposition: string;
contentEncoding: string;
contentLanguage: string;
contentType: string;
customMetadata: { [key: string]: string };
}
}
declare namespace firebase.storage {
interface Storage {
app: firebase.app.App;
maxOperationRetryTime: number;
maxUploadRetryTime: number;
ref(path?: string): firebase.storage.Reference;
refFromURL(url: string): firebase.storage.Reference;
setMaxOperationRetryTime(time: number): any;
setMaxUploadRetryTime(time: number): any;
}
}
declare namespace firebase.storage {
type TaskEvent = string;
var TaskEvent: {
STATE_CHANGED: TaskEvent,
};
}
declare namespace firebase.storage {
type TaskState = string;
var TaskState: {
CANCELED: TaskState,
ERROR: TaskState,
PAUSED: TaskState,
RUNNING: TaskState,
SUCCESS: TaskState,
};
}
declare namespace firebase.storage {
interface UploadMetadata extends firebase.storage.SettableMetadata {
md5Hash: string;
}
}
declare namespace firebase.storage {
interface UploadTask {
cancel(): boolean;
on(event: firebase.storage.TaskEvent, nextOrObserver?: Object, error?: (a: Object) => any, complete?: () => any): (...a: any[]) => any;
pause(): boolean;
resume(): boolean;
snapshot: firebase.storage.UploadTaskSnapshot;
}
}
declare namespace firebase.storage {
interface UploadTaskSnapshot {
bytesTransferred: number;
downloadURL: string;
metadata: firebase.storage.FullMetadata;
ref: firebase.storage.Reference;
state: firebase.storage.TaskState;
task: firebase.storage.UploadTask;
totalBytes: number;
}
}
declare module 'firebase' {
export = firebase;
}