-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnative.go
More file actions
47 lines (42 loc) · 1.72 KB
/
native.go
File metadata and controls
47 lines (42 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package plugin
import (
"database/sql"
"log/slog"
"net/http"
)
// PluginDependency declares a dependency on another plugin.
type PluginDependency struct {
Name string `json:"name"` // required plugin name
MinVersion string `json:"minVersion"` // semver constraint, empty = any version
}
// PluginContext provides shared resources to plugins during lifecycle events.
type PluginContext struct {
App interface{} // modular.Application — use interface{} to avoid import cycle
DB *sql.DB
Logger *slog.Logger
DataDir string
}
// UIPageDef describes a UI page contributed by a plugin.
type UIPageDef struct {
ID string `json:"id"`
Label string `json:"label"`
Icon string `json:"icon"`
Category string `json:"category"` // "global", "workflow", "plugin"
Order int `json:"order"`
RequiredRole string `json:"requiredRole,omitempty"` // minimum role: "viewer", "editor", "admin", "operator"
RequiredPermission string `json:"requiredPermission,omitempty"` // specific permission key, e.g. "plugins.manage"
APIEndpoint string `json:"apiEndpoint,omitempty"` // JSON data source for template pages
Template string `json:"template,omitempty"` // predefined template: "data-table", "chart-dashboard", "form", "detail-view"
}
// NativePlugin is a compiled-in plugin that provides HTTP handlers, UI page metadata,
// and lifecycle hooks with dependency declarations.
type NativePlugin interface {
Name() string
Version() string
Description() string
Dependencies() []PluginDependency
UIPages() []UIPageDef
RegisterRoutes(mux *http.ServeMux)
OnEnable(ctx PluginContext) error
OnDisable(ctx PluginContext) error
}