translator

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 72 Imported by: 0

README

Grammar

Repository resources

  • connections
  • constants
  • caches
  • messageBuses

Parameter auto-detection

Struct types

Relations

Codecs

Hints

Documentation

Overview

Package translator implements dql to datly rule translator

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractConnectorRef

func ExtractConnectorRef(SQL *string) string

func MatchByName

func MatchByName(types []*xreflect.Type, name string) *xreflect.Type

func SafeQueryStringify

func SafeQueryStringify(aQuery *query.Select) (SQL string, err error)

Types

type Config

type Config struct {
	*standalone.Config
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(repository *options.Repository) *Config

func (*Config) BaseURL

func (c *Config) BaseURL() string

func (*Config) Init

func (c *Config) Init(ctx context.Context) error

func (*Config) NormalizeURL

func (c *Config) NormalizeURL(repositoryURL string)

type OutputSettings

type OutputSettings struct {
	Kind        string
	Cardinality state.Cardinality
	DataType    string
	Title       string
}

func (*OutputSettings) IsToOne

func (o *OutputSettings) IsToOne() bool

func (*OutputSettings) ViewCardinality

func (o *OutputSettings) ViewCardinality() state.Cardinality

type Repository

type Repository struct {
	Config          *Config
	Resource        []*Resource
	State           inference.State
	Connectors      []*view.Connector
	NamedConnectors view.Connectors
	Caches          view.Caches
	MessageBuses    []*mbus.Resource
	Messages        msg.Messages
	Files           asset.Files
	Substitutes     Substitutes
	PersistAssets   bool
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(config *Config) *Repository

func (*Repository) ContentBaseURL

func (r *Repository) ContentBaseURL(rule *options.Rule) string

func (*Repository) Init

func (r *Repository) Init(ctx context.Context) error

Init Initialises translator repository

func (*Repository) LookupDb

func (r *Repository) LookupDb(name string) (*sql.DB, error)

func (*Repository) PersistConfig

func (r *Repository) PersistConfig() error

func (*Repository) RuleBaseURL

func (r *Repository) RuleBaseURL(rule *options.Rule) string

func (*Repository) RuleName

func (r *Repository) RuleName(rule *options.Rule) string

func (*Repository) Upload

func (r *Repository) Upload(ctx context.Context) error

func (*Repository) UploadPartialRules

func (r *Repository) UploadPartialRules(ctx context.Context) error

UploadPartialRules uploads rule into dest, this is temporary to see signature for component parameters

type Resource

type Resource struct {
	Generated bool

	Resource view.Resource

	State       inference.State
	OutputState inference.State
	AsyncState  inference.State
	Rule        *Rule
	tparser.Statements
	RawSQL string

	UseCustomTypes bool
	Declarations   *tparser.Declarations
	CustomTypeURLs []string

	Module         *modfile.Module
	ModuleLocation string
	// contains filtered or unexported fields
}

func NewResource

func NewResource(rule *options.Rule, repository *options.Repository, messages *msg.Messages) *Resource

func (*Resource) AddCustomTypeURL

func (r *Resource) AddCustomTypeURL(URL string)

func (*Resource) AdjustCustomType

func (r *Resource) AdjustCustomType()

func (*Resource) AppendTypeDefinition

func (r *Resource) AppendTypeDefinition(typeDef *view.TypeDefinition)

func (*Resource) AppendTypeDefinitions

func (r *Resource) AppendTypeDefinitions(typeDefs []*view.TypeDefinition)

func (*Resource) DataFieldName added in v0.10.0

func (r *Resource) DataFieldName(inInput bool) string

func (*Resource) ExtractDeclared

func (r *Resource) ExtractDeclared(dSQL *string) (err error)

ExtractDeclared extract both parameter declaration and transform expression

func (*Resource) GetSchema

func (r *Resource) GetSchema(dataType string, opts ...xreflect.Option) (*state.Schema, error)

func (*Resource) GetURI

func (r *Resource) GetURI() string

func (*Resource) ImpliedKind

func (r *Resource) ImpliedKind() state.Kind

func (*Resource) IncludeSnippets

func (r *Resource) IncludeSnippets(ctx context.Context, fs afs.Service, dSQL *string) error

func (*Resource) IncludeURL

func (r *Resource) IncludeURL(ctx context.Context, URL string, fs afs.Service) (string, error)

func (*Resource) InitRule

func (r *Resource) InitRule(dSQL *string, ctx context.Context, fs afs.Service, opts *options.Options) error

func (Resource) Lookup

func (n Resource) Lookup(viewName string) *indexNamespace

func (Resource) LookupNs

func (n Resource) LookupNs(namespace string) *indexNamespace

func (*Resource) LookupTypeDef

func (r *Resource) LookupTypeDef(typeName string) *view.TypeDefinition

LookupTypeDef returns matched type definition

func (*Resource) TypePackage

func (r *Resource) TypePackage(name string) string

type RouterConfig

type RouterConfig struct {
	RouterURL string `json:",omitempty" yaml:",omitempty"`
	URL       string `json:",omitempty" yaml:",omitempty"`
	Routes    []struct {
		SourceURL string
	}
}

type Rule

type Rule struct {
	Viewlets

	CustomValidation           bool
	IgnoreEmptyQueryParameters bool

	Root string
	//TODO replace with repository.Component and path.Settings ?
	router.Route

	*contract.Output
	Async    *async.Config          `json:",omitempty"`
	Cache    *view.Cache            `json:",omitempty"`
	CSV      *content.CSVConfig     `json:",omitempty"`
	Const    map[string]interface{} `json:",omitempty"`
	ConstURL string                 `json:",omitempty"`
	DocURL   string
	DocURLs  []string
	Doc      state.Docs

	TypeSrc           *parser.TypeImport         `json:",omitempty"`
	Package           string                     `json:",omitempty"`
	Router            *RouterConfig              `json:",omitempty" yaml:",omitempty"`
	DataFormat        string                     `json:",omitempty"`
	TabularJSON       *content.TabularJSONConfig `json:",omitempty"`
	XML               *content.XMLConfig         `json:",omitempty"`
	Type              string                     `json:",omitempty"`
	HandlerArgs       []string                   `json:",omitempty"`
	InputType         string                     `json:",omitempty"`
	OutputType        string                     `json:",omitempty"`
	MessageBus        string                     `json:",omitempty"`
	CompressAboveSize int                        `json:",omitempty"`
	With              []string                   `json:",omitempty"`
	Include           []string                   `json:",omitempty"`

	IsGeneratation    bool
	XMLUnmarshalType  string `json:",omitempty"`
	JSONUnmarshalType string `json:",omitempty"`

	OutputParameter *inference.Parameter
	// contains filtered or unexported fields
}

func NewRule

func NewRule() *Rule

func (*Rule) DSQLSetting

func (r *Rule) DSQLSetting() interface{}

func (*Rule) ExtractSettings

func (r *Rule) ExtractSettings(dSQL *string) error

func (*Rule) GetField

func (r *Rule) GetField() string

func (*Rule) IsBasic

func (r *Rule) IsBasic() bool

func (*Rule) IsMany

func (r *Rule) IsMany() bool

func (*Rule) IsReader

func (r *Rule) IsReader() bool

func (Rule) LookupNs

func (n Rule) LookupNs(namespace string) *indexNamespace

func (*Rule) RootView

func (r *Rule) RootView() *View

func (*Rule) RootViewlet

func (r *Rule) RootViewlet() *Viewlet

func (*Rule) ShallGenerateHandler

func (r *Rule) ShallGenerateHandler() bool

func (*Rule) StateTypePackage

func (r *Rule) StateTypePackage() string

type Service

type Service struct {
	Repository *Repository //TODO init repo with basic config and dependencies
	Plugins    []*options.Plugin
	// contains filtered or unexported fields
}

func New

func New(config *Config, service afs.Service) *Service

func (*Service) DefaultConnector

func (s *Service) DefaultConnector() string

func (*Service) Init

func (s *Service) Init(ctx context.Context) error

func (*Service) InitSignature

func (s *Service) InitSignature(ctx context.Context, rule *options.Rule) (err error)

func (*Service) Translate

func (s *Service) Translate(ctx context.Context, rule *options.Rule, dSQL string, opts *options.Options) (err error)

type Substitutes

type Substitutes map[string]view.Substitutes

func (Substitutes) Merge

func (s Substitutes) Merge() view.Substitutes

func (Substitutes) Replace

func (s Substitutes) Replace(text string) string

func (Substitutes) ReverseReplace

func (s Substitutes) ReverseReplace(text string) string

type TypeImport

type TypeImport struct {
	URL            string
	Types          []string
	Alias          string
	ForceGoTypeUse bool
}

type View

type View struct {
	Namespace string
	view.View

	ExecKind         string                 `json:",omitempty"`
	FetchRecords     bool                   `json:",omitempty"`
	Connector        string                 `json:",omitempty"`
	Self             *view.SelfReference    `json:",omitempty"`
	Warmup           map[string]interface{} `json:",omitempty"`
	Auth             string                 `json:",omitempty"`
	DataType         string                 `json:",omitempty"`
	AsyncTableName   string                 `json:",omitempty"`
	ParameterDerived bool
	Cardinality      string
	// contains filtered or unexported fields
}

func (*View) GenerateFiles

func (v *View) GenerateFiles(baseURL string, ruleName string, files *asset.Files, substitutes view.Substitutes)

type Viewlet

type Viewlet struct {
	Name   string
	Holder string

	Connector      string
	SQL            string
	SanitizedSQL   string
	Expanded       *sqlx.SQL
	Resource       *Resource
	Table          *inference.Table
	Join           *query.Join
	Spec           *inference.Spec
	OutputJSONHint string
	ViewJSONHint   string
	TableJSONHint  string
	Exclude        []string
	Whitelisted    []string
	ColumnConfig   view.ColumnConfigs

	View           *View
	TypeDefinition *view.TypeDefinition
	OutputSettings

	Columns   view.Columns
	Summary   *Viewlet
	IsSummary bool
	// contains filtered or unexported fields
}

func NewViewlet

func NewViewlet(name, SQL string, join *query.Join, resource *Resource) *Viewlet

func (*Viewlet) GetConnector added in v0.9.7

func (v *Viewlet) GetConnector() string

func (*Viewlet) IsMetaView

func (v *Viewlet) IsMetaView() bool

func (*Viewlet) NormalizeSQL added in v0.10.1

func (v *Viewlet) NormalizeSQL()

func (*Viewlet) UpdateParameterType

func (v *Viewlet) UpdateParameterType(aState *inference.State, name string, expression *parser.ExpressionContext)

type Viewlets

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

func (*Viewlets) Append

func (n *Viewlets) Append(viewlet *Viewlet)

func (*Viewlets) Each

func (n *Viewlets) Each(fn func(viewlet *Viewlet) error) error

func (*Viewlets) Init

func (n *Viewlets) Init(ctx context.Context, aQuery *query.Select, resource *Resource, initFn, setType func(ctx context.Context, n *Viewlet, aDoc state.Documentation) error) error

func (*Viewlets) Lookup

func (n *Viewlets) Lookup(name string) *Viewlet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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