@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
@@ -23,7 +23,10 @@ import type {
23
23
  } from "../../domain/entities";
24
24
  import { geminiImageGenerationService } from "./gemini-image-generation.service";
25
25
  import { geminiImageEditService } from "./gemini-image-edit.service";
26
- import { providerInitializer, type GeminiProviderConfig } from "./provider-initializer";
26
+ import {
27
+ providerInitializer,
28
+ type GeminiProviderConfig,
29
+ } from "./provider-initializer";
27
30
  import { jobProcessor } from "./job-processor";
28
31
  import { generationExecutor } from "./generation-executor";
29
32
  import { featureInputBuilder } from "./feature-input-builder";
@@ -50,6 +53,7 @@ const GEMINI_CAPABILITIES: ProviderCapabilities = {
50
53
  textToVideo: true,
51
54
  imageToVideo: true,
52
55
  textToVoice: false,
56
+ textToText: true,
53
57
  };
54
58
 
55
59
  export class GeminiProvider implements IAIProvider {
@@ -76,7 +80,10 @@ export class GeminiProvider implements IAIProvider {
76
80
  );
77
81
  }
78
82
 
79
- submitJob(model: string, input: Record<string, unknown>): Promise<JobSubmission> {
83
+ submitJob(
84
+ model: string,
85
+ input: Record<string, unknown>,
86
+ ): Promise<JobSubmission> {
80
87
  return jobProcessor.submitJob(model, input);
81
88
  }
82
89
 
@@ -0,0 +1,203 @@
1
+ # Telemetry Module
2
+
3
+ Monitoring and logging system for AI operations. Tracks request, response, error, and retry events for observability and debugging.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import { telemetryHooks } from '@umituz/react-native-ai-gemini-provider';
9
+ ```
10
+
11
+ ## 🎯 Purpose
12
+
13
+ Use telemetry to monitor AI operations in real-time. Provides event-based system for tracking performance, errors, and usage patterns.
14
+
15
+ **When to use:**
16
+ - Monitor API call performance
17
+ - Track error rates and types
18
+ - Analyze usage patterns
19
+ - Debug AI operations
20
+ - Send events to analytics services
21
+ - Implement custom monitoring
22
+ - Track rate limiting
23
+ - Generate metrics
24
+
25
+ ## 📌 Strategy
26
+
27
+ Telemetry provides visibility into AI operations. This system:
28
+ - Uses publish-subscribe pattern for events
29
+ - Supports multiple listeners simultaneously
30
+ - Emits events for all operations
31
+ - Provides timing and metadata
32
+ - Enables custom monitoring solutions
33
+ - Integrates with analytics platforms
34
+
35
+ **Key Decision**: Subscribe to telemetry events early in application lifecycle. Use events for monitoring, analytics, and debugging without modifying core services.
36
+
37
+ ## ⚠️ Rules
38
+
39
+ ### Usage Rules
40
+ - **MUST** subscribe to events before operations
41
+ - **SHOULD** unsubscribe when done
42
+ - **MUST NOT** emit sensitive data in events
43
+ - **SHOULD** aggregate metrics for performance
44
+ - **MUST** handle listener errors gracefully
45
+
46
+ ### Event Subscription Rules
47
+ - **SHOULD** subscribe at application startup
48
+ - **MUST** store unsubscribe function
49
+ - **SHOULD** handle all event types
50
+ - **MUST NOT** block event emission
51
+ - **SHOULD** filter events as needed
52
+
53
+ ### Data Privacy Rules
54
+ - **MUST NOT** log API keys in events
55
+ - **SHOULD NOT** include user data in metadata
56
+ - **MUST** sanitize sensitive information
57
+ - **SHOULD** use anonymized IDs
58
+ - **MUST** comply with privacy policies
59
+
60
+ ### Performance Rules
61
+ - **SHOULD** keep listeners lightweight
62
+ - **MUST** avoid expensive operations in listeners
63
+ - **SHOULD** batch event processing
64
+ - **MUST NOT** block main thread
65
+ - **SHOULD** use async operations for heavy processing
66
+
67
+ ## 🤖 AI Agent Guidelines
68
+
69
+ ### When Adding Telemetry
70
+ 1. **SUBSCRIBE** to telemetry events early
71
+ 2. **HANDLE** all event types appropriately
72
+ 3. **AGGREGATE** metrics for analysis
73
+ 4. **SEND** to monitoring/analytics service
74
+ 5. **UNSUBSCRIBE** on cleanup
75
+
76
+ ### When Creating Custom Monitoring
77
+ 1. **DEFINE** metrics to track
78
+ 2. **CREATE** data structures for aggregation
79
+ 3. **IMPLEMENT** event filtering
80
+ 4. **CALCULATE** statistics periodically
81
+ 5. **EXPORT** metrics for visualization
82
+
83
+ ### When Debugging with Telemetry
84
+ 1. **ADD** verbose logging for events
85
+ 2. **TRACK** request/response correlation
86
+ 3. **MONITOR** error patterns
87
+ 4. **ANALYZE** performance metrics
88
+ 5. **IDENTIFY** bottlenecks
89
+
90
+ ### Code Style Rules
91
+ - **USE** unsubscribe pattern for cleanup
92
+ - **FILTER** events by type or model
93
+ - **AGGREGATE** metrics efficiently
94
+ - **HANDLE** errors in listeners
95
+ - **LOG** important state changes
96
+
97
+ ## 📦 Available Telemetry
98
+
99
+ ### TelemetryHooks
100
+
101
+ **Refer to**: [`TelemetryHooks.ts`](./TelemetryHooks.ts)
102
+
103
+ **Singleton instance**: `telemetryHooks`
104
+
105
+ **Methods:**
106
+ - `subscribe(listener)` - Add event listener
107
+ - `emit(event)` - Emit custom event
108
+ - `logRequest(model, feature?)` - Log request start
109
+ - `logResponse(model, startTime, feature?, metadata?)` - Log response
110
+ - `logError(model, error, feature?)` - Log error
111
+ - `logRetry(model, attempt, feature?)` - Log retry
112
+ - `clear()` - Clear all listeners
113
+ - `getListenerCount()` - Get active listener count
114
+
115
+ ## 🔗 Related Modules
116
+
117
+ - **Infrastructure README**: [`../infrastructure/README.md`](../infrastructure/README.md)
118
+ - **Services**: [`../services/README.md`](../services/README.md)
119
+ - **Interceptors**: [`../interceptors/README.md`](../interceptors/README.md)
120
+
121
+ ## 📋 Event Types
122
+
123
+ ### Request Event
124
+ Emitted when operation starts.
125
+ - Contains model and feature
126
+ - Includes timestamp
127
+ - No duration yet
128
+
129
+ ### Response Event
130
+ Emitted when operation completes.
131
+ - Contains model and feature
132
+ - Includes duration in milliseconds
133
+ - May include metadata (token count, finish reason)
134
+
135
+ ### Error Event
136
+ Emitted when operation fails.
137
+ - Contains model and feature
138
+ - Includes error information
139
+ - May include error type
140
+
141
+ ### Retry Event
142
+ Emitted when retry is attempted.
143
+ - Contains model and feature
144
+ - Includes attempt number
145
+ - Tracks retry behavior
146
+
147
+ ## 🎓 Usage Patterns
148
+
149
+ ### Basic Monitoring
150
+ 1. Import `telemetryHooks`
151
+ 2. Subscribe to events with listener function
152
+ 3. Handle different event types
153
+ 4. Store unsubscribe function
154
+ 5. Unsubscribe on cleanup
155
+
156
+ ### Analytics Integration
157
+ 1. Subscribe to telemetry events
158
+ 2. Transform events to analytics format
159
+ 3. Send to analytics service
160
+ 4. Filter sensitive information
161
+ 5. Handle errors gracefully
162
+
163
+ ### Performance Tracking
164
+ 1. Track response times by model
165
+ 2. Calculate statistics (avg, min, max)
166
+ 3. Monitor trends over time
167
+ 4. Alert on slow operations
168
+ 5. Generate performance reports
169
+
170
+ ### Error Tracking
171
+ 1. Subscribe to error events
172
+ 2. Categorize errors by type
173
+ 3. Track error rates
174
+ 4. Send to error tracking service
175
+ 5. Monitor for anomalies
176
+
177
+ ### Custom Dashboard
178
+ 1. Aggregate event data
179
+ 2. Calculate statistics
180
+ 3. Track model usage
181
+ 4. Monitor success rates
182
+ 5. Generate dashboard metrics
183
+
184
+ ## 🚨 Common Pitfalls
185
+
186
+ ### Don't
187
+ - Forget to unsubscribe from events
188
+ - Log sensitive data in events
189
+ - Block event emission with heavy processing
190
+ - Subscribe multiple times without cleanup
191
+ - Emit custom events without proper format
192
+
193
+ ### Do
194
+ - Subscribe early in application lifecycle
195
+ - Clean up listeners when done
196
+ - Keep listeners lightweight
197
+ - Aggregate metrics efficiently
198
+ - Handle all event types appropriately
199
+
200
+ ---
201
+
202
+ **Last Updated**: 2025-01-08
203
+ **See Also**: [AI_GUIDELINES.md](../../../../AI_GUIDELINES.md)
@@ -0,0 +1,200 @@
1
+ # Telemetry System
2
+
3
+ Monitoring and logging system for AI operations. Allows applications to track requests, responses, errors, and retries in real-time.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import { telemetryHooks } from '@umituz/react-native-ai-gemini-provider';
9
+ ```
10
+
11
+ ## 🎯 Purpose
12
+
13
+ Use telemetry to monitor AI operations in real-time. Provides event-based system for tracking performance, errors, and usage patterns.
14
+
15
+ **When to use:**
16
+ - Monitor API call performance
17
+ - Track error rates and types
18
+ - Analyze usage patterns
19
+ - Debug AI operations
20
+ - Send events to analytics services
21
+ - Track rate limiting
22
+
23
+ ## 📌 Strategy
24
+
25
+ Telemetry provides visibility into AI operations. This system:
26
+ - Uses publish-subscribe pattern for events
27
+ - Supports multiple listeners simultaneously
28
+ - Emits events for all operations
29
+ - Provides timing and metadata
30
+ - Enables custom monitoring solutions
31
+
32
+ **Key Decision**: Subscribe to telemetry events early in application lifecycle. Use events for monitoring, analytics, and debugging.
33
+
34
+ ## ⚠️ Rules
35
+
36
+ ### Usage Rules
37
+ - **MUST** subscribe to events before operations
38
+ - **SHOULD** unsubscribe when done
39
+ - **MUST NOT** emit sensitive data in events
40
+ - **SHOULD** aggregate metrics for performance
41
+ - **MUST** handle listener errors gracefully
42
+
43
+ ### Event Subscription Rules
44
+ - **SHOULD** subscribe at application startup
45
+ - **MUST** store unsubscribe function
46
+ - **SHOULD** handle all event types
47
+ - **MUST NOT** block event emission
48
+ - **SHOULD** filter events as needed
49
+
50
+ ### Data Privacy Rules
51
+ - **MUST NOT** log API keys in events
52
+ - **SHOULD NOT** include user data in metadata
53
+ - **MUST** sanitize sensitive information
54
+ - **SHOULD** use anonymized IDs
55
+ - **MUST** comply with privacy policies
56
+
57
+ ### Performance Rules
58
+ - **SHOULD** keep listeners lightweight
59
+ - **MUST** avoid expensive operations in listeners
60
+ - **SHOULD** batch event processing
61
+ - **MUST NOT** block main thread
62
+ - **SHOULD** use async operations for heavy processing
63
+
64
+ ## 🤖 AI Agent Guidelines
65
+
66
+ ### When Adding Telemetry
67
+ 1. **SUBSCRIBE** to telemetry events early
68
+ 2. **HANDLE** all event types appropriately
69
+ 3. **AGGREGATE** metrics for analysis
70
+ 4. **SEND** to monitoring/analytics service
71
+ 5. **UNSUBSCRIBE** on cleanup
72
+
73
+ ### When Creating Custom Monitoring
74
+ 1. **DEFINE** metrics to track
75
+ 2. **CREATE** data structures for aggregation
76
+ 3. **IMPLEMENT** event filtering
77
+ 4. **CALCULATE** statistics periodically
78
+ 5. **EXPORT** metrics for visualization
79
+
80
+ ### When Debugging with Telemetry
81
+ 1. **ADD** verbose logging for events
82
+ 2. **TRACK** request/response correlation
83
+ 3. **MONITOR** error patterns
84
+ 4. **ANALYZE** performance metrics
85
+ 5. **IDENTIFY** bottlenecks
86
+
87
+ ### Code Style Rules
88
+ - **USE** unsubscribe pattern for cleanup
89
+ - **FILTER** events by type or model
90
+ - **AGGREGATE** metrics efficiently
91
+ - **HANDLE** errors in listeners
92
+ - **LOG** important state changes
93
+
94
+ ## 📦 Available System
95
+
96
+ ### telemetryHooks
97
+
98
+ **Refer to**: [`TelemetryHooks.ts`](./TelemetryHooks.ts)
99
+
100
+ **Singleton instance**
101
+
102
+ **Methods:**
103
+ - `subscribe(listener)` - Add event listener
104
+ - `emit(event)` - Emit custom event
105
+ - `logRequest(model, feature?)` - Log request start
106
+ - `logResponse(model, startTime, feature?, metadata?)` - Log response
107
+ - `logError(model, error, feature?)` - Log error
108
+ - `logRetry(model, attempt, feature?)` - Log retry
109
+ - `clear()` - Clear all listeners
110
+ - `getListenerCount()` - Get active listener count
111
+
112
+ ## 🔗 Related Modules
113
+
114
+ - **Infrastructure README**: [`../infrastructure/README.md`](../infrastructure/README.md)
115
+ - **Services**: [`../services/README.md`](../services/README.md)
116
+ - **Interceptors**: [`../interceptors/README.md`](../interceptors/README.md)
117
+
118
+ ## 📋 Event Types
119
+
120
+ ### Request Event
121
+ Emitted when operation starts.
122
+ - Contains model and feature
123
+ - Includes timestamp
124
+ - No duration yet
125
+
126
+ ### Response Event
127
+ Emitted when operation completes.
128
+ - Contains model and feature
129
+ - Includes duration in milliseconds
130
+ - May include metadata (token count, finish reason)
131
+
132
+ ### Error Event
133
+ Emitted when operation fails.
134
+ - Contains model and feature
135
+ - Includes error information
136
+ - May include error type
137
+
138
+ ### Retry Event
139
+ Emitted when retry is attempted.
140
+ - Contains model and feature
141
+ - Includes attempt number
142
+ - Tracks retry behavior
143
+
144
+ ## 🎓 Usage Patterns
145
+
146
+ ### Basic Monitoring
147
+ 1. Subscribe to telemetry events
148
+ 2. Track metrics in event handler
149
+ 3. Send to analytics/monitoring service
150
+ 4. Aggregate and analyze metrics
151
+ 5. Unsubscribe when done
152
+
153
+ ### Analytics Integration
154
+ 1. Subscribe to telemetry events
155
+ 2. Transform events to analytics format
156
+ 3. Send to analytics service
157
+ 4. Filter sensitive information
158
+ 5. Handle errors gracefully
159
+
160
+ ### Performance Tracking
161
+ 1. Track response times by model
162
+ 2. Calculate statistics (avg, min, max)
163
+ 3. Monitor trends over time
164
+ 4. Alert on slow operations
165
+ 5. Generate performance reports
166
+
167
+ ### Error Tracking
168
+ 1. Subscribe to error events
169
+ 2. Categorize errors by type
170
+ 3. Track error rates
171
+ 4. Send to error tracking service
172
+ 5. Monitor for anomalies
173
+
174
+ ### Custom Dashboard
175
+ 1. Aggregate event data
176
+ 2. Calculate statistics
177
+ 3. Track model usage
178
+ 4. Monitor success rates
179
+ 5. Generate dashboard metrics
180
+
181
+ ## 🚨 Common Pitfalls
182
+
183
+ ### Don't
184
+ - Forget to unsubscribe from events
185
+ - Log sensitive data in events
186
+ - Block event emission with heavy processing
187
+ - Subscribe multiple times without cleanup
188
+ - Emit custom events without proper format
189
+
190
+ ### Do
191
+ - Subscribe early in application lifecycle
192
+ - Clean up listeners when done
193
+ - Keep listeners lightweight
194
+ - Aggregate telemetry metrics
195
+ - Handle all event types appropriately
196
+
197
+ ---
198
+
199
+ **Last Updated**: 2025-01-08
200
+ **See Also**: [AI_GUIDELINES.md](../../../../AI_GUIDELINES.md)
@@ -0,0 +1,175 @@
1
+ # Data Transformer Utilities
2
+
3
+ Helper functions for transforming and processing Gemini API data. Extracts and converts data formats.
4
+
5
+ ## 📍 Import Path
6
+
7
+ ```
8
+ import {
9
+ extractBase64Data,
10
+ extractTextFromResponse
11
+ } from '@umituz/react-native-ai-gemini-provider';
12
+ ```
13
+
14
+ ## 🎯 Purpose
15
+
16
+ Use data transformers to extract and convert Gemini API data formats. Handles base64 extraction and text parsing.
17
+
18
+ **When to use:**
19
+ - Extract base64 from data URLs
20
+ - Parse text from API responses
21
+ - Clean up data formats
22
+ - Transform response structures
23
+ - Process multimodal data
24
+
25
+ ## 📌 Strategy
26
+
27
+ Data transformation ensures compatibility. This system:
28
+ - Extracts base64 from various formats
29
+ - Parses text from complex responses
30
+ - Handles missing data gracefully
31
+ - Normalizes data structures
32
+ - Simplifies data processing
33
+
34
+ **Key Decision**: Always use transformers for data extraction. Handles edge cases and format variations automatically.
35
+
36
+ ## ⚠️ Rules
37
+
38
+ ### Extraction Rules
39
+ - **MUST** handle missing data gracefully
40
+ - **SHOULD** validate input format
41
+ - **MUST** return empty string on failure
42
+ - **SHOULD** log extraction errors
43
+ - **MUST NOT** throw on invalid data
44
+
45
+ ### Format Rules
46
+ - **MUST** support multiple input formats
47
+ - **SHOULD** detect format automatically
48
+ - **MUST** preserve data integrity
49
+ - **SHOULD** handle encoding correctly
50
+ - **MUST NOT** corrupt data
51
+
52
+ ### Validation Rules
53
+ - **SHOULD** validate base64 before use
54
+ - **MUST** check for empty responses
55
+ - **SHOULD** handle malformed data
56
+ - **MUST** provide safe defaults
57
+ - **SHOULD NOT** assume format
58
+
59
+ ### Error Handling Rules
60
+ - **MUST** wrap extraction in try-catch
61
+ - **SHOULD** log transformation errors
62
+ - **MUST** return safe defaults
63
+ - **SHOULD NOT** propagate errors
64
+ - **MUST** handle all edge cases
65
+
66
+ ## 🤖 AI Agent Guidelines
67
+
68
+ ### When Extracting Base64
69
+ 1. **CALL** extractBase64Data()
70
+ 2. **PROVIDE** data URL or base64
71
+ 3. **GET** pure base64 string
72
+ 4. **VALIDATE** output
73
+ 5. **HANDLE** extraction errors
74
+
75
+ ### When Extracting Text
76
+ 1. **CALL** extractTextFromResponse()
77
+ 2. **PROVIDE** Gemini response object
78
+ 3. **GET** concatenated text
79
+ 4. **CHECK** for empty results
80
+ 5. **HANDLE** missing text
81
+
82
+ ### When Transforming Data
83
+ 1. **VALIDATE** input format
84
+ 2. **CALL** appropriate transformer
85
+ 3. **CHECK** output validity
86
+ 4. **USE** transformed data
87
+ 5. **HANDLE** transformation errors
88
+
89
+ ### Code Style Rules
90
+ - **VALIDATE** input before transformation
91
+ - **HANDLE** all edge cases
92
+ - **PROVIDE** safe defaults
93
+ - **LOG** transformation errors
94
+ - **TEST** with various formats
95
+
96
+ ## 📦 Available Functions
97
+
98
+ **Refer to**: [`gemini-data-transformer.util.ts`](./gemini-data-transformer.util.ts)
99
+
100
+ ### Base64 Extraction
101
+ - `extractBase64Data(base64)` - Extract base64 from data URL
102
+
103
+ ### Text Extraction
104
+ - `extractTextFromResponse(response)` - Extract text from Gemini response
105
+
106
+ ## 🔗 Related Modules
107
+
108
+ - **Domain Entities**: [`../../domain/entities/README.md`](../../domain/entities/README.md)
109
+ - **Image Edit Service**: [`../services/IMAGE_EDIT_SERVICE.md`](../services/IMAGE_EDIT_SERVICE.md)
110
+ - **Response Formatter**: [`../response/RESPONSE_FORMATTER.md`](../response/RESPONSE_FORMATTER.md)
111
+
112
+ ## 📋 Supported Formats
113
+
114
+ ### Base64 Input Formats
115
+ - Data URL: `data:image/png;base64,iVBORw0KG...`
116
+ - Pure base64: `iVBORw0KG...`
117
+ - Various MIME types: PNG, JPEG, GIF, WebP
118
+
119
+ ### Response Structure
120
+ ```typescript
121
+ {
122
+ candidates: [{
123
+ content: {
124
+ parts: [
125
+ { text: string },
126
+ { inlineData: { mimeType: string; data: string } }
127
+ ]
128
+ }
129
+ }]
130
+ }
131
+ ```
132
+
133
+ ## 🎓 Usage Patterns
134
+
135
+ ### Base64 Extraction
136
+ 1. Provide data URL or base64
137
+ 2. Call extractBase64Data()
138
+ 3. Get pure base64 string
139
+ 4. Use in API requests
140
+ 5. Handle empty results
141
+
142
+ ### Text Extraction
143
+ 1. Provide Gemini response object
144
+ 2. Call extractTextFromResponse()
145
+ 3. Get concatenated text
146
+ 4. Use extracted text
147
+ 5. Handle empty responses
148
+
149
+ ### Data Processing
150
+ 1. Validate input format
151
+ 2. Transform with utilities
152
+ 3. Validate output
153
+ 4. Use in application
154
+ 5. Handle errors gracefully
155
+
156
+ ## 🚨 Common Pitfalls
157
+
158
+ ### Don't
159
+ - Assume data format
160
+ - Skip validation
161
+ - Throw on invalid data
162
+ - Ignore empty responses
163
+ - Corrupt data during transformation
164
+
165
+ ### Do
166
+ - Validate input format
167
+ - Handle all edge cases
168
+ - Provide safe defaults
169
+ - Test with various formats
170
+ - Handle errors gracefully
171
+
172
+ ---
173
+
174
+ **Last Updated**: 2025-01-08
175
+ **See Also**: [AI_GUIDELINES.md](../../../../AI_GUIDELINES.md)