typecatalog

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 7

Documentation

Overview

Package typecatalog owns structural type lookup, resolution context, and layered package/generated/DQL type authority.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneDescriptor

func CloneDescriptor(source *x.Type) (*x.Type, error)

CloneDescriptor returns a descriptor whose mutable synthetic syntax is detached from source. It is the shared clone boundary for catalog snapshots and package-aware resolvers.

func ExportedFieldName

func ExportedFieldName(name string) string

ExportedFieldName preserves an already exported Go identifier and otherwise applies the canonical authored-name conversion.

func FieldByName

func FieldByName(structType reflect.Type, name string) (reflect.StructField, bool)

FieldByName resolves an authored field name against a Go struct type.

func FieldName

func FieldName(name string) string

FieldName converts an authored identifier into its canonical exported Go field name using Tagly's case-format authority.

Types

type AmbiguityError

type AmbiguityError struct {
	Expression string
	Candidates []string
}

func (*AmbiguityError) Error

func (e *AmbiguityError) Error() string

type Authority

type Authority string

Authority selects the source-of-truth order for an immutable catalog view.

const (
	PackageAuthority    Authority = "package"
	TranscribeAuthority Authority = "transcribe"
)

type Catalog

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

Catalog retains all known structural types without assigning one global precedence. Callers select package or transcribe authority when resolving.

func NewCatalog

func NewCatalog() *Catalog

func (*Catalog) Clone

func (c *Catalog) Clone() (*Catalog, error)

Clone returns a detached catalog snapshot that can be safely extended without mutating the source catalog.

func (*Catalog) LinkRuntimeAll

func (c *Catalog) LinkRuntimeAll(origin TypeOrigin, types ...*x.Type) error

LinkRuntimeAll attaches available compiled Go identities to source-backed descriptors without replacing their declaration metadata. A source-only descriptor is retained as-is. Indexed bootstrap first loads package ASTs and initialized binaries subsequently contribute reflect.Types; those are two representations of the same package authority, not duplicate registrations.

func (*Catalog) LinkRuntimeTypes

func (c *Catalog) LinkRuntimeTypes(origin TypeOrigin, types ...*x.Type) error

LinkRuntimeTypes attaches compiled Go identities to existing source-backed registrations from the same package origin. It preserves the source descriptor and still rejects a different compiled identity for an already linked key. The update is atomic across the supplied group.

func (*Catalog) Register

func (c *Catalog) Register(origin TypeOrigin, typ *x.Type) error

func (*Catalog) RegisterAll

func (c *Catalog) RegisterAll(origin TypeOrigin, types ...*x.Type) error

RegisterAll atomically adds a group of types under one origin. Validation or conflicts leave the catalog unchanged.

func (*Catalog) RegisterPackage

func (c *Catalog) RegisterPackage(origin TypeOrigin, pkg *smodel.Package) error

RegisterPackage adds every declared type in a loaded synthetic package under one origin. The package remains the source artifact; Catalog is the sole authority used for subsequent type resolution.

func (*Catalog) RegisterPackageFiles

func (c *Catalog) RegisterPackageFiles(pkg *smodel.Package, generatedFiles map[string]bool) error

RegisterPackageFiles preserves source ownership in a shared generated package. The file ownership manifest classifies declarations; it never promotes an unrelated authored file to generated authority.

func (*Catalog) Registry

func (c *Catalog) Registry(authority Authority) (*x.Registry, error)

Registry returns a deterministic snapshot for one authority. Later catalog registrations cannot mutate the returned registry.

func (*Catalog) Resolve

func (c *Catalog) Resolve(authority Authority, key string) (*x.Type, bool, error)

func (*Catalog) ResolveRuntimeType

func (c *Catalog) ResolveRuntimeType(authority Authority, key string) (reflect.Type, bool, error)

ResolveRuntimeType returns only the immutable Go identity of the selected descriptor. A found synthetic-only declaration returns nil, true; it must not fall through to a lower-priority origin's compiled type.

type ContextValidationIssue

type ContextValidationIssue struct {
	Field   string
	Message string
}

func ValidateContext

func ValidateContext(context *ResolutionContext) []ContextValidationIssue

type Destination

type Destination struct{ Directory, ImportPath, Name string }

type DestinationAuthority

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

DestinationAuthority confines authored generation packages to one project and its enclosing module. Type lookup authority never grants write authority.

func NewDestinationAuthority

func NewDestinationAuthority(root string) (*DestinationAuthority, error)

func (*DestinationAuthority) Package

func (a *DestinationAuthority) Package(authored, fallback string) (Destination, error)

type PackageImport

type PackageImport struct {
	Alias   string `json:",omitempty" yaml:",omitempty"`
	Package string `json:",omitempty" yaml:",omitempty"`
}

type Provenance

type Provenance struct {
	Package string `json:",omitempty" yaml:",omitempty"`
	File    string `json:",omitempty" yaml:",omitempty"`
	Kind    string `json:",omitempty" yaml:",omitempty"`
}

type Resolution

type Resolution struct {
	Expression  string     `json:",omitempty" yaml:",omitempty"`
	Target      string     `json:",omitempty" yaml:",omitempty"`
	ResolvedKey string     `json:",omitempty" yaml:",omitempty"`
	MatchKind   string     `json:",omitempty" yaml:",omitempty"`
	Provenance  Provenance `json:",omitempty" yaml:",omitempty"`
}

type ResolutionContext

type ResolutionContext struct {
	DefaultPackage string          `json:",omitempty" yaml:",omitempty"`
	Imports        []PackageImport `json:",omitempty" yaml:",omitempty"`
	PackageDir     string          `json:",omitempty" yaml:",omitempty"`
	PackageName    string          `json:",omitempty" yaml:",omitempty"`
	PackagePath    string          `json:",omitempty" yaml:",omitempty"`
}

func NormalizeContext

func NormalizeContext(input *ResolutionContext) *ResolutionContext

NormalizeContext returns a detached, canonical type-resolution context.

type Resolver

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

Resolver applies package/import context over an immutable catalog snapshot. Native shape resolution and public results receive detached descriptors.

func NewResolver

func NewResolver(catalog *Catalog, authority Authority, context *ResolutionContext) (*Resolver, error)

func NewResolverWithProvenance

func NewResolverWithProvenance(catalog *Catalog, authority Authority, context *ResolutionContext, provenance map[string]Provenance) (*Resolver, error)

func (*Resolver) CanonicalDeclaration

func (r *Resolver) CanonicalDeclaration(expression, defaultPackage string) (string, error)

CanonicalDeclaration applies authored import/default-package authority to a type declaration in a destination-normalized defaultPackage. Source lookup scope is not a declaration destination. Native shape owns expression syntax.

func (*Resolver) Descriptor

func (r *Resolver) Descriptor(typeExpr string) (*x.Type, error)

Descriptor resolves an expression to its detached viant/x type descriptor. Synthetic-only generated types are returned without fabricating reflect.Type.

func (*Resolver) Resolve

func (r *Resolver) Resolve(typeExpr string) (string, error)

func (*Resolver) ResolveShape

func (r *Resolver) ResolveShape(typeExpr string) (*xshape.Resolution, error)

ResolveShape resolves the complete expression identity and its base descriptor under this resolver's package and import authority.

func (*Resolver) ResolveWithProvenance

func (r *Resolver) ResolveWithProvenance(typeExpr string) (*Resolution, error)

func (*Resolver) Type

func (r *Resolver) Type(typeExpr string) (reflect.Type, error)

Type resolves an expression to the catalog's effective reflect type.

type TypeOrigin

type TypeOrigin string

TypeOrigin identifies where a structural type entered Datly's authority.

const (
	TypeOriginPackage   TypeOrigin = "package"
	TypeOriginGenerated TypeOrigin = "generated"
	TypeOriginDQL       TypeOrigin = "dql"
)

Jump to

Keyboard shortcuts

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