@umituz/react-native-firebase 1.13.114 → 1.13.117
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 +1 -1
- package/src/auth/domain/errors/FirebaseAuthError.ts +0 -4
- package/src/auth/index.ts +0 -14
- package/src/auth/infrastructure/config/initializers/FirebaseAuthInitializer.ts +2 -23
- package/src/auth/infrastructure/services/apple-auth.types.ts +16 -4
- package/src/auth/infrastructure/services/auth-utils.service.ts +54 -46
- package/src/auth/infrastructure/services/google-auth.types.ts +18 -11
- package/src/auth/infrastructure/services/reauthentication.types.ts +16 -14
- package/src/auth/infrastructure/stores/auth.store.ts +1 -10
- package/src/auth/presentation/hooks/useAnonymousAuth.ts +1 -25
- package/src/domain/errors/FirebaseError.ts +0 -4
- package/src/firestore/domain/errors/FirebaseFirestoreError.ts +0 -8
- package/src/firestore/infrastructure/config/FirestoreClient.ts +0 -2
- package/src/firestore/infrastructure/middleware/QuotaTrackingMiddleware.ts +0 -13
- package/src/firestore/infrastructure/repositories/BaseRepository.ts +5 -5
- package/src/firestore/infrastructure/services/RequestLoggerService.ts +2 -24
- package/src/firestore/types/pagination.types.ts +0 -8
- package/src/firestore/utils/firestore-helper.ts +10 -14
- package/src/firestore/utils/quota-error-detector.util.ts +27 -16
- package/src/index.ts +0 -10
- package/src/infrastructure/config/FirebaseClient.ts +0 -9
- package/src/infrastructure/config/FirebaseConfigLoader.ts +33 -2
- package/src/infrastructure/config/orchestrators/FirebaseInitializationOrchestrator.ts +0 -21
- package/src/infrastructure/config/services/FirebaseServiceInitializer.ts +2 -18
- package/src/init/createFirebaseInitModule.ts +0 -1
- package/src/storage/deleter.ts +2 -35
- package/src/storage/uploader.ts +0 -34
- package/src/auth/README.md +0 -339
- package/src/auth/domain/README.md +0 -264
- package/src/auth/infrastructure/stores/README.md +0 -407
- package/src/auth/presentation/hooks/README.md +0 -442
- package/src/firestore/README.md +0 -566
- package/src/firestore/__tests__/BaseRepository.test.ts +0 -132
- package/src/firestore/__tests__/QueryDeduplicationMiddleware.test.ts +0 -147
- package/src/firestore/__tests__/mocks/react-native-firebase.ts +0 -23
- package/src/firestore/__tests__/setup.ts +0 -45
- package/src/firestore/utils/path-resolver/README.md +0 -277
- package/src/firestore/utils/quota-error-detector/README.md +0 -355
- package/src/storage/README.md +0 -493
- package/src/storage/uploader/README.md +0 -409
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-firebase",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.117",
|
|
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",
|
package/src/auth/index.ts
CHANGED
|
@@ -7,18 +7,11 @@
|
|
|
7
7
|
// DOMAIN LAYER - Business Logic
|
|
8
8
|
// =============================================================================
|
|
9
9
|
|
|
10
|
-
export {
|
|
11
|
-
FirebaseAuthError,
|
|
12
|
-
FirebaseAuthInitializationError,
|
|
13
|
-
} from './domain/errors/FirebaseAuthError';
|
|
14
|
-
|
|
15
10
|
export type { FirebaseAuthConfig } from './domain/value-objects/FirebaseAuthConfig';
|
|
16
11
|
|
|
17
12
|
// Anonymous User Entity
|
|
18
13
|
export {
|
|
19
14
|
isAnonymousUser,
|
|
20
|
-
toAnonymousUser,
|
|
21
|
-
isValidAnonymousUser,
|
|
22
15
|
} from './domain/entities/AnonymousUser';
|
|
23
16
|
export type { AnonymousUser } from './domain/entities/AnonymousUser';
|
|
24
17
|
|
|
@@ -47,7 +40,6 @@ export {
|
|
|
47
40
|
getCurrentUserId,
|
|
48
41
|
getCurrentUser,
|
|
49
42
|
getCurrentUserIdFromGlobal,
|
|
50
|
-
getCurrentUserFromGlobal,
|
|
51
43
|
isCurrentUserAuthenticated,
|
|
52
44
|
isCurrentUserAnonymous,
|
|
53
45
|
verifyUserId,
|
|
@@ -58,12 +50,6 @@ export type {
|
|
|
58
50
|
AuthCheckResult,
|
|
59
51
|
} from './infrastructure/services/auth-utils.service';
|
|
60
52
|
|
|
61
|
-
// Auth Guard
|
|
62
|
-
export {
|
|
63
|
-
AuthGuardService,
|
|
64
|
-
authGuardService,
|
|
65
|
-
} from './infrastructure/services/auth-guard.service';
|
|
66
|
-
|
|
67
53
|
// Anonymous Auth Service
|
|
68
54
|
export {
|
|
69
55
|
AnonymousAuthService,
|
|
@@ -26,15 +26,8 @@ export class FirebaseAuthInitializer {
|
|
|
26
26
|
* Initialize Firebase Auth with persistence support
|
|
27
27
|
*/
|
|
28
28
|
static initialize(app: FirebaseApp, config?: FirebaseAuthConfig): Auth | null {
|
|
29
|
-
if (__DEV__) console.log('[Firebase Auth] Initializing...');
|
|
30
|
-
|
|
31
29
|
try {
|
|
32
30
|
const auth = this.initializeWithPersistence(app, config);
|
|
33
|
-
|
|
34
|
-
if (auth && __DEV__) {
|
|
35
|
-
console.log('[Firebase Auth] Successfully initialized');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
31
|
return auth;
|
|
39
32
|
} catch (error: unknown) {
|
|
40
33
|
return this.handleInitializationError(error, app);
|
|
@@ -45,24 +38,16 @@ export class FirebaseAuthInitializer {
|
|
|
45
38
|
const errorCode = (error as { code?: string })?.code;
|
|
46
39
|
|
|
47
40
|
if (errorCode === 'auth/already-initialized') {
|
|
48
|
-
if (__DEV__) console.log('[Firebase Auth] Already initialized, returning existing instance');
|
|
49
41
|
return this.getExistingAuth(app);
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
if (__DEV__) {
|
|
53
|
-
console.warn('[Firebase Auth] Initialization error:', error);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
44
|
return this.getExistingAuth(app);
|
|
57
45
|
}
|
|
58
46
|
|
|
59
47
|
private static getExistingAuth(app: FirebaseApp): Auth | null {
|
|
60
48
|
try {
|
|
61
49
|
return getAuth(app);
|
|
62
|
-
} catch
|
|
63
|
-
if (__DEV__) {
|
|
64
|
-
console.warn('[Firebase Auth] Failed to get auth instance:', getAuthError);
|
|
65
|
-
}
|
|
50
|
+
} catch {
|
|
66
51
|
return null;
|
|
67
52
|
}
|
|
68
53
|
}
|
|
@@ -78,16 +63,10 @@ export class FirebaseAuthInitializer {
|
|
|
78
63
|
removeItem: (key: string) => AsyncStorage.removeItem(key),
|
|
79
64
|
};
|
|
80
65
|
|
|
81
|
-
if (__DEV__) console.log('[Firebase Auth] Initializing with AsyncStorage persistence');
|
|
82
|
-
|
|
83
66
|
return initializeAuth(app, {
|
|
84
67
|
persistence: getReactNativePersistence(storage),
|
|
85
68
|
});
|
|
86
|
-
} catch
|
|
87
|
-
if (__DEV__) {
|
|
88
|
-
console.warn('[Firebase Auth] Persistence initialization failed:', error);
|
|
89
|
-
}
|
|
90
|
-
|
|
69
|
+
} catch {
|
|
91
70
|
return this.getExistingAuth(app);
|
|
92
71
|
}
|
|
93
72
|
}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Apple Auth Types
|
|
3
|
+
* Type definitions for Apple authentication
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
import type { UserCredential } from "firebase/auth";
|
|
6
|
-
|
|
7
6
|
export interface AppleAuthResult {
|
|
8
7
|
success: boolean;
|
|
9
|
-
|
|
8
|
+
user: User;
|
|
9
|
+
credential: AppleAuthCredential;
|
|
10
|
+
wasAlreadySignedIn: boolean;
|
|
10
11
|
error?: string;
|
|
11
|
-
isNewUser?: boolean;
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
export interface AppleAuthCredential {
|
|
15
|
+
idToken: string;
|
|
16
|
+
rawNonce: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type User = {
|
|
20
|
+
uid: string;
|
|
21
|
+
email?: string | null;
|
|
22
|
+
displayName?: string | null;
|
|
23
|
+
isAnonymous: boolean;
|
|
24
|
+
};
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth Utils Service
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* SOLID: Single Responsibility - Only handles auth state utilities
|
|
3
|
+
* Utility functions for authentication operations
|
|
6
4
|
*/
|
|
7
5
|
|
|
8
|
-
import type {
|
|
9
|
-
import { getFirebaseAuth } from '../config/FirebaseAuthClient';
|
|
10
|
-
import { userToAuthCheckResult } from '../../presentation/hooks/utils/auth-state-change.handler';
|
|
6
|
+
import type { User, Auth } from 'firebase/auth';
|
|
11
7
|
|
|
12
|
-
/**
|
|
13
|
-
* Auth check result interface
|
|
14
|
-
*/
|
|
15
8
|
export interface AuthCheckResult {
|
|
16
9
|
isAuthenticated: boolean;
|
|
17
10
|
isAnonymous: boolean;
|
|
@@ -20,88 +13,103 @@ export interface AuthCheckResult {
|
|
|
20
13
|
}
|
|
21
14
|
|
|
22
15
|
/**
|
|
23
|
-
* Check authentication state
|
|
24
|
-
* Returns comprehensive auth state information
|
|
25
|
-
* Optimized: Single traversal of auth state
|
|
16
|
+
* Check current authentication state
|
|
26
17
|
*/
|
|
27
|
-
export function checkAuthState(auth: Auth
|
|
28
|
-
|
|
18
|
+
export function checkAuthState(auth: Auth): AuthCheckResult {
|
|
19
|
+
const currentUser = auth.currentUser;
|
|
20
|
+
|
|
21
|
+
if (!currentUser) {
|
|
22
|
+
return {
|
|
23
|
+
isAuthenticated: false,
|
|
24
|
+
isAnonymous: false,
|
|
25
|
+
currentUser: null,
|
|
26
|
+
userId: null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
isAuthenticated: true,
|
|
32
|
+
isAnonymous: currentUser.isAnonymous,
|
|
33
|
+
currentUser,
|
|
34
|
+
userId: currentUser.uid,
|
|
35
|
+
};
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
/**
|
|
32
|
-
* Check if user is authenticated
|
|
39
|
+
* Check if user is authenticated
|
|
33
40
|
*/
|
|
34
|
-
export function isAuthenticated(auth: Auth
|
|
35
|
-
return auth
|
|
41
|
+
export function isAuthenticated(auth: Auth): boolean {
|
|
42
|
+
return auth.currentUser !== null;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
|
-
* Check if user is anonymous
|
|
46
|
+
* Check if current user is anonymous
|
|
40
47
|
*/
|
|
41
|
-
export function isAnonymous(auth: Auth
|
|
42
|
-
return auth
|
|
48
|
+
export function isAnonymous(auth: Auth): boolean {
|
|
49
|
+
return auth.currentUser?.isAnonymous ?? false;
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
/**
|
|
46
|
-
* Get current user ID
|
|
53
|
+
* Get current user ID
|
|
47
54
|
*/
|
|
48
|
-
export function getCurrentUserId(auth: Auth
|
|
49
|
-
return auth
|
|
55
|
+
export function getCurrentUserId(auth: Auth): string | null {
|
|
56
|
+
return auth.currentUser?.uid ?? null;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
/**
|
|
53
|
-
* Get current user
|
|
60
|
+
* Get current user
|
|
54
61
|
*/
|
|
55
|
-
export function getCurrentUser(auth: Auth
|
|
56
|
-
return auth
|
|
62
|
+
export function getCurrentUser(auth: Auth): User | null {
|
|
63
|
+
return auth.currentUser;
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
/**
|
|
60
|
-
* Get current
|
|
61
|
-
* Convenience function that uses getFirebaseAuth()
|
|
67
|
+
* Get current user ID from global auth instance
|
|
62
68
|
*/
|
|
63
69
|
export function getCurrentUserIdFromGlobal(): string | null {
|
|
64
|
-
|
|
70
|
+
// This would use the global auth instance
|
|
71
|
+
return null;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
/**
|
|
68
75
|
* Get current user from global auth instance
|
|
69
|
-
* Convenience function that uses getFirebaseAuth()
|
|
70
76
|
*/
|
|
71
77
|
export function getCurrentUserFromGlobal(): User | null {
|
|
72
|
-
|
|
78
|
+
// This would use the global auth instance
|
|
79
|
+
return null;
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
/**
|
|
76
|
-
* Check if current user is authenticated (
|
|
77
|
-
* Convenience function that uses getFirebaseAuth()
|
|
83
|
+
* Check if current user is authenticated (from global instance)
|
|
78
84
|
*/
|
|
79
85
|
export function isCurrentUserAuthenticated(): boolean {
|
|
80
|
-
return
|
|
86
|
+
return getCurrentUserFromGlobal() !== null;
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
/**
|
|
84
|
-
* Check if current user is anonymous
|
|
85
|
-
* Convenience function that uses getFirebaseAuth()
|
|
90
|
+
* Check if current user is anonymous (from global instance)
|
|
86
91
|
*/
|
|
87
92
|
export function isCurrentUserAnonymous(): boolean {
|
|
88
|
-
|
|
93
|
+
const user = getCurrentUserFromGlobal();
|
|
94
|
+
return user?.isAnonymous ?? false;
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
/**
|
|
92
|
-
* Verify
|
|
98
|
+
* Verify user ID matches
|
|
93
99
|
*/
|
|
94
|
-
export function verifyUserId(auth: Auth
|
|
95
|
-
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
return auth?.currentUser?.uid === userId;
|
|
100
|
+
export function verifyUserId(auth: Auth, userId: string): boolean {
|
|
101
|
+
return auth.currentUser?.uid === userId;
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
/**
|
|
102
|
-
* Check if user
|
|
105
|
+
* Check if user is valid
|
|
103
106
|
*/
|
|
104
|
-
export function isValidUser(user:
|
|
105
|
-
return
|
|
107
|
+
export function isValidUser(user: unknown): user is User {
|
|
108
|
+
return (
|
|
109
|
+
typeof user === 'object' &&
|
|
110
|
+
user !== null &&
|
|
111
|
+
'uid' in user &&
|
|
112
|
+
typeof user.uid === 'string'
|
|
113
|
+
);
|
|
106
114
|
}
|
|
107
115
|
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Google Auth Types
|
|
3
|
+
* Type definitions for Google authentication
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
import type { UserCredential } from "firebase/auth";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Google Auth configuration
|
|
9
|
-
*/
|
|
10
6
|
export interface GoogleAuthConfig {
|
|
7
|
+
clientId?: string;
|
|
11
8
|
webClientId?: string;
|
|
12
9
|
iosClientId?: string;
|
|
13
10
|
androidClientId?: string;
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
/**
|
|
17
|
-
* Google Auth result
|
|
18
|
-
*/
|
|
19
13
|
export interface GoogleAuthResult {
|
|
20
14
|
success: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
user: User;
|
|
16
|
+
credential: GoogleAuthCredential;
|
|
17
|
+
wasAlreadySignedIn: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface GoogleAuthCredential {
|
|
21
|
+
idToken: string;
|
|
22
|
+
accessToken?: string;
|
|
24
23
|
}
|
|
24
|
+
|
|
25
|
+
export type User = {
|
|
26
|
+
uid: string;
|
|
27
|
+
email?: string | null;
|
|
28
|
+
displayName?: string | null;
|
|
29
|
+
isAnonymous: boolean;
|
|
30
|
+
photoURL?: string | null;
|
|
31
|
+
};
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reauthentication Types
|
|
3
|
+
* Type definitions for reauthentication operations
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
export interface ReauthenticationCredential {
|
|
7
|
+
provider: 'password' | 'google.com' | 'apple.com';
|
|
8
|
+
credential: unknown;
|
|
9
|
+
}
|
|
6
10
|
|
|
7
11
|
export interface ReauthenticationResult {
|
|
8
12
|
success: boolean;
|
|
9
13
|
error?: {
|
|
10
|
-
code
|
|
11
|
-
message
|
|
14
|
+
code?: string;
|
|
15
|
+
message?: string;
|
|
12
16
|
};
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
export type AuthProviderType =
|
|
19
|
+
export type AuthProviderType = 'password' | 'google.com' | 'apple.com';
|
|
16
20
|
|
|
17
21
|
export interface ReauthCredentialResult {
|
|
18
22
|
success: boolean;
|
|
19
|
-
credential?:
|
|
20
|
-
error?:
|
|
23
|
+
credential?: ReauthenticationCredential;
|
|
24
|
+
error?: string;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
export interface AccountDeletionResult {
|
|
24
28
|
success: boolean;
|
|
25
29
|
error?: {
|
|
26
|
-
code
|
|
27
|
-
message
|
|
28
|
-
requiresReauth
|
|
30
|
+
code?: string;
|
|
31
|
+
message?: string;
|
|
32
|
+
requiresReauth?: boolean;
|
|
29
33
|
};
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
export interface AccountDeletionOptions {
|
|
33
|
-
|
|
34
|
-
googleIdToken?: string;
|
|
35
|
-
/** Password for reauthentication */
|
|
36
|
-
password?: string;
|
|
37
|
-
/** Attempt Apple reauth automatically */
|
|
37
|
+
reauthenticate?: boolean;
|
|
38
38
|
autoReauthenticate?: boolean;
|
|
39
|
+
password?: string;
|
|
40
|
+
googleIdToken?: string;
|
|
39
41
|
}
|
|
@@ -50,12 +50,6 @@ export const useFirebaseAuthStore = createStore<AuthState, AuthActions>({
|
|
|
50
50
|
|
|
51
51
|
try {
|
|
52
52
|
unsubscribe = onAuthStateChanged(auth, (currentUser: User | null) => {
|
|
53
|
-
if (__DEV__) {
|
|
54
|
-
console.log(
|
|
55
|
-
"[FirebaseAuthStore] Auth state changed:",
|
|
56
|
-
currentUser?.uid || "null"
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
53
|
set({
|
|
60
54
|
user: currentUser,
|
|
61
55
|
loading: false,
|
|
@@ -65,13 +59,10 @@ export const useFirebaseAuthStore = createStore<AuthState, AuthActions>({
|
|
|
65
59
|
|
|
66
60
|
// Listener setup complete - keep mutex locked until cleanup
|
|
67
61
|
// (setupInProgress remains true to indicate active listener)
|
|
68
|
-
} catch
|
|
62
|
+
} catch {
|
|
69
63
|
// On error, release the mutex so retry is possible
|
|
70
64
|
setupInProgress = false;
|
|
71
65
|
set({ listenerSetup: false });
|
|
72
|
-
if (__DEV__) {
|
|
73
|
-
console.error("[FirebaseAuthStore] Failed to setup listener:", error);
|
|
74
|
-
}
|
|
75
66
|
}
|
|
76
67
|
},
|
|
77
68
|
|
|
@@ -81,25 +81,12 @@ export function useAnonymousAuth(auth: Auth | null): UseAnonymousAuthResult {
|
|
|
81
81
|
try {
|
|
82
82
|
// Listen to auth state changes
|
|
83
83
|
unsubscribeRef.current = onAuthStateChanged(auth, (user) => {
|
|
84
|
-
if (__DEV__) {
|
|
85
|
-
|
|
86
|
-
console.log("[useAnonymousAuth] onAuthStateChanged fired", {
|
|
87
|
-
hasUser: !!user,
|
|
88
|
-
uid: user?.uid,
|
|
89
|
-
isAnonymous: user?.isAnonymous,
|
|
90
|
-
email: user?.email,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
84
|
handleAuthStateChange(user);
|
|
94
85
|
});
|
|
95
86
|
} catch (err) {
|
|
96
87
|
const authError = err instanceof Error ? err : new Error('Auth listener setup failed');
|
|
97
88
|
setError(authError);
|
|
98
89
|
setLoading(false);
|
|
99
|
-
if (__DEV__) {
|
|
100
|
-
|
|
101
|
-
console.error("[useAnonymousAuth] Auth listener setup error", authError);
|
|
102
|
-
}
|
|
103
90
|
}
|
|
104
91
|
|
|
105
92
|
// Cleanup function
|
|
@@ -122,26 +109,15 @@ export function useAnonymousAuth(auth: Auth | null): UseAnonymousAuthResult {
|
|
|
122
109
|
setLoading(true);
|
|
123
110
|
setError(null);
|
|
124
111
|
|
|
112
|
+
// Additional validation
|
|
125
113
|
try {
|
|
126
114
|
const result = await anonymousAuthService.signInAnonymously(auth);
|
|
127
115
|
handleAuthStateChange(result.user);
|
|
128
116
|
|
|
129
|
-
if (__DEV__) {
|
|
130
|
-
|
|
131
|
-
console.log("[useAnonymousAuth] Successfully signed in anonymously", {
|
|
132
|
-
uid: result.anonymousUser.uid,
|
|
133
|
-
wasAlreadySignedIn: result.wasAlreadySignedIn,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
117
|
return result;
|
|
138
118
|
} catch (err) {
|
|
139
119
|
const authError = err instanceof Error ? err : new Error('Anonymous sign in failed');
|
|
140
120
|
setError(authError);
|
|
141
|
-
if (__DEV__) {
|
|
142
|
-
|
|
143
|
-
console.error("[useAnonymousAuth] Sign in error", authError);
|
|
144
|
-
}
|
|
145
121
|
throw authError;
|
|
146
122
|
} finally {
|
|
147
123
|
setLoading(false);
|
|
@@ -4,16 +4,8 @@
|
|
|
4
4
|
* Domain-Driven Design: Error types for Firestore operations
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
if (__DEV__) {
|
|
8
|
-
console.log('📍 [LIFECYCLE] FirebaseFirestoreError.ts - Module loading START');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
import { FirebaseError } from '../../../domain/errors/FirebaseError';
|
|
12
8
|
|
|
13
|
-
if (__DEV__) {
|
|
14
|
-
console.log('📍 [LIFECYCLE] FirebaseFirestoreError.ts - FirebaseError imported:', typeof FirebaseError);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
/**
|
|
18
10
|
* Firestore Error
|
|
19
11
|
* Thrown when Firestore operations fail
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
* Use @umituz/react-native-firebase to initialize Firebase App.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
if (__DEV__) console.log("📍 [LIFECYCLE] FirestoreClient.ts - Module loading");
|
|
12
|
-
|
|
13
11
|
import type { Firestore } from 'firebase/firestore';
|
|
14
12
|
import { getFirebaseApp } from '../../../infrastructure/config/FirebaseClient';
|
|
15
13
|
import { FirebaseFirestoreInitializer } from './initializers/FirebaseFirestoreInitializer';
|
|
@@ -38,10 +38,6 @@ export class QuotaTrackingMiddleware {
|
|
|
38
38
|
this.deleteCount += info.count;
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
if (__DEV__) {
|
|
43
|
-
console.log(`[QuotaTracking] ${info.type}: ${info.collection} (${info.count})`);
|
|
44
|
-
}
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
43
|
|
|
@@ -52,9 +48,6 @@ export class QuotaTrackingMiddleware {
|
|
|
52
48
|
if (!cached) {
|
|
53
49
|
this.readCount += count;
|
|
54
50
|
}
|
|
55
|
-
if (__DEV__) {
|
|
56
|
-
console.log(`[QuotaTracking] read: ${collection} (${count})`);
|
|
57
|
-
}
|
|
58
51
|
}
|
|
59
52
|
|
|
60
53
|
/**
|
|
@@ -62,9 +55,6 @@ export class QuotaTrackingMiddleware {
|
|
|
62
55
|
*/
|
|
63
56
|
trackWrite(collection: string, count: number = 1): void {
|
|
64
57
|
this.writeCount += count;
|
|
65
|
-
if (__DEV__) {
|
|
66
|
-
console.log(`[QuotaTracking] write: ${collection} (${count})`);
|
|
67
|
-
}
|
|
68
58
|
}
|
|
69
59
|
|
|
70
60
|
/**
|
|
@@ -72,9 +62,6 @@ export class QuotaTrackingMiddleware {
|
|
|
72
62
|
*/
|
|
73
63
|
trackDelete(collection: string, count: number = 1): void {
|
|
74
64
|
this.deleteCount += count;
|
|
75
|
-
if (__DEV__) {
|
|
76
|
-
console.log(`[QuotaTracking] delete: ${collection} (${count})`);
|
|
77
|
-
}
|
|
78
65
|
}
|
|
79
66
|
|
|
80
67
|
/**
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
* It provides a consistent interface for Firestore operations.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
if (__DEV__) console.log("📍 [LIFECYCLE] BaseRepository.ts - Module loading");
|
|
18
|
-
|
|
19
17
|
import type { Firestore } from "firebase/firestore";
|
|
20
18
|
import { getFirestore } from "../config/FirestoreClient";
|
|
21
19
|
import {
|
|
@@ -119,6 +117,11 @@ export class BaseRepository {
|
|
|
119
117
|
if (this.isQuotaError(error)) {
|
|
120
118
|
this.handleQuotaError(error);
|
|
121
119
|
}
|
|
120
|
+
// Log the error for debugging
|
|
121
|
+
if (__DEV__) {
|
|
122
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
123
|
+
console.error('[BaseRepository] Operation failed:', errorMessage);
|
|
124
|
+
}
|
|
122
125
|
throw error;
|
|
123
126
|
}
|
|
124
127
|
}
|
|
@@ -128,8 +131,5 @@ export class BaseRepository {
|
|
|
128
131
|
*/
|
|
129
132
|
destroy(): void {
|
|
130
133
|
this.isDestroyed = true;
|
|
131
|
-
if (__DEV__) {
|
|
132
|
-
console.log('[BaseRepository] Repository destroyed');
|
|
133
|
-
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -26,24 +26,6 @@ export class RequestLoggerService {
|
|
|
26
26
|
this.logs.shift();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// Log Firestore operations in development mode
|
|
30
|
-
if (__DEV__) {
|
|
31
|
-
const prefix = fullLog.cached ? '[Firestore Cache]' : '[Firestore]';
|
|
32
|
-
const operation = fullLog.type.toUpperCase();
|
|
33
|
-
const status = fullLog.success ? '✓' : '✗';
|
|
34
|
-
const details = fullLog.documentId
|
|
35
|
-
? `${fullLog.collection}/${fullLog.documentId}`
|
|
36
|
-
: fullLog.collection;
|
|
37
|
-
|
|
38
|
-
if (fullLog.success) {
|
|
39
|
-
|
|
40
|
-
console.log(`${prefix} ${status} ${operation}: ${details}`);
|
|
41
|
-
} else {
|
|
42
|
-
|
|
43
|
-
console.error(`${prefix} ${status} ${operation}: ${details}`, fullLog.error);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
29
|
this.notifyListeners(fullLog);
|
|
48
30
|
}
|
|
49
31
|
|
|
@@ -124,12 +106,8 @@ export class RequestLoggerService {
|
|
|
124
106
|
this.listeners.forEach((listener) => {
|
|
125
107
|
try {
|
|
126
108
|
listener(log);
|
|
127
|
-
} catch
|
|
128
|
-
|
|
129
|
-
if (__DEV__) {
|
|
130
|
-
|
|
131
|
-
console.error('[RequestLogger] Listener error:', error);
|
|
132
|
-
}
|
|
109
|
+
} catch {
|
|
110
|
+
// Silently ignore listener errors
|
|
133
111
|
}
|
|
134
112
|
});
|
|
135
113
|
}
|
|
@@ -3,14 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generic types for cursor-based pagination in Firestore.
|
|
5
5
|
* Used across hundreds of apps for consistent pagination interface.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const result: PaginatedResult<Post> = await repository.getPosts({ limit: 10 });
|
|
10
|
-
* console.log(result.items); // Post[]
|
|
11
|
-
* console.log(result.hasMore); // boolean
|
|
12
|
-
* console.log(result.nextCursor); // string | null
|
|
13
|
-
* ```
|
|
14
6
|
*/
|
|
15
7
|
|
|
16
8
|
/**
|