@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.
Files changed (71) hide show
  1. package/package.json +2 -4
  2. package/src/domain/entities/error.types.ts +2 -0
  3. package/src/domain/types/provider.types.ts +1 -0
  4. package/src/exports/infrastructure.ts +0 -3
  5. package/src/exports/presentation.ts +0 -9
  6. package/src/index.ts +0 -3
  7. package/src/infrastructure/services/fal-feature-models.ts +3 -1
  8. package/src/infrastructure/services/fal-provider-subscription.ts +35 -13
  9. package/src/infrastructure/services/fal-provider.ts +6 -0
  10. package/src/infrastructure/services/fal-queue-operations.ts +30 -1
  11. package/src/infrastructure/services/fal-status-mapper.ts +2 -0
  12. package/src/infrastructure/services/request-store.ts +30 -2
  13. package/src/infrastructure/utils/cost-tracker.ts +34 -8
  14. package/src/infrastructure/utils/error-mapper.ts +17 -3
  15. package/src/infrastructure/utils/fal-storage.util.ts +3 -3
  16. package/src/infrastructure/utils/image-feature-builders.util.ts +10 -5
  17. package/src/infrastructure/utils/index.ts +7 -6
  18. package/src/infrastructure/utils/input-preprocessor.util.ts +1 -1
  19. package/src/infrastructure/utils/input-validator.util.ts +92 -0
  20. package/src/infrastructure/utils/type-guards.util.ts +7 -3
  21. package/src/infrastructure/utils/video-feature-builders.util.ts +6 -3
  22. package/src/infrastructure/validators/nsfw-validator.ts +62 -4
  23. package/src/presentation/hooks/index.ts +3 -21
  24. package/src/presentation/hooks/use-fal-generation.ts +5 -4
  25. package/src/domain/constants/default-models.constants.README.md +0 -378
  26. package/src/domain/constants/models/image-to-video.README.md +0 -266
  27. package/src/domain/constants/models/index.README.md +0 -269
  28. package/src/domain/constants/models/text-to-image.README.md +0 -237
  29. package/src/domain/constants/models/text-to-text.README.md +0 -249
  30. package/src/domain/constants/models/text-to-video.README.md +0 -259
  31. package/src/domain/constants/models/text-to-voice.README.md +0 -264
  32. package/src/domain/entities/error.types.README.md +0 -292
  33. package/src/domain/entities/fal.types.README.md +0 -460
  34. package/src/domain/types/index.README.md +0 -229
  35. package/src/domain/types/model-selection.types.README.md +0 -311
  36. package/src/exports/registry.ts +0 -39
  37. package/src/index.README.md +0 -420
  38. package/src/infrastructure/builders/image-feature-builder.README.md +0 -435
  39. package/src/infrastructure/builders/index.ts +0 -7
  40. package/src/infrastructure/services/fal-models-service.README.md +0 -293
  41. package/src/infrastructure/services/fal-provider-subscription.README.md +0 -257
  42. package/src/infrastructure/services/fal-provider.README.md +0 -474
  43. package/src/infrastructure/services/fal-status-mapper.README.md +0 -246
  44. package/src/infrastructure/services/nsfw-content-error.README.md +0 -215
  45. package/src/infrastructure/utils/base-builders.util.README.md +0 -313
  46. package/src/infrastructure/utils/cost-tracker-queries.ts +0 -67
  47. package/src/infrastructure/utils/error-categorizer.README.md +0 -395
  48. package/src/infrastructure/utils/error-mapper.README.md +0 -367
  49. package/src/infrastructure/utils/helpers.util.README.md +0 -395
  50. package/src/infrastructure/utils/image-feature-builders.util.README.md +0 -411
  51. package/src/infrastructure/utils/index.README.md +0 -338
  52. package/src/infrastructure/utils/job-metadata/index.README.md +0 -267
  53. package/src/infrastructure/utils/job-metadata/job-metadata-format.util.README.md +0 -209
  54. package/src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.README.md +0 -311
  55. package/src/infrastructure/utils/job-metadata/job-metadata-queries.util.README.md +0 -332
  56. package/src/infrastructure/utils/job-metadata/job-metadata.types.README.md +0 -446
  57. package/src/infrastructure/utils/job-metadata.README.md +0 -268
  58. package/src/infrastructure/utils/timing-helpers.util.ts +0 -56
  59. package/src/infrastructure/utils/type-guards.util.README.md +0 -371
  60. package/src/infrastructure/validators/index.README.md +0 -205
  61. package/src/infrastructure/validators/nsfw-validator.README.md +0 -309
  62. package/src/presentation/hooks/index.README.md +0 -224
  63. package/src/presentation/hooks/use-fal-generation.README.md +0 -398
  64. package/src/presentation/hooks/use-model-capabilities.ts +0 -99
  65. package/src/presentation/hooks/use-models.README.md +0 -318
  66. package/src/registry/global-capabilities.ts +0 -75
  67. package/src/registry/index.ts +0 -50
  68. package/src/registry/model-registry.service.ts +0 -93
  69. package/src/registry/model-registry.types.ts +0 -106
  70. package/src/registry/models/index.ts +0 -6
  71. package/src/registry/models/sora-2.config.ts +0 -95
@@ -1,311 +0,0 @@
1
- # Model Selection Types
2
-
3
- TypeScript types for model selection functionality and the `useModels` hook.
4
-
5
- **Location:** `src/domain/types/model-selection.types.ts`
6
-
7
- ## Overview
8
-
9
- This module defines all TypeScript types and interfaces related to model selection in the FAL provider. These types are used by the `useModels` hook to manage model state, configuration, and actions.
10
-
11
- ## Purpose
12
-
13
- Provides type safety for model selection by:
14
- - Defining supported model types
15
- - Specifying selection configuration options
16
- - Typing selection state structure
17
- - Enabling type-safe model operations
18
- - Supporting model filtering and validation
19
-
20
- ## Import
21
-
22
- ```typescript
23
- import type {
24
- ModelType,
25
- ModelSelectionConfig,
26
- ModelSelectionState
27
- } from '@umituz/react-native-ai-fal-provider';
28
- ```
29
-
30
- ## Types
31
-
32
- ### ModelType
33
-
34
- Supported AI model generation types.
35
-
36
- **Valid Values:**
37
- - `text-to-image`: Generate images from text prompts
38
- - `text-to-video`: Generate videos from text prompts
39
- - `image-to-video`: Generate videos from images
40
- - `text-to-voice`: Generate speech from text (TTS)
41
-
42
- **Usage:**
43
- Use to specify model generation type. Enables type-safe model filtering. Used in `useModels` hook parameter. Supports model categorization.
44
-
45
- **Implementation:** See complete type definition in `src/domain/types/model-selection.types.ts`
46
-
47
- **Related:**
48
- - Model type guards: `src/infrastructure/utils/type-guards.util.ts`
49
- - useModels hook: `src/presentation/hooks/use-models.ts`
50
-
51
- ### ModelSelectionConfig
52
-
53
- Configuration options for model selection behavior.
54
-
55
- **Properties:**
56
- - `initialModelId`: Model ID to select on mount (optional)
57
- - `defaultCreditCost`: Fallback credit cost if model has no pricing (optional)
58
- - `defaultModelId`: Fallback model if no models are available (optional)
59
-
60
- **Usage:**
61
- Configure initial model selection state. Set default behaviors. Provide fallback options. Customize hook behavior.
62
-
63
- **Related:**
64
- - useModels hook: `src/presentation/hooks/use-models.ts`
65
-
66
- ### ModelSelectionState
67
-
68
- State object containing model selection data.
69
-
70
- **Properties:**
71
- - `models`: All available models for the selected type
72
- - `selectedModel`: Currently selected model configuration
73
- - `creditCost`: Credit cost based on selected model
74
- - `modelId`: Selected model's FAL ID for API calls
75
- - `isLoading`: Loading state indicator
76
- - `error`: Error message if fetch failed
77
-
78
- **Usage:**
79
- Access model selection state from hook. Display model information. Check loading and error states. Use model data for generation.
80
-
81
- **Related:**
82
- - useModels hook: `src/presentation/hooks/use-models.ts`
83
- - Model constants: `src/domain/constants/default-models.constants.ts`
84
-
85
- ## Usage Guidelines
86
-
87
- ### For Type Safety
88
-
89
- **Type Usage Pattern:**
90
- 1. Import `ModelType` from package
91
- 2. Use in function parameters
92
- 3. Enable type narrowing
93
- 4. Validate model types with guards
94
- 5. Switch on model type
95
-
96
- **Best Practices:**
97
- - Use type imports for type-only imports
98
- - Validate runtime values with type guards
99
- - Handle all model type cases
100
- - Use discriminated unions when appropriate
101
- - Leverage type inference
102
-
103
- **Related:**
104
- - Type guards: `src/infrastructure/utils/type-guards.util.ts`
105
-
106
- ### For Configuration
107
-
108
- **Configuration Pattern:**
109
- 1. Import `ModelSelectionConfig` type
110
- 2. Create config object with desired options
111
- 3. Pass to `useModels` hook
112
- 4. Configure initial state
113
- 5. Set fallback behaviors
114
-
115
- **Configuration Options:**
116
- - Set initial model selection
117
- - Provide default costs
118
- - Configure fallback models
119
- - Customize hook behavior
120
- - Handle edge cases
121
-
122
- ### For State Management
123
-
124
- **State Usage Pattern:**
125
- 1. Access state from `useModels` hook
126
- 2. Use `models` array for display
127
- 3. Check `selectedModel` for current selection
128
- 4. Monitor `isLoading` for UI feedback
129
- 5. Handle `error` state appropriately
130
-
131
- **State Properties:**
132
- - `models`: Available models list
133
- - `selectedModel`: Current selection
134
- - `creditCost`: Generation cost
135
- - `modelId`: Model identifier
136
- - `isLoading`: Loading indicator
137
- - `error`: Error information
138
-
139
- ## Best Practices
140
-
141
- ### 1. Use Type Imports
142
-
143
- Import types correctly:
144
- - Use `import type` for type-only imports
145
- - Import from package root
146
- - Maintain consistent imports
147
- - Avoid value imports for types
148
-
149
- ### 2. Validate Model Types
150
-
151
- Check model type validity:
152
- - Use type guards for runtime validation
153
- - Handle unknown model types
154
- - Provide fallback behavior
155
- - Log validation failures
156
- - Update guards when adding types
157
-
158
- **Related:**
159
- - Type guards: `src/infrastructure/utils/type-guards.util.ts`
160
-
161
- ### 3. Configure Properly
162
-
163
- Set appropriate configuration:
164
- - Provide initial model when known
165
- - Set sensible default costs
166
- - Configure fallback models
167
- - Handle undefined states
168
- - Test edge cases
169
-
170
- ### 4. Handle State Changes
171
-
172
- Respond to state updates:
173
- - Monitor `isLoading` changes
174
- - Handle `error` states
175
- - Update UI on model changes
176
- - Persist user selections
177
- - React to cost changes
178
-
179
- ### 5. Provide Type Safety
180
-
181
- Maintain type safety throughout:
182
- - Use strict TypeScript settings
183
- - Avoid type assertions
184
- - Leverage type inference
185
- - Handle all type cases
186
- - Keep types synchronized
187
-
188
- ## For AI Agents
189
-
190
- ### When Using Model Selection Types
191
-
192
- **DO:**
193
- - Import types from package root
194
- - Use type imports for types
195
- - Validate model types at runtime
196
- - Handle all model type cases
197
- - Use type guards
198
- - Leverage type inference
199
- - Maintain type safety
200
-
201
- **DON'T:**
202
- - Import from internal paths
203
- - Skip type validation
204
- - Assume type correctness
205
- - Use type assertions unnecessarily
206
- - Handle only some type cases
207
- - Ignore type errors
208
- - Create duplicate types
209
-
210
- ### When Configuring Selection
211
-
212
- **DO:**
213
- - Set initial model when available
214
- - Provide default costs
215
- - Configure fallback options
216
- - Handle undefined states
217
- - Test configuration
218
- - Document config choices
219
- - Update types when needed
220
-
221
- **DON'T:**
222
- - Skip configuration
223
- - Use arbitrary values
224
- - Forget fallback options
225
- - Ignore edge cases
226
- - Assume defaults work
227
- - Create inconsistent configs
228
- - Use outdated types
229
-
230
- ### When Managing State
231
-
232
- **DO:**
233
- - Access state from hook
234
- - Check all state properties
235
- - Handle loading states
236
- - Display error messages
237
- - Update UI on changes
238
- - Persist selections
239
- - Validate state data
240
-
241
- **DON'T:**
242
- - Ignore state properties
243
- - Skip loading handling
244
- - Hide error states
245
- - Assume valid data
246
- - Forget UI updates
247
- - Lose user selections
248
- - Skip validation
249
-
250
- ### When Adding Types
251
-
252
- **For New Model Types:**
253
- 1. Add value to `ModelType` type
254
- 2. Update type guards
255
- 3. Add support in hooks
256
- 4. Update constants
257
- 5. Test new type
258
- 6. Update this README
259
-
260
- **For Enhanced Config Options:**
261
- 1. Add property to config interface
262
- 2. Set optional with good reason
263
- 3. Update hook logic
264
- 4. Document behavior
265
- 5. Test configuration
266
- 6. Update TypeScript types
267
-
268
- **For State Properties:**
269
- 1. Add property to state interface
270
- 2. Initialize in hook
271
- 3. Update type definitions
272
- 4. Document usage
273
- 5. Test state changes
274
- 6. Update related code
275
-
276
- ## Implementation Notes
277
-
278
- **Location:** `src/domain/types/model-selection.types.ts`
279
-
280
- **Dependencies:**
281
- - No external dependencies
282
- - Pure TypeScript type definitions
283
- - Used throughout model selection system
284
-
285
- **Type Categories:**
286
- - Model type definitions
287
- - Configuration interfaces
288
- - State interfaces
289
- - Action types
290
-
291
- **Import:**
292
- ```typescript
293
- import type {
294
- ModelType,
295
- ModelSelectionConfig,
296
- ModelSelectionState
297
- } from '@umituz/react-native-ai-fal-provider';
298
- ```
299
-
300
- **Related:**
301
- - useModels hook: `src/presentation/hooks/use-models.ts`
302
- - Type guards: `src/infrastructure/utils/type-guards.util.ts`
303
- - Model constants: `src/domain/constants/default-models.constants.ts`
304
- - Model service: `src/infrastructure/services/fal-models-service.ts`
305
-
306
- ## Related Documentation
307
-
308
- - [useModels Hook](../../presentation/hooks/use-models.README.md)
309
- - [Type Guards](../../infrastructure/utils/type-guards.util.README.md)
310
- - [Default Models Constants](../constants/default-models.constants.README.md)
311
- - [Model Service](../../infrastructure/services/fal-models-service.README.md)
@@ -1,39 +0,0 @@
1
- /**
2
- * Model Registry Exports
3
- */
4
-
5
- export {
6
- VIDEO_ASPECT_RATIOS,
7
- IMAGE_ASPECT_RATIOS,
8
- GLOBAL_CAPABILITIES,
9
- GLOBAL_DEFAULTS,
10
- SORA_2_DURATIONS,
11
- SORA_2_RESOLUTIONS,
12
- SORA_2_CREDITS_BY_DURATION,
13
- SORA_2_TEXT_TO_VIDEO,
14
- SORA_2_IMAGE_TO_VIDEO,
15
- SORA_2_MODELS,
16
- MODEL_REGISTRY,
17
- getModelConfig,
18
- getModelsByType,
19
- getEnabledModels,
20
- getModelCapabilities,
21
- getModelCreditCost,
22
- getDefaultModelFromRegistry,
23
- } from "../registry";
24
-
25
- export type {
26
- ModelType as RegistryModelType,
27
- ModelProvider,
28
- DurationOption,
29
- ResolutionOption,
30
- AspectRatioOption,
31
- ModelCapabilities,
32
- ModelPricing,
33
- ModelDefaults,
34
- ModelConfig,
35
- ModelRegistry as ModelRegistryType,
36
- ResolvedCapabilities,
37
- GlobalCapabilities,
38
- GlobalDefaults,
39
- } from "../registry";