@umituz/react-native-firebase 2.4.100 → 2.6.0
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/domains/firestore/index.ts +11 -58
- package/src/domains/firestore/infrastructure/repositories/BasePaginatedRepository.ts +1 -7
- package/src/domains/firestore/infrastructure/repositories/BaseQueryRepository.ts +8 -34
- package/src/domains/firestore/infrastructure/repositories/BaseRepository.ts +9 -48
- package/src/domains/firestore/presentation/hooks/index.ts +0 -10
- package/src/shared/domain/utils/calculation.util.ts +17 -305
- package/src/shared/domain/utils/index.ts +0 -5
- package/src/shared/infrastructure/config/state/FirebaseClientState.ts +34 -12
- package/src/domains/firestore/domain/constants/QuotaLimits.ts +0 -101
- package/src/domains/firestore/domain/entities/QuotaMetrics.ts +0 -26
- package/src/domains/firestore/domain/entities/RequestLog.ts +0 -28
- package/src/domains/firestore/domain/services/QuotaCalculator.ts +0 -71
- package/src/domains/firestore/infrastructure/middleware/QueryDeduplicationMiddleware.ts +0 -312
- package/src/domains/firestore/infrastructure/middleware/QuotaTrackingMiddleware.ts +0 -95
- package/src/domains/firestore/infrastructure/services/RequestLoggerService.ts +0 -165
- package/src/domains/firestore/presentation/hooks/useSmartFirestoreSnapshot.ts +0 -361
- package/src/domains/firestore/presentation/query-keys/createFirestoreKeys.ts +0 -32
- package/src/domains/firestore/presentation/query-keys/index.ts +0 -1
- package/src/domains/firestore/utils/deduplication/pending-query-manager.util.ts +0 -119
- package/src/domains/firestore/utils/deduplication/query-key-generator.util.ts +0 -34
- package/src/domains/firestore/utils/deduplication/timer-manager.util.ts +0 -83
- package/src/shared/infrastructure/config/base/ClientStateManager.ts +0 -82
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Timer Manager Utility
|
|
3
|
-
* Manages cleanup timers for deduplication middleware
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
interface TimerManagerOptions {
|
|
7
|
-
cleanupIntervalMs: number;
|
|
8
|
-
onCleanup: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class TimerManager {
|
|
12
|
-
private timer: ReturnType<typeof setInterval> | null = null;
|
|
13
|
-
private readonly options: TimerManagerOptions;
|
|
14
|
-
private destroyed = false;
|
|
15
|
-
|
|
16
|
-
constructor(options: TimerManagerOptions) {
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Start the cleanup timer
|
|
22
|
-
* Idempotent: safe to call multiple times
|
|
23
|
-
*/
|
|
24
|
-
start(): void {
|
|
25
|
-
if (this.destroyed) {
|
|
26
|
-
return; // Don't start if destroyed
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Clear existing timer if running (prevents duplicate timers)
|
|
30
|
-
if (this.timer) {
|
|
31
|
-
this.stop();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.timer = setInterval(() => {
|
|
35
|
-
if (this.destroyed) {
|
|
36
|
-
this.stop();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
this.options.onCleanup();
|
|
42
|
-
} catch (error) {
|
|
43
|
-
// Silently handle cleanup errors to prevent timer from causing issues
|
|
44
|
-
// Log error in development for debugging (use __DEV__ for React Native)
|
|
45
|
-
if (__DEV__) {
|
|
46
|
-
console.error('TimerManager cleanup error:', error);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}, this.options.cleanupIntervalMs);
|
|
50
|
-
|
|
51
|
-
// In React Native, timers may not run when app is backgrounded
|
|
52
|
-
// Unref the timer to allow the event loop to exit if this is the only active timer
|
|
53
|
-
if (typeof (this.timer as any).unref === 'function') {
|
|
54
|
-
(this.timer as any).unref();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Stop the cleanup timer
|
|
60
|
-
*/
|
|
61
|
-
stop(): void {
|
|
62
|
-
if (this.timer) {
|
|
63
|
-
clearInterval(this.timer);
|
|
64
|
-
this.timer = null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Check if timer is running
|
|
70
|
-
*/
|
|
71
|
-
isRunning(): boolean {
|
|
72
|
-
return this.timer !== null && !this.destroyed;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Destroy the timer manager
|
|
77
|
-
* Prevents timer from restarting
|
|
78
|
-
*/
|
|
79
|
-
destroy(): void {
|
|
80
|
-
this.destroyed = true;
|
|
81
|
-
this.stop();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Client State Manager
|
|
3
|
-
*
|
|
4
|
-
* Generic state management for Firebase service clients.
|
|
5
|
-
* Provides centralized state tracking for initialization status, errors, and instances.
|
|
6
|
-
*
|
|
7
|
-
* @template TInstance - The service instance type (e.g., FirebaseApp, Firestore, Auth)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
interface ClientState<TInstance> {
|
|
11
|
-
instance: TInstance | null;
|
|
12
|
-
initializationError: string | null;
|
|
13
|
-
isInitialized: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generic client state manager
|
|
18
|
-
* Handles initialization state, error tracking, and instance management
|
|
19
|
-
*/
|
|
20
|
-
export class ClientStateManager<TInstance> {
|
|
21
|
-
private state: ClientState<TInstance>;
|
|
22
|
-
|
|
23
|
-
constructor() {
|
|
24
|
-
this.state = {
|
|
25
|
-
instance: null,
|
|
26
|
-
initializationError: null,
|
|
27
|
-
isInitialized: false,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get the current instance
|
|
33
|
-
*/
|
|
34
|
-
getInstance(): TInstance | null {
|
|
35
|
-
return this.state.instance;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Set the instance
|
|
40
|
-
*/
|
|
41
|
-
setInstance(instance: TInstance | null): void {
|
|
42
|
-
this.state.instance = instance;
|
|
43
|
-
this.state.isInitialized = instance !== null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Check if the service is initialized
|
|
48
|
-
*/
|
|
49
|
-
isInitialized(): boolean {
|
|
50
|
-
return this.state.isInitialized;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Get the initialization error if any
|
|
55
|
-
*/
|
|
56
|
-
getInitializationError(): string | null {
|
|
57
|
-
return this.state.initializationError;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Set the initialization error
|
|
62
|
-
*/
|
|
63
|
-
setInitializationError(error: string | null): void {
|
|
64
|
-
this.state.initializationError = error;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Reset the state
|
|
69
|
-
*/
|
|
70
|
-
reset(): void {
|
|
71
|
-
this.state.instance = null;
|
|
72
|
-
this.state.initializationError = null;
|
|
73
|
-
this.state.isInitialized = false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get the current state (read-only)
|
|
78
|
-
*/
|
|
79
|
-
getState(): Readonly<ClientState<TInstance>> {
|
|
80
|
-
return this.state;
|
|
81
|
-
}
|
|
82
|
-
}
|