@umituz/react-native-ai-generation-content 1.83.12 → 1.83.14

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.83.12",
3
+ "version": "1.83.14",
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",
@@ -4,7 +4,7 @@
4
4
  * Single Responsibility: Firestore query operations
5
5
  */
6
6
 
7
- import { getDocs, getDoc, query, orderBy, where } from "firebase/firestore";
7
+ import { getDocs, getDoc, query, orderBy } from "firebase/firestore";
8
8
  import type { IPathResolver } from "@umituz/react-native-firebase";
9
9
  import type { DocumentMapper } from "../../domain/value-objects/CreationsConfig";
10
10
  import type { Creation, CreationDocument } from "../../domain/entities/Creation";
@@ -28,20 +28,20 @@ export class CreationsQuery {
28
28
  try {
29
29
  const q = query(
30
30
  userCollection,
31
- where(CREATION_FIELDS.DELETED_AT, "==", null),
32
31
  orderBy(CREATION_FIELDS.CREATED_AT, "desc")
33
32
  );
34
33
  const snapshot = await getDocs(q);
35
34
 
36
- const creations = snapshot.docs.map((docSnap) => {
37
- const data = docSnap.data() as CreationDocument;
38
- return this.documentMapper(docSnap.id, data);
39
- });
35
+ const creations = snapshot.docs
36
+ .map((docSnap) => {
37
+ const data = docSnap.data() as CreationDocument;
38
+ return this.documentMapper(docSnap.id, data);
39
+ })
40
+ .filter((c) => c.deletedAt == null);
40
41
 
41
42
  if (__DEV__) {
42
43
  console.log("[CreationsQuery] Fetched creations:", {
43
44
  count: creations.length,
44
- hasDeletedFilter: true,
45
45
  });
46
46
  }
47
47
 
@@ -4,7 +4,7 @@
4
4
  * Single Responsibility: Firestore realtime listeners
5
5
  */
6
6
 
7
- import { query, orderBy, onSnapshot, where } from "firebase/firestore";
7
+ import { query, orderBy, onSnapshot } from "firebase/firestore";
8
8
  import type { IPathResolver } from "@umituz/react-native-firebase";
9
9
  import type { DocumentMapper } from "../../domain/value-objects/CreationsConfig";
10
10
  import type { CreationDocument } from "../../domain/entities/Creation";
@@ -35,7 +35,6 @@ export class CreationsSubscription {
35
35
 
36
36
  const q = query(
37
37
  userCollection,
38
- where(CREATION_FIELDS.DELETED_AT, "==", null),
39
38
  orderBy(CREATION_FIELDS.CREATED_AT, "desc")
40
39
  );
41
40
 
@@ -43,10 +42,12 @@ export class CreationsSubscription {
43
42
  q,
44
43
  { includeMetadataChanges: false },
45
44
  (snapshot) => {
46
- const creations = snapshot.docs.map((docSnap) => {
47
- const data = docSnap.data() as CreationDocument;
48
- return this.documentMapper(docSnap.id, data);
49
- });
45
+ const creations = snapshot.docs
46
+ .map((docSnap) => {
47
+ const data = docSnap.data() as CreationDocument;
48
+ return this.documentMapper(docSnap.id, data);
49
+ })
50
+ .filter((c) => c.deletedAt == null);
50
51
 
51
52
  if (__DEV__) {
52
53
  console.log("[CreationsSubscription] Sync:", creations.length, "items");
@@ -76,7 +76,7 @@ export function useCreations({
76
76
  }
77
77
  unsubscribe();
78
78
  };
79
- }, [userId, repository, enabled, onDataCallback, onErrorCallback]);
79
+ }, [userId, repository, enabled]); // onDataCallback/onErrorCallback intentionally omitted - stable memoized refs
80
80
 
81
81
  return { data, isLoading, error, refetch };
82
82
  }
@@ -16,7 +16,7 @@ interface ModerationHandlerParams<TInput, TResult> {
16
16
  readonly resetState: () => void;
17
17
  readonly executeGeneration: (input: TInput) => Promise<TResult>;
18
18
  readonly showError: (title: string, message: string) => void;
19
- readonly onError?: (error: GenerationError) => void;
19
+ readonly onError?: (error: GenerationError) => void | Promise<void>;
20
20
  readonly handleLifecycleComplete: (status: "success" | "error", result?: TResult, error?: GenerationError) => void;
21
21
  }
22
22
 
@@ -54,13 +54,13 @@ export async function handleModeration<TInput, TResult>(
54
54
  },
55
55
  () => {
56
56
  // Return the promise to allow proper error handling chain
57
- return executeGeneration(input).catch((err) => {
57
+ return executeGeneration(input).catch(async (err) => {
58
58
  const error = parseError(err);
59
59
  if (isMountedRef.current) {
60
60
  setState({ status: "error", isGenerating: false, result: null, error });
61
61
  }
62
62
  showError("Error", getAlertMessage(error, alertMessages));
63
- onError?.(error);
63
+ await onError?.(error);
64
64
  handleLifecycleComplete("error", undefined, error);
65
65
  throw error; // Re-throw to allow caller to handle
66
66
  }).finally(() => {
@@ -109,7 +109,7 @@ export const useGenerationOrchestrator = <TInput, TResult>(
109
109
  }
110
110
 
111
111
  if (alertMessages.success) showSuccess("Success", alertMessages.success);
112
- onSuccess?.(result);
112
+ await onSuccess?.(result);
113
113
  handleLifecycleComplete("success", result);
114
114
  return result;
115
115
  },
@@ -201,7 +201,7 @@ export const useGenerationOrchestrator = <TInput, TResult>(
201
201
  if (typeof __DEV__ !== "undefined" && __DEV__) console.log("[Orchestrator] Error:", error);
202
202
  if (isMountedRef.current) setState({ status: "error", isGenerating: false, result: null, error });
203
203
  showError("Error", getAlertMessage(error, alertMessages));
204
- onError?.(error);
204
+ await onError?.(error);
205
205
  handleLifecycleComplete("error", undefined, error);
206
206
  throw error;
207
207
  } finally {
@@ -54,8 +54,8 @@ export interface LifecycleConfig {
54
54
  export interface GenerationConfig {
55
55
  readonly userId: string | undefined;
56
56
  readonly alertMessages: AlertMessages;
57
- readonly onSuccess?: (result: unknown) => void;
58
- readonly onError?: (error: GenerationError) => void;
57
+ readonly onSuccess?: (result: unknown) => void | Promise<void>;
58
+ readonly onError?: (error: GenerationError) => void | Promise<void>;
59
59
  readonly moderation?: ModerationCallbacks;
60
60
  readonly lifecycle?: LifecycleConfig;
61
61
  }