sqlite

package
v0.0.0-...-fbe0f95 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package sqlite provides SQLite query and persistence operations for Expensor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Config   config.SQLite
	Security config.Security
}

Options configures the SQLite store.

type Store

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

Store owns the SQLite connection pool and shared repository dependencies.

func New

func New(ctx context.Context, opts Options) (*Store, error)

New opens, checks, migrates, and initializes a SQLite store.

func (*Store) AddLabel

func (s *Store) AddLabel(ctx context.Context, tenant store.Tenant, transactionID, label string) error

func (*Store) AddLabels

func (s *Store) AddLabels(ctx context.Context, tenant store.Tenant, transactionID string, labels []string) error

func (*Store) ApplyBucketByMerchant

func (s *Store) ApplyBucketByMerchant(ctx context.Context, tenant store.Tenant, bucket, merchant string) (int64, error)

func (*Store) ApplyCategoryByMerchant

func (s *Store) ApplyCategoryByMerchant(ctx context.Context, tenant store.Tenant, category, merchant string) (int64, error)

func (*Store) ApplyLabelByMerchant

func (s *Store) ApplyLabelByMerchant(ctx context.Context, tenant store.Tenant, label, pattern string) (int64, error)

func (*Store) BootstrapRequired

func (s *Store) BootstrapRequired(ctx context.Context) (bool, error)

BootstrapRequired reports whether the instance has no users.

func (*Store) CategorizeMerchant

func (s *Store) CategorizeMerchant(ctx context.Context, tenant store.Tenant, merchant, category, bucket string) (int64, error)

func (*Store) ClearActiveLLMProvider

func (s *Store) ClearActiveLLMProvider(ctx context.Context, tenant store.Tenant) error

func (*Store) ClearActiveScanningReader

func (s *Store) ClearActiveScanningReader(ctx context.Context, tenant store.Tenant) error

func (*Store) Close

func (s *Store) Close()

Close releases the SQLite connection pool.

func (*Store) CompleteAccountSetup

func (s *Store) CompleteAccountSetup(ctx context.Context, input store.CompleteAccountSetupInput) (*store.User, error)

CompleteAccountSetup updates a user and consumes a valid setup token atomically.

func (*Store) CreateAccessToken

func (s *Store) CreateAccessToken(ctx context.Context, input store.CreateAccessTokenInput) (*store.AccessToken, error)

CreateAccessToken creates a programmatic access token record.

func (*Store) CreateAccountSetupToken

func (s *Store) CreateAccountSetupToken(ctx context.Context, input store.CreateAccountSetupTokenInput) (*store.AccountSetupToken, error)

CreateAccountSetupToken creates a one-time account setup token record.

func (*Store) CreateBootstrapAdmin

func (s *Store) CreateBootstrapAdmin(ctx context.Context, input store.CreateBootstrapAdminInput) (*store.User, error)

CreateBootstrapAdmin creates the first user as an administrator.

func (*Store) CreateBucket

func (s *Store) CreateBucket(ctx context.Context, tenant store.Tenant, name, description string) error

func (*Store) CreateCategory

func (s *Store) CreateCategory(ctx context.Context, tenant store.Tenant, name, description string) error

func (*Store) CreateLabel

func (s *Store) CreateLabel(ctx context.Context, tenant store.Tenant, name, color string) error

func (*Store) CreateRule

func (s *Store) CreateRule(ctx context.Context, tenant store.Tenant, rule store.RuleRow) (*store.RuleRow, error)

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, input store.CreateSessionInput) (*store.Session, error)

CreateSession creates a browser session.

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, input store.CreateUserInput) (*store.User, error)

CreateUser creates an instance user.

func (*Store) DeleteBucket

func (s *Store) DeleteBucket(ctx context.Context, tenant store.Tenant, name string, removeFromTransactions bool) error

func (*Store) DeleteCategory

func (s *Store) DeleteCategory(ctx context.Context, tenant store.Tenant, name string, removeFromTransactions bool) error

func (*Store) DeleteLLMProviderRuntime

func (s *Store) DeleteLLMProviderRuntime(ctx context.Context, tenant store.Tenant, provider string) error

func (*Store) DeleteLabel

func (s *Store) DeleteLabel(ctx context.Context, tenant store.Tenant, name string, removeFromTransactions bool) error

func (*Store) DeleteMutedMerchant

func (s *Store) DeleteMutedMerchant(ctx context.Context, tenant store.Tenant, id string) error

func (*Store) DeleteMutedMerchantAndUnmute

func (s *Store) DeleteMutedMerchantAndUnmute(ctx context.Context, tenant store.Tenant, id string) error

func (*Store) DeleteReaderRuntime

func (s *Store) DeleteReaderRuntime(ctx context.Context, tenant store.Tenant, reader string) error

func (*Store) DeleteReaderToken

func (s *Store) DeleteReaderToken(ctx context.Context, tenant store.Tenant, reader string) error

func (*Store) DeleteRule

func (s *Store) DeleteRule(ctx context.Context, tenant store.Tenant, id string) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, id string) error

DeleteUser deletes a user and all rows that depend on it.

func (*Store) EnsureScanningStateForTenant

func (s *Store) EnsureScanningStateForTenant(ctx context.Context, tenant store.Tenant) error

func (*Store) FindAccessTokenByHash

func (s *Store) FindAccessTokenByHash(ctx context.Context, tokenHash string) (*store.AccessToken, error)

FindAccessTokenByHash finds an access token by its token hash.

func (*Store) FindAccountSetupTokenByHash

func (s *Store) FindAccountSetupTokenByHash(ctx context.Context, tokenHash string) (*store.AccountSetupToken, error)

FindAccountSetupTokenByHash finds an account setup token by its hash.

func (*Store) FindSessionByHash

func (s *Store) FindSessionByHash(ctx context.Context, tokenHash string) (*store.Session, error)

FindSessionByHash finds a session by its token hash.

func (*Store) FindUserByEmail

func (s *Store) FindUserByEmail(ctx context.Context, email string) (*store.User, error)

FindUserByEmail finds a user with case-insensitive email matching.

func (*Store) FindUserByID

func (s *Store) FindUserByID(ctx context.Context, id string) (*store.User, error)

FindUserByID finds a user by ID.

func (*Store) GetActiveLLMProviderRuntime

func (s *Store) GetActiveLLMProviderRuntime(ctx context.Context, tenant store.Tenant) (store.LLMProviderRuntime, bool, error)

func (*Store) GetAnnualSpend

func (s *Store) GetAnnualSpend(ctx context.Context, tenant store.Tenant, year int) ([]store.DailyBucket, error)

func (*Store) GetAppConfig

func (s *Store) GetAppConfig(ctx context.Context, tenant store.Tenant, key string) (string, error)

func (*Store) GetBucketMappings

func (s *Store) GetBucketMappings(ctx context.Context, tenant store.Tenant) (map[string][]string, error)

func (*Store) GetCategoryMappings

func (s *Store) GetCategoryMappings(ctx context.Context, tenant store.Tenant) (map[string][]string, error)

func (*Store) GetChartData

func (s *Store) GetChartData(ctx context.Context, tenant store.Tenant) (*store.ChartData, error)

func (*Store) GetCommunitySyncSettings

func (s *Store) GetCommunitySyncSettings(ctx context.Context) (store.CommunitySyncSettings, error)

func (*Store) GetCommunityURL

func (s *Store) GetCommunityURL(ctx context.Context) (string, error)

func (*Store) GetDashboardData

func (s *Store) GetDashboardData(ctx context.Context, tenant store.Tenant) (*store.DashboardData, error)

func (*Store) GetExtractionDiagnostic

func (s *Store) GetExtractionDiagnostic(ctx context.Context, tenant store.Tenant, id string) (*store.ExtractionDiagnosticRow, error)

func (*Store) GetFacets

func (s *Store) GetFacets(ctx context.Context, tenant store.Tenant) (*store.Facets, error)

func (*Store) GetLLMProviderConfig

func (s *Store) GetLLMProviderConfig(
	ctx context.Context,
	tenant store.Tenant,
	provider string,
) (config json.RawMessage, found bool, err error)

func (*Store) GetLLMProviderCredentials

func (s *Store) GetLLMProviderCredentials(
	ctx context.Context,
	tenant store.Tenant,
	provider string,
) (credentials []byte, found bool, err error)

func (*Store) GetLabelMappings

func (s *Store) GetLabelMappings(ctx context.Context, tenant store.Tenant) (map[string][]string, error)

func (*Store) GetMonthlyBreakdownSpend

func (s *Store) GetMonthlyBreakdownSpend(ctx context.Context, tenant store.Tenant, dimension string, months int) (*store.MonthlyBreakdownData, error)

func (*Store) GetMutedMerchantPatterns

func (s *Store) GetMutedMerchantPatterns(ctx context.Context, tenant store.Tenant) ([]string, error)

func (*Store) GetMutedMerchantsWithCount

func (s *Store) GetMutedMerchantsWithCount(ctx context.Context, tenant store.Tenant) ([]store.MutedMerchantWithCount, error)

func (*Store) GetReaderConfig

func (s *Store) GetReaderConfig(
	ctx context.Context,
	tenant store.Tenant,
	reader string,
) (config json.RawMessage, found bool, err error)

func (*Store) GetReaderSecret

func (s *Store) GetReaderSecret(
	ctx context.Context,
	tenant store.Tenant,
	reader string,
) (value []byte, found bool, err error)

func (*Store) GetReaderToken

func (s *Store) GetReaderToken(
	ctx context.Context,
	tenant store.Tenant,
	reader string,
) (value []byte, found bool, err error)

func (*Store) GetRule

func (s *Store) GetRule(ctx context.Context, tenant store.Tenant, id string) (*store.RuleRow, error)

func (*Store) GetScanningState

func (s *Store) GetScanningState(ctx context.Context, tenant store.Tenant) (store.TenantScanningState, error)

func (*Store) GetSchedulerConfig

func (s *Store) GetSchedulerConfig(ctx context.Context) (store.SchedulerConfig, error)

func (*Store) GetSpendingHeatmap

func (s *Store) GetSpendingHeatmap(ctx context.Context, tenant store.Tenant, from, to *time.Time) (*store.HeatmapData, error)

func (*Store) GetStats

func (s *Store) GetStats(ctx context.Context, tenant store.Tenant, baseCurrency string) (*store.Stats, error)

func (*Store) GetSyncStatus

func (s *Store) GetSyncStatus(ctx context.Context) (store.SyncStatus, error)

func (*Store) GetTransaction

func (s *Store) GetTransaction(ctx context.Context, tenant store.Tenant, id string) (*store.Transaction, error)

func (*Store) HealthCheck

func (s *Store) HealthCheck(ctx context.Context) error

HealthCheck verifies that the SQLite database is reachable.

func (*Store) ImportUserRules

func (s *Store) ImportUserRules(ctx context.Context, tenant store.Tenant, rules []store.RuleRow) error

func (*Store) IsMessageProcessed

func (s *Store) IsMessageProcessed(ctx context.Context, tenant store.Tenant, key string) (bool, error)

func (*Store) ListAccessTokens

func (s *Store) ListAccessTokens(ctx context.Context, userID string) ([]store.AccessToken, error)

ListAccessTokens lists active access tokens for a user.

func (*Store) ListBuckets

func (s *Store) ListBuckets(ctx context.Context, tenant store.Tenant) ([]store.Bucket, error)

func (*Store) ListCategories

func (s *Store) ListCategories(ctx context.Context, tenant store.Tenant) ([]store.Category, error)

func (*Store) ListExtractionDiagnostics

func (s *Store) ListExtractionDiagnostics(ctx context.Context, tenant store.Tenant, filter store.DiagnosticFilter) ([]store.ExtractionDiagnosticRow, error)

func (*Store) ListLabels

func (s *Store) ListLabels(ctx context.Context, tenant store.Tenant) ([]store.Label, error)

func (*Store) ListMutedMerchants

func (s *Store) ListMutedMerchants(ctx context.Context, tenant store.Tenant) ([]store.MutedMerchant, error)

func (*Store) ListRules

func (s *Store) ListRules(ctx context.Context, tenant store.Tenant) ([]store.RuleRow, error)

func (*Store) ListRunnableScanningStates

func (s *Store) ListRunnableScanningStates(ctx context.Context) ([]store.TenantScanningState, error)

func (*Store) ListScanningStates

func (s *Store) ListScanningStates(ctx context.Context) ([]store.TenantScanningState, error)

func (*Store) ListTransactions

func (s *Store) ListTransactions(ctx context.Context, tenant store.Tenant, filter store.ListFilter) ([]store.Transaction, store.TransactionListResult, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context) ([]store.User, error)

ListUsers lists all instance users in creation order.

func (*Store) LoadCategorySnapshot

func (s *Store) LoadCategorySnapshot(ctx context.Context) (api.CategoryResolver, error)

func (*Store) MarkAccessTokenUsed

func (s *Store) MarkAccessTokenUsed(ctx context.Context, id string) error

MarkAccessTokenUsed records use of an active access token.

func (*Store) MarkAccountSetupTokenUsed

func (s *Store) MarkAccountSetupTokenUsed(ctx context.Context, id string) error

MarkAccountSetupTokenUsed marks an account setup token as used.

func (*Store) MarkMessageProcessed

func (s *Store) MarkMessageProcessed(ctx context.Context, tenant store.Tenant, key string, at time.Time) error

func (*Store) MuteByMerchant

func (s *Store) MuteByMerchant(ctx context.Context, tenant store.Tenant, pattern, reason string) error

func (*Store) MuteTransaction

func (s *Store) MuteTransaction(ctx context.Context, tenant store.Tenant, id string, muted bool, reason string) error

func (*Store) PatchCommunitySyncSettings

func (s *Store) PatchCommunitySyncSettings(ctx context.Context, patch store.CommunitySyncSettingsPatch) (store.CommunitySyncSettings, error)

func (*Store) PatchSchedulerConfig

func (s *Store) PatchSchedulerConfig(ctx context.Context, patch store.SchedulerConfigPatch) (store.SchedulerConfig, error)

func (*Store) RecordExtractionDiagnostic

func (s *Store) RecordExtractionDiagnostic(ctx context.Context, tenant store.Tenant, diagnostic api.ExtractionDiagnostic) error

func (*Store) RemoveBucketByMerchant

func (s *Store) RemoveBucketByMerchant(ctx context.Context, tenant store.Tenant, bucket, merchant string) (int64, error)

func (*Store) RemoveCategoryByMerchant

func (s *Store) RemoveCategoryByMerchant(ctx context.Context, tenant store.Tenant, category, merchant string) (int64, error)

func (*Store) RemoveLabel

func (s *Store) RemoveLabel(ctx context.Context, tenant store.Tenant, transactionID, label string) error

func (*Store) RemoveLabelByMerchant

func (s *Store) RemoveLabelByMerchant(ctx context.Context, tenant store.Tenant, label, pattern string) (int64, error)

func (*Store) RevokeAccessToken

func (s *Store) RevokeAccessToken(ctx context.Context, id, userID string) error

RevokeAccessToken revokes an access token owned by a user.

func (*Store) RevokeSession

func (s *Store) RevokeSession(ctx context.Context, id string) error

RevokeSession revokes a browser session.

func (*Store) SearchTransactions

func (s *Store) SearchTransactions(
	ctx context.Context,
	tenant store.Tenant,
	query string,
	filter store.ListFilter,
) ([]store.Transaction, store.TransactionListResult, error)

func (*Store) Seed

func (s *Store) Seed(ctx context.Context, content store.SeedContent) (api.CategoryResolver, error)

func (*Store) SeedMCCCategories

func (s *Store) SeedMCCCategories(ctx context.Context, names []string) error

func (*Store) SeedMCCCodes

func (s *Store) SeedMCCCodes(ctx context.Context, entries []store.MCCEntry) error

func (*Store) SeedMerchantCategories

func (s *Store) SeedMerchantCategories(ctx context.Context, entries []store.MerchantCategoryEntry) (int64, error)

func (*Store) SeedPredefinedRules

func (s *Store) SeedPredefinedRules(ctx context.Context, rules []store.RuleRow) error

func (*Store) SetActiveLLMProvider

func (s *Store) SetActiveLLMProvider(ctx context.Context, tenant store.Tenant, provider string) error

func (*Store) SetActiveScanningReader

func (s *Store) SetActiveScanningReader(ctx context.Context, tenant store.Tenant, reader string) error

func (*Store) SetAppConfig

func (s *Store) SetAppConfig(ctx context.Context, tenant store.Tenant, key, value string) error

func (*Store) SetCommunityURL

func (s *Store) SetCommunityURL(ctx context.Context, url string) error

func (*Store) SetLLMProviderConfig

func (s *Store) SetLLMProviderConfig(ctx context.Context, tenant store.Tenant, provider string, config json.RawMessage) error

func (*Store) SetLLMProviderCredentials

func (s *Store) SetLLMProviderCredentials(ctx context.Context, tenant store.Tenant, provider string, credentials []byte) error

func (*Store) SetReaderConfig

func (s *Store) SetReaderConfig(ctx context.Context, tenant store.Tenant, reader string, config json.RawMessage) error

func (*Store) SetReaderSecret

func (s *Store) SetReaderSecret(ctx context.Context, tenant store.Tenant, reader string, secret []byte) error

func (*Store) SetReaderToken

func (s *Store) SetReaderToken(ctx context.Context, tenant store.Tenant, reader string, token []byte) error

func (*Store) SetScanningEnabled

func (s *Store) SetScanningEnabled(ctx context.Context, tenant store.Tenant, enabled bool) error

func (*Store) SetSyncStatus

func (s *Store) SetSyncStatus(ctx context.Context, status store.SyncStatus) error

func (*Store) UnmuteByPattern

func (s *Store) UnmuteByPattern(ctx context.Context, tenant store.Tenant, pattern string) error

func (*Store) UpdateDescription

func (s *Store) UpdateDescription(ctx context.Context, tenant store.Tenant, id, description string) error

func (*Store) UpdateExtractionDiagnosticStatus

func (s *Store) UpdateExtractionDiagnosticStatus(ctx context.Context, tenant store.Tenant, id, status string) (*store.ExtractionDiagnosticRow, error)

func (*Store) UpdateLabel

func (s *Store) UpdateLabel(ctx context.Context, tenant store.Tenant, name, color string) error

func (*Store) UpdateMerchantReason

func (s *Store) UpdateMerchantReason(ctx context.Context, tenant store.Tenant, id, reason string) error

func (*Store) UpdateMuteReason

func (s *Store) UpdateMuteReason(ctx context.Context, tenant store.Tenant, id, reason string) error

func (*Store) UpdateRule

func (s *Store) UpdateRule(ctx context.Context, tenant store.Tenant, id string, rule store.RuleRow) (*store.RuleRow, error)

func (*Store) UpdateScanningState

func (s *Store) UpdateScanningState(ctx context.Context, tenant store.Tenant, update store.ScanningStateUpdate) error

func (*Store) UpdateTransaction

func (s *Store) UpdateTransaction(ctx context.Context, tenant store.Tenant, id string, update store.TransactionUpdate) error

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, id string, input store.UpdateUserInput) (*store.User, error)

UpdateUser updates mutable user metadata.

func (*Store) UpdateUserPassword

func (s *Store) UpdateUserPassword(ctx context.Context, id string, input store.UpdateUserPasswordInput) error

UpdateUserPassword replaces a user's password hash.

func (*Store) Write

func (s *Store) Write(ctx context.Context, batch store.IngestionBatch) error

Write atomically persists one tenant-scoped ingestion batch.

Directories

Path Synopsis
Package migrations embeds and applies the SQLite baseline schema.
Package migrations embeds and applies the SQLite baseline schema.

Jump to

Keyboard shortcuts

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