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