@umituz/react-native-ai-generation-content 1.83.10 → 1.83.12
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/domain/constants/queue-status.constants.ts +0 -2
- package/src/domain/entities/flow-config-data.types.ts +0 -9
- package/src/domain/entities/flow-config.types.ts +2 -6
- package/src/domain/entities/flow-configuration.types.ts +1 -8
- package/src/domain/interfaces/app-services.interface.ts +2 -2
- package/src/domain/interfaces/index.ts +0 -8
- package/src/domains/background/infrastructure/services/job-poller.service.ts +0 -1
- package/src/domains/background/infrastructure/utils/result-validator.util.ts +0 -1
- package/src/domains/background/infrastructure/utils/status-checker.util.ts +0 -1
- package/src/domains/background/infrastructure/utils/status-extraction-helpers.ts +1 -1
- package/src/domains/content-moderation/infrastructure/utils/content-security.util.ts +1 -1
- package/src/domains/creations/domain/constants/creation-fields.constants.ts +1 -10
- package/src/domains/creations/domain/constants/creation-status.constants.ts +0 -20
- package/src/domains/creations/domain/constants/creation-validation.constants.ts +0 -12
- package/src/domains/creations/domain/constants/index.ts +3 -15
- package/src/domains/creations/domain/entities/index.ts +1 -1
- package/src/domains/creations/infrastructure/repositories/creation-update.operations.ts +0 -2
- package/src/domains/creations/infrastructure/repositories/creations-operations.ts +1 -1
- package/src/domains/creations/presentation/components/CreationCard.tsx +3 -3
- package/src/domains/creations/presentation/components/CreationImagePreview.tsx +1 -1
- package/src/domains/creations/presentation/components/CreationVideoPreview.tsx +1 -1
- package/src/domains/creations/presentation/components/CreationsFilterBar.tsx +0 -1
- package/src/domains/creations/presentation/components/GalleryEmptyStates.tsx +4 -4
- package/src/domains/creations/presentation/components/GalleryHeader.tsx +3 -1
- package/src/domains/creations/presentation/components/GalleryScreenHeader.tsx +1 -1
- package/src/domains/creations/presentation/components/index.ts +0 -23
- package/src/domains/creations/presentation/hooks/creation-validators.ts +4 -4
- package/src/domains/creations/presentation/hooks/filterHelpers.ts +5 -5
- package/src/domains/creations/presentation/hooks/useFilter.ts +2 -2
- package/src/domains/creations/presentation/hooks/useGalleryCallbacks.ts +24 -19
- package/src/domains/creations/presentation/hooks/useGalleryState.ts +2 -2
- package/src/domains/creations/presentation/hooks/useProcessingJobsPoller.ts +24 -15
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +0 -1
- package/src/domains/creations/presentation/utils/filter-buttons.util.ts +2 -2
- package/src/domains/creations/presentation-exports.ts +5 -3
- package/src/domains/face-detection/presentation/components/FaceValidationStatus.tsx +1 -1
- package/src/domains/generation/infrastructure/executors/text-to-image-executor.helpers.ts +1 -1
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +0 -2
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.types.ts +0 -4
- package/src/domains/generation/wizard/infrastructure/strategies/index.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/strategies/shared/unified-prompt-builder.ts +1 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.types.ts +2 -6
- package/src/domains/generation/wizard/infrastructure/strategies/wizard-strategy.constants.ts +0 -7
- package/src/domains/generation/wizard/infrastructure/strategies/wizard-strategy.factory.ts +1 -3
- package/src/domains/generation/wizard/infrastructure/utils/creation-persistence.util.ts +0 -5
- package/src/domains/generation/wizard/infrastructure/utils/index.ts +0 -3
- package/src/domains/generation/wizard/infrastructure/utils/primitive-extractors.ts +3 -3
- package/src/domains/generation/wizard/presentation/components/IndeterminateProgressBar.tsx +1 -1
- package/src/domains/generation/wizard/presentation/components/WizardContinueButton.tsx +1 -1
- package/src/domains/generation/wizard/presentation/components/WizardFlowContent.tsx +1 -1
- package/src/domains/generation/wizard/presentation/components/WizardStepRenderer.tsx +0 -2
- package/src/domains/generation/wizard/presentation/components/WizardStepRenderer.utils.ts +0 -7
- package/src/domains/generation/wizard/presentation/components/index.ts +0 -2
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderPhotoUploadStep.tsx +1 -1
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderPreviewStep.tsx +1 -1
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderSelectionStep.tsx +1 -1
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderTextInputStep.tsx +1 -1
- package/src/domains/generation/wizard/presentation/hooks/generationStateMachine.ts +2 -2
- package/src/domains/generation/wizard/presentation/hooks/useGenerationPhase.ts +1 -1
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.ts +2 -2
- package/src/domains/generation/wizard/presentation/hooks/useWizardFlowHandlers.ts +1 -1
- package/src/domains/generation/wizard/presentation/screens/GeneratingScreen.tsx +1 -1
- package/src/domains/generation/wizard/presentation/screens/GenericPhotoUploadScreen.tsx +3 -3
- package/src/domains/generation/wizard/presentation/screens/SelectionScreen.tsx +0 -6
- package/src/domains/generation/wizard/presentation/screens/TextInputScreen.tsx +5 -3
- package/src/domains/generation/wizard/presentation/screens/index.ts +0 -13
- package/src/domains/generation/wizard/presentation/utilities/validateScenario.ts +0 -6
- package/src/domains/image-to-video/presentation/hooks/image-to-video-feature.types.ts +0 -8
- package/src/domains/image-to-video/presentation/index.ts +0 -4
- package/src/domains/result-preview/presentation/components/StarRatingPicker.tsx +1 -1
- package/src/domains/result-preview/presentation/types/result-preview.types.ts +0 -5
- package/src/domains/scenarios/configs/index.ts +1 -6
- package/src/domains/scenarios/configs/wizard-step-factories.ts +1 -1
- package/src/domains/scenarios/infrastructure/scenario-registry.ts +0 -9
- package/src/domains/scenarios/presentation/components/ScenarioContinueButton.tsx +1 -1
- package/src/domains/scenarios/presentation/hooks/useHierarchicalScenarios.ts +2 -2
- package/src/domains/scenarios/presentation/screens/HierarchicalScenarioListScreen.tsx +1 -1
- package/src/domains/scenarios/presentation/screens/ScenarioPreviewScreen.tsx +2 -2
- package/src/domains/shared/presentation/components/AutoSkipPreview.tsx +1 -1
- package/src/domains/shared/presentation/components/index.ts +0 -1
- package/src/domains/shared/presentation/utils/index.ts +0 -3
- package/src/domains/shared/presentation/utils/wizard-flow.utils.ts +2 -2
- package/src/domains/text-to-image/presentation/index.ts +0 -2
- package/src/domains/text-to-video/domain/types/component.types.ts +0 -6
- package/src/domains/text-to-video/domain/types/index.ts +0 -4
- package/src/domains/text-to-video/presentation/components/FrameSelector.tsx +97 -52
- package/src/domains/text-to-video/presentation/index.ts +0 -2
- package/src/infrastructure/config/index.ts +0 -2
- package/src/infrastructure/constants/index.ts +0 -6
- package/src/infrastructure/constants/polling.constants.ts +0 -21
- package/src/infrastructure/constants/validation.constants.ts +0 -30
- package/src/infrastructure/utils/error-classification.ts +1 -1
- package/src/infrastructure/utils/error-factory.ts +2 -2
- package/src/infrastructure/utils/index.ts +0 -9
- package/src/infrastructure/utils/message-extractor.ts +1 -20
- package/src/infrastructure/utils/progress.utils.ts +0 -37
- package/src/infrastructure/utils/provider-validator.util.ts +1 -1
- package/src/infrastructure/utils/url-extractor/index.ts +0 -5
- package/src/infrastructure/utils/url-extractor.util.ts +0 -11
- package/src/infrastructure/utils/video-helpers.ts +1 -1
- package/src/infrastructure/validation/ai-validator.ts +0 -28
- package/src/infrastructure/validation/entity-validator.ts +0 -34
- package/src/infrastructure/validation/input-validator.ts +2 -5
- package/src/infrastructure/validation/sanitizer.ts +0 -17
- package/src/presentation/components/AIGenerationConfig.tsx +3 -1
- package/src/presentation/components/GenerationProgressContent.styles.ts +0 -2
- package/src/presentation/components/PhotoUploadCard/PhotoUploadCard.tsx +0 -1
- package/src/presentation/components/ProgressCloseButton.tsx +1 -1
- package/src/presentation/components/ProgressDismissButton.tsx +1 -1
- package/src/presentation/components/ProgressHeader.tsx +1 -1
- package/src/presentation/components/ProgressHint.tsx +1 -1
- package/src/presentation/components/display/AIGenerationResult.tsx +6 -4
- package/src/presentation/components/display/index.ts +0 -1
- package/src/presentation/components/moderation/ModerationSummary.tsx +2 -2
- package/src/presentation/components/prompts/ExamplePrompts.tsx +2 -2
- package/src/presentation/components/result/ResultImageCard.tsx +39 -21
- package/src/presentation/components/result/ResultStoryCard.tsx +38 -15
- package/src/presentation/components/result/button-style.utils.ts +1 -1
- package/src/presentation/components/selectors/GridSelector.tsx +2 -2
- package/src/presentation/components/selectors/factories/aspect-ratio.factory.ts +0 -2
- package/src/presentation/components/selectors/factories/duration.factory.ts +0 -2
- package/src/presentation/components/selectors/factories/style.factory.ts +1 -1
- package/src/presentation/components/shared/ModelSelector.tsx +3 -1
- package/src/presentation/hooks/ai-feature-callbacks-auth.hooks.ts +2 -2
- package/src/presentation/hooks/ai-feature-callbacks-cost.hooks.ts +2 -2
- package/src/presentation/hooks/ai-feature-callbacks-execution.hooks.ts +2 -2
- package/src/presentation/hooks/generation/index.ts +0 -5
- package/src/presentation/hooks/generation/moderation-handler.ts +1 -1
- package/src/presentation/hooks/generation/types.ts +0 -12
- package/src/presentation/hooks/index.ts +0 -4
- package/src/presentation/hooks/useProgressDismiss.ts +1 -1
- package/src/presentation/layouts/types/layout-props.ts +1 -1
- package/src/domain/constants/index.ts +0 -2
- package/src/domain/entities/feature-flow-config.types.ts +0 -17
- package/src/domain/entities/scenario-step-config.types.ts +0 -32
- package/src/domain/entities/step-config.types.ts +0 -18
- package/src/domain/entities/step-definition.types.ts +0 -50
- package/src/domain/entities/step-input-config.types.ts +0 -36
- package/src/domain/entities/step-upload-config.types.ts +0 -17
- package/src/domains/background/domain/entities/index.ts +0 -1
- package/src/domains/background/domain/interfaces/index.ts +0 -1
- package/src/domains/content-moderation/infrastructure/utils/validators.util.ts +0 -51
- package/src/domains/creations/domain/constants/creation-errors.constants.ts +0 -27
- package/src/domains/creations/domain/constants/creation-query.constants.ts +0 -37
- package/src/domains/creations/domain/constants/creation-types.constants.ts +0 -45
- package/src/domains/creations/presentation/components/CreationImageViewer.tsx +0 -43
- package/src/domains/creations/presentation/components/CreationRating.tsx +0 -69
- package/src/domains/creations/presentation/components/CreationsGrid.tsx +0 -130
- package/src/domains/creations/presentation/components/FilterSheets.tsx +0 -63
- package/src/domains/creations/presentation/hooks/index.ts +0 -24
- package/src/domains/creations/presentation/hooks/useCreationRating.ts +0 -68
- package/src/domains/creations/presentation/screens/index.ts +0 -5
- package/src/domains/generation/infrastructure/flow/scenario-configs.ts +0 -54
- package/src/domains/generation/infrastructure/flow/step-builders.ts +0 -133
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.utils.ts +0 -42
- package/src/domains/generation/wizard/presentation/components/WizardHeader.tsx +0 -96
- package/src/domains/generation/wizard/presentation/components/step-renderers/index.ts +0 -8
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderGeneratingStep.tsx +0 -24
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderResultStep.tsx +0 -69
- package/src/domains/generation/wizard/presentation/utilities/index.ts +0 -1
- package/src/domains/prompts/infrastructure/services/base/index.ts +0 -6
- package/src/domains/prompts/infrastructure/services/base/prompt-service.base.ts +0 -112
- package/src/domains/result-preview/index.ts +0 -37
- package/src/domains/result-preview/presentation/components/GenerationErrorScreen.tsx +0 -109
- package/src/domains/result-preview/presentation/components/index.ts +0 -16
- package/src/domains/result-preview/presentation/hooks/index.ts +0 -5
- package/src/domains/result-preview/presentation/types/index.ts +0 -16
- package/src/domains/result-preview/presentation/types/result-data.types.ts +0 -35
- package/src/domains/text-to-image/presentation/screens/TextToImageWizardFlow.types.ts +0 -27
- package/src/domains/text-to-video/domain/types/action-component.types.ts +0 -15
- package/src/domains/text-to-video/domain/types/selector-component.types.ts +0 -31
- package/src/infrastructure/constants/content.constants.ts +0 -8
- package/src/infrastructure/constants/storage.constants.ts +0 -27
- package/src/infrastructure/http/api-client.types.ts +0 -17
- package/src/infrastructure/http/http-client-methods.ts +0 -73
- package/src/infrastructure/http/http-client.util.ts +0 -12
- package/src/infrastructure/http/http-fetch-handler.ts +0 -63
- package/src/infrastructure/http/http-methods.constants.ts +0 -23
- package/src/infrastructure/http/http-request-executor.ts +0 -49
- package/src/infrastructure/http/http-response-parser.ts +0 -65
- package/src/infrastructure/http/index.ts +0 -16
- package/src/infrastructure/http/query-string.util.ts +0 -40
- package/src/infrastructure/http/timeout.util.ts +0 -26
- package/src/infrastructure/logging/debug.util.ts +0 -51
- package/src/infrastructure/logging/index.ts +0 -6
- package/src/infrastructure/utils/content-validators.ts +0 -92
- package/src/infrastructure/utils/domain-guards.ts +0 -23
- package/src/infrastructure/utils/error-classifiers.ts +0 -23
- package/src/infrastructure/utils/error-handlers.ts +0 -53
- package/src/infrastructure/utils/error-retry.ts +0 -44
- package/src/infrastructure/utils/error-types.ts +0 -23
- package/src/infrastructure/utils/general-validators.ts +0 -64
- package/src/infrastructure/utils/id-validators.ts +0 -39
- package/src/infrastructure/utils/primitive-guards.ts +0 -66
- package/src/infrastructure/utils/structure-guards.ts +0 -75
- package/src/infrastructure/utils/type-guards.util.ts +0 -26
- package/src/infrastructure/utils/validation-types.ts +0 -8
- package/src/infrastructure/utils/validation.util.ts +0 -18
- package/src/shared/utils/index.ts +0 -6
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content Validation Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
MAX_PROMPT_LENGTH,
|
|
7
|
-
MIN_PROMPT_LENGTH,
|
|
8
|
-
MAX_URL_LENGTH,
|
|
9
|
-
MIN_VIDEO_DURATION_SECONDS,
|
|
10
|
-
MAX_VIDEO_DURATION_SECONDS,
|
|
11
|
-
} from "../constants/validation.constants";
|
|
12
|
-
import type { ValidationResult } from "./validation-types";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Validates text prompt length
|
|
16
|
-
*/
|
|
17
|
-
export function validatePrompt(prompt: string): ValidationResult {
|
|
18
|
-
if (!prompt || typeof prompt !== "string") {
|
|
19
|
-
return { isValid: false, error: "Prompt is required" };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (prompt.length < MIN_PROMPT_LENGTH) {
|
|
23
|
-
return { isValid: false, error: "Prompt is too short" };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (prompt.length > MAX_PROMPT_LENGTH) {
|
|
27
|
-
return { isValid: false, error: "Prompt is too long" };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return { isValid: true };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Validates URL format
|
|
35
|
-
*/
|
|
36
|
-
export function validateUrl(url: string): ValidationResult {
|
|
37
|
-
if (!url || typeof url !== "string") {
|
|
38
|
-
return { isValid: false, error: "URL is required" };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (url.length > MAX_URL_LENGTH) {
|
|
42
|
-
return { isValid: false, error: "URL is too long" };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
new URL(url);
|
|
47
|
-
return { isValid: true };
|
|
48
|
-
} catch {
|
|
49
|
-
return { isValid: false, error: "Invalid URL format" };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Validates video duration
|
|
55
|
-
*/
|
|
56
|
-
export function validateVideoDuration(duration: number): ValidationResult {
|
|
57
|
-
if (typeof duration !== "number" || isNaN(duration)) {
|
|
58
|
-
return { isValid: false, error: "Duration must be a number" };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (duration < MIN_VIDEO_DURATION_SECONDS) {
|
|
62
|
-
return {
|
|
63
|
-
isValid: false,
|
|
64
|
-
error: `Duration must be at least ${MIN_VIDEO_DURATION_SECONDS} seconds`,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (duration > MAX_VIDEO_DURATION_SECONDS) {
|
|
69
|
-
return {
|
|
70
|
-
isValid: false,
|
|
71
|
-
error: `Duration must not exceed ${MAX_VIDEO_DURATION_SECONDS} seconds`,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return { isValid: true };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Validates email format
|
|
80
|
-
*/
|
|
81
|
-
export function validateEmail(email: string): ValidationResult {
|
|
82
|
-
if (!email || typeof email !== "string") {
|
|
83
|
-
return { isValid: false, error: "Email is required" };
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
87
|
-
if (!emailRegex.test(email)) {
|
|
88
|
-
return { isValid: false, error: "Invalid email format" };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return { isValid: true };
|
|
92
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain-Specific Type Guards
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { hasProperty } from "./structure-guards";
|
|
6
|
-
import { isObject } from "./primitive-guards";
|
|
7
|
-
import { isNonEmptyString } from "./primitive-guards";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Type guard for creation objects with output property
|
|
11
|
-
*/
|
|
12
|
-
export function isCreationWithOutput(
|
|
13
|
-
value: unknown
|
|
14
|
-
): value is { output: unknown } {
|
|
15
|
-
return hasProperty(value, "output") && isObject(value.output);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Type guard for wizard data with id property
|
|
20
|
-
*/
|
|
21
|
-
export function isWizardData(value: unknown): value is { id: string } {
|
|
22
|
-
return hasProperty(value, "id") && isNonEmptyString(value.id);
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Classification Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { isError } from "./error-types";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Checks if error is a network error
|
|
9
|
-
*/
|
|
10
|
-
export function isNetworkError(error: unknown): boolean {
|
|
11
|
-
if (!isError(error)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const message = error.message.toLowerCase();
|
|
16
|
-
return (
|
|
17
|
-
message.includes("network") ||
|
|
18
|
-
message.includes("fetch") ||
|
|
19
|
-
message.includes("connection") ||
|
|
20
|
-
message.includes("timeout")
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Handling Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { getErrorMessage } from "./message-extractor";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Sanitizes error message to prevent information disclosure
|
|
9
|
-
* Removes sensitive data like file paths, API keys, stack traces
|
|
10
|
-
*/
|
|
11
|
-
function sanitizeErrorMessage(message: string): string {
|
|
12
|
-
if (!message) return "An error occurred";
|
|
13
|
-
|
|
14
|
-
// Remove file paths (Unix and Windows style)
|
|
15
|
-
let sanitized = message.replace(/\/[\w\/\-.]+/g, "[PATH]");
|
|
16
|
-
sanitized = sanitized.replace(/[A-Z]:\\[\w\\\-.]+/g, "[PATH]");
|
|
17
|
-
|
|
18
|
-
// Remove potential API keys or tokens (common patterns)
|
|
19
|
-
sanitized = sanitized.replace(/[a-z0-9]{32,}/gi, "[TOKEN]");
|
|
20
|
-
|
|
21
|
-
// Remove stack trace lines
|
|
22
|
-
sanitized = sanitized.split("\n")[0];
|
|
23
|
-
|
|
24
|
-
// Limit length
|
|
25
|
-
return sanitized.slice(0, 500);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Wraps an async function with error handling
|
|
30
|
-
*/
|
|
31
|
-
export async function withErrorHandling<T>(
|
|
32
|
-
operation: () => Promise<T>,
|
|
33
|
-
onError?: (error: Error) => void
|
|
34
|
-
): Promise<{ data?: T; error?: Error }> {
|
|
35
|
-
try {
|
|
36
|
-
const data = await operation();
|
|
37
|
-
return { data };
|
|
38
|
-
} catch (error) {
|
|
39
|
-
const errorMessage = getErrorMessage(error);
|
|
40
|
-
const sanitizedMessage = sanitizeErrorMessage(errorMessage);
|
|
41
|
-
const appError = new Error(sanitizedMessage);
|
|
42
|
-
|
|
43
|
-
// In production, don't expose original error details
|
|
44
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
45
|
-
console.error("[withErrorHandling] Original error:", error);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
onError?.(appError);
|
|
49
|
-
return { error: appError };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Retry Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { getErrorMessage } from "./message-extractor";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Retry function with exponential backoff
|
|
9
|
-
*/
|
|
10
|
-
export async function retryWithBackoff<T>(
|
|
11
|
-
operation: () => Promise<T>,
|
|
12
|
-
options: {
|
|
13
|
-
maxRetries?: number;
|
|
14
|
-
delayMs?: number;
|
|
15
|
-
backoffMultiplier?: number;
|
|
16
|
-
shouldRetry?: (error: Error) => boolean;
|
|
17
|
-
} = {}
|
|
18
|
-
): Promise<T> {
|
|
19
|
-
const {
|
|
20
|
-
maxRetries = 3,
|
|
21
|
-
delayMs = 1000,
|
|
22
|
-
backoffMultiplier = 2,
|
|
23
|
-
shouldRetry = () => true,
|
|
24
|
-
} = options;
|
|
25
|
-
|
|
26
|
-
let lastError: Error | undefined;
|
|
27
|
-
|
|
28
|
-
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
29
|
-
try {
|
|
30
|
-
return await operation();
|
|
31
|
-
} catch (error) {
|
|
32
|
-
lastError = error instanceof Error ? error : new Error(getErrorMessage(error));
|
|
33
|
-
|
|
34
|
-
if (!shouldRetry(lastError)) {
|
|
35
|
-
throw lastError;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const delay = delayMs * Math.pow(backoffMultiplier, attempt);
|
|
39
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
throw lastError ?? new Error("Operation failed after retries");
|
|
44
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Type Definitions and Guards
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export interface AppError extends Error {
|
|
6
|
-
code?: string;
|
|
7
|
-
statusCode?: number;
|
|
8
|
-
originalError?: unknown;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Type guard to check if value is an Error
|
|
13
|
-
*/
|
|
14
|
-
export function isError(value: unknown): value is Error {
|
|
15
|
-
return value instanceof Error;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Type guard to check if value is an AppError
|
|
20
|
-
*/
|
|
21
|
-
export function isAppError(value: unknown): value is AppError {
|
|
22
|
-
return isError(value) && "code" in value;
|
|
23
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* General Validation Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ValidationResult } from "./validation-types";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Validates that a value is not empty
|
|
9
|
-
*/
|
|
10
|
-
export function validateNotEmpty(value: unknown, fieldName = "Value"): ValidationResult {
|
|
11
|
-
if (value === null || value === undefined) {
|
|
12
|
-
return { isValid: false, error: `${fieldName} is required` };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (typeof value === "string" && value.trim().length === 0) {
|
|
16
|
-
return { isValid: false, error: `${fieldName} cannot be empty` };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (Array.isArray(value) && value.length === 0) {
|
|
20
|
-
return { isValid: false, error: `${fieldName} cannot be empty` };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return { isValid: true };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Validates numeric range
|
|
28
|
-
*/
|
|
29
|
-
export function validateNumericRange(
|
|
30
|
-
value: number,
|
|
31
|
-
options: {
|
|
32
|
-
min?: number;
|
|
33
|
-
max?: number;
|
|
34
|
-
fieldName?: string;
|
|
35
|
-
}
|
|
36
|
-
): ValidationResult {
|
|
37
|
-
const { min, max, fieldName = "Value" } = options;
|
|
38
|
-
|
|
39
|
-
if (typeof value !== "number" || isNaN(value)) {
|
|
40
|
-
return { isValid: false, error: `${fieldName} must be a number` };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (min !== undefined && value < min) {
|
|
44
|
-
return { isValid: false, error: `${fieldName} must be at least ${min}` };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (max !== undefined && value > max) {
|
|
48
|
-
return { isValid: false, error: `${fieldName} must not exceed ${max}` };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return { isValid: true };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Combines multiple validation results
|
|
56
|
-
*/
|
|
57
|
-
export function combineValidations(...results: ValidationResult[]): ValidationResult {
|
|
58
|
-
for (const result of results) {
|
|
59
|
-
if (!result.isValid) {
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return { isValid: true };
|
|
64
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ID Validation Utilities
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
MAX_USER_ID_LENGTH,
|
|
7
|
-
MAX_CREATION_ID_LENGTH,
|
|
8
|
-
} from "../constants/validation.constants";
|
|
9
|
-
import type { ValidationResult } from "./validation-types";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Validates user ID
|
|
13
|
-
*/
|
|
14
|
-
export function validateUserId(userId: string): ValidationResult {
|
|
15
|
-
if (!userId || typeof userId !== "string") {
|
|
16
|
-
return { isValid: false, error: "User ID is required" };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (userId.length > MAX_USER_ID_LENGTH) {
|
|
20
|
-
return { isValid: false, error: "User ID is too long" };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return { isValid: true };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Validates creation ID
|
|
28
|
-
*/
|
|
29
|
-
export function validateCreationId(creationId: string): ValidationResult {
|
|
30
|
-
if (!creationId || typeof creationId !== "string") {
|
|
31
|
-
return { isValid: false, error: "Creation ID is required" };
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (creationId.length > MAX_CREATION_ID_LENGTH) {
|
|
35
|
-
return { isValid: false, error: "Creation ID is too long" };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return { isValid: true };
|
|
39
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Primitive Type Guards
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Checks if value is a non-null object
|
|
7
|
-
*/
|
|
8
|
-
export function isObject(value: unknown): value is Record<string, unknown> {
|
|
9
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Checks if value is an array
|
|
14
|
-
*/
|
|
15
|
-
export function isArray(value: unknown): value is unknown[] {
|
|
16
|
-
return Array.isArray(value);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Checks if value is a non-empty string
|
|
21
|
-
*/
|
|
22
|
-
export function isNonEmptyString(value: unknown): value is string {
|
|
23
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Checks if value is a number (excluding NaN)
|
|
28
|
-
*/
|
|
29
|
-
export function isNumber(value: unknown): value is number {
|
|
30
|
-
return typeof value === "number" && !isNaN(value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Checks if value is a positive number
|
|
35
|
-
*/
|
|
36
|
-
export function isPositiveNumber(value: unknown): value is number {
|
|
37
|
-
return isNumber(value) && value > 0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Checks if value is a boolean
|
|
42
|
-
*/
|
|
43
|
-
export function isBoolean(value: unknown): value is boolean {
|
|
44
|
-
return typeof value === "boolean";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Checks if value is a function
|
|
49
|
-
*/
|
|
50
|
-
export function isFunction(value: unknown): value is (...args: unknown[]) => unknown {
|
|
51
|
-
return typeof value === "function";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Checks if value is a date object
|
|
56
|
-
*/
|
|
57
|
-
export function isDate(value: unknown): value is Date {
|
|
58
|
-
return value instanceof Date && !isNaN(value.getTime());
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Checks if value is defined (not null or undefined)
|
|
63
|
-
*/
|
|
64
|
-
export function isDefined<T>(value: T | null | undefined): value is T {
|
|
65
|
-
return value !== null && value !== undefined;
|
|
66
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Complex Structure Type Guards
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { isObject, isArray, isNonEmptyString, isNumber, isFunction } from "./primitive-guards";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Checks if value is a plain object (not null, not array)
|
|
9
|
-
*/
|
|
10
|
-
export function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
11
|
-
return isObject(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Checks if value is a string URL
|
|
16
|
-
*/
|
|
17
|
-
export function isUrl(value: unknown): value is string {
|
|
18
|
-
if (!isNonEmptyString(value)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
new URL(value);
|
|
24
|
-
return true;
|
|
25
|
-
} catch {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Checks if value is an array of strings
|
|
32
|
-
*/
|
|
33
|
-
export function isStringArray(value: unknown): value is string[] {
|
|
34
|
-
return isArray(value) && value.every((item) => typeof item === "string");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Checks if value is an array of numbers
|
|
39
|
-
*/
|
|
40
|
-
export function isNumberArray(value: unknown): value is number[] {
|
|
41
|
-
return isArray(value) && value.every(isNumber);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Checks if value has a specific property
|
|
46
|
-
*/
|
|
47
|
-
export function hasProperty<K extends PropertyKey>(
|
|
48
|
-
value: unknown,
|
|
49
|
-
key: K
|
|
50
|
-
): value is Record<K, unknown> {
|
|
51
|
-
return isObject(value) && key in value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Checks if object has all required properties
|
|
56
|
-
*/
|
|
57
|
-
export function hasProperties<K extends PropertyKey>(
|
|
58
|
-
value: unknown,
|
|
59
|
-
keys: K[]
|
|
60
|
-
): value is Record<K, unknown> {
|
|
61
|
-
return isObject(value) && keys.every((key) => key in value);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Checks if value is a promise
|
|
66
|
-
*/
|
|
67
|
-
export function isPromise(value: unknown): value is Promise<unknown> {
|
|
68
|
-
return (
|
|
69
|
-
isObject(value) &&
|
|
70
|
-
"then" in value &&
|
|
71
|
-
isFunction(value.then) &&
|
|
72
|
-
"catch" in value &&
|
|
73
|
-
isFunction(value.catch)
|
|
74
|
-
);
|
|
75
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type Guard Utilities - Barrel Export
|
|
3
|
-
* Provides reusable type guards for common type checking patterns
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
isObject,
|
|
8
|
-
isArray,
|
|
9
|
-
isNonEmptyString,
|
|
10
|
-
isNumber,
|
|
11
|
-
isPositiveNumber,
|
|
12
|
-
isBoolean,
|
|
13
|
-
isFunction,
|
|
14
|
-
isDate,
|
|
15
|
-
isDefined,
|
|
16
|
-
} from "./primitive-guards";
|
|
17
|
-
export {
|
|
18
|
-
isPlainObject,
|
|
19
|
-
isUrl,
|
|
20
|
-
isStringArray,
|
|
21
|
-
isNumberArray,
|
|
22
|
-
hasProperty,
|
|
23
|
-
hasProperties,
|
|
24
|
-
isPromise,
|
|
25
|
-
} from "./structure-guards";
|
|
26
|
-
export { isCreationWithOutput, isWizardData } from "./domain-guards";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common Validation Utilities - Barrel Export
|
|
3
|
-
* Reusable validation functions for forms and data
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type { ValidationResult } from "./validation-types";
|
|
7
|
-
export { validateUserId, validateCreationId } from "./id-validators";
|
|
8
|
-
export {
|
|
9
|
-
validatePrompt,
|
|
10
|
-
validateUrl,
|
|
11
|
-
validateVideoDuration,
|
|
12
|
-
validateEmail,
|
|
13
|
-
} from "./content-validators";
|
|
14
|
-
export {
|
|
15
|
-
validateNotEmpty,
|
|
16
|
-
validateNumericRange,
|
|
17
|
-
combineValidations,
|
|
18
|
-
} from "./general-validators";
|