1
1
import { createSnapshot , extractRefs , FirestoreSerializer } from './utils'
2
2
import { walkGet , callOnceWithArg , OperationsType } from '../shared'
3
- import { firestore } from 'firebase'
3
+ import firebase from 'firebase/app '
4
4
5
5
export interface FirestoreOptions {
6
6
maxRefDepth ?: number
@@ -21,7 +21,7 @@ interface FirestoreSubscription {
21
21
unsub : ( ) => void
22
22
// Firestore unique key eg: items/12
23
23
path : string
24
- data : ( ) => firestore . DocumentData | null
24
+ data : ( ) => firebase . firestore . DocumentData | null
25
25
// // path inside the object to access the data items.3
26
26
// key: string
27
27
}
@@ -36,7 +36,7 @@ function updateDataFromDocumentSnapshot(
36
36
options : Required < FirestoreOptions > ,
37
37
target : CommonBindOptionsParameter [ 'vm' ] ,
38
38
path : string ,
39
- snapshot : firestore . DocumentSnapshot ,
39
+ snapshot : firebase . firestore . DocumentSnapshot ,
40
40
subs : Record < string , FirestoreSubscription > ,
41
41
ops : CommonBindOptionsParameter [ 'ops' ] ,
42
42
depth : number ,
@@ -53,7 +53,7 @@ interface SubscribeToDocumentParamater {
53
53
depth : number
54
54
resolve : ( ) => void
55
55
ops : CommonBindOptionsParameter [ 'ops' ]
56
- ref : firestore . DocumentReference
56
+ ref : firebase . firestore . DocumentReference
57
57
}
58
58
59
59
function subscribeToDocument (
@@ -79,7 +79,7 @@ function subscribeToDocument(
79
79
interface SubscribeToRefsParameter {
80
80
subs : Record < string , FirestoreSubscription >
81
81
target : CommonBindOptionsParameter [ 'vm' ]
82
- refs : Record < string , firestore . DocumentReference >
82
+ refs : Record < string , firebase . firestore . DocumentReference >
83
83
path : string | number
84
84
depth : number
85
85
resolve : CommonBindOptionsParameter [ 'resolve' ]
@@ -94,7 +94,7 @@ function subscribeToRefs(
94
94
target : CommonBindOptionsParameter [ 'vm' ] ,
95
95
path : string | number ,
96
96
subs : Record < string , FirestoreSubscription > ,
97
- refs : Record < string , firestore . DocumentReference > ,
97
+ refs : Record < string , firebase . firestore . DocumentReference > ,
98
98
ops : CommonBindOptionsParameter [ 'ops' ] ,
99
99
depth : number ,
100
100
resolve : CommonBindOptionsParameter [ 'resolve' ]
@@ -159,7 +159,7 @@ interface CommonBindOptionsParameter {
159
159
}
160
160
161
161
interface BindCollectionParamater extends CommonBindOptionsParameter {
162
- collection : firestore . CollectionReference | firestore . Query
162
+ collection : firebase . firestore . CollectionReference | firebase . firestore . Query
163
163
}
164
164
165
165
// TODO: refactor without using an object to improve size like the other functions
@@ -179,14 +179,14 @@ export function bindCollection(
179
179
const arraySubs : Record < string , FirestoreSubscription > [ ] = [ ]
180
180
181
181
const change = {
182
- added : ( { newIndex, doc } : firestore . DocumentChange ) => {
182
+ added : ( { newIndex, doc } : firebase . firestore . DocumentChange ) => {
183
183
arraySubs . splice ( newIndex , 0 , Object . create ( null ) )
184
184
const subs = arraySubs [ newIndex ]
185
185
const [ data , refs ] = extractRefs ( options . serialize ( doc ) , undefined , subs )
186
186
ops . add ( array , newIndex , data )
187
187
subscribeToRefs ( options , array , newIndex , subs , refs , ops , 0 , resolve . bind ( null , doc ) )
188
188
} ,
189
- modified : ( { oldIndex, newIndex, doc } : firestore . DocumentChange ) => {
189
+ modified : ( { oldIndex, newIndex, doc } : firebase . firestore . DocumentChange ) => {
190
190
const subs = arraySubs [ oldIndex ]
191
191
const oldData = array [ oldIndex ]
192
192
const [ data , refs ] = extractRefs ( options . serialize ( doc ) , oldData , subs )
@@ -197,7 +197,7 @@ export function bindCollection(
197
197
ops . add ( array , newIndex , data )
198
198
subscribeToRefs ( options , array , newIndex , subs , refs , ops , 0 , resolve )
199
199
} ,
200
- removed : ( { oldIndex } : firestore . DocumentChange ) => {
200
+ removed : ( { oldIndex } : firebase . firestore . DocumentChange ) => {
201
201
ops . remove ( array , oldIndex )
202
202
unsubscribeAll ( arraySubs . splice ( oldIndex , 1 ) [ 0 ] )
203
203
} ,
@@ -215,7 +215,7 @@ export function bindCollection(
215
215
typeof snapshot . docChanges === 'function'
216
216
? snapshot . docChanges ( )
217
217
: /* istanbul ignore next to support firebase < 5*/
218
- ( ( snapshot . docChanges as unknown ) as firestore . DocumentChange [ ] )
218
+ ( ( snapshot . docChanges as unknown ) as firebase . firestore . DocumentChange [ ] )
219
219
220
220
if ( ! isResolved && docChanges . length ) {
221
221
// isResolved is only meant to make sure we do the check only once
@@ -263,7 +263,7 @@ export function bindCollection(
263
263
}
264
264
265
265
interface BindDocumentParamater extends CommonBindOptionsParameter {
266
- document : firestore . DocumentReference
266
+ document : firebase . firestore . DocumentReference
267
267
}
268
268
269
269
/**
0 commit comments