cmd

package
v1.0.0-beta10 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute() error

Execute executes the root command.

func LoadBundle

func LoadBundle(ctx *ls.Context, file string) (ls.SchemaLoader, error)

func LoadSchemaFromFileOrRepo

func LoadSchemaFromFileOrRepo(ctx *ls.Context, compiledSchema, repoDir, schemaName, typeName, bundleName string) (*ls.Layer, error)

func LoadValuesetFiles

func LoadValuesetFiles(vs *Valuesets, files []string) error

func OutputIngestedGraph

func OutputIngestedGraph(outFormat string, target graph.Graph, wr io.Writer, includeSchema bool) error

func ReadLayers

func ReadLayers(input []byte, interner ls.Interner) ([]*ls.Layer, error)

ReadLayers reads layer(s) from jsongraph, jsonld

Types

type Attribute

type Attribute struct {
	ID            string `json:"@id"`
	AttributeName string `json:"attributeName"`
	Types         string `json:"@type"`
}

Following structs are used to define a Layered Schema

type Bundle

type Bundle struct {
	TypeNames map[string]BundleVariant `json:"typeNames" yaml:"typeNames"`
}

Bundle defines type names for variants so references can be resolved

func ParseBundle

func ParseBundle(text string, contentType string) (*Bundle, error)

ParseBundle parses a bundle from JSON

func (*Bundle) GetLayers

func (bundle *Bundle) GetLayers(ctx *ls.Context, path string, loader func(s string) (*ls.Layer, error)) (map[string]*ls.Layer, error)

GetLayers returns the layers of the bundle keyed by variant type

type BundleSchemaRef

type BundleSchemaRef struct {
	Schema     string               `json:"schema,omitempty" yaml:"schema,omitempty"`
	JSONSchema *JSONSchemaReference `json:"jsonSchema" yaml:"jsonSchema"`
}

func (BundleSchemaRef) GetLayerID

func (ref BundleSchemaRef) GetLayerID() string

GetLayerID returns the layer id for the schema reference

type BundleVariant

type BundleVariant struct {
	BundleSchemaRef
	Overlays []BundleSchemaRef `json:"overlays" yaml:"overlays"`
}

BundleVariant combines a schema and overlays

type ImportJSONSchemaRequest

type ImportJSONSchemaRequest struct {
	Entities []jsonsch.Entity   `json:"entities"`
	SchemaID string             `json:"schemaId"`
	Schema   string             `json:"schemaVariant"`
	Layers   []SliceByTermsSpec `json:"layers"`
}

func (*ImportJSONSchemaRequest) CompileAndImport

func (req *ImportJSONSchemaRequest) CompileAndImport() (graph.Graph, []jsonsch.EntityLayer, error)

func (*ImportJSONSchemaRequest) Slice

func (req *ImportJSONSchemaRequest) Slice(index int, item jsonsch.EntityLayer) ([]*ls.Layer, *ls.SchemaVariant, error)

type JSONSchemaReference

type JSONSchemaReference struct {
	LayerID string `json:"layerId" yaml:"layerId" bson:"layerId"`
	Ref     string `json:"ref" yaml:"ref" bson:"ref"`
}

type LS

type LS struct {
	Context string `json:"@context"`
	ID      string `json:"@id"`
	Type    string `json:"@type"`
	Layer   Layer  `json:"layer"`
}

type Layer

type Layer struct {
	AttributeList []Attribute `json:"attributeList"`
}

type SliceByTermsSpec

type SliceByTermsSpec struct {
	Type  string   `json:"type"`
	Terms []string `json:"terms"`
	ID    string   `json:"@id"`
	File  string   `json:"file"`
}

func (SliceByTermsSpec) Slice

func (spec SliceByTermsSpec) Slice(sourceLayer *ls.Layer, targetType string, templateData interface{}) (*ls.Layer, error)

type Valueset

type Valueset struct {
	ID     string          `json:"id" yaml:"id"`
	Values []ValuesetValue `json:"values" yaml:"values"`
}

func (Valueset) Lookup

type ValuesetValue

type ValuesetValue struct {
	// Possible input values
	Values []string `json:"values" yaml:"values"`
	// Possible input value as key-value pairs
	KeyValues     map[string]string `json:"keyValues" yaml:"keyValues"`
	CaseSensitive bool              `json:"caseSensitive" yaml:"caseSensitive"`
	// Result output value
	Result string `json:"result" yaml:"result"`
	// Result output values as key-value pairs
	ResultValues map[string]string `json:"results" yaml:"results"`
}

func (ValuesetValue) IsDefault

func (v ValuesetValue) IsDefault() bool

func (ValuesetValue) Match

type Valuesets

type Valuesets struct {
	Sets map[string]Valueset `json:"valuesets" yaml:"valuesets"`
}

func (Valuesets) Lookup

Lookup can be used as the external lookup func of LookupProcessor

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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