@hyperttp/core 1.1.11 → 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 +174 -9
- package/Core/HyperCore.d.ts.map +1 -1
- package/Core/HyperCore.js +337 -110
- 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 +19 -5
- package/transports/node.d.ts.map +1 -1
- package/transports/node.js +254 -126
- 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 -14
- package/transports/bun.d.ts.map +0 -1
- package/transports/bun.js +0 -164
- 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 -20
- package/types/transport.d.ts.map +0 -1
- package/types/transport.js +0 -2
- package/types/transport.js.map +0 -1
package/transports/node.js
CHANGED
|
@@ -1,145 +1,273 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import http from "node:http";
|
|
2
|
+
import https from "node:https";
|
|
3
|
+
import { Readable } from "node:stream";
|
|
4
|
+
const REDIRECT_STATUS_CODES = new Set([301, 302, 303, 307, 308]);
|
|
5
|
+
const DEFAULT_RETRY_STATUS_CODES = [502, 503, 504];
|
|
6
|
+
export function isRedirect(status) {
|
|
7
|
+
return REDIRECT_STATUS_CODES.has(status);
|
|
8
|
+
}
|
|
9
|
+
export function combineSignal(signal, timeoutMs) {
|
|
10
|
+
if (timeoutMs <= 0) {
|
|
11
|
+
return {
|
|
12
|
+
signal,
|
|
13
|
+
cancelTimer: () => { },
|
|
14
|
+
isTimeoutAbort: () => false,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const timeoutController = new AbortController();
|
|
18
|
+
const timer = setTimeout(() => timeoutController.abort(), timeoutMs);
|
|
19
|
+
let combinedSignal;
|
|
20
|
+
if (signal) {
|
|
21
|
+
if (typeof AbortSignal.any === "function") {
|
|
22
|
+
combinedSignal = AbortSignal.any([signal, timeoutController.signal]);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const onAbort = () => timeoutController.abort();
|
|
26
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
27
|
+
combinedSignal = timeoutController.signal;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
combinedSignal = timeoutController.signal;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
signal: combinedSignal,
|
|
35
|
+
cancelTimer: () => clearTimeout(timer),
|
|
36
|
+
isTimeoutAbort: () => timeoutController.signal.aborted,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function shouldRetry(status, retryOptions) {
|
|
40
|
+
const codes = retryOptions.retryStatusCodes;
|
|
41
|
+
if (codes && codes.length > 0) {
|
|
42
|
+
return codes.includes(status);
|
|
43
|
+
}
|
|
44
|
+
return DEFAULT_RETRY_STATUS_CODES.includes(status);
|
|
45
|
+
}
|
|
46
|
+
export function sleep(ms) {
|
|
47
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
48
|
+
}
|
|
49
|
+
export function calcDelay(attempt, retryOptions) {
|
|
50
|
+
const { baseDelay = 1000, maxDelay = 10000, jitter = true } = retryOptions;
|
|
51
|
+
const base = Math.min(baseDelay * 2 ** attempt, maxDelay);
|
|
52
|
+
return jitter ? base * (0.75 + Math.random() * 0.5) : base;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @ru Реализация ответа для стандартного Node.js транспорта.
|
|
56
|
+
*/
|
|
57
|
+
class NodeTransportResponse {
|
|
58
|
+
status;
|
|
59
|
+
headers;
|
|
60
|
+
url;
|
|
61
|
+
body;
|
|
62
|
+
baseUrl;
|
|
63
|
+
_rawBody;
|
|
64
|
+
_cachedText;
|
|
65
|
+
_cachedJson;
|
|
66
|
+
_cachedJsonReady = false;
|
|
67
|
+
constructor(status, headers, url, rawBody) {
|
|
68
|
+
this.status = status;
|
|
69
|
+
this.headers = headers;
|
|
70
|
+
this.url = url;
|
|
71
|
+
this._rawBody = rawBody;
|
|
72
|
+
this.baseUrl = url;
|
|
73
|
+
const stream = Readable.from([rawBody]);
|
|
74
|
+
Object.defineProperty(stream, "dump", {
|
|
75
|
+
value: () => Promise.resolve(),
|
|
76
|
+
writable: false,
|
|
77
|
+
enumerable: false,
|
|
78
|
+
configurable: true,
|
|
79
|
+
});
|
|
80
|
+
this.body = stream;
|
|
81
|
+
}
|
|
82
|
+
async text() {
|
|
83
|
+
if (this._cachedText === undefined) {
|
|
84
|
+
this._cachedText = this._rawBody.toString("utf-8");
|
|
85
|
+
}
|
|
86
|
+
return this._cachedText;
|
|
87
|
+
}
|
|
88
|
+
async json() {
|
|
89
|
+
if (this._cachedJsonReady) {
|
|
90
|
+
return this._cachedJson;
|
|
91
|
+
}
|
|
92
|
+
const text = await this.text();
|
|
93
|
+
if (!text.trim()) {
|
|
94
|
+
this._cachedJson = null;
|
|
95
|
+
this._cachedJsonReady = true;
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
this._cachedJson = JSON.parse(text);
|
|
99
|
+
this._cachedJsonReady = true;
|
|
100
|
+
return this._cachedJson;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @ru Высокопроизводительный транспорт на базе классических модулей http/https Node.js.
|
|
105
|
+
*/
|
|
5
106
|
export class NodeTransport {
|
|
6
|
-
|
|
7
|
-
|
|
107
|
+
config;
|
|
108
|
+
httpAgent;
|
|
109
|
+
httpsAgent;
|
|
8
110
|
constructor(config) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
: config.network.pipelining
|
|
17
|
-
: allowH2
|
|
18
|
-
? 100
|
|
19
|
-
: 1;
|
|
20
|
-
this.agent = new CookieAgent({
|
|
21
|
-
connections: concurrency === Infinity ? null : concurrency,
|
|
22
|
-
pipelining,
|
|
23
|
-
keepAliveTimeout: config.network?.keepAliveTimeout ?? 30000,
|
|
24
|
-
keepAliveMaxTimeout: config.network?.keepAliveTimeout ?? 30000,
|
|
25
|
-
clientTtl: 60000,
|
|
26
|
-
connect: { rejectUnauthorized: config.network?.rejectUnauthorized },
|
|
27
|
-
allowH2,
|
|
28
|
-
});
|
|
29
|
-
const retryOptions = {
|
|
30
|
-
maxRetries: config.retry?.maxRetries ?? 3,
|
|
31
|
-
...config.retry,
|
|
111
|
+
this.config = config;
|
|
112
|
+
const agentOptions = {
|
|
113
|
+
keepAlive: true,
|
|
114
|
+
keepAliveMsecs: config.network?.keepAliveTimeout ?? 30000,
|
|
115
|
+
maxSockets: config.network?.maxConcurrent ?? 500,
|
|
116
|
+
maxFreeSockets: Math.min(256, Math.floor((config.network?.maxConcurrent ?? 500) / 2)),
|
|
117
|
+
scheduling: "lifo",
|
|
32
118
|
};
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
retryOptions: retryOptions,
|
|
39
|
-
verbose: config.verbose ?? false,
|
|
40
|
-
logger: config.logger,
|
|
41
|
-
});
|
|
119
|
+
this.httpAgent = new http.Agent(agentOptions);
|
|
120
|
+
this.httpsAgent = new https.Agent(agentOptions);
|
|
121
|
+
}
|
|
122
|
+
get timeout() {
|
|
123
|
+
return this.config.network?.timeout ?? 30000;
|
|
42
124
|
}
|
|
43
125
|
async execute(req) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
126
|
+
let currentUrl = req.url;
|
|
127
|
+
let currentMethod = req.method;
|
|
128
|
+
let currentHeaders = { ...req.headers };
|
|
129
|
+
let currentBody = req.body;
|
|
130
|
+
let redirects = 0;
|
|
131
|
+
let attempt = 0;
|
|
132
|
+
const maxRedirects = this.config.network?.maxRedirects ?? 5;
|
|
133
|
+
const maxRetries = this.config.retry?.maxRetries ?? 3;
|
|
134
|
+
const isStreamBody = currentBody instanceof Readable;
|
|
135
|
+
while (true) {
|
|
136
|
+
const { signal, cancelTimer, isTimeoutAbort } = combineSignal(req.signal, this.timeout);
|
|
137
|
+
try {
|
|
138
|
+
const fullUrl = new URL(currentUrl);
|
|
139
|
+
const result = await this.dispatchOnce(fullUrl, {
|
|
140
|
+
method: currentMethod,
|
|
141
|
+
headers: currentHeaders,
|
|
142
|
+
body: currentBody,
|
|
143
|
+
signal,
|
|
144
|
+
});
|
|
145
|
+
if ((this.config.network?.followRedirects ?? true) &&
|
|
146
|
+
isRedirect(result.status)) {
|
|
147
|
+
if (redirects >= maxRedirects) {
|
|
148
|
+
throw new Error("Too many redirects");
|
|
149
|
+
}
|
|
150
|
+
const location = result.headers["location"];
|
|
151
|
+
if (location && typeof location === "string") {
|
|
152
|
+
const nextUrl = new URL(location, fullUrl.toString()).toString();
|
|
153
|
+
let nextMethod = currentMethod;
|
|
154
|
+
if (result.status === 303 ||
|
|
155
|
+
((result.status === 301 || result.status === 302) &&
|
|
156
|
+
currentMethod === "POST")) {
|
|
157
|
+
nextMethod = "GET";
|
|
158
|
+
}
|
|
159
|
+
currentUrl = nextUrl;
|
|
160
|
+
currentMethod = nextMethod;
|
|
161
|
+
currentBody =
|
|
162
|
+
nextMethod === "GET" || isStreamBody ? undefined : currentBody;
|
|
163
|
+
const nextHeaders = { ...currentHeaders };
|
|
164
|
+
if (nextMethod === "GET") {
|
|
165
|
+
delete nextHeaders["content-type"];
|
|
166
|
+
delete nextHeaders["content-length"];
|
|
167
|
+
}
|
|
168
|
+
currentHeaders = nextHeaders;
|
|
169
|
+
redirects += 1;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!isStreamBody &&
|
|
174
|
+
shouldRetry(result.status, this.config.retry ?? {})) {
|
|
175
|
+
if (attempt < maxRetries) {
|
|
176
|
+
await sleep(calcDelay(attempt, this.config.retry ?? {}));
|
|
177
|
+
attempt += 1;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return new NodeTransportResponse(result.status, result.headers, fullUrl.toString(), result.body);
|
|
57
182
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
183
|
+
catch (err) {
|
|
184
|
+
if (err.name === "AbortError" || isTimeoutAbort()) {
|
|
185
|
+
if (req.signal?.aborted)
|
|
186
|
+
throw err;
|
|
187
|
+
if (isTimeoutAbort()) {
|
|
188
|
+
throw new Error(`Request timeout after ${this.timeout}ms`, {
|
|
189
|
+
cause: err,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
throw new Error("Transport closed or aborted", { cause: err });
|
|
193
|
+
}
|
|
194
|
+
const retryableCodes = [
|
|
195
|
+
"ECONNREFUSED",
|
|
196
|
+
"ETIMEDOUT",
|
|
197
|
+
"ECONNRESET",
|
|
198
|
+
"EPIPE",
|
|
199
|
+
];
|
|
200
|
+
if (!isStreamBody &&
|
|
201
|
+
attempt < maxRetries &&
|
|
202
|
+
retryableCodes.includes(err.code)) {
|
|
203
|
+
await sleep(calcDelay(attempt, this.config.retry ?? {}));
|
|
204
|
+
attempt += 1;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
throw err;
|
|
61
208
|
}
|
|
62
|
-
|
|
63
|
-
|
|
209
|
+
finally {
|
|
210
|
+
cancelTimer();
|
|
64
211
|
}
|
|
65
212
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
213
|
+
}
|
|
214
|
+
dispatchOnce(url, options) {
|
|
215
|
+
return new Promise((resolve, reject) => {
|
|
216
|
+
const isHttps = url.protocol === "https:";
|
|
217
|
+
const requestFn = isHttps ? https.request : http.request;
|
|
218
|
+
const agent = isHttps ? this.httpsAgent : this.httpAgent;
|
|
219
|
+
const reqOptions = {
|
|
220
|
+
method: options.method,
|
|
221
|
+
headers: options.headers,
|
|
222
|
+
agent,
|
|
223
|
+
signal: options.signal,
|
|
224
|
+
};
|
|
225
|
+
if (options.signal?.aborted) {
|
|
226
|
+
const abortError = new Error("The operation was aborted.");
|
|
227
|
+
abortError.name = "AbortError";
|
|
228
|
+
return reject(abortError);
|
|
229
|
+
}
|
|
230
|
+
const req = requestFn(url, reqOptions, (res) => {
|
|
231
|
+
const chunks = [];
|
|
232
|
+
res.on("data", (chunk) => {
|
|
233
|
+
chunks.push(chunk);
|
|
234
|
+
});
|
|
235
|
+
res.on("end", () => {
|
|
236
|
+
const body = chunks.length === 0 ? Buffer.alloc(0) : Buffer.concat(chunks);
|
|
237
|
+
resolve({
|
|
238
|
+
status: res.statusCode ?? 200,
|
|
239
|
+
headers: res.headers,
|
|
240
|
+
body,
|
|
83
241
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
242
|
+
});
|
|
243
|
+
res.on("error", (err) => {
|
|
244
|
+
reject(err);
|
|
245
|
+
});
|
|
88
246
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return body;
|
|
103
|
-
}
|
|
104
|
-
let decompressor = null;
|
|
105
|
-
if (encoding === "gzip") {
|
|
106
|
-
decompressor = zlib.createGunzip({ flush: zlib.constants.Z_SYNC_FLUSH });
|
|
107
|
-
}
|
|
108
|
-
else if (encoding === "deflate") {
|
|
109
|
-
decompressor = zlib.createInflate();
|
|
110
|
-
}
|
|
111
|
-
else if (encoding === "br") {
|
|
112
|
-
decompressor = zlib.createBrotliDecompress();
|
|
113
|
-
}
|
|
114
|
-
if (!decompressor) {
|
|
115
|
-
return body;
|
|
116
|
-
}
|
|
117
|
-
const decompressedStream = pipeline(body, decompressor, (err) => {
|
|
118
|
-
if (err) {
|
|
119
|
-
decompressedStream.emit("error", err);
|
|
120
|
-
if (this.executor.verbose) {
|
|
121
|
-
console.error?.(`[Hyperttp] Decompression failed: ${err.message}`);
|
|
247
|
+
req.on("error", (err) => {
|
|
248
|
+
reject(err);
|
|
249
|
+
});
|
|
250
|
+
if (options.body !== undefined && options.body !== null) {
|
|
251
|
+
if (Buffer.isBuffer(options.body) || typeof options.body === "string") {
|
|
252
|
+
req.write(options.body);
|
|
253
|
+
}
|
|
254
|
+
else if (options.body instanceof Readable) {
|
|
255
|
+
options.body.pipe(req);
|
|
256
|
+
return; // Управление потоком передано pipe
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
req.write(JSON.stringify(options.body));
|
|
122
260
|
}
|
|
123
261
|
}
|
|
262
|
+
req.end();
|
|
124
263
|
});
|
|
125
|
-
|
|
264
|
+
}
|
|
265
|
+
async close() {
|
|
266
|
+
this.httpAgent.destroy();
|
|
267
|
+
this.httpsAgent.destroy();
|
|
126
268
|
}
|
|
127
269
|
async destroy() {
|
|
128
|
-
await
|
|
129
|
-
try {
|
|
130
|
-
const structuralAgent = this.agent;
|
|
131
|
-
if (typeof structuralAgent.close === "function") {
|
|
132
|
-
await structuralAgent.close();
|
|
133
|
-
}
|
|
134
|
-
else if (typeof structuralAgent.destroy === "function") {
|
|
135
|
-
await structuralAgent.destroy();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
if (this.executor.verbose) {
|
|
140
|
-
console.warn("Transport destroy error (likely race condition):", err);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
270
|
+
await this.close();
|
|
143
271
|
}
|
|
144
272
|
}
|
|
145
273
|
//# sourceMappingURL=node.js.map
|
package/transports/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/transports/node.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/transports/node.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAUvC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACjE,MAAM,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEnD,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,MAA+B,EAC/B,SAAiB;IAMjB,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,OAAO;YACL,MAAM;YACN,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;YACrB,cAAc,EAAE,GAAG,EAA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O,CAAC,mCAAmC;gBAC7C,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC;YAED,GAAG,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ru Базовый класс ошибок клиента Hyperttp, агрегирующий контекст неудачного сетевого запроса.
|
|
3
|
+
* @en Base error class for the Hyperttp client, providing explicit layout context for failed requests.
|
|
4
|
+
*/
|
|
5
|
+
export declare class HttpClientError extends Error {
|
|
6
|
+
code: string;
|
|
7
|
+
statusCode?: number | undefined;
|
|
8
|
+
originalError?: Error | undefined;
|
|
9
|
+
url?: string | undefined;
|
|
10
|
+
method?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* @ru Создает новый экземпляр HttpClientError.
|
|
13
|
+
* @en Creates a new HttpClientError instance.
|
|
14
|
+
* @param message - Human-readable error message text.
|
|
15
|
+
* @param code - Internal stringified error state identifier code.
|
|
16
|
+
* @param statusCode - Numerical HTTP response status code received from the server.
|
|
17
|
+
* @param originalError - Raw captured exception instance causing this failure.
|
|
18
|
+
* @param url - Targeted request URL destination string.
|
|
19
|
+
* @param method - HTTP method verb utilized for the request.
|
|
20
|
+
*/
|
|
21
|
+
constructor(message: string, code?: string, statusCode?: number | undefined, originalError?: Error | undefined, url?: string | undefined, method?: string | undefined);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @ru Ошибка, возникающая при превышении лимита времени ожидания ответа от сервера.
|
|
25
|
+
* @en Error thrown when a network request exceeds its allocated execution timeout threshold.
|
|
26
|
+
*/
|
|
27
|
+
export declare class TimeoutError extends HttpClientError {
|
|
28
|
+
/**
|
|
29
|
+
* @ru Создает новый экземпляр TimeoutError.
|
|
30
|
+
* @en Creates a new TimeoutError instance.
|
|
31
|
+
* @param url - Targeted request URL destination string.
|
|
32
|
+
* @param timeout - Threshold duration statement in milliseconds.
|
|
33
|
+
*/
|
|
34
|
+
constructor(url: string, timeout: number);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @ru Ошибка, генерируемая при получении HTTP-статуса 429 (превышение лимита частоты запросов).
|
|
38
|
+
* @en Error triggered when encountering an HTTP 429 status code indicating rate limit exhaustion.
|
|
39
|
+
*/
|
|
40
|
+
export declare class RateLimitError extends HttpClientError {
|
|
41
|
+
/**
|
|
42
|
+
* @ru Создает новый экземпляр RateLimitError.
|
|
43
|
+
* @en Creates a new RateLimitError instance.
|
|
44
|
+
* @param url - Targeted request URL destination string.
|
|
45
|
+
* @param retryAfter - Optional cool-down period duration in milliseconds before the next retry attempt.
|
|
46
|
+
*/
|
|
47
|
+
constructor(url: string, retryAfter?: number);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAa/B,IAAI,EAAE,MAAM;IACZ,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,KAAK;IACrB,GAAG,CAAC,EAAE,MAAM;IACZ,MAAM,CAAC,EAAE,MAAM;IAhBxB;;;;;;;;;OASG;gBAED,OAAO,EAAE,MAAM,EACR,IAAI,GAAE,MAAqB,EAC3B,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,KAAK,YAAA,EACrB,GAAG,CAAC,EAAE,MAAM,YAAA,EACZ,MAAM,CAAC,EAAE,MAAM,YAAA;CAKzB;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,eAAe;IAC/C;;;;;OAKG;gBACS,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAIzC;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,eAAe;IACjD;;;;;OAKG;gBACS,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAU7C"}
|
package/utils/errors.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ru Базовый класс ошибок клиента Hyperttp, агрегирующий контекст неудачного сетевого запроса.
|
|
3
|
+
* @en Base error class for the Hyperttp client, providing explicit layout context for failed requests.
|
|
4
|
+
*/
|
|
5
|
+
export class HttpClientError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
statusCode;
|
|
8
|
+
originalError;
|
|
9
|
+
url;
|
|
10
|
+
method;
|
|
11
|
+
/**
|
|
12
|
+
* @ru Создает новый экземпляр HttpClientError.
|
|
13
|
+
* @en Creates a new HttpClientError instance.
|
|
14
|
+
* @param message - Human-readable error message text.
|
|
15
|
+
* @param code - Internal stringified error state identifier code.
|
|
16
|
+
* @param statusCode - Numerical HTTP response status code received from the server.
|
|
17
|
+
* @param originalError - Raw captured exception instance causing this failure.
|
|
18
|
+
* @param url - Targeted request URL destination string.
|
|
19
|
+
* @param method - HTTP method verb utilized for the request.
|
|
20
|
+
*/
|
|
21
|
+
constructor(message, code = "HTTP_ERROR", statusCode, originalError, url, method) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.statusCode = statusCode;
|
|
25
|
+
this.originalError = originalError;
|
|
26
|
+
this.url = url;
|
|
27
|
+
this.method = method;
|
|
28
|
+
this.name = "HttpClientError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @ru Ошибка, возникающая при превышении лимита времени ожидания ответа от сервера.
|
|
33
|
+
* @en Error thrown when a network request exceeds its allocated execution timeout threshold.
|
|
34
|
+
*/
|
|
35
|
+
export class TimeoutError extends HttpClientError {
|
|
36
|
+
/**
|
|
37
|
+
* @ru Создает новый экземпляр TimeoutError.
|
|
38
|
+
* @en Creates a new TimeoutError instance.
|
|
39
|
+
* @param url - Targeted request URL destination string.
|
|
40
|
+
* @param timeout - Threshold duration statement in milliseconds.
|
|
41
|
+
*/
|
|
42
|
+
constructor(url, timeout) {
|
|
43
|
+
super(`Timeout after ${timeout}ms`, "TIMEOUT", 408, undefined, url);
|
|
44
|
+
this.name = "TimeoutError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @ru Ошибка, генерируемая при получении HTTP-статуса 429 (превышение лимита частоты запросов).
|
|
49
|
+
* @en Error triggered when encountering an HTTP 429 status code indicating rate limit exhaustion.
|
|
50
|
+
*/
|
|
51
|
+
export class RateLimitError extends HttpClientError {
|
|
52
|
+
/**
|
|
53
|
+
* @ru Создает новый экземпляр RateLimitError.
|
|
54
|
+
* @en Creates a new RateLimitError instance.
|
|
55
|
+
* @param url - Targeted request URL destination string.
|
|
56
|
+
* @param retryAfter - Optional cool-down period duration in milliseconds before the next retry attempt.
|
|
57
|
+
*/
|
|
58
|
+
constructor(url, retryAfter) {
|
|
59
|
+
super(`Rate limited${retryAfter ? ` retry in ${retryAfter}ms` : ""}`, "RATE_LIMIT", 429, undefined, url);
|
|
60
|
+
this.name = "RateLimitError";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAa/B;IACA;IACA;IACA;IACA;IAhBT;;;;;;;;;OASG;IACH,YACE,OAAe,EACR,OAAe,YAAY,EAC3B,UAAmB,EACnB,aAAqB,EACrB,GAAY,EACZ,MAAe;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QANR,SAAI,GAAJ,IAAI,CAAuB;QAC3B,eAAU,GAAV,UAAU,CAAS;QACnB,kBAAa,GAAb,aAAa,CAAQ;QACrB,QAAG,GAAH,GAAG,CAAS;QACZ,WAAM,GAAN,MAAM,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,eAAe;IAC/C;;;;;OAKG;IACH,YAAY,GAAW,EAAE,OAAe;QACtC,KAAK,CAAC,iBAAiB,OAAO,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,eAAe;IACjD;;;;;OAKG;IACH,YAAY,GAAW,EAAE,UAAmB;QAC1C,KAAK,CACH,eAAe,UAAU,CAAC,CAAC,CAAC,aAAa,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAC9D,YAAY,EACZ,GAAG,EACH,SAAS,EACT,GAAG,CACJ,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
|
package/utils/merge.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
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
|
+
*/
|
|
8
|
+
export declare function deepMerge<T extends Record<string, unknown>, S extends Record<string, unknown>>(target: T, source: S): T & S;
|
|
2
9
|
//# sourceMappingURL=merge.d.ts.map
|
package/utils/merge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/utils/merge.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/utils/merge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAuB7B"}
|