schema

package
v0.0.0-...-8de7dcd Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayOfScalarField

type ArrayOfScalarField interface {
	AppendASTValue(j5reflect.ASTValue) (int, error)
	FullTypeName() string
}

type BlockHook

type BlockHook interface {
	RunHook(j5reflect.ContainerField) error
}

type BlockHookFunc

type BlockHookFunc func(j5reflect.ContainerField) error

func (BlockHookFunc) RunHook

type BlockSpec

type BlockSpec struct {
	DebugName string // Prints as context to the user

	Description *string // Field to place the description in

	Aliases map[string]PathSpec

	Name       *Tag
	TypeSelect *Tag

	Qualifier *Tag // A qualifier maps to a new child block at this field

	OnlyDefined bool // Only allows blocks and attributes explicitly defined in Spec, otherwise merges all available in the schema

	// Callback to run after closing the block, to run validation, automatic
	// cleanup etc.
	RunAfter BlockHook

	ScalarSplit *ScalarSplit
	// contains filtered or unexported fields
}

Defines customizations for a 'type', these should be set in the schema

func (*BlockSpec) ErrName

func (bs *BlockSpec) ErrName() string

func (*BlockSpec) Validate

func (bs *BlockSpec) Validate() error

type ChildSpec

type ChildSpec struct {
	Path PathSpec
	// contains filtered or unexported fields
}

func (ChildSpec) TagString

func (cs ChildSpec) TagString() string

type Container

type Container interface {
	Path() []string
	Spec() BlockSpec
	Name() string
}

type Field

type Field interface {
	j5reflect.Field
}

type PathErrorType

type PathErrorType int
const (
	UnknownPathError PathErrorType = iota
	NodeNotContainer
	NodeNotScalar
	NodeNotScalarArray
	NodeNotFound
	RootNotFound
)

type PathSpec

type PathSpec []string

func (PathSpec) GoString

func (sp PathSpec) GoString() string

type ScalarField

type ScalarField interface {
	SetASTValue(j5reflect.ASTValue) error
	FullTypeName() string
}

type ScalarSplit

type ScalarSplit struct {
	Delimiter   *string
	RightToLeft bool

	Required  []PathSpec
	Optional  []PathSpec
	Remainder *PathSpec
}

type SchemaSet

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

func NewSchemaSet

func NewSchemaSet(given *bcl_j5pb.Schema) (*SchemaSet, error)

type Scope

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

func NewRootSchemaWalker

func NewRootSchemaWalker(ss *SchemaSet, root j5reflect.Object, sourceLoc *bcl_j5pb.SourceLocation) (*Scope, error)

func (*Scope) ChildBlock

func (sw *Scope) ChildBlock(name string, source SourceLocation) (*Scope, *WalkPathError)

func (*Scope) CurrentBlock

func (sw *Scope) CurrentBlock() Container

func (*Scope) Field

func (sw *Scope) Field(name string, source SourceLocation, existingIsOk bool) (Field, *WalkPathError)

func (*Scope) ListAttributes

func (sw *Scope) ListAttributes() []string

func (*Scope) ListBlocks

func (sw *Scope) ListBlocks() []string

func (*Scope) MergeScope

func (sw *Scope) MergeScope(other *Scope) *Scope

func (*Scope) PrintScope

func (sw *Scope) PrintScope(logf func(string, ...interface{}))

func (*Scope) RootBlock

func (sw *Scope) RootBlock() Container

func (*Scope) ScalarField

func (sw *Scope) ScalarField(name string, source SourceLocation) (ScalarField, *WalkPathError)

func (*Scope) SchemaNames

func (sw *Scope) SchemaNames() []string

func (*Scope) TailScope

func (sw *Scope) TailScope() *Scope

type SourceLocation

type SourceLocation = errpos.Position

type Tag

type Tag struct {
	FieldName         string
	BangFieldName     *string
	QuestionFieldName *string

	IsOptional bool
	IsBlock    bool
}

func (*Tag) Validate

func (t *Tag) Validate(tagType TagType) error

type TagType

type TagType int
const (

	// Set the scalar value at Path to the value of Tag. Oneofs are allowed at
	// the leaf, the default value of the property matching the tag is set.
	TagTypeScalar TagType

	// The leaf node at Path + Tag must be a container. Used on 'type select'
	// fields
	TagTypeTypeSelect

	// Leaf can be either type.
	// If it is a container, it must have a property matching the given name.
	// Then the container is included in the search path for attributes and
	// blocks.
	// If it is a scalar, the value is set, the search path does not change.
	// If it is a SplitRef scalar, the value is set, and if there are any
	// remaining blocks in the item they are added to the search path.
	TagTypeQualifier
)

type WalkPathError

type WalkPathError struct {
	Type PathErrorType

	// for unknown:
	Err error

	// for RootNotFound and NodeNotFound:
	Available []string
	Schema    string
	Field     string
	Path      []string
}

func (*WalkPathError) Error

func (wpe *WalkPathError) Error() string

func (*WalkPathError) LongMessage

func (wpe *WalkPathError) LongMessage() string

Jump to

Keyboard shortcuts

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