hyperttp 0.2.3 → 0.2.5
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/Hyperttp/Core/CacheManager.d.ts +63 -40
- package/dist/Hyperttp/Core/CacheManager.d.ts.map +1 -1
- package/dist/Hyperttp/Core/CacheManager.js +64 -62
- package/dist/Hyperttp/Core/CacheManager.js.map +1 -1
- package/dist/Hyperttp/Core/HttpClientImproved.d.ts +55 -33
- package/dist/Hyperttp/Core/HttpClientImproved.d.ts.map +1 -1
- package/dist/Hyperttp/Core/HttpClientImproved.js +313 -219
- package/dist/Hyperttp/Core/HttpClientImproved.js.map +1 -1
- package/dist/Hyperttp/Core/InterceptorManager.d.ts +11 -11
- package/dist/Hyperttp/Core/InterceptorManager.d.ts.map +1 -1
- package/dist/Hyperttp/Core/InterceptorManager.js +10 -10
- package/dist/Hyperttp/Core/InterceptorManager.js.map +1 -1
- package/dist/Hyperttp/Core/MetricsManager.d.ts +33 -42
- package/dist/Hyperttp/Core/MetricsManager.d.ts.map +1 -1
- package/dist/Hyperttp/Core/MetricsManager.js +147 -58
- package/dist/Hyperttp/Core/MetricsManager.js.map +1 -1
- package/dist/Hyperttp/Core/QueueManager.d.ts +6 -4
- package/dist/Hyperttp/Core/QueueManager.d.ts.map +1 -1
- package/dist/Hyperttp/Core/QueueManager.js +36 -34
- package/dist/Hyperttp/Core/QueueManager.js.map +1 -1
- package/dist/Hyperttp/Core/RateLimiter.d.ts +29 -36
- package/dist/Hyperttp/Core/RateLimiter.d.ts.map +1 -1
- package/dist/Hyperttp/Core/RateLimiter.js +96 -36
- package/dist/Hyperttp/Core/RateLimiter.js.map +1 -1
- package/dist/Hyperttp/Core/RequestBuilder.d.ts +3 -1
- package/dist/Hyperttp/Core/RequestBuilder.d.ts.map +1 -1
- package/dist/Hyperttp/Core/RequestBuilder.js +10 -3
- package/dist/Hyperttp/Core/RequestBuilder.js.map +1 -1
- package/dist/Hyperttp/Core/RequestExecutor.d.ts +7 -34
- package/dist/Hyperttp/Core/RequestExecutor.d.ts.map +1 -1
- package/dist/Hyperttp/Core/RequestExecutor.js +120 -114
- package/dist/Hyperttp/Core/RequestExecutor.js.map +1 -1
- package/dist/Hyperttp/Core/ResponseConverter.d.ts +23 -0
- package/dist/Hyperttp/Core/ResponseConverter.d.ts.map +1 -0
- package/dist/Hyperttp/Core/ResponseConverter.js +368 -0
- package/dist/Hyperttp/Core/ResponseConverter.js.map +1 -0
- package/dist/Hyperttp/Core/index.d.ts +7 -10
- package/dist/Hyperttp/Core/index.d.ts.map +1 -1
- package/dist/Hyperttp/Core/index.js +26 -15
- package/dist/Hyperttp/Core/index.js.map +1 -1
- package/dist/Hyperttp/Request.d.ts +9 -20
- package/dist/Hyperttp/Request.d.ts.map +1 -1
- package/dist/Hyperttp/Request.js +93 -85
- package/dist/Hyperttp/Request.js.map +1 -1
- package/dist/Hyperttp/UrlExtractor.d.ts +1 -1
- package/dist/Hyperttp/UrlExtractor.d.ts.map +1 -1
- package/dist/Hyperttp/index.d.ts +1 -3
- package/dist/Hyperttp/index.d.ts.map +1 -1
- package/dist/Hyperttp/index.js +7 -8
- package/dist/Hyperttp/index.js.map +1 -1
- package/dist/Types/cache.d.ts +10 -0
- package/dist/Types/cache.d.ts.map +1 -0
- package/dist/Types/cache.js +3 -0
- package/dist/Types/cache.js.map +1 -0
- package/dist/Types/errors.d.ts +15 -0
- package/dist/Types/errors.d.ts.map +1 -0
- package/dist/Types/errors.js +34 -0
- package/dist/Types/errors.js.map +1 -0
- package/dist/Types/http-client.d.ts +39 -0
- package/dist/Types/http-client.d.ts.map +1 -0
- package/dist/Types/http-client.js +3 -0
- package/dist/Types/http-client.js.map +1 -0
- package/dist/Types/http.d.ts +5 -0
- package/dist/Types/http.d.ts.map +1 -0
- package/dist/Types/http.js +3 -0
- package/dist/Types/http.js.map +1 -0
- package/dist/Types/index.d.ts +12 -126
- package/dist/Types/index.d.ts.map +1 -1
- package/dist/Types/index.js +12 -39
- package/dist/Types/index.js.map +1 -1
- package/dist/Types/interceptors.d.ts +13 -0
- package/dist/Types/interceptors.d.ts.map +1 -0
- package/dist/Types/interceptors.js +3 -0
- package/dist/Types/interceptors.js.map +1 -0
- package/dist/Types/metrics.d.ts +67 -0
- package/dist/Types/metrics.d.ts.map +1 -0
- package/dist/Types/metrics.js +3 -0
- package/dist/Types/metrics.js.map +1 -0
- package/dist/Types/options.d.ts +233 -0
- package/dist/Types/options.d.ts.map +1 -0
- package/dist/Types/options.js +3 -0
- package/dist/Types/options.js.map +1 -0
- package/dist/Types/queue.d.ts +8 -0
- package/dist/Types/queue.d.ts.map +1 -0
- package/dist/Types/queue.js +3 -0
- package/dist/Types/queue.js.map +1 -0
- package/dist/Types/request.d.ts +150 -12
- package/dist/Types/request.d.ts.map +1 -1
- package/dist/Types/response.d.ts +28 -0
- package/dist/Types/response.d.ts.map +1 -0
- package/dist/Types/response.js +3 -0
- package/dist/Types/response.js.map +1 -0
- package/dist/Types/stream.d.ts +39 -0
- package/dist/Types/stream.d.ts.map +1 -0
- package/dist/Types/stream.js +3 -0
- package/dist/Types/stream.js.map +1 -0
- package/dist/Types/url-extractor.d.ts +10 -0
- package/dist/Types/url-extractor.d.ts.map +1 -0
- package/dist/Types/url-extractor.js +3 -0
- package/dist/Types/url-extractor.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
- package/dist/Hyperttp/Core/ResponseTransformer.d.ts +0 -35
- package/dist/Hyperttp/Core/ResponseTransformer.d.ts.map +0 -1
- package/dist/Hyperttp/Core/ResponseTransformer.js +0 -171
- package/dist/Hyperttp/Core/ResponseTransformer.js.map +0 -1
package/dist/Types/index.d.ts
CHANGED
|
@@ -1,127 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export * from "./
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
export declare class TimeoutError extends HttpClientError {
|
|
15
|
-
constructor(url: string, timeout: number);
|
|
16
|
-
}
|
|
17
|
-
export declare class RateLimitError extends HttpClientError {
|
|
18
|
-
retryAfter?: number | undefined;
|
|
19
|
-
constructor(url: string, retryAfter?: number | undefined);
|
|
20
|
-
}
|
|
21
|
-
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
22
|
-
export interface RetryOptions {
|
|
23
|
-
maxRetries: number;
|
|
24
|
-
baseDelay: number;
|
|
25
|
-
maxDelay: number;
|
|
26
|
-
retryStatusCodes: number[];
|
|
27
|
-
jitter: boolean;
|
|
28
|
-
}
|
|
29
|
-
export type RequestInterceptor = (config: {
|
|
30
|
-
url: string;
|
|
31
|
-
method: string;
|
|
32
|
-
headers: Record<string, string>;
|
|
33
|
-
body?: any;
|
|
34
|
-
}) => Promise<any> | any;
|
|
35
|
-
export type ResponseInterceptor = (response: {
|
|
36
|
-
status: number;
|
|
37
|
-
headers: Record<string, any>;
|
|
38
|
-
body: Buffer;
|
|
39
|
-
url: string;
|
|
40
|
-
}) => Promise<any> | any;
|
|
41
|
-
export interface HttpClientOptions {
|
|
42
|
-
timeout?: number;
|
|
43
|
-
maxConcurrent?: number;
|
|
44
|
-
maxRetries?: number;
|
|
45
|
-
cacheTTL?: number;
|
|
46
|
-
cacheMaxSize?: number;
|
|
47
|
-
rateLimit?: {
|
|
48
|
-
maxRequests: number;
|
|
49
|
-
windowMs: number;
|
|
50
|
-
};
|
|
51
|
-
userAgent?: string;
|
|
52
|
-
logger?: (level: LogLevel, message: string, meta?: any) => void;
|
|
53
|
-
retryOptions?: Partial<RetryOptions>;
|
|
54
|
-
followRedirects?: boolean;
|
|
55
|
-
maxRedirects?: number;
|
|
56
|
-
maxResponseBytes?: number;
|
|
57
|
-
validateStatus?: (status: number) => boolean;
|
|
58
|
-
cacheMethods?: string[];
|
|
59
|
-
maxMetricsSize?: number;
|
|
60
|
-
verbose?: boolean;
|
|
61
|
-
enableQueue?: boolean;
|
|
62
|
-
enableRateLimit?: boolean;
|
|
63
|
-
enableCache?: boolean;
|
|
64
|
-
}
|
|
65
|
-
export interface HttpClientInterface {
|
|
66
|
-
get<T = any>(req: RequestInterface | string, responseType?: ResponseType): Promise<T>;
|
|
67
|
-
post<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
68
|
-
put<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
69
|
-
delete<T = any>(req: RequestInterface | string, responseType?: ResponseType): Promise<T>;
|
|
70
|
-
patch<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
71
|
-
head(req: RequestInterface | string): Promise<{
|
|
72
|
-
status: number;
|
|
73
|
-
headers: Record<string, any>;
|
|
74
|
-
}>;
|
|
75
|
-
stream(req: RequestInterface | string): Promise<StreamResponse>;
|
|
76
|
-
clearCache(): void;
|
|
77
|
-
}
|
|
78
|
-
export interface RequestMetrics {
|
|
79
|
-
startTime: number;
|
|
80
|
-
endTime: number;
|
|
81
|
-
duration: number;
|
|
82
|
-
statusCode?: number;
|
|
83
|
-
bytesReceived: number;
|
|
84
|
-
bytesSent: number;
|
|
85
|
-
retries: number;
|
|
86
|
-
cached: boolean;
|
|
87
|
-
url: string;
|
|
88
|
-
method: string;
|
|
89
|
-
bodyHash?: string;
|
|
90
|
-
}
|
|
91
|
-
export interface StreamResponse {
|
|
92
|
-
status: number;
|
|
93
|
-
headers: Record<string, any>;
|
|
94
|
-
body: AsyncIterable<Uint8Array>;
|
|
95
|
-
url: string;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Interface for a universal URL extractor
|
|
99
|
-
*/
|
|
100
|
-
export interface UrlExtractorInterface {
|
|
101
|
-
/**
|
|
102
|
-
* Register a platform with its URL patterns
|
|
103
|
-
* @param platform Platform name (e.g., "yandex", "spotify")
|
|
104
|
-
* @param patterns Array of URL patterns for the platform
|
|
105
|
-
*/
|
|
106
|
-
registerPlatform(platform: string, patterns: UrlPattern[]): void;
|
|
107
|
-
/**
|
|
108
|
-
* Extract an entity ID or related info from a URL
|
|
109
|
-
* @param url URL to extract from
|
|
110
|
-
* @param entity Entity type ("track", "album", "artist", "playlist", etc.)
|
|
111
|
-
* @param platform Platform name that has been registered
|
|
112
|
-
* @returns Record of extracted values (keys depend on the pattern)
|
|
113
|
-
*/
|
|
114
|
-
extractId<T extends string | number>(url: string, entity: string, platform: string): Record<string, T>;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Defines a URL extraction pattern for a platform
|
|
118
|
-
*/
|
|
119
|
-
export interface UrlPattern<T extends string = string> {
|
|
120
|
-
/** Entity type this pattern applies to (track, album, artist, playlist, etc.) */
|
|
121
|
-
entity: string;
|
|
122
|
-
/** Regex with named capturing groups to extract IDs or info */
|
|
123
|
-
regex: RegExp;
|
|
124
|
-
/** Names of the capturing groups to extract */
|
|
125
|
-
groupNames: T[];
|
|
126
|
-
}
|
|
1
|
+
export * from "./cache.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * from "./http-client.js";
|
|
4
|
+
export * from "./http.js";
|
|
5
|
+
export * from "./interceptors.js";
|
|
6
|
+
export * from "./metrics.js";
|
|
7
|
+
export * from "./options.js";
|
|
8
|
+
export * from "./queue.js";
|
|
9
|
+
export * from "./request.js";
|
|
10
|
+
export * from "./response.js";
|
|
11
|
+
export * from "./stream.js";
|
|
12
|
+
export * from "./url-extractor.js";
|
|
127
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Types/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
|
package/dist/Types/index.js
CHANGED
|
@@ -14,43 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
super(message);
|
|
30
|
-
this.code = code;
|
|
31
|
-
this.statusCode = statusCode;
|
|
32
|
-
this.originalError = originalError;
|
|
33
|
-
this.url = url;
|
|
34
|
-
this.method = method;
|
|
35
|
-
this.name = "HttpClientError";
|
|
36
|
-
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.HttpClientError = HttpClientError;
|
|
40
|
-
class TimeoutError extends HttpClientError {
|
|
41
|
-
constructor(url, timeout) {
|
|
42
|
-
super(`Request timeout after ${timeout}ms for ${url}`, "TIMEOUT", 408, undefined, url);
|
|
43
|
-
this.name = "TimeoutError";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.TimeoutError = TimeoutError;
|
|
47
|
-
class RateLimitError extends HttpClientError {
|
|
48
|
-
retryAfter;
|
|
49
|
-
constructor(url, retryAfter) {
|
|
50
|
-
super(`Rate limited for ${url}${retryAfter ? `, retry after ${retryAfter}ms` : ""}`, "RATE_LIMIT", 429, undefined, url);
|
|
51
|
-
this.retryAfter = retryAfter;
|
|
52
|
-
this.name = "RateLimitError";
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.RateLimitError = RateLimitError;
|
|
17
|
+
__exportStar(require("./cache.js"), exports);
|
|
18
|
+
__exportStar(require("./errors.js"), exports);
|
|
19
|
+
__exportStar(require("./http-client.js"), exports);
|
|
20
|
+
__exportStar(require("./http.js"), exports);
|
|
21
|
+
__exportStar(require("./interceptors.js"), exports);
|
|
22
|
+
__exportStar(require("./metrics.js"), exports);
|
|
23
|
+
__exportStar(require("./options.js"), exports);
|
|
24
|
+
__exportStar(require("./queue.js"), exports);
|
|
25
|
+
__exportStar(require("./request.js"), exports);
|
|
26
|
+
__exportStar(require("./response.js"), exports);
|
|
27
|
+
__exportStar(require("./stream.js"), exports);
|
|
28
|
+
__exportStar(require("./url-extractor.js"), exports);
|
|
56
29
|
//# sourceMappingURL=index.js.map
|
package/dist/Types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,mDAAiC;AACjC,4CAA0B;AAC1B,oDAAkC;AAClC,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,+CAA6B;AAC7B,gDAA8B;AAC9B,8CAA4B;AAC5B,qDAAmC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RequestInterceptor = (config: {
|
|
2
|
+
url: string;
|
|
3
|
+
method: string;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
body?: any;
|
|
6
|
+
}) => any | Promise<any>;
|
|
7
|
+
export type ResponseInterceptor = (response: {
|
|
8
|
+
status: number;
|
|
9
|
+
headers: Record<string, any>;
|
|
10
|
+
body: Buffer;
|
|
11
|
+
url: string;
|
|
12
|
+
}) => any | Promise<any>;
|
|
13
|
+
//# sourceMappingURL=interceptors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptors.d.ts","sourceRoot":"","sources":["../../src/Types/interceptors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAEzB,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../../src/Types/interceptors.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface RequestMetrics {
|
|
2
|
+
/**
|
|
3
|
+
* @ru Время начала запроса (timestamp)
|
|
4
|
+
* @en Request start time (timestamp)
|
|
5
|
+
*/
|
|
6
|
+
startTime: number;
|
|
7
|
+
/**
|
|
8
|
+
* @ru Время окончания запроса (timestamp)
|
|
9
|
+
* @en Request end time (timestamp)
|
|
10
|
+
*/
|
|
11
|
+
endTime: number;
|
|
12
|
+
/**
|
|
13
|
+
* @ru Длительность запроса (мс)
|
|
14
|
+
* @en Request duration (ms)
|
|
15
|
+
*/
|
|
16
|
+
duration: number;
|
|
17
|
+
/**
|
|
18
|
+
* @ru HTTP статус код ответа
|
|
19
|
+
* @en HTTP status code of response
|
|
20
|
+
*/
|
|
21
|
+
statusCode?: number;
|
|
22
|
+
/**
|
|
23
|
+
* @ru Количество полученных байт
|
|
24
|
+
* @en Bytes received
|
|
25
|
+
*/
|
|
26
|
+
bytesReceived: number;
|
|
27
|
+
/**
|
|
28
|
+
* @ru Количество отправленных байт
|
|
29
|
+
* @en Bytes sent
|
|
30
|
+
*/
|
|
31
|
+
bytesSent: number;
|
|
32
|
+
/**
|
|
33
|
+
* @ru Количество повторных попыток
|
|
34
|
+
* @en Number of retries performed
|
|
35
|
+
*/
|
|
36
|
+
retries: number;
|
|
37
|
+
/**
|
|
38
|
+
* @ru Ответ из кэша
|
|
39
|
+
* @en Response served from cache
|
|
40
|
+
*/
|
|
41
|
+
cached: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @ru URL запроса
|
|
44
|
+
* @en Request URL
|
|
45
|
+
*/
|
|
46
|
+
url: string;
|
|
47
|
+
/**
|
|
48
|
+
* @ru HTTP метод запроса
|
|
49
|
+
* @en HTTP method
|
|
50
|
+
*/
|
|
51
|
+
method: string;
|
|
52
|
+
/**
|
|
53
|
+
* @ru Хэш тела запроса (для кэширования)
|
|
54
|
+
* @en Request body hash (for caching)
|
|
55
|
+
*/
|
|
56
|
+
bodyHash?: string;
|
|
57
|
+
}
|
|
58
|
+
export type CircuitStateName = "CLOSED" | "OPEN" | "HALF_OPEN";
|
|
59
|
+
export type CircuitState = {
|
|
60
|
+
state: CircuitStateName;
|
|
61
|
+
failureScore: number;
|
|
62
|
+
consecutiveFailures: number;
|
|
63
|
+
lastFailureTime: number;
|
|
64
|
+
lastTransitionTime: number;
|
|
65
|
+
probeInFlight: boolean;
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/Types/metrics.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,gBAAgB,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/Types/metrics.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { LogLevel, Method } from "./http";
|
|
2
|
+
import { ResponseConverterOptions } from "./response";
|
|
3
|
+
export interface RetryOptions {
|
|
4
|
+
/**
|
|
5
|
+
* @ru Максимальное количество повторных попыток
|
|
6
|
+
* @en Maximum number of retry attempts
|
|
7
|
+
*/
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
/**
|
|
10
|
+
* @ru Базовая задержка между попытками (мс)
|
|
11
|
+
* @en Base delay between retries (ms)
|
|
12
|
+
*/
|
|
13
|
+
baseDelay?: number;
|
|
14
|
+
/**
|
|
15
|
+
* @ru Максимальная задержка между попытками (мс)
|
|
16
|
+
* @en Maximum retry delay (ms)
|
|
17
|
+
*/
|
|
18
|
+
maxDelay?: number;
|
|
19
|
+
/**
|
|
20
|
+
* @ru Коды HTTP, при которых выполняется retry
|
|
21
|
+
* @en HTTP status codes that trigger retry logic
|
|
22
|
+
*/
|
|
23
|
+
retryStatusCodes?: readonly number[];
|
|
24
|
+
/**
|
|
25
|
+
* @ru Добавлять случайный jitter к задержке
|
|
26
|
+
* @en Add randomness (jitter) to retry delay
|
|
27
|
+
*/
|
|
28
|
+
jitter?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface CacheOptions {
|
|
31
|
+
/**
|
|
32
|
+
* @ru Включить кэш
|
|
33
|
+
* @en Enable cache
|
|
34
|
+
*/
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @ru Время жизни кэша (мс)
|
|
38
|
+
* @en Cache time-to-live in milliseconds
|
|
39
|
+
*/
|
|
40
|
+
ttl?: number;
|
|
41
|
+
/**
|
|
42
|
+
* @ru Максимальный размер кэша
|
|
43
|
+
* @en Maximum cache size
|
|
44
|
+
*/
|
|
45
|
+
maxSize?: number;
|
|
46
|
+
/**
|
|
47
|
+
* @ru HTTP методы, которые можно кэшировать
|
|
48
|
+
* @en HTTP methods allowed to be cached
|
|
49
|
+
*/
|
|
50
|
+
methods?: readonly Method[];
|
|
51
|
+
}
|
|
52
|
+
export interface RateLimitOptions {
|
|
53
|
+
/**
|
|
54
|
+
* @ru Включить rate limit
|
|
55
|
+
* @en Enable rate limiting
|
|
56
|
+
*/
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @ru Максимальное число запросов
|
|
60
|
+
* @en Maximum number of requests
|
|
61
|
+
*/
|
|
62
|
+
maxRequests?: number;
|
|
63
|
+
/**
|
|
64
|
+
* @ru Окно времени (мс)
|
|
65
|
+
* @en Time window in milliseconds
|
|
66
|
+
*/
|
|
67
|
+
windowMs?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface NetworkOptions {
|
|
70
|
+
/**
|
|
71
|
+
* @ru Таймаут запроса (мс)
|
|
72
|
+
* @en Request timeout in milliseconds
|
|
73
|
+
*/
|
|
74
|
+
timeout?: number;
|
|
75
|
+
/**
|
|
76
|
+
* @ru Максимум одновременных запросов. 0 = без лимита
|
|
77
|
+
* @en Maximum concurrent requests. 0 = unlimited
|
|
78
|
+
*/
|
|
79
|
+
maxConcurrent?: number;
|
|
80
|
+
/**
|
|
81
|
+
* @ru Количество pipelined запросов на соединение
|
|
82
|
+
* @en Number of pipelined requests per connection
|
|
83
|
+
*/
|
|
84
|
+
pipelining?: number;
|
|
85
|
+
/**
|
|
86
|
+
* @ru Таймаут keep-alive соединения (мс)
|
|
87
|
+
* @en Keep-alive connection timeout in milliseconds
|
|
88
|
+
*/
|
|
89
|
+
keepAliveTimeout?: number;
|
|
90
|
+
/**
|
|
91
|
+
* @ru Отклонять недоверенные SSL сертификаты
|
|
92
|
+
* @en Reject unauthorized SSL certificates
|
|
93
|
+
*/
|
|
94
|
+
rejectUnauthorized?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* @ru Следовать за редиректами
|
|
97
|
+
* @en Follow HTTP redirects
|
|
98
|
+
*/
|
|
99
|
+
followRedirects?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @ru Максимум редиректов
|
|
102
|
+
* @en Maximum number of redirects to follow
|
|
103
|
+
*/
|
|
104
|
+
maxRedirects?: number;
|
|
105
|
+
/**
|
|
106
|
+
* @ru Максимальный размер ответа (байты)
|
|
107
|
+
* @en Maximum response body size in bytes
|
|
108
|
+
*/
|
|
109
|
+
maxResponseBytes?: number;
|
|
110
|
+
/**
|
|
111
|
+
* @ru Переключение режима HTTP/2 и HTTP/1.1
|
|
112
|
+
* @en Switching between HTTP/2 and HTTP/1.1 modes
|
|
113
|
+
*/
|
|
114
|
+
allowHttp2?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* @ru User-Agent заголовок
|
|
117
|
+
* @en User-Agent header string
|
|
118
|
+
*/
|
|
119
|
+
userAgent?: string;
|
|
120
|
+
/**
|
|
121
|
+
* @ru Функция валидации HTTP статуса
|
|
122
|
+
* @en Function to validate HTTP status code
|
|
123
|
+
* @param status - HTTP status code
|
|
124
|
+
* @returns `true` if status is valid
|
|
125
|
+
*/
|
|
126
|
+
validateStatus?: (status: number) => boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface MetricsOptions {
|
|
129
|
+
/**
|
|
130
|
+
* @ru Включить сбор метрик
|
|
131
|
+
* @en Enable metrics collection
|
|
132
|
+
*/
|
|
133
|
+
enabled?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* @ru Максимальное количество записей в истории.
|
|
136
|
+
* @en Maximum number of entries in history.
|
|
137
|
+
*/
|
|
138
|
+
maxHistory?: number;
|
|
139
|
+
/**
|
|
140
|
+
* @ru Время хранения метрик в миллисекундах.
|
|
141
|
+
* @en Time to keep metrics in milliseconds.
|
|
142
|
+
*/
|
|
143
|
+
ttl?: number;
|
|
144
|
+
/**
|
|
145
|
+
* @ru Глубина scope для circuit breaker: 1 = host + первый сегмент пути.
|
|
146
|
+
* @en Scope depth for circuit breaker: 1 = host + first path segment.
|
|
147
|
+
*/
|
|
148
|
+
scopeDepth?: number;
|
|
149
|
+
/**
|
|
150
|
+
* @ru Порог ошибки, после которого circuit breaker переходит в OPEN.
|
|
151
|
+
* @en Failure score threshold that opens the circuit breaker.
|
|
152
|
+
*/
|
|
153
|
+
failureThreshold?: number;
|
|
154
|
+
/**
|
|
155
|
+
* @ru Время охлаждения перед переходом в HALF_OPEN.
|
|
156
|
+
* @en Cooldown time before switching to HALF_OPEN.
|
|
157
|
+
*/
|
|
158
|
+
resetTimeout?: number;
|
|
159
|
+
/**
|
|
160
|
+
* @ru Порог "медленного" запроса в миллисекундах.
|
|
161
|
+
* @en Slow request threshold in milliseconds.
|
|
162
|
+
*/
|
|
163
|
+
slowRequestMs?: number;
|
|
164
|
+
/**
|
|
165
|
+
* @ru Веса ошибок для разных классов отказов.
|
|
166
|
+
* @en Failure weights for different failure classes.
|
|
167
|
+
*/
|
|
168
|
+
weights?: {
|
|
169
|
+
timeout?: number;
|
|
170
|
+
serverError?: number;
|
|
171
|
+
rateLimit?: number;
|
|
172
|
+
slowRequest?: number;
|
|
173
|
+
other?: number;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export interface QueueOptions {
|
|
177
|
+
/**
|
|
178
|
+
* @ru Включить очередь запросов
|
|
179
|
+
* @en Enable request queue
|
|
180
|
+
*/
|
|
181
|
+
enabled?: boolean;
|
|
182
|
+
}
|
|
183
|
+
export interface HttpClientOptions {
|
|
184
|
+
/**
|
|
185
|
+
* @ru Настройки сети
|
|
186
|
+
* @en Network configuration
|
|
187
|
+
*/
|
|
188
|
+
network?: Partial<NetworkOptions>;
|
|
189
|
+
/**
|
|
190
|
+
* @ru Настройки retry
|
|
191
|
+
* @en Retry configuration
|
|
192
|
+
*/
|
|
193
|
+
retry?: Partial<RetryOptions>;
|
|
194
|
+
/**
|
|
195
|
+
* @ru Настройки кэша
|
|
196
|
+
* @en Cache configuration
|
|
197
|
+
*/
|
|
198
|
+
cache?: Partial<CacheOptions>;
|
|
199
|
+
/**
|
|
200
|
+
* @ru Настройки rate limit
|
|
201
|
+
* @en Rate limiting configuration
|
|
202
|
+
*/
|
|
203
|
+
rateLimit?: Partial<RateLimitOptions>;
|
|
204
|
+
/**
|
|
205
|
+
* @ru Метрики
|
|
206
|
+
* @en Metrics configuration
|
|
207
|
+
*/
|
|
208
|
+
metrics?: Partial<MetricsOptions>;
|
|
209
|
+
/**
|
|
210
|
+
* @ru Очередь запросов
|
|
211
|
+
* @en Request queue configuration
|
|
212
|
+
*/
|
|
213
|
+
queue?: Partial<QueueOptions>;
|
|
214
|
+
/**
|
|
215
|
+
* @ru Конвертер ответа
|
|
216
|
+
* @en Response converter configuration
|
|
217
|
+
*/
|
|
218
|
+
responseConverter?: Partial<ResponseConverterOptions>;
|
|
219
|
+
/**
|
|
220
|
+
* @ru Логгер
|
|
221
|
+
* @en Logger function
|
|
222
|
+
* @param level - log level
|
|
223
|
+
* @param message - log message
|
|
224
|
+
* @param meta - additional metadata
|
|
225
|
+
*/
|
|
226
|
+
logger?: (level: LogLevel, message: string, meta?: unknown) => void;
|
|
227
|
+
/**
|
|
228
|
+
* @ru Режим verbose логов
|
|
229
|
+
* @en Enable verbose logging
|
|
230
|
+
*/
|
|
231
|
+
verbose?: boolean;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/Types/options.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/Types/options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/Types/queue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAEnD,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/Types/queue.ts"],"names":[],"mappings":""}
|