github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/cmd/vpm/types.go (about)

     1  /*
     2   * Copyright (c) 2023-present unTill Pro, Ltd.
     3   * @author Alisher Nurmanov
     4   */
     5  
     6  package main
     7  
     8  type vpmParams struct {
     9  	Dir         string
    10  	TargetDir   string
    11  	IgnoreFile  string
    12  	HeaderFile  string
    13  	PackagePath string
    14  	Output     string
    15  }
    16  
    17  // packageFiles is a map of package name to a list of files that belong to the package
    18  type packageFiles map[string][]string
    19  
    20  // baselineInfo is a struct that is saved to baseline.json file
    21  type baselineInfo struct {
    22  	BaselinePackageUrl string
    23  	Timestamp          string
    24  	GitCommitHash      string `json:",omitempty"`
    25  }
    26  
    27  type ignoreInfo struct {
    28  	Ignore []string `yaml:"Ignore"`
    29  }
    30  
    31  // types for ORM generating
    32  type ormPackageInfo struct {
    33  	Name              string
    34  	FullPath          string
    35  	HeaderFileContent string
    36  }
    37  
    38  type ormPackage struct {
    39  	ormPackageInfo
    40  	Items []interface{}
    41  }
    42  
    43  type ormPackageItem struct {
    44  	Package   ormPackageInfo
    45  	QName     string
    46  	TypeQName string
    47  	Name      string
    48  	Type      string
    49  	// TODO: find a way to extract sql-code of the package item from parser/appdef
    50  	SqlContent string
    51  }
    52  
    53  type ormTableItem struct {
    54  	ormPackageItem
    55  	Fields       []ormField
    56  	Keys         []ormField
    57  	NonKeyFields []ormField
    58  }
    59  
    60  type ormCommand struct {
    61  	ormPackageItem
    62  	ArgumentObject         interface{}
    63  	UnloggedArgumentObject interface{}
    64  	ResultObjectFields     []ormField
    65  }
    66  
    67  func getQName(obj interface{}) string {
    68  	switch t := obj.(type) {
    69  	case ormPackageItem:
    70  		return t.QName
    71  	case ormTableItem:
    72  		return t.QName
    73  	case ormCommand:
    74  		return t.QName
    75  	default:
    76  		panic("unknown type")
    77  	}
    78  }
    79  
    80  type ormField struct {
    81  	Table         ormTableItem
    82  	Type          string
    83  	Name          string
    84  	GetMethodName string
    85  	SetMethodName string
    86  }