1use serde::{Deserialize, Serialize};
8use std::collections::HashMap;
9use std::path::PathBuf;
10use std::time::{Duration, SystemTime};
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct WorkflowConfig {
19 pub enable_task_delegation: bool,
20 pub enable_report_generation: bool,
21 pub enable_data_export: bool,
22 pub enable_notifications: bool,
23 pub enable_approval_workflows: bool,
24 pub enable_audit_trails: bool,
25 pub export_directory: PathBuf,
26 pub report_directory: PathBuf,
27 pub audit_directory: PathBuf,
28 pub max_concurrent_tasks: usize,
29 pub task_timeout: Duration,
30}
31
32impl Default for WorkflowConfig {
33 fn default() -> Self {
34 Self {
35 enable_task_delegation: true,
36 enable_report_generation: true,
37 enable_data_export: true,
38 enable_notifications: true,
39 enable_approval_workflows: true,
40 enable_audit_trails: true,
41 export_directory: PathBuf::from("./exports"),
42 report_directory: PathBuf::from("./reports"),
43 audit_directory: PathBuf::from("./audit"),
44 max_concurrent_tasks: 10,
45 task_timeout: Duration::from_secs(300),
46 }
47 }
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct TaskRequest {
57 pub title: String,
58 pub description: String,
59 pub task_type: TaskType,
60 pub assignee: String,
61 pub deadline: Option<SystemTime>,
62 pub priority: TaskPriority,
63 pub dependencies: Vec<String>,
64 pub metadata: HashMap<String, String>,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct Task {
70 pub id: TaskId,
71 pub request: TaskRequest,
72 pub status: TaskStatus,
73 pub created_at: SystemTime,
74 pub updated_at: SystemTime,
75 pub assigned_to: String,
76 pub deadline: Option<SystemTime>,
77 pub priority: TaskPriority,
78 pub dependencies: Vec<String>,
79 pub metadata: HashMap<String, String>,
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84pub struct TaskId(pub String);
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
88pub enum TaskType {
89 DataAnalysis,
90 ReportGeneration,
91 DataValidation,
92 QueryOptimization,
93 KnowledgeUpdate,
94 UserSupport,
95 SystemMaintenance,
96 Custom(String),
97}
98
99#[derive(Debug, Clone, Serialize, Deserialize)]
101pub enum TaskStatus {
102 Pending,
103 InProgress,
104 Completed,
105 Failed,
106 Cancelled,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
111pub enum TaskPriority {
112 Low,
113 Medium,
114 High,
115 Critical,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
124pub struct ReportRequest {
125 pub title: String,
126 pub report_type: ReportType,
127 pub format: ReportFormat,
128 pub time_range: TimeRange,
129 pub filters: HashMap<String, String>,
130 pub include_charts: bool,
131 pub include_raw_data: bool,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct ReportResult {
137 pub title: String,
138 pub format: ReportFormat,
139 pub file_path: PathBuf,
140 pub generated_at: SystemTime,
141 pub size_bytes: u64,
142 pub metadata: HashMap<String, String>,
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
147pub enum ReportType {
148 ConversationSummary,
149 PerformanceMetrics,
150 UsageAnalytics,
151 ErrorReport,
152 UserSatisfaction,
153 QueryAnalysis,
154 Custom(String),
155}
156
157#[derive(Debug, Clone, Serialize, Deserialize)]
159pub enum ReportFormat {
160 PDF,
161 HTML,
162 CSV,
163 JSON,
164 Excel,
165 Markdown,
166}
167
168impl std::fmt::Display for ReportFormat {
169 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
170 match self {
171 ReportFormat::PDF => write!(f, "PDF"),
172 ReportFormat::HTML => write!(f, "HTML"),
173 ReportFormat::CSV => write!(f, "CSV"),
174 ReportFormat::JSON => write!(f, "JSON"),
175 ReportFormat::Excel => write!(f, "Excel"),
176 ReportFormat::Markdown => write!(f, "Markdown"),
177 }
178 }
179}
180
181#[derive(Debug, Clone, Serialize, Deserialize)]
187pub struct ExportRequest {
188 pub data_type: DataType,
189 pub format: ExportFormat,
190 pub time_range: TimeRange,
191 pub filters: HashMap<String, String>,
192 pub compression: bool,
193}
194
195#[derive(Debug, Clone, Serialize, Deserialize)]
197pub struct ExportResult {
198 pub filename: String,
199 pub format: ExportFormat,
200 pub file_path: PathBuf,
201 pub exported_at: SystemTime,
202 pub record_count: usize,
203 pub size_bytes: u64,
204}
205
206#[derive(Debug, Clone, Serialize, Deserialize)]
208pub enum DataType {
209 Messages,
210 Sessions,
211 Analytics,
212 AuditLogs,
213 UserProfiles,
214 QueryHistory,
215 All,
216}
217
218#[derive(Debug, Clone, Serialize, Deserialize)]
220pub enum ExportFormat {
221 JSON,
222 CSV,
223 Parquet,
224 Avro,
225 XML,
226}
227
228impl std::fmt::Display for ExportFormat {
229 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
230 match self {
231 ExportFormat::JSON => write!(f, "JSON"),
232 ExportFormat::CSV => write!(f, "CSV"),
233 ExportFormat::Parquet => write!(f, "Parquet"),
234 ExportFormat::Avro => write!(f, "Avro"),
235 ExportFormat::XML => write!(f, "XML"),
236 }
237 }
238}
239
240#[derive(Debug, Clone, Serialize, Deserialize)]
246pub struct ApprovalRequest {
247 pub id: Option<ApprovalId>,
248 pub title: String,
249 pub description: String,
250 pub request_type: ApprovalType,
251 pub requester: String,
252 pub approvers: Vec<String>,
253 pub required_approvals: usize,
254 pub status: ApprovalStatus,
255 pub submitted_at: Option<SystemTime>,
256 pub processed_at: Option<SystemTime>,
257 pub decision: Option<ApprovalDecision>,
258 pub metadata: HashMap<String, String>,
259}
260
261#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
263pub struct ApprovalId(pub String);
264
265#[derive(Debug, Clone, Serialize, Deserialize)]
267pub struct ApprovalDecision {
268 pub approved: bool,
269 pub approver: String,
270 pub comments: String,
271 pub decided_at: SystemTime,
272}
273
274#[derive(Debug, Clone, Serialize, Deserialize)]
276pub enum ApprovalType {
277 DataAccess,
278 FeatureActivation,
279 ConfigurationChange,
280 UserPermission,
281 DataExport,
282 SystemUpgrade,
283 Custom(String),
284}
285
286#[derive(Debug, Clone, Serialize, Deserialize)]
288pub enum ApprovalStatus {
289 Pending,
290 Approved,
291 Rejected,
292 Expired,
293}
294
295#[derive(Debug, Clone, Serialize, Deserialize)]
301pub struct Notification {
302 pub recipient: String,
303 pub notification_type: NotificationType,
304 pub title: String,
305 pub message: String,
306 pub priority: NotificationPriority,
307 pub channel: NotificationChannel,
308 pub metadata: HashMap<String, String>,
309}
310
311#[derive(Debug, Clone, Serialize, Deserialize)]
313pub enum NotificationType {
314 TaskAssignment,
315 TaskCompletion,
316 ApprovalRequest,
317 ApprovalDecision,
318 SystemAlert,
319 UserMessage,
320 Custom(String),
321}
322
323#[derive(Debug, Clone, Serialize, Deserialize)]
325pub enum NotificationPriority {
326 Low,
327 Medium,
328 High,
329 Urgent,
330}
331
332#[derive(Debug, Clone, Serialize, Deserialize)]
334pub enum NotificationChannel {
335 Email,
336 SMS,
337 InApp,
338 Webhook,
339 Slack,
340 Teams,
341}
342
343#[derive(Debug, Clone, Serialize, Deserialize)]
349pub struct TimeRange {
350 pub start: SystemTime,
351 pub end: SystemTime,
352}
353
354#[derive(Debug, Clone, Serialize, Deserialize)]
360pub struct AuditEntry {
361 pub id: String,
362 pub entity_id: String,
363 pub action: AuditAction,
364 pub actor: String,
365 pub timestamp: SystemTime,
366 pub details: HashMap<String, String>,
367 pub ip_address: Option<String>,
368 pub user_agent: Option<String>,
369}
370
371#[derive(Debug, Clone, Serialize, Deserialize)]
373pub enum AuditAction {
374 TaskCreated,
375 TaskUpdated,
376 TaskCompleted,
377 ReportGenerated,
378 DataExported,
379 ApprovalRequested,
380 ApprovalDecided,
381 ConfigurationChanged,
382 UserAction(String),
383}
384
385#[derive(Debug, Clone, Serialize, Deserialize)]
391pub struct CollaborativeWorkspace {
392 pub id: WorkspaceId,
393 pub name: String,
394 pub description: Option<String>,
395 pub owner: String,
396 pub members: Vec<WorkspaceMember>,
397 pub permissions: WorkspacePermissions,
398 pub shared_documents: Vec<SharedDocument>,
399 pub active_collaborations: Vec<ActiveCollaboration>,
400 pub settings: WorkspaceSettings,
401 pub created_at: SystemTime,
402 pub updated_at: SystemTime,
403}
404
405#[derive(Debug, Clone, Serialize, Deserialize)]
407pub struct WorkspaceId(pub String);
408
409#[derive(Debug, Clone, Serialize, Deserialize)]
411pub struct SessionToken(pub String);
412
413#[derive(Debug, Clone, Serialize, Deserialize)]
415pub struct MessageId(pub String);
416
417#[derive(Debug, Clone, Serialize, Deserialize)]
419pub struct DecisionId(pub String);
420
421#[derive(Debug, Clone, Serialize, Deserialize)]
423pub struct WorkspaceMember {
424 pub user_id: String,
425 pub role: WorkspaceRole,
426 pub permissions: UserPermissions,
427 pub joined_at: SystemTime,
428 pub last_active: SystemTime,
429}
430
431#[derive(Debug, Clone, Serialize, Deserialize)]
433pub enum WorkspaceRole {
434 Owner,
435 Admin,
436 Editor,
437 Viewer,
438 Guest,
439}
440
441#[derive(Debug, Clone, Serialize, Deserialize)]
443pub struct UserPermissions {
444 pub can_edit_documents: bool,
445 pub can_create_documents: bool,
446 pub can_delete_documents: bool,
447 pub can_invite_users: bool,
448 pub can_manage_permissions: bool,
449 pub can_start_decisions: bool,
450 pub can_vote: bool,
451 pub can_moderate: bool,
452}
453
454impl Default for UserPermissions {
455 fn default() -> Self {
456 Self {
457 can_edit_documents: true,
458 can_create_documents: true,
459 can_delete_documents: false,
460 can_invite_users: false,
461 can_manage_permissions: false,
462 can_start_decisions: true,
463 can_vote: true,
464 can_moderate: false,
465 }
466 }
467}
468
469#[derive(Debug, Clone, Serialize, Deserialize)]
471pub struct WorkspacePermissions {
472 pub public_readable: bool,
473 pub allow_anonymous_access: bool,
474 pub require_approval_for_members: bool,
475 pub default_member_permissions: UserPermissions,
476}
477
478#[derive(Debug, Clone, Serialize, Deserialize)]
480pub struct WorkspaceSettings {
481 pub enable_real_time_editing: bool,
482 pub enable_presence_awareness: bool,
483 pub enable_chat: bool,
484 pub enable_video_calls: bool,
485 pub enable_decision_voting: bool,
486 pub auto_save_interval: std::time::Duration,
487 pub max_concurrent_editors: usize,
488 pub session_timeout: std::time::Duration,
489}
490
491impl Default for WorkspaceSettings {
492 fn default() -> Self {
493 Self {
494 enable_real_time_editing: true,
495 enable_presence_awareness: true,
496 enable_chat: true,
497 enable_video_calls: false,
498 enable_decision_voting: true,
499 auto_save_interval: std::time::Duration::from_secs(10),
500 max_concurrent_editors: 50,
501 session_timeout: std::time::Duration::from_secs(8 * 3600),
502 }
503 }
504}
505
506#[derive(Debug, Clone, Serialize, Deserialize)]
508pub struct CreateWorkspaceRequest {
509 pub name: String,
510 pub description: Option<String>,
511 pub owner: String,
512 pub initial_members: Vec<WorkspaceMember>,
513 pub permissions: WorkspacePermissions,
514 pub settings: Option<WorkspaceSettings>,
515}
516
517#[derive(Debug, Clone, Serialize, Deserialize)]
519pub struct UserInfo {
520 pub name: String,
521 pub email: String,
522 pub avatar_url: Option<String>,
523 pub timezone: String,
524 pub preferences: UserPreferences,
525}
526
527#[derive(Debug, Clone, Serialize, Deserialize)]
529pub struct UserPreferences {
530 pub enable_notifications: bool,
531 pub notification_types: Vec<NotificationType>,
532 pub presence_status: PresenceStatus,
533 pub auto_join_calls: bool,
534}
535
536#[derive(Debug, Clone, Serialize, Deserialize)]
538pub enum PresenceStatus {
539 Online,
540 Away,
541 Busy,
542 DoNotDisturb,
543 Offline,
544}
545
546#[derive(Debug, Clone, Serialize, Deserialize)]
548pub struct CollaborativeSession {
549 pub token: SessionToken,
550 pub workspace_id: WorkspaceId,
551 pub user_id: String,
552 pub user_info: UserInfo,
553 pub joined_at: SystemTime,
554 pub last_activity: SystemTime,
555 pub active_documents: Vec<String>,
556 pub permissions: UserPermissions,
557}
558
559#[derive(Debug, Clone, Serialize, Deserialize)]
561pub struct UserPresence {
562 pub user_id: String,
563 pub status: PresenceStatus,
564 pub last_seen: SystemTime,
565 pub current_activity: Option<String>,
566 pub cursor_position: Option<CursorPosition>,
567 pub viewing_document: Option<String>,
568}
569
570#[derive(Debug, Clone, Serialize, Deserialize)]
572pub struct CursorPosition {
573 pub document_id: String,
574 pub line: u32,
575 pub column: u32,
576 pub selection_start: Option<(u32, u32)>,
577 pub selection_end: Option<(u32, u32)>,
578}
579
580#[derive(Debug, Clone, Serialize, Deserialize)]
582pub struct CollaborativeMessage {
583 pub id: Option<MessageId>,
584 pub sender_id: String,
585 pub message_type: MessageType,
586 pub content: String,
587 pub thread_id: Option<String>,
588 pub reply_to: Option<MessageId>,
589 pub mentions: Vec<String>,
590 pub attachments: Vec<MessageAttachment>,
591 pub reactions: Vec<MessageReaction>,
592 pub timestamp: Option<SystemTime>,
593 pub edited_at: Option<SystemTime>,
594}
595
596#[derive(Debug, Clone, Serialize, Deserialize)]
598pub enum MessageType {
599 Text,
600 System,
601 Notification,
602 DocumentUpdate,
603 VideoCall,
604 Decision,
605 Poll,
606}
607
608#[derive(Debug, Clone, Serialize, Deserialize)]
610pub struct MessageAttachment {
611 pub file_id: String,
612 pub filename: String,
613 pub file_type: String,
614 pub size_bytes: u64,
615 pub url: String,
616}
617
618#[derive(Debug, Clone, Serialize, Deserialize)]
620pub struct MessageReaction {
621 pub emoji: String,
622 pub user_id: String,
623 pub timestamp: SystemTime,
624}
625
626#[derive(Debug, Clone, Serialize, Deserialize)]
628pub struct SharedDocument {
629 pub id: String,
630 pub name: String,
631 pub document_type: DocumentType,
632 pub content: String,
633 pub version: u64,
634 pub created_by: String,
635 pub created_at: SystemTime,
636 pub last_modified_by: String,
637 pub last_modified_at: SystemTime,
638 pub collaborators: Vec<String>,
639 pub permissions: DocumentPermissions,
640}
641
642#[derive(Debug, Clone, Serialize, Deserialize)]
644pub enum DocumentType {
645 SparqlQuery,
646 MarkdownDocument,
647 JsonDocument,
648 CodeFile { language: String },
649 Whiteboard,
650 Spreadsheet,
651 Presentation,
652}
653
654#[derive(Debug, Clone, Serialize, Deserialize)]
656pub struct DocumentPermissions {
657 pub public_readable: bool,
658 pub editors: Vec<String>,
659 pub viewers: Vec<String>,
660 pub allow_comments: bool,
661 pub allow_suggestions: bool,
662}
663
664#[derive(Debug, Clone, Serialize, Deserialize)]
666pub struct CollaborativeEditingSession {
667 pub session_id: String,
668 pub workspace_id: WorkspaceId,
669 pub document_id: String,
670 pub user_id: String,
671 pub document_type: DocumentType,
672 pub started_at: SystemTime,
673 pub last_edit: SystemTime,
674 pub cursor_position: Option<CursorPosition>,
675 pub pending_operations: Vec<EditOperation>,
676}
677
678#[derive(Debug, Clone, Serialize, Deserialize)]
680pub struct EditOperation {
681 pub operation_id: String,
682 pub operation_type: OperationType,
683 pub position: TextPosition,
684 pub content: String,
685 pub timestamp: SystemTime,
686 pub user_id: String,
687}
688
689#[derive(Debug, Clone, Serialize, Deserialize)]
691pub enum OperationType {
692 Insert,
693 Delete,
694 Replace,
695 FormatApply,
696 Comment,
697 Suggestion,
698}
699
700#[derive(Debug, Clone, Serialize, Deserialize)]
702pub struct TextPosition {
703 pub line: u32,
704 pub column: u32,
705 pub offset: u32,
706}
707
708#[derive(Debug, Clone, Serialize, Deserialize)]
710pub struct ActiveCollaboration {
711 pub collaboration_id: String,
712 pub collaboration_type: CollaborationType,
713 pub participants: Vec<String>,
714 pub started_by: String,
715 pub started_at: SystemTime,
716 pub status: CollaborationStatus,
717 pub context: serde_json::Value,
718}
719
720#[derive(Debug, Clone, Serialize, Deserialize)]
722pub enum CollaborationType {
723 DocumentEditing,
724 VideoCall,
725 ScreenShare,
726 Brainstorming,
727 DecisionMaking,
728 ReviewSession,
729}
730
731#[derive(Debug, Clone, Serialize, Deserialize)]
733pub enum CollaborationStatus {
734 Active,
735 Paused,
736 Completed,
737 Cancelled,
738}
739
740#[derive(Debug, Clone, Serialize, Deserialize)]
746pub struct DecisionRequest {
747 pub title: String,
748 pub description: String,
749 pub decision_type: DecisionType,
750 pub options: Vec<DecisionOption>,
751 pub eligible_voters: Vec<String>,
752 pub deadline: Option<SystemTime>,
753}
754
755#[derive(Debug, Clone, Serialize, Deserialize)]
757pub struct DecisionProcess {
758 pub id: DecisionId,
759 pub workspace_id: WorkspaceId,
760 pub initiator_id: String,
761 pub title: String,
762 pub description: String,
763 pub decision_type: DecisionType,
764 pub options: Vec<DecisionOption>,
765 pub eligible_voters: Vec<String>,
766 pub votes: HashMap<String, Vote>,
767 pub comments: Vec<DecisionComment>,
768 pub deadline: Option<SystemTime>,
769 pub status: DecisionStatus,
770 pub created_at: SystemTime,
771 pub updated_at: SystemTime,
772}
773
774#[derive(Debug, Clone, Serialize, Deserialize)]
776pub enum DecisionType {
777 SingleChoice,
778 MultipleChoice,
779 Ranking,
780 YesNo,
781 Consensus,
782 Budget,
783}
784
785#[derive(Debug, Clone, Serialize, Deserialize)]
787pub struct DecisionOption {
788 pub id: String,
789 pub title: String,
790 pub description: Option<String>,
791 pub proposed_by: String,
792 pub vote_count: u32,
793}
794
795#[derive(Debug, Clone, Serialize, Deserialize)]
797pub struct Vote {
798 pub voter_id: String,
799 pub option_ids: Vec<String>,
800 pub ranking: Option<Vec<String>>,
801 pub comment: Option<String>,
802 pub timestamp: SystemTime,
803}
804
805#[derive(Debug, Clone, Serialize, Deserialize)]
807pub struct DecisionComment {
808 pub id: String,
809 pub author_id: String,
810 pub content: String,
811 pub timestamp: SystemTime,
812 pub replies: Vec<DecisionComment>,
813}
814
815#[derive(Debug, Clone, Serialize, Deserialize)]
817pub enum DecisionStatus {
818 Open,
819 Closed,
820 Cancelled,
821 Implemented,
822}
823
824#[derive(Debug, Clone, Serialize, Deserialize)]
830pub struct ActivityEvent {
831 pub id: String,
832 pub workspace_id: WorkspaceId,
833 pub event_type: ActivityEventType,
834 pub actor_id: String,
835 pub target_id: Option<String>,
836 pub description: String,
837 pub timestamp: SystemTime,
838 pub metadata: HashMap<String, String>,
839}
840
841#[derive(Debug, Clone, Serialize, Deserialize)]
843pub enum ActivityEventType {
844 UserJoined,
845 UserLeft,
846 DocumentCreated,
847 DocumentEdited,
848 DocumentShared,
849 MessageSent,
850 DecisionStarted,
851 DecisionVoted,
852 CollaborationStarted,
853 CollaborationEnded,
854}
855
856pub struct WorkflowManager {
862 pub(crate) config: WorkflowConfig,
863 pub(crate) active_tasks: HashMap<String, Task>,
864 pub(crate) approval_queue: Vec<ApprovalRequest>,
865 pub(crate) audit_logger: AuditLogger,
866 pub(crate) notification_service: NotificationService,
867 pub(crate) report_generator: ReportGenerator,
868 pub(crate) data_exporter: DataExporter,
869}
870
871pub(crate) struct AuditLogger {
873 pub(crate) config: WorkflowConfig,
874}
875
876pub(crate) struct NotificationService {
878 #[allow(dead_code)]
879 pub(crate) config: WorkflowConfig,
880}
881
882pub(crate) struct ReportGenerator {
884 pub(crate) config: WorkflowConfig,
885}
886
887pub(crate) struct DataExporter {
889 pub(crate) config: WorkflowConfig,
890}
891
892pub struct CollaborativeWorkspaceManager {
894 pub(crate) workspaces: HashMap<String, CollaborativeWorkspace>,
895 pub(crate) active_sessions: HashMap<String, CollaborativeSession>,
896 pub(crate) presence_tracker: PresenceTracker,
897 pub(crate) message_bus: CollaborativeMessageBus,
898 pub(crate) shared_document_manager: SharedDocumentManager,
899 pub(crate) decision_tracker: CollaborativeDecisionTracker,
900}
901
902pub struct PresenceTracker {
904 pub(crate) workspace_presence: HashMap<String, Vec<UserPresence>>,
905}
906
907pub struct CollaborativeMessageBus {
909 pub(crate) message_history: HashMap<String, Vec<CollaborativeMessage>>,
910 pub(crate) _subscribers: HashMap<String, Vec<String>>,
911}
912
913pub struct SharedDocumentManager {
915 pub(crate) _documents: HashMap<String, SharedDocument>,
916 pub(crate) editing_sessions: HashMap<String, Vec<CollaborativeEditingSession>>,
917}
918
919pub struct CollaborativeDecisionTracker {
921 pub(crate) active_decisions: HashMap<String, DecisionProcess>,
922}