@umituz/react-native-ai-generation-content 1.83.10 → 1.83.11
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 +1 -1
- package/src/domains/creations/presentation/hooks/useGalleryState.ts +2 -2
- 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,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Client Methods
|
|
3
|
-
* Infrastructure: Public API for HTTP operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { RequestOptions, ApiResponse } from "./api-client.types";
|
|
7
|
-
import { fetchWithTimeout } from "./http-fetch-handler";
|
|
8
|
-
import { HTTP_METHOD } from "./http-methods.constants";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Makes a GET request
|
|
12
|
-
*/
|
|
13
|
-
export async function get<T>(
|
|
14
|
-
url: string,
|
|
15
|
-
options: Omit<RequestOptions, "method" | "body"> = {}
|
|
16
|
-
): Promise<ApiResponse<T>> {
|
|
17
|
-
return fetchWithTimeout<T>(url, { ...options, method: HTTP_METHOD.GET });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Makes a POST request
|
|
22
|
-
*/
|
|
23
|
-
export async function post<T>(
|
|
24
|
-
url: string,
|
|
25
|
-
data: unknown,
|
|
26
|
-
options: Omit<RequestOptions, "method"> = {}
|
|
27
|
-
): Promise<ApiResponse<T>> {
|
|
28
|
-
return fetchWithTimeout<T>(url, {
|
|
29
|
-
...options,
|
|
30
|
-
method: HTTP_METHOD.POST,
|
|
31
|
-
body: JSON.stringify(data),
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Makes a PUT request
|
|
37
|
-
*/
|
|
38
|
-
export async function put<T>(
|
|
39
|
-
url: string,
|
|
40
|
-
data: unknown,
|
|
41
|
-
options: Omit<RequestOptions, "method"> = {}
|
|
42
|
-
): Promise<ApiResponse<T>> {
|
|
43
|
-
return fetchWithTimeout<T>(url, {
|
|
44
|
-
...options,
|
|
45
|
-
method: HTTP_METHOD.PUT,
|
|
46
|
-
body: JSON.stringify(data),
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Makes a DELETE request
|
|
52
|
-
*/
|
|
53
|
-
export async function del<T>(
|
|
54
|
-
url: string,
|
|
55
|
-
options: Omit<RequestOptions, "method" | "body"> = {}
|
|
56
|
-
): Promise<ApiResponse<T>> {
|
|
57
|
-
return fetchWithTimeout<T>(url, { ...options, method: HTTP_METHOD.DELETE });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Makes a PATCH request
|
|
62
|
-
*/
|
|
63
|
-
export async function patch<T>(
|
|
64
|
-
url: string,
|
|
65
|
-
data: unknown,
|
|
66
|
-
options: Omit<RequestOptions, "method"> = {}
|
|
67
|
-
): Promise<ApiResponse<T>> {
|
|
68
|
-
return fetchWithTimeout<T>(url, {
|
|
69
|
-
...options,
|
|
70
|
-
method: HTTP_METHOD.PATCH,
|
|
71
|
-
body: JSON.stringify(data),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Client Utilities - Barrel Export
|
|
3
|
-
* Core HTTP request handling with error handling and retry logic
|
|
4
|
-
*
|
|
5
|
-
* Architecture:
|
|
6
|
-
* - Domain: HTTP methods, content types (constants)
|
|
7
|
-
* - Infrastructure: Request execution, response parsing, error handling
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export { HTTP_METHOD, HTTP_CONTENT_TYPE, DEFAULT_HEADERS, type HttpMethod } from "./http-methods.constants";
|
|
11
|
-
export { fetchWithTimeout } from "./http-fetch-handler";
|
|
12
|
-
export { get, post, put, del, patch } from "./http-client-methods";
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Fetch Handler
|
|
3
|
-
* Infrastructure: Orchestrates request execution with error handling
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { withErrorHandling } from "../utils/error-handlers";
|
|
7
|
-
import { getErrorMessage } from "../utils/message-extractor";
|
|
8
|
-
import { retryWithBackoff } from "../utils/error-retry";
|
|
9
|
-
import { isNetworkError } from "../utils/error-classifiers";
|
|
10
|
-
import { env } from "../config/env.config";
|
|
11
|
-
import type { RequestOptions, ApiResponse } from "./api-client.types";
|
|
12
|
-
import { executeRequest, isSuccessResponse, extractErrorMessage } from "./http-request-executor";
|
|
13
|
-
import { parseResponse, createSuccessResponse, createErrorResponse } from "./http-response-parser";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Fetches data with timeout, retry, and error handling
|
|
18
|
-
*/
|
|
19
|
-
export async function fetchWithTimeout<T>(
|
|
20
|
-
url: string,
|
|
21
|
-
options: RequestOptions = {}
|
|
22
|
-
): Promise<ApiResponse<T>> {
|
|
23
|
-
const { retries = 0 } = options;
|
|
24
|
-
|
|
25
|
-
const operation = async (): Promise<T> => {
|
|
26
|
-
const response = await executeRequest(url, options);
|
|
27
|
-
|
|
28
|
-
if (!isSuccessResponse(response)) {
|
|
29
|
-
const errorMessage = await extractErrorMessage(response);
|
|
30
|
-
throw new Error(errorMessage);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return parseResponse<T>(response);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const result = await withErrorHandling(
|
|
37
|
-
async () => {
|
|
38
|
-
if (retries > 0) {
|
|
39
|
-
return retryWithBackoff(operation, {
|
|
40
|
-
maxRetries: retries,
|
|
41
|
-
delayMs: env.apiRetryDelayMs,
|
|
42
|
-
shouldRetry: (error) => isNetworkError(error),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return operation();
|
|
46
|
-
},
|
|
47
|
-
(error) => {
|
|
48
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
49
|
-
console.error("[API Client] Request failed:", error);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
if (result.error) {
|
|
55
|
-
return createErrorResponse(getErrorMessage(result.error));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (result.data === undefined) {
|
|
59
|
-
return createErrorResponse("No data received from server");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return createSuccessResponse(result.data);
|
|
63
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Methods Constants
|
|
3
|
-
* Domain knowledge: Standard HTTP methods
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export const HTTP_METHOD = {
|
|
7
|
-
GET: "GET",
|
|
8
|
-
POST: "POST",
|
|
9
|
-
PUT: "PUT",
|
|
10
|
-
DELETE: "DELETE",
|
|
11
|
-
PATCH: "PATCH",
|
|
12
|
-
} as const;
|
|
13
|
-
|
|
14
|
-
export type HttpMethod = typeof HTTP_METHOD[keyof typeof HTTP_METHOD];
|
|
15
|
-
|
|
16
|
-
export const HTTP_CONTENT_TYPE = {
|
|
17
|
-
JSON: "application/json",
|
|
18
|
-
TEXT: "text/plain",
|
|
19
|
-
} as const;
|
|
20
|
-
|
|
21
|
-
export const DEFAULT_HEADERS = {
|
|
22
|
-
"Content-Type": HTTP_CONTENT_TYPE.JSON,
|
|
23
|
-
} as const;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Request Executor
|
|
3
|
-
* Infrastructure: Handles low-level fetch operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { env } from "../config/env.config";
|
|
7
|
-
import { createTimeoutController } from "./timeout.util";
|
|
8
|
-
import { DEFAULT_HEADERS } from "./http-methods.constants";
|
|
9
|
-
import type { RequestOptions } from "./api-client.types";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Executes HTTP request with timeout
|
|
13
|
-
*/
|
|
14
|
-
export async function executeRequest(
|
|
15
|
-
url: string,
|
|
16
|
-
options: RequestOptions = {}
|
|
17
|
-
): Promise<Response> {
|
|
18
|
-
const {
|
|
19
|
-
timeout = env.apiDefaultTimeoutMs,
|
|
20
|
-
headers = {},
|
|
21
|
-
...fetchOptions
|
|
22
|
-
} = options;
|
|
23
|
-
|
|
24
|
-
const controller = createTimeoutController(timeout);
|
|
25
|
-
|
|
26
|
-
return fetch(url, {
|
|
27
|
-
...fetchOptions,
|
|
28
|
-
headers: {
|
|
29
|
-
...DEFAULT_HEADERS,
|
|
30
|
-
...headers,
|
|
31
|
-
},
|
|
32
|
-
signal: controller?.signal,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Checks if response is successful
|
|
38
|
-
*/
|
|
39
|
-
export function isSuccessResponse(response: Response): boolean {
|
|
40
|
-
return response.ok;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Extracts error message from failed response
|
|
45
|
-
*/
|
|
46
|
-
export async function extractErrorMessage(response: Response): Promise<string> {
|
|
47
|
-
const errorText = await response.text().catch(() => "Unknown error");
|
|
48
|
-
return `HTTP ${response.status}: ${errorText}`;
|
|
49
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Response Parser
|
|
3
|
-
* Infrastructure: Parses HTTP responses to typed data
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { HTTP_CONTENT_TYPE } from "./http-methods.constants";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Parses response based on content type
|
|
10
|
-
* Note: Type T is not validated at runtime - caller must ensure type safety
|
|
11
|
-
*/
|
|
12
|
-
export async function parseResponse<T>(response: Response): Promise<T> {
|
|
13
|
-
const contentType = response.headers.get("content-type");
|
|
14
|
-
|
|
15
|
-
if (contentType?.includes(HTTP_CONTENT_TYPE.JSON)) {
|
|
16
|
-
try {
|
|
17
|
-
return await response.json();
|
|
18
|
-
} catch (error) {
|
|
19
|
-
throw new Error(`Failed to parse JSON response: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// For non-JSON responses, return text
|
|
24
|
-
// WARNING: Type T is not validated - caller is responsible for type safety
|
|
25
|
-
try {
|
|
26
|
-
const text = await response.text();
|
|
27
|
-
return text as T;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
throw new Error(`Failed to parse text response: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Creates successful API response
|
|
35
|
-
*/
|
|
36
|
-
export function createSuccessResponse<T>(data: T): {
|
|
37
|
-
data: T;
|
|
38
|
-
error: null;
|
|
39
|
-
status: number;
|
|
40
|
-
headers: Headers;
|
|
41
|
-
} {
|
|
42
|
-
return {
|
|
43
|
-
data,
|
|
44
|
-
error: null,
|
|
45
|
-
status: 200,
|
|
46
|
-
headers: new Headers(),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Creates error API response
|
|
52
|
-
*/
|
|
53
|
-
export function createErrorResponse(errorMessage: string): {
|
|
54
|
-
data: null;
|
|
55
|
-
error: string;
|
|
56
|
-
status: number;
|
|
57
|
-
headers: Headers;
|
|
58
|
-
} {
|
|
59
|
-
return {
|
|
60
|
-
data: null,
|
|
61
|
-
error: errorMessage,
|
|
62
|
-
status: 0,
|
|
63
|
-
headers: new Headers(),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP Client Module
|
|
3
|
-
* Exports all HTTP client utilities
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type { RequestOptions, ApiResponse } from "./api-client.types";
|
|
7
|
-
export {
|
|
8
|
-
get,
|
|
9
|
-
post,
|
|
10
|
-
put,
|
|
11
|
-
del,
|
|
12
|
-
patch,
|
|
13
|
-
fetchWithTimeout,
|
|
14
|
-
} from "./http-client.util";
|
|
15
|
-
export { buildQueryString, appendQueryParams } from "./query-string.util";
|
|
16
|
-
export { createTimeoutController } from "./timeout.util";
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Query String Utilities
|
|
3
|
-
* Helper functions for building and manipulating query strings
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Builds query string from object
|
|
8
|
-
* @param params - Object with query parameters
|
|
9
|
-
* @returns Query string (without leading ?)
|
|
10
|
-
*/
|
|
11
|
-
export function buildQueryString(params: Record<string, unknown>): string {
|
|
12
|
-
const searchParams = new URLSearchParams();
|
|
13
|
-
|
|
14
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
15
|
-
if (value !== null && value !== undefined) {
|
|
16
|
-
searchParams.append(key, String(value));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return searchParams.toString();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Appends query parameters to URL
|
|
25
|
-
* @param url - Base URL
|
|
26
|
-
* @param params - Query parameters to append
|
|
27
|
-
* @returns URL with query parameters
|
|
28
|
-
*/
|
|
29
|
-
export function appendQueryParams(
|
|
30
|
-
url: string,
|
|
31
|
-
params: Record<string, unknown>
|
|
32
|
-
): string {
|
|
33
|
-
const queryString = buildQueryString(params);
|
|
34
|
-
if (!queryString) {
|
|
35
|
-
return url;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const separator = url.includes("?") ? "&" : "?";
|
|
39
|
-
return `${url}${separator}${queryString}`;
|
|
40
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Timeout Controller Utility
|
|
3
|
-
* Creates AbortController instances with timeout support
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates an AbortController with timeout
|
|
8
|
-
* @param timeout - Timeout in milliseconds
|
|
9
|
-
* @returns AbortController instance or undefined if no timeout specified
|
|
10
|
-
*/
|
|
11
|
-
export function createTimeoutController(
|
|
12
|
-
timeout?: number
|
|
13
|
-
): AbortController | undefined {
|
|
14
|
-
if (!timeout) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const controller = new AbortController();
|
|
19
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
20
|
-
|
|
21
|
-
controller.signal.addEventListener('abort', () => {
|
|
22
|
-
clearTimeout(timeoutId);
|
|
23
|
-
}, { once: true });
|
|
24
|
-
|
|
25
|
-
return controller;
|
|
26
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Debug logging utility with __DEV__ guard
|
|
3
|
-
* Centralized debug logging for development
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
type LogLevel = "log" | "warn" | "error" | "info";
|
|
7
|
-
|
|
8
|
-
export interface DebugOptions {
|
|
9
|
-
readonly tag?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** Single source of truth for development environment detection */
|
|
13
|
-
export const isDev = typeof __DEV__ !== "undefined" && __DEV__;
|
|
14
|
-
|
|
15
|
-
function formatMessage(tag: string | undefined, message: string): string {
|
|
16
|
-
return tag ? `[${tag}] ${message}` : message;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function log(level: LogLevel, tag: string | undefined, message: string, ...args: readonly unknown[]): void {
|
|
20
|
-
if (!isDev) return;
|
|
21
|
-
|
|
22
|
-
const formattedMessage = formatMessage(tag, message);
|
|
23
|
-
|
|
24
|
-
switch (level) {
|
|
25
|
-
case "error":
|
|
26
|
-
console.error(formattedMessage, ...args);
|
|
27
|
-
break;
|
|
28
|
-
case "warn":
|
|
29
|
-
console.warn(formattedMessage, ...args);
|
|
30
|
-
break;
|
|
31
|
-
case "info":
|
|
32
|
-
console.info(formattedMessage, ...args);
|
|
33
|
-
break;
|
|
34
|
-
default:
|
|
35
|
-
console.log(formattedMessage, ...args);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const debug = {
|
|
40
|
-
log: (message: string, options?: DebugOptions, ...args: readonly unknown[]): void =>
|
|
41
|
-
log("log", options?.tag, message, ...args),
|
|
42
|
-
|
|
43
|
-
warn: (message: string, options?: DebugOptions, ...args: readonly unknown[]): void =>
|
|
44
|
-
log("warn", options?.tag, message, ...args),
|
|
45
|
-
|
|
46
|
-
error: (message: string, options?: DebugOptions, ...args: readonly unknown[]): void =>
|
|
47
|
-
log("error", options?.tag, message, ...args),
|
|
48
|
-
|
|
49
|
-
info: (message: string, options?: DebugOptions, ...args: readonly unknown[]): void =>
|
|
50
|
-
log("info", options?.tag, message, ...args),
|
|
51
|
-
};
|
|
@@ -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
|
-
}
|