@umituz/react-native-ai-generation-content 1.12.21 → 1.12.24
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 +33 -15
- package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +4 -32
- package/src/domains/content-moderation/infrastructure/services/moderators/base.moderator.ts +1 -1
- package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +1 -1
- package/src/domains/face-detection/presentation/components/FaceValidationStatus.tsx +3 -3
- package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +2 -1
- package/src/domains/prompts/domain/entities/GeneratedPrompt.ts +0 -1
- package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +6 -12
- package/src/domains/prompts/infrastructure/repositories/PromptHistoryRepository.ts +42 -42
- package/src/domains/prompts/infrastructure/repositories/TemplateRepository.ts +42 -42
- package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/ColorizationService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +19 -20
- package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +11 -31
- package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +7 -7
- package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +13 -13
- package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +8 -8
- package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +7 -7
- package/src/domains/prompts/presentation/hooks/useAIServices.ts +30 -28
- package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +1 -2
- package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +4 -5
- package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +1 -1
- package/src/domains/prompts/presentation/hooks/useTemplateRepository.ts +3 -3
- package/src/domains/prompts/presentation/theme/utils.ts +1 -1
- package/src/features/audio-generation/domain/entities.ts +39 -0
- package/src/features/audio-generation/index.ts +2 -0
- package/src/features/audio-generation/presentation/hooks.ts +39 -0
- package/src/{domains/feature-background → features/background}/presentation/components/BackgroundFeature.tsx +5 -4
- package/src/{domains/feature-background → features/background}/presentation/components/ComparisonSlider.tsx +45 -51
- package/src/{domains/feature-background → features/background}/presentation/components/ErrorDisplay.tsx +5 -3
- package/src/{domains/feature-background → features/background}/presentation/components/ModeSelector.tsx +2 -2
- package/src/{domains/feature-background → features/background}/presentation/hooks/useBackgroundFeature.ts +3 -2
- package/src/features/colorization/domain/entities.ts +46 -0
- package/src/features/colorization/index.ts +2 -0
- package/src/features/colorization/presentation/hooks.ts +39 -0
- package/src/features/face-swap/domain/entities.ts +48 -0
- package/src/features/face-swap/index.ts +2 -0
- package/src/features/face-swap/presentation/hooks.ts +41 -0
- package/src/features/future-prediction/domain/entities.ts +45 -0
- package/src/features/future-prediction/index.ts +2 -0
- package/src/features/future-prediction/presentation/hooks.ts +39 -0
- package/src/features/image-captioning/domain/entities.ts +47 -0
- package/src/features/image-captioning/index.ts +2 -0
- package/src/features/image-captioning/presentation/hooks.ts +39 -0
- package/src/features/inpainting/domain/entities.ts +58 -0
- package/src/features/inpainting/index.ts +2 -0
- package/src/features/inpainting/presentation/hooks.ts +39 -0
- package/src/features/photo-restoration/domain/entities.ts +48 -0
- package/src/features/photo-restoration/index.ts +2 -0
- package/src/features/photo-restoration/presentation/hooks.ts +39 -0
- package/src/features/sketch-to-image/domain/entities.ts +47 -0
- package/src/features/sketch-to-image/index.ts +2 -0
- package/src/features/sketch-to-image/presentation/hooks.ts +39 -0
- package/src/features/style-transfer/domain/entities.ts +52 -0
- package/src/features/style-transfer/index.ts +2 -0
- package/src/features/style-transfer/presentation/hooks.ts +39 -0
- package/src/features/text-to-image/domain/entities.ts +58 -0
- package/src/features/text-to-image/index.ts +2 -0
- package/src/features/text-to-image/presentation/hooks.ts +39 -0
- package/src/features/text-to-video/domain/entities.ts +52 -0
- package/src/features/text-to-video/index.ts +2 -0
- package/src/features/text-to-video/presentation/hooks.ts +39 -0
- package/src/features/upscaling/domain/entities.ts +42 -0
- package/src/features/upscaling/index.ts +2 -0
- package/src/features/upscaling/presentation/hooks.ts +39 -0
- package/src/index.ts +3 -6
- package/src/infrastructure/utils/status-checker.util.ts +4 -4
- package/src/infrastructure/wrappers/synchronous-generation.wrapper.ts +3 -3
- package/src/presentation/components/result/GenerationResultContent.tsx +21 -22
- package/src/presentation/components/result/ResultActions.tsx +51 -52
- package/src/presentation/components/result/ResultHeader.tsx +24 -25
- package/src/presentation/components/result/ResultImageCard.tsx +19 -20
- package/src/presentation/components/result/ResultStoryCard.tsx +23 -24
- package/src/presentation/hooks/photo-generation.types.ts +13 -4
- package/src/presentation/hooks/usePhotoGeneration.ts +30 -13
- package/src/domains/creations/application/services/CreationsService.ts +0 -72
- package/src/domains/creations/domain/entities/Creation.ts +0 -54
- package/src/domains/creations/domain/entities/index.ts +0 -6
- package/src/domains/creations/domain/repositories/ICreationsRepository.ts +0 -25
- package/src/domains/creations/domain/repositories/index.ts +0 -5
- package/src/domains/creations/domain/services/ICreationsStorageService.ts +0 -13
- package/src/domains/creations/domain/value-objects/CreationsConfig.ts +0 -77
- package/src/domains/creations/domain/value-objects/index.ts +0 -12
- package/src/domains/creations/index.ts +0 -84
- package/src/domains/creations/infrastructure/adapters/createRepository.ts +0 -54
- package/src/domains/creations/infrastructure/adapters/index.ts +0 -5
- package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +0 -263
- package/src/domains/creations/infrastructure/repositories/index.ts +0 -8
- package/src/domains/creations/infrastructure/services/CreationsStorageService.ts +0 -48
- package/src/domains/creations/presentation/components/CreationCard.tsx +0 -196
- package/src/domains/creations/presentation/components/CreationDetail/DetailActions.tsx +0 -76
- package/src/domains/creations/presentation/components/CreationDetail/DetailHeader.tsx +0 -81
- package/src/domains/creations/presentation/components/CreationDetail/DetailImage.tsx +0 -41
- package/src/domains/creations/presentation/components/CreationDetail/DetailStory.tsx +0 -67
- package/src/domains/creations/presentation/components/CreationDetail/index.ts +0 -4
- package/src/domains/creations/presentation/components/CreationImageViewer.tsx +0 -101
- package/src/domains/creations/presentation/components/CreationThumbnail.tsx +0 -63
- package/src/domains/creations/presentation/components/CreationsGalleryEmptyState.tsx +0 -77
- package/src/domains/creations/presentation/components/CreationsGrid.tsx +0 -87
- package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +0 -176
- package/src/domains/creations/presentation/components/EmptyState.tsx +0 -75
- package/src/domains/creations/presentation/components/FilterBottomSheet.tsx +0 -157
- package/src/domains/creations/presentation/components/FilterChips.tsx +0 -105
- package/src/domains/creations/presentation/components/GalleryHeader.tsx +0 -157
- package/src/domains/creations/presentation/components/index.ts +0 -20
- package/src/domains/creations/presentation/hooks/index.ts +0 -9
- package/src/domains/creations/presentation/hooks/useCreations.ts +0 -33
- package/src/domains/creations/presentation/hooks/useCreationsFilter.ts +0 -90
- package/src/domains/creations/presentation/hooks/useDeleteCreation.ts +0 -51
- package/src/domains/creations/presentation/hooks/useDeleteMultipleCreations.ts +0 -57
- package/src/domains/creations/presentation/hooks/useToggleFavorite.ts +0 -59
- package/src/domains/creations/presentation/screens/CreationDetailScreen.tsx +0 -71
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +0 -264
- package/src/domains/creations/presentation/screens/index.ts +0 -5
- package/src/domains/creations/presentation/utils/filterUtils.ts +0 -52
- package/src/domains/creations/types.d.ts +0 -107
- /package/src/{domains/feature-background → features/background}/domain/entities/background.types.ts +0 -0
- /package/src/{domains/feature-background → features/background}/domain/entities/component.types.ts +0 -0
- /package/src/{domains/feature-background → features/background}/domain/entities/config.types.ts +0 -0
- /package/src/{domains/feature-background → features/background}/domain/entities/index.ts +0 -0
- /package/src/{domains/feature-background → features/background}/index.ts +0 -0
- /package/src/{domains/feature-background → features/background}/infrastructure/constants/index.ts +0 -0
- /package/src/{domains/feature-background → features/background}/infrastructure/constants/prompts.constants.ts +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/components/FeatureHeader.tsx +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/components/GenerateButton.tsx +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/components/ImagePicker.tsx +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/components/ProcessingModal.tsx +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/components/PromptInput.tsx +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/components/ResultDisplay.tsx +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/components/index.ts +0 -0
- /package/src/{domains/feature-background → features/background}/presentation/hooks/index.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.24",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@react-navigation/native": ">=6.0.0",
|
|
42
42
|
"@tanstack/react-query": ">=5.0.0",
|
|
43
|
-
"@umituz/react-native-animation": "
|
|
44
|
-
"@umituz/react-native-design-system": "
|
|
45
|
-
"@umituz/react-native-firebase": "
|
|
46
|
-
"@umituz/react-native-image": "
|
|
47
|
-
"@umituz/react-native-offline": "
|
|
48
|
-
"@umituz/react-native-uuid": "
|
|
43
|
+
"@umituz/react-native-animation": "*",
|
|
44
|
+
"@umituz/react-native-design-system": "*",
|
|
45
|
+
"@umituz/react-native-firebase": "*",
|
|
46
|
+
"@umituz/react-native-image": "*",
|
|
47
|
+
"@umituz/react-native-offline": "*",
|
|
48
|
+
"@umituz/react-native-uuid": "*",
|
|
49
49
|
"expo-linear-gradient": ">=15.0.0",
|
|
50
50
|
"firebase": ">=10.0.0",
|
|
51
51
|
"react": ">=18.0.0",
|
|
@@ -53,29 +53,47 @@
|
|
|
53
53
|
"react-native-safe-area-context": ">=4.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@
|
|
56
|
+
"@expo/vector-icons": "^15.0.3",
|
|
57
|
+
"@gorhom/bottom-sheet": "^5.2.8",
|
|
58
|
+
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
59
|
+
"@react-native-community/datetimepicker": "^8.5.1",
|
|
60
|
+
"@react-navigation/bottom-tabs": "^7.9.0",
|
|
57
61
|
"@react-navigation/native": "^6.1.18",
|
|
62
|
+
"@react-navigation/stack": "^7.6.13",
|
|
58
63
|
"@tanstack/react-query": "^5.0.0",
|
|
59
64
|
"@types/react": "~19.1.10",
|
|
60
65
|
"@types/react-native": "^0.73.0",
|
|
61
66
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
62
67
|
"@typescript-eslint/parser": "^7.0.0",
|
|
63
|
-
"@umituz/react-native-animation": "
|
|
64
|
-
"@umituz/react-native-design-system": "
|
|
65
|
-
"@umituz/react-native-firebase": "
|
|
66
|
-
"@umituz/react-native-
|
|
67
|
-
"@umituz/react-native-
|
|
68
|
-
"@umituz/react-native-
|
|
68
|
+
"@umituz/react-native-animation": "*",
|
|
69
|
+
"@umituz/react-native-design-system": "^2.3.31",
|
|
70
|
+
"@umituz/react-native-firebase": "*",
|
|
71
|
+
"@umituz/react-native-haptics": "^1.0.2",
|
|
72
|
+
"@umituz/react-native-image": "*",
|
|
73
|
+
"@umituz/react-native-offline": "*",
|
|
74
|
+
"@umituz/react-native-uuid": "*",
|
|
69
75
|
"eslint": "^8.57.0",
|
|
76
|
+
"expo-application": "^7.0.8",
|
|
77
|
+
"expo-clipboard": "^8.0.8",
|
|
78
|
+
"expo-crypto": "^15.0.8",
|
|
79
|
+
"expo-device": "^8.0.10",
|
|
80
|
+
"expo-file-system": "^19.0.21",
|
|
81
|
+
"expo-haptics": "^15.0.8",
|
|
82
|
+
"expo-image": "^3.0.11",
|
|
70
83
|
"expo-linear-gradient": "~15.0.7",
|
|
84
|
+
"expo-localization": "^17.0.8",
|
|
85
|
+
"expo-sharing": "^14.0.8",
|
|
71
86
|
"firebase": "^11.1.0",
|
|
72
87
|
"react": "19.1.0",
|
|
73
88
|
"react-native": "0.81.5",
|
|
89
|
+
"react-native-gesture-handler": "^2.30.0",
|
|
90
|
+
"react-native-reanimated": "^4.2.1",
|
|
74
91
|
"react-native-safe-area-context": "^5.6.2",
|
|
92
|
+
"rn-emoji-keyboard": "^1.7.0",
|
|
75
93
|
"typescript": "^5.3.0",
|
|
76
94
|
"zustand": "^5.0.2"
|
|
77
95
|
},
|
|
78
96
|
"publishConfig": {
|
|
79
97
|
"access": "public"
|
|
80
98
|
}
|
|
81
|
-
}
|
|
99
|
+
}
|
package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts
CHANGED
|
@@ -18,7 +18,6 @@ import { videoModerator } from "./moderators/video.moderator";
|
|
|
18
18
|
import { voiceModerator } from "./moderators/voice.moderator";
|
|
19
19
|
import { rulesRegistry } from "../rules/rules-registry";
|
|
20
20
|
|
|
21
|
-
declare const __DEV__: boolean;
|
|
22
21
|
|
|
23
22
|
interface ServiceConfig {
|
|
24
23
|
suggestionMessages?: SuggestionMessages;
|
|
@@ -28,15 +27,6 @@ interface ServiceConfig {
|
|
|
28
27
|
|
|
29
28
|
class ContentModerationService {
|
|
30
29
|
configure(config: ServiceConfig): void {
|
|
31
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
32
|
-
// eslint-disable-next-line no-console
|
|
33
|
-
console.log("[ContentModeration] Configure:", {
|
|
34
|
-
hasSuggestionMessages: !!config.suggestionMessages,
|
|
35
|
-
hasValidationLimits: !!config.validationLimits,
|
|
36
|
-
customRulesCount: config.customRules?.length ?? 0,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
30
|
if (config.suggestionMessages) {
|
|
41
31
|
textModerator.setSuggestionMessages(config.suggestionMessages);
|
|
42
32
|
voiceModerator.setSuggestionMessages(config.suggestionMessages);
|
|
@@ -59,15 +49,7 @@ class ContentModerationService {
|
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
51
|
|
|
62
|
-
|
|
63
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
|
-
console.log("[ContentModeration] Moderate started:", {
|
|
66
|
-
contentType: context.contentType,
|
|
67
|
-
contentLength: context.content?.length ?? 0,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
52
|
+
moderate(context: ModerationContext): Promise<ModerationResult> {
|
|
71
53
|
const result = this.moderateByType(context.contentType, context.content);
|
|
72
54
|
const moderationResult: ModerationResult = {
|
|
73
55
|
isAllowed: result.isAllowed,
|
|
@@ -76,25 +58,15 @@ class ContentModerationService {
|
|
|
76
58
|
suggestedAction: this.determineAction(result.violations),
|
|
77
59
|
};
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
// eslint-disable-next-line no-console
|
|
81
|
-
console.log("[ContentModeration] Moderate completed:", {
|
|
82
|
-
contentType: context.contentType,
|
|
83
|
-
isAllowed: moderationResult.isAllowed,
|
|
84
|
-
violationsCount: moderationResult.violations?.length ?? 0,
|
|
85
|
-
suggestedAction: moderationResult.suggestedAction,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return moderationResult;
|
|
61
|
+
return Promise.resolve(moderationResult);
|
|
90
62
|
}
|
|
91
63
|
|
|
92
|
-
|
|
64
|
+
isContentAllowed(
|
|
93
65
|
content: string,
|
|
94
66
|
contentType: ContentType
|
|
95
67
|
): Promise<boolean> {
|
|
96
68
|
const result = this.moderateByType(contentType, content);
|
|
97
|
-
return result.isAllowed;
|
|
69
|
+
return Promise.resolve(result.isAllowed);
|
|
98
70
|
}
|
|
99
71
|
|
|
100
72
|
moderateSync(
|
|
@@ -36,7 +36,7 @@ export abstract class BaseModerator {
|
|
|
36
36
|
|
|
37
37
|
protected getSuggestion(type: ViolationType): string {
|
|
38
38
|
if (this.customSuggestions?.[type]) {
|
|
39
|
-
return this.customSuggestions[type]
|
|
39
|
+
return this.customSuggestions[type];
|
|
40
40
|
}
|
|
41
41
|
return DEFAULT_SUGGESTIONS[type] || DEFAULT_SUGGESTIONS.default;
|
|
42
42
|
}
|
|
@@ -25,7 +25,7 @@ export const parseDetectionResponse = (
|
|
|
25
25
|
return createFailedResult("Invalid response format");
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const parsed = JSON.parse(jsonMatch[0])
|
|
28
|
+
const parsed = JSON.parse(jsonMatch[0]) as Record<string, unknown>;
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
31
|
hasFace: Boolean(parsed.hasFace),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Translations provided by main app via props.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import * as React from "react";
|
|
9
9
|
import { View, StyleSheet, ActivityIndicator } from "react-native";
|
|
10
10
|
import {
|
|
11
11
|
AtomicText,
|
|
@@ -59,7 +59,7 @@ export const FaceValidationStatus: React.FC<FaceValidationStatusProps> = ({
|
|
|
59
59
|
<AtomicIcon
|
|
60
60
|
name="alert-circle"
|
|
61
61
|
size="sm"
|
|
62
|
-
|
|
62
|
+
color="error"
|
|
63
63
|
/>
|
|
64
64
|
<AtomicText style={[styles.text, { color: tokens.colors.error }]}>
|
|
65
65
|
{labels.error}
|
|
@@ -88,7 +88,7 @@ export const FaceValidationStatus: React.FC<FaceValidationStatusProps> = ({
|
|
|
88
88
|
<AtomicIcon
|
|
89
89
|
name={valid ? "checkmark-circle" : "close-circle"}
|
|
90
90
|
size="sm"
|
|
91
|
-
|
|
91
|
+
color={valid ? "success" : "error"}
|
|
92
92
|
/>
|
|
93
93
|
<AtomicText
|
|
94
94
|
style={[
|
|
@@ -10,7 +10,8 @@ export interface FuturePredictionSettings {
|
|
|
10
10
|
readonly outputType: FuturePredictionOutputType;
|
|
11
11
|
readonly personCount: 1 | 2;
|
|
12
12
|
readonly includeDate: boolean;
|
|
13
|
-
readonly language: string;
|
|
13
|
+
readonly language: string; // Language code (e.g. 'en', 'tr')
|
|
14
|
+
readonly languageName?: string; // Full language name provided by app (e.g. 'Turkish', 'English')
|
|
14
15
|
readonly tone?: string; // e.g. 'romantic', 'professional', 'funny', 'dramatic'
|
|
15
16
|
readonly subjectRole?: string; // e.g. 'couple', 'best friends', 'business partners', 'parents'
|
|
16
17
|
readonly year?: number; // Optional specific year for prediction
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import type { AIPromptTemplate } from '../entities/AIPromptTemplate';
|
|
2
2
|
import type { AIPromptResult } from '../entities/types';
|
|
3
|
-
import type { FaceSwapConfig
|
|
3
|
+
import type { FaceSwapConfig } from '../entities/FaceSwapConfig';
|
|
4
4
|
import type {
|
|
5
|
-
PhotoRestorationConfig
|
|
6
|
-
PhotoRestorationResult
|
|
5
|
+
PhotoRestorationConfig
|
|
7
6
|
} from '../entities/PhotoRestorationConfig';
|
|
8
7
|
import type {
|
|
9
8
|
ImageEnhancementConfig,
|
|
10
|
-
ImageEnhancementResult,
|
|
11
9
|
EnhancementAdjustments
|
|
12
10
|
} from '../entities/ImageEnhancementConfig';
|
|
13
11
|
import type {
|
|
14
|
-
StyleTransferConfig
|
|
15
|
-
StyleTransferResult
|
|
12
|
+
StyleTransferConfig
|
|
16
13
|
} from '../entities/StyleTransferConfig';
|
|
17
14
|
import type {
|
|
18
|
-
BackgroundRemovalConfig
|
|
19
|
-
BackgroundRemovalResult
|
|
15
|
+
BackgroundRemovalConfig
|
|
20
16
|
} from '../entities/BackgroundRemovalConfig';
|
|
21
17
|
import type {
|
|
22
|
-
TextGenerationConfig
|
|
23
|
-
TextGenerationResult
|
|
18
|
+
TextGenerationConfig
|
|
24
19
|
} from '../entities/TextGenerationConfig';
|
|
25
20
|
import type {
|
|
26
|
-
ColorizationConfig
|
|
27
|
-
ColorizationResult
|
|
21
|
+
ColorizationConfig
|
|
28
22
|
} from '../entities/ColorizationConfig';
|
|
29
23
|
import type {
|
|
30
24
|
FuturePredictionConfig,
|
|
@@ -1,79 +1,79 @@
|
|
|
1
1
|
import type { IPromptHistoryRepository } from '../../domain/repositories/IPromptHistoryRepository';
|
|
2
2
|
import type { GeneratedPrompt } from '../../domain/entities/GeneratedPrompt';
|
|
3
|
-
import type { AIPromptResult
|
|
3
|
+
import type { AIPromptResult } from '../../domain/entities/types';
|
|
4
4
|
|
|
5
5
|
export class PromptHistoryRepository implements IPromptHistoryRepository {
|
|
6
6
|
private storage: GeneratedPrompt[] = [];
|
|
7
7
|
private readonly maxStorageSize = 100;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
save(prompt: GeneratedPrompt): Promise<AIPromptResult<void>> {
|
|
10
10
|
try {
|
|
11
11
|
this.storage.push(prompt);
|
|
12
12
|
this.trimStorage();
|
|
13
|
-
return { success: true, data: undefined };
|
|
14
|
-
} catch
|
|
15
|
-
return {
|
|
16
|
-
success: false,
|
|
17
|
-
error: 'STORAGE_ERROR',
|
|
18
|
-
message: 'Failed to save prompt to history'
|
|
19
|
-
};
|
|
13
|
+
return Promise.resolve({ success: true, data: undefined });
|
|
14
|
+
} catch {
|
|
15
|
+
return Promise.resolve({
|
|
16
|
+
success: false,
|
|
17
|
+
error: 'STORAGE_ERROR',
|
|
18
|
+
message: 'Failed to save prompt to history'
|
|
19
|
+
});
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
findRecent(limit: number = 50): Promise<AIPromptResult<GeneratedPrompt[]>> {
|
|
24
24
|
try {
|
|
25
25
|
const prompts = this.storage.slice(-limit);
|
|
26
|
-
return { success: true, data: prompts };
|
|
27
|
-
} catch
|
|
28
|
-
return {
|
|
29
|
-
success: false,
|
|
30
|
-
error: 'STORAGE_ERROR',
|
|
31
|
-
message: 'Failed to retrieve recent prompts'
|
|
32
|
-
};
|
|
26
|
+
return Promise.resolve({ success: true, data: prompts });
|
|
27
|
+
} catch {
|
|
28
|
+
return Promise.resolve({
|
|
29
|
+
success: false,
|
|
30
|
+
error: 'STORAGE_ERROR',
|
|
31
|
+
message: 'Failed to retrieve recent prompts'
|
|
32
|
+
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
templateId: string,
|
|
36
|
+
findByTemplateId(
|
|
37
|
+
templateId: string,
|
|
38
38
|
limit: number = 20
|
|
39
39
|
): Promise<AIPromptResult<GeneratedPrompt[]>> {
|
|
40
40
|
try {
|
|
41
41
|
const prompts = this.storage
|
|
42
42
|
.filter(prompt => prompt.templateId === templateId)
|
|
43
43
|
.slice(-limit);
|
|
44
|
-
return { success: true, data: prompts };
|
|
45
|
-
} catch
|
|
46
|
-
return {
|
|
47
|
-
success: false,
|
|
48
|
-
error: 'STORAGE_ERROR',
|
|
49
|
-
message: 'Failed to retrieve prompts by template ID'
|
|
50
|
-
};
|
|
44
|
+
return Promise.resolve({ success: true, data: prompts });
|
|
45
|
+
} catch {
|
|
46
|
+
return Promise.resolve({
|
|
47
|
+
success: false,
|
|
48
|
+
error: 'STORAGE_ERROR',
|
|
49
|
+
message: 'Failed to retrieve prompts by template ID'
|
|
50
|
+
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
delete(id: string): Promise<AIPromptResult<void>> {
|
|
55
55
|
try {
|
|
56
56
|
this.storage = this.storage.filter(prompt => prompt.id !== id);
|
|
57
|
-
return { success: true, data: undefined };
|
|
58
|
-
} catch
|
|
59
|
-
return {
|
|
60
|
-
success: false,
|
|
61
|
-
error: 'STORAGE_ERROR',
|
|
62
|
-
message: 'Failed to delete prompt'
|
|
63
|
-
};
|
|
57
|
+
return Promise.resolve({ success: true, data: undefined });
|
|
58
|
+
} catch {
|
|
59
|
+
return Promise.resolve({
|
|
60
|
+
success: false,
|
|
61
|
+
error: 'STORAGE_ERROR',
|
|
62
|
+
message: 'Failed to delete prompt'
|
|
63
|
+
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
clear(): Promise<AIPromptResult<void>> {
|
|
68
68
|
try {
|
|
69
69
|
this.storage = [];
|
|
70
|
-
return { success: true, data: undefined };
|
|
71
|
-
} catch
|
|
72
|
-
return {
|
|
73
|
-
success: false,
|
|
74
|
-
error: 'STORAGE_ERROR',
|
|
75
|
-
message: 'Failed to clear prompt history'
|
|
76
|
-
};
|
|
70
|
+
return Promise.resolve({ success: true, data: undefined });
|
|
71
|
+
} catch {
|
|
72
|
+
return Promise.resolve({
|
|
73
|
+
success: false,
|
|
74
|
+
error: 'STORAGE_ERROR',
|
|
75
|
+
message: 'Failed to clear prompt history'
|
|
76
|
+
});
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -5,73 +5,73 @@ import type { AIPromptCategory, AIPromptResult } from '../../domain/entities/typ
|
|
|
5
5
|
export class TemplateRepository implements ITemplateRepository {
|
|
6
6
|
private storage = new Map<string, AIPromptTemplate>();
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
findById(id: string): Promise<AIPromptResult<AIPromptTemplate | null>> {
|
|
9
9
|
try {
|
|
10
10
|
const template = this.storage.get(id) || null;
|
|
11
|
-
return { success: true, data: template };
|
|
12
|
-
} catch
|
|
13
|
-
return {
|
|
14
|
-
success: false,
|
|
15
|
-
error: 'STORAGE_ERROR',
|
|
16
|
-
message: 'Failed to retrieve template'
|
|
17
|
-
};
|
|
11
|
+
return Promise.resolve({ success: true, data: template });
|
|
12
|
+
} catch {
|
|
13
|
+
return Promise.resolve({
|
|
14
|
+
success: false,
|
|
15
|
+
error: 'STORAGE_ERROR',
|
|
16
|
+
message: 'Failed to retrieve template'
|
|
17
|
+
});
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
findByCategory(category: AIPromptCategory): Promise<AIPromptResult<AIPromptTemplate[]>> {
|
|
22
22
|
try {
|
|
23
23
|
const templates = Array.from(this.storage.values())
|
|
24
24
|
.filter(template => template.category === category);
|
|
25
|
-
return { success: true, data: templates };
|
|
26
|
-
} catch
|
|
27
|
-
return {
|
|
28
|
-
success: false,
|
|
29
|
-
error: 'STORAGE_ERROR',
|
|
30
|
-
message: 'Failed to retrieve templates by category'
|
|
31
|
-
};
|
|
25
|
+
return Promise.resolve({ success: true, data: templates });
|
|
26
|
+
} catch {
|
|
27
|
+
return Promise.resolve({
|
|
28
|
+
success: false,
|
|
29
|
+
error: 'STORAGE_ERROR',
|
|
30
|
+
message: 'Failed to retrieve templates by category'
|
|
31
|
+
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
findAll(): Promise<AIPromptResult<AIPromptTemplate[]>> {
|
|
36
36
|
try {
|
|
37
37
|
const templates = Array.from(this.storage.values());
|
|
38
|
-
return { success: true, data: templates };
|
|
39
|
-
} catch
|
|
40
|
-
return {
|
|
41
|
-
success: false,
|
|
42
|
-
error: 'STORAGE_ERROR',
|
|
43
|
-
message: 'Failed to retrieve all templates'
|
|
44
|
-
};
|
|
38
|
+
return Promise.resolve({ success: true, data: templates });
|
|
39
|
+
} catch {
|
|
40
|
+
return Promise.resolve({
|
|
41
|
+
success: false,
|
|
42
|
+
error: 'STORAGE_ERROR',
|
|
43
|
+
message: 'Failed to retrieve all templates'
|
|
44
|
+
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
save(template: AIPromptTemplate): Promise<AIPromptResult<void>> {
|
|
49
49
|
try {
|
|
50
50
|
this.storage.set(template.id, template);
|
|
51
|
-
return { success: true, data: undefined };
|
|
52
|
-
} catch
|
|
53
|
-
return {
|
|
54
|
-
success: false,
|
|
55
|
-
error: 'STORAGE_ERROR',
|
|
56
|
-
message: 'Failed to save template'
|
|
57
|
-
};
|
|
51
|
+
return Promise.resolve({ success: true, data: undefined });
|
|
52
|
+
} catch {
|
|
53
|
+
return Promise.resolve({
|
|
54
|
+
success: false,
|
|
55
|
+
error: 'STORAGE_ERROR',
|
|
56
|
+
message: 'Failed to save template'
|
|
57
|
+
});
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
delete(id: string): Promise<AIPromptResult<void>> {
|
|
62
62
|
try {
|
|
63
63
|
this.storage.delete(id);
|
|
64
|
-
return { success: true, data: undefined };
|
|
65
|
-
} catch
|
|
66
|
-
return {
|
|
67
|
-
success: false,
|
|
68
|
-
error: 'STORAGE_ERROR',
|
|
69
|
-
message: 'Failed to delete template'
|
|
70
|
-
};
|
|
64
|
+
return Promise.resolve({ success: true, data: undefined });
|
|
65
|
+
} catch {
|
|
66
|
+
return Promise.resolve({
|
|
67
|
+
success: false,
|
|
68
|
+
error: 'STORAGE_ERROR',
|
|
69
|
+
message: 'Failed to delete template'
|
|
70
|
+
});
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
return this.storage.has(id);
|
|
74
|
+
exists(id: string): Promise<boolean> {
|
|
75
|
+
return Promise.resolve(this.storage.has(id));
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -83,24 +83,24 @@ export class BackgroundRemovalService implements IBackgroundRemovalService {
|
|
|
83
83
|
this.promptService = new PromptGenerationService();
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
generateTemplate(config: BackgroundRemovalConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
87
87
|
try {
|
|
88
88
|
if (!this.validateConfig(config)) {
|
|
89
|
-
return {
|
|
89
|
+
return Promise.resolve({
|
|
90
90
|
success: false,
|
|
91
91
|
error: 'VALIDATION_ERROR',
|
|
92
92
|
message: 'Invalid background removal configuration'
|
|
93
|
-
};
|
|
93
|
+
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
const template = this.createBackgroundRemovalTemplate(config);
|
|
97
|
-
return { success: true, data: template };
|
|
98
|
-
} catch
|
|
99
|
-
return {
|
|
97
|
+
return Promise.resolve({ success: true, data: template });
|
|
98
|
+
} catch {
|
|
99
|
+
return Promise.resolve({
|
|
100
100
|
success: false,
|
|
101
101
|
error: 'GENERATION_FAILED',
|
|
102
102
|
message: 'Failed to generate background removal template'
|
|
103
|
-
};
|
|
103
|
+
});
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -87,24 +87,24 @@ export class ColorizationService implements IColorizationService {
|
|
|
87
87
|
this.promptService = new PromptGenerationService();
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
generateTemplate(config: ColorizationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
91
91
|
try {
|
|
92
92
|
if (!this.validateConfig(config)) {
|
|
93
|
-
return {
|
|
93
|
+
return Promise.resolve({
|
|
94
94
|
success: false,
|
|
95
95
|
error: 'VALIDATION_ERROR',
|
|
96
96
|
message: 'Invalid colorization configuration'
|
|
97
|
-
};
|
|
97
|
+
});
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
const template = this.createColorizationTemplate(config);
|
|
101
|
-
return { success: true, data: template };
|
|
102
|
-
} catch
|
|
103
|
-
return {
|
|
101
|
+
return Promise.resolve({ success: true, data: template });
|
|
102
|
+
} catch {
|
|
103
|
+
return Promise.resolve({
|
|
104
104
|
success: false,
|
|
105
105
|
error: 'GENERATION_FAILED',
|
|
106
106
|
message: 'Failed to generate colorization template'
|
|
107
|
-
};
|
|
107
|
+
});
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { IFaceSwapService } from '../../domain/repositories/IAIPromptServices';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
3
|
AIPromptTemplate
|
|
4
4
|
} from '../../domain/entities/AIPromptTemplate';
|
|
5
|
-
import type {
|
|
6
|
-
FaceSwapConfig,
|
|
7
|
-
FaceSwapGenerationResult,
|
|
5
|
+
import type {
|
|
6
|
+
FaceSwapConfig,
|
|
8
7
|
FaceSwapSafety
|
|
9
8
|
} from '../../domain/entities/FaceSwapConfig';
|
|
10
9
|
import type { AIPromptCategory } from '../../domain/entities/types';
|
|
@@ -82,29 +81,29 @@ export class FaceSwapService implements IFaceSwapService {
|
|
|
82
81
|
this.initializeDefaultStyles();
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
|
|
84
|
+
generateTemplate(config: FaceSwapConfig): Promise<AIPromptResult<AIPromptTemplate>> {
|
|
86
85
|
try {
|
|
87
86
|
if (!this.validateConfig(config)) {
|
|
88
|
-
return {
|
|
89
|
-
success: false,
|
|
90
|
-
error: 'INVALID_VARIABLES',
|
|
91
|
-
message: 'Invalid face swap configuration'
|
|
92
|
-
};
|
|
87
|
+
return Promise.resolve({
|
|
88
|
+
success: false,
|
|
89
|
+
error: 'INVALID_VARIABLES',
|
|
90
|
+
message: 'Invalid face swap configuration'
|
|
91
|
+
});
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
const template = this.createFaceSwapTemplate(config);
|
|
96
|
-
return { success: true, data: template };
|
|
97
|
-
} catch
|
|
98
|
-
return {
|
|
99
|
-
success: false,
|
|
100
|
-
error: 'GENERATION_FAILED',
|
|
101
|
-
message: 'Failed to generate face swap template'
|
|
102
|
-
};
|
|
95
|
+
return Promise.resolve({ success: true, data: template });
|
|
96
|
+
} catch {
|
|
97
|
+
return Promise.resolve({
|
|
98
|
+
success: false,
|
|
99
|
+
error: 'GENERATION_FAILED',
|
|
100
|
+
message: 'Failed to generate face swap template'
|
|
101
|
+
});
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
async generatePrompt(
|
|
107
|
-
template: AIPromptTemplate,
|
|
106
|
+
template: AIPromptTemplate,
|
|
108
107
|
config: FaceSwapConfig
|
|
109
108
|
): Promise<AIPromptResult<string>> {
|
|
110
109
|
const variables = {
|
|
@@ -123,7 +122,7 @@ export class FaceSwapService implements IFaceSwapService {
|
|
|
123
122
|
return validateFaceSwapConfig(config);
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
|
|
125
|
+
getAvailableStyles(): Promise<string[]> {
|
|
127
126
|
return Promise.resolve([...this.availableStyles]);
|
|
128
127
|
}
|
|
129
128
|
|
|
@@ -147,7 +146,7 @@ export class FaceSwapService implements IFaceSwapService {
|
|
|
147
146
|
|
|
148
147
|
private createFaceSwapTemplate(config: FaceSwapConfig): AIPromptTemplate {
|
|
149
148
|
const templateId = `face-swap-${config.styleName.toLowerCase().replace(/\s+/g, '-')}`;
|
|
150
|
-
|
|
149
|
+
|
|
151
150
|
return createAIPromptTemplate({
|
|
152
151
|
id: templateId,
|
|
153
152
|
name: `Face Swap: ${config.styleName}`,
|