@umituz/react-native-ai-generation-content 1.17.228 → 1.17.230
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/LICENSE +21 -0
- package/README.md +346 -0
- package/package.json +1 -3
- package/src/domain/README.md +503 -0
- package/src/domains/content-moderation/README.md +363 -0
- package/src/domains/creations/README.md +394 -0
- package/src/domains/face-detection/README.md +395 -0
- package/src/domains/prompts/README.md +387 -0
- package/src/features/ai-hug/README.md +276 -0
- package/src/features/ai-kiss/README.md +276 -0
- package/src/features/anime-selfie/README.md +325 -0
- package/src/features/audio-generation/README.md +370 -0
- package/src/features/colorization/README.md +289 -0
- package/src/features/couple-future/README.md +270 -0
- package/src/features/face-swap/README.md +234 -0
- package/src/features/future-prediction/README.md +281 -0
- package/src/features/hd-touch-up/README.md +309 -0
- package/src/features/image-captioning/README.md +361 -0
- package/src/features/image-to-image/README.md +418 -0
- package/src/features/image-to-video/README.md +369 -0
- package/src/features/inpainting/README.md +302 -0
- package/src/features/meme-generator/README.md +327 -0
- package/src/features/photo-restoration/README.md +286 -0
- package/src/features/remove-background/README.md +292 -0
- package/src/features/remove-object/README.md +352 -0
- package/src/features/replace-background/README.md +288 -0
- package/src/features/script-generator/README.md +362 -0
- package/src/features/shared/README.md +280 -0
- package/src/features/sketch-to-image/README.md +296 -0
- package/src/features/style-transfer/README.md +301 -0
- package/src/features/text-to-image/README.md +228 -0
- package/src/features/text-to-video/README.md +245 -0
- package/src/features/text-to-voice/README.md +335 -0
- package/src/features/upscaling/README.md +247 -0
- package/src/infrastructure/config/README.md +310 -0
- package/src/infrastructure/middleware/README.md +378 -0
- package/src/infrastructure/orchestration/README.md +362 -0
- package/src/infrastructure/services/README.md +382 -0
- package/src/infrastructure/utils/README.md +523 -0
- package/src/infrastructure/wrappers/README.md +336 -0
- package/src/presentation/components/README.md +535 -0
- package/src/presentation/hooks/README.md +380 -0
- package/src/presentation/hooks/base/use-dual-image-feature.ts +4 -4
- package/src/presentation/hooks/base/use-image-with-prompt-feature.ts +4 -4
- package/src/presentation/hooks/base/utils/feature-state.factory.ts +1 -1
- package/src/presentation/layouts/README.md +374 -0
- package/src/presentation/layouts/types/layout-props.ts +1 -1
- package/src/presentation/screens/README.md +430 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
# Domain Layer
|
|
2
|
+
|
|
3
|
+
Core business logic and type definitions.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The domain layer contains the core business logic, types, and interfaces that define the AI generation system. It is independent of any external dependencies and provides the foundation for the entire library.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Core type definitions
|
|
12
|
+
- Domain entities
|
|
13
|
+
- Business rules
|
|
14
|
+
- Repository interfaces
|
|
15
|
+
- Service interfaces
|
|
16
|
+
|
|
17
|
+
## Core Types
|
|
18
|
+
|
|
19
|
+
### Generation Types
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
// Generation status
|
|
23
|
+
enum GenerationStatus {
|
|
24
|
+
IDLE = 'idle',
|
|
25
|
+
PROCESSING = 'processing',
|
|
26
|
+
COMPLETED = 'completed',
|
|
27
|
+
FAILED = 'failed',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Generation result
|
|
31
|
+
interface GenerationResult {
|
|
32
|
+
success: boolean;
|
|
33
|
+
output?: {
|
|
34
|
+
imageUrl?: string;
|
|
35
|
+
imageUrls?: string[];
|
|
36
|
+
videoUrl?: string;
|
|
37
|
+
audioUrl?: string;
|
|
38
|
+
thumbnailUrl?: string;
|
|
39
|
+
};
|
|
40
|
+
metadata?: GenerationMetadata;
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Generation request
|
|
45
|
+
interface GenerationRequest {
|
|
46
|
+
featureType: string;
|
|
47
|
+
inputData: any;
|
|
48
|
+
userId: string;
|
|
49
|
+
providerId?: string;
|
|
50
|
+
options?: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Generation metadata
|
|
54
|
+
interface GenerationMetadata {
|
|
55
|
+
prompt?: string;
|
|
56
|
+
model?: string;
|
|
57
|
+
timestamp: string;
|
|
58
|
+
duration?: number;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Job Types
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
// Job status
|
|
67
|
+
enum JobStatus {
|
|
68
|
+
PENDING = 'pending',
|
|
69
|
+
PROCESSING = 'processing',
|
|
70
|
+
COMPLETED = 'completed',
|
|
71
|
+
FAILED = 'failed',
|
|
72
|
+
CANCELLED = 'cancelled',
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Job submission
|
|
76
|
+
interface JobSubmission {
|
|
77
|
+
jobId: string;
|
|
78
|
+
status: JobStatus;
|
|
79
|
+
result?: any;
|
|
80
|
+
error?: Error;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Background job
|
|
84
|
+
interface BackgroundJob {
|
|
85
|
+
id: string;
|
|
86
|
+
featureType: string;
|
|
87
|
+
inputData: any;
|
|
88
|
+
userId: string;
|
|
89
|
+
status: JobStatus;
|
|
90
|
+
progress: number;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
updatedAt: string;
|
|
93
|
+
result?: any;
|
|
94
|
+
error?: Error;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Error Types
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
// Error types
|
|
102
|
+
enum AIErrorType {
|
|
103
|
+
INSUFFICIENT_CREDITS = 'INSUFFICIENT_CREDITS',
|
|
104
|
+
PROVIDER_ERROR = 'PROVIDER_ERROR',
|
|
105
|
+
NETWORK_ERROR = 'NETWORK_ERROR',
|
|
106
|
+
VALIDATION_ERROR = 'VALIDATION_ERROR',
|
|
107
|
+
TIMEOUT_ERROR = 'TIMEOUT_ERROR',
|
|
108
|
+
UNKNOWN_ERROR = 'UNKNOWN_ERROR',
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Error info
|
|
112
|
+
interface AIErrorInfo {
|
|
113
|
+
type: AIErrorType;
|
|
114
|
+
message: string;
|
|
115
|
+
details?: any;
|
|
116
|
+
timestamp: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Error messages
|
|
120
|
+
interface AIErrorMessages {
|
|
121
|
+
[key: string]: string;
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Processing Modes
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
// Processing modes
|
|
129
|
+
type ImageProcessingMode =
|
|
130
|
+
| 'free'
|
|
131
|
+
| 'premium'
|
|
132
|
+
| 'prompt-required';
|
|
133
|
+
|
|
134
|
+
// Mode config
|
|
135
|
+
interface ModeConfig {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
description: string;
|
|
139
|
+
mode: ImageProcessingMode;
|
|
140
|
+
creditCost: number;
|
|
141
|
+
promptRequired?: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Mode catalog
|
|
145
|
+
interface ModeCatalog {
|
|
146
|
+
modes: ModeConfig[];
|
|
147
|
+
getMode(modeId: string): ModeConfig | undefined;
|
|
148
|
+
getFreeModes(): ModeConfig[];
|
|
149
|
+
getPremiumModes(): ModeConfig[];
|
|
150
|
+
getPromptRequiredModes(): ModeConfig[];
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Interfaces
|
|
155
|
+
|
|
156
|
+
### IAIProvider
|
|
157
|
+
|
|
158
|
+
AI provider interface:
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
interface IAIProvider {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
capabilities: ProviderCapabilities;
|
|
165
|
+
execute(request: GenerationRequest): Promise<GenerationResult>;
|
|
166
|
+
pollJob?(jobId: string): Promise<JobSubmission>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface ProviderCapabilities {
|
|
170
|
+
textToImage?: boolean;
|
|
171
|
+
textToVideo?: boolean;
|
|
172
|
+
textToVoice?: boolean;
|
|
173
|
+
imageToImage?: boolean;
|
|
174
|
+
faceSwap?: boolean;
|
|
175
|
+
// ... more capabilities
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### IAppServices
|
|
180
|
+
|
|
181
|
+
App services interface:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
interface IAppServices {
|
|
185
|
+
networkService?: INetworkService;
|
|
186
|
+
creditService?: ICreditService;
|
|
187
|
+
paywallService?: IPaywallService;
|
|
188
|
+
authService?: IAuthService;
|
|
189
|
+
analyticsService?: IAnalyticsService;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
interface INetworkService {
|
|
193
|
+
baseUrl: string;
|
|
194
|
+
apiKey?: string;
|
|
195
|
+
timeout?: number;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface ICreditService {
|
|
199
|
+
checkCredits(userId: string, cost: number): Promise<boolean>;
|
|
200
|
+
deductCredits(userId: string, cost: number): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface IPaywallService {
|
|
204
|
+
showPaywall(): Promise<boolean>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
interface IAuthService {
|
|
208
|
+
getCurrentUser(): Promise<User | null>;
|
|
209
|
+
getToken(): Promise<string | null>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
interface IAnalyticsService {
|
|
213
|
+
trackEvent(event: string, properties?: any): Promise<void>;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### IFeatureUtils
|
|
218
|
+
|
|
219
|
+
Feature utilities interface:
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
interface IFeatureUtils {
|
|
223
|
+
showVideoGenerationSuccess?(options: VideoAlertFunction): Promise<void>;
|
|
224
|
+
showContentModerationWarning?(options: AlertFunction): Promise<void>;
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Entities
|
|
229
|
+
|
|
230
|
+
### GenerationCapability
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
interface GenerationCapability {
|
|
234
|
+
featureType: string;
|
|
235
|
+
supported: boolean;
|
|
236
|
+
provider?: string;
|
|
237
|
+
creditCost: number;
|
|
238
|
+
processingTime?: number;
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### GenerationProgress
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
interface GenerationProgress {
|
|
246
|
+
percent: number;
|
|
247
|
+
stage: string;
|
|
248
|
+
message: string;
|
|
249
|
+
timestamp: string;
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### PollingConfig
|
|
254
|
+
|
|
255
|
+
```tsx
|
|
256
|
+
interface PollingConfig {
|
|
257
|
+
maxAttempts: number;
|
|
258
|
+
interval: number;
|
|
259
|
+
timeout: number;
|
|
260
|
+
backoffMultiplier: number;
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### MiddlewareContext
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
interface MiddlewareContext {
|
|
268
|
+
featureType: string;
|
|
269
|
+
inputData: any;
|
|
270
|
+
userId?: string;
|
|
271
|
+
options?: Record<string, any>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
interface MiddlewareResultContext extends MiddlewareContext {
|
|
275
|
+
result: GenerationResult;
|
|
276
|
+
duration: number;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface MiddlewareErrorContext extends MiddlewareContext {
|
|
280
|
+
error: Error;
|
|
281
|
+
errorType: AIErrorType;
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Constants
|
|
286
|
+
|
|
287
|
+
### Default Configurations
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
// Default polling config
|
|
291
|
+
const DEFAULT_POLLING_CONFIG: PollingConfig = {
|
|
292
|
+
maxAttempts: 30,
|
|
293
|
+
interval: 2000,
|
|
294
|
+
timeout: 60000,
|
|
295
|
+
backoffMultiplier: 1.5,
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// Default progress stages
|
|
299
|
+
const DEFAULT_PROGRESS_STAGES = {
|
|
300
|
+
textToImage: [
|
|
301
|
+
{ stage: 'initializing', weight: 10 },
|
|
302
|
+
{ stage: 'processing', weight: 70 },
|
|
303
|
+
{ stage: 'finalizing', weight: 20 },
|
|
304
|
+
],
|
|
305
|
+
// ... more features
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// Default queue config
|
|
309
|
+
const DEFAULT_QUEUE_CONFIG = {
|
|
310
|
+
concurrency: 3,
|
|
311
|
+
maxQueueSize: 100,
|
|
312
|
+
retryAttempts: 3,
|
|
313
|
+
};
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Processing Modes
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
// Default processing modes
|
|
320
|
+
const DEFAULT_PROCESSING_MODES: ModeConfig[] = [
|
|
321
|
+
{
|
|
322
|
+
id: 'free',
|
|
323
|
+
name: 'Free',
|
|
324
|
+
description: 'Free generation',
|
|
325
|
+
mode: 'free',
|
|
326
|
+
creditCost: 0,
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
id: 'premium',
|
|
330
|
+
name: 'Premium',
|
|
331
|
+
description: 'Premium quality',
|
|
332
|
+
mode: 'premium',
|
|
333
|
+
creditCost: 1,
|
|
334
|
+
},
|
|
335
|
+
// ... more modes
|
|
336
|
+
];
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Utility Functions
|
|
340
|
+
|
|
341
|
+
### getModeConfig
|
|
342
|
+
|
|
343
|
+
Get mode configuration:
|
|
344
|
+
|
|
345
|
+
```tsx
|
|
346
|
+
import { getModeConfig } from '@umituz/react-native-ai-generation-content';
|
|
347
|
+
|
|
348
|
+
const config = getModeConfig('premium');
|
|
349
|
+
console.log('Premium mode costs:', config.creditCost, 'credits');
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### getFreeModes
|
|
353
|
+
|
|
354
|
+
Get all free modes:
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { getFreeModes } from '@umituz/react-native-ai-generation-content';
|
|
358
|
+
|
|
359
|
+
const freeModes = getFreeModes();
|
|
360
|
+
console.log('Free modes:', freeModes);
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### getPremiumModes
|
|
364
|
+
|
|
365
|
+
Get all premium modes:
|
|
366
|
+
|
|
367
|
+
```tsx
|
|
368
|
+
import { getPremiumModes } from '@umituz/react-native-ai-generation-content';
|
|
369
|
+
|
|
370
|
+
const premiumModes = getPremiumModes();
|
|
371
|
+
console.log('Premium modes:', premiumModes);
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### getPromptRequiredModes
|
|
375
|
+
|
|
376
|
+
Get modes requiring prompts:
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
import { getPromptRequiredModes } from '@umituz/react-native-ai-generation-content';
|
|
380
|
+
|
|
381
|
+
const modes = getPromptRequiredModes();
|
|
382
|
+
console.log('Modes requiring prompts:', modes);
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Type Guards
|
|
386
|
+
|
|
387
|
+
### isJobComplete
|
|
388
|
+
|
|
389
|
+
```tsx
|
|
390
|
+
import { isJobComplete } from '@umituz/react-native-ai-generation-content';
|
|
391
|
+
|
|
392
|
+
if (isJobComplete(jobStatus)) {
|
|
393
|
+
console.log('Job is complete');
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### isJobProcessing
|
|
398
|
+
|
|
399
|
+
```tsx
|
|
400
|
+
import { isJobProcessing } from '@umituz/react-native-ai-generation-content';
|
|
401
|
+
|
|
402
|
+
if (isJobProcessing(jobStatus)) {
|
|
403
|
+
console.log('Job is processing');
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### isJobFailed
|
|
408
|
+
|
|
409
|
+
```tsx
|
|
410
|
+
import { isJobFailed } from '@umituz/react-native-ai-generation-content';
|
|
411
|
+
|
|
412
|
+
if (isJobFailed(jobStatus)) {
|
|
413
|
+
console.log('Job failed');
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## Type Exports
|
|
418
|
+
|
|
419
|
+
The domain layer exports all core types:
|
|
420
|
+
|
|
421
|
+
```tsx
|
|
422
|
+
// Core interfaces
|
|
423
|
+
export type {
|
|
424
|
+
IAIProvider,
|
|
425
|
+
IAppServices,
|
|
426
|
+
INetworkService,
|
|
427
|
+
ICreditService,
|
|
428
|
+
IPaywallService,
|
|
429
|
+
IAuthService,
|
|
430
|
+
IAnalyticsService,
|
|
431
|
+
IFeatureUtils,
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// Core types
|
|
435
|
+
export type {
|
|
436
|
+
AIProviderConfig,
|
|
437
|
+
JobSubmission,
|
|
438
|
+
JobStatus,
|
|
439
|
+
AIJobStatusType,
|
|
440
|
+
AILogEntry,
|
|
441
|
+
SubscribeOptions,
|
|
442
|
+
RunOptions,
|
|
443
|
+
ImageFeatureType,
|
|
444
|
+
VideoFeatureType,
|
|
445
|
+
ImageFeatureInputData,
|
|
446
|
+
VideoFeatureInputData,
|
|
447
|
+
ProviderCapabilities,
|
|
448
|
+
ProviderProgressInfo,
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
// Entities
|
|
452
|
+
export type {
|
|
453
|
+
AIErrorInfo,
|
|
454
|
+
AIErrorMessages,
|
|
455
|
+
GenerationCapability,
|
|
456
|
+
GenerationStatus,
|
|
457
|
+
GenerationMetadata,
|
|
458
|
+
GenerationResult,
|
|
459
|
+
GenerationProgress,
|
|
460
|
+
GenerationRequest,
|
|
461
|
+
PollingConfig,
|
|
462
|
+
PollingState,
|
|
463
|
+
PollingOptions,
|
|
464
|
+
ProgressStageConfig,
|
|
465
|
+
ProgressConfig,
|
|
466
|
+
MiddlewareContext,
|
|
467
|
+
MiddlewareResultContext,
|
|
468
|
+
BeforeGenerateHook,
|
|
469
|
+
AfterGenerateHook,
|
|
470
|
+
GenerationMiddleware,
|
|
471
|
+
MiddlewareChain,
|
|
472
|
+
BackgroundJobStatus,
|
|
473
|
+
BackgroundJob,
|
|
474
|
+
AddJobInput,
|
|
475
|
+
UpdateJobInput,
|
|
476
|
+
JobExecutorConfig,
|
|
477
|
+
BackgroundQueueConfig,
|
|
478
|
+
GenerationMode,
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
// Enums
|
|
482
|
+
export { AIErrorType };
|
|
483
|
+
export { DEFAULT_POLLING_CONFIG, DEFAULT_PROGRESS_STAGES, DEFAULT_QUEUE_CONFIG };
|
|
484
|
+
export { DEFAULT_PROCESSING_MODES, getModeConfig, getFreeModes, getPremiumModes, getPromptRequiredModes };
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
## Best Practices
|
|
488
|
+
|
|
489
|
+
1. **Type Safety**: Use types everywhere
|
|
490
|
+
2. **No Dependencies**: Keep domain layer dependency-free
|
|
491
|
+
3. **Clear Interfaces**: Define clear interfaces
|
|
492
|
+
4. **Immutable Data**: Keep data immutable
|
|
493
|
+
5. **Validation**: Validate at domain boundaries
|
|
494
|
+
|
|
495
|
+
## Related
|
|
496
|
+
|
|
497
|
+
- [Infrastructure](../../infrastructure/) - Infrastructure implementation
|
|
498
|
+
- [Presentation](../../presentation/) - UI layer
|
|
499
|
+
- [Features](../../features/) - Feature implementations
|
|
500
|
+
|
|
501
|
+
## License
|
|
502
|
+
|
|
503
|
+
MIT
|