contractscan

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package contractscan discovers runtime contract registrations in normal Go source using the standard Go AST.

Index

Constants

View Source
const RuntimeImportPath = "github.com/cssbruno/gowdk/runtime/contracts"

Variables

This section is empty.

Functions

func LinkReferences

func LinkReferences(refs []gwdkir.ContractReference, report Report) []gwdkir.ContractReference

Types

type Contract

type Contract struct {
	Kind             runtimecontracts.Kind          `json:"kind"`
	EventCategory    runtimecontracts.EventCategory `json:"eventCategory,omitempty"`
	Package          string                         `json:"package,omitempty"`
	Type             string                         `json:"type"`
	TypeImportPath   string                         `json:"typeImportPath,omitempty"`
	Result           string                         `json:"result,omitempty"`
	ResultImportPath string                         `json:"resultImportPath,omitempty"`
	Handler          string                         `json:"handler,omitempty"`
	Register         string                         `json:"register,omitempty"`
	InputFields      []manifest.BackendInputField   `json:"inputFields,omitempty"`
	Emits            []EventRef                     `json:"emits,omitempty"`
	Roles            []string                       `json:"roles,omitempty"`
	Source           string                         `json:"source"`
	Line             int                            `json:"line"`
	Column           int                            `json:"column"`
}

Contract describes one discovered registration call.

type Diagnostic

type Diagnostic struct {
	Severity       string                `json:"severity"`
	Code           string                `json:"code,omitempty"`
	Kind           runtimecontracts.Kind `json:"kind,omitempty"`
	Package        string                `json:"package,omitempty"`
	Type           string                `json:"type,omitempty"`
	TypeImportPath string                `json:"typeImportPath,omitempty"`
	Handler        string                `json:"handler,omitempty"`
	Source         string                `json:"source"`
	Line           int                   `json:"line"`
	Column         int                   `json:"column"`
	Message        string                `json:"message"`
}

Diagnostic describes a validation issue found while scanning contracts.

type EventRef

type EventRef struct {
	Category       runtimecontracts.EventCategory `json:"category"`
	Type           string                         `json:"type"`
	TypeImportPath string                         `json:"typeImportPath,omitempty"`
}

EventRef describes one event a command handler can emit.

type Report

type Report struct {
	Version     int          `json:"version"`
	Root        string       `json:"root"`
	Contracts   []Contract   `json:"contracts"`
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}

Report is the full discovery output.

func Scan

func Scan(root string) (Report, error)

Scan walks root and reports registrations that call runtime/contracts helpers.

func (Report) Filter

func (report Report) Filter(kind runtimecontracts.Kind) []Contract

Filter returns contracts of kind. Empty kind returns a copy of all contracts.

func (Report) JSON

func (report Report) JSON(kind runtimecontracts.Kind) ([]byte, error)

JSON returns deterministic indented JSON.

Jump to

Keyboard shortcuts

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