@@ -70,6 +70,7 @@ import {
70
70
validateSetOptions
71
71
} from '../../src/util/input_validation' ;
72
72
import { Compat } from '../../src/compat/compat' ;
73
+ import { Firestore } from '../../src/api/database' ;
73
74
74
75
export { GeoPoint , Timestamp } from '../index' ;
75
76
export { FieldValue } from '../../src/compat/field_value' ;
@@ -93,92 +94,11 @@ export class FirebaseApp
93
94
}
94
95
}
95
96
96
- export class FirebaseFirestore
97
- extends Compat < exp . FirebaseFirestore >
98
- implements legacy . FirebaseFirestore {
99
- app = new FirebaseApp ( this . _delegate . app ) ;
100
-
101
- settings ( settings : legacy . Settings ) : void {
102
- initializeFirestore ( this . app . _delegate , settings ) ;
103
- }
104
-
105
- useEmulator ( host : string , port : number ) : void {
106
- this . settings ( { host : `${ host } :${ port } ` , ssl : false , merge : true } ) ;
107
- }
108
-
109
- enablePersistence ( settings ?: legacy . PersistenceSettings ) : Promise < void > {
110
- return settings ?. synchronizeTabs
111
- ? enableMultiTabIndexedDbPersistence ( this . _delegate )
112
- : enableIndexedDbPersistence ( this . _delegate ) ;
113
- }
114
-
115
- collection ( collectionPath : string ) : CollectionReference < legacy . DocumentData > {
116
- return new CollectionReference (
117
- this ,
118
- collection ( this . _delegate , collectionPath )
119
- ) ;
120
- }
121
-
122
- doc ( documentPath : string ) : DocumentReference < legacy . DocumentData > {
123
- return new DocumentReference ( this , doc ( this . _delegate , documentPath ) ) ;
124
- }
125
-
126
- collectionGroup ( collectionId : string ) : Query < legacy . DocumentData > {
127
- return new Query ( this , collectionGroup ( this . _delegate , collectionId ) ) ;
128
- }
129
-
130
- runTransaction < T > (
131
- updateFunction : ( transaction : legacy . Transaction ) => Promise < T >
132
- ) : Promise < T > {
133
- return runTransaction ( this . _delegate , t =>
134
- updateFunction ( new Transaction ( this , t ) )
135
- ) ;
136
- }
137
-
138
- batch ( ) : legacy . WriteBatch {
139
- return new WriteBatch ( writeBatch ( this . _delegate ) ) ;
140
- }
141
-
142
- clearPersistence ( ) : Promise < void > {
143
- return clearIndexedDbPersistence ( this . _delegate ) ;
144
- }
145
-
146
- enableNetwork ( ) : Promise < void > {
147
- return enableNetwork ( this . _delegate ) ;
148
- }
149
-
150
- disableNetwork ( ) : Promise < void > {
151
- return disableNetwork ( this . _delegate ) ;
152
- }
153
-
154
- waitForPendingWrites ( ) : Promise < void > {
155
- return waitForPendingWrites ( this . _delegate ) ;
156
- }
157
-
158
- onSnapshotsInSync ( observer : {
159
- next ?: ( value : void ) => void ;
160
- error ?: ( error : legacy . FirestoreError ) => void ;
161
- complete ?: ( ) => void ;
162
- } ) : ( ) => void ;
163
- onSnapshotsInSync ( onSync : ( ) => void ) : ( ) => void ;
164
- onSnapshotsInSync ( arg : any ) : ( ) => void {
165
- return onSnapshotsInSync ( this . _delegate , arg ) ;
166
- }
167
-
168
- terminate ( ) : Promise < void > {
169
- return terminate ( this . _delegate ) ;
170
- }
171
-
172
- INTERNAL = {
173
- delete : ( ) => terminate ( this . _delegate )
174
- } ;
175
- }
176
-
177
97
export class Transaction
178
98
extends Compat < exp . Transaction >
179
99
implements legacy . Transaction {
180
100
constructor (
181
- private readonly _firestore : FirebaseFirestore ,
101
+ private readonly _firestore : Firestore ,
182
102
delegate : exp . Transaction
183
103
) {
184
104
super ( delegate ) ;
@@ -301,7 +221,7 @@ export class DocumentReference<T = legacy.DocumentData>
301
221
extends Compat < exp . DocumentReference < T > >
302
222
implements legacy . DocumentReference < T > {
303
223
constructor (
304
- readonly firestore : FirebaseFirestore ,
224
+ readonly firestore : Firestore ,
305
225
delegate : exp . DocumentReference < T >
306
226
) {
307
227
super ( delegate ) ;
@@ -424,7 +344,7 @@ export class DocumentSnapshot<T = legacy.DocumentData>
424
344
extends Compat < exp . DocumentSnapshot < T > >
425
345
implements legacy . DocumentSnapshot < T > {
426
346
constructor (
427
- private readonly _firestore : FirebaseFirestore ,
347
+ private readonly _firestore : Firestore ,
428
348
delegate : exp . DocumentSnapshot < T >
429
349
) {
430
350
super ( delegate ) ;
@@ -455,7 +375,7 @@ export class QueryDocumentSnapshot<T = legacy.DocumentData>
455
375
extends DocumentSnapshot < T >
456
376
implements legacy . QueryDocumentSnapshot < T > {
457
377
constructor (
458
- firestore : FirebaseFirestore ,
378
+ firestore : Firestore ,
459
379
readonly _delegate : exp . QueryDocumentSnapshot < T >
460
380
) {
461
381
super ( firestore , _delegate ) ;
@@ -469,7 +389,7 @@ export class QueryDocumentSnapshot<T = legacy.DocumentData>
469
389
export class Query < T = legacy . DocumentData >
470
390
extends Compat < exp . Query < T > >
471
391
implements legacy . Query < T > {
472
- constructor ( readonly firestore : FirebaseFirestore , delegate : exp . Query < T > ) {
392
+ constructor ( readonly firestore : Firestore , delegate : exp . Query < T > ) {
473
393
super ( delegate ) ;
474
394
}
475
395
@@ -592,7 +512,7 @@ export class Query<T = legacy.DocumentData>
592
512
export class QuerySnapshot < T = legacy . DocumentData >
593
513
implements legacy . QuerySnapshot < T > {
594
514
constructor (
595
- readonly _firestore : FirebaseFirestore ,
515
+ readonly _firestore : Firestore ,
596
516
readonly _delegate : exp . QuerySnapshot < T >
597
517
) { }
598
518
@@ -633,7 +553,7 @@ export class QuerySnapshot<T = legacy.DocumentData>
633
553
export class DocumentChange < T = legacy . DocumentData >
634
554
implements legacy . DocumentChange < T > {
635
555
constructor (
636
- private readonly _firestore : FirebaseFirestore ,
556
+ private readonly _firestore : Firestore ,
637
557
private readonly _delegate : exp . DocumentChange < T >
638
558
) { }
639
559
readonly type = this . _delegate . type ;
@@ -649,7 +569,7 @@ export class CollectionReference<T = legacy.DocumentData>
649
569
extends Query < T >
650
570
implements legacy . CollectionReference < T > {
651
571
constructor (
652
- firestore : FirebaseFirestore ,
572
+ firestore : Firestore ,
653
573
readonly _delegate : exp . CollectionReference < T >
654
574
) {
655
575
super ( firestore , _delegate ) ;
@@ -755,7 +675,7 @@ function wrap(value: any): any {
755
675
// TODO(mrschmidt): Ideally, we should use an existing instance of
756
676
// FirebaseFirestore here rather than instantiating a new instance
757
677
return new DocumentReference (
758
- new FirebaseFirestore ( value . firestore as exp . FirebaseFirestore ) ,
678
+ new Firestore ( value . firestore as exp . FirebaseFirestore ) ,
759
679
value
760
680
) ;
761
681
} else if ( isPlainObject ( value ) ) {
0 commit comments