@umituz/react-native-ai-generation-content 1.12.20 → 1.12.23

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 (82) hide show
  1. package/package.json +33 -15
  2. package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +4 -32
  3. package/src/domains/content-moderation/infrastructure/services/moderators/base.moderator.ts +1 -1
  4. package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +1 -1
  5. package/src/domains/face-detection/presentation/components/FaceValidationStatus.tsx +3 -3
  6. package/src/domains/feature-background/presentation/components/BackgroundFeature.tsx +5 -4
  7. package/src/domains/feature-background/presentation/components/ComparisonSlider.tsx +45 -51
  8. package/src/domains/feature-background/presentation/components/ErrorDisplay.tsx +5 -3
  9. package/src/domains/feature-background/presentation/components/ModeSelector.tsx +2 -2
  10. package/src/domains/feature-background/presentation/hooks/useBackgroundFeature.ts +3 -2
  11. package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +2 -1
  12. package/src/domains/prompts/domain/entities/GeneratedPrompt.ts +0 -1
  13. package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +6 -12
  14. package/src/domains/prompts/index.ts +5 -0
  15. package/src/domains/prompts/infrastructure/repositories/PromptHistoryRepository.ts +42 -42
  16. package/src/domains/prompts/infrastructure/repositories/TemplateRepository.ts +42 -42
  17. package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +7 -7
  18. package/src/domains/prompts/infrastructure/services/ColorizationService.ts +7 -7
  19. package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +19 -20
  20. package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +59 -31
  21. package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +7 -7
  22. package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +7 -7
  23. package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +13 -13
  24. package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +8 -8
  25. package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +7 -7
  26. package/src/domains/prompts/presentation/hooks/useAIServices.ts +30 -28
  27. package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +1 -2
  28. package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +4 -5
  29. package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +1 -1
  30. package/src/domains/prompts/presentation/hooks/useTemplateRepository.ts +3 -3
  31. package/src/domains/prompts/presentation/theme/utils.ts +1 -1
  32. package/src/index.ts +0 -5
  33. package/src/infrastructure/utils/status-checker.util.ts +4 -4
  34. package/src/infrastructure/wrappers/synchronous-generation.wrapper.ts +3 -3
  35. package/src/presentation/components/result/GenerationResultContent.tsx +21 -22
  36. package/src/presentation/components/result/ResultActions.tsx +51 -52
  37. package/src/presentation/components/result/ResultHeader.tsx +24 -25
  38. package/src/presentation/components/result/ResultImageCard.tsx +19 -20
  39. package/src/presentation/components/result/ResultStoryCard.tsx +23 -24
  40. package/src/presentation/hooks/photo-generation.types.ts +4 -4
  41. package/src/presentation/hooks/usePhotoGeneration.ts +18 -13
  42. package/src/domains/creations/application/services/CreationsService.ts +0 -72
  43. package/src/domains/creations/domain/entities/Creation.ts +0 -54
  44. package/src/domains/creations/domain/entities/index.ts +0 -6
  45. package/src/domains/creations/domain/repositories/ICreationsRepository.ts +0 -25
  46. package/src/domains/creations/domain/repositories/index.ts +0 -5
  47. package/src/domains/creations/domain/services/ICreationsStorageService.ts +0 -13
  48. package/src/domains/creations/domain/value-objects/CreationsConfig.ts +0 -77
  49. package/src/domains/creations/domain/value-objects/index.ts +0 -12
  50. package/src/domains/creations/index.ts +0 -84
  51. package/src/domains/creations/infrastructure/adapters/createRepository.ts +0 -54
  52. package/src/domains/creations/infrastructure/adapters/index.ts +0 -5
  53. package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +0 -263
  54. package/src/domains/creations/infrastructure/repositories/index.ts +0 -8
  55. package/src/domains/creations/infrastructure/services/CreationsStorageService.ts +0 -48
  56. package/src/domains/creations/presentation/components/CreationCard.tsx +0 -196
  57. package/src/domains/creations/presentation/components/CreationDetail/DetailActions.tsx +0 -76
  58. package/src/domains/creations/presentation/components/CreationDetail/DetailHeader.tsx +0 -81
  59. package/src/domains/creations/presentation/components/CreationDetail/DetailImage.tsx +0 -41
  60. package/src/domains/creations/presentation/components/CreationDetail/DetailStory.tsx +0 -67
  61. package/src/domains/creations/presentation/components/CreationDetail/index.ts +0 -4
  62. package/src/domains/creations/presentation/components/CreationImageViewer.tsx +0 -101
  63. package/src/domains/creations/presentation/components/CreationThumbnail.tsx +0 -63
  64. package/src/domains/creations/presentation/components/CreationsGalleryEmptyState.tsx +0 -77
  65. package/src/domains/creations/presentation/components/CreationsGrid.tsx +0 -87
  66. package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +0 -176
  67. package/src/domains/creations/presentation/components/EmptyState.tsx +0 -75
  68. package/src/domains/creations/presentation/components/FilterBottomSheet.tsx +0 -157
  69. package/src/domains/creations/presentation/components/FilterChips.tsx +0 -105
  70. package/src/domains/creations/presentation/components/GalleryHeader.tsx +0 -157
  71. package/src/domains/creations/presentation/components/index.ts +0 -20
  72. package/src/domains/creations/presentation/hooks/index.ts +0 -9
  73. package/src/domains/creations/presentation/hooks/useCreations.ts +0 -33
  74. package/src/domains/creations/presentation/hooks/useCreationsFilter.ts +0 -90
  75. package/src/domains/creations/presentation/hooks/useDeleteCreation.ts +0 -51
  76. package/src/domains/creations/presentation/hooks/useDeleteMultipleCreations.ts +0 -57
  77. package/src/domains/creations/presentation/hooks/useToggleFavorite.ts +0 -59
  78. package/src/domains/creations/presentation/screens/CreationDetailScreen.tsx +0 -71
  79. package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +0 -264
  80. package/src/domains/creations/presentation/screens/index.ts +0 -5
  81. package/src/domains/creations/presentation/utils/filterUtils.ts +0 -52
  82. package/src/domains/creations/types.d.ts +0 -107
@@ -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
- async findById(id: string): Promise<AIPromptResult<AIPromptTemplate | null>> {
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 (error) {
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
- async findByCategory(category: AIPromptCategory): Promise<AIPromptResult<AIPromptTemplate[]>> {
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 (error) {
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
- async findAll(): Promise<AIPromptResult<AIPromptTemplate[]>> {
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 (error) {
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
- async save(template: AIPromptTemplate): Promise<AIPromptResult<void>> {
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 (error) {
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
- async delete(id: string): Promise<AIPromptResult<void>> {
61
+ delete(id: string): Promise<AIPromptResult<void>> {
62
62
  try {
63
63
  this.storage.delete(id);
64
- return { success: true, data: undefined };
65
- } catch (error) {
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
- async exists(id: string): Promise<boolean> {
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
- async generateTemplate(config: BackgroundRemovalConfig): Promise<AIPromptResult<AIPromptTemplate>> {
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 (error) {
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
- async generateTemplate(config: ColorizationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
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 (error) {
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
- async generateTemplate(config: FaceSwapConfig): Promise<AIPromptResult<AIPromptTemplate>> {
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 (error) {
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
- async getAvailableStyles(): Promise<string[]> {
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}`,
@@ -12,6 +12,54 @@ import {
12
12
  } from '../../domain/entities/FuturePredictionConfig';
13
13
  import { PromptGenerationService } from './PromptGenerationService';
14
14
 
15
+ /**
16
+ * Core preservation instruction for photorealistic couple/family transformations
17
+ */
18
+ export const IDENTITY_INSTRUCTION = `CRITICAL PRESERVATION LOCK:
19
+ {
20
+ "policy": "PRESERVE BOTH SUBJECTS' IDENTITIES & ENFORCE STRICT PHOTOREALISM",
21
+ "rule_1": "The output MUST depict the EXACT SAME TWO PEOPLE from the input photos.",
22
+ "rule_2": "STYLE: Always render as a HIGH-END PHOTOREALISTIC photograph. 8k resolution, cinematic lighting, ultra-detailed textures.",
23
+ "rule_3": "STRICTLY PROHIBITED: Anime, cartoons, illustrations, sketches, or 3D character renders. NO non-human stylization.",
24
+ "rule_4": "Preserve both persons' facial layouts, eye colors, skin tones, and unique features while placing them in the new scenario.",
25
+ "rule_5": "Both subjects must appear naturally together in the same frame with realistic proportions."
26
+ }`;
27
+
28
+ /**
29
+ * Creates a scenario transformation prompt with structured JSON-like format
30
+ */
31
+ export const createScenarioPrompt = (
32
+ scenarioName: string,
33
+ subjectA: string,
34
+ subjectB: string,
35
+ costume: string,
36
+ environment: string,
37
+ additionalDetails?: string,
38
+ ) => `
39
+ ${IDENTITY_INSTRUCTION}
40
+
41
+ TRANSFORMATION_REQUEST:
42
+ {
43
+ "target_scenario": "${scenarioName}",
44
+ "subjects": {
45
+ "person_A": "${subjectA}",
46
+ "person_B": "${subjectB}"
47
+ },
48
+ "modifications": {
49
+ "appearance_update": "${costume.replace(/\n/g, " ").trim()}",
50
+ "environment_update": "${environment.replace(/\n/g, " ").trim()}"
51
+ ${additionalDetails ? `,"additional_details": "${additionalDetails.replace(/\n/g, " ").trim()}"` : ""}
52
+ },
53
+ "visual_constraints": {
54
+ "style_matching": "Render as a premium DSLR photograph",
55
+ "face_preservation": "Maintain 100% identity of BOTH persons from input photos",
56
+ "lighting": "Realistic professional studio or outdoor cinematic lighting",
57
+ "composition": "Both subjects prominently visible, natural poses"
58
+ }
59
+ }
60
+
61
+ FINAL COMMAND: Create a strictly photorealistic image of these two specific people in a ${scenarioName} scenario. No matter what the input style is, the result MUST be real-life looking people in a premium quality photograph.`;
62
+
15
63
  const IMAGE_PROMPT_TEMPLATE = `
16
64
  Generate a single high-quality, photorealistic image of {{subjectA}}{{#if subjectB}} and {{subjectB}}{{/if}}.
17
65
  Role/Relationship: {{subjectRole}}
@@ -48,36 +96,36 @@ export class FuturePredictionService implements IFuturePredictionService {
48
96
  this.promptService = new PromptGenerationService();
49
97
  }
50
98
 
51
- async generateTemplate(
99
+ generateTemplate(
52
100
  config: FuturePredictionConfig
53
101
  ): Promise<AIPromptResult<AIPromptTemplate>> {
54
102
  if (!this.validateConfig(config)) {
55
- return {
103
+ return Promise.resolve({
56
104
  success: false,
57
105
  error: 'VALIDATION_ERROR',
58
106
  message: 'Invalid future prediction configuration',
59
- };
107
+ });
60
108
  }
61
109
 
62
110
  const template = this.createTemplate(config);
63
- return { success: true, data: template };
111
+ return Promise.resolve({ success: true, data: template });
64
112
  }
65
113
 
66
- async generatePrompts(
114
+ generatePrompts(
67
115
  config: FuturePredictionConfig
68
116
  ): Promise<AIPromptResult<FuturePredictionResult>> {
69
117
  if (!this.validateConfig(config)) {
70
- return {
118
+ return Promise.resolve({
71
119
  success: false,
72
120
  error: 'VALIDATION_ERROR',
73
121
  message: 'Invalid configuration',
74
- };
122
+ });
75
123
  }
76
124
 
77
125
  const imagePrompt = this.buildImagePrompt(config);
78
126
  const storyPrompt = this.buildStoryPrompt(config);
79
127
 
80
- return {
128
+ return Promise.resolve({
81
129
  success: true,
82
130
  data: {
83
131
  imagePrompt,
@@ -89,7 +137,7 @@ export class FuturePredictionService implements IFuturePredictionService {
89
137
  generatedAt: Date.now(),
90
138
  },
91
139
  },
92
- };
140
+ });
93
141
  }
94
142
 
95
143
  validateConfig(config: FuturePredictionConfig): boolean {
@@ -123,10 +171,10 @@ export class FuturePredictionService implements IFuturePredictionService {
123
171
  .replace(/{{promptModifier}}/g, config.promptModifier)
124
172
  .replace(/{{futureYear}}/g, String(futureYear));
125
173
 
126
- if (config.settings.language && config.settings.language !== 'en') {
174
+ if (config.settings.languageName) {
127
175
  prompt = prompt.replace(
128
176
  /{{#if language}}(.*?){{\/if}}/g,
129
- `$1`.replace(/{{language}}/g, this.getLanguageName(config.settings.language))
177
+ `$1`.replace(/{{language}}/g, config.settings.languageName)
130
178
  );
131
179
  } else {
132
180
  prompt = prompt.replace(/{{#if language}}.*?{{\/if}}/g, '');
@@ -153,24 +201,4 @@ export class FuturePredictionService implements IFuturePredictionService {
153
201
  version: '1.0.0',
154
202
  });
155
203
  }
156
-
157
- private getLanguageName(code: string): string {
158
- const languages: Record<string, string> = {
159
- tr: 'Turkish',
160
- es: 'Spanish',
161
- fr: 'French',
162
- de: 'German',
163
- it: 'Italian',
164
- pt: 'Portuguese',
165
- ru: 'Russian',
166
- ja: 'Japanese',
167
- ko: 'Korean',
168
- zh: 'Chinese',
169
- ar: 'Arabic',
170
- hi: 'Hindi',
171
- th: 'Thai',
172
- vi: 'Vietnamese',
173
- };
174
- return languages[code] || 'English';
175
- }
176
204
  }
@@ -67,24 +67,24 @@ export class ImageEnhancementService implements IImageEnhancementService {
67
67
  this.promptService = new PromptGenerationService();
68
68
  }
69
69
 
70
- async generateTemplate(config: ImageEnhancementConfig): Promise<AIPromptResult<AIPromptTemplate>> {
70
+ generateTemplate(config: ImageEnhancementConfig): Promise<AIPromptResult<AIPromptTemplate>> {
71
71
  try {
72
72
  if (!this.validateConfig(config)) {
73
- return {
73
+ return Promise.resolve({
74
74
  success: false,
75
75
  error: 'VALIDATION_ERROR',
76
76
  message: 'Invalid image enhancement configuration'
77
- };
77
+ });
78
78
  }
79
79
 
80
80
  const template = this.createImageEnhancementTemplate(config);
81
- return { success: true, data: template };
82
- } catch (error) {
83
- return {
81
+ return Promise.resolve({ success: true, data: template });
82
+ } catch {
83
+ return Promise.resolve({
84
84
  success: false,
85
85
  error: 'GENERATION_FAILED',
86
86
  message: 'Failed to generate image enhancement template'
87
- };
87
+ });
88
88
  }
89
89
  }
90
90
 
@@ -59,24 +59,24 @@ export class PhotoRestorationService implements IPhotoRestorationService {
59
59
  this.promptService = new PromptGenerationService();
60
60
  }
61
61
 
62
- async generateTemplate(config: PhotoRestorationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
62
+ generateTemplate(config: PhotoRestorationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
63
63
  try {
64
64
  if (!this.validateConfig(config)) {
65
- return {
65
+ return Promise.resolve({
66
66
  success: false,
67
67
  error: 'VALIDATION_ERROR',
68
68
  message: 'Invalid photo restoration configuration'
69
- };
69
+ });
70
70
  }
71
71
 
72
72
  const template = this.createPhotoRestorationTemplate(config);
73
- return { success: true, data: template };
74
- } catch (error) {
75
- return {
73
+ return Promise.resolve({ success: true, data: template });
74
+ } catch {
75
+ return Promise.resolve({
76
76
  success: false,
77
77
  error: 'GENERATION_FAILED',
78
78
  message: 'Failed to generate photo restoration template'
79
- };
79
+ });
80
80
  }
81
81
  }
82
82
 
@@ -1,10 +1,10 @@
1
1
  import type { IPromptGenerationService } from '../../domain/repositories/IAIPromptServices';
2
2
  import type { AIPromptTemplate } from '../../domain/entities/AIPromptTemplate';
3
- import type { AIPromptResult, AIPromptError } from '../../domain/entities/types';
3
+ import type { AIPromptResult } from '../../domain/entities/types';
4
4
 
5
5
  export class PromptGenerationService implements IPromptGenerationService {
6
6
  generateFromTemplate(
7
- template: AIPromptTemplate,
7
+ template: AIPromptTemplate,
8
8
  variables: Record<string, unknown>
9
9
  ): Promise<AIPromptResult<string>> {
10
10
  return new Promise((resolve) => {
@@ -18,25 +18,25 @@ export class PromptGenerationService implements IPromptGenerationService {
18
18
  const generatedText = this.replaceTemplateVariables(template.template, variables);
19
19
  resolve({ success: true, data: generatedText });
20
20
  } catch (error) {
21
- resolve({
22
- success: false,
23
- error: 'GENERATION_FAILED',
24
- message: 'Failed to generate prompt'
21
+ resolve({
22
+ success: false,
23
+ error: 'GENERATION_FAILED',
24
+ message: 'Failed to generate prompt'
25
25
  });
26
26
  }
27
27
  });
28
28
  }
29
29
 
30
30
  validateVariables(
31
- template: AIPromptTemplate,
31
+ template: AIPromptTemplate,
32
32
  variables: Record<string, unknown>
33
33
  ): AIPromptResult<void> {
34
34
  for (const variable of template.variables) {
35
35
  if (variable.required && !(variable.name in variables)) {
36
- return {
37
- success: false,
38
- error: 'INVALID_VARIABLES',
39
- message: `Required variable ${variable.name} is missing`
36
+ return {
37
+ success: false,
38
+ error: 'INVALID_VARIABLES',
39
+ message: `Required variable ${variable.name} is missing`
40
40
  };
41
41
  }
42
42
  }
@@ -44,11 +44,11 @@ export class PromptGenerationService implements IPromptGenerationService {
44
44
  }
45
45
 
46
46
  replaceTemplateVariables(
47
- template: string,
47
+ template: string,
48
48
  variables: Record<string, unknown>
49
49
  ): string {
50
50
  let result = template;
51
-
51
+
52
52
  Object.entries(variables).forEach(([key, value]) => {
53
53
  const regex = new RegExp(`\\$\\{${key}\\}`, 'g');
54
54
  result = result.replace(regex, String(value || ''));
@@ -72,24 +72,24 @@ export class StyleTransferService implements IStyleTransferService {
72
72
  this.initializeDefaultStyles();
73
73
  }
74
74
 
75
- async generateTemplate(config: StyleTransferConfig): Promise<AIPromptResult<AIPromptTemplate>> {
75
+ generateTemplate(config: StyleTransferConfig): Promise<AIPromptResult<AIPromptTemplate>> {
76
76
  try {
77
77
  if (!this.validateConfig(config)) {
78
- return {
78
+ return Promise.resolve({
79
79
  success: false,
80
80
  error: 'VALIDATION_ERROR',
81
81
  message: 'Invalid style transfer configuration'
82
- };
82
+ });
83
83
  }
84
84
 
85
85
  const template = this.createStyleTransferTemplate(config);
86
- return { success: true, data: template };
87
- } catch (error) {
88
- return {
86
+ return Promise.resolve({ success: true, data: template });
87
+ } catch {
88
+ return Promise.resolve({
89
89
  success: false,
90
90
  error: 'GENERATION_FAILED',
91
91
  message: 'Failed to generate style transfer template'
92
- };
92
+ });
93
93
  }
94
94
  }
95
95
 
@@ -114,7 +114,7 @@ export class StyleTransferService implements IStyleTransferService {
114
114
  return validateStyleTransferConfig(config);
115
115
  }
116
116
 
117
- async getAvailableStyles(): Promise<string[]> {
117
+ getAvailableStyles(): Promise<string[]> {
118
118
  return Promise.resolve([...this.availableStyles]);
119
119
  }
120
120
 
@@ -72,24 +72,24 @@ export class TextGenerationService implements ITextGenerationService {
72
72
  this.promptService = new PromptGenerationService();
73
73
  }
74
74
 
75
- async generateTemplate(config: TextGenerationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
75
+ generateTemplate(config: TextGenerationConfig): Promise<AIPromptResult<AIPromptTemplate>> {
76
76
  try {
77
77
  if (!this.validateConfig(config)) {
78
- return {
78
+ return Promise.resolve({
79
79
  success: false,
80
80
  error: 'VALIDATION_ERROR',
81
81
  message: 'Invalid text generation configuration'
82
- };
82
+ });
83
83
  }
84
84
 
85
85
  const template = this.createTextGenerationTemplate(config);
86
- return { success: true, data: template };
87
- } catch (error) {
88
- return {
86
+ return Promise.resolve({ success: true, data: template });
87
+ } catch {
88
+ return Promise.resolve({
89
89
  success: false,
90
90
  error: 'GENERATION_FAILED',
91
91
  message: 'Failed to generate text template'
92
- };
92
+ });
93
93
  }
94
94
  }
95
95