Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(spec query.Dashboard, ops []Operation) (query.Dashboard, bool, error)
- func Compact(panels []query.Panel)
- func DefaultSpec() query.Dashboard
- func MarkSaveCommitted(ctx context.Context)
- func OwnerFromContext(ctx context.Context) string
- func PackMissing(panels []query.Panel)
- func SaveCommitted(ctx context.Context) bool
- func TrackSave(ctx context.Context) context.Context
- func WithBuildOrigin(ctx context.Context, origin BuildOrigin) context.Context
- func WithOwner(ctx context.Context, ownerID string) context.Context
- func WithSaveCheck(ctx context.Context, check func(context.Context, query.Dashboard) error) context.Context
- type Author
- type BuildOrigin
- type ChangeSet
- type Mutation
- type Operation
- type PanelChange
- type Record
- type Service
- func (s *Service) Create(ctx context.Context, ownerID string, spec query.Dashboard, author Author) (Record, error)
- func (s *Service) CreateWithChanges(ctx context.Context, ownerID string, spec query.Dashboard, author Author) (Mutation, error)
- func (s *Service) Delete(ctx context.Context, ownerID, id string) error
- func (s *Service) Edit(ctx context.Context, ownerID, id string, ops []Operation, baseVersion int, ...) (Record, error)
- func (s *Service) EditWithChanges(ctx context.Context, ownerID, id string, ops []Operation, baseVersion int, ...) (Mutation, error)
- func (s *Service) Get(ctx context.Context, ownerID, id string) (Record, error)
- func (s *Service) List(ctx context.Context, ownerID string) ([]Summary, error)
- func (s *Service) Replace(ctx context.Context, ownerID, id string, spec query.Dashboard, baseVersion int, ...) (Record, error)
- func (s *Service) ReplaceWithChanges(ctx context.Context, ownerID, id string, spec query.Dashboard, baseVersion int, ...) (Mutation, error)
- func (s *Service) Restore(ctx context.Context, ownerID, id string, version int, author Author) (Record, error)
- func (s *Service) RestoreWithChanges(ctx context.Context, ownerID, id string, version int, author Author) (Mutation, error)
- func (s *Service) VersionRecord(ctx context.Context, owner, id string, version int) (VersionRecord, error)
- func (s *Service) Versions(ctx context.Context, ownerID, id string) ([]VersionInfo, error)
- type Summary
- type Validator
- type VersionInfo
- type VersionRecord
Constants ¶
const AlreadyCurrentCode = "already_current"
const BuildOriginMetaKey = "io.pitot/build-origin"
const OAuthScope = auth.MCPScopeDashboardManage
const OwnerMetaKey = "io.pitot/owner-id"
OwnerMetaKey carries the dashboard owner's user ID in MCP request _meta.
Trust model (three-file invariant): io.pitot/owner-id and io.pitot/build-origin are client-suppliable metadata. Dashboard tools trust these values ONLY on the in-process path with authenticated owner injection from internal/agent/tools.go. ProtectMCP and ProtectBrowserMCP (internal/api/oauth.go) guarantee OAuth TokenInfo on both HTTP mounts; remote TokenInfo takes precedence, and remote metadata cannot fabricate ownership or conversation provenance.
const RowHeight = 40
RowHeight is the grid row height in pixels; ui/host/src/dashboards/grid.tsx uses the same value.
const VersionNotFoundCode = "dashboard_version_not_found"
Variables ¶
var ( ErrNotFound = errors.New("dashboard not found") ErrConflict = errors.New("a dashboard with that name already exists") ErrStale = errors.New("the dashboard changed since it was read") )
var ErrAlreadyCurrent = errors.New("dashboard version is already current")
var ErrVersionNotFound = errors.New("dashboard version not found")
Functions ¶
func Apply ¶
Apply runs operations in order on a copy of spec. The bool reports whether panels were moved or resized, which requires a fresh pack. Additions keep existing coordinates and receive their own placement in prepare.
func Compact ¶
Compact repairs unusable grids, then closes vertical gaps without changing usable columns or dimensions. Work depends on panel count, never grid Y.
func DefaultSpec ¶
DefaultSpec is every owner's first dashboard: the shape of the whole system, filterable to one service.
func MarkSaveCommitted ¶
MarkSaveCommitted records a confirmed database commit or successful remote mutation result before any subsequent receipt/encoding work can panic.
func OwnerFromContext ¶
func PackMissing ¶
PackMissing preserves every valid, non-overlapping supplied grid and packs only panels without usable coordinates around them.
func SaveCommitted ¶
func TrackSave ¶
TrackSave starts a per-call observation, shared with nested service work. It is never serialized or accepted as client-supplied metadata.
func WithBuildOrigin ¶
func WithBuildOrigin(ctx context.Context, origin BuildOrigin) context.Context
Types ¶
type BuildOrigin ¶
type BuildOrigin struct {
ThreadID string `json:"thread_id"`
MessageID string `json:"message_id"`
RequestExcerpt string `json:"request_excerpt"`
}
func BuildOriginFromContext ¶
func BuildOriginFromContext(ctx context.Context) (BuildOrigin, bool)
type ChangeSet ¶
type ChangeSet struct {
Panels []PanelChange `json:"panels"`
LayoutChanged bool `json:"layout_changed"`
DashboardFields []string `json:"dashboard_fields,omitempty"`
}
type Operation ¶
type Operation struct {
Op string `json:"op" jsonschema:"add_panel, update_panel, remove_panel, move_panel, set_variable, remove_variable, set_time or rename"`
ID string `json:"id,omitempty" jsonschema:"update_panel, remove_panel, move_panel: the panel id"`
After string `` /* 144-byte string literal not displayed */
Panel *query.Panel `json:"panel,omitempty" jsonschema:"add_panel: the complete new panel"`
Set map[string]any `` /* 143-byte string literal not displayed */
Variable *query.Variable `json:"variable,omitempty" jsonschema:"set_variable: the variable, added or replaced by name"`
Name string `json:"name,omitempty" jsonschema:"remove_variable: the variable name; rename: the new dashboard name"`
Description *string `json:"description,omitempty" jsonschema:"rename: the new description"`
Time *query.Time `json:"time,omitempty" jsonschema:"set_time: the new default time"`
}
Operation is one typed edit. Panels are addressed by their stable id, never by position, so an edit lands on exactly the panel it names.
type PanelChange ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) CreateWithChanges ¶
func (*Service) Edit ¶
func (s *Service) Edit(ctx context.Context, ownerID, id string, ops []Operation, baseVersion int, author Author, message string) (Record, error)
Edit applies typed operations atomically. baseVersion 0 means "the latest".
func (*Service) EditWithChanges ¶
func (*Service) Replace ¶
func (s *Service) Replace(ctx context.Context, ownerID, id string, spec query.Dashboard, baseVersion int, author Author, message string) (Record, error)
Replace stores a whole new spec. baseVersion 0 means "the latest".
func (*Service) ReplaceWithChanges ¶
func (*Service) RestoreWithChanges ¶
func (s *Service) RestoreWithChanges(ctx context.Context, ownerID, id string, version int, author Author) (Mutation, error)
RestoreWithChanges appends a historical spec as a new save against the latest optimistic base, retaining the committed snapshots for the shared diff.
func (*Service) VersionRecord ¶
func (s *Service) VersionRecord(ctx context.Context, owner, id string, version int) (VersionRecord, error)
VersionRecord reads immutable historical content and its shared save diff. IsDefault describes the current owned board; UpdatedAt is the version time.
type Validator ¶
Validator checks a spec completely, including its filters and SQL. *panel.Executor implements it.
type VersionInfo ¶
type VersionRecord ¶
type VersionRecord struct {
Dashboard Record `json:"dashboard"`
AuthorKind string `json:"author_kind"`
AuthorID string `json:"author_id,omitempty"`
Message string `json:"message,omitempty"`
CreatedAt string `json:"created_at"`
Changes []PanelChange `json:"changes"`
LayoutChanged bool `json:"layout_changed"`
DashboardFields []string `json:"dashboard_fields"`
ChangesAvailable bool `json:"changes_available"`
}