spec

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package spec defines the specification types for the object api. Any change to the API has direct impact on the user.

Index

Constants

This section is empty.

Variables

View Source
var ApigearModuleSchema []byte
View Source
var ApigearRulesSchema []byte
View Source
var ApigearScenarioSchema []byte
View Source
var ApigearSolutionSchema []byte

Functions

func DocumentTypeFromFileName

func DocumentTypeFromFileName(fn string) (string, error)

func FeatureRulesToStringMap added in v0.20.0

func FeatureRulesToStringMap(features []*FeatureRule) map[string]bool

func FeatureRulesToStrings added in v0.20.0

func FeatureRulesToStrings(features []*FeatureRule) []string

func JsonToYaml

func JsonToYaml(data []byte) ([]byte, error)

func LoadSchema

func LoadSchema(t DocumentType) (gojsonschema.JSONLoader, error)

func YamlToJson

func YamlToJson(data []byte) ([]byte, error)

Types

type ActionEntry added in v0.6.1

type ActionEntry map[string]map[string]any

ActionEntry represents an action in an operation or sequence.

type ActionListEntry added in v0.6.1

type ActionListEntry struct {
	// Name is the name of the action list.
	Name string `json:"name" yaml:"name"`
	// Description is the description of the action list.
	Description string `json:"description" yaml:"description"`
	// Actions is the list of actions in the action list.
	Actions []ActionEntry `json:"actions" yaml:"actions"`
}

ActionListEntry represents a list of actions

type DocumentRule

type DocumentRule struct {
	// Source is the source document to apply the transformation to.
	Source string `json:"source" yaml:"source"`
	// Target is the target document to write to after the transformation.
	Target string `json:"target" yaml:"target"`
	// Transform is true if the transformation should be applied.
	Raw bool `json:"raw" yaml:"raw"`
	// Force is true if the target file should be overwritten.
	Force bool `json:"force" yaml:"force"`
	// Preserve is true if the target file should be preserved.
	Preserve bool `json:"preserve" yaml:"preserve"`
}

DocumentRule defines a document rule with a source and target document.

func (*DocumentRule) Validate added in v0.33.0

func (r *DocumentRule) Validate() error

type DocumentType

type DocumentType string
const (
	DocumentTypeModule   DocumentType = "module"
	DocumentTypeSolution DocumentType = "solution"
	DocumentTypeScenario DocumentType = "scenario"
	DocumentTypeRules    DocumentType = "rules"
	DocumentTypeUnknown  DocumentType = "unknown"
)

func GetDocumentType

func GetDocumentType(file string) (DocumentType, error)

type Engines added in v0.35.0

type Engines struct {
	// Cli is the version constraint for the cli engine.
	Cli string `json:"cli" yaml:"cli"`
}

Engines defines version constraints for the engines.

type ErrorResult added in v0.30.0

type ErrorResult struct {
	Field       string `json:"field"`
	Description string `json:"description"`
	Related     string `json:"related"`
}

func (ErrorResult) String added in v0.30.0

func (e ErrorResult) String() string

type FeatureRule

type FeatureRule struct {
	// Name of the feature.
	Name string `json:"name" yaml:"name"`
	// Which other features are required by this feature.
	Requires []string `json:"requires" yaml:"requires"`
	// Scopes to match.
	Scopes []*ScopeRule `json:"scopes" yaml:"scopes"`
	Skip   bool         `json:"-" yaml:"-"`
}

A feature rule defines a set of scopes to match a symbol type.

func (*FeatureRule) FindScopesByMatch added in v0.9.0

func (s *FeatureRule) FindScopesByMatch(match ScopeType) []*ScopeRule

FindScopeByMatch returns the first scope that matches the given match.

func (*FeatureRule) Validate added in v0.33.0

func (r *FeatureRule) Validate() error

type InterfaceEntry added in v0.6.1

type InterfaceEntry struct {
	Name        string             `json:"name" yaml:"name"`
	Description string             `json:"description" yaml:"description"`
	Properties  map[string]any     `json:"properties" yaml:"properties"`
	Operations  []*ActionListEntry `json:"operations" yaml:"operations"`
}

InterfaceEntry represents an interface in a scenario.

func (InterfaceEntry) GetOperation added in v0.6.1

func (e InterfaceEntry) GetOperation(name string) *ActionListEntry

GetOperation returns the operation entry with the given name.

func (*InterfaceEntry) Validate added in v0.33.0

func (e *InterfaceEntry) Validate() error

type Result added in v0.30.0

type Result struct {
	File   string        `json:"file"`
	Errors []ErrorResult `json:"errors"`
}

func CheckCsvFile

func CheckCsvFile(name string) (*Result, error)

func CheckFile

func CheckFile(file string) (*Result, error)

func CheckFileAndType added in v0.21.0

func CheckFileAndType(file string, t DocumentType) (*Result, error)

func CheckIdlFile

func CheckIdlFile(name string) (*Result, error)

func CheckJson added in v0.8.0

func CheckJson(t DocumentType, jsonDoc []byte) (*Result, error)

func (*Result) Valid added in v0.30.0

func (r *Result) Valid() bool

type RulesDoc

type RulesDoc struct {
	Name      string         `json:"name" yaml:"name"`
	Engines   Engines        `json:"engines" yaml:"engines"`
	Languages []string       `json:"languages" yaml:"languages"`
	Features  []*FeatureRule `json:"features" yaml:"features"`
}

func (*RulesDoc) CheckEngines added in v0.35.0

func (r *RulesDoc) CheckEngines(version string) (bool, []error)

CheckCliVersion checks if the given engines are compatible with the rules.

func (*RulesDoc) ComputeFeatures added in v0.15.1

func (r *RulesDoc) ComputeFeatures(wanted []string) error

ComputeFeatures returns a filtered set of features based on the given features. And the features that are required by the given features.

func (*RulesDoc) FeatureByName added in v0.15.1

func (r *RulesDoc) FeatureByName(name string) *FeatureRule

FeatureByName returns the feature with the given name.

func (*RulesDoc) FeatureNamesMap added in v0.20.0

func (r *RulesDoc) FeatureNamesMap() map[string]bool

func (*RulesDoc) Validate added in v0.33.0

func (d *RulesDoc) Validate() error

type ScenarioDoc

type ScenarioDoc struct {
	Schema      string            `json:"schema" yaml:"schema"`
	Name        string            `json:"name" yaml:"name"`
	Source      string            `json:"source" yaml:"source"`
	Description string            `json:"description" yaml:"description"`
	Version     string            `json:"version" yaml:"version"`
	Interfaces  []*InterfaceEntry `json:"interfaces" yaml:"interfaces"`
	Sequences   []*SequenceEntry  `json:"sequences" yaml:"sequences"`
}

ScenarioDoc is a scenario document as part of a simulation.

func (*ScenarioDoc) GetInterface added in v0.6.1

func (s *ScenarioDoc) GetInterface(name string) *InterfaceEntry

GetInterface returns the interface entry with the given name.

func (*ScenarioDoc) GetSequence added in v0.6.1

func (s *ScenarioDoc) GetSequence(name string) *SequenceEntry

GetSequence returns the sequence entry with the given name.

func (*ScenarioDoc) Validate added in v0.33.0

func (d *ScenarioDoc) Validate() error

type ScopeRule

type ScopeRule struct {
	// Match is the type of the symbol to match
	Match ScopeType `json:"match" yaml:"match"`
	// Prefix is the prefix for all target documents
	Prefix string `json:"prefix" yaml:"prefix"`
	// Documents is a list of document rules to apply
	Documents []DocumentRule `json:"documents" yaml:"documents"`
}

ScopeRule defines a scope rule which is matched based on the symbol type.

func (*ScopeRule) Validate added in v0.33.0

func (r *ScopeRule) Validate() error

type ScopeType

type ScopeType string

ScopeType is the type of a scope.

const (
	ScopeSystem    ScopeType = "system"
	ScopeModule    ScopeType = "module"
	ScopeInterface ScopeType = "interface"
	ScopeStruct    ScopeType = "struct"
	ScopeEnum      ScopeType = "enum"
)

type SequenceEntry added in v0.6.1

type SequenceEntry struct {
	// Name is the name of the sequence.
	Name string `json:"name" yaml:"name"`
	// Description is the description of the sequence.
	Description string `json:"description" yaml:"description"`
	// Interface is the name of the default interface used.
	Interface string `json:"interface" yaml:"interface"`
	// Interval is the interval in milliseconds between runs.
	Interval int `json:"interval" yaml:"interval"`
	// Loops is the number of times the sequence should be run.
	Loops int `json:"loops" yaml:"loops"`
	// Forever is true if the sequence should be run forever.
	Forever bool `json:"forever" yaml:"forever"`
	// Steps is the list of steps in the sequence.
	Steps []*ActionListEntry `json:"steps" yaml:"steps"`
}

SequenceEntry represents a sequence in a scenario.

func (*SequenceEntry) Validate added in v0.33.0

func (e *SequenceEntry) Validate() error

type SolutionDoc

type SolutionDoc struct {
	Version     string            `json:"version" yaml:"version"`
	Name        string            `json:"name" yaml:"name"`
	Description string            `json:"description" yaml:"description"`
	RootDir     string            `json:"rootDir" yaml:"rootDir"`
	Meta        map[string]any    `json:"meta" yaml:"meta"`
	Layers      []*SolutionTarget `json:"layers" yaml:"layers"`
	Targets     []*SolutionTarget `json:"targets" yaml:"targets"`
	// contains filtered or unexported fields
}

func (*SolutionDoc) AggregateDependencies added in v0.30.0

func (s *SolutionDoc) AggregateDependencies() []string

AggregateDependencies computes the dependencies of each layer.

func (*SolutionDoc) Validate added in v0.13.13

func (s *SolutionDoc) Validate() error

type SolutionTarget added in v0.33.0

type SolutionTarget struct {
	Name        string                 `json:"name" yaml:"name"`
	Description string                 `json:"description" yaml:"description"`
	Inputs      []string               `json:"inputs" yaml:"inputs"`
	Output      string                 `json:"output" yaml:"output"`
	Template    string                 `json:"template" yaml:"template"`
	Features    []string               `json:"features" yaml:"features"`
	Force       bool                   `json:"force" yaml:"force"`
	Imports     []string               `json:"imports" yaml:"imports"`
	Meta        map[string]interface{} `json:"meta" yaml:"meta"`
	MetaImports map[string]interface{} `json:"-" yaml:"-"` // meta imports

	// TemplateDir is the directory of the template
	TemplateDir string `json:"-" yaml:"-"`
	// TemplatesDir is the "templates" directory inside the template dir
	TemplatesDir string `json:"-" yaml:"-"`
	// RulesFile is the "rules.yaml" file inside the template dir
	RulesFile string `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

func (*SolutionTarget) Dependencies added in v0.33.0

func (l *SolutionTarget) Dependencies() []string

func (*SolutionTarget) ExpandedInputs added in v0.33.0

func (l *SolutionTarget) ExpandedInputs() []string

func (*SolutionTarget) GetOutputDir added in v0.33.0

func (l *SolutionTarget) GetOutputDir(rootDir string) string

GetOutputDir returns the output dir. The output dir can be relative to the root dir of the solution.

func (*SolutionTarget) Validate added in v0.33.0

func (l *SolutionTarget) Validate(doc *SolutionDoc) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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