import { PostgresJsDatabase } from 'drizzle-orm/postgres-js'; import { ICardQueryRepository, CardQueryOptions, PaginatedQueryResult, UrlCardQueryResultDTO, CollectionCardQueryResultDTO, UrlCardViewDTO, LibraryForUrlDTO, NoteCardForUrlRawDTO, UrlCardView, } from '../../domain/ICardQueryRepository'; import { UrlCardQueryService } from './query-services/UrlCardQueryService'; import { CollectionCardQueryService } from './query-services/CollectionCardQueryService'; import { LibraryQueryService } from './query-services/LibraryQueryService'; import { NoteCardQueryService } from './query-services/NoteCardQueryService'; export class DrizzleCardQueryRepository implements ICardQueryRepository { private urlCardQueryService: UrlCardQueryService; private collectionCardQueryService: CollectionCardQueryService; private libraryQueryService: LibraryQueryService; private noteCardQueryService: NoteCardQueryService; constructor(private db: PostgresJsDatabase) { this.urlCardQueryService = new UrlCardQueryService(db); this.collectionCardQueryService = new CollectionCardQueryService(db); this.libraryQueryService = new LibraryQueryService(db); this.noteCardQueryService = new NoteCardQueryService(db); } async getUrlCardsOfUser( userId: string, options: CardQueryOptions, callingUserId?: string, ): Promise> { return this.urlCardQueryService.getUrlCardsOfUser( userId, options, callingUserId, ); } async getCardsInCollection( collectionId: string, options: CardQueryOptions, callingUserId?: string, ): Promise> { return this.collectionCardQueryService.getCardsInCollection( collectionId, options, callingUserId, ); } async getUrlCardView( cardId: string, callingUserId?: string, ): Promise { return this.urlCardQueryService.getUrlCardView(cardId, callingUserId); } async getUrlCardBasic( cardId: string, callingUserId?: string, ): Promise { return this.urlCardQueryService.getUrlCardBasic(cardId, callingUserId); } async getLibrariesForCard(cardId: string): Promise { return this.libraryQueryService.getLibrariesForCard(cardId); } async getLibrariesForUrl( url: string, options: CardQueryOptions, ): Promise> { return this.urlCardQueryService.getLibrariesForUrl(url, options); } async getNoteCardsForUrl( url: string, options: CardQueryOptions, ): Promise> { return this.noteCardQueryService.getNoteCardsForUrl(url, options); } }