Documentation
¶
Index ¶
Constants ¶
const ( VisibilityPublic = pkgentity.VisibilityPublic VisibilityPrivate = pkgentity.VisibilityPrivate )
const ( HomeViewCompact = "compact" HomeViewDetailed = "detailed" )
const SSOProviderGoogle = "google"
SSOProviderGoogle is the provider key for Google OAuth.
Variables ¶
var StructToConfigs = pkgentity.StructToConfigs
StructToConfigs is re-exported from pkg/entity — see that package for the tag grammar and reflection rules.
Functions ¶
This section is empty.
Types ¶
type Bookmark ¶
type Bookmark struct {
UserID string `gorm:"primaryKey;type:varchar(36)"`
ToolPath string `gorm:"primaryKey;type:varchar(255)"`
CreatedAt time.Time
}
Bookmark marks a tool as a favorite for a specific user. Bookmarked tools appear in a dedicated "Bookmarks" group on the home page in addition to any group/category they already belong to.
type Config ¶
Config is re-exported from pkg/entity so existing internal callers keep working. Module authors should import pkg/entity directly.
type HealthComponent ¶
type HealthComponent struct {
Database HealthState `json:"database"`
}
type HealthState ¶
type HealthState string
const ( HealthStateOK HealthState = "ok" HealthStateFail HealthState = "fail" )
type Job ¶
type Job struct {
ID string `gorm:"type:varchar(36);primaryKey"`
Key string `gorm:"type:varchar(100);uniqueIndex;not null"`
Name string `gorm:"type:varchar(255);not null"`
Description string `gorm:"type:text"`
Icon string `gorm:"type:varchar(10)"`
Schedule string `gorm:"type:varchar(100)"` // cron expression
Enabled bool `gorm:"default:false"`
MaxRuns int `gorm:"default:0"` // 0 = unlimited, admin-managed
TotalRuns int `gorm:"default:0"`
LastStatus JobStatus `gorm:"type:varchar(20);default:'idle'"`
LastRunAt *time.Time
CreatedBy string `gorm:"type:varchar(36)"`
CreatedAt time.Time
UpdatedAt time.Time
}
Job is a background job definition whose schedule and lifecycle are managed via the DB. Code-defined jobs bootstrap a row on startup; admins can tweak the cron expression, enable/disable, and cap the run count.
type JobRun ¶
type JobRun struct {
ID string `gorm:"type:varchar(36);primaryKey"`
JobID string `gorm:"type:varchar(36);index;not null"`
Status RunStatus `gorm:"type:varchar(20);not null"`
Result string `gorm:"type:text"`
TriggeredBy RunTrigger `gorm:"type:varchar(20);not null"`
UserID string `gorm:"type:varchar(36)"`
StartedAt time.Time
EndedAt *time.Time
CreatedAt time.Time
}
JobRun stores the result of a single execution of a Job.
type RunTrigger ¶
type RunTrigger string
RunTrigger describes how a run was initiated.
const ( RunTriggerManual RunTrigger = "manual" RunTriggerCron RunTrigger = "cron" )
type SSOProvider ¶
type SSOProvider struct {
ID uint `gorm:"primaryKey"`
Provider string `gorm:"uniqueIndex;type:varchar(32);not null"` // "google"
ClientID string `gorm:"type:varchar(255)"`
ClientSecret string `gorm:"type:varchar(255)"`
Enabled bool `gorm:"default:false"`
// AllowedDomains is a comma-separated list of email domains allowed
// to sign in through this provider (e.g. "abc.com,abc.net").
// Empty string means no restriction — any email from the provider is
// accepted. Matching is case-insensitive.
AllowedDomains string `gorm:"type:text"`
CreatedAt time.Time
UpdatedAt time.Time
}
SSOProvider holds one OAuth/SSO provider's configuration. The callback URL is never stored — it's derived at runtime from app_variables.app_url + "/auth/callback".
func (SSOProvider) TableName ¶
func (SSOProvider) TableName() string
type Tag ¶
type Tag struct {
ID string `gorm:"type:varchar(36);primaryKey"`
Name string `gorm:"uniqueIndex;type:varchar(100);not null"`
Description string `gorm:"type:varchar(500)"`
IsGroup bool `gorm:"default:false"`
IsFilter bool `gorm:"default:false"`
SortOrder int `gorm:"default:0"`
CreatedAt time.Time
}
Tag is a first-class label that can be attached to users and tools. Renaming a Tag propagates automatically because associations store TagID, not the name.
A Tag has two orthogonal-but-combinable purposes:
- Access filter: when IsFilter is true and the tag is attached to a Private tool, only users who carry the same tag may access it. Tool-tags without IsFilter are purely cosmetic for access (they don't restrict who can enter).
- Group on home: when IsGroup is true, tools carrying the tag are rendered together on the home page under Name. A tool with multiple group tags appears in each group.
A tag can set any combination of IsGroup and IsFilter independently.
type ToolPermission ¶
type ToolPermission struct {
ToolPath string `gorm:"primaryKey;type:varchar(255)"`
Visibility ToolVisibility `gorm:"type:varchar(50);default:'private'"`
// Disabled hides the tool from every user (including admins) and makes
// direct hits to /tools/{slug}/* return 404. Admins re-enable from
// /admin/tools.
Disabled bool `gorm:"default:false"`
UpdatedAt time.Time
}
ToolPermission stores the per-tool visibility override set by an admin. If no row exists for a tool path the code falls back to the tool's declared default visibility.
type ToolTag ¶
type ToolTag struct {
ToolPath string `gorm:"primaryKey;type:varchar(255)"`
TagID string `gorm:"primaryKey;type:varchar(36);index"`
}
ToolTag links a tool to a Tag. When a tool is Private and at least one ToolTag exists, only users carrying one of those tags may access it.
type ToolVisibility ¶
type ToolVisibility = pkgentity.ToolVisibility
ToolVisibility is re-exported from pkg/entity so existing callers continue to work after the public contract moved out of internal.
type User ¶
type User struct {
ID string `gorm:"type:varchar(36);primaryKey"`
Email string `gorm:"uniqueIndex;not null"`
Name string `gorm:"not null"`
Avatar string
Role UserRole `gorm:"type:varchar(50);default:'user'"`
Approved bool `gorm:"default:false"`
PasswordHash string `gorm:"type:varchar(255)"`
Metadata UserMetadata `gorm:"type:jsonb"`
CreatedAt time.Time
UpdatedAt time.Time
}
type UserMetadata ¶
type UserMetadata struct {
// HomeView picks the tool grid density: "compact" (icon+name) or
// "detailed" (wider cards with description). Empty means compact.
HomeView string `json:"home_view,omitempty"`
// Theme picks the UI color palette. Values are Theme.ID from
// internal/pkg/ui/theme.go ("light", "dark", "dracula", …).
// Empty means "no preference" — guests follow the device
// `prefers-color-scheme`, logged-in users can pick in the navbar.
Theme string `json:"theme,omitempty"`
// LightTheme / DarkTheme remember the last light- and dark-mode
// theme the user picked from the dropdown, so the navbar toggle
// can switch straight back to that variant instead of the generic
// "light"/"dark" defaults. Values are Theme.ID.
LightTheme string `json:"light_theme,omitempty"`
DarkTheme string `json:"dark_theme,omitempty"`
}
UserMetadata is the free-form preferences bag stored as JSON on the user row. Add fields here when a new per-user preference is needed — all consumers should default to the zero value when a field is unset so existing rows (NULL metadata) keep working without a backfill.
func (UserMetadata) HomeViewOrDefault ¶
func (m UserMetadata) HomeViewOrDefault() string
HomeViewOrDefault returns a valid HomeView value, falling back to compact when unset or unrecognized.
func (*UserMetadata) Scan ¶
func (m *UserMetadata) Scan(value any) error