@umituz/react-native-ai-generation-content 1.90.1 → 1.90.3

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 (152) hide show
  1. package/package.json +1 -4
  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/domains/background/infrastructure/services/job-poller-index.ts +7 -0
  7. package/src/domains/background/infrastructure/services/job-poller-utils.ts +130 -0
  8. package/src/domains/background/infrastructure/utils/polling-interval.util.ts +1 -1
  9. package/src/domains/background/presentation/hooks/use-background-generation.ts +1 -1
  10. package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +1 -1
  11. package/src/domains/content-moderation/infrastructure/services/moderators/image.moderator.ts +34 -8
  12. package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +15 -4
  13. package/src/domains/content-moderation/infrastructure/services/moderators/video.moderator.ts +34 -8
  14. package/src/domains/content-moderation/infrastructure/services/moderators/voice.moderator.ts +19 -8
  15. package/src/domains/creations/domain/types/creation-categories.constants.ts +57 -0
  16. package/src/domains/creations/domain/types/creation-categories.helpers.ts +67 -0
  17. package/src/domains/creations/domain/types/creation-categories.ts +5 -111
  18. package/src/domains/creations/presentation/hooks/creation-validators.ts +31 -29
  19. package/src/domains/creations/presentation/hooks/job-poller-index.ts +10 -0
  20. package/src/domains/creations/presentation/hooks/job-poller-utils.filters.ts +34 -0
  21. package/src/domains/creations/presentation/hooks/job-poller-utils.logger.ts +76 -0
  22. package/src/domains/creations/presentation/hooks/job-poller-utils.stale-handlers.ts +52 -0
  23. package/src/domains/creations/presentation/hooks/job-poller-utils.ts +8 -0
  24. package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +1 -1
  25. package/src/domains/creations/presentation-exports.ts +2 -2
  26. package/src/domains/face-detection/domain/entities/FaceDetection.ts +4 -3
  27. package/src/domains/face-detection/presentation/hooks/useFaceDetection.ts +24 -21
  28. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-preparation.ts +58 -0
  29. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-prompt.ts +69 -0
  30. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-resolution.ts +77 -0
  31. package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple.ts +54 -0
  32. package/src/domains/generation/infrastructure/couple-generation-builder/builder-index.ts +8 -0
  33. package/src/domains/generation/infrastructure/couple-generation-builder/builder-scenario.ts +113 -0
  34. package/src/domains/generation/infrastructure/couple-generation-builder/builder.ts +7 -0
  35. package/src/domains/generation/infrastructure/couple-generation-builder/index.ts +20 -0
  36. package/src/domains/generation/infrastructure/couple-generation-builder/types.ts +44 -0
  37. package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-end-logger.ts +18 -0
  38. package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-start-logger.ts +57 -0
  39. package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-step-logger.ts +106 -0
  40. package/src/domains/generation/infrastructure/couple-generation-builder/utils/index.ts +8 -0
  41. package/src/domains/generation/infrastructure/couple-generation-builder/utils/types.ts +49 -0
  42. package/src/domains/generation/infrastructure/couple-generation-builder/utils.ts +8 -0
  43. package/src/domains/generation/infrastructure/flow/flow-store-actions.ts +105 -0
  44. package/src/domains/generation/infrastructure/flow/flow-store-initial-state.ts +26 -0
  45. package/src/domains/generation/infrastructure/flow/useFlowStore.ts +4 -116
  46. package/src/domains/generation/presentation/useAIGeneration.hook.ts +1 -1
  47. package/src/domains/generation/wizard/infrastructure/strategies/image-generation-strategy-index.ts +7 -0
  48. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts +2 -12
  49. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.types.ts +11 -0
  50. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.utils.ts +12 -0
  51. package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +1 -220
  52. package/src/domains/generation/wizard/infrastructure/strategies/image-input-builder.ts +66 -0
  53. package/src/domains/generation/wizard/infrastructure/strategies/image-input-extraction.ts +88 -0
  54. package/src/domains/generation/wizard/infrastructure/strategies/image-input-prompt-builder.ts +75 -0
  55. package/src/domains/generation/wizard/infrastructure/strategies/image-input-style-enhancements.ts +35 -0
  56. package/src/domains/generation/wizard/infrastructure/strategies/image-strategy-factory.ts +42 -0
  57. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor-index.ts +11 -0
  58. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor.ts +76 -0
  59. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-input-builder.ts +46 -0
  60. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-result-types.ts +17 -0
  61. package/src/domains/generation/wizard/infrastructure/strategies/video-generation-submission.ts +62 -0
  62. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.audio-extractor.ts +27 -0
  63. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts +2 -175
  64. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.input-builder.ts +90 -0
  65. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +3 -108
  66. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.types.ts +0 -129
  67. package/src/domains/generation/wizard/infrastructure/strategies/video-generation.validation.ts +136 -0
  68. package/src/domains/generation/wizard/presentation/hooks/photo-upload/index.ts +39 -0
  69. package/src/domains/generation/wizard/presentation/hooks/photo-upload/types.ts +37 -0
  70. package/src/domains/generation/wizard/presentation/hooks/photo-upload/usePhotoUploadStateLogic.ts +142 -0
  71. package/src/domains/generation/wizard/presentation/hooks/use-video-queue-utils.ts +103 -0
  72. package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.handlers.ts +97 -0
  73. package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.saver.ts +54 -0
  74. package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.ts +22 -87
  75. package/src/domains/generation/wizard/presentation/hooks/usePhotoUploadState.ts +8 -177
  76. package/src/domains/generation/wizard/presentation/hooks/useVideoQueueGeneration.ts +1 -295
  77. package/src/domains/generation/wizard/presentation/hooks/useWizardGeneration.ts +1 -1
  78. package/src/domains/generation/wizard/presentation/hooks/video-queue/index.ts +82 -0
  79. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationCallbacks.ts +120 -0
  80. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationPolling.ts +76 -0
  81. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationRefs.ts +65 -0
  82. package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationStart.ts +123 -0
  83. package/src/domains/generation/wizard/presentation/hooks/video-queue-index.ts +9 -0
  84. package/src/domains/image-to-video/domain/types/image-to-video-state.types.ts +11 -4
  85. package/src/domains/text-to-image/domain/types/text-to-image.types.ts +44 -22
  86. package/src/domains/text-to-video/domain/types/request.types.ts +33 -9
  87. package/src/domains/text-to-video/domain/types/state.types.ts +29 -9
  88. package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.handlers.ts +44 -0
  89. package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.ts +5 -51
  90. package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.types.ts +33 -0
  91. package/src/infrastructure/services/generation-orchestrator.service.ts +2 -2
  92. package/src/infrastructure/utils/couple-input-context.ts +13 -0
  93. package/src/infrastructure/utils/couple-input-index.ts +8 -0
  94. package/src/infrastructure/utils/couple-input-refiner.ts +101 -0
  95. package/src/infrastructure/utils/couple-input-resolver.ts +71 -0
  96. package/src/infrastructure/utils/couple-input-types.ts +14 -0
  97. package/src/infrastructure/utils/couple-input.util.ts +3 -176
  98. package/src/infrastructure/utils/photo-generation/photo-preparation.util.ts +1 -1
  99. package/src/infrastructure/validation/base-validator.ts +1 -27
  100. package/src/infrastructure/validation/base-validator.types.ts +32 -0
  101. package/src/presentation/hooks/generation/index.ts +1 -1
  102. package/src/presentation/hooks/generation/orchestrator-abort-logs.ts +48 -0
  103. package/src/presentation/hooks/generation/orchestrator-execution-logs.ts +67 -0
  104. package/src/presentation/hooks/generation/orchestrator-index.ts +14 -0
  105. package/src/presentation/hooks/generation/orchestrator-start-logs.ts +65 -0
  106. package/src/presentation/hooks/generation/orchestrator-state-utils.ts +17 -0
  107. package/src/presentation/hooks/generation/orchestrator-types.ts +55 -0
  108. package/src/presentation/hooks/generation/orchestrator-utils-index.ts +29 -0
  109. package/src/presentation/hooks/generation/orchestrator-utils.ts +25 -0
  110. package/src/presentation/hooks/generation/useDualImageGeneration.ts +1 -1
  111. package/src/presentation/hooks/generation/useImageGeneration.ts +1 -1
  112. package/src/presentation/hooks/generation/useVideoGeneration.ts +1 -1
  113. package/src/shared/hooks/factories/generation-hook-index.ts +12 -0
  114. package/src/shared/hooks/factories/generation-hook-types.ts +47 -0
  115. package/src/shared/hooks/factories/generation-hook-utils.ts +94 -0
  116. package/src/shared/hooks/factories/index.ts +1 -1
  117. package/src/shared/index.ts +1 -1
  118. package/src/shared/utils/calculations/aspect-ratio-calculations.ts +30 -0
  119. package/src/shared/utils/calculations/base64-calculations.ts +26 -0
  120. package/src/shared/utils/calculations/confidence-calculations.ts +21 -0
  121. package/src/shared/utils/calculations/cost-calculations-index.ts +43 -0
  122. package/src/shared/utils/calculations/cost-calculations.ts +25 -0
  123. package/src/shared/utils/calculations/credit-calculations.ts +37 -0
  124. package/src/shared/utils/calculations/index.ts +46 -0
  125. package/src/shared/utils/calculations/math-utilities.ts +32 -0
  126. package/src/shared/utils/calculations/memory-calculations.ts +33 -0
  127. package/src/shared/utils/calculations/pagination-calculations.ts +38 -0
  128. package/src/shared/utils/calculations/percentage-calculations.ts +33 -0
  129. package/src/shared/utils/calculations/time-calculations.ts +99 -0
  130. package/src/shared/utils/credit.ts +1 -1
  131. package/src/shared-kernel/application/hooks/index.ts +8 -0
  132. package/src/shared-kernel/application/hooks/use-feature-state.ts +107 -0
  133. package/src/shared-kernel/application/hooks/use-generation-handler.ts +110 -0
  134. package/src/shared-kernel/base-types/base-callbacks.types.ts +73 -0
  135. package/src/shared-kernel/base-types/base-feature-state.types.ts +77 -0
  136. package/src/shared-kernel/base-types/base-generation.types.ts +69 -0
  137. package/src/shared-kernel/base-types/index.ts +30 -0
  138. package/src/shared-kernel/domain/base-generation-strategy.ts +146 -0
  139. package/src/shared-kernel/domain/index.ts +7 -0
  140. package/src/shared-kernel/index.ts +17 -0
  141. package/src/shared-kernel/infrastructure/validation/common-validators.ts +126 -0
  142. package/src/shared-kernel/infrastructure/validation/common-validators.types.ts +33 -0
  143. package/src/shared-kernel/infrastructure/validation/error-handler.ts +52 -0
  144. package/src/shared-kernel/infrastructure/validation/error-handler.types.ts +38 -0
  145. package/src/shared-kernel/infrastructure/validation/error-handler.utils.ts +79 -0
  146. package/src/shared-kernel/infrastructure/validation/index.ts +28 -0
  147. package/src/domains/background/infrastructure/services/job-poller.service.ts +0 -234
  148. package/src/domains/creations/presentation/hooks/useProcessingJobsPoller.ts +0 -256
  149. package/src/domains/generation/infrastructure/couple-generation-builder.ts +0 -374
  150. package/src/presentation/hooks/generation/orchestrator.ts +0 -276
  151. package/src/shared/hooks/factories/createGenerationHook.ts +0 -253
  152. package/src/shared/utils/calculations.util.ts +0 -366
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Video Queue Generation Hook - Start Generation Logic
3
+ */
4
+
5
+ import { useCallback } from "react";
6
+ import {
7
+ DEFAULT_POLL_INTERVAL_MS,
8
+ } from "../../../../../infrastructure/constants/polling.constants";
9
+ import { extractInputMetadata } from "./use-video-queue-utils";
10
+ import type {
11
+ UseVideoQueueGenerationProps,
12
+ } from "../use-video-queue-generation.types";
13
+ import type { VideoQueueRefs, VideoQueueState } from "./useVideoQueueGenerationRefs";
14
+
15
+ /**
16
+ * Create start generation callback
17
+ */
18
+ export function useStartGeneration(
19
+ props: UseVideoQueueGenerationProps,
20
+ refs: VideoQueueRefs,
21
+ state: VideoQueueState,
22
+ clearPolling: () => void,
23
+ ): (input: unknown, prompt: string) => Promise<void> {
24
+ const { userId, scenario, persistence, strategy, creditCost, onError } = props;
25
+ const { setIsGenerating } = state;
26
+ const { creationIdRef, requestIdRef, modelRef, pollStartTimeRef, isGeneratingRef, pollingRef, pollStatusRef } = refs;
27
+
28
+ return useCallback(
29
+ async (input: unknown, prompt: string) => {
30
+ if (!strategy.submitToQueue) {
31
+ onError?.("Queue submission not available");
32
+ return;
33
+ }
34
+ if (isGeneratingRef.current) return;
35
+
36
+ isGeneratingRef.current = true;
37
+ setIsGenerating(true);
38
+
39
+ let creationId: string | null = null;
40
+ if (userId && prompt) {
41
+ try {
42
+ const { duration, resolution, aspectRatio } = extractInputMetadata(input);
43
+
44
+ const result = await persistence.saveAsProcessing(userId, {
45
+ scenarioId: scenario.id,
46
+ scenarioTitle: scenario.title || scenario.id,
47
+ prompt,
48
+ duration,
49
+ resolution,
50
+ creditCost,
51
+ aspectRatio,
52
+ provider: "fal",
53
+ outputType: scenario.outputType,
54
+ });
55
+ creationId = result.creationId;
56
+ creationIdRef.current = creationId;
57
+ // Record the actual DB-level start time for accurate durationMs
58
+ pollStartTimeRef.current = result.startedAt.getTime();
59
+ } catch (error) {
60
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
61
+ console.error("[VideoQueue] Failed to save processing creation:", error);
62
+ }
63
+ }
64
+ }
65
+
66
+ let queueResult;
67
+ try {
68
+ queueResult = await strategy.submitToQueue(input);
69
+ } catch (error) {
70
+ if (creationId && userId) {
71
+ try {
72
+ await persistence.updateToFailed(userId, creationId, error instanceof Error ? error.message : "Queue submission failed");
73
+ } catch (persistError) {
74
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
75
+ console.error("[VideoQueue] Failed to persist submission error:", persistError);
76
+ }
77
+ }
78
+ }
79
+ isGeneratingRef.current = false;
80
+ setIsGenerating(false);
81
+ onError?.(error instanceof Error ? error.message : "Queue submission failed");
82
+ return;
83
+ }
84
+
85
+ if (!queueResult.success || !queueResult.requestId || !queueResult.model) {
86
+ if (creationId && userId) {
87
+ try {
88
+ await persistence.updateToFailed(userId, creationId, queueResult.error || "Queue submission failed");
89
+ } catch (persistError) {
90
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
91
+ console.error("[VideoQueue] Failed to persist queue failure:", persistError);
92
+ }
93
+ }
94
+ }
95
+ isGeneratingRef.current = false;
96
+ setIsGenerating(false);
97
+ onError?.(queueResult.error || "Queue submission failed");
98
+ return;
99
+ }
100
+
101
+ requestIdRef.current = queueResult.requestId;
102
+ modelRef.current = queueResult.model;
103
+
104
+ if (creationId && userId && queueResult.requestId && queueResult.model) {
105
+ try {
106
+ await persistence.updateRequestId(userId, creationId, queueResult.requestId, queueResult.model);
107
+ } catch (error) {
108
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
109
+ console.error("[VideoQueue] Failed to update request ID:", error);
110
+ }
111
+ }
112
+ }
113
+
114
+ // Start polling: use DB-level startedAt if available, otherwise fallback to now
115
+ if (pollStartTimeRef.current === null) {
116
+ pollStartTimeRef.current = Date.now();
117
+ }
118
+ pollingRef.current = setInterval(() => void pollStatusRef.current(), DEFAULT_POLL_INTERVAL_MS);
119
+ void pollStatusRef.current();
120
+ },
121
+ [userId, scenario, persistence, strategy, creditCost, onError, setIsGenerating, creationIdRef, requestIdRef, modelRef, pollStartTimeRef, isGeneratingRef, pollingRef, pollStatusRef],
122
+ );
123
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Video Queue Generation Hook
3
+ */
4
+
5
+ export { useVideoQueueGeneration } from "./useVideoQueueGeneration";
6
+ export type {
7
+ UseVideoQueueGenerationProps,
8
+ UseVideoQueueGenerationReturn,
9
+ } from "./use-video-queue-generation.types";
@@ -1,17 +1,24 @@
1
1
  /**
2
2
  * Image-to-Video State Types
3
+ * Refactored to use shared kernel types
3
4
  */
4
5
 
5
- export interface ImageToVideoFeatureState {
6
+ import type { BaseFeatureState } from '../../../../shared-kernel/base-types';
7
+
8
+ /**
9
+ * Image-to-video feature state
10
+ * Extends base feature state with image-specific fields
11
+ */
12
+ export interface ImageToVideoFeatureState extends BaseFeatureState {
6
13
  imageUri: string | null;
7
14
  motionPrompt: string;
8
15
  videoUrl: string | null;
9
16
  thumbnailUrl: string | null;
10
- isProcessing: boolean;
11
- progress: number;
12
- error: string | null;
13
17
  }
14
18
 
19
+ /**
20
+ * Image-to-video translations
21
+ */
15
22
  export interface ImageToVideoTranslations {
16
23
  uploadTitle: string;
17
24
  uploadSubtitle: string;
@@ -1,58 +1,80 @@
1
1
  /**
2
2
  * Text-to-Image Feature Types
3
- * Request, Result, Config types for text-to-image generation
3
+ * Refactored to use shared kernel types
4
4
  */
5
5
 
6
- export interface TextToImageOptions {
7
- aspectRatio?: "16:9" | "9:16" | "1:1";
8
- size?: "512x512" | "768x768" | "1024x1024" | "1024x1792" | "1792x1024";
6
+ import type {
7
+ AspectRatio,
8
+ BaseGenerationOptions,
9
+ BaseGenerationResult,
10
+ BaseRequestMeta,
11
+ BaseFeatureState,
12
+ BaseGenerationCallbacks,
13
+ } from '../../../../shared-kernel/base-types';
14
+
15
+ /**
16
+ * Text-to-image specific options
17
+ * Extends base options with image-specific fields
18
+ */
19
+ export interface TextToImageOptions extends BaseGenerationOptions {
20
+ /** Image size dimensions */
21
+ size?: '512x512' | '768x768' | '1024x1024' | '1024x1792' | '1792x1024';
22
+ /** Number of images to generate */
9
23
  numImages?: number;
10
- guidanceScale?: number;
11
- seed?: number;
12
24
  }
13
25
 
26
+ /**
27
+ * Text-to-image request
28
+ * Uses base metadata from shared kernel
29
+ */
14
30
  export interface TextToImageRequest {
15
31
  prompt: string;
16
- userId: string;
17
32
  negativePrompt?: string;
18
33
  options?: TextToImageOptions;
34
+ meta: BaseRequestMeta;
19
35
  }
20
36
 
21
- export interface TextToImageResult {
22
- success: boolean;
37
+ /**
38
+ * Text-to-image result
39
+ * Extends base result with image-specific output
40
+ */
41
+ export interface TextToImageResult extends BaseGenerationResult<string | string[]> {
23
42
  imageUrl?: string;
24
43
  imageUrls?: string[];
25
- error?: string;
26
- requestId?: string;
27
44
  }
28
45
 
29
- export interface TextToImageFeatureState {
46
+ /**
47
+ * Text-to-image feature state
48
+ * Extends base feature state with prompt field
49
+ */
50
+ export interface TextToImageFeatureState extends BaseFeatureState<string | string[]> {
30
51
  prompt: string;
31
- imageUrl: string | null;
32
- imageUrls: string[];
33
- isProcessing: boolean;
34
- progress: number;
35
- error: string | null;
36
52
  }
37
53
 
38
-
54
+ /**
55
+ * Input builder type
56
+ */
39
57
  export type TextToImageInputBuilder = (
40
58
  prompt: string,
41
59
  options?: TextToImageOptions,
42
60
  ) => Record<string, unknown>;
43
61
 
62
+ /**
63
+ * Result extractor type
64
+ */
44
65
  export type TextToImageResultExtractor = (
45
66
  result: unknown,
46
67
  ) => { imageUrl?: string; imageUrls?: string[] } | undefined;
47
68
 
69
+ /**
70
+ * Text-to-image feature configuration
71
+ * Uses shared callbacks
72
+ */
48
73
  export interface TextToImageFeatureConfig {
49
74
  providerId?: string;
50
75
  creditCost?: number;
51
76
  model: string;
52
77
  buildInput: TextToImageInputBuilder;
53
78
  extractResult?: TextToImageResultExtractor;
54
- onPromptChange?: (prompt: string) => void;
55
- onProcessingStart?: () => void;
56
- onProcessingComplete?: (result: TextToImageResult) => void;
57
- onError?: (error: string) => void;
79
+ callbacks?: BaseGenerationCallbacks<string | string[]>;
58
80
  }
@@ -1,36 +1,60 @@
1
1
  /**
2
2
  * Text-to-Video Request/Response Types
3
- * Single Responsibility: Define API request and response structures
3
+ * Refactored to use shared kernel types
4
4
  */
5
5
 
6
- export interface TextToVideoOptions {
6
+ import type {
7
+ AspectRatio,
8
+ BaseGenerationOptions,
9
+ BaseGenerationResult,
10
+ BaseRequestMeta,
11
+ } from '../../../../shared-kernel/base-types';
12
+
13
+ /**
14
+ * Text-to-video specific options
15
+ * Extends base options with video-specific fields
16
+ */
17
+ export interface TextToVideoOptions extends BaseGenerationOptions {
18
+ /** Video duration in seconds */
7
19
  duration?: number;
20
+ /** Frames per second */
8
21
  fps?: number;
9
- guidanceScale?: number;
10
- aspectRatio?: "16:9" | "9:16" | "1:1";
22
+ /** Video style preset */
11
23
  style?: string;
24
+ /** Negative prompt for content avoidance */
12
25
  negativePrompt?: string;
13
26
  }
14
27
 
28
+ /**
29
+ * Text-to-video request
30
+ * Uses base metadata from shared kernel
31
+ */
15
32
  export interface TextToVideoRequest {
16
33
  prompt: string;
17
- userId: string;
18
34
  options?: TextToVideoOptions;
35
+ meta: BaseRequestMeta;
19
36
  }
20
37
 
21
- export interface TextToVideoResult {
22
- success: boolean;
38
+ /**
39
+ * Text-to-video result
40
+ * Extends base result with video-specific output
41
+ */
42
+ export interface TextToVideoResult extends BaseGenerationResult {
23
43
  videoUrl?: string;
24
44
  thumbnailUrl?: string;
25
- error?: string;
26
- requestId?: string;
27
45
  }
28
46
 
47
+ /**
48
+ * Input builder type
49
+ */
29
50
  export type TextToVideoInputBuilder = (
30
51
  prompt: string,
31
52
  options?: TextToVideoOptions,
32
53
  ) => Record<string, unknown>;
33
54
 
55
+ /**
56
+ * Result extractor type
57
+ */
34
58
  export type TextToVideoResultExtractor = (
35
59
  result: unknown,
36
60
  ) => { videoUrl?: string; thumbnailUrl?: string } | undefined;
@@ -1,17 +1,24 @@
1
1
  /**
2
2
  * Text-to-Video Feature State Types
3
- * Single Responsibility: Define internal state structures
3
+ * Refactored to use shared kernel types
4
4
  */
5
5
 
6
- export interface TextToVideoFeatureState {
6
+ import type { BaseFeatureState } from '../../../../shared-kernel/base-types';
7
+
8
+ /**
9
+ * Text-to-video feature state
10
+ * Extends base feature state with video-specific fields
11
+ */
12
+ export interface TextToVideoFeatureState extends BaseFeatureState {
7
13
  prompt: string;
8
14
  videoUrl: string | null;
9
15
  thumbnailUrl: string | null;
10
- isProcessing: boolean;
11
- progress: number;
12
- error: string | null;
13
16
  }
14
17
 
18
+ /**
19
+ * Text-to-video form state
20
+ * UI-specific state, separate from feature state
21
+ */
15
22
  export interface TextToVideoFormState {
16
23
  prompt: string;
17
24
  style: string;
@@ -22,6 +29,10 @@ export interface TextToVideoFormState {
22
29
  professionalMode: boolean;
23
30
  }
24
31
 
32
+ /**
33
+ * Text-to-video generation state
34
+ * Legacy state for backward compatibility
35
+ */
25
36
  export interface TextToVideoGenerationState {
26
37
  isGenerating: boolean;
27
38
  progress: number;
@@ -29,22 +40,31 @@ export interface TextToVideoGenerationState {
29
40
  error: string | null;
30
41
  }
31
42
 
43
+ /**
44
+ * Frame data structure
45
+ */
32
46
  export interface FrameData {
33
47
  id: string;
34
48
  url: string;
35
49
  order: number;
36
50
  }
37
51
 
52
+ /**
53
+ * Initial form state
54
+ */
38
55
  export const INITIAL_FORM_STATE: TextToVideoFormState = {
39
- prompt: "",
40
- style: "realistic",
41
- aspectRatio: "16:9",
56
+ prompt: '',
57
+ style: 'realistic',
58
+ aspectRatio: '16:9',
42
59
  duration: 4,
43
- activeTab: "text-to-video",
60
+ activeTab: 'text-to-video',
44
61
  soundEnabled: false,
45
62
  professionalMode: false,
46
63
  };
47
64
 
65
+ /**
66
+ * Initial generation state
67
+ */
48
68
  export const INITIAL_GENERATION_STATE: TextToVideoGenerationState = {
49
69
  isGenerating: false,
50
70
  progress: 0,
@@ -0,0 +1,44 @@
1
+ /**
2
+ * useTextToVideoForm Hook - Handlers
3
+ * Frame manipulation handlers for text-to-video form
4
+ */
5
+
6
+ import type { FrameData } from "../../domain/types";
7
+
8
+ export function createFrameChangeHandler(
9
+ setFrames: React.Dispatch<React.SetStateAction<FrameData[]>>,
10
+ framesLength: number,
11
+ ) {
12
+ return (fromIndex: number, toIndex: number) => {
13
+ if (fromIndex < 0 || fromIndex >= framesLength || toIndex < 0 || toIndex >= framesLength) {
14
+ if (__DEV__) {
15
+ console.warn("[TextToVideoForm] Invalid frame indices:", { fromIndex, toIndex, length: framesLength });
16
+ }
17
+ return;
18
+ }
19
+
20
+ if (fromIndex === toIndex) return;
21
+
22
+ setFrames((prevFrames) => {
23
+ const newFrames = [...prevFrames];
24
+ const [movedFrame] = newFrames.splice(fromIndex, 1);
25
+ newFrames.splice(toIndex, 0, movedFrame);
26
+ return newFrames;
27
+ });
28
+ };
29
+ }
30
+
31
+ export function createFrameDeleteHandler(
32
+ setFrames: React.Dispatch<React.SetStateAction<FrameData[]>>,
33
+ framesLength: number,
34
+ ) {
35
+ return (index: number) => {
36
+ if (index < 0 || index >= framesLength) {
37
+ if (__DEV__) {
38
+ console.warn("[TextToVideoForm] Invalid frame index:", index);
39
+ }
40
+ return;
41
+ }
42
+ setFrames((prevFrames) => prevFrames.filter((_, i) => i !== index));
43
+ };
44
+ }
@@ -9,31 +9,8 @@ import type {
9
9
  FrameData,
10
10
  } from "../../domain/types";
11
11
  import { INITIAL_FORM_STATE } from "../../domain/types";
12
-
13
-
14
- export interface UseTextToVideoFormProps {
15
- initialValues?: Partial<TextToVideoFormState>;
16
- onPromptChange?: (prompt: string) => void;
17
- onStyleChange?: (style: string) => void;
18
- onTabChange?: (tab: string) => void;
19
- }
20
-
21
- export interface UseTextToVideoFormReturn {
22
- state: TextToVideoFormState;
23
- frames: FrameData[];
24
- setPrompt: (prompt: string) => void;
25
- setStyle: (style: string) => void;
26
- setAspectRatio: (ratio: string) => void;
27
- setDuration: (duration: number) => void;
28
- setActiveTab: (tab: string) => void;
29
- setSoundEnabled: (enabled: boolean) => void;
30
- setProfessionalMode: (enabled: boolean) => void;
31
- setFrames: (frames: FrameData[]) => void;
32
- handleFrameChange: (fromIndex: number, toIndex: number) => void;
33
- handleFrameDelete: (index: number) => void;
34
- selectExamplePrompt: (prompt: string) => void;
35
- reset: () => void;
36
- }
12
+ import type { UseTextToVideoFormProps, UseTextToVideoFormReturn } from "./useTextToVideoForm.types";
13
+ import { createFrameChangeHandler, createFrameDeleteHandler } from "./useTextToVideoForm.handlers";
37
14
 
38
15
  export function useTextToVideoForm(
39
16
  props: UseTextToVideoFormProps = {},
@@ -88,36 +65,12 @@ export function useTextToVideoForm(
88
65
  }, []);
89
66
 
90
67
  const handleFrameChange = useCallback(
91
- (fromIndex: number, toIndex: number) => {
92
- if (fromIndex < 0 || fromIndex >= frames.length || toIndex < 0 || toIndex >= frames.length) {
93
- if (__DEV__) {
94
- console.warn("[TextToVideoForm] Invalid frame indices:", { fromIndex, toIndex, length: frames.length });
95
- }
96
- return;
97
- }
98
-
99
- if (fromIndex === toIndex) return;
100
-
101
- setFrames((prevFrames) => {
102
- const newFrames = [...prevFrames];
103
- const [movedFrame] = newFrames.splice(fromIndex, 1);
104
- newFrames.splice(toIndex, 0, movedFrame);
105
- return newFrames;
106
- });
107
- },
68
+ createFrameChangeHandler(setFrames, frames.length),
108
69
  [frames.length],
109
70
  );
110
71
 
111
72
  const handleFrameDelete = useCallback(
112
- (index: number) => {
113
- if (index < 0 || index >= frames.length) {
114
- if (__DEV__) {
115
- console.warn("[TextToVideoForm] Invalid frame index:", index);
116
- }
117
- return;
118
- }
119
- setFrames((prevFrames) => prevFrames.filter((_, i) => i !== index));
120
- },
73
+ createFrameDeleteHandler(setFrames, frames.length),
121
74
  [frames.length],
122
75
  );
123
76
 
@@ -150,3 +103,4 @@ export function useTextToVideoForm(
150
103
  reset,
151
104
  };
152
105
  }
106
+
@@ -0,0 +1,33 @@
1
+ /**
2
+ * useTextToVideoForm Hook - Types
3
+ * Type definitions for text-to-video form
4
+ */
5
+
6
+ import type {
7
+ TextToVideoFormState,
8
+ FrameData,
9
+ } from "../../domain/types";
10
+
11
+ export interface UseTextToVideoFormProps {
12
+ initialValues?: Partial<TextToVideoFormState>;
13
+ onPromptChange?: (prompt: string) => void;
14
+ onStyleChange?: (style: string) => void;
15
+ onTabChange?: (tab: string) => void;
16
+ }
17
+
18
+ export interface UseTextToVideoFormReturn {
19
+ state: TextToVideoFormState;
20
+ frames: FrameData[];
21
+ setPrompt: (prompt: string) => void;
22
+ setStyle: (style: string) => void;
23
+ setAspectRatio: (ratio: string) => void;
24
+ setDuration: (duration: number) => void;
25
+ setActiveTab: (tab: string) => void;
26
+ setSoundEnabled: (enabled: boolean) => void;
27
+ setProfessionalMode: (enabled: boolean) => void;
28
+ setFrames: (frames: FrameData[]) => void;
29
+ handleFrameChange: (fromIndex: number, toIndex: number) => void;
30
+ handleFrameDelete: (index: number) => void;
31
+ selectExamplePrompt: (prompt: string) => void;
32
+ reset: () => void;
33
+ }
@@ -10,9 +10,9 @@ import type {
10
10
  PollingConfig,
11
11
  } from "../../domain/entities";
12
12
  import { classifyError } from "../utils/error-classification";
13
- import { pollJob } from "../../domains/background/infrastructure/services/job-poller.service";
13
+ import { pollJob } from "../../domains/background/infrastructure/services/job-poller-index";
14
14
  import { ProviderValidator } from "./provider-validator";
15
- import { calculateDurationMs } from "../../shared/utils/calculations.util";
15
+ import { calculateDurationMs } from "../../shared/utils/calculations";
16
16
 
17
17
 
18
18
  export interface OrchestratorConfig {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Couple Input Utilities - Context Management
3
+ */
4
+
5
+ /**
6
+ * Prepends optional context (e.g. appearance analysis) to a base prompt.
7
+ */
8
+ export function prependContext(
9
+ basePrompt: string,
10
+ context: string | undefined | null,
11
+ ): string {
12
+ return context ? `${context}\n\n${basePrompt}` : basePrompt;
13
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Couple Input Utilities - Index
3
+ */
4
+
5
+ export { resolveCoupleInput } from "./couple-input-resolver";
6
+ export { prependContext } from "./couple-input-context";
7
+ export { refinePromptForCouple } from "./couple-input-refiner";
8
+ export type { GenerationTargetLike } from "./couple-input-types";