-
Notifications
You must be signed in to change notification settings - Fork 57
/
index.d.ts
178 lines (160 loc) · 5.68 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
import * as firebase from 'firebase'
import { Action } from 'redux'
import { Buffer, Channel, SagaIterator } from 'redux-saga'
interface SyncOptions<S, T> {
successActionCreator: (data: S | T) => Action
failureActionCreator?: (error: Error) => Action
transform?: (data: S) => T
}
declare enum FirestoreType {
Collection = 'collection',
Document = 'document',
}
declare namespace PathOrRef {
type Base<R> = string | R
type Collection = Base<
firebase.firestore.CollectionReference | firebase.firestore.Query
>
type Database = Base<firebase.database.Reference>
type Document = Base<firebase.firestore.DocumentReference>
type Storage = Base<firebase.storage.Reference>
type Firestore = Database | Document
}
declare namespace ChannelOutput {
namespace Auth {
interface User {
user: firebase.User
}
interface Error {
error: firebase.auth.Error
}
}
type Auth = Auth.User | Auth.Error
type Database = {
snapshot: firebase.database.DataSnapshot
value: any
}
type Firestore = firebase.firestore.QuerySnapshot | firebase.firestore.DocumentSnapshot
namespace Messaging {
type Message = object
type Token = string
}
}
interface Auth {
applyActionCode: (code: string) => SagaIterator
channel: () => Channel<ChannelOutput.Auth>
confirmPasswordReset: (code: string, newPassword: string) => SagaIterator
createUserWithEmailAndPassword: (email: string, password: string) => firebase.User
deleteProfile: () => SagaIterator
linkWithPopup: (authProvider: firebase.auth.AuthProvider) => SagaIterator
linkWithRedirect: (authProvider: firebase.auth.AuthProvider) => SagaIterator
sendEmailVerification: (
actionCodeSettings: firebase.auth.ActionCodeSettings,
) => SagaIterator
sendPasswordResetEmail: (
email: string,
actionCodeSettings: firebase.auth.ActionCodeSettings,
) => SagaIterator
signInAndRetrieveDataWithCredential: (
credential: firebase.auth.AuthCredential,
) => SagaIterator
signInAnonymously: () => SagaIterator
signInWithCredential: (credential: firebase.auth.AuthCredential) => SagaIterator
signInWithCustomToken: (token: string) => SagaIterator
signInWithEmailAndPassword: (email: string, password: string) => SagaIterator
signInWithPhoneNumber: (
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier,
) => SagaIterator
signInWithPopup: (authProvider: firebase.auth.AuthProvider) => SagaIterator
signInWithRedirect: (authProvider: firebase.auth.AuthProvider) => SagaIterator
signOut: () => SagaIterator
unlink: (provider: string) => SagaIterator
updateEmail: (email: string) => SagaIterator
updatePassword: (password: string) => SagaIterator
updateProfile: (profile: object) => SagaIterator
}
interface Database {
read: (pathOrRef: PathOrRef.Database) => SagaIterator
create: (pathOrRef: PathOrRef.Database, data: any) => SagaIterator
update: (pathOrRef: PathOrRef.Database, data: any) => SagaIterator
patch: (pathOrRef: PathOrRef.Database, data: any) => SagaIterator
delete: (pathOrRef: PathOrRef.Database) => SagaIterator
channel: (
pathOrRef: PathOrRef.Database,
event?: string,
buffer?: Buffer<any>,
) => Channel<ChannelOutput.Database>
sync: (pathOrRef: PathOrRef.Database, options: object, event: string) => SagaIterator
}
interface Firestore {
addDocument: (collectionRef: PathOrRef.Collection, data: object) => SagaIterator
channel: (
pathOrRef: PathOrRef.Firestore,
type?: FirestoreType,
buffer?: Buffer<any>,
) => Channel<ChannelOutput.Firestore>
deleteDocument: (documentRef: PathOrRef.Document) => SagaIterator
getCollection: (collectionRef: PathOrRef.Collection) => SagaIterator
getDocument: (documentRef: PathOrRef.Document) => SagaIterator
setDocument: (
documentRef: PathOrRef.Document,
data: object,
options: firebase.firestore.SetOptions,
) => SagaIterator
syncCollection: <T>(
collectionRef: PathOrRef.Collection,
options: SyncOptions<ChannelOutput.Firestore, T>,
) => SagaIterator
syncDocument: <T>(
documentRef: PathOrRef.Document,
options: SyncOptions<ChannelOutput.Firestore, T>,
) => SagaIterator
updateDocument: (documentRef: PathOrRef.Document, ...args: any[]) => SagaIterator
}
interface Functions {
call: (functionName: string, queryParams: object, init: object) => any
}
interface Messaging {
channel: () => Channel<ChannelOutput.Messaging.Message>
syncMessages: <T>(
options: SyncOptions<ChannelOutput.Messaging.Message, T>,
) => SagaIterator
syncToken: <T>(options: SyncOptions<ChannelOutput.Messaging.Token, T>) => SagaIterator
tokenRefreshChannel: () => Channel<ChannelOutput.Messaging.Token>
}
interface Storage {
uploadFile: (
pathOrRef: PathOrRef.Storage,
file: Blob | Uint8Array | ArrayBuffer,
metadata?: firebase.storage.UploadMetadata,
) => firebase.storage.UploadTask
uploadString: (
pathOrRef: PathOrRef.Storage,
string: string,
format: firebase.storage.StringFormat,
metadata: firebase.storage.UploadMetadata,
) => firebase.storage.UploadTask
getDownloadURL: (pathOrRef: PathOrRef.Storage) => SagaIterator
getFileMetadata: (pathOrRef: PathOrRef.Storage) => SagaIterator
updateFileMetadata: (
pathOrRef: PathOrRef.Storage,
newMetadata: firebase.storage.SettableMetadata,
) => SagaIterator
deleteFile: (pathOrRef: PathOrRef.Storage) => SagaIterator
}
declare class ReduxSagaFirebase {
app: firebase.app.App
region: string
_projectId: string
_authChannel: Channel<ChannelOutput.Auth>
auth: Auth
database: Database
firestore: Firestore
functions: Functions
messaging: Messaging
storage: Storage
constructor(firebaseApp: firebase.app.App)
projectId(): string
}
export default ReduxSagaFirebase