Download apps/web-naive/src/api/core/sync.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-naive/src/api/core/sync.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/apps/web-naive/src/api/core/sync.ts
-
curl -L -o sync.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/apps/web-naive/src/api/core/sync.ts
1.51 kB
| import type { PaginatedList } from './types'; | |
| import { requestClient } from '#/api/request'; | |
| // ======================== 类型定义 ======================== | |
| export interface SyncLogListParams { | |
| page?: number; | |
| page_size?: number; | |
| source_id?: number; | |
| /** running | success | failed | skipped */ | |
| status?: string; | |
| } | |
| export interface SyncLogItem { | |
| id: number; | |
| source_id: number; | |
| source_name: string; | |
| range_type: string; | |
| status: string; | |
| total_fetched: number; | |
| new_count: number; | |
| update_count: number; | |
| error_message: null | string; | |
| started_at: null | string; | |
| finished_at: null | string; | |
| } | |
| // ======================== API ======================== | |
| /** 同步日志列表 GET /admin/sync/log */ | |
| export function getSyncLogListApi(params?: SyncLogListParams) { | |
| return requestClient.get<PaginatedList<SyncLogItem>>('/admin/sync/log', { | |
| params, | |
| }); | |
| } | |
| /** | |
| * 触发同步任务 POST /admin/sync/trigger | |
| * @param rangeType all | monthly | weekly | daily | |
| * @param sourceId 指定源站 ID,不传则同步全部 | |
| */ | |
| export function triggerSyncApi( | |
| rangeType: 'all' | 'daily' | 'monthly' | 'weekly' = 'daily', | |
| sourceId?: number, | |
| ) { | |
| return requestClient.post('/admin/sync/trigger', null, { | |
| params: { | |
| range_type: rangeType, | |
| ...(sourceId === undefined ? {} : { source_id: sourceId }), | |
| }, | |
| }); | |
| } | |
| /** 同步状态 GET /admin/sync/status */ | |
| export function getSyncStatusApi() { | |
| return requestClient.get<{ is_running: boolean }>('/admin/sync/status'); | |
| } | |