clientgen

package
v1.43.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package clientgen generates code for use with Encore apps.

Index

Constants

View Source
const (
	// GoInitial is the originally released Go client generator
	GoInitial goGenVersion = iota

	// GoExperimental can be used to lock experimental or uncompleted features in the generated code
	// It should always be the last item in the enum
	GoExperimental
)
View Source
const (
	// JsInitial is the originally released javascript generator
	JsInitial jsGenVersion = iota

	// JsExperimental can be used to lock experimental or uncompleted features in the generated code
	// It should always be the last item in the enum
	JsExperimental
)
View Source
const (
	InOut streamDirection = iota
	In
	Out
)
View Source
const (
	// TsInitial is the originally released typescript generator
	TsInitial tsGenVersion = iota

	// TsExperimental can be used to lock experimental or uncompleted features in the generated code
	// It should always be the last item in the enum
	TsExperimental
)

Variables

View Source
var ErrUnknownLang = errors.New("unknown language")

ErrUnknownLang is reported by Generate when the language is not known.

Functions

func Client

func Client(
	lang Lang,
	appSlug string,
	md *meta.Data,
	services clientgentypes.ServiceSet,
	tags clientgentypes.TagSet,
	opts clientgentypes.Options,
) (code []byte, err error)

Client generates an API client based on the given app metadata. ServiceNames are the services to include in the output. If it's nil, all services are included.

func GenTypes added in v1.35.3

func GenTypes(md *meta.Data, typs ...*schema.Decl) ([]byte, error)

Types

type ErrCode

type ErrCode struct {
	Name           string
	Comment        string
	HttpStatusCode int
}

type FileStatement added in v1.35.3

type FileStatement interface {
	Comment(string) *Statement
	Line() *Statement
	Type() *Statement
}

FileStatement is an interface implemented by both jen.File and jen.Statement

type Lang

type Lang string

Lang represents a programming language or dialect that we support generating code for.

const (
	LangUnknown    Lang = ""
	LangTypeScript Lang = "typescript"
	LangJavascript Lang = "javascript"
	LangGo         Lang = "go"
	LangOpenAPI    Lang = "openapi"
)

These constants represent supported languages.

func Detect

func Detect(path string) (lang Lang, ok bool)

Detect attempts to detect the language from the given filename.

func GetLang

func GetLang(lang string) (Lang, error)

GetLang returns the language specified by the given string, allowing for case insensitivity and common aliases.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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