api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api implements the local HTTP REST surface of bacio. It shares the same SQLite store, validators, audit log, and JSON-input schemas as the CLI; nothing in this package is allowed to import internal/cli or to open the store itself — the cobra command owns that lifecycle.

Package api transport-only composite types. The CLI keeps its own equivalents (in internal/cli/output.go and the *_preview structs in the relevant cli/*.go files) for text rendering; both surfaces emit the same JSON shape so consumers don't need a per-surface parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActorFromContext

func ActorFromContext(ctx context.Context) string

ActorFromContext retrieves the resolved actor stamped onto the request context by actorMiddleware. Returns the default if missing so callers don't have to nil-check.

Types

type BriefDoc

type BriefDoc struct {
	Filename    string             `json:"filename"`
	Type        model.DocumentType `json:"type"`
	Description string             `json:"description,omitempty"`
	SourcePath  string             `json:"source_path,omitempty"`
	LinkedVia   []string           `json:"linked_via"`
	Content     string             `json:"content"`
}

BriefDoc mirrors internal/cli/issue.go:briefDoc — one linked document with its full content inlined and an attribution path captured in LinkedVia.

type CascadeCount

type CascadeCount struct {
	Comments      int `json:"comments"`
	Relations     int `json:"relations"`
	PullRequests  int `json:"pull_requests"`
	DocumentLinks int `json:"document_links"`
	Tags          int `json:"tags"`
}

type ClaimResult

type ClaimResult struct {
	Issue *model.Issue `json:"issue"`
}

ClaimResult mirrors internal/cli/issue.go:claimResult. Issue is nil when no work is currently claimable so JSON consumers see {"issue": null}.

type DocView

type DocView struct {
	Document *model.Document       `json:"document"`
	Links    []*model.DocumentLink `json:"links"`
}

DocView mirrors internal/cli/output.go:docView so JSON consumers see the same shape from `bacio doc show -o json` and `GET /documents/{filename}`.

type DocumentCascadeCount

type DocumentCascadeCount struct {
	IssueLinks   int `json:"issue_links"`
	FeatureLinks int `json:"feature_links"`
}

DocumentCascadeCount counts the link rows that would be removed alongside a document delete. Issue and feature link rows live in the same table — kept separate here to match the cascade preview rendered for issue deletes (CascadeCount) so consumers can pick out either kind.

type DocumentDeletePreview

type DocumentDeletePreview struct {
	Document    *model.Document      `json:"document"`
	Cascade     DocumentCascadeCount `json:"cascade"`
	WouldDelete bool                 `json:"would_delete"`
}

DocumentDeletePreview is the dry-run payload for DELETE /documents/{filename}.

type DocumentUnlinkPreview

type DocumentUnlinkPreview struct {
	Filename    string `json:"filename"`
	Target      string `json:"target"`
	WouldRemove int    `json:"would_remove"`
}

DocumentUnlinkPreview is the dry-run payload for DELETE /documents/{filename}/links.

type FeatureDeletePreview

type FeatureDeletePreview struct {
	Feature        *model.Feature `json:"feature"`
	WouldDelete    bool           `json:"would_delete"`
	IssuesUnlinked int            `json:"issues_unlinked"`
	DocumentLinks  int            `json:"document_links"`
}

FeatureDeletePreview mirrors internal/cli/feature.go:featureDeletePreview. IssuesUnlinked counts issues that would have feature_id set to NULL (the schema cascades via SET NULL); DocumentLinks counts document_links rows that would actually be removed.

type FeatureView

type FeatureView struct {
	Feature   *model.Feature        `json:"feature"`
	Issues    []*model.Issue        `json:"issues"`
	Documents []*model.DocumentLink `json:"documents"`
}

FeatureView mirrors internal/cli/output.go:featureView so JSON consumers see the same shape from `bacio feature show -o json` and the API.

type IssueBrief

type IssueBrief struct {
	Issue        *model.Issue          `json:"issue"`
	Feature      *model.Feature        `json:"feature,omitempty"`
	Relations    *store.IssueRelations `json:"relations"`
	PullRequests []*model.PullRequest  `json:"pull_requests"`
	Documents    []*BriefDoc           `json:"documents"`
	Comments     []*model.Comment      `json:"comments"`
	Warnings     []string              `json:"warnings"`
}

IssueBrief mirrors internal/cli/issue.go:issueBrief — bulk-context JSON payload for an issue (issue + feature + linked docs + comments + relations + PRs) collapsed into one structured response.

type IssueDeletePreview

type IssueDeletePreview struct {
	Issue       *model.Issue `json:"issue"`
	Cascade     CascadeCount `json:"cascade"`
	WouldDelete bool         `json:"would_delete"`
}

type IssueView

type IssueView struct {
	Issue        *model.Issue          `json:"issue"`
	Comments     []*model.Comment      `json:"comments"`
	Relations    *store.IssueRelations `json:"relations"`
	PullRequests []*model.PullRequest  `json:"pull_requests"`
	Documents    []*model.DocumentLink `json:"documents"`
}

type Options

type Options struct {
	Addr  string
	Token string
}

Options is the bind/auth configuration for an API server. Token is the shared bearer secret; an empty string disables auth (and logs nothing on /healthz, which is unauthenticated regardless).

type PRDetachPreview

type PRDetachPreview struct {
	IssueKey    string `json:"issue_key"`
	URL         string `json:"url"`
	WouldRemove int    `json:"would_remove"`
}

type PlanEntry

type PlanEntry struct {
	Key       string      `json:"key"`
	Title     string      `json:"title"`
	State     model.State `json:"state"`
	Assignee  string      `json:"assignee,omitempty"`
	BlockedBy []string    `json:"blocked_by,omitempty"`
}

PlanEntry mirrors internal/cli/plan.go:planEntry.

type PlanView

type PlanView struct {
	Feature string      `json:"feature"`
	Order   []PlanEntry `json:"order"`
}

PlanView mirrors internal/cli/plan.go:planView.

type RelationDeletePreview

type RelationDeletePreview struct {
	A           string `json:"a"`
	B           string `json:"b"`
	WouldRemove int    `json:"would_remove"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the wired-up HTTP server. The caller (cmd/bacio) owns the store and is responsible for Open/Close; New does not take ownership.

func New

func New(s *store.Store, opts Options, logger *slog.Logger) *Server

New constructs the server but does not start listening.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the wrapped http.Handler so tests can drive the server via httptest.NewServer without going through a real listener.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the listener and blocks until ctx is cancelled, then performs a 5s graceful shutdown via http.Server.Shutdown.

Jump to

Keyboard shortcuts

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