Big changes
This commit is contained in:
parent
4240ad38e2
commit
e3f0d63fec
99 changed files with 8804 additions and 1731 deletions
|
|
@ -13,26 +13,39 @@ export interface PublicationItem {
|
|||
pub_url: string | null;
|
||||
doi: string | null;
|
||||
pdf_url: string | null;
|
||||
pdf_status: "untracked" | "queued" | "running" | "resolved" | "failed";
|
||||
pdf_attempt_count: number;
|
||||
pdf_failure_reason: string | null;
|
||||
pdf_failure_detail: string | null;
|
||||
is_read: boolean;
|
||||
is_favorite: boolean;
|
||||
first_seen_at: string;
|
||||
is_new_in_latest_run: boolean;
|
||||
}
|
||||
|
||||
export interface PublicationsResult {
|
||||
mode: PublicationMode;
|
||||
favorite_only: boolean;
|
||||
selected_scholar_profile_id: number | null;
|
||||
unread_count: number;
|
||||
favorites_count: number;
|
||||
latest_count: number;
|
||||
// Compatibility alias for latest_count; retained while API clients migrate.
|
||||
new_count: number;
|
||||
total_count: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
has_next: boolean;
|
||||
has_prev: boolean;
|
||||
publications: PublicationItem[];
|
||||
}
|
||||
|
||||
export interface PublicationsQuery {
|
||||
mode?: PublicationMode;
|
||||
favoriteOnly?: boolean;
|
||||
scholarProfileId?: number;
|
||||
limit?: number;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
export interface PublicationSelection {
|
||||
|
|
@ -46,12 +59,18 @@ export async function listPublications(query: PublicationsQuery = {}): Promise<P
|
|||
if (query.mode) {
|
||||
params.set("mode", query.mode);
|
||||
}
|
||||
if (query.favoriteOnly) {
|
||||
params.set("favorite_only", "true");
|
||||
}
|
||||
if (query.scholarProfileId) {
|
||||
params.set("scholar_profile_id", String(query.scholarProfileId));
|
||||
}
|
||||
if (query.limit) {
|
||||
params.set("limit", String(query.limit));
|
||||
}
|
||||
const parsedPage = Number.isFinite(query.page) ? Math.max(1, Math.trunc(Number(query.page))) : 1;
|
||||
const parsedPageSize = Number.isFinite(query.pageSize)
|
||||
? Math.max(1, Math.min(500, Math.trunc(Number(query.pageSize))))
|
||||
: 100;
|
||||
params.set("page", String(parsedPage));
|
||||
params.set("page_size", String(parsedPageSize));
|
||||
|
||||
const suffix = params.toString();
|
||||
const response = await apiRequest<PublicationsResult>(
|
||||
|
|
@ -87,10 +106,16 @@ export async function markSelectedRead(selections: PublicationSelection[]): Prom
|
|||
|
||||
export interface RetryPublicationPdfResult {
|
||||
message: string;
|
||||
queued: boolean;
|
||||
resolved_pdf: boolean;
|
||||
publication: PublicationItem;
|
||||
}
|
||||
|
||||
export interface TogglePublicationFavoriteResult {
|
||||
message: string;
|
||||
publication: PublicationItem;
|
||||
}
|
||||
|
||||
export async function retryPublicationPdf(
|
||||
publicationId: number,
|
||||
scholarProfileId: number,
|
||||
|
|
@ -104,3 +129,21 @@ export async function retryPublicationPdf(
|
|||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function togglePublicationFavorite(
|
||||
publicationId: number,
|
||||
scholarProfileId: number,
|
||||
isFavorite: boolean,
|
||||
): Promise<TogglePublicationFavoriteResult> {
|
||||
const response = await apiRequest<TogglePublicationFavoriteResult>(
|
||||
`/publications/${publicationId}/favorite`,
|
||||
{
|
||||
method: "POST",
|
||||
body: {
|
||||
scholar_profile_id: scholarProfileId,
|
||||
is_favorite: isFavorite,
|
||||
},
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue