Documentation
¶
Overview ¶
Package trilium implements the Trilium adapter for the note capability.
Package trilium implements the Trilium adapter for the note capability.
Index ¶
- Constants
- func NewPoller() capability.PollingResource
- func Register(app string, svc Service) error
- type Adapter
- func (a *Adapter) Create(ctx context.Context, title, content, typ, parentNoteID string) (*capability.Note, error)
- func (a *Adapter) Delete(ctx context.Context, id string) error
- func (a *Adapter) Get(ctx context.Context, id string) (*capability.Note, error)
- func (a *Adapter) GetAppInfo(ctx context.Context) (*capability.Note, error)
- func (a *Adapter) GetContent(ctx context.Context, id string) (string, error)
- func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)
- func (a *Adapter) List(ctx context.Context, q *ListQuery) (*capability.ListResult[capability.Note], error)
- func (a *Adapter) ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
- func (a *Adapter) Search(ctx context.Context, query string) (*capability.ListResult[capability.Note], error)
- func (a *Adapter) SetContent(ctx context.Context, id, content string) error
- func (a *Adapter) Update(ctx context.Context, id, title, content string) (*capability.Note, error)
- type ListQuery
- 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) (capability.PollResult, error)
- func (*NotePoller) ResourceName() string
- type Service
Constants ¶
const ( OpList = "list" OpGet = "get" OpCreate = "create" OpUpdate = "update" OpDelete = "delete" OpGetContent = "get_content" OpSetContent = "set_content" OpSearch = "search" OpGetAppInfo = "get_app_info" OpHealth = "health" )
Variables ¶
This section is empty.
Functions ¶
func NewPoller ¶
func NewPoller() capability.PollingResource
NewPoller creates a NotePoller backed by a default adapter. It returns nil when the provider is not configured.
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) (*capability.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) HealthCheck ¶
HealthCheck reports whether the Trilium backend is reachable by querying app info.
func (*Adapter) List ¶
func (a *Adapter) List(ctx context.Context, q *ListQuery) (*capability.ListResult[capability.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) (*capability.ListResult[capability.Note], error)
Search searches notes by the given query string.
func (*Adapter) SetContent ¶
SetContent sets the full content of a note.
type ListQuery ¶
type ListQuery = capability.NoteListQuery
ListQuery wraps pagination for listing notes.
type NotePoller ¶
type NotePoller struct {
// contains filtered or unexported fields
}
NotePoller implements capability.PollingResource for the note capability. It polls Trilium for new and updated notes.
func NewPollerWithService ¶
func NewPollerWithService(svc 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) (capability.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.
type Service ¶
type Service interface {
List(ctx context.Context, q *ListQuery) (*capability.ListResult[capability.Note], error)
Get(ctx context.Context, id string) (*capability.Note, error)
Create(ctx context.Context, title, content, typ, parentNoteID string) (*capability.Note, error)
Update(ctx context.Context, id, title, content string) (*capability.Note, error)
Delete(ctx context.Context, id string) error
GetContent(ctx context.Context, id string) (string, error)
SetContent(ctx context.Context, id, content string) error
Search(ctx context.Context, query string) (*capability.ListResult[capability.Note], error)
GetAppInfo(ctx context.Context) (*capability.Note, error)
ListRawEvents(ctx context.Context, cursor string) ([]any, string, error)
HealthCheck(ctx context.Context) (bool, error)
}
Service defines the note capability contract.
func New ¶
func New() Service
New creates an Adapter using the default provider client (reads config from YAML). It returns nil when the provider is not configured.
func NewWithClient ¶
func NewWithClient(c client) Service
NewWithClient creates an Adapter with a specific client, useful for testing.