Documentation
¶
Index ¶
- func ClearAuth() error
- func ConfigDir() (string, error)
- func GenerateDeviceID() (string, error)
- func GetAPIKey() string
- func GetAutoSyncDebounce() time.Duration
- func GetAutoSyncEnabled() bool
- func GetAutoSyncInterval() time.Duration
- func GetAutoSyncOnStart() bool
- func GetAutoSyncPull() bool
- func GetDeviceID() (string, error)
- func GetServerURL() string
- func GetSnapshotThreshold() int
- func IsAuthenticated() bool
- func SaveAuth(creds *AuthCredentials) error
- func SaveConfig(cfg *Config) error
- type AuthCredentials
- type AutoSyncConfig
- type Config
- type SyncConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateDeviceID ¶
GenerateDeviceID creates a new random device ID (16 bytes hex).
func GetAPIKey ¶
func GetAPIKey() string
GetAPIKey returns the API key. Priority: TD_AUTH_KEY env > auth.json.
func GetAutoSyncDebounce ¶
GetAutoSyncDebounce returns the debounce duration for post-mutation sync. Priority: TD_SYNC_AUTO_DEBOUNCE env > config.json sync.auto.debounce > 3s
func GetAutoSyncEnabled ¶
func GetAutoSyncEnabled() bool
GetAutoSyncEnabled returns whether auto-sync is enabled. Priority: TD_SYNC_AUTO env > config.json sync.auto.enabled > true
func GetAutoSyncInterval ¶
GetAutoSyncInterval returns the periodic sync interval. Priority: TD_SYNC_AUTO_INTERVAL env > config.json sync.auto.interval > 5m
func GetAutoSyncOnStart ¶
func GetAutoSyncOnStart() bool
GetAutoSyncOnStart returns whether to sync on startup. Priority: TD_SYNC_AUTO_START env > config.json sync.auto.on_start > true
func GetAutoSyncPull ¶
func GetAutoSyncPull() bool
GetAutoSyncPull returns whether auto-sync should include pull. Priority: TD_SYNC_AUTO_PULL env > config.json sync.auto.pull > true
func GetDeviceID ¶
GetDeviceID returns the device ID from auth.json, generating one if needed.
func GetServerURL ¶
func GetServerURL() string
GetServerURL returns the sync server URL. Priority: TD_SYNC_URL env > config.json > default.
func GetSnapshotThreshold ¶
func GetSnapshotThreshold() int
GetSnapshotThreshold returns the snapshot bootstrap threshold (min server events). Priority: TD_SYNC_SNAPSHOT_THRESHOLD env > config.json > default (100).
func IsAuthenticated ¶
func IsAuthenticated() bool
IsAuthenticated returns true if an API key is available.
func SaveAuth ¶
func SaveAuth(creds *AuthCredentials) error
SaveAuth writes auth credentials to ~/.config/td/auth.json (0600 perms).
func SaveConfig ¶
SaveConfig writes the global config to ~/.config/td/config.json.
Types ¶
type AuthCredentials ¶
type AuthCredentials struct {
APIKey string `json:"api_key"`
UserID string `json:"user_id"`
Email string `json:"email"`
ServerURL string `json:"server_url"`
DeviceID string `json:"device_id"`
ExpiresAt string `json:"expires_at"`
}
AuthCredentials stores authentication state at ~/.config/td/auth.json.
func LoadAuth ¶
func LoadAuth() (*AuthCredentials, error)
LoadAuth reads auth credentials from ~/.config/td/auth.json.
type AutoSyncConfig ¶
type AutoSyncConfig struct {
Enabled *bool `json:"enabled,omitempty"` // nil = default true
OnStart *bool `json:"on_start,omitempty"` // nil = default true
Debounce string `json:"debounce,omitempty"` // duration string, default "3s"
Interval string `json:"interval,omitempty"` // duration string, default "5m"
Pull *bool `json:"pull,omitempty"` // nil = default true
}
AutoSyncConfig holds auto-sync settings.
type Config ¶
type Config struct {
Sync SyncConfig `json:"sync"`
}
Config is the global td config stored at ~/.config/td/config.json.
func LoadConfig ¶
LoadConfig reads the global config from ~/.config/td/config.json.
type SyncConfig ¶
type SyncConfig struct {
URL string `json:"url"`
Enabled bool `json:"enabled"`
SnapshotThreshold *int `json:"snapshot_threshold,omitempty"`
Auto AutoSyncConfig `json:"auto"`
}
SyncConfig holds sync-related settings.