-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtypes.js
126 lines (109 loc) · 3.83 KB
/
types.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
// @flow
export type EventType = 'value' | 'child_added' | 'child_removed' | 'child_changed' | 'child_moved';
export type Priority = number | string | null;
export interface DataSnapshot {
child(path: string) : DataSnapshot;
exists() : Promise<boolean>;
exportVal() : Promise<any>;
forEach(cb:(snapshot:DataSnapshot) => Promise<?boolean>) : Promise<void>;
getPriority() : Promise<Priority>;
hasChild(path:string) : Promise<boolean>;
hasChildren() : Promise<boolean>;
numChildren() : Promise<number>;
val() : Promise<any>;
}
export interface Query {
endAt(value:number|string|boolean|null, key:?string) : Query;
equalTo(value:number|string|boolean|null, key:?string) : Query;
limitToFirst(limit:number) : Query;
limitToLast(limit:number) : Query;
on(eventType:EventType, cb:((snapshot:DataSnapshot) => Promise<void>)) : () => void;
once(eventType:EventType, cb:((snapshot:DataSnapshot) => Promise<void>)) : () => void;
orderByChild(path:string) : Query;
orderByKey() : Query;
orderByPriority() : Query;
orderByValue() : Query;
startAt(value:number|string|boolean|null, key:?string) : Query;
toString() : Promise<string>;
}
export type DatabaseReference = Query & {
key(): Promise<string>;
child(pathString:string) : DatabaseReference;
push() : DatabaseReference;
setValue(value:any) : Promise<void>;
setValueWithPriority(value:any, priority:Priority) : Promise<void>;
remove() : Promise<void>;
setPriority(priority:Priority) : Promise<void>;
}
export type User = {
uid: string;
email: ?string;
emailVerified: boolean;
providerId: string;
displayName: ?string;
photoUrl: ?string;
isAnonymous: boolean;
}
// Description of reference received via native bridge calls
export type DatabaseReferenceDescriptor = {
locationUrl?: ?string;
key?: string;
}
// Description of snapshot received via native bridge calls
export type DataSnapshotDescriptor = {
ref: DatabaseReferenceDescriptor;
childrenCount: number;
exists: boolean;
hasChildren: boolean;
uuid: string;
priority: number;
};
export type AuthCredential = {
id: string;
provider: string;
};
export type FacebookAuthProvider = {
credential(token:string) : Promise<AuthCredential>;
};
export type TwitterAuthProvider = {
credential(token:string, secret:string) : Promise<AuthCredential>;
};
export type GoogleAuthProvider = {
credential(idToken:string, accessToken:string) : Promise<AuthCredential>;
};
export type GithubAuthProvider = {
credential(token:string) : Promise<AuthCredential>;
};
export type AuthModule = {
app: App;
currentUser:?User;
createUserWithEmail(email:string, password:string) : Promise<User>;
signInWithEmail(email:string, password:string) : Promise<User>;
signInAnonymously() : Promise<User>;
signInWithCredential(credential:AuthCredential|Promise<AuthCredential>) : Promise<User>;
FacebookAuthProvider: FacebookAuthProvider;
GithubAuthProvider: GithubAuthProvider;
TwitterAuthProvider: TwitterAuthProvider;
GoogleAuthProvider: GoogleAuthProvider;
getCurrentUser() : Promise<User>;
};
interface Auth {
app: App;
createUserWithEmailAndPassword(email:string, password:string) : Promise<User>;
currentUser:?User;
fetchProvidersForEmail(email:string) : Promise<Array<string>>;
sendPasswordResetEmail(email:string) : Promise<void>;
signInAnonymously() : Promise<User>;
signInWithEmail(email:string, password:string) : Promise<User>;
signInWithCredential(credential:AuthCredential|Promise<AuthCredential>) : Promise<User>;
signInWithCustomToken(token:string) : Promise<User>;
signOut() : Promise<void>;
}
export interface App {
name: string;
options: {};
auth(): Auth;
database(): Database;
delete(): Promise<void>;
//storage(): Storage;
}