Documentation
¶
Overview ¶
Package trilium implements the Trilium adapter for the note capability.
Package trilium implements the Trilium adapter for the note capability.
Index ¶
- func New() notesvc.Service
- func NewPoller() ability.PollingResource
- func NewWithClient(c client) notesvc.Service
- type Adapter
- func (a *Adapter) Create(ctx context.Context, title, content, typ, parentNoteID string) (*ability.Note, error)
- func (a *Adapter) Delete(ctx context.Context, id string) error
- func (a *Adapter) Get(ctx context.Context, id string) (*ability.Note, error)
- func (a *Adapter) GetAppInfo(ctx context.Context) (*ability.Note, error)
- func (a *Adapter) GetContent(ctx context.Context, id string) (string, error)
- func (a *Adapter) List(ctx context.Context, q *notesvc.ListQuery) (*ability.ListResult[ability.Note], error)
- func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
- func (a *Adapter) Search(ctx context.Context, query string) (*ability.ListResult[ability.Note], error)
- func (a *Adapter) SetContent(ctx context.Context, id, content string) error
- func (a *Adapter) Update(ctx context.Context, id, title, content string) (*ability.Note, error)
- type NotePoller
- func (*NotePoller) ContentHash(item any) string
- func (*NotePoller) CursorField() string
- func (*NotePoller) DefaultInterval() time.Duration
- func (*NotePoller) DiffKey(item any) string
- func (p *NotePoller) List(ctx context.Context, cursor string) (ability.PollResult, error)
- func (*NotePoller) ResourceName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates an Adapter using the default provider client (reads config from YAML). It returns nil when the provider is not configured.
func NewPoller ¶
func NewPoller() ability.PollingResource
NewPoller creates a NotePoller backed by a default adapter. It returns nil when the provider is not configured.
func NewWithClient ¶
NewWithClient creates an Adapter with a specific client, useful for testing.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements note.Service using the Trilium provider client.
func (*Adapter) Create ¶
func (a *Adapter) Create(ctx context.Context, title, content, typ, parentNoteID string) (*ability.Note, error)
Create creates a new note with the given parameters. If typ is empty, defaults to "text".
func (*Adapter) GetAppInfo ¶
GetAppInfo returns information about the running Trilium instance, mapped into a Note domain type for the ability layer.
func (*Adapter) GetContent ¶
GetContent retrieves the full content of a note.
func (*Adapter) List ¶
func (a *Adapter) List(ctx context.Context, q *notesvc.ListQuery) (*ability.ListResult[ability.Note], error)
List returns a paginated list of notes, optionally filtered by query. Trilium does not have a dedicated "list all" endpoint; this uses SearchNotes without a search string to return all notes, applying the query parameter as the search string when provided.
func (*Adapter) ListRawEvents ¶
ListRawEvents lists notes as raw events for polling support.
func (*Adapter) Search ¶
func (a *Adapter) Search(ctx context.Context, query string) (*ability.ListResult[ability.Note], error)
Search searches notes by the given query string.
func (*Adapter) SetContent ¶
SetContent sets the full content of a note.
type NotePoller ¶
type NotePoller struct {
// contains filtered or unexported fields
}
NotePoller implements ability.PollingResource for the note capability. It polls Trilium for new and updated notes.
func NewPollerWithService ¶
func NewPollerWithService(svc notesvc.Service) *NotePoller
NewPollerWithService creates a NotePoller with a specific service, useful for testing.
func (*NotePoller) ContentHash ¶
func (*NotePoller) ContentHash(item any) string
ContentHash returns a SHA256 hash of the item for content-based change detection.
func (*NotePoller) CursorField ¶
func (*NotePoller) CursorField() string
CursorField returns the field name used for cursor-based pagination.
func (*NotePoller) DefaultInterval ¶
func (*NotePoller) DefaultInterval() time.Duration
DefaultInterval returns the recommended polling interval.
func (*NotePoller) DiffKey ¶
func (*NotePoller) DiffKey(item any) string
DiffKey returns the unique identifier for an item, used for change detection.
func (*NotePoller) List ¶
func (p *NotePoller) List(ctx context.Context, cursor string) (ability.PollResult, error)
List fetches a batch of items from the provider starting after the given cursor.
func (*NotePoller) ResourceName ¶
func (*NotePoller) ResourceName() string
ResourceName returns the unique name for this polling resource.