@umituz/react-native-ai-generation-content 1.90.2 → 1.90.4
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 +3 -3
- package/src/domain/interfaces/app-services-auth.interface.ts +27 -0
- package/src/domain/interfaces/app-services-composite.interface.ts +29 -0
- package/src/domain/interfaces/app-services-optional.interface.ts +42 -0
- package/src/domain/interfaces/app-services.interface.ts +0 -79
- package/src/domain/interfaces/index.ts +3 -0
- package/src/domains/background/infrastructure/services/job-poller-index.ts +7 -0
- package/src/domains/background/infrastructure/services/job-poller-utils.ts +127 -0
- package/src/domains/background/infrastructure/services/job-poller.service.ts +85 -140
- package/src/domains/background/infrastructure/utils/polling-interval.util.ts +1 -1
- package/src/domains/background/presentation/hooks/use-background-generation.ts +1 -1
- package/src/domains/content-moderation/index.ts +7 -13
- package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts +1 -1
- package/src/domains/content-moderation/infrastructure/services/moderators/image.moderator.ts +34 -8
- package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +15 -4
- package/src/domains/content-moderation/infrastructure/services/moderators/video.moderator.ts +34 -8
- package/src/domains/content-moderation/infrastructure/services/moderators/voice.moderator.ts +19 -8
- package/src/domains/content-moderation/infrastructure/services/pattern-matcher.service.ts +1 -2
- package/src/domains/creations/domain/types/creation-categories.constants.ts +57 -0
- package/src/domains/creations/domain/types/creation-categories.helpers.ts +67 -0
- package/src/domains/creations/domain/types/creation-categories.ts +7 -114
- package/src/domains/creations/domain/utils/creation-display.util.ts +1 -1
- package/src/domains/creations/domain/utils/status-helpers.ts +1 -1
- package/src/domains/creations/presentation/hooks/creation-validators.ts +31 -29
- package/src/domains/creations/presentation/hooks/job-poller-index.ts +10 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.filters.ts +34 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.logger.ts +76 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.stale-handlers.ts +52 -0
- package/src/domains/creations/presentation/hooks/job-poller-utils.ts +8 -0
- package/src/domains/creations/presentation/hooks/useCreations.ts +1 -1
- package/src/domains/creations/presentation/hooks/useProcessingJobsPoller.ts +18 -235
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +1 -2
- package/src/domains/creations/presentation-exports.ts +2 -2
- package/src/domains/face-detection/domain/entities/FaceDetection.ts +4 -3
- package/src/domains/face-detection/presentation/hooks/useFaceDetection.ts +24 -21
- package/src/domains/generation/infrastructure/appearance-analysis/index.ts +5 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-preparation.ts +58 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-prompt.ts +69 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple-resolution.ts +77 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-couple.ts +54 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-index.ts +8 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder-scenario.ts +112 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/builder.ts +7 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/index.ts +20 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/types.ts +44 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-end-logger.ts +18 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-start-logger.ts +57 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/builder-step-logger.ts +106 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/index.ts +8 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils/types.ts +49 -0
- package/src/domains/generation/infrastructure/couple-generation-builder/utils.ts +8 -0
- package/src/domains/generation/infrastructure/flow/flow-store-actions.ts +105 -0
- package/src/domains/generation/infrastructure/flow/flow-store-initial-state.ts +26 -0
- package/src/domains/generation/infrastructure/flow/useFlowStore.ts +4 -116
- package/src/domains/generation/presentation/useAIGeneration.hook.ts +1 -1
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation-strategy-index.ts +7 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts +2 -12
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.types.ts +11 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.utils.ts +12 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +1 -220
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-builder.ts +66 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-extraction.ts +88 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-prompt-builder.ts +74 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-input-style-enhancements.ts +35 -0
- package/src/domains/generation/wizard/infrastructure/strategies/image-strategy-factory.ts +41 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor-index.ts +10 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-executor.ts +76 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-input-builder.ts +46 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-result-types.ts +17 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation-submission.ts +61 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.audio-extractor.ts +27 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts +2 -176
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.input-builder.ts +90 -0
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +3 -108
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.types.ts +0 -130
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.validation.ts +136 -0
- package/src/domains/generation/wizard/presentation/hooks/photo-upload/index.ts +40 -0
- package/src/domains/generation/wizard/presentation/hooks/photo-upload/types.ts +37 -0
- package/src/domains/generation/wizard/presentation/hooks/photo-upload/usePhotoUploadStateLogic.ts +142 -0
- package/src/domains/generation/wizard/presentation/hooks/use-video-queue-utils.ts +102 -0
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.handlers.ts +97 -0
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.saver.ts +54 -0
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.ts +22 -87
- package/src/domains/generation/wizard/presentation/hooks/usePhotoUploadState.ts +8 -177
- package/src/domains/generation/wizard/presentation/hooks/useVideoQueueGeneration.ts +1 -295
- package/src/domains/generation/wizard/presentation/hooks/useWizardGeneration.ts +1 -1
- package/src/domains/generation/wizard/presentation/hooks/video-queue/index.ts +77 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/use-video-queue-utils.ts +123 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationCallbacks.ts +119 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationPolling.ts +75 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationRefs.ts +65 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue/useVideoQueueGenerationStart.ts +123 -0
- package/src/domains/generation/wizard/presentation/hooks/video-queue-index.ts +9 -0
- package/src/domains/image-to-video/domain/types/image-to-video-state.types.ts +11 -4
- package/src/domains/text-to-image/domain/constants/index.ts +5 -6
- package/src/domains/text-to-image/domain/types/text-to-image.types.ts +43 -22
- package/src/domains/text-to-video/domain/types/request.types.ts +32 -9
- package/src/domains/text-to-video/domain/types/state.types.ts +22 -22
- package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.handlers.ts +44 -0
- package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.ts +5 -51
- package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.types.ts +33 -0
- package/src/exports/features.ts +1 -1
- package/src/infrastructure/services/generation-orchestrator.service.ts +2 -2
- package/src/infrastructure/utils/couple-input-context.ts +13 -0
- package/src/infrastructure/utils/couple-input-index.ts +9 -0
- package/src/infrastructure/utils/couple-input-photorealistic.ts +40 -0
- package/src/infrastructure/utils/couple-input-refiner.ts +101 -0
- package/src/infrastructure/utils/couple-input-resolver.ts +71 -0
- package/src/infrastructure/utils/couple-input-types.ts +11 -0
- package/src/infrastructure/utils/couple-input.util.ts +3 -176
- package/src/infrastructure/utils/photo-generation/photo-preparation.util.ts +1 -1
- package/src/infrastructure/validation/base-validator.ts +3 -26
- package/src/infrastructure/validation/base-validator.types.ts +32 -0
- package/src/presentation/hooks/generation/index.ts +1 -1
- package/src/presentation/hooks/generation/orchestrator-abort-logs.ts +48 -0
- package/src/presentation/hooks/generation/orchestrator-execution-logs.ts +67 -0
- package/src/presentation/hooks/generation/orchestrator-index.ts +14 -0
- package/src/presentation/hooks/generation/orchestrator-start-logs.ts +65 -0
- package/src/presentation/hooks/generation/orchestrator-state-utils.ts +17 -0
- package/src/presentation/hooks/generation/orchestrator-types.ts +55 -0
- package/src/presentation/hooks/generation/orchestrator-utils-index.ts +29 -0
- package/src/presentation/hooks/generation/orchestrator-utils.ts +25 -0
- package/src/presentation/hooks/generation/useDualImageGeneration.ts +1 -1
- package/src/presentation/hooks/generation/useImageGeneration.ts +1 -1
- package/src/presentation/hooks/generation/useVideoGeneration.ts +1 -1
- package/src/shared/hooks/factories/generation-hook-index.ts +12 -0
- package/src/shared/hooks/factories/generation-hook-types.ts +47 -0
- package/src/shared/hooks/factories/generation-hook-utils.ts +94 -0
- package/src/shared/hooks/factories/index.ts +1 -1
- package/src/shared/index.ts +1 -1
- package/src/shared/utils/calculations/aspect-ratio-calculations.ts +30 -0
- package/src/shared/utils/calculations/base64-calculations.ts +26 -0
- package/src/shared/utils/calculations/confidence-calculations.ts +21 -0
- package/src/shared/utils/calculations/cost-calculations-index.ts +43 -0
- package/src/shared/utils/calculations/cost-calculations.ts +25 -0
- package/src/shared/utils/calculations/credit-calculations.ts +37 -0
- package/src/shared/utils/calculations/index.ts +46 -0
- package/src/shared/utils/calculations/math-utilities.ts +32 -0
- package/src/shared/utils/calculations/memory-calculations.ts +33 -0
- package/src/shared/utils/calculations/pagination-calculations.ts +38 -0
- package/src/shared/utils/calculations/percentage-calculations.ts +33 -0
- package/src/shared/utils/calculations/time-calculations.ts +99 -0
- package/src/shared/utils/credit.ts +1 -1
- package/src/shared-kernel/application/hooks/index.ts +8 -0
- package/src/shared-kernel/application/hooks/use-feature-state.ts +106 -0
- package/src/shared-kernel/application/hooks/use-generation-handler.ts +110 -0
- package/src/shared-kernel/base-types/base-callbacks.types.ts +73 -0
- package/src/shared-kernel/base-types/base-feature-state.types.ts +77 -0
- package/src/shared-kernel/base-types/base-generation.types.ts +69 -0
- package/src/shared-kernel/base-types/index.ts +30 -0
- package/src/shared-kernel/domain/base-generation-strategy.ts +146 -0
- package/src/shared-kernel/domain/index.ts +7 -0
- package/src/shared-kernel/index.ts +17 -0
- package/src/shared-kernel/infrastructure/validation/common-validators.ts +126 -0
- package/src/shared-kernel/infrastructure/validation/common-validators.types.ts +33 -0
- package/src/shared-kernel/infrastructure/validation/error-handler.ts +52 -0
- package/src/shared-kernel/infrastructure/validation/error-handler.types.ts +38 -0
- package/src/shared-kernel/infrastructure/validation/error-handler.utils.ts +79 -0
- package/src/shared-kernel/infrastructure/validation/index.ts +70 -0
- package/src/domains/content-moderation/infrastructure/services/index.ts +0 -8
- package/src/domains/creations/domain/constants/index.ts +0 -12
- package/src/domains/creations/domain/utils/index.ts +0 -12
- package/src/domains/generation/infrastructure/couple-generation-builder.ts +0 -374
- package/src/domains/image-to-video/domain/index.ts +0 -2
- package/src/domains/image-to-video/infrastructure/index.ts +0 -1
- package/src/domains/image-to-video/presentation/index.ts +0 -5
- package/src/domains/text-to-video/domain/index.ts +0 -1
- package/src/domains/text-to-video/presentation/index.ts +0 -7
- package/src/presentation/hooks/generation/orchestrator.ts +0 -276
- package/src/shared/hooks/factories/createGenerationHook.ts +0 -253
- package/src/shared/utils/calculations.util.ts +0 -366
|
@@ -38,19 +38,13 @@ export type {
|
|
|
38
38
|
// INFRASTRUCTURE LAYER - Services
|
|
39
39
|
// =============================================================================
|
|
40
40
|
|
|
41
|
-
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
BaseModerator,
|
|
49
|
-
} from "./infrastructure/services";
|
|
50
|
-
|
|
51
|
-
export type {
|
|
52
|
-
PatternMatch,
|
|
53
|
-
} from "./infrastructure/services";
|
|
41
|
+
export { contentModerationService } from "./infrastructure/services/content-moderation.service";
|
|
42
|
+
export { patternMatcherService, type PatternMatch } from "./infrastructure/services/pattern-matcher.service";
|
|
43
|
+
export { textModerator } from "./infrastructure/services/moderators/text.moderator";
|
|
44
|
+
export { imageModerator } from "./infrastructure/services/moderators/image.moderator";
|
|
45
|
+
export { videoModerator } from "./infrastructure/services/moderators/video.moderator";
|
|
46
|
+
export { voiceModerator } from "./infrastructure/services/moderators/voice.moderator";
|
|
47
|
+
export { BaseModerator } from "./infrastructure/services/moderators/base.moderator";
|
|
54
48
|
|
|
55
49
|
// =============================================================================
|
|
56
50
|
// INFRASTRUCTURE LAYER - Rules
|
package/src/domains/content-moderation/infrastructure/services/content-moderation.service.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { imageModerator } from "./moderators/image.moderator";
|
|
|
17
17
|
import { videoModerator } from "./moderators/video.moderator";
|
|
18
18
|
import { voiceModerator } from "./moderators/voice.moderator";
|
|
19
19
|
import { rulesRegistry } from "../rules/rules-registry";
|
|
20
|
-
import { calculateConfidenceScore } from "../../../../shared/utils/calculations
|
|
20
|
+
import { calculateConfidenceScore } from "../../../../shared/utils/calculations";
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
interface ServiceConfig {
|
package/src/domains/content-moderation/infrastructure/services/moderators/image.moderator.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Image Content Moderator
|
|
3
|
-
* Validates and moderates image URIs
|
|
3
|
+
* Validates and moderates image URIs using shared validation utilities
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Violation } from "../../../domain/entities/moderation.types";
|
|
7
7
|
import { BaseModerator, type ModerationResult } from "./base.moderator";
|
|
8
8
|
import { DEFAULT_PROTOCOLS, DEFAULT_MAX_URI_LENGTH } from "../../constants/moderation.constants";
|
|
9
|
+
import { validateUrl, validateString, validateRequiredFields } from "../../../../../shared-kernel/infrastructure/validation";
|
|
9
10
|
|
|
10
11
|
class ImageModerator extends BaseModerator {
|
|
11
12
|
private allowedProtocols: readonly string[] = DEFAULT_PROTOCOLS;
|
|
@@ -29,18 +30,43 @@ class ImageModerator extends BaseModerator {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
private validate(uri: string): Violation | null {
|
|
32
|
-
|
|
33
|
+
// Use shared validation utilities
|
|
34
|
+
const requiredValidation = validateRequiredFields({ uri }, ['uri']);
|
|
35
|
+
if (!requiredValidation.isValid) {
|
|
33
36
|
return this.createViolation("empty-uri", "Image Validation", "empty URI");
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
39
|
+
// Use shared URL validation
|
|
40
|
+
const urlValidation = validateUrl(uri);
|
|
41
|
+
if (!urlValidation.isValid) {
|
|
42
|
+
if (urlValidation.errors.required) {
|
|
43
|
+
return this.createViolation("empty-uri", "Image Validation", "empty URI");
|
|
44
|
+
}
|
|
45
|
+
if (urlValidation.errors.pattern) {
|
|
46
|
+
return this.createViolation(
|
|
47
|
+
"invalid-protocol",
|
|
48
|
+
"Image Validation",
|
|
49
|
+
"invalid protocol"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Use shared string validation for length
|
|
55
|
+
const lengthValidation = validateString(uri, {
|
|
56
|
+
maxLength: this.maxUriLength,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!lengthValidation.isValid) {
|
|
60
|
+
if (lengthValidation.errors.maxLength) {
|
|
61
|
+
return this.createViolation(
|
|
62
|
+
"uri-too-long",
|
|
63
|
+
"Image Validation",
|
|
64
|
+
"URI too long"
|
|
65
|
+
);
|
|
66
|
+
}
|
|
42
67
|
}
|
|
43
68
|
|
|
69
|
+
// Custom protocol check
|
|
44
70
|
if (!this.hasValidProtocol(uri)) {
|
|
45
71
|
return this.createViolation(
|
|
46
72
|
"invalid-protocol",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Text Content Moderator
|
|
3
|
-
* Validates and moderates text content
|
|
3
|
+
* Validates and moderates text content using shared validation utilities
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Violation } from "../../../domain/entities/moderation.types";
|
|
@@ -10,6 +10,7 @@ import { BaseModerator, type ModerationResult } from "./base.moderator";
|
|
|
10
10
|
import { DEFAULT_MAX_TEXT_LENGTH } from "../../constants/moderation.constants";
|
|
11
11
|
import { containsMaliciousPatterns } from "../../utils/content-security.util";
|
|
12
12
|
import { containsPromptInjection } from "../../utils/prompt-injection.util";
|
|
13
|
+
import { validateString, validateRequiredFields } from "../../../../../shared-kernel/infrastructure/validation";
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class TextModerator extends BaseModerator {
|
|
@@ -50,12 +51,22 @@ class TextModerator extends BaseModerator {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
private validate(content: string): Violation | null {
|
|
53
|
-
|
|
54
|
+
// Use shared validation utilities
|
|
55
|
+
const requiredValidation = validateRequiredFields({ content }, ['content']);
|
|
56
|
+
if (!requiredValidation.isValid) {
|
|
54
57
|
return this.createViolation("empty-content", "Validation", "empty");
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
const stringValidation = validateString(content, {
|
|
61
|
+
required: true,
|
|
62
|
+
maxLength: this.maxLength,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!stringValidation.isValid) {
|
|
66
|
+
if (stringValidation.errors.maxLength) {
|
|
67
|
+
return this.createViolation("too-long", "Validation", "length exceeded");
|
|
68
|
+
}
|
|
69
|
+
return this.createViolation("empty-content", "Validation", "empty");
|
|
59
70
|
}
|
|
60
71
|
|
|
61
72
|
if (this.containsMaliciousCode(content)) {
|
package/src/domains/content-moderation/infrastructure/services/moderators/video.moderator.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Video Content Moderator
|
|
3
|
-
* Validates and moderates video URIs
|
|
3
|
+
* Validates and moderates video URIs using shared validation utilities
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Violation } from "../../../domain/entities/moderation.types";
|
|
7
7
|
import { BaseModerator, type ModerationResult } from "./base.moderator";
|
|
8
8
|
import { VIDEO_PROTOCOLS, DEFAULT_MAX_URI_LENGTH } from "../../constants/moderation.constants";
|
|
9
|
+
import { validateUrl, validateString, validateRequiredFields } from "../../../../../shared-kernel/infrastructure/validation";
|
|
9
10
|
|
|
10
11
|
class VideoModerator extends BaseModerator {
|
|
11
12
|
private allowedProtocols: readonly string[] = VIDEO_PROTOCOLS;
|
|
@@ -29,18 +30,43 @@ class VideoModerator extends BaseModerator {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
private validate(uri: string): Violation | null {
|
|
32
|
-
|
|
33
|
+
// Use shared validation utilities
|
|
34
|
+
const requiredValidation = validateRequiredFields({ uri }, ['uri']);
|
|
35
|
+
if (!requiredValidation.isValid) {
|
|
33
36
|
return this.createViolation("empty-uri", "Video Validation", "empty URI");
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
39
|
+
// Use shared URL validation
|
|
40
|
+
const urlValidation = validateUrl(uri);
|
|
41
|
+
if (!urlValidation.isValid) {
|
|
42
|
+
if (urlValidation.errors.required) {
|
|
43
|
+
return this.createViolation("empty-uri", "Video Validation", "empty URI");
|
|
44
|
+
}
|
|
45
|
+
if (urlValidation.errors.pattern) {
|
|
46
|
+
return this.createViolation(
|
|
47
|
+
"invalid-protocol",
|
|
48
|
+
"Video Validation",
|
|
49
|
+
"invalid protocol"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Use shared string validation for length
|
|
55
|
+
const lengthValidation = validateString(uri, {
|
|
56
|
+
maxLength: this.maxUriLength,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!lengthValidation.isValid) {
|
|
60
|
+
if (lengthValidation.errors.maxLength) {
|
|
61
|
+
return this.createViolation(
|
|
62
|
+
"uri-too-long",
|
|
63
|
+
"Video Validation",
|
|
64
|
+
"URI too long"
|
|
65
|
+
);
|
|
66
|
+
}
|
|
42
67
|
}
|
|
43
68
|
|
|
69
|
+
// Custom protocol check
|
|
44
70
|
if (!this.hasValidProtocol(uri)) {
|
|
45
71
|
return this.createViolation(
|
|
46
72
|
"invalid-protocol",
|
package/src/domains/content-moderation/infrastructure/services/moderators/voice.moderator.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Voice Content Moderator
|
|
3
|
-
* Validates and moderates voice/TTS text content
|
|
3
|
+
* Validates and moderates voice/TTS text content using shared validation utilities
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Violation } from "../../../domain/entities/moderation.types";
|
|
@@ -8,6 +8,7 @@ import { patternMatcherService } from "../pattern-matcher.service";
|
|
|
8
8
|
import { rulesRegistry } from "../../rules/rules-registry";
|
|
9
9
|
import { BaseModerator, type ModerationResult } from "./base.moderator";
|
|
10
10
|
import { env } from "../../../../../infrastructure/config/env.config";
|
|
11
|
+
import { validateString, validateRequiredFields } from "../../../../../shared-kernel/infrastructure/validation";
|
|
11
12
|
|
|
12
13
|
class VoiceModerator extends BaseModerator {
|
|
13
14
|
private maxLength = env.moderationVoiceMaxLength;
|
|
@@ -27,16 +28,26 @@ class VoiceModerator extends BaseModerator {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
private validate(text: string): Violation | null {
|
|
30
|
-
|
|
31
|
+
// Use shared validation utilities
|
|
32
|
+
const requiredValidation = validateRequiredFields({ text }, ['text']);
|
|
33
|
+
if (!requiredValidation.isValid) {
|
|
31
34
|
return this.createViolation("empty-text", "Voice Validation", "empty");
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const stringValidation = validateString(text, {
|
|
38
|
+
required: true,
|
|
39
|
+
maxLength: this.maxLength,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!stringValidation.isValid) {
|
|
43
|
+
if (stringValidation.errors.maxLength) {
|
|
44
|
+
return this.createViolation(
|
|
45
|
+
"too-long",
|
|
46
|
+
"Voice Validation",
|
|
47
|
+
"length exceeded"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return this.createViolation("empty-text", "Voice Validation", "empty");
|
|
40
51
|
}
|
|
41
52
|
|
|
42
53
|
return null;
|
|
@@ -113,8 +113,7 @@ class PatternMatcherService {
|
|
|
113
113
|
const regex = new RegExp(escaped, "gi");
|
|
114
114
|
return regex.test(content);
|
|
115
115
|
} catch {
|
|
116
|
-
|
|
117
|
-
return content.toLowerCase().includes(searchTerm.toLowerCase());
|
|
116
|
+
return false;
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creation Categories - Constants
|
|
3
|
+
* Constants for creation type categories
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { CreationTypeId } from "./creation-types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Image-related creation types
|
|
10
|
+
*/
|
|
11
|
+
export const IMAGE_CREATION_TYPES: CreationTypeId[] = [
|
|
12
|
+
"text-to-image",
|
|
13
|
+
"imagine",
|
|
14
|
+
"wardrobe",
|
|
15
|
+
"historical-wardrobe",
|
|
16
|
+
"upscale",
|
|
17
|
+
"remove-background",
|
|
18
|
+
"photo-restore",
|
|
19
|
+
"inpainting",
|
|
20
|
+
"style-transfer",
|
|
21
|
+
"colorization",
|
|
22
|
+
"face-swap",
|
|
23
|
+
"object-removal",
|
|
24
|
+
"background-replacement",
|
|
25
|
+
"ai-brush",
|
|
26
|
+
"hd-touch-up",
|
|
27
|
+
"anime-selfie",
|
|
28
|
+
"aging",
|
|
29
|
+
"headshot",
|
|
30
|
+
"retouch",
|
|
31
|
+
"magic-edit",
|
|
32
|
+
"color-grading",
|
|
33
|
+
"art-style",
|
|
34
|
+
"mood-filter",
|
|
35
|
+
"face-expression",
|
|
36
|
+
"scene-composer",
|
|
37
|
+
"ai-background",
|
|
38
|
+
"effects",
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Video-related creation types (core types only)
|
|
43
|
+
* NOTE: All other video types (scenarios, etc.)
|
|
44
|
+
* are dynamically determined by output content via isVideoUrl()
|
|
45
|
+
*/
|
|
46
|
+
export const VIDEO_CREATION_TYPES: CreationTypeId[] = [
|
|
47
|
+
"text-to-video",
|
|
48
|
+
"image-to-video",
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* All creation types
|
|
53
|
+
*/
|
|
54
|
+
export const ALL_CREATION_TYPES: CreationTypeId[] = [
|
|
55
|
+
...IMAGE_CREATION_TYPES,
|
|
56
|
+
...VIDEO_CREATION_TYPES,
|
|
57
|
+
];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creation Categories - Helpers
|
|
3
|
+
* Helper functions for creation type categorization
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { CreationTypeId, CreationCategory } from "./creation-types";
|
|
7
|
+
import { IMAGE_CREATION_TYPES, VIDEO_CREATION_TYPES } from "./creation-categories.constants";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get creation types for a category
|
|
11
|
+
*/
|
|
12
|
+
export function getTypesForCategory(
|
|
13
|
+
category: CreationCategory
|
|
14
|
+
): CreationTypeId[] {
|
|
15
|
+
switch (category) {
|
|
16
|
+
case "image":
|
|
17
|
+
return IMAGE_CREATION_TYPES;
|
|
18
|
+
case "video":
|
|
19
|
+
return VIDEO_CREATION_TYPES;
|
|
20
|
+
case "all":
|
|
21
|
+
return [...IMAGE_CREATION_TYPES, ...VIDEO_CREATION_TYPES];
|
|
22
|
+
default:
|
|
23
|
+
return [...IMAGE_CREATION_TYPES, ...VIDEO_CREATION_TYPES];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get category for a creation type
|
|
29
|
+
*/
|
|
30
|
+
export function getCategoryForType(type: CreationTypeId): CreationCategory {
|
|
31
|
+
if (IMAGE_CREATION_TYPES.includes(type)) {
|
|
32
|
+
return "image";
|
|
33
|
+
}
|
|
34
|
+
if (VIDEO_CREATION_TYPES.includes(type)) {
|
|
35
|
+
return "video";
|
|
36
|
+
}
|
|
37
|
+
return "image";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Check if a type belongs to a category
|
|
42
|
+
*/
|
|
43
|
+
export function isTypeInCategory(
|
|
44
|
+
type: CreationTypeId,
|
|
45
|
+
category: CreationCategory
|
|
46
|
+
): boolean {
|
|
47
|
+
if (category === "all") {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return getTypesForCategory(category).includes(type);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Check if creation type is video
|
|
55
|
+
*/
|
|
56
|
+
export function isVideoCreationType(type?: string): boolean {
|
|
57
|
+
if (!type) return false;
|
|
58
|
+
return VIDEO_CREATION_TYPES.includes(type as CreationTypeId);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Check if creation type is image
|
|
63
|
+
*/
|
|
64
|
+
export function isImageCreationType(type?: string): boolean {
|
|
65
|
+
if (!type) return false;
|
|
66
|
+
return IMAGE_CREATION_TYPES.includes(type as CreationTypeId);
|
|
67
|
+
}
|
|
@@ -3,89 +3,8 @@
|
|
|
3
3
|
* Maps creation types to categories for filtering and organization
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Image-related creation types
|
|
10
|
-
*/
|
|
11
|
-
export const IMAGE_CREATION_TYPES: CreationTypeId[] = [
|
|
12
|
-
"text-to-image",
|
|
13
|
-
"imagine",
|
|
14
|
-
"wardrobe",
|
|
15
|
-
"historical-wardrobe",
|
|
16
|
-
"upscale",
|
|
17
|
-
"remove-background",
|
|
18
|
-
"photo-restore",
|
|
19
|
-
"inpainting",
|
|
20
|
-
"style-transfer",
|
|
21
|
-
"colorization",
|
|
22
|
-
"face-swap",
|
|
23
|
-
"object-removal",
|
|
24
|
-
"background-replacement",
|
|
25
|
-
"ai-brush",
|
|
26
|
-
"hd-touch-up",
|
|
27
|
-
"anime-selfie",
|
|
28
|
-
"aging",
|
|
29
|
-
"headshot",
|
|
30
|
-
"retouch",
|
|
31
|
-
"magic-edit",
|
|
32
|
-
"color-grading",
|
|
33
|
-
"art-style",
|
|
34
|
-
"mood-filter",
|
|
35
|
-
"face-expression",
|
|
36
|
-
"scene-composer",
|
|
37
|
-
"ai-background",
|
|
38
|
-
"effects",
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Video-related creation types (core types only)
|
|
43
|
-
* NOTE: All other video types (scenarios, etc.)
|
|
44
|
-
* are dynamically determined by output content via isVideoUrl()
|
|
45
|
-
*/
|
|
46
|
-
export const VIDEO_CREATION_TYPES: CreationTypeId[] = [
|
|
47
|
-
"text-to-video",
|
|
48
|
-
"image-to-video",
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* All creation types
|
|
53
|
-
*/
|
|
54
|
-
export const ALL_CREATION_TYPES: CreationTypeId[] = [
|
|
55
|
-
...IMAGE_CREATION_TYPES,
|
|
56
|
-
...VIDEO_CREATION_TYPES,
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Get creation types for a category
|
|
61
|
-
*/
|
|
62
|
-
export function getTypesForCategory(
|
|
63
|
-
category: CreationCategory
|
|
64
|
-
): CreationTypeId[] {
|
|
65
|
-
switch (category) {
|
|
66
|
-
case "image":
|
|
67
|
-
return IMAGE_CREATION_TYPES;
|
|
68
|
-
case "video":
|
|
69
|
-
return VIDEO_CREATION_TYPES;
|
|
70
|
-
case "all":
|
|
71
|
-
return ALL_CREATION_TYPES;
|
|
72
|
-
default:
|
|
73
|
-
return ALL_CREATION_TYPES;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get category for a creation type (type-based fallback only)
|
|
79
|
-
*/
|
|
80
|
-
export function getCategoryForType(type: CreationTypeId): CreationCategory {
|
|
81
|
-
if (IMAGE_CREATION_TYPES.includes(type)) {
|
|
82
|
-
return "image";
|
|
83
|
-
}
|
|
84
|
-
if (VIDEO_CREATION_TYPES.includes(type)) {
|
|
85
|
-
return "video";
|
|
86
|
-
}
|
|
87
|
-
return "image"; // Default fallback
|
|
88
|
-
}
|
|
6
|
+
import type { CreationCategory } from "./creation-types";
|
|
7
|
+
import { getCategoryForType } from "./creation-categories.helpers";
|
|
89
8
|
|
|
90
9
|
/**
|
|
91
10
|
* Get category for a creation based on its output content
|
|
@@ -106,7 +25,7 @@ export function getCategoryForCreation(creation: {
|
|
|
106
25
|
};
|
|
107
26
|
uri?: string;
|
|
108
27
|
}): CreationCategory {
|
|
109
|
-
//
|
|
28
|
+
// Check output field names
|
|
110
29
|
if (creation.output?.videoUrl) {
|
|
111
30
|
return "video";
|
|
112
31
|
}
|
|
@@ -115,40 +34,14 @@ export function getCategoryForCreation(creation: {
|
|
|
115
34
|
return "image";
|
|
116
35
|
}
|
|
117
36
|
|
|
118
|
-
//
|
|
37
|
+
// Use type-based categorization
|
|
119
38
|
if (creation.type) {
|
|
120
|
-
return getCategoryForType(creation.type as CreationTypeId);
|
|
39
|
+
return getCategoryForType(creation.type as import("./creation-types").CreationTypeId);
|
|
121
40
|
}
|
|
122
41
|
|
|
123
|
-
// Final fallback
|
|
124
42
|
return "image";
|
|
125
43
|
}
|
|
126
44
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*/
|
|
130
|
-
export function isTypeInCategory(
|
|
131
|
-
type: CreationTypeId,
|
|
132
|
-
category: CreationCategory
|
|
133
|
-
): boolean {
|
|
134
|
-
if (category === "all") {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
return getTypesForCategory(category).includes(type);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Check if creation type is video
|
|
142
|
-
*/
|
|
143
|
-
export function isVideoCreationType(type?: string): boolean {
|
|
144
|
-
if (!type) return false;
|
|
145
|
-
return VIDEO_CREATION_TYPES.includes(type as CreationTypeId);
|
|
146
|
-
}
|
|
45
|
+
export { IMAGE_CREATION_TYPES, VIDEO_CREATION_TYPES, ALL_CREATION_TYPES } from "./creation-categories.constants";
|
|
46
|
+
export { getTypesForCategory, getCategoryForType, isTypeInCategory, isVideoCreationType, isImageCreationType } from "./creation-categories.helpers";
|
|
147
47
|
|
|
148
|
-
/**
|
|
149
|
-
* Check if creation type is image
|
|
150
|
-
*/
|
|
151
|
-
export function isImageCreationType(type?: string): boolean {
|
|
152
|
-
if (!type) return false;
|
|
153
|
-
return IMAGE_CREATION_TYPES.includes(type as CreationTypeId);
|
|
154
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creation Validation Utilities
|
|
3
3
|
*
|
|
4
|
-
* Centralized validation logic for creation persistence.
|
|
4
|
+
* Centralized validation logic for creation persistence using shared kernel.
|
|
5
5
|
* Keeps validation rules separate from hook logic.
|
|
6
6
|
*
|
|
7
7
|
* @module CreationValidators
|
|
@@ -13,12 +13,7 @@ import {
|
|
|
13
13
|
CREATION_FIELDS,
|
|
14
14
|
} from "../../domain/constants";
|
|
15
15
|
import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
interface ValidationResult {
|
|
19
|
-
isValid: boolean;
|
|
20
|
-
error?: string;
|
|
21
|
-
}
|
|
16
|
+
import { validateUrl, validateString, combineValidationResults, type ValidationResult } from "../../../../shared-kernel/infrastructure/validation";
|
|
22
17
|
|
|
23
18
|
/**
|
|
24
19
|
* Validates that at least one URL is present
|
|
@@ -30,10 +25,10 @@ function validateHasUrl(
|
|
|
30
25
|
if (!imageUrl && !videoUrl) {
|
|
31
26
|
return {
|
|
32
27
|
isValid: false,
|
|
33
|
-
|
|
28
|
+
errors: { urls: "No output URL provided" },
|
|
34
29
|
};
|
|
35
30
|
}
|
|
36
|
-
return { isValid: true };
|
|
31
|
+
return { isValid: true, errors: {} };
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
/**
|
|
@@ -47,42 +42,49 @@ function validateUriProtocol(uri: string): ValidationResult {
|
|
|
47
42
|
if (!hasValidProtocol) {
|
|
48
43
|
return {
|
|
49
44
|
isValid: false,
|
|
50
|
-
|
|
45
|
+
errors: {
|
|
46
|
+
protocol: `Invalid URI protocol. Expected one of: ${CREATION_VALIDATION.VALID_URI_PROTOCOLS.join(", ")}`
|
|
47
|
+
},
|
|
51
48
|
};
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
return { isValid: true };
|
|
51
|
+
return { isValid: true, errors: {} };
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
/**
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
function validateUriLength(uri: string): ValidationResult {
|
|
61
|
-
if (uri.length > CREATION_VALIDATION.MAX_URI_LENGTH) {
|
|
62
|
-
return {
|
|
63
|
-
isValid: false,
|
|
64
|
-
error: `URI length (${uri.length}) exceeds maximum (${CREATION_VALIDATION.MAX_URI_LENGTH})`,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return { isValid: true };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Runs all validations and returns first error
|
|
55
|
+
* Runs all validations using shared kernel utilities
|
|
73
56
|
*/
|
|
74
57
|
export function runAllValidations(
|
|
75
58
|
imageUrl?: string,
|
|
76
59
|
videoUrl?: string
|
|
77
60
|
): ValidationResult {
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
// Check that at least one URL is present
|
|
62
|
+
const hasUrlCheck = validateHasUrl(imageUrl, videoUrl);
|
|
63
|
+
if (!hasUrlCheck.isValid) return hasUrlCheck;
|
|
80
64
|
|
|
81
65
|
const uri = imageUrl || videoUrl || "";
|
|
66
|
+
|
|
67
|
+
// Use shared URL validation
|
|
68
|
+
const urlValidation = validateUrl(uri);
|
|
69
|
+
if (!urlValidation.isValid) return urlValidation;
|
|
70
|
+
|
|
71
|
+
// Use shared string validation for length
|
|
72
|
+
const lengthValidation = validateString(uri, {
|
|
73
|
+
maxLength: CREATION_VALIDATION.MAX_URI_LENGTH,
|
|
74
|
+
});
|
|
75
|
+
if (!lengthValidation.isValid) return lengthValidation;
|
|
76
|
+
|
|
77
|
+
// Validate protocol
|
|
82
78
|
const protocolCheck = validateUriProtocol(uri);
|
|
83
79
|
if (!protocolCheck.isValid) return protocolCheck;
|
|
84
80
|
|
|
85
|
-
|
|
81
|
+
// Combine all results
|
|
82
|
+
return combineValidationResults(
|
|
83
|
+
hasUrlCheck,
|
|
84
|
+
urlValidation,
|
|
85
|
+
lengthValidation,
|
|
86
|
+
protocolCheck
|
|
87
|
+
);
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processing Jobs Poller Hook
|
|
3
|
+
* Polls queue status for "processing" creations and updates Firestore when complete
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { useProcessingJobsPoller } from "./useProcessingJobsPoller";
|
|
7
|
+
export type {
|
|
8
|
+
UseProcessingJobsPollerConfig,
|
|
9
|
+
UseProcessingJobsPollerReturn,
|
|
10
|
+
} from "./useProcessingJobsPoller";
|