@umituz/react-native-ai-fal-provider 3.2.34 → 3.2.35

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 (3) hide show
  1. package/package.json +1 -1
  2. package/LICENSE +0 -21
  3. package/README.md +0 -623
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-fal-provider",
3
- "version": "3.2.34",
3
+ "version": "3.2.35",
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",
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Umit UZ
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,623 +0,0 @@
1
- # @umituz/react-native-ai-fal-provider
2
-
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
- ---
29
-
30
- ## Installation
31
-
32
- ```bash
33
- npm install @umituz/react-native-ai-fal-provider @fal-ai/client
34
- ```
35
-
36
- ---
37
-
38
- ## Quick Start
39
-
40
- ### 1. Initialize Provider
41
-
42
- **Location:** `src/infrastructure/services/fal-provider.ts`
43
-
44
- **Import:**
45
- ```typescript
46
- import { falProvider } from '@umituz/react-native-ai-fal-provider';
47
- ```
48
-
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
- ---
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:**
63
- ```typescript
64
- import { useFalGeneration, useModels } from '@umituz/react-native-ai-fal-provider';
65
- ```
66
-
67
- **Usage:**
68
- - Use `useFalGeneration` hook for managing AI generation operations
69
- - Use `useModels` hook for model selection and management
70
-
71
- **Implementation:** See hook files for complete API and options.
72
-
73
- ---
74
-
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
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
- - Image-to-Video - Convert images to video
144
- - Text-to-Video - Generate video from text prompts
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:**
163
- ```typescript
164
- import { falProvider } from '@umituz/react-native-ai-fal-provider';
165
- ```
166
-
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
176
-
177
- **Implementation:** See `src/infrastructure/services/fal-provider.ts` for complete API
178
-
179
- **Related:**
180
- - Provider constants: `src/infrastructure/services/fal-provider.constants.ts`
181
- - Subscription handler: `src/infrastructure/services/fal-provider-subscription.ts`
182
-
183
- ---
184
-
185
- ### useFalGeneration Hook
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:**
197
- - `data` - Generation result
198
- - `error` - Error information
199
- - `isLoading` - Loading state
200
- - `isRetryable` - Whether error can be retried
201
- - `generate()` - Start generation function
202
- - `retry()` - Retry failed generation
203
- - `cancel()` - Cancel current generation
204
- - `reset()` - Reset state
205
-
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
618
-
619
- **Issues:** Report issues at https://github.com/umituz/react-native-ai-fal-provider/issues
620
-
621
- **Author:** Umit UZ <umit@umituz.com>
622
-
623
- **License:** MIT