@umituz/react-native-ai-generation-content 1.66.6 → 1.67.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.66.6",
3
+ "version": "1.67.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",
@@ -39,15 +39,15 @@
39
39
  "url": "git+https://github.com/umituz/react-native-ai-generation-content.git"
40
40
  },
41
41
  "dependencies": {
42
- "@umituz/react-native-auth": "^3.6.25"
42
+ "@umituz/react-native-auth": "latest"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@react-navigation/native": ">=6.0.0",
46
46
  "@tanstack/react-query": ">=5.0.0",
47
47
  "@umituz/react-native-design-system": ">=4.0.0",
48
+ "@umituz/react-native-firebase": ">=1.0.0",
48
49
  "@umituz/react-native-subscription": ">=2.23.0",
49
50
  "@umituz/react-native-video-editor": ">=1.0.0",
50
- "@umituz/react-native-firebase": ">=1.0.0",
51
51
  "expo": ">=54.0.0",
52
52
  "expo-video": ">=1.0.0",
53
53
  "firebase": ">=10.0.0",
@@ -69,9 +69,9 @@
69
69
  "@types/react": "~19.1.10",
70
70
  "@typescript-eslint/eslint-plugin": "^8.54.0",
71
71
  "@typescript-eslint/parser": "^8.54.0",
72
- "@umituz/react-native-design-system": "^4.23.79",
73
- "@umituz/react-native-firebase": "^1.13.161",
74
- "@umituz/react-native-subscription": "^2.27.23",
72
+ "@umituz/react-native-design-system": "latest",
73
+ "@umituz/react-native-firebase": "latest",
74
+ "@umituz/react-native-subscription": "latest",
75
75
  "eslint": "^9.39.2",
76
76
  "eslint-plugin-react": "^7.37.5",
77
77
  "eslint-plugin-react-hooks": "^7.0.1",
@@ -1,36 +1,21 @@
1
- import type { CollectionReference, DocumentReference, DocumentData } from "firebase/firestore";
1
+ import type { IPathResolver } from "@umituz/react-native-firebase";
2
+ export type { IPathResolver };
2
3
  import type { DocumentMapper } from "../../domain/value-objects/CreationsConfig";
3
4
  import type { Creation } from "../../domain/entities/Creation";
4
5
  import type { CreationsSubscriptionCallback, UnsubscribeFunction } from "../../domain/repositories/ICreationsRepository";
5
6
  import { CreationsQuery } from "./CreationsQuery";
6
7
  import { CreationsSubscription } from "./CreationsSubscription";
7
8
 
8
- /**
9
- * Path resolver functions from BaseRepository
10
- */
11
- export type GetUserCollection = (userId: string) => CollectionReference<DocumentData> | null;
12
- export type GetDocRef = (userId: string, documentId: string) => DocumentReference<DocumentData> | null;
13
-
14
- /**
15
- * CreationsFetcher
16
- * Orchestrates read operations for creations
17
- * Delegates to specialized classes for queries and subscriptions
18
- *
19
- * Architecture: Facade pattern
20
- * - Query operations → CreationsQuery
21
- * - Subscription operations → CreationsSubscription
22
- */
23
9
  export class CreationsFetcher {
24
10
  private readonly query: CreationsQuery;
25
11
  private readonly subscription: CreationsSubscription;
26
12
 
27
13
  constructor(
28
- getUserCollection: GetUserCollection,
29
- getDocRef: GetDocRef,
14
+ pathResolver: IPathResolver,
30
15
  documentMapper: DocumentMapper,
31
16
  ) {
32
- this.query = new CreationsQuery(getUserCollection, getDocRef, documentMapper);
33
- this.subscription = new CreationsSubscription(getUserCollection, getDocRef, documentMapper);
17
+ this.query = new CreationsQuery(pathResolver, documentMapper);
18
+ this.subscription = new CreationsSubscription(pathResolver, documentMapper);
34
19
  }
35
20
 
36
21
  /**
@@ -5,20 +5,16 @@
5
5
  */
6
6
 
7
7
  import { getDocs, getDoc, query, orderBy, where } from "firebase/firestore";
8
- import type { GetUserCollection, GetDocRef } from "./CreationsFetcher";
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";
11
11
  import { CREATION_FIELDS } from "../../domain/constants";
12
12
 
13
13
  declare const __DEV__: boolean;
14
14
 
15
- /**
16
- * Handles query operations for creations
17
- */
18
15
  export class CreationsQuery {
19
16
  constructor(
20
- private readonly getUserCollection: GetUserCollection,
21
- private readonly getDocRef: GetDocRef,
17
+ private readonly pathResolver: IPathResolver,
22
18
  private readonly documentMapper: DocumentMapper,
23
19
  ) { }
24
20
 
@@ -27,7 +23,7 @@ export class CreationsQuery {
27
23
  * Optimized query: Server-side filtering for non-deleted items
28
24
  */
29
25
  async getAll(userId: string): Promise<Creation[]> {
30
- const userCollection = this.getUserCollection(userId);
26
+ const userCollection = this.pathResolver.getUserCollection(userId);
31
27
  if (!userCollection) return [];
32
28
 
33
29
  try {
@@ -63,7 +59,7 @@ export class CreationsQuery {
63
59
  * Get a single creation by ID
64
60
  */
65
61
  async getById(userId: string, id: string): Promise<Creation | null> {
66
- const docRef = this.getDocRef(userId, id);
62
+ const docRef = this.pathResolver.getDocRef(userId, id);
67
63
  if (!docRef) return null;
68
64
 
69
65
  try {
@@ -43,16 +43,8 @@ export class CreationsRepository
43
43
 
44
44
  const documentMapper = options?.documentMapper ?? mapDocumentToCreation;
45
45
 
46
- // Pass BaseRepository methods directly to dependencies
47
- this.fetcher = new CreationsFetcher(
48
- (userId) => this.getUserCollection(userId),
49
- (userId, docId) => this.getDocRef(userId, docId),
50
- documentMapper
51
- );
52
- this.writer = new CreationsWriter(
53
- (userId) => this.getUserCollection(userId),
54
- (userId, docId) => this.getDocRef(userId, docId)
55
- );
46
+ this.fetcher = new CreationsFetcher(this, documentMapper);
47
+ this.writer = new CreationsWriter(this);
56
48
  }
57
49
 
58
50
  async getAll(userId: string): Promise<Creation[]> {
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { query, orderBy, onSnapshot, where } from "firebase/firestore";
8
- import type { GetUserCollection } from "./CreationsFetcher";
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";
11
11
  import type { CreationsSubscriptionCallback, UnsubscribeFunction } from "../../domain/repositories/ICreationsRepository";
@@ -13,14 +13,9 @@ import { CREATION_FIELDS } from "../../domain/constants";
13
13
 
14
14
  declare const __DEV__: boolean;
15
15
 
16
- /**
17
- * Handles realtime subscriptions for creations
18
- * Optimized with server-side filtering (80% data reduction)
19
- */
20
16
  export class CreationsSubscription {
21
17
  constructor(
22
- private readonly getUserCollection: GetUserCollection,
23
- _getDocRef: unknown, // Not used in subscription, but accepted for consistent interface
18
+ private readonly pathResolver: IPathResolver,
24
19
  private readonly documentMapper: DocumentMapper,
25
20
  ) { }
26
21
 
@@ -29,7 +24,7 @@ export class CreationsSubscription {
29
24
  onData: CreationsSubscriptionCallback,
30
25
  onError?: (error: Error) => void,
31
26
  ): UnsubscribeFunction {
32
- const userCollection = this.getUserCollection(userId);
27
+ const userCollection = this.pathResolver.getUserCollection(userId);
33
28
 
34
29
  if (!userCollection) {
35
30
  const error = new Error(`[CreationsSubscription] Invalid user collection: ${userId}`);
@@ -1,51 +1,42 @@
1
- /**
2
- * Creations Writer
3
- * Main class that orchestrates all creation write operations
4
- */
5
-
6
- import type { GetUserCollection, GetDocRef } from "./CreationsFetcher";
1
+ import type { IPathResolver } from "@umituz/react-native-firebase";
7
2
  import type { Creation } from "../../domain/entities/Creation";
8
3
  import * as operations from "./creations-operations";
9
4
  import * as stateOperations from "./creations-state-operations";
10
5
 
11
- /**
12
- * Handles write operations for creations
13
- */
14
6
  export class CreationsWriter {
15
7
  constructor(
16
- private readonly getUserCollection: GetUserCollection,
17
- private readonly getDocRef: GetDocRef,
8
+ private readonly pathResolver: IPathResolver,
18
9
  ) {}
19
10
 
20
11
  async create(userId: string, creation: Creation): Promise<void> {
21
- return operations.createCreation(this.getUserCollection, this.getDocRef, userId, creation);
12
+ return operations.createCreation(this.pathResolver, userId, creation);
22
13
  }
23
14
 
24
15
  async update(userId: string, id: string, updates: Partial<Creation>): Promise<boolean> {
25
- return operations.updateCreation(this.getDocRef, userId, id, updates);
16
+ return operations.updateCreation(this.pathResolver, userId, id, updates);
26
17
  }
27
18
 
28
19
  async delete(userId: string, creationId: string): Promise<boolean> {
29
- return operations.deleteCreation(this.getDocRef, userId, creationId);
20
+ return operations.deleteCreation(this.pathResolver, userId, creationId);
30
21
  }
31
22
 
32
23
  async hardDelete(userId: string, creationId: string): Promise<boolean> {
33
- return operations.hardDeleteCreation(this.getDocRef, userId, creationId);
24
+ return operations.hardDeleteCreation(this.pathResolver, userId, creationId);
34
25
  }
35
26
 
36
27
  async restore(userId: string, creationId: string): Promise<boolean> {
37
- return operations.restoreCreation(this.getDocRef, userId, creationId);
28
+ return operations.restoreCreation(this.pathResolver, userId, creationId);
38
29
  }
39
30
 
40
31
  async updateShared(userId: string, creationId: string, isShared: boolean): Promise<boolean> {
41
- return stateOperations.updateCreationShared(this.getDocRef, userId, creationId, isShared);
32
+ return stateOperations.updateCreationShared(this.pathResolver, userId, creationId, isShared);
42
33
  }
43
34
 
44
35
  async updateFavorite(userId: string, creationId: string, isFavorite: boolean): Promise<boolean> {
45
- return stateOperations.updateCreationFavorite(this.getDocRef, userId, creationId, isFavorite);
36
+ return stateOperations.updateCreationFavorite(this.pathResolver, userId, creationId, isFavorite);
46
37
  }
47
38
 
48
39
  async rate(userId: string, creationId: string, rating: number, description?: string): Promise<boolean> {
49
- return stateOperations.rateCreation(this.getDocRef, userId, creationId, rating, description);
40
+ return stateOperations.rateCreation(this.pathResolver, userId, creationId, rating, description);
50
41
  }
51
42
  }
@@ -3,19 +3,15 @@
3
3
  */
4
4
 
5
5
  import { setDoc } from "firebase/firestore";
6
- import type { GetUserCollection, GetDocRef } from "./CreationsFetcher";
6
+ import type { IPathResolver } from "@umituz/react-native-firebase";
7
7
  import type { Creation, CreationDocument } from "../../domain/entities/Creation";
8
8
 
9
- /**
10
- * Creates a new creation document
11
- */
12
9
  export async function createCreation(
13
- _getUserCollection: GetUserCollection,
14
- getDocRef: GetDocRef,
10
+ pathResolver: IPathResolver,
15
11
  userId: string,
16
12
  creation: Creation
17
13
  ): Promise<void> {
18
- const docRef = getDocRef(userId, creation.id);
14
+ const docRef = pathResolver.getDocRef(userId, creation.id);
19
15
  if (!docRef) throw new Error("Firestore not initialized");
20
16
 
21
17
  const data: CreationDocument = {
@@ -4,18 +4,18 @@
4
4
  */
5
5
 
6
6
  import { updateDoc, deleteDoc } from "firebase/firestore";
7
- import type { GetDocRef } from "./CreationsFetcher";
7
+ import type { IPathResolver } from "./CreationsFetcher";
8
8
  import { logOperationError, logOperationSuccess, logInvalidRef } from "./creation-error-handler.util";
9
9
 
10
10
  /**
11
11
  * Soft deletes a creation by setting deletedAt timestamp
12
12
  */
13
13
  export async function deleteCreation(
14
- getDocRef: GetDocRef,
14
+ pathResolver: IPathResolver,
15
15
  userId: string,
16
16
  creationId: string
17
17
  ): Promise<boolean> {
18
- const docRef = getDocRef(userId, creationId);
18
+ const docRef = pathResolver.getDocRef(userId, creationId);
19
19
  const context = { userId, creationId };
20
20
 
21
21
  if (!docRef) {
@@ -37,11 +37,11 @@ export async function deleteCreation(
37
37
  * Permanently deletes a creation from Firestore
38
38
  */
39
39
  export async function hardDeleteCreation(
40
- getDocRef: GetDocRef,
40
+ pathResolver: IPathResolver,
41
41
  userId: string,
42
42
  creationId: string
43
43
  ): Promise<boolean> {
44
- const docRef = getDocRef(userId, creationId);
44
+ const docRef = pathResolver.getDocRef(userId, creationId);
45
45
  const context = { userId, creationId };
46
46
 
47
47
  if (!docRef) {
@@ -63,11 +63,11 @@ export async function hardDeleteCreation(
63
63
  * Restores a soft-deleted creation by clearing deletedAt
64
64
  */
65
65
  export async function restoreCreation(
66
- getDocRef: GetDocRef,
66
+ pathResolver: IPathResolver,
67
67
  userId: string,
68
68
  creationId: string
69
69
  ): Promise<boolean> {
70
- const docRef = getDocRef(userId, creationId);
70
+ const docRef = pathResolver.getDocRef(userId, creationId);
71
71
  const context = { userId, creationId };
72
72
 
73
73
  if (!docRef) {
@@ -3,15 +3,12 @@
3
3
  */
4
4
 
5
5
  import { updateDoc } from "firebase/firestore";
6
- import type { GetDocRef } from "./CreationsFetcher";
6
+ import type { IPathResolver } from "@umituz/react-native-firebase";
7
7
  import type { Creation } from "../../domain/entities/Creation";
8
8
  import { CREATION_FIELDS, type CreationFieldName } from "../../domain/constants";
9
9
 
10
10
  declare const __DEV__: boolean;
11
11
 
12
- /**
13
- * Updatable fields list
14
- */
15
12
  export const UPDATABLE_FIELDS: ReadonlyArray<CreationFieldName> = [
16
13
  CREATION_FIELDS.URI,
17
14
  CREATION_FIELDS.STATUS,
@@ -30,16 +27,13 @@ export const UPDATABLE_FIELDS: ReadonlyArray<CreationFieldName> = [
30
27
  "type" as CreationFieldName,
31
28
  ] as const;
32
29
 
33
- /**
34
- * Updates a creation document
35
- */
36
30
  export async function updateCreation(
37
- getDocRef: GetDocRef,
31
+ pathResolver: IPathResolver,
38
32
  userId: string,
39
33
  id: string,
40
34
  updates: Partial<Creation>
41
35
  ): Promise<boolean> {
42
- const docRef = getDocRef(userId, id);
36
+ const docRef = pathResolver.getDocRef(userId, id);
43
37
 
44
38
  if (!docRef) {
45
39
  throw new Error(
@@ -4,19 +4,18 @@
4
4
  */
5
5
 
6
6
  import { updateDoc } from "firebase/firestore";
7
- import type { GetDocRef } from "./CreationsFetcher";
8
- import { submitFeedback } from "@umituz/react-native-subscription";
7
+ import type { IPathResolver } from "./CreationsFetcher";
9
8
 
10
9
  /**
11
10
  * Updates the shared status of a creation
12
11
  */
13
12
  export async function updateCreationShared(
14
- getDocRef: GetDocRef,
13
+ pathResolver: IPathResolver,
15
14
  userId: string,
16
15
  creationId: string,
17
16
  isShared: boolean
18
17
  ): Promise<boolean> {
19
- const docRef = getDocRef(userId, creationId);
18
+ const docRef = pathResolver.getDocRef(userId, creationId);
20
19
  if (!docRef) return false;
21
20
 
22
21
  try {
@@ -31,12 +30,12 @@ export async function updateCreationShared(
31
30
  * Updates the favorite status of a creation
32
31
  */
33
32
  export async function updateCreationFavorite(
34
- getDocRef: GetDocRef,
33
+ pathResolver: IPathResolver,
35
34
  userId: string,
36
35
  creationId: string,
37
36
  isFavorite: boolean
38
37
  ): Promise<boolean> {
39
- const docRef = getDocRef(userId, creationId);
38
+ const docRef = pathResolver.getDocRef(userId, creationId);
40
39
  if (!docRef) return false;
41
40
 
42
41
  try {
@@ -51,34 +50,17 @@ export async function updateCreationFavorite(
51
50
  * Rates a creation and optionally submits feedback
52
51
  */
53
52
  export async function rateCreation(
54
- getDocRef: GetDocRef,
53
+ pathResolver: IPathResolver,
55
54
  userId: string,
56
55
  creationId: string,
57
56
  rating: number,
58
- description?: string
57
+ _description?: string
59
58
  ): Promise<boolean> {
60
- const docRef = getDocRef(userId, creationId);
59
+ const docRef = pathResolver.getDocRef(userId, creationId);
61
60
  if (!docRef) return false;
62
61
 
63
62
  try {
64
63
  await updateDoc(docRef, { rating, ratedAt: new Date() });
65
-
66
- // Submit feedback if description or rating is provided
67
- if (description || rating) {
68
- try {
69
- await submitFeedback({
70
- userId,
71
- userEmail: null,
72
- type: "creation_rating",
73
- title: `Creation Rating: ${rating} Stars`,
74
- description: description || `User rated creation ${rating} stars`,
75
- rating,
76
- status: "pending",
77
- });
78
- } catch {
79
- // Feedback submission failed but rating was saved - continue
80
- }
81
- }
82
64
  return true;
83
65
  } catch {
84
66
  return false;
@@ -46,7 +46,7 @@ export async function buildImageInput(
46
46
  // Extract style for text-to-image
47
47
  const styleValue = extractSelection(wizardData.style);
48
48
  const style = typeof styleValue === "string" ? styleValue : undefined;
49
- const interactionStyle = (scenario.interactionStyle as InteractionStyle) ?? "natural";
49
+ const interactionStyle = scenario.interactionStyle as InteractionStyle | undefined;
50
50
  const promptType = scenario.promptType;
51
51
 
52
52
  return { photos, prompt: finalPrompt, style, interactionStyle, promptType };
@@ -27,7 +27,7 @@ export function useImageToVideoFeature(props: UseImageToVideoFeatureProps): UseI
27
27
  () =>
28
28
  createImageToVideoStrategy({
29
29
  config,
30
- callbacks: callbacks as ImageToVideoCallbacks | undefined,
30
+ callbacks: callbacks as unknown as ImageToVideoCallbacks | undefined,
31
31
  buildInput: config.buildInput,
32
32
  extractResult: config.extractResult,
33
33
  userId,
@@ -38,7 +38,7 @@ export async function executeImageFeature(
38
38
  ): Promise<ImageFeatureResult> {
39
39
  const validation = validateProvider(`Image:${featureType}`);
40
40
  if (!validation.success) {
41
- return { success: false, error: validation.error };
41
+ return { success: false, error: ("error" in validation ? validation.error : "Provider validation failed") };
42
42
  }
43
43
 
44
44
  const { provider } = validation;
@@ -49,7 +49,7 @@ export async function executeMultiImageGeneration(
49
49
  ): Promise<MultiImageGenerationResult> {
50
50
  const validation = validateProvider("MultiImageExecutor");
51
51
  if (!validation.success) {
52
- return { success: false, error: validation.error };
52
+ return { success: false, error: ("error" in validation ? validation.error : "Provider validation failed") };
53
53
  }
54
54
  const provider = validation.provider;
55
55
 
@@ -21,7 +21,7 @@ export async function executeVideoFeature(
21
21
  ): Promise<VideoFeatureResult> {
22
22
  const validation = validateProvider(`VideoExecutor:${featureType}`);
23
23
  if (!validation.success) {
24
- return { success: false, error: validation.error };
24
+ return { success: false, error: ("error" in validation ? validation.error : "Provider validation failed") };
25
25
  }
26
26
 
27
27
  const { provider } = validation;
@@ -78,7 +78,7 @@ export async function submitVideoFeatureToQueue(
78
78
  ): Promise<{ success: boolean; requestId?: string; model?: string; error?: string }> {
79
79
  const validation = validateProvider(`VideoExecutor:${featureType}`);
80
80
  if (!validation.success) {
81
- return { success: false, error: validation.error };
81
+ return { success: false, error: ("error" in validation ? validation.error : "Provider validation failed") };
82
82
  }
83
83
 
84
84
  const { provider } = validation;
@@ -9,6 +9,6 @@ export {
9
9
  type AIGenerationResultAction,
10
10
  } from "./AIGenerationResult";
11
11
  export {
12
- ExceptionErrorState as ErrorDisplay,
13
- ExceptionEmptyState,
12
+ EmptyState as ErrorDisplay,
13
+ EmptyState as ExceptionEmptyState,
14
14
  } from "@umituz/react-native-design-system";