starlark_type

package
v0.18.8 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToMap added in v0.15.14

func ConvertToMap(p any) (map[string]any, error)

ConvertToMap converts a struct to a map[string]any

func ConvertToStarlark added in v0.15.14

func ConvertToStarlark(p any) (starlark.Value, error)

func IsEmptyStarlarkString

func IsEmptyStarlarkString(s starlark.String) bool

IsEmptyStarlarkString checks is a starlark string is empty ("" for a go string) starlark.String.String performs repr-style quotation, which is necessary for the starlark.Value contract but a frequent source of errors in API clients. This helper method makes sure it'll work properly

func MarshalStarlark

func MarshalStarlark(data interface{}) (v starlark.Value, err error)

MarshalStarlark turns go values into starlark types

func UnmarshalStarlark

func UnmarshalStarlark(x starlark.Value) (val interface{}, err error)

UnmarshalStarlark decodes a starlark.Value into it's golang counterpart

func UnquoteStarlark

func UnquoteStarlark(x starlark.Value) (string, error)

UnquoteStarlark unquotes a starlark string value

Types

type DownloadStream added in v0.18.7

type DownloadStream struct {
	// contains filtered or unexported fields
}

DownloadStream is an opaque starlark value carrying a lazily produced download body. Only plugin Go code can construct one; app starlark code can just pass it through into ace.response(data=..., download=...) - it exposes no attributes, so a handler cannot fabricate or inspect one. The producer is invoked by the download response handler at response-write time, writing the body into the response buffer: the payload is never fully materialized in memory or staged to disk, and once the buffer fills a stalled client blocks the producer (TCP backpressure). Single use: a second Produce errors instead of silently sending an empty body.

func NewDownloadStream added in v0.18.7

func NewDownloadStream(name string, producer func(w io.Writer) error) *DownloadStream

func (*DownloadStream) Freeze added in v0.18.7

func (d *DownloadStream) Freeze()

Freeze is a no-op: the value is consumed by the single request thread that created it, never shared across starlark threads

func (*DownloadStream) Hash added in v0.18.7

func (d *DownloadStream) Hash() (uint32, error)

func (*DownloadStream) Name added in v0.18.7

func (d *DownloadStream) Name() string

Name is the download attachment file name

func (*DownloadStream) Produce added in v0.18.7

func (d *DownloadStream) Produce(w io.Writer) error

Produce writes the body to w. It may block on w (the response writer) when the client is slow to read

func (*DownloadStream) String added in v0.18.7

func (d *DownloadStream) String() string

func (*DownloadStream) Truth added in v0.18.7

func (d *DownloadStream) Truth() starlark.Bool

func (*DownloadStream) Type added in v0.18.7

func (d *DownloadStream) Type() string

type Index

type Index struct {
	Fields []string
	Unique bool
}

type Marshaler

type Marshaler interface {
	// MarshalStarlark marshal a custom type to starlark object.
	MarshalStarlark() (starlark.Value, error)
}

Marshaler is the interface use to marshal starlark custom types.

type Output

type Output struct {
	Value starlark.Value
	Err   string
}

func (Output) Attr

func (o Output) Attr(name string) (starlark.Value, error)

func (Output) AttrNames

func (o Output) AttrNames() []string

func (Output) Freeze

func (o Output) Freeze()

func (Output) Hash

func (o Output) Hash() (uint32, error)

func (Output) String

func (o Output) String() string

func (Output) Truth

func (o Output) Truth() starlark.Bool

func (Output) Type

func (o Output) Type() string

type Request

type Request struct {
	AppName     string
	AppPath     string
	AppUrl      string
	PagePath    string
	PageUrl     string
	Method      string
	IsDev       bool
	IsPartial   bool
	PushEvents  bool
	HtmxVersion string
	// Headers is the sanitized request header view exposed as req.Headers. It
	// is built lazily by HeadersFunc on first access, since most handlers never
	// read headers and cloning the whole header map per request is expensive.
	// Set Headers directly (with HeadersFunc nil) when the value is already
	// known.
	Headers        http.Header
	HeadersFunc    func() http.Header
	RemoteIP       string
	UrlParams      map[string]string
	Form           url.Values
	Query          url.Values
	PostForm       url.Values
	UserId         string
	UserSubject    string
	UserEmail      string
	CustomPerms    []string
	AppRBACEnabled bool
	Data           any
}

Request is a starlark.Value that represents an HTTP request. A Request is created from the Go http.Request and passed to the starlark handler function as it only argument. The Data field is updated with the handler's response and then the template evaluation is done with the same Request

func (Request) Attr

func (r Request) Attr(name string) (starlark.Value, error)

func (Request) AttrNames

func (r Request) AttrNames() []string

func (Request) Freeze

func (r Request) Freeze()

func (Request) Hash

func (r Request) Hash() (uint32, error)

func (Request) String

func (r Request) String() string

func (Request) Truth

func (r Request) Truth() starlark.Bool

func (Request) Type

func (r Request) Type() string

type StarlarkType

type StarlarkType struct {
	// contains filtered or unexported fields
}

StarlarkType represents a Starlark type created from the schema type definition.

func NewStarlarkType

func NewStarlarkType(name string, data map[string]starlark.Value) *StarlarkType

func (*StarlarkType) Attr

func (s *StarlarkType) Attr(attr string) (starlark.Value, error)

func (*StarlarkType) AttrNames

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

func (*StarlarkType) Freeze

func (s *StarlarkType) Freeze()

func (*StarlarkType) Hash

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

func (*StarlarkType) SetField

func (s *StarlarkType) SetField(name string, val starlark.Value) error

func (*StarlarkType) String

func (s *StarlarkType) String() string

func (*StarlarkType) Truth

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

func (*StarlarkType) Type

func (s *StarlarkType) Type() string

func (*StarlarkType) UnmarshalStarlarkType

func (s *StarlarkType) UnmarshalStarlarkType() (any, error)

type StoreField

type StoreField struct {
	Name    string
	Type    TypeName
	Default any
}

type StoreInfo

type StoreInfo struct {
	Bytes []byte // The raw bytes for the schema.star file
	Types []StoreType
}

type StoreType

type StoreType struct {
	Name    string
	Fields  []StoreField
	Indexes []Index
}

type TypeBuilder

type TypeBuilder struct {
	Name   string
	Fields []StoreField
}

func (*TypeBuilder) CreateType

func (s *TypeBuilder) CreateType(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

type TypeName

type TypeName string
const (
	INT      TypeName = "INT"
	FLOAT    TypeName = "FLOAT"
	DATETIME TypeName = "DATETIME"
	STRING   TypeName = "STRING"
	BOOLEAN  TypeName = "BOOLEAN"
	LIST     TypeName = "LIST"
	DICT     TypeName = "DICT"
)

type TypeUnmarshaler

type TypeUnmarshaler interface {
	// UnmarshalStarlark unmarshals a starlark object to go object
	UnmarshalStarlarkType() (any, error)
}

Unmarshaler is the interface use to unmarshal starlark custom types.

type Unmarshaler

type Unmarshaler interface {
	// UnmarshalStarlark unmarshal a starlark object to custom type.
	UnmarshalStarlark(starlark.Value) error
}

Unmarshaler is the interface use to unmarshal starlark custom types.

Jump to

Keyboard shortcuts

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