@kelvininc/web-client-sdk 7.1.0 → 7.8.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 +79 -0
- package/README.md +3 -3
- package/dist/cjs/adapters/http-adapter.d.ts +1 -7
- package/dist/cjs/adapters/http-adapter.js +13 -4
- package/dist/cjs/adapters/http-adapter.js.map +1 -1
- package/dist/esm/adapters/http-adapter.d.ts +1 -7
- package/dist/esm/adapters/http-adapter.js +12 -4
- package/dist/esm/adapters/http-adapter.js.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,85 @@
|
|
|
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
|
+
# [7.8.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.7.0...v7.8.0) (2022-07-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **kelvin-js-sdk:** rollback content type header support ([6714394](https://bitbucket.org/kelvininc/kelvinjs/commits/6714394a21cd946bd8489f3a362e4acbe9c42b9b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **kelvin-web-sdk:** fix version due to [#434](https://bitbucket.org/kelvininc/kelvinjs/issues/434) issue ([aef2b89](https://bitbucket.org/kelvininc/kelvinjs/commits/aef2b89a56fc576efd90ba5d50f7954733d45c61))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [7.7.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.6.0...v7.7.0) (2022-05-26)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @kelvininc/web-client-sdk
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [7.6.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.5.0...v7.6.0) (2022-05-20)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* add thread services, update asset service with templates and visualization models ([a9b6a07](https://bitbucket.org/kelvininc/kelvinjs/commits/a9b6a076a69cc50c206ecfe05034c77b3f459d01))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# [7.5.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.4.1...v7.5.0) (2022-05-06)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @kelvininc/web-client-sdk
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [7.4.1](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.4.0...v7.4.1) (2022-05-05)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @kelvininc/web-client-sdk
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# [7.4.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.3.0...v7.4.0) (2022-04-27)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @kelvininc/web-client-sdk
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# [7.3.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.2.0...v7.3.0) (2022-04-12)
|
|
66
|
+
|
|
67
|
+
**Note:** Version bump only for package @kelvininc/web-client-sdk
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# [7.2.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.1.0...v7.2.0) (2022-04-12)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Bug Fixes
|
|
77
|
+
|
|
78
|
+
* **kelvin-web-sdk:** change default params serializer to use lists ([b13cf9f](https://bitbucket.org/kelvininc/kelvinjs/commits/b13cf9f8318862e289f71f5d6c12f45314237b16))
|
|
79
|
+
* **kelvin-web-sdk:** fix status error access ([f7e2fcb](https://bitbucket.org/kelvininc/kelvinjs/commits/f7e2fcb6157f036b23f9a85015bd91c6e0cb6064))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
6
85
|
# [7.1.0](https://bitbucket.org/kelvininc/kelvinjs/compare/v7.0.1...v7.1.0) (2022-02-15)
|
|
7
86
|
|
|
8
87
|
**Note:** Version bump only for package @kelvininc/web-client-sdk
|
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@ Kelvin SDK Client provides a simple way to integrate our Authentication, Service
|
|
|
6
6
|
|
|
7
7
|
To run our SDK inside your project you need to support the following versions:
|
|
8
8
|
|
|
9
|
-
- Rxjs: 6.
|
|
10
|
-
- Axios
|
|
9
|
+
- Rxjs: 6.6.X
|
|
10
|
+
- Axios: ^0.27.2
|
|
11
11
|
- Optionally, keycloak-js to handle the authentication
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
@@ -15,7 +15,7 @@ To run our SDK inside your project you need to support the following versions:
|
|
|
15
15
|
Install the Kelvin SDK Client, RxJS and Axios Client:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install @kelvininc/web-client-sdk axios rxjs@~6.
|
|
18
|
+
npm install @kelvininc/web-client-sdk axios rxjs@~6.6.7 --save
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Setup without Keycloak
|
|
@@ -5,12 +5,6 @@ export declare class HttpAdapter implements IKvHttpAdapter {
|
|
|
5
5
|
private httpClient;
|
|
6
6
|
constructor(httpClient: AxiosInstance);
|
|
7
7
|
request(requestPayload: IKvHttpRequest): Observable<IKvHttpResponse>;
|
|
8
|
-
handleError(err: AxiosError, config: IKvHttpRequest):
|
|
9
|
-
status: string;
|
|
10
|
-
statusText: string;
|
|
11
|
-
headers: any;
|
|
12
|
-
config: IKvHttpRequest;
|
|
13
|
-
httpResponse: AxiosResponse<any>;
|
|
14
|
-
};
|
|
8
|
+
handleError(err: AxiosError, config: IKvHttpRequest): IKvHttpResponse | AxiosError;
|
|
15
9
|
handleRequest(response: AxiosResponse, isChunked: boolean, config: IKvHttpRequest): IKvHttpResponse;
|
|
16
10
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpAdapter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const js_client_sdk_1 = require("@kelvininc/js-client-sdk");
|
|
5
6
|
const rxjs_1 = require("rxjs");
|
|
7
|
+
const qs_1 = tslib_1.__importDefault(require("qs"));
|
|
6
8
|
class HttpAdapter {
|
|
7
9
|
constructor(httpClient) {
|
|
8
10
|
this.httpClient = httpClient;
|
|
@@ -12,13 +14,19 @@ class HttpAdapter {
|
|
|
12
14
|
const { method, url, data, headers, params, mediaType } = requestPayload;
|
|
13
15
|
const isChunked = mediaType === js_client_sdk_1.EKvHttpMediaType.jsonStream;
|
|
14
16
|
const responseType = !mediaType || (mediaType === js_client_sdk_1.EKvHttpMediaType.json) ? 'json' : 'text';
|
|
17
|
+
if (data instanceof FormData) {
|
|
18
|
+
headers['Content-Type'] = 'multipart/form-data';
|
|
19
|
+
}
|
|
15
20
|
let mappedRequestPayload = {
|
|
16
21
|
method,
|
|
17
22
|
url,
|
|
18
23
|
headers,
|
|
19
24
|
data,
|
|
20
25
|
responseType,
|
|
21
|
-
params
|
|
26
|
+
params,
|
|
27
|
+
paramsSerializer: (paramsToSerialize) => {
|
|
28
|
+
return qs_1.default.stringify(paramsToSerialize, { arrayFormat: 'comma' });
|
|
29
|
+
}
|
|
22
30
|
};
|
|
23
31
|
const requestInstance$ = new rxjs_1.Subject();
|
|
24
32
|
if ((_a = requestPayload.options) === null || _a === void 0 ? void 0 : _a.reportProgress) {
|
|
@@ -47,12 +55,13 @@ class HttpAdapter {
|
|
|
47
55
|
return requestInstance$;
|
|
48
56
|
}
|
|
49
57
|
handleError(err, config) {
|
|
50
|
-
var _a;
|
|
58
|
+
var _a, _b;
|
|
51
59
|
const error = err
|
|
52
60
|
? {
|
|
53
|
-
|
|
61
|
+
type: js_client_sdk_1.EKvHttpResponseType.Response,
|
|
62
|
+
status: (_a = err.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
54
63
|
statusText: err.message,
|
|
55
|
-
headers: (
|
|
64
|
+
headers: (_b = err.response) === null || _b === void 0 ? void 0 : _b.headers,
|
|
56
65
|
config,
|
|
57
66
|
httpResponse: err.response
|
|
58
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-adapter.js","sourceRoot":"","sources":["../../../src/adapters/http-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-adapter.js","sourceRoot":"","sources":["../../../src/adapters/http-adapter.ts"],"names":[],"mappings":";;;;AAAA,4DAAkI;AAElI,+BAA2C;AAC3C,oDAAoB;AAEpB,MAAa,WAAW;IAEvB,YAAoB,UAAyB;QAAzB,eAAU,GAAV,UAAU,CAAe;IAAI,CAAC;IAElD,OAAO,CAAC,cAA8B;;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC;QACzE,MAAM,SAAS,GAAG,SAAS,KAAK,gCAAgB,CAAC,UAAU,CAAC;QAC5D,MAAM,YAAY,GAAG,CAAC,SAAS,IAAI,CAAC,SAAS,KAAK,gCAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QAE3F,IAAI,IAAI,YAAY,QAAQ,EAAE;YAC7B,OAAO,CAAC,cAAc,CAAC,GAAG,qBAAqB,CAAC;SAChD;QAED,IAAI,oBAAo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AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\nimport { Observable, Subject } from 'rxjs';\nimport qs from 'qs';\n\nexport class HttpAdapter implements IKvHttpAdapter {\n\n\tconstructor(private httpClient: AxiosInstance) { }\n\n\trequest(requestPayload: IKvHttpRequest): Observable<IKvHttpResponse> {\n\t\tconst { method, url, data, headers, params, mediaType } = requestPayload;\n\t\tconst isChunked = mediaType === EKvHttpMediaType.jsonStream;\n\t\tconst responseType = !mediaType || (mediaType === EKvHttpMediaType.json) ? 'json' : 'text';\n\n\t\tif (data instanceof FormData) {\n\t\t\theaders['Content-Type'] = 'multipart/form-data';\n\t\t}\n\n\t\tlet mappedRequestPayload: AxiosRequestConfig = {\n\t\t\tmethod,\n\t\t\turl,\n\t\t\theaders,\n\t\t\tdata,\n\t\t\tresponseType,\n\t\t\tparams,\n\t\t\tparamsSerializer: (paramsToSerialize) => {\n\t\t\t\treturn qs.stringify(paramsToSerialize, { arrayFormat: 'comma' });\n\t\t\t}\n\t\t};\n\n\t\tconst requestInstance$ = new Subject<IKvHttpResponse>();\n\t\tif (requestPayload.options?.reportProgress) {\n\t\t\tmappedRequestPayload = {\n\t\t\t\t...mappedRequestPayload,\n\t\t\t\tonDownloadProgress: (progress) => {\n\t\t\t\t\trequestInstance$.next({\n\t\t\t\t\t\thttpResponse: progress,\n\t\t\t\t\t\ttype: EKvHttpResponseType.DownloadProgress,\n\t\t\t\t\t\tconfig: requestPayload\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tonUploadProgress: (progress) => {\n\t\t\t\t\trequestInstance$.next({\n\t\t\t\t\t\thttpResponse: progress,\n\t\t\t\t\t\ttype: EKvHttpResponseType.UploadProgress,\n\t\t\t\t\t\tconfig: requestPayload\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tthis.httpClient.request(mappedRequestPayload)\n\t\t\t.then((response: AxiosResponse) => {\n\t\t\t\trequestInstance$.next(this.handleRequest(response, isChunked, requestPayload));\n\t\t\t\trequestInstance$.complete();\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\trequestInstance$.error(this.handleError(error, requestPayload));\n\t\t\t});\n\t\treturn requestInstance$;\n\t}\n\n\thandleError(err: AxiosError, config: IKvHttpRequest): IKvHttpResponse | AxiosError {\n\t\tconst error = err\n\t\t\t? {\n\t\t\t\ttype: EKvHttpResponseType.Response,\n\t\t\t\tstatus: err.response?.status,\n\t\t\t\tstatusText: err.message,\n\t\t\t\theaders: err.response?.headers,\n\t\t\t\tconfig,\n\t\t\t\thttpResponse: err.response\n\t\t\t}\n\t\t\t: err;\n\n\t\treturn error;\n\t}\n\n\thandleRequest(response: AxiosResponse, isChunked: boolean, config: IKvHttpRequest): IKvHttpResponse {\n\t\tconst { data, status, statusText, headers } = response;\n\t\tlet bodyParsed = data;\n\t\t/**\n\t\t * typeof bodyParsed == 'string' fixes a bug when the stream\n\t\t * comes with only one array the axios framework parses it automatically\n\t\t */\n\t\tif (isChunked && typeof bodyParsed === 'string') {\n\t\t\ttry {\n\t\t\t\tbodyParsed = bodyParsed ? JSON.parse(data.replace(/\\]\\n\\[/g, ',')) : [];\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Error during parsing chunk data');\n\t\t\t\tbodyParsed = [];\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\ttype: EKvHttpResponseType.Response,\n\t\t\tbody: bodyParsed,\n\t\t\tstatus,\n\t\t\tstatusText,\n\t\t\theaders,\n\t\t\tconfig,\n\t\t\thttpResponse: event\n\t\t};\n\t}\n}\n"]}
|
|
@@ -5,12 +5,6 @@ export declare class HttpAdapter implements IKvHttpAdapter {
|
|
|
5
5
|
private httpClient;
|
|
6
6
|
constructor(httpClient: AxiosInstance);
|
|
7
7
|
request(requestPayload: IKvHttpRequest): Observable<IKvHttpResponse>;
|
|
8
|
-
handleError(err: AxiosError, config: IKvHttpRequest):
|
|
9
|
-
status: string;
|
|
10
|
-
statusText: string;
|
|
11
|
-
headers: any;
|
|
12
|
-
config: IKvHttpRequest;
|
|
13
|
-
httpResponse: AxiosResponse<any>;
|
|
14
|
-
};
|
|
8
|
+
handleError(err: AxiosError, config: IKvHttpRequest): IKvHttpResponse | AxiosError;
|
|
15
9
|
handleRequest(response: AxiosResponse, isChunked: boolean, config: IKvHttpRequest): IKvHttpResponse;
|
|
16
10
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EKvHttpMediaType, EKvHttpResponseType } from '@kelvininc/js-client-sdk';
|
|
2
2
|
import { Subject } from 'rxjs';
|
|
3
|
+
import qs from 'qs';
|
|
3
4
|
export class HttpAdapter {
|
|
4
5
|
constructor(httpClient) {
|
|
5
6
|
this.httpClient = httpClient;
|
|
@@ -9,13 +10,19 @@ export class HttpAdapter {
|
|
|
9
10
|
const { method, url, data, headers, params, mediaType } = requestPayload;
|
|
10
11
|
const isChunked = mediaType === EKvHttpMediaType.jsonStream;
|
|
11
12
|
const responseType = !mediaType || (mediaType === EKvHttpMediaType.json) ? 'json' : 'text';
|
|
13
|
+
if (data instanceof FormData) {
|
|
14
|
+
headers['Content-Type'] = 'multipart/form-data';
|
|
15
|
+
}
|
|
12
16
|
let mappedRequestPayload = {
|
|
13
17
|
method,
|
|
14
18
|
url,
|
|
15
19
|
headers,
|
|
16
20
|
data,
|
|
17
21
|
responseType,
|
|
18
|
-
params
|
|
22
|
+
params,
|
|
23
|
+
paramsSerializer: (paramsToSerialize) => {
|
|
24
|
+
return qs.stringify(paramsToSerialize, { arrayFormat: 'comma' });
|
|
25
|
+
}
|
|
19
26
|
};
|
|
20
27
|
const requestInstance$ = new Subject();
|
|
21
28
|
if ((_a = requestPayload.options) === null || _a === void 0 ? void 0 : _a.reportProgress) {
|
|
@@ -44,12 +51,13 @@ export class HttpAdapter {
|
|
|
44
51
|
return requestInstance$;
|
|
45
52
|
}
|
|
46
53
|
handleError(err, config) {
|
|
47
|
-
var _a;
|
|
54
|
+
var _a, _b;
|
|
48
55
|
const error = err
|
|
49
56
|
? {
|
|
50
|
-
|
|
57
|
+
type: EKvHttpResponseType.Response,
|
|
58
|
+
status: (_a = err.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
51
59
|
statusText: err.message,
|
|
52
|
-
headers: (
|
|
60
|
+
headers: (_b = err.response) === null || _b === void 0 ? void 0 : _b.headers,
|
|
53
61
|
config,
|
|
54
62
|
httpResponse: err.response
|
|
55
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-adapter.js","sourceRoot":"","sources":["../../../src/adapters/http-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAmD,MAAM,0BAA0B,CAAC;AAElI,OAAO,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"http-adapter.js","sourceRoot":"","sources":["../../../src/adapters/http-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAmD,MAAM,0BAA0B,CAAC;AAElI,OAAO,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,OAAO,WAAW;IAEvB,YAAoB,UAAyB;QAAzB,eAAU,GAAV,UAAU,CAAe;IAAI,CAAC;IAElD,OAAO,CAAC,cAA8B;;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC;QACzE,MAAM,SAAS,GAAG,SAAS,KAAK,gBAAgB,CAAC,UAAU,CAAC;QAC5D,MAAM,YAAY,GAAG,CAAC,SAAS,IAAI,CAAC,SAAS,KAAK,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QAE3F,IAAI,IAAI,YAAY,QAAQ,EAAE;YAC7B,OAAO,CAAC,cAAc,CAAC,GAAG,q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vininc/js-client-sdk';\nimport { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\nimport { Observable, Subject } from 'rxjs';\nimport qs from 'qs';\n\nexport class HttpAdapter implements IKvHttpAdapter {\n\n\tconstructor(private httpClient: AxiosInstance) { }\n\n\trequest(requestPayload: IKvHttpRequest): Observable<IKvHttpResponse> {\n\t\tconst { method, url, data, headers, params, mediaType } = requestPayload;\n\t\tconst isChunked = mediaType === EKvHttpMediaType.jsonStream;\n\t\tconst responseType = !mediaType || (mediaType === EKvHttpMediaType.json) ? 'json' : 'text';\n\n\t\tif (data instanceof FormData) {\n\t\t\theaders['Content-Type'] = 'multipart/form-data';\n\t\t}\n\n\t\tlet mappedRequestPayload: AxiosRequestConfig = {\n\t\t\tmethod,\n\t\t\turl,\n\t\t\theaders,\n\t\t\tdata,\n\t\t\tresponseType,\n\t\t\tparams,\n\t\t\tparamsSerializer: (paramsToSerialize) => {\n\t\t\t\treturn qs.stringify(paramsToSerialize, { arrayFormat: 'comma' });\n\t\t\t}\n\t\t};\n\n\t\tconst requestInstance$ = new Subject<IKvHttpResponse>();\n\t\tif (requestPayload.options?.reportProgress) {\n\t\t\tmappedRequestPayload = {\n\t\t\t\t...mappedRequestPayload,\n\t\t\t\tonDownloadProgress: (progress) => {\n\t\t\t\t\trequestInstance$.next({\n\t\t\t\t\t\thttpResponse: progress,\n\t\t\t\t\t\ttype: EKvHttpResponseType.DownloadProgress,\n\t\t\t\t\t\tconfig: requestPayload\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tonUploadProgress: (progress) => {\n\t\t\t\t\trequestInstance$.next({\n\t\t\t\t\t\thttpResponse: progress,\n\t\t\t\t\t\ttype: EKvHttpResponseType.UploadProgress,\n\t\t\t\t\t\tconfig: requestPayload\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tthis.httpClient.request(mappedRequestPayload)\n\t\t\t.then((response: AxiosResponse) => {\n\t\t\t\trequestInstance$.next(this.handleRequest(response, isChunked, requestPayload));\n\t\t\t\trequestInstance$.complete();\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\trequestInstance$.error(this.handleError(error, requestPayload));\n\t\t\t});\n\t\treturn requestInstance$;\n\t}\n\n\thandleError(err: AxiosError, config: IKvHttpRequest): IKvHttpResponse | AxiosError {\n\t\tconst error = err\n\t\t\t? {\n\t\t\t\ttype: EKvHttpResponseType.Response,\n\t\t\t\tstatus: err.response?.status,\n\t\t\t\tstatusText: err.message,\n\t\t\t\theaders: err.response?.headers,\n\t\t\t\tconfig,\n\t\t\t\thttpResponse: err.response\n\t\t\t}\n\t\t\t: err;\n\n\t\treturn error;\n\t}\n\n\thandleRequest(response: AxiosResponse, isChunked: boolean, config: IKvHttpRequest): IKvHttpResponse {\n\t\tconst { data, status, statusText, headers } = response;\n\t\tlet bodyParsed = data;\n\t\t/**\n\t\t * typeof bodyParsed == 'string' fixes a bug when the stream\n\t\t * comes with only one array the axios framework parses it automatically\n\t\t */\n\t\tif (isChunked && typeof bodyParsed === 'string') {\n\t\t\ttry {\n\t\t\t\tbodyParsed = bodyParsed ? JSON.parse(data.replace(/\\]\\n\\[/g, ',')) : [];\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Error during parsing chunk data');\n\t\t\t\tbodyParsed = [];\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\ttype: EKvHttpResponseType.Response,\n\t\t\tbody: bodyParsed,\n\t\t\tstatus,\n\t\t\tstatusText,\n\t\t\theaders,\n\t\t\tconfig,\n\t\t\thttpResponse: event\n\t\t};\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kelvininc/web-client-sdk",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"description": "Kelvin SDK Client for modern frontend Javascript frameworks, like Vue or React",
|
|
5
5
|
"homepage": "https://docs.kelvininc.com",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@kelvininc/js-client-sdk": "^7.
|
|
34
|
+
"@kelvininc/js-client-sdk": "^7.8.0",
|
|
35
|
+
"qs": "6.10.3"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/axios": "^0.14.0",
|
|
@@ -41,8 +42,8 @@
|
|
|
41
42
|
"typescript": "^4.1.5"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"axios": "^0.
|
|
45
|
+
"axios": "^0.27.2",
|
|
45
46
|
"rxjs": "~6.6.7"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "7e49a7220ddeae6a5f856d19c59f78996554d540"
|
|
48
49
|
}
|