Documentation ¶
Index ¶
- Constants
- func AsCodecOptions(options []interface{}) []codec.Option
- func BuildCodec(aTag *tags.Tag, param *Parameter)
- func BuildHandler(aTag *tags.Tag, param *Parameter)
- func BuildPredicate(aTag *tags.Tag, param *Parameter)
- func BuildSchema(field *reflect.StructField, pTag *tags.Parameter, result *Parameter, ...)
- func IsReservedAsyncState(name string) bool
- func NewField(aTag string, structFieldName string, rType reflect.Type) reflect.StructField
- func PkgPath(fieldName string, pkgPath string) (fieldPath string)
- func RawComponentType(typeName string) string
- func SanitizeTypeName(typeName string) string
- func StructFieldName(sourceCaseFormat text.CaseFormat, columnName string) string
- type Cardinality
- type Codec
- type Docs
- type Documentation
- func (d Documentation) ByName(name string) (string, bool)
- func (d Documentation) ColumnDescription(table, column string) (string, bool)
- func (d Documentation) ColumnExample(table, column string) (string, bool)
- func (d Documentation) FieldDocumentation(name string) (Documentation, bool)
- func (d Documentation) Merge(output Documentation)
- type Embedder
- type FSEmbedder
- type Finalizer
- type Handler
- type Initializer
- type Kind
- type Location
- func NewBodyLocation(name string) *Location
- func NewComponent(name string) *Location
- func NewConstLocation(name string) *Location
- func NewContextLocation(name string) *Location
- func NewFormLocation(name string) *Location
- func NewGenerator(name string) *Location
- func NewHeaderLocation(name string) *Location
- func NewObjectLocation(name string) *Location
- func NewOutputLocation(name string) *Location
- func NewParameterLocation(name string) *Location
- func NewPathLocation(name string) *Location
- func NewQueryLocation(name string) *Location
- func NewRequestLocation() *Location
- func NewState(name string) *Location
- func NewViewLocation(name string) *Location
- type NamedParameters
- type Option
- func WithBodyType(bodyType bool) Option
- func WithDoc(doc Documentation) Option
- func WithFS(fs *embed.FS) Option
- func WithMarker(marker bool) Option
- func WithPackage(pkg string) Option
- func WithParameters(parameters Parameters) Option
- func WithResource(resource Resource) Option
- func WithSchema(schema *Schema) Option
- type ParamName
- type Parameter
- func (p *Parameter) Clone() *Parameter
- func (p *Parameter) CombineTags() reflect.StructTag
- func (p *Parameter) GetValue(state *structology.State) (interface{}, error)
- func (p *Parameter) Init(ctx context.Context, resource Resource) error
- func (p *Parameter) IsAnonymous() bool
- func (p *Parameter) IsAsync() bool
- func (p *Parameter) IsCacheable() bool
- func (p *Parameter) IsHTTPParameter() bool
- func (p *Parameter) IsRequired() bool
- func (p *Parameter) IsUsedBy(text string) bool
- func (p *Parameter) NewState(value interface{}) *structology.State
- func (p *Parameter) OutputSchema() *Schema
- func (p *Parameter) OutputType() reflect.Type
- func (p *Parameter) Selector() *structology.Selector
- func (p *Parameter) Set(state *structology.State, value interface{}) error
- func (p *Parameter) SetSelector(selector *structology.Selector)
- func (p *Parameter) SetTypeNameTag()
- func (p *Parameter) Validate() error
- type ParameterOption
- type Parameters
- func (p *Parameters) Append(parameter *Parameter)
- func (p Parameters) BuildBodyType(pkgPath string, lookupType xreflect.LookupType) (reflect.Type, error)
- func (p Parameters) ByKindName() NamedParameters
- func (p Parameters) External() Parameters
- func (p Parameters) Filter(kind Kind) NamedParameters
- func (p Parameters) FilterByKind(kind Kind) Parameters
- func (p Parameters) FlagOutput()
- func (p Parameters) Groups() []Parameters
- func (p Parameters) HasErrorParameter() bool
- func (p Parameters) HttpParameters() Parameters
- func (p Parameters) Index() NamedParameters
- func (p Parameters) InitRepeated(state *structology.State) (err error)
- func (p Parameters) LocationInput() Parameters
- func (p Parameters) Lookup(name string) *Parameter
- func (p Parameters) LookupByLocation(kind Kind, location string) *Parameter
- func (p Parameters) PredicateStructType() reflect.Type
- func (p Parameters) ReflectType(pkgPath string, lookupType xreflect.LookupType, opts ...ReflectOption) (reflect.Type, error)
- func (p Parameters) SetLiterals(state *structology.State) (err error)
- func (p Parameters) UsedBy(text string) Parameters
- type ReflectOption
- type Resource
- type Schema
- func (s *Schema) AutoGen() bool
- func (s *Schema) Clone() *Schema
- func (s *Schema) CompType() reflect.Type
- func (s *Schema) EnsurePointer()
- func (s *Schema) GetPackage() string
- func (s *Schema) InheritType(rType reflect.Type)
- func (s *Schema) Init(resource Resource) error
- func (s *Schema) InitType(lookupType xreflect.LookupType, ptr bool) error
- func (s *Schema) IsNamed() bool
- func (s *Schema) IsStruct() bool
- func (s *Schema) LoadTypeIfNeeded(lookupType xreflect.LookupType) error
- func (s *Schema) SetPackage(pkg string)
- func (s *Schema) SetType(rType reflect.Type)
- func (s *Schema) SimpleTypeName() string
- func (s *Schema) Slice() *xunsafe.Slice
- func (s *Schema) SliceType() reflect.Type
- func (s *Schema) Type() reflect.Type
- func (s *Schema) TypeName() string
- type SchemaOption
- func WithAutoGenFlag(flag bool) SchemaOption
- func WithAutoGenFunc(fn func() (reflect.Type, error)) SchemaOption
- func WithMany() SchemaOption
- func WithModulePath(aPath string) SchemaOption
- func WithPackagePath(pkgPath string) SchemaOption
- func WithSchemaMethods(methods []reflect.Method) SchemaOption
- func WithSchemaPackage(pkg string) SchemaOption
- type Type
- type Types
Constants ¶
const ( SetMarkerTag = `setMarker:"true" format:"-" sqlx:"-" diff:"-" json:"-" ` TypedSetMarkerTag = SetMarkerTag + ` typeName:"%s"` )
Variables ¶
This section is empty.
Functions ¶
func AsCodecOptions ¶
AsCodecOptions creates codec options
func BuildCodec ¶
func BuildHandler ¶
func BuildPredicate ¶
func BuildSchema ¶
func BuildSchema(field *reflect.StructField, pTag *tags.Parameter, result *Parameter, lookupType xreflect.LookupType)
func IsReservedAsyncState ¶
IsReservedAsyncState returns true if reserved async state
func RawComponentType ¶
func SanitizeTypeName ¶
func StructFieldName ¶
func StructFieldName(sourceCaseFormat text.CaseFormat, columnName string) string
Types ¶
type Cardinality ¶
type Cardinality string
const ( One Cardinality = "One" Many Cardinality = "Many" )
type Codec ¶
type Codec struct { shared.Reference Name string `json:",omitempty" yaml:"Name,omitempty" ` Body string `json:",omitempty" yaml:"Body,omitempty"` Args []string `json:",omitempty" yaml:"Args,omitempty"` Schema *Schema `json:",omitempty" yaml:"Schema,omitempty"` OutputType string `json:",omitempty" yaml:"OutputType,omitempty"` // contains filtered or unexported fields }
func (*Codec) Initialized ¶
type Docs ¶
type Docs struct { Filter Documentation Columns Documentation Parameters Documentation Paths Documentation }
type Documentation ¶
type Documentation map[string]interface{}
func (Documentation) ColumnDescription ¶ added in v0.10.0
func (d Documentation) ColumnDescription(table, column string) (string, bool)
func (Documentation) ColumnExample ¶ added in v0.10.0
func (d Documentation) ColumnExample(table, column string) (string, bool)
func (Documentation) FieldDocumentation ¶
func (d Documentation) FieldDocumentation(name string) (Documentation, bool)
func (Documentation) Merge ¶ added in v0.10.0
func (d Documentation) Merge(output Documentation)
type FSEmbedder ¶ added in v0.9.14
type FSEmbedder struct {
// contains filtered or unexported fields
}
FSEmbedder represents fs embedder
func NewFSEmbedder ¶ added in v0.9.14
func NewFSEmbedder(fs *embed.FS) *FSEmbedder
func (*FSEmbedder) EmbedFS ¶ added in v0.9.14
func (f *FSEmbedder) EmbedFS() *embed.FS
EmbedFS returns embed fs
type Finalizer ¶
Finalizer is an interface that should be implemented by any type that needs to be finalized
type Handler ¶
type Handler struct { Name string `tag:"name,omitempty"` Args []string `tag:"arguments,omitempty"` }
Handler represents a handler
type Initializer ¶
Initializer is an interface that should be implemented by any type that needs to be initialized
type Kind ¶
type Kind string
Kind represents parameter location Parameter value can be retrieved from the i.e. HTTP Header, path Variable or using other View
const ( KindView Kind = "view" KindHeader Kind = "header" KindQuery Kind = "query" KindForm Kind = "form" KindPath Kind = "path" KindCookie Kind = "cookie" KindRequestBody Kind = "body" KindEnvironment Kind = "env" KindConst Kind = "const" KindLiteral Kind = "literal" KindParam Kind = "param" KindRequest Kind = "http_request" KindObject Kind = "object" KindRepeated Kind = "repeated" KindOutput Kind = "output" //reader output KindAsync Kind = "async" //async jobs/status related information KindMeta Kind = "meta" //component/view meta information KindState Kind = "state" //input state KindComponent Kind = "component" //input state KindContext Kind = "context" //global context based state //KindGenerator represents common value generator KindGenerator Kind = "generator" //KindTransient represents parameter placeholder with no actual value source KindTransient Kind = "transient" //KindHandler represents handler type KindHandler Kind = "handler" )
type Location ¶
type Location struct { Kind Kind `json:",omitempty" yaml:"Kind"` Name string `json:",omitempty" yaml:"Name"` }
Location represents parameter location
func NewBodyLocation ¶
NewBodyLocation creates a body location
func NewComponent ¶
NewComponent creates a component location
func NewConstLocation ¶
func NewContextLocation ¶
NewContextLocation creates a context location
func NewFormLocation ¶
NewFormLocation creates a query location
func NewHeaderLocation ¶
NewHeaderLocation creates a query location
func NewObjectLocation ¶
NewObjectLocation creates an output location
func NewOutputLocation ¶
NewOutputLocation creates an output location
func NewParameterLocation ¶
NewParameterLocation creates a parameter location
func NewPathLocation ¶
NewPathLocation creates a path location
func NewQueryLocation ¶
NewQueryLocation creates a query location
func NewRequestLocation ¶
func NewRequestLocation() *Location
NewRequestLocation creates a body location
func NewViewLocation ¶
NewViewLocation creates a dataview location
type NamedParameters ¶
NamedParameters represents Parameter map indexed by Parameter.Name
func (NamedParameters) Lookup ¶
func (p NamedParameters) Lookup(name string) (*Parameter, error)
Lookup returns Parameter with given name
func (NamedParameters) LookupByLocation ¶
func (s NamedParameters) LookupByLocation(kind Kind, location string) *Parameter
func (NamedParameters) Merge ¶
func (p NamedParameters) Merge(with NamedParameters)
func (NamedParameters) Register ¶
func (p NamedParameters) Register(parameter *Parameter) error
Register registers parameter
type Option ¶
type Option func(t *Type)
func WithBodyType ¶
func WithDoc ¶
func WithDoc(doc Documentation) Option
func WithMarker ¶
func WithPackage ¶
func WithParameters ¶
func WithParameters(parameters Parameters) Option
func WithResource ¶
func WithSchema ¶
type ParamName ¶
type ParamName string
ParamName represents name of parameter in given Location.Kind i.e. if you want to extract lang from query string: ?foo=bar&lang=eng required Kind is KindQuery and ParamName `lang`
type Parameter ¶
type Parameter struct { shared.Reference Object Parameters `json:",omitempty" yaml:"Object"` Repeated Parameters `json:",omitempty" yaml:"Repeated"` //LocationInput, component input LocationInput *Type `json:",omitempty" yaml:"Input"` Predicates []*extension.PredicateConfig `json:",omitempty" yaml:"Predicates"` Name string `json:",omitempty" yaml:"Name"` SQL string `json:",omitempty" yaml:"SQL"` In *Location `json:",omitempty" yaml:"In" ` Scope string `json:",omitempty" yaml:"Scope" ` Required *bool `json:",omitempty" yaml:"Required" ` Description string `json:",omitempty" yaml:"Description"` Example string `json:",omitempty" yaml:"Example"` Style string `json:",omitempty" yaml:"Style"` MaxAllowedRecords *int `json:",omitempty"` MinAllowedRecords *int `json:",omitempty"` ExpectedReturned *int `json:",omitempty"` Schema *Schema `json:",omitempty" yaml:"Schema"` Output *Codec `json:",omitempty" yaml:"Output"` Handler *Handler `json:",omitempty" yaml:"Handler"` Value interface{} `json:"Value,omitempty" yaml:"Value"` //deprecated use format timelayout instead DateFormat string `json:",omitempty" yaml:"DateFormat"` ErrorStatusCode int `json:",omitempty" yaml:"ErrorStatusCode"` ErrorMessage string `json:",omitempty" yaml:"ErrorMessage"` Tag string `json:",omitempty" yaml:"Tag"` When string `json:",omitempty" yaml:"When"` With string `json:",omitempty" yaml:"With"` Cacheable *bool `json:",omitempty" yaml:"Cacheable"` Async bool `json:",omitempty" yaml:"Async"` // contains filtered or unexported fields }
func BuildParameter ¶
func BuildParameter(field *reflect.StructField, fs *embed.FS, lookupType xreflect.LookupType) (*Parameter, error)
func NewParameter ¶
func NewParameter(name string, in *Location, opts ...ParameterOption) *Parameter
NewParameter creates a parameter
func NewRefParameter ¶
NewRefParameter creates a new ref parameter
func (*Parameter) CombineTags ¶
func (*Parameter) GetValue ¶
func (p *Parameter) GetValue(state *structology.State) (interface{}, error)
func (*Parameter) IsAnonymous ¶ added in v0.9.6
func (*Parameter) IsCacheable ¶
func (*Parameter) IsHTTPParameter ¶ added in v0.10.0
func (*Parameter) IsRequired ¶
func (*Parameter) NewState ¶
func (p *Parameter) NewState(value interface{}) *structology.State
func (*Parameter) OutputSchema ¶
func (*Parameter) OutputType ¶
func (*Parameter) Selector ¶
func (p *Parameter) Selector() *structology.Selector
func (*Parameter) SetSelector ¶
func (p *Parameter) SetSelector(selector *structology.Selector)
func (*Parameter) SetTypeNameTag ¶
func (p *Parameter) SetTypeNameTag()
type ParameterOption ¶
type ParameterOption func(p *Parameter)
func WithCacheable ¶ added in v0.9.7
func WithCacheable(flag bool) ParameterOption
func WithParameterSchema ¶
func WithParameterSchema(schema *Schema) ParameterOption
func WithParameterTag ¶
func WithParameterTag(tag string) ParameterOption
func WithParameterType ¶
func WithParameterType(t reflect.Type) ParameterOption
WithParameterType returns schema type parameter option
type Parameters ¶
type Parameters []*Parameter
Parameters represents slice of parameters
func (*Parameters) Append ¶
func (p *Parameters) Append(parameter *Parameter)
Append appends parameter
func (Parameters) BuildBodyType ¶
func (p Parameters) BuildBodyType(pkgPath string, lookupType xreflect.LookupType) (reflect.Type, error)
func (Parameters) ByKindName ¶ added in v0.9.7
func (p Parameters) ByKindName() NamedParameters
ByKindName indexes parameters by Parameter.In.Name
func (Parameters) External ¶
func (p Parameters) External() Parameters
func (Parameters) Filter ¶
func (p Parameters) Filter(kind Kind) NamedParameters
Filter filters Parameters with given Kind and creates Template
func (Parameters) FilterByKind ¶
func (p Parameters) FilterByKind(kind Kind) Parameters
func (Parameters) FlagOutput ¶
func (p Parameters) FlagOutput()
func (Parameters) Groups ¶
func (p Parameters) Groups() []Parameters
func (Parameters) HasErrorParameter ¶ added in v0.9.2
func (p Parameters) HasErrorParameter() bool
func (Parameters) HttpParameters ¶ added in v0.10.0
func (p Parameters) HttpParameters() Parameters
func (Parameters) Index ¶
func (p Parameters) Index() NamedParameters
Index indexes parameters by Parameter.Name
func (Parameters) InitRepeated ¶
func (p Parameters) InitRepeated(state *structology.State) (err error)
func (Parameters) LocationInput ¶
func (p Parameters) LocationInput() Parameters
LocationInput returns location input
func (Parameters) Lookup ¶
func (p Parameters) Lookup(name string) *Parameter
Lookup returns match parameter or nil
func (Parameters) LookupByLocation ¶
func (p Parameters) LookupByLocation(kind Kind, location string) *Parameter
LookupByLocation returns match parameter by location
func (Parameters) PredicateStructType ¶
func (p Parameters) PredicateStructType() reflect.Type
func (Parameters) ReflectType ¶
func (p Parameters) ReflectType(pkgPath string, lookupType xreflect.LookupType, opts ...ReflectOption) (reflect.Type, error)
func (Parameters) SetLiterals ¶
func (p Parameters) SetLiterals(state *structology.State) (err error)
func (Parameters) UsedBy ¶
func (p Parameters) UsedBy(text string) Parameters
type ReflectOption ¶
type ReflectOption func(o *reflectOptions)
func WithLocationInput ¶
func WithLocationInput(parameters Parameters) ReflectOption
func WithRelation ¶
func WithRelation() ReflectOption
func WithSQL ¶
func WithSQL() ReflectOption
func WithSetMarker ¶
func WithSetMarker() ReflectOption
func WithTypeName ¶
func WithTypeName(name string) ReflectOption
func WithVelty ¶
func WithVelty(flag bool) ReflectOption
type Resource ¶
type Resource interface { LookupParameter(name string) (*Parameter, error) AppendParameter(parameter *Parameter) ViewSchema(ctx context.Context, name string) (*Schema, error) ViewSchemaPointer(ctx context.Context, name string) (*Schema, error) LookupType() xreflect.LookupType LoadText(ctx context.Context, URL string) (string, error) Codecs() *codec.Registry //CodecOptions returns base codec options CodecOptions() *codec.Options ExpandSubstitutes(text string) string ReverseSubstitutes(text string) string }
type Schema ¶
type Schema struct { Package string `json:",omitempty" yaml:"Package,omitempty"` PackagePath string `json:",omitempty" yaml:"PackagePath,omitempty"` ModulePath string `json:",omitempty" yaml:"ModulePath,omitempty"` Name string `json:",omitempty" yaml:"Name,omitempty"` DataType string `json:",omitempty" yaml:"DataType,omitempty"` Cardinality Cardinality `json:",omitempty" yaml:"Cardinality,omitempty"` Methods []reflect.Method // contains filtered or unexported fields }
Schema represents View as Go type.
func (*Schema) AutoGen ¶
AutoGen indicates whether Schema was generated using ColumnTypes fetched from DB or was passed programmatically.
func (*Schema) EnsurePointer ¶
func (s *Schema) EnsurePointer()
func (*Schema) GetPackage ¶ added in v0.9.8
func (*Schema) InheritType ¶
func (*Schema) LoadTypeIfNeeded ¶
func (s *Schema) LoadTypeIfNeeded(lookupType xreflect.LookupType) error
func (*Schema) SetPackage ¶
func (*Schema) SimpleTypeName ¶
type SchemaOption ¶
type SchemaOption func(s *Schema)
Schema represents View as Go type.
func WithAutoGenFlag ¶
func WithAutoGenFlag(flag bool) SchemaOption
WithAutoGenFlag creates with autogen schema option
func WithAutoGenFunc ¶
func WithAutoGenFunc(fn func() (reflect.Type, error)) SchemaOption
WithAutoGenFunc return autoget
func WithMany ¶
func WithMany() SchemaOption
func WithModulePath ¶
func WithModulePath(aPath string) SchemaOption
func WithPackagePath ¶ added in v0.9.8
func WithPackagePath(pkgPath string) SchemaOption
WithPackagePath returns package options
func WithSchemaMethods ¶
func WithSchemaMethods(methods []reflect.Method) SchemaOption
func WithSchemaPackage ¶
func WithSchemaPackage(pkg string) SchemaOption
type Type ¶
type Type struct { *Schema Parameters Parameters `json:",omitempty" yaml:"Parameters"` Doc Documentation // contains filtered or unexported fields }
Type represents parameters/schema derived state type
func (*Type) AnonymousParameters ¶
func (*Type) IsAnonymous ¶
IsAnonymous returns flag for basic unwrapped style