viewdef

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

CRC: crc-ViewdefStore.md Spec: viewdefs.md

Package viewdef provides viewdef management. CRC: crc-Viewdef.md Spec: viewdefs.md

ViewdefManager loads and serves viewdefs to frontend sessions. Spec: viewdefs.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseKey

func ParseKey(key string) (typeName, namespace string, err error)

ParseKey parses a TYPE.NAMESPACE key into type and namespace.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages viewdef storage and delivery.

func NewStore

func NewStore() *Store

NewStore creates a new viewdef store.

func (*Store) Count

func (s *Store) Count() int

Count returns the number of stored viewdefs.

func (*Store) FlushUpdates

func (s *Store) FlushUpdates() map[string]string

FlushUpdates returns pending viewdef updates and clears the queue. Returns nil if no updates pending.

func (*Store) Get

func (s *Store) Get(typeName, namespace string) *Viewdef

Get retrieves a viewdef by TYPE.NAMESPACE. Falls back to TYPE.DEFAULT if TYPE.NAMESPACE not found.

func (*Store) GetByKey

func (s *Store) GetByKey(key string) *Viewdef

GetByKey retrieves a viewdef by TYPE.NAMESPACE key.

func (*Store) GetForType

func (s *Store) GetForType(typeName string) []*Viewdef

GetForType returns all viewdefs for a type.

func (*Store) GetPendingUpdatesJSON

func (s *Store) GetPendingUpdatesJSON() ([]byte, error)

GetPendingUpdatesJSON returns pending updates as JSON for variable 1's viewdefs property.

func (*Store) Has

func (s *Store) Has(typeName, namespace string) bool

Has checks if a viewdef exists.

func (*Store) HasPendingUpdates

func (s *Store) HasPendingUpdates() bool

HasPendingUpdates checks if there are queued viewdef updates.

func (*Store) Keys

func (s *Store) Keys() []string

Keys returns all viewdef keys.

func (*Store) LoadFromFS

func (s *Store) LoadFromFS(fsys fs.FS) error

LoadFromFS loads viewdefs from a filesystem (e.g., embedded or os.DirFS). Expects files at html/viewdefs/TYPE.NAMESPACE.html

func (*Store) QueueForType

func (s *Store) QueueForType(typeName string)

QueueForType queues all viewdefs for a type for delivery. Called when a variable of this type needs its viewdefs.

func (*Store) QueueViewdef

func (s *Store) QueueViewdef(viewdef *Viewdef)

QueueViewdef queues a specific viewdef for delivery.

func (*Store) Remove

func (s *Store) Remove(typeName, namespace string)

Remove deletes a viewdef.

func (*Store) ResetSentTypes

func (s *Store) ResetSentTypes()

ResetSentTypes clears the record of sent types. Call when a new frontend connects.

func (*Store) Store

func (s *Store) Store(viewdef *Viewdef)

Store adds or replaces a viewdef.

type Viewdef

type Viewdef struct {
	Type      string // Type name (e.g., "Contact")
	Namespace string // Namespace (e.g., "DEFAULT", "COMPACT", "OPTION")
	Content   string // HTML template content
}

Viewdef represents a view definition template.

func NewViewdef

func NewViewdef(typeName, namespace, content string) *Viewdef

NewViewdef creates a new viewdef.

func (*Viewdef) GetContent

func (v *Viewdef) GetContent() string

GetContent returns the HTML template content.

func (*Viewdef) GetNamespace

func (v *Viewdef) GetNamespace() string

GetNamespace returns the namespace.

func (*Viewdef) GetType

func (v *Viewdef) GetType() string

GetType returns the type name.

func (*Viewdef) Key

func (v *Viewdef) Key() string

Key returns the TYPE.NAMESPACE identifier string.

type ViewdefManager

type ViewdefManager struct {
	// contains filtered or unexported fields
}

ViewdefManager manages viewdef loading and tracking.

func NewViewdefManager

func NewViewdefManager() *ViewdefManager

NewViewdefManager creates a new viewdef manager.

func (*ViewdefManager) AddNewViewdefsForSession

func (m *ViewdefManager) AddNewViewdefsForSession(sessionID, typeName string, defs map[string]string)

GetNewViewdefsForSession returns viewdefs for a type that haven't been sent to this session yet. Marks the type as sent for this session.

func (*ViewdefManager) AddViewdef

func (m *ViewdefManager) AddViewdef(key, content string)

AddViewdef adds or updates a viewdef dynamically.

func (*ViewdefManager) ClearSession

func (m *ViewdefManager) ClearSession(sessionID string)

ClearSession removes tracking data for a session.

func (*ViewdefManager) Count

func (m *ViewdefManager) Count() int

Count returns the number of loaded viewdefs.

func (*ViewdefManager) GetAllViewdefs

func (m *ViewdefManager) GetAllViewdefs() map[string]string

GetAllViewdefs returns all loaded viewdefs.

func (*ViewdefManager) GetNewViewdefsForSession

func (m *ViewdefManager) GetNewViewdefsForSession(sessionID, typeName string) map[string]string

GetNewViewdefsForSession returns viewdefs for a type that haven't been sent to this session yet. Marks the type as sent for this session.

func (*ViewdefManager) GetSent

func (m *ViewdefManager) GetSent(sessionID string) map[string]bool

func (*ViewdefManager) GetViewdefsForType

func (m *ViewdefManager) GetViewdefsForType(typeName string) map[string]string

GetViewdefsForType returns all viewdefs for a given type. Returns a map of TYPE.NAMESPACE -> HTML content

func (*ViewdefManager) LoadFromBundle

func (m *ViewdefManager) LoadFromBundle() error

LoadFromBundle loads viewdefs from the embedded bundle.

func (*ViewdefManager) LoadFromDirectory

func (m *ViewdefManager) LoadFromDirectory(dir string) error

LoadFromDirectory loads viewdefs from a directory. Files should be named TYPE.NAMESPACE.html (e.g., Adder.DEFAULT.html)

func (*ViewdefManager) LoadFromFS

func (m *ViewdefManager) LoadFromFS(fsys fs.FS, dir string) error

LoadFromFS loads viewdefs from a filesystem (for custom site directories).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL