@umituz/react-native-ai-generation-content 1.26.44 → 1.26.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/domains/creations/domain/entities/Creation.ts +11 -0
- package/src/domains/creations/domain/repositories/ICreationsRepository.ts +5 -0
- package/src/domains/creations/infrastructure/repositories/CreationsFetcher.ts +4 -1
- package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +8 -0
- package/src/domains/creations/infrastructure/repositories/CreationsWriter.ts +29 -0
- package/src/domains/generation/wizard/presentation/hooks/usePhotoUploadState.ts +7 -1
- package/src/domains/generation/wizard/presentation/screens/GeneratingScreen.tsx +20 -5
- package/src/domains/scenarios/domain/Scenario.ts +8 -0
- package/src/domains/scenarios/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.46",
|
|
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",
|
|
@@ -35,6 +35,8 @@ export interface Creation {
|
|
|
35
35
|
// Extended fields for job-based creations
|
|
36
36
|
readonly status?: CreationStatus;
|
|
37
37
|
readonly output?: CreationOutput;
|
|
38
|
+
// Soft delete - if set, the creation is considered deleted
|
|
39
|
+
readonly deletedAt?: Date;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export interface CreationDocument {
|
|
@@ -55,6 +57,7 @@ export interface CreationDocument {
|
|
|
55
57
|
readonly ratedAt?: FirebaseTimestamp | Date;
|
|
56
58
|
readonly createdAt: FirebaseTimestamp | Date;
|
|
57
59
|
readonly completedAt?: FirebaseTimestamp | Date;
|
|
60
|
+
readonly deletedAt?: FirebaseTimestamp | Date;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
interface FirebaseTimestamp {
|
|
@@ -89,6 +92,13 @@ export function mapDocumentToCreation(
|
|
|
89
92
|
ratedAtDate = data.ratedAt.toDate();
|
|
90
93
|
}
|
|
91
94
|
|
|
95
|
+
let deletedAtDate: Date | undefined;
|
|
96
|
+
if (data.deletedAt instanceof Date) {
|
|
97
|
+
deletedAtDate = data.deletedAt;
|
|
98
|
+
} else if (data.deletedAt && typeof data.deletedAt === "object" && "toDate" in data.deletedAt && typeof data.deletedAt.toDate === "function") {
|
|
99
|
+
deletedAtDate = data.deletedAt.toDate();
|
|
100
|
+
}
|
|
101
|
+
|
|
92
102
|
return {
|
|
93
103
|
id,
|
|
94
104
|
uri,
|
|
@@ -103,5 +113,6 @@ export function mapDocumentToCreation(
|
|
|
103
113
|
ratedAt: ratedAtDate,
|
|
104
114
|
status: data.status as CreationStatus | undefined,
|
|
105
115
|
output: data.output ?? undefined,
|
|
116
|
+
deletedAt: deletedAtDate,
|
|
106
117
|
};
|
|
107
118
|
}
|
|
@@ -14,7 +14,12 @@ export interface ICreationsRepository {
|
|
|
14
14
|
id: string,
|
|
15
15
|
updates: Partial<Creation>,
|
|
16
16
|
): Promise<boolean>;
|
|
17
|
+
/** Soft delete - sets deletedAt timestamp */
|
|
17
18
|
delete(userId: string, creationId: string): Promise<boolean>;
|
|
19
|
+
/** Hard delete - permanently removes from database */
|
|
20
|
+
hardDelete(userId: string, creationId: string): Promise<boolean>;
|
|
21
|
+
/** Restore a soft-deleted creation */
|
|
22
|
+
restore(userId: string, creationId: string): Promise<boolean>;
|
|
18
23
|
updateShared(
|
|
19
24
|
userId: string,
|
|
20
25
|
creationId: string,
|
|
@@ -33,10 +33,13 @@ export class CreationsFetcher {
|
|
|
33
33
|
console.log("[CreationsRepository] Fetched:", snapshot.docs.length);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const allCreations = snapshot.docs.map((docSnap) => {
|
|
37
37
|
const data = docSnap.data() as CreationDocument;
|
|
38
38
|
return this.documentMapper(docSnap.id, data);
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
// Filter out soft-deleted creations
|
|
42
|
+
return allCreations.filter((creation) => !creation.deletedAt);
|
|
40
43
|
} catch (error) {
|
|
41
44
|
if (__DEV__) {
|
|
42
45
|
|
|
@@ -82,6 +82,14 @@ export class CreationsRepository
|
|
|
82
82
|
return this.writer.delete(userId, creationId);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
async hardDelete(userId: string, creationId: string): Promise<boolean> {
|
|
86
|
+
return this.writer.hardDelete(userId, creationId);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async restore(userId: string, creationId: string): Promise<boolean> {
|
|
90
|
+
return this.writer.restore(userId, creationId);
|
|
91
|
+
}
|
|
92
|
+
|
|
85
93
|
async updateShared(
|
|
86
94
|
userId: string,
|
|
87
95
|
creationId: string,
|
|
@@ -94,6 +94,9 @@ export class CreationsWriter {
|
|
|
94
94
|
if (updates.isFavorite !== undefined) {
|
|
95
95
|
updateData.isFavorite = updates.isFavorite;
|
|
96
96
|
}
|
|
97
|
+
if (updates.deletedAt !== undefined) {
|
|
98
|
+
updateData.deletedAt = updates.deletedAt;
|
|
99
|
+
}
|
|
97
100
|
|
|
98
101
|
await updateDoc(docRef, updateData);
|
|
99
102
|
return true;
|
|
@@ -110,6 +113,19 @@ export class CreationsWriter {
|
|
|
110
113
|
const docRef = this.pathResolver.getDocRef(userId, creationId);
|
|
111
114
|
if (!docRef) return false;
|
|
112
115
|
|
|
116
|
+
try {
|
|
117
|
+
// Soft delete: set deletedAt timestamp instead of hard delete
|
|
118
|
+
await updateDoc(docRef, { deletedAt: new Date() });
|
|
119
|
+
return true;
|
|
120
|
+
} catch {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async hardDelete(userId: string, creationId: string): Promise<boolean> {
|
|
126
|
+
const docRef = this.pathResolver.getDocRef(userId, creationId);
|
|
127
|
+
if (!docRef) return false;
|
|
128
|
+
|
|
113
129
|
try {
|
|
114
130
|
await deleteDoc(docRef);
|
|
115
131
|
return true;
|
|
@@ -118,6 +134,19 @@ export class CreationsWriter {
|
|
|
118
134
|
}
|
|
119
135
|
}
|
|
120
136
|
|
|
137
|
+
async restore(userId: string, creationId: string): Promise<boolean> {
|
|
138
|
+
const docRef = this.pathResolver.getDocRef(userId, creationId);
|
|
139
|
+
if (!docRef) return false;
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
// Remove deletedAt to restore the creation
|
|
143
|
+
await updateDoc(docRef, { deletedAt: null });
|
|
144
|
+
return true;
|
|
145
|
+
} catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
121
150
|
async updateShared(
|
|
122
151
|
userId: string,
|
|
123
152
|
creationId: string,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* NO feature-specific logic - works for ANY photo upload
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { useState, useCallback } from "react";
|
|
7
|
+
import { useState, useCallback, useEffect } from "react";
|
|
8
8
|
import * as ImagePicker from "expo-image-picker";
|
|
9
9
|
import { Alert } from "react-native";
|
|
10
10
|
import type { UploadedImage } from "../../../../../presentation/hooks/generation/useAIGenerateState";
|
|
@@ -41,6 +41,12 @@ export const usePhotoUploadState = ({
|
|
|
41
41
|
}: UsePhotoUploadStateProps): UsePhotoUploadStateReturn => {
|
|
42
42
|
const [image, setImage] = useState<UploadedImage | null>(initialImage || null);
|
|
43
43
|
|
|
44
|
+
// Sync state with initialImage prop when it changes
|
|
45
|
+
// This handles cases where the same component is reused for different steps
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setImage(initialImage || null);
|
|
48
|
+
}, [initialImage]);
|
|
49
|
+
|
|
44
50
|
const maxFileSizeMB = config?.maxFileSizeMB ?? DEFAULT_MAX_FILE_SIZE_MB;
|
|
45
51
|
|
|
46
52
|
const handlePickImage = useCallback(async () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic Generating Screen
|
|
3
3
|
* Shows progress while AI generates content
|
|
4
|
-
*
|
|
4
|
+
* Uses scenario-specific messages with fallback to generic messages
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import React from "react";
|
|
7
|
+
import React, { useMemo } from "react";
|
|
8
8
|
import { View, StyleSheet, ActivityIndicator } from "react-native";
|
|
9
9
|
import { useAppDesignTokens, AtomicText } from "@umituz/react-native-design-system";
|
|
10
10
|
|
|
@@ -13,6 +13,12 @@ export interface GeneratingScreenProps {
|
|
|
13
13
|
readonly scenario?: {
|
|
14
14
|
readonly id: string;
|
|
15
15
|
readonly title?: string;
|
|
16
|
+
readonly category?: string;
|
|
17
|
+
readonly generatingMessages?: {
|
|
18
|
+
readonly title?: string;
|
|
19
|
+
readonly waitMessage?: string;
|
|
20
|
+
readonly hint?: string;
|
|
21
|
+
};
|
|
16
22
|
};
|
|
17
23
|
readonly t: (key: string) => string;
|
|
18
24
|
readonly onCancel?: () => void;
|
|
@@ -33,17 +39,26 @@ export const GeneratingScreen: React.FC<GeneratingScreenProps> = ({
|
|
|
33
39
|
});
|
|
34
40
|
}
|
|
35
41
|
|
|
42
|
+
const messages = useMemo(() => {
|
|
43
|
+
const custom = scenario?.generatingMessages;
|
|
44
|
+
return {
|
|
45
|
+
title: custom?.title || t("generator.title"),
|
|
46
|
+
waitMessage: custom?.waitMessage || t("generator.waitMessage"),
|
|
47
|
+
hint: custom?.hint || t("generator.hint"),
|
|
48
|
+
};
|
|
49
|
+
}, [scenario, t]);
|
|
50
|
+
|
|
36
51
|
return (
|
|
37
52
|
<View style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}>
|
|
38
53
|
<View style={styles.content}>
|
|
39
54
|
<ActivityIndicator size="large" color={tokens.colors.primary} />
|
|
40
55
|
|
|
41
56
|
<AtomicText type="headlineMedium" style={styles.title}>
|
|
42
|
-
{
|
|
57
|
+
{messages.title}
|
|
43
58
|
</AtomicText>
|
|
44
59
|
|
|
45
60
|
<AtomicText type="bodyMedium" style={[styles.message, { color: tokens.colors.textSecondary }]}>
|
|
46
|
-
{
|
|
61
|
+
{messages.waitMessage}
|
|
47
62
|
</AtomicText>
|
|
48
63
|
|
|
49
64
|
{/* Progress Bar */}
|
|
@@ -73,7 +88,7 @@ export const GeneratingScreen: React.FC<GeneratingScreenProps> = ({
|
|
|
73
88
|
|
|
74
89
|
{/* Hint */}
|
|
75
90
|
<AtomicText type="bodySmall" style={[styles.hint, { color: tokens.colors.textSecondary }]}>
|
|
76
|
-
{
|
|
91
|
+
{messages.hint}
|
|
77
92
|
</AtomicText>
|
|
78
93
|
</View>
|
|
79
94
|
</View>
|
|
@@ -555,6 +555,12 @@ export enum ScenarioId {
|
|
|
555
555
|
|
|
556
556
|
export type ScenarioOutputType = "image" | "video";
|
|
557
557
|
|
|
558
|
+
export interface GeneratingMessages {
|
|
559
|
+
title?: string;
|
|
560
|
+
waitMessage?: string;
|
|
561
|
+
hint?: string;
|
|
562
|
+
}
|
|
563
|
+
|
|
558
564
|
export interface Scenario {
|
|
559
565
|
id: ScenarioId;
|
|
560
566
|
category?: ScenarioCategory;
|
|
@@ -570,4 +576,6 @@ export interface Scenario {
|
|
|
570
576
|
outputType: ScenarioOutputType;
|
|
571
577
|
model?: string; // AI model from app config
|
|
572
578
|
enabled?: boolean;
|
|
579
|
+
// Optional custom generating screen messages
|
|
580
|
+
generatingMessages?: GeneratingMessages;
|
|
573
581
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Types
|
|
7
|
-
export type { ScenarioOutputType } from "./domain/Scenario";
|
|
7
|
+
export type { ScenarioOutputType, GeneratingMessages } from "./domain/Scenario";
|
|
8
8
|
export { ScenarioCategory, ScenarioId } from "./domain/Scenario";
|
|
9
9
|
export type { Scenario } from "./domain/Scenario";
|
|
10
10
|
|