import { FetchlyResult } from './types/FetchlyResult'; import { Options } from './types/Options'; export declare class Fetchly { private baseURL?; private headers?; private params?; private timeout?; private mode?; private cache?; private credentials?; private redirect?; private referrer?; private referrerPolicy?; private responseFormat?; private proxy?; private next?; private additionalOptions?; private showLogs; private onRequest?; private onSuccess?; private onError?; private onInternalError?; /** * Constructs a new instance of the Fetchly class. * @param options The options to configure the Fetchly instance. * @example * const fetchInstance = new Fetchly({ * baseURL: 'https://api.example.com', * headers: { * 'Content-Type': 'application/json', * 'Authorization': 'Bearer token' * } * }); */ constructor(options?: Options); /** * Configures the Fetchly instance with the provided options. * @param options - The configuration options. * @example * const fetchInstance = new Fetchly(); * fetchInstance.configure({ * baseURL: 'https://api.example.com', * headers: { * 'Authorization': 'Bearer token123' * }, * timeout: 5000, * mode: 'cors', * cache: 'no-cache', * credentials: 'include', * redirect: 'manual', * referrerPolicy: 'strict-origin-when-cross-origin' * }); */ configure(options?: Options): Promise; /** * Generates the configuration object for the NextFetchRequest. * @param options - The options object containing the configuration parameters. * @returns The NextFetchRequestConfig object or null if no configuration is provided. * @example * const options = { * next: { * revalidate: 60, * tags: ['posts', 'comments'] * } * }; * const config = generateNextConfig(options); * console.log(config); * // Output: { revalidate: 60, tags: ['posts', 'comments'] } */ private generateNextConfig; /** * Performs a fetch request with the specified URL, method, options, and body. * @template T The type of the response data. * @template E The type of the error data. * @param {string} url The URL to fetch. * @param {Method} method The HTTP method to use for the request. * @param {Options} [options] The options for the fetch request. * @param {unknown} [body] The request body. * @returns {Promise>} A promise that resolves to the fetch response. * * @example * const response = await _fetch('/users', 'GET', { params: { page: 1 } }); * if (response.status === Status.Success) { * console.log('Data:', response.data); * } else { * console.error('Error:', response.error); * } */ private _fetch; /** * Sends a GET request to the specified URL. * * @param url - The URL to send the request to. * @param options - Optional request options. * @returns A promise that resolves to a FetchlyResult object. * * @example * const fetcher = new Fetchly(); * const response = await fetcher.get('https://api.example.com/users'); * console.log(response.data); // Output: { id: 1, name: 'John Doe' } */ get(url: string, options?: Options): Promise>; /** * Sends a POST request to the specified URL with the given body and options. * @param url - The URL to send the request to. * @param body - The body of the request. * @param options - The options for the request. * @returns A promise that resolves to a FetchlyResult object containing the response data. * @example * const response = await post('/api/users', { name: 'John Doe' }); * console.log(response.data); // Output: { id: 1, name: 'John Doe' } */ post(url: string, body: unknown, options?: Options): Promise>; /** * Sends a PUT request to the specified URL with the provided body and options. * @param url The URL to send the request to. * @param body The body of the request. * @param options The options for the request. * @returns A promise that resolves to the response of the request. * @example * const response = await put('/api/users/1', { name: 'John Doe' }); * console.log(response.data); // Output: { id: 1, name: 'John Doe' } */ put(url: string, body: unknown, options?: Options): Promise>; /** * Sends a PATCH request to the specified URL with the provided body and options. * @param url The URL to send the request to. * @param body The body of the request. * @param options The options for the request. * @returns A promise that resolves to the response of the request. * @example * const response = await patch('/api/users/1', { name: 'John Doe' }); * console.log(response.data); // Output: { id: 1, name: 'John Doe' } */ patch(url: string, body: unknown, options?: Options): Promise>; /** * Sends a DELETE request to the specified URL. * * @param url - The URL to send the request to. * @param options - Optional request options. * @returns A promise that resolves to a FetchlyResult object. * * @example * // Delete a user by ID * const response = await delete(`https://api.example.com/users/${userId}`); * console.log(response.data); // User object * console.log(response.status); // HTTP status code */ delete(url: string, options?: Options): Promise>; } declare const fetchly: Fetchly; export default fetchly;