models

package
v1.0.80 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncTask

type AsyncTask struct {
	ID          string     `json:"id" gorm:"primaryKey"`
	Type        TaskType   `json:"type" gorm:"type:varchar(50);not null"`
	Status      TaskStatus `json:"status" gorm:"type:varchar(50);not null"`
	ResourceID  string     `json:"resource_id" gorm:"type:varchar(255);not null"` // ID of the resource being processed (e.g., repo ID)
	UserID      string     `json:"user_id" gorm:"type:varchar(255);not null"`     // ID of the user who initiated the task
	Message     string     `json:"message" gorm:"type:text"`                      // Status message or error message
	Progress    int        `json:"progress" gorm:"default:0"`                     // Progress percentage (0-100)
	StartedAt   *time.Time `json:"started_at"`                                    // When the task started running
	CompletedAt *time.Time `json:"completed_at"`                                  // When the task completed or failed
	CreatedAt   time.Time  `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt   time.Time  `json:"updated_at" gorm:"autoUpdateTime"`
}

AsyncTask represents an asynchronous task in the system

type ContentFormat

type ContentFormat string

ContentFormat represents the format of content in a collection

type CreateEventRequest

type CreateEventRequest struct {
	Level        EventLevel  `json:"level" binding:"required"`
	Source       EventSource `json:"source" binding:"required"`
	Message      string      `json:"message" binding:"required"`
	Details      string      `json:"details"`
	StackTrace   string      `json:"stack_trace"`
	UserID       *string     `json:"user_id"`
	ResourceID   *uint       `json:"resource_id"`
	ResourceType string      `json:"resource_type"`
	IPAddress    string      `json:"ip_address"`
	UserAgent    string      `json:"user_agent"`
}

CreateEventRequest is the structure for event creation requests

type CreateUserRequest

type CreateUserRequest struct {
	Username  string `json:"username" binding:"required"`
	Email     string `json:"email" binding:"required,email"`
	Password  string `json:"password" binding:"required,min=6"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

CreateUserRequest is the structure for user creation requests

type Event

type Event struct {
	ID           uint        `json:"id" gorm:"primaryKey"`
	Level        EventLevel  `json:"level" gorm:"type:string;not null;index"`
	Source       EventSource `json:"source" gorm:"type:string;not null;index"`
	Message      string      `json:"message" gorm:"not null"`
	Details      string      `json:"details" gorm:"type:text"`
	StackTrace   string      `json:"stack_trace" gorm:"type:text"`
	UserID       *string     `json:"user_id" gorm:"index"`
	User         *User       `json:"user" gorm:"foreignKey:UserID"`
	ResourceID   *uint       `json:"resource_id"`
	ResourceType string      `json:"resource_type" gorm:"index"`
	IPAddress    string      `json:"ip_address"`
	UserAgent    string      `json:"user_agent"`
	Resolved     bool        `json:"resolved" gorm:"default:false;index"`
	ResolvedAt   *time.Time  `json:"resolved_at"`
	ResolvedBy   *string     `json:"resolved_by"`
	CreatedAt    time.Time   `json:"created_at" gorm:"index"`
}

Event represents a system event or error

func (*Event) ToResponse

func (e *Event) ToResponse(includeDetails bool, includeUser bool) EventResponse

ToResponse converts an Event to an EventResponse

type EventLevel

type EventLevel string

EventLevel represents the severity level of an event

const (
	// EventLevelInfo represents an informational event
	EventLevelInfo EventLevel = "info"
	// EventLevelWarning represents a warning event
	EventLevelWarning EventLevel = "warning"
	// EventLevelError represents an error event
	EventLevelError EventLevel = "error"
	// EventLevelCritical represents a critical error event
	EventLevelCritical EventLevel = "critical"
)

type EventResponse

type EventResponse struct {
	ID           uint          `json:"id"`
	Level        EventLevel    `json:"level"`
	Source       EventSource   `json:"source"`
	Message      string        `json:"message"`
	Details      string        `json:"details,omitempty"`
	StackTrace   string        `json:"stack_trace,omitempty"`
	UserID       *string       `json:"user_id,omitempty"`
	User         *UserResponse `json:"user,omitempty"`
	ResourceID   *uint         `json:"resource_id,omitempty"`
	ResourceType string        `json:"resource_type,omitempty"`
	IPAddress    string        `json:"ip_address,omitempty"`
	UserAgent    string        `json:"user_agent,omitempty"`
	Resolved     bool          `json:"resolved"`
	ResolvedAt   *time.Time    `json:"resolved_at,omitempty"`
	ResolvedBy   *string       `json:"resolved_by,omitempty"`
	CreatedAt    time.Time     `json:"created_at"`
}

EventResponse is the structure returned to clients

type EventSource

type EventSource string

EventSource represents the source of an event

const (
	// EventSourceSystem represents a system-generated event
	EventSourceSystem EventSource = "system"
	// EventSourceUser represents a user-generated event
	EventSourceUser EventSource = "user"
	// EventSourceGitRepo represents a git repository-related event
	EventSourceGitRepo EventSource = "git_repo"
	// EventSourceAPI represents an API-related event
	EventSourceAPI EventSource = "api"
	// EventSourceDatabase represents a database-related event
	EventSourceDatabase EventSource = "database"
)

type Field

type Field struct {
	Type     string `yaml:"type" json:"type"`
	Name     string `yaml:"name" json:"name"`
	Label    string `yaml:"label" json:"label"`
	Required bool   `yaml:"required,omitempty" json:"required"`
	Format   string `yaml:"format,omitempty" json:"format"`
	List     bool   `yaml:"list,omitempty" json:"list"`
	Default  string `yaml:"default,omitempty" json:"default"`
}

type FileNameGenerator added in v1.0.48

type FileNameGenerator struct {
	Type  string `yaml:"type" json:"type"`
	First string `yaml:"first" json:"first"`
}

type FileUploadRequest

type FileUploadRequest struct {
	Path    string `json:"path" binding:"required"`
	Content string `json:"content"`
}

FileUploadRequest represents a request to upload a file

type GitHubAppSettings

type GitHubAppSettings struct {
	AppID          int64  `json:"app_id"`
	AppName        string `json:"app_name"`
	Description    string `json:"description"`
	HomepageURL    string `json:"homepage_url"`
	WebhookURL     string `json:"webhook_url"`
	WebhookSecret  string `json:"webhook_secret"`
	PrivateKeyPath string `json:"private_key_path"`
}

GitHubAppSettings contains configuration for the GitHub App

type GitHubAuthData

type GitHubAuthData struct {
	InstallationID int64 `json:"installation_id"`
}

GitHubAuthData represents authentication data for GitHub

type GitHubRepository

type GitHubRepository struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	FullName      string    `json:"full_name"`
	Private       bool      `json:"private"`
	HTMLURL       string    `json:"html_url"`
	CloneURL      string    `json:"clone_url"`
	DefaultBranch string    `json:"default_branch"`
	Description   string    `json:"description"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

GitHubRepository represents a GitHub repository

type GitHubUser

type GitHubUser struct {
	ID        string `json:"id"`
	Login     string `json:"login"`
	AvatarURL string `json:"avatar_url"`
	Type      string `json:"type"`
}

GitHubUser represents a GitHub user or organization

type GitRepoStatus

type GitRepoStatus string

GitRepoStatus represents the status of a git repository

const (
	// StatusSynced indicates the repository is in sync with remote
	StatusSynced GitRepoStatus = "synced"
	// StatusSyncing indicates the repository is currently syncing
	StatusSyncing GitRepoStatus = "syncing"
	// StatusFailed indicates the repository sync failed
	StatusFailed GitRepoStatus = "failed"
	// StatusPending indicates the repository is pending for sync
	StatusPending GitRepoStatus = "pending"
	// StatusWarning indicates the repository has a warning (e.g., missing config)
	StatusWarning GitRepoStatus = "warning"
)

type ImportRepositoriesRequest

type ImportRepositoriesRequest struct {
	UserID        string  `json:"user_id"`
	RepositoryIDs []int64 `json:"repositories" binding:"required"`
}

ImportRepositoriesRequest represents a request to import repositories from GitHub

type Role

type Role struct {
	gorm.Model         // Includes fields ID, CreatedAt, UpdatedAt, DeletedAt
	Name        string `gorm:"uniqueIndex;not null;size:50"` // Role name (e.g., "admin", "editor")
	Description string `gorm:"size:255"`                     // Optional description
	Quota       bool   `gorm:"default:false"`

	// --- Relationships ---
	// Many-to-Many relationship with User (inverse of User.Roles)
	Users []*User `gorm:"many2many:user_roles;"` // Use pointer slice []*User
}

type SiteSetting

type SiteSetting struct {
	gorm.Model
	Key   string `json:"key"`
	Value string `json:"value"`
}

type TaskStatus

type TaskStatus string

TaskStatus represents the status of an async task

const (
	// TaskStatusPending indicates the task is waiting to be processed
	TaskStatusPending TaskStatus = "pending"
	// TaskStatusRunning indicates the task is currently running
	TaskStatusRunning TaskStatus = "running"
	// TaskStatusCompleted indicates the task has completed successfully
	TaskStatusCompleted TaskStatus = "completed"
	// TaskStatusFailed indicates the task has failed
	TaskStatusFailed TaskStatus = "failed"
)

type TaskType

type TaskType string

TaskType represents the type of async task

const (
	// TaskTypeSync indicates a repository sync task
	TaskTypeSync TaskType = "sync"
)

type UpdateUserGitRepoRequest

type UpdateUserGitRepoRequest struct {
	Name           string        `json:"name"`
	Description    string        `json:"description"`
	RemoteURL      string        `json:"remote_url"`
	CloneURL       string        `json:"clone_url"`
	Branch         string        `json:"branch"`
	AuthType       string        `json:"auth_type"`
	AuthData       string        `json:"auth_data"`
	Status         GitRepoStatus `json:"status"`
	ErrorMsg       string        `json:"error_msg"`
	InstallationID int64         `json:"installation_id"`
}

UpdateUserGitRepoRequest is the structure for repository update requests

type UpdateUserRequest

type UpdateUserRequest struct {
	Email     string `json:"email" binding:"omitempty,email"`
	Password  string `json:"password" binding:"omitempty,min=6"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

UpdateUserRequest is the structure for user update requests

type User

type User struct {
	ID         string    `json:"id" gorm:"primaryKey;type:text"`
	Username   string    `json:"username" gorm:"unique;not null"`
	Email      string    `json:"email" gorm:"unique;not null"`
	Password   string    `json:"-"` // Password is not exposed in JSON
	Name       string    `json:"name"`
	FirstName  string    `json:"first_name"`
	LastName   string    `json:"last_name"`
	AvatarURL  string    `json:"avatar_url"`
	Provider   string    `json:"provider"`    // OAuth provider (github, google, etc.)
	ProviderID string    `json:"provider_id"` // ID from the OAuth provider
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	IsActive   bool      `json:"is_active"`
	Roles      []*Role   `gorm:"many2many:user_roles;"` // Use pointer slice []*Role
}

User represents a user in the system

func (*User) GetQuotaRole

func (u *User) GetQuotaRole() *Role

func (*User) ToResponse

func (u *User) ToResponse() UserResponse

ToResponse converts a User to a UserResponse

func (*User) ToResponseWithExpires

func (u *User) ToResponseWithExpires(expireInt int64) UserResponse

type UserFileDraftStatus added in v1.0.42

type UserFileDraftStatus struct {
	ID             uint `gorm:"primaryKey"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
	UserID         string `gorm:"index:idx_user_repo_collection,not null"`
	RepoID         uint   `gorm:"index:idx_user_repo_collection,not null"`
	CollectionName string `gorm:"index:idx_user_repo_collection,not null"`
	FilePath       string `gorm:"not null"`
	Draft          bool   `gorm:"not null"`
}

type UserGitRepo

type UserGitRepo struct {
	ID             uint          `json:"id" gorm:"primaryKey"`
	GitRepoID      int64         `json:"git_repo_id" gorm:"not null"`
	Name           string        `json:"name" gorm:"not null"`
	Description    string        `json:"description"`
	LocalPath      string        `json:"local_path" gorm:"not null"`
	RemoteURL      string        `json:"remote_url" gorm:"not null"`
	CloneURL       string        `json:"clone_url"`
	Branch         string        `json:"branch" gorm:"default:main"`
	UserID         string        `json:"user_id" gorm:"not null"`
	User           User          `json:"user" gorm:"foreignKey:UserID"`
	AuthType       string        `json:"auth_type" gorm:"default:'none'"`
	AuthData       string        `json:"auth_data"`
	Provider       string        `json:"provider" gorm:"default:'git'"`
	LastSyncAt     time.Time     `json:"last_sync_at"`
	Status         GitRepoStatus `json:"status" gorm:"type:string;default:'pending'"`
	ErrorMsg       string        `json:"error_msg"`
	CreatedAt      time.Time     `json:"created_at"`
	UpdatedAt      time.Time     `json:"updated_at"`
	InstallationID int64         `json:"installation_id"`
}

UserGitRepo represents a git repository associated with a user

func (*UserGitRepo) ToResponse

func (r *UserGitRepo) ToResponse(includeUser bool) UserGitRepoResponse

ToResponse converts a UserGitRepo to a UserGitRepoResponse

type UserGitRepoCollection

type UserGitRepoCollection struct {
	ID                uint               `json:"id" gorm:"primaryKey"`
	Name              string             `json:"name" gorm:"not null"`
	Label             string             `json:"label" gorm:"not null"`
	Path              string             `json:"path" gorm:"not null"`
	Format            ContentFormat      `json:"format" gorm:"type:string;not null;default:'md'"`
	Description       string             `json:"description"`
	RepoID            uint               `json:"repo_id" gorm:"not null"`
	Repo              UserGitRepo        `json:"repo" gorm:"foreignKey:RepoID"`
	CreatedAt         time.Time          `json:"created_at"`
	UpdatedAt         time.Time          `json:"updated_at"`
	Fields            []Field            `json:"fields" gorm:"foreignKey:CollectionID"`
	FileNameGenerator *FileNameGenerator `json:"file_name_generator" gorm:"foreignKey:CollectionID"`
}

UserGitRepoCollection represents a collection of content within a git repository

func (*UserGitRepoCollection) ToResponse

func (c *UserGitRepoCollection) ToResponse(includeRepo bool) UserGitRepoCollectionResponse

ToResponse converts a UserGitRepoCollection to a UserGitRepoCollectionResponse

type UserGitRepoCollectionResponse

type UserGitRepoCollectionResponse struct {
	ID                uint                `json:"id"`
	Name              string              `json:"name"`
	Label             string              `json:"label"`
	Path              string              `json:"path"`
	Format            ContentFormat       `json:"format"`
	Description       string              `json:"description,omitempty"`
	RepoID            uint                `json:"repo_id"`
	Repo              UserGitRepoResponse `json:"repo,omitempty"`
	CreatedAt         time.Time           `json:"created_at"`
	UpdatedAt         time.Time           `json:"updated_at"`
	Fields            []Field             `json:"fields,omitempty"`
	FileNameGenerator *FileNameGenerator  `json:"file_name_generator,omitempty"`
}

UserGitRepoCollectionResponse is the structure returned to clients

type UserGitRepoResponse

type UserGitRepoResponse struct {
	ID             uint          `json:"id"`
	Name           string        `json:"name"`
	Description    string        `json:"description"`
	LocalPath      string        `json:"local_path"`
	RemoteURL      string        `json:"remote_url"`
	CloneURL       string        `json:"clone_url"`
	Branch         string        `json:"branch"`
	UserID         string        `json:"user_id"`
	User           UserResponse  `json:"user,omitempty"`
	AuthType       string        `json:"auth_type"`
	LastSyncAt     time.Time     `json:"last_sync_at"`
	Status         GitRepoStatus `json:"status"`
	ErrorMsg       string        `json:"error_msg,omitempty"`
	CreatedAt      time.Time     `json:"created_at"`
	UpdatedAt      time.Time     `json:"updated_at"`
	InstallationID int64         `json:"installation_id"`
}

UserGitRepoResponse is the structure returned to clients

type UserResponse

type UserResponse struct {
	ID        string    `json:"id"`
	Username  string    `json:"username"`
	Email     string    `json:"email"`
	Name      string    `json:"name"`
	FirstName string    `json:"first_name"`
	LastName  string    `json:"last_name"`
	AvatarURL string    `json:"avatar_url"`
	Provider  string    `json:"provider"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	ExpiresAt int64     `json:"expires_at"`
}

UserResponse is the structure returned to clients

type UserRoleQuota

type UserRoleQuota struct {
	gorm.Model
	Role      *Role `gorm:"foreignKey:RoleID"`
	RoleID    string
	RepoCount int
	DocSize   int `gorm:"type:bigint;default:100"` // MB
}

type UserStorage

type UserStorage struct {
	gorm.Model
	UserID     string `gorm:"not null uniqueIndex"`
	User       User   `gorm:"foreignKey:UserID"`
	BucketName string
}

type UserStorageFile

type UserStorageFile struct {
	gorm.Model
	UserStorageID uint
	UserStorage   UserStorage `gorm:"foreignKey:UserStorageID"`
	FileName      string      // origin file name
	Url           string      // /repo/:repoId/:collectionName/storage/2025-04-18-{collectionName}-uuid.xxx
	Path          string      `gorm:"index"` // 2025-04/{collectionName}-uuid.xxx minio path
	ContentType   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL