1use serde::{Deserialize, Serialize};
9use uuid::Uuid;
10use chrono::{DateTime, Utc};
11use crate::domain::entity::*;
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
21pub struct AccessLogId(pub Uuid);
22
23impl AccessLogId {
24 pub fn new(id: Uuid) -> Self {
25 Self(id)
26 }
27
28 pub fn into_inner(self) -> Uuid {
29 self.0
30 }
31}
32
33impl From<Uuid> for AccessLogId {
34 fn from(id: Uuid) -> Self {
35 Self(id)
36 }
37}
38
39impl From<AccessLogId> for Uuid {
40 fn from(id: AccessLogId) -> Self {
41 id.0
42 }
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct AccessLogDto {
50 pub id: AccessLogId,
51 pub file_id: Uuid,
52 pub bucket_id: Option<Uuid>,
53 pub action: AccessAction,
54 pub user_id: Option<Uuid>,
55 pub share_id: Option<Uuid>,
56 pub is_owner: bool,
57 pub is_shared: bool,
58 pub is_public: bool,
59 pub ip_address: Option<String>,
60 pub user_agent: Option<String>,
61 pub referer: Option<String>,
62 pub country_code: Option<String>,
63 pub city: Option<String>,
64 pub bytes_transferred: Option<i64>,
65 pub duration_ms: Option<i32>,
66 pub success: bool,
67 pub error_message: Option<String>,
68 pub accessed_at: DateTime<Utc>,
69 pub metadata: serde_json::Value,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct AccessLogSummary {
75 pub id: AccessLogId,
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80pub struct AccessLogRef {
81 pub id: AccessLogId,
82}
83
84#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
92pub struct BucketId(pub Uuid);
93
94impl BucketId {
95 pub fn new(id: Uuid) -> Self {
96 Self(id)
97 }
98
99 pub fn into_inner(self) -> Uuid {
100 self.0
101 }
102}
103
104impl From<Uuid> for BucketId {
105 fn from(id: Uuid) -> Self {
106 Self(id)
107 }
108}
109
110impl From<BucketId> for Uuid {
111 fn from(id: BucketId) -> Self {
112 id.0
113 }
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
120pub struct BucketDto {
121 pub id: BucketId,
122 pub name: String,
123 pub slug: String,
124 pub description: Option<String>,
125 pub owner_id: Uuid,
126 pub bucket_type: BucketType,
127 pub status: BucketStatus,
128 pub storage_backend: StorageBackend,
129 pub root_path: String,
130 pub file_count: i32,
131 pub total_size_bytes: i64,
132 pub max_file_size: Option<i64>,
133 pub allowed_mime_types: Vec<String>,
134 pub auto_delete_after_days: Option<i32>,
135 pub enable_cdn: bool,
136 pub enable_versioning: bool,
137 pub enable_deduplication: bool,
138 pub metadata: serde_json::Value,
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize)]
143pub struct BucketSummary {
144 pub id: BucketId,
145 pub name: String,
146 pub status: BucketStatus,
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
151pub struct BucketRef {
152 pub id: BucketId,
153}
154
155#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
163pub struct ContentHashId(pub Uuid);
164
165impl ContentHashId {
166 pub fn new(id: Uuid) -> Self {
167 Self(id)
168 }
169
170 pub fn into_inner(self) -> Uuid {
171 self.0
172 }
173}
174
175impl From<Uuid> for ContentHashId {
176 fn from(id: Uuid) -> Self {
177 Self(id)
178 }
179}
180
181impl From<ContentHashId> for Uuid {
182 fn from(id: ContentHashId) -> Self {
183 id.0
184 }
185}
186
187#[derive(Debug, Clone, Serialize, Deserialize)]
191pub struct ContentHashDto {
192 pub id: ContentHashId,
193 pub hash: String,
194 pub size_bytes: i64,
195 pub storage_key: String,
196 pub storage_backend: StorageBackend,
197 pub reference_count: i32,
198 pub first_uploaded_at: DateTime<Utc>,
199 pub last_referenced_at: DateTime<Utc>,
200 pub fingerprint: Option<String>,
201 pub metadata: serde_json::Value,
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206pub struct ContentHashSummary {
207 pub id: ContentHashId,
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize)]
212pub struct ContentHashRef {
213 pub id: ContentHashId,
214}
215
216#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
224pub struct ConversionJobId(pub Uuid);
225
226impl ConversionJobId {
227 pub fn new(id: Uuid) -> Self {
228 Self(id)
229 }
230
231 pub fn into_inner(self) -> Uuid {
232 self.0
233 }
234}
235
236impl From<Uuid> for ConversionJobId {
237 fn from(id: Uuid) -> Self {
238 Self(id)
239 }
240}
241
242impl From<ConversionJobId> for Uuid {
243 fn from(id: ConversionJobId) -> Self {
244 id.0
245 }
246}
247
248#[derive(Debug, Clone, Serialize, Deserialize)]
252pub struct ConversionJobDto {
253 pub id: ConversionJobId,
254 pub source_file_id: Uuid,
255 pub target_format: String,
256 pub status: ConversionStatus,
257 pub conversion_options: Option<serde_json::Value>,
258 pub result_file_id: Option<Uuid>,
259 pub progress: i32,
260 pub error_message: Option<String>,
261 pub started_at: Option<DateTime<Utc>>,
262 pub completed_at: Option<DateTime<Utc>>,
263 pub metadata: serde_json::Value,
264}
265
266#[derive(Debug, Clone, Serialize, Deserialize)]
268pub struct ConversionJobSummary {
269 pub id: ConversionJobId,
270 pub status: ConversionStatus,
271}
272
273#[derive(Debug, Clone, Serialize, Deserialize)]
275pub struct ConversionJobRef {
276 pub id: ConversionJobId,
277}
278
279#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
287pub struct FileCommentId(pub Uuid);
288
289impl FileCommentId {
290 pub fn new(id: Uuid) -> Self {
291 Self(id)
292 }
293
294 pub fn into_inner(self) -> Uuid {
295 self.0
296 }
297}
298
299impl From<Uuid> for FileCommentId {
300 fn from(id: Uuid) -> Self {
301 Self(id)
302 }
303}
304
305impl From<FileCommentId> for Uuid {
306 fn from(id: FileCommentId) -> Self {
307 id.0
308 }
309}
310
311#[derive(Debug, Clone, Serialize, Deserialize)]
315pub struct FileCommentDto {
316 pub id: FileCommentId,
317 pub file_id: Uuid,
318 pub user_id: Uuid,
319 pub parent_id: Option<Uuid>,
320 pub content: String,
321 pub annotation_region: Option<serde_json::Value>,
322 pub mentions: Vec<Uuid>,
323 pub resolved: bool,
324 pub resolved_by: Option<Uuid>,
325 pub resolved_at: Option<DateTime<Utc>>,
326 pub status: CommentStatus,
327 pub metadata: serde_json::Value,
328}
329
330#[derive(Debug, Clone, Serialize, Deserialize)]
332pub struct FileCommentSummary {
333 pub id: FileCommentId,
334 pub status: CommentStatus,
335}
336
337#[derive(Debug, Clone, Serialize, Deserialize)]
339pub struct FileCommentRef {
340 pub id: FileCommentId,
341}
342
343#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
351pub struct FileLockId(pub Uuid);
352
353impl FileLockId {
354 pub fn new(id: Uuid) -> Self {
355 Self(id)
356 }
357
358 pub fn into_inner(self) -> Uuid {
359 self.0
360 }
361}
362
363impl From<Uuid> for FileLockId {
364 fn from(id: Uuid) -> Self {
365 Self(id)
366 }
367}
368
369impl From<FileLockId> for Uuid {
370 fn from(id: FileLockId) -> Self {
371 id.0
372 }
373}
374
375#[derive(Debug, Clone, Serialize, Deserialize)]
379pub struct FileLockDto {
380 pub id: FileLockId,
381 pub file_id: Uuid,
382 pub user_id: Uuid,
383 pub locked_at: DateTime<Utc>,
384 pub expires_at: DateTime<Utc>,
385 pub refreshed_at: Option<DateTime<Utc>>,
386 pub status: LockStatus,
387 pub metadata: serde_json::Value,
388}
389
390#[derive(Debug, Clone, Serialize, Deserialize)]
392pub struct FileLockSummary {
393 pub id: FileLockId,
394 pub status: LockStatus,
395}
396
397#[derive(Debug, Clone, Serialize, Deserialize)]
399pub struct FileLockRef {
400 pub id: FileLockId,
401}
402
403#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
411pub struct FileShareId(pub Uuid);
412
413impl FileShareId {
414 pub fn new(id: Uuid) -> Self {
415 Self(id)
416 }
417
418 pub fn into_inner(self) -> Uuid {
419 self.0
420 }
421}
422
423impl From<Uuid> for FileShareId {
424 fn from(id: Uuid) -> Self {
425 Self(id)
426 }
427}
428
429impl From<FileShareId> for Uuid {
430 fn from(id: FileShareId) -> Self {
431 id.0
432 }
433}
434
435#[derive(Debug, Clone, Serialize, Deserialize)]
439pub struct FileShareDto {
440 pub id: FileShareId,
441 pub file_id: Uuid,
442 pub owner_id: Uuid,
443 pub token: String,
444 pub share_type: ShareType,
445 pub permission: SharePermission,
446 pub shared_with: Vec<Uuid>,
447 pub password_hash: Option<String>,
448 pub max_downloads: Option<i32>,
449 pub download_count: i32,
450 pub expires_at: Option<DateTime<Utc>>,
451 pub status: ShareStatus,
452 pub revoked_at: Option<DateTime<Utc>>,
453 pub revoked_by: Option<Uuid>,
454 pub message: Option<String>,
455 pub metadata: serde_json::Value,
456}
457
458#[derive(Debug, Clone, Serialize, Deserialize)]
460pub struct FileShareSummary {
461 pub id: FileShareId,
462 pub status: ShareStatus,
463}
464
465#[derive(Debug, Clone, Serialize, Deserialize)]
467pub struct FileShareRef {
468 pub id: FileShareId,
469}
470
471#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
479pub struct FileVersionId(pub Uuid);
480
481impl FileVersionId {
482 pub fn new(id: Uuid) -> Self {
483 Self(id)
484 }
485
486 pub fn into_inner(self) -> Uuid {
487 self.0
488 }
489}
490
491impl From<Uuid> for FileVersionId {
492 fn from(id: Uuid) -> Self {
493 Self(id)
494 }
495}
496
497impl From<FileVersionId> for Uuid {
498 fn from(id: FileVersionId) -> Self {
499 id.0
500 }
501}
502
503#[derive(Debug, Clone, Serialize, Deserialize)]
507pub struct FileVersionDto {
508 pub id: FileVersionId,
509 pub file_id: Uuid,
510 pub version_number: i32,
511 pub version_type: VersionType,
512 pub storage_key: String,
513 pub storage_backend: String,
514 pub name: String,
515 pub mime_type: String,
516 pub checksum_md5: Option<String>,
517 pub checksum_sha256: Option<String>,
518 pub created_by_id: Uuid,
519 pub change_summary: Option<String>,
520 pub is_current: bool,
521 pub restored_from_id: Option<Uuid>,
522 pub expires_at: Option<DateTime<Utc>>,
523 pub status: FileVersionStatus,
524 pub deleted_at: Option<DateTime<Utc>>,
525 pub size_bytes: i64,
526 pub metadata: serde_json::Value,
527}
528
529#[derive(Debug, Clone, Serialize, Deserialize)]
531pub struct FileVersionSummary {
532 pub id: FileVersionId,
533 pub name: String,
534 pub status: FileVersionStatus,
535}
536
537#[derive(Debug, Clone, Serialize, Deserialize)]
539pub struct FileVersionRef {
540 pub id: FileVersionId,
541}
542
543#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
551pub struct ProcessingJobId(pub Uuid);
552
553impl ProcessingJobId {
554 pub fn new(id: Uuid) -> Self {
555 Self(id)
556 }
557
558 pub fn into_inner(self) -> Uuid {
559 self.0
560 }
561}
562
563impl From<Uuid> for ProcessingJobId {
564 fn from(id: Uuid) -> Self {
565 Self(id)
566 }
567}
568
569impl From<ProcessingJobId> for Uuid {
570 fn from(id: ProcessingJobId) -> Self {
571 id.0
572 }
573}
574
575#[derive(Debug, Clone, Serialize, Deserialize)]
579pub struct ProcessingJobDto {
580 pub id: ProcessingJobId,
581 pub file_id: Uuid,
582 pub job_type: ProcessingJobType,
583 pub status: JobStatus,
584 pub priority: i32,
585 pub input_data: Option<serde_json::Value>,
586 pub result_data: Option<serde_json::Value>,
587 pub error_message: Option<String>,
588 pub started_at: Option<DateTime<Utc>>,
589 pub completed_at: Option<DateTime<Utc>>,
590 pub retry_count: i32,
591 pub max_retries: i32,
592 pub metadata: serde_json::Value,
593}
594
595#[derive(Debug, Clone, Serialize, Deserialize)]
597pub struct ProcessingJobSummary {
598 pub id: ProcessingJobId,
599 pub status: JobStatus,
600}
601
602#[derive(Debug, Clone, Serialize, Deserialize)]
604pub struct ProcessingJobRef {
605 pub id: ProcessingJobId,
606}
607
608#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
616pub struct StoredFileId(pub Uuid);
617
618impl StoredFileId {
619 pub fn new(id: Uuid) -> Self {
620 Self(id)
621 }
622
623 pub fn into_inner(self) -> Uuid {
624 self.0
625 }
626}
627
628impl From<Uuid> for StoredFileId {
629 fn from(id: Uuid) -> Self {
630 Self(id)
631 }
632}
633
634impl From<StoredFileId> for Uuid {
635 fn from(id: StoredFileId) -> Self {
636 id.0
637 }
638}
639
640#[derive(Debug, Clone, Serialize, Deserialize)]
644pub struct StoredFileDto {
645 pub id: StoredFileId,
646 pub bucket_id: Uuid,
647 pub owner_id: Uuid,
648 pub path: String,
649 pub original_name: String,
650 pub size_bytes: i64,
651 pub mime_type: String,
652 pub checksum: Option<String>,
653 pub is_compressed: bool,
654 pub original_size: Option<i64>,
655 pub compression_algorithm: Option<String>,
656 pub is_scanned: bool,
657 pub scan_result: Option<serde_json::Value>,
658 pub threat_level: Option<ThreatLevel>,
659 pub has_thumbnail: bool,
660 pub thumbnail_path: Option<String>,
661 pub has_video_thumbnail: bool,
662 pub has_document_preview: bool,
663 pub processing_status: Option<ProcessingStatus>,
664 pub content_hash_id: Option<Uuid>,
665 pub cdn_url: Option<String>,
666 pub cdn_url_expires_at: Option<DateTime<Utc>>,
667 pub owner_module: Option<String>,
668 pub owner_entity: Option<String>,
669 pub owner_entity_id: Option<Uuid>,
670 pub field_name: Option<String>,
671 pub sort_order: i32,
672 pub status: FileStatus,
673 pub storage_key: String,
674 pub version: i32,
675 pub previous_version_id: Option<Uuid>,
676 pub download_count: i32,
677 pub last_accessed_at: Option<DateTime<Utc>>,
678 pub metadata: serde_json::Value,
679}
680
681#[derive(Debug, Clone, Serialize, Deserialize)]
683pub struct StoredFileSummary {
684 pub id: StoredFileId,
685 pub original_name: String,
686 pub field_name: Option<String>,
687 pub status: FileStatus,
688}
689
690#[derive(Debug, Clone, Serialize, Deserialize)]
692pub struct StoredFileRef {
693 pub id: StoredFileId,
694}
695
696#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
704pub struct ThumbnailId(pub Uuid);
705
706impl ThumbnailId {
707 pub fn new(id: Uuid) -> Self {
708 Self(id)
709 }
710
711 pub fn into_inner(self) -> Uuid {
712 self.0
713 }
714}
715
716impl From<Uuid> for ThumbnailId {
717 fn from(id: Uuid) -> Self {
718 Self(id)
719 }
720}
721
722impl From<ThumbnailId> for Uuid {
723 fn from(id: ThumbnailId) -> Self {
724 id.0
725 }
726}
727
728#[derive(Debug, Clone, Serialize, Deserialize)]
732pub struct ThumbnailDto {
733 pub id: ThumbnailId,
734 pub file_id: Uuid,
735 pub size: ThumbnailSize,
736 pub width: i32,
737 pub height: i32,
738 pub storage_key: String,
739 pub storage_backend: String,
740 pub mime_type: String,
741 pub format: String,
742 pub quality: i32,
743 pub size_bytes: i64,
744 pub generated_at: DateTime<Utc>,
745 pub generation_time_ms: Option<i32>,
746 pub source_version: i32,
747 pub cdn_url: Option<String>,
748 pub cache_expires_at: Option<DateTime<Utc>>,
749 pub is_stale: bool,
750 pub metadata: serde_json::Value,
751}
752
753#[derive(Debug, Clone, Serialize, Deserialize)]
755pub struct ThumbnailSummary {
756 pub id: ThumbnailId,
757}
758
759#[derive(Debug, Clone, Serialize, Deserialize)]
761pub struct ThumbnailRef {
762 pub id: ThumbnailId,
763}
764
765#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
773pub struct UploadSessionId(pub Uuid);
774
775impl UploadSessionId {
776 pub fn new(id: Uuid) -> Self {
777 Self(id)
778 }
779
780 pub fn into_inner(self) -> Uuid {
781 self.0
782 }
783}
784
785impl From<Uuid> for UploadSessionId {
786 fn from(id: Uuid) -> Self {
787 Self(id)
788 }
789}
790
791impl From<UploadSessionId> for Uuid {
792 fn from(id: UploadSessionId) -> Self {
793 id.0
794 }
795}
796
797#[derive(Debug, Clone, Serialize, Deserialize)]
801pub struct UploadSessionDto {
802 pub id: UploadSessionId,
803 pub bucket_id: Uuid,
804 pub user_id: Uuid,
805 pub path: String,
806 pub filename: String,
807 pub mime_type: Option<String>,
808 pub file_size: i64,
809 pub chunk_size: i32,
810 pub total_chunks: i32,
811 pub uploaded_chunks: i32,
812 pub status: UploadStatus,
813 pub storage_backend: StorageBackend,
814 pub completed_parts: Vec<i32>,
815 pub part_etags: Option<serde_json::Value>,
816 pub expires_at: DateTime<Utc>,
817 pub metadata: serde_json::Value,
818}
819
820#[derive(Debug, Clone, Serialize, Deserialize)]
822pub struct UploadSessionSummary {
823 pub id: UploadSessionId,
824 pub status: UploadStatus,
825}
826
827#[derive(Debug, Clone, Serialize, Deserialize)]
829pub struct UploadSessionRef {
830 pub id: UploadSessionId,
831}
832
833#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
841pub struct UserQuotaId(pub Uuid);
842
843impl UserQuotaId {
844 pub fn new(id: Uuid) -> Self {
845 Self(id)
846 }
847
848 pub fn into_inner(self) -> Uuid {
849 self.0
850 }
851}
852
853impl From<Uuid> for UserQuotaId {
854 fn from(id: Uuid) -> Self {
855 Self(id)
856 }
857}
858
859impl From<UserQuotaId> for Uuid {
860 fn from(id: UserQuotaId) -> Self {
861 id.0
862 }
863}
864
865#[derive(Debug, Clone, Serialize, Deserialize)]
869pub struct UserQuotaDto {
870 pub id: UserQuotaId,
871 pub user_id: Uuid,
872 pub limit_bytes: i64,
873 pub used_bytes: i64,
874 pub file_count: i32,
875 pub max_file_size: Option<i64>,
876 pub max_file_count: Option<i32>,
877 pub tier: String,
878 pub quota_status: QuotaStatus,
879 pub warning_threshold_percent: i32,
880 pub last_warning_sent_at: Option<DateTime<Utc>>,
881 pub peak_usage_bytes: i64,
882 pub peak_usage_at: Option<DateTime<Utc>>,
883 pub metadata: serde_json::Value,
884}
885
886#[derive(Debug, Clone, Serialize, Deserialize)]
888pub struct UserQuotaSummary {
889 pub id: UserQuotaId,
890}
891
892#[derive(Debug, Clone, Serialize, Deserialize)]
894pub struct UserQuotaRef {
895 pub id: UserQuotaId,
896}
897
898