@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,171 @@
1
+ # Date Utilities
2
+
3
+ Utility functions for converting between ISO strings, JavaScript Dates, and Firestore Timestamps.
4
+
5
+ ## Purpose
6
+
7
+ Provides type-safe conversions for date/time handling between application code and Firestore storage. Ensures consistent date format handling across the application.
8
+
9
+ ## For AI Agents
10
+
11
+ ### Before Using Date Utilities
12
+
13
+ 1. **USE** these utilities instead of manual conversions
14
+ 2. **STORE** dates as ISO strings in Firestore
15
+ 3. **CONVERT** Timestamps when reading from Firestore
16
+ 4. **HANDLE** null/undefined cases appropriately
17
+
18
+ ### Required Practices
19
+
20
+ 1. **Always use utilities** for date conversions
21
+ 2. **Store as ISO strings** in Firestore documents
22
+ 3. **Convert on read** when retrieving from Firestore
23
+ 4. **Handle edge cases** (null, undefined, invalid dates)
24
+
25
+ ### Forbidden Practices
26
+
27
+ ## ❌ NEVER
28
+
29
+ - Manual date/timestamp conversion logic
30
+ - Store Date objects directly in Firestore
31
+ - Store Timestamp objects in documents
32
+ - Assume timestamps are always valid
33
+ - Mix date formats (some ISO, some Timestamp)
34
+
35
+ ## ⚠️ Avoid
36
+
37
+ - Time zone conversions (use UTC everywhere)
38
+ - Locale-specific date formatting
39
+ - Date arithmetic (use libraries like date-fns)
40
+ - Inconsistent date formats across collections
41
+
42
+ ## Usage Strategies
43
+
44
+ ### For Firestore Documents
45
+
46
+ **Strategy:** Store dates as ISO strings in Firestore, convert when reading.
47
+
48
+ **When to Use:**
49
+ - Creating documents with date fields
50
+ - Reading documents with Timestamp fields
51
+ - Comparing dates in queries
52
+
53
+ **Approach:**
54
+ 1. Use `getCurrentISOString()` for current time
55
+ 2. Use `isoToTimestamp()` when querying with dates
56
+ 3. Use `timestampToISO()` when reading from Firestore
57
+ 4. Use `timestampToDate()` for Date operations
58
+
59
+ ### For Query Filtering
60
+
61
+ **Strategy:** Use Timestamp conversions for date range queries.
62
+
63
+ **When to Use:**
64
+ - Filtering documents by date range
65
+ - Sorting by date fields
66
+ - Comparing dates in where clauses
67
+
68
+ ### For Display
69
+
70
+ **Strategy:** Convert to Date object for UI formatting.
71
+
72
+ **When to Use:**
73
+ - Displaying dates in UI components
74
+ - Formatting dates for users
75
+ - Date manipulation in business logic
76
+
77
+ ## Function Reference
78
+
79
+ ### `getCurrentISOString(): string`
80
+
81
+ Returns current date/time as ISO string.
82
+
83
+ **Use For:**
84
+ - Setting createdAt timestamps
85
+ - Setting updatedAt timestamps
86
+ - Current date/time storage
87
+
88
+ ### `isoToTimestamp(isoString: string): Timestamp`
89
+
90
+ Converts ISO string to Firestore Timestamp.
91
+
92
+ **Use For:**
93
+ - Query filters with dates
94
+ - Date comparisons in queries
95
+ - Timestamp-based operations
96
+
97
+ ### `timestampToISO(timestamp: Timestamp): string`
98
+
99
+ Converts Firestore Timestamp to ISO string.
100
+
101
+ **Use For:**
102
+ - Reading dates from Firestore
103
+ - Storing timestamps as ISO strings
104
+ - Consistent date format
105
+
106
+ ### `timestampToDate(timestamp: Timestamp): Date`
107
+
108
+ Converts Firestore Timestamp to JavaScript Date.
109
+
110
+ **Use For:**
111
+ - UI date formatting
112
+ - Date manipulation
113
+ - Date calculations
114
+
115
+ ## Common Mistakes to Avoid
116
+
117
+ 1. ❌ Storing Date objects directly in Firestore
118
+ - ✅ Use ISO strings via `getCurrentISOString()`
119
+
120
+ 2. ❌ Manual timestamp conversion
121
+ - ✅ Use `isoToTimestamp()` and `timestampToISO()`
122
+
123
+ 3. ❌ Inconsistent date formats
124
+ - ✅ Always use ISO strings for storage
125
+
126
+ 4. ❌ Not handling null timestamps
127
+ - ✅ Utilities handle null cases with defaults
128
+
129
+ ## AI Agent Instructions
130
+
131
+ ### When Adding Date Operations
132
+
133
+ 1. Check if utility already exists
134
+ 2. Add to this file if date-related
135
+ 3. Handle null/undefined cases
136
+ 4. Return consistent types
137
+ 5. Update this README
138
+
139
+ ### When Working with Dates
140
+
141
+ 1. Always use these utilities
142
+ 2. Don't create custom date logic
143
+ 3. Handle time zones consistently (UTC)
144
+ 4. Document date format expectations
145
+
146
+ ## Code Quality Standards
147
+
148
+ ### TypeScript
149
+
150
+ - All functions must have explicit types
151
+ - Handle null/undefined parameters
152
+ - Return consistent types
153
+ - Export for use across modules
154
+
155
+ ### Error Handling
156
+
157
+ - Provide default values for null inputs
158
+ - Never throw for invalid dates
159
+ - Handle timezone differences
160
+ - Log warnings for edge cases
161
+
162
+ ## Related Documentation
163
+
164
+ - [Firestore Module README](../README.md)
165
+ - [Query Builder README](../query-builder/README.md)
166
+ - [Repository README](../../infrastructure/repositories/README.md)
167
+
168
+ ---
169
+
170
+ **Last Updated:** 2025-01-08
171
+ **Maintainer:** Firestore Module Team
@@ -0,0 +1,309 @@
1
+ # Document Mapper
2
+
3
+ Utility for transforming Firestore documents to domain entities and vice versa.
4
+
5
+ ## Purpose
6
+
7
+ Provides bidirectional mapping between Firestore document structures and application domain entities, enabling clean separation between database schema and application models.
8
+
9
+ ## For AI Agents
10
+
11
+ ### Before Using Document Mapper
12
+
13
+ 1. **DEFINE** both document and entity interfaces
14
+ 2. **USE** short field names in Firestore documents (saves storage)
15
+ 3. **USE** descriptive names in entities (better code readability)
16
+ 4. **CREATE** one mapper per entity type
17
+ 5. **USE** mapper for all conversions (never manual mapping)
18
+
19
+ ### Required Practices
20
+
21
+ 1. **Always use mappers** for document-entity conversions
22
+ 2. **Keep Firestore schema minimal** (short field names)
23
+ 3. **Use descriptive names** in entity interfaces
24
+ 4. **Create one mapper per entity** (not generic mappers)
25
+ 5. **Use type-safe mapping** (never use `any`)
26
+
27
+ ### Forbidden Practices
28
+
29
+ ## ❌ NEVER
30
+
31
+ - Use Firestore documents directly in application code
32
+ - Use entity objects directly in Firestore operations
33
+ - Create generic mappers (loses type safety)
34
+ - Mix document and entity types
35
+ - Manual field-by-field mapping
36
+ - Use `any` type for mappers
37
+
38
+ ## ⚠️ Avoid
39
+
40
+ - Complex transformation logic in mappers (keep simple)
41
+ - Nested field mappings (flatten structure)
42
+ - Business logic in mappers (only mapping)
43
+ - Inconsistent naming conventions
44
+
45
+ ## Usage Strategies
46
+
47
+ ### For User Entities
48
+
49
+ **Strategy:** Map between short Firestore fields and descriptive entity fields.
50
+
51
+ **Firestore Document Schema:**
52
+ - Use short field names to reduce storage
53
+ - Example: `nm` instead of `name`, `em` instead of `email`
54
+ - Store dates as ISO strings
55
+ - Use consistent naming
56
+
57
+ **Entity Schema:**
58
+ - Use descriptive field names
59
+ - Example: `name`, `email`, `createdAt`
60
+ - Use Date objects for dates
61
+ - Follow TypeScript conventions
62
+
63
+ **Mapper Configuration:**
64
+ - Import from: `src/firestore/utils/document-mapper.helper`
65
+ - Use: `createDocumentMapper<DocumentType, EntityType>()`
66
+ - Define field mappings in config object
67
+ - One mapper per entity type
68
+
69
+ ### For Product Entities
70
+
71
+ **Strategy:** Separate product document schema from application model.
72
+
73
+ **When to Use:**
74
+ - E-commerce applications
75
+ - Product catalogs
76
+ - Inventory management
77
+
78
+ **Document Fields (Firestore):**
79
+ - Short names: `n` (name), `d` (description), `p` (price)
80
+ - Categories: `cat`, `st` (stock), `imgs` (images)
81
+
82
+ **Entity Fields (Application):**
83
+ - Descriptive: `name`, `description`, `price`
84
+ - Full names: `category`, `stock`, `images`
85
+
86
+ **Benefits:**
87
+ - Reduced Firestore storage costs
88
+ - Better code readability
89
+ - Type-safe conversions
90
+ - Easy to modify schema
91
+
92
+ ### For Multiple Views
93
+
94
+ **Strategy:** Create different mappers for different use cases.
95
+
96
+ **Mapper Types:**
97
+ - **Full Mapper** - Complete entity with all fields
98
+ - **Summary Mapper** - Minimal fields for lists
99
+ - **Public Mapper** - Only public-safe fields
100
+ - **Admin Mapper** - All fields including sensitive data
101
+
102
+ **When to Use:**
103
+ - Different UI views need different data
104
+ - Public vs private data access
105
+ - Performance optimization (smaller payloads)
106
+ - Security (hide sensitive fields)
107
+
108
+ **Implementation:**
109
+ - Create separate mapper instances
110
+ - Name them descriptively (e.g., `userFullMapper`, `userSummaryMapper`)
111
+ - Use appropriate mapper for each context
112
+ - Document mapper purpose
113
+
114
+ ### For Custom Transformations
115
+
116
+ **Strategy:** Create custom mapper class for complex transformations.
117
+
118
+ **When to Use:**
119
+ - Need validation logic
120
+ - Need data formatting
121
+ - Need computed fields
122
+ - Need type conversions beyond simple renaming
123
+
124
+ **Custom Mapper Pattern:**
125
+ - Create class with `toEntity()` and `toDocument()` methods
126
+ - Implement transformation logic
127
+ - Handle null/undefined cases
128
+ - Add validation if needed
129
+ - Keep methods focused
130
+
131
+ ## Configuration Options
132
+
133
+ ### DocumentMapperConfig
134
+
135
+ **Import from:** `src/firestore/utils/document-mapper.helper`
136
+
137
+ **Required Fields:**
138
+ - `id` - ID field name in document (usually 'id')
139
+ - `fields` - Object mapping entity fields to document fields
140
+
141
+ **Field Mapping Format:**
142
+ - Key: Entity field name (descriptive)
143
+ - Value: Document field name (short)
144
+
145
+ **Example Strategy:**
146
+ - Entity field `email` → Document field `em`
147
+ - Entity field `createdAt` → Document field `cr_at`
148
+ - Entity field `phoneNumber` → Document field `ph`
149
+
150
+ ### Type Safety
151
+
152
+ **Generic Types:**
153
+ - `Document` - Firestore document interface
154
+ - `Entity` - Application entity interface
155
+ - Both required for type safety
156
+
157
+ **TypeScript Benefits:**
158
+ - Autocomplete for field names
159
+ - Compile-time type checking
160
+ - Refactoring support
161
+ - No runtime type errors
162
+
163
+ ## Field Naming Strategies
164
+
165
+ ### Firestore Document Names
166
+
167
+ **Strategy:** Use short, abbreviated names.
168
+
169
+ **Guidelines:**
170
+ - Max 5-10 characters per field
171
+ - Remove vowels from common words
172
+ - Use consistent abbreviations
173
+ - Document abbreviations in comments
174
+
175
+ **Common Abbreviations:**
176
+ - `nm` - name
177
+ - `em` - email
178
+ - `ph` - phone
179
+ - `addr` - address
180
+ - `cr_at` - created_at
181
+ - `up_at` - updated_at
182
+ - `img` - image
183
+
184
+ ### Entity Field Names
185
+
186
+ **Strategy:** Use descriptive, full names.
187
+
188
+ **Guidelines:**
189
+ - Use complete words
190
+ - Follow TypeScript conventions
191
+ - camelCase for multi-word names
192
+ - Clear and self-documenting
193
+
194
+ **Examples:**
195
+ - `firstName` (not `fn`)
196
+ - `emailAddress` (not `em`)
197
+ - `phoneNumber` (not `ph`)
198
+ - `profilePictureUrl` (not `img`)
199
+
200
+ ## Common Mistakes to Avoid
201
+
202
+ 1. ❌ Using Firestore documents directly in UI code
203
+ - ✅ Always map to entities first
204
+
205
+ 2. ❌ Not creating separate document interfaces
206
+ - ✅ Define both Document and Entity types
207
+
208
+ 3. ❌ Long field names in Firestore
209
+ - ✅ Use short abbreviations in documents
210
+
211
+ 4. ❌ Manual field mapping
212
+ - ✅ Always use DocumentMapper
213
+
214
+ 5. ❌ One mapper for all entities
215
+ - ✅ Create one mapper per entity type
216
+
217
+ 6. ❌ Complex transformation logic
218
+ - ✅ Keep mappers simple, use custom classes for complex logic
219
+
220
+ ## AI Agent Instructions
221
+
222
+ ### When Creating New Mapper
223
+
224
+ 1. Define Document interface (Firestore schema)
225
+ 2. Define Entity interface (application model)
226
+ 3. Use `createDocumentMapper<Document, Entity>()`
227
+ 4. Map entity fields to document fields
228
+ 5. Export mapper instance
229
+ 6. Document field abbreviations
230
+
231
+ ### When Modifying Schema
232
+
233
+ 1. Update Document or Entity interface
234
+ 2. Update mapper configuration
235
+ 3. No need to update mapping logic
236
+ 4. TypeScript will show compilation errors if incomplete
237
+ 5. Update this README if pattern changes
238
+
239
+ ### For Repository Integration
240
+
241
+ 1. Create mapper in repository file
242
+ 2. Use in repository methods
243
+ 3. Map documents to entities when reading
244
+ 4. Map entities to documents when writing
245
+ 5. Never expose document types outside repository
246
+
247
+ ## Code Quality Standards
248
+
249
+ ### TypeScript
250
+
251
+ - Always specify generic types `<Document, Entity>`
252
+ - Never use `any` type
253
+ - Export both Document and Entity interfaces
254
+ - Use strict type checking
255
+
256
+ ### File Organization
257
+
258
+ - One mapper per file (or per entity)
259
+ - Place near entity definition
260
+ - Export mapper instance
261
+ - Document field mappings
262
+
263
+ ### Testing
264
+
265
+ - Test both directions (toEntity, toDocument)
266
+ - Test edge cases (null, undefined)
267
+ - Test type safety
268
+ - Verify all fields mapped correctly
269
+
270
+ ## Performance Considerations
271
+
272
+ ### Mapping Overhead
273
+
274
+ - Minimal performance impact
275
+ - Type checking at compile time (not runtime)
276
+ - No runtime cost for generics
277
+ - Acceptable for all use cases
278
+
279
+ ### Storage Savings
280
+
281
+ **Example Calculation:**
282
+ - Field `email` vs `em`: 2 bytes saved per document
283
+ - 100,000 users: 200,000 bytes saved
284
+ - Cumulative savings across all fields significant
285
+
286
+ **Recommendation:** Always use short field names in Firestore
287
+
288
+ ## Related Documentation
289
+
290
+ - [Firestore Module README](../../README.md)
291
+ - [Repository README](../../infrastructure/repositories/README.md)
292
+ - [Type Definitions README](../../types/pagination/README.md)
293
+
294
+ ## API Reference
295
+
296
+ ### Main Export
297
+
298
+ **Function:** `createDocumentMapper<Document, Entity>(config)`
299
+
300
+ **Returns:** DocumentMapper instance with methods:
301
+ - `toEntity(document)` - Convert document to entity
302
+ - `toDocument(entity)` - Convert entity to document
303
+
304
+ **Import From:** `src/firestore/utils/document-mapper.helper`
305
+
306
+ ---
307
+
308
+ **Last Updated:** 2025-01-08
309
+ **Maintainer:** Firestore Module Team