@umituz/react-native-ai-generation-content 1.12.4 → 1.12.5

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.
Files changed (67) hide show
  1. package/package.json +29 -6
  2. package/src/domains/creations/application/services/CreationsService.ts +71 -0
  3. package/src/domains/creations/domain/entities/Creation.ts +51 -0
  4. package/src/domains/creations/domain/entities/index.ts +6 -0
  5. package/src/domains/creations/domain/repositories/ICreationsRepository.ts +23 -0
  6. package/src/domains/creations/domain/repositories/index.ts +5 -0
  7. package/src/domains/creations/domain/services/ICreationsStorageService.ts +13 -0
  8. package/src/domains/creations/domain/value-objects/CreationsConfig.ts +76 -0
  9. package/src/domains/creations/domain/value-objects/index.ts +12 -0
  10. package/src/domains/creations/index.ts +84 -0
  11. package/src/domains/creations/infrastructure/adapters/createRepository.ts +54 -0
  12. package/src/domains/creations/infrastructure/adapters/index.ts +5 -0
  13. package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +233 -0
  14. package/src/domains/creations/infrastructure/repositories/index.ts +8 -0
  15. package/src/domains/creations/infrastructure/services/CreationsStorageService.ts +48 -0
  16. package/src/domains/creations/presentation/components/CreationCard.tsx +136 -0
  17. package/src/domains/creations/presentation/components/CreationDetail/DetailActions.tsx +76 -0
  18. package/src/domains/creations/presentation/components/CreationDetail/DetailHeader.tsx +81 -0
  19. package/src/domains/creations/presentation/components/CreationDetail/DetailImage.tsx +41 -0
  20. package/src/domains/creations/presentation/components/CreationDetail/DetailStory.tsx +67 -0
  21. package/src/domains/creations/presentation/components/CreationDetail/index.ts +4 -0
  22. package/src/domains/creations/presentation/components/CreationImageViewer.tsx +43 -0
  23. package/src/domains/creations/presentation/components/CreationThumbnail.tsx +63 -0
  24. package/src/domains/creations/presentation/components/CreationsGrid.tsx +75 -0
  25. package/src/domains/creations/presentation/components/CreationsHomeCard.tsx +176 -0
  26. package/src/domains/creations/presentation/components/EmptyState.tsx +75 -0
  27. package/src/domains/creations/presentation/components/FilterBottomSheet.tsx +158 -0
  28. package/src/domains/creations/presentation/components/FilterChips.tsx +105 -0
  29. package/src/domains/creations/presentation/components/GalleryHeader.tsx +106 -0
  30. package/src/domains/creations/presentation/components/index.ts +19 -0
  31. package/src/domains/creations/presentation/hooks/index.ts +7 -0
  32. package/src/domains/creations/presentation/hooks/useCreations.ts +33 -0
  33. package/src/domains/creations/presentation/hooks/useCreationsFilter.ts +70 -0
  34. package/src/domains/creations/presentation/hooks/useDeleteCreation.ts +51 -0
  35. package/src/domains/creations/presentation/screens/CreationDetailScreen.tsx +71 -0
  36. package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +217 -0
  37. package/src/domains/creations/presentation/screens/index.ts +5 -0
  38. package/src/domains/creations/presentation/utils/filterUtils.ts +52 -0
  39. package/src/domains/creations/types.d.ts +107 -0
  40. package/src/domains/face-detection/domain/constants/faceDetectionConstants.ts +16 -0
  41. package/src/domains/face-detection/domain/entities/FaceDetection.ts +19 -0
  42. package/src/domains/face-detection/index.ts +26 -0
  43. package/src/domains/face-detection/infrastructure/analyzers/faceAnalyzer.ts +36 -0
  44. package/src/domains/face-detection/infrastructure/validators/faceValidator.ts +52 -0
  45. package/src/domains/face-detection/presentation/components/FaceValidationStatus.tsx +111 -0
  46. package/src/domains/face-detection/presentation/hooks/useFaceDetection.ts +58 -0
  47. package/src/domains/feature-background/domain/entities/background.types.ts +77 -0
  48. package/src/domains/feature-background/domain/entities/component.types.ts +96 -0
  49. package/src/domains/feature-background/domain/entities/config.types.ts +41 -0
  50. package/src/domains/feature-background/domain/entities/index.ts +31 -0
  51. package/src/domains/feature-background/index.ts +72 -0
  52. package/src/domains/feature-background/infrastructure/constants/index.ts +5 -0
  53. package/src/domains/feature-background/infrastructure/constants/prompts.constants.ts +15 -0
  54. package/src/domains/feature-background/presentation/components/BackgroundFeature.tsx +145 -0
  55. package/src/domains/feature-background/presentation/components/ComparisonSlider.tsx +199 -0
  56. package/src/domains/feature-background/presentation/components/ErrorDisplay.tsx +58 -0
  57. package/src/domains/feature-background/presentation/components/FeatureHeader.tsx +80 -0
  58. package/src/domains/feature-background/presentation/components/GenerateButton.tsx +86 -0
  59. package/src/domains/feature-background/presentation/components/ImagePicker.tsx +136 -0
  60. package/src/domains/feature-background/presentation/components/ModeSelector.tsx +78 -0
  61. package/src/domains/feature-background/presentation/components/ProcessingModal.tsx +113 -0
  62. package/src/domains/feature-background/presentation/components/PromptInput.tsx +142 -0
  63. package/src/domains/feature-background/presentation/components/ResultDisplay.tsx +123 -0
  64. package/src/domains/feature-background/presentation/components/index.ts +16 -0
  65. package/src/domains/feature-background/presentation/hooks/index.ts +7 -0
  66. package/src/domains/feature-background/presentation/hooks/useBackgroundFeature.ts +118 -0
  67. package/src/index.ts +18 -0
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.12.4",
3
+ "version": "1.12.5",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
7
7
  "exports": {
8
8
  ".": "./src/index.ts",
9
9
  "./prompts": "./src/domains/prompts/index.ts",
10
- "./content-moderation": "./src/domains/content-moderation/index.ts"
10
+ "./content-moderation": "./src/domains/content-moderation/index.ts",
11
+ "./creations": "./src/domains/creations/index.ts",
12
+ "./face-detection": "./src/domains/face-detection/index.ts",
13
+ "./feature-background": "./src/domains/feature-background/index.ts"
11
14
  },
12
15
  "files": [
13
16
  "src"
@@ -35,28 +38,48 @@
35
38
  "url": "git+https://github.com/umituz/react-native-ai-generation-content.git"
36
39
  },
37
40
  "peerDependencies": {
41
+ "@react-navigation/native": ">=6.0.0",
38
42
  "@tanstack/react-query": ">=5.0.0",
43
+ "@umituz/react-native-ai-gemini-provider": "latest",
44
+ "@umituz/react-native-alert": "latest",
39
45
  "@umituz/react-native-animation": "latest",
46
+ "@umituz/react-native-bottom-sheet": "latest",
40
47
  "@umituz/react-native-design-system": "latest",
48
+ "@umituz/react-native-firebase": "latest",
49
+ "@umituz/react-native-image": "latest",
50
+ "@umituz/react-native-localization": "latest",
41
51
  "@umituz/react-native-offline": "latest",
52
+ "@umituz/react-native-uuid": "latest",
42
53
  "expo-linear-gradient": ">=15.0.0",
54
+ "firebase": ">=10.0.0",
43
55
  "react": ">=18.0.0",
44
- "react-native": ">=0.74.0"
56
+ "react-native": ">=0.74.0",
57
+ "react-native-safe-area-context": ">=4.0.0"
45
58
  },
46
59
  "devDependencies": {
47
60
  "@react-native-async-storage/async-storage": "2.2.0",
61
+ "@react-navigation/native": "^6.1.18",
48
62
  "@tanstack/react-query": "^5.0.0",
49
- "@umituz/react-native-animation": "latest",
50
- "@umituz/react-native-design-system": "latest",
51
- "@umituz/react-native-offline": "latest",
52
63
  "@types/react": "~19.1.10",
53
64
  "@types/react-native": "^0.73.0",
54
65
  "@typescript-eslint/eslint-plugin": "^7.0.0",
55
66
  "@typescript-eslint/parser": "^7.0.0",
67
+ "@umituz/react-native-ai-gemini-provider": "latest",
68
+ "@umituz/react-native-alert": "latest",
69
+ "@umituz/react-native-animation": "latest",
70
+ "@umituz/react-native-bottom-sheet": "latest",
71
+ "@umituz/react-native-design-system": "latest",
72
+ "@umituz/react-native-firebase": "latest",
73
+ "@umituz/react-native-image": "latest",
74
+ "@umituz/react-native-localization": "latest",
75
+ "@umituz/react-native-offline": "latest",
76
+ "@umituz/react-native-uuid": "latest",
56
77
  "eslint": "^8.57.0",
57
78
  "expo-linear-gradient": "~15.0.7",
79
+ "firebase": "^11.1.0",
58
80
  "react": "19.1.0",
59
81
  "react-native": "0.81.5",
82
+ "react-native-safe-area-context": "^4.0.0",
60
83
  "typescript": "^5.3.0",
61
84
  "zustand": "^5.0.2"
62
85
  },
@@ -0,0 +1,71 @@
1
+ import { serverTimestamp, addDoc, collection } from "firebase/firestore";
2
+ import { generateUUID } from "@umituz/react-native-uuid";
3
+ import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
4
+ import type { ICreationsStorageService } from "../../domain/services/ICreationsStorageService";
5
+ import type { CreationType } from "../../domain/value-objects";
6
+ import { BaseRepository } from "@umituz/react-native-firebase";
7
+
8
+ export interface CreateCreationDTO {
9
+ userId: string;
10
+ type: CreationType;
11
+ prompt: string;
12
+ metadata?: Record<string, any>;
13
+ imageUri: string; // can be local file uri or base64
14
+ aspectRatio?: number;
15
+ }
16
+
17
+ export class CreationsService extends BaseRepository {
18
+ constructor(
19
+ private readonly repository: ICreationsRepository,
20
+ private readonly storageService: ICreationsStorageService,
21
+ private readonly collectionName: string = "creations" // Default to generic name, app can override via repo
22
+ ) {
23
+ super();
24
+ }
25
+
26
+ async saveCreation(dto: CreateCreationDTO): Promise<string> {
27
+ const db = this.getDb();
28
+ if (!db) throw new Error("Firestore not initialized");
29
+
30
+ try {
31
+ const creationId = generateUUID();
32
+
33
+ const imageUrl = await this.storageService.uploadCreationImage(
34
+ dto.userId,
35
+ creationId,
36
+ dto.imageUri
37
+ );
38
+
39
+ await this.repository.create(dto.userId, {
40
+ id: creationId,
41
+ uri: imageUrl,
42
+ type: dto.type.id,
43
+ prompt: dto.prompt,
44
+ metadata: dto.metadata,
45
+ createdAt: new Date(),
46
+ isShared: false,
47
+ });
48
+
49
+ return creationId;
50
+ } catch (error) {
51
+ console.error(error);
52
+ throw error;
53
+ }
54
+ }
55
+
56
+ async getCreation(userId: string, id: string): Promise<any> {
57
+ return this.repository.getById(userId, id);
58
+ }
59
+
60
+ async updateCreation(
61
+ userId: string,
62
+ id: string,
63
+ updates: { metadata?: Record<string, any> },
64
+ ): Promise<boolean> {
65
+ return this.repository.update(userId, id, updates);
66
+ }
67
+
68
+ async deleteCreation(userId: string, id: string): Promise<boolean> {
69
+ return this.repository.delete(userId, id);
70
+ }
71
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Creation Entity
3
+ * Represents an AI-generated creation
4
+ */
5
+
6
+ export interface Creation {
7
+ readonly id: string;
8
+ readonly uri: string;
9
+ readonly type: string;
10
+ readonly prompt?: string;
11
+ readonly metadata?: Record<string, any>;
12
+ readonly originalUri?: string;
13
+ readonly createdAt: Date;
14
+ readonly isShared: boolean;
15
+ }
16
+
17
+ export interface CreationDocument {
18
+ readonly uri?: string;
19
+ readonly prompt?: string;
20
+ readonly metadata?: Record<string, any>;
21
+ readonly originalImage?: string;
22
+ readonly originalImageUrl?: string;
23
+ readonly transformedImage?: string;
24
+ readonly transformedImageUrl?: string;
25
+ readonly transformationType?: string;
26
+ readonly type?: string;
27
+ readonly status?: string;
28
+ readonly isShared: boolean;
29
+ readonly createdAt: FirebaseTimestamp | Date; // Allow Date for writing
30
+ readonly completedAt?: FirebaseTimestamp | Date;
31
+ }
32
+
33
+ interface FirebaseTimestamp {
34
+ toDate: () => Date;
35
+ }
36
+
37
+ export function mapDocumentToCreation(
38
+ id: string,
39
+ data: CreationDocument,
40
+ ): Creation {
41
+ return {
42
+ id,
43
+ uri: data.transformedImageUrl || data.transformedImage || data.uri || "",
44
+ type: data.transformationType || data.type || "unknown",
45
+ prompt: data.prompt,
46
+ metadata: data.metadata,
47
+ originalUri: data.originalImageUrl || data.originalImage,
48
+ createdAt: (data.createdAt as any)?.toDate?.() || (data.createdAt instanceof Date ? data.createdAt : new Date()),
49
+ isShared: data.isShared ?? false,
50
+ };
51
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Domain Entities
3
+ */
4
+
5
+ export type { Creation, CreationDocument } from "./Creation";
6
+ export { mapDocumentToCreation } from "./Creation";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Creations Repository Interface
3
+ * Defines the contract for creations data access
4
+ */
5
+
6
+ import type { Creation } from "../entities/Creation";
7
+
8
+ export interface ICreationsRepository {
9
+ getAll(userId: string): Promise<Creation[]>;
10
+ getById(userId: string, id: string): Promise<Creation | null>;
11
+ create(userId: string, creation: Creation): Promise<void>;
12
+ update(
13
+ userId: string,
14
+ id: string,
15
+ updates: Partial<Creation>,
16
+ ): Promise<boolean>;
17
+ delete(userId: string, creationId: string): Promise<boolean>;
18
+ updateShared(
19
+ userId: string,
20
+ creationId: string,
21
+ isShared: boolean,
22
+ ): Promise<boolean>;
23
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Domain Repository Interfaces
3
+ */
4
+
5
+ export type { ICreationsRepository } from "./ICreationsRepository";
@@ -0,0 +1,13 @@
1
+ export interface ICreationsStorageService {
2
+ uploadCreationImage(
3
+ userId: string,
4
+ creationId: string,
5
+ imageUri: string,
6
+ mimeType?: string
7
+ ): Promise<string>;
8
+
9
+ deleteCreationImage(
10
+ userId: string,
11
+ creationId: string
12
+ ): Promise<boolean>;
13
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Creations Configuration Value Object
3
+ * Defines the configuration for creations feature
4
+ */
5
+
6
+ import type { Creation, CreationDocument } from "../entities/Creation";
7
+
8
+ export interface CreationType {
9
+ readonly id: string;
10
+ readonly labelKey: string;
11
+ readonly icon: string;
12
+ }
13
+
14
+ export interface CreationsTranslations {
15
+ readonly title: string;
16
+ readonly subtitle: string;
17
+ readonly empty: string;
18
+ readonly emptyDescription: string;
19
+ readonly deleteTitle: string;
20
+ readonly deleteMessage: string;
21
+ readonly photoCount: string;
22
+ readonly filterAll: string;
23
+ readonly filterLabel: string;
24
+ readonly filterTitle: string;
25
+ }
26
+
27
+ /**
28
+ * Path builder function type
29
+ * Allows apps to define custom Firestore path structures
30
+ * @example
31
+ * // Default: users/{userId}/creations
32
+ * pathBuilder: (userId) => ["users", userId, "creations"]
33
+ * // Alternative: creations/{userId}/items
34
+ * pathBuilder: (userId) => ["creations", userId, "items"]
35
+ */
36
+ export type PathBuilder = (userId: string) => string[];
37
+
38
+ /**
39
+ * Document mapper function type
40
+ * Allows apps to map their specific document structure to Creation
41
+ */
42
+ export type DocumentMapper = (id: string, data: CreationDocument) => Creation;
43
+
44
+ import type { FilterCategory } from "@umituz/react-native-bottom-sheet";
45
+
46
+ export interface CreationsConfig {
47
+ readonly collectionName: string;
48
+ readonly types: readonly CreationType[];
49
+ readonly filterCategories?: readonly FilterCategory[];
50
+ readonly translations: CreationsTranslations;
51
+ readonly maxThumbnails?: number;
52
+ readonly gridColumns?: number;
53
+ readonly pathBuilder?: PathBuilder;
54
+ readonly documentMapper?: DocumentMapper;
55
+ }
56
+
57
+ export const DEFAULT_TRANSLATIONS: CreationsTranslations = {
58
+ title: "creations.title",
59
+ subtitle: "creations.subtitle",
60
+ empty: "creations.empty",
61
+ emptyDescription: "creations.emptyDescription",
62
+ deleteTitle: "creations.deleteTitle",
63
+ deleteMessage: "creations.deleteMessage",
64
+ photoCount: "creations.photoCount",
65
+ filterAll: "creations.filterAll",
66
+ filterLabel: "common.filter",
67
+ filterTitle: "common.filter",
68
+ };
69
+
70
+ export const DEFAULT_CONFIG: CreationsConfig = {
71
+ collectionName: "creations",
72
+ types: [],
73
+ translations: DEFAULT_TRANSLATIONS,
74
+ maxThumbnails: 4,
75
+ gridColumns: 2,
76
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Domain Value Objects
3
+ */
4
+
5
+ export type {
6
+ CreationType,
7
+ CreationsTranslations,
8
+ CreationsConfig,
9
+ PathBuilder,
10
+ DocumentMapper,
11
+ } from "./CreationsConfig";
12
+ export { DEFAULT_TRANSLATIONS, DEFAULT_CONFIG } from "./CreationsConfig";
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @umituz/react-native-ai-creations
3
+ *
4
+ * AI-generated creations gallery with filtering, sharing, and management
5
+ *
6
+ * Architecture:
7
+ * - Extends BaseRepository from @umituz/react-native-firestore
8
+ * - Fully dynamic path structure (configurable per app)
9
+ * - Fully dynamic document mapping (configurable per app)
10
+ * - App-agnostic: Works with any app, no app-specific code
11
+ *
12
+ * This package is designed to be used across hundreds of apps.
13
+ *
14
+ * Usage:
15
+ * import {
16
+ * CreationsGalleryScreen,
17
+ * CreationsHomeCard,
18
+ * useCreations,
19
+ * createCreationsRepository,
20
+ * } from '@umituz/react-native-ai-creations';
21
+ */
22
+
23
+ // =============================================================================
24
+ // DOMAIN LAYER - Entities
25
+ // =============================================================================
26
+
27
+ export type { Creation, CreationDocument } from "./domain/entities";
28
+ export { mapDocumentToCreation } from "./domain/entities";
29
+
30
+ // =============================================================================
31
+ // DOMAIN LAYER - Value Objects
32
+ // =============================================================================
33
+
34
+ export type {
35
+ CreationType,
36
+ CreationsTranslations,
37
+ CreationsConfig,
38
+ PathBuilder,
39
+ DocumentMapper,
40
+ } from "./domain/value-objects";
41
+ export { DEFAULT_TRANSLATIONS, DEFAULT_CONFIG } from "./domain/value-objects";
42
+
43
+ // =============================================================================
44
+ // DOMAIN LAYER - Repository Interface
45
+ // =============================================================================
46
+
47
+ export type { ICreationsRepository } from "./domain/repositories";
48
+
49
+ // =============================================================================
50
+ // INFRASTRUCTURE LAYER
51
+ // =============================================================================
52
+
53
+ export {
54
+ CreationsRepository,
55
+ type RepositoryOptions,
56
+ } from "./infrastructure/repositories";
57
+ export { CreationsStorageService } from "./infrastructure/services/CreationsStorageService";
58
+ export { createCreationsRepository } from "./infrastructure/adapters";
59
+ export { CreationsService } from "./application/services/CreationsService";
60
+ export type { ICreationsStorageService } from "./domain/services/ICreationsStorageService";
61
+
62
+ // =============================================================================
63
+ // PRESENTATION LAYER - Hooks
64
+ // =============================================================================
65
+
66
+ export { useCreations } from "./presentation/hooks/useCreations";
67
+ export { useDeleteCreation } from "./presentation/hooks/useDeleteCreation";
68
+ export { useCreationsFilter } from "./presentation/hooks/useCreationsFilter";
69
+
70
+ // =============================================================================
71
+ // PRESENTATION LAYER - Components
72
+ // =============================================================================
73
+
74
+ export { CreationThumbnail } from "./presentation/components/CreationThumbnail";
75
+ export { CreationCard } from "./presentation/components/CreationCard";
76
+ export { CreationsHomeCard } from "./presentation/components/CreationsHomeCard";
77
+ export { FilterChips } from "./presentation/components/FilterChips";
78
+ export { EmptyState } from "./presentation/components/EmptyState";
79
+
80
+ // =============================================================================
81
+ // PRESENTATION LAYER - Screens
82
+ // =============================================================================
83
+
84
+ export { CreationsGalleryScreen } from "./presentation/screens/CreationsGalleryScreen";
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Repository Factory
3
+ * Creates repository instance with given configuration
4
+ *
5
+ * Architecture:
6
+ * - Factory pattern for repository creation
7
+ * - Supports dynamic path structure per app
8
+ * - Supports custom document mapping per app
9
+ * - App-agnostic: No Firestore instance needed (BaseRepository handles it)
10
+ *
11
+ * This factory is designed to be used across hundreds of apps.
12
+ */
13
+
14
+ import {
15
+ CreationsRepository,
16
+ type RepositoryOptions,
17
+ } from "../repositories/CreationsRepository";
18
+ import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
19
+
20
+ /**
21
+ * Creates a new CreationsRepository instance
22
+ *
23
+ * @param collectionName - Firestore collection name
24
+ * @param options - Optional repository configuration
25
+ * @returns ICreationsRepository instance
26
+ *
27
+ * @example
28
+ * // Basic usage with default path (users/{userId}/photos)
29
+ * const repo = createCreationsRepository("photos");
30
+ *
31
+ * @example
32
+ * // Custom path structure
33
+ * const repo = createCreationsRepository("creations", {
34
+ * pathBuilder: (userId) => ["gallery", userId, "items"],
35
+ * });
36
+ *
37
+ * @example
38
+ * // Custom document mapper
39
+ * const repo = createCreationsRepository("photos", {
40
+ * documentMapper: (id, data) => ({
41
+ * id,
42
+ * uri: data.imageUrl,
43
+ * type: data.category,
44
+ * createdAt: data.timestamp?.toDate() || new Date(),
45
+ * isShared: data.public ?? false,
46
+ * }),
47
+ * });
48
+ */
49
+ export function createCreationsRepository(
50
+ collectionName: string,
51
+ options?: RepositoryOptions,
52
+ ): ICreationsRepository {
53
+ return new CreationsRepository(collectionName, options);
54
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Infrastructure Adapters
3
+ */
4
+
5
+ export { createCreationsRepository } from "./createRepository";