Documentation
¶
Overview ¶
Package supermodel is the public Go SDK for the Supermodel API.
Other Go programs can import this package to embed Supermodel graph analysis without shelling out to the CLI binary.
Usage:
import "github.com/supermodeltools/cli/pkg/supermodel"
client := supermodel.NewClient("your-api-key")
graph, err := client.Analyze(ctx, "/path/to/repo")
if err != nil {
log.Fatal(err)
}
fmt.Println("files:", len(graph.NodesByLabel("File")))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int `json:"-"`
Code string `json:"code"`
Message string `json:"message"`
}
APIError is returned for non-2xx responses.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the Supermodel API.
func (*Client) AnalyzeZip ¶
AnalyzeZip uploads a pre-built ZIP to the Supermodel API and polls until the async job completes, returning the resulting Graph. idempotencyKey must be unique per logical request.
type Graph ¶
type Graph struct {
Nodes []Node `json:"nodes"`
Edges []Relationship `json:"edges"`
Relationships []Relationship `json:"relationships"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Graph is the result of a Supermodel analysis.
func (*Graph) NodesByLabel ¶
NodesByLabel returns all nodes that carry label.
func (*Graph) Rels ¶
func (g *Graph) Rels() []Relationship
Rels returns all relationships regardless of which JSON field they came from.
type Node ¶
type Node struct {
ID string `json:"id"`
Labels []string `json:"labels"`
Properties map[string]any `json:"properties"`
}
Node is a node in the Supermodel graph.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL overrides the default API base URL.
func WithHTTPClient ¶
WithHTTPClient substitutes a custom HTTP client (useful for testing).