Documentation
¶
Overview ¶
Package pluginui implements the GoatKit PaaS Plugin UI System.
Plugins declare independent UIs (agent apps, customer portals, public pages, kiosks) via UISpec in GKRegistration. The platform handles routing, shells, auth, navigation, and PWA manifest generation.
Index ¶
- Constants
- func BuildFullID(pluginName, uiID string) string
- func DefaultAuthMethod(uiType string) string
- func DefaultShell(uiType string) string
- func GenerateMenuItems(uis []PluginUI) map[string][]map[string]any
- func IsValidShell(s string) bool
- func IsValidUIType(t string) bool
- func RegisterUIRoutes(eng *gin.Engine, repo *Repository, caller PluginCaller, ...) error
- func UISpecToConfig(spec interface{}) (*json.RawMessage, error)
- func ValidAuthMethods() []string
- func ValidDataScopes() []string
- func ValidNavPositions() []string
- func ValidShells() []string
- func ValidUITypes() []string
- type PluginCaller
- type PluginUI
- type Repository
- func (r *Repository) Create(u *PluginUI, userID int) (int64, error)
- func (r *Repository) Delete(id int64) error
- func (r *Repository) GetByFullID(fullID string) (*PluginUI, error)
- func (r *Repository) GetByID(id int64) (*PluginUI, error)
- func (r *Repository) List(pluginName, uiType string, enabledOnly bool) ([]PluginUI, error)
- func (r *Repository) ListActive() ([]PluginUI, error)
- func (r *Repository) SetEnabled(id int64, enabled bool, userID int) error
- func (r *Repository) Update(u *PluginUI, userID int) error
- type TemplateRenderer
- type UIAuthConfig
- type UIBrandingConfig
- type UIConfig
- type UINavConfig
- type UINavItemConfig
- type UIPWAConfig
- type UIRouteConfig
Constants ¶
const ( TypeAdminPage = "admin_page" TypeAgentApp = "agent_app" TypeCustomerApp = "customer_app" TypePublicPage = "public_page" TypeKiosk = "kiosk" )
UI types.
const ( ShellNone = "none" ShellMinimal = "minimal" ShellStandard = "standard" )
Shell types.
const ( AuthSession = "session" AuthPIN = "pin" AuthToken = "token" AuthNone = "none" )
Auth methods.
const ( ScopeSelf = "self" ScopeOrg = "org" ScopeAll = "all" )
Data scopes.
const ( )
Nav positions.
Variables ¶
This section is empty.
Functions ¶
func BuildFullID ¶
BuildFullID constructs the full ID from plugin name and UI ID.
func DefaultAuthMethod ¶
DefaultAuthMethod returns the default auth method for a UI type.
func DefaultShell ¶
DefaultShell returns the default shell for a UI type.
func GenerateMenuItems ¶
GenerateMenuItems converts active plugin UIs into MenuItemSpecs for navigation injection. Returns items grouped by location: "admin", "agent", "customer".
func IsValidShell ¶
IsValidShell checks whether the given shell type is supported.
func IsValidUIType ¶
IsValidUIType checks whether the given UI type is supported.
func RegisterUIRoutes ¶
func RegisterUIRoutes(eng *gin.Engine, repo *Repository, caller PluginCaller, renderer TemplateRenderer, logger *slog.Logger) error
RegisterUIRoutes registers all active plugin UI routes on the given gin engine. Call this during dynamic engine rebuild, after YAML routes and before plugin routes.
func UISpecToConfig ¶
func UISpecToConfig(spec interface{}) (*json.RawMessage, error)
UISpecToConfig converts a plugin UISpec to the stored JSON config.
func ValidAuthMethods ¶
func ValidAuthMethods() []string
ValidAuthMethods returns all supported auth methods.
func ValidDataScopes ¶
func ValidDataScopes() []string
ValidDataScopes returns all supported data scopes.
func ValidNavPositions ¶
func ValidNavPositions() []string
ValidNavPositions returns all supported nav positions.
Types ¶
type PluginCaller ¶
type PluginCaller interface {
Call(ctx context.Context, pluginName, fn string, args json.RawMessage) (json.RawMessage, error)
}
PluginCaller is an interface for calling plugin functions. Satisfied by the plugin.Manager.
type PluginUI ¶
type PluginUI struct {
ID int64 `json:"id" db:"id"`
PluginName string `json:"plugin_name" db:"plugin_name"`
UIID string `json:"ui_id" db:"ui_id"`
FullID string `json:"full_id" db:"full_id"`
Name string `json:"name" db:"name"`
Description *string `json:"description,omitempty" db:"description"`
UIType string `json:"ui_type" db:"ui_type"`
Shell string `json:"shell" db:"shell"`
Icon *string `json:"icon,omitempty" db:"icon"`
Config *json.RawMessage `json:"config,omitempty" db:"config"`
Enabled bool `json:"enabled" db:"enabled"`
CustomDomain *string `json:"custom_domain,omitempty" db:"custom_domain"`
ValidID int `json:"valid_id" db:"valid_id"`
CreateTime time.Time `json:"create_time" db:"create_time"`
CreateBy int `json:"create_by" db:"create_by"`
ChangeTime time.Time `json:"change_time" db:"change_time"`
ChangeBy int `json:"change_by" db:"change_by"`
}
PluginUI represents a stored plugin UI from gk_plugin_ui.
func (*PluginUI) ParsedConfig ¶
ParsedConfig returns the full UISpec config from the JSON column.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository provides CRUD operations for plugin UI registrations.
func NewRepository ¶
func NewRepository() (*Repository, error)
NewRepository creates a repository using the global DB connection.
func NewRepositoryWithDB ¶
func NewRepositoryWithDB(db *sql.DB) *Repository
NewRepositoryWithDB creates a repository with an explicit DB connection.
func (*Repository) Create ¶
func (r *Repository) Create(u *PluginUI, userID int) (int64, error)
Create inserts a new plugin UI. Returns the new row ID.
func (*Repository) Delete ¶
func (r *Repository) Delete(id int64) error
Delete removes a plugin UI permanently.
func (*Repository) GetByFullID ¶
func (r *Repository) GetByFullID(fullID string) (*PluginUI, error)
GetByFullID retrieves a plugin UI by its full ID ({plugin}_{ui_id}).
func (*Repository) GetByID ¶
func (r *Repository) GetByID(id int64) (*PluginUI, error)
GetByID retrieves a plugin UI by its database ID.
func (*Repository) List ¶
func (r *Repository) List(pluginName, uiType string, enabledOnly bool) ([]PluginUI, error)
List retrieves plugin UIs with optional filters.
func (*Repository) ListActive ¶
func (r *Repository) ListActive() ([]PluginUI, error)
ListActive returns all enabled, valid plugin UIs. Used at startup for route registration.
func (*Repository) SetEnabled ¶
func (r *Repository) SetEnabled(id int64, enabled bool, userID int) error
SetEnabled enables or disables a plugin UI.
type TemplateRenderer ¶
type TemplateRenderer interface {
HTML(c *gin.Context, code int, name string, data pongo2.Context)
}
TemplateRenderer is the interface for rendering pongo2 templates.
type UIAuthConfig ¶
type UIAuthConfig struct {
Method string `json:"method,omitempty"` // session, pin, token, none
Groups []string `json:"groups,omitempty"`
}
UIAuthConfig holds per-UI auth configuration.
type UIBrandingConfig ¶
type UIBrandingConfig struct {
AppName string `json:"app_name,omitempty"`
Logo string `json:"logo,omitempty"`
Favicon string `json:"favicon,omitempty"`
Color string `json:"color,omitempty"`
}
UIBrandingConfig holds per-UI branding overrides.
type UIConfig ¶
type UIConfig struct {
Routes []UIRouteConfig `json:"routes,omitempty"`
Branding *UIBrandingConfig `json:"branding,omitempty"`
Auth *UIAuthConfig `json:"auth,omitempty"`
PWA *UIPWAConfig `json:"pwa,omitempty"`
DataScope string `json:"data_scope,omitempty"`
RateLimit int `json:"rate_limit,omitempty"`
}
UIConfig stores the full UISpec configuration in the config JSON column.
type UIPWAConfig ¶
type UIPWAConfig struct {
Enabled bool `json:"enabled"`
StartURL string `json:"start_url,omitempty"`
Display string `json:"display,omitempty"` // standalone, fullscreen, minimal-ui
ThemeColor string `json:"theme_color,omitempty"`
CacheRoutes []string `json:"cache_routes,omitempty"`
}
UIPWAConfig holds PWA manifest configuration.
type UIRouteConfig ¶
type UIRouteConfig struct {
Path string `json:"path"`
Method string `json:"method,omitempty"`
Handler string `json:"handler"`
}
UIRouteConfig is a route within a plugin UI.