@odata2ts/http-client-jquery 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,29 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.11.0](https://github.com/odata2ts/http-client/compare/@odata2ts/jquery-v0.10.0...@odata2ts/jquery-v0.11.0) (2026-06-10)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * **jquery:** AjaxRequestConfig becomes JQueryRequestConfig
12
+
13
+ ### Features
14
+
15
+ * create blob request ([#28](https://github.com/odata2ts/http-client/issues/28)) ([4cc238d](https://github.com/odata2ts/http-client/commit/4cc238d3fbe07c09d56732b4b12d0b1b875a3ef5))
16
+
17
+
18
+ ### Code Refactoring
19
+
20
+ * **jquery:** benefit from api additions & improve config handling ([d08e4f3](https://github.com/odata2ts/http-client/commit/d08e4f30140d4c1d8968c71b89c9eb009ab44a93))
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * The following workspace dependencies were updated
26
+ * dependencies
27
+ * @odata2ts/http-client-base bumped from ^0.5.4 to ^0.5.5
28
+
6
29
  ## [0.10.0](https://github.com/odata2ts/http-client/compare/@odata2ts/jquery-v0.9.3...@odata2ts/jquery-v0.10.0) (2025-03-26)
7
30
 
8
31
 
@@ -1,15 +1,13 @@
1
1
  /// <reference types="jquery/JQueryStatic" />
2
- import { HttpResponseModel, ODataHttpClient } from "@odata2ts/http-client-api";
3
- import { BaseHttpClient, BaseHttpClientOptions, HttpMethods, InternalHttpClientConfig } from "@odata2ts/http-client-base";
4
- import { AjaxRequestConfig } from "./AjaxRequestConfig";
2
+ import { HttpResponseModel, ODataHttpClient, ODataHttpClientOptions, ODataHttpMethods } from "@odata2ts/http-client-api";
3
+ import { BaseHttpClient, BaseRequestConfig } from "@odata2ts/http-client-base";
4
+ import { JQueryRequestConfig } from "./JQueryRequestConfig";
5
5
  import jqXHR = JQuery.jqXHR;
6
6
  export declare const DEFAULT_ERROR_MESSAGE = "No error message!";
7
- export interface ClientOptions extends BaseHttpClientOptions {
8
- }
9
- export declare class JQueryClient extends BaseHttpClient<AjaxRequestConfig> implements ODataHttpClient<AjaxRequestConfig> {
7
+ export declare class JQueryClient extends BaseHttpClient<JQueryRequestConfig> implements ODataHttpClient<JQueryRequestConfig> {
10
8
  private readonly client;
11
9
  private readonly config;
12
- constructor(jquery: JQueryStatic, config?: AjaxRequestConfig, clientOptions?: ClientOptions);
10
+ constructor(jquery: JQueryStatic, config?: JQueryRequestConfig, clientOptions?: ODataHttpClientOptions);
13
11
  protected mapHeaders(jqXhr: jqXHR): Record<string, string>;
14
- protected executeRequest<ResponseModel>(method: HttpMethods, url: string, data: any, requestConfig?: JQuery.AjaxSettings, internalConfig?: InternalHttpClientConfig): Promise<HttpResponseModel<ResponseModel>>;
12
+ protected executeRequest<ResponseModel>(method: ODataHttpMethods, url: string, data: any, requestConfig?: JQueryRequestConfig, internalConfig?: BaseRequestConfig): Promise<HttpResponseModel<ResponseModel>>;
15
13
  }
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.JQueryClient = exports.DEFAULT_ERROR_MESSAGE = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const http_client_base_1 = require("@odata2ts/http-client-base");
7
- const AjaxRequestConfig_1 = require("./AjaxRequestConfig");
8
7
  const JQueryClientError_1 = require("./JQueryClientError");
8
+ const JQueryRequestConfig_1 = require("./JQueryRequestConfig");
9
9
  exports.DEFAULT_ERROR_MESSAGE = "No error message!";
10
10
  class JQueryClient extends http_client_base_1.BaseHttpClient {
11
11
  constructor(jquery, config, clientOptions) {
12
12
  super(clientOptions);
13
13
  this.client = jquery;
14
- this.config = (0, AjaxRequestConfig_1.getDefaultConfig)(config);
14
+ this.config = config !== null && config !== void 0 ? config : {};
15
15
  }
16
16
  mapHeaders(jqXhr) {
17
17
  return jqXhr
@@ -30,26 +30,27 @@ class JQueryClient extends http_client_base_1.BaseHttpClient {
30
30
  }
31
31
  executeRequest(method, url, data, requestConfig, internalConfig = {}) {
32
32
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
33
- const withInternalConfig = (0, AjaxRequestConfig_1.mergeAjaxConfig)({ headers: internalConfig.headers }, requestConfig);
34
- const _a = (0, AjaxRequestConfig_1.mergeAjaxConfig)(this.config, withInternalConfig), { params } = _a, mergedConfig = tslib_1.__rest(_a, ["params"]);
35
- mergedConfig.method = method;
36
- mergedConfig.data = JSON.stringify(data);
37
- mergedConfig.url = url;
33
+ const { headers } = internalConfig;
34
+ const _a = (0, JQueryRequestConfig_1.mergeConfigs)(this.config, (0, JQueryRequestConfig_1.mergeConfigs)({ headers }, requestConfig)), { params } = _a, mergedConfig = tslib_1.__rest(_a, ["params"]);
35
+ // set core inputs for request
36
+ const resultConfig = Object.assign(Object.assign({}, mergedConfig), { method, data: JSON.stringify(data), url });
37
+ // apply additional query params to the URL
38
38
  if (params && Object.values(params).length) {
39
- mergedConfig.url +=
39
+ resultConfig.url +=
40
40
  (url.match(/\?/) ? "&" : "?") +
41
41
  // @ts-ignore
42
42
  new URLSearchParams(params).toString();
43
43
  }
44
+ // handling of extra data types: blob and stream (not supported)
44
45
  if (internalConfig.dataType === "blob") {
45
- mergedConfig.xhrFields = { responseType: "blob" };
46
+ resultConfig.xhrFields = { responseType: "blob" };
46
47
  }
47
48
  else if (internalConfig.dataType === "stream") {
48
49
  throw new Error("Streaming is not supported by the JqueryClient!");
49
50
  }
50
51
  // the actual request
51
52
  return new Promise((resolve, reject) => {
52
- this.client.ajax(Object.assign(Object.assign({}, mergedConfig), { success: (response, textStatus, jqXHR) => {
53
+ this.client.ajax(Object.assign(Object.assign({}, resultConfig), { success: (response, textStatus, jqXHR) => {
53
54
  resolve({
54
55
  status: jqXHR.status,
55
56
  statusText: jqXHR.statusText,
@@ -1 +1 @@
1
-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AC,oBAAoB,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY,CAAC,CAAC;wBACvE,MAAM,OAAO,GAAG,eAAe,IAAI,WAAW,IAAI,6BAAqB,CAAC;wBACxE,MAAM,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC,qCAAqC,GAAG,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC;wBACzG,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;wBAC/C,MAAM,CAAC,IAAI,qCAAiB,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;oBACxG,CAAC,IACD,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AA1ED,oCA0EC","sourcesContent":["/// <reference path=\"../../../node_modules/@types/jquery/JQueryStatic.d.ts\" />\n\nimport { HttpResponseModel, ODataHttpClient } from \"@odata2ts/http-client-api\";\nimport {\n BaseHttpClient,\n BaseHttpClientOptions,\n HttpMethods,\n InternalHttpClientConfig,\n} from \"@odata2ts/http-client-base\";\nimport { AjaxRequestConfig, getDefaultConfig, mergeAjaxConfig } from \"./AjaxRequestConfig\";\nimport { JQueryClientError } from \"./JQueryClientError\";\n\nimport jqXHR = JQuery.jqXHR;\n\nexport const DEFAULT_ERROR_MESSAGE = \"No error message!\";\n\nexport interface ClientOptions extends BaseHttpClientOptions {}\n\nexport class JQueryClient extends BaseHttpClient<AjaxRequestConfig> implements ODataHttpClient<AjaxRequestConfig> {\n private readonly client: JQueryStatic;\n private readonly config: JQuery.AjaxSettings;\n\n constructor(jquery: JQueryStatic, config?: AjaxRequestConfig, clientOptions?: ClientOptions) {\n super(clientOptions);\n this.client = jquery;\n this.config = getDefaultConfig(config);\n }\n\n protected mapHeaders(jqXhr: jqXHR): Record<string, string> {\n return jqXhr\n .getAllResponseHeaders()\n .trim()\n .split(/[\\r\\n]+/)\n .reduce((collector: Record<string, string>, line: string) => {\n const parts = line.split(\": \");\n const header = parts.shift();\n const value = parts.join(\": \");\n\n if (header) {\n collector[header.toLowerCase()] = value;\n }\n return collector;\n }, {});\n }\n\n protected async executeRequest<ResponseModel>(\n method: HttpMethods,\n url: string,\n data: any,\n requestConfig?: JQuery.AjaxSettings,\n internalConfig: InternalHttpClientConfig = {},\n ): Promise<HttpResponseModel<ResponseModel>> {\n const withInternalConfig = mergeAjaxConfig({ headers: internalConfig.headers }, requestConfig);\n const { params, ...mergedConfig } = mergeAjaxConfig(this.config, withInternalConfig);\n mergedConfig.method = method;\n mergedConfig.data = JSON.stringify(data);\n mergedConfig.url = url;\n if (params && Object.values(params).length) {\n mergedConfig.url +=\n (url.match(/\\?/) ? \"&\" : \"?\") +\n // @ts-ignore\n new URLSearchParams(params).toString();\n }\n\n if (internalConfig.dataType === \"blob\") {\n mergedConfig.xhrFields = { responseType: \"blob\" };\n } else if (internalConfig.dataType === \"stream\") {\n throw new Error(\"Streaming is not supported by the JqueryClient!\");\n }\n\n // the actual request\n return new Promise((resolve, reject) => {\n this.client.ajax({\n ...mergedConfig,\n success: (response: any, textStatus: string, jqXHR: JQuery.jqXHR) => {\n resolve({\n status: jqXHR.status,\n statusText: jqXHR.statusText,\n headers: this.mapHeaders(jqXHR),\n data: response,\n });\n },\n error: (jqXHR: JQuery.jqXHR, textStatus: string, thrownError: string) => {\n const responseMessage = this.retrieveErrorMessage(jqXHR?.responseJSON);\n const failMsg = responseMessage || thrownError || DEFAULT_ERROR_MESSAGE;\n const errorMessage = responseMessage ? \"OData server responded with error: \" + responseMessage : failMsg;\n const responseHeaders = this.mapHeaders(jqXHR);\n reject(new JQueryClientError(errorMessage, jqXHR.status, responseHeaders, new Error(failMsg), jqXHR));\n },\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"JQueryClient.js","sourceRoot":"","sources":["../src/JQueryClient.ts"],"names":[],"mappings":";AAAA,8EAA8E;;;;AAQ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,GAAG,eAAe,IAAI,WAAW,IAAI,6BAAqB,CAAC;wBACxE,MAAM,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC,qCAAqC,GAAG,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC;wBACzG,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;wBAC/C,MAAM,CAAC,IAAI,qCAAiB,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;oBACxG,CAAC,IACD,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAlFD,oCAkFC","sourcesContent":["/// <reference path=\"../../../node_modules/@types/jquery/JQueryStatic.d.ts\" />\n\nimport {\n HttpResponseModel,\n ODataHttpClient,\n ODataHttpClientOptions,\n ODataHttpMethods,\n} from \"@odata2ts/http-client-api\";\nimport { BaseHttpClient, BaseRequestConfig } from \"@odata2ts/http-client-base\";\nimport { JQueryClientError } from \"./JQueryClientError\";\nimport { JQueryRequestConfig, mergeConfigs } from \"./JQueryRequestConfig\";\n\nimport jqXHR = JQuery.jqXHR;\n\nexport const DEFAULT_ERROR_MESSAGE = \"No error message!\";\n\ninterface InternalRequestConfig\n extends JQueryRequestConfig,\n Pick<JQuery.AjaxSettings, \"url\" | \"data\" | \"dataType\" | \"method\" | \"xhrFields\"> {}\n\nexport class JQueryClient extends BaseHttpClient<JQueryRequestConfig> implements ODataHttpClient<JQueryRequestConfig> {\n private readonly client: JQueryStatic;\n private readonly config: JQueryRequestConfig;\n\n constructor(jquery: JQueryStatic, config?: JQueryRequestConfig, clientOptions?: ODataHttpClientOptions) {\n super(clientOptions);\n this.client = jquery;\n this.config = config ?? {};\n }\n\n protected mapHeaders(jqXhr: jqXHR): Record<string, string> {\n return jqXhr\n .getAllResponseHeaders()\n .trim()\n .split(/[\\r\\n]+/)\n .reduce((collector: Record<string, string>, line: string) => {\n const parts = line.split(\": \");\n const header = parts.shift();\n const value = parts.join(\": \");\n\n if (header) {\n collector[header.toLowerCase()] = value;\n }\n return collector;\n }, {});\n }\n\n protected async executeRequest<ResponseModel>(\n method: ODataHttpMethods,\n url: string,\n data: any,\n requestConfig?: JQueryRequestConfig,\n internalConfig: BaseRequestConfig = {},\n ): Promise<HttpResponseModel<ResponseModel>> {\n const { headers } = internalConfig;\n const { params, ...mergedConfig } = mergeConfigs(this.config, mergeConfigs({ headers }, requestConfig));\n\n // set core inputs for request\n const resultConfig: InternalRequestConfig = {\n ...mergedConfig,\n method,\n data: JSON.stringify(data),\n url,\n };\n\n // apply additional query params to the URL\n if (params && Object.values(params).length) {\n resultConfig.url +=\n (url.match(/\\?/) ? \"&\" : \"?\") +\n // @ts-ignore\n new URLSearchParams(params).toString();\n }\n\n // handling of extra data types: blob and stream (not supported)\n if (internalConfig.dataType === \"blob\") {\n resultConfig.xhrFields = { responseType: \"blob\" };\n } else if (internalConfig.dataType === \"stream\") {\n throw new Error(\"Streaming is not supported by the JqueryClient!\");\n }\n\n // the actual request\n return new Promise((resolve, reject) => {\n this.client.ajax({\n ...resultConfig,\n success: (response: any, textStatus: string, jqXHR: JQuery.jqXHR) => {\n resolve({\n status: jqXHR.status,\n statusText: jqXHR.statusText,\n headers: this.mapHeaders(jqXHR),\n data: response,\n });\n },\n error: (jqXHR: JQuery.jqXHR, textStatus: string, thrownError: string) => {\n const responseMessage = this.retrieveErrorMessage(jqXHR?.responseJSON);\n const failMsg = responseMessage || thrownError || DEFAULT_ERROR_MESSAGE;\n const errorMessage = responseMessage ? \"OData server responded with error: \" + responseMessage : failMsg;\n const responseHeaders = this.mapHeaders(jqXHR);\n reject(new JQueryClientError(errorMessage, jqXHR.status, responseHeaders, new Error(failMsg), jqXHR));\n },\n });\n });\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { ODataRequestConfig } from "@odata2ts/http-client-api";
2
+ export interface JQueryRequestConfig extends ODataRequestConfig, Pick<JQuery.AjaxSettings, "complete" | "beforeSend" | "statusCode" | "timeout" | "cache"> {
3
+ }
4
+ export declare function mergeConfigs(config?: JQueryRequestConfig, toMerge?: JQueryRequestConfig): JQueryRequestConfig;
@@ -1,21 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeAjaxConfig = exports.getDefaultConfig = void 0;
3
+ exports.mergeConfigs = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const DEFAULT_CONFIG = {
6
- // we never want caching
7
- cache: false,
8
- // we always want JSON
9
- // dataType: "json",
10
- };
11
- function getDefaultConfig(config) {
12
- return mergeAjaxConfig(DEFAULT_CONFIG, config);
13
- }
14
- exports.getDefaultConfig = getDefaultConfig;
15
- function mergeAjaxConfig(config, toMerge) {
5
+ function mergeConfigs(config, toMerge) {
16
6
  const _a = config || {}, { headers } = _a, passThrough = tslib_1.__rest(_a, ["headers"]);
17
7
  const _b = toMerge || {}, { headers: headers2 } = _b, passThrough2 = tslib_1.__rest(_b, ["headers"]);
18
8
  return Object.assign(Object.assign(Object.assign({}, passThrough), passThrough2), { headers: Object.assign(Object.assign({}, headers), headers2) });
19
9
  }
20
- exports.mergeAjaxConfig = mergeAjaxConfig;
21
- //# sourceMappingURL=AjaxRequestConfig.js.map
10
+ exports.mergeConfigs = mergeConfigs;
11
+ //# sourceMappingURL=JQueryRequestConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JQueryRequestConfig.js","sourceRoot":"","sources":["../src/JQueryRequestConfig.ts"],"names":[],"mappings":";;;;AAMA,SAAgB,YAAY,CAAC,MAA4B,EAAE,OAA6B;IACtF,MAAM,KAA8B,MAAM,IAAI,EAAE,EAA1C,EAAE,OAAO,OAAiC,EAA5B,WAAW,sBAAzB,WAA2B,CAAe,CAAC;IACjD,MAAM,KAAyC,OAAO,IAAI,EAAE,EAAtD,EAAE,OAAO,EAAE,QAAQ,OAAmC,EAA9B,YAAY,sBAApC,WAAsC,CAAgB,CAAC;IAC7D,qDACK,WAAW,GACX,YAAY,KACf,OAAO,kCACF,OAAO,GACP,QAAQ,KAEb;AACJ,CAAC;AAXD,oCAWC","sourcesContent":["import { ODataRequestConfig } from \"@odata2ts/http-client-api\";\n\nexport interface JQueryRequestConfig\n extends ODataRequestConfig,\n Pick<JQuery.AjaxSettings, \"complete\" | \"beforeSend\" | \"statusCode\" | \"timeout\" | \"cache\"> {}\n\nexport function mergeConfigs(config?: JQueryRequestConfig, toMerge?: JQueryRequestConfig): JQueryRequestConfig {\n const { headers, ...passThrough } = config || {};\n const { headers: headers2, ...passThrough2 } = toMerge || {};\n return {\n ...passThrough,\n ...passThrough2,\n headers: {\n ...headers,\n ...headers2,\n },\n };\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { AjaxRequestConfig } from "./AjaxRequestConfig";
1
+ export { JQueryRequestConfig } from "./JQueryRequestConfig";
2
2
  export * from "./JQueryClient";
3
3
  export { JQueryClientError } from "./JQueryClientError";
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,yDAA+B;AAC/B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["export { AjaxRequestConfig } from \"./AjaxRequestConfig\";\nexport * from \"./JQueryClient\";\nexport { JQueryClientError } from \"./JQueryClientError\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,yDAA+B;AAC/B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["export { JQueryRequestConfig } from \"./JQueryRequestConfig\";\nexport * from \"./JQueryClient\";\nexport { JQueryClientError } from \"./JQueryClientError\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odata2ts/http-client-jquery",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "JQuery based http client usable by odata2ts",
5
5
  "keywords": [
6
6
  "http client",
@@ -31,7 +31,7 @@
31
31
  "test": "vitest run"
32
32
  },
33
33
  "dependencies": {
34
- "@odata2ts/http-client-base": "^0.5.4"
34
+ "@odata2ts/http-client-base": "^0.5.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/jquery": "^3.5.16",
@@ -1,13 +0,0 @@
1
- /**
2
- * Available config options for end user when making a given request.
3
- */
4
- export interface AjaxRequestConfig extends Pick<JQuery.AjaxSettings, "complete" | "beforeSend" | "headers" | "statusCode" | "timeout"> {
5
- /**
6
- * Add query params.
7
- */
8
- params?: Record<string, string | number | boolean | Array<string | number | boolean>>;
9
- }
10
- export interface InternalRequestConfig extends JQuery.AjaxSettings, Pick<AjaxRequestConfig, "params"> {
11
- }
12
- export declare function getDefaultConfig(config?: AjaxRequestConfig): InternalRequestConfig;
13
- export declare function mergeAjaxConfig(config?: JQuery.AjaxSettings, toMerge?: JQuery.AjaxSettings): InternalRequestConfig;
@@ -1 +0,0 @@
1
- {"version":3,"file":"AjaxRequestConfig.js","sourceRoot":"","sources":["../src/AjaxRequestConfig.ts"],"names":[],"mappings":";;;;AAAA,MAAM,cAAc,GAAwB;IAC1C,wBAAwB;IACxB,KAAK,EAAE,KAAK;IACZ,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAeF,SAAgB,gBAAgB,CAAC,MAA0B;IACzD,OAAO,eAAe,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe,CAAC,MAA4B,EAAE,OAA6B;IACzF,MAAM,KAA8B,MAAM,IAAI,EAAE,EAA1C,EAAE,OAAO,OAAiC,EAA5B,WAAW,sBAAzB,WAA2B,CAAe,CAAC;IACjD,MAAM,KAAyC,OAAO,IAAI,EAAE,EAAtD,EAAE,OAAO,EAAE,QAAQ,OAAmC,EAA9B,YAAY,sBAApC,WAAsC,CAAgB,CAAC;IAC7D,qDACK,WAAW,GACX,YAAY,KACf,OAAO,kCACF,OAAO,GACP,QAAQ,KAEb;AACJ,CAAC;AAXD,0CAWC","sourcesContent":["const DEFAULT_CONFIG: JQuery.AjaxSettings = {\n // we never want caching\n cache: false,\n // we always want JSON\n // dataType: \"json\",\n};\n\n/**\n * Available config options for end user when making a given request.\n */\nexport interface AjaxRequestConfig\n extends Pick<JQuery.AjaxSettings, \"complete\" | \"beforeSend\" | \"headers\" | \"statusCode\" | \"timeout\"> {\n /**\n * Add query params.\n */\n params?: Record<string, string | number | boolean | Array<string | number | boolean>>;\n}\n\nexport interface InternalRequestConfig extends JQuery.AjaxSettings, Pick<AjaxRequestConfig, \"params\"> {}\n\nexport function getDefaultConfig(config?: AjaxRequestConfig): InternalRequestConfig {\n return mergeAjaxConfig(DEFAULT_CONFIG, config);\n}\n\nexport function mergeAjaxConfig(config?: JQuery.AjaxSettings, toMerge?: JQuery.AjaxSettings): InternalRequestConfig {\n const { headers, ...passThrough } = config || {};\n const { headers: headers2, ...passThrough2 } = toMerge || {};\n return {\n ...passThrough,\n ...passThrough2,\n headers: {\n ...headers,\n ...headers2,\n },\n };\n}\n"]}