repositories.ts raw

   1  import { Pubkey } from '../shared'
   2  import { BookmarkList } from './BookmarkList'
   3  import { PinList } from './PinList'
   4  
   5  /**
   6   * Repository interface for BookmarkList aggregate
   7   *
   8   * Implementations should handle:
   9   * - Local caching (IndexedDB)
  10   * - Remote fetching from relays
  11   * - Event publishing
  12   */
  13  export interface BookmarkListRepository {
  14    /**
  15     * Find the bookmark list for a user
  16     * Should check cache first, then fetch from relays if not found
  17     */
  18    findByOwner(pubkey: Pubkey): Promise<BookmarkList | null>
  19  
  20    /**
  21     * Save a bookmark list
  22     * Should publish to relays and update local cache
  23     */
  24    save(bookmarkList: BookmarkList): Promise<void>
  25  }
  26  
  27  /**
  28   * Repository interface for PinList aggregate
  29   *
  30   * Implementations should handle:
  31   * - Local caching (IndexedDB)
  32   * - Remote fetching from relays
  33   * - Event publishing
  34   */
  35  export interface PinListRepository {
  36    /**
  37     * Find the pin list for a user
  38     * Should check cache first, then fetch from relays if not found
  39     */
  40    findByOwner(pubkey: Pubkey): Promise<PinList | null>
  41  
  42    /**
  43     * Save a pin list
  44     * Should publish to relays and update local cache
  45     */
  46    save(pinList: PinList): Promise<void>
  47  }
  48