dev

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApp

func NewApp(svc *Service) *tygor.App

NewApp creates a tygor App with the devtools service registered. Used both for the runtime server and for type generation.

func SetupApp

func SetupApp() *tygor.App

SetupApp returns a tygor.App for type generation. This is discovered by `tygor gen` via signature detection.

Types

type AppStatus

type AppStatus struct {
	Status string `json:"status"` // "running", "building", "error", "starting"
	Port   int    `json:"port,omitempty"`
	Error  string `json:"error,omitempty"`
	Phase  string `json:"phase,omitempty"` // "prebuild", "build", "runtime"
}

AppStatus represents the status of the user's app as reported by vite plugin.

type Cmd

type Cmd struct {
	RPCDir string `help:"Directory containing generated RPC files." default:"./src/rpc" name:"rpc-dir"`
	Port   int    `help:"Port to listen on." default:"9000" short:"p"`
	Watch  bool   `help:"Watch for file changes." short:"w"`
}

func (*Cmd) Run

func (c *Cmd) Run() error

type DiscoverySchema

type DiscoverySchema struct {
	Package  PackageInfo         `json:"Package"`
	Types    []TypeDescriptor    `json:"Types"`
	Services []ServiceDescriptor `json:"Services"`
	Warnings []Warning           `json:"Warnings,omitempty"`
}

DiscoverySchema is the top-level discovery.json structure.

type Documentation

type Documentation struct {
	Summary    string  `json:"Summary,omitempty"`
	Body       string  `json:"Body,omitempty"`
	Deprecated *string `json:"Deprecated,omitempty"`
}

Documentation holds doc comments.

type EndpointDescriptor

type EndpointDescriptor struct {
	Name      string   `json:"name"`
	FullName  string   `json:"fullName"`
	Primitive string   `json:"primitive"` // "query", "exec", "stream", or "atom"
	Path      string   `json:"path"`
	Request   *TypeRef `json:"request,omitempty"`
	Response  *TypeRef `json:"response,omitempty"`
	Doc       string   `json:"doc,omitempty"`
}

EndpointDescriptor describes an RPC endpoint.

type EnumMember

type EnumMember struct {
	Name  string `json:"name"`
	Value any    `json:"value"` // string, int64, or float64
	Doc   string `json:"doc,omitempty"`
}

EnumMember describes a single enum constant.

type FieldDescriptor

type FieldDescriptor struct {
	Name          string  `json:"name"`
	Type          TypeRef `json:"type"`
	JSONName      string  `json:"jsonName"`
	Optional      bool    `json:"optional,omitempty"`
	StringEncoded bool    `json:"stringEncoded,omitempty"`
	Skip          bool    `json:"skip,omitempty"`
	ValidateTag   string  `json:"validateTag,omitempty"`
	Doc           string  `json:"doc,omitempty"`
}

FieldDescriptor describes a struct field.

type GetDiscoveryRequest

type GetDiscoveryRequest struct{}

GetDiscoveryRequest is the request for Devtools.GetDiscovery.

type GetDiscoveryResponse

type GetDiscoveryResponse struct {
	// Discovery is the parsed discovery schema.
	Discovery DiscoverySchema `json:"discovery"`
}

GetDiscoveryResponse returns the discovery.json content.

type GetSourceRequest

type GetSourceRequest struct {
	File    string `json:"file"`
	Line    int    `json:"line,omitempty"`
	Context int    `json:"context,omitempty"` // lines of context around Line (default 5)
}

GetSourceRequest is the request for Devtools.GetSource.

type GetSourceResponse

type GetSourceResponse struct {
	File     string       `json:"file"`
	Language string       `json:"language"`
	Lines    []SourceLine `json:"lines"`
	Context  int          `json:"context"`
}

GetSourceResponse returns source code with context.

type GetStatusRequest

type GetStatusRequest struct{}

GetStatusRequest is the request for Devtools.GetStatus.

type GetStatusResponse

type GetStatusResponse struct {
	Status   string   `json:"status"`
	Port     int      `json:"port,omitempty"`
	Error    string   `json:"error,omitempty"`
	Phase    string   `json:"phase,omitempty"` // "prebuild", "build", "runtime"
	Command  *string  `json:"command"`         // null when not applicable
	Cwd      string   `json:"cwd,omitempty"`
	ExitCode *int     `json:"exitCode"`           // null when not applicable
	RawrData []string `json:"rawrData,omitempty"` // sent on initial request
}

GetStatusResponse returns the combined status in flat format for the devtools UI. Status is a discriminated union: "ok", "error", "reloading", "starting", "disconnected".

type GoIdentifier

type GoIdentifier struct {
	Name    string `json:"name"`
	Package string `json:"package,omitempty"`
}

GoIdentifier is a fully-qualified Go type name.

type PackageInfo

type PackageInfo struct {
	Path string `json:"Path"`
	Name string `json:"Name"`
	Dir  string `json:"Dir"`
}

PackageInfo describes the source Go package.

type ReloadRequest

type ReloadRequest struct {
	Files  []string `json:"files,omitempty"`
	Reason string   `json:"reason,omitempty"` // "file_change", "manual"
}

ReloadRequest triggers a reload of discovery.json.

type ReloadResponse

type ReloadResponse struct{}

ReloadResponse is the response for Reload.

type Service

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

Service implements the devtools server endpoints.

func (*Service) GetDiscovery

func (s *Service) GetDiscovery(ctx context.Context, req *GetDiscoveryRequest) (*GetDiscoveryResponse, error)

GetDiscovery returns the discovery.json from the rpc-dir.

func (*Service) GetSource

func (s *Service) GetSource(ctx context.Context, req *GetSourceRequest) (*GetSourceResponse, error)

GetSource returns source code with context around a line.

func (*Service) GetStatus

GetStatus streams status updates for devtools UI consumption. The first message always includes RawrData. Subsequent messages are sent when UpdateStatus is called.

func (*Service) Reload

func (s *Service) Reload(ctx context.Context, req *ReloadRequest) (*ReloadResponse, error)

Reload triggers reloading of discovery.json (called by vite plugin on file changes).

func (*Service) UpdateStatus

func (s *Service) UpdateStatus(ctx context.Context, req *UpdateStatusRequest) (*UpdateStatusResponse, error)

UpdateStatus updates the app status (called by vite plugin). Notifies all connected GetStatus subscribers of the change.

type ServiceDescriptor

type ServiceDescriptor struct {
	Name      string               `json:"name"`
	Endpoints []EndpointDescriptor `json:"endpoints"`
	Doc       string               `json:"doc,omitempty"`
}

ServiceDescriptor describes a service and its endpoints.

type SourceLine

type SourceLine struct {
	Num       int    `json:"num"`
	Content   string `json:"content"`
	Highlight bool   `json:"highlight,omitempty"`
}

SourceLine represents a single line of source code.

type SourceLocation

type SourceLocation struct {
	File   string `json:"File"`
	Line   int    `json:"Line"`
	Column int    `json:"Column"`
}

SourceLocation points to a position in source code.

type TypeDescriptor

type TypeDescriptor struct {
	Kind           string            `json:"kind"` // "struct", "enum", "alias"
	Name           GoIdentifier      `json:"Name"`
	TypeParameters []TypeParameter   `json:"TypeParameters,omitempty"`
	Fields         []FieldDescriptor `json:"Fields,omitempty"`     // for struct
	Members        []EnumMember      `json:"Members,omitempty"`    // for enum
	Underlying     *TypeRef          `json:"Underlying,omitempty"` // for alias
	Extends        []GoIdentifier    `json:"Extends,omitempty"`
	Documentation  *Documentation    `json:"Documentation,omitempty"`
	Source         *SourceLocation   `json:"Source,omitempty"`
}

TypeDescriptor is a named type (struct, enum, or alias). Uses kind discriminator for polymorphism.

type TypeParameter

type TypeParameter struct {
	Kind       string   `json:"kind"` // "typeParameter"
	ParamName  string   `json:"paramName"`
	Constraint *TypeRef `json:"constraint,omitempty"`
}

TypeParameter describes a generic type parameter.

type TypeRef

type TypeRef struct {
	Kind          string    `json:"kind"`                    // "primitive", "reference", "array", "map", "ptr", "union", "typeParameter"
	PrimitiveKind string    `json:"primitiveKind,omitempty"` // for primitive
	BitSize       int       `json:"bitSize,omitempty"`       // for numeric primitives
	Name          string    `json:"name,omitempty"`          // for reference
	Package       string    `json:"package,omitempty"`       // for reference
	Element       *TypeRef  `json:"element,omitempty"`       // for array, ptr
	Length        int       `json:"length,omitempty"`        // for array (0 = slice)
	Key           *TypeRef  `json:"key,omitempty"`           // for map
	Value         *TypeRef  `json:"value,omitempty"`         // for map
	Types         []TypeRef `json:"types,omitempty"`         // for union
	ParamName     string    `json:"paramName,omitempty"`     // for typeParameter
	Constraint    *TypeRef  `json:"constraint,omitempty"`    // for typeParameter
}

TypeRef is a reference to a type (used in fields, requests, responses). Uses kind discriminator for the various type expression forms.

type UpdateStatusRequest

type UpdateStatusRequest struct {
	App AppStatus `json:"app"`
}

UpdateStatusRequest is sent by vite plugin to update app status.

type UpdateStatusResponse

type UpdateStatusResponse struct{}

UpdateStatusResponse is the response for UpdateStatus.

type Warning

type Warning struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Warning represents a non-fatal issue during schema generation.

Jump to

Keyboard shortcuts

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