Documentation
¶
Index ¶
- Variables
- func DataToJSONSchema(schema *Schema, dataRef DataRef) (*jsonschema.Schema, error)
- func Normalise[T Node](n T) T
- func ProtobufSchema() string
- func ValidateModule(module *Module) error
- func Visit(n Node, visit func(n Node, next func() error) error) error
- type Array
- type Bool
- type Bytes
- type Data
- type DataRef
- type Decl
- type Field
- type Float
- type IngressPathComponent
- type IngressPathLiteral
- type IngressPathParameter
- type Int
- type Map
- type Metadata
- type MetadataCalls
- type MetadataIngress
- type Module
- type Node
- type Optional
- type Position
- type Ref
- type Schema
- func (s *Schema) DataMap() map[DataRef]*Data
- func (s *Schema) Hash() [sha256.Size]byte
- func (s *Schema) Module(name string) types.Option[*Module]
- func (s *Schema) ResolveDataRef(ref *DataRef) *Data
- func (s *Schema) ResolveVerbRef(ref *VerbRef) *Verb
- func (s *Schema) String() string
- func (s *Schema) ToProto() proto.Message
- func (s *Schema) Upsert(module *Module)
- type String
- type Time
- type Type
- type Verb
- type VerbRef
Constants ¶
This section is empty.
Variables ¶
var ( // BuiltinsSource is the schema source code for built-in types. BuiltinsSource = `` /* 428-byte string literal not displayed */ )
Functions ¶
func DataToJSONSchema ¶ added in v0.1.1
DataToJSONSchema converts the schema for a Data object to a JSON Schema.
It takes in the full schema in order to resolve and define references.
func Normalise ¶
func Normalise[T Node](n T) T
Normalise clones and normalises (zeroes) positional information in schema Nodes.
func ProtobufSchema ¶
func ProtobufSchema() string
ProtobufSchema returns a string containing the equivalent protobuf schema for the FTL schema.
func ValidateModule ¶
ValidateModule performs the subset of semantic validation possible on a single module.
Types ¶
type Array ¶
type Bool ¶
type Bytes ¶ added in v0.88.0
type Data ¶
type Data struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"5"` Name string `parser:"'data' @Ident '{'" protobuf:"2"` Fields []*Field `parser:"@@* '}'" protobuf:"3"` Metadata []Metadata `parser:"@@*" protobuf:"4"` }
A Data structure.
func DataToSchema ¶
type Field ¶
type Float ¶
type IngressPathComponent ¶ added in v0.85.5
type IngressPathComponent interface { Node // contains filtered or unexported methods }
type IngressPathLiteral ¶ added in v0.85.5
type IngressPathLiteral struct { Pos Position `parser:"" protobuf:"1,optional"` Text string `parser:"@Ident" protobuf:"2"` }
func (*IngressPathLiteral) String ¶ added in v0.85.5
func (l *IngressPathLiteral) String() string
func (*IngressPathLiteral) ToProto ¶ added in v0.85.5
func (l *IngressPathLiteral) ToProto() proto.Message
type IngressPathParameter ¶ added in v0.85.5
type IngressPathParameter struct { Pos Position `parser:"" protobuf:"1,optional"` Name string `parser:"'{' @Ident '}'" protobuf:"2"` }
func (*IngressPathParameter) String ¶ added in v0.85.5
func (l *IngressPathParameter) String() string
func (*IngressPathParameter) ToProto ¶ added in v0.85.5
func (l *IngressPathParameter) ToProto() proto.Message
type Int ¶
type Map ¶
type MetadataCalls ¶
type MetadataCalls struct { Pos Position `parser:"" protobuf:"1,optional"` Calls []*VerbRef `parser:"'calls' @@ (',' @@)*" protobuf:"2"` }
func (*MetadataCalls) String ¶
func (m *MetadataCalls) String() string
func (*MetadataCalls) ToProto ¶
func (m *MetadataCalls) ToProto() proto.Message
type MetadataIngress ¶
type MetadataIngress struct { Pos Position `parser:"" protobuf:"1,optional"` Type string `parser:"'ingress' @('http' | 'ftl')" protobuf:"2"` Method string `parser:"@('GET' | 'POST' | 'PUT' | 'DELETE')" protobuf:"3"` Path []IngressPathComponent `parser:"('/' @@)+" protobuf:"4"` }
func (*MetadataIngress) String ¶
func (m *MetadataIngress) String() string
func (*MetadataIngress) ToProto ¶
func (m *MetadataIngress) ToProto() proto.Message
type Module ¶
type Module struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"2"` Builtin bool `parser:"@'builtin'?" protobuf:"3"` Name string `parser:"'module' @Ident '{'" protobuf:"4"` Decls []Decl `parser:"@@* '}'" protobuf:"5"` }
func Builtins ¶ added in v0.89.0
func Builtins() *Module
Builtins returns a Module containing built-in types.
func ModuleFromBytes ¶
func ModuleFromProto ¶
ModuleFromProto converts a protobuf Module to a Module and validates it.
func ParseModuleString ¶
type Node ¶
type Node interface { String() string ToProto() proto.Message // contains filtered or unexported methods }
A Node in the schema grammar.
type Optional ¶ added in v0.78.0
type Optional struct { Pos Position `parser:"" protobuf:"1,optional"` Type Type `parser:"@@" protobuf:"2,optional"` }
Optional represents a Type whose value may be optional.
type Position ¶
type Ref ¶
type Ref struct { Pos Position `parser:"" protobuf:"1,optional"` Module string `parser:"(@Ident '.')?" protobuf:"3"` Name string `parser:"@Ident" protobuf:"2"` }
Ref is a reference to another symbol.
type Schema ¶
type Schema struct { Pos Position `parser:"" protobuf:"1,optional"` Modules []*Module `parser:"@@*" protobuf:"2"` }
func MustValidate ¶ added in v0.89.0
MustValidate panics if a schema is invalid.
This is useful for testing.
func ParseString ¶
func (*Schema) ResolveDataRef ¶ added in v0.80.0
func (*Schema) ResolveVerbRef ¶ added in v0.80.0
type String ¶
type Time ¶
type Type ¶
type Type interface { Node // contains filtered or unexported methods }
Type represents a Type Node in the schema grammar.
type Verb ¶
type Verb struct { Pos Position `parser:"" protobuf:"1,optional"` Comments []string `parser:"@Comment*" protobuf:"3"` Name string `parser:"'verb' @Ident" protobuf:"2"` Request *DataRef `parser:"'(' @@ ')'" protobuf:"4"` Response *DataRef `parser:"@@" protobuf:"5"` Metadata []Metadata `parser:"@@*" protobuf:"6"` }
func VerbToSchema ¶
func (*Verb) GetMetadataIngress ¶ added in v0.91.0
func (v *Verb) GetMetadataIngress() types.Option[*MetadataIngress]