@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.
Files changed (77) hide show
  1. package/package.json +1 -1
  2. package/src/atoms/AtomicInput.tsx +0 -2
  3. package/src/atoms/button/AtomicButton.tsx +7 -0
  4. package/src/atoms/button/types/index.ts +4 -0
  5. package/src/atoms/input/hooks/useInputState.ts +3 -7
  6. package/src/haptics/infrastructure/services/HapticService.ts +1 -1
  7. package/src/media/domain/entities/{MultimediaFlashcardTypes.ts → MediaAttachments.ts} +13 -32
  8. package/src/media/index.ts +24 -23
  9. package/src/media/{presentation/hooks/useCardMediaGeneration.ts → infrastructure/hooks/useGenericMediaGeneration.ts} +77 -31
  10. package/src/media/infrastructure/services/MediaGenerationService.ts +1 -1
  11. package/src/media/infrastructure/services/MediaOptimizerService.ts +1 -1
  12. package/src/media/infrastructure/services/MediaUploadService.ts +1 -1
  13. package/src/media/infrastructure/services/MediaValidationService.ts +1 -1
  14. package/src/media/infrastructure/services/MultimediaFlashcardService.ts +1 -1
  15. package/src/media/infrastructure/utils/PermissionManager.ts +1 -1
  16. package/src/media/infrastructure/utils/media-collection-utils.ts +4 -2
  17. package/src/media/infrastructure/utils/mediaPickerMappers.ts +1 -1
  18. package/src/media/presentation/hooks/multimedia.types.ts +1 -1
  19. package/src/media/presentation/hooks/useCardMultimediaFlashcard.ts +4 -4
  20. package/src/media/presentation/hooks/useMedia.ts +2 -2
  21. package/src/media/presentation/hooks/useMediaGeneration.ts +5 -88
  22. package/src/media/presentation/hooks/useMediaUpload.ts +1 -1
  23. package/src/media/presentation/hooks/useMediaValidation.ts +1 -1
  24. package/src/media/presentation/hooks/useMultimediaFlashcard.ts +1 -1
  25. package/src/molecules/navigation/components/NavigationHeader.tsx +3 -3
  26. package/src/molecules/navigation/utils/AppNavigation.ts +3 -3
  27. package/src/offline/index.ts +1 -0
  28. package/src/offline/infrastructure/storage/OfflineConfigStore.ts +34 -0
  29. package/src/offline/presentation/hooks/useOffline.ts +8 -4
  30. package/src/storage/domain/utils/devUtils.ts +0 -24
  31. package/src/storage/index.ts +1 -1
  32. package/src/storage/infrastructure/adapters/StorageService.ts +5 -10
  33. package/src/storage/infrastructure/repositories/BaseStorageOperations.ts +5 -8
  34. package/src/storage/presentation/hooks/CacheStorageOperations.ts +5 -11
  35. package/src/storage/presentation/hooks/useStore.ts +13 -5
  36. package/src/utilities/sharing/presentation/hooks/useSharing.ts +3 -3
  37. package/src/layouts/ScreenLayout/ScreenLayout.example.tsx +0 -92
  38. package/src/media/domain/entities/CardMultimedia.types.README.md +0 -129
  39. package/src/media/domain/entities/CardMultimedia.types.ts +0 -120
  40. package/src/media/domain/entities/Media.README.md +0 -80
  41. package/src/media/domain/entities/MultimediaFlashcardTypes.README.md +0 -144
  42. package/src/media/domain/utils/MediaUtils.README.md +0 -178
  43. package/src/media/index.ts.README.md +0 -191
  44. package/src/media/infrastructure/services/CardMediaGenerationService.README.md +0 -99
  45. package/src/media/infrastructure/services/CardMediaGenerationService.ts +0 -101
  46. package/src/media/infrastructure/services/CardMediaOptimizerService.README.md +0 -167
  47. package/src/media/infrastructure/services/CardMediaOptimizerService.ts +0 -36
  48. package/src/media/infrastructure/services/CardMediaUploadService.README.md +0 -123
  49. package/src/media/infrastructure/services/CardMediaUploadService.ts +0 -62
  50. package/src/media/infrastructure/services/CardMediaValidationService.README.md +0 -134
  51. package/src/media/infrastructure/services/CardMediaValidationService.ts +0 -81
  52. package/src/media/infrastructure/services/CardMultimediaService.README.md +0 -176
  53. package/src/media/infrastructure/services/CardMultimediaService.ts +0 -98
  54. package/src/media/infrastructure/services/MediaGenerationService.README.md +0 -142
  55. package/src/media/infrastructure/services/MediaOptimizerService.README.md +0 -145
  56. package/src/media/infrastructure/services/MediaPickerService.README.md +0 -106
  57. package/src/media/infrastructure/services/MediaSaveService.README.md +0 -120
  58. package/src/media/infrastructure/services/MediaUploadService.README.md +0 -135
  59. package/src/media/infrastructure/services/MediaValidationService.README.md +0 -135
  60. package/src/media/infrastructure/services/MultimediaFlashcardService.README.md +0 -142
  61. package/src/media/infrastructure/utils/mediaHelpers.README.md +0 -96
  62. package/src/media/infrastructure/utils/mediaPickerMappers.README.md +0 -129
  63. package/src/media/presentation/hooks/card-multimedia.types.README.md +0 -177
  64. package/src/media/presentation/hooks/card-multimedia.types.ts +0 -53
  65. package/src/media/presentation/hooks/multimedia.types.README.md +0 -201
  66. package/src/media/presentation/hooks/useCardMediaGeneration.README.md +0 -164
  67. package/src/media/presentation/hooks/useCardMediaUpload.README.md +0 -153
  68. package/src/media/presentation/hooks/useCardMediaUpload.ts +0 -84
  69. package/src/media/presentation/hooks/useCardMediaValidation.README.md +0 -176
  70. package/src/media/presentation/hooks/useCardMediaValidation.ts +0 -101
  71. package/src/media/presentation/hooks/useCardMultimediaFlashcard.README.md +0 -158
  72. package/src/media/presentation/hooks/useMedia.README.md +0 -94
  73. package/src/media/presentation/hooks/useMediaGeneration.README.md +0 -118
  74. package/src/media/presentation/hooks/useMediaUpload.README.md +0 -108
  75. package/src/media/presentation/hooks/useMediaValidation.README.md +0 -134
  76. package/src/media/presentation/hooks/useMultimediaFlashcard.README.md +0 -141
  77. package/src/storage/domain/utils/__tests__/devUtils.test.ts +0 -97
@@ -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)
@@ -1,120 +0,0 @@
1
- # MediaSaveService
2
-
3
- ## Purpose
4
- Handles saving image and video files to the device's photo gallery, including album management and permission handling.
5
-
6
- ## File Location
7
- `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/MediaSaveService`
8
-
9
- ## Strategy
10
-
11
- ### Core Purpose
12
- - Save media files to device gallery
13
- - Create and manage custom albums
14
- - Handle platform-specific save requirements
15
- - Manage write permissions for media library
16
-
17
- ### Usage Scenarios
18
- - Saving downloaded images to gallery
19
- - Creating app-specific albums
20
- - Saving captured media to gallery
21
- - Organizing media into custom collections
22
- - Backup workflows
23
-
24
- ### Integration Points
25
- - After media download completes
26
- - After media generation/creation
27
- - User-initiated save actions
28
- - Batch media save operations
29
-
30
- ## Forbidden
31
-
32
- ### MUST NOT
33
- - Save files without proper write permissions
34
- - Assume album creation always succeeds
35
- - Create duplicate albums with same name
36
- - Overwrite existing media without user consent
37
- - Save invalid or corrupted media files
38
- - Ignore save operation results
39
-
40
- ### MUST NEVER
41
- - Attempt to save when permission is denied
42
- - Assume save operation is instant
43
- - Save to private app storage using this service
44
- - Modify saved media after save operation completes
45
- - Bypass platform-specific save restrictions
46
-
47
- ## Rules
48
-
49
- ### Permission Management
50
- - MUST request write permission before saving
51
- - MUST check permission status before operations
52
- - MUST handle permission denial gracefully
53
- - MUST provide clear error messages for permission issues
54
- - MUST respect user's permission decisions
55
-
56
- ### Save Operations
57
- - MUST validate file URI/path before saving
58
- - MUST determine media type (image/video) correctly
59
- - MUST handle save failures appropriately
60
- - MUST return success/failure status
61
- - MUST include asset ID in successful results
62
-
63
- ### Album Management
64
- - MUST create album automatically if it doesn't exist
65
- - MUST NOT create duplicate albums with same name
66
- - MUST save to default gallery if no album specified
67
- - MUST handle album creation failures
68
- - MUST validate album names
69
-
70
- ### Error Handling
71
- - MUST catch and report save failures
72
- - MUST handle invalid file paths
73
- - MUST handle insufficient storage scenarios
74
- - MUST provide meaningful error messages
75
- - MUST allow retry after permission grant
76
-
77
- ### Platform Considerations
78
- - MUST handle iOS save requirements
79
- - MUST handle Android scoped storage (API 10+)
80
- - MUST account for platform-specific restrictions
81
- - MUST test on both platforms
82
-
83
- ## AI Agent Guidelines
84
-
85
- ### When Implementing Save Operations
86
- 1. Always check permissions before attempting save
87
- 2. Validate file URI/path exists and is accessible
88
- 3. Determine correct media type for the file
89
- 4. Handle both success and failure cases
90
- 5. Provide user feedback for save operations
91
-
92
- ### When Working with Albums
93
- - Check if album exists before creating
94
- - Use consistent album naming
95
- - Handle album creation failures gracefully
96
- - Allow saving to default gallery as fallback
97
-
98
- ### When Adding Features
99
- - Add new media types with proper validation
100
- - Extend save options without breaking changes
101
- - Maintain backward compatibility
102
- - Add error handling for new edge cases
103
-
104
- ### When Refactoring
105
- - Keep public API stable
106
- - Preserve permission handling logic
107
- - Maintain platform-specific behavior
108
- - Don't remove existing save methods without deprecation
109
-
110
- ### Common Patterns to Follow
111
- - Request permission -> Check status -> Validate file -> Save
112
- - Handle result -> Check success -> Return asset ID or error
113
- - Always wrap in try-catch for unexpected errors
114
- - Provide user feedback for save status
115
-
116
- ## Dependencies
117
-
118
- - Domain types: MediaType, MediaLibraryPermission from Media
119
- - External libraries: expo-media-library
120
- - No internal utility dependencies
@@ -1,135 +0,0 @@
1
- # MediaUploadService
2
-
3
- ## Purpose
4
- Manages media file uploads to remote servers, including compression, URL management, and download functionality.
5
-
6
- ## File Location
7
- `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-media/src/infrastructure/services/MediaUploadService`
8
-
9
- ## Strategy
10
-
11
- ### Core Purpose
12
- - Upload media files to remote storage
13
- - Generate and manage media URLs
14
- - Support compression during upload
15
- - Download media to local storage
16
- - Generate thumbnails automatically
17
-
18
- ### Usage Scenarios
19
- - User-generated content uploads
20
- - Profile picture uploads
21
- - Document/image sharing
22
- - Media backup workflows
23
- - Content delivery networks integration
24
-
25
- ### Integration Points
26
- - Form submissions with media attachments
27
- - Social media sharing features
28
- - Cloud storage synchronization
29
- - Content management systems
30
- - Media delivery pipelines
31
-
32
- ## Forbidden
33
-
34
- ### MUST NOT
35
- - Upload invalid or corrupted files
36
- - Assume network is always available
37
- - Upload without file size limits
38
- - Ignore authentication requirements
39
- - Store sensitive credentials in service
40
- - Generate duplicate URLs for same media
41
-
42
- ### MUST NEVER
43
- - Upload without proper error handling
44
- - Assume upload progress is always available
45
- - Retry failed uploads indefinitely
46
- - Expose sensitive upload endpoints
47
- - Upload without user consent
48
- - Ignore network timeout scenarios
49
-
50
- ## Rules
51
-
52
- ### Upload Operations
53
- - MUST validate file before upload
54
- - MUST handle network errors gracefully
55
- - MUST support compression options
56
- - MUST return unique media ID
57
- - MUST provide upload progress when possible
58
- - MUST handle timeout scenarios
59
-
60
- ### Compression Options
61
- - MUST support quality adjustment (0-1)
62
- - MUST support max width/height constraints
63
- - MUST support format conversion (jpeg/png)
64
- - MUST validate compression parameters
65
- - MUST apply compression before upload
66
-
67
- ### URL Management
68
- - MUST generate unique URLs for each media
69
- - MUST support URL retrieval by media ID
70
- - MUST handle invalid media IDs
71
- - MUST maintain URL consistency
72
- - MUST support URL expiration if required
73
-
74
- ### Download Operations
75
- - MUST validate media ID before download
76
- - MUST handle download failures
77
- - MUST return local file path
78
- - MUST manage storage space
79
- - MUST support large file downloads
80
-
81
- ### Return Values
82
- - MUST include media metadata (type, size, MIME)
83
- - MUST include unique identifier
84
- - MUST include URL (full or relative)
85
- - MUST include thumbnail for applicable types
86
- - MUST include duration for audio/video
87
-
88
- ### Error Handling
89
- - MUST catch network errors
90
- - MUST handle authentication failures
91
- - MUST handle storage quota exceeded
92
- - MUST provide meaningful error messages
93
- - MUST allow retry after failure
94
-
95
- ## AI Agent Guidelines
96
-
97
- ### When Implementing Upload Features
98
- 1. Always validate file metadata before upload
99
- 2. Apply compression options if specified
100
- 3. Generate unique media identifier
101
- 4. Handle network failures gracefully
102
- 5. Return complete media attachment object
103
-
104
- ### When Working with URLs
105
- - Generate unique, predictable URLs
106
- - Support both absolute and relative URLs
107
- - Include media ID in URL structure
108
- - Handle URL generation failures
109
-
110
- ### When Adding Features
111
- - Add new media types with validation
112
- - Extend compression options carefully
113
- - Maintain backward compatibility
114
- - Add progress tracking for large files
115
- - Support batch uploads if needed
116
-
117
- ### When Refactoring
118
- - Keep upload API stable
119
- - Preserve media ID generation logic
120
- - Maintain URL structure consistency
121
- - Don't change return value structure
122
- - Add deprecation warnings for breaking changes
123
-
124
- ### Common Patterns to Follow
125
- - Validate file -> Apply compression -> Upload -> Return attachment
126
- - Handle network errors -> Retry if appropriate -> Return error
127
- - Generate URL -> Store mapping -> Return URL
128
- - Always wrap network operations in try-catch
129
- - Provide user feedback for upload progress
130
-
131
- ## Dependencies
132
-
133
- - Domain types: MediaAttachment, MediaCompressionOptions from MultimediaFlashcardTypes
134
- - Internal utilities: mediaHelpers (generateThumbnail, getMediaDuration, getMediaType)
135
- - No external library dependencies (uses native APIs and fetch)