graph

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWriteFile

func AtomicWriteFile(path string, data []byte) error

AtomicWriteFile writes data to path by creating a temp file in the same directory, syncing, then renaming.

func InsertLinesAfter

func InsertLinesAfter(file []byte, afterLine int, newLines []string) ([]byte, error)

InsertLinesAfter inserts new physical lines immediately after 1-based line index `afterLine`.

func NewSiblingLine

func NewSiblingLine(anchorLine string, text string) string

NewSiblingLine builds one Markdown line to insert after anchorLine (first line of preceding block).

func ReplaceBlockLineRange

func ReplaceBlockLineRange(file []byte, lineStart, lineEnd int, newContent string) ([]byte, error)

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

func ResolveVaultPath(notesRoot, userPath string) (string, error)

ResolveVaultPath joins a user path (absolute or vault-relative) against notesRoot and rejects ".." escape.

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

func VaultRelativePath(notesRoot, absPath string) (string, error)

VaultRelativePath returns a slash-separated path relative to notesRoot, or an error if absPath is outside the vault.

func WikilinkLookupKeys

func WikilinkLookupKeys(absPagePath, notesRoot string) ([]string, error)

WikilinkLookupKeys returns normalized lookup strings that might appear in block_wikilinks.target for links pointing to absPagePath inside notesRoot.

func WikilinkToAbsPath

func WikilinkToAbsPath(notesRoot, target string) (string, error)

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

func NewService(store storage.Provider, engine *parser.Engine) *Service

NewService wires storage and a shared parser engine.

func (*Service) AppendQuickCapture

func (s *Service) AppendQuickCapture(ctx context.Context, absPath, text string) error

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

func (s *Service) ApplySlashOp(ctx context.Context, blockID, op string) error

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

func (s *Service) CycleBlockTodo(ctx context.Context, blockID string) error

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

func (s *Service) DeleteFile(ctx context.Context, path string) error

DeleteFile removes blocks, page metadata, and aliases for a path.

func (*Service) EnsurePage

func (s *Service) EnsurePage(ctx context.Context, absPath string) error

EnsurePage creates an empty Markdown page with a title heading if the file does not exist.

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

func (s *Service) IndentBlock(ctx context.Context, blockID string) error

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

func (s *Service) InsertBlockAfter(ctx context.Context, blockID, initialText string) error

InsertBlockAfter inserts a new Markdown line after the block's last line (sibling list item / paragraph).

func (*Service) OutdentBlock

func (s *Service) OutdentBlock(ctx context.Context, blockID string) error

OutdentBlock removes two leading spaces from the same span; fails if any affected line has fewer than two leading spaces.

func (*Service) QueryBlocks

func (s *Service) QueryBlocks(ctx context.Context, dsl string) ([]domain.Block, error)

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

func (s *Service) ReindexFile(ctx context.Context, path string) error

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

func (s *Service) ReindexMarkdownBytes(ctx context.Context, absPath string, src []byte) error

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

func (s *Service) ReorderSiblingBefore(ctx context.Context, movingID, beforeID string) error

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) SetBus

func (s *Service) SetBus(b *bus.Bus)

SetBus attaches an optional event bus (plugins, sync hooks).

func (*Service) UpdateBlock

func (s *Service) UpdateBlock(ctx context.Context, blockID, newContent string) error

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.

Jump to

Keyboard shortcuts

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