forked from EddyVerbruggen/nativescript-plugin-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase.d.ts
115 lines (103 loc) · 3.07 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
/// <reference path="firebase-common.d.ts"/>
declare module "nativescript-plugin-firebase" {
/**
* The options object passed into the init function.
*/
export interface InitOptions {
/**
* The endpoint of your firebase instance.
*/
url: string;
}
/**
* The options object passed into the query function.
*/
export interface QueryOptions {
/**
* How you'd like to sort the query result.
*/
orderBy: {
type: QueryOrderByType;
/**
* mandatory when type is QueryOrderByType.CHILD
*/
value?: string;
};
/**
* You can further restrict the returned results by specifying restrictions.
*/
range?: {
type: QueryRangeType;
value: string;
}
/**
* You can limit the number of returned rows if you want to.
*/
limit?: {
type: QueryLimitType;
value: number;
};
/**
* Set this to true if you don't want to listen for any future updates,
* but just want to retrieve the current value.
* You can also use this to check if certain data is in the database.
* Default false.
*/
singleEvent?: boolean;
}
/**
* The options object passed into the login function.
*/
export interface LoginOptions {
type: LoginType;
email?: string;
password?: string;
}
/**
* The returned object from the login function.
*/
export interface LoginResult {
uid: string;
provider: LoginType;
expiresAtUnixEpochSeconds: number;
profileImageURL?: string;
token: string;
}
/**
* The returned object from the push function.
*/
export interface PushResult {
key: string;
}
/**
* The returned object from the createUser function.
*/
export interface CreateUserResult {
key: string;
}
/**
* The options object passed into the createUser function.
*/
export interface CreateUserOptions {
email: string;
password: string;
}
/**
* The returned object in the callback handlers
* of the addChildEventListener and addValueEventListener functions.
*/
export interface FBData {
type: string;
key: string;
value: any;
}
export function init(options: InitOptions): Promise<any>;
export function login(options: LoginOptions): Promise<LoginResult>;
export function createUser(options: CreateUserOptions): Promise<CreateUserResult>;
export function push(path: string, value: any): Promise<PushResult>;
export function setValue(path: string, value: any): Promise<any>;
export function remove(path: string): Promise<any>;
export function query(onValueEvent: (data: FBData) => void, path: string, options: QueryOptions): Promise<any>;
export function addChildEventListener(onChildEvent: (data: FBData) => void, path: string): Promise<any>;
export function addValueEventListener(onValueEvent: (data: FBData) => void, path: string): Promise<any>;
}