(context, conf, options)
| 33824 | } |
| 33825 | } |
| 33826 | _createRequest(context, conf, options) { |
| 33827 | var _a5, _b2, _c2, _d2; |
| 33828 | const { method, path: path5, query, headers: opHeaders, security } = conf; |
| 33829 | const base = (_a5 = conf.baseURL) !== null && _a5 !== void 0 ? _a5 : this._baseURL; |
| 33830 | if (!base) { |
| 33831 | return (0, fp_js_1.ERR)(new httpclienterrors_js_1.InvalidRequestError("No base URL provided for operation")); |
| 33832 | } |
| 33833 | const reqURL = new URL(base); |
| 33834 | const inputURL = new URL(path5, reqURL); |
| 33835 | if (path5) { |
| 33836 | reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); |
| 33837 | } |
| 33838 | let finalQuery = query || ""; |
| 33839 | const secQuery = []; |
| 33840 | for (const [k7, v5] of Object.entries((security === null || security === void 0 ? void 0 : security.queryParams) || {})) { |
| 33841 | secQuery.push((0, encodings_js_1.encodeForm)(k7, v5, { charEncoding: "percent" })); |
| 33842 | } |
| 33843 | if (secQuery.length) { |
| 33844 | finalQuery += `&${secQuery.join("&")}`; |
| 33845 | } |
| 33846 | if (finalQuery) { |
| 33847 | const q6 = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery; |
| 33848 | reqURL.search = `?${q6}`; |
| 33849 | } |
| 33850 | const headers = new Headers(opHeaders); |
| 33851 | const username = security === null || security === void 0 ? void 0 : security.basic.username; |
| 33852 | const password = security === null || security === void 0 ? void 0 : security.basic.password; |
| 33853 | if (username != null || password != null) { |
| 33854 | const encoded = (0, base64_js_1.stringToBase64)([username || "", password || ""].join(":")); |
| 33855 | headers.set("Authorization", `Basic ${encoded}`); |
| 33856 | } |
| 33857 | const securityHeaders = new Headers((security === null || security === void 0 ? void 0 : security.headers) || {}); |
| 33858 | for (const [k7, v5] of securityHeaders) { |
| 33859 | headers.set(k7, v5); |
| 33860 | } |
| 33861 | let cookie = headers.get("cookie") || ""; |
| 33862 | for (const [k7, v5] of Object.entries((security === null || security === void 0 ? void 0 : security.cookies) || {})) { |
| 33863 | cookie += `; ${k7}=${v5}`; |
| 33864 | } |
| 33865 | cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; |
| 33866 | headers.set("cookie", cookie); |
| 33867 | const userHeaders = new Headers((_b2 = options === null || options === void 0 ? void 0 : options.fetchOptions) === null || _b2 === void 0 ? void 0 : _b2.headers); |
| 33868 | for (const [k7, v5] of userHeaders) { |
| 33869 | headers.set(k7, v5); |
| 33870 | } |
| 33871 | if (!isBrowserLike) { |
| 33872 | headers.set((_c2 = conf.uaHeader) !== null && _c2 !== void 0 ? _c2 : "user-agent", config_js_1.SDK_METADATA.userAgent); |
| 33873 | } |
| 33874 | let fetchOptions = options === null || options === void 0 ? void 0 : options.fetchOptions; |
| 33875 | if (!(fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.signal) && conf.timeoutMs && conf.timeoutMs > 0) { |
| 33876 | const timeoutSignal = AbortSignal.timeout(conf.timeoutMs); |
| 33877 | if (!fetchOptions) { |
| 33878 | fetchOptions = { signal: timeoutSignal }; |
| 33879 | } else { |
| 33880 | fetchOptions.signal = timeoutSignal; |
| 33881 | } |
| 33882 | } |
| 33883 | if (conf.body instanceof ReadableStream) { |
no test coverage detected