transform

package
v1.0.0-beta7 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JoinMethodJoin  = "join"
	JoinMethodError = "error"
)
View Source
const RS = ls.LS + "reshape/"

Variables

View Source
var (
	ErrInvalidSource                = errors.New("Invalid source")
	ErrMultipleSourceNodesForObject = errors.New("Multiple source nodes specified for an object")
	ErrSourceMustBeString           = errors.New("source term value must be a string")
)
View Source
var ErrInvalidConditional = errors.New("Invalid conditional")
View Source
var ErrInvalidVariables = errors.New("Invalid vars section")
View Source
var ErrJoinFailure = errors.New("Join failure")
View Source
var ReshapeTerms = struct {
	// If given, the If term specifies a predicate that should be true to reshape the node
	If string
	// Vars defines a list of expressions that pull values from the
	// source graph and define them as variables
	Vars string
	// Source specifies the source value to be used to generate the target value
	Source string
	// IfEmpty determines whether to reshape the node even if it has no value
	IfEmpty string
	// JoinMethod determines how to join multiple values to generate a single value
	JoinMethod string
	// JoinDelimiter specifies the join delimiter if there are multiple values to be combined
	JoinDelimiter string
}{
	If: ls.NewTerm(RS+"if", false, false, ls.OverrideComposition, struct {
		ifSemantics
	}{}),
	Vars: ls.NewTerm(RS+"vars", false, true, ls.OverrideComposition, struct {
		varsSemantics
	}{}),
	Source: ls.NewTerm(RS+"source", false, false, ls.OverrideComposition, struct {
		sourceSemantics
	}{}),
	IfEmpty:       ls.NewTerm(RS+"ifEmpty", false, false, ls.OverrideComposition, nil),
	JoinMethod:    ls.NewTerm(RS+"joinMethod", false, false, ls.OverrideComposition, nil),
	JoinDelimiter: ls.NewTerm(RS+"joinDelimiter", false, false, ls.OverrideComposition, nil),
}

ReshapeTerms defines the terms used to specify reshaping layers

Functions

func JoinValues

func JoinValues(nodes []ls.Node, method, delimiter string) (string, error)

Types

type ErrInvalidSchemaNodeType

type ErrInvalidSchemaNodeType []string

ErrInvalidSchemaNodeType is returned if the schema node type cannot be projected (such as a reference, which cannot happen after compilation)

func (ErrInvalidSchemaNodeType) Error

func (e ErrInvalidSchemaNodeType) Error() string

type ReshapeContext

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

func (*ReshapeContext) CurrentSchemaNode

func (p *ReshapeContext) CurrentSchemaNode() ls.Node

type Reshaper

type Reshaper struct {
	TargetSchema *ls.Layer

	// If true, adds the references to the target schema
	AddInstanceOfEdges bool

	// GenerateID will generate a node ID given schema path and target document path up to the new node
	GenerateID func(schemaPath, docPath []ls.Node) string
}

func (*Reshaper) Reshape

func (respaher *Reshaper) Reshape(rootNode ls.Node) (ls.Node, error)

Reshape the graph rooted at the rootNode to the targetSchema, using the getReshapeProperties function that will return reshaping properties for given schema nodes

Jump to

Keyboard shortcuts

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