catalog

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package catalog is the operation index shared by the runtime, the MCP server, and a generated client.

Index

Constants

View Source
const (
	KindRead   Kind = "read"
	KindCreate Kind = "create"
	KindUpdate Kind = "update"
	KindDelete Kind = "delete"
	KindAction Kind = "action"

	SideEffectNone        SideEffect = "none"
	SideEffectWrite       SideEffect = "write"
	SideEffectDestructive SideEffect = "destructive"

	// ExposureDirect is a pinned tool. ExposureGrouped is one tool for the resource. ExposureDiscovery stays on search and describe.
	ExposureDirect    = "direct"
	ExposureGrouped   = "grouped"
	ExposureDiscovery = "discovery-only"
)
View Source
const (
	NodeResource  NodeKind = "resource"
	NodeOperation NodeKind = "operation"
	NodeSchema    NodeKind = "schema"

	EdgeOwns    = "owns"
	EdgeUses    = "uses"
	EdgeLinks   = "links"
	EdgeRelates = "relates"
)

Variables

This section is empty.

Functions

func ApplyRelations

func ApplyRelations(cat *Catalog, rels []Relation) error

A field name in a spec does not create an edge. This declaration does.

func Facts

func Facts(cat *Catalog) map[string]OpFact

func SurfaceRegressions

func SurfaceRegressions(base, next map[string]OpFact, confirmationChanged map[string]bool, confirmationOff bool) []string

confirmationChanged lists operations whose agent.yaml confirmation field changed on purpose.

Types

type Auth

type Auth struct {
	Name       string   `json:"Name"`
	Header     string   `json:"Header"`
	Query      string   `json:"Query"`
	Kind       string   `json:"Kind"`
	Scopes     []string `json:"Scopes"`
	UserHeader string   `json:"UserHeader"`
	Type       string   `json:"-"` // OpenAPI security scheme type
	Scheme     string   `json:"-"` // OpenAPI http scheme, such as basic
}

Auth is one scheme in a security requirement. Header is set for header placement. Query is set for an apiKey in query. UserHeader is set when the contract names a separate header for the person token.

type Catalog

type Catalog struct {
	Title      string
	Version    string
	Operations []Operation
	Links      []OpLink
	Uses       []SchemaUse
	Graph      Graph
	// contains filtered or unexported fields
}

func Merge

func Merge(parts ...*Catalog) (*Catalog, error)

func (*Catalog) ByID

func (c *Catalog) ByID(id string) *Operation

func (*Catalog) ClearConfirmation

func (c *Catalog) ClearConfirmation()

ClearConfirmation turns the confirmation gate off for every operation.

func (*Catalog) Finalize

func (c *Catalog) Finalize()

func (*Catalog) IndexLine

func (c *Catalog) IndexLine() string

func (*Catalog) Joins

func (c *Catalog) Joins() []string

func (*Catalog) Select added in v0.1.1

func (c *Catalog) Select(s Selection)

Select removes every operation s does not keep, with the links and relations that point at it.

func (*Catalog) SelectServer

func (c *Catalog) SelectServer(name string) error

type Edge

type Edge struct {
	From string
	To   string
	Kind string
	Note string
}

Owns is resource to operation. Uses is operation to schema. Links is operation to operation.

type Graph

type Graph struct {
	Nodes []Node
	Edges []Edge
}

func BuildGraph

func BuildGraph(ops []Operation, links []OpLink, uses []SchemaUse) Graph

func (Graph) OperationsForResource

func (g Graph) OperationsForResource(resource string) []string

func (Graph) Related

func (g Graph) Related(operationID string) []string

func (Graph) Schemas

func (g Graph) Schemas(operationID string) []string

type Kind

type Kind string

type Match

type Match struct {
	Operation Operation `json:"Operation"`
	Related   []string  `json:"Related"`
}
func Search(cat *Catalog, query string, synonyms map[string][]string) []Match

An exact id outranks a synonym. A synonym outranks a weaker substring.

func SearchPage

func SearchPage(cat *Catalog, query string, synonyms map[string][]string, offset, limit int) []Match

type Node

type Node struct {
	ID   string
	Name string
	Kind NodeKind
}

type NodeKind

type NodeKind string

type OpFact

type OpFact struct {
	Confirmation bool     `json:"confirmation"`
	Destructive  bool     `json:"destructive"`
	Referenced   bool     `json:"referenced"`
	Callable     *bool    `json:"callable,omitempty"`
	Permissions  []string `json:"permissions,omitempty"`
}
type OpLink struct {
	From   string
	To     string
	Note   string
	Params map[string]string
}

type Operation

type Operation struct {
	ID                   string            `json:"ID"`
	Name                 string            `json:"Name"`
	Summary              string            `json:"-"`
	Description          string            `json:"Description"`
	IDFallback           bool              `json:"-"`
	IDCollision          string            `json:"-"`
	Group                string            `json:"Group"`
	Kind                 Kind              `json:"Kind"`
	Method               string            `json:"Method"`
	PathTemplate         string            `json:"PathTemplate"`
	Params               []Param           `json:"Params"`
	ResponseSummary      string            `json:"ResponseSummary"`
	SideEffect           SideEffect        `json:"SideEffect"`
	RequiresConfirmation bool              `json:"RequiresConfirmation"`
	Permissions          []string          `json:"Permissions"`
	Idempotency          string            `json:"Idempotency"`
	Retry                string            `json:"Retry"`
	Exposure             string            `json:"Exposure"`
	BaseURL              string            `json:"BaseURL"`
	Servers              []Server          `json:"Servers"`
	Page                 map[string]string `json:"Page"`
	Auth                 []Auth            `json:"Auth"`
	Requirements         [][]Auth          `json:"Requirements"` // OR of AND groups. Auth is the first group.
	Tags                 []string          `json:"Tags"`
	ResponseFields       []string          `json:"ResponseFields"`
	ResponseRequired     []string          `json:"ResponseRequired,omitempty"`
}

func (Operation) AuthSchemes

func (op Operation) AuthSchemes() []Auth

AuthSchemes returns each scheme name once, across every requirement.

func (Operation) BodyParam

func (op Operation) BodyParam() (Param, bool)

func (Operation) CheckParams added in v0.1.1

func (op Operation) CheckParams(params map[string]string) error

CheckParams reports a missing required value, a parameter the call cannot send, a body that is not the declared JSON object, or a query, path, or header value that is not the declared schema.

func (Operation) FoldBody added in v0.1.11

func (op Operation) FoldBody(params map[string]string) map[string]string

FoldBody moves string fields of a missing JSON body onto that body. An explicit body is left as given. A field that is not a string stays out of the body.

type Param

type Param struct {
	Name        string `json:"Name"`
	In          string `json:"In"` // path, query, header, body
	Required    bool   `json:"Required"`
	Description string `json:"Description"`
	Schema      string `json:"Schema"`
	MediaType   string `json:"MediaType"`
	Default     string `json:"Default"`
	Style       string `json:"Style"`
	Explode     bool   `json:"Explode"`
	// contains filtered or unexported fields
}

func (Param) Structured added in v0.1.1

func (p Param) Structured() bool

Structured reports an array or object schema.

func (Param) Type added in v0.1.1

func (p Param) Type() string

Type is the single JSON Schema type of the parameter, or empty.

func (Param) Unserializable added in v0.1.1

func (p Param) Unserializable() string

Unserializable reports why a parameter cannot be placed on the request. An empty string means the call can send it.

type Relation

type Relation struct {
	Schema string `yaml:"schema"`
	Field  string `yaml:"field"`
	To     string `yaml:"to"`
}

func ParseRelations

func ParseRelations(data []byte) ([]Relation, error)

type SchemaUse

type SchemaUse struct {
	OperationID string
	Name        string
}

type Selection added in v0.1.1

type Selection struct {
	ReadOnly bool
	Tags     []string
	Paths    []string
}

Selection is the part of a contract a deployment exposes; the zero value keeps every operation.

func (Selection) Keeps added in v0.1.1

func (s Selection) Keeps(op Operation) bool

Keeps reports whether op stays in the catalog. Tags and paths are OR within each list and AND across lists that are set.

type Server

type Server struct {
	URL  string `json:"URL"`
	Name string `json:"Name"`
}

type SideEffect

type SideEffect string

Jump to

Keyboard shortcuts

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