@odata2ts/http-client-jquery 0.8.1 → 0.8.2
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 +4 -0
- package/lib/JQueryClient.d.ts +3 -3
- package/lib/JQueryClient.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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.8.2](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-jquery@0.8.1...@odata2ts/http-client-jquery@0.8.2) (2023-09-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @odata2ts/http-client-jquery
|
|
9
|
+
|
|
6
10
|
## [0.8.1](https://github.com/odata2ts/http-client/compare/@odata2ts/http-client-jquery@0.8.0...@odata2ts/http-client-jquery@0.8.1) (2023-09-13)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @odata2ts/http-client-jquery
|
package/lib/JQueryClient.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="jquery/jquerystatic" />
|
|
2
|
-
import { HttpResponseModel,
|
|
3
|
-
import { BaseHttpClient, BaseHttpClientOptions, HttpMethods } from "@odata2ts/http-client-base";
|
|
2
|
+
import { HttpResponseModel, ODataHttpClient } from "@odata2ts/http-client-api";
|
|
3
|
+
import { BaseHttpClient, BaseHttpClientOptions, HttpMethods, InternalHttpClientConfig } from "@odata2ts/http-client-base";
|
|
4
4
|
import { AjaxRequestConfig } from "./AjaxRequestConfig";
|
|
5
5
|
import jqXHR = JQuery.jqXHR;
|
|
6
6
|
export declare const DEFAULT_ERROR_MESSAGE = "No error message!";
|
|
7
7
|
export interface ClientOptions extends BaseHttpClientOptions {
|
|
8
8
|
}
|
|
9
|
-
export declare class JQueryClient extends BaseHttpClient<AjaxRequestConfig> {
|
|
9
|
+
export declare class JQueryClient extends BaseHttpClient<AjaxRequestConfig> implements ODataHttpClient<AjaxRequestConfig> {
|
|
10
10
|
private readonly client;
|
|
11
11
|
private readonly config;
|
|
12
12
|
constructor(jquery: JQueryStatic, config?: AjaxRequestConfig, clientOptions?: ClientOptions);
|
package/lib/JQueryClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JQueryClient.js","sourceRoot":"","sources":["../src/JQueryClient.ts"],"names":[],"mappings":";AAAA,8EAA8E;;;;AAG9E,
|
|
1
|
+
{"version":3,"file":"JQueryClient.js","sourceRoot":"","sources":["../src/JQueryClient.ts"],"names":[],"mappings":";AAAA,8EAA8E;;;;AAG9E,iEAKoC;AAEpC,2DAA2F;AAC3F,2DAAwD;AAI3C,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AAIzD,MAAa,YAAa,SAAQ,iCAAiC;IAIjE,YAAY,MAAoB,EAAE,MAA0B,EAAE,aAA6B;QACzF,KAAK,CAAC,aAAa,CAAC,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAA,oCAAgB,EAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAES,UAAU,CAAC,KAAY;QAC/B,OAAO,KAAK;aACT,qBAAqB,EAAE;aACvB,IAAI,EAAE;aACN,KAAK,CAAC,SAAS,CAAC;aAChB,MAAM,CAAC,CAAC,SAAiC,EAAE,IAAY,EAAE,EAAE;YAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE/B,IAAI,MAAM,EAAE;gBACV,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;aACzC;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;yBACf,CAAC,CAAC;oBACL,CAAC,EACD,KAAK,EAAE,CAAC,KAAmB,EAAE,UAAkB,EAAE,WAAmB,EAAE,EAAE;;wBACtE,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY,CAAC,CAAC;wBACvE,MAAM,OAAO,GAAG,MAAA,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,WAAW,mCAAI,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;AApED,oCAoEC","sourcesContent":["/// <reference path=\"../../../node_modules/@types/jquery/JQueryStatic.d.ts\" />\r\n\r\nimport { HttpResponseModel, ODataHttpClient } from \"@odata2ts/http-client-api\";\r\nimport {\r\n BaseHttpClient,\r\n BaseHttpClientOptions,\r\n HttpMethods,\r\n InternalHttpClientConfig,\r\n} from \"@odata2ts/http-client-base\";\r\n\r\nimport { AjaxRequestConfig, getDefaultConfig, mergeAjaxConfig } from \"./AjaxRequestConfig\";\r\nimport { JQueryClientError } from \"./JQueryClientError\";\r\n\r\nimport jqXHR = JQuery.jqXHR;\r\n\r\nexport const DEFAULT_ERROR_MESSAGE = \"No error message!\";\r\n\r\nexport interface ClientOptions extends BaseHttpClientOptions {}\r\n\r\nexport class JQueryClient extends BaseHttpClient<AjaxRequestConfig> implements ODataHttpClient<AjaxRequestConfig> {\r\n private readonly client: JQueryStatic;\r\n private readonly config: JQuery.AjaxSettings;\r\n\r\n constructor(jquery: JQueryStatic, config?: AjaxRequestConfig, clientOptions?: ClientOptions) {\r\n super(clientOptions);\r\n this.client = jquery;\r\n this.config = getDefaultConfig(config);\r\n }\r\n\r\n protected mapHeaders(jqXhr: jqXHR): Record<string, string> {\r\n return jqXhr\r\n .getAllResponseHeaders()\r\n .trim()\r\n .split(/[\\r\\n]+/)\r\n .reduce((collector: Record<string, string>, line: string) => {\r\n const parts = line.split(\": \");\r\n const header = parts.shift();\r\n const value = parts.join(\": \");\r\n\r\n if (header) {\r\n collector[header.toLowerCase()] = value;\r\n }\r\n return collector;\r\n }, {});\r\n }\r\n\r\n protected async executeRequest<ResponseModel>(\r\n method: HttpMethods,\r\n url: string,\r\n data: any,\r\n requestConfig?: JQuery.AjaxSettings,\r\n internalConfig: InternalHttpClientConfig = {}\r\n ): Promise<HttpResponseModel<ResponseModel>> {\r\n const withInternalConfig = mergeAjaxConfig({ headers: internalConfig.headers }, requestConfig);\r\n const { params, ...mergedConfig } = mergeAjaxConfig(this.config, withInternalConfig);\r\n mergedConfig.method = method;\r\n mergedConfig.data = JSON.stringify(data);\r\n mergedConfig.url = url;\r\n if (params && Object.values(params).length) {\r\n mergedConfig.url +=\r\n (url.match(/\\?/) ? \"&\" : \"?\") +\r\n // @ts-ignore\r\n new URLSearchParams(params).toString();\r\n }\r\n\r\n // the actual request\r\n return new Promise((resolve, reject) => {\r\n this.client.ajax({\r\n ...mergedConfig,\r\n success: (response: any, textStatus: string, jqXHR: JQuery.jqXHR) => {\r\n resolve({\r\n status: jqXHR.status,\r\n statusText: jqXHR.statusText,\r\n headers: this.mapHeaders(jqXHR),\r\n data: response,\r\n });\r\n },\r\n error: (jqXHR: JQuery.jqXHR, textStatus: string, thrownError: string) => {\r\n const responseMessage = this.retrieveErrorMessage(jqXHR?.responseJSON);\r\n const failMsg = responseMessage ?? thrownError ?? DEFAULT_ERROR_MESSAGE;\r\n const errorMessage = responseMessage ? \"OData server responded with error: \" + responseMessage : failMsg;\r\n const responseHeaders = this.mapHeaders(jqXHR);\r\n reject(new JQueryClientError(errorMessage, jqXHR.status, responseHeaders, new Error(failMsg), jqXHR));\r\n },\r\n });\r\n });\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odata2ts/http-client-jquery",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"jquery": ">1.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@odata2ts/http-client-base": "^0.4.
|
|
38
|
+
"@odata2ts/http-client-base": "^0.4.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/jest": "^27.4.1",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"typescript": "5.0.4"
|
|
51
51
|
},
|
|
52
52
|
"types": "./lib/index.d.ts",
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "0886c9e292a84560001d4c4e4503babf3809e1d7"
|
|
54
54
|
}
|