"use client";

/**
 * IUserStorage 接口
 *
 * 对齐 Dart 端 `IUserStorage`（lib/data/services/storage/iuser_storage.dart）：
 *   - User 对象 / userId / avatarUrl 三个独立字段的 CRUD
 *   - `clearUserData()` 批量清空
 *
 * 注：完整 User 模型见 `src/data/dto/user/user.ts`，本接口允许存 JSON 字符串，
 * 具体序列化由实现层通过 Zod schema 校验后转换为 `User` 类实例。
 */

import type { Result } from "@/utils";
import type { UserEntitlementSnapshotData } from "@/data/schemas/user/user_entitlement_snapshot";
import type { UserData } from "@/data/schemas/user/user";

export interface IUserStorage {
  getUser(): Promise<Result<UserData | null>>;
  setUser(user: UserData): Promise<Result<void>>;
  clearUser(): Promise<Result<void>>;

  getUserId(): Promise<Result<string | null>>;
  setUserId(id: string): Promise<Result<void>>;
  clearUserId(): Promise<Result<void>>;

  getAvatarUrl(): Promise<Result<string | null>>;
  setAvatarUrl(url: string): Promise<Result<void>>;
  clearAvatarUrl(): Promise<Result<void>>;

  getEntitlementSnapshot(): Promise<Result<UserEntitlementSnapshotData | null>>;
  setEntitlementSnapshot(
    data: UserEntitlementSnapshotData,
  ): Promise<Result<void>>;
  clearEntitlementSnapshot(): Promise<Result<void>>;

  clearUserData(): Promise<Result<void>>;
}
