hyperttp 0.4.9 → 0.4.11
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/Hyperttp/Client/HyperClient.d.ts +8 -0
- package/Hyperttp/Client/HyperClient.d.ts.map +1 -1
- package/Hyperttp/Client/HyperClient.js +2 -361
- package/Hyperttp/Client/HyperClient.js.map +7 -1
- package/Hyperttp/Request.d.ts +2 -2
- package/Hyperttp/Request.d.ts.map +1 -1
- package/Hyperttp/Request.js +2 -406
- package/Hyperttp/Request.js.map +7 -1
- package/Hyperttp/UrlExtractor.js +2 -123
- package/Hyperttp/UrlExtractor.js.map +7 -1
- package/Hyperttp/Utils/RequestBuilder.d.ts.map +1 -1
- package/Hyperttp/Utils/RequestBuilder.js +2 -298
- package/Hyperttp/Utils/RequestBuilder.js.map +7 -1
- package/Hyperttp/Utils/index.d.ts +1 -0
- package/Hyperttp/Utils/index.d.ts.map +1 -1
- package/Hyperttp/Utils/index.js +2 -2
- package/Hyperttp/Utils/index.js.map +7 -1
- package/Hyperttp/Utils/query.d.ts +3 -0
- package/Hyperttp/Utils/query.d.ts.map +1 -0
- package/Hyperttp/Utils/query.js +2 -0
- package/Hyperttp/Utils/query.js.map +7 -0
- package/Hyperttp/defaultConfig.js +2 -38
- package/Hyperttp/defaultConfig.js.map +7 -1
- package/Hyperttp/index.js +2 -6
- package/Hyperttp/index.js.map +7 -1
- package/README.md +1 -2
- package/Types/index.js +2 -2
- package/Types/index.js.map +7 -1
- package/Types/url-extractor.js +2 -2
- package/Types/url-extractor.js.map +7 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +2 -11
- package/index.js.map +7 -1
- package/package.json +2 -2
|
@@ -1,298 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* @ru Строитель запросов для удобного создания и настройки HTTP запросов.
|
|
4
|
-
* @en Request builder for convenient creation and configuration of HTTP requests.
|
|
5
|
-
*/
|
|
6
|
-
export class RequestBuilder {
|
|
7
|
-
_url;
|
|
8
|
-
_method = "GET";
|
|
9
|
-
_headers = {};
|
|
10
|
-
_body;
|
|
11
|
-
_responseType = "json";
|
|
12
|
-
_client;
|
|
13
|
-
_signal;
|
|
14
|
-
_queryParams = {};
|
|
15
|
-
/**
|
|
16
|
-
* @ru Создаёт экземпляр построителя запросов.
|
|
17
|
-
* @en Creates a request builder instance.
|
|
18
|
-
* @param url - Base URL for the request.
|
|
19
|
-
* @param client - HyperClient instance used to execute the request.
|
|
20
|
-
*/
|
|
21
|
-
constructor(url, client) {
|
|
22
|
-
this._url = url;
|
|
23
|
-
this._client = client;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* @ru Устанавливает HTTP метод.
|
|
27
|
-
* @en Sets the HTTP method.
|
|
28
|
-
* @param method - HTTP method (GET, POST, etc.).
|
|
29
|
-
* @returns This builder instance for chaining.
|
|
30
|
-
*/
|
|
31
|
-
method(method) {
|
|
32
|
-
this._method = method;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @ru Добавляет заголовки к запросу (мержит с существующими).
|
|
37
|
-
* @en Adds headers to the request (merges with existing ones).
|
|
38
|
-
* @param headers - Headers object to merge.
|
|
39
|
-
* @returns This builder instance for chaining.
|
|
40
|
-
*/
|
|
41
|
-
headers(headers) {
|
|
42
|
-
Object.assign(this._headers, headers);
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* @ru Устанавливает тело запроса (произвольные данные).
|
|
47
|
-
* @en Sets the request body (arbitrary data).
|
|
48
|
-
* @param bodyData - Request body data.
|
|
49
|
-
* @returns This builder instance for chaining.
|
|
50
|
-
*/
|
|
51
|
-
body(bodyData) {
|
|
52
|
-
this._body = bodyData;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @ru Устанавливает тело запроса в формате JSON и автоматически добавляет заголовок Content-Type: application/json.
|
|
57
|
-
* @en Sets the request body as JSON and automatically adds Content-Type: application/json header.
|
|
58
|
-
* @param body - JSON-serializable body.
|
|
59
|
-
* @returns This builder instance for chaining.
|
|
60
|
-
*/
|
|
61
|
-
jsonBody(body) {
|
|
62
|
-
this._body = body;
|
|
63
|
-
this._headers["Content-Type"] = "application/json; charset=utf-8";
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* @ru Добавляет параметры запроса (query string). Мержит с существующими.
|
|
68
|
-
* @en Adds query parameters to the URL (query string). Merges with existing ones.
|
|
69
|
-
* @param params - Object with query parameters (keys and values).
|
|
70
|
-
* @returns This builder instance for chaining.
|
|
71
|
-
*/
|
|
72
|
-
query(params) {
|
|
73
|
-
Object.assign(this._queryParams, params);
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @ru Устанавливает метод HTTP в GET.
|
|
78
|
-
* @en Sets HTTP method to GET.
|
|
79
|
-
* @returns This builder instance for chaining.
|
|
80
|
-
*/
|
|
81
|
-
get() {
|
|
82
|
-
this._method = "GET";
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* @ru Устанавливает метод HTTP в POST.
|
|
87
|
-
* @en Sets HTTP method to POST.
|
|
88
|
-
* @returns This builder instance for chaining.
|
|
89
|
-
*/
|
|
90
|
-
post() {
|
|
91
|
-
this._method = "POST";
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* @ru Устанавливает метод HTTP в PUT.
|
|
96
|
-
* @en Sets HTTP method to PUT.
|
|
97
|
-
* @returns This builder instance for chaining.
|
|
98
|
-
*/
|
|
99
|
-
put() {
|
|
100
|
-
this._method = "PUT";
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* @ru Устанавливает метод HTTP в PATCH.
|
|
105
|
-
* @en Sets HTTP method to PATCH.
|
|
106
|
-
* @returns This builder instance for chaining.
|
|
107
|
-
*/
|
|
108
|
-
patch() {
|
|
109
|
-
this._method = "PATCH";
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* @ru Устанавливает метод HTTP в DELETE.
|
|
114
|
-
* @en Sets HTTP method to DELETE.
|
|
115
|
-
* @returns This builder instance for chaining.
|
|
116
|
-
*/
|
|
117
|
-
delete() {
|
|
118
|
-
this._method = "DELETE";
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @ru Устанавливает метод HTTP в HEAD.
|
|
123
|
-
* @en Sets HTTP method to HEAD.
|
|
124
|
-
* @returns This builder instance for chaining.
|
|
125
|
-
*/
|
|
126
|
-
head() {
|
|
127
|
-
this._method = "HEAD";
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* @ru Устанавливает метод HTTP в OPTIONS.
|
|
132
|
-
* @en Sets HTTP method to OPTIONS.
|
|
133
|
-
* @returns This builder instance for chaining.
|
|
134
|
-
*/
|
|
135
|
-
options() {
|
|
136
|
-
this._method = "OPTIONS";
|
|
137
|
-
return this;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @ru Устанавливает ожидаемый тип ответа в JSON (по умолчанию).
|
|
141
|
-
* @en Sets expected response type to JSON (default).
|
|
142
|
-
* @returns This builder instance for chaining.
|
|
143
|
-
*/
|
|
144
|
-
json() {
|
|
145
|
-
this._responseType = "json";
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* @ru Устанавливает ожидаемый тип ответа в текст (string).
|
|
150
|
-
* @en Sets expected response type to text (string).
|
|
151
|
-
* @returns This builder instance for chaining.
|
|
152
|
-
*/
|
|
153
|
-
text() {
|
|
154
|
-
this._responseType = "text";
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* @ru Устанавливает ожидаемый тип ответа в XML.
|
|
159
|
-
* @en Sets expected response type to XML.
|
|
160
|
-
* @returns This builder instance for chaining.
|
|
161
|
-
*/
|
|
162
|
-
xml() {
|
|
163
|
-
this._responseType = "xml";
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* @ru Устанавливает ожидаемый тип ответа в HTML.
|
|
168
|
-
* @en Sets expected response type to HTML.
|
|
169
|
-
* @returns This builder instance for chaining.
|
|
170
|
-
*/
|
|
171
|
-
html() {
|
|
172
|
-
this._responseType = "html";
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* @ru Устанавливает ожидаемый тип ответа в буфер (Buffer / Uint8Array).
|
|
177
|
-
* @en Sets expected response type to buffer (Buffer / Uint8Array).
|
|
178
|
-
* @returns This builder instance for chaining.
|
|
179
|
-
*/
|
|
180
|
-
buffer() {
|
|
181
|
-
this._responseType = "buffer";
|
|
182
|
-
return this;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* @ru Устанавливает ожидаемый тип ответа в поток (ReadableStream).
|
|
186
|
-
* @en Sets expected response type to stream (ReadableStream).
|
|
187
|
-
* @returns This builder instance for chaining.
|
|
188
|
-
*/
|
|
189
|
-
stream() {
|
|
190
|
-
this._responseType = "stream";
|
|
191
|
-
return this;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @ru Устанавливает сигнал для отмены запроса (AbortSignal).
|
|
195
|
-
* @en Sets an abort signal for the request.
|
|
196
|
-
* @param signal - AbortSignal instance.
|
|
197
|
-
* @returns This builder instance for chaining.
|
|
198
|
-
*/
|
|
199
|
-
signal(signal) {
|
|
200
|
-
this._signal = signal;
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* @ru Устанавливает таймаут запроса в миллисекундах. Создаёт AbortSignal.timeout.
|
|
205
|
-
* @en Sets a request timeout in milliseconds. Creates an AbortSignal.timeout.
|
|
206
|
-
* @param ms - Timeout in milliseconds.
|
|
207
|
-
* @returns This builder instance for chaining.
|
|
208
|
-
*/
|
|
209
|
-
timeout(ms) {
|
|
210
|
-
this._signal = AbortSignal.timeout(ms);
|
|
211
|
-
return this;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* @ru Создаёт копию текущего builder'а.
|
|
215
|
-
* @en Creates a clone of the current builder.
|
|
216
|
-
* @returns New RequestBuilder instance with the same configuration.
|
|
217
|
-
*/
|
|
218
|
-
clone() {
|
|
219
|
-
const cloned = new RequestBuilder(this._url, this._client);
|
|
220
|
-
cloned._method = this._method;
|
|
221
|
-
cloned._headers = { ...this._headers };
|
|
222
|
-
cloned._body = this._body;
|
|
223
|
-
cloned._responseType = this._responseType;
|
|
224
|
-
cloned._signal = this._signal;
|
|
225
|
-
cloned._queryParams = { ...this._queryParams };
|
|
226
|
-
return cloned;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* @ru Формирует объект запроса RequestInterface из текущих настроек.
|
|
230
|
-
* @en Builds a RequestInterface object from current settings.
|
|
231
|
-
* @returns RequestInterface ready for dispatching.
|
|
232
|
-
*/
|
|
233
|
-
toRequest() {
|
|
234
|
-
let finalUrl = this._url;
|
|
235
|
-
if (Object.keys(this._queryParams).length > 0) {
|
|
236
|
-
const urlObj = new URL(this._url);
|
|
237
|
-
for (const k in this._queryParams) {
|
|
238
|
-
if (Object.prototype.hasOwnProperty.call(this._queryParams, k)) {
|
|
239
|
-
const v = this._queryParams[k];
|
|
240
|
-
if (v == null)
|
|
241
|
-
continue;
|
|
242
|
-
if (Array.isArray(v)) {
|
|
243
|
-
for (const item of v) {
|
|
244
|
-
if (item != null)
|
|
245
|
-
urlObj.searchParams.append(k, String(item));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
urlObj.searchParams.set(k, String(v));
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
finalUrl = urlObj.toString();
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
url: finalUrl,
|
|
257
|
-
headers: this._headers,
|
|
258
|
-
body: this._body,
|
|
259
|
-
signal: this._signal,
|
|
260
|
-
meta: { responseType: this._responseType },
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* @ru Выполняет запрос с текущими настройками и возвращает Promise с результатом.
|
|
265
|
-
* @en Executes the request with current settings and returns a Promise with the result.
|
|
266
|
-
* @template T - Expected response type.
|
|
267
|
-
* @returns Promise resolving to the response (type depends on responseType).
|
|
268
|
-
*/
|
|
269
|
-
send() {
|
|
270
|
-
const req = this.toRequest();
|
|
271
|
-
const responseType = this._responseType;
|
|
272
|
-
const signal = this._signal;
|
|
273
|
-
if (responseType === "stream") {
|
|
274
|
-
return this._client.stream(req, signal);
|
|
275
|
-
}
|
|
276
|
-
if (this._method === "HEAD") {
|
|
277
|
-
return this._client.head(req, signal);
|
|
278
|
-
}
|
|
279
|
-
const hasBody = ["POST", "PUT", "PATCH", "OPTIONS"].includes(this._method);
|
|
280
|
-
switch (this._method) {
|
|
281
|
-
case "GET":
|
|
282
|
-
return this._client.get(req, responseType, signal);
|
|
283
|
-
case "POST":
|
|
284
|
-
return this._client.post(req, responseType, this._body, signal);
|
|
285
|
-
case "PUT":
|
|
286
|
-
return this._client.put(req, responseType, this._body, signal);
|
|
287
|
-
case "PATCH":
|
|
288
|
-
return this._client.patch(req, responseType, this._body, signal);
|
|
289
|
-
case "DELETE":
|
|
290
|
-
return this._client.delete(req, responseType, signal);
|
|
291
|
-
case "OPTIONS":
|
|
292
|
-
return this._client.options(req, responseType, hasBody ? this._body : undefined, signal);
|
|
293
|
-
default:
|
|
294
|
-
return this._client.get(req, responseType, signal);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
//# sourceMappingURL=RequestBuilder.js.map
|
|
1
|
+
"use strict";import"../Client/HyperClient.js";import{appendQueryToUrl as i}from"./query.js";export class RequestBuilder{_url;_method="GET";_headers={};_body;_responseType="json";_client;_signal;_queryParams={};constructor(t,e){this._url=t,this._client=e}method(t){return this._method=t,this}headers(t){return Object.assign(this._headers,t),this}body(t){return this._body=t,this}jsonBody(t){return this._body=t,this._headers["Content-Type"]="application/json; charset=utf-8",this}query(t){return Object.assign(this._queryParams,t),this}get(){return this._method="GET",this}post(){return this._method="POST",this}put(){return this._method="PUT",this}patch(){return this._method="PATCH",this}delete(){return this._method="DELETE",this}head(){return this._method="HEAD",this}options(){return this._method="OPTIONS",this}json(){return this._responseType="json",this}text(){return this._responseType="text",this}xml(){return this._responseType="xml",this}html(){return this._responseType="html",this}buffer(){return this._responseType="buffer",this}stream(){return this._responseType="stream",this}signal(t){return this._signal=t,this}timeout(t){return this._signal=AbortSignal.timeout(t),this}clone(){const t=new RequestBuilder(this._url,this._client);return t._method=this._method,t._headers={...this._headers},t._body=this._body,t._responseType=this._responseType,t._signal=this._signal,t._queryParams={...this._queryParams},t}toRequest(){let t=this._url;return Object.keys(this._queryParams).length>0&&(t=i(this._url,this._queryParams)),{url:t,headers:this._headers,body:this._body,signal:this._signal,meta:{responseType:this._responseType}}}send(){const t=this.toRequest(),e=this._responseType,s=this._signal;if(e==="stream")return this._client.stream(t,s);if(this._method==="HEAD")return this._client.head(t,s);const r=["POST","PUT","PATCH","OPTIONS"].includes(this._method);switch(this._method){case"GET":return this._client.get(t,e,s);case"POST":return this._client.post(t,e,this._body,s);case"PUT":return this._client.put(t,e,this._body,s);case"PATCH":return this._client.patch(t,e,this._body,s);case"DELETE":return this._client.delete(t,e,s);case"OPTIONS":return this._client.options(t,e,r?this._body:void 0,s);default:return this._client.get(t,e,s)}}}
|
|
2
|
+
//# sourceMappingURL=RequestBuilder.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Hyperttp/Utils/RequestBuilder.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Method, RequestInterface, ResponseType, RequestQuery } from \"@hyperttp/types\";\nimport { HyperClient } from \"../Client/HyperClient.js\";\nimport { appendQueryToUrl } from \"./query.js\";\n\n/**\n * @ru \u0421\u0442\u0440\u043E\u0438\u0442\u0435\u043B\u044C \u0437\u0430\u043F\u0440\u043E\u0441\u043E\u0432 \u0434\u043B\u044F \u0443\u0434\u043E\u0431\u043D\u043E\u0433\u043E \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u0438 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 HTTP \u0437\u0430\u043F\u0440\u043E\u0441\u043E\u0432.\n * @en Request builder for convenient creation and configuration of HTTP requests.\n */\nexport class RequestBuilder {\n private _url: string;\n private _method: Method = \"GET\";\n private _headers: Record<string, string> = {};\n private _body?: unknown;\n private _responseType: ResponseType = \"json\";\n private _client: HyperClient;\n private _signal?: AbortSignal;\n private _queryParams: RequestQuery = {};\n\n /**\n * @ru \u0421\u043E\u0437\u0434\u0430\u0451\u0442 \u044D\u043A\u0437\u0435\u043C\u043F\u043B\u044F\u0440 \u043F\u043E\u0441\u0442\u0440\u043E\u0438\u0442\u0435\u043B\u044F \u0437\u0430\u043F\u0440\u043E\u0441\u043E\u0432.\n * @en Creates a request builder instance.\n * @param url - Base URL for the request.\n * @param client - HyperClient instance used to execute the request.\n */\n constructor(url: string, client: HyperClient) {\n this._url = url;\n this._client = client;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 HTTP \u043C\u0435\u0442\u043E\u0434.\n * @en Sets the HTTP method.\n * @param method - HTTP method (GET, POST, etc.).\n * @returns This builder instance for chaining.\n */\n method(method: Method): this {\n this._method = method;\n return this;\n }\n\n /**\n * @ru \u0414\u043E\u0431\u0430\u0432\u043B\u044F\u0435\u0442 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0438 \u043A \u0437\u0430\u043F\u0440\u043E\u0441\u0443 (\u043C\u0435\u0440\u0436\u0438\u0442 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044E\u0449\u0438\u043C\u0438).\n * @en Adds headers to the request (merges with existing ones).\n * @param headers - Headers object to merge.\n * @returns This builder instance for chaining.\n */\n headers(headers: Record<string, string>): this {\n Object.assign(this._headers, headers);\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043B\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0430 (\u043F\u0440\u043E\u0438\u0437\u0432\u043E\u043B\u044C\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435).\n * @en Sets the request body (arbitrary data).\n * @param bodyData - Request body data.\n * @returns This builder instance for chaining.\n */\n body(bodyData: unknown): this {\n this._body = bodyData;\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043B\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 JSON \u0438 \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438 \u0434\u043E\u0431\u0430\u0432\u043B\u044F\u0435\u0442 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A Content-Type: application/json.\n * @en Sets the request body as JSON and automatically adds Content-Type: application/json header.\n * @param body - JSON-serializable body.\n * @returns This builder instance for chaining.\n */\n jsonBody(body: unknown): this {\n this._body = body;\n this._headers[\"Content-Type\"] = \"application/json; charset=utf-8\";\n return this;\n }\n\n /**\n * @ru \u0414\u043E\u0431\u0430\u0432\u043B\u044F\u0435\u0442 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0437\u0430\u043F\u0440\u043E\u0441\u0430 (query string). \u041C\u0435\u0440\u0436\u0438\u0442 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044E\u0449\u0438\u043C\u0438.\n * @en Adds query parameters to the URL (query string). Merges with existing ones.\n * @param params - Object with query parameters (keys and values).\n * @returns This builder instance for chaining.\n */\n query(params: RequestQuery): this {\n Object.assign(this._queryParams, params);\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043C\u0435\u0442\u043E\u0434 HTTP \u0432 GET.\n * @en Sets HTTP method to GET.\n * @returns This builder instance for chaining.\n */\n get(): this {\n this._method = \"GET\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043C\u0435\u0442\u043E\u0434 HTTP \u0432 POST.\n * @en Sets HTTP method to POST.\n * @returns This builder instance for chaining.\n */\n post(): this {\n this._method = \"POST\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043C\u0435\u0442\u043E\u0434 HTTP \u0432 PUT.\n * @en Sets HTTP method to PUT.\n * @returns This builder instance for chaining.\n */\n put(): this {\n this._method = \"PUT\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043C\u0435\u0442\u043E\u0434 HTTP \u0432 PATCH.\n * @en Sets HTTP method to PATCH.\n * @returns This builder instance for chaining.\n */\n patch(): this {\n this._method = \"PATCH\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043C\u0435\u0442\u043E\u0434 HTTP \u0432 DELETE.\n * @en Sets HTTP method to DELETE.\n * @returns This builder instance for chaining.\n */\n delete(): this {\n this._method = \"DELETE\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043C\u0435\u0442\u043E\u0434 HTTP \u0432 HEAD.\n * @en Sets HTTP method to HEAD.\n * @returns This builder instance for chaining.\n */\n head(): this {\n this._method = \"HEAD\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043C\u0435\u0442\u043E\u0434 HTTP \u0432 OPTIONS.\n * @en Sets HTTP method to OPTIONS.\n * @returns This builder instance for chaining.\n */\n options(): this {\n this._method = \"OPTIONS\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043E\u0442\u0432\u0435\u0442\u0430 \u0432 JSON (\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E).\n * @en Sets expected response type to JSON (default).\n * @returns This builder instance for chaining.\n */\n json(): this {\n this._responseType = \"json\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043E\u0442\u0432\u0435\u0442\u0430 \u0432 \u0442\u0435\u043A\u0441\u0442 (string).\n * @en Sets expected response type to text (string).\n * @returns This builder instance for chaining.\n */\n text(): this {\n this._responseType = \"text\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043E\u0442\u0432\u0435\u0442\u0430 \u0432 XML.\n * @en Sets expected response type to XML.\n * @returns This builder instance for chaining.\n */\n xml(): this {\n this._responseType = \"xml\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043E\u0442\u0432\u0435\u0442\u0430 \u0432 HTML.\n * @en Sets expected response type to HTML.\n * @returns This builder instance for chaining.\n */\n html(): this {\n this._responseType = \"html\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043E\u0442\u0432\u0435\u0442\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440 (Buffer / Uint8Array).\n * @en Sets expected response type to buffer (Buffer / Uint8Array).\n * @returns This builder instance for chaining.\n */\n buffer(): this {\n this._responseType = \"buffer\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u043E\u0436\u0438\u0434\u0430\u0435\u043C\u044B\u0439 \u0442\u0438\u043F \u043E\u0442\u0432\u0435\u0442\u0430 \u0432 \u043F\u043E\u0442\u043E\u043A (ReadableStream).\n * @en Sets expected response type to stream (ReadableStream).\n * @returns This builder instance for chaining.\n */\n stream(): this {\n this._responseType = \"stream\";\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u0441\u0438\u0433\u043D\u0430\u043B \u0434\u043B\u044F \u043E\u0442\u043C\u0435\u043D\u044B \u0437\u0430\u043F\u0440\u043E\u0441\u0430 (AbortSignal).\n * @en Sets an abort signal for the request.\n * @param signal - AbortSignal instance.\n * @returns This builder instance for chaining.\n */\n signal(signal: AbortSignal): this {\n this._signal = signal;\n return this;\n }\n\n /**\n * @ru \u0423\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u0435\u0442 \u0442\u0430\u0439\u043C\u0430\u0443\u0442 \u0437\u0430\u043F\u0440\u043E\u0441\u0430 \u0432 \u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434\u0430\u0445. \u0421\u043E\u0437\u0434\u0430\u0451\u0442 AbortSignal.timeout.\n * @en Sets a request timeout in milliseconds. Creates an AbortSignal.timeout.\n * @param ms - Timeout in milliseconds.\n * @returns This builder instance for chaining.\n */\n timeout(ms: number): this {\n this._signal = AbortSignal.timeout(ms);\n return this;\n }\n\n /**\n * @ru \u0421\u043E\u0437\u0434\u0430\u0451\u0442 \u043A\u043E\u043F\u0438\u044E \u0442\u0435\u043A\u0443\u0449\u0435\u0433\u043E builder'\u0430.\n * @en Creates a clone of the current builder.\n * @returns New RequestBuilder instance with the same configuration.\n */\n clone(): RequestBuilder {\n const cloned = new RequestBuilder(this._url, this._client);\n cloned._method = this._method;\n cloned._headers = { ...this._headers };\n cloned._body = this._body;\n cloned._responseType = this._responseType;\n cloned._signal = this._signal;\n cloned._queryParams = { ...this._queryParams };\n return cloned;\n }\n\n /**\n * @ru \u0424\u043E\u0440\u043C\u0438\u0440\u0443\u0435\u0442 \u043E\u0431\u044A\u0435\u043A\u0442 \u0437\u0430\u043F\u0440\u043E\u0441\u0430 RequestInterface \u0438\u0437 \u0442\u0435\u043A\u0443\u0449\u0438\u0445 \u043D\u0430\u0441\u0442\u0440\u043E\u0435\u043A.\n * @en Builds a RequestInterface object from current settings.\n * @returns RequestInterface ready for dispatching.\n */\n private toRequest(): RequestInterface {\n let finalUrl = this._url;\n\n if (Object.keys(this._queryParams).length > 0) {\n finalUrl = appendQueryToUrl(this._url, this._queryParams);\n }\n\n return {\n url: finalUrl,\n headers: this._headers,\n body: this._body,\n signal: this._signal,\n meta: { responseType: this._responseType },\n };\n }\n\n /**\n * @ru \u0412\u044B\u043F\u043E\u043B\u043D\u044F\u0435\u0442 \u0437\u0430\u043F\u0440\u043E\u0441 \u0441 \u0442\u0435\u043A\u0443\u0449\u0438\u043C\u0438 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430\u043C\u0438 \u0438 \u0432\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Promise \u0441 \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u043E\u043C.\n * @en Executes the request with current settings and returns a Promise with the result.\n * @template T - Expected response type.\n * @returns Promise resolving to the response (type depends on responseType).\n */\n send<T = unknown>(): Promise<T> {\n const req = this.toRequest();\n const responseType = this._responseType;\n const signal = this._signal;\n\n if (responseType === \"stream\") {\n return this._client.stream(req, signal) as Promise<T>;\n }\n\n if (this._method === \"HEAD\") {\n return this._client.head(req, signal) as unknown as Promise<T>;\n }\n\n const hasBody = [\"POST\", \"PUT\", \"PATCH\", \"OPTIONS\"].includes(this._method);\n\n switch (this._method) {\n case \"GET\":\n return this._client.get<T>(req, responseType, signal);\n case \"POST\":\n return this._client.post<T>(req, responseType, this._body, signal);\n case \"PUT\":\n return this._client.put<T>(req, responseType, this._body, signal);\n case \"PATCH\":\n return this._client.patch<T>(req, responseType, this._body, signal);\n case \"DELETE\":\n return this._client.delete<T>(req, responseType, signal);\n case \"OPTIONS\":\n return this._client.options<T>(req, responseType, hasBody ? this._body : undefined, signal);\n default:\n return this._client.get<T>(req, responseType, signal);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["appendQueryToUrl", "url", "client", "method", "headers", "bodyData", "body", "params", "signal", "ms", "cloned", "finalUrl", "req", "responseType", "hasBody"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Hyperttp/Utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Hyperttp/Utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
package/Hyperttp/Utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";export{RequestBuilder}from"./RequestBuilder.js";export{appendQueryToUrl}from"./query.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Hyperttp/Utils/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { RequestBuilder } from \"./RequestBuilder.js\";\nexport { appendQueryToUrl } from \"./query.js\";\n"],
|
|
5
|
+
"mappings": "aAAA,OAAS,mBAAsB,sBAC/B,OAAS,qBAAwB",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/Hyperttp/Utils/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAoBzE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";export function appendQueryToUrl(o,n){try{const e=new URL(o);for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const t=n[r];if(t==null)continue;if(Array.isArray(t))for(const a of t)a!=null&&e.searchParams.append(r,String(a));else e.searchParams.set(r,String(t))}return e.toString()}catch{return o}}
|
|
2
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Hyperttp/Utils/query.ts"],
|
|
4
|
+
"sourcesContent": ["import type { RequestQuery } from \"@hyperttp/types\";\n\nexport function appendQueryToUrl(url: string, query: RequestQuery): string {\n try {\n const urlObj = new URL(url);\n for (const k in query) {\n if (Object.prototype.hasOwnProperty.call(query, k)) {\n const v = query[k];\n if (v == null) continue;\n if (Array.isArray(v)) {\n for (const item of v) {\n if (item != null) urlObj.searchParams.append(k, String(item));\n }\n } else {\n urlObj.searchParams.set(k, String(v));\n }\n }\n }\n return urlObj.toString();\n } catch {\n return url;\n }\n}\n"],
|
|
5
|
+
"mappings": "aAEM,gBAAU,iBAAiBA,EAAaC,EAAmB,CAC/D,GAAI,CACF,MAAMC,EAAS,IAAI,IAAIF,CAAG,EAC1B,UAAWG,KAAKF,EACd,GAAI,OAAO,UAAU,eAAe,KAAKA,EAAOE,CAAC,EAAG,CAClD,MAAMC,EAAIH,EAAME,CAAC,EACjB,GAAIC,GAAK,KAAM,SACf,GAAI,MAAM,QAAQA,CAAC,EACjB,UAAWC,KAAQD,EACbC,GAAQ,MAAMH,EAAO,aAAa,OAAOC,EAAG,OAAOE,CAAI,CAAC,OAG9DH,EAAO,aAAa,IAAIC,EAAG,OAAOC,CAAC,CAAC,CAExC,CAEF,OAAOF,EAAO,SAAQ,CACxB,MAAQ,CACN,OAAOF,CACT,CACF",
|
|
6
|
+
"names": ["url", "query", "urlObj", "k", "v", "item"]
|
|
7
|
+
}
|
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
export const defaultConfig
|
|
2
|
-
|
|
3
|
-
timeout: 30000,
|
|
4
|
-
maxConcurrent: 500,
|
|
5
|
-
pipelining: 10,
|
|
6
|
-
keepAliveTimeout: 30000,
|
|
7
|
-
followRedirects: true,
|
|
8
|
-
maxRedirects: 5,
|
|
9
|
-
rejectUnauthorized: true,
|
|
10
|
-
},
|
|
11
|
-
retry: {
|
|
12
|
-
maxRetries: 3,
|
|
13
|
-
baseDelay: 100,
|
|
14
|
-
maxDelay: 5000,
|
|
15
|
-
jitter: true,
|
|
16
|
-
},
|
|
17
|
-
metrics: {
|
|
18
|
-
enabled: true,
|
|
19
|
-
},
|
|
20
|
-
cache: {
|
|
21
|
-
enabled: true,
|
|
22
|
-
maxSize: 1000,
|
|
23
|
-
ttl: 60000,
|
|
24
|
-
},
|
|
25
|
-
interceptors: {
|
|
26
|
-
enabled: true,
|
|
27
|
-
},
|
|
28
|
-
rateLimit: {
|
|
29
|
-
enabled: true,
|
|
30
|
-
maxRequests: 10000,
|
|
31
|
-
windowMs: 1000,
|
|
32
|
-
},
|
|
33
|
-
queue: {
|
|
34
|
-
enabled: true,
|
|
35
|
-
},
|
|
36
|
-
verbose: false,
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=defaultConfig.js.map
|
|
1
|
+
"use strict";export const defaultConfig={network:{timeout:3e4,maxConcurrent:500,pipelining:10,keepAliveTimeout:3e4,followRedirects:!0,maxRedirects:5,rejectUnauthorized:!0},retry:{maxRetries:3,baseDelay:100,maxDelay:5e3,jitter:!0},metrics:{enabled:!0},cache:{enabled:!0,maxSize:1e3,ttl:6e4},interceptors:{enabled:!0},rateLimit:{enabled:!0,maxRequests:1e4,windowMs:1e3},queue:{enabled:!0},verbose:!1};
|
|
2
|
+
//# sourceMappingURL=defaultConfig.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Hyperttp/defaultConfig.ts"],
|
|
4
|
+
"sourcesContent": ["import type { HttpClientOptions } from \"@hyperttp/types\";\n\nexport const defaultConfig: HttpClientOptions = {\n network: {\n timeout: 30000,\n maxConcurrent: 500,\n pipelining: 10,\n keepAliveTimeout: 30000,\n followRedirects: true,\n maxRedirects: 5,\n rejectUnauthorized: true,\n },\n\n retry: {\n maxRetries: 3,\n baseDelay: 100,\n maxDelay: 5000,\n jitter: true,\n },\n\n metrics: {\n enabled: true,\n },\n\n cache: {\n enabled: true,\n maxSize: 1000,\n ttl: 60000,\n },\n\n interceptors: {\n enabled: true,\n },\n\n rateLimit: {\n enabled: true,\n maxRequests: 10000,\n windowMs: 1000,\n },\n\n queue: {\n enabled: true,\n },\n\n verbose: false,\n};\n"],
|
|
5
|
+
"mappings": "aAEO,aAAM,cAAmC,CAC9C,QAAS,CACP,QAAS,IACT,cAAe,IACf,WAAY,GACZ,iBAAkB,IAClB,gBAAiB,GACjB,aAAc,EACd,mBAAoB,IAGtB,MAAO,CACL,WAAY,EACZ,UAAW,IACX,SAAU,IACV,OAAQ,IAGV,QAAS,CACP,QAAS,IAGX,MAAO,CACL,QAAS,GACT,QAAS,IACT,IAAK,KAGP,aAAc,CACZ,QAAS,IAGX,UAAW,CACT,QAAS,GACT,YAAa,IACb,SAAU,KAGZ,MAAO,CACL,QAAS,IAGX,QAAS",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/Hyperttp/index.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export { PreparedRequest } from "./Request.js";
|
|
4
|
-
export { default as UrlExtractor } from "./UrlExtractor.js";
|
|
5
|
-
export * from "./Utils/index.js";
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";export{HyperClient}from"./Client/HyperClient.js";export{default as Request}from"./Request.js";export{PreparedRequest}from"./Request.js";export{default as UrlExtractor}from"./UrlExtractor.js";export*from"./Utils/index.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/Hyperttp/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Hyperttp/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { HyperClient } from \"./Client/HyperClient.js\";\nexport { default as Request } from \"./Request.js\";\nexport { PreparedRequest } from \"./Request.js\";\nexport { default as UrlExtractor } from \"./UrlExtractor.js\";\nexport * from \"./Utils/index.js\";\n"],
|
|
5
|
+
"mappings": "aAAA,OAAS,gBAAmB,0BAC5B,OAAS,WAAW,YAAe,eACnC,OAAS,oBAAuB,eAChC,OAAS,WAAW,iBAAoB,oBACxC,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/README.md
CHANGED
|
@@ -198,7 +198,6 @@ When using `HyperClient`, the following plugins are automatically registered:
|
|
|
198
198
|
|
|
199
199
|
| Plugin | Purpose |
|
|
200
200
|
| ------------------ | ----------------------------------------------------------- |
|
|
201
|
-
| `withSerializer` | Serializes request bodies (JSON, FormData, URLSearchParams) |
|
|
202
201
|
| `withParser` | Parses response bodies based on `responseType` |
|
|
203
202
|
| `withQueue` | Queues requests when concurrency limit is reached |
|
|
204
203
|
| `withRateLimit` | Enforces rate limits |
|
|
@@ -255,7 +254,7 @@ client.use({
|
|
|
255
254
|
```
|
|
256
255
|
┌─────────────────────────────────────────────────────────────────┐
|
|
257
256
|
│ HyperClient │
|
|
258
|
-
│ (Auto-wires:
|
|
257
|
+
│ (Auto-wires: Parser → Queue → RateLimit → │
|
|
259
258
|
│ Inflight → Cache → Interceptors → Metrics) │
|
|
260
259
|
└──────────────────────────┬──────────────────────────────────────┘
|
|
261
260
|
│
|
package/Types/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";export*from"./url-extractor.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/Types/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Types/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./url-extractor.js\";\n"],
|
|
5
|
+
"mappings": "aAAA,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/Types/url-extractor.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=url-extractor.js.map
|
|
1
|
+
"use strict";export{};
|
|
2
|
+
//# sourceMappingURL=url-extractor.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["url-extractor.js"],
|
|
4
|
+
"sourcesContent": ["export {};\n//# sourceMappingURL=url-extractor.js.map"],
|
|
5
|
+
"mappings": "aAAA",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { HyperClient } from "./Hyperttp/index.js";
|
|
1
|
+
export { HyperClient, RequestBuilder } from "./Hyperttp/index.js";
|
|
2
2
|
export { Request, PreparedRequest, UrlExtractor } from "./Hyperttp/index.js";
|
|
3
3
|
export type * from "./Types/index.js";
|
|
4
4
|
export * from "@hyperttp/cache";
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE7E,mBAAmB,kBAAkB,CAAC;AAEtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export * from "@hyperttp/cache";
|
|
4
|
-
export * from "@hyperttp/queue";
|
|
5
|
-
export * from "@hyperttp/ratelimit";
|
|
6
|
-
export * from "@hyperttp/interceptors";
|
|
7
|
-
export * from "@hyperttp/metrics";
|
|
8
|
-
export * from "@hyperttp/inflight";
|
|
9
|
-
export * from "@hyperttp/parser";
|
|
10
|
-
export * from "@hyperttp/serializer";
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";export{HyperClient,RequestBuilder}from"./Hyperttp/index.js";export{Request,PreparedRequest,UrlExtractor}from"./Hyperttp/index.js";export*from"@hyperttp/cache";export*from"@hyperttp/queue";export*from"@hyperttp/ratelimit";export*from"@hyperttp/interceptors";export*from"@hyperttp/metrics";export*from"@hyperttp/inflight";export*from"@hyperttp/parser";export*from"@hyperttp/serializer";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { HyperClient, RequestBuilder } from \"./Hyperttp/index.js\";\nexport { Request, PreparedRequest, UrlExtractor } from \"./Hyperttp/index.js\";\n\nexport type * from \"./Types/index.js\";\n\nexport * from \"@hyperttp/cache\";\nexport * from \"@hyperttp/queue\";\nexport * from \"@hyperttp/ratelimit\";\nexport * from \"@hyperttp/interceptors\";\nexport * from \"@hyperttp/metrics\";\nexport * from \"@hyperttp/inflight\";\nexport * from \"@hyperttp/parser\";\nexport * from \"@hyperttp/serializer\";\n"],
|
|
5
|
+
"mappings": "aAAA,OAAS,YAAa,mBAAsB,sBAC5C,OAAS,QAAS,gBAAiB,iBAAoB,sBAIvD,WAAc,kBACd,WAAc,kBACd,WAAc,sBACd,WAAc,yBACd,WAAc,oBACd,WAAc,qBACd,WAAc,mBACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperttp",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"description": "A high-performance, universal HTTP client for Node.js, Bun, Deno and Browser with caching, retries, queueing, rate limiting, cookies and logging.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@hyperttp/cache": "^1.1.6",
|
|
39
|
-
"@hyperttp/core": "^1.
|
|
39
|
+
"@hyperttp/core": "^1.5.0",
|
|
40
40
|
"@hyperttp/inflight": "^1.1.6",
|
|
41
41
|
"@hyperttp/interceptors": "^1.1.5",
|
|
42
42
|
"@hyperttp/metrics": "^1.2.0",
|