Documentation
¶
Index ¶
- func AtomicWriteFile(path string, data []byte) error
- func InsertLinesAfter(file []byte, afterLine int, newLines []string) ([]byte, error)
- func NewSiblingLine(anchorLine string, text string) string
- func ReplaceBlockLineRange(file []byte, lineStart, lineEnd int, newContent string) ([]byte, error)
- func ResolveVaultPath(notesRoot, userPath string) (string, error)
- func ResolveWikilink(ctx context.Context, st storage.Provider, notesRoot, target string) (string, error)
- func VaultRelativePath(notesRoot, absPath string) (string, error)
- func WikilinkLookupKeys(absPagePath, notesRoot string) ([]string, error)
- func WikilinkToAbsPath(notesRoot, target string) (string, error)
- type Service
- func (s *Service) AppendQuickCapture(ctx context.Context, absPath, text string) error
- func (s *Service) ApplySlashOp(ctx context.Context, blockID, op string) error
- func (s *Service) CycleBlockTodo(ctx context.Context, blockID string) error
- func (s *Service) DeleteFile(ctx context.Context, path string) error
- func (s *Service) EnsurePage(ctx context.Context, absPath string) error
- func (s *Service) GetBacklinks(ctx context.Context, notesRoot, pagePath string) ([]domain.Block, error)
- func (s *Service) IndentBlock(ctx context.Context, blockID string) error
- func (s *Service) InsertBlockAfter(ctx context.Context, blockID, initialText string) error
- func (s *Service) OutdentBlock(ctx context.Context, blockID string) error
- func (s *Service) QueryBlocks(ctx context.Context, dsl string) ([]domain.Block, error)
- func (s *Service) ReindexBlocks(ctx context.Context, sourcePath string, res parser.ParseResult) error
- func (s *Service) ReindexFile(ctx context.Context, path string) error
- func (s *Service) ReindexMarkdownBytes(ctx context.Context, absPath string, src []byte) error
- func (s *Service) ReorderSiblingBefore(ctx context.Context, movingID, beforeID string) error
- func (s *Service) SetBus(b *bus.Bus)
- func (s *Service) UpdateBlock(ctx context.Context, blockID, newContent string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicWriteFile ¶
AtomicWriteFile writes data to path by creating a temp file in the same directory, syncing, then renaming.
func InsertLinesAfter ¶
InsertLinesAfter inserts new physical lines immediately after 1-based line index `afterLine`.
func NewSiblingLine ¶
NewSiblingLine builds one Markdown line to insert after anchorLine (first line of preceding block).
func ReplaceBlockLineRange ¶
ReplaceBlockLineRange replaces 1-based inclusive line range [lineStart, lineEnd] with lines derived from newContent. Markdown list / heading prefixes on the first original line are preserved so sibling/nested structure below is untouched.
func ResolveVaultPath ¶
ResolveVaultPath joins a user path (absolute or vault-relative) against notesRoot and rejects ".." escape.
func ResolveWikilink ¶
func ResolveWikilink(ctx context.Context, st storage.Provider, notesRoot, target string) (string, error)
ResolveWikilink returns the absolute path for a [[wikilink]] target: existing file, else alias match, else the default would-be path.
func VaultRelativePath ¶
VaultRelativePath returns a slash-separated path relative to notesRoot, or an error if absPath is outside the vault.
func WikilinkLookupKeys ¶
WikilinkLookupKeys returns normalized lookup strings that might appear in block_wikilinks.target for links pointing to absPagePath inside notesRoot.
func WikilinkToAbsPath ¶
WikilinkToAbsPath maps a [[target]] title to a .md path inside the vault.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service applies parse results to a storage Provider (blocks + link/tag edges).
func NewService ¶
NewService wires storage and a shared parser engine.
func (*Service) AppendQuickCapture ¶
AppendQuickCapture appends bullet line(s) to the end of a page (EnsurePage if missing), then reindexes. Multi-line text becomes one list item with indented continuation lines.
func (*Service) ApplySlashOp ¶
ApplySlashOp transforms the block's first physical line (and span for code fences) in the markdown file. op: today | todo | h1 | h2 | h3 | code
func (*Service) CycleBlockTodo ¶
CycleBlockTodo advances TODO → DOING → DONE → (clear) on the first physical line's body (text after list marker / heading marker). Atomic write + ReindexFile.
func (*Service) DeleteFile ¶
DeleteFile removes blocks, page metadata, and aliases for a path.
func (*Service) EnsurePage ¶
EnsurePage creates an empty Markdown page with a title heading if the file does not exist.
func (*Service) GetBacklinks ¶
func (s *Service) GetBacklinks(ctx context.Context, notesRoot, pagePath string) ([]domain.Block, error)
GetBacklinks returns distinct blocks (any page) that contain a wikilink whose target resolves to pagePath.
func (*Service) IndentBlock ¶
IndentBlock adds two leading spaces to the block line (and its nested subtree for list items), then re-indexes the file. Parent/level in SQLite come from the parser after ReindexFile.
func (*Service) InsertBlockAfter ¶
InsertBlockAfter inserts a new Markdown line after the block's last line (sibling list item / paragraph).
func (*Service) OutdentBlock ¶
OutdentBlock removes two leading spaces from the same span; fails if any affected line has fewer than two leading spaces.
func (*Service) QueryBlocks ¶
QueryBlocks interprets a small DSL:
- "key:value" → filter properties_json (e.g. status:todo)
- otherwise → FTS prefix search on block content
func (*Service) ReindexBlocks ¶
func (s *Service) ReindexBlocks(ctx context.Context, sourcePath string, res parser.ParseResult) error
ReindexBlocks upserts using an in-memory parse result (e.g. tests).
func (*Service) ReindexFile ¶
ReindexFile reads path (read-only), parses Markdown, then replaces all blocks (and derived edges) for that source_path inside a single transaction.
func (*Service) ReindexMarkdownBytes ¶
ReindexMarkdownBytes parses in-memory markdown for an absolute vault path and applies it to the store (same indexing rules as ReindexFile). Used by the SaaS HTTP API and RemoteStore sync.
func (*Service) ReorderSiblingBefore ¶
ReorderSiblingBefore moves movingID's subtree to sit immediately before beforeID in the file. Both blocks must share the same source file and parent_id.
func (*Service) UpdateBlock ¶
UpdateBlock replaces only the source lines for the given block and re-indexes the file. Child blocks live on separate lines and are not part of [LineStart, LineEnd], so they are preserved.