plugin

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package plugin provides plugin management for XxSql.

Index

Constants

This section is empty.

Variables

View Source
var OfficialPlugins = []RegistryPlugin{
	{
		Name:        "auth",
		Version:     "1.0.0",
		Author:      "XxSql Team",
		Description: "User authentication with session management, login/register/logout endpoints",
		Category:    "auth",
		Tables:      "_plugin_auth_users,_plugin_auth_sessions",
		Endpoints: []Endpoint{
			{SKEY: "auth/login", Description: "User login"},
			{SKEY: "auth/register", Description: "Register new user"},
			{SKEY: "auth/logout", Description: "User logout"},
			{SKEY: "auth/check", Description: "Check authentication status"},
			{SKEY: "auth/user", Description: "Get current user info"},
		},
		DownloadURL: "https://github.com/topxeq/xxsql-plugins/raw/main/auth.zip",
	},
	{
		Name:        "logging",
		Version:     "1.0.0",
		Author:      "XxSql Team",
		Description: "Centralized logging service with query and filtering capabilities",
		Category:    "logging",
		Tables:      "_plugin_log_entries",
		Endpoints: []Endpoint{
			{SKEY: "log/write", Description: "Write log entry"},
			{SKEY: "log/query", Description: "Query logs with filters"},
			{SKEY: "log/clear", Description: "Clear old logs"},
			{SKEY: "log/stats", Description: "Log statistics"},
		},
		DownloadURL: "https://github.com/topxeq/xxsql-plugins/raw/main/logging.zip",
	},
	{
		Name:        "ratelimit",
		Version:     "1.0.0",
		Author:      "XxSql Team",
		Description: "Request rate limiting with configurable rules per IP or user",
		Category:    "utility",
		Tables:      "_plugin_ratelimit_rules,_plugin_ratelimit_counters",
		Endpoints: []Endpoint{
			{SKEY: "ratelimit/check", Description: "Check if request is allowed"},
			{SKEY: "ratelimit/rules", Description: "Manage rate limit rules"},
			{SKEY: "ratelimit/reset", Description: "Reset rate limit counter"},
		},
		DownloadURL: "https://github.com/topxeq/xxsql-plugins/raw/main/ratelimit.zip",
	},
	{
		Name:        "storage",
		Version:     "1.0.0",
		Author:      "XxSql Team",
		Description: "File storage service with upload, download, and management",
		Category:    "storage",
		Tables:      "_plugin_storage_files",
		Endpoints: []Endpoint{
			{SKEY: "storage/upload", Description: "Upload file"},
			{SKEY: "storage/download", Description: "Download file"},
			{SKEY: "storage/list", Description: "List files"},
			{SKEY: "storage/delete", Description: "Delete file"},
			{SKEY: "storage/info", Description: "Get file info"},
		},
		DownloadURL: "https://github.com/topxeq/xxsql-plugins/raw/main/storage.zip",
	},
}

OfficialPlugins is the built-in registry of official XxSql plugins.

View Source
var PluginCategories = []string{
	"auth",
	"logging",
	"storage",
	"utility",
}

PluginCategories returns the list of plugin categories.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	SKEY        string `json:"skey"`
	Script      string `json:"script"`
	Description string `json:"description"`
}

Endpoint represents a plugin endpoint.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages plugins in XxSql.

func NewManager

func NewManager(engine *storage.Engine, exec *executor.Executor, dataDir string) *Manager

NewManager creates a new plugin manager.

func (*Manager) Disable

func (m *Manager) Disable(name string) error

Disable disables a plugin.

func (*Manager) Enable

func (m *Manager) Enable(name string) error

Enable enables a plugin.

func (*Manager) GetPlugin

func (m *Manager) GetPlugin(name string) (*Plugin, error)

GetPlugin returns a specific plugin by name.

func (*Manager) InstallFromZIP

func (m *Manager) InstallFromZIP(zipPath string) error

InstallFromZIP installs a plugin from a ZIP file.

func (*Manager) IsInstalled

func (m *Manager) IsInstalled(name string) bool

IsInstalled checks if a plugin is installed.

func (*Manager) ListInstalled

func (m *Manager) ListInstalled() ([]*Plugin, error)

ListInstalled returns all installed plugins.

func (*Manager) Uninstall

func (m *Manager) Uninstall(name string) error

Uninstall removes a plugin.

type Plugin

type Plugin struct {
	Name          string     `json:"name"`
	Version       string     `json:"version"`
	LatestVersion string     `json:"latest_version"`
	Author        string     `json:"author"`
	Description   string     `json:"description"`
	Category      string     `json:"category"`
	Enabled       bool       `json:"enabled"`
	InstalledAt   string     `json:"installed_at"`
	Tables        string     `json:"tables"`
	HasUpdate     bool       `json:"has_update"`
	Source        string     `json:"source"`
	Endpoints     []Endpoint `json:"endpoints"`
}

Plugin represents an installed or available plugin.

type RegistryPlugin

type RegistryPlugin struct {
	Name        string     `json:"name"`
	Version     string     `json:"version"`
	Author      string     `json:"author"`
	Description string     `json:"description"`
	Category    string     `json:"category"`
	Tables      string     `json:"tables"`
	Endpoints   []Endpoint `json:"endpoints"`
	DownloadURL string     `json:"download_url"`
}

RegistryPlugin represents a plugin in the registry.

func GetAvailablePlugins

func GetAvailablePlugins() []RegistryPlugin

GetAvailablePlugins returns plugins available in the registry. For now, returns the built-in list. In future, can fetch from GitHub.

func GetRegistryPlugin

func GetRegistryPlugin(name string) *RegistryPlugin

GetRegistryPlugin returns a specific plugin from the registry.

Jump to

Keyboard shortcuts

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