@umituz/react-native-firebase 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-firebase",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Unified Firebase package for React Native apps - Auth and Firestore services using Firebase JS SDK (no native modules).",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -18,16 +18,24 @@ export * from './domain';
|
|
|
18
18
|
// INFRASTRUCTURE LAYER - Implementation
|
|
19
19
|
// =============================================================================
|
|
20
20
|
|
|
21
|
-
// Firestore
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
// IMPORTANT: Use Firebase SDK directly for Firestore operations
|
|
22
|
+
// Import in your app: import { getFirestore } from 'firebase/firestore';
|
|
23
|
+
//
|
|
24
|
+
// Firestore initialization:
|
|
25
|
+
// import { initializeFirestore } from 'firebase/firestore';
|
|
26
|
+
// import { getReactNativePersistence } from 'firebase/firestore/react-native';
|
|
27
|
+
// import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
28
|
+
//
|
|
29
|
+
// const db = initializeFirestore(firebaseApp, {
|
|
30
|
+
// localCache: getReactNativePersistence(AsyncStorage)
|
|
31
|
+
// });
|
|
32
|
+
|
|
33
|
+
// Re-export Firestore type (any to avoid conflicts)
|
|
29
34
|
export type { Firestore } from './infrastructure/config/FirestoreClient';
|
|
30
35
|
|
|
36
|
+
// Re-export getFirestore for convenience (imports from Firebase SDK)
|
|
37
|
+
export { getFirestore } from 'firebase/firestore';
|
|
38
|
+
|
|
31
39
|
// Repositories
|
|
32
40
|
export { BaseRepository } from './infrastructure/repositories/BaseRepository';
|
|
33
41
|
export type { IPathResolver } from './infrastructure/repositories/BaseRepository';
|
|
@@ -1,76 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Firestore Configuration Client
|
|
3
3
|
*
|
|
4
|
-
* IMPORTANT: This package does NOT
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Instead, you should:
|
|
8
|
-
* 1. Install firebase SDK in your app: npm install firebase
|
|
9
|
-
* 2. Import and use getFirestore() from 'firebase/firestore' directly
|
|
10
|
-
* 3. Use the utilities from this package for repositories and helpers
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { FirebaseInitializationError } from "../../../../shared/domain/errors/FirebaseError";
|
|
14
|
-
|
|
15
|
-
// Firestore type from firebase/firestore SDK
|
|
16
|
-
// Import in your app: import type { Firestore } from 'firebase/firestore'
|
|
17
|
-
export type Firestore = unknown;
|
|
18
|
-
|
|
19
|
-
let firestoreInstance: Firestore | null = null;
|
|
20
|
-
let initializationError: Error | null = null;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Initialize Firestore
|
|
24
|
-
*
|
|
25
|
-
* DEPRECATED: This function is deprecated and will be removed in future versions.
|
|
26
|
-
*
|
|
27
|
-
* Instead, initialize Firestore directly in your app:
|
|
4
|
+
* IMPORTANT: This package does NOT provide Firestore initialization.
|
|
5
|
+
* Use Firebase SDK directly in your app:
|
|
28
6
|
* ```typescript
|
|
29
|
-
* import { initializeFirestore } from 'firebase/firestore';
|
|
7
|
+
* import { getFirestore, initializeFirestore } from 'firebase/firestore';
|
|
30
8
|
* import { getReactNativePersistence } from 'firebase/firestore/react-native';
|
|
31
9
|
* import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
32
10
|
*
|
|
33
|
-
* const
|
|
11
|
+
* const db = initializeFirestore(firebaseApp, {
|
|
34
12
|
* localCache: getReactNativePersistence(AsyncStorage)
|
|
35
13
|
* });
|
|
36
14
|
* ```
|
|
15
|
+
*
|
|
16
|
+
* This package only provides:
|
|
17
|
+
* - Base repository classes (extend these for your data layer)
|
|
18
|
+
* - Utilities for pagination, queries, dates
|
|
19
|
+
* - Type definitions (import from 'firebase/firestore' in your app)
|
|
37
20
|
*/
|
|
38
|
-
export async function initializeFirestore(
|
|
39
|
-
firebaseApp: unknown // FirebaseApp from firebase/app
|
|
40
|
-
): Promise<Firestore> {
|
|
41
|
-
throw new FirebaseInitializationError(
|
|
42
|
-
"Firestore initialization has moved. " +
|
|
43
|
-
"Please use initializeFirestore() from 'firebase/firestore' directly in your app. " +
|
|
44
|
-
"See package README for migration guide."
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get Firestore instance
|
|
50
|
-
* Returns null if not initialized
|
|
51
|
-
*/
|
|
52
|
-
export function getFirestore(): Firestore | null {
|
|
53
|
-
return firestoreInstance;
|
|
54
|
-
}
|
|
55
21
|
|
|
56
|
-
|
|
57
|
-
* Check if Firestore is initialized
|
|
58
|
-
*/
|
|
59
|
-
export function isFirestoreInitialized(): boolean {
|
|
60
|
-
return firestoreInstance !== null;
|
|
61
|
-
}
|
|
22
|
+
import { getFirebaseApp } from '../../../../shared/infrastructure/config/services/FirebaseInitializationService';
|
|
62
23
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export function getFirestoreInitializationError(): Error | null {
|
|
67
|
-
return initializationError;
|
|
68
|
-
}
|
|
24
|
+
// Firestore type - use 'any' to avoid type conflicts with Firebase SDK
|
|
25
|
+
// The actual type checking happens in your app when you import from firebase/firestore
|
|
26
|
+
export type Firestore = any;
|
|
69
27
|
|
|
70
28
|
/**
|
|
71
|
-
*
|
|
29
|
+
* Get Firestore instance
|
|
30
|
+
* Returns null if Firebase app is not initialized
|
|
31
|
+
*
|
|
32
|
+
* This is a convenience wrapper that gets the Firebase app and returns
|
|
33
|
+
* a Firestore instance. For type safety, import Firestore from 'firebase/firestore'
|
|
34
|
+
* in your app.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { getDb } from '@umituz/react-native-firebase/firestore';
|
|
39
|
+
* import type { Firestore } from 'firebase/firestore';
|
|
40
|
+
*
|
|
41
|
+
* const db = getDb() as Firestore | null;
|
|
42
|
+
* if (db) {
|
|
43
|
+
* // Use db with Firebase SDK functions
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
72
46
|
*/
|
|
73
|
-
export function
|
|
74
|
-
|
|
75
|
-
|
|
47
|
+
export function getFirestore(): Firestore | null {
|
|
48
|
+
const app = getFirebaseApp();
|
|
49
|
+
if (!app) return null;
|
|
50
|
+
|
|
51
|
+
// Import getFirestore from Firebase SDK dynamically
|
|
52
|
+
// This avoids the idb dependency during bundling
|
|
53
|
+
try {
|
|
54
|
+
const firebaseFirestore = require('firebase/firestore');
|
|
55
|
+
return firebaseFirestore.getFirestore(app);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.warn('[Firestore] Failed to get Firestore instance:', error);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
76
60
|
}
|
|
@@ -29,11 +29,9 @@ export interface FirebaseAppOptions {
|
|
|
29
29
|
// Firestore Types
|
|
30
30
|
// =============================================================================
|
|
31
31
|
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
export
|
|
35
|
-
readonly __brand: 'Firestore';
|
|
36
|
-
}
|
|
32
|
+
// Firestore type - use 'any' to avoid type conflicts with Firebase SDK
|
|
33
|
+
// In your app, import the actual type: import type { Firestore } from 'firebase/firestore'
|
|
34
|
+
export type Firestore = any;
|
|
37
35
|
|
|
38
36
|
export interface DocumentSnapshot<T = unknown> {
|
|
39
37
|
id: string;
|