11import { createSnapshot , extractRefs , FirestoreSerializer } from './utils'
22import { walkGet , callOnceWithArg , OperationsType } from '../shared'
3- import { firestore } from 'firebase'
3+ import firebase from 'firebase/app '
44
55export interface FirestoreOptions {
66 maxRefDepth ?: number
@@ -21,7 +21,7 @@ interface FirestoreSubscription {
2121 unsub : ( ) => void
2222 // Firestore unique key eg: items/12
2323 path : string
24- data : ( ) => firestore . DocumentData | null
24+ data : ( ) => firebase . firestore . DocumentData | null
2525 // // path inside the object to access the data items.3
2626 // key: string
2727}
@@ -36,7 +36,7 @@ function updateDataFromDocumentSnapshot(
3636 options : Required < FirestoreOptions > ,
3737 target : CommonBindOptionsParameter [ 'vm' ] ,
3838 path : string ,
39- snapshot : firestore . DocumentSnapshot ,
39+ snapshot : firebase . firestore . DocumentSnapshot ,
4040 subs : Record < string , FirestoreSubscription > ,
4141 ops : CommonBindOptionsParameter [ 'ops' ] ,
4242 depth : number ,
@@ -53,7 +53,7 @@ interface SubscribeToDocumentParamater {
5353 depth : number
5454 resolve : ( ) => void
5555 ops : CommonBindOptionsParameter [ 'ops' ]
56- ref : firestore . DocumentReference
56+ ref : firebase . firestore . DocumentReference
5757}
5858
5959function subscribeToDocument (
@@ -79,7 +79,7 @@ function subscribeToDocument(
7979interface SubscribeToRefsParameter {
8080 subs : Record < string , FirestoreSubscription >
8181 target : CommonBindOptionsParameter [ 'vm' ]
82- refs : Record < string , firestore . DocumentReference >
82+ refs : Record < string , firebase . firestore . DocumentReference >
8383 path : string | number
8484 depth : number
8585 resolve : CommonBindOptionsParameter [ 'resolve' ]
@@ -94,7 +94,7 @@ function subscribeToRefs(
9494 target : CommonBindOptionsParameter [ 'vm' ] ,
9595 path : string | number ,
9696 subs : Record < string , FirestoreSubscription > ,
97- refs : Record < string , firestore . DocumentReference > ,
97+ refs : Record < string , firebase . firestore . DocumentReference > ,
9898 ops : CommonBindOptionsParameter [ 'ops' ] ,
9999 depth : number ,
100100 resolve : CommonBindOptionsParameter [ 'resolve' ]
@@ -159,7 +159,7 @@ interface CommonBindOptionsParameter {
159159}
160160
161161interface BindCollectionParamater extends CommonBindOptionsParameter {
162- collection : firestore . CollectionReference | firestore . Query
162+ collection : firebase . firestore . CollectionReference | firebase . firestore . Query
163163}
164164
165165// TODO: refactor without using an object to improve size like the other functions
@@ -179,14 +179,14 @@ export function bindCollection(
179179 const arraySubs : Record < string , FirestoreSubscription > [ ] = [ ]
180180
181181 const change = {
182- added : ( { newIndex, doc } : firestore . DocumentChange ) => {
182+ added : ( { newIndex, doc } : firebase . firestore . DocumentChange ) => {
183183 arraySubs . splice ( newIndex , 0 , Object . create ( null ) )
184184 const subs = arraySubs [ newIndex ]
185185 const [ data , refs ] = extractRefs ( options . serialize ( doc ) , undefined , subs )
186186 ops . add ( array , newIndex , data )
187187 subscribeToRefs ( options , array , newIndex , subs , refs , ops , 0 , resolve . bind ( null , doc ) )
188188 } ,
189- modified : ( { oldIndex, newIndex, doc } : firestore . DocumentChange ) => {
189+ modified : ( { oldIndex, newIndex, doc } : firebase . firestore . DocumentChange ) => {
190190 const subs = arraySubs [ oldIndex ]
191191 const oldData = array [ oldIndex ]
192192 const [ data , refs ] = extractRefs ( options . serialize ( doc ) , oldData , subs )
@@ -197,7 +197,7 @@ export function bindCollection(
197197 ops . add ( array , newIndex , data )
198198 subscribeToRefs ( options , array , newIndex , subs , refs , ops , 0 , resolve )
199199 } ,
200- removed : ( { oldIndex } : firestore . DocumentChange ) => {
200+ removed : ( { oldIndex } : firebase . firestore . DocumentChange ) => {
201201 ops . remove ( array , oldIndex )
202202 unsubscribeAll ( arraySubs . splice ( oldIndex , 1 ) [ 0 ] )
203203 } ,
@@ -215,7 +215,7 @@ export function bindCollection(
215215 typeof snapshot . docChanges === 'function'
216216 ? snapshot . docChanges ( )
217217 : /* istanbul ignore next to support firebase < 5*/
218- ( ( snapshot . docChanges as unknown ) as firestore . DocumentChange [ ] )
218+ ( ( snapshot . docChanges as unknown ) as firebase . firestore . DocumentChange [ ] )
219219
220220 if ( ! isResolved && docChanges . length ) {
221221 // isResolved is only meant to make sure we do the check only once
@@ -263,7 +263,7 @@ export function bindCollection(
263263}
264264
265265interface BindDocumentParamater extends CommonBindOptionsParameter {
266- document : firestore . DocumentReference
266+ document : firebase . firestore . DocumentReference
267267}
268268
269269/**
0 commit comments