import { ConfigSchema } from "../schema/config"; import { Sort } from "../interfaces/sort"; import { Pagination } from "../interfaces/pagination"; import EventDispatcher from "./event-dispatcher"; export default class Client { private readonly _config; private readonly _eventDispatcher; private _sort; private _pagination; private _search; constructor(config: ConfigSchema, eventDispatcher: EventDispatcher); /** * Refreshes data by triggering an AJAX request to the configured URL. * Handles the data response and dispatches appropriate events in the process, * including "before-data-fetch", "data-fetch", "after-data-fetch", and "data-fetch-error". */ refresh(): void; get sort(): Sort | null; set sort(value: Sort | null); get pagination(): Pagination | null; set pagination(value: Pagination | null); get search(): string | null; set search(value: string | null); /** * Generates and returns a new Request object based on the current configuration. * * The request is constructed using parameters defined in the `_config` object. * Depending on the HTTP method specified in `_config.ajaxMethod`, the request URL and body * will be formatted accordingly. * * For `GET` requests, the URL is appended with query parameters generated by `generateURLSearchParams()`. * For `POST` requests, the request body is generated by `generateRequestBody()` and stringifies as JSON. * * @private * @returns {Request} */ private generateRequest; /** * Generates and returns the request body containing pagination and sort data. * * @private */ private generateRequestBody; /** * Generates and returns URL search parameters based on the current pagination and sort settings. * * If pagination details are available, they are added as "pagination-page" and "pagination-size" parameters. * If sorting details are specified, they are added as "sort-column" and "sort-direction" parameters. * * @return {URLSearchParams} */ private generateURLSearchParams; }