spec

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 12 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 CheckCsvFile

func CheckCsvFile(name string) error

func CheckFile

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

func CheckIdlFile

func CheckIdlFile(name string) error

func CheckNdjsonFile

func CheckNdjsonFile(name string) error

func DocumentTypeFromFileName

func DocumentTypeFromFileName(fn string) (string, error)

func JsonToYaml

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

func LintJsonDoc

func LintJsonDoc(t DocumentType, jsonDoc []byte) (*gojsonschema.Result, error)

func LoadSchema

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

func YamlToJson

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

Types

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"`
}

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

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 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"`
}

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

func (*FeatureRule) FindScopeByMatch

func (s *FeatureRule) FindScopeByMatch(match ScopeType) ScopeRule

FindScopeByMatch returns the first scope that matches the given match.

type RulesDoc

type RulesDoc struct {
	Features []FeatureRule `json:"features" yaml:"features"`
}

type ScenarioDoc

type ScenarioDoc struct {
	Schema     string              `json:"schema" yaml:"schema"`
	Interfaces []ScenarioInterface `json:"interfaces" yaml:"interfaces"`
}

type ScenarioInterface

type ScenarioInterface struct {
	Name       string             `json:"name" yaml:"name"`
	Properties []ScenarioProperty `json:"properties" yaml:"properties"`
}

type ScenarioProperty

type ScenarioProperty struct {
	Name  string `json:"name" yaml:"name"`
	Value string `json:"value" yaml:"value"`
}

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.

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 SolutionDoc

type SolutionDoc struct {
	Schema      string          `json:"schema" yaml:"schema"`
	Version     string          `json:"version" yaml:"version"`
	Name        string          `json:"name" yaml:"name"`
	Description string          `json:"description" yaml:"description"`
	RootDir     string          `json:"rootDir" yaml:"rootDir"`
	Layers      []SolutionLayer `json:"layers" yaml:"layers"`
}

type SolutionLayer

type SolutionLayer 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"`
}

Jump to

Keyboard shortcuts

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