Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate takes a cue.Value and generates the corresponding TypeScript for all top-level members of that value that have appropriate @cuetsy attributes.
Members that are definitions, hidden fields, or optional fields are ignored.
func NoImportMappingErr ¶
func NoImportMappingErr(d *ast.ImportDecl) error
NoImportMappingErr returns a standard error indicating that no mapping can be made for the provided import statement.
Types ¶
type Concreteness ¶
type Concreteness int
Concreteness is a measure of the level of concreteness of a value, where lower values mean more concrete.
Replicated from cuelang.org/internal/core/adt
const ( BottomLevel Concreteness = iota // Concrete indicates a concrete scalar value, list or struct. Concrete // Constraint indicates a non-concrete scalar value that is more specific, // than a top-level type. Constraint // Type indicates a top-level specific type, for instance, string, // bytes, number, or bool. Type // Any indicates any value, or top. Any )
type Config ¶
type Config struct {
// ImportMapper determines how CUE imports are mapped to Typescript imports.
// If nil, any non-stdlib import in the CUE source will result in a fatal
// error.
ImportMapper
}
Config governs certain variable behaviors when converting CUE to Typescript.
type ImportMapper ¶
type ImportMapper func(*ast.ImportDecl) (string, error)
An ImportMapper takes an ImportDecl and returns a string indicating the import statement that should be used in the corresponding typescript, or an error if no mapping can be made.
type NewConfig ¶
type NewConfig struct {
// Subpath is the path within the cue.Instance that cuetsy should treat as the
// root object to be rendered. Optional.
Subpath cue.Path
// Self indicates that, rather than rendering all the attribute-annotated
// children of provided instance, the instance itself should be rendered.
Self bool
// InjectCuetsyAttrs is an optional set of attribute bodies to be dynamically
// injected onto values as they're being rendered.
//
// The keys will be passed to cue.ParsePath(). The value will be treated as
// the body of a @cuetsy attribute (@cuetsy(<value>)) for values encountered at
// that path, relative to the root.
InjectCuetsyAttrs map[string]string
}
type TypeMapper ¶
type TypeMapper interface {
Value() cue.Value
Kind() cue.Kind
Concreteness() Concreteness
String() string
}
TypeMapper is a general interface to describe a mapping between cue.Value and typescript kinds and types. Will necessarily need to omit expressions.