diff --git a/src/lib/models.ts b/src/lib/models.ts index c0a4526f27..4016328e11 100644 --- a/src/lib/models.ts +++ b/src/lib/models.ts @@ -1,10 +1,10 @@ import { RetryConfiguration } from "./retry.js"; -import { Dispatcher } from "undici-types"; +import type { Dispatcher } from "undici-types"; /** * @private */ -export type FetchAPI = (url: URL | RequestInfo, init?: RequestInit) => Promise; +export type FetchAPI = (url: string | URL | Request, init?: RequestInit) => Promise; export interface ClientOptions extends Omit { telemetry?: boolean; @@ -61,7 +61,7 @@ export type HTTPBody = any | FormData | URLSearchParams; export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; - credentials?: RequestCredentials; + credentials?: "include" | "omit" | "same-origin"; body?: HTTPBody; }; @@ -120,26 +120,26 @@ export class TextApiResponse implements ApiResponse { } export interface FetchParams { - url: URL | RequestInfo; + url: string | URL | Request; init: RequestInit; } export interface RequestContext { fetch: FetchAPI; - url: URL | RequestInfo; + url: string | URL | Request; init: RequestInit; } export interface ResponseContext { fetch: FetchAPI; - url: URL | RequestInfo; + url: string | URL | Request; init: RequestInit; response: Response; } export interface ErrorContext { fetch: FetchAPI; - url: URL | RequestInfo; + url: string | URL | Request; init: RequestInit; error: unknown; response?: Response; diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts index 2cd4016000..52b79bb79b 100644 --- a/src/lib/runtime.ts +++ b/src/lib/runtime.ts @@ -102,7 +102,7 @@ export class BaseAPI { } }; - private fetch = async (url: URL | RequestInfo, init: RequestInit) => { + private fetch = async (url: string | URL | Request, init: RequestInit) => { let fetchParams = { url, init }; for (const middleware of this.middleware) { if (middleware.pre) {