plugins

package
v0.0.0-...-b25413d Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsClientErr

func IsClientErr(err error) bool

IsClientErr reports whether an error is a client error.

func ToRow

func ToRow(w *UploadedWidget) widgetsrepo.Row

ToRow converts UploadedWidget to repository Row.

Types

type Logger

type Logger interface {
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

Logger represents the minimal logging interface used by the uploader.

type Manifest

type Manifest struct {
	ID           string         `json:"id"`
	Name         string         `json:"name"`
	Version      string         `json:"version"`
	Type         string         `json:"type"`
	Scopes       []string       `json:"scopes"`
	Enabled      *bool          `json:"enabled,omitempty"`
	Description  *string        `json:"description,omitempty"`
	Capabilities []string       `json:"capabilities,omitempty"`
	Homepage     *string        `json:"homepage,omitempty"`
	Meta         map[string]any `json:"meta,omitempty"`
}

Manifest represents a plugin manifest inside the uploaded archive.

func ExtractManifest

func ExtractManifest(path string) (*Manifest, error)

ExtractManifest extracts manifest.json or plugin.json from the archive at path.

type UploadOptions

type UploadOptions struct {
	TenantScope string
	Tenants     []string
}

UploadOptions controls how a plugin upload should be handled.

type UploadedWidget

type UploadedWidget struct {
	ID           string
	Name         string
	Version      string
	Type         string
	Scopes       []string
	Enabled      bool
	Description  *string
	Capabilities []string
	Homepage     *string
	Meta         map[string]any
	TenantScope  string
	Tenants      []string
	UpdatedAt    time.Time
	PackageSize  int64
}

UploadedWidget contains information about the stored widget.

type Uploader

type Uploader struct {
	Repo      WidgetsRepo
	Notifier  WidgetsNotifier
	Logger    Logger
	AcceptExt []string
	TmpDir    string
	StoreDir  string
}

Uploader handles plugin uploads.

func (*Uploader) HandleUpload

func (u *Uploader) HandleUpload(ctx context.Context, f multipart.File, filename string, opt UploadOptions) (*UploadedWidget, error)

HandleUpload processes the uploaded plugin file and stores metadata.

type WidgetsNotifier

type WidgetsNotifier interface {
	NotifyWidgetChanged(ctx context.Context, id string) error
	NotifyWidgetRemoved(ctx context.Context, id string) error
}

WidgetsNotifier notifies other nodes of widget changes.

type WidgetsRepo

type WidgetsRepo interface {
	Upsert(ctx context.Context, r widgetsrepo.Row) error
}

WidgetsRepo defines the repository for widgets.

Jump to

Keyboard shortcuts

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