envelope

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package envelope provides the standard JSON response wrapper for all --json output.

Index

Constants

View Source
const SchemaVersion = "v1"

SchemaVersion is the public contract version. Consumers decoding this envelope should branch on major-version changes (v1 -> v2) and expect additive changes within a version. Adding a field is backward-compatible (unknown fields are ignored by Go's json decoder). Renaming or removing a field is a breaking change and requires a major-version bump.

Variables

This section is empty.

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	SchemaVersion string      `json:"schema_version"`
	Command       string      `json:"command"`
	Status        string      `json:"status"`
	Warnings      []Issue     `json:"warnings"`
	Errors        []Issue     `json:"errors"`
	Result        interface{} `json:"result"`
	Meta          Meta        `json:"meta"`
}

Envelope is the standard JSON response wrapper for all --json output.

func Error

func Error(command, code, message, field string) *Envelope

Error creates an error envelope.

func OK

func OK(command string, result interface{}) *Envelope

OK creates a successful envelope.

func (*Envelope) AddWarning

func (e *Envelope) AddWarning(code, message, field string)

AddWarning adds a structured warning and updates status.

type Issue

type Issue struct {
	Code       string   `json:"code"`
	Message    string   `json:"message"`
	Field      string   `json:"field,omitempty"`
	Candidates []string `json:"candidates,omitempty"`
}

Issue represents a structured warning or error.

type Meta

type Meta struct {
	VaultPath  string `json:"vault_path"`
	IndexHash  string `json:"index_hash"`
	Timestamp  string `json:"timestamp"`
	IndexStale bool   `json:"index_stale,omitempty"`
}

Meta contains envelope metadata.

Jump to

Keyboard shortcuts

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