hoffmation-base 2.19.5 → 2.19.7
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { DachsClientOptions, KeyListEntityResponse } from '../interfaces';
|
|
3
|
-
import { iFlattenedCompleteResponse } from '../interfaces/iFlattenedCompleteResponse';
|
|
2
|
+
import { DachsClientOptions, iFlattenedCompleteResponse, KeyListEntityResponse } from '../interfaces';
|
|
4
3
|
/**
|
|
5
4
|
* axios HTTP Client Class
|
|
6
5
|
* - with some prepared fetch functions for data
|
|
@@ -11,6 +10,7 @@ import { iFlattenedCompleteResponse } from '../interfaces/iFlattenedCompleteResp
|
|
|
11
10
|
export declare class DachsHttpClient {
|
|
12
11
|
private options;
|
|
13
12
|
private url;
|
|
13
|
+
private axiosInstance;
|
|
14
14
|
constructor(options: DachsClientOptions);
|
|
15
15
|
/**
|
|
16
16
|
* Takes every key and add the key to the get parameter list
|
|
@@ -31,6 +31,8 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
31
31
|
const ReadKeyList_1 = __importDefault(require("./ReadKeyList"));
|
|
32
32
|
const _ = __importStar(require("lodash"));
|
|
33
33
|
const keyTemplates_1 = __importDefault(require("./keyTemplates"));
|
|
34
|
+
const services_1 = require("../../../services");
|
|
35
|
+
const models_1 = require("../../../../models");
|
|
34
36
|
/**
|
|
35
37
|
* axios HTTP Client Class
|
|
36
38
|
* - with some prepared fetch functions for data
|
|
@@ -48,6 +50,19 @@ class DachsHttpClient {
|
|
|
48
50
|
this.options.host = this.options.host.startsWith('http') ? this.options.host : `${protocol}://${this.options.host}`;
|
|
49
51
|
//combine all parameter for url
|
|
50
52
|
this.url = `${this.options.host}:${(_a = this.options.port) !== null && _a !== void 0 ? _a : 8080}`;
|
|
53
|
+
this.axiosInstance = axios_1.default.create({
|
|
54
|
+
auth: {
|
|
55
|
+
username: this.options.username || 'glt',
|
|
56
|
+
password: this.options.password || '',
|
|
57
|
+
},
|
|
58
|
+
baseURL: this.url,
|
|
59
|
+
});
|
|
60
|
+
// Interceptor for error handling
|
|
61
|
+
this.axiosInstance.interceptors.response.use((response) => {
|
|
62
|
+
return response;
|
|
63
|
+
}, (error) => {
|
|
64
|
+
services_1.ServerLogService.writeLog(models_1.LogLevel.Error, `DachsHttpClient: ${error.message}`);
|
|
65
|
+
});
|
|
51
66
|
}
|
|
52
67
|
/**
|
|
53
68
|
* Takes every key and add the key to the get parameter list
|
|
@@ -73,14 +88,8 @@ class DachsHttpClient {
|
|
|
73
88
|
*/
|
|
74
89
|
fetchByKeys(...keys) {
|
|
75
90
|
return new Promise((resolve, reject) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
username: this.options.username || 'glt',
|
|
79
|
-
password: this.options.password || '',
|
|
80
|
-
},
|
|
81
|
-
baseURL: this.url,
|
|
82
|
-
url: `/getKey` + this.urlBuilder(keys),
|
|
83
|
-
})
|
|
91
|
+
this.axiosInstance
|
|
92
|
+
.get(`/getKey` + this.urlBuilder(keys))
|
|
84
93
|
.then((res) => {
|
|
85
94
|
resolve(this.parser(res.data));
|
|
86
95
|
})
|
|
@@ -105,18 +114,10 @@ class DachsHttpClient {
|
|
|
105
114
|
}
|
|
106
115
|
setKeys(data) {
|
|
107
116
|
return new Promise((resolve, reject) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
baseURL: this.url,
|
|
114
|
-
url: `/setKeys`,
|
|
115
|
-
method: 'POST',
|
|
116
|
-
data: Object.entries(data)
|
|
117
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
118
|
-
.join('&'),
|
|
119
|
-
})
|
|
117
|
+
this.axiosInstance
|
|
118
|
+
.post(`/setKeys`, Object.entries(data)
|
|
119
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
120
|
+
.join('&'))
|
|
120
121
|
.then((res) => {
|
|
121
122
|
resolve(res);
|
|
122
123
|
})
|