@umituz/react-native-design-system 4.23.97 → 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/atoms/button/AtomicButton.tsx +7 -0
- package/src/atoms/button/types/index.ts +4 -0
- package/src/atoms/input/hooks/useInputState.ts +3 -7
- package/src/haptics/infrastructure/services/HapticService.ts +1 -1
- package/src/media/domain/entities/{MultimediaFlashcardTypes.ts → MediaAttachments.ts} +13 -32
- package/src/media/index.ts +24 -23
- package/src/media/{presentation/hooks/useCardMediaGeneration.ts → infrastructure/hooks/useGenericMediaGeneration.ts} +77 -31
- 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 +5 -88
- 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/components/NavigationHeader.tsx +3 -3
- package/src/molecules/navigation/utils/AppNavigation.ts +3 -3
- package/src/offline/index.ts +1 -0
- package/src/offline/infrastructure/storage/OfflineConfigStore.ts +34 -0
- package/src/offline/presentation/hooks/useOffline.ts +8 -4
- package/src/storage/domain/utils/devUtils.ts +0 -24
- package/src/storage/index.ts +1 -1
- package/src/storage/infrastructure/adapters/StorageService.ts +5 -10
- package/src/storage/infrastructure/repositories/BaseStorageOperations.ts +5 -8
- package/src/storage/presentation/hooks/CacheStorageOperations.ts +5 -11
- package/src/storage/presentation/hooks/useStore.ts +13 -5
- package/src/utilities/sharing/presentation/hooks/useSharing.ts +3 -3
- package/src/layouts/ScreenLayout/ScreenLayout.example.tsx +0 -92
- package/src/media/domain/entities/CardMultimedia.types.README.md +0 -129
- package/src/media/domain/entities/CardMultimedia.types.ts +0 -120
- 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/CardMediaGenerationService.README.md +0 -99
- package/src/media/infrastructure/services/CardMediaGenerationService.ts +0 -101
- package/src/media/infrastructure/services/CardMediaOptimizerService.README.md +0 -167
- package/src/media/infrastructure/services/CardMediaOptimizerService.ts +0 -36
- package/src/media/infrastructure/services/CardMediaUploadService.README.md +0 -123
- package/src/media/infrastructure/services/CardMediaUploadService.ts +0 -62
- package/src/media/infrastructure/services/CardMediaValidationService.README.md +0 -134
- package/src/media/infrastructure/services/CardMediaValidationService.ts +0 -81
- 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.README.md +0 -164
- package/src/media/presentation/hooks/useCardMediaUpload.README.md +0 -153
- package/src/media/presentation/hooks/useCardMediaUpload.ts +0 -84
- package/src/media/presentation/hooks/useCardMediaValidation.README.md +0 -176
- package/src/media/presentation/hooks/useCardMediaValidation.ts +0 -101
- 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
- package/src/storage/domain/utils/__tests__/devUtils.test.ts +0 -97
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
# MediaValidationService
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Validates media files before upload by checking file size, type, and other properties to ensure compatibility and performance.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/MediaValidationService`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
|
|
11
|
-
### Core Purpose
|
|
12
|
-
- Validate media files before upload
|
|
13
|
-
- Check file size constraints
|
|
14
|
-
- Verify supported file types
|
|
15
|
-
- Provide actionable feedback (errors, warnings, recommendations)
|
|
16
|
-
- Prevent upload of invalid or problematic files
|
|
17
|
-
|
|
18
|
-
### Usage Scenarios
|
|
19
|
-
- Pre-upload validation checks
|
|
20
|
-
- Form submission workflows
|
|
21
|
-
- File selection validation
|
|
22
|
-
- User feedback on file issues
|
|
23
|
-
- Quality control processes
|
|
24
|
-
|
|
25
|
-
### Integration Points
|
|
26
|
-
- Before upload operations
|
|
27
|
-
- After file selection
|
|
28
|
-
- In form validation workflows
|
|
29
|
-
- User input feedback loops
|
|
30
|
-
- File processing pipelines
|
|
31
|
-
|
|
32
|
-
## Forbidden
|
|
33
|
-
|
|
34
|
-
### MUST NOT
|
|
35
|
-
- Allow uploads of files exceeding size limits
|
|
36
|
-
- Accept unsupported file types
|
|
37
|
-
- Ignore validation results
|
|
38
|
-
- Proceed with upload when isValid is false
|
|
39
|
-
- Assume all files are valid
|
|
40
|
-
- Skip validation for performance
|
|
41
|
-
|
|
42
|
-
### MUST NEVER
|
|
43
|
-
- Upload files with errors
|
|
44
|
-
- Modify files during validation
|
|
45
|
-
- Cache validation results indefinitely
|
|
46
|
-
- Assume synchronous validation
|
|
47
|
-
- Ignore platform-specific constraints
|
|
48
|
-
- Allow bypass of critical validation rules
|
|
49
|
-
|
|
50
|
-
## Rules
|
|
51
|
-
|
|
52
|
-
### Validation Rules
|
|
53
|
-
- MUST check file size (max 50 MB)
|
|
54
|
-
- MUST check file type against supported formats
|
|
55
|
-
- MUST return validation result with isValid boolean
|
|
56
|
-
- MUST provide errors for upload-blocking issues
|
|
57
|
-
- MUST provide warnings for performance concerns
|
|
58
|
-
- MUST provide recommendations for improvements
|
|
59
|
-
|
|
60
|
-
### File Size Limits
|
|
61
|
-
- MUST reject files over 50 MB (error)
|
|
62
|
-
- MUST warn on files over 10 MB
|
|
63
|
-
- MUST recommend compression for large files
|
|
64
|
-
- MUST format file sizes for readability
|
|
65
|
-
- MUST consider media type for limits
|
|
66
|
-
|
|
67
|
-
### Supported File Types
|
|
68
|
-
- Images: JPEG, PNG, WebP
|
|
69
|
-
- Audio: MP3, WAV, M4A
|
|
70
|
-
- Video: MP4, MOV
|
|
71
|
-
- MUST validate MIME types
|
|
72
|
-
- MUST reject unsupported types with clear error
|
|
73
|
-
|
|
74
|
-
### Validation Results
|
|
75
|
-
- MUST include isValid boolean
|
|
76
|
-
- MUST include errors array (upload blockers)
|
|
77
|
-
- MUST include warnings array (performance impacts)
|
|
78
|
-
- MUST include recommendations array (improvements)
|
|
79
|
-
- MUST be serializable for transport
|
|
80
|
-
|
|
81
|
-
### Error Handling
|
|
82
|
-
- MUST handle missing file metadata
|
|
83
|
-
- MUST handle invalid file structures
|
|
84
|
-
- MUST handle async validation operations
|
|
85
|
-
- MUST provide specific error messages
|
|
86
|
-
- MUST support batch validation
|
|
87
|
-
|
|
88
|
-
### Feedback Levels
|
|
89
|
-
- Errors: Critical issues that prevent upload
|
|
90
|
-
- Warnings: Non-critical but impactful issues
|
|
91
|
-
- Recommendations: Suggestions for optimization
|
|
92
|
-
- MUST clearly distinguish between levels
|
|
93
|
-
|
|
94
|
-
## AI Agent Guidelines
|
|
95
|
-
|
|
96
|
-
### When Implementing Validation
|
|
97
|
-
1. Always check file metadata completeness
|
|
98
|
-
2. Validate size limits before processing
|
|
99
|
-
3. Check MIME type against allowed list
|
|
100
|
-
4. Provide specific, actionable error messages
|
|
101
|
-
5. Return structured validation result
|
|
102
|
-
|
|
103
|
-
### When Working with Validation Results
|
|
104
|
-
- Check isValid flag before proceeding
|
|
105
|
-
- Display errors to user (block upload)
|
|
106
|
-
- Show warnings to user (allow upload)
|
|
107
|
-
- Present recommendations as optional
|
|
108
|
-
- Format messages for user understanding
|
|
109
|
-
|
|
110
|
-
### When Adding Validation Rules
|
|
111
|
-
- Add new size limits with clear thresholds
|
|
112
|
-
- Add new file types with MIME validation
|
|
113
|
-
- Add custom rules for specific use cases
|
|
114
|
-
- Maintain backward compatibility
|
|
115
|
-
- Document rule changes
|
|
116
|
-
|
|
117
|
-
### When Refactoring
|
|
118
|
-
- Keep validation API stable
|
|
119
|
-
- Preserve error message format
|
|
120
|
-
- Maintain validation logic flow
|
|
121
|
-
- Don't change result structure
|
|
122
|
-
- Add deprecation warnings for breaking changes
|
|
123
|
-
|
|
124
|
-
### Common Patterns to Follow
|
|
125
|
-
- Receive file -> Check metadata -> Validate rules -> Return result
|
|
126
|
-
- Check isValid -> If false, show errors -> If true, proceed
|
|
127
|
-
- Check size -> If large, warn and recommend compression
|
|
128
|
-
- Check type -> If invalid, error with supported types
|
|
129
|
-
- Always handle async validation properly
|
|
130
|
-
|
|
131
|
-
## Dependencies
|
|
132
|
-
|
|
133
|
-
- Domain types: MediaValidation from MultimediaFlashcardTypes
|
|
134
|
-
- Internal utilities: mediaHelpers (formatFileSize)
|
|
135
|
-
- No external library dependencies (uses native File API)
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# MultimediaFlashcardService
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Main service that manages all media operations for media-enabled flashcards from a single point, combining upload, generation, validation, and optimization capabilities through a singleton instance.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/MultimediaFlashcardService`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide unified interface for all flashcard media operations
|
|
11
|
-
- Coordinate upload, generation, validation, and optimization services
|
|
12
|
-
- Maintain singleton pattern for resource efficiency
|
|
13
|
-
- Simplify media management for flashcard applications
|
|
14
|
-
- Support general flashcard media requirements
|
|
15
|
-
- Enable batch operations for card sets
|
|
16
|
-
- Provide consistent API across all media operations
|
|
17
|
-
- Reduce complexity by exposing single service instance
|
|
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 flashcard media with other media types
|
|
27
|
-
- **DO NOT** assume all operations will succeed
|
|
28
|
-
|
|
29
|
-
## Rules
|
|
30
|
-
1. MUST use getInstance() to retrieve service instance
|
|
31
|
-
2. MUST NOT create new instances with constructor
|
|
32
|
-
3. MUST maintain single instance across application lifecycle
|
|
33
|
-
4. MUST validate media before upload operations
|
|
34
|
-
5. MUST handle all operation failures gracefully
|
|
35
|
-
6. MUST support MediaAttachment and MediaPosition types
|
|
36
|
-
7. MUST provide consistent interface through all methods
|
|
37
|
-
8. MUST initialize all sub-services on first use
|
|
38
|
-
9. MUST coordinate between sub-services for complex operations
|
|
39
|
-
10. MUST handle asynchronous operations properly
|
|
40
|
-
11. MUST return appropriate error messages for failures
|
|
41
|
-
|
|
42
|
-
## AI Agent Guidelines
|
|
43
|
-
|
|
44
|
-
When working with MultimediaFlashcardService:
|
|
45
|
-
|
|
46
|
-
1. **Singleton Pattern**: Always use getInstance(), never constructor
|
|
47
|
-
2. **Validation First**: Validate before upload or generation
|
|
48
|
-
3. **Operation Flow**: Follow validate -> upload/generate -> optimize -> store
|
|
49
|
-
4. **Error Handling**: Handle errors at each step appropriately
|
|
50
|
-
5. **Resource Management**: Rely on singleton for efficient resource use
|
|
51
|
-
6. **Type Safety**: Use MediaAttachment and MediaPosition types
|
|
52
|
-
7. **Service Coordination**: Let service coordinate sub-operations
|
|
53
|
-
|
|
54
|
-
### Flashcard Creation Workflow
|
|
55
|
-
|
|
56
|
-
- **Step 1 - Get Instance**: `MultimediaFlashcardService.getInstance()`
|
|
57
|
-
- **Step 2 - Select File**: Pick file from device or camera
|
|
58
|
-
- **Step 3 - Validate**: Run validation, check results
|
|
59
|
-
- **Step 4 - Upload**: Upload if validation passes
|
|
60
|
-
- **Step 5 - Optimize** (Optional): Optimize if file is large
|
|
61
|
-
- **Step 6 - Store**: Save attachment with flashcard data
|
|
62
|
-
- **Step 7 - Handle Errors**: Provide feedback at each step
|
|
63
|
-
|
|
64
|
-
### Media Upload Workflow
|
|
65
|
-
|
|
66
|
-
- Use for user-selected media (images, audio, video)
|
|
67
|
-
- Always validate before uploading
|
|
68
|
-
- Consider compression for large files
|
|
69
|
-
- Set appropriate position if applicable
|
|
70
|
-
- Store returned attachment with flashcard
|
|
71
|
-
- Handle upload failures with user feedback
|
|
72
|
-
|
|
73
|
-
### AI Content Generation Workflow
|
|
74
|
-
|
|
75
|
-
- Use for text-to-image or text-to-audio generation
|
|
76
|
-
- Validate prompts before generation
|
|
77
|
-
- Check credit/balance availability
|
|
78
|
-
- Set appropriate options (language, voice, style)
|
|
79
|
-
- Handle generation failures gracefully
|
|
80
|
-
- Store successful attachments with flashcard
|
|
81
|
-
|
|
82
|
-
### Media Optimization Workflow
|
|
83
|
-
|
|
84
|
-
- Use when file size impacts performance
|
|
85
|
-
- Choose quality level based on use case
|
|
86
|
-
- Consider flashcard importance (front/back)
|
|
87
|
-
- Calculate expected size reduction
|
|
88
|
-
- Preserve attachments through optimization
|
|
89
|
-
- Update flashcard with optimized media
|
|
90
|
-
|
|
91
|
-
### Media Deletion Workflow
|
|
92
|
-
|
|
93
|
-
- Verify media ownership before deletion
|
|
94
|
-
- Check flashcard associations
|
|
95
|
-
- Confirm deletion with user if needed
|
|
96
|
-
- Delete from all storage locations
|
|
97
|
-
- Update flashcard references
|
|
98
|
-
- Handle missing files gracefully
|
|
99
|
-
|
|
100
|
-
### Batch Operations
|
|
101
|
-
|
|
102
|
-
- For multiple flashcards, use same service instance
|
|
103
|
-
- Process uploads/generations in sequence
|
|
104
|
-
- Collect results before saving
|
|
105
|
-
- Handle partial failures appropriately
|
|
106
|
-
- Consider parallel operations for independent media
|
|
107
|
-
- Track progress for user feedback
|
|
108
|
-
|
|
109
|
-
### Error Handling Patterns
|
|
110
|
-
|
|
111
|
-
- **Validation Errors**: Show to user, block upload
|
|
112
|
-
- **Upload Errors**: Retry or allow alternative file
|
|
113
|
-
- **Generation Errors**: Check credits, try different prompt
|
|
114
|
-
- **Optimization Errors**: Continue with original media
|
|
115
|
-
- **Deletion Errors**: Log error, notify user
|
|
116
|
-
- **Network Errors**: Show connection message, allow retry
|
|
117
|
-
|
|
118
|
-
### Service Coordination
|
|
119
|
-
|
|
120
|
-
The service automatically coordinates:
|
|
121
|
-
- UploadService handles file uploads
|
|
122
|
-
- GenerationService handles AI generation
|
|
123
|
-
- ValidationService checks file validity
|
|
124
|
-
- OptimizerService handles compression
|
|
125
|
-
- All services work together seamlessly
|
|
126
|
-
|
|
127
|
-
### Performance Considerations
|
|
128
|
-
|
|
129
|
-
- Singleton reduces memory footprint
|
|
130
|
-
- Single instance maintains state efficiently
|
|
131
|
-
- Sub-services initialized once
|
|
132
|
-
- All operations are asynchronous
|
|
133
|
-
- Consider lazy loading for large card sets
|
|
134
|
-
- Cache media URLs when possible
|
|
135
|
-
|
|
136
|
-
## Dependencies
|
|
137
|
-
- MediaUploadService for upload operations
|
|
138
|
-
- MediaGenerationService for AI generation
|
|
139
|
-
- MediaValidationService for validation
|
|
140
|
-
- MediaOptimizerService for optimization
|
|
141
|
-
- MediaAttachment type from domain layer
|
|
142
|
-
- MediaPosition type for media placement
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Media Helper Utilities
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Core utility functions for media type detection, duration calculation, thumbnail generation, and file size operations.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/infrastructure/utils/mediaHelpers.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Provide pure utility functions for common media operations
|
|
11
|
-
- Enable media type classification from MIME types
|
|
12
|
-
- Support file size calculations and formatting
|
|
13
|
-
- Generate thumbnails for video files
|
|
14
|
-
- Extract metadata from media collections
|
|
15
|
-
- Maintain framework-agnostic approach where possible
|
|
16
|
-
|
|
17
|
-
## Forbidden
|
|
18
|
-
- **DO NOT** add business logic to utility functions
|
|
19
|
-
- **DO NOT** make network calls or API requests
|
|
20
|
-
- **DO NOT** modify input parameters (pure functions)
|
|
21
|
-
- **DO NOT** store state or cache results globally
|
|
22
|
-
- **DO NOT** depend on React or UI frameworks
|
|
23
|
-
- **DO NOT** throw exceptions without clear error messages
|
|
24
|
-
- **DO NOT** use locale-specific string formatting
|
|
25
|
-
|
|
26
|
-
## Rules
|
|
27
|
-
1. All functions must be pure (same input = same output)
|
|
28
|
-
2. File size calculations must use bytes as the base unit
|
|
29
|
-
3. Media type detection must use MIME type patterns
|
|
30
|
-
4. Duration calculation must return seconds (or undefined for non-audio/video)
|
|
31
|
-
5. Thumbnail generation must only return URLs for video files
|
|
32
|
-
6. Type extraction must remove duplicates and preserve order
|
|
33
|
-
7. Size formatting must use appropriate units (Bytes/KB/MB/GB)
|
|
34
|
-
8. All functions must handle edge cases (empty arrays, null values)
|
|
35
|
-
9. Must support both CardMediaAttachment and MediaAttachment types
|
|
36
|
-
10. Must return fallback values for invalid inputs
|
|
37
|
-
|
|
38
|
-
## AI Agent Guidelines
|
|
39
|
-
|
|
40
|
-
When working with media helper utilities:
|
|
41
|
-
|
|
42
|
-
1. **Type Detection**: Always use `getCardMediaType()` for consistent type classification from MIME types
|
|
43
|
-
2. **Size Calculations**: Use `calculateTotalSize()` for aggregating file sizes, never sum manually
|
|
44
|
-
3. **Duration Handling**: Check for undefined return value from `getMediaDuration()` for non-audio/video files
|
|
45
|
-
4. **Thumbnail Generation**: Only videos return thumbnail URLs; images return undefined
|
|
46
|
-
5. **Type Extraction**: Use `extractMediaTypes()` to get unique media types from collections
|
|
47
|
-
6. **Size Formatting**: Always use `formatFileSize()` for user-facing size displays
|
|
48
|
-
7. **Null Safety**: Always handle null/undefined returns appropriately
|
|
49
|
-
8. **Collection Operations**: Use provided utilities instead of manual array operations
|
|
50
|
-
|
|
51
|
-
### Media Type Classification
|
|
52
|
-
|
|
53
|
-
- **Supported Types**: "image", "audio", "video"
|
|
54
|
-
- **Detection Method**: MIME type pattern matching
|
|
55
|
-
- **Default Behavior**: Unknown types default to "image"
|
|
56
|
-
- **Common Patterns**:
|
|
57
|
-
- Images: image/jpeg, image/png, image/gif, image/webp
|
|
58
|
-
- Audio: audio/mp3, audio/wav, audio/mpeg, audio/aac
|
|
59
|
-
- Video: video/mp4, video/quicktime, video/x-msvideo
|
|
60
|
-
|
|
61
|
-
### File Size Operations
|
|
62
|
-
|
|
63
|
-
1. **Aggregation**: `calculateTotalSize()` - Sum all file sizes in bytes
|
|
64
|
-
2. **Formatting**: `formatFileSize()` - Convert bytes to readable format
|
|
65
|
-
3. **Unit Selection**: Automatically chooses appropriate unit (Bytes/KB/MB/GB)
|
|
66
|
-
4. **Rounding**: Rounds to 2 decimal places for KB and above
|
|
67
|
-
|
|
68
|
-
### Duration and Metadata
|
|
69
|
-
|
|
70
|
-
1. **Duration**: Returns seconds for audio/video, undefined for images
|
|
71
|
-
2. **Thumbnails**: Only generated for video files using external service
|
|
72
|
-
3. **Type Extraction**: Returns unique types in order of appearance
|
|
73
|
-
4. **Media Support**: Works with both CardMediaAttachment and MediaAttachment
|
|
74
|
-
|
|
75
|
-
### Error Handling
|
|
76
|
-
|
|
77
|
-
1. Handle undefined returns from `getMediaDuration()` for images
|
|
78
|
-
2. Handle undefined returns from `generateThumbnail()` for non-videos
|
|
79
|
-
3. Validate MIME type strings before type detection
|
|
80
|
-
4. Handle empty arrays in collection operations
|
|
81
|
-
5. Always check for null/undefined file objects
|
|
82
|
-
|
|
83
|
-
### Usage Patterns
|
|
84
|
-
|
|
85
|
-
1. **Media Analysis**: Combine multiple utilities for comprehensive file analysis
|
|
86
|
-
2. **Validation**: Use type detection and size calculation for pre-upload validation
|
|
87
|
-
3. **Statistics**: Aggregate collection data using type extraction and size calculation
|
|
88
|
-
4. **Display**: Format sizes for user interfaces using formatFileSize
|
|
89
|
-
5. **Filtering**: Use extracted types for conditional logic and filtering
|
|
90
|
-
|
|
91
|
-
## Dependencies
|
|
92
|
-
|
|
93
|
-
- Domain layer types (MediaAttachment, CardMediaAttachment)
|
|
94
|
-
- No external libraries
|
|
95
|
-
- No framework dependencies
|
|
96
|
-
- Pure TypeScript/JavaScript utilities
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# Media Picker Mappers
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
Mapper functions to convert between expo-image-picker types and domain types, maintaining abstraction layer.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/infrastructure/utils/mediaPickerMappers.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Isolate expo-image-picker dependency to infrastructure layer
|
|
11
|
-
- Provide clean mapping between external and domain types
|
|
12
|
-
- Handle permission status conversion
|
|
13
|
-
- Convert media type enums to library-specific formats
|
|
14
|
-
- Transform picker results to domain entities
|
|
15
|
-
- Maintain compatibility with expo-image-picker API changes
|
|
16
|
-
|
|
17
|
-
## Forbidden
|
|
18
|
-
- **DO NOT** import expo-image-picker outside infrastructure layer
|
|
19
|
-
- **DO NOT** add business logic to mapping functions
|
|
20
|
-
- **DO NOT** modify input parameters during mapping
|
|
21
|
-
- **DO NOT** throw exceptions for invalid inputs (use defaults)
|
|
22
|
-
- **DO NOT** add side effects to mapping functions
|
|
23
|
-
- **DO NOT** directly use mapped types in domain or presentation layers
|
|
24
|
-
- **DO NOT** create circular dependencies with picker implementation
|
|
25
|
-
|
|
26
|
-
## Rules
|
|
27
|
-
1. All mapping functions must be pure transformations
|
|
28
|
-
2. Permission status must map UNDETERMINED to DENIED
|
|
29
|
-
3. MediaType must convert to array format for expo-image-picker
|
|
30
|
-
4. Asset properties must use fallback values for undefined fields
|
|
31
|
-
5. All mappers must handle null/undefined inputs gracefully
|
|
32
|
-
6. Mapped types must match domain type contracts exactly
|
|
33
|
-
7. Must preserve all original data during transformation
|
|
34
|
-
8. Type conversion must be reversible where possible
|
|
35
|
-
9. Must handle all enum values explicitly
|
|
36
|
-
10. Default values must be documented
|
|
37
|
-
|
|
38
|
-
## AI Agent Guidelines
|
|
39
|
-
|
|
40
|
-
When working with media picker mappers:
|
|
41
|
-
|
|
42
|
-
1. **Layer Isolation**: Only use mappers in infrastructure layer, never in domain/presentation
|
|
43
|
-
2. **Type Conversion**: Always use provided mappers, never manually convert types
|
|
44
|
-
3. **Permission Handling**: Check mapped permission status, not raw expo-image-picker values
|
|
45
|
-
4. **Media Types**: Use domain MediaType enum, then map to expo format when calling picker
|
|
46
|
-
5. **Result Processing**: Always map picker results before passing to other layers
|
|
47
|
-
6. **Fallback Values**: Be aware that asset properties may have default values
|
|
48
|
-
7. **Null Safety**: Handle undefined optional properties in mapped results
|
|
49
|
-
8. **Version Compatibility**: Update mappers when upgrading expo-image-picker
|
|
50
|
-
|
|
51
|
-
### Permission Status Mapping
|
|
52
|
-
|
|
53
|
-
- **GRANTED** → GRANTED (full access)
|
|
54
|
-
- **DENIED** → DENIED (no access)
|
|
55
|
-
- **UNDETERMINED** → DENIED (treat as denied, request again)
|
|
56
|
-
|
|
57
|
-
**Strategy**: Convert undetermined to denied to force explicit permission request
|
|
58
|
-
|
|
59
|
-
### MediaType Mapping
|
|
60
|
-
|
|
61
|
-
| Domain MediaType | expo-image-picker Format |
|
|
62
|
-
|-----------------|------------------------|
|
|
63
|
-
| IMAGE | ["images"] |
|
|
64
|
-
| VIDEO | ["videos"] |
|
|
65
|
-
| ALL | ["images", "videos"] |
|
|
66
|
-
| undefined | ["images"] (default) |
|
|
67
|
-
|
|
68
|
-
**Strategy**: Convert domain enum to array format required by library
|
|
69
|
-
|
|
70
|
-
### Asset Transformation
|
|
71
|
-
|
|
72
|
-
All asset fields are mapped with fallback values:
|
|
73
|
-
- **uri**: Required, no fallback
|
|
74
|
-
- **width**: Number, fallback 0
|
|
75
|
-
- **height**: Number, fallback 0
|
|
76
|
-
- **type**: MediaType enum (IMAGE or VIDEO)
|
|
77
|
-
- **fileSize**: Number, fallback 0
|
|
78
|
-
- **fileName**: String or undefined
|
|
79
|
-
- **duration**: Number or undefined (video only)
|
|
80
|
-
- **base64**: String or undefined (only when requested)
|
|
81
|
-
- **mimeType**: String or undefined
|
|
82
|
-
|
|
83
|
-
### Picker Result Structure
|
|
84
|
-
|
|
85
|
-
**Input Structure (expo-image-picker)**:
|
|
86
|
-
- A boolean `canceled` field indicating whether the user cancelled the operation
|
|
87
|
-
- An optional `assets` array containing Asset objects from expo-image-picker
|
|
88
|
-
|
|
89
|
-
**Output Structure (MediaPickerResult)**:
|
|
90
|
-
- A boolean `canceled` field (same as input)
|
|
91
|
-
- An optional `assets` array containing MediaAsset domain objects
|
|
92
|
-
- All Asset fields are transformed to MediaAsset fields with appropriate fallback values
|
|
93
|
-
|
|
94
|
-
### Integration Patterns
|
|
95
|
-
|
|
96
|
-
1. **Before Picker**: Convert domain types to picker types
|
|
97
|
-
2. **After Picker**: Convert picker results to domain types
|
|
98
|
-
3. **Permission Check**: Map permission status before domain layer access
|
|
99
|
-
4. **Error Handling**: Check canceled flag before processing assets
|
|
100
|
-
5. **Type Safety**: Use domain types throughout application logic
|
|
101
|
-
|
|
102
|
-
### Common Workflows
|
|
103
|
-
|
|
104
|
-
1. **Permission Request**: Check status → Map → Request → Map result
|
|
105
|
-
2. **Media Selection**: Map MediaType → Launch picker → Map result
|
|
106
|
-
3. **Multiple Selection**: Handle array of assets in mapper
|
|
107
|
-
4. **Camera vs Library**: Use same mappers for both picker types
|
|
108
|
-
|
|
109
|
-
### Validation Rules
|
|
110
|
-
|
|
111
|
-
1. Always check `canceled` flag before accessing assets
|
|
112
|
-
2. Validate assets array exists and has length > 0
|
|
113
|
-
3. Handle undefined optional properties gracefully
|
|
114
|
-
4. Check permission status before launching picker
|
|
115
|
-
5. Handle null asset properties with fallback values
|
|
116
|
-
|
|
117
|
-
### Error Handling
|
|
118
|
-
|
|
119
|
-
1. Cancelled operations return `{ canceled: true }`
|
|
120
|
-
2. Missing assets return empty array or undefined
|
|
121
|
-
3. Invalid types use default fallback values
|
|
122
|
-
4. Permission denied operations should be handled at application level
|
|
123
|
-
5. Never throw exceptions from mapping functions
|
|
124
|
-
|
|
125
|
-
## Dependencies
|
|
126
|
-
|
|
127
|
-
- expo-image-picker (external library)
|
|
128
|
-
- Domain layer types (MediaAsset, MediaPickerResult, MediaType, MediaLibraryPermission)
|
|
129
|
-
- Infrastructure layer only
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
# Card Multimedia Hook Types
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
TypeScript return type interfaces for card-specific multimedia hooks in the presentation layer.
|
|
5
|
-
|
|
6
|
-
## File Location
|
|
7
|
-
`src/presentation/hooks/card-multimedia.types.ts`
|
|
8
|
-
|
|
9
|
-
## Strategy
|
|
10
|
-
- Define contracts for card multimedia hook implementations
|
|
11
|
-
- Ensure type safety across card media operations
|
|
12
|
-
- Provide consistent return types for upload, generation, and validation
|
|
13
|
-
- Support card-specific media operations (including image search)
|
|
14
|
-
- Enable proper error handling and loading states
|
|
15
|
-
- Maintain separation between card and general multimedia types
|
|
16
|
-
|
|
17
|
-
## Forbidden
|
|
18
|
-
- **DO NOT** import implementation details or hooks in type files
|
|
19
|
-
- **DO NOT** mix CardMediaAttachment and MediaAttachment types
|
|
20
|
-
- **DO NOT** add business logic to type definitions
|
|
21
|
-
- **DO NOT** use `any` type for function parameters or returns
|
|
22
|
-
- **DO NOT** create circular dependencies with domain types
|
|
23
|
-
- **DO NOT** export implementation-specific types
|
|
24
|
-
- **DO NOT** modify these types without updating all hook implementations
|
|
25
|
-
|
|
26
|
-
## Rules
|
|
27
|
-
1. All hook returns must include loading state, error state, and operation function
|
|
28
|
-
2. Async operations must return Promise with appropriate type
|
|
29
|
-
3. Error states must be string | null (not Error objects)
|
|
30
|
-
4. Progress/results must be null when not active
|
|
31
|
-
5. Boolean states must clearly indicate operation in progress
|
|
32
|
-
6. All interfaces must be exported and public
|
|
33
|
-
7. Type names must follow Use*Result pattern
|
|
34
|
-
8. Functions must accept domain types, not external types
|
|
35
|
-
9. Optional parameters must be clearly marked
|
|
36
|
-
10. Return types must match hook implementations exactly
|
|
37
|
-
|
|
38
|
-
## AI Agent Guidelines
|
|
39
|
-
|
|
40
|
-
When working with card multimedia hook types:
|
|
41
|
-
|
|
42
|
-
1. **Type Imports**: Always import types from this file for card multimedia hooks
|
|
43
|
-
2. **Hook Implementation**: Implement hooks that return these exact interfaces
|
|
44
|
-
3. **Card vs General**: Use Card* types for card-specific operations, Media* for general
|
|
45
|
-
4. **Error Handling**: Always check error state before using results
|
|
46
|
-
5. **Loading States**: Respect loading states to prevent race conditions
|
|
47
|
-
6. **Progress Tracking**: Use progress objects for upload operations
|
|
48
|
-
7. **Type Safety**: Use these types for all card multimedia hook return values
|
|
49
|
-
8. **Testing**: Mock these interfaces when testing card media operations
|
|
50
|
-
|
|
51
|
-
### Hook Return Type Structure
|
|
52
|
-
|
|
53
|
-
All card multimedia hook returns follow this consistent pattern:
|
|
54
|
-
|
|
55
|
-
**Core Components**:
|
|
56
|
-
- **operationFunction**: An async function that accepts parameters and returns a Promise with the result type
|
|
57
|
-
- **isOperationInProgress**: A boolean flag indicating whether the operation is currently running
|
|
58
|
-
- **operationResult**: The result object or null when no operation is active
|
|
59
|
-
- **error**: A string containing error messages or null when no error exists
|
|
60
|
-
|
|
61
|
-
### UseCardMediaUploadResult
|
|
62
|
-
|
|
63
|
-
**Purpose**: Card media upload operations with compression options
|
|
64
|
-
|
|
65
|
-
**Key Features**:
|
|
66
|
-
- Upload function accepts file and compression options
|
|
67
|
-
- Tracks upload progress
|
|
68
|
-
- Returns CardMediaAttachment
|
|
69
|
-
- Handles upload errors
|
|
70
|
-
|
|
71
|
-
**Usage Pattern**:
|
|
72
|
-
1. Check `isUploading` before calling
|
|
73
|
-
2. Call `uploadMedia()` with file and optional compression
|
|
74
|
-
3. Monitor `uploadProgress` during upload
|
|
75
|
-
4. Check `error` state on completion
|
|
76
|
-
5. Use returned CardMediaAttachment on success
|
|
77
|
-
|
|
78
|
-
### UseCardMediaGenerationResult
|
|
79
|
-
|
|
80
|
-
**Purpose**: Card media generation (AI-based generation, image search)
|
|
81
|
-
|
|
82
|
-
**Key Features**:
|
|
83
|
-
- Generation function accepts request parameters
|
|
84
|
-
- Tracks generation status
|
|
85
|
-
- Returns CardMediaGenerationResult
|
|
86
|
-
- Supports multiple generation methods
|
|
87
|
-
|
|
88
|
-
**Usage Pattern**:
|
|
89
|
-
1. Prepare CardMediaGenerationRequest
|
|
90
|
-
2. Check `isGenerating` before calling
|
|
91
|
-
3. Call `generateMedia()` with request
|
|
92
|
-
4. Access `generationResult` when complete
|
|
93
|
-
5. Handle `error` if generation fails
|
|
94
|
-
|
|
95
|
-
### UseCardMediaValidationResult
|
|
96
|
-
|
|
97
|
-
**Purpose**: Card media validation before upload or processing
|
|
98
|
-
|
|
99
|
-
**Key Features**:
|
|
100
|
-
- Validation function accepts file
|
|
101
|
-
- Tracks validation status
|
|
102
|
-
- Returns CardMediaValidation result
|
|
103
|
-
- Provides detailed validation errors
|
|
104
|
-
|
|
105
|
-
**Usage Pattern**:
|
|
106
|
-
1. Check `isValidating` before calling
|
|
107
|
-
2. Call `validateMedia()` with file
|
|
108
|
-
3. Access `validation` result for validity check
|
|
109
|
-
4. Use `validation.errors` array for error details
|
|
110
|
-
5. Check `error` state for validation failures
|
|
111
|
-
|
|
112
|
-
### UseCardMultimediaFlashcardResult
|
|
113
|
-
|
|
114
|
-
**Purpose**: Card flashcard CRUD operations
|
|
115
|
-
|
|
116
|
-
**Key Features**:
|
|
117
|
-
- Create card with multimedia
|
|
118
|
-
- Update card media
|
|
119
|
-
- Delete specific media attachment
|
|
120
|
-
- Tracks processing state
|
|
121
|
-
- Returns CardMultimediaFlashcard
|
|
122
|
-
|
|
123
|
-
**Usage Pattern**:
|
|
124
|
-
1. Create: Call `createCardMultimedia()` with card data
|
|
125
|
-
2. Update: Call `updateCardMedia()` with cardId and media array
|
|
126
|
-
3. Delete: Call `deleteCardMedia()` with attachmentId
|
|
127
|
-
4. Check `isProcessing` before operations
|
|
128
|
-
5. Handle `error` state for failures
|
|
129
|
-
|
|
130
|
-
### Card vs General Multimedia Types
|
|
131
|
-
|
|
132
|
-
| Operation | Card Types | General Types | Key Difference |
|
|
133
|
-
|-----------|-----------|---------------|----------------|
|
|
134
|
-
| Upload | CardMediaAttachment | MediaAttachment | Card-specific metadata |
|
|
135
|
-
| Generation | CardMediaGenerationRequest | MediaGenerationRequest | Cards include image search |
|
|
136
|
-
| Validation | CardMediaValidation | MediaValidation | Card-specific rules |
|
|
137
|
-
| Flashcard | CardMultimediaFlashcard | MultimediaFlashcard | Different entity types |
|
|
138
|
-
|
|
139
|
-
### Type Guards and Validation
|
|
140
|
-
|
|
141
|
-
1. **Upload Hook**: Check for `uploadMedia` function and `isUploading` boolean
|
|
142
|
-
2. **Generation Hook**: Check for `generateMedia` function and `isGenerating` boolean
|
|
143
|
-
3. **Validation Hook**: Check for `validateMedia` function and `isValidating` boolean
|
|
144
|
-
4. **Flashcard Hook**: Check for all three CRUD functions and `isProcessing` boolean
|
|
145
|
-
|
|
146
|
-
### Error Handling Patterns
|
|
147
|
-
|
|
148
|
-
1. Always check if `error !== null` before using results
|
|
149
|
-
2. Errors are strings, not Error objects
|
|
150
|
-
3. Clear error before starting new operation
|
|
151
|
-
4. Show user-friendly error messages
|
|
152
|
-
5. Handle null states for progress/results
|
|
153
|
-
|
|
154
|
-
### Async Operation Patterns
|
|
155
|
-
|
|
156
|
-
1. **Before Call**: Check loading state to prevent concurrent calls
|
|
157
|
-
2. **During Call**: Show loading indicator based on boolean state
|
|
158
|
-
3. **After Call**: Check error state, then use result
|
|
159
|
-
4. **Error Case**: Display error, reset loading state
|
|
160
|
-
5. **Success Case**: Use result, clear error
|
|
161
|
-
|
|
162
|
-
### Related Domain Types
|
|
163
|
-
|
|
164
|
-
These interfaces use domain types:
|
|
165
|
-
- CardMediaAttachment
|
|
166
|
-
- CardMediaGenerationRequest
|
|
167
|
-
- CardMediaGenerationResult
|
|
168
|
-
- CardMediaCompressionOptions
|
|
169
|
-
- CardMediaValidation
|
|
170
|
-
- CardMediaUploadProgress
|
|
171
|
-
- CardMultimediaFlashcard
|
|
172
|
-
|
|
173
|
-
## Dependencies
|
|
174
|
-
|
|
175
|
-
- Domain layer types (Card* entities)
|
|
176
|
-
- Presentation layer hooks
|
|
177
|
-
- No external dependencies
|