Documentation
¶
Index ¶
- func WithContext(ctx context.Context, adminContext Context) context.Context
- func WriteError(w http.ResponseWriter, status int, requestID, code, message string, ...)
- func WriteJSON(w http.ResponseWriter, status int, requestID string, data any, ...)
- type Action
- func (a *Action) Action(name string, handler any) *Action
- func (a *Action) Audit() *Resource
- func (a *Action) Can(permission string) *Action
- func (a *Action) Danger() *Action
- func (a *Action) Describe(description string) *Action
- func (a *Action) Field(name string) *Field
- func (a *Action) Form(schema any) *Action
- func (a *Action) Policy(policy Policy) *Resource
- func (a *Action) RequireConfirmation() *Action
- func (a *Action) RequireReason() *Action
- func (a *Action) TenantScoped(column string) *Resource
- func (a *Action) WithIcon(icon string) *Action
- func (a *Action) WithTimeout(timeout time.Duration) *Action
- type ActionHandler
- type ActionRequest
- type ActionResult
- type Actor
- type AllowAllPolicy
- type App
- type Context
- type DenyAllPolicy
- type Error
- type Field
- func (f *Field) Action(name string, handler any) *Action
- func (f *Field) Audit() *Resource
- func (f *Field) Badge() *Field
- func (f *Field) BadgeColor(value, color string) *Field
- func (f *Field) BelongsTo(resource any) *Field
- func (f *Field) Boolean() *Field
- func (f *Field) Computed() *Field
- func (f *Field) Date() *Field
- func (f *Field) DateRangeFilter() *Field
- func (f *Field) DateTime() *Field
- func (f *Field) Decimal() *Field
- func (f *Field) DefaultValue(value any) *Field
- func (f *Field) Display(field string) *Field
- func (f *Field) Email() *Field
- func (f *Field) Enum(values ...string) *Field
- func (f *Field) Field(name string) *Field
- func (f *Field) FileUpload() *Field
- func (f *Field) Filterable() *Field
- func (f *Field) Float() *Field
- func (f *Field) ForeignKey(field string) *Field
- func (f *Field) Formatter(name string) *Field
- func (f *Field) HasMany(resource any) *Field
- func (f *Field) Help(text string) *Field
- func (f *Field) Hidden() *Field
- func (f *Field) HiddenInDetail() *Field
- func (f *Field) HiddenInForm() *Field
- func (f *Field) HiddenInList() *Field
- func (f *Field) ImageUpload() *Field
- func (f *Field) Integer() *Field
- func (f *Field) JSON() *Field
- func (f *Field) JSONB() *Field
- func (f *Field) Markdown() *Field
- func (f *Field) Money(currency string) *Field
- func (f *Field) Nullable() *Field
- func (f *Field) Number() *Field
- func (f *Field) Parser(name string) *Field
- func (f *Field) Password() *Field
- func (f *Field) Placeholder(text string) *Field
- func (f *Field) Policy(policy Policy) *Resource
- func (f *Field) Primary() *Field
- func (f *Field) Readonly() *Field
- func (f *Field) RelationTo(resource any) *Field
- func (f *Field) Renderer(name string) *Field
- func (f *Field) Required() *Field
- func (f *Field) RichText() *Field
- func (f *Field) Searchable() *Field
- func (f *Field) Sortable() *Field
- func (f *Field) String() *Field
- func (f *Field) TenantKey() *Field
- func (f *Field) TenantScoped(column string) *Resource
- func (f *Field) Text() *Field
- func (f *Field) Time() *Field
- func (f *Field) UUID() *Field
- func (f *Field) Unique() *Field
- func (f *Field) Validation(rules ...string) *Field
- type FieldType
- type Filter
- type Policy
- type Relation
- type Resource
- func (r *Resource) Action(name string, handler any) *Action
- func (r *Resource) ActionByName(name string) (*Action, bool)
- func (r *Resource) Audit() *Resource
- func (r *Resource) Description(description string) *Resource
- func (r *Resource) Field(name string) *Field
- func (r *Resource) FieldByName(name string) (*Field, bool)
- func (r *Resource) Group(group string) *Resource
- func (r *Resource) Icon(icon string) *Resource
- func (r *Resource) Label(label string) *Resource
- func (r *Resource) PageSize(size int) *Resource
- func (r *Resource) PluralLabel(label string) *Resource
- func (r *Resource) Policy(policy Policy) *Resource
- func (r *Resource) Primary(primaryKey string) *Resource
- func (r *Resource) Sort(sort string) *Resource
- func (r *Resource) TableName(table string) *Resource
- func (r *Resource) TenantScoped(column string) *Resource
- func (r *Resource) Visible(rule Rule) *Resource
- type Response
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
Types ¶
type Action ¶
type Action struct {
Resource *Resource `json:"-"`
Name string `json:"name"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Dangerous bool `json:"danger"`
RequiresConfirm bool `json:"requires_confirmation"`
RequiresReason bool `json:"requires_reason"`
InputSchema any `json:"input_schema,omitempty"`
Permission string `json:"permission,omitempty"`
Handler any `json:"-"`
Timeout string `json:"timeout,omitempty"`
}
func (*Action) RequireConfirmation ¶
func (*Action) RequireReason ¶
func (*Action) TenantScoped ¶
type ActionHandler ¶
type ActionHandler func(context.Context, ActionRequest[map[string]any]) (ActionResult, error)
ActionHandler is the runtime-compatible action handler signature.
type ActionRequest ¶
type ActionRequest[T any] struct { Context Context Actor Actor Resource *Resource ResourceID string Input T Selected []string Reason string }
ActionRequest is passed to custom action handlers.
type ActionResult ¶
type ActionResult struct {
Message string `json:"message"`
Redirect string `json:"redirect,omitempty"`
Data map[string]any `json:"data,omitempty"`
}
ActionResult is a structured response from an action.
type Actor ¶
type AllowAllPolicy ¶
type AllowAllPolicy struct{}
type App ¶
type App struct {
// contains filtered or unexported fields
}
App holds the resource registry used by generators and runtime handlers.
func (*App) GetResource ¶
GetResource returns a resource by name.
type DenyAllPolicy ¶
type DenyAllPolicy struct{}
type Field ¶
type Field struct {
Resource *Resource `json:"-"`
Name string `json:"name"`
Label string `json:"label"`
Type FieldType `json:"type"`
RequiredValue bool `json:"required"`
UniqueValue bool `json:"unique"`
NullableValue bool `json:"nullable"`
SearchableValue bool `json:"searchable"`
SortableValue bool `json:"sortable"`
FilterableValue bool `json:"filterable"`
ReadonlyValue bool `json:"readonly"`
HiddenValue bool `json:"hidden"`
HiddenInListValue bool `json:"hidden_in_list"`
HiddenInFormValue bool `json:"hidden_in_form"`
HiddenInDetailValue bool `json:"hidden_in_detail"`
PrimaryValue bool `json:"primary"`
TenantKeyValue bool `json:"tenant_key"`
DefaultValueValue any `json:"default_value,omitempty"`
ValidationRules []string `json:"validation,omitempty"`
HelpTextValue string `json:"help_text,omitempty"`
PlaceholderValue string `json:"placeholder,omitempty"`
BadgeColors map[string]string `json:"badge_colors,omitempty"`
EnumValues []string `json:"enum_values,omitempty"`
Currency string `json:"currency,omitempty"`
Relation *Relation `json:"relation,omitempty"`
RendererName string `json:"renderer,omitempty"`
FormatterName string `json:"formatter,omitempty"`
ParserName string `json:"parser,omitempty"`
}
func (*Field) BadgeColor ¶
func (*Field) DateRangeFilter ¶
func (*Field) DefaultValue ¶
func (*Field) FileUpload ¶
func (*Field) Filterable ¶
func (*Field) ForeignKey ¶
func (*Field) HiddenInDetail ¶
func (*Field) HiddenInForm ¶
func (*Field) HiddenInList ¶
func (*Field) ImageUpload ¶
func (*Field) Placeholder ¶
func (*Field) RelationTo ¶
func (*Field) Searchable ¶
func (*Field) TenantScoped ¶
func (*Field) Validation ¶
type FieldType ¶
type FieldType string
const ( FieldString FieldType = "string" FieldText FieldType = "text" FieldEmail FieldType = "email" FieldPassword FieldType = "password" FieldNumber FieldType = "number" FieldInteger FieldType = "integer" FieldFloat FieldType = "float" FieldDecimal FieldType = "decimal" FieldMoney FieldType = "money" FieldBoolean FieldType = "boolean" FieldEnum FieldType = "enum" FieldStatus FieldType = "status" FieldDate FieldType = "date" FieldDateTime FieldType = "datetime" FieldTime FieldType = "time" FieldUUID FieldType = "uuid" FieldJSON FieldType = "json" FieldJSONB FieldType = "jsonb" FieldMarkdown FieldType = "markdown" FieldRichText FieldType = "rich_text" FieldImage FieldType = "image" FieldFile FieldType = "file" FieldRelation FieldType = "relation" FieldComputed FieldType = "computed" )
type Policy ¶
type Policy interface {
CanView(ctx Context, actor Actor, row any) bool
CanCreate(ctx Context, actor Actor) bool
CanUpdate(ctx Context, actor Actor, row any) bool
CanDelete(ctx Context, actor Actor, row any) bool
}
Policy allows resource-level and row-level permission decisions.
type Resource ¶
type Resource struct {
Name string `json:"name"`
LabelText string `json:"label"`
PluralText string `json:"plural_label"`
IconName string `json:"icon"`
DescriptionText string `json:"description"`
Table string `json:"table"`
PrimaryKey string `json:"primary_key"`
DefaultSort string `json:"default_sort"`
DefaultFilters []Filter `json:"default_filters,omitempty"`
DefaultPageSize int `json:"default_page_size"`
VisibleWhen Rule `json:"-"`
Fields []*Field `json:"fields"`
Actions []*Action `json:"actions"`
PolicyValue Policy `json:"-"`
AuditEnabled bool `json:"audit_enabled"`
TenantColumn string `json:"tenant_column,omitempty"`
}
Resource describes an admin-managed database-backed entity.
func (*Resource) Description ¶
func (*Resource) PluralLabel ¶
func (*Resource) TenantScoped ¶
Click to show internal directories.
Click to hide internal directories.