lib

package
v1.8.76 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultShard        = 0
	MetaDirectory       = ".dvc"
	PermissionsFile     = ".dvc/permissions.json"
	CorePermissionsFile = "core/permissions.json"
	SettingsFile        = ".dvc/settings.json"
	CoreSettingsFile    = "core/settings.json"
	ConfigFilePath      = ".dvc/config.json"
	SchemasFilePath     = ".dvc/schemas.json"
	CoreSchemasFilePath = "core/schemas.json"
	CoreSchemasName     = "core"
	CoreSchemasLogName  = "core_log"
	ChangeFilePath      = ".dvc/changes.log"
	TablesCacheFilePath = ".dvc/tables-cache.json"
	RoutesFilePath      = ".dvc/routes.json"
	ModelsDir           = "models"
	ModelsGenDir        = "gen/definitions/models"
	IntegrationsDir     = "integrations"
	DALsDir             = "dals"
	// Generated Go file containing constants for all route permissions
	GoPermissionsPath = "gen/permissions"
)
View Source
const (
	// OptLogInfo triggers verbose logging
	OptLogInfo = 1 << iota
	// OptLogDebug triggers extremely verbose logging
	OptLogDebug
	// OptSilent suppresses all logging
	OptSilent
	// OptReverse reverses the function
	OptReverse
	// OptSummary shows a summary of the actions instead of a raw stdout dump
	OptSummary
	// OptClean cleans
	OptClean
	// OptForce forces
	OptForce
)

Variables

This section is empty.

Functions

func DirExists

func DirExists(dirPath string) bool

func DirIsEmpty

func DirIsEmpty(dirPath string) bool

func EnsureDir

func EnsureDir(dir string) (e error)

EnsureDir creates a new dir if the dir is not found

func ExtractRootNameFromKey

func ExtractRootNameFromKey(key string) string

func FetchDirFileNames

func FetchDirFileNames(dirPath string) (fileNames []string, e error)

FetchDirFileNames fetches returns a slice of strings of the name of the directories in a directory (non-recursive)

func FetchFile

func FetchFile(filePath string) (changesetFileString string, e error)

FetchFile fetches a file contents

func FetchNonDirFileNames

func FetchNonDirFileNames(dirPath string) (files []string, e error)

FetchNonDirFileNames returns a list of files in a directory that are only regular files

func FileExists

func FileExists(filePath string) bool

func FmtGoCode

func FmtGoCode(filePath string) (e error)

FmtGoCode formats a go file

func FormatCode

func FormatCode(code string) ([]byte, error)

FormatCode formats the code

func FormatFieldList

func FormatFieldList(src []byte, fieldList *ast.FieldList, pkgName string) (fields []string)

FormatFieldList returns a list of formatted list of fields

func GetFuncDeclarationReceiverType

func GetFuncDeclarationReceiverType(fd *ast.FuncDecl) (expr ast.Expr, e error)

GetFuncDeclarationReceiverType returns the receiver type of a function declaration

func GetReceiverTypeName

func GetReceiverTypeName(src []byte, fl interface{}) (name string, funcDef *ast.FuncDecl)

GetReceiverTypeName returns the name of the receiver type and the declaration

func HashFileMd5

func HashFileMd5(filePath string) (string, error)

HashFileMd5 returns an MD5 checksum of the file at `filePath`

func HashStringMd5

func HashStringMd5(s string) string

HashStringMd5 genereates an MD5 hash of a string

func ReadCliInput

func ReadCliInput(reader *bufio.Reader, title string) string

func RunCommand

func RunCommand(name string, args ...string) (stdout string, stderr string, exitCode int)

RunCommand runs a system command

func WriteGoCodeToFile

func WriteGoCodeToFile(goCode string, filePath string) (e error)

WriteGoCodeToFile writes a string of golang code to a file and then formats it with `go fmt`

func WriteSQLToLog

func WriteSQLToLog(sql string) error

Types

type CLITable

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

func NewCLITable

func NewCLITable(colNames []string) *CLITable

func (*CLITable) AddRow

func (c *CLITable) AddRow(row []string)

func (*CLITable) Col

func (c *CLITable) Col(val string)

func (*CLITable) Colf

func (c *CLITable) Colf(template string, args ...interface{})

func (*CLITable) NewRow

func (c *CLITable) NewRow() []string

func (*CLITable) Row

func (c *CLITable) Row()

func (*CLITable) String

func (c *CLITable) String() string

type ChangeFile

type ChangeFile struct {
	ID          int64
	DateCreated int64
	Hash        string
	Name        string
	DVCSetID    int64
	IsRun       bool
	IsDeleted   bool
	Content     string
	FullPath    string
	Ordinal     int
}

ChangeFile represents both a physical file on the local file system along with the entry in the changefile database

type Changeset

type Changeset struct {
	ChangeFiles map[string]ChangeFile
	Signature   string
}

Changeset represents all of the changes in an environment and their changes

type Command

type Command struct {
	Options Options
}

Command is the command line functionality

type Config

type Config struct {
	ChangeSetPath             string            `json:"changesetPath"`
	BasePackage               string            `json:"basePackage"`
	Databases                 []*ConfigDatabase `json:"Databases"`
	TypescriptModelsPath      string            `json:"TypescriptModelsPath"`
	TypescriptDTOsPath        string            `json:"TypescriptDTOsPath"`
	TypescriptAggregatesPath  string            `json:"TypescriptAggregatesPath"`
	TypescriptPermissionsPath string            `json:"TypescriptPermissionsPath"`
	TypescriptRoutesPath      string            `json:"TypescriptRoutesPath"`
	Packages                  struct {
		Cache    string `json:"cache"`
		Models   string `json:"models"`
		Schema   string `json:"schema"`
		Repos    string `json:"repos"`
		Services string `json:"services"`
		API      string `json:"api"`
	} `json:"packages"`

	Dirs struct {
		Dals                  string `json:"dals"`
		DalInterfaces         string `json:"dalInterfaces"`
		Repos                 string `json:"repos"`
		Cache                 string `json:"cache"`
		Models                string `json:"models"`
		Integrations          string `json:"integrations"`
		IntegrationInterfaces string `json:"integrationInterfaces"`
		Aggregates            string `json:"aggregates"`
		Schema                string `json:"schema"`
		Typescript            string `json:"typescript"`
		Services              string `json:"services"`
		ServiceInterfaces     string `json:"serviceInterfaces"`
		Controllers           string `json:"controllers"`
		API                   string `json:"api"`
		Permissions           string `json:"permissions"`
	} `json:"dirs"`
}

Config contains a set of configuration values used throughout the application

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads a config file

type ConfigDatabase

type ConfigDatabase struct {
	Key       string            `json:"key"`
	Type      string            `json:"type"`
	User      string            `json:"user"`
	Pass      string            `json:"pass"`
	Host      string            `json:"host"`
	Name      string            `json:"name"`
	Enums     []string          `json:"enums"`
	OneToMany map[string]string `json:"onetomany"`
	OneToOne  map[string]string `json:"onetoone"`
	ManyToOne map[string]string `json:"manytoone"`
}

func GetDatabasesByRootName

func GetDatabasesByRootName(rootName string, config *Config) []*ConfigDatabase

GetDatabaseByName gets all databases that have the name of `name` as the base and includes shards with `_[shardNo]` as the suffix.

type Controller added in v1.8.23

type Controller struct {
	Name              string             `json:"Name"`
	Description       string             `json:"Description"`
	Path              string             `json:"-"`
	Routes            []*ControllerRoute `json:"Routes"`
	HasDTOsImport     bool               `json:"-"`
	HasResponseImport bool               `json:"-"`
	PermCount         int                `json:"-"`
	Package           string             `json:"Package"`
}

Controller represents a REST controller

type ControllerRoute added in v1.8.23

type ControllerRoute struct {
	Name           string                 `json:"Name"`
	Description    string                 `json:"Description"`
	Raw            string                 `json:"Path"`
	Path           string                 `json:"-"`
	Method         string                 `json:"Method"`
	Params         []ControllerRouteParam `json:"Params"`
	Queries        []ControllerRouteQuery `json:"Queries"`
	IsAuth         bool                   `json:"IsAuth"`
	BodyType       string                 `json:"BodyType"`
	BodyFormat     string                 `json:"BodyFormat"`
	HasBody        bool                   `json:"HasBody"`
	ResponseType   string                 `json:"ResponseType"`
	ResponseFormat string                 `json:"ResponseFormat"`
	ResponseCode   int                    `json:"ResponseCode"`
	Permission     string                 `json:"Permission"`
	ControllerName string                 `json:"ControllerName"`
	FileName       string                 `json:"FileName"`
	LineNo         int                    `json:"LineNo"`
}

ControllerRoute represents a route inside a REST controller

type ControllerRouteParam added in v1.8.23

type ControllerRouteParam struct {
	Name    string
	Pattern string
	Type    string
}

ControllerRouteParam represents a param inside a controller route

type ControllerRouteQuery added in v1.8.23

type ControllerRouteQuery struct {
	Name         string
	Pattern      string
	Type         string
	VariableName string
	ValueRaw     string
}

ControllerRouteQuery represents a query inside a controller route

type DatabaseType

type DatabaseType string

DatabaseType is the type of database to be used.

const (
	// DatabaseTypeMysql is the MySQL flavor of database
	DatabaseTypeMysql DatabaseType = "mysql"
)

type DocRoute added in v1.8.23

type DocRoute struct {
	Name           string
	Description    string
	Method         string
	Path           string
	HasBody        bool
	BodyType       string
	BodyFormat     string
	ResponseType   string
	ResponseFormat string
	ResponseCode   int
}

DocRoute is a route in the documentation

type DocRouteParam added in v1.8.23

type DocRouteParam struct {
	Name    string
	Pattern string
	Type    string
}

DocRouteParam represents a parameter inside a route for documentation

type DocRouteQuery added in v1.8.23

type DocRouteQuery struct {
	Name    string
	Pattern string
	Type    string
}

DocRouteQuery represents a query inside a route for documentation

type Files

type Files struct {
}

Files contains functionality pertaining to files

func (*Files) BuildChangeFile

func (f *Files) BuildChangeFile(sqlPath string, ordinal int) (changeFile *ChangeFile, e error)

BuildChangeFile builds a changeFile object based on a path and an ordinal

func (*Files) BuildChangeFiles

func (f *Files) BuildChangeFiles(sqlPaths []string) (changeFiles []ChangeFile, e error)

BuildChangeFiles returns a collection of ChangeFile objects based on a collection of sql paths

func (*Files) FetchLocalChangesetList

func (f *Files) FetchLocalChangesetList(rootPath string) (sqlPaths []string, e error)

FetchLocalChangesetList gets the contents of the changesets.json file and returns a collection of paths ([]string)

func (*Files) ScanDir

func (f *Files) ScanDir(rootPath string, extension string) (paths []string, e error)

ScanDir scans the changeset directory for any file with an extension

type GoFileImports

type GoFileImports []string

GoFileImports is a collection of imports for a model file

func (*GoFileImports) Append

func (i *GoFileImports) Append(m string)

Append adds to the collection of imports

func (*GoFileImports) Get

func (i *GoFileImports) Get(idx int) string

Get returns an import at an index

func (*GoFileImports) Len

func (i *GoFileImports) Len() int

Len returns the length of the collection of imports

func (*GoFileImports) ToString

func (i *GoFileImports) ToString() string

ToString returns a string representation of imports on a go file

type GoStruct

type GoStruct struct {
	Package  string
	Name     string
	Fields   *GoStructFields
	Methods  *GoStructMethods
	Comments string
	Imports  *GoFileImports
}

GoStruct represents a model struct

func NewGoStruct

func NewGoStruct() *GoStruct

NewGoStruct returns a new GoStruct

type GoStructField

type GoStructField struct {
	Name     string
	DataType string
	Tags     []*GoStructFieldTag
	Comments string
}

GoStructField is a field on a Model struct

func (*GoStructField) ToString

func (m *GoStructField) ToString() string

ToString returns a tring representation of a go struct field

type GoStructFieldTag

type GoStructFieldTag struct {
	Name    string
	Value   string
	Options []string
}

GoStructFieldTag is a tag on a field on a model struct

func (*GoStructFieldTag) ToString

func (t *GoStructFieldTag) ToString() string

ToString returns a string representation of a go struct field tag

type GoStructFields

type GoStructFields []*GoStructField

GoStructFields is a collection of a go struct fields

func (*GoStructFields) Append

func (i *GoStructFields) Append(m *GoStructField)

Append adds to the collection of imports

func (*GoStructFields) Get

func (i *GoStructFields) Get(idx int) *GoStructField

Get returns an import at an index

func (*GoStructFields) Len

func (i *GoStructFields) Len() int

Len returns the length of the collection of imports

type GoStructMethod

type GoStructMethod struct {
	Code string
	Docs []string
}

GoStructMethod is a method on a struct

type GoStructMethods

type GoStructMethods []*GoStructMethod

GoStructMethods is a collection of go methods on a struct

func (*GoStructMethods) Append

func (g *GoStructMethods) Append(m *GoStructMethod)

Append adds a new struct to the struct collection

func (*GoStructMethods) Get

func (g *GoStructMethods) Get(index int) (m *GoStructMethod)

Get gets a struct at index

func (*GoStructMethods) Len

func (g *GoStructMethods) Len() int

Len returns the number of methods

type Method

type Method struct {
	Code      string
	Documents []string
	LineNo    int
}

Method describes code and Documents for a method

func ParseStruct

func ParseStruct(src []byte, structName string, copyDocuments bool, copyTypeDocuments bool, pkgName string) (methods []Method, imports []string, typeDoc string)

ParseStruct parses a struct

func (*Method) Lines

func (m *Method) Lines() []string

Lines return a a slice of documentation and code

type Options

type Options uint

Options are the available runtime flags

type ParsedStruct added in v1.8.48

type ParsedStruct struct {
	Docs   []string
	Name   string
	Fields map[string]string
}

func ParseStruct2 added in v1.8.48

func ParseStruct2(filePath string) (*ParsedStruct, error)

type RoutesJSONContainer added in v1.8.23

type RoutesJSONContainer struct {
	Routes     map[string]*ControllerRoute  `json:"routes"`
	DTOs       map[string]map[string]string `json:"dtos"`
	Models     map[string]map[string]string `json:"models"`
	Aggregates map[string]map[string]string `json:"aggregates"`
	Constants  map[string][]string          `json:"constants"`
}

RoutesJSONContainer is a container for JSON Routes

Jump to

Keyboard shortcuts

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