gen

package
v0.0.0-...-57bed1d Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMustBeginWithLowerLatin = errors.New(
		"must begin with a lower case latin character",
	)
	ErrMustBeginWithUpperLatin = errors.New(
		"must begin with an upper case latin character",
	)
	ErrContainsIllegalChars = errors.New(
		"contains illegal characters",
	)
	ErrEmpty = errors.New("empty")
)

Functions

func ParseComment

func ParseComment(s string) []string

func ParseTypeID

func ParseTypeID(t TypeID) (
	typeName string,
	packagePath []string,
	err error,
)

func ValidateCamelCase

func ValidateCamelCase(n string) error

func ValidateEventName

func ValidateEventName(n EventName) error

func ValidatePascalCase

func ValidatePascalCase(n string) error

func ValidateProjectionName

func ValidateProjectionName(n ProjectionName) error

func ValidateProjectionState

func ValidateProjectionState(n ProjectionState) error

func ValidatePropertyName

func ValidatePropertyName(n PropertyName) error

func ValidateServiceMethodName

func ValidateServiceMethodName(n ServiceMethodName) error

func ValidateServiceName

func ValidateServiceName(n ServiceName) error

Types

type Event

type Event struct {
	Schema     *Schema
	Name       string
	Properties []*Property
	References []interface{}
}

type EventName

type EventName = string

type Generator

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

func NewGenerator

func NewGenerator() *Generator

func (*Generator) Generate

func (g *Generator) Generate(
	schema *Schema,
	outputPath string,
	options GeneratorOptions,
) (outPackagePath string, err error)

type GeneratorOptions

type GeneratorOptions struct {
	PackageName        string
	ExcludeProjections bool
}

func (*GeneratorOptions) Prepare

func (o *GeneratorOptions) Prepare() error

Prepare validates the options and sets defaults for undefined values

type ModelEvent

type ModelEvent = ModelProperties

type ModelProjection

type ModelProjection struct {
	States      []ProjectionState               `yaml:"states"`
	Properties  ModelProperties                 `yaml:"properties"`
	CreateOn    EventName                       `yaml:"createOn"`
	Transitions map[EventName][]ModelTransition `yaml:"transitions"`
}

type ModelProperties

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

func (*ModelProperties) UnmarshalYAML

func (m *ModelProperties) UnmarshalYAML(v *yaml.Node) error

type ModelProperty

type ModelProperty struct {
	Pos          int
	TypeID       TypeID
	CommentLines []string
}

type ModelSchema

type ModelSchema struct {
	Events      map[EventName]ModelEvent           `yaml:"events"`
	Projections map[ProjectionName]ModelProjection `yaml:"projections"`
	Services    map[ServiceName]ModelService       `yaml:"services"`
}

type ModelService

type ModelService struct {
	Projections []ProjectionName    `yaml:"projections"`
	Methods     ModelServiceMethods `yaml:"methods"`
}

type ModelServiceMethod

type ModelServiceMethod struct {
	Pos          int
	CommentLines []string
	Input        *TypeID           `yaml:"in"`
	Output       *TypeID           `yaml:"out"`
	Type         ServiceMethodType `yaml:"type"`
	Emits        []EventName       `yaml:"emits"`
}

type ModelServiceMethods

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

func (*ModelServiceMethods) UnmarshalYAML

func (m *ModelServiceMethods) UnmarshalYAML(v *yaml.Node) error

type ModelTransition

type ModelTransition = string

type Projection

type Projection struct {
	Schema       *Schema
	Name         ProjectionName
	States       map[ProjectionState]struct{}
	InitialState ProjectionState
	Properties   []*Property
	CreateOn     *Event
	Transitions  map[*Event][]*Transition
}

type ProjectionName

type ProjectionName = string

type ProjectionState

type ProjectionState = string

type Property

type Property struct {
	Position     int
	Name         PropertyName
	Type         *Type
	CommentLines []string
}

type PropertyName

type PropertyName = string

type Schema

type Schema struct {
	Raw            string
	Events         map[EventName]*Event
	Projections    map[ProjectionName]*Projection
	Services       map[ServiceName]*Service
	SourcePackages map[SourcePackageID]*SourcePackage
	SourcePackage  *SourcePackage
	SourceModule   string
}

func Parse

func Parse(
	sourcePackagePath,
	schemaFilePath string,
) (*Schema, error)

type SemanticErr

type SemanticErr string

func (SemanticErr) Error

func (s SemanticErr) Error() string

type Service

type Service struct {
	Schema        *Schema
	Name          ServiceName
	Projections   []*Projection
	Methods       map[ServiceMethodName]*ServiceMethod
	Subscriptions map[EventName]*Event
}

type ServiceMethod

type ServiceMethod struct {
	Service      *Service
	Name         ServiceMethodName
	Type         ServiceMethodType
	Input        *Type
	Output       *Type
	Emits        []*Event
	CommentLines []string
}

type ServiceMethodName

type ServiceMethodName = string

type ServiceMethodType

type ServiceMethodType = string

type ServiceName

type ServiceName = string

type SourcePackage

type SourcePackage struct {
	Path       string // Absolute directory path
	ImportPath string // Import path relative to the module
	Name       SourcePackageName
	ID         SourcePackageID // dot-separated unique identifier
	Types      map[TypeID]*Type
}

type SourcePackageID

type SourcePackageID = string

type SourcePackageName

type SourcePackageName = string

type SyntaxErr

type SyntaxErr string

func (SyntaxErr) Error

func (s SyntaxErr) Error() string

type Transition

type Transition struct {
	Projection *Projection
	On         *Event
	From       ProjectionState
	To         ProjectionState
}

type Type

type Type struct {
	ID             string
	Name           string
	Package        *SourcePackage
	SourceLocation token.Position
	References     []interface{}
}

type TypeID

type TypeID = string

Jump to

Keyboard shortcuts

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