@umituz/react-native-ai-fal-provider 1.0.68 → 1.0.70
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/README.md +586 -71
- package/package.json +1 -1
- package/src/domain/constants/default-models.constants.README.md +378 -0
- package/src/domain/constants/feature-models.constants.README.md +337 -0
- package/src/domain/constants/models/image-to-video.README.md +266 -0
- package/src/domain/constants/models/index.README.md +269 -0
- package/src/domain/constants/models/text-to-image.README.md +237 -0
- package/src/domain/constants/models/text-to-text.README.md +249 -0
- package/src/domain/constants/models/text-to-video.README.md +259 -0
- package/src/domain/constants/models/text-to-voice.README.md +264 -0
- package/src/domain/entities/error.types.README.md +292 -0
- package/src/domain/entities/fal.types.README.md +460 -0
- package/src/domain/types/index.README.md +229 -0
- package/src/domain/types/input-builders.types.README.md +430 -0
- package/src/domain/types/model-selection.types.README.md +311 -0
- package/src/index.README.md +420 -0
- package/src/infrastructure/builders/image-feature-builder.README.md +435 -0
- package/src/infrastructure/builders/index.README.md +224 -0
- package/src/infrastructure/builders/video-feature-builder.README.md +343 -0
- package/src/infrastructure/services/fal-models-service.README.md +293 -0
- package/src/infrastructure/services/fal-provider-subscription.README.md +257 -0
- package/src/infrastructure/services/fal-provider.README.md +474 -0
- package/src/infrastructure/services/fal-provider.constants.README.md +299 -0
- package/src/infrastructure/services/fal-status-mapper.README.md +246 -0
- package/src/infrastructure/services/index.README.md +389 -0
- package/src/infrastructure/services/nsfw-content-error.README.md +215 -0
- package/src/infrastructure/utils/base-builders.util.README.md +313 -0
- package/src/infrastructure/utils/error-categorizer.README.md +395 -0
- package/src/infrastructure/utils/error-mapper.README.md +367 -0
- package/src/infrastructure/utils/helpers.util.README.md +395 -0
- package/src/infrastructure/utils/image-feature-builders.util.README.md +411 -0
- package/src/infrastructure/utils/index.README.md +338 -0
- package/src/infrastructure/utils/job-metadata/index.README.md +267 -0
- package/src/infrastructure/utils/job-metadata/job-metadata-format.util.README.md +209 -0
- package/src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.README.md +311 -0
- package/src/infrastructure/utils/job-metadata/job-metadata-queries.util.README.md +332 -0
- package/src/infrastructure/utils/job-metadata/job-metadata.types.README.md +446 -0
- package/src/infrastructure/utils/job-metadata.README.md +268 -0
- package/src/infrastructure/utils/type-guards.util.README.md +371 -0
- package/src/infrastructure/utils/video-feature-builders.util.README.md +344 -0
- package/src/infrastructure/validators/README.md +290 -0
- package/src/infrastructure/validators/index.README.md +205 -0
- package/src/infrastructure/validators/nsfw-validator.README.md +309 -0
- package/src/presentation/hooks/README.md +626 -0
- package/src/presentation/hooks/index.README.md +224 -0
- package/src/presentation/hooks/use-fal-generation.README.md +398 -0
- package/src/presentation/hooks/use-models.README.md +318 -0
package/README.md
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
# @umituz/react-native-ai-fal-provider
|
|
2
2
|
|
|
3
|
-
FAL AI provider
|
|
3
|
+
FAL AI provider for React Native - Unified AI generation with IAIProvider interface implementation.
|
|
4
|
+
|
|
5
|
+
## Documentation Strategy
|
|
6
|
+
|
|
7
|
+
**Important:** This documentation follows a code-example-free approach.
|
|
8
|
+
|
|
9
|
+
- **No Code Examples:** Documentation references file paths instead of showing code
|
|
10
|
+
- **Path-Based References:** Always references actual file locations
|
|
11
|
+
- **Maintainable:** Documentation stays valid when implementation changes
|
|
12
|
+
|
|
13
|
+
For detailed guidelines, see: `.docs-template.md`
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Text-to-Image Generation** - Generate images from text prompts (Flux models)
|
|
20
|
+
- **Text-to-Video Generation** - Create videos from text descriptions
|
|
21
|
+
- **Image-to-Video Conversion** - Transform images into videos
|
|
22
|
+
- **Image Processing** - Advanced image editing capabilities
|
|
23
|
+
- **Video Features** - AI-powered video generation
|
|
24
|
+
- **Model Management** - Dynamic pricing and model selection
|
|
25
|
+
- **Error Handling** - Categorization and retry logic
|
|
26
|
+
- **Job Management** - Complete job lifecycle tracking
|
|
27
|
+
|
|
28
|
+
---
|
|
4
29
|
|
|
5
30
|
## Installation
|
|
6
31
|
|
|
@@ -8,101 +33,591 @@ FAL AI provider service for React Native applications. Provides client wrapper,
|
|
|
8
33
|
npm install @umituz/react-native-ai-fal-provider @fal-ai/client
|
|
9
34
|
```
|
|
10
35
|
|
|
11
|
-
|
|
36
|
+
---
|
|
12
37
|
|
|
13
|
-
|
|
38
|
+
## Quick Start
|
|
14
39
|
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
### 1. Initialize Provider
|
|
41
|
+
|
|
42
|
+
**Location:** `src/infrastructure/services/fal-provider.ts`
|
|
17
43
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
defaultTimeoutMs: 300000,
|
|
22
|
-
});
|
|
44
|
+
**Import:**
|
|
45
|
+
```typescript
|
|
46
|
+
import { falProvider } from '@umituz/react-native-ai-fal-provider';
|
|
23
47
|
```
|
|
24
48
|
|
|
25
|
-
|
|
49
|
+
**Usage:**
|
|
50
|
+
Call `falProvider.initialize()` with your API key and configuration options.
|
|
51
|
+
|
|
52
|
+
**Implementation:** See `src/infrastructure/services/fal-provider.ts` for complete initialization options.
|
|
53
|
+
|
|
54
|
+
---
|
|
26
55
|
|
|
56
|
+
### 2. Use React Hooks
|
|
57
|
+
|
|
58
|
+
**Locations:**
|
|
59
|
+
- `src/presentation/hooks/use-fal-generation.ts` - Generation management
|
|
60
|
+
- `src/presentation/hooks/use-models.ts` - Model selection
|
|
61
|
+
|
|
62
|
+
**Import:**
|
|
27
63
|
```typescript
|
|
28
|
-
import { useFalGeneration } from
|
|
29
|
-
|
|
30
|
-
function MyComponent() {
|
|
31
|
-
const { data, error, isLoading, generate, retry } = useFalGeneration({
|
|
32
|
-
timeoutMs: 120000,
|
|
33
|
-
onProgress: (status) => console.log("Progress:", status),
|
|
34
|
-
onError: (error) => console.log("Error:", error),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const handleGenerate = async () => {
|
|
38
|
-
await generate("fal-ai/flux/dev", {
|
|
39
|
-
prompt: "A beautiful sunset",
|
|
40
|
-
image_size: "landscape_16_9",
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
// Your UI
|
|
46
|
-
);
|
|
47
|
-
}
|
|
64
|
+
import { useFalGeneration, useModels } from '@umituz/react-native-ai-fal-provider';
|
|
48
65
|
```
|
|
49
66
|
|
|
50
|
-
|
|
67
|
+
**Usage:**
|
|
68
|
+
- Use `useFalGeneration` hook for managing AI generation operations
|
|
69
|
+
- Use `useModels` hook for model selection and management
|
|
51
70
|
|
|
52
|
-
|
|
53
|
-
import { falProvider } from "@umituz/react-native-ai-fal-provider";
|
|
71
|
+
**Implementation:** See hook files for complete API and options.
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
prompt: "A beautiful sunset",
|
|
57
|
-
});
|
|
58
|
-
```
|
|
73
|
+
---
|
|
59
74
|
|
|
60
|
-
|
|
75
|
+
## Core Features
|
|
76
|
+
|
|
77
|
+
### Text-to-Image Generation
|
|
78
|
+
|
|
79
|
+
**Location:** `src/domain/constants/models/text-to-image.models.ts`
|
|
80
|
+
|
|
81
|
+
**Models:**
|
|
82
|
+
- Flux Schnell (1 credit) - Fast generation
|
|
83
|
+
- Flux Dev (2 credits) - High quality
|
|
84
|
+
- Flux Pro (3 credits) - Professional quality
|
|
85
|
+
|
|
86
|
+
**Usage:**
|
|
87
|
+
Use model IDs from `DEFAULT_TEXT_TO_IMAGE_MODELS` constant with `falProvider.subscribe()`.
|
|
88
|
+
|
|
89
|
+
**Related:**
|
|
90
|
+
- Model definitions: `src/domain/constants/models/text-to-image.models.ts`
|
|
91
|
+
- Default models: `src/domain/constants/default-models.constants.ts`
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### Text-to-Video Generation
|
|
61
96
|
|
|
97
|
+
**Location:** `src/domain/constants/models/text-to-video.models.ts`
|
|
98
|
+
|
|
99
|
+
**Models:**
|
|
100
|
+
- Hunyuan (10 credits) - Balanced quality/speed
|
|
101
|
+
- MiniMax (15 credits) - High quality
|
|
102
|
+
- Kling 1.5 (20 credits) - Premium
|
|
103
|
+
- Mochi (8 credits) - Fast
|
|
104
|
+
|
|
105
|
+
**Usage:**
|
|
106
|
+
Select model from `DEFAULT_TEXT_TO_VIDEO_MODELS` and pass to provider.
|
|
107
|
+
|
|
108
|
+
**Related:**
|
|
109
|
+
- Video models: `src/domain/constants/models/text-to-video.models.ts`
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### Image Features
|
|
114
|
+
|
|
115
|
+
**Location:** `src/infrastructure/builders/image-feature-builder.ts`
|
|
116
|
+
|
|
117
|
+
**Available Features:**
|
|
118
|
+
- Upscale (2x, 4x) - `src/infrastructure/utils/image-feature-builders.util.ts`
|
|
119
|
+
- Photo Restore - Enhance old photos
|
|
120
|
+
- Face Swap - Swap faces between images
|
|
121
|
+
- Remove Background - Clean background removal
|
|
122
|
+
- Remove Object - Object removal and inpainting
|
|
123
|
+
- Replace Background - Replace image background
|
|
124
|
+
- HD Touch Up - Enhance image quality
|
|
125
|
+
- Anime Selfie - Transform to anime style
|
|
126
|
+
|
|
127
|
+
**Usage:**
|
|
128
|
+
- Use `buildUpscaleInput()` from `src/infrastructure/utils/image-feature-builders.util.ts`
|
|
129
|
+
- Use `buildRemoveBackgroundInput()` for background removal
|
|
130
|
+
- Use `buildFaceSwapInput()` for face swapping
|
|
131
|
+
- See `src/infrastructure/builders/image-feature-builder.ts` for complete list
|
|
132
|
+
|
|
133
|
+
**Related:**
|
|
134
|
+
- Image builders: `src/infrastructure/utils/image-feature-builders.util.ts`
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### Video Features
|
|
139
|
+
|
|
140
|
+
**Location:** `src/infrastructure/builders/video-feature-builder.ts`
|
|
141
|
+
|
|
142
|
+
**Features:**
|
|
143
|
+
- AI Hug - Generate hug videos from 2 person images
|
|
144
|
+
- AI Kiss - Generate kiss videos from 2 person images
|
|
145
|
+
|
|
146
|
+
**Usage:**
|
|
147
|
+
Use `buildVideoFromImageInput()` from `src/infrastructure/utils/video-feature-builders.util.ts`
|
|
148
|
+
|
|
149
|
+
**Related:**
|
|
150
|
+
- Video builders: `src/infrastructure/utils/video-feature-builders.util.ts`
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## API Reference
|
|
155
|
+
|
|
156
|
+
### FalProvider
|
|
157
|
+
|
|
158
|
+
**Location:** `src/infrastructure/services/fal-provider.ts`
|
|
159
|
+
|
|
160
|
+
**Purpose:** Main provider class for FAL AI operations
|
|
161
|
+
|
|
162
|
+
**Import:**
|
|
62
163
|
```typescript
|
|
63
|
-
import {
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
await falProvider.run("fal-ai/flux/dev", { prompt: "test" });
|
|
67
|
-
} catch (error) {
|
|
68
|
-
const errorInfo = mapFalError(error);
|
|
69
|
-
console.log("Error type:", errorInfo.type);
|
|
70
|
-
console.log("Message key:", errorInfo.messageKey);
|
|
71
|
-
console.log("Retryable:", errorInfo.retryable);
|
|
72
|
-
}
|
|
164
|
+
import { falProvider } from '@umituz/react-native-ai-fal-provider';
|
|
73
165
|
```
|
|
74
166
|
|
|
75
|
-
|
|
167
|
+
**Key Methods:**
|
|
168
|
+
- `initialize()` - Set up provider with API key
|
|
169
|
+
- `subscribe()` - Subscribe to generation job with polling
|
|
170
|
+
- `run()` - Run generation job
|
|
171
|
+
- `submitJob()` - Submit job to queue
|
|
172
|
+
- `getJobStatus()` - Check job status
|
|
173
|
+
- `getJobResult()` - Get job result
|
|
174
|
+
- `cancelCurrentRequest()` - Cancel current request
|
|
175
|
+
- `hasRunningRequest()` - Check for active requests
|
|
76
176
|
|
|
77
|
-
|
|
177
|
+
**Implementation:** See `src/infrastructure/services/fal-provider.ts` for complete API
|
|
78
178
|
|
|
79
|
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- `getJobResult(model, requestId)` - Get job result
|
|
85
|
-
- `isInitialized()` - Check if provider is initialized
|
|
86
|
-
- `reset()` - Reset the provider
|
|
87
|
-
- `getCapabilities()` - Get provider capabilities
|
|
88
|
-
- `isFeatureSupported(feature)` - Check if feature is supported
|
|
179
|
+
**Related:**
|
|
180
|
+
- Provider constants: `src/infrastructure/services/fal-provider.constants.ts`
|
|
181
|
+
- Subscription handler: `src/infrastructure/services/fal-provider-subscription.ts`
|
|
182
|
+
|
|
183
|
+
---
|
|
89
184
|
|
|
90
185
|
### useFalGeneration Hook
|
|
91
186
|
|
|
187
|
+
**Location:** `src/presentation/hooks/use-fal-generation.ts`
|
|
188
|
+
|
|
189
|
+
**Purpose:** React hook for managing AI generation operations
|
|
190
|
+
|
|
191
|
+
**Import:**
|
|
192
|
+
```typescript
|
|
193
|
+
import { useFalGeneration } from '@umituz/react-native-ai-fal-provider';
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Returns:**
|
|
92
197
|
- `data` - Generation result
|
|
93
|
-
- `error` - Error
|
|
198
|
+
- `error` - Error information
|
|
94
199
|
- `isLoading` - Loading state
|
|
95
|
-
- `isRetryable` - Whether error
|
|
96
|
-
- `generate(
|
|
97
|
-
- `retry()` - Retry
|
|
200
|
+
- `isRetryable` - Whether error can be retried
|
|
201
|
+
- `generate()` - Start generation function
|
|
202
|
+
- `retry()` - Retry failed generation
|
|
203
|
+
- `cancel()` - Cancel current generation
|
|
98
204
|
- `reset()` - Reset state
|
|
99
205
|
|
|
100
|
-
|
|
206
|
+
**Usage Guidelines:**
|
|
207
|
+
Use this hook when you need to manage AI generation in React components. It handles loading states, errors, and retries automatically.
|
|
208
|
+
|
|
209
|
+
**Implementation:** See `src/presentation/hooks/use-fal-generation.ts` for options and callbacks
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### useModels Hook
|
|
214
|
+
|
|
215
|
+
**Location:** `src/presentation/hooks/use-models.ts`
|
|
216
|
+
|
|
217
|
+
**Purpose:** React hook for managing AI model selection
|
|
218
|
+
|
|
219
|
+
**Import:**
|
|
220
|
+
```typescript
|
|
221
|
+
import { useModels } from '@umituz/react-native-ai-fal-provider';
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Returns:**
|
|
225
|
+
- `models` - Available models array
|
|
226
|
+
- `selectedModel` - Currently selected model
|
|
227
|
+
- `selectModel()` - Select model function
|
|
228
|
+
- `creditCost` - Cost in credits
|
|
229
|
+
- `modelId` - Selected model ID
|
|
230
|
+
- `isLoading` - Loading state
|
|
231
|
+
- `error` - Error information
|
|
232
|
+
- `refreshModels()` - Refresh models function
|
|
233
|
+
|
|
234
|
+
**Usage Guidelines:**
|
|
235
|
+
Use this hook to provide model selection UI and dynamic pricing information.
|
|
236
|
+
|
|
237
|
+
**Implementation:** See `src/presentation/hooks/use-models.ts` for configuration options
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Type Definitions
|
|
242
|
+
|
|
243
|
+
### Core Types
|
|
244
|
+
|
|
245
|
+
**Location:** `src/domain/entities/fal.types.ts`
|
|
246
|
+
|
|
247
|
+
**Types:**
|
|
248
|
+
- `FalConfig` - Provider configuration
|
|
249
|
+
- `FalModel` - Model definition
|
|
250
|
+
- `FalJobInput` - Job input structure
|
|
251
|
+
- `FalJobResult` - Job result structure
|
|
252
|
+
- `FalQueueStatus` - Queue status structure
|
|
253
|
+
|
|
254
|
+
**Import:**
|
|
255
|
+
```typescript
|
|
256
|
+
import type {
|
|
257
|
+
FalConfig,
|
|
258
|
+
FalModel,
|
|
259
|
+
FalJobInput,
|
|
260
|
+
FalJobResult
|
|
261
|
+
} from '@umituz/react-native-ai-fal-provider';
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
### Error Types
|
|
267
|
+
|
|
268
|
+
**Location:** `src/domain/entities/error.types.ts`
|
|
269
|
+
|
|
270
|
+
**Types:**
|
|
271
|
+
- `FalErrorType` - Error type enumeration
|
|
272
|
+
- `FalErrorCategory` - Error category
|
|
273
|
+
- `FalErrorInfo` - Error information structure
|
|
274
|
+
|
|
275
|
+
**Usage:**
|
|
276
|
+
Use error types from `src/domain/entities/error.types.ts` for type-safe error handling.
|
|
277
|
+
|
|
278
|
+
**Related:**
|
|
279
|
+
- Error mapper: `src/infrastructure/utils/error-mapper.ts`
|
|
280
|
+
- Error categorizer: `src/infrastructure/utils/error-categorizer.ts`
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### Input Builder Types
|
|
285
|
+
|
|
286
|
+
**Location:** `src/domain/types/input-builders.types.ts`
|
|
287
|
+
|
|
288
|
+
**Types:**
|
|
289
|
+
- `UpscaleOptions` - Upscale operation options
|
|
290
|
+
- `PhotoRestoreOptions` - Photo restore options
|
|
291
|
+
- `ImageToImagePromptConfig` - Image-to-image configuration
|
|
292
|
+
- `VideoFromImageOptions` - Video generation options
|
|
293
|
+
- `FaceSwapOptions` - Face swap options
|
|
294
|
+
|
|
295
|
+
**Usage:**
|
|
296
|
+
Use these types when calling input builder functions from `src/infrastructure/utils/`.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Utilities
|
|
301
|
+
|
|
302
|
+
### Error Handling
|
|
303
|
+
|
|
304
|
+
**Location:** `src/infrastructure/utils/error-mapper.ts`
|
|
305
|
+
|
|
306
|
+
**Functions:**
|
|
307
|
+
- `mapFalError()` - Map FAL errors to standard format
|
|
308
|
+
- `isFalErrorRetryable()` - Check if error can be retried
|
|
309
|
+
|
|
310
|
+
**Import:**
|
|
311
|
+
```typescript
|
|
312
|
+
import { mapFalError, isFalErrorRetryable } from '@umituz/react-native-ai-fal-provider';
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Usage:**
|
|
316
|
+
Use these functions to handle errors consistently across your application.
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
### Input Builders
|
|
321
|
+
|
|
322
|
+
**Locations:**
|
|
323
|
+
- `src/infrastructure/utils/image-feature-builders.util.ts` - Image features
|
|
324
|
+
- `src/infrastructure/utils/video-feature-builders.util.ts` - Video features
|
|
325
|
+
- `src/infrastructure/utils/base-builders.util.ts` - Base builders
|
|
326
|
+
|
|
327
|
+
**Functions:**
|
|
328
|
+
- `buildUpscaleInput()` - Build upscale input
|
|
329
|
+
- `buildRemoveBackgroundInput()` - Build background removal input
|
|
330
|
+
- `buildFaceSwapInput()` - Build face swap input
|
|
331
|
+
- `buildVideoFromImageInput()` - Build video generation input
|
|
332
|
+
|
|
333
|
+
**Usage:**
|
|
334
|
+
Import builder functions and use them to construct API-compatible input objects.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
### Type Guards
|
|
339
|
+
|
|
340
|
+
**Location:** `src/infrastructure/utils/type-guards.util.ts`
|
|
341
|
+
|
|
342
|
+
**Functions:**
|
|
343
|
+
- `isValidBase64Image()` - Validate base64 image data
|
|
344
|
+
- `isValidApiKey()` - Validate API key format
|
|
345
|
+
- `isValidPrompt()` - Validate prompt text
|
|
346
|
+
- `isFalModelType()` - Check FAL model type
|
|
347
|
+
|
|
348
|
+
**Import:**
|
|
349
|
+
```typescript
|
|
350
|
+
import {
|
|
351
|
+
isValidBase64Image,
|
|
352
|
+
isValidApiKey,
|
|
353
|
+
isFalModelType
|
|
354
|
+
} from '@umituz/react-native-ai-fal-provider';
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Usage:**
|
|
358
|
+
Use these guards to validate inputs before making API calls.
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
### Helper Functions
|
|
363
|
+
|
|
364
|
+
**Location:** `src/infrastructure/utils/helpers.util.ts`
|
|
365
|
+
|
|
366
|
+
**Functions:**
|
|
367
|
+
- `formatImageDataUri()` - Format image data URI
|
|
368
|
+
- `extractBase64()` - Extract base64 from data URI
|
|
369
|
+
- `formatCreditCost()` - Format credit cost for display
|
|
370
|
+
- `truncatePrompt()` - Truncate prompt to max length
|
|
371
|
+
- `sanitizePrompt()` - Sanitize prompt text
|
|
372
|
+
|
|
373
|
+
**Import:**
|
|
374
|
+
```typescript
|
|
375
|
+
import {
|
|
376
|
+
formatImageDataUri,
|
|
377
|
+
formatCreditCost,
|
|
378
|
+
truncatePrompt
|
|
379
|
+
} from '@umituz/react-native-ai-fal-provider';
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Usage:**
|
|
383
|
+
Use these helpers for common data formatting operations.
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
### Job Management
|
|
388
|
+
|
|
389
|
+
**Location:** `src/infrastructure/utils/job-metadata/index.ts`
|
|
390
|
+
|
|
391
|
+
**Functions:**
|
|
392
|
+
- `createJobMetadata()` - Create job tracking metadata
|
|
393
|
+
- `updateJobMetadata()` - Update job metadata
|
|
394
|
+
- `isJobCompleted()` - Check if job completed
|
|
395
|
+
- `getJobDuration()` - Get job duration
|
|
396
|
+
- `serializeJobMetadata()` - Serialize for storage
|
|
397
|
+
- `deserializeJobMetadata()` - Deserialize from storage
|
|
398
|
+
|
|
399
|
+
**Import:**
|
|
400
|
+
```typescript
|
|
401
|
+
import {
|
|
402
|
+
createJobMetadata,
|
|
403
|
+
updateJobMetadata,
|
|
404
|
+
saveJobMetadata,
|
|
405
|
+
loadJobMetadata
|
|
406
|
+
} from '@umituz/react-native-ai-fal-provider';
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Usage:**
|
|
410
|
+
Use these functions to track and persist job state.
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Constants
|
|
415
|
+
|
|
416
|
+
### Default Models
|
|
417
|
+
|
|
418
|
+
**Location:** `src/domain/constants/default-models.constants.ts`
|
|
419
|
+
|
|
420
|
+
**Exports:**
|
|
421
|
+
- `DEFAULT_TEXT_TO_IMAGE_MODELS` - Text-to-image model list
|
|
422
|
+
- `DEFAULT_TEXT_TO_VIDEO_MODELS` - Text-to-video model list
|
|
423
|
+
- `DEFAULT_IMAGE_TO_VIDEO_MODELS` - Image-to-video model list
|
|
424
|
+
- `DEFAULT_TEXT_TO_VOICE_MODELS` - Text-to-voice model list
|
|
425
|
+
|
|
426
|
+
**Functions:**
|
|
427
|
+
- `getAllDefaultModels()` - Get all models
|
|
428
|
+
- `getDefaultModelsByType()` - Get models by type
|
|
429
|
+
- `getDefaultModel()` - Get default model for type
|
|
430
|
+
- `findModelById()` - Find model by ID
|
|
431
|
+
|
|
432
|
+
**Import:**
|
|
433
|
+
```typescript
|
|
434
|
+
import {
|
|
435
|
+
DEFAULT_TEXT_TO_IMAGE_MODELS,
|
|
436
|
+
getDefaultModel
|
|
437
|
+
} from '@umituz/react-native-ai-fal-provider';
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
### Feature Models
|
|
443
|
+
|
|
444
|
+
**Location:** `src/domain/constants/feature-models.constants.ts`
|
|
445
|
+
|
|
446
|
+
**Exports:**
|
|
447
|
+
- `FAL_IMAGE_FEATURE_MODELS` - Image feature model mappings
|
|
448
|
+
- `FAL_VIDEO_FEATURE_MODELS` - Video feature model mappings
|
|
449
|
+
|
|
450
|
+
**Functions:**
|
|
451
|
+
- `getAllFeatureModels()` - Get all feature models
|
|
452
|
+
|
|
453
|
+
**Usage:**
|
|
454
|
+
Use these constants to find model IDs for specific features.
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
### Provider Constants
|
|
459
|
+
|
|
460
|
+
**Location:** `src/infrastructure/services/fal-provider.constants.ts`
|
|
461
|
+
|
|
462
|
+
**Constants:**
|
|
463
|
+
- `DEFAULT_FAL_CONFIG` - Default provider configuration
|
|
464
|
+
- `FAL_CAPABILITIES` - Provider capabilities
|
|
465
|
+
|
|
466
|
+
**Usage:**
|
|
467
|
+
Reference these constants for configuration options and supported features.
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Services
|
|
472
|
+
|
|
473
|
+
### FalProvider Service
|
|
474
|
+
|
|
475
|
+
**Location:** `src/infrastructure/services/fal-provider.ts`
|
|
476
|
+
|
|
477
|
+
**Purpose:** Main service class implementing IAIProvider interface
|
|
478
|
+
|
|
479
|
+
**Import:**
|
|
480
|
+
```typescript
|
|
481
|
+
import { falProvider } from '@umituz/react-native-ai-fal-provider';
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
**Singleton:** Use the exported `falProvider` instance
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
### FalModelsService
|
|
489
|
+
|
|
490
|
+
**Location:** `src/infrastructure/services/fal-models.service.ts`
|
|
491
|
+
|
|
492
|
+
**Purpose:** Model management service
|
|
493
|
+
|
|
494
|
+
**Import:**
|
|
495
|
+
```typescript
|
|
496
|
+
import { falModelsService } from '@umituz/react-native-ai-fal-provider';
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
**Usage:**
|
|
500
|
+
Use this service for advanced model management operations.
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
## Validators
|
|
505
|
+
|
|
506
|
+
### NSFW Content Validator
|
|
507
|
+
|
|
508
|
+
**Location:** `src/infrastructure/validators/nsfw-validator.ts`
|
|
509
|
+
|
|
510
|
+
**Function:** `validateNSFWContent()`
|
|
511
|
+
|
|
512
|
+
**Import:**
|
|
513
|
+
```typescript
|
|
514
|
+
import { validateNSFWContent } from '@umituz/react-native-ai-fal-provider';
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
**Purpose:** Validate AI-generated content for inappropriate material
|
|
518
|
+
|
|
519
|
+
**Usage:**
|
|
520
|
+
Call this function on generation results to ensure content safety.
|
|
521
|
+
|
|
522
|
+
**Throws:** `NSFWContentError` if NSFW content detected
|
|
523
|
+
|
|
524
|
+
**Related:**
|
|
525
|
+
- Error class: `src/infrastructure/services/nsfw-content-error.ts`
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## Documentation Index
|
|
530
|
+
|
|
531
|
+
### Models
|
|
532
|
+
- [Text-to-Image](src/domain/constants/models/text-to-image.README.md)
|
|
533
|
+
- [Text-to-Video](src/domain/constants/models/text-to-video.README.md)
|
|
534
|
+
- [Image-to-Video](src/domain/constants/models/image-to-video.README.md)
|
|
535
|
+
- [Text-to-Voice](src/domain/constants/models/text-to-voice.README.md)
|
|
536
|
+
- [Text-to-Text](src/domain/constants/models/text-to-text.README.md)
|
|
537
|
+
|
|
538
|
+
### Features
|
|
539
|
+
- [Image Features](src/infrastructure/builders/image-feature-builder.README.md)
|
|
540
|
+
- [Video Features](src/infrastructure/builders/video-feature-builder.README.md)
|
|
541
|
+
|
|
542
|
+
### Core Services
|
|
543
|
+
- [FalProvider](src/infrastructure/services/fal-provider.README.md)
|
|
544
|
+
- [Model Management](src/infrastructure/services/fal-models-service.README.md)
|
|
545
|
+
|
|
546
|
+
### Error Handling
|
|
547
|
+
- [Error Mapper](src/infrastructure/utils/error-mapper.README.md)
|
|
548
|
+
- [Error Categorizer](src/infrastructure/utils/error-categorizer.README.md)
|
|
549
|
+
- [NSFW Content Error](src/infrastructure/services/nsfw-content-error.README.md)
|
|
550
|
+
|
|
551
|
+
### Utilities
|
|
552
|
+
- [Type Guards](src/infrastructure/utils/type-guards.util.README.md)
|
|
553
|
+
- [Helper Functions](src/infrastructure/utils/helpers.util.README.md)
|
|
554
|
+
- [Job Metadata](src/infrastructure/utils/job-metadata/index.README.md)
|
|
555
|
+
|
|
556
|
+
### React Integration
|
|
557
|
+
- [React Hooks](src/presentation/hooks/index.README.md)
|
|
558
|
+
- [useFalGeneration Hook](src/presentation/hooks/use-fal-generation.README.md)
|
|
559
|
+
- [useModels Hook](src/presentation/hooks/use-models.README.md)
|
|
560
|
+
|
|
561
|
+
### Types
|
|
562
|
+
- [FAL Types](src/domain/entities/fal.types.README.md)
|
|
563
|
+
- [Error Types](src/domain/entities/error.types.README.md)
|
|
564
|
+
- [Input Builders Types](src/domain/types/input-builders.types.README.md)
|
|
565
|
+
- [Model Selection Types](src/domain/types/model-selection.types.README.md)
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
## For AI Agents
|
|
570
|
+
|
|
571
|
+
### When Working with This Codebase
|
|
572
|
+
|
|
573
|
+
**DO:**
|
|
574
|
+
- Read the actual source files before writing code
|
|
575
|
+
- Follow existing patterns in the codebase
|
|
576
|
+
- Use types from `src/domain/types/`
|
|
577
|
+
- Respect the architecture (domain/infrastructure/presentation)
|
|
578
|
+
- Maintain type safety
|
|
579
|
+
- Update documentation when adding features
|
|
580
|
+
|
|
581
|
+
**DON'T:**
|
|
582
|
+
- Write code without reading existing implementations
|
|
583
|
+
- Make assumptions about code structure
|
|
584
|
+
- Skip type definitions
|
|
585
|
+
- Ignore documentation paths
|
|
586
|
+
- Create parallel implementations
|
|
587
|
+
|
|
588
|
+
### File Finding
|
|
589
|
+
|
|
590
|
+
When documentation mentions a file path:
|
|
591
|
+
1. Navigate to that exact path
|
|
592
|
+
2. Read the file completely
|
|
593
|
+
3. Understand exports and types
|
|
594
|
+
4. Follow the implementation pattern
|
|
595
|
+
5. Apply to your use case
|
|
596
|
+
|
|
597
|
+
### Implementation Patterns
|
|
598
|
+
|
|
599
|
+
**For New Features:**
|
|
600
|
+
1. Define types in `src/domain/types/`
|
|
601
|
+
2. Implement in appropriate layer (domain/infrastructure/presentation)
|
|
602
|
+
3. Export from `src/index.ts`
|
|
603
|
+
4. Update documentation
|
|
604
|
+
5. Follow existing patterns
|
|
605
|
+
|
|
606
|
+
**For Modifications:**
|
|
607
|
+
1. Read the complete file first
|
|
608
|
+
2. Understand dependencies
|
|
609
|
+
3. Make changes while maintaining patterns
|
|
610
|
+
4. Update type definitions if needed
|
|
611
|
+
5. Test thoroughly
|
|
612
|
+
|
|
613
|
+
---
|
|
614
|
+
|
|
615
|
+
## Support
|
|
616
|
+
|
|
617
|
+
**Documentation:** See individual README files in each directory
|
|
101
618
|
|
|
102
|
-
|
|
103
|
-
- `isFalErrorRetryable(error)` - Check if error is retryable
|
|
104
|
-
- `categorizeFalError(error)` - Get error category
|
|
619
|
+
**Issues:** Report issues at https://github.com/umituz/react-native-ai-fal-provider/issues
|
|
105
620
|
|
|
106
|
-
|
|
621
|
+
**Author:** Umit UZ <umit@umituz.com>
|
|
107
622
|
|
|
108
|
-
MIT
|
|
623
|
+
**License:** MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-fal-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.70",
|
|
4
4
|
"description": "FAL AI provider for React Native - implements IAIProvider interface for unified AI generation",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|