UNPKG

@scalar/api-client

Version:

the open source API testing client

53 lines 2.1 kB
import type { HttpMethod } from '@scalar/helpers/http/http-methods'; import type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'; import { type ErrorResponse } from '../../../../libs/errors.js'; import { type ClientPlugin } from '../../../../v2/helpers/plugins.js'; /** A single set of populated values for a sent request */ export type ResponseInstance = Omit<Response, 'headers'> & { /** Store headers as an object to match what we had with axios */ headers: Record<string, string>; /** Keys of headers which set cookies */ cookieHeaderKeys: string[]; /** Time in ms the request took */ duration: number; /** The response status */ status: number; /** The response status text */ statusText: string; /** The response method */ method: HttpMethod; /** The request path */ path: string; } & ({ /** The response data */ data: string | Blob; /** The response size in bytes */ size: number; } | { /** A stream reader for a streamable response body */ reader: ReadableStreamDefaultReader<Uint8Array>; }); /** * Execute the built fetch request and return a structured response. * * This function handles the complete request lifecycle including plugin hooks, * response processing, streaming detection, and error handling. It supports both * standard responses and server-sent event streams. * * @param request - The request built by the buildRequest helper * @param operation - The OpenAPI operation being executed * @param plugins - Array of client plugins to execute hooks * @param isUsingProxy - Whether the request is being proxied for header handling * @returns A tuple with either an error or the response data */ export declare const sendRequest: ({ isUsingProxy, operation, request, plugins, }: { isUsingProxy: boolean; operation: OperationObject; plugins: ClientPlugin[]; request: Request; }) => Promise<ErrorResponse<{ response: ResponseInstance; request: Request; timestamp: number; }>>; //# sourceMappingURL=send-request.d.ts.map