@umituz/react-native-ai-fal-provider 1.2.0 → 2.0.0
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 -3
- package/src/domain/constants/feature-models.constants.ts +1 -1
- package/src/domain/types/index.ts +24 -0
- package/src/domain/types/provider.types.ts +194 -0
- package/src/infrastructure/builders/image-feature-builder.ts +1 -1
- package/src/infrastructure/builders/video-feature-builder.ts +1 -1
- package/src/infrastructure/services/fal-feature-models.ts +1 -1
- package/src/infrastructure/services/fal-provider-subscription.ts +1 -1
- package/src/infrastructure/services/fal-provider.constants.ts +1 -1
- package/src/infrastructure/services/fal-provider.ts +1 -1
- package/src/infrastructure/services/fal-queue-operations.ts +1 -1
- package/src/infrastructure/services/fal-status-mapper.ts +1 -1
- package/src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.ts +1 -1
- package/src/infrastructure/utils/job-metadata/job-metadata.types.ts +1 -1
- package/src/init/createAiProviderInitModule.ts +1 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-fal-provider",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@fal-ai/client": ">=0.6.0",
|
|
33
|
-
"@umituz/react-native-ai-generation-content": "*",
|
|
34
33
|
"react": ">=18.2.0",
|
|
35
34
|
"react-native": ">=0.74.0"
|
|
36
35
|
},
|
|
@@ -52,7 +51,6 @@
|
|
|
52
51
|
"@types/react": "~18.3.12",
|
|
53
52
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
54
53
|
"@typescript-eslint/parser": "^7.0.0",
|
|
55
|
-
"@umituz/react-native-ai-generation-content": "*",
|
|
56
54
|
"@umituz/react-native-auth": "*",
|
|
57
55
|
"@umituz/react-native-design-system": "*",
|
|
58
56
|
"@umituz/react-native-firebase": "*",
|
|
@@ -21,3 +21,27 @@ export type {
|
|
|
21
21
|
TextToVideoOptions,
|
|
22
22
|
FaceSwapOptions,
|
|
23
23
|
} from "./input-builders.types";
|
|
24
|
+
|
|
25
|
+
// Provider Types (local definitions)
|
|
26
|
+
export type {
|
|
27
|
+
ImageFeatureType,
|
|
28
|
+
VideoFeatureType,
|
|
29
|
+
AIProviderConfig,
|
|
30
|
+
AIJobStatusType,
|
|
31
|
+
AILogEntry,
|
|
32
|
+
JobSubmission,
|
|
33
|
+
JobStatus,
|
|
34
|
+
ProviderProgressInfo,
|
|
35
|
+
SubscribeOptions,
|
|
36
|
+
RunOptions,
|
|
37
|
+
ProviderCapabilities,
|
|
38
|
+
ImageFeatureInputData,
|
|
39
|
+
VideoFeatureInputData,
|
|
40
|
+
IAIProviderLifecycle,
|
|
41
|
+
IAIProviderCapabilities,
|
|
42
|
+
IAIProviderJobManager,
|
|
43
|
+
IAIProviderExecutor,
|
|
44
|
+
IAIProviderImageFeatures,
|
|
45
|
+
IAIProviderVideoFeatures,
|
|
46
|
+
IAIProvider,
|
|
47
|
+
} from "./provider.types";
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Types
|
|
3
|
+
* Local type definitions for FAL Provider
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// =============================================================================
|
|
7
|
+
// Feature Types
|
|
8
|
+
// =============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Feature types for image processing (output: image)
|
|
12
|
+
*/
|
|
13
|
+
export type ImageFeatureType =
|
|
14
|
+
| "upscale"
|
|
15
|
+
| "photo-restore"
|
|
16
|
+
| "face-swap"
|
|
17
|
+
| "anime-selfie"
|
|
18
|
+
| "remove-background"
|
|
19
|
+
| "remove-object"
|
|
20
|
+
| "hd-touch-up"
|
|
21
|
+
| "replace-background";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Feature types for video generation (output: video)
|
|
25
|
+
*/
|
|
26
|
+
export type VideoFeatureType = "image-to-video" | "text-to-video";
|
|
27
|
+
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// Provider Configuration
|
|
30
|
+
// =============================================================================
|
|
31
|
+
|
|
32
|
+
export interface AIProviderConfig {
|
|
33
|
+
apiKey: string;
|
|
34
|
+
maxRetries?: number;
|
|
35
|
+
baseDelay?: number;
|
|
36
|
+
maxDelay?: number;
|
|
37
|
+
defaultTimeoutMs?: number;
|
|
38
|
+
textModel?: string;
|
|
39
|
+
textToImageModel?: string;
|
|
40
|
+
imageEditModel?: string;
|
|
41
|
+
videoGenerationModel?: string;
|
|
42
|
+
videoFeatureModels?: Partial<Record<VideoFeatureType, string>>;
|
|
43
|
+
imageFeatureModels?: Partial<Record<ImageFeatureType, string>>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// Status Types
|
|
48
|
+
// =============================================================================
|
|
49
|
+
|
|
50
|
+
export type AIJobStatusType =
|
|
51
|
+
| "IN_QUEUE"
|
|
52
|
+
| "IN_PROGRESS"
|
|
53
|
+
| "COMPLETED"
|
|
54
|
+
| "FAILED";
|
|
55
|
+
|
|
56
|
+
export interface AILogEntry {
|
|
57
|
+
message: string;
|
|
58
|
+
level: "info" | "warn" | "error";
|
|
59
|
+
timestamp?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface JobSubmission {
|
|
63
|
+
requestId: string;
|
|
64
|
+
statusUrl?: string;
|
|
65
|
+
responseUrl?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface JobStatus {
|
|
69
|
+
status: AIJobStatusType;
|
|
70
|
+
logs?: AILogEntry[];
|
|
71
|
+
queuePosition?: number;
|
|
72
|
+
eta?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// =============================================================================
|
|
76
|
+
// Progress & Options
|
|
77
|
+
// =============================================================================
|
|
78
|
+
|
|
79
|
+
export interface ProviderProgressInfo {
|
|
80
|
+
progress: number;
|
|
81
|
+
status?: AIJobStatusType;
|
|
82
|
+
message?: string;
|
|
83
|
+
estimatedTimeRemaining?: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface SubscribeOptions<T = unknown> {
|
|
87
|
+
timeoutMs?: number;
|
|
88
|
+
onQueueUpdate?: (status: JobStatus) => void;
|
|
89
|
+
onProgress?: (progress: ProviderProgressInfo) => void;
|
|
90
|
+
onResult?: (result: T) => void;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface RunOptions {
|
|
94
|
+
onProgress?: (progress: ProviderProgressInfo) => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// =============================================================================
|
|
98
|
+
// Capabilities
|
|
99
|
+
// =============================================================================
|
|
100
|
+
|
|
101
|
+
export interface ProviderCapabilities {
|
|
102
|
+
imageFeatures: readonly ImageFeatureType[];
|
|
103
|
+
videoFeatures: readonly VideoFeatureType[];
|
|
104
|
+
textToImage: boolean;
|
|
105
|
+
textToVideo: boolean;
|
|
106
|
+
imageToVideo: boolean;
|
|
107
|
+
textToVoice: boolean;
|
|
108
|
+
textToText: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// =============================================================================
|
|
112
|
+
// Feature Input Data
|
|
113
|
+
// =============================================================================
|
|
114
|
+
|
|
115
|
+
export interface ImageFeatureInputData {
|
|
116
|
+
imageBase64: string;
|
|
117
|
+
targetImageBase64?: string;
|
|
118
|
+
prompt?: string;
|
|
119
|
+
options?: Record<string, unknown>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface VideoFeatureInputData {
|
|
123
|
+
sourceImageBase64?: string;
|
|
124
|
+
targetImageBase64?: string;
|
|
125
|
+
prompt?: string;
|
|
126
|
+
options?: Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// =============================================================================
|
|
130
|
+
// Provider Interface
|
|
131
|
+
// =============================================================================
|
|
132
|
+
|
|
133
|
+
export interface IAIProviderLifecycle {
|
|
134
|
+
initialize(config: AIProviderConfig): void;
|
|
135
|
+
isInitialized(): boolean;
|
|
136
|
+
reset(): void;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface IAIProviderCapabilities {
|
|
140
|
+
getCapabilities(): ProviderCapabilities;
|
|
141
|
+
isFeatureSupported(feature: ImageFeatureType | VideoFeatureType): boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface IAIProviderJobManager {
|
|
145
|
+
submitJob(
|
|
146
|
+
model: string,
|
|
147
|
+
input: Record<string, unknown>,
|
|
148
|
+
): Promise<JobSubmission>;
|
|
149
|
+
getJobStatus(model: string, requestId: string): Promise<JobStatus>;
|
|
150
|
+
getJobResult<T = unknown>(model: string, requestId: string): Promise<T>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface IAIProviderExecutor {
|
|
154
|
+
subscribe<T = unknown>(
|
|
155
|
+
model: string,
|
|
156
|
+
input: Record<string, unknown>,
|
|
157
|
+
options?: SubscribeOptions<T>,
|
|
158
|
+
): Promise<T>;
|
|
159
|
+
run<T = unknown>(
|
|
160
|
+
model: string,
|
|
161
|
+
input: Record<string, unknown>,
|
|
162
|
+
options?: RunOptions,
|
|
163
|
+
): Promise<T>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface IAIProviderImageFeatures {
|
|
167
|
+
getImageFeatureModel(feature: ImageFeatureType): string;
|
|
168
|
+
buildImageFeatureInput(
|
|
169
|
+
feature: ImageFeatureType,
|
|
170
|
+
data: ImageFeatureInputData,
|
|
171
|
+
): Record<string, unknown>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface IAIProviderVideoFeatures {
|
|
175
|
+
getVideoFeatureModel(feature: VideoFeatureType): string;
|
|
176
|
+
buildVideoFeatureInput(
|
|
177
|
+
feature: VideoFeatureType,
|
|
178
|
+
data: VideoFeatureInputData,
|
|
179
|
+
): Record<string, unknown>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Main AI Provider Interface
|
|
184
|
+
*/
|
|
185
|
+
export interface IAIProvider
|
|
186
|
+
extends IAIProviderLifecycle,
|
|
187
|
+
IAIProviderCapabilities,
|
|
188
|
+
IAIProviderJobManager,
|
|
189
|
+
IAIProviderExecutor,
|
|
190
|
+
IAIProviderImageFeatures,
|
|
191
|
+
IAIProviderVideoFeatures {
|
|
192
|
+
readonly providerId: string;
|
|
193
|
+
readonly providerName: string;
|
|
194
|
+
}
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
VideoFeatureType,
|
|
8
8
|
ImageFeatureInputData,
|
|
9
9
|
VideoFeatureInputData,
|
|
10
|
-
} from "
|
|
10
|
+
} from "../../domain/types";
|
|
11
11
|
import {
|
|
12
12
|
buildImageFeatureInput as buildImageFeatureInputImpl,
|
|
13
13
|
buildVideoFeatureInput as buildVideoFeatureInputImpl,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { fal } from "@fal-ai/client";
|
|
7
|
-
import type { SubscribeOptions, RunOptions } from "
|
|
7
|
+
import type { SubscribeOptions, RunOptions } from "../../domain/types";
|
|
8
8
|
import type { FalQueueStatus } from "../../domain/entities/fal.types";
|
|
9
9
|
import { DEFAULT_FAL_CONFIG } from "./fal-provider.constants";
|
|
10
10
|
import { mapFalStatusToJobStatus } from "./fal-status-mapper";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Configuration and capability definitions for FAL AI provider
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ProviderCapabilities } from "
|
|
6
|
+
import type { ProviderCapabilities } from "../../domain/types";
|
|
7
7
|
|
|
8
8
|
export const DEFAULT_FAL_CONFIG = {
|
|
9
9
|
maxRetries: 3,
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
IAIProvider, AIProviderConfig, JobSubmission, JobStatus, SubscribeOptions,
|
|
9
9
|
RunOptions, ImageFeatureType, VideoFeatureType, ImageFeatureInputData,
|
|
10
10
|
VideoFeatureInputData, ProviderCapabilities,
|
|
11
|
-
} from "
|
|
11
|
+
} from "../../domain/types";
|
|
12
12
|
import type { CostTrackerConfig } from "../../domain/entities/cost-tracking.types";
|
|
13
13
|
import { DEFAULT_FAL_CONFIG, FAL_CAPABILITIES } from "./fal-provider.constants";
|
|
14
14
|
import { handleFalSubscription, handleFalRun } from "./fal-provider-subscription";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { fal } from "@fal-ai/client";
|
|
6
|
-
import type { JobSubmission, JobStatus } from "
|
|
6
|
+
import type { JobSubmission, JobStatus } from "../../domain/types";
|
|
7
7
|
import type { FalQueueStatus } from "../../domain/entities/fal.types";
|
|
8
8
|
import { mapFalStatusToJobStatus } from "./fal-status-mapper";
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Maps FAL queue status to standardized job status
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { JobStatus, AIJobStatusType } from "
|
|
6
|
+
import type { JobStatus, AIJobStatusType } from "../../domain/types";
|
|
7
7
|
import type { FalQueueStatus, FalLogEntry } from "../../domain/entities/fal.types";
|
|
8
8
|
|
|
9
9
|
const STATUS_MAP = {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { falProvider } from '../infrastructure/services';
|
|
7
|
-
import { providerRegistry } from '@umituz/react-native-ai-generation-content';
|
|
8
7
|
|
|
9
8
|
declare const __DEV__: boolean;
|
|
10
9
|
|
|
@@ -37,12 +36,6 @@ export interface AiProviderInitModuleConfig {
|
|
|
37
36
|
*/
|
|
38
37
|
imageFeatureModels?: Record<string, string>;
|
|
39
38
|
|
|
40
|
-
/**
|
|
41
|
-
* Provider ID to use
|
|
42
|
-
* @default "fal"
|
|
43
|
-
*/
|
|
44
|
-
providerId?: string;
|
|
45
|
-
|
|
46
39
|
/**
|
|
47
40
|
* Whether this module is critical for app startup
|
|
48
41
|
* @default false
|
|
@@ -86,7 +79,6 @@ export function createAiProviderInitModule(
|
|
|
86
79
|
getApiKey,
|
|
87
80
|
videoFeatureModels,
|
|
88
81
|
imageFeatureModels,
|
|
89
|
-
providerId = 'fal',
|
|
90
82
|
critical = false,
|
|
91
83
|
dependsOn = ['firebase'],
|
|
92
84
|
} = config;
|
|
@@ -113,12 +105,8 @@ export function createAiProviderInitModule(
|
|
|
113
105
|
imageFeatureModels,
|
|
114
106
|
});
|
|
115
107
|
|
|
116
|
-
// Register and set as active
|
|
117
|
-
providerRegistry.register(falProvider);
|
|
118
|
-
providerRegistry.setActiveProvider(providerId);
|
|
119
|
-
|
|
120
108
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
121
|
-
console.log('[createAiProviderInitModule]
|
|
109
|
+
console.log('[createAiProviderInitModule] FAL provider initialized');
|
|
122
110
|
}
|
|
123
111
|
|
|
124
112
|
return Promise.resolve(true);
|