types

package
v0.0.0-...-bc49051 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableOpTypeSet           = "set"
	TableOpTypeSetColumnName = "set_column_name"
	TableOpTypeDelete        = "delete"
	TableOpTypeInsertColumn  = "insert_column"
	TableOpTypeDeleteColumn  = "delete_column"
	TableOpTypeInsertRow     = "insert_row"
	TableOpTypeDeleteRow     = "delete_row"
	TableOpTypeReorderColumn = "reorder_column"
	TableOpTypeReorderRow    = "reorder_row"
)

TableOp types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	ParentID       incr.Identifier `json:"parent_id"`
	ChildID        incr.Identifier `json:"child_id"`
	ChildInputName string          `json:"child_input_name"`
}

Edge is a represented edge in the graph between a source node (the parent) and the target node (the child).

type Graph

type Graph struct {
	ID               incr.Identifier `json:"id"`
	Label            string          `json:"label"`
	StabilizationNum uint64          `json:"stabilization_num"`
	Metadata         GraphMetadata   `json:"metadata"`
}

func GraphFromIncr

func GraphFromIncr(g *incr.Graph) *Graph

GraphFromIncr returns a db graph from an incremental graph object.

type GraphFull

type GraphFull struct {
	Graph         *Graph            `json:"graph"`
	Nodes         []Node            `json:"nodes,omitempty"`
	Edges         []Edge            `json:"edges,omitempty"`
	Values        []NodeValue       `json:"values,omitempty"`
	RecomputeHeap []incr.Identifier `json:"recompute_heap,omitempty"`
}

GraphFull is a serialized graph.

type GraphMetadata

type GraphMetadata struct {
	UserID       uuid.UUID `json:"user_id"`
	CreatedUTC   time.Time `json:"created_utc"`
	UpdatedUTC   time.Time `json:"updated_utc"`
	ViewportX    float64   `json:"viewport_x"`
	ViewportY    float64   `json:"viewport_y"`
	ViewportZoom float64   `json:"viewport_zoom"`
}

type Node

type Node struct {
	// ID is a unique identifier for the node.
	ID incr.Identifier `json:"id"`
	// Label is the descriptive label for the node.
	Label string `json:"label,omitempty"`
	// Metadata is data that's held on the node metadata field.
	//
	// It will not be data that is inferred from the INode itself.
	Metadata NodeMetadata `json:"metadata"`

	// these are from the incremental node metadata specifically
	Always                    bool   `json:"always"`
	Observer                  bool   `json:"observer"`
	Valid                     bool   `json:"valid"`
	ChangedAt                 uint64 `json:"changed_at"`
	RecomputedAt              uint64 `json:"recomputed_at"`
	SetAt                     uint64 `json:"set_at"`
	Height                    int    `json:"height"`
	HeightInRecomputeHeap     int    `json:"height_in_recompute_heap"`
	HeightInAdjustHeightsHeap int    `json:"height_in_adjust_heights_heap"`
}

Node is the serialized / api form of the incr node(s).

type NodeMetadata

type NodeMetadata struct {
	Collapsed        bool     `json:"collapsed"`
	Watched          bool     `json:"watched"`
	WatchedCollapsed bool     `json:"watched_collapsed"`
	PositionX        float64  `json:"position_x"`
	PositionY        float64  `json:"position_y"`
	Height           *float64 `json:"height"`
	Width            *float64 `json:"width"`
	NodeType         string   `json:"node_type"`
	InputType        string   `json:"input_type,omitempty"`
	OutputType       string   `json:"output_type,omitempty"`
	Expression       string   `json:"expression,omitempty"`
}

NodeMetadata is strictly the data that's held on the INode.Metadata() field.

type NodeValue

type NodeValue struct {
	ID        incr.Identifier `json:"id"`
	ValueType string          `json:"value_type"`
	Value     any             `json:"value,omitempty"`
}

NodeValue is a value for a node.

type PatchSet

type PatchSet map[string]any

PatchSet is a set of fields to patch.

type SVG

type SVG struct {
	Main      string `json:"main"`
	Thumbnail string `json:"thumbnail"`
}

SVG is effectively a pair of very large strings.

func SVGFromJSON

func SVGFromJSON(obj map[string]any) (*SVG, error)

SVGFromJSON returns an svg from a json object.

type Table

type Table struct {
	Columns []TableColumn `json:"columns"`
}

Table is a column oriented store of data.

Specifically it breaks the data into columns, and those columns have values which you can think of as rows.

This makes inserting a new column very easy (and fast!), but it also means that some operations are kind of finicky (specifically inserting rows).

func TableFromCSV

func TableFromCSV(data [][]string) (*Table, error)

TableFromCSV returns a table from a csv.

func TableFromCSVReader

func TableFromCSVReader(data io.Reader) (*Table, error)

TableFromCSVReader returns a table from a reader that holds csv data.

func TableFromJSON

func TableFromJSON(obj map[string]any) (*Table, error)

TableFromJSON returns a table from a json object.

func (*Table) ApplyOps

func (t *Table) ApplyOps(ops ...TableOp) error

ApplyOps applies operations to the table.

func (*Table) Delete

func (t *Table) Delete(row, col int) error

Delete deletes a value at a given row and column.

func (*Table) DeleteColumn

func (t *Table) DeleteColumn(columnIndex int) error

DeleteColumn deletes a column at a given index.

func (*Table) DeleteRow

func (t *Table) DeleteRow(rowIndex int) error

DeleteRow deletes a row at a given index.

func (*Table) InsertColumn

func (t *Table) InsertColumn(columnIndex int, newColumn TableColumn) error

InsertColumn insets a new column at a given index.

func (*Table) InsertRow

func (t *Table) InsertRow(rowIndex int, rowValues []any) error

InsertRow inserts a row at a given index.

func (*Table) Range

func (t *Table) Range(r TableRange) [][]any

Range returns a subset of the table data according to a given range predicate.

func (*Table) ReorderColumn

func (t *Table) ReorderColumn(oldColumn, newColumn int) error

ReorderColumn swaps the column order from a given old index to a given new index.

func (*Table) ReorderRow

func (t *Table) ReorderRow(oldRow, newRow int) error

ReorderRow swaps the row order from a given old index to a given new index.

func (*Table) RowCount

func (t *Table) RowCount() (maxRows int)

RowCount returns the maximum number of rows in any of the columns of the table.

func (*Table) Rows

func (t *Table) Rows() [][]any

Rows returns the values of the table organized by row (instead of by column.)

func (*Table) Set

func (t *Table) Set(row, col int, value any) error

Set sets the value for a given row and column.

If the row is beyond the current row count for a given column, nil values are added to satisfy the "density" of the table.

func (*Table) SetColumnName

func (t *Table) SetColumnName(columnIndex int, columnName string) error

SetColumnName sets the column name for a column at a given index.

type TableColumn

type TableColumn struct {
	Name      string `json:"name"`
	ValueType string `json:"value_type"`
	Values    []any  `json:"values"`
}

TableColumn is a vector of data.

func TableColumnFromJSON

func TableColumnFromJSON(obj map[string]any) (*TableColumn, error)

TableColumnFromJSON returns a table column from a json object.

type TableInfo

type TableInfo struct {
	Rows    int      `json:"rows"`
	Columns []string `json:"columns"`
}

TableInfo is the table metdata less the actual data.

type TableOp

type TableOp struct {
	// type determines what function to call
	Type string `json:"type"`
	// the column name typically
	Name string `json:"name"`
	// the colmn value type typically
	ValueType string `json:"value_type"`

	// used for various commands
	Col int `json:"col"`
	Row int `json:"row"`

	// used for reodering
	Old int `json:"old"`
	New int `json:"new"`

	// for setting the value
	Value any `json:"value"`
	// for inserting rows and columns
	Values []any `json:"values"`
}

TableOp is an operation a user can take on a table.

NOTE(wc): The format here is kind of gross because we don't have the ability to do the typescript thing where we discriminate types based on a string field value.

We could use interfaces and do a bunch of careful implementing but this is fine for now.

type TableOpType

type TableOpType string

TableOpType is a type of operation on a table.

type TableRange

type TableRange struct {
	Top    int `json:"top"`
	Left   int `json:"left"`
	Bottom int `json:"bottom"`
	Right  int `json:"right"`
}

TableRange holds visible coordinates.

type Viewport

type Viewport struct {
	X    float64 `json:"x"`
	Y    float64 `json:"y"`
	Zoom float64 `json:"zoom"`
}

Viewport is the viewport information for a graph.

Jump to

Keyboard shortcuts

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