@kontent-ai/core-sdk 10.1.1 → 10.2.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/dist/cjs/helpers/header.helper.d.ts +13 -13
- package/dist/cjs/helpers/header.helper.js +22 -22
- package/dist/cjs/helpers/headers-helper.d.ts +3 -3
- package/dist/cjs/helpers/headers-helper.js +14 -14
- package/dist/cjs/helpers/index.d.ts +4 -5
- package/dist/cjs/helpers/index.js +20 -21
- package/dist/cjs/helpers/index.js.map +1 -1
- package/dist/cjs/helpers/retry-helper.d.ts +37 -37
- package/dist/cjs/helpers/retry-helper.js +148 -148
- package/dist/cjs/helpers/url.helper.d.ts +10 -10
- package/dist/cjs/helpers/url.helper.js +26 -26
- package/dist/cjs/http/http.debugger.d.ts +6 -6
- package/dist/cjs/http/http.debugger.js +22 -22
- package/dist/cjs/http/http.functions.d.ts +11 -11
- package/dist/cjs/http/http.functions.js +260 -260
- package/dist/cjs/http/http.models.d.ts +73 -73
- package/dist/cjs/http/http.models.js +2 -2
- package/dist/cjs/http/http.service.d.ts +19 -19
- package/dist/cjs/http/http.service.js +56 -56
- package/dist/cjs/http/ihttp.service.d.ts +9 -9
- package/dist/cjs/http/ihttp.service.js +2 -2
- package/dist/cjs/http/index.d.ts +6 -6
- package/dist/cjs/http/index.js +22 -22
- package/dist/cjs/http/test-http.service.d.ts +17 -17
- package/dist/cjs/http/test-http.service.js +44 -44
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +20 -20
- package/dist/cjs/models/index.d.ts +3 -3
- package/dist/cjs/models/index.js +19 -19
- package/dist/cjs/models/isdk-info.d.ts +14 -14
- package/dist/cjs/models/isdk-info.js +2 -2
- package/dist/cjs/models/parameters.d.ts +16 -16
- package/dist/cjs/models/parameters.js +28 -28
- package/dist/cjs/models/parameters.js.map +1 -1
- package/dist/cjs/models/url.models.d.ts +3 -3
- package/dist/cjs/models/url.models.js +2 -2
- package/dist/cjs/sdk-info.generated.d.ts +2 -2
- package/dist/cjs/sdk-info.generated.js +8 -8
- package/dist/es6/helpers/header.helper.d.ts +13 -13
- package/dist/es6/helpers/header.helper.js +18 -18
- package/dist/es6/helpers/headers-helper.d.ts +3 -3
- package/dist/es6/helpers/headers-helper.js +10 -10
- package/dist/es6/helpers/index.d.ts +4 -5
- package/dist/es6/helpers/index.js +4 -5
- package/dist/es6/helpers/index.js.map +1 -1
- package/dist/es6/helpers/retry-helper.d.ts +37 -37
- package/dist/es6/helpers/retry-helper.js +144 -144
- package/dist/es6/helpers/url.helper.d.ts +10 -10
- package/dist/es6/helpers/url.helper.js +22 -22
- package/dist/es6/http/http.debugger.d.ts +6 -6
- package/dist/es6/http/http.debugger.js +18 -18
- package/dist/es6/http/http.functions.d.ts +11 -11
- package/dist/es6/http/http.functions.js +251 -251
- package/dist/es6/http/http.models.d.ts +73 -73
- package/dist/es6/http/http.models.js +1 -1
- package/dist/es6/http/http.service.d.ts +19 -19
- package/dist/es6/http/http.service.js +52 -52
- package/dist/es6/http/ihttp.service.d.ts +9 -9
- package/dist/es6/http/ihttp.service.js +1 -1
- package/dist/es6/http/index.d.ts +6 -6
- package/dist/es6/http/index.js +6 -6
- package/dist/es6/http/test-http.service.d.ts +17 -17
- package/dist/es6/http/test-http.service.js +40 -40
- package/dist/es6/index.d.ts +3 -3
- package/dist/es6/index.js +4 -4
- package/dist/es6/models/index.d.ts +3 -3
- package/dist/es6/models/index.js +3 -3
- package/dist/es6/models/isdk-info.d.ts +14 -14
- package/dist/es6/models/isdk-info.js +1 -1
- package/dist/es6/models/parameters.d.ts +16 -16
- package/dist/es6/models/parameters.js +25 -25
- package/dist/es6/models/url.models.d.ts +3 -3
- package/dist/es6/models/url.models.js +1 -1
- package/dist/es6/sdk-info.generated.d.ts +2 -2
- package/dist/es6/sdk-info.generated.js +5 -5
- package/dist/esnext/helpers/header.helper.d.ts +13 -13
- package/dist/esnext/helpers/header.helper.js +18 -18
- package/dist/esnext/helpers/headers-helper.d.ts +3 -3
- package/dist/esnext/helpers/headers-helper.js +10 -10
- package/dist/esnext/helpers/index.d.ts +4 -5
- package/dist/esnext/helpers/index.js +4 -5
- package/dist/esnext/helpers/index.js.map +1 -1
- package/dist/esnext/helpers/retry-helper.d.ts +37 -37
- package/dist/esnext/helpers/retry-helper.js +144 -144
- package/dist/esnext/helpers/url.helper.d.ts +10 -10
- package/dist/esnext/helpers/url.helper.js +22 -22
- package/dist/esnext/http/http.debugger.d.ts +6 -6
- package/dist/esnext/http/http.debugger.js +18 -18
- package/dist/esnext/http/http.functions.d.ts +11 -11
- package/dist/esnext/http/http.functions.js +251 -251
- package/dist/esnext/http/http.models.d.ts +73 -73
- package/dist/esnext/http/http.models.js +1 -1
- package/dist/esnext/http/http.service.d.ts +19 -19
- package/dist/esnext/http/http.service.js +52 -52
- package/dist/esnext/http/ihttp.service.d.ts +9 -9
- package/dist/esnext/http/ihttp.service.js +1 -1
- package/dist/esnext/http/index.d.ts +6 -6
- package/dist/esnext/http/index.js +6 -6
- package/dist/esnext/http/test-http.service.d.ts +17 -17
- package/dist/esnext/http/test-http.service.js +40 -40
- package/dist/esnext/index.d.ts +3 -3
- package/dist/esnext/index.js +4 -4
- package/dist/esnext/models/index.d.ts +3 -3
- package/dist/esnext/models/index.js +3 -3
- package/dist/esnext/models/isdk-info.d.ts +14 -14
- package/dist/esnext/models/isdk-info.js +1 -1
- package/dist/esnext/models/parameters.d.ts +16 -16
- package/dist/esnext/models/parameters.js +25 -25
- package/dist/esnext/models/url.models.d.ts +3 -3
- package/dist/esnext/models/url.models.js +1 -1
- package/dist/esnext/sdk-info.generated.d.ts +2 -2
- package/dist/esnext/sdk-info.generated.js +5 -5
- package/dist/umd/kontent-core.umd.js +3431 -2740
- package/dist/umd/kontent-core.umd.js.map +1 -1
- package/dist/umd/kontent-core.umd.min.js +1 -1
- package/dist/umd/kontent-core.umd.min.js.map +1 -1
- package/dist/umd/report.json +1 -1
- package/dist/umd/report.min.json +1 -1
- package/dist/umd/stats.json +1185 -8545
- package/dist/umd/stats.min.json +1192 -8684
- package/lib/helpers/index.ts +0 -1
- package/lib/sdk-info.generated.ts +1 -1
- package/package.json +26 -25
- package/dist/cjs/helpers/enum.helper.d.ts +0 -8
- package/dist/cjs/helpers/enum.helper.js +0 -54
- package/dist/cjs/helpers/enum.helper.js.map +0 -1
- package/dist/es6/helpers/enum.helper.d.ts +0 -8
- package/dist/es6/helpers/enum.helper.js +0 -50
- package/dist/es6/helpers/enum.helper.js.map +0 -1
- package/dist/esnext/helpers/enum.helper.d.ts +0 -8
- package/dist/esnext/helpers/enum.helper.js +0 -50
- package/dist/esnext/helpers/enum.helper.js.map +0 -1
- package/lib/helpers/enum.helper.ts +0 -63
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import { extractHeadersFromAxiosResponse } from './headers-helper';
|
|
2
|
-
export class RetryHelper {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.requestCancelledMessagePrefix = 'Request cancelled';
|
|
5
|
-
this.retryAfterHeaderName = 'Retry-After';
|
|
6
|
-
this.defaultRetryStatusCodes = [408, 429, 500, 502, 503, 504];
|
|
7
|
-
this.defaultRetryStrategy = {
|
|
8
|
-
addJitter: true,
|
|
9
|
-
deltaBackoffMs: 1000,
|
|
10
|
-
maxAttempts: 5,
|
|
11
|
-
canRetryError: (error) => this.canRetryErrorDefault(error)
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
getRetryErrorResult(data) {
|
|
15
|
-
var _a, _b, _c;
|
|
16
|
-
if (data.error && data.error.message) {
|
|
17
|
-
if (data.error.message.startsWith(this.requestCancelledMessagePrefix)) {
|
|
18
|
-
// request was cancelled by user, do not retry it
|
|
19
|
-
return {
|
|
20
|
-
canRetry: false,
|
|
21
|
-
retryInMs: 0,
|
|
22
|
-
maxRetries: 0
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const canRetryError = data.retryStrategy.canRetryError
|
|
27
|
-
? data.retryStrategy.canRetryError(data.error)
|
|
28
|
-
: this.defaultRetryStrategy.canRetryError(data.error);
|
|
29
|
-
if (!canRetryError) {
|
|
30
|
-
// request cannot be retried
|
|
31
|
-
return {
|
|
32
|
-
canRetry: false,
|
|
33
|
-
retryInMs: 0,
|
|
34
|
-
maxRetries: 0
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const maxRetries = ((_a = data.retryStrategy.maxAttempts) !== null && _a !== void 0 ? _a : this.defaultRetryStrategy.maxAttempts);
|
|
38
|
-
const maxRetriesReached = data.retryAttempt >= maxRetries;
|
|
39
|
-
if (maxRetriesReached) {
|
|
40
|
-
// request cannot be retried anymore due to maximum attempts
|
|
41
|
-
return {
|
|
42
|
-
canRetry: false,
|
|
43
|
-
retryInMs: 0,
|
|
44
|
-
maxRetries: maxRetries
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
// get wait time
|
|
48
|
-
const retryResult = this.tryGetRetryAfterInMsFromError(data.error);
|
|
49
|
-
if (retryResult) {
|
|
50
|
-
// retry after header was provided
|
|
51
|
-
return {
|
|
52
|
-
canRetry: true,
|
|
53
|
-
retryInMs: retryResult,
|
|
54
|
-
maxRetries: maxRetries
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
// wait time was not provided in header
|
|
58
|
-
const waitTimeMs = this.getNextWaitTimeMs((_b = data.retryStrategy.addJitter) !== null && _b !== void 0 ? _b : this.defaultRetryStrategy.addJitter, (_c = data.retryStrategy.deltaBackoffMs) !== null && _c !== void 0 ? _c : this.defaultRetryStrategy.deltaBackoffMs, data.retryAttempt);
|
|
59
|
-
return {
|
|
60
|
-
canRetry: true,
|
|
61
|
-
retryInMs: waitTimeMs,
|
|
62
|
-
maxRetries: maxRetries
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
getRetryStrategyFromStrategyOptions(retryOptions) {
|
|
66
|
-
if (!retryOptions) {
|
|
67
|
-
return this.defaultRetryStrategy;
|
|
68
|
-
}
|
|
69
|
-
return retryOptions;
|
|
70
|
-
}
|
|
71
|
-
canRetryInTime(startTime, maxCumulativeWaitTimeMs) {
|
|
72
|
-
const start = startTime.getTime();
|
|
73
|
-
const now = new Date().getTime();
|
|
74
|
-
const differenceInMs = now - start;
|
|
75
|
-
return {
|
|
76
|
-
canRetry: differenceInMs < maxCumulativeWaitTimeMs,
|
|
77
|
-
differenceInMs: differenceInMs
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
getNextWaitTimeMs(addJitter, deltaBackoffMs, retryAttempts) {
|
|
81
|
-
if (!addJitter) {
|
|
82
|
-
return deltaBackoffMs * Math.pow(2, retryAttempts);
|
|
83
|
-
}
|
|
84
|
-
const from = 0.8 * deltaBackoffMs;
|
|
85
|
-
const to = 1.2 * deltaBackoffMs * Math.pow(2, retryAttempts);
|
|
86
|
-
return this.randomNumberFromInterval(from, to);
|
|
87
|
-
}
|
|
88
|
-
canRetryErrorDefault(error) {
|
|
89
|
-
const axiosError = this.tryGetAxiosError(error);
|
|
90
|
-
if (!axiosError) {
|
|
91
|
-
// by default non-axios errors are not retried
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
const statusCode = this.getStatusCodeFromError(error);
|
|
95
|
-
const canRetryStatusCode = this.canRetryStatusCode(statusCode, this.defaultRetryStatusCodes);
|
|
96
|
-
if (canRetryStatusCode) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
tryGetRetryAfterInMsFromError(error) {
|
|
102
|
-
const axiosError = this.tryGetAxiosError(error);
|
|
103
|
-
if (!axiosError || !axiosError.response) {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
const headers = extractHeadersFromAxiosResponse(axiosError.response);
|
|
107
|
-
const retryValueHeader = headers.find((m) => m.header.toLowerCase() === this.retryAfterHeaderName.toLowerCase());
|
|
108
|
-
if (!retryValueHeader) {
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
const retryInSeconds = +retryValueHeader.value;
|
|
112
|
-
return retryInSeconds * 1000;
|
|
113
|
-
}
|
|
114
|
-
canRetryStatusCode(statusCode, useRetryForResponseCodes) {
|
|
115
|
-
return useRetryForResponseCodes.includes(statusCode);
|
|
116
|
-
}
|
|
117
|
-
getStatusCodeFromError(error) {
|
|
118
|
-
const axiosError = this.tryGetAxiosError(error);
|
|
119
|
-
if (!axiosError || !axiosError.response) {
|
|
120
|
-
return 0;
|
|
121
|
-
}
|
|
122
|
-
return axiosError.response.status;
|
|
123
|
-
}
|
|
124
|
-
tryGetAxiosError(error) {
|
|
125
|
-
if (!error) {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
if (error.isAxiosError) {
|
|
129
|
-
return error;
|
|
130
|
-
}
|
|
131
|
-
const originalError = error.originalError;
|
|
132
|
-
if (originalError && originalError.isAxiosError) {
|
|
133
|
-
return originalError;
|
|
134
|
-
}
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* min and max included
|
|
139
|
-
*/
|
|
140
|
-
randomNumberFromInterval(min, max) {
|
|
141
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
export const retryHelper = new RetryHelper();
|
|
1
|
+
import { extractHeadersFromAxiosResponse } from './headers-helper';
|
|
2
|
+
export class RetryHelper {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.requestCancelledMessagePrefix = 'Request cancelled';
|
|
5
|
+
this.retryAfterHeaderName = 'Retry-After';
|
|
6
|
+
this.defaultRetryStatusCodes = [408, 429, 500, 502, 503, 504];
|
|
7
|
+
this.defaultRetryStrategy = {
|
|
8
|
+
addJitter: true,
|
|
9
|
+
deltaBackoffMs: 1000,
|
|
10
|
+
maxAttempts: 5,
|
|
11
|
+
canRetryError: (error) => this.canRetryErrorDefault(error)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getRetryErrorResult(data) {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
if (data.error && data.error.message) {
|
|
17
|
+
if (data.error.message.startsWith(this.requestCancelledMessagePrefix)) {
|
|
18
|
+
// request was cancelled by user, do not retry it
|
|
19
|
+
return {
|
|
20
|
+
canRetry: false,
|
|
21
|
+
retryInMs: 0,
|
|
22
|
+
maxRetries: 0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const canRetryError = data.retryStrategy.canRetryError
|
|
27
|
+
? data.retryStrategy.canRetryError(data.error)
|
|
28
|
+
: this.defaultRetryStrategy.canRetryError(data.error);
|
|
29
|
+
if (!canRetryError) {
|
|
30
|
+
// request cannot be retried
|
|
31
|
+
return {
|
|
32
|
+
canRetry: false,
|
|
33
|
+
retryInMs: 0,
|
|
34
|
+
maxRetries: 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const maxRetries = ((_a = data.retryStrategy.maxAttempts) !== null && _a !== void 0 ? _a : this.defaultRetryStrategy.maxAttempts);
|
|
38
|
+
const maxRetriesReached = data.retryAttempt >= maxRetries;
|
|
39
|
+
if (maxRetriesReached) {
|
|
40
|
+
// request cannot be retried anymore due to maximum attempts
|
|
41
|
+
return {
|
|
42
|
+
canRetry: false,
|
|
43
|
+
retryInMs: 0,
|
|
44
|
+
maxRetries: maxRetries
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// get wait time
|
|
48
|
+
const retryResult = this.tryGetRetryAfterInMsFromError(data.error);
|
|
49
|
+
if (retryResult) {
|
|
50
|
+
// retry after header was provided
|
|
51
|
+
return {
|
|
52
|
+
canRetry: true,
|
|
53
|
+
retryInMs: retryResult,
|
|
54
|
+
maxRetries: maxRetries
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// wait time was not provided in header
|
|
58
|
+
const waitTimeMs = this.getNextWaitTimeMs((_b = data.retryStrategy.addJitter) !== null && _b !== void 0 ? _b : this.defaultRetryStrategy.addJitter, (_c = data.retryStrategy.deltaBackoffMs) !== null && _c !== void 0 ? _c : this.defaultRetryStrategy.deltaBackoffMs, data.retryAttempt);
|
|
59
|
+
return {
|
|
60
|
+
canRetry: true,
|
|
61
|
+
retryInMs: waitTimeMs,
|
|
62
|
+
maxRetries: maxRetries
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
getRetryStrategyFromStrategyOptions(retryOptions) {
|
|
66
|
+
if (!retryOptions) {
|
|
67
|
+
return this.defaultRetryStrategy;
|
|
68
|
+
}
|
|
69
|
+
return retryOptions;
|
|
70
|
+
}
|
|
71
|
+
canRetryInTime(startTime, maxCumulativeWaitTimeMs) {
|
|
72
|
+
const start = startTime.getTime();
|
|
73
|
+
const now = new Date().getTime();
|
|
74
|
+
const differenceInMs = now - start;
|
|
75
|
+
return {
|
|
76
|
+
canRetry: differenceInMs < maxCumulativeWaitTimeMs,
|
|
77
|
+
differenceInMs: differenceInMs
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
getNextWaitTimeMs(addJitter, deltaBackoffMs, retryAttempts) {
|
|
81
|
+
if (!addJitter) {
|
|
82
|
+
return deltaBackoffMs * Math.pow(2, retryAttempts);
|
|
83
|
+
}
|
|
84
|
+
const from = 0.8 * deltaBackoffMs;
|
|
85
|
+
const to = 1.2 * deltaBackoffMs * Math.pow(2, retryAttempts);
|
|
86
|
+
return this.randomNumberFromInterval(from, to);
|
|
87
|
+
}
|
|
88
|
+
canRetryErrorDefault(error) {
|
|
89
|
+
const axiosError = this.tryGetAxiosError(error);
|
|
90
|
+
if (!axiosError) {
|
|
91
|
+
// by default non-axios errors are not retried
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const statusCode = this.getStatusCodeFromError(error);
|
|
95
|
+
const canRetryStatusCode = this.canRetryStatusCode(statusCode, this.defaultRetryStatusCodes);
|
|
96
|
+
if (canRetryStatusCode) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
tryGetRetryAfterInMsFromError(error) {
|
|
102
|
+
const axiosError = this.tryGetAxiosError(error);
|
|
103
|
+
if (!axiosError || !axiosError.response) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
const headers = extractHeadersFromAxiosResponse(axiosError.response);
|
|
107
|
+
const retryValueHeader = headers.find((m) => m.header.toLowerCase() === this.retryAfterHeaderName.toLowerCase());
|
|
108
|
+
if (!retryValueHeader) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
const retryInSeconds = +retryValueHeader.value;
|
|
112
|
+
return retryInSeconds * 1000;
|
|
113
|
+
}
|
|
114
|
+
canRetryStatusCode(statusCode, useRetryForResponseCodes) {
|
|
115
|
+
return useRetryForResponseCodes.includes(statusCode);
|
|
116
|
+
}
|
|
117
|
+
getStatusCodeFromError(error) {
|
|
118
|
+
const axiosError = this.tryGetAxiosError(error);
|
|
119
|
+
if (!axiosError || !axiosError.response) {
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
return axiosError.response.status;
|
|
123
|
+
}
|
|
124
|
+
tryGetAxiosError(error) {
|
|
125
|
+
if (!error) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
if (error.isAxiosError) {
|
|
129
|
+
return error;
|
|
130
|
+
}
|
|
131
|
+
const originalError = error.originalError;
|
|
132
|
+
if (originalError && originalError.isAxiosError) {
|
|
133
|
+
return originalError;
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* min and max included
|
|
139
|
+
*/
|
|
140
|
+
randomNumberFromInterval(min, max) {
|
|
141
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export const retryHelper = new RetryHelper();
|
|
145
145
|
//# sourceMappingURL=retry-helper.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IQueryParameter } from '../models';
|
|
2
|
-
export declare class UrlHelper {
|
|
3
|
-
/**
|
|
4
|
-
* Adds query parameters to given url
|
|
5
|
-
* @param url Url to which options will be added
|
|
6
|
-
* @param options Query parameters to add
|
|
7
|
-
*/
|
|
8
|
-
addOptionsToUrl(url: string, options?: IQueryParameter[]): string;
|
|
9
|
-
}
|
|
10
|
-
export declare const urlHelper: UrlHelper;
|
|
1
|
+
import { IQueryParameter } from '../models';
|
|
2
|
+
export declare class UrlHelper {
|
|
3
|
+
/**
|
|
4
|
+
* Adds query parameters to given url
|
|
5
|
+
* @param url Url to which options will be added
|
|
6
|
+
* @param options Query parameters to add
|
|
7
|
+
*/
|
|
8
|
+
addOptionsToUrl(url: string, options?: IQueryParameter[]): string;
|
|
9
|
+
}
|
|
10
|
+
export declare const urlHelper: UrlHelper;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export class UrlHelper {
|
|
2
|
-
/**
|
|
3
|
-
* Adds query parameters to given url
|
|
4
|
-
* @param url Url to which options will be added
|
|
5
|
-
* @param options Query parameters to add
|
|
6
|
-
*/
|
|
7
|
-
addOptionsToUrl(url, options) {
|
|
8
|
-
if (options) {
|
|
9
|
-
options.forEach(filter => {
|
|
10
|
-
if (url.indexOf('?') > -1) {
|
|
11
|
-
url += '&';
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
url += '?';
|
|
15
|
-
}
|
|
16
|
-
url += filter.getParam();
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return url;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export const urlHelper = new UrlHelper();
|
|
1
|
+
export class UrlHelper {
|
|
2
|
+
/**
|
|
3
|
+
* Adds query parameters to given url
|
|
4
|
+
* @param url Url to which options will be added
|
|
5
|
+
* @param options Query parameters to add
|
|
6
|
+
*/
|
|
7
|
+
addOptionsToUrl(url, options) {
|
|
8
|
+
if (options) {
|
|
9
|
+
options.forEach(filter => {
|
|
10
|
+
if (url.indexOf('?') > -1) {
|
|
11
|
+
url += '&';
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
url += '?';
|
|
15
|
+
}
|
|
16
|
+
url += filter.getParam();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return url;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export const urlHelper = new UrlHelper();
|
|
23
23
|
//# sourceMappingURL=url.helper.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class HttpDebugger {
|
|
2
|
-
debugStartHttpRequest(): void;
|
|
3
|
-
debugSuccessHttpRequest(): void;
|
|
4
|
-
debugRetryHttpRequest(): void;
|
|
5
|
-
}
|
|
6
|
-
export declare const httpDebugger: HttpDebugger;
|
|
1
|
+
export declare class HttpDebugger {
|
|
2
|
+
debugStartHttpRequest(): void;
|
|
3
|
+
debugSuccessHttpRequest(): void;
|
|
4
|
+
debugRetryHttpRequest(): void;
|
|
5
|
+
}
|
|
6
|
+
export declare const httpDebugger: HttpDebugger;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export class HttpDebugger {
|
|
2
|
-
/*
|
|
3
|
-
Called when http request is started
|
|
4
|
-
*/
|
|
5
|
-
debugStartHttpRequest() {
|
|
6
|
-
}
|
|
7
|
-
/*
|
|
8
|
-
Called when http request is resolved
|
|
9
|
-
*/
|
|
10
|
-
debugSuccessHttpRequest() {
|
|
11
|
-
}
|
|
12
|
-
/*
|
|
13
|
-
Called when http request is being retried
|
|
14
|
-
*/
|
|
15
|
-
debugRetryHttpRequest() {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export const httpDebugger = new HttpDebugger();
|
|
1
|
+
export class HttpDebugger {
|
|
2
|
+
/*
|
|
3
|
+
Called when http request is started
|
|
4
|
+
*/
|
|
5
|
+
debugStartHttpRequest() {
|
|
6
|
+
}
|
|
7
|
+
/*
|
|
8
|
+
Called when http request is resolved
|
|
9
|
+
*/
|
|
10
|
+
debugSuccessHttpRequest() {
|
|
11
|
+
}
|
|
12
|
+
/*
|
|
13
|
+
Called when http request is being retried
|
|
14
|
+
*/
|
|
15
|
+
debugRetryHttpRequest() {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const httpDebugger = new HttpDebugger();
|
|
19
19
|
//# sourceMappingURL=http.debugger.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AxiosInstance, CancelToken } from 'axios';
|
|
2
|
-
import { IHttpCancelRequestToken, IHttpDeleteQueryCall, IHttpGetQueryCall, IHttpPatchQueryCall, IHttpPostQueryCall, IHttpPutQueryCall, IHttpQueryOptions, IResponse } from './http.models';
|
|
3
|
-
export interface IHttpFunctionsConfig {
|
|
4
|
-
logErrorsToConsole: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare function getWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpGetQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
7
|
-
export declare function postWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpPostQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
8
|
-
export declare function putWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpPutQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
9
|
-
export declare function patchWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpPatchQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
10
|
-
export declare function deleteWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpDeleteQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
11
|
-
export declare function createCancelToken(): IHttpCancelRequestToken<CancelToken>;
|
|
1
|
+
import { AxiosInstance, CancelToken } from 'axios';
|
|
2
|
+
import { IHttpCancelRequestToken, IHttpDeleteQueryCall, IHttpGetQueryCall, IHttpPatchQueryCall, IHttpPostQueryCall, IHttpPutQueryCall, IHttpQueryOptions, IResponse } from './http.models';
|
|
3
|
+
export interface IHttpFunctionsConfig {
|
|
4
|
+
logErrorsToConsole: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function getWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpGetQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
7
|
+
export declare function postWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpPostQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
8
|
+
export declare function putWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpPutQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
9
|
+
export declare function patchWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpPatchQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
10
|
+
export declare function deleteWithRetryAsync<TRawData>(instance: AxiosInstance, call: IHttpDeleteQueryCall, functionsConfig: IHttpFunctionsConfig, options?: IHttpQueryOptions<CancelToken>): Promise<IResponse<TRawData>>;
|
|
11
|
+
export declare function createCancelToken(): IHttpCancelRequestToken<CancelToken>;
|