repositories.ts raw

   1  import { Pubkey } from '../shared'
   2  import { FollowList } from './FollowList'
   3  import { MuteList } from './MuteList'
   4  import { PinnedUsersList } from './PinnedUsersList'
   5  
   6  /**
   7   * Repository interface for FollowList aggregate
   8   *
   9   * Implementations should handle:
  10   * - Local caching (IndexedDB)
  11   * - Remote fetching from relays
  12   * - Event publishing
  13   */
  14  export interface FollowListRepository {
  15    /**
  16     * Find the follow list for a user
  17     * Should check cache first, then fetch from relays if not found
  18     */
  19    findByOwner(pubkey: Pubkey): Promise<FollowList | null>
  20  
  21    /**
  22     * Save a follow list
  23     * Should publish to relays and update local cache
  24     */
  25    save(followList: FollowList): Promise<void>
  26  }
  27  
  28  /**
  29   * Repository interface for MuteList aggregate
  30   *
  31   * Implementations should handle:
  32   * - Local caching (IndexedDB)
  33   * - Remote fetching from relays
  34   * - NIP-04 encryption/decryption for private mutes
  35   * - Event publishing
  36   */
  37  export interface MuteListRepository {
  38    /**
  39     * Find the mute list for a user
  40     * Should check cache first, then fetch from relays if not found
  41     * Private mutes should be decrypted automatically
  42     */
  43    findByOwner(pubkey: Pubkey): Promise<MuteList | null>
  44  
  45    /**
  46     * Save a mute list
  47     * Should encrypt private mutes and publish to relays
  48     */
  49    save(muteList: MuteList): Promise<void>
  50  }
  51  
  52  /**
  53   * Repository interface for PinnedUsersList aggregate
  54   *
  55   * Implementations should handle:
  56   * - Local caching (IndexedDB)
  57   * - Remote fetching from relays
  58   * - NIP-04 encryption/decryption for private pins
  59   * - Event publishing
  60   */
  61  export interface PinnedUsersListRepository {
  62    /**
  63     * Find the pinned users list for a user
  64     * Should check cache first, then fetch from relays if not found
  65     * Private pins should be decrypted automatically
  66     */
  67    findByOwner(pubkey: Pubkey): Promise<PinnedUsersList | null>
  68  
  69    /**
  70     * Save a pinned users list
  71     * Should encrypt private pins and publish to relays
  72     */
  73    save(pinnedUsersList: PinnedUsersList): Promise<void>
  74  }
  75