@umituz/react-native-firebase 1.5.1 → 1.7.2
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 +15 -31
- package/src/analytics/application/ports/IAnalyticsService.ts +92 -0
- package/src/analytics/index.ts +19 -0
- package/src/analytics/infrastructure/adapters/index.ts +10 -0
- package/src/analytics/infrastructure/adapters/native-analytics.adapter.ts +91 -0
- package/src/analytics/infrastructure/adapters/web-analytics.adapter.ts +63 -0
- package/src/analytics/infrastructure/services/FirebaseAnalyticsService.ts +187 -0
- package/src/analytics/infrastructure/services/PerformanceTracker.ts +49 -0
- package/src/analytics/infrastructure/services/analytics-event.service.ts +72 -0
- package/src/analytics/infrastructure/services/analytics-initializer.service.ts +162 -0
- package/src/analytics/infrastructure/services/analytics-user.service.ts +98 -0
- package/src/analytics/infrastructure/services/index.ts +12 -0
- package/src/analytics/presentation/decorators/PerformanceDecorator.ts +72 -0
- package/src/analytics/presentation/decorators/TrackingDecorator.ts +38 -0
- package/src/analytics/presentation/hooks/useNavigationTracking.ts +70 -0
- package/src/analytics/presentation/hooks/useScreenTime.ts +69 -0
- package/src/analytics/presentation/hooks/useScreenView.ts +70 -0
- package/src/analytics/presentation/utils/analyticsUtils.ts +78 -0
- package/src/crashlytics/index.ts +9 -0
- package/src/crashlytics/infrastructure/adapters/index.ts +8 -0
- package/src/crashlytics/infrastructure/adapters/native-crashlytics.adapter.ts +125 -0
- package/src/crashlytics/infrastructure/services/FirebaseCrashlyticsService.ts +99 -0
- package/src/crashlytics/infrastructure/services/crashlytics-error.service.ts +67 -0
- package/src/crashlytics/infrastructure/services/crashlytics-initializer.service.ts +31 -0
- package/src/crashlytics/infrastructure/services/crashlytics-user.service.ts +91 -0
- package/src/crashlytics/infrastructure/services/index.ts +11 -0
- package/src/domain/errors/FirebaseError.ts +20 -38
- package/src/domain/value-objects/FirebaseConfig.ts +10 -40
- package/src/index.ts +18 -22
- package/src/infrastructure/config/FirebaseClient.ts +16 -4
- package/src/infrastructure/config/initializers/FirebaseAppInitializer.ts +7 -5
- package/README.md +0 -221
- package/lib/application/ports/IFirebaseClient.d.ts +0 -37
- package/lib/application/ports/IFirebaseClient.d.ts.map +0 -1
- package/lib/application/ports/IFirebaseClient.js +0 -8
- package/lib/application/ports/IFirebaseClient.js.map +0 -1
- package/lib/domain/errors/FirebaseError.d.ts +0 -28
- package/lib/domain/errors/FirebaseError.d.ts.map +0 -1
- package/lib/domain/errors/FirebaseError.js +0 -46
- package/lib/domain/errors/FirebaseError.js.map +0 -1
- package/lib/domain/value-objects/FirebaseConfig.d.ts +0 -36
- package/lib/domain/value-objects/FirebaseConfig.d.ts.map +0 -1
- package/lib/domain/value-objects/FirebaseConfig.js +0 -8
- package/lib/domain/value-objects/FirebaseConfig.js.map +0 -1
- package/lib/index.d.ts +0 -26
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -29
- package/lib/index.js.map +0 -1
- package/lib/infrastructure/config/FirebaseClient.d.ts +0 -145
- package/lib/infrastructure/config/FirebaseClient.d.ts.map +0 -1
- package/lib/infrastructure/config/FirebaseClient.js +0 -335
- package/lib/infrastructure/config/FirebaseClient.js.map +0 -1
- package/lib/infrastructure/config/FirebaseConfigLoader.d.ts +0 -16
- package/lib/infrastructure/config/FirebaseConfigLoader.d.ts.map +0 -1
- package/lib/infrastructure/config/FirebaseConfigLoader.js +0 -131
- package/lib/infrastructure/config/FirebaseConfigLoader.js.map +0 -1
- package/lib/infrastructure/config/initializers/FirebaseAppInitializer.d.ts +0 -17
- package/lib/infrastructure/config/initializers/FirebaseAppInitializer.d.ts.map +0 -1
- package/lib/infrastructure/config/initializers/FirebaseAppInitializer.js +0 -83
- package/lib/infrastructure/config/initializers/FirebaseAppInitializer.js.map +0 -1
- package/lib/infrastructure/config/validators/FirebaseConfigValidator.d.ts +0 -18
- package/lib/infrastructure/config/validators/FirebaseConfigValidator.d.ts.map +0 -1
- package/lib/infrastructure/config/validators/FirebaseConfigValidator.js +0 -62
- package/lib/infrastructure/config/validators/FirebaseConfigValidator.js.map +0 -1
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
* Single Responsibility: Initialize Firebase App instance
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import {
|
|
8
|
+
initializeApp,
|
|
9
|
+
getApps,
|
|
10
|
+
type FirebaseApp as FirebaseAppType,
|
|
11
|
+
} from 'firebase/app';
|
|
7
12
|
import type { FirebaseConfig } from '../../../domain/value-objects/FirebaseConfig';
|
|
8
13
|
import { FirebaseInitializationError } from '../../../domain/errors/FirebaseError';
|
|
9
14
|
|
|
10
|
-
export type FirebaseApp =
|
|
11
|
-
|
|
12
|
-
declare const initializeApp: any;
|
|
13
|
-
declare const getApps: any;
|
|
15
|
+
export type FirebaseApp = FirebaseAppType;
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Firebase configuration mapper
|
|
@@ -53,7 +55,7 @@ class FirebaseAppManager {
|
|
|
53
55
|
static getExistingApp(): FirebaseApp | null {
|
|
54
56
|
try {
|
|
55
57
|
const existingApps = getApps();
|
|
56
|
-
return existingApps.length > 0 ? existingApps[0] : null;
|
|
58
|
+
return existingApps.length > 0 ? existingApps[0] ?? null : null;
|
|
57
59
|
} catch {
|
|
58
60
|
return null;
|
|
59
61
|
}
|
package/README.md
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
# @umituz/react-native-firebase
|
|
2
|
-
|
|
3
|
-
Domain-Driven Design Firebase client for React Native apps with type-safe operations and singleton pattern.
|
|
4
|
-
|
|
5
|
-
Built with **SOLID**, **DRY**, and **KISS** principles.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @umituz/react-native-firebase
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Peer Dependencies
|
|
14
|
-
|
|
15
|
-
- `firebase` >= 11.0.0
|
|
16
|
-
- `react` >= 18.2.0
|
|
17
|
-
- `react-native` >= 0.74.0
|
|
18
|
-
- `@react-native-async-storage/async-storage` >= 1.21.0
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
- ✅ Domain-Driven Design (DDD) architecture
|
|
23
|
-
- ✅ SOLID principles (Single Responsibility, Open/Closed, etc.)
|
|
24
|
-
- ✅ DRY (Don't Repeat Yourself)
|
|
25
|
-
- ✅ KISS (Keep It Simple, Stupid)
|
|
26
|
-
- ✅ Singleton pattern for single client instance
|
|
27
|
-
- ✅ Type-safe Firebase operations
|
|
28
|
-
- ✅ Platform-specific initialization (Web vs Native)
|
|
29
|
-
- ✅ **Security**: No .env reading - configuration must be provided by app
|
|
30
|
-
- ✅ Works with Expo and React Native CLI
|
|
31
|
-
|
|
32
|
-
## Important: Configuration
|
|
33
|
-
|
|
34
|
-
**This package does NOT read from .env files for security reasons.** You must provide configuration from your application code.
|
|
35
|
-
|
|
36
|
-
### Why?
|
|
37
|
-
|
|
38
|
-
- **Security**: Prevents accidental exposure of credentials
|
|
39
|
-
- **Flexibility**: Works with any configuration source (Constants, config files, etc.)
|
|
40
|
-
- **Multi-app support**: Same package can be used across hundreds of apps with different configs
|
|
41
|
-
|
|
42
|
-
## Usage
|
|
43
|
-
|
|
44
|
-
### 1. Initialize Firebase Client
|
|
45
|
-
|
|
46
|
-
Initialize the client early in your app (e.g., in `App.tsx` or `index.js`):
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
import { initializeFirebase } from '@umituz/react-native-firebase';
|
|
50
|
-
import Constants from 'expo-constants';
|
|
51
|
-
|
|
52
|
-
// Get configuration from your app's config source
|
|
53
|
-
const config = {
|
|
54
|
-
apiKey: Constants.expoConfig?.extra?.firebaseApiKey || process.env.EXPO_PUBLIC_FIREBASE_API_KEY!,
|
|
55
|
-
authDomain: Constants.expoConfig?.extra?.firebaseAuthDomain || process.env.EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN!,
|
|
56
|
-
projectId: Constants.expoConfig?.extra?.firebaseProjectId || process.env.EXPO_PUBLIC_FIREBASE_PROJECT_ID!,
|
|
57
|
-
storageBucket: Constants.expoConfig?.extra?.firebaseStorageBucket,
|
|
58
|
-
messagingSenderId: Constants.expoConfig?.extra?.firebaseMessagingSenderId,
|
|
59
|
-
appId: Constants.expoConfig?.extra?.firebaseAppId,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// Initialize
|
|
63
|
-
const app = initializeFirebase(config);
|
|
64
|
-
|
|
65
|
-
if (!app) {
|
|
66
|
-
console.error('Failed to initialize Firebase');
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### 2. Use Firebase Services
|
|
71
|
-
|
|
72
|
-
#### Direct Access
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
import { getFirebaseApp } from '@umituz/react-native-firebase';
|
|
76
|
-
import { getFirebaseAuth } from '@umituz/react-native-firebase-auth';
|
|
77
|
-
import { getFirestore } from '@umituz/react-native-firestore';
|
|
78
|
-
|
|
79
|
-
// Get instances
|
|
80
|
-
const app = getFirebaseApp();
|
|
81
|
-
const auth = getFirebaseAuth();
|
|
82
|
-
const db = getFirestore();
|
|
83
|
-
|
|
84
|
-
// Use Firebase features
|
|
85
|
-
import { signInWithEmailAndPassword } from 'firebase/auth';
|
|
86
|
-
import { collection, getDocs } from 'firebase/firestore';
|
|
87
|
-
|
|
88
|
-
// Sign in
|
|
89
|
-
await signInWithEmailAndPassword(auth, email, password);
|
|
90
|
-
|
|
91
|
-
// Query Firestore
|
|
92
|
-
const querySnapshot = await getDocs(collection(db, 'users'));
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### 3. Error Handling
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
import {
|
|
99
|
-
getFirebaseApp,
|
|
100
|
-
FirebaseInitializationError,
|
|
101
|
-
FirebaseConfigurationError,
|
|
102
|
-
} from '@umituz/react-native-firebase';
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
const app = getFirebaseApp();
|
|
106
|
-
// Use app
|
|
107
|
-
} catch (error) {
|
|
108
|
-
if (error instanceof FirebaseInitializationError) {
|
|
109
|
-
console.error('Firebase not initialized:', error.message);
|
|
110
|
-
} else if (error instanceof FirebaseConfigurationError) {
|
|
111
|
-
console.error('Invalid configuration:', error.message);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### 4. Check Initialization Status
|
|
117
|
-
|
|
118
|
-
```typescript
|
|
119
|
-
import {
|
|
120
|
-
isFirebaseInitialized,
|
|
121
|
-
getFirebaseInitializationError,
|
|
122
|
-
} from '@umituz/react-native-firebase';
|
|
123
|
-
|
|
124
|
-
if (isFirebaseInitialized()) {
|
|
125
|
-
console.log('Firebase is ready');
|
|
126
|
-
} else {
|
|
127
|
-
const error = getFirebaseInitializationError();
|
|
128
|
-
console.error('Initialization error:', error);
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Architecture
|
|
133
|
-
|
|
134
|
-
### SOLID Principles
|
|
135
|
-
|
|
136
|
-
- **Single Responsibility**: Each class has one clear purpose
|
|
137
|
-
- `FirebaseConfigValidator`: Only validates configuration
|
|
138
|
-
- `FirebaseAppInitializer`: Only initializes Firebase App
|
|
139
|
-
- `FirebaseClient`: Only orchestrates Firebase App initialization
|
|
140
|
-
|
|
141
|
-
- **Open/Closed**: Extensible through configuration, closed for modification
|
|
142
|
-
|
|
143
|
-
- **Dependency Inversion**: Depends on abstractions (interfaces), not concrete implementations
|
|
144
|
-
|
|
145
|
-
### DRY (Don't Repeat Yourself)
|
|
146
|
-
|
|
147
|
-
- Shared initialization logic extracted to specialized classes
|
|
148
|
-
- No code duplication across platforms
|
|
149
|
-
|
|
150
|
-
### KISS (Keep It Simple, Stupid)
|
|
151
|
-
|
|
152
|
-
- Simple, focused classes
|
|
153
|
-
- Clear responsibilities
|
|
154
|
-
- Easy to understand and maintain
|
|
155
|
-
|
|
156
|
-
## API
|
|
157
|
-
|
|
158
|
-
### Functions
|
|
159
|
-
|
|
160
|
-
- `initializeFirebase(config)`: Initialize Firebase App with configuration
|
|
161
|
-
- `getFirebaseApp()`: Get Firebase App instance (throws if not initialized)
|
|
162
|
-
- `isFirebaseInitialized()`: Check if Firebase App is initialized
|
|
163
|
-
- `getFirebaseInitializationError()`: Get initialization error if any
|
|
164
|
-
- `resetFirebaseClient()`: Reset client instance (useful for testing)
|
|
165
|
-
|
|
166
|
-
### Types
|
|
167
|
-
|
|
168
|
-
- `FirebaseConfig`: Configuration interface
|
|
169
|
-
- `FirebaseApp`: Firebase App type
|
|
170
|
-
|
|
171
|
-
### Errors
|
|
172
|
-
|
|
173
|
-
- `FirebaseError`: Base error class
|
|
174
|
-
- `FirebaseInitializationError`: Initialization errors
|
|
175
|
-
- `FirebaseConfigurationError`: Configuration errors
|
|
176
|
-
|
|
177
|
-
### Related Packages
|
|
178
|
-
|
|
179
|
-
For other Firebase services, use dedicated packages:
|
|
180
|
-
- `@umituz/react-native-firebase-auth` - Firebase Authentication
|
|
181
|
-
- `@umituz/react-native-firebase-analytics` - Firebase Analytics
|
|
182
|
-
- `@umituz/react-native-firebase-crashlytics` - Firebase Crashlytics
|
|
183
|
-
- `@umituz/react-native-firestore` - Firestore initialization and utilities
|
|
184
|
-
|
|
185
|
-
## Integration with Expo
|
|
186
|
-
|
|
187
|
-
For Expo apps, configure in `app.config.js`:
|
|
188
|
-
|
|
189
|
-
```javascript
|
|
190
|
-
module.exports = () => {
|
|
191
|
-
return {
|
|
192
|
-
expo: {
|
|
193
|
-
// ... other config
|
|
194
|
-
extra: {
|
|
195
|
-
firebaseApiKey: process.env.EXPO_PUBLIC_FIREBASE_API_KEY,
|
|
196
|
-
firebaseAuthDomain: process.env.EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
197
|
-
firebaseProjectId: process.env.EXPO_PUBLIC_FIREBASE_PROJECT_ID,
|
|
198
|
-
firebaseStorageBucket: process.env.EXPO_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
199
|
-
firebaseMessagingSenderId: process.env.EXPO_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
200
|
-
firebaseAppId: process.env.EXPO_PUBLIC_FIREBASE_APP_ID,
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## Security Best Practices
|
|
208
|
-
|
|
209
|
-
1. **Never commit credentials**: Use environment variables or secure config files
|
|
210
|
-
2. **Use proper Firebase security rules**: Configure Firestore and Storage rules
|
|
211
|
-
3. **Implement RLS**: Use Firebase security rules for data protection
|
|
212
|
-
4. **Clear user data on logout**: Always clear user data on logout (GDPR compliance)
|
|
213
|
-
|
|
214
|
-
## License
|
|
215
|
-
|
|
216
|
-
MIT
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Firebase Client Port (Interface)
|
|
3
|
-
*
|
|
4
|
-
* Domain-Driven Design: Application layer port for Firebase client
|
|
5
|
-
* Defines the contract for Firebase client operations
|
|
6
|
-
*/
|
|
7
|
-
export type FirebaseApp = any;
|
|
8
|
-
/**
|
|
9
|
-
* Firebase Client Interface
|
|
10
|
-
* Defines the contract for Firebase client operations
|
|
11
|
-
*
|
|
12
|
-
* Note:
|
|
13
|
-
* - Firebase Auth is now handled by @umituz/react-native-firebase-auth
|
|
14
|
-
* - Firestore is now handled by @umituz/react-native-firestore
|
|
15
|
-
*/
|
|
16
|
-
export interface IFirebaseClient {
|
|
17
|
-
/**
|
|
18
|
-
* Get the Firebase app instance
|
|
19
|
-
* Returns null if config is not available (offline mode)
|
|
20
|
-
* @returns Firebase app instance or null if not initialized
|
|
21
|
-
*/
|
|
22
|
-
getApp(): FirebaseApp | null;
|
|
23
|
-
/**
|
|
24
|
-
* Check if client is initialized
|
|
25
|
-
*/
|
|
26
|
-
isInitialized(): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Get initialization error if any
|
|
29
|
-
*/
|
|
30
|
-
getInitializationError(): string | null;
|
|
31
|
-
/**
|
|
32
|
-
* Reset the client instance
|
|
33
|
-
* Useful for testing
|
|
34
|
-
*/
|
|
35
|
-
reset(): void;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=IFirebaseClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IFirebaseClient.d.ts","sourceRoot":"","sources":["../../../src/application/ports/IFirebaseClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC;AAE9B;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,MAAM,IAAI,WAAW,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC;IAEzB;;OAEG;IACH,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAAC;IAExC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IFirebaseClient.js","sourceRoot":"","sources":["../../../src/application/ports/IFirebaseClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Firebase Domain Errors
|
|
3
|
-
*
|
|
4
|
-
* Domain-Driven Design: Error types for Firebase operations
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Base Firebase Error
|
|
8
|
-
*/
|
|
9
|
-
export declare class FirebaseError extends Error {
|
|
10
|
-
readonly code?: string | undefined;
|
|
11
|
-
readonly originalError?: unknown | undefined;
|
|
12
|
-
constructor(message: string, code?: string | undefined, originalError?: unknown | undefined);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Initialization Error
|
|
16
|
-
* Thrown when Firebase client fails to initialize
|
|
17
|
-
*/
|
|
18
|
-
export declare class FirebaseInitializationError extends FirebaseError {
|
|
19
|
-
constructor(message: string, originalError?: unknown);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Configuration Error
|
|
23
|
-
* Thrown when required configuration is missing or invalid
|
|
24
|
-
*/
|
|
25
|
-
export declare class FirebaseConfigurationError extends FirebaseError {
|
|
26
|
-
constructor(message: string, originalError?: unknown);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=FirebaseError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseError.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/FirebaseError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;aAGpB,IAAI,CAAC,EAAE,MAAM;aACb,aAAa,CAAC,EAAE,OAAO;gBAFvC,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,aAAa,CAAC,EAAE,OAAO,YAAA;CAM1C;AAED;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,aAAa;gBAChD,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO;CAKrD;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,aAAa;gBAC/C,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO;CAKrD"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Firebase Domain Errors
|
|
3
|
-
*
|
|
4
|
-
* Domain-Driven Design: Error types for Firebase operations
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Base Firebase Error
|
|
8
|
-
*/
|
|
9
|
-
export class FirebaseError extends Error {
|
|
10
|
-
constructor(message, code, originalError) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.code = code;
|
|
13
|
-
this.originalError = originalError;
|
|
14
|
-
this.name = 'FirebaseError';
|
|
15
|
-
Object.setPrototypeOf(this, FirebaseError.prototype);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Initialization Error
|
|
20
|
-
* Thrown when Firebase client fails to initialize
|
|
21
|
-
*/
|
|
22
|
-
export class FirebaseInitializationError extends FirebaseError {
|
|
23
|
-
constructor(message, originalError) {
|
|
24
|
-
super(message, 'INITIALIZATION_ERROR', originalError);
|
|
25
|
-
this.name = 'FirebaseInitializationError';
|
|
26
|
-
Object.setPrototypeOf(this, FirebaseInitializationError.prototype);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Configuration Error
|
|
31
|
-
* Thrown when required configuration is missing or invalid
|
|
32
|
-
*/
|
|
33
|
-
export class FirebaseConfigurationError extends FirebaseError {
|
|
34
|
-
constructor(message, originalError) {
|
|
35
|
-
super(message, 'CONFIGURATION_ERROR', originalError);
|
|
36
|
-
this.name = 'FirebaseConfigurationError';
|
|
37
|
-
Object.setPrototypeOf(this, FirebaseConfigurationError.prototype);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// Note: FirebaseAnalyticsError, FirebaseCrashlyticsError, FirebaseAuthError, and FirebaseFirestoreError
|
|
41
|
-
// have been moved to their respective packages:
|
|
42
|
-
// - @umituz/react-native-firebase-analytics
|
|
43
|
-
// - @umituz/react-native-firebase-crashlytics
|
|
44
|
-
// - @umituz/react-native-firebase-auth
|
|
45
|
-
// - @umituz/react-native-firestore
|
|
46
|
-
//# sourceMappingURL=FirebaseError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseError.js","sourceRoot":"","sources":["../../../src/domain/errors/FirebaseError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YACE,OAAe,EACC,IAAa,EACb,aAAuB;QAEvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAS;QACb,kBAAa,GAAb,aAAa,CAAU;QAGvC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,aAAa;IAC5D,YAAY,OAAe,EAAE,aAAuB;QAClD,KAAK,CAAC,OAAO,EAAE,sBAAsB,EAAE,aAAa,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,2BAA2B,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,aAAa;IAC3D,YAAY,OAAe,EAAE,aAAuB;QAClD,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,aAAa,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpE,CAAC;CACF;AAED,wGAAwG;AACxG,gDAAgD;AAChD,4CAA4C;AAC5C,8CAA8C;AAC9C,uCAAuC;AACvC,mCAAmC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Firebase Configuration Value Object
|
|
3
|
-
*
|
|
4
|
-
* Domain-Driven Design: Value object for Firebase configuration
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Firebase Configuration
|
|
8
|
-
* Required configuration for initializing Firebase client
|
|
9
|
-
*/
|
|
10
|
-
export interface FirebaseConfig {
|
|
11
|
-
/**
|
|
12
|
-
* Firebase API Key
|
|
13
|
-
*/
|
|
14
|
-
apiKey: string;
|
|
15
|
-
/**
|
|
16
|
-
* Firebase Auth Domain
|
|
17
|
-
*/
|
|
18
|
-
authDomain: string;
|
|
19
|
-
/**
|
|
20
|
-
* Firebase Project ID
|
|
21
|
-
*/
|
|
22
|
-
projectId: string;
|
|
23
|
-
/**
|
|
24
|
-
* Firebase Storage Bucket
|
|
25
|
-
*/
|
|
26
|
-
storageBucket?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Firebase Messaging Sender ID
|
|
29
|
-
*/
|
|
30
|
-
messagingSenderId?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Firebase App ID
|
|
33
|
-
*/
|
|
34
|
-
appId?: string;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=FirebaseConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseConfig.d.ts","sourceRoot":"","sources":["../../../src/domain/value-objects/FirebaseConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseConfig.js","sourceRoot":"","sources":["../../../src/domain/value-objects/FirebaseConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAsCH,mFAAmF"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Native Firebase - Minimal Core Package
|
|
3
|
-
*
|
|
4
|
-
* Domain-Driven Design (DDD) Architecture
|
|
5
|
-
*
|
|
6
|
-
* This package provides ONLY Firebase App initialization.
|
|
7
|
-
* For other Firebase services, use dedicated packages:
|
|
8
|
-
* - @umituz/react-native-firebase-auth - Firebase Authentication
|
|
9
|
-
* - @umituz/react-native-firebase-analytics - Firebase Analytics
|
|
10
|
-
* - @umituz/react-native-firebase-crashlytics - Firebase Crashlytics
|
|
11
|
-
* - @umituz/react-native-firestore - Firestore initialization and utilities
|
|
12
|
-
*
|
|
13
|
-
* Architecture:
|
|
14
|
-
* - domain: Entities, value objects, errors (business logic)
|
|
15
|
-
* - application: Ports (interfaces)
|
|
16
|
-
* - infrastructure: Firebase client implementation
|
|
17
|
-
*
|
|
18
|
-
* Usage:
|
|
19
|
-
* import { initializeFirebase, getFirebaseApp } from '@umituz/react-native-firebase';
|
|
20
|
-
*/
|
|
21
|
-
export { FirebaseError, FirebaseInitializationError, FirebaseConfigurationError, } from './domain/errors/FirebaseError';
|
|
22
|
-
export type { FirebaseConfig } from './domain/value-objects/FirebaseConfig';
|
|
23
|
-
export type { IFirebaseClient } from './application/ports/IFirebaseClient';
|
|
24
|
-
export { initializeFirebase, getFirebaseApp, autoInitializeFirebase, initializeAllFirebaseServices, isFirebaseInitialized, getFirebaseInitializationError, resetFirebaseClient, firebaseClient, } from './infrastructure/config/FirebaseClient';
|
|
25
|
-
export type { FirebaseApp, } from './infrastructure/config/FirebaseClient';
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAM5E,YAAY,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAM3E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,6BAA6B,EAC7B,qBAAqB,EACrB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,GACf,MAAM,wCAAwC,CAAC;AAEhD,YAAY,EACV,WAAW,GACZ,MAAM,wCAAwC,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Native Firebase - Minimal Core Package
|
|
3
|
-
*
|
|
4
|
-
* Domain-Driven Design (DDD) Architecture
|
|
5
|
-
*
|
|
6
|
-
* This package provides ONLY Firebase App initialization.
|
|
7
|
-
* For other Firebase services, use dedicated packages:
|
|
8
|
-
* - @umituz/react-native-firebase-auth - Firebase Authentication
|
|
9
|
-
* - @umituz/react-native-firebase-analytics - Firebase Analytics
|
|
10
|
-
* - @umituz/react-native-firebase-crashlytics - Firebase Crashlytics
|
|
11
|
-
* - @umituz/react-native-firestore - Firestore initialization and utilities
|
|
12
|
-
*
|
|
13
|
-
* Architecture:
|
|
14
|
-
* - domain: Entities, value objects, errors (business logic)
|
|
15
|
-
* - application: Ports (interfaces)
|
|
16
|
-
* - infrastructure: Firebase client implementation
|
|
17
|
-
*
|
|
18
|
-
* Usage:
|
|
19
|
-
* import { initializeFirebase, getFirebaseApp } from '@umituz/react-native-firebase';
|
|
20
|
-
*/
|
|
21
|
-
// =============================================================================
|
|
22
|
-
// DOMAIN LAYER - Business Logic
|
|
23
|
-
// =============================================================================
|
|
24
|
-
export { FirebaseError, FirebaseInitializationError, FirebaseConfigurationError, } from './domain/errors/FirebaseError';
|
|
25
|
-
// =============================================================================
|
|
26
|
-
// INFRASTRUCTURE LAYER - Implementation
|
|
27
|
-
// =============================================================================
|
|
28
|
-
export { initializeFirebase, getFirebaseApp, autoInitializeFirebase, initializeAllFirebaseServices, isFirebaseInitialized, getFirebaseInitializationError, resetFirebaseClient, firebaseClient, } from './infrastructure/config/FirebaseClient';
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gFAAgF;AAChF,gCAAgC;AAChC,gFAAgF;AAEhF,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AAUvC,gFAAgF;AAChF,wCAAwC;AACxC,gFAAgF;AAEhF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,6BAA6B,EAC7B,qBAAqB,EACrB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,GACf,MAAM,wCAAwC,CAAC"}
|
|
@@ -1,145 +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
|
-
* SOLID Principles:
|
|
11
|
-
* - Single Responsibility: Only orchestrates initialization, delegates to specialized classes
|
|
12
|
-
* - Open/Closed: Extensible through configuration, closed for modification
|
|
13
|
-
* - Dependency Inversion: Depends on abstractions (interfaces), not concrete implementations
|
|
14
|
-
*/
|
|
15
|
-
import type { FirebaseConfig } from '../../domain/value-objects/FirebaseConfig';
|
|
16
|
-
import type { IFirebaseClient } from '../../application/ports/IFirebaseClient';
|
|
17
|
-
export type FirebaseApp = any;
|
|
18
|
-
/**
|
|
19
|
-
* Firebase Client Singleton
|
|
20
|
-
* Orchestrates Firebase initialization using specialized initializers
|
|
21
|
-
*/
|
|
22
|
-
declare class FirebaseClientSingleton implements IFirebaseClient {
|
|
23
|
-
private static instance;
|
|
24
|
-
private state;
|
|
25
|
-
private constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Get singleton instance
|
|
28
|
-
*/
|
|
29
|
-
static getInstance(): FirebaseClientSingleton;
|
|
30
|
-
/**
|
|
31
|
-
* Initialize Firebase client with configuration
|
|
32
|
-
* Configuration must be provided by the application (not from .env)
|
|
33
|
-
*
|
|
34
|
-
* @param config - Firebase configuration
|
|
35
|
-
* @returns Firebase app instance or null if initialization fails
|
|
36
|
-
*/
|
|
37
|
-
initialize(config: FirebaseConfig): FirebaseApp | null;
|
|
38
|
-
/**
|
|
39
|
-
* Get the Firebase app instance
|
|
40
|
-
* Auto-initializes from Constants/environment if not already initialized
|
|
41
|
-
* Returns null if config is not available (offline mode - no error)
|
|
42
|
-
* @returns Firebase app instance or null if not initialized
|
|
43
|
-
*/
|
|
44
|
-
getApp(): FirebaseApp | null;
|
|
45
|
-
/**
|
|
46
|
-
* Check if client is initialized
|
|
47
|
-
*/
|
|
48
|
-
isInitialized(): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Get initialization error if any
|
|
51
|
-
*/
|
|
52
|
-
getInitializationError(): string | null;
|
|
53
|
-
/**
|
|
54
|
-
* Reset the client instance
|
|
55
|
-
* Useful for testing
|
|
56
|
-
*/
|
|
57
|
-
reset(): void;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Singleton instance
|
|
61
|
-
*/
|
|
62
|
-
export declare const firebaseClient: FirebaseClientSingleton;
|
|
63
|
-
/**
|
|
64
|
-
* Initialize Firebase client
|
|
65
|
-
* This is the main entry point for applications
|
|
66
|
-
*
|
|
67
|
-
* @param config - Firebase configuration (must be provided by app, not from .env)
|
|
68
|
-
* @returns Firebase app instance or null if initialization fails
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* import { initializeFirebase } from '@umituz/react-native-firebase';
|
|
73
|
-
*
|
|
74
|
-
* const config = {
|
|
75
|
-
* apiKey: 'your-api-key',
|
|
76
|
-
* authDomain: 'your-project.firebaseapp.com',
|
|
77
|
-
* projectId: 'your-project-id',
|
|
78
|
-
* };
|
|
79
|
-
*
|
|
80
|
-
* const app = initializeFirebase(config);
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
export declare function initializeFirebase(config: FirebaseConfig): FirebaseApp | null;
|
|
84
|
-
/**
|
|
85
|
-
* Get Firebase app instance
|
|
86
|
-
* Auto-initializes from Constants/environment if not already initialized
|
|
87
|
-
* Returns null if config is not available (offline mode - no error)
|
|
88
|
-
* @returns Firebase app instance or null if not initialized
|
|
89
|
-
*/
|
|
90
|
-
export declare function getFirebaseApp(): FirebaseApp | null;
|
|
91
|
-
/**
|
|
92
|
-
* Auto-initialize Firebase from Constants/environment
|
|
93
|
-
* Called automatically when getFirebaseApp() is first accessed
|
|
94
|
-
* Can be called manually to initialize early
|
|
95
|
-
* @returns Firebase app instance or null if initialization fails
|
|
96
|
-
*/
|
|
97
|
-
export declare function autoInitializeFirebase(): FirebaseApp | null;
|
|
98
|
-
/**
|
|
99
|
-
* Service initialization result interface
|
|
100
|
-
*/
|
|
101
|
-
interface ServiceInitializationResult {
|
|
102
|
-
app: FirebaseApp | null;
|
|
103
|
-
auth: any | null;
|
|
104
|
-
analytics: any | null;
|
|
105
|
-
crashlytics: any | null;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Initialize all Firebase services (App, Auth, Analytics, Crashlytics)
|
|
109
|
-
* This is the main entry point for applications - call this once at app startup
|
|
110
|
-
* All services will be initialized automatically if Firebase App is available
|
|
111
|
-
*
|
|
112
|
-
* @param config - Optional Firebase configuration (if not provided, will auto-load from Constants/env)
|
|
113
|
-
* @returns Object with initialization results for each service
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* import { initializeAllFirebaseServices } from '@umituz/react-native-firebase';
|
|
118
|
-
*
|
|
119
|
-
* // Auto-initialize from Constants/env
|
|
120
|
-
* const result = await initializeAllFirebaseServices();
|
|
121
|
-
*
|
|
122
|
-
* // Or provide config explicitly
|
|
123
|
-
* const result = await initializeAllFirebaseServices({
|
|
124
|
-
* apiKey: 'your-api-key',
|
|
125
|
-
* projectId: 'your-project-id',
|
|
126
|
-
* // ...
|
|
127
|
-
* });
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
export declare function initializeAllFirebaseServices(config?: FirebaseConfig): Promise<ServiceInitializationResult>;
|
|
131
|
-
/**
|
|
132
|
-
* Check if Firebase client is initialized
|
|
133
|
-
*/
|
|
134
|
-
export declare function isFirebaseInitialized(): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Get initialization error if any
|
|
137
|
-
*/
|
|
138
|
-
export declare function getFirebaseInitializationError(): string | null;
|
|
139
|
-
/**
|
|
140
|
-
* Reset Firebase client instance
|
|
141
|
-
* Useful for testing
|
|
142
|
-
*/
|
|
143
|
-
export declare function resetFirebaseClient(): void;
|
|
144
|
-
export {};
|
|
145
|
-
//# sourceMappingURL=FirebaseClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FirebaseClient.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/config/FirebaseClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAK/E,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC;AA6I9B;;;GAGG;AACH,cAAM,uBAAwB,YAAW,eAAe;IACtD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAwC;IAC/D,OAAO,CAAC,KAAK,CAAsB;IAEnC,OAAO;IAIP;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,uBAAuB;IAO7C;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,IAAI;IAItD;;;;;OAKG;IACH,MAAM,IAAI,WAAW,GAAG,IAAI;IAI5B;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,sBAAsB,IAAI,MAAM,GAAG,IAAI;IAIvC;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,yBAAwC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,GACrB,WAAW,GAAG,IAAI,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,GAAG,IAAI,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,WAAW,GAAG,IAAI,CAM3D;AAED;;GAEG;AACH,UAAU,2BAA2B;IACnC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACjB,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,GAAG,GAAG,IAAI,CAAC;CACzB;AAiED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,2BAA2B,CAAC,CAoBtC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,GAAG,IAAI,CAE9D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|