67 lines
2.2 KiB
Go
67 lines
2.2 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// =========================================
|
|
// WORKSPACES (v0.21.0)
|
|
// =========================================
|
|
|
|
// Workspace owner type constants.
|
|
const (
|
|
WorkspaceOwnerUser = "user"
|
|
WorkspaceOwnerProject = "project"
|
|
WorkspaceOwnerChannel = "channel"
|
|
WorkspaceOwnerTeam = "team"
|
|
)
|
|
|
|
// Workspace status constants.
|
|
const (
|
|
WorkspaceStatusActive = "active"
|
|
WorkspaceStatusArchived = "archived"
|
|
WorkspaceStatusDeleting = "deleting"
|
|
)
|
|
|
|
// Workspace represents a file workspace bound to an owner (user, project, channel, or team).
|
|
type Workspace struct {
|
|
BaseModel
|
|
OwnerType string `json:"owner_type" db:"owner_type"`
|
|
OwnerID string `json:"owner_id" db:"owner_id"`
|
|
Name string `json:"name" db:"name"`
|
|
RootPath string `json:"-" db:"root_path"` // never expose filesystem path
|
|
MaxBytes *int64 `json:"max_bytes,omitempty" db:"max_bytes"`
|
|
Status string `json:"status" db:"status"`
|
|
|
|
// Computed fields (not DB columns)
|
|
FileCount int `json:"file_count,omitempty"`
|
|
TotalBytes int64 `json:"total_bytes,omitempty"`
|
|
}
|
|
|
|
// WorkspacePatch holds optional fields for updating a workspace.
|
|
type WorkspacePatch struct {
|
|
Name *string `json:"name,omitempty"`
|
|
MaxBytes *int64 `json:"max_bytes,omitempty"`
|
|
Status *string `json:"status,omitempty"`
|
|
}
|
|
|
|
// WorkspaceFile represents metadata for a single file or directory in a workspace.
|
|
type WorkspaceFile struct {
|
|
ID string `json:"id" db:"id"`
|
|
WorkspaceID string `json:"workspace_id" db:"workspace_id"`
|
|
Path string `json:"path" db:"path"`
|
|
IsDirectory bool `json:"is_directory" db:"is_directory"`
|
|
ContentType string `json:"content_type,omitempty" db:"content_type"`
|
|
SizeBytes int64 `json:"size_bytes" db:"size_bytes"`
|
|
SHA256 string `json:"sha256,omitempty" db:"sha256"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
// WorkspaceStats holds aggregate storage metrics for a workspace.
|
|
type WorkspaceStats struct {
|
|
WorkspaceID string `json:"workspace_id"`
|
|
FileCount int `json:"file_count"`
|
|
DirCount int `json:"dir_count"`
|
|
TotalBytes int64 `json:"total_bytes"`
|
|
MaxBytes *int64 `json:"max_bytes,omitempty"`
|
|
}
|