@umituz/react-native-firebase 1.13.58 → 1.13.59

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 (35) hide show
  1. package/README.md +277 -0
  2. package/package.json +1 -1
  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/services/README.md +346 -0
  9. package/src/auth/infrastructure/stores/README.md +407 -0
  10. package/src/auth/presentation/hooks/README.md +442 -0
  11. package/src/domain/README.md +628 -0
  12. package/src/firestore/README.md +566 -0
  13. package/src/firestore/domain/README.md +325 -0
  14. package/src/firestore/domain/constants/README.md +332 -0
  15. package/src/firestore/domain/entities/README.md +286 -0
  16. package/src/firestore/domain/errors/README.md +389 -0
  17. package/src/firestore/infrastructure/config/README.md +239 -0
  18. package/src/firestore/infrastructure/middleware/README.md +316 -0
  19. package/src/firestore/infrastructure/repositories/README.md +425 -0
  20. package/src/firestore/infrastructure/services/README.md +332 -0
  21. package/src/firestore/types/pagination/README.md +332 -0
  22. package/src/firestore/utils/README.md +574 -0
  23. package/src/firestore/utils/dateUtils/README.md +171 -0
  24. package/src/firestore/utils/document-mapper.helper/README.md +309 -0
  25. package/src/firestore/utils/pagination.helper/README.md +298 -0
  26. package/src/firestore/utils/path-resolver/README.md +277 -0
  27. package/src/firestore/utils/query-builder/README.md +291 -0
  28. package/src/firestore/utils/quota-error-detector/README.md +355 -0
  29. package/src/infrastructure/README.md +408 -0
  30. package/src/infrastructure/config/README.md +262 -0
  31. package/src/presentation/README.md +556 -0
  32. package/src/storage/README.md +493 -0
  33. package/src/storage/deleter/README.md +370 -0
  34. package/src/storage/types/README.md +313 -0
  35. package/src/storage/uploader/README.md +409 -0
@@ -0,0 +1,628 @@
1
+ # Shared Domain
2
+
3
+ Shared domain models, types, and business logic used across multiple modules.
4
+
5
+ ## Purpose
6
+
7
+ Implements Domain-Driven Design (DDD) principles with shared domain entities, value objects, business rules, and domain errors used by Auth, Firestore, and Storage modules.
8
+
9
+ ## For AI Agents
10
+
11
+ ### Before Using Shared Domain
12
+
13
+ 1. **UNDERSTAND** DDD architecture principles
14
+ 2. **USE** value objects for business concepts
15
+ 3. **DEFINE** business rules in domain
16
+ 4. **VALIDATE** invariants in domain
17
+ 5. **NEVER** import Firebase SDK in domain layer
18
+
19
+ ### Required Practices
20
+
21
+ 1. **Keep domain Firebase-free** - No Firebase imports in domain
22
+ 2. **Use value objects** - For business concepts with behavior
23
+ 3. **Validate invariants** - In constructors/factory methods
24
+ 4. **Define business rules** - In domain services
25
+ 5. **Use Result types** - For error handling
26
+
27
+ ### Forbidden Practices
28
+
29
+ ## ❌ NEVER
30
+
31
+ - Import Firebase SDK in domain layer
32
+ - Create anemic domain models (data without behavior)
33
+ - Put business logic in infrastructure
34
+ - Skip domain validation
35
+ - Leaky domain boundaries
36
+
37
+ ## ⚠️ Avoid
38
+
39
+ - Primitive obsession (use value objects)
40
+ - Business logic in UI/components
41
+ - Missing domain validation
42
+ - Weak domain boundaries
43
+ - Unclear business rules
44
+
45
+ ## Common Types
46
+
47
+ ### User Types
48
+
49
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
50
+
51
+ **Types:**
52
+ - `BaseUser` - Base user interface with common properties
53
+ - `AuthUser` - Firebase Auth user (extends BaseUser)
54
+ - `DatabaseUser` - Firestore database user (extends BaseUser)
55
+
56
+ **Properties:**
57
+ - `uid: string` - Unique user identifier
58
+ - `email?: string | null` - User email
59
+ - `displayName?: string | null` - Display name
60
+ - `photoURL?: string | null` - Profile photo URL
61
+
62
+ **Usage Strategy:**
63
+ 1. Use BaseUser for shared properties
64
+ 2. Use AuthUser for authentication-specific data
65
+ 3. Use DatabaseUser for Firestore data
66
+ 4. Type user parameters appropriately
67
+ 5. Distinguish between auth and database users
68
+
69
+ **When to Use:**
70
+ - User type annotations
71
+ - Function parameters
72
+ - Type checking
73
+ - User data validation
74
+ - Type-safe operations
75
+
76
+ ### Timestamp Types
77
+
78
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
79
+
80
+ **Types:**
81
+ - `ISOString` - ISO string timestamp type
82
+ - `Timestampable` - Entities with timestamps
83
+ - `Trackable` - Entities with user tracking
84
+ - `SoftDeletable` - Entities with soft delete
85
+
86
+ **Properties:**
87
+ - `createdAt: ISOString` - Creation timestamp
88
+ - `updatedAt: ISOString` - Update timestamp
89
+ - `createdBy: string` - Creator user ID
90
+ - `updatedBy: string` - Updater user ID
91
+ - `deletedAt?: ISOString` - Deletion timestamp
92
+ - `isDeleted: boolean` - Deletion status
93
+
94
+ **Usage Strategy:**
95
+ 1. Use Timestampable for audit trails
96
+ 2. Use Trackable for user tracking
97
+ 3. Use SoftDeletable for soft deletes
98
+ 4. Extend interfaces as needed
99
+ 5. Store timestamps as ISO strings
100
+
101
+ **When to Use:**
102
+ - Entity definitions
103
+ - Audit trails
104
+ - User tracking
105
+ - Soft delete implementation
106
+ - Data lifecycle management
107
+
108
+ ### Entity Types
109
+
110
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
111
+
112
+ **Types:**
113
+ - `Identifiable` - Entities with ID
114
+ - `Named` - Entities with name
115
+ - `Described` - Entities with description
116
+ - `BaseEntity` - Complete base entity
117
+
118
+ **Properties:**
119
+ - `id: string` - Entity identifier
120
+ - `name: string` - Entity name
121
+ - `description: string` - Entity description
122
+ - `createdAt: string` - Creation timestamp
123
+ - `updatedAt: string` - Update timestamp
124
+
125
+ **Usage Strategy:**
126
+ 1. Extend Identifiable for all entities
127
+ 2. Add Named/Described as needed
128
+ 3. Use BaseEntity for common entity pattern
129
+ 4. Combine interfaces for specific needs
130
+ 5. Ensure all entities have ID
131
+
132
+ **When to Use:**
133
+ - Entity definitions
134
+ - Type safety
135
+ - Common entity properties
136
+ - Domain modeling
137
+ - Data structure validation
138
+
139
+ ## Value Objects
140
+
141
+ ### Email
142
+
143
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
144
+
145
+ **Purpose:** Immutable value object for email validation
146
+
147
+ **Methods:**
148
+ - `static create(email)` - Factory method (returns null if invalid)
149
+ - `getValue()` - Get email string
150
+ - `getDomain()` - Get email domain
151
+ - `equals(other)` - Compare emails
152
+
153
+ **Usage Strategy:**
154
+ 1. Use Email.create() to create instances
155
+ 2. Validate email on creation
156
+ 3. Auto-normalizes to lowercase
157
+ 4. Use getValue() for string access
158
+ 5. Compare with equals() method
159
+
160
+ **When to Use:**
161
+ - Email input validation
162
+ - User registration
163
+ - Email comparison
164
+ - Email domain extraction
165
+ - Type-safe email operations
166
+
167
+ ### UserId
168
+
169
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
170
+
171
+ **Purpose:** Value object for user identification
172
+
173
+ **Methods:**
174
+ - `static create(value)` - Create from string
175
+ - `static generate()` - Generate new UUID
176
+ - `getValue()` - Get user ID string
177
+ - `equals(other)` - Compare user IDs
178
+ - `toString()` - Convert to string
179
+
180
+ **Usage Strategy:**
181
+ 1. Use UserId.create() for existing IDs
182
+ 2. Use UserId.generate() for new IDs
183
+ 3. Validate ID format on creation
184
+ 4. Use equals() for comparison
185
+ 5. Type-safe user ID operations
186
+
187
+ **When to Use:**
188
+ - User identification
189
+ - Type-safe ID operations
190
+ - ID validation
191
+ - UUID generation
192
+ - User references
193
+
194
+ ### Money
195
+
196
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
197
+
198
+ **Purpose:** Value object for monetary amounts
199
+
200
+ **Methods:**
201
+ - `static create(amount, currency?)` - Create money value
202
+ - `getAmount()` - Get amount
203
+ - `getCurrency()` - Get currency code
204
+ - `add(other)` - Add money values
205
+ - `subtract(other)` - Subtract money values
206
+ - `format()` - Format for display
207
+
208
+ **Usage Strategy:**
209
+ 1. Use Money.create() for instances
210
+ 2. Specify currency (default: USD)
211
+ 3. Use add/subtract for operations
212
+ 4. Currency matching enforced
213
+ 5. Format for display
214
+
215
+ **When to Use:**
216
+ - Payment processing
217
+ - Price calculations
218
+ - Currency operations
219
+ - Financial display
220
+ - Type-safe money operations
221
+
222
+ ## Domain Errors
223
+
224
+ ### Result Type
225
+
226
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
227
+
228
+ **Purpose:** Type-safe error handling without exceptions
229
+
230
+ **Type:** `Result<T, E = Error>`
231
+
232
+ **Shape:**
233
+ - Success: `{ success: true; data: T }`
234
+ - Failure: `{ success: false; error: E }`
235
+
236
+ **Usage Strategy:**
237
+ 1. Return Result type from operations
238
+ 2. Check success property
239
+ 3. Access data or error accordingly
240
+ 4. Handle both success and failure
241
+ 5. Avoid throwing exceptions
242
+
243
+ **When to Use:**
244
+ - Domain operations
245
+ - Service layer
246
+ - Error handling
247
+ - Validation results
248
+ - Type-safe operations
249
+
250
+ ### ValidationError
251
+
252
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
253
+
254
+ **Purpose:** Error for validation failures
255
+
256
+ **Properties:**
257
+ - `message: string` - Error message
258
+ - `field: string` - Field that failed validation
259
+ - `code: string` - Error code
260
+
261
+ **Usage Strategy:**
262
+ 1. Throw when validation fails
263
+ 2. Include field name
264
+ 3. Provide error code
265
+ 4. Display field-specific errors
266
+ 5. Use for form validation
267
+
268
+ **When to Use:**
269
+ - Input validation
270
+ - Form validation
271
+ - Field-specific errors
272
+ - Validation failures
273
+ - User feedback
274
+
275
+ ### NotFoundError
276
+
277
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
278
+
279
+ **Purpose:** Error when resource not found
280
+
281
+ **Parameters:**
282
+ - `resource: string` - Resource type
283
+ - `id: string` - Resource identifier
284
+
285
+ **Usage Strategy:**
286
+ 1. Throw when resource not found
287
+ 2. Include resource type and ID
288
+ 3. Use in repository operations
289
+ 4. Handle with user-friendly message
290
+ 5. Log for debugging
291
+
292
+ **When to Use:**
293
+ - Repository operations
294
+ - Resource lookups
295
+ - Data fetching
296
+ - Entity not found
297
+ - Missing data scenarios
298
+
299
+ ## Business Rules
300
+
301
+ ### Email Validation
302
+
303
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
304
+
305
+ **Functions:**
306
+ - `isValidEmail(email)` - Validate email format
307
+ - `normalizeEmail(email)` - Normalize email to lowercase
308
+
309
+ **Usage Strategy:**
310
+ 1. Validate before storage
311
+ 2. Normalize to lowercase
312
+ 3. Use on user input
313
+ 4. Validate on registration
314
+ 5. Check before sending emails
315
+
316
+ **When to Use:**
317
+ - User registration
318
+ - Email updates
319
+ - Email validation
320
+ - Input sanitization
321
+ - Data normalization
322
+
323
+ ### Password Validation
324
+
325
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
326
+
327
+ **Function:** `validatePassword(password, policy)`
328
+
329
+ **Policy Interface:**
330
+ - `minLength: number` - Minimum length
331
+ - `requireUppercase: boolean` - Require uppercase
332
+ - `requireLowercase: boolean` - Require lowercase
333
+ - `requireNumbers: boolean` - Require numbers
334
+ - `requireSpecialChars: boolean` - Require special characters
335
+
336
+ **Returns:** `{ valid: boolean; errors: string[] }`
337
+
338
+ **Usage Strategy:**
339
+ 1. Define password policy
340
+ 2. Validate password on creation
341
+ 3. Display validation errors
342
+ 4. Enforce policy consistently
343
+ 5. Show specific error messages
344
+
345
+ **When to Use:**
346
+ - User registration
347
+ - Password updates
348
+ - Password strength validation
349
+ - Security requirements
350
+ - User feedback
351
+
352
+ ### ID Validation
353
+
354
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
355
+
356
+ **Functions:**
357
+ - `isValidId(id)` - Validate ID format
358
+ - `requireValidId(id)` - Throw if invalid
359
+
360
+ **Supported Formats:**
361
+ - UUID format
362
+ - Firebase ID format
363
+
364
+ **Usage Strategy:**
365
+ 1. Validate IDs before operations
366
+ 2. Use requireValidId for critical operations
367
+ 3. Check format on user input
368
+ 4. Validate IDs from external sources
369
+ 5. Throw descriptive errors
370
+
371
+ **When to Use:**
372
+ - ID validation
373
+ - Parameter validation
374
+ - Security checks
375
+ - Data integrity
376
+ - Input sanitization
377
+
378
+ ## Utility Functions
379
+
380
+ ### Date Utilities
381
+
382
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
383
+
384
+ **Functions:**
385
+ - `getCurrentISO()` - Get current ISO timestamp
386
+ - `isRecent(isoString, days?)` - Check if date is recent
387
+ - `daysFromNow(isoString)` - Calculate days difference
388
+
389
+ **Usage Strategy:**
390
+ 1. Use getCurrentISO for timestamps
391
+ 2. Check isRecent for recent dates
392
+ 3. Calculate days difference
393
+ 4. Store dates as ISO strings
394
+ 5. Parse ISO strings for calculations
395
+
396
+ **When to Use:**
397
+ - Timestamp generation
398
+ - Date calculations
399
+ - Recent date checks
400
+ - Age calculations
401
+ - Date comparisons
402
+
403
+ ### String Utilities
404
+
405
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
406
+
407
+ **Functions:**
408
+ - `slugify(text)` - Convert text to slug
409
+ - `truncate(text, maxLength)` - Truncate text with ellipsis
410
+ - `generateRandomString(length?)` - Generate random string
411
+
412
+ **Usage Strategy:**
413
+ 1. Use slugify for URLs
414
+ 2. Use truncate for display
415
+ 3. Generate random strings for tokens
416
+ 4. Sanitize user input
417
+ 5. Format text appropriately
418
+
419
+ **When to Use:**
420
+ - URL generation
421
+ - Text display
422
+ - Token generation
423
+ - Input sanitization
424
+ - Text formatting
425
+
426
+ ### Collection Utilities
427
+
428
+ **Import From:** `@umituz/react-native-firebase/domain` or `src/domain`
429
+
430
+ **Functions:**
431
+ - `chunk(array, size)` - Split array into chunks
432
+ - `groupBy(array, keyFn)` - Group array by key
433
+ - `uniqueBy(array, keyFn)` - Get unique items
434
+
435
+ **Usage Strategy:**
436
+ 1. Use chunk for batch operations
437
+ 2. Use groupBy for data organization
438
+ 3. Use uniqueBy for deduplication
439
+ 4. Process large arrays efficiently
440
+ 5. Organize data structures
441
+
442
+ **When to Use:**
443
+ - Batch operations
444
+ - Data organization
445
+ - Deduplication
446
+ - Data processing
447
+ - Array manipulation
448
+
449
+ ## Common Mistakes to Avoid
450
+
451
+ 1. ❌ Using primitive strings for business concepts
452
+ - ✅ Use value objects (Email, UserId, Money)
453
+
454
+ 2. ❌ Business logic in infrastructure
455
+ - ✅ Put business logic in domain
456
+
457
+ 3. ❌ Throwing exceptions without handling
458
+ - ✅ Use Result types for error handling
459
+
460
+ 4. ❌ Skipping validation
461
+ - ✅ Validate invariants in domain
462
+
463
+ 5. ❌ Anemic domain models
464
+ - ✅ Add behavior to entities and value objects
465
+
466
+ ## AI Agent Instructions
467
+
468
+ ### When Creating Value Object
469
+
470
+ 1. Identify business concept
471
+ 2. Create immutable class
472
+ 3. Add validation on creation
473
+ 4. Provide factory methods
474
+ 5. Add behavior methods
475
+ 6. Use for type safety
476
+
477
+ ### When Creating Domain Error
478
+
479
+ 1. Extend Error class
480
+ 2. Add relevant properties
481
+ 3. Provide clear messages
482
+ 4. Include error codes
483
+ 5. Use for specific scenarios
484
+
485
+ ### When Implementing Business Rule
486
+
487
+ 1. Define rule clearly
488
+ 2. Implement in domain
489
+ 3. Validate inputs
490
+ 4. Return meaningful results
491
+ 5. Document behavior
492
+
493
+ ### When Using Result Type
494
+
495
+ 1. Return Result from operations
496
+ 2. Check success flag
497
+ 3. Handle both cases
498
+ 4. Avoid exceptions
499
+ 5. Provide clear errors
500
+
501
+ ## Code Quality Standards
502
+
503
+ ### Domain Layer
504
+
505
+ - No Firebase imports
506
+ - Pure TypeScript
507
+ - Business logic only
508
+ - Type-safe operations
509
+ - Clear interfaces
510
+
511
+ ### Value Objects
512
+
513
+ - Immutable by design
514
+ - Validate on creation
515
+ - Encapsulate behavior
516
+ - Factory methods
517
+ - Equality checks
518
+
519
+ ### Error Handling
520
+
521
+ - Use Result types
522
+ - Type-safe errors
523
+ - Clear error messages
524
+ - Error codes
525
+ - Proper inheritance
526
+
527
+ ## Performance Considerations
528
+
529
+ ### Value Objects
530
+
531
+ - Lightweight creation
532
+ - Minimal memory overhead
533
+ - Efficient equality checks
534
+ - Immutable (no mutation costs)
535
+ - Reuse when possible
536
+
537
+ ### Validation
538
+
539
+ - Validate early
540
+ - Fail fast
541
+ - Clear error messages
542
+ - Efficient validation logic
543
+ - Cache validation when appropriate
544
+
545
+ ### Collections
546
+
547
+ - Efficient algorithms
548
+ - Lazy evaluation when possible
549
+ - Memory-conscious operations
550
+ - Batch processing
551
+ - Avoid unnecessary iterations
552
+
553
+ ## Related Documentation
554
+
555
+ - [Auth Domain README](../auth/domain/README.md)
556
+ - [Firestore Domain README](../firestore/domain/README.md)
557
+ - [Domain Errors README](../auth/domain/errors/README.md)
558
+
559
+ ## API Reference
560
+
561
+ ### Types
562
+
563
+ **Import Path:** `@umituz/react-native-firebase/domain` or `src/domain`
564
+
565
+ | Type | Description |
566
+ |------|-------------|
567
+ | `BaseUser` | Base user interface |
568
+ | `AuthUser` | Firebase Auth user |
569
+ | `DatabaseUser` | Firestore database user |
570
+ | `ISOString` | ISO string timestamp |
571
+ | `Timestampable` | Timestamps (createdAt, updatedAt) |
572
+ | `Trackable` | User tracking (createdBy, updatedBy) |
573
+ | `SoftDeletable` | Soft delete support |
574
+ | `Identifiable` | Entity with ID |
575
+ | `BaseEntity` | Complete base entity |
576
+ | `Result<T, E>` | Result type for error handling |
577
+
578
+ ### Value Objects
579
+
580
+ **Import Path:** `@umituz/react-native-firebase/domain` or `src/domain`
581
+
582
+ | Class | Factory Methods | Description |
583
+ |-------|----------------|-------------|
584
+ | `Email` | `create(email)` | Email value object |
585
+ | `UserId` | `create(value), generate()` | User ID value object |
586
+ | `Money` | `create(amount, currency?)` | Money value object |
587
+
588
+ ### Domain Errors
589
+
590
+ **Import Path:** `@umituz/react-native-firebase/domain` or `src/domain`
591
+
592
+ | Error | Properties | Description |
593
+ |-------|------------|-------------|
594
+ | `ValidationError` | `message, field, code` | Validation failure |
595
+ | `NotFoundError` | `message` | Resource not found |
596
+
597
+ ### Validation Functions
598
+
599
+ **Import Path:** `@umituz/react-native-firebase/domain` or `src/domain`
600
+
601
+ | Function | Parameters | Returns | Description |
602
+ |----------|------------|---------|-------------|
603
+ | `isValidEmail` | `email` | `boolean` | Validate email format |
604
+ | `normalizeEmail` | `email` | `string` | Normalize email |
605
+ | `validatePassword` | `password, policy` | `{valid, errors}` | Validate password |
606
+ | `isValidId` | `id` | `boolean` | Validate ID format |
607
+ | `requireValidId` | `id` | `void` | Require valid ID |
608
+
609
+ ### Utility Functions
610
+
611
+ **Import Path:** `@umituz/react-native-firebase/domain` or `src/domain`
612
+
613
+ | Function | Parameters | Returns | Description |
614
+ |----------|------------|---------|-------------|
615
+ | `getCurrentISO` | - | `string` | Current timestamp |
616
+ | `isRecent` | `isoString, days?` | `boolean` | Check if recent |
617
+ | `daysFromNow` | `isoString` | `number` | Days difference |
618
+ | `slugify` | `text` | `string` | Convert to slug |
619
+ | `truncate` | `text, maxLength` | `string` | Truncate text |
620
+ | `generateRandomString` | `length?` | `string` | Random string |
621
+ | `chunk` | `array, size` | `T[][]` | Split array |
622
+ | `groupBy` | `array, keyFn` | `Record<string, T[]>` | Group by key |
623
+ | `uniqueBy` | `array, keyFn` | `T[]` | Unique items |
624
+
625
+ ---
626
+
627
+ **Last Updated:** 2025-01-08
628
+ **Maintainer:** Domain Layer Team