Documentation
¶
Index ¶
- func AsGoTypeWithInlineSupport(e *DatatypeDef, parentGoName string, visitor *Visitor) string
- func EventNameAsGoStructName(e *EventSpec) string
- func NewVersionData(version string) *versionData
- func ProcessFile(target FileToGenerate, data interface{}) error
- func ProcessModules(modules []*Module, opts Opts) error
- func WriteTemplateFile(filename string, data interface{}, templateString string) error
- type ApplicationTypesDefinition
- type CommandFieldSpec
- type CommandSpec
- func (c *CommandSpec) AsGoStructName() string
- func (c *CommandSpec) CtorArgsForTypeScript() string
- func (c *CommandSpec) CustomFields() []CommandFieldSpec
- func (c *CommandSpec) FieldsForTypeScript(tplData *TplData) string
- func (c *CommandSpec) MakeValidation(module *Module) string
- func (c *CommandSpec) Validate(module *Module) error
- type CommandSpecFile
- type DatatypeDef
- type DatatypeDefField
- type DatatypeDefObjectField
- type DomainFile
- type EndpointDefinition
- type EnumDef
- type EventDefForTpl
- type EventFieldSpec
- type EventSpec
- type FileToGenerate
- type GoStruct
- type GoStructField
- type Imports
- type Module
- type NamedDatatypeDef
- type Opts
- type ProcessedStringEnum
- type ProcessedStringEnumMember
- type StringConstDef
- type TplData
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsGoTypeWithInlineSupport ¶
func AsGoTypeWithInlineSupport(e *DatatypeDef, parentGoName string, visitor *Visitor) string
func EventNameAsGoStructName ¶
func NewVersionData ¶
func NewVersionData(version string) *versionData
func ProcessFile ¶
func ProcessFile(target FileToGenerate, data interface{}) error
func ProcessModules ¶
func WriteTemplateFile ¶
Types ¶
type ApplicationTypesDefinition ¶
type ApplicationTypesDefinition struct {
StringConsts []StringConstDef `json:"stringConsts"`
Enums []EnumDef `json:"enums"`
Types []NamedDatatypeDef `json:"types"`
Endpoints []EndpointDefinition `json:"endpoints"`
}
func (*ApplicationTypesDefinition) EndpointsProducesAndConsumesTypescriptTypes ¶
func (a *ApplicationTypesDefinition) EndpointsProducesAndConsumesTypescriptTypes() []string
func (*ApplicationTypesDefinition) UniqueDatatypesFlattened ¶
func (a *ApplicationTypesDefinition) UniqueDatatypesFlattened() []*DatatypeDef
func (*ApplicationTypesDefinition) Validate ¶
func (a *ApplicationTypesDefinition) Validate() error
type CommandFieldSpec ¶
type CommandFieldSpec struct {
Key string `json:"key"`
Title string `json:"title"`
Type string `json:"type"`
Unit string `json:"unit"`
ValidationRegex string `json:"validation_regex"`
MaxLength *int `json:"max_length"`
Optional bool `json:"optional"`
HideIfDefaultValue bool `json:"hideIfDefaultValue"`
Help string `json:"help"`
Placeholder string `json:"placeholder"`
}
func (*CommandFieldSpec) AsGoType ¶
func (c *CommandFieldSpec) AsGoType(module *Module) string
func (*CommandFieldSpec) AsTsType ¶
func (c *CommandFieldSpec) AsTsType() string
func (*CommandFieldSpec) AsValidationSnippet ¶
func (c *CommandFieldSpec) AsValidationSnippet(module *Module) string
func (*CommandFieldSpec) Validate ¶
func (c *CommandFieldSpec) Validate(module *Module) error
type CommandSpec ¶
type CommandSpec struct {
Command string `json:"command"`
Title string `json:"title"`
CrudNature string `json:"crudNature"`
AdditionalConfirmation string `json:"additional_confirmation"`
MiddlewareChain string `json:"chain"`
CtorArgs []string `json:"ctor"`
Fields []*CommandFieldSpec `json:"fields"`
Info []string `json:"info"`
}
func (*CommandSpec) AsGoStructName ¶
func (c *CommandSpec) AsGoStructName() string
func (*CommandSpec) CtorArgsForTypeScript ¶
func (c *CommandSpec) CtorArgsForTypeScript() string
func (*CommandSpec) CustomFields ¶
func (c *CommandSpec) CustomFields() []CommandFieldSpec
func (*CommandSpec) FieldsForTypeScript ¶
func (c *CommandSpec) FieldsForTypeScript(tplData *TplData) string
func (*CommandSpec) MakeValidation ¶
func (c *CommandSpec) MakeValidation(module *Module) string
returns Go code (as a string) for validating command inputs
func (*CommandSpec) Validate ¶
func (c *CommandSpec) Validate(module *Module) error
type CommandSpecFile ¶
type CommandSpecFile []*CommandSpec
func (*CommandSpecFile) ImportedCustomFieldTypes ¶
func (c *CommandSpecFile) ImportedCustomFieldTypes() []string
func (*CommandSpecFile) Validate ¶
func (c *CommandSpecFile) Validate(module *Module) error
type DatatypeDef ¶
type DatatypeDef struct {
NameRaw string `json:"_"` // "Type" | "module.Type" if referring to another module (such as "domain")
Notes string `json:"notes"`
Nullable bool `json:"nullable"`
Of *DatatypeDef `json:"of"` // only used if Name==list
Fields map[string]*DatatypeDef `json:"fields"` // only used if Name==object
}
func (*DatatypeDef) AsGoType ¶
func (e *DatatypeDef) AsGoType() string
func (*DatatypeDef) AsTypeScriptType ¶
func (d *DatatypeDef) AsTypeScriptType() string
func (*DatatypeDef) FieldsSorted ¶
func (d *DatatypeDef) FieldsSorted() []DatatypeDefField
func (*DatatypeDef) ModuleId ¶
func (d *DatatypeDef) ModuleId() string
func (*DatatypeDef) Name ¶
func (d *DatatypeDef) Name() string
type DatatypeDefField ¶
type DatatypeDefField struct {
Key string
Type *DatatypeDef
}
type DatatypeDefObjectField ¶
type DatatypeDefObjectField struct {
Key string `json:"key"`
Type *DatatypeDef `json:"type"`
}
type DomainFile ¶
type DomainFile struct {
Events []*EventSpec `json:"events"`
}
type EndpointDefinition ¶
type EndpointDefinition struct {
Path string `json:"path"`
HttpMethod string `json:"method"`
Name string `json:"name"`
MiddlewareChain string `json:"chain"`
Description string `json:"description"`
Produces *DatatypeDef `json:"produces"` // optional
Consumes *DatatypeDef `json:"consumes"` // optional
}
func (*EndpointDefinition) GoArgs ¶
func (e *EndpointDefinition) GoArgs() string
"/users/{id}/addresses/{idx}" => "id string, idx string"
func (*EndpointDefinition) GoPath ¶
func (e *EndpointDefinition) GoPath() string
FIXME: URL escaping "/users/{id}" => "/users/"+id+"" "/search?q={query}" => "/search?query="+query+""
func (*EndpointDefinition) TypescriptArgs ¶
func (e *EndpointDefinition) TypescriptArgs() string
"/users/{id}/addresses/{idx}" => "id: string, idx: string"
func (*EndpointDefinition) TypescriptPath ¶
func (e *EndpointDefinition) TypescriptPath() string
"/users/{id}" => "/users/${encodeURIComponent(id)}" "/search?q={query}" => "/search?query=${encodeURIComponent(query)}"
type EventDefForTpl ¶
type EventDefForTpl struct {
EventKey string
CtorArgs string
CtorAssignments string
GoStructName string
}
func ProcessEvents ¶
func ProcessEvents(file *DomainFile) ([]EventDefForTpl, string)
type EventFieldSpec ¶
type EventFieldSpec struct {
Key string `json:"key"`
Type DatatypeDef `json:"type"`
Notes string `json:"notes"`
}
type EventSpec ¶
type EventSpec struct {
Event string `json:"event"`
CtorArgs []string `json:"ctor"`
Changelog []string `json:"changelog"`
Fields []*EventFieldSpec `json:"fields"`
}
type FileToGenerate ¶
type FileToGenerate struct {
// contains filtered or unexported fields
}
func CompanionFile ¶
func CompanionFile(targetPath string) FileToGenerate
companion file means that for each of these files their corresponding .template file exists and will be rendered which will end up as the filename given
func Inline ¶
func Inline(targetPath string, inline string) FileToGenerate
type GoStruct ¶
type GoStruct struct {
Name string
Fields []GoStructField
}
func VisitForGoStructs ¶
func (*GoStruct) Field ¶
func (g *GoStruct) Field(name string) *GoStructField
type GoStructField ¶
func (*GoStructField) AsGoCode ¶
func (g *GoStructField) AsGoCode() string
type Imports ¶
type Imports struct {
// native types
Date bool
DateTime bool
Binary bool
ModuleIds []string // other modules whose types this module's types have dependencies to
}
func NewImports ¶
func NewImports() Imports
type Module ¶
type Module struct {
// config
Id string // "vstotypes"
Path string // "vstoserver/vstotypes"
// input files
EventsSpecFile string
CommandsSpecFile string
TypesFile string
UiRoutesFile string
// computed state
Events *DomainFile
Types *ApplicationTypesDefinition
Commands *CommandSpecFile
UiRoutes []uiRouteSpec
}
type NamedDatatypeDef ¶
type NamedDatatypeDef struct {
Name string `json:"name"`
Type *DatatypeDef `json:"type"`
}
func (*NamedDatatypeDef) AsToGoCode ¶
func (s *NamedDatatypeDef) AsToGoCode() string
func (*NamedDatatypeDef) AsTypeScriptCode ¶
func (s *NamedDatatypeDef) AsTypeScriptCode() string
type ProcessedStringEnum ¶
type ProcessedStringEnum struct {
Name string
MembersDigest string
Members []ProcessedStringEnumMember
}
func ProcessStringEnums ¶
func ProcessStringEnums(enums []EnumDef) []ProcessedStringEnum
type StringConstDef ¶
type TplData ¶
type TplData struct {
Module *Module
Opts Opts
AnyEndpointHasConsumes bool
TypesImports Imports
CommandsImports Imports
CommandsImportsUi Imports // UI only needs types that are mentioned in ctor
EventsImports Imports
StringEnums []ProcessedStringEnum
EventStructsAsGoCode string
EventDefs []EventDefForTpl
}
this is passed as data to each template that we'll render
Source Files
¶
Click to show internal directories.
Click to hide internal directories.