├── .gitignore ├── README.md ├── lib ├── index.d.ts └── index.js ├── package.json ├── src └── index.ts ├── tsconfig.json ├── typings.json └── typings ├── globals └── es6-shim │ ├── index.d.ts │ └── typings.json ├── index.d.ts └── modules └── firebase ├── index.d.ts └── typings.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Firebase version 3 + RXJS 5 (beta currently at Beta 6) wrapper around Firebase's API. 2 | 3 | Works great with Angular2! Install using npm, you don't need typings since it's already packaged with the project. 4 | 5 | `npm install rxjsfirebase --save` 6 | 7 | **Works on ES5 but also with ES6 and TypeScript** 8 | To create an instance, you'll simply have to supply a native Firebase object to the constructor 9 | 10 | ```javascript 11 | import {RxFirebaseApp, RxFirebaseAuth, RxFirebaseView, EventType} from 'rxjsfirebase' 12 | 13 | var config = config = { 14 | apiKey: '', 15 | authDomain: '', 16 | databaseURL: '', 17 | storageBucket: '' 18 | } 19 | 20 | var applicationInstance = new RxFirebaseApp(config); 21 | // or you can give the instance a name: 22 | var applicationInstance = new RxFirebaseApp(config, "myAppInstanceName"); 23 | ``` 24 | 25 | #Note 26 | 27 | I made an opinionated effort to name data-endpoints as **RxFirebaseView**. 28 | The RxFirebaseView is essentially a `ref` or `query` in the old Firebase documentation. 29 | The logic is that it's some sort of database-path location that you can observe. 30 | It has all the methods that you love like 31 | 32 | `child(mySubPath)` 33 | 34 | `orderByChild(childPath)` 35 | 36 | `orderByKey(key)` 37 | 38 | `orderByValue(val)` 39 | 40 | `orderByPriority()` 41 | 42 | `startAt` 43 | 44 | `endAt` 45 | 46 | `equalTo` 47 | 48 | `limitToFirst` 49 | 50 | `limitToLast` 51 | 52 | `limit` 53 | 54 | 55 | 56 | #Observing Values 57 | 58 | You'll need to import the modules `EventType` enum. 59 | The enum as these values: 60 | 61 | `EventType.CHILD_ADDED` 62 | 63 | `EventType.CHILD_REMOVED` 64 | 65 | `EventType.CHILD_MOVED` 66 | 67 | `EventType.CHILD_REMOVED` 68 | 69 | `EventType.VALUE` 70 | 71 | ```javascript 72 | import {EventType} from 'rxjsfirebase' 73 | 74 | viewReference.rx_observe(EventType.CHILD_ADDED) 75 | .subscribe((snapshot) => { 76 | console.log("Completed observing snapshot: ", snapshot.val()) 77 | }, (err) => { 78 | console.log(err) 79 | }) 80 | ``` 81 | 82 | 83 | #Observing Values Once 84 | 85 | To keep the API respectful to RxJS, we simply just fire a `take(1)` to observe the value once. 86 | 87 | ```javascript 88 | viewReference.rx_observe(EventType.CHILD_ADDED).take(1) 89 | .subscribe((snapshot) => { 90 | console.log("Completed observing snapshot just once: ", snapshot.val()) 91 | }, (err) => { 92 | console.log(err) 93 | }) 94 | ``` 95 | 96 | #Observing Values with a Sister Key 97 | 98 | This is actually a separate method: `rx_observeWithSiblingKey` and it returns an object with the keys `snapshot` and `siblingKey` 99 | ** Remember the sibling key might be `null` ** 100 | 101 | ```javascript 102 | viewReference.rx_observeWithSiblingKey(EventType.CHILD_ADDED) 103 | .subscribe(snapshotWithKey => { 104 | console.log("snapshot", snapshotWithKey.snapshot) 105 | console.log("siblingKey (might be null!)", snapshotWithKey.siblingKey) 106 | }) 107 | ``` 108 | 109 | #Observing Auth Values 110 | 111 | This will return the authData. This does not throw an error if you are not authenticated. 112 | 113 | ```javascript 114 | applicationInstance.auth.rx_observeAuth().subscribe(authData => { 115 | if (authData) { 116 | console.log("User " + authData.uid + " is logged in with " + authData.provider); 117 | } else { 118 | console.log("User is logged out"); 119 | } 120 | }) 121 | ``` 122 | 123 | #Setting Values 124 | 125 | But this one will wrap that callback into an Observable 126 | 127 | ```javascript 128 | viewReference.rx_set(myValue) 129 | .subscribe(() => { 130 | console.log("Completed setting the value at this ref") 131 | }, (err) => { 132 | console.log(err) 133 | }) 134 | ``` 135 | 136 | #Updating Values 137 | 138 | But this one will wrap that callback into an `Observable<{}>` 139 | 140 | ```javascript 141 | viewReference.rx_update(valuesToUpdate) 142 | .subscribe(() => { 143 | console.log("Completed updating values at this ref") 144 | }, (err) => { 145 | console.log(err) 146 | }) 147 | ``` 148 | 149 | #Push Values 150 | 151 | But this one will wrap that callback into an `Observable` 152 | The RxFirebase instance is the location of the new ref that was pushed 153 | 154 | ```javascript 155 | viewReference.rx_push(myValue) 156 | .subscribe(newFirebaseRef => { 157 | console.log("Completed pushing and it's located at this ref", newFirebaseRef) 158 | }, (err) => { 159 | console.log(err) 160 | }) 161 | ``` -------------------------------------------------------------------------------- /lib/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Observable } from 'rxjs/Rx'; 2 | import * as Firebase from 'firebase'; 3 | export interface ISnapshotWithSisterKey { 4 | snapshot: Firebase.database.DataSnapshot; 5 | siblingKey: string; 6 | } 7 | export declare enum EventType { 8 | CHILD_ADDED = 0, 9 | CHILD_REMOVED = 1, 10 | CHILD_CHANGED = 2, 11 | CHILD_MOVED = 3, 12 | VALUE = 4, 13 | } 14 | export declare class RxFirebaseApp { 15 | private _appReference; 16 | appReference: Firebase.app.App; 17 | constructor(options: any, name?: string); 18 | database: Firebase.database.Database; 19 | auth: RxFirebaseAuth; 20 | rootView: RxFirebaseView; 21 | } 22 | export declare class RxFirebaseAuth { 23 | private _auth; 24 | constructor(auth: Firebase.auth.Auth); 25 | createCustomToken(uid: string, additionalClaims?: any): string; 26 | rx_verifyIdToken(idToken: any): Observable; 27 | rx_signInWithCustomToken(token: string): Observable; 28 | rx_signOut(): Observable; 29 | rx_onAuthStateChanged(): Observable; 30 | } 31 | export declare class RxFirebaseView { 32 | query: Firebase.database.Query; 33 | ref: Firebase.database.Reference; 34 | _query: Firebase.database.Query; 35 | constructor(query: Firebase.database.Query); 36 | child(path: string): RxFirebaseView; 37 | rx_remove(): Observable<{}>; 38 | rx_push(data: any): Observable; 39 | rx_set(data: any): Observable<{}>; 40 | rx_update(data: any): Observable<{}>; 41 | rx_observe(eventType: EventType): Observable; 42 | rx_observeWithSiblingKey(eventType: EventType): Observable; 43 | orderByChild(key: string): RxFirebaseView; 44 | orderByValue(): RxFirebaseView; 45 | orderByPriority(): RxFirebaseView; 46 | limitToLast(limit: number): RxFirebaseView; 47 | startAt(value: any, key?: string): RxFirebaseView; 48 | endAt(value: any, key?: string): RxFirebaseView; 49 | equalTo(value: any, key?: string): RxFirebaseView; 50 | private static convertToString(eventType); 51 | } 52 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var Rx_1 = require('rxjs/Rx'); 3 | var Firebase = require('firebase'); 4 | (function (EventType) { 5 | EventType[EventType["CHILD_ADDED"] = 0] = "CHILD_ADDED"; 6 | EventType[EventType["CHILD_REMOVED"] = 1] = "CHILD_REMOVED"; 7 | EventType[EventType["CHILD_CHANGED"] = 2] = "CHILD_CHANGED"; 8 | EventType[EventType["CHILD_MOVED"] = 3] = "CHILD_MOVED"; 9 | EventType[EventType["VALUE"] = 4] = "VALUE"; 10 | })(exports.EventType || (exports.EventType = {})); 11 | var EventType = exports.EventType; 12 | var RxFirebaseApp = (function () { 13 | function RxFirebaseApp(options, name) { 14 | if (name === void 0) { name = "rxfirebase"; } 15 | this._appReference = Firebase.initializeApp(options, name); 16 | } 17 | Object.defineProperty(RxFirebaseApp.prototype, "appReference", { 18 | get: function () { 19 | return this._appReference; 20 | }, 21 | enumerable: true, 22 | configurable: true 23 | }); 24 | Object.defineProperty(RxFirebaseApp.prototype, "database", { 25 | get: function () { 26 | return this._appReference.database(); 27 | }, 28 | enumerable: true, 29 | configurable: true 30 | }); 31 | Object.defineProperty(RxFirebaseApp.prototype, "auth", { 32 | get: function () { 33 | return new RxFirebaseAuth(this._appReference.auth()); 34 | }, 35 | enumerable: true, 36 | configurable: true 37 | }); 38 | Object.defineProperty(RxFirebaseApp.prototype, "rootView", { 39 | get: function () { 40 | return new RxFirebaseView(this._appReference.database().ref()); 41 | }, 42 | enumerable: true, 43 | configurable: true 44 | }); 45 | return RxFirebaseApp; 46 | }()); 47 | exports.RxFirebaseApp = RxFirebaseApp; 48 | var RxFirebaseAuth = (function () { 49 | function RxFirebaseAuth(auth) { 50 | this._auth = auth; 51 | } 52 | RxFirebaseAuth.prototype.createCustomToken = function (uid, additionalClaims) { 53 | if (additionalClaims === void 0) { additionalClaims = {}; } 54 | return this._auth.createCustomToken(uid, additionalClaims); 55 | }; 56 | RxFirebaseAuth.prototype.rx_verifyIdToken = function (idToken) { 57 | return Rx_1.Observable.fromPromise(this._auth.verifyIdToken(idToken)); 58 | }; 59 | RxFirebaseAuth.prototype.rx_signInWithCustomToken = function (token) { 60 | return Rx_1.Observable.fromPromise(this._auth.signInWithCustomToken(token)); 61 | }; 62 | RxFirebaseAuth.prototype.rx_signOut = function () { 63 | return Rx_1.Observable.fromPromise(this._auth.signOut()); 64 | }; 65 | RxFirebaseAuth.prototype.rx_onAuthStateChanged = function () { 66 | var self = this; 67 | return new Rx_1.Observable(function (subscriber) { 68 | var listenerReference = self._auth.onAuthStateChanged(function (user) { 69 | subscriber.next(user); 70 | }, function (err) { 71 | subscriber.error(err); 72 | }, function () { 73 | subscriber.complete(); 74 | }); 75 | return function () { 76 | listenerReference(); // unsubscriber 77 | }; 78 | }); 79 | }; 80 | return RxFirebaseAuth; 81 | }()); 82 | exports.RxFirebaseAuth = RxFirebaseAuth; 83 | var RxFirebaseView = (function () { 84 | function RxFirebaseView(query) { 85 | this._query = query; 86 | } 87 | Object.defineProperty(RxFirebaseView.prototype, "query", { 88 | get: function () { 89 | return this._query; 90 | }, 91 | enumerable: true, 92 | configurable: true 93 | }); 94 | Object.defineProperty(RxFirebaseView.prototype, "ref", { 95 | get: function () { 96 | return this.query.ref; 97 | }, 98 | enumerable: true, 99 | configurable: true 100 | }); 101 | RxFirebaseView.prototype.child = function (path) { 102 | return new RxFirebaseView(this.query.ref.child(path)); 103 | }; 104 | RxFirebaseView.prototype.rx_remove = function () { 105 | var self = this; 106 | return new Rx_1.Observable(function (subscriber) { 107 | self.ref.remove(function (err) { 108 | if (err != null) { 109 | subscriber.error(err); 110 | } 111 | else { 112 | subscriber.next({}); 113 | subscriber.complete(); 114 | } 115 | }); 116 | return function () { }; 117 | }); 118 | }; 119 | RxFirebaseView.prototype.rx_push = function (data) { 120 | var self = this; 121 | return new Rx_1.Observable(function (subscriber) { 122 | var newRef = self.ref.push(data, function (err) { 123 | if (err != null) { 124 | subscriber.error(err); 125 | } 126 | else { 127 | subscriber.next(new RxFirebaseView(newRef)); 128 | subscriber.complete(); 129 | } 130 | }); 131 | return function () { 132 | }; 133 | }); 134 | }; 135 | RxFirebaseView.prototype.rx_set = function (data) { 136 | var self = this; 137 | return new Rx_1.Observable(function (subscriber) { 138 | self.query.ref.set(data, function (err) { 139 | if (err != null) { 140 | subscriber.error(err); 141 | } 142 | else { 143 | subscriber.next({}); 144 | subscriber.complete(); 145 | } 146 | }); 147 | return function () { 148 | }; 149 | }); 150 | }; 151 | RxFirebaseView.prototype.rx_update = function (data) { 152 | var self = this; 153 | return new Rx_1.Observable(function (subscriber) { 154 | self.ref.update(data, function (err) { 155 | if (err != null) { 156 | subscriber.error(err); 157 | } 158 | else { 159 | subscriber.next({}); 160 | subscriber.complete(); 161 | } 162 | }); 163 | return function () { 164 | }; 165 | }); 166 | }; 167 | RxFirebaseView.prototype.rx_observe = function (eventType) { 168 | var self = this; 169 | return new Rx_1.Observable(function (subscriber) { 170 | var callback = function (snapshot, siblingKey) { 171 | subscriber.next(snapshot); 172 | }; 173 | self.query.on(RxFirebaseView.convertToString(eventType), callback, function (err) { 174 | subscriber.error(err); 175 | }); 176 | return function () { 177 | self.query.off(RxFirebaseView.convertToString(eventType), callback); 178 | }; 179 | }); 180 | }; 181 | RxFirebaseView.prototype.rx_observeWithSiblingKey = function (eventType) { 182 | var self = this; 183 | return new Rx_1.Observable(function (subscriber) { 184 | var callback = function (snapshot, siblingKey) { 185 | var payload = { 186 | snapshot: snapshot, 187 | siblingKey: siblingKey 188 | }; 189 | subscriber.next(payload); 190 | }; 191 | self.query.on(RxFirebaseView.convertToString(eventType), callback, function (err) { 192 | subscriber.error(err); 193 | }); 194 | return function () { 195 | self.query.off(RxFirebaseView.convertToString(eventType), callback); 196 | }; 197 | }); 198 | }; 199 | RxFirebaseView.prototype.orderByChild = function (key) { 200 | var newQuery = this.query.orderByChild(key); 201 | return new RxFirebaseView(newQuery); 202 | }; 203 | RxFirebaseView.prototype.orderByValue = function () { 204 | var newQuery = this.query.orderByValue(); 205 | return new RxFirebaseView(newQuery); 206 | }; 207 | RxFirebaseView.prototype.orderByPriority = function () { 208 | var newQuery = this.query.orderByPriority(); 209 | return new RxFirebaseView(newQuery); 210 | }; 211 | RxFirebaseView.prototype.limitToLast = function (limit) { 212 | var newQuery = this.query.limitToLast(limit); 213 | return new RxFirebaseView(newQuery); 214 | }; 215 | RxFirebaseView.prototype.startAt = function (value, key) { 216 | var newQuery = this.query.startAt(value, key); 217 | return new RxFirebaseView(newQuery); 218 | }; 219 | RxFirebaseView.prototype.endAt = function (value, key) { 220 | var newQuery = this.query.endAt(value, key); 221 | return new RxFirebaseView(newQuery); 222 | }; 223 | RxFirebaseView.prototype.equalTo = function (value, key) { 224 | var newQuery = this.query.equalTo(value, key); 225 | return new RxFirebaseView(newQuery); 226 | }; 227 | RxFirebaseView.convertToString = function (eventType) { 228 | switch (eventType) { 229 | case EventType.CHILD_ADDED: 230 | return "child_added"; 231 | case EventType.CHILD_CHANGED: 232 | return "child_changed"; 233 | case EventType.CHILD_MOVED: 234 | return "child_moved"; 235 | case EventType.CHILD_REMOVED: 236 | return "child_removed"; 237 | case EventType.VALUE: 238 | return "value"; 239 | default: 240 | break; 241 | } 242 | }; 243 | return RxFirebaseView; 244 | }()); 245 | exports.RxFirebaseView = RxFirebaseView; 246 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjsfirebase", 3 | "main": "lib/index.js", 4 | "typings": "lib/index.d.ts", 5 | "files": [ 6 | "lib" 7 | ], 8 | "version": "3.2.7", 9 | "description": "RxJS Beta 5 wrapper around firebase", 10 | "scripts": { 11 | "prepublish": "tsc", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/mbalex99/rxjsfirebase" 17 | }, 18 | "dependencies": { 19 | "firebase": "^3.2.0", 20 | "rxjs": "~5.0.0-beta.6" 21 | }, 22 | "devDependencies": { 23 | "typescript": "1.8.10" 24 | }, 25 | "keywords": [], 26 | "author": "Maximilian Alexander (http://blog.edenmsg.com/)", 27 | "license": "MIT" 28 | } -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import {Observable, Subscriber} from 'rxjs/Rx' 2 | import * as Firebase from 'firebase' 3 | 4 | export interface ISnapshotWithSisterKey { 5 | snapshot: Firebase.database.DataSnapshot, 6 | siblingKey: string 7 | } 8 | 9 | export enum EventType { 10 | CHILD_ADDED, CHILD_REMOVED, CHILD_CHANGED, CHILD_MOVED, VALUE 11 | } 12 | 13 | export class RxFirebaseApp { 14 | 15 | private _appReference : Firebase.app.App 16 | get appReference(): Firebase.app.App { 17 | return this._appReference; 18 | } 19 | 20 | constructor(options: any, name: string = "rxfirebase"){ 21 | this._appReference = Firebase.initializeApp(options, name) 22 | } 23 | public get database() : Firebase.database.Database { 24 | return this._appReference.database() 25 | } 26 | public get auth(): RxFirebaseAuth { 27 | return new RxFirebaseAuth(this._appReference.auth()) 28 | } 29 | 30 | public get rootView(): RxFirebaseView { 31 | return new RxFirebaseView(this._appReference.database().ref()) 32 | } 33 | } 34 | 35 | export class RxFirebaseAuth { 36 | private _auth : Firebase.auth.Auth; 37 | public constructor(auth: Firebase.auth.Auth){ 38 | this._auth = auth; 39 | } 40 | 41 | public createCustomToken(uid: string, additionalClaims: any = {}) : string { 42 | return (this._auth).createCustomToken(uid, additionalClaims); 43 | } 44 | 45 | public rx_verifyIdToken(idToken) : Observable { 46 | return Observable.fromPromise((this._auth).verifyIdToken(idToken)) 47 | } 48 | 49 | public rx_signInWithCustomToken(token: string) : Observable{ 50 | return Observable.fromPromise(this._auth.signInWithCustomToken(token)) 51 | } 52 | 53 | public rx_signOut() : Observable{ 54 | return Observable.fromPromise(this._auth.signOut()) 55 | } 56 | public rx_onAuthStateChanged() : Observable { 57 | var self = this; 58 | return new Observable((subscriber: Subscriber) => { 59 | var listenerReference = self._auth.onAuthStateChanged((user: Firebase.User) => { 60 | subscriber.next(user); 61 | }, err => { 62 | subscriber.error(err); 63 | }, () => { 64 | subscriber.complete(); 65 | }); 66 | return () => { 67 | listenerReference(); // unsubscriber 68 | } 69 | }); 70 | } 71 | 72 | } 73 | 74 | 75 | export class RxFirebaseView { 76 | 77 | public get query(): Firebase.database.Query { 78 | return this._query; 79 | } 80 | 81 | public get ref(): Firebase.database.Reference { 82 | return this.query.ref; 83 | } 84 | 85 | _query: Firebase.database.Query 86 | public constructor(query: Firebase.database.Query) 87 | { 88 | this._query = query; 89 | } 90 | 91 | child(path: string): RxFirebaseView { 92 | return new RxFirebaseView(this.query.ref.child(path)); 93 | } 94 | 95 | rx_remove(): Observable<{}> { 96 | let self = this; 97 | return new Observable((subscriber : Subscriber<{}>) => { 98 | self.ref.remove((err) => { 99 | if(err != null){ 100 | subscriber.error(err); 101 | }else{ 102 | subscriber.next({}); 103 | subscriber.complete(); 104 | } 105 | }) 106 | return () => {} 107 | }) 108 | } 109 | 110 | rx_push(data: any): Observable{ 111 | let self = this; 112 | return new Observable((subscriber: Subscriber) => { 113 | var newRef = self.ref.push(data, (err) => { 114 | if(err != null){ 115 | subscriber.error(err); 116 | }else{ 117 | subscriber.next(new RxFirebaseView(newRef)); 118 | subscriber.complete(); 119 | } 120 | }) 121 | return () => { 122 | 123 | } 124 | }) 125 | } 126 | 127 | rx_set(data: any): Observable<{}>{ 128 | let self = this; 129 | return new Observable((subscriber: Subscriber<{}>) => { 130 | self.query.ref.set(data, (err) => { 131 | if(err != null){ 132 | subscriber.error(err); 133 | }else{ 134 | subscriber.next({}); 135 | subscriber.complete(); 136 | } 137 | }) 138 | return () => { 139 | 140 | } 141 | }); 142 | } 143 | 144 | rx_update(data: any): Observable<{}> { 145 | let self = this; 146 | return new Observable((subscriber: Subscriber<{}>) => { 147 | self.ref.update(data, (err) => { 148 | if(err != null){ 149 | subscriber.error(err); 150 | }else{ 151 | subscriber.next({}); 152 | subscriber.complete(); 153 | } 154 | }) 155 | return () => { 156 | 157 | } 158 | }); 159 | } 160 | 161 | rx_observe(eventType: EventType) : Observable { 162 | var self = this; 163 | return new Observable((subscriber : Subscriber) => { 164 | var callback = (snapshot: Firebase.database.DataSnapshot, siblingKey: string) => { 165 | subscriber.next(snapshot) 166 | } 167 | self.query.on(RxFirebaseView.convertToString(eventType), callback, (err: Firebase.FirebaseError) => { 168 | subscriber.error(err); 169 | }) 170 | return () => { 171 | self.query.off(RxFirebaseView.convertToString(eventType), callback); 172 | } 173 | }); 174 | } 175 | 176 | 177 | 178 | rx_observeWithSiblingKey(eventType: EventType): Observable { 179 | var self = this; 180 | return new Observable((subscriber: Subscriber) => { 181 | var callback = (snapshot: Firebase.database.DataSnapshot, siblingKey: string) => { 182 | var payload : ISnapshotWithSisterKey = { 183 | snapshot: snapshot, 184 | siblingKey: siblingKey 185 | } 186 | subscriber.next(payload) 187 | } 188 | self.query.on(RxFirebaseView.convertToString(eventType), callback, (err: Firebase.FirebaseError) => { 189 | subscriber.error(err); 190 | }) 191 | return () => { 192 | self.query.off(RxFirebaseView.convertToString(eventType), callback); 193 | } 194 | }) 195 | } 196 | 197 | 198 | orderByChild(key: string) : RxFirebaseView { 199 | let newQuery = this.query.orderByChild(key); 200 | return new RxFirebaseView(newQuery); 201 | } 202 | 203 | orderByValue(): RxFirebaseView { 204 | let newQuery = this.query.orderByValue() 205 | return new RxFirebaseView(newQuery); 206 | } 207 | 208 | orderByPriority(): RxFirebaseView { 209 | let newQuery = this.query.orderByPriority(); 210 | return new RxFirebaseView(newQuery) 211 | } 212 | 213 | limitToLast(limit: number): RxFirebaseView { 214 | let newQuery = this.query.limitToLast(limit); 215 | return new RxFirebaseView(newQuery); 216 | } 217 | 218 | startAt(value: any, key?: string): RxFirebaseView { 219 | let newQuery = this.query.startAt(value, key) 220 | return new RxFirebaseView(newQuery); 221 | } 222 | 223 | endAt(value: any, key?: string): RxFirebaseView { 224 | let newQuery = this.query.endAt(value, key) 225 | return new RxFirebaseView(newQuery); 226 | } 227 | 228 | equalTo(value: any, key?: string){ 229 | let newQuery = this.query.equalTo(value, key) 230 | return new RxFirebaseView(newQuery); 231 | } 232 | 233 | private static convertToString(eventType: EventType) : string { 234 | switch (eventType) { 235 | case EventType.CHILD_ADDED: 236 | return "child_added" 237 | case EventType.CHILD_CHANGED: 238 | return "child_changed" 239 | case EventType.CHILD_MOVED: 240 | return "child_moved" 241 | case EventType.CHILD_REMOVED: 242 | return "child_removed" 243 | case EventType.VALUE: 244 | return "value" 245 | default: 246 | break; 247 | } 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "outDir": "lib", 5 | "sourceMap": false, 6 | "declaration": true, 7 | "module": "commonjs", 8 | "removeComments": false 9 | }, 10 | "exclude": [ 11 | "node_modules", 12 | "test", 13 | "lib", 14 | ".build" 15 | ] 16 | } -------------------------------------------------------------------------------- /typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjsfirebase", 3 | "globalDevDependencies": { 4 | "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c" 5 | }, 6 | "dependencies": { 7 | "firebase": "registry:npm/firebase#3.0.5+20160705215914" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /typings/globals/es6-shim/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts 3 | declare type PropertyKey = string | number | symbol; 4 | 5 | interface IteratorResult { 6 | done: boolean; 7 | value?: T; 8 | } 9 | 10 | interface IterableShim { 11 | /** 12 | * Shim for an ES6 iterable. Not intended for direct use by user code. 13 | */ 14 | "_es6-shim iterator_"(): Iterator; 15 | } 16 | 17 | interface Iterator { 18 | next(value?: any): IteratorResult; 19 | return?(value?: any): IteratorResult; 20 | throw?(e?: any): IteratorResult; 21 | } 22 | 23 | interface IterableIteratorShim extends IterableShim, Iterator { 24 | /** 25 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code. 26 | */ 27 | "_es6-shim iterator_"(): IterableIteratorShim; 28 | } 29 | 30 | interface StringConstructor { 31 | /** 32 | * Return the String value whose elements are, in order, the elements in the List elements. 33 | * If length is 0, the empty string is returned. 34 | */ 35 | fromCodePoint(...codePoints: number[]): string; 36 | 37 | /** 38 | * String.raw is intended for use as a tag function of a Tagged Template String. When called 39 | * as such the first argument will be a well formed template call site object and the rest 40 | * parameter will contain the substitution values. 41 | * @param template A well-formed template string call site representation. 42 | * @param substitutions A set of substitution values. 43 | */ 44 | raw(template: TemplateStringsArray, ...substitutions: any[]): string; 45 | } 46 | 47 | interface String { 48 | /** 49 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point 50 | * value of the UTF-16 encoded code point starting at the string element at position pos in 51 | * the String resulting from converting this object to a String. 52 | * If there is no element at that position, the result is undefined. 53 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. 54 | */ 55 | codePointAt(pos: number): number; 56 | 57 | /** 58 | * Returns true if searchString appears as a substring of the result of converting this 59 | * object to a String, at one or more positions that are 60 | * greater than or equal to position; otherwise, returns false. 61 | * @param searchString search string 62 | * @param position If position is undefined, 0 is assumed, so as to search all of the String. 63 | */ 64 | includes(searchString: string, position?: number): boolean; 65 | 66 | /** 67 | * Returns true if the sequence of elements of searchString converted to a String is the 68 | * same as the corresponding elements of this object (converted to a String) starting at 69 | * endPosition – length(this). Otherwise returns false. 70 | */ 71 | endsWith(searchString: string, endPosition?: number): boolean; 72 | 73 | /** 74 | * Returns a String value that is made from count copies appended together. If count is 0, 75 | * T is the empty String is returned. 76 | * @param count number of copies to append 77 | */ 78 | repeat(count: number): string; 79 | 80 | /** 81 | * Returns true if the sequence of elements of searchString converted to a String is the 82 | * same as the corresponding elements of this object (converted to a String) starting at 83 | * position. Otherwise returns false. 84 | */ 85 | startsWith(searchString: string, position?: number): boolean; 86 | 87 | /** 88 | * Returns an HTML anchor element and sets the name attribute to the text value 89 | * @param name 90 | */ 91 | anchor(name: string): string; 92 | 93 | /** Returns a HTML element */ 94 | big(): string; 95 | 96 | /** Returns a HTML element */ 97 | blink(): string; 98 | 99 | /** Returns a HTML element */ 100 | bold(): string; 101 | 102 | /** Returns a HTML element */ 103 | fixed(): string 104 | 105 | /** Returns a HTML element and sets the color attribute value */ 106 | fontcolor(color: string): string 107 | 108 | /** Returns a HTML element and sets the size attribute value */ 109 | fontsize(size: number): string; 110 | 111 | /** Returns a HTML element and sets the size attribute value */ 112 | fontsize(size: string): string; 113 | 114 | /** Returns an HTML element */ 115 | italics(): string; 116 | 117 | /** Returns an HTML element and sets the href attribute value */ 118 | link(url: string): string; 119 | 120 | /** Returns a HTML element */ 121 | small(): string; 122 | 123 | /** Returns a HTML element */ 124 | strike(): string; 125 | 126 | /** Returns a HTML element */ 127 | sub(): string; 128 | 129 | /** Returns a HTML element */ 130 | sup(): string; 131 | 132 | /** 133 | * Shim for an ES6 iterable. Not intended for direct use by user code. 134 | */ 135 | "_es6-shim iterator_"(): IterableIteratorShim; 136 | } 137 | 138 | interface ArrayConstructor { 139 | /** 140 | * Creates an array from an array-like object. 141 | * @param arrayLike An array-like object to convert to an array. 142 | * @param mapfn A mapping function to call on every element of the array. 143 | * @param thisArg Value of 'this' used to invoke the mapfn. 144 | */ 145 | from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 146 | 147 | /** 148 | * Creates an array from an iterable object. 149 | * @param iterable An iterable object to convert to an array. 150 | * @param mapfn A mapping function to call on every element of the array. 151 | * @param thisArg Value of 'this' used to invoke the mapfn. 152 | */ 153 | from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 154 | 155 | /** 156 | * Creates an array from an array-like object. 157 | * @param arrayLike An array-like object to convert to an array. 158 | */ 159 | from(arrayLike: ArrayLike): Array; 160 | 161 | /** 162 | * Creates an array from an iterable object. 163 | * @param iterable An iterable object to convert to an array. 164 | */ 165 | from(iterable: IterableShim): Array; 166 | 167 | /** 168 | * Returns a new array from a set of elements. 169 | * @param items A set of elements to include in the new array object. 170 | */ 171 | of(...items: T[]): Array; 172 | } 173 | 174 | interface Array { 175 | /** 176 | * Returns the value of the first element in the array where predicate is true, and undefined 177 | * otherwise. 178 | * @param predicate find calls predicate once for each element of the array, in ascending 179 | * order, until it finds one where predicate returns true. If such an element is found, find 180 | * immediately returns that element value. Otherwise, find returns undefined. 181 | * @param thisArg If provided, it will be used as the this value for each invocation of 182 | * predicate. If it is not provided, undefined is used instead. 183 | */ 184 | find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; 185 | 186 | /** 187 | * Returns the index of the first element in the array where predicate is true, and undefined 188 | * otherwise. 189 | * @param predicate find calls predicate once for each element of the array, in ascending 190 | * order, until it finds one where predicate returns true. If such an element is found, find 191 | * immediately returns that element value. Otherwise, find returns undefined. 192 | * @param thisArg If provided, it will be used as the this value for each invocation of 193 | * predicate. If it is not provided, undefined is used instead. 194 | */ 195 | findIndex(predicate: (value: T) => boolean, thisArg?: any): number; 196 | 197 | /** 198 | * Returns the this object after filling the section identified by start and end with value 199 | * @param value value to fill array section with 200 | * @param start index to start filling the array at. If start is negative, it is treated as 201 | * length+start where length is the length of the array. 202 | * @param end index to stop filling the array at. If end is negative, it is treated as 203 | * length+end. 204 | */ 205 | fill(value: T, start?: number, end?: number): T[]; 206 | 207 | /** 208 | * Returns the this object after copying a section of the array identified by start and end 209 | * to the same array starting at position target 210 | * @param target If target is negative, it is treated as length+target where length is the 211 | * length of the array. 212 | * @param start If start is negative, it is treated as length+start. If end is negative, it 213 | * is treated as length+end. 214 | * @param end If not specified, length of the this object is used as its default value. 215 | */ 216 | copyWithin(target: number, start: number, end?: number): T[]; 217 | 218 | /** 219 | * Returns an array of key, value pairs for every entry in the array 220 | */ 221 | entries(): IterableIteratorShim<[number, T]>; 222 | 223 | /** 224 | * Returns an list of keys in the array 225 | */ 226 | keys(): IterableIteratorShim; 227 | 228 | /** 229 | * Returns an list of values in the array 230 | */ 231 | values(): IterableIteratorShim; 232 | 233 | /** 234 | * Shim for an ES6 iterable. Not intended for direct use by user code. 235 | */ 236 | "_es6-shim iterator_"(): IterableIteratorShim; 237 | } 238 | 239 | interface NumberConstructor { 240 | /** 241 | * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 242 | * that is representable as a Number value, which is approximately: 243 | * 2.2204460492503130808472633361816 x 10‍−‍16. 244 | */ 245 | EPSILON: number; 246 | 247 | /** 248 | * Returns true if passed value is finite. 249 | * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a 250 | * number. Only finite values of the type number, result in true. 251 | * @param number A numeric value. 252 | */ 253 | isFinite(number: number): boolean; 254 | 255 | /** 256 | * Returns true if the value passed is an integer, false otherwise. 257 | * @param number A numeric value. 258 | */ 259 | isInteger(number: number): boolean; 260 | 261 | /** 262 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a 263 | * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter 264 | * to a number. Only values of the type number, that are also NaN, result in true. 265 | * @param number A numeric value. 266 | */ 267 | isNaN(number: number): boolean; 268 | 269 | /** 270 | * Returns true if the value passed is a safe integer. 271 | * @param number A numeric value. 272 | */ 273 | isSafeInteger(number: number): boolean; 274 | 275 | /** 276 | * The value of the largest integer n such that n and n + 1 are both exactly representable as 277 | * a Number value. 278 | * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. 279 | */ 280 | MAX_SAFE_INTEGER: number; 281 | 282 | /** 283 | * The value of the smallest integer n such that n and n − 1 are both exactly representable as 284 | * a Number value. 285 | * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). 286 | */ 287 | MIN_SAFE_INTEGER: number; 288 | 289 | /** 290 | * Converts a string to a floating-point number. 291 | * @param string A string that contains a floating-point number. 292 | */ 293 | parseFloat(string: string): number; 294 | 295 | /** 296 | * Converts A string to an integer. 297 | * @param s A string to convert into a number. 298 | * @param radix A value between 2 and 36 that specifies the base of the number in numString. 299 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. 300 | * All other strings are considered decimal. 301 | */ 302 | parseInt(string: string, radix?: number): number; 303 | } 304 | 305 | interface ObjectConstructor { 306 | /** 307 | * Copy the values of all of the enumerable own properties from one or more source objects to a 308 | * target object. Returns the target object. 309 | * @param target The target object to copy to. 310 | * @param sources One or more source objects to copy properties from. 311 | */ 312 | assign(target: any, ...sources: any[]): any; 313 | 314 | /** 315 | * Returns true if the values are the same value, false otherwise. 316 | * @param value1 The first value. 317 | * @param value2 The second value. 318 | */ 319 | is(value1: any, value2: any): boolean; 320 | 321 | /** 322 | * Sets the prototype of a specified object o to object proto or null. Returns the object o. 323 | * @param o The object to change its prototype. 324 | * @param proto The value of the new prototype or null. 325 | * @remarks Requires `__proto__` support. 326 | */ 327 | setPrototypeOf(o: any, proto: any): any; 328 | } 329 | 330 | interface RegExp { 331 | /** 332 | * Returns a string indicating the flags of the regular expression in question. This field is read-only. 333 | * The characters in this string are sequenced and concatenated in the following order: 334 | * 335 | * - "g" for global 336 | * - "i" for ignoreCase 337 | * - "m" for multiline 338 | * - "u" for unicode 339 | * - "y" for sticky 340 | * 341 | * If no flags are set, the value is the empty string. 342 | */ 343 | flags: string; 344 | } 345 | 346 | interface Math { 347 | /** 348 | * Returns the number of leading zero bits in the 32-bit binary representation of a number. 349 | * @param x A numeric expression. 350 | */ 351 | clz32(x: number): number; 352 | 353 | /** 354 | * Returns the result of 32-bit multiplication of two numbers. 355 | * @param x First number 356 | * @param y Second number 357 | */ 358 | imul(x: number, y: number): number; 359 | 360 | /** 361 | * Returns the sign of the x, indicating whether x is positive, negative or zero. 362 | * @param x The numeric expression to test 363 | */ 364 | sign(x: number): number; 365 | 366 | /** 367 | * Returns the base 10 logarithm of a number. 368 | * @param x A numeric expression. 369 | */ 370 | log10(x: number): number; 371 | 372 | /** 373 | * Returns the base 2 logarithm of a number. 374 | * @param x A numeric expression. 375 | */ 376 | log2(x: number): number; 377 | 378 | /** 379 | * Returns the natural logarithm of 1 + x. 380 | * @param x A numeric expression. 381 | */ 382 | log1p(x: number): number; 383 | 384 | /** 385 | * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of 386 | * the natural logarithms). 387 | * @param x A numeric expression. 388 | */ 389 | expm1(x: number): number; 390 | 391 | /** 392 | * Returns the hyperbolic cosine of a number. 393 | * @param x A numeric expression that contains an angle measured in radians. 394 | */ 395 | cosh(x: number): number; 396 | 397 | /** 398 | * Returns the hyperbolic sine of a number. 399 | * @param x A numeric expression that contains an angle measured in radians. 400 | */ 401 | sinh(x: number): number; 402 | 403 | /** 404 | * Returns the hyperbolic tangent of a number. 405 | * @param x A numeric expression that contains an angle measured in radians. 406 | */ 407 | tanh(x: number): number; 408 | 409 | /** 410 | * Returns the inverse hyperbolic cosine of a number. 411 | * @param x A numeric expression that contains an angle measured in radians. 412 | */ 413 | acosh(x: number): number; 414 | 415 | /** 416 | * Returns the inverse hyperbolic sine of a number. 417 | * @param x A numeric expression that contains an angle measured in radians. 418 | */ 419 | asinh(x: number): number; 420 | 421 | /** 422 | * Returns the inverse hyperbolic tangent of a number. 423 | * @param x A numeric expression that contains an angle measured in radians. 424 | */ 425 | atanh(x: number): number; 426 | 427 | /** 428 | * Returns the square root of the sum of squares of its arguments. 429 | * @param values Values to compute the square root for. 430 | * If no arguments are passed, the result is +0. 431 | * If there is only one argument, the result is the absolute value. 432 | * If any argument is +Infinity or -Infinity, the result is +Infinity. 433 | * If any argument is NaN, the result is NaN. 434 | * If all arguments are either +0 or −0, the result is +0. 435 | */ 436 | hypot(...values: number[]): number; 437 | 438 | /** 439 | * Returns the integral part of the a numeric expression, x, removing any fractional digits. 440 | * If x is already an integer, the result is x. 441 | * @param x A numeric expression. 442 | */ 443 | trunc(x: number): number; 444 | 445 | /** 446 | * Returns the nearest single precision float representation of a number. 447 | * @param x A numeric expression. 448 | */ 449 | fround(x: number): number; 450 | 451 | /** 452 | * Returns an implementation-dependent approximation to the cube root of number. 453 | * @param x A numeric expression. 454 | */ 455 | cbrt(x: number): number; 456 | } 457 | 458 | interface PromiseLike { 459 | /** 460 | * Attaches callbacks for the resolution and/or rejection of the Promise. 461 | * @param onfulfilled The callback to execute when the Promise is resolved. 462 | * @param onrejected The callback to execute when the Promise is rejected. 463 | * @returns A Promise for the completion of which ever callback is executed. 464 | */ 465 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; 466 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; 467 | } 468 | 469 | /** 470 | * Represents the completion of an asynchronous operation 471 | */ 472 | interface Promise { 473 | /** 474 | * Attaches callbacks for the resolution and/or rejection of the Promise. 475 | * @param onfulfilled The callback to execute when the Promise is resolved. 476 | * @param onrejected The callback to execute when the Promise is rejected. 477 | * @returns A Promise for the completion of which ever callback is executed. 478 | */ 479 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 480 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 481 | 482 | /** 483 | * Attaches a callback for only the rejection of the Promise. 484 | * @param onrejected The callback to execute when the Promise is rejected. 485 | * @returns A Promise for the completion of the callback. 486 | */ 487 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 488 | catch(onrejected?: (reason: any) => void): Promise; 489 | } 490 | 491 | interface PromiseConstructor { 492 | /** 493 | * A reference to the prototype. 494 | */ 495 | prototype: Promise; 496 | 497 | /** 498 | * Creates a new Promise. 499 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 500 | * a resolve callback used resolve the promise with a value or the result of another promise, 501 | * and a reject callback used to reject the promise with a provided reason or error. 502 | */ 503 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 504 | 505 | /** 506 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 507 | * resolve, or rejected when any Promise is rejected. 508 | * @param values An array of Promises. 509 | * @returns A new Promise. 510 | */ 511 | all(values: IterableShim>): Promise; 512 | 513 | /** 514 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 515 | * or rejected. 516 | * @param values An array of Promises. 517 | * @returns A new Promise. 518 | */ 519 | race(values: IterableShim>): Promise; 520 | 521 | /** 522 | * Creates a new rejected promise for the provided reason. 523 | * @param reason The reason the promise was rejected. 524 | * @returns A new rejected Promise. 525 | */ 526 | reject(reason: any): Promise; 527 | 528 | /** 529 | * Creates a new rejected promise for the provided reason. 530 | * @param reason The reason the promise was rejected. 531 | * @returns A new rejected Promise. 532 | */ 533 | reject(reason: any): Promise; 534 | 535 | /** 536 | * Creates a new resolved promise for the provided value. 537 | * @param value A promise. 538 | * @returns A promise whose internal state matches the provided promise. 539 | */ 540 | resolve(value: T | PromiseLike): Promise; 541 | 542 | /** 543 | * Creates a new resolved promise . 544 | * @returns A resolved promise. 545 | */ 546 | resolve(): Promise; 547 | } 548 | 549 | declare var Promise: PromiseConstructor; 550 | 551 | interface Map { 552 | clear(): void; 553 | delete(key: K): boolean; 554 | forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; 555 | get(key: K): V; 556 | has(key: K): boolean; 557 | set(key: K, value?: V): Map; 558 | size: number; 559 | entries(): IterableIteratorShim<[K, V]>; 560 | keys(): IterableIteratorShim; 561 | values(): IterableIteratorShim; 562 | } 563 | 564 | interface MapConstructor { 565 | new (): Map; 566 | new (iterable: IterableShim<[K, V]>): Map; 567 | prototype: Map; 568 | } 569 | 570 | declare var Map: MapConstructor; 571 | 572 | interface Set { 573 | add(value: T): Set; 574 | clear(): void; 575 | delete(value: T): boolean; 576 | forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; 577 | has(value: T): boolean; 578 | size: number; 579 | entries(): IterableIteratorShim<[T, T]>; 580 | keys(): IterableIteratorShim; 581 | values(): IterableIteratorShim; 582 | } 583 | 584 | interface SetConstructor { 585 | new (): Set; 586 | new (iterable: IterableShim): Set; 587 | prototype: Set; 588 | } 589 | 590 | declare var Set: SetConstructor; 591 | 592 | interface WeakMap { 593 | delete(key: K): boolean; 594 | get(key: K): V; 595 | has(key: K): boolean; 596 | set(key: K, value?: V): WeakMap; 597 | } 598 | 599 | interface WeakMapConstructor { 600 | new (): WeakMap; 601 | new (iterable: IterableShim<[K, V]>): WeakMap; 602 | prototype: WeakMap; 603 | } 604 | 605 | declare var WeakMap: WeakMapConstructor; 606 | 607 | interface WeakSet { 608 | add(value: T): WeakSet; 609 | delete(value: T): boolean; 610 | has(value: T): boolean; 611 | } 612 | 613 | interface WeakSetConstructor { 614 | new (): WeakSet; 615 | new (iterable: IterableShim): WeakSet; 616 | prototype: WeakSet; 617 | } 618 | 619 | declare var WeakSet: WeakSetConstructor; 620 | 621 | declare module Reflect { 622 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 623 | function construct(target: Function, argumentsList: ArrayLike): any; 624 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 625 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 626 | function enumerate(target: any): IterableIteratorShim; 627 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 628 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 629 | function getPrototypeOf(target: any): any; 630 | function has(target: any, propertyKey: PropertyKey): boolean; 631 | function isExtensible(target: any): boolean; 632 | function ownKeys(target: any): Array; 633 | function preventExtensions(target: any): boolean; 634 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 635 | function setPrototypeOf(target: any, proto: any): boolean; 636 | } 637 | 638 | declare module "es6-shim" { 639 | var String: StringConstructor; 640 | var Array: ArrayConstructor; 641 | var Number: NumberConstructor; 642 | var Math: Math; 643 | var Object: ObjectConstructor; 644 | var Map: MapConstructor; 645 | var Set: SetConstructor; 646 | var WeakMap: WeakMapConstructor; 647 | var WeakSet: WeakSetConstructor; 648 | var Promise: PromiseConstructor; 649 | module Reflect { 650 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 651 | function construct(target: Function, argumentsList: ArrayLike): any; 652 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 653 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 654 | function enumerate(target: any): Iterator; 655 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 656 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 657 | function getPrototypeOf(target: any): any; 658 | function has(target: any, propertyKey: PropertyKey): boolean; 659 | function isExtensible(target: any): boolean; 660 | function ownKeys(target: any): Array; 661 | function preventExtensions(target: any): boolean; 662 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 663 | function setPrototypeOf(target: any, proto: any): boolean; 664 | } 665 | } -------------------------------------------------------------------------------- /typings/globals/es6-shim/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts", 5 | "raw": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /typings/modules/firebase/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/typed-typings/npm-es6-promise/fb04188767acfec1defd054fc8024fafa5cd4de7/dist/es6-promise.d.ts 3 | declare module '~firebase~es6-promise/dist/es6-promise' { 4 | export interface Thenable { 5 | then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; 6 | then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; 7 | } 8 | 9 | export class Promise implements Thenable { 10 | /** 11 | * If you call resolve in the body of the callback passed to the constructor, 12 | * your promise is fulfilled with result object passed to resolve. 13 | * If you call reject your promise is rejected with the object passed to resolve. 14 | * For consistency and debugging (eg stack traces), obj should be an instanceof Error. 15 | * Any errors thrown in the constructor callback will be implicitly passed to reject(). 16 | */ 17 | constructor (callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); 18 | 19 | /** 20 | * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. 21 | * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. 22 | * Both callbacks have a single parameter , the fulfillment value or rejection reason. 23 | * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. 24 | * If an error is thrown in the callback, the returned promise rejects with that error. 25 | * 26 | * @param onFulfilled called when/if "promise" resolves 27 | * @param onRejected called when/if "promise" rejects 28 | */ 29 | then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; 30 | then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; 31 | 32 | /** 33 | * Sugar for promise.then(undefined, onRejected) 34 | * 35 | * @param onRejected called when/if "promise" rejects 36 | */ 37 | catch (onRejected?: (error: any) => U | Thenable): Promise; 38 | 39 | /** 40 | * Make a new promise from the thenable. 41 | * A thenable is promise-like in as far as it has a "then" method. 42 | */ 43 | static resolve (): Promise; 44 | static resolve (value: R | Thenable): Promise; 45 | 46 | /** 47 | * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error 48 | */ 49 | static reject (error: any): Promise; 50 | 51 | /** 52 | * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. 53 | * the array passed to all can be a mixture of promise-like objects and other objects. 54 | * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. 55 | */ 56 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable, T10 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; 57 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable, T9 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; 58 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable, T8 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; 59 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable, T7 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; 60 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable, T6 | Thenable]): Promise<[T1, T2, T3, T4, T5, T6]>; 61 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable , T5 | Thenable]): Promise<[T1, T2, T3, T4, T5]>; 62 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable, T4 | Thenable ]): Promise<[T1, T2, T3, T4]>; 63 | static all(values: [T1 | Thenable, T2 | Thenable, T3 | Thenable]): Promise<[T1, T2, T3]>; 64 | static all(values: [T1 | Thenable, T2 | Thenable]): Promise<[T1, T2]>; 65 | static all(values: [T1 | Thenable]): Promise<[T1]>; 66 | static all(values: Array>): Promise; 67 | 68 | /** 69 | * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. 70 | */ 71 | static race (promises: (R | Thenable)[]): Promise; 72 | } 73 | 74 | /** 75 | * The polyfill method will patch the global environment (in this case to the Promise name) when called. 76 | */ 77 | export function polyfill (): void; 78 | } 79 | declare module '~firebase~es6-promise' { 80 | export * from '~firebase~es6-promise/dist/es6-promise'; 81 | } 82 | 83 | // Generated by typings 84 | // Source: https://raw.githubusercontent.com/typed-typings/npm-firebase/7dceb15d79a7adacbd01163e7f65043900775e00/firebase-node.d.ts 85 | declare module '~firebase/firebase-node' { 86 | /* 87 | 88 | 1. Delete goog namespaces 89 | 2. Delete look of disaproval 90 | 3. typealias firebase.Promise to Promise 91 | 4. Union type FirebaseOAuthProvider 92 | 5. Remove _noStructuralTyping from Promise classes 93 | 6. Remove catch() and then() declarations from firebase.Thenable, and extend Promise. 94 | 95 | */ 96 | 97 | import { Promise } from '~firebase~es6-promise'; 98 | 99 | interface FirebaseService { 100 | INTERNAL: Object; 101 | app: firebase.app.App; 102 | } 103 | 104 | interface FirebaseServiceNamespace { 105 | app(app?: firebase.app.App): FirebaseService; 106 | } 107 | 108 | interface Observer { 109 | complete(): any; 110 | error(error: Object): any; 111 | next(value: any): any; 112 | } 113 | 114 | 115 | type FirebaseOAuthProvider = firebase.auth.GithubAuthProvider | 116 | firebase.auth.GoogleAuthProvider | 117 | firebase.auth.FacebookAuthProvider; 118 | 119 | class Promise_Instance implements PromiseLike { 120 | constructor(resolver: (a: (a?: TYPE | PromiseLike | { then: any }) => any, b: (a?: any) => any) => any); 121 | catch(onRejected: (a: any) => RESULT): Promise; 122 | then(opt_onFulfilled?: (a: TYPE) => VALUE, opt_onRejected?: (a: any) => any): RESULT; 123 | } 124 | 125 | namespace firebase { 126 | type AuthTokenData = { accessToken: string, expirationTime: number, refreshToken: string }; 127 | } 128 | namespace firebase { 129 | type AuthTokenListener = (a: string) => void; 130 | } 131 | namespace firebase { 132 | type CompleteFn = () => void; 133 | } 134 | namespace firebase { 135 | type ErrorFn = (a: Object) => void; 136 | } 137 | namespace firebase { 138 | interface FirebaseError { 139 | code: string; 140 | message: string; 141 | name: string; 142 | stack: string; 143 | } 144 | } 145 | namespace firebase { 146 | type NextFn = (a: any) => void; 147 | } 148 | namespace firebase { 149 | class Promise extends Promise_Instance { 150 | static all(values: firebase.Promise[]): firebase.Promise; 151 | static reject(error: Object): firebase.Promise; 152 | static resolve(value: T): firebase.Promise; 153 | } 154 | class Promise_Instance implements firebase.Thenable { 155 | constructor(resolver: (a?: (a: T) => void, b?: (a: Object) => void) => any); 156 | catch(onReject?: (a: Object) => any): firebase.Thenable; 157 | then(onResolve?: (a: T) => any, onReject?: (a: Object) => any): firebase.Promise; 158 | } 159 | } 160 | namespace firebase { 161 | var SDK_VERSION: string; 162 | } 163 | namespace firebase { 164 | type Subscribe = (a?: ((a: any) => void) | Observer, b?: (a: Object) => void, c?: () => void) => () => void; 165 | } 166 | namespace firebase { 167 | interface Thenable extends Promise { 168 | //Removed definitions of catch() and then(), and extended Promise. 169 | } 170 | } 171 | namespace firebase { 172 | type Unsubscribe = () => void; 173 | } 174 | namespace firebase { 175 | interface User extends firebase.UserInfo { 176 | delete(): firebase.Promise; 177 | emailVerified: boolean; 178 | getToken(opt_forceRefresh?: boolean): firebase.Promise; 179 | isAnonymous: boolean; 180 | link(credential: firebase.auth.AuthCredential): firebase.Promise; 181 | linkWithPopup(provider: firebase.auth.AuthProvider): firebase.Promise<{ credential: firebase.auth.AuthCredential, user: firebase.User }>; 182 | linkWithRedirect(provider: firebase.auth.AuthProvider): firebase.Promise; 183 | providerData: (firebase.UserInfo)[]; 184 | reauthenticate(credential: firebase.auth.AuthCredential): firebase.Promise; 185 | refreshToken: string; 186 | reload(): firebase.Promise; 187 | sendEmailVerification(): firebase.Promise; 188 | unlink(providerId: string): firebase.Promise; 189 | updateEmail(newEmail: string): firebase.Promise; 190 | updatePassword(newPassword: string): firebase.Promise; 191 | updateProfile(profile: { displayName: string, photoURL: string }): firebase.Promise; 192 | } 193 | } 194 | namespace firebase { 195 | interface UserInfo { 196 | displayName: string; 197 | email: string; 198 | photoURL: string; 199 | providerId: string; 200 | uid: string; 201 | } 202 | } 203 | namespace firebase { 204 | function app(name: string): firebase.app.App; 205 | } 206 | namespace firebase.app { 207 | interface App { 208 | INTERNAL: Object; 209 | auth(): firebase.auth.Auth; 210 | database(): firebase.database.Database; 211 | delete(): firebase.Promise; 212 | name: string; 213 | options: Object; 214 | storage(): firebase.storage.Storage; 215 | } 216 | } 217 | namespace firebase { 218 | var apps: (firebase.app.App)[]; 219 | } 220 | namespace firebase { 221 | function auth(app?: firebase.app.App): firebase.auth.Auth; 222 | } 223 | namespace firebase.auth { 224 | interface ActionCodeInfo { 225 | } 226 | } 227 | namespace firebase.auth { 228 | interface Auth { 229 | app: firebase.app.App; 230 | applyActionCode(code: string): firebase.Promise; 231 | checkActionCode(code: string): firebase.Promise; 232 | confirmPasswordReset(code: string, newPassword: string): firebase.Promise; 233 | createUserWithEmailAndPassword(email: string, password: string): firebase.Promise; 234 | currentUser: firebase.User; 235 | fetchProvidersForEmail(email: string): firebase.Promise; 236 | getRedirectResult(): firebase.Promise<{ credential: firebase.auth.AuthCredential, user: firebase.User }>; 237 | onAuthStateChanged(nextOrObserver: Object, opt_error?: (a: firebase.auth.Error) => any, opt_completed?: () => any): () => any; 238 | sendPasswordResetEmail(email: string): firebase.Promise; 239 | signInAnonymously(): firebase.Promise; 240 | signInWithCredential(credential: firebase.auth.AuthCredential): firebase.Promise; 241 | signInWithCustomToken(token: string): firebase.Promise; 242 | signInWithEmailAndPassword(email: string, password: string): firebase.Promise; 243 | signInWithPopup(provider: firebase.auth.AuthProvider): firebase.Promise<{ credential: firebase.auth.AuthCredential, user: firebase.User }>; 244 | signInWithRedirect(provider: firebase.auth.AuthProvider): firebase.Promise; 245 | signOut(): firebase.Promise; 246 | verifyPasswordResetCode(code: string): firebase.Promise; 247 | } 248 | } 249 | namespace firebase.auth { 250 | interface AuthCredential { 251 | provider: string; 252 | } 253 | } 254 | namespace firebase.auth { 255 | interface AuthProvider { 256 | providerId: string; 257 | } 258 | } 259 | namespace firebase.auth { 260 | class EmailAuthProvider extends EmailAuthProvider_Instance { 261 | static PROVIDER_ID: string; 262 | } 263 | class EmailAuthProvider_Instance implements firebase.auth.AuthProvider { 264 | private noStructuralTyping_: any; 265 | credential(email: string, password: string): firebase.auth.AuthCredential; 266 | providerId: string; 267 | } 268 | } 269 | namespace firebase.auth { 270 | interface Error { 271 | code: string; 272 | message: string; 273 | } 274 | } 275 | namespace firebase.auth { 276 | class FacebookAuthProvider extends FacebookAuthProvider_Instance { 277 | static PROVIDER_ID: string; 278 | } 279 | class FacebookAuthProvider_Instance implements firebase.auth.AuthProvider { 280 | private noStructuralTyping_: any; 281 | addScope(scope: string): any; 282 | credential(token: string): firebase.auth.AuthCredential; 283 | providerId: string; 284 | } 285 | } 286 | namespace firebase.auth { 287 | class GithubAuthProvider extends GithubAuthProvider_Instance { 288 | static PROVIDER_ID: string; 289 | // TODO fix upstream 290 | static credential(token: string): firebase.auth.AuthCredential; 291 | } 292 | class GithubAuthProvider_Instance implements firebase.auth.AuthProvider { 293 | private noStructuralTyping_: any; 294 | addScope(scope: string): any; 295 | providerId: string; 296 | } 297 | } 298 | namespace firebase.auth { 299 | class GoogleAuthProvider extends GoogleAuthProvider_Instance { 300 | static PROVIDER_ID: string; 301 | } 302 | class GoogleAuthProvider_Instance implements firebase.auth.AuthProvider { 303 | private noStructuralTyping_: any; 304 | addScope(scope: string): any; 305 | credential(idToken?: string, accessToken?: string): firebase.auth.AuthCredential; 306 | providerId: string; 307 | } 308 | } 309 | namespace firebase.auth { 310 | class TwitterAuthProvider extends TwitterAuthProvider_Instance { 311 | static PROVIDER_ID: string; 312 | // TODO fix this upstream 313 | static credential(token: string, secret: string): firebase.auth.AuthCredential; 314 | } 315 | class TwitterAuthProvider_Instance implements firebase.auth.AuthProvider { 316 | private noStructuralTyping_: any; 317 | providerId: string; 318 | } 319 | } 320 | namespace firebase.auth { 321 | type UserCredential = { credential: firebase.auth.AuthCredential, user: firebase.User }; 322 | } 323 | namespace firebase { 324 | function database(app?: firebase.app.App): firebase.database.Database; 325 | } 326 | namespace firebase.database { 327 | interface DataSnapshot { 328 | child(path: string): firebase.database.DataSnapshot; 329 | exists(): boolean; 330 | exportVal(): any; 331 | forEach(action: (a: firebase.database.DataSnapshot) => boolean): boolean; 332 | getPriority(): string | number; 333 | hasChild(path: string): boolean; 334 | hasChildren(): boolean; 335 | key: string; 336 | numChildren(): number; 337 | ref: firebase.database.Reference; 338 | val(): any; 339 | } 340 | } 341 | namespace firebase.database { 342 | interface Database { 343 | app: firebase.app.App; 344 | goOffline(): any; 345 | goOnline(): any; 346 | ref(path?: string): firebase.database.Reference; 347 | refFromURL(url: string): firebase.database.Reference; 348 | } 349 | } 350 | namespace firebase.database { 351 | interface OnDisconnect { 352 | cancel(onComplete?: (a: Object) => any): firebase.Promise; 353 | remove(onComplete?: (a: Object) => any): firebase.Promise; 354 | set(value: any, onComplete?: (a: Object) => any): firebase.Promise; 355 | setWithPriority(value: any, priority: number | string, onComplete?: (a: Object) => any): firebase.Promise; 356 | update(values: Object, onComplete?: (a: Object) => any): firebase.Promise; 357 | } 358 | } 359 | namespace firebase.database { 360 | interface Query { 361 | endAt(value: number | string | boolean, key?: string): firebase.database.Query; 362 | equalTo(value: number | string | boolean, key?: string): firebase.database.Query; 363 | limitToFirst(limit: number): firebase.database.Query; 364 | limitToLast(limit: number): firebase.database.Query; 365 | off(eventType?: string, callback?: (a: firebase.database.DataSnapshot, b?: string) => any, context?: Object): any; 366 | on(eventType: string, callback: (a: firebase.database.DataSnapshot, b?: string) => any, cancelCallbackOrContext?: Object, context?: Object): (a: firebase.database.DataSnapshot, b?: string) => any; 367 | once(eventType: string, callback?: (a: firebase.database.DataSnapshot, b?: string) => any): firebase.Promise; 368 | orderByChild(path: string): firebase.database.Query; 369 | orderByKey(): firebase.database.Query; 370 | orderByPriority(): firebase.database.Query; 371 | orderByValue(): firebase.database.Query; 372 | ref: firebase.database.Reference; 373 | startAt(value: number | string | boolean, key?: string): firebase.database.Query; 374 | toString(): string; 375 | } 376 | } 377 | namespace firebase.database { 378 | interface Reference extends firebase.database.Query { 379 | child(path: string): firebase.database.Reference; 380 | key: string; 381 | onDisconnect(): firebase.database.OnDisconnect; 382 | parent: firebase.database.Reference; 383 | push(value?: any, onComplete?: (a: Object) => any): firebase.database.ThenableReference; 384 | remove(onComplete?: (a: Object) => any): firebase.Promise; 385 | root: firebase.database.Reference; 386 | set(value: any, onComplete?: (a: Object) => any): firebase.Promise; 387 | setPriority(priority: string | number, onComplete: (a: Object) => any): firebase.Promise; 388 | setWithPriority(newVal: any, newPriority: string | number, onComplete?: (a: Object) => any): firebase.Promise; 389 | 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 }>; 390 | update(values: Object, onComplete?: (a: Object) => any): firebase.Promise; 391 | } 392 | } 393 | namespace firebase.database.ServerValue { 394 | } 395 | namespace firebase.database { 396 | interface ThenableReference extends firebase.database.Reference, firebase.Thenable { 397 | } 398 | } 399 | namespace firebase.database { 400 | function enableLogging(logger?: any, persistent?: boolean): any; 401 | } 402 | namespace firebase { 403 | function initializeApp(options: Object, name?: string): firebase.app.App; 404 | } 405 | namespace firebase { 406 | function storage(app?: firebase.app.App): firebase.storage.Storage; 407 | } 408 | namespace firebase.storage { 409 | interface FullMetadata extends firebase.storage.UploadMetadata { 410 | bucket: string; 411 | downloadURLs: string[]; 412 | fullPath: string; 413 | generation: string; 414 | metageneration: string; 415 | name: string; 416 | size: number; 417 | timeCreated: string; 418 | updated: string; 419 | } 420 | } 421 | namespace firebase.storage { 422 | interface Reference { 423 | bucket: string; 424 | child(path: string): firebase.storage.Reference; 425 | delete(): Promise; 426 | fullPath: string; 427 | getDownloadURL(): Promise; 428 | getMetadata(): Promise; 429 | name: string; 430 | parent: firebase.storage.Reference; 431 | put(blob: Blob, metadata?: firebase.storage.UploadMetadata): firebase.storage.UploadTask; 432 | root: firebase.storage.Reference; 433 | storage: firebase.storage.Storage; 434 | toString(): string; 435 | updateMetadata(metadata: firebase.storage.SettableMetadata): Promise; 436 | } 437 | } 438 | namespace firebase.storage { 439 | interface SettableMetadata { 440 | cacheControl: string; 441 | contentDisposition: string; 442 | contentEncoding: string; 443 | contentLanguage: string; 444 | contentType: string; 445 | customMetadata: { [key: string]: string }; 446 | } 447 | } 448 | namespace firebase.storage { 449 | interface Storage { 450 | app: firebase.app.App; 451 | maxOperationRetryTime: number; 452 | maxUploadRetryTime: number; 453 | ref(path?: string): firebase.storage.Reference; 454 | refFromURL(url: string): firebase.storage.Reference; 455 | setMaxOperationRetryTime(time: number): any; 456 | setMaxUploadRetryTime(time: number): any; 457 | } 458 | } 459 | namespace firebase.storage { 460 | type TaskEvent = string; 461 | var TaskEvent: { 462 | STATE_CHANGED: TaskEvent, 463 | }; 464 | } 465 | namespace firebase.storage { 466 | type TaskState = string; 467 | var TaskState: { 468 | CANCELED: TaskState, 469 | ERROR: TaskState, 470 | PAUSED: TaskState, 471 | RUNNING: TaskState, 472 | SUCCESS: TaskState, 473 | }; 474 | } 475 | namespace firebase.storage { 476 | interface UploadMetadata extends firebase.storage.SettableMetadata { 477 | md5Hash: string; 478 | } 479 | } 480 | namespace firebase.storage { 481 | interface UploadTask { 482 | cancel(): boolean; 483 | on(event: firebase.storage.TaskEvent, nextOrObserver?: Object, error?: (a: Object) => any, complete?: () => any): (...a: any[]) => any; 484 | pause(): boolean; 485 | resume(): boolean; 486 | snapshot: firebase.storage.UploadTaskSnapshot; 487 | } 488 | } 489 | namespace firebase.storage { 490 | interface UploadTaskSnapshot { 491 | bytesTransferred: number; 492 | downloadURL: string; 493 | metadata: firebase.storage.FullMetadata; 494 | ref: firebase.storage.Reference; 495 | state: firebase.storage.TaskState; 496 | task: firebase.storage.UploadTask; 497 | totalBytes: number; 498 | } 499 | } 500 | 501 | export = firebase; 502 | } 503 | declare module 'firebase/firebase-node' { 504 | import main = require('~firebase/firebase-node'); 505 | export = main; 506 | } 507 | declare module 'firebase' { 508 | import main = require('~firebase/firebase-node'); 509 | export = main; 510 | } 511 | -------------------------------------------------------------------------------- /typings/modules/firebase/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/typed-typings/npm-firebase/7dceb15d79a7adacbd01163e7f65043900775e00/typings.json", 5 | "raw": "registry:npm/firebase#3.0.5+20160705215914", 6 | "main": "firebase-node.d.ts", 7 | "version": "3.0.5", 8 | "global": false, 9 | "dependencies": { 10 | "es6-promise": { 11 | "src": "https://raw.githubusercontent.com/typed-typings/npm-es6-promise/fb04188767acfec1defd054fc8024fafa5cd4de7/typings.json", 12 | "raw": "registry:npm/es6-promise#3.0.0+20160211003958", 13 | "main": "dist/es6-promise.d.ts", 14 | "global": false, 15 | "name": "es6-promise", 16 | "type": "typings" 17 | } 18 | }, 19 | "name": "firebase", 20 | "type": "typings" 21 | } 22 | } 23 | --------------------------------------------------------------------------------