@umituz/react-native-firebase 2.0.0 → 2.0.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 +1 -1
- package/src/domains/account-deletion/application/ports/reauthentication.types.ts +2 -0
- package/src/domains/auth/index.ts +0 -1
- package/src/domains/auth/domain/errors/README.md +0 -291
- package/src/domains/auth/infrastructure/config/README.md +0 -239
- package/src/domains/auth/infrastructure/services/README.md +0 -346
- package/src/domains/firestore/domain/README.md +0 -325
- package/src/domains/firestore/domain/constants/README.md +0 -332
- package/src/domains/firestore/domain/entities/README.md +0 -286
- package/src/domains/firestore/domain/errors/README.md +0 -389
- package/src/domains/firestore/infrastructure/config/README.md +0 -239
- package/src/domains/firestore/infrastructure/middleware/README.md +0 -316
- package/src/domains/firestore/infrastructure/repositories/README.md +0 -425
- package/src/domains/firestore/infrastructure/services/README.md +0 -332
- package/src/domains/firestore/types/pagination/README.md +0 -332
- package/src/domains/firestore/utils/README.md +0 -574
- package/src/domains/firestore/utils/dateUtils/README.md +0 -171
- package/src/domains/firestore/utils/document-mapper.helper/README.md +0 -309
- package/src/domains/firestore/utils/pagination.helper/README.md +0 -298
- package/src/domains/firestore/utils/query-builder/README.md +0 -291
- package/src/presentation/README.md +0 -556
- package/src/shared/domain/README.md +0 -628
- package/src/shared/infrastructure/README.md +0 -408
- package/src/shared/infrastructure/config/README.md +0 -262
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
# Firestore Errors
|
|
2
|
-
|
|
3
|
-
Firebase Firestore error types, error detection, and error handling utilities.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
Provides custom error classes for Firestore operations, quota error detection, error handling utilities, and retry logic for transient failures.
|
|
8
|
-
|
|
9
|
-
## For AI Agents
|
|
10
|
-
|
|
11
|
-
### Before Using Firestore Errors
|
|
12
|
-
|
|
13
|
-
1. **USE** custom error classes (not Firebase errors directly)
|
|
14
|
-
2. **CHECK** error types with instanceof
|
|
15
|
-
3. **HANDLE** quota errors appropriately
|
|
16
|
-
4. **RETRY** transient errors automatically
|
|
17
|
-
5. **LOG** errors for debugging
|
|
18
|
-
|
|
19
|
-
### Required Practices
|
|
20
|
-
|
|
21
|
-
1. **Use custom error classes** - Import from firestore module
|
|
22
|
-
2. **Check error types** - Use instanceof for type checking
|
|
23
|
-
3. **Handle quota errors** - Show user-friendly messages
|
|
24
|
-
4. **Use retry logic** - Retry transient errors
|
|
25
|
-
5. **Provide context** - Include error details in logs
|
|
26
|
-
|
|
27
|
-
### Forbidden Practices
|
|
28
|
-
|
|
29
|
-
## ❌ NEVER
|
|
30
|
-
|
|
31
|
-
- Throw primitive values (always Error instances)
|
|
32
|
-
- Ignore error types
|
|
33
|
-
- Assume all errors are retryable
|
|
34
|
-
- Show technical error messages to users
|
|
35
|
-
- Catch and suppress errors silently
|
|
36
|
-
|
|
37
|
-
## ⚠️ Avoid
|
|
38
|
-
|
|
39
|
-
- Not checking error types before handling
|
|
40
|
-
- Retrying non-retryable errors
|
|
41
|
-
- Generic error handling
|
|
42
|
-
- Not logging errors
|
|
43
|
-
- Missing error context
|
|
44
|
-
|
|
45
|
-
## Error Classes
|
|
46
|
-
|
|
47
|
-
### FirebaseFirestoreError
|
|
48
|
-
|
|
49
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
50
|
-
|
|
51
|
-
**Purpose:** Base error class for all Firestore errors
|
|
52
|
-
|
|
53
|
-
**Properties:**
|
|
54
|
-
- `code: string` - Error code for programmatic handling
|
|
55
|
-
- `message: string` - Human-readable error message
|
|
56
|
-
|
|
57
|
-
**Usage:**
|
|
58
|
-
- Base class for all Firestore errors
|
|
59
|
-
- Type checking with instanceof
|
|
60
|
-
- Error code for conditional logic
|
|
61
|
-
|
|
62
|
-
**When to Use:**
|
|
63
|
-
- Throwing custom Firestore errors
|
|
64
|
-
- Catching and handling Firestore errors
|
|
65
|
-
- Type-safe error handling
|
|
66
|
-
|
|
67
|
-
### FirebaseFirestoreInitializationError
|
|
68
|
-
|
|
69
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
70
|
-
|
|
71
|
-
**Purpose:** Error thrown when Firestore fails to initialize
|
|
72
|
-
|
|
73
|
-
**Extends:** FirebaseFirestoreError
|
|
74
|
-
|
|
75
|
-
**Usage:**
|
|
76
|
-
- Initialization failures
|
|
77
|
-
- Configuration errors
|
|
78
|
-
- Firebase setup issues
|
|
79
|
-
|
|
80
|
-
**When to Use:**
|
|
81
|
-
- Firestore not initialized
|
|
82
|
-
- Invalid Firebase config
|
|
83
|
-
- Initialization timeout
|
|
84
|
-
|
|
85
|
-
### FirebaseFirestoreQuotaError
|
|
86
|
-
|
|
87
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
88
|
-
|
|
89
|
-
**Purpose:** Error thrown when Firestore quota is exceeded
|
|
90
|
-
|
|
91
|
-
**Extends:** FirebaseFirestoreError
|
|
92
|
-
|
|
93
|
-
**Properties:**
|
|
94
|
-
- `quotaType: 'read' | 'write' | 'delete'` - Type of quota exceeded
|
|
95
|
-
- `usage: QuotaStatus` - Quota usage details
|
|
96
|
-
|
|
97
|
-
**Usage:**
|
|
98
|
-
- Quota exceeded scenarios
|
|
99
|
-
- Usage tracking
|
|
100
|
-
- Cost management
|
|
101
|
-
|
|
102
|
-
**When to Use:**
|
|
103
|
-
- Read quota exceeded (daily limit)
|
|
104
|
-
- Write quota exceeded (daily limit)
|
|
105
|
-
- Delete quota exceeded (monthly limit)
|
|
106
|
-
|
|
107
|
-
## Error Detection
|
|
108
|
-
|
|
109
|
-
### isQuotaError
|
|
110
|
-
|
|
111
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
112
|
-
|
|
113
|
-
**Purpose:** Check if an error is quota-related
|
|
114
|
-
|
|
115
|
-
**Returns:** `boolean`
|
|
116
|
-
|
|
117
|
-
**Usage Strategy:**
|
|
118
|
-
1. Catch Firestore errors
|
|
119
|
-
2. Call isQuotaError(error)
|
|
120
|
-
3. Handle quota errors specifically
|
|
121
|
-
4. Show user-friendly quota message
|
|
122
|
-
5. Log quota usage for monitoring
|
|
123
|
-
|
|
124
|
-
**When to Use:**
|
|
125
|
-
- Distinguishing quota errors from other errors
|
|
126
|
-
- Showing quota-specific UI
|
|
127
|
-
- Implementing quota-based throttling
|
|
128
|
-
|
|
129
|
-
### isRetryableError
|
|
130
|
-
|
|
131
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
132
|
-
|
|
133
|
-
**Purpose:** Check if an error is retryable (transient)
|
|
134
|
-
|
|
135
|
-
**Returns:** `boolean`
|
|
136
|
-
|
|
137
|
-
**Retryable Errors:**
|
|
138
|
-
- Network errors
|
|
139
|
-
- Timeout errors
|
|
140
|
-
- Service unavailable
|
|
141
|
-
- Deadline exceeded
|
|
142
|
-
- Aborted operations
|
|
143
|
-
|
|
144
|
-
**Non-Retryable Errors:**
|
|
145
|
-
- Permission denied
|
|
146
|
-
- Not found
|
|
147
|
-
- Invalid arguments
|
|
148
|
-
- Quota exceeded
|
|
149
|
-
- Failed precondition
|
|
150
|
-
|
|
151
|
-
**Usage Strategy:**
|
|
152
|
-
1. Catch error from operation
|
|
153
|
-
2. Check isRetryableError(error)
|
|
154
|
-
3. Retry with exponential backoff if true
|
|
155
|
-
4. Show error if false
|
|
156
|
-
5. Limit retry attempts
|
|
157
|
-
|
|
158
|
-
### getQuotaErrorMessage
|
|
159
|
-
|
|
160
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
161
|
-
|
|
162
|
-
**Purpose:** Get user-friendly quota error message
|
|
163
|
-
|
|
164
|
-
**Returns:** `string`
|
|
165
|
-
|
|
166
|
-
**Message Format:**
|
|
167
|
-
- Shows quota type (read/write/delete)
|
|
168
|
-
- Displays usage percentage
|
|
169
|
-
- Indicates limit reached
|
|
170
|
-
- Suggests next steps
|
|
171
|
-
|
|
172
|
-
**Usage Strategy:**
|
|
173
|
-
1. Check if error is quota error
|
|
174
|
-
2. Call getQuotaErrorMessage(error)
|
|
175
|
-
3. Display message to user
|
|
176
|
-
4. Provide upgrade options
|
|
177
|
-
5. Log technical details
|
|
178
|
-
|
|
179
|
-
## Error Handling Strategies
|
|
180
|
-
|
|
181
|
-
### For Quota Errors
|
|
182
|
-
|
|
183
|
-
**Strategy:** Detect and handle quota exceeded scenarios.
|
|
184
|
-
|
|
185
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
186
|
-
|
|
187
|
-
**When to Use:**
|
|
188
|
-
- Daily read quota exceeded
|
|
189
|
-
- Daily write quota exceeded
|
|
190
|
-
- Monthly delete quota exceeded
|
|
191
|
-
|
|
192
|
-
**Handling Strategy:**
|
|
193
|
-
1. Catch error from Firestore operation
|
|
194
|
-
2. Check isQuotaError(error)
|
|
195
|
-
3. Get user-friendly message
|
|
196
|
-
4. Display upgrade option
|
|
197
|
-
5. Log quota usage for monitoring
|
|
198
|
-
6. Implement throttling if needed
|
|
199
|
-
|
|
200
|
-
**User Experience:**
|
|
201
|
-
- Clear message about quota exceeded
|
|
202
|
-
- Show usage percentage
|
|
203
|
-
- Offer upgrade or wait option
|
|
204
|
-
- Provide quota reset time
|
|
205
|
-
|
|
206
|
-
### For Transient Errors
|
|
207
|
-
|
|
208
|
-
**Strategy:** Retry transient failures with exponential backoff.
|
|
209
|
-
|
|
210
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
211
|
-
|
|
212
|
-
**When to Use:**
|
|
213
|
-
- Network failures
|
|
214
|
-
- Service unavailable
|
|
215
|
-
- Timeout errors
|
|
216
|
-
- Temporary issues
|
|
217
|
-
|
|
218
|
-
**Retry Strategy:**
|
|
219
|
-
1. Check isRetryableError(error)
|
|
220
|
-
2. Wait with exponential backoff (1s, 2s, 4s)
|
|
221
|
-
3. Retry operation
|
|
222
|
-
4. Limit retries to 3 attempts
|
|
223
|
-
5. Give up after max retries
|
|
224
|
-
|
|
225
|
-
**Exponential Backoff:**
|
|
226
|
-
- First retry: 1000ms (1 second)
|
|
227
|
-
- Second retry: 2000ms (2 seconds)
|
|
228
|
-
- Third retry: 4000ms (4 seconds)
|
|
229
|
-
- Max total wait: ~7 seconds
|
|
230
|
-
|
|
231
|
-
### For Initialization Errors
|
|
232
|
-
|
|
233
|
-
**Strategy:** Handle Firestore initialization failures.
|
|
234
|
-
|
|
235
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
236
|
-
|
|
237
|
-
**When to Use:**
|
|
238
|
-
- Firebase config missing
|
|
239
|
-
- Invalid Firebase config
|
|
240
|
-
- Network issues during init
|
|
241
|
-
- Permission issues
|
|
242
|
-
|
|
243
|
-
**Handling Strategy:**
|
|
244
|
-
1. Catch initialization error
|
|
245
|
-
2. Check error type
|
|
246
|
-
3. Show setup error message
|
|
247
|
-
4. Provide setup instructions
|
|
248
|
-
5. Offer retry option
|
|
249
|
-
|
|
250
|
-
## Error Codes Reference
|
|
251
|
-
|
|
252
|
-
### Common Error Codes
|
|
253
|
-
|
|
254
|
-
**Import From:** Error.code property
|
|
255
|
-
|
|
256
|
-
| Error Code | Description | Retryable | User Action |
|
|
257
|
-
|------------|-------------|-----------|-------------|
|
|
258
|
-
| `INITIALIZATION_FAILED` | Failed to initialize Firestore | Yes | Check config, retry |
|
|
259
|
-
| `QUOTA_EXCEEDED` | Quota limit exceeded | No | Wait or upgrade plan |
|
|
260
|
-
| `NOT_FOUND` | Document not found | No | Check document ID |
|
|
261
|
-
| `PERMISSION_DENIED` | Insufficient permissions | No | Check security rules |
|
|
262
|
-
| `UNAVAILABLE` | Service unavailable | Yes | Retry after delay |
|
|
263
|
-
| `DEADLINE_EXCEEDED` | Request timeout | Yes | Retry after delay |
|
|
264
|
-
| `ALREADY_EXISTS` | Document already exists | No | Check before create |
|
|
265
|
-
| `INVALID_ARGUMENT` | Invalid argument | No | Fix argument value |
|
|
266
|
-
| `FAILED_PRECONDITION` | Failed precondition | No | Fix precondition |
|
|
267
|
-
| `ABORTED` | Operation aborted | Yes | Retry operation |
|
|
268
|
-
|
|
269
|
-
## Common Mistakes to Avoid
|
|
270
|
-
|
|
271
|
-
1. ❌ Not checking error types
|
|
272
|
-
- ✅ Use instanceof for type checking
|
|
273
|
-
|
|
274
|
-
2. ❌ Retrying non-retryable errors
|
|
275
|
-
- ✅ Check isRetryableError() first
|
|
276
|
-
|
|
277
|
-
3. ❌ Showing technical messages to users
|
|
278
|
-
- ✅ Use getQuotaErrorMessage() for user-friendly messages
|
|
279
|
-
|
|
280
|
-
4. ❌ Not logging errors
|
|
281
|
-
- ✅ Log all errors with context
|
|
282
|
-
|
|
283
|
-
5. ❌ Suppressing errors silently
|
|
284
|
-
- ✅ Always handle or rethrow errors
|
|
285
|
-
|
|
286
|
-
## AI Agent Instructions
|
|
287
|
-
|
|
288
|
-
### When Handling Firestore Errors
|
|
289
|
-
|
|
290
|
-
1. Wrap operations in try-catch
|
|
291
|
-
2. Check error type with instanceof
|
|
292
|
-
3. Handle quota errors separately
|
|
293
|
-
4. Check if retryable with isRetryableError()
|
|
294
|
-
5. Retry with backoff if appropriate
|
|
295
|
-
6. Log errors with context
|
|
296
|
-
7. Show user-friendly messages
|
|
297
|
-
|
|
298
|
-
### When Implementing Retry Logic
|
|
299
|
-
|
|
300
|
-
1. Check isRetryableError(error)
|
|
301
|
-
2. Use exponential backoff (2^n seconds)
|
|
302
|
-
3. Limit retries to 3 attempts
|
|
303
|
-
4. Log retry attempts
|
|
304
|
-
5. Give up after max retries
|
|
305
|
-
6. Show error to user
|
|
306
|
-
|
|
307
|
-
### When Handling Quota Errors
|
|
308
|
-
|
|
309
|
-
1. Check isQuotaError(error)
|
|
310
|
-
2. Get user-friendly message
|
|
311
|
-
3. Display quota usage
|
|
312
|
-
4. Show upgrade option
|
|
313
|
-
5. Log quota exceeded event
|
|
314
|
-
6. Implement throttling if needed
|
|
315
|
-
|
|
316
|
-
## Code Quality Standards
|
|
317
|
-
|
|
318
|
-
### Error Handling
|
|
319
|
-
|
|
320
|
-
- Always use custom error classes
|
|
321
|
-
- Check error types before handling
|
|
322
|
-
- Provide error context
|
|
323
|
-
- Log errors appropriately
|
|
324
|
-
- Show user-friendly messages
|
|
325
|
-
|
|
326
|
-
### Type Safety
|
|
327
|
-
|
|
328
|
-
- Use instanceof for type checking
|
|
329
|
-
- Never use `any` for errors
|
|
330
|
-
- Type all error parameters
|
|
331
|
-
- Use discriminated unions
|
|
332
|
-
- Export error classes
|
|
333
|
-
|
|
334
|
-
### Retry Logic
|
|
335
|
-
|
|
336
|
-
- Use exponential backoff
|
|
337
|
-
- Limit retry attempts
|
|
338
|
-
- Log retry attempts
|
|
339
|
-
- Give up after max retries
|
|
340
|
-
- Don't retry non-retryable errors
|
|
341
|
-
|
|
342
|
-
## Performance Considerations
|
|
343
|
-
|
|
344
|
-
### Retry Overhead
|
|
345
|
-
|
|
346
|
-
- Retries add latency (up to 7 seconds)
|
|
347
|
-
- Use retries only for transient errors
|
|
348
|
-
- Limit retry attempts
|
|
349
|
-
- Consider circuit breaker pattern
|
|
350
|
-
- Monitor retry success rate
|
|
351
|
-
|
|
352
|
-
### Error Logging
|
|
353
|
-
|
|
354
|
-
- Log errors asynchronously
|
|
355
|
-
- Don't block on logging
|
|
356
|
-
- Use error tracking service
|
|
357
|
-
- Include context in logs
|
|
358
|
-
- Sanitize sensitive data
|
|
359
|
-
|
|
360
|
-
## Related Documentation
|
|
361
|
-
|
|
362
|
-
- [Firestore Module README](../../README.md)
|
|
363
|
-
- [Quota Error Detector README](../../utils/quota-error-detector/README.md)
|
|
364
|
-
- [Firestore Constants README](../constants/README.md)
|
|
365
|
-
|
|
366
|
-
## API Reference
|
|
367
|
-
|
|
368
|
-
### Error Classes
|
|
369
|
-
|
|
370
|
-
**Import Path:** `@umituz/react-native-firebase/firestore` or `src/firestore/domain/errors`
|
|
371
|
-
|
|
372
|
-
| Class | Constructor Parameters | Description |
|
|
373
|
-
|-------|----------------------|-------------|
|
|
374
|
-
| `FirebaseFirestoreError` | `(message: string, code: string)` | Base Firestore error |
|
|
375
|
-
| `FirebaseFirestoreInitializationError` | `(message: string)` | Init error |
|
|
376
|
-
| `FirebaseFirestoreQuotaError` | `(quotaType, usage: QuotaStatus)` | Quota exceeded error |
|
|
377
|
-
|
|
378
|
-
### Detection Functions
|
|
379
|
-
|
|
380
|
-
| Function | Parameters | Returns | Description |
|
|
381
|
-
|----------|-----------|---------|-------------|
|
|
382
|
-
| `isQuotaError` | `(error: unknown)` | `boolean` | Check if quota error |
|
|
383
|
-
| `isRetryableError` | `(error: unknown)` | `boolean` | Check if retryable |
|
|
384
|
-
| `getQuotaErrorMessage` | `(error: FirebaseFirestoreQuotaError)` | `string` | Get user-friendly message |
|
|
385
|
-
|
|
386
|
-
---
|
|
387
|
-
|
|
388
|
-
**Last Updated:** 2025-01-08
|
|
389
|
-
**Maintainer:** Firestore Module Team
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
# Firestore Configuration
|
|
2
|
-
|
|
3
|
-
Firestore client initialization, configuration management, and service initialization.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
Provides core Firestore client functionality including initialization, state management, service access, and error handling.
|
|
8
|
-
|
|
9
|
-
## For AI Agents
|
|
10
|
-
|
|
11
|
-
### Before Using Firestore Config
|
|
12
|
-
|
|
13
|
-
1. **INITIALIZE** Firestore once at app startup
|
|
14
|
-
2. **CHECK** initialization status before use
|
|
15
|
-
3. **USE** getFirestore() to get Firestore instance
|
|
16
|
-
4. **HANDLE** initialization errors appropriately
|
|
17
|
-
5. **NEVER** initialize Firestore multiple times
|
|
18
|
-
|
|
19
|
-
### Required Practices
|
|
20
|
-
|
|
21
|
-
1. **Initialize once** - Call initializeFirestore() at app startup
|
|
22
|
-
2. **Check status** - Verify initialization before using Firestore
|
|
23
|
-
3. **Get Firestore instance** - Use getFirestore() after initialization
|
|
24
|
-
4. **Handle errors** - Check for initialization errors
|
|
25
|
-
5. **Use repositories** - Use repository pattern instead of direct Firestore
|
|
26
|
-
|
|
27
|
-
### Forbidden Practices
|
|
28
|
-
|
|
29
|
-
## ❌ NEVER
|
|
30
|
-
|
|
31
|
-
- Initialize Firestore multiple times
|
|
32
|
-
- Use Firestore SDK before initialization
|
|
33
|
-
- Use getFirestore() from firebase/firestore directly
|
|
34
|
-
- Ignore initialization errors
|
|
35
|
-
- Skip initialization status check
|
|
36
|
-
|
|
37
|
-
## ⚠️ Avoid
|
|
38
|
-
|
|
39
|
-
- Initializing Firestore in components
|
|
40
|
-
- Not checking initialization status
|
|
41
|
-
- Direct Firestore SDK usage (use repositories)
|
|
42
|
-
- Initializing without Firebase app
|
|
43
|
-
- Not handling initialization failures
|
|
44
|
-
|
|
45
|
-
## Initialization Strategy
|
|
46
|
-
|
|
47
|
-
### Basic Initialization
|
|
48
|
-
|
|
49
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/infrastructure/config`
|
|
50
|
-
|
|
51
|
-
**Function:** `initializeFirestore()`
|
|
52
|
-
|
|
53
|
-
**Returns:** `Promise<void>`
|
|
54
|
-
|
|
55
|
-
**When to Use:**
|
|
56
|
-
- App startup (after Firebase initialized)
|
|
57
|
-
- Before any Firestore operations
|
|
58
|
-
- Root component initialization
|
|
59
|
-
|
|
60
|
-
**Initialization Flow:**
|
|
61
|
-
1. Verify Firebase app initialized
|
|
62
|
-
2. Get Firebase app instance
|
|
63
|
-
3. Initialize Firestore with app
|
|
64
|
-
4. Set initialization state
|
|
65
|
-
5. Handle errors appropriately
|
|
66
|
-
|
|
67
|
-
### Check Initialization Status
|
|
68
|
-
|
|
69
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/infrastructure/config`
|
|
70
|
-
|
|
71
|
-
**Functions:**
|
|
72
|
-
- `isFirestoreInitialized()` - Check if Firestore initialized
|
|
73
|
-
- `isFirestoreInitializing()` - Check if initializing
|
|
74
|
-
- `getFirestoreInitializationError()` - Get error if failed
|
|
75
|
-
|
|
76
|
-
**Returns:**
|
|
77
|
-
- `boolean` for status checks
|
|
78
|
-
- `Error | null` for error check
|
|
79
|
-
|
|
80
|
-
**When to Use:**
|
|
81
|
-
- Before Firestore operations
|
|
82
|
-
- Before using repositories
|
|
83
|
-
- Error recovery
|
|
84
|
-
- Status display
|
|
85
|
-
|
|
86
|
-
**Usage Strategy:**
|
|
87
|
-
1. Check isFirestoreInitialized()
|
|
88
|
-
2. If false, show loading or initialize
|
|
89
|
-
3. If error, show error message
|
|
90
|
-
4. Proceed with Firestore operations
|
|
91
|
-
|
|
92
|
-
## Service Access
|
|
93
|
-
|
|
94
|
-
### Get Firestore Instance
|
|
95
|
-
|
|
96
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/infrastructure/config`
|
|
97
|
-
|
|
98
|
-
**Function:** `getFirestore()`
|
|
99
|
-
|
|
100
|
-
**Returns:** `Firestore` instance from Firebase Firestore SDK
|
|
101
|
-
|
|
102
|
-
**Usage Strategy:**
|
|
103
|
-
1. Check initialization status first
|
|
104
|
-
2. Call getFirestore()
|
|
105
|
-
3. Use Firestore instance for operations
|
|
106
|
-
4. Handle errors appropriately
|
|
107
|
-
|
|
108
|
-
**When to Use:**
|
|
109
|
-
- Repository implementations
|
|
110
|
-
- Custom Firestore operations
|
|
111
|
-
- Direct Firestore SDK usage (rare)
|
|
112
|
-
- Advanced Firestore features
|
|
113
|
-
|
|
114
|
-
**Important:** Prefer using repositories over direct Firestore SDK usage
|
|
115
|
-
|
|
116
|
-
### Reset Client
|
|
117
|
-
|
|
118
|
-
**Import From:** `@umituz/react-native-firebase/firestore` or `src/firestore/infrastructure/config`
|
|
119
|
-
|
|
120
|
-
**Function:** `resetFirestoreClient()`
|
|
121
|
-
|
|
122
|
-
**Purpose:** Reset Firestore client state (useful for testing)
|
|
123
|
-
|
|
124
|
-
**When to Use:**
|
|
125
|
-
- Testing scenarios
|
|
126
|
-
- Error recovery
|
|
127
|
-
- Reinitialization
|
|
128
|
-
- Development
|
|
129
|
-
|
|
130
|
-
**Usage Strategy:**
|
|
131
|
-
1. Call resetFirestoreClient()
|
|
132
|
-
2. Reinitialize if needed
|
|
133
|
-
3. Use only in development/testing
|
|
134
|
-
4. Never use in production
|
|
135
|
-
|
|
136
|
-
## Common Mistakes to Avoid
|
|
137
|
-
|
|
138
|
-
1. ❌ Initializing Firestore multiple times
|
|
139
|
-
- ✅ Initialize once at app startup
|
|
140
|
-
|
|
141
|
-
2. ❌ Not checking initialization status
|
|
142
|
-
- ✅ Always check isFirestoreInitialized()
|
|
143
|
-
|
|
144
|
-
3. ❌ Using getFirestore() from firebase/firestore
|
|
145
|
-
- ✅ Use getFirestore() from firestore config
|
|
146
|
-
|
|
147
|
-
4. ❌ Initializing before Firebase app
|
|
148
|
-
- ✅ Initialize Firebase first, then Firestore
|
|
149
|
-
|
|
150
|
-
5. ❌ Ignoring initialization errors
|
|
151
|
-
- ✅ Handle and display errors
|
|
152
|
-
|
|
153
|
-
## AI Agent Instructions
|
|
154
|
-
|
|
155
|
-
### When Initializing Firestore
|
|
156
|
-
|
|
157
|
-
1. Initialize Firebase first
|
|
158
|
-
2. Call initializeFirestore()
|
|
159
|
-
3. Await initialization completion
|
|
160
|
-
4. Check for errors
|
|
161
|
-
5. Show error message if failed
|
|
162
|
-
|
|
163
|
-
### When Using Repositories
|
|
164
|
-
|
|
165
|
-
1. Check Firestore initialization status
|
|
166
|
-
2. If not initialized, initialize first
|
|
167
|
-
3. Use repositories for all operations
|
|
168
|
-
4. Handle errors appropriately
|
|
169
|
-
5. Show user feedback
|
|
170
|
-
|
|
171
|
-
### When Getting Firestore Instance
|
|
172
|
-
|
|
173
|
-
1. Check isFirestoreInitialized()
|
|
174
|
-
2. Call getFirestore()
|
|
175
|
-
3. Use Firestore instance
|
|
176
|
-
4. Handle uninitialized state
|
|
177
|
-
5. Prefer repositories over direct usage
|
|
178
|
-
|
|
179
|
-
## Code Quality Standards
|
|
180
|
-
|
|
181
|
-
### Initialization
|
|
182
|
-
|
|
183
|
-
- Initialize once at startup
|
|
184
|
-
- Check status before use
|
|
185
|
-
- Handle errors gracefully
|
|
186
|
-
- Show loading states
|
|
187
|
-
- Provide error feedback
|
|
188
|
-
|
|
189
|
-
### Error Handling
|
|
190
|
-
|
|
191
|
-
- Catch initialization errors
|
|
192
|
-
- Store error in state
|
|
193
|
-
- Provide error context
|
|
194
|
-
- Allow retry/recovery
|
|
195
|
-
- Log for debugging
|
|
196
|
-
|
|
197
|
-
## Performance Considerations
|
|
198
|
-
|
|
199
|
-
### Initialization Overhead
|
|
200
|
-
|
|
201
|
-
- One-time cost at app startup
|
|
202
|
-
- Async initialization (non-blocking)
|
|
203
|
-
- ~50-200ms typical
|
|
204
|
-
- Initialize once, reuse Firestore instance
|
|
205
|
-
- Don't reinitialize unnecessarily
|
|
206
|
-
|
|
207
|
-
### State Checking
|
|
208
|
-
|
|
209
|
-
- Fast boolean checks
|
|
210
|
-
- No performance overhead
|
|
211
|
-
- Safe to call frequently
|
|
212
|
-
- Use before Firestore operations
|
|
213
|
-
- Prevents errors
|
|
214
|
-
|
|
215
|
-
## Related Documentation
|
|
216
|
-
|
|
217
|
-
- [Firestore Module README](../../README.md)
|
|
218
|
-
- [Firestore Repositories README](../repositories/README.md)
|
|
219
|
-
- [Firebase Infrastructure Config README](../../../infrastructure/config/README.md)
|
|
220
|
-
|
|
221
|
-
## API Reference
|
|
222
|
-
|
|
223
|
-
### Main Functions
|
|
224
|
-
|
|
225
|
-
**Import Path:** `@umituz/react-native-firebase/firestore` or `src/firestore/infrastructure/config`
|
|
226
|
-
|
|
227
|
-
| Function | Returns | Description |
|
|
228
|
-
|----------|---------|-------------|
|
|
229
|
-
| `initializeFirestore` | `Promise<void>` | Initialize Firestore |
|
|
230
|
-
| `getFirestore` | `Firestore` | Get Firestore instance |
|
|
231
|
-
| `isFirestoreInitialized` | `boolean` | Check if initialized |
|
|
232
|
-
| `isFirestoreInitializing` | `boolean` | Check if initializing |
|
|
233
|
-
| `getFirestoreInitializationError` | `Error \| null` | Get initialization error |
|
|
234
|
-
| `resetFirestoreClient` | `void` | Reset client state (testing) |
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
**Last Updated:** 2025-01-08
|
|
239
|
-
**Maintainer:** Firestore Module Team
|