export type CachePolicy = | 'cache-first' | 'cache-only' | 'network-first' | 'network-only'; export interface ExecuteRequestOptions { baseUrl?: string; fetchOptions?: RequestInit; } /** Use fetch options shared across all configs. */ export interface BaseUseFetchOptions { domains: D[]; autoFetch?: boolean; parseResponse?: (response: any) => T; baseUrl?: string; fetchOptions?: RequestInit; } /** Default useFetch options. */ export interface GeneralUseFetchOptions extends BaseUseFetchOptions { cachePolicy?: Exclude; } /** useFetch options without domain (for network-only). */ export interface NetworkOnlyUseFetchOptions extends Omit, 'domains'> { cachePolicy: 'network-only'; } /** useFetch options without autoFetch option (for cache-only). */ export interface CacheOnlyUseFetchOptions extends Omit, 'autoFetch'> { cachePolicy: 'cache-only'; } /** Config options for useFetch. */ export type UseFetchOptions = | GeneralUseFetchOptions | NetworkOnlyUseFetchOptions | CacheOnlyUseFetchOptions; /** Network information returned from useFetch. */ export interface FetchState { fetching: boolean; data?: T; error?: Error; } /** useFetch hook response ([fetchState, refetch]). */ export type UseFetchResponse = [FetchState, () => void]; /** Re-export utility type for enforcing domain. */ export type TypedUseFetch = ( url: string, opts: UseFetchOptions ) => UseFetchResponse; /** Map of domain strings pointing to request keys */ export type DomainMap = Record; /** Map of request keys pointing to data states and refetch values */ export type ResponseMap = Record; /** Tipple provider props. */ export interface ProviderProps { /** Url to prefix all requests (e.g. "https://mydomain.com/api"). */ baseUrl?: string; /** HTTP headers to append to all requests. */ fetchOptions?: RequestInit | ((arg?: RequestInit) => RequestInit | undefined); } /** Utility type to Omit keys from an interface/object type */ export type Omit = Pick>;