A social knowledge tool for researchers built on ATProto
at development 2.3 kB view raw
1import { CardTypeEnum } from './value-objects/CardType'; 2 3export interface CardQueryOptions { 4 page: number; 5 limit: number; 6 sortBy: CardSortField; 7 sortOrder: SortOrder; 8} 9 10export interface PaginatedQueryResult<T> { 11 items: T[]; 12 totalCount: number; 13 hasMore: boolean; 14} 15 16export enum CardSortField { 17 CREATED_AT = 'createdAt', 18 UPDATED_AT = 'updatedAt', 19 LIBRARY_COUNT = 'libraryCount', 20} 21 22export enum SortOrder { 23 ASC = 'asc', 24 DESC = 'desc', 25} 26 27// Simplified DTO for cards in a collection (no collections array to avoid circular data) 28export interface UrlCardView { 29 id: string; 30 type: CardTypeEnum.URL; 31 url: string; 32 cardContent: { 33 url: string; 34 title?: string; 35 description?: string; 36 author?: string; 37 thumbnailUrl?: string; 38 }; 39 libraryCount: number; 40 createdAt: Date; 41 updatedAt: Date; 42 note?: { 43 id: string; 44 text: string; 45 }; 46} 47 48export type CollectionCardQueryResultDTO = UrlCardView; 49// Raw data from repository - minimal, just what's stored 50export interface WithCollections { 51 collections: { id: string; name: string; authorId: string }[]; 52} 53 54export interface WithLibraries { 55 libraries: { userId: string }[]; 56} 57export type UrlCardQueryResultDTO = UrlCardView & WithCollections; 58 59// DTO for single URL card view with library and collection info 60export type UrlCardViewDTO = UrlCardView & WithCollections & WithLibraries; 61 62export interface LibraryForUrlDTO { 63 userId: string; 64 cardId: string; 65} 66 67export interface NoteCardForUrlDTO { 68 id: string; 69 note: string; 70 authorId: string; 71 createdAt: Date; 72 updatedAt: Date; 73} 74 75export interface ICardQueryRepository { 76 getUrlCardsOfUser( 77 userId: string, 78 options: CardQueryOptions, 79 ): Promise<PaginatedQueryResult<UrlCardQueryResultDTO>>; 80 81 getCardsInCollection( 82 collectionId: string, 83 options: CardQueryOptions, 84 ): Promise<PaginatedQueryResult<CollectionCardQueryResultDTO>>; 85 86 getUrlCardView(cardId: string): Promise<UrlCardViewDTO | null>; 87 88 getLibrariesForCard(cardId: string): Promise<string[]>; 89 90 getLibrariesForUrl( 91 url: string, 92 options: CardQueryOptions, 93 ): Promise<PaginatedQueryResult<LibraryForUrlDTO>>; 94 95 getNoteCardsForUrl( 96 url: string, 97 options: CardQueryOptions, 98 ): Promise<PaginatedQueryResult<NoteCardForUrlDTO>>; 99}