MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / FetchCacheAdapter

Class FetchCacheAdapter

src/services/cache/fetch.ts:4–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import { get, post } from '../utils/http'
3
4export class FetchCacheAdapter implements CacheServiceAdapter {
5 async getInfo(): Promise<CacheInfo> {
6 return get<CacheInfo>('/cache/info')
7 }
8
9 async clear(cacheId: string): Promise<{ success: boolean; error?: string; message?: string }> {
10 return post<{ success: boolean; error?: string; message?: string }>('/cache/clear', { cacheId })
11 }
12
13 async getDataDir(): Promise<DataDirInfo> {
14 return get<DataDirInfo>('/cache/data-dir')
15 }
16
17 async setDataDir(
18 path: string | null,
19 migrate: boolean = true
20 ): Promise<{ success: boolean; error?: string; from?: string; to?: string; requiresRelaunch?: boolean }> {
21 return post<{ success: boolean; error?: string; from?: string; to?: string; requiresRelaunch?: boolean }>(
22 '/cache/data-dir',
23 {
24 path,
25 migrate,
26 }
27 )
28 }
29
30 async getLatestImportLog(): Promise<{ success: boolean; path?: string; name?: string; error?: string }> {
31 return get<{ success: boolean; path?: string; name?: string; error?: string }>('/cache/latest-import-log')
32 }
33
34 async saveToDownloads(
35 filename: string,
36 dataUrl: string
37 ): Promise<{ success: boolean; filePath?: string; error?: string }> {
38 return post<{ success: boolean; filePath?: string; error?: string }>('/cache/save-to-downloads', {
39 filename,
40 dataUrl,
41 })
42 }
43
44 async openDir(cacheId: string): Promise<{ success: boolean; error?: string }> {
45 return post<{ success: boolean; error?: string }>('/cache/open-dir', { cacheId })
46 }
47
48 async showInFolder(filePath: string): Promise<{ success: boolean; error?: string }> {
49 return post<{ success: boolean; error?: string }>('/cache/show-in-folder', { filePath })
50 }
51}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected