@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.
Files changed (106) hide show
  1. package/lib/commonjs/core/HttpService.js +481 -0
  2. package/lib/commonjs/core/HttpService.js.map +1 -0
  3. package/lib/commonjs/core/OxyServices.base.js +29 -26
  4. package/lib/commonjs/core/OxyServices.base.js.map +1 -1
  5. package/lib/commonjs/core/OxyServices.js +1 -2
  6. package/lib/commonjs/core/OxyServices.js.map +1 -1
  7. package/lib/commonjs/core/mixins/OxyServices.assets.js +3 -2
  8. package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
  9. package/lib/commonjs/core/mixins/OxyServices.user.js +9 -5
  10. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  11. package/lib/commonjs/core/mixins/OxyServices.utility.js +1 -0
  12. package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -1
  13. package/lib/commonjs/ui/components/FollowButton.js +0 -53
  14. package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
  15. package/lib/commonjs/utils/asyncUtils.js +23 -3
  16. package/lib/commonjs/utils/asyncUtils.js.map +1 -1
  17. package/lib/commonjs/utils/errorUtils.js +48 -33
  18. package/lib/commonjs/utils/errorUtils.js.map +1 -1
  19. package/lib/commonjs/utils/validationUtils.js +15 -0
  20. package/lib/commonjs/utils/validationUtils.js.map +1 -1
  21. package/lib/module/core/HttpService.js +476 -0
  22. package/lib/module/core/HttpService.js.map +1 -0
  23. package/lib/module/core/OxyServices.base.js +29 -26
  24. package/lib/module/core/OxyServices.base.js.map +1 -1
  25. package/lib/module/core/OxyServices.js +1 -2
  26. package/lib/module/core/OxyServices.js.map +1 -1
  27. package/lib/module/core/mixins/OxyServices.assets.js +3 -2
  28. package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
  29. package/lib/module/core/mixins/OxyServices.user.js +9 -5
  30. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  31. package/lib/module/core/mixins/OxyServices.utility.js +1 -0
  32. package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
  33. package/lib/module/ui/components/FollowButton.js +1 -54
  34. package/lib/module/ui/components/FollowButton.js.map +1 -1
  35. package/lib/module/utils/asyncUtils.js +24 -3
  36. package/lib/module/utils/asyncUtils.js.map +1 -1
  37. package/lib/module/utils/errorUtils.js +43 -33
  38. package/lib/module/utils/errorUtils.js.map +1 -1
  39. package/lib/module/utils/validationUtils.js +14 -0
  40. package/lib/module/utils/validationUtils.js.map +1 -1
  41. package/lib/typescript/core/HttpService.d.ts +111 -0
  42. package/lib/typescript/core/HttpService.d.ts.map +1 -0
  43. package/lib/typescript/core/OxyServices.base.d.ts +6 -8
  44. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  45. package/lib/typescript/core/OxyServices.d.ts +1 -2
  46. package/lib/typescript/core/OxyServices.d.ts.map +1 -1
  47. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts +4 -5
  48. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  49. package/lib/typescript/core/mixins/OxyServices.assets.d.ts +4 -5
  50. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  51. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +4 -5
  52. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  53. package/lib/typescript/core/mixins/OxyServices.developer.d.ts +4 -5
  54. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  55. package/lib/typescript/core/mixins/OxyServices.devices.d.ts +4 -5
  56. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  57. package/lib/typescript/core/mixins/OxyServices.karma.d.ts +4 -5
  58. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  59. package/lib/typescript/core/mixins/OxyServices.language.d.ts +4 -5
  60. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  61. package/lib/typescript/core/mixins/OxyServices.location.d.ts +4 -5
  62. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  63. package/lib/typescript/core/mixins/OxyServices.payment.d.ts +4 -5
  64. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  65. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts +4 -5
  66. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  67. package/lib/typescript/core/mixins/OxyServices.totp.d.ts +4 -5
  68. package/lib/typescript/core/mixins/OxyServices.totp.d.ts.map +1 -1
  69. package/lib/typescript/core/mixins/OxyServices.user.d.ts +4 -5
  70. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  71. package/lib/typescript/core/mixins/OxyServices.utility.d.ts +4 -5
  72. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  73. package/lib/typescript/core/mixins/index.d.ts +52 -65
  74. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  75. package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
  76. package/lib/typescript/utils/asyncUtils.d.ts +4 -0
  77. package/lib/typescript/utils/asyncUtils.d.ts.map +1 -1
  78. package/lib/typescript/utils/errorUtils.d.ts +9 -1
  79. package/lib/typescript/utils/errorUtils.d.ts.map +1 -1
  80. package/lib/typescript/utils/validationUtils.d.ts +6 -0
  81. package/lib/typescript/utils/validationUtils.d.ts.map +1 -1
  82. package/package.json +1 -1
  83. package/src/core/HttpService.ts +523 -0
  84. package/src/core/OxyServices.base.ts +36 -34
  85. package/src/core/OxyServices.ts +1 -2
  86. package/src/core/mixins/OxyServices.assets.ts +2 -1
  87. package/src/core/mixins/OxyServices.user.ts +7 -6
  88. package/src/core/mixins/OxyServices.utility.ts +1 -0
  89. package/src/ui/components/FollowButton.tsx +0 -53
  90. package/src/utils/asyncUtils.ts +23 -3
  91. package/src/utils/errorUtils.ts +72 -45
  92. package/src/utils/validationUtils.ts +14 -0
  93. package/lib/commonjs/core/HttpClient.js +0 -317
  94. package/lib/commonjs/core/HttpClient.js.map +0 -1
  95. package/lib/commonjs/core/RequestManager.js +0 -199
  96. package/lib/commonjs/core/RequestManager.js.map +0 -1
  97. package/lib/module/core/HttpClient.js +0 -311
  98. package/lib/module/core/HttpClient.js.map +0 -1
  99. package/lib/module/core/RequestManager.js +0 -194
  100. package/lib/module/core/RequestManager.js.map +0 -1
  101. package/lib/typescript/core/HttpClient.d.ts +0 -110
  102. package/lib/typescript/core/HttpClient.d.ts.map +0 -1
  103. package/lib/typescript/core/RequestManager.d.ts +0 -67
  104. package/lib/typescript/core/RequestManager.d.ts.map +0 -1
  105. package/src/core/HttpClient.ts +0 -346
  106. package/src/core/RequestManager.ts +0 -240
@@ -1,311 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * HTTP Client Service
5
- *
6
- * Handles all HTTP communication with authentication, interceptors, and error handling.
7
- * This is the single source of truth for making authenticated HTTP requests.
8
- */
9
-
10
- import axios from 'axios';
11
- import { jwtDecode } from 'jwt-decode';
12
- import { handleHttpError } from '../utils/errorUtils';
13
- import { SimpleLogger } from '../utils/requestUtils';
14
- /**
15
- * Token store for authentication
16
- */
17
- class TokenStore {
18
- accessToken = null;
19
- refreshToken = null;
20
- constructor() {}
21
- static getInstance() {
22
- if (!TokenStore.instance) {
23
- TokenStore.instance = new TokenStore();
24
- }
25
- return TokenStore.instance;
26
- }
27
- setTokens(accessToken, refreshToken = '') {
28
- this.accessToken = accessToken;
29
- this.refreshToken = refreshToken;
30
- }
31
- getAccessToken() {
32
- return this.accessToken;
33
- }
34
- getRefreshToken() {
35
- return this.refreshToken;
36
- }
37
- clearTokens() {
38
- this.accessToken = null;
39
- this.refreshToken = null;
40
- }
41
- hasAccessToken() {
42
- return !!this.accessToken;
43
- }
44
- }
45
-
46
- /**
47
- * HTTP Client Service
48
- *
49
- * Manages Axios instance with authentication interceptors.
50
- * All HTTP requests should go through this service to ensure authentication.
51
- */
52
- export class HttpClient {
53
- constructor(config) {
54
- this.baseURL = config.baseURL;
55
- this.tokenStore = TokenStore.getInstance();
56
- this.logger = new SimpleLogger(config.enableLogging || false, config.logLevel || 'error', 'HttpClient');
57
- const timeout = config.requestTimeout || 5000;
58
-
59
- // Create Axios instance with optimized configuration
60
- this.client = axios.create({
61
- baseURL: config.baseURL,
62
- timeout,
63
- headers: {
64
- 'Accept': 'application/json'
65
- },
66
- // Enable HTTP keep-alive for connection reuse (Node.js only)
67
- ...(typeof process !== 'undefined' && process.env && typeof window === 'undefined' && typeof require !== 'undefined' ? {
68
- httpAgent: new (require('http').Agent)({
69
- keepAlive: true,
70
- keepAliveMsecs: 1000,
71
- maxSockets: 50
72
- }),
73
- httpsAgent: new (require('https').Agent)({
74
- keepAlive: true,
75
- keepAliveMsecs: 1000,
76
- maxSockets: 50
77
- })
78
- } : {})
79
- });
80
- this.setupInterceptors();
81
- }
82
-
83
- /**
84
- * Setup axios interceptors for authentication and error handling
85
- */
86
- setupInterceptors() {
87
- // Request interceptor: Add authentication header
88
- this.client.interceptors.request.use(async req => {
89
- const accessToken = this.tokenStore.getAccessToken();
90
- if (!accessToken) {
91
- return req;
92
- }
93
- try {
94
- const decoded = jwtDecode(accessToken);
95
- const currentTime = Math.floor(Date.now() / 1000);
96
-
97
- // If token expires in less than 60 seconds, refresh it
98
- if (decoded.exp && decoded.exp - currentTime < 60) {
99
- if (decoded.sessionId) {
100
- try {
101
- // Create a new axios instance to avoid interceptor recursion
102
- const refreshClient = axios.create({
103
- baseURL: this.client.defaults.baseURL,
104
- timeout: this.client.defaults.timeout
105
- });
106
- const res = await refreshClient.get(`/api/session/token/${decoded.sessionId}`);
107
- this.tokenStore.setTokens(res.data.accessToken);
108
- req.headers.Authorization = `Bearer ${res.data.accessToken}`;
109
- this.logger.debug('Token refreshed');
110
- } catch (refreshError) {
111
- // If refresh fails, use current token anyway
112
- req.headers.Authorization = `Bearer ${accessToken}`;
113
- this.logger.warn('Token refresh failed, using current token');
114
- }
115
- } else {
116
- req.headers.Authorization = `Bearer ${accessToken}`;
117
- }
118
- } else {
119
- req.headers.Authorization = `Bearer ${accessToken}`;
120
- }
121
- } catch (error) {
122
- this.logger.error('Error processing token:', error);
123
- // Even if there's an error, still try to use the token
124
- req.headers.Authorization = `Bearer ${accessToken}`;
125
- }
126
- return req;
127
- }, error => {
128
- this.logger.error('Request interceptor error:', error);
129
- return Promise.reject(error);
130
- });
131
-
132
- // Response interceptor: Handle auth errors
133
- this.client.interceptors.response.use(response => response, error => {
134
- if (error.response?.status === 401) {
135
- this.logger.warn('401 Unauthorized, clearing tokens');
136
- this.tokenStore.clearTokens();
137
- }
138
- return Promise.reject(error);
139
- });
140
- }
141
-
142
- /**
143
- * Get the underlying Axios instance
144
- * Use this only when you need direct access to Axios features
145
- */
146
- getAxiosInstance() {
147
- return this.client;
148
- }
149
-
150
- /**
151
- * Make a raw HTTP request (no caching, deduplication, etc.)
152
- * Use this for requests that need to bypass performance features
153
- */
154
- async request(config) {
155
- try {
156
- const response = await this.client.request({
157
- method: config.method,
158
- url: config.url,
159
- data: config.data,
160
- params: config.params,
161
- timeout: config.timeout,
162
- signal: config.signal
163
- });
164
-
165
- // Unwrap standardized API response format: { data: ... }
166
- // This handles responses from sendSuccess() and sendPaginated() helpers
167
- const responseData = response.data;
168
-
169
- // Handle paginated responses: { data: [...], pagination: {...} }
170
- // Return the data array directly - the calling method will wrap it appropriately
171
- if (responseData && typeof responseData === 'object' && 'data' in responseData && 'pagination' in responseData) {
172
- // For paginated responses, return the data array directly
173
- // The calling methods like getUserFollowers/getUserFollowing will handle wrapping
174
- // We return the whole response so methods can access both data and pagination
175
- return responseData;
176
- }
177
-
178
- // Handle regular success responses: { data: ... }
179
- if (responseData && typeof responseData === 'object' && 'data' in responseData && !Array.isArray(responseData)) {
180
- return responseData.data;
181
- }
182
-
183
- // Return as-is for responses that don't use sendSuccess wrapper
184
- return responseData;
185
- } catch (error) {
186
- throw handleHttpError(error);
187
- }
188
- }
189
-
190
- /**
191
- * GET request convenience method
192
- */
193
- async get(url, config) {
194
- const response = await this.request({
195
- method: 'GET',
196
- url,
197
- params: config?.params,
198
- timeout: config?.timeout,
199
- signal: config?.signal
200
- });
201
- return {
202
- data: response
203
- };
204
- }
205
-
206
- /**
207
- * POST request convenience method
208
- */
209
- async post(url, data, config) {
210
- const response = await this.request({
211
- method: 'POST',
212
- url,
213
- data,
214
- timeout: config?.timeout,
215
- signal: config?.signal
216
- });
217
- return {
218
- data: response
219
- };
220
- }
221
-
222
- /**
223
- * PUT request convenience method
224
- */
225
- async put(url, data, config) {
226
- const response = await this.request({
227
- method: 'PUT',
228
- url,
229
- data,
230
- timeout: config?.timeout,
231
- signal: config?.signal
232
- });
233
- return {
234
- data: response
235
- };
236
- }
237
-
238
- /**
239
- * PATCH request convenience method
240
- */
241
- async patch(url, data, config) {
242
- const response = await this.request({
243
- method: 'PATCH',
244
- url,
245
- data,
246
- timeout: config?.timeout,
247
- signal: config?.signal
248
- });
249
- return {
250
- data: response
251
- };
252
- }
253
-
254
- /**
255
- * DELETE request convenience method
256
- */
257
- async delete(url, config) {
258
- const response = await this.request({
259
- method: 'DELETE',
260
- url,
261
- timeout: config?.timeout,
262
- signal: config?.signal
263
- });
264
- return {
265
- data: response
266
- };
267
- }
268
-
269
- /**
270
- * Get base URL
271
- */
272
- getBaseURL() {
273
- return this.baseURL;
274
- }
275
-
276
- /**
277
- * Set authentication tokens
278
- */
279
- setTokens(accessToken, refreshToken = '') {
280
- this.tokenStore.setTokens(accessToken, refreshToken);
281
- }
282
-
283
- /**
284
- * Clear authentication tokens
285
- */
286
- clearTokens() {
287
- this.tokenStore.clearTokens();
288
- }
289
-
290
- /**
291
- * Get access token
292
- */
293
- getAccessToken() {
294
- return this.tokenStore.getAccessToken();
295
- }
296
-
297
- /**
298
- * Check if has access token
299
- */
300
- hasAccessToken() {
301
- return this.tokenStore.hasAccessToken();
302
- }
303
-
304
- // Test-only utility to reset global tokens between jest tests
305
- static __resetTokensForTests() {
306
- try {
307
- TokenStore.getInstance().clearTokens();
308
- } catch {}
309
- }
310
- }
311
- //# sourceMappingURL=HttpClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["axios","jwtDecode","handleHttpError","SimpleLogger","TokenStore","accessToken","refreshToken","constructor","getInstance","instance","setTokens","getAccessToken","getRefreshToken","clearTokens","hasAccessToken","HttpClient","config","baseURL","tokenStore","logger","enableLogging","logLevel","timeout","requestTimeout","client","create","headers","process","env","window","require","httpAgent","Agent","keepAlive","keepAliveMsecs","maxSockets","httpsAgent","setupInterceptors","interceptors","request","use","req","decoded","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","post","put","patch","delete","getBaseURL","__resetTokensForTests"],"sourceRoot":"../../../src","sources":["core/HttpClient.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAmF,OAAO;AACtG,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,YAAY,QAAQ,uBAAuB;AAUpD;AACA;AACA;AACA,MAAMC,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,UAAU,CAACK,QAAQ,GAAG,IAAIL,UAAU,CAAC,CAAC;IACxC;IACA,OAAOA,UAAU,CAACK,QAAQ;EAC5B;EAEAC,SAASA,CAACL,WAAmB,EAAEC,YAAY,GAAG,EAAE,EAAQ;IACtD,IAAI,CAACD,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACC,YAAY,GAAGA,YAAY;EAClC;EAEAK,cAAcA,CAAA,EAAkB;IAC9B,OAAO,IAAI,CAACN,WAAW;EACzB;EAEAO,eA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AAEpD,MAAM,EAAEoD;IAClB,CAAC,CAAC;IACF,OAAO;MAAEd,IAAI,EAAEQ;IAAc,CAAC;EAChC;;EAEA;AACF;AACA;EACEc,UAAUA,CAAA,EAAW;IACnB,OAAO,IAAI,CAAC3D,OAAO;EACrB;;EAEA;AACF;AACA;EACEP,SAASA,CAACL,WAAmB,EAAEC,YAAY,GAAG,EAAE,EAAQ;IACtD,IAAI,CAACY,UAAU,CAACR,SAAS,CAACL,WAAW,EAAEC,YAAY,CAAC;EACtD;;EAEA;AACF;AACA;EACEO,WAAWA,CAAA,EAAS;IAClB,IAAI,CAACK,UAAU,CAACL,WAAW,CAAC,CAAC;EAC/B;;EAEA;AACF;AACA;EACEF,cAAcA,CAAA,EAAkB;IAC9B,OAAO,IAAI,CAACO,UAAU,CAACP,cAAc,CAAC,CAAC;EACzC;;EAEA;AACF;AACA;EACEG,cAAcA,CAAA,EAAY;IACxB,OAAO,IAAI,CAACI,UAAU,CAACJ,cAAc,CAAC,CAAC;EACzC;;EAEA;EACA,OAAO+D,qBAAqBA,CAAA,EAAS;IACnC,IAAI;MACFzE,UAAU,CAACI,WAAW,CAAC,CAAC,CAACK,WAAW,CAAC,CAAC;IACxC,CAAC,CAAC,MAAM,CAAC;EACX;AACF","ignoreList":[]}
@@ -1,194 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Request Manager
5
- *
6
- * Handles request-level optimizations: caching, deduplication, queuing, and retry.
7
- * Works on top of HttpClient to add performance features.
8
- */
9
-
10
- import { TTLCache, registerCacheForCleanup } from '../utils/cache';
11
- import { RequestDeduplicator, RequestQueue, SimpleLogger } from '../utils/requestUtils';
12
- /**
13
- * Request Manager
14
- *
15
- * Manages request-level optimizations while delegating actual HTTP calls to HttpClient.
16
- */
17
- export class RequestManager {
18
- // Performance monitoring
19
- requestMetrics = {
20
- totalRequests: 0,
21
- successfulRequests: 0,
22
- failedRequests: 0,
23
- cacheHits: 0,
24
- cacheMisses: 0,
25
- averageResponseTime: 0
26
- };
27
- constructor(httpClient, config) {
28
- this.httpClient = httpClient;
29
- this.config = config;
30
-
31
- // Initialize performance infrastructure
32
- this.cache = new TTLCache(config.cacheTTL || 5 * 60 * 1000);
33
- registerCacheForCleanup(this.cache);
34
- this.deduplicator = new RequestDeduplicator();
35
- this.requestQueue = new RequestQueue(config.maxConcurrentRequests || 10, config.requestQueueSize || 100);
36
- this.logger = new SimpleLogger(config.enableLogging || false, config.logLevel || 'error', 'RequestManager');
37
- }
38
-
39
- /**
40
- * Make a request with all performance optimizations
41
- */
42
- async request(method, url, data, options = {}) {
43
- const {
44
- cache = method === 'GET',
45
- // Cache GET requests by default
46
- cacheTTL,
47
- deduplicate = true,
48
- retry = this.config.enableRetry !== false,
49
- maxRetries = this.config.maxRetries || 3,
50
- timeout,
51
- signal
52
- } = options;
53
-
54
- // Generate cache key
55
- const cacheKey = cache ? `${method}:${url}:${JSON.stringify(data || {})}` : null;
56
-
57
- // Check cache first
58
- if (cache && cacheKey) {
59
- const cached = this.cache.get(cacheKey);
60
- if (cached !== null) {
61
- this.requestMetrics.cacheHits++;
62
- this.logger.debug('Cache hit:', url);
63
- return cached;
64
- }
65
- this.requestMetrics.cacheMisses++;
66
- }
67
-
68
- // Request function that uses HttpClient
69
- const requestFn = async () => {
70
- const startTime = Date.now();
71
- try {
72
- const result = await this.httpClient.request({
73
- method,
74
- url,
75
- data: method !== 'GET' ? data : undefined,
76
- params: method === 'GET' ? data : undefined,
77
- timeout: timeout || this.config.requestTimeout || 5000,
78
- signal
79
- });
80
- const duration = Date.now() - startTime;
81
- this.updateMetrics(true, duration);
82
- this.config.onRequestEnd?.(url, method, duration, true);
83
- return result;
84
- } catch (error) {
85
- const duration = Date.now() - startTime;
86
- this.updateMetrics(false, duration);
87
- this.config.onRequestEnd?.(url, method, duration, false);
88
- this.config.onRequestError?.(url, method, error);
89
- throw error;
90
- }
91
- };
92
-
93
- // Wrap with retry if enabled
94
- const requestWithRetry = retry ? () => this.retryWithBackoff(requestFn, maxRetries) : requestFn;
95
-
96
- // Wrap with deduplication if enabled
97
- const dedupeKey = deduplicate ? `${method}:${url}:${JSON.stringify(data || {})}` : null;
98
- const finalRequest = dedupeKey ? () => this.deduplicator.deduplicate(dedupeKey, requestWithRetry) : requestWithRetry;
99
-
100
- // Execute request (with queue if needed)
101
- const result = await this.requestQueue.enqueue(finalRequest);
102
-
103
- // Cache the result if caching is enabled
104
- if (cache && cacheKey && result) {
105
- this.cache.set(cacheKey, result, cacheTTL);
106
- }
107
- return result;
108
- }
109
-
110
- /**
111
- * Exponential backoff retry logic with 4xx error handling
112
- */
113
- async retryWithBackoff(fn, maxRetries = 3, baseDelay = 1000) {
114
- let lastError;
115
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
116
- try {
117
- return await fn();
118
- } catch (error) {
119
- lastError = error;
120
-
121
- // Don't retry on 4xx errors (client errors)
122
- if (error.response?.status >= 400 && error.response?.status < 500) {
123
- throw error;
124
- }
125
-
126
- // Don't retry on last attempt
127
- if (attempt === maxRetries) {
128
- break;
129
- }
130
-
131
- // Calculate delay with exponential backoff and jitter
132
- const delay = baseDelay * Math.pow(2, attempt) + Math.random() * 1000;
133
- this.logger.debug(`Retry attempt ${attempt + 1}/${maxRetries} after ${delay}ms`);
134
- await new Promise(resolve => setTimeout(resolve, delay));
135
- }
136
- }
137
- throw lastError;
138
- }
139
-
140
- /**
141
- * Update request metrics
142
- */
143
- updateMetrics(success, duration) {
144
- this.requestMetrics.totalRequests++;
145
- if (success) {
146
- this.requestMetrics.successfulRequests++;
147
- } else {
148
- this.requestMetrics.failedRequests++;
149
- }
150
-
151
- // Update average response time (exponential moving average)
152
- const alpha = 0.1; // Smoothing factor
153
- this.requestMetrics.averageResponseTime = this.requestMetrics.averageResponseTime * (1 - alpha) + duration * alpha;
154
- }
155
-
156
- /**
157
- * Get performance metrics
158
- */
159
- getMetrics() {
160
- return {
161
- ...this.requestMetrics
162
- };
163
- }
164
-
165
- /**
166
- * Clear request cache
167
- */
168
- clearCache() {
169
- this.cache.clear();
170
- this.logger.debug('Cache cleared');
171
- }
172
-
173
- /**
174
- * Clear specific cache entry
175
- */
176
- clearCacheEntry(key) {
177
- this.cache.delete(key);
178
- }
179
-
180
- /**
181
- * Get cache statistics
182
- */
183
- getCacheStats() {
184
- const cacheStats = this.cache.getStats();
185
- const total = this.requestMetrics.cacheHits + this.requestMetrics.cacheMisses;
186
- return {
187
- size: cacheStats.size,
188
- hits: this.requestMetrics.cacheHits,
189
- misses: this.requestMetrics.cacheMisses,
190
- hitRate: total > 0 ? this.requestMetrics.cacheHits / total : 0
191
- };
192
- }
193
- }
194
- //# sourceMappingURL=RequestManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TTLCache","registerCacheForCleanup","RequestDeduplicator","RequestQueue","SimpleLogger","RequestManager","requestMetrics","totalRequests","successfulRequests","failedRequests","cacheHits","cacheMisses","averageResponseTime","constructor","httpClient","config","cache","cacheTTL","deduplicator","requestQueue","maxConcurrentRequests","requestQueueSize","logger","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"],"sourceRoot":"../../../src","sources":["core/RequestManager.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,uBAAuB,QAAQ,gBAAgB;AAClE,SAASC,mBAAmB,EAAEC,YAAY,EAAEC,YAAY,QAAQ,uBAAuB;AAcvF;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,CAAC;EAQ1B;EACQC,cAAc,GAAG;IACvBC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A,CAAA,EAAS;IACjB,IAAI,CAAC7D,KAAK,CAAC8D,KAAK,CAAC,CAAC;IAClB,IAAI,CAACxD,MAAM,CAACmB,KAAK,CAAC,eAAe,CAAC;EACpC;;EAEA;AACF;AACA;EACEsC,eAAeA,CAACC,GAAW,EAAQ;IACjC,IAAI,CAAChE,KAAK,CAACiE,MAAM,CAACD,GAAG,CAAC;EACxB;;EAEA;AACF;AACA;EACEE,aAAaA,CAAA,EAAoE;IAC/E,MAAMC,UAAU,GAAG,IAAI,CAACnE,KAAK,CAACoE,QAAQ,CAAC,CAAC;IACxC,MAAMC,KAAK,GAAG,IAAI,CAAC/E,cAAc,CAACI,SAAS,GAAG,IAAI,CAACJ,cAAc,CAACK,WAAW;IAC7E,OAAO;MACL2E,IAAI,EAAEH,UAAU,CAACG,IAAI;MACrBC,IAAI,EAAE,IAAI,CAACjF,cAAc,CAACI,SAAS;MACnC8E,MAAM,EAAE,IAAI,CAAClF,cAAc,CAACK,WAAW;MACvC8E,OAAO,EAAEJ,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC/E,cAAc,CAACI,SAAS,GAAG2E,KAAK,GAAG;IAC/D,CAAC;EACH;AACF","ignoreList":[]}
@@ -1,110 +0,0 @@
1
- /**
2
- * HTTP Client Service
3
- *
4
- * Handles all HTTP communication with authentication, interceptors, and error handling.
5
- * This is the single source of truth for making authenticated HTTP requests.
6
- */
7
- import { type AxiosInstance } from 'axios';
8
- import type { OxyConfig } from '../models/interfaces';
9
- /**
10
- * HTTP Client Service
11
- *
12
- * Manages Axios instance with authentication interceptors.
13
- * All HTTP requests should go through this service to ensure authentication.
14
- */
15
- export declare class HttpClient {
16
- private client;
17
- private tokenStore;
18
- private logger;
19
- private baseURL;
20
- constructor(config: OxyConfig);
21
- /**
22
- * Setup axios interceptors for authentication and error handling
23
- */
24
- private setupInterceptors;
25
- /**
26
- * Get the underlying Axios instance
27
- * Use this only when you need direct access to Axios features
28
- */
29
- getAxiosInstance(): AxiosInstance;
30
- /**
31
- * Make a raw HTTP request (no caching, deduplication, etc.)
32
- * Use this for requests that need to bypass performance features
33
- */
34
- request<T = any>(config: {
35
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
36
- url: string;
37
- data?: any;
38
- params?: any;
39
- timeout?: number;
40
- signal?: AbortSignal;
41
- }): Promise<T>;
42
- /**
43
- * GET request convenience method
44
- */
45
- get<T = any>(url: string, config?: {
46
- params?: any;
47
- timeout?: number;
48
- signal?: AbortSignal;
49
- }): Promise<{
50
- data: T;
51
- }>;
52
- /**
53
- * POST request convenience method
54
- */
55
- post<T = any>(url: string, data?: any, config?: {
56
- timeout?: number;
57
- signal?: AbortSignal;
58
- }): Promise<{
59
- data: T;
60
- }>;
61
- /**
62
- * PUT request convenience method
63
- */
64
- put<T = any>(url: string, data?: any, config?: {
65
- timeout?: number;
66
- signal?: AbortSignal;
67
- }): Promise<{
68
- data: T;
69
- }>;
70
- /**
71
- * PATCH request convenience method
72
- */
73
- patch<T = any>(url: string, data?: any, config?: {
74
- timeout?: number;
75
- signal?: AbortSignal;
76
- }): Promise<{
77
- data: T;
78
- }>;
79
- /**
80
- * DELETE request convenience method
81
- */
82
- delete<T = any>(url: string, config?: {
83
- timeout?: number;
84
- signal?: AbortSignal;
85
- }): Promise<{
86
- data: T;
87
- }>;
88
- /**
89
- * Get base URL
90
- */
91
- getBaseURL(): string;
92
- /**
93
- * Set authentication tokens
94
- */
95
- setTokens(accessToken: string, refreshToken?: string): void;
96
- /**
97
- * Clear authentication tokens
98
- */
99
- clearTokens(): void;
100
- /**
101
- * Get access token
102
- */
103
- getAccessToken(): string | null;
104
- /**
105
- * Check if has access token
106
- */
107
- hasAccessToken(): boolean;
108
- static __resetTokensForTests(): void;
109
- }
110
- //# sourceMappingURL=HttpClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../../src/core/HttpClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,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