v1alpha

package
v0.0.0-...-e07d34e Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any any

Any represents a type which can be used as arbitrary node data.

type Array

type Array struct {
	Type    nuggit.Type `json:"type,omitempty"`
	Entries []any       `json:"entries,omitempty"`
}

Array creates an array of the same record type.

type Assert

type Assert struct {
	Lhs *Const `json:"lhs,omitempty"`
	Op  CondOp `json:"op,omitempty"`
	Rhs *Const `json:"rhs,omitempty"`
}

Assert represents an assertion that would cause a program to fail.

A string error message can be passed to input.

type Cache

type Cache struct {
	Dir string `json:"dir,omitempty"`
}

type Chromedp

type Chromedp struct {
	Source *Source `json:"source,omitempty"`
}

Chromedp runs a chromedp executor which fetches the outer HTML of an HTML document.

func (*Chromedp) Run

func (x *Chromedp) Run(ctx context.Context) (any, error)

func (*Chromedp) Validate

func (x *Chromedp) Validate() error

type Col

type Col struct {
	Name     string      `json:"name,omitempty"`
	Type     nuggit.Type `json:"type,omitempty"`
	Nullable bool        `json:"nullable,omitempty"`
}

type CondOp

type CondOp string
const (
	CondUndefined   CondOp = ""
	CondPassthrough CondOp = "passthrough"
	CondTrue        CondOp = "true"
	CondEqual       CondOp = "equal"
	CondLess        CondOp = "less"
)

type Const

type Const struct {
	Type  nuggit.Type `json:"type,omitempty"`
	Value any         `json:"value,omitempty"`
}

Const is a constant with a native type recognized by Nuggit.

See nuggit.Type.

func (*Const) CopyTo

func (x *Const) CopyTo(v *Var) error

type Count

type Count struct {
	Find *Find `json:"find,omitempty"`
}

type CrossJoin

type CrossJoin struct {
	Lhs any `json:"lhs,omitempty"`
	Rhs any `json:"rhs,omitempty"`
}

CrossJoin uses a lazy cross join strategy to join its arguments.

type Entity

type Entity struct {
	Type  nuggit.Type `json:"type,omitempty"`
	Value string      `json:"value,omitempty"`

	String string `json:"string,omitempty"`
	Table  *Table `json:"table,omitempty"`
}

type ExprFlags

type ExprFlags int
const (
	FlagsUndefined       ExprFlags = 0               //
	FlagsCaseInsensitive ExprFlags = 1 << (iota - 1) // i
	FlagsMultiLine                                   // m
	FlagsDotAll                                      // s
)

func (ExprFlags) CaseInsensitive

func (flags ExprFlags) CaseInsensitive() bool

func (ExprFlags) DotAll

func (flags ExprFlags) DotAll() bool

func (ExprFlags) MarshalJSON

func (flags ExprFlags) MarshalJSON() ([]byte, error)

func (ExprFlags) MultiLine

func (flags ExprFlags) MultiLine() bool

func (ExprFlags) String

func (flags ExprFlags) String() string

func (*ExprFlags) UnmarshalJSON

func (flags *ExprFlags) UnmarshalJSON(data []byte) error

type Factory

type Factory struct{}

func (Factory) New

func (Factory) New(n nuggit.Node) (any, error)

type Field

type Field struct {
	Key  nuggit.FieldKey
	Type *Type
}

type File

type File struct {
	FS       fs.FS  `json:"-"`
	Root     string `json:"root,omitempty"`
	Filename string `json:"filename,omitempty"`
}

func (*File) ReadFile

func (f *File) ReadFile() ([]byte, error)

type Find

type Find struct {
	Literal string `json:"literal,omitempty"`
	Byte    *byte  `json:"byte,omitempty"`
	AnyByte []byte `json:"any_byte,omitempty"`
	AnyRune string `json:"any_rune,omitempty"`
	Offset  int    `json:"offset,omitempty"`
	// Regex is a regular expression pattern.
	Regex *Regex `json:"regex,omitempty"`
	Sink  *Sink  `json:"sink,omitempty"`
	// All marks whether to find
	All bool `json:"all,omitempty"`
	// Submatch marks whether to include matching groups in the results.
	Submatch      bool   `json:"submatch,omitempty"`
	Index         bool   `json:"index,omitempty"`
	SubmatchIndex int    `json:"submatch_index,omitempty"`
	GroupName     string `json:"group_name,omitempty"`
	// Reverse marks that the search be conducted in reverse.
	Reverse bool `json:"reverse,omitempty"`
}

func (*Find) Run

func (x *Find) Run(ctx context.Context) (any, error)

type FnOp

type FnOp string
const (
	FnUndefined   FnOp = ""
	FnPassthrough FnOp = "passthrough"
	FnFilter      FnOp = "filter"
	FnMap         FnOp = "map"
	FnFlatMap     FnOp = "flatmap"
	FnReduce      FnOp = "reduce"
	FnHead        FnOp = "head"
	FnTail        FnOp = "tail"
)

type Functional

type Functional struct {
	Op         FnOp         `json:"op,omitempty"`
	Lambda     []string     `json:"lambda,omitempty"`
	InputType1 *Type        `json:"input_type1,omitempty"`
	InputType2 *Type        `json:"input_type2,omitempty"`
	OutputType *Type        `json:"output_type,omitempty"`
	Input      any          `json:"input,omitempty"`
	Node       *nuggit.Node `json:"node,omitempty"`
}

TODO(wes): Experimental: Determine interface for arbitrary ops and conditions.

type HTML

type HTML struct {
	Sink   *Sink  `json:"sink,omitempty"`
	String string `json:"string,omitempty"`
	Bytes  []byte `json:"bytes,omitempty"`
}

HTML parses an HTML document.

func (*HTML) Run

func (x *HTML) Run(ctx context.Context) (any, error)

type HTTP

type HTTP struct {
	Source *Source           `json:"source,omitempty"`
	Method string            `json:"method,omitempty"`
	Header map[string]string `json:"header,omitempty"`
}

func (*HTTP) GetHeader

func (x *HTTP) GetHeader() http.Header

func (*HTTP) Request

func (x *HTTP) Request() (*http.Request, error)

func (*HTTP) Response

func (x *HTTP) Response() (*http.Response, error)

func (*HTTP) Validate

func (x *HTTP) Validate() error

type Map

type Map struct {
	Data map[string]any `json:"data,omitempty"`
}

type MapEntry

type MapEntry struct {
	Key   string
	Value any
}

type Median

type Median struct {
	Type        nuggit.Type     `json:"type,omitempty"`
	Values      []*Const        `json:"values,omitempty"`
	CompareKey  nuggit.FieldKey `json:"compare_key"`
	AnyValues   []Any           `json:"any_values,omitempty"`
	TupleIndex  int             `json:"tuple_index,omitempty"`
	TupleValues [][]Any         `json:"tuple_values,omitempty"`
}

func (*Median) Run

func (x *Median) Run(ctx context.Context) error

type Numeric

type Numeric struct {
	Op  NumericOp `json:"op,omitempty"`
	Lhs *Const    `json:"lhs,omitempty"`
	Rhs *Const    `json:"rhs,omitempty"`
}

type NumericOp

type NumericOp string
const (
	NumericOpUnknown NumericOp = ""
	NumericOpLhs     NumericOp = "lhs"
	NumericOpRhs     NumericOp = "rhs"
	NumericOpAdd     NumericOp = "add"
)

type Range

type Range struct {
	Lo rune `json:"lo,omitempty"`
	Hi rune `json:"hi,omitempty"`
}

Range describes the open interval [Lo, Hi).

ExprConfig.Negate may be set to match all values,

type Regex

type Regex struct {
	Pattern string `json:"pattern,omitempty"`
}

Regex defines a Go-style regular expression.

Pattern should be a string input the regular expression.

The pattern can incorporate steps and variables using step inputs.

Syntax: https://golang.org/s/re2syntax.

func (*Regex) Compile

func (x *Regex) Compile() (*regexp.Regexp, error)

func (*Regex) Run

func (x *Regex) Run(ctx context.Context) (any, error)

func (*Regex) Validate

func (x *Regex) Validate() error

type Remote

type Remote struct {
	*Source      `json:",omitempty"`
	*nuggit.Sums `json:",omitempty"`
}

Remote operator specifies a source URL with checksums. Typically used for loading remote Crush programs.

type Repeat

type Repeat struct {
	Min  uint `json:"min,omitempty"`
	Max  uint `json:"max,omitempty"`
	Lazy bool `json:"lazy,omitempty"`
}

type Replace

type Replace struct {
	Op ReplaceOp `json:"op,omitempty"`
	// FindSubmatch is the index of the match to find for regex matching.
	FindSubmatch int  `json:"find_submatch,omitempty"`
	FindByte     byte `json:"find_byte,omitempty"`
	ReplaceByte  byte `json:"replace_byte,omitempty"`
	// ReplaceSubmatch replaces the matches with the submatch of the previous regex.
	ReplaceSubmatch int `json:"replace_submatch,omitempty"`
}

Replace replaces strings.

type ReplaceOp

type ReplaceOp string
const (
	ReplaceUndefined ReplaceOp = ""
	ReplaceByte      ReplaceOp = "byte"
)

type Row

type Row struct{}

type Sample

type Sample struct{}

Sample uses a sampling strategy to select elements from various sources.

type Selector

type Selector struct {
	All      bool   `json:"all,omitempty"`
	Selector string `json:"selector,omitempty"`
	Sink     *Sink  `json:"sink,omitempty"`
}

Selector implements CSS selectors.

func (*Selector) Run

func (x *Selector) Run(ctx context.Context) (any, error)

type Sink

type Sink struct {
	Op         SinkOp `json:"op,omitempty"`
	BufferSize int    `json:"buffer_size,omitempty"`
	Offset     int    `json:"offset,omitempty"`
	Bytes      []byte `json:"bytes,omitempty"`
	String     string `json:"string,omitempty"`
	HTTP       *HTTP  `json:"http,omitempty"`
	File       *File  `json:"file,omitempty"`
}

func (*Sink) Run

func (x *Sink) Run(ctx context.Context) (v any, err error)

type SinkOp

type SinkOp string
const (
	SinkUndefined SinkOp = ""
	SinkBytes     SinkOp = "bytes"
	SinkString    SinkOp = "string"
	SinkHTTP      SinkOp = "http"
	SinkFile      SinkOp = "file"
)

type Source

type Source struct {
	Scheme string `json:"scheme,omitempty"`
	Host   string `json:"host,omitempty"`
	Path   string `json:"path,omitempty"`
	Query  string `json:"query,omitempty"`
}

Source defines a Web source with a given host and path.

The path elements are dynamic to support variables and step outputs. The Host is a static variable not changeable through inputs.

func (*Source) URL

func (x *Source) URL() (*url.URL, error)

type Span

type Span struct {
	Pos int `json:"pos,omitempty"`
	End int `json:"end,omitempty"`
}

Span is a representation of an entity as indices into a source byte slice.

The entity content is represented by data[Pos:End] where data is a byte slice. The zero entity is used to indicate lack of presence. Entities where Pos == End are not valid.

type String

type String struct {
	Op     StringOp `json:"op,omitempty"`
	String string   `json:"value,omitempty"`
	Format string   `json:"format,omitempty"`
	Sink   *Sink    `json:"sink,omitempty"`
	Args   []any    `json:"args,omitempty"`
	Const  *Const   `json:"const,omitempty"`
	Sep    string   `json:"sep,omitempty"`
	At     int      `json:"at,omitempty"`
	Begin  int      `json:"begin,omitempty"`
	End    int      `json:"end,omitempty"`
}

func (*String) Run

func (x *String) Run(context.Context) (any, error)

type StringOp

type StringOp string
const (
	StringUndefined        StringOp = ""
	StringFormat           StringOp = "sprintf"
	StringAggstring        StringOp = "aggstring"
	StringSubstring        StringOp = "substring"
	StringToLower          StringOp = "tolower"
	StringToUpper          StringOp = "toupper"
	StringURLPathEscape    StringOp = "urlpathescape"
	StringURLPathJoin      StringOp = "urlpathjoin"
	StringURLPathUnescape  StringOp = "urlpathunescape"
	StringURLQueryEscape   StringOp = "urlqueryescape"
	StringURLQueryUnescape StringOp = "urlqueryunescape"
)

type Table

type Table struct {
	Cols []Col    `json:"cols,omitempty"`
	Key  []string `json:"key,omitempty"`
}

func (*Table) Unmarshal

func (x *Table) Unmarshal(data any) error

type Time

type Time struct {
	Op      TimeOp       `json:"op,omitempty"`
	Sink    *Sink        `json:"sink,omitempty"`
	Layout  string       `json:"layout,omitempty"`
	Year    int          `json:"year,omitempty"`
	Month   time.Month   `json:"month,omitempty"`
	Day     int          `json:"day,omitempty"`
	Hour    int          `json:"hour,omitempty"`
	Min     int          `json:"min,omitempty"`
	Sec     int          `json:"sec,omitempty"`
	Nsec    int          `json:"nsec,omitempty"`
	Loc     string       `json:"loc,omitempty"`
	Weekday time.Weekday `json:"weekday,omitempty"`
	Time    *time.Time   `json:"time_value,omitempty"`
}

type TimeOp

type TimeOp string
const (
	TimeUndefined TimeOp = ""
	TimeNow       TimeOp = "now"
)

type Type

type Type struct {
	Key    string      `json:"key,omitempty"`
	Type   nuggit.Type `json:"type,omitempty"`
	Fields []Field     `json:"fields,omitempty"`
}

type Var

type Var struct {
	Type    nuggit.Type `json:"type,omitempty"`
	Value   any         `json:"value,omitempty"`
	Default any         `json:"default,omitempty"`
}

Vap is a variable.

func (*Var) Run

func (v *Var) Run(ctx context.Context) (any, error)

Jump to

Keyboard shortcuts

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