( request: Request | RequestInit | undefined, )
| 9 | * `expect.objectContaining()` keep working when no request override was set. |
| 10 | */ |
| 11 | export function extractRequestOptions( |
| 12 | request: Request | RequestInit | undefined, |
| 13 | ): { headers?: HeadersInit; signal?: AbortSignal | null } { |
| 14 | if (!request) return {} |
| 15 | // Conditional spread: under exactOptionalPropertyTypes the target's |
| 16 | // `headers?: HeadersInit` and `signal?: AbortSignal | null` forbid an |
| 17 | // explicit `undefined`. Omit the keys entirely when the source values |
| 18 | // are absent so the OpenAI SDK sees `headers: undefined` as "not set" |
| 19 | // rather than a present-but-undefined value. |
| 20 | return { |
| 21 | ...(request.headers !== undefined && { headers: request.headers }), |
| 22 | ...(request.signal != null && { signal: request.signal }), |
| 23 | } |
| 24 | } |
no outgoing calls
no test coverage detected