@umituz/react-native-firebase 2.4.24 → 2.4.25

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": "2.4.24",
3
+ "version": "2.4.25",
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",
@@ -14,7 +14,7 @@ import * as AppleAuthentication from "expo-apple-authentication";
14
14
  import { Platform } from "react-native";
15
15
  import { generateNonce, hashNonce } from "../../../auth/infrastructure/services/crypto.util";
16
16
  import { executeOperation, failureResultFrom, toErrorInfo, ERROR_MESSAGES } from "../../../../shared/domain/utils";
17
- import { isCancelledError } from "../../../../shared/domain/utils/error-handler.util";
17
+ import { isCancelledError } from "../../../../shared/domain/utils/error-handlers/error-checkers";
18
18
  import type {
19
19
  ReauthenticationResult,
20
20
  AuthProviderType,
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { Auth } from 'firebase/auth';
8
- import { getFirebaseApp } from '../../../../shared/infrastructure/config/FirebaseClient';
8
+ import { getFirebaseApp } from '../../../../shared/infrastructure/config/services/FirebaseInitializationService';
9
9
  import { FirebaseAuthInitializer } from './initializers/FirebaseAuthInitializer';
10
10
  import type { FirebaseAuthConfig } from '../../domain/value-objects/FirebaseAuthConfig';
11
11
  import { ServiceClientSingleton } from '../../../../shared/infrastructure/config/base/ServiceClientSingleton';
@@ -5,7 +5,7 @@
5
5
 
6
6
  import type { User, Auth } from 'firebase/auth';
7
7
  import { getFirebaseAuth } from '../config/FirebaseAuthClient';
8
- import { isValidString } from '../../../../shared/domain/utils/validation.util';
8
+ import { isValidString } from '../../../../shared/domain/utils/validators/string.validator';
9
9
 
10
10
  export interface AuthCheckResult {
11
11
  isAuthenticated: boolean;
@@ -57,12 +57,6 @@ export type {
57
57
  } from './types/pagination.types';
58
58
  export { EMPTY_PAGINATED_RESULT } from './types/pagination.types';
59
59
 
60
- // Document Mapper
61
- export {
62
- DocumentMapperHelper,
63
- createDocumentMapper,
64
- } from './utils/document-mapper.helper';
65
-
66
60
  // Domain Constants
67
61
  export {
68
62
  FREE_TIER_LIMITS,
@@ -91,8 +85,10 @@ export { QuotaCalculator } from './domain/services/QuotaCalculator';
91
85
  export {
92
86
  isQuotaError,
93
87
  isRetryableError,
88
+ } from '../../shared/domain/utils/error-handlers/error-checkers';
89
+ export {
94
90
  getQuotaErrorMessage,
95
- } from './utils/quota-error-detector.util';
91
+ } from '../../shared/domain/utils/error-handlers/error-messages';
96
92
 
97
93
  // Middleware
98
94
  export {
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import type { Firestore } from 'firebase/firestore';
12
- import { getFirebaseApp } from '../../../../shared/infrastructure/config/FirebaseClient';
12
+ import { getFirebaseApp } from '../../../../shared/infrastructure/config/services/FirebaseInitializationService';
13
13
  import { FirebaseFirestoreInitializer } from './initializers/FirebaseFirestoreInitializer';
14
14
  import { ServiceClientSingleton } from '../../../../shared/infrastructure/config/base/ServiceClientSingleton';
15
15
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  import type { Firestore, CollectionReference, DocumentReference, DocumentData } from 'firebase/firestore';
12
12
  import { getFirestore, collection, doc } from 'firebase/firestore';
13
- import { isQuotaError as checkQuotaError } from '../../utils/quota-error-detector.util';
13
+ import { isQuotaError as checkQuotaError } from '../../../../shared/domain/utils/error-handlers/error-checkers';
14
14
  import { ERROR_MESSAGES } from '../../../../shared/domain/utils/error-handlers/error-messages';
15
15
  import { quotaTrackingMiddleware } from '../middleware/QuotaTrackingMiddleware';
16
16
 
package/src/index.ts CHANGED
@@ -2,12 +2,6 @@
2
2
  * React Native Firebase - Unified Package
3
3
  *
4
4
  * Domain-Driven Design (DDD) Architecture
5
- *
6
- * Core exports - App initialization and shared utilities
7
- *
8
- * Module-specific exports available via:
9
- * - @umituz/react-native-firebase/auth
10
- * - @umituz/react-native-firebase/firestore
11
5
  */
12
6
 
13
7
  // Core Errors
@@ -30,15 +24,18 @@ export {
30
24
  isFirebaseInitialized,
31
25
  getFirebaseInitializationError,
32
26
  resetFirebaseClient,
33
- firebaseClient,
34
- } from "./shared/infrastructure/config/FirebaseClient";
27
+ } from "./shared/infrastructure/config/services/FirebaseInitializationService";
35
28
 
36
29
  export type {
37
- FirebaseApp,
38
30
  AuthInitializer,
39
31
  ServiceInitializationOptions,
40
32
  ServiceInitializationResult,
41
- } from "./shared/infrastructure/config/FirebaseClient";
33
+ } from "./shared/infrastructure/config/services/FirebaseInitializationService";
34
+
35
+ export type { FirebaseApp } from "./shared/infrastructure/config/initializers/FirebaseAppInitializer";
36
+
37
+ import { FirebaseClientSingleton } from "./shared/infrastructure/config/clients/FirebaseClientSingleton";
38
+ export const firebaseClient = FirebaseClientSingleton.getInstance();
42
39
 
43
40
  // Type Guards
44
41
  export {
@@ -56,40 +53,16 @@ export {
56
53
  export * from "./domains/auth";
57
54
  export * from "./domains/account-deletion";
58
55
 
59
-
60
-
61
56
  // Firestore Module Exports
62
- export {
63
- BaseRepository,
64
- BaseQueryRepository,
65
- BasePaginatedRepository,
66
- } from "./domains/firestore";
67
57
  export * from "./domains/firestore";
68
- export { Timestamp } from "firebase/firestore";
69
58
  export type {
70
59
  Transaction,
71
60
  DocumentReference,
72
- CollectionReference,
73
61
  WriteBatch,
74
62
  DocumentSnapshot,
75
63
  QuerySnapshot,
76
- QueryDocumentSnapshot,
77
- DocumentData,
78
- Firestore,
79
64
  } from "firebase/firestore";
80
65
 
81
- // Firestore Helper Utilities
82
- export {
83
- withFirestore,
84
- withFirestoreVoid,
85
- withFirestoreBool,
86
- createErrorResult,
87
- createSuccessResult,
88
- runTransaction,
89
- serverTimestamp,
90
- } from "./domains/firestore/utils/firestore-helper";
91
- export type { NoDbResult } from "./domains/firestore/utils/firestore-helper";
92
-
93
66
  // Init Module Factory
94
67
  export {
95
68
  createFirebaseInitModule,
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { InitModule } from '@umituz/react-native-design-system';
7
- import { initializeAllFirebaseServices } from '../shared/infrastructure/config/FirebaseClient';
7
+ import { initializeAllFirebaseServices } from '../shared/infrastructure/config/services/FirebaseInitializationService';
8
8
 
9
9
  export interface FirebaseInitModuleConfig {
10
10
  /**
@@ -3,8 +3,8 @@
3
3
  * Retry and timeout support for async operations
4
4
  */
5
5
 
6
- import type { Result } from '../result.util';
7
- import { failureResultFromError, successResult } from '../result.util';
6
+ import type { Result } from '../result/result-types';
7
+ import { failureResultFromError, successResult } from '../result/result-creators';
8
8
  import { executeOperation } from './basic-executors.util';
9
9
 
10
10
  /**
@@ -3,8 +3,8 @@
3
3
  * Core async operation execution with error handling
4
4
  */
5
5
 
6
- import type { Result } from '../result.util';
7
- import { successResult } from '../result.util';
6
+ import type { Result } from '../result/result-types';
7
+ import { successResult } from '../result/result-creators';
8
8
  import { toErrorInfo } from '../error-handlers/error-converters';
9
9
 
10
10
  /**
@@ -1,5 +1,6 @@
1
- import type { Result } from '../result.util';
2
- import { failureResultFromError, successResult, isSuccess, isFailure } from '../result.util';
1
+ import type { Result } from '../result/result-types';
2
+ import { failureResultFromError, successResult } from '../result/result-creators';
3
+ import { isSuccess, isFailure } from '../result/result-helpers';
3
4
 
4
5
  export async function executeAll<T>(
5
6
  ...operations: (() => Promise<Result<T>>)[]
@@ -3,22 +3,28 @@
3
3
  * Centralized utilities for domain operations
4
4
  */
5
5
 
6
- // Result types
6
+ // Result types and helpers
7
+ export type {
8
+ Result,
9
+ SuccessResult,
10
+ FailureResult,
11
+ ErrorInfo,
12
+ } from './result/result-types';
13
+
7
14
  export {
8
15
  successResult,
9
16
  failureResult,
10
17
  failureResultFrom,
11
18
  failureResultFromError,
19
+ } from './result/result-creators';
20
+
21
+ export {
12
22
  isSuccess,
13
23
  isFailure,
14
24
  getDataOrDefault,
15
25
  mapResult,
16
26
  chainResults,
17
- type Result,
18
- type SuccessResult,
19
- type FailureResult,
20
- type ErrorInfo,
21
- } from './result.util';
27
+ } from './result/result-helpers';
22
28
 
23
29
  // Async operation execution
24
30
  export {
@@ -52,8 +58,9 @@ export {
52
58
  } from './credential.util';
53
59
 
54
60
  // Error handling
61
+ export { toErrorInfo } from './error-handlers/error-converters';
62
+
55
63
  export {
56
- toErrorInfo,
57
64
  hasErrorCode,
58
65
  isCancelledError,
59
66
  isQuotaErrorInfo,
@@ -61,14 +68,12 @@ export {
61
68
  isAuthError,
62
69
  isQuotaError,
63
70
  isRetryableError,
64
- getQuotaErrorMessage,
65
- getRetryableErrorMessage,
66
- type ErrorInfo as ErrorHandlerErrorInfo,
67
- } from './error-handler.util';
71
+ } from './error-handlers/error-checkers';
68
72
 
69
- // Error messages
70
73
  export {
71
74
  ERROR_MESSAGES,
75
+ getQuotaErrorMessage,
76
+ getRetryableErrorMessage,
72
77
  } from './error-handlers/error-messages';
73
78
 
74
79
  // Type guards
@@ -82,18 +87,28 @@ export {
82
87
  export {
83
88
  isValidString,
84
89
  isEmptyString,
90
+ isDefined,
91
+ } from './validators/string.validator';
92
+
93
+ export {
85
94
  isValidFirebaseApiKey,
86
95
  isValidFirebaseAuthDomain,
87
96
  isValidFirebaseProjectId,
97
+ } from './validators/firebase.validator';
98
+
99
+ export {
88
100
  isValidUrl,
89
101
  isValidHttpsUrl,
90
- isValidEmail,
91
- isDefined,
102
+ } from './validators/url.validator';
103
+
104
+ export { isValidEmail } from './validators/user-input.validator';
105
+
106
+ export {
92
107
  isNonEmptyArray,
93
108
  isInRange,
94
109
  isPositive,
95
110
  isNonNegative,
96
- } from './validation.util';
111
+ } from './validators/generic.validator';
97
112
 
98
113
  // ID generation
99
114
  export {
@@ -7,11 +7,8 @@
7
7
  */
8
8
 
9
9
  import type { FirebaseConfig } from '../../domain/value-objects/FirebaseConfig';
10
- import {
11
- isValidString,
12
- isValidFirebaseApiKey,
13
- isValidFirebaseAuthDomain,
14
- } from '../../domain/utils/validation.util';
10
+ import { isValidString } from '../../domain/utils/validators/string.validator';
11
+ import { isValidFirebaseApiKey, isValidFirebaseAuthDomain } from '../../domain/utils/validators/firebase.validator';
15
12
 
16
13
  type ConfigKey = 'apiKey' | 'authDomain' | 'projectId' | 'storageBucket' | 'messagingSenderId' | 'appId';
17
14
 
@@ -7,7 +7,8 @@
7
7
 
8
8
  import type { FirebaseConfig } from '../../../domain/value-objects/FirebaseConfig';
9
9
  import { FirebaseConfigurationError } from '../../../domain/errors/FirebaseError';
10
- import { isValidString, isValidFirebaseApiKey, isValidFirebaseProjectId, isValidFirebaseAuthDomain } from '../../../domain/utils/validation.util';
10
+ import { isValidString } from '../../../domain/utils/validators/string.validator';
11
+ import { isValidFirebaseApiKey, isValidFirebaseProjectId, isValidFirebaseAuthDomain } from '../../../domain/utils/validators/firebase.validator';
11
12
 
12
13
  /**
13
14
  * Validation rule interface
@@ -1,153 +0,0 @@
1
- /**
2
- * Document Mapper Helper
3
- *
4
- * Utilities for batch document processing with enrichment.
5
- * Handles document extraction, validation, and enrichment with related data.
6
- *
7
- * App-agnostic: Works with any document type and any enrichment logic.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { DocumentMapperHelper } from '@umituz/react-native-firestore';
12
- *
13
- * const mapper = new DocumentMapperHelper<Post, User, EnrichedPost>();
14
- * const enriched = await mapper.mapWithEnrichment(
15
- * postDocs,
16
- * post => extractPost(post),
17
- * post => post.userId,
18
- * userId => userRepo.getById(userId),
19
- * (post, user) => ({ ...post, user })
20
- * );
21
- * ```
22
- */
23
-
24
- import type { QueryDocumentSnapshot, DocumentData } from 'firebase/firestore';
25
- import { mapDocuments } from './mapper/base-mapper.util';
26
- import { mapWithEnrichment, mapWithBatchEnrichment } from './mapper/enrichment-mapper.util';
27
- import { mapWithMultipleEnrichments } from './mapper/multi-enrichment-mapper.util';
28
-
29
- export class DocumentMapperHelper<TSource, TEnrichment, TResult> {
30
- /**
31
- * Map documents with enrichment from related data
32
- *
33
- * Process flow:
34
- * 1. Extract source data from document
35
- * 2. Skip if extraction fails or source is invalid
36
- * 3. Get enrichment key from source
37
- * 4. Fetch enrichment data using the key
38
- * 5. Skip if enrichment data not found
39
- * 6. Combine source and enrichment into result
40
- *
41
- * @param docs - Firestore document snapshots
42
- * @param extractSource - Extract source data from document
43
- * @param getEnrichmentKey - Get enrichment key from source
44
- * @param fetchEnrichment - Fetch enrichment data by key
45
- * @param combineData - Combine source and enrichment into result
46
- * @returns Array of enriched results
47
- */
48
- async mapWithEnrichment(
49
- docs: QueryDocumentSnapshot<DocumentData>[],
50
- extractSource: (doc: QueryDocumentSnapshot<DocumentData>) => TSource | null,
51
- getEnrichmentKey: (source: TSource) => string,
52
- fetchEnrichment: (key: string) => Promise<TEnrichment | null>,
53
- combineData: (source: TSource, enrichment: TEnrichment) => TResult,
54
- ): Promise<TResult[]> {
55
- return mapWithEnrichment(
56
- docs,
57
- extractSource,
58
- getEnrichmentKey,
59
- fetchEnrichment,
60
- combineData,
61
- );
62
- }
63
-
64
- /**
65
- * Map documents with batch enrichment (fetch all enrichments at once)
66
- *
67
- * More efficient than mapWithEnrichment when dealing with multiple documents.
68
- *
69
- * @param docs - Firestore document snapshots
70
- * @param extractSource - Extract source data from document
71
- * @param getEnrichmentKey - Get enrichment key from source
72
- * @param fetchBatchEnrichments - Fetch all enrichments by keys in batch
73
- * @param combineData - Combine source and enrichment into result
74
- * @returns Array of enriched results
75
- */
76
- async mapWithBatchEnrichment(
77
- docs: QueryDocumentSnapshot<DocumentData>[],
78
- extractSource: (doc: QueryDocumentSnapshot<DocumentData>) => TSource | null,
79
- getEnrichmentKey: (source: TSource) => string,
80
- fetchBatchEnrichments: (keys: string[]) => Promise<Map<string, TEnrichment>>,
81
- combineData: (source: TSource, enrichment: TEnrichment) => TResult,
82
- ): Promise<TResult[]> {
83
- return mapWithBatchEnrichment(
84
- docs,
85
- extractSource,
86
- getEnrichmentKey,
87
- fetchBatchEnrichments,
88
- combineData,
89
- );
90
- }
91
-
92
- /**
93
- * Map documents with multiple enrichments
94
- *
95
- * Similar to mapWithEnrichment but supports multiple enrichment sources.
96
- * Useful when result needs data from multiple related collections.
97
- *
98
- * @param docs - Firestore document snapshots
99
- * @param extractSource - Extract source data from document
100
- * @param getEnrichmentKeys - Get all enrichment keys from source
101
- * @param fetchEnrichments - Fetch all enrichment data by keys
102
- * @param combineData - Combine source and enrichments into result
103
- * @returns Array of enriched results
104
- */
105
- async mapWithMultipleEnrichments<TEnrichments extends Record<string, unknown>>(
106
- docs: QueryDocumentSnapshot<DocumentData>[],
107
- extractSource: (doc: QueryDocumentSnapshot<DocumentData>) => TSource | null,
108
- getEnrichmentKeys: (source: TSource) => Record<string, string>,
109
- fetchEnrichments: (keys: Record<string, string>) => Promise<TEnrichments | null>,
110
- combineData: (source: TSource, enrichments: TEnrichments) => TResult,
111
- ): Promise<TResult[]> {
112
- return mapWithMultipleEnrichments(
113
- docs,
114
- extractSource,
115
- getEnrichmentKeys,
116
- fetchEnrichments,
117
- combineData,
118
- );
119
- }
120
-
121
- /**
122
- * Simple document mapping without enrichment
123
- *
124
- * @param docs - Firestore document snapshots
125
- * @param extractData - Extract data from document
126
- * @returns Array of extracted data (nulls filtered out)
127
- */
128
- map(
129
- docs: QueryDocumentSnapshot<DocumentData>[],
130
- extractData: (doc: QueryDocumentSnapshot<DocumentData>) => TResult | null,
131
- ): TResult[] {
132
- return mapDocuments(docs, extractData);
133
- }
134
- }
135
-
136
- /**
137
- * Create document mapper helper
138
- *
139
- * @returns DocumentMapperHelper instance
140
- *
141
- * @example
142
- * ```typescript
143
- * const mapper = createDocumentMapper<Post, User, EnrichedPost>();
144
- * const enriched = await mapper.mapWithEnrichment(...);
145
- * ```
146
- */
147
- export function createDocumentMapper<
148
- TSource,
149
- TEnrichment,
150
- TResult,
151
- >(): DocumentMapperHelper<TSource, TEnrichment, TResult> {
152
- return new DocumentMapperHelper<TSource, TEnrichment, TResult>();
153
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Base Mapper Utility
3
- * Core document mapping functionality
4
- */
5
-
6
- import type { QueryDocumentSnapshot, DocumentData } from 'firebase/firestore';
7
-
8
- /**
9
- * Simple document mapping without enrichment
10
- */
11
- export function mapDocuments<T>(
12
- docs: QueryDocumentSnapshot<DocumentData>[],
13
- extractData: (doc: QueryDocumentSnapshot<DocumentData>) => T | null,
14
- ): T[] {
15
- const results: T[] = [];
16
-
17
- for (const doc of docs) {
18
- const data = extractData(doc);
19
- if (data != null) {
20
- results.push(data);
21
- }
22
- }
23
-
24
- return results;
25
- }
26
-
27
- /**
28
- * Filter out null values from array
29
- */
30
- export function filterNull<T>(items: (T | null)[]): T[] {
31
- return items.filter((item): item is T => item != null);
32
- }
33
-
34
- /**
35
- * Safe document extraction with null check
36
- */
37
- export function extractDocumentData<T>(
38
- doc: QueryDocumentSnapshot<DocumentData>,
39
- extractor: (doc: QueryDocumentSnapshot<DocumentData>) => T | null
40
- ): T | null {
41
- return extractor(doc);
42
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * Multiple Enrichment Mapper Utility
3
- * Document mapping with multiple enrichment sources
4
- */
5
-
6
- import type { QueryDocumentSnapshot, DocumentData } from 'firebase/firestore';
7
-
8
- /**
9
- * Map documents with multiple enrichments
10
- *
11
- * Similar to mapWithEnrichment but supports multiple enrichment sources.
12
- * Useful when result needs data from multiple related collections.
13
- */
14
- export async function mapWithMultipleEnrichments<
15
- TSource,
16
- TEnrichments extends Record<string, unknown>,
17
- TResult
18
- >(
19
- docs: QueryDocumentSnapshot<DocumentData>[],
20
- extractSource: (doc: QueryDocumentSnapshot<DocumentData>) => TSource | null,
21
- getEnrichmentKeys: (source: TSource) => Record<string, string>,
22
- fetchEnrichments: (keys: Record<string, string>) => Promise<TEnrichments | null>,
23
- combineData: (source: TSource, enrichments: TEnrichments) => TResult,
24
- ): Promise<TResult[]> {
25
- const results: TResult[] = [];
26
-
27
- for (const doc of docs) {
28
- const source = extractSource(doc);
29
- if (!source) continue;
30
-
31
- const enrichmentKeys = getEnrichmentKeys(source);
32
- const enrichments = await fetchEnrichments(enrichmentKeys);
33
- if (!enrichments) continue;
34
-
35
- results.push(combineData(source, enrichments));
36
- }
37
-
38
- return results;
39
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Quota Error Detection Utilities
3
- *
4
- * Re-exports centralized quota error detection from error-handler.util.ts
5
- * This maintains backwards compatibility while using a single source of truth.
6
- */
7
-
8
- export {
9
- isQuotaError,
10
- isRetryableError,
11
- getQuotaErrorMessage,
12
- getRetryableErrorMessage,
13
- } from '../../../shared/domain/utils/error-handler.util';
@@ -1,28 +0,0 @@
1
- /**
2
- * FirebaseClient - Barrel re-export
3
- * Aggregates exports from refactored sub-modules for backward compatibility
4
- */
5
-
6
- // Functions
7
- export {
8
- initializeFirebase,
9
- getFirebaseApp,
10
- autoInitializeFirebase,
11
- initializeAllFirebaseServices,
12
- isFirebaseInitialized,
13
- getFirebaseInitializationError,
14
- resetFirebaseClient,
15
- } from './services/FirebaseInitializationService';
16
-
17
- // Types
18
- export type {
19
- AuthInitializer,
20
- ServiceInitializationOptions,
21
- ServiceInitializationResult,
22
- } from './services/FirebaseInitializationService';
23
-
24
- export type { FirebaseApp } from './initializers/FirebaseAppInitializer';
25
-
26
- // Singleton instance
27
- import { FirebaseClientSingleton } from './clients/FirebaseClientSingleton';
28
- export const firebaseClient = FirebaseClientSingleton.getInstance();