@eclipse-scout/core
Version:
Eclipse Scout runtime
210 lines • 14 kB
TypeScript
/// <reference types="jquery" />
import { AjaxCall, AjaxCallModel, AjaxError, BaseDoEntity, DoEntity } from '../index';
/**
* Utility to perform AJAX requests via HTTP in an easy way. It provides some common functions to call a REST backend using {@link AjaxCall}.
*/
export declare const ajax: {
/**
* Performs an HTTP GET request.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
get(url: string, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP POST request.
*
* @param data the data to be sent.
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
post(url: string, data?: any, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP PUT request.
*
* @param data the data to be sent.
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
put(url: string, data?: any, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP DELETE request.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
remove(url: string, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP request.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
call(options: UrlAjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Prepares an {@link AjaxCall}, but does not execute it yet.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns the prepared {@link AjaxCall}. Execute it with the `call()` function.
*/
createCall(options: UrlAjaxSettings, model?: AjaxCallModel): AjaxCall;
/**
* Performs an HTTP GET request using JSON as format for the request and the response.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
getJson(url: string, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP POST request using JSON as format for the request and the response.
*
* @param data the data to be sent. If the data is not a string it will be converted to a string using JSON.stringify().
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
postJson(url: string, data?: any, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP PUT request using JSON as format for the request and the response.
*
* @param data the data to be sent. If the data is not a string it will be converted to a string using JSON.stringify().
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
putJson(url: string, data?: any, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP DELETE request using JSON as format for the request and the response.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
removeJson(url: string, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Performs an HTTP request using JSON as format for the request and the response.
* The default HTTP method is POST.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns a promise which is resolved when the request succeeds.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
callJson(options?: UrlAjaxSettings, model?: AjaxCallModel): JQuery.Promise<any, AjaxError>;
/**
* Prepares an HTTP call with JSON as format for the request and the response, but does not execute it yet.
* The default HTTP method is POST.
*
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall}.
* @returns the prepared Ajax call object. Execute it with the call() function.
*/
createCallJson(options?: UrlAjaxSettings, model?: AjaxCallModel): AjaxCall;
/**
* Performs an HTTP GET request to the given URL and converts the response to a data object.
*
* @param url The URL of the request.
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall} which is created to perform the request.
* @returns A promise which is resolved when the request succeeds. The response is automatically converted to a {@link BaseDoEntity} or `null`.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
getDataObject<TDoOut extends BaseDoEntity>(url: string, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<TDoOut, AjaxError>;
/**
* Sends the given data object with an HTTP POST request to the given URL. The result is expected to be a data object as well.
*
* @param url The URL of the request.
* @param dataObject The data object to send or `null`.
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall} which is created to perform the request.
* @returns A promise which is resolved when the request succeeds. The response is automatically converted to a {@link BaseDoEntity} or `null`.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
postDataObject<TDoIn extends void | BaseDoEntity, TDoOut_1 extends void | BaseDoEntity>(url: string, dataObject?: TDoIn, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<TDoOut_1, AjaxError, any>;
/**
* Sends the given data object with an HTTP PUT request to the given URL. The result is expected to be a data object as well.
*
* @param url The URL of the request.
* @param dataObject The data object to send or `null`.
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall} which is created to perform the request.
* @returns A promise which is resolved when the request succeeds. The response is automatically converted to a {@link BaseDoEntity} or `null`.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
putDataObject<TDoIn_1 extends void | BaseDoEntity, TDoOut_2 extends void | BaseDoEntity>(url: string, dataObject?: TDoIn_1, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<TDoOut_2, AjaxError, any>;
/**
* Sends the given data object with an HTTP DELETE request to the given URL. The result is expected to be a data object as well.
*
* @param url The URL of the request.
* @param dataObject The data object to send or `null`.
* @param options additional settings for the request.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param model additional properties for the {@link AjaxCall} which is created to perform the request.
* @returns A promise which is resolved when the request succeeds. The response is automatically converted to a {@link BaseDoEntity} or `null`.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
removeDataObject<TDoIn_2 extends void | BaseDoEntity, TDoOut_3 extends void | BaseDoEntity>(url: string, dataObject?: TDoIn_2, options?: AjaxSettings, model?: AjaxCallModel): JQuery.Promise<TDoOut_3, AjaxError, any>;
/**
* Sends the given data object with an HTTP request. The result is expected to be a data object as well.
*
* @param options Settings for the request. Must contain the properties `url` and `method`.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param dataObject The data object to send or `null`.
* @param model additional properties for the {@link AjaxCall} which is created to perform the request.
* @returns A promise which is resolved when the request succeeds. The response is automatically converted to a {@link BaseDoEntity} or `null`.
* In case of an error the promise is rejected with an {@link AjaxError}.
*/
callDataObject<TDoIn_3 extends void | BaseDoEntity, TDoOut_4 extends void | BaseDoEntity>(options: UrlAjaxSettings, dataObject?: TDoIn_3, model?: AjaxCallModel): JQuery.Promise<TDoOut_4, AjaxError, any>;
/**
* Creates an {@link AjaxCall} which sends the given data object as json.
*
* @param options Settings for the request. Must contain the property 'url' and 'method'.
* Since jQuery is used to perform the request, all {@link https://api.jquery.com/jQuery.ajax/ jQuery.ajax} settings are accepted.
* @param dataObject The data object to send or `null`.
* @param model Properties for the {@link AjaxCall} which is created.
* @returns an {@link AjaxCall} which sends the given data object, pre-configured using the given options and model. The result of the call is converted to a data object automatically.
*/
createCallDataObject(options: UrlAjaxSettings, dataObject?: DoEntity | void, model?: AjaxCallModel): AjaxCall;
};
/**
* Like JQuery.AjaxSettings without 'type' property. Use 'method' instead.
*/
export type AjaxSettings = Omit<JQuery.AjaxSettings, 'type'>;
/**
* Like JQuery.UrlAjaxSettings without 'type' property. Use 'method' instead.
*/
export type UrlAjaxSettings = AjaxSettings & {
url: string;
};
//# sourceMappingURL=ajax.d.ts.map