@umituz/react-native-ai-generation-content 1.90.2 → 1.90.4

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 (171) hide show
  1. package/package.json +3 -3
  2. package/src/domain/interfaces/app-services-auth.interface.ts +27 -0
  3. package/src/domain/interfaces/app-services-composite.interface.ts +29 -0
  4. package/src/domain/interfaces/app-services-optional.interface.ts +42 -0
  5. package/src/domain/interfaces/app-services.interface.ts +0 -79
  6. package/src/domain/interfaces/index.ts +3 -0
  7. package/src/domains/background/infrastructure/services/job-poller-index.ts +7 -0
  8. package/src/domains/background/infrastructure/services/job-poller-utils.ts +127 -0
  9. package/src/domains/background/infrastructure/services/job-poller.service.ts +85 -140
  10. package/src/domains/background/infrastructure/utils/polling-interval.util.ts +1 -1
  11. package/src/domains/background/presentation/hooks/use-background-generation.ts +1 -1
  12. package/src/domains/content-moderation/index.ts +7 -13
  13. package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +1 -1
  14. package/src/domains/content-moderation/infrastructure/services/moderators/image.moderator.ts +34 -8
  15. package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +15 -4
  16. package/src/domains/content-moderation/infrastructure/services/moderators/video.moderator.ts +34 -8
  17. package/src/domains/content-moderation/infrastructure/services/moderators/voice.moderator.ts +19 -8
  18. package/src/domains/content-moderation/infrastructure/services/pattern-matcher.service.ts +1 -2
  19. package/src/domains/creations/domain/types/creation-categories.constants.ts +57 -0
  20. package/src/domains/creations/domain/types/creation-categories.helpers.ts +67 -0
  21. package/src/domains/creations/domain/types/creation-categories.ts +7 -114
  22. package/src/domains/creations/domain/utils/creation-display.util.ts +1 -1
  23. package/src/domains/creations/domain/utils/status-helpers.ts +1 -1
  24. package/src/domains/creations/presentation/hooks/creation-validators.ts +31 -29
  25. package/src/domains/creations/presentation/hooks/job-poller-index.ts +10 -0
  26. package/src/domains/creations/presentation/hooks/job-poller-utils.filters.ts +34 -0
  27. package/src/domains/creations/presentation/hooks/job-poller-utils.logger.ts +76 -0
  28. package/src/domains/creations/presentation/hooks/job-poller-utils.stale-handlers.ts +52 -0
  29. package/src/domains/creations/presentation/hooks/job-poller-utils.ts +8 -0
  30. package/src/domains/creations/presentation/hooks/useCreations.ts +1 -1
  31. package/src/domains/creations/presentation/hooks/useProcessingJobsPoller.ts +18 -235
  32. package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +1 -2
  33. package/src/domains/creations/presentation-exports.ts +2 -2
  34. package/src/domains/face-detection/domain/entities/FaceDetection.ts +4 -3
  35. package/src/domains/face-detection/presentation/hooks/useFaceDetection.ts +24 -21
  36. package/src/domains/generation/infrastructure/appearance-analysis/index.ts +5 -0
  37. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-preparation.ts +58 -0
  38. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-prompt.ts +69 -0
  39. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-resolution.ts +77 -0
  40. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple.ts +54 -0
  41. package/src/domains/generation/infrastructure/couple-generation-builder/builder-index.ts +8 -0
  42. package/src/domains/generation/infrastructure/couple-generation-builder/builder-scenario.ts +112 -0
  43. package/src/domains/generation/infrastructure/couple-generation-builder/builder.ts +7 -0
  44. package/src/domains/generation/infrastructure/couple-generation-builder/index.ts +20 -0
  45. package/src/domains/generation/infrastructure/couple-generation-builder/types.ts +44 -0
  46. package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-end-logger.ts +18 -0
  47. package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-start-logger.ts +57 -0
  48. package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-step-logger.ts +106 -0
  49. package/src/domains/generation/infrastructure/couple-generation-builder/utils/index.ts +8 -0
  50. package/src/domains/generation/infrastructure/couple-generation-builder/utils/types.ts +49 -0
  51. package/src/domains/generation/infrastructure/couple-generation-builder/utils.ts +8 -0
  52. package/src/domains/generation/infrastructure/flow/flow-store-actions.ts +105 -0
  53. package/src/domains/generation/infrastructure/flow/flow-store-initial-state.ts +26 -0
  54. package/src/domains/generation/infrastructure/flow/useFlowStore.ts +4 -116
  55. package/src/domains/generation/presentation/useAIGeneration.hook.ts +1 -1
  56. package/src/domains/generation/wizard/infrastructure/strategies/image-generation-strategy-index.ts +7 -0
  57. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts +2 -12
  58. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.types.ts +11 -0
  59. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.utils.ts +12 -0
  60. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +1 -220
  61. package/src/domains/generation/wizard/infrastructure/strategies/image-input-builder.ts +66 -0
  62. package/src/domains/generation/wizard/infrastructure/strategies/image-input-extraction.ts +88 -0
  63. package/src/domains/generation/wizard/infrastructure/strategies/image-input-prompt-builder.ts +74 -0
  64. package/src/domains/generation/wizard/infrastructure/strategies/image-input-style-enhancements.ts +35 -0
  65. package/src/domains/generation/wizard/infrastructure/strategies/image-strategy-factory.ts +41 -0
  66. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor-index.ts +10 -0
  67. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor.ts +76 -0
  68. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-input-builder.ts +46 -0
  69. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-result-types.ts +17 -0
  70. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-submission.ts +61 -0
  71. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.audio-extractor.ts +27 -0
  72. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts +2 -176
  73. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.input-builder.ts +90 -0
  74. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +3 -108
  75. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.types.ts +0 -130
  76. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.validation.ts +136 -0
  77. package/src/domains/generation/wizard/presentation/hooks/photo-upload/index.ts +40 -0
  78. package/src/domains/generation/wizard/presentation/hooks/photo-upload/types.ts +37 -0
  79. package/src/domains/generation/wizard/presentation/hooks/photo-upload/usePhotoUploadStateLogic.ts +142 -0
  80. package/src/domains/generation/wizard/presentation/hooks/use-video-queue-utils.ts +102 -0
  81. package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.handlers.ts +97 -0
  82. package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.saver.ts +54 -0
  83. package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.ts +22 -87
  84. package/src/domains/generation/wizard/presentation/hooks/usePhotoUploadState.ts +8 -177
  85. package/src/domains/generation/wizard/presentation/hooks/useVideoQueueGeneration.ts +1 -295
  86. package/src/domains/generation/wizard/presentation/hooks/useWizardGeneration.ts +1 -1
  87. package/src/domains/generation/wizard/presentation/hooks/video-queue/index.ts +77 -0
  88. package/src/domains/generation/wizard/presentation/hooks/video-queue/use-video-queue-utils.ts +123 -0
  89. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationCallbacks.ts +119 -0
  90. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationPolling.ts +75 -0
  91. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationRefs.ts +65 -0
  92. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationStart.ts +123 -0
  93. package/src/domains/generation/wizard/presentation/hooks/video-queue-index.ts +9 -0
  94. package/src/domains/image-to-video/domain/types/image-to-video-state.types.ts +11 -4
  95. package/src/domains/text-to-image/domain/constants/index.ts +5 -6
  96. package/src/domains/text-to-image/domain/types/text-to-image.types.ts +43 -22
  97. package/src/domains/text-to-video/domain/types/request.types.ts +32 -9
  98. package/src/domains/text-to-video/domain/types/state.types.ts +22 -22
  99. package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.handlers.ts +44 -0
  100. package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.ts +5 -51
  101. package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.types.ts +33 -0
  102. package/src/exports/features.ts +1 -1
  103. package/src/infrastructure/services/generation-orchestrator.service.ts +2 -2
  104. package/src/infrastructure/utils/couple-input-context.ts +13 -0
  105. package/src/infrastructure/utils/couple-input-index.ts +9 -0
  106. package/src/infrastructure/utils/couple-input-photorealistic.ts +40 -0
  107. package/src/infrastructure/utils/couple-input-refiner.ts +101 -0
  108. package/src/infrastructure/utils/couple-input-resolver.ts +71 -0
  109. package/src/infrastructure/utils/couple-input-types.ts +11 -0
  110. package/src/infrastructure/utils/couple-input.util.ts +3 -176
  111. package/src/infrastructure/utils/photo-generation/photo-preparation.util.ts +1 -1
  112. package/src/infrastructure/validation/base-validator.ts +3 -26
  113. package/src/infrastructure/validation/base-validator.types.ts +32 -0
  114. package/src/presentation/hooks/generation/index.ts +1 -1
  115. package/src/presentation/hooks/generation/orchestrator-abort-logs.ts +48 -0
  116. package/src/presentation/hooks/generation/orchestrator-execution-logs.ts +67 -0
  117. package/src/presentation/hooks/generation/orchestrator-index.ts +14 -0
  118. package/src/presentation/hooks/generation/orchestrator-start-logs.ts +65 -0
  119. package/src/presentation/hooks/generation/orchestrator-state-utils.ts +17 -0
  120. package/src/presentation/hooks/generation/orchestrator-types.ts +55 -0
  121. package/src/presentation/hooks/generation/orchestrator-utils-index.ts +29 -0
  122. package/src/presentation/hooks/generation/orchestrator-utils.ts +25 -0
  123. package/src/presentation/hooks/generation/useDualImageGeneration.ts +1 -1
  124. package/src/presentation/hooks/generation/useImageGeneration.ts +1 -1
  125. package/src/presentation/hooks/generation/useVideoGeneration.ts +1 -1
  126. package/src/shared/hooks/factories/generation-hook-index.ts +12 -0
  127. package/src/shared/hooks/factories/generation-hook-types.ts +47 -0
  128. package/src/shared/hooks/factories/generation-hook-utils.ts +94 -0
  129. package/src/shared/hooks/factories/index.ts +1 -1
  130. package/src/shared/index.ts +1 -1
  131. package/src/shared/utils/calculations/aspect-ratio-calculations.ts +30 -0
  132. package/src/shared/utils/calculations/base64-calculations.ts +26 -0
  133. package/src/shared/utils/calculations/confidence-calculations.ts +21 -0
  134. package/src/shared/utils/calculations/cost-calculations-index.ts +43 -0
  135. package/src/shared/utils/calculations/cost-calculations.ts +25 -0
  136. package/src/shared/utils/calculations/credit-calculations.ts +37 -0
  137. package/src/shared/utils/calculations/index.ts +46 -0
  138. package/src/shared/utils/calculations/math-utilities.ts +32 -0
  139. package/src/shared/utils/calculations/memory-calculations.ts +33 -0
  140. package/src/shared/utils/calculations/pagination-calculations.ts +38 -0
  141. package/src/shared/utils/calculations/percentage-calculations.ts +33 -0
  142. package/src/shared/utils/calculations/time-calculations.ts +99 -0
  143. package/src/shared/utils/credit.ts +1 -1
  144. package/src/shared-kernel/application/hooks/index.ts +8 -0
  145. package/src/shared-kernel/application/hooks/use-feature-state.ts +106 -0
  146. package/src/shared-kernel/application/hooks/use-generation-handler.ts +110 -0
  147. package/src/shared-kernel/base-types/base-callbacks.types.ts +73 -0
  148. package/src/shared-kernel/base-types/base-feature-state.types.ts +77 -0
  149. package/src/shared-kernel/base-types/base-generation.types.ts +69 -0
  150. package/src/shared-kernel/base-types/index.ts +30 -0
  151. package/src/shared-kernel/domain/base-generation-strategy.ts +146 -0
  152. package/src/shared-kernel/domain/index.ts +7 -0
  153. package/src/shared-kernel/index.ts +17 -0
  154. package/src/shared-kernel/infrastructure/validation/common-validators.ts +126 -0
  155. package/src/shared-kernel/infrastructure/validation/common-validators.types.ts +33 -0
  156. package/src/shared-kernel/infrastructure/validation/error-handler.ts +52 -0
  157. package/src/shared-kernel/infrastructure/validation/error-handler.types.ts +38 -0
  158. package/src/shared-kernel/infrastructure/validation/error-handler.utils.ts +79 -0
  159. package/src/shared-kernel/infrastructure/validation/index.ts +70 -0
  160. package/src/domains/content-moderation/infrastructure/services/index.ts +0 -8
  161. package/src/domains/creations/domain/constants/index.ts +0 -12
  162. package/src/domains/creations/domain/utils/index.ts +0 -12
  163. package/src/domains/generation/infrastructure/couple-generation-builder.ts +0 -374
  164. package/src/domains/image-to-video/domain/index.ts +0 -2
  165. package/src/domains/image-to-video/infrastructure/index.ts +0 -1
  166. package/src/domains/image-to-video/presentation/index.ts +0 -5
  167. package/src/domains/text-to-video/domain/index.ts +0 -1
  168. package/src/domains/text-to-video/presentation/index.ts +0 -7
  169. package/src/presentation/hooks/generation/orchestrator.ts +0 -276
  170. package/src/shared/hooks/factories/createGenerationHook.ts +0 -253
  171. package/src/shared/utils/calculations.util.ts +0 -366
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Couple Image Generation Builder - Prompt Processing
3
+ *
4
+ * Handles prompt refinement and final prompt creation
5
+ */
6
+
7
+ import {
8
+ prependContext,
9
+ refinePromptForCouple,
10
+ createPhotorealisticPrompt,
11
+ } from "../../../../infrastructure/utils/couple-input.util";
12
+ import { logBuilderStep } from "./utils";
13
+ import type { CoupleGenerationInputParams } from "./types";
14
+
15
+ export interface CouplePromptResult {
16
+ prompt: string;
17
+ refinedPrompt: string;
18
+ }
19
+
20
+ /**
21
+ * Process and refine prompt for couple generation
22
+ */
23
+ export function processCouplePrompt(
24
+ params: CoupleGenerationInputParams,
25
+ appearanceContext: string,
26
+ prefix: string = "[CoupleBuilder]",
27
+ ): CouplePromptResult {
28
+ const {
29
+ basePrompt,
30
+ customInstructions,
31
+ isCoupleMode,
32
+ } = params;
33
+
34
+ // 3. REFINE FOR COUPLE + PREPEND CONTEXT - Wardrobe mantığı
35
+ logBuilderStep(prefix, "STEP 3: REFINE & PREPEND CONTEXT", {
36
+ basePromptLength: basePrompt.length,
37
+ isCoupleMode
38
+ });
39
+
40
+ const refinedPrompt = prependContext(
41
+ refinePromptForCouple(basePrompt, isCoupleMode),
42
+ appearanceContext,
43
+ );
44
+
45
+ logBuilderStep(prefix, "Refined Prompt Result", {
46
+ refinedPromptLength: refinedPrompt.length,
47
+ refinedPromptPreview: refinedPrompt.substring(0, 300),
48
+ });
49
+
50
+ // 4. CREATE FINAL PROMPT - Photorealistic
51
+ logBuilderStep(prefix, "STEP 4: CREATE PHOTOREALISTIC PROMPT", {
52
+ isCouple: isCoupleMode,
53
+ hasCustomInstructions: !!customInstructions
54
+ });
55
+
56
+ const prompt = createPhotorealisticPrompt(refinedPrompt, {
57
+ isCouple: isCoupleMode,
58
+ customInstructions,
59
+ });
60
+
61
+ logBuilderStep(prefix, "Final Prompt Result", {
62
+ promptLength: prompt.length,
63
+ promptPreview: prompt.substring(0, 500),
64
+ hasCustomInstructions: !!customInstructions,
65
+ customInstructions,
66
+ });
67
+
68
+ return { prompt, refinedPrompt };
69
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Couple Image Generation Builder - Input Resolution
3
+ *
4
+ * Handles target resolution and final input building
5
+ */
6
+
7
+ import {
8
+ resolveCoupleInput,
9
+ } from "../../../../infrastructure/utils/couple-input.util";
10
+ import { logBuilderStep, logBuilderEnd } from "./utils";
11
+ import type {
12
+ CoupleGenerationInputParams,
13
+ CoupleGenerationInput,
14
+ } from "./types";
15
+
16
+ /**
17
+ * Build final couple generation input with resolved target and parameters
18
+ */
19
+ export function buildCoupleGenerationResult(
20
+ params: CoupleGenerationInputParams,
21
+ prompt: string,
22
+ prefix: string = "[CoupleBuilder]",
23
+ ): CoupleGenerationInput {
24
+ const {
25
+ partner1PhotoUri,
26
+ partner2PhotoUri,
27
+ isCoupleMode,
28
+ aspectRatio = "3:4",
29
+ strength,
30
+ } = params;
31
+
32
+ // 5. RESOLVE COUPLE INPUT - Doğru target ve image'lar
33
+ logBuilderStep(prefix, "STEP 5: RESOLVE COUPLE INPUT", {
34
+ partner1Uri: partner1PhotoUri,
35
+ partner2Uri: partner2PhotoUri,
36
+ isCoupleMode,
37
+ singleTarget: "p-image-edit/pruna",
38
+ coupleTarget: "p-image-edit/pruna"
39
+ });
40
+
41
+ const { target, imageUrls } = resolveCoupleInput(
42
+ partner1PhotoUri,
43
+ partner2PhotoUri,
44
+ isCoupleMode,
45
+ { model: "p-image-edit", providerId: "pruna" }, // Single target
46
+ { model: "p-image-edit", providerId: "pruna" }, // Couple target
47
+ );
48
+
49
+ logBuilderStep(prefix, "Target Resolution Result", {
50
+ targetModel: target.model,
51
+ targetProvider: target.providerId,
52
+ imageUrlsCount: imageUrls.length,
53
+ image1: imageUrls[0],
54
+ image2: imageUrls[1],
55
+ });
56
+
57
+ // 6. BUILD PARAMS - Wardrobe formatında
58
+ logBuilderStep(prefix, "STEP 6: BUILD PARAMS", {
59
+ prompt,
60
+ imageUrls,
61
+ aspectRatio,
62
+ strength,
63
+ });
64
+
65
+ logBuilderEnd(prefix);
66
+
67
+ return {
68
+ target,
69
+ prompt,
70
+ params: {
71
+ prompt,
72
+ image_urls: imageUrls,
73
+ aspect_ratio: aspectRatio,
74
+ ...(strength !== undefined && { strength }),
75
+ },
76
+ };
77
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Couple Image Generation Builder - Couple Generation
3
+ *
4
+ * Merkezi couple generation input builder
5
+ */
6
+
7
+ import type {
8
+ CoupleGenerationInputParams,
9
+ CoupleGenerationInput,
10
+ } from "./types";
11
+ import { logBuilderStart } from "./utils";
12
+ import { prepareCoupleGeneration } from "./builder-couple-preparation";
13
+ import { processCouplePrompt } from "./builder-couple-prompt";
14
+ import { buildCoupleGenerationResult } from "./builder-couple-resolution";
15
+
16
+ /**
17
+ * Merkezi couple generation input builder
18
+ *
19
+ * Wardrobe mantığını tüm couple generation için paylaştırır:
20
+ * 1. Appearance analysis (fotoğrafları analiz et)
21
+ * 2. Couple refinement (çift modu için iyileştir)
22
+ * 3. Context prepending (context'i prompt'a ekle)
23
+ * 4. Photorealistic prompt creation
24
+ * 5. Couple input resolution (doğru target ve image'lar)
25
+ *
26
+ * @param params - Generation parameters
27
+ * @returns Generation input with target, prompt, and params
28
+ */
29
+ export async function buildCoupleGenerationInput(
30
+ params: CoupleGenerationInputParams,
31
+ ): Promise<CoupleGenerationInput> {
32
+ const prefix = "[CoupleBuilder]";
33
+
34
+ logBuilderStart(prefix, {
35
+ isCoupleMode: params.isCoupleMode,
36
+ basePromptLength: params.basePrompt.length,
37
+ aspectRatio: params.aspectRatio,
38
+ hasPartner2: !!params.partner2PhotoUri,
39
+ hasCustomInstructions: !!params.customInstructions,
40
+ hasStrength: params.strength !== undefined,
41
+ strength: params.strength,
42
+ partner1Uri: params.partner1PhotoUri,
43
+ partner2Uri: params.partner2PhotoUri,
44
+ });
45
+
46
+ // Phase 1: Prepare photo URIs and analyze appearance
47
+ const { appearanceContext } = await prepareCoupleGeneration(params, prefix);
48
+
49
+ // Phase 2: Process and refine prompt
50
+ const { prompt } = processCouplePrompt(params, appearanceContext, prefix);
51
+
52
+ // Phase 3: Build final result with resolved target
53
+ return buildCoupleGenerationResult(params, prompt, prefix);
54
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Couple Image Generation Builder - Main Builder Functions
3
+ *
4
+ * Merkezi couple generation input builder
5
+ */
6
+
7
+ export { buildCoupleGenerationInput } from "./builder-couple";
8
+ export { buildScenarioGenerationInput } from "./builder-scenario";
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Couple Image Generation Builder - Scenario Generation
3
+ *
4
+ * Scenario generation için özel wrapper
5
+ */
6
+
7
+ import {
8
+ resolveCoupleInput,
9
+ refinePromptForCouple,
10
+ prependContext,
11
+ } from "../../../../infrastructure/utils/couple-input.util";
12
+ import { getAppearanceContext } from "../../appearance-analysis";
13
+ import type {
14
+ ScenarioGenerationInputParams,
15
+ CoupleGenerationInput,
16
+ } from "./types";
17
+ import { logBuilderStart, logBuilderStep, logBuilderEnd } from "./utils";
18
+
19
+ /**
20
+ * Scenario generation için özel wrapper
21
+ *
22
+ * Senaryo aiPrompt'larını (zaten createPhotorealisticPrompt ile oluşturulmuş)
23
+ * Wardrobe mantığı ile birleştirir.
24
+ */
25
+ export async function buildScenarioGenerationInput(
26
+ params: ScenarioGenerationInputParams,
27
+ ): Promise<CoupleGenerationInput> {
28
+
29
+ const {
30
+ partner1PhotoUri,
31
+ partner2PhotoUri,
32
+ isCoupleMode,
33
+ scenarioPrompt,
34
+ } = params;
35
+
36
+ logBuilderStart("[ScenarioBuilder]", {
37
+ isCoupleMode,
38
+ scenarioPromptLength: scenarioPrompt.length,
39
+ scenarioPromptPreview: scenarioPrompt.substring(0, 200),
40
+ partner1Uri: partner1PhotoUri,
41
+ partner2Uri: partner2PhotoUri,
42
+ });
43
+
44
+ // 1. GET PHOTO URIs
45
+ const photoUris =
46
+ isCoupleMode && partner2PhotoUri
47
+ ? [partner1PhotoUri, partner2PhotoUri]
48
+ : [partner1PhotoUri];
49
+
50
+ logBuilderStep("[ScenarioBuilder]", "STEP 1: PHOTO URIs", {
51
+ photoUrisCount: photoUris.length,
52
+ });
53
+
54
+ // 2. ANALYZE APPEARANCE
55
+ logBuilderStep("[ScenarioBuilder]", "STEP 2: APPEARANCE ANALYSIS");
56
+
57
+ const appearanceContext = await getAppearanceContext(
58
+ photoUris,
59
+ isCoupleMode,
60
+ );
61
+
62
+ logBuilderStep("[ScenarioBuilder]", "Appearance Analysis Result", {
63
+ contextLength: appearanceContext.length,
64
+ contextPreview: appearanceContext.length > 0 ? appearanceContext.substring(0, 150) : "No context (vision disabled)",
65
+ });
66
+
67
+ // 3. REFINE FOR COUPLE + PREPEND CONTEXT
68
+ logBuilderStep("[ScenarioBuilder]", "STEP 3: REFINE & PREPEND CONTEXT");
69
+
70
+ const refinedPrompt = refinePromptForCouple(scenarioPrompt, isCoupleMode);
71
+ const finalPrompt = prependContext(refinedPrompt, appearanceContext);
72
+
73
+ logBuilderStep("[ScenarioBuilder]", "Refined Prompt Result", {
74
+ refinedPromptLength: refinedPrompt.length,
75
+ finalPromptLength: finalPrompt.length,
76
+ finalPromptPreview: finalPrompt.substring(0, 300),
77
+ });
78
+
79
+ // 4. RESOLVE COUPLE INPUT
80
+ logBuilderStep("[ScenarioBuilder]", "STEP 4: RESOLVE COUPLE INPUT");
81
+
82
+ const { target, imageUrls } = resolveCoupleInput(
83
+ partner1PhotoUri,
84
+ partner2PhotoUri,
85
+ isCoupleMode,
86
+ { model: "p-image-edit", providerId: "pruna" }, // Single target
87
+ { model: "p-image-edit", providerId: "pruna" }, // Couple target
88
+ );
89
+
90
+ logBuilderStep("[ScenarioBuilder]", "Target Resolution Result", {
91
+ targetModel: target.model,
92
+ targetProvider: target.providerId,
93
+ imageUrlsCount: imageUrls.length,
94
+ });
95
+
96
+ // 5. BUILD PARAMS - Scenario formatında
97
+ logBuilderStep("[ScenarioBuilder]", "STEP 5: BUILD PARAMS", {
98
+ aspectRatio: "3:4"
99
+ });
100
+
101
+ logBuilderEnd("[ScenarioBuilder]");
102
+
103
+ return {
104
+ target,
105
+ prompt: finalPrompt,
106
+ params: {
107
+ prompt: finalPrompt,
108
+ image_urls: imageUrls,
109
+ aspect_ratio: "3:4",
110
+ },
111
+ };
112
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Couple Image Generation Builder - Main Builder Functions
3
+ *
4
+ * Merkezi couple generation input builder
5
+ */
6
+
7
+ export { buildCoupleGenerationInput, buildScenarioGenerationInput } from "./builder-index";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Couple Image Generation Builder
3
+ *
4
+ * Wardrobe'da kusursuz çalışan mantığı tüm couple generation için paylaştırır.
5
+ * Bu utility'yi tüm çift görüntü oluşturma işlemleri kullanır.
6
+ *
7
+ * Kullanım alanları:
8
+ * - Senaryo generation (Home couple images)
9
+ * - Wardrobe generation
10
+ * - Background generation
11
+ * - Art style generation
12
+ * - Mood filter generation
13
+ */
14
+
15
+ export type {
16
+ CoupleGenerationInputParams,
17
+ CoupleGenerationInput,
18
+ ScenarioGenerationInputParams,
19
+ } from "./types";
20
+ export { buildCoupleGenerationInput, buildScenarioGenerationInput } from "./builder";
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Couple Image Generation Builder - Type Definitions
3
+ *
4
+ * Wardrobe'da kusursuz çalışan mantığı tüm couple generation için paylaştırır.
5
+ * Bu utility'yi tüm çift görüntü oluşturma işlemleri kullanır.
6
+ */
7
+
8
+ import type { GenerationTargetLike } from "../../../../infrastructure/utils/couple-input.util";
9
+
10
+ /**
11
+ * Couple generation input parameters
12
+ */
13
+ export interface CoupleGenerationInputParams {
14
+ // Required params
15
+ partner1PhotoUri: string;
16
+ partner2PhotoUri: string | null;
17
+ isCoupleMode: boolean;
18
+ basePrompt: string; // Scenario prompt, wardrobe prompt, background prompt, etc.
19
+
20
+ // Optional params
21
+ customInstructions?: string;
22
+ aspectRatio?: string; // Default: "3:4"
23
+ strength?: number; // Optional strength for some operations
24
+ }
25
+
26
+ /**
27
+ * Couple generation result
28
+ */
29
+ export interface CoupleGenerationInput {
30
+ target: GenerationTargetLike;
31
+ prompt: string;
32
+ params: Record<string, unknown>;
33
+ }
34
+
35
+ /**
36
+ * Scenario generation input parameters
37
+ */
38
+ export interface ScenarioGenerationInputParams {
39
+ partner1PhotoUri: string;
40
+ partner2PhotoUri: string | null;
41
+ isCoupleMode: boolean;
42
+ scenarioPrompt: string; // Senaryo prompt'u (aiPrompt)
43
+ customInstructions?: string;
44
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Couple Image Generation Builder - End Logger
3
+ */
4
+
5
+ const DEV = typeof __DEV__ !== "undefined" && __DEV__;
6
+
7
+ /**
8
+ * Log builder end
9
+ */
10
+ export function logBuilderEnd(prefix: string): void {
11
+ if (!DEV) return;
12
+
13
+ console.log(`${prefix} ========================================`);
14
+ console.log(`${prefix} ===== BUILD COUPLE GENERATION END =====`);
15
+ console.log(`${prefix} ========================================`);
16
+ console.log(`${prefix} Returning: { target, prompt, params }`);
17
+ console.log("");
18
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Couple Image Generation Builder - Start Logger
3
+ */
4
+
5
+ import type { BuilderStartParams } from "./types";
6
+
7
+ const DEV = typeof __DEV__ !== "undefined" && __DEV__;
8
+
9
+ /**
10
+ * Log builder start with parameters
11
+ */
12
+ export function logBuilderStart(
13
+ prefix: string,
14
+ params: BuilderStartParams
15
+ ): void {
16
+ if (!DEV) return;
17
+
18
+ console.log(`${prefix} ========================================`);
19
+ console.log(`${prefix} ===== BUILD COUPLE GENERATION START =====`);
20
+ console.log(`${prefix} ========================================`);
21
+ console.log(`${prefix} ===== INPUT PARAMS =====`);
22
+
23
+ if (params.isCoupleMode !== undefined) {
24
+ console.log(`${prefix} Is couple mode:`, params.isCoupleMode);
25
+ }
26
+ if (params.basePromptLength !== undefined) {
27
+ console.log(`${prefix} Base prompt length:`, params.basePromptLength);
28
+ console.log(`${prefix} Base prompt preview:`, params.basePromptLength.toString().substring(0, 200) + "...");
29
+ }
30
+ if (params.scenarioPromptLength !== undefined) {
31
+ console.log(`${prefix} Scenario prompt length:`, params.scenarioPromptLength);
32
+ }
33
+ if (params.scenarioPromptPreview !== undefined) {
34
+ console.log(`${prefix} Scenario prompt preview:`, params.scenarioPromptPreview);
35
+ }
36
+ if (params.aspectRatio !== undefined) {
37
+ console.log(`${prefix} Aspect ratio:`, params.aspectRatio);
38
+ }
39
+ if (params.hasPartner2 !== undefined) {
40
+ console.log(`${prefix} Has partner 2:`, params.hasPartner2);
41
+ }
42
+ if (params.hasCustomInstructions !== undefined) {
43
+ console.log(`${prefix} Has custom instructions:`, params.hasCustomInstructions);
44
+ }
45
+ if (params.hasStrength !== undefined) {
46
+ console.log(`${prefix} Has strength:`, params.hasStrength);
47
+ }
48
+ if (params.strength !== undefined) {
49
+ console.log(`${prefix} Strength value:`, params.strength);
50
+ }
51
+ if (params.partner1Uri !== undefined) {
52
+ console.log(`${prefix} Partner 1 URI:`, params.partner1Uri.substring(0, 80) + "...");
53
+ }
54
+ if (params.partner2Uri !== undefined) {
55
+ console.log(`${prefix} Partner 2 URI:`, params.partner2Uri.substring(0, 80) + "...");
56
+ }
57
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Couple Image Generation Builder - Step Logger
3
+ */
4
+
5
+ import type { BuilderStepParams } from "./types";
6
+
7
+ const DEV = typeof __DEV__ !== "undefined" && __DEV__;
8
+
9
+ /**
10
+ * Log builder step with details
11
+ */
12
+ export function logBuilderStep(
13
+ prefix: string,
14
+ stepName: string,
15
+ params: BuilderStepParams = {}
16
+ ): void {
17
+ if (!DEV) return;
18
+
19
+ console.log(`${prefix} ===== ${stepName} =====`);
20
+
21
+ if (params.photoUrisCount !== undefined) {
22
+ console.log(`${prefix} Photo URIs count:`, params.photoUrisCount);
23
+ }
24
+ if (params.photo1 !== undefined) {
25
+ console.log(`${prefix} Photo 1:`, params.photo1.substring(0, 60) + "...");
26
+ }
27
+ if (params.photo2 !== undefined) {
28
+ console.log(`${prefix} Photo 2:`, params.photo2.substring(0, 60) + "...");
29
+ }
30
+ if (params.photoCount !== undefined) {
31
+ console.log(`${prefix} Photo count:`, params.photoCount);
32
+ }
33
+ if (params.isCoupleMode !== undefined) {
34
+ console.log(`${prefix} Is couple mode:`, params.isCoupleMode);
35
+ }
36
+ if (params.basePromptLength !== undefined) {
37
+ console.log(`${prefix} Base prompt length:`, params.basePromptLength);
38
+ }
39
+ if (params.contextLength !== undefined) {
40
+ console.log(`${prefix} Appearance context length:`, params.contextLength);
41
+ }
42
+ if (params.contextPreview !== undefined) {
43
+ if (params.contextPreview.length > 0) {
44
+ console.log(`${prefix} Appearance context preview:`, params.contextPreview + "...");
45
+ } else {
46
+ console.log(`${prefix} ℹ️ No appearance context returned (vision disabled)`);
47
+ }
48
+ }
49
+ if (params.refinedPromptLength !== undefined) {
50
+ console.log(`${prefix} Refined prompt length:`, params.refinedPromptLength);
51
+ }
52
+ if (params.refinedPromptPreview !== undefined) {
53
+ console.log(`${prefix} Refined prompt preview:`, params.refinedPromptPreview + "...");
54
+ }
55
+ if (params.finalPromptLength !== undefined) {
56
+ console.log(`${prefix} Final prompt length:`, params.finalPromptLength);
57
+ }
58
+ if (params.finalPromptPreview !== undefined) {
59
+ console.log(`${prefix} Final prompt preview:`, params.finalPromptPreview + "...");
60
+ }
61
+ if (params.promptLength !== undefined) {
62
+ console.log(`${prefix} Prompt length:`, params.promptLength);
63
+ }
64
+ if (params.promptPreview !== undefined) {
65
+ console.log(`${prefix} Prompt preview:`, params.promptPreview + "...");
66
+ }
67
+ if (params.hasCustomInstructions !== undefined) {
68
+ console.log(`${prefix} Has custom instructions:`, params.hasCustomInstructions);
69
+ }
70
+ if (params.customInstructions !== undefined) {
71
+ console.log(`${prefix} Custom instructions:`, params.customInstructions);
72
+ }
73
+ if (params.partner1Uri !== undefined) {
74
+ console.log(`${prefix} Partner 1 URI:`, params.partner1Uri.substring(0, 50) + "...");
75
+ }
76
+ if (params.partner2Uri !== undefined) {
77
+ console.log(`${prefix} Partner 2 URI:`, params.partner2Uri ? params.partner2Uri.substring(0, 50) + "..." : null);
78
+ }
79
+ if (params.singleTarget !== undefined) {
80
+ console.log(`${prefix} Single target:`, params.singleTarget);
81
+ }
82
+ if (params.coupleTarget !== undefined) {
83
+ console.log(`${prefix} Couple target:`, params.coupleTarget);
84
+ }
85
+ if (params.targetModel !== undefined) {
86
+ console.log(`${prefix} Target model:`, params.targetModel);
87
+ }
88
+ if (params.targetProvider !== undefined) {
89
+ console.log(`${prefix} Target provider:`, params.targetProvider);
90
+ }
91
+ if (params.imageUrlsCount !== undefined) {
92
+ console.log(`${prefix} Image URLs count:`, params.imageUrlsCount);
93
+ }
94
+ if (params.image1 !== undefined) {
95
+ console.log(`${prefix} Image 1:`, params.image1.substring(0, 80) + "...");
96
+ }
97
+ if (params.image2 !== undefined) {
98
+ console.log(`${prefix} Image 2:`, params.image2?.substring(0, 80) + "...");
99
+ }
100
+ if (params.aspectRatio !== undefined) {
101
+ console.log(`${prefix} Aspect ratio:`, params.aspectRatio);
102
+ }
103
+ if (params.strength !== undefined) {
104
+ console.log(`${prefix} Strength:`, params.strength);
105
+ }
106
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Couple Image Generation Builder - Utility Functions
3
+ */
4
+
5
+ export { logBuilderStart } from "./builder-start-logger";
6
+ export { logBuilderStep } from "./builder-step-logger";
7
+ export { logBuilderEnd } from "./builder-end-logger";
8
+ export type { BuilderStartParams, BuilderStepParams } from "./types";
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Couple Image Generation Builder - Type Definitions
3
+ */
4
+
5
+ export interface BuilderStartParams {
6
+ isCoupleMode?: boolean;
7
+ basePromptLength?: number;
8
+ scenarioPromptLength?: number;
9
+ aspectRatio?: string;
10
+ hasPartner2?: boolean;
11
+ hasCustomInstructions?: boolean;
12
+ hasStrength?: boolean;
13
+ strength?: number;
14
+ partner1Uri?: string;
15
+ partner2Uri?: string;
16
+ scenarioPromptPreview?: string;
17
+ }
18
+
19
+ export interface BuilderStepParams {
20
+ photoUrisCount?: number;
21
+ photo1?: string;
22
+ photo2?: string;
23
+ photoCount?: number;
24
+ isCoupleMode?: boolean;
25
+ basePromptLength?: number;
26
+ contextLength?: number;
27
+ contextPreview?: string;
28
+ refinedPromptLength?: number;
29
+ refinedPromptPreview?: string;
30
+ finalPromptLength?: number;
31
+ finalPromptPreview?: string;
32
+ promptLength?: number;
33
+ promptPreview?: string;
34
+ hasCustomInstructions?: boolean;
35
+ customInstructions?: string;
36
+ partner1Uri?: string;
37
+ partner2Uri?: string;
38
+ singleTarget?: string;
39
+ coupleTarget?: string;
40
+ targetModel?: string;
41
+ targetProvider?: string;
42
+ imageUrlsCount?: number;
43
+ image1?: string;
44
+ image2?: string;
45
+ prompt?: string;
46
+ imageUrls?: string[];
47
+ aspectRatio?: string;
48
+ strength?: number;
49
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Couple Image Generation Builder - Utility Functions
3
+ *
4
+ * Logging and helper functions for the couple generation builder
5
+ */
6
+
7
+ export { logBuilderStart, logBuilderStep, logBuilderEnd } from "./utils/index";
8
+ export type { BuilderStartParams, BuilderStepParams } from "./utils/types";