-
-
Notifications
You must be signed in to change notification settings - Fork 554
/
index.d.ts
1392 lines (1262 loc) · 43.9 KB
/
index.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
import * as React from 'react'
import { FirebaseNamespace } from '@firebase/app-types'
import * as FirestoreTypes from '@firebase/firestore-types'
import * as DatabaseTypes from '@firebase/database-types'
import * as StorageTypes from '@firebase/storage-types'
import * as AuthTypes from '@firebase/auth-types'
import { Dispatch } from 'redux'
/**
* Diff / Omit taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
*/
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
type FileOrBlob<T> = T extends File ? File : Blob
/**
* Injects props and removes them from the prop requirements.
* Will not pass through the injected props if they are passed in during
* render. Also adds new prop requirements from TNeedsProps.
*/
export interface InferableComponentEnhancerWithProps<
TInjectedProps,
TNeedsProps
> {
<P extends TInjectedProps>(
component: React.ComponentType<P>
): React.ComponentType<Omit<P, keyof TInjectedProps> & TNeedsProps>
}
type mapper<TInner, TOutter> = (input: TInner) => TOutter
/**
* Redux action types for react-redux-firebase
* @see https://react-redux-firebase.com/docs/api/constants.html#actiontypes
*/
export const actionTypes: {
START: string
SET: string
REMOVE: string
MERGE: string
SET_PROFILE: string
LOGIN: string
LOGOUT: string
LOGIN_ERROR: string
NO_VALUE: string
UNAUTHORIZED_ERROR: string
ERROR: string
CLEAR_ERRORS: string
SET_LISTENER: string
UNSET_LISTENER: string
AUTHENTICATION_INIT_FINISHED: string
AUTHENTICATION_INIT_STARTED: string
SESSION_START: string
SESSION_END: string
FILE_UPLOAD_START: string
FILE_UPLOAD_ERROR: string
FILE_UPLOAD_PROGRESS: string
FILE_UPLOAD_COMPLETE: string
FILE_DELETE_START: string
FILE_DELETE_ERROR: string
FILE_DELETE_COMPLETE: string
AUTH_UPDATE_START: string
AUTH_UPDATE_ERROR: string
AUTH_UPDATE_SUCCESS: string
AUTH_EMPTY_CHANGE: string
AUTH_LINK_ERROR: string
AUTH_LINK_START: string
AUTH_LINK_SUCCESS: string
AUTH_RELOAD_ERROR: string
AUTH_RELOAD_START: string
AUTH_RELOAD_SUCCESS: string
EMAIL_UPDATE_ERROR: string
EMAIL_UPDATE_START: string
EMAIL_UPDATE_SUCCESS: string
PROFILE_UPDATE_START: string
PROFILE_UPDATE_ERROR: string
PROFILE_UPDATE_SUCCESS: string
}
/**
* Constants used within react-redux-firbease
* @see https://react-redux-firebase.com/docs/api/constants.html
*/
export const constants: {
actionTypes: {
AUTHENTICATION_INIT_FINISHED: string
AUTHENTICATION_INIT_STARTED: string
AUTH_EMPTY_CHANGE: string
AUTH_LINK_ERROR: string
AUTH_LINK_START: string
AUTH_LINK_SUCCESS: string
AUTH_RELOAD_ERROR: string
AUTH_RELOAD_START: string
AUTH_RELOAD_SUCCESS: string
AUTH_UPDATE_ERROR: string
AUTH_UPDATE_START: string
AUTH_UPDATE_SUCCESS: string
CLEAR_ERRORS: string
EMAIL_UPDATE_ERROR: string
EMAIL_UPDATE_START: string
EMAIL_UPDATE_SUCCESS: string
ERROR: string
FILE_DELETE_COMPLETE: string
FILE_DELETE_ERROR: string
FILE_DELETE_START: string
FILE_UPLOAD_COMPLETE: string
FILE_UPLOAD_ERROR: string
FILE_UPLOAD_PROGRESS: string
FILE_UPLOAD_START: string
LOGIN: string
LOGIN_ERROR: string
LOGOUT: string
MERGE: string
NO_VALUE: string
PROFILE_UPDATE_ERROR: string
PROFILE_UPDATE_START: string
PROFILE_UPDATE_SUCCESS: string
REMOVE: string
SESSION_END: string
SESSION_START: string
SET: string
SET_LISTENER: string
SET_PROFILE: string
START: string
UNAUTHORIZED_ERROR: string
UNSET_LISTENER: string
}
/**
* @see https://react-redux-firebase.com/docs/api/constants.html#defaultconfig
*/
defaultConfig: ReactReduxFirebaseConfig
}
/**
* Promise which resolves when auth state has loaded.
*/
export function authIsReady(store: any, ...args: any[]): any
interface RemoveOptions {
dispatchAction: boolean
}
/**
* https://firebase.google.com/docs/reference/js/firebase.database
*/
interface FirebaseDatabaseService {
database: {
(app?: string): DatabaseTypes.FirebaseDatabase
Reference: DatabaseTypes.Reference
Query: DatabaseTypes.Query
DataSnapshot: DatabaseTypes.DataSnapshot
enableLogging: typeof DatabaseTypes.enableLogging
ServerValue: DatabaseTypes.ServerValue
Database: typeof DatabaseTypes.FirebaseDatabase
}
}
/**
* Firestore instance extended with methods which dispatch
* redux actions.
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html
*/
interface BaseExtendedFirebaseInstance
extends DatabaseTypes.FirebaseDatabase,
FirebaseDatabaseService,
ExtendedAuthInstance,
ExtendedStorageInstance {
initializeAuth: VoidFunction
firestore: (() => ExtendedFirestoreInstance) & FirestoreStatics
dispatch: Dispatch
/**
* Sets data to Firebase.
* @param path - Path to location on Firebase which to set
* @param value - Value to write to Firebase
* @param onComplete - Function to run on complete (`not required`)
* @returns Containing reference snapshot
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#set
*/
set: (
path: string,
value: object | string | boolean | number | any,
onComplete?: Function
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Sets data to Firebase along with meta data. Currently,
* this includes createdAt and createdBy. *Warning* using this function
* may have unintended consequences (setting createdAt even if data already
* exists)
* @param path - Path to location on Firebase which to set
* @param value - Value to write to Firebase
* @param onComplete - Function to run on complete (`not required`)
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#setWithMeta
*/
setWithMeta: (
path: string,
value: object | string | boolean | number,
onComplete?: Function
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Pushes data to Firebase.
* @param path - Path to location on Firebase which to push
* @param value - Value to push to Firebase
* @param onComplete - Function to run on complete
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#push
*/
push: (
path: string,
value: object | string | boolean | number,
onComplete?: Function
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Pushes data to Firebase along with meta data. Currently,
* this includes createdAt and createdBy.
* @param path - Path to location on Firebase which to set
* @param value - Value to write to Firebase
* @param onComplete - Function to run on complete
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#pushWithMeta
*/
pushWithMeta: (
path: string,
value: object | string | boolean | number,
onComplete: Function
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Similar to the firebaseConnect Higher Order Component but
* presented as a function (not a React Component). Useful for populating
* your redux state without React, e.g., for server side rendering. Only
* `once` type should be used as other query types such as `value` do not
* return a Promise.
* @param watchArray - Array of objects or strings for paths to sync
* from Firebase. Can also be a function that returns the array. The function
* is passed the props object specified as the next parameter.
* @param options - The options object that you would like to pass to
* your watchArray generating function.
*/
promiseEvents: (
watchArray: (string | object)[],
options: object
) => Promise<any>
/**
* Updates data on Firebase and sends new data.
* @param path - Path to location on Firebase which to update
* @param value - Value to update to Firebase
* @param onComplete - Function to run on complete (`not required`)
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#update
*/
update: (
path: string,
value: object | string | boolean | number,
onComplete?: Function
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Updates data on Firebase along with meta. *Warning*
* using this function may have unintented consequences (setting
* createdAt even if data already exists)
* @param path - Path to location on Firebase which to update
* @param value - Value to update to Firebase
* @param onComplete - Function to run on complete
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateWithMeta
*/
updateWithMeta: (
path: string,
value: object | string | boolean | number,
onComplete?: Function
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Removes data from Firebase at a given path. **NOTE** A
* seperate action is not dispatched unless `dispatchRemoveAction: true` is
* provided to config on store creation. That means that a listener must
* be attached in order for state to be updated when calling remove.
* @param path - Path to location on Firebase which to remove
* @param onComplete - Function to run on complete
* @param options - Configuration for removal
* @param [options.dispatchAction=true] - Whether or not to dispatch REMOVE action
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#remove
*/
remove: (
path: string,
onComplete?: Function,
options?: RemoveOptions
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Sets data to Firebase only if the path does not already
* exist, otherwise it rejects. Internally uses a Firebase transaction to
* prevent a race condition between seperate clients calling uniqueSet.
* @param path - Path to location on Firebase which to set
* @param value - Value to write to Firebase
* @param onComplete - Function to run on complete (`not required`)
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#uniqueset
*/
uniqueSet: (
path: string,
value: object | string | boolean | number,
onComplete?: Function
) => Promise<DatabaseTypes.DataSnapshot>
/**
* Watch a path in Firebase Real Time Database.
* @param type - Type of event to watch for (defaults to value)
* @param path - Path to watch with watcher
* @param storeAs - Location within redux to store value
* @param options - List of parameters for the query
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#watchevent
*/
watchEvent: (
type: string,
path: string,
storeAs: string,
options?: object
) => Promise<any>
/**
* Unset a listener watch event. **Note:** this method is used
* internally so examples have not yet been created, and it may not work
* as expected.
* @param type - Type of watch event
* @param path - Path to location on Firebase which to unset listener
* @param queryId - Id of the listener
* @param options - Event options object
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#watchevent
*/
unWatchEvent: (
type: string,
path: string,
queryId: string,
options?: string
) => Promise<any>
}
/**
* OptionalOverride is left here in the event that any of the optional properties below need to be extended in the future.
* Example: OptionalOverride<FirebaseNamespace, 'messaging', { messaging: ExtendedMessagingInstance }>
*/
type OptionalOverride<T, b extends string, P> = b extends keyof T ? P : {}
type OptionalPick<T, b extends string> = Pick<T, b & keyof T>
type ExtendedFirebaseInstance = BaseExtendedFirebaseInstance & OptionalPick<FirebaseNamespace, 'messaging' | 'performance' | 'functions' | 'analytics' | 'remoteConfig'>
/**
* Create an extended firebase instance that has methods attached
* which dispatch redux actions.
* @param firebase - Firebase instance which to extend
* @param configs - Configuration object
* @param dispatch - Action dispatch function
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html
*/
export function createFirebaseInstance(
firebase: any,
configs: Partial<ReduxFirestoreConfig>,
dispatch: Dispatch
): ExtendedFirebaseInstance
export type QueryParamOption =
| 'orderByKey'
| 'orderByChild'
| 'orderByPriority'
| 'limitToFirst'
| 'limitToLast'
| 'notParsed'
| 'parsed'
export type QueryParamOptions = QueryParamOption | string[]
/**
* Options which can be passed to firebase query through react-redux-firebase
* @see https://react-redux-firebase.com/docs/queries.html
*/
export interface ReactReduxFirebaseQuerySetting {
path: string
type?:
| 'value'
| 'once'
| 'child_added'
| 'child_removed'
| 'child_changed'
| 'child_moved'
queryParams?: QueryParamOptions
storeAs?: string
populates?: { child: string; root: string }[]
}
/**
* List of query configuration objects for react-redux-firebase
*/
export type ReactReduxFirebaseQueries =
| (ReactReduxFirebaseQuerySetting | string)[]
| (ReactReduxFirebaseQuerySetting | string)
/**
* Function that recieves component props and returns
* a list of query configuration objects for react-redux-firebase
*/
export type ReactReduxFirebaseQueriesFunction = (
props?: any
) => ReactReduxFirebaseQueries
/**
* @see https://github.com/prescottprue/redux-firestore#query-options
*/
type WhereOptions = [string, FirestoreTypes.WhereFilterOp, any]
type OrderByOptions = [string, FirestoreTypes.OrderByDirection]
/**
* Options which can be passed to firestore query through
* redux-firestore or react-redux-firebase.
* @see https://github.com/prescottprue/redux-firestore#query-options
*/
export interface ReduxFirestoreQuerySetting {
/**
* Collection name
* @see https://github.com/prescottprue/redux-firestore#collection
*/
collection?: string
/**
* Collection Group name
* @see https://github.com/prescottprue/redux-firestore#collection-group
*/
collectionGroup?: string
/**
* Document id
* @see https://github.com/prescottprue/redux-firestore#document
*/
doc?: string
/**
* Subcollection path settings
* @see https://github.com/prescottprue/redux-firestore#sub-collections
*/
subcollections?: ReduxFirestoreQuerySetting[]
/**
* Where settings
* @see https://github.com/prescottprue/redux-firestore#where
*/
where?: WhereOptions | WhereOptions[]
/**
* @see https://github.com/prescottprue/redux-firestore#orderby
*/
orderBy?: OrderByOptions | OrderByOptions[]
/**
* @see https://github.com/prescottprue/redux-firestore#limit
*/
limit?: number
/**
* @see https://github.com/prescottprue/redux-firestore#storeas
*/
storeAs?: string
/**
* @see https://github.com/prescottprue/redux-firestore#startat
*/
startAt?: FirestoreTypes.DocumentSnapshot | any | any[]
/**
* @see https://github.com/prescottprue/redux-firestore#startafter
*/
startAfter?: FirestoreTypes.DocumentSnapshot | any | any[]
/**
* @see https://github.com/prescottprue/redux-firestore#endat
*/
endAt?: FirestoreTypes.DocumentSnapshot | any | any[]
/**
* @see https://github.com/prescottprue/redux-firestore#endbefore
*/
endBefore?: FirestoreTypes.DocumentSnapshot | any | any[]
/**
* @see https://github.com/prescottprue/redux-firestore#population
*/
populates?: { child: string; root: string }[]
}
/**
* List of query configuration objects for redux-firestore
*/
export type ReduxFirestoreQueries =
| (ReduxFirestoreQuerySetting | string)[]
| (ReduxFirestoreQuerySetting | string)
/**
* Function that receives component props and returns
* a list of query configuration objects for redux-firestore
*/
export type ReduxFirestoreQueriesFunction = (
props?: any
) => ReduxFirestoreQueries
/**
* Firestore instance extended with methods which dispatch redux actions.
* @see https://github.com/prescottprue/redux-firestore#api
*/
interface ExtendedFirestoreInstance
extends FirestoreTypes.FirebaseFirestore, FirestoreStatics {
/**
* Get data from firestore.
* @see https://github.com/prescottprue/redux-firestore#get
*/
get: <T>(
docPath: string | ReduxFirestoreQuerySetting
) => Promise<FirestoreTypes.DocumentSnapshot<Partial<T>>>
/**
* Set data to firestore.
* @see https://github.com/prescottprue/redux-firestore#set
*/
set: <T>(
docPath: string | ReduxFirestoreQuerySetting,
data: Partial<T>,
options?: FirestoreTypes.SetOptions
) => Promise<FirestoreTypes.DocumentSnapshot<Partial<T>>>
/**
* Add document to firestore.
* @see https://github.com/prescottprue/redux-firestore#add
*/
add: <T>(
collectionPath: string | ReduxFirestoreQuerySetting,
data: Partial<T>
) => Promise<{ id: string }>
/**
* Update document within firestore.
* @see https://github.com/prescottprue/redux-firestore#update
*/
update: <T>(
docPath: string | ReduxFirestoreQuerySetting,
data: Partial<T>
) => Promise<FirestoreTypes.DocumentSnapshot<Partial<T>>>
/**
* Delete a document within firestore.
* @see https://github.com/prescottprue/redux-firestore#delete
*/
delete: <T>(docPath: string | ReduxFirestoreQuerySetting) => Promise<T>
/**
* Executes the given updateFunction and then attempts to commit the changes applied within the
* transaction.
* @see https://github.com/prescottprue/redux-firestore#runtransaction
*/
runTransaction: typeof FirestoreTypes.FirebaseFirestore.prototype.runTransaction
/**
* Sets a listener within redux-firestore
* @see https://github.com/prescottprue/redux-firestore#onsnapshotsetlistener
*/
onSnapshot: (options: ReduxFirestoreQuerySetting) => Promise<void>
/**
* Sets a listener within redux-firestore
* @see https://github.com/prescottprue/redux-firestore#onsnapshotsetlistener
*/
setListener: (options: ReduxFirestoreQuerySetting) => Promise<void>
/**
* Sets multiple firestore listeners created within redux-firestore
* @see https://github.com/prescottprue/redux-firestore#onsnapshotsetlisteners
*/
setListeners: (optionsArray: ReduxFirestoreQuerySetting[]) => Promise<void>
/**
* Unset firestore listener created within redux-firestore
* @see https://github.com/prescottprue/redux-firestore#unsetlistener--unsetlistener
*/
unsetListener: (options: ReduxFirestoreQuerySetting) => void
/**
* Unset multiple firestore listeners created within redux-firestore
* @see https://github.com/prescottprue/redux-firestore#unsetlistener--unsetlisteners
*/
unsetListeners: (options: ReduxFirestoreQuerySetting[]) => void
}
/**
* @see https://github.com/prescottprue/redux-firestore#other-firebase-statics
*/
interface FirestoreStatics {
FieldValue: typeof FirestoreTypes.FieldValue
FieldPath: FirestoreTypes.FieldPath
setLogLevel: (logLevel: FirestoreTypes.LogLevel) => void
Blob: FirestoreTypes.Blob
CollectionReference: FirestoreTypes.CollectionReference
DocumentReference: FirestoreTypes.DocumentReference
DocumentSnapshot: FirestoreTypes.DocumentSnapshot
GeoPoint: FirestoreTypes.GeoPoint
Query: FirestoreTypes.Query
QueryDocumentSnapshot: FirestoreTypes.QueryDocumentSnapshot
QuerySnapshot: FirestoreTypes.QuerySnapshot
Timestamp: typeof FirestoreTypes.FieldValue
Transaction: FirestoreTypes.Transaction
WriteBatch: FirestoreTypes.WriteBatch
}
export interface WithFirestoreProps {
firestore: ExtendedFirestoreInstance
firebase: ExtendedFirebaseInstance
dispatch: Dispatch
}
interface CreateUserCredentials {
email: string
password: string
signIn?: boolean // default true
}
type Credentials =
| CreateUserCredentials
| {
provider: 'facebook' | 'google' | 'twitter' | 'github' | 'microsoft.com' | 'apple.com' | 'yahoo.com'
type: 'popup' | 'redirect'
scopes?: string[]
}
| {
credential: AuthTypes.AuthCredential
}
| {
token: string
profile: Object
}
| {
phoneNumber: string
applicationVerifier: AuthTypes.ApplicationVerifier
}
type UserProfile<P extends object = {}> = P
/**
* Firebase JS SDK Auth instance extended with methods which dispatch redux actions.
* @see https://react-redux-firebase.com/docs/auth.html
*/
interface ExtendedAuthInstance {
auth: () => AuthTypes.FirebaseAuth
/**
* Logs user into Firebase.
* @param credentials - Credentials for authenticating
* @param credentials.provider - External provider (google |
* facebook | twitter)
* @param credentials.type - Type of external authentication
* (popup | redirect) (only used with provider)
* @param credentials.email - Credentials for authenticating
* @param credentials.password - Credentials for authenticating (only used with email)
* @see https://react-redux-firebase.com/docs/auth.html#logincredentials
*/
login: (credentials: Credentials) => Promise<AuthTypes.UserCredential>
/**
* Creates a new user in Firebase authentication. If
* `userProfile` config option is set, user profiles will be set to this
* location.
* @param credentials - Credentials for authenticating
* @param profile - Data to include within new user profile
* @see https://react-redux-firebase.com/docs/auth.html#createusercredentials-profile
*/
createUser: (
credentials: CreateUserCredentials,
profile?: UserProfile
) => Promise<AuthTypes.UserInfo>
/**
* Logs user out of Firebase and empties firebase state from
* redux store.
* @see https://react-redux-firebase.com/docs/auth.html#logout
*/
logout: () => Promise<void>
/**
* Sends password reset email.
* @param email - Email to send recovery email to
* @see https://react-redux-firebase.com/docs/auth.html#resetpasswordcredentials
*/
resetPassword: (email: string) => Promise<any>
/**
* Confirm that a user's password has been reset.
* @param code - Password reset code to verify
* @param password - New Password to confirm reset to
* @see https://react-redux-firebase.com/docs/auth.html#confirmpasswordresetcode-newpassword
*/
confirmPasswordReset: AuthTypes.FirebaseAuth['confirmPasswordReset']
// https://react-redux-firebase.com/docs/auth.html#verifypasswordresetcodecode
verifyPasswordResetCode: AuthTypes.FirebaseAuth['verifyPasswordResetCode']
// https://react-redux-firebase.com/docs/auth.html#applyactioncode
applyActionCode: AuthTypes.FirebaseAuth['applyActionCode']
/**
* Signs in using a phone number in an async pattern (i.e. requires calling a second method).
* @param phoneNumber - Update to be auth object
* @param appVerifier - Update in profile
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#signinwithphonenumber
*/
signInWithPhoneNumber: AuthTypes.FirebaseAuth['signInWithPhoneNumber']
/**
* Update user's email
* @param newEmail - Update to be auth object
* @param updateInProfile - Update in profile
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateemail
*/
updateEmail: (newEmail: string, updateInProfile?: boolean) => Promise<void>
/**
* Links the user account with the given credentials. Internally
* calls `firebase.auth().currentUser.reload`.
* @param credential - The auth credential
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#reloadauth
*/
reloadAuth: (credential?: AuthTypes.AuthCredential | any) => Promise<void>
/**
* Links the user account with the given credentials. Internally
* calls `firebase.auth().currentUser.linkWithCredential`.
* @param credential - Credential with which to link user account
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#linkwithcredential
*/
linkWithCredential: (
credential: AuthTypes.AuthCredential
) => Promise<AuthTypes.User>
/**
* Update Auth Object
* @param authUpdate - Update to be auth object
* @param updateInProfile - Update in profile
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateauth
*/
updateAuth: (
authUpdate: {
displayName?: string | null
photoURL?: string | null
},
updateInProfile?: boolean
) => Promise<void>
/**
* Update user profile on Firebase Real Time Database or
* Firestore (if `useFirestoreForProfile: true` config passed to
* reactReduxFirebase). Real Time Database update uses `update` method
* internally while updating profile on Firestore uses `set` with merge.
* @param profileUpdate - Profile data to place in new profile
* @param options - Options object (used to change how profile
* update occurs)
* @param [options.useSet=true] - Use set with merge instead of
* update. Setting to `false` uses update (can cause issue of profile document
* does not exist). Note: Only used when updating profile on Firestore
* @param [options.merge=true] - Whether or not to use merge when
* setting profile. Note: Only used when updating profile on Firestore
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateprofile
* @see https://react-redux-firebase.com/docs/recipes/profile.html#update-profile
*/
updateProfile: (profile: Partial<ProfileType>, options?: Object) => Promise<void>
/**
* Logs user into Firebase using external.
* @param authData - Auth data from Firebase's getRedirectResult
* @returns Resolves with user's profile
* @see https://react-redux-firebase.com/docs/recipes/auth.html
*/
handleRedirectResult: (authData: any) => Promise<any>
/**
* Re-authenticate user into Firebase. For examples, visit the
* [auth section of the docs](https://react-redux-firebase.com/docs/auth.html) or the
* [auth recipes section](https://react-redux-firebase.com/docs/recipes/auth.html).
* @param credentials - Credentials for authenticating
* @param credentials.provider - External provider (google |
* facebook | twitter)
* @param credentials.type - Type of external authentication
* (popup | redirect) (only used with provider)
* @returns Resolves with user's auth data
* @see https://react-redux-firebase.com/docs/auth.html#logincredentials
* @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#login
*/
reauthenticate: (credentials: any) => Promise<any>
}
/**
* Instance of Firebase Storage with methods that dispatch redux actions.
* @see https://react-redux-firebase.com/docs/storage.html
*/
interface ExtendedStorageInstance {
storage: () => StorageTypes.FirebaseStorage
/**
* Delete a file from Firebase Storage with the option to
* remove its metadata in Firebase Database.
* @param path - Path to location on Firebase which to set
* @param dbPath - Database path to place uploaded file metadata
* @see https://react-redux-firebase.com/docs/api/storage.html#deletefile
*/
deleteFile: (
path: string,
dbPath?: string
) => Promise<{ path: string; dbPath: string }>
/**
* Upload a file to Firebase Storage with the option to store
* its metadata in Firebase Database.
* @param path - Path to location on Firebase which to set
* @param file - File object to upload (usually first element from
* array output of select-file or a drag/drop `onDrop`)
* @param dbPath - Database path to place uploaded file metadata
* @param options - Options
* @param options.name - Name of the file
* @param options.metadata - Metadata associated with the file to upload to storage
* @param options.documentId - Id of document to update with metadata if using Firestore
* @see https://react-redux-firebase.com/docs/api/storage.html#uploadFile
*/
uploadFile: <T extends File | Blob>(
path: string,
file: FileOrBlob<T>,
dbPath?: string,
options?: UploadFileOptions<T>
) => Promise<{ uploadTaskSnapshot: StorageTypes.UploadTaskSnapshot }>
/**
* Upload multiple files to Firebase Storage with the option
* to store their metadata in Firebase Database.
* @param path - Path to location on Firebase which to set
* @param files - Array of File objects to upload (usually from
* a select-file or a drag/drop `onDrop`)
* @param dbPath - Database path to place uploaded files metadata.
* @param options - Options
* @param options.name - Name of the file
* @param options.metadata - Metadata associated with the file to upload to storage
* @param options.documentId - Id of document to update with metadata if using Firestore
* @see https://react-redux-firebase.com/docs/api/storage.html#uploadFiles
*/
uploadFiles: <T extends File | Blob>(
path: string,
files: FileOrBlob<T>[],
dbPath?: string,
options?: UploadFileOptions<T>
) => Promise<{ uploadTaskSnapshot: StorageTypes.UploadTaskSnapshot }[]>
}
/**
* Configuration object passed to uploadFile and uploadFiles functions
*/
export interface UploadFileOptions<T extends File | Blob> {
name?:
| string
| ((
file: FileOrBlob<T>,
internalFirebase: WithFirebaseProps<ProfileType>['firebase'],
uploadConfig: {
path: string
file: FileOrBlob<T>
dbPath?: string
options?: UploadFileOptions<T>
}
) => string)
documentId?:
| string
| ((
uploadRes: StorageTypes.UploadTaskSnapshot,
firebase: WithFirebaseProps<ProfileType>['firebase'],
metadata: StorageTypes.UploadTaskSnapshot['metadata'],
downloadURL: string
) => string)
useSetForMetadata?: boolean
metadata?: StorageTypes.UploadMetadata
metadataFactory?: (
uploadRes: StorageTypes.UploadTaskSnapshot,
firebase: WithFirebaseProps<ProfileType>['firebase'],
metadata: StorageTypes.UploadTaskSnapshot['metadata'],
downloadURL: string
) => object
}
export interface WithFirebaseProps<ProfileType> {
firebase: ExtendedFirebaseInstance
}
/**
* React Higher Order Component that automatically listens/unListens to
* Firebase Real Time Database on mount/unmount of the component. This uses
* React's Component Lifecycle hooks.
* @see https://react-redux-firebase.com/docs/api/firebaseConnect.html
*/
export function firebaseConnect<ProfileType, TInner = {}>(
queriesConfig?:
| mapper<TInner, ReactReduxFirebaseQueries>
| ReactReduxFirebaseQueries
): InferableComponentEnhancerWithProps<
TInner & WithFirebaseProps<ProfileType>,
WithFirebaseProps<ProfileType>
>
/**
* Reducer for Firebase state
* @param state - Current Firebase Redux State (state.firebase)
* @param action - Action which will modify state
* @param action.type - Type of Action being called
* @param action.path - Path of action that was dispatched
* @param action.data - Data associated with action
* @see https://react-redux-firebase.com/docs/getting_started.html#add-reducer
*/
export function firebaseReducer<
ProfileType extends Record<string, any> = {},
Schema extends Record<string, any> = {}
>(state: any, action: any): FirebaseReducer.Reducer<ProfileType, Schema>
export function makeFirebaseReducer<
ProfileType extends Record<string, any> = {},
Schema extends Record<string, any> = {}
>(): (state: any, action: any) => FirebaseReducer.Reducer<ProfileType, Schema>
/**
* React HOC that attaches/detaches Cloud Firestore listeners on mount/unmount
* @see https://react-redux-firebase.com/docs/api/firestoreConnect.html
*/
export function firestoreConnect<TInner = {}>(
connect?: mapper<TInner, ReduxFirestoreQueries> | ReduxFirestoreQueries
): InferableComponentEnhancerWithProps<
TInner & WithFirestoreProps,
WithFirestoreProps
>
/**
* Reducer for Firestore state
* @param state - Current Firebase Redux State (state.firestore)
* @param action - Action which will modify state
* @param action.type - Type of Action being called
* @param action.path - Path of action that was dispatched
* @param action.data - Data associated with action
* @see https://react-redux-firebase.com/docs/api/reducer.html
*/
export function firestoreReducer(
state: any,
action: any
): FirestoreReducer.Reducer
/**
* Fix path by adding "/" to path if needed
* @param path - Path string to fix
*/
export function fixPath(path: string): string
/**
* Get internal Firebase instance with methods which are wrapped with action dispatches. Useful for
* integrations into external libraries such as redux-thunk and redux-observable.
* @see https://react-redux-firebase.com/docs/api/getFirebase.html
*/
export function getFirebase(): ExtendedFirebaseInstance
/**
* Get a value from firebase using slash notation. This enables an easy
* migration from v1's dataToJS/pathToJS/populatedDataToJS functions to v2 syntax
* **NOTE:** Setting a default value will cause `isLoaded` to always return true
* @param firebase - Firebase instance (state.firebase)
* @param path - Path of parameter to load
* @param notSetValue - Value to return if value is not
* found in redux. This will cause `isLoaded` to always return true (since
* value is set from the start).
* @returns Data located at path within firebase.
* @see https://react-redux-firebase.com/docs/api/helpers.html#getval
*/
export function getVal(firebase: any, path: string, notSetValue?: any): any
/**
* Detect whether items are empty or not
* @param item - Item to check loaded status of. A comma seperated list
* is also acceptable.
* @returns Whether or not item is empty
* @see https://react-redux-firebase.com/docs/api/helpers.html#isempty
*/
export function isEmpty(...args: any[]): boolean
/**
* Detect whether data from redux state is loaded yet or not
* @param item - Item to check loaded status of. A comma separated
* list is also acceptable.
* @returns Whether or not item is loaded
* @see https://react-redux-firebase.com/docs/api/helpers.html#isloaded
*/
export function isLoaded<T>(arg: T | null | undefined): arg is T
export function isLoaded(...args: any[]): boolean
/**
* React hook that provides `firebase` object. Extended Firebase
* instance is gathered from `ReactReduxFirebaseContext`.
* @see https://react-redux-firebase.com/docs/api/useFirebase.html
*/
export function useFirebase(): ExtendedFirebaseInstance
/**
* React hook that automatically listens/unListens
* to provided Cloud Firestore paths. Make sure you have required/imported
* Cloud Firestore, including it's reducer, before attempting to use.
* @param queriesConfig - An object or string for paths to sync
* from firestore. Can also be a function that returns the object or string.