UNPKG

@scalar/api-client

Version:

the open source API testing client

44 lines 2.21 kB
import type { HttpMethod } from '@scalar/helpers/http/http-methods'; import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'; import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'; import type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'; import type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/operation'; import { type ErrorResponse } from '../../../../libs/errors.js'; import type { SecuritySchemeObjectSecret } from '../../../../v2/blocks/scalar-auth-selector-block/helpers/secret-types'; /** * Builds a fully configured Request object ready for execution. * * This function processes an OpenAPI operation and constructs a fetch-compatible * Request by resolving environment variables, applying security schemes, building * headers and cookies, handling proxy redirection, and preparing the request body. * * The function handles special cases like Electron environments and proxy usage * where custom cookie headers are required. * * @returns A tuple containing either an error or the request object with an abort controller */ export declare const buildRequest: ({ environment, exampleKey, globalCookies, method, operation, path, proxyUrl, server, selectedSecuritySchemes, }: { /** For environment variables in the inputs */ environment: XScalarEnvironment; /** The key of the current example */ exampleKey: string; /** Workspace + document cookies */ globalCookies: XScalarCookie[]; /** The HTTP method of the operation */ method: HttpMethod; /** The operation object */ operation: OperationObject; /** The path of the operation */ path: string; /** The proxy URL for cookie domain determination */ proxyUrl: string; /** The server object */ server: ServerObject | null; /** The selected security schemes for the current operation */ selectedSecuritySchemes: SecuritySchemeObjectSecret[]; }) => ErrorResponse<{ controller: AbortController; request: Request; isUsingProxy: boolean; }>; //# sourceMappingURL=build-request.d.ts.map