hyperttp 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Hyperttp/Core/CacheManager.d.ts +13 -54
- package/dist/Hyperttp/Core/CacheManager.d.ts.map +1 -1
- package/dist/Hyperttp/Core/CacheManager.js +28 -50
- package/dist/Hyperttp/Core/CacheManager.js.map +1 -1
- package/dist/Hyperttp/Core/HttpClientImproved.d.ts +19 -249
- package/dist/Hyperttp/Core/HttpClientImproved.d.ts.map +1 -1
- package/dist/Hyperttp/Core/HttpClientImproved.js +393 -173
- package/dist/Hyperttp/Core/HttpClientImproved.js.map +1 -1
- package/dist/Hyperttp/Core/QueueManager.d.ts.map +1 -1
- package/dist/Hyperttp/Core/QueueManager.js +0 -2
- package/dist/Hyperttp/Core/QueueManager.js.map +1 -1
- package/dist/Hyperttp/Core/RateLimiter.d.ts.map +1 -1
- package/dist/Hyperttp/Core/RateLimiter.js.map +1 -1
- package/dist/Hyperttp/Core/index.d.ts +7 -7
- package/dist/Hyperttp/Core/index.d.ts.map +1 -1
- package/dist/Hyperttp/Core/index.js +8 -8
- package/dist/Hyperttp/Core/index.js.map +1 -1
- package/dist/Hyperttp/Request.d.ts.map +1 -1
- package/dist/Hyperttp/Request.js +0 -1
- package/dist/Hyperttp/Request.js.map +1 -1
- package/dist/Hyperttp/UrlExtractor.d.ts.map +1 -1
- package/dist/Hyperttp/UrlExtractor.js +0 -1
- package/dist/Hyperttp/UrlExtractor.js.map +1 -1
- package/dist/Hyperttp/index.d.ts +4 -4
- package/dist/Hyperttp/index.d.ts.map +1 -1
- package/dist/Hyperttp/index.js +11 -11
- package/dist/Hyperttp/index.js.map +1 -1
- package/dist/Types/index.d.ts +256 -0
- package/dist/Types/index.d.ts.map +1 -1
- package/dist/Types/index.js +47 -0
- package/dist/Types/index.js.map +1 -1
- package/dist/Types/request.d.ts +1 -1
- package/dist/Types/request.d.ts.map +1 -1
- package/dist/Types/request.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/Types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RateLimiterConfig } from "../Hyperttp/Core";
|
|
2
|
+
import { ResponseType } from "./request";
|
|
1
3
|
/**
|
|
2
4
|
* Interface for a universal URL extractor
|
|
3
5
|
*/
|
|
@@ -28,5 +30,259 @@ export interface UrlPattern<T extends string = string> {
|
|
|
28
30
|
/** Names of the capturing groups to extract */
|
|
29
31
|
groupNames: T[];
|
|
30
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Base error class for HTTP client operations.
|
|
35
|
+
* Contains additional context about the failed request including status code, URL, and method.
|
|
36
|
+
*/
|
|
37
|
+
export declare class HttpClientError extends Error {
|
|
38
|
+
statusCode?: number | undefined;
|
|
39
|
+
originalError?: Error | undefined;
|
|
40
|
+
url?: string | undefined;
|
|
41
|
+
method?: string | undefined;
|
|
42
|
+
constructor(message: string, statusCode?: number | undefined, originalError?: Error | undefined, url?: string | undefined, method?: string | undefined);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when an HTTP request exceeds the configured timeout duration.
|
|
46
|
+
* Contains information about the URL and timeout value that caused the failure.
|
|
47
|
+
*/
|
|
48
|
+
export declare class TimeoutError extends HttpClientError {
|
|
49
|
+
constructor(url: string, timeout: number);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Error thrown when an HTTP request is rate limited by the server.
|
|
53
|
+
* Contains information about the URL and optional retry-after duration.
|
|
54
|
+
*/
|
|
55
|
+
export declare class RateLimitError extends HttpClientError {
|
|
56
|
+
retryAfter?: number | undefined;
|
|
57
|
+
constructor(url: string, retryAfter?: number | undefined);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Log level for HTTP client logging.
|
|
61
|
+
* Defines the verbosity of log output from the client.
|
|
62
|
+
*/
|
|
63
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
64
|
+
/**
|
|
65
|
+
* Function type for logging HTTP client events.
|
|
66
|
+
* Used to customize how the client logs various events like requests, responses, and errors.
|
|
67
|
+
*
|
|
68
|
+
* @param level - The severity level of the log message
|
|
69
|
+
* @param message - The log message content
|
|
70
|
+
* @param meta - Optional additional context or metadata
|
|
71
|
+
*/
|
|
72
|
+
export type LoggerFunction = (level: LogLevel, message: string, meta?: any) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Configuration options for HTTP request retry behavior.
|
|
75
|
+
* Defines how the client should handle failed requests and when to retry them.
|
|
76
|
+
*/
|
|
77
|
+
export interface RetryOptions {
|
|
78
|
+
/** Maximum number of retry attempts before giving up */
|
|
79
|
+
maxRetries: number;
|
|
80
|
+
/** Base delay in milliseconds between retry attempts (exponential backoff) */
|
|
81
|
+
baseDelay: number;
|
|
82
|
+
/** Maximum delay in milliseconds between retry attempts */
|
|
83
|
+
maxDelay: number;
|
|
84
|
+
/** HTTP status codes that should trigger a retry */
|
|
85
|
+
retryStatusCodes: number[];
|
|
86
|
+
/** Whether to add random jitter to retry delays to prevent thundering herd */
|
|
87
|
+
jitter: boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Function type for intercepting and modifying HTTP requests before they are sent.
|
|
91
|
+
* Request interceptors can modify the URL, method, headers, or body of outgoing requests.
|
|
92
|
+
*
|
|
93
|
+
* @param config - The request configuration object
|
|
94
|
+
* @returns A promise that resolves to the modified request configuration
|
|
95
|
+
*/
|
|
96
|
+
export type RequestInterceptor = (config: {
|
|
97
|
+
url: string;
|
|
98
|
+
method: string;
|
|
99
|
+
headers: Record<string, string>;
|
|
100
|
+
body?: string | Buffer;
|
|
101
|
+
}) => Promise<{
|
|
102
|
+
url: string;
|
|
103
|
+
method: string;
|
|
104
|
+
headers: Record<string, string>;
|
|
105
|
+
body?: string | Buffer;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Function type for intercepting and modifying HTTP responses before they are processed.
|
|
109
|
+
* Response interceptors can modify the status, headers, body, or URL of incoming responses.
|
|
110
|
+
*
|
|
111
|
+
* @param response - The response object containing status, headers, body, and URL
|
|
112
|
+
* @returns A promise that resolves to the modified response object
|
|
113
|
+
*/
|
|
114
|
+
export type ResponseInterceptor = (response: {
|
|
115
|
+
status: number;
|
|
116
|
+
headers: Record<string, any>;
|
|
117
|
+
body: Buffer;
|
|
118
|
+
url: string;
|
|
119
|
+
}) => Promise<{
|
|
120
|
+
status: number;
|
|
121
|
+
headers: Record<string, any>;
|
|
122
|
+
body: Buffer;
|
|
123
|
+
url: string;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Configuration options for the HttpClientImproved instance.
|
|
127
|
+
* Defines all the behavior settings for HTTP requests including timeouts, retries, caching, and more.
|
|
128
|
+
*/
|
|
129
|
+
export interface HttpClientOptions {
|
|
130
|
+
/** Request timeout in milliseconds (default: 15000) */
|
|
131
|
+
timeout?: number;
|
|
132
|
+
/** Maximum number of concurrent requests (default: 50) */
|
|
133
|
+
maxConcurrent?: number;
|
|
134
|
+
/** Maximum number of retry attempts for failed requests (default: 3) */
|
|
135
|
+
maxRetries?: number;
|
|
136
|
+
/** Cache time-to-live in milliseconds (default: 300000) */
|
|
137
|
+
cacheTTL?: number;
|
|
138
|
+
/** Maximum number of cached entries (default: 500) */
|
|
139
|
+
cacheMaxSize?: number;
|
|
140
|
+
/** Rate limiting configuration to prevent overwhelming servers */
|
|
141
|
+
rateLimit?: RateLimiterConfig;
|
|
142
|
+
/** User-Agent string for HTTP requests (default: "Hyperttp/0.1.0 Node.js") */
|
|
143
|
+
userAgent?: string;
|
|
144
|
+
/** Custom logger function for HTTP client events */
|
|
145
|
+
logger?: LoggerFunction;
|
|
146
|
+
/** Retry behavior configuration */
|
|
147
|
+
retryOptions?: Partial<RetryOptions>;
|
|
148
|
+
/** Whether to automatically follow HTTP redirects (default: true) */
|
|
149
|
+
followRedirects?: boolean;
|
|
150
|
+
/** Maximum number of redirects to follow (default: 5) */
|
|
151
|
+
maxRedirects?: number;
|
|
152
|
+
/** Maximum response size in bytes (default: 1MB) */
|
|
153
|
+
maxResponseBytes?: number;
|
|
154
|
+
/** Function to validate HTTP status codes (default: 200-299) */
|
|
155
|
+
validateStatus?: (status: number) => boolean;
|
|
156
|
+
/** HTTP methods that should be cached (default: ["GET", "HEAD"]) */
|
|
157
|
+
cacheMethods?: string[];
|
|
158
|
+
/** Maximum number of request metrics to store (default: 10000) */
|
|
159
|
+
maxMetricsSize?: number;
|
|
160
|
+
/** Whether to enable verbose logging (default: false) */
|
|
161
|
+
verbose?: boolean;
|
|
162
|
+
/** Whether to enable request queuing (default: true) */
|
|
163
|
+
enableQueue?: boolean;
|
|
164
|
+
/** Whether to enable rate limiting (default: true) */
|
|
165
|
+
enableRateLimit?: boolean;
|
|
166
|
+
/** Whether to enable caching (default: true) */
|
|
167
|
+
enableCache?: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Interface for defining HTTP request parameters.
|
|
171
|
+
* Used to encapsulate URL, headers, and body data for HTTP requests.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* class ApiRequest implements RequestInterface {
|
|
176
|
+
* constructor(
|
|
177
|
+
* private url: string,
|
|
178
|
+
* private headers: Record<string, string> = {},
|
|
179
|
+
* private body?: any
|
|
180
|
+
* ) {}
|
|
181
|
+
*
|
|
182
|
+
* getURL(): string { return this.url; }
|
|
183
|
+
* getHeaders(): Record<string, string> { return this.headers; }
|
|
184
|
+
* getBodyData(): any { return this.body; }
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export interface RequestInterface {
|
|
189
|
+
/** Returns the full URL for the HTTP request */
|
|
190
|
+
getURL(): string;
|
|
191
|
+
/** Returns the request body data (string, Buffer, or any serializable object) */
|
|
192
|
+
getBodyData(): any;
|
|
193
|
+
/** Returns the HTTP headers for the request */
|
|
194
|
+
getHeaders(): Record<string, string>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Interface defining the contract for HTTP client implementations.
|
|
198
|
+
* Provides methods for making HTTP requests with various HTTP methods.
|
|
199
|
+
*/
|
|
200
|
+
export interface HttpClientInterface {
|
|
201
|
+
/**
|
|
202
|
+
* Makes an HTTP GET request
|
|
203
|
+
* @param req - Request configuration or URL string
|
|
204
|
+
* @param responseType - Expected response type (default: "json")
|
|
205
|
+
* @returns Promise resolving to the response data
|
|
206
|
+
*/
|
|
207
|
+
get<T = any>(req: RequestInterface | string, responseType?: ResponseType): Promise<T>;
|
|
208
|
+
/**
|
|
209
|
+
* Makes an HTTP POST request
|
|
210
|
+
* @param req - Request configuration or URL string
|
|
211
|
+
* @param body - Request body data
|
|
212
|
+
* @param responseType - Expected response type (default: "json")
|
|
213
|
+
* @returns Promise resolving to the response data
|
|
214
|
+
*/
|
|
215
|
+
post<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
216
|
+
/**
|
|
217
|
+
* Makes an HTTP PUT request
|
|
218
|
+
* @param req - Request configuration or URL string
|
|
219
|
+
* @param body - Request body data
|
|
220
|
+
* @param responseType - Expected response type (default: "json")
|
|
221
|
+
* @returns Promise resolving to the response data
|
|
222
|
+
*/
|
|
223
|
+
put<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
|
|
224
|
+
stream(req: RequestInterface | string): Promise<StreamResponse>;
|
|
225
|
+
/**
|
|
226
|
+
* Makes an HTTP DELETE request
|
|
227
|
+
* @param req - Request configuration or URL string
|
|
228
|
+
* @param responseType - Expected response type (default: "json")
|
|
229
|
+
* @returns Promise resolving to the response data
|
|
230
|
+
*/
|
|
231
|
+
delete<T = any>(req: RequestInterface | string, responseType?: ResponseType): Promise<T>;
|
|
232
|
+
/**
|
|
233
|
+
* Makes an HTTP PATCH request
|
|
234
|
+
* @param req - Request configuration
|
|
235
|
+
* @param responseType - Expected response type (default: "json")
|
|
236
|
+
* @returns Promise resolving to the response data
|
|
237
|
+
*/
|
|
238
|
+
patch<T = any>(req: RequestInterface | string, responseType?: ResponseType): Promise<T>;
|
|
239
|
+
/**
|
|
240
|
+
* Makes an HTTP HEAD request
|
|
241
|
+
* @param req - Request configuration or URL string
|
|
242
|
+
* @returns Promise resolving to status and headers
|
|
243
|
+
*/
|
|
244
|
+
head(req: RequestInterface | string): Promise<{
|
|
245
|
+
status: number;
|
|
246
|
+
headers: Record<string, any>;
|
|
247
|
+
}>;
|
|
248
|
+
/**
|
|
249
|
+
* Clears the internal cache of the HTTP client
|
|
250
|
+
*/
|
|
251
|
+
clearCache(): void;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Metrics collected for HTTP requests to monitor performance and behavior.
|
|
255
|
+
* Contains timing information, response details, and caching information.
|
|
256
|
+
*/
|
|
257
|
+
export interface RequestMetrics {
|
|
258
|
+
/** Timestamp when the request started */
|
|
259
|
+
startTime: number;
|
|
260
|
+
/** Timestamp when the request completed */
|
|
261
|
+
endTime: number;
|
|
262
|
+
/** Total duration of the request in milliseconds */
|
|
263
|
+
duration: number;
|
|
264
|
+
/** HTTP status code of the response (if available) */
|
|
265
|
+
statusCode?: number;
|
|
266
|
+
/** Number of bytes received in the response */
|
|
267
|
+
bytesReceived: number;
|
|
268
|
+
/** Number of bytes sent in the request body */
|
|
269
|
+
bytesSent: number;
|
|
270
|
+
/** Number of retry attempts made for this request */
|
|
271
|
+
retries: number;
|
|
272
|
+
/** Whether the response was served from cache */
|
|
273
|
+
cached: boolean;
|
|
274
|
+
/** URL of the request */
|
|
275
|
+
url: string;
|
|
276
|
+
/** HTTP method used (GET, POST, etc.) */
|
|
277
|
+
method: string;
|
|
278
|
+
/** Hash of the request body for cache key generation */
|
|
279
|
+
bodyHash?: string;
|
|
280
|
+
}
|
|
281
|
+
export interface StreamResponse {
|
|
282
|
+
status: number;
|
|
283
|
+
headers: Record<string, any>;
|
|
284
|
+
body: AsyncIterable<Uint8Array>;
|
|
285
|
+
url: string;
|
|
286
|
+
}
|
|
31
287
|
export * from "./request";
|
|
32
288
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAEjE;;;;;;OAMG;IACH,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACjC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACnD,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IAEf,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,UAAU,EAAE,CAAC,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAG/B,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,KAAK;IACrB,GAAG,CAAC,EAAE,MAAM;IACZ,MAAM,CAAC,EAAE,MAAM;gBAJtB,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,KAAK,YAAA,EACrB,GAAG,CAAC,EAAE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M,CAAC;CACb;AAED,cAAc,WAAW,CAAC"}
|
package/dist/Types/index.js
CHANGED
|
@@ -14,5 +14,52 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.RateLimitError = exports.TimeoutError = exports.HttpClientError = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* Base error class for HTTP client operations.
|
|
20
|
+
* Contains additional context about the failed request including status code, URL, and method.
|
|
21
|
+
*/
|
|
22
|
+
class HttpClientError extends Error {
|
|
23
|
+
statusCode;
|
|
24
|
+
originalError;
|
|
25
|
+
url;
|
|
26
|
+
method;
|
|
27
|
+
constructor(message, statusCode, originalError, url, method) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.statusCode = statusCode;
|
|
30
|
+
this.originalError = originalError;
|
|
31
|
+
this.url = url;
|
|
32
|
+
this.method = method;
|
|
33
|
+
this.name = "HttpClientError";
|
|
34
|
+
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.HttpClientError = HttpClientError;
|
|
38
|
+
/**
|
|
39
|
+
* Error thrown when an HTTP request exceeds the configured timeout duration.
|
|
40
|
+
* Contains information about the URL and timeout value that caused the failure.
|
|
41
|
+
*/
|
|
42
|
+
class TimeoutError extends HttpClientError {
|
|
43
|
+
constructor(url, timeout) {
|
|
44
|
+
super(`Request timeout after ${timeout}ms for ${url}`);
|
|
45
|
+
this.name = "TimeoutError";
|
|
46
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.TimeoutError = TimeoutError;
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when an HTTP request is rate limited by the server.
|
|
52
|
+
* Contains information about the URL and optional retry-after duration.
|
|
53
|
+
*/
|
|
54
|
+
class RateLimitError extends HttpClientError {
|
|
55
|
+
retryAfter;
|
|
56
|
+
constructor(url, retryAfter) {
|
|
57
|
+
super(`Rate limited for ${url}${retryAfter ? `, retry after ${retryAfter}ms` : ""}`);
|
|
58
|
+
this.retryAfter = retryAfter;
|
|
59
|
+
this.name = "RateLimitError";
|
|
60
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.RateLimitError = RateLimitError;
|
|
17
64
|
__exportStar(require("./request"), exports);
|
|
18
65
|
//# sourceMappingURL=index.js.map
|
package/dist/Types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA0CA;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAG/B;IACA;IACA;IACA;IALT,YACE,OAAe,EACR,UAAmB,EACnB,aAAqB,EACrB,GAAY,EACZ,MAAe;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QALR,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;QAC9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;CACF;AAZD,0CAYC;AAED;;;GAGG;AACH,MAAa,YAAa,SAAQ,eAAe;IAC/C,YAAY,GAAW,EAAE,OAAe;QACtC,KAAK,CAAC,yBAAyB,OAAO,UAAU,GAAG,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACF;AAND,oCAMC;AAED;;;GAGG;AACH,MAAa,cAAe,SAAQ,eAAe;IAGxC;IAFT,YACE,GAAW,EACJ,UAAmB;QAE1B,KAAK,CACH,oBAAoB,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,iBAAiB,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9E,CAAC;QAJK,eAAU,GAAV,UAAU,CAAS;QAK1B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACF;AAXD,wCAWC;AA2QD,4CAA0B"}
|
package/dist/Types/request.d.ts
CHANGED
|
@@ -132,5 +132,5 @@ export interface HttpClientOptions {
|
|
|
132
132
|
timeout?: number;
|
|
133
133
|
responseType?: ResponseType;
|
|
134
134
|
}
|
|
135
|
-
export type ResponseType = "json" | "text" | "buffer" | "xml";
|
|
135
|
+
export type ResponseType = "json" | "text" | "buffer" | "xml" | "stream";
|
|
136
136
|
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/Types/request.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1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AC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/Types/request.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { HttpClientImproved, QueueManager, CacheManager, RateLimiter, Request, PreparedRequest, UrlExtractor, } from "./Hyperttp";
|
|
2
|
-
export type * from "./Types";
|
|
1
|
+
export { HttpClientImproved, QueueManager, CacheManager, RateLimiter, Request, PreparedRequest, UrlExtractor, } from "./Hyperttp/index.js";
|
|
2
|
+
export type * from "./Types/index.js";
|
|
3
|
+
export type * from "./Types/request.js";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,OAAO,EACP,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UrlExtractor = exports.PreparedRequest = exports.Request = exports.RateLimiter = exports.CacheManager = exports.QueueManager = exports.HttpClientImproved = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "HttpClientImproved", { enumerable: true, get: function () { return
|
|
6
|
-
Object.defineProperty(exports, "QueueManager", { enumerable: true, get: function () { return
|
|
7
|
-
Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return
|
|
8
|
-
Object.defineProperty(exports, "RateLimiter", { enumerable: true, get: function () { return
|
|
9
|
-
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return
|
|
10
|
-
Object.defineProperty(exports, "PreparedRequest", { enumerable: true, get: function () { return
|
|
11
|
-
Object.defineProperty(exports, "UrlExtractor", { enumerable: true, get: function () { return
|
|
4
|
+
var index_js_1 = require("./Hyperttp/index.js");
|
|
5
|
+
Object.defineProperty(exports, "HttpClientImproved", { enumerable: true, get: function () { return index_js_1.HttpClientImproved; } });
|
|
6
|
+
Object.defineProperty(exports, "QueueManager", { enumerable: true, get: function () { return index_js_1.QueueManager; } });
|
|
7
|
+
Object.defineProperty(exports, "CacheManager", { enumerable: true, get: function () { return index_js_1.CacheManager; } });
|
|
8
|
+
Object.defineProperty(exports, "RateLimiter", { enumerable: true, get: function () { return index_js_1.RateLimiter; } });
|
|
9
|
+
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return index_js_1.Request; } });
|
|
10
|
+
Object.defineProperty(exports, "PreparedRequest", { enumerable: true, get: function () { return index_js_1.PreparedRequest; } });
|
|
11
|
+
Object.defineProperty(exports, "UrlExtractor", { enumerable: true, get: function () { return index_js_1.UrlExtractor; } });
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,gDAQ6B;AAP3B,8GAAA,kBAAkB,OAAA;AAClB,wGAAA,YAAY,OAAA;AACZ,wGAAA,YAAY,OAAA;AACZ,uGAAA,WAAW,OAAA;AACX,mGAAA,OAAO,OAAA;AACP,2GAAA,eAAe,OAAA;AACf,wGAAA,YAAY,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperttp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "A high-performance, universal HTTP client for Node.js with caching, retries, queueing, rate limiting, cookies and logging.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"logger"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"undici": "^
|
|
27
|
-
"tough-cookie": "^6.0.
|
|
26
|
+
"undici": "^8.0.2",
|
|
27
|
+
"tough-cookie": "^6.0.1",
|
|
28
28
|
"http-cookie-agent": "^7.0.3",
|
|
29
|
-
"fast-xml-parser": "^5.5.
|
|
30
|
-
"lru-cache": "^11.
|
|
29
|
+
"fast-xml-parser": "^5.5.10",
|
|
30
|
+
"lru-cache": "^11.3.0"
|
|
31
31
|
}
|
|
32
32
|
}
|