entity

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package entity exposes shared entity types used in the public wick contract (tool/job registration). Most entity types stay in internal/entity — only the bits downstream authors touch live here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Owner         string `gorm:"primaryKey;type:varchar(64);default:''"`
	Key           string `gorm:"primaryKey;type:varchar(64)"`
	Value         string `gorm:"type:text"`
	Type          string `gorm:"type:varchar(16);default:'text'"`
	Options       string `gorm:"type:text"`
	IsSecret      bool   `gorm:"default:false"`
	CanRegenerate bool   `gorm:"default:false"`
	Locked        bool   `gorm:"default:false"`
	Required      bool   `gorm:"default:false"`
	Description   string `gorm:"type:text"`
	UpdatedAt     time.Time
	// Hidden is set from the `wick:"hidden"` tag at seed time. Not persisted
	// (gorm:"-") — tells the manager Settings page to skip this row. Hidden
	// configs are still seeded to DB so runtime reads work normally.
	Hidden bool `gorm:"-" json:"-"`
	// ColOptions holds per-column select options for kvlist rows. Not persisted.
	// Key = column name; Value = pipe-separated "label::value" pairs (or just
	// "value" when label == value). The kvlist component renders a <select>
	// instead of <input> for columns that have options set.
	ColOptions map[string]string `gorm:"-" json:"-"`
	// VisibleWhen is a "<otherField>:<value>" predicate sourced from the
	// `wick:"visible_when=..."` tag. When set, the admin UI shows this row
	// only while the named field's current value equals <value>. Not
	// persisted — pure presentation hint.
	VisibleWhen string `gorm:"-" json:"-"`
}

Config is one row in the runtime-editable KV config table (legacy name: `app_variables`). Wick reconciles two sources into this table at boot:

  • app-level defaults declared in internal/configs/spec.go (Owner == "", for session_secret / app_url / app_name)
  • per-module Config structs passed to app.RegisterTool. Framework reflects the typed struct + `wick:"..."` tags into rows via StructToConfigs, with Owner == Meta.Key stamped at boot.

The composite primary key (Owner, Key) lets the same Key repeat across scopes without collision (every tool can have its own "api_key", for example).

Type drives which widget the admin UI renders:

text (default), textarea, dropdown, number, checkbox,
email, url, color, date, datetime,
kvlist (editable table; Options = pipe-separated column names)

Options is pipe-separated (`a|b|c`). For "dropdown" it holds option values; for "kvlist" it holds column names (e.g. "id|name"). Value for kvlist rows is a JSON array of string-keyed objects.

func StructToConfigs

func StructToConfigs(cfg any) []Config

StructToConfigs reflects a typed per-module Config struct into a slice of Config rows ready for reconciliation. Each exported field with a non-empty `wick:"..."` tag becomes one row.

Field name → Key: CamelCase → snake_case (InitText → init_text), unless overridden by `key=...` in the tag.

Field type → widget:

bool   → "checkbox"
int*   → "number"
string → "text" (or whatever tag flag says: textarea, dropdown,
                 email, url, color, date, datetime)

Field value → seed Value. Zero values are written as empty string for string fields, "0" for int fields, "false" for bool fields — reconcile then either inserts the row or preserves the existing DB value.

Fields without a `wick` tag are ignored, so Config structs can hold internal state that should not become a row.

func (Config) TableName

func (Config) TableName() string

type ToolVisibility

type ToolVisibility string

ToolVisibility controls who can access a tool.

const (
	VisibilityPublic  ToolVisibility = "public"  // no login needed
	VisibilityPrivate ToolVisibility = "private" // login + approved (optionally filtered by tags)
)

Jump to

Keyboard shortcuts

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