import { Entry, Har, Header, Log } from 'har-format'; /** * A type representing a function that retrieves a HAR object from a given file. * * @typedef LoadHarDataFn * @type {function} * @param {string} filePath - The path of the file to read the HAR data from. * @returns {Promise} A promise that resolves to the HAR object. */ export type LoadHarDataFn = (filePath: string) => Promise; /** * A type representing a function that sets a new HAR entry and saves it to a given file. * * @typedef AppendEntryAndSaveHarFn * @type {function} * @param {Entry} entry - The new HAR entry to be added. * @param {string} filePath - The path of the file to save the updated HAR data to. * @returns {Promise} A promise that resolves to the updated HAR object. */ export type AppendEntryAndSaveHarFn = (entry: Entry, filePath: string) => Promise; /** * Finds the HAR entry in the given log with the matching HTTP method and endpoint. * * @param {Log} harLog - The HAR log to search through. * @param {string} method - The HTTP method of the desired entry. * @param {string} endpoint - The endpoint (pathname and search) of the desired entry, e.g., "/users?id=123". * @param {RegExp} [endpointRegex] - Optional regular expression to match the endpoint against. For example, to match endpoints that start with "/users" followed by a number, use `/^\/users\d+/`. * @param {boolean} [ignoreSearch=false] - Optional flag to ignore the search part of the URL when matching endpoints. * @param {string} [prefixToRemove] - Optional prefix to remove from the beginning of the `entry.request.path` property before matching the endpoint. * @returns {Entry | null} The matching HAR entry if found, or null if not found. */ export declare function findHarEntry(harLog: Log | undefined | null, method: string, endpoint: string, endpointRegex?: RegExp, ignoreSearch?: boolean, prefixToRemove?: string): Entry | null; /** * Filters a HAR log and returns a filtered HAR log based on the specified inputs. * * @param {Log | undefined | null} harLog - The HAR log to filter. * @param {string} method - The HTTP method to filter by. * @param {string} endpoint - The endpoint (pathname and search) to filter by, e.g., "/users?id=123". * @param {RegExp} [endpointRegex] - Optional regular expression to match the endpoint against. * @param {boolean} [ignoreSearch=false] - Optional flag to ignore the search part of the URL when matching endpoints. * @param {string} [prefixToRemove] - Optional prefix to remove from the beginning of the `entry.request.path` property before matching the endpoint. * @param {boolean} [sanitize] - Optional remove headers and cookies from the har file. * @returns {Log} The filtered HAR log. If no matching entries are found, an empty log will be returned. */ export declare function filterHarLog(harLog: Log | undefined | null, method: string, endpoint: string, endpointRegex?: RegExp, ignoreSearch?: boolean, prefixToRemove?: string, sanitize?: boolean): Log; /** * Type for the parameter object of the createHarEntryFromText function. */ export type HarEntryParams = { /** The base URL of the request (example: 'https://example.com'). */ baseUrl: string; /** The endpoint of the request (example: '/book/story/?page=4'). */ endpoint: string; /** The text of the response body. */ text: string; /** The MIME type of the response body (default: 'application/json'). Optional. */ mimeType?: string; /** The HTTP method used for the request (default: 'GET'). Optional. */ requestMethod?: string; /** The HTTP status code of the response (default: StatusCodes.OK). Optional. */ statusCode?: number; /** The response headers (default: an empty array). Optional. */ headers?: Header[]; }; /** * Creates a HAR (HTTP Archive) entry object from the given input parameters. * * @param {HarEntryParams} params - The parameters for creating the HAR entry. * @returns {Entry} The generated HAR entry object. */ export declare function createHarEntryFromText(params: HarEntryParams): Entry;