@oxyhq/services 5.13.25 → 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/utils/errorUtils.js +35 -15
- package/lib/commonjs/utils/errorUtils.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/utils/errorUtils.js +36 -15
- package/lib/module/utils/errorUtils.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/utils/errorUtils.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/utils/errorUtils.ts +65 -19
- package/lib/commonjs/core/HttpClient.js +0 -317
- package/lib/commonjs/core/HttpClient.js.map +0 -1
- package/lib/commonjs/core/RequestManager.js +0 -170
- 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 -165
- 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 -63
- package/lib/typescript/core/RequestManager.d.ts.map +0 -1
- package/src/core/HttpClient.ts +0 -346
- package/src/core/RequestManager.ts +0 -205
|
@@ -1,165 +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
|
-
import { retryAsync } from '../utils/asyncUtils';
|
|
13
|
-
/**
|
|
14
|
-
* Request Manager
|
|
15
|
-
*
|
|
16
|
-
* Manages request-level optimizations while delegating actual HTTP calls to HttpClient.
|
|
17
|
-
*/
|
|
18
|
-
export class RequestManager {
|
|
19
|
-
// Performance monitoring
|
|
20
|
-
requestMetrics = {
|
|
21
|
-
totalRequests: 0,
|
|
22
|
-
successfulRequests: 0,
|
|
23
|
-
failedRequests: 0,
|
|
24
|
-
cacheHits: 0,
|
|
25
|
-
cacheMisses: 0,
|
|
26
|
-
averageResponseTime: 0
|
|
27
|
-
};
|
|
28
|
-
constructor(httpClient, config) {
|
|
29
|
-
this.httpClient = httpClient;
|
|
30
|
-
this.config = config;
|
|
31
|
-
|
|
32
|
-
// Initialize performance infrastructure
|
|
33
|
-
this.cache = new TTLCache(config.cacheTTL || 5 * 60 * 1000);
|
|
34
|
-
registerCacheForCleanup(this.cache);
|
|
35
|
-
this.deduplicator = new RequestDeduplicator();
|
|
36
|
-
this.requestQueue = new RequestQueue(config.maxConcurrentRequests || 10, config.requestQueueSize || 100);
|
|
37
|
-
this.logger = new SimpleLogger(config.enableLogging || false, config.logLevel || 'error', 'RequestManager');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Make a request with all performance optimizations
|
|
42
|
-
*/
|
|
43
|
-
async request(method, url, data, options = {}) {
|
|
44
|
-
const {
|
|
45
|
-
cache = method === 'GET',
|
|
46
|
-
// Cache GET requests by default
|
|
47
|
-
cacheTTL,
|
|
48
|
-
deduplicate = true,
|
|
49
|
-
retry = this.config.enableRetry !== false,
|
|
50
|
-
maxRetries = this.config.maxRetries || 3,
|
|
51
|
-
timeout,
|
|
52
|
-
signal
|
|
53
|
-
} = options;
|
|
54
|
-
|
|
55
|
-
// Generate cache key
|
|
56
|
-
const cacheKey = cache ? `${method}:${url}:${JSON.stringify(data || {})}` : null;
|
|
57
|
-
|
|
58
|
-
// Check cache first
|
|
59
|
-
if (cache && cacheKey) {
|
|
60
|
-
const cached = this.cache.get(cacheKey);
|
|
61
|
-
if (cached !== null) {
|
|
62
|
-
this.requestMetrics.cacheHits++;
|
|
63
|
-
this.logger.debug('Cache hit:', url);
|
|
64
|
-
return cached;
|
|
65
|
-
}
|
|
66
|
-
this.requestMetrics.cacheMisses++;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Request function that uses HttpClient
|
|
70
|
-
const requestFn = async () => {
|
|
71
|
-
const startTime = Date.now();
|
|
72
|
-
try {
|
|
73
|
-
const result = await this.httpClient.request({
|
|
74
|
-
method,
|
|
75
|
-
url,
|
|
76
|
-
data: method !== 'GET' ? data : undefined,
|
|
77
|
-
params: method === 'GET' ? data : undefined,
|
|
78
|
-
timeout: timeout || this.config.requestTimeout || 5000,
|
|
79
|
-
signal
|
|
80
|
-
});
|
|
81
|
-
const duration = Date.now() - startTime;
|
|
82
|
-
this.updateMetrics(true, duration);
|
|
83
|
-
this.config.onRequestEnd?.(url, method, duration, true);
|
|
84
|
-
return result;
|
|
85
|
-
} catch (error) {
|
|
86
|
-
const duration = Date.now() - startTime;
|
|
87
|
-
this.updateMetrics(false, duration);
|
|
88
|
-
this.config.onRequestEnd?.(url, method, duration, false);
|
|
89
|
-
this.config.onRequestError?.(url, method, error);
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// Wrap with retry if enabled
|
|
95
|
-
const requestWithRetry = retry ? () => retryAsync(requestFn, maxRetries, this.config.retryDelay || 1000) : requestFn;
|
|
96
|
-
|
|
97
|
-
// Wrap with deduplication if enabled
|
|
98
|
-
const dedupeKey = deduplicate ? `${method}:${url}:${JSON.stringify(data || {})}` : null;
|
|
99
|
-
const finalRequest = dedupeKey ? () => this.deduplicator.deduplicate(dedupeKey, requestWithRetry) : requestWithRetry;
|
|
100
|
-
|
|
101
|
-
// Execute request (with queue if needed)
|
|
102
|
-
const result = await this.requestQueue.enqueue(finalRequest);
|
|
103
|
-
|
|
104
|
-
// Cache the result if caching is enabled
|
|
105
|
-
if (cache && cacheKey && result) {
|
|
106
|
-
this.cache.set(cacheKey, result, cacheTTL);
|
|
107
|
-
}
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Update request metrics
|
|
113
|
-
*/
|
|
114
|
-
updateMetrics(success, duration) {
|
|
115
|
-
this.requestMetrics.totalRequests++;
|
|
116
|
-
if (success) {
|
|
117
|
-
this.requestMetrics.successfulRequests++;
|
|
118
|
-
} else {
|
|
119
|
-
this.requestMetrics.failedRequests++;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Update average response time (exponential moving average)
|
|
123
|
-
const alpha = 0.1; // Smoothing factor
|
|
124
|
-
this.requestMetrics.averageResponseTime = this.requestMetrics.averageResponseTime * (1 - alpha) + duration * alpha;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Get performance metrics
|
|
129
|
-
*/
|
|
130
|
-
getMetrics() {
|
|
131
|
-
return {
|
|
132
|
-
...this.requestMetrics
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Clear request cache
|
|
138
|
-
*/
|
|
139
|
-
clearCache() {
|
|
140
|
-
this.cache.clear();
|
|
141
|
-
this.logger.debug('Cache cleared');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Clear specific cache entry
|
|
146
|
-
*/
|
|
147
|
-
clearCacheEntry(key) {
|
|
148
|
-
this.cache.delete(key);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Get cache statistics
|
|
153
|
-
*/
|
|
154
|
-
getCacheStats() {
|
|
155
|
-
const cacheStats = this.cache.getStats();
|
|
156
|
-
const total = this.requestMetrics.cacheHits + this.requestMetrics.cacheMisses;
|
|
157
|
-
return {
|
|
158
|
-
size: cacheStats.size,
|
|
159
|
-
hits: this.requestMetrics.cacheHits,
|
|
160
|
-
misses: this.requestMetrics.cacheMisses,
|
|
161
|
-
hitRate: total > 0 ? this.requestMetrics.cacheHits / total : 0
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=RequestManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TTLCache","registerCacheForCleanup","RequestDeduplicator","RequestQueue","SimpleLogger","retryAsync","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","retryDelay","dedupeKey","finalRequest","enqueue","set","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,SAASC,UAAU,QAAQ,qBAAqB;AAahD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,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,IAAIjB,QAAQ,CAAMgB,MAAM,CAACE,QAAQ,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IAChEjB,uBA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,IAAI,CAAC3C,MAAM,CAACmB,KAAK,CAAC,eAAe,CAAC;EACpC;;EAEA;AACF;AACA;EACEyB,eAAeA,CAACC,GAAW,EAAQ;IACjC,IAAI,CAACnD,KAAK,CAACoD,MAAM,CAACD,GAAG,CAAC;EACxB;;EAEA;AACF;AACA;EACEE,aAAaA,CAAA,EAAoE;IAC/E,MAAMC,UAAU,GAAG,IAAI,CAACtD,KAAK,CAACuD,QAAQ,CAAC,CAAC;IACxC,MAAMC,KAAK,GAAG,IAAI,CAAClE,cAAc,CAACI,SAAS,GAAG,IAAI,CAACJ,cAAc,CAACK,WAAW;IAC7E,OAAO;MACL8D,IAAI,EAAEH,UAAU,CAACG,IAAI;MACrBC,IAAI,EAAE,IAAI,CAACpE,cAAc,CAACI,SAAS;MACnCiE,MAAM,EAAE,IAAI,CAACrE,cAAc,CAACK,WAAW;MACvCiE,OAAO,EAAEJ,KAAK,GAAG,CAAC,GAAG,IAAI,CAAClE,cAAc,CAACI,SAAS,GAAG8D,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,OAAc,EAAE,KAAK,aAAa,EAAuD,MAAM,OAAO,CAAC;AAEvG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAoDtD;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,SAAS;IAuC7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;I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,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;IAWxH;;OAEG;IACG,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;IAU7G;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,SAAK,GAAG,IAAI;IAIvD;;OAEG;IACH,WAAW,IAAI,IAAI;IAInB;;OAEG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,cAAc,IAAI,OAAO;IAKzB,MAAM,CAAC,qBAAqB,IAAI,IAAI;CAKrC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Request Manager
|
|
3
|
-
*
|
|
4
|
-
* Handles request-level optimizations: caching, deduplication, queuing, and retry.
|
|
5
|
-
* Works on top of HttpClient to add performance features.
|
|
6
|
-
*/
|
|
7
|
-
import type { OxyConfig } from '../models/interfaces';
|
|
8
|
-
export interface RequestOptions {
|
|
9
|
-
cache?: boolean;
|
|
10
|
-
cacheTTL?: number;
|
|
11
|
-
deduplicate?: boolean;
|
|
12
|
-
retry?: boolean;
|
|
13
|
-
maxRetries?: number;
|
|
14
|
-
timeout?: number;
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Request Manager
|
|
19
|
-
*
|
|
20
|
-
* Manages request-level optimizations while delegating actual HTTP calls to HttpClient.
|
|
21
|
-
*/
|
|
22
|
-
export declare class RequestManager {
|
|
23
|
-
private cache;
|
|
24
|
-
private deduplicator;
|
|
25
|
-
private requestQueue;
|
|
26
|
-
private logger;
|
|
27
|
-
private config;
|
|
28
|
-
private httpClient;
|
|
29
|
-
private requestMetrics;
|
|
30
|
-
constructor(httpClient: {
|
|
31
|
-
request: (config: any) => Promise<any>;
|
|
32
|
-
}, config: OxyConfig);
|
|
33
|
-
/**
|
|
34
|
-
* Make a request with all performance optimizations
|
|
35
|
-
*/
|
|
36
|
-
request<T>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', url: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
37
|
-
/**
|
|
38
|
-
* Update request metrics
|
|
39
|
-
*/
|
|
40
|
-
private updateMetrics;
|
|
41
|
-
/**
|
|
42
|
-
* Get performance metrics
|
|
43
|
-
*/
|
|
44
|
-
getMetrics(): typeof this.requestMetrics;
|
|
45
|
-
/**
|
|
46
|
-
* Clear request cache
|
|
47
|
-
*/
|
|
48
|
-
clearCache(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Clear specific cache entry
|
|
51
|
-
*/
|
|
52
|
-
clearCacheEntry(key: string): void;
|
|
53
|
-
/**
|
|
54
|
-
* Get cache statistics
|
|
55
|
-
*/
|
|
56
|
-
getCacheStats(): {
|
|
57
|
-
size: number;
|
|
58
|
-
hits: number;
|
|
59
|
-
misses: number;
|
|
60
|
-
hitRate: number;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=RequestManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestManager.d.ts","sourceRoot":"","sources":["../../../src/core/RequestManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,cAAc;I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