@umituz/react-native-firebase 2.4.18 → 2.4.20
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/auth/presentation/hooks/shared/hook-utils.util.ts +0 -20
- package/src/domains/firestore/utils/mapper/enrichment-mapper.util.ts +0 -89
- package/src/shared/domain/utils/error-handler.util.ts +0 -28
- package/src/shared/domain/utils/result.util.ts +0 -30
- package/src/shared/domain/utils/validation.util.ts +0 -40
- package/src/shared/infrastructure/config/FirebaseClient.ts +0 -37
- package/src/shared/infrastructure/config/services/FirebaseServiceInitializer.ts +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-firebase",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.20",
|
|
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",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared Hook Utilities
|
|
3
|
-
* Re-exports all hook utilities for backward compatibility
|
|
4
|
-
* @deprecated Import from specific files instead
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// State Management Hooks
|
|
8
|
-
export type { HookState, HookStateActions } from './state-hooks.util';
|
|
9
|
-
export { useHookState, useAsyncOperation } from './state-hooks.util';
|
|
10
|
-
|
|
11
|
-
// Safe State Hooks
|
|
12
|
-
export {
|
|
13
|
-
useIsMounted,
|
|
14
|
-
useSafeState,
|
|
15
|
-
useDebouncedValue,
|
|
16
|
-
useCleanup,
|
|
17
|
-
} from './safe-state-hooks.util';
|
|
18
|
-
|
|
19
|
-
// Auth Hooks
|
|
20
|
-
export { createAuthStateHandler, useAuthListener } from './auth-hooks.util';
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enrichment Mapper Utility
|
|
3
|
-
* Document mapping with single enrichment source
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { QueryDocumentSnapshot, DocumentData } from 'firebase/firestore';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Map documents with enrichment from related data
|
|
10
|
-
*
|
|
11
|
-
* @deprecated Use mapWithBatchEnrichment for better performance with large datasets.
|
|
12
|
-
* This function fetches enrichments in parallel but doesn't deduplicate keys,
|
|
13
|
-
* and uses sequential async operations which can be slower than batch fetching.
|
|
14
|
-
*
|
|
15
|
-
* Process flow:
|
|
16
|
-
* 1. Extract source data from document
|
|
17
|
-
* 2. Skip if extraction fails or source is invalid
|
|
18
|
-
* 3. Get enrichment key from source
|
|
19
|
-
* 4. Fetch enrichment data using the key
|
|
20
|
-
* 5. Skip if enrichment data not found
|
|
21
|
-
* 6. Combine source and enrichment into result
|
|
22
|
-
*/
|
|
23
|
-
export async function mapWithEnrichment<TSource, TEnrichment, TResult>(
|
|
24
|
-
docs: QueryDocumentSnapshot<DocumentData>[],
|
|
25
|
-
extractSource: (doc: QueryDocumentSnapshot<DocumentData>) => TSource | null,
|
|
26
|
-
getEnrichmentKey: (source: TSource) => string,
|
|
27
|
-
fetchEnrichment: (key: string) => Promise<TEnrichment | null>,
|
|
28
|
-
combineData: (source: TSource, enrichment: TEnrichment) => TResult,
|
|
29
|
-
): Promise<TResult[]> {
|
|
30
|
-
const results: TResult[] = [];
|
|
31
|
-
|
|
32
|
-
for (const doc of docs) {
|
|
33
|
-
const source = extractSource(doc);
|
|
34
|
-
if (!source) continue;
|
|
35
|
-
|
|
36
|
-
const enrichmentKey = getEnrichmentKey(source);
|
|
37
|
-
const enrichment = await fetchEnrichment(enrichmentKey);
|
|
38
|
-
if (!enrichment) continue;
|
|
39
|
-
|
|
40
|
-
results.push(combineData(source, enrichment));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return results;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Map documents with batch enrichment (fetch all enrichments at once)
|
|
48
|
-
*/
|
|
49
|
-
export async function mapWithBatchEnrichment<TSource, TEnrichment, TResult>(
|
|
50
|
-
docs: QueryDocumentSnapshot<DocumentData>[],
|
|
51
|
-
extractSource: (doc: QueryDocumentSnapshot<DocumentData>) => TSource | null,
|
|
52
|
-
getEnrichmentKey: (source: TSource) => string,
|
|
53
|
-
fetchBatchEnrichments: (keys: string[]) => Promise<Map<string, TEnrichment>>,
|
|
54
|
-
combineData: (source: TSource, enrichment: TEnrichment) => TResult,
|
|
55
|
-
): Promise<TResult[]> {
|
|
56
|
-
// First, extract all sources and collect keys
|
|
57
|
-
const sources: TSource[] = [];
|
|
58
|
-
const keys: string[] = [];
|
|
59
|
-
|
|
60
|
-
for (const doc of docs) {
|
|
61
|
-
const source = extractSource(doc);
|
|
62
|
-
if (source) {
|
|
63
|
-
sources.push(source);
|
|
64
|
-
keys.push(getEnrichmentKey(source));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (sources.length === 0) {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// FIX: Deduplicate keys before batch fetch to reduce redundant fetches
|
|
73
|
-
const uniqueKeys = [...new Set(keys)];
|
|
74
|
-
|
|
75
|
-
// Fetch all enrichments in batch (deduplicated)
|
|
76
|
-
const enrichmentMap = await fetchBatchEnrichments(uniqueKeys);
|
|
77
|
-
|
|
78
|
-
// Combine sources with enrichments
|
|
79
|
-
const results: TResult[] = [];
|
|
80
|
-
for (const source of sources) {
|
|
81
|
-
const key = getEnrichmentKey(source);
|
|
82
|
-
const enrichment = enrichmentMap.get(key);
|
|
83
|
-
if (enrichment) {
|
|
84
|
-
results.push(combineData(source, enrichment));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return results;
|
|
89
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Handler Utility
|
|
3
|
-
* Re-exports all error handling utilities for backward compatibility
|
|
4
|
-
* @deprecated Import from specific error-handler files instead
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Error Types
|
|
8
|
-
export type { ErrorInfo } from './result/result-types';
|
|
9
|
-
|
|
10
|
-
// Error Converters
|
|
11
|
-
export { toErrorInfo } from './error-handlers/error-converters';
|
|
12
|
-
|
|
13
|
-
// Error Checkers
|
|
14
|
-
export {
|
|
15
|
-
hasErrorCode,
|
|
16
|
-
isCancelledError,
|
|
17
|
-
isQuotaErrorInfo,
|
|
18
|
-
isNetworkError,
|
|
19
|
-
isAuthError,
|
|
20
|
-
isQuotaError,
|
|
21
|
-
isRetryableError,
|
|
22
|
-
} from './error-handlers/error-checkers';
|
|
23
|
-
|
|
24
|
-
// Error Messages
|
|
25
|
-
export { getQuotaErrorMessage, getRetryableErrorMessage } from './error-handlers/error-messages';
|
|
26
|
-
|
|
27
|
-
// Re-export type guards for convenience
|
|
28
|
-
export { hasCodeProperty, hasMessageProperty, hasCodeAndMessageProperties } from './type-guards.util';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Result Utility
|
|
3
|
-
* Re-exports all result utilities for backward compatibility
|
|
4
|
-
* @deprecated Import from specific result files instead
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Types
|
|
8
|
-
export type {
|
|
9
|
-
ErrorInfo,
|
|
10
|
-
Result,
|
|
11
|
-
SuccessResult,
|
|
12
|
-
FailureResult,
|
|
13
|
-
} from './result/result-types';
|
|
14
|
-
|
|
15
|
-
// Creators
|
|
16
|
-
export {
|
|
17
|
-
successResult,
|
|
18
|
-
failureResult,
|
|
19
|
-
failureResultFrom,
|
|
20
|
-
failureResultFromError,
|
|
21
|
-
} from './result/result-creators';
|
|
22
|
-
|
|
23
|
-
// Helpers
|
|
24
|
-
export {
|
|
25
|
-
isSuccess,
|
|
26
|
-
isFailure,
|
|
27
|
-
getDataOrDefault,
|
|
28
|
-
mapResult,
|
|
29
|
-
chainResults,
|
|
30
|
-
} from './result/result-helpers';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation Utility
|
|
3
|
-
* Re-exports all validators for backward compatibility
|
|
4
|
-
* @deprecated Import from specific validator files instead
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// String Validators
|
|
8
|
-
export { isValidString, isEmptyString, isDefined } from './validators/string.validator';
|
|
9
|
-
|
|
10
|
-
// Firebase Validators
|
|
11
|
-
export {
|
|
12
|
-
isValidFirebaseApiKey,
|
|
13
|
-
isValidFirebaseAuthDomain,
|
|
14
|
-
isValidFirebaseProjectId,
|
|
15
|
-
} from './validators/firebase.validator';
|
|
16
|
-
|
|
17
|
-
// URL Validators
|
|
18
|
-
export { isValidUrl, isValidHttpsUrl } from './validators/url.validator';
|
|
19
|
-
|
|
20
|
-
// User Input Validators
|
|
21
|
-
export {
|
|
22
|
-
isValidEmail,
|
|
23
|
-
isStrongPassword,
|
|
24
|
-
isValidUsername,
|
|
25
|
-
isValidPhoneNumber,
|
|
26
|
-
} from './validators/user-input.validator';
|
|
27
|
-
|
|
28
|
-
// Generic Validators
|
|
29
|
-
export {
|
|
30
|
-
isNonEmptyArray,
|
|
31
|
-
isInRange,
|
|
32
|
-
isPositive,
|
|
33
|
-
isNonNegative,
|
|
34
|
-
hasRequiredProperties,
|
|
35
|
-
allMatch,
|
|
36
|
-
anyMatch,
|
|
37
|
-
} from './validators/generic.validator';
|
|
38
|
-
|
|
39
|
-
// Composite Validators
|
|
40
|
-
export { combineValidators, anyValidator } from './validators/composite.validator';
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Firebase Client - Infrastructure Layer
|
|
3
|
-
*
|
|
4
|
-
* Domain-Driven Design: Infrastructure implementation of Firebase client
|
|
5
|
-
* Singleton pattern for managing Firebase client instance
|
|
6
|
-
*
|
|
7
|
-
* IMPORTANT: This package does NOT read from .env files.
|
|
8
|
-
* Configuration must be provided by the application.
|
|
9
|
-
*
|
|
10
|
-
* @deprecated Import from specific files instead:
|
|
11
|
-
* - FirebaseClientSingleton from './clients/FirebaseClientSingleton'
|
|
12
|
-
* - Initialization functions from './services/FirebaseInitializationService'
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export type { FirebaseApp } from './initializers/FirebaseAppInitializer';
|
|
16
|
-
|
|
17
|
-
// Export singleton for backward compatibility
|
|
18
|
-
export { FirebaseClientSingleton } from './clients/FirebaseClientSingleton';
|
|
19
|
-
import { FirebaseClientSingleton as FCSingleton } from './clients/FirebaseClientSingleton';
|
|
20
|
-
export const firebaseClient = FCSingleton.getInstance();
|
|
21
|
-
|
|
22
|
-
// Re-export types and functions
|
|
23
|
-
export type {
|
|
24
|
-
AuthInitializer,
|
|
25
|
-
ServiceInitializationOptions,
|
|
26
|
-
ServiceInitializationResult,
|
|
27
|
-
} from './services/FirebaseInitializationService';
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
initializeFirebase,
|
|
31
|
-
getFirebaseApp,
|
|
32
|
-
autoInitializeFirebase,
|
|
33
|
-
initializeAllFirebaseServices,
|
|
34
|
-
isFirebaseInitialized,
|
|
35
|
-
getFirebaseInitializationError,
|
|
36
|
-
resetFirebaseClient,
|
|
37
|
-
} from './services/FirebaseInitializationService';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Firebase Service Initializer
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates initialization of all Firebase services
|
|
5
|
-
* NOTE: This file is deprecated - use FirebaseClient.ts instead
|
|
6
|
-
* Kept for backwards compatibility
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { FirebaseApp } from 'firebase/app';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Initialize Firebase services
|
|
13
|
-
* @deprecated Use initializeAllFirebaseServices from FirebaseClient instead
|
|
14
|
-
*/
|
|
15
|
-
export class FirebaseServiceInitializer {
|
|
16
|
-
/**
|
|
17
|
-
* Initialize all Firebase services
|
|
18
|
-
* @deprecated
|
|
19
|
-
*/
|
|
20
|
-
static async initializeAll(
|
|
21
|
-
_app: FirebaseApp,
|
|
22
|
-
_options?: unknown
|
|
23
|
-
): Promise<{ app: FirebaseApp | null; auth: boolean | null }> {
|
|
24
|
-
// This is now handled by FirebaseClient
|
|
25
|
-
return {
|
|
26
|
-
app: null,
|
|
27
|
-
auth: null,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Initialize services (legacy compatibility)
|
|
33
|
-
* @deprecated
|
|
34
|
-
*/
|
|
35
|
-
static async initializeServices(
|
|
36
|
-
_options?: unknown
|
|
37
|
-
): Promise<{ app: FirebaseApp | null; auth: boolean | null }> {
|
|
38
|
-
return {
|
|
39
|
-
app: null,
|
|
40
|
-
auth: null,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|