store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBackend

func RegisterBackend(name string, factory BackendFactory)

RegisterBackend allows external modules (e.g. kombify) to register custom backends. Called from init() in private modules -- SpeechKit itself never knows about kombify.

Types

type AudioAsset

type AudioAsset struct {
	StorageKind AudioStorageKind `json:"storageKind"`
	Path        string           `json:"path,omitempty"`
	MimeType    string           `json:"mimeType"`
	SizeBytes   int64            `json:"sizeBytes"`
	DurationMs  int64            `json:"durationMs"`
}

type AudioStorageKind

type AudioStorageKind string
const (
	AudioStorageLocalFile AudioStorageKind = "local-file"
)

type BackendFactory

type BackendFactory func(cfg StoreConfig) (Store, error)

BackendFactory creates a Store from config.

type ListOpts

type ListOpts struct {
	Limit    int
	Offset   int
	Language string
	After    time.Time
}

ListOpts controls pagination and filtering for list queries.

type PostgresStore

type PostgresStore struct {
	// contains filtered or unexported fields
}

PostgresStore implements Store using PostgreSQL for metadata and the local filesystem for optional raw WAV persistence.

func NewPostgresStore

func NewPostgresStore(cfg StoreConfig) (*PostgresStore, error)

NewPostgresStore creates a PostgreSQL-backed store.

func (*PostgresStore) Close

func (s *PostgresStore) Close() error

func (*PostgresStore) DeleteQuickNote

func (s *PostgresStore) DeleteQuickNote(_ context.Context, id int64) error

func (*PostgresStore) GetQuickNote

func (s *PostgresStore) GetQuickNote(_ context.Context, id int64) (*QuickNote, error)

func (*PostgresStore) GetTranscription

func (s *PostgresStore) GetTranscription(_ context.Context, id int64) (*Transcription, error)

func (*PostgresStore) ListQuickNotes

func (s *PostgresStore) ListQuickNotes(_ context.Context, opts ListOpts) ([]QuickNote, error)

func (*PostgresStore) ListTranscriptions

func (s *PostgresStore) ListTranscriptions(_ context.Context, opts ListOpts) ([]Transcription, error)

func (*PostgresStore) PinQuickNote

func (s *PostgresStore) PinQuickNote(_ context.Context, id int64, pinned bool) error

func (*PostgresStore) QuickNoteCount

func (s *PostgresStore) QuickNoteCount(_ context.Context) (int, error)

func (*PostgresStore) SaveQuickNote

func (s *PostgresStore) SaveQuickNote(_ context.Context, text, language, provider string, durationMs, latencyMs int64, audioData []byte) (int64, error)

func (*PostgresStore) SaveTranscription

func (s *PostgresStore) SaveTranscription(_ context.Context, text, language, provider, model string, durationMs, latencyMs int64, audioData []byte) error

func (*PostgresStore) SemanticCapabilities

func (s *PostgresStore) SemanticCapabilities(context.Context) SemanticCapabilities

func (*PostgresStore) Stats

func (s *PostgresStore) Stats(_ context.Context) (Stats, error)

func (*PostgresStore) TranscriptionCount

func (s *PostgresStore) TranscriptionCount(_ context.Context) (int, error)

func (*PostgresStore) UpdateQuickNote

func (s *PostgresStore) UpdateQuickNote(_ context.Context, id int64, text string) error

func (*PostgresStore) UpdateQuickNoteCapture

func (s *PostgresStore) UpdateQuickNoteCapture(_ context.Context, id int64, text, provider string, durationMs, latencyMs int64, audioData []byte) error

type QuickNote

type QuickNote struct {
	ID         int64
	Text       string
	Language   string
	Provider   string
	DurationMs int64
	LatencyMs  int64
	AudioPath  string
	Audio      *AudioAsset
	Pinned     bool
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

QuickNote represents a user-created dictation note.

type SQLiteStore

type SQLiteStore struct {
	// contains filtered or unexported fields
}

SQLiteStore implements Store using a local SQLite database. Uses modernc.org/sqlite (pure Go, no CGo required).

func NewSQLiteStore

func NewSQLiteStore(cfg StoreConfig) (*SQLiteStore, error)

NewSQLiteStore opens or creates a SQLite feedback database.

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) DeleteQuickNote

func (s *SQLiteStore) DeleteQuickNote(_ context.Context, id int64) error

func (*SQLiteStore) GetQuickNote

func (s *SQLiteStore) GetQuickNote(_ context.Context, id int64) (*QuickNote, error)

func (*SQLiteStore) GetTranscription

func (s *SQLiteStore) GetTranscription(_ context.Context, id int64) (*Transcription, error)

func (*SQLiteStore) ListQuickNotes

func (s *SQLiteStore) ListQuickNotes(_ context.Context, opts ListOpts) ([]QuickNote, error)

func (*SQLiteStore) ListTranscriptions

func (s *SQLiteStore) ListTranscriptions(_ context.Context, opts ListOpts) ([]Transcription, error)

func (*SQLiteStore) PinQuickNote

func (s *SQLiteStore) PinQuickNote(_ context.Context, id int64, pinned bool) error

func (*SQLiteStore) QuickNoteCount

func (s *SQLiteStore) QuickNoteCount(_ context.Context) (int, error)

func (*SQLiteStore) SaveQuickNote

func (s *SQLiteStore) SaveQuickNote(_ context.Context, text, language, provider string, durationMs, latencyMs int64, audioData []byte) (int64, error)

func (*SQLiteStore) SaveTranscription

func (s *SQLiteStore) SaveTranscription(_ context.Context, text, language, provider, model string, durationMs, latencyMs int64, audioData []byte) error

func (*SQLiteStore) SemanticCapabilities

func (s *SQLiteStore) SemanticCapabilities(context.Context) SemanticCapabilities

func (*SQLiteStore) Stats

func (s *SQLiteStore) Stats(_ context.Context) (Stats, error)

func (*SQLiteStore) TranscriptionCount

func (s *SQLiteStore) TranscriptionCount(_ context.Context) (int, error)

func (*SQLiteStore) UpdateQuickNote

func (s *SQLiteStore) UpdateQuickNote(_ context.Context, id int64, text string) error

func (*SQLiteStore) UpdateQuickNoteCapture

func (s *SQLiteStore) UpdateQuickNoteCapture(_ context.Context, id int64, text, provider string, durationMs, latencyMs int64, audioData []byte) error

type SemanticCapabilities

type SemanticCapabilities struct {
	Provider     SemanticProvider `json:"provider"`
	FullText     bool             `json:"fullText"`
	Embeddings   bool             `json:"embeddings"`
	VectorSearch bool             `json:"vectorSearch"`
}

type SemanticCapabilityProvider

type SemanticCapabilityProvider interface {
	SemanticCapabilities(ctx context.Context) SemanticCapabilities
}

SemanticCapabilityProvider is an optional extension for stores that can advertise indexing/vector capabilities without forcing every backend to implement semantic features immediately.

type SemanticProvider

type SemanticProvider string
const (
	SemanticProviderNone SemanticProvider = "none"
)

type Stats

type Stats struct {
	Transcriptions        int
	QuickNotes            int
	TotalWords            int
	TotalAudioDurationMs  int64
	AverageWordsPerMinute float64
	AverageLatencyMs      int64
}

type Store

type Store interface {
	// Transcriptions
	SaveTranscription(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audioData []byte) error
	GetTranscription(ctx context.Context, id int64) (*Transcription, error)
	ListTranscriptions(ctx context.Context, opts ListOpts) ([]Transcription, error)
	TranscriptionCount(ctx context.Context) (int, error)

	// Quick Notes
	SaveQuickNote(ctx context.Context, text, language, provider string, durationMs, latencyMs int64, audioData []byte) (int64, error)
	GetQuickNote(ctx context.Context, id int64) (*QuickNote, error)
	ListQuickNotes(ctx context.Context, opts ListOpts) ([]QuickNote, error)
	UpdateQuickNote(ctx context.Context, id int64, text string) error
	UpdateQuickNoteCapture(ctx context.Context, id int64, text, provider string, durationMs, latencyMs int64, audioData []byte) error
	PinQuickNote(ctx context.Context, id int64, pinned bool) error
	DeleteQuickNote(ctx context.Context, id int64) error
	QuickNoteCount(ctx context.Context) (int, error)
	Stats(ctx context.Context) (Stats, error)

	// Lifecycle
	Close() error
}

Store is the central storage abstraction. Each backend (SQLite, PostgreSQL, kombify Cloud) implements this interface.

func New

func New(cfg StoreConfig) (Store, error)

New creates a Store backend based on the config.

type StoreConfig

type StoreConfig struct {
	Backend                 string `toml:"backend"` // "sqlite" | "postgres" | registered name
	SQLitePath              string `toml:"sqlite_path"`
	PostgresDSN             string `toml:"postgres_dsn"`
	SaveAudio               bool   `toml:"save_audio"`
	AudioRetentionDays      int    `toml:"audio_retention_days"`
	MaxAudioStorageMB       int    `toml:"max_audio_storage_mb"`
	TranscriptionModelHints map[string]string
}

StoreConfig holds configuration for store backend selection.

type Transcription

type Transcription struct {
	ID         int64
	Text       string
	Language   string
	Provider   string
	Model      string
	DurationMs int64
	LatencyMs  int64
	AudioPath  string
	Audio      *AudioAsset
	CreatedAt  time.Time
}

Transcription represents a saved transcription record.

Jump to

Keyboard shortcuts

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