pkg

package
v0.0.0-...-d782b9e Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CMSObject

type CMSObject struct {
	Schema *Schema `yaml:"schema"`
	Layout *Layout `yaml:"layout"`
}

type Field

type Field struct {
	Name string                   `yaml:"name"`
	Type parameters.ParameterType `yaml:"type"`
	Help string                   `yaml:"help,omitempty"`
	// Specifies if a unique index should be created for the given field
	Unique *bool `yaml:"unique,omitempty"`
	// Specifies if an index should be created for the given field
	Index *bool `yaml:"index,omitempty"`
	// For numeric types, specifies the minimum and maximum values
	Min *float32 `yaml:"min,omitempty"`
	Max *float32 `yaml:"max,omitempty"`
	// For documentation purposes, specifies the unit of the field
	Unit *string `yaml:"unit,omitempty"`
	// For ParameterTypeChoice, specifies the possible choices
	Choices []string `yaml:"choices,omitempty"`
}

Field is a struct that represents a field in a table. It specifies the type, which can be: - ParameterTypeString = "string" - ParameterTypeInteger = "int" - ParameterTypeFloat = "float" - ParameterTypeBool = "bool" - ParameterTypeDate = "date" - ParameterTypeChoice = "choice" -> string

type Input

type Input struct {
	Name  string    `yaml:"name"`
	Type  InputType `yaml:"type"`
	Label string    `yaml:"label,omitempty"`
	// Optional help tooltip
	Tooltip string `yaml:"tooltip,omitempty"`
	// Target is a string `table.field` that specifies the field to which the input is linked.
	Target string `yaml:"target,omitempty"`
}

Input is a struct that represents an input for a CMS field.

type InputType

type InputType string

InputType is used to specify the type of input for a CMS field.

const (
	InputTypeTextInput    InputType = "text-input"
	InputTypeTextArea     InputType = "textarea"
	InputTypeIntegerInput InputType = "integer-input"
	InputTypeIntegerRange InputType = "integer-range"
	InputTypeEditableList InputType = "editable-list"
)

type Layout

type Layout struct {
	Sections []Section `yaml:"section"`
}

Layout is a struct that represents the layout of a CMS object.

func ParseLayout

func ParseLayout(input []byte) (*Layout, error)

type Row

type Row struct {
	Inputs []Input `yaml:"inputs"`
}

Row is a struct that represents a row in a CMS section. It is basically a list of fields.

type Schema

type Schema struct {
	Tables    map[string]Table `yaml:"tables"`
	MainTable string           `yaml:"main-table"`
}

Schema is a struct that represents the schema of a CMS object. This contains all the necessary tables, as well as the main table for the object to which all other tables are joined on its `id` using the `parent_id` field.

A CMS object is represents by a main table and multiple additional tables used to represent list or object fields.

When mapped to SQL, every table contains an id field that can be used to do foreign relational joins.

- For list fields, the value of the list item is stored in a column named `value` in the respective secondary table. - For object fields, every column of the secondary table represents one key of the object. There is supposed to be only one row. - For object list fields, the table is the same as for object fields, but there can be multiple rows.

func ParseSchemaFromYAML

func ParseSchemaFromYAML(input []byte) (*Schema, error)

type Section

type Section struct {
	Title        string `yaml:"title"`
	HasAddRemove bool   `yaml:"has-add-remove,omitempty"`
	Rows         []Row  `yaml:"rows"`
}

Section is a struct that represents a section in a CMS object. It has multiple rows and can be used to represent a list of objects or a list of fields.

type Table

type Table struct {
	Help string `yaml:"help,omitempty"`
	// The fields of the table, empty is IsList is true
	Fields []Field `yaml:"fields,omitempty"`
	// Indicates where this table only stores a list of values, and thus only has a single field `ValueField`
	IsList bool `yaml:"is-list,omitempty"`
	// A single field storing elements of the list, only used if `IsList` is true
	ValueField *Field `yaml:"value-field,omitempty"`
}

Table is a struct that represents a table in a database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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