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 ¶
- func ParseKey(key string) (typeName, namespace string, err error)
- type Store
- func (s *Store) Count() int
- func (s *Store) FlushUpdates() map[string]string
- func (s *Store) Get(typeName, namespace string) *Viewdef
- func (s *Store) GetByKey(key string) *Viewdef
- func (s *Store) GetForType(typeName string) []*Viewdef
- func (s *Store) GetPendingUpdatesJSON() ([]byte, error)
- func (s *Store) Has(typeName, namespace string) bool
- func (s *Store) HasPendingUpdates() bool
- func (s *Store) Keys() []string
- func (s *Store) LoadFromFS(fsys fs.FS) error
- func (s *Store) QueueForType(typeName string)
- func (s *Store) QueueViewdef(viewdef *Viewdef)
- func (s *Store) Remove(typeName, namespace string)
- func (s *Store) ResetSentTypes()
- func (s *Store) Store(viewdef *Viewdef)
- type Viewdef
- type ViewdefManager
- func (m *ViewdefManager) AddNewViewdefsForSession(sessionID, typeName string, defs map[string]string)
- func (m *ViewdefManager) AddViewdef(key, content string)
- func (m *ViewdefManager) ClearSession(sessionID string)
- func (m *ViewdefManager) Count() int
- func (m *ViewdefManager) GetAllViewdefs() map[string]string
- func (m *ViewdefManager) GetNewViewdefsForSession(sessionID, typeName string) map[string]string
- func (m *ViewdefManager) GetSent(sessionID string) map[string]bool
- func (m *ViewdefManager) GetViewdefsForType(typeName string) map[string]string
- func (m *ViewdefManager) LoadFromBundle() error
- func (m *ViewdefManager) LoadFromDirectory(dir string) error
- func (m *ViewdefManager) LoadFromFS(fsys fs.FS, dir string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages viewdef storage and delivery.
func (*Store) FlushUpdates ¶
FlushUpdates returns pending viewdef updates and clears the queue. Returns nil if no updates pending.
func (*Store) Get ¶
Get retrieves a viewdef by TYPE.NAMESPACE. Falls back to TYPE.DEFAULT if TYPE.NAMESPACE not found.
func (*Store) GetForType ¶
GetForType returns all viewdefs for a type.
func (*Store) GetPendingUpdatesJSON ¶
GetPendingUpdatesJSON returns pending updates as JSON for variable 1's viewdefs property.
func (*Store) HasPendingUpdates ¶
HasPendingUpdates checks if there are queued viewdef updates.
func (*Store) LoadFromFS ¶
LoadFromFS loads viewdefs from a filesystem (e.g., embedded or os.DirFS). Expects files at html/viewdefs/TYPE.NAMESPACE.html
func (*Store) QueueForType ¶
QueueForType queues all viewdefs for a type for delivery. Called when a variable of this type needs its viewdefs.
func (*Store) QueueViewdef ¶
QueueViewdef queues a specific viewdef for delivery.
func (*Store) ResetSentTypes ¶
func (s *Store) ResetSentTypes()
ResetSentTypes clears the record of sent types. Call when a new frontend connects.
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 ¶
NewViewdef creates a new viewdef.
func (*Viewdef) GetContent ¶
GetContent returns the HTML template content.
func (*Viewdef) GetNamespace ¶
GetNamespace returns the namespace.
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) 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).