@oxyhq/services 5.13.24 → 5.13.26
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/lib/commonjs/core/HttpService.js +481 -0
- package/lib/commonjs/core/HttpService.js.map +1 -0
- package/lib/commonjs/core/OxyServices.base.js +29 -26
- package/lib/commonjs/core/OxyServices.base.js.map +1 -1
- package/lib/commonjs/core/OxyServices.js +1 -2
- package/lib/commonjs/core/OxyServices.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.assets.js +3 -2
- package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.user.js +9 -5
- package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.utility.js +1 -0
- package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +0 -53
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/utils/asyncUtils.js +23 -3
- package/lib/commonjs/utils/asyncUtils.js.map +1 -1
- package/lib/commonjs/utils/errorUtils.js +48 -33
- package/lib/commonjs/utils/errorUtils.js.map +1 -1
- package/lib/commonjs/utils/validationUtils.js +15 -0
- package/lib/commonjs/utils/validationUtils.js.map +1 -1
- package/lib/module/core/HttpService.js +476 -0
- package/lib/module/core/HttpService.js.map +1 -0
- package/lib/module/core/OxyServices.base.js +29 -26
- package/lib/module/core/OxyServices.base.js.map +1 -1
- package/lib/module/core/OxyServices.js +1 -2
- package/lib/module/core/OxyServices.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.assets.js +3 -2
- package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.user.js +9 -5
- package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.utility.js +1 -0
- package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +1 -54
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/utils/asyncUtils.js +24 -3
- package/lib/module/utils/asyncUtils.js.map +1 -1
- package/lib/module/utils/errorUtils.js +43 -33
- package/lib/module/utils/errorUtils.js.map +1 -1
- package/lib/module/utils/validationUtils.js +14 -0
- package/lib/module/utils/validationUtils.js.map +1 -1
- package/lib/typescript/core/HttpService.d.ts +111 -0
- package/lib/typescript/core/HttpService.d.ts.map +1 -0
- package/lib/typescript/core/OxyServices.base.d.ts +6 -8
- package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
- package/lib/typescript/core/OxyServices.d.ts +1 -2
- package/lib/typescript/core/OxyServices.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.analytics.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.developer.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.devices.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.karma.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.language.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.location.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.payment.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.privacy.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.totp.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.totp.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.user.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.utility.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +52 -65
- package/lib/typescript/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/utils/asyncUtils.d.ts +4 -0
- package/lib/typescript/utils/asyncUtils.d.ts.map +1 -1
- package/lib/typescript/utils/errorUtils.d.ts +9 -1
- package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
- package/lib/typescript/utils/validationUtils.d.ts +6 -0
- package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/HttpService.ts +523 -0
- package/src/core/OxyServices.base.ts +36 -34
- package/src/core/OxyServices.ts +1 -2
- package/src/core/mixins/OxyServices.assets.ts +2 -1
- package/src/core/mixins/OxyServices.user.ts +7 -6
- package/src/core/mixins/OxyServices.utility.ts +1 -0
- package/src/ui/components/FollowButton.tsx +0 -53
- package/src/utils/asyncUtils.ts +23 -3
- package/src/utils/errorUtils.ts +72 -45
- package/src/utils/validationUtils.ts +14 -0
- package/lib/commonjs/core/HttpClient.js +0 -317
- package/lib/commonjs/core/HttpClient.js.map +0 -1
- package/lib/commonjs/core/RequestManager.js +0 -199
- package/lib/commonjs/core/RequestManager.js.map +0 -1
- package/lib/module/core/HttpClient.js +0 -311
- package/lib/module/core/HttpClient.js.map +0 -1
- package/lib/module/core/RequestManager.js +0 -194
- package/lib/module/core/RequestManager.js.map +0 -1
- package/lib/typescript/core/HttpClient.d.ts +0 -110
- package/lib/typescript/core/HttpClient.d.ts.map +0 -1
- package/lib/typescript/core/RequestManager.d.ts +0 -67
- package/lib/typescript/core/RequestManager.d.ts.map +0 -1
- package/src/core/HttpClient.ts +0 -346
- package/src/core/RequestManager.ts +0 -240
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.HttpClient = void 0;
|
|
7
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
-
var _jwtDecode = require("jwt-decode");
|
|
9
|
-
var _errorUtils = require("../utils/errorUtils");
|
|
10
|
-
var _requestUtils = require("../utils/requestUtils");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* HTTP Client Service
|
|
14
|
-
*
|
|
15
|
-
* Handles all HTTP communication with authentication, interceptors, and error handling.
|
|
16
|
-
* This is the single source of truth for making authenticated HTTP requests.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Token store for authentication
|
|
21
|
-
*/
|
|
22
|
-
class TokenStore {
|
|
23
|
-
accessToken = null;
|
|
24
|
-
refreshToken = null;
|
|
25
|
-
constructor() {}
|
|
26
|
-
static getInstance() {
|
|
27
|
-
if (!TokenStore.instance) {
|
|
28
|
-
TokenStore.instance = new TokenStore();
|
|
29
|
-
}
|
|
30
|
-
return TokenStore.instance;
|
|
31
|
-
}
|
|
32
|
-
setTokens(accessToken, refreshToken = '') {
|
|
33
|
-
this.accessToken = accessToken;
|
|
34
|
-
this.refreshToken = refreshToken;
|
|
35
|
-
}
|
|
36
|
-
getAccessToken() {
|
|
37
|
-
return this.accessToken;
|
|
38
|
-
}
|
|
39
|
-
getRefreshToken() {
|
|
40
|
-
return this.refreshToken;
|
|
41
|
-
}
|
|
42
|
-
clearTokens() {
|
|
43
|
-
this.accessToken = null;
|
|
44
|
-
this.refreshToken = null;
|
|
45
|
-
}
|
|
46
|
-
hasAccessToken() {
|
|
47
|
-
return !!this.accessToken;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* HTTP Client Service
|
|
53
|
-
*
|
|
54
|
-
* Manages Axios instance with authentication interceptors.
|
|
55
|
-
* All HTTP requests should go through this service to ensure authentication.
|
|
56
|
-
*/
|
|
57
|
-
class HttpClient {
|
|
58
|
-
constructor(config) {
|
|
59
|
-
this.baseURL = config.baseURL;
|
|
60
|
-
this.tokenStore = TokenStore.getInstance();
|
|
61
|
-
this.logger = new _requestUtils.SimpleLogger(config.enableLogging || false, config.logLevel || 'error', 'HttpClient');
|
|
62
|
-
const timeout = config.requestTimeout || 5000;
|
|
63
|
-
|
|
64
|
-
// Create Axios instance with optimized configuration
|
|
65
|
-
this.client = _axios.default.create({
|
|
66
|
-
baseURL: config.baseURL,
|
|
67
|
-
timeout,
|
|
68
|
-
headers: {
|
|
69
|
-
'Accept': 'application/json'
|
|
70
|
-
},
|
|
71
|
-
// Enable HTTP keep-alive for connection reuse (Node.js only)
|
|
72
|
-
...(typeof process !== 'undefined' && process.env && typeof window === 'undefined' && typeof require !== 'undefined' ? {
|
|
73
|
-
httpAgent: new (require('http').Agent)({
|
|
74
|
-
keepAlive: true,
|
|
75
|
-
keepAliveMsecs: 1000,
|
|
76
|
-
maxSockets: 50
|
|
77
|
-
}),
|
|
78
|
-
httpsAgent: new (require('https').Agent)({
|
|
79
|
-
keepAlive: true,
|
|
80
|
-
keepAliveMsecs: 1000,
|
|
81
|
-
maxSockets: 50
|
|
82
|
-
})
|
|
83
|
-
} : {})
|
|
84
|
-
});
|
|
85
|
-
this.setupInterceptors();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Setup axios interceptors for authentication and error handling
|
|
90
|
-
*/
|
|
91
|
-
setupInterceptors() {
|
|
92
|
-
// Request interceptor: Add authentication header
|
|
93
|
-
this.client.interceptors.request.use(async req => {
|
|
94
|
-
const accessToken = this.tokenStore.getAccessToken();
|
|
95
|
-
if (!accessToken) {
|
|
96
|
-
return req;
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
const decoded = (0, _jwtDecode.jwtDecode)(accessToken);
|
|
100
|
-
const currentTime = Math.floor(Date.now() / 1000);
|
|
101
|
-
|
|
102
|
-
// If token expires in less than 60 seconds, refresh it
|
|
103
|
-
if (decoded.exp && decoded.exp - currentTime < 60) {
|
|
104
|
-
if (decoded.sessionId) {
|
|
105
|
-
try {
|
|
106
|
-
// Create a new axios instance to avoid interceptor recursion
|
|
107
|
-
const refreshClient = _axios.default.create({
|
|
108
|
-
baseURL: this.client.defaults.baseURL,
|
|
109
|
-
timeout: this.client.defaults.timeout
|
|
110
|
-
});
|
|
111
|
-
const res = await refreshClient.get(`/api/session/token/${decoded.sessionId}`);
|
|
112
|
-
this.tokenStore.setTokens(res.data.accessToken);
|
|
113
|
-
req.headers.Authorization = `Bearer ${res.data.accessToken}`;
|
|
114
|
-
this.logger.debug('Token refreshed');
|
|
115
|
-
} catch (refreshError) {
|
|
116
|
-
// If refresh fails, use current token anyway
|
|
117
|
-
req.headers.Authorization = `Bearer ${accessToken}`;
|
|
118
|
-
this.logger.warn('Token refresh failed, using current token');
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
req.headers.Authorization = `Bearer ${accessToken}`;
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
req.headers.Authorization = `Bearer ${accessToken}`;
|
|
125
|
-
}
|
|
126
|
-
} catch (error) {
|
|
127
|
-
this.logger.error('Error processing token:', error);
|
|
128
|
-
// Even if there's an error, still try to use the token
|
|
129
|
-
req.headers.Authorization = `Bearer ${accessToken}`;
|
|
130
|
-
}
|
|
131
|
-
return req;
|
|
132
|
-
}, error => {
|
|
133
|
-
this.logger.error('Request interceptor error:', error);
|
|
134
|
-
return Promise.reject(error);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Response interceptor: Handle auth errors
|
|
138
|
-
this.client.interceptors.response.use(response => response, error => {
|
|
139
|
-
if (error.response?.status === 401) {
|
|
140
|
-
this.logger.warn('401 Unauthorized, clearing tokens');
|
|
141
|
-
this.tokenStore.clearTokens();
|
|
142
|
-
}
|
|
143
|
-
return Promise.reject(error);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Get the underlying Axios instance
|
|
149
|
-
* Use this only when you need direct access to Axios features
|
|
150
|
-
*/
|
|
151
|
-
getAxiosInstance() {
|
|
152
|
-
return this.client;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Make a raw HTTP request (no caching, deduplication, etc.)
|
|
157
|
-
* Use this for requests that need to bypass performance features
|
|
158
|
-
*/
|
|
159
|
-
async request(config) {
|
|
160
|
-
try {
|
|
161
|
-
const response = await this.client.request({
|
|
162
|
-
method: config.method,
|
|
163
|
-
url: config.url,
|
|
164
|
-
data: config.data,
|
|
165
|
-
params: config.params,
|
|
166
|
-
timeout: config.timeout,
|
|
167
|
-
signal: config.signal
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// Unwrap standardized API response format: { data: ... }
|
|
171
|
-
// This handles responses from sendSuccess() and sendPaginated() helpers
|
|
172
|
-
const responseData = response.data;
|
|
173
|
-
|
|
174
|
-
// Handle paginated responses: { data: [...], pagination: {...} }
|
|
175
|
-
// Return the data array directly - the calling method will wrap it appropriately
|
|
176
|
-
if (responseData && typeof responseData === 'object' && 'data' in responseData && 'pagination' in responseData) {
|
|
177
|
-
// For paginated responses, return the data array directly
|
|
178
|
-
// The calling methods like getUserFollowers/getUserFollowing will handle wrapping
|
|
179
|
-
// We return the whole response so methods can access both data and pagination
|
|
180
|
-
return responseData;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Handle regular success responses: { data: ... }
|
|
184
|
-
if (responseData && typeof responseData === 'object' && 'data' in responseData && !Array.isArray(responseData)) {
|
|
185
|
-
return responseData.data;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Return as-is for responses that don't use sendSuccess wrapper
|
|
189
|
-
return responseData;
|
|
190
|
-
} catch (error) {
|
|
191
|
-
throw (0, _errorUtils.handleHttpError)(error);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* GET request convenience method
|
|
197
|
-
*/
|
|
198
|
-
async get(url, config) {
|
|
199
|
-
const response = await this.request({
|
|
200
|
-
method: 'GET',
|
|
201
|
-
url,
|
|
202
|
-
params: config?.params,
|
|
203
|
-
timeout: config?.timeout,
|
|
204
|
-
signal: config?.signal
|
|
205
|
-
});
|
|
206
|
-
return {
|
|
207
|
-
data: response
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* POST request convenience method
|
|
213
|
-
*/
|
|
214
|
-
async post(url, data, config) {
|
|
215
|
-
const response = await this.request({
|
|
216
|
-
method: 'POST',
|
|
217
|
-
url,
|
|
218
|
-
data,
|
|
219
|
-
timeout: config?.timeout,
|
|
220
|
-
signal: config?.signal
|
|
221
|
-
});
|
|
222
|
-
return {
|
|
223
|
-
data: response
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* PUT request convenience method
|
|
229
|
-
*/
|
|
230
|
-
async put(url, data, config) {
|
|
231
|
-
const response = await this.request({
|
|
232
|
-
method: 'PUT',
|
|
233
|
-
url,
|
|
234
|
-
data,
|
|
235
|
-
timeout: config?.timeout,
|
|
236
|
-
signal: config?.signal
|
|
237
|
-
});
|
|
238
|
-
return {
|
|
239
|
-
data: response
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* PATCH request convenience method
|
|
245
|
-
*/
|
|
246
|
-
async patch(url, data, config) {
|
|
247
|
-
const response = await this.request({
|
|
248
|
-
method: 'PATCH',
|
|
249
|
-
url,
|
|
250
|
-
data,
|
|
251
|
-
timeout: config?.timeout,
|
|
252
|
-
signal: config?.signal
|
|
253
|
-
});
|
|
254
|
-
return {
|
|
255
|
-
data: response
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* DELETE request convenience method
|
|
261
|
-
*/
|
|
262
|
-
async delete(url, config) {
|
|
263
|
-
const response = await this.request({
|
|
264
|
-
method: 'DELETE',
|
|
265
|
-
url,
|
|
266
|
-
timeout: config?.timeout,
|
|
267
|
-
signal: config?.signal
|
|
268
|
-
});
|
|
269
|
-
return {
|
|
270
|
-
data: response
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Get base URL
|
|
276
|
-
*/
|
|
277
|
-
getBaseURL() {
|
|
278
|
-
return this.baseURL;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Set authentication tokens
|
|
283
|
-
*/
|
|
284
|
-
setTokens(accessToken, refreshToken = '') {
|
|
285
|
-
this.tokenStore.setTokens(accessToken, refreshToken);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Clear authentication tokens
|
|
290
|
-
*/
|
|
291
|
-
clearTokens() {
|
|
292
|
-
this.tokenStore.clearTokens();
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Get access token
|
|
297
|
-
*/
|
|
298
|
-
getAccessToken() {
|
|
299
|
-
return this.tokenStore.getAccessToken();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Check if has access token
|
|
304
|
-
*/
|
|
305
|
-
hasAccessToken() {
|
|
306
|
-
return this.tokenStore.hasAccessToken();
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Test-only utility to reset global tokens between jest tests
|
|
310
|
-
static __resetTokensForTests() {
|
|
311
|
-
try {
|
|
312
|
-
TokenStore.getInstance().clearTokens();
|
|
313
|
-
} catch {}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
exports.HttpClient = HttpClient;
|
|
317
|
-
//# sourceMappingURL=HttpClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_axios","_interopRequireDefault","require","_jwtDecode","_errorUtils","_requestUtils","e","__esModule","default","TokenStore","accessToken","refreshToken","constructor","getInstance","instance","setTokens","getAccessToken","getRefreshToken","clearTokens","hasAccessToken","HttpClient","config","baseURL","tokenStore","logger","SimpleLogger","enableLogging","logLevel","timeout","requestTimeout","client","axios","create","headers","process","env","window","httpAgent","Agent","keepAlive","keepAliveMsecs","maxSockets","httpsAgent","setupInterceptors","interceptors","request","use","req","decoded","jwtDecode","currentTime","Math","floor","Date","now","exp","sessionId","refreshClient","defaults","res","get","data","Authorization","debug","refreshError","warn","error","Promise","reject","response","status","getAxiosInstance","method","url","params","signal","responseData","Array","isArray","handleHttpError","post","put","patch","delete","getBaseURL","__resetTokensForTests","exports"],"sourceRoot":"../../../src","sources":["core/HttpClient.ts"],"mappings":";;;;;;AAOA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAAqD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAXrD;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA,MAAMG,UAAU,CAAC;EAEPC,WAAW,GAAkB,IAAI;EACjCC,YAAY,GAAkB,IAAI;EAElCC,WAAWA,CAAA,EAAG,CAAC;EAEvB,OAAOC,WAAWA,CAAA,EAAe;IAC/B,IAAI,CAACJ,UAAU,CAACK,QAAQ,EAAE;MACxBL,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defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.RequestManager = void 0;
|
|
7
|
-
var _cache = require("../utils/cache");
|
|
8
|
-
var _requestUtils = require("../utils/requestUtils");
|
|
9
|
-
/**
|
|
10
|
-
* Request Manager
|
|
11
|
-
*
|
|
12
|
-
* Handles request-level optimizations: caching, deduplication, queuing, and retry.
|
|
13
|
-
* Works on top of HttpClient to add performance features.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Request Manager
|
|
18
|
-
*
|
|
19
|
-
* Manages request-level optimizations while delegating actual HTTP calls to HttpClient.
|
|
20
|
-
*/
|
|
21
|
-
class RequestManager {
|
|
22
|
-
// Performance monitoring
|
|
23
|
-
requestMetrics = {
|
|
24
|
-
totalRequests: 0,
|
|
25
|
-
successfulRequests: 0,
|
|
26
|
-
failedRequests: 0,
|
|
27
|
-
cacheHits: 0,
|
|
28
|
-
cacheMisses: 0,
|
|
29
|
-
averageResponseTime: 0
|
|
30
|
-
};
|
|
31
|
-
constructor(httpClient, config) {
|
|
32
|
-
this.httpClient = httpClient;
|
|
33
|
-
this.config = config;
|
|
34
|
-
|
|
35
|
-
// Initialize performance infrastructure
|
|
36
|
-
this.cache = new _cache.TTLCache(config.cacheTTL || 5 * 60 * 1000);
|
|
37
|
-
(0, _cache.registerCacheForCleanup)(this.cache);
|
|
38
|
-
this.deduplicator = new _requestUtils.RequestDeduplicator();
|
|
39
|
-
this.requestQueue = new _requestUtils.RequestQueue(config.maxConcurrentRequests || 10, config.requestQueueSize || 100);
|
|
40
|
-
this.logger = new _requestUtils.SimpleLogger(config.enableLogging || false, config.logLevel || 'error', 'RequestManager');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Make a request with all performance optimizations
|
|
45
|
-
*/
|
|
46
|
-
async request(method, url, data, options = {}) {
|
|
47
|
-
const {
|
|
48
|
-
cache = method === 'GET',
|
|
49
|
-
// Cache GET requests by default
|
|
50
|
-
cacheTTL,
|
|
51
|
-
deduplicate = true,
|
|
52
|
-
retry = this.config.enableRetry !== false,
|
|
53
|
-
maxRetries = this.config.maxRetries || 3,
|
|
54
|
-
timeout,
|
|
55
|
-
signal
|
|
56
|
-
} = options;
|
|
57
|
-
|
|
58
|
-
// Generate cache key
|
|
59
|
-
const cacheKey = cache ? `${method}:${url}:${JSON.stringify(data || {})}` : null;
|
|
60
|
-
|
|
61
|
-
// Check cache first
|
|
62
|
-
if (cache && cacheKey) {
|
|
63
|
-
const cached = this.cache.get(cacheKey);
|
|
64
|
-
if (cached !== null) {
|
|
65
|
-
this.requestMetrics.cacheHits++;
|
|
66
|
-
this.logger.debug('Cache hit:', url);
|
|
67
|
-
return cached;
|
|
68
|
-
}
|
|
69
|
-
this.requestMetrics.cacheMisses++;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Request function that uses HttpClient
|
|
73
|
-
const requestFn = async () => {
|
|
74
|
-
const startTime = Date.now();
|
|
75
|
-
try {
|
|
76
|
-
const result = await this.httpClient.request({
|
|
77
|
-
method,
|
|
78
|
-
url,
|
|
79
|
-
data: method !== 'GET' ? data : undefined,
|
|
80
|
-
params: method === 'GET' ? data : undefined,
|
|
81
|
-
timeout: timeout || this.config.requestTimeout || 5000,
|
|
82
|
-
signal
|
|
83
|
-
});
|
|
84
|
-
const duration = Date.now() - startTime;
|
|
85
|
-
this.updateMetrics(true, duration);
|
|
86
|
-
this.config.onRequestEnd?.(url, method, duration, true);
|
|
87
|
-
return result;
|
|
88
|
-
} catch (error) {
|
|
89
|
-
const duration = Date.now() - startTime;
|
|
90
|
-
this.updateMetrics(false, duration);
|
|
91
|
-
this.config.onRequestEnd?.(url, method, duration, false);
|
|
92
|
-
this.config.onRequestError?.(url, method, error);
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Wrap with retry if enabled
|
|
98
|
-
const requestWithRetry = retry ? () => this.retryWithBackoff(requestFn, maxRetries) : requestFn;
|
|
99
|
-
|
|
100
|
-
// Wrap with deduplication if enabled
|
|
101
|
-
const dedupeKey = deduplicate ? `${method}:${url}:${JSON.stringify(data || {})}` : null;
|
|
102
|
-
const finalRequest = dedupeKey ? () => this.deduplicator.deduplicate(dedupeKey, requestWithRetry) : requestWithRetry;
|
|
103
|
-
|
|
104
|
-
// Execute request (with queue if needed)
|
|
105
|
-
const result = await this.requestQueue.enqueue(finalRequest);
|
|
106
|
-
|
|
107
|
-
// Cache the result if caching is enabled
|
|
108
|
-
if (cache && cacheKey && result) {
|
|
109
|
-
this.cache.set(cacheKey, result, cacheTTL);
|
|
110
|
-
}
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Exponential backoff retry logic with 4xx error handling
|
|
116
|
-
*/
|
|
117
|
-
async retryWithBackoff(fn, maxRetries = 3, baseDelay = 1000) {
|
|
118
|
-
let lastError;
|
|
119
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
120
|
-
try {
|
|
121
|
-
return await fn();
|
|
122
|
-
} catch (error) {
|
|
123
|
-
lastError = error;
|
|
124
|
-
|
|
125
|
-
// Don't retry on 4xx errors (client errors)
|
|
126
|
-
if (error.response?.status >= 400 && error.response?.status < 500) {
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Don't retry on last attempt
|
|
131
|
-
if (attempt === maxRetries) {
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Calculate delay with exponential backoff and jitter
|
|
136
|
-
const delay = baseDelay * Math.pow(2, attempt) + Math.random() * 1000;
|
|
137
|
-
this.logger.debug(`Retry attempt ${attempt + 1}/${maxRetries} after ${delay}ms`);
|
|
138
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
throw lastError;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Update request metrics
|
|
146
|
-
*/
|
|
147
|
-
updateMetrics(success, duration) {
|
|
148
|
-
this.requestMetrics.totalRequests++;
|
|
149
|
-
if (success) {
|
|
150
|
-
this.requestMetrics.successfulRequests++;
|
|
151
|
-
} else {
|
|
152
|
-
this.requestMetrics.failedRequests++;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Update average response time (exponential moving average)
|
|
156
|
-
const alpha = 0.1; // Smoothing factor
|
|
157
|
-
this.requestMetrics.averageResponseTime = this.requestMetrics.averageResponseTime * (1 - alpha) + duration * alpha;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Get performance metrics
|
|
162
|
-
*/
|
|
163
|
-
getMetrics() {
|
|
164
|
-
return {
|
|
165
|
-
...this.requestMetrics
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Clear request cache
|
|
171
|
-
*/
|
|
172
|
-
clearCache() {
|
|
173
|
-
this.cache.clear();
|
|
174
|
-
this.logger.debug('Cache cleared');
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Clear specific cache entry
|
|
179
|
-
*/
|
|
180
|
-
clearCacheEntry(key) {
|
|
181
|
-
this.cache.delete(key);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Get cache statistics
|
|
186
|
-
*/
|
|
187
|
-
getCacheStats() {
|
|
188
|
-
const cacheStats = this.cache.getStats();
|
|
189
|
-
const total = this.requestMetrics.cacheHits + this.requestMetrics.cacheMisses;
|
|
190
|
-
return {
|
|
191
|
-
size: cacheStats.size,
|
|
192
|
-
hits: this.requestMetrics.cacheHits,
|
|
193
|
-
misses: this.requestMetrics.cacheMisses,
|
|
194
|
-
hitRate: total > 0 ? this.requestMetrics.cacheHits / total : 0
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
exports.RequestManager = RequestManager;
|
|
199
|
-
//# sourceMappingURL=RequestManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_cache","require","_requestUtils","RequestManager","requestMetrics","totalRequests","successfulRequests","failedRequests","cacheHits","cacheMisses","averageResponseTime","constructor","httpClient","config","cache","TTLCache","cacheTTL","registerCacheForCleanup","deduplicator","RequestDeduplicator","requestQueue","RequestQueue","maxConcurrentRequests","requestQueueSize","logger","SimpleLogger","enableLogging","logLevel","request","method","url","data","options","deduplicate","retry","enableRetry","maxRetries","timeout","signal","cacheKey","JSON","stringify","cached","get","debug","requestFn","startTime","Date","now","result","undefined","params","requestTimeout","duration","updateMetrics","onRequestEnd","error","onRequestError","requestWithRetry","retryWithBackoff","dedupeKey","finalRequest","enqueue","set","fn","baseDelay","lastError","attempt","response","status","delay","Math","pow","random","Promise","resolve","setTimeout","success","alpha","getMetrics","clearCache","clear","clearCacheEntry","key","delete","getCacheStats","cacheStats","getStats","total","size","hits","misses","hitRate","exports"],"sourceRoot":"../../../src","sources":["core/RequestManager.ts"],"mappings":";;;;;;AAQA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACO,MAAME,cAAc,CAAC;EAQ1B;EACQC,cAAc,GAAG;IACvBC,aAAa,EAAE,CAAC;IAChBC,kBAAkB,EAAE,CAAC;IACrBC,cAAc,EAAE,CAAC;IACjBC,SAAS,EAAE,CAAC;IACZC,WAAW,EAAE,CAAC;IACdC,mBAAmB,EAAE;EACvB,CAAC;EAEDC,WAAWA,CACTC,UAAsD,EACtDC,MAAiB,EACjB;IACA,IAAI,CAACD,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,MAAM,GAAGA,MAAM;;IAEpB;IACA,IAAI,CAACC,KAAK,GAAG,IAAIC,eAAQ,CAAMF,MAAM,CAACG,QAAQ,IAAI,CA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