@odata2ts/http-client-axios 0.7.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 +98 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/lib/AxiosClient.d.ts +26 -0
- package/lib/AxiosClient.js +123 -0
- package/lib/AxiosClient.js.map +1 -0
- package/lib/AxiosClientError.d.ts +6 -0
- package/lib/AxiosClientError.js +13 -0
- package/lib/AxiosClientError.js.map +1 -0
- package/lib/AxiosRequestConfig.d.ts +11 -0
- package/lib/AxiosRequestConfig.js +27 -0
- package/lib/AxiosRequestConfig.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/package.json +51 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.7.0 (2023-06-03)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **axios:** take over axios-odata-client as http-client-axios ([#1](https://github.com/odata2ts/http-client/issues/1)) ([d679f60](https://github.com/odata2ts/http-client/commit/d679f60087adfdefa00f2a4860bed77ca9b15654))
|
|
11
|
+
* switch to http-client-api ([52d1b86](https://github.com/odata2ts/http-client/commit/52d1b868ee82dbaf45486da6b22fdcf4c773dfb8))
|
|
12
|
+
* switch to http-client-api ([5a6da23](https://github.com/odata2ts/http-client/commit/5a6da23053b3ea5adb866bb7e30b469f1b8ed260))
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **axios:** new name and axios becomes peer dependency
|
|
17
|
+
|
|
18
|
+
# [0.6.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.5.3...@odata2ts/axios-odata-client@0.6.0) (2023-04-20)
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* better errors for jquery and axios odata clients ([#139](https://github.com/odata2ts/odata2ts/issues/139)) ([bb74514](https://github.com/odata2ts/odata2ts/commit/bb745144fb37235ad9864ab78eebbecf1d69107c))
|
|
23
|
+
|
|
24
|
+
## [0.5.3](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.5.2...@odata2ts/axios-odata-client@0.5.3) (2023-04-08)
|
|
25
|
+
|
|
26
|
+
**Note:** Version bump only for package @odata2ts/axios-odata-client
|
|
27
|
+
|
|
28
|
+
## [0.5.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.5.1...@odata2ts/axios-odata-client@0.5.2) (2023-02-03)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @odata2ts/axios-odata-client
|
|
31
|
+
|
|
32
|
+
## [0.5.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.5.0...@odata2ts/axios-odata-client@0.5.1) (2023-01-07)
|
|
33
|
+
|
|
34
|
+
**Note:** Version bump only for package @odata2ts/axios-odata-client
|
|
35
|
+
|
|
36
|
+
# [0.5.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.4.0...@odata2ts/axios-odata-client@0.5.0) (2023-01-05)
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* **axios-odata-client:** default error message retriever ([#82](https://github.com/odata2ts/odata2ts/issues/82)) ([11b7b61](https://github.com/odata2ts/odata2ts/commit/11b7b6171291ba78c2e2b4c7ab39a6c425d02cf1))
|
|
41
|
+
|
|
42
|
+
* **axios-odata-client:** MERGE implementation for V2 ([#83](https://github.com/odata2ts/odata2ts/issues/83)) ([097005f](https://github.com/odata2ts/odata2ts/commit/097005fda1f4008c1fe3ea71f177697867e761fe))
|
|
43
|
+
|
|
44
|
+
### BREAKING CHANGES
|
|
45
|
+
|
|
46
|
+
* **axios-odata-client:** errorMessageRetriever is not part of the constructor signature anymore; use the setter if you want to apply a custom error message retriever
|
|
47
|
+
|
|
48
|
+
# [0.4.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.2.3...@odata2ts/axios-odata-client@0.4.0) (2022-12-18)
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* **odata-client-api:** dynamic response data model for put and patch ([b6d9a7d](https://github.com/odata2ts/odata2ts/commit/b6d9a7de45b39106693515c6e2b5490112547ae4))
|
|
53
|
+
|
|
54
|
+
### BREAKING CHANGES
|
|
55
|
+
|
|
56
|
+
* **odata-client-api:** put and patch allow for response values now => OData v4 specifies that either void or the model representation might be returned (void is more usual though)
|
|
57
|
+
|
|
58
|
+
# [0.3.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.2.3...@odata2ts/axios-odata-client@0.3.0) (2022-12-18)
|
|
59
|
+
|
|
60
|
+
### Features
|
|
61
|
+
|
|
62
|
+
* **odata-client-api:** dynamic response data model for put and patch ([b6d9a7d](https://github.com/odata2ts/odata2ts/commit/b6d9a7de45b39106693515c6e2b5490112547ae4))
|
|
63
|
+
|
|
64
|
+
### BREAKING CHANGES
|
|
65
|
+
|
|
66
|
+
* **odata-client-api:** put and patch allow for response values now => OData v4 specifies that either void or the model representation might be returned (void is more usual though)
|
|
67
|
+
|
|
68
|
+
## [0.2.3](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.2.2...@odata2ts/axios-odata-client@0.2.3) (2022-09-08)
|
|
69
|
+
|
|
70
|
+
**Note:** Version bump only for package @odata2ts/axios-odata-client
|
|
71
|
+
|
|
72
|
+
## [0.2.2](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.2.1...@odata2ts/axios-odata-client@0.2.2) (2022-08-25)
|
|
73
|
+
|
|
74
|
+
### Bug Fixes
|
|
75
|
+
|
|
76
|
+
* **axios-odata-client:** export everything from AxiosODataClient ([#55](https://github.com/odata2ts/odata2ts/issues/55)) ([b43e8f8](https://github.com/odata2ts/odata2ts/commit/b43e8f88b54605edd75ced95fd09b84267c52716))
|
|
77
|
+
|
|
78
|
+
## [0.2.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.2.0...@odata2ts/axios-odata-client@0.2.1) (2022-07-11)
|
|
79
|
+
|
|
80
|
+
**Note:** Version bump only for package @odata2ts/axios-odata-client
|
|
81
|
+
|
|
82
|
+
# [0.2.0](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.1.1...@odata2ts/axios-odata-client@0.2.0) (2022-07-06)
|
|
83
|
+
|
|
84
|
+
### Features
|
|
85
|
+
|
|
86
|
+
* add option to enable automatic csrf token handling ([#32](https://github.com/odata2ts/odata2ts/issues/32)) ([cf4b8c6](https://github.com/odata2ts/odata2ts/commit/cf4b8c60f02ef1fdf7af267e61791e4b7d94fb3e))
|
|
87
|
+
|
|
88
|
+
## [0.1.1](https://github.com/odata2ts/odata2ts/compare/@odata2ts/axios-odata-client@0.1.0...@odata2ts/axios-odata-client@0.1.1) (2022-06-30)
|
|
89
|
+
|
|
90
|
+
### Bug Fixes
|
|
91
|
+
|
|
92
|
+
* add prebulish script to guarantee building before publishing ([b6986db](https://github.com/odata2ts/odata2ts/commit/b6986dbdb258b7b3cb8f36ab52ae1ff7b093f7dc))
|
|
93
|
+
|
|
94
|
+
# 0.1.0 (2022-06-02)
|
|
95
|
+
|
|
96
|
+
### Features
|
|
97
|
+
|
|
98
|
+
* **axios-odata-client:** introduce new module ([ea5684f](https://github.com/odata2ts/odata2ts/commit/ea5684f1f07a7b753e7ef587f41fbc450578497a))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 odata2ts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@odata2ts/http-client-axios)
|
|
2
|
+
|
|
3
|
+
# Axios HTTP Client
|
|
4
|
+
|
|
5
|
+
The **Axios HTTP Client** uses - as its name suggests - [axios](https://github.com/axios/axios) for realizing
|
|
6
|
+
the HTTP communication for [odata2ts](https://github.com/odata2ts/odata2ts).
|
|
7
|
+
|
|
8
|
+
It supports:
|
|
9
|
+
|
|
10
|
+
- request configuration
|
|
11
|
+
- automatic CSRF token handling
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Install package `@odata2ts/http-client-axios` as runtime dependency:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save @odata2ts/http-client-axios
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
s
|
|
22
|
+
|
|
23
|
+
## Documentation
|
|
24
|
+
|
|
25
|
+
[Axios HTTP Client Documentation](https://odata2ts.github.io/docs/odata-client/http-client/axios)
|
|
26
|
+
|
|
27
|
+
Main documentation for the odata2ts eco system:
|
|
28
|
+
[https://odata2ts.github.io](https://odata2ts.github.io/)
|
|
29
|
+
|
|
30
|
+
## Tests
|
|
31
|
+
|
|
32
|
+
See folder [test](https://github.com/odata2ts/http-client/tree/main/packages/axios/test)
|
|
33
|
+
for unit tests.
|
|
34
|
+
|
|
35
|
+
See folder [int-test](https://github.com/odata2ts/http-client/tree/main/packages/axios/int-test) for
|
|
36
|
+
integration tests.
|
|
37
|
+
|
|
38
|
+
## Support, Feedback, Contributing
|
|
39
|
+
|
|
40
|
+
This project is open to feature requests, suggestions, bug reports, usage questions etc.
|
|
41
|
+
via [GitHub issues](https://github.com/odata2ts/http-client/issues).
|
|
42
|
+
|
|
43
|
+
Contributions and feedback are encouraged and always welcome.
|
|
44
|
+
|
|
45
|
+
See the [contribution guidelines](https://github.com/odata2ts/http-client/blob/main/CONTRIBUTING.md) for further information.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT - see [License](./LICENSE).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HttpResponseModel, ODataHttpClient } from "@odata2ts/http-client-api";
|
|
2
|
+
import { AxiosRequestConfig } from "./AxiosRequestConfig";
|
|
3
|
+
export type ErrorMessageRetriever<ResponseType = any> = (error: any) => string | null | undefined;
|
|
4
|
+
export interface ClientOptions {
|
|
5
|
+
useCsrfProtection?: boolean;
|
|
6
|
+
csrfTokenFetchUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_ERROR_MESSAGE = "No error message!";
|
|
9
|
+
export declare const getV2OrV4ErrorMessage: ErrorMessageRetriever;
|
|
10
|
+
export declare class AxiosClient implements ODataHttpClient<AxiosRequestConfig> {
|
|
11
|
+
private clientOptions?;
|
|
12
|
+
private readonly client;
|
|
13
|
+
private csrfToken;
|
|
14
|
+
private getErrorMessage;
|
|
15
|
+
constructor(config?: AxiosRequestConfig, clientOptions?: ClientOptions | undefined);
|
|
16
|
+
setErrorMessageRetriever<T = any>(getErrorMsg: ErrorMessageRetriever<T>): void;
|
|
17
|
+
private setupSecurityToken;
|
|
18
|
+
private fetchSecurityToken;
|
|
19
|
+
private sendRequest;
|
|
20
|
+
post<ResponseModel>(url: string, data: any, requestConfig?: AxiosRequestConfig): Promise<HttpResponseModel<ResponseModel>>;
|
|
21
|
+
get<ResponseModel>(url: string, requestConfig?: AxiosRequestConfig): Promise<HttpResponseModel<ResponseModel>>;
|
|
22
|
+
put<ResponseModel>(url: string, data: any, requestConfig?: AxiosRequestConfig): Promise<HttpResponseModel<ResponseModel>>;
|
|
23
|
+
patch<ResponseModel>(url: string, data: any, requestConfig?: AxiosRequestConfig): Promise<HttpResponseModel<ResponseModel>>;
|
|
24
|
+
merge<ResponseModel>(url: string, data: any, requestConfig?: AxiosRequestConfig): Promise<HttpResponseModel<ResponseModel>>;
|
|
25
|
+
delete(url: string, requestConfig?: AxiosRequestConfig): Promise<HttpResponseModel<void>>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AxiosClient = exports.getV2OrV4ErrorMessage = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const AxiosClientError_1 = require("./AxiosClientError");
|
|
7
|
+
const AxiosRequestConfig_1 = require("./AxiosRequestConfig");
|
|
8
|
+
exports.DEFAULT_ERROR_MESSAGE = "No error message!";
|
|
9
|
+
const FAILURE_MISSING_CSRF_URL = "When automatic CSRF token handling is activated, the URL must be supplied via attribute [csrfTokenFetchUrl]!";
|
|
10
|
+
const FAILURE_NO_RESPONSE = "No response from server! Failure: ";
|
|
11
|
+
const FAILURE_NO_REQUEST = "No request was sent! Failure: ";
|
|
12
|
+
const FAILURE_RESPONSE_MESSAGE = "OData server responded with error: ";
|
|
13
|
+
const FAILURE_AXIOS = "Fatal Axios failure: ";
|
|
14
|
+
function buildErrorMessage(prefix, error) {
|
|
15
|
+
const msg = typeof error === "string" ? error : error === null || error === void 0 ? void 0 : error.message;
|
|
16
|
+
return prefix + (msg || exports.DEFAULT_ERROR_MESSAGE);
|
|
17
|
+
}
|
|
18
|
+
const getV2OrV4ErrorMessage = (responseData) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const eMsg = (_a = responseData === null || responseData === void 0 ? void 0 : responseData.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
21
|
+
return typeof (eMsg === null || eMsg === void 0 ? void 0 : eMsg.value) === "string" ? eMsg.value : eMsg;
|
|
22
|
+
};
|
|
23
|
+
exports.getV2OrV4ErrorMessage = getV2OrV4ErrorMessage;
|
|
24
|
+
class AxiosClient {
|
|
25
|
+
constructor(config, clientOptions) {
|
|
26
|
+
var _a;
|
|
27
|
+
this.clientOptions = clientOptions;
|
|
28
|
+
this.getErrorMessage = exports.getV2OrV4ErrorMessage;
|
|
29
|
+
this.client = axios_1.default.create((0, AxiosRequestConfig_1.getDefaultConfig)(config));
|
|
30
|
+
if (clientOptions && clientOptions.useCsrfProtection && !((_a = clientOptions.csrfTokenFetchUrl) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
31
|
+
throw new Error(FAILURE_MISSING_CSRF_URL);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
setErrorMessageRetriever(getErrorMsg) {
|
|
35
|
+
this.getErrorMessage = getErrorMsg;
|
|
36
|
+
}
|
|
37
|
+
setupSecurityToken() {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (!this.csrfToken) {
|
|
40
|
+
this.csrfToken = yield this.fetchSecurityToken();
|
|
41
|
+
}
|
|
42
|
+
return this.csrfToken;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
fetchSecurityToken() {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const fetchUrl = this.clientOptions.csrfTokenFetchUrl;
|
|
48
|
+
const response = yield this.get(fetchUrl, { headers: { "x-csrf-token": "Fetch" } });
|
|
49
|
+
return response.headers["x-csrf-token"];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
sendRequest(config) {
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (typeof config.url !== "string") {
|
|
56
|
+
throw new Error("Value for URL must be provided!");
|
|
57
|
+
}
|
|
58
|
+
// setup automatic CSRF token handling
|
|
59
|
+
if (((_a = this.clientOptions) === null || _a === void 0 ? void 0 : _a.useCsrfProtection) &&
|
|
60
|
+
["POST", "PUT", "PATCH", "DELETE"].includes(config.method.toUpperCase())) {
|
|
61
|
+
const csrfToken = yield this.setupSecurityToken();
|
|
62
|
+
if (typeof csrfToken === "string") {
|
|
63
|
+
if (!config.headers) {
|
|
64
|
+
config.headers = {};
|
|
65
|
+
}
|
|
66
|
+
config.headers["x-csrf-token"] = csrfToken;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
return yield this.client.request(config);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.isAxiosError) {
|
|
74
|
+
const axiosError = error;
|
|
75
|
+
// automatic CSRF token handling
|
|
76
|
+
// csrf token expired, let's reset it and perform the original request again
|
|
77
|
+
if (((_b = this.clientOptions) === null || _b === void 0 ? void 0 : _b.useCsrfProtection) &&
|
|
78
|
+
((_c = axiosError.response) === null || _c === void 0 ? void 0 : _c.status) === 403 &&
|
|
79
|
+
axiosError.response.headers["x-csrf-token"] === "Required") {
|
|
80
|
+
this.csrfToken = undefined;
|
|
81
|
+
return this.sendRequest(config);
|
|
82
|
+
}
|
|
83
|
+
// regular failure handling
|
|
84
|
+
if (axiosError.response) {
|
|
85
|
+
const msg = buildErrorMessage(FAILURE_RESPONSE_MESSAGE, this.getErrorMessage(axiosError.response.data));
|
|
86
|
+
throw new AxiosClientError_1.AxiosClientError(msg, axiosError.response.status, axiosError);
|
|
87
|
+
}
|
|
88
|
+
// fatal failure without response
|
|
89
|
+
else {
|
|
90
|
+
throw new AxiosClientError_1.AxiosClientError(buildErrorMessage(axiosError.request ? FAILURE_NO_RESPONSE : FAILURE_NO_REQUEST, axiosError), undefined, axiosError);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// not an Axios error
|
|
94
|
+
throw new AxiosClientError_1.AxiosClientError(buildErrorMessage(FAILURE_AXIOS, error), undefined, error);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
post(url, data, requestConfig) {
|
|
99
|
+
return this.sendRequest(Object.assign(Object.assign({}, requestConfig), { url, data, method: "POST" }));
|
|
100
|
+
}
|
|
101
|
+
get(url, requestConfig) {
|
|
102
|
+
return this.sendRequest(Object.assign(Object.assign({}, requestConfig), { url, method: "GET" }));
|
|
103
|
+
}
|
|
104
|
+
put(url, data, requestConfig) {
|
|
105
|
+
return this.sendRequest(Object.assign(Object.assign({}, requestConfig), { url, data, method: "PUT" }));
|
|
106
|
+
}
|
|
107
|
+
patch(url, data, requestConfig) {
|
|
108
|
+
return this.sendRequest(Object.assign(Object.assign({}, requestConfig), { url, data, method: "PATCH" }));
|
|
109
|
+
}
|
|
110
|
+
merge(url, data, requestConfig) {
|
|
111
|
+
return this.sendRequest((0, AxiosRequestConfig_1.mergeConfig)(requestConfig, {
|
|
112
|
+
url,
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: { "X-Http-Method": "MERGE" },
|
|
115
|
+
data,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
delete(url, requestConfig) {
|
|
119
|
+
return this.sendRequest(Object.assign(Object.assign({}, requestConfig), { url, method: "DELETE" }));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.AxiosClient = AxiosClient;
|
|
123
|
+
//# sourceMappingURL=AxiosClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxiosClient.js","sourceRoot":"","sources":["../src/AxiosClient.ts"],"names":[],"mappings":";;;;AACA,0DAAsG;AAEtG,yDAAsD;AACtD,6DAAgH;AASnG,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,wBAAwB,GAC5B,8GAA8G,CAAC;AACjH,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AACjE,MAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAC5D,MAAM,wBAAwB,GAAG,qCAAqC,CAAC;AACvE,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,SAAS,iBAAiB,CAAC,MAAc,EAAE,KAAU;IACnD,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,KAAe,aAAf,KAAK,uBAAL,KAAK,CAAY,OAAO,CAAC;IAC1E,OAAO,MAAM,GAAG,CAAC,GAAG,IAAI,6BAAqB,CAAC,CAAC;AACjD,CAAC;AAEM,MAAM,qBAAqB,GAA0B,CAAC,YAAiB,EAAsB,EAAE;;IACpG,MAAM,IAAI,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,0CAAE,OAAO,CAAC;IAC1C,OAAO,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7D,CAAC,CAAC;AAHW,QAAA,qBAAqB,yBAGhC;AAEF,MAAa,WAAW;IAKtB,YAAY,MAA2B,EAAU,aAA6B;;QAA7B,kBAAa,GAAb,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C","sourcesContent":["import { HttpResponseModel, ODataHttpClient } from \"@odata2ts/http-client-api\";\nimport axios, { AxiosError, AxiosInstance, AxiosRequestConfig as OriginalRequestConfig } from \"axios\";\n\nimport { AxiosClientError } from \"./AxiosClientError\";\nimport { AxiosRequestConfig, InternalRequestConfig, getDefaultConfig, mergeConfig } from \"./AxiosRequestConfig\";\n\nexport type ErrorMessageRetriever<ResponseType = any> = (error: any) => string | null | undefined;\n\nexport interface ClientOptions {\n useCsrfProtection?: boolean;\n csrfTokenFetchUrl?: string;\n}\n\nexport const DEFAULT_ERROR_MESSAGE = \"No error message!\";\nconst FAILURE_MISSING_CSRF_URL =\n \"When automatic CSRF token handling is activated, the URL must be supplied via attribute [csrfTokenFetchUrl]!\";\nconst FAILURE_NO_RESPONSE = \"No response from server! Failure: \";\nconst FAILURE_NO_REQUEST = \"No request was sent! Failure: \";\nconst FAILURE_RESPONSE_MESSAGE = \"OData server responded with error: \";\nconst FAILURE_AXIOS = \"Fatal Axios failure: \";\n\nfunction buildErrorMessage(prefix: string, error: any) {\n const msg = typeof error === \"string\" ? error : (error as Error)?.message;\n return prefix + (msg || DEFAULT_ERROR_MESSAGE);\n}\n\nexport const getV2OrV4ErrorMessage: ErrorMessageRetriever = (responseData: any): string | undefined => {\n const eMsg = responseData?.error?.message;\n return typeof eMsg?.value === \"string\" ? eMsg.value : eMsg;\n};\n\nexport class AxiosClient implements ODataHttpClient<AxiosRequestConfig> {\n private readonly client: AxiosInstance;\n private csrfToken: string | undefined;\n private getErrorMessage: ErrorMessageRetriever = getV2OrV4ErrorMessage;\n\n constructor(config?: AxiosRequestConfig, private clientOptions?: ClientOptions) {\n this.client = axios.create(getDefaultConfig(config));\n\n if (clientOptions && clientOptions.useCsrfProtection && !clientOptions.csrfTokenFetchUrl?.trim()) {\n throw new Error(FAILURE_MISSING_CSRF_URL);\n }\n }\n\n public setErrorMessageRetriever<T = any>(getErrorMsg: ErrorMessageRetriever<T>) {\n this.getErrorMessage = getErrorMsg;\n }\n\n private async setupSecurityToken() {\n if (!this.csrfToken) {\n this.csrfToken = await this.fetchSecurityToken();\n }\n return this.csrfToken;\n }\n\n private async fetchSecurityToken(): Promise<string | undefined> {\n const fetchUrl = this.clientOptions!.csrfTokenFetchUrl!;\n const response = await this.get(fetchUrl, { headers: { \"x-csrf-token\": \"Fetch\" } });\n\n return response.headers[\"x-csrf-token\"];\n }\n\n private async sendRequest<ResponseType>(config: InternalRequestConfig): Promise<HttpResponseModel<ResponseType>> {\n if (typeof config.url !== \"string\") {\n throw new Error(\"Value for URL must be provided!\");\n }\n\n // setup automatic CSRF token handling\n if (\n this.clientOptions?.useCsrfProtection &&\n [\"POST\", \"PUT\", \"PATCH\", \"DELETE\"].includes(config.method!.toUpperCase())\n ) {\n const csrfToken = await this.setupSecurityToken();\n if (typeof csrfToken === \"string\") {\n if (!config.headers) {\n config.headers = {};\n }\n config.headers![\"x-csrf-token\"] = csrfToken;\n }\n }\n\n try {\n return await this.client.request(config as OriginalRequestConfig);\n } catch (error: any) {\n if ((error as AxiosError).isAxiosError) {\n const axiosError = error as AxiosError;\n\n // automatic CSRF token handling\n // csrf token expired, let's reset it and perform the original request again\n if (\n this.clientOptions?.useCsrfProtection &&\n axiosError.response?.status === 403 &&\n axiosError.response.headers[\"x-csrf-token\"] === \"Required\"\n ) {\n this.csrfToken = undefined;\n return this.sendRequest<ResponseType>(config);\n }\n\n // regular failure handling\n if (axiosError.response) {\n const msg = buildErrorMessage(FAILURE_RESPONSE_MESSAGE, this.getErrorMessage(axiosError.response.data));\n throw new AxiosClientError(msg, axiosError.response.status, axiosError);\n }\n // fatal failure without response\n else {\n throw new AxiosClientError(\n buildErrorMessage(axiosError.request ? FAILURE_NO_RESPONSE : FAILURE_NO_REQUEST, axiosError),\n undefined,\n axiosError\n );\n }\n }\n // not an Axios error\n throw new AxiosClientError(buildErrorMessage(FAILURE_AXIOS, error), undefined, error);\n }\n }\n\n public post<ResponseModel>(\n url: string,\n data: any,\n requestConfig?: AxiosRequestConfig\n ): Promise<HttpResponseModel<ResponseModel>> {\n return this.sendRequest({ ...requestConfig, url, data, method: \"POST\" });\n }\n public get<ResponseModel>(\n url: string,\n requestConfig?: AxiosRequestConfig\n ): Promise<HttpResponseModel<ResponseModel>> {\n return this.sendRequest({ ...requestConfig, url, method: \"GET\" });\n }\n public put<ResponseModel>(\n url: string,\n data: any,\n requestConfig?: AxiosRequestConfig\n ): Promise<HttpResponseModel<ResponseModel>> {\n return this.sendRequest({ ...requestConfig, url, data, method: \"PUT\" });\n }\n public patch<ResponseModel>(\n url: string,\n data: any,\n requestConfig?: AxiosRequestConfig\n ): Promise<HttpResponseModel<ResponseModel>> {\n return this.sendRequest({ ...requestConfig, url, data, method: \"PATCH\" });\n }\n public merge<ResponseModel>(\n url: string,\n data: any,\n requestConfig?: AxiosRequestConfig\n ): Promise<HttpResponseModel<ResponseModel>> {\n return this.sendRequest(\n mergeConfig(requestConfig, {\n url,\n method: \"POST\",\n headers: { \"X-Http-Method\": \"MERGE\" },\n data,\n })\n );\n }\n public delete(url: string, requestConfig?: AxiosRequestConfig): Promise<HttpResponseModel<void>> {\n return this.sendRequest({ ...requestConfig, url, method: \"DELETE\" });\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AxiosError } from "axios";
|
|
2
|
+
export declare class AxiosClientError extends Error {
|
|
3
|
+
readonly status: number | undefined;
|
|
4
|
+
readonly cause: Error | AxiosError | undefined;
|
|
5
|
+
constructor(msg: string, status: number | undefined, cause: Error | AxiosError | undefined);
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AxiosClientError = void 0;
|
|
4
|
+
class AxiosClientError extends Error {
|
|
5
|
+
constructor(msg, status, cause) {
|
|
6
|
+
super(msg, { cause });
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.cause = cause;
|
|
9
|
+
this.name = this.constructor.name;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.AxiosClientError = AxiosClientError;
|
|
13
|
+
//# sourceMappingURL=AxiosClientError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxiosClientError.js","sourceRoot":"","sources":["../src/AxiosClientError.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YACE,GAAW,EACK,MAA0B,EAC1B,KAAqC;QAErD,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAHN,WAAM,GAAN,MAAM,CAAoB;QAC1B,UAAK,GAAL,KAAK,CAAgC;QAGrD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AATD,4CASC","sourcesContent":["import type { AxiosError } from \"axios\";\n\nexport class AxiosClientError extends Error {\n constructor(\n msg: string,\n public readonly status: number | undefined,\n public readonly cause: Error | AxiosError | undefined\n ) {\n super(msg, { cause });\n this.name = this.constructor.name;\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CreateAxiosDefaults, AxiosRequestConfig as OriginalRequestConfig } from "axios";
|
|
2
|
+
export interface AxiosRequestConfig extends Omit<OriginalRequestConfig, "method" | "url" | "headers"> {
|
|
3
|
+
headers?: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
export interface InternalRequestConfig extends Omit<OriginalRequestConfig, "headers"> {
|
|
6
|
+
url?: string;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function getDefaultConfig(config?: AxiosRequestConfig | undefined): CreateAxiosDefaults;
|
|
10
|
+
export declare function mergeConfig(): undefined;
|
|
11
|
+
export declare function mergeConfig(...configs: Array<InternalRequestConfig | undefined>): InternalRequestConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeConfig = exports.getDefaultConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const DEFAULT_CONFIG = {
|
|
6
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
7
|
+
};
|
|
8
|
+
function getDefaultConfig(config) {
|
|
9
|
+
return mergeConfig(DEFAULT_CONFIG, config);
|
|
10
|
+
}
|
|
11
|
+
exports.getDefaultConfig = getDefaultConfig;
|
|
12
|
+
function mergeConfig(...configs) {
|
|
13
|
+
if (!configs.length) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return configs
|
|
17
|
+
.filter((c) => !!c)
|
|
18
|
+
.reduce((collector, current) => {
|
|
19
|
+
const { headers } = current, passThrough = tslib_1.__rest(current, ["headers"]);
|
|
20
|
+
if (headers) {
|
|
21
|
+
Object.entries(headers).forEach(([key, val]) => (collector.headers[key] = val));
|
|
22
|
+
}
|
|
23
|
+
return Object.assign(Object.assign({}, collector), passThrough);
|
|
24
|
+
}, { headers: {} });
|
|
25
|
+
}
|
|
26
|
+
exports.mergeConfig = mergeConfig;
|
|
27
|
+
//# sourceMappingURL=AxiosRequestConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxiosRequestConfig.js","sourceRoot":"","sources":["../src/AxiosRequestConfig.ts"],"names":[],"mappings":";;;;AAWA,MAAM,cAAc,GAA0B;IAC5C,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE;CAC5E,CAAC;AAEF,SAAgB,gBAAgB,CAAC,MAAuC;IACtE,OAAO,WAAW,CAAC,cAAc,EAAE,MAA+B,CAAwB,CAAC;AAC7F,CAAC;AAFD,4CAEC;AAID,SAAgB,WAAW,CAAC,GAAG,OAAiD;IAC9E,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C,MAAM,CACL,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;QACrB,MAAM,EAAE,OAAO,KAAqB,OAAO,EAAvB,WAAW,kBAAK,OAAO,EAArC,WAA2B,CAAU,CAAC;QAE5C,IAAI,OAAO,EAAE;YACX,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,OAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SAClF;QACD,uCAAY,SAAS,GAAK,WAAW,EAAG;IAC1C,CAAC,EACD,EAAE,OAAO,EAAE,EAAE,EAAE,CAChB,CAAC;AACN,CAAC;AAlBD,kCAkBC","sourcesContent":["import { CreateAxiosDefaults, AxiosRequestConfig as OriginalRequestConfig } from \"axios\";\n\nexport interface AxiosRequestConfig extends Omit<OriginalRequestConfig, \"method\" | \"url\" | \"headers\"> {\n headers?: Record<string, string>;\n}\n\nexport interface InternalRequestConfig extends Omit<OriginalRequestConfig, \"headers\"> {\n url?: string;\n headers?: Record<string, string>;\n}\n\nconst DEFAULT_CONFIG: InternalRequestConfig = {\n headers: { Accept: \"application/json\", \"Content-Type\": \"application/json\" },\n};\n\nexport function getDefaultConfig(config?: AxiosRequestConfig | undefined): CreateAxiosDefaults {\n return mergeConfig(DEFAULT_CONFIG, config as InternalRequestConfig) as CreateAxiosDefaults;\n}\n\nexport function mergeConfig(): undefined;\nexport function mergeConfig(...configs: Array<InternalRequestConfig | undefined>): InternalRequestConfig;\nexport function mergeConfig(...configs: Array<InternalRequestConfig | undefined>) {\n if (!configs.length) {\n return undefined;\n }\n\n return configs\n .filter((c): c is InternalRequestConfig => !!c)\n .reduce<InternalRequestConfig>(\n (collector, current) => {\n const { headers, ...passThrough } = current;\n\n if (headers) {\n Object.entries(headers).forEach(([key, val]) => (collector.headers![key] = val));\n }\n return { ...collector, ...passThrough };\n },\n { headers: {} }\n );\n}\n"]}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AxiosClientError = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./AxiosClient"), exports);
|
|
6
|
+
var AxiosClientError_1 = require("./AxiosClientError");
|
|
7
|
+
Object.defineProperty(exports, "AxiosClientError", { enumerable: true, get: function () { return AxiosClientError_1.AxiosClientError; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,wDAA8B;AAC9B,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA","sourcesContent":["export * from \"./AxiosClient\";\nexport { AxiosClientError } from \"./AxiosClientError\";\nexport { AxiosRequestConfig } from \"./AxiosRequestConfig\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@odata2ts/http-client-axios",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Axios based odata HTTP client consumable by odata2ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": "git@github.com:odata2ts/http-client.git",
|
|
10
|
+
"author": "texttechne",
|
|
11
|
+
"main": "./lib/index.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "yarn clean && yarn compile",
|
|
14
|
+
"check-circular-deps": "madge ./src --extensions ts --circular",
|
|
15
|
+
"clean": "rimraf lib coverage",
|
|
16
|
+
"compile": "tsc",
|
|
17
|
+
"prepublish": "yarn build",
|
|
18
|
+
"test": "jest --passWithNoTests"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"*.md",
|
|
22
|
+
"lib",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"http client",
|
|
27
|
+
"axios",
|
|
28
|
+
"odata",
|
|
29
|
+
"odata2ts",
|
|
30
|
+
"ts",
|
|
31
|
+
"typescript"
|
|
32
|
+
],
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"axios": "^0.27.0 || ^1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@odata2ts/http-client-api": "^0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/jest": "^27.4.1",
|
|
41
|
+
"@types/node": "^17.0.23",
|
|
42
|
+
"axios": "^1.4.0",
|
|
43
|
+
"jest": "29.5.0",
|
|
44
|
+
"rimraf": "^5.0.1",
|
|
45
|
+
"ts-jest": "^29.1.0",
|
|
46
|
+
"ts-node": "10.9.1",
|
|
47
|
+
"typescript": "5.0.4"
|
|
48
|
+
},
|
|
49
|
+
"types": "./lib/index.d.ts",
|
|
50
|
+
"gitHead": "a93b726286ef9a118fda63b0e7900d6b3e739dd2"
|
|
51
|
+
}
|