Documentation
¶
Index ¶
- type Backend
- type FullTextSearcher
- type HasDataScript
- type IndexableBackend
- type JournalResult
- type JournalSearcher
- type LazyBackend
- func (lb *LazyBackend) AppendBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
- func (lb *LazyBackend) CreatePage(ctx context.Context, name string, properties map[string]any, ...) (*types.PageEntity, error)
- func (lb *LazyBackend) DatascriptQuery(ctx context.Context, query string, inputs ...any) (json.RawMessage, error)
- func (lb *LazyBackend) DeletePage(ctx context.Context, name string) error
- func (lb *LazyBackend) FindBlocksByTag(ctx context.Context, tag string, includeChildren bool) ([]TagResult, error)
- func (lb *LazyBackend) FindByProperty(ctx context.Context, key, value, operator string) ([]PropertyResult, error)
- func (lb *LazyBackend) FullTextSearch(ctx context.Context, query string, limit int) ([]SearchHit, error)
- func (lb *LazyBackend) GetAllPages(ctx context.Context) ([]types.PageEntity, error)
- func (lb *LazyBackend) GetBlock(ctx context.Context, uuid string, opts ...map[string]any) (*types.BlockEntity, error)
- func (lb *LazyBackend) GetPage(ctx context.Context, nameOrID any) (*types.PageEntity, error)
- func (lb *LazyBackend) GetPageBlocksTree(ctx context.Context, nameOrID any) ([]types.BlockEntity, error)
- func (lb *LazyBackend) GetPageLinkedReferences(ctx context.Context, nameOrID any) (json.RawMessage, error)
- func (lb *LazyBackend) InsertBlock(ctx context.Context, srcBlock any, content string, opts map[string]any) (*types.BlockEntity, error)
- func (lb *LazyBackend) MarkFailed(err error)
- func (lb *LazyBackend) MarkReady()
- func (lb *LazyBackend) MoveBlock(ctx context.Context, uuid string, targetUUID string, opts map[string]any) error
- func (lb *LazyBackend) Ping(ctx context.Context) error
- func (lb *LazyBackend) PrependBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
- func (lb *LazyBackend) RemoveBlock(ctx context.Context, uuid string) error
- func (lb *LazyBackend) RenamePage(ctx context.Context, oldName, newName string) error
- func (lb *LazyBackend) SearchJournals(ctx context.Context, query string, from, to string) ([]JournalResult, error)
- func (lb *LazyBackend) UpdateBlock(ctx context.Context, uuid string, content string, opts ...map[string]any) error
- type PropertyResult
- type PropertySearcher
- type SearchHit
- type TagResult
- type TagSearcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// Core read operations
GetAllPages(ctx context.Context) ([]types.PageEntity, error)
GetPage(ctx context.Context, nameOrID any) (*types.PageEntity, error)
GetPageBlocksTree(ctx context.Context, nameOrID any) ([]types.BlockEntity, error)
GetBlock(ctx context.Context, uuid string, opts ...map[string]any) (*types.BlockEntity, error)
GetPageLinkedReferences(ctx context.Context, nameOrID any) (json.RawMessage, error)
// Query operations
DatascriptQuery(ctx context.Context, query string, inputs ...any) (json.RawMessage, error)
// Write operations
CreatePage(ctx context.Context, name string, properties map[string]any, opts map[string]any) (*types.PageEntity, error)
AppendBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
PrependBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
InsertBlock(ctx context.Context, srcBlock any, content string, opts map[string]any) (*types.BlockEntity, error)
UpdateBlock(ctx context.Context, uuid string, content string, opts ...map[string]any) error
RemoveBlock(ctx context.Context, uuid string) error
MoveBlock(ctx context.Context, uuid string, targetUUID string, opts map[string]any) error
// Page management
DeletePage(ctx context.Context, name string) error
RenamePage(ctx context.Context, oldName, newName string) error
// Connectivity
Ping(ctx context.Context) error
}
Backend is the interface every knowledge graph backend must implement. The Logseq client (client.Client) satisfies this interface. Future backends (e.g. Obsidian vault) implement the same contract.
type FullTextSearcher ¶ added in v0.4.0
type FullTextSearcher interface {
FullTextSearch(ctx context.Context, query string, limit int) ([]SearchHit, error)
}
FullTextSearcher is implemented by backends with an inverted index for efficient full-text search. When available, tools/search.go uses this instead of brute-force scanning.
type HasDataScript ¶
type HasDataScript interface {
HasDataScript()
}
HasDataScript is a marker interface for backends supporting DataScript queries. Logseq implements this; Obsidian does not.
type IndexableBackend ¶ added in v0.5.0
type IndexableBackend interface {
Backend
FullTextSearcher
TagSearcher
PropertySearcher
JournalSearcher
}
IndexableBackend is a Backend that also serves the index-driven search capabilities. LazyBackend is built for backends of this shape — the "indexing" is exactly what takes time to start. Naming the precondition at the type level lets the wrapper forward capability calls directly, without runtime guards.
type JournalResult ¶
type JournalResult struct {
Date string `json:"date"`
Page string `json:"page"`
Blocks []types.BlockEntity `json:"blocks"`
}
JournalResult holds a journal entry found by search.
type JournalSearcher ¶
type JournalSearcher interface {
SearchJournals(ctx context.Context, query string, from, to string) ([]JournalResult, error)
}
JournalSearcher is implemented by backends that support journal search without DataScript.
type LazyBackend ¶ added in v0.5.0
type LazyBackend struct {
// contains filtered or unexported fields
}
LazyBackend wraps an IndexableBackend that needs time to initialize. It responds to Ping immediately but blocks all other calls until the underlying backend signals readiness.
func NewLazyBackend ¶ added in v0.5.0
func NewLazyBackend(inner IndexableBackend) *LazyBackend
NewLazyBackend returns a wrapper around inner. Call MarkReady or MarkFailed from a goroutine once initialization is complete.
func (*LazyBackend) AppendBlockInPage ¶ added in v0.5.0
func (lb *LazyBackend) AppendBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
func (*LazyBackend) CreatePage ¶ added in v0.5.0
func (*LazyBackend) DatascriptQuery ¶ added in v0.5.0
func (lb *LazyBackend) DatascriptQuery(ctx context.Context, query string, inputs ...any) (json.RawMessage, error)
func (*LazyBackend) DeletePage ¶ added in v0.5.0
func (lb *LazyBackend) DeletePage(ctx context.Context, name string) error
func (*LazyBackend) FindBlocksByTag ¶ added in v0.5.0
func (*LazyBackend) FindByProperty ¶ added in v0.5.0
func (lb *LazyBackend) FindByProperty(ctx context.Context, key, value, operator string) ([]PropertyResult, error)
func (*LazyBackend) FullTextSearch ¶ added in v0.5.0
func (*LazyBackend) GetAllPages ¶ added in v0.5.0
func (lb *LazyBackend) GetAllPages(ctx context.Context) ([]types.PageEntity, error)
func (*LazyBackend) GetBlock ¶ added in v0.5.0
func (lb *LazyBackend) GetBlock(ctx context.Context, uuid string, opts ...map[string]any) (*types.BlockEntity, error)
func (*LazyBackend) GetPage ¶ added in v0.5.0
func (lb *LazyBackend) GetPage(ctx context.Context, nameOrID any) (*types.PageEntity, error)
func (*LazyBackend) GetPageBlocksTree ¶ added in v0.5.0
func (lb *LazyBackend) GetPageBlocksTree(ctx context.Context, nameOrID any) ([]types.BlockEntity, error)
func (*LazyBackend) GetPageLinkedReferences ¶ added in v0.5.0
func (lb *LazyBackend) GetPageLinkedReferences(ctx context.Context, nameOrID any) (json.RawMessage, error)
func (*LazyBackend) InsertBlock ¶ added in v0.5.0
func (lb *LazyBackend) InsertBlock(ctx context.Context, srcBlock any, content string, opts map[string]any) (*types.BlockEntity, error)
func (*LazyBackend) MarkFailed ¶ added in v0.5.0
func (lb *LazyBackend) MarkFailed(err error)
MarkFailed signals that initialization failed. All subsequent calls will return this error. Safe to call multiple times; only the first call wins. err must be non-nil.
func (*LazyBackend) MarkReady ¶ added in v0.5.0
func (lb *LazyBackend) MarkReady()
MarkReady signals that the underlying backend is fully initialized. Safe to call multiple times; only the first call wins.
func (*LazyBackend) Ping ¶ added in v0.5.0
func (lb *LazyBackend) Ping(ctx context.Context) error
Ping responds immediately — the server is alive even while loading.
func (*LazyBackend) PrependBlockInPage ¶ added in v0.5.0
func (lb *LazyBackend) PrependBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
func (*LazyBackend) RemoveBlock ¶ added in v0.5.0
func (lb *LazyBackend) RemoveBlock(ctx context.Context, uuid string) error
func (*LazyBackend) RenamePage ¶ added in v0.5.0
func (lb *LazyBackend) RenamePage(ctx context.Context, oldName, newName string) error
func (*LazyBackend) SearchJournals ¶ added in v0.5.0
func (lb *LazyBackend) SearchJournals(ctx context.Context, query string, from, to string) ([]JournalResult, error)
func (*LazyBackend) UpdateBlock ¶ added in v0.5.0
type PropertyResult ¶
type PropertyResult struct {
Type string `json:"type"` // "page" or "block"
Name string `json:"name,omitempty"`
UUID string `json:"uuid,omitempty"`
Properties map[string]any `json:"properties"`
}
PropertyResult holds a page or block found by property search.
type PropertySearcher ¶
type PropertySearcher interface {
FindByProperty(ctx context.Context, key, value, operator string) ([]PropertyResult, error)
}
PropertySearcher is implemented by backends that support property search without DataScript.
type SearchHit ¶ added in v0.4.0
type SearchHit struct {
PageName string `json:"page"`
UUID string `json:"uuid"`
Content string `json:"content"`
}
SearchHit is a block found by full-text search.
type TagResult ¶
type TagResult struct {
Page string `json:"page"`
Blocks []types.BlockEntity `json:"blocks"`
}
TagResult holds a block found by tag search, grouped by page.