trilium

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package trilium implements the Trilium adapter for the note capability.

Package trilium implements the Trilium adapter for the note capability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() notesvc.Service

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

func NewWithClient(c client) notesvc.Service

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

func (a *Adapter) Delete(ctx context.Context, id string) error

Delete removes a note by its ID.

func (*Adapter) Get

func (a *Adapter) Get(ctx context.Context, id string) (*ability.Note, error)

Get returns a single note by its ID.

func (*Adapter) GetAppInfo

func (a *Adapter) GetAppInfo(ctx context.Context) (*ability.Note, error)

GetAppInfo returns information about the running Trilium instance, mapped into a Note domain type for the ability layer.

func (*Adapter) GetContent

func (a *Adapter) GetContent(ctx context.Context, id string) (string, error)

GetContent retrieves the full content of a note.

func (*Adapter) List

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

func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)

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

func (a *Adapter) SetContent(ctx context.Context, id, content string) error

SetContent sets the full content of a note.

func (*Adapter) Update

func (a *Adapter) Update(ctx context.Context, id, title, content string) (*ability.Note, error)

Update updates a note's title and/or content. When content is non-empty, it calls UpdateNoteContent separately after the metadata patch.

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.

Jump to

Keyboard shortcuts

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