Documentation
¶
Overview ¶
Package manager 提供 pluginkit 插件配置的工作台 Web UI 与 HTTP API。
宿主应用在 main 中 import 自己的插件包(触发 init Register),再启动 manager:
import "github.com/lengzhao/pluginkit/manager"
func main() {
manager.Run(manager.Options{Addr: ":8080"})
}
工作台通过 GET /api/bootstrap 获取 catalog 与可选 InitialYAML; POST /api/load 或 POST /api/edit(importYAML)加载 YAML; POST /api/edit 应用其他编辑命令,返回 document + view + diagnostics + yaml。 Options.OnChange / OnBuild 在 edit、load、build 成功后回调 DocumentEvent。 可选执行宿主 ValidateBuild 做试装配。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChangeReason ¶
type ChangeReason string
ChangeReason 描述文档变更来源。
const ( // ChangeEdit 表示用户通过 /api/edit 修改了文档。 ChangeEdit ChangeReason = "edit" // ChangeLoad 表示通过 /api/load 或 importYAML 整表替换。 ChangeLoad ChangeReason = "load" // ChangeBuild 表示用户触发了试装配。 ChangeBuild ChangeReason = "build" )
type Diagnostic ¶
type Diagnostic struct {
Path string `json:"path"`
Severity string `json:"severity"`
Stage string `json:"stage"`
Code string `json:"code"`
Message string `json:"message"`
}
Diagnostic 是钉到稳定 path 上的分层校验结果。
type Document ¶
type Document struct {
RootID string `json:"rootId"`
Plugin PluginNode `json:"plugin"`
}
Document 是 UI 维护的实例图:root 内联树 + 可选顶层共享实例。
type DocumentEvent ¶
type DocumentEvent struct {
Reason ChangeReason `json:"reason"`
Operation string `json:"operation,omitempty"`
Document Document `json:"document"`
YAML string `json:"yaml"`
Diagnostics []Diagnostic `json:"diagnostics"`
}
DocumentEvent 是工作台状态变更事件,供宿主 OnChange / OnBuild 回调。
type KindCandidate ¶
type KindCandidate struct {
Kind string `json:"kind"`
ReturnType string `json:"returnType"`
Exact bool `json:"exact"`
}
KindCandidate 是空槽可新建的内联插件候选。
type Operation ¶
type Operation struct {
Type string `json:"type"`
Path string `json:"path,omitempty"`
Kind string `json:"kind,omitempty"`
RefID string `json:"refId,omitempty"`
ID string `json:"id,omitempty"`
Config map[string]any `json:"config,omitempty"`
YAML string `json:"yaml,omitempty"`
DeleteOrphan *bool `json:"deleteOrphan,omitempty"`
}
Operation 是工作台的一次编辑命令。
type Options ¶
type Options struct {
// Addr 监听地址,空值时使用 :8080。
Addr string
// InitialYAML 可选的初始 YAML。设置后 UI 启动时直接加载该文档,而非空白新建。
InitialYAML string
// ValidateBuild 在结构校验与 ValidatePlan 通过后可选执行完整 build。
// 宿主可在此调用 build.Build[T] 做更严格的校验。
ValidateBuild func(ctx context.Context, doc Document) error
// OnChange 在 edit / load 成功后调用,供宿主同步 YAML 或继续编排。
OnChange func(ctx context.Context, evt DocumentEvent) error
// OnBuild 在试装配完成后调用(无论是否通过)。
OnBuild func(ctx context.Context, evt DocumentEvent) error
}
Options 配置 manager HTTP 服务。
type PluginNode ¶
type PluginNode struct {
Use string `json:"use"`
Config map[string]any `json:"config,omitempty"`
Deps map[string]any `json:"deps,omitempty"`
}
PluginNode 对应一个插件实例(内联或共享)。
type RefCandidate ¶
RefCandidate 是空槽可引用的已有共享实例。
type View ¶
type View struct {
Root *ViewNode `json:"root"`
}
View 是装配树给前端的投影:只渲染 view,不解析 deps 联合类型。
type ViewField ¶
type ViewField struct {
Name string `json:"name"`
Type string `json:"type"`
Value any `json:"value"`
}
ViewField 是检查器里的一个 config 字段。
type ViewNode ¶
type ViewNode struct {
Path string `json:"path"`
Role string `json:"role"`
Kind string `json:"kind,omitempty"`
RefID string `json:"refId,omitempty"`
RefCount int `json:"refCount,omitempty"`
Config []ViewField `json:"config,omitempty"`
Slots []ViewSlot `json:"slots,omitempty"`
}
ViewNode 是装配树上的一个节点:内联子树、引用芯片、或共享定义。
type ViewSlot ¶
type ViewSlot struct {
Name string `json:"name"`
Path string `json:"path"`
Status string `json:"status"`
List bool `json:"list,omitempty"`
Optional bool `json:"optional,omitempty"`
Type string `json:"type,omitempty"`
Kinds []KindCandidate `json:"kinds,omitempty"`
Refs []RefCandidate `json:"refs,omitempty"`
Items []ViewNode `json:"items,omitempty"`
}
ViewSlot 是插件扩展点:空槽带候选,已填槽带 items。