import { Status } from '@vue-skuilder/common'; /** * Common types used by UserDB implementations across different sync strategies */ /** * Result type for account creation operations */ interface AccountCreationResult { status: Status; error?: string; } /** * Result type for authentication operations */ interface AuthenticationResult { ok: boolean; error?: string; } /** * Strategy interface for handling user data synchronization * Different implementations handle remote sync vs local-only storage */ interface SyncStrategy { /** * Set up the remote database for a user * @param username The username to set up remote DB for * @returns PouchDB database instance (may be same as local for no-op) */ setupRemoteDB(username: string): PouchDB.Database; /** * Get the database to use for write operations (local-first approach) * @param username The username to get write DB for * @returns PouchDB database instance for write operations */ getWriteDB?(username: string): PouchDB.Database; /** * Start synchronization between local and remote databases * @param localDB The local PouchDB instance * @param remoteDB The remote PouchDB instance */ startSync(localDB: PouchDB.Database, remoteDB: PouchDB.Database): void; /** * Stop synchronization (optional - for cleanup) */ stopSync?(): void; /** * Whether this strategy supports account creation */ canCreateAccount(): boolean; /** * Whether this strategy supports authentication */ canAuthenticate(): boolean; /** * Create a new user account (if supported) * @param username The username for the new account * @param password The password for the new account */ createAccount?(username: string, password: string): Promise; /** * Authenticate a user (if supported) * @param username The username to authenticate * @param password The password to authenticate with */ authenticate?(username: string, password: string): Promise; /** * Log out the current user (if supported) */ logout?(): Promise; /** * Get the current logged-in username * Returns the username if logged in, or a default guest username */ getCurrentUsername(): Promise; } export type { AccountCreationResult as A, SyncStrategy as S, AuthenticationResult as a };