Documentation
¶
Index ¶
- Variables
- func OptionValues(options ...Option) utils.Set[string]
- func WithCredentials(ctx context.Context, creds *Credentials) context.Context
- type AMQP
- type Credentials
- type Field
- type FieldError
- type Form
- type NotifyContext
- type Option
- type Policy
- type RequestContext
- type ResultContext
- type Template
- type Type
- type Webhook
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func WithCredentials ¶ added in v0.2.0
func WithCredentials(ctx context.Context, creds *Credentials) context.Context
Types ¶
type AMQP ¶ added in v0.3.0
type AMQP struct {
Exchange string // Exchange name, can be empty
Key Template[NotifyContext] // Routing key, usually required
Retry int // maximum number of retries (negative means no retries)
Timeout time.Duration // publish timeout
Interval time.Duration // interval between attempts (publish message)
Headers map[string]string // arbitrary headers (only string supported)
Type string // optional content type property; if not set and message is nil, type is set to application/json
Correlation Template[NotifyContext] // optional correlation ID template (commonly result ID)
ID Template[NotifyContext] // optional correlation ID template (commonly result ID), useful for client-side deduplication
Message Template[NotifyContext] // payload content, if not set - JSON representation of storage result
}
type Credentials ¶ added in v0.2.0
func CredentialsFromContext ¶ added in v0.2.0
func CredentialsFromContext(ctx context.Context) *Credentials
type Field ¶
type Field struct {
Name string // column name in database.
Label string // short name of field which will be shown in UI, if not set - [Field.Name] is used.
Description string // (markdown) optional description for the field, also shown in UI as help text.
Required bool // make field as required: empty values will not be accepted as well as at least one option should be selected.
Disabled bool // user input will be ignored, by field will be visible in UI. Doesn't apply for options.
Hidden bool // user input will be ignored, field not visible in UI
Default Template[RequestContext] // golang template expression for the default value. Doesn't apply for options with [Field.Multiple].
Type Type // (default [TypeString]) field type used for user input validation.
Pattern string // optional regexp to validate content, applicable only for string type
Options []Option // allowed values. If [Field.Multiple] set, it acts as "any of", otherwise "one of".
Multiple bool // allow picking multiple options. Column type in database MUST be ARRAY of corresponding type.
Multiline bool // multiline input (for [TypeString] only)
Icon string // optional MDI icon
}
type FieldError ¶ added in v0.4.0
func ParseForm ¶ added in v0.4.0
func ParseForm(definition *Form, tzLocation *time.Location, viewCtx *RequestContext) (map[string]any, []FieldError)
ParseForm converts user request to parsed field.
type Form ¶
type Form struct {
Name string // unique form name, if not set - file name without extension will be used.
Table string // database table name
Title string // optional title for the form
Description Template[RequestContext] // (markdown) optional description of the form
Fields []Field // form fields
Webhooks []Webhook // Webhook (HTTP) notification
AMQP []AMQP // AMQP notification
Success Template[ResultContext] // markdown message for success (also go template with available .Result)
Failed Template[ResultContext] // markdown message for failed (also go template with .Error)
Policy *Policy // optional access policy
Codes utils.Set[string] // optional access tokens
}
func (*Form) HasCodeAccess ¶ added in v0.4.0
func (*Form) IsAllowed ¶ added in v0.2.0
func (f *Form) IsAllowed(creds *Credentials) bool
IsAllowed checks permission for the provided credentials. Always allowed for nil policy or for nil creds, and always prohibited if policy returns non-boolean value.
type NotifyContext ¶ added in v0.4.0
NotifyContext is used for rendering notification message.
type Policy ¶ added in v0.2.0
func (*Policy) UnmarshalText ¶ added in v0.2.0
type RequestContext ¶ added in v0.4.0
type RequestContext struct {
Headers http.Header
Query url.Values
Form url.Values
Code string // access code
Credentials *Credentials // optional user credentials
}
RequestContext is used for rendering default values.
func (*RequestContext) Email ¶ added in v0.4.0
func (rc *RequestContext) Email() string
func (*RequestContext) Groups ¶ added in v0.4.0
func (rc *RequestContext) Groups() []string
func (*RequestContext) User ¶ added in v0.4.0
func (rc *RequestContext) User() string
type ResultContext ¶ added in v0.4.0
ResultContext is used for rendering result message (success or fail).
type Webhook ¶
type Webhook struct {
URL string // URL for POST webhook, where payload is JSON with fields from database column.
Method string // HTTP method to perform, default is POST
Retry int // maximum number of retries (negative means no retries)
Timeout time.Duration // request timeout
Interval time.Duration // interval between attempts (for non 2xx code)
Headers map[string]string // arbitrary headers (ex: Authorization)
Message Template[NotifyContext] // payload content, if not set - JSON representation of storage result
}
Click to show internal directories.
Click to hide internal directories.