@umituz/react-native-ai-fal-provider 2.0.11 → 2.0.15
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 +2 -4
- package/src/domain/entities/error.types.ts +2 -0
- package/src/domain/types/provider.types.ts +1 -0
- package/src/exports/infrastructure.ts +0 -3
- package/src/exports/presentation.ts +0 -9
- package/src/index.ts +0 -3
- package/src/infrastructure/services/fal-feature-models.ts +3 -1
- package/src/infrastructure/services/fal-provider-subscription.ts +35 -13
- package/src/infrastructure/services/fal-provider.ts +6 -0
- package/src/infrastructure/services/fal-queue-operations.ts +30 -1
- package/src/infrastructure/services/fal-status-mapper.ts +2 -0
- package/src/infrastructure/services/request-store.ts +30 -2
- package/src/infrastructure/utils/cost-tracker.ts +34 -8
- package/src/infrastructure/utils/error-mapper.ts +17 -3
- package/src/infrastructure/utils/fal-storage.util.ts +3 -3
- package/src/infrastructure/utils/image-feature-builders.util.ts +10 -5
- package/src/infrastructure/utils/index.ts +7 -6
- package/src/infrastructure/utils/input-preprocessor.util.ts +1 -1
- package/src/infrastructure/utils/input-validator.util.ts +92 -0
- package/src/infrastructure/utils/type-guards.util.ts +7 -3
- package/src/infrastructure/utils/video-feature-builders.util.ts +6 -3
- package/src/infrastructure/validators/nsfw-validator.ts +62 -4
- package/src/presentation/hooks/index.ts +3 -21
- package/src/presentation/hooks/use-fal-generation.ts +5 -4
- package/src/domain/constants/default-models.constants.README.md +0 -378
- package/src/domain/constants/models/image-to-video.README.md +0 -266
- package/src/domain/constants/models/index.README.md +0 -269
- package/src/domain/constants/models/text-to-image.README.md +0 -237
- package/src/domain/constants/models/text-to-text.README.md +0 -249
- package/src/domain/constants/models/text-to-video.README.md +0 -259
- package/src/domain/constants/models/text-to-voice.README.md +0 -264
- package/src/domain/entities/error.types.README.md +0 -292
- package/src/domain/entities/fal.types.README.md +0 -460
- package/src/domain/types/index.README.md +0 -229
- package/src/domain/types/model-selection.types.README.md +0 -311
- package/src/exports/registry.ts +0 -39
- package/src/index.README.md +0 -420
- package/src/infrastructure/builders/image-feature-builder.README.md +0 -435
- package/src/infrastructure/builders/index.ts +0 -7
- package/src/infrastructure/services/fal-models-service.README.md +0 -293
- package/src/infrastructure/services/fal-provider-subscription.README.md +0 -257
- package/src/infrastructure/services/fal-provider.README.md +0 -474
- package/src/infrastructure/services/fal-status-mapper.README.md +0 -246
- package/src/infrastructure/services/nsfw-content-error.README.md +0 -215
- package/src/infrastructure/utils/base-builders.util.README.md +0 -313
- package/src/infrastructure/utils/cost-tracker-queries.ts +0 -67
- package/src/infrastructure/utils/error-categorizer.README.md +0 -395
- package/src/infrastructure/utils/error-mapper.README.md +0 -367
- package/src/infrastructure/utils/helpers.util.README.md +0 -395
- package/src/infrastructure/utils/image-feature-builders.util.README.md +0 -411
- package/src/infrastructure/utils/index.README.md +0 -338
- package/src/infrastructure/utils/job-metadata/index.README.md +0 -267
- package/src/infrastructure/utils/job-metadata/job-metadata-format.util.README.md +0 -209
- package/src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.README.md +0 -311
- package/src/infrastructure/utils/job-metadata/job-metadata-queries.util.README.md +0 -332
- package/src/infrastructure/utils/job-metadata/job-metadata.types.README.md +0 -446
- package/src/infrastructure/utils/job-metadata.README.md +0 -268
- package/src/infrastructure/utils/timing-helpers.util.ts +0 -56
- package/src/infrastructure/utils/type-guards.util.README.md +0 -371
- package/src/infrastructure/validators/index.README.md +0 -205
- package/src/infrastructure/validators/nsfw-validator.README.md +0 -309
- package/src/presentation/hooks/index.README.md +0 -224
- package/src/presentation/hooks/use-fal-generation.README.md +0 -398
- package/src/presentation/hooks/use-model-capabilities.ts +0 -99
- package/src/presentation/hooks/use-models.README.md +0 -318
- package/src/registry/global-capabilities.ts +0 -75
- package/src/registry/index.ts +0 -50
- package/src/registry/model-registry.service.ts +0 -93
- package/src/registry/model-registry.types.ts +0 -106
- package/src/registry/models/index.ts +0 -6
- package/src/registry/models/sora-2.config.ts +0 -95
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
# Error Types
|
|
2
|
-
|
|
3
|
-
Type definitions for FAL AI error management, categorization, and user-friendly messaging.
|
|
4
|
-
|
|
5
|
-
**Location:** `src/domain/entities/error.types.ts`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
This module contains TypeScript type definitions used throughout the FAL AI provider for error handling, categorization, and user messaging. It provides consistent error structures across the application.
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
Standardizes error handling by:
|
|
14
|
-
- Defining error type enumeration
|
|
15
|
-
- Providing error information structures
|
|
16
|
-
- Supporting retry logic with type safety
|
|
17
|
-
- Enabling consistent error categorization
|
|
18
|
-
- Facilitating user-friendly error messages
|
|
19
|
-
|
|
20
|
-
## Types
|
|
21
|
-
|
|
22
|
-
### FalErrorType
|
|
23
|
-
|
|
24
|
-
Enumeration of all error types in the FAL AI system.
|
|
25
|
-
|
|
26
|
-
**Values:**
|
|
27
|
-
- `network`: Network connectivity errors
|
|
28
|
-
- `timeout`: Request timeout errors
|
|
29
|
-
- `authentication`: Authentication and authorization failures
|
|
30
|
-
- `quota_exceeded`: Credit quota limit reached
|
|
31
|
-
- `rate_limit`: API rate limit exceeded
|
|
32
|
-
- `invalid_input`: Input validation failures
|
|
33
|
-
- `model_unavailable`: Model temporarily unavailable
|
|
34
|
-
- `nsfw_content`: NSFW content detected
|
|
35
|
-
- `validation`: General validation errors
|
|
36
|
-
- `content_policy`: Content policy violations
|
|
37
|
-
- `unknown`: Uncategorized errors
|
|
38
|
-
|
|
39
|
-
**Usage:**
|
|
40
|
-
Use to check error type and implement type-specific handling. Import from package root when working with error types.
|
|
41
|
-
|
|
42
|
-
**Implementation:** See complete enum definition in `src/domain/entities/error.types.ts`
|
|
43
|
-
|
|
44
|
-
### FalErrorCategory
|
|
45
|
-
|
|
46
|
-
Basic error category information.
|
|
47
|
-
|
|
48
|
-
**Structure:**
|
|
49
|
-
- `type`: Error type from `FalErrorType` enum
|
|
50
|
-
- `messageKey`: i18n translation key for user messages
|
|
51
|
-
- `retryable`: Boolean indicating if error can be retried
|
|
52
|
-
|
|
53
|
-
**Usage:**
|
|
54
|
-
Returned by error categorization functions. Use for quick error type checking and retry decisions.
|
|
55
|
-
|
|
56
|
-
**Related:**
|
|
57
|
-
- Error categorizer: `src/infrastructure/utils/error-categorizer.ts`
|
|
58
|
-
|
|
59
|
-
### FalErrorInfo
|
|
60
|
-
|
|
61
|
-
Comprehensive error information object.
|
|
62
|
-
|
|
63
|
-
**Structure:**
|
|
64
|
-
- `type`: Error type from `FalErrorType` enum
|
|
65
|
-
- `messageKey`: i18n translation key for user messages
|
|
66
|
-
- `retryable`: Boolean indicating if error can be retried
|
|
67
|
-
- `originalError`: Original error message or object
|
|
68
|
-
- `statusCode`: HTTP status code if available
|
|
69
|
-
|
|
70
|
-
**Usage:**
|
|
71
|
-
Primary error information structure used throughout the application. Contains all necessary information for error handling, user display, and logging.
|
|
72
|
-
|
|
73
|
-
**Related:**
|
|
74
|
-
- Error mapper: `src/infrastructure/utils/error-mapper.ts`
|
|
75
|
-
|
|
76
|
-
### FalErrorMessages
|
|
77
|
-
|
|
78
|
-
Optional interface for custom error messages.
|
|
79
|
-
|
|
80
|
-
**Structure:**
|
|
81
|
-
Optional string properties for each error type
|
|
82
|
-
|
|
83
|
-
**Usage:**
|
|
84
|
-
Use for providing custom error messages. Not typically used directly - prefer message keys with i18n system.
|
|
85
|
-
|
|
86
|
-
## Type Usage
|
|
87
|
-
|
|
88
|
-
### For Error Type Checking
|
|
89
|
-
|
|
90
|
-
**Pattern:**
|
|
91
|
-
1. Import `FalErrorType` from package
|
|
92
|
-
2. Compare error info `type` property
|
|
93
|
-
3. Implement type-specific handling
|
|
94
|
-
4. Use switch or if statements
|
|
95
|
-
|
|
96
|
-
**Type Comparison:**
|
|
97
|
-
Use strict equality (`===`) for type checking. This ensures type safety and prevents errors from misspelled type strings.
|
|
98
|
-
|
|
99
|
-
### For Error Information Access
|
|
100
|
-
|
|
101
|
-
**Access Pattern:**
|
|
102
|
-
1. Get `FalErrorInfo` from error mapper
|
|
103
|
-
2. Access `type` for category
|
|
104
|
-
3. Access `messageKey` for user display
|
|
105
|
-
4. Check `retryable` for retry decisions
|
|
106
|
-
5. Log `originalError` for debugging
|
|
107
|
-
6. Use `statusCode` if available
|
|
108
|
-
|
|
109
|
-
**Property Reference:**
|
|
110
|
-
See property descriptions above for complete usage information.
|
|
111
|
-
|
|
112
|
-
### For Retry Logic
|
|
113
|
-
|
|
114
|
-
**Retry Checking:**
|
|
115
|
-
Use `retryable` property from error info or category:
|
|
116
|
-
- Check before attempting retry
|
|
117
|
-
- Implement appropriate backoff
|
|
118
|
-
- Respect non-retryable errors
|
|
119
|
-
- Set retry limits appropriately
|
|
120
|
-
|
|
121
|
-
**Related:**
|
|
122
|
-
- Error mapper: `src/infrastructure/utils/error-mapper.ts`
|
|
123
|
-
- Error categorizer: `src/infrastructure/utils/error-categorizer.ts`
|
|
124
|
-
|
|
125
|
-
### For User Messaging
|
|
126
|
-
|
|
127
|
-
**Message Keys:**
|
|
128
|
-
Use `messageKey` property for translations:
|
|
129
|
-
- Format: `fal.errors.{type}`
|
|
130
|
-
- Use with i18n translation system
|
|
131
|
-
- Provide consistent user-facing messages
|
|
132
|
-
- Support multiple languages
|
|
133
|
-
|
|
134
|
-
**Implementation:** See error mapper documentation for complete key list
|
|
135
|
-
|
|
136
|
-
## Type Definitions Reference
|
|
137
|
-
|
|
138
|
-
**Import:**
|
|
139
|
-
```typescript
|
|
140
|
-
import type {
|
|
141
|
-
FalErrorType,
|
|
142
|
-
FalErrorCategory,
|
|
143
|
-
FalErrorInfo
|
|
144
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
**Related Files:**
|
|
148
|
-
- Error categorizer: `src/infrastructure/utils/error-categorizer.ts`
|
|
149
|
-
- Error mapper: `src/infrastructure/utils/error-mapper.ts`
|
|
150
|
-
- Type guards: `src/infrastructure/utils/type-guards.util.ts`
|
|
151
|
-
|
|
152
|
-
## Best Practices
|
|
153
|
-
|
|
154
|
-
### 1. Use Type Imports
|
|
155
|
-
|
|
156
|
-
Import types correctly:
|
|
157
|
-
- Use `import type` for type-only imports
|
|
158
|
-
- Import from package root
|
|
159
|
-
- Don't import from internal paths
|
|
160
|
-
- Maintain consistent import style
|
|
161
|
-
|
|
162
|
-
### 2. Check Types Strictly
|
|
163
|
-
|
|
164
|
-
Compare error types properly:
|
|
165
|
-
- Use strict equality (`===`)
|
|
166
|
-
- Don't use loose equality (`==`)
|
|
167
|
-
- Check against enum values
|
|
168
|
-
- Handle all type cases
|
|
169
|
-
|
|
170
|
-
### 3. Handle All Types
|
|
171
|
-
|
|
172
|
-
Prepare for every error type:
|
|
173
|
-
- Switch statements should cover all cases
|
|
174
|
-
- Provide default handling for unknown
|
|
175
|
-
- Don't ignore specific types
|
|
176
|
-
- Update handlers when adding types
|
|
177
|
-
|
|
178
|
-
### 4. Use Message Keys
|
|
179
|
-
|
|
180
|
-
Leverage message key system:
|
|
181
|
-
- Use `messageKey` for all user messages
|
|
182
|
-
- Don't hardcode error text
|
|
183
|
-
- Support i18n translations
|
|
184
|
-
- Keep messages consistent
|
|
185
|
-
|
|
186
|
-
### 5. Preserve Original Errors
|
|
187
|
-
|
|
188
|
-
Maintain error context:
|
|
189
|
-
- Log `originalError` for debugging
|
|
190
|
-
- Include in error reports
|
|
191
|
-
- Use for troubleshooting
|
|
192
|
-
- Don't modify or truncate
|
|
193
|
-
|
|
194
|
-
## For AI Agents
|
|
195
|
-
|
|
196
|
-
### When Using Error Types
|
|
197
|
-
|
|
198
|
-
**DO:**
|
|
199
|
-
- Import types from package root
|
|
200
|
-
- Use `FalErrorType` enum for type checking
|
|
201
|
-
- Check types with strict equality
|
|
202
|
-
- Handle all error type cases
|
|
203
|
-
- Use `messageKey` for display
|
|
204
|
-
- Check `retryable` before retrying
|
|
205
|
-
- Log `originalError` for debugging
|
|
206
|
-
|
|
207
|
-
**DON'T:**
|
|
208
|
-
- Import from internal paths
|
|
209
|
-
- Use string literals for types
|
|
210
|
-
- Use loose equality
|
|
211
|
-
- Skip error type handling
|
|
212
|
-
- Hardcode error messages
|
|
213
|
-
- Retry without checking retryable
|
|
214
|
-
- Discard original error info
|
|
215
|
-
|
|
216
|
-
### When Working with ErrorInfo
|
|
217
|
-
|
|
218
|
-
**DO:**
|
|
219
|
-
- Access all properties as needed
|
|
220
|
-
- Check `retryable` before retrying
|
|
221
|
-
- Use `messageKey` for translations
|
|
222
|
-
- Log `originalError` for debugging
|
|
223
|
-
- Use `statusCode` for specific handling
|
|
224
|
-
- Handle null/undefined properly
|
|
225
|
-
|
|
226
|
-
**DON'T:**
|
|
227
|
-
- Assume properties exist
|
|
228
|
-
- Skip null checks on optional fields
|
|
229
|
-
- Ignore retryable flag
|
|
230
|
-
- Hardcode message text
|
|
231
|
-
- Lose original error context
|
|
232
|
-
- Forget statusCode handling
|
|
233
|
-
|
|
234
|
-
### When Adding Error Types
|
|
235
|
-
|
|
236
|
-
**For New Error Types:**
|
|
237
|
-
1. Add value to `FalErrorType` enum
|
|
238
|
-
2. Update error categorizer patterns
|
|
239
|
-
3. Add message key to translations
|
|
240
|
-
4. Update error handling logic
|
|
241
|
-
5. Update this README
|
|
242
|
-
6. Test new error type
|
|
243
|
-
|
|
244
|
-
**For New Error Properties:**
|
|
245
|
-
1. Add to appropriate interface
|
|
246
|
-
2. Update error mapper
|
|
247
|
-
3. Update TypeScript types
|
|
248
|
-
4. Document new property
|
|
249
|
-
5. Test with all error types
|
|
250
|
-
|
|
251
|
-
**For Enhanced Type Safety:**
|
|
252
|
-
1. Review type definitions
|
|
253
|
-
2. Add stricter types where needed
|
|
254
|
-
3. Update type guards
|
|
255
|
-
4. Improve type coverage
|
|
256
|
-
5. Document type changes
|
|
257
|
-
|
|
258
|
-
## Implementation Notes
|
|
259
|
-
|
|
260
|
-
**Location:** `src/domain/entities/error.types.ts`
|
|
261
|
-
|
|
262
|
-
**Dependencies:**
|
|
263
|
-
- No external dependencies
|
|
264
|
-
- Pure TypeScript type definitions
|
|
265
|
-
- Used throughout error handling system
|
|
266
|
-
|
|
267
|
-
**Exports:**
|
|
268
|
-
- `FalErrorType` enum
|
|
269
|
-
- `FalErrorCategory` interface
|
|
270
|
-
- `FalErrorInfo` interface
|
|
271
|
-
- `FalErrorMessages` interface
|
|
272
|
-
|
|
273
|
-
**Import:**
|
|
274
|
-
```typescript
|
|
275
|
-
import type {
|
|
276
|
-
FalErrorType,
|
|
277
|
-
FalErrorCategory,
|
|
278
|
-
FalErrorInfo
|
|
279
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
**Related:**
|
|
283
|
-
- Error categorizer: `src/infrastructure/utils/error-categorizer.ts`
|
|
284
|
-
- Error mapper: `src/infrastructure/utils/error-mapper.ts`
|
|
285
|
-
- NSFW validator: `src/infrastructure/validators/nsfw-validator.ts`
|
|
286
|
-
|
|
287
|
-
## Related Documentation
|
|
288
|
-
|
|
289
|
-
- [Error Categorizer](../../infrastructure/utils/error-categorizer.README.md)
|
|
290
|
-
- [Error Mapper](../../infrastructure/utils/error-mapper.README.md)
|
|
291
|
-
- [Type Guards](../../infrastructure/utils/type-guards.util.README.md)
|
|
292
|
-
- [NSFW Validator](../../infrastructure/validators/nsfw-validator.README.md)
|