import { RecursiveRecord, CacheStore } from '@dvcol/common-utils'; import { BaseSettings } from '../models/base-client.model.js'; import { BaseTemplateOptions, BaseBody, BaseTemplate } from '../models/base-template.model.js'; import { ClientEndpointCall, CacheKeyFunction, ClientEndpointCache } from '../models/client-endpoint.model.js'; /** * Creates a cached function that will wrap the inner client function and store the response in a provided cache store * @param clientFn - the inner client function to cache * @param key - the key to use for the cache * @param evictionKey - the key to use for eviction of the method (all cache entries matching this key will be evicted) * @param cache - the cache store to use * @param retention - the default retention time for the cache */ declare const getCachedFunction: (clientFn: ClientEndpointCall, { key, evictionKey, cache, retention, }: { key: string | CacheKeyFunction; evictionKey?: string | CacheKeyFunction; cache: CacheStore; retention?: BaseTemplateOptions['cache']; }) => ClientEndpointCache; /** * Parses body from a template and generate a json BodyInit. * * @template T - The type of the parameters. * * @param template - The expected body structure. * @param {T} params - The actual parameters. * * @returns {RecursiveRecord} The parsed request body as a Json Object. */ declare const parseBodyJson: (template: BaseBody, params: T) => RecursiveRecord; /** * Parses body from a template and constructs a FormData BodyInit. * * @template T - The type of the parameters. * * @param template - The expected body structure. * @param {T} params - The actual parameters. * * @returns {FormData} The parsed request body as a FormData Object. */ declare const parseBodyFormData: (template: BaseBody, params: T) => FormData; /** * Parses body from a template and constructs a URLSearchParams BodyInit. * * @template T - The type of the parameters. * * @param template - The expected body structure. * @param {T} params - The actual parameters. * * @returns {URLSearchParams} The parsed request body as a URLSearchParams Object. */ declare const parseBodyUrlEncoded: (template: BaseBody, params: T) => URLSearchParams; /** * Parses body from a template and stringifies a {@link BodyInit} * * @private * * @template T - The type of the parameters. * * @param template - The expected body structure. * @param {T} params - The actual parameters. * * @returns {BodyInit} The parsed request body. */ declare const parseBody: (template: BaseBody, params: T) => BodyInit; /** * Patches the response object to include a json method that parses the response data. * @param response - The response to patch * @param parseResponse - Optional function to parse the response data */ declare const patchResponse: (response: T, parseResponse?: (data: D) => R) => T; /** * Parses the parameters and constructs the URL for a API request. * * @private * * @template P - The type of the parameters. * * @param {BaseTemplate

} template - The template for the API endpoint. * @param {P} params - The parameters for the API call. * @param {string} base - The API base url. * * @returns {URL} The URL for the API request. * * @throws {Error} Throws an error if mandatory parameters are missing or if a filter is not supported. */ declare const parseUrl:

(template: BaseTemplate, params: P, base: string, encode?: boolean) => URL; /** * Injects a url prefix to the template URL if it is not already present. * * @param prefix - The prefix to inject. * @param template - The template for the API endpoint. * @param mutate - Whether to mutate the template or return a new one. */ declare const injectUrlPrefix:

(prefix: P, template: T, mutate?: boolean) => T; /** * Injects the cors proxy prefix to the URL if it is not already present. * * @param template - The template for the API endpoint. * @param settings - The client settings. * @param mutate - Whether to mutate the template or return a new one. */ declare const injectCorsProxyPrefix: (template: T, settings: S, mutate?: boolean) => T; export { getCachedFunction, injectCorsProxyPrefix, injectUrlPrefix, parseBody, parseBodyFormData, parseBodyJson, parseBodyUrlEncoded, parseUrl, patchResponse };