forked from firebase/firebase-bower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase.d.ts
2121 lines (1934 loc) · 72.5 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare namespace firebase {
type NextFn<T> = (value: T) => void;
type ErrorFn<E = Error> = (error: E) => void;
type CompleteFn = () => void;
interface FirebaseError {
code: string;
message: string;
name: string;
stack?: string;
}
interface Observer<T, E = Error> {
next: NextFn<T>;
error: ErrorFn<E>;
complete: CompleteFn;
}
var SDK_VERSION: string;
type Unsubscribe = () => void;
interface User extends firebase.UserInfo {
delete(): Promise<void>;
emailVerified: boolean;
getIdTokenResult(
forceRefresh?: boolean
): Promise<firebase.auth.IdTokenResult>;
getIdToken(forceRefresh?: boolean): Promise<string>;
isAnonymous: boolean;
linkAndRetrieveDataWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
linkWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.User>;
linkWithPhoneNumber(
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<firebase.auth.ConfirmationResult>;
linkWithPopup(
provider: firebase.auth.AuthProvider
): Promise<firebase.auth.UserCredential>;
linkWithRedirect(provider: firebase.auth.AuthProvider): Promise<void>;
metadata: firebase.auth.UserMetadata;
phoneNumber: string | null;
providerData: (firebase.UserInfo | null)[];
reauthenticateAndRetrieveDataWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
reauthenticateWithCredential(
credential: firebase.auth.AuthCredential
): Promise<void>;
reauthenticateWithPhoneNumber(
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<firebase.auth.ConfirmationResult>;
reauthenticateWithPopup(
provider: firebase.auth.AuthProvider
): Promise<firebase.auth.UserCredential>;
reauthenticateWithRedirect(
provider: firebase.auth.AuthProvider
): Promise<void>;
refreshToken: string;
reload(): Promise<void>;
sendEmailVerification(
actionCodeSettings?: firebase.auth.ActionCodeSettings | null
): Promise<void>;
toJSON(): Object;
unlink(providerId: string): Promise<firebase.User>;
updateEmail(newEmail: string): Promise<void>;
updatePassword(newPassword: string): Promise<void>;
updatePhoneNumber(
phoneCredential: firebase.auth.AuthCredential
): Promise<void>;
updateProfile(profile: {
displayName: string | null;
photoURL: string | null;
}): Promise<void>;
}
interface UserInfo {
displayName: string | null;
email: string | null;
phoneNumber: string | null;
photoURL: string | null;
providerId: string;
uid: string;
}
function app(name?: string): firebase.app.App;
var apps: firebase.app.App[];
function auth(app?: firebase.app.App): firebase.auth.Auth;
function database(app?: firebase.app.App): firebase.database.Database;
function initializeApp(options: Object, name?: string): firebase.app.App;
function messaging(app?: firebase.app.App): firebase.messaging.Messaging;
function storage(app?: firebase.app.App): firebase.storage.Storage;
function firestore(app?: firebase.app.App): firebase.firestore.Firestore;
function functions(app?: firebase.app.App): firebase.functions.Functions;
}
declare namespace firebase.app {
interface App {
auth(): firebase.auth.Auth;
database(url?: string): firebase.database.Database;
delete(): Promise<any>;
messaging(): firebase.messaging.Messaging;
name: string;
options: Object;
storage(url?: string): firebase.storage.Storage;
firestore(): firebase.firestore.Firestore;
functions(region?: string): firebase.functions.Functions;
}
}
declare namespace firebase.functions {
export interface HttpsCallableResult {
readonly data: any;
}
export interface HttpsCallable {
(data?: any): Promise<HttpsCallableResult>;
}
export class Functions {
private constructor();
useFunctionsEmulator(url: string): void;
httpsCallable(name: string): HttpsCallable;
}
export type ErrorStatus =
| 'ok'
| 'cancelled'
| 'unknown'
| 'invalid-argument'
| 'deadline-exceeded'
| 'not-found'
| 'already-exists'
| 'permission-denied'
| 'resource-exhausted'
| 'failed-precondition'
| 'aborted'
| 'out-of-range'
| 'unimplemented'
| 'internal'
| 'unavailable'
| 'data-loss'
| 'unauthenticated';
export interface HttpsError extends Error {
readonly code: ErrorStatus;
readonly details?: any;
}
}
declare namespace firebase.auth {
interface ActionCodeInfo {
data: {
email?: string | null;
fromEmail?: string | null;
};
operation: string;
}
type ActionCodeSettings = {
android?: {
installApp?: boolean;
minimumVersion?: string;
packageName: string;
};
handleCodeInApp?: boolean;
iOS?: { bundleId: string };
url: string;
dynamicLinkDomain?: string;
};
type AdditionalUserInfo = {
isNewUser: boolean;
profile: Object | null;
providerId: string;
username?: string | null;
};
interface ApplicationVerifier {
type: string;
verify(): Promise<string>;
}
interface AuthSettings {
appVerificationDisabledForTesting: boolean;
}
interface Auth {
app: firebase.app.App;
applyActionCode(code: string): Promise<void>;
checkActionCode(code: string): Promise<firebase.auth.ActionCodeInfo>;
confirmPasswordReset(code: string, newPassword: string): Promise<void>;
createUserAndRetrieveDataWithEmailAndPassword(
email: string,
password: string
): Promise<firebase.auth.UserCredential>;
createUserWithEmailAndPassword(
email: string,
password: string
): Promise<firebase.auth.UserCredential>;
currentUser: firebase.User | null;
fetchProvidersForEmail(email: string): Promise<Array<string>>;
fetchSignInMethodsForEmail(email: string): Promise<Array<string>>;
isSignInWithEmailLink(emailLink: string): boolean;
getRedirectResult(): Promise<firebase.auth.UserCredential>;
languageCode: string | null;
settings: firebase.auth.AuthSettings;
onAuthStateChanged(
nextOrObserver:
| firebase.Observer<any>
| ((a: firebase.User | null) => any),
error?: (a: firebase.auth.Error) => any,
completed?: firebase.Unsubscribe
): firebase.Unsubscribe;
onIdTokenChanged(
nextOrObserver:
| firebase.Observer<any>
| ((a: firebase.User | null) => any),
error?: (a: firebase.auth.Error) => any,
completed?: firebase.Unsubscribe
): firebase.Unsubscribe;
sendSignInLinkToEmail(
email: string,
actionCodeSettings: firebase.auth.ActionCodeSettings
): Promise<void>;
sendPasswordResetEmail(
email: string,
actionCodeSettings?: firebase.auth.ActionCodeSettings | null
): Promise<void>;
setPersistence(persistence: firebase.auth.Auth.Persistence): Promise<void>;
signInAndRetrieveDataWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
signInAnonymously(): Promise<firebase.auth.UserCredential>;
signInAnonymouslyAndRetrieveData(): Promise<firebase.auth.UserCredential>;
signInWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.User>;
signInWithCustomToken(token: string): Promise<firebase.auth.UserCredential>;
signInAndRetrieveDataWithCustomToken(
token: string
): Promise<firebase.auth.UserCredential>;
signInWithEmailAndPassword(
email: string,
password: string
): Promise<firebase.auth.UserCredential>;
signInAndRetrieveDataWithEmailAndPassword(
email: string,
password: string
): Promise<firebase.auth.UserCredential>;
signInWithPhoneNumber(
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<firebase.auth.ConfirmationResult>;
signInWithEmailLink(
email: string,
emailLink?: string
): Promise<firebase.auth.UserCredential>;
signInWithPopup(
provider: firebase.auth.AuthProvider
): Promise<firebase.auth.UserCredential>;
signInWithRedirect(provider: firebase.auth.AuthProvider): Promise<void>;
signOut(): Promise<void>;
updateCurrentUser(user: firebase.User | null): Promise<void>;
useDeviceLanguage(): void;
verifyPasswordResetCode(code: string): Promise<string>;
}
interface AuthCredential {
providerId: string;
signInMethod: string;
}
interface AuthProvider {
providerId: string;
}
interface ConfirmationResult {
confirm(verificationCode: string): Promise<firebase.auth.UserCredential>;
verificationId: string;
}
class EmailAuthProvider extends EmailAuthProvider_Instance {
static PROVIDER_ID: string;
static EMAIL_PASSWORD_SIGN_IN_METHOD: string;
static EMAIL_LINK_SIGN_IN_METHOD: string;
static credential(
email: string,
password: string
): firebase.auth.AuthCredential;
static credentialWithLink(
email: string,
emailLink: string
): firebase.auth.AuthCredential;
}
class EmailAuthProvider_Instance implements firebase.auth.AuthProvider {
providerId: string;
}
interface Error {
code: string;
message: string;
}
class FacebookAuthProvider extends FacebookAuthProvider_Instance {
static PROVIDER_ID: string;
static FACEBOOK_SIGN_IN_METHOD: string;
static credential(token: string): firebase.auth.AuthCredential;
}
class FacebookAuthProvider_Instance implements firebase.auth.AuthProvider {
addScope(scope: string): firebase.auth.AuthProvider;
providerId: string;
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
class GithubAuthProvider extends GithubAuthProvider_Instance {
static PROVIDER_ID: string;
static GITHUB_SIGN_IN_METHOD: string;
static credential(token: string): firebase.auth.AuthCredential;
}
class GithubAuthProvider_Instance implements firebase.auth.AuthProvider {
addScope(scope: string): firebase.auth.AuthProvider;
providerId: string;
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
class GoogleAuthProvider extends GoogleAuthProvider_Instance {
static PROVIDER_ID: string;
static GOOGLE_SIGN_IN_METHOD: string;
static credential(
idToken?: string | null,
accessToken?: string | null
): firebase.auth.AuthCredential;
}
class GoogleAuthProvider_Instance implements firebase.auth.AuthProvider {
addScope(scope: string): firebase.auth.AuthProvider;
providerId: string;
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
class OAuthProvider implements firebase.auth.AuthProvider {
providerId: string;
addScope(scope: string): firebase.auth.AuthProvider;
credential(
idToken?: string,
accessToken?: string
): firebase.auth.AuthCredential;
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
class SAMLAuthProvider implements firebase.auth.AuthProvider {
providerId: string;
}
interface IdTokenResult {
token: string;
expirationTime: string;
authTime: string;
issuedAtTime: string;
signInProvider: string | null;
claims: {
[key: string]: any;
};
}
class PhoneAuthProvider extends PhoneAuthProvider_Instance {
static PROVIDER_ID: string;
static PHONE_SIGN_IN_METHOD: string;
static credential(
verificationId: string,
verificationCode: string
): firebase.auth.AuthCredential;
}
class PhoneAuthProvider_Instance implements firebase.auth.AuthProvider {
constructor(auth?: firebase.auth.Auth | null);
providerId: string;
verifyPhoneNumber(
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<string>;
}
class RecaptchaVerifier extends RecaptchaVerifier_Instance {}
class RecaptchaVerifier_Instance
implements firebase.auth.ApplicationVerifier {
constructor(
container: any | string,
parameters?: Object | null,
app?: firebase.app.App | null
);
clear(): void;
render(): Promise<number>;
type: string;
verify(): Promise<string>;
}
class TwitterAuthProvider extends TwitterAuthProvider_Instance {
static PROVIDER_ID: string;
static TWITTER_SIGN_IN_METHOD: string;
static credential(
token: string,
secret: string
): firebase.auth.AuthCredential;
}
class TwitterAuthProvider_Instance implements firebase.auth.AuthProvider {
providerId: string;
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
type UserCredential = {
additionalUserInfo?: firebase.auth.AdditionalUserInfo | null;
credential: firebase.auth.AuthCredential | null;
operationType?: string | null;
user: firebase.User | null;
};
interface UserMetadata {
creationTime?: string;
lastSignInTime?: string;
}
}
declare namespace firebase.auth.Auth {
type Persistence = string;
var Persistence: {
LOCAL: Persistence;
NONE: Persistence;
SESSION: Persistence;
};
}
declare namespace firebase.database {
interface DataSnapshot {
child(path: string): firebase.database.DataSnapshot;
exists(): boolean;
exportVal(): any;
forEach(
action: (a: firebase.database.DataSnapshot) => boolean | void
): boolean;
getPriority(): string | number | null;
hasChild(path: string): boolean;
hasChildren(): boolean;
key: string | null;
numChildren(): number;
val(): any;
ref: firebase.database.Reference;
toJSON(): Object | null;
}
interface Database {
app: firebase.app.App;
goOffline(): any;
goOnline(): any;
ref(path?: string): firebase.database.Reference;
refFromURL(url: string): firebase.database.Reference;
}
interface OnDisconnect {
cancel(onComplete?: (a: Error | null) => any): Promise<any>;
remove(onComplete?: (a: Error | null) => any): Promise<any>;
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
setWithPriority(
value: any,
priority: number | string | null,
onComplete?: (a: Error | null) => any
): Promise<any>;
update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
}
type EventType =
| 'value'
| 'child_added'
| 'child_changed'
| 'child_moved'
| 'child_removed';
interface Query {
endAt(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
equalTo(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
isEqual(other: firebase.database.Query | null): boolean;
limitToFirst(limit: number): firebase.database.Query;
limitToLast(limit: number): firebase.database.Query;
off(
eventType?: EventType,
callback?: (a: firebase.database.DataSnapshot, b?: string | null) => any,
context?: Object | null
): any;
on(
eventType: EventType,
callback: (a: firebase.database.DataSnapshot | null, b?: string) => any,
cancelCallbackOrContext?: Object | null,
context?: Object | null
): (a: firebase.database.DataSnapshot | null, b?: string) => any;
once(
eventType: EventType,
successCallback?: (a: firebase.database.DataSnapshot, b?: string) => any,
failureCallbackOrContext?: Object | null,
context?: Object | null
): Promise<DataSnapshot>;
orderByChild(path: string): firebase.database.Query;
orderByKey(): firebase.database.Query;
orderByPriority(): firebase.database.Query;
orderByValue(): firebase.database.Query;
ref: firebase.database.Reference;
startAt(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
toJSON(): Object;
toString(): string;
}
interface Reference extends firebase.database.Query {
child(path: string): firebase.database.Reference;
key: string | null;
onDisconnect(): firebase.database.OnDisconnect;
parent: firebase.database.Reference | null;
push(
value?: any,
onComplete?: (a: Error | null) => any
): firebase.database.ThenableReference;
remove(onComplete?: (a: Error | null) => any): Promise<any>;
root: firebase.database.Reference;
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
setPriority(
priority: string | number | null,
onComplete: (a: Error | null) => any
): Promise<any>;
setWithPriority(
newVal: any,
newPriority: string | number | null,
onComplete?: (a: Error | null) => any
): Promise<any>;
transaction(
transactionUpdate: (a: any) => any,
onComplete?: (
a: Error | null,
b: boolean,
c: firebase.database.DataSnapshot | null
) => any,
applyLocally?: boolean
): Promise<any>;
update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
}
interface ThenableReference
extends firebase.database.Reference,
PromiseLike<any> {}
function enableLogging(
logger?: boolean | ((a: string) => any),
persistent?: boolean
): any;
}
declare namespace firebase.database.ServerValue {
var TIMESTAMP: Object;
}
declare namespace firebase.messaging {
interface Messaging {
deleteToken(token: string): Promise<boolean>;
getToken(): Promise<string | null>;
onMessage(
nextOrObserver: firebase.NextFn<any> | firebase.Observer<any>,
error?: firebase.ErrorFn,
completed?: firebase.CompleteFn
): firebase.Unsubscribe;
onTokenRefresh(
nextOrObserver: firebase.NextFn<any> | firebase.Observer<any>,
error?: firebase.ErrorFn,
completed?: firebase.CompleteFn
): firebase.Unsubscribe;
requestPermission(): Promise<void>;
setBackgroundMessageHandler(
callback: (payload: any) => Promise<any> | void
): void;
useServiceWorker(registration: ServiceWorkerRegistration): void;
usePublicVapidKey(b64PublicKey: string): void;
}
function isSupported(): boolean;
}
declare namespace firebase.storage {
interface FullMetadata extends firebase.storage.UploadMetadata {
bucket: string;
/**
* @deprecated
* Use Reference.getDownloadURL instead. This property will be removed in a
* future release.
*/
downloadURLs: string[];
fullPath: string;
generation: string;
metageneration: string;
name: string;
size: number;
timeCreated: string;
updated: string;
}
interface Reference {
bucket: string;
child(path: string): firebase.storage.Reference;
delete(): Promise<any>;
fullPath: string;
getDownloadURL(): Promise<any>;
getMetadata(): Promise<any>;
name: string;
parent: firebase.storage.Reference | null;
put(
data: any | any | any,
metadata?: firebase.storage.UploadMetadata
): firebase.storage.UploadTask;
putString(
data: string,
format?: firebase.storage.StringFormat,
metadata?: firebase.storage.UploadMetadata
): firebase.storage.UploadTask;
root: firebase.storage.Reference;
storage: firebase.storage.Storage;
toString(): string;
updateMetadata(metadata: firebase.storage.SettableMetadata): Promise<any>;
}
interface SettableMetadata {
cacheControl?: string | null;
contentDisposition?: string | null;
contentEncoding?: string | null;
contentLanguage?: string | null;
contentType?: string | null;
customMetadata?: {
[/* warning: coerced from ? */ key: string]: string;
} | null;
}
interface Storage {
app: firebase.app.App;
maxOperationRetryTime: number;
maxUploadRetryTime: number;
ref(path?: string): firebase.storage.Reference;
refFromURL(url: string): firebase.storage.Reference;
setMaxOperationRetryTime(time: number): any;
setMaxUploadRetryTime(time: number): any;
}
type StringFormat = string;
var StringFormat: {
BASE64: StringFormat;
BASE64URL: StringFormat;
DATA_URL: StringFormat;
RAW: StringFormat;
};
type TaskEvent = string;
var TaskEvent: {
STATE_CHANGED: TaskEvent;
};
type TaskState = string;
var TaskState: {
CANCELED: TaskState;
ERROR: TaskState;
PAUSED: TaskState;
RUNNING: TaskState;
SUCCESS: TaskState;
};
interface UploadMetadata extends firebase.storage.SettableMetadata {
md5Hash?: string | null;
}
interface UploadTask {
cancel(): boolean;
catch(onRejected: (a: Error) => any): Promise<any>;
on(
event: firebase.storage.TaskEvent,
nextOrObserver?: firebase.Observer<any> | null | ((a: Object) => any),
error?: ((a: Error) => any) | null,
complete?: (firebase.Unsubscribe) | null
): Function;
pause(): boolean;
resume(): boolean;
snapshot: firebase.storage.UploadTaskSnapshot;
then(
onFulfilled?: ((a: firebase.storage.UploadTaskSnapshot) => any) | null,
onRejected?: ((a: Error) => any) | null
): Promise<any>;
}
interface UploadTaskSnapshot {
bytesTransferred: number;
/**
* @deprecated
* Use Reference.getDownloadURL instead. This property will be removed in a
* future release.
*/
downloadURL: string | null;
metadata: firebase.storage.FullMetadata;
ref: firebase.storage.Reference;
state: firebase.storage.TaskState;
task: firebase.storage.UploadTask;
totalBytes: number;
}
}
declare namespace firebase.firestore {
/**
* Document data (for use with `DocumentReference.set()`) consists of fields
* mapped to values.
*/
export type DocumentData = { [field: string]: any };
/**
* Update data (for use with `DocumentReference.update()`) consists of field
* paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots
* reference nested fields within the document.
*/
export type UpdateData = { [fieldPath: string]: any };
/**
* Constant used to indicate the LRU garbage collection should be disabled.
* Set this value as the `cacheSizeBytes` on the settings passed to the
* `Firestore` instance.
*/
export const CACHE_SIZE_UNLIMITED: number;
/** Settings used to configure a `Firestore` instance. */
export interface Settings {
/** The hostname to connect to. */
host?: string;
/** Whether to use SSL when connecting. */
ssl?: boolean;
/**
* Enables the use of `Timestamp`s for timestamp fields in
* `DocumentSnapshot`s.
*
* Currently, Firestore returns timestamp fields as `Date` but `Date` only
* supports millisecond precision, which leads to truncation and causes
* unexpected behavior when using a timestamp from a snapshot as a part
* of a subsequent query.
*
* Setting `timestampsInSnapshots` to true will cause Firestore to return
* `Timestamp` values instead of `Date` avoiding this kind of problem. To make
* this work you must also change any code that uses `Date` to use `Timestamp`
* instead.
*
* NOTE: in the future `timestampsInSnapshots: true` will become the
* default and this option will be removed so you should change your code to
* use Timestamp now and opt-in to this new behavior as soon as you can.
*/
timestampsInSnapshots?: boolean;
/**
* An approximate cache size threshold for the on-disk data. If the cache grows beyond this
* size, Firestore will start removing data that hasn't been recently used. The size is not a
* guarantee that the cache will stay below that size, only that if the cache exceeds the given
* size, cleanup will be attempted.
*
* The default value is 40 MB. The threshold must be set to at least 1 MB, and can be set to
* CACHE_SIZE_UNLIMITED to disable garbage collection.
*/
cacheSizeBytes?: number;
}
/**
* Settings that can be passed to Firestore.enablePersistence() to configure
* Firestore persistence.
*/
export interface PersistenceSettings {
/**
* Whether to synchronize the in-memory state of multiple tabs. Setting this
* to 'true' in all open tabs enables shared access to local persistence,
* shared execution of queries and latency-compensated local document updates
* across all connected instances.
*
* To enable this mode, `experimentalTabSynchronization:true` needs to be set
* globally in all active tabs. If omitted or set to 'false',
* `enablePersistence()` will fail in all but the first tab.
*
* NOTE: This mode is not yet recommended for production use.
*/
experimentalTabSynchronization?: boolean;
}
export type LogLevel = 'debug' | 'error' | 'silent';
export function setLogLevel(logLevel: LogLevel): void;
/**
* `Firestore` represents a Firestore Database and is the entry point for all
* Firestore operations.
*/
export class Firestore {
private constructor();
/**
* Specifies custom settings to be used to configure the `Firestore`
* instance. Must be set before invoking any other methods.
*
* @param settings The settings to use.
*/
settings(settings: Settings): void;
/**
* Attempts to enable persistent storage, if possible.
*
* Must be called before any other methods (other than settings()).
*
* If this fails, enablePersistence() will reject the promise it returns.
* Note that even after this failure, the firestore instance will remain
* usable, however offline persistence will be disabled.
*
* There are several reasons why this can fail, which can be identified by
* the `code` on the error.
*
* * failed-precondition: The app is already open in another browser tab.
* * unimplemented: The browser is incompatible with the offline
* persistence implementation.
*
* @param settings Optional settings object to configure persistence.
* @return A promise that represents successfully enabling persistent
* storage.
*/
enablePersistence(settings?: PersistenceSettings): Promise<void>;
/**
* Gets a `CollectionReference` instance that refers to the collection at
* the specified path.
*
* @param collectionPath A slash-separated path to a collection.
* @return The `CollectionReference` instance.
*/
collection(collectionPath: string): CollectionReference;
/**
* Gets a `DocumentReference` instance that refers to the document at the
* specified path.
*
* @param documentPath A slash-separated path to a document.
* @return The `DocumentReference` instance.
*/
doc(documentPath: string): DocumentReference;
/**
* Executes the given updateFunction and then attempts to commit the
* changes applied within the transaction. If any document read within the
* transaction has changed, the updateFunction will be retried. If it fails
* to commit after 5 attempts, the transaction will fail.
*
* @param updateFunction The function to execute within the transaction
* context.
* @return If the transaction completed successfully or was explicitly
* aborted (by the updateFunction returning a failed Promise), the Promise
* returned by the updateFunction will be returned here. Else if the
* transaction failed, a rejected Promise with the corresponding failure
* error will be returned.
*/
runTransaction<T>(
updateFunction: (transaction: Transaction) => Promise<T>
): Promise<T>;
/**
* Creates a write batch, used for performing multiple writes as a single
* atomic operation.
*/
batch(): WriteBatch;
/**
* The `FirebaseApp` associated with this `Firestore` instance.
*/
app: firebase.app.App;
/**
* Re-enables use of the network for this Firestore instance after a prior
* call to disableNetwork().
*
* @return A promise that is resolved once the network has been enabled.
*/
enableNetwork(): Promise<void>;
/**
* Disables network usage for this instance. It can be re-enabled via
* enableNetwork(). While the network is disabled, any snapshot listeners or
* get() calls will return results from cache, and any write operations will
* be queued until the network is restored.
*
* @return A promise that is resolved once the network has been disabled.
*/
disableNetwork(): Promise<void>;
INTERNAL: { delete: () => Promise<void> };
}
/**
* An immutable object representing a geo point in Firestore. The geo point
* is represented as latitude/longitude pair.
*
* Latitude values are in the range of [-90, 90].
* Longitude values are in the range of [-180, 180].
*/
export class GeoPoint {
/**
* Creates a new immutable GeoPoint object with the provided latitude and
* longitude values.
* @param latitude The latitude as number between -90 and 90.
* @param longitude The longitude as number between -180 and 180.
*/
constructor(latitude: number, longitude: number);
readonly latitude: number;
readonly longitude: number;
/**
* Returns true if this `GeoPoint` is equal to the provided one.
*
* @param other The `GeoPoint` to compare against.
* @return true if this `GeoPoint` is equal to the provided one.
*/
isEqual(other: GeoPoint): boolean;
}
/**
* A Timestamp represents a point in time independent of any time zone or
* calendar, represented as seconds and fractions of seconds at nanosecond
* resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian
* Calendar which extends the Gregorian calendar backwards to year one. It is
* encoded assuming all minutes are 60 seconds long, i.e. leap seconds are
* "smeared" so that no leap second table is needed for interpretation. Range is
* from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
*
* @see https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto
*/
export class Timestamp {
/**
* Creates a new timestamp with the current date, with millisecond precision.
*
* @return a new timestamp representing the current date.
*/
static now(): Timestamp;
/**
* Creates a new timestamp from the given date.
*
* @param date The date to initialize the `Timestamp` from.
* @return A new `Timestamp` representing the same point in time as the given
* date.
*/
static fromDate(date: Date): Timestamp;
/**
* Creates a new timestamp from the given number of milliseconds.
*
* @param milliseconds Number of milliseconds since Unix epoch
* 1970-01-01T00:00:00Z.
* @return A new `Timestamp` representing the same point in time as the given
* number of milliseconds.
*/
static fromMillis(milliseconds: number): Timestamp;