Documentation
¶
Index ¶
- Constants
- Variables
- func EscapeName(name string) string
- func ParseAnchor(s string, siblings []RepeatableRef) (string, error)
- func UnescapeName(name string) (string, error)
- type Anchor
- type BlockDef
- type FieldDef
- type Kind
- type NestedBlocks
- type Option
- type ParseError
- type Path
- type RepeatableRef
- type ResolveError
- type Resolved
- type Schema
- func (s *Schema) BlockSlugs(canvas string) []string
- func (s *Schema) BlockSlugsFor(canvas, parentSlug string) []string
- func (s *Schema) Blocks(canvas string) []BlockDef
- func (s *Schema) BlocksFor(canvas, parentSlug string) []BlockDef
- func (s *Schema) FieldType(canvas, slug, field string) string
- func (s Schema) MarshalJSON() ([]byte, error)
- func (s *Schema) OptionsFor(canvas, repeatableSlug, field string) []Option
- func (s *Schema) UnmarshalJSON(data []byte) error
- type Segment
- type Selector
- type Template
Constants ¶
const ( ResolveKindIndex = "index_out_of_range" ResolveKindEditable = "editable_not_found" ResolveKindPage = "page_editable_not_found" ResolveKindSlug = "ambiguous_slug" ResolveKindID = "repeatable_id_not_found" ResolveKindDepth = "depth_exceeded" )
ResolveError kinds used in CLI JSON details.
const ( SelIndex = iota SelID SelSlug )
Selector kinds.
const ( AnchorOmit = iota AnchorNull AnchorID AnchorNoop )
Anchor modes distinguish omit / JSON null / id / no-op.
Variables ¶
var ErrAnchorNoop = errors.New("move is a no-op")
ErrAnchorNoop is returned by AnchorForMove when the item is already at target.
Functions ¶
func EscapeName ¶
EscapeName encodes an editable name for a raw API path. It uses url.PathEscape (%20 for spaces, never +) so Rails CGI.unescape round-trips names including spaces and en-dashes.
func ParseAnchor ¶
func ParseAnchor(s string, siblings []RepeatableRef) (string, error)
ParseAnchor resolves a 24-hex id or integer index to a sibling id.
func UnescapeName ¶
UnescapeName decodes a raw-path name segment.
Types ¶
type Anchor ¶
Anchor is a tri-state insert/move cursor.
func AnchorForInsert ¶
func AnchorForInsert(siblings []RepeatableRef, position int) (Anchor, error)
AnchorForInsert returns the batch `after` value for inserting at a 0-based index. 0 → explicit null (beginning); N → id of sibling N-1; N > len → omit (append).
func AnchorForMove ¶
func AnchorForMove(siblings []RepeatableRef, currentIndex, targetIndex int) (Anchor, error)
AnchorForMove returns the batch `after` value for moving currentIndex to targetIndex.
type BlockDef ¶
type BlockDef struct {
Slug string `json:"slug"`
Label string `json:"label"`
Fields []FieldDef `json:"fields"`
AvailableBlocks map[string][]BlockDef `json:"available_blocks,omitempty"`
}
BlockDef is one available repeatable slug for a canvas.
type FieldDef ¶
type FieldDef struct {
Slug string `json:"slug"`
Label string `json:"label"`
Type string `json:"type"`
Options []Option `json:"options"`
Reference string `json:"reference"`
AvailableBlocks NestedBlocks `json:"available_blocks,omitempty"`
}
FieldDef is one editable inside a block definition.
type NestedBlocks ¶
type NestedBlocks []BlockDef
NestedBlocks is available_blocks on a canvas field: a live array, or a keyed object.
func (*NestedBlocks) UnmarshalJSON ¶
func (n *NestedBlocks) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts both `[{block}, ...]` and `{"CanvasName":[{block}, ...]}`.
type ParseError ¶
ParseError is a structured failure while parsing a human or raw page path.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Path ¶
Path is a parsed human or raw page path.
type RepeatableRef ¶
RepeatableRef is one repeatable in position order.
type ResolveError ¶
type ResolveError struct {
Path string
Kind string
Candidates []string
// contains filtered or unexported fields
}
ResolveError lists candidates so an agent can correct a path in one step.
func (*ResolveError) Error ¶
func (e *ResolveError) Error() string
type Resolved ¶
type Resolved struct {
RawPath string
Kind Kind
Type string
RepeatableID string
RepeatableSlug string
Index int
ParentCanvasRaw string
Siblings []RepeatableRef
Value any
}
Resolved is a human path mapped onto a page document.
type Schema ¶
type Schema struct {
Template Template
AvailableBlocks map[string][]BlockDef
SelectOptions map[string][]Option
CurrentStructure json.RawMessage
// contains filtered or unexported fields
}
Schema mirrors GET /pages/{id}/schema.
func (*Schema) BlockSlugs ¶
BlockSlugs returns available repeatable slugs for a top-level canvas, in schema order.
func (*Schema) BlockSlugsFor ¶
BlockSlugsFor returns available slugs for a canvas, optionally nested under parentSlug.
func (*Schema) Blocks ¶
Blocks returns available block definitions for a top-level canvas, in schema order.
func (*Schema) BlocksFor ¶
BlocksFor returns block definitions for a canvas. parentSlug selects a nested canvas on that parent repeatable (live available_blocks on the canvas field).
func (Schema) MarshalJSON ¶
MarshalJSON returns the original API body when it was captured.
func (*Schema) OptionsFor ¶
OptionsFor returns select options for a field. Top-level fields use canvas="" and repeatableSlug="".
func (*Schema) UnmarshalJSON ¶
UnmarshalJSON accepts the real object-shaped schema and the empty/array stubs.