dealroom/internal/model/models.go

146 lines
5.2 KiB
Go

package model
import (
"encoding/json"
"time"
)
// User represents a system user
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Role string `json:"role"` // admin, user
AvatarURL *string `json:"avatar_url,omitempty"`
CreatedAt time.Time `json:"created_at"`
LastLogin *time.Time `json:"last_login,omitempty"`
IsActive bool `json:"is_active"`
}
// Entry represents any content in the system (deal room, document, note, etc.)
type Entry struct {
ID string `json:"id"`
ParentID *string `json:"parent_id,omitempty"`
DealRoomID string `json:"deal_room_id"`
EntryType string `json:"entry_type"`
Title string `json:"title"`
Content json.RawMessage `json:"content"`
FilePath *string `json:"file_path,omitempty"`
FileSize *int64 `json:"file_size,omitempty"`
FileHash *string `json:"file_hash,omitempty"`
Embedding []byte `json:"-"` // Not included in JSON output
CreatedBy string `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Access represents RBAC permissions for entries
type Access struct {
ID string `json:"id"`
EntryID string `json:"entry_id"`
UserID string `json:"user_id"`
Permissions int `json:"permissions"` // Bitmask: read=1, write=2, delete=4, manage=8
GrantedBy string `json:"granted_by"`
GrantedAt time.Time `json:"granted_at"`
}
// Permission constants
const (
PermissionRead = 1
PermissionWrite = 2
PermissionDelete = 4
PermissionManage = 8
)
// HasPermission checks if access includes the given permission
func (a *Access) HasPermission(permission int) bool {
return a.Permissions&permission != 0
}
// Session represents a user session
type Session struct {
Token string `json:"token"`
UserID string `json:"user_id"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
LastUsed time.Time `json:"last_used"`
UserAgent *string `json:"user_agent,omitempty"`
IPAddress *string `json:"ip_address,omitempty"`
}
// IsExpired checks if the session has expired
func (s *Session) IsExpired() bool {
return time.Now().After(s.ExpiresAt)
}
// AuditLog represents an audit trail entry
type AuditLog struct {
ID string `json:"id"`
UserID *string `json:"user_id,omitempty"`
EntryID *string `json:"entry_id,omitempty"`
Action string `json:"action"`
Details json.RawMessage `json:"details,omitempty"`
IPAddress *string `json:"ip_address,omitempty"`
UserAgent *string `json:"user_agent,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// Deal Room specific content types
// DealRoomContent represents the content structure for deal room entries
type DealRoomContent struct {
Type string `json:"type"`
Description string `json:"description"`
Stage string `json:"stage"` // sourcing, loi, due_diligence, closing, completed
TargetCompany string `json:"target_company"`
DealValue string `json:"deal_value"`
Participants []DealParticipant `json:"participants"`
KeyDates map[string]string `json:"key_dates"`
ConfidentialityLevel string `json:"confidentiality_level"`
}
type DealParticipant struct {
Name string `json:"name"`
Role string `json:"role"`
Organization string `json:"organization"`
}
// DocumentContent represents the content structure for document entries
type DocumentContent struct {
Type string `json:"type"`
Category string `json:"category"` // nda, cim, financial_model, teaser, legal, dd_report
MimeType string `json:"mime_type"`
OriginalName string `json:"original_name"`
Version string `json:"version"`
Analysis *DocumentAnalysis `json:"analysis,omitempty"`
RequiresNDA bool `json:"requires_nda"`
}
type DocumentAnalysis struct {
Summary string `json:"summary"`
KeyMetrics []string `json:"key_metrics"`
RiskFactors []string `json:"risk_factors"`
AIConfidence float64 `json:"ai_confidence"`
}
// NoteContent represents the content structure for note/message entries
type NoteContent struct {
Type string `json:"type"`
Body string `json:"body"`
Mentions []string `json:"mentions"` // User IDs mentioned with @
Attachments []string `json:"attachments"` // Entry IDs referenced
ThreadContext string `json:"thread_context"` // Context for organizing conversations
}
// ActivityItem represents an item in the activity feed
type ActivityItem struct {
ID string `json:"id"`
UserID string `json:"user_id"`
UserName string `json:"user_name"`
Action string `json:"action"`
EntryID string `json:"entry_id"`
EntryType string `json:"entry_type"`
Title string `json:"title"`
Details json.RawMessage `json:"details,omitempty"`
CreatedAt time.Time `json:"created_at"`
}