15
15
* limitations under the License.
16
16
*/
17
17
18
- // Imports firebase via the raw sources and re-exports it.
19
- // This file exists for two reasons:
20
- // - It serves as a single entry point to all Firebase types and can return
21
- // the leagcy SDK types directly (if `firebase.firestore` exists), or wrapping
22
- // types that use the firebase-exp SDK.
23
- // - It can be replaced by the "<repo-root>/integration/firestore" test suite
24
- // with a reference to the minified sources.
25
- //
26
- // If you change any exports in this file, you need to also adjust
27
- // "integration/firestore/firebase_export.ts".
18
+ // Imports firebase via the raw sources and re-exports it. The
19
+ // "<repo-root>/integration/firestore" test suite replaces this file with a
20
+ // reference to the minified sources. If you change any exports in this file,
21
+ // you need to also adjust "integration/firestore/firebase_export.ts".
28
22
29
23
import * as firestore from '@firebase/firestore-types' ;
30
24
31
25
import firebase from '@firebase/app' ;
32
- // eslint-disable-next-line import/no-extraneous-dependencies
33
- import firebaseAppCompat from '@firebase/app-compat' ;
34
26
35
- import * as exp from '../../../exp/test/shim' ;
36
27
import { FieldValue } from '../../../src/compat/field_value' ;
37
28
import { FieldPath } from '../../../src/api/field_path' ;
29
+ import { Timestamp } from '../../../src/api/timestamp' ;
30
+ import { Blob } from '../../../src/api/blob' ;
31
+ import { GeoPoint } from '../../../src/api/geo_point' ;
38
32
import { FirebaseApp } from '@firebase/app-types' ;
39
- import {
40
- Firestore ,
41
- IndexedDbPersistenceProvider
42
- } from '../../../src/api/database' ;
43
- import { getFirestore } from '../../../exp/src/api/database' ;
44
-
45
- /**
46
- * Detects whether we are running against the functionial (tree-shakeable)
47
- * Firestore API. Used to exclude some tests, e.g. those that validate invalid
48
- * TypeScript input.
49
- */
50
- function usesFunctionalApi ( ) : boolean {
51
- // Use the firebase namespace to detect if `firebase.firestore` has been
52
- // registered, which is only registered in the classic version of Firestore.
53
- return ! ( 'firestore' in firebase ) ;
54
- }
33
+ import { Firestore } from '../../../src/api/database' ;
55
34
56
35
// TODO(dimond): Right now we create a new app and Firestore instance for
57
36
// every test and never clean them up. We may need to revisit.
@@ -70,56 +49,22 @@ export function newTestFirestore(
70
49
nameOrApp = 'test-app-' + appCount ++ ;
71
50
}
72
51
73
- let firestore : firestore . FirebaseFirestore ;
74
- if ( usesFunctionalApi ( ) ) {
75
- const app =
76
- typeof nameOrApp === 'string'
77
- ? firebaseAppCompat . initializeApp (
78
- {
79
- apiKey : 'fake-api-key' ,
80
- projectId
81
- } ,
82
- nameOrApp
83
- )
84
- : nameOrApp ;
85
-
86
- firestore = new Firestore (
87
- app ,
88
- getFirestore ( app ) ,
89
- new IndexedDbPersistenceProvider ( )
90
- ) ;
91
- } else {
92
- const app =
93
- typeof nameOrApp === 'string'
94
- ? firebase . initializeApp (
95
- {
96
- apiKey : 'fake-api-key' ,
97
- projectId
98
- } ,
99
- nameOrApp
100
- )
101
- : nameOrApp ;
102
-
103
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
- firestore = ( firebase as any ) . firestore ( app ) ;
105
- }
52
+ const app =
53
+ typeof nameOrApp === 'string'
54
+ ? firebase . initializeApp (
55
+ {
56
+ apiKey : 'fake-api-key' ,
57
+ projectId
58
+ } ,
59
+ nameOrApp
60
+ )
61
+ : nameOrApp ;
62
+ const firestore = firebase . firestore ( app ) ;
106
63
107
64
if ( settings ) {
108
65
firestore . settings ( settings ) ;
109
66
}
110
67
return firestore ;
111
68
}
112
69
113
- // We only register firebase.firestore if the tests are run against the
114
- // legacy SDK. To prevent a compile-time error with the firestore-exp
115
- // SDK, we cast to `any`.
116
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
- const legacyNamespace = ( firebase as any ) . firestore ;
118
-
119
- const Timestamp = usesFunctionalApi ( )
120
- ? exp . Timestamp
121
- : legacyNamespace . Timestamp ;
122
- const GeoPoint = usesFunctionalApi ( ) ? exp . GeoPoint : legacyNamespace . GeoPoint ;
123
- const Blob = usesFunctionalApi ( ) ? exp . Blob : legacyNamespace . Blob ;
124
-
125
70
export { Firestore , FieldValue , FieldPath , Timestamp , Blob , GeoPoint } ;
0 commit comments