Documentation
¶
Overview ¶
Package typecatalog owns structural type lookup, resolution context, and layered package/generated/DQL type authority.
Index ¶
- func CloneDescriptor(source *x.Type) (*x.Type, error)
- func ExportedFieldName(name string) string
- func FieldByName(structType reflect.Type, name string) (reflect.StructField, bool)
- func FieldName(name string) string
- type AmbiguityError
- type Authority
- type Catalog
- func (c *Catalog) Clone() (*Catalog, error)
- func (c *Catalog) ImportReferences(source *Catalog, keys []string) error
- func (c *Catalog) LinkRuntimeAll(origin TypeOrigin, types ...*x.Type) error
- func (c *Catalog) LinkRuntimeTypes(origin TypeOrigin, types ...*x.Type) error
- func (c *Catalog) Register(origin TypeOrigin, typ *x.Type) error
- func (c *Catalog) RegisterAll(origin TypeOrigin, types ...*x.Type) error
- func (c *Catalog) RegisterPackage(origin TypeOrigin, pkg *smodel.Package) error
- func (c *Catalog) RegisterPackageFiles(pkg *smodel.Package, generatedFiles map[string]bool) error
- func (c *Catalog) Registry(authority Authority) (*x.Registry, error)
- func (c *Catalog) Resolve(authority Authority, key string) (*x.Type, bool, error)
- func (c *Catalog) ResolveRuntimeType(authority Authority, key string) (reflect.Type, bool, error)
- type ContextValidationIssue
- type Destination
- type DestinationAuthority
- type PackageImport
- type Provenance
- type Resolution
- type ResolutionContext
- type Resolver
- func (r *Resolver) CanonicalDeclaration(expression, defaultPackage string) (string, error)
- func (r *Resolver) Descriptor(typeExpr string) (*x.Type, error)
- func (r *Resolver) Resolve(typeExpr string) (string, error)
- func (r *Resolver) ResolveShape(typeExpr string) (*xshape.Resolution, error)
- func (r *Resolver) ResolveWithProvenance(typeExpr string) (*Resolution, error)
- func (r *Resolver) Type(typeExpr string) (reflect.Type, error)
- type TypeOrigin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneDescriptor ¶
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 ¶
ExportedFieldName preserves an already exported Go identifier and otherwise applies the canonical authored-name conversion.
func FieldByName ¶
FieldByName resolves an authored field name against a Go struct type.
Types ¶
type AmbiguityError ¶
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.
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 ¶
Clone returns a detached catalog snapshot that can be safely extended without mutating the source catalog.
func (*Catalog) ImportReferences ¶ added in v1.1.0
ImportReferences adds only the requested declarations from a staged catalog, preserving their ownership. It does not replace whole package snapshots.
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) 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 ¶
RegisterPackageFiles preserves source ownership in a shared generated package. Current emitted files and generated source comments classify declarations; unrelated authored files retain package authority.
func (*Catalog) Registry ¶
Registry returns a deterministic snapshot for one authority. Later catalog registrations cannot mutate the returned registry.
func (*Catalog) ResolveRuntimeType ¶
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 ¶
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 Provenance ¶
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 ¶
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 ¶
Descriptor resolves an expression to its detached viant/x type descriptor. Synthetic-only generated types are returned without fabricating reflect.Type.
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)
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" )