@umituz/react-native-firebase 1.13.58 → 1.13.60

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.
Files changed (43) hide show
  1. package/README.md +277 -0
  2. package/package.json +10 -5
  3. package/scripts/README.md +513 -0
  4. package/src/auth/README.md +339 -0
  5. package/src/auth/domain/README.md +264 -0
  6. package/src/auth/domain/errors/README.md +291 -0
  7. package/src/auth/infrastructure/config/README.md +239 -0
  8. package/src/auth/infrastructure/config/initializers/FirebaseAuthInitializer.ts +1 -1
  9. package/src/auth/infrastructure/services/README.md +346 -0
  10. package/src/auth/infrastructure/stores/README.md +407 -0
  11. package/src/auth/infrastructure/stores/auth.store.ts +1 -1
  12. package/src/auth/presentation/hooks/README.md +442 -0
  13. package/src/auth/presentation/hooks/useAnonymousAuth.ts +4 -4
  14. package/src/auth/presentation/hooks/utils/auth-state-change.handler.ts +1 -1
  15. package/src/domain/README.md +628 -0
  16. package/src/firestore/README.md +566 -0
  17. package/src/firestore/domain/README.md +325 -0
  18. package/src/firestore/domain/constants/README.md +332 -0
  19. package/src/firestore/domain/entities/README.md +286 -0
  20. package/src/firestore/domain/errors/README.md +389 -0
  21. package/src/firestore/infrastructure/config/FirestoreClient.ts +1 -1
  22. package/src/firestore/infrastructure/config/README.md +239 -0
  23. package/src/firestore/infrastructure/middleware/README.md +316 -0
  24. package/src/firestore/infrastructure/repositories/BaseRepository.ts +1 -1
  25. package/src/firestore/infrastructure/repositories/README.md +425 -0
  26. package/src/firestore/infrastructure/services/README.md +332 -0
  27. package/src/firestore/infrastructure/services/RequestLoggerService.ts +4 -4
  28. package/src/firestore/types/pagination/README.md +332 -0
  29. package/src/firestore/utils/README.md +574 -0
  30. package/src/firestore/utils/dateUtils/README.md +171 -0
  31. package/src/firestore/utils/document-mapper.helper/README.md +309 -0
  32. package/src/firestore/utils/pagination.helper/README.md +298 -0
  33. package/src/firestore/utils/path-resolver/README.md +277 -0
  34. package/src/firestore/utils/query-builder/README.md +291 -0
  35. package/src/firestore/utils/quota-error-detector/README.md +355 -0
  36. package/src/infrastructure/README.md +408 -0
  37. package/src/infrastructure/config/FirebaseClient.ts +1 -1
  38. package/src/infrastructure/config/README.md +262 -0
  39. package/src/presentation/README.md +556 -0
  40. package/src/storage/README.md +493 -0
  41. package/src/storage/deleter/README.md +370 -0
  42. package/src/storage/types/README.md +313 -0
  43. package/src/storage/uploader/README.md +409 -0
@@ -0,0 +1,556 @@
1
+ # Presentation Layer
2
+
3
+ Shared presentation layer components and utilities for React Native applications.
4
+
5
+ ## Purpose
6
+
7
+ Provides reusable UI components, context providers, hooks, and utilities for presenting Firebase data and managing authentication state in React Native applications.
8
+
9
+ ## For AI Agents
10
+
11
+ ### Before Using Presentation Layer
12
+
13
+ 1. **WRAP** app with required providers
14
+ 2. **USE** provided hooks for state management
15
+ 3. **PROTECT** authenticated screens
16
+ 4. **HANDLE** loading and error states
17
+ 5. **NEVER** create duplicate providers or components
18
+
19
+ ### Required Practices
20
+
21
+ 1. **Use providers** - Wrap app with AuthProvider and UserProvider
22
+ 2. **Protect screens** - Use ProtectedScreen for authenticated routes
23
+ 3. **Handle states** - Show loading and error components
24
+ 4. **Use hooks** - Leverage custom hooks for state management
25
+ 5. **Follow patterns** - Use established presentation patterns
26
+
27
+ ### Forbidden Practices
28
+
29
+ ## ❌ NEVER
30
+
31
+ - Create duplicate context providers
32
+ - Skip wrapping app with providers
33
+ - Manually check auth in every component
34
+ - Ignore loading and error states
35
+ - Create duplicate UI components
36
+
37
+ ## ⚠️ Avoid
38
+
39
+ - Provider nesting in wrong order
40
+ - Missing ProtectedScreen wrapper
41
+ - Inline state management
42
+ - Not handling error states
43
+ - Skipping loading indicators
44
+
45
+ ## Context Providers
46
+
47
+ ### AuthProvider
48
+
49
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
50
+
51
+ **Component:** `<AuthProvider>`
52
+
53
+ **Purpose:** Provides authentication context to entire application
54
+
55
+ **Props:**
56
+ - `children: ReactNode` - Child components
57
+
58
+ **Context Value:**
59
+ - `user: User | null` - Current authenticated user
60
+ - `isAuthenticated: boolean` - Authentication status
61
+ - `isLoading: boolean` - Loading state
62
+ - `error: Error | null` - Authentication error
63
+
64
+ **Usage Strategy:**
65
+ 1. Wrap app with AuthProvider at root
66
+ 2. Access context with useAuthContext hook
67
+ 3. Check authentication status before routes
68
+ 4. Handle loading states
69
+ 5. Display error messages
70
+
71
+ **When to Use:**
72
+ - App initialization (root component)
73
+ - Authentication checks
74
+ - Protected routes
75
+ - User data access
76
+ - Auth state management
77
+
78
+ **Provider Placement:**
79
+ - Wrap at highest level (root of app)
80
+ - Place inside NavigationContainer if using React Navigation
81
+ - Ensure all authenticated screens are children
82
+
83
+ ### UserProvider
84
+
85
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
86
+
87
+ **Component:** `<UserProvider>`
88
+
89
+ **Purpose:** Provides user data context to entire application
90
+
91
+ **Props:**
92
+ - `children: ReactNode` - Child components
93
+
94
+ **Context Value:**
95
+ - `user: UserData | null` - User profile data
96
+ - `loading: boolean` - Data loading state
97
+ - `error: Error | null` - Data fetch error
98
+ - `refresh: () => Promise<void>` - Refresh user data
99
+
100
+ **Usage Strategy:**
101
+ 1. Wrap app with UserProvider (inside AuthProvider)
102
+ 2. Access context with useUserContext hook
103
+ 3. Fetch user data on authentication
104
+ 4. Handle loading and error states
105
+ 5. Refresh data when needed
106
+
107
+ **When to Use:**
108
+ - App initialization (after AuthProvider)
109
+ - User profile display
110
+ - User data updates
111
+ - User-dependent features
112
+
113
+ **Provider Placement:**
114
+ - Wrap inside AuthProvider
115
+ - Ensure authenticated before fetching user data
116
+ - Place before navigation/screen components
117
+
118
+ ## UI Components
119
+
120
+ ### ProtectedScreen
121
+
122
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
123
+
124
+ **Component:** `<ProtectedScreen>`
125
+
126
+ **Purpose:** HOC component that protects screens requiring authentication
127
+
128
+ **Props:**
129
+ - `children: ReactNode` - Child components to protect
130
+
131
+ **Usage Strategy:**
132
+ 1. Wrap authenticated screens with ProtectedScreen
133
+ 2. Component redirects to login if not authenticated
134
+ 3. Shows loading while checking auth
135
+ 4. Auto-handles authentication checks
136
+ 5. No manual auth checks needed
137
+
138
+ **When to Use:**
139
+ - Dashboard screens
140
+ - Profile screens
141
+ - Settings screens
142
+ - Any authenticated route
143
+ - Data-sensitive screens
144
+
145
+ **Behavior:**
146
+ - Shows loading while checking auth
147
+ - Redirects to login if not authenticated
148
+ - Renders children if authenticated
149
+ - Handles auth state changes
150
+
151
+ ### LoadingScreen
152
+
153
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
154
+
155
+ **Component:** `<LoadingScreen>`
156
+
157
+ **Purpose:** Reusable loading screen component
158
+
159
+ **Props:**
160
+ - `message?: string` - Optional loading message
161
+
162
+ **Usage Strategy:**
163
+ 1. Show during async operations
164
+ 2. Provide context with message
165
+ 3. Use consistent loading UI
166
+ 4. Replace with content when ready
167
+ 5. Handle all loading states
168
+
169
+ **When to Use:**
170
+ - Data fetching
171
+ - Authentication checks
172
+ - Form submissions
173
+ - Page transitions
174
+ - Any async operation
175
+
176
+ ### ErrorScreen
177
+
178
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
179
+
180
+ **Component:** `<ErrorScreen>`
181
+
182
+ **Purpose:** Reusable error screen component
183
+
184
+ **Props:**
185
+ - `error: Error` - Error to display
186
+ - `onRetry?: () => void` - Optional retry callback
187
+
188
+ **Usage Strategy:**
189
+ 1. Show when errors occur
190
+ 2. Display user-friendly error message
191
+ 3. Provide retry option when possible
192
+ 4. Log error for debugging
193
+ 5. Allow error recovery
194
+
195
+ **When to Use:**
196
+ - Data fetch failures
197
+ - Authentication errors
198
+ - Network errors
199
+ - Validation errors
200
+ - Any operation failure
201
+
202
+ ## Hooks
203
+
204
+ ### useAuthContext
205
+
206
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
207
+
208
+ **Hook:** `useAuthContext()`
209
+
210
+ **Returns:** `AuthContextValue`
211
+
212
+ **Purpose:** Access authentication context
213
+
214
+ **Return Value:**
215
+ - `user: User | null` - Current user
216
+ - `isAuthenticated: boolean` - Auth status
217
+ - `isLoading: boolean` - Loading state
218
+ - `error: Error | null` - Auth error
219
+
220
+ **Usage Strategy:**
221
+ 1. Call in components that need auth
222
+ 2. Check isAuthenticated before showing protected content
223
+ 3. Show loading while isLoading
224
+ 4. Handle errors appropriately
225
+ 5. Redirect if not authenticated
226
+
227
+ **When to Use:**
228
+ - Authentication checks
229
+ - User data access
230
+ - Protected route logic
231
+ - Conditional rendering
232
+ - Auth-dependent features
233
+
234
+ ### useUserContext
235
+
236
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
237
+
238
+ **Hook:** `useUserContext()`
239
+
240
+ **Returns:** `UserContextValue`
241
+
242
+ **Purpose:** Access user data context
243
+
244
+ **Return Value:**
245
+ - `user: UserData | null` - User profile data
246
+ - `loading: boolean` - Loading state
247
+ - `error: Error | null` - Data error
248
+ - `refresh: () => Promise<void>` - Refresh function
249
+
250
+ **Usage Strategy:**
251
+ 1. Call in components that need user data
252
+ 2. Show loading while loading
253
+ 3. Handle errors appropriately
254
+ 4. Use refresh to update data
255
+ 5. Display user information
256
+
257
+ **When to Use:**
258
+ - User profile display
259
+ - User settings
260
+ - User-dependent features
261
+ - User updates
262
+ - Profile completion
263
+
264
+ ### useLoadingState
265
+
266
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
267
+
268
+ **Hook:** `useLoadingState()`
269
+
270
+ **Returns:** `{isLoading, startLoading, stopLoading}`
271
+
272
+ **Purpose:** Manage loading state
273
+
274
+ **Return Value:**
275
+ - `isLoading: boolean` - Loading status
276
+ - `startLoading: () => void` - Start loading
277
+ - `stopLoading: () => void` - Stop loading
278
+
279
+ **Usage Strategy:**
280
+ 1. Call hook in component
281
+ 2. Call startLoading before async operation
282
+ 3. Call stopLoading after operation completes
283
+ 4. Use isLoading for conditional rendering
284
+ 5. Handle in finally block
285
+
286
+ **When to Use:**
287
+ - Data fetching
288
+ - Form submissions
289
+ - Async operations
290
+ - Button loading states
291
+ - Content loading
292
+
293
+ ### useErrorState
294
+
295
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
296
+
297
+ **Hook:** `useErrorState()`
298
+
299
+ **Returns:** `{error, setError, clearError}`
300
+
301
+ **Purpose:** Manage error state
302
+
303
+ **Return Value:**
304
+ - `error: Error | null` - Current error
305
+ - `setError: (error) => void` - Set error
306
+ - `clearError: () => void` - Clear error
307
+
308
+ **Usage Strategy:**
309
+ 1. Call hook in component
310
+ 2. Set error when operation fails
311
+ 3. Display error to user
312
+ 4. Clear error on retry or dismiss
313
+ 5. Auto-clear with setTimeout if needed
314
+
315
+ **When to Use:**
316
+ - Error display
317
+ - Error recovery
318
+ - Form validation
319
+ - API failures
320
+ - User feedback
321
+
322
+ ## HOC Utilities
323
+
324
+ ### withAuthProtection
325
+
326
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
327
+
328
+ **HOC:** `withAuthProtection(Component)`
329
+
330
+ **Purpose:** Higher-order component to protect components
331
+
332
+ **Parameters:**
333
+ - `Component: ReactComponentType` - Component to protect
334
+
335
+ **Returns:** Protected component
336
+
337
+ **Usage Strategy:**
338
+ 1. Wrap component export with HOC
339
+ 2. Component auto-checks authentication
340
+ 3. Redirects if not authenticated
341
+ 4. No manual auth checks needed
342
+ 5. Use for entire screens
343
+
344
+ **When to Use:**
345
+ - Screen-level protection
346
+ - Export-time protection
347
+ - Alternative to ProtectedScreen wrapper
348
+ - Route protection
349
+
350
+ ### withLoading
351
+
352
+ **Import From:** `@umituz/react-native-firebase/presentation` or `src/presentation`
353
+
354
+ **HOC:** `withLoading(Component, options)`
355
+
356
+ **Purpose:** Higher-order component to add loading state
357
+
358
+ **Parameters:**
359
+ - `Component: ReactComponentType` - Component to wrap
360
+ - `options: { loadingComponent, checkLoading }` - Configuration
361
+
362
+ **Returns:** Component with loading state
363
+
364
+ **Usage Strategy:**
365
+ 1. Wrap component that needs loading
366
+ 2. Provide custom loading component
367
+ 3. Define checkLoading function
368
+ 4. HOC auto-shows loading
369
+ 5. Use for consistent loading UI
370
+
371
+ **When to Use:**
372
+ - Consistent loading patterns
373
+ - Reusable loading logic
374
+ - Component-level loading
375
+ - Conditional loading display
376
+
377
+ ## App Structure
378
+
379
+ ### Provider Setup Order
380
+
381
+ **Correct Order:**
382
+ 1. Initialize Firebase
383
+ 2. Wrap with AuthProvider
384
+ 3. Wrap with UserProvider (inside AuthProvider)
385
+ 4. Wrap with NavigationContainer (if using React Navigation)
386
+ 5. Render app screens
387
+
388
+ **Provider Nesting:**
389
+ - AuthProvider (outermost)
390
+ - UserProvider (inside AuthProvider)
391
+ - NavigationContainer (inside UserProvider)
392
+ - Screens (inside NavigationContainer)
393
+
394
+ ### Screen Protection Strategy
395
+
396
+ **Authentication Flow:**
397
+ 1. App starts
398
+ 2. Providers initialize
399
+ 3. Check authentication status
400
+ 4. Show loading while checking
401
+ 5. Redirect to login or dashboard
402
+ 6. Handle auth state changes
403
+
404
+ **Protected Screen:**
405
+ 1. User navigates to protected route
406
+ 2. ProtectedScreen checks authentication
407
+ 3. Redirect to login if not authenticated
408
+ 4. Show content if authenticated
409
+
410
+ ## Common Mistakes to Avoid
411
+
412
+ 1. ❌ Not wrapping app with providers
413
+ - ✅ Always wrap with AuthProvider and UserProvider
414
+
415
+ 2. ❌ Wrong provider order
416
+ - ✅ AuthProvider → UserProvider → Navigation
417
+
418
+ 3. ❌ Not handling loading states
419
+ - ✅ Show loading indicators during async operations
420
+
421
+ 4. ❌ Ignoring error states
422
+ - ✅ Display errors and provide retry options
423
+
424
+ 5. ❌ Manual auth checks in every component
425
+ - ✅ Use ProtectedScreen or withAuthProtection
426
+
427
+ ## AI Agent Instructions
428
+
429
+ ### When Setting Up App
430
+
431
+ 1. Initialize Firebase first
432
+ 2. Wrap app with AuthProvider
433
+ 3. Wrap with UserProvider inside AuthProvider
434
+ 4. Set up navigation
435
+ 5. Test provider hierarchy
436
+
437
+ ### When Creating Screen
438
+
439
+ 1. Check if authentication required
440
+ 2. Use ProtectedScreen if needed
441
+ 3. Handle loading state
442
+ 4. Handle error state
443
+ 5. Provide user feedback
444
+
445
+ ### When Using Hooks
446
+
447
+ 1. Call hooks at component top level
448
+ 2. Destructure return values
449
+ 3. Check states before rendering
450
+ 4. Handle loading and errors
451
+ 5. Update state appropriately
452
+
453
+ ### When Showing Loading
454
+
455
+ 1. Use LoadingScreen component
456
+ 2. Provide context message
457
+ 3. Show during async operations
458
+ 4. Replace with content when ready
459
+ 5. Handle all loading scenarios
460
+
461
+ ## Code Quality Standards
462
+
463
+ ### Provider Setup
464
+
465
+ - Wrap app at root level
466
+ - Follow correct order
467
+ - Nest providers properly
468
+ - Initialize before usage
469
+ - Handle provider errors
470
+
471
+ ### Screen Protection
472
+
473
+ - Use ProtectedScreen consistently
474
+ - Handle all auth states
475
+ - Show loading during checks
476
+ - Redirect appropriately
477
+ - Provide user feedback
478
+
479
+ ### State Management
480
+
481
+ - Use provided hooks
482
+ - Handle loading states
483
+ - Handle error states
484
+ - Update state correctly
485
+ - Provide user feedback
486
+
487
+ ## Performance Considerations
488
+
489
+ ### Provider Performance
490
+
491
+ - Minimize provider re-renders
492
+ - Memoize context values when needed
493
+ - Split providers if needed
494
+ - Avoid deep nesting
495
+ - Optimize context updates
496
+
497
+ ### Component Performance
498
+
499
+ - Use React.memo for expensive components
500
+ - Avoid unnecessary re-renders
501
+ - Optimize hook dependencies
502
+ - Lazy load screens
503
+ - Code split when appropriate
504
+
505
+ ## Related Documentation
506
+
507
+ - [Auth Infrastructure README](../auth/infrastructure/README.md)
508
+ - [Firestore Infrastructure README](../firestore/infrastructure/README.md)
509
+ - [Storage Infrastructure README](../storage/README.md)
510
+ - [Infrastructure README](../infrastructure/README.md)
511
+
512
+ ## API Reference
513
+
514
+ ### Providers
515
+
516
+ **Import Path:** `@umituz/react-native-firebase/presentation` or `src/presentation`
517
+
518
+ | Component | Props | Description |
519
+ |-----------|-------|-------------|
520
+ | `AuthProvider` | `children` | Provides auth context |
521
+ | `UserProvider` | `children` | Provides user context |
522
+
523
+ ### Components
524
+
525
+ **Import Path:** `@umituz/react-native-firebase/presentation` or `src/presentation`
526
+
527
+ | Component | Props | Description |
528
+ |-----------|-------|-------------|
529
+ | `ProtectedScreen` | `children` | Protects authenticated screens |
530
+ | `LoadingScreen` | `message?` | Displays loading state |
531
+ | `ErrorScreen` | `error, onRetry?` | Displays error state |
532
+
533
+ ### Hooks
534
+
535
+ **Import Path:** `@umituz/react-native-firebase/presentation` or `src/presentation`
536
+
537
+ | Hook | Returns | Description |
538
+ |------|---------|-------------|
539
+ | `useAuthContext()` | `AuthContextValue` | Access auth context |
540
+ | `useUserContext()` | `UserContextValue` | Access user context |
541
+ | `useLoadingState()` | `{isLoading, startLoading, stopLoading}` | Manage loading state |
542
+ | `useErrorState()` | `{error, setError, clearError}` | Manage error state |
543
+
544
+ ### HOCs
545
+
546
+ **Import Path:** `@umituz/react-native-firebase/presentation` or `src/presentation`
547
+
548
+ | HOC | Parameters | Description |
549
+ |-----|------------|-------------|
550
+ | `withAuthProtection` | `Component` | Protect component requiring auth |
551
+ | `withLoading` | `Component, options` | Add loading state to component |
552
+
553
+ ---
554
+
555
+ **Last Updated:** 2025-01-08
556
+ **Maintainer:** Presentation Layer Team