Documentation ¶
Index ¶
- func FieldName(opt *TSOption) func(name string) string
- func FunctionCase_TSProto(s string) string
- func GetModuleName(file protoreflect.FileDescriptor) string
- func JSONCamelCase(s string) string
- func JsonFieldName(opt *TSOption) func(name string) string
- func TSProtoEnumToJson(enumTyp *protogen.Enum) func(g *TSRegistry, in string) string
- func TSProtoFieldMaskToJson(msgTyp *protogen.Message) func(g *TSRegistry, in string) string
- func TSProtoFieldToJson(field *protogen.Field) func(g *TSRegistry, in string) string
- func TSProtoMessageToJson(msgTyp *protogen.Message) func(g *TSRegistry, in string) string
- func TSProtoScalarToJson() func(g *TSRegistry, in string) string
- func TSProtoTimestampToJson() func(g *TSRegistry, in string) string
- func TSProto_EnumToJSONFuncName(g *TSRegistry, enum protoreflect.EnumDescriptor) string
- type TSIdent
- type TSModule
- type TSOption
- type TSRegistry
- func (g *TSRegistry) Apply(w io.Writer) error
- func (g *TSRegistry) ImportSegments() string
- func (g *TSRegistry) P(v ...any)
- func (opt *TSRegistry) PComment(comments ...string)
- func (opt *TSRegistry) PCommentf(format string, args ...interface{})
- func (opt *TSRegistry) PTmpl(tmpl *template.Template, data interface{}, funcs ...template.FuncMap)
- func (opt *TSRegistry) PTmplStr(tmpl string, data interface{}, funcs ...template.FuncMap)
- func (opt *TSRegistry) Pf(format string, v ...any)
- func (r *TSRegistry) QualifiedTSIdent(ident TSIdent) string
- func (r *TSRegistry) ServiceFmap() template.FuncMap
- func (r *TSRegistry) TsType(def *protogen.Message, location protogen.Location) string
- func (g *TSRegistry) Write(p []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetModuleName ¶
func GetModuleName(file protoreflect.FileDescriptor) string
GetModuleName returns module name = package name + base file name to be the unique identifier for source file in a ts file. Package name and base file name are converted to camel case, special characters like dot, dash and underscore are removed. packageName: memos.api.v1 fileName: memos.proto
func JSONCamelCase ¶
JSONCamelCase converts a snake_case identifier to a camelCase identifier, according to the protobuf JSON specification.
Copied from: google.golang.org/protobuf/internal/strs.
func JsonFieldName ¶ added in v1.0.24
func TSProtoEnumToJson ¶
func TSProtoEnumToJson(enumTyp *protogen.Enum) func(g *TSRegistry, in string) string
func TSProtoFieldMaskToJson ¶
func TSProtoFieldMaskToJson(msgTyp *protogen.Message) func(g *TSRegistry, in string) string
func TSProtoFieldToJson ¶
func TSProtoFieldToJson(field *protogen.Field) func(g *TSRegistry, in string) string
func TSProtoMessageToJson ¶
func TSProtoMessageToJson(msgTyp *protogen.Message) func(g *TSRegistry, in string) string
func TSProtoScalarToJson ¶
func TSProtoScalarToJson() func(g *TSRegistry, in string) string
func TSProtoTimestampToJson ¶
func TSProtoTimestampToJson() func(g *TSRegistry, in string) string
func TSProto_EnumToJSONFuncName ¶
func TSProto_EnumToJSONFuncName(g *TSRegistry, enum protoreflect.EnumDescriptor) string
Types ¶
type TSIdent ¶
func TSIdent_TSProto_Message ¶
type TSModule ¶
type TSModule struct { ModuleName string Path string // path relative to the generate root, or the absolute path Relative bool // whether the path is relative to the current file }
func TSModule_TSProto ¶
func TSModule_TSProto(file protoreflect.FileDescriptor) TSModule
type TSRegistry ¶
type TSRegistry struct { GenOpts pluginutils.GenerateOptions ImportIdents map[string][]TSIdent // map<module_path, TSIdent> // contains filtered or unexported fields }
func NewTSRegistry ¶
func NewTSRegistry(opts pluginutils.GenerateOptions) *TSRegistry
func (*TSRegistry) ImportSegments ¶
func (g *TSRegistry) ImportSegments() string
func (*TSRegistry) P ¶
func (g *TSRegistry) P(v ...any)
func (*TSRegistry) PComment ¶
func (opt *TSRegistry) PComment(comments ...string)
PComment allows multiple lines string as comment.
func (*TSRegistry) PCommentf ¶
func (opt *TSRegistry) PCommentf(format string, args ...interface{})
PCommentf allows formatted string as comment.
func (*TSRegistry) PTmpl ¶
func (opt *TSRegistry) PTmpl(tmpl *template.Template, data interface{}, funcs ...template.FuncMap)
func (*TSRegistry) PTmplStr ¶
func (opt *TSRegistry) PTmplStr(tmpl string, data interface{}, funcs ...template.FuncMap)
func (*TSRegistry) Pf ¶
func (opt *TSRegistry) Pf(format string, v ...any)
Pf is same as P, but with formatted string.
func (*TSRegistry) QualifiedTSIdent ¶
func (r *TSRegistry) QualifiedTSIdent(ident TSIdent) string
func (*TSRegistry) ServiceFmap ¶
func (r *TSRegistry) ServiceFmap() template.FuncMap
ServiceTemplate gets the template for the primary typescript file.