Documentation ¶
Index ¶
- Constants
- func EncodeOptions(starlarkOptions starlark.Value) (string, error)
- func LoadModule() (starlark.StringDict, error)
- type Dropdown
- func (s *Dropdown) AsSchemaField() SchemaField
- func (s *Dropdown) Attr(name string) (starlark.Value, error)
- func (s *Dropdown) AttrNames() []string
- func (s *Dropdown) Freeze()
- func (s *Dropdown) Hash() (uint32, error)
- func (s *Dropdown) String() string
- func (s *Dropdown) Truth() starlark.Bool
- func (s *Dropdown) Type() string
- type Field
- type HandlerReturnType
- type Location
- func (s *Location) AsSchemaField() SchemaField
- func (s *Location) Attr(name string) (starlark.Value, error)
- func (s *Location) AttrNames() []string
- func (s *Location) Freeze()
- func (s *Location) Hash() (uint32, error)
- func (s *Location) String() string
- func (s *Location) Truth() starlark.Bool
- func (s *Location) Type() string
- type Option
- func (s *Option) AsSchemaOption() SchemaOption
- func (s *Option) Attr(name string) (starlark.Value, error)
- func (s *Option) AttrNames() []string
- func (s *Option) Freeze()
- func (s *Option) Hash() (uint32, error)
- func (s *Option) String() string
- func (s *Option) Truth() starlark.Bool
- func (s *Option) Type() string
- type Schema
- type SchemaField
- type SchemaHandler
- type SchemaOption
- type SchemaVisibility
- type StarlarkSchema
- func (s StarlarkSchema) Attr(name string) (starlark.Value, error)
- func (s StarlarkSchema) AttrNames() []string
- func (s StarlarkSchema) Freeze()
- func (s StarlarkSchema) Hash() (uint32, error)
- func (s StarlarkSchema) String() string
- func (s StarlarkSchema) Truth() starlark.Bool
- func (s StarlarkSchema) Type() string
- type Text
- type Toggle
- func (s *Toggle) AsSchemaField() SchemaField
- func (s *Toggle) Attr(name string) (starlark.Value, error)
- func (s *Toggle) AttrNames() []string
- func (s *Toggle) Freeze()
- func (s *Toggle) Hash() (uint32, error)
- func (s *Toggle) String() string
- func (s *Toggle) Truth() starlark.Bool
- func (s *Toggle) Type() string
Constants ¶
const (
ModuleName = "schema"
)
const ( // SchemaFunctionName is the name of the function in Starlark that we expect // to be able to call to get the schema for an applet. SchemaFunctionName = "get_schema" )
Variables ¶
This section is empty.
Functions ¶
func EncodeOptions ¶
Encodes a list of schema options into validated json.
func LoadModule ¶
func LoadModule() (starlark.StringDict, error)
Types ¶
type Dropdown ¶
type Dropdown struct { SchemaField // contains filtered or unexported fields }
func (*Dropdown) AsSchemaField ¶
func (s *Dropdown) AsSchemaField() SchemaField
type Field ¶
type Field interface {
AsSchemaField() SchemaField
}
type HandlerReturnType ¶
type HandlerReturnType int8
HandlerReturnType defines an enum for the type of information we expect to get back from the schema function.
const ( ReturnSchema HandlerReturnType = iota ReturnOptions ReturnString ReturnField )
type Location ¶
type Location struct {
SchemaField
}
func (*Location) AsSchemaField ¶
func (s *Location) AsSchemaField() SchemaField
type Option ¶
type Option struct {
SchemaOption
}
func (*Option) AsSchemaOption ¶
func (s *Option) AsSchemaOption() SchemaOption
type Schema ¶
type Schema struct { Version string `json:"version" validate:"required"` Fields []SchemaField `json:"schema" validate:"required,dive"` Handlers map[string]SchemaHandler `json:"-"` // contains filtered or unexported fields }
Schema holds a configuration object for an applet. It holds a list of fileds that are exported from an applet.
func FromStarlark ¶ added in v0.11.1
FromStarlark creates a new Schema from a Starlark schema object.
func (*Schema) Field ¶ added in v0.11.1
func (s *Schema) Field(id string) *SchemaField
Field returns a pointer to the schema field with the given ID, or nil if it doesn't exist.
type SchemaField ¶
type SchemaField struct { Type string `` /* 133-byte string literal not displayed */ ID string `json:"id" validate:"required"` Name string `json:"name,omitempty" validate:"required_for=datetime dropdown location locationbased onoff radio text typeahead png"` Description string `json:"description,omitempty"` Icon string `json:"icon,omitempty" validate:"forbidden_for=generated"` Visibility *SchemaVisibility `json:"visibility,omitempty" validate:"omitempty,dive"` Default string `json:"default,omitempty" validate:"required_for=dropdown onoff radio"` Options []SchemaOption `json:"options,omitempty" validate:"required_for=dropdown radio,dive"` Source string `json:"source,omitempty" validate:"required_for=generated"` Handler string `json:"handler,omitempty" validate:"required_for=generated locationbased typeahead oauth2"` ClientID string `json:"client_id,omitempty" validate:"required_for=oauth2"` AuthorizationEndpoint string `json:"authorization_endpoint,omitempty" validate:"required_for=oauth2"` Scopes []string `json:"scopes,omitempty" validate:"required_for=oauth2"` }
SchemaField represents an item in the config used to confgure an applet.
type SchemaHandler ¶
type SchemaHandler struct { Function *starlark.Function ReturnType HandlerReturnType }
SchemaHandler defines a function and and return type for getting the schema for an applet. This can both be the predefined schema function we expect all applets to have for config, but can also be used as a callback for
type SchemaOption ¶
type SchemaOption struct { Text string `json:"text" validate:"required"` Value string `json:"value" validate:"required"` }
SchemaOption represents an option in a field. For example, an item in a drop down menu.
type SchemaVisibility ¶
type SchemaVisibility struct { Type string `json:"type" validate:"required,oneof=invisible disabled"` Condition string `json:"condition" validate:"required,oneof=equal not_equal"` Variable string `json:"variable" validate:"required"` Value string `json:"value"` }
SchemaVisibility enables conditional fields inside of the mobile app. For example, if a field should be invisible until a login is provided.
type StarlarkSchema ¶
type StarlarkSchema struct { Schema // contains filtered or unexported fields }
func (StarlarkSchema) AttrNames ¶
func (s StarlarkSchema) AttrNames() []string
func (StarlarkSchema) Freeze ¶
func (s StarlarkSchema) Freeze()
func (StarlarkSchema) Hash ¶
func (s StarlarkSchema) Hash() (uint32, error)
func (StarlarkSchema) String ¶
func (s StarlarkSchema) String() string
func (StarlarkSchema) Truth ¶
func (s StarlarkSchema) Truth() starlark.Bool
func (StarlarkSchema) Type ¶
func (s StarlarkSchema) Type() string
type Text ¶ added in v0.10.1
type Text struct {
SchemaField
}
func (*Text) AsSchemaField ¶ added in v0.10.1
func (s *Text) AsSchemaField() SchemaField
type Toggle ¶
type Toggle struct {
SchemaField
}
func (*Toggle) AsSchemaField ¶
func (s *Toggle) AsSchemaField() SchemaField