project

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitIgnoreFile     = ".gitignore"
	MainFile          = "main.go"
	LocalFile         = "local.json"
	GoModFile         = "go.mod"
	ConfigFileProject = "atomika.json"
)
View Source
const (
	DefDirService  = "def"
	ErrFile        = "errors.go"
	DefinitionFile = "definitions.go"
	ConsumerFile   = "consumer.go"
	ServerFile     = "server.go"
	ServiceFile    = "service.go"
	TestFile       = "service_test.go"
)
View Source
const (
	ClientGoFile = "client.go"
	ClientJsFile = "client.js"
	ClientTsFile = "client.ts"
)

Variables

View Source
var (
	ErrCwd          = errors.New("cannot cwd")
	ErrCreateDir    = errors.New("cannot create dir")
	ErrSetDirRoot   = errors.New("cannot set dir root")
	ErrBadPath      = errors.New("bad path")
	ErrLoadFromFile = errors.New("cannot load from file")
)
View Source
var (
	ErrPkgNotFound     = errors.New("pkg not found")
	ErrPkgMod          = errors.New("pkg has no module information")
	ErrNoGoFilesFound  = errors.New("pkg has no Go files")
	ErrMethodFormat    = errors.New("invalid method format. Expected: Method(MethodReq) MethodRes")
	ErrMethodObjParse  = errors.New("cannot parse object for method")
	ErrObjNotStruct    = errors.New("object is not a struct")
	ErrObjNotFound     = errors.New("object not found")
	ErrFieldUnexported = errors.New("filed is unexported")
	ErrFieldIsStruct   = errors.New("filed cannot not be struct")
)

Parser errors

Functions

func EnsureDir

func EnsureDir(root *os.Root, filePath string) error

func HasPath

func HasPath(root *os.Root, filePath string) bool

func MkDirAll

func MkDirAll(root *os.Root, dirPath string) error

func Parse

func Parse(rootFs *os.Root, defDir string) (*Definition, *Report, error)

Parse definitions for project service defDir - internal/<service>/def

func Render

func Render(file *templates.File, data any) ([]byte, error)

func WriteFile

func WriteFile(root *os.Root, path string, data []byte) error

Types

type Alias added in v1.5.3

type Alias struct {
	Name     string
	Expr     string
	Comment  string
	Metadata Metadata
}

type Definition

type Definition struct {
	Package  string
	Imports  map[string]string
	Aliases  []*Alias
	Services []*Service
	Objects  []*Object
}

Definition will map the contents of service/def dir to an interface

type Diag

type Diag struct {
	Where   string `json:"where,omitempty"`
	Message string `json:"message"`
}

type Field

type Field struct {
	Name               string
	NameCamelLowerCase string
	Type               FieldType
	OmitEmpty          bool
	Tag                string
	ParsedTags         map[string]FieldTag
	Comment            string
	Metadata           Metadata
	JSONOmitEmpty      bool
}

type FieldTag

type FieldTag struct {
	Value   string   `json:"value"`
	Options []string `json:"options"`
}

type FieldType

type FieldType struct {
	TypeID                  string
	TypeName                string
	ObjName                 string
	ObjNameToLowerCamelCase string
	Package                 string
	IsCollection            bool
	IsObject                bool
	JSType                  string
	TSType                  string
	Length                  int
	CollectionKeyType       string
	CollectionValue         *FieldType
	IsLocal                 bool
	TSDefault               string
}

type MetaKeyResult

type MetaKeyResult struct {
	Exists bool
	Result any
}

type Metadata

type Metadata map[string]string

func (Metadata) Get

func (m Metadata) Get(key string) (string, bool)

type MetadataValueDesc

type MetadataValueDesc struct {
	Value       any    `json:"value"`
	Description string `json:"description,omitempty"`
}

type Method

type Method struct {
	Name               string
	NameCamelLowerCase string
	Params             FieldType
	Returns            FieldType
	Comment            string
	Metadata           Metadata
}

type Object

type Object struct {
	Name     string
	ObjName  string
	TypeID   string
	Imported bool
	Fields   []Field
	Comment  string
	Metadata Metadata
}

type ParseStats

type ParseStats struct {
	PackageName string    `json:"packageName"`
	NumFiles    int       `json:"numFiles"`
	NumServices int       `json:"numServices"`
	NumObjects  int       `json:"numObjects"`
	NumMethods  int       `json:"numMethods"`
	NumFields   int       `json:"numFields"`
	StartedAt   time.Time `json:"startedAt"`
	FinishedAt  time.Time `json:"finishedAt"`
}

ParseStats tracks deterministic counters for CI visibility.

func (ParseStats) TimeTook

func (p ParseStats) TimeTook() string

type Project

type Project struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
	// contains filtered or unexported fields
}

func LoadFromConfig

func LoadFromConfig() (*Project, error)

LoadFromConfig load a project from an atomika.json file

func New

func New(dir string) (*Project, error)

func (*Project) Exists

func (p *Project) Exists() bool

func (*Project) Root

func (p *Project) Root() *os.Root

func (*Project) ToMap

func (p *Project) ToMap() (map[string]any, error)

ToMap returns a map representation of the project struct

type Report

type Report struct {
	Warnings []Diag     `json:"warnings"`
	Errors   []Diag     `json:"errors"`
	Stats    ParseStats `json:"stats"`
}

type Service

type Service struct {
	Name               string
	NameCamelLowerCase string
	TargetServiceName  string
	TargetServiceArg   string
	Methods            []*Method
	Comment            string
	Metadata           Metadata
	IsWebsocket        bool
}

Jump to

Keyboard shortcuts

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