(state: ClientState, path: string, opts: RequestOptions, throwOnErrorDefault: boolean)
| 115 | // WITHOUT a signal — execute() supplies a fresh per-attempt signal via fetch's |
| 116 | // init.signal (which overrides any signal carried on the Request). |
| 117 | function buildRequest(state: ClientState, path: string, opts: RequestOptions, throwOnErrorDefault: boolean): BuiltRequest { |
| 118 | const method: HttpMethod = opts.method ?? 'GET' |
| 119 | const effectiveTimeoutMs = opts.timeoutMs !== undefined |
| 120 | ? (opts.timeoutMs > 0 ? opts.timeoutMs : undefined) |
| 121 | : state.defaultTimeoutMs |
| 122 | const effectiveRetryAttempts = opts.retryAttempts ?? state.defaultRetryAttempts |
| 123 | const throwOnError = opts.throwOnError ?? throwOnErrorDefault |
| 124 | |
| 125 | const { body, contentType } = buildBody({ json: opts.json, body: opts.body, method }) |
| 126 | const headers = mergeHeaders(opts.headers, contentType) |
| 127 | const url = appendSearchParams(joinURL(state.baseURL, path), opts.searchParams) |
| 128 | |
| 129 | const request = new Request(url, { method, headers, body }) |
| 130 | const resolved: ResolvedOptions = { |
| 131 | method, |
| 132 | headers, |
| 133 | body, |
| 134 | timeoutMs: effectiveTimeoutMs, |
| 135 | retryAttempts: effectiveRetryAttempts, |
| 136 | throwOnError, |
| 137 | retryOnRateLimit: opts.retryOnRateLimit ?? false, |
| 138 | } |
| 139 | return { request, resolved, effectiveTimeoutMs, userSignal: opts.signal } |
| 140 | } |
| 141 | |
| 142 | // The shared transport engine: hooks -> fetch -> retry -> error-map. Accepts an |
| 143 | // already-built Request, so both the path entrypoints (via buildRequest) and the |
no test coverage detected