import { apiFetch } from './client'; import type { LoginStatus, QRCodeResult, Feed, FeedDetail, Comment, UserProfile, SearchFilters, HealthResponse, ApiResponse, PublishResult, CommentResult, CommentNotification, } from './types'; // Health (no auth required) export const getHealth = () => apiFetch('/health'); // Login export const getLoginStatus = () => apiFetch>('/api/xhs/login/status'); export const getLoginQRCode = () => apiFetch>('/api/xhs/login/qrcode'); export const deleteCookies = () => apiFetch>('/api/xhs/login/cookies', { method: 'DELETE' }); // Lightweight cookie check (no browser opened) export const checkLoginCookie = () => apiFetch>('/api/xhs/login/cookie-check'); // Feeds export const listFeeds = () => apiFetch>('/api/xhs/feeds'); export const searchFeeds = (keyword: string, filters?: SearchFilters) => apiFetch>('/api/xhs/search', { method: 'POST', body: JSON.stringify({ keyword, filters }), }); export const getFeedDetail = (feedId: string, xsecToken: string) => apiFetch>('/api/xhs/feeds/detail', { method: 'POST', body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken }), }); export const getSubComments = ( feedId: string, xsecToken: string, commentId: string, maxCount = 20, ) => apiFetch>('/api/xhs/feeds/sub-comments', { method: 'POST', body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken, comment_id: commentId, max_count: maxCount }), }); // User export const getUserProfile = (userId: string, xsecToken: string) => apiFetch>('/api/xhs/user/profile', { method: 'POST', body: JSON.stringify({ user_id: userId, xsec_token: xsecToken }), }); // Publish export const publishImage = (data: { title: string; content: string; images: string[]; tags?: string[]; schedule_at?: string; is_original?: boolean; visibility?: 'public' | 'private' | 'friends'; }) => apiFetch>('/api/xhs/publish/image', { method: 'POST', body: JSON.stringify(data), }); export const publishVideo = (data: { title: string; content: string; video: string; tags?: string[]; schedule_at?: string; visibility?: 'public' | 'private' | 'friends'; }) => apiFetch>('/api/xhs/publish/video', { method: 'POST', body: JSON.stringify(data), }); // Interactions export const postComment = (feedId: string, xsecToken: string, content: string) => apiFetch>('/api/xhs/comment', { method: 'POST', body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken, content }), }); export const replyComment = (data: { feed_id: string; xsec_token: string; content: string; comment_id?: string; user_id?: string; }) => apiFetch>('/api/xhs/comment/reply', { method: 'POST', body: JSON.stringify(data), }); // Notifications export const getCommentNotifications = (maxCount = 20) => apiFetch>(`/api/xhs/notifications/comments?max_count=${maxCount}`); export const replyNotification = (data: { user_id: string; comment_content: string; reply_content: string; }) => apiFetch>('/api/xhs/notifications/reply', { method: 'POST', body: JSON.stringify(data), }); export const toggleLike = (feedId: string, xsecToken: string) => apiFetch>('/api/xhs/like', { method: 'POST', body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken }), }); export const toggleFavorite = (feedId: string, xsecToken: string) => apiFetch>('/api/xhs/favorite', { method: 'POST', body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken }), });