@umituz/react-native-ai-gemini-provider 1.14.28 → 1.14.30

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 (49) hide show
  1. package/package.json +41 -3
  2. package/src/domain/README.md +232 -0
  3. package/src/domain/constants/README.md +191 -0
  4. package/src/domain/entities/README.md +238 -0
  5. package/src/infrastructure/README.md +252 -0
  6. package/src/infrastructure/cache/CACHE_SYSTEM.md +213 -0
  7. package/src/infrastructure/cache/README.md +213 -0
  8. package/src/infrastructure/content/CONTENT_BUILDER.md +175 -0
  9. package/src/infrastructure/content/README.md +175 -0
  10. package/src/infrastructure/interceptors/README.md +226 -0
  11. package/src/infrastructure/interceptors/REQUEST_INTERCEPTORS.md +171 -0
  12. package/src/infrastructure/job/JOB_MANAGER.md +174 -0
  13. package/src/infrastructure/job/README.md +194 -0
  14. package/src/infrastructure/response/README.md +187 -0
  15. package/src/infrastructure/response/RESPONSE_FORMATTER.md +185 -0
  16. package/src/infrastructure/services/CORE_CLIENT_SERVICE.md +202 -0
  17. package/src/infrastructure/services/FEATURE_MODEL_SELECTOR_SERVICE.md +206 -0
  18. package/src/infrastructure/services/GENERATION_EXECUTOR_SERVICE.md +176 -0
  19. package/src/infrastructure/services/IMAGE_EDIT_SERVICE.md +169 -0
  20. package/src/infrastructure/services/IMAGE_GENERATION_SERVICE.md +166 -0
  21. package/src/infrastructure/services/JOB_PROCESSOR_SERVICE.md +174 -0
  22. package/src/infrastructure/services/PROVIDER_INITIALIZER_SERVICE.md +176 -0
  23. package/src/infrastructure/services/README.md +233 -0
  24. package/src/infrastructure/services/RETRY_SERVICE.md +178 -0
  25. package/src/infrastructure/services/STREAMING_SERVICE.md +166 -0
  26. package/src/infrastructure/services/STRUCTURED_TEXT_SERVICE.md +175 -0
  27. package/src/infrastructure/services/TEXT_GENERATION_SERVICE.md +160 -0
  28. package/src/infrastructure/services/VEO_HTTP_CLIENT_SERVICE.md +179 -0
  29. package/src/infrastructure/services/VEO_POLLING_SERVICE.md +173 -0
  30. package/src/infrastructure/services/VIDEO_DOWNLOADER_SERVICE.md +166 -0
  31. package/src/infrastructure/services/VIDEO_ERROR_HANDLER_SERVICE.md +185 -0
  32. package/src/infrastructure/services/VIDEO_GENERATION_SERVICE.md +176 -0
  33. package/src/infrastructure/services/VIDEO_URL_EXTRACTOR_SERVICE.md +186 -0
  34. package/src/infrastructure/services/gemini-provider.ts +9 -2
  35. package/src/infrastructure/telemetry/README.md +203 -0
  36. package/src/infrastructure/telemetry/TELEMETRY_SYSTEM.md +200 -0
  37. package/src/infrastructure/utils/DATA_TRANSFORMER_UTILS.md +175 -0
  38. package/src/infrastructure/utils/ERROR_MAPPER.md +170 -0
  39. package/src/infrastructure/utils/ERROR_UTILITIES.md +208 -0
  40. package/src/infrastructure/utils/IMAGE_PREPARER_UTILS.md +185 -0
  41. package/src/infrastructure/utils/INPUT_BUILDERS.md +214 -0
  42. package/src/infrastructure/utils/MODEL_VALIDATION_UTILS.md +189 -0
  43. package/src/infrastructure/utils/PERFORMANCE_UTILITIES.md +477 -0
  44. package/src/infrastructure/utils/PERFORMANCE_UTILS.md +219 -0
  45. package/src/infrastructure/utils/README.md +289 -0
  46. package/src/presentation/README.md +187 -0
  47. package/src/presentation/hooks/README.md +188 -0
  48. package/src/presentation/hooks/USE_GEMINI_HOOK.md +226 -0
  49. package/src/providers/README.md +247 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-gemini-provider",
3
- "version": "1.14.28",
3
+ "version": "1.14.30",
4
4
  "description": "Google Gemini AI provider for React Native applications",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -36,15 +36,53 @@
36
36
  "react-native": ">=0.74.0"
37
37
  },
38
38
  "devDependencies": {
39
+ "@expo/vector-icons": "^15.0.3",
39
40
  "@google/generative-ai": "^0.21.0",
41
+ "@react-native-async-storage/async-storage": "^2.2.0",
42
+ "@react-native-community/datetimepicker": "^8.6.0",
43
+ "@react-native-community/slider": "^5.1.1",
44
+ "@react-navigation/bottom-tabs": "^7.9.0",
45
+ "@react-navigation/native": "^7.1.26",
46
+ "@react-navigation/stack": "^7.6.13",
47
+ "@tanstack/react-query": "^5.90.16",
40
48
  "@types/react": "~19.1.10",
41
49
  "@typescript-eslint/eslint-plugin": "^7.0.0",
42
50
  "@typescript-eslint/parser": "^7.0.0",
43
- "@umituz/react-native-ai-generation-content": "latest",
51
+ "@umituz/react-native-ai-generation-content": "^1.17.259",
52
+ "@umituz/react-native-design-system": "^2.8.7",
53
+ "@umituz/react-native-filesystem": "^2.1.22",
54
+ "@umituz/react-native-location": "^1.0.9",
44
55
  "eslint": "^8.57.0",
56
+ "expo-apple-authentication": "^8.0.8",
57
+ "expo-application": "^7.0.8",
58
+ "expo-auth-session": "^7.0.10",
59
+ "expo-clipboard": "^8.0.8",
60
+ "expo-crypto": "^15.0.8",
61
+ "expo-device": "^8.0.10",
62
+ "expo-file-system": "^19.0.21",
63
+ "expo-font": "^14.0.10",
64
+ "expo-haptics": "^15.0.8",
65
+ "expo-image": "^3.0.11",
66
+ "expo-image-manipulator": "^14.0.8",
67
+ "expo-localization": "^17.0.8",
68
+ "expo-media-library": "^18.2.1",
69
+ "expo-modules-core": "^3.0.29",
70
+ "expo-network": "^8.0.8",
71
+ "expo-secure-store": "^15.0.8",
72
+ "expo-sharing": "^14.0.8",
73
+ "expo-video": "^3.0.15",
74
+ "expo-web-browser": "^15.0.10",
75
+ "firebase": "^12.7.0",
76
+ "i18next": "^25.7.4",
45
77
  "react": "19.1.0",
78
+ "react-i18next": "^16.5.1",
46
79
  "react-native": "0.81.5",
47
- "typescript": "^5.3.0"
80
+ "react-native-gesture-handler": "^2.30.0",
81
+ "react-native-safe-area-context": "^5.6.2",
82
+ "react-native-svg": "^15.15.1",
83
+ "rn-emoji-keyboard": "^1.7.0",
84
+ "typescript": "^5.3.0",
85
+ "zustand": "^5.0.9"
48
86
  },
49
87
  "publishConfig": {
50
88
  "access": "public"
@@ -0,0 +1,232 @@
1
+ # Domain Layer
2
+
3
+ Core type definitions and constants for the Gemini provider. Contains data structures and constants independent of business logic.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import type {
9
+ GeminiConfig,
10
+ GeminiGenerationConfig,
11
+ GeminiResponse,
12
+ GeminiImageGenerationResult,
13
+ VideoGenerationResult,
14
+ GeminiError,
15
+ GeminiErrorType
16
+ } from '@umituz/react-native-ai-gemini-provider';
17
+
18
+ import {
19
+ GEMINI_MODELS,
20
+ DEFAULT_MODELS,
21
+ getGeminiImageFeatureModel,
22
+ getGeminiVideoFeatureModel
23
+ } from '@umituz/react-native-ai-gemini-provider';
24
+ ```
25
+
26
+ ## 🎯 Purpose
27
+
28
+ Use this layer for type-safe integration with Gemini services. Provides TypeScript interfaces and constants for all operations.
29
+
30
+ **When to use:**
31
+ - Type-check API requests and responses
32
+ - Access model constants and configurations
33
+ - Define function signatures
34
+ - Understand data structures
35
+ - Handle typed errors
36
+
37
+ ## 📌 Strategy
38
+
39
+ Domain layer contains NO business logic or external dependencies. These definitions:
40
+ - Provide pure type definitions
41
+ - Define constant values
42
+ - Enable compile-time type checking
43
+ - Document API contracts
44
+ - Remain stable despite code changes
45
+
46
+ **Key Decision**: All domain types have NO external dependencies. This keeps them pure, reusable, and testable.
47
+
48
+ ## ⚠️ Rules
49
+
50
+ ### Usage Rules
51
+ - **MUST** use types from domain layer
52
+ - **SHOULD** use type imports over value imports
53
+ - **MUST** handle all defined error types
54
+ - **SHOULD** use constants instead of hardcoded values
55
+ - **MUST NOT** use `any` type
56
+
57
+ ### Type Safety Rules
58
+ - **MUST** define explicit return types
59
+ - **SHOULD** use strict null checks
60
+ - **MUST** validate runtime data
61
+ - **SHOULD** use discriminated unions for errors
62
+ - **MUST NOT** bypass type checking
63
+
64
+ ### Constants Rules
65
+ - **MUST** use defined model constants
66
+ - **SHOULD** use helper functions for model selection
67
+ - **MUST NOT** hardcode model IDs
68
+ - **SHOULD** prefer constants over magic strings
69
+ - **MUST** use valid model IDs from constants
70
+
71
+ ## 🤖 AI Agent Guidelines
72
+
73
+ ### When Modifying Domain Types
74
+ 1. **READ** existing type definitions first
75
+ 2. **UNDERSTAND** type relationships
76
+ 3. **MAINTAIN** backward compatibility
77
+ 4. **UPDATE** all dependent code
78
+ 5. **ADD** tests for new types
79
+
80
+ ### When Adding New Types
81
+ 1. **CHECK** if similar type exists
82
+ 2. **FOLLOW** existing naming conventions
83
+ 3. **USE** consistent patterns
84
+ 4. **DOCUMENT** with JSDoc comments
85
+ 5. **EXPORT** from index files
86
+
87
+ ### When Adding Constants
88
+ 1. **CHECK** if constant already exists
89
+ 2. **USE** descriptive names
90
+ 3. **GROUP** related constants
91
+ 4. **PROVIDE** helper functions
92
+ 5. **DOCUMENT** constant values
93
+
94
+ ### Code Style Rules
95
+ - **USE** explicit type annotations
96
+ - **AVOID** `any` type
97
+ - **PREFER** readonly where appropriate
98
+ - **USE** discriminated unions
99
+ - **DOCUMENT** complex types
100
+
101
+ ## 📦 Available Modules
102
+
103
+ ### Type Definitions
104
+
105
+ **Entities**: Core data structures
106
+
107
+ **Refer to**: [`entities/README.md`](./entities/README.md)
108
+
109
+ **Files:**
110
+ - [`entities/gemini.types.ts`](./entities/gemini.types.ts) - Main Gemini types
111
+ - [`entities/error.types.ts`](./entities/error.types.ts) - Error types
112
+ - [`entities/models.ts`](./entities/models.ts) - Model definitions
113
+ - [`entities/video.types.ts`](./entities/video.types.ts) - Video types
114
+
115
+ ### Constants
116
+
117
+ **Feature Models**: Model mappings for features
118
+
119
+ **Refer to**: [`constants/README.md`](./constants/README.md)
120
+
121
+ **Files:**
122
+ - [`constants/feature-models.constants.ts`](./constants/feature-models.constants.ts) - Feature model mappings
123
+ - [`constants/models.constants.ts`](./constants/models.constants.ts) - Model constants
124
+
125
+ ## 🔗 Related Modules
126
+
127
+ - **Services**: [`../infrastructure/services/README.md`](../infrastructure/services/README.md)
128
+ - **Infrastructure**: [`../infrastructure/README.md`](../infrastructure/README.md)
129
+ - **Providers**: [`../providers/README.md`](../providers/README.md)
130
+
131
+ ## 📋 Type Reference
132
+
133
+ ### Configuration Types
134
+
135
+ **GeminiConfig**: Client configuration
136
+ - `apiKey`: string (required)
137
+ - `baseUrl`: string (optional)
138
+ - `maxRetries`: number (optional)
139
+ - Various model IDs (optional)
140
+
141
+ **GeminiGenerationConfig**: Generation parameters
142
+ - Compatible with Google SDK
143
+ - Temperature, topP, topK, maxOutputTokens
144
+ - Response schema
145
+
146
+ ### Request/Response Types
147
+
148
+ **GeminiContent**: API request structure
149
+ - `parts`: Array of text, inline data, or file data
150
+ - `role`: "user" | "model"
151
+
152
+ **GeminiResponse**: API response structure
153
+ - `candidates`: Generated results
154
+ - `promptFeedback`: Prompt feedback
155
+ - `usageMetadata`: Token usage
156
+
157
+ ### Error Types
158
+
159
+ **GeminiError**: Custom error class
160
+ - Extends Error
161
+ - Includes error type and original error
162
+
163
+ **GeminiErrorType**: Error categories
164
+ - API_ERROR, VALIDATION_ERROR, NETWORK_ERROR
165
+ - TIMEOUT_ERROR, RATE_LIMIT_ERROR, PARSING_ERROR
166
+ - QUOTA_EXCEEDED, AUTHENTICATION, SAFETY
167
+ - MODEL_NOT_FOUND, SERVER
168
+
169
+ ### Model Constants
170
+
171
+ **GEMINI_MODELS**: All supported models
172
+ - Text models (gemini-2.5-flash-lite, gemini-2.5-pro, etc.)
173
+ - Image models (imagen-4.0-generate-001, etc.)
174
+ - Video models (veo-3.1-fast-generate-preview, etc.)
175
+
176
+ **DEFAULT_MODELS**: Default model selections
177
+ - TEXT: gemini-2.5-flash-lite
178
+ - TEXT_TO_IMAGE: imagen-4.0-generate-001
179
+ - IMAGE_EDIT: gemini-2.5-flash-image
180
+ - VIDEO_GENERATION: veo-3.1-fast-generate-preview
181
+
182
+ ## 🎓 Usage Patterns
183
+
184
+ ### Type Imports
185
+ 1. Import types from package
186
+ 2. Use for function parameters
187
+ 3. Define return types
188
+ 4. Handle typed errors
189
+ 5. Validate runtime data
190
+
191
+ ### Model Selection
192
+ 1. Import model constants
193
+ 2. Use helper functions for feature-based selection
194
+ 3. Get model ID for specific feature
195
+ 4. Use returned ID in service calls
196
+ 5. Avoid hardcoded model strings
197
+
198
+ ### Error Handling
199
+ 1. Catch error from operation
200
+ 2. Check if `instanceof GeminiError`
201
+ 3. Switch on error.type
202
+ 4. Handle each error type appropriately
203
+ 5. Provide user feedback
204
+
205
+ ### Configuration
206
+ 1. Create config object
207
+ 2. Use types for validation
208
+ 3. Specify model IDs from constants
209
+ 4. Include retry and timeout settings
210
+ 5. Initialize provider with config
211
+
212
+ ## 🚨 Common Pitfalls
213
+
214
+ ### Don't
215
+ - Use `any` type to bypass typing
216
+ - Hardcode model IDs
217
+ - Ignore error types
218
+ - Skip runtime validation
219
+ - Use magic strings
220
+
221
+ ### Do
222
+ - Use explicit type annotations
223
+ - Import constants for model IDs
224
+ - Check error types
225
+ - Validate runtime data
226
+ - Use helper functions
227
+ - Define proper interfaces
228
+
229
+ ---
230
+
231
+ **Last Updated**: 2025-01-08
232
+ **See Also**: [AI_GUIDELINES.md](../../AI_GUIDELINES.md)
@@ -0,0 +1,191 @@
1
+ # Domain Constants
2
+
3
+ Constant values and model catalogs for Gemini provider. Contains feature-based model mappings for image and video operations.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import {
9
+ GEMINI_IMAGE_FEATURE_MODELS,
10
+ GEMINI_VIDEO_FEATURE_MODELS,
11
+ getGeminiImageFeatureModel,
12
+ getGeminiVideoFeatureModel,
13
+ getAllFeatureModels
14
+ } from '@umituz/react-native-ai-gemini-provider';
15
+ ```
16
+
17
+ ## 🎯 Purpose
18
+
19
+ Use constants to map features to appropriate models. Provides centralized model selection for image and video processing features.
20
+
21
+ **When to use:**
22
+ - Get model ID for specific feature
23
+ - Display available features in UI
24
+ - Validate feature requests
25
+ - Map user features to models
26
+ - List supported operations
27
+
28
+ ## 📌 Strategy
29
+
30
+ Features map to specific models. This system:
31
+ - Provides constant feature-to-model mappings
32
+ - Centralizes model configuration
33
+ - Enables feature validation
34
+ - Simplifies model selection
35
+ - Maintains consistency across codebase
36
+
37
+ **Key Decision**: Use feature constants instead of hardcoded model IDs. This enables centralized model management and updates.
38
+
39
+ ## ⚠️ Rules
40
+
41
+ ### Usage Rules
42
+ - **MUST** use constants for model selection
43
+ - **SHOULD** validate feature before use
44
+ - **MUST** handle unknown features gracefully
45
+ - **SHOULD** check model compatibility
46
+ - **MUST NOT** hardcode model IDs
47
+
48
+ ### Feature Selection Rules
49
+ - **MUST** select appropriate model for feature
50
+ - **SHOULD** use getter functions
51
+ - **MUST** validate feature type
52
+ - **SHOULD** handle missing features
53
+ - **MUST** return valid model IDs
54
+
55
+ ### Validation Rules
56
+ - **SHOULD** validate feature strings
57
+ - **MUST** check feature exists
58
+ - **SHOULD** provide fallback models
59
+ - **MUST** throw on invalid features
60
+ - **SHOULD** log validation failures
61
+
62
+ ### Maintenance Rules
63
+ - **MUST** update constants when models change
64
+ - **SHOULD** document model changes
65
+ - **MUST** maintain backward compatibility
66
+ - **SHOULD** test feature mappings
67
+ - **MUST** update documentation
68
+
69
+ ## 🤖 AI Agent Guidelines
70
+
71
+ ### When Getting Model for Feature
72
+ 1. **CALL** getGeminiImageFeatureModel() or getGeminiVideoFeatureModel()
73
+ 2. **VALIDATE** feature exists
74
+ 3. **RETURN** model ID
75
+ 4. **HANDLE** unknown features
76
+ 5. **LOG** model selection
77
+
78
+ ### When Listing Features
79
+ 1. **CALL** getAllFeatureModels()
80
+ 2. **FILTER** by feature type
81
+ 3. **DISPLAY** to user
82
+ 4. **GROUP** by category
83
+ 5. **HANDLE** empty lists
84
+
85
+ ### When Validating Features
86
+ 1. **CHECK** feature in constants
87
+ 2. **VERIFY** model exists
88
+ 3. **RETURN** validation result
89
+ 4. **PROVIDE** error messages
90
+ 5. **SUGGEST** alternatives
91
+
92
+ ### Code Style Rules
93
+ - **USE** constants instead of hardcoded values
94
+ - **IMPORT** specific constants needed
95
+ - **VALIDATE** feature inputs
96
+ - **HANDLE** edge cases
97
+ - **DOCUMENT** custom features
98
+
99
+ ## 📦 Available Constants
100
+
101
+ ### Image Feature Models
102
+
103
+ **Refer to**: [`feature-models.constants.ts`](./feature-models.constants.ts)
104
+
105
+ **Features:**
106
+ - `upscale` - Image upscaling
107
+ - `photo-restore` - Photo restoration
108
+ - `face-swap` - Face swapping
109
+ - `anime-selfie` - Anime style transformation
110
+ - `remove-background` - Background removal
111
+ - `remove-object` - Object removal
112
+ - `hd-touch-up` - HD enhancement
113
+ - `replace-background` - Background replacement
114
+
115
+ **Model**: All use `gemini-2.0-flash-exp`
116
+
117
+ ### Video Feature Models
118
+
119
+ **Refer to**: [`feature-models.constants.ts`](./feature-models.constants.ts)
120
+
121
+ **Features:**
122
+ - `ai-hug` - AI hugging effect
123
+ - `ai-kiss` - AI kissing effect
124
+
125
+ **Model**: All use `gemini-2.0-flash-exp`
126
+
127
+ ## 🔗 Related Modules
128
+
129
+ - **Domain Entities**: [`../entities/README.md`](../entities/README.md)
130
+ - **Domain README**: [`../README.md`](../README.md)
131
+ - **Model Selector**: [`../../infrastructure/services/FEATURE_MODEL_SELECTOR_SERVICE.md`](../../infrastructure/services/FEATURE_MODEL_SELECTOR_SERVICE.md)
132
+
133
+ ## 📋 Feature Reference
134
+
135
+ ### Image Editing Features
136
+ - **upscale**: Enlarge image while maintaining quality
137
+ - **photo-restore**: Restore old or damaged photos
138
+ - **face-swap**: Swap faces between images
139
+ - **anime-selfie**: Transform selfie to anime style
140
+ - **remove-background**: Remove image background
141
+ - **remove-object**: Remove specific objects from image
142
+ - **hd-touch-up**: Enhance image quality to HD
143
+ - **replace-background**: Replace image background
144
+
145
+ ### Video Features
146
+ - **ai-hug**: Generate video of subjects hugging
147
+ - **ai-kiss**: Generate video of subjects kissing
148
+
149
+ ## 🎓 Usage Patterns
150
+
151
+ ### Feature-Based Model Selection
152
+ 1. Determine feature type (image or video)
153
+ 2. Call appropriate getter function
154
+ 3. Get model ID for feature
155
+ 4. Use model in service call
156
+ 5. Handle unknown features
157
+
158
+ ### Feature Listing
159
+ 1. Call getAllFeatureModels()
160
+ 2. Iterate through feature list
161
+ 3. Group by category
162
+ 4. Display to user
163
+ 5. Handle feature selection
164
+
165
+ ### Feature Validation
166
+ 1. Check feature in constants
167
+ 2. Verify model mapping exists
168
+ 3. Validate feature type
169
+ 4. Return validation result
170
+ 5. Provide feedback
171
+
172
+ ## 🚨 Common Pitfalls
173
+
174
+ ### Don't
175
+ - Hardcode model IDs in application code
176
+ - Use features without validation
177
+ - Assume all features use same model
178
+ - Skip feature existence checks
179
+ - Use invalid feature strings
180
+
181
+ ### Do
182
+ - Use constants for model selection
183
+ - Validate features before use
184
+ - Check model mappings
185
+ - Handle unknown features gracefully
186
+ - Update constants when models change
187
+
188
+ ---
189
+
190
+ **Last Updated**: 2025-01-08
191
+ **See Also**: [AI_GUIDELINES.md](../../../AI_GUIDELINES.md)