import type { UserPreferences } from './user-preferences'; import type { Persona } from './persona'; import type { DomainConversations, DataSharingRecord } from './conversation'; import type { SiteConfiguration, PageContext } from './site-configuration'; /** * Storage data version for migration support */ export type StorageVersion = '1.0.0' | '1.1.0' | '1.2.0'; /** * Storage migration status */ export type MigrationStatus = 'pending' | 'in-progress' | 'completed' | 'failed'; /** * Storage quota status */ export type QuotaStatus = 'normal' | 'warning' | 'critical' | 'exceeded'; /** * Storage backup status */ export type BackupStatus = 'none' | 'local' | 'cloud' | 'both'; /** * Storage encryption status (strong encryption only) */ export type EncryptionStatus = 'none' | 'strong'; /** * Storage sync status */ export type SyncStatus = 'disabled' | 'enabled' | 'syncing' | 'error'; /** * Storage metadata and versioning information */ export interface StorageMetadata { /** Current storage schema version */ version: StorageVersion; /** Timestamp when storage was last updated */ lastUpdated: string; /** Timestamp when storage was created */ createdAt: string; /** Total storage size in bytes */ totalSize: number; /** Available storage space in bytes */ availableSpace: number; /** Storage quota status */ quotaStatus: QuotaStatus; /** Whether storage is encrypted (strong encryption only) */ encryptionStatus: EncryptionStatus; /** Whether storage is synced */ syncStatus: SyncStatus; /** Backup status */ backupStatus: BackupStatus; /** Migration status */ migrationStatus: MigrationStatus; /** Number of domains with stored data */ domainCount: number; /** Number of total conversations stored */ conversationCount: number; } /** * Storage statistics and analytics (user-controlled metrics only) */ export interface StorageStatistics { /** Total number of messages stored */ totalMessages: number; /** Average response time in milliseconds */ averageResponseTime: number; /** Average satisfaction score (1-5) */ averageSatisfactionScore: number; /** Most active domain */ mostActiveDomain: string; /** Most used persona ID */ mostUsedPersona: string; /** Storage usage by domain */ domainUsage: Record; /** Storage usage by date */ dateUsage: Record; /** Storage usage by persona */ personaUsage: Record; } /** * Storage settings and configuration (user-controlled options only) */ export interface StorageSettings { /** Whether to enable automatic cleanup */ enableAutoCleanup: boolean; /** Days to keep conversation data */ retentionDays: number; /** Whether to compress stored data */ enableCompression: boolean; /** Whether to encrypt stored data (strong encryption only) */ enableEncryption: boolean; /** Whether to show storage warnings */ showStorageWarnings: boolean; /** Storage warning threshold percentage */ warningThreshold: number; /** Whether to auto-delete old data */ autoDeleteOldData: boolean; } /** * Storage error and recovery information */ export interface StorageErrorInfo { /** Error type */ type: 'quota_exceeded' | 'corruption' | 'migration_failed' | 'sync_error' | 'backup_error'; /** Error message */ message: string; /** Error timestamp */ timestamp: string; /** Whether error has been resolved */ resolved: boolean; /** Resolution timestamp */ resolvedAt?: string; /** Error details */ details?: Record; /** Recovery action taken */ recoveryAction?: string; } /** * Storage migration information */ export interface StorageMigrationInfo { /** Migration version */ fromVersion: StorageVersion; /** Target version */ toVersion: StorageVersion; /** Migration start timestamp */ startedAt: string; /** Migration completion timestamp */ completedAt?: string; /** Migration status */ status: MigrationStatus; /** Migration progress percentage */ progress: number; /** Number of items migrated */ itemsMigrated: number; /** Total number of items to migrate */ totalItems: number; /** Migration errors */ errors: StorageErrorInfo[]; /** Migration warnings */ warnings: string[]; } /** * Storage backup information */ export interface StorageBackupInfo { /** Backup ID */ backupId: string; /** Backup timestamp */ timestamp: string; /** Backup size in bytes */ size: number; /** Backup type */ type: 'manual' | 'automatic' | 'scheduled'; /** Backup location */ location: 'local' | 'cloud' | 'both'; /** Backup status */ status: 'pending' | 'in-progress' | 'completed' | 'failed'; /** Backup description */ description?: string; /** Backup metadata */ metadata?: Record; } /** * Storage sync information */ export interface StorageSyncInfo { /** Last sync timestamp */ lastSyncAt: string; /** Next sync timestamp */ nextSyncAt: string; /** Sync status */ status: SyncStatus; /** Number of items synced */ itemsSynced: number; /** Sync errors */ errors: StorageErrorInfo[]; /** Sync conflicts */ conflicts: number; /** Sync progress percentage */ progress: number; } /** * Floating container state for persistence across navigations */ export interface FloatingContainerState { /** Current container state type */ currentState: 'full' | 'bubble' | 'transparent' | 'minimized' | 'maximized'; /** Container position */ position: { x: number; y: number; }; /** Container size */ size: { width: number; height: number; }; /** Previous state for restoration */ previousState: 'full' | 'bubble' | 'transparent' | 'minimized' | 'maximized' | null; /** Whether container is visible */ isVisible: boolean; /** Last updated timestamp */ lastUpdated: string; } /** * Side Panel preferences (global, non-domain-specific) */ export interface SidePanelPreferences { /** Whether chat area is visible */ showChat: boolean; /** Optional last conversation URL used in the panel */ lastConversationUrl?: string; /** Prefer the Tavus prebuilt Conversation UI over the custom Daily React UI */ usePrebuiltConversation?: boolean; /** Timestamp for last update */ lastUpdated: string; /** Schema version for forward-compat */ schemaVersion: '1.0.0'; } /** * Domain-specific floating container preferences */ export interface DomainFloatingContainerPreferences { /** Domain identifier */ domain: string; /** Container state for this domain */ containerState: FloatingContainerState; /** Whether to auto-position on this domain */ autoPosition: boolean; /** Preferred corner for positioning */ preferredCorner: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; /** Whether to remember position for this domain */ rememberPosition: boolean; /** Whether to remember state for this domain */ rememberState: boolean; } /** * Complete extension storage structure */ export interface ExtensionStorage { /** Storage metadata */ metadata: StorageMetadata; /** Storage statistics */ statistics: StorageStatistics; /** Storage settings */ settings: StorageSettings; /** User preferences */ userPreferences: UserPreferences; /** Available personas */ personas: Record; /** Domain conversations */ domainConversations: Record; /** Site configurations */ siteConfigurations: Record; /** Current page contexts */ pageContexts: Record; /** Floating container preferences by domain */ floatingContainerPreferences: Record; /** Storage errors */ errors: StorageErrorInfo[]; /** Storage migrations */ migrations: StorageMigrationInfo[]; /** Storage backups */ backups: StorageBackupInfo[]; /** Storage sync information */ syncInfo: StorageSyncInfo; /** Data sharing records across all domains */ dataSharingRecords: DataSharingRecord[]; /** Custom storage data */ customData?: Record; }