Documentation
¶
Index ¶
- Constants
- Variables
- func AddMonths(t time.Time, months int) time.Time
- func ComputeNextDue(last *time.Time, intervalMonths int) *time.Time
- func DefaultDBPath() (string, error)
- func DocumentCacheDir() (string, error)
- func EvictStaleCache(dir string, ttl time.Duration) (int, error)
- func ExpandHome(path string) string
- func FormatCents(cents int64) string
- func FormatCompactCents(cents int64) string
- func FormatCompactOptionalCents(cents *int64) string
- func FormatDate(value *time.Time) string
- func FormatOptionalCents(cents *int64) string
- func ParseIntervalMonths(input string) (int, error)
- func ParseOptionalCents(input string) (*int64, error)
- func ParseOptionalDate(input string) (*time.Time, error)
- func ParseOptionalFloat(input string) (float64, error)
- func ParseOptionalInt(input string) (int, error)
- func ParseRequiredCents(input string) (int64, error)
- func ParseRequiredDate(input string) (time.Time, error)
- func ParseRequiredFloat(input string) (float64, error)
- func ParseRequiredInt(input string) (int, error)
- func TitleFromFilename(name string) string
- func ValidateDBPath(path string) error
- type Appliance
- type ChatInput
- type DeletionRecord
- type Document
- type HouseProfile
- type Incident
- type MaintenanceCategory
- type MaintenanceItem
- type PragmaColumn
- type Project
- type ProjectType
- type Quote
- type SeedSummary
- type ServiceLogEntry
- type Setting
- type Store
- func (s *Store) AppendChatInput(input string) error
- func (s *Store) AutoMigrate() error
- func (s *Store) Backup(ctx context.Context, destPath string) error
- func (s *Store) Close() error
- func (s *Store) ColumnHints() string
- func (s *Store) CountDocumentsByEntity(entityKind string, entityIDs []uint) (map[uint]int, error)
- func (s *Store) CountIncidentsByAppliance(applianceIDs []uint) (map[uint]int, error)
- func (s *Store) CountIncidentsByVendor(vendorIDs []uint) (map[uint]int, error)
- func (s *Store) CountMaintenanceByAppliance(applianceIDs []uint) (map[uint]int, error)
- func (s *Store) CountQuotesByProject(projectIDs []uint) (map[uint]int, error)
- func (s *Store) CountQuotesByVendor(vendorIDs []uint) (map[uint]int, error)
- func (s *Store) CountServiceLogs(itemIDs []uint) (map[uint]int, error)
- func (s *Store) CountServiceLogsByVendor(vendorIDs []uint) (map[uint]int, error)
- func (s *Store) CreateAppliance(item *Appliance) error
- func (s *Store) CreateDocument(doc *Document) error
- func (s *Store) CreateHouseProfile(profile HouseProfile) error
- func (s *Store) CreateIncident(item *Incident) error
- func (s *Store) CreateMaintenance(item *MaintenanceItem) error
- func (s *Store) CreateProject(project *Project) error
- func (s *Store) CreateQuote(quote *Quote, vendor Vendor) error
- func (s *Store) CreateServiceLog(entry *ServiceLogEntry, vendor Vendor) error
- func (s *Store) CreateVendor(vendor *Vendor) error
- func (s *Store) DataDump() string
- func (s *Store) DeleteAppliance(id uint) error
- func (s *Store) DeleteDocument(id uint) error
- func (s *Store) DeleteIncident(id uint) error
- func (s *Store) DeleteMaintenance(id uint) error
- func (s *Store) DeleteProject(id uint) error
- func (s *Store) DeleteQuote(id uint) error
- func (s *Store) DeleteServiceLog(id uint) error
- func (s *Store) DeleteVendor(id uint) error
- func (s *Store) ExtractDocument(id uint) (string, error)
- func (s *Store) GetAppliance(id uint) (Appliance, error)
- func (s *Store) GetDocument(id uint) (Document, error)
- func (s *Store) GetIncident(id uint) (Incident, error)
- func (s *Store) GetLastModel() (string, error)
- func (s *Store) GetMaintenance(id uint) (MaintenanceItem, error)
- func (s *Store) GetProject(id uint) (Project, error)
- func (s *Store) GetQuote(id uint) (Quote, error)
- func (s *Store) GetServiceLog(id uint) (ServiceLogEntry, error)
- func (s *Store) GetSetting(key string) (string, error)
- func (s *Store) GetShowDashboard() (bool, error)
- func (s *Store) GetVendor(id uint) (Vendor, error)
- func (s *Store) HouseProfile() (HouseProfile, error)
- func (s *Store) IsMicasaDB() (bool, error)
- func (s *Store) LastDeletion(entity string) (DeletionRecord, error)
- func (s *Store) ListActiveProjects() ([]Project, error)
- func (s *Store) ListAppliances(includeDeleted bool) ([]Appliance, error)
- func (s *Store) ListDocuments(includeDeleted bool) ([]Document, error)
- func (s *Store) ListDocumentsByEntity(entityKind string, entityID uint, includeDeleted bool) ([]Document, error)
- func (s *Store) ListExpiringWarranties(now time.Time, lookBack, horizon time.Duration) ([]Appliance, error)
- func (s *Store) ListIncidents(includeDeleted bool) ([]Incident, error)
- func (s *Store) ListMaintenance(includeDeleted bool) ([]MaintenanceItem, error)
- func (s *Store) ListMaintenanceByAppliance(applianceID uint, includeDeleted bool) ([]MaintenanceItem, error)
- func (s *Store) ListMaintenanceWithSchedule() ([]MaintenanceItem, error)
- func (s *Store) ListOpenIncidents() ([]Incident, error)
- func (s *Store) ListProjects(includeDeleted bool) ([]Project, error)
- func (s *Store) ListQuotes(includeDeleted bool) ([]Quote, error)
- func (s *Store) ListQuotesByProject(projectID uint, includeDeleted bool) ([]Quote, error)
- func (s *Store) ListQuotesByVendor(vendorID uint, includeDeleted bool) ([]Quote, error)
- func (s *Store) ListRecentServiceLogs(limit int) ([]ServiceLogEntry, error)
- func (s *Store) ListServiceLog(maintenanceItemID uint, includeDeleted bool) ([]ServiceLogEntry, error)
- func (s *Store) ListServiceLogsByVendor(vendorID uint, includeDeleted bool) ([]ServiceLogEntry, error)
- func (s *Store) ListVendors(includeDeleted bool) ([]Vendor, error)
- func (s *Store) LoadChatHistory() ([]string, error)
- func (s *Store) MaintenanceCategories() ([]MaintenanceCategory, error)
- func (s *Store) MaxDocumentSize() uint64
- func (s *Store) ProjectTypes() ([]ProjectType, error)
- func (s *Store) PutLastModel(model string) error
- func (s *Store) PutSetting(key, value string) error
- func (s *Store) PutShowDashboard(show bool) error
- func (s *Store) ReadOnlyQuery(query string) (columns []string, rows [][]string, err error)
- func (s *Store) RestoreAppliance(id uint) error
- func (s *Store) RestoreDocument(id uint) error
- func (s *Store) RestoreIncident(id uint) error
- func (s *Store) RestoreMaintenance(id uint) error
- func (s *Store) RestoreProject(id uint) error
- func (s *Store) RestoreQuote(id uint) error
- func (s *Store) RestoreServiceLog(id uint) error
- func (s *Store) RestoreVendor(id uint) error
- func (s *Store) SeedDefaults() error
- func (s *Store) SeedDemoData() error
- func (s *Store) SeedDemoDataFrom(h *fake.HomeFaker) error
- func (s *Store) SeedScaledData(years int) (SeedSummary, error)
- func (s *Store) SeedScaledDataFrom(h *fake.HomeFaker, years int) (SeedSummary, error)
- func (s *Store) SetMaxDocumentSize(n uint64) error
- func (s *Store) TableColumns(table string) ([]PragmaColumn, error)
- func (s *Store) TableNames() ([]string, error)
- func (s *Store) TotalProjectSpendCents() (int64, error)
- func (s *Store) UpdateAppliance(item Appliance) error
- func (s *Store) UpdateDocument(doc Document) error
- func (s *Store) UpdateHouseProfile(profile HouseProfile) error
- func (s *Store) UpdateIncident(item Incident) error
- func (s *Store) UpdateMaintenance(item MaintenanceItem) error
- func (s *Store) UpdateProject(project Project) error
- func (s *Store) UpdateQuote(quote Quote, vendor Vendor) error
- func (s *Store) UpdateServiceLog(entry ServiceLogEntry, vendor Vendor) error
- func (s *Store) UpdateVendor(vendor Vendor) error
- func (s *Store) YTDServiceSpendCents(yearStart time.Time) (int64, error)
- type Vendor
Constants ¶
const ( ProjectStatusIdeating = "ideating" ProjectStatusPlanned = "planned" ProjectStatusQuoted = "quoted" ProjectStatusInProgress = "underway" ProjectStatusDelayed = "delayed" ProjectStatusCompleted = "completed" ProjectStatusAbandoned = "abandoned" )
const ( DeletionEntityProject = "project" DeletionEntityQuote = "quote" DeletionEntityMaintenance = "maintenance" DeletionEntityAppliance = "appliance" DeletionEntityServiceLog = "service_log" DeletionEntityVendor = "vendor" DeletionEntityDocument = "document" DeletionEntityIncident = "incident" )
const ( ColID = "id" ColName = "name" ColCreatedAt = "created_at" ColUpdatedAt = "updated_at" ColDeletedAt = "deleted_at" ColStatus = "status" ColActualCents = "actual_cents" ColBudgetCents = "budget_cents" ColCostCents = "cost_cents" ColTotalCents = "total_cents" ColIntervalMonths = "interval_months" ColLastServicedAt = "last_serviced_at" ColWarrantyExpiry = "warranty_expiry" ColServicedAt = "serviced_at" ColReceivedDate = "received_date" ColRestoredAt = "restored_at" ColVendorID = "vendor_id" ColProjectID = "project_id" ColProjectTypeID = "project_type_id" ColApplianceID = "appliance_id" ColMaintenanceItemID = "maintenance_item_id" ColEntityKind = "entity_kind" ColEntityID = "entity_id" ColEntity = "entity" ColTargetID = "target_id" ColContactName = "contact_name" ColEmail = "email" ColPhone = "phone" ColWebsite = "website" ColNotes = "notes" ColTitle = "title" ColFileName = "file_name" ColMIMEType = "mime_type" ColSizeBytes = "size_bytes" ColChecksum = "sha256" ColData = "data" ColSeverity = "severity" ColDescription = "description" ColDateNoticed = "date_noticed" ColDateResolved = "date_resolved" ColLocation = "location" ColIncidentID = "incident_id" )
Column name constants for use in raw SQL queries. Centralising these prevents drift between struct fields and hand-written SQL fragments.
const ( IncidentStatusOpen = "open" IncidentStatusInProgress = "in_progress" )
const ( IncidentSeverityUrgent = "urgent" IncidentSeveritySoon = "soon" IncidentSeverityWhenever = "whenever" )
const ( DocumentEntityNone = "" DocumentEntityProject = "project" DocumentEntityQuote = "quote" DocumentEntityMaintenance = "maintenance" DocumentEntityAppliance = "appliance" DocumentEntityServiceLog = "service_log" DocumentEntityVendor = "vendor" DocumentEntityIncident = "incident" )
Document entity kind values for polymorphic linking.
const AppName = "micasa"
const DateLayout = "2006-01-02"
const MaxDocumentSize uint64 = 50 << 20 // 50 MiB
MaxDocumentSize is the largest file that can be imported as a document attachment. SQLite handles arbitrarily large BLOBs, but reading a huge file into memory would be a bad experience.
Variables ¶
var ( // ErrParentDeleted indicates the parent record exists but is soft-deleted. ErrParentDeleted = errors.New("parent record is deleted") // ErrParentNotFound indicates the parent record doesn't exist at all. ErrParentNotFound = errors.New("parent record not found") )
var ( ErrInvalidMoney = errors.New("invalid money value") ErrNegativeMoney = errors.New("negative money value") ErrInvalidDate = errors.New("invalid date value") ErrInvalidInt = errors.New("invalid integer value") ErrInvalidFloat = errors.New("invalid decimal value") ErrInvalidInterval = errors.New("invalid interval value") )
Functions ¶
func AddMonths ¶ added in v1.29.0
AddMonths adds the given number of months to t, clamping the day to the last day of the target month. This avoids the time.AddDate gotcha where Jan 31 + 1 month = March 3 instead of Feb 28.
func DefaultDBPath ¶
func DocumentCacheDir ¶ added in v1.27.0
DocumentCacheDir returns the directory used for extracted document BLOBs. On Linux: $XDG_CACHE_HOME/micasa/documents (default ~/.cache/micasa/documents)
func EvictStaleCache ¶ added in v1.29.0
EvictStaleCache removes cached document files from dir that haven't been modified within the given TTL. A ttl of 0 disables eviction. Returns the number of files removed and any error encountered while listing the directory (individual file removal errors are skipped).
func ExpandHome ¶ added in v1.41.0
ExpandHome replaces a leading "~" or "~/" with the current user's home directory. Other forms like "~user/" are left as-is because os/user.Lookup requires cgo on macOS.
func FormatCents ¶
func FormatCompactCents ¶ added in v1.17.0
FormatCompactCents formats cents using abbreviated notation for large values: $1.2k, $45k, $1.3M. Values under $1,000 use full precision. Uses go-humanize for SI prefix formatting.
func FormatCompactOptionalCents ¶ added in v1.17.0
FormatCompactOptionalCents formats optional cents compactly.
func FormatDate ¶
func FormatOptionalCents ¶
func ParseIntervalMonths ¶ added in v1.30.0
ParseIntervalMonths parses a human-friendly interval into months. Accepts bare integers ("12"), month suffix ("6m"), year suffix ("1y"), or combined ("2y 6m", "1y6m"). Case-insensitive, whitespace-flexible. Returns (0, nil) for empty/blank input (non-recurring).
func ParseOptionalCents ¶
func ParseOptionalFloat ¶
func ParseOptionalInt ¶
func ParseRequiredCents ¶
func ParseRequiredFloat ¶
func ParseRequiredInt ¶
func TitleFromFilename ¶ added in v1.27.0
TitleFromFilename derives a human-friendly title from a filename by stripping extensions (including compound ones like .tar.gz), splitting on word boundaries via strcase, and title-casing each word.
func ValidateDBPath ¶ added in v1.10.1
ValidateDBPath rejects paths that could be interpreted as URIs by the SQLite driver. The underlying go-sqlite driver passes query strings through net/url.ParseQuery (subject to CVE GO-2026-4341) and enables SQLITE_OPEN_URI, so both file:// URIs and scheme://... URLs must be blocked. Only plain filesystem paths and the special ":memory:" value are accepted.
Types ¶
type Appliance ¶
type Appliance struct {
ID uint `gorm:"primaryKey"`
Name string
Brand string
ModelNumber string
SerialNumber string
PurchaseDate *time.Time
WarrantyExpiry *time.Time `gorm:"index"`
Location string
CostCents *int64
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type ChatInput ¶ added in v1.22.0
type ChatInput struct {
ID uint `gorm:"primaryKey"`
Input string `gorm:"not null"`
CreatedAt time.Time
}
ChatInput stores a single chat prompt for cross-session history. Ordered by creation time, newest last.
type DeletionRecord ¶
type Document ¶ added in v1.27.0
type Document struct {
ID uint `gorm:"primaryKey"`
Title string
FileName string `gorm:"column:file_name"`
EntityKind string `gorm:"index:idx_doc_entity"`
EntityID uint `gorm:"index:idx_doc_entity"`
MIMEType string
SizeBytes int64
ChecksumSHA256 string `gorm:"column:sha256"`
Data []byte
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type HouseProfile ¶
type HouseProfile struct {
ID uint `gorm:"primaryKey"`
Nickname string
AddressLine1 string
AddressLine2 string
City string
State string
PostalCode string
YearBuilt int
SquareFeet int
LotSquareFeet int
Bedrooms int
Bathrooms float64
FoundationType string
WiringType string
RoofType string
ExteriorType string
HeatingType string
CoolingType string
WaterSource string
SewerType string
ParkingType string
BasementType string
InsuranceCarrier string
InsurancePolicy string
InsuranceRenewal *time.Time
PropertyTaxCents *int64
HOAName string
HOAFeeCents *int64
CreatedAt time.Time
UpdatedAt time.Time
}
type Incident ¶ added in v1.36.0
type Incident struct {
ID uint `gorm:"primaryKey"`
Title string
Description string
Status string
Severity string
DateNoticed time.Time
DateResolved *time.Time
Location string
CostCents *int64
ApplianceID *uint `gorm:"index"`
Appliance Appliance `gorm:"constraint:OnDelete:SET NULL;"`
VendorID *uint `gorm:"index"`
Vendor Vendor `gorm:"constraint:OnDelete:SET NULL;"`
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type MaintenanceCategory ¶
type MaintenanceItem ¶
type MaintenanceItem struct {
ID uint `gorm:"primaryKey"`
Name string
CategoryID uint `gorm:"index"`
Category MaintenanceCategory `gorm:"constraint:OnDelete:RESTRICT;"`
ApplianceID *uint `gorm:"index"`
Appliance Appliance `gorm:"constraint:OnDelete:SET NULL;"`
LastServicedAt *time.Time
IntervalMonths int
ManualURL string
ManualText string
Notes string
CostCents *int64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type PragmaColumn ¶ added in v1.22.0
type PragmaColumn struct {
CID int `gorm:"column:cid"`
Name string `gorm:"column:name"`
Type string `gorm:"column:type"`
NotNull bool `gorm:"column:notnull"`
DfltValue *string `gorm:"column:dflt_value"`
PK int `gorm:"column:pk"`
}
PragmaColumn mirrors the output of PRAGMA table_info.
type Project ¶
type Project struct {
ID uint `gorm:"primaryKey"`
Title string
ProjectTypeID uint
ProjectType ProjectType `gorm:"constraint:OnDelete:RESTRICT;"`
Status string
Description string
StartDate *time.Time
EndDate *time.Time
BudgetCents *int64
ActualCents *int64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type ProjectType ¶
type Quote ¶
type Quote struct {
ID uint `gorm:"primaryKey"`
ProjectID uint `gorm:"index"`
Project Project `gorm:"constraint:OnDelete:RESTRICT;"`
VendorID uint `gorm:"index"`
Vendor Vendor `gorm:"constraint:OnDelete:RESTRICT;"`
TotalCents int64
LaborCents *int64
MaterialsCents *int64
OtherCents *int64
ReceivedDate *time.Time
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type SeedSummary ¶ added in v1.33.0
type SeedSummary struct {
Vendors int
Projects int
Quotes int
Appliances int
Maintenance int
Incidents int
ServiceLogs int
Documents int
}
SeedSummary holds counts of generated entities for display after seeding.
type ServiceLogEntry ¶
type ServiceLogEntry struct {
ID uint `gorm:"primaryKey"`
MaintenanceItemID uint `gorm:"index"`
MaintenanceItem MaintenanceItem `gorm:"constraint:OnDelete:CASCADE;"`
ServicedAt time.Time
VendorID *uint `gorm:"index"`
Vendor Vendor `gorm:"constraint:OnDelete:SET NULL;"`
CostCents *int64
Notes string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
type Setting ¶ added in v1.22.0
Setting is a simple key-value store for app preferences that persist across sessions (e.g. last-used LLM model). Stored in SQLite so a single "micasa backup backup.db" captures everything.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AppendChatInput ¶ added in v1.22.0
AppendChatInput adds a prompt to the persistent history, deduplicating consecutive repeats. Trims old entries beyond chatHistoryMax.
func (*Store) AutoMigrate ¶
func (*Store) Backup ¶ added in v1.38.0
Backup creates a consistent snapshot of the database at destPath using SQLite's Online Backup API. The destination must not already exist. After copying, it runs PRAGMA integrity_check on the backup to verify internal consistency.
func (*Store) ColumnHints ¶ added in v1.22.0
ColumnHints queries the database for distinct values in key columns and returns them as a formatted string suitable for inclusion in an LLM prompt. Returns empty string if no hints are available.
func (*Store) CountDocumentsByEntity ¶ added in v1.27.0
func (s *Store) CountDocumentsByEntity( entityKind string, entityIDs []uint, ) (map[uint]int, error)
CountDocumentsByEntity counts non-deleted documents grouped by entity_id where entity_kind matches. Uses a custom query because documents use two-column polymorphic keys that countByFK can't handle.
func (*Store) CountIncidentsByAppliance ¶ added in v1.36.0
func (*Store) CountIncidentsByVendor ¶ added in v1.36.0
func (*Store) CountMaintenanceByAppliance ¶
CountMaintenanceByAppliance returns the count of non-deleted maintenance items for each appliance ID.
func (*Store) CountQuotesByProject ¶ added in v1.18.0
CountQuotesByProject returns the number of non-deleted quotes per project ID.
func (*Store) CountQuotesByVendor ¶ added in v1.6.0
CountQuotesByVendor returns the number of non-deleted quotes per vendor ID.
func (*Store) CountServiceLogs ¶
CountServiceLogs returns the number of non-deleted service log entries per maintenance item ID for the given set of IDs.
func (*Store) CountServiceLogsByVendor ¶ added in v1.6.0
CountServiceLogsByVendor returns the number of non-deleted service log entries per vendor ID.
func (*Store) CreateAppliance ¶
func (*Store) CreateDocument ¶ added in v1.27.0
func (*Store) CreateHouseProfile ¶
func (s *Store) CreateHouseProfile(profile HouseProfile) error
func (*Store) CreateIncident ¶ added in v1.36.0
func (*Store) CreateMaintenance ¶
func (s *Store) CreateMaintenance(item *MaintenanceItem) error
func (*Store) CreateProject ¶
func (*Store) CreateServiceLog ¶
func (s *Store) CreateServiceLog(entry *ServiceLogEntry, vendor Vendor) error
func (*Store) CreateVendor ¶ added in v1.6.0
func (*Store) DataDump ¶ added in v1.22.0
DataDump exports every row of every user table as readable text, suitable for stuffing into an LLM context window. For a home-scale database this is small enough to fit comfortably.
Unlike ReadOnlyQuery this bypasses the row cap and keyword filter -- table names come from sqlite_master so the queries are fully trusted.
The output is optimized for small LLMs: null/empty values are omitted, money columns (ending in "_ct") are formatted as dollars, and internal columns (id, created_at, updated_at, deleted_at) are excluded to reduce noise.
func (*Store) DeleteAppliance ¶
func (*Store) DeleteDocument ¶ added in v1.27.0
func (*Store) DeleteIncident ¶ added in v1.36.0
func (*Store) DeleteMaintenance ¶
func (*Store) DeleteProject ¶
func (*Store) DeleteQuote ¶
func (*Store) DeleteServiceLog ¶
func (*Store) DeleteVendor ¶ added in v1.11.0
func (*Store) ExtractDocument ¶ added in v1.27.0
ExtractDocument writes the document's BLOB content to the XDG cache directory and returns the resulting filesystem path. If the cached file already exists and has the expected size, the extraction is skipped.
func (*Store) GetLastModel ¶ added in v1.22.0
GetLastModel returns the persisted LLM model name, or "" if none.
func (*Store) GetMaintenance ¶
func (s *Store) GetMaintenance(id uint) (MaintenanceItem, error)
func (*Store) GetServiceLog ¶
func (s *Store) GetServiceLog(id uint) (ServiceLogEntry, error)
func (*Store) GetSetting ¶ added in v1.22.0
GetSetting retrieves a setting by key. Returns ("", nil) if not found.
func (*Store) GetShowDashboard ¶ added in v1.24.0
GetShowDashboard returns whether the dashboard should be shown on startup. Defaults to true when no preference has been saved.
func (*Store) HouseProfile ¶
func (s *Store) HouseProfile() (HouseProfile, error)
func (*Store) IsMicasaDB ¶ added in v1.38.0
IsMicasaDB returns true if the database contains the core micasa tables.
func (*Store) LastDeletion ¶
func (s *Store) LastDeletion(entity string) (DeletionRecord, error)
func (*Store) ListActiveProjects ¶
ListActiveProjects returns non-deleted projects with status "underway" or "delayed", preloading ProjectType.
func (*Store) ListAppliances ¶
func (*Store) ListDocuments ¶ added in v1.27.0
func (*Store) ListDocumentsByEntity ¶ added in v1.27.0
func (s *Store) ListDocumentsByEntity( entityKind string, entityID uint, includeDeleted bool, ) ([]Document, error)
ListDocumentsByEntity returns documents scoped to a specific entity, excluding the BLOB data.
func (*Store) ListExpiringWarranties ¶
func (s *Store) ListExpiringWarranties( now time.Time, lookBack, horizon time.Duration, ) ([]Appliance, error)
ListExpiringWarranties returns non-deleted appliances whose warranty expires between (now - lookBack) and (now + horizon).
func (*Store) ListIncidents ¶ added in v1.36.0
func (*Store) ListMaintenance ¶
func (s *Store) ListMaintenance(includeDeleted bool) ([]MaintenanceItem, error)
func (*Store) ListMaintenanceByAppliance ¶
func (s *Store) ListMaintenanceByAppliance( applianceID uint, includeDeleted bool, ) ([]MaintenanceItem, error)
func (*Store) ListMaintenanceWithSchedule ¶
func (s *Store) ListMaintenanceWithSchedule() ([]MaintenanceItem, error)
ListMaintenanceWithSchedule returns all non-deleted maintenance items that have a positive interval, preloading Category and Appliance. These are the items eligible for overdue/upcoming computation.
func (*Store) ListOpenIncidents ¶ added in v1.36.0
ListOpenIncidents returns non-deleted incidents (open or in-progress), preloading Appliance and Vendor. Ordered by severity (urgent first) then most recently updated.
func (*Store) ListQuotesByProject ¶ added in v1.18.0
ListQuotesByProject returns all quotes for a specific project.
func (*Store) ListQuotesByVendor ¶ added in v1.18.0
ListQuotesByVendor returns all quotes for a specific vendor.
func (*Store) ListRecentServiceLogs ¶
func (s *Store) ListRecentServiceLogs(limit int) ([]ServiceLogEntry, error)
ListRecentServiceLogs returns the most recent service log entries across all maintenance items, preloading MaintenanceItem and Vendor.
func (*Store) ListServiceLog ¶
func (s *Store) ListServiceLog( maintenanceItemID uint, includeDeleted bool, ) ([]ServiceLogEntry, error)
func (*Store) ListServiceLogsByVendor ¶ added in v1.18.0
func (s *Store) ListServiceLogsByVendor( vendorID uint, includeDeleted bool, ) ([]ServiceLogEntry, error)
ListServiceLogsByVendor returns all service log entries for a specific vendor.
func (*Store) LoadChatHistory ¶ added in v1.22.0
LoadChatHistory returns all persisted chat inputs, oldest first.
func (*Store) MaintenanceCategories ¶
func (s *Store) MaintenanceCategories() ([]MaintenanceCategory, error)
func (*Store) MaxDocumentSize ¶ added in v1.29.0
MaxDocumentSize returns the configured maximum file size for document imports.
func (*Store) ProjectTypes ¶
func (s *Store) ProjectTypes() ([]ProjectType, error)
func (*Store) PutLastModel ¶ added in v1.22.0
PutLastModel persists the LLM model name.
func (*Store) PutSetting ¶ added in v1.22.0
PutSetting upserts a setting.
func (*Store) PutShowDashboard ¶ added in v1.24.0
PutShowDashboard persists the user's dashboard visibility preference.
func (*Store) ReadOnlyQuery ¶ added in v1.22.0
ReadOnlyQuery executes a validated SELECT query and returns the results as string slices. Only SELECT statements are allowed; result rows are capped at maxQueryRows.
func (*Store) RestoreAppliance ¶
func (*Store) RestoreDocument ¶ added in v1.27.0
func (*Store) RestoreIncident ¶ added in v1.36.0
func (*Store) RestoreMaintenance ¶
func (*Store) RestoreProject ¶
func (*Store) RestoreQuote ¶
func (*Store) RestoreServiceLog ¶
func (*Store) RestoreVendor ¶ added in v1.11.0
func (*Store) SeedDefaults ¶
func (*Store) SeedDemoData ¶
SeedDemoData populates the database with realistic demo data using a fixed seed so the demo always looks the same. Skips if data already exists.
func (*Store) SeedDemoDataFrom ¶ added in v1.10.0
SeedDemoDataFrom populates the database with demo data generated by the given HomeFaker. Callers can pass different seeds for varied test data.
func (*Store) SeedScaledData ¶ added in v1.33.0
func (s *Store) SeedScaledData(years int) (SeedSummary, error)
SeedScaledData populates the database with years of simulated home ownership data using a fixed seed for deterministic output. Skips if data already exists.
func (*Store) SeedScaledDataFrom ¶ added in v1.33.0
SeedScaledDataFrom populates the database with scaled demo data generated by the given HomeFaker. The years parameter controls how many years of simulated home ownership to generate.
func (*Store) SetMaxDocumentSize ¶ added in v1.27.0
SetMaxDocumentSize overrides the maximum allowed file size for document imports. The value must be positive; zero is rejected.
func (*Store) TableColumns ¶ added in v1.22.0
func (s *Store) TableColumns(table string) ([]PragmaColumn, error)
TableColumns returns column metadata for the named table via PRAGMA. The table name is validated to contain only safe characters.
func (*Store) TableNames ¶ added in v1.22.0
TableNames returns the names of all non-internal tables in the database.
func (*Store) TotalProjectSpendCents ¶ added in v1.29.0
TotalProjectSpendCents returns the total actual spend across all non-deleted projects. Unlike service log entries (which have a serviced_at date), projects have no per-transaction date, so YTD filtering is not meaningful. The previous updated_at filter was incorrect: editing any project field (e.g. description) would cause its spend to appear/disappear from the total.
func (*Store) UpdateAppliance ¶
func (*Store) UpdateDocument ¶ added in v1.27.0
UpdateDocument persists changes to a document. Entity linkage (EntityID, EntityKind) is always preserved -- callers must use a dedicated method to re-link a document. When Data is empty the existing BLOB and file metadata columns are also preserved, so metadata-only edits don't erase the file.
func (*Store) UpdateHouseProfile ¶
func (s *Store) UpdateHouseProfile(profile HouseProfile) error
func (*Store) UpdateIncident ¶ added in v1.36.0
func (*Store) UpdateMaintenance ¶
func (s *Store) UpdateMaintenance(item MaintenanceItem) error
func (*Store) UpdateProject ¶
func (*Store) UpdateServiceLog ¶
func (s *Store) UpdateServiceLog(entry ServiceLogEntry, vendor Vendor) error