Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit da7818c

Browse files
#7 TypeScript Definition Not Included
1 parent 8270df9 commit da7818c

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

firebase-common.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
declare module "nativescript-plugin-firebase" {
2+
3+
/**
4+
* The allowed values for LoginOptions.type.
5+
*/
6+
enum LoginType {
7+
/**
8+
* No further data is required.
9+
*/
10+
ANONYMOUS,
11+
/**
12+
* This requires you to pass in email and password properties as well.
13+
*/
14+
PASSWORD
15+
}
16+
17+
/**
18+
* The allowed values for QueryOptions.orderBy.type.
19+
*/
20+
enum QueryOrderByType {
21+
KEY,
22+
VALUE,
23+
CHILD,
24+
PRIORITY
25+
}
26+
27+
/**
28+
* The allowed values for QueryOptions.range.type.
29+
*/
30+
enum QueryRangeType {
31+
START_AT,
32+
END_AT,
33+
EQUAL_TO
34+
}
35+
36+
/**
37+
* The allowed values for QueryOptions.limit.type.
38+
*/
39+
enum QueryLimitType {
40+
FIRST,
41+
LAST
42+
}
43+
44+
/**
45+
* Logout of the Firebase instance you previously logged in to.
46+
*/
47+
function logout(): void;
48+
}

firebase.d.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/// <reference path="firebase-common.d.ts"/>
2+
declare module "nativescript-plugin-firebase" {
3+
4+
/**
5+
* The options object passed into the init function.
6+
*/
7+
export interface InitOptions {
8+
/**
9+
* The endpoint of your firebase instance.
10+
*/
11+
url: string;
12+
}
13+
14+
/**
15+
* The options object passed into the query function.
16+
*/
17+
export interface QueryOptions {
18+
/**
19+
* How you'd like to sort the query result.
20+
*/
21+
orderBy: {
22+
type: QueryOrderByType;
23+
/**
24+
* mandatory when type is QueryOrderByType.CHILD
25+
*/
26+
value?: string;
27+
};
28+
29+
/**
30+
* You can further restrict the returned results by specifying restrictions.
31+
*/
32+
range?: {
33+
type: QueryRangeType;
34+
value: string;
35+
}
36+
37+
/**
38+
* You can limit the number of returned rows if you want to.
39+
*/
40+
limit?: {
41+
type: QueryLimitType;
42+
value: number;
43+
};
44+
}
45+
46+
/**
47+
* The options object passed into the login function.
48+
*/
49+
export interface LoginOptions {
50+
type: LoginType;
51+
email?: string;
52+
password?: string;
53+
}
54+
55+
/**
56+
* The returned object from the login function.
57+
*/
58+
export interface LoginResult {
59+
uid: string;
60+
provider: LoginType;
61+
expiresAtUnixEpochSeconds: number;
62+
profileImageURL?: string;
63+
token: string;
64+
}
65+
66+
/**
67+
* The options object passed into the createUser function.
68+
*/
69+
export interface CreateUserOptions {
70+
email: string;
71+
password: string;
72+
}
73+
74+
/**
75+
* The returned object in the callback handlers
76+
* of the addChildEventListener and addValueEventListener functions.
77+
*/
78+
export interface FBData {
79+
type: string;
80+
key: string;
81+
value: any;
82+
}
83+
84+
export function init(options : InitOptions): Promise<any>;
85+
export function login(options : LoginOptions): Promise<LoginResult>;
86+
export function createUser(options : CreateUserOptions): string;
87+
export function push(path: string, value: any): void;
88+
export function setValue(path: string, value: any): void;
89+
export function remove(path: string): void;
90+
export function query(onValueEvent: (data: FBData) => void, path: string, options: QueryOptions): void;
91+
export function addChildEventListener(onChildEvent: (data: FBData) => void, path: string): void;
92+
export function addValueEventListener(onValueEvent: (data: FBData) => void, path: string): void;
93+
}

0 commit comments

Comments
 (0)