@umituz/react-native-ai-generation-content 1.26.44 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.26.44",
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
- return snapshot.docs.map((docSnap) => {
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,