import { type AbsoluteMiddlewareOptions, type FinalizeHandler, type SerializeHandler } from '@byu-oit-sdk/middleware-stack'; import { Command } from './Command.js'; import type { ClientMiddlewareExecutionContext } from './ClientMiddlewareExecutionContext.js'; export interface RequestPromiseOptions { body?: BodyInit | object | null; encoding?: string; headers?: Record; json?: boolean; method?: string; qs?: Record; resolveWithFullResponse?: boolean; simple?: boolean; [key: string]: unknown; } export type RequiredUriUrl = { url: string | URL; } | { uri: string | URL; }; export type OptionalUriUrl = Partial; export type RequestInput = RequestPromiseOptions & RequiredUriUrl; /** * Interface representing a response object similar to what the request package produces, but without the utility * methods it includes. */ export interface AbbreviatedResponse { statusCode: number; statusMessage: string; headers: Record; body: string; } export type RequestOutput = Response | AbbreviatedResponse; /** * Wraps the Fetch Request class with a Command. */ export declare class RequestCommand extends Command { constructor(url: string | RequestInput, options?: RequestPromiseOptions & OptionalUriUrl); } /** * Wraps the Error class with a StatusCodeError type. */ export declare class StatusCodeError extends Error { statusCode: number; constructor(statusCode: number, message: string); } /** * Translates the behaviors of the request-promise package to the fetch API. * * @param next - The next middleware to invoke in the middleware stack. * @param context - The metadata and information shared between all middleware in the stack * @returns A serialize middleware handler. */ export declare function RequestTransformer(next: FinalizeHandler, context: ClientMiddlewareExecutionContext): SerializeHandler; export declare const RequestTransformerOptions: AbsoluteMiddlewareOptions; /** * Converts a request-promise options object into a native fetch API Request. * * @param options - Options conforming to request-promise's type definitions. * @param context - Metadata from the client and command * @returns A Request object ready for use with the fetch API. */ export declare function toFetchRequest(options: RequestPromiseOptions & RequiredUriUrl, context: ClientMiddlewareExecutionContext): Request; /** * Converts a fetch Response object into a request-like response object. * * @param response - The fetch Response to convert. * @param resolveWithFullResponse - Return the full Response object, otherwise abbreviate the response. * @param simple - Outright fail if anything other than a successful response is returned in the response. * @returns A promise that resolves to a RequestResponse object. */ export declare function toRequestResponse(response: Response, resolveWithFullResponse?: boolean, simple?: boolean): Promise;