Documentation ¶
Overview ¶
Package schema contains the types and functions for generating the schema from the spec and definition files.
Index ¶
- func DefinitionsYAML() string
- func VSSToGoName(name string) string
- func VSSToJSONName(name string) string
- func Validate(d *DefinitionInfo) error
- func VssRel42DIMO() string
- type ConversionInfo
- type DefinitionInfo
- type Definitions
- type InvalidError
- type OriginalNameInfo
- type SignalInfo
- type TemplateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefinitionsYAML ¶
func DefinitionsYAML() string
DefinitionsYAML is the embedded YAML file containing the definitions.yaml for the VSS schema.
func VSSToGoName ¶ added in v0.2.11
VSSToGoName returns the golang formated name of a VSS signal. This is done by removing the root Prefix and nonAlphaNumeric characters from the name and capitalizes the first letter.
func VSSToJSONName ¶ added in v0.2.11
VSSToJSONName returns the JSON formated name of a VSS signal. This is done by removing the root Prefix and nonAlphaNumeric characters from the name and lowercases the first word.
func Validate ¶ added in v0.2.1
func Validate(d *DefinitionInfo) error
Validate checks if the definition is valid.
func VssRel42DIMO ¶
func VssRel42DIMO() string
VssRel42DIMO is the embedded CSV file containing the VSS schema for DIMO.
Types ¶
type ConversionInfo ¶
type ConversionInfo struct { OriginalName string `json:"originalName" yaml:"originalName"` OriginalType string `json:"originalType" yaml:"originalType"` IsArray bool `json:"isArray" yaml:"isArray"` }
ConversionInfo contains the conversion information for a field.
type DefinitionInfo ¶
type DefinitionInfo struct { VspecName string `json:"vspecName" yaml:"vspecName"` Conversions []*ConversionInfo `json:"conversions" yaml:"conversions"` RequiredPrivileges []string `json:"requiredPrivileges" yaml:"requiredPrivileges"` }
DefinitionInfo contains the definition information for a field.
type Definitions ¶
type Definitions struct { // FromName contains a mapping from VSS name to definition info. FromName map[string]*DefinitionInfo }
Definitions is a map of definitions from clickhouse Name to definition info.
func LoadDefinitionFile ¶
func LoadDefinitionFile(r io.Reader) (*Definitions, error)
LoadDefinitionFile loads the definitions from a definitions.yaml file.
func (*Definitions) DefinedSignal ¶
func (m *Definitions) DefinedSignal(signal []*SignalInfo) []*SignalInfo
DefinedSignal returns a new slice of signals with the definition information applied. excluding signals that are not in the definition file.
type InvalidError ¶ added in v0.2.15
InvalidError is an error for invalid definitions.
func (InvalidError) Error ¶ added in v0.2.15
func (e InvalidError) Error() string
type OriginalNameInfo ¶ added in v0.3.0
type OriginalNameInfo struct { Name string Signals []*SignalInfo }
OriginalNameInfo contains the original name and signals that are derived from it.
type SignalInfo ¶
type SignalInfo struct { // From spec CSV Name string Type string DataType string Unit string Min string Max string Desc string Deprecated bool // Derived IsArray bool GOName string JSONName string BaseGoType string BaseGQLType string Conversions []*ConversionInfo Privileges []string }
SignalInfo holds information about a signal that is accessed during template execution. This information comes from the combinations of the spec and definition files. The Types defined by this stuct are used to determine what strings to use in the template file.
func LoadSignalsCSV ¶
func LoadSignalsCSV(r io.Reader) ([]*SignalInfo, error)
LoadSignalsCSV loads the signals from a vss CSV file.
func NewSignalInfo ¶
func NewSignalInfo(record []string) *SignalInfo
NewSignalInfo creates a new SignalInfo from a record from the CSV file.
func (*SignalInfo) GOType ¶
func (s *SignalInfo) GOType() string
GOType returns the golang type of the signal.
func (*SignalInfo) GQLType ¶ added in v0.2.1
func (s *SignalInfo) GQLType() string
GQLType returns the graphql type of the signal.
func (*SignalInfo) MergeWithDefinition ¶
func (s *SignalInfo) MergeWithDefinition(definition *DefinitionInfo)
MergeWithDefinition merges the signal with the definition information.
type TemplateData ¶
type TemplateData struct { ModelName string Signals []*SignalInfo OriginalNames []*OriginalNameInfo }
TemplateData contains the data to be used during template execution.
func GetDefinedSignals ¶
func GetDefinedSignals(specReader, definitionReader io.Reader) (*TemplateData, error)
GetDefinedSignals reads the signals and definitions files and merges them.