15
15
* limitations under the License.
16
16
*/
17
17
18
- import * as firestore from '../../../exp-types' ;
19
-
20
18
import { _getProvider , _removeServiceInstance } from '@firebase/app-exp' ;
21
19
import { _FirebaseService , FirebaseApp } from '@firebase/app-types-exp' ;
22
20
import { Provider } from '@firebase/component' ;
@@ -33,7 +31,10 @@ import {
33
31
MultiTabOfflineComponentProvider ,
34
32
OnlineComponentProvider
35
33
} from '../../../src/core/component_provider' ;
36
- import { Firestore as LiteFirestore } from '../../../lite/src/api/database' ;
34
+ import {
35
+ FirebaseFirestore as LiteFirestore ,
36
+ Settings as LiteSettings
37
+ } from '../../../lite/src/api/database' ;
37
38
import { cast } from '../../../lite/src/api/util' ;
38
39
import { Code , FirestoreError } from '../../../src/util/error' ;
39
40
import { Deferred } from '../../../src/util/promise' ;
@@ -66,13 +67,17 @@ import { PersistenceSettings } from '../../../exp-types';
66
67
67
68
const LOG_TAG = 'Firestore' ;
68
69
70
+ export interface Settings extends LiteSettings {
71
+ cacheSizeBytes ?: number ;
72
+ }
73
+
69
74
/**
70
75
* The root reference to the Firestore database and the entry point for the
71
76
* tree-shakeable SDK.
72
77
*/
73
- export class Firestore
78
+ export class FirebaseFirestore
74
79
extends LiteFirestore
75
- implements firestore . FirebaseFirestore , _FirebaseService {
80
+ implements _FirebaseService {
76
81
readonly _queue = new AsyncQueue ( ) ;
77
82
readonly _persistenceKey : string ;
78
83
readonly _clientId = AutoId . newId ( ) ;
@@ -83,7 +88,7 @@ export class Firestore
83
88
84
89
// We override the Settings property of the Lite SDK since the full Firestore
85
90
// SDK supports more settings.
86
- protected _settings ?: firestore . Settings ;
91
+ protected _settings ?: Settings ;
87
92
88
93
constructor (
89
94
app : FirebaseApp ,
@@ -130,7 +135,7 @@ export class Firestore
130
135
} ;
131
136
}
132
137
133
- _getSettings ( ) : firestore . Settings {
138
+ _getSettings ( ) : Settings {
134
139
return super . _getSettings ( ) ;
135
140
}
136
141
@@ -171,12 +176,12 @@ export class Firestore
171
176
172
177
export function initializeFirestore (
173
178
app : FirebaseApp ,
174
- settings : firestore . Settings
175
- ) : Firestore {
179
+ settings : Settings
180
+ ) : FirebaseFirestore {
176
181
const firestore = _getProvider (
177
182
app ,
178
183
'firestore-exp'
179
- ) . getImmediate ( ) as Firestore ;
184
+ ) . getImmediate ( ) as FirebaseFirestore ;
180
185
181
186
if (
182
187
settings . cacheSizeBytes !== undefined &&
@@ -193,15 +198,15 @@ export function initializeFirestore(
193
198
return firestore ;
194
199
}
195
200
196
- export function getFirestore ( app : FirebaseApp ) : Firestore {
197
- return _getProvider ( app , 'firestore-exp' ) . getImmediate ( ) as Firestore ;
201
+ export function getFirestore ( app : FirebaseApp ) : FirebaseFirestore {
202
+ return _getProvider ( app , 'firestore-exp' ) . getImmediate ( ) as FirebaseFirestore ;
198
203
}
199
204
200
205
export function enableIndexedDbPersistence (
201
- firestore : firestore . FirebaseFirestore ,
206
+ firestore : FirebaseFirestore ,
202
207
persistenceSettings ?: PersistenceSettings
203
208
) : Promise < void > {
204
- const firestoreImpl = cast ( firestore , Firestore ) ;
209
+ const firestoreImpl = cast ( firestore , FirebaseFirestore ) ;
205
210
verifyNotInitialized ( firestoreImpl ) ;
206
211
207
212
// `_getSettings()` freezes the client settings and prevents further changes
@@ -232,9 +237,9 @@ export function enableIndexedDbPersistence(
232
237
}
233
238
234
239
export function enableMultiTabIndexedDbPersistence (
235
- firestore : firestore . FirebaseFirestore
240
+ firestore : FirebaseFirestore
236
241
) : Promise < void > {
237
- const firestoreImpl = cast ( firestore , Firestore ) ;
242
+ const firestoreImpl = cast ( firestore , FirebaseFirestore ) ;
238
243
verifyNotInitialized ( firestoreImpl ) ;
239
244
240
245
// `_getSettings()` freezes the client settings and prevents further changes
@@ -264,9 +269,9 @@ export function enableMultiTabIndexedDbPersistence(
264
269
}
265
270
266
271
export function clearIndexedDbPersistence (
267
- firestore : firestore . FirebaseFirestore
272
+ firestore : FirebaseFirestore
268
273
) : Promise < void > {
269
- const firestoreImpl = cast ( firestore , Firestore ) ;
274
+ const firestoreImpl = cast ( firestore , FirebaseFirestore ) ;
270
275
if ( firestoreImpl . _initialized && ! firestoreImpl . _terminated ) {
271
276
throw new FirestoreError (
272
277
Code . FAILED_PRECONDITION ,
@@ -293,9 +298,9 @@ export function clearIndexedDbPersistence(
293
298
}
294
299
295
300
export function waitForPendingWrites (
296
- firestore : firestore . FirebaseFirestore
301
+ firestore : FirebaseFirestore
297
302
) : Promise < void > {
298
- const firestoreImpl = cast ( firestore , Firestore ) ;
303
+ const firestoreImpl = cast ( firestore , FirebaseFirestore ) ;
299
304
firestoreImpl . _verifyNotTerminated ( ) ;
300
305
301
306
const deferred = new Deferred < void > ( ) ;
@@ -306,10 +311,8 @@ export function waitForPendingWrites(
306
311
return deferred . promise ;
307
312
}
308
313
309
- export function enableNetwork (
310
- firestore : firestore . FirebaseFirestore
311
- ) : Promise < void > {
312
- const firestoreImpl = cast ( firestore , Firestore ) ;
314
+ export function enableNetwork ( firestore : FirebaseFirestore ) : Promise < void > {
315
+ const firestoreImpl = cast ( firestore , FirebaseFirestore ) ;
313
316
firestoreImpl . _verifyNotTerminated ( ) ;
314
317
315
318
return firestoreImpl . _queue . enqueue ( async ( ) => {
@@ -320,10 +323,8 @@ export function enableNetwork(
320
323
} ) ;
321
324
}
322
325
323
- export function disableNetwork (
324
- firestore : firestore . FirebaseFirestore
325
- ) : Promise < void > {
326
- const firestoreImpl = cast ( firestore , Firestore ) ;
326
+ export function disableNetwork ( firestore : FirebaseFirestore ) : Promise < void > {
327
+ const firestoreImpl = cast ( firestore , FirebaseFirestore ) ;
327
328
firestoreImpl . _verifyNotTerminated ( ) ;
328
329
329
330
return firestoreImpl . _queue . enqueue ( async ( ) => {
@@ -334,15 +335,13 @@ export function disableNetwork(
334
335
} ) ;
335
336
}
336
337
337
- export function terminate (
338
- firestore : firestore . FirebaseFirestore
339
- ) : Promise < void > {
338
+ export function terminate ( firestore : FirebaseFirestore ) : Promise < void > {
340
339
_removeServiceInstance ( firestore . app , 'firestore-exp' ) ;
341
- const firestoreImpl = cast ( firestore , Firestore ) ;
340
+ const firestoreImpl = cast ( firestore , FirebaseFirestore ) ;
342
341
return firestoreImpl . _delete ( ) ;
343
342
}
344
343
345
- function verifyNotInitialized ( firestore : Firestore ) : void {
344
+ function verifyNotInitialized ( firestore : FirebaseFirestore ) : void {
346
345
if ( firestore . _initialized || firestore . _terminated ) {
347
346
throw new FirestoreError (
348
347
Code . FAILED_PRECONDITION ,
0 commit comments