Documentation
¶
Overview ¶
Package definitions carries the content definitions a plugin declares into the registry.
Index ¶
- Constants
- Variables
- func Adopt(ctx context.Context, registry *content.Registry, held Held) error
- func ReadableFormat(declared string) error
- type Change
- type Confirmed
- type Drift
- type Envelope
- type FieldDefinition
- type GroupDefinition
- type Held
- type Import
- type Outcome
- type Plan
- type Registrar
- func (r *Registrar) DeclareField(ctx context.Context, groupKey string, declared sdk.FieldDeclaration) error
- func (r *Registrar) DeclareGroup(ctx context.Context, declared sdk.GroupDeclaration) error
- func (r *Registrar) DeclareType(ctx context.Context, declared sdk.TypeDeclaration) error
- func (r *Registrar) Declared() []Held
- func (r *Registrar) Skipped() []Held
- type Stray
- type TypeDefinition
- type Walk
- type Walked
- type Warning
Constants ¶
const ( ActionCreate = "create" ActionUpdate = "update" ActionDelete = "delete" )
The actions a planned change stands for.
const ( SubjectType = "type" SubjectGroup = "group" SubjectField = "field" )
The definitions a planned change stands over.
const ( ReasonRemoved = "removed" ReasonKindChanged = "kind_changed" ReasonShapeChanged = "shape_changed" ReasonMoved = "moved" )
The reasons a planned change takes a definition away.
const ( WarningRootMoved = "root_moved" WarningRouteWordChanged = "route_word_changed" )
The changes an import reaches beyond the definitions to make.
const Format = "1.0.0"
Format is the version of the definitions envelope this build writes.
const ReasonRootKept = "root_kept"
ReasonRootKept names the root an import left where the site already had it.
Variables ¶
var ErrFormatUnreadable = errors.New("definitions: the format marker is not a plain version")
ErrFormatUnreadable reports an envelope whose format marker is not three plain numbers.
var ErrFormatUnsupported = errors.New("definitions: the format is not one this release reads")
ErrFormatUnsupported reports an envelope written under a format this release does not read.
var ErrKindChanged = errors.New("definitions: the kind of a declared field cannot change")
ErrKindChanged reports a plugin declaring a field under a kind other than the stored one.
var ErrRouteWordChanged = errors.New("definitions: the route word of a declared type cannot change")
ErrRouteWordChanged reports a plugin declaring a type under a route word other than the stored one.
var ErrShapeChanged = errors.New("definitions: the shape of a declared field cannot change")
ErrShapeChanged reports a plugin declaring a field whose relation target or cardinality is not the stored one.
var ErrSubjectUnknown = errors.New("definitions: no definition answers to that subject")
ErrSubjectUnknown reports a definition named as something the site does not hold.
Functions ¶
func ReadableFormat ¶
ReadableFormat returns the reason the declared format cannot be read, or nothing when it can.
Types ¶
type Change ¶
type Change struct {
Action string `json:"action"`
Subject string `json:"subject"`
Key string `json:"key"`
Group string `json:"group,omitempty"`
Label string `json:"label"`
Reason string `json:"reason,omitempty"`
}
Change is one definition an import would add, carry over, or take away.
type Confirmed ¶
type Confirmed struct {
Subject string `json:"subject"`
Key string `json:"key"`
Group string `json:"group,omitempty"`
}
Confirmed names one change an import may take away.
type Drift ¶
Drift is what the site holds that no plugin declares, and what a plugin declares that the site holds.
type Envelope ¶
type Envelope struct {
Format string `json:"format"`
Types []TypeDefinition `json:"types"`
Groups []GroupDefinition `json:"groups"`
}
Envelope is the site's own content definitions as the admin downloads them.
type FieldDefinition ¶
type FieldDefinition struct {
Key string `json:"key"`
Label string `json:"label"`
Kind string `json:"kind"`
RelatesTo string `json:"relates_to,omitempty"`
Many bool `json:"many"`
Required bool `json:"required"`
Settings map[string]any `json:"settings,omitempty"`
Fields []FieldDefinition `json:"fields,omitempty"`
}
FieldDefinition is one field as the envelope carries it, its sub fields in stored order.
type GroupDefinition ¶
type GroupDefinition struct {
Key string `json:"key"`
Title string `json:"title"`
Location content.Rules `json:"location"`
Active bool `json:"active"`
Fields []FieldDefinition `json:"fields"`
}
GroupDefinition is one field group as the envelope carries it, its fields in stored order.
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar carries one plugin's declarations into the content registry, skipping what the site already holds.
func (*Registrar) DeclareField ¶
func (r *Registrar) DeclareField(ctx context.Context, groupKey string, declared sdk.FieldDeclaration) error
DeclareField stores the field inside the plugin's group carrying the key, or carries changes onto a stored one.
func (*Registrar) DeclareGroup ¶
DeclareGroup stores the group with its fields, carries changes onto a stored one, or skips a key it does not own.
func (*Registrar) DeclareType ¶
DeclareType stores the type, carries its labels onto a stored one, or skips a key the plugin does not own.
type Stray ¶
type Stray struct {
Subject string `json:"subject"`
Key string `json:"key"`
Origin string `json:"origin"`
Label string `json:"label"`
}
Stray is one definition standing apart from what the plugins declare.
type TypeDefinition ¶
type TypeDefinition struct {
Key string `json:"key"`
SingularLabel string `json:"singular_label"`
PluralLabel string `json:"plural_label"`
RouteWord string `json:"route_word"`
Hierarchical bool `json:"hierarchical"`
Revisions bool `json:"revisions"`
RevisionCap int `json:"revision_cap"`
PageKind string `json:"page_kind"`
Default bool `json:"default"`
Active bool `json:"active"`
}
TypeDefinition is one content type as the envelope carries it.