client

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package client provides the etu journal backend client: configuration, caching, and gRPC calls used by the CLI and TUI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachePath added in v1.3.0

func CachePath(filename string) (string, error)

CachePath returns the path for a cache file under the config directory. Example: CachePath("timesince.cache") => ~/.config/etu/timesince.cache

func ConfigDir added in v1.3.0

func ConfigDir() (string, error)

ConfigDir returns the etu config directory (e.g. ~/.config/etu on Unix). Creates the directory if it does not exist. Use this for config and cache files.

func ConfigPath added in v1.3.0

func ConfigPath() (string, error)

ConfigPath returns the path to the config file (~/.config/etu/config.json).

func LoadAudioUploads added in v1.3.0

func LoadAudioUploads(paths []string) ([]*proto.AudioUpload, error)

LoadAudioUploads reads audio files from paths and returns proto AudioUpload messages. MIME type is detected from content (or file extension as fallback).

func LoadImageUploads added in v1.3.0

func LoadImageUploads(paths []string) ([]*proto.ImageUpload, error)

LoadImageUploads reads image files from paths and returns proto ImageUpload messages. MIME type is detected from content (or file extension as fallback).

Types

type Config added in v0.1.0

type Config struct {
	APIKey     string
	GRPCTarget string
	// contains filtered or unexported fields
}

Config holds the configuration for the client.

func LoadConfig added in v1.1.2

func LoadConfig() *Config

LoadConfig loads configuration from ~/.config/etu/config.json and environment variables. Env ETU_API_KEY and ETU_GRPC_TARGET override file values. If no config file exists and no API key is set, a config file is created with the correct structure and an empty key.

func (*Config) DeletePost added in v0.1.0

func (c *Config) DeletePost(ctx context.Context, pageID string) error

DeletePost deletes a journal entry by ID.

func (*Config) GetPostFullContent added in v0.1.0

func (c *Config) GetPostFullContent(ctx context.Context, pageID string) (string, error)

GetPostFullContent fetches the full content of a post by ID.

func (*Config) GetRandomPosts added in v1.4.0

func (c *Config) GetRandomPosts(ctx context.Context, count int) ([]*Post, error)

GetRandomPosts fetches random journal entries from the backend.

func (*Config) GetStats added in v1.5.0

func (c *Config) GetStats(ctx context.Context, global bool) (Stats, error)

GetStats fetches aggregate stats. When global is true, community-wide stats are returned; otherwise stats are scoped to the current user.

func (*Config) ListPosts added in v0.1.0

func (c *Config) ListPosts(ctx context.Context, count int) ([]*Post, error)

ListPosts lists the most recent journal entries.

func (*Config) ListTags added in v1.5.0

func (c *Config) ListTags(ctx context.Context) ([]Tag, error)

ListTags lists all tags for the current user.

func (*Config) SaveEntry added in v0.1.0

func (c *Config) SaveEntry(ctx context.Context, text string, imagePaths, audioPaths []string) error

SaveEntry saves a new journal entry via the backend (tags are generated on the backend). imagePaths and audioPaths are optional paths to image and audio files to attach to the note.

func (*Config) SearchPosts added in v0.1.0

func (c *Config) SearchPosts(ctx context.Context, query string, maxResults int) ([]*Post, error)

SearchPosts searches journal entries via the backend.

func (*Config) TimeSinceLastPost added in v0.1.0

func (c *Config) TimeSinceLastPost(ctx context.Context) (time.Duration, error)

TimeSinceLastPost returns the time since the last post was created.

func (*Config) UpdateCache added in v0.1.0

func (c *Config) UpdateCache(ctx context.Context) error

UpdateCache updates the cache with the latest post.

func (*Config) UpdatePost added in v1.5.0

func (c *Config) UpdatePost(ctx context.Context, pageID, content string) (*Post, error)

UpdatePost updates the content of an existing journal entry by ID. Tags are left untouched (the backend keeps the existing tag list).

func (*Config) Validate added in v1.1.2

func (c *Config) Validate() error

Validate checks that the API key is present.

type ConfigFile added in v1.3.0

type ConfigFile struct {
	APIKey     string `json:"api_key"`
	GRPCTarget string `json:"grpc_target"`
}

ConfigFile represents the persisted config file format.

func SaveConfig added in v1.3.0

func SaveConfig(apiKey, grpcTarget string) (*ConfigFile, error)

SaveConfig writes api_key and grpc_target to ~/.config/etu/config.json. Creates the config directory if it does not exist.

type Post

type Post struct {
	PageID    string // Note ID for fetching full content
	Tags      []string
	Text      string
	CreatedAt time.Time
	Images    []*proto.NoteImage
	Audios    []*proto.NoteAudio
}

Post represents a journal entry (display model for TUI/CLI).

type Stats added in v1.5.0

type Stats struct {
	TotalBlips   int64
	UniqueTags   int64
	WordsWritten int64
}

Stats holds aggregate journal metrics from the backend.

type Tag added in v1.5.0

type Tag struct {
	Name  string
	Count int32
}

Tag represents a journal tag and how many entries use it.

Jump to

Keyboard shortcuts

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