Documentation ¶
Index ¶
- Constants
- func EncodeOptions(starlarkOptions starlark.Value) (string, error)
- func LoadModule() (starlark.StringDict, error)
- type Color
- func (s *Color) AsSchemaField() SchemaField
- func (s *Color) Attr(name string) (starlark.Value, error)
- func (s *Color) AttrNames() []string
- func (s *Color) Freeze()
- func (s *Color) Hash() (uint32, error)
- func (s *Color) String() string
- func (s *Color) Truth() starlark.Bool
- func (s *Color) Type() string
- type DateTime
- func (s *DateTime) AsSchemaField() SchemaField
- func (s *DateTime) Attr(name string) (starlark.Value, error)
- func (s *DateTime) AttrNames() []string
- func (s *DateTime) Freeze()
- func (s *DateTime) Hash() (uint32, error)
- func (s *DateTime) String() string
- func (s *DateTime) Truth() starlark.Bool
- func (s *DateTime) Type() string
- 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 Generated
- func (s *Generated) AsSchemaField() SchemaField
- func (s *Generated) Attr(name string) (starlark.Value, error)
- func (s *Generated) AttrNames() []string
- func (s *Generated) Freeze()
- func (s *Generated) Hash() (uint32, error)
- func (s *Generated) String() string
- func (s *Generated) Truth() starlark.Bool
- func (s *Generated) Type() string
- type Handler
- func (s *Handler) AsSchemaHandler() SchemaHandler
- func (s *Handler) Attr(name string) (starlark.Value, error)
- func (s *Handler) AttrNames() []string
- func (s *Handler) Freeze()
- func (s *Handler) Hash() (uint32, error)
- func (s *Handler) String() string
- func (s *Handler) Truth() starlark.Bool
- func (s *Handler) Type() string
- 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 LocationBased
- func (s *LocationBased) AsSchemaField() SchemaField
- func (s *LocationBased) Attr(name string) (starlark.Value, error)
- func (s *LocationBased) AttrNames() []string
- func (s *LocationBased) Freeze()
- func (s *LocationBased) Hash() (uint32, error)
- func (s *LocationBased) String() string
- func (s *LocationBased) Truth() starlark.Bool
- func (s *LocationBased) Type() string
- type Notification
- func (s *Notification) AsSchemaField() SchemaField
- func (s *Notification) Attr(name string) (starlark.Value, error)
- func (s *Notification) AttrNames() []string
- func (s *Notification) Freeze()
- func (s *Notification) Hash() (uint32, error)
- func (s *Notification) String() string
- func (s *Notification) Truth() starlark.Bool
- func (s *Notification) Type() string
- type OAuth2
- func (s *OAuth2) AsSchemaField() SchemaField
- func (s *OAuth2) Attr(name string) (starlark.Value, error)
- func (s *OAuth2) AttrNames() []string
- func (s *OAuth2) Freeze()
- func (s *OAuth2) Hash() (uint32, error)
- func (s *OAuth2) String() string
- func (s *OAuth2) Truth() starlark.Bool
- func (s *OAuth2) 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 PhotoSelect
- func (s *PhotoSelect) AsSchemaField() SchemaField
- func (s *PhotoSelect) Attr(name string) (starlark.Value, error)
- func (s *PhotoSelect) AttrNames() []string
- func (s *PhotoSelect) Freeze()
- func (s *PhotoSelect) Hash() (uint32, error)
- func (s *PhotoSelect) String() string
- func (s *PhotoSelect) Truth() starlark.Bool
- func (s *PhotoSelect) Type() string
- type Schema
- type SchemaField
- type SchemaHandler
- type SchemaOption
- type SchemaSound
- type SchemaVisibility
- type Sound
- func (s *Sound) AsSchemaSound() SchemaSound
- func (s *Sound) Attr(name string) (starlark.Value, error)
- func (s *Sound) AttrNames() []string
- func (s *Sound) Freeze()
- func (s *Sound) Hash() (uint32, error)
- func (s *Sound) String() string
- func (s *Sound) Truth() starlark.Bool
- func (s *Sound) Type() string
- 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
- type Typeahead
- func (s *Typeahead) AsSchemaField() SchemaField
- func (s *Typeahead) Attr(name string) (starlark.Value, error)
- func (s *Typeahead) AttrNames() []string
- func (s *Typeahead) Freeze()
- func (s *Typeahead) Hash() (uint32, error)
- func (s *Typeahead) String() string
- func (s *Typeahead) Truth() starlark.Bool
- func (s *Typeahead) 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 Color ¶ added in v0.24.7
type Color struct { SchemaField // contains filtered or unexported fields }
func (*Color) AsSchemaField ¶ added in v0.24.7
func (s *Color) AsSchemaField() SchemaField
type DateTime ¶ added in v0.14.0
type DateTime struct {
SchemaField
}
func (*DateTime) AsSchemaField ¶ added in v0.14.0
func (s *DateTime) AsSchemaField() SchemaField
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 Generated ¶ added in v0.16.2
type Generated struct {
SchemaField
}
func (*Generated) AsSchemaField ¶ added in v0.16.2
func (s *Generated) AsSchemaField() SchemaField
type Handler ¶ added in v0.16.1
type Handler struct {
SchemaHandler
}
func (*Handler) AsSchemaHandler ¶ added in v0.16.1
func (s *Handler) AsSchemaHandler() SchemaHandler
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 LocationBased ¶ added in v0.14.0
type LocationBased struct {
SchemaField
}
func (*LocationBased) AsSchemaField ¶ added in v0.14.0
func (s *LocationBased) AsSchemaField() SchemaField
func (*LocationBased) Attr ¶ added in v0.14.0
func (s *LocationBased) Attr(name string) (starlark.Value, error)
func (*LocationBased) AttrNames ¶ added in v0.14.0
func (s *LocationBased) AttrNames() []string
func (*LocationBased) Freeze ¶ added in v0.14.0
func (s *LocationBased) Freeze()
func (*LocationBased) Hash ¶ added in v0.14.0
func (s *LocationBased) Hash() (uint32, error)
func (*LocationBased) String ¶ added in v0.14.0
func (s *LocationBased) String() string
func (*LocationBased) Truth ¶ added in v0.14.0
func (s *LocationBased) Truth() starlark.Bool
func (*LocationBased) Type ¶ added in v0.14.0
func (s *LocationBased) Type() string
type Notification ¶ added in v0.32.7
type Notification struct { SchemaField Builder *starlark.Function `json:"-"` // contains filtered or unexported fields }
func (*Notification) AsSchemaField ¶ added in v0.32.7
func (s *Notification) AsSchemaField() SchemaField
func (*Notification) Attr ¶ added in v0.32.7
func (s *Notification) Attr(name string) (starlark.Value, error)
func (*Notification) AttrNames ¶ added in v0.32.7
func (s *Notification) AttrNames() []string
func (*Notification) Freeze ¶ added in v0.32.7
func (s *Notification) Freeze()
func (*Notification) Hash ¶ added in v0.32.7
func (s *Notification) Hash() (uint32, error)
func (*Notification) String ¶ added in v0.32.7
func (s *Notification) String() string
func (*Notification) Truth ¶ added in v0.32.7
func (s *Notification) Truth() starlark.Bool
func (*Notification) Type ¶ added in v0.32.7
func (s *Notification) Type() string
type OAuth2 ¶ added in v0.14.0
type OAuth2 struct { SchemaField // contains filtered or unexported fields }
func (*OAuth2) AsSchemaField ¶ added in v0.14.0
func (s *OAuth2) AsSchemaField() SchemaField
type Option ¶
type Option struct {
SchemaOption
}
func (*Option) AsSchemaOption ¶
func (s *Option) AsSchemaOption() SchemaOption
type PhotoSelect ¶ added in v0.14.0
type PhotoSelect struct {
SchemaField
}
func (*PhotoSelect) AsSchemaField ¶ added in v0.14.0
func (s *PhotoSelect) AsSchemaField() SchemaField
func (*PhotoSelect) Attr ¶ added in v0.14.0
func (s *PhotoSelect) Attr(name string) (starlark.Value, error)
func (*PhotoSelect) AttrNames ¶ added in v0.14.0
func (s *PhotoSelect) AttrNames() []string
func (*PhotoSelect) Freeze ¶ added in v0.14.0
func (s *PhotoSelect) Freeze()
func (*PhotoSelect) Hash ¶ added in v0.14.0
func (s *PhotoSelect) Hash() (uint32, error)
func (*PhotoSelect) String ¶ added in v0.14.0
func (s *PhotoSelect) String() string
func (*PhotoSelect) Truth ¶ added in v0.14.0
func (s *PhotoSelect) Truth() starlark.Bool
func (*PhotoSelect) Type ¶ added in v0.14.0
func (s *PhotoSelect) Type() string
type Schema ¶
type Schema struct { Version string `json:"version" validate:"required"` Fields []SchemaField `json:"schema" validate:"dive"` Notifications []Notification `json:"notifications,omitempty" validate:"dive"` Handlers map[string]SchemaHandler `json:"-"` }
Schema holds a configuration object for an applet. It holds a list of fields 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) MarshalJSON ¶ added in v0.13.3
type SchemaField ¶
type SchemaField struct { Type string `` /* 152-byte string literal not displayed */ ID string `json:"id" validate:"required,excludesall=$"` 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"` Default string `json:"default,omitempty" validate:"required_for=dropdown onoff radio"` Options []SchemaOption `json:"options,omitempty" validate:"required_for=dropdown radio,dive"` Palette []string `json:"palette,omitempty"` Sounds []SchemaSound `json:"sounds,omitempty" validate:"required_for=notification,dive"` Source string `json:"source,omitempty" validate:"required_for=generated"` Handler string `json:"handler,omitempty" validate:"required_for=generated locationbased typeahead oauth2"` StarlarkHandler *starlark.Function `json:"-"` 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 { Display string `json:"display"` Text string `json:"text" validate:"required"` // The same as display, for legacy reasons. Value string `json:"value" validate:"required"` }
SchemaOption represents an option in a field. For example, an item in a drop down menu.
type SchemaSound ¶ added in v0.32.7
type SchemaSound struct { ID string `json:"id" validate:"required"` Title string `json:"title" validate:"required"` Path string `json:"path" validate:"required"` }
SchemaSound represents a sound that can be played by the applet.
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 Sound ¶ added in v0.32.7
type Sound struct { SchemaSound // contains filtered or unexported fields }
func (*Sound) AsSchemaSound ¶ added in v0.32.7
func (s *Sound) AsSchemaSound() SchemaSound
type StarlarkSchema ¶
type StarlarkSchema struct { Schema Handlers map[string]SchemaHandler // 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
type Typeahead ¶ added in v0.14.0
type Typeahead struct {
SchemaField
}
func (*Typeahead) AsSchemaField ¶ added in v0.14.0
func (s *Typeahead) AsSchemaField() SchemaField