@umituz/react-native-ai-generation-content 1.83.0 → 1.83.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/constants/duration-options.constants.ts +1 -0
- package/src/core/constants/index.ts +11 -44
- package/src/core/constants/preset-styles.constants.ts +1 -0
- package/src/core/constants/script-durations.constants.ts +5 -0
- package/src/core/constants/style-options.constants.ts +1 -0
- package/src/domains/access-control/hooks/useAIFeatureGate.ts +0 -1
- package/src/domains/background/infrastructure/services/job-poller.service.ts +0 -1
- package/src/domains/background/infrastructure/utils/result-validation-logic.ts +0 -1
- package/src/domains/content-moderation/infrastructure/services/moderators/text.moderator.ts +0 -1
- package/src/domains/creations/domain/constants/creation-fields.constants.ts +7 -3
- package/src/domains/creations/domain/entities/Creation.ts +22 -35
- package/src/domains/creations/infrastructure/repositories/CreationsQuery.ts +0 -1
- package/src/domains/creations/infrastructure/repositories/CreationsSubscription.ts +0 -1
- package/src/domains/creations/infrastructure/repositories/creation-create.operations.ts +1 -0
- package/src/domains/creations/infrastructure/repositories/creation-error-handler.util.ts +0 -1
- package/src/domains/creations/infrastructure/repositories/creation-update.operations.ts +2 -19
- package/src/domains/creations/presentation/components/GalleryHeader.tsx +0 -1
- package/src/domains/creations/presentation/hooks/useCreationPersistence.ts +0 -1
- package/src/domains/creations/presentation/hooks/useCreationRating.ts +0 -1
- package/src/domains/creations/presentation/hooks/useCreations.ts +0 -1
- package/src/domains/creations/presentation/hooks/useDeleteCreation.ts +0 -1
- package/src/domains/creations/presentation/hooks/useGalleryCallbacks.ts +0 -1
- package/src/domains/creations/presentation/hooks/useProcessingJobsPoller.ts +0 -1
- package/src/domains/generation/application/feature-registry.ts +0 -1
- package/src/domains/generation/application/generation-strategy.factory.ts +0 -1
- package/src/domains/generation/infrastructure/executors/executor-factory.ts +0 -1
- package/src/domains/generation/infrastructure/executors/image-executor.ts +0 -1
- package/src/domains/generation/infrastructure/executors/text-to-image-executor.ts +0 -1
- package/src/domains/generation/infrastructure/executors/video-executor.ts +0 -1
- package/src/domains/generation/infrastructure/flow/useFlowStore.ts +0 -1
- package/src/domains/generation/presentation/useAIGeneration.hook.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/strategies/shared/photo-extraction.utils.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.utils.ts +0 -1
- package/src/domains/generation/wizard/infrastructure/utils/creation-persistence.types.ts +2 -0
- package/src/domains/generation/wizard/infrastructure/utils/creation-save-operations.ts +5 -4
- package/src/domains/generation/wizard/infrastructure/utils/creation-update-operations.ts +8 -2
- package/src/domains/generation/wizard/presentation/components/GenericWizardFlow.tsx +0 -1
- package/src/domains/generation/wizard/presentation/components/step-renderers/renderSelectionStep.tsx +0 -1
- package/src/domains/generation/wizard/presentation/hooks/generationExecutor.ts +0 -1
- package/src/domains/generation/wizard/presentation/hooks/usePhotoBlockingGeneration.ts +0 -1
- package/src/domains/generation/wizard/presentation/hooks/usePhotoUploadState.ts +0 -1
- package/src/domains/generation/wizard/presentation/hooks/useVideoQueueGeneration.ts +9 -4
- package/src/domains/generation/wizard/presentation/hooks/videoQueuePoller.ts +0 -1
- package/src/domains/generation/wizard/presentation/screens/SelectionScreen.tsx +0 -1
- package/src/domains/generation/wizard/presentation/utilities/validateScenario.ts +0 -1
- package/src/domains/image-to-video/presentation/hooks/imageToVideoStrategy.ts +0 -1
- package/src/domains/image-to-video/presentation/hooks/useImageToVideoForm.ts +0 -1
- package/src/domains/result-preview/presentation/hooks/useResultActions.ts +0 -1
- package/src/domains/scenarios/configs/wizard-config-resolver.ts +0 -1
- package/src/domains/scenarios/infrastructure/scenario-registry.ts +0 -1
- package/src/domains/text-to-image/presentation/hooks/useGeneration.ts +0 -1
- package/src/domains/text-to-video/infrastructure/services/text-to-video-executor.ts +0 -1
- package/src/domains/text-to-video/presentation/hooks/textToVideoStrategy.ts +0 -1
- package/src/domains/text-to-video/presentation/hooks/useTextToVideoForm.ts +0 -1
- package/src/infrastructure/config/app-services.config.ts +0 -1
- package/src/infrastructure/executors/base-executor.ts +0 -1
- package/src/infrastructure/http/http-fetch-handler.ts +1 -2
- package/src/infrastructure/logging/debug.util.ts +2 -3
- package/src/infrastructure/logging/index.ts +1 -1
- package/src/infrastructure/providers/generation-config.provider.tsx +0 -1
- package/src/infrastructure/services/generation-orchestrator.service.ts +0 -1
- package/src/infrastructure/services/multi-image-generation.executor.ts +0 -1
- package/src/infrastructure/services/provider-registry.service.ts +0 -2
- package/src/infrastructure/services/provider-validator.ts +0 -1
- package/src/infrastructure/utils/classifier-helpers.ts +0 -1
- package/src/infrastructure/utils/error-classification.ts +0 -1
- package/src/infrastructure/utils/error-handlers.ts +1 -2
- package/src/infrastructure/utils/error-retry.ts +1 -1
- package/src/infrastructure/utils/feature-utils.ts +0 -1
- package/src/infrastructure/utils/index.ts +0 -1
- package/src/infrastructure/utils/message-extractor.ts +18 -1
- package/src/infrastructure/utils/provider-validator.util.ts +0 -1
- package/src/infrastructure/utils/url-extractor/rule-executor.ts +0 -1
- package/src/presentation/components/buttons/GenerateButton.tsx +0 -1
- package/src/presentation/hooks/generation/orchestrator.ts +0 -1
- package/src/presentation/hooks/generation/useImagePicker.ts +0 -1
- package/src/core/constants/model.constants.ts +0 -11
- package/src/core/constants/text-to-image-models.constants.ts +0 -18
- package/src/infrastructure/logging/logger.ts +0 -174
- package/src/infrastructure/utils/error-extractors.ts +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.83.
|
|
3
|
+
"version": "1.83.2",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -1,49 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AI Generation Constants
|
|
3
|
-
* Generic constants reusable across any AI generation app
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Here we export the raw config constants (not UI-specific types).
|
|
4
|
+
* Generic, provider-agnostic constants — single source of truth for all apps.
|
|
5
|
+
* Model IDs and pricing are NOT here: those are always app-level decisions.
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
// Video duration options
|
|
20
|
-
export {
|
|
21
|
-
VIDEO_DURATION,
|
|
22
|
-
VIDEO_DURATION_OPTIONS,
|
|
23
|
-
VIDEO_DURATION_OPTIONS_WITH_LABELS,
|
|
24
|
-
VIDEO_ASPECT_RATIO,
|
|
25
|
-
VIDEO_ASPECT_RATIO_OPTIONS,
|
|
26
|
-
} from "./video.constants";
|
|
27
|
-
export type { VideoAspectRatio } from "./video.constants";
|
|
28
|
-
|
|
29
|
-
// Image constants
|
|
30
|
-
export {
|
|
31
|
-
IMAGE_SIZE,
|
|
32
|
-
DEFAULT_NUM_IMAGES,
|
|
33
|
-
DEFAULT_IMAGE_GUIDANCE_SCALE,
|
|
34
|
-
} from "./image.constants";
|
|
35
|
-
|
|
36
|
-
// Aspect ratio config
|
|
37
|
-
export { ASPECT_RATIO, DEFAULT_IMAGE_SIZES } from "./aspect-ratio.constants";
|
|
38
|
-
|
|
39
|
-
// Status constants
|
|
40
|
-
export { FAL_AI_STATUS, CREATION_STATUS, PROVIDER } from "./status.constants";
|
|
41
|
-
|
|
42
|
-
// Validation limits
|
|
43
|
-
export { VALIDATION_LIMITS } from "./validation.constants";
|
|
44
|
-
|
|
45
|
-
// Polling config
|
|
46
|
-
export { POLLING_CONFIG } from "./polling.constants";
|
|
47
|
-
|
|
48
|
-
// Animation style options
|
|
49
|
-
export { ANIMATION_STYLE } from "./animation.constants";
|
|
8
|
+
export * from "./video.constants";
|
|
9
|
+
export * from "./aspect-ratio.constants";
|
|
10
|
+
export * from "./image.constants";
|
|
11
|
+
export * from "./animation.constants";
|
|
12
|
+
export * from "./validation.constants";
|
|
13
|
+
export * from "./preset-styles.constants";
|
|
14
|
+
export * from "./style-options.constants";
|
|
15
|
+
export * from "./duration-options.constants";
|
|
16
|
+
export * from "./script-durations.constants";
|
|
@@ -10,7 +10,6 @@ import { checkStatusForErrors, isJobComplete } from "../utils/status-checker.uti
|
|
|
10
10
|
import { validateResult } from "../utils/result-validator.util";
|
|
11
11
|
import type { PollJobOptions, PollJobResult } from "./job-poller.types";
|
|
12
12
|
|
|
13
|
-
declare const __DEV__: boolean;
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Wraps a promise with abort signal support
|
|
@@ -11,7 +11,6 @@ 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
13
|
|
|
14
|
-
declare const __DEV__: boolean;
|
|
15
14
|
|
|
16
15
|
class TextModerator extends BaseModerator {
|
|
17
16
|
private maxLength = DEFAULT_MAX_TEXT_LENGTH;
|
|
@@ -32,18 +32,20 @@ export const CREATION_FIELDS = {
|
|
|
32
32
|
|
|
33
33
|
// Timestamps
|
|
34
34
|
CREATED_AT: "createdAt" as const,
|
|
35
|
+
STARTED_AT: "startedAt" as const,
|
|
35
36
|
UPDATED_AT: "updatedAt" as const,
|
|
36
37
|
DELETED_AT: "deletedAt" as const,
|
|
37
38
|
RATED_AT: "ratedAt" as const,
|
|
39
|
+
COMPLETED_AT: "completedAt" as const,
|
|
40
|
+
|
|
41
|
+
// Duration (ms elapsed from startedAt to completedAt)
|
|
42
|
+
DURATION_MS: "durationMs" as const,
|
|
38
43
|
|
|
39
44
|
// User interactions
|
|
40
45
|
IS_FAVORITE: "isFavorite" as const,
|
|
41
46
|
IS_SHARED: "isShared" as const,
|
|
42
47
|
RATING: "rating" as const,
|
|
43
48
|
|
|
44
|
-
// Completion timestamp
|
|
45
|
-
COMPLETED_AT: "completedAt" as const,
|
|
46
|
-
|
|
47
49
|
// AI provider metadata
|
|
48
50
|
REQUEST_ID: "requestId" as const,
|
|
49
51
|
MODEL: "model" as const,
|
|
@@ -73,6 +75,8 @@ export const UPDATABLE_FIELDS: ReadonlyArray<CreationFieldName> = [
|
|
|
73
75
|
CREATION_FIELDS.MODEL,
|
|
74
76
|
CREATION_FIELDS.PROMPT,
|
|
75
77
|
CREATION_FIELDS.COMPLETED_AT,
|
|
78
|
+
CREATION_FIELDS.STARTED_AT,
|
|
79
|
+
CREATION_FIELDS.DURATION_MS,
|
|
76
80
|
] as const;
|
|
77
81
|
|
|
78
82
|
/**
|
|
@@ -39,11 +39,17 @@ export interface Creation {
|
|
|
39
39
|
readonly requestId?: string;
|
|
40
40
|
readonly model?: string;
|
|
41
41
|
// Timestamps
|
|
42
|
-
readonly
|
|
42
|
+
readonly startedAt?: Date; // When generation was submitted to the queue
|
|
43
|
+
readonly completedAt?: Date; // When generation finished (success or failure)
|
|
44
|
+
readonly durationMs?: number; // Elapsed ms from startedAt to completedAt
|
|
43
45
|
// Soft delete - if set, the creation is considered deleted
|
|
44
46
|
readonly deletedAt?: Date;
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
interface FirebaseTimestamp {
|
|
50
|
+
toDate: () => Date;
|
|
51
|
+
}
|
|
52
|
+
|
|
47
53
|
export interface CreationDocument {
|
|
48
54
|
readonly uri?: string;
|
|
49
55
|
readonly prompt?: string;
|
|
@@ -61,30 +67,30 @@ export interface CreationDocument {
|
|
|
61
67
|
readonly rating?: number;
|
|
62
68
|
readonly ratedAt?: FirebaseTimestamp | Date | null;
|
|
63
69
|
readonly createdAt: FirebaseTimestamp | Date;
|
|
70
|
+
readonly startedAt?: FirebaseTimestamp | Date | null;
|
|
64
71
|
readonly completedAt?: FirebaseTimestamp | Date | null;
|
|
65
72
|
readonly deletedAt?: FirebaseTimestamp | Date | null;
|
|
66
73
|
readonly updatedAt?: FirebaseTimestamp | Date | null;
|
|
74
|
+
readonly durationMs?: number;
|
|
67
75
|
// Background job tracking
|
|
68
76
|
readonly requestId?: string;
|
|
69
77
|
readonly model?: string;
|
|
70
78
|
}
|
|
71
79
|
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
function toDate(value: FirebaseTimestamp | Date | null | undefined): Date | undefined {
|
|
81
|
+
if (!value) return undefined;
|
|
82
|
+
if (value instanceof Date) return value;
|
|
83
|
+
if (typeof value === "object" && "toDate" in value && typeof (value as FirebaseTimestamp).toDate === "function") {
|
|
84
|
+
return (value as FirebaseTimestamp).toDate();
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
export function mapDocumentToCreation(
|
|
77
90
|
id: string,
|
|
78
91
|
data: CreationDocument,
|
|
79
92
|
): Creation {
|
|
80
|
-
|
|
81
|
-
if (data.createdAt instanceof Date) {
|
|
82
|
-
creationDate = data.createdAt;
|
|
83
|
-
} else if (data.createdAt && typeof data.createdAt === "object" && "toDate" in data.createdAt && typeof data.createdAt.toDate === "function") {
|
|
84
|
-
creationDate = data.createdAt.toDate();
|
|
85
|
-
} else {
|
|
86
|
-
creationDate = new Date();
|
|
87
|
-
}
|
|
93
|
+
const creationDate = toDate(data.createdAt) ?? new Date();
|
|
88
94
|
|
|
89
95
|
// Get URI from output or direct fields
|
|
90
96
|
const uri = data.output?.imageUrl ||
|
|
@@ -94,27 +100,6 @@ export function mapDocumentToCreation(
|
|
|
94
100
|
data.uri ||
|
|
95
101
|
"";
|
|
96
102
|
|
|
97
|
-
let ratedAtDate: Date | undefined;
|
|
98
|
-
if (data.ratedAt instanceof Date) {
|
|
99
|
-
ratedAtDate = data.ratedAt;
|
|
100
|
-
} else if (data.ratedAt && typeof data.ratedAt === "object" && "toDate" in data.ratedAt && typeof data.ratedAt.toDate === "function") {
|
|
101
|
-
ratedAtDate = data.ratedAt.toDate();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let deletedAtDate: Date | undefined;
|
|
105
|
-
if (data.deletedAt instanceof Date) {
|
|
106
|
-
deletedAtDate = data.deletedAt;
|
|
107
|
-
} else if (data.deletedAt && typeof data.deletedAt === "object" && "toDate" in data.deletedAt && typeof data.deletedAt.toDate === "function") {
|
|
108
|
-
deletedAtDate = data.deletedAt.toDate();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
let completedAtDate: Date | undefined;
|
|
112
|
-
if (data.completedAt instanceof Date) {
|
|
113
|
-
completedAtDate = data.completedAt;
|
|
114
|
-
} else if (data.completedAt && typeof data.completedAt === "object" && "toDate" in data.completedAt && typeof data.completedAt.toDate === "function") {
|
|
115
|
-
completedAtDate = data.completedAt.toDate();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
103
|
return {
|
|
119
104
|
id,
|
|
120
105
|
uri,
|
|
@@ -126,12 +111,14 @@ export function mapDocumentToCreation(
|
|
|
126
111
|
isShared: data.isShared ?? false,
|
|
127
112
|
isFavorite: data.isFavorite ?? false,
|
|
128
113
|
rating: data.rating,
|
|
129
|
-
ratedAt:
|
|
114
|
+
ratedAt: toDate(data.ratedAt),
|
|
130
115
|
status: data.status as CreationStatus | undefined,
|
|
131
116
|
output: data.output ?? undefined,
|
|
132
117
|
requestId: data.requestId,
|
|
133
118
|
model: data.model,
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
startedAt: toDate(data.startedAt),
|
|
120
|
+
completedAt: toDate(data.completedAt),
|
|
121
|
+
durationMs: data.durationMs,
|
|
122
|
+
deletedAt: toDate(data.deletedAt),
|
|
136
123
|
};
|
|
137
124
|
}
|
|
@@ -10,7 +10,6 @@ import type { DocumentMapper } from "../../domain/value-objects/CreationsConfig"
|
|
|
10
10
|
import type { Creation, CreationDocument } from "../../domain/entities/Creation";
|
|
11
11
|
import { CREATION_FIELDS } from "../../domain/constants";
|
|
12
12
|
|
|
13
|
-
declare const __DEV__: boolean;
|
|
14
13
|
|
|
15
14
|
export class CreationsQuery {
|
|
16
15
|
constructor(
|
|
@@ -11,7 +11,6 @@ import type { CreationDocument } from "../../domain/entities/Creation";
|
|
|
11
11
|
import type { CreationsSubscriptionCallback, UnsubscribeFunction } from "../../domain/repositories/ICreationsRepository";
|
|
12
12
|
import { CREATION_FIELDS } from "../../domain/constants";
|
|
13
13
|
|
|
14
|
-
declare const __DEV__: boolean;
|
|
15
14
|
|
|
16
15
|
export class CreationsSubscription {
|
|
17
16
|
constructor(
|
|
@@ -27,6 +27,7 @@ export async function createCreation(
|
|
|
27
27
|
...(creation.prompt !== undefined && { prompt: creation.prompt }),
|
|
28
28
|
...(creation.requestId !== undefined && { requestId: creation.requestId }),
|
|
29
29
|
...(creation.model !== undefined && { model: creation.model }),
|
|
30
|
+
...(creation.startedAt !== undefined && { startedAt: creation.startedAt }),
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
try {
|
|
@@ -5,27 +5,10 @@
|
|
|
5
5
|
import { updateDoc } from "firebase/firestore";
|
|
6
6
|
import type { IPathResolver } from "@umituz/react-native-firebase";
|
|
7
7
|
import type { Creation } from "../../domain/entities/Creation";
|
|
8
|
-
import {
|
|
8
|
+
import { UPDATABLE_FIELDS } from "../../domain/constants";
|
|
9
9
|
|
|
10
|
-
declare const __DEV__: boolean;
|
|
11
10
|
|
|
12
|
-
export
|
|
13
|
-
CREATION_FIELDS.URI,
|
|
14
|
-
CREATION_FIELDS.STATUS,
|
|
15
|
-
CREATION_FIELDS.OUTPUT,
|
|
16
|
-
CREATION_FIELDS.IMAGE_URL,
|
|
17
|
-
CREATION_FIELDS.VIDEO_URL,
|
|
18
|
-
CREATION_FIELDS.METADATA,
|
|
19
|
-
CREATION_FIELDS.IS_SHARED,
|
|
20
|
-
CREATION_FIELDS.IS_FAVORITE,
|
|
21
|
-
CREATION_FIELDS.RATING,
|
|
22
|
-
CREATION_FIELDS.RATED_AT,
|
|
23
|
-
CREATION_FIELDS.DELETED_AT,
|
|
24
|
-
CREATION_FIELDS.REQUEST_ID,
|
|
25
|
-
CREATION_FIELDS.MODEL,
|
|
26
|
-
CREATION_FIELDS.PROMPT,
|
|
27
|
-
"type" as CreationFieldName,
|
|
28
|
-
] as const;
|
|
11
|
+
export { UPDATABLE_FIELDS };
|
|
29
12
|
|
|
30
13
|
export async function updateCreation(
|
|
31
14
|
pathResolver: IPathResolver,
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import { useCallback, useMemo } from "react";
|
|
6
6
|
|
|
7
|
-
declare const __DEV__: boolean;
|
|
8
7
|
import { useAuth } from "@umituz/react-native-auth";
|
|
9
8
|
import { createCreationsRepository } from "../../infrastructure/adapters";
|
|
10
9
|
import type { Creation } from "../../domain/entities/Creation";
|
|
@@ -8,7 +8,6 @@ import { useState, useEffect, useCallback } from "react";
|
|
|
8
8
|
import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
|
|
9
9
|
import type { Creation } from "../../domain/entities/Creation";
|
|
10
10
|
|
|
11
|
-
declare const __DEV__: boolean;
|
|
12
11
|
|
|
13
12
|
interface UseCreationsProps {
|
|
14
13
|
readonly userId: string | null;
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import type { Creation } from "../../domain/entities/Creation";
|
|
17
17
|
import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
|
|
18
18
|
|
|
19
|
-
declare const __DEV__: boolean;
|
|
20
19
|
|
|
21
20
|
export interface UseProcessingJobsPollerConfig {
|
|
22
21
|
readonly userId?: string | null;
|
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
import { ExecutorFactory } from "../infrastructure/executors/executor-factory";
|
|
13
13
|
import { featureRegistry } from "./feature-registry";
|
|
14
14
|
|
|
15
|
-
declare const __DEV__: boolean;
|
|
16
15
|
|
|
17
16
|
interface CreationRepository {
|
|
18
17
|
create(userId: string, creation: unknown): Promise<void>;
|
|
@@ -8,7 +8,6 @@ import { ImageExecutor } from "./image-executor";
|
|
|
8
8
|
import { VideoExecutor } from "./video-executor";
|
|
9
9
|
import { TextToImageExecutor } from "./text-to-image-executor";
|
|
10
10
|
|
|
11
|
-
declare const __DEV__: boolean;
|
|
12
11
|
|
|
13
12
|
export type GenerationType = "image" | "video" | "text-to-image" | "text-to-video" | "image-to-video" | "meme";
|
|
14
13
|
|
|
@@ -13,7 +13,6 @@ import type { GenerationResult } from "../../../../domain/entities/generation.ty
|
|
|
13
13
|
import { providerRegistry } from "../../../../infrastructure/services/provider-registry.service";
|
|
14
14
|
import { env } from "../../../../infrastructure/config/env.config";
|
|
15
15
|
|
|
16
|
-
declare const __DEV__: boolean;
|
|
17
16
|
|
|
18
17
|
export class ImageExecutor
|
|
19
18
|
implements GenerationExecutor<ImageGenerationInput, ImageGenerationOutput>
|
|
@@ -12,7 +12,6 @@ import { providerRegistry } from "../../../../infrastructure/services/provider-r
|
|
|
12
12
|
import type { TextToImageInput, TextToImageOutput } from "./text-to-image-executor.types";
|
|
13
13
|
import { buildModelInput, extractResult } from "./text-to-image-executor.helpers";
|
|
14
14
|
|
|
15
|
-
declare const __DEV__: boolean;
|
|
16
15
|
|
|
17
16
|
export class TextToImageExecutor
|
|
18
17
|
implements GenerationExecutor<TextToImageInput, TextToImageOutput>
|
|
@@ -13,7 +13,6 @@ import type { GenerationResult } from "../../../../domain/entities/generation.ty
|
|
|
13
13
|
import { providerRegistry } from "../../../../infrastructure/services/provider-registry.service";
|
|
14
14
|
import { env } from "../../../../infrastructure/config/env.config";
|
|
15
15
|
|
|
16
|
-
declare const __DEV__: boolean;
|
|
17
16
|
|
|
18
17
|
export class VideoExecutor
|
|
19
18
|
implements GenerationExecutor<VideoGenerationInput, VideoGenerationOutput>
|
|
@@ -9,7 +9,6 @@ import type { AlertMessages } from "../../../presentation/hooks/generation/types
|
|
|
9
9
|
import { DEFAULT_ALERT_MESSAGES } from "../../../presentation/constants/alert-messages";
|
|
10
10
|
import { createGenerationStrategy } from "../application/generation-strategy.factory";
|
|
11
11
|
|
|
12
|
-
declare const __DEV__: boolean;
|
|
13
12
|
|
|
14
13
|
// ============================================================================
|
|
15
14
|
// Types
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type { VideoModelConfig } from "../../../../../domain/interfaces/video-mo
|
|
|
10
10
|
import { GENERATION_TIMEOUT_MS, BASE64_IMAGE_PREFIX } from "./wizard-strategy.constants";
|
|
11
11
|
import { createGenerationError, GenerationErrorType } from "../../../../../infrastructure/utils/error-factory";
|
|
12
12
|
|
|
13
|
-
declare const __DEV__: boolean;
|
|
14
13
|
|
|
15
14
|
interface ExecutionResult {
|
|
16
15
|
success: boolean;
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts
CHANGED
|
@@ -13,7 +13,6 @@ import type { WizardVideoInput, CreateVideoStrategyOptions } from "./video-gener
|
|
|
13
13
|
import { validatePhotoCount, validateWizardVideoInput } from "./video-generation.types";
|
|
14
14
|
import { executeVideoGeneration, submitVideoGenerationToQueue } from "./video-generation.executor";
|
|
15
15
|
|
|
16
|
-
declare const __DEV__: boolean;
|
|
17
16
|
|
|
18
17
|
export type { WizardVideoInput, WizardVideoResult, CreateVideoStrategyOptions } from "./video-generation.types";
|
|
19
18
|
|
|
@@ -7,7 +7,6 @@ import type { VideoFeatureType } from "../../../../../domain/interfaces";
|
|
|
7
7
|
import type { WizardScenarioData } from "../../presentation/hooks/wizard-generation.types";
|
|
8
8
|
import { VIDEO_FEATURE_PATTERNS } from "./wizard-strategy.constants";
|
|
9
9
|
|
|
10
|
-
declare const __DEV__: boolean;
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Determines the video feature type from scenario
|
|
@@ -26,4 +26,6 @@ export interface CompletedCreationData {
|
|
|
26
26
|
readonly imageUrl?: string;
|
|
27
27
|
readonly videoUrl?: string;
|
|
28
28
|
readonly thumbnailUrl?: string;
|
|
29
|
+
/** Unix timestamp (ms) when generation was submitted; used to compute durationMs */
|
|
30
|
+
readonly generationStartedAt?: number;
|
|
29
31
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import type { ICreationsRepository } from "../../../../creations/domain/repositories";
|
|
7
7
|
import type { ProcessingCreationData } from "./creation-persistence.types";
|
|
8
8
|
|
|
9
|
-
declare const __DEV__: boolean;
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Save creation with status="processing" when generation starts
|
|
@@ -16,9 +15,11 @@ export async function saveAsProcessing(
|
|
|
16
15
|
repository: ICreationsRepository,
|
|
17
16
|
userId: string,
|
|
18
17
|
data: ProcessingCreationData
|
|
19
|
-
): Promise<string> {
|
|
18
|
+
): Promise<{ creationId: string; startedAt: Date }> {
|
|
20
19
|
const creationId = `${data.scenarioId}_${Date.now()}`;
|
|
21
20
|
|
|
21
|
+
const startedAt = new Date();
|
|
22
|
+
|
|
22
23
|
await repository.create(userId, {
|
|
23
24
|
id: creationId,
|
|
24
25
|
uri: "",
|
|
@@ -26,6 +27,7 @@ export async function saveAsProcessing(
|
|
|
26
27
|
prompt: data.prompt,
|
|
27
28
|
status: "processing" as const,
|
|
28
29
|
createdAt: new Date(),
|
|
30
|
+
startedAt,
|
|
29
31
|
isShared: false,
|
|
30
32
|
isFavorite: false,
|
|
31
33
|
requestId: data.requestId,
|
|
@@ -39,7 +41,6 @@ export async function saveAsProcessing(
|
|
|
39
41
|
...(data.aspectRatio && { aspectRatio: data.aspectRatio }),
|
|
40
42
|
...(data.provider && { provider: data.provider }),
|
|
41
43
|
...(data.outputType && { outputType: data.outputType }),
|
|
42
|
-
startedAt: new Date().toISOString(),
|
|
43
44
|
},
|
|
44
45
|
});
|
|
45
46
|
|
|
@@ -51,5 +52,5 @@ export async function saveAsProcessing(
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
return creationId;
|
|
55
|
+
return { creationId, startedAt };
|
|
55
56
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import type { ICreationsRepository } from "../../../../creations/domain/repositories";
|
|
7
7
|
import type { CompletedCreationData } from "./creation-persistence.types";
|
|
8
8
|
|
|
9
|
-
declare const __DEV__: boolean;
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Update creation to status="completed" when generation finishes
|
|
@@ -22,11 +21,18 @@ export async function updateToCompleted(
|
|
|
22
21
|
if (data.videoUrl) output.videoUrl = data.videoUrl;
|
|
23
22
|
if (data.thumbnailUrl) output.thumbnailUrl = data.thumbnailUrl;
|
|
24
23
|
|
|
24
|
+
const completedAt = new Date();
|
|
25
|
+
const durationMs =
|
|
26
|
+
data.generationStartedAt !== undefined
|
|
27
|
+
? completedAt.getTime() - data.generationStartedAt
|
|
28
|
+
: undefined;
|
|
29
|
+
|
|
25
30
|
await repository.update(userId, creationId, {
|
|
26
31
|
uri: data.uri,
|
|
27
32
|
status: "completed" as const,
|
|
28
33
|
output,
|
|
29
|
-
completedAt
|
|
34
|
+
completedAt,
|
|
35
|
+
...(durationMs !== undefined && { durationMs }),
|
|
30
36
|
} as Partial<import("../../../../creations/domain/entities/Creation").Creation>);
|
|
31
37
|
|
|
32
38
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
@@ -2,7 +2,6 @@ import { buildWizardInput } from "../../infrastructure/strategies";
|
|
|
2
2
|
import type { WizardScenarioData } from "./wizard-generation.types";
|
|
3
3
|
import type { GenerationAction } from "./generationStateMachine";
|
|
4
4
|
|
|
5
|
-
declare const __DEV__: boolean;
|
|
6
5
|
|
|
7
6
|
interface ExecuteGenerationParams {
|
|
8
7
|
wizardData: Record<string, unknown>;
|
|
@@ -13,7 +13,6 @@ import type { WizardStrategy } from "../../infrastructure/strategies/wizard-stra
|
|
|
13
13
|
import type { WizardScenarioData } from "./wizard-generation.types";
|
|
14
14
|
import type { AlertMessages } from "../../../../../presentation/hooks/generation/types";
|
|
15
15
|
|
|
16
|
-
declare const __DEV__: boolean;
|
|
17
16
|
|
|
18
17
|
export interface UsePhotoBlockingGenerationProps {
|
|
19
18
|
readonly userId?: string;
|