| 25 | // ==================== NodeFetcher ==================== |
| 26 | |
| 27 | export class NodeFetcher implements HttpFetcher { |
| 28 | async fetchToTempFile(baseUrl: string, remoteSessionId: string, token: string, params: FetchParams): Promise<string> { |
| 29 | const url = buildPullUrl(baseUrl, remoteSessionId, params) |
| 30 | const headers: Record<string, string> = { |
| 31 | Accept: 'application/json', |
| 32 | } |
| 33 | if (token) headers['Authorization'] = `Bearer ${token}` |
| 34 | |
| 35 | const response = await fetch(url, { headers, signal: AbortSignal.timeout(120_000) }) |
| 36 | if (!response.ok) { |
| 37 | throw new Error(`HTTP ${response.status}`) |
| 38 | } |
| 39 | |
| 40 | const contentType = response.headers.get('content-type') || 'application/json' |
| 41 | const isJsonl = contentType.includes('ndjson') || contentType.includes('jsonl') |
| 42 | const tempFile = getTempFilePath(isJsonl ? '.jsonl' : '.json') |
| 43 | |
| 44 | const buffer = Buffer.from(await response.arrayBuffer()) |
| 45 | fs.writeFileSync(tempFile, buffer) |
| 46 | return tempFile |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | // ==================== DirectImporter ==================== |
| 51 |
nothing calls this directly
no outgoing calls
no test coverage detected