This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

semble / src / modules / cards / domain / ICardQueryRepository.ts
3.5 kB 148 lines
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 urlLibraryCount: number; 41 urlInLibrary?: boolean; 42 createdAt: Date; 43 updatedAt: Date; 44 authorId: string; // NEW - needed to enrich with author profile 45 note?: { 46 id: string; 47 text: string; 48 }; 49} 50 51export type CollectionCardQueryResultDTO = UrlCardView; 52// Raw data from repository - minimal, just what's stored 53export interface WithCollections { 54 collections: { id: string; name: string; authorId: string }[]; 55} 56 57export interface WithLibraries { 58 libraries: { userId: string }[]; 59} 60export type UrlCardQueryResultDTO = UrlCardView & WithCollections; 61 62// DTO for single URL card view with library and collection info 63export type UrlCardViewDTO = UrlCardView & WithCollections & WithLibraries; 64 65// Repository returns card data - will be enriched with user profile in use case 66export interface LibraryForUrlDTO { 67 userId: string; 68 card: { 69 id: string; 70 url: string; 71 cardContent: { 72 url: string; 73 title?: string; 74 description?: string; 75 author?: string; 76 thumbnailUrl?: string; 77 }; 78 libraryCount: number; 79 urlLibraryCount: number; 80 urlInLibrary?: boolean; 81 createdAt: Date; 82 updatedAt: Date; 83 note?: { 84 id: string; 85 text: string; 86 }; 87 }; 88 // Note: userId is the card author in this context (it's their card in their library) 89} 90 91// Raw repository DTO - what the repository returns (not enriched) 92export interface NoteCardForUrlRawDTO { 93 id: string; 94 note: string; 95 authorId: string; 96 createdAt: Date; 97 updatedAt: Date; 98} 99 100// Public DTO - what the use case returns (enriched with author profile) 101export interface NoteCardForUrlDTO { 102 id: string; 103 note: string; 104 author: { 105 id: string; 106 name: string; 107 handle: string; 108 avatarUrl?: string; 109 }; 110 createdAt: Date; 111 updatedAt: Date; 112} 113 114export interface ICardQueryRepository { 115 getUrlCardsOfUser( 116 userId: string, 117 options: CardQueryOptions, 118 callingUserId?: string, 119 ): Promise<PaginatedQueryResult<UrlCardQueryResultDTO>>; 120 121 getCardsInCollection( 122 collectionId: string, 123 options: CardQueryOptions, 124 callingUserId?: string, 125 ): Promise<PaginatedQueryResult<CollectionCardQueryResultDTO>>; 126 127 getUrlCardView( 128 cardId: string, 129 callingUserId?: string, 130 ): Promise<UrlCardViewDTO | null>; 131 132 getUrlCardBasic( 133 cardId: string, 134 callingUserId?: string, 135 ): Promise<UrlCardView | null>; 136 137 getLibrariesForCard(cardId: string): Promise<string[]>; 138 139 getLibrariesForUrl( 140 url: string, 141 options: CardQueryOptions, 142 ): Promise<PaginatedQueryResult<LibraryForUrlDTO>>; 143 144 getNoteCardsForUrl( 145 url: string, 146 options: CardQueryOptions, 147 ): Promise<PaginatedQueryResult<NoteCardForUrlRawDTO>>; 148}