@umituz/react-native-ai-generation-content 1.65.1 → 1.65.2

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 -1
  2. package/src/domain/constants/processing-modes-catalog.constants.ts +97 -0
  3. package/src/domain/constants/processing-modes-filters.ts +34 -0
  4. package/src/domain/constants/processing-modes-getters.ts +20 -0
  5. package/src/domain/constants/processing-modes.constants.ts +8 -134
  6. package/src/domain/entities/feature-flow-config.types.ts +17 -0
  7. package/src/domain/entities/flow-actions.types.ts +26 -0
  8. package/src/domain/entities/flow-config-data.types.ts +41 -0
  9. package/src/domain/entities/flow-config.types.ts +17 -169
  10. package/src/domain/entities/flow-configuration.types.ts +44 -0
  11. package/src/domain/entities/flow-state.types.ts +30 -0
  12. package/src/domain/entities/flow-step.types.ts +56 -0
  13. package/src/domain/entities/scenario-step-config.types.ts +32 -0
  14. package/src/domain/entities/step-config.types.ts +14 -129
  15. package/src/domain/entities/step-definition.types.ts +50 -0
  16. package/src/domain/entities/step-input-config.types.ts +36 -0
  17. package/src/domain/entities/step-upload-config.types.ts +17 -0
  18. package/src/domain/interfaces/ai-provider-capabilities.types.ts +27 -0
  19. package/src/domain/interfaces/ai-provider-config.types.ts +30 -0
  20. package/src/domain/interfaces/ai-provider-feature-types.ts +22 -0
  21. package/src/domain/interfaces/ai-provider-input.types.ts +28 -0
  22. package/src/domain/interfaces/ai-provider-progress.types.ts +37 -0
  23. package/src/domain/interfaces/ai-provider-status.types.ts +41 -0
  24. package/src/domain/interfaces/ai-provider.interface.ts +32 -142
  25. package/src/domain/types/result-constructors.ts +20 -0
  26. package/src/domain/types/result-guards.ts +20 -0
  27. package/src/domain/types/result-transformers.ts +36 -0
  28. package/src/domain/types/result-type-definitions.ts +27 -0
  29. package/src/domain/types/result-unwrappers.ts +28 -0
  30. package/src/domain/types/result.types.ts +11 -100
  31. package/src/domains/background/infrastructure/utils/polling-interval.util.ts +3 -8
  32. package/src/domains/background/infrastructure/utils/result-validation-logic.ts +88 -0
  33. package/src/domains/background/infrastructure/utils/result-validator-constants.ts +18 -0
  34. package/src/domains/background/infrastructure/utils/result-validator.types.ts +16 -0
  35. package/src/domains/background/infrastructure/utils/result-validator.util.ts +8 -109
  36. package/src/domains/background/infrastructure/utils/status-checker.types.ts +11 -0
  37. package/src/domains/background/infrastructure/utils/status-checker.util.ts +9 -119
  38. package/src/domains/background/infrastructure/utils/status-error-detector.ts +61 -0
  39. package/src/domains/background/infrastructure/utils/status-extraction-helpers.ts +25 -0
  40. package/src/domains/background/infrastructure/utils/status-predicates.ts +37 -0
  41. package/src/domains/creations/domain-exports.ts +79 -0
  42. package/src/domains/creations/index.ts +9 -169
  43. package/src/domains/creations/infrastructure-exports.ts +9 -0
  44. package/src/domains/creations/presentation-exports.ts +59 -0
  45. package/src/domains/generation/infrastructure/executors/text-to-image-executor.helpers.ts +81 -0
  46. package/src/domains/generation/infrastructure/executors/text-to-image-executor.ts +4 -100
  47. package/src/domains/generation/infrastructure/executors/text-to-image-executor.types.ts +19 -0
  48. package/src/domains/generation/infrastructure/flow/use-flow-store.types.ts +19 -0
  49. package/src/domains/generation/infrastructure/flow/useFlowStore.ts +33 -65
  50. package/src/domains/generation/wizard/domain/entities/wizard-config-builder.ts +75 -0
  51. package/src/domains/generation/wizard/domain/entities/wizard-feature-config.types.ts +29 -0
  52. package/src/domains/generation/wizard/domain/entities/wizard-feature.types.ts +9 -114
  53. package/src/domains/generation/wizard/domain/entities/wizard-presets.constants.ts +23 -0
  54. package/src/domains/generation/wizard/infrastructure/strategies/shared/unified-prompt-builder.ts +1 -1
  55. package/src/domains/generation/wizard/infrastructure/utils/creation-persistence-factory.ts +33 -0
  56. package/src/domains/generation/wizard/infrastructure/utils/creation-persistence.types.ts +22 -0
  57. package/src/domains/generation/wizard/infrastructure/utils/creation-persistence.util.ts +11 -135
  58. package/src/domains/generation/wizard/infrastructure/utils/creation-save-operations.ts +48 -0
  59. package/src/domains/generation/wizard/infrastructure/utils/creation-update-operations.ts +72 -0
  60. package/src/domains/generation/wizard/presentation/hooks/use-video-queue-generation.types.ts +21 -0
  61. package/src/domains/generation/wizard/presentation/hooks/useVideoQueueGeneration.ts +14 -35
  62. package/src/domains/image-to-video/domain/types/image-to-video-callbacks.types.ts +33 -0
  63. package/src/domains/image-to-video/domain/types/image-to-video-config.types.ts +29 -0
  64. package/src/domains/image-to-video/domain/types/image-to-video-request.types.ts +31 -0
  65. package/src/domains/image-to-video/domain/types/image-to-video-result.types.ts +17 -0
  66. package/src/domains/image-to-video/domain/types/image-to-video-state.types.ts +24 -0
  67. package/src/domains/image-to-video/domain/types/image-to-video.types.ts +24 -114
  68. package/src/domains/image-to-video/infrastructure/services/image-to-video-executor.ts +26 -99
  69. package/src/domains/image-to-video/infrastructure/services/image-to-video-executor.types.ts +15 -0
  70. package/src/domains/prompts/domain/base/constants.ts +47 -0
  71. package/src/domains/prompts/domain/base/creators.ts +76 -0
  72. package/src/domains/prompts/domain/base/types.ts +10 -0
  73. package/src/domains/prompts/domain/entities/MultiPersonPromptStructure.ts +1 -1
  74. package/src/domains/prompts/index.ts +4 -2
  75. package/src/domains/prompts/infrastructure/services/ImagePromptBuilder.ts +2 -72
  76. package/src/domains/prompts/infrastructure/services/image-prompt-builder.types.ts +17 -0
  77. package/src/domains/result-preview/presentation/types/result-components.types.ts +47 -0
  78. package/src/domains/result-preview/presentation/types/result-creation.types.ts +14 -0
  79. package/src/domains/result-preview/presentation/types/result-data.types.ts +35 -0
  80. package/src/domains/result-preview/presentation/types/result-hooks.types.ts +35 -0
  81. package/src/domains/result-preview/presentation/types/result-preview.types.ts +19 -182
  82. package/src/domains/result-preview/presentation/types/result-screen.types.ts +69 -0
  83. package/src/domains/text-to-image/domain-exports.ts +50 -0
  84. package/src/domains/text-to-image/index.ts +11 -102
  85. package/src/domains/text-to-image/infrastructure-exports.ts +6 -0
  86. package/src/domains/text-to-image/presentation/hooks/useFormState.ts +39 -24
  87. package/src/domains/text-to-image/presentation/hooks/useGeneration.ts +5 -3
  88. package/src/domains/text-to-image/presentation-exports.ts +41 -0
  89. package/src/domains/text-to-video/domain/types/action-component.types.ts +15 -0
  90. package/src/domains/text-to-video/domain/types/component.types.ts +16 -103
  91. package/src/domains/text-to-video/domain/types/content-component.types.ts +30 -0
  92. package/src/domains/text-to-video/domain/types/panel-component.types.ts +24 -0
  93. package/src/domains/text-to-video/domain/types/selector-component.types.ts +31 -0
  94. package/src/domains/text-to-video/domain/types/tab-component.types.ts +26 -0
  95. package/src/index.ts +0 -10
  96. package/src/infrastructure/executors/base-executor.ts +40 -112
  97. package/src/infrastructure/executors/base-executor.types.ts +10 -0
  98. package/src/infrastructure/http/http-client-methods.ts +73 -0
  99. package/src/infrastructure/http/http-client.util.ts +8 -163
  100. package/src/infrastructure/http/http-fetch-handler.ts +53 -0
  101. package/src/infrastructure/http/http-methods.constants.ts +23 -0
  102. package/src/infrastructure/http/http-request-executor.ts +49 -0
  103. package/src/infrastructure/http/http-response-parser.ts +53 -0
  104. package/src/infrastructure/orchestration/GenerationOrchestrator.ts +8 -43
  105. package/src/infrastructure/utils/classifier-helpers.ts +36 -0
  106. package/src/infrastructure/utils/content-validators.ts +92 -0
  107. package/src/infrastructure/utils/domain-guards.ts +22 -0
  108. package/src/infrastructure/utils/error-classification.ts +122 -0
  109. package/src/infrastructure/utils/error-classifier.util.ts +8 -181
  110. package/src/infrastructure/utils/error-classifiers.ts +49 -0
  111. package/src/infrastructure/utils/error-extractors.ts +42 -0
  112. package/src/infrastructure/utils/error-factory.ts +25 -0
  113. package/src/infrastructure/utils/error-handlers.ts +51 -0
  114. package/src/infrastructure/utils/error-handling.util.ts +7 -186
  115. package/src/infrastructure/utils/error-message-extractor.util.ts +10 -172
  116. package/src/infrastructure/utils/error-retry.ts +44 -0
  117. package/src/infrastructure/utils/error-types.ts +23 -0
  118. package/src/infrastructure/utils/extraction-types.ts +37 -0
  119. package/src/infrastructure/utils/fal-error-checker.ts +44 -0
  120. package/src/infrastructure/utils/general-validators.ts +64 -0
  121. package/src/infrastructure/utils/id-validators.ts +39 -0
  122. package/src/infrastructure/utils/message-extractor.ts +89 -0
  123. package/src/infrastructure/utils/primitive-guards.ts +66 -0
  124. package/src/infrastructure/utils/result-polling.ts +39 -0
  125. package/src/infrastructure/utils/structure-guards.ts +75 -0
  126. package/src/infrastructure/utils/type-guards.util.ts +22 -149
  127. package/src/infrastructure/utils/validation-types.ts +8 -0
  128. package/src/infrastructure/utils/validation.util.ts +14 -184
  129. package/src/presentation/hooks/ai-feature-callbacks-auth.hooks.ts +43 -0
  130. package/src/presentation/hooks/ai-feature-callbacks-cost.hooks.ts +56 -0
  131. package/src/presentation/hooks/ai-feature-callbacks-execution.hooks.ts +66 -0
  132. package/src/presentation/hooks/ai-feature-callbacks.types.ts +69 -0
  133. package/src/presentation/hooks/generation/use-image-generation.types.ts +39 -0
  134. package/src/presentation/hooks/generation/useImageGeneration.ts +33 -99
  135. package/src/presentation/hooks/generation-flow-navigation.ts +58 -0
  136. package/src/presentation/hooks/generation-flow-updates.ts +67 -0
  137. package/src/presentation/hooks/generation-flow.types.ts +32 -0
  138. package/src/presentation/hooks/useAIFeatureCallbacks.ts +48 -138
  139. package/src/presentation/hooks/useGenerationFlow.ts +40 -136
  140. package/src/presentation/types/flow-config.types.ts +9 -140
  141. package/src/presentation/types/flow-generation-config.types.ts +25 -0
  142. package/src/presentation/types/flow-state.types.ts +16 -0
  143. package/src/presentation/types/flow-step-configs.types.ts +48 -0
  144. package/src/presentation/types/flow-step-data.types.ts +24 -0
  145. package/src/presentation/types/result-actions.types.ts +50 -0
  146. package/src/presentation/types/result-config.types.ts +22 -171
  147. package/src/presentation/types/result-header.types.ts +44 -0
  148. package/src/presentation/types/result-image.types.ts +29 -0
  149. package/src/presentation/types/result-layout.types.ts +26 -0
  150. package/src/presentation/types/result-story.types.ts +42 -0
  151. package/src/domains/prompts/domain/entities/BasePromptStructure.ts +0 -168
  152. package/src/exports/domains.ts +0 -149
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Creations Presentation Layer Exports
3
+ */
4
+
5
+ // Hooks
6
+ export { useCreations } from "./presentation/hooks/useCreations";
7
+ export { useDeleteCreation } from "./presentation/hooks/useDeleteCreation";
8
+ export { useCreationsFilter } from "./presentation/hooks/useCreationsFilter";
9
+ export { useAdvancedFilter } from "./presentation/hooks/useAdvancedFilter";
10
+ export { useCreationPersistence } from "./presentation/hooks/useCreationPersistence";
11
+ export type {
12
+ UseCreationPersistenceConfig,
13
+ UseCreationPersistenceReturn,
14
+ BaseProcessingStartData,
15
+ BaseProcessingResult,
16
+ } from "./presentation/hooks/useCreationPersistence";
17
+ export { useProcessingJobsPoller } from "./presentation/hooks/useProcessingJobsPoller";
18
+ export type {
19
+ UseProcessingJobsPollerConfig,
20
+ UseProcessingJobsPollerReturn,
21
+ } from "./presentation/hooks/useProcessingJobsPoller";
22
+
23
+ // Core Components
24
+ export { CreationPreview } from "./presentation/components/CreationPreview";
25
+ export { CreationBadges } from "./presentation/components/CreationBadges";
26
+ export {
27
+ CreationActions,
28
+ type CreationAction,
29
+ } from "./presentation/components/CreationActions";
30
+ export {
31
+ CreationCard,
32
+ type CreationCardData,
33
+ type CreationCardCallbacks,
34
+ } from "./presentation/components/CreationCard";
35
+ export { CreationThumbnail } from "./presentation/components/CreationThumbnail";
36
+
37
+ // Filter Components
38
+ export { FilterChips } from "./presentation/components/FilterChips";
39
+ export {
40
+ CreationsFilterBar,
41
+ createMediaFilterButtons,
42
+ createStatusFilterButtons,
43
+ type FilterButton,
44
+ } from "./presentation/components/CreationsFilterBar";
45
+
46
+ // Gallery Components
47
+ export { CreationsHomeCard } from "./presentation/components/CreationsHomeCard";
48
+ export { EmptyState } from "./presentation/components/EmptyState";
49
+ export { PendingJobsSection, type PendingJobsSectionProps } from "./presentation/components/PendingJobsSection";
50
+
51
+ // Utilities
52
+ export {
53
+ getLocalizedTitle,
54
+ getFilterCategoriesFromConfig,
55
+ getTranslatedTypes,
56
+ } from "./presentation/utils/gallery-filters";
57
+
58
+ // Screens
59
+ export { CreationsGalleryScreen } from "./presentation/screens/CreationsGalleryScreen";
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Text-to-Image Executor Helpers
3
+ */
4
+
5
+ import type { TextToImageInput, TextToImageOutput } from "./text-to-image-executor.types";
6
+
7
+ export function buildModelInput(input: TextToImageInput): Record<string, unknown> {
8
+ const {
9
+ prompt,
10
+ negativePrompt,
11
+ aspectRatio,
12
+ size,
13
+ numImages,
14
+ guidanceScale,
15
+ style,
16
+ outputFormat,
17
+ } = input;
18
+
19
+ let finalPrompt = prompt;
20
+ if (style && style !== "none") {
21
+ finalPrompt = `${prompt}, ${style} style`;
22
+ }
23
+
24
+ return {
25
+ prompt: finalPrompt,
26
+ ...(negativePrompt && { negative_prompt: negativePrompt }),
27
+ ...(aspectRatio && { aspect_ratio: aspectRatio }),
28
+ ...(size && { image_size: size }),
29
+ ...(numImages && { num_images: numImages }),
30
+ ...(guidanceScale && { guidance_scale: guidanceScale }),
31
+ ...(outputFormat && { output_format: outputFormat }),
32
+ };
33
+ }
34
+
35
+ export function extractImagesFromObject(obj: Record<string, unknown>): string[] {
36
+ if (!Array.isArray(obj.images)) {
37
+ return [];
38
+ }
39
+
40
+ return obj.images
41
+ .map((img) => {
42
+ if (typeof img === "string") return img;
43
+ if (img && typeof img === "object" && "url" in img) {
44
+ return (img as { url: string }).url;
45
+ }
46
+ return null;
47
+ })
48
+ .filter((url): url is string => url !== null);
49
+ }
50
+
51
+ export function extractResult(result: unknown): TextToImageOutput | undefined {
52
+ if (typeof result !== "object" || result === null) {
53
+ return undefined;
54
+ }
55
+
56
+ const r = result as Record<string, unknown>;
57
+
58
+ if (r.data && typeof r.data === "object") {
59
+ const urls = extractImagesFromObject(r.data as Record<string, unknown>);
60
+ if (urls.length > 0) {
61
+ return { imageUrl: urls[0], imageUrls: urls };
62
+ }
63
+ }
64
+
65
+ const directUrls = extractImagesFromObject(r);
66
+ if (directUrls.length > 0) {
67
+ return { imageUrl: directUrls[0], imageUrls: directUrls };
68
+ }
69
+
70
+ if (typeof r.imageUrl === "string") {
71
+ return { imageUrl: r.imageUrl, imageUrls: [r.imageUrl] };
72
+ }
73
+
74
+ if (typeof r.imageBase64 === "string") {
75
+ const mimeType = typeof r.mimeType === "string" ? r.mimeType : "image/png";
76
+ const dataUrl = `data:${mimeType};base64,${r.imageBase64}`;
77
+ return { imageUrl: dataUrl, imageUrls: [dataUrl] };
78
+ }
79
+
80
+ return undefined;
81
+ }
@@ -9,25 +9,11 @@ import type {
9
9
  } from "../../domain/generation.types";
10
10
  import type { GenerationResult } from "../../../../domain/entities/generation.types";
11
11
  import { providerRegistry } from "../../../../infrastructure/services/provider-registry.service";
12
+ import type { TextToImageInput, TextToImageOutput } from "./text-to-image-executor.types";
13
+ import { buildModelInput, extractResult } from "./text-to-image-executor.helpers";
12
14
 
13
15
  declare const __DEV__: boolean;
14
16
 
15
- export interface TextToImageInput {
16
- prompt: string;
17
- negativePrompt?: string;
18
- aspectRatio?: string;
19
- size?: string;
20
- numImages?: number;
21
- guidanceScale?: number;
22
- style?: string;
23
- outputFormat?: "jpeg" | "png" | "webp";
24
- }
25
-
26
- export interface TextToImageOutput {
27
- imageUrl: string;
28
- imageUrls: string[];
29
- }
30
-
31
17
  export class TextToImageExecutor
32
18
  implements GenerationExecutor<TextToImageInput, TextToImageOutput>
33
19
  {
@@ -58,13 +44,13 @@ export class TextToImageExecutor
58
44
 
59
45
  options?.onProgress?.(10);
60
46
 
61
- const modelInput = this.buildModelInput(input);
47
+ const modelInput = buildModelInput(input);
62
48
  options?.onProgress?.(20);
63
49
 
64
50
  const result = await provider.run(model, modelInput);
65
51
  options?.onProgress?.(90);
66
52
 
67
- const extracted = this.extractResult(result);
53
+ const extracted = extractResult(result);
68
54
  options?.onProgress?.(100);
69
55
 
70
56
  if (!extracted?.imageUrl) {
@@ -88,86 +74,4 @@ export class TextToImageExecutor
88
74
  return { success: false, error: message };
89
75
  }
90
76
  }
91
-
92
- private buildModelInput(input: TextToImageInput): Record<string, unknown> {
93
- const {
94
- prompt,
95
- negativePrompt,
96
- aspectRatio,
97
- size,
98
- numImages,
99
- guidanceScale,
100
- style,
101
- outputFormat,
102
- } = input;
103
-
104
- let finalPrompt = prompt;
105
- if (style && style !== "none") {
106
- finalPrompt = `${prompt}, ${style} style`;
107
- }
108
-
109
- return {
110
- prompt: finalPrompt,
111
- ...(negativePrompt && { negative_prompt: negativePrompt }),
112
- ...(aspectRatio && { aspect_ratio: aspectRatio }),
113
- ...(size && { image_size: size }),
114
- ...(numImages && { num_images: numImages }),
115
- ...(guidanceScale && { guidance_scale: guidanceScale }),
116
- ...(outputFormat && { output_format: outputFormat }),
117
- };
118
- }
119
-
120
- private extractResult(
121
- result: unknown,
122
- ): { imageUrl: string; imageUrls: string[] } | undefined {
123
- if (typeof result !== "object" || result === null) {
124
- return undefined;
125
- }
126
-
127
- const r = result as Record<string, unknown>;
128
-
129
- // Check nested 'data' object
130
- if (r.data && typeof r.data === "object") {
131
- const urls = this.extractImagesFromObject(r.data as Record<string, unknown>);
132
- if (urls.length > 0) {
133
- return { imageUrl: urls[0], imageUrls: urls };
134
- }
135
- }
136
-
137
- // Check direct images array
138
- const directUrls = this.extractImagesFromObject(r);
139
- if (directUrls.length > 0) {
140
- return { imageUrl: directUrls[0], imageUrls: directUrls };
141
- }
142
-
143
- // Check for imageUrl
144
- if (typeof r.imageUrl === "string") {
145
- return { imageUrl: r.imageUrl, imageUrls: [r.imageUrl] };
146
- }
147
-
148
- // Fallback: base64
149
- if (typeof r.imageBase64 === "string") {
150
- const mimeType = typeof r.mimeType === "string" ? r.mimeType : "image/png";
151
- const dataUrl = `data:${mimeType};base64,${r.imageBase64}`;
152
- return { imageUrl: dataUrl, imageUrls: [dataUrl] };
153
- }
154
-
155
- return undefined;
156
- }
157
-
158
- private extractImagesFromObject(obj: Record<string, unknown>): string[] {
159
- if (!Array.isArray(obj.images)) {
160
- return [];
161
- }
162
-
163
- return obj.images
164
- .map((img) => {
165
- if (typeof img === "string") return img;
166
- if (img && typeof img === "object" && "url" in img) {
167
- return (img as { url: string }).url;
168
- }
169
- return null;
170
- })
171
- .filter((url): url is string => url !== null);
172
- }
173
77
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Text-to-Image Executor Types
3
+ */
4
+
5
+ export interface TextToImageInput {
6
+ prompt: string;
7
+ negativePrompt?: string;
8
+ aspectRatio?: string;
9
+ size?: string;
10
+ numImages?: number;
11
+ guidanceScale?: number;
12
+ style?: string;
13
+ outputFormat?: "jpeg" | "png" | "webp";
14
+ }
15
+
16
+ export interface TextToImageOutput {
17
+ imageUrl: string;
18
+ imageUrls: string[];
19
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Flow Store Types
3
+ */
4
+
5
+ import type {
6
+ FlowState,
7
+ FlowActions,
8
+ StepDefinition,
9
+ } from "../../../../domain/entities/flow-config.types";
10
+
11
+ export interface FlowStoreState extends FlowState {
12
+ stepDefinitions: readonly StepDefinition[];
13
+ }
14
+
15
+ export interface FlowStoreConfig {
16
+ steps: readonly StepDefinition[];
17
+ initialStepId?: string;
18
+ initialStepIndex?: number;
19
+ }
@@ -1,6 +1,5 @@
1
1
  /**
2
- * useFlowStore
3
- * Zustand store for multi-step flow state management
2
+ * Flow Store - Zustand store for multi-step flow state management
4
3
  */
5
4
 
6
5
  import { createStore } from "@umituz/react-native-design-system";
@@ -8,12 +7,8 @@ import type {
8
7
  FlowState,
9
8
  FlowActions,
10
9
  FlowUploadedImageData,
11
- StepDefinition,
12
10
  } from "../../../../domain/entities/flow-config.types";
13
-
14
- interface FlowStoreState extends FlowState {
15
- stepDefinitions: readonly StepDefinition[];
16
- }
11
+ import type { FlowStoreState, FlowStoreConfig } from "./use-flow-store.types";
17
12
 
18
13
  const createInitialState = (): FlowState => ({
19
14
  currentStepId: "",
@@ -33,14 +28,7 @@ const createInitialState = (): FlowState => ({
33
28
  generationError: undefined,
34
29
  });
35
30
 
36
- interface FlowStoreConfig {
37
- steps: readonly StepDefinition[];
38
- initialStepId?: string;
39
- initialStepIndex?: number;
40
- }
41
-
42
31
  export const createFlowStore = (config: FlowStoreConfig) => {
43
- // Support both initialStepId and initialStepIndex
44
32
  let initialIndex = 0;
45
33
 
46
34
  if (config.initialStepIndex !== undefined) {
@@ -74,76 +62,58 @@ export const createFlowStore = (config: FlowStoreConfig) => {
74
62
  nextStep: () => {
75
63
  const { stepDefinitions, currentStepIndex, completedSteps, currentStepId } = get();
76
64
  const nextIndex = currentStepIndex + 1;
77
- if (nextIndex < stepDefinitions.length) {
78
- const nextStep = stepDefinitions[nextIndex];
79
- const newCompleted = completedSteps.includes(currentStepId)
65
+ if (nextIndex >= stepDefinitions.length) return;
66
+ set({
67
+ currentStepId: stepDefinitions[nextIndex].id,
68
+ currentStepIndex: nextIndex,
69
+ completedSteps: completedSteps.includes(currentStepId)
80
70
  ? completedSteps
81
- : [...completedSteps, currentStepId];
82
-
83
- if (typeof __DEV__ !== "undefined" && __DEV__) {
84
- console.log("[FlowStore] nextStep", {
85
- fromIndex: currentStepIndex,
86
- toIndex: nextIndex,
87
- fromStep: currentStepId,
88
- toStep: nextStep.id,
89
- toStepType: nextStep.type,
90
- });
91
- }
92
-
93
- set({ currentStepId: nextStep.id, currentStepIndex: nextIndex, completedSteps: newCompleted });
94
- }
71
+ : [...completedSteps, currentStepId],
72
+ });
95
73
  },
96
74
 
97
75
  previousStep: () => {
98
76
  const { stepDefinitions, currentStepIndex } = get();
99
77
  if (currentStepIndex > 0) {
100
- const prevStep = stepDefinitions[currentStepIndex - 1];
101
- set({ currentStepId: prevStep.id, currentStepIndex: currentStepIndex - 1 });
78
+ set({
79
+ currentStepId: stepDefinitions[currentStepIndex - 1].id,
80
+ currentStepIndex: currentStepIndex - 1,
81
+ });
102
82
  }
103
83
  },
104
84
 
105
85
  setCategory: (category: unknown) => set({ selectedCategory: category }),
106
86
  setScenario: (scenario: unknown) => set({ selectedScenario: scenario }),
107
87
 
108
- setPartnerImage: (partnerId: string, image: FlowUploadedImageData | undefined) => {
109
- const { partners } = get();
110
- set({ partners: { ...partners, [partnerId]: image } });
111
- },
88
+ setPartnerImage: (partnerId: string, image: FlowUploadedImageData | undefined) =>
89
+ set({ partners: { ...get().partners, [partnerId]: image } }),
112
90
 
113
- setPartnerName: (partnerId: string, name: string) => {
114
- const { partnerNames } = get();
115
- set({ partnerNames: { ...partnerNames, [partnerId]: name } });
116
- },
91
+ setPartnerName: (partnerId: string, name: string) =>
92
+ set({ partnerNames: { ...get().partnerNames, [partnerId]: name } }),
117
93
 
118
94
  setTextInput: (text: string) => set({ textInput: text }),
119
95
  setVisualStyle: (styleId: string) => set({ visualStyle: styleId }),
120
96
 
121
- setSelectedFeatures: (featureType: string, ids: readonly string[]) => {
122
- const { selectedFeatures } = get();
123
- set({ selectedFeatures: { ...selectedFeatures, [featureType]: ids } });
124
- },
97
+ setSelectedFeatures: (featureType: string, ids: readonly string[]) =>
98
+ set({ selectedFeatures: { ...get().selectedFeatures, [featureType]: ids } }),
125
99
 
126
- setCustomData: (key: string, value: unknown) => {
127
- const { customData } = get();
128
- set({ customData: { ...customData, [key]: value } });
129
- },
100
+ setCustomData: (key: string, value: unknown) =>
101
+ set({ customData: { ...get().customData, [key]: value } }),
130
102
 
131
- startGeneration: () => {
132
- set({ generationStatus: "preparing", generationProgress: 0, generationError: undefined });
133
- },
103
+ startGeneration: () =>
104
+ set({ generationStatus: "preparing", generationProgress: 0, generationError: undefined }),
134
105
 
135
- updateProgress: (progress: number) => {
136
- const generationStatus = progress >= 100 ? "completed" : progress > 0 ? "generating" : "preparing";
137
- set({ generationProgress: progress, generationStatus });
138
- },
106
+ updateProgress: (progress: number) =>
107
+ set({
108
+ generationProgress: progress,
109
+ generationStatus: progress >= 100 ? "completed" : progress > 0 ? "generating" : "preparing",
110
+ }),
139
111
 
140
- setResult: (result: unknown) => {
141
- set({ generationResult: result, generationStatus: "completed", generationProgress: 100 });
142
- },
112
+ setResult: (result: unknown) =>
113
+ set({ generationResult: result, generationStatus: "completed", generationProgress: 100 }),
143
114
 
144
- setError: (error: string) => {
145
- set({ generationError: error, generationStatus: "failed", generationProgress: 0 });
146
- },
115
+ setError: (error: string) =>
116
+ set({ generationError: error, generationStatus: "failed", generationProgress: 0 }),
147
117
 
148
118
  reset: () => {
149
119
  const { stepDefinitions } = get();
@@ -153,9 +123,7 @@ export const createFlowStore = (config: FlowStoreConfig) => {
153
123
 
154
124
  completeStep: (stepId: string) => {
155
125
  const { completedSteps } = get();
156
- if (!completedSteps.includes(stepId)) {
157
- set({ completedSteps: [...completedSteps, stepId] });
158
- }
126
+ if (!completedSteps.includes(stepId)) set({ completedSteps: [...completedSteps, stepId] });
159
127
  },
160
128
  }),
161
129
  });
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Wizard Config Builder
3
+ * Domain Service: Builds wizard configuration from scenario
4
+ */
5
+
6
+ import type { WizardStepConfig } from "./wizard-step.types";
7
+ import type { WizardFeatureConfig, ScenarioBasedConfig } from "./wizard-feature-config.types";
8
+
9
+ /**
10
+ * Build wizard config from scenario shorthand
11
+ */
12
+ export function buildWizardConfigFromScenario(
13
+ scenarioId: string,
14
+ config: ScenarioBasedConfig
15
+ ): WizardFeatureConfig {
16
+ const steps: WizardStepConfig[] = [];
17
+
18
+ if (config.photoCount && config.photoCount > 0) {
19
+ const maxPhotos = Math.min(config.photoCount, 2);
20
+ for (let i = 0; i < maxPhotos; i++) {
21
+ steps.push({
22
+ id: `photo_${i + 1}`,
23
+ type: "photo_upload",
24
+ label: config.photoLabels?.[i] || `Photo ${i + 1}`,
25
+ showFaceDetection: true,
26
+ showPhotoTips: true,
27
+ required: true,
28
+ });
29
+ }
30
+ }
31
+
32
+ if (config.requireText) {
33
+ steps.push({
34
+ id: "text_input",
35
+ type: "text_input",
36
+ required: true,
37
+ minLength: 10,
38
+ maxLength: 500,
39
+ });
40
+ }
41
+
42
+ if (config.requireStyleSelection) {
43
+ steps.push({
44
+ id: "style_selection",
45
+ type: "selection",
46
+ selectionType: "style",
47
+ options: [],
48
+ required: true,
49
+ });
50
+ }
51
+
52
+ if (config.requireDurationSelection) {
53
+ steps.push({
54
+ id: "duration_selection",
55
+ type: "selection",
56
+ selectionType: "duration",
57
+ options: [
58
+ { id: "5s", label: "5 seconds", value: 5 },
59
+ { id: "10s", label: "10 seconds", value: 10 },
60
+ { id: "15s", label: "15 seconds", value: 15 },
61
+ ],
62
+ required: true,
63
+ });
64
+ }
65
+
66
+ if (config.customSteps) {
67
+ steps.push(...config.customSteps);
68
+ }
69
+
70
+ return {
71
+ id: scenarioId,
72
+ name: scenarioId,
73
+ steps,
74
+ };
75
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Wizard Feature Configuration Types
3
+ */
4
+
5
+ import type { WizardStepConfig } from "./wizard-step.types";
6
+
7
+ /**
8
+ * Feature Flow Configuration
9
+ */
10
+ export interface WizardFeatureConfig {
11
+ readonly id: string;
12
+ readonly name: string;
13
+ readonly steps: readonly WizardStepConfig[];
14
+ readonly translations?: {
15
+ readonly [key: string]: string | Record<string, string>;
16
+ };
17
+ }
18
+
19
+ /**
20
+ * Scenario-based Configuration Builder
21
+ */
22
+ export interface ScenarioBasedConfig {
23
+ readonly photoCount?: number;
24
+ readonly photoLabels?: readonly string[];
25
+ readonly requireText?: boolean;
26
+ readonly requireStyleSelection?: boolean;
27
+ readonly requireDurationSelection?: boolean;
28
+ readonly customSteps?: readonly WizardStepConfig[];
29
+ }
@@ -1,118 +1,13 @@
1
1
  /**
2
- * Wizard Feature Configuration Types
2
+ * Wizard Feature Configuration Types - Barrel Export
3
3
  * Feature-level configs and builder utilities
4
+ *
5
+ * Architecture:
6
+ * - Domain: Feature config types, scenario config types
7
+ * - Domain Service: Config builder function
8
+ * - Domain Knowledge: Preset configurations
4
9
  */
5
10
 
6
- import type { WizardStepConfig } from "./wizard-step.types";
7
-
8
- /**
9
- * Feature Flow Configuration
10
- */
11
- export interface WizardFeatureConfig {
12
- readonly id: string;
13
- readonly name: string;
14
- readonly steps: readonly WizardStepConfig[];
15
- readonly translations?: {
16
- readonly [key: string]: string | Record<string, string>;
17
- };
18
- }
19
-
20
- /**
21
- * Scenario-based Configuration Builder
22
- */
23
- export interface ScenarioBasedConfig {
24
- readonly photoCount?: number;
25
- readonly photoLabels?: readonly string[];
26
- readonly requireText?: boolean;
27
- readonly requireStyleSelection?: boolean;
28
- readonly requireDurationSelection?: boolean;
29
- readonly customSteps?: readonly WizardStepConfig[];
30
- }
31
-
32
- /**
33
- * Build wizard config from scenario shorthand
34
- */
35
- export const buildWizardConfigFromScenario = (
36
- scenarioId: string,
37
- config: ScenarioBasedConfig,
38
- ): WizardFeatureConfig => {
39
- const steps: WizardStepConfig[] = [];
40
-
41
- if (config.photoCount && config.photoCount > 0) {
42
- const maxPhotos = Math.min(config.photoCount, 2);
43
- for (let i = 0; i < maxPhotos; i++) {
44
- steps.push({
45
- id: `photo_${i + 1}`,
46
- type: "photo_upload",
47
- label: config.photoLabels?.[i] || `Photo ${i + 1}`,
48
- showFaceDetection: true,
49
- showPhotoTips: true,
50
- required: true,
51
- });
52
- }
53
- }
54
-
55
- if (config.requireText) {
56
- steps.push({
57
- id: "text_input",
58
- type: "text_input",
59
- required: true,
60
- minLength: 10,
61
- maxLength: 500,
62
- });
63
- }
64
-
65
- if (config.requireStyleSelection) {
66
- steps.push({
67
- id: "style_selection",
68
- type: "selection",
69
- selectionType: "style",
70
- options: [],
71
- required: true,
72
- });
73
- }
74
-
75
- if (config.requireDurationSelection) {
76
- steps.push({
77
- id: "duration_selection",
78
- type: "selection",
79
- selectionType: "duration",
80
- options: [
81
- { id: "5s", label: "5 seconds", value: 5 },
82
- { id: "10s", label: "10 seconds", value: 10 },
83
- { id: "15s", label: "15 seconds", value: 15 },
84
- ],
85
- required: true,
86
- });
87
- }
88
-
89
- if (config.customSteps) {
90
- steps.push(...config.customSteps);
91
- }
92
-
93
- return {
94
- id: scenarioId,
95
- name: scenarioId,
96
- steps,
97
- };
98
- };
99
-
100
- /**
101
- * Pre-configured scenarios for common use cases
102
- */
103
- export const WIZARD_PRESETS = {
104
- TWO_PHOTOS: {
105
- photoCount: 2,
106
- },
107
- SINGLE_PHOTO: {
108
- photoCount: 1,
109
- requireStyleSelection: true,
110
- requireDurationSelection: true,
111
- },
112
- TEXT_ONLY: {
113
- photoCount: 0,
114
- requireText: true,
115
- requireStyleSelection: true,
116
- requireDurationSelection: true,
117
- },
118
- } as const;
11
+ export type { WizardFeatureConfig, ScenarioBasedConfig } from "./wizard-feature-config.types";
12
+ export { buildWizardConfigFromScenario } from "./wizard-config-builder";
13
+ export { WIZARD_PRESETS } from "./wizard-presets.constants";