@umituz/react-native-ai-generation-content 1.26.43 → 1.26.45
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/infrastructure/builders/dynamic-step-builder.ts +7 -0
- package/src/domains/generation/wizard/presentation/components/GenericWizardFlow.tsx +18 -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.45",
|
|
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,
|
|
@@ -68,6 +68,13 @@ export const buildFlowStepsFromWizard = (
|
|
|
68
68
|
type: StepType.GENERATING,
|
|
69
69
|
required: true,
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
// Always add result preview after generating
|
|
73
|
+
steps.push({
|
|
74
|
+
id: "RESULT_PREVIEW",
|
|
75
|
+
type: StepType.RESULT_PREVIEW,
|
|
76
|
+
required: true,
|
|
77
|
+
});
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
return steps;
|
|
@@ -86,6 +86,7 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
86
86
|
previousStep,
|
|
87
87
|
setCustomData,
|
|
88
88
|
updateProgress,
|
|
89
|
+
setResult,
|
|
89
90
|
} = flow;
|
|
90
91
|
|
|
91
92
|
// Handle progress change - memoized to prevent infinite loops
|
|
@@ -96,6 +97,22 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
96
97
|
[updateProgress],
|
|
97
98
|
);
|
|
98
99
|
|
|
100
|
+
// Handle generation complete - saves result and advances to result preview
|
|
101
|
+
const handleGenerationComplete = useCallback(
|
|
102
|
+
(result: unknown) => {
|
|
103
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
104
|
+
console.log("[GenericWizardFlow] Generation completed, saving result and advancing to result preview");
|
|
105
|
+
}
|
|
106
|
+
// Save result in flow state
|
|
107
|
+
setResult(result);
|
|
108
|
+
// Advance to result preview step
|
|
109
|
+
nextStep();
|
|
110
|
+
// Notify parent
|
|
111
|
+
onGenerationComplete?.(result);
|
|
112
|
+
},
|
|
113
|
+
[setResult, nextStep, onGenerationComplete],
|
|
114
|
+
);
|
|
115
|
+
|
|
99
116
|
// Validate scenario - NO FALLBACK, aiPrompt is REQUIRED
|
|
100
117
|
const validatedScenario = useMemo(() => {
|
|
101
118
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
@@ -148,7 +165,7 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
148
165
|
userId,
|
|
149
166
|
isGeneratingStep: currentStep?.type === StepType.GENERATING,
|
|
150
167
|
alertMessages,
|
|
151
|
-
onSuccess:
|
|
168
|
+
onSuccess: handleGenerationComplete,
|
|
152
169
|
onError: onGenerationError,
|
|
153
170
|
onProgressChange: handleProgressChange,
|
|
154
171
|
onCreditsExhausted,
|