Documentation
¶
Overview ¶
Package ast defines the target-neutral semantic tree used to generate Go and Velty handlers. It contains no canonical-metadata compiler or target syntax.
Index ¶
- type Action
- type ContractRef
- type CurrentField
- type CurrentPlan
- type EntityField
- type EntityPlan
- type FieldPath
- type FieldRef
- type InvariantGroup
- type KeyLink
- type KeyPart
- type LateWriteEffects
- type LinkConversion
- type LookupProjection
- type Operation
- type Plan
- type ReadCollection
- type ReadGroup
- type RecordPlan
- type RelationPlan
- type SelfRelationPlan
- type SequencePlan
- type WritePolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContractRef ¶
type ContractRef struct {
ParamIdentity string
Path FieldPath
Cardinality spec.Cardinality
}
ContractRef identifies one canonical parameter and its generated field.
type CurrentField ¶
type CurrentField struct {
Current FieldRef
Entity FieldRef
Conversion LinkConversion
}
CurrentField describes one typed assignment from a database current row into the entity-shaped Previous value. Dereference requires a non-nil source; consumers must not silently turn a loaded SQL NULL into a scalar zero.
type CurrentPlan ¶
type CurrentPlan struct {
Lookup *LookupProjection
ParamIdentity string
ViewIdentity string
InputPath FieldPath
Keys []KeyPart
// Fields is the declared current-to-entity projection, not evidence that a
// particular read selected these fields. PreviousFields requires read provenance.
Fields []CurrentField
// Self names the actual read row's self-reference holders, not entity edges.
Self []FieldRef
}
type EntityField ¶
type EntityField struct {
Name string
Path FieldPath
Type spec.TypeRef
Identity bool
Relation bool
Self bool
Writable bool
Invariant string
DeleteMarker bool
ConcurrencyToken bool
}
EntityField describes a canonical field whose presence is owned by the mutable entity contract. Identity presence does not authorize an UPDATE SET.
type EntityPlan ¶
type EntityPlan struct {
Type spec.TypeRef
MarkerField string
MarkerPointer bool
Owned bool
MarkerType spec.TypeRef
Fields []EntityField
Keys []KeyPart
Invariants []InvariantGroup
Hooks spec.TypeRef
// HooksScaffold marks an explicit unresolved local lifecycle declaration.
HooksScaffold bool
HooksBind bool
LateWrite LateWriteEffects
}
EntityPlan carries immutable generation facts for typed setters and original presence capture. Hook invocation phases are separate handler semantics.
func (*EntityPlan) Clone ¶
func (p *EntityPlan) Clone() *EntityPlan
type FieldPath ¶
type FieldPath []string
FieldPath is a prevalidated generated-contract selector path.
type InvariantGroup ¶
InvariantGroup is a normalized group of business fields whose omitted values may be hydrated from the matched database projection before validation.
type KeyLink ¶
type KeyLink struct {
Parent KeyPart
Child KeyPart
ParentNamespace string
ChildNamespace string
Conversion LinkConversion
}
KeyLink describes one ordered parent-to-child relation key assignment.
type LateWriteEffects ¶
type LateWriteEffects struct {
Unresolved string
InsertHook bool
UpdateHook bool
DefaultFields []string
}
LateWriteEffects describes native row behavior executed during write flush, after generic mutation business validation has already completed.
type LinkConversion ¶
type LinkConversion string
LinkConversion identifies the typed assignment needed for relation keys and current-to-entity field projections. Velty dereferences transparently; the Go target consumes this explicitly.
const ( LinkDirect LinkConversion = "direct" LinkAddress LinkConversion = "address" LinkDereference LinkConversion = "dereference" )
type LookupProjection ¶
type LookupProjection struct {
// ParentOnly projects the already scoped Previous parent, without request fallback.
ParentOnly bool
Name string
Columns []string
}
CurrentPlan describes the ordinary input datapoint used for PATCH lookup. LookupProjection names a pure typed projection for a generated auxiliary read. The enclosing relation supplies identity and value-link semantics.
func (*LookupProjection) Clone ¶
func (p *LookupProjection) Clone() *LookupProjection
type Plan ¶
type Plan struct {
ReadCollections []ReadCollection
Operation Operation
Input ContractRef
Output *ContractRef
Root *RecordPlan
}
Plan is the immutable target-neutral input to handler target lowering.
type ReadCollection ¶
type ReadCollection struct {
Name string
InputPath FieldPath
Type spec.TypeRef
Fields []FieldRef
Keys []KeyPart
// Groups are exact canonical relationship tuples prepared automatically.
Groups []ReadGroup
}
ReadCollection describes an ordinary bound read for application lookup. It grants no write permission; CurrentPlan owns mutation matching scope.
type ReadGroup ¶
type ReadGroup struct{ Parts []KeyPart }
ReadGroup is a typed relationship-key tuple, not an inferred naming convention.
type RecordPlan ¶
type RecordPlan struct {
Identity string
// Auxiliary records remain available to business reads/indexes, but are
// excluded from generated sequencing and mutation traversal.
Auxiliary bool
InputPath FieldPath
Current *CurrentPlan
Table string
Cardinality spec.Cardinality
Keys []KeyPart
// PresenceFields are generated-view fields whose programmatic assignments
// must be exposed to SQLX PATCH updates through the generated Has marker.
// Package-linked record authority leaves this empty.
PresenceFields []string
Entity *EntityPlan
Sequence *SequencePlan
Write WritePolicy
Relations []*RelationPlan
SelfRelations []SelfRelationPlan
}
RecordPlan describes one canonical record write and its ordered children.
func (*RecordPlan) IdentityKeys ¶
func (r *RecordPlan) IdentityKeys() []KeyPart
IdentityKeys returns the final entity identity when refined, otherwise the source-view identity. Callers must treat the returned metadata as immutable.
func (*RecordPlan) TracksPresence ¶
func (r *RecordPlan) TracksPresence(field string) bool
TracksPresence reports whether generated business logic owns the presence bit for field. The slice keeps the semantic plan deterministic and portable across target lowerers.
type RelationPlan ¶
type RelationPlan struct {
// AllowReparent is explicit permission to change non-identity parent links.
AllowReparent bool
Identity string
FieldPath FieldPath
Cardinality spec.Cardinality
Links []KeyLink
Child *RecordPlan
}
RelationPlan describes one typed child traversal from a parent record.
func (*RelationPlan) WriteHookName ¶
func (r *RelationPlan) WriteHookName() (string, error)
WriteHookName is the canonical optional typed relation hook name used by both generated targets.
type SelfRelationPlan ¶
SelfRelationPlan describes holder-specific linking within the same row type. It has no child plan: the existing record role owns recursive traversal.
type SequencePlan ¶
type SequencePlan struct {
Destination FieldPath
Selector FieldPath
// Field is the canonical local row field, independent of root traversal syntax.
Field FieldRef
}
SequencePlan describes identifier allocation through the injected sequencer.