@umituz/react-native-ai-generation-content 1.28.5 → 1.28.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/domains/generation/wizard/presentation/components/GenericWizardFlow.tsx +13 -8
- package/src/infrastructure/services/video-feature-executor.service.ts +4 -1
- package/src/infrastructure/utils/error-message-extractor.util.ts +42 -0
- package/src/infrastructure/utils/error-patterns.constants.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.7",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useMemo, useCallback, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { View, StyleSheet } from "react-native";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
8
|
+
import { useAppDesignTokens, useAlert, AlertType, AlertMode } from "@umituz/react-native-design-system";
|
|
9
9
|
import { useFlow } from "../../../infrastructure/flow/useFlow";
|
|
10
10
|
import { StepType, type StepDefinition } from "../../../../../domain/entities/flow-config.types";
|
|
11
11
|
import type { WizardFeatureConfig } from "../../domain/entities/wizard-config.types";
|
|
@@ -14,6 +14,7 @@ import { useWizardGeneration, type WizardScenarioData } from "../hooks/useWizard
|
|
|
14
14
|
import type { AlertMessages } from "../../../../../presentation/hooks/generation/types";
|
|
15
15
|
import type { UploadedImage } from "../../../../../presentation/hooks/generation/useAIGenerateState";
|
|
16
16
|
import type { Creation } from "../../../../creations/domain/entities/Creation";
|
|
17
|
+
import { createCreationsRepository } from "../../../../creations";
|
|
17
18
|
import { useResultActions } from "../../../../result-preview/presentation/hooks/useResultActions";
|
|
18
19
|
import { validateScenario } from "../utilities/validateScenario";
|
|
19
20
|
import { WizardStepRenderer } from "./WizardStepRenderer";
|
|
@@ -32,7 +33,6 @@ export interface GenericWizardFlowProps {
|
|
|
32
33
|
readonly onGenerationComplete?: (result: unknown) => void;
|
|
33
34
|
readonly onGenerationError?: (error: string) => void;
|
|
34
35
|
readonly onCreditsExhausted?: () => void;
|
|
35
|
-
readonly onRate?: (creationId: string, rating: number, description: string) => Promise<boolean>;
|
|
36
36
|
readonly onBack?: () => void;
|
|
37
37
|
readonly onTryAgain?: () => void;
|
|
38
38
|
readonly t: (key: string) => string;
|
|
@@ -53,7 +53,6 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
53
53
|
onGenerationComplete,
|
|
54
54
|
onGenerationError,
|
|
55
55
|
onCreditsExhausted,
|
|
56
|
-
onRate,
|
|
57
56
|
onBack,
|
|
58
57
|
onTryAgain,
|
|
59
58
|
t,
|
|
@@ -63,11 +62,14 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
63
62
|
renderResult,
|
|
64
63
|
}) => {
|
|
65
64
|
const tokens = useAppDesignTokens();
|
|
65
|
+
const alert = useAlert();
|
|
66
66
|
const [currentCreation, setCurrentCreation] = useState<Creation | null>(null);
|
|
67
67
|
const [showRatingPicker, setShowRatingPicker] = useState(false);
|
|
68
68
|
const [hasRated, setHasRated] = useState(false);
|
|
69
69
|
const prevStepIdRef = useRef<string | undefined>(undefined);
|
|
70
70
|
|
|
71
|
+
const repository = useMemo(() => createCreationsRepository("creations"), []);
|
|
72
|
+
|
|
71
73
|
const flowSteps = useMemo<StepDefinition[]>(() => {
|
|
72
74
|
return buildFlowStepsFromWizard(featureConfig, {
|
|
73
75
|
includePreview: true,
|
|
@@ -184,13 +186,16 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
184
186
|
}, []);
|
|
185
187
|
|
|
186
188
|
const handleSubmitRating = useCallback(async (rating: number, description: string) => {
|
|
187
|
-
if (!currentCreation?.id || !
|
|
188
|
-
const success = await
|
|
189
|
-
if (success)
|
|
189
|
+
if (!currentCreation?.id || !userId) return;
|
|
190
|
+
const success = await repository.rate(userId, currentCreation.id, rating, description);
|
|
191
|
+
if (success) {
|
|
192
|
+
setHasRated(true);
|
|
193
|
+
alert.show(AlertType.SUCCESS, AlertMode.TOAST, t("result.rateSuccessTitle"), t("result.rateSuccessMessage"));
|
|
194
|
+
}
|
|
190
195
|
setShowRatingPicker(false);
|
|
191
|
-
}, [currentCreation,
|
|
196
|
+
}, [currentCreation, userId, repository, alert, t]);
|
|
192
197
|
|
|
193
|
-
const showRatingButton = Boolean(
|
|
198
|
+
const showRatingButton = Boolean(userId) && !hasRated;
|
|
194
199
|
|
|
195
200
|
return (
|
|
196
201
|
<View style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { providerRegistry } from "./provider-registry.service";
|
|
8
|
-
import { cleanBase64, extractErrorMessage } from "../utils";
|
|
8
|
+
import { cleanBase64, extractErrorMessage, checkFalApiError } from "../utils";
|
|
9
9
|
import { extractVideoResult } from "../utils/url-extractor";
|
|
10
10
|
import { VIDEO_TIMEOUT_MS } from "../constants";
|
|
11
11
|
import type { VideoFeatureType, VideoFeatureInputData } from "../../domain/interfaces";
|
|
@@ -64,6 +64,9 @@ export async function executeVideoFeature(
|
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
// Check for FAL API error in result (may return with COMPLETED status)
|
|
68
|
+
checkFalApiError(result);
|
|
69
|
+
|
|
67
70
|
const extractor = extractResult ?? extractVideoResult;
|
|
68
71
|
const videoUrl = extractor(result);
|
|
69
72
|
|
|
@@ -5,6 +5,48 @@
|
|
|
5
5
|
|
|
6
6
|
declare const __DEV__: boolean;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* FAL API error detail item
|
|
10
|
+
*/
|
|
11
|
+
interface FalErrorDetail {
|
|
12
|
+
readonly msg?: string;
|
|
13
|
+
readonly type?: string;
|
|
14
|
+
readonly loc?: string[];
|
|
15
|
+
readonly input?: string;
|
|
16
|
+
readonly url?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if result contains a FAL API error response
|
|
21
|
+
* FAL sometimes returns errors with COMPLETED status
|
|
22
|
+
*/
|
|
23
|
+
export function checkFalApiError(result: unknown): void {
|
|
24
|
+
if (!result || typeof result !== "object") return;
|
|
25
|
+
|
|
26
|
+
const resultObj = result as { detail?: FalErrorDetail[] };
|
|
27
|
+
|
|
28
|
+
// FAL API error format: {detail: [{msg, type, loc}]}
|
|
29
|
+
if (Array.isArray(resultObj.detail) && resultObj.detail.length > 0) {
|
|
30
|
+
const firstError = resultObj.detail[0];
|
|
31
|
+
const errorType = firstError?.type || "unknown";
|
|
32
|
+
const errorMsg = firstError?.msg || "Unknown API error";
|
|
33
|
+
|
|
34
|
+
if (__DEV__) {
|
|
35
|
+
console.error("[FalApiError] Detected error in result:", {
|
|
36
|
+
type: errorType,
|
|
37
|
+
message: errorMsg,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Throw specific error based on type
|
|
42
|
+
if (errorType === "content_policy_violation") {
|
|
43
|
+
throw new Error(`Content policy violation: ${errorMsg}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
throw new Error(errorMsg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
8
50
|
/**
|
|
9
51
|
* Extract error message from FAL API and other error formats
|
|
10
52
|
* Supports: Error instances, FAL API errors, generic objects
|
|
@@ -25,10 +25,13 @@ export const AUTH_ERROR_PATTERNS = [
|
|
|
25
25
|
|
|
26
26
|
export const CONTENT_POLICY_PATTERNS = [
|
|
27
27
|
"content policy",
|
|
28
|
+
"content_policy_violation",
|
|
29
|
+
"policy violation",
|
|
28
30
|
"safety",
|
|
29
31
|
"moderation",
|
|
30
32
|
"inappropriate",
|
|
31
33
|
"blocked",
|
|
34
|
+
"flagged by a content checker",
|
|
32
35
|
] as const;
|
|
33
36
|
|
|
34
37
|
export const SERVER_ERROR_PATTERNS = [
|