@umituz/react-native-ai-fal-provider 2.0.14 → 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 +1 -1
- 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/image-feature-builders.util.ts +10 -5
- package/src/infrastructure/utils/index.ts +7 -6
- 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,460 +0,0 @@
|
|
|
1
|
-
# FAL Types
|
|
2
|
-
|
|
3
|
-
Core type definitions for FAL AI integration including configuration, models, jobs, and queue status.
|
|
4
|
-
|
|
5
|
-
**Location:** `src/domain/entities/fal.types.ts`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
This module contains TypeScript type definitions used throughout the FAL AI provider for configuration, model information, job management, queue status tracking, and subscription handling.
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
Provides type safety for FAL operations by:
|
|
14
|
-
- Defining configuration interfaces for provider initialization
|
|
15
|
-
- Specifying model information structures
|
|
16
|
-
- Typing job input and result data
|
|
17
|
-
- Tracking queue status throughout job lifecycle
|
|
18
|
-
- Supporting subscription callbacks with proper typing
|
|
19
|
-
- Ensuring type-safe operations across the provider
|
|
20
|
-
|
|
21
|
-
## Import
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import type {
|
|
25
|
-
FalConfig,
|
|
26
|
-
FalModel,
|
|
27
|
-
FalModelType,
|
|
28
|
-
FalModelPricing,
|
|
29
|
-
FalJobInput,
|
|
30
|
-
FalJobResult,
|
|
31
|
-
FalLogEntry,
|
|
32
|
-
FalQueueStatus,
|
|
33
|
-
FalSubscribeOptions
|
|
34
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Type Definitions
|
|
38
|
-
|
|
39
|
-
### FalConfig
|
|
40
|
-
|
|
41
|
-
FAL provider configuration interface.
|
|
42
|
-
|
|
43
|
-
**Properties:**
|
|
44
|
-
- `apiKey`: FAL API authentication key
|
|
45
|
-
- `baseUrl`: Optional custom base URL for API requests
|
|
46
|
-
- `maxRetries`: Maximum number of retry attempts (optional)
|
|
47
|
-
- `baseDelay`: Base delay for retry logic in milliseconds (optional)
|
|
48
|
-
- `maxDelay`: Maximum delay for retry logic in milliseconds (optional)
|
|
49
|
-
- `defaultTimeoutMs`: Default timeout for requests in milliseconds (optional)
|
|
50
|
-
|
|
51
|
-
**Usage:**
|
|
52
|
-
Use to configure the FAL provider instance. All properties except `apiKey` are optional with sensible defaults. Initialize provider with this configuration.
|
|
53
|
-
|
|
54
|
-
**Implementation:** See complete interface definition in `src/domain/entities/fal.types.ts`
|
|
55
|
-
|
|
56
|
-
**Related:**
|
|
57
|
-
- FAL provider: `src/infrastructure/services/fal-provider.ts`
|
|
58
|
-
|
|
59
|
-
### FalModel
|
|
60
|
-
|
|
61
|
-
Model information structure.
|
|
62
|
-
|
|
63
|
-
**Properties:**
|
|
64
|
-
- `id`: Unique model identifier (e.g., 'fal-ai/flux/schnell')
|
|
65
|
-
- `name`: Human-readable model name
|
|
66
|
-
- `description`: Optional model description
|
|
67
|
-
- `endpoint`: API endpoint for model invocation
|
|
68
|
-
- `type`: Model type from `FalModelType` enum
|
|
69
|
-
- `pricing`: Optional pricing information
|
|
70
|
-
- `enabled`: Whether model is active
|
|
71
|
-
- `order`: Optional ordering for UI display
|
|
72
|
-
|
|
73
|
-
**Usage:**
|
|
74
|
-
Use to represent available FAL models. Returned by model listing operations. Used for model selection in UI.
|
|
75
|
-
|
|
76
|
-
**Related:**
|
|
77
|
-
- Model types: `src/domain/types/model-selection.types.ts`
|
|
78
|
-
- useModels hook: `src/presentation/hooks/use-models.ts`
|
|
79
|
-
|
|
80
|
-
### FalModelType
|
|
81
|
-
|
|
82
|
-
Enumeration of supported model types.
|
|
83
|
-
|
|
84
|
-
**Valid Values:**
|
|
85
|
-
- `text-to-image`: Text prompt to image generation
|
|
86
|
-
- `text-to-video`: Text prompt to video generation
|
|
87
|
-
- `text-to-voice`: Text to speech synthesis
|
|
88
|
-
- `image-to-video`: Image to video conversion
|
|
89
|
-
- `image-to-image`: Image to image transformation
|
|
90
|
-
- `text-to-text`: Text processing and generation
|
|
91
|
-
|
|
92
|
-
**Usage:**
|
|
93
|
-
Use to categorize models by their input/output types. Enables filtering models by type. Use with type guards for type-safe operations.
|
|
94
|
-
|
|
95
|
-
**Related:**
|
|
96
|
-
- Model type guards: `src/infrastructure/utils/type-guards.util.ts`
|
|
97
|
-
- Model selection types: `src/domain/types/model-selection.types.ts`
|
|
98
|
-
|
|
99
|
-
### FalModelPricing
|
|
100
|
-
|
|
101
|
-
Model pricing information structure.
|
|
102
|
-
|
|
103
|
-
**Properties:**
|
|
104
|
-
- `creditsPerGeneration`: Credit cost per generation
|
|
105
|
-
- `currency`: Optional currency identifier
|
|
106
|
-
|
|
107
|
-
**Usage:**
|
|
108
|
-
Use to display pricing information to users. Calculate total costs before generation. Show credit cost in UI.
|
|
109
|
-
|
|
110
|
-
### FalJobInput
|
|
111
|
-
|
|
112
|
-
Job input data structure.
|
|
113
|
-
|
|
114
|
-
**Structure:**
|
|
115
|
-
- Index signature with string keys and unknown values
|
|
116
|
-
- Supports arbitrary model-specific parameters
|
|
117
|
-
- Flexible structure for different model requirements
|
|
118
|
-
|
|
119
|
-
**Usage:**
|
|
120
|
-
Use to pass input parameters to FAL models. Structure varies by model type. Include prompt, image data, and model-specific parameters.
|
|
121
|
-
|
|
122
|
-
**Related:**
|
|
123
|
-
- Image feature builders: `src/infrastructure/utils/image-feature-builders.util.ts`
|
|
124
|
-
- Video feature builders: `src/infrastructure/utils/video-feature-builders.util.ts`
|
|
125
|
-
|
|
126
|
-
### FalJobResult
|
|
127
|
-
|
|
128
|
-
Job result structure with generic data type.
|
|
129
|
-
|
|
130
|
-
**Properties:**
|
|
131
|
-
- `requestId`: Unique identifier for the request
|
|
132
|
-
- `data`: Generated data (generic type)
|
|
133
|
-
- `logs`: Optional array of log entries
|
|
134
|
-
|
|
135
|
-
**Usage:**
|
|
136
|
-
Use to represent completed job results. Generic type parameter allows type-safe result handling. Access generated data through `data` property.
|
|
137
|
-
|
|
138
|
-
**Related:**
|
|
139
|
-
- Queue status: `FalQueueStatus`
|
|
140
|
-
- Log entries: `FalLogEntry`
|
|
141
|
-
|
|
142
|
-
### FalLogEntry
|
|
143
|
-
|
|
144
|
-
Individual log entry structure.
|
|
145
|
-
|
|
146
|
-
**Properties:**
|
|
147
|
-
- `message`: Log message content
|
|
148
|
-
- `timestamp`: Optional ISO timestamp
|
|
149
|
-
- `level`: Optional log level (info, warn, error)
|
|
150
|
-
|
|
151
|
-
**Usage:**
|
|
152
|
-
Use to track job processing progress. Display to users for transparency. Include in job results for debugging.
|
|
153
|
-
|
|
154
|
-
**Related:**
|
|
155
|
-
- Job metadata: `src/infrastructure/utils/job-metadata/`
|
|
156
|
-
|
|
157
|
-
### FalQueueStatus
|
|
158
|
-
|
|
159
|
-
Job queue status throughout lifecycle.
|
|
160
|
-
|
|
161
|
-
**Properties:**
|
|
162
|
-
- `status`: Current status value
|
|
163
|
-
- `requestId`: Unique request identifier
|
|
164
|
-
- `logs`: Optional array of log entries
|
|
165
|
-
- `queuePosition`: Optional position in queue
|
|
166
|
-
|
|
167
|
-
**Valid Status Values:**
|
|
168
|
-
- `IN_QUEUE`: Job is queued waiting to start
|
|
169
|
-
- `IN_PROGRESS`: Job is currently processing
|
|
170
|
-
- `COMPLETED`: Job finished successfully
|
|
171
|
-
- `FAILED`: Job failed with error
|
|
172
|
-
|
|
173
|
-
**Usage:**
|
|
174
|
-
Use to track job lifecycle from submission to completion. Monitor queue position for wait times. Display status to users for transparency.
|
|
175
|
-
|
|
176
|
-
**Related:**
|
|
177
|
-
- Job lifecycle utilities: `src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.ts`
|
|
178
|
-
- Job status queries: `src/infrastructure/utils/job-metadata/job-metadata-queries.util.ts`
|
|
179
|
-
|
|
180
|
-
### FalSubscribeOptions
|
|
181
|
-
|
|
182
|
-
Subscription callback configuration.
|
|
183
|
-
|
|
184
|
-
**Properties:**
|
|
185
|
-
- `onQueueUpdate`: Optional callback for status updates
|
|
186
|
-
- `timeoutMs`: Optional timeout in milliseconds
|
|
187
|
-
|
|
188
|
-
**Usage:**
|
|
189
|
-
Use to configure real-time job monitoring. Receive status updates through callback. Control timeout duration for long-running jobs.
|
|
190
|
-
|
|
191
|
-
**Related:**
|
|
192
|
-
- FAL provider: `src/infrastructure/services/fal-provider.ts`
|
|
193
|
-
- Queue status tracking: `src/infrastructure/utils/job-metadata/`
|
|
194
|
-
|
|
195
|
-
## Usage Guidelines
|
|
196
|
-
|
|
197
|
-
### For Configuration
|
|
198
|
-
|
|
199
|
-
**Provider Initialization:**
|
|
200
|
-
1. Import `FalConfig` type from package
|
|
201
|
-
2. Create configuration object with API key
|
|
202
|
-
3. Optionally set retry and timeout parameters
|
|
203
|
-
4. Initialize provider with configuration
|
|
204
|
-
5. Use provider for generation operations
|
|
205
|
-
|
|
206
|
-
**Best Practices:**
|
|
207
|
-
- Always set API key from secure storage
|
|
208
|
-
- Configure appropriate timeouts for your use case
|
|
209
|
-
- Set reasonable retry limits to prevent excessive retries
|
|
210
|
-
- Use default values for optional properties when unsure
|
|
211
|
-
|
|
212
|
-
### For Model Information
|
|
213
|
-
|
|
214
|
-
**Model Selection:**
|
|
215
|
-
1. Import `FalModel` and `FalModelType` types
|
|
216
|
-
2. Get available models from provider or hook
|
|
217
|
-
3. Filter models by type using type guards
|
|
218
|
-
4. Display model information in UI
|
|
219
|
-
5. Select model for generation
|
|
220
|
-
|
|
221
|
-
**Related:**
|
|
222
|
-
- useModels hook: `src/presentation/hooks/use-models.ts`
|
|
223
|
-
- Model type guards: `src/infrastructure/utils/type-guards.util.ts`
|
|
224
|
-
|
|
225
|
-
### For Job Management
|
|
226
|
-
|
|
227
|
-
**Job Submission:**
|
|
228
|
-
1. Prepare input data using `FalJobInput` structure
|
|
229
|
-
2. Include prompt and required parameters
|
|
230
|
-
3. Use image builders for image operations
|
|
231
|
-
4. Submit job to provider
|
|
232
|
-
5. Track status using `FalQueueStatus`
|
|
233
|
-
|
|
234
|
-
**Result Handling:**
|
|
235
|
-
1. Receive result as `FalJobResult<T>` with specific type
|
|
236
|
-
2. Access generated data through `data` property
|
|
237
|
-
3. Process log entries for progress information
|
|
238
|
-
4. Display results to user
|
|
239
|
-
5. Handle errors appropriately
|
|
240
|
-
|
|
241
|
-
**Related:**
|
|
242
|
-
- Image feature builders: `src/infrastructure/utils/image-feature-builders.util.ts`
|
|
243
|
-
- Video feature builders: `src/infrastructure/utils/video-feature-builders.util.ts`
|
|
244
|
-
- Job lifecycle utilities: `src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.ts`
|
|
245
|
-
|
|
246
|
-
### For Status Tracking
|
|
247
|
-
|
|
248
|
-
**Queue Monitoring:**
|
|
249
|
-
1. Import `FalQueueStatus` type
|
|
250
|
-
2. Subscribe to job with callback
|
|
251
|
-
3. Monitor status changes in callback
|
|
252
|
-
4. Update UI based on status
|
|
253
|
-
5. Display queue position when applicable
|
|
254
|
-
|
|
255
|
-
**Status Handling:**
|
|
256
|
-
- `IN_QUEUE`: Show queue position to user
|
|
257
|
-
- `IN_PROGRESS`: Show processing indicator, display logs
|
|
258
|
-
- `COMPLETED`: Display result, hide progress
|
|
259
|
-
- `FAILED`: Show error message, allow retry
|
|
260
|
-
|
|
261
|
-
**Related:**
|
|
262
|
-
- Job lifecycle utilities: `src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.ts`
|
|
263
|
-
- Job format utilities: `src/infrastructure/utils/job-metadata/job-metadata-format.util.ts`
|
|
264
|
-
|
|
265
|
-
### For Subscription Configuration
|
|
266
|
-
|
|
267
|
-
**Callback Setup:**
|
|
268
|
-
1. Import `FalSubscribeOptions` type
|
|
269
|
-
2. Configure `onQueueUpdate` callback
|
|
270
|
-
3. Set appropriate timeout duration
|
|
271
|
-
4. Pass options to subscribe method
|
|
272
|
-
5. Handle updates in callback
|
|
273
|
-
|
|
274
|
-
**Timeout Management:**
|
|
275
|
-
- Set timeouts based on expected job duration
|
|
276
|
-
- Implement timeout error handling
|
|
277
|
-
- Allow users to extend timeout if needed
|
|
278
|
-
- Consider retry on timeout
|
|
279
|
-
|
|
280
|
-
## Best Practices
|
|
281
|
-
|
|
282
|
-
### 1. Use Type Generics
|
|
283
|
-
|
|
284
|
-
Leverage generic types for type safety:
|
|
285
|
-
- Specify result type in `FalJobResult<T>`
|
|
286
|
-
- Use model-specific result interfaces
|
|
287
|
-
- Enable TypeScript type checking
|
|
288
|
-
- Prevent type errors at compile time
|
|
289
|
-
|
|
290
|
-
### 2. Respect Readonly Properties
|
|
291
|
-
|
|
292
|
-
Maintain immutability of type properties:
|
|
293
|
-
- Don't modify readonly properties
|
|
294
|
-
- Create copies when transformations needed
|
|
295
|
-
- Use spread operator for updates
|
|
296
|
-
- Maintain type safety
|
|
297
|
-
|
|
298
|
-
### 3. Handle All Status Values
|
|
299
|
-
|
|
300
|
-
Prepare for every queue status:
|
|
301
|
-
- Implement handlers for all four status values
|
|
302
|
-
- Show appropriate UI for each status
|
|
303
|
-
- Handle status transitions smoothly
|
|
304
|
-
- Consider edge cases in status changes
|
|
305
|
-
|
|
306
|
-
### 4. Validate Input Data
|
|
307
|
-
|
|
308
|
-
Ensure input data correctness:
|
|
309
|
-
- Check required parameters before submission
|
|
310
|
-
- Validate parameter types and ranges
|
|
311
|
-
- Use type guards for runtime validation
|
|
312
|
-
- Sanitize user input appropriately
|
|
313
|
-
|
|
314
|
-
**Related:**
|
|
315
|
-
- Type guards: `src/infrastructure/utils/type-guards.util.ts`
|
|
316
|
-
- Helper utilities: `src/infrastructure/utils/helpers.util.ts`
|
|
317
|
-
|
|
318
|
-
### 5. Use Type Guards
|
|
319
|
-
|
|
320
|
-
Implement runtime type checking:
|
|
321
|
-
- Validate model types before use
|
|
322
|
-
- Check queue status values
|
|
323
|
-
- Guard against invalid data
|
|
324
|
-
- Enable type narrowing
|
|
325
|
-
|
|
326
|
-
**Related:**
|
|
327
|
-
- Type guards: `src/infrastructure/utils/type-guards.util.ts`
|
|
328
|
-
|
|
329
|
-
## For AI Agents
|
|
330
|
-
|
|
331
|
-
### When Using FAL Types
|
|
332
|
-
|
|
333
|
-
**DO:**
|
|
334
|
-
- Import types from package root
|
|
335
|
-
- Use proper TypeScript type annotations
|
|
336
|
-
- Leverage generic types for type safety
|
|
337
|
-
- Respect readonly property modifiers
|
|
338
|
-
- Validate data before use
|
|
339
|
-
- Handle all possible type values
|
|
340
|
-
- Use type guards for runtime checks
|
|
341
|
-
|
|
342
|
-
**DON'T:**
|
|
343
|
-
- Import from internal paths
|
|
344
|
-
- Ignore type annotations
|
|
345
|
-
- Modify readonly properties
|
|
346
|
-
- Assume type correctness
|
|
347
|
-
- Skip type guards
|
|
348
|
-
- Handle only some type values
|
|
349
|
-
- Use type assertions unnecessarily
|
|
350
|
-
- Cast to wrong types
|
|
351
|
-
|
|
352
|
-
### When Working with Configuration
|
|
353
|
-
|
|
354
|
-
**DO:**
|
|
355
|
-
- Set API key from secure storage
|
|
356
|
-
- Configure appropriate timeouts
|
|
357
|
-
- Set reasonable retry limits
|
|
358
|
-
- Use default values appropriately
|
|
359
|
-
- Validate configuration before use
|
|
360
|
-
- Store configuration securely
|
|
361
|
-
- Document configuration choices
|
|
362
|
-
|
|
363
|
-
**DON'T:**
|
|
364
|
-
- Hardcode API keys
|
|
365
|
-
- Set unreasonable timeouts
|
|
366
|
-
- Allow infinite retries
|
|
367
|
-
- Ignore optional properties
|
|
368
|
-
- Skip configuration validation
|
|
369
|
-
- Store API keys in plain text
|
|
370
|
-
- Use arbitrary configuration values
|
|
371
|
-
|
|
372
|
-
### When Handling Jobs
|
|
373
|
-
|
|
374
|
-
**DO:**
|
|
375
|
-
- Type job inputs properly
|
|
376
|
-
- Use specific result types
|
|
377
|
-
- Handle all status values
|
|
378
|
-
- Process log entries appropriately
|
|
379
|
-
- Validate job data
|
|
380
|
-
- Handle errors gracefully
|
|
381
|
-
- Display progress to users
|
|
382
|
-
|
|
383
|
-
**DON'T::**
|
|
384
|
-
- Use loose input types
|
|
385
|
-
- Ignore result typing
|
|
386
|
-
- Skip status values
|
|
387
|
-
- Discard log information
|
|
388
|
-
- Assume data validity
|
|
389
|
-
- Ignore error cases
|
|
390
|
-
- Hide progress information
|
|
391
|
-
|
|
392
|
-
### When Adding Types
|
|
393
|
-
|
|
394
|
-
**For New Type Definitions:**
|
|
395
|
-
1. Add type to appropriate file
|
|
396
|
-
2. Export from package root
|
|
397
|
-
3. Update TypeScript types
|
|
398
|
-
4. Document type purpose
|
|
399
|
-
5. Add usage examples (in separate files)
|
|
400
|
-
6. Update this README
|
|
401
|
-
|
|
402
|
-
**For New Type Properties:**
|
|
403
|
-
1. Add property to interface
|
|
404
|
-
2. Mark readonly if appropriate
|
|
405
|
-
3. Make optional with good reason
|
|
406
|
-
4. Document property purpose
|
|
407
|
-
5. Update type definitions
|
|
408
|
-
6. Test type usage
|
|
409
|
-
|
|
410
|
-
**For Enhanced Type Safety:**
|
|
411
|
-
1. Review existing types
|
|
412
|
-
2. Add stricter types where needed
|
|
413
|
-
3. Use discriminated unions
|
|
414
|
-
4. Improve type coverage
|
|
415
|
-
5. Document type changes
|
|
416
|
-
6. Update related code
|
|
417
|
-
|
|
418
|
-
## Implementation Notes
|
|
419
|
-
|
|
420
|
-
**Location:** `src/domain/entities/fal.types.ts`
|
|
421
|
-
|
|
422
|
-
**Dependencies:**
|
|
423
|
-
- No external dependencies
|
|
424
|
-
- Pure TypeScript type definitions
|
|
425
|
-
- Used throughout FAL provider
|
|
426
|
-
|
|
427
|
-
**Type Categories:**
|
|
428
|
-
- Configuration types
|
|
429
|
-
- Model information types
|
|
430
|
-
- Job management types
|
|
431
|
-
- Queue status types
|
|
432
|
-
- Subscription types
|
|
433
|
-
|
|
434
|
-
**Import:**
|
|
435
|
-
```typescript
|
|
436
|
-
import type {
|
|
437
|
-
FalConfig,
|
|
438
|
-
FalModel,
|
|
439
|
-
FalModelType,
|
|
440
|
-
FalModelPricing,
|
|
441
|
-
FalJobInput,
|
|
442
|
-
FalJobResult,
|
|
443
|
-
FalLogEntry,
|
|
444
|
-
FalQueueStatus,
|
|
445
|
-
FalSubscribeOptions
|
|
446
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
**Related:**
|
|
450
|
-
- Error types: `src/domain/entities/error.types.ts`
|
|
451
|
-
- Model selection types: `src/domain/types/model-selection.types.ts`
|
|
452
|
-
- FAL provider: `src/infrastructure/services/fal-provider.ts`
|
|
453
|
-
- Type guards: `src/infrastructure/utils/type-guards.util.ts`
|
|
454
|
-
|
|
455
|
-
## Related Documentation
|
|
456
|
-
|
|
457
|
-
- [Error Types](./error.types.README.md)
|
|
458
|
-
- [Model Selection Types](../types/model-selection.types.README.md)
|
|
459
|
-
- [FAL Provider](../../infrastructure/services/fal-provider.README.md)
|
|
460
|
-
- [Type Guards](../../infrastructure/utils/type-guards.util.README.md)
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
# Domain Types Index
|
|
2
|
-
|
|
3
|
-
Central export point for all domain type definitions.
|
|
4
|
-
|
|
5
|
-
**Location:** `src/domain/types/index.ts`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
The domain types module serves as the central export hub for all TypeScript types and interfaces used throughout the `react-native-ai-fal-provider` package. This module consolidates type exports from two main categories: model selection types and input builders types.
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
Provides type organization by:
|
|
14
|
-
- Centralizing type exports
|
|
15
|
-
- Organizing types by category
|
|
16
|
-
- Facilitating type imports
|
|
17
|
-
- Maintaining type consistency
|
|
18
|
-
- Enabling tree-shaking
|
|
19
|
-
|
|
20
|
-
## Import
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import type {
|
|
24
|
-
ModelType,
|
|
25
|
-
ModelSelectionConfig,
|
|
26
|
-
ModelSelectionState,
|
|
27
|
-
UpscaleOptions,
|
|
28
|
-
VideoFromImageOptions,
|
|
29
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Exports
|
|
33
|
-
|
|
34
|
-
### Model Selection Types
|
|
35
|
-
|
|
36
|
-
Types related to model selection functionality and the `useModels` hook.
|
|
37
|
-
|
|
38
|
-
**Path:** `src/domain/types/model-selection.types.ts`
|
|
39
|
-
|
|
40
|
-
**Includes:**
|
|
41
|
-
- `ModelType` - Supported AI model generation types
|
|
42
|
-
- `ModelSelectionConfig` - Configuration options for model selection
|
|
43
|
-
- `ModelSelectionState` - Model selection state object
|
|
44
|
-
- `ModelSelectionActions` - Actions for manipulating model selection
|
|
45
|
-
- `UseModelsReturn` - Complete return type for `useModels` hook
|
|
46
|
-
|
|
47
|
-
### Input Builders Types
|
|
48
|
-
|
|
49
|
-
Types related to input builder functions for FAL API calls.
|
|
50
|
-
|
|
51
|
-
**Path:** `src/domain/types/input-builders.types.ts`
|
|
52
|
-
|
|
53
|
-
**Includes:**
|
|
54
|
-
- `UpscaleOptions` - Options for image upscaling
|
|
55
|
-
- `PhotoRestoreOptions` - Options for photo restoration
|
|
56
|
-
- `ImageToImagePromptConfig` - Configuration for image-to-image generation
|
|
57
|
-
- `RemoveBackgroundOptions` - Options for background removal
|
|
58
|
-
- `RemoveObjectOptions` - Options for object removal
|
|
59
|
-
- `ReplaceBackgroundOptions` - Options for background replacement
|
|
60
|
-
- `VideoFromImageOptions` - Options for video generation from images
|
|
61
|
-
- `FaceSwapOptions` - Options for face swapping
|
|
62
|
-
|
|
63
|
-
## Usage Guidelines
|
|
64
|
-
|
|
65
|
-
### For Type Imports
|
|
66
|
-
|
|
67
|
-
**Import Pattern:**
|
|
68
|
-
1. Use `import type` for type-only imports
|
|
69
|
-
2. Import only needed types
|
|
70
|
-
3. Import from package root
|
|
71
|
-
4. Enable tree-shaking
|
|
72
|
-
5. Maintain type safety
|
|
73
|
-
|
|
74
|
-
**Best Practices:**
|
|
75
|
-
- Use type imports for types
|
|
76
|
-
- Avoid value imports for types
|
|
77
|
-
- Import specific types needed
|
|
78
|
-
- Group related type imports
|
|
79
|
-
- Enable strict TypeScript checking
|
|
80
|
-
|
|
81
|
-
### For Type Safety
|
|
82
|
-
|
|
83
|
-
**Safety Pattern:**
|
|
84
|
-
1. Use types for configuration
|
|
85
|
-
2. Enable autocomplete
|
|
86
|
-
3. Validate at compile time
|
|
87
|
-
4. Use type guards
|
|
88
|
-
5. Leverage type inference
|
|
89
|
-
|
|
90
|
-
**Benefits:**
|
|
91
|
-
- Compile-time validation
|
|
92
|
-
- IDE autocomplete support
|
|
93
|
-
- Parameter type checking
|
|
94
|
-
- Prevent invalid inputs
|
|
95
|
-
- Self-documenting code
|
|
96
|
-
|
|
97
|
-
## Best Practices
|
|
98
|
-
|
|
99
|
-
### 1. Use Type Imports
|
|
100
|
-
|
|
101
|
-
Import types correctly:
|
|
102
|
-
- Use `import type` for type-only imports
|
|
103
|
-
- Import from package root
|
|
104
|
-
- Maintain consistent imports
|
|
105
|
-
- Enable tree-shaking
|
|
106
|
-
|
|
107
|
-
### 2. Import Only What You Need
|
|
108
|
-
|
|
109
|
-
Be specific in imports:
|
|
110
|
-
- Import only required types
|
|
111
|
-
- Avoid star imports
|
|
112
|
-
- Group related types
|
|
113
|
-
- Remove unused imports
|
|
114
|
-
- Keep imports organized
|
|
115
|
-
|
|
116
|
-
### 3. Combine Related Types
|
|
117
|
-
|
|
118
|
-
Organize type imports:
|
|
119
|
-
- Group by functionality
|
|
120
|
-
- Import related types together
|
|
121
|
-
- Maintain logical grouping
|
|
122
|
-
- Document type relationships
|
|
123
|
-
- Enable reusability
|
|
124
|
-
|
|
125
|
-
### 4. Use Type Guards
|
|
126
|
-
|
|
127
|
-
Implement type checking:
|
|
128
|
-
- Use type guards for validation
|
|
129
|
-
- Enable type narrowing
|
|
130
|
-
- Check runtime values
|
|
131
|
-
- Validate model types
|
|
132
|
-
- Handle type errors
|
|
133
|
-
|
|
134
|
-
### 5. Enable Type Inference
|
|
135
|
-
|
|
136
|
-
Leverage TypeScript:
|
|
137
|
-
- Use type inference where possible
|
|
138
|
-
- Provide type annotations when needed
|
|
139
|
-
- Avoid unnecessary type assertions
|
|
140
|
-
- Let TypeScript infer types
|
|
141
|
-
- Maintain type safety
|
|
142
|
-
|
|
143
|
-
## For AI Agents
|
|
144
|
-
|
|
145
|
-
### When Using Types
|
|
146
|
-
|
|
147
|
-
**DO:**
|
|
148
|
-
- Use `import type` for types
|
|
149
|
-
- Import specific types needed
|
|
150
|
-
- Import from package root
|
|
151
|
-
- Enable type safety
|
|
152
|
-
- Use type guards
|
|
153
|
-
- Validate at compile time
|
|
154
|
-
- Enable autocomplete
|
|
155
|
-
|
|
156
|
-
**DON'T:**
|
|
157
|
-
- Use value imports for types
|
|
158
|
-
- Import everything indiscriminately
|
|
159
|
-
- Import from internal paths
|
|
160
|
-
- Skip type validation
|
|
161
|
-
- Use type assertions unnecessarily
|
|
162
|
-
- Disable type checking
|
|
163
|
-
- Create duplicate types
|
|
164
|
-
|
|
165
|
-
### When Organizing Imports
|
|
166
|
-
|
|
167
|
-
**DO:**
|
|
168
|
-
- Group by functionality
|
|
169
|
-
- Import related types together
|
|
170
|
-
- Maintain logical grouping
|
|
171
|
-
- Remove unused imports
|
|
172
|
-
- Enable tree-shaking
|
|
173
|
-
- Follow import conventions
|
|
174
|
-
|
|
175
|
-
**DON'T:**
|
|
176
|
-
- Mix imports randomly
|
|
177
|
-
- Import unused types
|
|
178
|
-
- Create import chaos
|
|
179
|
-
- Skip organization
|
|
180
|
-
- Disable tree-shaking
|
|
181
|
-
- Follow inconsistent patterns
|
|
182
|
-
|
|
183
|
-
### When Validating Types
|
|
184
|
-
|
|
185
|
-
**DO:**
|
|
186
|
-
- Use type guards
|
|
187
|
-
- Check runtime values
|
|
188
|
-
- Validate model types
|
|
189
|
-
- Handle type errors
|
|
190
|
-
- Provide helpful errors
|
|
191
|
-
- Update type guards
|
|
192
|
-
|
|
193
|
-
**DON'T:**
|
|
194
|
-
- Skip type validation
|
|
195
|
-
- Assume type correctness
|
|
196
|
-
- Use type assertions
|
|
197
|
-
- Ignore type errors
|
|
198
|
-
- Create type mismatches
|
|
199
|
-
- Forget type guards
|
|
200
|
-
|
|
201
|
-
## Implementation Notes
|
|
202
|
-
|
|
203
|
-
**Location:** `src/domain/types/index.ts`
|
|
204
|
-
|
|
205
|
-
**Dependencies:**
|
|
206
|
-
- Re-exports from type files
|
|
207
|
-
- No external dependencies
|
|
208
|
-
- Pure TypeScript types
|
|
209
|
-
|
|
210
|
-
**Type Categories:**
|
|
211
|
-
- Model selection types
|
|
212
|
-
- Input builder types
|
|
213
|
-
- Configuration types
|
|
214
|
-
- State types
|
|
215
|
-
|
|
216
|
-
**Import:**
|
|
217
|
-
```typescript
|
|
218
|
-
import type {
|
|
219
|
-
ModelType,
|
|
220
|
-
ModelSelectionConfig,
|
|
221
|
-
ModelSelectionState,
|
|
222
|
-
UpscaleOptions,
|
|
223
|
-
VideoFromImageOptions,
|
|
224
|
-
} from '@umituz/react-native-ai-fal-provider';
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
**Related:**
|
|
228
|
-
- Model selection types: `src/domain/types/model-selection.types.ts`
|
|
229
|
-
- Input builder types: `src/domain/types/input-builders.types.ts`
|