hof

package
v0.6.8-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

README

notes

once we start pushing this package out to more of the code base we might want to consider using a hof/runtime to house the common pieces across the major features, loading and enriching the CUE as a whole, then being able to work with any of the sub-features

For now, we are only using this setup in datamodel as a POC. Gen should be easy to update after that, flow with the rewrite

Documentation

Overview

This package manages the #hof: _ configuration and the various @<hof>() attributes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Root bool
	Name string
	Type string
}

hof/chat configuration

type Datamodel

type Datamodel struct {
	// Root for datamodel features
	// This acts as the entrypoint
	// the other fields determine behavior
	Root bool

	// index, pivot, level, hierachy, node?
	Node bool

	// Enable snapshots and history in .hof/dm/...
	History bool

	// create an Ordered<Label> list in parent data
	// where elements are from CUE iteration of fields
	Ordered bool

	// treat as a cue value
	// nesting stops here and the whole
	// value is tracked as a singular value
	// support incomplete values & schemas
	Cue bool

	// Semantic version for value
	Version string
}

hof/datamodel configuration

type Flow

type Flow struct {
	Root bool
	Name string
	Task string
}
  hof/flow configuration
  this has more shorthands
	@flow() | @flow(name)
	@task(op) | @task(op,name)

type Gen

type Gen struct {
	Root    bool
	Name    string
	Creator bool
}

hof/gen configuration #hof: gen: "name" @gen(name)

type Hof

type Hof struct {
	// label from containing value in CUE
	Label string

	// path to containing value in CUE
	Path string

	// Semantic hof datamodel api-version for compat
	APIVersion string

	// #hof: metadata: ...
	Metadata Metadata

	// #hof: <feature>: ...
	// @<feature>(<name>) can be shorthand with no-name implying label?
	Datamodel Datamodel
	Gen       Gen
	Flow      Flow
	Chat      Chat

	// any extra config, set by users
	Extra map[string]any
}

#hof: ...

type Metadata

type Metadata struct {
	// A unique ID as @id(string) generated by hof
	ID string `json:"id"`

	// Given name for the value
	Name string

	// arbitrary key=string data
	Labels map[string]string

	// CUE import path / package
	// only needs to be set if importing elsewhere
	Package string
}

Common Metadata

type Node

type Node[T any] struct {
	Hof Hof

	// containing value
	Value cue.Value

	// The wrapping type
	T *T

	// heirarchy of tracked values
	Parent *Node[T]
	// we (this node) are in between
	Children []*Node[T]
}

func FindHofs

func FindHofs(value cue.Value) (roots []*Node[any], err error)

func New

func New[T any](label string, val cue.Value, curr *T, parent *Node[T]) *Node[T]

func Upgrade

func Upgrade[S, T any](src *Node[S], upgrade func(*Node[T]) *T, parent *Node[T]) *Node[T]

func (*Node[T]) Print

func (hn *Node[T]) Print()

Jump to

Keyboard shortcuts

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