@hyperttp/core 1.1.12 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Core/HyperCore.d.ts +173 -8
- package/Core/HyperCore.d.ts.map +1 -1
- package/Core/HyperCore.js +329 -100
- package/Core/HyperCore.js.map +1 -1
- package/Core/index.d.ts +0 -1
- package/Core/index.d.ts.map +1 -1
- package/Core/index.js +0 -1
- package/Core/index.js.map +1 -1
- package/LICENSE +21 -0
- package/README.md +178 -0
- package/defaultConfig.d.ts +1 -1
- package/defaultConfig.d.ts.map +1 -1
- package/defaultConfig.js +0 -1
- package/defaultConfig.js.map +1 -1
- package/index.d.ts +1 -4
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +20 -6
- package/transports/node.d.ts +18 -7
- package/transports/node.d.ts.map +1 -1
- package/transports/node.js +255 -142
- package/transports/node.js.map +1 -1
- package/utils/errors.d.ts +49 -0
- package/utils/errors.d.ts.map +1 -0
- package/utils/errors.js +63 -0
- package/utils/errors.js.map +1 -0
- package/utils/merge.d.ts +8 -1
- package/utils/merge.d.ts.map +1 -1
- package/utils/merge.js +27 -13
- package/utils/merge.js.map +1 -1
- package/utils/response.d.ts +40 -0
- package/utils/response.d.ts.map +1 -0
- package/utils/response.js +79 -0
- package/utils/response.js.map +1 -0
- package/utils/retryUtils.d.ts +5 -0
- package/utils/retryUtils.d.ts.map +1 -0
- package/utils/retryUtils.js +35 -0
- package/utils/retryUtils.js.map +1 -0
- package/Core/RequestExecutor.d.ts +0 -64
- package/Core/RequestExecutor.d.ts.map +0 -1
- package/Core/RequestExecutor.js +0 -213
- package/Core/RequestExecutor.js.map +0 -1
- package/transports/bun.d.ts +0 -16
- package/transports/bun.d.ts.map +0 -1
- package/transports/bun.js +0 -181
- package/transports/bun.js.map +0 -1
- package/types/errors.d.ts +0 -20
- package/types/errors.d.ts.map +0 -1
- package/types/errors.js +0 -28
- package/types/errors.js.map +0 -1
- package/types/http.d.ts +0 -5
- package/types/http.d.ts.map +0 -1
- package/types/http.js +0 -2
- package/types/http.js.map +0 -1
- package/types/hyper.d.ts +0 -34
- package/types/hyper.d.ts.map +0 -1
- package/types/hyper.js +0 -2
- package/types/hyper.js.map +0 -1
- package/types/index.d.ts +0 -12
- package/types/index.d.ts.map +0 -1
- package/types/index.js +0 -12
- package/types/index.js.map +0 -1
- package/types/metrics.d.ts +0 -65
- package/types/metrics.d.ts.map +0 -1
- package/types/metrics.js +0 -2
- package/types/metrics.js.map +0 -1
- package/types/network.d.ts +0 -65
- package/types/network.d.ts.map +0 -1
- package/types/network.js +0 -2
- package/types/network.js.map +0 -1
- package/types/options.d.ts +0 -51
- package/types/options.d.ts.map +0 -1
- package/types/options.js +0 -2
- package/types/options.js.map +0 -1
- package/types/plugins.d.ts +0 -47
- package/types/plugins.d.ts.map +0 -1
- package/types/plugins.js +0 -2
- package/types/plugins.js.map +0 -1
- package/types/request.d.ts +0 -114
- package/types/request.d.ts.map +0 -1
- package/types/request.js +0 -2
- package/types/request.js.map +0 -1
- package/types/retry.d.ts +0 -28
- package/types/retry.d.ts.map +0 -1
- package/types/retry.js +0 -2
- package/types/retry.js.map +0 -1
- package/types/stream.d.ts +0 -39
- package/types/stream.d.ts.map +0 -1
- package/types/stream.js +0 -2
- package/types/stream.js.map +0 -1
- package/types/transport.d.ts +0 -25
- package/types/transport.d.ts.map +0 -1
- package/types/transport.js +0 -2
- package/types/transport.js.map +0 -1
package/utils/merge.js
CHANGED
|
@@ -1,25 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ru Рекурсивно объединяет два объекта. Избегает лишних аллокаций памяти и защищает от разделения ссылок nested-структур.
|
|
3
|
+
* @en Recursively merges two objects. Avoids redundant memory allocations and prevents shared reference leakage for nested structures.
|
|
4
|
+
* @param target - Foundational target base object layout.
|
|
5
|
+
* @param source - High-priority source object containing overrides.
|
|
6
|
+
* @returns New deeply merged intersection object.
|
|
7
|
+
*/
|
|
1
8
|
export function deepMerge(target, source) {
|
|
2
9
|
const output = { ...target };
|
|
3
10
|
if (isObject(target) && isObject(source)) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
11
|
+
for (const key in source) {
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13
|
+
const sourceValue = source[key];
|
|
14
|
+
const targetValue = output[key];
|
|
15
|
+
if (isObject(sourceValue)) {
|
|
16
|
+
if (key in output && isObject(targetValue)) {
|
|
17
|
+
output[key] = deepMerge(targetValue, sourceValue);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
output[key] = deepMerge({}, sourceValue);
|
|
21
|
+
}
|
|
10
22
|
}
|
|
11
|
-
else {
|
|
12
|
-
output[key] =
|
|
23
|
+
else if (sourceValue !== undefined) {
|
|
24
|
+
output[key] = sourceValue;
|
|
13
25
|
}
|
|
14
26
|
}
|
|
15
|
-
|
|
16
|
-
Object.assign(output, { [key]: sourceValue });
|
|
17
|
-
}
|
|
18
|
-
});
|
|
27
|
+
}
|
|
19
28
|
}
|
|
20
29
|
return output;
|
|
21
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* @ru Быстрая проверка, является ли переданный элемент чистым объектом (исключая массивы и null).
|
|
33
|
+
* @en Fast check verifying if the provided item is a plain object layout (excluding arrays and null).
|
|
34
|
+
* @param item - Evaluated runtime variable value context.
|
|
35
|
+
*/
|
|
22
36
|
function isObject(item) {
|
|
23
|
-
return
|
|
37
|
+
return typeof item === "object" && item !== null && !Array.isArray(item);
|
|
24
38
|
}
|
|
25
39
|
//# sourceMappingURL=merge.js.map
|
package/utils/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/utils/merge.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAGvB,MAAS,EAAE,MAAS;IACpB,MAAM,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,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { HttpResponse, HyperTransport, StreamResponse } from "@hyperttp/types";
|
|
2
|
+
type TransportResponse = Awaited<ReturnType<HyperTransport["execute"]>>;
|
|
3
|
+
/**
|
|
4
|
+
* @ru Высокопроизводительный глубокий клон тела ответа. Безопасно пропускает стримы и буферы без мутации рантайма.
|
|
5
|
+
* @en High-performance deep clone for response payloads. Safely bypasses streams and buffers to prevent runtime state mutations.
|
|
6
|
+
* @param body - Targeted data or stream context to clone.
|
|
7
|
+
*/
|
|
8
|
+
export declare const cloneBodyFast: <T>(body: T) => T;
|
|
9
|
+
/**
|
|
10
|
+
* @ru Контекстный обработчик для создания независимого изолированного клона объекта HttpResponse.
|
|
11
|
+
* @en Contextual execution handler to generate an isolated deep clone of the HttpResponse instance.
|
|
12
|
+
*/
|
|
13
|
+
export declare function responseCloneHandler<T>(this: HttpResponse<T>): HttpResponse<T>;
|
|
14
|
+
/**
|
|
15
|
+
* @ru Быстрый маппинг сырого низкоуровневого ответа сетевого транспорта в плоский объект Hyperttp.
|
|
16
|
+
* @en Fast mapping from raw low-level network transport response into flat Hyperttp object layouts.
|
|
17
|
+
* @param rawResponse - Target instance returned by a transport executor.
|
|
18
|
+
*/
|
|
19
|
+
export declare const mapResponseFast: (rawResponse: TransportResponse) => {
|
|
20
|
+
status: number;
|
|
21
|
+
headers: Record<string, string | string[]>;
|
|
22
|
+
body: import("@hyperttp/types").TransportResponsePayload;
|
|
23
|
+
url: string;
|
|
24
|
+
clone: typeof responseCloneHandler;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @ru Быстрый маппинг сырого ответа транспорта в специализированный объект потокового ответа StreamResponse.
|
|
28
|
+
* @en Fast mapping from raw transport context into a specialized streaming response StreamResponse layout.
|
|
29
|
+
* @param rawResponse - Target instance returned by a transport executor.
|
|
30
|
+
*/
|
|
31
|
+
export declare const mapStreamFast: (rawResponse: TransportResponse) => StreamResponse<unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* @ru Zero-allocation слияние заголовков. Полностью избегает вызовов `Object.keys()` и выделения массивов в куче.
|
|
34
|
+
* @en Zero-allocation headers merging layout. Completely avoids `Object.keys()` overhead and heavy heap array operations.
|
|
35
|
+
* @param base - Primary dictionary containing foundational header values.
|
|
36
|
+
* @param override - High-priority map containing overrides or additions.
|
|
37
|
+
*/
|
|
38
|
+
export declare const mergeHeadersFast: (base: Record<string, string | string[]>, override?: Record<string, string | string[]>) => Record<string, string | string[]>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/utils/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,KAAK,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,MAAM,CAAC,KAAG,CAsB1C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GACpB,YAAY,CAAC,CAAC,CAAC,CAQjB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,aAAa,iBAAiB;;;;;;CAM5D,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,aAAa,iBAAiB,KAC7B,cAAc,CAAC,OAAO,CAKvB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EACvC,WAAW,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,KAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CASlC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ru Высокопроизводительный глубокий клон тела ответа. Безопасно пропускает стримы и буферы без мутации рантайма.
|
|
3
|
+
* @en High-performance deep clone for response payloads. Safely bypasses streams and buffers to prevent runtime state mutations.
|
|
4
|
+
* @param body - Targeted data or stream context to clone.
|
|
5
|
+
*/
|
|
6
|
+
export const cloneBodyFast = (body) => {
|
|
7
|
+
if (typeof body !== "object" || body === null)
|
|
8
|
+
return body;
|
|
9
|
+
const obj = body;
|
|
10
|
+
if (body instanceof Uint8Array ||
|
|
11
|
+
typeof obj.pipe === "function" ||
|
|
12
|
+
typeof obj.getReader === "function") {
|
|
13
|
+
return body;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return structuredClone(body);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(JSON.stringify(body));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return { ...body };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @ru Контекстный обработчик для создания независимого изолированного клона объекта HttpResponse.
|
|
29
|
+
* @en Contextual execution handler to generate an isolated deep clone of the HttpResponse instance.
|
|
30
|
+
*/
|
|
31
|
+
export function responseCloneHandler() {
|
|
32
|
+
return {
|
|
33
|
+
status: this.status,
|
|
34
|
+
headers: { ...this.headers },
|
|
35
|
+
body: cloneBodyFast(this.body),
|
|
36
|
+
url: this.url,
|
|
37
|
+
clone: responseCloneHandler,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @ru Быстрый маппинг сырого низкоуровневого ответа сетевого транспорта в плоский объект Hyperttp.
|
|
42
|
+
* @en Fast mapping from raw low-level network transport response into flat Hyperttp object layouts.
|
|
43
|
+
* @param rawResponse - Target instance returned by a transport executor.
|
|
44
|
+
*/
|
|
45
|
+
export const mapResponseFast = (rawResponse) => ({
|
|
46
|
+
status: rawResponse.status,
|
|
47
|
+
headers: rawResponse.headers,
|
|
48
|
+
body: rawResponse.body,
|
|
49
|
+
url: rawResponse.url ?? "",
|
|
50
|
+
clone: responseCloneHandler,
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* @ru Быстрый маппинг сырого ответа транспорта в специализированный объект потокового ответа StreamResponse.
|
|
54
|
+
* @en Fast mapping from raw transport context into a specialized streaming response StreamResponse layout.
|
|
55
|
+
* @param rawResponse - Target instance returned by a transport executor.
|
|
56
|
+
*/
|
|
57
|
+
export const mapStreamFast = (rawResponse) => ({
|
|
58
|
+
status: rawResponse.status,
|
|
59
|
+
headers: rawResponse.headers,
|
|
60
|
+
body: rawResponse.body,
|
|
61
|
+
url: rawResponse.url ?? "",
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* @ru Zero-allocation слияние заголовков. Полностью избегает вызовов `Object.keys()` и выделения массивов в куче.
|
|
65
|
+
* @en Zero-allocation headers merging layout. Completely avoids `Object.keys()` overhead and heavy heap array operations.
|
|
66
|
+
* @param base - Primary dictionary containing foundational header values.
|
|
67
|
+
* @param override - High-priority map containing overrides or additions.
|
|
68
|
+
*/
|
|
69
|
+
export const mergeHeadersFast = (base, override) => {
|
|
70
|
+
if (!override)
|
|
71
|
+
return base;
|
|
72
|
+
for (const key in override) {
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(override, key)) {
|
|
74
|
+
return { ...base, ...override };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return base;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/utils/response.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,I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,CAC3B,WAA8B,EACL,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM;IAC1B,OAAO,EAAE,WAAW,CAAC,OAAO;IAC5B,IAAI,EAAE,WAAW,CAAC,IAAI;IACtB,GAAG,EAAE,WAAW,CAAC,GAAG,IAAI,EAAE;CAC3B,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAuC,EACvC,QAA4C,EACT,EAAE;IACrC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RetryOptions } from "@hyperttp/types";
|
|
2
|
+
export declare function calcDelay(attempt: number, retryOptions: RetryOptions): number;
|
|
3
|
+
export declare function drainBody(body: unknown): Promise<void>;
|
|
4
|
+
export declare function shouldRetry(status: number, retryOptions: RetryOptions): boolean;
|
|
5
|
+
//# sourceMappingURL=retryUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryUtils.d.ts","sourceRoot":"","sources":["../../src/utils/retryUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,CAK7E;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB5D;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,GACzB,OAAO,CAQT"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const DEFAULT_RETRY_STATUS_CODES = [502, 503, 504];
|
|
2
|
+
export function calcDelay(attempt, retryOptions) {
|
|
3
|
+
const { baseDelay = 1000, maxDelay = 10000, jitter = true } = retryOptions;
|
|
4
|
+
const base = Math.min(baseDelay * 2 ** attempt, maxDelay);
|
|
5
|
+
return jitter ? base * (0.75 + Math.random() * 0.5) : base;
|
|
6
|
+
}
|
|
7
|
+
export async function drainBody(body) {
|
|
8
|
+
if (!body || typeof body !== "object")
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
const stream = body;
|
|
12
|
+
if (typeof stream.dump === "function") {
|
|
13
|
+
await stream.dump();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (typeof stream.resume === "function") {
|
|
17
|
+
stream.resume();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (typeof stream.destroy === "function") {
|
|
21
|
+
stream.destroy();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
//
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function shouldRetry(status, retryOptions) {
|
|
29
|
+
const codes = retryOptions.retryStatusCodes;
|
|
30
|
+
if (codes && codes.length > 0) {
|
|
31
|
+
return codes.includes(status);
|
|
32
|
+
}
|
|
33
|
+
return DEFAULT_RETRY_STATUS_CODES.includes(status);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=retryUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryUtils.js","sourceRoot":"","sources":["../../src/utils/retryUtils.ts"],"names":[],"mappings":"AAEA,MAAM,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEnD,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,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AAC,MAAM,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Agent } from "undici";
|
|
2
|
-
import type { RetryOptions } from "../types/retry.js";
|
|
3
|
-
import type { LogLevel, ResponseType } from "../types/http.js";
|
|
4
|
-
import type { RequestMetrics } from "../types/metrics.js";
|
|
5
|
-
export type LowLevelResponse = {
|
|
6
|
-
status: number;
|
|
7
|
-
headers: Record<string, string | string[] | undefined>;
|
|
8
|
-
body: unknown;
|
|
9
|
-
url: string;
|
|
10
|
-
};
|
|
11
|
-
export interface InterceptorRequestConfig {
|
|
12
|
-
url: string;
|
|
13
|
-
method: string;
|
|
14
|
-
headers: Record<string, string | string[]>;
|
|
15
|
-
body: string | Buffer | undefined;
|
|
16
|
-
}
|
|
17
|
-
export interface DynamicInterceptor {
|
|
18
|
-
applyRequest(config: InterceptorRequestConfig): Promise<InterceptorRequestConfig>;
|
|
19
|
-
applyResponse(response: LowLevelResponse): Promise<LowLevelResponse>;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @en Low-level request executor responsible for handling the actual HTTP lifecycle.
|
|
23
|
-
* @ru Низкоуровневый исполнитель запросов, отвечающий за полный цикл HTTP-жизни.
|
|
24
|
-
*/
|
|
25
|
-
export declare class RequestExecutor {
|
|
26
|
-
private agent;
|
|
27
|
-
private options;
|
|
28
|
-
private readonly redirectStatusCodes;
|
|
29
|
-
constructor(agent: Agent, options: {
|
|
30
|
-
timeout: number;
|
|
31
|
-
maxRetries: number;
|
|
32
|
-
followRedirects: boolean;
|
|
33
|
-
maxRedirects: number;
|
|
34
|
-
retryOptions: RetryOptions;
|
|
35
|
-
verbose?: boolean;
|
|
36
|
-
logger?: (level: LogLevel, message: string, meta?: unknown) => void;
|
|
37
|
-
});
|
|
38
|
-
/**
|
|
39
|
-
* @en Executes a raw HTTP request.
|
|
40
|
-
* @ru Выполняет "сырой" HTTP-запрос.
|
|
41
|
-
*/
|
|
42
|
-
execute(method: string, url: string, headers: Record<string, string | string[]>, body: string | Buffer | undefined, signal?: AbortSignal, metrics?: RequestMetrics, interceptors?: DynamicInterceptor, meta?: {
|
|
43
|
-
responseType?: ResponseType;
|
|
44
|
-
}): Promise<LowLevelResponse>;
|
|
45
|
-
get verbose(): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* @en Calculates the delay for the next retry attempt using exponential backoff.
|
|
48
|
-
* @ru Вычисляет задержку для следующей попытки повтора.
|
|
49
|
-
*/
|
|
50
|
-
private calcDelay;
|
|
51
|
-
private sleep;
|
|
52
|
-
/**
|
|
53
|
-
* @en Ensures that the response body stream is properly closed to prevent memory leaks.
|
|
54
|
-
* @ru Гарантирует, что поток тела ответа корректно закрыт.
|
|
55
|
-
*/
|
|
56
|
-
private drainBody;
|
|
57
|
-
/**
|
|
58
|
-
* @en Checks if the status code should trigger a retry attempt.
|
|
59
|
-
* @ru Проверяет, должен ли данный статус-код вызывать повтор запроса.
|
|
60
|
-
*/
|
|
61
|
-
private shouldRetry;
|
|
62
|
-
private executeCore;
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=RequestExecutor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestExecutor.d.ts","sourceRoot":"","sources":["../../src/Core/RequestExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAU,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,IAAI,EAAE,OAAO,CA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C,IAAI,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,YAAY,CAAA;KAAE,GACrC,OAAO,CAAC,gBAAgB,CAAC;IAc5B,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;OAGG;IACH,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,KAAK;IAIb;;;OAGG;YACW,SAAS;IAqBvB;;;OAGG;IACH,OAAO,CAAC,WAAW;YAQL,WAAW;CAsL1B"}
|
package/Core/RequestExecutor.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { request } from "undici";
|
|
2
|
-
import { HttpClientError, TimeoutError } from "../types/errors.js";
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
* Статический интерцептор-заглушка. Исключает аллокацию объекта на каждый запрос.
|
|
6
|
-
*/
|
|
7
|
-
const defaultInterceptorManager = {
|
|
8
|
-
applyRequest: (config) => Promise.resolve(config),
|
|
9
|
-
applyResponse: (response) => Promise.resolve(response),
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @private
|
|
13
|
-
* Статический парсер тела ответа. Исключает создание замыканий внутри execute().
|
|
14
|
-
*/
|
|
15
|
-
const defaultBodyParser = (res) => Promise.resolve(res.body);
|
|
16
|
-
/**
|
|
17
|
-
* @en Low-level request executor responsible for handling the actual HTTP lifecycle.
|
|
18
|
-
* @ru Низкоуровневый исполнитель запросов, отвечающий за полный цикл HTTP-жизни.
|
|
19
|
-
*/
|
|
20
|
-
export class RequestExecutor {
|
|
21
|
-
agent;
|
|
22
|
-
options;
|
|
23
|
-
redirectStatusCodes = new Set([301, 302, 303, 307, 308]);
|
|
24
|
-
constructor(agent, options) {
|
|
25
|
-
this.agent = agent;
|
|
26
|
-
this.options = options;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @en Executes a raw HTTP request.
|
|
30
|
-
* @ru Выполняет "сырой" HTTP-запрос.
|
|
31
|
-
*/
|
|
32
|
-
async execute(method, url, headers, body, signal, metrics, interceptors, meta) {
|
|
33
|
-
return this.executeCore(method, url, headers, body, metrics, signal, defaultBodyParser, interceptors, meta?.responseType === "stream");
|
|
34
|
-
}
|
|
35
|
-
get verbose() {
|
|
36
|
-
return this.options.verbose ?? false;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @en Calculates the delay for the next retry attempt using exponential backoff.
|
|
40
|
-
* @ru Вычисляет задержку для следующей попытки повтора.
|
|
41
|
-
*/
|
|
42
|
-
calcDelay(attempt) {
|
|
43
|
-
const { baseDelay = 1000, maxDelay = 10000, jitter = true, } = this.options.retryOptions;
|
|
44
|
-
const base = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
|
|
45
|
-
return jitter ? base * (0.75 + Math.random() * 0.5) : base;
|
|
46
|
-
}
|
|
47
|
-
sleep(ms) {
|
|
48
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @en Ensures that the response body stream is properly closed to prevent memory leaks.
|
|
52
|
-
* @ru Гарантирует, что поток тела ответа корректно закрыт.
|
|
53
|
-
*/
|
|
54
|
-
async drainBody(body) {
|
|
55
|
-
if (!body || typeof body !== "object")
|
|
56
|
-
return;
|
|
57
|
-
try {
|
|
58
|
-
const stream = body;
|
|
59
|
-
if (typeof stream.dump === "function") {
|
|
60
|
-
await stream.dump();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (typeof stream.resume === "function") {
|
|
64
|
-
stream.resume();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (typeof stream.destroy === "function") {
|
|
68
|
-
stream.destroy();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
/* ignore */
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* @en Checks if the status code should trigger a retry attempt.
|
|
77
|
-
* @ru Проверяет, должен ли данный статус-код вызывать повтор запроса.
|
|
78
|
-
*/
|
|
79
|
-
shouldRetry(status) {
|
|
80
|
-
const codes = this.options.retryOptions.retryStatusCodes;
|
|
81
|
-
if (codes && codes.length > 0) {
|
|
82
|
-
return codes.includes(status);
|
|
83
|
-
}
|
|
84
|
-
return status === 502 || status === 503 || status === 504;
|
|
85
|
-
}
|
|
86
|
-
async executeCore(method, url, headers, body, metrics, signal, parser, interceptors, isStreaming = false) {
|
|
87
|
-
let currentUrl = url;
|
|
88
|
-
let currentMethod = method;
|
|
89
|
-
let currentHeaders = headers;
|
|
90
|
-
let currentBody = body;
|
|
91
|
-
let redirects = 0;
|
|
92
|
-
let attempt = 0;
|
|
93
|
-
const manager = interceptors ?? defaultInterceptorManager;
|
|
94
|
-
const timeoutValue = isStreaming ? 0 : this.options.timeout;
|
|
95
|
-
let timeoutController = undefined;
|
|
96
|
-
let timer = undefined;
|
|
97
|
-
let combinedSignal = signal;
|
|
98
|
-
if (timeoutValue > 0) {
|
|
99
|
-
timeoutController = new AbortController();
|
|
100
|
-
timer = setTimeout(() => timeoutController?.abort(), timeoutValue);
|
|
101
|
-
combinedSignal = signal
|
|
102
|
-
? AbortSignal.any([signal, timeoutController.signal])
|
|
103
|
-
: timeoutController.signal;
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
while (true) {
|
|
107
|
-
try {
|
|
108
|
-
const config = await manager.applyRequest({
|
|
109
|
-
url: currentUrl,
|
|
110
|
-
method: currentMethod,
|
|
111
|
-
headers: currentHeaders,
|
|
112
|
-
body: currentBody,
|
|
113
|
-
});
|
|
114
|
-
const res = await request(config.url, {
|
|
115
|
-
method: config.method,
|
|
116
|
-
headers: config.headers,
|
|
117
|
-
body: config.body,
|
|
118
|
-
dispatcher: this.agent,
|
|
119
|
-
signal: combinedSignal,
|
|
120
|
-
});
|
|
121
|
-
const status = res.statusCode;
|
|
122
|
-
const resHeaders = res.headers;
|
|
123
|
-
if (this.options.followRedirects &&
|
|
124
|
-
this.redirectStatusCodes.has(status)) {
|
|
125
|
-
if (redirects >= this.options.maxRedirects) {
|
|
126
|
-
await this.drainBody(res.body);
|
|
127
|
-
throw new HttpClientError("Too many redirects", "TOO_MANY_REDIRECTS", status);
|
|
128
|
-
}
|
|
129
|
-
const location = resHeaders.location;
|
|
130
|
-
if (location) {
|
|
131
|
-
await this.drainBody(res.body);
|
|
132
|
-
const nextUrl = new URL(location, config.url).toString();
|
|
133
|
-
let nextMethod = currentMethod;
|
|
134
|
-
if (status === 303 ||
|
|
135
|
-
((status === 301 || status === 302) && currentMethod === "POST")) {
|
|
136
|
-
nextMethod = "GET";
|
|
137
|
-
}
|
|
138
|
-
currentUrl = nextUrl;
|
|
139
|
-
currentMethod = nextMethod;
|
|
140
|
-
currentBody = nextMethod === "GET" ? undefined : currentBody;
|
|
141
|
-
if (nextMethod === "GET") {
|
|
142
|
-
const nextHeaders = { ...currentHeaders };
|
|
143
|
-
delete nextHeaders["content-type"];
|
|
144
|
-
delete nextHeaders["Content-Type"];
|
|
145
|
-
delete nextHeaders["content-length"];
|
|
146
|
-
delete nextHeaders["Content-Length"];
|
|
147
|
-
currentHeaders = nextHeaders;
|
|
148
|
-
}
|
|
149
|
-
redirects++;
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (this.shouldRetry(status)) {
|
|
154
|
-
if (attempt < this.options.maxRetries) {
|
|
155
|
-
if (metrics)
|
|
156
|
-
metrics.retries += 1;
|
|
157
|
-
await this.drainBody(res.body);
|
|
158
|
-
await this.sleep(this.calcDelay(attempt));
|
|
159
|
-
attempt++;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
throw new HttpClientError(`HTTP ${status}`, "HTTP_ERROR", status, undefined, config.url, currentMethod);
|
|
163
|
-
}
|
|
164
|
-
const transformed = await manager.applyResponse({
|
|
165
|
-
status,
|
|
166
|
-
headers: resHeaders,
|
|
167
|
-
body: res.body,
|
|
168
|
-
url: config.url,
|
|
169
|
-
});
|
|
170
|
-
const parsed = await parser(transformed);
|
|
171
|
-
return {
|
|
172
|
-
status: transformed.status,
|
|
173
|
-
headers: transformed.headers,
|
|
174
|
-
body: parsed,
|
|
175
|
-
url: transformed.url,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
catch (err) {
|
|
179
|
-
const errorTarget = err;
|
|
180
|
-
const errorName = errorTarget?.name;
|
|
181
|
-
const errorCode = errorTarget?.code;
|
|
182
|
-
if (errorName === "AbortError") {
|
|
183
|
-
if (signal?.aborted) {
|
|
184
|
-
throw new HttpClientError("Request aborted by user", "ABORTED", 0, err instanceof Error ? err : undefined, url, method);
|
|
185
|
-
}
|
|
186
|
-
if (timeoutController?.signal.aborted) {
|
|
187
|
-
throw new TimeoutError(url, this.options.timeout);
|
|
188
|
-
}
|
|
189
|
-
throw new HttpClientError("Request aborted due to transport closure or internal state reset", "TRANSPORT_CLOSED", 0, err instanceof Error ? err : undefined, url, method);
|
|
190
|
-
}
|
|
191
|
-
if (attempt < this.options.maxRetries &&
|
|
192
|
-
(errorCode === "ECONNREFUSED" ||
|
|
193
|
-
errorCode === "ETIMEDOUT" ||
|
|
194
|
-
errorCode === "ECONNRESET" ||
|
|
195
|
-
errorCode === "EPIPE" ||
|
|
196
|
-
errorCode === "UND_ERR_SOCKET")) {
|
|
197
|
-
if (metrics)
|
|
198
|
-
metrics.retries += 1;
|
|
199
|
-
await this.sleep(this.calcDelay(attempt));
|
|
200
|
-
attempt++;
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
throw err;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
finally {
|
|
208
|
-
if (timer)
|
|
209
|
-
clearTimeout(timer);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=RequestExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestExecutor.js","sourceRoot":"","sources":["../../src/Core/RequestExecutor.ts"],"names":[],"mappings":"AAAA,OAA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AED,IACE,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;wBACjC,CAAC,SAAS,KAAK,cAAc;4BAC3B,SAAS,KAAK,WAAW;4BACzB,SAAS,KAAK,YAAY;4BAC1B,SAAS,KAAK,OAAO;4BACrB,SAAS,KAAK,gBAAgB,CAAC,EACjC,CAAC;wBACD,IAAI,OAAO;4BAAE,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;wBAClC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;wBAC1C,OAAO,EAAE,CAAC;wBACV,SAAS;oBACX,CAAC;oBACD,MAAM,GAAG,CAAC;gBACZ,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
|
package/transports/bun.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { HttpClientOptions } from "../types/options.js";
|
|
2
|
-
import type { HyperTransport, TransportRequest, TransportResponse } from "../types/transport.js";
|
|
3
|
-
export declare class BunTransport implements HyperTransport {
|
|
4
|
-
private cookieJar;
|
|
5
|
-
private config;
|
|
6
|
-
private cookieCache;
|
|
7
|
-
private activeRequests;
|
|
8
|
-
private concurrencyQueue;
|
|
9
|
-
constructor(config: HttpClientOptions);
|
|
10
|
-
execute(req: TransportRequest): Promise<TransportResponse>;
|
|
11
|
-
private getCookiesForDomain;
|
|
12
|
-
private updateCookies;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
destroy(): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=bun.d.ts.map
|
package/transports/bun.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../../src/transports/bun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAc/B,qBAAa,YAAa,YAAW,cAAc;IACjD,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,WAAW,CAA6B;IAEhD,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,gBAAgB,CAAsB;gBAElC,MAAM,EAAE,iBAAiB;IAIxB,OAAO,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA2GvE,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,aAAa;IAqCR,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
|