schema

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName = "schema"
)
View Source
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

func EncodeOptions(
	starlarkOptions starlark.Value,
) (string, error)

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

func (*Color) Attr added in v0.24.7

func (s *Color) Attr(name string) (starlark.Value, error)

func (*Color) AttrNames added in v0.24.7

func (s *Color) AttrNames() []string

func (*Color) Freeze added in v0.24.7

func (s *Color) Freeze()

func (*Color) Hash added in v0.24.7

func (s *Color) Hash() (uint32, error)

func (*Color) String added in v0.24.7

func (s *Color) String() string

func (*Color) Truth added in v0.24.7

func (s *Color) Truth() starlark.Bool

func (*Color) Type added in v0.24.7

func (s *Color) Type() string

type DateTime added in v0.14.0

type DateTime struct {
	SchemaField
}

func (*DateTime) AsSchemaField added in v0.14.0

func (s *DateTime) AsSchemaField() SchemaField

func (*DateTime) Attr added in v0.14.0

func (s *DateTime) Attr(name string) (starlark.Value, error)

func (*DateTime) AttrNames added in v0.14.0

func (s *DateTime) AttrNames() []string

func (*DateTime) Freeze added in v0.14.0

func (s *DateTime) Freeze()

func (*DateTime) Hash added in v0.14.0

func (s *DateTime) Hash() (uint32, error)

func (*DateTime) String added in v0.14.0

func (s *DateTime) String() string

func (*DateTime) Truth added in v0.14.0

func (s *DateTime) Truth() starlark.Bool

func (*DateTime) Type added in v0.14.0

func (s *DateTime) Type() string
type Dropdown struct {
	SchemaField
	// contains filtered or unexported fields
}
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 Field interface {
	AsSchemaField() SchemaField
}

type Generated added in v0.16.2

type Generated struct {
	SchemaField
	// contains filtered or unexported fields
}

func (*Generated) AsSchemaField added in v0.16.2

func (s *Generated) AsSchemaField() SchemaField

func (*Generated) Attr added in v0.16.2

func (s *Generated) Attr(name string) (starlark.Value, error)

func (*Generated) AttrNames added in v0.16.2

func (s *Generated) AttrNames() []string

func (*Generated) Freeze added in v0.16.2

func (s *Generated) Freeze()

func (*Generated) Hash added in v0.16.2

func (s *Generated) Hash() (uint32, error)

func (*Generated) String added in v0.16.2

func (s *Generated) String() string

func (*Generated) Truth added in v0.16.2

func (s *Generated) Truth() starlark.Bool

func (*Generated) Type added in v0.16.2

func (s *Generated) Type() string

type Handler added in v0.16.1

type Handler struct {
	SchemaHandler
}

func (*Handler) AsSchemaHandler added in v0.16.1

func (s *Handler) AsSchemaHandler() SchemaHandler

func (*Handler) Attr added in v0.16.1

func (s *Handler) Attr(name string) (starlark.Value, error)

func (*Handler) AttrNames added in v0.16.1

func (s *Handler) AttrNames() []string

func (*Handler) Freeze added in v0.16.1

func (s *Handler) Freeze()

func (*Handler) Hash added in v0.16.1

func (s *Handler) Hash() (uint32, error)

func (*Handler) String added in v0.16.1

func (s *Handler) String() string

func (*Handler) Truth added in v0.16.1

func (s *Handler) Truth() starlark.Bool

func (*Handler) Type added in v0.16.1

func (s *Handler) Type() string

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

func (*Location) Attr

func (s *Location) Attr(name string) (starlark.Value, error)

func (*Location) AttrNames

func (s *Location) AttrNames() []string

func (*Location) Freeze

func (s *Location) Freeze()

func (*Location) Hash

func (s *Location) Hash() (uint32, error)

func (*Location) String

func (s *Location) String() string

func (*Location) Truth

func (s *Location) Truth() starlark.Bool

func (*Location) Type

func (s *Location) Type() string

type LocationBased added in v0.14.0

type LocationBased struct {
	SchemaField
	// contains filtered or unexported fields
}

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
	// 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

func (*OAuth2) Attr added in v0.14.0

func (s *OAuth2) Attr(name string) (starlark.Value, error)

func (*OAuth2) AttrNames added in v0.14.0

func (s *OAuth2) AttrNames() []string

func (*OAuth2) Freeze added in v0.14.0

func (s *OAuth2) Freeze()

func (*OAuth2) Hash added in v0.14.0

func (s *OAuth2) Hash() (uint32, error)

func (*OAuth2) String added in v0.14.0

func (s *OAuth2) String() string

func (*OAuth2) Truth added in v0.14.0

func (s *OAuth2) Truth() starlark.Bool

func (*OAuth2) Type added in v0.14.0

func (s *OAuth2) Type() string

type Option

type Option struct {
	SchemaOption
}

func (*Option) AsSchemaOption

func (s *Option) AsSchemaOption() SchemaOption

func (*Option) Attr

func (s *Option) Attr(name string) (starlark.Value, error)

func (*Option) AttrNames

func (s *Option) AttrNames() []string

func (*Option) Freeze

func (s *Option) Freeze()

func (*Option) Hash

func (s *Option) Hash() (uint32, error)

func (*Option) String

func (s *Option) String() string

func (*Option) Truth

func (s *Option) Truth() starlark.Bool

func (*Option) Type

func (s *Option) Type() string

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 []SchemaField `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

func FromStarlark(
	val starlark.Value,
	globals starlark.StringDict,
) (*Schema, error)

FromStarlark creates a new Schema from a Starlark schema object.

func (Schema) MarshalJSON added in v0.13.3

func (s Schema) MarshalJSON() ([]byte, error)

type SchemaField

type SchemaField struct {
	Type        string            `` /* 152-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"`

	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"`

	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 {
	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

func (*Sound) Attr added in v0.32.7

func (s *Sound) Attr(name string) (starlark.Value, error)

func (*Sound) AttrNames added in v0.32.7

func (s *Sound) AttrNames() []string

func (*Sound) Freeze added in v0.32.7

func (s *Sound) Freeze()

func (*Sound) Hash added in v0.32.7

func (s *Sound) Hash() (uint32, error)

func (*Sound) String added in v0.32.7

func (s *Sound) String() string

func (*Sound) Truth added in v0.32.7

func (s *Sound) Truth() starlark.Bool

func (*Sound) Type added in v0.32.7

func (s *Sound) Type() string

type StarlarkSchema

type StarlarkSchema struct {
	Schema
	Handlers map[string]SchemaHandler
	// contains filtered or unexported fields
}

func (StarlarkSchema) Attr

func (s StarlarkSchema) Attr(name string) (starlark.Value, error)

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

func (*Text) Attr added in v0.10.1

func (s *Text) Attr(name string) (starlark.Value, error)

func (*Text) AttrNames added in v0.10.1

func (s *Text) AttrNames() []string

func (*Text) Freeze added in v0.10.1

func (s *Text) Freeze()

func (*Text) Hash added in v0.10.1

func (s *Text) Hash() (uint32, error)

func (*Text) String added in v0.10.1

func (s *Text) String() string

func (*Text) Truth added in v0.10.1

func (s *Text) Truth() starlark.Bool

func (*Text) Type added in v0.10.1

func (s *Text) Type() string

type Toggle

type Toggle struct {
	SchemaField
}

func (*Toggle) AsSchemaField

func (s *Toggle) AsSchemaField() SchemaField

func (*Toggle) Attr

func (s *Toggle) Attr(name string) (starlark.Value, error)

func (*Toggle) AttrNames

func (s *Toggle) AttrNames() []string

func (*Toggle) Freeze

func (s *Toggle) Freeze()

func (*Toggle) Hash

func (s *Toggle) Hash() (uint32, error)

func (*Toggle) String

func (s *Toggle) String() string

func (*Toggle) Truth

func (s *Toggle) Truth() starlark.Bool

func (*Toggle) Type

func (s *Toggle) Type() string

type Typeahead added in v0.14.0

type Typeahead struct {
	SchemaField
	// contains filtered or unexported fields
}

func (*Typeahead) AsSchemaField added in v0.14.0

func (s *Typeahead) AsSchemaField() SchemaField

func (*Typeahead) Attr added in v0.14.0

func (s *Typeahead) Attr(name string) (starlark.Value, error)

func (*Typeahead) AttrNames added in v0.14.0

func (s *Typeahead) AttrNames() []string

func (*Typeahead) Freeze added in v0.14.0

func (s *Typeahead) Freeze()

func (*Typeahead) Hash added in v0.14.0

func (s *Typeahead) Hash() (uint32, error)

func (*Typeahead) String added in v0.14.0

func (s *Typeahead) String() string

func (*Typeahead) Truth added in v0.14.0

func (s *Typeahead) Truth() starlark.Bool

func (*Typeahead) Type added in v0.14.0

func (s *Typeahead) Type() string

Jump to

Keyboard shortcuts

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