import { CacheStoreEntity, RecursiveRecord, CancellablePromise, HttpMethods } from '@dvcol/common-utils'; import { BaseInit, BaseTemplateOptions, BaseTemplate, BaseBody } from './base-template.model.js'; type CacheResponse = { previous?: CacheStoreEntity>; current?: CacheStoreEntity>; isCache?: boolean; evict?: () => string | boolean | undefined | Promise; }; type TypedResponse = Omit & { json(): Promise; cache?: CacheResponse; }; type ResponseOrTypedResponse = T extends never ? Response : TypedResponse; type ClientEndpointCall, Response = unknown> = (param?: Parameter, init?: BaseInit) => CancellablePromise>; type CacheKeyFunction = (param?: Parameter, init?: BaseInit, cacheOption?: BaseCacheOption) => string; type BaseCacheOption = { /** If true, the cache will be forcefully evicted */ force?: boolean; /** The duration in milliseconds after which the cached values are ignored (computed from the cachedAt value). */ retention?: number; /** If true, the eviction date will be persisted and enforce in subsequent calls, regardless or retention context. */ saveRetention?: boolean; /** If true, the cache will be deleted if an error occurs. */ evictOnError?: boolean; /** Overrides or complements the cache key computation. */ cacheKey?: string | ((key: string) => string); }; type ClientEndpointCache, Response = unknown> = { evict: (param?: Parameter, init?: BaseInit, cacheOptions?: BaseCacheOption) => Promise; } & ((param?: Parameter, init?: BaseInit, cacheOptions?: BaseCacheOption) => CancellablePromise>); interface ClientEndpoint, Response = unknown> { (param?: Parameter, init?: BaseInit): CancellablePromise>; } declare class ClientEndpoint, Response = unknown, Cache extends boolean = true, Option extends BaseTemplateOptions = BaseTemplateOptions> implements BaseTemplate { method: HttpMethods; url: string; opts: Option; body?: BaseBody; init?: BaseInit; seed?: Partial; transform?: (param: Parameter) => Parameter; validate?: (param: Parameter) => boolean; cached: Cache extends true ? Omit & ClientEndpointCache : never; resolve: (param?: Parameter) => URL; get config(): { method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE"; url: string; opts: Option; init: BaseInit; body: Partial>; }; constructor(template: BaseTemplate); } type IApi = { [key: string]: ClientEndpoint | IApi; }; export { type BaseCacheOption, type CacheKeyFunction, type CacheResponse, ClientEndpoint, type ClientEndpointCache, type ClientEndpointCall, type IApi, type ResponseOrTypedResponse, type TypedResponse };