/** * @module types */ import type { CanPromise, IDestructible, IDictionary } from './types'; import type { IViewBased } from './view'; export type DataVariant = | IDictionary | null | FormData | string | IDictionary; export interface IRequest { url: string; method: string; data: DataVariant; } export interface IResponse { readonly status: number; readonly statusText: string; readonly url: string; readonly request: IRequest; json(): Promise; text(): Promise; blob(): Promise; } export interface IAjax extends IDestructible { options: AjaxOptions; o: this['options']; jodit: IViewBased; abort(): IAjax; send(): Promise>; prepareRequest(): IRequest; } export interface AjaxOptions { successStatuses: number[]; /** * json or text The type of data that you're expecting back * from the server. if `json` the return value passes through the `JSON.parse` */ dataType?: string; /** * The HTTP method to use for the request * (e.g. "POST", "GET", "PUT") */ method?: string; /** * A string containing the URL which the request is sent. */ url?: string; /** * Data be sent to the server. * It is converted to a query string, if not already a string. It's appended to the url for GET-requests. */ data: DataVariant; /** * When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; * charset=UTF-8", which is fine for most cases */ contentType?: string | false; /** * An object (or a function which returns an object) of additional header key/value pairs to send along * with requests using the XMLHttpRequest transport. Uses in [[FileBrowser]] * and [[Uploader]] */ headers?: | IDictionary | null | ((this: IAjax) => CanPromise | null>); responseType?: XMLHttpRequestResponseType; /** * Enable or disable Access-Control-Allow-Credentials client side. Useful for cross domain requests */ withCredentials?: boolean; queryBuild?: ( this: IAjax, obj: string | IDictionary | FormData, prefix?: string ) => string | FormData; xhr?: () => XMLHttpRequest; onProgress?: (percentage: number) => void; }