Documentation
¶
Overview ¶
Package sync provides SQLite-based offline caching for Aha Studio.
Index ¶
- func DefaultDBPath() string
- type DB
- func (d *DB) Close() error
- func (d *DB) CreateFilter(f *SavedFilter) error
- func (d *DB) DeleteFilter(id string) error
- func (d *DB) FullTextSearch(query string, entityTypes []string, limit int) ([]map[string]any, error)
- func (d *DB) GetFeatureIDs(product string) ([]string, error)
- func (d *DB) GetFilter(id string) (*SavedFilter, error)
- func (d *DB) GetFilterByName(name string) (*SavedFilter, error)
- func (d *DB) GetLastSync(entity, product string) (time.Time, error)
- func (d *DB) GetRelationships(entityType, entityID string) ([]map[string]any, error)
- func (d *DB) GetSyncStatus(product string) (map[string]SyncStatus, error)
- func (d *DB) ListFilters() ([]SavedFilter, error)
- func (d *DB) QueryOffline(plan *planner.Plan) (*result.Result, error)
- func (d *DB) SetLastSync(entity, product string, t time.Time, count int) error
- func (d *DB) SetProduct(product string)
- func (d *DB) UpdateFilter(f *SavedFilter) error
- func (d *DB) UpsertComment(product string, data map[string]any) error
- func (d *DB) UpsertEpic(product string, data map[string]any) error
- func (d *DB) UpsertFeature(product string, data map[string]any) error
- func (d *DB) UpsertGoal(product string, data map[string]any) error
- func (d *DB) UpsertIdea(product string, data map[string]any) error
- func (d *DB) UpsertInitiative(product string, data map[string]any) error
- func (d *DB) UpsertProduct(data map[string]any) error
- func (d *DB) UpsertRelationship(fromType, fromID, relType, toType, toID, product string) error
- func (d *DB) UpsertRelease(product string, data map[string]any) error
- func (d *DB) UpsertRequirement(product string, data map[string]any) error
- func (d *DB) UpsertUser(data map[string]any) error
- type SavedFilter
- type Scheduler
- func (s *Scheduler) IsRunning() bool
- func (s *Scheduler) LastError() error
- func (s *Scheduler) LastSync() time.Time
- func (s *Scheduler) Start(ctx context.Context) error
- func (s *Scheduler) Status() SchedulerStatus
- func (s *Scheduler) Stop()
- func (s *Scheduler) SyncNow(ctx context.Context) ([]SyncResult, error)
- type SchedulerConfig
- type SchedulerStatus
- type SyncOptions
- type SyncResult
- type SyncStatus
- type Syncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite database connection for Aha data caching.
func (*DB) CreateFilter ¶
func (d *DB) CreateFilter(f *SavedFilter) error
CreateFilter creates a new saved filter.
func (*DB) DeleteFilter ¶
DeleteFilter deletes a saved filter by ID.
func (*DB) FullTextSearch ¶
func (d *DB) FullTextSearch(query string, entityTypes []string, limit int) ([]map[string]any, error)
FullTextSearch searches across all FTS5 tables.
func (*DB) GetFeatureIDs ¶
GetFeatureIDs returns all feature IDs for a product.
func (*DB) GetFilter ¶
func (d *DB) GetFilter(id string) (*SavedFilter, error)
GetFilter returns a saved filter by ID.
func (*DB) GetFilterByName ¶
func (d *DB) GetFilterByName(name string) (*SavedFilter, error)
GetFilterByName returns a saved filter by name.
func (*DB) GetLastSync ¶
GetLastSync returns the last sync time for an entity/product combination.
func (*DB) GetRelationships ¶
GetRelationships returns relationships for an entity.
func (*DB) GetSyncStatus ¶
func (d *DB) GetSyncStatus(product string) (map[string]SyncStatus, error)
GetSyncStatus returns the sync status for all entities.
func (*DB) ListFilters ¶
func (d *DB) ListFilters() ([]SavedFilter, error)
ListFilters returns all saved filters.
func (*DB) QueryOffline ¶
QueryOffline executes a query against the local SQLite database.
func (*DB) SetLastSync ¶
SetLastSync updates the last sync time for an entity/product combination.
func (*DB) SetProduct ¶
SetProduct sets the current product context.
func (*DB) UpdateFilter ¶
func (d *DB) UpdateFilter(f *SavedFilter) error
UpdateFilter updates an existing saved filter.
func (*DB) UpsertComment ¶
UpsertComment inserts or updates a comment record.
func (*DB) UpsertEpic ¶
UpsertEpic inserts or updates an epic record.
func (*DB) UpsertFeature ¶
UpsertFeature inserts or updates a feature record.
func (*DB) UpsertGoal ¶
UpsertGoal inserts or updates a goal record.
func (*DB) UpsertIdea ¶
UpsertIdea inserts or updates an idea record.
func (*DB) UpsertInitiative ¶
UpsertInitiative inserts or updates an initiative record.
func (*DB) UpsertProduct ¶
UpsertProduct inserts or updates a product record.
func (*DB) UpsertRelationship ¶
UpsertRelationship inserts or updates a relationship record.
func (*DB) UpsertRelease ¶
UpsertRelease inserts or updates a release record.
func (*DB) UpsertRequirement ¶
UpsertRequirement inserts or updates a requirement record.
type SavedFilter ¶
type SavedFilter struct {
ID string `json:"id"`
Name string `json:"name"`
AQL string `json:"aql"`
Product string `json:"product,omitempty"`
Description string `json:"description,omitempty"`
IsFavorite bool `json:"is_favorite"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
SavedFilter represents a saved AQL query.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages background sync operations.
func NewScheduler ¶
func NewScheduler(syncer *Syncer, cfg SchedulerConfig) *Scheduler
NewScheduler creates a new sync scheduler.
func (*Scheduler) Status ¶
func (s *Scheduler) Status() SchedulerStatus
Status returns the current scheduler status.
type SchedulerConfig ¶
type SchedulerConfig struct {
// Interval between sync runs. Default: 15 minutes.
Interval time.Duration
// Product ID to sync.
Product string
// Logger for sync events. Default: slog.Default().
Logger *slog.Logger
// Entities to sync. Default: all entities.
Entities []string
}
SchedulerConfig configures the sync scheduler.
func DefaultSchedulerConfig ¶
func DefaultSchedulerConfig() SchedulerConfig
DefaultSchedulerConfig returns default scheduler configuration.
type SchedulerStatus ¶
type SchedulerStatus struct {
Running bool
Interval time.Duration
Product string
LastSync time.Time
LastErr error
}
SchedulerStatus contains scheduler status information.
type SyncOptions ¶
type SyncOptions struct {
Product string // Product ID to sync
Incremental bool // Only sync changes since last sync
Since time.Time // Custom since time (overrides incremental lookup)
Entities []string // Specific entities to sync (nil = all)
}
SyncOptions configures a sync operation.
type SyncResult ¶
SyncResult contains the result of a sync operation.
type SyncStatus ¶
SyncStatus contains sync status for an entity.
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer synchronizes Aha data to a local SQLite database.
func (*Syncer) SyncAll ¶
func (s *Syncer) SyncAll(ctx context.Context, opts SyncOptions) ([]SyncResult, error)
SyncAll syncs all entities for a product.