(
method: 'POST',
path: string,
body: FormData,
)
| 137 | } |
| 138 | |
| 139 | private async formRequest<T>( |
| 140 | method: 'POST', |
| 141 | path: string, |
| 142 | body: FormData, |
| 143 | ): Promise<T> { |
| 144 | const url = this.url(path); |
| 145 | const res = await fetchWithReport( |
| 146 | url, |
| 147 | { |
| 148 | method, |
| 149 | headers: { accept: 'application/json' }, |
| 150 | body, |
| 151 | }, |
| 152 | { |
| 153 | fetchImpl: this.opts.fetchImpl, |
| 154 | reportDir: this.opts.reportDir, |
| 155 | path, |
| 156 | }, |
| 157 | ); |
| 158 | const text = await res.text(); |
| 159 | let envelope: Envelope<T>; |
| 160 | try { |
| 161 | envelope = JSON.parse(text) as Envelope<T>; |
| 162 | } catch (error) { |
| 163 | throw new Error( |
| 164 | `server ${method} ${path} returned non-JSON (HTTP ${res.status}): ${text.slice(0, 200)}`, |
| 165 | { cause: error }, |
| 166 | ); |
| 167 | } |
| 168 | return unwrap(envelope); |
| 169 | } |
| 170 | |
| 171 | // ── Probes + model catalog ───────────────────────────────────────────── |
| 172 | getAuth(): Promise<AuthSummary> { |
no test coverage detected