Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Specialize ¶
Specialize builds the per-kind Query rule — the port of catalog.ts specializeQuerySchema (L20-43). A registered kind does not validate against the generic Query schema: its `property`, `rel` and `sort.by` are narrowed to what that kind actually exposes, `kind` becomes required, and `spec.sort` gains a default of the kind's natural order.
Doing it in the SCHEMA rather than as a post-validation check is what produces Joi's `any.only` error naming the alternatives ("must be one of [name, id, …]") instead of a bespoke sentence. The caller gets the list of properties they could have used, which is the whole point of the message.
props/rels are ORDERED: the order reaches the user as the order of the valids in that message, and TS's comes from Object.keys() over the registration literal.
Types ¶
type Query ¶
type Query struct {
Kind base.Kind `json:"kind,omitzero"`
Context *QueryContext `json:"context,omitzero" validate:"readOnly"`
Fetch QueryFetch `json:"fetch,omitzero" validate:"default=items,optional"`
Spec *Spec `json:"spec,omitzero"`
}
type QueryContext ¶
type QueryFetch ¶
type QueryFetch string
const ( QueryFetchLinks QueryFetch = "links" QueryFetchItems QueryFetch = "items" )
func (QueryFetch) EnumValues ¶
func (QueryFetch) EnumValues() []string
EnumValues ports `Joi.string().valid('links','items')` (query.ts fetch).
type QueryResult ¶
type QueryResultKind ¶
type QueryResultKind string
const (
QueryResultKindQueryresult QueryResultKind = "queryresult"
)
type SpecMatch ¶
type SpecMatch string
func (SpecMatch) EnumValues ¶
EnumValues ports `Joi.string().valid('all','any','none')` (query.ts match).
type SpecSort ¶
type SpecSort struct {
By string `json:"by" validate:"required"`
Order SpecSortOrder `json:"order,omitzero" validate:"default=asc"`
}
type SpecSortOrder ¶
type SpecSortOrder string
const ( SpecSortOrderAsc SpecSortOrder = "asc" SpecSortOrderDesc SpecSortOrder = "desc" )
func (SpecSortOrder) EnumValues ¶
func (SpecSortOrder) EnumValues() []string
EnumValues ports `Joi.string().valid('asc','desc')` (query.ts sort.order).
type Term ¶
type Term struct {
Op TermOp `json:"op,omitzero" validate:"trim,default=="`
Property string `json:"property,omitzero" validate:"trim"`
Rel string `json:"rel,omitzero" validate:"trim"`
Tag string `json:"tag,omitzero" validate:"trim"`
Value TermValue `json:"value,omitzero"`
}
func (Term) ValidationRule ¶
ValidationRule ports the Term object rule (query.ts:6-37): the tagged fields plus the value presence/type rules, the xor, and the tag-value coercion.
type TermOp ¶
type TermOp string
func (TermOp) EnumValues ¶
EnumValues ports the Term.op `Joi.string().valid(...)` enum (query.ts:7-10), in Joi's declaration order so the "must be one of [...]" message matches.