import { type NamedService, type ServiceDescriptor } from '@conduit-client/utils'; import type { RetryService } from '@conduit-client/service-retry/v1'; export type FetchParameters = Parameters; /** * The first argument to `fetch` (a `RequestInfo | URL` in lib.dom). Pulled * via index access so we don't depend on the DOM `RequestInfo` name being * directly resolvable in every consuming tsconfig. */ export type FetchInput = FetchParameters[0]; /** * Optional per-call data passed by callers (typically `FetchNetworkCommand` * subclasses) and merged into the per-request interceptor context inside * `buildServiceDescriptor`. Carried on the `init` argument under the * `__contextSeed` key (see `ExtendedRequestInit`) so that detection is a * named-property lookup rather than positional arity sniffing — runtime * type checks beat length checks for distinguishing a seed from a vanilla * `RequestInit`. The seed is stripped from `init` before the underlying * `fetch` call, so it never reaches the network. */ export type FetchContextSeed = Record; /** * `RequestInit` plus an optional `__contextSeed` slot. Every existing * `RequestInit` value is assignable to this type, so today's callers * continue to compile and behave identically. */ export type ExtendedRequestInit = RequestInit & { __contextSeed?: FetchContextSeed; }; export type FetchService = (input: FetchInput, init?: ExtendedRequestInit) => PromiseLike; export type IFetchService = FetchService; export type FetchServiceDescriptor = ServiceDescriptor; export type NamedFetchService = NamedService; export type RequestInterceptor = (fetchArgs: FetchParameters, context?: Context) => PromiseLike; export type RetryInterceptor = (fetchArgs: FetchParameters, retryService?: RetryService, context?: Context) => PromiseLike; export type ResponseInterceptor = (response: Response, context?: Context) => PromiseLike; export type FinallyInterceptor = (context?: Context) => PromiseLike | void; export type Interceptors = { createContext?: () => Context; request?: RequestInterceptor[]; retry?: RetryInterceptor; response?: ResponseInterceptor[]; finally?: FinallyInterceptor[]; }; export declare function buildServiceDescriptor(interceptors?: Interceptors, retryService?: RetryService): FetchServiceDescriptor;