A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
at main 74 lines 2.7 kB view raw
1package database 2 3import "time" 4 5// User represents a user in the system 6type User struct { 7 ID int `json:"id"` 8 GithubID int `json:"github_id"` 9 Username string `json:"username"` 10 Email string `json:"email"` 11 AvatarURL string `json:"avatar_url"` 12 CreatedAt time.Time `json:"created_at"` 13 UpdatedAt time.Time `json:"updated_at"` 14 LastRepo string `json:"last_repo"` 15} 16 17// UserRepo represents a repository associated with a user 18type UserRepo struct { 19 ID int `json:"id"` 20 UserID int `json:"user_id"` 21 RepoName string `json:"repo_name"` 22 RepoLink string `json:"repo_link"` 23 LastUsedAt time.Time `json:"last_used_at"` 24 CreatedAt time.Time `json:"created_at"` 25 UpdatedAt time.Time `json:"updated_at"` 26} 27 28// AuthToken represents an OAuth token for a provider 29type AuthToken struct { 30 ID int `json:"id"` 31 UserID int `json:"user_id"` 32 Provider string `json:"provider"` 33 AccessToken string `json:"-"` // Never expose in JSON 34 RefreshToken string `json:"-"` // Never expose in JSON 35 ExpiresAt time.Time `json:"expires_at"` 36 CreatedAt time.Time `json:"created_at"` 37} 38 39// BranchState tracks the state of a user's branch for a repository 40type BranchState struct { 41 ID int `json:"id"` 42 UserID int `json:"user_id"` 43 RepoFullName string `json:"repo_full_name"` 44 BranchName string `json:"branch_name"` 45 BaseBranch string `json:"base_branch"` 46 LastPushAt time.Time `json:"last_push_at"` 47 HasUncommittedChanges bool `json:"has_uncommitted_changes"` 48 FilePaths string `json:"file_paths"` // JSON array 49 CreatedAt time.Time `json:"created_at"` 50 UpdatedAt time.Time `json:"updated_at"` 51} 52 53// DraftContent represents auto-saved content 54type DraftContent struct { 55 ID int `json:"id"` 56 UserID int `json:"user_id"` 57 RepoFullName string `json:"repo_full_name"` 58 FilePath string `json:"file_path"` 59 Content string `json:"content"` 60 ChangeType string `json:"change_type"` // 'edit', 'new_file', 'new_folder', 'rename' 61 OriginalPath string `json:"original_path"` // For renames: old path 62 LastSavedAt time.Time `json:"last_saved_at"` 63} 64 65// CacheStat represents a cache statistics entry 66type CacheStat struct { 67 ID int `json:"id"` 68 CacheKey string `json:"cache_key"` 69 CacheType string `json:"cache_type"` 70 EventType string `json:"event_type"` 71 UserID *int `json:"user_id,omitempty"` 72 ResponseTimeMs int `json:"response_time_ms"` 73 CreatedAt time.Time `json:"created_at"` 74}