tag

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: 14 Imported by: 6

Documentation

Overview

Package tag owns Datly-specific Go struct-tag metadata.

Binding tags are delegated to Bindly and sqlx tags are delegated to SQLX; this package does not maintain compatibility parsers for either mechanism.

Index

Constants

View Source
const (
	RouteNameTag    = "routeName"
	APIKeyHeaderTag = "apiKeyHeader"
	APIKeyValueTag  = "apiKeyValue"
	InternalTag     = "internal"
	MCPTag          = "mcp"
)
View Source
const (
	SQLName         = "sql"
	RelationName    = "on"
	SourceName      = "source"
	SelectorAlias   = "selectorAlias"
	GroupableName   = "groupable"
	DescriptionName = "desc"
	ExampleName     = "example"
)
View Source
const (
	SequenceStrategyTag = "sequenceStrategy"
	CaseFormatTag       = "caseFormat"
	CacheTag            = "cache"
	JSONMarshalTag      = "jsonMarshal"
	JSONUnmarshalTag    = "jsonUnmarshal"
	XMLUnmarshalTag     = "xmlUnmarshal"
	FormatTag           = "format"
	DateFormatTag       = "dateFormat"
	OutputSettingsTag   = "output"
	IgnoreEmptyQueryTag = "ignoreEmptyQueryParameters"
	MutationTag         = "mutation"
)
View Source
const CodecName = "codec"
View Source
const ComponentName = "component"
View Source
const InvariantName = "invariant"
View Source
const PredicateName = "predicate"
View Source
const QuerySelectorName = "querySelector"
View Source
const SelfName = "self"
View Source
const ViewName = "view"

Variables

This section is empty.

Functions

func BindingAliases

func BindingAliases(field reflect.StructField, param *spec.Parameter) []string

BindingAliases returns the logical and physical names for one bound field. A param source names another input datapoint and is therefore a dependency, not an alias owned by the derived destination field.

func ParseInvariant

func ParseInvariant(value string) (string, error)

ParseInvariant accepts one authored group name. Group-to-method naming is a semantic compilation decision; this boundary does not split lists silently.

func ParsePredicates

func ParsePredicates(structTag reflect.StructTag) ([]*spec.Predicate, error)

ParsePredicates parses every predicate tag attached to one Go field.

func ParseSQLMethods

func ParseSQLMethods(value string) ([]spec.SQLMethod, error)

ParseSQLMethods decodes the canonical selector-method JSON used by both Go view tags and DQL selector policy declarations.

func PredicateValue

func PredicateValue(predicate *spec.Predicate) (string, error)

PredicateValue formats canonical predicate metadata using ParsePredicates' grammar. Argument order remains authored order.

func RelationValue

func RelationValue(links []*RelationLink) (string, error)

RelationValue formats typed relation links using ParseRelation's grammar.

Types

type BindingField

type BindingField struct {
	Field   reflect.StructField
	Binding bindly.BindingSpec
	Tagged  bool
}

type BindingIndex

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

BindingIndex is the parsed Bindly field metadata for one input contract.

func NewBindingIndex

func NewBindingIndex(structType reflect.Type) (*BindingIndex, error)

func (*BindingIndex) Fields

func (i *BindingIndex) Fields() []BindingField

func (*BindingIndex) Resolve

func (i *BindingIndex) Resolve(param *spec.Parameter) (reflect.StructField, bool, error)

Resolve matches a canonical parameter to a Go input field. Structural names take precedence for ordinary parameters. View selectors first match their explicit source because different views can share a logical property name. Bindly aliases and source locations handle remaining package field matches.

type Codec

type Codec struct {
	Name       string
	Body       string
	Arguments  []string
	OutputType string
}

func ParseCodec

func ParseCodec(value string) (*Codec, error)

func (Codec) Value

func (c Codec) Value() (string, error)

Value formats codec metadata using the same grammar accepted by ParseCodec.

type Component

type Component struct {
	Documentation         xdocs.Source
	Name                  string
	RouteName             string
	Path                  string
	Method                string
	Connector             string
	Marshaller            string
	Handler               string
	APIKeyHeader          string
	APIKeyValue           string
	Input                 string
	Output                string
	View                  string
	Source                string
	Description           string
	Example               string
	Internal              bool
	WarmupTarget          string
	Report                bool
	ReportCompose         *spec.CubeComposeSettings
	ReportMCPTool         *bool
	ReportLinkedInputType string
	ReportDimensions      string
	ReportMeasures        string
	ReportFilters         string
	ReportOrderBy         string
	ReportLimit           string
	ReportOffset          string
	MCP                   []*spec.MCPExposure
	Settings              Settings
}

Component is the metadata carried by a component holder field.

func ParseComponent

func ParseComponent(structTag reflect.StructTag) (Component, bool, error)

func ParseComponentValue

func ParseComponentValue(value string) (Component, error)

func (Component) StructTag

func (c Component) StructTag() (string, error)

func (Component) ValidateRoute

func (c Component) ValidateRoute() error

type Field

type Field struct {
	Component     *Component
	View          *View
	Self          *SelfReference
	Codec         *Codec
	SQL           *SQL
	Binding       *bindly.BindingSpec
	Relation      []*RelationLink
	Predicates    []*spec.Predicate
	QuerySelector *QuerySelector
	Source        string
	SelectorAlias string
	Description   string
	Example       string
	Groupable     bool
	MCP           *bool
	PathMCP       *bool
	Invariant     string
}

Field is the parsed Datly metadata for one Go field. Generic binding and SQLX metadata remain represented by their owning packages.

func ParseField

func ParseField(field reflect.StructField) (*Field, error)

type QuerySelector

type QuerySelector struct {
	View string
}

QuerySelector identifies the view property bound to one selector input field.

func ParseQuerySelector

func ParseQuerySelector(value string) (*QuerySelector, error)

ParseQuerySelector accepts querySelector:"users" and querySelector:"view=users".

func (QuerySelector) Value

func (q QuerySelector) Value() (string, error)

Value formats query-selector metadata using ParseQuerySelector's grammar.

type RelationLink struct {
	Parent RelationPart
	Child  RelationPart
}

RelationLink is one typed parent-to-child equality from an on tag.

func ParseRelation

func ParseRelation(value string) ([]*RelationLink, error)

ParseRelation parses the complete comma-separated on-tag relation contract.

type RelationPart

type RelationPart struct {
	Field     string
	Namespace string
	Column    string
	Include   *bool
}

RelationPart identifies an optional Go field, SQL namespace, and required SQL column.

type SQL

type SQL struct {
	Text string
	URI  string
}

func ParseSQL

func ParseSQL(value string) *SQL

func (SQL) Value

func (s SQL) Value() string

Value formats SQL metadata using ParseSQL's grammar.

type SelfReference

type SelfReference struct {
	Child  string
	Parent string
}

func ParseSelf

func ParseSelf(value string) (*SelfReference, error)

func (SelfReference) Value

func (s SelfReference) Value() (string, error)

Value formats self-reference metadata using ParseSelf's grammar.

type Settings

type Settings struct {
	Mutation                   string
	SequenceStrategy           string
	MCPFolders                 []spec.ResourceFolder
	IgnoreEmptyQueryParameters *bool
	CaseFormat                 string
	Cache                      *spec.CacheSettings
	JSONMarshalType            string
	JSONUnmarshalType          string
	XMLUnmarshalType           string
	Format                     string
	DateFormat                 string
	Output                     *spec.OutputSettings
}

Settings contains component settings that remain meaningful after package generation. spec.Settings.Generation, type names, documentation sources, and constants are deliberately excluded because transcription consumes or materializes them before package bootstrap.

func ParseSettings

func ParseSettings(structTag reflect.StructTag) (Settings, error)

func SettingsFromSpec

func SettingsFromSpec(source *spec.Settings) Settings

func (Settings) Apply

func (s Settings) Apply(target *spec.Settings)

func (Settings) StructTag

func (s Settings) StructTag() (string, error)

type View

type View struct {
	Name                  string
	TypeName              string
	Dest                  string
	EntityHooks           string
	URI                   string
	Connector             string
	Table                 string
	Cache                 string
	CacheWarmup           string
	OrderBy               string
	Limit                 *int
	Offset                *int
	Batch                 int
	BatchConcurrency      int
	Match                 string
	PublishParent         bool
	RelationalConcurrency int
	AllowNulls            *bool
	Groupable             *bool
	Auxiliary             bool
	Partitioning          *spec.Partitioning
	Selector              *spec.Selector
}

func ParseView

func ParseView(value string) (*View, error)

func (View) Value

func (v View) Value() (string, error)

Value formats view metadata using the same grammar accepted by ParseView.

Jump to

Keyboard shortcuts

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