Documentation
¶
Index ¶
- type MarkdownV2
- func (m *MarkdownV2) Close() error
- func (m *MarkdownV2) CreateBlock(date time.Time, blk block.Block) error
- func (m *MarkdownV2) CreateTemplate(t storage.Template) error
- func (m *MarkdownV2) DeleteBlock(blockID string) error
- func (m *MarkdownV2) DeleteDay(date time.Time) error
- func (m *MarkdownV2) DeleteTemplate(id string) error
- func (m *MarkdownV2) GetBlock(blockID string) (block.Block, time.Time, error)
- func (m *MarkdownV2) GetDay(date time.Time) (day.Day, error)
- func (m *MarkdownV2) GetTemplate(id string) (storage.Template, error)
- func (m *MarkdownV2) GetTemplateByName(name string) (storage.Template, error)
- func (m *MarkdownV2) ListBlocks(date time.Time) ([]block.Block, error)
- func (m *MarkdownV2) ListDays(opts storage.ListDaysOptions) ([]storage.DaySummary, error)
- func (m *MarkdownV2) ListTemplates() ([]storage.Template, error)
- func (m *MarkdownV2) SearchBlocks(opts storage.SearchOptions) ([]storage.BlockResult, error)
- func (m *MarkdownV2) UpdateBlock(blockID string, content string, attributes map[string]string) error
- func (m *MarkdownV2) UpdateTemplate(id string, name string, content string, attributes map[string]string) (storage.Template, error)
- type Store
- func (s *Store) AttachContext(entryID string, contextID string) error
- func (s *Store) Close() error
- func (s *Store) Create(e entry.Entry) error
- func (s *Store) CreateContext(c storage.Context) error
- func (s *Store) CreateTemplate(t storage.Template) error
- func (s *Store) Delete(id string) error
- func (s *Store) DeleteContext(id string) error
- func (s *Store) DeleteTemplate(id string) error
- func (s *Store) DetachContext(entryID string, contextID string) error
- func (s *Store) Get(id string) (entry.Entry, error)
- func (s *Store) GetContext(id string) (storage.Context, error)
- func (s *Store) GetContextByName(name string) (storage.Context, error)
- func (s *Store) GetTemplate(id string) (storage.Template, error)
- func (s *Store) GetTemplateByName(name string) (storage.Template, error)
- func (s *Store) List(opts storage.ListOptions) ([]entry.Entry, error)
- func (s *Store) ListContexts() ([]storage.Context, error)
- func (s *Store) ListDays(opts storage.ListDaysOptions) ([]storage.DaySummary, error)
- func (s *Store) ListTemplates() ([]storage.Template, error)
- func (s *Store) Update(id string, content string, templates []entry.TemplateRef) (entry.Entry, error)
- func (s *Store) UpdateTemplate(id string, name string, content string, attributes map[string]string) (storage.Template, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MarkdownV2 ¶
type MarkdownV2 struct {
// contains filtered or unexported fields
}
MarkdownV2 implements storage.StorageV2 interface using JSON files. Days are stored as JSON files in a days/ subdirectory. Templates are stored as JSON files in a templates/ subdirectory.
func NewV2 ¶
func NewV2(basePath string) (*MarkdownV2, error)
NewV2 creates a new MarkdownV2 storage instance. It ensures the necessary directories exist (days/, templates/).
Parameters:
- basePath: The base directory where storage files will be created
Returns an error if directory creation fails.
func (*MarkdownV2) Close ¶
func (m *MarkdownV2) Close() error
Close closes the storage connection and releases any resources. For file-based storage, this is a no-op.
func (*MarkdownV2) CreateBlock ¶
CreateBlock creates a new block for the given date. The date will be normalized to midnight local time. The block's ID, CreatedAt, and UpdatedAt timestamps MUST be set by the caller.
func (*MarkdownV2) CreateTemplate ¶
func (m *MarkdownV2) CreateTemplate(t storage.Template) error
CreateTemplate creates a new template with attributes. The template's ID, CreatedAt, and UpdatedAt timestamps MUST be set by the caller. Implementations SHOULD validate these fields and return ErrValidation if they are missing or invalid.
func (*MarkdownV2) DeleteBlock ¶
func (m *MarkdownV2) DeleteBlock(blockID string) error
DeleteBlock deletes a block by ID. Returns ErrNotFound if the block doesn't exist. Returns ErrValidation if blockID is empty.
func (*MarkdownV2) DeleteDay ¶
func (m *MarkdownV2) DeleteDay(date time.Time) error
DeleteDay deletes a day and all its blocks. Returns ErrNotFound if the day doesn't exist.
func (*MarkdownV2) DeleteTemplate ¶
func (m *MarkdownV2) DeleteTemplate(id string) error
DeleteTemplate deletes a template by ID. Returns ErrNotFound if the template doesn't exist. Returns ErrValidation if id is empty.
func (*MarkdownV2) GetBlock ¶
GetBlock returns a block by ID along with the date it belongs to. Returns ErrNotFound if the block doesn't exist. Returns ErrValidation if blockID is empty.
func (*MarkdownV2) GetDay ¶
GetDay returns the day for the given date, creating an empty day if it doesn't exist. The date parameter will be normalized to midnight local time.
func (*MarkdownV2) GetTemplate ¶
func (m *MarkdownV2) GetTemplate(id string) (storage.Template, error)
GetTemplate returns a template by ID. Returns ErrNotFound if the template doesn't exist. Returns ErrValidation if id is empty.
func (*MarkdownV2) GetTemplateByName ¶
func (m *MarkdownV2) GetTemplateByName(name string) (storage.Template, error)
GetTemplateByName returns a template by name. Returns ErrNotFound if the template doesn't exist. Returns ErrValidation if name is empty.
func (*MarkdownV2) ListBlocks ¶
ListBlocks returns all blocks for the given date, ordered by CreatedAt ascending. Returns an empty slice if no blocks exist for the date.
func (*MarkdownV2) ListDays ¶
func (m *MarkdownV2) ListDays(opts storage.ListDaysOptions) ([]storage.DaySummary, error)
ListDays returns a list of day summaries matching the filter criteria. Days are returned in descending order by date (most recent first). TODO: Implement ListDays - scan days directory, filter by opts, return summaries
func (*MarkdownV2) ListTemplates ¶
func (m *MarkdownV2) ListTemplates() ([]storage.Template, error)
ListTemplates returns all templates ordered by name ascending.
func (*MarkdownV2) SearchBlocks ¶
func (m *MarkdownV2) SearchBlocks(opts storage.SearchOptions) ([]storage.BlockResult, error)
SearchBlocks searches for blocks matching the given criteria. Results are ordered by date descending, then by CreatedAt descending. TODO: Implement SearchBlocks - scan days, filter by attributes/content/date, return results
func (*MarkdownV2) UpdateBlock ¶
func (m *MarkdownV2) UpdateBlock(blockID string, content string, attributes map[string]string) error
UpdateBlock updates the content and attributes of a block. The block's UpdatedAt timestamp will be updated automatically. Returns ErrNotFound if the block doesn't exist. Returns ErrValidation if blockID is empty or content is invalid.
func (*MarkdownV2) UpdateTemplate ¶
func (m *MarkdownV2) UpdateTemplate(id string, name string, content string, attributes map[string]string) (storage.Template, error)
UpdateTemplate updates a template's name, content, and attributes. The template's UpdatedAt timestamp will be updated automatically. Returns the updated template or ErrNotFound if the template doesn't exist. Returns ErrValidation if id or name is empty.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements storage.Storage using Markdown files with YAML front-matter.
func (*Store) AttachContext ¶
AttachContext adds a context reference to an entry's frontmatter.
func (*Store) CreateContext ¶
CreateContext persists a new context as a JSON file.
func (*Store) CreateTemplate ¶
CreateTemplate persists a new template as a Markdown file.
func (*Store) DeleteContext ¶
DeleteContext removes a context by ID and detaches it from all entries. To avoid orphaned references, we detach from all entries first, then delete the context file.
func (*Store) DeleteTemplate ¶
DeleteTemplate removes a template by ID.
func (*Store) DetachContext ¶
DetachContext removes a context reference from an entry's frontmatter.
func (*Store) GetContext ¶
GetContext retrieves a context by ID.
func (*Store) GetContextByName ¶
GetContextByName retrieves a context by name.
func (*Store) GetTemplate ¶
GetTemplate retrieves a template by ID by scanning the templates directory.
func (*Store) GetTemplateByName ¶
GetTemplateByName retrieves a template by name.
func (*Store) ListContexts ¶
ListContexts returns all contexts sorted by name.
func (*Store) ListDays ¶
func (s *Store) ListDays(opts storage.ListDaysOptions) ([]storage.DaySummary, error)
ListDays returns aggregated day summaries by scanning the directory tree.
func (*Store) ListTemplates ¶
ListTemplates returns all templates sorted by name.