interface ServerCacheOptions { cache?: RequestCache; revalidate?: number; tags?: string[]; } interface ClientCacheOptions { revalidate?: number; tags?: string[]; cachedHeaders?: string[]; } interface CacheOptions { server?: ServerCacheOptions; client?: ClientCacheOptions; } interface CacheEntry { data: T; createdAt: number; expiresAt: number; etag?: string; clientRevalidate?: number; clientTags?: string[]; serverTags?: string[]; } interface CacheKeyOptions { url: string; method?: string; clientTags?: string[]; serverTags?: string[]; } interface ClientCacheEntry extends CacheEntry { source: 'fetch' | 'hydration' | 'manual'; headers?: Record; } type CacheRevalidateTime = number | false; interface HydrationData { [cacheKey: string]: Omit; } interface CacheHandler { get(): TData | undefined; set(updater: (oldData: TData | undefined) => TData): void; remove(): void; invalidate(): void; isStale(): boolean; subscribe(callback: (data: TData | undefined) => void): () => void; } type AllowedRequestInit = Pick; interface RetryOptions { count: number; delay?: number; } interface NexusRequestConfig extends AllowedRequestInit, CacheOptions { baseURL?: string; interceptors?: string[]; timeout?: number; retry?: RetryOptions; } type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; type BaseNexusDefinition = Readonly & { readonly method: HttpMethod; readonly endpoint: string; readonly _phantomResponse?: TResponse; }; interface GetNexusDefinition extends BaseNexusDefinition { readonly method: 'GET'; readonly data?: never; } interface PostNexusDefinition extends BaseNexusDefinition { readonly method: 'POST'; readonly data?: unknown; } interface PutNexusDefinition extends BaseNexusDefinition { readonly method: 'PUT'; readonly data?: unknown; } interface PatchNexusDefinition extends BaseNexusDefinition { readonly method: 'PATCH'; readonly data?: unknown; } interface DeleteNexusDefinition extends BaseNexusDefinition { readonly method: 'DELETE'; readonly data?: never; } type NexusDefinition = GetNexusDefinition | PostNexusDefinition | PutNexusDefinition | PatchNexusDefinition | DeleteNexusDefinition; interface NexusDefinitionConfig extends NexusRequestConfig { method: HttpMethod; endpoint: string; data?: unknown; } export type { CacheHandler as C, GetNexusDefinition as G, HydrationData as H, NexusRequestConfig as N, NexusDefinitionConfig as a, NexusDefinition as b, CacheKeyOptions as c, CacheRevalidateTime as d };