Documentation
¶
Overview ¶
Package operation 定义 STX API、CLI 与能力查询共用的操作登记结构。 Package operation defines the shared operation registry used by the STX API, CLI, and capability discovery.
Index ¶
Constants ¶
const RegistryRevision = 26
RegistryRevision 是操作登记表的兼容修订号。 RegistryRevision is the compatibility revision of the operation registry.
Variables ¶
This section is empty.
Functions ¶
func RegistryDigest ¶
func RegistryDigest() string
RegistryDigest 返回登记表内容的稳定 SHA-256 标识。 RegistryDigest returns a stable SHA-256 identifier for the registry contents.
func Validate ¶
func Validate(specs []OperationSpec, exceptions []RouteException) error
Validate 检查操作登记表和特殊路由例外是否满足公共契约。 Validate checks whether the operation registry and special-route exceptions satisfy the shared contract.
Types ¶
type ImpactSpec ¶
type ImpactSpec struct {
Level RiskLevel `json:"level" yaml:"level"`
Message string `json:"message" yaml:"message"`
Performance string `json:"performance,omitempty" yaml:"performance,omitempty"`
}
ImpactSpec 描述执行操作前需要展示的影响信息。 ImpactSpec describes impact information that must be shown before execution.
type InputLocation ¶
type InputLocation string
InputLocation 表示输入参数在 HTTP 请求中的位置。 InputLocation identifies where an input is carried in an HTTP request.
const ( InputPath InputLocation = "path" InputQuery InputLocation = "query" InputHeader InputLocation = "header" InputBody InputLocation = "body" InputFile InputLocation = "file" )
type InputSpec ¶
type InputSpec struct {
Name string `json:"name" yaml:"name"`
Location InputLocation `json:"location" yaml:"location"`
Required bool `json:"required" yaml:"required"`
// Repeated 表示查询参数可以在同一请求中出现多次。
// Repeated indicates that a query parameter may appear more than once in one request.
Repeated bool `json:"repeated,omitempty" yaml:"repeated,omitempty"`
Description string `json:"description" yaml:"description"`
}
InputSpec 描述一个可由 CLI 传入的操作参数。 InputSpec describes an operation input accepted by the CLI.
type OperationMode ¶
type OperationMode string
OperationMode 表示操作需要采用的客户端处理方式。 OperationMode identifies the client behavior required by an operation.
const ( ModeNormal OperationMode = "normal" ModeWatch OperationMode = "watch" ModeDownload OperationMode = "download" ModeServerOnly OperationMode = "server_only" ModeProxy OperationMode = "proxy" )
type OperationSpec ¶
type OperationSpec struct {
ID string `json:"operation_id" yaml:"operation_id"`
CommandPath []string `json:"command_path" yaml:"command_path"`
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
GeneratedCLI bool `json:"generated_cli" yaml:"generated_cli"`
Method string `json:"method" yaml:"method"`
Route string `json:"route" yaml:"route"`
Mode OperationMode `json:"mode" yaml:"mode"`
AuthRequired bool `json:"auth_required" yaml:"auth_required"`
Risk RiskLevel `json:"risk" yaml:"risk"`
AdminOnly bool `json:"admin_only" yaml:"admin_only"`
Revision int `json:"revision" yaml:"revision"`
UsesAgent bool `json:"uses_agent" yaml:"uses_agent"`
Async bool `json:"async" yaml:"async"`
SupportsPick bool `json:"supports_pick" yaml:"supports_pick"`
SupportsRevision bool `json:"supports_revision" yaml:"supports_revision"`
Impact *ImpactSpec `json:"impact,omitempty" yaml:"impact,omitempty"`
Input []InputSpec `json:"input,omitempty" yaml:"input,omitempty"`
Example string `json:"example" yaml:"example"`
OutputExample string `json:"output_example" yaml:"output_example"`
}
OperationSpec 是普通 API 路由、CLI 命令和能力查询共用的稳定登记项。 OperationSpec is the stable registry entry shared by API routes, CLI commands, and capability discovery.
func Registry ¶
func Registry() []OperationSpec
Registry 返回登记表的副本,调用方不能修改包内数据。 Registry returns a copy so callers cannot mutate package-owned data.
type RiskLevel ¶
type RiskLevel string
RiskLevel 表示服务端评估的操作风险等级。 RiskLevel identifies the server-assessed risk level of an operation.
type RouteException ¶
type RouteException struct {
Method string `json:"method" yaml:"method"`
Route string `json:"route" yaml:"route"`
Mode OperationMode `json:"mode" yaml:"mode"`
Reason string `json:"reason" yaml:"reason"`
}
RouteException 记录不生成普通 CLI 命令的特殊路由。 RouteException records a special route that does not generate a normal CLI command.
func RouteExceptions ¶
func RouteExceptions() []RouteException
RouteExceptions 返回特殊路由例外的副本。 RouteExceptions returns a copy of the special-route exceptions.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
contract-report
command
|
|
|
Package contract 提供操作登记表与源码路由、Swagger 的开发期检查。
|
Package contract 提供操作登记表与源码路由、Swagger 的开发期检查。 |