1- declare module "nativescript- firebase" {
1+ declare namespace firebase {
22
33 /**
44 * The allowed values for LoginOptions.type.
55 */
66 export 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- * This requires you to pass either an authentication token generated by your backend server
17- * or the tokenProviderFn function that returns a promise to provide the token.
18- * See: https://firebase.google.com/docs/auth/server
19- */
20- CUSTOM ,
21- /**
22- * This requires you to setup Facebook Auth in the Firebase console,
23- * as well as uncommenting the SDK includes in include.gradle (Android) and Podfile (iOS).
24- */
25- FACEBOOK ,
26- /**
27- * This requires you to setup Google Sign In in the Firebase console,
28- * as well as uncommenting the SDK includes in include.gradle (Android) and Podfile (iOS).
29- */
30- GOOGLE
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+ * This requires you to pass either an authentication token generated by your backend server
17+ * or the tokenProviderFn function that returns a promise to provide the token.
18+ * See: https://firebase.google.com/docs/auth/server
19+ */
20+ CUSTOM ,
21+ /**
22+ * This requires you to setup Facebook Auth in the Firebase console,
23+ * as well as uncommenting the SDK includes in include.gradle (Android) and Podfile (iOS).
24+ */
25+ FACEBOOK ,
26+ /**
27+ * This requires you to setup Google Sign In in the Firebase console,
28+ * as well as uncommenting the SDK includes in include.gradle (Android) and Podfile (iOS).
29+ */
30+ GOOGLE
3131 }
3232
3333 /**
3434 * The allowed values for QueryOptions.orderBy.type.
3535 */
3636 export enum QueryOrderByType {
37- KEY ,
38- VALUE ,
39- CHILD ,
40- PRIORITY
37+ KEY ,
38+ VALUE ,
39+ CHILD ,
40+ PRIORITY
4141 }
4242
4343 /**
4444 * The allowed values for QueryOptions.range.type.
4545 */
4646 export enum QueryRangeType {
47- START_AT ,
48- END_AT ,
49- EQUAL_TO
47+ START_AT ,
48+ END_AT ,
49+ EQUAL_TO
5050 }
5151
5252 /**
5353 * The allowed values for QueryOptions.limit.type.
5454 */
5555 export enum QueryLimitType {
56- FIRST ,
57- LAST
56+ FIRST ,
57+ LAST
5858 }
5959
6060 export interface ServerValue {
6161 /**
62- * TODO
62+ * TODO
6363 */
6464 TIMESTAMP : any ;
6565 }
@@ -358,7 +358,7 @@ declare module "nativescript-firebase" {
358358
359359 /**
360360 * You can get updates during upload by passing a function, example:
361- *
361+ *
362362 * onProgress: function(status) {
363363 * console.log("Uploaded fraction: " + status.fractionCompleted);
364364 * console.log("Percentage complete: " + status.percentageCompleted);
@@ -368,7 +368,6 @@ declare module "nativescript-firebase" {
368368 }
369369
370370 export interface UploadFileResult {
371-
372371 }
373372
374373 export interface DownloadFileOptions {
@@ -428,24 +427,8 @@ declare module "nativescript-firebase" {
428427 log : string ;
429428 }
430429
431- export function init ( options : InitOptions ) : Promise < any > ;
432-
433- // Database
434- export function push ( path : string , value : any ) : Promise < PushResult > ;
435- export function setValue ( path : string , value : any ) : Promise < any > ;
436- export function update ( path : string , value : any ) : Promise < any > ;
437- export function remove ( path : string ) : Promise < any > ;
438- export function query ( onValueEvent : ( data : FBData ) => void , path : string , options : QueryOptions ) : Promise < any > ;
439- export function addChildEventListener ( onChildEvent : ( data : FBData ) => void , path : string ) : Promise < AddEventListenerResult > ;
440- export function addValueEventListener ( onValueEvent : ( data : FBData ) => void , path : string ) : Promise < AddEventListenerResult > ;
441- export function removeEventListeners ( listeners : Array < any > , path : string ) : Promise < any > ;
442- /**
443- * Tells the client to keep its local cache in sync with the server automatically.
444- */
445- export function keepInSync ( path : string , switchOn : boolean ) : Promise < any > ;
446-
447430 // Analytics, nicely grouped in its own module
448- export module analytics {
431+ namespace analytics {
449432 export interface LogEventParameter {
450433 key : string ;
451434 value : string ;
@@ -461,7 +444,7 @@ declare module "nativescript-firebase" {
461444 * Each (predefined) event has its own set of optional parameters, see
462445 * https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Param
463446 * Example:
464- *
447+ *
465448 * parameters: [{
466449 * key: "item_name",
467450 * value: "abc"
@@ -479,32 +462,52 @@ declare module "nativescript-firebase" {
479462 function setUserProperty ( options : SetUserPropertyOptions ) : Promise < any > ;
480463 }
481464
482- // Auth
483- export function login ( options : LoginOptions ) : Promise < User > ;
484- export function getAuthToken ( option : GetAuthTokenOptions ) : Promise < string > ;
485- export function logout ( ) : Promise < any > ;
486- export function createUser ( options : CreateUserOptions ) : Promise < CreateUserResult > ;
487- export function deleteUser ( ) : Promise < any > ;
488- export function resetPassword ( options : ResetPasswordOptions ) : Promise < any > ;
489- export function changePassword ( options : ChangePasswordOptions ) : Promise < any > ;
490- export function addAuthStateListener ( listener : AuthStateChangeListener ) : boolean ;
491- export function removeAuthStateListener ( listener : AuthStateChangeListener ) : boolean ;
492- export function hasAuthStateListener ( listener : AuthStateChangeListener ) : boolean ;
493- export function getCurrentUser ( ) : Promise < User > ;
494-
495- // FCM
496- export function addOnMessageReceivedCallback ( onMessageReceived : ( data : Message ) => void ) : Promise < any > ;
497- export function addOnPushTokenReceivedCallback ( onPushTokenReceived : ( data : string ) => void ) : Promise < any > ;
498-
499- // remote config
500- export function getRemoteConfig ( options : GetRemoteConfigOptions ) : Promise < GetRemoteConfigResult > ;
501-
502- // storage
503- export function uploadFile ( options : UploadFileOptions ) : Promise < UploadFileResult > ;
504- export function downloadFile ( options : DownloadFileOptions ) : Promise < any > ;
505- export function getDownloadUrl ( options : GetDownloadUrlOptions ) : Promise < string > ;
506- export function deleteFile ( options : DeleteFileOptions ) : Promise < any > ;
507-
508- // crash logging
509- // export function sendCrashLog(options: SendCrashLogOptions): Promise<any>;
510- }
465+ interface Firebase {
466+ init ( options : InitOptions ) : Promise < any > ;
467+
468+ // Database
469+ push ( path : string , value : any ) : Promise < PushResult > ;
470+ setValue ( path : string , value : any ) : Promise < any > ;
471+ update ( path : string , value : any ) : Promise < any > ;
472+ remove ( path : string ) : Promise < any > ;
473+ query ( onValueEvent : ( data : FBData ) => void , path : string , options : QueryOptions ) : Promise < any > ;
474+ addChildEventListener ( onChildEvent : ( data : FBData ) => void , path : string ) : Promise < AddEventListenerResult > ;
475+ addValueEventListener ( onValueEvent : ( data : FBData ) => void , path : string ) : Promise < AddEventListenerResult > ;
476+ removeEventListeners ( listeners : Array < any > , path : string ) : Promise < any > ;
477+ /**
478+ * Tells the client to keep its local cache in sync with the server automatically.
479+ */
480+ keepInSync ( path : string , switchOn : boolean ) : Promise < any > ;
481+
482+ // Auth
483+ login ( options : LoginOptions ) : Promise < User > ;
484+ getAuthToken ( option : GetAuthTokenOptions ) : Promise < string > ;
485+ logout ( ) : Promise < any > ;
486+ createUser ( options : CreateUserOptions ) : Promise < CreateUserResult > ;
487+ deleteUser ( ) : Promise < any > ;
488+ resetPassword ( options : ResetPasswordOptions ) : Promise < any > ;
489+ changePassword ( options : ChangePasswordOptions ) : Promise < any > ;
490+ addAuthStateListener ( listener : AuthStateChangeListener ) : boolean ;
491+ removeAuthStateListener ( listener : AuthStateChangeListener ) : boolean ;
492+ hasAuthStateListener ( listener : AuthStateChangeListener ) : boolean ;
493+ getCurrentUser ( ) : Promise < User > ;
494+
495+ // FCM
496+ addOnMessageReceivedCallback ( onMessageReceived : ( data : Message ) => void ) : Promise < any > ;
497+ addOnPushTokenReceivedCallback ( onPushTokenReceived : ( data : string ) => void ) : Promise < any > ;
498+
499+ // remote config
500+ getRemoteConfig ( options : GetRemoteConfigOptions ) : Promise < GetRemoteConfigResult > ;
501+
502+ // storage
503+ uploadFile ( options : UploadFileOptions ) : Promise < UploadFileResult > ;
504+ downloadFile ( options : DownloadFileOptions ) : Promise < any > ;
505+ getDownloadUrl ( options : GetDownloadUrlOptions ) : Promise < string > ;
506+ deleteFile ( options : DeleteFileOptions ) : Promise < any > ;
507+
508+ // crash logging
509+ // sendCrashLog(options: SendCrashLogOptions): Promise<any>;
510+ }
511+ }
512+
513+ export = firebase ;
0 commit comments