@umituz/react-native-design-system 4.23.100 → 4.23.101
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 +1 -1
- package/src/atoms/AtomicInput.tsx +0 -2
- package/src/media/domain/entities/{MultimediaFlashcardTypes.ts → MediaAttachments.ts} +13 -32
- package/src/media/index.ts +24 -23
- package/src/media/infrastructure/services/MediaGenerationService.ts +1 -1
- package/src/media/infrastructure/services/MediaOptimizerService.ts +1 -1
- package/src/media/infrastructure/services/MediaUploadService.ts +1 -1
- package/src/media/infrastructure/services/MediaValidationService.ts +1 -1
- package/src/media/infrastructure/services/MultimediaFlashcardService.ts +1 -1
- package/src/media/infrastructure/utils/PermissionManager.ts +1 -1
- package/src/media/infrastructure/utils/media-collection-utils.ts +4 -2
- package/src/media/infrastructure/utils/mediaPickerMappers.ts +1 -1
- package/src/media/presentation/hooks/multimedia.types.ts +1 -1
- package/src/media/presentation/hooks/useCardMultimediaFlashcard.ts +4 -4
- package/src/media/presentation/hooks/useMedia.ts +2 -2
- package/src/media/presentation/hooks/useMediaGeneration.ts +1 -1
- package/src/media/presentation/hooks/useMediaUpload.ts +1 -1
- package/src/media/presentation/hooks/useMediaValidation.ts +1 -1
- package/src/media/presentation/hooks/useMultimediaFlashcard.ts +1 -1
- package/src/molecules/navigation/utils/AppNavigation.ts +3 -3
- package/src/storage/infrastructure/adapters/StorageService.ts +3 -3
- package/src/storage/infrastructure/repositories/BaseStorageOperations.ts +5 -5
- package/src/storage/presentation/hooks/CacheStorageOperations.ts +3 -3
- package/src/storage/presentation/hooks/useStore.ts +0 -1
- package/src/media/domain/entities/CardMultimedia.types.README.md +0 -129
- package/src/media/domain/entities/Media.README.md +0 -80
- package/src/media/domain/entities/MultimediaFlashcardTypes.README.md +0 -144
- package/src/media/domain/utils/MediaUtils.README.md +0 -178
- package/src/media/index.ts.README.md +0 -191
- package/src/media/infrastructure/services/CardMultimediaService.README.md +0 -176
- package/src/media/infrastructure/services/CardMultimediaService.ts +0 -98
- package/src/media/infrastructure/services/MediaGenerationService.README.md +0 -142
- package/src/media/infrastructure/services/MediaOptimizerService.README.md +0 -145
- package/src/media/infrastructure/services/MediaPickerService.README.md +0 -106
- package/src/media/infrastructure/services/MediaSaveService.README.md +0 -120
- package/src/media/infrastructure/services/MediaUploadService.README.md +0 -135
- package/src/media/infrastructure/services/MediaValidationService.README.md +0 -135
- package/src/media/infrastructure/services/MultimediaFlashcardService.README.md +0 -142
- package/src/media/infrastructure/utils/mediaHelpers.README.md +0 -96
- package/src/media/infrastructure/utils/mediaPickerMappers.README.md +0 -129
- package/src/media/presentation/hooks/card-multimedia.types.README.md +0 -177
- package/src/media/presentation/hooks/card-multimedia.types.ts +0 -53
- package/src/media/presentation/hooks/multimedia.types.README.md +0 -201
- package/src/media/presentation/hooks/useCardMediaGeneration.ts +0 -20
- package/src/media/presentation/hooks/useCardMediaUpload.ts +0 -84
- package/src/media/presentation/hooks/useCardMediaValidation.ts +0 -104
- package/src/media/presentation/hooks/useCardMultimediaFlashcard.README.md +0 -158
- package/src/media/presentation/hooks/useMedia.README.md +0 -94
- package/src/media/presentation/hooks/useMediaGeneration.README.md +0 -118
- package/src/media/presentation/hooks/useMediaUpload.README.md +0 -108
- package/src/media/presentation/hooks/useMediaValidation.README.md +0 -134
- package/src/media/presentation/hooks/useMultimediaFlashcard.README.md +0 -141
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# CardMultimediaService
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Central service for managing all media operations in card-based applications, combining upload, generation, validation, and optimization capabilities through a singleton instance with card-specific media support.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/CardMultimediaService`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide unified interface for all card media operations
|
|
11
|
-
- Coordinate upload, generation, validation, and optimization services
|
|
12
|
-
- Maintain singleton pattern for resource efficiency
|
|
13
|
-
- Support card-specific media requirements (front/back/both positions)
|
|
14
|
-
- Simplify media management for card applications
|
|
15
|
-
- Enable batch operations for card sets
|
|
16
|
-
- Provide consistent API across all media operations
|
|
17
|
-
- Handle card-specific metadata and associations
|
|
18
|
-
|
|
19
|
-
## Forbidden
|
|
20
|
-
- **DO NOT** create multiple service instances (use singleton only)
|
|
21
|
-
- **DO NOT** call media operations without validation
|
|
22
|
-
- **DO NOT** assume AI generation is always available
|
|
23
|
-
- **DO NOT** ignore optimization recommendations
|
|
24
|
-
- **DO NOT** bypass singleton pattern with direct service instantiation
|
|
25
|
-
- **DO NOT** proceed without error handling for any operation
|
|
26
|
-
- **DO NOT** mix card media with non-card media types
|
|
27
|
-
- **DO NOT** assume all operations will succeed
|
|
28
|
-
- **DO NOT** ignore card-specific position requirements
|
|
29
|
-
|
|
30
|
-
## Rules
|
|
31
|
-
1. MUST use getInstance() to retrieve service instance
|
|
32
|
-
2. MUST NOT create new instances with constructor
|
|
33
|
-
3. MUST maintain single instance across application lifecycle
|
|
34
|
-
4. MUST validate media before upload operations
|
|
35
|
-
5. MUST support CardMediaAttachment and CardMediaPosition types
|
|
36
|
-
6. MUST handle position attribute (front/back/both) correctly
|
|
37
|
-
7. MUST handle all operation failures gracefully
|
|
38
|
-
8. MUST provide consistent interface through all methods
|
|
39
|
-
9. MUST initialize all sub-services on first use
|
|
40
|
-
10. MUST coordinate between sub-services for complex operations
|
|
41
|
-
11. MUST handle asynchronous operations properly
|
|
42
|
-
12. MUST return appropriate error messages for failures
|
|
43
|
-
13. MUST support card-specific media constraints
|
|
44
|
-
|
|
45
|
-
## AI Agent Guidelines
|
|
46
|
-
|
|
47
|
-
When working with CardMultimediaService:
|
|
48
|
-
|
|
49
|
-
1. **Singleton Pattern**: Always use getInstance(), never constructor
|
|
50
|
-
2. **Validation First**: Validate before upload or generation
|
|
51
|
-
3. **Position Awareness**: Always consider card position (front/back/both)
|
|
52
|
-
4. **Operation Flow**: Follow validate -> upload/generate -> optimize -> store
|
|
53
|
-
5. **Error Handling**: Handle errors at each step appropriately
|
|
54
|
-
6. **Resource Management**: Rely on singleton for efficient resource use
|
|
55
|
-
7. **Type Safety**: Use CardMediaAttachment and CardMediaPosition types
|
|
56
|
-
8. **Card Context**: Maintain card-specific context throughout operations
|
|
57
|
-
|
|
58
|
-
### Card Creation Workflow
|
|
59
|
-
|
|
60
|
-
- **Step 1 - Get Instance**: `CardMultimediaService.getInstance()`
|
|
61
|
-
- **Step 2 - Select File**: Pick file from device or camera
|
|
62
|
-
- **Step 3 - Validate**: Run validation, check results
|
|
63
|
-
- **Step 4 - Upload**: Upload if validation passes
|
|
64
|
-
- **Step 5 - Set Position**: Assign position (front/back/both)
|
|
65
|
-
- **Step 6 - Optimize** (Optional): Optimize if file is large
|
|
66
|
-
- **Step 7 - Store**: Save attachment with card data
|
|
67
|
-
- **Step 8 - Handle Errors**: Provide feedback at each step
|
|
68
|
-
|
|
69
|
-
### Media Upload with Position
|
|
70
|
-
|
|
71
|
-
- Use for user-selected media on card sides
|
|
72
|
-
- Always validate before uploading
|
|
73
|
-
- Set position based on card side (front/back/both)
|
|
74
|
-
- Consider compression for large files
|
|
75
|
-
- Store returned attachment with card
|
|
76
|
-
- Handle upload failures with user feedback
|
|
77
|
-
|
|
78
|
-
### AI Content Generation for Cards
|
|
79
|
-
|
|
80
|
-
- Use for text-to-image or text-to-audio generation
|
|
81
|
-
- Validate prompts before generation
|
|
82
|
-
- Check credit/balance availability
|
|
83
|
-
- Set position based on use case (front for questions, back for answers)
|
|
84
|
-
- Handle generation failures gracefully
|
|
85
|
-
- Store successful attachments with card
|
|
86
|
-
|
|
87
|
-
### Position Management
|
|
88
|
-
|
|
89
|
-
- **Front**: Media displayed on card front side
|
|
90
|
-
- Typically contains questions or prompts
|
|
91
|
-
- Often uses text-to-image generation
|
|
92
|
-
- May require higher quality
|
|
93
|
-
|
|
94
|
-
- **Back**: Media displayed on card back side
|
|
95
|
-
- Typically contains answers or explanations
|
|
96
|
-
- Often uses text-to-audio generation
|
|
97
|
-
- Can be more compressed
|
|
98
|
-
|
|
99
|
-
- **Both**: Media used on both sides
|
|
100
|
-
- Shared content between sides
|
|
101
|
-
- Less common but supported
|
|
102
|
-
- Maintain consistency across sides
|
|
103
|
-
|
|
104
|
-
### Media Optimization for Cards
|
|
105
|
-
|
|
106
|
-
- Use when file size impacts performance
|
|
107
|
-
- Choose quality level based on position (front = higher, back = lower)
|
|
108
|
-
- Consider card importance and frequency of use
|
|
109
|
-
- Calculate expected size reduction
|
|
110
|
-
- Preserve position through optimization
|
|
111
|
-
- Update card with optimized media
|
|
112
|
-
|
|
113
|
-
### Media Deletion for Cards
|
|
114
|
-
|
|
115
|
-
- Verify media ownership before deletion
|
|
116
|
-
- Check card associations and dependencies
|
|
117
|
-
- Confirm deletion with user if needed
|
|
118
|
-
- Delete from all storage locations
|
|
119
|
-
- Update card references
|
|
120
|
-
- Handle missing files gracefully
|
|
121
|
-
|
|
122
|
-
### Batch Operations for Card Sets
|
|
123
|
-
|
|
124
|
-
- For multiple cards, use same service instance
|
|
125
|
-
- Process uploads/generations in sequence
|
|
126
|
-
- Collect results before saving
|
|
127
|
-
- Handle partial failures appropriately
|
|
128
|
-
- Consider parallel operations for independent media
|
|
129
|
-
- Track progress for user feedback
|
|
130
|
-
- Maintain position consistency across cards
|
|
131
|
-
|
|
132
|
-
### Error Handling Patterns
|
|
133
|
-
|
|
134
|
-
- **Validation Errors**: Show to user, block upload
|
|
135
|
-
- **Upload Errors**: Retry or allow alternative file
|
|
136
|
-
- **Generation Errors**: Check credits, try different prompt
|
|
137
|
-
- **Optimization Errors**: Continue with original media
|
|
138
|
-
- **Deletion Errors**: Log error, notify user
|
|
139
|
-
- **Position Errors**: Validate position before operations
|
|
140
|
-
- **Network Errors**: Show connection message, allow retry
|
|
141
|
-
|
|
142
|
-
### Card-Specific Considerations
|
|
143
|
-
|
|
144
|
-
- **Front Media**: Often focal point, prioritize quality
|
|
145
|
-
- **Back Media**: Secondary content, can be more compressed
|
|
146
|
-
- **Both Position**: Ensure quality works for both sides
|
|
147
|
-
- **Multiple Media**: Support multiple attachments per card
|
|
148
|
-
- **Position Validation**: Validate media type compatibility with position
|
|
149
|
-
- **Card Associations**: Maintain references between media and cards
|
|
150
|
-
|
|
151
|
-
### Service Coordination
|
|
152
|
-
|
|
153
|
-
The service automatically coordinates:
|
|
154
|
-
- CardMediaUploadService handles file uploads
|
|
155
|
-
- CardMediaGenerationService handles AI generation
|
|
156
|
-
- CardMediaValidationService checks file validity
|
|
157
|
-
- CardMediaOptimizerService handles compression
|
|
158
|
-
- All services work together with card-specific requirements
|
|
159
|
-
|
|
160
|
-
### Performance Considerations
|
|
161
|
-
|
|
162
|
-
- Singleton reduces memory footprint
|
|
163
|
-
- Single instance maintains state efficiently
|
|
164
|
-
- Sub-services initialized once
|
|
165
|
-
- All operations are asynchronous
|
|
166
|
-
- Consider lazy loading for large card sets
|
|
167
|
-
- Cache media URLs when possible
|
|
168
|
-
- Optimize media based on card usage patterns
|
|
169
|
-
|
|
170
|
-
## Dependencies
|
|
171
|
-
- CardMediaUploadService for upload operations
|
|
172
|
-
- CardMediaGenerationService for AI generation (including image-search)
|
|
173
|
-
- CardMediaValidationService for validation
|
|
174
|
-
- CardMediaOptimizerService for optimization
|
|
175
|
-
- CardMediaAttachment type from domain layer
|
|
176
|
-
- CardMediaPosition type for card-side placement
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Card Multimedia Flashcard Service
|
|
3
|
-
* Media attachments for flashcards - Main entry point
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
CardMediaAttachment,
|
|
8
|
-
CardMediaFile,
|
|
9
|
-
CardMediaGenerationRequest,
|
|
10
|
-
CardMediaGenerationResult,
|
|
11
|
-
CardMediaCompressionOptions,
|
|
12
|
-
CardMediaValidation,
|
|
13
|
-
CardMultimediaFlashcardService as ICardMultimediaFlashcardService,
|
|
14
|
-
} from "../../domain/entities/CardMultimedia.types";
|
|
15
|
-
import { CardMediaUploadService } from "./CardMediaUploadService";
|
|
16
|
-
import { CardMediaGenerationService } from "./CardMediaGenerationService";
|
|
17
|
-
import { CardMediaValidationService } from "./CardMediaValidationService";
|
|
18
|
-
import { CardMediaOptimizerService } from "./CardMediaOptimizerService";
|
|
19
|
-
|
|
20
|
-
export class CardMultimediaFlashcardService implements ICardMultimediaFlashcardService {
|
|
21
|
-
private static instance: CardMultimediaFlashcardService;
|
|
22
|
-
private uploadService: CardMediaUploadService;
|
|
23
|
-
private generationService: CardMediaGenerationService;
|
|
24
|
-
private validationService: CardMediaValidationService;
|
|
25
|
-
private optimizerService: CardMediaOptimizerService;
|
|
26
|
-
|
|
27
|
-
private constructor() {
|
|
28
|
-
this.uploadService = new CardMediaUploadService();
|
|
29
|
-
this.generationService = new CardMediaGenerationService();
|
|
30
|
-
this.validationService = new CardMediaValidationService();
|
|
31
|
-
this.optimizerService = new CardMediaOptimizerService();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static getInstance(): CardMultimediaFlashcardService {
|
|
35
|
-
if (!CardMultimediaFlashcardService.instance) {
|
|
36
|
-
CardMultimediaFlashcardService.instance =
|
|
37
|
-
new CardMultimediaFlashcardService();
|
|
38
|
-
}
|
|
39
|
-
return CardMultimediaFlashcardService.instance;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Upload media file with optional compression
|
|
44
|
-
*/
|
|
45
|
-
async uploadMedia(
|
|
46
|
-
file: CardMediaFile,
|
|
47
|
-
options?: CardMediaCompressionOptions,
|
|
48
|
-
): Promise<CardMediaAttachment> {
|
|
49
|
-
return this.uploadService.uploadMedia(file, options);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Generate media from AI (text-to-image, text-to-audio, etc.)
|
|
54
|
-
*/
|
|
55
|
-
async generateMedia(
|
|
56
|
-
request: CardMediaGenerationRequest,
|
|
57
|
-
): Promise<CardMediaGenerationResult> {
|
|
58
|
-
return this.generationService.generateMedia(request);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Validate media file before upload
|
|
63
|
-
*/
|
|
64
|
-
async validateMedia(file: CardMediaFile): Promise<CardMediaValidation> {
|
|
65
|
-
return this.validationService.validateMedia(file);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Optimize media file
|
|
70
|
-
*/
|
|
71
|
-
async optimizeMedia(
|
|
72
|
-
attachment: CardMediaAttachment,
|
|
73
|
-
options: CardMediaCompressionOptions,
|
|
74
|
-
): Promise<CardMediaAttachment> {
|
|
75
|
-
return this.optimizerService.optimizeMedia(attachment, options);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Delete media attachment
|
|
80
|
-
*/
|
|
81
|
-
async deleteMedia(attachmentId: string): Promise<void> {
|
|
82
|
-
return this.optimizerService.deleteMedia(attachmentId);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Get media URL
|
|
87
|
-
*/
|
|
88
|
-
async getMediaUrl(attachmentId: string): Promise<string> {
|
|
89
|
-
return this.uploadService.getMediaUrl(attachmentId);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Download media to local storage
|
|
94
|
-
*/
|
|
95
|
-
async downloadMedia(attachmentId: string): Promise<string> {
|
|
96
|
-
return this.uploadService.downloadMedia(attachmentId);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# MediaGenerationService
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Provides AI-powered media generation capabilities including text-to-image and text-to-audio generation with credit/balance management.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/MediaGenerationService`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
|
|
11
|
-
### Core Purpose
|
|
12
|
-
- Generate images from text descriptions (text-to-image)
|
|
13
|
-
- Generate audio from text (text-to-audio)
|
|
14
|
-
- Support multiple result generation
|
|
15
|
-
- Track processing time and performance
|
|
16
|
-
- Manage generation costs/credits
|
|
17
|
-
|
|
18
|
-
### Usage Scenarios
|
|
19
|
-
- AI-generated visual content for cards
|
|
20
|
-
- Text-to-speech conversion
|
|
21
|
-
- Creative content generation
|
|
22
|
-
- Localization and voice-over creation
|
|
23
|
-
- Dynamic asset generation
|
|
24
|
-
|
|
25
|
-
### Integration Points
|
|
26
|
-
- AI-powered content creation workflows
|
|
27
|
-
- Text-to-speech features
|
|
28
|
-
- Automated asset generation
|
|
29
|
-
- Creative assistance tools
|
|
30
|
-
- Educational content generation
|
|
31
|
-
|
|
32
|
-
## Forbidden
|
|
33
|
-
|
|
34
|
-
### MUST NOT
|
|
35
|
-
- Generate without sufficient credits/balance
|
|
36
|
-
- Assume generation always succeeds
|
|
37
|
-
- Generate inappropriate or harmful content
|
|
38
|
-
- Ignore rate limiting or API constraints
|
|
39
|
-
- Cache generated content without validation
|
|
40
|
-
- Generate without user prompt input
|
|
41
|
-
|
|
42
|
-
### MUST NEVER
|
|
43
|
-
- Expose API keys or credentials
|
|
44
|
-
- Allow unlimited free generation
|
|
45
|
-
- Ignore generation failures
|
|
46
|
-
- Bypass credit/balance checks
|
|
47
|
-
- Generate without proper error handling
|
|
48
|
-
- Assume instant generation results
|
|
49
|
-
|
|
50
|
-
## Rules
|
|
51
|
-
|
|
52
|
-
### Generation Operations
|
|
53
|
-
- MUST validate prompt before generation
|
|
54
|
-
- MUST check sufficient credits/balance
|
|
55
|
-
- MUST handle generation failures
|
|
56
|
-
- MUST track processing time
|
|
57
|
-
- MUST return unique request ID
|
|
58
|
-
- MUST respect result limits (maxResults)
|
|
59
|
-
|
|
60
|
-
### Text-to-Image Generation
|
|
61
|
-
- MUST support style options
|
|
62
|
-
- MUST support aspect ratio options
|
|
63
|
-
- MUST generate multiple results if requested
|
|
64
|
-
- MUST validate image generation parameters
|
|
65
|
-
- MUST handle generation timeouts
|
|
66
|
-
|
|
67
|
-
### Text-to-Audio Generation
|
|
68
|
-
- MUST support voice options
|
|
69
|
-
- MUST support language selection
|
|
70
|
-
- MUST support speed adjustment
|
|
71
|
-
- MUST return audio duration
|
|
72
|
-
- MUST validate audio parameters
|
|
73
|
-
|
|
74
|
-
### Credit Management
|
|
75
|
-
- MUST deduct credits per generation
|
|
76
|
-
- MUST track credit usage in results
|
|
77
|
-
- MUST validate credit availability
|
|
78
|
-
- MUST prevent generation with insufficient credits
|
|
79
|
-
- MUST report credits used in result
|
|
80
|
-
|
|
81
|
-
### Return Values
|
|
82
|
-
- MUST include success status
|
|
83
|
-
- MUST include generated media attachments
|
|
84
|
-
- MUST include credits used
|
|
85
|
-
- MUST include processing time
|
|
86
|
-
- MUST include unique request ID
|
|
87
|
-
- MUST include error details on failure
|
|
88
|
-
|
|
89
|
-
### Error Handling
|
|
90
|
-
- MUST handle insufficient credits
|
|
91
|
-
- MUST handle generation timeouts
|
|
92
|
-
- MUST handle invalid prompts
|
|
93
|
-
- MUST handle API failures
|
|
94
|
-
- MUST provide meaningful error messages
|
|
95
|
-
- MUST allow retry after appropriate delay
|
|
96
|
-
|
|
97
|
-
## AI Agent Guidelines
|
|
98
|
-
|
|
99
|
-
### When Implementing Generation Features
|
|
100
|
-
1. Always validate prompt input
|
|
101
|
-
2. Check credit/balance before generation
|
|
102
|
-
3. Set appropriate timeouts
|
|
103
|
-
4. Handle both success and failure cases
|
|
104
|
-
5. Track and report processing metrics
|
|
105
|
-
|
|
106
|
-
### When Working with Text-to-Image
|
|
107
|
-
- Support common aspect ratios (16:9, 4:3, 1:1)
|
|
108
|
-
- Provide style presets (realistic, artistic, etc.)
|
|
109
|
-
- Limit max results to reasonable number
|
|
110
|
-
- Validate image generation parameters
|
|
111
|
-
|
|
112
|
-
### When Working with Text-to-Audio
|
|
113
|
-
- Support common languages
|
|
114
|
-
- Provide voice options (male, female)
|
|
115
|
-
- Allow speed adjustment (0.5-2.0)
|
|
116
|
-
- Return accurate duration
|
|
117
|
-
|
|
118
|
-
### When Adding Features
|
|
119
|
-
- Add new generation types with validation
|
|
120
|
-
- Extend options without breaking compatibility
|
|
121
|
-
- Add new credit tiers carefully
|
|
122
|
-
- Support batch generation if needed
|
|
123
|
-
- Add content filtering if required
|
|
124
|
-
|
|
125
|
-
### When Refactoring
|
|
126
|
-
- Keep generation API stable
|
|
127
|
-
- Preserve credit calculation logic
|
|
128
|
-
- Maintain request ID generation
|
|
129
|
-
- Don't change result structure
|
|
130
|
-
- Add deprecation warnings for breaking changes
|
|
131
|
-
|
|
132
|
-
### Common Patterns to Follow
|
|
133
|
-
- Validate prompt -> Check credits -> Generate -> Return result
|
|
134
|
-
- Handle timeout -> Retry if appropriate -> Return error
|
|
135
|
-
- Calculate credits -> Deduct -> Track usage
|
|
136
|
-
- Always wrap in try-catch for unexpected errors
|
|
137
|
-
- Provide user feedback for generation status
|
|
138
|
-
|
|
139
|
-
## Dependencies
|
|
140
|
-
|
|
141
|
-
- Domain types: MediaAttachment, MediaGenerationRequest, MediaGenerationResult, MediaType, MediaPosition from MultimediaFlashcardTypes
|
|
142
|
-
- No external library dependencies (uses native APIs)
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
# MediaOptimizerService
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Optimizes and compresses media files to reduce file size while maintaining acceptable quality, and manages media deletion operations.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/MediaOptimizerService`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
|
|
11
|
-
### Core Purpose
|
|
12
|
-
- Reduce media file size through compression
|
|
13
|
-
- Maintain acceptable quality after optimization
|
|
14
|
-
- Support quality and dimension constraints
|
|
15
|
-
- Delete media from server and local storage
|
|
16
|
-
- Generate optimized versions of existing media
|
|
17
|
-
|
|
18
|
-
### Usage Scenarios
|
|
19
|
-
- Pre-upload optimization
|
|
20
|
-
- Storage cost reduction
|
|
21
|
-
- Performance improvement
|
|
22
|
-
- Bandwidth optimization
|
|
23
|
-
- Media cleanup workflows
|
|
24
|
-
|
|
25
|
-
### Integration Points
|
|
26
|
-
- After upload, before storage
|
|
27
|
-
- In media management workflows
|
|
28
|
-
- Storage optimization processes
|
|
29
|
-
- Media cleanup routines
|
|
30
|
-
- Performance tuning operations
|
|
31
|
-
|
|
32
|
-
## Forbidden
|
|
33
|
-
|
|
34
|
-
### MUST NOT
|
|
35
|
-
- Optimize media beyond usable quality
|
|
36
|
-
- Delete media without proper authorization
|
|
37
|
-
- Assume optimization always succeeds
|
|
38
|
-
- Modify original media files
|
|
39
|
-
- Ignore quality settings
|
|
40
|
-
- Delete without confirmation in critical workflows
|
|
41
|
-
|
|
42
|
-
### MUST NEVER
|
|
43
|
-
- Optimize already optimized media repeatedly
|
|
44
|
-
- Use quality below 0.3 without explicit request
|
|
45
|
-
- Delete media without backup when required
|
|
46
|
-
- Assume optimization is lossless
|
|
47
|
-
- Ignore file size after optimization
|
|
48
|
-
- Return different media ID after optimization
|
|
49
|
-
|
|
50
|
-
## Rules
|
|
51
|
-
|
|
52
|
-
### Optimization Operations
|
|
53
|
-
- MUST accept media attachment and options
|
|
54
|
-
- MUST preserve original media (create new version)
|
|
55
|
-
- MUST return optimized media attachment
|
|
56
|
-
- MUST maintain same media ID
|
|
57
|
-
- MUST update file size accurately
|
|
58
|
-
- MUST add optimization indicator to URL
|
|
59
|
-
|
|
60
|
-
### Compression Options
|
|
61
|
-
- MUST support quality adjustment (0-1)
|
|
62
|
-
- MUST support max width constraint
|
|
63
|
-
- MUST support max height constraint
|
|
64
|
-
- MUST support format conversion
|
|
65
|
-
- MUST validate compression parameters
|
|
66
|
-
- MUST respect quality vs size tradeoff
|
|
67
|
-
|
|
68
|
-
### Quality Levels
|
|
69
|
-
- High quality (0.9-1.0): 10-20% size reduction
|
|
70
|
-
- Medium quality (0.7-0.8): 30-50% size reduction
|
|
71
|
-
- Low quality (0.5-0.6): 50-70% size reduction
|
|
72
|
-
- Preview quality (0.3-0.4): 70-80% size reduction
|
|
73
|
-
- MUST document quality tradeoffs
|
|
74
|
-
|
|
75
|
-
### Deletion Operations
|
|
76
|
-
- MUST accept media ID for deletion
|
|
77
|
-
- MUST delete from both server and local storage
|
|
78
|
-
- MUST handle non-existent media gracefully
|
|
79
|
-
- MUST confirm deletion success
|
|
80
|
-
- MUST be permanent and irreversible
|
|
81
|
-
|
|
82
|
-
### Return Values
|
|
83
|
-
- MUST preserve original media ID
|
|
84
|
-
- MUST preserve media type
|
|
85
|
-
- MUST update file size
|
|
86
|
-
- MUST preserve MIME type
|
|
87
|
-
- MUST preserve creation date
|
|
88
|
-
- MUST update URL with optimization indicator
|
|
89
|
-
|
|
90
|
-
### Error Handling
|
|
91
|
-
- MUST handle optimization failures
|
|
92
|
-
- MUST handle deletion failures
|
|
93
|
-
- MUST handle invalid media IDs
|
|
94
|
-
- MUST handle invalid compression options
|
|
95
|
-
- MUST provide meaningful error messages
|
|
96
|
-
- MUST allow retry on transient failures
|
|
97
|
-
|
|
98
|
-
## AI Agent Guidelines
|
|
99
|
-
|
|
100
|
-
### When Implementing Optimization
|
|
101
|
-
1. Always validate compression options
|
|
102
|
-
2. Calculate expected file size reduction
|
|
103
|
-
3. Apply compression with specified quality
|
|
104
|
-
4. Update metadata accurately
|
|
105
|
-
5. Return optimized version with same ID
|
|
106
|
-
|
|
107
|
-
### When Working with Quality Settings
|
|
108
|
-
- Use 0.7-0.8 for general use (recommended)
|
|
109
|
-
- Use 0.9-1.0 for high-quality requirements
|
|
110
|
-
- Use 0.5-0.6 for previews and thumbnails
|
|
111
|
-
- Avoid quality below 0.3 unless specifically needed
|
|
112
|
-
- Consider content type when setting quality
|
|
113
|
-
|
|
114
|
-
### When Performing Deletion
|
|
115
|
-
- Confirm media ID exists before deletion
|
|
116
|
-
- Handle deletion from both storage locations
|
|
117
|
-
- Provide confirmation in critical workflows
|
|
118
|
-
- Log deletion operations for audit
|
|
119
|
-
- Handle non-existent media gracefully
|
|
120
|
-
|
|
121
|
-
### When Adding Features
|
|
122
|
-
- Add new compression formats carefully
|
|
123
|
-
- Support new dimension constraints
|
|
124
|
-
- Add batch optimization if needed
|
|
125
|
-
- Maintain backward compatibility
|
|
126
|
-
- Add optimization presets for common cases
|
|
127
|
-
|
|
128
|
-
### When Refactoring
|
|
129
|
-
- Keep optimization API stable
|
|
130
|
-
- Preserve ID generation logic
|
|
131
|
-
- Maintain URL structure
|
|
132
|
-
- Don't change return value structure
|
|
133
|
-
- Add deprecation warnings for breaking changes
|
|
134
|
-
|
|
135
|
-
### Common Patterns to Follow
|
|
136
|
-
- Receive attachment -> Validate options -> Optimize -> Return optimized
|
|
137
|
-
- Calculate size -> Apply quality -> Update metadata -> Return
|
|
138
|
-
- Receive ID -> Validate -> Delete -> Confirm
|
|
139
|
-
- Always wrap in try-catch for unexpected errors
|
|
140
|
-
- Provide user feedback for optimization progress
|
|
141
|
-
|
|
142
|
-
## Dependencies
|
|
143
|
-
|
|
144
|
-
- Domain types: MediaAttachment, MediaCompressionOptions from MultimediaFlashcardTypes
|
|
145
|
-
- No external library dependencies (uses native APIs)
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# MediaPickerService
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Provides image and video selection functionality from device camera and gallery, including permission management and media type filtering.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/MediaPickerService`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
|
|
11
|
-
### Core Purpose
|
|
12
|
-
- Enable users to select media from device gallery or capture using camera
|
|
13
|
-
- Support single and multiple media selection
|
|
14
|
-
- Handle platform-specific permission requirements
|
|
15
|
-
- Provide customizable selection options
|
|
16
|
-
|
|
17
|
-
### Usage Scenarios
|
|
18
|
-
- User profile picture selection
|
|
19
|
-
- Content creation workflows
|
|
20
|
-
- Multi-image selection for galleries
|
|
21
|
-
- Video recording for user-generated content
|
|
22
|
-
- Mixed media selection (images and videos)
|
|
23
|
-
|
|
24
|
-
### Integration Points
|
|
25
|
-
- Forms requiring media attachments
|
|
26
|
-
- Content management systems
|
|
27
|
-
- Social media features
|
|
28
|
-
- Document upload workflows
|
|
29
|
-
|
|
30
|
-
## Forbidden
|
|
31
|
-
|
|
32
|
-
### MUST NOT
|
|
33
|
-
- Bypass permission checks or force camera/gallery access
|
|
34
|
-
- Assume permissions are always granted
|
|
35
|
-
- Hardcode file paths or URIs
|
|
36
|
-
- Access media without explicit user action
|
|
37
|
-
- Automatically launch camera without user consent
|
|
38
|
-
- Store selected media URIs in permanent storage without validation
|
|
39
|
-
|
|
40
|
-
### MUST NEVER
|
|
41
|
-
- Allow infinite selection limits without boundaries
|
|
42
|
-
- Use base64 conversion by default (performance impact)
|
|
43
|
-
- Assume all devices support the same media types
|
|
44
|
-
- Ignore permission denial states
|
|
45
|
-
- Access camera roll without proper permissions
|
|
46
|
-
|
|
47
|
-
## Rules
|
|
48
|
-
|
|
49
|
-
### Permission Management
|
|
50
|
-
- MUST request camera permission before launching camera
|
|
51
|
-
- MUST request media library permission before accessing gallery
|
|
52
|
-
- MUST handle permission denial gracefully
|
|
53
|
-
- MUST check permission status before operations
|
|
54
|
-
- MUST provide clear error messages when permissions are denied
|
|
55
|
-
|
|
56
|
-
### Media Selection
|
|
57
|
-
- MUST respect selection limits
|
|
58
|
-
- MUST validate selected media before processing
|
|
59
|
-
- MUST handle user cancellation (canceled: true)
|
|
60
|
-
- MUST support both single and multiple selection modes
|
|
61
|
-
- MUST filter media types appropriately
|
|
62
|
-
|
|
63
|
-
### Platform Considerations
|
|
64
|
-
- MUST handle iOS and Android permission differences
|
|
65
|
-
- MUST account for platform-specific media type restrictions
|
|
66
|
-
- MUST test on both platforms for compatibility
|
|
67
|
-
- MUST handle aspect ratio options correctly (only works with allowsEditing: true)
|
|
68
|
-
|
|
69
|
-
### Performance
|
|
70
|
-
- MUST avoid base64 conversion unless explicitly required
|
|
71
|
-
- MUST set reasonable quality defaults
|
|
72
|
-
- MUST handle large media files appropriately
|
|
73
|
-
- MUST provide loading states during selection
|
|
74
|
-
|
|
75
|
-
## AI Agent Guidelines
|
|
76
|
-
|
|
77
|
-
### When Implementing Media Selection
|
|
78
|
-
1. Always check permissions before launching picker
|
|
79
|
-
2. Handle both success (canceled: false) and cancellation (canceled: true)
|
|
80
|
-
3. Validate returned assets array exists and has items
|
|
81
|
-
4. Consider media type (image vs video) for different handling
|
|
82
|
-
5. Use appropriate quality settings based on use case
|
|
83
|
-
|
|
84
|
-
### When Adding Features
|
|
85
|
-
- Add new permission types only if required by new functionality
|
|
86
|
-
- Extend options interface without breaking existing functionality
|
|
87
|
-
- Maintain backward compatibility with existing selection methods
|
|
88
|
-
- Add error handling for new edge cases
|
|
89
|
-
|
|
90
|
-
### When Refactoring
|
|
91
|
-
- Keep public API stable
|
|
92
|
-
- Preserve permission handling logic
|
|
93
|
-
- Maintain platform-specific behavior differences
|
|
94
|
-
- Don't remove existing selection methods without deprecation
|
|
95
|
-
|
|
96
|
-
### Common Patterns to Follow
|
|
97
|
-
- Request permission -> Check status -> Launch picker
|
|
98
|
-
- Handle result -> Validate -> Return or process
|
|
99
|
-
- Always wrap in try-catch for unexpected errors
|
|
100
|
-
- Provide user feedback for permission states
|
|
101
|
-
|
|
102
|
-
## Dependencies
|
|
103
|
-
|
|
104
|
-
- Domain types: MediaPickerOptions, MediaPickerResult, CameraOptions, MediaType, MediaLibraryPermission, MEDIA_CONSTANTS from Media
|
|
105
|
-
- External libraries: expo-image-picker
|
|
106
|
-
- Internal utilities: mediaPickerMappers (mapMediaType, mapPermissionStatus, mapPickerResult)
|