This repository has no description
1import { CardTypeEnum } from './value-objects/CardType';
2import { UrlType } from './value-objects/UrlType';
3
4export interface CardQueryOptions {
5 page: number;
6 limit: number;
7 sortBy: CardSortField;
8 sortOrder: SortOrder;
9 urlType?: UrlType;
10}
11
12export interface PaginatedQueryResult<T> {
13 items: T[];
14 totalCount: number;
15 hasMore: boolean;
16}
17
18export enum CardSortField {
19 CREATED_AT = 'createdAt',
20 UPDATED_AT = 'updatedAt',
21 LIBRARY_COUNT = 'libraryCount',
22}
23
24export enum SortOrder {
25 ASC = 'asc',
26 DESC = 'desc',
27}
28
29// Simplified DTO for cards in a collection (no collections array to avoid circular data)
30export interface UrlCardView {
31 id: string;
32 type: CardTypeEnum.URL;
33 url: string;
34 uri?: string;
35 cardContent: {
36 url: string;
37 title?: string;
38 description?: string;
39 author?: string;
40 publishedDate?: Date;
41 siteName?: string;
42 imageUrl?: string;
43 type?: string;
44 retrievedAt?: Date;
45 doi?: string;
46 isbn?: string;
47 };
48 libraryCount: number;
49 urlLibraryCount: number;
50 urlInLibrary?: boolean;
51 createdAt: Date;
52 updatedAt: Date;
53 authorId: string; // NEW - needed to enrich with author profile
54 note?: {
55 id: string;
56 text: string;
57 };
58}
59
60export type CollectionCardQueryResultDTO = UrlCardView;
61// Raw data from repository - minimal, just what's stored
62export interface WithCollections {
63 collections: {
64 id: string;
65 name: string;
66 authorId: string;
67 accessType: string;
68 }[];
69}
70
71export interface WithLibraries {
72 libraries: { userId: string }[];
73}
74export type UrlCardQueryResultDTO = UrlCardView & WithCollections;
75
76// DTO for single URL card view with library and collection info
77export type UrlCardViewDTO = UrlCardView & WithCollections & WithLibraries;
78
79// Repository returns card data - will be enriched with user profile in use case
80export interface LibraryForUrlDTO {
81 userId: string;
82 card: {
83 id: string;
84 url: string;
85 uri?: string;
86 cardContent: {
87 url: string;
88 title?: string;
89 description?: string;
90 author?: string;
91 publishedDate?: Date;
92 siteName?: string;
93 imageUrl?: string;
94 type?: string;
95 retrievedAt?: Date;
96 doi?: string;
97 isbn?: string;
98 };
99 libraryCount: number;
100 urlLibraryCount: number;
101 urlInLibrary?: boolean;
102 createdAt: Date;
103 updatedAt: Date;
104 note?: {
105 id: string;
106 text: string;
107 };
108 };
109 // Note: userId is the card author in this context (it's their card in their library)
110}
111
112// Raw repository DTO - what the repository returns (not enriched)
113export interface NoteCardForUrlRawDTO {
114 id: string;
115 note: string;
116 authorId: string;
117 createdAt: Date;
118 updatedAt: Date;
119}
120
121// Public DTO - what the use case returns (enriched with author profile)
122export interface NoteCardForUrlDTO {
123 id: string;
124 note: string;
125 author: {
126 id: string;
127 name: string;
128 handle: string;
129 avatarUrl?: string;
130 };
131 createdAt: Date;
132 updatedAt: Date;
133}
134
135export interface ICardQueryRepository {
136 getUrlCardsOfUser(
137 userId: string,
138 options: CardQueryOptions,
139 callingUserId?: string,
140 ): Promise<PaginatedQueryResult<UrlCardQueryResultDTO>>;
141
142 getCardsInCollection(
143 collectionId: string,
144 options: CardQueryOptions,
145 callingUserId?: string,
146 ): Promise<PaginatedQueryResult<CollectionCardQueryResultDTO>>;
147
148 getUrlCardView(
149 cardId: string,
150 callingUserId?: string,
151 ): Promise<UrlCardViewDTO | null>;
152
153 getUrlCardBasic(
154 cardId: string,
155 callingUserId?: string,
156 ): Promise<UrlCardView | null>;
157
158 getLibrariesForCard(cardId: string): Promise<string[]>;
159
160 getLibrariesForUrl(
161 url: string,
162 options: CardQueryOptions,
163 ): Promise<PaginatedQueryResult<LibraryForUrlDTO>>;
164
165 getNoteCardsForUrl(
166 url: string,
167 options: CardQueryOptions,
168 ): Promise<PaginatedQueryResult<NoteCardForUrlRawDTO>>;
169}