Download desktop/src/api/openTargets.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 994 Bytes
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/openTargets.ts
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/openTargets.ts
-
curl -L -o openTargets.ts https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/openTargets.ts
994 Bytes
| import { api, getApiUrl } from './client' | |
| export type OpenTargetKind = 'ide' | 'file_manager' | |
| export type OpenTarget = { | |
| id: string | |
| kind: OpenTargetKind | |
| label: string | |
| icon: string | |
| iconUrl?: string | |
| platform: string | |
| } | |
| export type OpenTargetList = { | |
| platform: string | |
| targets: OpenTarget[] | |
| primaryTargetId: string | null | |
| cachedAt: number | |
| ttlMs: number | |
| } | |
| export type OpenTargetOpenResponse = { | |
| ok: true | |
| targetId: string | |
| path: string | |
| } | |
| function normalizeOpenTargetList(result: OpenTargetList): OpenTargetList { | |
| return { | |
| ...result, | |
| targets: result.targets.map((target) => ({ | |
| ...target, | |
| iconUrl: target.iconUrl ? getApiUrl(target.iconUrl) : undefined, | |
| })), | |
| } | |
| } | |
| export const openTargetsApi = { | |
| async list() { | |
| return normalizeOpenTargetList(await api.get<OpenTargetList>('/api/open-targets')) | |
| }, | |
| open(targetId: string, path: string) { | |
| return api.post<OpenTargetOpenResponse>('/api/open-targets/open', { targetId, path }) | |
| }, | |
| } | |